@getodk/xforms-engine 0.3.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 (429) hide show
  1. package/dist/client/BaseNode.d.ts +15 -5
  2. package/dist/client/BaseValueNode.d.ts +32 -0
  3. package/dist/client/EngineConfig.d.ts +49 -49
  4. package/dist/client/GroupNode.d.ts +2 -3
  5. package/dist/client/InputNode.d.ts +53 -0
  6. package/dist/client/ModelValueNode.d.ts +13 -9
  7. package/dist/client/NodeAppearances.d.ts +1 -2
  8. package/dist/client/NoteNode.d.ts +3 -4
  9. package/dist/client/RootNode.d.ts +36 -10
  10. package/dist/client/SelectNode.d.ts +4 -5
  11. package/dist/client/SubtreeNode.d.ts +1 -2
  12. package/dist/client/TextRange.d.ts +3 -4
  13. package/dist/client/TriggerNode.d.ts +25 -0
  14. package/dist/client/ValueType.d.ts +3 -0
  15. package/dist/client/constants.d.ts +50 -1
  16. package/dist/client/hierarchy.d.ts +9 -5
  17. package/dist/client/identity.d.ts +14 -0
  18. package/dist/client/index.d.ts +0 -1
  19. package/dist/client/node-types.d.ts +3 -1
  20. package/dist/client/repeat/BaseRepeatRangeNode.d.ts +1 -2
  21. package/dist/client/repeat/RepeatInstanceNode.d.ts +2 -3
  22. package/dist/client/repeat/RepeatRangeControlledNode.d.ts +1 -2
  23. package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +1 -2
  24. package/dist/client/resources.d.ts +93 -0
  25. package/dist/client/submission/SubmissionData.d.ts +7 -0
  26. package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
  27. package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
  28. package/dist/client/submission/SubmissionOptions.d.ts +23 -0
  29. package/dist/client/submission/SubmissionResult.d.ts +91 -0
  30. package/dist/client/submission/SubmissionState.d.ts +12 -0
  31. package/dist/client/unsupported/RangeNode.d.ts +9 -0
  32. package/dist/client/unsupported/RankNode.d.ts +9 -0
  33. package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
  34. package/dist/client/unsupported/UploadNode.d.ts +9 -0
  35. package/dist/client/validation.d.ts +2 -3
  36. package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
  37. package/dist/error/ValueTypeInvariantError.d.ts +17 -0
  38. package/dist/error/XPathFunctionalityError.d.ts +14 -0
  39. package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
  40. package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
  41. package/dist/index.d.ts +16 -4
  42. package/dist/index.js +8559 -4700
  43. package/dist/index.js.map +1 -1
  44. package/dist/instance/Group.d.ts +9 -5
  45. package/dist/instance/InputControl.d.ts +36 -0
  46. package/dist/instance/ModelValue.d.ts +16 -27
  47. package/dist/instance/Note.d.ts +11 -5
  48. package/dist/instance/PrimaryInstance.d.ts +84 -0
  49. package/dist/instance/Root.d.ts +31 -28
  50. package/dist/instance/SelectField.d.ts +13 -6
  51. package/dist/instance/Subtree.d.ts +10 -6
  52. package/dist/instance/TriggerControl.d.ts +47 -0
  53. package/dist/instance/abstract/DescendantNode.d.ts +33 -26
  54. package/dist/instance/abstract/InstanceNode.d.ts +50 -31
  55. package/dist/instance/abstract/UnsupportedControl.d.ts +53 -0
  56. package/dist/instance/abstract/ValueNode.d.ts +48 -0
  57. package/dist/instance/children.d.ts +0 -1
  58. package/dist/instance/hierarchy.d.ts +13 -8
  59. package/dist/instance/identity.d.ts +2 -7
  60. package/dist/instance/index.d.ts +0 -1
  61. package/dist/instance/internal-api/EvaluationContext.d.ts +53 -13
  62. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -3
  63. package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
  64. package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
  65. package/dist/instance/internal-api/TranslationContext.d.ts +3 -3
  66. package/dist/instance/internal-api/ValidationContext.d.ts +12 -6
  67. package/dist/instance/internal-api/ValueContext.d.ts +5 -5
  68. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
  69. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
  70. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
  71. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
  72. package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -85
  73. package/dist/instance/repeat/RepeatInstance.d.ts +11 -30
  74. package/dist/instance/repeat/RepeatRangeControlled.d.ts +3 -4
  75. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +3 -4
  76. package/dist/instance/resource.d.ts +1 -2
  77. package/dist/instance/text/TextChunk.d.ts +0 -1
  78. package/dist/instance/text/TextRange.d.ts +1 -2
  79. package/dist/instance/unsupported/RangeControl.d.ts +6 -0
  80. package/dist/instance/unsupported/RankControl.d.ts +6 -0
  81. package/dist/instance/unsupported/UploadControl.d.ts +6 -0
  82. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
  83. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
  84. package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
  85. package/dist/integration/xpath/adapter/kind.d.ts +32 -0
  86. package/dist/integration/xpath/adapter/names.d.ts +16 -0
  87. package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
  88. package/dist/integration/xpath/adapter/values.d.ts +2 -0
  89. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
  90. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
  91. package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
  92. package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
  93. package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
  94. package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
  95. package/dist/lib/TokenListParser.d.ts +3 -3
  96. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
  97. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
  98. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
  99. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
  100. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
  101. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
  102. package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
  103. package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
  104. package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
  105. package/dist/lib/codecs/ValueCodec.d.ts +30 -0
  106. package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
  107. package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
  108. package/dist/lib/dom/query.d.ts +4 -2
  109. package/dist/lib/reactivity/createChildrenState.d.ts +7 -6
  110. package/dist/lib/reactivity/createComputedExpression.d.ts +19 -7
  111. package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
  112. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -3
  113. package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
  114. package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
  115. package/dist/lib/reactivity/createValueState.d.ts +6 -11
  116. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -5
  117. package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
  118. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
  119. package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
  120. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +0 -1
  121. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
  122. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +0 -1
  123. package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
  124. package/dist/lib/reactivity/scope.d.ts +0 -1
  125. package/dist/lib/reactivity/text/createFieldHint.d.ts +1 -2
  126. package/dist/lib/reactivity/text/createNodeLabel.d.ts +1 -2
  127. package/dist/lib/reactivity/text/createNoteText.d.ts +1 -2
  128. package/dist/lib/reactivity/text/createTextRange.d.ts +0 -1
  129. package/dist/lib/reactivity/types.d.ts +0 -1
  130. package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +0 -1
  131. package/dist/lib/reactivity/validation/createValidation.d.ts +0 -1
  132. package/dist/lib/xml-serialization.d.ts +41 -0
  133. package/dist/parse/XFormDOM.d.ts +42 -0
  134. package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +3 -5
  135. package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
  136. package/dist/{body → parse/body}/BodyDefinition.d.ts +16 -11
  137. package/dist/{body → parse/body}/BodyElementDefinition.d.ts +7 -7
  138. package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +3 -4
  139. package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
  140. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +3 -0
  141. package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
  142. package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
  143. package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
  144. package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
  145. package/dist/{body/control/InputDefinition.d.ts → parse/body/control/InputControlDefinition.d.ts} +2 -3
  146. package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
  147. package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
  148. package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
  149. package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
  150. package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +2 -3
  151. package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +4 -5
  152. package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +1 -4
  153. package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
  154. package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
  155. package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
  156. package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
  157. package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
  158. package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
  159. package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
  160. package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
  161. package/dist/parse/expression/RepeatCountControlExpression.d.ts +2 -3
  162. package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
  163. package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
  164. package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
  165. package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
  166. package/dist/parse/expression/abstract/DependencyContext.d.ts +7 -0
  167. package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +4 -6
  168. package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
  169. package/dist/parse/model/BindDefinition.d.ts +38 -0
  170. package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
  171. package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -2
  172. package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
  173. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
  174. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
  175. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
  176. package/dist/{model → parse/model}/LeafNodeDefinition.d.ts +4 -3
  177. package/dist/{model → parse/model}/ModelBindMap.d.ts +1 -2
  178. package/dist/{model → parse/model}/ModelDefinition.d.ts +3 -2
  179. package/dist/{model → parse/model}/NodeDefinition.d.ts +0 -2
  180. package/dist/parse/{NoteNodeDefinition.d.ts → model/NoteNodeDefinition.d.ts} +12 -13
  181. package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +1 -2
  182. package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +2 -3
  183. package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
  184. package/dist/{model → parse/model}/RootDefinition.d.ts +5 -5
  185. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
  186. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
  187. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
  188. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
  189. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
  190. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
  191. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
  192. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
  193. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
  194. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
  195. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
  196. package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
  197. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
  198. package/dist/parse/text/HintDefinition.d.ts +2 -3
  199. package/dist/parse/text/ItemLabelDefinition.d.ts +2 -3
  200. package/dist/parse/text/ItemsetLabelDefinition.d.ts +3 -4
  201. package/dist/parse/text/LabelDefinition.d.ts +5 -6
  202. package/dist/parse/text/MessageDefinition.d.ts +4 -5
  203. package/dist/parse/text/abstract/TextElementDefinition.d.ts +8 -9
  204. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +4 -7
  205. package/dist/parse/xpath/path-resolution.d.ts +0 -1
  206. package/dist/parse/xpath/predicate-analysis.d.ts +0 -1
  207. package/dist/parse/xpath/reference-parsing.d.ts +0 -1
  208. package/dist/parse/xpath/semantic-analysis.d.ts +5 -1
  209. package/dist/parse/xpath/syntax-traversal.d.ts +0 -1
  210. package/dist/solid.js +8398 -4543
  211. package/dist/solid.js.map +1 -1
  212. package/package.json +14 -12
  213. package/src/client/BaseNode.ts +17 -7
  214. package/src/client/BaseValueNode.ts +35 -0
  215. package/src/client/EngineConfig.ts +52 -51
  216. package/src/client/GroupNode.ts +2 -2
  217. package/src/client/InputNode.ts +77 -0
  218. package/src/client/ModelValueNode.ts +31 -8
  219. package/src/client/NodeAppearances.ts +1 -1
  220. package/src/client/NoteNode.ts +3 -3
  221. package/src/client/RootNode.ts +39 -9
  222. package/src/client/SelectNode.ts +5 -5
  223. package/src/client/SubtreeNode.ts +1 -1
  224. package/src/client/TextRange.ts +4 -5
  225. package/src/client/TriggerNode.ts +29 -0
  226. package/src/client/ValueType.ts +4 -0
  227. package/src/client/constants.ts +67 -0
  228. package/src/client/hierarchy.ts +16 -4
  229. package/src/client/identity.ts +16 -0
  230. package/src/client/node-types.ts +19 -5
  231. package/src/client/repeat/BaseRepeatRangeNode.ts +1 -1
  232. package/src/client/repeat/RepeatInstanceNode.ts +2 -2
  233. package/src/client/repeat/RepeatRangeControlledNode.ts +1 -1
  234. package/src/client/repeat/RepeatRangeUncontrolledNode.ts +1 -1
  235. package/src/client/resources.ts +118 -0
  236. package/src/client/submission/SubmissionData.ts +12 -0
  237. package/src/client/submission/SubmissionDefinition.ts +16 -0
  238. package/src/client/submission/SubmissionInstanceFile.ts +9 -0
  239. package/src/client/submission/SubmissionOptions.ts +28 -0
  240. package/src/client/submission/SubmissionResult.ts +124 -0
  241. package/src/client/submission/SubmissionState.ts +14 -0
  242. package/src/client/unsupported/RangeNode.ts +14 -0
  243. package/src/client/unsupported/RankNode.ts +14 -0
  244. package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
  245. package/src/client/unsupported/UploadNode.ts +14 -0
  246. package/src/client/validation.ts +2 -2
  247. package/src/error/ErrorProductionDesignPendingError.ts +6 -0
  248. package/src/error/ValueTypeInvariantError.ts +22 -0
  249. package/src/error/XPathFunctionalityError.ts +26 -0
  250. package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
  251. package/src/error/XPathFunctionalityPendingError.ts +18 -0
  252. package/src/index.ts +16 -2
  253. package/src/instance/Group.ts +17 -5
  254. package/src/instance/InputControl.ts +119 -0
  255. package/src/instance/ModelValue.ts +47 -54
  256. package/src/instance/Note.ts +26 -10
  257. package/src/instance/PrimaryInstance.ts +244 -0
  258. package/src/instance/Root.ts +64 -132
  259. package/src/instance/SelectField.ts +62 -25
  260. package/src/instance/Subtree.ts +19 -7
  261. package/src/instance/{StringField.ts → TriggerControl.ts} +61 -30
  262. package/src/instance/abstract/DescendantNode.ts +92 -47
  263. package/src/instance/abstract/InstanceNode.ts +104 -98
  264. package/src/instance/abstract/UnsupportedControl.ts +174 -0
  265. package/src/instance/abstract/ValueNode.ts +127 -0
  266. package/src/instance/children.ts +83 -14
  267. package/src/instance/hierarchy.ts +36 -14
  268. package/src/instance/identity.ts +3 -9
  269. package/src/instance/index.ts +26 -8
  270. package/src/instance/internal-api/EvaluationContext.ts +61 -14
  271. package/src/instance/internal-api/InstanceConfig.ts +9 -2
  272. package/src/instance/internal-api/InstanceValueContext.ts +24 -0
  273. package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
  274. package/src/instance/internal-api/TranslationContext.ts +3 -2
  275. package/src/instance/internal-api/ValidationContext.ts +13 -5
  276. package/src/instance/internal-api/ValueContext.ts +5 -4
  277. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
  278. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
  279. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
  280. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
  281. package/src/instance/repeat/BaseRepeatRange.ts +51 -132
  282. package/src/instance/repeat/RepeatInstance.ts +20 -46
  283. package/src/instance/repeat/RepeatRangeControlled.ts +6 -6
  284. package/src/instance/repeat/RepeatRangeUncontrolled.ts +3 -5
  285. package/src/instance/resource.ts +1 -1
  286. package/src/instance/text/TextChunk.ts +1 -1
  287. package/src/instance/unsupported/RangeControl.ts +9 -0
  288. package/src/instance/unsupported/RankControl.ts +9 -0
  289. package/src/instance/unsupported/UploadControl.ts +9 -0
  290. package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
  291. package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
  292. package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
  293. package/src/integration/xpath/adapter/kind.ts +114 -0
  294. package/src/integration/xpath/adapter/names.ts +99 -0
  295. package/src/integration/xpath/adapter/traversal.ts +228 -0
  296. package/src/integration/xpath/adapter/values.ts +5 -0
  297. package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
  298. package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
  299. package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
  300. package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
  301. package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
  302. package/src/integration/xpath/static-dom/StaticText.ts +28 -0
  303. package/src/lib/TokenListParser.ts +11 -7
  304. package/src/lib/client-reactivity/README.md +0 -0
  305. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
  306. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
  307. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
  308. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
  309. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
  310. package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
  311. package/src/lib/codecs/DecimalValueCodec.ts +46 -0
  312. package/src/lib/codecs/IntValueCodec.ts +100 -0
  313. package/src/lib/codecs/StringValueCodec.ts +11 -0
  314. package/src/lib/codecs/ValueCodec.ts +106 -0
  315. package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
  316. package/src/lib/codecs/getSharedValueCodec.ts +77 -0
  317. package/src/lib/dom/query.ts +8 -1
  318. package/src/lib/reactivity/createChildrenState.ts +8 -6
  319. package/src/lib/reactivity/createComputedExpression.ts +59 -36
  320. package/src/lib/reactivity/createInstanceValueState.ts +166 -0
  321. package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
  322. package/src/lib/reactivity/createSelectItems.ts +23 -23
  323. package/src/lib/reactivity/createTranslationState.ts +61 -0
  324. package/src/lib/reactivity/createValueState.ts +64 -122
  325. package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
  326. package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
  327. package/src/lib/reactivity/text/createFieldHint.ts +1 -1
  328. package/src/lib/reactivity/text/createNodeLabel.ts +1 -1
  329. package/src/lib/reactivity/text/createNoteText.ts +1 -1
  330. package/src/lib/reactivity/text/createTextRange.ts +8 -7
  331. package/src/lib/reactivity/validation/createAggregatedViolations.ts +9 -4
  332. package/src/lib/reactivity/validation/createValidation.ts +2 -3
  333. package/src/lib/xml-serialization.ts +96 -0
  334. package/src/{XFormDOM.ts → parse/XFormDOM.ts} +110 -75
  335. package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +3 -8
  336. package/src/parse/attachments/FormAttachmentResource.ts +40 -0
  337. package/src/{body → parse/body}/BodyDefinition.ts +46 -29
  338. package/src/{body → parse/body}/BodyElementDefinition.ts +12 -6
  339. package/src/{body → parse/body}/RepeatElementDefinition.ts +7 -5
  340. package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +2 -2
  341. package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
  342. package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
  343. package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
  344. package/src/{body → parse/body}/control/ControlDefinition.ts +4 -4
  345. package/src/{body/control/InputDefinition.ts → parse/body/control/InputControlDefinition.ts} +3 -5
  346. package/src/parse/body/control/RangeControlDefinition.ts +26 -0
  347. package/src/parse/body/control/RankControlDefinition.ts +27 -0
  348. package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
  349. package/src/parse/body/control/UploadControlDefinition.ts +26 -0
  350. package/src/{body → parse/body}/control/select/ItemDefinition.ts +2 -2
  351. package/src/{body → parse/body}/control/select/ItemsetDefinition.ts +5 -5
  352. package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +1 -6
  353. package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
  354. package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -22
  355. package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
  356. package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -8
  357. package/src/{body/control/select → parse/expression}/ItemsetNodesetExpression.ts +2 -2
  358. package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
  359. package/src/parse/expression/RepeatCountControlExpression.ts +2 -2
  360. package/src/parse/expression/TextLiteralExpression.ts +19 -0
  361. package/src/parse/{text/OutputChunkDefinition.ts → expression/TextOutputExpression.ts} +4 -4
  362. package/src/parse/{text/ReferenceChunkDefinition.ts → expression/TextReferenceExpression.ts} +4 -4
  363. package/src/parse/{text/TranslationChunkDefinition.ts → expression/TextTranslationExpression.ts} +4 -4
  364. package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -26
  365. package/src/{expression → parse/expression/abstract}/DependentExpression.ts +5 -16
  366. package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
  367. package/src/parse/model/BindDefinition.ts +104 -0
  368. package/src/parse/model/BindTypeDefinition.ts +175 -0
  369. package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -6
  370. package/src/parse/model/FormSubmissionDefinition.ts +44 -0
  371. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
  372. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
  373. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
  374. package/src/{model → parse/model}/LeafNodeDefinition.ts +4 -1
  375. package/src/{model → parse/model}/ModelBindMap.ts +6 -8
  376. package/src/parse/model/ModelDefinition.ts +24 -0
  377. package/src/{model → parse/model}/NodeDefinition.ts +0 -3
  378. package/src/parse/{NoteNodeDefinition.ts → model/NoteNodeDefinition.ts} +12 -12
  379. package/src/{model → parse/model}/RepeatRangeDefinition.ts +1 -1
  380. package/src/{model → parse/model}/RootDefinition.ts +4 -3
  381. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
  382. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
  383. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
  384. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
  385. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
  386. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
  387. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
  388. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
  389. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
  390. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
  391. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
  392. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
  393. package/src/parse/text/HintDefinition.ts +2 -2
  394. package/src/parse/text/ItemLabelDefinition.ts +2 -2
  395. package/src/parse/text/ItemsetLabelDefinition.ts +7 -7
  396. package/src/parse/text/LabelDefinition.ts +5 -5
  397. package/src/parse/text/MessageDefinition.ts +7 -7
  398. package/src/parse/text/abstract/TextElementDefinition.ts +14 -14
  399. package/src/parse/text/abstract/TextRangeDefinition.ts +4 -10
  400. package/src/parse/xpath/semantic-analysis.ts +29 -0
  401. package/dist/XFormDOM.d.ts +0 -32
  402. package/dist/XFormDataType.d.ts +0 -27
  403. package/dist/body/appearance/inputAppearanceParser.d.ts +0 -4
  404. package/dist/client/StringNode.d.ts +0 -47
  405. package/dist/expression/DependencyContext.d.ts +0 -13
  406. package/dist/instance/StringField.d.ts +0 -45
  407. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -60
  408. package/dist/model/BindDefinition.d.ts +0 -34
  409. package/dist/parse/text/OutputChunkDefinition.d.ts +0 -8
  410. package/dist/parse/text/ReferenceChunkDefinition.d.ts +0 -8
  411. package/dist/parse/text/StaticTextChunkDefinition.d.ts +0 -10
  412. package/dist/parse/text/TranslationChunkDefinition.d.ts +0 -9
  413. package/dist/parse/text/abstract/TextChunkDefinition.d.ts +0 -18
  414. package/src/XFormDataType.ts +0 -64
  415. package/src/client/StringNode.ts +0 -52
  416. package/src/instance/internal-api/SubscribableDependency.ts +0 -61
  417. package/src/model/BindDefinition.ts +0 -106
  418. package/src/model/ModelDefinition.ts +0 -19
  419. package/src/parse/TODO.md +0 -3
  420. package/src/parse/text/StaticTextChunkDefinition.ts +0 -19
  421. package/src/parse/text/abstract/TextChunkDefinition.ts +0 -38
  422. /package/dist/{model → parse/model}/BindElement.d.ts +0 -0
  423. /package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
  424. /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
  425. /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
  426. /package/src/{model → parse/model}/BindElement.ts +0 -0
  427. /package/src/{model → parse/model}/RepeatInstanceDefinition.ts +0 -0
  428. /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
  429. /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
