@iota-uz/sdk 0.46.0 → 0.47.1

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 (535) hide show
  1. package/README.md +5 -0
  2. package/dist/client-host/identity.d.ts +4 -4
  3. package/dist/client-host/identity.js +2 -2
  4. package/dist/lens/{CascadePanel-Bha4qY7J.js → CascadePanel-BlYJd18G.js} +1 -1
  5. package/dist/lens/{ChartDataEquivalent-Bwgn4yYB.js → ChartDataEquivalent-B6xSOdzC.js} +1 -1
  6. package/dist/lens/{ChartPanel-BZpzBuwl.js → ChartPanel-BIJjrs5D.js} +159 -159
  7. package/dist/lens/{CoveragePanel-D40AuKkD.js → CoveragePanel-CHtXDMtt.js} +1 -1
  8. package/dist/lens/{GaugePanel-C9k2TuJH.js → GaugePanel-By0TOJPa.js} +1 -1
  9. package/dist/lens/LensDashboard.d.ts +13 -0
  10. package/dist/lens/LensDashboard.d.ts.map +1 -1
  11. package/dist/lens/{MapPanel-ZYxfDsPM.js → MapPanel-Cw4ELCiM.js} +3 -3
  12. package/dist/lens/{MetricFlowPanel-CmESLoLK.js → MetricFlowPanel-Gr5wi3nI.js} +2 -2
  13. package/dist/lens/{MetricHierarchyPanel-UZVuJ5P2.js → MetricHierarchyPanel-VLA_5LXX.js} +2 -2
  14. package/dist/lens/{MetricRelationshipPanel-CXLdScAy.js → MetricRelationshipPanel-DFP566_c.js} +2 -2
  15. package/dist/lens/{PrintReport-lrfdCTZO.js → PrintReport-C0OV1iHP.js} +5 -5
  16. package/dist/lens/{QualityChip-BYz-DHfs.js → QualityChip-DTi-0jdh.js} +1 -1
  17. package/dist/lens/SaveInvestigation-CX1Abyl8.js +309 -0
  18. package/dist/lens/TablePanel-BusKU7cU.js +994 -0
  19. package/dist/lens/{adapter-CeAqYWqm.js → adapter-CQg4-M7p.js} +7 -7
  20. package/dist/lens/contract/schemas.d.ts +2 -0
  21. package/dist/lens/contract/schemas.d.ts.map +1 -1
  22. package/dist/lens/contract/types.d.ts +12 -0
  23. package/dist/lens/contract/types.d.ts.map +1 -1
  24. package/dist/lens/{dashboardEdit-DKVE_6J_.js → dashboardEdit-CJgCVfi_.js} +1 -1
  25. package/dist/lens/explore/DrillOverlay.d.ts +38 -0
  26. package/dist/lens/explore/DrillOverlay.d.ts.map +1 -1
  27. package/dist/lens/explore/ExplorePanel.d.ts.map +1 -1
  28. package/dist/lens/explore/SaveInvestigation.d.ts +21 -0
  29. package/dist/lens/explore/SaveInvestigation.d.ts.map +1 -0
  30. package/dist/lens/explore/drillHost.d.ts +25 -0
  31. package/dist/lens/explore/drillHost.d.ts.map +1 -0
  32. package/dist/lens/explore/investigation.d.ts +174 -0
  33. package/dist/lens/explore/investigation.d.ts.map +1 -0
  34. package/dist/lens/explore/provenanceLabels.d.ts +10 -0
  35. package/dist/lens/explore/provenanceLabels.d.ts.map +1 -0
  36. package/dist/lens/index-DR7Hf8Km.js +19805 -0
  37. package/dist/lens/{index-DkVTXC8W.js → index-DZFw4cqF.js} +1 -1
  38. package/dist/lens/index.d.ts +7 -1
  39. package/dist/lens/index.d.ts.map +1 -1
  40. package/dist/lens/index.js +67 -53
  41. package/dist/lens/{install-CQ_iMuAE.js → install-B2lTK6uo.js} +1 -1
  42. package/dist/lens/{install-Ch0_qifK.js → install-BXr4Mnc0.js} +1 -1
  43. package/dist/lens/{install-CKmxqMe1.js → install-CicNQ_ks.js} +1 -1
  44. package/dist/lens/{install-BwD_xNlp.js → install-d8A0WPiw.js} +1 -1
  45. package/dist/lens/{keys-BBmWdfaH.js → keys-C-Akc9lZ.js} +2 -2
  46. package/dist/lens/panels/ChartPanel.d.ts.map +1 -1
  47. package/dist/lens/panels/TablePanel.d.ts.map +1 -1
  48. package/dist/lens/panels/actions.d.ts.map +1 -1
  49. package/dist/lens/panels/panelFailure.d.ts.map +1 -1
  50. package/dist/lens/{prefetch-BXoUIIgq.js → prefetch-C9kxuIs8.js} +2 -2
  51. package/dist/lens/{prefetchPanels-a-zs_bDm.js → prefetchPanels-gbY9RIqL.js} +1 -1
  52. package/dist/lens/{print-CpgWJxDG.js → print-CllsAP3d.js} +1 -1
  53. package/dist/lens/reports/ReportCompositionEditor.d.ts +8 -2
  54. package/dist/lens/reports/ReportCompositionEditor.d.ts.map +1 -1
  55. package/dist/lens/reports/ReportDefinitionEditor.d.ts +54 -0
  56. package/dist/lens/reports/ReportDefinitionEditor.d.ts.map +1 -0
  57. package/dist/lens/reports/ReportPicker.d.ts +6 -0
  58. package/dist/lens/reports/ReportPicker.d.ts.map +1 -1
  59. package/dist/lens/reports/dashboardEdit.d.ts +3 -0
  60. package/dist/lens/reports/dashboardEdit.d.ts.map +1 -1
  61. package/dist/lens/reports/editing.d.ts +35 -0
  62. package/dist/lens/reports/editing.d.ts.map +1 -1
  63. package/dist/lens/reports/picker.d.ts +4 -1
  64. package/dist/lens/reports/picker.d.ts.map +1 -1
  65. package/dist/lens/runtime/index.d.ts +0 -1
  66. package/dist/lens/runtime/index.d.ts.map +1 -1
  67. package/dist/lens/runtime/messages.d.ts +2 -2
  68. package/dist/lens/runtime/messages.d.ts.map +1 -1
  69. package/dist/lens/runtime/provider.d.ts +5 -1
  70. package/dist/lens/runtime/provider.d.ts.map +1 -1
  71. package/dist/lens/runtime/returnContext.d.ts +62 -0
  72. package/dist/lens/runtime/returnContext.d.ts.map +1 -0
  73. package/dist/lens/runtime/tableSummary.d.ts +9 -0
  74. package/dist/lens/runtime/tableSummary.d.ts.map +1 -0
  75. package/dist/lens/{scales-BLf9OweG.js → scales-CO6Q9RtG.js} +1 -1
  76. package/dist/lens/style.css +1 -1
  77. package/dist/runtime/README.md +24 -0
  78. package/dist/runtime/assert.d.ts +51 -0
  79. package/dist/runtime/assert.js +172 -0
  80. package/dist/runtime/build/README.txt +1 -0
  81. package/dist/runtime/build/extract.mjs +342 -0
  82. package/dist/runtime/build/shared-exports.json +388 -0
  83. package/dist/runtime/build/test-child.mjs +136 -0
  84. package/dist/runtime/build/theme/tailwind.config.js +121 -0
  85. package/dist/runtime/build/theme/theme.css +462 -0
  86. package/dist/runtime/build/theme/utilities.css +1 -0
  87. package/dist/runtime/build/vendor/lib/lib.d.ts +22 -0
  88. package/dist/runtime/build/vendor/lib/lib.decorators.d.ts +384 -0
  89. package/dist/runtime/build/vendor/lib/lib.decorators.legacy.d.ts +22 -0
  90. package/dist/runtime/build/vendor/lib/lib.dom.asynciterable.d.ts +41 -0
  91. package/dist/runtime/build/vendor/lib/lib.dom.d.ts +28983 -0
  92. package/dist/runtime/build/vendor/lib/lib.dom.iterable.d.ts +491 -0
  93. package/dist/runtime/build/vendor/lib/lib.es2015.collection.d.ts +147 -0
  94. package/dist/runtime/build/vendor/lib/lib.es2015.core.d.ts +597 -0
  95. package/dist/runtime/build/vendor/lib/lib.es2015.d.ts +28 -0
  96. package/dist/runtime/build/vendor/lib/lib.es2015.generator.d.ts +77 -0
  97. package/dist/runtime/build/vendor/lib/lib.es2015.iterable.d.ts +590 -0
  98. package/dist/runtime/build/vendor/lib/lib.es2015.promise.d.ts +81 -0
  99. package/dist/runtime/build/vendor/lib/lib.es2015.proxy.d.ts +128 -0
  100. package/dist/runtime/build/vendor/lib/lib.es2015.reflect.d.ts +144 -0
  101. package/dist/runtime/build/vendor/lib/lib.es2015.symbol.d.ts +46 -0
  102. package/dist/runtime/build/vendor/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  103. package/dist/runtime/build/vendor/lib/lib.es2016.array.include.d.ts +116 -0
  104. package/dist/runtime/build/vendor/lib/lib.es2016.d.ts +21 -0
  105. package/dist/runtime/build/vendor/lib/lib.es2016.full.d.ts +23 -0
  106. package/dist/runtime/build/vendor/lib/lib.es2016.intl.d.ts +31 -0
  107. package/dist/runtime/build/vendor/lib/lib.es2017.arraybuffer.d.ts +21 -0
  108. package/dist/runtime/build/vendor/lib/lib.es2017.d.ts +26 -0
  109. package/dist/runtime/build/vendor/lib/lib.es2017.date.d.ts +31 -0
  110. package/dist/runtime/build/vendor/lib/lib.es2017.full.d.ts +23 -0
  111. package/dist/runtime/build/vendor/lib/lib.es2017.intl.d.ts +44 -0
  112. package/dist/runtime/build/vendor/lib/lib.es2017.object.d.ts +49 -0
  113. package/dist/runtime/build/vendor/lib/lib.es2017.sharedmemory.d.ts +135 -0
  114. package/dist/runtime/build/vendor/lib/lib.es2017.string.d.ts +45 -0
  115. package/dist/runtime/build/vendor/lib/lib.es2017.typedarrays.d.ts +53 -0
  116. package/dist/runtime/build/vendor/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  117. package/dist/runtime/build/vendor/lib/lib.es2018.asynciterable.d.ts +53 -0
  118. package/dist/runtime/build/vendor/lib/lib.es2018.d.ts +24 -0
  119. package/dist/runtime/build/vendor/lib/lib.es2018.full.d.ts +24 -0
  120. package/dist/runtime/build/vendor/lib/lib.es2018.intl.d.ts +83 -0
  121. package/dist/runtime/build/vendor/lib/lib.es2018.promise.d.ts +30 -0
  122. package/dist/runtime/build/vendor/lib/lib.es2018.regexp.d.ts +37 -0
  123. package/dist/runtime/build/vendor/lib/lib.es2019.array.d.ts +79 -0
  124. package/dist/runtime/build/vendor/lib/lib.es2019.d.ts +24 -0
  125. package/dist/runtime/build/vendor/lib/lib.es2019.full.d.ts +24 -0
  126. package/dist/runtime/build/vendor/lib/lib.es2019.intl.d.ts +23 -0
  127. package/dist/runtime/build/vendor/lib/lib.es2019.object.d.ts +33 -0
  128. package/dist/runtime/build/vendor/lib/lib.es2019.string.d.ts +37 -0
  129. package/dist/runtime/build/vendor/lib/lib.es2019.symbol.d.ts +24 -0
  130. package/dist/runtime/build/vendor/lib/lib.es2020.bigint.d.ts +731 -0
  131. package/dist/runtime/build/vendor/lib/lib.es2020.d.ts +27 -0
  132. package/dist/runtime/build/vendor/lib/lib.es2020.date.d.ts +42 -0
  133. package/dist/runtime/build/vendor/lib/lib.es2020.full.d.ts +24 -0
  134. package/dist/runtime/build/vendor/lib/lib.es2020.intl.d.ts +474 -0
  135. package/dist/runtime/build/vendor/lib/lib.es2020.number.d.ts +28 -0
  136. package/dist/runtime/build/vendor/lib/lib.es2020.promise.d.ts +47 -0
  137. package/dist/runtime/build/vendor/lib/lib.es2020.sharedmemory.d.ts +99 -0
  138. package/dist/runtime/build/vendor/lib/lib.es2020.string.d.ts +44 -0
  139. package/dist/runtime/build/vendor/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  140. package/dist/runtime/build/vendor/lib/lib.es2021.d.ts +23 -0
  141. package/dist/runtime/build/vendor/lib/lib.es2021.full.d.ts +24 -0
  142. package/dist/runtime/build/vendor/lib/lib.es2021.intl.d.ts +166 -0
  143. package/dist/runtime/build/vendor/lib/lib.es2021.promise.d.ts +48 -0
  144. package/dist/runtime/build/vendor/lib/lib.es2021.string.d.ts +33 -0
  145. package/dist/runtime/build/vendor/lib/lib.es2021.weakref.d.ts +78 -0
  146. package/dist/runtime/build/vendor/lib/lib.es2022.array.d.ts +121 -0
  147. package/dist/runtime/build/vendor/lib/lib.es2022.d.ts +25 -0
  148. package/dist/runtime/build/vendor/lib/lib.es2022.error.d.ts +75 -0
  149. package/dist/runtime/build/vendor/lib/lib.es2022.full.d.ts +24 -0
  150. package/dist/runtime/build/vendor/lib/lib.es2022.intl.d.ts +121 -0
  151. package/dist/runtime/build/vendor/lib/lib.es2022.object.d.ts +26 -0
  152. package/dist/runtime/build/vendor/lib/lib.es2022.regexp.d.ts +39 -0
  153. package/dist/runtime/build/vendor/lib/lib.es2022.string.d.ts +25 -0
  154. package/dist/runtime/build/vendor/lib/lib.es2023.array.d.ts +924 -0
  155. package/dist/runtime/build/vendor/lib/lib.es2023.collection.d.ts +21 -0
  156. package/dist/runtime/build/vendor/lib/lib.es2023.d.ts +22 -0
  157. package/dist/runtime/build/vendor/lib/lib.es2023.full.d.ts +24 -0
  158. package/dist/runtime/build/vendor/lib/lib.es2023.intl.d.ts +56 -0
  159. package/dist/runtime/build/vendor/lib/lib.es2024.arraybuffer.d.ts +65 -0
  160. package/dist/runtime/build/vendor/lib/lib.es2024.collection.d.ts +29 -0
  161. package/dist/runtime/build/vendor/lib/lib.es2024.d.ts +26 -0
  162. package/dist/runtime/build/vendor/lib/lib.es2024.full.d.ts +24 -0
  163. package/dist/runtime/build/vendor/lib/lib.es2024.object.d.ts +29 -0
  164. package/dist/runtime/build/vendor/lib/lib.es2024.promise.d.ts +35 -0
  165. package/dist/runtime/build/vendor/lib/lib.es2024.regexp.d.ts +25 -0
  166. package/dist/runtime/build/vendor/lib/lib.es2024.sharedmemory.d.ts +68 -0
  167. package/dist/runtime/build/vendor/lib/lib.es2024.string.d.ts +29 -0
  168. package/dist/runtime/build/vendor/lib/lib.es5.d.ts +4585 -0
  169. package/dist/runtime/build/vendor/lib/lib.es6.d.ts +23 -0
  170. package/dist/runtime/build/vendor/lib/lib.esnext.array.d.ts +35 -0
  171. package/dist/runtime/build/vendor/lib/lib.esnext.collection.d.ts +96 -0
  172. package/dist/runtime/build/vendor/lib/lib.esnext.d.ts +25 -0
  173. package/dist/runtime/build/vendor/lib/lib.esnext.decorators.d.ts +28 -0
  174. package/dist/runtime/build/vendor/lib/lib.esnext.disposable.d.ts +193 -0
  175. package/dist/runtime/build/vendor/lib/lib.esnext.full.d.ts +24 -0
  176. package/dist/runtime/build/vendor/lib/lib.esnext.intl.d.ts +21 -0
  177. package/dist/runtime/build/vendor/lib/lib.esnext.iterator.d.ts +148 -0
  178. package/dist/runtime/build/vendor/node-types/assert/strict.d.ts +111 -0
  179. package/dist/runtime/build/vendor/node-types/assert.d.ts +1115 -0
  180. package/dist/runtime/build/vendor/node-types/async_hooks.d.ts +619 -0
  181. package/dist/runtime/build/vendor/node-types/buffer.buffer.d.ts +477 -0
  182. package/dist/runtime/build/vendor/node-types/buffer.d.ts +1941 -0
  183. package/dist/runtime/build/vendor/node-types/child_process.d.ts +1480 -0
  184. package/dist/runtime/build/vendor/node-types/cluster.d.ts +578 -0
  185. package/dist/runtime/build/vendor/node-types/compatibility/iterators.d.ts +21 -0
  186. package/dist/runtime/build/vendor/node-types/console.d.ts +453 -0
  187. package/dist/runtime/build/vendor/node-types/constants.d.ts +21 -0
  188. package/dist/runtime/build/vendor/node-types/crypto.d.ts +5484 -0
  189. package/dist/runtime/build/vendor/node-types/dgram.d.ts +715 -0
  190. package/dist/runtime/build/vendor/node-types/diagnostics_channel.d.ts +576 -0
  191. package/dist/runtime/build/vendor/node-types/dns/promises.d.ts +503 -0
  192. package/dist/runtime/build/vendor/node-types/dns.d.ts +923 -0
  193. package/dist/runtime/build/vendor/node-types/domain.d.ts +166 -0
  194. package/dist/runtime/build/vendor/node-types/events.d.ts +967 -0
  195. package/dist/runtime/build/vendor/node-types/fs/promises.d.ts +1354 -0
  196. package/dist/runtime/build/vendor/node-types/fs.d.ts +4777 -0
  197. package/dist/runtime/build/vendor/node-types/globals.d.ts +170 -0
  198. package/dist/runtime/build/vendor/node-types/globals.typedarray.d.ts +41 -0
  199. package/dist/runtime/build/vendor/node-types/http.d.ts +2246 -0
  200. package/dist/runtime/build/vendor/node-types/http2.d.ts +2882 -0
  201. package/dist/runtime/build/vendor/node-types/https.d.ts +585 -0
  202. package/dist/runtime/build/vendor/node-types/index.d.ts +101 -0
  203. package/dist/runtime/build/vendor/node-types/inspector.d.ts +323 -0
  204. package/dist/runtime/build/vendor/node-types/inspector.generated.d.ts +4406 -0
  205. package/dist/runtime/build/vendor/node-types/module.d.ts +844 -0
  206. package/dist/runtime/build/vendor/node-types/net.d.ts +1197 -0
  207. package/dist/runtime/build/vendor/node-types/os.d.ts +507 -0
  208. package/dist/runtime/build/vendor/node-types/package.json +140 -0
  209. package/dist/runtime/build/vendor/node-types/path.d.ts +200 -0
  210. package/dist/runtime/build/vendor/node-types/perf_hooks.d.ts +1054 -0
  211. package/dist/runtime/build/vendor/node-types/process.d.ts +2101 -0
  212. package/dist/runtime/build/vendor/node-types/punycode.d.ts +117 -0
  213. package/dist/runtime/build/vendor/node-types/querystring.d.ts +152 -0
  214. package/dist/runtime/build/vendor/node-types/readline/promises.d.ts +161 -0
  215. package/dist/runtime/build/vendor/node-types/readline.d.ts +600 -0
  216. package/dist/runtime/build/vendor/node-types/repl.d.ts +438 -0
  217. package/dist/runtime/build/vendor/node-types/sea.d.ts +162 -0
  218. package/dist/runtime/build/vendor/node-types/sqlite.d.ts +1182 -0
  219. package/dist/runtime/build/vendor/node-types/stream/consumers.d.ts +45 -0
  220. package/dist/runtime/build/vendor/node-types/stream/promises.d.ts +90 -0
  221. package/dist/runtime/build/vendor/node-types/stream/web.d.ts +596 -0
  222. package/dist/runtime/build/vendor/node-types/stream.d.ts +1707 -0
  223. package/dist/runtime/build/vendor/node-types/string_decoder.d.ts +67 -0
  224. package/dist/runtime/build/vendor/node-types/test.d.ts +2656 -0
  225. package/dist/runtime/build/vendor/node-types/timers/promises.d.ts +108 -0
  226. package/dist/runtime/build/vendor/node-types/timers.d.ts +285 -0
  227. package/dist/runtime/build/vendor/node-types/tls.d.ts +1314 -0
  228. package/dist/runtime/build/vendor/node-types/trace_events.d.ts +197 -0
  229. package/dist/runtime/build/vendor/node-types/ts5.6/buffer.buffer.d.ts +473 -0
  230. package/dist/runtime/build/vendor/node-types/ts5.6/compatibility/float16array.d.ts +71 -0
  231. package/dist/runtime/build/vendor/node-types/ts5.6/globals.typedarray.d.ts +36 -0
  232. package/dist/runtime/build/vendor/node-types/ts5.6/index.d.ts +103 -0
  233. package/dist/runtime/build/vendor/node-types/ts5.7/compatibility/float16array.d.ts +72 -0
  234. package/dist/runtime/build/vendor/node-types/ts5.7/index.d.ts +103 -0
  235. package/dist/runtime/build/vendor/node-types/tty.d.ts +209 -0
  236. package/dist/runtime/build/vendor/node-types/url.d.ts +1103 -0
  237. package/dist/runtime/build/vendor/node-types/util.d.ts +2379 -0
  238. package/dist/runtime/build/vendor/node-types/v8.d.ts +1010 -0
  239. package/dist/runtime/build/vendor/node-types/vm.d.ts +1160 -0
  240. package/dist/runtime/build/vendor/node-types/wasi.d.ts +202 -0
  241. package/dist/runtime/build/vendor/node-types/web-globals/abortcontroller.d.ts +34 -0
  242. package/dist/runtime/build/vendor/node-types/web-globals/crypto.d.ts +32 -0
  243. package/dist/runtime/build/vendor/node-types/web-globals/domexception.d.ts +68 -0
  244. package/dist/runtime/build/vendor/node-types/web-globals/events.d.ts +97 -0
  245. package/dist/runtime/build/vendor/node-types/web-globals/fetch.d.ts +62 -0
  246. package/dist/runtime/build/vendor/node-types/web-globals/navigator.d.ts +25 -0
  247. package/dist/runtime/build/vendor/node-types/web-globals/storage.d.ts +24 -0
  248. package/dist/runtime/build/vendor/node-types/web-globals/streams.d.ts +22 -0
  249. package/dist/runtime/build/vendor/node-types/worker_threads.d.ts +894 -0
  250. package/dist/runtime/build/vendor/node-types/zlib.d.ts +768 -0
  251. package/dist/runtime/build/vendor/node_modules/csstype/LICENSE +19 -0
  252. package/dist/runtime/build/vendor/node_modules/csstype/index.d.ts +22569 -0
  253. package/dist/runtime/build/vendor/node_modules/csstype/index.js.flow +6863 -0
  254. package/dist/runtime/build/vendor/node_modules/csstype/package.json +70 -0
  255. package/dist/runtime/build/vendor/node_modules/seroval/LICENSE +7 -0
  256. package/dist/runtime/build/vendor/node_modules/seroval/dist/cjs/development/index.cjs +4232 -0
  257. package/dist/runtime/build/vendor/node_modules/seroval/dist/cjs/production/index.cjs +3 -0
  258. package/dist/runtime/build/vendor/node_modules/seroval/dist/esm/development/index.mjs +4209 -0
  259. package/dist/runtime/build/vendor/node_modules/seroval/dist/esm/production/index.mjs +3 -0
  260. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/Serializer.d.ts +28 -0
  261. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/base-primitives.d.ts +28 -0
  262. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/compat.d.ts +15 -0
  263. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/constants.d.ts +105 -0
  264. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/constructors.d.ts +50 -0
  265. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/async-parser.d.ts +20 -0
  266. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/deserializer.d.ts +52 -0
  267. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/parser.d.ts +62 -0
  268. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/serializer.d.ts +103 -0
  269. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/sync-parser.d.ts +61 -0
  270. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/cross/index.d.ts +24 -0
  271. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/errors.d.ts +47 -0
  272. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/function-string.d.ts +3 -0
  273. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/keys.d.ts +4 -0
  274. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/literals.d.ts +10 -0
  275. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/node.d.ts +8 -0
  276. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/opaque-reference.d.ts +9 -0
  277. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/plugin.d.ts +52 -0
  278. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/reference.d.ts +6 -0
  279. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/sequence.d.ts +11 -0
  280. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/special-reference.d.ts +16 -0
  281. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/stream.d.ts +17 -0
  282. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/string.d.ts +4 -0
  283. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/symbols.d.ts +14 -0
  284. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/tree/index.d.ts +21 -0
  285. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/types.d.ts +233 -0
  286. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/error.d.ts +6 -0
  287. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/get-identifier.d.ts +2 -0
  288. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/get-object-flag.d.ts +3 -0
  289. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/is-valid-identifier.d.ts +2 -0
  290. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/promise-to-result.d.ts +2 -0
  291. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/typed-array.d.ts +6 -0
  292. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/valid-properties.d.ts +3 -0
  293. package/dist/runtime/build/vendor/node_modules/seroval/dist/types/index.d.ts +18 -0
  294. package/dist/runtime/build/vendor/node_modules/seroval/package.json +67 -0
  295. package/dist/runtime/build/vendor/node_modules/seroval/src/core/Serializer.ts +119 -0
  296. package/dist/runtime/build/vendor/node_modules/seroval/src/core/base-primitives.ts +537 -0
  297. package/dist/runtime/build/vendor/node_modules/seroval/src/core/compat.ts +23 -0
  298. package/dist/runtime/build/vendor/node_modules/seroval/src/core/constants.ts +202 -0
  299. package/dist/runtime/build/vendor/node_modules/seroval/src/core/constructors.ts +265 -0
  300. package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/async-parser.ts +666 -0
  301. package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/deserializer.ts +832 -0
  302. package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/parser.ts +335 -0
  303. package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/serializer.ts +1524 -0
  304. package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/sync-parser.ts +943 -0
  305. package/dist/runtime/build/vendor/node_modules/seroval/src/core/cross/index.ts +190 -0
  306. package/dist/runtime/build/vendor/node_modules/seroval/src/core/errors.ts +196 -0
  307. package/dist/runtime/build/vendor/node_modules/seroval/src/core/function-string.ts +31 -0
  308. package/dist/runtime/build/vendor/node_modules/seroval/src/core/keys.ts +17 -0
  309. package/dist/runtime/build/vendor/node_modules/seroval/src/core/literals.ts +43 -0
  310. package/dist/runtime/build/vendor/node_modules/seroval/src/core/node.ts +40 -0
  311. package/dist/runtime/build/vendor/node_modules/seroval/src/core/opaque-reference.ts +9 -0
  312. package/dist/runtime/build/vendor/node_modules/seroval/src/core/plugin.ts +105 -0
  313. package/dist/runtime/build/vendor/node_modules/seroval/src/core/reference.ts +66 -0
  314. package/dist/runtime/build/vendor/node_modules/seroval/src/core/sequence.ts +59 -0
  315. package/dist/runtime/build/vendor/node_modules/seroval/src/core/special-reference.ts +42 -0
  316. package/dist/runtime/build/vendor/node_modules/seroval/src/core/stream.ts +71 -0
  317. package/dist/runtime/build/vendor/node_modules/seroval/src/core/string.ts +86 -0
  318. package/dist/runtime/build/vendor/node_modules/seroval/src/core/symbols.ts +20 -0
  319. package/dist/runtime/build/vendor/node_modules/seroval/src/core/tree/index.ts +134 -0
  320. package/dist/runtime/build/vendor/node_modules/seroval/src/core/types.ts +377 -0
  321. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/error.ts +73 -0
  322. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/get-identifier.ts +18 -0
  323. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/get-object-flag.ts +14 -0
  324. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/is-valid-identifier.ts +12 -0
  325. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/promise-to-result.ts +9 -0
  326. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/typed-array.ts +56 -0
  327. package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/valid-properties.ts +34 -0
  328. package/dist/runtime/build/vendor/node_modules/seroval/src/index.ts +36 -0
  329. package/dist/runtime/build/vendor/node_modules/seroval-plugins/LICENSE +7 -0
  330. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/cjs/development/web.cjs +826 -0
  331. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/cjs/production/web.cjs +1 -0
  332. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/esm/development/web.mjs +803 -0
  333. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/esm/production/web.mjs +1 -0
  334. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/abort-signal.d.ts +3 -0
  335. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/blob.d.ts +3 -0
  336. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/custom-event.d.ts +3 -0
  337. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/dom-exception.d.ts +3 -0
  338. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/event.d.ts +3 -0
  339. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/file.d.ts +3 -0
  340. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/form-data.d.ts +3 -0
  341. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/headers.d.ts +3 -0
  342. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/image-data.d.ts +3 -0
  343. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/index.d.ts +15 -0
  344. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/readable-stream.d.ts +3 -0
  345. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/request.d.ts +3 -0
  346. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/response.d.ts +3 -0
  347. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/url-search-params.d.ts +3 -0
  348. package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/url.d.ts +3 -0
  349. package/dist/runtime/build/vendor/node_modules/seroval-plugins/package.json +70 -0
  350. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/abort-signal.ts +131 -0
  351. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/blob.ts +41 -0
  352. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/custom-event.ts +66 -0
  353. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/dom-exception.ts +57 -0
  354. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/event.ts +62 -0
  355. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/file.ts +50 -0
  356. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/form-data.ts +105 -0
  357. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/headers.ts +49 -0
  358. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/image-data.ts +74 -0
  359. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/index.ts +14 -0
  360. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/readable-stream.ts +148 -0
  361. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/request.ts +82 -0
  362. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/response.ts +65 -0
  363. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/url-search-params.ts +40 -0
  364. package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/url.ts +37 -0
  365. package/dist/runtime/build/vendor/node_modules/solid-js/dist/server.cjs +824 -0
  366. package/dist/runtime/build/vendor/node_modules/solid-js/dist/server.js +770 -0
  367. package/dist/runtime/build/vendor/node_modules/solid-js/dist/solid.cjs +1808 -0
  368. package/dist/runtime/build/vendor/node_modules/solid-js/dist/solid.js +1753 -0
  369. package/dist/runtime/build/vendor/node_modules/solid-js/jsx-runtime.d.ts +1 -0
  370. package/dist/runtime/build/vendor/node_modules/solid-js/package.json +243 -0
  371. package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/server.cjs +133 -0
  372. package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/server.js +121 -0
  373. package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/store.cjs +463 -0
  374. package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/store.js +454 -0
  375. package/dist/runtime/build/vendor/node_modules/solid-js/store/package.json +46 -0
  376. package/dist/runtime/build/vendor/node_modules/solid-js/store/types/index.d.ts +12 -0
  377. package/dist/runtime/build/vendor/node_modules/solid-js/store/types/modifiers.d.ts +6 -0
  378. package/dist/runtime/build/vendor/node_modules/solid-js/store/types/mutable.d.ts +5 -0
  379. package/dist/runtime/build/vendor/node_modules/solid-js/store/types/server.d.ts +17 -0
  380. package/dist/runtime/build/vendor/node_modules/solid-js/store/types/store.d.ts +108 -0
  381. package/dist/runtime/build/vendor/node_modules/solid-js/types/index.d.ts +23 -0
  382. package/dist/runtime/build/vendor/node_modules/solid-js/types/jsx.d.ts +4253 -0
  383. package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/array.d.ts +44 -0
  384. package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/observable.d.ts +36 -0
  385. package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/scheduler.d.ts +10 -0
  386. package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/signal.d.ts +581 -0
  387. package/dist/runtime/build/vendor/node_modules/solid-js/types/render/Suspense.d.ts +26 -0
  388. package/dist/runtime/build/vendor/node_modules/solid-js/types/render/component.d.ts +111 -0
  389. package/dist/runtime/build/vendor/node_modules/solid-js/types/render/flow.d.ts +118 -0
  390. package/dist/runtime/build/vendor/node_modules/solid-js/types/render/hydration.d.ts +24 -0
  391. package/dist/runtime/build/vendor/node_modules/solid-js/types/render/index.d.ts +4 -0
  392. package/dist/runtime/build/vendor/node_modules/solid-js/types/server/index.d.ts +3 -0
  393. package/dist/runtime/build/vendor/node_modules/solid-js/types/server/reactive.d.ts +98 -0
  394. package/dist/runtime/build/vendor/node_modules/solid-js/types/server/rendering.d.ts +160 -0
  395. package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/server.cjs +900 -0
  396. package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/server.js +786 -0
  397. package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/web.cjs +884 -0
  398. package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/web.js +772 -0
  399. package/dist/runtime/build/vendor/node_modules/solid-js/web/package.json +46 -0
  400. package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/dist/storage.cjs +12 -0
  401. package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/dist/storage.js +10 -0
  402. package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/package.json +15 -0
  403. package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/types/index.d.ts +2 -0
  404. package/dist/runtime/build/vendor/node_modules/solid-js/web/types/client.d.ts +93 -0
  405. package/dist/runtime/build/vendor/node_modules/solid-js/web/types/core.d.ts +2 -0
  406. package/dist/runtime/build/vendor/node_modules/solid-js/web/types/index.d.ts +50 -0
  407. package/dist/runtime/build/vendor/node_modules/solid-js/web/types/jsx.d.ts +1 -0
  408. package/dist/runtime/build/vendor/node_modules/solid-js/web/types/server-mock.d.ts +65 -0
  409. package/dist/runtime/build/vendor/node_modules/solid-js/web/types/server.d.ts +187 -0
  410. package/dist/runtime/build/worker.mjs +293415 -0
  411. package/dist/runtime/catalog/sdk-natives.json +655 -0
  412. package/dist/runtime/cli/iota-ext.mjs +1028 -0
  413. package/dist/runtime/client-host/entry.d.ts +10 -0
  414. package/dist/runtime/client-host/entry.js +124 -0
  415. package/dist/runtime/client-host/hooks.d.ts +43 -0
  416. package/dist/runtime/client-host/hooks.js +94 -0
  417. package/dist/runtime/client-host/index.d.ts +9 -0
  418. package/dist/runtime/client-host/index.js +9 -0
  419. package/dist/runtime/client-host/islands.d.ts +44 -0
  420. package/dist/runtime/client-host/islands.js +165 -0
  421. package/dist/runtime/client-host/kit.d.ts +10 -0
  422. package/dist/runtime/client-host/kit.js +37 -0
  423. package/dist/runtime/client-host/page.d.ts +53 -0
  424. package/dist/runtime/client-host/page.js +217 -0
  425. package/dist/runtime/client-host/params.d.ts +8 -0
  426. package/dist/runtime/client-host/params.js +36 -0
  427. package/dist/runtime/client-host/protocol.d.ts +78 -0
  428. package/dist/runtime/client-host/protocol.js +26 -0
  429. package/dist/runtime/client-host/shared.d.ts +12 -0
  430. package/dist/runtime/client-host/shared.js +49 -0
  431. package/dist/runtime/client-host/shell.d.ts +88 -0
  432. package/dist/runtime/client-host/shell.js +195 -0
  433. package/dist/runtime/client-host/slots.d.ts +54 -0
  434. package/dist/runtime/client-host/slots.js +90 -0
  435. package/dist/runtime/client-host/styles.d.ts +7 -0
  436. package/dist/runtime/client-host/styles.js +61 -0
  437. package/dist/runtime/client-host/transport.d.ts +45 -0
  438. package/dist/runtime/client-host/transport.js +115 -0
  439. package/dist/runtime/client.d.ts +226 -0
  440. package/dist/runtime/client.js +121 -0
  441. package/dist/runtime/contracts.d.ts +204 -0
  442. package/dist/runtime/contracts.js +195 -0
  443. package/dist/runtime/docs/authoring.md +1609 -0
  444. package/dist/runtime/docs/example/docs/en/admin/limits.md +10 -0
  445. package/dist/runtime/docs/example/docs/en/getting-started.md +13 -0
  446. package/dist/runtime/docs/example/docs/en/points.md +9 -0
  447. package/dist/runtime/docs/example/docs/ru/getting-started.md +12 -0
  448. package/dist/runtime/docs/example/package.json +27 -0
  449. package/dist/runtime/docs/example/src/ClientScreen.tsx +10 -0
  450. package/dist/runtime/docs/example/src/RedemptionScreen.tsx +7 -0
  451. package/dist/runtime/docs/example/src/RewardsScreen.module.css +13 -0
  452. package/dist/runtime/docs/example/src/RewardsScreen.tsx +51 -0
  453. package/dist/runtime/docs/example/src/client.tsx +40 -0
  454. package/dist/runtime/docs/example/src/contracts.ts +132 -0
  455. package/dist/runtime/docs/example/src/css-modules.d.ts +5 -0
  456. package/dist/runtime/docs/example/src/server.test.ts +156 -0
  457. package/dist/runtime/docs/example/src/server.ts +188 -0
  458. package/dist/runtime/docs/example/tsconfig.json +16 -0
  459. package/dist/runtime/entity.d.ts +237 -0
  460. package/dist/runtime/entity.js +201 -0
  461. package/dist/runtime/fakes.d.ts +80 -0
  462. package/dist/runtime/fakes.js +88 -0
  463. package/dist/runtime/fixtures.d.ts +34 -0
  464. package/dist/runtime/fixtures.js +60 -0
  465. package/dist/runtime/help.d.ts +22 -0
  466. package/dist/runtime/help.js +51 -0
  467. package/dist/runtime/host/context.mjs +392 -0
  468. package/dist/runtime/host/errors.mjs +64 -0
  469. package/dist/runtime/host/loader.mjs +28 -0
  470. package/dist/runtime/host/protocol.mjs +4 -0
  471. package/dist/runtime/host/register.mjs +8 -0
  472. package/dist/runtime/host/sdk/assert.mjs +153 -0
  473. package/dist/runtime/host/sdk/client-host/hooks.mjs +86 -0
  474. package/dist/runtime/host/sdk/client-host/protocol.mjs +30 -0
  475. package/dist/runtime/host/sdk/client-host/slots.mjs +82 -0
  476. package/dist/runtime/host/sdk/client-host/styles.mjs +45 -0
  477. package/dist/runtime/host/sdk/client-host/transport.mjs +102 -0
  478. package/dist/runtime/host/sdk/client.mjs +115 -0
  479. package/dist/runtime/host/sdk/contracts.mjs +185 -0
  480. package/dist/runtime/host/sdk/entity.mjs +183 -0
  481. package/dist/runtime/host/sdk/fakes.mjs +88 -0
  482. package/dist/runtime/host/sdk/fixtures.mjs +56 -0
  483. package/dist/runtime/host/sdk/help.mjs +37 -0
  484. package/dist/runtime/host/sdk/index.mjs +83 -0
  485. package/dist/runtime/host/sdk/kit.mjs +11 -0
  486. package/dist/runtime/host/sdk/manifest.mjs +276 -0
  487. package/dist/runtime/host/sdk/model.mjs +4 -0
  488. package/dist/runtime/host/sdk/resource.mjs +34 -0
  489. package/dist/runtime/host/sdk/schema.mjs +75 -0
  490. package/dist/runtime/host/sdk/server.mjs +43 -0
  491. package/dist/runtime/host/sdk/testhost.mjs +992 -0
  492. package/dist/runtime/host/sdk/testing.mjs +21 -0
  493. package/dist/runtime/host/sdk/wire.mjs +207 -0
  494. package/dist/runtime/host/worker.mjs +252 -0
  495. package/dist/runtime/index.d.ts +10 -0
  496. package/dist/runtime/index.js +5 -0
  497. package/dist/runtime/kit.d.ts +5 -0
  498. package/dist/runtime/kit.js +14 -0
  499. package/dist/runtime/manifest.d.ts +17 -0
  500. package/dist/runtime/manifest.js +323 -0
  501. package/dist/runtime/model.d.ts +224 -0
  502. package/dist/runtime/model.js +3 -0
  503. package/dist/runtime/resource.d.ts +31 -0
  504. package/dist/runtime/resource.js +35 -0
  505. package/dist/runtime/schema.d.ts +97 -0
  506. package/dist/runtime/schema.js +73 -0
  507. package/dist/runtime/server.d.ts +445 -0
  508. package/dist/runtime/server.js +41 -0
  509. package/dist/runtime/testhost.d.ts +216 -0
  510. package/dist/runtime/testhost.js +1146 -0
  511. package/dist/runtime/testing.d.ts +10 -0
  512. package/dist/runtime/testing.js +7 -0
  513. package/dist/runtime/wire.d.ts +26 -0
  514. package/dist/runtime/wire.js +236 -0
  515. package/dist/sdk-identity.cjs +3 -3
  516. package/dist/sdk-identity.js +3 -3
  517. package/dist/sdk-identity.json +2 -2
  518. package/dist/solid-ui/embedded-css.d.ts +2 -0
  519. package/dist/solid-ui/embedded-css.js +1 -0
  520. package/dist/solid-ui/embedded.css +2 -0
  521. package/dist/testing/components.d.ts +73 -0
  522. package/dist/testing/components.js +96 -0
  523. package/dist/testing/htmx.d.ts +44 -0
  524. package/dist/testing/htmx.js +284 -0
  525. package/dist/testing/index.d.ts +4 -41
  526. package/dist/testing/index.js +3 -206
  527. package/dist/testing/scenarios.d.ts +83 -0
  528. package/dist/testing/scenarios.js +74 -0
  529. package/dist/testing/wait.d.ts +7 -0
  530. package/dist/testing/wait.js +19 -0
  531. package/package.json +33 -2
  532. package/dist/lens/TablePanel-C09tzJOL.js +0 -980
  533. package/dist/lens/index-DcVtZneD.js +0 -18473
  534. package/dist/lens/runtime/recovery.d.ts +0 -26
  535. package/dist/lens/runtime/recovery.d.ts.map +0 -1
