@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,174 +0,0 @@
|
|
|
1
|
-
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
-
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
3
|
-
import type { Accessor } from 'solid-js';
|
|
4
|
-
import type { UnsupportedControlNodeType } from '../../client/node-types.ts';
|
|
5
|
-
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
|
-
import type { TextRange } from '../../client/TextRange.ts';
|
|
7
|
-
import type {
|
|
8
|
-
UnsupportedControlDefinition,
|
|
9
|
-
UnsupportedControlElementDefinition,
|
|
10
|
-
UnsupportedControlNode,
|
|
11
|
-
} from '../../client/unsupported/UnsupportedControlNode.ts';
|
|
12
|
-
import type { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
13
|
-
import type { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
14
|
-
import { createLeafNodeSubmissionState } from '../../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
15
|
-
import { createValueState } from '../../lib/reactivity/createValueState.ts';
|
|
16
|
-
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
17
|
-
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
18
|
-
import {
|
|
19
|
-
createSharedNodeState,
|
|
20
|
-
type SharedNodeState,
|
|
21
|
-
} from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
22
|
-
import { createFieldHint } from '../../lib/reactivity/text/createFieldHint.ts';
|
|
23
|
-
import { createNodeLabel } from '../../lib/reactivity/text/createNodeLabel.ts';
|
|
24
|
-
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
25
|
-
import {
|
|
26
|
-
createValidationState,
|
|
27
|
-
type SharedValidationState,
|
|
28
|
-
} from '../../lib/reactivity/validation/createValidation.ts';
|
|
29
|
-
import type { UnknownAppearanceDefinition } from '../../parse/body/appearance/unknownAppearanceParser.ts';
|
|
30
|
-
import type { AnyUnsupportedControl, GeneralParentNode } from '../hierarchy.ts';
|
|
31
|
-
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
32
|
-
import type { ClientReactiveSubmittableLeafNode } from '../internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
33
|
-
import type { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
34
|
-
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
35
|
-
import { DescendantNode, type DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
36
|
-
|
|
37
|
-
type TypedUnsupportedControlElementDefinition<Type extends UnsupportedControlNodeType> = Extract<
|
|
38
|
-
UnsupportedControlElementDefinition,
|
|
39
|
-
{ readonly type: Type }
|
|
40
|
-
>;
|
|
41
|
-
|
|
42
|
-
interface TypedUnsupportedControlDefinition<Type extends UnsupportedControlNodeType>
|
|
43
|
-
extends UnsupportedControlDefinition {
|
|
44
|
-
readonly bodyElement: TypedUnsupportedControlElementDefinition<Type>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface UnsupportedControlStateSpec extends DescendantNodeStateSpec<unknown> {
|
|
48
|
-
readonly label: Accessor<TextRange<'label'> | null>;
|
|
49
|
-
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
50
|
-
readonly children: null;
|
|
51
|
-
readonly value: SimpleAtomicState<unknown>;
|
|
52
|
-
readonly valueOptions: never;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
class UnsupportedControlValueEncodeError extends Error {
|
|
56
|
-
constructor(type: UnsupportedControlNodeType) {
|
|
57
|
-
super(`Cannot encode state for node (type: ${type}) - not implemented`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
class UnsupportedControlWriteError extends Error {
|
|
62
|
-
constructor(type: UnsupportedControlNodeType) {
|
|
63
|
-
super(`Cannot write state for node (type: ${type}) - not implemented`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export abstract class UnsupportedControl<Type extends UnsupportedControlNodeType>
|
|
68
|
-
extends DescendantNode<
|
|
69
|
-
TypedUnsupportedControlDefinition<Type>,
|
|
70
|
-
UnsupportedControlStateSpec,
|
|
71
|
-
GeneralParentNode,
|
|
72
|
-
null
|
|
73
|
-
>
|
|
74
|
-
implements
|
|
75
|
-
UnsupportedControlNode,
|
|
76
|
-
XFormsXPathElement,
|
|
77
|
-
EvaluationContext,
|
|
78
|
-
ValidationContext,
|
|
79
|
-
ValueContext<unknown>,
|
|
80
|
-
ClientReactiveSubmittableLeafNode<unknown>
|
|
81
|
-
{
|
|
82
|
-
private readonly validation: SharedValidationState;
|
|
83
|
-
protected readonly state: SharedNodeState<UnsupportedControlStateSpec>;
|
|
84
|
-
|
|
85
|
-
// XFormsXPathElement
|
|
86
|
-
override readonly [XPathNodeKindKey] = 'element';
|
|
87
|
-
|
|
88
|
-
// InstanceNode
|
|
89
|
-
protected readonly engineState: EngineState<UnsupportedControlStateSpec>;
|
|
90
|
-
|
|
91
|
-
// UnsupportedControlNode
|
|
92
|
-
abstract override readonly nodeType: Type;
|
|
93
|
-
|
|
94
|
-
readonly appearances: UnknownAppearanceDefinition;
|
|
95
|
-
readonly currentState: CurrentState<UnsupportedControlStateSpec>;
|
|
96
|
-
|
|
97
|
-
get validationState(): LeafNodeValidationState {
|
|
98
|
-
return this.validation.currentState;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
readonly submissionState: SubmissionState;
|
|
102
|
-
|
|
103
|
-
// ValueContext
|
|
104
|
-
abstract override readonly contextNode: AnyUnsupportedControl & this;
|
|
105
|
-
|
|
106
|
-
readonly encodeValue = (instanceValue: unknown): string => {
|
|
107
|
-
const encoded = instanceValue;
|
|
108
|
-
|
|
109
|
-
if (typeof encoded === 'string') {
|
|
110
|
-
return encoded;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
throw new UnsupportedControlValueEncodeError(this.nodeType);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
readonly decodeValue = (instanceValue: unknown): unknown => {
|
|
117
|
-
return identity(instanceValue);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
constructor(parent: GeneralParentNode, definition: TypedUnsupportedControlDefinition<Type>) {
|
|
121
|
-
super(parent, definition);
|
|
122
|
-
|
|
123
|
-
this.appearances = definition.bodyElement.appearances;
|
|
124
|
-
|
|
125
|
-
const sharedStateOptions = {
|
|
126
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const stateSpec: UnsupportedControlStateSpec = {
|
|
130
|
-
reference: this.contextReference,
|
|
131
|
-
readonly: this.isReadonly,
|
|
132
|
-
relevant: this.isRelevant,
|
|
133
|
-
required: this.isRequired,
|
|
134
|
-
|
|
135
|
-
label: createNodeLabel(this, definition),
|
|
136
|
-
hint: createFieldHint(this, definition),
|
|
137
|
-
children: null,
|
|
138
|
-
valueOptions: null as never,
|
|
139
|
-
value: createValueState<unknown>(this),
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const state = createSharedNodeState(this.scope, stateSpec, sharedStateOptions);
|
|
143
|
-
|
|
144
|
-
this.state = state;
|
|
145
|
-
this.engineState = state.engineState;
|
|
146
|
-
this.currentState = state.currentState;
|
|
147
|
-
this.validation = createValidationState(this, sharedStateOptions);
|
|
148
|
-
this.submissionState = createLeafNodeSubmissionState(this);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// XFormsXPathElement
|
|
152
|
-
override getXPathValue(): string {
|
|
153
|
-
return this.encodeValue(this.engineState.value);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ValidationContext
|
|
157
|
-
getViolation(): AnyViolation | null {
|
|
158
|
-
return this.validation.engineState.violation;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
isBlank(): boolean {
|
|
162
|
-
return this.engineState.value === '';
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// InstanceNode
|
|
166
|
-
getChildren(): readonly [] {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// UnsupportedControlNode
|
|
171
|
-
setValue(_: never): never {
|
|
172
|
-
throw new UnsupportedControlWriteError(this.nodeType);
|
|
173
|
-
}
|
|
174
|
-
}
|
package/src/instance/children.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
|
-
import type { GroupDefinition } from '../client/GroupNode.ts';
|
|
3
|
-
import type { InputDefinition } from '../client/InputNode.ts';
|
|
4
|
-
import type { ModelValueDefinition } from '../client/ModelValueNode.ts';
|
|
5
|
-
import type { SubtreeDefinition } from '../client/SubtreeNode.ts';
|
|
6
|
-
import type { TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
7
|
-
import type { RangeNodeDefinition } from '../client/unsupported/RangeNode.ts';
|
|
8
|
-
import type { RankNodeDefinition } from '../client/unsupported/RankNode.ts';
|
|
9
|
-
import type { UnsupportedControlDefinition } from '../client/unsupported/UnsupportedControlNode.ts';
|
|
10
|
-
import type { UploadNodeDefinition } from '../client/unsupported/UploadNode.ts';
|
|
11
|
-
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
12
|
-
import { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
13
|
-
import type { SubtreeDefinition as ModelSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
14
|
-
import { Group } from './Group.ts';
|
|
15
|
-
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
16
|
-
import { InputControl } from './InputControl.ts';
|
|
17
|
-
import { ModelValue } from './ModelValue.ts';
|
|
18
|
-
import { Note } from './Note.ts';
|
|
19
|
-
import { RepeatRangeControlled } from './repeat/RepeatRangeControlled.ts';
|
|
20
|
-
import { RepeatRangeUncontrolled } from './repeat/RepeatRangeUncontrolled.ts';
|
|
21
|
-
import type { SelectFieldDefinition } from './SelectField.ts';
|
|
22
|
-
import { SelectField } from './SelectField.ts';
|
|
23
|
-
import { Subtree } from './Subtree.ts';
|
|
24
|
-
import { TriggerControl } from './TriggerControl.ts';
|
|
25
|
-
import { RangeControl } from './unsupported/RangeControl.ts';
|
|
26
|
-
import { RankControl } from './unsupported/RankControl.ts';
|
|
27
|
-
import { UploadControl } from './unsupported/UploadControl.ts';
|
|
28
|
-
|
|
29
|
-
const isSubtreeDefinition = (
|
|
30
|
-
definition: ModelSubtreeDefinition
|
|
31
|
-
): definition is SubtreeDefinition => {
|
|
32
|
-
return definition.bodyElement == null;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
type AnyUnsupportedControlDefinition =
|
|
36
|
-
| RangeNodeDefinition
|
|
37
|
-
| RankNodeDefinition
|
|
38
|
-
| UploadNodeDefinition;
|
|
39
|
-
|
|
40
|
-
// prettier-ignore
|
|
41
|
-
type ControlNodeDefinition =
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
43
|
-
| InputDefinition
|
|
44
|
-
| SelectFieldDefinition
|
|
45
|
-
| TriggerNodeDefinition
|
|
46
|
-
| AnyUnsupportedControlDefinition;
|
|
47
|
-
|
|
48
|
-
type AnyLeafNodeDefinition = ControlNodeDefinition | ModelValueDefinition;
|
|
49
|
-
|
|
50
|
-
const isModelValueDefinition = (
|
|
51
|
-
definition: LeafNodeDefinition
|
|
52
|
-
): definition is ModelValueDefinition => {
|
|
53
|
-
return definition.bodyElement == null;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const isInputDefinition = (definition: ControlNodeDefinition): definition is InputDefinition => {
|
|
57
|
-
return definition.bodyElement.type === 'input';
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const isSelectFieldDefinition = (
|
|
61
|
-
definition: ControlNodeDefinition
|
|
62
|
-
): definition is SelectFieldDefinition => {
|
|
63
|
-
return definition.bodyElement.type === 'select' || definition.bodyElement.type === 'select1';
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const isRangeNodeDefinition = (
|
|
67
|
-
definition: UnsupportedControlDefinition
|
|
68
|
-
): definition is RangeNodeDefinition => {
|
|
69
|
-
return definition.bodyElement.type === 'range';
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const isRankNodeDefinition = (
|
|
73
|
-
definition: UnsupportedControlDefinition
|
|
74
|
-
): definition is RankNodeDefinition => {
|
|
75
|
-
return definition.bodyElement.type === 'rank';
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const isTriggerNodeDefinition = (
|
|
79
|
-
definition: ControlNodeDefinition
|
|
80
|
-
): definition is TriggerNodeDefinition => {
|
|
81
|
-
return definition.bodyElement.type === 'trigger';
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const isUploadNodeDefinition = (
|
|
85
|
-
definition: ControlNodeDefinition
|
|
86
|
-
): definition is UploadNodeDefinition => {
|
|
87
|
-
return definition.bodyElement.type === 'upload';
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] => {
|
|
91
|
-
const { children } = parent.definition;
|
|
92
|
-
|
|
93
|
-
return children.map((child): GeneralChildNode => {
|
|
94
|
-
switch (child.type) {
|
|
95
|
-
case 'subtree': {
|
|
96
|
-
if (isSubtreeDefinition(child)) {
|
|
97
|
-
return new Subtree(parent, child);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// TODO: it'd be good to be able to do without this type assertion. The
|
|
101
|
-
// only distinction between the types is whether `bodyElement` is
|
|
102
|
-
// `null`, but for some reason that's insufficient to narrow the union.
|
|
103
|
-
return new Group(parent, child as GroupDefinition);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
case 'repeat-range': {
|
|
107
|
-
if (child.isControlled()) {
|
|
108
|
-
return new RepeatRangeControlled(parent, child);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return new RepeatRangeUncontrolled(parent, child);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
case 'leaf-node': {
|
|
115
|
-
if (child instanceof NoteNodeDefinition) {
|
|
116
|
-
return new Note(parent, child);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// More specific type helps with narrowing below
|
|
120
|
-
const leafChild: AnyLeafNodeDefinition = child;
|
|
121
|
-
|
|
122
|
-
if (isModelValueDefinition(leafChild)) {
|
|
123
|
-
return ModelValue.from(parent, leafChild);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (isInputDefinition(leafChild)) {
|
|
127
|
-
return InputControl.from(parent, leafChild);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (isSelectFieldDefinition(leafChild)) {
|
|
131
|
-
return new SelectField(parent, leafChild);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (isTriggerNodeDefinition(leafChild)) {
|
|
135
|
-
return new TriggerControl(parent, leafChild);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (isRangeNodeDefinition(leafChild)) {
|
|
139
|
-
return new RangeControl(parent, leafChild);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (isRankNodeDefinition(leafChild)) {
|
|
143
|
-
return new RankControl(parent, leafChild);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (isUploadNodeDefinition(leafChild)) {
|
|
147
|
-
return new UploadControl(parent, leafChild);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
throw new UnreachableError(leafChild);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
default: {
|
|
154
|
-
throw new UnreachableError(child);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
};
|
package/src/instance/index.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
-
import { getOwner } from 'solid-js';
|
|
3
|
-
import type { EngineConfig } from '../client/EngineConfig.ts';
|
|
4
|
-
import type { RootNode } from '../client/RootNode.ts';
|
|
5
|
-
import { MISSING_RESOURCE_BEHAVIOR } from '../client/constants.ts';
|
|
6
|
-
import type {
|
|
7
|
-
InitializeFormOptions as BaseInitializeFormOptions,
|
|
8
|
-
FormResource,
|
|
9
|
-
InitializeForm,
|
|
10
|
-
} from '../client/index.ts';
|
|
11
|
-
import { retrieveSourceXMLResource } from '../instance/resource.ts';
|
|
12
|
-
import { createReactiveScope } from '../lib/reactivity/scope.ts';
|
|
13
|
-
import { createUniqueId } from '../lib/unique-id.ts';
|
|
14
|
-
import { XFormDOM } from '../parse/XFormDOM.ts';
|
|
15
|
-
import { XFormDefinition } from '../parse/XFormDefinition.ts';
|
|
16
|
-
import { SecondaryInstancesDefinition } from '../parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts';
|
|
17
|
-
import { PrimaryInstance } from './PrimaryInstance.ts';
|
|
18
|
-
import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
19
|
-
|
|
20
|
-
interface InitializeFormOptions extends BaseInitializeFormOptions {
|
|
21
|
-
readonly config: Partial<InstanceConfig>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const buildInstanceConfig = (options: EngineConfig = {}): InstanceConfig => {
|
|
25
|
-
return {
|
|
26
|
-
createUniqueId,
|
|
27
|
-
fetchFormDefinition: options.fetchFormDefinition ?? fetch,
|
|
28
|
-
fetchFormAttachment: options.fetchFormAttachment ?? fetch,
|
|
29
|
-
missingResourceBehavior: options.missingResourceBehavior ?? MISSING_RESOURCE_BEHAVIOR.DEFAULT,
|
|
30
|
-
stateFactory: options.stateFactory ?? identity,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const initializeForm = async (
|
|
35
|
-
input: FormResource,
|
|
36
|
-
options: Partial<InitializeFormOptions> = {}
|
|
37
|
-
): Promise<RootNode> => {
|
|
38
|
-
const owner = getOwner();
|
|
39
|
-
const scope = createReactiveScope({ owner });
|
|
40
|
-
const engineConfig = buildInstanceConfig(options.config);
|
|
41
|
-
const sourceXML = await retrieveSourceXMLResource(input, {
|
|
42
|
-
fetchResource: engineConfig.fetchFormDefinition,
|
|
43
|
-
});
|
|
44
|
-
const xformDOM = XFormDOM.from(sourceXML);
|
|
45
|
-
const secondaryInstances = await SecondaryInstancesDefinition.load(xformDOM, {
|
|
46
|
-
fetchResource: engineConfig.fetchFormAttachment,
|
|
47
|
-
missingResourceBehavior: engineConfig.missingResourceBehavior,
|
|
48
|
-
});
|
|
49
|
-
const form = new XFormDefinition(xformDOM);
|
|
50
|
-
const primaryInstance = new PrimaryInstance(scope, form.model, secondaryInstances, engineConfig);
|
|
51
|
-
|
|
52
|
-
return primaryInstance.root;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
initializeForm satisfies InitializeForm;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { EngineXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
2
|
-
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
3
|
-
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
4
|
-
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
5
|
-
|
|
6
|
-
export type InstanceValue = string;
|
|
7
|
-
|
|
8
|
-
interface ValueContextDefinitionBind {
|
|
9
|
-
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
10
|
-
readonly readonly: BindComputationExpression<'readonly'>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ValueContextDefinition {
|
|
14
|
-
readonly bind: ValueContextDefinitionBind;
|
|
15
|
-
readonly defaultValue: InstanceValue;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ValueContext<RuntimeValue> extends EvaluationContext {
|
|
19
|
-
readonly scope: ReactiveScope;
|
|
20
|
-
readonly definition: ValueContextDefinition;
|
|
21
|
-
readonly contextNode: EngineXPathNode & this;
|
|
22
|
-
|
|
23
|
-
isReadonly(): boolean;
|
|
24
|
-
isRelevant(): boolean;
|
|
25
|
-
|
|
26
|
-
readonly encodeValue: (this: unknown, runtimeValue: RuntimeValue) => InstanceValue;
|
|
27
|
-
readonly decodeValue: (this: unknown, instanceValue: InstanceValue) => RuntimeValue;
|
|
28
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { SubmissionDefinition } from '../../../client/submission/SubmissionDefinition.ts';
|
|
2
|
-
import type { AncestorNodeValidationState } from '../../../client/validation.ts';
|
|
3
|
-
import type { Root } from '../../Root.ts';
|
|
4
|
-
import type {
|
|
5
|
-
ClientReactiveSubmittableParentNode,
|
|
6
|
-
ClientReactiveSubmittableParentNodeDefinition,
|
|
7
|
-
} from './ClientReactiveSubmittableParentNode.ts';
|
|
8
|
-
|
|
9
|
-
interface ClientReactiveSubmittableInstanceDefinition
|
|
10
|
-
extends ClientReactiveSubmittableParentNodeDefinition {
|
|
11
|
-
readonly submission: SubmissionDefinition;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ClientReactiveSubmittableInstance
|
|
15
|
-
extends ClientReactiveSubmittableParentNode<Root> {
|
|
16
|
-
readonly definition: ClientReactiveSubmittableInstanceDefinition;
|
|
17
|
-
readonly root: Root;
|
|
18
|
-
readonly parent: null;
|
|
19
|
-
readonly validationState: AncestorNodeValidationState;
|
|
20
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
import type { EscapedXMLText } from '../../../lib/xml-serialization.ts';
|
|
3
|
-
import type {
|
|
4
|
-
ClientReactiveSubmittableChildNode,
|
|
5
|
-
ClientReactiveSubmittableParentNode,
|
|
6
|
-
} from './ClientReactiveSubmittableParentNode.ts';
|
|
7
|
-
|
|
8
|
-
interface ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue> {
|
|
9
|
-
get relevant(): boolean;
|
|
10
|
-
get value(): RuntimeValue;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type SerializedSubmissionValue = string;
|
|
14
|
-
|
|
15
|
-
interface ClientReactiveSubmittableLeafNodeDefinition {
|
|
16
|
-
readonly nodeName: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface ClientReactiveSubmittableLeafNode<RuntimeValue> {
|
|
20
|
-
readonly definition: ClientReactiveSubmittableLeafNodeDefinition;
|
|
21
|
-
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
22
|
-
readonly currentState: ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue>;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A client-reactive submittable leaf node is responsible for producing a
|
|
26
|
-
* string representation of its value state, suitable for serialization for
|
|
27
|
-
* submission. It **MUST NOT** perform any further submission-specific
|
|
28
|
-
* serialization duties: in particular, the value **MUST NOT** be escaped for
|
|
29
|
-
* XML. This responsibility is delegated up the stack, to avoid repeat
|
|
30
|
-
* escaping.
|
|
31
|
-
*
|
|
32
|
-
* Note: excluding {@link EscapedXMLText} here does not have an effect on the
|
|
33
|
-
* type system, it is a documentation-only hint, to help guard against future
|
|
34
|
-
* double-escaping mistakes.
|
|
35
|
-
*/
|
|
36
|
-
readonly encodeValue: (
|
|
37
|
-
this: unknown,
|
|
38
|
-
runtimeValue: RuntimeValue
|
|
39
|
-
) => Exclude<string, EscapedXMLText>;
|
|
40
|
-
|
|
41
|
-
readonly submissionState: SubmissionState;
|
|
42
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
|
|
3
|
-
export interface ClientReactiveSubmittableChildNode {
|
|
4
|
-
readonly submissionState: SubmissionState;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface ClientReactiveSubmittableParentNodeCurrentState<
|
|
8
|
-
Child extends ClientReactiveSubmittableChildNode,
|
|
9
|
-
> {
|
|
10
|
-
get relevant(): boolean;
|
|
11
|
-
get children(): readonly Child[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ClientReactiveSubmittableParentNodeDefinition {
|
|
15
|
-
readonly nodeName: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ClientReactiveSubmittableParentNode<
|
|
19
|
-
Child extends ClientReactiveSubmittableChildNode,
|
|
20
|
-
> {
|
|
21
|
-
readonly definition: ClientReactiveSubmittableParentNodeDefinition;
|
|
22
|
-
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode> | null;
|
|
23
|
-
readonly currentState: ClientReactiveSubmittableParentNodeCurrentState<Child>;
|
|
24
|
-
readonly submissionState: SubmissionState;
|
|
25
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
import type {
|
|
3
|
-
ClientReactiveSubmittableChildNode,
|
|
4
|
-
ClientReactiveSubmittableParentNode,
|
|
5
|
-
} from './ClientReactiveSubmittableParentNode.ts';
|
|
6
|
-
|
|
7
|
-
interface ClientReactiveSubmittableValueNodeCurrentState {
|
|
8
|
-
get relevant(): boolean;
|
|
9
|
-
get instanceValue(): string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type SerializedSubmissionValue = string;
|
|
13
|
-
|
|
14
|
-
interface ClientReactiveSubmittableValueNodeDefinition {
|
|
15
|
-
readonly nodeName: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ClientReactiveSubmittableValueNode {
|
|
19
|
-
readonly definition: ClientReactiveSubmittableValueNodeDefinition;
|
|
20
|
-
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
21
|
-
readonly currentState: ClientReactiveSubmittableValueNodeCurrentState;
|
|
22
|
-
readonly submissionState: SubmissionState;
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
-
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
3
|
-
|
|
4
|
-
export class RangeControl extends UnsupportedControl<'range'> implements ValueContext<unknown> {
|
|
5
|
-
readonly nodeType = 'range';
|
|
6
|
-
|
|
7
|
-
// ValueContext
|
|
8
|
-
readonly contextNode = this;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
-
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
3
|
-
|
|
4
|
-
export class RankControl extends UnsupportedControl<'rank'> implements ValueContext<unknown> {
|
|
5
|
-
readonly nodeType = 'rank';
|
|
6
|
-
|
|
7
|
-
// ValueContext
|
|
8
|
-
readonly contextNode = this;
|
|
9
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { XFORMS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
-
import type { XFormsXPathNamedNode, XPathNamedNodeKind } from '../adapter/XFormsXPathNode.ts';
|
|
3
|
-
import type { StaticDocument } from './StaticDocument.ts';
|
|
4
|
-
import type { StaticParentNode } from './StaticNode.ts';
|
|
5
|
-
import { StaticNode } from './StaticNode.ts';
|
|
6
|
-
|
|
7
|
-
export interface StaticNamedNodeOptions {
|
|
8
|
-
readonly namespaceURI: string | null;
|
|
9
|
-
readonly localName: string;
|
|
10
|
-
readonly value?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export abstract class StaticNamedNode<Kind extends XPathNamedNodeKind>
|
|
14
|
-
extends StaticNode<Kind>
|
|
15
|
-
implements XFormsXPathNamedNode
|
|
16
|
-
{
|
|
17
|
-
readonly rootDocument: StaticDocument;
|
|
18
|
-
readonly isXFormsNamespace: boolean;
|
|
19
|
-
readonly namespaceURI: string | null;
|
|
20
|
-
readonly localName: string;
|
|
21
|
-
readonly value: string | null;
|
|
22
|
-
|
|
23
|
-
protected constructor(
|
|
24
|
-
readonly parent: StaticParentNode,
|
|
25
|
-
options: StaticNamedNodeOptions
|
|
26
|
-
) {
|
|
27
|
-
super();
|
|
28
|
-
|
|
29
|
-
this.rootDocument = parent.rootDocument;
|
|
30
|
-
|
|
31
|
-
const { namespaceURI, localName, value = null } = options;
|
|
32
|
-
|
|
33
|
-
this.namespaceURI = namespaceURI;
|
|
34
|
-
this.localName = localName;
|
|
35
|
-
this.value = value;
|
|
36
|
-
|
|
37
|
-
if (namespaceURI === XFORMS_NAMESPACE_URI) {
|
|
38
|
-
this.isXFormsNamespace = true;
|
|
39
|
-
} else if (parent == null || parent.isXFormsNamespace) {
|
|
40
|
-
this.isXFormsNamespace = namespaceURI == null;
|
|
41
|
-
} else {
|
|
42
|
-
this.isXFormsNamespace = false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
import type { ClientReactiveSubmittableInstance } from '../../../instance/internal-api/submission/ClientReactiveSubmittableInstance.ts';
|
|
3
|
-
|
|
4
|
-
export const createInstanceSubmissionState = (
|
|
5
|
-
node: ClientReactiveSubmittableInstance
|
|
6
|
-
): SubmissionState => {
|
|
7
|
-
return {
|
|
8
|
-
get submissionXML(): string {
|
|
9
|
-
return node.root.submissionState.submissionXML;
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
import type { ClientReactiveSubmittableLeafNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
3
|
-
import { escapeXMLText, serializeLeafElementXML } from '../../xml-serialization.ts';
|
|
4
|
-
|
|
5
|
-
export const createLeafNodeSubmissionState = <Value>(
|
|
6
|
-
node: ClientReactiveSubmittableLeafNode<Value>
|
|
7
|
-
): SubmissionState => {
|
|
8
|
-
return {
|
|
9
|
-
get submissionXML() {
|
|
10
|
-
if (!node.currentState.relevant) {
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const value = node.encodeValue(node.currentState.value);
|
|
15
|
-
const xmlValue = escapeXMLText(value);
|
|
16
|
-
|
|
17
|
-
return serializeLeafElementXML(node.definition.nodeName, xmlValue);
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
import type { ClientReactiveSubmittableParentNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
3
|
-
import type { RepeatInstance } from '../../../instance/repeat/RepeatInstance.ts';
|
|
4
|
-
|
|
5
|
-
export const createNodeRangeSubmissionState = (
|
|
6
|
-
node: ClientReactiveSubmittableParentNode<RepeatInstance>
|
|
7
|
-
): SubmissionState => {
|
|
8
|
-
return {
|
|
9
|
-
get submissionXML() {
|
|
10
|
-
const serializedChildren = node.currentState.children.map((child) => {
|
|
11
|
-
return child.submissionState.submissionXML;
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
return serializedChildren.join('');
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
-
import type { GeneralChildNode } from '../../../instance/hierarchy.ts';
|
|
3
|
-
import type { ClientReactiveSubmittableParentNode } from '../../../instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
4
|
-
import { serializeParentElementXML } from '../../xml-serialization.ts';
|
|
5
|
-
|
|
6
|
-
export const createParentNodeSubmissionState = (
|
|
7
|
-
node: ClientReactiveSubmittableParentNode<GeneralChildNode>
|
|
8
|
-
): SubmissionState => {
|
|
9
|
-
return {
|
|
10
|
-
get submissionXML() {
|
|
11
|
-
if (!node.currentState.relevant) {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const serializedChildren = node.currentState.children.map((child) => {
|
|
16
|
-
return child.submissionState.submissionXML;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return serializeParentElementXML(node.definition.nodeName, serializedChildren);
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
};
|