@@ -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,25 +1,37 @@
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
+ import type { TriggerNode } from './TriggerNode.ts';
13
+ import type { RangeNode } from './unsupported/RangeNode.ts';
14
+ import type { RankNode } from './unsupported/RankNode.ts';
15
+ import type { UploadNode } from './unsupported/UploadNode.ts';
16
+
17
+ // prettier-ignore
18
+ export type AnyUnsupportedControlNode =
19
+ | RangeNode
20
+ | RankNode
21
+ | UploadNode;
12
22
 
13
23
  // prettier-ignore
14
24
  export type AnyControlNode =
25
+ | AnyInputNode
15
26
  | NoteNode
16
27
  | SelectNode
17
- | StringNode;
28
+ | TriggerNode;
18
29
 
19
30
  // prettier-ignore
20
31
  export type AnyLeafNode =
21
32
  | AnyControlNode
22
- | ModelValueNode;
33
+ | AnyModelValueNode
34
+ | AnyUnsupportedControlNode;
23
35
 
24
36
  // prettier-ignore
25
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}`;
@@ -1,7 +1,23 @@
1
+ // prettier-ignore
2
+ export type UnsupportedControlNodeType =
3
+ | 'range'
4
+ | 'rank'
5
+ | 'upload';
6
+
1
7
  // prettier-ignore
2
8
  export type RepeatRangeNodeType =
3
9
  | 'repeat-range:controlled'
4
- | 'repeat-range:uncontrolled'
10
+ | 'repeat-range:uncontrolled';
11
+
12
+ // prettier-ignore
13
+ export type LeafNodeType =
14
+ // eslint-disable-next-line @typescript-eslint/sort-type-constituents
15
+ | 'model-value'
16
+ | 'note'
17
+ | 'select'
18
+ | 'input'
19
+ | 'trigger'
20
+ | UnsupportedControlNodeType;
5
21
 
6
22
  // prettier-ignore
7
23
  export type InstanceNodeType =
@@ -11,7 +27,5 @@ export type InstanceNodeType =
11
27
  | 'repeat-instance'
12
28
  | 'group'
13
29
  | 'subtree'
14
- | 'model-value'
15
- | 'note'
16
- | 'select'
17
- | 'string';
30
+ | LeafNodeType
31
+ | UnsupportedControlNodeType;
@@ -1,4 +1,4 @@
1
- import type { AnyRepeatRangeDefinition } from '../../model/RepeatRangeDefinition.ts';
1
+ import type { AnyRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
2
2
  import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
3
3
  import type { NodeAppearances } from '../NodeAppearances.ts';
4
4
  import type { RootNode } from '../RootNode.ts';
@@ -1,5 +1,5 @@
1
- import type { RepeatInstanceDefinition } from '../../model/RepeatInstanceDefinition.ts';
2
- import type { RepeatTemplateDefinition } from '../../model/RepeatTemplateDefinition.ts';
1
+ import type { RepeatInstanceDefinition } from '../../parse/model/RepeatInstanceDefinition.ts';
2
+ import type { RepeatTemplateDefinition } from '../../parse/model/RepeatTemplateDefinition.ts';
3
3
  import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
4
4
  import type { GeneralChildNode, RepeatRangeNode } from '../hierarchy.ts';
5
5
  import type { NodeAppearances } from '../NodeAppearances.ts';
@@ -1,4 +1,4 @@
1
- import type { ControlledRepeatRangeDefinition } from '../../model/RepeatRangeDefinition.ts';
1
+ import type { ControlledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
2
2
  import type { BaseRepeatRangeNode, BaseRepeatRangeNodeState } from './BaseRepeatRangeNode.ts';
3
3
  import type { RepeatRangeUncontrolledNode } from './RepeatRangeUncontrolledNode.ts';
4
4
 
@@ -1,4 +1,4 @@
1
- import type { UncontrolledRepeatRangeDefinition } from '../../model/RepeatRangeDefinition.ts';
1
+ import type { UncontrolledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
2
2
  import type { RootNode } from '../RootNode.ts';
3
3
  import type { BaseRepeatRangeNode, BaseRepeatRangeNodeState } from './BaseRepeatRangeNode.ts';
4
4
 
@@ -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];
@@ -0,0 +1,124 @@
1
+ import type { AnyViolation, DescendantNodeViolationReference } from '../validation.ts';
2
+ import type { SubmissionData } from './SubmissionData.ts';
3
+ import type { SubmissionDefinition } from './SubmissionDefinition.ts';
4
+ import type { SubmissionChunkedType, SubmissionOptions } from './SubmissionOptions.ts';
5
+
6
+ // prettier-ignore
7
+ export type SubmissionResultStatus =
8
+ // eslint-disable-next-line @typescript-eslint/sort-type-constituents
9
+ | 'pending'
10
+ | 'max-size-exceeded'
11
+ | 'ready';
12
+
13
+ // prettier-ignore
14
+ type SubmissionResultData<ChunkedType extends SubmissionChunkedType> = {
15
+ chunked: readonly [SubmissionData, ...SubmissionData[]];
16
+ monolithic: SubmissionData;
17
+ }[ChunkedType];
18
+
19
+ /**
20
+ * Provides detail about an individual submission attachment {@link File}s which
21
+ * exceeds the client-specified {@link maxSize} for a
22
+ * {@link SubmissionResult<'chunked'> | chunked submission result}. Clients may
23
+ * use this value to provide guidance to users.
24
+ *
25
+ * @todo We may want to consider (a) making {@link maxSize} a configuration the
26
+ * client can provide when initializing a form instance, rather than only on
27
+ * submission; and then (b) treating a maximum size violation as another kind of
28
+ * node-level violation. This would go beyond the kinds of validation specified
29
+ * by ODK XForms, but it would make a lot of _conceptual sense_.
30
+ *
31
+ * It would almost certainly be helpful to alert users to violations as the
32
+ * occur, rather than only at submission time (where they have likely already
33
+ * moved on). This is something clients can do without engine support, but it
34
+ * would likely promote good usability patterns if the engine makes it an
35
+ * obvious and uniform option at the main engine/client entrypoint.
36
+ *
37
+ * @todo If we consider the above, we'd want to reframe _this interface_ to
38
+ * match the shape of other {@link AnyViolation | violations} (adding it as a
39
+ * member of that union). We'd also likely eliminate
40
+ * {@link MaxSizeExceededResult} in the process, since
41
+ * {@link PendingSubmissionResult} would then cover the case.
42
+ */
43
+ interface MaxSizeViolation {
44
+ /**
45
+ * Specifies the index of
46
+ * {@link SubmissionResultData<'chunked'> | chunked submission data} where a
47
+ * submission attachment {@link File} exceeds the client-specified
48
+ * {@link maxSize}.
49
+ */
50
+ readonly dataIndex: number;
51
+
52
+ /**
53
+ * Specifies the name of the file which exceeds the client-specified
54
+ * {@link maxSize}. This name can also be used as a key to access the
55
+ * violating {@link File}/submission attachment, in the {@link SubmissionData}
56
+ * at the specified {@link dataIndex}.
57
+ */
58
+ readonly fileName: string;
59
+
60
+ /**
61
+ * Reflects the client-specified maximum size for each chunk of a
62
+ * {@link SubmissionResult<'chunked'> | chunked submission result}.
63
+ */
64
+ readonly maxSize: number;
65
+
66
+ /**
67
+ * Details the actual size of the violating {@link File}/submission
68
+ * attachment. Along with {@link maxSize}. Clients may use the delta between
69
+ * this value and {@link maxSize} to provide detailed guidance to users.
70
+ */
71
+ readonly actualSize: number;
72
+ }
73
+
74
+ // prettier-ignore
75
+ type SubmissionResultViolation =
76
+ | DescendantNodeViolationReference
77
+ | MaxSizeViolation;
78
+
79
+ interface BaseSubmissionResult<ChunkedType extends SubmissionChunkedType> {
80
+ readonly status: SubmissionResultStatus;
81
+ readonly definition: SubmissionDefinition;
82
+ get violations(): readonly SubmissionResultViolation[] | null;
83
+
84
+ /**
85
+ * Submission data may be chunked according to the
86
+ * {@link SubmissionOptions.maxSize | maxSize submission option}
87
+ */
88
+ readonly data: SubmissionResultData<ChunkedType>;
89
+ }
90
+
91
+ interface PendingSubmissionResult<ChunkedType extends SubmissionChunkedType>
92
+ extends BaseSubmissionResult<ChunkedType> {
93
+ readonly status: 'pending';
94
+ get violations(): readonly DescendantNodeViolationReference[];
95
+ }
96
+
97
+ interface MaxSizeExceededResult extends BaseSubmissionResult<'chunked'> {
98
+ readonly status: 'max-size-exceeded';
99
+ get violations(): readonly MaxSizeViolation[];
100
+ }
101
+
102
+ interface ReadySubmissionResult<ChunkedType extends SubmissionChunkedType>
103
+ extends BaseSubmissionResult<ChunkedType> {
104
+ readonly status: 'ready';
105
+ get violations(): null;
106
+ }
107
+
108
+ // prettier-ignore
109
+ type CommonSubmissionResult<ChunkedType extends SubmissionChunkedType> =
110
+ | PendingSubmissionResult<ChunkedType>
111
+ | ReadySubmissionResult<ChunkedType>;
112
+
113
+ // prettier-ignore
114
+ export type ChunkedSubmissionResult =
115
+ | CommonSubmissionResult<'chunked'>
116
+ | MaxSizeExceededResult;
117
+
118
+ export type MonolithicSubmissionResult = CommonSubmissionResult<'monolithic'>;
119
+
120
+ // prettier-ignore
121
+ export type SubmissionResult<ChunkedType extends SubmissionChunkedType> = {
122
+ chunked: ChunkedSubmissionResult;
123
+ monolithic: MonolithicSubmissionResult;
124
+ }[ChunkedType];
@@ -0,0 +1,14 @@
1
+ import type { RootNode } from '../RootNode.ts';
2
+
3
+ export interface SubmissionState {
4
+ /**
5
+ * Represents the serialized XML state of a given node, as it will be prepared
6
+ * for submission. The value produced in {@link RootNode.submissionState} is
7
+ * the same serialization which will be produced for the complete submission.
8
+ *
9
+ * @todo Note that this particular aspect of the design doesn't yet address
10
+ * production of unique file names. As such, this may change as we introduce
11
+ * affected data types (and their supporting nodes).
12
+ */
13
+ get submissionXML(): string;
14
+ }
@@ -0,0 +1,14 @@
1
+ import type { RangeControlDefinition } from '../../parse/body/control/RangeControlDefinition.ts';
2
+ import type {
3
+ UnsupportedControlDefinition,
4
+ UnsupportedControlNode,
5
+ } from './UnsupportedControlNode.ts';
6
+
7
+ export interface RangeNodeDefinition extends UnsupportedControlDefinition {
8
+ readonly bodyElement: RangeControlDefinition;
9
+ }
10
+
11
+ export interface RangeNode extends UnsupportedControlNode {
12
+ readonly nodeType: 'range';
13
+ readonly definition: RangeNodeDefinition;
14
+ }
@@ -0,0 +1,14 @@
1
+ import type { RankControlDefinition } from '../../parse/body/control/RankControlDefinition.ts';
2
+ import type {
3
+ UnsupportedControlDefinition,
4
+ UnsupportedControlNode,
5
+ } from './UnsupportedControlNode.ts';
6
+
7
+ export interface RankNodeDefinition extends UnsupportedControlDefinition {
8
+ readonly bodyElement: RankControlDefinition;
9
+ }
10
+
11
+ export interface RankNode extends UnsupportedControlNode {
12
+ readonly nodeType: 'rank';
13
+ readonly definition: RankNodeDefinition;
14
+ }
@@ -0,0 +1,40 @@
1
+ import type { UnknownAppearanceDefinition } from '../../parse/body/appearance/unknownAppearanceParser.ts';
2
+ import type { RangeControlDefinition } from '../../parse/body/control/RangeControlDefinition.ts';
3
+ import type { RankControlDefinition } from '../../parse/body/control/RankControlDefinition.ts';
4
+ import type { UploadControlDefinition } from '../../parse/body/control/UploadControlDefinition.ts';
5
+ import type { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
6
+ import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
7
+ import type { RootNode } from '../RootNode.ts';
8
+ import type { GeneralParentNode } from '../hierarchy.ts';
9
+ import type { UnsupportedControlNodeType } from '../node-types.ts';
10
+ import type { LeafNodeValidationState } from '../validation.ts';
11
+
12
+ export interface UnsupportedControlNodeState extends BaseNodeState {
13
+ get children(): null;
14
+ get valueOptions(): unknown;
15
+ get value(): unknown;
16
+ }
17
+
18
+ export type UnsupportedControlElementDefinition =
19
+ | RangeControlDefinition
20
+ | RankControlDefinition
21
+ | UploadControlDefinition;
22
+
23
+ export interface UnsupportedControlDefinition extends LeafNodeDefinition {
24
+ readonly bodyElement: UnsupportedControlElementDefinition;
25
+ }
26
+
27
+ /**
28
+ * Stub node, for form controls pending further engine support.
29
+ */
30
+ export interface UnsupportedControlNode extends BaseNode {
31
+ readonly nodeType: UnsupportedControlNodeType;
32
+ readonly appearances: UnknownAppearanceDefinition;
33
+ readonly definition: UnsupportedControlDefinition;
34
+ readonly root: RootNode;
35
+ readonly parent: GeneralParentNode;
36
+ readonly currentState: UnsupportedControlNodeState;
37
+ readonly validationState: LeafNodeValidationState;
38
+
39
+ setValue?(value: never): never;
40
+ }
@@ -0,0 +1,14 @@
1
+ import type { UploadControlDefinition } from '../../parse/body/control/UploadControlDefinition.ts';
2
+ import type {
3
+ UnsupportedControlDefinition,
4
+ UnsupportedControlNode,
5
+ } from './UnsupportedControlNode.ts';
6
+
7
+ export interface UploadNodeDefinition extends UnsupportedControlDefinition {
8
+ readonly bodyElement: UploadControlDefinition;
9
+ }
10
+
11
+ export interface UploadNode extends UnsupportedControlNode {
12
+ readonly nodeType: 'upload';
13
+ readonly definition: UploadNodeDefinition;
14
+ }
@@ -1,5 +1,5 @@
1
- import type { NodeID } from '../instance/identity.ts';
2
1
  import type { BaseNode, BaseNodeState } from './BaseNode.ts';
2
+ import type { FormNodeID } from './identity.ts';
3
3
  import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
4
4
  import type { RootNode } from './RootNode.ts';
5
5
  import type { TextRange } from './TextRange.ts';
@@ -176,7 +176,7 @@ export interface LeafNodeValidationState {
176
176
  * each property will be directly computed from the affected node.
177
177
  */
178
178
  export interface DescendantNodeViolationReference {
179
- readonly nodeId: NodeID;
179
+ readonly nodeId: FormNodeID;
180
180
 
181
181
  get reference(): string;
182
182
  get violation(): AnyViolation;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Temporary representation of newly introduced error conditions which we may
3
+ * produce to clients (and beyond). Intentionally a stub pending a more concrete
4
+ * design and implementation of our approach to producing Result types.
5
+ */
6
+ export class ErrorProductionDesignPendingError extends Error {}
@@ -0,0 +1,22 @@
1
+ import type { ValueType } from '../client/ValueType.ts';
2
+ import { ErrorProductionDesignPendingError } from './ErrorProductionDesignPendingError.ts';
3
+
4
+ /**
5
+ * Temporary(?) representation of error conditions arising from violation of
6
+ * invariants specific to {@link valueType}.
7
+ *
8
+ * @todo The intent of this distinct subclass of
9
+ * {@link ErrorProductionDesignPendingError} is to call out cases where we may
10
+ * want to represent such errors to clients as **validation errors** in the
11
+ * future. We identified this as probably desirable in the initial work on `int`
12
+ * and `decimal` value types, but held off on that aspect of implementation to
13
+ * tame scope.
14
+ */
15
+ export class ValueTypeInvariantError extends ErrorProductionDesignPendingError {
16
+ constructor(
17
+ readonly valueType: ValueType,
18
+ message: string
19
+ ) {
20
+ super(`(${valueType}) ${message}`);
21
+ }
22
+ }