@getodk/xforms-engine 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/dist/client/BaseNode.d.ts +14 -3
  2. package/dist/client/BaseValueNode.d.ts +32 -0
  3. package/dist/client/EngineConfig.d.ts +49 -48
  4. package/dist/client/InputNode.d.ts +53 -0
  5. package/dist/client/ModelValueNode.d.ts +12 -7
  6. package/dist/client/NoteNode.d.ts +2 -2
  7. package/dist/client/RootNode.d.ts +34 -7
  8. package/dist/client/SelectNode.d.ts +2 -2
  9. package/dist/client/ValueType.d.ts +3 -0
  10. package/dist/client/constants.d.ts +50 -0
  11. package/dist/client/hierarchy.d.ts +4 -4
  12. package/dist/client/identity.d.ts +14 -0
  13. package/dist/client/node-types.d.ts +2 -1
  14. package/dist/client/resources.d.ts +93 -0
  15. package/dist/client/submission/SubmissionData.d.ts +7 -0
  16. package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
  17. package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
  18. package/dist/client/submission/SubmissionOptions.d.ts +23 -0
  19. package/dist/client/submission/SubmissionResult.d.ts +91 -0
  20. package/dist/client/submission/SubmissionState.d.ts +12 -0
  21. package/dist/client/validation.d.ts +2 -2
  22. package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
  23. package/dist/error/ValueTypeInvariantError.d.ts +17 -0
  24. package/dist/error/XPathFunctionalityError.d.ts +14 -0
  25. package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
  26. package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
  27. package/dist/index.d.ts +10 -1
  28. package/dist/index.js +10856 -8585
  29. package/dist/index.js.map +1 -1
  30. package/dist/instance/Group.d.ts +9 -4
  31. package/dist/instance/InputControl.d.ts +36 -0
  32. package/dist/instance/ModelValue.d.ts +16 -26
  33. package/dist/instance/Note.d.ts +10 -3
  34. package/dist/instance/PrimaryInstance.d.ts +84 -0
  35. package/dist/instance/Root.d.ts +29 -25
  36. package/dist/instance/SelectField.d.ts +10 -2
  37. package/dist/instance/Subtree.d.ts +10 -5
  38. package/dist/instance/TriggerControl.d.ts +10 -3
  39. package/dist/instance/abstract/DescendantNode.d.ts +31 -23
  40. package/dist/instance/abstract/InstanceNode.d.ts +49 -29
  41. package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
  42. package/dist/instance/abstract/ValueNode.d.ts +48 -0
  43. package/dist/instance/hierarchy.d.ts +9 -8
  44. package/dist/instance/identity.d.ts +2 -7
  45. package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
  46. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
  47. package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
  48. package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
  49. package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
  50. package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
  51. package/dist/instance/internal-api/ValueContext.d.ts +2 -1
  52. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
  53. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
  54. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
  55. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
  56. package/dist/instance/repeat/BaseRepeatRange.d.ts +39 -83
  57. package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
  58. package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
  59. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
  60. package/dist/instance/resource.d.ts +1 -1
  61. package/dist/instance/text/TextRange.d.ts +1 -1
  62. package/dist/instance/unsupported/RangeControl.d.ts +3 -1
  63. package/dist/instance/unsupported/RankControl.d.ts +3 -1
  64. package/dist/instance/unsupported/UploadControl.d.ts +3 -1
  65. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
  66. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
  67. package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
  68. package/dist/integration/xpath/adapter/kind.d.ts +32 -0
  69. package/dist/integration/xpath/adapter/names.d.ts +16 -0
  70. package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
  71. package/dist/integration/xpath/adapter/values.d.ts +2 -0
  72. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
  73. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
  74. package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
  75. package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
  76. package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
  77. package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
  78. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
  79. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
  80. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
  81. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
  82. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
  83. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
  84. package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
  85. package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
  86. package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
  87. package/dist/lib/codecs/ValueCodec.d.ts +30 -0
  88. package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
  89. package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
  90. package/dist/lib/dom/query.d.ts +3 -0
  91. package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
  92. package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
  93. package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
  94. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
  95. package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
  96. package/dist/lib/reactivity/createValueState.d.ts +6 -10
  97. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
  98. package/dist/lib/xml-serialization.d.ts +41 -0
  99. package/dist/parse/XFormDOM.d.ts +18 -7
  100. package/dist/parse/XFormDefinition.d.ts +1 -2
  101. package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
  102. package/dist/parse/body/BodyDefinition.d.ts +3 -3
  103. package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
  104. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
  105. package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
  106. package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
  107. package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
  108. package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
  109. package/dist/parse/model/BindDefinition.d.ts +4 -5
  110. package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
  111. package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
  112. package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
  113. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
  114. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
  115. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
  116. package/dist/parse/model/LeafNodeDefinition.d.ts +3 -1
  117. package/dist/parse/model/ModelBindMap.d.ts +1 -1
  118. package/dist/parse/model/ModelDefinition.d.ts +2 -0
  119. package/dist/parse/model/NodeDefinition.d.ts +0 -1
  120. package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
  121. package/dist/parse/model/RootDefinition.d.ts +3 -2
  122. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
  123. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
  124. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
  125. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
  126. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
  127. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
  128. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
  129. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
  130. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
  131. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
  132. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
  133. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
  134. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
  135. package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
  136. package/dist/solid.js +8174 -5921
  137. package/dist/solid.js.map +1 -1
  138. package/package.json +13 -11
  139. package/src/client/BaseNode.ts +16 -6
  140. package/src/client/BaseValueNode.ts +35 -0
  141. package/src/client/EngineConfig.ts +52 -51
  142. package/src/client/InputNode.ts +77 -0
  143. package/src/client/ModelValueNode.ts +30 -7
  144. package/src/client/NoteNode.ts +2 -2
  145. package/src/client/RootNode.ts +37 -7
  146. package/src/client/SelectNode.ts +3 -3
  147. package/src/client/ValueType.ts +4 -0
  148. package/src/client/constants.ts +67 -0
  149. package/src/client/hierarchy.ts +5 -5
  150. package/src/client/identity.ts +16 -0
  151. package/src/client/node-types.ts +12 -6
  152. package/src/client/resources.ts +118 -0
  153. package/src/client/submission/SubmissionData.ts +12 -0
  154. package/src/client/submission/SubmissionDefinition.ts +16 -0
  155. package/src/client/submission/SubmissionInstanceFile.ts +9 -0
  156. package/src/client/submission/SubmissionOptions.ts +28 -0
  157. package/src/client/submission/SubmissionResult.ts +124 -0
  158. package/src/client/submission/SubmissionState.ts +14 -0
  159. package/src/client/validation.ts +2 -2
  160. package/src/error/ErrorProductionDesignPendingError.ts +6 -0
  161. package/src/error/ValueTypeInvariantError.ts +22 -0
  162. package/src/error/XPathFunctionalityError.ts +26 -0
  163. package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
  164. package/src/error/XPathFunctionalityPendingError.ts +18 -0
  165. package/src/index.ts +10 -1
  166. package/src/instance/Group.ts +17 -5
  167. package/src/instance/InputControl.ts +119 -0
  168. package/src/instance/ModelValue.ts +47 -54
  169. package/src/instance/Note.ts +24 -8
  170. package/src/instance/PrimaryInstance.ts +244 -0
  171. package/src/instance/Root.ts +62 -134
  172. package/src/instance/SelectField.ts +56 -19
  173. package/src/instance/Subtree.ts +19 -7
  174. package/src/instance/TriggerControl.ts +23 -6
  175. package/src/instance/abstract/DescendantNode.ts +90 -45
  176. package/src/instance/abstract/InstanceNode.ts +103 -105
  177. package/src/instance/abstract/UnsupportedControl.ts +28 -5
  178. package/src/instance/abstract/ValueNode.ts +127 -0
  179. package/src/instance/children.ts +9 -10
  180. package/src/instance/hierarchy.ts +19 -15
  181. package/src/instance/identity.ts +3 -9
  182. package/src/instance/index.ts +25 -7
  183. package/src/instance/internal-api/EvaluationContext.ts +60 -13
  184. package/src/instance/internal-api/InstanceConfig.ts +9 -2
  185. package/src/instance/internal-api/InstanceValueContext.ts +24 -0
  186. package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
  187. package/src/instance/internal-api/TranslationContext.ts +3 -2
  188. package/src/instance/internal-api/ValidationContext.ts +3 -4
  189. package/src/instance/internal-api/ValueContext.ts +2 -1
  190. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
  191. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
  192. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
  193. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
  194. package/src/instance/repeat/BaseRepeatRange.ts +50 -131
  195. package/src/instance/repeat/RepeatInstance.ts +20 -46
  196. package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
  197. package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
  198. package/src/instance/resource.ts +1 -1
  199. package/src/instance/text/TextChunk.ts +1 -1
  200. package/src/instance/unsupported/RangeControl.ts +5 -1
  201. package/src/instance/unsupported/RankControl.ts +5 -1
  202. package/src/instance/unsupported/UploadControl.ts +5 -1
  203. package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
  204. package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
  205. package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
  206. package/src/integration/xpath/adapter/kind.ts +114 -0
  207. package/src/integration/xpath/adapter/names.ts +99 -0
  208. package/src/integration/xpath/adapter/traversal.ts +228 -0
  209. package/src/integration/xpath/adapter/values.ts +5 -0
  210. package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
  211. package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
  212. package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
  213. package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
  214. package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
  215. package/src/integration/xpath/static-dom/StaticText.ts +28 -0
  216. package/src/lib/client-reactivity/README.md +0 -0
  217. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
  218. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
  219. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
  220. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
  221. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
  222. package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
  223. package/src/lib/codecs/DecimalValueCodec.ts +46 -0
  224. package/src/lib/codecs/IntValueCodec.ts +100 -0
  225. package/src/lib/codecs/StringValueCodec.ts +11 -0
  226. package/src/lib/codecs/ValueCodec.ts +106 -0
  227. package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
  228. package/src/lib/codecs/getSharedValueCodec.ts +77 -0
  229. package/src/lib/dom/query.ts +7 -0
  230. package/src/lib/reactivity/createChildrenState.ts +8 -6
  231. package/src/lib/reactivity/createComputedExpression.ts +57 -34
  232. package/src/lib/reactivity/createInstanceValueState.ts +166 -0
  233. package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
  234. package/src/lib/reactivity/createSelectItems.ts +21 -21
  235. package/src/lib/reactivity/createTranslationState.ts +61 -0
  236. package/src/lib/reactivity/createValueState.ts +62 -120
  237. package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
  238. package/src/lib/reactivity/text/createTextRange.ts +4 -3
  239. package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
  240. package/src/lib/reactivity/validation/createValidation.ts +2 -3
  241. package/src/lib/xml-serialization.ts +96 -0
  242. package/src/parse/XFormDOM.ts +110 -75
  243. package/src/parse/XFormDefinition.ts +1 -6
  244. package/src/parse/attachments/FormAttachmentResource.ts +40 -0
  245. package/src/parse/body/BodyDefinition.ts +3 -3
  246. package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
  247. package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
  248. package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
  249. package/src/parse/expression/abstract/DependencyContext.ts +0 -26
  250. package/src/parse/expression/abstract/DependentExpression.ts +2 -13
  251. package/src/parse/model/BindDefinition.ts +5 -8
  252. package/src/parse/model/BindTypeDefinition.ts +175 -0
  253. package/src/parse/model/DescendentNodeDefinition.ts +0 -6
  254. package/src/parse/model/FormSubmissionDefinition.ts +44 -0
  255. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
  256. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
  257. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
  258. package/src/parse/model/LeafNodeDefinition.ts +4 -1
  259. package/src/parse/model/ModelBindMap.ts +6 -8
  260. package/src/parse/model/ModelDefinition.ts +6 -1
  261. package/src/parse/model/NodeDefinition.ts +0 -3
  262. package/src/parse/model/NoteNodeDefinition.ts +3 -3
  263. package/src/parse/model/RootDefinition.ts +2 -1
  264. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
  265. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
  266. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
  267. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
  268. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
  269. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
  270. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
  271. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
  272. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
  273. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
  274. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
  275. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
  276. package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
  277. package/src/parse/xpath/semantic-analysis.ts +29 -0
  278. package/dist/client/StringNode.d.ts +0 -46
  279. package/dist/instance/StringField.d.ts +0 -44
  280. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
  281. package/dist/parse/XFormDataType.d.ts +0 -25
  282. package/src/client/StringNode.ts +0 -52
  283. package/src/instance/StringField.ts +0 -120
  284. package/src/instance/internal-api/SubscribableDependency.ts +0 -61
  285. package/src/parse/XFormDataType.ts +0 -62
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getodk/xforms-engine",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "XForms engine for ODK Web Forms",
6
6
  "type": "module",
