@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getodk/xforms-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "XForms engine for ODK Web Forms",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"README.md"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": "^18.20.4 || ^20.
|
|
32
|
+
"node": "^18.20.4 || ^20.17.0 || ^22.9.0",
|
|
33
33
|
"yarn": "1.22.22"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
@@ -54,22 +54,24 @@
|
|
|
54
54
|
"test:types": "tsc --project ./tsconfig.json --emitDeclarationOnly false --noEmit"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"
|
|
57
|
+
"papaparse": "^5.4.1",
|
|
58
|
+
"solid-js": "^1.9.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@babel/core": "^7.
|
|
61
|
+
"@babel/core": "^7.25.2",
|
|
61
62
|
"@getodk/tree-sitter-xpath": "0.1.2",
|
|
62
|
-
"@getodk/xpath": "0.
|
|
63
|
-
"@playwright/test": "^1.
|
|
64
|
-
"@
|
|
63
|
+
"@getodk/xpath": "0.3.0",
|
|
64
|
+
"@playwright/test": "^1.47.2",
|
|
65
|
+
"@types/papaparse": "^5.3.15",
|
|
66
|
+
"@vitest/browser": "^2.1.1",
|
|
65
67
|
"babel-plugin-transform-jsbi-to-bigint": "^1.4.0",
|
|
66
68
|
"http-server": "^14.1.1",
|
|
67
|
-
"jsdom": "^
|
|
68
|
-
"typedoc": "^0.26.
|
|
69
|
-
"vite": "^5.
|
|
70
|
-
"vite-plugin-dts": "^
|
|
69
|
+
"jsdom": "^25.0.1",
|
|
70
|
+
"typedoc": "^0.26.7",
|
|
71
|
+
"vite": "^5.4.8",
|
|
72
|
+
"vite-plugin-dts": "^4.2.2",
|
|
71
73
|
"vite-plugin-no-bundle": "^4.0.0",
|
|
72
|
-
"vitest": "^2.
|
|
74
|
+
"vitest": "^2.1.1"
|
|
73
75
|
},
|
|
74
76
|
"peerDependencies": {
|
|
75
77
|
"solid-js": "^1.8.18"
|
package/src/client/BaseNode.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { TokenListParser } from '../lib/TokenListParser.ts';
|
|
2
|
-
import type { AnyNodeDefinition } from '../model/NodeDefinition.ts';
|
|
2
|
+
import type { AnyNodeDefinition } from '../parse/model/NodeDefinition.ts';
|
|
3
3
|
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
4
4
|
import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
5
5
|
import type { TextRange } from './TextRange.ts';
|
|
6
|
+
import type { FormNodeID } from './identity.ts';
|
|
6
7
|
import type { InstanceNodeType } from './node-types.ts';
|
|
8
|
+
import type { SubmissionState } from './submission/SubmissionState.ts';
|
|
7
9
|
import type {
|
|
8
10
|
AncestorNodeValidationState,
|
|
9
11
|
LeafNodeValidationState,
|
|
@@ -129,8 +131,6 @@ export interface BaseNodeState {
|
|
|
129
131
|
get value(): unknown;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
type FormNodeID = string;
|
|
133
|
-
|
|
134
134
|
/**
|
|
135
135
|
* Base interface for common/shared aspects of any node type.
|
|
136
136
|
*/
|
|
@@ -189,15 +189,13 @@ export interface BaseNode {
|
|
|
189
189
|
// 2. If `parent` does become nullable state, how best to convey the same
|
|
190
190
|
// information for removed descendants. Some ideas:
|
|
191
191
|
//
|
|
192
|
-
// - Apply null-as-removed recursively.
|
|
193
|
-
// for the engine's current use of a DOM backing store (but that's an
|
|
194
|
-
// implementation detail clients don't/shouldn't care about).
|
|
192
|
+
// - Apply null-as-removed recursively.
|
|
195
193
|
//
|
|
196
194
|
// - Borrow the browser DOM's notion of node "connected"-ness. When a node
|
|
197
195
|
// is removed, its `isConnected` property is `false`. The same is true
|
|
198
196
|
// for any of its descendants, even though they retain their own direct
|
|
199
197
|
// parent reference.
|
|
200
|
-
readonly parent:
|
|
198
|
+
readonly parent: unknown;
|
|
201
199
|
|
|
202
200
|
/**
|
|
203
201
|
* Each node provides a discrete object representing the stateful aspects\* of
|
|
@@ -251,4 +249,16 @@ export interface BaseNode {
|
|
|
251
249
|
* clients to explicitly pause and resume recomputation.
|
|
252
250
|
*/
|
|
253
251
|
readonly validationState: NodeValidationState;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Represents the current submission state of the node.
|
|
255
|
+
*
|
|
256
|
+
* @see {@link SubmissionState.submissionXML} for additional detail.
|
|
257
|
+
*
|
|
258
|
+
* @todo Consider whether this can (should) be merged with
|
|
259
|
+
* {@link currentState}, while providing the same client-reactivity
|
|
260
|
+
* guarantees. (The challenge there is in defining client-reactive state which
|
|
261
|
+
* self-referentially derives state from its own definition.)
|
|
262
|
+
*/
|
|
263
|
+
readonly submissionState: SubmissionState;
|
|
254
264
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
2
|
+
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
4
|
+
import type { LeafNodeType } from './node-types.ts';
|
|
5
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
6
|
+
import type { ValueType } from './ValueType.ts';
|
|
7
|
+
|
|
8
|
+
export interface BaseValueNodeState<Value> extends BaseNodeState {
|
|
9
|
+
get children(): null;
|
|
10
|
+
get valueOptions(): null;
|
|
11
|
+
get value(): Value;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reflects the serialized string representation of a {@link BaseValueNode}'s
|
|
15
|
+
* {@link value} state. This representation allows access to the node's value
|
|
16
|
+
* _as primary instance state_. In other words, this is the value which:
|
|
17
|
+
*
|
|
18
|
+
* - would be serialized as a text node in
|
|
19
|
+
* {@link SubmissionState.submissionXML} (note: this value is **NOT**
|
|
20
|
+
* escaped for XML serialization, as it is there)
|
|
21
|
+
*
|
|
22
|
+
* - is used when the node's value is referenced in any of a form's XPath
|
|
23
|
+
* expressions
|
|
24
|
+
*/
|
|
25
|
+
get instanceValue(): string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BaseValueNode<V extends ValueType = ValueType, Value = string> extends BaseNode {
|
|
29
|
+
readonly nodeType: LeafNodeType;
|
|
30
|
+
readonly valueType: V;
|
|
31
|
+
readonly definition: LeafNodeDefinition;
|
|
32
|
+
readonly parent: GeneralParentNode;
|
|
33
|
+
readonly currentState: BaseValueNodeState<Value>;
|
|
34
|
+
readonly validationState: LeafNodeValidationState;
|
|
35
|
+
}
|
|
@@ -1,35 +1,7 @@
|
|
|
1
|
+
import type { initializeForm } from '../instance/index.ts';
|
|
2
|
+
import type { MissingResourceBehavior, MissingResourceBehaviorDefault } from './constants.ts';
|
|
1
3
|
import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @todo this is currently a strict subset of the web standard `Response`. Is it
|
|
5
|
-
* sufficient? Ways it might not be:
|
|
6
|
-
*
|
|
7
|
-
* - No way to convey metadata about the resource
|
|
8
|
-
* - Ambiguous if a client supplies an alternative implementation which doesn't
|
|
9
|
-
* exhaust the body on access
|
|
10
|
-
*/
|
|
11
|
-
export interface FetchResourceResponse {
|
|
12
|
-
readonly ok?: boolean;
|
|
13
|
-
readonly body?: ReadableStream<Uint8Array> | null;
|
|
14
|
-
readonly bodyUsed?: boolean;
|
|
15
|
-
|
|
16
|
-
readonly blob: () => Promise<Blob>;
|
|
17
|
-
readonly text: () => Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @todo this is a strict subset of the web standard `fetch` interface. It
|
|
22
|
-
* implicitly assumes that the engine itself will only ever issue `GET`-like
|
|
23
|
-
* requests. It also provides no further request-like semantics to the engine.
|
|
24
|
-
* This is presumed sufficient for now, but notably doesn't expose any notion of
|
|
25
|
-
* content negotiation (e.g. the ability to supply `Accept` headers).
|
|
26
|
-
*
|
|
27
|
-
* This also completely ignores any notion of mapping
|
|
28
|
-
* {@link https://getodk.github.io/xforms-spec/#uris | `jr:` URLs} to their
|
|
29
|
-
* actual resources (likely, but not necessarily, accessed at a corresponding
|
|
30
|
-
* HTTP URL).
|
|
31
|
-
*/
|
|
32
|
-
export type FetchResource = (resource: URL) => Promise<FetchResourceResponse>;
|
|
4
|
+
import type { FetchFormAttachment, FetchResource } from './resources.ts';
|
|
33
5
|
|
|
34
6
|
/**
|
|
35
7
|
* Options provided by a client to specify certain aspects of engine runtime
|
|
@@ -55,29 +27,58 @@ export interface EngineConfig {
|
|
|
55
27
|
readonly stateFactory?: OpaqueReactiveObjectFactory;
|
|
56
28
|
|
|
57
29
|
/**
|
|
58
|
-
* A client may specify a generic function for retrieving resources referenced
|
|
59
|
-
* by a form, such as:
|
|
60
30
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
31
|
+
* A client may specify an arbitrary {@link fetch}-like function for retrieving an XML XForm form
|
|
32
|
+
* definition.
|
|
33
|
+
*
|
|
34
|
+
* Notes:
|
|
35
|
+
*
|
|
36
|
+
* - This configuration will only be consuled for calls to
|
|
37
|
+
* {@link initializeForm} with a URL referencing an XML XForm definition. It
|
|
38
|
+
* will be ignored for calls passing an XML XForm form definition directly.
|
|
39
|
+
*
|
|
40
|
+
* - For calls to {@link initializeForm} with a URL, if this configuration is
|
|
41
|
+
* not specified it will default to the global {@link fetch} function (if
|
|
42
|
+
* one is defined).
|
|
43
|
+
*/
|
|
44
|
+
readonly fetchFormDefinition?: FetchResource;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A client may specify an arbitrary {@link fetch}-like function to retrieve a
|
|
48
|
+
* form's attachments, i.e. any `jr:` URL referenced by the form (as specified
|
|
49
|
+
* by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
|
|
50
|
+
*
|
|
51
|
+
* Notes:
|
|
65
52
|
*
|
|
66
|
-
*
|
|
67
|
-
* {@link
|
|
68
|
-
* performing `GET` requests for:
|
|
53
|
+
* - This configuration will be consulted for all supported form attachments,
|
|
54
|
+
* as a part of {@link initializeForm | form initialization}.
|
|
69
55
|
*
|
|
70
|
-
* -
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
56
|
+
* - If this configuration is not specified it will default to the global
|
|
57
|
+
* {@link fetch} function (if one is defined).
|
|
58
|
+
*
|
|
59
|
+
* This default behavior will typically result in failure to load form
|
|
60
|
+
* attachments—and in most cases this will also cause
|
|
61
|
+
* {@link initializeForm | form initialization} to fail overall—with the
|
|
62
|
+
* following exceptions:
|
|
63
|
+
*
|
|
64
|
+
* - **CLIENT-SPECIFIC:** Usage in coordination with a client-implemented
|
|
65
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Serivce Worker},
|
|
66
|
+
* which can intercept network requests **generally**. Clients already using
|
|
67
|
+
* a Service Worker may opt for the convenience of handling network requests
|
|
68
|
+
* for `jr:` URLs along with any other network interception logic. Client
|
|
69
|
+
* implementors should be warned, however, that such `jr:` URLs are not
|
|
70
|
+
* namespaced or otherwise scoped to a particular form; such a client would
|
|
71
|
+
* therefore inherently need to coordinate state between the Service Worker
|
|
72
|
+
* and the main thread (or whatever other realm calls
|
|
73
|
+
* {@link initializeForm}).
|
|
74
|
+
*/
|
|
75
|
+
readonly fetchFormAttachment?: FetchFormAttachment;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @see {@link MissingResourceBehavior}
|
|
79
|
+
* @see {@link MissingResourceBehaviorDefault}
|
|
74
80
|
*
|
|
75
|
-
*
|
|
76
|
-
* retrieve any such resource, as required for engine functionality. If
|
|
77
|
-
* absent, the engine will use the native `fetch` function (if available, a
|
|
78
|
-
* polyfill otherwise). Clients may use this function to provide resources
|
|
79
|
-
* from sources other than the network, (or even in a test client to provide
|
|
80
|
-
* e.g. resources from test fixtures).
|
|
81
|
+
* @default MissingResourceBehaviorDefault
|
|
81
82
|
*/
|
|
82
|
-
readonly
|
|
83
|
+
readonly missingResourceBehavior?: MissingResourceBehavior;
|
|
83
84
|
}
|
package/src/client/GroupNode.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyGroupElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
|
-
import type { SubtreeDefinition } from '../model/SubtreeDefinition.ts';
|
|
1
|
+
import type { AnyGroupElementDefinition } from '../parse/body/BodyDefinition.ts';
|
|
2
|
+
import type { SubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
3
3
|
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
5
5
|
import type { RootNode } from './RootNode.ts';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
2
|
+
import type { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
|
|
3
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
4
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
5
|
+
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
6
|
+
import type { RootNode } from './RootNode.ts';
|
|
7
|
+
import type { ValueType } from './ValueType.ts';
|
|
8
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
9
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
10
|
+
|
|
11
|
+
export type InputValue<V extends ValueType> = RuntimeValue<V>;
|
|
12
|
+
|
|
13
|
+
export type InputNodeInputValue<V extends ValueType> = RuntimeInputValue<V>;
|
|
14
|
+
|
|
15
|
+
export interface InputNodeState<V extends ValueType> extends BaseValueNodeState<InputValue<V>> {
|
|
16
|
+
get children(): null;
|
|
17
|
+
get valueOptions(): null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reflects the current value of a {@link InputNode}. This value may be
|
|
21
|
+
* populated when a form is loaded, and it may be updated by certain
|
|
22
|
+
* computations defined by the form. It may also be updated by a client, using
|
|
23
|
+
* the {@link InputNode.setValue} method.
|
|
24
|
+
*/
|
|
25
|
+
get value(): InputValue<V>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface InputDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
29
|
+
readonly bodyElement: InputControlDefinition;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type InputNodeAppearances = NodeAppearances<InputDefinition>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A node corresponding to form field defined as an
|
|
36
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<input>`},
|
|
37
|
+
* which a user-facing client would likely present for a user to fill..
|
|
38
|
+
*/
|
|
39
|
+
export interface InputNode<V extends ValueType = ValueType>
|
|
40
|
+
extends BaseValueNode<V, InputValue<V>> {
|
|
41
|
+
readonly nodeType: 'input';
|
|
42
|
+
readonly valueType: V;
|
|
43
|
+
readonly appearances: InputNodeAppearances;
|
|
44
|
+
readonly definition: InputDefinition<V>;
|
|
45
|
+
readonly root: RootNode;
|
|
46
|
+
readonly parent: GeneralParentNode;
|
|
47
|
+
readonly currentState: InputNodeState<V>;
|
|
48
|
+
readonly validationState: LeafNodeValidationState;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* For use by a client to update the value of an {@link InputNode}.
|
|
52
|
+
*/
|
|
53
|
+
setValue(value: InputNodeInputValue<V>): RootNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type StringInputNode = InputNode<'string'>;
|
|
57
|
+
export type IntInputNode = InputNode<'int'>;
|
|
58
|
+
export type DecimalInputNode = InputNode<'decimal'>;
|
|
59
|
+
|
|
60
|
+
// prettier-ignore
|
|
61
|
+
type SupportedInputValueType =
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
63
|
+
| 'string'
|
|
64
|
+
| 'int'
|
|
65
|
+
| 'decimal';
|
|
66
|
+
|
|
67
|
+
type TemporaryStringValueType = Exclude<ValueType, SupportedInputValueType>;
|
|
68
|
+
|
|
69
|
+
export type TemporaryStringValueInputNode = InputNode<TemporaryStringValueType>;
|
|
70
|
+
|
|
71
|
+
// prettier-ignore
|
|
72
|
+
export type AnyInputNode =
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
74
|
+
| StringInputNode
|
|
75
|
+
| IntInputNode
|
|
76
|
+
| DecimalInputNode
|
|
77
|
+
| TemporaryStringValueInputNode;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
2
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
3
4
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
4
5
|
import type { RootNode } from './RootNode.ts';
|
|
5
6
|
import type { LeafNodeValidationState } from './validation.ts';
|
|
7
|
+
import type { ValueType } from './ValueType.ts';
|
|
6
8
|
|
|
7
|
-
export
|
|
9
|
+
export type ModelValue<V extends ValueType> = RuntimeValue<V>;
|
|
10
|
+
|
|
11
|
+
export interface ModelValueNodeState<V extends ValueType>
|
|
12
|
+
extends BaseValueNodeState<ModelValue<V>> {
|
|
8
13
|
get label(): null;
|
|
9
14
|
get hint(): null;
|
|
10
15
|
get children(): null;
|
|
@@ -15,10 +20,11 @@ export interface ModelValueNodeState extends BaseNodeState {
|
|
|
15
20
|
* populated when a form is loaded, and it may be updated by certain
|
|
16
21
|
* computations defined by the form.
|
|
17
22
|
*/
|
|
18
|
-
get value():
|
|
23
|
+
get value(): ModelValue<V>;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
export interface ModelValueDefinition extends
|
|
26
|
+
export interface ModelValueDefinition<V extends ValueType = ValueType>
|
|
27
|
+
extends LeafNodeDefinition<V> {
|
|
22
28
|
readonly bodyElement: null;
|
|
23
29
|
}
|
|
24
30
|
|
|
@@ -29,12 +35,29 @@ export interface ModelValueDefinition extends LeafNodeDefinition {
|
|
|
29
35
|
* - a leaf/value node (i.e. it has no element children; it may be defined in
|
|
30
36
|
* the form's `<model>` as either an {@link Element} or {@link Attr})
|
|
31
37
|
*/
|
|
32
|
-
export interface ModelValueNode extends
|
|
38
|
+
export interface ModelValueNode<V extends ValueType = ValueType>
|
|
39
|
+
extends BaseValueNode<V, ModelValue<V>> {
|
|
33
40
|
readonly nodeType: 'model-value';
|
|
41
|
+
readonly valueType: V;
|
|
34
42
|
readonly appearances: null;
|
|
35
|
-
readonly definition: ModelValueDefinition
|
|
43
|
+
readonly definition: ModelValueDefinition<V>;
|
|
36
44
|
readonly root: RootNode;
|
|
37
45
|
readonly parent: GeneralParentNode;
|
|
38
|
-
readonly currentState: ModelValueNodeState
|
|
46
|
+
readonly currentState: ModelValueNodeState<V>;
|
|
39
47
|
readonly validationState: LeafNodeValidationState;
|
|
40
48
|
}
|
|
49
|
+
|
|
50
|
+
export type AnyModelValueNode =
|
|
51
|
+
| ModelValueNode<'barcode'>
|
|
52
|
+
| ModelValueNode<'binary'>
|
|
53
|
+
| ModelValueNode<'boolean'>
|
|
54
|
+
| ModelValueNode<'date'>
|
|
55
|
+
| ModelValueNode<'dateTime'>
|
|
56
|
+
| ModelValueNode<'decimal'>
|
|
57
|
+
| ModelValueNode<'geopoint'>
|
|
58
|
+
| ModelValueNode<'geoshape'>
|
|
59
|
+
| ModelValueNode<'geotrace'>
|
|
60
|
+
| ModelValueNode<'int'>
|
|
61
|
+
| ModelValueNode<'intent'>
|
|
62
|
+
| ModelValueNode<'string'>
|
|
63
|
+
| ModelValueNode<'time'>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ParsedTokenList } from '../lib/TokenListParser.ts';
|
|
2
|
-
import type { NodeDefinition } from '../model/NodeDefinition.ts';
|
|
2
|
+
import type { NodeDefinition } from '../parse/model/NodeDefinition.ts';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* - Provides a means to distinguish between internal and client-facing names
|
package/src/client/NoteNode.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
|
|
1
|
+
import type { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
|
|
2
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
3
|
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
5
5
|
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
@@ -52,7 +52,7 @@ export interface NoteNodeState extends BaseNodeState {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export interface NoteDefinition extends LeafNodeDefinition {
|
|
55
|
-
readonly bodyElement:
|
|
55
|
+
readonly bodyElement: InputControlDefinition;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
|
package/src/client/RootNode.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { BodyClassList } from '../body/BodyDefinition.ts';
|
|
2
|
-
import type { RootDefinition } from '../model/RootDefinition.ts';
|
|
1
|
+
import type { BodyClassList } from '../parse/body/BodyDefinition.ts';
|
|
2
|
+
import type { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
3
3
|
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import type { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
|
|
5
5
|
import type { GeneralChildNode } from './hierarchy.ts';
|
|
6
|
+
import type { SubmissionChunkedType, SubmissionOptions } from './submission/SubmissionOptions.ts';
|
|
7
|
+
import type { SubmissionResult } from './submission/SubmissionResult.ts';
|
|
6
8
|
import type { AncestorNodeValidationState } from './validation.ts';
|
|
7
9
|
|
|
8
10
|
export interface RootNodeState extends BaseNodeState {
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
across all node types seems like a point of potential confusion, so this
|
|
13
|
-
particular divergence seems like the most reasonable compromise.
|
|
12
|
+
* @todo If we ever expose an interface to the primary instance document, it
|
|
13
|
+
* would make sense to move this state up.
|
|
14
14
|
*/
|
|
15
15
|
get activeLanguage(): ActiveLanguage;
|
|
16
16
|
|
|
@@ -46,15 +46,45 @@ export interface RootNode extends BaseNode {
|
|
|
46
46
|
|
|
47
47
|
readonly definition: RootDefinition;
|
|
48
48
|
readonly root: RootNode;
|
|
49
|
-
readonly parent:
|
|
49
|
+
readonly parent: unknown;
|
|
50
50
|
readonly currentState: RootNodeState;
|
|
51
51
|
readonly validationState: AncestorNodeValidationState;
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* @todo as
|
|
55
|
-
* significant break in consistency across node types.
|
|
54
|
+
* @todo as discussed on {@link RootNodeState.activeLanguage}
|
|
56
55
|
*/
|
|
57
56
|
readonly languages: FormLanguages;
|
|
58
57
|
|
|
59
58
|
setLanguage(language: FormLanguage): RootNode;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Prepares the current form instance state for submission.
|
|
62
|
+
*
|
|
63
|
+
* A {@link SubmissionResult} will be prepared even if the current form state
|
|
64
|
+
* includes `constraint` or `required` violations. This is intended to serve
|
|
65
|
+
* two purposes:
|
|
66
|
+
*
|
|
67
|
+
* - A client may effectively use this method as a part of its own "submit"
|
|
68
|
+
* routine, and use any violations included in the {@link SubmissionResult}
|
|
69
|
+
* to prompt users to address those violations.
|
|
70
|
+
*
|
|
71
|
+
* - A client may inspect the submission state of a form at any time.
|
|
72
|
+
* Depending on the client and use case, this may be a convenience (e.g. for
|
|
73
|
+
* developers to inspect that form state at a current point in time); or it
|
|
74
|
+
* may provide necessary functionality (e.g. for test or tooling clients).
|
|
75
|
+
*
|
|
76
|
+
* Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
|
|
77
|
+
* a fast operation. It may even be nearly instantaneous, or roughly
|
|
78
|
+
* proportionate to the size of the form itself. However, this method is
|
|
79
|
+
* designed to be asynchronous out of an abundance of caution, anticipating
|
|
80
|
+
* that some as-yet undeveloped operations on binary data (e.g. form
|
|
81
|
+
* attachments) may themselves impose asynchrony (i.e. by interfaces provided
|
|
82
|
+
* by the platform and/or external dependencies).
|
|
83
|
+
*
|
|
84
|
+
* A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
|
|
85
|
+
* {@link SubmissionResult<'chunked'>} will be produced, with form attachments
|
|
86
|
+
*/
|
|
87
|
+
prepareSubmission<ChunkedType extends SubmissionChunkedType>(
|
|
88
|
+
options?: SubmissionOptions<ChunkedType>
|
|
89
|
+
): Promise<SubmissionResult<ChunkedType>>;
|
|
60
90
|
}
|
package/src/client/SelectNode.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
|
|
2
|
-
import type { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
|
|
1
|
+
import type { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
|
|
2
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
3
|
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
|
+
import type { InputNode } from './InputNode.ts';
|
|
4
5
|
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
5
6
|
import type { RootNode } from './RootNode.ts';
|
|
6
|
-
import type { StringNode } from './StringNode.ts';
|
|
7
7
|
import type { TextRange } from './TextRange.ts';
|
|
8
8
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
9
9
|
import type { LeafNodeValidationState } from './validation.ts';
|
|
@@ -60,7 +60,7 @@ export interface SelectNode extends BaseNode {
|
|
|
60
60
|
* - For fields defined with an XForms `<select1>`, calling this method will
|
|
61
61
|
* replace the selection (if any).
|
|
62
62
|
*
|
|
63
|
-
* @todo @see {@link
|
|
63
|
+
* @todo @see {@link InputNode.setValue} re: write restrictions
|
|
64
64
|
* @todo @see {@link SelectNodeState.value} re: breaking up the types
|
|
65
65
|
*/
|
|
66
66
|
select(item: SelectItem): RootNode;
|
|
@@ -69,7 +69,7 @@ export interface SelectNode extends BaseNode {
|
|
|
69
69
|
* For use by a client to remove an item from the node's
|
|
70
70
|
* {@link SelectNodeState.value}.
|
|
71
71
|
*
|
|
72
|
-
* @todo @see {@link
|
|
72
|
+
* @todo @see {@link InputNode.setValue} re: write restrictions
|
|
73
73
|
*/
|
|
74
74
|
deselect(item: SelectItem): RootNode;
|
|
75
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SubtreeDefinition as BaseSubtreeDefinition } from '../model/SubtreeDefinition.ts';
|
|
1
|
+
import type { SubtreeDefinition as BaseSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
2
2
|
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
3
|
import type { RootNode } from './RootNode.ts';
|
|
4
4
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
package/src/client/TextRange.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { RootNodeState } from './RootNode.ts';
|
|
|
24
24
|
* Here, `is-translation-expr()` is a fictional shorthand for checking
|
|
25
25
|
* that the attribute's value is a valid `jr:itext(...)` FunctionCall
|
|
26
26
|
* expression. Note that, per spec, these attributes **do not accept
|
|
27
|
-
* arbitrary XPath expressions**! The non-translation case is
|
|
27
|
+
* arbitrary XPath expressions**! The non-translation case is treated as
|
|
28
28
|
* static text, not parsed for e.g. an XPath [string] Literal expression.
|
|
29
29
|
* This is why we have introduced this 'translation' case, distinct from
|
|
30
30
|
* 'reference', which previously handled translated labels and hints.
|
|
@@ -34,7 +34,7 @@ import type { RootNodeState } from './RootNode.ts';
|
|
|
34
34
|
*
|
|
35
35
|
* - `h:body//label/@ref[is-translation-expr()]`
|
|
36
36
|
*
|
|
37
|
-
* - '
|
|
37
|
+
* - 'literal':
|
|
38
38
|
* - `h:head//bind/@jr:constraintMsg[not(is-translation-expr())]`
|
|
39
39
|
* - `h:head//bind/@jr:requiredMsg[not(is-translation-expr())]`
|
|
40
40
|
* - `h:body//label/text()`
|
|
@@ -60,11 +60,10 @@ import type { RootNodeState } from './RootNode.ts';
|
|
|
60
60
|
*/
|
|
61
61
|
// prettier-ignore
|
|
62
62
|
export type TextChunkSource =
|
|
63
|
-
|
|
63
|
+
| 'literal'
|
|
64
64
|
| 'output'
|
|
65
65
|
| 'reference'
|
|
66
|
-
| 'translation'
|
|
67
|
-
| 'static';
|
|
66
|
+
| 'translation';
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
69
|
* @todo This (and everything else to do with {@link TextRange}s is for
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
2
|
+
import type { TriggerControlDefinition } from '../parse/body/control/TriggerControlDefinition.ts';
|
|
3
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
4
|
+
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
5
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
6
|
+
import type { RootNode } from './RootNode.ts';
|
|
7
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
8
|
+
|
|
9
|
+
export interface TriggerNodeState extends BaseNodeState {
|
|
10
|
+
get children(): null;
|
|
11
|
+
get valueOptions(): null;
|
|
12
|
+
get value(): boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface TriggerNodeDefinition extends LeafNodeDefinition {
|
|
16
|
+
readonly bodyElement: TriggerControlDefinition;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TriggerNode extends BaseNode {
|
|
20
|
+
readonly nodeType: 'trigger';
|
|
21
|
+
readonly definition: TriggerNodeDefinition;
|
|
22
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
23
|
+
readonly root: RootNode;
|
|
24
|
+
readonly parent: GeneralParentNode;
|
|
25
|
+
readonly currentState: TriggerNodeState;
|
|
26
|
+
readonly validationState: LeafNodeValidationState;
|
|
27
|
+
|
|
28
|
+
setValue(value: boolean): RootNode;
|
|
29
|
+
}
|