@getodk/xforms-engine 0.3.0 → 0.5.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/dist/client/BaseNode.d.ts +15 -5
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -49
- package/dist/client/GroupNode.d.ts +2 -3
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +13 -9
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +3 -4
- package/dist/client/RootNode.d.ts +36 -10
- package/dist/client/SelectNode.d.ts +4 -5
- package/dist/client/SubtreeNode.d.ts +1 -2
- package/dist/client/TextRange.d.ts +3 -4
- package/dist/client/TriggerNode.d.ts +25 -0
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -1
- package/dist/client/hierarchy.d.ts +9 -5
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +3 -1
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +1 -2
- package/dist/client/repeat/RepeatInstanceNode.d.ts +2 -3
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +1 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +1 -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/RangeNode.d.ts +9 -0
- package/dist/client/unsupported/RankNode.d.ts +9 -0
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
- package/dist/client/unsupported/UploadNode.d.ts +9 -0
- package/dist/client/validation.d.ts +2 -3
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -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 +16 -4
- package/dist/index.js +8559 -4700
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -5
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -27
- package/dist/instance/Note.d.ts +11 -5
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +31 -28
- package/dist/instance/SelectField.d.ts +13 -6
- package/dist/instance/Subtree.d.ts +10 -6
- package/dist/instance/TriggerControl.d.ts +47 -0
- package/dist/instance/abstract/DescendantNode.d.ts +33 -26
- package/dist/instance/abstract/InstanceNode.d.ts +50 -31
- package/dist/instance/abstract/UnsupportedControl.d.ts +53 -0
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +13 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/index.d.ts +0 -1
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -13
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -3
- package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -3
- package/dist/instance/internal-api/ValidationContext.d.ts +12 -6
- package/dist/instance/internal-api/ValueContext.d.ts +5 -5
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -85
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -30
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +3 -4
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +3 -4
- package/dist/instance/resource.d.ts +1 -2
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +1 -2
- package/dist/instance/unsupported/RangeControl.d.ts +6 -0
- package/dist/instance/unsupported/RankControl.d.ts +6 -0
- package/dist/instance/unsupported/UploadControl.d.ts +6 -0
- 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 +16 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -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/TokenListParser.d.ts +3 -3
- 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/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/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
- package/dist/lib/dom/query.d.ts +4 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -6
- package/dist/lib/reactivity/createComputedExpression.d.ts +19 -7
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -3
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -11
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -5
- package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
- package/dist/lib/reactivity/scope.d.ts +0 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +1 -2
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +1 -2
- package/dist/lib/reactivity/text/createNoteText.d.ts +1 -2
- package/dist/lib/reactivity/text/createTextRange.d.ts +0 -1
- package/dist/lib/reactivity/types.d.ts +0 -1
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +0 -1
- package/dist/lib/reactivity/validation/createValidation.d.ts +0 -1
- package/dist/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +42 -0
- package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +3 -5
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/{body → parse/body}/BodyDefinition.d.ts +16 -11
- package/dist/{body → parse/body}/BodyElementDefinition.d.ts +7 -7
- package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
- package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
- package/dist/{body/control/InputDefinition.d.ts → parse/body/control/InputControlDefinition.d.ts} +2 -3
- package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
- package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +2 -3
- package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +4 -5
- package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +1 -4
- package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
- package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
- package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
- package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
- package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
- package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
- package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
- package/dist/parse/expression/RepeatCountControlExpression.d.ts +2 -3
- package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
- package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
- package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
- package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
- package/dist/parse/expression/abstract/DependencyContext.d.ts +7 -0
- package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +4 -6
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +38 -0
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -2
- 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 +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/{model → parse/model}/LeafNodeDefinition.d.ts +4 -3
- package/dist/{model → parse/model}/ModelBindMap.d.ts +1 -2
- package/dist/{model → parse/model}/ModelDefinition.d.ts +3 -2
- package/dist/{model → parse/model}/NodeDefinition.d.ts +0 -2
- package/dist/parse/{NoteNodeDefinition.d.ts → model/NoteNodeDefinition.d.ts} +12 -13
- package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +1 -2
- package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RootDefinition.d.ts +5 -5
- 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/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- package/dist/parse/text/HintDefinition.d.ts +2 -3
- package/dist/parse/text/ItemLabelDefinition.d.ts +2 -3
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +3 -4
- package/dist/parse/text/LabelDefinition.d.ts +5 -6
- package/dist/parse/text/MessageDefinition.d.ts +4 -5
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +8 -9
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +4 -7
- package/dist/parse/xpath/path-resolution.d.ts +0 -1
- package/dist/parse/xpath/predicate-analysis.d.ts +0 -1
- package/dist/parse/xpath/reference-parsing.d.ts +0 -1
- package/dist/parse/xpath/semantic-analysis.d.ts +5 -1
- package/dist/parse/xpath/syntax-traversal.d.ts +0 -1
- package/dist/solid.js +8398 -4543
- package/dist/solid.js.map +1 -1
- package/package.json +14 -12
- package/src/client/BaseNode.ts +17 -7
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/GroupNode.ts +2 -2
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +31 -8
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +3 -3
- package/src/client/RootNode.ts +39 -9
- package/src/client/SelectNode.ts +5 -5
- package/src/client/SubtreeNode.ts +1 -1
- package/src/client/TextRange.ts +4 -5
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +16 -4
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +19 -5
- package/src/client/repeat/BaseRepeatRangeNode.ts +1 -1
- package/src/client/repeat/RepeatInstanceNode.ts +2 -2
- package/src/client/repeat/RepeatRangeControlledNode.ts +1 -1
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +1 -1
- 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/RangeNode.ts +14 -0
- package/src/client/unsupported/RankNode.ts +14 -0
- package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
- package/src/client/unsupported/UploadNode.ts +14 -0
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/ValueTypeInvariantError.ts +22 -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 +16 -2
- package/src/instance/Group.ts +17 -5
- package/src/instance/InputControl.ts +119 -0
- package/src/instance/ModelValue.ts +47 -54
- package/src/instance/Note.ts +26 -10
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +64 -132
- package/src/instance/SelectField.ts +62 -25
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/{StringField.ts → TriggerControl.ts} +61 -30
- package/src/instance/abstract/DescendantNode.ts +92 -47
- package/src/instance/abstract/InstanceNode.ts +104 -98
- package/src/instance/abstract/UnsupportedControl.ts +174 -0
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +83 -14
- package/src/instance/hierarchy.ts +36 -14
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +26 -8
- package/src/instance/internal-api/EvaluationContext.ts +61 -14
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +24 -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 +13 -5
- package/src/instance/internal-api/ValueContext.ts +5 -4
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
- package/src/instance/repeat/BaseRepeatRange.ts +51 -132
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +6 -6
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +3 -5
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +9 -0
- package/src/instance/unsupported/RankControl.ts +9 -0
- package/src/instance/unsupported/UploadControl.ts +9 -0
- 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 +99 -0
- package/src/integration/xpath/adapter/traversal.ts +228 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- package/src/lib/TokenListParser.ts +11 -7
- 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/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/IntValueCodec.ts +100 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getSharedValueCodec.ts +77 -0
- package/src/lib/dom/query.ts +8 -1
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +59 -36
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +23 -23
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +64 -122
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +1 -1
- package/src/lib/reactivity/text/createNodeLabel.ts +1 -1
- package/src/lib/reactivity/text/createNoteText.ts +1 -1
- package/src/lib/reactivity/text/createTextRange.ts +8 -7
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +9 -4
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/{XFormDOM.ts → parse/XFormDOM.ts} +110 -75
- package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +3 -8
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/{body → parse/body}/BodyDefinition.ts +46 -29
- package/src/{body → parse/body}/BodyElementDefinition.ts +12 -6
- package/src/{body → parse/body}/RepeatElementDefinition.ts +7 -5
- package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +2 -2
- package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
- package/src/{body → parse/body}/control/ControlDefinition.ts +4 -4
- package/src/{body/control/InputDefinition.ts → parse/body/control/InputControlDefinition.ts} +3 -5
- package/src/parse/body/control/RangeControlDefinition.ts +26 -0
- package/src/parse/body/control/RankControlDefinition.ts +27 -0
- package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
- package/src/parse/body/control/UploadControlDefinition.ts +26 -0
- package/src/{body → parse/body}/control/select/ItemDefinition.ts +2 -2
- package/src/{body → parse/body}/control/select/ItemsetDefinition.ts +5 -5
- package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +1 -6
- package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
- package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -22
- package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
- package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -8
- package/src/{body/control/select → parse/expression}/ItemsetNodesetExpression.ts +2 -2
- package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
- package/src/parse/expression/RepeatCountControlExpression.ts +2 -2
- package/src/parse/expression/TextLiteralExpression.ts +19 -0
- package/src/parse/{text/OutputChunkDefinition.ts → expression/TextOutputExpression.ts} +4 -4
- package/src/parse/{text/ReferenceChunkDefinition.ts → expression/TextReferenceExpression.ts} +4 -4
- package/src/parse/{text/TranslationChunkDefinition.ts → expression/TextTranslationExpression.ts} +4 -4
- package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -26
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +5 -16
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/parse/model/BindDefinition.ts +104 -0
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -6
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/{model → parse/model}/LeafNodeDefinition.ts +4 -1
- package/src/{model → parse/model}/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +24 -0
- package/src/{model → parse/model}/NodeDefinition.ts +0 -3
- package/src/parse/{NoteNodeDefinition.ts → model/NoteNodeDefinition.ts} +12 -12
- package/src/{model → parse/model}/RepeatRangeDefinition.ts +1 -1
- package/src/{model → parse/model}/RootDefinition.ts +4 -3
- 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 +414 -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/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- package/src/parse/text/HintDefinition.ts +2 -2
- package/src/parse/text/ItemLabelDefinition.ts +2 -2
- package/src/parse/text/ItemsetLabelDefinition.ts +7 -7
- package/src/parse/text/LabelDefinition.ts +5 -5
- package/src/parse/text/MessageDefinition.ts +7 -7
- package/src/parse/text/abstract/TextElementDefinition.ts +14 -14
- package/src/parse/text/abstract/TextRangeDefinition.ts +4 -10
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/XFormDOM.d.ts +0 -32
- package/dist/XFormDataType.d.ts +0 -27
- package/dist/body/appearance/inputAppearanceParser.d.ts +0 -4
- package/dist/client/StringNode.d.ts +0 -47
- package/dist/expression/DependencyContext.d.ts +0 -13
- package/dist/instance/StringField.d.ts +0 -45
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -60
- package/dist/model/BindDefinition.d.ts +0 -34
- package/dist/parse/text/OutputChunkDefinition.d.ts +0 -8
- package/dist/parse/text/ReferenceChunkDefinition.d.ts +0 -8
- package/dist/parse/text/StaticTextChunkDefinition.d.ts +0 -10
- package/dist/parse/text/TranslationChunkDefinition.d.ts +0 -9
- package/dist/parse/text/abstract/TextChunkDefinition.d.ts +0 -18
- package/src/XFormDataType.ts +0 -64
- package/src/client/StringNode.ts +0 -52
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/model/BindDefinition.ts +0 -106
- package/src/model/ModelDefinition.ts +0 -19
- package/src/parse/TODO.md +0 -3
- package/src/parse/text/StaticTextChunkDefinition.ts +0 -19
- package/src/parse/text/abstract/TextChunkDefinition.ts +0 -38
- /package/dist/{model → parse/model}/BindElement.d.ts +0 -0
- /package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
- /package/src/{model → parse/model}/BindElement.ts +0 -0
- /package/src/{model → parse/model}/RepeatInstanceDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
- /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
package/src/parse/{text/TranslationChunkDefinition.ts → expression/TextTranslationExpression.ts}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { expressionParser } from '@getodk/xpath/expressionParser.js';
|
|
2
|
+
import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
|
|
2
3
|
import type { TranslationExpression } from '../xpath/semantic-analysis.ts';
|
|
3
4
|
import { isTranslationExpression } from '../xpath/semantic-analysis.ts';
|
|
4
|
-
import {
|
|
5
|
-
import type { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
|
|
5
|
+
import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class TextTranslationExpression extends TextChunkExpression<'translation'> {
|
|
8
8
|
static fromMessage(
|
|
9
9
|
context: AnyTextRangeDefinition,
|
|
10
10
|
maybeExpression: string
|
|
11
|
-
):
|
|
11
|
+
): TextTranslationExpression | null {
|
|
12
12
|
try {
|
|
13
13
|
expressionParser.parse(maybeExpression);
|
|
14
14
|
} catch {
|
|
@@ -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,14 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { resolveDependencyNodesets } from '../parse/xpath/dependency-analysis.ts';
|
|
1
|
+
import type { EngineXPathEvaluator } from '../../../integration/xpath/EngineXPathEvaluator.ts';
|
|
3
2
|
import type {
|
|
4
3
|
ConstantExpression,
|
|
5
4
|
ConstantTruthyExpression,
|
|
6
|
-
} from '
|
|
5
|
+
} from '../../xpath/semantic-analysis.ts';
|
|
7
6
|
import {
|
|
8
7
|
isConstantExpression,
|
|
9
8
|
isConstantTruthyExpression,
|
|
10
9
|
isTranslationExpression,
|
|
11
|
-
} from '
|
|
10
|
+
} from '../../xpath/semantic-analysis.ts';
|
|
12
11
|
import type { DependencyContext } from './DependencyContext.ts';
|
|
13
12
|
|
|
14
13
|
const evaluatorMethodsByResultType = {
|
|
@@ -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 {
|
|
@@ -54,8 +53,7 @@ export interface ConstantTruthyDependentExpression extends ConstantDependentExpr
|
|
|
54
53
|
readonly expression: ConstantTruthyExpression;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
export class DependentExpression<Type extends DependentExpressionResultType> {
|
|
58
|
-
readonly dependencyReferences: ReadonlySet<string> = new Set();
|
|
56
|
+
export abstract class DependentExpression<Type extends DependentExpressionResultType> {
|
|
59
57
|
readonly isTranslated: boolean = false;
|
|
60
58
|
readonly evaluatorMethod: DependentExpressionEvaluatorMethod<Type>;
|
|
61
59
|
readonly constantExpression: ConstantExpression | null;
|
|
@@ -81,26 +79,17 @@ export class DependentExpression<Type extends DependentExpressionResultType> {
|
|
|
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> {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TextChunkSource } from '../../../client/TextRange.ts';
|
|
2
|
+
import type { AnyTextRangeDefinition } from '../../text/abstract/TextRangeDefinition.ts';
|
|
3
|
+
import type { TextLiteralExpression } from '../TextLiteralExpression.ts';
|
|
4
|
+
import type { TextOutputExpression } from '../TextOutputExpression.ts';
|
|
5
|
+
import type { TextReferenceExpression } from '../TextReferenceExpression.ts';
|
|
6
|
+
import type { TextTranslationExpression } from '../TextTranslationExpression.ts';
|
|
7
|
+
import { DependentExpression } from './DependentExpression.ts';
|
|
8
|
+
|
|
9
|
+
interface TextChunkExpressionOptions {
|
|
10
|
+
readonly isTranslated?: true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export abstract class TextChunkExpression<
|
|
14
|
+
Source extends TextChunkSource,
|
|
15
|
+
> extends DependentExpression<'string'> {
|
|
16
|
+
abstract readonly source: Source;
|
|
17
|
+
readonly stringValue?: string;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
context: AnyTextRangeDefinition,
|
|
21
|
+
expression: string,
|
|
22
|
+
options: TextChunkExpressionOptions = {}
|
|
23
|
+
) {
|
|
24
|
+
super(context, 'string', expression, {
|
|
25
|
+
semanticDependencies: {
|
|
26
|
+
translations: options.isTranslated,
|
|
27
|
+
},
|
|
28
|
+
ignoreContextReference: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// prettier-ignore
|
|
34
|
+
export type AnyTextChunkExpression =
|
|
35
|
+
| TextLiteralExpression
|
|
36
|
+
| TextOutputExpression
|
|
37
|
+
| TextReferenceExpression
|
|
38
|
+
| TextTranslationExpression;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
2
|
+
import type { DependentExpression } from '../expression/abstract/DependentExpression.ts';
|
|
3
|
+
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
4
|
+
import { MessageDefinition } from '../text/MessageDefinition.ts';
|
|
5
|
+
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
6
|
+
import type { BindElement } from './BindElement.ts';
|
|
7
|
+
import type { BindType } from './BindTypeDefinition.ts';
|
|
8
|
+
import { BindTypeDefinition } from './BindTypeDefinition.ts';
|
|
9
|
+
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
10
|
+
|
|
11
|
+
export class BindDefinition<T extends BindType = BindType> extends DependencyContext {
|
|
12
|
+
readonly type: BindTypeDefinition<T>;
|
|
13
|
+
readonly parentNodeset: string | null;
|
|
14
|
+
|
|
15
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
16
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
17
|
+
readonly relevant: BindComputationExpression<'relevant'>;
|
|
18
|
+
readonly required: BindComputationExpression<'required'>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Diverges from
|
|
22
|
+
* {@link https://github.com/getodk/javarosa/blob/059321160e6f8dbb3e81d9add61d68dd35b13cc8/dag.md | JavaRosa's},
|
|
23
|
+
* which excludes `constraint` expressions. We compute `constraint`
|
|
24
|
+
* dependencies like the other <bind> computation expressions, but explicitly
|
|
25
|
+
* ignore self-references (this is currently handled by
|
|
26
|
+
* {@link BindComputationExpression}, via its {@link DependentExpression}
|
|
27
|
+
* super class).
|
|
28
|
+
*/
|
|
29
|
+
readonly constraint: BindComputationExpression<'constraint'>;
|
|
30
|
+
|
|
31
|
+
readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
|
|
32
|
+
readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
|
|
33
|
+
|
|
34
|
+
// TODO: it is unclear whether this will need to be supported.
|
|
35
|
+
// https://github.com/getodk/collect/issues/3758 mentions deprecation.
|
|
36
|
+
readonly saveIncomplete: BindComputationExpression<'saveIncomplete'>;
|
|
37
|
+
|
|
38
|
+
// TODO: these are deferred until prioritized
|
|
39
|
+
// readonly preload: string | null;
|
|
40
|
+
// readonly preloadParams: string | null;
|
|
41
|
+
// readonly 'max-pixels': string | null;
|
|
42
|
+
|
|
43
|
+
protected _parentBind: BindDefinition | null | undefined;
|
|
44
|
+
|
|
45
|
+
get parentBind(): BindDefinition | null {
|
|
46
|
+
let bind = this._parentBind;
|
|
47
|
+
|
|
48
|
+
if (typeof bind === 'undefined') {
|
|
49
|
+
const { parentNodeset } = this;
|
|
50
|
+
|
|
51
|
+
if (parentNodeset == null) {
|
|
52
|
+
bind = null;
|
|
53
|
+
} else {
|
|
54
|
+
bind = this.form.model.binds.get(parentNodeset) ?? null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this._parentBind = bind;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return bind;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// DependencyContext
|
|
64
|
+
get reference(): string {
|
|
65
|
+
return this.nodeset;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get parentReference(): string | null {
|
|
69
|
+
return this.parentNodeset;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
constructor(
|
|
73
|
+
readonly form: XFormDefinition,
|
|
74
|
+
protected readonly model: ModelDefinition,
|
|
75
|
+
readonly nodeset: string,
|
|
76
|
+
readonly bindElement: BindElement
|
|
77
|
+
) {
|
|
78
|
+
super();
|
|
79
|
+
|
|
80
|
+
this.type = BindTypeDefinition.from(bindElement);
|
|
81
|
+
|
|
82
|
+
const parentNodeset = nodeset.replace(/\/[^/]+$/, '');
|
|
83
|
+
|
|
84
|
+
this.parentNodeset = parentNodeset.length > 1 ? parentNodeset : null;
|
|
85
|
+
this.calculate = BindComputationExpression.forComputation(this, 'calculate');
|
|
86
|
+
this.readonly = BindComputationExpression.forComputation(this, 'readonly');
|
|
87
|
+
this.relevant = BindComputationExpression.forComputation(this, 'relevant');
|
|
88
|
+
this.required = BindComputationExpression.forComputation(this, 'required');
|
|
89
|
+
this.constraint = BindComputationExpression.forComputation(this, 'constraint');
|
|
90
|
+
this.saveIncomplete = BindComputationExpression.forComputation(this, 'saveIncomplete');
|
|
91
|
+
this.constraintMsg = MessageDefinition.from(this, 'constraintMsg');
|
|
92
|
+
this.requiredMsg = MessageDefinition.from(this, 'requiredMsg');
|
|
93
|
+
|
|
94
|
+
// this.preload = BindComputation.forExpression(this, 'preload');
|
|
95
|
+
// this.preloadParams = BindComputation.forExpression(this, 'preloadParams');
|
|
96
|
+
// this['max-pixels'] = BindComputation.forExpression(this, 'max-pixels');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
toJSON() {
|
|
100
|
+
const { form, model, /* modelElement, */ bindElement, ...rest } = this;
|
|
101
|
+
|
|
102
|
+
return rest;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { XSD_NAMESPACE_URI, XSD_PREFIX } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import { parseQualifiedNameExpression } from '../xpath/semantic-analysis.ts';
|
|
3
|
+
import type { BindElement } from './BindElement.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* As specified by {@link https://getodk.github.io/xforms-spec/#bind-attributes}
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_BIND_TYPE = 'string';
|
|
9
|
+
|
|
10
|
+
export type DefaultBindType = typeof DEFAULT_BIND_TYPE;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* As specified by {@link https://getodk.github.io/xforms-spec/#data-types}
|
|
14
|
+
*/
|
|
15
|
+
const BIND_TYPES = [
|
|
16
|
+
DEFAULT_BIND_TYPE,
|
|
17
|
+
'int',
|
|
18
|
+
'boolean',
|
|
19
|
+
'decimal',
|
|
20
|
+
'date',
|
|
21
|
+
'time',
|
|
22
|
+
'dateTime',
|
|
23
|
+
'geopoint',
|
|
24
|
+
'geotrace',
|
|
25
|
+
'geoshape',
|
|
26
|
+
'binary',
|
|
27
|
+
'barcode',
|
|
28
|
+
'intent',
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
type BindTypes = typeof BIND_TYPES;
|
|
32
|
+
|
|
33
|
+
export type BindType = BindTypes[number];
|
|
34
|
+
|
|
35
|
+
const isBindType = (value: string): value is BindType => {
|
|
36
|
+
return BIND_TYPES.includes(value as BindType);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const resolveSupportedBindType = (sourceType: string): BindType | null => {
|
|
40
|
+
return isBindType(sourceType) ? sourceType : null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type BindTypeAliasMapping = Readonly<Record<string, BindType>>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @todo should we make these aliases explicit (rather than relying on {@link resolveUnsupportedBindType})?
|
|
47
|
+
*
|
|
48
|
+
* - select1
|
|
49
|
+
* - rank
|
|
50
|
+
* - odk:rank
|
|
51
|
+
*/
|
|
52
|
+
const BIND_TYPE_ALIASES: BindTypeAliasMapping = {
|
|
53
|
+
integer: 'int',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @todo Should this be marked deprecated?
|
|
58
|
+
* @todo Should we warn on alias resolution?
|
|
59
|
+
*/
|
|
60
|
+
const resolveAliasedBindType = (sourceType: string): BindType | null => {
|
|
61
|
+
return BIND_TYPE_ALIASES[sourceType] ?? null;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @todo Should we warn on this fallback?
|
|
66
|
+
*/
|
|
67
|
+
const resolveUnsupportedBindType = (_unsupportedType: string): BindType => {
|
|
68
|
+
return DEFAULT_BIND_TYPE;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
interface BindDataTypeNamespaceResolver {
|
|
72
|
+
lookupNamespaceURI(prefix: string | null): string | null;
|
|
73
|
+
lookupPrefix(namespaceURI: string | null): string | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the XML Schema namespace prefix by:
|
|
78
|
+
*
|
|
79
|
+
* - Explicitly declared prefix, if any
|
|
80
|
+
* - Default to {@link XSD_PREFIX} _unless that prefix is bound to some other
|
|
81
|
+
* namespace URI_
|
|
82
|
+
*/
|
|
83
|
+
const resolveXMLSchemaNamespacePrefix = (
|
|
84
|
+
resolver: BindDataTypeNamespaceResolver
|
|
85
|
+
): string | null => {
|
|
86
|
+
const declaredPrefix = resolver.lookupPrefix(XSD_NAMESPACE_URI);
|
|
87
|
+
|
|
88
|
+
if (declaredPrefix != null) {
|
|
89
|
+
return declaredPrefix;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (resolver.lookupNamespaceURI(XSD_PREFIX) == null) {
|
|
93
|
+
return XSD_PREFIX;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
interface MaybeBindElementNamespaceResolver
|
|
100
|
+
extends BindElement,
|
|
101
|
+
Partial<BindDataTypeNamespaceResolver> {}
|
|
102
|
+
|
|
103
|
+
interface BindElementNamespaceResolver extends BindElement, BindDataTypeNamespaceResolver {}
|
|
104
|
+
|
|
105
|
+
const isNamespaceResolver = (
|
|
106
|
+
bindElement: MaybeBindElementNamespaceResolver
|
|
107
|
+
): bindElement is BindElementNamespaceResolver => {
|
|
108
|
+
return (
|
|
109
|
+
typeof bindElement.lookupNamespaceURI === 'function' &&
|
|
110
|
+
typeof bindElement.lookupPrefix === 'function'
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const resolveNamespacedBindType = (
|
|
115
|
+
bindElement: BindElement,
|
|
116
|
+
sourceType: string
|
|
117
|
+
): BindType | null => {
|
|
118
|
+
if (!isNamespaceResolver(bindElement)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const qualifiedName = parseQualifiedNameExpression(sourceType);
|
|
123
|
+
|
|
124
|
+
if (qualifiedName == null) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const xsdPrefix = resolveXMLSchemaNamespacePrefix(bindElement);
|
|
129
|
+
|
|
130
|
+
if (xsdPrefix == null) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const { prefix, localPart } = qualifiedName;
|
|
135
|
+
|
|
136
|
+
if (prefix === xsdPrefix) {
|
|
137
|
+
return (
|
|
138
|
+
resolveSupportedBindType(localPart) ??
|
|
139
|
+
resolveAliasedBindType(localPart) ??
|
|
140
|
+
resolveUnsupportedBindType(localPart)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return null;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const resolveBindType = (bindElement: BindElement, sourceType: string): BindType => {
|
|
148
|
+
return (
|
|
149
|
+
resolveSupportedBindType(sourceType) ??
|
|
150
|
+
resolveAliasedBindType(sourceType) ??
|
|
151
|
+
resolveNamespacedBindType(bindElement, sourceType) ??
|
|
152
|
+
resolveUnsupportedBindType(sourceType)
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export class BindTypeDefinition<T extends BindType = BindType> {
|
|
157
|
+
static from<T extends BindType>(bindElement: BindElement): BindTypeDefinition<T> {
|
|
158
|
+
const sourceType = bindElement.getAttribute('type');
|
|
159
|
+
|
|
160
|
+
if (sourceType == null) {
|
|
161
|
+
return new this(sourceType, DEFAULT_BIND_TYPE);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const resolved = resolveBindType(bindElement, sourceType);
|
|
165
|
+
|
|
166
|
+
return new this(sourceType, resolved);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private constructor(source: null, resolved: DefaultBindType);
|
|
170
|
+
private constructor(source: string, resolved: BindType);
|
|
171
|
+
private constructor(
|
|
172
|
+
readonly source: string | null,
|
|
173
|
+
readonly resolved: T
|
|
174
|
+
) {}
|
|
175
|
+
}
|
|
@@ -29,7 +29,6 @@ export abstract class DescendentNodeDefinition<
|
|
|
29
29
|
|
|
30
30
|
readonly root: RootDefinition;
|
|
31
31
|
readonly nodeset: string;
|
|
32
|
-
readonly dependencyExpressions: ReadonlySet<string>;
|
|
33
32
|
readonly isTranslated: boolean = false;
|
|
34
33
|
|
|
35
34
|
constructor(
|
|
@@ -43,11 +42,6 @@ export abstract class DescendentNodeDefinition<
|
|
|
43
42
|
if (bind.isTranslated || bodyElement?.isTranslated) {
|
|
44
43
|
this.isTranslated = true;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
this.dependencyExpressions = new Set([
|
|
48
|
-
...bind.dependencyExpressions,
|
|
49
|
-
...(bodyElement?.dependencyExpressions ?? []),
|
|
50
|
-
]);
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
47
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { SubmissionDefinition } from '../../client/submission/SubmissionDefinition.ts';
|
|
2
|
+
import { getSubmissionElement } from '../../lib/dom/query.ts';
|
|
3
|
+
import type { XFormDOM } from '../XFormDOM.ts';
|
|
4
|
+
|
|
5
|
+
export class FormSubmissionDefinition implements SubmissionDefinition {
|
|
6
|
+
readonly submissionAction!: URL | null;
|
|
7
|
+
readonly submissionMethod = 'post';
|
|
8
|
+
readonly encryptionKey!: string | null;
|
|
9
|
+
|
|
10
|
+
constructor(xformDOM: XFormDOM) {
|
|
11
|
+
const submissionElement = getSubmissionElement(xformDOM.model);
|
|
12
|
+
|
|
13
|
+
let submissionAction: URL | null = null;
|
|
14
|
+
let submissionMethod: 'post';
|
|
15
|
+
let encryptionKey: string | null = null;
|
|
16
|
+
|
|
17
|
+
if (submissionElement == null) {
|
|
18
|
+
submissionAction = null;
|
|
19
|
+
submissionMethod = 'post';
|
|
20
|
+
encryptionKey = null;
|
|
21
|
+
} else {
|
|
22
|
+
const method = submissionElement.getAttribute('method')?.trim();
|
|
23
|
+
|
|
24
|
+
if (method == null || method === 'post' || method === 'form-data-post') {
|
|
25
|
+
submissionMethod = 'post';
|
|
26
|
+
} else {
|
|
27
|
+
throw new Error(`Unexpected <submission method>: ${method}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const action = submissionElement.getAttribute('action');
|
|
31
|
+
|
|
32
|
+
if (action != null) {
|
|
33
|
+
// TODO: this is known-fallible.
|
|
34
|
+
submissionAction = new URL(action.trim());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
encryptionKey = submissionElement.getAttribute('base64RsaPublicKey');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.submissionAction = submissionAction;
|
|
41
|
+
this.submissionMethod = submissionMethod;
|
|
42
|
+
this.encryptionKey = encryptionKey;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StaticDocument } from '../../../integration/xpath/static-dom/StaticDocument.ts';
|
|
2
|
+
import { ItextTranslationRootDefinition } from './ItextTranslationRootDefinition.ts';
|
|
3
|
+
|
|
4
|
+
export class ItextTranslationDefinition extends StaticDocument<ItextTranslationRootDefinition> {}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { XFormsItextTranslationElement } from '@getodk/xpath';
|
|
2
|
+
import { XFORMS_KNOWN_ATTRIBUTE, XFORMS_LOCAL_NAME } from '@getodk/xpath';
|
|
3
|
+
import { StaticElement } from '../../../integration/xpath/static-dom/StaticElement.ts';
|
|
4
|
+
|
|
5
|
+
// prettier-ignore
|
|
6
|
+
type ItextTranslationRootKnownAttributeValue<LocalName extends string> =
|
|
7
|
+
LocalName extends 'lang'
|
|
8
|
+
? string
|
|
9
|
+
: string | null;
|
|
10
|
+
|
|
11
|
+
type AssertItextTranslationRootKnownAttributeValue = <LocalName extends string>(
|
|
12
|
+
localName: LocalName,
|
|
13
|
+
value: string | null
|
|
14
|
+
) => asserts value is ItextTranslationRootKnownAttributeValue<LocalName>;
|
|
15
|
+
|
|
16
|
+
const assertItextTranslationRootKnownAttributeValue: AssertItextTranslationRootKnownAttributeValue =
|
|
17
|
+
(localName, value) => {
|
|
18
|
+
if (localName === 'lang' && value == null) {
|
|
19
|
+
throw new Error('Invalid itext <translation> element: missing `lang` attribute');
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export class ItextTranslationRootDefinition
|
|
24
|
+
extends StaticElement
|
|
25
|
+
implements XFormsItextTranslationElement<ItextTranslationRootDefinition>
|
|
26
|
+
{
|
|
27
|
+
override readonly [XFORMS_LOCAL_NAME] = 'translation';
|
|
28
|
+
override readonly [XFORMS_KNOWN_ATTRIBUTE] = 'lang';
|
|
29
|
+
|
|
30
|
+
override getAttributeValue(localName: 'lang'): string;
|
|
31
|
+
override getAttributeValue(localName: string): string | null;
|
|
32
|
+
override getAttributeValue<LocalName extends string>(
|
|
33
|
+
localName: LocalName
|
|
34
|
+
): ItextTranslationRootKnownAttributeValue<LocalName> {
|
|
35
|
+
const value = super.getAttributeValue(localName);
|
|
36
|
+
|
|
37
|
+
assertItextTranslationRootKnownAttributeValue(localName, value);
|
|
38
|
+
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { XFormsItextTranslationMap } from '@getodk/xpath';
|
|
2
|
+
import type { EngineXPathNode } from '../../../integration/xpath/adapter/kind.ts';
|
|
3
|
+
import { parseStaticDocumentFromDOMSubtree } from '../../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
4
|
+
import type { XFormDOM } from '../../XFormDOM.ts';
|
|
5
|
+
import { ItextTranslationDefinition } from './ItextTranslationDefinition.ts';
|
|
6
|
+
import { ItextTranslationRootDefinition } from './ItextTranslationRootDefinition.ts';
|
|
7
|
+
|
|
8
|
+
export class ItextTranslationsDefinition
|
|
9
|
+
extends Map<string, ItextTranslationRootDefinition>
|
|
10
|
+
implements XFormsItextTranslationMap<EngineXPathNode>
|
|
11
|
+
{
|
|
12
|
+
static from(xformDOM: XFormDOM): ItextTranslationsDefinition {
|
|
13
|
+
const translationDefinitions = xformDOM.itextTranslationElements.map((element) => {
|
|
14
|
+
return parseStaticDocumentFromDOMSubtree(
|
|
15
|
+
ItextTranslationDefinition,
|
|
16
|
+
ItextTranslationRootDefinition,
|
|
17
|
+
element
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return new this(translationDefinitions);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private constructor(translations: readonly ItextTranslationDefinition[]) {
|
|
25
|
+
super(
|
|
26
|
+
translations.map(({ root }) => {
|
|
27
|
+
return [root.getAttributeValue('lang'), root];
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
1
2
|
import type { AnyBodyElementDefinition, ControlElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
3
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
3
4
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
4
5
|
import type { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
5
6
|
|
|
6
|
-
export class LeafNodeDefinition
|
|
7
|
+
export class LeafNodeDefinition<V extends ValueType = ValueType>
|
|
7
8
|
extends DescendentNodeDefinition<'leaf-node', ControlElementDefinition | null>
|
|
8
9
|
implements NodeDefinition<'leaf-node'>
|
|
9
10
|
{
|
|
10
11
|
readonly type = 'leaf-node';
|
|
12
|
+
readonly valueType: V;
|
|
11
13
|
|
|
12
14
|
readonly nodeName: string;
|
|
13
15
|
readonly children = null;
|
|
@@ -26,6 +28,7 @@ export class LeafNodeDefinition
|
|
|
26
28
|
|
|
27
29
|
super(parent, bind, bodyElement);
|
|
28
30
|
|
|
31
|
+
this.valueType = bind.type.resolved satisfies ValueType as V;
|
|
29
32
|
this.nodeName = node.localName;
|
|
30
33
|
this.defaultValue = node.textContent ?? '';
|
|
31
34
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
2
|
import { BindDefinition } from './BindDefinition.ts';
|
|
3
3
|
import type { BindElement, BindNodeset } from './BindElement.ts';
|
|
4
|
+
import { DEFAULT_BIND_TYPE } from './BindTypeDefinition.ts';
|
|
4
5
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
5
6
|
|
|
6
7
|
class ArtificialBindElement implements BindElement {
|
|
@@ -15,6 +16,10 @@ class ArtificialBindElement implements BindElement {
|
|
|
15
16
|
return this.ancestorNodeset;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
if (name === 'type') {
|
|
20
|
+
return DEFAULT_BIND_TYPE;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
return null;
|
|
19
24
|
}
|
|
20
25
|
|
|
@@ -37,15 +42,8 @@ export class ModelBindMap extends Map<BindNodeset, BindDefinition> {
|
|
|
37
42
|
protected readonly form: XFormDefinition,
|
|
38
43
|
protected readonly model: ModelDefinition
|
|
39
44
|
) {
|
|
40
|
-
const bindElements = form.xformDOM.rootEvaluator.evaluateNodes<BindElement & Element>(
|
|
41
|
-
'./xf:bind[@nodeset]',
|
|
42
|
-
{
|
|
43
|
-
contextNode: form.xformDOM.model,
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
|
|
47
45
|
super(
|
|
48
|
-
|
|
46
|
+
form.xformDOM.binds.map((bindElement) => {
|
|
49
47
|
const nodeset = bindElement.getAttribute('nodeset');
|
|
50
48
|
const bind = new BindDefinition(form, model, nodeset, bindElement);
|
|
51
49
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
+
import { FormSubmissionDefinition } from './FormSubmissionDefinition.ts';
|
|
3
|
+
import { ItextTranslationsDefinition } from './ItextTranslation/ItextTranslationsDefinition.ts';
|
|
4
|
+
import { ModelBindMap } from './ModelBindMap.ts';
|
|
5
|
+
import { RootDefinition } from './RootDefinition.ts';
|
|
6
|
+
|
|
7
|
+
export class ModelDefinition {
|
|
8
|
+
readonly binds: ModelBindMap;
|
|
9
|
+
readonly root: RootDefinition;
|
|
10
|
+
readonly itextTranslations: ItextTranslationsDefinition;
|
|
11
|
+
|
|
12
|
+
constructor(readonly form: XFormDefinition) {
|
|
13
|
+
const submission = new FormSubmissionDefinition(form.xformDOM);
|
|
14
|
+
this.binds = ModelBindMap.fromModel(this);
|
|
15
|
+
this.root = new RootDefinition(form, this, submission, form.body.classes);
|
|
16
|
+
this.itextTranslations = ItextTranslationsDefinition.from(form.xformDOM);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toJSON() {
|
|
20
|
+
const { form, ...rest } = this;
|
|
21
|
+
|
|
22
|
+
return rest;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -121,10 +121,7 @@ export interface NodeDefinition<Type extends NodeDefinitionType> {
|
|
|
121
121
|
readonly nodeset: string;
|
|
122
122
|
readonly nodeName: string;
|
|
123
123
|
readonly bodyElement: AnyBodyElementDefinition | RepeatElementDefinition | null;
|
|
124
|
-
|
|
125
124
|
readonly isTranslated: boolean;
|
|
126
|
-
readonly dependencyExpressions: ReadonlySet<string>;
|
|
127
|
-
|
|
128
125
|
readonly root: RootDefinition;
|
|
129
126
|
readonly parent: NodeParent<Type>;
|
|
130
127
|
readonly children: NodeChildren<Type>;
|