@@ -29,7 +29,7 @@
29
29
  "README.md"
30
30
  ],
31
31
  "engines": {
32
- "node": "^18.20.4 || ^20.17.0 || ^22.8.0",
32
+ "node": "^18.20.4 || ^20.17.0 || ^22.9.0",
33
33
  "yarn": "1.22.22"
34
34
  },
35
35
  "scripts": {
@@ -54,22 +54,24 @@
54
54
  "test:types": "tsc --project ./tsconfig.json --emitDeclarationOnly false --noEmit"
55
55
  },
56
56
  "dependencies": {
57
- "solid-js": "^1.8.22"
57
+ "papaparse": "^5.4.1",
58
+ "solid-js": "^1.9.1"
58
59
  },
59
60
  "devDependencies": {
60
61
  "@babel/core": "^7.25.2",
61
62
  "@getodk/tree-sitter-xpath": "0.1.2",
62
- "@getodk/xpath": "0.2.0",
63
- "@playwright/test": "^1.46.1",
64
- "@vitest/browser": "^2.0.5",
63
+ "@getodk/xpath": "0.3.0",
64
+ "@playwright/test": "^1.47.2",
65
+ "@types/papaparse": "^5.3.15",
66
+ "@vitest/browser": "^2.1.1",
65
67
  "babel-plugin-transform-jsbi-to-bigint": "^1.4.0",
66
68
  "http-server": "^14.1.1",
67
- "jsdom": "^25.0.0",
68
- "typedoc": "^0.26.6",
69
- "vite": "^5.4.3",
70
- "vite-plugin-dts": "^4.1.0",
69
+ "jsdom": "^25.0.1",
70
+ "typedoc": "^0.26.7",
71
+ "vite": "^5.4.8",
72
+ "vite-plugin-dts": "^4.2.2",
71
73
  "vite-plugin-no-bundle": "^4.0.0",
72
- "vitest": "^2.0.5"
74
+ "vitest": "^2.1.1"
73
75
  },
