@getodk/xforms-engine 0.6.0 → 0.8.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 +4 -4
- package/dist/client/BaseValueNode.d.ts +7 -3
- package/dist/client/RootNode.d.ts +20 -16
- package/dist/client/UploadNode.d.ts +53 -0
- package/dist/client/attachments/InstanceAttachmentMeta.d.ts +8 -0
- package/dist/client/attachments/InstanceAttachmentsConfig.d.ts +8 -0
- package/dist/client/constants.d.ts +11 -12
- package/dist/client/form/CreateFormInstance.d.ts +14 -0
- package/dist/client/form/EditFormInstance.d.ts +62 -0
- package/dist/client/form/FormInstance.d.ts +104 -0
- package/dist/client/form/FormInstanceConfig.d.ts +19 -0
- package/dist/client/form/FormResource.d.ts +1 -0
- package/dist/client/form/LoadForm.d.ts +79 -0
- package/dist/client/form/LoadFormResult.d.ts +67 -0
- package/dist/client/form/RestoreFormInstance.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +4 -5
- package/dist/client/index.d.ts +40 -11
- package/dist/client/node-types.d.ts +2 -3
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +3 -4
- package/dist/client/repeat/RepeatInstanceNode.d.ts +4 -5
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +2 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +2 -2
- package/dist/client/resources.d.ts +1 -1
- package/dist/client/serialization/InstanceData.d.ts +14 -0
- package/dist/client/serialization/InstanceFile.d.ts +6 -0
- package/dist/client/serialization/InstancePayload.d.ts +93 -0
- package/dist/client/serialization/InstancePayloadOptions.d.ts +24 -0
- package/dist/client/serialization/InstanceState.d.ts +12 -0
- package/dist/client/submission/{SubmissionDefinition.d.ts → SubmissionMeta.d.ts} +1 -1
- package/dist/entrypoints/FormInstance.d.ts +20 -0
- package/dist/entrypoints/FormResult/BaseFormResult.d.ts +22 -0
- package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +25 -0
- package/dist/entrypoints/FormResult/FormFailureResult.d.ts +17 -0
- package/dist/entrypoints/FormResult/FormSuccessResult.d.ts +15 -0
- package/dist/entrypoints/FormResult/FormWarningResult.d.ts +15 -0
- package/dist/entrypoints/createInstance.d.ts +9 -0
- package/dist/entrypoints/editInstance.d.ts +9 -0
- package/dist/entrypoints/index.d.ts +4 -0
- package/dist/entrypoints/loadForm.d.ts +4 -0
- package/dist/entrypoints/restoreInstance.d.ts +9 -0
- package/dist/error/LoadFormFailureError.d.ts +9 -0
- package/dist/error/MalformedInstanceDataError.d.ts +3 -0
- package/dist/error/TemplatedNodeAttributeSerializationError.d.ts +22 -0
- package/dist/error/UploadValueTypeError.d.ts +8 -0
- package/dist/index.d.ts +2 -33
- package/dist/index.js +8280 -6779
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +6 -5
- package/dist/instance/InputControl.d.ts +5 -4
- package/dist/instance/ModelValue.d.ts +5 -4
- package/dist/instance/Note.d.ts +4 -3
- package/dist/instance/PrimaryInstance.d.ts +34 -8
- package/dist/instance/RangeControl.d.ts +5 -4
- package/dist/instance/RankControl.d.ts +6 -5
- package/dist/instance/Root.d.ts +7 -9
- package/dist/instance/SelectControl.d.ts +4 -3
- package/dist/instance/Subtree.d.ts +6 -5
- package/dist/instance/TriggerControl.d.ts +4 -3
- package/dist/instance/UploadControl.d.ts +58 -0
- package/dist/instance/abstract/DescendantNode.d.ts +10 -1
- package/dist/instance/abstract/InstanceNode.d.ts +7 -4
- package/dist/instance/abstract/ValueNode.d.ts +7 -5
- package/dist/instance/attachments/InstanceAttachment.d.ts +42 -0
- package/dist/instance/attachments/InstanceAttachmentsState.d.ts +9 -0
- package/dist/instance/children/DescendantNodeInitOptions.d.ts +32 -0
- package/dist/instance/{children.d.ts → children/buildChildren.d.ts} +1 -1
- package/dist/instance/children/childrenInitOptions.d.ts +9 -0
- package/dist/instance/children/normalizeChildInitOptions.d.ts +2 -0
- package/dist/instance/hierarchy.d.ts +6 -7
- package/dist/instance/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceAttachmentContext.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +4 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +8 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +16 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.d.ts +32 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +13 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableValueNode.d.ts +21 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +10 -8
- package/dist/instance/repeat/RepeatInstance.d.ts +10 -7
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +27 -3
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +4 -3
- package/dist/instance/resource.d.ts +5 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +2 -2
- package/dist/integration/xpath/adapter/kind.d.ts +4 -10
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +4 -5
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +13 -10
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +21 -22
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +1 -1
- package/dist/integration/xpath/static-dom/StaticParentNode.d.ts +13 -0
- package/dist/integration/xpath/static-dom/staticNodeName.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createNodeRangeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createParentNodeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createPrimaryInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createRootInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +6 -0
- package/dist/lib/client-reactivity/instance-state/createValueNodeInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/prepareInstancePayload.d.ts +8 -0
- package/dist/lib/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/reactivity/createInstanceAttachment.d.ts +8 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/lib/resource-helpers.d.ts +2 -0
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -1
- package/dist/parse/body/control/UploadControlDefinition.d.ts +2 -0
- package/dist/parse/model/BindDefinition.d.ts +1 -1
- package/dist/parse/model/BindTypeDefinition.d.ts +2 -7
- package/dist/parse/model/ItextTranslationsDefinition.d.ts +18 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +4 -5
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +9 -2
- package/dist/parse/model/NodeDefinition.d.ts +18 -30
- package/dist/parse/model/NoteNodeDefinition.d.ts +3 -2
- package/dist/parse/model/RangeNodeDefinition.d.ts +2 -1
- package/dist/parse/model/RepeatDefinition.d.ts +62 -0
- package/dist/parse/model/RootAttributeDefinition.d.ts +1 -4
- package/dist/parse/model/RootAttributeMap.d.ts +2 -1
- package/dist/parse/model/RootDefinition.d.ts +7 -8
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +15 -2
- package/dist/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/defineSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +1 -7
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/{FormSubmissionDefinition.d.ts → SubmissionDefinition.d.ts} +2 -2
- package/dist/parse/model/SubtreeDefinition.d.ts +4 -5
- package/dist/parse/model/nodeDefinitionMap.d.ts +5 -0
- package/dist/parse/shared/parseInstanceXML.d.ts +21 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +4 -21
- package/dist/solid.js +8251 -6751
- package/dist/solid.js.map +1 -1
- package/package.json +15 -14
- package/src/client/BaseNode.ts +4 -4
- package/src/client/BaseValueNode.ts +7 -3
- package/src/client/RootNode.ts +32 -19
- package/src/client/UploadNode.ts +78 -0
- package/src/client/attachments/InstanceAttachmentMeta.ts +10 -0
- package/src/client/attachments/InstanceAttachmentsConfig.ts +13 -0
- package/src/client/constants.ts +12 -14
- package/src/client/form/CreateFormInstance.ts +19 -0
- package/src/client/form/EditFormInstance.ts +93 -0
- package/src/client/form/FormInstance.ts +114 -0
- package/src/client/form/FormInstanceConfig.ts +21 -0
- package/src/client/form/FormResource.ts +1 -0
- package/src/client/form/LoadForm.ts +92 -0
- package/src/client/form/LoadFormResult.ts +103 -0
- package/src/client/form/RestoreFormInstance.ts +14 -0
- package/src/client/hierarchy.ts +5 -8
- package/src/client/index.ts +49 -29
- package/src/client/node-types.ts +3 -8
- package/src/client/repeat/BaseRepeatRangeNode.ts +3 -4
- package/src/client/repeat/RepeatInstanceNode.ts +4 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +2 -2
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +2 -2
- package/src/client/resources.ts +2 -2
- package/src/client/serialization/InstanceData.ts +24 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +29 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/entrypoints/FormInstance.ts +56 -0
- package/src/entrypoints/FormResult/BaseFormResult.ts +40 -0
- package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +109 -0
- package/src/entrypoints/FormResult/FormFailureResult.ts +44 -0
- package/src/entrypoints/FormResult/FormSuccessResult.ts +25 -0
- package/src/entrypoints/FormResult/FormWarningResult.ts +25 -0
- package/src/entrypoints/createInstance.ts +23 -0
- package/src/entrypoints/editInstance.ts +24 -0
- package/src/entrypoints/index.ts +4 -0
- package/src/entrypoints/loadForm.ts +154 -0
- package/src/entrypoints/restoreInstance.ts +27 -0
- package/src/error/LoadFormFailureError.ts +114 -0
- package/src/error/MalformedInstanceDataError.ts +3 -0
- package/src/error/TemplatedNodeAttributeSerializationError.ts +24 -0
- package/src/error/UploadValueTypeError.ts +13 -0
- package/src/index.ts +2 -46
- package/src/instance/Group.ts +16 -15
- package/src/instance/InputControl.ts +17 -11
- package/src/instance/ModelValue.ts +17 -11
- package/src/instance/Note.ts +10 -9
- package/src/instance/PrimaryInstance.ts +68 -31
- package/src/instance/RangeControl.ts +17 -11
- package/src/instance/RankControl.ts +28 -19
- package/src/instance/Root.ts +20 -31
- package/src/instance/SelectControl.ts +21 -12
- package/src/instance/Subtree.ts +16 -15
- package/src/instance/TriggerControl.ts +21 -12
- package/src/instance/UploadControl.ts +184 -0
- package/src/instance/abstract/DescendantNode.ts +12 -2
- package/src/instance/abstract/InstanceNode.ts +9 -5
- package/src/instance/abstract/ValueNode.ts +11 -13
- package/src/instance/attachments/InstanceAttachment.ts +69 -0
- package/src/instance/attachments/InstanceAttachmentsState.ts +18 -0
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/{children.ts → children/buildChildren.ts} +57 -53
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/hierarchy.ts +6 -9
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +154 -0
- package/src/instance/internal-api/InstanceAttachmentContext.ts +20 -0
- package/src/instance/internal-api/InstanceConfig.ts +6 -10
- package/src/instance/internal-api/InstanceValueContext.ts +9 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +22 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.ts +43 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +26 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +24 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableValueNode.ts +28 -0
- package/src/instance/repeat/BaseRepeatRange.ts +19 -24
- package/src/instance/repeat/RepeatInstance.ts +26 -19
- package/src/instance/repeat/RepeatRangeControlled.ts +90 -17
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +10 -9
- package/src/instance/resource.ts +14 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +2 -2
- package/src/integration/xpath/adapter/kind.ts +1 -28
- package/src/integration/xpath/adapter/traversal.ts +2 -2
- package/src/integration/xpath/static-dom/StaticAttribute.ts +6 -5
- package/src/integration/xpath/static-dom/StaticDocument.ts +17 -16
- package/src/integration/xpath/static-dom/StaticElement.ts +196 -50
- package/src/integration/xpath/static-dom/StaticNode.ts +1 -1
- package/src/integration/xpath/static-dom/StaticParentNode.ts +22 -0
- package/src/integration/xpath/static-dom/staticNodeName.ts +20 -0
- package/src/lib/client-reactivity/instance-state/createNodeRangeInstanceState.ts +17 -0
- package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +22 -0
- package/src/lib/client-reactivity/instance-state/createPrimaryInstanceState.ts +12 -0
- package/src/lib/client-reactivity/{submission/createRootSubmissionState.ts → instance-state/createRootInstanceState.ts} +4 -4
- package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +31 -0
- package/src/lib/client-reactivity/instance-state/createValueNodeInstanceState.ts +21 -0
- package/src/lib/client-reactivity/instance-state/prepareInstancePayload.ts +237 -0
- package/src/lib/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/reactivity/createInstanceAttachment.ts +212 -0
- package/src/lib/reactivity/createInstanceValueState.ts +27 -51
- package/src/lib/resource-helpers.ts +33 -0
- package/src/parse/XFormDOM.ts +1 -3
- package/src/parse/body/BodyDefinition.ts +4 -0
- package/src/parse/body/control/UploadControlDefinition.ts +42 -0
- package/src/parse/model/BindDefinition.ts +1 -1
- package/src/parse/model/BindTypeDefinition.ts +68 -26
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +3 -5
- package/src/parse/model/ModelBindMap.ts +0 -5
- package/src/parse/model/ModelDefinition.ts +36 -3
- package/src/parse/model/NodeDefinition.ts +19 -45
- package/src/parse/model/NoteNodeDefinition.ts +4 -3
- package/src/parse/model/RangeNodeDefinition.ts +3 -2
- package/src/parse/model/RepeatDefinition.ts +382 -0
- package/src/parse/model/RootAttributeDefinition.ts +6 -7
- package/src/parse/model/RootAttributeMap.ts +15 -10
- package/src/parse/model/RootDefinition.ts +17 -19
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +23 -2
- package/src/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.ts +14 -0
- package/src/parse/model/SecondaryInstance/defineSecondaryInstance.ts +32 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +3 -24
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +33 -86
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +1 -30
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +64 -137
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +9 -7
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +1 -1
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +7 -7
- package/src/parse/model/{FormSubmissionDefinition.ts → SubmissionDefinition.ts} +2 -2
- package/src/parse/model/SubtreeDefinition.ts +4 -5
- package/src/parse/model/nodeDefinitionMap.ts +34 -0
- package/src/parse/shared/parseInstanceXML.ts +79 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +45 -130
- package/dist/client/EngineConfig.d.ts +0 -79
- package/dist/client/submission/SubmissionData.d.ts +0 -7
- package/dist/client/submission/SubmissionInstanceFile.d.ts +0 -6
- package/dist/client/submission/SubmissionOptions.d.ts +0 -23
- package/dist/client/submission/SubmissionResult.d.ts +0 -91
- package/dist/client/submission/SubmissionState.d.ts +0 -12
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +0 -30
- package/dist/client/unsupported/UploadNode.d.ts +0 -9
- package/dist/instance/abstract/UnsupportedControl.d.ts +0 -54
- package/dist/instance/index.d.ts +0 -8
- package/dist/instance/internal-api/ValueContext.d.ts +0 -23
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +0 -14
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +0 -32
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +0 -19
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +0 -18
- package/dist/instance/unsupported/UploadControl.d.ts +0 -6
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +0 -8
- package/dist/lib/reactivity/createValueState.d.ts +0 -40
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +0 -4
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +0 -9
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +0 -8
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +0 -17
- package/dist/parse/model/RepeatRangeDefinition.d.ts +0 -32
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +0 -31
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +0 -4
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +0 -7
- package/src/client/EngineConfig.ts +0 -84
- package/src/client/submission/SubmissionData.ts +0 -12
- package/src/client/submission/SubmissionInstanceFile.ts +0 -9
- package/src/client/submission/SubmissionOptions.ts +0 -28
- package/src/client/submission/SubmissionResult.ts +0 -124
- package/src/client/submission/SubmissionState.ts +0 -14
- package/src/client/unsupported/UnsupportedControlNode.ts +0 -36
- package/src/client/unsupported/UploadNode.ts +0 -14
- package/src/instance/abstract/UnsupportedControl.ts +0 -175
- package/src/instance/index.ts +0 -55
- package/src/instance/internal-api/ValueContext.ts +0 -28
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +0 -20
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +0 -43
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +0 -26
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +0 -24
- package/src/instance/unsupported/UploadControl.ts +0 -9
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +0 -12
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +0 -20
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +0 -17
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +0 -22
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +0 -21
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +0 -172
- package/src/lib/reactivity/createValueState.ts +0 -200
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +0 -4
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +0 -42
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +0 -31
- package/src/parse/model/RepeatInstanceDefinition.ts +0 -38
- package/src/parse/model/RepeatRangeDefinition.ts +0 -98
- package/src/parse/model/RepeatTemplateDefinition.ts +0 -149
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +0 -4
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +0 -12
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { loadForm } from '../../entrypoints/loadForm.ts';
|
|
2
|
+
import type { MissingResourceBehavior } from '../constants.ts';
|
|
3
|
+
import type { FetchFormAttachment, FetchResource } from '../resources.ts';
|
|
4
|
+
import type { FormResource } from './FormResource.ts';
|
|
5
|
+
import type { LoadFormFailureResult, LoadFormResult } from './LoadFormResult.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see {@link LoadForm}
|
|
9
|
+
*/
|
|
10
|
+
export interface FormLoadPromise<T> extends PromiseLike<T> {}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Any fetch-like {@link LoadFormOptions | form loading options} which are not
|
|
14
|
+
* provided will default to the global {@link fetch} function, if one is
|
|
15
|
+
* available in the calling environment. If a global {@link fetch} function is
|
|
16
|
+
* _is not available_, and if the associated form loading option is required for
|
|
17
|
+
* the provided {@link FormResource} to be loaded, a
|
|
18
|
+
* {@link LoadFormFailureResult} will be produced.
|
|
19
|
+
*/
|
|
20
|
+
export type GlobalFetchDefault = typeof fetch;
|
|
21
|
+
|
|
22
|
+
export interface LoadFormOptions {
|
|
23
|
+
/**
|
|
24
|
+
* A client may specify an arbitrary {@link fetch}-like function for
|
|
25
|
+
* retrieving an XML XForm form definition.
|
|
26
|
+
*
|
|
27
|
+
* Calls to {@link loadForm | load a form} from a form definition provided as
|
|
28
|
+
* either a raw XML string or {@link Blob} data containing an XML string, this
|
|
29
|
+
* option will be ignored.
|
|
30
|
+
*
|
|
31
|
+
* Calls to load a form by {@link URL} will consult this option, if defined.
|
|
32
|
+
*
|
|
33
|
+
* If this option is omitted, loading a form by URL will use the
|
|
34
|
+
* {@link GlobalFetchDefault | global fetch function} by default.
|
|
35
|
+
*/
|
|
36
|
+
readonly fetchFormDefinition?: FetchResource;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A client may specify an arbitrary {@link fetch}-like function to retrieve a
|
|
40
|
+
* form's attachments, i.e. any `jr:` URL referenced by the form (as specified
|
|
41
|
+
* by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
|
|
42
|
+
*
|
|
43
|
+
* As part of {@link loadForm | loading a form}, once the form definition
|
|
44
|
+
* itself is resolved, this option (if provided) will be consulted to load any
|
|
45
|
+
* form attachments referenced by the form definition.
|
|
46
|
+
*
|
|
47
|
+
* If this option is omitted, the engine will attempt to load form attachments
|
|
48
|
+
* by calling the {@link GlobalFetchDefault | global fetch function} with each
|
|
49
|
+
* attachment's `jr:` URL. This default behavior will typically result in
|
|
50
|
+
* failure to load form attachments—and in most cases this will in most cases
|
|
51
|
+
* cause {@link loadForm | loading a form} to produce a
|
|
52
|
+
* {@link LoadFormFailureResult}, with the following exception:
|
|
53
|
+
*
|
|
54
|
+
* Clients implementing a
|
|
55
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Service Worker}
|
|
56
|
+
* (e.g. supporting offline functionality, or any other use case for
|
|
57
|
+
* intercepting network requests) may opt for the convenience of handling
|
|
58
|
+
* network requests _for form attachments' `jr:` URLs_ along with any other
|
|
59
|
+
* network interception logic. Client implementors should be warned, however,
|
|
60
|
+
* that such `jr:` URLs are not namespaced or otherwise scoped to a particular
|
|
61
|
+
* form definition! Such a client would therefore inherently need to
|
|
62
|
+
* coordinate state between the Service Worker and the main thread (or
|
|
63
|
+
* whatever other realm calls {@link loadForm}).
|
|
64
|
+
*
|
|
65
|
+
* @todo We can almost certainly address the scoping caveat! We'll probably
|
|
66
|
+
* want to design for that as part of offline support.
|
|
67
|
+
*/
|
|
68
|
+
// TODO (internal): Also note that the current round of revisions to
|
|
69
|
+
// engine/client entrypoints are not directly designed to address the above
|
|
70
|
+
// `@todo`, but the offline use case in particular is very much in mind for
|
|
71
|
+
// these interface changes!
|
|
72
|
+
readonly fetchFormAttachment?: FetchFormAttachment;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @see {@link MissingResourceBehavior}
|
|
76
|
+
* @see {@link MissingResourceBehaviorDefault}
|
|
77
|
+
*
|
|
78
|
+
* @default MissingResourceBehaviorDefault
|
|
79
|
+
*/
|
|
80
|
+
readonly missingResourceBehavior?: MissingResourceBehavior;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Note: loading a form produce a {@link Promise} which **will never reject**.
|
|
85
|
+
* Rather than rejecting, any errors encountered in the process of loading a
|
|
86
|
+
* form will be **resolved**, in a
|
|
87
|
+
* {@link LoadFormFailureResult.error | FormLoadFailureResult error}.
|
|
88
|
+
*/
|
|
89
|
+
export type LoadForm = (
|
|
90
|
+
formResource: FormResource,
|
|
91
|
+
options?: LoadFormOptions
|
|
92
|
+
) => FormLoadPromise<LoadFormResult>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { UnknownObject } from '@getodk/common/lib/type-assertions/assertUnknownObject.ts';
|
|
2
|
+
import type { AnyFunction } from '@getodk/common/types/helpers.js';
|
|
3
|
+
import type { LoadFormFailureError } from '../../error/LoadFormFailureError.ts';
|
|
4
|
+
import type { CreateFormInstance } from './CreateFormInstance.ts';
|
|
5
|
+
import type { EditFormInstance } from './EditFormInstance.ts';
|
|
6
|
+
import type { RestoreFormInstance } from './RestoreFormInstance.ts';
|
|
7
|
+
|
|
8
|
+
// Re-export for client access
|
|
9
|
+
export type { LoadFormFailureError };
|
|
10
|
+
|
|
11
|
+
// prettier-ignore
|
|
12
|
+
export type FormResultStatus =
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
14
|
+
| 'success'
|
|
15
|
+
| 'warning'
|
|
16
|
+
| 'failure';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @todo Pending design and modeling of warning cases.
|
|
20
|
+
*/
|
|
21
|
+
export type LoadFormWarnings = UnknownObject;
|
|
22
|
+
|
|
23
|
+
// prettier-ignore
|
|
24
|
+
type FailedLoadFormResultMethodParameters<T extends AnyFunction> =
|
|
25
|
+
& readonly never[]
|
|
26
|
+
& (
|
|
27
|
+
Parameters<T> extends { readonly length: infer Length extends number }
|
|
28
|
+
? { readonly length: Length }
|
|
29
|
+
: never
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export type FailedLoadFormResultMethod<T extends AnyFunction> = (
|
|
33
|
+
...args: FailedLoadFormResultMethodParameters<T>
|
|
34
|
+
) => never;
|
|
35
|
+
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
export type FallibleLoadFormResultMethod<T extends AnyFunction> =
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
39
|
+
| T
|
|
40
|
+
| FailedLoadFormResultMethod<T>;
|
|
41
|
+
|
|
42
|
+
interface BaseLoadFormResult {
|
|
43
|
+
readonly status: FormResultStatus;
|
|
44
|
+
readonly warnings: LoadFormWarnings | null;
|
|
45
|
+
readonly error: LoadFormFailureError | null;
|
|
46
|
+
readonly createInstance: FallibleLoadFormResultMethod<CreateFormInstance>;
|
|
47
|
+
readonly editInstance: FallibleLoadFormResultMethod<EditFormInstance>;
|
|
48
|
+
readonly restoreInstance: FallibleLoadFormResultMethod<RestoreFormInstance>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface LoadFormSuccessResult extends BaseLoadFormResult {
|
|
52
|
+
readonly status: 'success';
|
|
53
|
+
readonly warnings: null;
|
|
54
|
+
readonly error: null;
|
|
55
|
+
readonly createInstance: CreateFormInstance;
|
|
56
|
+
readonly editInstance: EditFormInstance;
|
|
57
|
+
readonly restoreInstance: RestoreFormInstance;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface LoadFormWarningResult extends BaseLoadFormResult {
|
|
61
|
+
readonly status: 'warning';
|
|
62
|
+
readonly warnings: LoadFormWarnings;
|
|
63
|
+
readonly error: null;
|
|
64
|
+
readonly createInstance: CreateFormInstance;
|
|
65
|
+
readonly editInstance: EditFormInstance;
|
|
66
|
+
readonly restoreInstance: RestoreFormInstance;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface LoadFormFailureResult extends BaseLoadFormResult {
|
|
70
|
+
readonly status: 'failure';
|
|
71
|
+
readonly warnings: LoadFormWarnings | null;
|
|
72
|
+
readonly error: LoadFormFailureError;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @example A temporary demo integration was built during development of this
|
|
76
|
+
* interface.
|
|
77
|
+
*
|
|
78
|
+
* @see
|
|
79
|
+
* {@link https://github.com/getodk/web-forms/pull/345/commits/9ef36355d89dd1450d3a87c3a55506bb9b0fc414}
|
|
80
|
+
*/
|
|
81
|
+
readonly createInstance: FailedLoadFormResultMethod<CreateFormInstance>;
|
|
82
|
+
|
|
83
|
+
readonly editInstance: FailedLoadFormResultMethod<EditFormInstance>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @example A temporary demo integration was built during development of this
|
|
87
|
+
* interface.
|
|
88
|
+
*
|
|
89
|
+
* @see
|
|
90
|
+
* {@link https://github.com/getodk/web-forms/pull/345/commits/9ef36355d89dd1450d3a87c3a55506bb9b0fc414}
|
|
91
|
+
*/
|
|
92
|
+
readonly restoreInstance: FailedLoadFormResultMethod<RestoreFormInstance>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// prettier-ignore
|
|
96
|
+
export type InstantiableLoadFormResult =
|
|
97
|
+
| LoadFormSuccessResult
|
|
98
|
+
| LoadFormWarningResult
|
|
99
|
+
|
|
100
|
+
// prettier-ignore
|
|
101
|
+
export type LoadFormResult =
|
|
102
|
+
| InstantiableLoadFormResult
|
|
103
|
+
| LoadFormFailureResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InstanceData } from '../serialization/InstanceData.ts';
|
|
2
|
+
import type { FormInstance, FormInstanceRestoreMode } from './FormInstance.ts';
|
|
3
|
+
import type { FormInstanceConfig } from './FormInstanceConfig.ts';
|
|
4
|
+
|
|
5
|
+
export interface RestoreFormInstanceInput {
|
|
6
|
+
readonly data: readonly [InstanceData, ...InstanceData[]];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type RestoredFormInstance = FormInstance<FormInstanceRestoreMode>;
|
|
10
|
+
|
|
11
|
+
export type RestoreFormInstance = (
|
|
12
|
+
input: RestoreFormInstanceInput,
|
|
13
|
+
config?: FormInstanceConfig
|
|
14
|
+
) => Promise<RestoredFormInstance>;
|
package/src/client/hierarchy.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { AnyInputNode } from './InputNode.ts';
|
|
|
4
4
|
import type { AnyModelValueNode } from './ModelValueNode.ts';
|
|
5
5
|
import type { AnyNoteNode } from './NoteNode.ts';
|
|
6
6
|
import type { AnyRangeNode } from './RangeNode.ts';
|
|
7
|
+
import type { RankNode } from './RankNode.ts';
|
|
7
8
|
import type { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
|
|
8
9
|
import type { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
|
|
9
10
|
import type { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
|
|
@@ -11,11 +12,7 @@ import type { RootNode } from './RootNode.ts';
|
|
|
11
12
|
import type { SelectNode } from './SelectNode.ts';
|
|
12
13
|
import type { SubtreeNode } from './SubtreeNode.ts';
|
|
13
14
|
import type { TriggerNode } from './TriggerNode.ts';
|
|
14
|
-
import type {
|
|
15
|
-
import type { UploadNode } from './unsupported/UploadNode.ts';
|
|
16
|
-
|
|
17
|
-
// prettier-ignore
|
|
18
|
-
export type AnyUnsupportedControlNode = UploadNode;
|
|
15
|
+
import type { UploadNode } from './UploadNode.ts';
|
|
19
16
|
|
|
20
17
|
// prettier-ignore
|
|
21
18
|
export type AnyControlNode =
|
|
@@ -24,13 +21,13 @@ export type AnyControlNode =
|
|
|
24
21
|
| AnyRangeNode
|
|
25
22
|
| RankNode
|
|
26
23
|
| SelectNode
|
|
27
|
-
| TriggerNode
|
|
24
|
+
| TriggerNode
|
|
25
|
+
| UploadNode;
|
|
28
26
|
|
|
29
27
|
// prettier-ignore
|
|
30
28
|
export type AnyLeafNode =
|
|
31
29
|
| AnyControlNode
|
|
32
|
-
| AnyModelValueNode
|
|
33
|
-
| AnyUnsupportedControlNode;
|
|
30
|
+
| AnyModelValueNode;
|
|
34
31
|
|
|
35
32
|
// prettier-ignore
|
|
36
33
|
export type RepeatRangeNode =
|
package/src/client/index.ts
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
export type * from './attachments/InstanceAttachmentMeta.ts';
|
|
2
|
+
export type * from './attachments/InstanceAttachmentsConfig.ts';
|
|
3
|
+
export type * from './constants.ts';
|
|
4
|
+
export * as constants from './constants.ts';
|
|
5
|
+
export type * from './form/CreateFormInstance.ts';
|
|
6
|
+
export type * from './form/EditFormInstance.ts';
|
|
7
|
+
export type * from './form/FormInstance.ts';
|
|
8
|
+
export type * from './form/FormInstanceConfig.ts';
|
|
9
|
+
export type * from './form/FormResource.ts';
|
|
10
|
+
export type * from './form/LoadForm.ts';
|
|
11
|
+
export type * from './form/LoadFormResult.ts';
|
|
12
|
+
export type * from './form/RestoreFormInstance.ts';
|
|
13
|
+
export type * from './FormLanguage.ts';
|
|
14
|
+
export type * from './GroupNode.ts';
|
|
15
|
+
export type {
|
|
16
|
+
AnyChildNode,
|
|
17
|
+
AnyControlNode,
|
|
18
|
+
AnyLeafNode,
|
|
19
|
+
AnyNode,
|
|
20
|
+
AnyParentNode,
|
|
21
|
+
GeneralChildNode,
|
|
22
|
+
GeneralParentNode,
|
|
23
|
+
RepeatRangeNode,
|
|
24
|
+
} from './hierarchy.ts';
|
|
25
|
+
export type * from './identity.ts';
|
|
26
|
+
export type * from './InputNode.ts';
|
|
27
|
+
export type * from './ModelValueNode.ts';
|
|
28
|
+
export type * from './NoteNode.ts';
|
|
29
|
+
export type * from './OpaqueReactiveObjectFactory.ts';
|
|
30
|
+
export type * from './RangeNode.ts';
|
|
31
|
+
export type * from './RankNode.ts';
|
|
32
|
+
export type * from './repeat/RepeatInstanceNode.ts';
|
|
33
|
+
export type * from './repeat/RepeatRangeControlledNode.ts';
|
|
34
|
+
export type * from './repeat/RepeatRangeUncontrolledNode.ts';
|
|
35
|
+
export type * from './resources.ts';
|
|
36
|
+
export type * from './RootNode.ts';
|
|
37
|
+
export type * from './SelectNode.ts';
|
|
38
|
+
export type * from './serialization/InstanceData.ts';
|
|
39
|
+
export type * from './serialization/InstanceFile.ts';
|
|
40
|
+
export type * from './serialization/InstancePayload.ts';
|
|
41
|
+
export type * from './serialization/InstancePayloadOptions.ts';
|
|
42
|
+
export type * from './serialization/InstanceState.ts';
|
|
43
|
+
export type * from './submission/SubmissionMeta.ts';
|
|
44
|
+
export type * from './SubtreeNode.ts';
|
|
45
|
+
export type * from './TextRange.ts';
|
|
46
|
+
export type * from './TriggerNode.ts';
|
|
47
|
+
export type * from './UploadNode.ts';
|
|
48
|
+
export type * from './validation.ts';
|
|
49
|
+
export type * from './ValueType.ts';
|
package/src/client/node-types.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// prettier-ignore
|
|
2
|
-
export type UnsupportedControlNodeType =
|
|
3
|
-
| 'rank'
|
|
4
|
-
| 'upload';
|
|
5
|
-
|
|
6
1
|
// prettier-ignore
|
|
7
2
|
export type RepeatRangeNodeType =
|
|
8
3
|
| 'repeat-range:controlled'
|
|
@@ -17,7 +12,8 @@ export type LeafNodeType =
|
|
|
17
12
|
| 'input'
|
|
18
13
|
| 'trigger'
|
|
19
14
|
| 'range'
|
|
20
|
-
|
|
|
15
|
+
| 'rank'
|
|
16
|
+
| 'upload';
|
|
21
17
|
|
|
22
18
|
// prettier-ignore
|
|
23
19
|
export type InstanceNodeType =
|
|
@@ -27,5 +23,4 @@ export type InstanceNodeType =
|
|
|
27
23
|
| 'repeat-instance'
|
|
28
24
|
| 'group'
|
|
29
25
|
| 'subtree'
|
|
30
|
-
| LeafNodeType
|
|
31
|
-
| UnsupportedControlNodeType;
|
|
26
|
+
| LeafNodeType;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AnyRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
2
1
|
import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
3
2
|
import type { NodeAppearances } from '../NodeAppearances.ts';
|
|
4
3
|
import type { RootNode } from '../RootNode.ts';
|
|
@@ -6,7 +5,7 @@ import type { TextRange } from '../TextRange.ts';
|
|
|
6
5
|
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
7
6
|
import type { RepeatRangeNodeType } from '../node-types.ts';
|
|
8
7
|
import type { AncestorNodeValidationState } from '../validation.ts';
|
|
9
|
-
import type { RepeatInstanceNode } from './RepeatInstanceNode.ts';
|
|
8
|
+
import type { AnyRepeatDefinition, RepeatInstanceNode } from './RepeatInstanceNode.ts';
|
|
10
9
|
|
|
11
10
|
export interface BaseRepeatRangeNodeState extends BaseNodeState {
|
|
12
11
|
get hint(): null;
|
|
@@ -26,7 +25,7 @@ export interface BaseRepeatRangeNodeState extends BaseNodeState {
|
|
|
26
25
|
get value(): null;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export type RepeatRangeNodeAppearances = NodeAppearances<
|
|
28
|
+
export type RepeatRangeNodeAppearances = NodeAppearances<AnyRepeatDefinition>;
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Represents a contiguous set of zero or more {@link RepeatInstanceNode}s
|
|
@@ -95,7 +94,7 @@ export type RepeatRangeNodeAppearances = NodeAppearances<AnyRepeatRangeDefinitio
|
|
|
95
94
|
export interface BaseRepeatRangeNode extends BaseNode {
|
|
96
95
|
readonly nodeType: RepeatRangeNodeType;
|
|
97
96
|
readonly appearances: RepeatRangeNodeAppearances;
|
|
98
|
-
readonly definition:
|
|
97
|
+
readonly definition: AnyRepeatDefinition;
|
|
99
98
|
readonly root: RootNode;
|
|
100
99
|
readonly parent: GeneralParentNode;
|
|
101
100
|
readonly currentState: BaseRepeatRangeNodeState;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { RepeatTemplateDefinition } from '../../parse/model/RepeatTemplateDefinition.ts';
|
|
1
|
+
import type { AnyRepeatDefinition } from '../../parse/model/RepeatDefinition.ts';
|
|
3
2
|
import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
4
3
|
import type { GeneralChildNode, RepeatRangeNode } from '../hierarchy.ts';
|
|
5
4
|
import type { NodeAppearances } from '../NodeAppearances.ts';
|
|
@@ -19,17 +18,14 @@ export interface RepeatInstanceNodeState extends BaseNodeState {
|
|
|
19
18
|
get value(): null;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
export type RepeatDefinition =
|
|
24
|
-
| RepeatInstanceDefinition
|
|
25
|
-
| RepeatTemplateDefinition;
|
|
21
|
+
export type { AnyRepeatDefinition };
|
|
26
22
|
|
|
27
|
-
export type RepeatInstanceNodeAppearances = NodeAppearances<
|
|
23
|
+
export type RepeatInstanceNodeAppearances = NodeAppearances<AnyRepeatDefinition>;
|
|
28
24
|
|
|
29
25
|
export interface RepeatInstanceNode extends BaseNode {
|
|
30
26
|
readonly nodeType: 'repeat-instance';
|
|
31
27
|
readonly appearances: RepeatInstanceNodeAppearances;
|
|
32
|
-
readonly definition:
|
|
28
|
+
readonly definition: AnyRepeatDefinition;
|
|
33
29
|
readonly root: RootNode;
|
|
34
30
|
|
|
35
31
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlledRepeatDefinition } from '../../parse/model/RepeatDefinition.ts';
|
|
2
2
|
import type { BaseRepeatRangeNode, BaseRepeatRangeNodeState } from './BaseRepeatRangeNode.ts';
|
|
3
3
|
import type { RepeatRangeUncontrolledNode } from './RepeatRangeUncontrolledNode.ts';
|
|
4
4
|
|
|
@@ -16,5 +16,5 @@ export interface RepeatRangeControlledState extends BaseRepeatRangeNodeState {}
|
|
|
16
16
|
*/
|
|
17
17
|
export interface RepeatRangeControlledNode extends BaseRepeatRangeNode {
|
|
18
18
|
readonly nodeType: 'repeat-range:controlled';
|
|
19
|
-
readonly definition:
|
|
19
|
+
readonly definition: ControlledRepeatDefinition;
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UncontrolledRepeatDefinition } from '../../parse/model/RepeatDefinition.ts';
|
|
2
2
|
import type { RootNode } from '../RootNode.ts';
|
|
3
3
|
import type { BaseRepeatRangeNode, BaseRepeatRangeNodeState } from './BaseRepeatRangeNode.ts';
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@ export interface RepeatRangeUncontrolledState extends BaseRepeatRangeNodeState {
|
|
|
14
14
|
*/
|
|
15
15
|
export interface RepeatRangeUncontrolledNode extends BaseRepeatRangeNode {
|
|
16
16
|
readonly nodeType: 'repeat-range:uncontrolled';
|
|
17
|
-
readonly definition:
|
|
17
|
+
readonly definition: UncontrolledRepeatDefinition;
|
|
18
18
|
|
|
19
19
|
addInstances(afterIndex?: number, count?: number): RootNode;
|
|
20
20
|
removeInstances(startIndex: number, count?: number): RootNode;
|
package/src/client/resources.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JRResourceURL } from '@getodk/common/jr-resources/JRResourceURL.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { loadForm } from '../entrypoints/loadForm.ts';
|
|
3
3
|
|
|
4
4
|
interface FetchResourceHeadersIterator<T>
|
|
5
5
|
extends IteratorObject<
|
|
@@ -85,7 +85,7 @@ export interface FetchResourceResponseHeaders {
|
|
|
85
85
|
*
|
|
86
86
|
* Furthermore, if the engine intends to read {@link body} (or its indirect
|
|
87
87
|
* {@link blob} or {@link text} consumers), it will do so in the course of a
|
|
88
|
-
* client's call to {@link
|
|
88
|
+
* client's call to {@link loadForm}, and before the
|
|
89
89
|
* {@link Promise<PrimaryInstance>} returned by that call is resolved.
|
|
90
90
|
*/
|
|
91
91
|
export interface FetchResourceResponse {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { INSTANCE_FILE_NAME, InstanceFile } from './InstanceFile.ts';
|
|
2
|
+
|
|
3
|
+
export type InstanceAttachmentFileName = string;
|
|
4
|
+
|
|
5
|
+
export type InstanceDataEntryValue = File;
|
|
6
|
+
|
|
7
|
+
export interface InstanceData extends FormData {
|
|
8
|
+
[Symbol.iterator](): FormDataIterator<[string, InstanceDataEntryValue]>;
|
|
9
|
+
entries(): FormDataIterator<[string, InstanceDataEntryValue]>;
|
|
10
|
+
values(): FormDataIterator<InstanceDataEntryValue>;
|
|
11
|
+
|
|
12
|
+
forEach(
|
|
13
|
+
callbackfn: (value: InstanceDataEntryValue, key: string, parent: InstanceData) => void,
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
thisArg?: any
|
|
16
|
+
): void;
|
|
17
|
+
|
|
18
|
+
get(name: INSTANCE_FILE_NAME): InstanceFile;
|
|
19
|
+
get(name: InstanceAttachmentFileName): InstanceDataEntryValue | null;
|
|
20
|
+
getAll(name: string): InstanceDataEntryValue[];
|
|
21
|
+
|
|
22
|
+
has(name: INSTANCE_FILE_NAME): true;
|
|
23
|
+
has(name: InstanceAttachmentFileName): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { INSTANCE_FILE_NAME, INSTANCE_FILE_TYPE } from '../constants.ts';
|
|
2
|
+
|
|
3
|
+
// Re-export for convenient `InstanceFile` construction/access flows
|
|
4
|
+
export type { INSTANCE_FILE_NAME, INSTANCE_FILE_TYPE };
|
|
5
|
+
|
|
6
|
+
export interface InstanceFile extends File {
|
|
7
|
+
readonly name: INSTANCE_FILE_NAME;
|
|
8
|
+
readonly type: INSTANCE_FILE_TYPE;
|
|
9
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { SubmissionMeta } from '../submission/SubmissionMeta.ts';
|
|
2
|
+
import type { AnyViolation, DescendantNodeViolationReference } from '../validation.ts';
|
|
3
|
+
import type { InstanceData } from './InstanceData.ts';
|
|
4
|
+
import type { InstancePayloadOptions, InstancePayloadType } from './InstancePayloadOptions.ts';
|
|
5
|
+
|
|
6
|
+
// prettier-ignore
|
|
7
|
+
export type InstancePayloadStatus =
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
9
|
+
| 'pending'
|
|
10
|
+
| 'max-size-exceeded'
|
|
11
|
+
| 'ready';
|
|
12
|
+
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
type InstancePayloadData<PayloadType extends InstancePayloadType> = {
|
|
15
|
+
chunked: readonly [InstanceData, ...InstanceData[]];
|
|
16
|
+
monolithic: readonly [InstanceData];
|
|
17
|
+
}[PayloadType];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Provides detail about an individual instance attachment {@link File}s which
|
|
21
|
+
* exceeds the client-specified {@link maxSize} for a
|
|
22
|
+
* {@link ChunkedInstancePayload | chunked instance payload}. Clients may use
|
|
23
|
+
* this value to provide guidance to users.
|
|
24
|
+
*
|
|
25
|
+
* @todo We may want to consider (a) making {@link maxSize} a configuration the
|
|
26
|
+
* client can provide when initializing a form instance, rather than only when
|
|
27
|
+
* serializing an instance payload; and then (b) treating a maximum size
|
|
28
|
+
* violation as another kind of node-level violation. This would go beyond the
|
|
29
|
+
* kinds of validation specified by ODK XForms, but it would make a lot of
|
|
30
|
+
* _conceptual sense_.
|
|
31
|
+
*
|
|
32
|
+
* It would almost certainly be helpful to alert users to violations as the
|
|
33
|
+
* occur, rather than only at instance payload serialization time (where they
|
|
34
|
+
* have likely already moved on). This is something clients can do without
|
|
35
|
+
* engine support, but it would likely promote good usability patterns if the
|
|
36
|
+
* engine makes it an obvious and uniform option at the main engine/client
|
|
37
|
+
* entrypoint.
|
|
38
|
+
*
|
|
39
|
+
* @todo If we consider the above, we'd want to reframe _this interface_ to
|
|
40
|
+
* match the shape of other {@link AnyViolation | violations} (adding it as a
|
|
41
|
+
* member of that union). We'd also likely eliminate
|
|
42
|
+
* {@link MaxSizeExceededResult} in the process, since
|
|
43
|
+
* {@link PendingInstancePayload} would then cover the case.
|
|
44
|
+
*/
|
|
45
|
+
interface MaxSizeViolation {
|
|
46
|
+
/**
|
|
47
|
+
* Specifies the index of
|
|
48
|
+
* {@link InstancePayloadData<'chunked'> | chunked instance payload data}
|
|
49
|
+
* where an instance attachment {@link File} exceeds the client-specified
|
|
50
|
+
* {@link maxSize}.
|
|
51
|
+
*/
|
|
52
|
+
readonly dataIndex: number;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Specifies the name of the file which exceeds the client-specified
|
|
56
|
+
* {@link maxSize}. This name can also be used as a key to access the
|
|
57
|
+
* violating {@link File}/instance attachment, in the {@link InstanceData} at
|
|
58
|
+
* the specified {@link dataIndex}.
|
|
59
|
+
*/
|
|
60
|
+
readonly fileName: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Reflects the client-specified maximum size for each chunk of a
|
|
64
|
+
* {@link ChunkedInstancePayload | chunked instance payload}.
|
|
65
|
+
*/
|
|
66
|
+
readonly maxSize: number;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Details the actual size of the violating {@link File}/instance attachment.
|
|
70
|
+
* Along with {@link maxSize}. Clients may use the delta between this value
|
|
71
|
+
* and {@link maxSize} to provide detailed guidance to users.
|
|
72
|
+
*/
|
|
73
|
+
readonly actualSize: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// prettier-ignore
|
|
77
|
+
type InstancePayloadViolation =
|
|
78
|
+
| DescendantNodeViolationReference
|
|
79
|
+
| MaxSizeViolation;
|
|
80
|
+
|
|
81
|
+
interface BaseInstancePayload<PayloadType extends InstancePayloadType> {
|
|
82
|
+
readonly payloadType: PayloadType;
|
|
83
|
+
readonly status: InstancePayloadStatus;
|
|
84
|
+
readonly submissionMeta: SubmissionMeta;
|
|
85
|
+
|
|
86
|
+
get violations(): readonly InstancePayloadViolation[] | null;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Instance attachment data may be chunked according to the
|
|
90
|
+
* {@link InstancePayloadOptions.maxSize | maxSize instance payload option}
|
|
91
|
+
*/
|
|
92
|
+
readonly data: InstancePayloadData<PayloadType>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface PendingInstancePayload<PayloadType extends InstancePayloadType>
|
|
96
|
+
extends BaseInstancePayload<PayloadType> {
|
|
97
|
+
readonly status: 'pending';
|
|
98
|
+
get violations(): readonly DescendantNodeViolationReference[];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface MaxSizeExceededResult extends BaseInstancePayload<'chunked'> {
|
|
102
|
+
readonly status: 'max-size-exceeded';
|
|
103
|
+
get violations(): readonly MaxSizeViolation[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface ReadyInstancePayload<PayloadType extends InstancePayloadType>
|
|
107
|
+
extends BaseInstancePayload<PayloadType> {
|
|
108
|
+
readonly status: 'ready';
|
|
109
|
+
get violations(): null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// prettier-ignore
|
|
113
|
+
export type ChunkedInstancePayload =
|
|
114
|
+
| MaxSizeExceededResult
|
|
115
|
+
| PendingInstancePayload<'chunked'>
|
|
116
|
+
| ReadyInstancePayload<'chunked'>;
|
|
117
|
+
|
|
118
|
+
export type MonolithicInstancePayload =
|
|
119
|
+
| PendingInstancePayload<'monolithic'>
|
|
120
|
+
| ReadyInstancePayload<'monolithic'>;
|
|
121
|
+
|
|
122
|
+
// prettier-ignore
|
|
123
|
+
export type InstancePayload<PayloadType extends InstancePayloadType> = {
|
|
124
|
+
chunked: ChunkedInstancePayload;
|
|
125
|
+
monolithic: MonolithicInstancePayload;
|
|
126
|
+
}[PayloadType];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type InstancePayloadType = 'chunked' | 'monolithic';
|
|
2
|
+
|
|
3
|
+
interface BaseInstancePayloadOptions<PayloadType extends InstancePayloadType> {
|
|
4
|
+
readonly payloadType: PayloadType;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* As described in the
|
|
8
|
+
* {@link https://docs.getodk.org/openrosa-form-submission/#extended-transmission-considerations | OpenRosa Form Submission API},
|
|
9
|
+
* clients may obtain this value from an OpenRosa server's
|
|
10
|
+
* `X-OpenRosa-Accept-Content-Length` header.
|
|
11
|
+
*/
|
|
12
|
+
readonly maxSize?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ChunkedInstancePayloadOptions extends BaseInstancePayloadOptions<'chunked'> {
|
|
16
|
+
readonly payloadType: 'chunked';
|
|
17
|
+
readonly maxSize: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface MonolithicInstancePayloadOptions extends BaseInstancePayloadOptions<'monolithic'> {
|
|
21
|
+
readonly payloadType: 'monolithic';
|
|
22
|
+
readonly maxSize?: never;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// prettier-ignore
|
|
26
|
+
export type InstancePayloadOptions<PayloadType extends InstancePayloadType = 'monolithic'> = {
|
|
27
|
+
chunked: ChunkedInstancePayloadOptions;
|
|
28
|
+
monolithic: MonolithicInstancePayloadOptions;
|
|
29
|
+
}[PayloadType];
|