@getodk/xforms-engine 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client/BaseNode.d.ts +8 -4
- package/dist/client/BaseValueNode.d.ts +8 -4
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +32 -3
- package/dist/client/ModelValueNode.d.ts +1 -0
- package/dist/client/NoteNode.d.ts +24 -7
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +21 -14
- package/dist/client/SelectNode.d.ts +47 -25
- package/dist/client/SubtreeNode.d.ts +1 -0
- package/dist/client/TriggerNode.d.ts +10 -6
- package/dist/client/constants.d.ts +11 -12
- package/dist/client/form/CreateFormInstance.d.ts +14 -0
- package/dist/client/form/EditFormInstance.d.ts +62 -0
- package/dist/client/form/FormInstance.d.ts +104 -0
- package/dist/client/form/FormInstanceConfig.d.ts +17 -0
- package/dist/client/form/FormResource.d.ts +1 -0
- package/dist/client/form/LoadForm.d.ts +79 -0
- package/dist/client/form/LoadFormResult.d.ts +67 -0
- package/dist/client/form/RestoreFormInstance.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +5 -5
- package/dist/client/index.d.ts +37 -11
- package/dist/client/node-types.d.ts +2 -2
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +3 -4
- package/dist/client/repeat/RepeatInstanceNode.d.ts +4 -5
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +2 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +2 -2
- package/dist/client/resources.d.ts +1 -1
- package/dist/client/serialization/InstanceData.d.ts +12 -0
- package/dist/client/serialization/InstanceFile.d.ts +6 -0
- package/dist/client/serialization/InstancePayload.d.ts +93 -0
- package/dist/client/serialization/InstancePayloadOptions.d.ts +23 -0
- package/dist/client/serialization/InstanceState.d.ts +12 -0
- package/dist/client/submission/{SubmissionDefinition.d.ts → SubmissionMeta.d.ts} +1 -1
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
- package/dist/entrypoints/FormInstance.d.ts +20 -0
- package/dist/entrypoints/FormResult/BaseFormResult.d.ts +22 -0
- package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +25 -0
- package/dist/entrypoints/FormResult/FormFailureResult.d.ts +17 -0
- package/dist/entrypoints/FormResult/FormSuccessResult.d.ts +15 -0
- package/dist/entrypoints/FormResult/FormWarningResult.d.ts +15 -0
- package/dist/entrypoints/createInstance.d.ts +9 -0
- package/dist/entrypoints/editInstance.d.ts +9 -0
- package/dist/entrypoints/index.d.ts +4 -0
- package/dist/entrypoints/loadForm.d.ts +4 -0
- package/dist/entrypoints/restoreInstance.d.ts +9 -0
- package/dist/error/LoadFormFailureError.d.ts +9 -0
- package/dist/error/MalformedInstanceDataError.d.ts +3 -0
- package/dist/error/RankMissingValueError.d.ts +3 -0
- package/dist/error/RankValueTypeError.d.ts +6 -0
- package/dist/error/SelectValueTypeError.d.ts +15 -0
- package/dist/error/TemplatedNodeAttributeSerializationError.d.ts +22 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -0
- package/dist/index.d.ts +2 -34
- package/dist/index.js +7274 -5840
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +7 -5
- package/dist/instance/InputControl.d.ts +9 -6
- package/dist/instance/ModelValue.d.ts +7 -4
- package/dist/instance/Note.d.ts +14 -25
- package/dist/instance/PrimaryInstance.d.ts +36 -8
- package/dist/instance/RangeControl.d.ts +35 -0
- package/dist/instance/RankControl.d.ts +41 -0
- package/dist/instance/Root.d.ts +8 -9
- package/dist/instance/SelectControl.d.ts +67 -0
- package/dist/instance/Subtree.d.ts +7 -5
- package/dist/instance/TriggerControl.d.ts +10 -22
- package/dist/instance/abstract/DescendantNode.d.ts +11 -3
- package/dist/instance/abstract/InstanceNode.d.ts +10 -5
- package/dist/instance/abstract/ValueNode.d.ts +7 -6
- package/dist/instance/children/DescendantNodeInitOptions.d.ts +32 -0
- package/dist/instance/{children.d.ts → children/buildChildren.d.ts} +1 -1
- package/dist/instance/children/childrenInitOptions.d.ts +9 -0
- package/dist/instance/children/normalizeChildInitOptions.d.ts +2 -0
- package/dist/instance/hierarchy.d.ts +9 -9
- package/dist/instance/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +2 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +10 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +14 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.d.ts +32 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +13 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableValueNode.d.ts +21 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +11 -8
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -7
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +27 -3
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +4 -3
- package/dist/instance/resource.d.ts +5 -1
- package/dist/instance/unsupported/UploadControl.d.ts +32 -4
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +2 -2
- package/dist/integration/xpath/adapter/kind.d.ts +4 -10
- package/dist/integration/xpath/adapter/names.d.ts +1 -11
- package/dist/integration/xpath/adapter/traversal.d.ts +10 -9
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +10 -4
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +13 -11
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +25 -18
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +1 -1
- package/dist/integration/xpath/static-dom/StaticParentNode.d.ts +13 -0
- package/dist/integration/xpath/static-dom/staticNodeName.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createNodeRangeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createParentNodeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createPrimaryInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createRootInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +6 -0
- package/dist/lib/client-reactivity/instance-state/createValueNodeInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/prepareInstancePayload.d.ts +8 -0
- package/dist/lib/codecs/Geopoint/Geopoint.d.ts +48 -0
- package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
- package/dist/lib/codecs/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/TempUnsupportedControlCodec.d.ts +7 -0
- package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
- package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
- package/dist/lib/codecs/ValueCodec.d.ts +2 -2
- package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
- package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +3 -2
- package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
- package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
- package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
- package/dist/lib/dom/query.d.ts +1 -2
- package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
- package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
- package/dist/lib/names/NamespaceURL.d.ts +30 -0
- package/dist/lib/names/QualifiedName.d.ts +113 -0
- package/dist/lib/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/number-parsers.d.ts +2 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
- package/dist/lib/xml-serialization.d.ts +11 -2
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -2
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/InputControlDefinition.d.ts +3 -0
- package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
- package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
- package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
- package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
- package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
- package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
- package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
- package/dist/parse/model/BindDefinition.d.ts +3 -1
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -13
- package/dist/parse/model/ItextTranslationsDefinition.d.ts +18 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +9 -7
- package/dist/parse/model/ModelDefinition.d.ts +9 -2
- package/dist/parse/model/NodeDefinition.d.ts +30 -45
- package/dist/parse/model/NoteNodeDefinition.d.ts +7 -5
- package/dist/parse/model/RangeNodeDefinition.d.ts +42 -0
- package/dist/parse/model/RepeatDefinition.d.ts +62 -0
- package/dist/parse/model/RootAttributeDefinition.d.ts +21 -0
- package/dist/parse/model/RootAttributeMap.d.ts +24 -0
- package/dist/parse/model/RootDefinition.d.ts +15 -14
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +15 -2
- package/dist/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/defineSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +1 -7
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/{FormSubmissionDefinition.d.ts → SubmissionDefinition.d.ts} +2 -2
- package/dist/parse/model/SubtreeDefinition.d.ts +9 -7
- package/dist/parse/model/nodeDefinitionMap.d.ts +5 -0
- package/dist/parse/shared/parseInstanceXML.d.ts +21 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +4 -22
- package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
- package/dist/parse/xpath/semantic-analysis.d.ts +1 -3
- package/dist/solid.js +7247 -5813
- package/dist/solid.js.map +1 -1
- package/package.json +15 -12
- package/src/client/BaseNode.ts +9 -4
- package/src/client/BaseValueNode.ts +8 -4
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +38 -2
- package/src/client/ModelValueNode.ts +1 -0
- package/src/client/NoteNode.ts +43 -7
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +30 -16
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/constants.ts +12 -14
- package/src/client/form/CreateFormInstance.ts +19 -0
- package/src/client/form/EditFormInstance.ts +93 -0
- package/src/client/form/FormInstance.ts +114 -0
- package/src/client/form/FormInstanceConfig.ts +18 -0
- package/src/client/form/FormResource.ts +1 -0
- package/src/client/form/LoadForm.ts +92 -0
- package/src/client/form/LoadFormResult.ts +103 -0
- package/src/client/form/RestoreFormInstance.ts +14 -0
- package/src/client/hierarchy.ts +7 -8
- package/src/client/index.ts +47 -29
- package/src/client/node-types.ts +3 -5
- package/src/client/repeat/BaseRepeatRangeNode.ts +3 -4
- package/src/client/repeat/RepeatInstanceNode.ts +4 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +2 -2
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +2 -2
- package/src/client/resources.ts +2 -2
- package/src/client/serialization/InstanceData.ts +16 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +28 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
- package/src/entrypoints/FormInstance.ts +55 -0
- package/src/entrypoints/FormResult/BaseFormResult.ts +40 -0
- package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +109 -0
- package/src/entrypoints/FormResult/FormFailureResult.ts +44 -0
- package/src/entrypoints/FormResult/FormSuccessResult.ts +25 -0
- package/src/entrypoints/FormResult/FormWarningResult.ts +25 -0
- package/src/entrypoints/createInstance.ts +23 -0
- package/src/entrypoints/editInstance.ts +24 -0
- package/src/entrypoints/index.ts +4 -0
- package/src/entrypoints/loadForm.ts +154 -0
- package/src/entrypoints/restoreInstance.ts +27 -0
- package/src/error/LoadFormFailureError.ts +114 -0
- package/src/error/MalformedInstanceDataError.ts +3 -0
- package/src/error/RankMissingValueError.ts +5 -0
- package/src/error/RankValueTypeError.ts +13 -0
- package/src/error/SelectValueTypeError.ts +22 -0
- package/src/error/TemplatedNodeAttributeSerializationError.ts +24 -0
- package/src/error/XFormsSpecViolationError.ts +1 -0
- package/src/index.ts +2 -56
- package/src/instance/Group.ts +17 -15
- package/src/instance/InputControl.ts +58 -12
- package/src/instance/ModelValue.ts +19 -11
- package/src/instance/Note.ts +40 -64
- package/src/instance/PrimaryInstance.ts +70 -31
- package/src/instance/RangeControl.ts +119 -0
- package/src/instance/RankControl.ts +208 -0
- package/src/instance/Root.ts +21 -31
- package/src/instance/SelectControl.ts +228 -0
- package/src/instance/Subtree.ts +17 -15
- package/src/instance/TriggerControl.ts +50 -80
- package/src/instance/abstract/DescendantNode.ts +13 -8
- package/src/instance/abstract/InstanceNode.ts +19 -7
- package/src/instance/abstract/ValueNode.ts +14 -15
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/children/buildChildren.ts +206 -0
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/hierarchy.ts +21 -16
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +142 -0
- package/src/instance/internal-api/InstanceConfig.ts +3 -10
- package/src/instance/internal-api/InstanceValueContext.ts +11 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +20 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.ts +43 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +26 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +24 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableValueNode.ts +28 -0
- package/src/instance/repeat/BaseRepeatRange.ts +21 -24
- package/src/instance/repeat/RepeatInstance.ts +27 -19
- package/src/instance/repeat/RepeatRangeControlled.ts +90 -17
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +10 -9
- package/src/instance/resource.ts +18 -2
- package/src/instance/unsupported/UploadControl.ts +116 -5
- package/src/integration/xpath/EngineXPathEvaluator.ts +2 -2
- package/src/integration/xpath/adapter/kind.ts +1 -28
- package/src/integration/xpath/adapter/names.ts +66 -17
- package/src/integration/xpath/adapter/traversal.ts +12 -11
- package/src/integration/xpath/static-dom/StaticAttribute.ts +16 -7
- package/src/integration/xpath/static-dom/StaticDocument.ts +17 -18
- package/src/integration/xpath/static-dom/StaticElement.ts +211 -52
- package/src/integration/xpath/static-dom/StaticNode.ts +1 -1
- package/src/integration/xpath/static-dom/StaticParentNode.ts +22 -0
- package/src/integration/xpath/static-dom/staticNodeName.ts +20 -0
- package/src/lib/client-reactivity/instance-state/createNodeRangeInstanceState.ts +17 -0
- package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +22 -0
- package/src/lib/client-reactivity/instance-state/createPrimaryInstanceState.ts +12 -0
- package/src/lib/client-reactivity/instance-state/createRootInstanceState.ts +19 -0
- package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +31 -0
- package/src/lib/client-reactivity/instance-state/createValueNodeInstanceState.ts +21 -0
- package/src/lib/client-reactivity/instance-state/prepareInstancePayload.ts +173 -0
- package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/TempUnsupportedControlCodec.ts +32 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +2 -2
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +5 -3
- package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
- package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
- package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
- package/src/lib/dom/query.ts +1 -2
- package/src/lib/names/NamespaceDeclaration.ts +106 -0
- package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
- package/src/lib/names/NamespaceURL.ts +44 -0
- package/src/lib/names/QualifiedName.ts +170 -0
- package/src/lib/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/number-parsers.ts +25 -0
- package/src/lib/reactivity/createInstanceValueState.ts +69 -43
- package/src/lib/reactivity/{createSelectItems.ts → createItemCollection.ts} +41 -36
- package/src/lib/xml-serialization.ts +76 -9
- package/src/parse/XFormDOM.ts +141 -21
- package/src/parse/XFormDefinition.ts +1 -4
- package/src/parse/body/BodyDefinition.ts +4 -4
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +9 -0
- package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
- package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
- package/src/parse/body/control/RangeControlDefinition.ts +91 -6
- package/src/parse/body/control/RankControlDefinition.ts +25 -7
- package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
- package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
- package/src/parse/expression/ItemsetValueExpression.ts +1 -1
- package/src/parse/model/BindDefinition.ts +4 -0
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -25
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +13 -8
- package/src/parse/model/ModelDefinition.ts +36 -3
- package/src/parse/model/NodeDefinition.ts +38 -85
- package/src/parse/model/NoteNodeDefinition.ts +12 -10
- package/src/parse/model/RangeNodeDefinition.ts +119 -0
- package/src/parse/model/RepeatDefinition.ts +382 -0
- package/src/parse/model/RootAttributeDefinition.ts +44 -0
- package/src/parse/model/RootAttributeMap.ts +49 -0
- package/src/parse/model/RootDefinition.ts +42 -43
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +23 -2
- package/src/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.ts +14 -0
- package/src/parse/model/SecondaryInstance/defineSecondaryInstance.ts +32 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +3 -24
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +33 -86
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +64 -136
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +9 -7
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +1 -1
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +7 -7
- package/src/parse/model/{FormSubmissionDefinition.ts → SubmissionDefinition.ts} +2 -2
- package/src/parse/model/SubtreeDefinition.ts +15 -16
- package/src/parse/model/nodeDefinitionMap.ts +34 -0
- package/src/parse/shared/parseInstanceXML.ts +79 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +46 -131
- package/src/parse/text/ItemLabelDefinition.ts +1 -1
- package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
- package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
- package/src/parse/xpath/semantic-analysis.ts +4 -3
- package/dist/client/EngineConfig.d.ts +0 -79
- package/dist/client/submission/SubmissionData.d.ts +0 -7
- package/dist/client/submission/SubmissionInstanceFile.d.ts +0 -6
- package/dist/client/submission/SubmissionOptions.d.ts +0 -23
- package/dist/client/submission/SubmissionResult.d.ts +0 -91
- package/dist/client/submission/SubmissionState.d.ts +0 -12
- package/dist/client/unsupported/RangeNode.d.ts +0 -9
- package/dist/client/unsupported/RankNode.d.ts +0 -9
- package/dist/instance/SelectField.d.ts +0 -58
- package/dist/instance/abstract/UnsupportedControl.d.ts +0 -53
- package/dist/instance/index.d.ts +0 -8
- package/dist/instance/internal-api/ValueContext.d.ts +0 -23
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +0 -14
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +0 -31
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +0 -18
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +0 -17
- package/dist/instance/unsupported/RangeControl.d.ts +0 -6
- package/dist/instance/unsupported/RankControl.d.ts +0 -6
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +0 -17
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +0 -8
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/lib/reactivity/createValueState.d.ts +0 -40
- package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
- package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -9
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +0 -4
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +0 -8
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +0 -8
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +0 -14
- package/dist/parse/model/RepeatRangeDefinition.d.ts +0 -29
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +0 -28
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +0 -4
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +0 -7
- package/src/client/EngineConfig.ts +0 -84
- package/src/client/submission/SubmissionData.ts +0 -12
- package/src/client/submission/SubmissionInstanceFile.ts +0 -9
- package/src/client/submission/SubmissionOptions.ts +0 -28
- package/src/client/submission/SubmissionResult.ts +0 -124
- package/src/client/submission/SubmissionState.ts +0 -14
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -263
- package/src/instance/abstract/UnsupportedControl.ts +0 -174
- package/src/instance/children.ts +0 -158
- package/src/instance/index.ts +0 -55
- package/src/instance/internal-api/ValueContext.ts +0 -28
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +0 -20
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +0 -42
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +0 -25
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +0 -23
- package/src/instance/unsupported/RangeControl.ts +0 -9
- package/src/instance/unsupported/RankControl.ts +0 -9
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +0 -45
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +0 -12
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +0 -20
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +0 -17
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +0 -22
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +0 -21
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +0 -172
- package/src/lib/reactivity/createValueState.ts +0 -200
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -21
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +0 -4
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +0 -41
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +0 -31
- package/src/parse/model/RepeatInstanceDefinition.ts +0 -34
- package/src/parse/model/RepeatRangeDefinition.ts +0 -94
- package/src/parse/model/RepeatTemplateDefinition.ts +0 -145
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +0 -4
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +0 -12
|
@@ -1,25 +1,31 @@
|
|
|
1
|
+
import type { TriggerRuntimeValue, TriggerValueType } from '../lib/codecs/TriggerCodec.ts';
|
|
1
2
|
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
2
3
|
import type { TriggerControlDefinition } from '../parse/body/control/TriggerControlDefinition.ts';
|
|
3
4
|
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
4
|
-
import type {
|
|
5
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
5
6
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
6
7
|
import type { RootNode } from './RootNode.ts';
|
|
7
8
|
import type { LeafNodeValidationState } from './validation.ts';
|
|
9
|
+
import type { ValueType } from './ValueType.ts';
|
|
8
10
|
|
|
9
|
-
export
|
|
11
|
+
export type TriggerValue = TriggerRuntimeValue;
|
|
12
|
+
|
|
13
|
+
export interface TriggerNodeState extends BaseValueNodeState<TriggerValue> {
|
|
10
14
|
get children(): null;
|
|
11
15
|
get valueOptions(): null;
|
|
12
|
-
get value():
|
|
16
|
+
get value(): TriggerValue;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
export interface TriggerNodeDefinition extends
|
|
19
|
+
export interface TriggerNodeDefinition<V extends ValueType = ValueType>
|
|
20
|
+
extends LeafNodeDefinition<V> {
|
|
16
21
|
readonly bodyElement: TriggerControlDefinition;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export interface TriggerNode extends
|
|
24
|
+
export interface TriggerNode extends BaseValueNode<TriggerValueType, TriggerValue> {
|
|
20
25
|
readonly nodeType: 'trigger';
|
|
21
|
-
readonly definition: TriggerNodeDefinition
|
|
26
|
+
readonly definition: TriggerNodeDefinition<TriggerValueType>;
|
|
22
27
|
readonly appearances: UnknownAppearanceDefinition;
|
|
28
|
+
readonly nodeOptions: null;
|
|
23
29
|
readonly root: RootNode;
|
|
24
30
|
readonly parent: GeneralParentNode;
|
|
25
31
|
readonly currentState: TriggerNodeState;
|
package/src/client/constants.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { InitializeForm } from './index.ts';
|
|
1
|
+
import type { LoadForm } from './form/LoadForm.ts';
|
|
3
2
|
import type { ValidationTextRole } from './TextRange.ts';
|
|
4
3
|
|
|
5
4
|
export const MISSING_RESOURCE_BEHAVIOR = {
|
|
6
5
|
/**
|
|
7
|
-
* When this behavior is configured, {@link
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* When this behavior is configured, {@link LoadForm | loading a form} which
|
|
7
|
+
* references any **missing** resources will fail, producing an error to the
|
|
8
|
+
* calling client.
|
|
10
9
|
*
|
|
11
10
|
* @see {@link MissingResourceBehavior}
|
|
12
11
|
*/
|
|
13
12
|
ERROR: 'ERROR',
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* When this behavior is configured, {@link
|
|
17
|
-
*
|
|
18
|
-
* resources will succeed (producing a warning).
|
|
15
|
+
* When this behavior is configured, {@link LoadForm | loading a form} which
|
|
16
|
+
* references any **missing** resources will succeed (producing a warning).
|
|
19
17
|
*
|
|
20
18
|
* Such missing resources will be parsed as if they are blank, as appropriate
|
|
21
19
|
* for the resource's XForm semantic usage and/or format.
|
|
@@ -39,8 +37,8 @@ export type MissingResourceBehaviorBlank = typeof MISSING_RESOURCE_BEHAVIOR.BLAN
|
|
|
39
37
|
export type MissingResourceBehaviorDefault = typeof MISSING_RESOURCE_BEHAVIOR.DEFAULT;
|
|
40
38
|
|
|
41
39
|
/**
|
|
42
|
-
* Specifies behavior for {@link
|
|
43
|
-
*
|
|
40
|
+
* Specifies behavior for {@link LoadForm | loading a form} which references any
|
|
41
|
+
* **missing** resources.
|
|
44
42
|
*
|
|
45
43
|
* Here the term "missing" is consistent with
|
|
46
44
|
* {@link https://www.rfc-editor.org/rfc/rfc9110#status.404 | HTTP 404 status}
|
|
@@ -70,8 +68,8 @@ type ValidationTextDefaults = typeof VALIDATION_TEXT;
|
|
|
70
68
|
|
|
71
69
|
export type ValidationTextDefault<Role extends ValidationTextRole> = ValidationTextDefaults[Role];
|
|
72
70
|
|
|
73
|
-
export const
|
|
74
|
-
export type
|
|
71
|
+
export const INSTANCE_FILE_NAME = 'xml_submission_file';
|
|
72
|
+
export type INSTANCE_FILE_NAME = typeof INSTANCE_FILE_NAME;
|
|
75
73
|
|
|
76
|
-
export const
|
|
77
|
-
export type
|
|
74
|
+
export const INSTANCE_FILE_TYPE = 'text/xml';
|
|
75
|
+
export type INSTANCE_FILE_TYPE = typeof INSTANCE_FILE_TYPE;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RootNode } from '../RootNode.ts';
|
|
2
|
+
import type { FormInstance, FormInstanceCreateMode } from './FormInstance.ts';
|
|
3
|
+
import type { FormInstanceConfig } from './FormInstanceConfig.ts';
|
|
4
|
+
import type { LoadForm } from './LoadForm.ts';
|
|
5
|
+
import type { LoadFormResult } from './LoadFormResult.ts';
|
|
6
|
+
|
|
7
|
+
export type CreatedFormInstance = FormInstance<FormInstanceCreateMode>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @todo This is fallible! Client-facing interfaces will need to account for
|
|
11
|
+
* this. We've begun addressing fallibility _at the interface level_ in
|
|
12
|
+
* {@link LoadForm} (with {@link LoadFormResult}). We'll eventually have a more
|
|
13
|
+
* general interface pattern for this, and we'll apply it here as well. The baby
|
|
14
|
+
* step approach in {@link LoadFormResult} is impractical here due to
|
|
15
|
+
* engine-internal designs, and revising that is currently out of scope. As
|
|
16
|
+
* such, explicit interface-level documentation of fallibility is deferred here,
|
|
17
|
+
* on {@link RootNode} itself, and into any of its sub-interfaces.
|
|
18
|
+
*/
|
|
19
|
+
export type CreateFormInstance = (config?: FormInstanceConfig) => CreatedFormInstance;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Awaitable, Thunk } from '@getodk/common/types/helpers.d.ts';
|
|
2
|
+
import type { FetchResourceResponse } from '../resources.ts';
|
|
3
|
+
import type { InstanceAttachmentFileName, InstanceData } from '../serialization/InstanceData.ts';
|
|
4
|
+
import type { FormInstance, FormInstanceEditMode } from './FormInstance.ts';
|
|
5
|
+
import type { FormInstanceConfig } from './FormInstanceConfig.ts';
|
|
6
|
+
import type { LoadForm } from './LoadForm.ts';
|
|
7
|
+
import type { RestoreFormInstance, RestoreFormInstanceInput } from './RestoreFormInstance.ts';
|
|
8
|
+
|
|
9
|
+
export type ResolvableFormInstanceInputType = 'FORM_INSTANCE_INPUT_RESOLVABLE';
|
|
10
|
+
export type ResolvedFormInstanceInputType = 'FORM_INSTANCE_INPUT_RESOLVED';
|
|
11
|
+
|
|
12
|
+
// prettier-ignore
|
|
13
|
+
export type EditFormInstanceInputType =
|
|
14
|
+
| ResolvableFormInstanceInputType
|
|
15
|
+
| ResolvedFormInstanceInputType;
|
|
16
|
+
|
|
17
|
+
// prettier-ignore
|
|
18
|
+
export type ResolvedFormInstance =
|
|
19
|
+
| Blob
|
|
20
|
+
| FetchResourceResponse
|
|
21
|
+
| File
|
|
22
|
+
| string;
|
|
23
|
+
|
|
24
|
+
export type ResolvableFormInstance = Thunk<Awaitable<ResolvedFormInstance>>;
|
|
25
|
+
|
|
26
|
+
export type ResolveFormInstanceResource = Thunk<Promise<FetchResourceResponse>>;
|
|
27
|
+
|
|
28
|
+
export type ResolvableInstanceAttachmentsMap = ReadonlyMap<
|
|
29
|
+
InstanceAttachmentFileName,
|
|
30
|
+
ResolveFormInstanceResource
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
interface BaseEditFormInstanceInput {
|
|
34
|
+
readonly inputType: EditFormInstanceInputType;
|
|
35
|
+
readonly data?: readonly [InstanceData, ...InstanceData[]];
|
|
36
|
+
readonly resolveInstance?: ResolvableFormInstance;
|
|
37
|
+
readonly attachments?: ResolvableInstanceAttachmentsMap;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ResolvableFormInstanceInput extends BaseEditFormInstanceInput {
|
|
41
|
+
readonly inputType: ResolvableFormInstanceInputType;
|
|
42
|
+
readonly resolveInstance: ResolvableFormInstance;
|
|
43
|
+
readonly attachments: ResolvableInstanceAttachmentsMap;
|
|
44
|
+
readonly data?: never;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @todo This is included as a strawman for discussiong: "should we accept input
|
|
49
|
+
* to {@link EditFormInstance} in the same shape as input to
|
|
50
|
+
* {@link RestoreFormInstance}?".
|
|
51
|
+
*
|
|
52
|
+
* Pros:
|
|
53
|
+
*
|
|
54
|
+
* - More consistency between the two entrypoint APIs, which are pretty similar
|
|
55
|
+
* _conceptually_.
|
|
56
|
+
* - ?
|
|
57
|
+
*
|
|
58
|
+
* Cons:
|
|
59
|
+
*
|
|
60
|
+
* - Less consistency between this entrypoint API and {@link LoadForm}, which is
|
|
61
|
+
* also responsible for loading arbitrary attachments (presumably over a
|
|
62
|
+
* network), which...
|
|
63
|
+
* - ... all but rules out flexibility to optimize loading large resources (i.e.
|
|
64
|
+
* streaming video/audio)
|
|
65
|
+
*
|
|
66
|
+
* Alternative:
|
|
67
|
+
*
|
|
68
|
+
* - Increase consistency across the board by inverting the relationship between
|
|
69
|
+
* edit/restore: {@link RestoreFormInstanceInput} could be the place where we
|
|
70
|
+
* accept a union of resolved | resolvable input, and clients which might
|
|
71
|
+
* benefit from this consistency could consolidate on the resolvable case
|
|
72
|
+
* without sacrificing resource loading optimizations)
|
|
73
|
+
*/
|
|
74
|
+
export interface ResolvedFormInstanceInput
|
|
75
|
+
extends BaseEditFormInstanceInput,
|
|
76
|
+
RestoreFormInstanceInput {
|
|
77
|
+
readonly inputType: ResolvedFormInstanceInputType;
|
|
78
|
+
readonly data: readonly [InstanceData, ...InstanceData[]];
|
|
79
|
+
readonly resolveInstance?: never;
|
|
80
|
+
readonly attachments?: never;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// prettier-ignore
|
|
84
|
+
export type EditFormInstanceInput =
|
|
85
|
+
| ResolvableFormInstanceInput
|
|
86
|
+
| ResolvedFormInstanceInput;
|
|
87
|
+
|
|
88
|
+
export type EditedFormInstance = FormInstance<FormInstanceEditMode>;
|
|
89
|
+
|
|
90
|
+
export type EditFormInstance = (
|
|
91
|
+
input: EditFormInstanceInput,
|
|
92
|
+
config?: FormInstanceConfig
|
|
93
|
+
) => Promise<EditedFormInstance>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { RootNode } from '../RootNode.ts';
|
|
2
|
+
import type { InstantiableLoadFormResult, LoadFormResult } from './LoadFormResult.ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents an instance which is newly created from a form definition.
|
|
6
|
+
*
|
|
7
|
+
* A newly created instance is populated with default values and state defined
|
|
8
|
+
* by the form.
|
|
9
|
+
*
|
|
10
|
+
* Computations are performed on initialization as specified by
|
|
11
|
+
* {@link https://getodk.github.io/xforms-spec/ | ODK XForms}, as the instance's
|
|
12
|
+
* {@link https://getodk.github.io/xforms-spec/#event:odk-instance-first-load | first load}.
|
|
13
|
+
*/
|
|
14
|
+
export type FormInstanceCreateMode = 'create';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents an instance restored from previously filled state, as represented
|
|
18
|
+
* in an {@link InstancePayload}. Clients may serialize and persist an instance
|
|
19
|
+
* payload as appropriate for their use cases, and can restore the instance with
|
|
20
|
+
* a partial instance payload structure, defined by the
|
|
21
|
+
* {@link RestoreFormInstanceInput} interface.
|
|
22
|
+
*
|
|
23
|
+
* A restored instance is populated by the engine with the answers as they had
|
|
24
|
+
* been filled at the time the {@link InstancePayload}
|
|
25
|
+
* ({@link RestoreFormInstanceInput}) was created.
|
|
26
|
+
*
|
|
27
|
+
* Computations are performed on initialization as specified by
|
|
28
|
+
* {@link https://getodk.github.io/xforms-spec/#event:odk-instance-load | ODK XForms},
|
|
29
|
+
* as a
|
|
30
|
+
* {@link https://getodk.github.io/xforms-spec/#event:odk-instance-load | subsequent load}
|
|
31
|
+
* (i.e. **NOT** "first load", as is the case with newly
|
|
32
|
+
* {@link FormInstanceCreateMode | created} instances}) of the instance.
|
|
33
|
+
*/
|
|
34
|
+
export type FormInstanceRestoreMode = 'restore';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Represents an instance which:
|
|
38
|
+
*
|
|
39
|
+
* - was previously serialized
|
|
40
|
+
* - was **submitted**, often referred to as a "submission" (noun)
|
|
41
|
+
* - is being initialized to produce an edited instance of that "submission"
|
|
42
|
+
*
|
|
43
|
+
* An edited instance may be populated from one or more network-accessible
|
|
44
|
+
* resources—its serialized instance XML, and any _instance attachments_—which
|
|
45
|
+
* are resolved in a manner similar to that of a form definition and its _form
|
|
46
|
+
* attachments_.
|
|
47
|
+
*
|
|
48
|
+
* Once resolved, an edited instance is restored from its previously filled
|
|
49
|
+
* state _as it was submitted_, consistent with
|
|
50
|
+
* {@link FormInstanceRestoreMode | restoring an instance}, with the following
|
|
51
|
+
* exceptions:
|
|
52
|
+
*
|
|
53
|
+
* - If the form or instance does not define an explicit
|
|
54
|
+
* {@link https://getodk.github.io/xforms-spec/#metadata | `deprecatedID` metadata element},
|
|
55
|
+
* one will be created.
|
|
56
|
+
*
|
|
57
|
+
* - If the instance has an `instanceID` metadata element, that element's value
|
|
58
|
+
* will be assigned to the instance's `deprecatedID`.
|
|
59
|
+
*
|
|
60
|
+
* - If applicable, a new instance id will be assigned:
|
|
61
|
+
*
|
|
62
|
+
* - If the instance has an `instanceID` metadata element, and the form
|
|
63
|
+
* explicitly defines a
|
|
64
|
+
* {@link https://getodk.github.io/xforms-spec/#preload-attributes | `uid` preload attribute}
|
|
65
|
+
* for its model binding, a new instance id value will be assigned to that
|
|
66
|
+
* element _as if it were the
|
|
67
|
+
* {@link https://getodk.github.io/xforms-spec/#event:odk-instance-first-load | instance's first load}_.
|
|
68
|
+
*
|
|
69
|
+
* - **Consistent with {@link FormInstanceCreateMode | instance creation}:**
|
|
70
|
+
* if the form **DOES NOT** define an `instanceID` element or model
|
|
71
|
+
* binding, the `uid` preload behavior described above is **implied** as
|
|
72
|
+
* the form's default behavior for that metadata; in which case whether
|
|
73
|
+
* the instance defines an `instanceID` element explicitly or not, it will
|
|
74
|
+
* be treated as if it had, behaving as described in the point above.
|
|
75
|
+
*
|
|
76
|
+
* **NOTE:** the behavior for an instance's `instanceID` metadata element and a
|
|
77
|
+
* form's `uid` preload attribute describe a special case, applying only to that
|
|
78
|
+
* specific preload attribute. In other words, when initializing instance state
|
|
79
|
+
* for editing:
|
|
80
|
+
*
|
|
81
|
+
* - The `odk-instance-first-load` event itself will **NOT** be triggered
|
|
82
|
+
* - Preload attributes _other than `uid`_ will **NOT** be recomputed
|
|
83
|
+
*
|
|
84
|
+
* **NOTE:** while the `uid` preload attribute is discussed above in terms of
|
|
85
|
+
* the `instanceID` meta element, its behavior is not applied specially to any
|
|
86
|
+
* particular node, regardless of
|
|
87
|
+
* {@link FormInstanceInitializationMode | initialization mode}.
|
|
88
|
+
*/
|
|
89
|
+
export type FormInstanceEditMode = 'edit';
|
|
90
|
+
|
|
91
|
+
// prettier-ignore
|
|
92
|
+
export type FormInstanceInitializationMode =
|
|
93
|
+
| FormInstanceCreateMode
|
|
94
|
+
| FormInstanceEditMode
|
|
95
|
+
| FormInstanceRestoreMode;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @todo this could hypothetically convey warnings and/or errors, just as
|
|
99
|
+
* {@link LoadFormResult} does. This has been deferred because:
|
|
100
|
+
*
|
|
101
|
+
* - We really want a more thoughtful design for Result types
|
|
102
|
+
* - The `try`/`catch` approach to capturing all errors takes a huge performance
|
|
103
|
+
* hit, which we should not incur if we have a more thoughtful design coming
|
|
104
|
+
* eventually. It would be too easy to forget about, indefinitely!
|
|
105
|
+
*/
|
|
106
|
+
export interface FormInstance<Mode extends FormInstanceInitializationMode> {
|
|
107
|
+
readonly formResult: InstantiableLoadFormResult;
|
|
108
|
+
readonly mode: Mode;
|
|
109
|
+
readonly root: RootNode;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type AnyFormInstance = {
|
|
113
|
+
[Mode in FormInstanceInitializationMode]: FormInstance<Mode>;
|
|
114
|
+
}[FormInstanceInitializationMode];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OpaqueReactiveObjectFactory } from '../OpaqueReactiveObjectFactory.ts';
|
|
2
|
+
|
|
3
|
+
export interface FormInstanceConfig {
|
|
4
|
+
/**
|
|
5
|
+
* A client may specify a generic function for constructing stateful objects.
|
|
6
|
+
* The only hard requirement of this function is that it accepts an **object**
|
|
7
|
+
* and returns an object of the same shape. The engine will use this function
|
|
8
|
+
* to initialize client-facing state, and will mutate properties of the object
|
|
9
|
+
* when their corresponding state is changed.
|
|
10
|
+
*
|
|
11
|
+
* A client may use this function to provide its own implementation of
|
|
12
|
+
* reactivity with semantics like those described above. The mechanism of
|
|
13
|
+
* reactivity, if any, is at the discretion of the client. It is expected that
|
|
14
|
+
* clients providing this function will use a reactive subscribe-on-read
|
|
15
|
+
* mechanism to handle state updates conveyed by the engine.
|
|
16
|
+
*/
|
|
17
|
+
readonly stateFactory?: OpaqueReactiveObjectFactory;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FormResource = Blob | File | URL | string;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { loadForm } from '../../entrypoints/loadForm.ts';
|
|
2
|
+
import type { MissingResourceBehavior } from '../constants.ts';
|
|
3
|
+
import type { FetchFormAttachment, FetchResource } from '../resources.ts';
|
|
4
|
+
import type { FormResource } from './FormResource.ts';
|
|
5
|
+
import type { LoadFormFailureResult, LoadFormResult } from './LoadFormResult.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see {@link LoadForm}
|
|
9
|
+
*/
|
|
10
|
+
export interface FormLoadPromise<T> extends PromiseLike<T> {}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Any fetch-like {@link LoadFormOptions | form loading options} which are not
|
|
14
|
+
* provided will default to the global {@link fetch} function, if one is
|
|
15
|
+
* available in the calling environment. If a global {@link fetch} function is
|
|
16
|
+
* _is not available_, and if the associated form loading option is required for
|
|
17
|
+
* the provided {@link FormResource} to be loaded, a
|
|
18
|
+
* {@link LoadFormFailureResult} will be produced.
|
|
19
|
+
*/
|
|
20
|
+
export type GlobalFetchDefault = typeof fetch;
|
|
21
|
+
|
|
22
|
+
export interface LoadFormOptions {
|
|
23
|
+
/**
|
|
24
|
+
* A client may specify an arbitrary {@link fetch}-like function for
|
|
25
|
+
* retrieving an XML XForm form definition.
|
|
26
|
+
*
|
|
27
|
+
* Calls to {@link loadForm | load a form} from a form definition provided as
|
|
28
|
+
* either a raw XML string or {@link Blob} data containing an XML string, this
|
|
29
|
+
* option will be ignored.
|
|
30
|
+
*
|
|
31
|
+
* Calls to load a form by {@link URL} will consult this option, if defined.
|
|
32
|
+
*
|
|
33
|
+
* If this option is omitted, loading a form by URL will use the
|
|
34
|
+
* {@link GlobalFetchDefault | global fetch function} by default.
|
|
35
|
+
*/
|
|
36
|
+
readonly fetchFormDefinition?: FetchResource;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A client may specify an arbitrary {@link fetch}-like function to retrieve a
|
|
40
|
+
* form's attachments, i.e. any `jr:` URL referenced by the form (as specified
|
|
41
|
+
* by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
|
|
42
|
+
*
|
|
43
|
+
* As part of {@link loadForm | loading a form}, once the form definition
|
|
44
|
+
* itself is resolved, this option (if provided) will be consulted to load any
|
|
45
|
+
* form attachments referenced by the form definition.
|
|
46
|
+
*
|
|
47
|
+
* If this option is omitted, the engine will attempt to load form attachments
|
|
48
|
+
* by calling the {@link GlobalFetchDefault | global fetch function} with each
|
|
49
|
+
* attachment's `jr:` URL. This default behavior will typically result in
|
|
50
|
+
* failure to load form attachments—and in most cases this will in most cases
|
|
51
|
+
* cause {@link loadForm | loading a form} to produce a
|
|
52
|
+
* {@link LoadFormFailureResult}, with the following exception:
|
|
53
|
+
*
|
|
54
|
+
* Clients implementing a
|
|
55
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Service Worker}
|
|
56
|
+
* (e.g. supporting offline functionality, or any other use case for
|
|
57
|
+
* intercepting network requests) may opt for the convenience of handling
|
|
58
|
+
* network requests _for form attachments' `jr:` URLs_ along with any other
|
|
59
|
+
* network interception logic. Client implementors should be warned, however,
|
|
60
|
+
* that such `jr:` URLs are not namespaced or otherwise scoped to a particular
|
|
61
|
+
* form definition! Such a client would therefore inherently need to
|
|
62
|
+
* coordinate state between the Service Worker and the main thread (or
|
|
63
|
+
* whatever other realm calls {@link loadForm}).
|
|
64
|
+
*
|
|
65
|
+
* @todo We can almost certainly address the scoping caveat! We'll probably
|
|
66
|
+
* want to design for that as part of offline support.
|
|
67
|
+
*/
|
|
68
|
+
// TODO (internal): Also note that the current round of revisions to
|
|
69
|
+
// engine/client entrypoints are not directly designed to address the above
|
|
70
|
+
// `@todo`, but the offline use case in particular is very much in mind for
|
|
71
|
+
// these interface changes!
|
|
72
|
+
readonly fetchFormAttachment?: FetchFormAttachment;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @see {@link MissingResourceBehavior}
|
|
76
|
+
* @see {@link MissingResourceBehaviorDefault}
|
|
77
|
+
*
|
|
78
|
+
* @default MissingResourceBehaviorDefault
|
|
79
|
+
*/
|
|
80
|
+
readonly missingResourceBehavior?: MissingResourceBehavior;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Note: loading a form produce a {@link Promise} which **will never reject**.
|
|
85
|
+
* Rather than rejecting, any errors encountered in the process of loading a
|
|
86
|
+
* form will be **resolved**, in a
|
|
87
|
+
* {@link LoadFormFailureResult.error | FormLoadFailureResult error}.
|
|
88
|
+
*/
|
|
89
|
+
export type LoadForm = (
|
|
90
|
+
formResource: FormResource,
|
|
91
|
+
options?: LoadFormOptions
|
|
92
|
+
) => FormLoadPromise<LoadFormResult>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { UnknownObject } from '@getodk/common/lib/type-assertions/assertUnknownObject.ts';
|
|
2
|
+
import type { AnyFunction } from '@getodk/common/types/helpers.js';
|
|
3
|
+
import type { LoadFormFailureError } from '../../error/LoadFormFailureError.ts';
|
|
4
|
+
import type { CreateFormInstance } from './CreateFormInstance.ts';
|
|
5
|
+
import type { EditFormInstance } from './EditFormInstance.ts';
|
|
6
|
+
import type { RestoreFormInstance } from './RestoreFormInstance.ts';
|
|
7
|
+
|
|
8
|
+
// Re-export for client access
|
|
9
|
+
export type { LoadFormFailureError };
|
|
10
|
+
|
|
11
|
+
// prettier-ignore
|
|
12
|
+
export type FormResultStatus =
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
14
|
+
| 'success'
|
|
15
|
+
| 'warning'
|
|
16
|
+
| 'failure';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @todo Pending design and modeling of warning cases.
|
|
20
|
+
*/
|
|
21
|
+
export type LoadFormWarnings = UnknownObject;
|
|
22
|
+
|
|
23
|
+
// prettier-ignore
|
|
24
|
+
type FailedLoadFormResultMethodParameters<T extends AnyFunction> =
|
|
25
|
+
& readonly never[]
|
|
26
|
+
& (
|
|
27
|
+
Parameters<T> extends { readonly length: infer Length extends number }
|
|
28
|
+
? { readonly length: Length }
|
|
29
|
+
: never
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export type FailedLoadFormResultMethod<T extends AnyFunction> = (
|
|
33
|
+
...args: FailedLoadFormResultMethodParameters<T>
|
|
34
|
+
) => never;
|
|
35
|
+
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
export type FallibleLoadFormResultMethod<T extends AnyFunction> =
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
39
|
+
| T
|
|
40
|
+
| FailedLoadFormResultMethod<T>;
|
|
41
|
+
|
|
42
|
+
interface BaseLoadFormResult {
|
|
43
|
+
readonly status: FormResultStatus;
|
|
44
|
+
readonly warnings: LoadFormWarnings | null;
|
|
45
|
+
readonly error: LoadFormFailureError | null;
|
|
46
|
+
readonly createInstance: FallibleLoadFormResultMethod<CreateFormInstance>;
|
|
47
|
+
readonly editInstance: FallibleLoadFormResultMethod<EditFormInstance>;
|
|
48
|
+
readonly restoreInstance: FallibleLoadFormResultMethod<RestoreFormInstance>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface LoadFormSuccessResult extends BaseLoadFormResult {
|
|
52
|
+
readonly status: 'success';
|
|
53
|
+
readonly warnings: null;
|
|
54
|
+
readonly error: null;
|
|
55
|
+
readonly createInstance: CreateFormInstance;
|
|
56
|
+
readonly editInstance: EditFormInstance;
|
|
57
|
+
readonly restoreInstance: RestoreFormInstance;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface LoadFormWarningResult extends BaseLoadFormResult {
|
|
61
|
+
readonly status: 'warning';
|
|
62
|
+
readonly warnings: LoadFormWarnings;
|
|
63
|
+
readonly error: null;
|
|
64
|
+
readonly createInstance: CreateFormInstance;
|
|
65
|
+
readonly editInstance: EditFormInstance;
|
|
66
|
+
readonly restoreInstance: RestoreFormInstance;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface LoadFormFailureResult extends BaseLoadFormResult {
|
|
70
|
+
readonly status: 'failure';
|
|
71
|
+
readonly warnings: LoadFormWarnings | null;
|
|
72
|
+
readonly error: LoadFormFailureError;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @example A temporary demo integration was built during development of this
|
|
76
|
+
* interface.
|
|
77
|
+
*
|
|
78
|
+
* @see
|
|
79
|
+
* {@link https://github.com/getodk/web-forms/pull/345/commits/9ef36355d89dd1450d3a87c3a55506bb9b0fc414}
|
|
80
|
+
*/
|
|
81
|
+
readonly createInstance: FailedLoadFormResultMethod<CreateFormInstance>;
|
|
82
|
+
|
|
83
|
+
readonly editInstance: FailedLoadFormResultMethod<EditFormInstance>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @example A temporary demo integration was built during development of this
|
|
87
|
+
* interface.
|
|
88
|
+
*
|
|
89
|
+
* @see
|
|
90
|
+
* {@link https://github.com/getodk/web-forms/pull/345/commits/9ef36355d89dd1450d3a87c3a55506bb9b0fc414}
|
|
91
|
+
*/
|
|
92
|
+
readonly restoreInstance: FailedLoadFormResultMethod<RestoreFormInstance>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// prettier-ignore
|
|
96
|
+
export type InstantiableLoadFormResult =
|
|
97
|
+
| LoadFormSuccessResult
|
|
98
|
+
| LoadFormWarningResult
|
|
99
|
+
|
|
100
|
+
// prettier-ignore
|
|
101
|
+
export type LoadFormResult =
|
|
102
|
+
| InstantiableLoadFormResult
|
|
103
|
+
| LoadFormFailureResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InstanceData } from '../serialization/InstanceData.ts';
|
|
2
|
+
import type { FormInstance, FormInstanceRestoreMode } from './FormInstance.ts';
|
|
3
|
+
import type { FormInstanceConfig } from './FormInstanceConfig.ts';
|
|
4
|
+
|
|
5
|
+
export interface RestoreFormInstanceInput {
|
|
6
|
+
readonly data: readonly [InstanceData, ...InstanceData[]];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type RestoredFormInstance = FormInstance<FormInstanceRestoreMode>;
|
|
10
|
+
|
|
11
|
+
export type RestoreFormInstance = (
|
|
12
|
+
input: RestoreFormInstanceInput,
|
|
13
|
+
config?: FormInstanceConfig
|
|
14
|
+
) => Promise<RestoredFormInstance>;
|
package/src/client/hierarchy.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { ExpandUnion } from '@getodk/common/types/helpers.d.ts';
|
|
|
2
2
|
import type { GroupNode } from './GroupNode.ts';
|
|
3
3
|
import type { AnyInputNode } from './InputNode.ts';
|
|
4
4
|
import type { AnyModelValueNode } from './ModelValueNode.ts';
|
|
5
|
-
import type {
|
|
5
|
+
import type { AnyNoteNode } from './NoteNode.ts';
|
|
6
|
+
import type { AnyRangeNode } from './RangeNode.ts';
|
|
6
7
|
import type { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
|
|
7
8
|
import type { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
|
|
8
9
|
import type { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
|
|
@@ -10,20 +11,18 @@ import type { RootNode } from './RootNode.ts';
|
|
|
10
11
|
import type { SelectNode } from './SelectNode.ts';
|
|
11
12
|
import type { SubtreeNode } from './SubtreeNode.ts';
|
|
12
13
|
import type { TriggerNode } from './TriggerNode.ts';
|
|
13
|
-
import type {
|
|
14
|
-
import type { RankNode } from './unsupported/RankNode.ts';
|
|
14
|
+
import type { RankNode } from './RankNode.ts';
|
|
15
15
|
import type { UploadNode } from './unsupported/UploadNode.ts';
|
|
16
16
|
|
|
17
17
|
// prettier-ignore
|
|
18
|
-
export type AnyUnsupportedControlNode =
|
|
19
|
-
| RangeNode
|
|
20
|
-
| RankNode
|
|
21
|
-
| UploadNode;
|
|
18
|
+
export type AnyUnsupportedControlNode = UploadNode;
|
|
22
19
|
|
|
23
20
|
// prettier-ignore
|
|
24
21
|
export type AnyControlNode =
|
|
25
22
|
| AnyInputNode
|
|
26
|
-
|
|
|
23
|
+
| AnyNoteNode
|
|
24
|
+
| AnyRangeNode
|
|
25
|
+
| RankNode
|
|
27
26
|
| SelectNode
|
|
28
27
|
| TriggerNode;
|
|
29
28
|
|