@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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { PartiallyKnownString } from '@getodk/common/types/string/PartiallyKnownString.ts';
|
|
3
|
+
import type { BindElement } from './BindElement.ts';
|
|
4
|
+
|
|
5
|
+
type PartiallyKnownPreloadParameter<Known extends string> =
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
7
|
+
PartiallyKnownString<NonNullable<Known>> | Extract<Known, null>;
|
|
8
|
+
|
|
9
|
+
interface PreloadParametersByType {
|
|
10
|
+
readonly uid: string | null;
|
|
11
|
+
readonly date: PartiallyKnownPreloadParameter<'today'>;
|
|
12
|
+
readonly timestamp: PartiallyKnownPreloadParameter<'end' | 'start'>;
|
|
13
|
+
|
|
14
|
+
readonly property: PartiallyKnownPreloadParameter<
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
'deviceid' | 'email' | 'phonenumber' | 'username'
|
|
17
|
+
>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type PreloadType = PartiallyKnownString<keyof PreloadParametersByType>;
|
|
21
|
+
|
|
22
|
+
// prettier-ignore
|
|
23
|
+
type PreloadParameter<Type extends PreloadType> =
|
|
24
|
+
Type extends keyof PreloadParametersByType
|
|
25
|
+
? PreloadParametersByType[Type]
|
|
26
|
+
: string | null;
|
|
27
|
+
|
|
28
|
+
interface PreloadInput<Type extends PreloadType> {
|
|
29
|
+
readonly type: Type;
|
|
30
|
+
readonly parameter: PreloadParameter<Type>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type AnyPreloadInput = {
|
|
34
|
+
[Type in PreloadType]: PreloadInput<Type>;
|
|
35
|
+
}[PreloadType];
|
|
36
|
+
|
|
37
|
+
const getPreloadInput = (bindElement: BindElement): AnyPreloadInput | null => {
|
|
38
|
+
const type = bindElement.getAttributeNS(JAVAROSA_NAMESPACE_URI, 'preload');
|
|
39
|
+
|
|
40
|
+
if (type == null) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const parameter: PreloadParameter<typeof type> = bindElement.getAttributeNS(
|
|
45
|
+
JAVAROSA_NAMESPACE_URI,
|
|
46
|
+
'preloadParams'
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
type,
|
|
51
|
+
parameter,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parsed representation of
|
|
57
|
+
* {@link https://getodk.github.io/xforms-spec/#preload-attributes | Preload Attributes}.
|
|
58
|
+
* If specified on a
|
|
59
|
+
* {@link https://getodk.github.io/xforms-spec/#bindings | binding}, this will
|
|
60
|
+
* be parsed to define:
|
|
61
|
+
*
|
|
62
|
+
* - {@link type}, a `jr:preload`
|
|
63
|
+
* - {@link parameter}, an associated `jr:preloadParams` value
|
|
64
|
+
*
|
|
65
|
+
* @todo It would probably make sense for the _definition_ to also convey:
|
|
66
|
+
*
|
|
67
|
+
* 1. Which {@link https://getodk.github.io/xforms-spec/#events | event} the
|
|
68
|
+
* preload is semantically associated with (noting that the spec may be a tad
|
|
69
|
+
* overzealous about this association).
|
|
70
|
+
*
|
|
71
|
+
* 2. The constant XPath expression (or other computation?) expressed by the
|
|
72
|
+
* combined {@link type} and {@link parameter}.
|
|
73
|
+
*/
|
|
74
|
+
export class BindPreloadDefinition<Type extends PreloadType> implements PreloadInput<Type> {
|
|
75
|
+
static from(bindElement: BindElement): AnyBindPreloadDefinition | null {
|
|
76
|
+
const input = getPreloadInput(bindElement);
|
|
77
|
+
|
|
78
|
+
if (input == null) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return new this(input);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
readonly type: Type;
|
|
86
|
+
readonly parameter: PreloadParameter<Type>;
|
|
87
|
+
|
|
88
|
+
private constructor(input: PreloadInput<Type>) {
|
|
89
|
+
this.type = input.type;
|
|
90
|
+
this.parameter = input.parameter;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
export type AnyBindPreloadDefinition =
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
97
|
+
| BindPreloadDefinition<'uid'>
|
|
98
|
+
| BindPreloadDefinition<'timestamp'>
|
|
99
|
+
| BindPreloadDefinition<'property'>
|
|
100
|
+
| BindPreloadDefinition<string>;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
2
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
NodeChildren,
|
|
6
|
-
NodeDefaultValue,
|
|
7
|
-
NodeDefinition,
|
|
8
|
-
NodeDefinitionType,
|
|
9
|
-
NodeInstances,
|
|
10
|
-
NodeParent,
|
|
11
|
-
} from './NodeDefinition.ts';
|
|
3
|
+
import type { NodeDefinitionType, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
4
|
+
import { NodeDefinition } from './NodeDefinition.ts';
|
|
12
5
|
import type { RootDefinition } from './RootDefinition.ts';
|
|
13
6
|
|
|
14
7
|
export type DescendentNodeType = Exclude<NodeDefinitionType, 'root'>;
|
|
@@ -18,32 +11,21 @@ type DescendentNodeBodyElement = AnyBodyElementDefinition;
|
|
|
18
11
|
export abstract class DescendentNodeDefinition<
|
|
19
12
|
Type extends DescendentNodeType,
|
|
20
13
|
BodyElement extends DescendentNodeBodyElement | null = DescendentNodeBodyElement | null,
|
|
21
|
-
>
|
|
22
|
-
{
|
|
23
|
-
abstract readonly type: Type;
|
|
24
|
-
abstract readonly children: NodeChildren<Type>;
|
|
25
|
-
abstract readonly instances: NodeInstances<Type>;
|
|
26
|
-
abstract readonly defaultValue: NodeDefaultValue<Type>;
|
|
27
|
-
abstract readonly node: ModelNode<Type>;
|
|
28
|
-
abstract readonly nodeName: string;
|
|
29
|
-
|
|
14
|
+
> extends NodeDefinition<Type> {
|
|
30
15
|
readonly root: RootDefinition;
|
|
31
|
-
readonly nodeset: string;
|
|
32
16
|
readonly isTranslated: boolean = false;
|
|
33
17
|
|
|
34
18
|
constructor(
|
|
35
|
-
readonly parent:
|
|
36
|
-
|
|
19
|
+
readonly parent: ParentNodeDefinition,
|
|
20
|
+
bind: BindDefinition,
|
|
37
21
|
readonly bodyElement: BodyElement
|
|
38
22
|
) {
|
|
23
|
+
super(bind);
|
|
24
|
+
|
|
39
25
|
this.root = parent.root;
|
|
40
|
-
this.nodeset = bind.nodeset;
|
|
41
26
|
|
|
42
27
|
if (bind.isTranslated || bodyElement?.isTranslated) {
|
|
43
28
|
this.isTranslated = true;
|
|
44
29
|
}
|
|
45
30
|
}
|
|
46
31
|
}
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
export type AnyDescendantNodeDefinition = DescendentNodeDefinition<any, any>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
XFORMS_KNOWN_ATTRIBUTE,
|
|
3
|
+
XFORMS_LOCAL_NAME,
|
|
4
|
+
XFormsItextTranslationMap,
|
|
5
|
+
} from '@getodk/xpath';
|
|
6
|
+
import { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
7
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
8
|
+
import type { XFormDOM } from '../XFormDOM.ts';
|
|
9
|
+
import { parseStaticDocumentFromDOMSubtree } from '../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
10
|
+
|
|
11
|
+
export interface ItextTranslationDefinition extends StaticDocument {
|
|
12
|
+
readonly rootDocument: ItextTranslationDefinition;
|
|
13
|
+
readonly root: ItextTranslationRootDefinition;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ItextTranslationRootDefinition extends StaticElement {
|
|
17
|
+
readonly [XFORMS_LOCAL_NAME]: 'translation';
|
|
18
|
+
readonly [XFORMS_KNOWN_ATTRIBUTE]: 'lang';
|
|
19
|
+
|
|
20
|
+
readonly root: ItextTranslationRootDefinition;
|
|
21
|
+
readonly rootDocument: ItextTranslationDefinition;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type ItextTranslationsDefinitionEntry = readonly [
|
|
25
|
+
key: string,
|
|
26
|
+
value: ItextTranslationRootDefinition,
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
type AssertItextTranslationsDefinitionEntry = (
|
|
30
|
+
entry: readonly [key: string | null, value: StaticElement]
|
|
31
|
+
) => asserts entry is ItextTranslationsDefinitionEntry;
|
|
32
|
+
|
|
33
|
+
const assertItextTranslationsDefinitionEntry: AssertItextTranslationsDefinitionEntry = ([
|
|
34
|
+
key,
|
|
35
|
+
root,
|
|
36
|
+
]) => {
|
|
37
|
+
if (key == null || root.qualifiedName.localName !== 'translation') {
|
|
38
|
+
throw new Error();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @todo At time of writing, this shouldn't have any observable
|
|
44
|
+
* consequence—apart from preventing the potential mistake of using an
|
|
45
|
+
* {@link ItextTranslationDefinition} where an
|
|
46
|
+
* **instance**-as-{@link StaticDocument} would be expected (i.e. anything
|
|
47
|
+
* expecting an instance's {@link StaticDocument.nodeset} to be '/', or an its
|
|
48
|
+
* descendant elements' {@link StaticElement.nodeset} to start with '/'). The
|
|
49
|
+
* main intent, however, is to leave a breadcrumb back to ideas discussed in
|
|
50
|
+
* {@link https://github.com/getodk/web-forms/issues/22#issuecomment-2669228571 | Allow output in translation text (#22)}.
|
|
51
|
+
*/
|
|
52
|
+
const itextTranslationNodesetPrefix = (lang: string) => {
|
|
53
|
+
return `wf:translation('${lang}')`;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export class ItextTranslationsDefinition
|
|
57
|
+
extends Map<string, ItextTranslationRootDefinition>
|
|
58
|
+
implements XFormsItextTranslationMap<ItextTranslationRootDefinition>
|
|
59
|
+
{
|
|
60
|
+
static from(xformDOM: XFormDOM): ItextTranslationsDefinition {
|
|
61
|
+
const entries = xformDOM.itextTranslationElements.map((element) => {
|
|
62
|
+
const lang = element.getAttribute('lang');
|
|
63
|
+
const { root } = parseStaticDocumentFromDOMSubtree(element, {
|
|
64
|
+
nodesetPrefix: itextTranslationNodesetPrefix(lang),
|
|
65
|
+
});
|
|
66
|
+
const entry = [lang, root] as const;
|
|
67
|
+
|
|
68
|
+
assertItextTranslationsDefinitionEntry(entry);
|
|
69
|
+
|
|
70
|
+
return entry;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return new this(entries);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private constructor(entries: readonly ItextTranslationsDefinitionEntry[]) {
|
|
77
|
+
super(entries);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
3
|
+
import {
|
|
4
|
+
NamespaceDeclarationMap,
|
|
5
|
+
type NamedSubtreeDefinition,
|
|
6
|
+
} from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
7
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
2
8
|
import type { AnyBodyElementDefinition, ControlElementDefinition } from '../body/BodyDefinition.ts';
|
|
3
9
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
10
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
|
-
import type {
|
|
11
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
6
12
|
|
|
7
13
|
export class LeafNodeDefinition<V extends ValueType = ValueType>
|
|
8
14
|
extends DescendentNodeDefinition<'leaf-node', ControlElementDefinition | null>
|
|
9
|
-
implements
|
|
15
|
+
implements NamedSubtreeDefinition
|
|
10
16
|
{
|
|
11
17
|
readonly type = 'leaf-node';
|
|
12
18
|
readonly valueType: V;
|
|
13
19
|
|
|
14
|
-
readonly
|
|
20
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
21
|
+
readonly qualifiedName: QualifiedName;
|
|
15
22
|
readonly children = null;
|
|
16
|
-
readonly instances = null;
|
|
17
|
-
readonly defaultValue: string;
|
|
18
23
|
|
|
19
24
|
constructor(
|
|
20
25
|
parent: ParentNodeDefinition,
|
|
21
26
|
bind: BindDefinition,
|
|
22
27
|
bodyElement: AnyBodyElementDefinition | null,
|
|
23
|
-
readonly
|
|
28
|
+
readonly template: StaticLeafElement
|
|
24
29
|
) {
|
|
25
30
|
if (bodyElement != null && bodyElement.category !== 'control') {
|
|
26
31
|
throw new Error(`Unexpected body element for nodeset ${bind.nodeset}`);
|
|
@@ -29,8 +34,8 @@ export class LeafNodeDefinition<V extends ValueType = ValueType>
|
|
|
29
34
|
super(parent, bind, bodyElement);
|
|
30
35
|
|
|
31
36
|
this.valueType = bind.type.resolved satisfies ValueType as V;
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
37
|
+
this.qualifiedName = template.qualifiedName;
|
|
38
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
toJSON() {
|
|
@@ -1,21 +1,54 @@
|
|
|
1
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
2
|
+
import type { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
3
|
+
import { parseStaticDocumentFromDOMSubtree } from '../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
1
4
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
-
import {
|
|
3
|
-
import { ItextTranslationsDefinition } from './ItextTranslation/ItextTranslationsDefinition.ts';
|
|
5
|
+
import { ItextTranslationsDefinition } from './ItextTranslationsDefinition.ts';
|
|
4
6
|
import { ModelBindMap } from './ModelBindMap.ts';
|
|
7
|
+
import type { AnyNodeDefinition } from './NodeDefinition.ts';
|
|
8
|
+
import type { NodeDefinitionMap } from './nodeDefinitionMap.ts';
|
|
9
|
+
import { nodeDefinitionMap } from './nodeDefinitionMap.ts';
|
|
5
10
|
import { RootDefinition } from './RootDefinition.ts';
|
|
11
|
+
import { SubmissionDefinition } from './SubmissionDefinition.ts';
|
|
6
12
|
|
|
7
13
|
export class ModelDefinition {
|
|
8
14
|
readonly binds: ModelBindMap;
|
|
9
15
|
readonly root: RootDefinition;
|
|
16
|
+
readonly nodes: NodeDefinitionMap;
|
|
17
|
+
readonly instance: StaticDocument;
|
|
10
18
|
readonly itextTranslations: ItextTranslationsDefinition;
|
|
11
19
|
|
|
12
20
|
constructor(readonly form: XFormDefinition) {
|
|
13
|
-
const submission = new
|
|
21
|
+
const submission = new SubmissionDefinition(form.xformDOM);
|
|
22
|
+
|
|
14
23
|
this.binds = ModelBindMap.fromModel(this);
|
|
24
|
+
this.instance = parseStaticDocumentFromDOMSubtree(form.xformDOM.primaryInstanceRoot, {
|
|
25
|
+
nodesetPrefix: '/',
|
|
26
|
+
});
|
|
15
27
|
this.root = new RootDefinition(form, this, submission, form.body.classes);
|
|
28
|
+
this.nodes = nodeDefinitionMap(this.root);
|
|
16
29
|
this.itextTranslations = ItextTranslationsDefinition.from(form.xformDOM);
|
|
17
30
|
}
|
|
18
31
|
|
|
32
|
+
getNodeDefinition(nodeset: string): AnyNodeDefinition {
|
|
33
|
+
const definition = this.nodes.get(nodeset);
|
|
34
|
+
|
|
35
|
+
if (definition == null) {
|
|
36
|
+
throw new ErrorProductionDesignPendingError(`No definition for nodeset: ${nodeset}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return definition;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getRootDefinition(instance: StaticDocument): RootDefinition {
|
|
43
|
+
const definition = this.getNodeDefinition(instance.root.nodeset);
|
|
44
|
+
|
|
45
|
+
if (definition !== this.root) {
|
|
46
|
+
throw new ErrorProductionDesignPendingError();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return definition;
|
|
50
|
+
}
|
|
51
|
+
|
|
19
52
|
toJSON() {
|
|
20
53
|
const { form, ...rest } = this;
|
|
21
54
|
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
2
|
+
import type {
|
|
3
|
+
NamedSubtreeDefinition,
|
|
4
|
+
NamespaceDeclarationMap,
|
|
5
|
+
} from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
6
|
+
import type { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
7
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
8
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
3
9
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
10
|
import type { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
5
|
-
import type {
|
|
6
|
-
import type { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
7
|
-
import type { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
|
|
11
|
+
import type { AnyRepeatDefinition } from './RepeatDefinition.ts';
|
|
8
12
|
import type { RootDefinition } from './RootDefinition.ts';
|
|
9
13
|
import type { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
|
-
* Corresponds to
|
|
16
|
+
* Corresponds to a model instance root node, i.e.:
|
|
13
17
|
*
|
|
14
18
|
* - the element matching `/*` in primary instance expressions, a.k.a.
|
|
15
19
|
* - `/h:html/h:head/xf:model/xf:instance[1]/*`
|
|
@@ -17,34 +21,25 @@ import type { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
|
17
21
|
export type RootNodeType = 'root';
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
|
-
* Corresponds to
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
* an explicit `jr:template=""` attribute in the form definition or is inferred
|
|
28
|
-
* as a template from the form's first element matched by a <repeat nodeset>.
|
|
29
|
-
*/
|
|
30
|
-
export type RepeatTemplateType = 'repeat-template';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Corresponds to a single instance of a model/entry DOM subtree which
|
|
34
|
-
* in turn corresponds to a <repeat> in the form body definition, and a
|
|
35
|
-
* 'repeat-range' definition.
|
|
24
|
+
* Corresponds to the combined concepts defining a "repeat".
|
|
25
|
+
*
|
|
26
|
+
* @see {@link RepeatDefinition} for details on these concepts and how they are used to produce a "repeat definition", as such.
|
|
27
|
+
*
|
|
28
|
+
* , including or
|
|
29
|
+
* referencing all of the following:
|
|
30
|
+
*
|
|
36
31
|
*/
|
|
37
|
-
export type
|
|
32
|
+
export type RepeatType = 'repeat';
|
|
38
33
|
|
|
39
34
|
/**
|
|
40
|
-
* Corresponds to a model
|
|
35
|
+
* Corresponds to a model instance subtree which **does not** correspond to a
|
|
41
36
|
* <repeat> in the form definition. This will typically correspond to a <group>,
|
|
42
37
|
* but this is not strictly necessary per spec (hence the distinct name).
|
|
43
38
|
*/
|
|
44
39
|
export type SubtreeNodeType = 'subtree';
|
|
45
40
|
|
|
46
41
|
/**
|
|
47
|
-
* Corresponds to a model
|
|
42
|
+
* Corresponds to a model instance leaf node, i.e. one of:
|
|
48
43
|
*
|
|
49
44
|
* - An element with no child elements
|
|
50
45
|
* - Any attribute corresponding to a bind's `nodeset` expression
|
|
@@ -55,9 +50,7 @@ export type LeafNodeType = 'leaf-node';
|
|
|
55
50
|
export type NodeDefinitionType =
|
|
56
51
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
57
52
|
| RootNodeType
|
|
58
|
-
|
|
|
59
|
-
| RepeatTemplateType
|
|
60
|
-
| RepeatInstanceType
|
|
53
|
+
| RepeatType
|
|
61
54
|
| SubtreeNodeType
|
|
62
55
|
| LeafNodeType;
|
|
63
56
|
|
|
@@ -65,79 +58,39 @@ export type NodeDefinitionType =
|
|
|
65
58
|
export type ParentNodeDefinition =
|
|
66
59
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
67
60
|
| RootDefinition
|
|
68
|
-
|
|
|
69
|
-
| RepeatInstanceDefinition
|
|
61
|
+
| AnyRepeatDefinition
|
|
70
62
|
| SubtreeDefinition;
|
|
71
63
|
|
|
72
64
|
// prettier-ignore
|
|
73
65
|
export type ChildNodeDefinition =
|
|
74
|
-
|
|
|
66
|
+
| AnyRepeatDefinition
|
|
75
67
|
| LeafNodeDefinition
|
|
76
68
|
| SubtreeDefinition;
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
: null;
|
|
91
|
-
|
|
92
|
-
// prettier-ignore
|
|
93
|
-
export type NodeInstances<Type extends NodeDefinitionType> =
|
|
94
|
-
Type extends 'repeat-range'
|
|
95
|
-
? readonly RepeatInstanceDefinition[]
|
|
96
|
-
: null;
|
|
70
|
+
export abstract class NodeDefinition<Type extends NodeDefinitionType>
|
|
71
|
+
implements NamedSubtreeDefinition
|
|
72
|
+
{
|
|
73
|
+
abstract readonly type: Type;
|
|
74
|
+
abstract readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
75
|
+
abstract readonly qualifiedName: QualifiedName;
|
|
76
|
+
abstract readonly bodyElement: AnyBodyElementDefinition | RepeatElementDefinition | null;
|
|
77
|
+
abstract readonly isTranslated: boolean;
|
|
78
|
+
abstract readonly root: RootDefinition;
|
|
79
|
+
abstract readonly parent: ParentNodeDefinition | null;
|
|
80
|
+
abstract readonly template: StaticElement;
|
|
81
|
+
abstract readonly children: readonly ChildNodeDefinition[] | null;
|
|
97
82
|
|
|
98
|
-
// prettier-ignore
|
|
99
|
-
export type NodeParent<Type extends NodeDefinitionType> =
|
|
100
|
-
Type extends ChildNodeDefinition['type'] | ChildNodeInstanceDefinition['type']
|
|
101
|
-
? ParentNodeDefinition
|
|
102
|
-
: null;
|
|
103
|
-
|
|
104
|
-
// TODO: leaf-node may be Attr
|
|
105
|
-
// prettier-ignore
|
|
106
|
-
export type ModelNode<Type extends NodeDefinitionType> =
|
|
107
|
-
Type extends 'repeat-range'
|
|
108
|
-
? null
|
|
109
|
-
: Element;
|
|
110
|
-
|
|
111
|
-
// prettier-ignore
|
|
112
|
-
export type NodeDefaultValue<Type extends NodeDefinitionType> =
|
|
113
|
-
Type extends 'leaf-node'
|
|
114
|
-
? string
|
|
115
|
-
: null;
|
|
116
|
-
|
|
117
|
-
export interface NodeDefinition<Type extends NodeDefinitionType> {
|
|
118
|
-
readonly type: Type;
|
|
119
|
-
|
|
120
|
-
readonly bind: BindDefinition;
|
|
121
83
|
readonly nodeset: string;
|
|
122
|
-
readonly nodeName: string;
|
|
123
|
-
readonly bodyElement: AnyBodyElementDefinition | RepeatElementDefinition | null;
|
|
124
|
-
readonly isTranslated: boolean;
|
|
125
|
-
readonly root: RootDefinition;
|
|
126
|
-
readonly parent: NodeParent<Type>;
|
|
127
|
-
readonly children: NodeChildren<Type>;
|
|
128
|
-
readonly instances: NodeInstances<Type>;
|
|
129
84
|
|
|
130
|
-
readonly
|
|
131
|
-
|
|
85
|
+
constructor(readonly bind: BindDefinition) {
|
|
86
|
+
this.nodeset = bind.nodeset;
|
|
87
|
+
}
|
|
132
88
|
}
|
|
133
89
|
|
|
90
|
+
// prettier-ignore
|
|
134
91
|
export type AnyNodeDefinition =
|
|
135
92
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
136
93
|
| RootDefinition
|
|
137
|
-
|
|
|
138
|
-
| RepeatTemplateDefinition
|
|
139
|
-
| RepeatInstanceDefinition
|
|
94
|
+
| AnyRepeatDefinition
|
|
140
95
|
| SubtreeDefinition
|
|
141
96
|
| LeafNodeDefinition;
|
|
142
|
-
|
|
143
|
-
export type TypedNodeDefinition<Type> = Extract<AnyNodeDefinition, { readonly type: Type }>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { NoteNode } from '../../client/NoteNode.ts';
|
|
2
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
3
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
2
4
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
3
5
|
import type { InputControlDefinition } from '../body/control/InputControlDefinition.ts';
|
|
4
6
|
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
@@ -14,11 +16,11 @@ export type NoteReadonlyDefinition =
|
|
|
14
16
|
& BindComputationExpression<'readonly'>
|
|
15
17
|
& ConstantTruthyDependentExpression;
|
|
16
18
|
|
|
17
|
-
export interface NoteBindDefinition extends BindDefinition {
|
|
19
|
+
export interface NoteBindDefinition<V extends ValueType> extends BindDefinition<V> {
|
|
18
20
|
readonly readonly: NoteReadonlyDefinition;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
const isNoteBindDefinition = (bind: BindDefinition): bind is NoteBindDefinition => {
|
|
23
|
+
const isNoteBindDefinition = (bind: BindDefinition): bind is NoteBindDefinition<ValueType> => {
|
|
22
24
|
return bind.readonly.isConstantTruthyExpression();
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -37,13 +39,13 @@ export type NoteTextDefinition =
|
|
|
37
39
|
* aspects of the node's interface (such as its {@link NoteNode.nodeType} and
|
|
38
40
|
* distinct {@link NoteNode.currentState} types) to handle note-specific logic.
|
|
39
41
|
*/
|
|
40
|
-
export class NoteNodeDefinition extends LeafNodeDefinition {
|
|
41
|
-
static from(
|
|
42
|
+
export class NoteNodeDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
43
|
+
static from<V extends ValueType>(
|
|
42
44
|
parent: ParentNodeDefinition,
|
|
43
|
-
bind: BindDefinition
|
|
45
|
+
bind: BindDefinition<V>,
|
|
44
46
|
bodyElement: AnyBodyElementDefinition | null,
|
|
45
|
-
node:
|
|
46
|
-
): NoteNodeDefinition | null {
|
|
47
|
+
node: StaticLeafElement
|
|
48
|
+
): NoteNodeDefinition<V> | null {
|
|
47
49
|
if (!isNoteBindDefinition(bind) || bodyElement?.type !== 'input') {
|
|
48
50
|
return null;
|
|
49
51
|
}
|
|
@@ -60,11 +62,11 @@ export class NoteNodeDefinition extends LeafNodeDefinition {
|
|
|
60
62
|
|
|
61
63
|
constructor(
|
|
62
64
|
parent: ParentNodeDefinition,
|
|
63
|
-
override readonly bind: NoteBindDefinition
|
|
65
|
+
override readonly bind: NoteBindDefinition<V>,
|
|
64
66
|
override readonly bodyElement: InputControlDefinition,
|
|
65
67
|
readonly noteTextDefinition: NoteTextDefinition,
|
|
66
|
-
|
|
68
|
+
template: StaticLeafElement
|
|
67
69
|
) {
|
|
68
|
-
super(parent, bind, bodyElement,
|
|
70
|
+
super(parent, bind, bodyElement, template);
|
|
69
71
|
}
|
|
70
72
|
}
|