@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 +1 @@
1
- {"version":3,"file":"platform-serialize-RoRtBS0v.mjs","names":[],"sources":["../src/utils/test/platform-serialize.ts"],"sourcesContent":["/**\n * Validate and serialize a value as it would cross the Platform JSON boundary.\n *\n * Mirrors the runtime checks the platform performs on workflow arguments,\n * wait payloads, and trigger inputs so that local tests fail in the same\n * places production fails.\n *\n * Throws on:\n * - `NaN` / `Infinity` / `-Infinity` (`JSON.stringify` would silently emit `null`)\n * - `BigInt` (TypeError is thrown by `JSON.stringify`; we emit a clearer message)\n * - Non-plain objects (class instances, including `Date`, `Map`, `Set`, `Error`,\n * and user-defined DTOs whose prototype is not `Object.prototype`)\n *\n * The replacer reads `this[key]` so the check sees the original value before\n * any `toJSON` conversion (e.g. `Date.prototype.toJSON`).\n * @param value - Value to validate and round-trip\n * @returns The JSON-normalized value (undefined/function properties stripped, etc.)\n */\nexport function platformSerialize<T>(value: T): T {\n // Top-level undefined is allowed (jobs may take no input).\n if (value === undefined) return undefined as T;\n\n // Root function/symbol stringify to `undefined`; throw a specific message here.\n if (typeof value === \"function\") {\n throw new TypeError(\"platformSerialize: function is not JSON-serializable at <root>\");\n }\n if (typeof value === \"symbol\") {\n throw new TypeError(\"platformSerialize: Symbol is not JSON-serializable at <root>\");\n }\n\n const serialized = JSON.stringify(value, function (key, val) {\n if (typeof val === \"number\" && !Number.isFinite(val)) {\n throw new TypeError(\n `platformSerialize: non-finite number at ${formatPath(key)}: ${String(val)}`,\n );\n }\n if (typeof val === \"bigint\") {\n throw new TypeError(\n `platformSerialize: BigInt is not JSON-serializable at ${formatPath(key)}`,\n );\n }\n // Look at the pre-toJSON value so Date/Map/Set/etc. can be detected.\n const raw = (this as Record<string, unknown>)[key];\n if (raw !== null && typeof raw === \"object\" && !Array.isArray(raw)) {\n const proto = Object.getPrototypeOf(raw);\n if (proto !== Object.prototype && proto !== null) {\n const ctor = (raw as { constructor?: { name?: string } }).constructor?.name ?? \"anonymous\";\n throw new TypeError(\n `platformSerialize: non-plain object at ${formatPath(key)} (${ctor} instance)`,\n );\n }\n }\n return val;\n });\n\n // `JSON.stringify` returns `undefined` when the root collapses (e.g. a `toJSON`\n // returning `undefined`); parsing that would throw opaquely.\n // JSON.stringify returns undefined for non-serializable values\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (serialized === undefined) {\n throw new TypeError(\"platformSerialize: value is not JSON-serializable at <root>\");\n }\n\n return JSON.parse(serialized) as T;\n}\n\nfunction formatPath(key: string): string {\n return key === \"\" ? \"<root>\" : `\"${key}\"`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,SAAgB,kBAAqB,OAAa;CAEhD,IAAI,UAAU,QAAW,OAAO;CAGhC,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,UAAU,gEAAgE;CAEtF,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,UAAU,8DAA8D;CAGpF,MAAM,aAAa,KAAK,UAAU,OAAO,SAAU,KAAK,KAAK;EAC3D,IAAI,OAAO,QAAQ,YAAY,CAAC,OAAO,SAAS,GAAG,GACjD,MAAM,IAAI,UACR,2CAA2C,WAAW,GAAG,EAAE,IAAI,OAAO,GAAG,GAC3E;EAEF,IAAI,OAAO,QAAQ,UACjB,MAAM,IAAI,UACR,yDAAyD,WAAW,GAAG,GACzE;EAGF,MAAM,MAAO,KAAiC;EAC9C,IAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG,GAAG;GAClE,MAAM,QAAQ,OAAO,eAAe,GAAG;GACvC,IAAI,UAAU,OAAO,aAAa,UAAU,MAAM;IAChD,MAAM,OAAQ,IAA4C,aAAa,QAAQ;IAC/E,MAAM,IAAI,UACR,0CAA0C,WAAW,GAAG,EAAE,IAAI,KAAK,WACrE;GACF;EACF;EACA,OAAO;CACT,CAAC;CAMD,IAAI,eAAe,QACjB,MAAM,IAAI,UAAU,6DAA6D;CAGnF,OAAO,KAAK,MAAM,UAAU;AAC9B;AAEA,SAAS,WAAW,KAAqB;CACvC,OAAO,QAAQ,KAAK,WAAW,IAAI,IAAI;AACzC"}
1
+ {"version":3,"file":"platform-serialize-DkiTdHOt.mjs","names":[],"sources":["../src/utils/test/platform-serialize.ts"],"sourcesContent":["/**\n * Validate and serialize a value as it would cross the Platform JSON boundary.\n *\n * Mirrors the runtime checks the platform performs on workflow arguments,\n * wait payloads, and trigger inputs so that local tests fail in the same\n * places production fails.\n *\n * Throws on:\n * - `NaN` / `Infinity` / `-Infinity` (`JSON.stringify` would silently emit `null`)\n * - `BigInt` (TypeError is thrown by `JSON.stringify`; we emit a clearer message)\n * - Non-plain objects (class instances, including `Date`, `Map`, `Set`, `Error`,\n * and user-defined DTOs whose prototype is not `Object.prototype`)\n *\n * The replacer reads `this[key]` so the check sees the original value before\n * any `toJSON` conversion (e.g. `Date.prototype.toJSON`).\n * @param value - Value to validate and round-trip\n * @returns The JSON-normalized value (undefined/function properties stripped, etc.)\n */\nexport function platformSerialize<T>(value: T): T {\n // Top-level undefined is allowed (jobs may take no input).\n if (value === undefined) return undefined as T;\n\n // Root function/symbol stringify to `undefined`; throw a specific message here.\n if (typeof value === \"function\") {\n throw new TypeError(\"platformSerialize: function is not JSON-serializable at <root>\");\n }\n if (typeof value === \"symbol\") {\n throw new TypeError(\"platformSerialize: Symbol is not JSON-serializable at <root>\");\n }\n\n const serialized = JSON.stringify(value, function (key, val) {\n if (typeof val === \"number\" && !Number.isFinite(val)) {\n throw new TypeError(\n `platformSerialize: non-finite number at ${formatPath(key)}: ${String(val)}`,\n );\n }\n if (typeof val === \"bigint\") {\n throw new TypeError(\n `platformSerialize: BigInt is not JSON-serializable at ${formatPath(key)}`,\n );\n }\n // Look at the pre-toJSON value so Date/Map/Set/etc. can be detected.\n const raw = (this as Record<string, unknown>)[key];\n if (raw !== null && typeof raw === \"object\" && !Array.isArray(raw)) {\n const proto = Object.getPrototypeOf(raw);\n if (proto !== Object.prototype && proto !== null) {\n const ctor = (raw as { constructor?: { name?: string } }).constructor?.name ?? \"anonymous\";\n throw new TypeError(\n `platformSerialize: non-plain object at ${formatPath(key)} (${ctor} instance)`,\n );\n }\n }\n return val;\n });\n\n // `JSON.stringify` returns `undefined` when the root collapses (e.g. a `toJSON`\n // returning `undefined`); parsing that would throw opaquely.\n // JSON.stringify returns undefined for non-serializable values\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (serialized === undefined) {\n throw new TypeError(\"platformSerialize: value is not JSON-serializable at <root>\");\n }\n\n return JSON.parse(serialized) as T;\n}\n\nfunction formatPath(key: string): string {\n return key === \"\" ? \"<root>\" : `\"${key}\"`;\n}\n"],"mappings":"AAkBA,SAAgB,kBAAqB,EAAa,CAEhD,GAAI,IAAU,IAAA,GAAW,OAGzB,GAAI,OAAO,GAAU,WACnB,MAAU,UAAU,gEAAgE,EAEtF,GAAI,OAAO,GAAU,SACnB,MAAU,UAAU,8DAA8D,EAGpF,IAAM,EAAa,KAAK,UAAU,EAAO,SAAU,EAAK,EAAK,CAC3D,GAAI,OAAO,GAAQ,UAAY,CAAC,OAAO,SAAS,CAAG,EACjD,MAAU,UACR,2CAA2C,WAAW,CAAG,EAAE,IAAI,OAAO,CAAG,GAC3E,EAEF,GAAI,OAAO,GAAQ,SACjB,MAAU,UACR,yDAAyD,WAAW,CAAG,GACzE,EAGF,IAAM,EAAO,KAAiC,GAC9C,GAAoB,OAAO,GAAQ,UAA/B,GAA2C,CAAC,MAAM,QAAQ,CAAG,EAAG,CAClE,IAAM,EAAQ,OAAO,eAAe,CAAG,EACvC,GAAI,IAAU,OAAO,WAAa,IAAU,KAAM,CAChD,IAAM,EAAQ,EAA4C,aAAa,MAAQ,YAC/E,MAAU,UACR,0CAA0C,WAAW,CAAG,EAAE,IAAI,EAAK,WACrE,CACF,CACF,CACA,OAAO,CACT,CAAC,EAMD,GAAI,IAAe,IAAA,GACjB,MAAU,UAAU,6DAA6D,EAGnF,OAAO,KAAK,MAAM,CAAU,CAC9B,CAEA,SAAS,WAAW,EAAqB,CACvC,OAAO,IAAQ,GAAK,SAAW,IAAI,EAAI,EACzC"}
@@ -6,7 +6,7 @@ type EnumConstantsPluginOptions = {
6
6
  distPath: string;
7
7
  };
8
8
  /**
9
- * Plugin that generates enum constants from TailorDB type definitions.
9
+ * Plugin that generates enum constants from TailorDB table definitions.
10
10
  * @param options - Plugin options
11
11
  * @param options.distPath - Output file path for generated constants
12
12
  * @returns Plugin instance with onTailorDBReady hook
@@ -1,116 +1,7 @@
1
- //#region src/plugin/builtin/enum-constants/generate-enum-constants.ts
2
- /**
3
- * Generate enum constant definitions from collected metadata.
4
- * @param allEnums - All collected enum definitions
5
- * @returns Generated enum constant definitions
6
- */
7
- function generateUnifiedEnumConstants(allEnums) {
8
- if (allEnums.length === 0) return "";
9
- const enumMap = /* @__PURE__ */ new Map();
10
- for (const enumDef of allEnums) enumMap.set(enumDef.name, enumDef);
11
- const enumDefs = Array.from(enumMap.values()).map((e) => {
12
- const members = e.values.map((v) => {
13
- return ` "${v.value.replace(/[-\s]/g, "_")}": "${v.value}"`;
14
- }).join(",\n");
15
- const hasDescriptions = e.values.some((v) => v.description);
16
- let jsDoc = "";
17
- if (e.fieldDescription || hasDescriptions) {
18
- const lines = [];
19
- if (e.fieldDescription) {
20
- lines.push(` * ${e.fieldDescription}`);
21
- if (hasDescriptions) lines.push(" *");
22
- }
23
- if (hasDescriptions) {
24
- const propertyDocs = e.values.map((v) => {
25
- return ` * @property ${[v.value.replace(/[-\s]/g, "_"), v.description].filter(Boolean).join(" - ")}`;
26
- });
27
- lines.push(...propertyDocs);
28
- }
29
- if (lines.length > 0) jsDoc = `/**\n${lines.join("\n")}\n */\n`;
30
- }
31
- return `${`${jsDoc}export const ${e.name} = {\n${members}\n} as const;`}\n${`export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`}`;
32
- }).join("\n\n");
33
- if (!enumDefs) return "";
34
- return enumDefs + "\n";
35
- }
1
+ function generateUnifiedEnumConstants(e){if(e.length===0)return``;let t=new Map;for(let n of e)t.set(n.name,n);let n=Array.from(t.values()).map(e=>{let t=e.values.map(e=>` "${e.value.replace(/[-\s]/g,`_`)}": "${e.value}"`).join(`,
2
+ `),n=e.values.some(e=>e.description),r=``;if(e.fieldDescription||n){let t=[];if(e.fieldDescription&&(t.push(` * ${e.fieldDescription}`),n&&t.push(` *`)),n){let n=e.values.map(e=>` * @property ${[e.value.replace(/[-\s]/g,`_`),e.description].filter(Boolean).join(` - `)}`);t.push(...n)}t.length>0&&(r=`/**\n${t.join(`
3
+ `)}\n */\n`)}return`${`${r}export const ${e.name} = {\n${t}\n} as const;`}\n${`export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`}`}).join(`
36
4
 
37
- //#endregion
38
- //#region src/plugin/builtin/enum-constants/process-enum-type.ts
39
- function capitalizeFirst(str) {
40
- return str.charAt(0).toUpperCase() + str.slice(1);
41
- }
42
- function collectEnums(type) {
43
- const enums = [];
44
- for (const [fieldName, parsedField] of Object.entries(type.fields)) {
45
- if (parsedField.config.type === "enum" && parsedField.config.allowedValues) {
46
- const enumTypeName = `${type.name}${capitalizeFirst(fieldName)}`;
47
- enums.push({
48
- name: enumTypeName,
49
- values: parsedField.config.allowedValues,
50
- fieldDescription: parsedField.config.description
51
- });
52
- }
53
- if (parsedField.config.type === "nested" && parsedField.config.fields) {
54
- for (const [nestedFieldName, nestedFieldConfig] of Object.entries(parsedField.config.fields)) if (nestedFieldConfig.type === "enum" && nestedFieldConfig.allowedValues) {
55
- const fullFieldName = `${fieldName}${capitalizeFirst(nestedFieldName)}`;
56
- const enumTypeName = `${type.name}${capitalizeFirst(fullFieldName)}`;
57
- enums.push({
58
- name: enumTypeName,
59
- values: nestedFieldConfig.allowedValues,
60
- fieldDescription: nestedFieldConfig.description
61
- });
62
- }
63
- }
64
- }
65
- return enums;
66
- }
67
- /**
68
- * Process a TailorDB type and extract enum metadata.
69
- * @param type - The parsed TailorDB type to process
70
- * @returns Enum constant metadata for the type
71
- */
72
- async function processEnumType(type) {
73
- const enums = collectEnums(type);
74
- return {
75
- name: type.name,
76
- enums
77
- };
78
- }
79
-
80
- //#endregion
81
- //#region src/plugin/builtin/enum-constants/index.ts
82
- /** Unique identifier for the enum constants generator plugin. */
83
- const EnumConstantsGeneratorID = "@tailor-platform/enum-constants";
84
- /**
85
- * Plugin that generates enum constants from TailorDB type definitions.
86
- * @param options - Plugin options
87
- * @param options.distPath - Output file path for generated constants
88
- * @returns Plugin instance with onTailorDBReady hook
89
- */
90
- function enumConstantsPlugin(options) {
91
- return {
92
- id: EnumConstantsGeneratorID,
93
- description: "Generates enum constants from TailorDB type definitions",
94
- pluginConfig: options,
95
- async onTailorDBReady(ctx) {
96
- const allEnums = [];
97
- for (const ns of ctx.tailordb) for (const type of Object.values(ns.types)) {
98
- const metadata = await processEnumType(type);
99
- allEnums.push(...metadata.enums);
100
- }
101
- const files = [];
102
- if (allEnums.length > 0) {
103
- const content = generateUnifiedEnumConstants(allEnums);
104
- files.push({
105
- path: ctx.pluginConfig.distPath,
106
- content
107
- });
108
- }
109
- return { files };
110
- }
111
- };
112
- }
113
-
114
- //#endregion
115
- export { EnumConstantsGeneratorID, enumConstantsPlugin };
5
+ `);return n?n+`
6
+ `:``}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}function collectEnums(e){let t=[];for(let[n,r]of Object.entries(e.fields)){if(r.config.type===`enum`&&r.config.allowedValues){let i=`${e.name}${capitalizeFirst(n)}`;t.push({name:i,values:r.config.allowedValues,fieldDescription:r.config.description})}if(r.config.type===`nested`&&r.config.fields){for(let[i,a]of Object.entries(r.config.fields))if(a.type===`enum`&&a.allowedValues){let r=`${n}${capitalizeFirst(i)}`,o=`${e.name}${capitalizeFirst(r)}`;t.push({name:o,values:a.allowedValues,fieldDescription:a.description})}}}return t}async function processEnumType(e){let t=collectEnums(e);return{name:e.name,enums:t}}const e=`@tailor-platform/enum-constants`;function enumConstantsPlugin(t){return{id:e,description:`Generates enum constants from TailorDB table definitions`,pluginConfig:t,async onTailorDBReady(e){let t=[];for(let n of e.tailordb)for(let e of Object.values(n.tables)){let n=await processEnumType(e);t.push(...n.enums)}let n=[];if(t.length>0){let r=generateUnifiedEnumConstants(t);n.push({path:e.pluginConfig.distPath,content:r})}return{files:n}}}}export{e as EnumConstantsGeneratorID,enumConstantsPlugin};
116
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/enum-constants/generate-enum-constants.ts","../../../../src/plugin/builtin/enum-constants/process-enum-type.ts","../../../../src/plugin/builtin/enum-constants/index.ts"],"sourcesContent":["import type { EnumDefinition } from \"./types\";\n\n/**\n * Generate enum constant definitions from collected metadata.\n * @param allEnums - All collected enum definitions\n * @returns Generated enum constant definitions\n */\nexport function generateUnifiedEnumConstants(allEnums: EnumDefinition[]): string {\n if (allEnums.length === 0) {\n return \"\";\n }\n\n const enumMap = new Map<string, EnumDefinition>();\n for (const enumDef of allEnums) {\n enumMap.set(enumDef.name, enumDef);\n }\n\n const enumDefs = Array.from(enumMap.values())\n .map((e) => {\n const members = e.values\n .map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` \"${key}\": \"${v.value}\"`;\n })\n .join(\",\\n\");\n\n const hasDescriptions = e.values.some((v) => v.description);\n let jsDoc = \"\";\n if (e.fieldDescription || hasDescriptions) {\n const lines: string[] = [];\n\n if (e.fieldDescription) {\n lines.push(` * ${e.fieldDescription}`);\n if (hasDescriptions) {\n lines.push(\" *\");\n }\n }\n\n if (hasDescriptions) {\n const propertyDocs = e.values.map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` * @property ${[key, v.description].filter(Boolean).join(\" - \")}`;\n });\n lines.push(...propertyDocs);\n }\n\n if (lines.length > 0) {\n jsDoc = `/**\\n${lines.join(\"\\n\")}\\n */\\n`;\n }\n }\n\n const constDef = `${jsDoc}export const ${e.name} = {\\n${members}\\n} as const;`;\n const typeDef = `export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`;\n return `${constDef}\\n${typeDef}`;\n })\n .join(\"\\n\\n\");\n\n if (!enumDefs) {\n return \"\";\n }\n\n return enumDefs + \"\\n\";\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { EnumConstantMetadata } from \"./types\";\n\nfunction capitalizeFirst(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction collectEnums(type: TailorDBType): EnumConstantMetadata[\"enums\"] {\n const enums: EnumConstantMetadata[\"enums\"] = [];\n\n for (const [fieldName, parsedField] of Object.entries(type.fields)) {\n if (parsedField.config.type === \"enum\" && parsedField.config.allowedValues) {\n const enumTypeName = `${type.name}${capitalizeFirst(fieldName)}`;\n enums.push({\n name: enumTypeName,\n values: parsedField.config.allowedValues,\n fieldDescription: parsedField.config.description,\n });\n }\n\n // Process nested fields\n if (parsedField.config.type === \"nested\" && parsedField.config.fields) {\n for (const [nestedFieldName, nestedFieldConfig] of Object.entries(\n parsedField.config.fields,\n )) {\n if (nestedFieldConfig.type === \"enum\" && nestedFieldConfig.allowedValues) {\n const fullFieldName = `${fieldName}${capitalizeFirst(nestedFieldName)}`;\n const enumTypeName = `${type.name}${capitalizeFirst(fullFieldName)}`;\n enums.push({\n name: enumTypeName,\n values: nestedFieldConfig.allowedValues,\n fieldDescription: nestedFieldConfig.description,\n });\n }\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Process a TailorDB type and extract enum metadata.\n * @param type - The parsed TailorDB type to process\n * @returns Enum constant metadata for the type\n */\nexport async function processEnumType(type: TailorDBType): Promise<EnumConstantMetadata> {\n const enums = collectEnums(type);\n\n return {\n name: type.name,\n enums,\n };\n}\n","import { generateUnifiedEnumConstants } from \"./generate-enum-constants\";\nimport { processEnumType } from \"./process-enum-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { EnumDefinition } from \"./types\";\n\n/** Unique identifier for the enum constants generator plugin. */\nexport const EnumConstantsGeneratorID = \"@tailor-platform/enum-constants\";\n\ntype EnumConstantsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates enum constants from TailorDB type definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated constants\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function enumConstantsPlugin(\n options: EnumConstantsPluginOptions,\n): Plugin<unknown, EnumConstantsPluginOptions> {\n return {\n id: EnumConstantsGeneratorID,\n description: \"Generates enum constants from TailorDB type definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<EnumConstantsPluginOptions>,\n ): Promise<GeneratorResult> {\n const allEnums: EnumDefinition[] = [];\n\n for (const ns of ctx.tailordb) {\n for (const type of Object.values(ns.types)) {\n const metadata = await processEnumType(type);\n allEnums.push(...metadata.enums);\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allEnums.length > 0) {\n const content = generateUnifiedEnumConstants(allEnums);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,6BAA6B,UAAoC;CAC/E,IAAI,SAAS,WAAW,GACtB,OAAO;CAGT,MAAM,0BAAU,IAAI,IAA4B;CAChD,KAAK,MAAM,WAAW,UACpB,QAAQ,IAAI,QAAQ,MAAM,OAAO;CAGnC,MAAM,WAAW,MAAM,KAAK,QAAQ,OAAO,CAAC,CAAC,CAC1C,KAAK,MAAM;EACV,MAAM,UAAU,EAAE,OACf,KAAK,MAAM;GAEV,OAAO,MADK,EAAE,MAAM,QAAQ,UAAU,GACvB,EAAE,MAAM,EAAE,MAAM;EACjC,CAAC,CAAC,CACD,KAAK,KAAK;EAEb,MAAM,kBAAkB,EAAE,OAAO,MAAM,MAAM,EAAE,WAAW;EAC1D,IAAI,QAAQ;EACZ,IAAI,EAAE,oBAAoB,iBAAiB;GACzC,MAAM,QAAkB,CAAC;GAEz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,eAAe;IACxE,MAAM,gBAAgB,GAAG,YAAY,gBAAgB,eAAe;IACpE,MAAM,eAAe,GAAG,KAAK,OAAO,gBAAgB,aAAa;IACjE,MAAM,KAAK;KACT,MAAM;KACN,QAAQ,kBAAkB;KAC1B,kBAAkB,kBAAkB;IACtC,CAAC;GACH;EACF;CAEJ;CAEA,OAAO;AACT;;;;;;AAOA,eAAsB,gBAAgB,MAAmD;CACvF,MAAM,QAAQ,aAAa,IAAI;CAE/B,OAAO;EACL,MAAM,KAAK;EACX;CACF;AACF;;;;;AC/CA,MAAa,2BAA2B;;;;;;;AAYxC,SAAgB,oBACd,SAC6C;CAC7C,OAAO;EACL,IAAI;EACJ,aAAa;EACb,cAAc;EAEd,MAAM,gBACJ,KAC0B;GAC1B,MAAM,WAA6B,CAAC;GAEpC,KAAK,MAAM,MAAM,IAAI,UACnB,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG,KAAK,GAAG;IAC1C,MAAM,WAAW,MAAM,gBAAgB,IAAI;IAC3C,SAAS,KAAK,GAAG,SAAS,KAAK;GACjC;GAGF,MAAM,QAAkC,CAAC;GACzC,IAAI,SAAS,SAAS,GAAG;IACvB,MAAM,UAAU,6BAA6B,QAAQ;IACrD,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;IACF,CAAC;GACH;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/enum-constants/generate-enum-constants.ts","../../../../src/plugin/builtin/enum-constants/process-enum-type.ts","../../../../src/plugin/builtin/enum-constants/index.ts"],"sourcesContent":["import type { EnumDefinition } from \"./types\";\n\n/**\n * Generate enum constant definitions from collected metadata.\n * @param allEnums - All collected enum definitions\n * @returns Generated enum constant definitions\n */\nexport function generateUnifiedEnumConstants(allEnums: EnumDefinition[]): string {\n if (allEnums.length === 0) {\n return \"\";\n }\n\n const enumMap = new Map<string, EnumDefinition>();\n for (const enumDef of allEnums) {\n enumMap.set(enumDef.name, enumDef);\n }\n\n const enumDefs = Array.from(enumMap.values())\n .map((e) => {\n const members = e.values\n .map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` \"${key}\": \"${v.value}\"`;\n })\n .join(\",\\n\");\n\n const hasDescriptions = e.values.some((v) => v.description);\n let jsDoc = \"\";\n if (e.fieldDescription || hasDescriptions) {\n const lines: string[] = [];\n\n if (e.fieldDescription) {\n lines.push(` * ${e.fieldDescription}`);\n if (hasDescriptions) {\n lines.push(\" *\");\n }\n }\n\n if (hasDescriptions) {\n const propertyDocs = e.values.map((v) => {\n const key = v.value.replace(/[-\\s]/g, \"_\");\n return ` * @property ${[key, v.description].filter(Boolean).join(\" - \")}`;\n });\n lines.push(...propertyDocs);\n }\n\n if (lines.length > 0) {\n jsDoc = `/**\\n${lines.join(\"\\n\")}\\n */\\n`;\n }\n }\n\n const constDef = `${jsDoc}export const ${e.name} = {\\n${members}\\n} as const;`;\n const typeDef = `export type ${e.name} = (typeof ${e.name})[keyof typeof ${e.name}];`;\n return `${constDef}\\n${typeDef}`;\n })\n .join(\"\\n\\n\");\n\n if (!enumDefs) {\n return \"\";\n }\n\n return enumDefs + \"\\n\";\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { EnumConstantMetadata } from \"./types\";\n\nfunction capitalizeFirst(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nfunction collectEnums(type: TailorDBType): EnumConstantMetadata[\"enums\"] {\n const enums: EnumConstantMetadata[\"enums\"] = [];\n\n for (const [fieldName, parsedField] of Object.entries(type.fields)) {\n if (parsedField.config.type === \"enum\" && parsedField.config.allowedValues) {\n const enumTypeName = `${type.name}${capitalizeFirst(fieldName)}`;\n enums.push({\n name: enumTypeName,\n values: parsedField.config.allowedValues,\n fieldDescription: parsedField.config.description,\n });\n }\n\n // Process nested fields\n if (parsedField.config.type === \"nested\" && parsedField.config.fields) {\n for (const [nestedFieldName, nestedFieldConfig] of Object.entries(\n parsedField.config.fields,\n )) {\n if (nestedFieldConfig.type === \"enum\" && nestedFieldConfig.allowedValues) {\n const fullFieldName = `${fieldName}${capitalizeFirst(nestedFieldName)}`;\n const enumTypeName = `${type.name}${capitalizeFirst(fullFieldName)}`;\n enums.push({\n name: enumTypeName,\n values: nestedFieldConfig.allowedValues,\n fieldDescription: nestedFieldConfig.description,\n });\n }\n }\n }\n }\n\n return enums;\n}\n\n/**\n * Process a TailorDB table and extract enum metadata.\n * @param type - The parsed TailorDB table to process\n * @returns Enum constant metadata for the table\n */\nexport async function processEnumType(type: TailorDBType): Promise<EnumConstantMetadata> {\n const enums = collectEnums(type);\n\n return {\n name: type.name,\n enums,\n };\n}\n","import { generateUnifiedEnumConstants } from \"./generate-enum-constants\";\nimport { processEnumType } from \"./process-enum-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { EnumDefinition } from \"./types\";\n\n/** Unique identifier for the enum constants generator plugin. */\nexport const EnumConstantsGeneratorID = \"@tailor-platform/enum-constants\";\n\ntype EnumConstantsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates enum constants from TailorDB table definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated constants\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function enumConstantsPlugin(\n options: EnumConstantsPluginOptions,\n): Plugin<unknown, EnumConstantsPluginOptions> {\n return {\n id: EnumConstantsGeneratorID,\n description: \"Generates enum constants from TailorDB table definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<EnumConstantsPluginOptions>,\n ): Promise<GeneratorResult> {\n const allEnums: EnumDefinition[] = [];\n\n for (const ns of ctx.tailordb) {\n for (const type of Object.values(ns.tables)) {\n const metadata = await processEnumType(type);\n allEnums.push(...metadata.enums);\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allEnums.length > 0) {\n const content = generateUnifiedEnumConstants(allEnums);\n files.push({\n path: ctx.p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F,CAAC,CACH,CAEA,MAAO,CAAE,OAAM,CACjB,CACF,CACF"}
@@ -6,7 +6,7 @@ type FileUtilsPluginOptions = {
6
6
  distPath: string;
7
7
  };
