@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,26 +1,23 @@
|
|
|
1
1
|
import type { Group } from './Group.ts';
|
|
2
2
|
import type { AnyInputControl } from './InputControl.ts';
|
|
3
3
|
import type { AnyModelValue } from './ModelValue.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { AnyNote } from './Note.ts';
|
|
5
5
|
import type { PrimaryInstance } from './PrimaryInstance.ts';
|
|
6
|
+
import type { AnyRangeControl } from './RangeControl.ts';
|
|
6
7
|
import type { RepeatInstance } from './repeat/RepeatInstance.ts';
|
|
7
8
|
import type { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
8
9
|
import type { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
9
10
|
import type { Root } from './Root.ts';
|
|
10
|
-
import type {
|
|
11
|
+
import type { SelectControl } from './SelectControl.ts';
|
|
11
12
|
import type { Subtree } from './Subtree.ts';
|
|
12
13
|
import type { TriggerControl } from './TriggerControl.ts';
|
|
13
|
-
import type {
|
|
14
|
-
import type { RankControl } from './unsupported/RankControl.ts';
|
|
14
|
+
import type { RankControl } from './RankControl.ts';
|
|
15
15
|
import type { UploadControl } from './unsupported/UploadControl.ts';
|
|
16
16
|
|
|
17
17
|
export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
|
|
18
18
|
|
|
19
19
|
// prettier-ignore
|
|
20
|
-
export type AnyUnsupportedControl =
|
|
21
|
-
| RangeControl
|
|
22
|
-
| RankControl
|
|
23
|
-
| UploadControl;
|
|
20
|
+
export type AnyUnsupportedControl = UploadControl;
|
|
24
21
|
|
|
25
22
|
// prettier-ignore
|
|
26
23
|
export type AnyNode =
|
|
@@ -31,10 +28,12 @@ export type AnyNode =
|
|
|
31
28
|
| Subtree
|
|
32
29
|
| RepeatRange
|
|
33
30
|
| RepeatInstance
|
|
34
|
-
|
|
|
31
|
+
| AnyNote
|
|
35
32
|
| AnyModelValue
|
|
36
33
|
| AnyInputControl
|
|
37
|
-
|
|
|
34
|
+
| AnyRangeControl
|
|
35
|
+
| RankControl
|
|
36
|
+
| SelectControl
|
|
38
37
|
| TriggerControl
|
|
39
38
|
| AnyUnsupportedControl;
|
|
40
39
|
|
|
@@ -65,9 +64,11 @@ export type AnyChildNode =
|
|
|
65
64
|
| RepeatRange
|
|
66
65
|
| RepeatInstance
|
|
67
66
|
| AnyModelValue
|
|
68
|
-
|
|
|
67
|
+
| AnyNote
|
|
69
68
|
| AnyInputControl
|
|
70
|
-
|
|
|
69
|
+
| AnyRangeControl
|
|
70
|
+
| RankControl
|
|
71
|
+
| SelectControl
|
|
71
72
|
| TriggerControl
|
|
72
73
|
| AnyUnsupportedControl;
|
|
73
74
|
|
|
@@ -78,9 +79,11 @@ export type GeneralChildNode =
|
|
|
78
79
|
| Subtree
|
|
79
80
|
| RepeatRange
|
|
80
81
|
| AnyModelValue
|
|
81
|
-
|
|
|
82
|
+
| AnyNote
|
|
82
83
|
| AnyInputControl
|
|
83
|
-
|
|
|
84
|
+
| AnyRangeControl
|
|
85
|
+
| RankControl
|
|
86
|
+
| SelectControl
|
|
84
87
|
| TriggerControl
|
|
85
88
|
| AnyUnsupportedControl;
|
|
86
89
|
|
|
@@ -88,8 +91,10 @@ export type GeneralChildNode =
|
|
|
88
91
|
export type AnyValueNode =
|
|
89
92
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
90
93
|
| AnyModelValue
|
|
91
|
-
|
|
|
94
|
+
| AnyNote
|
|
92
95
|
| AnyInputControl
|
|
93
|
-
|
|
|
96
|
+
| AnyRangeControl
|
|
97
|
+
| RankControl
|
|
98
|
+
| SelectControl
|
|
94
99
|
| TriggerControl
|
|
95
100
|
| AnyUnsupportedControl;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { getBlobText } from '@getodk/common/lib/web-compat/blob.ts';
|
|
2
|
+
import { INSTANCE_FILE_NAME } from '../../client/constants.ts';
|
|
3
|
+
import type {
|
|
4
|
+
EditFormInstanceInput,
|
|
5
|
+
ResolvableFormInstanceInput,
|
|
6
|
+
} from '../../client/form/EditFormInstance.ts';
|
|
7
|
+
import type { InstanceData } from '../../client/serialization/InstanceData.ts';
|
|
8
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
9
|
+
import type { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
10
|
+
import type { ModelDefinition } from '../../parse/model/ModelDefinition.ts';
|
|
11
|
+
import { parseInstanceXML } from '../../parse/shared/parseInstanceXML.ts';
|
|
12
|
+
import type { XFormDOM } from '../../parse/XFormDOM.ts';
|
|
13
|
+
import { InstanceAttachmentMap } from './InstanceAttachmentMap.ts';
|
|
14
|
+
|
|
15
|
+
export type InitialInstanceStateSources = readonly [InstanceData, ...InstanceData[]];
|
|
16
|
+
|
|
17
|
+
interface InitialInstanceStateOptions {
|
|
18
|
+
readonly instanceXML: string;
|
|
19
|
+
readonly attachments: InstanceAttachmentMap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const resolveInstanceXML = async (input: ResolvableFormInstanceInput): Promise<string> => {
|
|
23
|
+
const instanceResult = await input.resolveInstance();
|
|
24
|
+
|
|
25
|
+
if (typeof instanceResult === 'string') {
|
|
26
|
+
return instanceResult;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (instanceResult instanceof Blob) {
|
|
30
|
+
return getBlobText(instanceResult);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return instanceResult.text();
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const parseInstanceDocument = (model: ModelDefinition, instanceXML: string): StaticDocument => {
|
|
37
|
+
const doc = parseInstanceXML(model, instanceXML);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Note: this is presently inferred as nullable. Its presence is _currently_
|
|
41
|
+
* enforced by {@link XFormDOM}, though that's definitely not ideal!
|
|
42
|
+
*
|
|
43
|
+
* @todo we would probably benefit from a single parse function responsible
|
|
44
|
+
* for both instance documents (form and input), with all `id` enforcement
|
|
45
|
+
* handled in one place (presence in both cases, matching in case of form +
|
|
46
|
+
* input). We could then also express this at the type level without weird DOM
|
|
47
|
+
* shenanigans in {@link XFormDOM} (which aren't likely to stick around in
|
|
48
|
+
* their current state forever!).
|
|
49
|
+
*/
|
|
50
|
+
const expectedId = model.instance.root.getAttributeValue('id');
|
|
51
|
+
const actualId = doc.root.getAttributeValue('id');
|
|
52
|
+
|
|
53
|
+
if (expectedId !== actualId) {
|
|
54
|
+
throw new ErrorProductionDesignPendingError(
|
|
55
|
+
`Invalid instance input. Expected instance id to be "${expectedId}", got: "${actualId}"`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return doc;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export class InitialInstanceState {
|
|
63
|
+
static async from(
|
|
64
|
+
model: ModelDefinition,
|
|
65
|
+
data: InitialInstanceStateSources
|
|
66
|
+
): Promise<InitialInstanceState> {
|
|
67
|
+
return this.resolve(model, {
|
|
68
|
+
inputType: 'FORM_INSTANCE_INPUT_RESOLVED',
|
|
69
|
+
data,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static async resolve(
|
|
74
|
+
model: ModelDefinition,
|
|
75
|
+
input: EditFormInstanceInput
|
|
76
|
+
): Promise<InitialInstanceState> {
|
|
77
|
+
if (input.inputType === 'FORM_INSTANCE_INPUT_RESOLVED') {
|
|
78
|
+
const { data } = input;
|
|
79
|
+
const [instanceData] = data;
|
|
80
|
+
const instanceFile = instanceData.get(INSTANCE_FILE_NAME);
|
|
81
|
+
const instanceXML = await getBlobText(instanceFile);
|
|
82
|
+
const attachments = InstanceAttachmentMap.from(data);
|
|
83
|
+
|
|
84
|
+
return new this(model, {
|
|
85
|
+
instanceXML,
|
|
86
|
+
attachments,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const [instanceXML, attachments] = await Promise.all([
|
|
91
|
+
resolveInstanceXML(input),
|
|
92
|
+
InstanceAttachmentMap.resolve(input.attachments),
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
return new this(model, {
|
|
96
|
+
instanceXML,
|
|
97
|
+
attachments,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
readonly document: StaticDocument;
|
|
102
|
+
readonly attachments: InstanceAttachmentMap;
|
|
103
|
+
|
|
104
|
+
private constructor(model: ModelDefinition, options: InitialInstanceStateOptions) {
|
|
105
|
+
this.document = parseInstanceDocument(model, options.instanceXML);
|
|
106
|
+
this.attachments = options.attachments;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { INSTANCE_FILE_NAME } from '../../client/constants.ts';
|
|
2
|
+
import type { ResolvableInstanceAttachmentsMap } from '../../client/form/EditFormInstance.ts';
|
|
3
|
+
import { MalformedInstanceDataError } from '../../error/MalformedInstanceDataError.ts';
|
|
4
|
+
|
|
5
|
+
type InstanceAttachmentMapSourceEntry = readonly [key: string, value: FormDataEntryValue];
|
|
6
|
+
|
|
7
|
+
interface InstanceAttachmentMapSource {
|
|
8
|
+
entries(): Iterable<InstanceAttachmentMapSourceEntry>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type InstanceAttachmentMapSources = readonly [
|
|
12
|
+
InstanceAttachmentMapSource,
|
|
13
|
+
...InstanceAttachmentMapSource[],
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @todo This currently short-circuits if there are actually any instance
|
|
18
|
+
* attachments to resolve. As described below, much of the approach is pretty
|
|
19
|
+
* naive now anyway, and none of it is really "ready" until we have something to
|
|
20
|
+
* actually _use the instance attachments_ once they're resolved! When we are
|
|
21
|
+
* ready, the functionality can be unblocked as in
|
|
22
|
+
* {@link https://github.com/getodk/web-forms/commit/88ee1b91c1f68d53ce9ba551bab334852e1e60cd | this commit}.
|
|
23
|
+
*
|
|
24
|
+
* @todo Everything about this is incredibly naive! We should almost certainly
|
|
25
|
+
* do _at least_ the following:
|
|
26
|
+
*
|
|
27
|
+
* - Limit how many attachments we attempt to resolve concurrently
|
|
28
|
+
* - Lazy resolution of large attachments (i.e. probably streaming, maybe range
|
|
29
|
+
* requests, ?)
|
|
30
|
+
*
|
|
31
|
+
* @todo Once lazy resolution is a thing, we will **also** need a clear path
|
|
32
|
+
* from there to eager resolution (i.e. for offline caching: it doesn't make
|
|
33
|
+
* sense to cache a stream in progress, as it won't load the resource once the
|
|
34
|
+
* user actually is offline/lacks network access). This may be something we can
|
|
35
|
+
* evolve gradually!
|
|
36
|
+
*/
|
|
37
|
+
const resolveInstanceAttachmentMapSource = async (
|
|
38
|
+
input: ResolvableInstanceAttachmentsMap
|
|
39
|
+
): Promise<InstanceAttachmentMapSource> => {
|
|
40
|
+
const inputEntries = Array.from(input.entries());
|
|
41
|
+
|
|
42
|
+
if (inputEntries.length > 0) {
|
|
43
|
+
const fileNames = Array.from(input.keys());
|
|
44
|
+
const errors = fileNames.map((fileName) => {
|
|
45
|
+
return new Error(`Failed to resolve instance attachment with file name "${fileName}"`);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
throw new AggregateError(errors, 'Not implemented: instance attachment resource resolution');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const entries = await Promise.all<InstanceAttachmentMapSourceEntry>(
|
|
52
|
+
inputEntries.map(async ([fileName, resolveAttachment]) => {
|
|
53
|
+
const response = await resolveAttachment();
|
|
54
|
+
const blob = await response.blob();
|
|
55
|
+
const value = new File([blob], fileName);
|
|
56
|
+
|
|
57
|
+
return [fileName, value] as const;
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return { entries: () => entries };
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
interface KeyedInstanceDataFile<Key extends string> extends File {
|
|
65
|
+
readonly name: Key;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type AssertKeyedInstanceDataFile = <Key extends string>(
|
|
69
|
+
key: Key,
|
|
70
|
+
file: File
|
|
71
|
+
) => asserts file is KeyedInstanceDataFile<Key>;
|
|
72
|
+
|
|
73
|
+
const assertKeyedInstanceDataFile: AssertKeyedInstanceDataFile = (key, file) => {
|
|
74
|
+
if (file.name !== key) {
|
|
75
|
+
throw new MalformedInstanceDataError(
|
|
76
|
+
`Unexpected InstanceData file. Expected file name to match key, got key: ${JSON.stringify(key)} and file name: ${JSON.stringify(file.name)}`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type UnknownInstanceDataEntry = readonly [key: string, value: FormDataEntryValue];
|
|
82
|
+
|
|
83
|
+
type KeyedInstanceDataEntry<Key extends string> = readonly [key: Key, KeyedInstanceDataFile<Key>];
|
|
84
|
+
|
|
85
|
+
type AssertInstanceDataEntry = <Key extends string>(
|
|
86
|
+
entry: UnknownInstanceDataEntry
|
|
87
|
+
) => asserts entry is KeyedInstanceDataEntry<Key>;
|
|
88
|
+
|
|
89
|
+
const assertInstanceDataEntry: AssertInstanceDataEntry = (entry) => {
|
|
90
|
+
const [key, value] = entry;
|
|
91
|
+
|
|
92
|
+
if (!(value instanceof File)) {
|
|
93
|
+
throw new MalformedInstanceDataError(
|
|
94
|
+
`Unexpected non-file attachment in InstanceData for key: ${key}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
assertKeyedInstanceDataFile(key, value);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export class InstanceAttachmentMap extends Map<string, File> {
|
|
102
|
+
static from(sources: InstanceAttachmentMapSources): InstanceAttachmentMap {
|
|
103
|
+
return new this(sources);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @todo
|
|
108
|
+
* @see {@link resolveInstanceAttachmentMapSource}
|
|
109
|
+
*/
|
|
110
|
+
static async resolve(input: ResolvableInstanceAttachmentsMap): Promise<InstanceAttachmentMap> {
|
|
111
|
+
const source = await resolveInstanceAttachmentMapSource(input);
|
|
112
|
+
|
|
113
|
+
return new this([source]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private constructor(sources: InstanceAttachmentMapSources) {
|
|
117
|
+
super();
|
|
118
|
+
|
|
119
|
+
for (const source of sources) {
|
|
120
|
+
for (const entry of source.entries()) {
|
|
121
|
+
const [key] = entry;
|
|
122
|
+
|
|
123
|
+
// Skip the instance XML file: it's not an attachment!
|
|
124
|
+
if (key === INSTANCE_FILE_NAME) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (this.has(key)) {
|
|
129
|
+
throw new MalformedInstanceDataError(
|
|
130
|
+
`Unexpected InstanceData entry. Duplicate instance attachment for key: ${JSON.stringify(key)}`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
assertInstanceDataEntry(entry);
|
|
135
|
+
|
|
136
|
+
const [, value] = entry;
|
|
137
|
+
|
|
138
|
+
this.set(key, value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormInstanceConfig } from '../../client/form/FormInstanceConfig.ts';
|
|
2
2
|
import type { OpaqueReactiveObjectFactory } from '../../client/OpaqueReactiveObjectFactory.ts';
|
|
3
|
-
import type { FetchFormAttachment, FetchResource } from '../../client/resources.ts';
|
|
4
|
-
import type { CreateUniqueId } from '../../lib/unique-id.ts';
|
|
5
3
|
|
|
6
4
|
export interface InstanceConfig {
|
|
7
|
-
readonly stateFactory: OpaqueReactiveObjectFactory;
|
|
8
|
-
readonly fetchFormDefinition: FetchResource;
|
|
9
|
-
readonly fetchFormAttachment: FetchFormAttachment;
|
|
10
|
-
readonly missingResourceBehavior: MissingResourceBehavior;
|
|
11
|
-
|
|
12
5
|
/**
|
|
13
|
-
*
|
|
6
|
+
* @see {@link FormInstanceConfig.stateFactory}
|
|
14
7
|
*/
|
|
15
|
-
readonly
|
|
8
|
+
readonly clientStateFactory: OpaqueReactiveObjectFactory;
|
|
16
9
|
}
|
|
@@ -1,22 +1,32 @@
|
|
|
1
|
+
import type { FormInstanceInitializationMode } from '../../client/index.ts';
|
|
2
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
1
3
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
4
|
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
5
|
+
import type { AnyBindPreloadDefinition } from '../../parse/model/BindPreloadDefinition.ts';
|
|
3
6
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
4
7
|
|
|
8
|
+
export interface InstanceValueContextDocument {
|
|
9
|
+
readonly initializationMode: FormInstanceInitializationMode;
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
export type DecodeInstanceValue = (value: string) => string;
|
|
6
13
|
|
|
7
14
|
interface InstanceValueContextDefinitionBind {
|
|
15
|
+
readonly preload: AnyBindPreloadDefinition | null;
|
|
8
16
|
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
9
17
|
readonly readonly: BindComputationExpression<'readonly'>;
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
export interface InstanceValueContextDefinition {
|
|
13
21
|
readonly bind: InstanceValueContextDefinitionBind;
|
|
14
|
-
readonly
|
|
22
|
+
readonly template: StaticLeafElement;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
export interface InstanceValueContext extends EvaluationContext {
|
|
18
26
|
readonly scope: ReactiveScope;
|
|
27
|
+
readonly rootDocument: InstanceValueContextDocument;
|
|
19
28
|
readonly definition: InstanceValueContextDefinition;
|
|
29
|
+
readonly instanceNode: StaticLeafElement | null;
|
|
20
30
|
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
21
31
|
|
|
22
32
|
isReadonly(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SubmissionMeta } from '../../../client/submission/SubmissionMeta.ts';
|
|
2
|
+
import type { AncestorNodeValidationState } from '../../../client/validation.ts';
|
|
3
|
+
import type { Root } from '../../Root.ts';
|
|
4
|
+
import type {
|
|
5
|
+
ClientReactiveSerializableParentNode,
|
|
6
|
+
ClientReactiveSerializableParentNodeDefinition,
|
|
7
|
+
} from './ClientReactiveSerializableParentNode.ts';
|
|
8
|
+
|
|
9
|
+
interface ClientReactiveSerializableInstanceDefinition
|
|
10
|
+
extends ClientReactiveSerializableParentNodeDefinition {
|
|
11
|
+
readonly submission: SubmissionMeta;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ClientReactiveSerializableInstance
|
|
15
|
+
extends ClientReactiveSerializableParentNode<Root> {
|
|
16
|
+
readonly definition: ClientReactiveSerializableInstanceDefinition;
|
|
17
|
+
readonly root: Root;
|
|
18
|
+
readonly parent: null;
|
|
19
|
+
readonly validationState: AncestorNodeValidationState;
|
|
20
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import type { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
|
+
import type { EscapedXMLText } from '../../../lib/xml-serialization.ts';
|
|
4
|
+
import type {
|
|
5
|
+
ClientReactiveSerializableChildNode,
|
|
6
|
+
ClientReactiveSerializableParentNode,
|
|
7
|
+
} from './ClientReactiveSerializableParentNode.ts';
|
|
8
|
+
|
|
9
|
+
interface ClientReactiveSerializableLeafNodeCurrentState<RuntimeValue> {
|
|
10
|
+
get relevant(): boolean;
|
|
11
|
+
get value(): RuntimeValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type SerializedInstanceValue = string;
|
|
15
|
+
|
|
16
|
+
interface ClientReactiveSerializableLeafNodeDefinition {
|
|
17
|
+
readonly qualifiedName: QualifiedName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ClientReactiveSerializableLeafNode<RuntimeValue> {
|
|
21
|
+
readonly definition: ClientReactiveSerializableLeafNodeDefinition;
|
|
22
|
+
readonly parent: ClientReactiveSerializableParentNode<ClientReactiveSerializableChildNode>;
|
|
23
|
+
readonly currentState: ClientReactiveSerializableLeafNodeCurrentState<RuntimeValue>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A client-reactive serializble leaf node is responsible for producing a
|
|
27
|
+
* string representation of its value state, suitable for instance
|
|
28
|
+
* serialization. It **MUST NOT** perform any further instance
|
|
29
|
+
* serialization-specific serialization duties: in particular, the value
|
|
30
|
+
* **MUST NOT** be escaped for XML. This responsibility is delegated up the
|
|
31
|
+
* stack, to avoid repeat escaping.
|
|
32
|
+
*
|
|
33
|
+
* Note: excluding {@link EscapedXMLText} here does not have an effect on the
|
|
34
|
+
* type system, it is a documentation-only hint, to help guard against future
|
|
35
|
+
* double-escaping mistakes.
|
|
36
|
+
*/
|
|
37
|
+
readonly encodeValue: (
|
|
38
|
+
this: unknown,
|
|
39
|
+
runtimeValue: RuntimeValue
|
|
40
|
+
) => Exclude<string, EscapedXMLText>;
|
|
41
|
+
|
|
42
|
+
readonly instanceState: InstanceState;
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import type { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
|
+
|
|
4
|
+
export interface ClientReactiveSerializableChildNode {
|
|
5
|
+
readonly instanceState: InstanceState;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ClientReactiveSerializableParentNodeCurrentState<
|
|
9
|
+
Child extends ClientReactiveSerializableChildNode,
|
|
10
|
+
> {
|
|
11
|
+
get relevant(): boolean;
|
|
12
|
+
get children(): readonly Child[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ClientReactiveSerializableParentNodeDefinition {
|
|
16
|
+
readonly qualifiedName: QualifiedName;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ClientReactiveSerializableParentNode<
|
|
20
|
+
Child extends ClientReactiveSerializableChildNode,
|
|
21
|
+
> {
|
|
22
|
+
readonly definition: ClientReactiveSerializableParentNodeDefinition;
|
|
23
|
+
readonly parent: ClientReactiveSerializableParentNode<ClientReactiveSerializableChildNode> | null;
|
|
24
|
+
readonly currentState: ClientReactiveSerializableParentNodeCurrentState<Child>;
|
|
25
|
+
readonly instanceState: InstanceState;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TemplatedNodeAttributeSerializationError } from '../../../error/TemplatedNodeAttributeSerializationError.ts';
|
|
2
|
+
import type { StaticElement } from '../../../integration/xpath/static-dom/StaticElement.ts';
|
|
3
|
+
import type { GeneralChildNode } from '../../hierarchy.ts';
|
|
4
|
+
import type {
|
|
5
|
+
ClientReactiveSerializableParentNode,
|
|
6
|
+
ClientReactiveSerializableParentNodeCurrentState,
|
|
7
|
+
ClientReactiveSerializableParentNodeDefinition,
|
|
8
|
+
} from './ClientReactiveSerializableParentNode.ts';
|
|
9
|
+
|
|
10
|
+
export interface ClientReactiveSerializableTemplatedNodeCurrentState
|
|
11
|
+
extends ClientReactiveSerializableParentNodeCurrentState<GeneralChildNode> {
|
|
12
|
+
/** @see {@link TemplatedNodeAttributeSerializationError} */
|
|
13
|
+
get attributes(): unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ClientReactiveSerializableTemplatedNodeDefinition
|
|
17
|
+
extends ClientReactiveSerializableParentNodeDefinition {
|
|
18
|
+
readonly template: StaticElement;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ClientReactiveSerializableTemplatedNode
|
|
22
|
+
extends ClientReactiveSerializableParentNode<GeneralChildNode> {
|
|
23
|
+
readonly currentState: ClientReactiveSerializableTemplatedNodeCurrentState;
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { InstanceState } from '../../../client/serialization/InstanceState.ts';
|
|
2
|
+
import type { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
|
+
import type {
|
|
4
|
+
ClientReactiveSerializableChildNode,
|
|
5
|
+
ClientReactiveSerializableParentNode,
|
|
6
|
+
} from './ClientReactiveSerializableParentNode.ts';
|
|
7
|
+
|
|
8
|
+
export type SerializedInstanceValue = string;
|
|
9
|
+
|
|
10
|
+
interface ClientReactiveSerializableValueNodeCurrentState {
|
|
11
|
+
get relevant(): boolean;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @todo Consider moving into {@link InstanceState}
|
|
15
|
+
*/
|
|
16
|
+
get instanceValue(): SerializedInstanceValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface ClientReactiveSerializableValueNodeDefinition {
|
|
20
|
+
readonly qualifiedName: QualifiedName;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ClientReactiveSerializableValueNode {
|
|
24
|
+
readonly definition: ClientReactiveSerializableValueNodeDefinition;
|
|
25
|
+
readonly parent: ClientReactiveSerializableParentNode<ClientReactiveSerializableChildNode>;
|
|
26
|
+
readonly currentState: ClientReactiveSerializableValueNodeCurrentState;
|
|
27
|
+
readonly instanceState: InstanceState;
|
|
28
|
+
}
|