@tailor-platform/sdk 2.4.0 → 2.6.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 (252) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/bin/tailor.mjs +3 -2
  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-CNeOcaLc.mjs +1 -0
  6. package/dist/application-CmXOqTaK.mjs +192 -0
  7. package/dist/application-CmXOqTaK.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/api/index.d.mts +1 -1
  15. package/dist/cli/commands/deploy/deploy.d.mts +2 -2
  16. package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
  17. package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
  18. package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
  19. package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
  20. package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
  21. package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
  22. package/dist/cli/commands/executor/jobs.d.mts +1 -1
  23. package/dist/cli/commands/executor/trigger.d.mts +1 -1
  24. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
  25. package/dist/cli/commands/show.d.mts +1 -1
  26. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -11
  27. package/dist/cli/commands/tailordb/migrate/generate.d.mts +4 -0
  28. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
  29. package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
  30. package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
  31. package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
  32. package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
  33. package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
  34. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
  35. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
  36. package/dist/cli/commands/workflow/start.d.mts +1 -1
  37. package/dist/cli/commands/workspace/list.d.mts +1 -1
  38. package/dist/cli/lib.d.mts +12 -4
  39. package/dist/cli/lib.mjs +1 -9
  40. package/dist/cli/lib.mjs.map +1 -1
  41. package/dist/cli/main.d.mts +2 -0
  42. package/dist/cli/main.mjs +1170 -7754
  43. package/dist/cli/main.mjs.map +1 -1
  44. package/dist/cli/shared/args.d.mts +65 -1
  45. package/dist/cli/shared/command.d.mts +11 -0
  46. package/dist/cli/shared/context.d.mts +1 -1
  47. package/dist/cli/shared/logger.d.mts +64 -0
  48. package/dist/cli/shared/script-executor.d.mts +1 -1
  49. package/dist/cli/shared/seed-chunker.d.mts +5 -5
  50. package/dist/completion/zsh-worker.zsh +82 -9
  51. package/dist/configure/config/index.d.mts +1 -1
  52. package/dist/configure/config/types.d.mts +2 -2
  53. package/dist/configure/index.d.mts +48 -12
  54. package/dist/configure/index.mjs +1 -1267
  55. package/dist/configure/index.mjs.map +1 -1
  56. package/dist/configure/services/auth/types.d.mts +1 -1
  57. package/dist/configure/services/idp/types.d.mts +1 -1
  58. package/dist/configure/services/tailordb/schema.d.mts +22 -8
  59. package/dist/configure/services/tailordb/types.d.mts +2 -2
  60. package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
  61. package/dist/configure/services/workflow/job.d.mts +12 -2
  62. package/dist/configure/types/field.types.d.mts +1 -1
  63. package/dist/configure/types/permission-operand.types.d.mts +1 -1
  64. package/dist/context-D0QjfxzD.mjs +2 -0
  65. package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
  66. package/dist/crashreport-BN28xp5B.mjs +42 -0
  67. package/dist/{crashreport-Q0pDAlrj.mjs.map → crashreport-BN28xp5B.mjs.map} +1 -1
  68. package/dist/crashreport-By23O2k-.mjs +1 -0
  69. package/dist/errors-DLsQ_-ol.mjs +2 -0
  70. package/dist/errors-DLsQ_-ol.mjs.map +1 -0
  71. package/dist/es-builtins-n3wBv4Sv.mjs +2 -0
  72. package/dist/es-builtins-n3wBv4Sv.mjs.map +1 -0
  73. package/dist/file-COPYfju_.mjs +2 -0
  74. package/dist/file-COPYfju_.mjs.map +1 -0
  75. package/dist/globals-CMHSnj4w.mjs +2 -0
  76. package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
  77. package/dist/iconv-DlFMt2gW.mjs +2 -0
  78. package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
  79. package/dist/idp-G_ojPBB5.mjs +2 -0
  80. package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
  81. package/dist/interceptor-DQg3cR_9.mjs +2 -0
  82. package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
  83. package/dist/kysely/index.mjs +1 -32
  84. package/dist/kysely/index.mjs.map +1 -1
  85. package/dist/kysely-type-BTi3BMtL.mjs +43 -0
  86. package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
  87. package/dist/logger-CCjs1DuH.mjs +9 -0
  88. package/dist/logger-CCjs1DuH.mjs.map +1 -0
  89. package/dist/logger-DP2BjQ93.mjs +2 -0
  90. package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
  91. package/dist/multiline-EyzjEwn9.mjs +3 -0
  92. package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
  93. package/dist/node-builtins-oBl7EbyV.mjs +2 -0
  94. package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
  95. package/dist/package-json-C690ceex.mjs +2 -0
  96. package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
  97. package/dist/package-json-CmqhDJ__.mjs +1 -0
  98. package/dist/parser/service/tailordb/type-source.d.mts +5 -5
  99. package/dist/parser/service/tailordb/types.d.mts +4 -4
  100. package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
  101. package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
  102. package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
  103. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  104. package/dist/plugin/builtin/file-utils/index.mjs +22 -104
  105. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  106. package/dist/plugin/builtin/kysely-type/index.d.mts +8 -1
  107. package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
  108. package/dist/plugin/builtin/seed/index.d.mts +5 -0
  109. package/dist/plugin/builtin/seed/index.mjs +1 -3
  110. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +0 -2
  111. package/dist/plugin/{get-generated-type.d.mts → get-generated-table.d.mts} +5 -5
  112. package/dist/plugin/index.d.mts +3 -2
  113. package/dist/plugin/index.mjs +1 -251
  114. package/dist/plugin/index.mjs.map +1 -1
  115. package/dist/plugin/types.d.mts +30 -23
  116. package/dist/plugin/with-context.d.mts +3 -3
  117. package/dist/register-ts-hook-oDA2JLp2.mjs +640 -0
  118. package/dist/register-ts-hook-oDA2JLp2.mjs.map +1 -0
  119. package/dist/registry-HlEaGvl5.mjs +2 -0
  120. package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
  121. package/dist/repl-editor-BG1aDOfH.mjs +2 -0
  122. package/dist/{repl-editor-F9LotMNx.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
  123. package/dist/runtime/aigateway.mjs +1 -3
  124. package/dist/runtime/authconnection.mjs +1 -3
  125. package/dist/runtime/context.mjs +1 -3
  126. package/dist/runtime/file.d.mts +21 -21
  127. package/dist/runtime/file.mjs +1 -3
  128. package/dist/runtime/globals.mjs +1 -1
  129. package/dist/runtime/iconv.mjs +1 -3
  130. package/dist/runtime/idp.mjs +1 -3
  131. package/dist/runtime/index.mjs +1 -11
  132. package/dist/runtime/logger.mjs +1 -3
  133. package/dist/runtime/secretmanager.mjs +1 -3
  134. package/dist/runtime/types.d.mts +1 -1
  135. package/dist/runtime/workflow.mjs +1 -3
  136. package/dist/schema-AYG4OhXY.mjs +2 -0
  137. package/dist/schema-AYG4OhXY.mjs.map +1 -0
  138. package/dist/secret-file-C9wp_FCX.mjs +2 -0
  139. package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
  140. package/dist/secretmanager-5olfnI1b.mjs +2 -0
  141. package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
  142. package/dist/secretmanager-vHQoXdQz.mjs +2 -0
  143. package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
  144. package/dist/seed/index.mjs +8 -244
  145. package/dist/seed/index.mjs.map +1 -1
  146. package/dist/seed-DwqRFdqP.mjs +207 -0
  147. package/dist/seed-DwqRFdqP.mjs.map +1 -0
  148. package/dist/service-CLPMoj9n.mjs +2 -0
  149. package/dist/{service-LTfp03ZZ.mjs.map → service-CLPMoj9n.mjs.map} +1 -1
  150. package/dist/service-D7iXk0BT.mjs +1 -0
  151. package/dist/service-YqDsHmlK.mjs +7 -0
  152. package/dist/service-YqDsHmlK.mjs.map +1 -0
  153. package/dist/service_pb-DGKCLuAs.mjs +2 -0
  154. package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
  155. package/dist/service_pb-_aeFE-Nv.mjs +1 -0
  156. package/dist/shared/src/color.d.mts +5 -0
  157. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +1 -1
  158. package/dist/telemetry-Bklv9kQY.mjs +2 -0
  159. package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
  160. package/dist/telemetry-DXHP3VVi.mjs +1 -0
  161. package/dist/type-source--ZNcV8RJ.mjs +2 -0
  162. package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
  163. package/dist/types/executor.generated.d.mts +1 -1
  164. package/dist/user-agent-vdHYF3QL.mjs +2 -0
  165. package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
  166. package/dist/utils/test/index.mjs +1 -109
  167. package/dist/utils/test/index.mjs.map +1 -1
  168. package/dist/vitest/environment.mjs +1 -41
  169. package/dist/vitest/environment.mjs.map +1 -1
  170. package/dist/vitest/index.mjs +1 -1986
  171. package/dist/vitest/index.mjs.map +1 -1
  172. package/dist/vitest/mocks/file.d.mts +8 -8
  173. package/dist/vitest/setup.mjs +1 -140
  174. package/dist/vitest/setup.mjs.map +1 -1
  175. package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
  176. package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
  177. package/dist/wait-point-registry-B-ESkTZX.mjs +2 -0
  178. package/dist/wait-point-registry-B-ESkTZX.mjs.map +1 -0
  179. package/dist/workflow-Cs9ISw6j.mjs +2 -0
  180. package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
  181. package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
  182. package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
  183. package/docs/cli/function.md +66 -6
  184. package/docs/cli/setup.md +24 -14
  185. package/docs/cli/tailordb.md +2 -0
  186. package/docs/cli-reference.md +9 -8
  187. package/docs/github-actions.md +14 -12
  188. package/docs/migration/v2.md +18 -2
  189. package/docs/migration/v3.md +121 -0
  190. package/docs/plugin/custom.md +130 -85
  191. package/docs/plugin/index.md +3 -3
  192. package/docs/services/tailordb-migration.md +21 -7
  193. package/docs/services/tailordb.md +9 -7
  194. package/docs/services/workflow.md +10 -9
  195. package/package.json +14 -13
  196. package/postinstall.mjs +1 -1
  197. package/dist/aigateway-DR4Kwuik.mjs +0 -9
  198. package/dist/application-C8a0UJ-z.mjs +0 -6071
  199. package/dist/application-C8a0UJ-z.mjs.map +0 -1
  200. package/dist/application-D4zOiLLa.mjs +0 -3
  201. package/dist/assert-DBxo8jPo.mjs +0 -9
  202. package/dist/authconnection-CZvi9ANm.mjs +0 -9
  203. package/dist/brand-Eo4pLXPJ.mjs +0 -36
  204. package/dist/context-DYQVYWqZ.mjs +0 -23
  205. package/dist/crashreport-Cd4TqfZq.mjs +0 -3
  206. package/dist/crashreport-Q0pDAlrj.mjs +0 -427
  207. package/dist/errors-Bxut5_Sy.mjs +0 -89
  208. package/dist/errors-Bxut5_Sy.mjs.map +0 -1
  209. package/dist/file-BUcmVIH2.mjs +0 -58
  210. package/dist/file-BUcmVIH2.mjs.map +0 -1
  211. package/dist/globals-B2nlxBrz.mjs +0 -126
  212. package/dist/iconv-QWaZh0TT.mjs +0 -38
  213. package/dist/idp-RA_swu-h.mjs +0 -82
  214. package/dist/interceptor-e33JtsC-.mjs +0 -33
  215. package/dist/logger-BtX0suGY.mjs +0 -48
  216. package/dist/logger-D0bEznPv.mjs +0 -362
  217. package/dist/logger-D0bEznPv.mjs.map +0 -1
  218. package/dist/multiline-sfHpTZZK.mjs +0 -38
  219. package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
  220. package/dist/package-json-8b0O9TlX.mjs +0 -17
  221. package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
  222. package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
  223. package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
  224. package/dist/plugin/builtin/seed/types.d.mts +0 -2
  225. package/dist/register-ts-hook-Vqjza10T.mjs +0 -25679
  226. package/dist/register-ts-hook-Vqjza10T.mjs.map +0 -1
  227. package/dist/registry-BIGVUrMB.mjs +0 -54
  228. package/dist/repl-editor-F9LotMNx.mjs +0 -252
  229. package/dist/schema-D4TC4BC3.mjs +0 -640
  230. package/dist/schema-D4TC4BC3.mjs.map +0 -1
  231. package/dist/secret-file-C3J4Gy8r.mjs +0 -64
  232. package/dist/secretmanager-CYlpffsz.mjs +0 -13
  233. package/dist/secretmanager-IY4UvinW.mjs +0 -131
  234. package/dist/seed-Cibjmtry.mjs +0 -489
  235. package/dist/seed-Cibjmtry.mjs.map +0 -1
  236. package/dist/service-2grcAOCJ.mjs +0 -898
  237. package/dist/service-2grcAOCJ.mjs.map +0 -1
  238. package/dist/service-CaBPNDIZ.mjs +0 -3
  239. package/dist/service-LTfp03ZZ.mjs +0 -133
  240. package/dist/service_pb-BEWj1pOV.mjs +0 -167
  241. package/dist/service_pb-BjlhvK9E.mjs +0 -3
  242. package/dist/telemetry-BRVdwh14.mjs +0 -84
  243. package/dist/telemetry-CkbkeJxl.mjs +0 -3
  244. package/dist/type-source-DH_LH20p.mjs +0 -13
  245. package/dist/type-source-DH_LH20p.mjs.map +0 -1
  246. package/dist/user-agent-Bgsszb5I.mjs +0 -28
  247. package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
  248. package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
  249. package/dist/wait-point-registry-TL99zotw.mjs +0 -47
  250. package/dist/wait-point-registry-TL99zotw.mjs.map +0 -1
  251. package/dist/workflow-Bamae_Yc.mjs +0 -34
  252. package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
@@ -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 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.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":"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"}
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.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":"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"}
@@ -1,24 +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
- const importStatement = 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`
22
3
  import { file } from "@tailor-platform/sdk/runtime/file";
23
4
  import type {
24
5
  FileUploadOptions,
@@ -26,22 +7,19 @@ function generateUnifiedFileUtils(namespaceData) {
26
7
  FileMetadata,
27
8
  FileDownloadStreamResponse,
28
9
  } from "@tailor-platform/sdk/runtime/file";
29
- ` + "\n";
30
- const interfaceDefinition = multiline`
10
+ `+`
11
+ `,o=e`
31
12
  export interface TypeWithFiles {
32
- ${interfaceFields}
13
+ ${i}
33
14
  }
34
- ` + "\n";
35
- const namespaceEntries = Array.from(typeNamespaceMap.entries()).map(([typeName, namespace]) => ` ${typeName}: "${namespace}"`).join(",\n");
36
- return [
37
- importStatement,
38
- interfaceDefinition,
39
- multiline`
15
+ `+`
16
+ `,s=Array.from(n.entries()).map(([e,t])=>` ${e}: "${t}"`).join(`,
17
+ `);return[a,o,e`
40
18
  const namespaces: Record<keyof TypeWithFiles, string> = {
41
- ${namespaceEntries},
19
+ ${s},
42
20
  };
43
- ` + "\n",
44
- multiline`
21
+ `+`
22
+ `,e`
45
23
  export async function downloadFile<T extends keyof TypeWithFiles>(
46
24
  type: T,
47
25
  field: TypeWithFiles[T]["fields"],
@@ -49,8 +27,8 @@ function generateUnifiedFileUtils(namespaceData) {
49
27
  ) {
50
28
  return await file.download(namespaces[type], type, field, recordId);
51
29
  }
52
- ` + "\n",
53
- multiline`
30
+ `+`
31
+ `,e`
54
32
  export async function uploadFile<T extends keyof TypeWithFiles>(
55
33
  type: T,
56
34
  field: TypeWithFiles[T]["fields"],
@@ -60,8 +38,8 @@ function generateUnifiedFileUtils(namespaceData) {
60
38
  ): Promise<FileUploadResponse> {
61
39
  return await file.upload(namespaces[type], type, field, recordId, data, options);
62
40
  }
63
- ` + "\n",
64
- multiline`
41
+ `+`
42
+ `,e`
65
43
  export async function deleteFile<T extends keyof TypeWithFiles>(
66
44
  type: T,
67
45
  field: TypeWithFiles[T]["fields"],
@@ -69,8 +47,8 @@ function generateUnifiedFileUtils(namespaceData) {
69
47
  ): Promise<void> {
70
48
  return await file.delete(namespaces[type], type, field, recordId);
71
49
  }
72
- ` + "\n",
73
- multiline`
50
+ `+`
51
+ `,e`
74
52
  export async function getFileMetadata<T extends keyof TypeWithFiles>(
75
53
  type: T,
76
54
  field: TypeWithFiles[T]["fields"],
@@ -78,8 +56,8 @@ function generateUnifiedFileUtils(namespaceData) {
78
56
  ): Promise<FileMetadata> {
79
57
  return await file.getMetadata(namespaces[type], type, field, recordId);
80
58
  }
81
- ` + "\n",
82
- multiline`
59
+ `+`
60
+ `,e`
83
61
  export async function downloadFileStream<T extends keyof TypeWithFiles>(
84
62
  type: T,
85
63
  field: TypeWithFiles[T]["fields"],
@@ -87,67 +65,7 @@ function generateUnifiedFileUtils(namespaceData) {
87
65
  ): Promise<FileDownloadStreamResponse> {
88
66
  return await file.downloadStream(namespaces[type], type, field, recordId);
89
67
  }
90
- ` + "\n"
91
- ].join("\n");
92
- }
93
-
94
- //#endregion
95
- //#region src/plugin/builtin/file-utils/process-file-type.ts
96
- /**
97
- * Process a TailorDB table and extract file field metadata.
98
- * @param type - The parsed TailorDB table to process
99
- * @returns File utility metadata for the table
100
- */
101
- async function processFileType(type) {
102
- const fileFields = [];
103
- if (type.files) for (const fileFieldName of Object.keys(type.files)) fileFields.push(fileFieldName);
104
- return {
105
- name: type.name,
106
- fileFields
107
- };
108
- }
109
-
110
- //#endregion
111
- //#region src/plugin/builtin/file-utils/index.ts
112
- /** Unique identifier for the file utilities generator plugin. */
113
- const FileUtilsGeneratorID = "@tailor-platform/file-utils";
114
- /**
115
- * Plugin that generates TypeWithFiles interface from TailorDB table definitions.
116
- * @param options - Plugin options
117
- * @param options.distPath - Output file path for generated file utilities
118
- * @returns Plugin instance with onTailorDBReady hook
119
- */
120
- function fileUtilsPlugin(options) {
121
- return {
122
- id: FileUtilsGeneratorID,
123
- description: "Generates TypeWithFiles interface from TailorDB table definitions",
124
- pluginConfig: options,
125
- async onTailorDBReady(ctx) {
126
- const namespaceData = [];
127
- for (const ns of ctx.tailordb) {
128
- const typesWithFiles = [];
129
- for (const type of Object.values(ns.types)) {
130
- const metadata = await processFileType(type);
131
- if (metadata.fileFields.length > 0) typesWithFiles.push(metadata);
132
- }
133
- if (typesWithFiles.length > 0) namespaceData.push({
134
- namespace: ns.namespace,
135
- types: typesWithFiles
136
- });
137
- }
138
- const files = [];
139
- if (namespaceData.length > 0) {
140
- const content = generateUnifiedFileUtils(namespaceData);
141
- if (content) files.push({
142
- path: ctx.pluginConfig.distPath,
143
- content
144
- });
145
- }
146
- return { files };
147
- }
148
- };
149
- }
150
-
151
- //#endregion
152
- 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};
153
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 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.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;CAEZ,MAAM,kBACJ,SAAmB;;;;;;;;QAQf;CAEN,MAAM,sBACJ,SAAmB;;QAEf,gBAAgB;;QAEhB;CAGN,MAAM,mBAAmB,MAAM,KAAK,iBAAiB,QAAQ,CAAC,CAAC,CAC5D,KAAK,CAAC,UAAU,eAAe,KAAK,SAAS,KAAK,UAAU,EAAE,CAAC,CAC/D,KAAK,KAAK;CAuEb,OAAO;EACL;EACA;EAtEA,SAAmB;;QAEf,iBAAiB;;QAEjB;EAIJ,SAAmB;;;;;;;;QAQf;EAIJ,SAAmB;;;;;;;;;;QAUf;EAIJ,SAAmB;;;;;;;;QAQf;EAIJ,SAAmB;;;;;;;;QAQf;EAIJ,SAAmB;;;;;;;;QAQf;CAWN,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;;;ACpIA,eAAsB,gBAAgB,MAA+C;CACnF,MAAM,aAAuB,CAAC;CAE9B,IAAI,KAAK,OACP,KAAK,MAAM,iBAAiB,OAAO,KAAK,KAAK,KAAK,GAChD,WAAW,KAAK,aAAa;CAIjC,OAAO;EACL,MAAM,KAAK;EACX;CACF;AACF;;;;;ACfA,MAAa,uBAAuB;;;;;;;AAYpC,SAAgB,gBACd,SACyC;CACzC,OAAO;EACL,IAAI;EACJ,aAAa;EACb,cAAc;EAEd,MAAM,gBACJ,KAC0B;GAC1B,MAAM,gBAAoE,CAAC;GAE3E,KAAK,MAAM,MAAM,IAAI,UAAU;IAC7B,MAAM,iBAAqC,CAAC;IAE5C,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG,KAAK,GAAG;KAC1C,MAAM,WAAW,MAAM,gBAAgB,IAAI;KAC3C,IAAI,SAAS,WAAW,SAAS,GAC/B,eAAe,KAAK,QAAQ;IAEhC;IAEA,IAAI,eAAe,SAAS,GAC1B,cAAc,KAAK;KACjB,WAAW,GAAG;KACd,OAAO;IACT,CAAC;GAEL;GAEA,MAAM,QAAkC,CAAC;GACzC,IAAI,cAAc,SAAS,GAAG;IAC5B,MAAM,UAAU,yBAAyB,aAAa;IACtD,IAAI,SACF,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;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 }\n\n return { files };\n },\n };\n}\n"],"mappings":"oDAQA,SAAgB,yBACd,EACQ,CACR,GAAI,EAAc,SAAW,EAC3B,MAAO,GAIT,IAAM,EAAoB,IAAI,IACxB,EAAgB,IAAI,IAE1B,IAAK,GAAM,CAAE,YAAW,WAAW,EACjC,IAAK,IAAM,KAAQ,EACjB,EAAkB,IAAI,EAAK,KAAM,CAAS,EAC1C,EAAc,IAAI,EAAK,KAAM,EAAK,UAAU,EAIhD,GAAI,EAAkB,OAAS,EAC7B,MAAO,GAIT,IAAM,EAAkB,MAAM,KAAK,EAAc,QAAQ,CAAC,CAAC,CACxD,KAAK,CAAC,EAAW,KAET,KAAK,EAAU,mBADE,EAAO,IAAK,GAAU,IAAI,EAAM,EAAE,CAAC,CAAC,KAAK,KACV,EAAE,QAC1D,CAAC,CACD,KAAK;CAAI,EAEN,EACJ,CAAmB;;;;;;;;MAQf;EAEA,EACJ,CAAmB;;QAEf,EAAgB;;MAEhB;EAGA,EAAmB,MAAM,KAAK,EAAkB,QAAQ,CAAC,CAAC,CAC7D,KAAK,CAAC,EAAW,KAAe,KAAK,EAAU,KAAK,EAAU,EAAE,CAAC,CACjE,KAAK;CAAK,EAuEb,MAAO,CACL,EACA,EAtEA,CAAmB;;QAEf,EAAiB;;MAEjB;EAIJ,CAAmB;;;;;;;;MAQf;EAIJ,CAAmB;;;;;;;;;;MAUf;EAIJ,CAAmB;;;;;;;;MAQf;EAIJ,CAAmB;;;;;;;;MAQf;EAIJ,CAAmB;;;;;;;;MAQf;CAWN,CAAC,CAAC,KAAK;CAAI,CACb,CCpIA,eAAsB,gBAAgB,EAA+C,CACnF,IAAM,EAAuB,CAAC,EAE9B,GAAI,EAAK,MACP,IAAK,IAAM,KAAiB,OAAO,KAAK,EAAK,KAAK,EAChD,EAAW,KAAK,CAAa,EAIjC,MAAO,CACL,KAAM,EAAK,KACX,YACF,CACF,CCfA,MAAa,EAAuB,8BAYpC,SAAgB,gBACd,EACyC,CACzC,MAAO,CACL,GAAI,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,6 +5,13 @@ 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
16
  * Plugin that generates Kysely type definitions for TailorDB tables.
