@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
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import type { ItemElement } from '../../../lib/dom/query.ts';
|
|
2
|
+
import { getValueElement } from '../../../lib/dom/query.ts';
|
|
3
|
+
import { ItemLabelDefinition } from '../../text/ItemLabelDefinition.ts';
|
|
4
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
5
|
+
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
6
|
+
import type { AnySelectControlDefinition } from './SelectControlDefinition.ts';
|
|
7
|
+
import { RankControlDefinition } from './RankControlDefinition.ts';
|
|
6
8
|
|
|
7
9
|
export class ItemDefinition extends BodyElementDefinition<'item'> {
|
|
8
10
|
override readonly category = 'support';
|
|
@@ -13,7 +15,7 @@ export class ItemDefinition extends BodyElementDefinition<'item'> {
|
|
|
13
15
|
|
|
14
16
|
constructor(
|
|
15
17
|
form: XFormDefinition,
|
|
16
|
-
override readonly parent:
|
|
18
|
+
override readonly parent: AnySelectControlDefinition | RankControlDefinition,
|
|
17
19
|
element: ItemElement
|
|
18
20
|
) {
|
|
19
21
|
const valueElement = getValueElement(element);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
1
|
+
import type { ItemsetElement } from '../../../lib/dom/query.ts';
|
|
2
|
+
import { getValueElement } from '../../../lib/dom/query.ts';
|
|
3
|
+
import { ItemsetNodesetExpression } from '../../expression/ItemsetNodesetExpression.ts';
|
|
4
|
+
import { ItemsetValueExpression } from '../../expression/ItemsetValueExpression.ts';
|
|
5
|
+
import { ItemsetLabelDefinition } from '../../text/ItemsetLabelDefinition.ts';
|
|
6
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
7
|
+
import { parseNodesetReference } from '../../xpath/reference-parsing.ts';
|
|
8
|
+
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
9
|
+
import type { AnySelectControlDefinition } from './SelectControlDefinition.ts';
|
|
10
|
+
import { RankControlDefinition } from './RankControlDefinition.ts';
|
|
9
11
|
|
|
10
12
|
export class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
|
|
11
13
|
override readonly category = 'support';
|
|
@@ -19,7 +21,7 @@ export class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
|
|
|
19
21
|
|
|
20
22
|
constructor(
|
|
21
23
|
form: XFormDefinition,
|
|
22
|
-
override readonly parent:
|
|
24
|
+
override readonly parent: AnySelectControlDefinition | RankControlDefinition,
|
|
23
25
|
element: ItemsetElement
|
|
24
26
|
) {
|
|
25
27
|
super(form, parent, element);
|
|
@@ -1,23 +1,108 @@
|
|
|
1
|
+
import { ErrorProductionDesignPendingError } from '../../../error/ErrorProductionDesignPendingError.ts';
|
|
1
2
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type UnknownAppearanceDefinition,
|
|
5
|
-
} from '../appearance/unknownAppearanceParser.ts';
|
|
3
|
+
import type { RangeAppearanceDefinition } from '../appearance/rangeAppearanceParser.ts';
|
|
4
|
+
import { rangeAppearanceParser } from '../appearance/rangeAppearanceParser.ts';
|
|
6
5
|
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
7
6
|
import { ControlDefinition } from './ControlDefinition.ts';
|
|
8
7
|
|
|
8
|
+
type NumericString = `${number}`;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @todo this should likely become a basis for generalizing how we parse number
|
|
12
|
+
* values from strings. Note for when we take that on: number semantics vary
|
|
13
|
+
* between:
|
|
14
|
+
*
|
|
15
|
+
* - {@link https://www.w3.org/TR/1999/REC-xpath-19991116/#numbers | XPath}:
|
|
16
|
+
* XPath "64-bit [...] IEEE 754" number values are almost totally consistent
|
|
17
|
+
* with JavaScript numbers; the main difference is that JavaScript's
|
|
18
|
+
* {@link Number} factory is more flexible in casting from string than the
|
|
19
|
+
* casting semantics specified by XPath
|
|
20
|
+
*
|
|
21
|
+
* - {@link https://getodk.github.io/xforms-spec/#data-types | [ODK] XForms}:
|
|
22
|
+
* specifies both `int` and `decimal` types. Decimals are **NOT** expected to
|
|
23
|
+
* have the same precision tradeoffs as IEEE 754 numbers, and we'll want to
|
|
24
|
+
* take special care that parsing does not introduce precision errors.
|
|
25
|
+
*/
|
|
26
|
+
const NUMERIC_STRING_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
27
|
+
|
|
28
|
+
const isNumericString = (value: string): value is NumericString => {
|
|
29
|
+
return NUMERIC_STRING_PATTERN.test(value);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type AssertNumericStringAttribute = (
|
|
33
|
+
localName: string,
|
|
34
|
+
value: string | null
|
|
35
|
+
) => asserts value is NumericString;
|
|
36
|
+
|
|
37
|
+
const assertNumericStringAttribute: AssertNumericStringAttribute = (localName, value) => {
|
|
38
|
+
if (value == null) {
|
|
39
|
+
throw new ErrorProductionDesignPendingError(`Expected attribute ${localName} is not defined`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!isNumericString(value)) {
|
|
43
|
+
throw new ErrorProductionDesignPendingError(
|
|
44
|
+
`Expected attribute ${localName} to be defined with numeric string, got: ${JSON.stringify(value)}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const parseNumericStringAttribute = (element: Element, localName: string): NumericString => {
|
|
50
|
+
const value = element.getAttribute(localName);
|
|
51
|
+
|
|
52
|
+
assertNumericStringAttribute(localName, value);
|
|
53
|
+
|
|
54
|
+
return value;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Per
|
|
59
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | ODK XForms spec},
|
|
60
|
+
* the following attributes are required:
|
|
61
|
+
*
|
|
62
|
+
* - `start`
|
|
63
|
+
* - `end`
|
|
64
|
+
* - `step`
|
|
65
|
+
*
|
|
66
|
+
* While we also know that a `<range>` control is expected to have a bind type
|
|
67
|
+
* of either `decimal` or `int`, at this parsing stage we do not yet know which
|
|
68
|
+
* type is associated with the control. So we parse the attributes as strings,
|
|
69
|
+
* checking only that they appear to be numeric values. We also preserve the
|
|
70
|
+
* attributes' names here, for consistency with the spec.
|
|
71
|
+
*
|
|
72
|
+
* Downstream, we parse these to their appropriate numeric runtime types, and
|
|
73
|
+
* alias them to their more conventional names (i.e. "start" -> "min", "end" ->
|
|
74
|
+
* "max").
|
|
75
|
+
*/
|
|
76
|
+
export class RangeControlBoundsDefinition {
|
|
77
|
+
static from(element: Element) {
|
|
78
|
+
const start = parseNumericStringAttribute(element, 'start');
|
|
79
|
+
const end = parseNumericStringAttribute(element, 'end');
|
|
80
|
+
const step = parseNumericStringAttribute(element, 'step');
|
|
81
|
+
|
|
82
|
+
return new this(start, end, step);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
constructor(
|
|
86
|
+
readonly start: NumericString,
|
|
87
|
+
readonly end: NumericString,
|
|
88
|
+
readonly step: NumericString
|
|
89
|
+
) {}
|
|
90
|
+
}
|
|
91
|
+
|
|
9
92
|
export class RangeControlDefinition extends ControlDefinition<'range'> {
|
|
10
93
|
static override isCompatible(localName: string): boolean {
|
|
11
94
|
return localName === 'range';
|
|
12
95
|
}
|
|
13
96
|
|
|
14
97
|
readonly type = 'range';
|
|
15
|
-
readonly appearances:
|
|
98
|
+
readonly appearances: RangeAppearanceDefinition;
|
|
99
|
+
readonly bounds: RangeControlBoundsDefinition;
|
|
16
100
|
|
|
17
101
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
18
102
|
super(form, parent, element);
|
|
19
103
|
|
|
20
|
-
this.appearances =
|
|
104
|
+
this.appearances = rangeAppearanceParser.parseFrom(element, 'appearance');
|
|
105
|
+
this.bounds = RangeControlBoundsDefinition.from(element);
|
|
21
106
|
}
|
|
22
107
|
|
|
23
108
|
override toJSON(): object {
|
|
@@ -1,27 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getItemElements, getItemsetElement } from '../../../lib/dom/query.ts';
|
|
2
2
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
+
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
|
+
import { ControlDefinition } from './ControlDefinition.ts';
|
|
5
|
+
import { ItemsetDefinition } from './ItemsetDefinition.ts';
|
|
6
|
+
import { ItemDefinition } from './ItemDefinition.ts';
|
|
3
7
|
import {
|
|
4
|
-
unknownAppearanceParser,
|
|
5
8
|
type UnknownAppearanceDefinition,
|
|
9
|
+
unknownAppearanceParser,
|
|
6
10
|
} from '../appearance/unknownAppearanceParser.ts';
|
|
7
|
-
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
8
|
-
import { ControlDefinition } from './ControlDefinition.ts';
|
|
9
11
|
|
|
10
12
|
export class RankControlDefinition extends ControlDefinition<'rank'> {
|
|
11
|
-
static override isCompatible(localName: string
|
|
12
|
-
return localName === 'rank'
|
|
13
|
+
static override isCompatible(localName: string): boolean {
|
|
14
|
+
return localName === 'rank';
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
readonly type = 'rank';
|
|
16
18
|
readonly appearances: UnknownAppearanceDefinition;
|
|
19
|
+
readonly itemset: ItemsetDefinition | null;
|
|
20
|
+
readonly items: readonly ItemDefinition[];
|
|
17
21
|
|
|
18
22
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
19
23
|
super(form, parent, element);
|
|
20
24
|
|
|
21
25
|
this.appearances = unknownAppearanceParser.parseFrom(element, 'appearance');
|
|
26
|
+
const itemsetElement = getItemsetElement(element);
|
|
27
|
+
const itemElements = getItemElements(element);
|
|
28
|
+
|
|
29
|
+
if (itemsetElement === null || itemElements === undefined) {
|
|
30
|
+
this.itemset = null;
|
|
31
|
+
this.items = itemElements.map((itemElement) => new ItemDefinition(form, this, itemElement));
|
|
32
|
+
} else {
|
|
33
|
+
if (itemElements.length > 0) {
|
|
34
|
+
throw new Error(`<${element.nodeName}> has both <itemset> and <item> children`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.items = [];
|
|
38
|
+
this.itemset = new ItemsetDefinition(form, this, itemsetElement);
|
|
39
|
+
}
|
|
22
40
|
}
|
|
23
41
|
|
|
24
|
-
override toJSON()
|
|
42
|
+
override toJSON() {
|
|
25
43
|
return {};
|
|
26
44
|
}
|
|
27
45
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { CollectionValues } from '@getodk/common/types/collections/CollectionValues.ts';
|
|
2
2
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
3
|
-
import { getItemElements, getItemsetElement } from '
|
|
4
|
-
import type { XFormDefinition } from '
|
|
5
|
-
import type { SelectAppearanceDefinition } from '
|
|
6
|
-
import { selectAppearanceParser } from '
|
|
7
|
-
import type { AnyBodyElementDefinition, BodyElementParentContext } from '
|
|
8
|
-
import { ControlDefinition } from '
|
|
3
|
+
import { getItemElements, getItemsetElement } from '../../../lib/dom/query.ts';
|
|
4
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
5
|
+
import type { SelectAppearanceDefinition } from '../appearance/selectAppearanceParser.ts';
|
|
6
|
+
import { selectAppearanceParser } from '../appearance/selectAppearanceParser.ts';
|
|
7
|
+
import type { AnyBodyElementDefinition, BodyElementParentContext } from '../BodyDefinition.ts';
|
|
8
|
+
import { ControlDefinition } from './ControlDefinition.ts';
|
|
9
9
|
import { ItemDefinition } from './ItemDefinition.ts';
|
|
10
10
|
import { ItemsetDefinition } from './ItemsetDefinition.ts';
|
|
11
11
|
|
|
@@ -22,12 +22,12 @@ const isSelectElement = (
|
|
|
22
22
|
return selectLocalNames.has(localName as SelectType);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export class
|
|
25
|
+
export class SelectControlDefinition<Type extends SelectType> extends ControlDefinition<Type> {
|
|
26
26
|
static override isCompatible(localName: string, element: Element): boolean {
|
|
27
27
|
return isSelectElement(element, localName);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
static isSelect(element: AnyBodyElementDefinition): element is
|
|
30
|
+
static isSelect(element: AnyBodyElementDefinition): element is AnySelectControlDefinition {
|
|
31
31
|
return selectLocalNames.has(element.type as SelectType);
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -72,4 +72,4 @@ export class SelectDefinition<Type extends SelectType> extends ControlDefinition
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export type
|
|
75
|
+
export type AnySelectControlDefinition = SelectControlDefinition<SelectType>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ItemsetDefinition } from '../body/control/
|
|
1
|
+
import type { ItemsetDefinition } from '../body/control/ItemsetDefinition.ts';
|
|
2
2
|
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
3
3
|
|
|
4
4
|
export class ItemsetNodesetExpression extends DependentExpression<'nodes'> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ItemsetDefinition } from '../body/control/
|
|
1
|
+
import type { ItemsetDefinition } from '../body/control/ItemsetDefinition.ts';
|
|
2
2
|
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
3
3
|
|
|
4
4
|
export class ItemsetValueExpression extends DependentExpression<'string'> {
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
import type { AnyDependentExpression } from './DependentExpression.ts';
|
|
2
|
-
|
|
3
1
|
export abstract class DependencyContext {
|
|
4
2
|
abstract get parentReference(): string | null;
|
|
5
3
|
abstract get reference(): string | null;
|
|
6
4
|
|
|
7
|
-
protected readonly dependentExpressions = new Set<AnyDependentExpression>();
|
|
8
|
-
|
|
9
|
-
protected dependencyExpressionsCache: ReadonlySet<string> | null = null;
|
|
10
|
-
|
|
11
|
-
get dependencyExpressions(): ReadonlySet<string> {
|
|
12
|
-
let { dependencyExpressionsCache } = this;
|
|
13
|
-
|
|
14
|
-
if (dependencyExpressionsCache == null) {
|
|
15
|
-
dependencyExpressionsCache = new Set(
|
|
16
|
-
Array.from(this.dependentExpressions).flatMap((expression) => {
|
|
17
|
-
return Array.from(expression.dependencyReferences);
|
|
18
|
-
})
|
|
19
|
-
);
|
|
20
|
-
this.dependencyExpressionsCache = dependencyExpressionsCache;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return dependencyExpressionsCache;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
5
|
get isTranslated(): boolean {
|
|
27
6
|
return this._isTranslated;
|
|
28
7
|
}
|
|
@@ -45,9 +24,4 @@ export abstract class DependencyContext {
|
|
|
45
24
|
|
|
46
25
|
// Update note on `set isTranslated` if this internal storage changes.
|
|
47
26
|
protected _isTranslated = false;
|
|
48
|
-
|
|
49
|
-
registerDependentExpression(expression: AnyDependentExpression): void {
|
|
50
|
-
this.dependencyExpressionsCache = null;
|
|
51
|
-
this.dependentExpressions.add(expression);
|
|
52
|
-
}
|
|
53
27
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { resolveDependencyNodesets } from '../../xpath/dependency-analysis.ts';
|
|
1
|
+
import type { EngineXPathEvaluator } from '../../../integration/xpath/EngineXPathEvaluator.ts';
|
|
3
2
|
import type {
|
|
4
3
|
ConstantExpression,
|
|
5
4
|
ConstantTruthyExpression,
|
|
@@ -26,7 +25,7 @@ export type DependentExpressionEvaluatorMethod<Type extends DependentExpressionR
|
|
|
26
25
|
EvaluatorMethodsByResultType[Type];
|
|
27
26
|
|
|
28
27
|
export type DependentExpressionResult<Type extends DependentExpressionResultType> = ReturnType<
|
|
29
|
-
|
|
28
|
+
EngineXPathEvaluator[DependentExpressionEvaluatorMethod<Type>]
|
|
30
29
|
>;
|
|
31
30
|
|
|
32
31
|
interface SemanticDependencyOptions {
|
|
@@ -55,7 +54,6 @@ export interface ConstantTruthyDependentExpression extends ConstantDependentExpr
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
export abstract class DependentExpression<Type extends DependentExpressionResultType> {
|
|
58
|
-
readonly dependencyReferences: ReadonlySet<string> = new Set();
|
|
59
57
|
readonly isTranslated: boolean = false;
|
|
60
58
|
readonly evaluatorMethod: DependentExpressionEvaluatorMethod<Type>;
|
|
61
59
|
readonly constantExpression: ConstantExpression | null;
|
|
@@ -81,26 +79,17 @@ export abstract class DependentExpression<Type extends DependentExpressionResult
|
|
|
81
79
|
this.evaluatorMethod = evaluatorMethodsByResultType[resultType];
|
|
82
80
|
|
|
83
81
|
const {
|
|
84
|
-
ignoreContextReference = false,
|
|
85
82
|
semanticDependencies = {
|
|
86
83
|
translations: false,
|
|
87
84
|
},
|
|
88
85
|
} = options;
|
|
89
86
|
|
|
90
|
-
this.dependencyReferences = new Set(
|
|
91
|
-
resolveDependencyNodesets(context.reference, expression, {
|
|
92
|
-
ignoreReferenceToContextPath: ignoreContextReference,
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
|
|
96
87
|
const isTranslated = semanticDependencies.translations && isTranslationExpression(expression);
|
|
97
88
|
|
|
98
89
|
if (isTranslated) {
|
|
99
90
|
this.isTranslated = true;
|
|
100
91
|
context.isTranslated = true;
|
|
101
92
|
}
|
|
102
|
-
|
|
103
|
-
context.registerDependentExpression(this);
|
|
104
93
|
}
|
|
105
94
|
|
|
106
95
|
isConstantExpression(): this is ConstantDependentExpression<Type> {
|
|
@@ -2,17 +2,19 @@ import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
|
2
2
|
import type { DependentExpression } from '../expression/abstract/DependentExpression.ts';
|
|
3
3
|
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
4
4
|
import { MessageDefinition } from '../text/MessageDefinition.ts';
|
|
5
|
-
import type { XFormDataType } from '../XFormDataType.ts';
|
|
6
|
-
import { bindDataType } from '../XFormDataType.ts';
|
|
7
5
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
8
6
|
import type { BindElement } from './BindElement.ts';
|
|
7
|
+
import { BindPreloadDefinition, type AnyBindPreloadDefinition } from './BindPreloadDefinition.ts';
|
|
8
|
+
import type { BindType } from './BindTypeDefinition.ts';
|
|
9
|
+
import { BindTypeDefinition } from './BindTypeDefinition.ts';
|
|
9
10
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
10
11
|
|
|
11
|
-
export class BindDefinition extends DependencyContext {
|
|
12
|
-
readonly
|
|
13
|
-
readonly dataType: XFormDataType;
|
|
12
|
+
export class BindDefinition<T extends BindType = BindType> extends DependencyContext {
|
|
13
|
+
readonly type: BindTypeDefinition<T>;
|
|
14
14
|
readonly parentNodeset: string | null;
|
|
15
15
|
|
|
16
|
+
readonly preload: AnyBindPreloadDefinition | null;
|
|
17
|
+
|
|
16
18
|
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
17
19
|
readonly readonly: BindComputationExpression<'readonly'>;
|
|
18
20
|
readonly relevant: BindComputationExpression<'relevant'>;
|
|
@@ -78,13 +80,12 @@ export class BindDefinition extends DependencyContext {
|
|
|
78
80
|
) {
|
|
79
81
|
super();
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.dataType = bindDataType(bindType);
|
|
83
|
+
this.type = BindTypeDefinition.from(bindElement);
|
|
84
84
|
|
|
85
85
|
const parentNodeset = nodeset.replace(/\/[^/]+$/, '');
|
|
86
86
|
|
|
87
87
|
this.parentNodeset = parentNodeset.length > 1 ? parentNodeset : null;
|
|
88
|
+
this.preload = BindPreloadDefinition.from(bindElement);
|
|
88
89
|
this.calculate = BindComputationExpression.forComputation(this, 'calculate');
|
|
89
90
|
this.readonly = BindComputationExpression.forComputation(this, 'readonly');
|
|
90
91
|
this.relevant = BindComputationExpression.forComputation(this, 'relevant');
|
|
@@ -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>;
|