@tailor-platform/sdk 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/README.md +1 -1
  3. package/dist/aigateway-DsWDjzk4.mjs +2 -0
  4. package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
  5. package/dist/application-DFOUovmN.mjs +1 -0
  6. package/dist/application-D_4vg1KR.mjs +192 -0
  7. package/dist/application-D_4vg1KR.mjs.map +1 -0
  8. package/dist/assert-WeXvmG4j.mjs +2 -0
  9. package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
  10. package/dist/authconnection-CynFBIv8.mjs +2 -0
  11. package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
  12. package/dist/brand-C8nMKhJC.mjs +2 -0
  13. package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
  14. package/dist/cli/commands/deploy/deploy.d.mts +2 -2
  15. package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
  16. package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
  17. package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
  18. package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
  19. package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
  20. package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
  21. package/dist/cli/commands/executor/jobs.d.mts +1 -1
  22. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
  23. package/dist/cli/commands/show.d.mts +1 -1
  24. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +15 -15
  25. package/dist/cli/commands/tailordb/migrate/generate.d.mts +7 -3
  26. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
  27. package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
  28. package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
  29. package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
  30. package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
  31. package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
  32. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
  33. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
  34. package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
  35. package/dist/cli/lib.d.mts +8 -4
  36. package/dist/cli/lib.mjs +1 -9
  37. package/dist/cli/lib.mjs.map +1 -1
  38. package/dist/cli/main.mjs +1170 -7686
  39. package/dist/cli/main.mjs.map +1 -1
  40. package/dist/cli/shared/seed-chunker.d.mts +5 -5
  41. package/dist/cli/ts-hook.mjs +3 -1
  42. package/dist/completion/zsh-worker.zsh +99 -18
  43. package/dist/configure/config/index.d.mts +2 -2
  44. package/dist/configure/config/types.d.mts +2 -2
  45. package/dist/configure/index.d.mts +49 -12
  46. package/dist/configure/index.mjs +1 -1267
  47. package/dist/configure/index.mjs.map +1 -1
  48. package/dist/configure/services/aigateway/index.d.mts +5 -4
  49. package/dist/configure/services/aigateway/types.d.mts +6 -1
  50. package/dist/configure/services/auth/types.d.mts +3 -3
  51. package/dist/configure/services/idp/types.d.mts +1 -1
  52. package/dist/configure/services/tailordb/permission.d.mts +1 -1
  53. package/dist/configure/services/tailordb/schema.d.mts +5 -9
  54. package/dist/configure/services/tailordb/types.d.mts +8 -5
  55. package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
  56. package/dist/configure/services/workflow/job.d.mts +12 -2
  57. package/dist/configure/types/auth-namespace-name.d.mts +18 -0
  58. package/dist/configure/types/field.types.d.mts +1 -1
  59. package/dist/configure/types/permission-operand.types.d.mts +1 -1
  60. package/dist/context-D0QjfxzD.mjs +2 -0
  61. package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
  62. package/dist/crashreport-B-_HTKLr.mjs +42 -0
  63. package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
  64. package/dist/crashreport-BmsRIdpy.mjs +1 -0
  65. package/dist/errors-DSEXKRVD.mjs +2 -0
  66. package/dist/errors-DSEXKRVD.mjs.map +1 -0
  67. package/dist/file-COPYfju_.mjs +2 -0
  68. package/dist/file-COPYfju_.mjs.map +1 -0
  69. package/dist/globals-CMHSnj4w.mjs +2 -0
  70. package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
  71. package/dist/iconv-DlFMt2gW.mjs +2 -0
  72. package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
  73. package/dist/idp-G_ojPBB5.mjs +2 -0
  74. package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
  75. package/dist/interceptor-DQg3cR_9.mjs +2 -0
  76. package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
  77. package/dist/kysely/index.mjs +1 -31
  78. package/dist/kysely/index.mjs.map +1 -1
  79. package/dist/kysely-type-BTi3BMtL.mjs +43 -0
  80. package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
  81. package/dist/logger-BcGy-u7G.mjs +9 -0
  82. package/dist/{logger-DSdExfor.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
  83. package/dist/logger-DP2BjQ93.mjs +2 -0
  84. package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
  85. package/dist/multiline-EyzjEwn9.mjs +3 -0
  86. package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
  87. package/dist/node-builtins-oBl7EbyV.mjs +2 -0
  88. package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
  89. package/dist/package-json-C690ceex.mjs +2 -0
  90. package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
  91. package/dist/package-json-CmqhDJ__.mjs +1 -0
  92. package/dist/parser/service/tailordb/type-source.d.mts +5 -5
  93. package/dist/parser/service/tailordb/types.d.mts +4 -4
  94. package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
  95. package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
  96. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  97. package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
  98. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  99. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  100. package/dist/plugin/builtin/file-utils/index.mjs +22 -101
  101. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  102. package/dist/plugin/builtin/kysely-type/index.d.mts +9 -2
  103. package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
  104. package/dist/plugin/builtin/seed/index.d.mts +5 -0
  105. package/dist/plugin/builtin/seed/index.mjs +1 -3
  106. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -6
  107. package/dist/plugin/get-generated-table.d.mts +16 -0
  108. package/dist/plugin/index.d.mts +3 -2
  109. package/dist/plugin/index.mjs +1 -251
  110. package/dist/plugin/index.mjs.map +1 -1
  111. package/dist/plugin/types.d.mts +32 -25
  112. package/dist/plugin/with-context.d.mts +4 -4
  113. package/dist/register-ts-hook-Drnaproy.mjs +640 -0
  114. package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
  115. package/dist/registry-HlEaGvl5.mjs +2 -0
  116. package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
  117. package/dist/repl-editor-BG1aDOfH.mjs +2 -0
  118. package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
  119. package/dist/runtime/aigateway.mjs +1 -3
  120. package/dist/runtime/authconnection.mjs +1 -3
  121. package/dist/runtime/context.mjs +1 -3
  122. package/dist/runtime/file.d.mts +28 -28
  123. package/dist/runtime/file.mjs +1 -3
  124. package/dist/runtime/globals.mjs +1 -1
  125. package/dist/runtime/iconv.mjs +1 -3
  126. package/dist/runtime/idp.mjs +1 -3
  127. package/dist/runtime/index.mjs +1 -11
  128. package/dist/runtime/logger.mjs +1 -3
  129. package/dist/runtime/secretmanager.mjs +1 -3
  130. package/dist/runtime/types.d.mts +1 -1
  131. package/dist/runtime/workflow.mjs +1 -3
  132. package/dist/schema-Ze_dI5VX.mjs +2 -0
  133. package/dist/schema-Ze_dI5VX.mjs.map +1 -0
  134. package/dist/secret-file-C9wp_FCX.mjs +2 -0
  135. package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
  136. package/dist/secretmanager-5olfnI1b.mjs +2 -0
  137. package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
  138. package/dist/secretmanager-vHQoXdQz.mjs +2 -0
  139. package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
  140. package/dist/seed/index.d.mts +4 -4
  141. package/dist/seed/index.mjs +8 -244
  142. package/dist/seed/index.mjs.map +1 -1
  143. package/dist/seed-DwqRFdqP.mjs +207 -0
  144. package/dist/seed-DwqRFdqP.mjs.map +1 -0
  145. package/dist/service-BVe9u2Rt.mjs +7 -0
  146. package/dist/service-BVe9u2Rt.mjs.map +1 -0
  147. package/dist/service-CpZELSBa.mjs +1 -0
  148. package/dist/service-DlgaUO4V.mjs +2 -0
  149. package/dist/{service-hZskxZmg.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
  150. package/dist/service_pb-DGKCLuAs.mjs +2 -0
  151. package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
  152. package/dist/service_pb-_aeFE-Nv.mjs +1 -0
  153. package/dist/telemetry-Bklv9kQY.mjs +2 -0
  154. package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
  155. package/dist/telemetry-DXHP3VVi.mjs +1 -0
  156. package/dist/type-source--ZNcV8RJ.mjs +2 -0
  157. package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
  158. package/dist/types/aigateway.generated.d.mts +2 -2
  159. package/dist/types/auth.generated.d.mts +3 -3
  160. package/dist/types/executor.generated.d.mts +2 -2
  161. package/dist/types/tailordb.generated.d.mts +12 -12
  162. package/dist/user-agent-vdHYF3QL.mjs +2 -0
  163. package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
  164. package/dist/utils/test/index.d.mts +4 -4
  165. package/dist/utils/test/index.mjs +1 -109
  166. package/dist/utils/test/index.mjs.map +1 -1
  167. package/dist/vitest/environment.mjs +1 -41
  168. package/dist/vitest/environment.mjs.map +1 -1
  169. package/dist/vitest/index.mjs +1 -1980
  170. package/dist/vitest/index.mjs.map +1 -1
  171. package/dist/vitest/mocks/file.d.mts +8 -8
  172. package/dist/vitest/setup.mjs +1 -140
  173. package/dist/vitest/setup.mjs.map +1 -1
  174. package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
  175. package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
  176. package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
  177. package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
  178. package/dist/workflow-Cs9ISw6j.mjs +2 -0
  179. package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
  180. package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
  181. package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
  182. package/docs/cli/application.md +3 -1
  183. package/docs/cli/function.md +77 -13
  184. package/docs/cli/setup.md +24 -14
  185. package/docs/cli/tailordb.md +32 -30
  186. package/docs/cli/workspace.md +2 -2
  187. package/docs/cli-reference.md +23 -22
  188. package/docs/configuration.md +2 -2
  189. package/docs/github-actions.md +10 -9
  190. package/docs/migration/v2.md +16 -4
  191. package/docs/migration/v3.md +123 -0
  192. package/docs/plugin/custom.md +130 -85
  193. package/docs/plugin/index.md +3 -3
  194. package/docs/quickstart.md +1 -1
  195. package/docs/services/aigateway.md +33 -9
  196. package/docs/services/executor.md +5 -1
  197. package/docs/services/tailordb-migration.md +68 -54
  198. package/docs/services/tailordb.md +7 -7
  199. package/docs/services/workflow.md +10 -9
  200. package/docs/testing.md +1 -1
  201. package/package.json +16 -16
  202. package/postinstall.mjs +1 -1
  203. package/dist/aigateway-DR4Kwuik.mjs +0 -9
  204. package/dist/application-BZfk4HKm.mjs +0 -3
  205. package/dist/application-F-nl107y.mjs +0 -6019
  206. package/dist/application-F-nl107y.mjs.map +0 -1
  207. package/dist/assert-DBxo8jPo.mjs +0 -9
  208. package/dist/authconnection-CZvi9ANm.mjs +0 -9
  209. package/dist/brand-Eo4pLXPJ.mjs +0 -36
  210. package/dist/context-DYQVYWqZ.mjs +0 -23
  211. package/dist/crashreport-CIIfLnoO.mjs +0 -423
  212. package/dist/crashreport-CINZ5dVN.mjs +0 -3
  213. package/dist/errors-BVb6vYGy.mjs +0 -89
  214. package/dist/errors-BVb6vYGy.mjs.map +0 -1
  215. package/dist/file-BUcmVIH2.mjs +0 -58
  216. package/dist/file-BUcmVIH2.mjs.map +0 -1
  217. package/dist/globals-B2nlxBrz.mjs +0 -126
  218. package/dist/iconv-QWaZh0TT.mjs +0 -38
  219. package/dist/idp-RA_swu-h.mjs +0 -82
  220. package/dist/interceptor-e33JtsC-.mjs +0 -33
  221. package/dist/logger-BtX0suGY.mjs +0 -48
  222. package/dist/logger-DSdExfor.mjs +0 -358
  223. package/dist/multiline-sfHpTZZK.mjs +0 -38
  224. package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
  225. package/dist/package-json-8b0O9TlX.mjs +0 -17
  226. package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
  227. package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
  228. package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
  229. package/dist/plugin/builtin/seed/types.d.mts +0 -2
  230. package/dist/plugin/get-generated-type.d.mts +0 -16
  231. package/dist/register-ts-hook-ClI226n2.mjs +0 -25543
  232. package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
  233. package/dist/registry-BIGVUrMB.mjs +0 -54
  234. package/dist/repl-editor-BCozyiNq.mjs +0 -251
  235. package/dist/schema--xYWRGfe.mjs +0 -639
  236. package/dist/schema--xYWRGfe.mjs.map +0 -1
  237. package/dist/secret-file-C3J4Gy8r.mjs +0 -64
  238. package/dist/secretmanager-CYlpffsz.mjs +0 -13
  239. package/dist/secretmanager-IY4UvinW.mjs +0 -131
  240. package/dist/seed-xqM9WIHP.mjs +0 -483
  241. package/dist/seed-xqM9WIHP.mjs.map +0 -1
  242. package/dist/service-C_WpbKHu.mjs +0 -898
  243. package/dist/service-C_WpbKHu.mjs.map +0 -1
  244. package/dist/service-D1RCdzIL.mjs +0 -3
  245. package/dist/service-hZskxZmg.mjs +0 -131
  246. package/dist/service_pb-BEWj1pOV.mjs +0 -167
  247. package/dist/service_pb-BjlhvK9E.mjs +0 -3
  248. package/dist/telemetry-BRVdwh14.mjs +0 -84
  249. package/dist/telemetry-CkbkeJxl.mjs +0 -3
  250. package/dist/type-source-DH_LH20p.mjs +0 -13
  251. package/dist/type-source-DH_LH20p.mjs.map +0 -1
  252. package/dist/user-agent-Bgsszb5I.mjs +0 -28
  253. package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
  254. package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
  255. package/dist/wait-point-registry-TL99zotw.mjs +0 -47
  256. package/dist/workflow-Bamae_Yc.mjs +0 -34
  257. package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
@@ -1,358 +0,0 @@
1
- import { formatWithOptions, stripVTControlCharacters, styleText } from "node:util";
2
- import { formatDistanceToNowStrict } from "date-fns";
3
- import { eastAsianWidth } from "get-east-asian-width";
4
-
5
- //#region ../shared/src/color.ts
6
- const style = (name) => (text) => styleText(name, text, { validateStream: false });
7
- /**
8
- * Style functions by name, so call sites read `color.bold(text)`. Styling is
9
- * always applied; `renderFor` drops it again when the destination stream has no
10
- * color support. Add a name here when a package needs one that is not listed.
11
- */
12
- const color = {
13
- bold: style("bold"),
14
- dim: style("dim"),
15
- italic: style("italic"),
16
- gray: style("gray"),
17
- white: style("white"),
18
- red: style("red"),
19
- green: style("green"),
20
- yellow: style("yellow"),
21
- cyan: style("cyan"),
22
- magenta: style("magenta"),
23
- redBright: style("redBright"),
24
- greenBright: style("greenBright"),
25
- cyanBright: style("cyanBright")
26
- };
27
- const supportsColor = (stream) => {
28
- const forced = process.env.FORCE_COLOR;
29
- if (forced !== void 0) return forced !== "0" && forced !== "false";
30
- if (process.env.NODE_DISABLE_COLORS !== void 0) return false;
31
- if ((process.env.NO_COLOR ?? "") !== "") return false;
32
- if (process.env.TERM === "dumb") return false;
33
- return stream.isTTY === true;
34
- };
35
- /**
36
- * Prepares styled text for the stream it is written to.
37
- * @param stream - Stream the text is written to
38
- * @param text - Styled text
39
- * @returns Text with styling removed when the stream has no color support
40
- */
41
- function renderFor(stream, text) {
42
- return supportsColor(stream) ? text : stripVTControlCharacters(text);
43
- }
44
-
45
- //#endregion
46
- //#region src/cli/shared/ascii-table.ts
47
- const ANSI_ESCAPE_PATTERN = /\x1b\[[0-9;]*m/g;
48
- const CARRIAGE_RETURN_PATTERN = /\r\n?/g;
49
- const graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
50
- function maxOf(values, fallback = 0) {
51
- return values.reduce((max, value) => value > max ? value : max, fallback);
52
- }
53
- const TAB_WIDTH = 8;
54
- function isStrippableControlCharacter(char) {
55
- const codePoint = char.codePointAt(0) ?? 0;
56
- if (char === "\n") return false;
57
- return codePoint <= 31 || codePoint === 127;
58
- }
59
- function normalizeControlCharacters(value) {
60
- const sgrSequences = value.match(ANSI_ESCAPE_PATTERN) ?? [];
61
- return value.split(ANSI_ESCAPE_PATTERN).map((segment) => {
62
- const chars = [];
63
- for (const char of segment) if (char === " ") chars.push(" ".repeat(TAB_WIDTH));
64
- else if (!isStrippableControlCharacter(char)) chars.push(char);
65
- return chars.join("");
66
- }).reduce((result, segment, i) => result + segment + (sgrSequences[i] ?? ""), "");
67
- }
68
- function sanitizeCell(cell) {
69
- return normalizeControlCharacters(String(cell ?? "").replace(CARRIAGE_RETURN_PATTERN, "\n"));
70
- }
71
- const ZERO_WIDTH_CLUSTER_PATTERN = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v;
72
- const RGI_EMOJI_PATTERN = /^\p{RGI_Emoji}$/v;
73
- function displayWidth(value) {
74
- let width = 0;
75
- for (const { segment } of graphemeSegmenter.segment(value.replace(ANSI_ESCAPE_PATTERN, ""))) {
76
- if (ZERO_WIDTH_CLUSTER_PATTERN.test(segment)) continue;
77
- if (RGI_EMOJI_PATTERN.test(segment)) {
78
- width += 2;
79
- continue;
80
- }
81
- const codePoint = segment.codePointAt(0);
82
- width += codePoint === void 0 ? 0 : eastAsianWidth(codePoint);
83
- }
84
- return width;
85
- }
86
- function toCellLines(cell) {
87
- return cell.split("\n").map((text) => ({
88
- text,
89
- width: displayWidth(text)
90
- }));
91
- }
92
- function padCell(cellLine, width) {
93
- return cellLine.text + " ".repeat(Math.max(0, width - cellLine.width));
94
- }
95
- function renderBorder(left, join, right, columnWidths) {
96
- return left + columnWidths.map((width) => "─".repeat(width + 2)).join(join) + right;
97
- }
98
- function validateConsistentColumnCount(rows) {
99
- const columnCount = rows[0]?.length;
100
- if (columnCount === void 0) return;
101
- rows.forEach((row, index) => {
102
- if (row.length !== columnCount) throw new Error(`renderTable: all rows must have the same number of columns (expected ${columnCount}, row ${index} has ${row.length}).`);
103
- });
104
- }
105
- /**
106
- * Renders a 2D array of values as a table using single-line Unicode box-drawing borders.
107
- * Column widths account for East Asian wide characters (measured per grapheme cluster,
108
- * so combining marks and ZWJ emoji sequences aren't overcounted, non-printing clusters
109
- * such as a lone joiner or combining mark measure as 0, and flags, keycaps, and
110
- * VS16-forced emoji presentation are measured as 2 columns) and strip ANSI SGR (color/style)
111
- * escape codes before measuring. Use this instead of importing a table-rendering package
112
- * directly.
113
- * @param data - Table rows; every row must have the same number of columns. Each cell is
114
- * stringified (`null`/`undefined` become an empty string rather than the literal text
115
- * "null"/"undefined"), may contain embedded newlines, has `\r`/`\r\n` normalized to `\n`,
116
- * has tabs expanded to spaces, and has other control characters stripped.
117
- * @param config - Rendering options
118
- * @returns The rendered table terminated with a trailing newline, or `""` when there are no
119
- * rows or no columns to display
120
- */
121
- function renderTable(data, config = {}) {
122
- const rows = data.map((row) => row.map(sanitizeCell));
123
- validateConsistentColumnCount(rows);
124
- const rowCount = rows.length;
125
- const columnCount = rows[0]?.length ?? 0;
126
- if (rowCount === 0 || columnCount === 0) return "";
127
- const rowsCellLines = rows.map((row) => Array.from({ length: columnCount }, (_, col) => toCellLines(row[col] ?? "")));
128
- const columnWidths = Array.from({ length: columnCount }, (_, col) => maxOf(rowsCellLines.map((row) => maxOf((row[col] ?? []).map((line) => line.width)))));
129
- const shouldDrawLine = (lineIndex) => config.singleLine ? lineIndex === 0 || lineIndex === rowCount : (config.drawHorizontalLine ?? (() => true))(lineIndex, rowCount);
130
- const lines = [];
131
- if (shouldDrawLine(0)) lines.push(renderBorder("┌", "┬", "┐", columnWidths));
132
- rowsCellLines.forEach((cellLines, rowIndex) => {
133
- const rowHeight = maxOf(cellLines.map((columnLines) => columnLines.length), 1);
134
- for (let line = 0; line < rowHeight; line++) {
135
- const cells = cellLines.map((columnLines, col) => padCell(columnLines[line] ?? {
136
- text: "",
137
- width: 0
138
- }, columnWidths[col] ?? 0));
139
- lines.push(`│ ${cells.join(" │ ")} │`);
140
- }
141
- if (rowIndex < rowCount - 1 && shouldDrawLine(rowIndex + 1)) lines.push(renderBorder("├", "┼", "┤", columnWidths));
142
- });
143
- if (shouldDrawLine(rowCount)) lines.push(renderBorder("└", "┴", "┘", columnWidths));
144
- return `${lines.join("\n")}\n`;
145
- }
146
-
147
- //#endregion
148
- //#region src/cli/shared/parse-boolean.ts
149
- const TRUTHY_VALUES = /* @__PURE__ */ new Set([
150
- "true",
151
- "t",
152
- "yes",
153
- "y",
154
- "on",
155
- "1"
156
- ]);
157
- const FALSY_VALUES = /* @__PURE__ */ new Set([
158
- "false",
159
- "f",
160
- "no",
161
- "n",
162
- "off",
163
- "0"
164
- ]);
165
- /**
166
- * Parse a string value as a boolean.
167
- *
168
- * Recognized values (case-insensitive, trimmed) follow Python's
169
- * `distutils.util.strtobool` convention:
170
- * - truthy: `true, t, yes, y, on, 1`
171
- * - falsy: `false, f, no, n, off, 0`
172
- *
173
- * Undefined, empty strings, and unrecognized values return `undefined` so
174
- * that callers can fall back to their own defaults.
175
- * @param value - The input string (e.g. an environment variable or CLI flag value)
176
- * @returns `true`, `false`, or `undefined` when the value is unset or unrecognized
177
- */
178
- function parseBoolean(value) {
179
- if (value === void 0) return void 0;
180
- const normalized = value.trim().toLowerCase();
181
- if (normalized === "") return void 0;
182
- if (TRUTHY_VALUES.has(normalized)) return true;
183
- if (FALSY_VALUES.has(normalized)) return false;
184
- }
185
-
186
- //#endregion
187
- //#region src/cli/shared/logger.ts
188
- /**
189
- * Error thrown when a prompt is attempted in a non-interactive environment
190
- */
191
- var CIPromptError = class extends Error {
192
- constructor(message) {
193
- super(message ?? "Interactive prompts are not available in this environment. Provide the required options explicitly.");
194
- this.name = "CIPromptError";
195
- }
196
- };
197
- /**
198
- * Semantic style functions for inline text styling
199
- */
200
- const styles = {
201
- success: color.green,
202
- error: color.red,
203
- warning: color.yellow,
204
- info: color.cyan,
205
- create: color.green,
206
- update: color.yellow,
207
- delete: color.red,
208
- replace: color.magenta,
209
- unchanged: color.gray,
210
- bold: color.bold,
211
- dim: color.gray,
212
- highlight: color.cyanBright,
213
- successBright: color.greenBright,
214
- errorBright: color.redBright,
215
- resourceType: color.bold,
216
- resourceName: color.cyan,
217
- path: color.cyan,
218
- value: color.white,
219
- placeholder: (text) => color.italic(color.gray(text))
220
- };
221
- /**
222
- * Standardized symbols for CLI output
223
- */
224
- const symbols = {
225
- success: styles.success("✓"),
226
- error: styles.error("✖"),
227
- warning: styles.warning("⚠"),
228
- info: styles.info("i"),
229
- create: styles.create("+"),
230
- update: styles.update("~"),
231
- delete: styles.delete("-"),
232
- replace: styles.replace("±"),
233
- bullet: styles.dim("•"),
234
- arrow: styles.dim("→")
235
- };
236
- let _jsonMode = false;
237
- const TYPE_ICONS = {
238
- info: "ℹ",
239
- success: "✔",
240
- warn: "⚠",
241
- error: "✖",
242
- debug: "⚙",
243
- trace: "→",
244
- log: ""
245
- };
246
- const TYPE_COLORS = {
247
- info: styles.info,
248
- success: styles.success,
249
- warn: styles.warning,
250
- error: styles.error,
251
- debug: styles.dim,
252
- trace: styles.dim,
253
- log: (text) => text
254
- };
255
- /**
256
- * Formats a log line with the appropriate prefix and indentation
257
- * @param opts - Formatting options
258
- * @returns Formatted log line
259
- */
260
- function formatLogLine(opts) {
261
- const { mode, indent, type, message, timestamp } = opts;
262
- const indentPrefix = indent > 0 ? " ".repeat(indent) : "";
263
- const colorFn = TYPE_COLORS[type] || ((text) => text);
264
- if (mode === "plain") return `${indentPrefix}${colorFn(message)}\n`;
265
- const icon = TYPE_ICONS[type] || "";
266
- const coloredOutput = colorFn(`${icon ? `${icon} ` : ""}${message}`);
267
- return `${indentPrefix}${timestamp ?? ""}${coloredOutput}\n`;
268
- }
269
- /**
270
- * Writes a formatted log line to stderr.
271
- * @param type - Log type (info, success, warn, error, log)
272
- * @param message - Log message
273
- * @param opts - Log options (mode and indent)
274
- */
275
- function writeLog(type, message, opts) {
276
- const mode = opts?.mode ?? "default";
277
- const output = formatLogLine({
278
- mode,
279
- indent: opts?.indent ?? 0,
280
- type,
281
- message: formatWithOptions({ breakLength: process.stdout.columns || 80 }, message),
282
- timestamp: mode === "stream" ? `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} ` : ""
283
- });
284
- process.stderr.write(renderFor(process.stderr, output));
285
- }
286
- const logger = {
287
- get jsonMode() {
288
- return _jsonMode;
289
- },
290
- set jsonMode(value) {
291
- _jsonMode = value;
292
- },
293
- info(message, opts) {
294
- writeLog("info", message, opts);
295
- },
296
- success(message, opts) {
297
- writeLog("success", message, opts);
298
- },
299
- warn(message, opts) {
300
- writeLog("warn", message, opts);
301
- },
302
- error(message, opts) {
303
- writeLog("error", message, opts);
304
- },
305
- log(message) {
306
- writeLog("log", message, { mode: "plain" });
307
- },
308
- newline() {
309
- process.stderr.write("\n");
310
- },
311
- debug(message) {
312
- if (parseBoolean(process.env.DEBUG) === true) writeLog("log", styles.dim(message), { mode: "plain" });
313
- },
314
- out(data, options) {
315
- if (typeof data === "string") {
316
- process.stdout.write(renderFor(process.stdout, data.endsWith("\n") ? data : data + "\n"));
317
- return;
318
- }
319
- if (this.jsonMode) {
320
- console.log(JSON.stringify(data));
321
- return;
322
- }
323
- const display = options?.display;
324
- const formatValue = (value, pretty = false) => {
325
- if (options?.showNull && value === null) return "NULL";
326
- if (value === null || value === void 0) return "N/A";
327
- if (value instanceof Date) return formatDistanceToNowStrict(value, { addSuffix: true });
328
- if (typeof value === "object") return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
329
- return String(value);
330
- };
331
- const isExcluded = (key) => {
332
- return display !== void 0 && key in display && display[key] === null;
333
- };
334
- const transformValue = (key, value, item, pretty = false) => {
335
- if (display && key in display) {
336
- const transformer = display[key];
337
- if (transformer) return transformer(value, item);
338
- }
339
- return formatValue(value, pretty);
340
- };
341
- if (!Array.isArray(data)) {
342
- const t = renderTable(Object.entries(data).filter(([key]) => !isExcluded(key)).map(([key, value]) => [key, transformValue(key, value, data, true)]), { singleLine: false });
343
- process.stdout.write(renderFor(process.stdout, t));
344
- return;
345
- }
346
- if (data.length === 0) return;
347
- const headers = Array.from(new Set(data.flatMap((item) => Object.keys(item)))).filter((h) => !isExcluded(h));
348
- if (headers.length === 0) return;
349
- const t = renderTable([headers, ...data.map((item) => headers.map((header) => transformValue(header, item[header], item)))], { drawHorizontalLine: (lineIndex, rowCount) => {
350
- return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
351
- } });
352
- process.stdout.write(renderFor(process.stdout, t));
353
- }
354
- };
355
-
356
- //#endregion
357
- export { parseBoolean as a, symbols as i, logger as n, renderTable as o, styles as r, renderFor as s, CIPromptError as t };
358
- //# sourceMappingURL=logger-DSdExfor.mjs.map
@@ -1,38 +0,0 @@
1
- //#region src/utils/multiline.ts
2
- /**
3
- * Tag function which strips the common leading indent from a multi-line
4
- * template literal and trims surrounding blank lines, while indenting each
5
- * line of interpolated values to match the placeholder's indent.
6
- *
7
- * Mirrors the behaviour of the `multiline-ts` package, which we used to
8
- * depend on. We replaced it with this in-tree implementation because the
9
- * upstream package ships a `preinstall: npx only-allow pnpm` hook that
10
- * makes `npx create-tailor-sdk@latest` (and any other npm-based install
11
- * path that resolves a fresh copy) abort with `ECOMPROMISED`.
12
- * @param value - Template strings array, or a plain string for non-tagged usage
13
- * @param inputs - Interpolated values
14
- * @returns The dedented and trimmed string
15
- */
16
- function multiline(value, ...inputs) {
17
- const strings = typeof value === "string" ? value.split(/(?=\r\n|\r|\n)/) : Array.from(value);
18
- let currentIndent = "";
19
- const lines = strings.map((segment, i) => {
20
- if (/\r\n|\r|\n/.test(segment)) currentIndent = getFinalIndent(segment) || currentIndent;
21
- return segment + (inputs[i] ?? "").replace(/\r\n|\r|\n/g, `\n${currentIndent}`);
22
- }).join("").split(/\r\n|\r|\n/);
23
- const indents = lines.filter((line) => /[^ \t]/.test(line)).map((line) => getIndent(line).length);
24
- const minIndent = indents.length === 0 ? 0 : Math.min(...indents);
25
- return lines.map((line) => line.slice(minIndent)).join("\n").replace(/^\n|\n[ \t]*$/g, "");
26
- }
27
- function getIndent(line) {
28
- const match = line.match(/^[ \t]+/);
29
- return match ? match[0] : "";
30
- }
31
- function getFinalIndent(value) {
32
- const match = value.match(/(?<=(\r\n|\r|\n))[ \t]+$/);
33
- return match ? match[0] : "";
34
- }
35
-
36
- //#endregion
37
- export { multiline as t };
38
- //# sourceMappingURL=multiline-sfHpTZZK.mjs.map
@@ -1,36 +0,0 @@
1
- import { isBuiltin } from "node:module";
2
-
3
- //#region src/utils/node-builtins.ts
4
- const SUGGESTIONS = {
5
- crypto: "Use the Web Crypto API (globalThis.crypto) instead.",
6
- buffer: "Use Uint8Array or ArrayBuffer instead.",
7
- fs: "File system access is not available in the Tailor Platform runtime.",
8
- "fs/promises": "File system access is not available in the Tailor Platform runtime.",
9
- path: "Use URL or URLPattern for path manipulation.",
10
- http: "Use the Fetch API (globalThis.fetch) for HTTP requests instead.",
11
- https: "Use the Fetch API (globalThis.fetch) for HTTPS requests instead.",
12
- url: "Use the URL and URLSearchParams Web APIs instead.",
13
- util: "Use Web Standard APIs instead.",
14
- stream: "Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.",
15
- "stream/web": "Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.",
16
- events: "Use EventTarget instead.",
17
- zlib: "Use CompressionStream and DecompressionStream Web APIs instead.",
18
- querystring: "Use URLSearchParams instead.",
19
- string_decoder: "Use TextDecoder instead."
20
- };
21
- function isNodeBuiltinImport(specifier) {
22
- return isBuiltin(specifier);
23
- }
24
- function getNodeBuiltinMessage(specifier) {
25
- const bare = normalizeNodeBuiltinSpecifier(specifier);
26
- const suggestion = SUGGESTIONS[bare];
27
- const base = `"${specifier}" is not available in the Tailor Platform runtime.`;
28
- return suggestion ? `${base} ${suggestion}` : base;
29
- }
30
- function normalizeNodeBuiltinSpecifier(specifier) {
31
- return specifier.startsWith("node:") ? specifier.slice(5) : specifier;
32
- }
33
-
34
- //#endregion
35
- export { isNodeBuiltinImport as n, getNodeBuiltinMessage as t };
36
- //# sourceMappingURL=node-builtins-CmaL2Cbq.mjs.map
@@ -1,17 +0,0 @@
1
- import { readPackageJSON } from "pkg-types";
2
-
3
- //#region src/cli/shared/package-json.ts
4
- let packageJson = null;
5
- /**
6
- * Read and cache the package.json of the SDK package.
7
- * @returns Parsed package.json contents
8
- */
9
- async function readPackageJson() {
10
- if (packageJson) return packageJson;
11
- packageJson = await readPackageJSON(import.meta.url);
12
- return packageJson;
13
- }
14
-
15
- //#endregion
16
- export { readPackageJson as t };
17
- //# sourceMappingURL=package-json-8b0O9TlX.mjs.map
@@ -1,3 +0,0 @@
1
- import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
2
-
3
- export { readPackageJson };
@@ -1,46 +0,0 @@
1
- //#region src/utils/test/platform-serialize.ts
2
- /**
3
- * Validate and serialize a value as it would cross the Platform JSON boundary.
4
- *
5
- * Mirrors the runtime checks the platform performs on workflow arguments,
6
- * wait payloads, and trigger inputs so that local tests fail in the same
7
- * places production fails.
8
- *
9
- * Throws on:
10
- * - `NaN` / `Infinity` / `-Infinity` (`JSON.stringify` would silently emit `null`)
11
- * - `BigInt` (TypeError is thrown by `JSON.stringify`; we emit a clearer message)
12
- * - Non-plain objects (class instances, including `Date`, `Map`, `Set`, `Error`,
13
- * and user-defined DTOs whose prototype is not `Object.prototype`)
14
- *
15
- * The replacer reads `this[key]` so the check sees the original value before
16
- * any `toJSON` conversion (e.g. `Date.prototype.toJSON`).
17
- * @param value - Value to validate and round-trip
18
- * @returns The JSON-normalized value (undefined/function properties stripped, etc.)
19
- */
20
- function platformSerialize(value) {
21
- if (value === void 0) return void 0;
22
- if (typeof value === "function") throw new TypeError("platformSerialize: function is not JSON-serializable at <root>");
23
- if (typeof value === "symbol") throw new TypeError("platformSerialize: Symbol is not JSON-serializable at <root>");
24
- const serialized = JSON.stringify(value, function(key, val) {
25
- if (typeof val === "number" && !Number.isFinite(val)) throw new TypeError(`platformSerialize: non-finite number at ${formatPath(key)}: ${String(val)}`);
26
- if (typeof val === "bigint") throw new TypeError(`platformSerialize: BigInt is not JSON-serializable at ${formatPath(key)}`);
27
- const raw = this[key];
28
- if (raw !== null && typeof raw === "object" && !Array.isArray(raw)) {
29
- const proto = Object.getPrototypeOf(raw);
30
- if (proto !== Object.prototype && proto !== null) {
31
- const ctor = raw.constructor?.name ?? "anonymous";
32
- throw new TypeError(`platformSerialize: non-plain object at ${formatPath(key)} (${ctor} instance)`);
33
- }
34
- }
35
- return val;
36
- });
37
- if (serialized === void 0) throw new TypeError("platformSerialize: value is not JSON-serializable at <root>");
38
- return JSON.parse(serialized);
39
- }
40
- function formatPath(key) {
41
- return key === "" ? "<root>" : `"${key}"`;
42
- }
43
-
44
- //#endregion
45
- export { platformSerialize as t };
46
- //# sourceMappingURL=platform-serialize-RoRtBS0v.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/kysely-type/type-processor.ts","../../../../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport { type KyselyNamespaceMetadata, type KyselyTypeMetadata } from \"./types\";\nimport type { OperatorFieldConfig, TailorDBType } from \"#/parser/service/tailordb/types\";\n\ntype UsedUtilityTypes = { Timestamp: boolean; Serial: boolean };\n\ntype FieldTypeResult = {\n type: string;\n usedUtilityTypes: UsedUtilityTypes;\n};\n\n/**\n * Get the enum type definition.\n * @param fieldConfig - The field configuration\n * @returns The enum type as a string union\n */\nfunction getEnumType(fieldConfig: OperatorFieldConfig): string {\n const allowedValues = fieldConfig.allowedValues;\n\n if (allowedValues && Array.isArray(allowedValues)) {\n return allowedValues\n .map((v: string | { value: string }) => {\n const value = typeof v === \"string\" ? v : v.value;\n return `\"${value}\"`;\n })\n .join(\" | \");\n }\n return \"string\";\n}\n\n/**\n * Get the nested object type definition.\n * @param fieldConfig - The field configuration\n * @returns The nested type with used utility types\n */\nfunction getNestedType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fields = fieldConfig.fields;\n if (!fields || typeof fields !== \"object\") {\n return {\n type: \"string\",\n usedUtilityTypes: { Timestamp: false, Serial: false },\n };\n }\n\n const fieldResults = Object.entries(fields).map(([fieldName, config]) => {\n const result = generateFieldType(config);\n const optional = config.required !== true ? \"?\" : \"\";\n return {\n fieldType: `${fieldName}${optional}: ${result.type}`,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n });\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const fieldTypes = fieldResults.map((r) => r.fieldType);\n const obj = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n\n const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);\n const hasGeneratedFields = Object.values(fields).some(\n (config) => config.hooks?.create || config.default !== undefined,\n );\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields || hasGeneratedFields) {\n return { type: `ObjectColumnType<${obj}>`, usedUtilityTypes: aggregatedUtilityTypes };\n }\n return { type: obj, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Get the base Kysely type for a field (without array/null modifiers).\n * @param fieldConfig - The field configuration\n * @returns The base type with used utility types\n */\nfunction getBaseType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n let type: string;\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n type = \"string\";\n break;\n case \"integer\":\n case \"float\":\n type = \"number\";\n break;\n case \"date\":\n case \"datetime\":\n usedUtilityTypes.Timestamp = true;\n type = \"Timestamp\";\n break;\n case \"bool\":\n case \"boolean\":\n type = \"boolean\";\n break;\n case \"enum\":\n type = getEnumType(fieldConfig);\n break;\n case \"nested\": {\n const nestedResult = getNestedType(fieldConfig);\n return nestedResult;\n }\n default:\n type = \"string\";\n break;\n }\n\n return { type, usedUtilityTypes };\n}\n\n/**\n * Generate the complete field type including array and null modifiers.\n * @param fieldConfig - The field configuration\n * @returns The complete field type with used utility types\n */\nfunction generateFieldType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const baseTypeResult = getBaseType(fieldConfig);\n const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };\n\n const isArray = fieldConfig.array === true;\n const isNullable = fieldConfig.required !== true;\n\n // Types that use ColumnType internally (Timestamp, ObjectColumnType) cannot be\n // directly wrapped with [] for arrays, because Kysely only resolves ColumnType at\n // the top-level table property. Use ArrayColumnType/ObjectArrayColumnType to keep\n // the ColumnType at the top level with arrays inside.\n const columnTypeBaseTypes = new Set([\"Timestamp\"]);\n const isColumnTypeBase = columnTypeBaseTypes.has(baseTypeResult.type);\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n if (isColumnTypeBase || finalType.startsWith(\"ObjectColumnType<\")) {\n finalType = `ArrayColumnType<${baseTypeResult.type}>`;\n } else {\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\n }\n if (isNullable) {\n finalType = `${finalType} | null`;\n }\n\n if (fieldConfig.serial) {\n usedUtilityTypes.Serial = true;\n finalType = `Serial<${finalType}>`;\n }\n if (fieldConfig.hooks?.create || fieldConfig.default !== undefined) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param type - The parsed TailorDB type\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(type: TailorDBType): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(type.fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, parsedField]) => ({\n fieldName,\n ...generateFieldType(parsedField.config),\n }));\n\n const fields = [\n \"id: Generated<string>;\",\n ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`),\n ];\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const typeDef = multiline /* ts */ `\n ${type.name}: {\n ${fields.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB type\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n const result = generateTableInterface(type);\n\n return {\n name: type.name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Generate unified types file from multiple namespaces.\n * @param namespaceData - Namespace metadata\n * @returns Generated types file contents\n */\nexport function generateUnifiedKyselyTypes(namespaceData: KyselyNamespaceMetadata[]): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Aggregate used utility types from all namespaces\n const globalUsedUtilityTypes = namespaceData.reduce(\n (acc, ns) => ({\n Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || ns.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const utilityTypeImports: string[] = [\"type Generated\"];\n if (globalUsedUtilityTypes.Timestamp) {\n utilityTypeImports.push(\"type Timestamp\");\n }\n const hasObjectColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ObjectColumnType<\")),\n );\n if (hasObjectColumnType) {\n utilityTypeImports.push(\"type ObjectColumnType\");\n }\n const hasArrayColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ArrayColumnType<\")),\n );\n if (hasArrayColumnType) {\n utilityTypeImports.push(\"type ArrayColumnType\");\n }\n if (globalUsedUtilityTypes.Serial) {\n utilityTypeImports.push(\"type Serial\");\n }\n\n const importsSection = multiline /* ts */ `\n import {\n createGetDB,\n ${utilityTypeImports.join(\",\\n\")},\n type NamespaceDB,\n type NamespaceInsertable,\n type NamespaceSelectable,\n type NamespaceTable,\n type NamespaceTableName,\n type NamespaceTransaction,\n type NamespaceUpdateable,\n } from \"@tailor-platform/sdk/kysely\";\n `;\n\n // Generate Namespace interface with multiple namespaces\n const namespaceInterfaces = namespaceData\n .map(({ namespace, types }) => {\n const typeDefsWithIndent = types\n .map((type) => {\n return type.typeDef\n .split(\"\\n\")\n .map((line) => (line.trim() ? ` ${line}` : \"\"))\n .join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return ` \"${namespace}\": {\\n${typeDefsWithIndent}\\n }`;\n })\n .join(\",\\n\");\n\n const namespaceInterface = `export interface Namespace {\\n${namespaceInterfaces}\\n}`;\n\n const getDBFunction = multiline /* ts */ `\n export const getDB = createGetDB<Namespace>();\n\n export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;\n `;\n\n const utilityTypeExports = multiline /* ts */ `\n export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =\n NamespaceTransaction<Namespace, K>;\n\n type TableName = NamespaceTableName<Namespace>;\n export type Table<T extends TableName> = NamespaceTable<Namespace, T>;\n\n export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;\n export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;\n export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;\n `;\n\n return (\n [importsSection, namespaceInterface, getDBFunction, utilityTypeExports].join(\"\\n\\n\") + \"\\n\"\n );\n}\n","import { processKyselyType, generateUnifiedKyselyTypes } from \"./type-processor\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\n\n/** Unique identifier for the Kysely type generator plugin. */\nexport const KyselyGeneratorID = \"@tailor-platform/kysely-type\";\n\ntype KyselyTypePluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB types.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated types\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function kyselyTypePlugin(\n options: KyselyTypePluginOptions,\n): Plugin<unknown, KyselyTypePluginOptions> {\n return {\n id: KyselyGeneratorID,\n description: \"Generates Kysely type definitions for TailorDB types\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<KyselyTypePluginOptions>,\n ): Promise<GeneratorResult> {\n const allNamespaceData: KyselyNamespaceMetadata[] = [];\n\n for (const ns of ctx.tailordb) {\n const typeMetadataList: KyselyTypeMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processKyselyType(type);\n typeMetadataList.push(metadata);\n }\n\n if (typeMetadataList.length === 0) continue;\n\n const usedUtilityTypes = typeMetadataList.reduce(\n (acc, type) => ({\n Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || type.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n allNamespaceData.push({\n namespace: ns.namespace,\n types: typeMetadataList,\n usedUtilityTypes,\n });\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allNamespaceData.length > 0) {\n const content = generateUnifiedKyselyTypes(allNamespaceData);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;AAgBA,SAAS,YAAY,aAA0C;CAC7D,MAAM,gBAAgB,YAAY;CAElC,IAAI,iBAAiB,MAAM,QAAQ,aAAa,GAC9C,OAAO,cACJ,KAAK,MAAkC;EAEtC,OAAO,IADO,OAAO,MAAM,WAAW,IAAI,EAAE,MAC3B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ordb/types.mjs";
2
- import "@toiroakr/lines-db";
@@ -1,16 +0,0 @@
1
- import { TailorAnyDBType } from "../configure/services/tailordb/types.mjs";
2
- //#region src/plugin/get-generated-type.d.ts
3
- /**
4
- * Get a generated type from a plugin by loading the config and resolving everything automatically.
5
- * For type-attached plugins, calls onTypeLoaded() with the sourceType.
6
- * For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.
7
- * Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.
8
- * @param configPath - Path to tailor.config.ts (absolute or relative to cwd)
9
- * @param pluginId - The plugin's unique identifier
10
- * @param sourceType - The source TailorDB type (null for namespace plugins)
11
- * @param kind - The generated type kind (e.g., "request", "step")
12
- * @returns The generated TailorDB type
13
- */
14
- declare function getGeneratedType(configPath: string, pluginId: string, sourceType: TailorAnyDBType | null, kind: string): Promise<TailorAnyDBType>;
15
- //#endregion
16
- export { getGeneratedType };