This module contains the function to initialize a ONE application instance.
- Source:
Methods
(static) getInstanceDirectory() → {string|undefined}
- Source:
Returns:
Returns instance directory
Type: string | undefined
(static) getInstanceName() → {string|undefined}
- Source:
Returns:
Returns the name
property of the Instance object of the
currently active instance, or undefined
if the instance has not been initialized yet
Type: string | undefined
(static) getInstanceIdHash() → {SHA256IdHash.<Instance>|undefined}
- Source:
Returns:
Returns the ID hash of the instance
Type: SHA256IdHash.<Instance> | undefined
(static) getInstanceOwnerIdHash() → {undefined|SHA256IdHash.<Person>}
- Source:
Returns:
Returns the ID hash of the instance owner person object
Type: undefined | SHA256IdHash.<Person>
(static) getInstanceOwnerEmail() → {string|undefined}
- Source:
Returns:
Returns the instance owner email
Type: string | undefined
(async, static) initInstance(options) → {Promise.<Instance>}
Parameters:
Name | Type | Description |
---|---|---|
options |
InstanceOptions | A mandatory object with options properties |
Load the map files used by the app. If bootstrapping fails because the bootstrap objects don't exist they are silently created.
- Source:
Returns:
Returns the Instance object
Type: Promise.<Instance>
(async, static) registerRecipes(recipes) → {Array.<ObjectCreation>}
Parameters:
Name | Type | Description |
---|---|---|
recipes |
Array.<Recipe> | Array of ONE "Recipe" objects to add to the currently active instance permanently |
TODO REMOVE THIS FUNCTION - Just call instance-updater directly. This is a remnant from when calling that module was cumbersome because it was a Plan module.
Adds a recipe consisting of an array of objects of type RecipeRule for the given type string. The recipe's rules are checked for the property names and the corresponding types but no further: For example, if you forget "itemprop" (mandatory, a string) in a rule, or if you have the wrong type of item on a rule property an Error is thrown. However, for "type" and a rule's "itemprop" string property we only guard against HTML-breaking "<" and ">" and against whitespace, and we don't check if any other recipes you refer to exist and a wide range of conceivable problems.
A recipe for a ONE object type consists of arrays of objects describing the data properties. Allowed rule properties are explained in RecipeRule:
Example
The following code adds a recipe for a ONE object type "Mailbox":
import * as ObjectRecipes from 'one.core/lib/object-recipes';
if (!ObjectRecipes.hasRecipe('Mailbox')) {
ObjectRecipes.addRecipeToRuntime({
$type$: 'Recipe',
name: 'Mailbox',
rule: [
// A SHA-256 hash pointing to an OneTest$ImapAccount object that this mailbox
// belongs to. Both the account and the name are the ID attributes of this
// VERSIONED object, meaning any Mailbox object with the same account and name
// will be a version of the same object, varying only in the data properties not
// marked as "isID:true".
{ itemprop: 'account', isId: true, referenceToObj: new Set(['Reference','Account'])
},
{ itemprop: 'name', isId: true },
// This is an IMAP protocol feature to check if the IMAP-UIDs from last time are
// still valid. This 32-bit integer can be fully represented by a Javascript number.
{ itemprop: 'uidValidity', valueType: 'number' },
// A JSON-stringified UID => Email-BLOB-hash map
{ itemprop: 'uidEmailBlobMap', valueType: 'object' },
]
});
}
A ONE object created using this recipe would look like this (indentation and newlines added fore readability, not present in the actual microdata):
<div itemscope itemtype="//refin.io/Mailbox">
<span itemprop="account">8296cf598c1af767b5287....2bd96eae03448da3066aa</span>
<span itemprop="name">INBOX</span>
<span itemprop="uidValidity">1455785767</span>
<span itemprop="uidEmailBlobMap">...[JSON]...</span>
</span>
- Source:
Returns:
Returns the result of creating the new Instance object and the new Recipe objects
Type: Array.<ObjectCreation>
(static) closeInstance() → {undefined}
If initInstance() is to be called more than once close() must be called first. There can be only a single ONE instance in a runtime environment. This is used by mocha storage tests which do the same storage-init followed by storage-deletion for each test file.
- Source:
Returns:
Type: undefined
(static) closeAndDeleteCurrentInstance() → {Promise.<void>}
Closes & deletes the current instance.
When the InstanceIdHash is undefined the instance was not initialized or is already closed.
- Source:
Returns:
Type: Promise.<void>
(static) instanceExists(instanceName, email) → {Promise.<boolean>}
Parameters:
Name | Type | Description |
---|---|---|
instanceName |
InstanceOptions.name | |
email |
InstanceOptions.email |
Allows checking if an instance exists without an active instance.
- Source:
Returns:
Type: Promise.<boolean>
(static) deleteInstance(instanceName, email) → {Promise.<boolean>}
Parameters:
Name | Type | Description |
---|---|---|
instanceName |
InstanceOptions.name | |
email |
InstanceOptions.email |
Allows deleting an instance without an active instance. This is important e.g. in case of a forgotten password.
- Source:
Returns:
Type: Promise.<boolean>
(static) calculateInstanceIdHash(instanceName, email) → {Promise.<SHA256IdHash.<Instance>>}
Parameters:
Name | Type | Description |
---|---|---|
instanceName |
InstanceOptions.name | |
email |
InstanceOptions.email |
Allows to calculate an instanceIdHash without an active instance needed to
- check if an inactive instance exists
- delete an inactive instance
IMPORTANT: Needs to be adjusted by microdata changes
- Source:
Returns:
Type: Promise.<SHA256IdHash.<Instance>>