@getodk/xforms-engine 0.4.0 → 0.6.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 (392) hide show
  1. package/README.md +1 -1
  2. package/dist/client/BaseNode.d.ts +18 -3
  3. package/dist/client/BaseValueNode.d.ts +32 -0
  4. package/dist/client/EngineConfig.d.ts +49 -48
  5. package/dist/client/GroupNode.d.ts +1 -0
  6. package/dist/client/InputNode.d.ts +82 -0
  7. package/dist/client/ModelValueNode.d.ts +13 -7
  8. package/dist/client/NoteNode.d.ts +26 -9
  9. package/dist/client/RangeNode.d.ts +36 -0
  10. package/dist/client/RankNode.d.ts +46 -0
  11. package/dist/client/RootNode.d.ts +37 -7
  12. package/dist/client/SelectNode.d.ts +47 -25
  13. package/dist/client/SubtreeNode.d.ts +1 -0
  14. package/dist/client/TriggerNode.d.ts +10 -6
  15. package/dist/client/ValueType.d.ts +3 -0
  16. package/dist/client/constants.d.ts +50 -0
  17. package/dist/client/hierarchy.d.ts +8 -8
  18. package/dist/client/identity.d.ts +14 -0
  19. package/dist/client/node-types.d.ts +3 -2
  20. package/dist/client/resources.d.ts +93 -0
  21. package/dist/client/submission/SubmissionData.d.ts +7 -0
  22. package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
  23. package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
  24. package/dist/client/submission/SubmissionOptions.d.ts +23 -0
  25. package/dist/client/submission/SubmissionResult.d.ts +91 -0
  26. package/dist/client/submission/SubmissionState.d.ts +12 -0
  27. package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
  28. package/dist/client/validation.d.ts +2 -2
  29. package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
  30. package/dist/error/RankMissingValueError.d.ts +3 -0
  31. package/dist/error/RankValueTypeError.d.ts +6 -0
  32. package/dist/error/SelectValueTypeError.d.ts +15 -0
  33. package/dist/error/ValueTypeInvariantError.d.ts +17 -0
  34. package/dist/error/XFormsSpecViolationError.d.ts +2 -0
  35. package/dist/error/XPathFunctionalityError.d.ts +14 -0
  36. package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
  37. package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
  38. package/dist/index.d.ts +12 -4
  39. package/dist/index.js +17864 -14655
  40. package/dist/index.js.map +1 -1
  41. package/dist/instance/Group.d.ts +10 -4
  42. package/dist/instance/InputControl.d.ts +38 -0
  43. package/dist/instance/ModelValue.d.ts +17 -25
  44. package/dist/instance/Note.d.ts +16 -21
  45. package/dist/instance/PrimaryInstance.d.ts +85 -0
  46. package/dist/instance/RangeControl.d.ts +34 -0
  47. package/dist/instance/RankControl.d.ts +40 -0
  48. package/dist/instance/Root.d.ts +30 -25
  49. package/dist/instance/SelectControl.d.ts +66 -0
  50. package/dist/instance/Subtree.d.ts +11 -5
  51. package/dist/instance/TriggerControl.d.ts +13 -19
  52. package/dist/instance/abstract/DescendantNode.d.ts +32 -25
  53. package/dist/instance/abstract/InstanceNode.d.ts +52 -30
  54. package/dist/instance/abstract/UnsupportedControl.d.ts +11 -3
  55. package/dist/instance/abstract/ValueNode.d.ts +47 -0
  56. package/dist/instance/hierarchy.d.ts +13 -12
  57. package/dist/instance/identity.d.ts +2 -7
  58. package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
  59. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
  60. package/dist/instance/internal-api/InstanceValueContext.d.ts +22 -0
  61. package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
  62. package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
  63. package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
  64. package/dist/instance/internal-api/ValueContext.d.ts +2 -1
  65. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
  66. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +32 -0
  67. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +19 -0
  68. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +18 -0
  69. package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -83
  70. package/dist/instance/repeat/RepeatInstance.d.ts +12 -29
  71. package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
  72. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
  73. package/dist/instance/resource.d.ts +1 -1
  74. package/dist/instance/text/TextRange.d.ts +1 -1
  75. package/dist/instance/unsupported/UploadControl.d.ts +3 -1
  76. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
  77. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
  78. package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
  79. package/dist/integration/xpath/adapter/kind.d.ts +32 -0
  80. package/dist/integration/xpath/adapter/names.d.ts +6 -0
  81. package/dist/integration/xpath/adapter/traversal.d.ts +26 -0
  82. package/dist/integration/xpath/adapter/values.d.ts +2 -0
  83. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +26 -0
  84. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +15 -0
  85. package/dist/integration/xpath/static-dom/StaticElement.d.ts +48 -0
  86. package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
  87. package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
  88. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
  89. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
  90. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
  91. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
  92. package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +3 -0
  93. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
  94. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
  95. package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
  96. package/dist/lib/codecs/Geopoint/Geopoint.d.ts +48 -0
  97. package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
  98. package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
  99. package/dist/lib/codecs/NoteCodec.d.ts +8 -0
  100. package/dist/lib/codecs/RangeCodec.d.ts +8 -0
  101. package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
  102. package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
  103. package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
  104. package/dist/lib/codecs/ValueCodec.d.ts +30 -0
  105. package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
  106. package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
  107. package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
  108. package/dist/lib/codecs/getSharedValueCodec.d.ts +48 -0
  109. package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
  110. package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
  111. package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
  112. package/dist/lib/dom/query.d.ts +4 -2
  113. package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
  114. package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
  115. package/dist/lib/names/NamespaceURL.d.ts +30 -0
  116. package/dist/lib/names/QualifiedName.d.ts +113 -0
  117. package/dist/lib/number-parsers.d.ts +2 -0
  118. package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
  119. package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
  120. package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
  121. package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
  122. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
  123. package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
  124. package/dist/lib/reactivity/createValueState.d.ts +6 -10
  125. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
  126. package/dist/lib/xml-serialization.d.ts +50 -0
  127. package/dist/parse/XFormDOM.d.ts +18 -7
  128. package/dist/parse/XFormDefinition.d.ts +1 -2
  129. package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
  130. package/dist/parse/body/BodyDefinition.d.ts +4 -4
  131. package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
  132. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
  133. package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
  134. package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +4 -1
  135. package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
  136. package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
  137. package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
  138. package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
  139. package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
  140. package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
  141. package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
  142. package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
  143. package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
  144. package/dist/parse/model/BindDefinition.d.ts +6 -5
  145. package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
  146. package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
  147. package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -14
  148. package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
  149. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
  150. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +9 -0
  151. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
  152. package/dist/parse/model/LeafNodeDefinition.d.ts +9 -4
  153. package/dist/parse/model/ModelBindMap.d.ts +1 -1
  154. package/dist/parse/model/ModelDefinition.d.ts +2 -0
  155. package/dist/parse/model/NodeDefinition.d.ts +16 -20
  156. package/dist/parse/model/NoteNodeDefinition.d.ts +9 -8
  157. package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
  158. package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
  159. package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
  160. package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
  161. package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
  162. package/dist/parse/model/RootAttributeMap.d.ts +23 -0
  163. package/dist/parse/model/RootDefinition.d.ts +12 -9
  164. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
  165. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
  166. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
  167. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
  168. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
  169. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
  170. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
  171. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
  172. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
  173. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
  174. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
  175. package/dist/parse/model/SubtreeDefinition.d.ts +7 -4
  176. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +23 -0
  177. package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
  178. package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
  179. package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
  180. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
  181. package/dist/parse/xpath/semantic-analysis.d.ts +6 -3
  182. package/dist/solid.js +15437 -12246
  183. package/dist/solid.js.map +1 -1
  184. package/package.json +18 -13
  185. package/src/client/BaseNode.ts +21 -6
  186. package/src/client/BaseValueNode.ts +35 -0
  187. package/src/client/EngineConfig.ts +52 -51
  188. package/src/client/GroupNode.ts +1 -0
  189. package/src/client/InputNode.ts +113 -0
  190. package/src/client/ModelValueNode.ts +31 -7
  191. package/src/client/NoteNode.ts +45 -9
  192. package/src/client/RangeNode.ts +51 -0
  193. package/src/client/RankNode.ts +54 -0
  194. package/src/client/RootNode.ts +43 -7
  195. package/src/client/SelectNode.ts +53 -26
  196. package/src/client/SubtreeNode.ts +1 -0
  197. package/src/client/TriggerNode.ts +12 -6
  198. package/src/client/ValueType.ts +4 -0
  199. package/src/client/constants.ts +67 -0
  200. package/src/client/hierarchy.ts +12 -13
  201. package/src/client/identity.ts +16 -0
  202. package/src/client/node-types.ts +13 -7
  203. package/src/client/resources.ts +118 -0
  204. package/src/client/submission/SubmissionData.ts +12 -0
  205. package/src/client/submission/SubmissionDefinition.ts +16 -0
  206. package/src/client/submission/SubmissionInstanceFile.ts +9 -0
  207. package/src/client/submission/SubmissionOptions.ts +28 -0
  208. package/src/client/submission/SubmissionResult.ts +124 -0
  209. package/src/client/submission/SubmissionState.ts +14 -0
  210. package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
  211. package/src/client/validation.ts +2 -2
  212. package/src/error/ErrorProductionDesignPendingError.ts +6 -0
  213. package/src/error/RankMissingValueError.ts +5 -0
  214. package/src/error/RankValueTypeError.ts +13 -0
  215. package/src/error/SelectValueTypeError.ts +22 -0
  216. package/src/error/ValueTypeInvariantError.ts +22 -0
  217. package/src/error/XFormsSpecViolationError.ts +1 -0
  218. package/src/error/XPathFunctionalityError.ts +26 -0
  219. package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
  220. package/src/error/XPathFunctionalityPendingError.ts +18 -0
  221. package/src/index.ts +12 -13
  222. package/src/instance/Group.ts +18 -5
  223. package/src/instance/InputControl.ts +159 -0
  224. package/src/instance/ModelValue.ts +48 -53
  225. package/src/instance/Note.ts +40 -49
  226. package/src/instance/PrimaryInstance.ts +245 -0
  227. package/src/instance/RangeControl.ts +113 -0
  228. package/src/instance/RankControl.ts +199 -0
  229. package/src/instance/Root.ts +63 -134
  230. package/src/instance/SelectControl.ts +219 -0
  231. package/src/instance/Subtree.ts +20 -7
  232. package/src/instance/TriggerControl.ts +44 -66
  233. package/src/instance/abstract/DescendantNode.ts +91 -51
  234. package/src/instance/abstract/InstanceNode.ts +113 -107
  235. package/src/instance/abstract/UnsupportedControl.ts +29 -5
  236. package/src/instance/abstract/ValueNode.ts +128 -0
  237. package/src/instance/children.ts +80 -40
  238. package/src/instance/hierarchy.ts +39 -30
  239. package/src/instance/identity.ts +3 -9
  240. package/src/instance/index.ts +25 -7
  241. package/src/instance/internal-api/EvaluationContext.ts +60 -13
  242. package/src/instance/internal-api/InstanceConfig.ts +9 -2
  243. package/src/instance/internal-api/InstanceValueContext.ts +26 -0
  244. package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
  245. package/src/instance/internal-api/TranslationContext.ts +3 -2
  246. package/src/instance/internal-api/ValidationContext.ts +3 -4
  247. package/src/instance/internal-api/ValueContext.ts +2 -1
  248. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
  249. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +43 -0
  250. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +26 -0
  251. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +24 -0
  252. package/src/instance/repeat/BaseRepeatRange.ts +52 -131
  253. package/src/instance/repeat/RepeatInstance.ts +21 -46
  254. package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
  255. package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
  256. package/src/instance/resource.ts +5 -2
  257. package/src/instance/text/TextChunk.ts +1 -1
  258. package/src/instance/unsupported/UploadControl.ts +5 -1
  259. package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
  260. package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
  261. package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
  262. package/src/integration/xpath/adapter/kind.ts +114 -0
  263. package/src/integration/xpath/adapter/names.ts +148 -0
  264. package/src/integration/xpath/adapter/traversal.ts +229 -0
  265. package/src/integration/xpath/adapter/values.ts +5 -0
  266. package/src/integration/xpath/static-dom/StaticAttribute.ts +41 -0
  267. package/src/integration/xpath/static-dom/StaticDocument.ts +36 -0
  268. package/src/integration/xpath/static-dom/StaticElement.ts +119 -0
  269. package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
  270. package/src/integration/xpath/static-dom/StaticText.ts +28 -0
  271. package/src/lib/client-reactivity/README.md +0 -0
  272. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
  273. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
  274. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
  275. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
  276. package/src/lib/client-reactivity/submission/createRootSubmissionState.ts +19 -0
  277. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
  278. package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
  279. package/src/lib/codecs/DecimalValueCodec.ts +46 -0
  280. package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
  281. package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
  282. package/src/lib/codecs/IntValueCodec.ts +100 -0
  283. package/src/lib/codecs/NoteCodec.ts +32 -0
  284. package/src/lib/codecs/RangeCodec.ts +65 -0
  285. package/src/lib/codecs/StringValueCodec.ts +11 -0
  286. package/src/lib/codecs/TriggerCodec.ts +64 -0
  287. package/src/lib/codecs/ValueArrayCodec.ts +42 -0
  288. package/src/lib/codecs/ValueCodec.ts +106 -0
  289. package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
  290. package/src/lib/codecs/getNoteCodec.ts +27 -0
  291. package/src/lib/codecs/getSelectCodec.ts +27 -0
  292. package/src/lib/codecs/getSharedValueCodec.ts +79 -0
  293. package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
  294. package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
  295. package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
  296. package/src/lib/dom/query.ts +8 -2
  297. package/src/lib/names/NamespaceDeclaration.ts +106 -0
  298. package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
  299. package/src/lib/names/NamespaceURL.ts +44 -0
  300. package/src/lib/names/QualifiedName.ts +170 -0
  301. package/src/lib/number-parsers.ts +25 -0
  302. package/src/lib/reactivity/createChildrenState.ts +8 -6
  303. package/src/lib/reactivity/createComputedExpression.ts +57 -34
  304. package/src/lib/reactivity/createInstanceValueState.ts +216 -0
  305. package/src/lib/reactivity/createItemCollection.ts +173 -0
  306. package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
  307. package/src/lib/reactivity/createTranslationState.ts +61 -0
  308. package/src/lib/reactivity/createValueState.ts +62 -120
  309. package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
  310. package/src/lib/reactivity/text/createTextRange.ts +4 -3
  311. package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
  312. package/src/lib/reactivity/validation/createValidation.ts +2 -3
  313. package/src/lib/xml-serialization.ts +163 -0
  314. package/src/parse/XFormDOM.ts +231 -76
  315. package/src/parse/XFormDefinition.ts +2 -10
  316. package/src/parse/attachments/FormAttachmentResource.ts +40 -0
  317. package/src/parse/body/BodyDefinition.ts +7 -7
  318. package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
  319. package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
  320. package/src/parse/body/control/InputControlDefinition.ts +29 -0
  321. package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
  322. package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
  323. package/src/parse/body/control/RangeControlDefinition.ts +91 -6
  324. package/src/parse/body/control/RankControlDefinition.ts +25 -7
  325. package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
  326. package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
  327. package/src/parse/expression/ItemsetValueExpression.ts +1 -1
  328. package/src/parse/expression/abstract/DependencyContext.ts +0 -26
  329. package/src/parse/expression/abstract/DependentExpression.ts +2 -13
  330. package/src/parse/model/BindDefinition.ts +9 -8
  331. package/src/parse/model/BindPreloadDefinition.ts +100 -0
  332. package/src/parse/model/BindTypeDefinition.ts +175 -0
  333. package/src/parse/model/DescendentNodeDefinition.ts +7 -31
  334. package/src/parse/model/FormSubmissionDefinition.ts +44 -0
  335. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
  336. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +42 -0
  337. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
  338. package/src/parse/model/LeafNodeDefinition.ts +15 -5
  339. package/src/parse/model/ModelBindMap.ts +6 -8
  340. package/src/parse/model/ModelDefinition.ts +6 -1
  341. package/src/parse/model/NodeDefinition.ts +24 -48
  342. package/src/parse/model/NoteNodeDefinition.ts +11 -10
  343. package/src/parse/model/RangeNodeDefinition.ts +118 -0
  344. package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
  345. package/src/parse/model/RepeatRangeDefinition.ts +11 -7
  346. package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
  347. package/src/parse/model/RootAttributeDefinition.ts +45 -0
  348. package/src/parse/model/RootAttributeMap.ts +44 -0
  349. package/src/parse/model/RootDefinition.ts +31 -29
  350. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
  351. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
  352. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
  353. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
  354. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
  355. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
  356. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
  357. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +415 -0
  358. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
  359. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
  360. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
  361. package/src/parse/model/SubtreeDefinition.ts +12 -12
  362. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
  363. package/src/parse/text/ItemLabelDefinition.ts +1 -1
  364. package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
  365. package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
  366. package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
  367. package/src/parse/xpath/semantic-analysis.ts +33 -3
  368. package/dist/client/StringNode.d.ts +0 -46
  369. package/dist/client/unsupported/RangeNode.d.ts +0 -9
  370. package/dist/client/unsupported/RankNode.d.ts +0 -9
  371. package/dist/instance/SelectField.d.ts +0 -50
  372. package/dist/instance/StringField.d.ts +0 -44
  373. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
  374. package/dist/instance/unsupported/RangeControl.d.ts +0 -4
  375. package/dist/instance/unsupported/RankControl.d.ts +0 -4
  376. package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
  377. package/dist/parse/XFormDataType.d.ts +0 -25
  378. package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
  379. package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
  380. package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -11
  381. package/src/client/StringNode.ts +0 -52
  382. package/src/client/unsupported/RangeNode.ts +0 -14
  383. package/src/client/unsupported/RankNode.ts +0 -14
  384. package/src/instance/SelectField.ts +0 -226
  385. package/src/instance/StringField.ts +0 -120
  386. package/src/instance/internal-api/SubscribableDependency.ts +0 -61
  387. package/src/instance/unsupported/RangeControl.ts +0 -5
  388. package/src/instance/unsupported/RankControl.ts +0 -5
  389. package/src/lib/reactivity/createSelectItems.ts +0 -168
  390. package/src/parse/XFormDataType.ts +0 -62
  391. package/src/parse/body/control/InputDefinition.ts +0 -22
  392. package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -26
