@getodk/xforms-engine 0.4.0 → 0.6.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 +18 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +82 -0
- package/dist/client/ModelValueNode.d.ts +13 -7
- package/dist/client/NoteNode.d.ts +26 -9
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +37 -7
- 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/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +8 -8
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +3 -2
- package/dist/client/resources.d.ts +93 -0
- package/dist/client/submission/SubmissionData.d.ts +7 -0
- package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
- package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
- package/dist/client/submission/SubmissionOptions.d.ts +23 -0
- package/dist/client/submission/SubmissionResult.d.ts +91 -0
- package/dist/client/submission/SubmissionState.d.ts +12 -0
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
- package/dist/client/validation.d.ts +2 -2
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -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/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -0
- package/dist/error/XPathFunctionalityError.d.ts +14 -0
- package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
- package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.js +17864 -14655
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +10 -4
- package/dist/instance/InputControl.d.ts +38 -0
- package/dist/instance/ModelValue.d.ts +17 -25
- package/dist/instance/Note.d.ts +16 -21
- package/dist/instance/PrimaryInstance.d.ts +85 -0
- package/dist/instance/RangeControl.d.ts +34 -0
- package/dist/instance/RankControl.d.ts +40 -0
- package/dist/instance/Root.d.ts +30 -25
- package/dist/instance/SelectControl.d.ts +66 -0
- package/dist/instance/Subtree.d.ts +11 -5
- package/dist/instance/TriggerControl.d.ts +13 -19
- package/dist/instance/abstract/DescendantNode.d.ts +32 -25
- package/dist/instance/abstract/InstanceNode.d.ts +52 -30
- package/dist/instance/abstract/UnsupportedControl.d.ts +11 -3
- package/dist/instance/abstract/ValueNode.d.ts +47 -0
- package/dist/instance/hierarchy.d.ts +13 -12
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
- package/dist/instance/internal-api/InstanceValueContext.d.ts +22 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
- package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +32 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +19 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +18 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +12 -29
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
- package/dist/instance/resource.d.ts +1 -1
- package/dist/instance/text/TextRange.d.ts +1 -1
- package/dist/instance/unsupported/UploadControl.d.ts +3 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
- package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
- package/dist/integration/xpath/adapter/kind.d.ts +32 -0
- package/dist/integration/xpath/adapter/names.d.ts +6 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +26 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +26 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +15 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +48 -0
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
- package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
- package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -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/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -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 +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- 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 +48 -0
- 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 +4 -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/number-parsers.d.ts +2 -0
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
- package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -10
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
- package/dist/lib/xml-serialization.d.ts +50 -0
- package/dist/parse/XFormDOM.d.ts +18 -7
- package/dist/parse/XFormDefinition.d.ts +1 -2
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/parse/body/BodyDefinition.d.ts +4 -4
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +4 -1
- 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/expression/abstract/DependencyContext.d.ts +0 -5
- package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
- package/dist/parse/model/BindDefinition.d.ts +6 -5
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -14
- package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +9 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +9 -4
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +2 -0
- package/dist/parse/model/NodeDefinition.d.ts +16 -20
- package/dist/parse/model/NoteNodeDefinition.d.ts +9 -8
- package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
- package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
- package/dist/parse/model/RootAttributeMap.d.ts +23 -0
- package/dist/parse/model/RootDefinition.d.ts +12 -9
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
- package/dist/parse/model/SubtreeDefinition.d.ts +7 -4
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +23 -0
- 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/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +6 -3
- package/dist/solid.js +15437 -12246
- package/dist/solid.js.map +1 -1
- package/package.json +18 -13
- package/src/client/BaseNode.ts +21 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +113 -0
- package/src/client/ModelValueNode.ts +31 -7
- package/src/client/NoteNode.ts +45 -9
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +43 -7
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +12 -13
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +13 -7
- package/src/client/resources.ts +118 -0
- package/src/client/submission/SubmissionData.ts +12 -0
- package/src/client/submission/SubmissionDefinition.ts +16 -0
- package/src/client/submission/SubmissionInstanceFile.ts +9 -0
- package/src/client/submission/SubmissionOptions.ts +28 -0
- package/src/client/submission/SubmissionResult.ts +124 -0
- package/src/client/submission/SubmissionState.ts +14 -0
- package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -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/ValueTypeInvariantError.ts +22 -0
- package/src/error/XFormsSpecViolationError.ts +1 -0
- package/src/error/XPathFunctionalityError.ts +26 -0
- package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
- package/src/error/XPathFunctionalityPendingError.ts +18 -0
- package/src/index.ts +12 -13
- package/src/instance/Group.ts +18 -5
- package/src/instance/InputControl.ts +159 -0
- package/src/instance/ModelValue.ts +48 -53
- package/src/instance/Note.ts +40 -49
- package/src/instance/PrimaryInstance.ts +245 -0
- package/src/instance/RangeControl.ts +113 -0
- package/src/instance/RankControl.ts +199 -0
- package/src/instance/Root.ts +63 -134
- package/src/instance/SelectControl.ts +219 -0
- package/src/instance/Subtree.ts +20 -7
- package/src/instance/TriggerControl.ts +44 -66
- package/src/instance/abstract/DescendantNode.ts +91 -51
- package/src/instance/abstract/InstanceNode.ts +113 -107
- package/src/instance/abstract/UnsupportedControl.ts +29 -5
- package/src/instance/abstract/ValueNode.ts +128 -0
- package/src/instance/children.ts +80 -40
- package/src/instance/hierarchy.ts +39 -30
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +25 -7
- package/src/instance/internal-api/EvaluationContext.ts +60 -13
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +26 -0
- package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
- package/src/instance/internal-api/TranslationContext.ts +3 -2
- package/src/instance/internal-api/ValidationContext.ts +3 -4
- package/src/instance/internal-api/ValueContext.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +43 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +26 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +24 -0
- package/src/instance/repeat/BaseRepeatRange.ts +52 -131
- package/src/instance/repeat/RepeatInstance.ts +21 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +5 -2
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/UploadControl.ts +5 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
- package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
- package/src/integration/xpath/adapter/kind.ts +114 -0
- package/src/integration/xpath/adapter/names.ts +148 -0
- package/src/integration/xpath/adapter/traversal.ts +229 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +41 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +36 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +119 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- package/src/lib/client-reactivity/README.md +0 -0
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
- package/src/lib/client-reactivity/submission/createRootSubmissionState.ts +19 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
- package/src/lib/codecs/DecimalValueCodec.ts +46 -0
- package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +79 -0
- 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 +8 -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/number-parsers.ts +25 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +216 -0
- package/src/lib/reactivity/createItemCollection.ts +173 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +62 -120
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/text/createTextRange.ts +4 -3
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +163 -0
- package/src/parse/XFormDOM.ts +231 -76
- package/src/parse/XFormDefinition.ts +2 -10
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +7 -7
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +29 -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/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +9 -8
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -31
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +42 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/parse/model/LeafNodeDefinition.ts +15 -5
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +24 -48
- package/src/parse/model/NoteNodeDefinition.ts +11 -10
- package/src/parse/model/RangeNodeDefinition.ts +118 -0
- package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
- package/src/parse/model/RepeatRangeDefinition.ts +11 -7
- package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
- package/src/parse/model/RootAttributeDefinition.ts +45 -0
- package/src/parse/model/RootAttributeMap.ts +44 -0
- package/src/parse/model/RootDefinition.ts +31 -29
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +415 -0
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
- package/src/parse/model/SubtreeDefinition.ts +12 -12
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- 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/text/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +33 -3
- package/dist/client/StringNode.d.ts +0 -46
- 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 -50
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/instance/unsupported/RangeControl.d.ts +0 -4
- package/dist/instance/unsupported/RankControl.d.ts +0 -4
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/parse/XFormDataType.d.ts +0 -25
- 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 -11
- package/src/client/StringNode.ts +0 -52
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -226
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/instance/unsupported/RangeControl.ts +0 -5
- package/src/instance/unsupported/RankControl.ts +0 -5
- package/src/lib/reactivity/createSelectItems.ts +0 -168
- package/src/parse/XFormDataType.ts +0 -62
- package/src/parse/body/control/InputDefinition.ts +0 -22
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -26
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { XSD_NAMESPACE_URI, XSD_PREFIX } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import { parseQualifiedNameExpression } from '../xpath/semantic-analysis.ts';
|
|
3
|
+
import type { BindElement } from './BindElement.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* As specified by {@link https://getodk.github.io/xforms-spec/#bind-attributes}
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_BIND_TYPE = 'string';
|
|
9
|
+
|
|
10
|
+
export type DefaultBindType = typeof DEFAULT_BIND_TYPE;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* As specified by {@link https://getodk.github.io/xforms-spec/#data-types}
|
|
14
|
+
*/
|
|
15
|
+
const BIND_TYPES = [
|
|
16
|
+
DEFAULT_BIND_TYPE,
|
|
17
|
+
'int',
|
|
18
|
+
'boolean',
|
|
19
|
+
'decimal',
|
|
20
|
+
'date',
|
|
21
|
+
'time',
|
|
22
|
+
'dateTime',
|
|
23
|
+
'geopoint',
|
|
24
|
+
'geotrace',
|
|
25
|
+
'geoshape',
|
|
26
|
+
'binary',
|
|
27
|
+
'barcode',
|
|
28
|
+
'intent',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
type BindTypes = typeof BIND_TYPES;
|
|
32
|
+
|
|
33
|
+
export type BindType = BindTypes[number];
|
|
34
|
+
|
|
35
|
+
const isBindType = (value: string): value is BindType => {
|
|
36
|
+
return BIND_TYPES.includes(value as BindType);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const resolveSupportedBindType = (sourceType: string): BindType | null => {
|
|
40
|
+
return isBindType(sourceType) ? sourceType : null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type BindTypeAliasMapping = Readonly<Record<string, BindType>>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @todo should we make these aliases explicit (rather than relying on {@link resolveUnsupportedBindType})?
|
|
47
|
+
*
|
|
48
|
+
* - select1
|
|
49
|
+
* - rank
|
|
50
|
+
* - odk:rank
|
|
51
|
+
*/
|
|
52
|
+
const BIND_TYPE_ALIASES: BindTypeAliasMapping = {
|
|
53
|
+
integer: 'int',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @todo Should this be marked deprecated?
|
|
58
|
+
* @todo Should we warn on alias resolution?
|
|
59
|
+
*/
|
|
60
|
+
const resolveAliasedBindType = (sourceType: string): BindType | null => {
|
|
61
|
+
return BIND_TYPE_ALIASES[sourceType] ?? null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @todo Should we warn on this fallback?
|
|
66
|
+
*/
|
|
67
|
+
const resolveUnsupportedBindType = (_unsupportedType: string): BindType => {
|
|
68
|
+
return DEFAULT_BIND_TYPE;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface BindDataTypeNamespaceResolver {
|
|
72
|
+
lookupNamespaceURI(prefix: string | null): string | null;
|
|
73
|
+
lookupPrefix(namespaceURI: string | null): string | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the XML Schema namespace prefix by:
|
|
78
|
+
*
|
|
79
|
+
* - Explicitly declared prefix, if any
|
|
80
|
+
* - Default to {@link XSD_PREFIX} _unless that prefix is bound to some other
|
|
81
|
+
* namespace URI_
|
|
82
|
+
*/
|
|
83
|
+
const resolveXMLSchemaNamespacePrefix = (
|
|
84
|
+
resolver: BindDataTypeNamespaceResolver
|
|
85
|
+
): string | null => {
|
|
86
|
+
const declaredPrefix = resolver.lookupPrefix(XSD_NAMESPACE_URI);
|
|
87
|
+
|
|
88
|
+
if (declaredPrefix != null) {
|
|
89
|
+
return declaredPrefix;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (resolver.lookupNamespaceURI(XSD_PREFIX) == null) {
|
|
93
|
+
return XSD_PREFIX;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
interface MaybeBindElementNamespaceResolver
|
|
100
|
+
extends BindElement,
|
|
101
|
+
Partial<BindDataTypeNamespaceResolver> {}
|
|
102
|
+
|
|
103
|
+
interface BindElementNamespaceResolver extends BindElement, BindDataTypeNamespaceResolver {}
|
|
104
|
+
|
|
105
|
+
const isNamespaceResolver = (
|
|
106
|
+
bindElement: MaybeBindElementNamespaceResolver
|
|
107
|
+
): bindElement is BindElementNamespaceResolver => {
|
|
108
|
+
return (
|
|
109
|
+
typeof bindElement.lookupNamespaceURI === 'function' &&
|
|
110
|
+
typeof bindElement.lookupPrefix === 'function'
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const resolveNamespacedBindType = (
|
|
115
|
+
bindElement: BindElement,
|
|
116
|
+
sourceType: string
|
|
117
|
+
): BindType | null => {
|
|
118
|
+
if (!isNamespaceResolver(bindElement)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const qualifiedName = parseQualifiedNameExpression(sourceType);
|
|
123
|
+
|
|
124
|
+
if (qualifiedName == null) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const xsdPrefix = resolveXMLSchemaNamespacePrefix(bindElement);
|
|
129
|
+
|
|
130
|
+
if (xsdPrefix == null) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const { prefix, localPart } = qualifiedName;
|
|
135
|
+
|
|
136
|
+
if (prefix === xsdPrefix) {
|
|
137
|
+
return (
|
|
138
|
+
resolveSupportedBindType(localPart) ??
|
|
139
|
+
resolveAliasedBindType(localPart) ??
|
|
140
|
+
resolveUnsupportedBindType(localPart)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const resolveBindType = (bindElement: BindElement, sourceType: string): BindType => {
|
|
148
|
+
return (
|
|
149
|
+
resolveSupportedBindType(sourceType) ??
|
|
150
|
+
resolveAliasedBindType(sourceType) ??
|
|
151
|
+
resolveNamespacedBindType(bindElement, sourceType) ??
|
|
152
|
+
resolveUnsupportedBindType(sourceType)
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export class BindTypeDefinition<T extends BindType = BindType> {
|
|
157
|
+
static from<T extends BindType>(bindElement: BindElement): BindTypeDefinition<T> {
|
|
158
|
+
const sourceType = bindElement.getAttribute('type');
|
|
159
|
+
|
|
160
|
+
if (sourceType == null) {
|
|
161
|
+
return new this(sourceType, DEFAULT_BIND_TYPE);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const resolved = resolveBindType(bindElement, sourceType);
|
|
165
|
+
|
|
166
|
+
return new this(sourceType, resolved);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private constructor(source: null, resolved: DefaultBindType);
|
|
170
|
+
private constructor(source: string, resolved: BindType);
|
|
171
|
+
private constructor(
|
|
172
|
+
readonly source: string | null,
|
|
173
|
+
readonly resolved: T
|
|
174
|
+
) {}
|
|
175
|
+
}
|
|
@@ -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,38 +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
|
-
readonly dependencyExpressions: ReadonlySet<string>;
|
|
33
16
|
readonly isTranslated: boolean = false;
|
|
34
17
|
|
|
35
18
|
constructor(
|
|
36
|
-
readonly parent:
|
|
37
|
-
|
|
19
|
+
readonly parent: ParentNodeDefinition,
|
|
20
|
+
bind: BindDefinition,
|
|
38
21
|
readonly bodyElement: BodyElement
|
|
39
22
|
) {
|
|
23
|
+
super(bind);
|
|
24
|
+
|
|
40
25
|
this.root = parent.root;
|
|
41
|
-
this.nodeset = bind.nodeset;
|
|
42
26
|
|
|
43
27
|
if (bind.isTranslated || bodyElement?.isTranslated) {
|
|
44
28
|
this.isTranslated = true;
|
|
45
29
|
}
|
|
46
|
-
|
|
47
|
-
this.dependencyExpressions = new Set([
|
|
48
|
-
...bind.dependencyExpressions,
|
|
49
|
-
...(bodyElement?.dependencyExpressions ?? []),
|
|
50
|
-
]);
|
|
51
30
|
}
|
|
52
31
|
}
|
|
53
|
-
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
export type AnyDescendantNodeDefinition = DescendentNodeDefinition<any, any>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { SubmissionDefinition } from '../../client/submission/SubmissionDefinition.ts';
|
|
2
|
+
import { getSubmissionElement } from '../../lib/dom/query.ts';
|
|
3
|
+
import type { XFormDOM } from '../XFormDOM.ts';
|
|
4
|
+
|
|
5
|
+
export class FormSubmissionDefinition implements SubmissionDefinition {
|
|
6
|
+
readonly submissionAction!: URL | null;
|
|
7
|
+
readonly submissionMethod = 'post';
|
|
8
|
+
readonly encryptionKey!: string | null;
|
|
9
|
+
|
|
10
|
+
constructor(xformDOM: XFormDOM) {
|
|
11
|
+
const submissionElement = getSubmissionElement(xformDOM.model);
|
|
12
|
+
|
|
13
|
+
let submissionAction: URL | null = null;
|
|
14
|
+
let submissionMethod: 'post';
|
|
15
|
+
let encryptionKey: string | null = null;
|
|
16
|
+
|
|
17
|
+
if (submissionElement == null) {
|
|
18
|
+
submissionAction = null;
|
|
19
|
+
submissionMethod = 'post';
|
|
20
|
+
encryptionKey = null;
|
|
21
|
+
} else {
|
|
22
|
+
const method = submissionElement.getAttribute('method')?.trim();
|
|
23
|
+
|
|
24
|
+
if (method == null || method === 'post' || method === 'form-data-post') {
|
|
25
|
+
submissionMethod = 'post';
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error(`Unexpected <submission method>: ${method}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const action = submissionElement.getAttribute('action');
|
|
31
|
+
|
|
32
|
+
if (action != null) {
|
|
33
|
+
// TODO: this is known-fallible.
|
|
34
|
+
submissionAction = new URL(action.trim());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
encryptionKey = submissionElement.getAttribute('base64RsaPublicKey');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.submissionAction = submissionAction;
|
|
41
|
+
this.submissionMethod = submissionMethod;
|
|
42
|
+
this.encryptionKey = encryptionKey;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StaticDocument } from '../../../integration/xpath/static-dom/StaticDocument.ts';
|
|
2
|
+
import { ItextTranslationRootDefinition } from './ItextTranslationRootDefinition.ts';
|
|
3
|
+
|
|
4
|
+
export class ItextTranslationDefinition extends StaticDocument<ItextTranslationRootDefinition> {}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { XFormsItextTranslationElement } from '@getodk/xpath';
|
|
2
|
+
import { XFORMS_KNOWN_ATTRIBUTE, XFORMS_LOCAL_NAME } from '@getodk/xpath';
|
|
3
|
+
import { StaticElement } from '../../../integration/xpath/static-dom/StaticElement.ts';
|
|
4
|
+
import type { ItextTranslationDefinition } from './ItextTranslationDefinition.ts';
|
|
5
|
+
|
|
6
|
+
// prettier-ignore
|
|
7
|
+
type ItextTranslationRootKnownAttributeValue<LocalName extends string> =
|
|
8
|
+
LocalName extends 'lang'
|
|
9
|
+
? string
|
|
10
|
+
: string | null;
|
|
11
|
+
|
|
12
|
+
type AssertItextTranslationRootKnownAttributeValue = <LocalName extends string>(
|
|
13
|
+
localName: LocalName,
|
|
14
|
+
value: string | null
|
|
15
|
+
) => asserts value is ItextTranslationRootKnownAttributeValue<LocalName>;
|
|
16
|
+
|
|
17
|
+
const assertItextTranslationRootKnownAttributeValue: AssertItextTranslationRootKnownAttributeValue =
|
|
18
|
+
(localName, value) => {
|
|
19
|
+
if (localName === 'lang' && value == null) {
|
|
20
|
+
throw new Error('Invalid itext <translation> element: missing `lang` attribute');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export class ItextTranslationRootDefinition
|
|
25
|
+
extends StaticElement<ItextTranslationDefinition>
|
|
26
|
+
implements XFormsItextTranslationElement<ItextTranslationRootDefinition>
|
|
27
|
+
{
|
|
28
|
+
override readonly [XFORMS_LOCAL_NAME] = 'translation';
|
|
29
|
+
override readonly [XFORMS_KNOWN_ATTRIBUTE] = 'lang';
|
|
30
|
+
|
|
31
|
+
override getAttributeValue(localName: 'lang'): string;
|
|
32
|
+
override getAttributeValue(localName: string): string | null;
|
|
33
|
+
override getAttributeValue<LocalName extends string>(
|
|
34
|
+
localName: LocalName
|
|
35
|
+
): ItextTranslationRootKnownAttributeValue<LocalName> {
|
|
36
|
+
const value = super.getAttributeValue(localName);
|
|
37
|
+
|
|
38
|
+
assertItextTranslationRootKnownAttributeValue(localName, value);
|
|
39
|
+
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { XFormsItextTranslationMap } from '@getodk/xpath';
|
|
2
|
+
import type { EngineXPathNode } from '../../../integration/xpath/adapter/kind.ts';
|
|
3
|
+
import { parseStaticDocumentFromDOMSubtree } from '../../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
4
|
+
import type { XFormDOM } from '../../XFormDOM.ts';
|
|
5
|
+
import { ItextTranslationDefinition } from './ItextTranslationDefinition.ts';
|
|
6
|
+
import { ItextTranslationRootDefinition } from './ItextTranslationRootDefinition.ts';
|
|
7
|
+
|
|
8
|
+
export class ItextTranslationsDefinition
|
|
9
|
+
extends Map<string, ItextTranslationRootDefinition>
|
|
10
|
+
implements XFormsItextTranslationMap<EngineXPathNode>
|
|
11
|
+
{
|
|
12
|
+
static from(xformDOM: XFormDOM): ItextTranslationsDefinition {
|
|
13
|
+
const translationDefinitions = xformDOM.itextTranslationElements.map((element) => {
|
|
14
|
+
return parseStaticDocumentFromDOMSubtree(
|
|
15
|
+
ItextTranslationDefinition,
|
|
16
|
+
ItextTranslationRootDefinition,
|
|
17
|
+
element
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return new this(translationDefinitions);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private constructor(translations: readonly ItextTranslationDefinition[]) {
|
|
25
|
+
super(
|
|
26
|
+
translations.map(({ root }) => {
|
|
27
|
+
return [root.getAttributeValue('lang'), root];
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import {
|
|
3
|
+
NamespaceDeclarationMap,
|
|
4
|
+
type NamedSubtreeDefinition,
|
|
5
|
+
} from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
6
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
7
|
import type { AnyBodyElementDefinition, ControlElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
8
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
3
9
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
4
|
-
import type {
|
|
10
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
5
11
|
|
|
6
|
-
export class LeafNodeDefinition
|
|
12
|
+
export class LeafNodeDefinition<V extends ValueType = ValueType>
|
|
7
13
|
extends DescendentNodeDefinition<'leaf-node', ControlElementDefinition | null>
|
|
8
|
-
implements
|
|
14
|
+
implements NamedSubtreeDefinition
|
|
9
15
|
{
|
|
10
16
|
readonly type = 'leaf-node';
|
|
17
|
+
readonly valueType: V;
|
|
11
18
|
|
|
12
|
-
readonly
|
|
19
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
20
|
+
readonly qualifiedName: QualifiedName;
|
|
13
21
|
readonly children = null;
|
|
14
22
|
readonly instances = null;
|
|
15
23
|
readonly defaultValue: string;
|
|
@@ -26,7 +34,9 @@ export class LeafNodeDefinition
|
|
|
26
34
|
|
|
27
35
|
super(parent, bind, bodyElement);
|
|
28
36
|
|
|
29
|
-
this.
|
|
37
|
+
this.valueType = bind.type.resolved satisfies ValueType as V;
|
|
38
|
+
this.qualifiedName = new QualifiedName(node);
|
|
39
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
30
40
|
this.defaultValue = node.textContent ?? '';
|
|
31
41
|
}
|
|
32
42
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
2
|
import { BindDefinition } from './BindDefinition.ts';
|
|
3
3
|
import type { BindElement, BindNodeset } from './BindElement.ts';
|
|
4
|
+
import { DEFAULT_BIND_TYPE } from './BindTypeDefinition.ts';
|
|
4
5
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
5
6
|
|
|
6
7
|
class ArtificialBindElement implements BindElement {
|
|
@@ -15,6 +16,10 @@ class ArtificialBindElement implements BindElement {
|
|
|
15
16
|
return this.ancestorNodeset;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
if (name === 'type') {
|
|
20
|
+
return DEFAULT_BIND_TYPE;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
return null;
|
|
19
24
|
}
|
|
20
25
|
|
|
@@ -37,15 +42,8 @@ export class ModelBindMap extends Map<BindNodeset, BindDefinition> {
|
|
|
37
42
|
protected readonly form: XFormDefinition,
|
|
38
43
|
protected readonly model: ModelDefinition
|
|
39
44
|
) {
|
|
40
|
-
const bindElements = form.xformDOM.rootEvaluator.evaluateNodes<BindElement & Element>(
|
|
41
|
-
'./xf:bind[@nodeset]',
|
|
42
|
-
{
|
|
43
|
-
contextNode: form.xformDOM.model,
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
|
|
47
45
|
super(
|
|
48
|
-
|
|
46
|
+
form.xformDOM.binds.map((bindElement) => {
|
|
49
47
|
const nodeset = bindElement.getAttribute('nodeset');
|
|
50
48
|
const bind = new BindDefinition(form, model, nodeset, bindElement);
|
|
51
49
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
+
import { FormSubmissionDefinition } from './FormSubmissionDefinition.ts';
|
|
3
|
+
import { ItextTranslationsDefinition } from './ItextTranslation/ItextTranslationsDefinition.ts';
|
|
2
4
|
import { ModelBindMap } from './ModelBindMap.ts';
|
|
3
5
|
import { RootDefinition } from './RootDefinition.ts';
|
|
4
6
|
|
|
5
7
|
export class ModelDefinition {
|
|
6
8
|
readonly binds: ModelBindMap;
|
|
7
9
|
readonly root: RootDefinition;
|
|
10
|
+
readonly itextTranslations: ItextTranslationsDefinition;
|
|
8
11
|
|
|
9
12
|
constructor(readonly form: XFormDefinition) {
|
|
13
|
+
const submission = new FormSubmissionDefinition(form.xformDOM);
|
|
10
14
|
this.binds = ModelBindMap.fromModel(this);
|
|
11
|
-
this.root = new RootDefinition(form, this, form.body.classes);
|
|
15
|
+
this.root = new RootDefinition(form, this, submission, form.body.classes);
|
|
16
|
+
this.itextTranslations = ItextTranslationsDefinition.from(form.xformDOM);
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
toJSON() {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
NamedSubtreeDefinition,
|
|
3
|
+
NamespaceDeclarationMap,
|
|
4
|
+
} from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
5
|
+
import type { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
6
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
7
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
3
8
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
@@ -83,55 +88,28 @@ export type ChildNodeInstanceDefinition =
|
|
|
83
88
|
| SubtreeDefinition
|
|
84
89
|
| LeafNodeDefinition;
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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;
|
|
91
|
+
export abstract class NodeDefinition<Type extends NodeDefinitionType>
|
|
92
|
+
implements NamedSubtreeDefinition
|
|
93
|
+
{
|
|
94
|
+
abstract readonly type: Type;
|
|
95
|
+
abstract readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
96
|
+
abstract readonly qualifiedName: QualifiedName;
|
|
97
|
+
abstract readonly bodyElement: AnyBodyElementDefinition | RepeatElementDefinition | null;
|
|
98
|
+
abstract readonly isTranslated: boolean;
|
|
99
|
+
abstract readonly root: RootDefinition;
|
|
100
|
+
abstract readonly parent: ParentNodeDefinition | null;
|
|
101
|
+
abstract readonly children: readonly ChildNodeDefinition[] | null;
|
|
102
|
+
abstract readonly instances: readonly RepeatInstanceDefinition[] | null;
|
|
103
|
+
abstract readonly defaultValue: string | null;
|
|
104
|
+
|
|
105
|
+
/** @todo leaf-node may be Attr */
|
|
106
|
+
abstract readonly node: Element | null;
|
|
110
107
|
|
|
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
108
|
readonly nodeset: string;
|
|
122
|
-
readonly nodeName: string;
|
|
123
|
-
readonly bodyElement: AnyBodyElementDefinition | RepeatElementDefinition | null;
|
|
124
109
|
|
|
125
|
-
readonly
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
readonly root: RootDefinition;
|
|
129
|
-
readonly parent: NodeParent<Type>;
|
|
130
|
-
readonly children: NodeChildren<Type>;
|
|
131
|
-
readonly instances: NodeInstances<Type>;
|
|
132
|
-
|
|
133
|
-
readonly node: ModelNode<Type>;
|
|
134
|
-
readonly defaultValue: NodeDefaultValue<Type>;
|
|
110
|
+
constructor(readonly bind: BindDefinition) {
|
|
111
|
+
this.nodeset = bind.nodeset;
|
|
112
|
+
}
|
|
135
113
|
}
|
|
136
114
|
|
|
137
115
|
export type AnyNodeDefinition =
|
|
@@ -142,5 +120,3 @@ export type AnyNodeDefinition =
|
|
|
142
120
|
| RepeatInstanceDefinition
|
|
143
121
|
| SubtreeDefinition
|
|
144
122
|
| LeafNodeDefinition;
|
|
145
|
-
|
|
146
|
-
export type TypedNodeDefinition<Type> = Extract<AnyNodeDefinition, { readonly type: Type }>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NoteNode } from '../../client/NoteNode.ts';
|
|
2
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
3
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
3
|
-
import type {
|
|
4
|
+
import type { InputControlDefinition } from '../body/control/InputControlDefinition.ts';
|
|
4
5
|
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
5
6
|
import type { ConstantTruthyDependentExpression } from '../expression/abstract/DependentExpression.ts';
|
|
6
7
|
import type { HintDefinition } from '../text/HintDefinition.ts';
|
|
@@ -14,11 +15,11 @@ export type NoteReadonlyDefinition =
|
|
|
14
15
|
& BindComputationExpression<'readonly'>
|
|
15
16
|
& ConstantTruthyDependentExpression;
|
|
16
17
|
|
|
17
|
-
export interface NoteBindDefinition extends BindDefinition {
|
|
18
|
+
export interface NoteBindDefinition<V extends ValueType> extends BindDefinition<V> {
|
|
18
19
|
readonly readonly: NoteReadonlyDefinition;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const isNoteBindDefinition = (bind: BindDefinition): bind is NoteBindDefinition => {
|
|
22
|
+
const isNoteBindDefinition = (bind: BindDefinition): bind is NoteBindDefinition<ValueType> => {
|
|
22
23
|
return bind.readonly.isConstantTruthyExpression();
|
|
23
24
|
};
|
|
24
25
|
|
|
@@ -31,19 +32,19 @@ export type NoteTextDefinition =
|
|
|
31
32
|
/**
|
|
32
33
|
* @package This class is used internally, both in static types and at runtime,
|
|
33
34
|
* to guard and guide the distinction between instance state nodes for 'note'
|
|
34
|
-
* and '
|
|
35
|
+
* and 'input' node types. It is intentionally package-private! The less
|
|
35
36
|
* specific {@link NoteNode.definition} type, if it has any client value at all,
|
|
36
37
|
* should be more than sufficient. Clients are otherwise expected to use other
|
|
37
38
|
* aspects of the node's interface (such as its {@link NoteNode.nodeType} and
|
|
38
39
|
* distinct {@link NoteNode.currentState} types) to handle note-specific logic.
|
|
39
40
|
*/
|
|
40
|
-
export class NoteNodeDefinition extends LeafNodeDefinition {
|
|
41
|
-
static from(
|
|
41
|
+
export class NoteNodeDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
42
|
+
static from<V extends ValueType>(
|
|
42
43
|
parent: ParentNodeDefinition,
|
|
43
|
-
bind: BindDefinition
|
|
44
|
+
bind: BindDefinition<V>,
|
|
44
45
|
bodyElement: AnyBodyElementDefinition | null,
|
|
45
46
|
node: Element
|
|
46
|
-
): NoteNodeDefinition | null {
|
|
47
|
+
): NoteNodeDefinition<V> | null {
|
|
47
48
|
if (!isNoteBindDefinition(bind) || bodyElement?.type !== 'input') {
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
@@ -60,8 +61,8 @@ export class NoteNodeDefinition extends LeafNodeDefinition {
|
|
|
60
61
|
|
|
61
62
|
constructor(
|
|
62
63
|
parent: ParentNodeDefinition,
|
|
63
|
-
override readonly bind: NoteBindDefinition
|
|
64
|
-
override readonly bodyElement:
|
|
64
|
+
override readonly bind: NoteBindDefinition<V>,
|
|
65
|
+
override readonly bodyElement: InputControlDefinition,
|
|
65
66
|
readonly noteTextDefinition: NoteTextDefinition,
|
|
66
67
|
node: Element
|
|
67
68
|
) {
|