@datakable/core 1.0.1 → 1.1.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 (280) hide show
  1. package/README.md +4 -2
  2. package/dist/catalog/codes.cjs +12 -8
  3. package/dist/catalog/codes.cjs.map +1 -1
  4. package/dist/catalog/codes.js +12 -8
  5. package/dist/catalog/codes.js.map +1 -1
  6. package/dist/catalog/slots.cjs +10 -6
  7. package/dist/catalog/slots.cjs.map +1 -1
  8. package/dist/catalog/slots.js +10 -6
  9. package/dist/catalog/slots.js.map +1 -1
  10. package/dist/{codes-OsjAR3Wz.d.cts → codes-B9bCK73-.d.cts} +30 -4
  11. package/dist/{codes-OsjAR3Wz.d.ts → codes-B9bCK73-.d.ts} +30 -4
  12. package/dist/column/column-def.cjs.map +1 -1
  13. package/dist/column/get-value.cjs +6 -1
  14. package/dist/column/get-value.cjs.map +1 -1
  15. package/dist/column/get-value.js +6 -1
  16. package/dist/column/get-value.js.map +1 -1
  17. package/dist/column-filters.d.cts +2 -2
  18. package/dist/column-filters.d.ts +2 -2
  19. package/dist/diagnostics/build.cjs +4 -1
  20. package/dist/diagnostics/build.cjs.map +1 -1
  21. package/dist/diagnostics/build.js +4 -1
  22. package/dist/diagnostics/build.js.map +1 -1
  23. package/dist/diagnostics/catalog.cjs +11 -5
  24. package/dist/diagnostics/catalog.cjs.map +1 -1
  25. package/dist/diagnostics/catalog.js +10 -5
  26. package/dist/diagnostics/catalog.js.map +1 -1
  27. package/dist/diagnostics/codes.cjs +12 -8
  28. package/dist/diagnostics/codes.cjs.map +1 -1
  29. package/dist/diagnostics/codes.js +12 -8
  30. package/dist/diagnostics/codes.js.map +1 -1
  31. package/dist/diagnostics/console.cjs +13 -6
  32. package/dist/diagnostics/console.cjs.map +1 -1
  33. package/dist/diagnostics/console.js +13 -6
  34. package/dist/diagnostics/console.js.map +1 -1
  35. package/dist/diagnostics/env.cjs +1 -0
  36. package/dist/diagnostics/env.cjs.map +1 -1
  37. package/dist/diagnostics/env.js +1 -0
  38. package/dist/diagnostics/env.js.map +1 -1
  39. package/dist/diagnostics/explain-text.cjs +2 -1
  40. package/dist/diagnostics/explain-text.cjs.map +1 -1
  41. package/dist/diagnostics/explain-text.js +2 -1
  42. package/dist/diagnostics/explain-text.js.map +1 -1
  43. package/dist/diagnostics/explain.cjs +3 -2
  44. package/dist/diagnostics/explain.cjs.map +1 -1
  45. package/dist/diagnostics/explain.js +3 -2
  46. package/dist/diagnostics/explain.js.map +1 -1
  47. package/dist/diagnostics/hub.cjs +5 -4
  48. package/dist/diagnostics/hub.cjs.map +1 -1
  49. package/dist/diagnostics/hub.js +5 -4
  50. package/dist/diagnostics/hub.js.map +1 -1
  51. package/dist/diagnostics/process-guard.cjs +26 -0
  52. package/dist/diagnostics/process-guard.cjs.map +1 -0
  53. package/dist/diagnostics/process-guard.js +9 -0
  54. package/dist/diagnostics/process-guard.js.map +1 -0
  55. package/dist/diagnostics/prose.cjs +120 -0
  56. package/dist/diagnostics/prose.cjs.map +1 -0
  57. package/dist/diagnostics/prose.js +93 -0
  58. package/dist/diagnostics/prose.js.map +1 -0
  59. package/dist/diagnostics/redact.cjs +7 -4
  60. package/dist/diagnostics/redact.cjs.map +1 -1
  61. package/dist/diagnostics/redact.js +6 -4
  62. package/dist/diagnostics/redact.js.map +1 -1
  63. package/dist/diagnostics/trace-store.cjs +6 -0
  64. package/dist/diagnostics/trace-store.cjs.map +1 -1
  65. package/dist/diagnostics/trace-store.js +4 -0
  66. package/dist/diagnostics/trace-store.js.map +1 -1
  67. package/dist/diagnostics/tracer.cjs +74 -13
  68. package/dist/diagnostics/tracer.cjs.map +1 -1
  69. package/dist/diagnostics/tracer.js +75 -14
  70. package/dist/diagnostics/tracer.js.map +1 -1
  71. package/dist/diagnostics/types.cjs.map +1 -1
  72. package/dist/{explain-vkD2cewE.d.cts → explain-Q8Cg0cZy.d.cts} +13 -4
  73. package/dist/{explain-Dn99IQt0.d.ts → explain-i0OATi_W.d.ts} +13 -4
  74. package/dist/feature/codes.cjs +1 -0
  75. package/dist/feature/codes.cjs.map +1 -1
  76. package/dist/feature/codes.js +1 -0
  77. package/dist/feature/codes.js.map +1 -1
  78. package/dist/feature/install.cjs +4 -3
  79. package/dist/feature/install.cjs.map +1 -1
  80. package/dist/feature/install.js +4 -3
  81. package/dist/feature/install.js.map +1 -1
  82. package/dist/features/column-filters/codes.cjs +1 -0
  83. package/dist/features/column-filters/codes.cjs.map +1 -1
  84. package/dist/features/column-filters/codes.js +1 -0
  85. package/dist/features/column-filters/codes.js.map +1 -1
  86. package/dist/features/column-filters/column-filters.cjs +4 -2
  87. package/dist/features/column-filters/column-filters.cjs.map +1 -1
  88. package/dist/features/column-filters/column-filters.js +4 -2
  89. package/dist/features/column-filters/column-filters.js.map +1 -1
  90. package/dist/features/column-filters/match.cjs +5 -5
  91. package/dist/features/column-filters/match.cjs.map +1 -1
  92. package/dist/features/column-filters/match.js +5 -5
  93. package/dist/features/column-filters/match.js.map +1 -1
  94. package/dist/features/pagination/codes.cjs +1 -0
  95. package/dist/features/pagination/codes.cjs.map +1 -1
  96. package/dist/features/pagination/codes.js +1 -0
  97. package/dist/features/pagination/codes.js.map +1 -1
  98. package/dist/features/pagination/pagination.cjs +16 -13
  99. package/dist/features/pagination/pagination.cjs.map +1 -1
  100. package/dist/features/pagination/pagination.js +16 -13
  101. package/dist/features/pagination/pagination.js.map +1 -1
  102. package/dist/features/search/codes.cjs +1 -0
  103. package/dist/features/search/codes.cjs.map +1 -1
  104. package/dist/features/search/codes.js +1 -0
  105. package/dist/features/search/codes.js.map +1 -1
  106. package/dist/features/search/search-index.cjs +68 -15
  107. package/dist/features/search/search-index.cjs.map +1 -1
  108. package/dist/features/search/search-index.js +68 -15
  109. package/dist/features/search/search-index.js.map +1 -1
  110. package/dist/features/search/search.cjs +41 -9
  111. package/dist/features/search/search.cjs.map +1 -1
  112. package/dist/features/search/search.js +41 -9
  113. package/dist/features/search/search.js.map +1 -1
  114. package/dist/features/search/skipped-codes.cjs +45 -0
  115. package/dist/features/search/skipped-codes.cjs.map +1 -0
  116. package/dist/features/search/skipped-codes.js +20 -0
  117. package/dist/features/search/skipped-codes.js.map +1 -0
  118. package/dist/features/sorting/codes.cjs +1 -0
  119. package/dist/features/sorting/codes.cjs.map +1 -1
  120. package/dist/features/sorting/codes.js +1 -0
  121. package/dist/features/sorting/codes.js.map +1 -1
  122. package/dist/features/sorting/sorting.cjs +16 -20
  123. package/dist/features/sorting/sorting.cjs.map +1 -1
  124. package/dist/features/sorting/sorting.js +16 -20
  125. package/dist/features/sorting/sorting.js.map +1 -1
  126. package/dist/features/sorting/strategy.cjs +4 -4
  127. package/dist/features/sorting/strategy.cjs.map +1 -1
  128. package/dist/features/sorting/strategy.js +4 -4
  129. package/dist/features/sorting/strategy.js.map +1 -1
  130. package/dist/features/validity/codes.cjs +1 -0
  131. package/dist/features/validity/codes.cjs.map +1 -1
  132. package/dist/features/validity/codes.js +1 -0
  133. package/dist/features/validity/codes.js.map +1 -1
  134. package/dist/features/validity/validity.cjs +3 -3
  135. package/dist/features/validity/validity.cjs.map +1 -1
  136. package/dist/features/validity/validity.js +3 -3
  137. package/dist/features/validity/validity.js.map +1 -1
  138. package/dist/index.d.cts +13 -10
  139. package/dist/index.d.ts +13 -10
  140. package/dist/ingest/data-check-codes.cjs +4 -2
  141. package/dist/ingest/data-check-codes.cjs.map +1 -1
  142. package/dist/ingest/data-check-codes.js +4 -2
  143. package/dist/ingest/data-check-codes.js.map +1 -1
  144. package/dist/ingest/data-checks.cjs +1 -1
  145. package/dist/ingest/data-checks.cjs.map +1 -1
  146. package/dist/ingest/data-checks.js +1 -1
  147. package/dist/ingest/data-checks.js.map +1 -1
  148. package/dist/ingest/row-key-codes.cjs +1 -0
  149. package/dist/ingest/row-key-codes.cjs.map +1 -1
  150. package/dist/ingest/row-key-codes.js +1 -0
  151. package/dist/ingest/row-key-codes.js.map +1 -1
  152. package/dist/ingest/row-key.cjs +23 -20
  153. package/dist/ingest/row-key.cjs.map +1 -1
  154. package/dist/ingest/row-key.js +23 -20
  155. package/dist/ingest/row-key.js.map +1 -1
  156. package/dist/ingest/schema-codes.cjs +1 -0
  157. package/dist/ingest/schema-codes.cjs.map +1 -1
  158. package/dist/ingest/schema-codes.js +1 -0
  159. package/dist/ingest/schema-codes.js.map +1 -1
  160. package/dist/ingest/unique-fields.cjs +2 -2
  161. package/dist/ingest/unique-fields.cjs.map +1 -1
  162. package/dist/ingest/unique-fields.js +2 -2
  163. package/dist/ingest/unique-fields.js.map +1 -1
  164. package/dist/intercept/boundary.cjs +4 -2
  165. package/dist/intercept/boundary.cjs.map +1 -1
  166. package/dist/intercept/boundary.js +4 -2
  167. package/dist/intercept/boundary.js.map +1 -1
  168. package/dist/intercept/cell-batch.cjs +4 -4
  169. package/dist/intercept/cell-batch.cjs.map +1 -1
  170. package/dist/intercept/cell-batch.js +4 -4
  171. package/dist/intercept/cell-batch.js.map +1 -1
  172. package/dist/intercept/codes.cjs +1 -0
  173. package/dist/intercept/codes.cjs.map +1 -1
  174. package/dist/intercept/codes.js +1 -0
  175. package/dist/intercept/codes.js.map +1 -1
  176. package/dist/intercept/fallbacks.cjs +12 -20
  177. package/dist/intercept/fallbacks.cjs.map +1 -1
  178. package/dist/intercept/fallbacks.js +12 -20
  179. package/dist/intercept/fallbacks.js.map +1 -1
  180. package/dist/intercept/runtime.cjs +7 -9
  181. package/dist/intercept/runtime.cjs.map +1 -1
  182. package/dist/intercept/runtime.js +7 -9
  183. package/dist/intercept/runtime.js.map +1 -1
  184. package/dist/messages/index.cjs +4 -1
  185. package/dist/messages/index.cjs.map +1 -1
  186. package/dist/messages/index.js +4 -1
  187. package/dist/messages/index.js.map +1 -1
  188. package/dist/pagination.d.cts +2 -2
  189. package/dist/pagination.d.ts +2 -2
  190. package/dist/pipeline/codes.cjs +1 -0
  191. package/dist/pipeline/codes.cjs.map +1 -1
  192. package/dist/pipeline/codes.js +1 -0
  193. package/dist/pipeline/codes.js.map +1 -1
  194. package/dist/pipeline/column-cache.cjs +94 -76
  195. package/dist/pipeline/column-cache.cjs.map +1 -1
  196. package/dist/pipeline/column-cache.js +92 -75
  197. package/dist/pipeline/column-cache.js.map +1 -1
  198. package/dist/pipeline/dev-checks.cjs +1 -0
  199. package/dist/pipeline/dev-checks.cjs.map +1 -1
  200. package/dist/pipeline/dev-checks.js +1 -0
  201. package/dist/pipeline/dev-checks.js.map +1 -1
  202. package/dist/pipeline/env-codes.cjs +3 -2
  203. package/dist/pipeline/env-codes.cjs.map +1 -1
  204. package/dist/pipeline/env-codes.js +3 -2
  205. package/dist/pipeline/env-codes.js.map +1 -1
  206. package/dist/pipeline/perf-codes.cjs +1 -0
  207. package/dist/pipeline/perf-codes.cjs.map +1 -1
  208. package/dist/pipeline/perf-codes.js +1 -0
  209. package/dist/pipeline/perf-codes.js.map +1 -1
  210. package/dist/pipeline/runner.cjs +17 -9
  211. package/dist/pipeline/runner.cjs.map +1 -1
  212. package/dist/pipeline/runner.js +17 -9
  213. package/dist/pipeline/runner.js.map +1 -1
  214. package/dist/pipeline/slice.cjs +3 -1
  215. package/dist/pipeline/slice.cjs.map +1 -1
  216. package/dist/pipeline/slice.js +3 -1
  217. package/dist/pipeline/slice.js.map +1 -1
  218. package/dist/schema.d.cts +2 -2
  219. package/dist/schema.d.ts +2 -2
  220. package/dist/{search-async-entry-v5JdEk5Y.d.cts → search-async-entry-CuLYPfY_.d.cts} +2 -2
  221. package/dist/{search-async-entry-DGSw2pDL.d.ts → search-async-entry-Cx7xpuVZ.d.ts} +2 -2
  222. package/dist/search-async.d.cts +3 -3
  223. package/dist/search-async.d.ts +3 -3
  224. package/dist/search.d.cts +8 -6
  225. package/dist/search.d.ts +8 -6
  226. package/dist/server.d.cts +3 -3
  227. package/dist/server.d.ts +3 -3
  228. package/dist/sorting.d.cts +2 -2
  229. package/dist/sorting.d.ts +2 -2
  230. package/dist/source/codes.cjs +1 -0
  231. package/dist/source/codes.cjs.map +1 -1
  232. package/dist/source/codes.js +1 -0
  233. package/dist/source/codes.js.map +1 -1
  234. package/dist/source/fetch-codes.cjs +1 -0
  235. package/dist/source/fetch-codes.cjs.map +1 -1
  236. package/dist/source/fetch-codes.js +1 -0
  237. package/dist/source/fetch-codes.js.map +1 -1
  238. package/dist/table/codes.cjs +1 -0
  239. package/dist/table/codes.cjs.map +1 -1
  240. package/dist/table/codes.js +1 -0
  241. package/dist/table/codes.js.map +1 -1
  242. package/dist/table/create-table.cjs +39 -9
  243. package/dist/table/create-table.cjs.map +1 -1
  244. package/dist/table/create-table.js +39 -9
  245. package/dist/table/create-table.js.map +1 -1
  246. package/dist/table/data-mutation.cjs +1 -0
  247. package/dist/table/data-mutation.cjs.map +1 -1
  248. package/dist/table/data-mutation.js +1 -0
  249. package/dist/table/data-mutation.js.map +1 -1
  250. package/dist/table/internals.cjs.map +1 -1
  251. package/dist/table/internals.js.map +1 -1
  252. package/dist/table/ssr-codes.cjs +1 -0
  253. package/dist/table/ssr-codes.cjs.map +1 -1
  254. package/dist/table/ssr-codes.js +1 -0
  255. package/dist/table/ssr-codes.js.map +1 -1
  256. package/dist/table/ssr.cjs +4 -1
  257. package/dist/table/ssr.cjs.map +1 -1
  258. package/dist/table/ssr.js +4 -1
  259. package/dist/table/ssr.js.map +1 -1
  260. package/dist/table/state-feedback.cjs +19 -0
  261. package/dist/table/state-feedback.cjs.map +1 -1
  262. package/dist/table/state-feedback.js +19 -0
  263. package/dist/table/state-feedback.js.map +1 -1
  264. package/dist/table/types.cjs.map +1 -1
  265. package/dist/table/types.js.map +1 -1
  266. package/dist/validity.d.cts +2 -2
  267. package/dist/validity.d.ts +2 -2
  268. package/dist/version.cjs +1 -1
  269. package/dist/version.cjs.map +1 -1
  270. package/dist/version.js +1 -1
  271. package/dist/version.js.map +1 -1
  272. package/dist/versioning/codes.cjs +18 -0
  273. package/dist/versioning/codes.cjs.map +1 -1
  274. package/dist/versioning/codes.js +18 -0
  275. package/dist/versioning/codes.js.map +1 -1
  276. package/dist/versioning/registry.cjs +4 -2
  277. package/dist/versioning/registry.cjs.map +1 -1
  278. package/dist/versioning/registry.js +4 -2
  279. package/dist/versioning/registry.js.map +1 -1
  280. package/package.json +39 -3