@@ -3,14 +3,18 @@ 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 { SubmissionOptions } from './submission/SubmissionOptions.ts';
7
+ import type {
8
+ ChunkedSubmissionResult,
9
+ MonolithicSubmissionResult,
10
+ SubmissionResult,
11
+ } from './submission/SubmissionResult.ts';
6
12
  import type { AncestorNodeValidationState } from './validation.ts';
7
13
 
8
14
  export interface RootNodeState extends BaseNodeState {
9
15
  /**
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.
16
+ * @todo If we ever expose an interface to the primary instance document, it
17
+ * would make sense to move this state up.
14
18
  */
15
19
  get activeLanguage(): ActiveLanguage;
16
20
 
@@ -29,6 +33,8 @@ export interface RootNode extends BaseNode {
29
33
  */
30
34
  readonly appearances: null;
31
35
 
36
+ readonly nodeOptions: null;
37
+
32
38
  /**
33
39
  * @todo This is another odd deviation in {@link RootNode}. Unlike
34
40
  * {@link languages}, it doesn't feel particularly **essential**. While it
@@ -46,15 +52,45 @@ export interface RootNode extends BaseNode {
46
52
 
47
53
  readonly definition: RootDefinition;
48
54
  readonly root: RootNode;
49
- readonly parent: null;
55
+ readonly parent: unknown;
50
56
  readonly currentState: RootNodeState;
51
57
  readonly validationState: AncestorNodeValidationState;
52
58
 
53
59
  /**
54
- * @todo as with {@link RootNodeState.activeLanguage}, this is the most
55
- * significant break in consistency across node types.
60
+ * @todo as discussed on {@link RootNodeState.activeLanguage}
56
61
  */
57
62
  readonly languages: FormLanguages;
58
63
 
59
64
  setLanguage(language: FormLanguage): RootNode;
65
+
66
+ /**
67
+ * Prepares the current form instance state for submission.
68
+ *
69
+ * A {@link SubmissionResult} will be prepared even if the current form state
70
+ * includes `constraint` or `required` violations. This is intended to serve
71
+ * two purposes:
72
+ *
73
+ * - A client may effectively use this method as a part of its own "submit"
74
+ * routine, and use any violations included in the {@link SubmissionResult}
75
+ * to prompt users to address those violations.
76
+ *
77
+ * - A client may inspect the submission state of a form at any time.
78
+ * Depending on the client and use case, this may be a convenience (e.g. for
79
+ * developers to inspect that form state at a current point in time); or it
80
+ * may provide necessary functionality (e.g. for test or tooling clients).
81
+ *
82
+ * Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
83
+ * a fast operation. It may even be nearly instantaneous, or roughly
84
+ * proportionate to the size of the form itself. However, this method is
85
+ * designed to be asynchronous out of an abundance of caution, anticipating
86
+ * that some as-yet undeveloped operations on binary data (e.g. form
87
+ * attachments) may themselves impose asynchrony (i.e. by interfaces provided
88
+ * by the platform and/or external dependencies).
89
+ *
90
+ * A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
91
+ * {@link SubmissionResult<'chunked'>} will be produced, with form attachments
92
+ */
93
+ prepareSubmission(): Promise<MonolithicSubmissionResult>;
94
+ prepareSubmission(options: SubmissionOptions<'monolithic'>): Promise<MonolithicSubmissionResult>;
95
+ prepareSubmission(options: SubmissionOptions<'chunked'>): Promise<ChunkedSubmissionResult>;
60
96
  }
@@ -1,24 +1,26 @@
1
- import type { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
1
+ import type {
2
+ AnySelectControlDefinition,
3
+ SelectType,
4
+ } from '../parse/body/control/SelectControlDefinition.ts';
2
5
  import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
6
+ import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
4
7
  import type { NodeAppearances } from './NodeAppearances.ts';
5
8
  import type { RootNode } from './RootNode.ts';
6
- import type { StringNode } from './StringNode.ts';
7
9
  import type { TextRange } from './TextRange.ts';
10
+ import type { ValueType } from './ValueType.ts';
8
11
  import type { GeneralParentNode } from './hierarchy.ts';
9
12
  import type { LeafNodeValidationState } from './validation.ts';
10
13
 
11
14
  export interface SelectItem {
15
+ get label(): TextRange<'item-label'>;
12
16
  get value(): string;
13
- get label(): TextRange<'item-label'> | null;
14
17
  }
15
18
 
16
- export interface SelectNodeState extends BaseNodeState {
19
+ export type SelectValueOptions = readonly SelectItem[];
20
+
21
+ export interface SelectNodeState extends BaseValueNodeState<readonly string[]> {
17
22
  get children(): null;
18
23
 
19
- /**
20
- * @todo should {@link BaseNodeState} include this??
21
- */
22
24
  get valueOptions(): readonly SelectItem[];
23
25
 
24
26
  /**
@@ -33,43 +35,68 @@ export interface SelectNodeState extends BaseNodeState {
33
35
  * Should a `SelectNodeState` have this `value` type, whereas a hypothetical
34
36
  * `Select1NodeState` would have `get value(): SelectItem | null`?
35
37
  */
36
- get value(): readonly SelectItem[];
38
+ get value(): readonly string[];
37
39
  }
38
40
 
39
- export interface SelectDefinition extends LeafNodeDefinition {
40
- readonly bodyElement: AnySelectDefinition;
41
+ export interface SelectDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
42
+ readonly bodyElement: AnySelectControlDefinition;
41
43
  }
42
44
 
43
45
  export type SelectNodeAppearances = NodeAppearances<SelectDefinition>;
44
46
 
45
- export interface SelectNode extends BaseNode {
47
+ export interface SelectNode extends BaseValueNode<'string', readonly string[]> {
46
48
  readonly nodeType: 'select';
49
+ readonly valueType: 'string';
50
+ readonly selectType: SelectType;
47
51
  readonly appearances: SelectNodeAppearances;
48
- readonly definition: SelectDefinition;
52
+ readonly nodeOptions: null;
53
+ readonly definition: SelectDefinition<'string'>;
49
54
  readonly root: RootNode;
50
55
  readonly parent: GeneralParentNode;
51
56
  readonly currentState: SelectNodeState;
52
57
  readonly validationState: LeafNodeValidationState;
53
58
 
54
59
  /**
55
- * For use by a client to update the selection of a select node where:
60
+ * Convenience API to get the {@link SelectItem} which is associated with
61
+ * {@link value}, if one is currently available—i.e. if it is present in
62
+ * {@link SelectNodeState.valueOptions}.
63
+ */
64
+ getValueOption(value: string): SelectItem | null;
65
+
66
+ /**
67
+ * Convenience API to determine if {@link value} is currently selected—i.e. if
68
+ * it is one of the selected values in {@link SelectNodeState.value}.
69
+ */
70
+ isSelected(value: string): boolean;
71
+
72
+ /**
73
+ * Selects a single {@link value}, as provided by a {@link SelectItem.value}.
74
+ * Calling this setter replaces the currently selected value(s, if any),
75
+ * where:
56
76
  *
57
- * - For fields defined with an XForms `<select>`, calling this method is
58
- * additive, i.e. it will include the item in its
59
- * {@link SelectNodeState.value}.
60
- * - For fields defined with an XForms `<select1>`, calling this method will
61
- * replace the selection (if any).
77
+ * - if the provided value is `null`, the current selection is cleared; ELSE
78
+ * - the provided value is selected in place of any currently selected values.
62
79
  *
63
- * @todo @see {@link StringNode.setValue} re: write restrictions
64
- * @todo @see {@link SelectNodeState.value} re: breaking up the types
80
+ * This setter is most useful for {@link SelectNode}s associated with an
81
+ * XForms
82
+ * {@link https://getodk.github.io/xforms-spec/#body-elements | `<select1>`}
83
+ * control.
65
84
  */
66
- select(item: SelectItem): RootNode;
85
+ selectValue(value: string | null): RootNode;
67
86
 
68
87
  /**
69
- * For use by a client to remove an item from the node's
70
- * {@link SelectNodeState.value}.
88
+ * Selects any number of {@link values}, as provided by any number of
89
+ * {@link SelectItem.value}s. Calling this setter replaces the currently
90
+ * selected value(s, if any). If called with an empty array, the current
91
+ * selection is cleared.
92
+ *
93
+ * This setter is most useful for {@link SelectNode}s associated with an
94
+ * XForms
95
+ * {@link https://getodk.github.io/xforms-spec/#body-elements | `<select>`}
96
+ * control.
71
97
  *
72
- * @todo @see {@link StringNode.setValue} re: write restrictions
98
+ * This setter _may_ be used with a `<select1>` control, in which case the
99
+ * provided {@link values} should produce at most one value.
73
100
  */
74
- deselect(item: SelectItem): RootNode;
101
+ selectValues(values: readonly string[]): RootNode;
75
102
  }
@@ -52,6 +52,7 @@ export interface SubtreeDefinition extends BaseSubtreeDefinition {
52
52
  export interface SubtreeNode extends BaseNode {
53
53
  readonly nodeType: 'subtree';
54
54
  readonly appearances: null;
55
+ readonly nodeOptions: null;
55
56
  readonly definition: SubtreeDefinition;
56
57
  readonly root: RootNode;
57
58
  readonly parent: GeneralParentNode;
@@ -1,25 +1,31 @@
1
+ import type { TriggerRuntimeValue, TriggerValueType } from '../lib/codecs/TriggerCodec.ts';
1
2
  import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
2
3
  import type { TriggerControlDefinition } from '../parse/body/control/TriggerControlDefinition.ts';
3
4
  import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
4
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
5
+ import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
5
6
  import type { GeneralParentNode } from './hierarchy.ts';
6
7
  import type { RootNode } from './RootNode.ts';
7
8
  import type { LeafNodeValidationState } from './validation.ts';
9
+ import type { ValueType } from './ValueType.ts';
8
10
 
9
- export interface TriggerNodeState extends BaseNodeState {
11
+ export type TriggerValue = TriggerRuntimeValue;
12
+
13
+ export interface TriggerNodeState extends BaseValueNodeState<TriggerValue> {
10
14
  get children(): null;
11
15
  get valueOptions(): null;
12
- get value(): boolean;
16
+ get value(): TriggerValue;
13
17
  }
14
18
 
15
- export interface TriggerNodeDefinition extends LeafNodeDefinition {
19
+ export interface TriggerNodeDefinition<V extends ValueType = ValueType>
20
+ extends LeafNodeDefinition<V> {
16
21
  readonly bodyElement: TriggerControlDefinition;
17
22
  }
18
23
 
19
- export interface TriggerNode extends BaseNode {
24
+ export interface TriggerNode extends BaseValueNode<TriggerValueType, TriggerValue> {
20
25
  readonly nodeType: 'trigger';
21
- readonly definition: TriggerNodeDefinition;
26
+ readonly definition: TriggerNodeDefinition<TriggerValueType>;
22
27
  readonly appearances: UnknownAppearanceDefinition;
28
+ readonly nodeOptions: null;
23
29
  readonly root: RootNode;
24
30
  readonly parent: GeneralParentNode;
25
31
  readonly currentState: TriggerNodeState;
@@ -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,37 +1,36 @@
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';
4
- import type { NoteNode } from './NoteNode.ts';
3
+ import type { AnyInputNode } from './InputNode.ts';
4
+ import type { AnyModelValueNode } from './ModelValueNode.ts';
5
+ import type { AnyNoteNode } from './NoteNode.ts';
6
+ import type { AnyRangeNode } from './RangeNode.ts';
5
7
  import type { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
6
8
  import type { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
7
9
  import type { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
8
10
  import type { RootNode } from './RootNode.ts';
9
11
  import type { SelectNode } from './SelectNode.ts';
10
- import type { StringNode } from './StringNode.ts';
11
12
  import type { SubtreeNode } from './SubtreeNode.ts';
12
13
  import type { TriggerNode } from './TriggerNode.ts';
13
- import type { RangeNode } from './unsupported/RangeNode.ts';
14
- import type { RankNode } from './unsupported/RankNode.ts';
14
+ import type { RankNode } from './RankNode.ts';
15
15
  import type { UploadNode } from './unsupported/UploadNode.ts';
16
16
 
17
17
  // prettier-ignore
18
- export type AnyUnsupportedControlNode =
19
- | RangeNode
20
- | RankNode
21
- | UploadNode;
18
+ export type AnyUnsupportedControlNode = UploadNode;
22
19
 
23
20
  // prettier-ignore
24
21
  export type AnyControlNode =
25
- | NoteNode
22
+ | AnyInputNode
23
+ | AnyNoteNode
24
+ | AnyRangeNode
25
+ | RankNode
26
26
  | SelectNode
27
- | StringNode
28
27
  | TriggerNode;
29
28
 
30
29
  // prettier-ignore
31
30
  export type AnyLeafNode =
32
31
  | AnyControlNode
33
- | AnyUnsupportedControlNode
34
- | ModelValueNode;
32
+ | AnyModelValueNode
33
+ | AnyUnsupportedControlNode;
35
34
 
36
35
  // prettier-ignore
37
36
  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}`;
@@ -1,13 +1,23 @@
1
1
  // prettier-ignore
2
2
  export type UnsupportedControlNodeType =
3
- | 'range'
4
3
  | 'rank'
5
4
  | 'upload';
6
5
 
7
6
  // prettier-ignore
8
7
  export type RepeatRangeNodeType =
9
8
  | 'repeat-range:controlled'
10
- | 'repeat-range:uncontrolled'
9
+ | 'repeat-range:uncontrolled';
10
+
11
+ // prettier-ignore
12
+ export type LeafNodeType =
13
+ // eslint-disable-next-line @typescript-eslint/sort-type-constituents
14
+ | 'model-value'
15
+ | 'note'
16
+ | 'select'
17
+ | 'input'
18
+ | 'trigger'
19
+ | 'range'
20
+ | UnsupportedControlNodeType;
11
21
 
12
22
  // prettier-ignore
13
23
  export type InstanceNodeType =
@@ -17,9 +27,5 @@ export type InstanceNodeType =
17
27
  | 'repeat-instance'
18
28
  | 'group'
19
29
  | 'subtree'
20
- | 'model-value'
21
- | 'note'
22
- | 'select'
23
- | 'string'
24
- | 'trigger'
30
+ | LeafNodeType
25
31
  | UnsupportedControlNodeType;
@@ -0,0 +1,118 @@
1
+ import type { JRResourceURL } from '@getodk/common/jr-resources/JRResourceURL.ts';
2
+ import type { initializeForm } from '../instance/index.ts';
3
+
4
+ interface FetchResourceHeadersIterator<T>
5
+ extends IteratorObject<
6
+ T,
7
+ // Note: we use this weird TypeScript intrinsic type so a built-in
8
+ // `HeadersIterator` is assignable regardless of a client's configured
9
+ // TypeScript or linting strictness. We don't actually care about the type, or
10
+ // consume the value it represents.
11
+ BuiltinIteratorReturn,
12
+ unknown
13
+ > {
14
+ [Symbol.iterator](): FetchResourceHeadersIterator<T>;
15
+ }
16
+
17
+ type FetchResourceHeadersForEachCallbackFn = (
18
+ value: string,
19
+ key: string,
20
+ parent: FetchResourceResponseHeaders
21
+ ) => void;
22
+
23
+ /**
24
+ * A read-only strict subset of the web standard {@link Headers}.
25
+ *
26
+ * Note that the engine may make the following assumptions about
27
+ * {@link FetchResourceResponse.headers}:
28
+ *
29
+ * - If {@link FetchResourceResponse} is an instance of {@link Response}, it
30
+ * will be assumed its {@link FetchResourceResponse.headers | headers object}
31
+ * _is present_, and that it is an instance of {@link Headers}. In other
32
+ * words: for the purposes of resource resolution, we explicitly expect that
33
+ * clients using APIs provided by the runtime platform (or polyfills thereof)
34
+ * will not monkey-patch properties of values produced by those APIs.
35
+ *
36
+ * - If the object is an instance of {@link Headers} (whether by inference as a
37
+ * property of {@link Response}, or by a direct instance type check), the
38
+ * engine will assume it is safe to treat header names as case insensitive for
39
+ * any lookups it may perform. In other words: we explicitly expect that
40
+ * clients _providing access_ to APIs rovided by the runtime platform (or
41
+ * polyfills thereof) will not alter the guarantees of those APIs.
42
+ *
43
+ * - If the object is not an instance of {@link Headers}, it will be treated as
44
+ * a {@link ReadonlyMap<string, string>}. In other words: we explicitly expect
45
+ * that clients, when providing a bespoke implementation of
46
+ * {@link FetchResourceResponse} and its constituent parts, will likely
47
+ * implement them partially (and in the case of
48
+ * {@link FetchResourceResponse.headers}, with the nearest common idiom
49
+ * available). In this case, we will favor a best effort at correctness,
50
+ * generally at some expense of performance.
51
+ */
52
+ export interface FetchResourceResponseHeaders {
53
+ [Symbol.iterator](): FetchResourceHeadersIterator<[string, string]>;
54
+
55
+ entries(): FetchResourceHeadersIterator<[string, string]>;
56
+ keys(): FetchResourceHeadersIterator<string>;
57
+ values(): FetchResourceHeadersIterator<string>;
58
+
59
+ get(name: string): string | null;
60
+ has(name: string): boolean;
61
+ forEach(callbackfn: FetchResourceHeadersForEachCallbackFn): void;
62
+ }
63
+
64
+ /**
65
+ * This is a strict subset of the web standard {@link Response}. Clients are
66
+ * encouraged to use the global {@link Response} constructor (as provided by the
67
+ * runtime platform, or by a global runtime polyfill), but may also provide a
68
+ * bespoke implementation if it suits their needs.
69
+ *
70
+ * Since we cannot assume a client's implementation will always be an instance
71
+ * of {@link Response}, we make some assumptions about its {@link headers}
72
+ * object (if available, as detailed on {@link FetchResourceResponseHeaders}).
73
+ *
74
+ * For other properties, we make the following assumptions (all of which are
75
+ * assumptions we would make about a platform-provided/polyfilled
76
+ * {@link Response}, but are explicitly stated for the benefit of confidence in
77
+ * client implementations):
78
+ *
79
+ * - If we read {@link body} directly, we will assume it is consumed on first
80
+ * read, and will not read it again.
81
+ *
82
+ * - We assume that {@link blob} and {@link text} indirectly consume
83
+ * {@link body} on first read as well, and will only ever read one of each of
84
+ * these properties, and only ever once.
85
+ *
86
+ * Furthermore, if the engine intends to read {@link body} (or its indirect
87
+ * {@link blob} or {@link text} consumers), it will do so in the course of a
88
+ * client's call to {@link initializeForm}, and before the
89
+ * {@link Promise<PrimaryInstance>} returned by that call is resolved.
90
+ */
91
+ export interface FetchResourceResponse {
92
+ readonly ok?: boolean;
93
+ readonly status?: number;
94
+ readonly body?: ReadableStream<Uint8Array> | null;
95
+ readonly bodyUsed?: boolean;
96
+ readonly headers?: FetchResourceResponseHeaders;
97
+
98
+ readonly blob: () => Promise<Blob>;
99
+ readonly text: () => Promise<string>;
100
+ }
101
+
102
+ /**
103
+ * This is a strict subset of the web standard `fetch` interface. It implicitly
104
+ * assumes that the engine itself will only ever perform `GET`-like network/IO
105
+ * requests. It also provides no further request-like semantics to the engine.
106
+ *
107
+ * This is presumed sufficient for now, but notably doesn't expose any notion of
108
+ * content negotiation (e.g. the ability for the engine to include `Accept`
109
+ * headers in resource requests issued to a client's {@link FetchResource}
110
+ * implementation).
111
+ */
112
+ export type FetchResource<Resource extends URL = URL> = (
113
+ resource: Resource
114
+ ) => Promise<FetchResourceResponse>;
115
+
116
+ export type FormAttachmentURL = JRResourceURL;
117
+
118
+ export type FetchFormAttachment = FetchResource<FormAttachmentURL>;
@@ -0,0 +1,12 @@
1
+ import type {
2
+ SubmissionInstanceFile,
3
+ SubmissionInstanceFileName,
4
+ } from './SubmissionInstanceFile.ts';
5
+
6
+ export interface SubmissionData extends FormData {
7
+ get(name: SubmissionInstanceFileName): SubmissionInstanceFile;
8
+ get(name: string): FormDataEntryValue | null;
9
+
10
+ has(name: SubmissionInstanceFileName): true;
11
+ has(name: string): boolean;
12
+ }
@@ -0,0 +1,16 @@
1
+ export interface SubmissionDefinition {
2
+ /**
3
+ * @see {@link https://getodk.github.io/xforms-spec/#submission-attributes | `action` submission attribute}
4
+ */
5
+ readonly submissionAction: URL | null;
6
+
7
+ /**
8
+ * @see {@link https://getodk.github.io/xforms-spec/#submission-attributes | `method` submission attribute}
9
+ */
10
+ readonly submissionMethod: 'post';
11
+
12
+ /**
13
+ * @see {@link https://getodk.github.io/xforms-spec/#submission-attributes | `base64RsaPublicKey` submission attribute}
14
+ */
15
+ readonly encryptionKey: string | null;
16
+ }
@@ -0,0 +1,9 @@
1
+ import type { SubmissionInstanceFileName, SubmissionInstanceFileType } from '../constants.ts';
2
+
3
+ // Re-export for convenient `SubmissionInstanceFile` construction/access flows
4
+ export type { SubmissionInstanceFileName, SubmissionInstanceFileType };
5
+
6
+ export interface SubmissionInstanceFile extends File {
7
+ readonly name: SubmissionInstanceFileName;
8
+ readonly type: SubmissionInstanceFileType;
9
+ }
@@ -0,0 +1,28 @@
1
+ export type SubmissionChunkedType = 'chunked' | 'monolithic';
2
+
3
+ interface BaseSubmissionOptions<ChunkedType extends SubmissionChunkedType> {
4
+ readonly chunked?: ChunkedType | undefined;
5
+
6
+ /**
7
+ * As described in the
8
+ * {@link https://docs.getodk.org/openrosa-form-submission/#extended-transmission-considerations | OpenRosa Form Submission API},
9
+ * clients may obtain this value from an OpenRosa server's
10
+ * `X-OpenRosa-Accept-Content-Length` header.
11
+ */
12
+ readonly maxSize?: number;
13
+ }
14
+
15
+ interface ChunkedSubmissionOptions extends BaseSubmissionOptions<'chunked'> {
16
+ readonly maxSize: number;
17
+ }
18
+
19
+ interface MonolithicSubmissionOptions extends BaseSubmissionOptions<'monolithic'> {
20
+ readonly chunked?: 'monolithic' | undefined;
21
+ readonly maxSize?: never;
22
+ }
23
+
24
+ // prettier-ignore
25
+ export type SubmissionOptions<ChunkedType extends SubmissionChunkedType = 'monolithic'> = {
26
+ chunked: ChunkedSubmissionOptions;
27
+ monolithic: MonolithicSubmissionOptions;
28
+ }[ChunkedType];