@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,34 +0,0 @@
1
- import { XFormDataType } from '../XFormDataType.ts';
2
- import { XFormDefinition } from '../XFormDefinition.ts';
3
- import { DependencyContext } from '../expression/DependencyContext.ts';
4
- import { MessageDefinition } from '../parse/text/MessageDefinition.ts';
5
- import { BindComputation } from './BindComputation.ts';
6
- import { BindElement } from './BindElement.ts';
7
- import { ModelDefinition } from './ModelDefinition.ts';
8
-
9
- export declare class BindDefinition extends DependencyContext {
10
- readonly form: XFormDefinition;
11
- protected readonly model: ModelDefinition;
12
- readonly nodeset: string;
13
- readonly bindElement: BindElement;
14
- readonly bindType: string | null;
15
- readonly dataType: XFormDataType;
16
- readonly parentNodeset: string | null;
17
- readonly calculate: BindComputation<'calculate'> | null;
18
- readonly readonly: BindComputation<'readonly'>;
19
- readonly relevant: BindComputation<'relevant'>;
20
- readonly required: BindComputation<'required'>;
21
- /**
22
- * Diverges from {@link https://github.com/getodk/javarosa/blob/059321160e6f8dbb3e81d9add61d68dd35b13cc8/dag.md | JavaRosa's}, which excludes `constraint` expressions. We compute `constraint` dependencies like the other <bind> computation expressions, but explicitly ignore self-references (this is currently handled by {@link BindComputation}, via its {@link DependentExpression} parent class).
23
- */
24
- readonly constraint: BindComputation<'constraint'>;
25
- readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
26
- readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
27
- readonly saveIncomplete: BindComputation<'saveIncomplete'>;
28
- protected _parentBind: BindDefinition | null | undefined;
29
- get parentBind(): BindDefinition | null;
30
- get reference(): string;
31
- get parentReference(): string | null;
32
- constructor(form: XFormDefinition, model: ModelDefinition, nodeset: string, bindElement: BindElement);
33
- toJSON(): Omit<this, "model" | "toJSON" | "form" | "reference" | "parentReference" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions" | "bindElement" | "parentBind">;
34
- }
@@ -1,8 +0,0 @@
1
- import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
- import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
-
4
- export declare class OutputChunkDefinition extends TextChunkDefinition<'output'> {
5
- static from(context: AnyTextRangeDefinition, element: Element): OutputChunkDefinition | null;
6
- readonly source = "output";
7
- private constructor();
8
- }
@@ -1,8 +0,0 @@
1
- import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
- import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
-
4
- export declare class ReferenceChunkDefinition extends TextChunkDefinition<'reference'> {
5
- static from(context: AnyTextRangeDefinition, refExpression: string): ReferenceChunkDefinition;
6
- readonly source = "reference";
7
- private constructor();
8
- }
@@ -1,10 +0,0 @@
1
- import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
- import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
-
4
- export type StaticTextChunkSourceNode = Attr | Text;
5
- export declare class StaticTextChunkDefinition extends TextChunkDefinition<'static'> {
6
- readonly stringValue: string;
7
- static from(context: AnyTextRangeDefinition, stringValue: string): StaticTextChunkDefinition;
8
- readonly source = "static";
9
- private constructor();
10
- }
@@ -1,9 +0,0 @@
1
- import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
- import { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
-
4
- export declare class TranslationChunkDefinition extends TextChunkDefinition<'translation'> {
5
- static fromMessage(context: AnyTextRangeDefinition, maybeExpression: string): TranslationChunkDefinition | null;
6
- static from(context: AnyTextRangeDefinition, maybeExpression: string): TranslationChunkDefinition | null;
7
- readonly source = "translation";
8
- private constructor();
9
- }
@@ -1,18 +0,0 @@
1
- import { TextChunkSource } from '../../../client/TextRange.ts';
2
- import { DependentExpression } from '../../../expression/DependentExpression.ts';
3
- import { OutputChunkDefinition } from '../OutputChunkDefinition.ts';
4
- import { ReferenceChunkDefinition } from '../ReferenceChunkDefinition.ts';
5
- import { StaticTextChunkDefinition } from '../StaticTextChunkDefinition.ts';
6
- import { TranslationChunkDefinition } from '../TranslationChunkDefinition.ts';
7
- import { AnyTextRangeDefinition } from './TextRangeDefinition.ts';
8
-
9
- interface TextChunkDefinitionOptions {
10
- readonly isTranslated?: true;
11
- }
12
- export declare abstract class TextChunkDefinition<Source extends TextChunkSource> extends DependentExpression<'string'> {
13
- abstract readonly source: Source;
14
- readonly stringValue?: string;
15
- constructor(context: AnyTextRangeDefinition, expression: string, options?: TextChunkDefinitionOptions);
16
- }
17
- export type AnyTextChunkDefinition = OutputChunkDefinition | ReferenceChunkDefinition | StaticTextChunkDefinition | TranslationChunkDefinition;
18
- export {};
@@ -1,64 +0,0 @@
1
- import type { CollectionValues } from '@getodk/common/types/collections/CollectionValues.ts';
2
-
3
- /**
4
- * Like JavaRosa. Presumably for explicit types which aren't impelemnted?
5
- */
6
- const UNSUPPORTED_DATA_TYPE = 'UNSUPPORTED';
7
-
8
- export type UnsupportedDataType = typeof UNSUPPORTED_DATA_TYPE;
9
-
10
- /**
11
- * Like JavaRosa. Presumably for e.g. groups with explicit binds (`relevant` etc)?
12
- */
13
- const NULL_DATA_TYPE = 'NULL';
14
-
15
- export type NullDataType = typeof NULL_DATA_TYPE;
16
-
17
- /**
18
- * As in ODK XForms Spec.
19
- *
20
- * TODO: it's unclear why JavaRosa's `DataType` hews closely to the spec, but
21
- * has certain differences (e.g. string -> TEXT, int -> INTEGER). It's also
22
- * not immediately clear how additive types like CHOICE and MULTIPLE_ITEMS
23
- * square with the underlying spec types.
24
- */
25
- export const XFORM_SPEC_DATA_TYPES = [
26
- 'string',
27
- 'int',
28
- 'boolean',
29
- 'decimal',
30
- 'date',
31
- 'time',
32
- 'dateTime',
33
- 'geopoint',
34
- 'geotrace',
35
- 'geoshape',
36
- 'binary',
37
- 'barcode',
38
- 'intent',
39
- ] as const;
40
-
41
- const isSupportedDataType = (bindType: string): bindType is XFormSpecDataType =>
42
- XFORM_SPEC_DATA_TYPES.includes(bindType as XFormSpecDataType);
43
-
44
- export type XFormSpecDataType = CollectionValues<typeof XFORM_SPEC_DATA_TYPES>;
45
-
46
- export type XFormDataType = NullDataType | UnsupportedDataType | XFormSpecDataType;
47
-
48
- const DEFAULT_XFORM_DATA_TYPE = 'string';
49
-
50
- export type DefaultXFormDataType = typeof DEFAULT_XFORM_DATA_TYPE;
51
-
52
- // TODO: groups -> NULL?
53
- // TODO: XSD namespace
54
- export const bindDataType = (bindType: string | null): XFormDataType => {
55
- if (bindType == null) {
56
- return DEFAULT_XFORM_DATA_TYPE;
57
- }
58
-
59
- if (isSupportedDataType(bindType)) {
60
- return bindType;
61
- }
62
-
63
- return UNSUPPORTED_DATA_TYPE;
64
- };
@@ -1,52 +0,0 @@
1
- import type { InputDefinition } from '../body/control/InputDefinition.ts';
2
- import type { LeafNodeDefinition } from '../model/LeafNodeDefinition.ts';
3
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
- import type { NodeAppearances } from './NodeAppearances.ts';
5
- import type { RootNode } from './RootNode.ts';
6
- import type { GeneralParentNode } from './hierarchy.ts';
7
- import type { LeafNodeValidationState } from './validation.ts';
8
-
9
- export interface StringNodeState extends BaseNodeState {
10
- get children(): null;
11
- get valueOptions(): null;
12
-
13
- /**
14
- * Reflects the current value of a {@link StringNode}. This value may be
15
- * populated when a form is loaded, and it may be updated by certain
16
- * computations defined by the form. It may also be updated by a client, using
17
- * the {@link StringNode.setValue} method.
18
- */
19
- get value(): string;
20
- }
21
-
22
- export interface StringDefinition extends LeafNodeDefinition {
23
- readonly bodyElement: InputDefinition;
24
- }
25
-
26
- export type StringNodeAppearances = NodeAppearances<StringDefinition>;
27
-
28
- /**
29
- * A node which can be assigned a string/text value. A string node **MAY**
30
- * correspond to form field defined as an XForms `<input>`, which a user-facing
31
- * client would likely present for a user to fill. It may not correspond to an
32
- * `<input>`, or necessarily have any presentational implications for a client
33
- * (for instance if the node is bound to an XForms `calculate` expression).
34
- */
35
- export interface StringNode extends BaseNode {
36
- readonly nodeType: 'string';
37
- readonly appearances: StringNodeAppearances;
38
- readonly definition: StringDefinition;
39
- readonly root: RootNode;
40
- readonly parent: GeneralParentNode;
41
- readonly currentState: StringNodeState;
42
- readonly validationState: LeafNodeValidationState;
43
-
44
- /**
45
- * For use by a client to update the value of a string node.
46
- *
47
- * @todo [how] should we express write restrictions to a client? E.g. what
48
- * happens when a string node is readonly, and a client attempts to call this
49
- * method?
50
- */
51
- setValue(value: string): RootNode;
52
- }
@@ -1,61 +0,0 @@
1
- import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
2
- import type { EvaluationContext } from './EvaluationContext.ts';
3
-
4
- /**
5
- * Provides a common interface to explicitly establish a reactive subscription
6
- * to a form node, regardless of which node-specific details might trigger
7
- * reactive updates. This is primarily intended for use in coordination with a
8
- * node's {@link EvaluationContext} interface, so that computed expression
9
- * evaluations can be re-executed when their dependencies update, without
10
- * requiring a given evaluation to handle node-specific logic to determine
11
- * when/whether updates have occurred.
12
- *
13
- * @example Given a form with these bindings:
14
- *
15
- * ```xml
16
- * <bind nodeset="/data/field-1" />
17
- * <bind nodeset="/data/field-2" type="int" />
18
- * <bind nodeset="/data/group-a" relevant="/data/field-1 != ''" />
19
- * <bind nodeset="/data/group-a/field-a-1" calculate="/data/field-2 * 2" />
20
- * ```
21
- *
22
- * The field `/data/group-a/field-a-1`'s calculate has two dependencies:
23
- *
24
- * - `/data-field-2` (explicit)
25
- * - `/data/group-a` (implicit: non-relevance is inherited)
26
- *
27
- * (This is an oversimplification, but it helps to illustrate the concept.)
28
- *
29
- * The first dependency's subscription is clearly concerned with that leaf
30
- * node's value. In which case, that node's `subscribe` method should react to
31
- * updates to its value (e.g. its `currentState.value` or the internal reactive
32
- * representation thereof).
33
- *
34
- * Whereas the second dependency has no value (no parent nodes do); instead, the
35
- * subscription would be concerned with that node's relevance. In which case,
36
- * that node's `subscribe` method should react to updates to its relevance state
37
- * (e.g. its `currentState.relevant` or the internal reactive represeentation
38
- * thereof).
39
- *
40
- * @example Given a form with:
41
- *
42
- * ```xml
43
- * <!-- model -->
44
- * <bind nodeset="/data/repeat-a/field-a-1" calculate="position(..)" />
45
- * <!-- body -->
46
- * <repeat nodeset="/data/repeat-a" />
47
- * ```
48
- *
49
- * The field `/data/repeat-a/field-a-1` has a dependency on its containing
50
- * repeat instance. That node also doesn't have a value, and here the dynamic
51
- * aspect of the dependency is the node's current position. Here the node's
52
- * `subscribe` method should react to changes in its position (likely indirectly
53
- * by reading its `contextReference`).
54
- *
55
- * @see {@link EvaluationContext}
56
- * @see {@link EvaluationContext.contextReference}
57
- */
58
- export interface SubscribableDependency {
59
- readonly scope: ReactiveScope;
60
- readonly subscribe: VoidFunction;
61
- }
@@ -1,106 +0,0 @@
1
- import type { XFormDataType } from '../XFormDataType.ts';
2
- import { bindDataType } from '../XFormDataType.ts';
3
- import type { XFormDefinition } from '../XFormDefinition.ts';
4
- import { DependencyContext } from '../expression/DependencyContext.ts';
5
- import type { DependentExpression } from '../expression/DependentExpression.ts';
6
- import { MessageDefinition } from '../parse/text/MessageDefinition.ts';
7
- import { BindComputation } from './BindComputation.ts';
8
- import type { BindElement } from './BindElement.ts';
9
- import type { ModelDefinition } from './ModelDefinition.ts';
10
-
11
- export class BindDefinition extends DependencyContext {
12
- readonly bindType: string | null;
13
- readonly dataType: XFormDataType;
14
- readonly parentNodeset: string | null;
15
-
16
- readonly calculate: BindComputation<'calculate'> | null;
17
- readonly readonly: BindComputation<'readonly'>;
18
- readonly relevant: BindComputation<'relevant'>;
19
- readonly required: BindComputation<'required'>;
20
-
21
- // According to
22
- //
23
- // this is not stored in the DAG. In contrast, we do compute constraint
24
- // dependencies, but self-references are ignored (handled by `BindComputation`
25
- // and its `DependentExpression` parent class).
26
- /**
27
- * Diverges from {@link https://github.com/getodk/javarosa/blob/059321160e6f8dbb3e81d9add61d68dd35b13cc8/dag.md | JavaRosa's}, which excludes `constraint` expressions. We compute `constraint` dependencies like the other <bind> computation expressions, but explicitly ignore self-references (this is currently handled by {@link BindComputation}, via its {@link DependentExpression} parent class).
28
- */
29
- readonly constraint: BindComputation<'constraint'>;
30
-
31
- readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
32
- readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
33
-
34
- // TODO: it is unclear whether this will need to be supported.
35
- // https://github.com/getodk/collect/issues/3758 mentions deprecation.
36
- readonly saveIncomplete: BindComputation<'saveIncomplete'>;
37
-
38
- // TODO: these are deferred until prioritized
39
- // readonly preload: string | null;
40
- // readonly preloadParams: string | null;
41
- // readonly 'max-pixels': string | null;
42
-
43
- protected _parentBind: BindDefinition | null | undefined;
44
-
45
- get parentBind(): BindDefinition | null {
46
- let bind = this._parentBind;
47
-
48
- if (typeof bind === 'undefined') {
49
- const { parentNodeset } = this;
50
-
51
- if (parentNodeset == null) {
52
- bind = null;
53
- } else {
54
- bind = this.form.model.binds.get(parentNodeset) ?? null;
55
- }
56
-
57
- this._parentBind = bind;
58
- }
59
-
60
- return bind;
61
- }
62
-
63
- // DependencyContext
64
- get reference(): string {
65
- return this.nodeset;
66
- }
67
-
68
- get parentReference(): string | null {
69
- return this.parentNodeset;
70
- }
71
-
72
- constructor(
73
- readonly form: XFormDefinition,
74
- protected readonly model: ModelDefinition,
75
- readonly nodeset: string,
76
- readonly bindElement: BindElement
77
- ) {
78
- super();
79
-
80
- const bindType = (this.bindType = bindElement.getAttribute('type'));
81
-
82
- this.dataType = bindDataType(bindType);
83
-
84
- const parentNodeset = nodeset.replace(/\/[^/]+$/, '');
85
-
86
- this.parentNodeset = parentNodeset.length > 1 ? parentNodeset : null;
87
- this.calculate = BindComputation.forExpression(this, 'calculate');
88
- this.readonly = BindComputation.forExpression(this, 'readonly');
89
- this.relevant = BindComputation.forExpression(this, 'relevant');
90
- this.required = BindComputation.forExpression(this, 'required');
91
- this.constraint = BindComputation.forExpression(this, 'constraint');
92
- this.saveIncomplete = BindComputation.forExpression(this, 'saveIncomplete');
93
- this.constraintMsg = MessageDefinition.from(this, 'constraintMsg');
94
- this.requiredMsg = MessageDefinition.from(this, 'requiredMsg');
95
-
96
- // this.preload = BindComputation.forExpression(this, 'preload');
97
- // this.preloadParams = BindComputation.forExpression(this, 'preloadParams');
98
- // this['max-pixels'] = BindComputation.forExpression(this, 'max-pixels');
99
- }
100
-
101
- toJSON() {
102
- const { form, model, /* modelElement, */ bindElement, ...rest } = this;
103
-
104
- return rest;
105
- }
106
- }
@@ -1,19 +0,0 @@
1
- import type { XFormDefinition } from '../XFormDefinition.ts';
2
- import { ModelBindMap } from './ModelBindMap.ts';
3
- import { RootDefinition } from './RootDefinition.ts';
4
-
5
- export class ModelDefinition {
6
- readonly binds: ModelBindMap;
7
- readonly root: RootDefinition;
8
-
9
- constructor(readonly form: XFormDefinition) {
10
- this.binds = ModelBindMap.fromModel(this);
11
- this.root = new RootDefinition(form, this, form.body.classes);
12
- }
13
-
14
- toJSON() {
15
- const { form, ...rest } = this;
16
-
17
- return rest;
18
- }
19
- }
package/src/parse/TODO.md DELETED
@@ -1,3 +0,0 @@
1
- # @getodk/xforms-engine: parse
2
-
3
- Presence of this file is intended to be temporary! It is here to signal the intent to make a clearer distinction between the parsing and runtime aspects of the engine implementation. For entirely pragmatic purposes, newly introduced will be added here to start. We can decide in review if we want to move the rest into this directory right away. (For existing/untouched code, this would just mean moving the files and updating imports to reflect that. Small effort, lots of potential diff noise.)
@@ -1,19 +0,0 @@
1
- import { TextChunkDefinition } from './abstract/TextChunkDefinition.ts';
2
- import type { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
3
-
4
- export type StaticTextChunkSourceNode = Attr | Text;
5
-
6
- export class StaticTextChunkDefinition extends TextChunkDefinition<'static'> {
7
- static from(context: AnyTextRangeDefinition, stringValue: string): StaticTextChunkDefinition {
8
- return new this(context, stringValue);
9
- }
10
-
11
- readonly source = 'static';
12
-
13
- private constructor(
14
- context: AnyTextRangeDefinition,
15
- override readonly stringValue: string
16
- ) {
17
- super(context, 'null');
18
- }
19
- }
@@ -1,38 +0,0 @@
1
- import type { TextChunkSource } from '../../../client/TextRange.ts';
2
- import { DependentExpression } from '../../../expression/DependentExpression.ts';
3
- import type { OutputChunkDefinition } from '../OutputChunkDefinition.ts';
4
- import type { ReferenceChunkDefinition } from '../ReferenceChunkDefinition.ts';
5
- import type { StaticTextChunkDefinition } from '../StaticTextChunkDefinition.ts';
6
- import type { TranslationChunkDefinition } from '../TranslationChunkDefinition.ts';
7
- import type { AnyTextRangeDefinition } from './TextRangeDefinition.ts';
8
-
9
- interface TextChunkDefinitionOptions {
10
- readonly isTranslated?: true;
11
- }
12
-
13
- export abstract class TextChunkDefinition<
14
- Source extends TextChunkSource,
15
- > extends DependentExpression<'string'> {
16
- abstract readonly source: Source;
17
- readonly stringValue?: string;
18
-
19
- constructor(
20
- context: AnyTextRangeDefinition,
21
- expression: string,
22
- options: TextChunkDefinitionOptions = {}
23
- ) {
24
- super(context, 'string', expression, {
25
- semanticDependencies: {
26
- translations: options.isTranslated,
27
- },
28
- ignoreContextReference: true,
29
- });
30
- }
31
- }
32
-
33
- // prettier-ignore
34
- export type AnyTextChunkDefinition =
35
- | OutputChunkDefinition
36
- | ReferenceChunkDefinition
37
- | StaticTextChunkDefinition
38
- | TranslationChunkDefinition;
File without changes
File without changes
File without changes