@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,118 @@
|
|
|
1
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
3
|
+
import type { RuntimeValue, SharedValueCodec } from '../../lib/codecs/getSharedValueCodec.ts';
|
|
4
|
+
import { getSharedValueCodec } from '../../lib/codecs/getSharedValueCodec.ts';
|
|
5
|
+
import type {
|
|
6
|
+
RangeControlBoundsDefinition,
|
|
7
|
+
RangeControlDefinition,
|
|
8
|
+
} from '../body/control/RangeControlDefinition.ts';
|
|
9
|
+
import type { BindDefinition } from './BindDefinition.ts';
|
|
10
|
+
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
11
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
12
|
+
|
|
13
|
+
const RANGE_VALUE_TYPES = ['decimal', 'int'] as const;
|
|
14
|
+
|
|
15
|
+
export type RangeValueType = (typeof RANGE_VALUE_TYPES)[number];
|
|
16
|
+
|
|
17
|
+
type AssertedRangeValueType<V extends ValueType> = Extract<V, RangeValueType>;
|
|
18
|
+
|
|
19
|
+
type AssertRangeBindDefinition = <V extends ValueType>(
|
|
20
|
+
bind: BindDefinition<V>
|
|
21
|
+
) => asserts bind is BindDefinition<AssertedRangeValueType<V>>;
|
|
22
|
+
|
|
23
|
+
const assertRangeBindDefinition: AssertRangeBindDefinition = (bind) => {
|
|
24
|
+
if (!RANGE_VALUE_TYPES.includes(bind.type.resolved as RangeValueType)) {
|
|
25
|
+
throw new ErrorProductionDesignPendingError(
|
|
26
|
+
`Expected range to have bind type "decimal" or "int", got: ${bind.type.resolved}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface RangeLeafNodeDefinition<V extends ValueType = ValueType>
|
|
32
|
+
extends LeafNodeDefinition<V> {
|
|
33
|
+
readonly bodyElement: RangeControlDefinition;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const decodeBoundsValue = <V extends ValueType>(
|
|
37
|
+
codec: SharedValueCodec<V>,
|
|
38
|
+
value: string
|
|
39
|
+
): NonNullable<RuntimeValue<V>> => {
|
|
40
|
+
const decoded = codec.decodeValue(value);
|
|
41
|
+
|
|
42
|
+
if (decoded == null) {
|
|
43
|
+
throw new ErrorProductionDesignPendingError(
|
|
44
|
+
`Failed to decode bounds value (encoded as ${JSON.stringify(value)})`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return decoded;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
class RangeNodeBoundsDefinition<V extends RangeValueType = RangeValueType> {
|
|
52
|
+
static from<V extends RangeValueType>(
|
|
53
|
+
bounds: RangeControlBoundsDefinition,
|
|
54
|
+
bind: BindDefinition<V>
|
|
55
|
+
): RangeNodeBoundsDefinition<V> {
|
|
56
|
+
const type = bind.type.resolved;
|
|
57
|
+
const codec = getSharedValueCodec(type);
|
|
58
|
+
const min = decodeBoundsValue(codec, bounds.start);
|
|
59
|
+
const max = decodeBoundsValue(codec, bounds.end);
|
|
60
|
+
const step = decodeBoundsValue(codec, bounds.step);
|
|
61
|
+
|
|
62
|
+
return new this(min, max, step);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
constructor(
|
|
66
|
+
readonly min: NonNullable<RuntimeValue<V>>,
|
|
67
|
+
readonly max: NonNullable<RuntimeValue<V>>,
|
|
68
|
+
readonly step: NonNullable<RuntimeValue<V>>
|
|
69
|
+
) {}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @todo We should really consider making `LeafNodeDefinition` an abstract base
|
|
74
|
+
* class, and each node's definition an explicit concrete subclass of that. It
|
|
75
|
+
* would simplify a lot of things, reduce redundancy (and drift!) between
|
|
76
|
+
* various like `*Definition` types, and allow us to reason more clearly about
|
|
77
|
+
* what parse-product-input is used to construct each primary instance node.
|
|
78
|
+
* Furthermore, it would give us a great deal more flexibility to revisit some
|
|
79
|
+
* of the weaker parts of our current data model (e.g. splitting up selects).
|
|
80
|
+
*
|
|
81
|
+
* I explored this refactor as part of the prerequisite work to support range
|
|
82
|
+
* controls. I eventually backed out because it involved more churn than I felt
|
|
83
|
+
* comfortable with, but I do think we should keep an eye out for other
|
|
84
|
+
* opportunities to take on the churn.
|
|
85
|
+
*/
|
|
86
|
+
export class RangeNodeDefinition<V extends RangeValueType = RangeValueType>
|
|
87
|
+
extends LeafNodeDefinition<V>
|
|
88
|
+
implements RangeLeafNodeDefinition<V>
|
|
89
|
+
{
|
|
90
|
+
static from<V extends ValueType>(
|
|
91
|
+
parent: ParentNodeDefinition,
|
|
92
|
+
bind: BindDefinition<V>,
|
|
93
|
+
bodyElement: RangeControlDefinition,
|
|
94
|
+
node: Element
|
|
95
|
+
): RangeNodeDefinition<Extract<V, RangeValueType>> {
|
|
96
|
+
assertRangeBindDefinition(bind);
|
|
97
|
+
|
|
98
|
+
return new this(parent, bind, bodyElement, node);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
readonly bounds: RangeNodeBoundsDefinition<V>;
|
|
102
|
+
|
|
103
|
+
private constructor(
|
|
104
|
+
parent: ParentNodeDefinition,
|
|
105
|
+
override readonly bind: BindDefinition<V>,
|
|
106
|
+
override readonly bodyElement: RangeControlDefinition,
|
|
107
|
+
node: Element
|
|
108
|
+
) {
|
|
109
|
+
super(parent, bind, bodyElement, node);
|
|
110
|
+
|
|
111
|
+
this.bounds = RangeNodeBoundsDefinition.from(bodyElement.bounds, bind);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// prettier-ignore
|
|
116
|
+
export type AnyRangeNodeDefinition =
|
|
117
|
+
| RangeNodeDefinition<'decimal'>
|
|
118
|
+
| RangeNodeDefinition<'int'>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
2
4
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
3
|
-
import type { ChildNodeDefinition
|
|
5
|
+
import type { ChildNodeDefinition } from './NodeDefinition.ts';
|
|
4
6
|
import type { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
5
7
|
|
|
6
|
-
export class RepeatInstanceDefinition
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
8
|
+
export class RepeatInstanceDefinition extends DescendentNodeDefinition<
|
|
9
|
+
'repeat-instance',
|
|
10
|
+
RepeatElementDefinition
|
|
11
|
+
> {
|
|
10
12
|
readonly type = 'repeat-instance';
|
|
11
13
|
|
|
12
|
-
readonly
|
|
14
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
15
|
+
readonly qualifiedName: QualifiedName;
|
|
13
16
|
readonly children: readonly ChildNodeDefinition[];
|
|
14
17
|
readonly instances = null;
|
|
15
18
|
readonly defaultValue = null;
|
|
@@ -22,7 +25,8 @@ export class RepeatInstanceDefinition
|
|
|
22
25
|
|
|
23
26
|
super(parent, bind, bodyElement);
|
|
24
27
|
|
|
25
|
-
this.
|
|
28
|
+
this.qualifiedName = new QualifiedName(node);
|
|
29
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
26
30
|
this.children = root.buildSubtree(this);
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
2
4
|
import { RepeatCountControlExpression } from '../expression/RepeatCountControlExpression.ts';
|
|
3
5
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
6
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
|
-
import type {
|
|
7
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
6
8
|
import { RepeatInstanceDefinition } from './RepeatInstanceDefinition.ts';
|
|
7
9
|
import { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
|
|
8
10
|
|
|
@@ -29,10 +31,10 @@ const assertRepeatRangeDefinitionUnion: AssertRepeatRangeDefinitionUnion = (_def
|
|
|
29
31
|
// tautologically true!
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
export class RepeatRangeDefinition
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
34
|
+
export class RepeatRangeDefinition extends DescendentNodeDefinition<
|
|
35
|
+
'repeat-range',
|
|
36
|
+
RepeatElementDefinition
|
|
37
|
+
> {
|
|
36
38
|
static from(
|
|
37
39
|
parent: ParentNodeDefinition,
|
|
38
40
|
bind: BindDefinition,
|
|
@@ -54,7 +56,8 @@ export class RepeatRangeDefinition
|
|
|
54
56
|
readonly count: RepeatCountControlExpression | null;
|
|
55
57
|
|
|
56
58
|
readonly node = null;
|
|
57
|
-
readonly
|
|
59
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
60
|
+
readonly qualifiedName: QualifiedName;
|
|
58
61
|
readonly defaultValue = null;
|
|
59
62
|
|
|
60
63
|
private constructor(
|
|
@@ -68,7 +71,8 @@ export class RepeatRangeDefinition
|
|
|
68
71
|
const { template, instanceNodes } = RepeatTemplateDefinition.parseModelNodes(this, modelNodes);
|
|
69
72
|
|
|
70
73
|
this.template = template;
|
|
71
|
-
this.
|
|
74
|
+
this.qualifiedName = template.qualifiedName;
|
|
75
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
72
76
|
this.count = RepeatCountControlExpression.from(bodyElement, instanceNodes.length);
|
|
73
77
|
|
|
74
78
|
assertRepeatRangeDefinitionUnion(this);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
3
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
2
4
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
3
5
|
import { BindDefinition } from './BindDefinition.ts';
|
|
4
6
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
|
-
import type { ChildNodeDefinition
|
|
7
|
+
import type { ChildNodeDefinition } from './NodeDefinition.ts';
|
|
6
8
|
import type { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
7
9
|
|
|
8
10
|
const repeatTemplates = new WeakMap<BindDefinition, RepeatTemplateDefinition>();
|
|
@@ -72,10 +74,10 @@ interface ParsedRepeatNodes {
|
|
|
72
74
|
readonly instanceNodes: readonly Element[];
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
export class RepeatTemplateDefinition
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
77
|
+
export class RepeatTemplateDefinition extends DescendentNodeDefinition<
|
|
78
|
+
'repeat-template',
|
|
79
|
+
RepeatElementDefinition
|
|
80
|
+
> {
|
|
79
81
|
static parseModelNodes(
|
|
80
82
|
range: RepeatRangeDefinition,
|
|
81
83
|
modelNodes: readonly [Element, ...Element[]]
|
|
@@ -115,7 +117,8 @@ export class RepeatTemplateDefinition
|
|
|
115
117
|
readonly type = 'repeat-template';
|
|
116
118
|
|
|
117
119
|
readonly node: Element;
|
|
118
|
-
readonly
|
|
120
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
121
|
+
readonly qualifiedName: QualifiedName;
|
|
119
122
|
readonly children: readonly ChildNodeDefinition[];
|
|
120
123
|
readonly instances = null;
|
|
121
124
|
readonly defaultValue = null;
|
|
@@ -133,7 +136,8 @@ export class RepeatTemplateDefinition
|
|
|
133
136
|
node.removeAttributeNS(JAVAROSA_NAMESPACE_URI, 'template');
|
|
134
137
|
|
|
135
138
|
this.node = node;
|
|
136
|
-
this.
|
|
139
|
+
this.qualifiedName = new QualifiedName(node);
|
|
140
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
137
141
|
this.children = root.buildSubtree(this);
|
|
138
142
|
}
|
|
139
143
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { XMLNS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { NamedNodeDefinition } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
3
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
4
|
+
import { escapeXMLText } from '../../lib/xml-serialization.ts';
|
|
5
|
+
import type { RootDefinition } from './RootDefinition.ts';
|
|
6
|
+
|
|
7
|
+
interface RootAttributeSource {
|
|
8
|
+
readonly namespaceURI: string | null;
|
|
9
|
+
readonly nodeName: string;
|
|
10
|
+
readonly prefix: string | null;
|
|
11
|
+
readonly localName: string;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @todo This class is named and typed to emphasize its intentionally narrow
|
|
17
|
+
* usage and purpose. It **intentionally** avoids addressing the much broader
|
|
18
|
+
* set of concerns around modeling attributes in primary instance/submissions.
|
|
19
|
+
*/
|
|
20
|
+
export class RootAttributeDefinition implements NamedNodeDefinition {
|
|
21
|
+
private readonly serializedXML: string;
|
|
22
|
+
|
|
23
|
+
readonly parent: RootDefinition;
|
|
24
|
+
readonly qualifiedName: QualifiedName;
|
|
25
|
+
readonly value: string;
|
|
26
|
+
|
|
27
|
+
constructor(root: RootDefinition, source: RootAttributeSource) {
|
|
28
|
+
const { namespaceURI, nodeName, value } = source;
|
|
29
|
+
|
|
30
|
+
this.parent = root;
|
|
31
|
+
this.qualifiedName = new QualifiedName(source);
|
|
32
|
+
this.value = value;
|
|
33
|
+
|
|
34
|
+
// We serialize namespace declarations separately
|
|
35
|
+
if (namespaceURI === XMLNS_NAMESPACE_URI) {
|
|
36
|
+
this.serializedXML = '';
|
|
37
|
+
} else {
|
|
38
|
+
this.serializedXML = ` ${nodeName}="${escapeXMLText(value, true)}"`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
serializeAttributeXML(): string {
|
|
43
|
+
return this.serializedXML;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { XMLNS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
3
|
+
import { RootAttributeDefinition } from './RootAttributeDefinition.ts';
|
|
4
|
+
import type { RootDefinition } from './RootDefinition.ts';
|
|
5
|
+
|
|
6
|
+
const isNonNamespaceDeclarationDOMAttr = (domAttr: Attr) => {
|
|
7
|
+
return domAttr.namespaceURI !== XMLNS_NAMESPACE_URI;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @todo This can be trivially expanded to a narrowly general case when we
|
|
12
|
+
* prioritize work to
|
|
13
|
+
* {@link https://github.com/getodk/web-forms/issues/285 | support attributes}
|
|
14
|
+
* (as modeled form nodes on par with elements). It's been deferred here to
|
|
15
|
+
* avoid expanding scope of an already fairly large yak shave.
|
|
16
|
+
*
|
|
17
|
+
* @todo There's a **much more expansive** general case just waiting for a good
|
|
18
|
+
* opportuntity to prioritize it. E.g. a `NamedNodeMap<T>`, where T is any
|
|
19
|
+
* generalized concept of a named node. This expansive generalization would have
|
|
20
|
+
* a ton of value in a variety of known performance optimization
|
|
21
|
+
* targets/solutions (i.e. optimizing the most redundant, suboptimal, frequently
|
|
22
|
+
* performed aspects of any typical XPath expression in a typical XForm).
|
|
23
|
+
*
|
|
24
|
+
* @see {@link QualifiedName} for more detail.
|
|
25
|
+
*/
|
|
26
|
+
export class RootAttributeMap extends Map<QualifiedName, RootAttributeDefinition> {
|
|
27
|
+
static from(root: RootDefinition, domRootSourceElement: Element) {
|
|
28
|
+
const domAttrs = Array.from(domRootSourceElement.attributes);
|
|
29
|
+
const nonNamespaceDeclarationDOMAttrs = domAttrs.filter(isNonNamespaceDeclarationDOMAttr);
|
|
30
|
+
const attributes = nonNamespaceDeclarationDOMAttrs.map((source) => {
|
|
31
|
+
return new RootAttributeDefinition(root, source);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return new this(attributes);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private constructor(attributes: readonly RootAttributeDefinition[]) {
|
|
38
|
+
super(
|
|
39
|
+
attributes.map((attribute) => {
|
|
40
|
+
return [attribute.qualifiedName, attribute];
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,61 +1,59 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import type { BodyClassList } from '../body/BodyDefinition.ts';
|
|
2
4
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
3
|
-
import type {
|
|
5
|
+
import type { FormSubmissionDefinition } from './FormSubmissionDefinition.ts';
|
|
4
6
|
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
5
7
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
NodeDefinition,
|
|
9
|
-
ParentNodeDefinition,
|
|
10
|
-
} from './NodeDefinition.ts';
|
|
8
|
+
import type { ChildNodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
9
|
+
import { NodeDefinition } from './NodeDefinition.ts';
|
|
11
10
|
import { NoteNodeDefinition } from './NoteNodeDefinition.ts';
|
|
11
|
+
import { RangeNodeDefinition } from './RangeNodeDefinition.ts';
|
|
12
12
|
import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
13
|
+
import { RootAttributeMap } from './RootAttributeMap.ts';
|
|
13
14
|
import { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
14
15
|
|
|
15
|
-
export class RootDefinition
|
|
16
|
+
export class RootDefinition extends NodeDefinition<'root'> {
|
|
16
17
|
readonly type = 'root';
|
|
17
|
-
readonly
|
|
18
|
-
readonly nodeset: string;
|
|
19
|
-
readonly nodeName: string;
|
|
18
|
+
readonly qualifiedName: QualifiedName;
|
|
20
19
|
readonly bodyElement = null;
|
|
21
20
|
readonly root = this;
|
|
22
21
|
readonly parent = null;
|
|
22
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
23
|
+
readonly attributes: RootAttributeMap;
|
|
23
24
|
readonly children: readonly ChildNodeDefinition[];
|
|
24
25
|
readonly instances = null;
|
|
25
26
|
readonly node: Element;
|
|
26
27
|
readonly defaultValue = null;
|
|
27
28
|
|
|
28
29
|
readonly isTranslated = false;
|
|
29
|
-
readonly dependencyExpressions: ReadonlySet<string> = new Set<string>();
|
|
30
30
|
|
|
31
31
|
constructor(
|
|
32
32
|
protected readonly form: XFormDefinition,
|
|
33
33
|
protected readonly model: ModelDefinition,
|
|
34
|
+
readonly submission: FormSubmissionDefinition,
|
|
34
35
|
readonly classes: BodyClassList
|
|
35
36
|
) {
|
|
37
|
+
const { primaryInstanceRoot } = form.xformDOM;
|
|
38
|
+
const qualifiedName = new QualifiedName(primaryInstanceRoot);
|
|
39
|
+
const nodeName = qualifiedName.getPrefixedName();
|
|
40
|
+
|
|
36
41
|
// TODO: theoretically the pertinent step in the bind's `nodeset` *could* be
|
|
37
42
|
// namespaced. It also may make more sense to determine the root nodeset
|
|
38
43
|
// earlier (i.e. in the appropriate definition class).
|
|
39
|
-
|
|
40
|
-
// TODO: while it's unlikely a form actually defines a <bind> for the root,
|
|
41
|
-
// if it did, bind nodesets are not yet normalized, so `/root` may currently
|
|
42
|
-
// be defined as `/ root` (or even `/ *` or any other valid expression
|
|
43
|
-
// resolving to the root).
|
|
44
|
-
const { primaryInstanceRoot } = form.xformDOM;
|
|
45
|
-
const { localName: rootNodeName } = primaryInstanceRoot;
|
|
46
|
-
|
|
47
|
-
this.nodeName = rootNodeName;
|
|
48
|
-
|
|
49
|
-
const nodeset = `/${rootNodeName}`;
|
|
44
|
+
const nodeset = `/${nodeName}`;
|
|
50
45
|
const bind = model.binds.get(nodeset);
|
|
51
46
|
|
|
52
47
|
if (bind == null) {
|
|
53
48
|
throw new Error('Missing root node bind definition');
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
super(bind);
|
|
52
|
+
|
|
53
|
+
this.qualifiedName = qualifiedName;
|
|
58
54
|
this.node = primaryInstanceRoot;
|
|
55
|
+
this.attributes = RootAttributeMap.from(this, primaryInstanceRoot);
|
|
56
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
59
57
|
this.children = this.buildSubtree(this);
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -69,13 +67,13 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
69
67
|
const childrenByName = new Map<string, [Element, ...Element[]]>();
|
|
70
68
|
|
|
71
69
|
for (const child of node.children) {
|
|
72
|
-
const {
|
|
70
|
+
const { nodeName } = child;
|
|
73
71
|
|
|
74
|
-
let elements = childrenByName.get(
|
|
72
|
+
let elements = childrenByName.get(nodeName);
|
|
75
73
|
|
|
76
74
|
if (elements == null) {
|
|
77
75
|
elements = [child];
|
|
78
|
-
childrenByName.set(
|
|
76
|
+
childrenByName.set(nodeName, elements);
|
|
79
77
|
} else {
|
|
80
78
|
// TODO: check if previous element exists, was it previous element
|
|
81
79
|
// sibling. Highly likely this should otherwise fail!
|
|
@@ -83,8 +81,8 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
return Array.from(childrenByName).map(([
|
|
87
|
-
const nodeset = `${parentNodeset}/${
|
|
84
|
+
return Array.from(childrenByName).map(([nodeName, children]) => {
|
|
85
|
+
const nodeset = `${parentNodeset}/${nodeName}`;
|
|
88
86
|
const bind = binds.getOrCreateBindDefinition(nodeset);
|
|
89
87
|
const bodyElement = body.getBodyElement(nodeset);
|
|
90
88
|
const [firstChild, ...restChildren] = children;
|
|
@@ -101,6 +99,10 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
101
99
|
const isLeafNode = element.childElementCount === 0;
|
|
102
100
|
|
|
103
101
|
if (isLeafNode) {
|
|
102
|
+
if (bodyElement?.type === 'range') {
|
|
103
|
+
return RangeNodeDefinition.from(parent, bind, bodyElement, element);
|
|
104
|
+
}
|
|
105
|
+
|
|
104
106
|
return (
|
|
105
107
|
NoteNodeDefinition.from(parent, bind, bodyElement, element) ??
|
|
106
108
|
new LeafNodeDefinition(parent, bind, bodyElement, element)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StaticDocument } from '../../../integration/xpath/static-dom/StaticDocument.ts';
|
|
2
|
+
import { SecondaryInstanceRootDefinition } from './SecondaryInstanceRootDefinition.ts';
|
|
3
|
+
|
|
4
|
+
export class SecondaryInstanceDefinition extends StaticDocument<SecondaryInstanceRootDefinition> {}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { XFormsSecondaryInstanceElement } 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 { SecondaryInstanceDefinition } from './SecondaryInstanceDefinition.ts';
|
|
5
|
+
|
|
6
|
+
export class SecondaryInstanceRootDefinition
|
|
7
|
+
extends StaticElement<SecondaryInstanceDefinition>
|
|
8
|
+
implements XFormsSecondaryInstanceElement<StaticElement>
|
|
9
|
+
{
|
|
10
|
+
override readonly [XFORMS_LOCAL_NAME] = 'instance';
|
|
11
|
+
override readonly [XFORMS_KNOWN_ATTRIBUTE] = 'id';
|
|
12
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { JRResourceURL } from '@getodk/common/jr-resources/JRResourceURL.ts';
|
|
2
|
+
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
3
|
+
import type { XFormsSecondaryInstanceMap } from '@getodk/xpath';
|
|
4
|
+
import { ErrorProductionDesignPendingError } from '../../../error/ErrorProductionDesignPendingError.ts';
|
|
5
|
+
import type { EngineXPathNode } from '../../../integration/xpath/adapter/kind.ts';
|
|
6
|
+
import type { XFormDOM } from '../../XFormDOM.ts';
|
|
7
|
+
import { SecondaryInstanceRootDefinition } from './SecondaryInstanceRootDefinition.ts';
|
|
8
|
+
import { BlankSecondaryInstanceSource } from './sources/BlankSecondaryInstanceSource.ts';
|
|
9
|
+
import { CSVExternalSecondaryInstanceSource } from './sources/CSVExternalSecondaryInstance.ts';
|
|
10
|
+
import type { ExternalSecondaryInstanceResourceLoadOptions } from './sources/ExternalSecondaryInstanceResource.ts';
|
|
11
|
+
import { ExternalSecondaryInstanceResource } from './sources/ExternalSecondaryInstanceResource.ts';
|
|
12
|
+
import { GeoJSONExternalSecondaryInstanceSource } from './sources/GeoJSONExternalSecondaryInstance.ts';
|
|
13
|
+
import { InternalSecondaryInstanceSource } from './sources/InternalSecondaryInstanceSource.ts';
|
|
14
|
+
import type { SecondaryInstanceSource } from './sources/SecondaryInstanceSource.ts';
|
|
15
|
+
import { XMLExternalSecondaryInstanceSource } from './sources/XMLExternalSecondaryInstanceSource.ts';
|
|
16
|
+
|
|
17
|
+
export class SecondaryInstancesDefinition
|
|
18
|
+
extends Map<string, SecondaryInstanceRootDefinition>
|
|
19
|
+
implements XFormsSecondaryInstanceMap<EngineXPathNode>
|
|
20
|
+
{
|
|
21
|
+
/**
|
|
22
|
+
* @package Only to be used for testing
|
|
23
|
+
*/
|
|
24
|
+
static loadSync(xformDOM: XFormDOM): SecondaryInstancesDefinition {
|
|
25
|
+
const { secondaryInstanceElements } = xformDOM;
|
|
26
|
+
const sources = secondaryInstanceElements.map((domElement) => {
|
|
27
|
+
const instanceId = domElement.getAttribute('id');
|
|
28
|
+
const src = domElement.getAttribute('src');
|
|
29
|
+
|
|
30
|
+
if (src != null) {
|
|
31
|
+
throw new ErrorProductionDesignPendingError(
|
|
32
|
+
`Unexpected external secondary instance src attribute: ${src}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return new InternalSecondaryInstanceSource(instanceId, src, domElement);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return new this(sources);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static async load(
|
|
43
|
+
xformDOM: XFormDOM,
|
|
44
|
+
options: ExternalSecondaryInstanceResourceLoadOptions
|
|
45
|
+
): Promise<SecondaryInstancesDefinition> {
|
|
46
|
+
const { secondaryInstanceElements } = xformDOM;
|
|
47
|
+
|
|
48
|
+
const sources = await Promise.all(
|
|
49
|
+
secondaryInstanceElements.map(async (domElement) => {
|
|
50
|
+
const instanceId = domElement.getAttribute('id');
|
|
51
|
+
const src = domElement.getAttribute('src');
|
|
52
|
+
|
|
53
|
+
if (src == null) {
|
|
54
|
+
return new InternalSecondaryInstanceSource(instanceId, src, domElement);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!JRResourceURL.isJRResourceReference(src)) {
|
|
58
|
+
throw new ErrorProductionDesignPendingError(
|
|
59
|
+
`Unexpected external secondary instance src attribute: ${src}`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const resourceURL = JRResourceURL.from(src);
|
|
64
|
+
const resource = await ExternalSecondaryInstanceResource.load(
|
|
65
|
+
instanceId,
|
|
66
|
+
resourceURL,
|
|
67
|
+
options
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (resource.isBlank) {
|
|
71
|
+
return new BlankSecondaryInstanceSource(instanceId, resourceURL, domElement);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
switch (resource.format) {
|
|
75
|
+
case 'csv':
|
|
76
|
+
return new CSVExternalSecondaryInstanceSource(domElement, resource);
|
|
77
|
+
|
|
78
|
+
case 'geojson':
|
|
79
|
+
return new GeoJSONExternalSecondaryInstanceSource(domElement, resource);
|
|
80
|
+
|
|
81
|
+
case 'xml':
|
|
82
|
+
return new XMLExternalSecondaryInstanceSource(domElement, resource);
|
|
83
|
+
|
|
84
|
+
default:
|
|
85
|
+
throw new UnreachableError(resource);
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return new this(sources);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private constructor(sources: readonly SecondaryInstanceSource[]) {
|
|
94
|
+
super(
|
|
95
|
+
sources.map((source) => {
|
|
96
|
+
const { root } = source.parseDefinition();
|
|
97
|
+
|
|
98
|
+
return [root.getAttributeValue('id'), root];
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { XFORMS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { JRResourceURL } from '@getodk/common/jr-resources/JRResourceURL.ts';
|
|
3
|
+
import type { StaticNode } from '../../../../integration/xpath/static-dom/StaticNode.ts';
|
|
4
|
+
import { parseStaticDocumentFromDOMSubtree } from '../../../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
5
|
+
import type { DOMSecondaryInstanceElement } from '../../../XFormDOM.ts';
|
|
6
|
+
import { SecondaryInstanceDefinition } from '../SecondaryInstanceDefinition.ts';
|
|
7
|
+
import { SecondaryInstanceRootDefinition } from '../SecondaryInstanceRootDefinition.ts';
|
|
8
|
+
import { SecondaryInstanceSource } from './SecondaryInstanceSource.ts';
|
|
9
|
+
|
|
10
|
+
export class BlankSecondaryInstanceSource extends SecondaryInstanceSource<'blank'> {
|
|
11
|
+
constructor(
|
|
12
|
+
instanceId: string,
|
|
13
|
+
resourceURL: JRResourceURL,
|
|
14
|
+
domElement: DOMSecondaryInstanceElement
|
|
15
|
+
) {
|
|
16
|
+
super('blank', instanceId, resourceURL, domElement);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @todo there is really no sense in using the DOM for this, other than it was
|
|
21
|
+
* quicker/more ergonomic than constructing the requisite {@link StaticNode}
|
|
22
|
+
* structures directly. Pretty good sign those constructor signatures could
|
|
23
|
+
* use some TLC!
|
|
24
|
+
*/
|
|
25
|
+
parseDefinition(): SecondaryInstanceDefinition {
|
|
26
|
+
const xmlDocument = this.domElement.ownerDocument.implementation.createDocument(
|
|
27
|
+
XFORMS_NAMESPACE_URI,
|
|
28
|
+
'instance'
|
|
29
|
+
);
|
|
30
|
+
const instanceElement = xmlDocument.documentElement;
|
|
31
|
+
|
|
32
|
+
instanceElement.setAttribute('id', this.instanceId);
|
|
33
|
+
|
|
34
|
+
return parseStaticDocumentFromDOMSubtree(
|
|
35
|
+
SecondaryInstanceDefinition,
|
|
36
|
+
SecondaryInstanceRootDefinition,
|
|
37
|
+
instanceElement
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|