10
17
  * @param options - Plugin options
@@ -13,4 +20,4 @@ type KyselyTypePluginOptions = {
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 };
@@ -1,275 +1 @@
1
- import { t as multiline } from "../../../multiline-sfHpTZZK.mjs";
2
-
3
- //#region src/plugin/builtin/kysely-type/type-processor.ts
4
- /**
5
- * Get the enum type definition.
6
- * @param fieldConfig - The field configuration
7
- * @returns The enum type as a string union
8
- */
9
- function getEnumType(fieldConfig) {
10
- const allowedValues = fieldConfig.allowedValues;
11
- if (allowedValues && Array.isArray(allowedValues)) return allowedValues.map((v) => {
12
- return `"${typeof v === "string" ? v : v.value}"`;
13
- }).join(" | ");
14
- return "string";
15
- }
16
- /**
17
- * Get the nested object type definition.
18
- * @param fieldConfig - The field configuration
19
- * @returns The nested type with used utility types
20
- */
21
- function getNestedType(fieldConfig) {
22
- const fields = fieldConfig.fields;
23
- if (!fields || typeof fields !== "object") return {
24
- type: "string",
25
- usedUtilityTypes: {
26
- Timestamp: false,
27
- Serial: false
28
- }
29
- };
30
- const fieldResults = Object.entries(fields).map(([fieldName, config]) => {
31
- const result = generateFieldType(config);
32
- return {
33
- fieldType: `${fieldName}${config.required !== true ? "?" : ""}: ${result.type}`,
34
- usedUtilityTypes: result.usedUtilityTypes
35
- };
36
- });
37
- const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
38
- Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
39
- Serial: acc.Serial || result.usedUtilityTypes.Serial
40
- }), {
41
- Timestamp: false,
42
- Serial: false
43
- });
44
- const fieldTypes = fieldResults.map((r) => r.fieldType);
45
- const obj = `{\n ${fieldTypes.join(";\n ")}${fieldTypes.length > 0 ? ";" : ""}\n}`;
46
- const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);
47
- const hasGeneratedFields = Object.values(fields).some((config) => config.hooks?.create || config.default !== void 0);
48
- if (aggregatedUtilityTypes.Timestamp || hasOptionalFields || hasGeneratedFields) return {
49
- type: `ObjectColumnType<${obj}>`,
50
- usedUtilityTypes: aggregatedUtilityTypes
51
- };
52
- return {
53
- type: obj,
54
- usedUtilityTypes: aggregatedUtilityTypes
55
- };
56
- }
57
- /**
58
- * Get the base Kysely type for a field (without array/null modifiers).
59
- * @param fieldConfig - The field configuration
60
- * @returns The base type with used utility types
61
- */
62
- function getBaseType(fieldConfig) {
63
- const fieldType = fieldConfig.type;
64
- const usedUtilityTypes = {
65
- Timestamp: false,
66
- Serial: false
67
- };
68
- let type;
69
- switch (fieldType) {
70
- case "uuid":
71
- case "string":
72
- case "decimal":
73
- type = "string";
74
- break;
75
- case "integer":
76
- case "float":
77
- type = "number";
78
- break;
79
- case "date":
80
- case "datetime":
81
- usedUtilityTypes.Timestamp = true;
82
- type = "Timestamp";
83
- break;
84
- case "bool":
85
- case "boolean":
86
- type = "boolean";
87
- break;
88
- case "enum":
89
- type = getEnumType(fieldConfig);
90
- break;
91
- case "nested": return getNestedType(fieldConfig);
92
- default: type = "string";
93
- }
94
- return {
95
- type,
96
- usedUtilityTypes
97
- };
98
- }
99
- /**
100
- * Generate the complete field type including array and null modifiers.
101
- * @param fieldConfig - The field configuration
102
- * @returns The complete field type with used utility types
103
- */
104
- function generateFieldType(fieldConfig) {
105
- const baseTypeResult = getBaseType(fieldConfig);
106
- const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };
107
- const isArray = fieldConfig.array === true;
108
- const isNullable = fieldConfig.required !== true;
109
- const isColumnTypeBase = (/* @__PURE__ */ new Set(["Timestamp"])).has(baseTypeResult.type);
110
- let finalType = baseTypeResult.type;
111
- if (isArray) {
112
- if (isColumnTypeBase || finalType.startsWith("ObjectColumnType<")) finalType = `ArrayColumnType<${baseTypeResult.type}>`;
113
- else finalType = fieldConfig.type === "enum" ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;
114
- }
115
- if (isNullable) finalType = `${finalType} | null`;
116
- if (fieldConfig.serial) {
117
- usedUtilityTypes.Serial = true;
118
- finalType = `Serial<${finalType}>`;
119
- }
120
- if (fieldConfig.hooks?.create || fieldConfig.default !== void 0) finalType = `Generated<${finalType}>`;
121
- return {
122
- type: finalType,
123
- usedUtilityTypes
124
- };
125
- }
126
- /**
127
- * Generate the table interface.
128
- * @param type - The parsed TailorDB table
129
- * @returns The type definition and used utility types
130
- */
131
- function generateTableInterface(type) {
132
- const fieldResults = Object.entries(type.fields).filter(([fieldName]) => fieldName !== "id").map(([fieldName, parsedField]) => ({
133
- fieldName,
134
- ...generateFieldType(parsedField.config)
135
- }));
136
- const fields = ["id: Generated<string>;", ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`)];
137
- const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
138
- Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
139
- Serial: acc.Serial || result.usedUtilityTypes.Serial
140
- }), {
141
- Timestamp: false,
142
- Serial: false
143
- });
144
- return {
145
- typeDef: multiline`
146
- ${type.name}: {
147
- ${fields.join("\n")}
148
- }
149
- `,
150
- usedUtilityTypes: aggregatedUtilityTypes
151
- };
152
- }
153
- /**
154
- * Convert a TailorDBType into KyselyTypeMetadata.
155
- * @param type - Parsed TailorDB table
156
- * @returns Generated Kysely type metadata
157
- */
158
- async function processKyselyType(type) {
159
- const result = generateTableInterface(type);
160
- return {
161
- name: type.name,
162
- typeDef: result.typeDef,
163
- usedUtilityTypes: result.usedUtilityTypes
164
- };
165
- }
166
- /**
167
- * Generate unified types file from multiple namespaces.
168
- * @param namespaceData - Namespace metadata
169
- * @returns Generated types file contents
170
- */
171
- function generateUnifiedKyselyTypes(namespaceData) {
172
- if (namespaceData.length === 0) return "";
173
- const globalUsedUtilityTypes = namespaceData.reduce((acc, ns) => ({
174
- Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,
175
- Serial: acc.Serial || ns.usedUtilityTypes.Serial
176
- }), {
177
- Timestamp: false,
178
- Serial: false
179
- });
180
- const utilityTypeImports = ["type Generated"];
181
- if (globalUsedUtilityTypes.Timestamp) utilityTypeImports.push("type Timestamp");
182
- if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ObjectColumnType<")))) utilityTypeImports.push("type ObjectColumnType");
183
- if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ArrayColumnType<")))) utilityTypeImports.push("type ArrayColumnType");
184
- if (globalUsedUtilityTypes.Serial) utilityTypeImports.push("type Serial");
185
- return [
186
- multiline`
187
- import {
188
- createGetDB,
189
- ${utilityTypeImports.join(",\n")},
190
- type NamespaceDB,
191
- type NamespaceInsertable,
192
- type NamespaceSelectable,
193
- type NamespaceTable,
194
- type NamespaceTableName,
195
- type NamespaceTransaction,
196
- type NamespaceUpdateable,
197
- } from "@tailor-platform/sdk/kysely";
198
- `,
199
- `export interface Namespace {\n${namespaceData.map(({ namespace, types }) => {
200
- return ` "${namespace}": {\n${types.map((type) => {
201
- return type.typeDef.split("\n").map((line) => line.trim() ? ` ${line}` : "").join("\n");
202
- }).join("\n\n")}\n }`;
203
- }).join(",\n")}\n}`,
204
- multiline`
205
- export const getDB = createGetDB<Namespace>();
206
-
207
- export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
208
- `,
209
- multiline`
210
- export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
211
- NamespaceTransaction<Namespace, K>;
212
-
213
- type TableName = NamespaceTableName<Namespace>;
214
- export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
215
-
216
- export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
217
- export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
218
- export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
219
- `
220
- ].join("\n\n") + "\n";
221
- }
222
-
223
- //#endregion
224
- //#region src/plugin/builtin/kysely-type/index.ts
225
- /** Unique identifier for the Kysely type generator plugin. */
226
- const KyselyGeneratorID = "@tailor-platform/kysely-type";
227
- /**
228
- * Plugin that generates Kysely type definitions for TailorDB tables.
229
- * @param options - Plugin options
230
- * @param options.distPath - Output file path for generated types
231
- * @returns Plugin instance with onTailorDBReady hook
232
- */
233
- function kyselyTypePlugin(options) {
234
- return {
235
- id: KyselyGeneratorID,
236
- description: "Generates Kysely type definitions for TailorDB tables",
237
- pluginConfig: options,
238
- async onTailorDBReady(ctx) {
239
- const allNamespaceData = [];
240
- for (const ns of ctx.tailordb) {
241
- const typeMetadataList = [];
242
- for (const type of Object.values(ns.types)) {
243
- const metadata = await processKyselyType(type);
244
- typeMetadataList.push(metadata);
245
- }
246
- if (typeMetadataList.length === 0) continue;
247
- const usedUtilityTypes = typeMetadataList.reduce((acc, type) => ({
248
- Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,
249
- Serial: acc.Serial || type.usedUtilityTypes.Serial
250
- }), {
251
- Timestamp: false,
252
- Serial: false
253
- });
254
- allNamespaceData.push({
255
- namespace: ns.namespace,
256
- types: typeMetadataList,
257
- usedUtilityTypes
258
- });
259
- }
260
- const files = [];
261
- if (allNamespaceData.length > 0) {
262
- const content = generateUnifiedKyselyTypes(allNamespaceData);
263
- files.push({
264
- path: ctx.pluginConfig.distPath,
265
- content
266
- });
267
- }
268
- return { files };
269
- }
270
- };
271
- }
272
-
273
- //#endregion
274
- export { KyselyGeneratorID, kyselyTypePlugin };
275
- //# sourceMappingURL=index.mjs.map
1
+ import{n as e,r as t,t as n}from"../../../kysely-type-BTi3BMtL.mjs";export{n as DEFAULT_KYSELY_TYPES_DIST_PATH,e as KyselyGeneratorID,t as kyselyTypePlugin};
@@ -32,6 +32,11 @@ type SeedPluginOptions = {
32
32
  */
33
33
  disableIdpUserSync?: DisableIdpUserSyncDirections;
34
34
  };
35
+ declare module "@tailor-platform/sdk/plugin" {
36
+ interface PluginConfigRegistry {
37
+ "@tailor-platform/seed": SeedPluginOptions;
38
+ }
39
+ }
35
40
  /**
36
41
  * Plugin that generates seed data and schema files consumed by the
37
42
  * `tailor seed` commands (@tailor-platform/sdk-plugin-seed).
@@ -1,3 +1 @@
1
- import { n as seedPlugin, t as SeedGeneratorID } from "../../../seed-Cibjmtry.mjs";
2
-
3
- export { SeedGeneratorID, seedPlugin };
1
+ import{n as e,t}from"../../../seed-DwqRFdqP.mjs";export{t as SeedGeneratorID,e as seedPlugin};
@@ -1,6 +1,4 @@
1
- import "../../../parser/service/tailordb/types.mjs";
2
1
  import "../../types.mjs";
3
- import "./types.mjs";
4
2
  //#region src/plugin/builtin/seed/seed-type-processor.d.ts
5
3
  /**
6
4
  * Seed ordering information for a TailorDB namespace.
@@ -1,16 +1,16 @@
1
1
  import { TailorAnyDBType } from "../configure/services/tailordb/types.mjs";
2
- //#region src/plugin/get-generated-type.d.ts
2
+ //#region src/plugin/get-generated-table.d.ts
3
3
  /**
4
4
  * Get a generated table from a plugin by loading the config and resolving everything automatically.
5
- * For type-attached plugins, calls onTypeLoaded() with the sourceType.
5
+ * For table-attached plugins, calls onTableLoaded() with the source table.
6
6
  * For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.
7
7
  * Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.
8
8
  * @param configPath - Path to tailor.config.ts (absolute or relative to cwd)
9
9
  * @param pluginId - The plugin's unique identifier
10
- * @param sourceType - The source TailorDB table (null for namespace plugins)
10
+ * @param sourceTable - The source TailorDB table (null for namespace plugins)
11
11
  * @param kind - The generated table kind (e.g., "request", "step")
12
12
  * @returns The generated TailorDB table
13
13
  */
14
- declare function getGeneratedType(configPath: string, pluginId: string, sourceType: TailorAnyDBType | null, kind: string): Promise<TailorAnyDBType>;
14
+ declare function getGeneratedTable(configPath: string, pluginId: string, sourceTable: TailorAnyDBType | null, kind: string): Promise<TailorAnyDBType>;
15
15
  //#endregion
16
- export { getGeneratedType };
16
+ export { getGeneratedTable };
@@ -1,3 +1,4 @@
1
+ import { PluginConfigRegistry } from "./types.mjs";
1
2
  import { PluginDBSchema, PluginExecutorFactory, PluginFunctionArgs, PluginRecord, PluginRecordCreatedArgs, PluginRecordDeletedArgs, PluginRecordUpdatedArgs, withPluginContext } from "./with-context.mjs";
2
- import { getGeneratedType } from "./get-generated-type.mjs";
3
- export { type PluginDBSchema, type PluginExecutorFactory, type PluginFunctionArgs, type PluginRecord, type PluginRecordCreatedArgs, type PluginRecordDeletedArgs, type PluginRecordUpdatedArgs, getGeneratedType, withPluginContext };
3
+ import { getGeneratedTable } from "./get-generated-table.mjs";
4
+ export { type PluginConfigRegistry, type PluginDBSchema, type PluginExecutorFactory, type PluginFunctionArgs, type PluginRecord, type PluginRecordCreatedArgs, type PluginRecordDeletedArgs, type PluginRecordUpdatedArgs, getGeneratedTable, withPluginContext };