@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,9 +1,10 @@
1
- import { AnyNodeDefinition } from '../model/NodeDefinition.ts';
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
-
7
8
  export interface BaseNodeState {
8
9
  /**
9
10
  * Location path reference to the node's primary instance state. This property
@@ -114,7 +115,6 @@ export interface BaseNodeState {
114
115
  */
115
116
  get value(): unknown;
116
117
  }
117
- type FormNodeID = string;
118
118
  /**
119
119
  * Base interface for common/shared aspects of any node type.
120
120
  */
@@ -154,7 +154,7 @@ export interface BaseNode {
154
154
  * Each node links back to its parent, if any. All nodes have a parent except
155
155
  * the form's {@link root}.
156
156
  */
157
- readonly parent: BaseNode | null;
157
+ readonly parent: unknown;
158
158
  /**
159
159
  * Each node provides a discrete object representing the stateful aspects\* of
160
160
  * that node which will change over time. When a client provides a
@@ -206,5 +206,15 @@ export interface BaseNode {
206
206
  * clients to explicitly pause and resume recomputation.
207
207
  */
208
208
  readonly validationState: NodeValidationState;
209
+ /**
210
+ * Represents the current submission state of the node.
211
+ *
212
+ * @see {@link SubmissionState.submissionXML} for additional detail.
213
+ *
214
+ * @todo Consider whether this can (should) be merged with
215
+ * {@link currentState}, while providing the same client-reactivity
216
+ * guarantees. (The challenge there is in defining client-reactive state which
217
+ * self-referentially derives state from its own definition.)
218
+ */
219
+ readonly submissionState: SubmissionState;
209
220
  }
210
- 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(): null;
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,33 +1,6 @@
1
+ import { MissingResourceBehavior } from './constants.ts';
1
2
  import { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
2
-
3
- /**
4
- * @todo this is currently a strict subset of the web standard `Response`. Is it
5
- * sufficient? Ways it might not be:
6
- *
7
- * - No way to convey metadata about the resource
8
- * - Ambiguous if a client supplies an alternative implementation which doesn't
9
- * exhaust the body on access
10
- */
11
- export interface FetchResourceResponse {
12
- readonly ok?: boolean;
13
- readonly body?: ReadableStream<Uint8Array> | null;
14
- readonly bodyUsed?: boolean;
15
- readonly blob: () => Promise<Blob>;
16
- readonly text: () => Promise<string>;
17
- }
18
- /**
19
- * @todo this is a strict subset of the web standard `fetch` interface. It
20
- * implicitly assumes that the engine itself will only ever issue `GET`-like
21
- * requests. It also provides no further request-like semantics to the engine.
22
- * This is presumed sufficient for now, but notably doesn't expose any notion of
23
- * content negotiation (e.g. the ability to supply `Accept` headers).
24
- *
25
- * This also completely ignores any notion of mapping
26
- * {@link https://getodk.github.io/xforms-spec/#uris | `jr:` URLs} to their
27
- * actual resources (likely, but not necessarily, accessed at a corresponding
28
- * HTTP URL).
29
- */
30
- export type FetchResource = (resource: URL) => Promise<FetchResourceResponse>;
3
+ import { FetchFormAttachment, FetchResource } from './resources.ts';
31
4
  /**
32
5
  * Options provided by a client to specify certain aspects of engine runtime
33
6
  * behavior. These options will generally be intended to facilitate cooperation
@@ -51,29 +24,56 @@ export interface EngineConfig {
51
24
  */
52
25
  readonly stateFactory?: OpaqueReactiveObjectFactory;
53
26
  /**
54
- * A client may specify a generic function for retrieving resources referenced
55
- * by a form, such as:
56
27
  *
57
- * - Form definitions themselves (if not provided directly to the engine by
58
- * the client)
59
- * - External secondary instances
60
- * - 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:
61
32
  *
62
- * The function is expected to be a subset of the
63
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API},
64
- * 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.
65
36
  *
66
- * - Text resources (e.g. XML, CSV, JSON/GeoJSON)
67
- * - Binary resources (e.g. media)
68
- * - Optionally streamed binary data of either (e.g. for optimized
69
- * 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}
70
75
  *
71
- * If provided by a client, this function will be used by the engine to
72
- * retrieve any such resource, as required for engine functionality. If
73
- * absent, the engine will use the native `fetch` function (if available, a
74
- * polyfill otherwise). Clients may use this function to provide resources
75
- * from sources other than the network, (or even in a test client to provide
76
- * e.g. resources from test fixtures).
76
+ * @default MissingResourceBehaviorDefault
77
77
  */
78
- readonly fetchResource?: FetchResource;
78
+ readonly missingResourceBehavior?: MissingResourceBehavior;
79
79
  }
