@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
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Implementation of the [ODK XForms specification](https://getodk.github.io/xforms-spec/)'s data model and computation logic. This package does not handle presentation or user interaction. Those aspects of forms are meant to be handled by a client. Presently, those clients are:
4
4
 
5
5
  - [`@getodk/web-forms`](../web-forms)
6
- - [`@getodk/ui-solid`](../ui-solid)
6
+ - [`@getodk/scenario`](../scenario)
7
7
 
8
8
  ## Install
9
9
 
@@ -1,7 +1,9 @@
1
1
  import { AnyNodeDefinition } from '../parse/model/NodeDefinition.ts';
2
2
  import { NodeAppearances } from './NodeAppearances.ts';
3
3
  import { TextRange } from './TextRange.ts';
4
+ import { FormNodeID } from './identity.ts';
4
5
  import { InstanceNodeType } from './node-types.ts';
6
+ import { SubmissionState } from './submission/SubmissionState.ts';
5
7
  import { NodeValidationState } from './validation.ts';
6
8
  export interface BaseNodeState {
7
9
  /**
@@ -113,7 +115,6 @@ export interface BaseNodeState {
113
115
  */
114
116
  get value(): unknown;
115
117
  }
116
- type FormNodeID = string;
117
118
  /**
118
119
  * Base interface for common/shared aspects of any node type.
119
120
  */
@@ -132,6 +133,10 @@ export interface BaseNode {
132
133
  * @see {@link TokenListParser} for details.
133
134
  */
134
135
  readonly appearances: NodeAppearances<any> | null;
136
+ /**
137
+ * A node can have options that determine its behavior.
138
+ */
139
+ readonly nodeOptions: object | null;
135
140
  /**
136
141
  * Each node has a definition which specifies aspects of the node defined in
137
142
  * the form. These aspects include (but are not limited to) the node's data
@@ -153,7 +158,7 @@ export interface BaseNode {
153
158
  * Each node links back to its parent, if any. All nodes have a parent except
154
159
  * the form's {@link root}.
155
160
  */
156
- readonly parent: BaseNode | null;
161
+ readonly parent: unknown;
157
162
  /**
158
163
  * Each node provides a discrete object representing the stateful aspects\* of
159
164
  * that node which will change over time. When a client provides a
@@ -205,5 +210,15 @@ export interface BaseNode {
205
210
  * clients to explicitly pause and resume recomputation.
206
211
  */
207
212
  readonly validationState: NodeValidationState;
213
+ /**
214
+ * Represents the current submission state of the node.
215
+ *
216
+ * @see {@link SubmissionState.submissionXML} for additional detail.
217
+ *
218
+ * @todo Consider whether this can (should) be merged with
219
+ * {@link currentState}, while providing the same client-reactivity
220
+ * guarantees. (The challenge there is in defining client-reactive state which
221
+ * self-referentially derives state from its own definition.)
222
+ */
223
+ readonly submissionState: SubmissionState;
208
224
  }
209
- export {};
@@ -0,0 +1,32 @@
1
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
2
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
3
+ import { GeneralParentNode } from './hierarchy.ts';
4
+ import { LeafNodeType } from './node-types.ts';
5
+ import { LeafNodeValidationState } from './validation.ts';
6
+ import { ValueType } from './ValueType.ts';
7
+ export interface BaseValueNodeState<Value> extends BaseNodeState {
8
+ get children(): null;
9
+ get valueOptions(): unknown;
10
+ get value(): Value;
11
+ /**
12
+ * Reflects the serialized string representation of a {@link BaseValueNode}'s
13
+ * {@link value} state. This representation allows access to the node's value
14
+ * _as primary instance state_. In other words, this is the value which:
15
+ *
16
+ * - would be serialized as a text node in
17
+ * {@link SubmissionState.submissionXML} (note: this value is **NOT**
18
+ * escaped for XML serialization, as it is there)
19
+ *
20
+ * - is used when the node's value is referenced in any of a form's XPath
21
+ * expressions
22
+ */
23
+ get instanceValue(): string;
24
+ }
25
+ export interface BaseValueNode<V extends ValueType = ValueType, Value = string> extends BaseNode {
26
+ readonly nodeType: LeafNodeType;
27
+ readonly valueType: V;
28
+ readonly definition: LeafNodeDefinition;
29
+ readonly parent: GeneralParentNode;
30
+ readonly currentState: BaseValueNodeState<Value>;
31
+ readonly validationState: LeafNodeValidationState;
32
+ }
@@ -1,32 +1,6 @@
1
+ import { MissingResourceBehavior } from './constants.ts';
1
2
  import { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
2
- /**
3
- * @todo this is currently a strict subset of the web standard `Response`. Is it
4
- * sufficient? Ways it might not be:
5
- *
6
- * - No way to convey metadata about the resource
7
- * - Ambiguous if a client supplies an alternative implementation which doesn't
8
- * exhaust the body on access
9
- */
10
- export interface FetchResourceResponse {
11
- readonly ok?: boolean;
12
- readonly body?: ReadableStream<Uint8Array> | null;
13
- readonly bodyUsed?: boolean;
14
- readonly blob: () => Promise<Blob>;
15
- readonly text: () => Promise<string>;
16
- }
17
- /**
18
- * @todo this is a strict subset of the web standard `fetch` interface. It
19
- * implicitly assumes that the engine itself will only ever issue `GET`-like
20
- * requests. It also provides no further request-like semantics to the engine.
21
- * This is presumed sufficient for now, but notably doesn't expose any notion of
22
- * content negotiation (e.g. the ability to supply `Accept` headers).
23
- *
24
- * This also completely ignores any notion of mapping
25
- * {@link https://getodk.github.io/xforms-spec/#uris | `jr:` URLs} to their
26
- * actual resources (likely, but not necessarily, accessed at a corresponding
27
- * HTTP URL).
28
- */
29
- export type FetchResource = (resource: URL) => Promise<FetchResourceResponse>;
3
+ import { FetchFormAttachment, FetchResource } from './resources.ts';
30
4
  /**
31
5
  * Options provided by a client to specify certain aspects of engine runtime
32
6
  * behavior. These options will generally be intended to facilitate cooperation
@@ -50,29 +24,56 @@ export interface EngineConfig {
50
24
  */
51
25
  readonly stateFactory?: OpaqueReactiveObjectFactory;
52
26
  /**
53
- * A client may specify a generic function for retrieving resources referenced
54
- * by a form, such as:
55
27
  *
56
- * - Form definitions themselves (if not provided directly to the engine by
57
- * the client)
58
- * - External secondary instances
59
- * - Media (images, audio, video, etc.)
28
+ * A client may specify an arbitrary {@link fetch}-like function for retrieving an XML XForm form
29
+ * definition.
30
+ *
31
+ * Notes:
60
32
  *
61
- * The function is expected to be a subset of the
62
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API},
63
- * performing `GET` requests for:
33
+ * - This configuration will only be consuled for calls to
34
+ * {@link initializeForm} with a URL referencing an XML XForm definition. It
35
+ * will be ignored for calls passing an XML XForm form definition directly.
64
36
  *
65
- * - Text resources (e.g. XML, CSV, JSON/GeoJSON)
66
- * - Binary resources (e.g. media)
67
- * - Optionally streamed binary data of either (e.g. for optimized
68
- * presentation of audio/video)
37
+ * - For calls to {@link initializeForm} with a URL, if this configuration is
38
+ * not specified it will default to the global {@link fetch} function (if
39
+ * one is defined).
40
+ */
41
+ readonly fetchFormDefinition?: FetchResource;
42
+ /**
43
+ * A client may specify an arbitrary {@link fetch}-like function to retrieve a
44
+ * form's attachments, i.e. any `jr:` URL referenced by the form (as specified
45
+ * by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
46
+ *
47
+ * Notes:
48
+ *
49
+ * - This configuration will be consulted for all supported form attachments,
50
+ * as a part of {@link initializeForm | form initialization}.
51
+ *
52
+ * - If this configuration is not specified it will default to the global
53
+ * {@link fetch} function (if one is defined).
54
+ *
55
+ * This default behavior will typically result in failure to load form
56
+ * attachments—and in most cases this will also cause
57
+ * {@link initializeForm | form initialization} to fail overall—with the
58
+ * following exceptions:
59
+ *
60
+ * - **CLIENT-SPECIFIC:** Usage in coordination with a client-implemented
61
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Serivce Worker},
62
+ * which can intercept network requests **generally**. Clients already using
63
+ * a Service Worker may opt for the convenience of handling network requests
64
+ * for `jr:` URLs along with any other network interception logic. Client
65
+ * implementors should be warned, however, that such `jr:` URLs are not
66
+ * namespaced or otherwise scoped to a particular form; such a client would
67
+ * therefore inherently need to coordinate state between the Service Worker
68
+ * and the main thread (or whatever other realm calls
69
+ * {@link initializeForm}).
70
+ */
71
+ readonly fetchFormAttachment?: FetchFormAttachment;
72
+ /**
73
+ * @see {@link MissingResourceBehavior}
74
+ * @see {@link MissingResourceBehaviorDefault}
69
75
  *
70
- * If provided by a client, this function will be used by the engine to
71
- * retrieve any such resource, as required for engine functionality. If
72
- * absent, the engine will use the native `fetch` function (if available, a
73
- * polyfill otherwise). Clients may use this function to provide resources
74
- * from sources other than the network, (or even in a test client to provide
75
- * e.g. resources from test fixtures).
76
+ * @default MissingResourceBehaviorDefault
76
77
  */
77
- readonly fetchResource?: FetchResource;
78
+ readonly missingResourceBehavior?: MissingResourceBehavior;
78
79
  }
@@ -21,6 +21,7 @@ export type GroupNodeAppearances = NodeAppearances<GroupDefinition>;
21
21
  export interface GroupNode extends BaseNode {
22
22
  readonly nodeType: 'group';
23
23
  readonly appearances: GroupNodeAppearances;
24
+ readonly nodeOptions: null;
24
25
  readonly definition: GroupDefinition;
25
26
  readonly root: RootNode;
26
27
  readonly parent: GeneralParentNode;
@@ -0,0 +1,82 @@
1
+ import { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
2
+ import { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
3
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
4
+ import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
5
+ import { NodeAppearances } from './NodeAppearances.ts';
6
+ import { RootNode } from './RootNode.ts';
7
+ import { ValueType } from './ValueType.ts';
8
+ import { GeneralParentNode } from './hierarchy.ts';
9
+ import { LeafNodeValidationState } from './validation.ts';
10
+ export type InputValue<V extends ValueType> = RuntimeValue<V>;
11
+ export type InputNodeInputValue<V extends ValueType> = RuntimeInputValue<V>;
12
+ export interface InputNodeState<V extends ValueType> extends BaseValueNodeState<InputValue<V>> {
13
+ get children(): null;
14
+ get valueOptions(): null;
15
+ /**
16
+ * Reflects the current value of a {@link InputNode}. This value may be
17
+ * populated when a form is loaded, and it may be updated by certain
18
+ * computations defined by the form. It may also be updated by a client, using
19
+ * the {@link InputNode.setValue} method.
20
+ */
21
+ get value(): InputValue<V>;
22
+ }
23
+ export interface InputDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
24
+ readonly bodyElement: InputControlDefinition;
25
+ }
26
+ export type InputNodeAppearances = NodeAppearances<InputDefinition>;
27
+ interface StringInputNodeOptions {
28
+ readonly rows: number | null;
29
+ }
30
+ interface GeoInputNodeOptions {
31
+ readonly accuracyThreshold: number | null;
32
+ readonly unacceptableAccuracyThreshold: number | null;
33
+ }
34
+ interface InputNodeOptionsByValueType {
35
+ readonly string: StringInputNodeOptions;
36
+ readonly int: null;
37
+ readonly boolean: null;
38
+ readonly decimal: null;
39
+ readonly date: null;
40
+ readonly time: null;
41
+ readonly dateTime: null;
42
+ readonly geopoint: GeoInputNodeOptions;
43
+ readonly geotrace: GeoInputNodeOptions;
44
+ readonly geoshape: GeoInputNodeOptions;
45
+ readonly binary: null;
46
+ readonly barcode: null;
47
+ readonly intent: null;
48
+ }
49
+ export type InputNodeOptions<V extends ValueType> = InputNodeOptionsByValueType[V];
50
+ /**
51
+ * A node corresponding to form field defined as an
52
+ * {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<input>`},
53
+ * which a user-facing client would likely present for a user to fill.
54
+ */
55
+ export interface InputNode<V extends ValueType = ValueType> extends BaseValueNode<V, InputValue<V>> {
56
+ readonly nodeType: 'input';
57
+ readonly valueType: V;
58
+ readonly appearances: InputNodeAppearances;
59
+ readonly nodeOptions: InputNodeOptions<V>;
60
+ readonly definition: InputDefinition<V>;
61
+ readonly root: RootNode;
62
+ readonly parent: GeneralParentNode;
63
+ readonly currentState: InputNodeState<V>;
64
+ readonly validationState: LeafNodeValidationState;
65
+ /**
66
+ * For use by a client to update the value of an {@link InputNode}.
67
+ */
68
+ setValue(value: InputNodeInputValue<V>): RootNode;
69
+ }
70
+ export type StringInputValue = InputValue<'string'>;
71
+ export type IntInputValue = InputValue<'int'>;
72
+ export type DecimalInputValue = InputValue<'decimal'>;
73
+ export type GeopointInputValue = InputValue<'geopoint'>;
74
+ export type StringInputNode = InputNode<'string'>;
75
+ export type IntInputNode = InputNode<'int'>;
76
+ export type DecimalInputNode = InputNode<'decimal'>;
77
+ export type GeopointInputNode = InputNode<'geopoint'>;
78
+ type SupportedInputValueType = 'string' | 'int' | 'decimal' | 'geopoint';
79
+ type TemporaryStringValueType = Exclude<ValueType, SupportedInputValueType>;
80
+ export type TemporaryStringValueInputNode = InputNode<TemporaryStringValueType>;
81
+ export type AnyInputNode = StringInputNode | IntInputNode | DecimalInputNode | GeopointInputNode | TemporaryStringValueInputNode;
82
+ export {};
@@ -1,9 +1,12 @@
1
+ import { RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
1
2
  import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
2
- import { BaseNode, BaseNodeState } from './BaseNode.ts';
3
+ import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
3
4
  import { GeneralParentNode } from './hierarchy.ts';
4
5
  import { RootNode } from './RootNode.ts';
5
6
  import { LeafNodeValidationState } from './validation.ts';
6
- export interface ModelValueNodeState extends BaseNodeState {
7
+ import { ValueType } from './ValueType.ts';
8
+ export type ModelValue<V extends ValueType> = RuntimeValue<V>;
9
+ export interface ModelValueNodeState<V extends ValueType> extends BaseValueNodeState<ModelValue<V>> {
7
10
  get label(): null;
8
11
  get hint(): null;
9
12
  get children(): null;
@@ -13,9 +16,9 @@ export interface ModelValueNodeState extends BaseNodeState {
13
16
  * populated when a form is loaded, and it may be updated by certain
14
17
  * computations defined by the form.
15
18
  */
16
- get value(): string;
19
+ get value(): ModelValue<V>;
17
20
  }
18
- export interface ModelValueDefinition extends LeafNodeDefinition {
21
+ export interface ModelValueDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
19
22
  readonly bodyElement: null;
20
23
  }
21
24
  /**
@@ -25,12 +28,15 @@ export interface ModelValueDefinition extends LeafNodeDefinition {
25
28
  * - a leaf/value node (i.e. it has no element children; it may be defined in
26
29
  * the form's `<model>` as either an {@link Element} or {@link Attr})
27
30
  */
28
- export interface ModelValueNode extends BaseNode {
31
+ export interface ModelValueNode<V extends ValueType = ValueType> extends BaseValueNode<V, ModelValue<V>> {
29
32
  readonly nodeType: 'model-value';
33
+ readonly valueType: V;
30
34
  readonly appearances: null;
31
- readonly definition: ModelValueDefinition;
35
+ readonly nodeOptions: null;
36
+ readonly definition: ModelValueDefinition<V>;
32
37
  readonly root: RootNode;
33
38
  readonly parent: GeneralParentNode;
34
- readonly currentState: ModelValueNodeState;
39
+ readonly currentState: ModelValueNodeState<V>;
35
40
  readonly validationState: LeafNodeValidationState;
36
41
  }
42
+ export type AnyModelValueNode = ModelValueNode<'barcode'> | ModelValueNode<'binary'> | ModelValueNode<'boolean'> | ModelValueNode<'date'> | ModelValueNode<'dateTime'> | ModelValueNode<'decimal'> | ModelValueNode<'geopoint'> | ModelValueNode<'geoshape'> | ModelValueNode<'geotrace'> | ModelValueNode<'int'> | ModelValueNode<'intent'> | ModelValueNode<'string'> | ModelValueNode<'time'>;
@@ -1,12 +1,15 @@
1
- import { InputDefinition } from '../parse/body/control/InputDefinition.ts';
1
+ import { NoteRuntimeValue } from '../lib/codecs/NoteCodec.ts';
2
+ import { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
2
3
  import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
- import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
4
5
  import { GeneralParentNode } from './hierarchy.ts';
5
6
  import { NodeAppearances } from './NodeAppearances.ts';
6
7
  import { RootNode } from './RootNode.ts';
7
8
  import { TextRange } from './TextRange.ts';
8
9
  import { LeafNodeValidationState } from './validation.ts';
9
- export interface NoteNodeState extends BaseNodeState {
10
+ import { ValueType } from './ValueType.ts';
11
+ export type NoteValue<V extends ValueType> = NoteRuntimeValue<V>;
12
+ export interface NoteNodeState<V extends ValueType> extends BaseValueNodeState<NoteValue<V>> {
10
13
  /**
11
14
  * Note-specific specialization: a note will always have a non-null value in
12
15
  * at least one of:
@@ -29,10 +32,10 @@ export interface NoteNodeState extends BaseNodeState {
29
32
  /**
30
33
  * Reflects the readonly value of a {@link NoteNode}, or `null` if blank.
31
34
  */
32
- get value(): string | null;
35
+ get value(): NoteValue<V>;
33
36
  }
34
- export interface NoteDefinition extends LeafNodeDefinition {
35
- readonly bodyElement: InputDefinition;
37
+ export interface NoteDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
38
+ readonly bodyElement: InputControlDefinition;
36
39
  }
37
40
  export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
38
41
  /**
@@ -41,12 +44,26 @@ export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
41
44
  * - associated with an input, with at least one text element (label or hint)
42
45
  * - guaranteed to be {@link NoteNodeState.readonly | readonly}
43
46
  */
44
- export interface NoteNode extends BaseNode {
47
+ export interface NoteNode<V extends ValueType = ValueType> extends BaseValueNode<V, NoteValue<V>> {
45
48
  readonly nodeType: 'note';
46
49
  readonly appearances: NoteNodeAppearances;
47
- readonly definition: NoteDefinition;
50
+ readonly nodeOptions: null;
51
+ readonly definition: NoteDefinition<V>;
48
52
  readonly root: RootNode;
49
53
  readonly parent: GeneralParentNode;
50
- readonly currentState: NoteNodeState;
54
+ readonly currentState: NoteNodeState<V>;
51
55
  readonly validationState: LeafNodeValidationState;
52
56
  }
57
+ export type StringNoteValue = NoteValue<'string'>;
58
+ export type IntNoteValue = NoteValue<'int'>;
59
+ export type DecimalNoteValue = NoteValue<'decimal'>;
60
+ export type GeopointNoteValue = NoteValue<'geopoint'>;
61
+ export type StringNoteNode = NoteNode<'string'>;
62
+ export type IntNoteNode = NoteNode<'int'>;
63
+ export type DecimalNoteNode = NoteNode<'decimal'>;
64
+ export type GeopointNoteNode = NoteNode<'geopoint'>;
65
+ type SupportedNoteValueType = 'string' | 'int' | 'decimal' | 'geopoint';
66
+ type TemporaryStringValueType = Exclude<ValueType, SupportedNoteValueType>;
67
+ export type TemporaryStringValueNoteNode = NoteNode<TemporaryStringValueType>;
68
+ export type AnyNoteNode = StringNoteNode | IntNoteNode | DecimalNoteNode | GeopointNoteNode | TemporaryStringValueNoteNode;
69
+ export {};
@@ -0,0 +1,36 @@
1
+ import { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
2
+ import { RangeNodeDefinition, RangeValueType } from '../parse/model/RangeNodeDefinition.ts';
3
+ import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
4
+ import { NodeAppearances } from './NodeAppearances.ts';
5
+ import { RootNode } from './RootNode.ts';
6
+ import { GeneralParentNode } from './hierarchy.ts';
7
+ import { LeafNodeValidationState } from './validation.ts';
8
+ export type { RangeValueType };
9
+ export type RangeValue<V extends RangeValueType> = RuntimeValue<V>;
10
+ export type RangeInputValue<V extends RangeValueType> = RuntimeInputValue<V>;
11
+ export interface RangeNodeState<V extends RangeValueType> extends BaseValueNodeState<RangeValue<V>> {
12
+ get valueOptions(): null;
13
+ }
14
+ export type RangeNodeAppearances = NodeAppearances<RangeNodeDefinition>;
15
+ /**
16
+ * A node corresponding to form field defined as an
17
+ * {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<range>`}.
18
+ */
19
+ export interface RangeNode<V extends RangeValueType = RangeValueType> extends BaseValueNode<V, RangeValue<V>> {
20
+ readonly nodeType: 'range';
21
+ readonly valueType: V;
22
+ readonly appearances: RangeNodeAppearances;
23
+ readonly nodeOptions: null;
24
+ readonly definition: RangeNodeDefinition<V>;
25
+ readonly root: RootNode;
26
+ readonly parent: GeneralParentNode;
27
+ readonly currentState: RangeNodeState<V>;
28
+ readonly validationState: LeafNodeValidationState;
29
+ /**
30
+ * For use by a client to update the value of an {@link RangeNode}.
31
+ */
32
+ setValue(value: RangeInputValue<V>): RootNode;
33
+ }
34
+ export type IntRangeNode = RangeNode<'int'>;
35
+ export type DecimalRangeNode = RangeNode<'decimal'>;
36
+ export type AnyRangeNode = IntRangeNode | DecimalRangeNode;
@@ -0,0 +1,46 @@
1
+ import { RankControlDefinition } from '../parse/body/control/RankControlDefinition.ts';
2
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
+ import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
4
+ import { RootNode } from './RootNode.ts';
5
+ import { TextRange } from './TextRange.ts';
6
+ import { GeneralParentNode } from './hierarchy.ts';
7
+ import { LeafNodeValidationState } from './validation.ts';
8
+ import { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
9
+ import { ValueType } from './ValueType.ts';
10
+ export interface RankItem {
11
+ get label(): TextRange<'item-label'>;
12
+ get value(): string;
13
+ }
14
+ export type RankValueOptions = readonly RankItem[];
15
+ export interface RankNodeState extends BaseValueNodeState<readonly string[]> {
16
+ get valueOptions(): RankValueOptions;
17
+ /**
18
+ * An ordered collection of values from {@link RankItem}.
19
+ * The order of the items is important and must be preserved during processing.
20
+ */
21
+ get value(): readonly string[];
22
+ }
23
+ export interface RankDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
24
+ readonly bodyElement: RankControlDefinition;
25
+ }
26
+ export interface RankNode extends BaseValueNode<'string', readonly string[]> {
27
+ readonly nodeType: 'rank';
28
+ readonly appearances: UnknownAppearanceDefinition;
29
+ readonly nodeOptions: null;
30
+ readonly valueType: 'string';
31
+ readonly definition: RankDefinition<'string'>;
32
+ readonly root: RootNode;
33
+ readonly parent: GeneralParentNode;
34
+ readonly currentState: RankNodeState;
35
+ readonly validationState: LeafNodeValidationState;
36
+ /**
37
+ * Convenience API to get the {@link RankItem}'s label.
38
+ */
39
+ getValueLabel(value: string): TextRange<'item-label'> | null;
40
+ /**
41
+ * Set the value which is an ordered collection of values from {@link RankItem}.
42
+ * Calling this setter replaces the currently value.
43
+ * If called with an empty array, the current is cleared.
44
+ */
45
+ setValues(values: readonly string[]): RootNode;
46
+ }
@@ -3,13 +3,13 @@ import { RootDefinition } from '../parse/model/RootDefinition.ts';
3
3
  import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
5
5
  import { GeneralChildNode } from './hierarchy.ts';
6
+ import { SubmissionOptions } from './submission/SubmissionOptions.ts';
7
+ import { ChunkedSubmissionResult, MonolithicSubmissionResult } from './submission/SubmissionResult.ts';
6
8
  import { AncestorNodeValidationState } from './validation.ts';
7
9
  export interface RootNodeState extends BaseNodeState {
8
10
  /**
9
- * This, along with {@link RootNode.languages} is the most significant break
10
- in consistency across node types' state and static properties. Exposing it
11
- across all node types seems like a point of potential confusion, so this
12
- particular divergence seems like the most reasonable compromise.
11
+ * @todo If we ever expose an interface to the primary instance document, it
12
+ * would make sense to move this state up.
13
13
  */
14
14
  get activeLanguage(): ActiveLanguage;
15
15
  get label(): null;
@@ -24,6 +24,7 @@ export interface RootNode extends BaseNode {
24
24
  * @todo this along with {@link classes} is... awkward.
25
25
  */
26
26
  readonly appearances: null;
27
+ readonly nodeOptions: null;
27
28
  /**
28
29
  * @todo This is another odd deviation in {@link RootNode}. Unlike
29
30
  * {@link languages}, it doesn't feel particularly **essential**. While it
@@ -40,13 +41,42 @@ export interface RootNode extends BaseNode {
40
41
  readonly classes: BodyClassList;
41
42
  readonly definition: RootDefinition;
42
43
  readonly root: RootNode;
43
- readonly parent: null;
44
+ readonly parent: unknown;
44
45
  readonly currentState: RootNodeState;
45
46
  readonly validationState: AncestorNodeValidationState;
46
47
  /**
47
- * @todo as with {@link RootNodeState.activeLanguage}, this is the most
48
- * significant break in consistency across node types.
48
+ * @todo as discussed on {@link RootNodeState.activeLanguage}
49
49
  */
50
50
  readonly languages: FormLanguages;
51
51
  setLanguage(language: FormLanguage): RootNode;
52
+ /**
53
+ * Prepares the current form instance state for submission.
54
+ *
55
+ * A {@link SubmissionResult} will be prepared even if the current form state
56
+ * includes `constraint` or `required` violations. This is intended to serve
57
+ * two purposes:
58
+ *
59
+ * - A client may effectively use this method as a part of its own "submit"
60
+ * routine, and use any violations included in the {@link SubmissionResult}
61
+ * to prompt users to address those violations.
62
+ *
63
+ * - A client may inspect the submission state of a form at any time.
64
+ * Depending on the client and use case, this may be a convenience (e.g. for
65
+ * developers to inspect that form state at a current point in time); or it
66
+ * may provide necessary functionality (e.g. for test or tooling clients).
67
+ *
68
+ * Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
69
+ * a fast operation. It may even be nearly instantaneous, or roughly
70
+ * proportionate to the size of the form itself. However, this method is
71
+ * designed to be asynchronous out of an abundance of caution, anticipating
72
+ * that some as-yet undeveloped operations on binary data (e.g. form
73
+ * attachments) may themselves impose asynchrony (i.e. by interfaces provided
74
+ * by the platform and/or external dependencies).
75
+ *
76
+ * A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
77
+ * {@link SubmissionResult<'chunked'>} will be produced, with form attachments
78
+ */
79
+ prepareSubmission(): Promise<MonolithicSubmissionResult>;
80
+ prepareSubmission(options: SubmissionOptions<'monolithic'>): Promise<MonolithicSubmissionResult>;
81
+ prepareSubmission(options: SubmissionOptions<'chunked'>): Promise<ChunkedSubmissionResult>;
52
82
  }