package/dist/sorting.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { W as comparatorDiagnostics, ar as sortingDiagnostics } from './codes-OsjAR3Wz.js';
2
- import { ad as SortAlgorithm, a1 as Path, e as FeatureTypes, F as Feature } from './explain-Dn99IQt0.js';
1
+ export { W as comparatorDiagnostics, ar as sortingDiagnostics } from './codes-B9bCK73-.js';
2
+ import { ad as SortAlgorithm, a1 as Path, e as FeatureTypes, F as Feature } from './explain-i0OATi_W.js';
3
3
  import { a as DataMode } from './mode-DFV8ryXo.js';
4
4
 
5
5
  /** The rank of `v` in {@link RANK}. */
@@ -25,6 +25,7 @@ __export(codes_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(codes_exports);
27
27
  var import_catalog = require("../diagnostics/catalog.cjs");
28
+ var import_process_guard = require("../diagnostics/process-guard.cjs");
28
29
  var asyncMessages = {
29
30
  DK_ASYNC_TIMEOUT: {
30
31
  problem: (d) => `${d.source} did not settle within the timeout (${d.timeout} ms)`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/source/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_ASYNC_TIMEOUT: {\n /** The option that ran too long (`fetcher`, `searchFn`); a closed set, never row data. */\n source: string\n /** The timeout that was exceeded, in ms. */\n timeout: number\n }\n }\n}\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const asyncMessages: DiagnosticMessages<'DK_ASYNC_TIMEOUT'> = {\n DK_ASYNC_TIMEOUT: {\n problem: (d) => `${d.source} did not settle within the timeout (${d.timeout} ms)`,\n impact: () =>\n 'the request was aborted and its late result is ignored; the previous results were kept ' +\n \"(status: 'error')\",\n fix: (d) => [\n `make ${d.source} answer faster (smaller pages, a server-side index), or raise \\`timeout\\` ` +\n `(now ${d.timeout} ms)`,\n `pass ctx.signal to fetch() inside ${d.source} so the timed-out request is cancelled on the ` +\n 'network too',\n ],\n },\n}\n\n/** Codes owned by asyncControl (spec §3.4, §7.1, §8.3). */\nexport const asyncDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_ASYNC_TIMEOUT',\n level: 'error',\n where: (d) => ({ kind: 'option', path: d.source }),\n },\n (process.env.NODE_ENV !== \"production\") && asyncMessages.DK_ASYNC_TIMEOUT,\n ),\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0D;AAcnD,IAAM,gBAAwD;AAAA,EACnE,kBAAkB;AAAA,IAChB,SAAS,CAAC,MAAM,GAAG,EAAE,MAAM,uCAAuC,EAAE,OAAO;AAAA,IAC3E,QAAQ,MACN;AAAA,IAEF,KAAK,CAAC,MAAM;AAAA,MACV,QAAQ,EAAE,MAAM,kFACN,EAAE,OAAO;AAAA,MACnB,qCAAqC,EAAE,MAAM;AAAA,IAE/C;AAAA,EACF;AACF;AAGO,IAAM,mBAAmB;AAAA,MAC9B;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,EAAE,OAAO;AAAA,IAClD;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/source/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_ASYNC_TIMEOUT: {\n /** The option that ran too long (`fetcher`, `searchFn`); a closed set, never row data. */\n source: string\n /** The timeout that was exceeded, in ms. */\n timeout: number\n }\n }\n}\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const asyncMessages: DiagnosticMessages<'DK_ASYNC_TIMEOUT'> = {\n DK_ASYNC_TIMEOUT: {\n problem: (d) => `${d.source} did not settle within the timeout (${d.timeout} ms)`,\n impact: () =>\n 'the request was aborted and its late result is ignored; the previous results were kept ' +\n \"(status: 'error')\",\n fix: (d) => [\n `make ${d.source} answer faster (smaller pages, a server-side index), or raise \\`timeout\\` ` +\n `(now ${d.timeout} ms)`,\n `pass ctx.signal to fetch() inside ${d.source} so the timed-out request is cancelled on the ` +\n 'network too',\n ],\n },\n}\n\n/** Codes owned by asyncControl (spec §3.4, §7.1, §8.3). */\nexport const asyncDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_ASYNC_TIMEOUT',\n level: 'error',\n where: (d) => ({ kind: 'option', path: d.source }),\n },\n (process.env.NODE_ENV !== \"production\") && asyncMessages.DK_ASYNC_TIMEOUT,\n ),\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0D;AAC1D,2BAAO;AAcA,IAAM,gBAAwD;AAAA,EACnE,kBAAkB;AAAA,IAChB,SAAS,CAAC,MAAM,GAAG,EAAE,MAAM,uCAAuC,EAAE,OAAO;AAAA,IAC3E,QAAQ,MACN;AAAA,IAEF,KAAK,CAAC,MAAM;AAAA,MACV,QAAQ,EAAE,MAAM,kFACN,EAAE,OAAO;AAAA,MACnB,qCAAqC,EAAE,MAAM;AAAA,IAE/C;AAAA,EACF;AACF;AAGO,IAAM,mBAAmB;AAAA,MAC9B;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,EAAE,OAAO;AAAA,IAClD;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
@@ -1,5 +1,6 @@
1
1
  // src/source/codes.ts
2
2
  import { defineDiagnostic } from "../diagnostics/catalog.js";
3
+ import "../diagnostics/process-guard.js";
3
4
  var asyncMessages = {
4
5
  DK_ASYNC_TIMEOUT: {
5
6
  problem: (d) => `${d.source} did not settle within the timeout (${d.timeout} ms)`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/source/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_ASYNC_TIMEOUT: {\n /** The option that ran too long (`fetcher`, `searchFn`); a closed set, never row data. */\n source: string\n /** The timeout that was exceeded, in ms. */\n timeout: number\n }\n }\n}\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const asyncMessages: DiagnosticMessages<'DK_ASYNC_TIMEOUT'> = {\n DK_ASYNC_TIMEOUT: {\n problem: (d) => `${d.source} did not settle within the timeout (${d.timeout} ms)`,\n impact: () =>\n 'the request was aborted and its late result is ignored; the previous results were kept ' +\n \"(status: 'error')\",\n fix: (d) => [\n `make ${d.source} answer faster (smaller pages, a server-side index), or raise \\`timeout\\` ` +\n `(now ${d.timeout} ms)`,\n `pass ctx.signal to fetch() inside ${d.source} so the timed-out request is cancelled on the ` +\n 'network too',\n ],\n },\n}\n\n/** Codes owned by asyncControl (spec §3.4, §7.1, §8.3). */\nexport const asyncDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_ASYNC_TIMEOUT',\n level: 'error',\n where: (d) => ({ kind: 'option', path: d.source }),\n },\n (process.env.NODE_ENV !== \"production\") && asyncMessages.DK_ASYNC_TIMEOUT,\n ),\n]\n"],"mappings":";AAAA,SAAkC,wBAAwB;AAcnD,IAAM,gBAAwD;AAAA,EACnE,kBAAkB;AAAA,IAChB,SAAS,CAAC,MAAM,GAAG,EAAE,MAAM,uCAAuC,EAAE,OAAO;AAAA,IAC3E,QAAQ,MACN;AAAA,IAEF,KAAK,CAAC,MAAM;AAAA,MACV,QAAQ,EAAE,MAAM,kFACN,EAAE,OAAO;AAAA,MACnB,qCAAqC,EAAE,MAAM;AAAA,IAE/C;AAAA,EACF;AACF;AAGO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,EAAE,OAAO;AAAA,IAClD;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/source/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_ASYNC_TIMEOUT: {\n /** The option that ran too long (`fetcher`, `searchFn`); a closed set, never row data. */\n source: string\n /** The timeout that was exceeded, in ms. */\n timeout: number\n }\n }\n}\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const asyncMessages: DiagnosticMessages<'DK_ASYNC_TIMEOUT'> = {\n DK_ASYNC_TIMEOUT: {\n problem: (d) => `${d.source} did not settle within the timeout (${d.timeout} ms)`,\n impact: () =>\n 'the request was aborted and its late result is ignored; the previous results were kept ' +\n \"(status: 'error')\",\n fix: (d) => [\n `make ${d.source} answer faster (smaller pages, a server-side index), or raise \\`timeout\\` ` +\n `(now ${d.timeout} ms)`,\n `pass ctx.signal to fetch() inside ${d.source} so the timed-out request is cancelled on the ` +\n 'network too',\n ],\n },\n}\n\n/** Codes owned by asyncControl (spec §3.4, §7.1, §8.3). */\nexport const asyncDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_ASYNC_TIMEOUT',\n level: 'error',\n where: (d) => ({ kind: 'option', path: d.source }),\n },\n (process.env.NODE_ENV !== \"production\") && asyncMessages.DK_ASYNC_TIMEOUT,\n ),\n]\n"],"mappings":";AAAA,SAAkC,wBAAwB;AAC1D,OAAO;AAcA,IAAM,gBAAwD;AAAA,EACnE,kBAAkB;AAAA,IAChB,SAAS,CAAC,MAAM,GAAG,EAAE,MAAM,uCAAuC,EAAE,OAAO;AAAA,IAC3E,QAAQ,MACN;AAAA,IAEF,KAAK,CAAC,MAAM;AAAA,MACV,QAAQ,EAAE,MAAM,kFACN,EAAE,OAAO;AAAA,MACnB,qCAAqC,EAAE,MAAM;AAAA,IAE/C;AAAA,EACF;AACF;AAGO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,EAAE,OAAO;AAAA,IAClD;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
@@ -25,6 +25,7 @@ __export(fetch_codes_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(fetch_codes_exports);
27
27
  var import_catalog = require("../diagnostics/catalog.cjs");
28
+ var import_process_guard = require("../diagnostics/process-guard.cjs");
28
29
  var BAD = {
29
30
  "not-an-object": (d) => `fetcher resolved with ${d.received}, not { rows, rowCount }`,
30
31
  "rows-not-an-array": (d) => `fetcher result.rows is ${d.received}, not an array`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/source/fetch-codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\n\n/** Why a fetcher result was rejected (`DK_FETCH_BAD_RESPONSE`); a closed set, never row data. */\nexport type BadResponse =\n | 'not-an-object'\n | 'rows-not-an-array'\n | 'rowCount-missing'\n | 'rowCount-invalid'\n | 'rowCount-too-small'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_MODE_ORDER: {\n /** The client-mode feature that runs before a server-mode one. */\n client: string\n clientStage: string\n /** The server-mode feature after it. */\n server: string\n serverStage: string\n }\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n /** The installed pipeline features (all client mode). */\n features: string[]\n phase: 'init' | 'setOptions'\n }\n DK_FETCH_FAILED: {\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n /** Whether rows were shown before (`false`: the first request failed). */\n hadRows: boolean\n }\n DK_FETCH_ABORTED: Record<string, never>\n DK_FETCH_BAD_RESPONSE: {\n problem: BadResponse\n /** The type of what was returned (`describeValue`), for the shape problems. */\n received?: string\n rows?: number\n rowCount?: number\n }\n }\n}\n\nconst BAD: Record<\n BadResponse,\n (d: { received?: string; rows?: number; rowCount?: number }) => string\n> = {\n 'not-an-object': (d) => `fetcher resolved with ${d.received}, not { rows, rowCount }`,\n 'rows-not-an-array': (d) => `fetcher result.rows is ${d.received}, not an array`,\n 'rowCount-missing': () =>\n 'fetcher result has no rowCount, and pagination is in server mode (it needs the total)',\n 'rowCount-invalid': (d) => `fetcher result.rowCount is ${d.received}, not an integer ≥ 0`,\n 'rowCount-too-small': (d) =>\n `fetcher result.rowCount (${d.rowCount}) is smaller than rows.length (${d.rows})`,\n}\n\nconst FETCHER = { kind: 'option', path: 'fetcher' } as const\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const fetchMessages: DiagnosticMessages<\n | 'DK_MODE_ORDER'\n | 'DK_FETCHER_WITHOUT_SERVER_MODE'\n | 'DK_FETCH_FAILED'\n | 'DK_FETCH_ABORTED'\n | 'DK_FETCH_BAD_RESPONSE'\n> = {\n DK_MODE_ORDER: {\n problem: (d) =>\n `feature \"${d.server}\" (${d.serverStage}) is in server mode, but \"${d.client}\" ` +\n `(${d.clientStage}) runs before it in client mode; server steps must come first`,\n impact: () =>\n 'the table was not created: the client step would only see the rows the server returned',\n fix: (d) => [\n `move \"${d.client}\" to the server too: ${d.client}({ mode: 'server' })`,\n `or handle \"${d.server}\" in the client: ${d.server}({ mode: 'client' }) (the default)`,\n ],\n },\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n problem: () => 'options.fetcher is set, but no feature is in server mode',\n impact: (d) =>\n d.phase === 'init'\n ? 'the table was not created: nothing would tell the fetcher what to load'\n : 'setOptions() was rejected; the previous options are kept',\n fix: (d) => [\n `set mode: 'server' on the features the server handles` +\n (d.features.length > 0 ? ` (installed: ${d.features.join(', ')})` : '') +\n `, e.g. pagination({ mode: 'server' })`,\n 'or remove fetcher and pass the rows as options.data (client mode)',\n ],\n },\n DK_FETCH_FAILED: {\n problem: (d) => `fetcher rejected or threw${d.errorName ? ` ${d.errorName}` : ''}`,\n impact: (d) =>\n d.hadRows\n ? \"the previous rows are kept (status: 'error')\"\n : \"nothing is shown yet (status: 'error', isInitialLoad: true)\",\n fix: () => [\n 'check the request the fetcher sends (the original error is context.cause, passed to ' +\n 'onDiagnostic)',\n 'retry from the UI with table.refetch(); the next state change (page, sort, filter, ' +\n 'query) or a new fetcher also runs it again',\n ],\n },\n DK_FETCH_ABORTED: {\n problem: () => 'a fetcher request was superseded by a newer one (latest wins)',\n impact: () => 'its result is ignored; the request was aborted through ctx.signal',\n fix: () => [\n 'nothing to fix; pass params.signal to fetch() so superseded requests stop on the network',\n ],\n },\n DK_FETCH_BAD_RESPONSE: {\n problem: (d) => BAD[d.problem](d),\n impact: () => \"the result was ignored and the previous rows are kept (status: 'error')\",\n fix: (d) => [\n d.problem === 'rowCount-too-small'\n ? 'return rowCount as the total number of matching rows on the server, not the page size'\n : 'resolve the fetcher with { rows: T[], rowCount: number } (rowCount = the total ' +\n 'number of matching rows on the server)',\n 'map your API response in the fetcher: async (p) => { const r = await api(p); ' +\n 'return { rows: r.items, rowCount: r.total } }',\n ],\n },\n}\n\n/** Codes owned by the data modes and the server source (spec §7.1, §8.3). */\nexport const fetchDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_MODE_ORDER',\n level: 'error',\n config: true,\n where: (d) => ({ kind: 'feature', name: d.server }),\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_MODE_ORDER,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCHER_WITHOUT_SERVER_MODE',\n level: 'error',\n config: true,\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCHER_WITHOUT_SERVER_MODE,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_FAILED',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_ABORTED',\n level: 'info',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_ABORTED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_BAD_RESPONSE',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_BAD_RESPONSE,\n ),\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0D;AA0C1D,IAAM,MAGF;AAAA,EACF,iBAAiB,CAAC,MAAM,yBAAyB,EAAE,QAAQ;AAAA,EAC3D,qBAAqB,CAAC,MAAM,0BAA0B,EAAE,QAAQ;AAAA,EAChE,oBAAoB,MAClB;AAAA,EACF,oBAAoB,CAAC,MAAM,8BAA8B,EAAE,QAAQ;AAAA,EACnE,sBAAsB,CAAC,MACrB,4BAA4B,EAAE,QAAQ,kCAAkC,EAAE,IAAI;AAClF;AAEA,IAAM,UAAU,EAAE,MAAM,UAAU,MAAM,UAAU;AAG3C,IAAM,gBAMT;AAAA,EACF,eAAe;AAAA,IACb,SAAS,CAAC,MACR,YAAY,EAAE,MAAM,MAAM,EAAE,WAAW,6BAA6B,EAAE,MAAM,MACxE,EAAE,WAAW;AAAA,IACnB,QAAQ,MACN;AAAA,IACF,KAAK,CAAC,MAAM;AAAA,MACV,SAAS,EAAE,MAAM,wBAAwB,EAAE,MAAM;AAAA,MACjD,cAAc,EAAE,MAAM,oBAAoB,EAAE,MAAM;AAAA,IACpD;AAAA,EACF;AAAA,EACA,gCAAgC;AAAA,IAC9B,SAAS,M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AA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,MACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,MACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/source/fetch-codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\n/** Why a fetcher result was rejected (`DK_FETCH_BAD_RESPONSE`); a closed set, never row data. */\nexport type BadResponse =\n | 'not-an-object'\n | 'rows-not-an-array'\n | 'rowCount-missing'\n | 'rowCount-invalid'\n | 'rowCount-too-small'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_MODE_ORDER: {\n /** The client-mode feature that runs before a server-mode one. */\n client: string\n clientStage: string\n /** The server-mode feature after it. */\n server: string\n serverStage: string\n }\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n /** The installed pipeline features (all client mode). */\n features: string[]\n phase: 'init' | 'setOptions'\n }\n DK_FETCH_FAILED: {\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n /** Whether rows were shown before (`false`: the first request failed). */\n hadRows: boolean\n }\n DK_FETCH_ABORTED: Record<string, never>\n DK_FETCH_BAD_RESPONSE: {\n problem: BadResponse\n /** The type of what was returned (`describeValue`), for the shape problems. */\n received?: string\n rows?: number\n rowCount?: number\n }\n }\n}\n\nconst BAD: Record<\n BadResponse,\n (d: { received?: string; rows?: number; rowCount?: number }) => string\n> = {\n 'not-an-object': (d) => `fetcher resolved with ${d.received}, not { rows, rowCount }`,\n 'rows-not-an-array': (d) => `fetcher result.rows is ${d.received}, not an array`,\n 'rowCount-missing': () =>\n 'fetcher result has no rowCount, and pagination is in server mode (it needs the total)',\n 'rowCount-invalid': (d) => `fetcher result.rowCount is ${d.received}, not an integer ≥ 0`,\n 'rowCount-too-small': (d) =>\n `fetcher result.rowCount (${d.rowCount}) is smaller than rows.length (${d.rows})`,\n}\n\nconst FETCHER = { kind: 'option', path: 'fetcher' } as const\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const fetchMessages: DiagnosticMessages<\n | 'DK_MODE_ORDER'\n | 'DK_FETCHER_WITHOUT_SERVER_MODE'\n | 'DK_FETCH_FAILED'\n | 'DK_FETCH_ABORTED'\n | 'DK_FETCH_BAD_RESPONSE'\n> = {\n DK_MODE_ORDER: {\n problem: (d) =>\n `feature \"${d.server}\" (${d.serverStage}) is in server mode, but \"${d.client}\" ` +\n `(${d.clientStage}) runs before it in client mode; server steps must come first`,\n impact: () =>\n 'the table was not created: the client step would only see the rows the server returned',\n fix: (d) => [\n `move \"${d.client}\" to the server too: ${d.client}({ mode: 'server' })`,\n `or handle \"${d.server}\" in the client: ${d.server}({ mode: 'client' }) (the default)`,\n ],\n },\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n problem: () => 'options.fetcher is set, but no feature is in server mode',\n impact: (d) =>\n d.phase === 'init'\n ? 'the table was not created: nothing would tell the fetcher what to load'\n : 'setOptions() was rejected; the previous options are kept',\n fix: (d) => [\n `set mode: 'server' on the features the server handles` +\n (d.features.length > 0 ? ` (installed: ${d.features.join(', ')})` : '') +\n `, e.g. pagination({ mode: 'server' })`,\n 'or remove fetcher and pass the rows as options.data (client mode)',\n ],\n },\n DK_FETCH_FAILED: {\n problem: (d) => `fetcher rejected or threw${d.errorName ? ` ${d.errorName}` : ''}`,\n impact: (d) =>\n d.hadRows\n ? \"the previous rows are kept (status: 'error')\"\n : \"nothing is shown yet (status: 'error', isInitialLoad: true)\",\n fix: () => [\n 'check the request the fetcher sends (the original error is context.cause, passed to ' +\n 'onDiagnostic)',\n 'retry from the UI with table.refetch(); the next state change (page, sort, filter, ' +\n 'query) or a new fetcher also runs it again',\n ],\n },\n DK_FETCH_ABORTED: {\n problem: () => 'a fetcher request was superseded by a newer one (latest wins)',\n impact: () => 'its result is ignored; the request was aborted through ctx.signal',\n fix: () => [\n 'nothing to fix; pass params.signal to fetch() so superseded requests stop on the network',\n ],\n },\n DK_FETCH_BAD_RESPONSE: {\n problem: (d) => BAD[d.problem](d),\n impact: () => \"the result was ignored and the previous rows are kept (status: 'error')\",\n fix: (d) => [\n d.problem === 'rowCount-too-small'\n ? 'return rowCount as the total number of matching rows on the server, not the page size'\n : 'resolve the fetcher with { rows: T[], rowCount: number } (rowCount = the total ' +\n 'number of matching rows on the server)',\n 'map your API response in the fetcher: async (p) => { const r = await api(p); ' +\n 'return { rows: r.items, rowCount: r.total } }',\n ],\n },\n}\n\n/** Codes owned by the data modes and the server source (spec §7.1, §8.3). */\nexport const fetchDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_MODE_ORDER',\n level: 'error',\n config: true,\n where: (d) => ({ kind: 'feature', name: d.server }),\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_MODE_ORDER,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCHER_WITHOUT_SERVER_MODE',\n level: 'error',\n config: true,\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCHER_WITHOUT_SERVER_MODE,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_FAILED',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_ABORTED',\n level: 'info',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_ABORTED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_BAD_RESPONSE',\n level: 'error',\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;AACF;","names":[]}
@@ -1,5 +1,6 @@
1
1
  // src/source/fetch-codes.ts
2
2
  import { defineDiagnostic } from "../diagnostics/catalog.js";
3
+ import "../diagnostics/process-guard.js";
3
4
  var BAD = {
4
5
  "not-an-object": (d) => `fetcher resolved with ${d.received}, not { rows, rowCount }`,
5
6
  "rows-not-an-array": (d) => `fetcher result.rows is ${d.received}, not an array`,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/source/fetch-codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\n\n/** Why a fetcher result was rejected (`DK_FETCH_BAD_RESPONSE`); a closed set, never row data. */\nexport type BadResponse =\n | 'not-an-object'\n | 'rows-not-an-array'\n | 'rowCount-missing'\n | 'rowCount-invalid'\n | 'rowCount-too-small'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_MODE_ORDER: {\n /** The client-mode feature that runs before a server-mode one. */\n client: string\n clientStage: string\n /** The server-mode feature after it. */\n server: string\n serverStage: string\n }\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n /** The installed pipeline features (all client mode). */\n features: string[]\n phase: 'init' | 'setOptions'\n }\n DK_FETCH_FAILED: {\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n /** Whether rows were shown before (`false`: the first request failed). */\n hadRows: boolean\n }\n DK_FETCH_ABORTED: Record<string, never>\n DK_FETCH_BAD_RESPONSE: {\n problem: BadResponse\n /** The type of what was returned (`describeValue`), for the shape problems. */\n received?: string\n rows?: number\n rowCount?: number\n }\n }\n}\n\nconst BAD: Record<\n BadResponse,\n (d: { received?: string; rows?: number; rowCount?: number }) => string\n> = {\n 'not-an-object': (d) => `fetcher resolved with ${d.received}, not { rows, rowCount }`,\n 'rows-not-an-array': (d) => `fetcher result.rows is ${d.received}, not an array`,\n 'rowCount-missing': () =>\n 'fetcher result has no rowCount, and pagination is in server mode (it needs the total)',\n 'rowCount-invalid': (d) => `fetcher result.rowCount is ${d.received}, not an integer ≥ 0`,\n 'rowCount-too-small': (d) =>\n `fetcher result.rowCount (${d.rowCount}) is smaller than rows.length (${d.rows})`,\n}\n\nconst FETCHER = { kind: 'option', path: 'fetcher' } as const\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const fetchMessages: DiagnosticMessages<\n | 'DK_MODE_ORDER'\n | 'DK_FETCHER_WITHOUT_SERVER_MODE'\n | 'DK_FETCH_FAILED'\n | 'DK_FETCH_ABORTED'\n | 'DK_FETCH_BAD_RESPONSE'\n> = {\n DK_MODE_ORDER: {\n problem: (d) =>\n `feature \"${d.server}\" (${d.serverStage}) is in server mode, but \"${d.client}\" ` +\n `(${d.clientStage}) runs before it in client mode; server steps must come first`,\n impact: () =>\n 'the table was not created: the client step would only see the rows the server returned',\n fix: (d) => [\n `move \"${d.client}\" to the server too: ${d.client}({ mode: 'server' })`,\n `or handle \"${d.server}\" in the client: ${d.server}({ mode: 'client' }) (the default)`,\n ],\n },\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n problem: () => 'options.fetcher is set, but no feature is in server mode',\n impact: (d) =>\n d.phase === 'init'\n ? 'the table was not created: nothing would tell the fetcher what to load'\n : 'setOptions() was rejected; the previous options are kept',\n fix: (d) => [\n `set mode: 'server' on the features the server handles` +\n (d.features.length > 0 ? ` (installed: ${d.features.join(', ')})` : '') +\n `, e.g. pagination({ mode: 'server' })`,\n 'or remove fetcher and pass the rows as options.data (client mode)',\n ],\n },\n DK_FETCH_FAILED: {\n problem: (d) => `fetcher rejected or threw${d.errorName ? ` ${d.errorName}` : ''}`,\n impact: (d) =>\n d.hadRows\n ? \"the previous rows are kept (status: 'error')\"\n : \"nothing is shown yet (status: 'error', isInitialLoad: true)\",\n fix: () => [\n 'check the request the fetcher sends (the original error is context.cause, passed to ' +\n 'onDiagnostic)',\n 'retry from the UI with table.refetch(); the next state change (page, sort, filter, ' +\n 'query) or a new fetcher also runs it again',\n ],\n },\n DK_FETCH_ABORTED: {\n problem: () => 'a fetcher request was superseded by a newer one (latest wins)',\n impact: () => 'its result is ignored; the request was aborted through ctx.signal',\n fix: () => [\n 'nothing to fix; pass params.signal to fetch() so superseded requests stop on the network',\n ],\n },\n DK_FETCH_BAD_RESPONSE: {\n problem: (d) => BAD[d.problem](d),\n impact: () => \"the result was ignored and the previous rows are kept (status: 'error')\",\n fix: (d) => [\n d.problem === 'rowCount-too-small'\n ? 'return rowCount as the total number of matching rows on the server, not the page size'\n : 'resolve the fetcher with { rows: T[], rowCount: number } (rowCount = the total ' +\n 'number of matching rows on the server)',\n 'map your API response in the fetcher: async (p) => { const r = await api(p); ' +\n 'return { rows: r.items, rowCount: r.total } }',\n ],\n },\n}\n\n/** Codes owned by the data modes and the server source (spec §7.1, §8.3). */\nexport const fetchDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_MODE_ORDER',\n level: 'error',\n config: true,\n where: (d) => ({ kind: 'feature', name: d.server }),\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_MODE_ORDER,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCHER_WITHOUT_SERVER_MODE',\n level: 'error',\n config: true,\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCHER_WITHOUT_SERVER_MODE,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_FAILED',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_ABORTED',\n level: 'info',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_ABORTED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_BAD_RESPONSE',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_BAD_RESPONSE,\n ),\n]\n"],"mappings":";AAAA,SAAkC,wBAAwB;AA0C1D,IAAM,MAGF;AA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B;AAAA,IACrB,SAAS,CAAC,MAAM,IAAI,EAAE,OAAO,EAAE,CAAC;AAAA,IAChC,QAAQ,MAAM;AAAA,IACd,KAAK,CAAC,MAAM;AAAA,MACV,EAAE,YAAY,uBACV,0FACA;AAAA,MAEJ;AAAA,IAEF;AAAA,EACF;AACF;AAGO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO,CAAC,OAAO,EAAE,MAAM,WAAW,MAAM,EAAE,OAAO;AAAA,IACnD;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/source/fetch-codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\n/** Why a fetcher result was rejected (`DK_FETCH_BAD_RESPONSE`); a closed set, never row data. */\nexport type BadResponse =\n | 'not-an-object'\n | 'rows-not-an-array'\n | 'rowCount-missing'\n | 'rowCount-invalid'\n | 'rowCount-too-small'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_MODE_ORDER: {\n /** The client-mode feature that runs before a server-mode one. */\n client: string\n clientStage: string\n /** The server-mode feature after it. */\n server: string\n serverStage: string\n }\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n /** The installed pipeline features (all client mode). */\n features: string[]\n phase: 'init' | 'setOptions'\n }\n DK_FETCH_FAILED: {\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n /** Whether rows were shown before (`false`: the first request failed). */\n hadRows: boolean\n }\n DK_FETCH_ABORTED: Record<string, never>\n DK_FETCH_BAD_RESPONSE: {\n problem: BadResponse\n /** The type of what was returned (`describeValue`), for the shape problems. */\n received?: string\n rows?: number\n rowCount?: number\n }\n }\n}\n\nconst BAD: Record<\n BadResponse,\n (d: { received?: string; rows?: number; rowCount?: number }) => string\n> = {\n 'not-an-object': (d) => `fetcher resolved with ${d.received}, not { rows, rowCount }`,\n 'rows-not-an-array': (d) => `fetcher result.rows is ${d.received}, not an array`,\n 'rowCount-missing': () =>\n 'fetcher result has no rowCount, and pagination is in server mode (it needs the total)',\n 'rowCount-invalid': (d) => `fetcher result.rowCount is ${d.received}, not an integer ≥ 0`,\n 'rowCount-too-small': (d) =>\n `fetcher result.rowCount (${d.rowCount}) is smaller than rows.length (${d.rows})`,\n}\n\nconst FETCHER = { kind: 'option', path: 'fetcher' } as const\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const fetchMessages: DiagnosticMessages<\n | 'DK_MODE_ORDER'\n | 'DK_FETCHER_WITHOUT_SERVER_MODE'\n | 'DK_FETCH_FAILED'\n | 'DK_FETCH_ABORTED'\n | 'DK_FETCH_BAD_RESPONSE'\n> = {\n DK_MODE_ORDER: {\n problem: (d) =>\n `feature \"${d.server}\" (${d.serverStage}) is in server mode, but \"${d.client}\" ` +\n `(${d.clientStage}) runs before it in client mode; server steps must come first`,\n impact: () =>\n 'the table was not created: the client step would only see the rows the server returned',\n fix: (d) => [\n `move \"${d.client}\" to the server too: ${d.client}({ mode: 'server' })`,\n `or handle \"${d.server}\" in the client: ${d.server}({ mode: 'client' }) (the default)`,\n ],\n },\n DK_FETCHER_WITHOUT_SERVER_MODE: {\n problem: () => 'options.fetcher is set, but no feature is in server mode',\n impact: (d) =>\n d.phase === 'init'\n ? 'the table was not created: nothing would tell the fetcher what to load'\n : 'setOptions() was rejected; the previous options are kept',\n fix: (d) => [\n `set mode: 'server' on the features the server handles` +\n (d.features.length > 0 ? ` (installed: ${d.features.join(', ')})` : '') +\n `, e.g. pagination({ mode: 'server' })`,\n 'or remove fetcher and pass the rows as options.data (client mode)',\n ],\n },\n DK_FETCH_FAILED: {\n problem: (d) => `fetcher rejected or threw${d.errorName ? ` ${d.errorName}` : ''}`,\n impact: (d) =>\n d.hadRows\n ? \"the previous rows are kept (status: 'error')\"\n : \"nothing is shown yet (status: 'error', isInitialLoad: true)\",\n fix: () => [\n 'check the request the fetcher sends (the original error is context.cause, passed to ' +\n 'onDiagnostic)',\n 'retry from the UI with table.refetch(); the next state change (page, sort, filter, ' +\n 'query) or a new fetcher also runs it again',\n ],\n },\n DK_FETCH_ABORTED: {\n problem: () => 'a fetcher request was superseded by a newer one (latest wins)',\n impact: () => 'its result is ignored; the request was aborted through ctx.signal',\n fix: () => [\n 'nothing to fix; pass params.signal to fetch() so superseded requests stop on the network',\n ],\n },\n DK_FETCH_BAD_RESPONSE: {\n problem: (d) => BAD[d.problem](d),\n impact: () => \"the result was ignored and the previous rows are kept (status: 'error')\",\n fix: (d) => [\n d.problem === 'rowCount-too-small'\n ? 'return rowCount as the total number of matching rows on the server, not the page size'\n : 'resolve the fetcher with { rows: T[], rowCount: number } (rowCount = the total ' +\n 'number of matching rows on the server)',\n 'map your API response in the fetcher: async (p) => { const r = await api(p); ' +\n 'return { rows: r.items, rowCount: r.total } }',\n ],\n },\n}\n\n/** Codes owned by the data modes and the server source (spec §7.1, §8.3). */\nexport const fetchDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_MODE_ORDER',\n level: 'error',\n config: true,\n where: (d) => ({ kind: 'feature', name: d.server }),\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_MODE_ORDER,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCHER_WITHOUT_SERVER_MODE',\n level: 'error',\n config: true,\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCHER_WITHOUT_SERVER_MODE,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_FAILED',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_ABORTED',\n level: 'info',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_ABORTED,\n ),\n defineDiagnostic(\n {\n code: 'DK_FETCH_BAD_RESPONSE',\n level: 'error',\n where: () => FETCHER,\n },\n (process.env.NODE_ENV !== \"production\") && fetchMessages.DK_FETCH_BAD_RESPONSE,\n ),\n]\n"],"mappings":";AAAA,SAAkC,wBAAwB;AAC1D,OAAO;AA0CP,IAAM,MAGF;AAAA,EACF,iBAAiB,CAAC,MAAM,yBAAyB,EAAE,QAAQ;AAAA,EAC3D,qBAAqB,CAAC,MAAM,0BAA0B,EAAE,QAAQ;AAAA,EAChE,oBAAoB,MAClB;AAAA,EACF,oBAAoB,CAAC,MAAM,8BAA8B,EAAE,QAAQ;AAAA,EACnE,sBAAsB,CAAC,MACrB,4BAA4B,EAAE,QAAQ,kCAAkC,EAAE,IAAI;AAClF;AAEA,IAAM,UAAU,EAAE,MAAM,UAAU,MAAM,UAAU;AAG3C,IAAM,gBAMT;AAAA,EACF,eAAe;AAAA,IACb,SAAS,CAAC,MACR,YAAY,EAAE,MAAM,MAAM,EAAE,WA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AAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,MAAM;AAAA,IACf;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