@@ -1,11 +1,10 @@
1
- import { AnyGroupElementDefinition } from '../body/BodyDefinition.ts';
2
- import { SubtreeDefinition } from '../model/SubtreeDefinition.ts';
1
+ import { AnyGroupElementDefinition } from '../parse/body/BodyDefinition.ts';
2
+ import { SubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
3
3
  import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import { NodeAppearances } from './NodeAppearances.ts';
5
5
  import { RootNode } from './RootNode.ts';
6
6
  import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
7
7
  import { AncestorNodeValidationState } from './validation.ts';
8
-
9
8
  export interface GroupNodeState extends BaseNodeState {
10
9
  get hint(): null;
11
10
  get children(): readonly GeneralChildNode[];
@@ -0,0 +1,53 @@
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
+ /**
28
+ * A node corresponding to form field defined as an
29
+ * {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<input>`},
30
+ * which a user-facing client would likely present for a user to fill..
31
+ */
32
+ export interface InputNode<V extends ValueType = ValueType> extends BaseValueNode<V, InputValue<V>> {
33
+ readonly nodeType: 'input';
34
+ readonly valueType: V;
35
+ readonly appearances: InputNodeAppearances;
36
+ readonly definition: InputDefinition<V>;
37
+ readonly root: RootNode;
38
+ readonly parent: GeneralParentNode;
39
+ readonly currentState: InputNodeState<V>;
40
+ readonly validationState: LeafNodeValidationState;
41
+ /**
42
+ * For use by a client to update the value of an {@link InputNode}.
43
+ */
44
+ setValue(value: InputNodeInputValue<V>): RootNode;
45
+ }
46
+ export type StringInputNode = InputNode<'string'>;
47
+ export type IntInputNode = InputNode<'int'>;
48
+ export type DecimalInputNode = InputNode<'decimal'>;
49
+ type SupportedInputValueType = 'string' | 'int' | 'decimal';
50
+ type TemporaryStringValueType = Exclude<ValueType, SupportedInputValueType>;
51
+ export type TemporaryStringValueInputNode = InputNode<TemporaryStringValueType>;
52
+ export type AnyInputNode = StringInputNode | IntInputNode | DecimalInputNode | TemporaryStringValueInputNode;
53
+ export {};
@@ -1,10 +1,12 @@
1
- import { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
2
- import { BaseNode, BaseNodeState } from './BaseNode.ts';
1
+ import { RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
2
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.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
-
7
- 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>> {
8
10
  get label(): null;
9
11
  get hint(): null;
10
12
  get children(): null;
@@ -14,9 +16,9 @@ export interface ModelValueNodeState extends BaseNodeState {
14
16
  * populated when a form is loaded, and it may be updated by certain
15
17
  * computations defined by the form.
16
18
  */
17
- get value(): string;
19
+ get value(): ModelValue<V>;
18
20
  }
19
- export interface ModelValueDefinition extends LeafNodeDefinition {
21
+ export interface ModelValueDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
20
22
  readonly bodyElement: null;
21
23
  }
22
24
  /**
@@ -26,12 +28,14 @@ export interface ModelValueDefinition extends LeafNodeDefinition {
26
28
  * - a leaf/value node (i.e. it has no element children; it may be defined in
27
29
  * the form's `<model>` as either an {@link Element} or {@link Attr})
28
30
  */
29
- export interface ModelValueNode extends BaseNode {
31
+ export interface ModelValueNode<V extends ValueType = ValueType> extends BaseValueNode<V, ModelValue<V>> {
30
32
  readonly nodeType: 'model-value';
33
+ readonly valueType: V;
31
34
  readonly appearances: null;
32
- readonly definition: ModelValueDefinition;
35
+ readonly definition: ModelValueDefinition<V>;
33
36
  readonly root: RootNode;
34
37
  readonly parent: GeneralParentNode;
35
- readonly currentState: ModelValueNodeState;
38
+ readonly currentState: ModelValueNodeState<V>;
36
39
  readonly validationState: LeafNodeValidationState;
37
40
  }
41
+ 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,6 +1,5 @@
1
1
  import { ParsedTokenList } from '../lib/TokenListParser.ts';
2
- import { NodeDefinition } from '../model/NodeDefinition.ts';
3
-
2
+ import { NodeDefinition } from '../parse/model/NodeDefinition.ts';
4
3
  /**
5
4
  * - Provides a means to distinguish between internal and client-facing names
6
5
  * for the same {@link ParsedTokenList} types.
@@ -1,12 +1,11 @@
1
- import { InputDefinition } from '../body/control/InputDefinition.ts';
2
- import { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
1
+ import { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
2
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
3
  import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import { GeneralParentNode } from './hierarchy.ts';
5
5
  import { NodeAppearances } from './NodeAppearances.ts';
6
6
  import { RootNode } from './RootNode.ts';
7
7
  import { TextRange } from './TextRange.ts';
8
8
  import { LeafNodeValidationState } from './validation.ts';
9
-
10
9
  export interface NoteNodeState extends BaseNodeState {
11
10
  /**
12
11
  * Note-specific specialization: a note will always have a non-null value in
@@ -33,7 +32,7 @@ export interface NoteNodeState extends BaseNodeState {
33
32
  get value(): string | null;
34
33
  }
35
34
  export interface NoteDefinition extends LeafNodeDefinition {
36
- readonly bodyElement: InputDefinition;
35
+ readonly bodyElement: InputControlDefinition;
37
36
  }
38
37
  export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
39
38
  /**
@@ -1,16 +1,15 @@
1
- import { BodyClassList } from '../body/BodyDefinition.ts';
2
- import { RootDefinition } from '../model/RootDefinition.ts';
1
+ import { BodyClassList } from '../parse/body/BodyDefinition.ts';
2
+ 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 { SubmissionChunkedType, SubmissionOptions } from './submission/SubmissionOptions.ts';
7
+ import { SubmissionResult } from './submission/SubmissionResult.ts';
6
8
  import { AncestorNodeValidationState } from './validation.ts';
7
-
8
9
  export interface RootNodeState extends BaseNodeState {
9
10
  /**
10
- * This, along with {@link RootNode.languages} is the most significant break
11
- in consistency across node types' state and static properties. Exposing it
12
- across all node types seems like a point of potential confusion, so this
13
- particular divergence seems like the most reasonable compromise.
11
+ * @todo If we ever expose an interface to the primary instance document, it
12
+ * would make sense to move this state up.
14
13
  */
15
14
  get activeLanguage(): ActiveLanguage;
16
15
  get label(): null;
@@ -41,13 +40,40 @@ export interface RootNode extends BaseNode {
41
40
  readonly classes: BodyClassList;
42
41
  readonly definition: RootDefinition;
43
42
  readonly root: RootNode;
44
- readonly parent: null;
43
+ readonly parent: unknown;
45
44
  readonly currentState: RootNodeState;
46
45
  readonly validationState: AncestorNodeValidationState;
47
46
  /**
48
- * @todo as with {@link RootNodeState.activeLanguage}, this is the most
49
- * significant break in consistency across node types.
47
+ * @todo as discussed on {@link RootNodeState.activeLanguage}
50
48
  */
51
49
  readonly languages: FormLanguages;
52
50
  setLanguage(language: FormLanguage): RootNode;
51
+ /**
52
+ * Prepares the current form instance state for submission.
53
+ *
54
+ * A {@link SubmissionResult} will be prepared even if the current form state
55
+ * includes `constraint` or `required` violations. This is intended to serve
56
+ * two purposes:
57
+ *
58
+ * - A client may effectively use this method as a part of its own "submit"
59
+ * routine, and use any violations included in the {@link SubmissionResult}
60
+ * to prompt users to address those violations.
61
+ *
62
+ * - A client may inspect the submission state of a form at any time.
63
+ * Depending on the client and use case, this may be a convenience (e.g. for
64
+ * developers to inspect that form state at a current point in time); or it
65
+ * may provide necessary functionality (e.g. for test or tooling clients).
66
+ *
67
+ * Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
68
+ * a fast operation. It may even be nearly instantaneous, or roughly
69
+ * proportionate to the size of the form itself. However, this method is
70
+ * designed to be asynchronous out of an abundance of caution, anticipating
71
+ * that some as-yet undeveloped operations on binary data (e.g. form
72
+ * attachments) may themselves impose asynchrony (i.e. by interfaces provided
73
+ * by the platform and/or external dependencies).
74
+ *
75
+ * A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
76
+ * {@link SubmissionResult<'chunked'>} will be produced, with form attachments
77
+ */
78
+ prepareSubmission<ChunkedType extends SubmissionChunkedType>(options?: SubmissionOptions<ChunkedType>): Promise<SubmissionResult<ChunkedType>>;
53
79
  }
@@ -1,12 +1,11 @@
1
- import { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
2
- import { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
1
+ import { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
2
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
3
  import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import { NodeAppearances } from './NodeAppearances.ts';
5
5
  import { RootNode } from './RootNode.ts';
6
6
  import { TextRange } from './TextRange.ts';
7
7
  import { GeneralParentNode } from './hierarchy.ts';
8
8
  import { LeafNodeValidationState } from './validation.ts';
9
-
10
9
  export interface SelectItem {
11
10
  get value(): string;
12
11
  get label(): TextRange<'item-label'> | null;
@@ -52,7 +51,7 @@ export interface SelectNode extends BaseNode {
52
51
  * - For fields defined with an XForms `<select1>`, calling this method will
53
52
  * replace the selection (if any).
54
53
  *
55
- * @todo @see {@link StringNode.setValue} re: write restrictions
54
+ * @todo @see {@link InputNode.setValue} re: write restrictions
56
55
  * @todo @see {@link SelectNodeState.value} re: breaking up the types
57
56
  */
58
57
  select(item: SelectItem): RootNode;
@@ -60,7 +59,7 @@ export interface SelectNode extends BaseNode {
60
59
  * For use by a client to remove an item from the node's
61
60
  * {@link SelectNodeState.value}.
62
61
  *
63
- * @todo @see {@link StringNode.setValue} re: write restrictions
62
+ * @todo @see {@link InputNode.setValue} re: write restrictions
64
63
  */
65
64
  deselect(item: SelectItem): RootNode;
66
65
  }
@@ -1,9 +1,8 @@
1
- import { SubtreeDefinition as BaseSubtreeDefinition } from '../model/SubtreeDefinition.ts';
1
+ import { SubtreeDefinition as BaseSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
2
2
  import { BaseNode, BaseNodeState } from './BaseNode.ts';
3
3
  import { RootNode } from './RootNode.ts';
4
4
  import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
5
5
  import { AncestorNodeValidationState } from './validation.ts';
6
-
7
6
  export interface SubtreeNodeState extends BaseNodeState {
8
7
  get label(): null;
9
8
  get hint(): null;
@@ -1,5 +1,4 @@
1
1
  import { ActiveLanguage } from './FormLanguage.ts';
2
-
3
2
  /**
4
3
  * **COMMENTARY**
5
4
  *
@@ -23,7 +22,7 @@ import { ActiveLanguage } from './FormLanguage.ts';
23
22
  * Here, `is-translation-expr()` is a fictional shorthand for checking
24
23
  * that the attribute's value is a valid `jr:itext(...)` FunctionCall
25
24
  * expression. Note that, per spec, these attributes **do not accept
26
- * arbitrary XPath expressions**! The non-translation case is treated as
25
+ * arbitrary XPath expressions**! The non-translation case is treated as
27
26
  * static text, not parsed for e.g. an XPath [string] Literal expression.
28
27
  * This is why we have introduced this 'translation' case, distinct from
29
28
  * 'reference', which previously handled translated labels and hints.
@@ -33,7 +32,7 @@ import { ActiveLanguage } from './FormLanguage.ts';
33
32
  *
34
33
  * - `h:body//label/@ref[is-translation-expr()]`
35
34
  *
36
- * - 'static':
35
+ * - 'literal':
37
36
  * - `h:head//bind/@jr:constraintMsg[not(is-translation-expr())]`
38
37
  * - `h:head//bind/@jr:requiredMsg[not(is-translation-expr())]`
39
38
  * - `h:body//label/text()`
@@ -57,7 +56,7 @@ import { ActiveLanguage } from './FormLanguage.ts';
57
56
  * package, and the engine doesn't really deal with itext translations at the
58
57
  * node level at all).
59
58
  */
60
- export type TextChunkSource = 'output' | 'reference' | 'translation' | 'static';
59
+ export type TextChunkSource = 'literal' | 'output' | 'reference' | 'translation';
61
60
  /**
62
61
  * @todo This (and everything else to do with {@link TextRange}s is for
63
62
  * illustration purposes, as a starting point where any particular detail is of
@@ -0,0 +1,25 @@
1
+ import { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
2
+ import { TriggerControlDefinition } from '../parse/body/control/TriggerControlDefinition.ts';
3
+ import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
4
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
5
+ import { GeneralParentNode } from './hierarchy.ts';
6
+ import { RootNode } from './RootNode.ts';
7
+ import { LeafNodeValidationState } from './validation.ts';
8
+ export interface TriggerNodeState extends BaseNodeState {
9
+ get children(): null;
10
+ get valueOptions(): null;
11
+ get value(): boolean;
12
+ }
13
+ export interface TriggerNodeDefinition extends LeafNodeDefinition {
14
+ readonly bodyElement: TriggerControlDefinition;
15
+ }
16
+ export interface TriggerNode extends BaseNode {
17
+ readonly nodeType: 'trigger';
18
+ readonly definition: TriggerNodeDefinition;
19
+ readonly appearances: UnknownAppearanceDefinition;
20
+ readonly root: RootNode;
21
+ readonly parent: GeneralParentNode;
22
+ readonly currentState: TriggerNodeState;
23
+ readonly validationState: LeafNodeValidationState;
24
+ setValue(value: boolean): RootNode;
25
+ }
@@ -0,0 +1,3 @@
1
+ import { ExpandUnion } from '../../../common/types/helpers.js';
2
+ import { BindType } from '../parse/model/BindTypeDefinition.ts';
3
+ export type ValueType = ExpandUnion<BindType>;
@@ -1,9 +1,58 @@
1
1
  import { ValidationTextRole } from './TextRange.ts';
2
-
2
+ export declare const MISSING_RESOURCE_BEHAVIOR: {
3
+ /**
4
+ * When this behavior is configured, {@link InitializeForm | initializing} a
5
+ * {@link PrimaryInstance} for a form which references any **missing**
6
+ * resources will fail, producing an error to the calling client.
7
+ *
8
+ * @see {@link MissingResourceBehavior}
9
+ */
10
+ readonly ERROR: "ERROR";
11
+ /**
12
+ * When this behavior is configured, {@link InitializeForm | initializing} a
13
+ * {@link PrimaryInstance} for a form which references any **missing**
14
+ * resources will succeed (producing a warning).
15
+ *
16
+ * Such missing resources will be parsed as if they are blank, as appropriate
17
+ * for the resource's XForm semantic usage and/or format.
18
+ *
19
+ * @see {@link MissingResourceBehavior}
20
+ */
21
+ readonly BLANK: "BLANK";
22
+ /**
23
+ * @see {@link MISSING_RESOURCE_BEHAVIOR.ERROR}
24
+ */
25
+ readonly DEFAULT: "ERROR";
26
+ };
27
+ export type MissingResourceBehaviorError = typeof MISSING_RESOURCE_BEHAVIOR.ERROR;
28
+ export type MissingResourceBehaviorBlank = typeof MISSING_RESOURCE_BEHAVIOR.BLANK;
29
+ export type MissingResourceBehaviorDefault = typeof MISSING_RESOURCE_BEHAVIOR.DEFAULT;
30
+ /**
31
+ * Specifies behavior for {@link InitializeForm | initializing} a form's
32
+ * {@link PrimaryInstance} which references any **missing** resources.
33
+ *
34
+ * Here the term "missing" is consistent with
35
+ * {@link https://www.rfc-editor.org/rfc/rfc9110#status.404 | HTTP 404 status}
36
+ * semantics. Clients which provide access to form attachments by performing
37
+ * HTTP network requests (e.g. with {@link fetch}) can generally convey this
38
+ * semantic meaning with a standard {@link Response}.
39
+ *
40
+ * **IMPORTANT**
41
+ *
42
+ * The term "missing" is distinct from other network/IO failures, e.g. when
43
+ * network access itself is unavailable. In these cases, the engine will
44
+ * consider a resource's availability **ambiguous**, producing an error
45
+ * regardless of the configured behavior for **missing** resources.
46
+ */
47
+ export type MissingResourceBehavior = MissingResourceBehaviorError | MissingResourceBehaviorBlank;
3
48
  export declare const VALIDATION_TEXT: {
4
49
  readonly constraintMsg: "Condition not satisfied: constraint";
5
50
  readonly requiredMsg: "Condition not satisfied: required";
6
51
  };
7
52
  type ValidationTextDefaults = typeof VALIDATION_TEXT;
8
53
  export type ValidationTextDefault<Role extends ValidationTextRole> = ValidationTextDefaults[Role];
54
+ export declare const SUBMISSION_INSTANCE_FILE_NAME = "xml_submission_file";
55
+ export type SubmissionInstanceFileName = typeof SUBMISSION_INSTANCE_FILE_NAME;
56
+ export declare const SUBMISSION_INSTANCE_FILE_TYPE = "text/xml";
57
+ export type SubmissionInstanceFileType = typeof SUBMISSION_INSTANCE_FILE_TYPE;
9
58
  export {};
@@ -1,17 +1,21 @@
1
1
  import { ExpandUnion } from '../../../common/types/helpers.d.ts';
2
2
  import { GroupNode } from './GroupNode.ts';
3
- import { ModelValueNode } from './ModelValueNode.ts';
3
+ import { AnyInputNode } from './InputNode.ts';
4
+ import { AnyModelValueNode } from './ModelValueNode.ts';
4
5
  import { NoteNode } from './NoteNode.ts';
5
6
  import { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
6
7
  import { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
7
8
  import { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
8
9
  import { RootNode } from './RootNode.ts';
9
10
  import { SelectNode } from './SelectNode.ts';
10
- import { StringNode } from './StringNode.ts';
11
11
  import { SubtreeNode } from './SubtreeNode.ts';
12
-
13
- export type AnyControlNode = NoteNode | SelectNode | StringNode;
14
- export type AnyLeafNode = AnyControlNode | ModelValueNode;
12
+ import { TriggerNode } from './TriggerNode.ts';
13
+ import { RangeNode } from './unsupported/RangeNode.ts';
14
+ import { RankNode } from './unsupported/RankNode.ts';
15
+ import { UploadNode } from './unsupported/UploadNode.ts';
16
+ export type AnyUnsupportedControlNode = RangeNode | RankNode | UploadNode;
17
+ export type AnyControlNode = AnyInputNode | NoteNode | SelectNode | TriggerNode;
18
+ export type AnyLeafNode = AnyControlNode | AnyModelValueNode | AnyUnsupportedControlNode;
15
19
  export type RepeatRangeNode = RepeatRangeControlledNode | RepeatRangeUncontrolledNode;
16
20
  /**
17
21
  * Any of the concrete node types which may be a parent of non-repeat instance
@@ -0,0 +1,14 @@
1
+ type ODKXFormsUUID = `uuid:${string}`;
2
+ /**
3
+ * @see {@link https://getodk.github.io/xforms-spec/#metadata}
4
+ */
5
+ export type InstanceID = ODKXFormsUUID;
6
+ /**
7
+ * @see {@link https://getodk.github.io/xforms-spec/#metadata}
8
+ */
9
+ export type DeprecatedID = ODKXFormsUUID;
10
+ /**
11
+ * Represents a session-stable identifier for any particular node i
12
+ */
13
+ export type FormNodeID = `node:${string}`;
14
+ export {};
@@ -1,6 +1,5 @@
1
1
  import { EngineConfig } from './EngineConfig.ts';
2
2
  import { RootNode } from './RootNode.ts';
3
-
4
3
  export type FormResource = Blob | URL | string;
5
4
  export interface InitializeFormOptions {
6
5
  readonly config: EngineConfig;
@@ -1,2 +1,4 @@
1
+ export type UnsupportedControlNodeType = 'range' | 'rank' | 'upload';
1
2
  export type RepeatRangeNodeType = 'repeat-range:controlled' | 'repeat-range:uncontrolled';
2
- export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | 'subtree' | 'model-value' | 'note' | 'select' | 'string';
3
+ export type LeafNodeType = 'model-value' | 'note' | 'select' | 'input' | 'trigger' | UnsupportedControlNodeType;
4
+ export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | 'subtree' | LeafNodeType | UnsupportedControlNodeType;