@getodk/xforms-engine 0.4.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 +14 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +12 -7
- package/dist/client/NoteNode.d.ts +2 -2
- package/dist/client/RootNode.d.ts +34 -7
- package/dist/client/SelectNode.d.ts +2 -2
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +4 -4
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +2 -1
- 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/validation.d.ts +2 -2
- 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 +10 -1
- package/dist/index.js +10856 -8585
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -4
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -26
- package/dist/instance/Note.d.ts +10 -3
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +29 -25
- package/dist/instance/SelectField.d.ts +10 -2
- package/dist/instance/Subtree.d.ts +10 -5
- package/dist/instance/TriggerControl.d.ts +10 -3
- package/dist/instance/abstract/DescendantNode.d.ts +31 -23
- package/dist/instance/abstract/InstanceNode.d.ts +49 -29
- package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/hierarchy.d.ts +9 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
- package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
- package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +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 +39 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
- package/dist/instance/resource.d.ts +1 -1
- package/dist/instance/text/TextRange.d.ts +1 -1
- package/dist/instance/unsupported/RangeControl.d.ts +3 -1
- package/dist/instance/unsupported/RankControl.d.ts +3 -1
- package/dist/instance/unsupported/UploadControl.d.ts +3 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
- package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
- package/dist/integration/xpath/adapter/kind.d.ts +32 -0
- package/dist/integration/xpath/adapter/names.d.ts +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/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 +3 -0
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
- package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -10
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
- package/dist/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +18 -7
- package/dist/parse/XFormDefinition.d.ts +1 -2
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/parse/body/BodyDefinition.d.ts +3 -3
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
- package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
- package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
- package/dist/parse/model/BindDefinition.d.ts +4 -5
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
- 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/parse/model/LeafNodeDefinition.d.ts +3 -1
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +2 -0
- package/dist/parse/model/NodeDefinition.d.ts +0 -1
- package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
- package/dist/parse/model/RootDefinition.d.ts +3 -2
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
- package/dist/solid.js +8174 -5921
- package/dist/solid.js.map +1 -1
- package/package.json +13 -11
- package/src/client/BaseNode.ts +16 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +30 -7
- package/src/client/NoteNode.ts +2 -2
- package/src/client/RootNode.ts +37 -7
- package/src/client/SelectNode.ts +3 -3
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +5 -5
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +12 -6
- 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/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 +10 -1
- 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 +24 -8
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +62 -134
- package/src/instance/SelectField.ts +56 -19
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/TriggerControl.ts +23 -6
- package/src/instance/abstract/DescendantNode.ts +90 -45
- package/src/instance/abstract/InstanceNode.ts +103 -105
- package/src/instance/abstract/UnsupportedControl.ts +28 -5
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +9 -10
- package/src/instance/hierarchy.ts +19 -15
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +25 -7
- package/src/instance/internal-api/EvaluationContext.ts +60 -13
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +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 +3 -4
- package/src/instance/internal-api/ValueContext.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +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 +50 -131
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +5 -1
- package/src/instance/unsupported/RankControl.ts +5 -1
- package/src/instance/unsupported/UploadControl.ts +5 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
- package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
- package/src/integration/xpath/adapter/kind.ts +114 -0
- package/src/integration/xpath/adapter/names.ts +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/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 +7 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +21 -21
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +62 -120
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/text/createTextRange.ts +4 -3
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/parse/XFormDOM.ts +110 -75
- package/src/parse/XFormDefinition.ts +1 -6
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +3 -3
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
- package/src/parse/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +5 -8
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/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/parse/model/LeafNodeDefinition.ts +4 -1
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +0 -3
- package/src/parse/model/NoteNodeDefinition.ts +3 -3
- package/src/parse/model/RootDefinition.ts +2 -1
- 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/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/client/StringNode.d.ts +0 -46
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/parse/XFormDataType.d.ts +0 -25
- package/src/client/StringNode.ts +0 -52
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/parse/XFormDataType.ts +0 -62
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AnyNodeDefinition } from '../parse/model/NodeDefinition.ts';
|
|
2
2
|
import { NodeAppearances } from './NodeAppearances.ts';
|
|
3
3
|
import { TextRange } from './TextRange.ts';
|
|
4
|
+
import { FormNodeID } from './identity.ts';
|
|
4
5
|
import { InstanceNodeType } from './node-types.ts';
|
|
6
|
+
import { SubmissionState } from './submission/SubmissionState.ts';
|
|
5
7
|
import { NodeValidationState } from './validation.ts';
|
|
6
8
|
export interface BaseNodeState {
|
|
7
9
|
/**
|
|
@@ -113,7 +115,6 @@ export interface BaseNodeState {
|
|
|
113
115
|
*/
|
|
114
116
|
get value(): unknown;
|
|
115
117
|
}
|
|
116
|
-
type FormNodeID = string;
|
|
117
118
|
/**
|
|
118
119
|
* Base interface for common/shared aspects of any node type.
|
|
119
120
|
*/
|
|
@@ -153,7 +154,7 @@ export interface BaseNode {
|
|
|
153
154
|
* Each node links back to its parent, if any. All nodes have a parent except
|
|
154
155
|
* the form's {@link root}.
|
|
155
156
|
*/
|
|
156
|
-
readonly parent:
|
|
157
|
+
readonly parent: unknown;
|
|
157
158
|
/**
|
|
158
159
|
* Each node provides a discrete object representing the stateful aspects\* of
|
|
159
160
|
* that node which will change over time. When a client provides a
|
|
@@ -205,5 +206,15 @@ export interface BaseNode {
|
|
|
205
206
|
* clients to explicitly pause and resume recomputation.
|
|
206
207
|
*/
|
|
207
208
|
readonly validationState: NodeValidationState;
|
|
209
|
+
/**
|
|
210
|
+
* Represents the current submission state of the node.
|
|
211
|
+
*
|
|
212
|
+
* @see {@link SubmissionState.submissionXML} for additional detail.
|
|
213
|
+
*
|
|
214
|
+
* @todo Consider whether this can (should) be merged with
|
|
215
|
+
* {@link currentState}, while providing the same client-reactivity
|
|
216
|
+
* guarantees. (The challenge there is in defining client-reactive state which
|
|
217
|
+
* self-referentially derives state from its own definition.)
|
|
218
|
+
*/
|
|
219
|
+
readonly submissionState: SubmissionState;
|
|
208
220
|
}
|
|
209
|
-
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
2
|
+
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
|
+
import { GeneralParentNode } from './hierarchy.ts';
|
|
4
|
+
import { LeafNodeType } from './node-types.ts';
|
|
5
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
6
|
+
import { ValueType } from './ValueType.ts';
|
|
7
|
+
export interface BaseValueNodeState<Value> extends BaseNodeState {
|
|
8
|
+
get children(): null;
|
|
9
|
+
get valueOptions(): null;
|
|
10
|
+
get value(): Value;
|
|
11
|
+
/**
|
|
12
|
+
* Reflects the serialized string representation of a {@link BaseValueNode}'s
|
|
13
|
+
* {@link value} state. This representation allows access to the node's value
|
|
14
|
+
* _as primary instance state_. In other words, this is the value which:
|
|
15
|
+
*
|
|
16
|
+
* - would be serialized as a text node in
|
|
17
|
+
* {@link SubmissionState.submissionXML} (note: this value is **NOT**
|
|
18
|
+
* escaped for XML serialization, as it is there)
|
|
19
|
+
*
|
|
20
|
+
* - is used when the node's value is referenced in any of a form's XPath
|
|
21
|
+
* expressions
|
|
22
|
+
*/
|
|
23
|
+
get instanceValue(): string;
|
|
24
|
+
}
|
|
25
|
+
export interface BaseValueNode<V extends ValueType = ValueType, Value = string> extends BaseNode {
|
|
26
|
+
readonly nodeType: LeafNodeType;
|
|
27
|
+
readonly valueType: V;
|
|
28
|
+
readonly definition: LeafNodeDefinition;
|
|
29
|
+
readonly parent: GeneralParentNode;
|
|
30
|
+
readonly currentState: BaseValueNodeState<Value>;
|
|
31
|
+
readonly validationState: LeafNodeValidationState;
|
|
32
|
+
}
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
+
import { MissingResourceBehavior } from './constants.ts';
|
|
1
2
|
import { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
2
|
-
|
|
3
|
-
* @todo this is currently a strict subset of the web standard `Response`. Is it
|
|
4
|
-
* sufficient? Ways it might not be:
|
|
5
|
-
*
|
|
6
|
-
* - No way to convey metadata about the resource
|
|
7
|
-
* - Ambiguous if a client supplies an alternative implementation which doesn't
|
|
8
|
-
* exhaust the body on access
|
|
9
|
-
*/
|
|
10
|
-
export interface FetchResourceResponse {
|
|
11
|
-
readonly ok?: boolean;
|
|
12
|
-
readonly body?: ReadableStream<Uint8Array> | null;
|
|
13
|
-
readonly bodyUsed?: boolean;
|
|
14
|
-
readonly blob: () => Promise<Blob>;
|
|
15
|
-
readonly text: () => Promise<string>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @todo this is a strict subset of the web standard `fetch` interface. It
|
|
19
|
-
* implicitly assumes that the engine itself will only ever issue `GET`-like
|
|
20
|
-
* requests. It also provides no further request-like semantics to the engine.
|
|
21
|
-
* This is presumed sufficient for now, but notably doesn't expose any notion of
|
|
22
|
-
* content negotiation (e.g. the ability to supply `Accept` headers).
|
|
23
|
-
*
|
|
24
|
-
* This also completely ignores any notion of mapping
|
|
25
|
-
* {@link https://getodk.github.io/xforms-spec/#uris | `jr:` URLs} to their
|
|
26
|
-
* actual resources (likely, but not necessarily, accessed at a corresponding
|
|
27
|
-
* HTTP URL).
|
|
28
|
-
*/
|
|
29
|
-
export type FetchResource = (resource: URL) => Promise<FetchResourceResponse>;
|
|
3
|
+
import { FetchFormAttachment, FetchResource } from './resources.ts';
|
|
30
4
|
/**
|
|
31
5
|
* Options provided by a client to specify certain aspects of engine runtime
|
|
32
6
|
* behavior. These options will generally be intended to facilitate cooperation
|
|
@@ -50,29 +24,56 @@ export interface EngineConfig {
|
|
|
50
24
|
*/
|
|
51
25
|
readonly stateFactory?: OpaqueReactiveObjectFactory;
|
|
52
26
|
/**
|
|
53
|
-
* A client may specify a generic function for retrieving resources referenced
|
|
54
|
-
* by a form, such as:
|
|
55
27
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
28
|
+
* A client may specify an arbitrary {@link fetch}-like function for retrieving an XML XForm form
|
|
29
|
+
* definition.
|
|
30
|
+
*
|
|
31
|
+
* Notes:
|
|
60
32
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
33
|
+
* - This configuration will only be consuled for calls to
|
|
34
|
+
* {@link initializeForm} with a URL referencing an XML XForm definition. It
|
|
35
|
+
* will be ignored for calls passing an XML XForm form definition directly.
|
|
64
36
|
*
|
|
65
|
-
* -
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
37
|
+
* - For calls to {@link initializeForm} with a URL, if this configuration is
|
|
38
|
+
* not specified it will default to the global {@link fetch} function (if
|
|
39
|
+
* one is defined).
|
|
40
|
+
*/
|
|
41
|
+
readonly fetchFormDefinition?: FetchResource;
|
|
42
|
+
/**
|
|
43
|
+
* A client may specify an arbitrary {@link fetch}-like function to retrieve a
|
|
44
|
+
* form's attachments, i.e. any `jr:` URL referenced by the form (as specified
|
|
45
|
+
* by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
|
|
46
|
+
*
|
|
47
|
+
* Notes:
|
|
48
|
+
*
|
|
49
|
+
* - This configuration will be consulted for all supported form attachments,
|
|
50
|
+
* as a part of {@link initializeForm | form initialization}.
|
|
51
|
+
*
|
|
52
|
+
* - If this configuration is not specified it will default to the global
|
|
53
|
+
* {@link fetch} function (if one is defined).
|
|
54
|
+
*
|
|
55
|
+
* This default behavior will typically result in failure to load form
|
|
56
|
+
* attachments—and in most cases this will also cause
|
|
57
|
+
* {@link initializeForm | form initialization} to fail overall—with the
|
|
58
|
+
* following exceptions:
|
|
59
|
+
*
|
|
60
|
+
* - **CLIENT-SPECIFIC:** Usage in coordination with a client-implemented
|
|
61
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Serivce Worker},
|
|
62
|
+
* which can intercept network requests **generally**. Clients already using
|
|
63
|
+
* a Service Worker may opt for the convenience of handling network requests
|
|
64
|
+
* for `jr:` URLs along with any other network interception logic. Client
|
|
65
|
+
* implementors should be warned, however, that such `jr:` URLs are not
|
|
66
|
+
* namespaced or otherwise scoped to a particular form; such a client would
|
|
67
|
+
* therefore inherently need to coordinate state between the Service Worker
|
|
68
|
+
* and the main thread (or whatever other realm calls
|
|
69
|
+
* {@link initializeForm}).
|
|
70
|
+
*/
|
|
71
|
+
readonly fetchFormAttachment?: FetchFormAttachment;
|
|
72
|
+
/**
|
|
73
|
+
* @see {@link MissingResourceBehavior}
|
|
74
|
+
* @see {@link MissingResourceBehaviorDefault}
|
|
69
75
|
*
|
|
70
|
-
*
|
|
71
|
-
* retrieve any such resource, as required for engine functionality. If
|
|
72
|
-
* absent, the engine will use the native `fetch` function (if available, a
|
|
73
|
-
* polyfill otherwise). Clients may use this function to provide resources
|
|
74
|
-
* from sources other than the network, (or even in a test client to provide
|
|
75
|
-
* e.g. resources from test fixtures).
|
|
76
|
+
* @default MissingResourceBehaviorDefault
|
|
76
77
|
*/
|
|
77
|
-
readonly
|
|
78
|
+
readonly missingResourceBehavior?: MissingResourceBehavior;
|
|
78
79
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
2
|
+
import { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
|
|
3
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
4
|
+
import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
5
|
+
import { NodeAppearances } from './NodeAppearances.ts';
|
|
6
|
+
import { RootNode } from './RootNode.ts';
|
|
7
|
+
import { ValueType } from './ValueType.ts';
|
|
8
|
+
import { GeneralParentNode } from './hierarchy.ts';
|
|
9
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
10
|
+
export type InputValue<V extends ValueType> = RuntimeValue<V>;
|
|
11
|
+
export type InputNodeInputValue<V extends ValueType> = RuntimeInputValue<V>;
|
|
12
|
+
export interface InputNodeState<V extends ValueType> extends BaseValueNodeState<InputValue<V>> {
|
|
13
|
+
get children(): null;
|
|
14
|
+
get valueOptions(): null;
|
|
15
|
+
/**
|
|
16
|
+
* Reflects the current value of a {@link InputNode}. This value may be
|
|
17
|
+
* populated when a form is loaded, and it may be updated by certain
|
|
18
|
+
* computations defined by the form. It may also be updated by a client, using
|
|
19
|
+
* the {@link InputNode.setValue} method.
|
|
20
|
+
*/
|
|
21
|
+
get value(): InputValue<V>;
|
|
22
|
+
}
|
|
23
|
+
export interface InputDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
24
|
+
readonly bodyElement: InputControlDefinition;
|
|
25
|
+
}
|
|
26
|
+
export type InputNodeAppearances = NodeAppearances<InputDefinition>;
|
|
27
|
+
/**
|
|
28
|
+
* A node corresponding to form field defined as an
|
|
29
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<input>`},
|
|
30
|
+
* which a user-facing client would likely present for a user to fill..
|
|
31
|
+
*/
|
|
32
|
+
export interface InputNode<V extends ValueType = ValueType> extends BaseValueNode<V, InputValue<V>> {
|
|
33
|
+
readonly nodeType: 'input';
|
|
34
|
+
readonly valueType: V;
|
|
35
|
+
readonly appearances: InputNodeAppearances;
|
|
36
|
+
readonly definition: InputDefinition<V>;
|
|
37
|
+
readonly root: RootNode;
|
|
38
|
+
readonly parent: GeneralParentNode;
|
|
39
|
+
readonly currentState: InputNodeState<V>;
|
|
40
|
+
readonly validationState: LeafNodeValidationState;
|
|
41
|
+
/**
|
|
42
|
+
* For use by a client to update the value of an {@link InputNode}.
|
|
43
|
+
*/
|
|
44
|
+
setValue(value: InputNodeInputValue<V>): RootNode;
|
|
45
|
+
}
|
|
46
|
+
export type StringInputNode = InputNode<'string'>;
|
|
47
|
+
export type IntInputNode = InputNode<'int'>;
|
|
48
|
+
export type DecimalInputNode = InputNode<'decimal'>;
|
|
49
|
+
type SupportedInputValueType = 'string' | 'int' | 'decimal';
|
|
50
|
+
type TemporaryStringValueType = Exclude<ValueType, SupportedInputValueType>;
|
|
51
|
+
export type TemporaryStringValueInputNode = InputNode<TemporaryStringValueType>;
|
|
52
|
+
export type AnyInputNode = StringInputNode | IntInputNode | DecimalInputNode | TemporaryStringValueInputNode;
|
|
53
|
+
export {};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
1
2
|
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
2
|
-
import {
|
|
3
|
+
import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
3
4
|
import { GeneralParentNode } from './hierarchy.ts';
|
|
4
5
|
import { RootNode } from './RootNode.ts';
|
|
5
6
|
import { LeafNodeValidationState } from './validation.ts';
|
|
6
|
-
|
|
7
|
+
import { ValueType } from './ValueType.ts';
|
|
8
|
+
export type ModelValue<V extends ValueType> = RuntimeValue<V>;
|
|
9
|
+
export interface ModelValueNodeState<V extends ValueType> extends BaseValueNodeState<ModelValue<V>> {
|
|
7
10
|
get label(): null;
|
|
8
11
|
get hint(): null;
|
|
9
12
|
get children(): null;
|
|
@@ -13,9 +16,9 @@ export interface ModelValueNodeState extends BaseNodeState {
|
|
|
13
16
|
* populated when a form is loaded, and it may be updated by certain
|
|
14
17
|
* computations defined by the form.
|
|
15
18
|
*/
|
|
16
|
-
get value():
|
|
19
|
+
get value(): ModelValue<V>;
|
|
17
20
|
}
|
|
18
|
-
export interface ModelValueDefinition extends LeafNodeDefinition {
|
|
21
|
+
export interface ModelValueDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
19
22
|
readonly bodyElement: null;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
@@ -25,12 +28,14 @@ export interface ModelValueDefinition extends LeafNodeDefinition {
|
|
|
25
28
|
* - a leaf/value node (i.e. it has no element children; it may be defined in
|
|
26
29
|
* the form's `<model>` as either an {@link Element} or {@link Attr})
|
|
27
30
|
*/
|
|
28
|
-
export interface ModelValueNode extends
|
|
31
|
+
export interface ModelValueNode<V extends ValueType = ValueType> extends BaseValueNode<V, ModelValue<V>> {
|
|
29
32
|
readonly nodeType: 'model-value';
|
|
33
|
+
readonly valueType: V;
|
|
30
34
|
readonly appearances: null;
|
|
31
|
-
readonly definition: ModelValueDefinition
|
|
35
|
+
readonly definition: ModelValueDefinition<V>;
|
|
32
36
|
readonly root: RootNode;
|
|
33
37
|
readonly parent: GeneralParentNode;
|
|
34
|
-
readonly currentState: ModelValueNodeState
|
|
38
|
+
readonly currentState: ModelValueNodeState<V>;
|
|
35
39
|
readonly validationState: LeafNodeValidationState;
|
|
36
40
|
}
|
|
41
|
+
export type AnyModelValueNode = ModelValueNode<'barcode'> | ModelValueNode<'binary'> | ModelValueNode<'boolean'> | ModelValueNode<'date'> | ModelValueNode<'dateTime'> | ModelValueNode<'decimal'> | ModelValueNode<'geopoint'> | ModelValueNode<'geoshape'> | ModelValueNode<'geotrace'> | ModelValueNode<'int'> | ModelValueNode<'intent'> | ModelValueNode<'string'> | ModelValueNode<'time'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
|
|
2
2
|
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
3
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import { GeneralParentNode } from './hierarchy.ts';
|
|
@@ -32,7 +32,7 @@ export interface NoteNodeState extends BaseNodeState {
|
|
|
32
32
|
get value(): string | null;
|
|
33
33
|
}
|
|
34
34
|
export interface NoteDefinition extends LeafNodeDefinition {
|
|
35
|
-
readonly bodyElement:
|
|
35
|
+
readonly bodyElement: InputControlDefinition;
|
|
36
36
|
}
|
|
37
37
|
export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
|
|
38
38
|
/**
|
|
@@ -3,13 +3,13 @@ import { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
|
3
3
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
|
|
5
5
|
import { GeneralChildNode } from './hierarchy.ts';
|
|
6
|
+
import { SubmissionChunkedType, SubmissionOptions } from './submission/SubmissionOptions.ts';
|
|
7
|
+
import { SubmissionResult } from './submission/SubmissionResult.ts';
|
|
6
8
|
import { AncestorNodeValidationState } from './validation.ts';
|
|
7
9
|
export interface RootNodeState extends BaseNodeState {
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
across all node types seems like a point of potential confusion, so this
|
|
12
|
-
particular divergence seems like the most reasonable compromise.
|
|
11
|
+
* @todo If we ever expose an interface to the primary instance document, it
|
|
12
|
+
* would make sense to move this state up.
|
|
13
13
|
*/
|
|
14
14
|
get activeLanguage(): ActiveLanguage;
|
|
15
15
|
get label(): null;
|
|
@@ -40,13 +40,40 @@ export interface RootNode extends BaseNode {
|
|
|
40
40
|
readonly classes: BodyClassList;
|
|
41
41
|
readonly definition: RootDefinition;
|
|
42
42
|
readonly root: RootNode;
|
|
43
|
-
readonly parent:
|
|
43
|
+
readonly parent: unknown;
|
|
44
44
|
readonly currentState: RootNodeState;
|
|
45
45
|
readonly validationState: AncestorNodeValidationState;
|
|
46
46
|
/**
|
|
47
|
-
* @todo as
|
|
48
|
-
* significant break in consistency across node types.
|
|
47
|
+
* @todo as discussed on {@link RootNodeState.activeLanguage}
|
|
49
48
|
*/
|
|
50
49
|
readonly languages: FormLanguages;
|
|
51
50
|
setLanguage(language: FormLanguage): RootNode;
|
|
51
|
+
/**
|
|
52
|
+
* Prepares the current form instance state for submission.
|
|
53
|
+
*
|
|
54
|
+
* A {@link SubmissionResult} will be prepared even if the current form state
|
|
55
|
+
* includes `constraint` or `required` violations. This is intended to serve
|
|
56
|
+
* two purposes:
|
|
57
|
+
*
|
|
58
|
+
* - A client may effectively use this method as a part of its own "submit"
|
|
59
|
+
* routine, and use any violations included in the {@link SubmissionResult}
|
|
60
|
+
* to prompt users to address those violations.
|
|
61
|
+
*
|
|
62
|
+
* - A client may inspect the submission state of a form at any time.
|
|
63
|
+
* Depending on the client and use case, this may be a convenience (e.g. for
|
|
64
|
+
* developers to inspect that form state at a current point in time); or it
|
|
65
|
+
* may provide necessary functionality (e.g. for test or tooling clients).
|
|
66
|
+
*
|
|
67
|
+
* Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
|
|
68
|
+
* a fast operation. It may even be nearly instantaneous, or roughly
|
|
69
|
+
* proportionate to the size of the form itself. However, this method is
|
|
70
|
+
* designed to be asynchronous out of an abundance of caution, anticipating
|
|
71
|
+
* that some as-yet undeveloped operations on binary data (e.g. form
|
|
72
|
+
* attachments) may themselves impose asynchrony (i.e. by interfaces provided
|
|
73
|
+
* by the platform and/or external dependencies).
|
|
74
|
+
*
|
|
75
|
+
* A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
|
|
76
|
+
* {@link SubmissionResult<'chunked'>} will be produced, with form attachments
|
|
77
|
+
*/
|
|
78
|
+
prepareSubmission<ChunkedType extends SubmissionChunkedType>(options?: SubmissionOptions<ChunkedType>): Promise<SubmissionResult<ChunkedType>>;
|
|
52
79
|
}
|
|
@@ -51,7 +51,7 @@ export interface SelectNode extends BaseNode {
|
|
|
51
51
|
* - For fields defined with an XForms `<select1>`, calling this method will
|
|
52
52
|
* replace the selection (if any).
|
|
53
53
|
*
|
|
54
|
-
* @todo @see {@link
|
|
54
|
+
* @todo @see {@link InputNode.setValue} re: write restrictions
|
|
55
55
|
* @todo @see {@link SelectNodeState.value} re: breaking up the types
|
|
56
56
|
*/
|
|
57
57
|
select(item: SelectItem): RootNode;
|
|
@@ -59,7 +59,7 @@ export interface SelectNode extends BaseNode {
|
|
|
59
59
|
* For use by a client to remove an item from the node's
|
|
60
60
|
* {@link SelectNodeState.value}.
|
|
61
61
|
*
|
|
62
|
-
* @todo @see {@link
|
|
62
|
+
* @todo @see {@link InputNode.setValue} re: write restrictions
|
|
63
63
|
*/
|
|
64
64
|
deselect(item: SelectItem): RootNode;
|
|
65
65
|
}
|
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
import { ValidationTextRole } from './TextRange.ts';
|
|
2
|
+
export declare const MISSING_RESOURCE_BEHAVIOR: {
|
|
3
|
+
/**
|
|
4
|
+
* When this behavior is configured, {@link InitializeForm | initializing} a
|
|
5
|
+
* {@link PrimaryInstance} for a form which references any **missing**
|
|
6
|
+
* resources will fail, producing an error to the calling client.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link MissingResourceBehavior}
|
|
9
|
+
*/
|
|
10
|
+
readonly ERROR: "ERROR";
|
|
11
|
+
/**
|
|
12
|
+
* When this behavior is configured, {@link InitializeForm | initializing} a
|
|
13
|
+
* {@link PrimaryInstance} for a form which references any **missing**
|
|
14
|
+
* resources will succeed (producing a warning).
|
|
15
|
+
*
|
|
16
|
+
* Such missing resources will be parsed as if they are blank, as appropriate
|
|
17
|
+
* for the resource's XForm semantic usage and/or format.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link MissingResourceBehavior}
|
|
20
|
+
*/
|
|
21
|
+
readonly BLANK: "BLANK";
|
|
22
|
+
/**
|
|
23
|
+
* @see {@link MISSING_RESOURCE_BEHAVIOR.ERROR}
|
|
24
|
+
*/
|
|
25
|
+
readonly DEFAULT: "ERROR";
|
|
26
|
+
};
|
|
27
|
+
export type MissingResourceBehaviorError = typeof MISSING_RESOURCE_BEHAVIOR.ERROR;
|
|
28
|
+
export type MissingResourceBehaviorBlank = typeof MISSING_RESOURCE_BEHAVIOR.BLANK;
|
|
29
|
+
export type MissingResourceBehaviorDefault = typeof MISSING_RESOURCE_BEHAVIOR.DEFAULT;
|
|
30
|
+
/**
|
|
31
|
+
* Specifies behavior for {@link InitializeForm | initializing} a form's
|
|
32
|
+
* {@link PrimaryInstance} which references any **missing** resources.
|
|
33
|
+
*
|
|
34
|
+
* Here the term "missing" is consistent with
|
|
35
|
+
* {@link https://www.rfc-editor.org/rfc/rfc9110#status.404 | HTTP 404 status}
|
|
36
|
+
* semantics. Clients which provide access to form attachments by performing
|
|
37
|
+
* HTTP network requests (e.g. with {@link fetch}) can generally convey this
|
|
38
|
+
* semantic meaning with a standard {@link Response}.
|
|
39
|
+
*
|
|
40
|
+
* **IMPORTANT**
|
|
41
|
+
*
|
|
42
|
+
* The term "missing" is distinct from other network/IO failures, e.g. when
|
|
43
|
+
* network access itself is unavailable. In these cases, the engine will
|
|
44
|
+
* consider a resource's availability **ambiguous**, producing an error
|
|
45
|
+
* regardless of the configured behavior for **missing** resources.
|
|
46
|
+
*/
|
|
47
|
+
export type MissingResourceBehavior = MissingResourceBehaviorError | MissingResourceBehaviorBlank;
|
|
2
48
|
export declare const VALIDATION_TEXT: {
|
|
3
49
|
readonly constraintMsg: "Condition not satisfied: constraint";
|
|
4
50
|
readonly requiredMsg: "Condition not satisfied: required";
|
|
5
51
|
};
|
|
6
52
|
type ValidationTextDefaults = typeof VALIDATION_TEXT;
|
|
7
53
|
export type ValidationTextDefault<Role extends ValidationTextRole> = ValidationTextDefaults[Role];
|
|
54
|
+
export declare const SUBMISSION_INSTANCE_FILE_NAME = "xml_submission_file";
|
|
55
|
+
export type SubmissionInstanceFileName = typeof SUBMISSION_INSTANCE_FILE_NAME;
|
|
56
|
+
export declare const SUBMISSION_INSTANCE_FILE_TYPE = "text/xml";
|
|
57
|
+
export type SubmissionInstanceFileType = typeof SUBMISSION_INSTANCE_FILE_TYPE;
|
|
8
58
|
export {};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { ExpandUnion } from '../../../common/types/helpers.d.ts';
|
|
2
2
|
import { GroupNode } from './GroupNode.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { AnyInputNode } from './InputNode.ts';
|
|
4
|
+
import { AnyModelValueNode } from './ModelValueNode.ts';
|
|
4
5
|
import { NoteNode } from './NoteNode.ts';
|
|
5
6
|
import { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
|
|
6
7
|
import { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
|
|
7
8
|
import { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
|
|
8
9
|
import { RootNode } from './RootNode.ts';
|
|
9
10
|
import { SelectNode } from './SelectNode.ts';
|
|
10
|
-
import { StringNode } from './StringNode.ts';
|
|
11
11
|
import { SubtreeNode } from './SubtreeNode.ts';
|
|
12
12
|
import { TriggerNode } from './TriggerNode.ts';
|
|
13
13
|
import { RangeNode } from './unsupported/RangeNode.ts';
|
|
14
14
|
import { RankNode } from './unsupported/RankNode.ts';
|
|
15
15
|
import { UploadNode } from './unsupported/UploadNode.ts';
|
|
16
16
|
export type AnyUnsupportedControlNode = RangeNode | RankNode | UploadNode;
|
|
17
|
-
export type AnyControlNode =
|
|
18
|
-
export type AnyLeafNode = AnyControlNode |
|
|
17
|
+
export type AnyControlNode = AnyInputNode | NoteNode | SelectNode | TriggerNode;
|
|
18
|
+
export type AnyLeafNode = AnyControlNode | AnyModelValueNode | AnyUnsupportedControlNode;
|
|
19
19
|
export type RepeatRangeNode = RepeatRangeControlledNode | RepeatRangeUncontrolledNode;
|
|
20
20
|
/**
|
|
21
21
|
* Any of the concrete node types which may be a parent of non-repeat instance
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ODKXFormsUUID = `uuid:${string}`;
|
|
2
|
+
/**
|
|
3
|
+
* @see {@link https://getodk.github.io/xforms-spec/#metadata}
|
|
4
|
+
*/
|
|
5
|
+
export type InstanceID = ODKXFormsUUID;
|
|
6
|
+
/**
|
|
7
|
+
* @see {@link https://getodk.github.io/xforms-spec/#metadata}
|
|
8
|
+
*/
|
|
9
|
+
export type DeprecatedID = ODKXFormsUUID;
|
|
10
|
+
/**
|
|
11
|
+
* Represents a session-stable identifier for any particular node i
|
|
12
|
+
*/
|
|
13
|
+
export type FormNodeID = `node:${string}`;
|
|
14
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type UnsupportedControlNodeType = 'range' | 'rank' | 'upload';
|
|
2
2
|
export type RepeatRangeNodeType = 'repeat-range:controlled' | 'repeat-range:uncontrolled';
|
|
3
|
-
export type
|
|
3
|
+
export type LeafNodeType = 'model-value' | 'note' | 'select' | 'input' | 'trigger' | UnsupportedControlNodeType;
|
|
4
|
+
export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | 'subtree' | LeafNodeType | UnsupportedControlNodeType;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { JRResourceURL } from '../../../common/src/jr-resources/JRResourceURL.ts';
|
|
2
|
+
interface FetchResourceHeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
|
3
|
+
[Symbol.iterator](): FetchResourceHeadersIterator<T>;
|
|
4
|
+
}
|
|
5
|
+
type FetchResourceHeadersForEachCallbackFn = (value: string, key: string, parent: FetchResourceResponseHeaders) => void;
|
|
6
|
+
/**
|
|
7
|
+
* A read-only strict subset of the web standard {@link Headers}.
|
|
8
|
+
*
|
|
9
|
+
* Note that the engine may make the following assumptions about
|
|
10
|
+
* {@link FetchResourceResponse.headers}:
|
|
11
|
+
*
|
|
12
|
+
* - If {@link FetchResourceResponse} is an instance of {@link Response}, it
|
|
13
|
+
* will be assumed its {@link FetchResourceResponse.headers | headers object}
|
|
14
|
+
* _is present_, and that it is an instance of {@link Headers}. In other
|
|
15
|
+
* words: for the purposes of resource resolution, we explicitly expect that
|
|
16
|
+
* clients using APIs provided by the runtime platform (or polyfills thereof)
|
|
17
|
+
* will not monkey-patch properties of values produced by those APIs.
|
|
18
|
+
*
|
|
19
|
+
* - If the object is an instance of {@link Headers} (whether by inference as a
|
|
20
|
+
* property of {@link Response}, or by a direct instance type check), the
|
|
21
|
+
* engine will assume it is safe to treat header names as case insensitive for
|
|
22
|
+
* any lookups it may perform. In other words: we explicitly expect that
|
|
23
|
+
* clients _providing access_ to APIs rovided by the runtime platform (or
|
|
24
|
+
* polyfills thereof) will not alter the guarantees of those APIs.
|
|
25
|
+
*
|
|
26
|
+
* - If the object is not an instance of {@link Headers}, it will be treated as
|
|
27
|
+
* a {@link ReadonlyMap<string, string>}. In other words: we explicitly expect
|
|
28
|
+
* that clients, when providing a bespoke implementation of
|
|
29
|
+
* {@link FetchResourceResponse} and its constituent parts, will likely
|
|
30
|
+
* implement them partially (and in the case of
|
|
31
|
+
* {@link FetchResourceResponse.headers}, with the nearest common idiom
|
|
32
|
+
* available). In this case, we will favor a best effort at correctness,
|
|
33
|
+
* generally at some expense of performance.
|
|
34
|
+
*/
|
|
35
|
+
export interface FetchResourceResponseHeaders {
|
|
36
|
+
[Symbol.iterator](): FetchResourceHeadersIterator<[string, string]>;
|
|
37
|
+
entries(): FetchResourceHeadersIterator<[string, string]>;
|
|
38
|
+
keys(): FetchResourceHeadersIterator<string>;
|
|
39
|
+
values(): FetchResourceHeadersIterator<string>;
|
|
40
|
+
get(name: string): string | null;
|
|
41
|
+
has(name: string): boolean;
|
|
42
|
+
forEach(callbackfn: FetchResourceHeadersForEachCallbackFn): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* This is a strict subset of the web standard {@link Response}. Clients are
|
|
46
|
+
* encouraged to use the global {@link Response} constructor (as provided by the
|
|
47
|
+
* runtime platform, or by a global runtime polyfill), but may also provide a
|
|
48
|
+
* bespoke implementation if it suits their needs.
|
|
49
|
+
*
|
|
50
|
+
* Since we cannot assume a client's implementation will always be an instance
|
|
51
|
+
* of {@link Response}, we make some assumptions about its {@link headers}
|
|
52
|
+
* object (if available, as detailed on {@link FetchResourceResponseHeaders}).
|
|
53
|
+
*
|
|
54
|
+
* For other properties, we make the following assumptions (all of which are
|
|
55
|
+
* assumptions we would make about a platform-provided/polyfilled
|
|
56
|
+
* {@link Response}, but are explicitly stated for the benefit of confidence in
|
|
57
|
+
* client implementations):
|
|
58
|
+
*
|
|
59
|
+
* - If we read {@link body} directly, we will assume it is consumed on first
|
|
60
|
+
* read, and will not read it again.
|
|
61
|
+
*
|
|
62
|
+
* - We assume that {@link blob} and {@link text} indirectly consume
|
|
63
|
+
* {@link body} on first read as well, and will only ever read one of each of
|
|
64
|
+
* these properties, and only ever once.
|
|
65
|
+
*
|
|
66
|
+
* Furthermore, if the engine intends to read {@link body} (or its indirect
|
|
67
|
+
* {@link blob} or {@link text} consumers), it will do so in the course of a
|
|
68
|
+
* client's call to {@link initializeForm}, and before the
|
|
69
|
+
* {@link Promise<PrimaryInstance>} returned by that call is resolved.
|
|
70
|
+
*/
|
|
71
|
+
export interface FetchResourceResponse {
|
|
72
|
+
readonly ok?: boolean;
|
|
73
|
+
readonly status?: number;
|
|
74
|
+
readonly body?: ReadableStream<Uint8Array> | null;
|
|
75
|
+
readonly bodyUsed?: boolean;
|
|
76
|
+
readonly headers?: FetchResourceResponseHeaders;
|
|
77
|
+
readonly blob: () => Promise<Blob>;
|
|
78
|
+
readonly text: () => Promise<string>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* This is a strict subset of the web standard `fetch` interface. It implicitly
|
|
82
|
+
* assumes that the engine itself will only ever perform `GET`-like network/IO
|
|
83
|
+
* requests. It also provides no further request-like semantics to the engine.
|
|
84
|
+
*
|
|
85
|
+
* This is presumed sufficient for now, but notably doesn't expose any notion of
|
|
86
|
+
* content negotiation (e.g. the ability for the engine to include `Accept`
|
|
87
|
+
* headers in resource requests issued to a client's {@link FetchResource}
|
|
88
|
+
* implementation).
|
|
89
|
+
*/
|
|
90
|
+
export type FetchResource<Resource extends URL = URL> = (resource: Resource) => Promise<FetchResourceResponse>;
|
|
91
|
+
export type FormAttachmentURL = JRResourceURL;
|
|
92
|
+
export type FetchFormAttachment = FetchResource<FormAttachmentURL>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SubmissionInstanceFile, SubmissionInstanceFileName } from './SubmissionInstanceFile.ts';
|
|
2
|
+
export interface SubmissionData extends FormData {
|
|
3
|
+
get(name: SubmissionInstanceFileName): SubmissionInstanceFile;
|
|
4
|
+
get(name: string): FormDataEntryValue | null;
|
|
5
|
+
has(name: SubmissionInstanceFileName): true;
|
|
6
|
+
has(name: string): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SubmissionDefinition {
|
|
2
|
+
/**
|
|
3
|
+
* @see {@link https://getodk.github.io/xforms-spec/#submission-attributes | `action` submission attribute}
|
|
4
|
+
*/
|
|
5
|
+
readonly submissionAction: URL | null;
|
|
6
|
+
/**
|
|
7
|
+
* @see {@link https://getodk.github.io/xforms-spec/#submission-attributes | `method` submission attribute}
|
|
8
|
+
*/
|
|
9
|
+
readonly submissionMethod: 'post';
|
|
10
|
+
/**
|
|
11
|
+
* @see {@link https://getodk.github.io/xforms-spec/#submission-attributes | `base64RsaPublicKey` submission attribute}
|
|
12
|
+
*/
|
|
13
|
+
readonly encryptionKey: string | null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SubmissionInstanceFileName, SubmissionInstanceFileType } from '../constants.ts';
|
|
2
|
+
export type { SubmissionInstanceFileName, SubmissionInstanceFileType };
|
|
3
|
+
export interface SubmissionInstanceFile extends File {
|
|
4
|
+
readonly name: SubmissionInstanceFileName;
|
|
5
|
+
readonly type: SubmissionInstanceFileType;
|
|
6
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type SubmissionChunkedType = 'chunked' | 'monolithic';
|
|
2
|
+
interface BaseSubmissionOptions<ChunkedType extends SubmissionChunkedType> {
|
|
3
|
+
readonly chunked?: ChunkedType | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* As described in the
|
|
6
|
+
* {@link https://docs.getodk.org/openrosa-form-submission/#extended-transmission-considerations | OpenRosa Form Submission API},
|
|
7
|
+
* clients may obtain this value from an OpenRosa server's
|
|
8
|
+
* `X-OpenRosa-Accept-Content-Length` header.
|
|
9
|
+
*/
|
|
10
|
+
readonly maxSize?: number;
|
|
11
|
+
}
|
|
12
|
+
interface ChunkedSubmissionOptions extends BaseSubmissionOptions<'chunked'> {
|
|
13
|
+
readonly maxSize: number;
|
|
14
|
+
}
|
|
15
|
+
interface MonolithicSubmissionOptions extends BaseSubmissionOptions<'monolithic'> {
|
|
16
|
+
readonly chunked?: 'monolithic' | undefined;
|
|
17
|
+
readonly maxSize?: never;
|
|
18
|
+
}
|
|
19
|
+
export type SubmissionOptions<ChunkedType extends SubmissionChunkedType = 'monolithic'> = {
|
|
20
|
+
chunked: ChunkedSubmissionOptions;
|
|
21
|
+
monolithic: MonolithicSubmissionOptions;
|
|
22
|
+
}[ChunkedType];
|
|
23
|
+
export {};
|