@getodk/xforms-engine 0.6.0 → 0.7.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/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 +17 -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/index.d.ts +37 -11
- package/dist/client/node-types.d.ts +2 -2
- 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 +12 -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 +23 -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/index.d.ts +2 -33
- package/dist/index.js +1915 -1419
- 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 +35 -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/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/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/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +2 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +8 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +14 -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/instance/unsupported/UploadControl.d.ts +32 -4
- 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/codecs/TempUnsupportedControlCodec.d.ts +7 -0
- package/dist/lib/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/model/BindDefinition.d.ts +1 -1
- 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 +1709 -1213
- package/dist/solid.js.map +1 -1
- package/package.json +1 -1
- package/src/client/BaseNode.ts +4 -4
- package/src/client/BaseValueNode.ts +7 -3
- package/src/client/RootNode.ts +27 -19
- 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 +18 -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/index.ts +47 -29
- package/src/client/node-types.ts +2 -4
- 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 +16 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +28 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/entrypoints/FormInstance.ts +55 -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/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 +69 -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/abstract/DescendantNode.ts +12 -2
- package/src/instance/abstract/InstanceNode.ts +9 -5
- package/src/instance/abstract/ValueNode.ts +11 -13
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/{children.ts → children/buildChildren.ts} +55 -48
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +142 -0
- package/src/instance/internal-api/InstanceConfig.ts +3 -10
- package/src/instance/internal-api/InstanceValueContext.ts +9 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +20 -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/instance/unsupported/UploadControl.ts +116 -5
- 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 +173 -0
- package/src/lib/codecs/TempUnsupportedControlCodec.ts +32 -0
- package/src/lib/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/reactivity/createInstanceValueState.ts +27 -51
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +3 -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/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/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/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/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/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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseStaticDocumentFromDOMSubtree } from '../../../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
2
2
|
import type { DOMSecondaryInstanceElement } from '../../../XFormDOM.ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { assertSecondaryInstanceDefinition } from '../assertSecondaryInstanceDefinition.ts';
|
|
4
|
+
import type { SecondaryInstanceDefinition } from '../SecondaryInstancesDefinition.ts';
|
|
5
5
|
import { SecondaryInstanceSource } from './SecondaryInstanceSource.ts';
|
|
6
6
|
|
|
7
7
|
export class InternalSecondaryInstanceSource extends SecondaryInstanceSource<'internal'> {
|
|
@@ -10,10 +10,12 @@ export class InternalSecondaryInstanceSource extends SecondaryInstanceSource<'in
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
parseDefinition(): SecondaryInstanceDefinition {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
13
|
+
const doc = parseStaticDocumentFromDOMSubtree(this.domElement, {
|
|
14
|
+
nodesetPrefix: `instance('${this.instanceId}')`,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
assertSecondaryInstanceDefinition(doc);
|
|
18
|
+
|
|
19
|
+
return doc;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JRResourceURL } from '@getodk/common/jr-resources/JRResourceURL.ts';
|
|
2
2
|
import type { DOMSecondaryInstanceElement } from '../../../XFormDOM.ts';
|
|
3
|
-
import type { SecondaryInstanceDefinition } from '../
|
|
3
|
+
import type { SecondaryInstanceDefinition } from '../SecondaryInstancesDefinition.ts';
|
|
4
4
|
|
|
5
5
|
// prettier-ignore
|
|
6
6
|
export type ExternalSecondaryInstanceSourceFormat =
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XFORMS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
2
|
import { parseStaticDocumentFromDOMSubtree } from '../../../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { assertSecondaryInstanceDefinition } from '../assertSecondaryInstanceDefinition.ts';
|
|
4
|
+
import type { SecondaryInstanceDefinition } from '../SecondaryInstancesDefinition.ts';
|
|
5
5
|
import { ExternalSecondaryInstanceSource } from './ExternalSecondaryInstanceSource.ts';
|
|
6
6
|
import type { InternalSecondaryInstanceSource } from './InternalSecondaryInstanceSource.ts';
|
|
7
7
|
|
|
@@ -23,10 +23,10 @@ export class XMLExternalSecondaryInstanceSource extends ExternalSecondaryInstanc
|
|
|
23
23
|
instanceElement.setAttribute('id', this.instanceId);
|
|
24
24
|
instanceElement.innerHTML = this.resource.data;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const doc = parseStaticDocumentFromDOMSubtree(instanceElement);
|
|
27
|
+
|
|
28
|
+
assertSecondaryInstanceDefinition(doc);
|
|
29
|
+
|
|
30
|
+
return doc;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SubmissionMeta } from '../../client/submission/SubmissionMeta.ts';
|
|
2
2
|
import { getSubmissionElement } from '../../lib/dom/query.ts';
|
|
3
3
|
import type { XFormDOM } from '../XFormDOM.ts';
|
|
4
4
|
|
|
5
|
-
export class
|
|
5
|
+
export class SubmissionDefinition implements SubmissionMeta {
|
|
6
6
|
readonly submissionAction!: URL | null;
|
|
7
7
|
readonly submissionMethod = 'post';
|
|
8
8
|
readonly encryptionKey!: string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
1
2
|
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
3
|
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
3
4
|
import type {
|
|
@@ -17,14 +18,12 @@ export class SubtreeDefinition extends DescendentNodeDefinition<
|
|
|
17
18
|
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
18
19
|
readonly qualifiedName: QualifiedName;
|
|
19
20
|
readonly children: readonly ChildNodeDefinition[];
|
|
20
|
-
readonly instances = null;
|
|
21
|
-
readonly defaultValue = null;
|
|
22
21
|
|
|
23
22
|
constructor(
|
|
24
23
|
parent: ParentNodeDefinition,
|
|
25
24
|
bind: BindDefinition,
|
|
26
25
|
bodyElement: AnyBodyElementDefinition | null,
|
|
27
|
-
readonly
|
|
26
|
+
readonly template: StaticElement
|
|
28
27
|
) {
|
|
29
28
|
if (
|
|
30
29
|
bodyElement != null &&
|
|
@@ -37,9 +36,9 @@ export class SubtreeDefinition extends DescendentNodeDefinition<
|
|
|
37
36
|
|
|
38
37
|
const { root } = parent;
|
|
39
38
|
|
|
40
|
-
this.qualifiedName =
|
|
39
|
+
this.qualifiedName = template.qualifiedName;
|
|
41
40
|
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
42
|
-
this.children = root.buildSubtree(this);
|
|
41
|
+
this.children = root.buildSubtree(this, template);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
toJSON() {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
2
|
+
import type { AnyNodeDefinition } from './NodeDefinition.ts';
|
|
3
|
+
import type { RootDefinition } from './RootDefinition.ts';
|
|
4
|
+
|
|
5
|
+
export type NodesetReference = string;
|
|
6
|
+
|
|
7
|
+
const collectDefinitions = (
|
|
8
|
+
result: Map<NodesetReference, AnyNodeDefinition>,
|
|
9
|
+
definition: AnyNodeDefinition
|
|
10
|
+
): Map<NodesetReference, AnyNodeDefinition> => {
|
|
11
|
+
const { nodeset } = definition;
|
|
12
|
+
|
|
13
|
+
if (result.has(nodeset)) {
|
|
14
|
+
throw new ErrorProductionDesignPendingError();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
result.set(nodeset, definition);
|
|
18
|
+
|
|
19
|
+
if (definition.type === 'leaf-node') {
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (const child of definition.children) {
|
|
24
|
+
collectDefinitions(result, child);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type NodeDefinitionMap = ReadonlyMap<NodesetReference, AnyNodeDefinition>;
|
|
31
|
+
|
|
32
|
+
export const nodeDefinitionMap = (root: RootDefinition): NodeDefinitionMap => {
|
|
33
|
+
return collectDefinitions(new Map(), root);
|
|
34
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
2
|
+
import type { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
3
|
+
import type { StaticNode } from '../../integration/xpath/static-dom/StaticNode.ts';
|
|
4
|
+
import type { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
5
|
+
import { escapeXMLText } from '../../lib/xml-serialization.ts';
|
|
6
|
+
import type { ModelDefinition } from '../model/ModelDefinition.ts';
|
|
7
|
+
import type { RootDefinition } from '../model/RootDefinition.ts';
|
|
8
|
+
import { parseStaticDocumentFromDOMSubtree } from './parseStaticDocumentFromDOMSubtree.ts';
|
|
9
|
+
|
|
10
|
+
type WrappedInstanceXML = `<wrapped${string}</wrapped>`;
|
|
11
|
+
|
|
12
|
+
const wrapInstanceXML = (model: ModelDefinition, instanceXML: string): WrappedInstanceXML => {
|
|
13
|
+
const defaultNamespace = model.root.namespaceDeclarations.get(null);
|
|
14
|
+
const defaultNamespaceURI = defaultNamespace?.declaredURI?.href;
|
|
15
|
+
|
|
16
|
+
if (defaultNamespaceURI == null) {
|
|
17
|
+
return `<wrapped>${instanceXML}</wrapped>`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return /* xml */ `<wrapped xmlns="${escapeXMLText(defaultNamespaceURI, true)}">
|
|
21
|
+
${instanceXML}
|
|
22
|
+
</wrapped>`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type AssertSoleChildElement = (element?: Element | null) => asserts element is Element;
|
|
26
|
+
|
|
27
|
+
const assertSoleChildElement: AssertSoleChildElement = (element) => {
|
|
28
|
+
if (element == null) {
|
|
29
|
+
throw new ErrorProductionDesignPendingError('Expected a child element');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const { parentNode } = element;
|
|
33
|
+
|
|
34
|
+
if (parentNode == null) {
|
|
35
|
+
throw new ErrorProductionDesignPendingError('Expected element to be a child of a parent node');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (element !== parentNode.firstElementChild || element !== parentNode.lastElementChild) {
|
|
39
|
+
throw new ErrorProductionDesignPendingError(
|
|
40
|
+
"Expected child element to be parent node's only element child."
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getWrappedInstanceRootElement = (xml: WrappedInstanceXML): Element => {
|
|
46
|
+
const domParser = new DOMParser();
|
|
47
|
+
const doc = domParser.parseFromString(xml, 'text/xml');
|
|
48
|
+
const { documentElement } = doc;
|
|
49
|
+
const [root] = documentElement.children;
|
|
50
|
+
|
|
51
|
+
assertSoleChildElement(root);
|
|
52
|
+
|
|
53
|
+
return root;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Parses incoming instance XML input into a {@link StaticDocument}, preserving
|
|
58
|
+
* the form definition's default namespace URI (when the instance XML does not
|
|
59
|
+
* explicitly declare a default namespace).
|
|
60
|
+
*
|
|
61
|
+
* @todo This is a hack! A proper solution will involve extending namespace
|
|
62
|
+
* resolution (i.e. probably {@link NamespaceDeclarationMap}) from
|
|
63
|
+
* {@link RootDefinition} on down throughout the instance's {@link StaticNode}
|
|
64
|
+
* tree. The same will probably be the case for parsing (XML) external secondary
|
|
65
|
+
* instances as well, so at that point we can also stop using this specialized
|
|
66
|
+
* name!
|
|
67
|
+
*
|
|
68
|
+
* @todo Aside from this being a hack, it's not very robust because it makes
|
|
69
|
+
* assumptions which are _likely but definitely not guaranteed_!
|
|
70
|
+
*
|
|
71
|
+
* - Instance XML (probably) doeesn't declare a default namespace
|
|
72
|
+
* - Instance XML **definitely** declares non-default namespaces
|
|
73
|
+
*/
|
|
74
|
+
export const parseInstanceXML = (model: ModelDefinition, instanceXML: string): StaticDocument => {
|
|
75
|
+
const wrappedXML = wrapInstanceXML(model, instanceXML);
|
|
76
|
+
const root = getWrappedInstanceRootElement(wrappedXML);
|
|
77
|
+
|
|
78
|
+
return parseStaticDocumentFromDOMSubtree(root);
|
|
79
|
+
};
|
|
@@ -1,149 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { StaticAttribute } from '../../integration/xpath/static-dom/StaticAttribute.ts';
|
|
1
|
+
import type { StaticAttributeOptions } from '../../integration/xpath/static-dom/StaticAttribute.ts';
|
|
2
|
+
import { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
4
3
|
import type {
|
|
5
|
-
|
|
6
|
-
StaticDocumentRootFactory,
|
|
7
|
-
} from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
8
|
-
import type {
|
|
9
|
-
StaticElementAttributesFactory,
|
|
10
|
-
StaticElementChildNodesFactory,
|
|
4
|
+
StaticElementChildOption,
|
|
11
5
|
StaticElementOptions,
|
|
12
6
|
} from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
13
|
-
import {
|
|
14
|
-
import type { StaticParentNode } from '../../integration/xpath/static-dom/StaticNode.ts';
|
|
15
|
-
import { StaticText } from '../../integration/xpath/static-dom/StaticText.ts';
|
|
16
|
-
|
|
17
|
-
type ConcreteConstructor<T extends AnyConstructor> = Pick<T, keyof T>;
|
|
18
|
-
|
|
19
|
-
// prettier-ignore
|
|
20
|
-
export type ConcreteStaticDocumentConstructor<
|
|
21
|
-
T extends StaticDocument<Root>,
|
|
22
|
-
Root extends StaticElement,
|
|
23
|
-
> =
|
|
24
|
-
& ConcreteConstructor<typeof StaticDocument<Root>>
|
|
25
|
-
& (new (rootFactory: StaticDocumentRootFactory<T, Root>) => T);
|
|
26
|
-
|
|
27
|
-
const domElementAttributesFactory = (domElement: Element): StaticElementAttributesFactory => {
|
|
28
|
-
const attributes = Array.from(domElement.attributes);
|
|
7
|
+
import type { QualifiedNameSource } from '../../lib/names/QualifiedName.ts';
|
|
29
8
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
const parseNodeName = (domNode: Attr | Element): QualifiedNameSource => {
|
|
10
|
+
return {
|
|
11
|
+
namespaceURI: domNode.namespaceURI,
|
|
12
|
+
prefix: domNode.prefix,
|
|
13
|
+
localName: domNode.localName,
|
|
34
14
|
};
|
|
35
15
|
};
|
|
36
16
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface StaticChildTextSource {
|
|
45
|
-
readonly domType: typeof CDATA_SECTION_NODE | typeof TEXT_NODE;
|
|
46
|
-
readonly domNode: CharacterData;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// prettier-ignore
|
|
50
|
-
type StaticChildNodeSource =
|
|
51
|
-
| StaticChildElementSource
|
|
52
|
-
| StaticChildTextSource;
|
|
53
|
-
|
|
54
|
-
export const toStaticChildNodeSource = (childNode: ChildNode): StaticChildNodeSource | null => {
|
|
55
|
-
const domType = childNode.nodeType;
|
|
56
|
-
|
|
57
|
-
switch (domType) {
|
|
58
|
-
case ELEMENT_NODE:
|
|
59
|
-
return {
|
|
60
|
-
domType,
|
|
61
|
-
domNode: childNode as Element,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
case TEXT_NODE:
|
|
65
|
-
return {
|
|
66
|
-
domType,
|
|
67
|
-
domNode: childNode as Text,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
case CDATA_SECTION_NODE:
|
|
71
|
-
return {
|
|
72
|
-
domType,
|
|
73
|
-
domNode: childNode as CDATASection,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
default:
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const toStaticChildNodeSources = (childNode: ChildNode): StaticChildNodeSource | readonly [] => {
|
|
82
|
-
return toStaticChildNodeSource(childNode) ?? [];
|
|
17
|
+
const parseStaticElementAttributes = (domElement: Element): readonly StaticAttributeOptions[] => {
|
|
18
|
+
return Array.from(domElement.attributes).map((attr) => ({
|
|
19
|
+
name: attr,
|
|
20
|
+
value: attr.value,
|
|
21
|
+
}));
|
|
83
22
|
};
|
|
84
23
|
|
|
85
|
-
const
|
|
86
|
-
const childNodeSources = Array.from(domElement.childNodes).flatMap(toStaticChildNodeSources);
|
|
24
|
+
const { ELEMENT_NODE, CDATA_SECTION_NODE, TEXT_NODE } = Node;
|
|
87
25
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
26
|
+
const parseStaticElementChildren = (domElement: Element): readonly StaticElementChildOption[] => {
|
|
27
|
+
return Array.from(domElement.childNodes).flatMap((child) => {
|
|
28
|
+
switch (child.nodeType) {
|
|
29
|
+
case ELEMENT_NODE:
|
|
30
|
+
return parseStaticElementOptions(child as Element);
|
|
93
31
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
32
|
+
case TEXT_NODE:
|
|
33
|
+
case CDATA_SECTION_NODE:
|
|
34
|
+
return (child as CharacterData).data;
|
|
97
35
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
36
|
+
default:
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
103
40
|
};
|
|
104
41
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
& ConcreteConstructor<typeof StaticElement>
|
|
111
|
-
& {
|
|
112
|
-
readonly prototype: T;
|
|
113
|
-
|
|
114
|
-
new (
|
|
115
|
-
parent: Parent,
|
|
116
|
-
attributesFactory: StaticElementAttributesFactory,
|
|
117
|
-
childNodesFactory: StaticElementChildNodesFactory,
|
|
118
|
-
options: StaticElementOptions
|
|
119
|
-
): T;
|
|
42
|
+
const parseStaticElementOptions = (domElement: Element): StaticElementOptions => {
|
|
43
|
+
return {
|
|
44
|
+
name: parseNodeName(domElement),
|
|
45
|
+
attributes: parseStaticElementAttributes(domElement),
|
|
46
|
+
children: parseStaticElementChildren(domElement),
|
|
120
47
|
};
|
|
121
|
-
|
|
122
|
-
const parseStaticElementFromDOMElement = <
|
|
123
|
-
T extends StaticElement<Parent>,
|
|
124
|
-
Parent extends StaticParentNode = StaticParentNode,
|
|
125
|
-
>(
|
|
126
|
-
parent: Parent,
|
|
127
|
-
ElementConstructor: StaticElementConstructor<T, Parent>,
|
|
128
|
-
domElement: Element
|
|
129
|
-
): T => {
|
|
130
|
-
const attributesFactory = domElementAttributesFactory(domElement);
|
|
131
|
-
const childNodesFactory = domElementChildNodesFactory(domElement);
|
|
132
|
-
|
|
133
|
-
return new ElementConstructor(parent, attributesFactory, childNodesFactory, domElement);
|
|
134
48
|
};
|
|
135
49
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
):
|
|
144
|
-
const
|
|
145
|
-
return parseStaticElementFromDOMElement(parent, DocumentRootConstructor, subtreeRootElement);
|
|
146
|
-
};
|
|
50
|
+
interface ParseStaticDocumentFromDOMSubtreeOptions {
|
|
51
|
+
readonly nodesetPrefix?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const parseStaticDocumentFromDOMSubtree = (
|
|
55
|
+
subtreeRootElement: Element,
|
|
56
|
+
options: ParseStaticDocumentFromDOMSubtreeOptions = {}
|
|
57
|
+
): StaticDocument => {
|
|
58
|
+
const documentRoot = parseStaticElementOptions(subtreeRootElement);
|
|
147
59
|
|
|
148
|
-
return new
|
|
60
|
+
return new StaticDocument({
|
|
61
|
+
...options,
|
|
62
|
+
documentRoot,
|
|
63
|
+
});
|
|
149
64
|
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { MissingResourceBehavior } from './constants.ts';
|
|
2
|
-
import { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
3
|
-
import { FetchFormAttachment, FetchResource } from './resources.ts';
|
|
4
|
-
/**
|
|
5
|
-
* Options provided by a client to specify certain aspects of engine runtime
|
|
6
|
-
* behavior. These options will generally be intended to facilitate cooperation
|
|
7
|
-
* where there is mixed responsibility between a client and the engine, or where
|
|
8
|
-
* the engine may provide sensible defaults which a client could be expected to
|
|
9
|
-
* override or augment.
|
|
10
|
-
*/
|
|
11
|
-
export interface EngineConfig {
|
|
12
|
-
/**
|
|
13
|
-
* A client may specify a generic function for constructing stateful objects.
|
|
14
|
-
* The only hard requirement of this function is that it accepts an **object**
|
|
15
|
-
* and returns an object of the same shape. The engine will use this function
|
|
16
|
-
* to initialize client-facing state, and will mutate properties of the object
|
|
17
|
-
* when their corresponding state is changed.
|
|
18
|
-
*
|
|
19
|
-
* A client may use this function to provide its own implementation of
|
|
20
|
-
* reactivity with semantics like those described above. The mechanism of
|
|
21
|
-
* reactivity, if any, is at the discretion of the client. It is expected
|
|
22
|
-
* that clients providing this function will use a reactive subscribe-on-read
|
|
23
|
-
* mechanism to handle state updates conveyed by the engine.
|
|
24
|
-
*/
|
|
25
|
-
readonly stateFactory?: OpaqueReactiveObjectFactory;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* A client may specify an arbitrary {@link fetch}-like function for retrieving an XML XForm form
|
|
29
|
-
* definition.
|
|
30
|
-
*
|
|
31
|
-
* Notes:
|
|
32
|
-
*
|
|
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.
|
|
36
|
-
*
|
|
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}
|
|
75
|
-
*
|
|
76
|
-
* @default MissingResourceBehaviorDefault
|
|
77
|
-
*/
|
|
78
|
-
readonly missingResourceBehavior?: MissingResourceBehavior;
|
|
79
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { DescendantNodeViolationReference } from '../validation.ts';
|
|
2
|
-
import { SubmissionData } from './SubmissionData.ts';
|
|
3
|
-
import { SubmissionDefinition } from './SubmissionDefinition.ts';
|
|
4
|
-
import { SubmissionChunkedType } from './SubmissionOptions.ts';
|
|
5
|
-
export type SubmissionResultStatus = 'pending' | 'max-size-exceeded' | 'ready';
|
|
6
|
-
type SubmissionResultData<ChunkedType extends SubmissionChunkedType> = {
|
|
7
|
-
chunked: readonly [SubmissionData, ...SubmissionData[]];
|
|
8
|
-
monolithic: SubmissionData;
|
|
9
|
-
}[ChunkedType];
|
|
10
|
-
/**
|
|
11
|
-
* Provides detail about an individual submission attachment {@link File}s which
|
|
12
|
-
* exceeds the client-specified {@link maxSize} for a
|
|
13
|
-
* {@link SubmissionResult<'chunked'> | chunked submission result}. Clients may
|
|
14
|
-
* use this value to provide guidance to users.
|
|
15
|
-
*
|
|
16
|
-
* @todo We may want to consider (a) making {@link maxSize} a configuration the
|
|
17
|
-
* client can provide when initializing a form instance, rather than only on
|
|
18
|
-
* submission; and then (b) treating a maximum size violation as another kind of
|
|
19
|
-
* node-level violation. This would go beyond the kinds of validation specified
|
|
20
|
-
* by ODK XForms, but it would make a lot of _conceptual sense_.
|
|
21
|
-
*
|
|
22
|
-
* It would almost certainly be helpful to alert users to violations as the
|
|
23
|
-
* occur, rather than only at submission time (where they have likely already
|
|
24
|
-
* moved on). This is something clients can do without engine support, but it
|
|
25
|
-
* would likely promote good usability patterns if the engine makes it an
|
|
26
|
-
* obvious and uniform option at the main engine/client entrypoint.
|
|
27
|
-
*
|
|
28
|
-
* @todo If we consider the above, we'd want to reframe _this interface_ to
|
|
29
|
-
* match the shape of other {@link AnyViolation | violations} (adding it as a
|
|
30
|
-
* member of that union). We'd also likely eliminate
|
|
31
|
-
* {@link MaxSizeExceededResult} in the process, since
|
|
32
|
-
* {@link PendingSubmissionResult} would then cover the case.
|
|
33
|
-
*/
|
|
34
|
-
interface MaxSizeViolation {
|
|
35
|
-
/**
|
|
36
|
-
* Specifies the index of
|
|
37
|
-
* {@link SubmissionResultData<'chunked'> | chunked submission data} where a
|
|
38
|
-
* submission attachment {@link File} exceeds the client-specified
|
|
39
|
-
* {@link maxSize}.
|
|
40
|
-
*/
|
|
41
|
-
readonly dataIndex: number;
|
|
42
|
-
/**
|
|
43
|
-
* Specifies the name of the file which exceeds the client-specified
|
|
44
|
-
* {@link maxSize}. This name can also be used as a key to access the
|
|
45
|
-
* violating {@link File}/submission attachment, in the {@link SubmissionData}
|
|
46
|
-
* at the specified {@link dataIndex}.
|
|
47
|
-
*/
|
|
48
|
-
readonly fileName: string;
|
|
49
|
-
/**
|
|
50
|
-
* Reflects the client-specified maximum size for each chunk of a
|
|
51
|
-
* {@link SubmissionResult<'chunked'> | chunked submission result}.
|
|
52
|
-
*/
|
|
53
|
-
readonly maxSize: number;
|
|
54
|
-
/**
|
|
55
|
-
* Details the actual size of the violating {@link File}/submission
|
|
56
|
-
* attachment. Along with {@link maxSize}. Clients may use the delta between
|
|
57
|
-
* this value and {@link maxSize} to provide detailed guidance to users.
|
|
58
|
-
*/
|
|
59
|
-
readonly actualSize: number;
|
|
60
|
-
}
|
|
61
|
-
type SubmissionResultViolation = DescendantNodeViolationReference | MaxSizeViolation;
|
|
62
|
-
interface BaseSubmissionResult<ChunkedType extends SubmissionChunkedType> {
|
|
63
|
-
readonly status: SubmissionResultStatus;
|
|
64
|
-
readonly definition: SubmissionDefinition;
|
|
65
|
-
get violations(): readonly SubmissionResultViolation[] | null;
|
|
66
|
-
/**
|
|
67
|
-
* Submission data may be chunked according to the
|
|
68
|
-
* {@link SubmissionOptions.maxSize | maxSize submission option}
|
|
69
|
-
*/
|
|
70
|
-
readonly data: SubmissionResultData<ChunkedType>;
|
|
71
|
-
}
|
|
72
|
-
interface PendingSubmissionResult<ChunkedType extends SubmissionChunkedType> extends BaseSubmissionResult<ChunkedType> {
|
|
73
|
-
readonly status: 'pending';
|
|
74
|
-
get violations(): readonly DescendantNodeViolationReference[];
|
|
75
|
-
}
|
|
76
|
-
interface MaxSizeExceededResult extends BaseSubmissionResult<'chunked'> {
|
|
77
|
-
readonly status: 'max-size-exceeded';
|
|
78
|
-
get violations(): readonly MaxSizeViolation[];
|
|
79
|
-
}
|
|
80
|
-
interface ReadySubmissionResult<ChunkedType extends SubmissionChunkedType> extends BaseSubmissionResult<ChunkedType> {
|
|
81
|
-
readonly status: 'ready';
|
|
82
|
-
get violations(): null;
|
|
83
|
-
}
|
|
84
|
-
type CommonSubmissionResult<ChunkedType extends SubmissionChunkedType> = PendingSubmissionResult<ChunkedType> | ReadySubmissionResult<ChunkedType>;
|
|
85
|
-
export type ChunkedSubmissionResult = CommonSubmissionResult<'chunked'> | MaxSizeExceededResult;
|
|
86
|
-
export type MonolithicSubmissionResult = CommonSubmissionResult<'monolithic'>;
|
|
87
|
-
export type SubmissionResult<ChunkedType extends SubmissionChunkedType> = {
|
|
88
|
-
chunked: ChunkedSubmissionResult;
|
|
89
|
-
monolithic: MonolithicSubmissionResult;
|
|
90
|
-
}[ChunkedType];
|
|
91
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface SubmissionState {
|
|
2
|
-
/**
|
|
3
|
-
* Represents the serialized XML state of a given node, as it will be prepared
|
|
4
|
-
* for submission. The value produced in {@link RootNode.submissionState} is
|
|
5
|
-
* the same serialization which will be produced for the complete submission.
|
|
6
|
-
*
|
|
7
|
-
* @todo Note that this particular aspect of the design doesn't yet address
|
|
8
|
-
* production of unique file names. As such, this may change as we introduce
|
|
9
|
-
* affected data types (and their supporting nodes).
|
|
10
|
-
*/
|
|
11
|
-
get submissionXML(): string;
|
|
12
|
-
}
|