@@ -25,6 +25,7 @@ __export(codes_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(codes_exports);
27
27
  var import_catalog = require("../diagnostics/catalog.cjs");
28
+ var import_process_guard = require("../diagnostics/process-guard.cjs");
28
29
  var listSlices = (s) => s.length === 0 ? "a function updater" : s.map((k) => `"${k}"`).join(", ");
29
30
  var tableMessages = {
30
31
  DK_LISTENER_FAILED: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/table/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_LISTENER_FAILED: {\n /** Subscription number (1 = the first `subscribe` call). */\n listener: number\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n }\n DK_UPDATE_LOOP: {\n limit: number\n /** Slice names of the dropped update. */\n slices: string[]\n /** The listener whose update was dropped, if one was running. */\n listener?: number\n }\n DK_TABLE_DESTROYED: { method: string }\n DK_CONTROLLED_WITHOUT_HANDLER: {\n /** Controlled slices (keys of `options.state`). */\n slices: string[]\n /** `true` when an update to them was just dropped. */\n dropped: boolean\n }\n }\n}\n\nconst listSlices = (s: string[]) =>\n s.length === 0 ? 'a function updater' : s.map((k) => `\"${k}\"`).join(', ')\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const tableMessages: DiagnosticMessages<\n 'DK_LISTENER_FAILED' | 'DK_UPDATE_LOOP' | 'DK_TABLE_DESTROYED' | 'DK_CONTROLLED_WITHOUT_HANDLER'\n> = {\n DK_LISTENER_FAILED: {\n problem: (d) =>\n `subscribe listener #${d.listener} threw${d.errorName ? ` ${d.errorName}` : ''} ` +\n 'while being notified of a state change',\n impact: () => 'the other listeners still ran; the state change is committed',\n fix: (d) => [\n `catch errors inside listener #${d.listener} (the ${d.listener}. subscribe call); ` +\n 'listeners must not throw',\n 'the original error is context.cause (passed to onDiagnostic)',\n ],\n },\n DK_UPDATE_LOOP: {\n problem: (d) =>\n `state updates re-entered from listeners ${d.limit} rounds in a row ` +\n `(last update: ${listSlices(d.slices)})`,\n impact: () => 'the update was dropped to break the loop; the state is unchanged by it',\n fix: (d) => [\n `make ${d.listener === undefined ? 'the listener' : `listener #${d.listener}`} update ` +\n 'state only when the value differs (compare before calling setState)',\n 'derive the value instead of storing it, or move the update out of the listener',\n ],\n },\n DK_TABLE_DESTROYED: {\n problem: (d) => `table.${d.method}() was called after table.destroy()`,\n impact: () => 'the call was ignored (no-op)',\n fix: (d) => [\n `stop calling ${d.method}() after destroy(): unsubscribe / cancel timers in your cleanup`,\n 'create a new table with createTable() if the component is mounted again',\n ],\n },\n DK_CONTROLLED_WITHOUT_HANDLER: {\n problem: (d) =>\n `options.state controls ${listSlices(d.slices)} but options.onStateChange is missing`,\n impact: (d) =>\n d.dropped\n ? 'an update to these slices was dropped: interactions that change them are frozen'\n : 'interactions that change these slices are frozen (their updates are dropped)',\n fix: (d) => [\n 'pass onStateChange: (updater) => setMyState(updater), and feed the result back with ' +\n 'setOptions({ state })',\n `or remove ${listSlices(d.slices)} from options.state (use initialState) so the table ` +\n 'owns them',\n ],\n },\n}\n\n/** Codes owned by the store (§3.2, §8.3). */\nexport const tableDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_LISTENER_FAILED',\n level: 'error',\n where: (d) => ({ kind: 'operation', op: 'table.subscribe', slot: `listener #${d.listener}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_LISTENER_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_UPDATE_LOOP',\n level: 'error',\n where: (d) =>\n d.listener === undefined\n ? { kind: 'operation', op: 'table.setState' }\n : { kind: 'operation', op: 'table.setState', slot: `listener #${d.listener}` },\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_UPDATE_LOOP,\n ),\n defineDiagnostic(\n {\n code: 'DK_TABLE_DESTROYED',\n level: 'warn',\n where: (d) => ({ kind: 'operation', op: `table.${d.method}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_TABLE_DESTROYED,\n ),\n defineDiagnostic(\n {\n code: 'DK_CONTROLLED_WITHOUT_HANDLER',\n level: 'warn',\n where: (d) => ({ kind: 'option', path: `state.${d.slices[0] ?? ''}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_CONTROLLED_WITHOUT_HANDLER,\n ),\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0D;AA2B1D,IAAM,aAAa,CAAC,MAClB,EAAE,WAAW,IAAI,uBAAuB,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI;AAGnE,IAAM,gBAET;AAAA,EACF,oBAAoB;AAAA,IAClB,SAAS,CAAC,MACR,uBAAuB,EAAE,QAAQ,SAAS,EAAE,YAAY,IAAI,EAAE,SAAS,KAAK,EAAE;AAAA,IAEhF,QAAQ,MAA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,QAAQ,GAAG;AAAA,IACnF;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,MACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,aAAa,IAAI,SAAS,EAAE,MAAM,GAAG;AAAA,IAC9D;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,MACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG;AAAA,IACtE;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/table/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_LISTENER_FAILED: {\n /** Subscription number (1 = the first `subscribe` call). */\n listener: number\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n }\n DK_UPDATE_LOOP: {\n limit: number\n /** Slice names of the dropped update. */\n slices: string[]\n /** The listener whose update was dropped, if one was running. */\n listener?: number\n }\n DK_TABLE_DESTROYED: { method: string }\n DK_CONTROLLED_WITHOUT_HANDLER: {\n /** Controlled slices (keys of `options.state`). */\n slices: string[]\n /** `true` when an update to them was just dropped. */\n dropped: boolean\n }\n }\n}\n\nconst listSlices = (s: string[]) =>\n s.length === 0 ? 'a function updater' : s.map((k) => `\"${k}\"`).join(', ')\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const tableMessages: DiagnosticMessages<\n 'DK_LISTENER_FAILED' | 'DK_UPDATE_LOOP' | 'DK_TABLE_DESTROYED' | 'DK_CONTROLLED_WITHOUT_HANDLER'\n> = {\n DK_LISTENER_FAILED: {\n problem: (d) =>\n `subscribe listener #${d.listener} threw${d.errorName ? ` ${d.errorName}` : ''} ` +\n 'while being notified of a state change',\n impact: () => 'the other listeners still ran; the state change is committed',\n fix: (d) => [\n `catch errors inside listener #${d.listener} (the ${d.listener}. subscribe call); ` +\n 'listeners must not throw',\n 'the original error is context.cause (passed to onDiagnostic)',\n ],\n },\n DK_UPDATE_LOOP: {\n problem: (d) =>\n `state updates re-entered from listeners ${d.limit} rounds in a row ` +\n `(last update: ${listSlices(d.slices)})`,\n impact: () => 'the update was dropped to break the loop; the state is unchanged by it',\n fix: (d) => [\n `make ${d.listener === undefined ? 'the listener' : `listener #${d.listener}`} update ` +\n 'state only when the value differs (compare before calling setState)',\n 'derive the value instead of storing it, or move the update out of the listener',\n ],\n },\n DK_TABLE_DESTROYED: {\n problem: (d) => `table.${d.method}() was called after table.destroy()`,\n impact: () => 'the call was ignored (no-op)',\n fix: (d) => [\n `stop calling ${d.method}() after destroy(): unsubscribe / cancel timers in your cleanup`,\n 'create a new table with createTable() if the component is mounted again',\n ],\n },\n DK_CONTROLLED_WITHOUT_HANDLER: {\n problem: (d) =>\n `options.state controls ${listSlices(d.slices)} but options.onStateChange is missing`,\n impact: (d) =>\n d.dropped\n ? 'an update to these slices was dropped: interactions that change them are frozen'\n : 'interactions that change these slices are frozen (their updates are dropped)',\n fix: (d) => [\n 'pass onStateChange: (updater) => setMyState(updater), and feed the result back with ' +\n 'setOptions({ state })',\n `or remove ${listSlices(d.slices)} from options.state (use initialState) so the table ` +\n 'owns them',\n ],\n },\n}\n\n/** Codes owned by the store (§3.2, §8.3). */\nexport const tableDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_LISTENER_FAILED',\n level: 'error',\n where: (d) => ({ kind: 'operation', op: 'table.subscribe', slot: `listener #${d.listener}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_LISTENER_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_UPDATE_LOOP',\n level: 'error',\n where: (d) =>\n d.listener === undefined\n ? { kind: 'operation', op: 'table.setState' }\n : { kind: 'operation', op: 'table.setState', slot: `listener #${d.listener}` },\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_UPDATE_LOOP,\n ),\n defineDiagnostic(\n {\n code: 'DK_TABLE_DESTROYED',\n level: 'warn',\n where: (d) => ({ kind: 'operation', op: `table.${d.method}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_TABLE_DESTROYED,\n ),\n defineDiagnostic(\n {\n code: 'DK_CONTROLLED_WITHOUT_HANDLER',\n level: 'warn',\n where: (d) => ({ kind: 'option', path: `state.${d.slices[0] ?? ''}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_CONTROLLED_WITHOUT_HANDLER,\n ),\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0D;AAC1D,2BAAO;AA2BP,IAAM,aAAa,CAAC,MAClB,EAAE,WAAW,IAAI,uBAAuB,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI;AAGnE,IAAM,gBAET;AAAA,EACF,oBAAoB;AAAA,IAClB,SAAS,CAAC,MACR,uBAAuB,EAAE,QAAQ,SAAS,EAAE,YAAY,IAAI,EAAE,SAAS,KAAK,EAAE;AAAA,IAEhF,QAAQ,MAAM;AAAA,IACd,KAAK,CAAC,MAAM;AAAA,MACV,iCAAiC,EAAE,QAAQ,SAAS,EAAE,QAAQ;AAAA,MAE9D;AAAA,IACF;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS,CAAC,MACR,2CAA2C,EAAE,KAAK,kCACjC,WAAW,EAAE,MAAM,CAAC;AAAA,IACvC,QAAQ,MAAM;AAAA,IACd,KAAK,CAAC,MAAM;AAAA,MACV,QAAQ,EAAE,aAAa,SAAY,iBAAiB,aAAa,EAAE,QAAQ,EAA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AAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG;AAAA,IACtE;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
@@ -1,5 +1,6 @@
1
1
  // src/table/codes.ts
2
2
  import { defineDiagnostic } from "../diagnostics/catalog.js";
3
+ import "../diagnostics/process-guard.js";
3
4
  var listSlices = (s) => s.length === 0 ? "a function updater" : s.map((k) => `"${k}"`).join(", ");
4
5
  var tableMessages = {
5
6
  DK_LISTENER_FAILED: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/table/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_LISTENER_FAILED: {\n /** Subscription number (1 = the first `subscribe` call). */\n listener: number\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n }\n DK_UPDATE_LOOP: {\n limit: number\n /** Slice names of the dropped update. */\n slices: string[]\n /** The listener whose update was dropped, if one was running. */\n listener?: number\n }\n DK_TABLE_DESTROYED: { method: string }\n DK_CONTROLLED_WITHOUT_HANDLER: {\n /** Controlled slices (keys of `options.state`). */\n slices: string[]\n /** `true` when an update to them was just dropped. */\n dropped: boolean\n }\n }\n}\n\nconst listSlices = (s: string[]) =>\n s.length === 0 ? 'a function updater' : s.map((k) => `\"${k}\"`).join(', ')\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const tableMessages: DiagnosticMessages<\n 'DK_LISTENER_FAILED' | 'DK_UPDATE_LOOP' | 'DK_TABLE_DESTROYED' | 'DK_CONTROLLED_WITHOUT_HANDLER'\n> = {\n DK_LISTENER_FAILED: {\n problem: (d) =>\n `subscribe listener #${d.listener} threw${d.errorName ? ` ${d.errorName}` : ''} ` +\n 'while being notified of a state change',\n impact: () => 'the other listeners still ran; the state change is committed',\n fix: (d) => [\n `catch errors inside listener #${d.listener} (the ${d.listener}. subscribe call); ` +\n 'listeners must not throw',\n 'the original error is context.cause (passed to onDiagnostic)',\n ],\n },\n DK_UPDATE_LOOP: {\n problem: (d) =>\n `state updates re-entered from listeners ${d.limit} rounds in a row ` +\n `(last update: ${listSlices(d.slices)})`,\n impact: () => 'the update was dropped to break the loop; the state is unchanged by it',\n fix: (d) => [\n `make ${d.listener === undefined ? 'the listener' : `listener #${d.listener}`} update ` +\n 'state only when the value differs (compare before calling setState)',\n 'derive the value instead of storing it, or move the update out of the listener',\n ],\n },\n DK_TABLE_DESTROYED: {\n problem: (d) => `table.${d.method}() was called after table.destroy()`,\n impact: () => 'the call was ignored (no-op)',\n fix: (d) => [\n `stop calling ${d.method}() after destroy(): unsubscribe / cancel timers in your cleanup`,\n 'create a new table with createTable() if the component is mounted again',\n ],\n },\n DK_CONTROLLED_WITHOUT_HANDLER: {\n problem: (d) =>\n `options.state controls ${listSlices(d.slices)} but options.onStateChange is missing`,\n impact: (d) =>\n d.dropped\n ? 'an update to these slices was dropped: interactions that change them are frozen'\n : 'interactions that change these slices are frozen (their updates are dropped)',\n fix: (d) => [\n 'pass onStateChange: (updater) => setMyState(updater), and feed the result back with ' +\n 'setOptions({ state })',\n `or remove ${listSlices(d.slices)} from options.state (use initialState) so the table ` +\n 'owns them',\n ],\n },\n}\n\n/** Codes owned by the store (§3.2, §8.3). */\nexport const tableDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_LISTENER_FAILED',\n level: 'error',\n where: (d) => ({ kind: 'operation', op: 'table.subscribe', slot: `listener #${d.listener}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_LISTENER_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_UPDATE_LOOP',\n level: 'error',\n where: (d) =>\n d.listener === undefined\n ? { kind: 'operation', op: 'table.setState' }\n : { kind: 'operation', op: 'table.setState', slot: `listener #${d.listener}` },\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_UPDATE_LOOP,\n ),\n defineDiagnostic(\n {\n code: 'DK_TABLE_DESTROYED',\n level: 'warn',\n where: (d) => ({ kind: 'operation', op: `table.${d.method}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_TABLE_DESTROYED,\n ),\n defineDiagnostic(\n {\n code: 'DK_CONTROLLED_WITHOUT_HANDLER',\n level: 'warn',\n where: (d) => ({ kind: 'option', path: `state.${d.slices[0] ?? ''}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_CONTROLLED_WITHOUT_HANDLER,\n ),\n]\n"],"mappings":";AAAA,SAAkC,wBAAwB;AA2B1D,IAAM,aAAa,CAAC,MAClB,EAAE,WAAW,IAAI,uBAAuB,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI;AAGnE,IAAM,gBAET;AAAA,EACF,oBAAoB;AAAA,IAClB,SAAS,CAAC,MACR,uBAAuB,EAAE,QAAQ,SAAS,EAAE,YAAY,IAAI,EAAE,SAAS,KAAK,EAAE;AAAA,IAEhF,QAAQ,MAAM;AAAA,IACd,KAAK,CAAC,MAAM;AAAA,MACV,iCAAiC,EAAE,QAAQ,SAAS,EAAE,QAAQ;AAAA,MAE9D;AAAA,IACF;AAAA,EACF;AAAA,EACA,gBAAgB;AAAA,IACd,SAAS,CAAC,MACR,2CAA2C,EAAE,KAAK,kCACjC,WAAW,EAAE,MAAM,CAAC;AAAA,IACvC,QAAQ,MAAM;AAAA,IACd,KAAK,CAAC,MAAM;AAAA,MACV,QAAQ,EAAE,aAAa,SAAY,iBAAiB,aAAa,EAAE,QAAQ,EAAE;AAAA,MAE7E;AAAA,IACF;AAAA,EACF;AAAA,EACA,oBAAoB;AAAA,IAClB,SAAS,CAAC,MAAM,SAAS,EAAE,MAAM;AAAA,IACjC,QAAQ,MAAM;AAAA,IACd,KAAK,CAAC,MAAM;AAAA,MACV,gBAAgB,EAAE,MAAM;AAAA,MACxB;A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src/table/codes.ts"],"sourcesContent":["import { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_LISTENER_FAILED: {\n /** Subscription number (1 = the first `subscribe` call). */\n listener: number\n /** `error.name` only; the full error is `context.cause`. */\n errorName?: string\n }\n DK_UPDATE_LOOP: {\n limit: number\n /** Slice names of the dropped update. */\n slices: string[]\n /** The listener whose update was dropped, if one was running. */\n listener?: number\n }\n DK_TABLE_DESTROYED: { method: string }\n DK_CONTROLLED_WITHOUT_HANDLER: {\n /** Controlled slices (keys of `options.state`). */\n slices: string[]\n /** `true` when an update to them was just dropped. */\n dropped: boolean\n }\n }\n}\n\nconst listSlices = (s: string[]) =>\n s.length === 0 ? 'a function updater' : s.map((k) => `\"${k}\"`).join(', ')\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const tableMessages: DiagnosticMessages<\n 'DK_LISTENER_FAILED' | 'DK_UPDATE_LOOP' | 'DK_TABLE_DESTROYED' | 'DK_CONTROLLED_WITHOUT_HANDLER'\n> = {\n DK_LISTENER_FAILED: {\n problem: (d) =>\n `subscribe listener #${d.listener} threw${d.errorName ? ` ${d.errorName}` : ''} ` +\n 'while being notified of a state change',\n impact: () => 'the other listeners still ran; the state change is committed',\n fix: (d) => [\n `catch errors inside listener #${d.listener} (the ${d.listener}. subscribe call); ` +\n 'listeners must not throw',\n 'the original error is context.cause (passed to onDiagnostic)',\n ],\n },\n DK_UPDATE_LOOP: {\n problem: (d) =>\n `state updates re-entered from listeners ${d.limit} rounds in a row ` +\n `(last update: ${listSlices(d.slices)})`,\n impact: () => 'the update was dropped to break the loop; the state is unchanged by it',\n fix: (d) => [\n `make ${d.listener === undefined ? 'the listener' : `listener #${d.listener}`} update ` +\n 'state only when the value differs (compare before calling setState)',\n 'derive the value instead of storing it, or move the update out of the listener',\n ],\n },\n DK_TABLE_DESTROYED: {\n problem: (d) => `table.${d.method}() was called after table.destroy()`,\n impact: () => 'the call was ignored (no-op)',\n fix: (d) => [\n `stop calling ${d.method}() after destroy(): unsubscribe / cancel timers in your cleanup`,\n 'create a new table with createTable() if the component is mounted again',\n ],\n },\n DK_CONTROLLED_WITHOUT_HANDLER: {\n problem: (d) =>\n `options.state controls ${listSlices(d.slices)} but options.onStateChange is missing`,\n impact: (d) =>\n d.dropped\n ? 'an update to these slices was dropped: interactions that change them are frozen'\n : 'interactions that change these slices are frozen (their updates are dropped)',\n fix: (d) => [\n 'pass onStateChange: (updater) => setMyState(updater), and feed the result back with ' +\n 'setOptions({ state })',\n `or remove ${listSlices(d.slices)} from options.state (use initialState) so the table ` +\n 'owns them',\n ],\n },\n}\n\n/** Codes owned by the store (§3.2, §8.3). */\nexport const tableDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_LISTENER_FAILED',\n level: 'error',\n where: (d) => ({ kind: 'operation', op: 'table.subscribe', slot: `listener #${d.listener}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_LISTENER_FAILED,\n ),\n defineDiagnostic(\n {\n code: 'DK_UPDATE_LOOP',\n level: 'error',\n where: (d) =>\n d.listener === undefined\n ? { kind: 'operation', op: 'table.setState' }\n : { kind: 'operation', op: 'table.setState', slot: `listener #${d.listener}` },\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_UPDATE_LOOP,\n ),\n defineDiagnostic(\n {\n code: 'DK_TABLE_DESTROYED',\n level: 'warn',\n where: (d) => ({ kind: 'operation', op: `table.${d.method}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_TABLE_DESTROYED,\n ),\n defineDiagnostic(\n {\n code: 'DK_CONTROLLED_WITHOUT_HANDLER',\n level: 'warn',\n where: (d) => ({ kind: 'option', path: `state.${d.slices[0] ?? ''}` }),\n },\n (process.env.NODE_ENV !== \"production\") && tableMessages.DK_CONTROLLED_WITHOUT_HANDLER,\n ),\n]\n"],"mappings":";AAAA,SAAkC,w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mBAAmB,MAAM,aAAa,EAAE,QAAQ,GAAG;AAAA,IAC7F;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,MACN,EAAE,aAAa,SACX,EAAE,MAAM,aAAa,IAAI,iBAAiB,IAC1C,EAAE,MAAM,aAAa,IAAI,kBAAkB,MAAM,aAAa,EAAE,QAAQ,GAAG;AAAA,IACnF;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,aAAa,IAAI,SAAS,EAAE,MAAM,GAAG;AAAA,IAC9D;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AAAA,EACA;AAAA,IACE;AAAA,MACE,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO,CAAC,OAAO,EAAE,MAAM,UAAU,MAAM,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG;AAAA,IACtE;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
@@ -27,8 +27,10 @@ var import_codes = require("../catalog/codes.cjs");
27
27
  var import_validator = require("../catalog/validator.cjs");
28
28
  var import_build = require("../diagnostics/build.cjs");
29
29
  var import_catalog = require("../diagnostics/catalog.cjs");
30
+ var import_process_guard = require("../diagnostics/process-guard.cjs");
30
31
  var import_explain = require("../diagnostics/explain.cjs");
31
32
  var import_hub = require("../diagnostics/hub.cjs");
33
+ var import_redact = require("../diagnostics/redact.cjs");
32
34
  var import_tracer = require("../diagnostics/tracer.cjs");
33
35
  var import_runtime = require("../feature/runtime.cjs");
34
36
  var import_data_checks = require("../ingest/data-checks.cjs");
@@ -65,7 +67,23 @@ var RANK = [
65
67
  "error"
66
68
  ];
67
69
  var isThenable = (v) => v != null && typeof v.then === "function";
68
- var freeze = (s) => process.env.NODE_ENV !== "production" ? Object.freeze(s) : s;
70
+ var deepFrozen = process.env.NODE_ENV !== "production" ? /* @__PURE__ */ new WeakSet() : void 0;
71
+ function deepFreeze(v) {
72
+ if (v === null || typeof v !== "object" || deepFrozen?.has(v)) return;
73
+ const isArray = Array.isArray(v);
74
+ if (!isArray) {
75
+ const proto = Object.getPrototypeOf(v);
76
+ if (proto !== Object.prototype && proto !== null) return;
77
+ }
78
+ deepFrozen?.add(v);
79
+ Object.freeze(v);
80
+ if (isArray) for (let i = 0; i < v.length; i++) deepFreeze(v[i]);
81
+ else for (const k in v) deepFreeze(v[k]);
82
+ }
83
+ var freeze = (s) => {
84
+ if (process.env.NODE_ENV !== "production") deepFreeze(s);
85
+ return s;
86
+ };
69
87
  var columnId = (c) => c.key ?? c.id;
70
88
  function createTable(initialOptions) {
71
89
  let options = { ...initialOptions };
@@ -118,7 +136,11 @@ function createTable(initialOptions) {
118
136
  ...typeof redactOption === "string" ? { level: redactOption } : {},
119
137
  ...typeof redactOption === "function" ? { redact: redactOption } : {},
120
138
  sensitiveColumns,
121
- rowKeySensitive: () => typeof options.rowKey === "string" && sensitiveColumns().includes(options.rowKey)
139
+ // A rowKey path into (or above) a sensitive column reads its data too (#45).
140
+ rowKeySensitive: () => {
141
+ const k = options.rowKey;
142
+ return typeof k === "string" && sensitiveColumns().some((c) => (0, import_redact.pathsOverlap)(k, c));
143
+ }
122
144
  };
123
145
  const hub = (0, import_hub.createDiagnostics)({
124
146
  ...options.name === void 0 ? {} : { name: options.name },
@@ -159,7 +181,7 @@ function createTable(initialOptions) {
159
181
  options.invalidRows ?? "drop",
160
182
  () => options.columns
161
183
  );
162
- if (options.schema && !schemaIngest) unwrapped("schema", "withSchema");
184
+ if (options.schema && !schemaIngest) unwrapped("schema", options.schema, "withSchema");
163
185
  function sensitiveColumns() {
164
186
  const out = [];
165
187
  for (const c of options.columns ?? EMPTY) {
@@ -329,7 +351,7 @@ function createTable(initialOptions) {
329
351
  if (next === data) return;
330
352
  data = next;
331
353
  pending = true;
332
- dataChecks?.check(data, options.columns);
354
+ if (process.env.NODE_ENV !== "production") dataChecks?.check(data, options.columns);
333
355
  rowModelDirty = true;
334
356
  }
335
357
  const runner = (0, import_runner.createPipeline)({
@@ -485,7 +507,7 @@ function createTable(initialOptions) {
485
507
  );
486
508
  });
487
509
  } finally {
488
- if (!fetched) dataCheck?.remember(options.data);
510
+ if (process.env.NODE_ENV !== "production" && !fetched) dataCheck?.remember(options.data);
489
511
  }
490
512
  }
491
513
  function update(updater, slot) {
@@ -554,7 +576,7 @@ function createTable(initialOptions) {
554
576
  if (next.rowCount !== previous.rowCount) pending = true;
555
577
  if (next.fetcher !== previous.fetcher) server?.reset();
556
578
  if (next.data !== previous.data) ingest();
557
- else {
579
+ else if (process.env.NODE_ENV !== "production") {
558
580
  if ("data" in partial) dataCheck?.check(next.data);
559
581
  if (next.columns !== previous.columns) dataChecks?.check(data, next.columns);
560
582
  }
@@ -625,13 +647,20 @@ function createTable(initialOptions) {
625
647
  function useServer(fetcher, phase) {
626
648
  const factory = fetcher?.[import_server_brand.SERVER_SOURCE];
627
649
  if (factory) server = use(factory);
628
- else if (fetcher) unwrapped("fetcher", "withFetcher", phase);
650
+ else if (fetcher) unwrapped("fetcher", fetcher, "withFetcher", "server", phase);
629
651
  return server;
630
652
  }
631
- function unwrapped(path, wrap, phase = "init") {
653
+ function unwrapped(path, value, wrap, entry = path, phase = "init") {
632
654
  return (0, import_build.throwConfigError)(
633
655
  "DK_INVALID_OPTION",
634
- { path, expected: `${wrap}(${path})`, received: path, suggestions: [], phase },
656
+ {
657
+ path,
658
+ expected: `wrapped|${wrap}|${path}|${entry}`,
659
+ // prose key (diagnostics/prose.ts)
660
+ received: typeof value,
661
+ suggestions: [],
662
+ phase
663
+ },
635
664
  { table: hub.table, trigger: phase }
636
665
  );
637
666
  }
@@ -653,6 +682,7 @@ function createTable(initialOptions) {
653
682
  }
654
683
  (0, import_internals.setTableInternals)(table, {
655
684
  features: pipeline,
685
+ name: options.name,
656
686
  rowCount: () => typeof options.fetcher === "function" ? server?.rowCount() : options.rowCount,
657
687
  hasFetcher: () => typeof options.fetcher === "function",
658
688
  emit: hub.emit,