26.07 Storage Module
The Storage module is used to indicate the storage for artifacts. The Storage module introduces a new type Storage defined as
type Storage = Artifact[]
where all Artifact type objects in it MUST have an id member in their metadata and the id values MUST be unique.
interface Metadata {
id: string // REQUIRED if Storage module is in use
// ...
}
The id MUST be used to resolve the Artifact in Form to the Artifact in Storage, i.e., they are considered the same object. If two or more Artifact objects share the same id, the Artifact appearing first in the array MUST be considered the only Artifact with that id and the rest MUST be discarded.
The Storage module also introduces new members in FormProperties, defined as
interface FormProperties {
storage: "path" | "impl" // OPTIONAL
storagePath: string // OPTIONAL
storageOverwrite: boolean // OPTIONAL
storageEnforce: boolean // OPTIONAL
// ...
}
where
storageis OPTIONAL and its value MUST be one of those specified above. When it is provided, the Storage module is in use. When its value is"impl", the implementation MUST specify theStorageand use it to resolve the scene with theFormobject.storagePathis OPTIONAL and its value MUST be of typestringand MUST be a path or URL to a JSON file of theStoragedata used for theForm. If it is not provided, the default value"./storage.json"MUST be used. Its value MUST be ignored ifstoragehas a value other than"path".storageOverwriteis OPTIONAL and its value MUST be of typeboolean. If it is not provided, the default valuetrueMUST be used. Its value MUST be ignored ifstorageis not specified. When it istrue, any conflict between anArtifactinFormand anArtifactinStorageMUST be resolved in favor of theArtifactinStorage; when it isfalse, theArtifactinFormMUST be merged into the correspondingArtifactinStoragemember by member at every level, where each member present inFormoverwrites the corresponding member inStorage, and the mergedArtifactMUST be used, providing further customization of the scene in addition to theStoragedata.storageEnforceis OPTIONAL and its value MUST be of typeboolean. If it is not provided, the default valuetrueMUST be used. Its value MUST be ignored ifstorageis not specified. When it istrue, anyArtifactinFormthat is not present inStorageMUST be discarded.
When a storage value is provided, it is valid, though not recommended, to have an Artifact in Form containing only metadatawith an id, and use storageOverwrite to resolve it to the corresponding Artifact in Storage. Storage MUST contain the full information of the artifacts. If Storage is not provided or the relevant Artifact is missing from Storage, an Artifact missing a content or type member MUST be discarded.