@getodk/xforms-engine 0.6.0 → 0.8.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 (332) hide show
  1. package/dist/client/BaseNode.d.ts +4 -4
  2. package/dist/client/BaseValueNode.d.ts +7 -3
  3. package/dist/client/RootNode.d.ts +20 -16
  4. package/dist/client/UploadNode.d.ts +53 -0
  5. package/dist/client/attachments/InstanceAttachmentMeta.d.ts +8 -0
  6. package/dist/client/attachments/InstanceAttachmentsConfig.d.ts +8 -0
  7. package/dist/client/constants.d.ts +11 -12
  8. package/dist/client/form/CreateFormInstance.d.ts +14 -0
  9. package/dist/client/form/EditFormInstance.d.ts +62 -0
  10. package/dist/client/form/FormInstance.d.ts +104 -0
  11. package/dist/client/form/FormInstanceConfig.d.ts +19 -0
  12. package/dist/client/form/FormResource.d.ts +1 -0
  13. package/dist/client/form/LoadForm.d.ts +79 -0
  14. package/dist/client/form/LoadFormResult.d.ts +67 -0
  15. package/dist/client/form/RestoreFormInstance.d.ts +8 -0
  16. package/dist/client/hierarchy.d.ts +4 -5
  17. package/dist/client/index.d.ts +40 -11
  18. package/dist/client/node-types.d.ts +2 -3
  19. package/dist/client/repeat/BaseRepeatRangeNode.d.ts +3 -4
  20. package/dist/client/repeat/RepeatInstanceNode.d.ts +4 -5
  21. package/dist/client/repeat/RepeatRangeControlledNode.d.ts +2 -2
  22. package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +2 -2
  23. package/dist/client/resources.d.ts +1 -1
  24. package/dist/client/serialization/InstanceData.d.ts +14 -0
  25. package/dist/client/serialization/InstanceFile.d.ts +6 -0
  26. package/dist/client/serialization/InstancePayload.d.ts +93 -0
  27. package/dist/client/serialization/InstancePayloadOptions.d.ts +24 -0
  28. package/dist/client/serialization/InstanceState.d.ts +12 -0
  29. package/dist/client/submission/{SubmissionDefinition.d.ts → SubmissionMeta.d.ts} +1 -1
  30. package/dist/entrypoints/FormInstance.d.ts +20 -0
  31. package/dist/entrypoints/FormResult/BaseFormResult.d.ts +22 -0
  32. package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +25 -0
  33. package/dist/entrypoints/FormResult/FormFailureResult.d.ts +17 -0
  34. package/dist/entrypoints/FormResult/FormSuccessResult.d.ts +15 -0
  35. package/dist/entrypoints/FormResult/FormWarningResult.d.ts +15 -0
  36. package/dist/entrypoints/createInstance.d.ts +9 -0
  37. package/dist/entrypoints/editInstance.d.ts +9 -0
  38. package/dist/entrypoints/index.d.ts +4 -0
  39. package/dist/entrypoints/loadForm.d.ts +4 -0
  40. package/dist/entrypoints/restoreInstance.d.ts +9 -0
  41. package/dist/error/LoadFormFailureError.d.ts +9 -0
  42. package/dist/error/MalformedInstanceDataError.d.ts +3 -0
  43. package/dist/error/TemplatedNodeAttributeSerializationError.d.ts +22 -0
  44. package/dist/error/UploadValueTypeError.d.ts +8 -0
  45. package/dist/index.d.ts +2 -33
  46. package/dist/index.js +8280 -6779
  47. package/dist/index.js.map +1 -1
  48. package/dist/instance/Group.d.ts +6 -5
  49. package/dist/instance/InputControl.d.ts +5 -4
  50. package/dist/instance/ModelValue.d.ts +5 -4
  51. package/dist/instance/Note.d.ts +4 -3
  52. package/dist/instance/PrimaryInstance.d.ts +34 -8
  53. package/dist/instance/RangeControl.d.ts +5 -4
  54. package/dist/instance/RankControl.d.ts +6 -5
  55. package/dist/instance/Root.d.ts +7 -9
  56. package/dist/instance/SelectControl.d.ts +4 -3
  57. package/dist/instance/Subtree.d.ts +6 -5
  58. package/dist/instance/TriggerControl.d.ts +4 -3
  59. package/dist/instance/UploadControl.d.ts +58 -0
  60. package/dist/instance/abstract/DescendantNode.d.ts +10 -1
  61. package/dist/instance/abstract/InstanceNode.d.ts +7 -4
  62. package/dist/instance/abstract/ValueNode.d.ts +7 -5
  63. package/dist/instance/attachments/InstanceAttachment.d.ts +42 -0
  64. package/dist/instance/attachments/InstanceAttachmentsState.d.ts +9 -0
  65. package/dist/instance/children/DescendantNodeInitOptions.d.ts +32 -0
  66. package/dist/instance/{children.d.ts → children/buildChildren.d.ts} +1 -1
  67. package/dist/instance/children/childrenInitOptions.d.ts +9 -0
  68. package/dist/instance/children/normalizeChildInitOptions.d.ts +2 -0
  69. package/dist/instance/hierarchy.d.ts +6 -7
  70. package/dist/instance/input/InitialInstanceState.d.ts +13 -0
  71. package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
  72. package/dist/instance/internal-api/InstanceAttachmentContext.d.ts +19 -0
  73. package/dist/instance/internal-api/InstanceConfig.d.ts +4 -9
  74. package/dist/instance/internal-api/InstanceValueContext.d.ts +8 -1
  75. package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +16 -0
  76. package/dist/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.d.ts +32 -0
  77. package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +18 -0
  78. package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +13 -0
  79. package/dist/instance/internal-api/serialization/ClientReactiveSerializableValueNode.d.ts +21 -0
  80. package/dist/instance/repeat/BaseRepeatRange.d.ts +10 -8
  81. package/dist/instance/repeat/RepeatInstance.d.ts +10 -7
  82. package/dist/instance/repeat/RepeatRangeControlled.d.ts +27 -3
  83. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +4 -3
  84. package/dist/instance/resource.d.ts +5 -1
  85. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +2 -2
  86. package/dist/integration/xpath/adapter/kind.d.ts +4 -10
  87. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +4 -5
  88. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +13 -10
  89. package/dist/integration/xpath/static-dom/StaticElement.d.ts +21 -22
  90. package/dist/integration/xpath/static-dom/StaticNode.d.ts +1 -1
  91. package/dist/integration/xpath/static-dom/StaticParentNode.d.ts +13 -0
  92. package/dist/integration/xpath/static-dom/staticNodeName.d.ts +3 -0
  93. package/dist/lib/client-reactivity/instance-state/createNodeRangeInstanceState.d.ts +4 -0
  94. package/dist/lib/client-reactivity/instance-state/createParentNodeInstanceState.d.ts +4 -0
  95. package/dist/lib/client-reactivity/instance-state/createPrimaryInstanceState.d.ts +3 -0
  96. package/dist/lib/client-reactivity/instance-state/createRootInstanceState.d.ts +3 -0
  97. package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +6 -0
  98. package/dist/lib/client-reactivity/instance-state/createValueNodeInstanceState.d.ts +3 -0
  99. package/dist/lib/client-reactivity/instance-state/prepareInstancePayload.d.ts +8 -0
  100. package/dist/lib/names/UnprefixedXFormsName.d.ts +4 -0
  101. package/dist/lib/reactivity/createInstanceAttachment.d.ts +8 -0
  102. package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
  103. package/dist/lib/resource-helpers.d.ts +2 -0
  104. package/dist/parse/XFormDOM.d.ts +1 -1
  105. package/dist/parse/body/BodyDefinition.d.ts +2 -1
  106. package/dist/parse/body/control/UploadControlDefinition.d.ts +2 -0
  107. package/dist/parse/model/BindDefinition.d.ts +1 -1
  108. package/dist/parse/model/BindTypeDefinition.d.ts +2 -7
  109. package/dist/parse/model/ItextTranslationsDefinition.d.ts +18 -0
  110. package/dist/parse/model/LeafNodeDefinition.d.ts +4 -5
  111. package/dist/parse/model/ModelBindMap.d.ts +1 -1
  112. package/dist/parse/model/ModelDefinition.d.ts +9 -2
  113. package/dist/parse/model/NodeDefinition.d.ts +18 -30
  114. package/dist/parse/model/NoteNodeDefinition.d.ts +3 -2
  115. package/dist/parse/model/RangeNodeDefinition.d.ts +2 -1
  116. package/dist/parse/model/RepeatDefinition.d.ts +62 -0
  117. package/dist/parse/model/RootAttributeDefinition.d.ts +1 -4
  118. package/dist/parse/model/RootAttributeMap.d.ts +2 -1
  119. package/dist/parse/model/RootDefinition.d.ts +7 -8
  120. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +15 -2
  121. package/dist/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.d.ts +5 -0
  122. package/dist/parse/model/SecondaryInstance/defineSecondaryInstance.d.ts +5 -0
  123. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +1 -7
  124. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +1 -1
  125. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +1 -1
  126. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +1 -1
  127. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +1 -1
  128. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +1 -1
  129. package/dist/parse/model/{FormSubmissionDefinition.d.ts → SubmissionDefinition.d.ts} +2 -2
  130. package/dist/parse/model/SubtreeDefinition.d.ts +4 -5
  131. package/dist/parse/model/nodeDefinitionMap.d.ts +5 -0
  132. package/dist/parse/shared/parseInstanceXML.d.ts +21 -0
  133. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +4 -21
  134. package/dist/solid.js +8251 -6751
  135. package/dist/solid.js.map +1 -1
  136. package/package.json +15 -14
  137. package/src/client/BaseNode.ts +4 -4
  138. package/src/client/BaseValueNode.ts +7 -3
  139. package/src/client/RootNode.ts +32 -19
  140. package/src/client/UploadNode.ts +78 -0
  141. package/src/client/attachments/InstanceAttachmentMeta.ts +10 -0
  142. package/src/client/attachments/InstanceAttachmentsConfig.ts +13 -0
  143. package/src/client/constants.ts +12 -14
  144. package/src/client/form/CreateFormInstance.ts +19 -0
  145. package/src/client/form/EditFormInstance.ts +93 -0
  146. package/src/client/form/FormInstance.ts +114 -0
  147. package/src/client/form/FormInstanceConfig.ts +21 -0
  148. package/src/client/form/FormResource.ts +1 -0
  149. package/src/client/form/LoadForm.ts +92 -0
  150. package/src/client/form/LoadFormResult.ts +103 -0
  151. package/src/client/form/RestoreFormInstance.ts +14 -0
  152. package/src/client/hierarchy.ts +5 -8
  153. package/src/client/index.ts +49 -29
  154. package/src/client/node-types.ts +3 -8
  155. package/src/client/repeat/BaseRepeatRangeNode.ts +3 -4
  156. package/src/client/repeat/RepeatInstanceNode.ts +4 -8
  157. package/src/client/repeat/RepeatRangeControlledNode.ts +2 -2
  158. package/src/client/repeat/RepeatRangeUncontrolledNode.ts +2 -2
  159. package/src/client/resources.ts +2 -2
  160. package/src/client/serialization/InstanceData.ts +24 -0
  161. package/src/client/serialization/InstanceFile.ts +9 -0
  162. package/src/client/serialization/InstancePayload.ts +126 -0
  163. package/src/client/serialization/InstancePayloadOptions.ts +29 -0
  164. package/src/client/serialization/InstanceState.ts +14 -0
  165. package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
  166. package/src/entrypoints/FormInstance.ts +56 -0
  167. package/src/entrypoints/FormResult/BaseFormResult.ts +40 -0
  168. package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +109 -0
  169. package/src/entrypoints/FormResult/FormFailureResult.ts +44 -0
  170. package/src/entrypoints/FormResult/FormSuccessResult.ts +25 -0
  171. package/src/entrypoints/FormResult/FormWarningResult.ts +25 -0
  172. package/src/entrypoints/createInstance.ts +23 -0
  173. package/src/entrypoints/editInstance.ts +24 -0
  174. package/src/entrypoints/index.ts +4 -0
  175. package/src/entrypoints/loadForm.ts +154 -0
  176. package/src/entrypoints/restoreInstance.ts +27 -0
  177. package/src/error/LoadFormFailureError.ts +114 -0
  178. package/src/error/MalformedInstanceDataError.ts +3 -0
  179. package/src/error/TemplatedNodeAttributeSerializationError.ts +24 -0
  180. package/src/error/UploadValueTypeError.ts +13 -0
  181. package/src/index.ts +2 -46
  182. package/src/instance/Group.ts +16 -15
  183. package/src/instance/InputControl.ts +17 -11
  184. package/src/instance/ModelValue.ts +17 -11
  185. package/src/instance/Note.ts +10 -9
  186. package/src/instance/PrimaryInstance.ts +68 -31
  187. package/src/instance/RangeControl.ts +17 -11
  188. package/src/instance/RankControl.ts +28 -19
  189. package/src/instance/Root.ts +20 -31
  190. package/src/instance/SelectControl.ts +21 -12
  191. package/src/instance/Subtree.ts +16 -15
  192. package/src/instance/TriggerControl.ts +21 -12
  193. package/src/instance/UploadControl.ts +184 -0
  194. package/src/instance/abstract/DescendantNode.ts +12 -2
  195. package/src/instance/abstract/InstanceNode.ts +9 -5
  196. package/src/instance/abstract/ValueNode.ts +11 -13
  197. package/src/instance/attachments/InstanceAttachment.ts +69 -0
  198. package/src/instance/attachments/InstanceAttachmentsState.ts +18 -0
  199. package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
  200. package/src/instance/{children.ts → children/buildChildren.ts} +57 -53
  201. package/src/instance/children/childrenInitOptions.ts +117 -0
  202. package/src/instance/children/normalizeChildInitOptions.ts +332 -0
  203. package/src/instance/hierarchy.ts +6 -9
  204. package/src/instance/input/InitialInstanceState.ts +108 -0
  205. package/src/instance/input/InstanceAttachmentMap.ts +154 -0
  206. package/src/instance/internal-api/InstanceAttachmentContext.ts +20 -0
  207. package/src/instance/internal-api/InstanceConfig.ts +6 -10
  208. package/src/instance/internal-api/InstanceValueContext.ts +9 -1
  209. package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +22 -0
  210. package/src/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.ts +43 -0
  211. package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +26 -0
  212. package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +24 -0
  213. package/src/instance/internal-api/serialization/ClientReactiveSerializableValueNode.ts +28 -0
  214. package/src/instance/repeat/BaseRepeatRange.ts +19 -24
  215. package/src/instance/repeat/RepeatInstance.ts +26 -19
  216. package/src/instance/repeat/RepeatRangeControlled.ts +90 -17
  217. package/src/instance/repeat/RepeatRangeUncontrolled.ts +10 -9
  218. package/src/instance/resource.ts +14 -1
  219. package/src/integration/xpath/EngineXPathEvaluator.ts +2 -2
  220. package/src/integration/xpath/adapter/kind.ts +1 -28
  221. package/src/integration/xpath/adapter/traversal.ts +2 -2
  222. package/src/integration/xpath/static-dom/StaticAttribute.ts +6 -5
  223. package/src/integration/xpath/static-dom/StaticDocument.ts +17 -16
  224. package/src/integration/xpath/static-dom/StaticElement.ts +196 -50
  225. package/src/integration/xpath/static-dom/StaticNode.ts +1 -1
  226. package/src/integration/xpath/static-dom/StaticParentNode.ts +22 -0
  227. package/src/integration/xpath/static-dom/staticNodeName.ts +20 -0
  228. package/src/lib/client-reactivity/instance-state/createNodeRangeInstanceState.ts +17 -0
  229. package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +22 -0
  230. package/src/lib/client-reactivity/instance-state/createPrimaryInstanceState.ts +12 -0
  231. package/src/lib/client-reactivity/{submission/createRootSubmissionState.ts → instance-state/createRootInstanceState.ts} +4 -4
  232. package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +31 -0
  233. package/src/lib/client-reactivity/instance-state/createValueNodeInstanceState.ts +21 -0
  234. package/src/lib/client-reactivity/instance-state/prepareInstancePayload.ts +237 -0
  235. package/src/lib/names/UnprefixedXFormsName.ts +12 -0
  236. package/src/lib/reactivity/createInstanceAttachment.ts +212 -0
  237. package/src/lib/reactivity/createInstanceValueState.ts +27 -51
  238. package/src/lib/resource-helpers.ts +33 -0
  239. package/src/parse/XFormDOM.ts +1 -3
  240. package/src/parse/body/BodyDefinition.ts +4 -0
  241. package/src/parse/body/control/UploadControlDefinition.ts +42 -0
  242. package/src/parse/model/BindDefinition.ts +1 -1
  243. package/src/parse/model/BindTypeDefinition.ts +68 -26
  244. package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
  245. package/src/parse/model/LeafNodeDefinition.ts +3 -5
  246. package/src/parse/model/ModelBindMap.ts +0 -5
  247. package/src/parse/model/ModelDefinition.ts +36 -3
  248. package/src/parse/model/NodeDefinition.ts +19 -45
  249. package/src/parse/model/NoteNodeDefinition.ts +4 -3
  250. package/src/parse/model/RangeNodeDefinition.ts +3 -2
  251. package/src/parse/model/RepeatDefinition.ts +382 -0
  252. package/src/parse/model/RootAttributeDefinition.ts +6 -7
  253. package/src/parse/model/RootAttributeMap.ts +15 -10
  254. package/src/parse/model/RootDefinition.ts +17 -19
  255. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +23 -2
  256. package/src/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.ts +14 -0
  257. package/src/parse/model/SecondaryInstance/defineSecondaryInstance.ts +32 -0
  258. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +3 -24
  259. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +33 -86
  260. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +1 -30
  261. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +64 -137
  262. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +9 -7
  263. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +1 -1
  264. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +7 -7
  265. package/src/parse/model/{FormSubmissionDefinition.ts → SubmissionDefinition.ts} +2 -2
  266. package/src/parse/model/SubtreeDefinition.ts +4 -5
  267. package/src/parse/model/nodeDefinitionMap.ts +34 -0
  268. package/src/parse/shared/parseInstanceXML.ts +79 -0
  269. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +45 -130
  270. package/dist/client/EngineConfig.d.ts +0 -79
  271. package/dist/client/submission/SubmissionData.d.ts +0 -7
  272. package/dist/client/submission/SubmissionInstanceFile.d.ts +0 -6
  273. package/dist/client/submission/SubmissionOptions.d.ts +0 -23
  274. package/dist/client/submission/SubmissionResult.d.ts +0 -91
  275. package/dist/client/submission/SubmissionState.d.ts +0 -12
  276. package/dist/client/unsupported/UnsupportedControlNode.d.ts +0 -30
  277. package/dist/client/unsupported/UploadNode.d.ts +0 -9
  278. package/dist/instance/abstract/UnsupportedControl.d.ts +0 -54
  279. package/dist/instance/index.d.ts +0 -8
  280. package/dist/instance/internal-api/ValueContext.d.ts +0 -23
  281. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +0 -14
  282. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +0 -32
  283. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +0 -19
  284. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +0 -18
  285. package/dist/instance/unsupported/UploadControl.d.ts +0 -6
  286. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +0 -3
  287. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +0 -3
  288. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +0 -4
  289. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +0 -4
  290. package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +0 -3
  291. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +0 -3
  292. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +0 -8
  293. package/dist/lib/reactivity/createValueState.d.ts +0 -40
  294. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +0 -4
  295. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +0 -9
  296. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +0 -8
  297. package/dist/parse/model/RepeatInstanceDefinition.d.ts +0 -17
  298. package/dist/parse/model/RepeatRangeDefinition.d.ts +0 -32
  299. package/dist/parse/model/RepeatTemplateDefinition.d.ts +0 -31
  300. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +0 -4
  301. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +0 -7
  302. package/src/client/EngineConfig.ts +0 -84
  303. package/src/client/submission/SubmissionData.ts +0 -12
  304. package/src/client/submission/SubmissionInstanceFile.ts +0 -9
  305. package/src/client/submission/SubmissionOptions.ts +0 -28
  306. package/src/client/submission/SubmissionResult.ts +0 -124
  307. package/src/client/submission/SubmissionState.ts +0 -14
  308. package/src/client/unsupported/UnsupportedControlNode.ts +0 -36
  309. package/src/client/unsupported/UploadNode.ts +0 -14
  310. package/src/instance/abstract/UnsupportedControl.ts +0 -175
  311. package/src/instance/index.ts +0 -55
  312. package/src/instance/internal-api/ValueContext.ts +0 -28
  313. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +0 -20
  314. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +0 -43
  315. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +0 -26
  316. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +0 -24
  317. package/src/instance/unsupported/UploadControl.ts +0 -9
  318. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +0 -12
  319. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +0 -20
  320. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +0 -17
  321. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +0 -22
  322. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +0 -21
  323. package/src/lib/client-reactivity/submission/prepareSubmission.ts +0 -172
  324. package/src/lib/reactivity/createValueState.ts +0 -200
  325. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +0 -4
  326. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +0 -42
  327. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +0 -31
  328. package/src/parse/model/RepeatInstanceDefinition.ts +0 -38
  329. package/src/parse/model/RepeatRangeDefinition.ts +0 -98
  330. package/src/parse/model/RepeatTemplateDefinition.ts +0 -149
  331. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +0 -4
  332. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getodk/xforms-engine",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "XForms engine for ODK Web Forms",