@@ -0,0 +1,188 @@
1
+ // Server graph: handlers bound to contracts, plus guards, subscriptions, schedules, endpoints and templates.
2
+ import { isoDateTime, ref, t, validation, type ISODateTime } from "@iota-uz/sdk/runtime"
3
+ import {
4
+ endpoint, guard, implement, recipient, schedule, subscribe, templates, writeRule,
5
+ } from "@iota-uz/sdk/runtime/server"
6
+ import * as core from "@iota-kit/core"
7
+ import * as crm from "@iota-kit/crm"
8
+ import * as c from "./contracts"
9
+
10
+ // ---- operation: reads and writes in the caller's transaction
11
+ export const adjustPoints = implement(c.AdjustPoints, async (tx, input) => {
12
+ const current = (await tx.get(c.ClientLoyalty, input.client))?.points ?? 0
13
+ const next = current + input.delta
14
+ if (next < 0) throw c.NotEnoughPoints.of({ have: current, need: -input.delta })
15
+ const row = await tx.put(c.ClientLoyalty, input.client, { points: next })
16
+ await tx.emit(c.PointsChanged, { subject: input.client, payload: { points: next, delta: input.delta } })
17
+ return { points: row.points }
18
+ })
19
+
20
+ // Additive checks run in the same transaction whoever implements the operation.
21
+ export const deltaLimit = guard("acme.loyalty.deltaLimit", c.AdjustPoints, async (_ctx, input) => {
22
+ if (Math.abs(input.delta) > 10_000) throw validation(c.DeltaTooLarge.at(["delta"], { max: 10_000 }))
23
+ })
24
+
25
+ // ---- atomic command
26
+ export const createReward = implement(c.CreateReward, async (tx, input) => {
27
+ if (input.cost <= 0) throw validation(c.CostMustBePositive.at(["cost"], { min: 1 }))
28
+ const row = await tx.insert(c.Reward, { name: input.name.trim(), cost: input.cost })
29
+ return { reward: row.ref }
30
+ })
31
+
32
+ // A write rule guards the entity itself, whatever code path writes it.
33
+ export const rewardRule = writeRule("acme.loyalty.rewardRule", c.Reward, async (_ctx, change) => {
34
+ if (change.proposed !== null && change.proposed.cost > 1_000_000) throw validation(c.CostMustBePositive.at(["cost"], { min: 1 }))
35
+ })
36
+
37
+ // ---- ordinary command: outside calls happen between transactions, never inside one
38
+ export const redeem = implement(c.Redeem, async (ctx, input) => {
39
+ const reward = await ctx.query.get(c.Reward, input.reward)
40
+ if (reward === null || !reward.active) throw c.RewardUnavailable.of({ reward: input.reward.key })
41
+ const stock = await fetch(`https://api.partner.example/stock/${encodeURIComponent(reward.name)}`, {
42
+ headers: { authorization: `Bearer ${await ctx.secrets.get("PARTNER_TOKEN")}` },
43
+ })
44
+ if (!stock.ok) throw c.RewardUnavailable.of({ reward: input.reward.key })
45
+
46
+ const redemption = await ctx.transaction(async (tx) => {
47
+ await tx.call(c.AdjustPoints, { client: input.client, delta: -reward.cost })
48
+ const row = await tx.insert(c.Redemption, {
49
+ client: input.client, reward: input.reward, cost: reward.cost, requestedBy: ref(core.User, ctx.user.userId),
50
+ })
51
+ // Outside subscriptions and workflows a start needs a key: the same key never starts a second instance.
52
+ await tx.start(c.Approval, { redemption: row.ref }, { key: `approval:${row.key}` })
53
+ return row
54
+ })
55
+ return { redemption: redemption.ref }
56
+ })
57
+
58
+ export const catalog = implement(c.Catalog, async (q, input) => {
59
+ const rewards = await q.find(c.Reward, {
60
+ where: input.onlyActive === true ? { active: true } : {},
61
+ orderBy: [{ field: "cost" }, { field: "name" }],
62
+ })
63
+ return rewards.map((r) => ({ reward: r.ref, name: r.name, cost: r.cost, active: r.active }))
64
+ })
65
+
66
+ // ---- events: each subscription runs in its own transaction after the publishing one commits
67
+ export const onPointsChanged = subscribe("acme.loyalty.onPointsChanged", c.PointsChanged, async (tx, event) => {
68
+ const tier = event.payload.points >= 1000 ? "gold" : event.payload.points >= 300 ? "silver" : "standard"
69
+ await tx.put(c.ClientLoyalty, event.subject, { tier })
70
+ })
71
+
72
+ // ---- workflows: durable, replayed from a journal; every primitive takes a stable name
73
+ export const approval = implement(c.Approval, async (wf, input) => {
74
+ const verdict = await wf.task("approve", {
75
+ subject: input.redemption,
76
+ assignee: wf.user,
77
+ decision: t.object({ approved: t.bool() }),
78
+ timeout: "3d",
79
+ })
80
+ const approved = verdict.outcome === "decided" && verdict.decision.approved
81
+
82
+ // An external effect: may run again after a crash, so it gets a provider idempotency key.
83
+ const voucher = approved
84
+ ? await wf.step("voucher", async ({ idempotencyKey }) => {
85
+ const res = await fetch("https://api.partner.example/vouchers", {
86
+ method: "POST",
87
+ headers: { "content-type": "application/json", "idempotency-key": idempotencyKey },
88
+ body: JSON.stringify({ redemption: input.redemption.key }),
89
+ })
90
+ const body = (await res.json()) as { code: string }
91
+ return { code: body.code }
92
+ })
93
+ : null
94
+
95
+ // Data effects commit together with their journal entry. The result must be JSON.
96
+ await wf.transaction("settle", async (tx) => {
97
+ const row = await tx.get(c.Redemption, input.redemption)
98
+ if (row === null) return { settled: false }
99
+ const reward = await tx.get(c.Reward, row.reward)
100
+ await tx.update(c.Redemption, row.ref, { status: approved ? "approved" : "rejected" })
101
+ if (!approved) await tx.call(c.AdjustPoints, { client: row.client, delta: row.cost })
102
+ await tx.notify(c.RedemptionResult, {
103
+ subject: row.ref,
104
+ payload: { reward: reward?.name ?? "", approved },
105
+ to: [recipient.record(row.client)],
106
+ channels: ["sms", "email"],
107
+ })
108
+ return { settled: true }
109
+ })
110
+ return { approved, voucher: voucher?.code ?? null }
111
+ })
112
+
113
+ export const reminder = implement(c.Reminder, async (wf, input) => {
114
+ await wf.sleep("wait", "30d")
115
+ const answer = await wf.waitFor("optOut", c.Reminder.signals.optOut, { timeout: "1d" })
116
+ if (answer.outcome === "received") return { reminded: false }
117
+ await wf.transaction("remind", async (tx) => {
118
+ const points = (await tx.get(c.ClientLoyalty, input.client))?.points ?? 0
119
+ await tx.notify(c.PointsReminder, {
120
+ subject: input.client,
121
+ payload: { points },
122
+ to: [recipient.record(input.client)],
123
+ channels: ["sms"],
124
+ })
125
+ return { points }
126
+ })
127
+ return { reminded: true }
128
+ })
129
+
130
+ // ---- replacing a native command
131
+ // crm.SaveClient is the published intent behind the client forms; its Go default calls the operation crm.UpsertClient
132
+ // in one transaction. This implementation is only a candidate: it runs when an administrator binds it to the command
133
+ // (and the Go default returns when the binding is removed). It keeps the invariants by writing through the same
134
+ // operation, and every guard on that operation (ours included) still applies.
135
+ export const saveClient = implement(crm.SaveClient, async (ctx, input) =>
136
+ ctx.transaction(async (tx) => {
137
+ const saved = await tx.call(crm.UpsertClient, input)
138
+ if (saved.created) await tx.call(c.AdjustPoints, { client: saved.client, delta: 50 })
139
+ return saved
140
+ }),
141
+ )
142
+
143
+ // ---- notifications: contact data of a record, and per-channel templates
144
+ export const clientConsent = implement(c.ClientConsent, async (q, request) => {
145
+ const loyalty = await q.get(c.ClientLoyalty, request.recipient.ref)
146
+ if (request.channel === "sms" && loyalty?.smsOptOut === true) return { allow: false, reason: "sms_opt_out" }
147
+ return { allow: true }
148
+ })
149
+
150
+ export const clientContacts = implement(c.ClientContacts, async (q, record) => {
151
+ const client = await q.get(crm.Client, record)
152
+ if (client === null) return {}
153
+ return {
154
+ ...(client.phone === null ? {} : { sms: [client.phone] }),
155
+ ...(client.email === null ? {} : { email: [client.email] }),
156
+ }
157
+ })
158
+
159
+ export const resultTemplates = templates(c.RedemptionResult, {
160
+ sms: ({ payload }) => (payload.approved ? `Your reward "${payload.reward}" is approved.` : `Your reward "${payload.reward}" was declined.`),
161
+ email: ({ payload, locale }) => ({
162
+ subject: payload.approved ? "Reward approved" : "Reward declined",
163
+ html: `<p lang="${locale}">${payload.reward}</p>`,
164
+ text: payload.reward,
165
+ }),
166
+ inApp: ({ payload }) => ({ title: "Redemption", body: payload.approved ? `${payload.reward}: approved` : `${payload.reward}: declined` }),
167
+ })
168
+
169
+ export const reminderTemplates = templates(c.PointsReminder, {
170
+ sms: ({ payload }) => `You have ${payload.points} loyalty points.`,
171
+ })
172
+
173
+ // ---- triggers: a schedule runs as its owner-user, an endpoint as the caller (or the owner when public)
174
+ export const closeStale = schedule("acme.loyalty.closeStale", { cron: "0 3 * * *", timezone: "Asia/Tashkent" }, async (ctx) => {
175
+ const cutoff: ISODateTime = isoDateTime(new Date(Date.parse(ctx.slot) - 7 * 86_400_000).toISOString())
176
+ await ctx.transaction(async (tx) => {
177
+ const stale = await tx.find(c.Redemption, { where: { status: "pending", createdAt: { lt: cutoff } } })
178
+ for (const row of stale) {
179
+ await tx.update(c.Redemption, row.ref, { status: "rejected" })
180
+ await tx.call(c.AdjustPoints, { client: row.client, delta: row.cost })
181
+ }
182
+ })
183
+ })
184
+
185
+ export const publicCatalog = endpoint("acme.loyalty.publicCatalog", { method: "GET", path: "/catalog", public: true }, async (ctx) => {
186
+ const rewards = await ctx.query.find(c.Reward, { where: { active: true }, orderBy: [{ field: "name" }] })
187
+ return { status: 200, body: rewards.map((r) => ({ name: r.name, cost: r.cost })) }
188
+ })
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "skipLibCheck": true,
9
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
10
+ "types": ["node"],
11
+ "paths": { "@iota-kit/*": ["./.iota/kit/*"] },
12
+ "jsx": "preserve",
13
+ "jsxImportSource": "solid-js"
14
+ },
15
+ "include": ["src"]
16
+ }
@@ -0,0 +1,237 @@
1
+ import type { FilterJSON, ISODateTime, Json, JsonNotNull, Label, TypeKind } from './model.ts';
2
+ import { type Contract } from './resource.ts';
3
+ import { type DecimalOptions, type EntityLike, type Infer, type JsonConstraint, type Presence, type Ref, type SchemaLike, type StringOptions, type UserEntity, type UserRef } from './schema.ts';
4
+ import type { Permission } from './contracts.ts';
5
+ export interface FieldSpec {
6
+ readonly unique: boolean;
7
+ readonly index: boolean;
8
+ readonly default?: Json;
9
+ readonly renamedFrom: readonly string[];
10
+ readonly label?: Label;
11
+ }
12
+ /**
13
+ * A typed column. Reading a row yields `T` (`T | null` for nullable columns).
14
+ * - `.optional()` is a nullable column that may be omitted on insert: `T | null` on read, `T | null | undefined` on write.
15
+ * - `.default(x)` may be omitted on insert; it reads `T` only while the column is not nullable.
16
+ */
17
+ export interface Field<T = unknown, K extends Presence = 'req', N extends TypeKind = TypeKind> extends SchemaLike<T, K, N> {
18
+ readonly spec: FieldSpec;
19
+ optional(): Field<T | null, 'opt', N>;
20
+ nullable(): Field<T | null, K, N>;
21
+ unique(): Field<T, K, N>;
22
+ index(): Field<T, K, N>;
23
+ /** Validated against the column type; a nullable column may default to `null`. */
24
+ default(value: T): Field<T, 'def', N>;
25
+ /** Previous field keys; the physical column follows the field across renames. */
26
+ renamedFrom(...keys: string[]): Field<T, K, N>;
27
+ label(label: Label): Field<T, K, N>;
28
+ }
29
+ export type AnyField = Field<unknown, Presence, TypeKind>;
30
+ export type FieldShape = Readonly<Record<string, AnyField>>;
31
+ export declare const field: {
32
+ readonly text: (o?: StringOptions) => Field<string, "req", "string">;
33
+ readonly string: (o?: StringOptions) => Field<string, "req", "string">;
34
+ readonly int: () => Field<number, "req", "int">;
35
+ readonly int64: () => Field<import("./model.ts").Int64, "req", "int64">;
36
+ readonly decimal: (o: DecimalOptions) => Field<import("./model.ts").Decimal, "req", "decimal">;
37
+ readonly bool: () => Field<boolean, "req", "bool">;
38
+ readonly date: () => Field<import("./model.ts").ISODate, "req", "date">;
39
+ readonly datetime: () => Field<ISODateTime, "req", "datetime">;
40
+ readonly uuid: () => Field<string, "req", "uuid">;
41
+ readonly enum: <const V extends readonly [string, ...string[]]>(values: V) => Field<V[number], "req", "enum">;
42
+ readonly json: <T extends JsonConstraint<T> = JsonNotNull>() => Field<T, "req", "json">;
43
+ readonly ref: <E extends EntityLike>(entity: E) => Field<Ref<E>, "req", "ref">;
44
+ };
45
+ export interface BoundMeta {
46
+ readonly owner: string;
47
+ readonly key: string;
48
+ }
49
+ export type BoundFields<F extends FieldShape> = {
50
+ readonly [K in keyof F]: F[K] & BoundMeta;
51
+ };
52
+ export type EntityOrigin = 'own' | 'native';
53
+ export type KeyType = 'int64' | 'uuid' | 'string';
54
+ export interface Entity<Id extends string = string, F extends FieldShape = FieldShape, O extends EntityOrigin = EntityOrigin> extends Contract<Id, 'entity'> {
55
+ readonly entityKind: O;
56
+ readonly keyType: KeyType;
57
+ readonly fields: BoundFields<F>;
58
+ }
59
+ export type OwnEntity = Entity<string, FieldShape, 'own'>;
60
+ export type AnyEntity = Entity<string, FieldShape, EntityOrigin>;
61
+ export interface Overlay<Id extends string = string, B extends AnyEntity = AnyEntity, F extends FieldShape = FieldShape> extends Contract<Id, 'overlay'> {
62
+ readonly base: B;
63
+ readonly fields: BoundFields<F>;
64
+ }
65
+ export type AnyOverlay = Overlay<string, AnyEntity, FieldShape>;
66
+ type Simplify<T> = {
67
+ [K in keyof T]: T[K];
68
+ };
69
+ /** The value of a field as read from a row: `T`, or `T | null` for optional/nullable columns. */
70
+ export type FieldValue<S> = S extends SchemaLike<infer V, Presence, TypeKind> ? V : never;
71
+ export type Fields<E> = E extends {
72
+ readonly fields: infer G extends FieldShape;
73
+ } ? G : never;
74
+ export type FieldValues<E> = {
75
+ readonly [K in keyof Fields<E>]: FieldValue<Fields<E>[K]>;
76
+ };
77
+ /**
78
+ * An entity row as returned by the data layer: system columns plus every declared field (optional ones read `null`).
79
+ * `ref` is the typed pointer to this record, so a handler never has to re-state the entity (`ref(Entity, row.key)`).
80
+ * It is attached by the runtime context layer to every row `get`/`find`/`insert`/`update` returns.
81
+ */
82
+ export type Row<E extends EntityLike> = Simplify<{
83
+ readonly key: string;
84
+ /** Typed pointer to this record. */
85
+ readonly ref: Ref<E>;
86
+ readonly createdAt: ISODateTime;
87
+ readonly updatedAt: ISODateTime;
88
+ /** Incremented on every write; pass it to `tx.update(..., { rowVersion })` for an optimistic check. */
89
+ readonly rowVersion: number;
90
+ } & FieldValues<E>>;
91
+ /** An overlay row, keyed by the base record's key. */
92
+ export type OverlayRow<O> = Simplify<{
93
+ readonly baseKey: string;
94
+ } & FieldValues<O>>;
95
+ export type RecordOf<E extends AnyEntity | AnyOverlay> = E extends AnyOverlay ? OverlayRow<E> : E extends AnyEntity ? Row<E> : never;
96
+ /** Keys the data layer owns on every row; declaring a field with one of these keys is an error. */
97
+ export declare const RESERVED_KEYS: ReadonlySet<string>;
98
+ type RequiredInsertKeys<F extends FieldShape> = {
99
+ [K in keyof F]: F[K] extends SchemaLike<unknown, 'req'> ? K : never;
100
+ }[keyof F];
101
+ type OptionalInsertKeys<F extends FieldShape> = Exclude<keyof F, RequiredInsertKeys<F>>;
102
+ /** Values accepted by `tx.insert`: fields that are optional or defaulted may be omitted. */
103
+ export type InsertOf<E> = Simplify<{
104
+ [K in RequiredInsertKeys<Fields<E>>]: FieldValue<Fields<E>[K]>;
105
+ } & {
106
+ [K in OptionalInsertKeys<Fields<E>>]?: FieldValue<Fields<E>[K]>;
107
+ }>;
108
+ export type PatchOf<E> = {
109
+ [K in keyof Fields<E>]?: FieldValue<Fields<E>[K]>;
110
+ };
111
+ type IsUnion<T, U = T> = T extends unknown ? ([U] extends [T] ? false : true) : never;
112
+ /** Compile-time message type: an argument that cannot satisfy it fails with the message in the error text. */
113
+ export type Hint<M extends string> = {
114
+ readonly [K in M]: never;
115
+ };
116
+ /**
117
+ * `Ref<E>` for a single entity. A union of entities (`cond ? A : B`) is rejected: the ref could belong to either
118
+ * branch, so the call would type-check for the wrong record.
119
+ */
120
+ export type RefTo<E extends EntityLike> = [IsUnion<E>] extends [false] ? Ref<E> : Hint<'entity is a union: narrow it to one entity before using a ref'>;
121
+ export interface UserPlaceholder {
122
+ readonly $: 'user';
123
+ }
124
+ /** `$.user` is the current subject's user ref inside access rules and filters; it matches only `core.user` ref fields. */
125
+ export declare const $: {
126
+ readonly user: UserPlaceholder;
127
+ };
128
+ type Depth = readonly unknown[];
129
+ type Leaf<P extends string, V, N extends string> = readonly [path: P, value: V, kind: N];
130
+ /** System columns every row has. `key` supports equality only; the timestamps behave like datetime fields. */
131
+ type SystemLeaves = Leaf<'key', string, 'key'> | Leaf<'createdAt', ISODateTime, 'datetime'> | Leaf<'updatedAt', ISODateTime, 'datetime'>;
132
+ type FieldLeaves<F extends FieldShape> = {
133
+ [K in keyof F & string]: F[K] extends SchemaLike<infer V, Presence, infer N> ? Leaf<K, V, N> : never;
134
+ }[keyof F & string];
135
+ type Prefixed<K extends string, L> = L extends readonly [infer P extends string, infer V, infer N extends string] ? Leaf<`${K}.${P}`, V, N> : never;
136
+ type PathLeaves<F extends FieldShape, D extends Depth = readonly []> = FieldLeaves<F> | SystemLeaves | {
137
+ [K in keyof F & string]: NonNullable<Infer<F[K]>> extends Ref<infer E> ? D['length'] extends 2 ? never : Fields<E> extends infer G extends FieldShape ? Prefixed<K, PathLeaves<G, readonly [...D, unknown]>> : never : never;
138
+ }[keyof F & string];
139
+ /** Kinds with a total order the database can sort and range-filter by. */
140
+ type Orderable = 'int' | 'int64' | 'decimal' | 'date' | 'datetime' | 'string';
141
+ type PathOfKind<L, Pred extends string> = L extends readonly [infer P extends string, unknown, infer N extends string] ? [N] extends [Pred] ? P : never : never;
142
+ /** Field keys and system columns, plus dotted paths through ref fields ("holder.owner"); `json` fields are not filterable. */
143
+ export type PathOf<E> = PathOfKind<PathLeaves<Fields<E>>, Exclude<TypeKind, 'json'> | 'key'>;
144
+ /** Paths a result can be ordered by: orderable field kinds and `createdAt` / `updatedAt` (not `key`, uuid, enum, bool, ref). */
145
+ export type OrderPathOf<E> = PathOfKind<PathLeaves<Fields<E>>, Orderable>;
146
+ type Val<V> = NonNullable<V> extends UserRef ? V | UserPlaceholder : V;
147
+ /** Name of a wire kind in the hints below (`key` and `ref` read better as they are). */
148
+ type KindName<N extends string> = N extends 'string' ? 'string' : N;
149
+ /**
150
+ * The conditions a field of wire kind `N` supports: ranges only on orderable kinds, `like` only on strings.
151
+ * An operator the kind lacks is typed as a `Hint`, so using it names the reason in the error text.
152
+ */
153
+ export type Ops<V, N extends string = string> = N extends 'key' ? {
154
+ eq?: V;
155
+ in?: readonly V[];
156
+ ne?: Hint<'key supports only eq and in'>;
157
+ lt?: Hint<'key supports only eq and in'>;
158
+ gt?: Hint<'key supports only eq and in'>;
159
+ } : {
160
+ eq?: Val<V>;
161
+ ne?: Val<V>;
162
+ in?: readonly Val<V>[];
163
+ isNull?: boolean;
164
+ } & ([N] extends [Orderable] ? {
165
+ lt?: NonNullable<V>;
166
+ lte?: NonNullable<V>;
167
+ gt?: NonNullable<V>;
168
+ gte?: NonNullable<V>;
169
+ } : {
170
+ lt?: Hint<`${KindName<N>} fields cannot be compared with lt/lte/gt/gte: ranges need int, int64, decimal, date, datetime or string`>;
171
+ lte?: Hint<`${KindName<N>} fields cannot be compared with lt/lte/gt/gte: ranges need int, int64, decimal, date, datetime or string`>;
172
+ gt?: Hint<`${KindName<N>} fields cannot be compared with lt/lte/gt/gte: ranges need int, int64, decimal, date, datetime or string`>;
173
+ gte?: Hint<`${KindName<N>} fields cannot be compared with lt/lte/gt/gte: ranges need int, int64, decimal, date, datetime or string`>;
174
+ }) & ([N] extends ['string'] ? {
175
+ like?: string;
176
+ } : {
177
+ like?: Hint<`like needs a string field, not ${KindName<N>}`>;
178
+ });
179
+ /** Conjunction of conditions on fields or ref paths; a bare value means equality. */
180
+ export type Where<E> = {
181
+ [L in PathLeaves<Fields<E>> as L[0]]?: L[2] extends 'json' ? Hint<`json field '${L[0]}' cannot be filtered: filter on a typed field`> : Val<L[1]> | Ops<L[1], L[2]>;
182
+ } & {
183
+ or?: readonly Where<E>[];
184
+ };
185
+ type OrderEntries<E> = {
186
+ [L in PathLeaves<Fields<E>> as L[0]]: L[2] extends Orderable ? {
187
+ field: L[0];
188
+ desc?: boolean;
189
+ } : {
190
+ field: L[0];
191
+ desc?: boolean;
192
+ } & Hint<`cannot order by '${L[0]}': ${KindName<L[2]>} fields have no database order; order by an int, int64, decimal, date, datetime or string field, or createdAt/updatedAt`>;
193
+ };
194
+ /** One `orderBy` entry: an orderable path; any other path is accepted by the types only to explain, in the error text, why not. */
195
+ export type OrderBy<E> = OrderEntries<E>[keyof OrderEntries<E>];
196
+ export declare function compileFilter(where: object): FilterJSON;
197
+ export interface ReadRule<E> {
198
+ /** Permission the subject must hold; omitted means any authenticated subject. */
199
+ when?: Permission;
200
+ /** `'all'` every row, `'none'` no row (an explicit deny), or a filter. */
201
+ rows: 'all' | 'none' | Where<E>;
202
+ }
203
+ export interface EntityAccess<F extends FieldShape> {
204
+ /**
205
+ * Visibility rules (union of the rules whose permission the subject holds). Omit `read` for unrestricted rows;
206
+ * an empty list is rejected as ambiguous: write `[{ rows: 'none' }]` to deny everyone explicitly.
207
+ */
208
+ read?: readonly ReadRule<{
209
+ readonly fields: F;
210
+ }>[];
211
+ /** Permissions required to read a field; applies to every surface. */
212
+ fields?: {
213
+ readonly [K in keyof F]?: readonly Permission[];
214
+ };
215
+ }
216
+ export interface EntityOptions<F extends FieldShape> {
217
+ label?: Label;
218
+ description?: string;
219
+ access?: EntityAccess<F>;
220
+ }
221
+ /** An entity owned by this package: one typed table, generic CRUD allowed. */
222
+ export declare function entity<const Id extends string, F extends FieldShape>(id: Id, fields: F, opts?: EntityOptions<F>): Entity<Id, F, 'own'>;
223
+ /**
224
+ * Descriptor of a platform/Granite-owned entity, produced by the developer kit.
225
+ * Readable through queries and refs; generic writes are rejected (types and runtime).
226
+ */
227
+ export declare function nativeEntity<const Id extends string, F extends FieldShape>(id: Id, fields: F, opts: {
228
+ key: KeyType;
229
+ }): Entity<Id, F, 'native'>;
230
+ /**
231
+ * A separate 1:1 typed table keyed by the base record key. A record without an overlay row
232
+ * reads declared defaults or null, so every overlay field must be optional, nullable or defaulted.
233
+ */
234
+ export declare function overlay<const Id extends string, B extends AnyEntity, F extends FieldShape>(id: Id, base: B, fields: F, opts?: Pick<EntityOptions<F>, 'label' | 'description' | 'access'>): Overlay<Id, B, F>;
235
+ /** Typed pointer to a record. The key is checked against the entity's key type (uuid for own entities). */
236
+ export declare function ref<E extends AnyEntity>(entity: E, key: string): Ref<E>;
237
+ export type { Ref, UserEntity, UserRef };
@@ -0,0 +1,201 @@
1
+ import { contract, omitEmpty } from "./resource.js";
2
+ import { makeSchema, t, } from "./schema.js";
3
+ import { isInt64String, isUUID, validate } from "./wire.js";
4
+ const emptySpec = { unique: false, index: false, renamedFrom: [] };
5
+ function makeField(type, spec = emptySpec) {
6
+ const base = makeSchema(type);
7
+ const next = (patch, nextType = type) => makeField(nextType, { ...spec, ...patch });
8
+ return {
9
+ ...base,
10
+ spec,
11
+ optional: () => next({}, { ...type, optional: true, nullable: true }),
12
+ nullable: () => next({}, { ...type, nullable: true }),
13
+ unique: () => next({ unique: true }),
14
+ index: () => next({ index: true }),
15
+ default: (value) => {
16
+ const json = value;
17
+ try {
18
+ validate(type, json);
19
+ }
20
+ catch (e) {
21
+ throw new Error(`invalid field default: ${e instanceof Error ? e.message : String(e)}`);
22
+ }
23
+ return next({ default: json });
24
+ },
25
+ renamedFrom: (...keys) => next({ renamedFrom: [...spec.renamedFrom, ...keys] }),
26
+ label: (label) => next({ label }),
27
+ };
28
+ }
29
+ function fieldOf(schema) {
30
+ return makeField(schema.type);
31
+ }
32
+ const text = (o) => fieldOf(t.string(o));
33
+ export const field = {
34
+ text,
35
+ string: text,
36
+ int: () => fieldOf(t.int()),
37
+ int64: () => fieldOf(t.int64()),
38
+ decimal: (o) => fieldOf(t.decimal(o)),
39
+ bool: () => fieldOf(t.bool()),
40
+ date: () => fieldOf(t.date()),
41
+ datetime: () => fieldOf(t.datetime()),
42
+ uuid: () => fieldOf(t.uuid()),
43
+ enum: (values) => fieldOf(t.enum(values)),
44
+ json: () => fieldOf(t.json()),
45
+ ref: (entity) => fieldOf(t.ref(entity)),
46
+ };
47
+ /** Keys the data layer owns on every row; declaring a field with one of these keys is an error. */
48
+ export const RESERVED_KEYS = new Set(['key', 'ref', 'createdAt', 'updatedAt', 'rowVersion', 'baseKey']);
49
+ /** `$.user` is the current subject's user ref inside access rules and filters; it matches only `core.user` ref fields. */
50
+ export const $ = { user: { $: 'user' } };
51
+ const opKeys = new Set(['eq', 'ne', 'in', 'lt', 'lte', 'gt', 'gte', 'isNull', 'like']);
52
+ function isPlaceholder(value) {
53
+ return typeof value === 'object' && value !== null && value.$ === 'user';
54
+ }
55
+ function toCondition(value) {
56
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && !isPlaceholder(value)) {
57
+ const keys = Object.keys(value);
58
+ if (keys.length > 0 && keys.every((k) => opKeys.has(k)))
59
+ return { ...value };
60
+ }
61
+ return { eq: value };
62
+ }
63
+ export function compileFilter(where) {
64
+ const fields = {};
65
+ let or;
66
+ for (const [key, value] of Object.entries(where)) {
67
+ if (value === undefined)
68
+ continue;
69
+ if (key === 'or')
70
+ or = value.map(compileFilter);
71
+ else
72
+ fields[key] = toCondition(value);
73
+ }
74
+ return omitEmpty({ fields: Object.keys(fields).length > 0 ? fields : undefined, or });
75
+ }
76
+ /** `$.user` is a `core.user` ref: reject it on a direct field of another type (dotted paths are checked by the types). */
77
+ function checkUserPlaceholders(owner, fields, where) {
78
+ for (const [key, value] of Object.entries(where)) {
79
+ if (value === undefined)
80
+ continue;
81
+ if (key === 'or') {
82
+ for (const w of value)
83
+ checkUserPlaceholders(owner, fields, w);
84
+ continue;
85
+ }
86
+ if (key.includes('.'))
87
+ continue;
88
+ const cond = toCondition(value);
89
+ const used = isPlaceholder(cond.eq) || isPlaceholder(cond.ne) || (cond.in ?? []).some(isPlaceholder);
90
+ if (!used)
91
+ continue;
92
+ const type = fields[key]?.type;
93
+ if (type === undefined || type.kind !== 'ref' || type.entity !== 'core.user') {
94
+ throw new Error(`${owner}: $.user can only be compared with a ref to core.user, but "${key}" is not one`);
95
+ }
96
+ }
97
+ }
98
+ function compileField(id, f) {
99
+ const typed = omitEmpty({
100
+ id,
101
+ type: f.type,
102
+ unique: f.spec.unique,
103
+ index: f.spec.index,
104
+ renamedFrom: [...f.spec.renamedFrom],
105
+ label: f.spec.label,
106
+ });
107
+ // `default` is a JSON value: `false`, `0`, `""`, `[]` and `null` are real defaults and must be emitted.
108
+ if (f.spec.default === undefined)
109
+ return typed;
110
+ const { id: fid, type, unique, index, ...rest } = typed;
111
+ return { id: fid, type, ...(unique ? { unique } : {}), ...(index ? { index } : {}), default: f.spec.default, ...rest };
112
+ }
113
+ function compileAccess(owner, fields, access) {
114
+ if (!access)
115
+ return undefined;
116
+ if (access.read !== undefined && access.read.length === 0) {
117
+ throw new Error(`${owner}: access.read is empty, which is ambiguous (unrestricted or denied?); omit it, or write [{ rows: 'none' }] to deny`);
118
+ }
119
+ const read = (access.read ?? []).map((r) => {
120
+ if (typeof r.rows === 'object')
121
+ checkUserPlaceholders(owner, fields, r.rows);
122
+ return omitEmpty({
123
+ permission: r.when?.id,
124
+ all: r.rows === 'all',
125
+ rows: typeof r.rows === 'object' ? compileFilter(r.rows) : undefined,
126
+ });
127
+ });
128
+ const permissions = {};
129
+ for (const [k, perms] of Object.entries(access.fields ?? {})) {
130
+ if (perms)
131
+ permissions[k] = perms.map((p) => p.id);
132
+ }
133
+ return omitEmpty({ read, fields: Object.keys(permissions).length > 0 ? permissions : undefined });
134
+ }
135
+ function bind(owner, fields, rejectReserved) {
136
+ const out = {};
137
+ for (const [key, f] of Object.entries(fields)) {
138
+ if (rejectReserved && RESERVED_KEYS.has(key))
139
+ throw new Error(`${owner}: field key "${key}" is reserved for the data layer`);
140
+ out[key] = { ...f, owner, key };
141
+ }
142
+ return out;
143
+ }
144
+ /** An entity owned by this package: one typed table, generic CRUD allowed. */
145
+ export function entity(id, fields, opts = {}) {
146
+ const resource = omitEmpty({
147
+ id,
148
+ kind: 'entity',
149
+ label: opts.label,
150
+ description: opts.description,
151
+ fields: Object.entries(fields).map(([k, f]) => compileField(k, f)),
152
+ access: compileAccess(id, fields, opts.access),
153
+ });
154
+ return { ...contract(resource), entityKind: 'own', keyType: 'uuid', fields: bind(id, fields, true) };
155
+ }
156
+ /**
157
+ * Descriptor of a platform/Granite-owned entity, produced by the developer kit.
158
+ * Readable through queries and refs; generic writes are rejected (types and runtime).
159
+ */
160
+ export function nativeEntity(id, fields, opts) {
161
+ const resource = {
162
+ id,
163
+ kind: 'entity',
164
+ fields: Object.entries(fields).map(([k, f]) => compileField(k, f)),
165
+ };
166
+ return { ...contract(resource, true), entityKind: 'native', keyType: opts.key, fields: bind(id, fields, false) };
167
+ }
168
+ /**
169
+ * A separate 1:1 typed table keyed by the base record key. A record without an overlay row
170
+ * reads declared defaults or null, so every overlay field must be optional, nullable or defaulted.
171
+ */
172
+ export function overlay(id, base, fields, opts = {}) {
173
+ for (const [key, f] of Object.entries(fields)) {
174
+ if (!f.type.optional && !f.type.nullable && f.spec.default === undefined) {
175
+ throw new Error(`${id}: overlay field "${key}" needs .optional(), .nullable() or .default(...): a base record may have no overlay row`);
176
+ }
177
+ }
178
+ const resource = omitEmpty({
179
+ id,
180
+ kind: 'overlay',
181
+ label: opts.label,
182
+ description: opts.description,
183
+ base: base.id,
184
+ fields: Object.entries(fields).map(([k, f]) => compileField(k, f)),
185
+ access: compileAccess(id, fields, opts.access),
186
+ });
187
+ return { ...contract(resource), base, fields: bind(id, fields, true) };
188
+ }
189
+ function validKey(keyType, key) {
190
+ if (keyType === 'int64')
191
+ return isInt64String(key);
192
+ if (keyType === 'uuid')
193
+ return isUUID(key);
194
+ return key !== '';
195
+ }
196
+ /** Typed pointer to a record. The key is checked against the entity's key type (uuid for own entities). */
197
+ export function ref(entity, key) {
198
+ if (!validKey(entity.keyType, key))
199
+ throw new Error(`ref(${entity.id}): "${key}" is not a valid ${entity.keyType} key`);
200
+ return { entity: entity.id, key };
201
+ }