74
76
  "peerDependencies": {
75
77
  "solid-js": "^1.8.18"
@@ -3,7 +3,9 @@ import type { AnyNodeDefinition } from '../parse/model/NodeDefinition.ts';
3
3
  import type { NodeAppearances } from './NodeAppearances.ts';
4
4
  import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
5
5
  import type { TextRange } from './TextRange.ts';
6
+ import type { FormNodeID } from './identity.ts';
6
7
  import type { InstanceNodeType } from './node-types.ts';
8
+ import type { SubmissionState } from './submission/SubmissionState.ts';
7
9
  import type {
8
10
  AncestorNodeValidationState,
9
11
  LeafNodeValidationState,
@@ -129,8 +131,6 @@ export interface BaseNodeState {
129
131
  get value(): unknown;
130
132
  }
131
133
 
132
- type FormNodeID = string;
133
-
134
134
  /**
135
135
  * Base interface for common/shared aspects of any node type.
136
136
  */
@@ -189,15 +189,13 @@ export interface BaseNode {
189
189
  // 2. If `parent` does become nullable state, how best to convey the same
190
190
  // information for removed descendants. Some ideas:
191
191
  //
192
- // - Apply null-as-removed recursively. This wouldn't technically be true
193
- // for the engine's current use of a DOM backing store (but that's an
194
- // implementation detail clients don't/shouldn't care about).
192
+ // - Apply null-as-removed recursively.
195
193
  //
196
194
  // - Borrow the browser DOM's notion of node "connected"-ness. When a node
197
195
  // is removed, its `isConnected` property is `false`. The same is true
198
196
  // for any of its descendants, even though they retain their own direct
199
197
  // parent reference.
200
- readonly parent: BaseNode | null;
198
+ readonly parent: unknown;
201
199
 
202
200
  /**
203
201
  * Each node provides a discrete object representing the stateful aspects\* of
@@ -251,4 +249,16 @@ export interface BaseNode {
251
249
  * clients to explicitly pause and resume recomputation.
252
250
  */
253
251
  readonly validationState: NodeValidationState;
252
+
253
+ /**
254
+ * Represents the current submission state of the node.
255
+ *
256
+ * @see {@link SubmissionState.submissionXML} for additional detail.
257
+ *
258
+ * @todo Consider whether this can (should) be merged with
259
+ * {@link currentState}, while providing the same client-reactivity
260
+ * guarantees. (The challenge there is in defining client-reactive state which
261
+ * self-referentially derives state from its own definition.)
262
+ */
263
+ readonly submissionState: SubmissionState;
254
264
  }
@@ -0,0 +1,35 @@
1
+ import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
2
+ import type { BaseNode, BaseNodeState } from './BaseNode.ts';
3
+ import type { GeneralParentNode } from './hierarchy.ts';
4
+ import type { LeafNodeType } from './node-types.ts';
5
+ import type { LeafNodeValidationState } from './validation.ts';
6
+ import type { ValueType } from './ValueType.ts';
7
+
8
+ export interface BaseValueNodeState<Value> extends BaseNodeState {
9
+ get children(): null;
10
+ get valueOptions(): null;
11
+ get value(): Value;
12
+
13
+ /**
14
+ * Reflects the serialized string representation of a {@link BaseValueNode}'s
15
+ * {@link value} state. This representation allows access to the node's value
16
+ * _as primary instance state_. In other words, this is the value which:
17
+ *
18
+ * - would be serialized as a text node in
19
+ * {@link SubmissionState.submissionXML} (note: this value is **NOT**
20
+ * escaped for XML serialization, as it is there)
21
+ *
22
+ * - is used when the node's value is referenced in any of a form's XPath
23
+ * expressions
24
+ */
25
+ get instanceValue(): string;
26
+ }
27
+
28
+ export interface BaseValueNode<V extends ValueType = ValueType, Value = string> extends BaseNode {
29
+ readonly nodeType: LeafNodeType;
30
+ readonly valueType: V;
31
+ readonly definition: LeafNodeDefinition;
32
+ readonly parent: GeneralParentNode;
33
+ readonly currentState: BaseValueNodeState<Value>;
34
+ readonly validationState: LeafNodeValidationState;
35
+ }
@@ -1,35 +1,7 @@
1
+ import type { initializeForm } from '../instance/index.ts';
2
+ import type { MissingResourceBehavior, MissingResourceBehaviorDefault } from './constants.ts';
1
3
  import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
2
-
3
- /**
4
- * @todo this is currently a strict subset of the web standard `Response`. Is it
5
- * sufficient? Ways it might not be:
6
- *
7
- * - No way to convey metadata about the resource
8
- * - Ambiguous if a client supplies an alternative implementation which doesn't
9
- * exhaust the body on access
10
- */
11
- export interface FetchResourceResponse {
12
- readonly ok?: boolean;
13
- readonly body?: ReadableStream<Uint8Array> | null;
14
- readonly bodyUsed?: boolean;
15
-
16
- readonly blob: () => Promise<Blob>;
17
- readonly text: () => Promise<string>;
18
- }
19
-
20
- /**
21
- * @todo this is a strict subset of the web standard `fetch` interface. It
22
- * implicitly assumes that the engine itself will only ever issue `GET`-like
23
- * requests. It also provides no further request-like semantics to the engine.
24
- * This is presumed sufficient for now, but notably doesn't expose any notion of
25
- * content negotiation (e.g. the ability to supply `Accept` headers).
26
- *
27
- * This also completely ignores any notion of mapping
28
- * {@link https://getodk.github.io/xforms-spec/#uris | `jr:` URLs} to their
29
- * actual resources (likely, but not necessarily, accessed at a corresponding
30
- * HTTP URL).
31
- */
32
- export type FetchResource = (resource: URL) => Promise<FetchResourceResponse>;
4
+ import type { FetchFormAttachment, FetchResource } from './resources.ts';
33
5
 
34
6
  /**
35
7
  * Options provided by a client to specify certain aspects of engine runtime
@@ -55,29 +27,58 @@ export interface EngineConfig {
55
27
  readonly stateFactory?: OpaqueReactiveObjectFactory;
56
28
 
57
29
  /**
58
- * A client may specify a generic function for retrieving resources referenced
59
- * by a form, such as:
60
30
  *
61
- * - Form definitions themselves (if not provided directly to the engine by
62
- * the client)
63
- * - External secondary instances
64
- * - Media (images, audio, video, etc.)
31
+ * A client may specify an arbitrary {@link fetch}-like function for retrieving an XML XForm form
32
+ * definition.
33
+ *
34
+ * Notes:
35
+ *
36
+ * - This configuration will only be consuled for calls to
37
+ * {@link initializeForm} with a URL referencing an XML XForm definition. It
38
+ * will be ignored for calls passing an XML XForm form definition directly.
39
+ *
40
+ * - For calls to {@link initializeForm} with a URL, if this configuration is
41
+ * not specified it will default to the global {@link fetch} function (if
42
+ * one is defined).
43
+ */
44
+ readonly fetchFormDefinition?: FetchResource;
45
+
46
+ /**
47
+ * A client may specify an arbitrary {@link fetch}-like function to retrieve a
48
+ * form's attachments, i.e. any `jr:` URL referenced by the form (as specified
49
+ * by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
50
+ *
51
+ * Notes:
65
52
  *
66
- * The function is expected to be a subset of the
67
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API},
68
- * performing `GET` requests for:
53
+ * - This configuration will be consulted for all supported form attachments,
54
+ * as a part of {@link initializeForm | form initialization}.
69
55
  *
70
- * - Text resources (e.g. XML, CSV, JSON/GeoJSON)
71
- * - Binary resources (e.g. media)
72
- * - Optionally streamed binary data of either (e.g. for optimized
73
- * presentation of audio/video)
56
+ * - If this configuration is not specified it will default to the global
57
+ * {@link fetch} function (if one is defined).
58
+ *
59
+ * This default behavior will typically result in failure to load form
60
+ * attachments—and in most cases this will also cause
61
+ * {@link initializeForm | form initialization} to fail overall—with the
62
+ * following exceptions:
63
+ *
64
+ * - **CLIENT-SPECIFIC:** Usage in coordination with a client-implemented
65
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Serivce Worker},
66
+ * which can intercept network requests **generally**. Clients already using
67
+ * a Service Worker may opt for the convenience of handling network requests
68
+ * for `jr:` URLs along with any other network interception logic. Client
69
+ * implementors should be warned, however, that such `jr:` URLs are not
70
+ * namespaced or otherwise scoped to a particular form; such a client would
71
+ * therefore inherently need to coordinate state between the Service Worker
72
+ * and the main thread (or whatever other realm calls
73
+ * {@link initializeForm}).
74
+ */
75
+ readonly fetchFormAttachment?: FetchFormAttachment;
76
+
77
+ /**
78
+ * @see {@link MissingResourceBehavior}
79
+ * @see {@link MissingResourceBehaviorDefault}
74
80
  *
75
- * If provided by a client, this function will be used by the engine to
76
- * retrieve any such resource, as required for engine functionality. If
77
- * absent, the engine will use the native `fetch` function (if available, a
78
- * polyfill otherwise). Clients may use this function to provide resources
79
- * from sources other than the network, (or even in a test client to provide
80
- * e.g. resources from test fixtures).
81
+ * @default MissingResourceBehaviorDefault
81
82
  */
82
- readonly fetchResource?: FetchResource;
83
+ readonly missingResourceBehavior?: MissingResourceBehavior;
83
84
  }
@@ -0,0 +1,77 @@
1
+ import type { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
2
+ import type { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
3
+ import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
4
+ import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
5
+ import type { NodeAppearances } from './NodeAppearances.ts';
6
+ import type { RootNode } from './RootNode.ts';
7
+ import type { ValueType } from './ValueType.ts';
8
+ import type { GeneralParentNode } from './hierarchy.ts';
9
+ import type { LeafNodeValidationState } from './validation.ts';
10
+
11
+ export type InputValue<V extends ValueType> = RuntimeValue<V>;
12
+
13
+ export type InputNodeInputValue<V extends ValueType> = RuntimeInputValue<V>;
14
+
15
+ export interface InputNodeState<V extends ValueType> extends BaseValueNodeState<InputValue<V>> {
16
+ get children(): null;
17
+ get valueOptions(): null;
18
+
19
+ /**
20
+ * Reflects the current value of a {@link InputNode}. This value may be
21
+ * populated when a form is loaded, and it may be updated by certain
22
+ * computations defined by the form. It may also be updated by a client, using
23
+ * the {@link InputNode.setValue} method.
24
+ */
25
+ get value(): InputValue<V>;
26
+ }
27
+
28
+ export interface InputDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
29
+ readonly bodyElement: InputControlDefinition;
30
+ }
31
+
32
+ export type InputNodeAppearances = NodeAppearances<InputDefinition>;
33
+
34
+ /**
35
+ * A node corresponding to form field defined as an
36
+ * {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<input>`},
37
+ * which a user-facing client would likely present for a user to fill..
38
+ */
39
+ export interface InputNode<V extends ValueType = ValueType>
40
+ extends BaseValueNode<V, InputValue<V>> {
41
+ readonly nodeType: 'input';
42
+ readonly valueType: V;
43
+ readonly appearances: InputNodeAppearances;
44
+ readonly definition: InputDefinition<V>;
45
+ readonly root: RootNode;
46
+ readonly parent: GeneralParentNode;
47
+ readonly currentState: InputNodeState<V>;
48
+ readonly validationState: LeafNodeValidationState;
49
+
50
+ /**
51
+ * For use by a client to update the value of an {@link InputNode}.
52
+ */
53
+ setValue(value: InputNodeInputValue<V>): RootNode;
54
+ }
55
+
56
+ export type StringInputNode = InputNode<'string'>;
57
+ export type IntInputNode = InputNode<'int'>;
58
+ export type DecimalInputNode = InputNode<'decimal'>;
59
+
60
+ // prettier-ignore
61
+ type SupportedInputValueType =
62
+ // eslint-disable-next-line @typescript-eslint/sort-type-constituents
63
+ | 'string'
64
+ | 'int'
65
+ | 'decimal';
66
+
67
+ type TemporaryStringValueType = Exclude<ValueType, SupportedInputValueType>;
68
+
69
+ export type TemporaryStringValueInputNode = InputNode<TemporaryStringValueType>;
70
+
71
+ // prettier-ignore
72
+ export type AnyInputNode =
73
+ // eslint-disable-next-line @typescript-eslint/sort-type-constituents
74
+ | StringInputNode
75
+ | IntInputNode
76
+ | DecimalInputNode
77
+ | TemporaryStringValueInputNode;
@@ -1,10 +1,15 @@
1
+ import type { RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
1
2
  import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
2
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
3
+ import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
3
4
  import type { GeneralParentNode } from './hierarchy.ts';
4
5
  import type { RootNode } from './RootNode.ts';
5
6
  import type { LeafNodeValidationState } from './validation.ts';
7
+ import type { ValueType } from './ValueType.ts';
6
8
 
7
- export interface ModelValueNodeState extends BaseNodeState {
9
+ export type ModelValue<V extends ValueType> = RuntimeValue<V>;
10
+
11
+ export interface ModelValueNodeState<V extends ValueType>
12
+ extends BaseValueNodeState<ModelValue<V>> {
8
13
  get label(): null;
9
14
  get hint(): null;
10
15
  get children(): null;
@@ -15,10 +20,11 @@ export interface ModelValueNodeState extends BaseNodeState {
15
20
  * populated when a form is loaded, and it may be updated by certain
16
21
  * computations defined by the form.
17
22
  */
18
- get value(): string;
23
+ get value(): ModelValue<V>;
19
24
  }
20
25
 
21
- export interface ModelValueDefinition extends LeafNodeDefinition {
26
+ export interface ModelValueDefinition<V extends ValueType = ValueType>
27
+ extends LeafNodeDefinition<V> {
22
28
  readonly bodyElement: null;
23
29
  }
24
30
 
@@ -29,12 +35,29 @@ export interface ModelValueDefinition extends LeafNodeDefinition {
29
35
  * - a leaf/value node (i.e. it has no element children; it may be defined in
30
36
  * the form's `<model>` as either an {@link Element} or {@link Attr})
31
37
  */
32
- export interface ModelValueNode extends BaseNode {
38
+ export interface ModelValueNode<V extends ValueType = ValueType>
39
+ extends BaseValueNode<V, ModelValue<V>> {
33
40
  readonly nodeType: 'model-value';
41
+ readonly valueType: V;
34
42
  readonly appearances: null;
35
- readonly definition: ModelValueDefinition;
43
+ readonly definition: ModelValueDefinition<V>;
36
44
  readonly root: RootNode;
37
45
  readonly parent: GeneralParentNode;
38
- readonly currentState: ModelValueNodeState;
46
+ readonly currentState: ModelValueNodeState<V>;
39
47
  readonly validationState: LeafNodeValidationState;
40
48
  }
49
+
50
+ export type AnyModelValueNode =
51
+ | ModelValueNode<'barcode'>
52
+ | ModelValueNode<'binary'>
53
+ | ModelValueNode<'boolean'>
54
+ | ModelValueNode<'date'>
55
+ | ModelValueNode<'dateTime'>
56
+ | ModelValueNode<'decimal'>
57
+ | ModelValueNode<'geopoint'>
58
+ | ModelValueNode<'geoshape'>
59
+ | ModelValueNode<'geotrace'>
60
+ | ModelValueNode<'int'>
61
+ | ModelValueNode<'intent'>
62
+ | ModelValueNode<'string'>
63
+ | ModelValueNode<'time'>;
@@ -1,4 +1,4 @@
1
- import type { InputDefinition } from '../parse/body/control/InputDefinition.ts';
1
+ import type { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
2
2
  import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
3
  import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import type { GeneralParentNode } from './hierarchy.ts';
@@ -52,7 +52,7 @@ export interface NoteNodeState extends BaseNodeState {
52
52
  }
53
53
 
54
54
  export interface NoteDefinition extends LeafNodeDefinition {
55
- readonly bodyElement: InputDefinition;
55
+ readonly bodyElement: InputControlDefinition;
56
56
  }
57
57
 
58
58
  export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
@@ -3,14 +3,14 @@ import type { RootDefinition } from '../parse/model/RootDefinition.ts';
3
3
  import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import type { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
5
5
  import type { GeneralChildNode } from './hierarchy.ts';
6
+ import type { SubmissionChunkedType, SubmissionOptions } from './submission/SubmissionOptions.ts';
7
+ import type { SubmissionResult } from './submission/SubmissionResult.ts';
6
8
  import type { AncestorNodeValidationState } from './validation.ts';
7
9
 
8
10
  export interface RootNodeState extends BaseNodeState {
9
11
  /**
10
- * This, along with {@link RootNode.languages} is the most significant break
11
- in consistency across node types' state and static properties. Exposing it
12
- across all node types seems like a point of potential confusion, so this
13
- particular divergence seems like the most reasonable compromise.
12
+ * @todo If we ever expose an interface to the primary instance document, it
13
+ * would make sense to move this state up.
14
14
  */
15
15
  get activeLanguage(): ActiveLanguage;
16
16
 
@@ -46,15 +46,45 @@ export interface RootNode extends BaseNode {
46
46
 
47
47
  readonly definition: RootDefinition;
48
48
  readonly root: RootNode;
49
- readonly parent: null;
49
+ readonly parent: unknown;
50
50
  readonly currentState: RootNodeState;
51
51
  readonly validationState: AncestorNodeValidationState;
52
52
 
53
53
  /**
54
- * @todo as with {@link RootNodeState.activeLanguage}, this is the most
55
- * significant break in consistency across node types.
54
+ * @todo as discussed on {@link RootNodeState.activeLanguage}
56
55
  */
57
56
  readonly languages: FormLanguages;
58
57
 
59
58
  setLanguage(language: FormLanguage): RootNode;
59
+
60
+ /**
61
+ * Prepares the current form instance state for submission.
62
+ *
63
+ * A {@link SubmissionResult} will be prepared even if the current form state
64
+ * includes `constraint` or `required` violations. This is intended to serve
65
+ * two purposes:
66
+ *
67
+ * - A client may effectively use this method as a part of its own "submit"
68
+ * routine, and use any violations included in the {@link SubmissionResult}
69
+ * to prompt users to address those violations.
70
+ *
71
+ * - A client may inspect the submission state of a form at any time.
72
+ * Depending on the client and use case, this may be a convenience (e.g. for
73
+ * developers to inspect that form state at a current point in time); or it
74
+ * may provide necessary functionality (e.g. for test or tooling clients).
75
+ *
76
+ * Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
77
+ * a fast operation. It may even be nearly instantaneous, or roughly
78
+ * proportionate to the size of the form itself. However, this method is
79
+ * designed to be asynchronous out of an abundance of caution, anticipating
80
+ * that some as-yet undeveloped operations on binary data (e.g. form
81
+ * attachments) may themselves impose asynchrony (i.e. by interfaces provided
82
+ * by the platform and/or external dependencies).
83
+ *
84
+ * A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
85
+ * {@link SubmissionResult<'chunked'>} will be produced, with form attachments
86
+ */
87
+ prepareSubmission<ChunkedType extends SubmissionChunkedType>(
88
+ options?: SubmissionOptions<ChunkedType>
89
+ ): Promise<SubmissionResult<ChunkedType>>;
60
90
  }
@@ -1,9 +1,9 @@
1
1
  import type { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
2
2
  import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
3
  import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import type { InputNode } from './InputNode.ts';
4
5
  import type { NodeAppearances } from './NodeAppearances.ts';
5
6
  import type { RootNode } from './RootNode.ts';
6
- import type { StringNode } from './StringNode.ts';
7
7
  import type { TextRange } from './TextRange.ts';
8
8
  import type { GeneralParentNode } from './hierarchy.ts';
9
9
  import type { LeafNodeValidationState } from './validation.ts';
@@ -60,7 +60,7 @@ export interface SelectNode extends BaseNode {
60
60
  * - For fields defined with an XForms `<select1>`, calling this method will
61
61
  * replace the selection (if any).
62
62
  *
63
- * @todo @see {@link StringNode.setValue} re: write restrictions
63
+ * @todo @see {@link InputNode.setValue} re: write restrictions
64
64
  * @todo @see {@link SelectNodeState.value} re: breaking up the types
65
65
  */
66
66
  select(item: SelectItem): RootNode;
@@ -69,7 +69,7 @@ export interface SelectNode extends BaseNode {
69
69
  * For use by a client to remove an item from the node's
70
70
  * {@link SelectNodeState.value}.
71
71
  *
72
- * @todo @see {@link StringNode.setValue} re: write restrictions
72
+ * @todo @see {@link InputNode.setValue} re: write restrictions
73
73
  */
74
74
  deselect(item: SelectItem): RootNode;
75
75
  }
@@ -0,0 +1,4 @@
1
+ import type { ExpandUnion } from '@getodk/common/types/helpers.js';
2
+ import type { BindType } from '../parse/model/BindTypeDefinition.ts';
3
+
4
+ export type ValueType = ExpandUnion<BindType>;
@@ -1,5 +1,66 @@
1
+ import type { PrimaryInstance } from '../instance/PrimaryInstance.ts';
2
+ import type { InitializeForm } from './index.ts';
1
3
  import type { ValidationTextRole } from './TextRange.ts';
2
4
 
5
+ export const MISSING_RESOURCE_BEHAVIOR = {
6
+ /**
7
+ * When this behavior is configured, {@link InitializeForm | initializing} a
8
+ * {@link PrimaryInstance} for a form which references any **missing**
9
+ * resources will fail, producing an error to the calling client.
10
+ *
11
+ * @see {@link MissingResourceBehavior}
12
+ */
13
+ ERROR: 'ERROR',
14
+
15
+ /**
16
+ * When this behavior is configured, {@link InitializeForm | initializing} a
17
+ * {@link PrimaryInstance} for a form which references any **missing**
18
+ * resources will succeed (producing a warning).
19
+ *
20
+ * Such missing resources will be parsed as if they are blank, as appropriate
21
+ * for the resource's XForm semantic usage and/or format.
22
+ *
23
+ * @see {@link MissingResourceBehavior}
24
+ */
25
+ BLANK: 'BLANK',
26
+
27
+ /**
28
+ * @see {@link MISSING_RESOURCE_BEHAVIOR.ERROR}
29
+ */
30
+ get DEFAULT(): 'ERROR' {
31
+ return MISSING_RESOURCE_BEHAVIOR.ERROR;
32
+ },
33
+ } as const;
34
+
35
+ export type MissingResourceBehaviorError = typeof MISSING_RESOURCE_BEHAVIOR.ERROR;
36
+
37
+ export type MissingResourceBehaviorBlank = typeof MISSING_RESOURCE_BEHAVIOR.BLANK;
38
+
39
+ export type MissingResourceBehaviorDefault = typeof MISSING_RESOURCE_BEHAVIOR.DEFAULT;
40
+
41
+ /**
42
+ * Specifies behavior for {@link InitializeForm | initializing} a form's
43
+ * {@link PrimaryInstance} which references any **missing** resources.
44
+ *
45
+ * Here the term "missing" is consistent with
46
+ * {@link https://www.rfc-editor.org/rfc/rfc9110#status.404 | HTTP 404 status}
47
+ * semantics. Clients which provide access to form attachments by performing
48
+ * HTTP network requests (e.g. with {@link fetch}) can generally convey this
49
+ * semantic meaning with a standard {@link Response}.
50
+ *
51
+ * **IMPORTANT**
52
+ *
53
+ * The term "missing" is distinct from other network/IO failures, e.g. when
54
+ * network access itself is unavailable. In these cases, the engine will
55
+ * consider a resource's availability **ambiguous**, producing an error
56
+ * regardless of the configured behavior for **missing** resources.
57
+ */
58
+ // prettier-ignore
59
+ export type MissingResourceBehavior =
60
+ // eslint-disable-next-line @typescript-eslint/sort-type-constituents
61
+ | MissingResourceBehaviorError
62
+ | MissingResourceBehaviorBlank;
63
+
3
64
  export const VALIDATION_TEXT = {
4
65
  constraintMsg: 'Condition not satisfied: constraint',
5
66
  requiredMsg: 'Condition not satisfied: required',
@@ -8,3 +69,9 @@ export const VALIDATION_TEXT = {
8
69
  type ValidationTextDefaults = typeof VALIDATION_TEXT;
9
70
 
10
71
  export type ValidationTextDefault<Role extends ValidationTextRole> = ValidationTextDefaults[Role];
72
+
73
+ export const SUBMISSION_INSTANCE_FILE_NAME = 'xml_submission_file';
74
+ export type SubmissionInstanceFileName = typeof SUBMISSION_INSTANCE_FILE_NAME;
75
+
76
+ export const SUBMISSION_INSTANCE_FILE_TYPE = 'text/xml';
77
+ export type SubmissionInstanceFileType = typeof SUBMISSION_INSTANCE_FILE_TYPE;
@@ -1,13 +1,13 @@
1
1
  import type { ExpandUnion } from '@getodk/common/types/helpers.d.ts';
2
2
  import type { GroupNode } from './GroupNode.ts';
3
- import type { ModelValueNode } from './ModelValueNode.ts';
3
+ import type { AnyInputNode } from './InputNode.ts';
4
+ import type { AnyModelValueNode } from './ModelValueNode.ts';
4
5
  import type { NoteNode } from './NoteNode.ts';
5
6
  import type { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
6
7
  import type { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
7
8
  import type { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
8
9
  import type { RootNode } from './RootNode.ts';
9
10
  import type { SelectNode } from './SelectNode.ts';
10
- import type { StringNode } from './StringNode.ts';
11
11
  import type { SubtreeNode } from './SubtreeNode.ts';
12
12
  import type { TriggerNode } from './TriggerNode.ts';
13
13
  import type { RangeNode } from './unsupported/RangeNode.ts';
@@ -22,16 +22,16 @@ export type AnyUnsupportedControlNode =
22
22
 
23
23
  // prettier-ignore
24
24
  export type AnyControlNode =
25
+ | AnyInputNode
25
26
  | NoteNode
26
27
  | SelectNode
27
- | StringNode
28
28
  | TriggerNode;
29
29
 
30
30
  // prettier-ignore
31
31
  export type AnyLeafNode =
32
32
  | AnyControlNode
33
- | AnyUnsupportedControlNode
34
- | ModelValueNode;
33
+ | AnyModelValueNode
34
+ | AnyUnsupportedControlNode;
35
35
 
36
36
  // prettier-ignore
37
37
  export type RepeatRangeNode =
@@ -0,0 +1,16 @@
1
+ type ODKXFormsUUID = `uuid:${string}`;
2
+
3
+ /**
4
+ * @see {@link https://getodk.github.io/xforms-spec/#metadata}
5
+ */
6
+ export type InstanceID = ODKXFormsUUID;
7
+
8
+ /**
9
+ * @see {@link https://getodk.github.io/xforms-spec/#metadata}
10
+ */
11
+ export type DeprecatedID = ODKXFormsUUID;
12
+
13
+ /**
14
+ * Represents a session-stable identifier for any particular node i
15
+ */
16
+ export type FormNodeID = `node:${string}`;