6
6
  "type": "module",
@@ -54,27 +54,28 @@
54
54
  "test:types": "tsc --project ./tsconfig.json --emitDeclarationOnly false --noEmit"
55
55
  },
56
56
  "dependencies": {
57
- "papaparse": "^5.4.1",
58
- "solid-js": "^1.9.3"
57
+ "bin-packer": "1.7.0",
58
+ "papaparse": "^5.5.2",
59
+ "solid-js": "^1.9.5"
59
60
  },
60
61
  "devDependencies": {
61
- "@babel/core": "^7.26.0",
62
- "@getodk/tree-sitter-xpath": "0.1.2",
63
- "@getodk/xpath": "0.4.0",
62
+ "@babel/core": "^7.26.10",
63
+ "@getodk/tree-sitter-xpath": "0.1.3",
64
+ "@getodk/xpath": "0.4.1",
64
65
  "@playwright/test": "^1.49.1",
65
66
  "@types/papaparse": "^5.3.15",
66
- "@vitest/browser": "^2.1.8",
67
- "babel-plugin-transform-jsbi-to-bigint": "^1.4.0",
67
+ "@vitest/browser": "^3.0.9",
68
+ "babel-plugin-transform-jsbi-to-bigint": "^1.4.2",
68
69
  "http-server": "^14.1.1",
69
- "jsdom": "^25.0.1",
70
- "typedoc": "^0.27.5",
71
- "vite": "^5.4.11",
72
- "vite-plugin-dts": "^4.3.0",
70
+ "jsdom": "^26.0.0",
71
+ "typedoc": "^0.28.2",
72
+ "vite": "^6.2.3",
73
+ "vite-plugin-dts": "^4.5.3",
73
74
  "vite-plugin-no-bundle": "^4.0.0",
74
- "vitest": "^2.1.8"
75
+ "vitest": "^3.0.9"
75
76
  },