8
8
  /**
9
- * Plugin that generates TypeWithFiles interface from TailorDB type definitions.
9
+ * Plugin that generates TypeWithFiles interface from TailorDB table definitions.
10
10
  * @param options - Plugin options
11
11
  * @param options.distPath - Output file path for generated file utilities
12
12
  * @returns Plugin instance with onTailorDBReady hook
@@ -1,25 +1,5 @@
1
- import { t as multiline } from "../../../multiline-sfHpTZZK.mjs";
2
-
3
- //#region src/plugin/builtin/file-utils/generate-file-utils.ts
4
- /**
5
- * Generate unified file utility functions from collected metadata.
6
- * @param namespaceData - Namespace data with file utility metadata
7
- * @returns Generated file utility code
8
- */
9
- function generateUnifiedFileUtils(namespaceData) {
10
- if (namespaceData.length === 0) return "";
11
- const typeNamespaceMap = /* @__PURE__ */ new Map();
12
- const typeFieldsMap = /* @__PURE__ */ new Map();
13
- for (const { namespace, types } of namespaceData) for (const type of types) {
14
- typeNamespaceMap.set(type.name, namespace);
15
- typeFieldsMap.set(type.name, type.fileFields);
16
- }
17
- if (typeNamespaceMap.size === 0) return "";
18
- const interfaceFields = Array.from(typeFieldsMap.entries()).map(([typeName, fields]) => {
19
- return ` ${typeName}: {\n fields: ${fields.map((field) => `"${field}"`).join(" | ")};\n };`;
20
- }).join("\n");
21
- return [
22
- multiline`
1
+ import{t as e}from"../../../multiline-EyzjEwn9.mjs";function generateUnifiedFileUtils(t){if(t.length===0)return``;let n=new Map,r=new Map;for(let{namespace:e,types:i}of t)for(let t of i)n.set(t.name,e),r.set(t.name,t.fileFields);if(n.size===0)return``;let i=Array.from(r.entries()).map(([e,t])=>` ${e}: {\n fields: ${t.map(e=>`"${e}"`).join(` | `)};\n };`).join(`
2
+ `),a=e`
23
3
  import { file } from "@tailor-platform/sdk/runtime/file";
24
4
  import type {
25
5
  FileUploadOptions,
@@ -27,18 +7,19 @@ function generateUnifiedFileUtils(namespaceData) {
27
7
  FileMetadata,
28
8
  FileDownloadStreamResponse,
29
9
  } from "@tailor-platform/sdk/runtime/file";
30
- ` + "\n",
31
- multiline`
10
+ `+`
11
+ `,o=e`
32
12
  export interface TypeWithFiles {
33
- ${interfaceFields}
13
+ ${i}
34
14
  }
35
- ` + "\n",
36
- multiline`
15
+ `+`
16
+ `,s=Array.from(n.entries()).map(([e,t])=>` ${e}: "${t}"`).join(`,
17
+ `);return[a,o,e`
37
18
  const namespaces: Record<keyof TypeWithFiles, string> = {
38
- ${Array.from(typeNamespaceMap.entries()).map(([typeName, namespace]) => ` ${typeName}: "${namespace}"`).join(",\n")},
19
+ ${s},
39
20
  };
40
- ` + "\n",
41
- multiline`
21
+ `+`
22
+ `,e`
42
23
  export async function downloadFile<T extends keyof TypeWithFiles>(
43
24
  type: T,
44
25
  field: TypeWithFiles[T]["fields"],
@@ -46,8 +27,8 @@ function generateUnifiedFileUtils(namespaceData) {
46
27
  ) {
47
28
  return await file.download(namespaces[type], type, field, recordId);
48
29
  }
49
- ` + "\n",
50
- multiline`
30
+ `+`
31
+ `,e`
51
32
  export async function uploadFile<T extends keyof TypeWithFiles>(
52
33
  type: T,
53
34
  field: TypeWithFiles[T]["fields"],
@@ -57,8 +38,8 @@ function generateUnifiedFileUtils(namespaceData) {
57
38
  ): Promise<FileUploadResponse> {
58
39
  return await file.upload(namespaces[type], type, field, recordId, data, options);
59
40
  }
60
- ` + "\n",
61
- multiline`
41
+ `+`
42
+ `,e`
62
43
  export async function deleteFile<T extends keyof TypeWithFiles>(
63
44
  type: T,
64
45
  field: TypeWithFiles[T]["fields"],
@@ -66,8 +47,8 @@ function generateUnifiedFileUtils(namespaceData) {
66
47
  ): Promise<void> {
67
48
  return await file.delete(namespaces[type], type, field, recordId);
68
49
  }
69
- ` + "\n",
70
- multiline`
50
+ `+`
51
+ `,e`
71
52
  export async function getFileMetadata<T extends keyof TypeWithFiles>(
72
53
  type: T,
73
54
  field: TypeWithFiles[T]["fields"],
@@ -75,8 +56,8 @@ function generateUnifiedFileUtils(namespaceData) {
75
56
  ): Promise<FileMetadata> {
76
57
  return await file.getMetadata(namespaces[type], type, field, recordId);
77
58
  }
78
- ` + "\n",
79
- multiline`
59
+ `+`
60
+ `,e`
80
61
  export async function downloadFileStream<T extends keyof TypeWithFiles>(
81
62
  type: T,
82
63
  field: TypeWithFiles[T]["fields"],
@@ -84,67 +65,7 @@ function generateUnifiedFileUtils(namespaceData) {
84
65
  ): Promise<FileDownloadStreamResponse> {
85
66
  return await file.downloadStream(namespaces[type], type, field, recordId);
86
67
  }
87
- ` + "\n"
88
- ].join("\n");
89
- }
90
-
91
- //#endregion
92
- //#region src/plugin/builtin/file-utils/process-file-type.ts
93
- /**
94
- * Process a TailorDB type and extract file field metadata.
95
- * @param type - The parsed TailorDB type to process
96
- * @returns File utility metadata for the type
97
- */
98
- async function processFileType(type) {
99
- const fileFields = [];
100
- if (type.files) for (const fileFieldName of Object.keys(type.files)) fileFields.push(fileFieldName);
101
- return {
102
- name: type.name,
103
- fileFields
104
- };
105
- }
106
-
107
- //#endregion
108
- //#region src/plugin/builtin/file-utils/index.ts
109
- /** Unique identifier for the file utilities generator plugin. */
110
- const FileUtilsGeneratorID = "@tailor-platform/file-utils";
111
- /**
112
- * Plugin that generates TypeWithFiles interface from TailorDB type definitions.
113
- * @param options - Plugin options
114
- * @param options.distPath - Output file path for generated file utilities
115
- * @returns Plugin instance with onTailorDBReady hook
116
- */
117
- function fileUtilsPlugin(options) {
118
- return {
119
- id: FileUtilsGeneratorID,
120
- description: "Generates TypeWithFiles interface from TailorDB type definitions",
121
- pluginConfig: options,
122
- async onTailorDBReady(ctx) {
123
- const namespaceData = [];
124
- for (const ns of ctx.tailordb) {
125
- const typesWithFiles = [];
126
- for (const type of Object.values(ns.types)) {
127
- const metadata = await processFileType(type);
128
- if (metadata.fileFields.length > 0) typesWithFiles.push(metadata);
129
- }
130
- if (typesWithFiles.length > 0) namespaceData.push({
131
- namespace: ns.namespace,
132
- types: typesWithFiles
133
- });
134
- }
135
- const files = [];
136
- if (namespaceData.length > 0) {
137
- const content = generateUnifiedFileUtils(namespaceData);
138
- if (content) files.push({
139
- path: ctx.pluginConfig.distPath,
140
- content
141
- });
142
- }
143
- return { files };
144
- }
145
- };
146
- }
147
-
148
- //#endregion
149
- export { FileUtilsGeneratorID, fileUtilsPlugin };
68
+ `+`
69
+ `].join(`
70
+ `)}async function processFileType(e){let t=[];if(e.files)for(let n of Object.keys(e.files))t.push(n);return{name:e.name,fileFields:t}}const t=`@tailor-platform/file-utils`;function fileUtilsPlugin(e){return{id:t,description:`Generates TypeWithFiles interface from TailorDB table definitions`,pluginConfig:e,async onTailorDBReady(e){let t=[];for(let n of e.tailordb){let e=[];for(let t of Object.values(n.tables)){let n=await processFileType(t);n.fileFields.length>0&&e.push(n)}e.length>0&&t.push({namespace:n.namespace,types:e})}let n=[];if(t.length>0){let r=generateUnifiedFileUtils(t);r&&n.push({path:e.pluginConfig.distPath,content:r})}return{files:n}}}}export{t as FileUtilsGeneratorID,fileUtilsPlugin};
150
71
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/file-utils/generate-file-utils.ts","../../../../src/plugin/builtin/file-utils/process-file-type.ts","../../../../src/plugin/builtin/file-utils/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Generate unified file utility functions from collected metadata.\n * @param namespaceData - Namespace data with file utility metadata\n * @returns Generated file utility code\n */\nexport function generateUnifiedFileUtils(\n namespaceData: { namespace: string; types: FileUtilMetadata[] }[],\n): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Collect all types with their namespace\n const typeNamespaceMap = new Map<string, string>();\n const typeFieldsMap = new Map<string, string[]>();\n\n for (const { namespace, types } of namespaceData) {\n for (const type of types) {\n typeNamespaceMap.set(type.name, namespace);\n typeFieldsMap.set(type.name, type.fileFields);\n }\n }\n\n if (typeNamespaceMap.size === 0) {\n return \"\";\n }\n\n // Generate interface fields\n const interfaceFields = Array.from(typeFieldsMap.entries())\n .map(([typeName, fields]) => {\n const fieldNamesUnion = fields.map((field) => `\"${field}\"`).join(\" | \");\n return ` ${typeName}: {\\n fields: ${fieldNamesUnion};\\n };`;\n })\n .join(\"\\n\");\n\n const importStatement =\n multiline /* ts */ `\n import { file } from \"@tailor-platform/sdk/runtime/file\";\n import type {\n FileUploadOptions,\n FileUploadResponse,\n FileMetadata,\n FileDownloadStreamResponse,\n } from \"@tailor-platform/sdk/runtime/file\";\n ` + \"\\n\";\n\n const interfaceDefinition =\n multiline /* ts */ `\n export interface TypeWithFiles {\n ${interfaceFields}\n }\n ` + \"\\n\";\n\n // Generate namespaces object\n const namespaceEntries = Array.from(typeNamespaceMap.entries())\n .map(([typeName, namespace]) => ` ${typeName}: \"${namespace}\"`)\n .join(\",\\n\");\n\n const namespacesDefinition =\n multiline /* ts */ `\n const namespaces: Record<keyof TypeWithFiles, string> = {\n ${namespaceEntries},\n };\n ` + \"\\n\";\n\n // Generate downloadFile helper function\n const downloadFunction =\n multiline /* ts */ `\n export async function downloadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ) {\n return await file.download(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate uploadFile helper function\n const uploadFunction =\n multiline /* ts */ `\n export async function uploadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n data: string | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse> {\n return await file.upload(namespaces[type], type, field, recordId, data, options);\n }\n ` + \"\\n\";\n\n // Generate deleteFile helper function\n const deleteFunction =\n multiline /* ts */ `\n export async function deleteFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<void> {\n return await file.delete(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate getFileMetadata helper function\n const getMetadataFunction =\n multiline /* ts */ `\n export async function getFileMetadata<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileMetadata> {\n return await file.getMetadata(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate downloadFileStream helper function\n const downloadStreamFunction =\n multiline /* ts */ `\n export async function downloadFileStream<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileDownloadStreamResponse> {\n return await file.downloadStream(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n return [\n importStatement,\n interfaceDefinition,\n namespacesDefinition,\n downloadFunction,\n uploadFunction,\n deleteFunction,\n getMetadataFunction,\n downloadStreamFunction,\n ].join(\"\\n\");\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Process a TailorDB type and extract file field metadata.\n * @param type - The parsed TailorDB type to process\n * @returns File utility metadata for the type\n */\nexport async function processFileType(type: TailorDBType): Promise<FileUtilMetadata> {\n const fileFields: string[] = [];\n\n if (type.files) {\n for (const fileFieldName of Object.keys(type.files)) {\n fileFields.push(fileFieldName);\n }\n }\n\n return {\n name: type.name,\n fileFields,\n };\n}\n","import { generateUnifiedFileUtils } from \"./generate-file-utils\";\nimport { processFileType } from \"./process-file-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/** Unique identifier for the file utilities generator plugin. */\nexport const FileUtilsGeneratorID = \"@tailor-platform/file-utils\";\n\ntype FileUtilsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates TypeWithFiles interface from TailorDB type definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated file utilities\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function fileUtilsPlugin(\n options: FileUtilsPluginOptions,\n): Plugin<unknown, FileUtilsPluginOptions> {\n return {\n id: FileUtilsGeneratorID,\n description: \"Generates TypeWithFiles interface from TailorDB type definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<FileUtilsPluginOptions>,\n ): Promise<GeneratorResult> {\n const namespaceData: { namespace: string; types: FileUtilMetadata[] }[] = [];\n\n for (const ns of ctx.tailordb) {\n const typesWithFiles: FileUtilMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processFileType(type);\n if (metadata.fileFields.length > 0) {\n typesWithFiles.push(metadata);\n }\n }\n\n if (typesWithFiles.length > 0) {\n namespaceData.push({\n namespace: ns.namespace,\n types: typesWithFiles,\n });\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (namespaceData.length > 0) {\n const content = generateUnifiedFileUtils(namespaceData);\n if (content) {\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,yBACd,eACQ;CACR,IAAI,cAAc,WAAW,GAC3B,OAAO;CAIT,MAAM,mCAAmB,IAAI,IAAoB;CACjD,MAAM,gCAAgB,IAAI,IAAsB;CAEhD,KAAK,MAAM,EAAE,WAAW,WAAW,eACjC,KAAK,MAAM,QAAQ,OAAO;EACxB,iBAAiB,IAAI,KAAK,MAAM,SAAS;EACzC,cAAc,IAAI,KAAK,MAAM,KAAK,UAAU;CAC9C;CAGF,IAAI,iBAAiB,SAAS,GAC5B,OAAO;CAIT,MAAM,kBAAkB,MAAM,KAAK,cAAc,QAAQ,CAAC,CAAC,CACxD,KAAK,CAAC,UAAU,YAAY;EAE3B,OAAO,KAAK,SAAS,mBADG,OAAO,KAAK,UAAU,IAAI,MAAM,EAAE,CAAC,CAAC,KAAK,KACX,EAAE;CAC1D,CAAC,CAAC,CACD,KAAK,IAAI;CA8FZ,O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KACvB;IACF,CAAC;GAEL;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/file-utils/generate-file-utils.ts","../../../../src/plugin/builtin/file-utils/process-file-type.ts","../../../../src/plugin/builtin/file-utils/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Generate unified file utility functions from collected metadata.\n * @param namespaceData - Namespace data with file utility metadata\n * @returns Generated file utility code\n */\nexport function generateUnifiedFileUtils(\n namespaceData: { namespace: string; types: FileUtilMetadata[] }[],\n): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Collect all tables with their namespace\n const tableNamespaceMap = new Map<string, string>();\n const typeFieldsMap = new Map<string, string[]>();\n\n for (const { namespace, types } of namespaceData) {\n for (const type of types) {\n tableNamespaceMap.set(type.name, namespace);\n typeFieldsMap.set(type.name, type.fileFields);\n }\n }\n\n if (tableNamespaceMap.size === 0) {\n return \"\";\n }\n\n // Generate interface fields\n const interfaceFields = Array.from(typeFieldsMap.entries())\n .map(([tableName, fields]) => {\n const fieldNamesUnion = fields.map((field) => `\"${field}\"`).join(\" | \");\n return ` ${tableName}: {\\n fields: ${fieldNamesUnion};\\n };`;\n })\n .join(\"\\n\");\n\n const importStatement =\n multiline /* ts */ `\n import { file } from \"@tailor-platform/sdk/runtime/file\";\n import type {\n FileUploadOptions,\n FileUploadResponse,\n FileMetadata,\n FileDownloadStreamResponse,\n } from \"@tailor-platform/sdk/runtime/file\";\n ` + \"\\n\";\n\n const interfaceDefinition =\n multiline /* ts */ `\n export interface TypeWithFiles {\n ${interfaceFields}\n }\n ` + \"\\n\";\n\n // Generate namespaces object\n const namespaceEntries = Array.from(tableNamespaceMap.entries())\n .map(([tableName, namespace]) => ` ${tableName}: \"${namespace}\"`)\n .join(\",\\n\");\n\n const namespacesDefinition =\n multiline /* ts */ `\n const namespaces: Record<keyof TypeWithFiles, string> = {\n ${namespaceEntries},\n };\n ` + \"\\n\";\n\n // Generate downloadFile helper function\n const downloadFunction =\n multiline /* ts */ `\n export async function downloadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ) {\n return await file.download(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate uploadFile helper function\n const uploadFunction =\n multiline /* ts */ `\n export async function uploadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n data: string | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse> {\n return await file.upload(namespaces[type], type, field, recordId, data, options);\n }\n ` + \"\\n\";\n\n // Generate deleteFile helper function\n const deleteFunction =\n multiline /* ts */ `\n export async function deleteFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<void> {\n return await file.delete(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate getFileMetadata helper function\n const getMetadataFunction =\n multiline /* ts */ `\n export async function getFileMetadata<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileMetadata> {\n return await file.getMetadata(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate downloadFileStream helper function\n const downloadStreamFunction =\n multiline /* ts */ `\n export async function downloadFileStream<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileDownloadStreamResponse> {\n return await file.downloadStream(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n return [\n importStatement,\n interfaceDefinition,\n namespacesDefinition,\n downloadFunction,\n uploadFunction,\n deleteFunction,\n getMetadataFunction,\n downloadStreamFunction,\n ].join(\"\\n\");\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Process a TailorDB table and extract file field metadata.\n * @param type - The parsed TailorDB table to process\n * @returns File utility metadata for the table\n */\nexport async function processFileType(type: TailorDBType): Promise<FileUtilMetadata> {\n const fileFields: string[] = [];\n\n if (type.files) {\n for (const fileFieldName of Object.keys(type.files)) {\n fileFields.push(fileFieldName);\n }\n }\n\n return {\n name: type.name,\n fileFields,\n };\n}\n","import { generateUnifiedFileUtils } from \"./generate-file-utils\";\nimport { processFileType } from \"./process-file-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/** Unique identifier for the file utilities generator plugin. */\nexport const FileUtilsGeneratorID = \"@tailor-platform/file-utils\";\n\ntype FileUtilsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates TypeWithFiles interface from TailorDB table definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated file utilities\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function fileUtilsPlugin(\n options: FileUtilsPluginOptions,\n): Plugin<unknown, FileUtilsPluginOptions> {\n return {\n id: FileUtilsGeneratorID,\n description: \"Generates TypeWithFiles interface from TailorDB table definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<FileUtilsPluginOptions>,\n ): Promise<GeneratorResult> {\n const namespaceData: { namespace: string; types: FileUtilMetadata[] }[] = [];\n\n for (const ns of ctx.tailordb) {\n const typesWithFiles: FileUtilMetadata[] = [];\n\n for (const type of Object.values(ns.tables)) {\n const metadata = await processFileType(type);\n if (metadata.fileFields.length > 0) {\n typesWithFiles.push(metadata);\n }\n }\n\n if (typesWithFiles.length > 0) {\n namespaceData.push({\n namespace: ns.namespace,\n types: typesWithFiles,\n });\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (namespaceData.length > 0) {\n const content = generateUnifiedFileUtils(namespaceData);\n if (content) {\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n }\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AI,EACJ,YAAa,oEACb,aAAc,EAEd,MAAM,gBACJ,EAC0B,CAC1B,IAAM,EAAoE,CAAC,EAE3E,IAAK,IAAM,KAAM,EAAI,SAAU,CAC7B,IAAM,EAAqC,CAAC,EAE5C,IAAK,IAAM,KAAQ,OAAO,OAAO,EAAG,MAAM,EAAG,CAC3C,IAAM,EAAW,MAAM,gBAAgB,CAAI,EACvC,EAAS,WAAW,OAAS,GAC/B,EAAe,KAAK,CAAQ,CAEhC,CAEI,EAAe,OAAS,GAC1B,EAAc,KAAK,CACjB,UAAW,EAAG,UACd,MAAO,CACT,CAAC,CAEL,CAEA,IAAM,EAAkC,CAAC,EACzC,GAAI,EAAc,OAAS,EAAG,CAC5B,IAAM,EAAU,yBAAyB,CAAa,EAClD,GACF,EAAM,KAAK,CACT,KAAM,EAAI,aAAa,SACvB,SACF,CAAC,CAEL,CAEA,MAAO,CAAE,OAAM,CACjB,CACF,CACF"}
@@ -5,12 +5,19 @@ declare const KyselyGeneratorID = "@tailor-platform/kysely-type";
5
5
  type KyselyTypePluginOptions = {
6
6
  distPath: string;
7
7
  };
8
+ declare module "@tailor-platform/sdk/plugin" {
9
+ interface PluginConfigRegistry {
10
+ "@tailor-platform/kysely-type": KyselyTypePluginOptions;
11
+ }
12
+ }
13
+ /** Conventional output path used when `kyselyTypePlugin` has no `distPath` configured. */
14
+ declare const DEFAULT_KYSELY_TYPES_DIST_PATH = "./generated/tailordb.ts";
8
15
  /**
9
- * Plugin that generates Kysely type definitions for TailorDB types.
16
+ * Plugin that generates Kysely type definitions for TailorDB tables.
10
17
  * @param options - Plugin options
11
18
  * @param options.distPath - Output file path for generated types
12
19
  * @returns Plugin instance with onTailorDBReady hook
13
20
  */
14
21
  declare function kyselyTypePlugin(options: KyselyTypePluginOptions): Plugin<unknown, KyselyTypePluginOptions>;
15
22
  //#endregion
16
- export { KyselyGeneratorID, kyselyTypePlugin };
23
+ export { DEFAULT_KYSELY_TYPES_DIST_PATH, KyselyGeneratorID, kyselyTypePlugin };