76
77
  "peerDependencies": {
77
- "solid-js": "^1.9.3"
78
+ "solid-js": "^1.9.5"
78
79
  },
79
80
  "peerDependenciesMeta": {
80
81
  "solid-js": {
@@ -5,7 +5,7 @@ import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.
5
5
  import type { TextRange } from './TextRange.ts';
6
6
  import type { FormNodeID } from './identity.ts';
7
7
  import type { InstanceNodeType } from './node-types.ts';
8
- import type { SubmissionState } from './submission/SubmissionState.ts';
8
+ import type { InstanceState } from './serialization/InstanceState.ts';
9
9
  import type {
10
10
  AncestorNodeValidationState,
11
11
  LeafNodeValidationState,
@@ -256,14 +256,14 @@ export interface BaseNode {
256
256
  readonly validationState: NodeValidationState;
257
257
 
258
258
  /**
259
- * Represents the current submission state of the node.
259
+ * Represents the current instance state of the node.
260
260
  *
261
- * @see {@link SubmissionState.submissionXML} for additional detail.
261
+ * @see {@link InstanceState.instanceXML} for additional detail.
262
262
  *
263
263
  * @todo Consider whether this can (should) be merged with
264
264
  * {@link currentState}, while providing the same client-reactivity
265
265
  * guarantees. (The challenge there is in defining client-reactive state which
266
266
  * self-referentially derives state from its own definition.)
267
267
  */
268
- readonly submissionState: SubmissionState;
268
+ readonly instanceState: InstanceState;
269
269
  }
@@ -2,6 +2,7 @@ import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
2
2
  import type { BaseNode, BaseNodeState } from './BaseNode.ts';
3
3
  import type { GeneralParentNode } from './hierarchy.ts';
4
4
  import type { LeafNodeType } from './node-types.ts';
5
+ import type { InstanceState } from './serialization/InstanceState.ts';
5
6
  import type { LeafNodeValidationState } from './validation.ts';
6
7
  import type { ValueType } from './ValueType.ts';
7
8
 
@@ -15,12 +16,14 @@ export interface BaseValueNodeState<Value> extends BaseNodeState {
15
16
  * {@link value} state. This representation allows access to the node's value
16
17
  * _as primary instance state_. In other words, this is the value which:
17
18
  *
18
- * - would be serialized as a text node in
19
- * {@link SubmissionState.submissionXML} (note: this value is **NOT**
20
- * escaped for XML serialization, as it is there)
19
+ * - would be serialized as a text node in {@link InstanceState.instanceXML}
20
+ * (note: this value is **NOT** escaped for XML serialization, as it is
21
+ * there)
21
22
  *
22
23
  * - is used when the node's value is referenced in any of a form's XPath
23
24
  * expressions
25
+ *
26
+ * @todo Consider moving into {@link InstanceState}
24
27
  */
25
28
  get instanceValue(): string;
26
29
  }
@@ -32,4 +35,5 @@ export interface BaseValueNode<V extends ValueType = ValueType, Value = string>
32
35
  readonly parent: GeneralParentNode;
33
36
  readonly currentState: BaseValueNodeState<Value>;
34
37
  readonly validationState: LeafNodeValidationState;
38
+ readonly instanceState: InstanceState;
35
39
  }
@@ -3,12 +3,15 @@ import type { RootDefinition } from '../parse/model/RootDefinition.ts';
3
3
  import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import type { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
5
5
  import type { GeneralChildNode } from './hierarchy.ts';
6
- import type { SubmissionOptions } from './submission/SubmissionOptions.ts';
7
6
  import type {
8
- ChunkedSubmissionResult,
9
- MonolithicSubmissionResult,
10
- SubmissionResult,
11
- } from './submission/SubmissionResult.ts';
7
+ ChunkedInstancePayload,
8
+ InstancePayload,
9
+ MonolithicInstancePayload,
10
+ } from './serialization/InstancePayload.ts';
11
+ import type {
12
+ InstancePayloadOptions,
13
+ InstancePayloadType,
14
+ } from './serialization/InstancePayloadOptions.ts';
12
15
  import type { AncestorNodeValidationState } from './validation.ts';
13
16
 
14
17
  export interface RootNodeState extends BaseNodeState {
@@ -64,33 +67,43 @@ export interface RootNode extends BaseNode {
64
67
  setLanguage(language: FormLanguage): RootNode;
65
68
 
66
69
  /**
67
- * Prepares the current form instance state for submission.
70
+ * Prepares the current form instance state as an {@link InstancePayload}.
68
71
  *
69
- * A {@link SubmissionResult} will be prepared even if the current form state
70
- * includes `constraint` or `required` violations. This is intended to serve
71
- * two purposes:
72
+ * A payload will be prepared even if the current form state includes
73
+ * `constraint` or `required` violations. This supports serveral purposes:
72
74
  *
73
- * - A client may effectively use this method as a part of its own "submit"
74
- * routine, and use any violations included in the {@link SubmissionResult}
75
+ * - A client may effectively use this method as a part of its "submit"
76
+ * workflow, and use any violations included in the {@link InstancePayload}
75
77
  * to prompt users to address those violations.
76
78
  *
77
- * - A client may inspect the submission state of a form at any time.
79
+ * - A client may inspect the serialized instance state of a form at any time.
78
80
  * Depending on the client and use case, this may be a convenience (e.g. for
79
81
  * developers to inspect that form state at a current point in time); or it
80
82
  * may provide necessary functionality (e.g. for test or tooling clients).
81
83
  *
82
- * Note on asynchrony: preparing a {@link SubmissionResult} is expected to be
83
- * a fast operation. It may even be nearly instantaneous, or roughly
84
+ * - A client may capture _incomplete_ instance state (e.g. for storage in
85
+ * client-side storage or similar persistance layer), to resume filling the
86
+ * instance at a later time.
87
+ *
88
+ * Note on asynchrony: preparing a {@link InstancePayload} is expected to be a
89
+ * fast operation. It may even be nearly instantaneous, or roughly
84
90
  * proportionate to the size of the form itself. However, this method is
85
91
  * designed to be asynchronous out of an abundance of caution, anticipating
86
92
  * that some as-yet undeveloped operations on binary data (e.g. form
87
93
  * attachments) may themselves impose asynchrony (i.e. by interfaces provided
88
94
  * by the platform and/or external dependencies).
89
95
  *
90
- * A client may specify {@link SubmissionOptions<'chunked'>}, in which case a
91
- * {@link SubmissionResult<'chunked'>} will be produced, with form attachments
96
+ * A client may specify {@link InstancePayloadOptions<'chunked'>}, in which
97
+ * case a {@link ChunkedInstancePayload} will be produced, with form
98
+ * attachments
92
99
  */
93
- prepareSubmission(): Promise<MonolithicSubmissionResult>;
94
- prepareSubmission(options: SubmissionOptions<'monolithic'>): Promise<MonolithicSubmissionResult>;
95
- prepareSubmission(options: SubmissionOptions<'chunked'>): Promise<ChunkedSubmissionResult>;
100
+ prepareInstancePayload(
101
+ options?: InstancePayloadOptions<'monolithic'>
102
+ ): Promise<MonolithicInstancePayload>;
103
+ prepareInstancePayload(
104
+ options: InstancePayloadOptions<'chunked'>
105
+ ): Promise<ChunkedInstancePayload>;
106
+ prepareInstancePayload<PayloadType extends InstancePayloadType>(
107
+ options: InstancePayloadOptions<PayloadType>
108
+ ): Promise<InstancePayload<PayloadType>>;
96
109
  }
@@ -0,0 +1,78 @@
1
+ import type { PartiallyKnownString } from '@getodk/common/types/string/PartiallyKnownString.ts';
2
+ import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
3
+ import type { UploadControlDefinition } from '../parse/body/control/UploadControlDefinition.ts';
4
+ import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
5
+ import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
6
+ import type { GeneralParentNode } from './hierarchy.ts';
7
+ import type { RootNode } from './RootNode.ts';
8
+ import type { InstanceAttachmentFileName } from './serialization/InstanceData.ts';
9
+ import type { LeafNodeValidationState } from './validation.ts';
10
+ import type { ValueType } from './ValueType.ts';
11
+
12
+ export type UploadValue = File | null;
13
+
14
+ export interface UploadNodeState extends BaseValueNodeState<UploadValue> {
15
+ get valueOptions(): null;
16
+ get value(): UploadValue;
17
+ get instanceValue(): InstanceAttachmentFileName;
18
+ }
19
+
20
+ export interface UploadDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
21
+ readonly bodyElement: UploadControlDefinition;
22
+ }
23
+
24
+ // prettier-ignore
25
+ export type UploadMediaType = PartiallyKnownString<
26
+ | '*'
27
+ | 'audio'
28
+ | 'image'
29
+ | 'video'
30
+ >;
31
+
32
+ export type UploadMediaSubtype = PartiallyKnownString<'*'>;
33
+
34
+ // prettier-ignore
35
+ export type UploadMediaAccept = PartiallyKnownString<
36
+ | '*'
37
+ | `${UploadMediaType}/${UploadMediaSubtype}`
38
+ >;
39
+
40
+ interface BaseUploadMediaOptions {
41
+ readonly accept: UploadMediaAccept;
42
+ readonly type: UploadMediaType | null;
43
+ readonly subtype: UploadMediaSubtype | null;
44
+ }
45
+
46
+ export interface ExplicitUploadMediaOptions extends BaseUploadMediaOptions {
47
+ readonly type: UploadMediaType;
48
+ readonly subtype: UploadMediaSubtype;
49
+ }
50
+
51
+ export interface UnspecifiedUploadMediaOptions extends BaseUploadMediaOptions {
52
+ readonly type: null;
53
+ readonly subtype: null;
54
+ }
55
+
56
+ // prettier-ignore
57
+ export type UploadMediaOptions =
58
+ | ExplicitUploadMediaOptions
59
+ | UnspecifiedUploadMediaOptions;
60
+
61
+ export interface UploadNodeOptions {
62
+ readonly media: UploadMediaOptions;
63
+ }
64
+
65
+ export interface UploadNode extends BaseValueNode<'binary', UploadValue> {
66
+ readonly nodeType: 'upload';
67
+ /** @todo */
68
+ readonly appearances: UnknownAppearanceDefinition;
69
+ readonly nodeOptions: UploadNodeOptions;
70
+ readonly valueType: 'binary';
71
+ readonly definition: UploadDefinition<'binary'>;
72
+ readonly root: RootNode;
73
+ readonly parent: GeneralParentNode;
74
+ readonly currentState: UploadNodeState;
75
+ readonly validationState: LeafNodeValidationState;
76
+
77
+ setValue(value: UploadValue): RootNode;
78
+ }
@@ -0,0 +1,10 @@
1
+ import type { FormNodeID } from '../identity.ts';
2
+
3
+ export type InstanceAttachmentExtension = `.${string}`;
4
+
5
+ export interface InstanceAttachmentMeta {
6
+ readonly nodeId: FormNodeID;
7
+ readonly writtenAt: Date | null;
8
+ readonly basename: string;
9
+ readonly extension: InstanceAttachmentExtension | null;
10
+ }
@@ -0,0 +1,13 @@
1
+ import type { InstanceAttachmentMeta } from './InstanceAttachmentMeta.ts';
2
+
3
+ export interface UpdatedInstanceAttachmentMeta extends InstanceAttachmentMeta {
4
+ readonly writtenAt: Date;
5
+ }
6
+
7
+ export type InstanceAttachmentFileNameFactory = (
8
+ meta: UpdatedInstanceAttachmentMeta
9
+ ) => string | null;
10
+
11
+ export interface InstanceAttachmentsConfig {
12
+ readonly fileNameFactory?: InstanceAttachmentFileNameFactory;
13
+ }
@@ -1,21 +1,19 @@
1
- import type { PrimaryInstance } from '../instance/PrimaryInstance.ts';
2
- import type { InitializeForm } from './index.ts';
1
+ import type { LoadForm } from './form/LoadForm.ts';
3
2
  import type { ValidationTextRole } from './TextRange.ts';
4
3
 
5
4
  export const MISSING_RESOURCE_BEHAVIOR = {
6
5
  /**
7
- * When this behavior is configured, {@link InitializeForm | initializing} a
8
- * {@link PrimaryInstance} for a form which references any **missing**
9
- * resources will fail, producing an error to the calling client.
6
+ * When this behavior is configured, {@link LoadForm | loading a form} which
7
+ * references any **missing** resources will fail, producing an error to the
8
+ * calling client.
10
9
  *
11
10
  * @see {@link MissingResourceBehavior}
12
11
  */
13
12
  ERROR: 'ERROR',
14
13
 
15
14
  /**
16
- * When this behavior is configured, {@link InitializeForm | initializing} a
17
- * {@link PrimaryInstance} for a form which references any **missing**
18
- * resources will succeed (producing a warning).
15
+ * When this behavior is configured, {@link LoadForm | loading a form} which
16
+ * references any **missing** resources will succeed (producing a warning).
19
17
  *
20
18
  * Such missing resources will be parsed as if they are blank, as appropriate
21
19
  * for the resource's XForm semantic usage and/or format.
@@ -39,8 +37,8 @@ export type MissingResourceBehaviorBlank = typeof MISSING_RESOURCE_BEHAVIOR.BLAN
39
37
  export type MissingResourceBehaviorDefault = typeof MISSING_RESOURCE_BEHAVIOR.DEFAULT;
40
38
 
41
39
  /**
42
- * Specifies behavior for {@link InitializeForm | initializing} a form's
43
- * {@link PrimaryInstance} which references any **missing** resources.
40
+ * Specifies behavior for {@link LoadForm | loading a form} which references any
41
+ * **missing** resources.
44
42
  *
45
43
  * Here the term "missing" is consistent with
46
44
  * {@link https://www.rfc-editor.org/rfc/rfc9110#status.404 | HTTP 404 status}
@@ -70,8 +68,8 @@ type ValidationTextDefaults = typeof VALIDATION_TEXT;
70
68
 
71
69
  export type ValidationTextDefault<Role extends ValidationTextRole> = ValidationTextDefaults[Role];
72
70
 
73
- export const SUBMISSION_INSTANCE_FILE_NAME = 'xml_submission_file';
74
- export type SubmissionInstanceFileName = typeof SUBMISSION_INSTANCE_FILE_NAME;
71
+ export const INSTANCE_FILE_NAME = 'xml_submission_file';
72
+ export type INSTANCE_FILE_NAME = typeof INSTANCE_FILE_NAME;
75
73
 
76
- export const SUBMISSION_INSTANCE_FILE_TYPE = 'text/xml';
77
- export type SubmissionInstanceFileType = typeof SUBMISSION_INSTANCE_FILE_TYPE;
74
+ export const INSTANCE_FILE_TYPE = 'text/xml';
75
+ export type INSTANCE_FILE_TYPE = typeof INSTANCE_FILE_TYPE;
@@ -0,0 +1,19 @@
1
+ import type { RootNode } from '../RootNode.ts';
2
+ import type { FormInstance, FormInstanceCreateMode } from './FormInstance.ts';
3
+ import type { FormInstanceConfig } from './FormInstanceConfig.ts';
4
+ import type { LoadForm } from './LoadForm.ts';
5
+ import type { LoadFormResult } from './LoadFormResult.ts';
6
+
7
+ export type CreatedFormInstance = FormInstance<FormInstanceCreateMode>;
8
+
9
+ /**
10
+ * @todo This is fallible! Client-facing interfaces will need to account for
11
+ * this. We've begun addressing fallibility _at the interface level_ in
12
+ * {@link LoadForm} (with {@link LoadFormResult}). We'll eventually have a more
13
+ * general interface pattern for this, and we'll apply it here as well. The baby
14
+ * step approach in {@link LoadFormResult} is impractical here due to
15
+ * engine-internal designs, and revising that is currently out of scope. As
16
+ * such, explicit interface-level documentation of fallibility is deferred here,
17
+ * on {@link RootNode} itself, and into any of its sub-interfaces.
18
+ */
19
+ export type CreateFormInstance = (config?: FormInstanceConfig) => CreatedFormInstance;
@@ -0,0 +1,93 @@
1
+ import type { Awaitable, Thunk } from '@getodk/common/types/helpers.d.ts';
2
+ import type { FetchResourceResponse } from '../resources.ts';
3
+ import type { InstanceAttachmentFileName, InstanceData } from '../serialization/InstanceData.ts';
4
+ import type { FormInstance, FormInstanceEditMode } from './FormInstance.ts';
5
+ import type { FormInstanceConfig } from './FormInstanceConfig.ts';
6
+ import type { LoadForm } from './LoadForm.ts';
7
+ import type { RestoreFormInstance, RestoreFormInstanceInput } from './RestoreFormInstance.ts';
8
+
9
+ export type ResolvableFormInstanceInputType = 'FORM_INSTANCE_INPUT_RESOLVABLE';
10
+ export type ResolvedFormInstanceInputType = 'FORM_INSTANCE_INPUT_RESOLVED';
11
+
12
+ // prettier-ignore
13
+ export type EditFormInstanceInputType =
14
+ | ResolvableFormInstanceInputType
15
+ | ResolvedFormInstanceInputType;
16
+
17
+ // prettier-ignore
18
+ export type ResolvedFormInstance =
19
+ | Blob
20
+ | FetchResourceResponse
21
+ | File
22
+ | string;
23
+
24
+ export type ResolvableFormInstance = Thunk<Awaitable<ResolvedFormInstance>>;
25
+
26
+ export type ResolveFormInstanceResource = Thunk<Promise<FetchResourceResponse>>;
27
+
28
+ export type ResolvableInstanceAttachmentsMap = ReadonlyMap<
29
+ InstanceAttachmentFileName,
30
+ ResolveFormInstanceResource
31
+ >;
32
+
33
+ interface BaseEditFormInstanceInput {
34
+ readonly inputType: EditFormInstanceInputType;
35
+ readonly data?: readonly [InstanceData, ...InstanceData[]];
36
+ readonly resolveInstance?: ResolvableFormInstance;
37
+ readonly attachments?: ResolvableInstanceAttachmentsMap;
38
+ }
39
+
40
+ export interface ResolvableFormInstanceInput extends BaseEditFormInstanceInput {
41
+ readonly inputType: ResolvableFormInstanceInputType;
42
+ readonly resolveInstance: ResolvableFormInstance;
43
+ readonly attachments: ResolvableInstanceAttachmentsMap;
44
+ readonly data?: never;
45
+ }
46
+
47
+ /**
48
+ * @todo This is included as a strawman for discussiong: "should we accept input
49
+ * to {@link EditFormInstance} in the same shape as input to
50
+ * {@link RestoreFormInstance}?".
51
+ *
52
+ * Pros:
53
+ *
54
+ * - More consistency between the two entrypoint APIs, which are pretty similar
55
+ * _conceptually_.
56
+ * - ?
57
+ *
58
+ * Cons:
59
+ *
60
+ * - Less consistency between this entrypoint API and {@link LoadForm}, which is
61
+ * also responsible for loading arbitrary attachments (presumably over a
62
+ * network), which...
63
+ * - ... all but rules out flexibility to optimize loading large resources (i.e.
64
+ * streaming video/audio)
65
+ *
66
+ * Alternative:
67
+ *
68
+ * - Increase consistency across the board by inverting the relationship between
69
+ * edit/restore: {@link RestoreFormInstanceInput} could be the place where we
70
+ * accept a union of resolved | resolvable input, and clients which might
71
+ * benefit from this consistency could consolidate on the resolvable case
72
+ * without sacrificing resource loading optimizations)
73
+ */
74
+ export interface ResolvedFormInstanceInput
75
+ extends BaseEditFormInstanceInput,
76
+ RestoreFormInstanceInput {
77
+ readonly inputType: ResolvedFormInstanceInputType;
78
+ readonly data: readonly [InstanceData, ...InstanceData[]];
79
+ readonly resolveInstance?: never;
80
+ readonly attachments?: never;
81
+ }
82
+
83
+ // prettier-ignore
84
+ export type EditFormInstanceInput =
85
+ | ResolvableFormInstanceInput
86
+ | ResolvedFormInstanceInput;
87
+
88
+ export type EditedFormInstance = FormInstance<FormInstanceEditMode>;
89
+
90
+ export type EditFormInstance = (
91
+ input: EditFormInstanceInput,
92
+ config?: FormInstanceConfig
93
+ ) => Promise<EditedFormInstance>;
@@ -0,0 +1,114 @@
1
+ import type { RootNode } from '../RootNode.ts';
2
+ import type { InstantiableLoadFormResult, LoadFormResult } from './LoadFormResult.ts';
3
+
4
+ /**
5
+ * Represents an instance which is newly created from a form definition.
6
+ *
7
+ * A newly created instance is populated with default values and state defined
8
+ * by the form.
9
+ *
10
+ * Computations are performed on initialization as specified by
11
+ * {@link https://getodk.github.io/xforms-spec/ | ODK XForms}, as the instance's
12
+ * {@link https://getodk.github.io/xforms-spec/#event:odk-instance-first-load | first load}.
13
+ */
14
+ export type FormInstanceCreateMode = 'create';
15
+
16
+ /**
17
+ * Represents an instance restored from previously filled state, as represented
18
+ * in an {@link InstancePayload}. Clients may serialize and persist an instance
19
+ * payload as appropriate for their use cases, and can restore the instance with
20
+ * a partial instance payload structure, defined by the
21
+ * {@link RestoreFormInstanceInput} interface.
22
+ *
23
+ * A restored instance is populated by the engine with the answers as they had
24
+ * been filled at the time the {@link InstancePayload}
25
+ * ({@link RestoreFormInstanceInput}) was created.
26
+ *
27
+ * Computations are performed on initialization as specified by
28
+ * {@link https://getodk.github.io/xforms-spec/#event:odk-instance-load | ODK XForms},
29
+ * as a
30
+ * {@link https://getodk.github.io/xforms-spec/#event:odk-instance-load | subsequent load}
31
+ * (i.e. **NOT** "first load", as is the case with newly
32
+ * {@link FormInstanceCreateMode | created} instances}) of the instance.
33
+ */
34
+ export type FormInstanceRestoreMode = 'restore';
35
+
36
+ /**
37
+ * Represents an instance which:
38
+ *
39
+ * - was previously serialized
40
+ * - was **submitted**, often referred to as a "submission" (noun)
41
+ * - is being initialized to produce an edited instance of that "submission"
42
+ *
43
+ * An edited instance may be populated from one or more network-accessible
44
+ * resources—its serialized instance XML, and any _instance attachments_—which
45
+ * are resolved in a manner similar to that of a form definition and its _form
46
+ * attachments_.
47
+ *
48
+ * Once resolved, an edited instance is restored from its previously filled
49
+ * state _as it was submitted_, consistent with
50
+ * {@link FormInstanceRestoreMode | restoring an instance}, with the following
51
+ * exceptions:
52
+ *
53
+ * - If the form or instance does not define an explicit
54
+ * {@link https://getodk.github.io/xforms-spec/#metadata | `deprecatedID` metadata element},
55
+ * one will be created.
56
+ *
57
+ * - If the instance has an `instanceID` metadata element, that element's value
58
+ * will be assigned to the instance's `deprecatedID`.
59
+ *
60
+ * - If applicable, a new instance id will be assigned:
61
+ *
62
+ * - If the instance has an `instanceID` metadata element, and the form
63
+ * explicitly defines a
64
+ * {@link https://getodk.github.io/xforms-spec/#preload-attributes | `uid` preload attribute}
65
+ * for its model binding, a new instance id value will be assigned to that
66
+ * element _as if it were the
67
+ * {@link https://getodk.github.io/xforms-spec/#event:odk-instance-first-load | instance's first load}_.
68
+ *
69
+ * - **Consistent with {@link FormInstanceCreateMode | instance creation}:**
70
+ * if the form **DOES NOT** define an `instanceID` element or model
71
+ * binding, the `uid` preload behavior described above is **implied** as
72
+ * the form's default behavior for that metadata; in which case whether
73
+ * the instance defines an `instanceID` element explicitly or not, it will
74
+ * be treated as if it had, behaving as described in the point above.
75
+ *
76
+ * **NOTE:** the behavior for an instance's `instanceID` metadata element and a
77
+ * form's `uid` preload attribute describe a special case, applying only to that
78
+ * specific preload attribute. In other words, when initializing instance state
79
+ * for editing:
80
+ *
81
+ * - The `odk-instance-first-load` event itself will **NOT** be triggered
82
+ * - Preload attributes _other than `uid`_ will **NOT** be recomputed
83
+ *
84
+ * **NOTE:** while the `uid` preload attribute is discussed above in terms of
85
+ * the `instanceID` meta element, its behavior is not applied specially to any
86
+ * particular node, regardless of
87
+ * {@link FormInstanceInitializationMode | initialization mode}.
88
+ */
89
+ export type FormInstanceEditMode = 'edit';
90
+
91
+ // prettier-ignore
92
+ export type FormInstanceInitializationMode =
93
+ | FormInstanceCreateMode
94
+ | FormInstanceEditMode
95
+ | FormInstanceRestoreMode;
96
+
97
+ /**
98
+ * @todo this could hypothetically convey warnings and/or errors, just as
99
+ * {@link LoadFormResult} does. This has been deferred because:
100
+ *
101
+ * - We really want a more thoughtful design for Result types
102
+ * - The `try`/`catch` approach to capturing all errors takes a huge performance
103
+ * hit, which we should not incur if we have a more thoughtful design coming
104
+ * eventually. It would be too easy to forget about, indefinitely!
105
+ */
106
+ export interface FormInstance<Mode extends FormInstanceInitializationMode> {
107
+ readonly formResult: InstantiableLoadFormResult;
108
+ readonly mode: Mode;
109
+ readonly root: RootNode;
110
+ }
111
+
112
+ export type AnyFormInstance = {
113
+ [Mode in FormInstanceInitializationMode]: FormInstance<Mode>;
114
+ }[FormInstanceInitializationMode];
@@ -0,0 +1,21 @@
1
+ import type { InstanceAttachmentsConfig } from '../attachments/InstanceAttachmentsConfig.ts';
2
+ import type { OpaqueReactiveObjectFactory } from '../OpaqueReactiveObjectFactory.ts';
3
+
4
+ export interface FormInstanceConfig {
5
+ /**
6
+ * A client may specify a generic function for constructing stateful objects.
7
+ * The only hard requirement of this function is that it accepts an **object**
8
+ * and returns an object of the same shape. The engine will use this function
9
+ * to initialize client-facing state, and will mutate properties of the object
10
+ * when their corresponding state is changed.
11
+ *
12
+ * A client may use this function to provide its own implementation of
13
+ * reactivity with semantics like those described above. The mechanism of
14
+ * reactivity, if any, is at the discretion of the client. It is expected that
15
+ * clients providing this function will use a reactive subscribe-on-read
16
+ * mechanism to handle state updates conveyed by the engine.
17
+ */
18
+ readonly stateFactory?: OpaqueReactiveObjectFactory;
19
+
20
+ readonly instanceAttachments?: InstanceAttachmentsConfig;
21
+ }
@@ -0,0 +1 @@
1
+ export type FormResource = Blob | File | URL | string;