@tailor-platform/sdk 2.4.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 (234) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/dist/aigateway-DsWDjzk4.mjs +2 -0
  3. package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
  4. package/dist/application-DFOUovmN.mjs +1 -0
  5. package/dist/application-D_4vg1KR.mjs +192 -0
  6. package/dist/application-D_4vg1KR.mjs.map +1 -0
  7. package/dist/assert-WeXvmG4j.mjs +2 -0
  8. package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
  9. package/dist/authconnection-CynFBIv8.mjs +2 -0
  10. package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
  11. package/dist/brand-C8nMKhJC.mjs +2 -0
  12. package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
  13. package/dist/cli/commands/deploy/deploy.d.mts +2 -2
  14. package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
  15. package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
  16. package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
  17. package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
  18. package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
  19. package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
  20. package/dist/cli/commands/executor/jobs.d.mts +1 -1
  21. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
  22. package/dist/cli/commands/show.d.mts +1 -1
  23. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -11
  24. package/dist/cli/commands/tailordb/migrate/generate.d.mts +4 -0
  25. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
  26. package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
  27. package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
  28. package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
  29. package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
  30. package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
  31. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
  32. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
  33. package/dist/cli/lib.d.mts +8 -4
  34. package/dist/cli/lib.mjs +1 -9
  35. package/dist/cli/lib.mjs.map +1 -1
  36. package/dist/cli/main.mjs +1170 -7754
  37. package/dist/cli/main.mjs.map +1 -1
  38. package/dist/cli/shared/seed-chunker.d.mts +5 -5
  39. package/dist/completion/zsh-worker.zsh +82 -9
  40. package/dist/configure/config/index.d.mts +1 -1
  41. package/dist/configure/config/types.d.mts +2 -2
  42. package/dist/configure/index.d.mts +48 -12
  43. package/dist/configure/index.mjs +1 -1267
  44. package/dist/configure/index.mjs.map +1 -1
  45. package/dist/configure/services/auth/types.d.mts +1 -1
  46. package/dist/configure/services/idp/types.d.mts +1 -1
  47. package/dist/configure/services/tailordb/schema.d.mts +4 -8
  48. package/dist/configure/services/tailordb/types.d.mts +1 -1
  49. package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
  50. package/dist/configure/services/workflow/job.d.mts +12 -2
  51. package/dist/configure/types/field.types.d.mts +1 -1
  52. package/dist/configure/types/permission-operand.types.d.mts +1 -1
  53. package/dist/context-D0QjfxzD.mjs +2 -0
  54. package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
  55. package/dist/crashreport-B-_HTKLr.mjs +42 -0
  56. package/dist/{crashreport-Q0pDAlrj.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
  57. package/dist/crashreport-BmsRIdpy.mjs +1 -0
  58. package/dist/errors-DSEXKRVD.mjs +2 -0
  59. package/dist/errors-DSEXKRVD.mjs.map +1 -0
  60. package/dist/file-COPYfju_.mjs +2 -0
  61. package/dist/file-COPYfju_.mjs.map +1 -0
  62. package/dist/globals-CMHSnj4w.mjs +2 -0
  63. package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
  64. package/dist/iconv-DlFMt2gW.mjs +2 -0
  65. package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
  66. package/dist/idp-G_ojPBB5.mjs +2 -0
  67. package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
  68. package/dist/interceptor-DQg3cR_9.mjs +2 -0
  69. package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
  70. package/dist/kysely/index.mjs +1 -32
  71. package/dist/kysely/index.mjs.map +1 -1
  72. package/dist/kysely-type-BTi3BMtL.mjs +43 -0
  73. package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
  74. package/dist/logger-BcGy-u7G.mjs +9 -0
  75. package/dist/{logger-D0bEznPv.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
  76. package/dist/logger-DP2BjQ93.mjs +2 -0
  77. package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
  78. package/dist/multiline-EyzjEwn9.mjs +3 -0
  79. package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
  80. package/dist/node-builtins-oBl7EbyV.mjs +2 -0
  81. package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
  82. package/dist/package-json-C690ceex.mjs +2 -0
  83. package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
  84. package/dist/package-json-CmqhDJ__.mjs +1 -0
  85. package/dist/parser/service/tailordb/type-source.d.mts +5 -5
  86. package/dist/parser/service/tailordb/types.d.mts +4 -4
  87. package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
  88. package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
  89. package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
  90. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  91. package/dist/plugin/builtin/file-utils/index.mjs +22 -104
  92. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  93. package/dist/plugin/builtin/kysely-type/index.d.mts +8 -1
  94. package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
  95. package/dist/plugin/builtin/seed/index.d.mts +5 -0
  96. package/dist/plugin/builtin/seed/index.mjs +1 -3
  97. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +0 -2
  98. package/dist/plugin/{get-generated-type.d.mts → get-generated-table.d.mts} +5 -5
  99. package/dist/plugin/index.d.mts +3 -2
  100. package/dist/plugin/index.mjs +1 -251
  101. package/dist/plugin/index.mjs.map +1 -1
  102. package/dist/plugin/types.d.mts +30 -23
  103. package/dist/plugin/with-context.d.mts +3 -3
  104. package/dist/register-ts-hook-Drnaproy.mjs +640 -0
  105. package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
  106. package/dist/registry-HlEaGvl5.mjs +2 -0
  107. package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
  108. package/dist/repl-editor-BG1aDOfH.mjs +2 -0
  109. package/dist/{repl-editor-F9LotMNx.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
  110. package/dist/runtime/aigateway.mjs +1 -3
  111. package/dist/runtime/authconnection.mjs +1 -3
  112. package/dist/runtime/context.mjs +1 -3
  113. package/dist/runtime/file.d.mts +21 -21
  114. package/dist/runtime/file.mjs +1 -3
  115. package/dist/runtime/globals.mjs +1 -1
  116. package/dist/runtime/iconv.mjs +1 -3
  117. package/dist/runtime/idp.mjs +1 -3
  118. package/dist/runtime/index.mjs +1 -11
  119. package/dist/runtime/logger.mjs +1 -3
  120. package/dist/runtime/secretmanager.mjs +1 -3
  121. package/dist/runtime/types.d.mts +1 -1
  122. package/dist/runtime/workflow.mjs +1 -3
  123. package/dist/schema-Ze_dI5VX.mjs +2 -0
  124. package/dist/schema-Ze_dI5VX.mjs.map +1 -0
  125. package/dist/secret-file-C9wp_FCX.mjs +2 -0
  126. package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
  127. package/dist/secretmanager-5olfnI1b.mjs +2 -0
  128. package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
  129. package/dist/secretmanager-vHQoXdQz.mjs +2 -0
  130. package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
  131. package/dist/seed/index.mjs +8 -244
  132. package/dist/seed/index.mjs.map +1 -1
  133. package/dist/seed-DwqRFdqP.mjs +207 -0
  134. package/dist/seed-DwqRFdqP.mjs.map +1 -0
  135. package/dist/service-BVe9u2Rt.mjs +7 -0
  136. package/dist/service-BVe9u2Rt.mjs.map +1 -0
  137. package/dist/service-CpZELSBa.mjs +1 -0
  138. package/dist/service-DlgaUO4V.mjs +2 -0
  139. package/dist/{service-LTfp03ZZ.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
  140. package/dist/service_pb-DGKCLuAs.mjs +2 -0
  141. package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
  142. package/dist/service_pb-_aeFE-Nv.mjs +1 -0
  143. package/dist/telemetry-Bklv9kQY.mjs +2 -0
  144. package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
  145. package/dist/telemetry-DXHP3VVi.mjs +1 -0
  146. package/dist/type-source--ZNcV8RJ.mjs +2 -0
  147. package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
  148. package/dist/types/executor.generated.d.mts +1 -1
  149. package/dist/user-agent-vdHYF3QL.mjs +2 -0
  150. package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
  151. package/dist/utils/test/index.mjs +1 -109
  152. package/dist/utils/test/index.mjs.map +1 -1
  153. package/dist/vitest/environment.mjs +1 -41
  154. package/dist/vitest/environment.mjs.map +1 -1
  155. package/dist/vitest/index.mjs +1 -1986
  156. package/dist/vitest/index.mjs.map +1 -1
  157. package/dist/vitest/mocks/file.d.mts +8 -8
  158. package/dist/vitest/setup.mjs +1 -140
  159. package/dist/vitest/setup.mjs.map +1 -1
  160. package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
  161. package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
  162. package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
  163. package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
  164. package/dist/workflow-Cs9ISw6j.mjs +2 -0
  165. package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
  166. package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
  167. package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
  168. package/docs/cli/function.md +66 -6
  169. package/docs/cli/setup.md +24 -14
  170. package/docs/cli/tailordb.md +2 -0
  171. package/docs/cli-reference.md +9 -8
  172. package/docs/github-actions.md +10 -9
  173. package/docs/migration/v2.md +13 -1
  174. package/docs/migration/v3.md +82 -0
  175. package/docs/plugin/custom.md +130 -85
  176. package/docs/plugin/index.md +3 -3
  177. package/docs/services/tailordb-migration.md +21 -7
  178. package/docs/services/workflow.md +10 -9
  179. package/package.json +11 -11
  180. package/postinstall.mjs +1 -1
  181. package/dist/aigateway-DR4Kwuik.mjs +0 -9
  182. package/dist/application-C8a0UJ-z.mjs +0 -6071
  183. package/dist/application-C8a0UJ-z.mjs.map +0 -1
  184. package/dist/application-D4zOiLLa.mjs +0 -3
  185. package/dist/assert-DBxo8jPo.mjs +0 -9
  186. package/dist/authconnection-CZvi9ANm.mjs +0 -9
  187. package/dist/brand-Eo4pLXPJ.mjs +0 -36
  188. package/dist/context-DYQVYWqZ.mjs +0 -23
  189. package/dist/crashreport-Cd4TqfZq.mjs +0 -3
  190. package/dist/crashreport-Q0pDAlrj.mjs +0 -427
  191. package/dist/errors-Bxut5_Sy.mjs +0 -89
  192. package/dist/errors-Bxut5_Sy.mjs.map +0 -1
  193. package/dist/file-BUcmVIH2.mjs +0 -58
  194. package/dist/file-BUcmVIH2.mjs.map +0 -1
  195. package/dist/globals-B2nlxBrz.mjs +0 -126
  196. package/dist/iconv-QWaZh0TT.mjs +0 -38
  197. package/dist/idp-RA_swu-h.mjs +0 -82
  198. package/dist/interceptor-e33JtsC-.mjs +0 -33
  199. package/dist/logger-BtX0suGY.mjs +0 -48
  200. package/dist/logger-D0bEznPv.mjs +0 -362
  201. package/dist/multiline-sfHpTZZK.mjs +0 -38
  202. package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
  203. package/dist/package-json-8b0O9TlX.mjs +0 -17
  204. package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
  205. package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
  206. package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
  207. package/dist/plugin/builtin/seed/types.d.mts +0 -2
  208. package/dist/register-ts-hook-Vqjza10T.mjs +0 -25679
  209. package/dist/register-ts-hook-Vqjza10T.mjs.map +0 -1
  210. package/dist/registry-BIGVUrMB.mjs +0 -54
  211. package/dist/repl-editor-F9LotMNx.mjs +0 -252
  212. package/dist/schema-D4TC4BC3.mjs +0 -640
  213. package/dist/schema-D4TC4BC3.mjs.map +0 -1
  214. package/dist/secret-file-C3J4Gy8r.mjs +0 -64
  215. package/dist/secretmanager-CYlpffsz.mjs +0 -13
  216. package/dist/secretmanager-IY4UvinW.mjs +0 -131
  217. package/dist/seed-Cibjmtry.mjs +0 -489
  218. package/dist/seed-Cibjmtry.mjs.map +0 -1
  219. package/dist/service-2grcAOCJ.mjs +0 -898
  220. package/dist/service-2grcAOCJ.mjs.map +0 -1
  221. package/dist/service-CaBPNDIZ.mjs +0 -3
  222. package/dist/service-LTfp03ZZ.mjs +0 -133
  223. package/dist/service_pb-BEWj1pOV.mjs +0 -167
  224. package/dist/service_pb-BjlhvK9E.mjs +0 -3
  225. package/dist/telemetry-BRVdwh14.mjs +0 -84
  226. package/dist/telemetry-CkbkeJxl.mjs +0 -3
  227. package/dist/type-source-DH_LH20p.mjs +0 -13
  228. package/dist/type-source-DH_LH20p.mjs.map +0 -1
  229. package/dist/user-agent-Bgsszb5I.mjs +0 -28
  230. package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
  231. package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
  232. package/dist/wait-point-registry-TL99zotw.mjs +0 -47
  233. package/dist/workflow-Bamae_Yc.mjs +0 -34
  234. package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/plugin/with-context.ts","../../src/plugin/get-generated-type.ts"],"sourcesContent":["/**\n * Plugin executor context support for defining plugin executors in separate files.\n * This module provides utilities for creating type-safe plugin executors that receive\n * context (like table references and namespace) at runtime.\n */\n\nimport type { TailorEnv, TailorPrincipal } from \"#/runtime/types\";\n\n/**\n * Plugin executor factory function type.\n * Takes context and returns an executor configuration.\n * Returns unknown since the exact return type depends on createExecutor's generic params.\n */\nexport type PluginExecutorFactory<Ctx> = (ctx: Ctx) => unknown;\n\n// ============================================================================\n// Plugin Executor Args Types\n// ============================================================================\n\n/**\n * Base args for plugin executor function operations.\n * Provides typed access to runtime context without requiring specific record types.\n */\nexport interface PluginFunctionArgs {\n /** Workspace ID where the executor runs */\n workspaceId: string;\n /** Application namespace */\n appNamespace: string;\n /** Environment variables */\n env: TailorEnv;\n /** Principal that triggered the event, null for system events */\n actor: TailorPrincipal | null;\n /** Name of the TailorDB table */\n typeName: string;\n /** TailorDB connections by namespace */\n tailordb: Record<string, unknown>;\n}\n\n/**\n * Args for plugin executors triggered on record creation.\n */\nexport interface PluginRecordCreatedArgs extends PluginFunctionArgs {\n /** The newly created record */\n newRecord: Record<string, unknown>;\n}\n\n/**\n * Args for plugin executors triggered on record update.\n */\nexport interface PluginRecordUpdatedArgs extends PluginFunctionArgs {\n /** The record after update */\n newRecord: Record<string, unknown>;\n /** The record before update */\n oldRecord: Record<string, unknown>;\n}\n\n/**\n * Args for plugin executors triggered on record deletion.\n */\nexport interface PluginRecordDeletedArgs extends PluginFunctionArgs {\n /** The deleted record */\n oldRecord: Record<string, unknown>;\n}\n\n/**\n * Database schema type for plugins.\n * Since plugins work with dynamic types, the schema uses Record types.\n */\nexport type PluginDBSchema = Record<string, Record<string, unknown>>;\n\n/**\n * Base record type for TailorDB records.\n * All records have an id field.\n */\nexport type PluginRecord = { id: string } & Record<string, unknown>;\n\n/**\n * Define a plugin executor that receives context at runtime.\n * This allows executor definitions to be in separate files while\n * still receiving dynamic values like typeName, generated types, and namespace.\n * @param factory - Function that takes context and returns executor configuration\n * @returns The same factory function (for type inference)\n * @example\n * ```typescript\n * // executors/on-create.ts\n * import { withPluginContext } from \"@tailor-platform/sdk/plugin\";\n * import { createExecutor, recordCreatedTrigger } from \"@tailor-platform/sdk\";\n * import { getDB } from \"@tailor-platform/function-kysely-tailordb\";\n *\n * interface MyContext {\n * sourceType: TailorAnyDBType;\n * historyType: TailorAnyDBType;\n * namespace: string;\n * }\n *\n * export default withPluginContext<MyContext>((ctx) =>\n * createExecutor({\n * name: `${ctx.sourceType.name.toLowerCase()}-on-create`,\n * trigger: recordCreatedTrigger({ type: ctx.sourceType }),\n * operation: {\n * kind: \"function\",\n * body: async (args) => {\n * const db = getDB(ctx.namespace);\n * await db.insertInto(ctx.historyType.name).values({\n * recordId: args.newRecord.id,\n * // ...\n * }).execute();\n * },\n * },\n * })\n * );\n * ```\n */\nexport function withPluginContext<Ctx>(\n factory: PluginExecutorFactory<Ctx>,\n): PluginExecutorFactory<Ctx> {\n return factory;\n}\n","import * as fs from \"node:fs\";\nimport { pathToFileURL } from \"node:url\";\nimport * as path from \"pathe\";\nimport type { TailorAnyDBType } from \"#/configure/services/tailordb/types\";\nimport type { Plugin, PluginOutput, TypePluginOutput } from \"#/plugin/types\";\n\n// ========================================\n// Config loading and caching\n// ========================================\n\ninterface PluginEntry {\n plugin: Plugin;\n pluginConfig: unknown;\n}\n\ninterface ConfigCache {\n config: { db?: Record<string, unknown> };\n plugins: Map<string, PluginEntry>;\n configDir: string;\n}\n\n/** Cache: resolved config path -> loaded config data */\nconst configCacheMap = new Map<string, ConfigCache>();\n\n/**\n * Check if a value is a Plugin instance.\n * @param value - Value to check\n * @returns True if value has the shape of Plugin\n */\nfunction isPlugin(value: unknown): value is Plugin {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<string, unknown>).id === \"string\" &&\n typeof (value as Record<string, unknown>).description === \"string\"\n );\n}\n\n/**\n * Load and cache config module from the given path.\n * Extracts plugins from all array exports using definePlugins() format.\n * Returns null if the config file does not exist (e.g., in bundled executor on platform server).\n * @param configPath - Absolute or relative path to tailor.config.ts\n * @returns Cached config data with plugins map, or null if config file is not available\n */\nasync function loadAndCacheConfig(configPath: string): Promise<ConfigCache | null> {\n const resolvedPath = path.resolve(configPath);\n\n const cached = configCacheMap.get(resolvedPath);\n if (cached) return cached;\n\n // Config file may not exist in bundled environments (e.g., platform server)\n if (!fs.existsSync(resolvedPath)) {\n return null;\n }\n\n const configModule = await import(pathToFileURL(resolvedPath).href);\n if (!configModule?.default) {\n throw new Error(`Invalid config module at \"${resolvedPath}\": default export not found`);\n }\n\n const config = configModule.default as { db?: Record<string, unknown> };\n const configDir = path.dirname(resolvedPath);\n const plugins = new Map<string, PluginEntry>();\n\n // Find plugin arrays from exports (definePlugins returns PluginConfig[])\n for (const value of Object.values(configModule)) {\n if (!Array.isArray(value)) continue;\n\n for (const item of value) {\n if (isPlugin(item)) {\n plugins.set(item.id, { plugin: item, pluginConfig: item.pluginConfig });\n }\n }\n }\n\n const result: ConfigCache = { config, plugins, configDir };\n configCacheMap.set(resolvedPath, result);\n return result;\n}\n\n// ========================================\n// Namespace resolution\n// ========================================\n\ninterface DbNamespaceConfig {\n files?: string[];\n external?: boolean;\n}\n\n/**\n * Resolve the namespace for a type-attached sourceType by checking config.db file patterns.\n * Uses ESM module cache identity: same file path yields same object references.\n * @param config - App config with db namespace definitions\n * @param config.db - DB namespace definitions\n * @param configDir - Directory containing the config file\n * @param sourceType - The TailorDB table to look up\n * @returns The namespace name\n */\nasync function resolveNamespaceForType(\n config: { db?: Record<string, unknown> },\n configDir: string,\n sourceType: TailorAnyDBType,\n): Promise<string> {\n if (!config.db) {\n throw new Error(`No db configuration found in config`);\n }\n\n for (const [namespace, nsConfig] of Object.entries(config.db)) {\n const dbConfig = nsConfig as DbNamespaceConfig;\n // Skip external namespaces (no files to resolve)\n if (dbConfig.external || !dbConfig.files) continue;\n\n for (const pattern of dbConfig.files) {\n const absolutePattern = path.resolve(configDir, pattern);\n let matchedFiles: string[];\n try {\n matchedFiles = fs.globSync(absolutePattern);\n } catch {\n continue;\n }\n\n for (const file of matchedFiles) {\n const mod = await import(pathToFileURL(file).href);\n for (const exported of Object.values(mod)) {\n if (exported === sourceType) {\n return namespace;\n }\n }\n }\n }\n }\n\n throw new Error(\n `Could not resolve namespace for type \"${sourceType.name}\". ` +\n `Ensure the type file is included in a db namespace's files pattern.`,\n );\n}\n\n/**\n * Resolve the namespace for a namespace plugin by trying each namespace.\n * Calls onNamespaceLoaded() for each and returns the first whose output contains the requested kind.\n * @param config - App config with db namespace definitions\n * @param config.db - DB namespace definitions\n * @param plugin - Plugin instance\n * @param kind - The generated table kind to look for\n * @param pluginConfig - Plugin-level configuration\n * @returns The namespace name\n */\nasync function resolveNamespaceForNamespacePlugin(\n config: { db?: Record<string, unknown> },\n plugin: Plugin,\n kind: string,\n pluginConfig: unknown,\n): Promise<{ namespace: string; output: PluginOutput }> {\n if (!config.db) {\n throw new Error(`No db configuration found in config`);\n }\n\n if (!plugin.onNamespaceLoaded) {\n throw new Error(`Plugin \"${plugin.id}\" does not have a onNamespaceLoaded() method`);\n }\n\n for (const namespace of Object.keys(config.db)) {\n const dbConfig = config.db[namespace] as DbNamespaceConfig;\n if (dbConfig.external) continue;\n\n const output = await plugin.onNamespaceLoaded({\n pluginConfig,\n namespace,\n });\n\n if (output.types?.[kind]) {\n return { namespace, output };\n }\n }\n\n throw new Error(\n `Could not resolve namespace for plugin \"${plugin.id}\" with kind \"${kind}\". ` +\n `No namespace produced a type with that kind.`,\n );\n}\n\n// ========================================\n// Process caching\n// ========================================\n\n// Cache: plugin -> cacheKey -> TypePluginOutput\nconst processCache = new WeakMap<Plugin, Map<string, TypePluginOutput>>();\n\n// Cache for namespace plugins: plugin -> cacheKey -> PluginOutput\nconst namespaceProcessCache = new WeakMap<Plugin, Map<string, PluginOutput>>();\n\n/**\n * Generate a cache key that includes pluginConfig.\n * @param baseKey - Base key for the cache\n * @param pluginConfig - Plugin configuration to include in the key\n * @returns Cache key string\n */\nfunction getCacheKey(baseKey: string, pluginConfig: unknown): string {\n if (pluginConfig === undefined) {\n return baseKey;\n }\n try {\n return `${baseKey}:${JSON.stringify(pluginConfig)}`;\n } catch {\n throw new Error(\n `pluginConfig must be JSON-serializable for caching. Received non-serializable value.`,\n );\n }\n}\n\n// ========================================\n// Main API\n// ========================================\n\n/**\n * Get a generated table from a plugin by loading the config and resolving everything automatically.\n * For type-attached plugins, calls onTypeLoaded() with the sourceType.\n * For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.\n * Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.\n * @param configPath - Path to tailor.config.ts (absolute or relative to cwd)\n * @param pluginId - The plugin's unique identifier\n * @param sourceType - The source TailorDB table (null for namespace plugins)\n * @param kind - The generated table kind (e.g., \"request\", \"step\")\n * @returns The generated TailorDB table\n */\nexport async function getGeneratedType(\n configPath: string,\n pluginId: string,\n sourceType: TailorAnyDBType | null,\n kind: string,\n): Promise<TailorAnyDBType> {\n const cache = await loadAndCacheConfig(configPath);\n\n if (!cache) {\n // Config not available (e.g., running in bundled executor on platform server).\n // Return a placeholder. The actual table is resolved at generate/apply time.\n return { name: `__placeholder_${kind}__`, fields: {} } as TailorAnyDBType;\n }\n\n const { config, configDir, plugins } = cache;\n\n const pluginEntry = plugins.get(pluginId);\n if (!pluginEntry) {\n throw new Error(\n `Plugin \"${pluginId}\" not found in config at \"${configPath}\". ` +\n `Ensure the plugin is registered via definePlugins().`,\n );\n }\n\n const { plugin, pluginConfig } = pluginEntry;\n\n if (sourceType === null) {\n return getGeneratedTypeForNamespacePlugin(config, plugin, kind, pluginConfig);\n }\n\n const namespace = await resolveNamespaceForType(config, configDir, sourceType);\n return getGeneratedTypeForTypeAttachedPlugin(plugin, sourceType, kind, pluginConfig, namespace);\n}\n\n/**\n * Get a generated table from a type-attached plugin.\n * @param plugin - The plugin instance (must have onTypeLoaded() method)\n * @param sourceType - The source TailorDB table\n * @param kind - The generated table kind\n * @param pluginConfig - Plugin-level configuration\n * @param namespace - Resolved namespace\n * @returns The generated TailorDB table\n */\nasync function getGeneratedTypeForTypeAttachedPlugin(\n plugin: Plugin,\n sourceType: TailorAnyDBType,\n kind: string,\n pluginConfig: unknown,\n namespace: string,\n): Promise<TailorAnyDBType> {\n if (!plugin.onTypeLoaded) {\n throw new Error(`Plugin \"${plugin.id}\" does not have a onTypeLoaded() method`);\n }\n\n // Check cache first\n let pluginCache = processCache.get(plugin);\n if (!pluginCache) {\n pluginCache = new Map();\n processCache.set(plugin, pluginCache);\n }\n\n const cacheKey = getCacheKey(`${sourceType.name}:ns=${namespace}`, pluginConfig);\n let output = pluginCache.get(cacheKey);\n\n if (!output) {\n const typeConfig = sourceType.plugins.find((p) => p.pluginId === plugin.id)?.config;\n output = await plugin.onTypeLoaded({\n type: sourceType,\n typeConfig: typeConfig ?? {},\n pluginConfig,\n namespace,\n });\n pluginCache.set(cacheKey, output);\n }\n\n const generatedType = output.types?.[kind];\n if (!generatedType) {\n throw new Error(\n `Generated type not found: plugin=${plugin.id}, sourceType=${sourceType.name}, kind=${kind}`,\n );\n }\n\n return generatedType as TailorAnyDBType;\n}\n\n/**\n * Get a generated table from a namespace plugin.\n * Auto-resolves the namespace by trying each one.\n * @param config - App config with db namespace definitions\n * @param config.db - DB namespace definitions\n * @param plugin - The plugin instance (must have onNamespaceLoaded() method)\n * @param kind - The generated table kind\n * @param pluginConfig - Plugin-level configuration\n * @returns The generated TailorDB table\n */\nasync function getGeneratedTypeForNamespacePlugin(\n config: { db?: Record<string, unknown> },\n plugin: Plugin,\n kind: string,\n pluginConfig: unknown,\n): Promise<TailorAnyDBType> {\n if (!plugin.onNamespaceLoaded) {\n throw new Error(`Plugin \"${plugin.id}\" does not have a onNamespaceLoaded() method`);\n }\n\n // Check cache first - try all namespaces\n let pluginCache = namespaceProcessCache.get(plugin);\n if (!pluginCache) {\n pluginCache = new Map();\n namespaceProcessCache.set(plugin, pluginCache);\n }\n\n // Try cached results first\n if (config.db) {\n for (const namespace of Object.keys(config.db)) {\n const dbConfig = config.db[namespace] as DbNamespaceConfig;\n if (dbConfig.external) continue;\n\n const cacheKey = getCacheKey(`namespace:ns=${namespace}`, pluginConfig);\n const cached = pluginCache.get(cacheKey);\n if (cached?.types?.[kind]) {\n return cached.types[kind] as TailorAnyDBType;\n }\n }\n }\n\n // Not in cache - resolve namespace and process\n const { namespace, output } = await resolveNamespaceForNamespacePlugin(\n config,\n plugin,\n kind,\n pluginConfig,\n );\n\n const cacheKey = getCacheKey(`namespace:ns=${namespace}`, pluginConfig);\n pluginCache.set(cacheKey, output);\n\n const generatedType = output.types?.[kind];\n if (!generatedType) {\n throw new Error(`Generated type not found: plugin=${plugin.id}, kind=${kind}`);\n }\n\n return generatedType as TailorAnyDBType;\n}\n\n/**\n * Clear all internal caches. For testing only.\n */\nexport function _clearCacheForTesting(): void {\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MAAM,IAAI,MAAM,WAAW,OAAO,GAAG,6CAA6C;CAIpF,IAAI,cAAc,sBAAsB,IAAI,MAAM;CAClD,IAAI,CAAC,aAAa;EAChB,8BAAc,IAAI,IAAI;EACtB,sBAAsB,IAAI,QAAQ,WAAW;CAC/C;CAGA,IAAI,OAAO,IACT,KAAK,MAAM,aAAa,OAAO,KAAK,OAAO,EAAE,GAAG;EAE9C,IADiB,OAAO,GAAG,UACf,CAAC,UAAU;EAEvB,MAAM,WAAW,YAAY,gBAAgB,aAAa,YAAY;EACtE,MAAM,SAAS,YAAY,IAAI,QAAQ;EACvC,IAAI,QAAQ,QAAQ,OAClB,OAAO,OAAO,MAAM;CAExB;CAIF,MAAM,EAAE,WAAW,WAAW,MAAM,mCAClC,QACA,QACA,MACA,YACF;CAEA,MAAM,WAAW,YAAY,gBAAgB,aAAa,YAAY;CACtE,YAAY,IAAI,UAAU,MAAM;CAEhC,MAAM,gBAAgB,OAAO,QAAQ;CACrC,IAAI,CAAC,eACH,MAAM,IAAI,MAAM,oCAAoC,OAAO,GAAG,SAAS,MAAM;CAG/E,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/plugin/with-context.ts","../../src/plugin/get-generated-table.ts"],"sourcesContent":["/**\n * Plugin executor context support for defining plugin executors in separate files.\n * This module provides utilities for creating type-safe plugin executors that receive\n * context (like table references and namespace) at runtime.\n */\n\nimport type { TailorEnv, TailorPrincipal } from \"#/runtime/types\";\n\n/**\n * Plugin executor factory function type.\n * Takes context and returns an executor configuration.\n * Returns unknown since the exact return type depends on createExecutor's generic params.\n */\nexport type PluginExecutorFactory<Ctx> = (ctx: Ctx) => unknown;\n\n// ============================================================================\n// Plugin Executor Args Types\n// ============================================================================\n\n/**\n * Base args for plugin executor function operations.\n * Provides typed access to runtime context without requiring specific record types.\n */\nexport interface PluginFunctionArgs {\n /** Workspace ID where the executor runs */\n workspaceId: string;\n /** Application namespace */\n appNamespace: string;\n /** Environment variables */\n env: TailorEnv;\n /** Principal that triggered the event, null for system events */\n actor: TailorPrincipal | null;\n /** Name of the TailorDB table */\n typeName: string;\n /** TailorDB connections by namespace */\n tailordb: Record<string, unknown>;\n}\n\n/**\n * Args for plugin executors triggered on record creation.\n */\nexport interface PluginRecordCreatedArgs extends PluginFunctionArgs {\n /** The newly created record */\n newRecord: Record<string, unknown>;\n}\n\n/**\n * Args for plugin executors triggered on record update.\n */\nexport interface PluginRecordUpdatedArgs extends PluginFunctionArgs {\n /** The record after update */\n newRecord: Record<string, unknown>;\n /** The record before update */\n oldRecord: Record<string, unknown>;\n}\n\n/**\n * Args for plugin executors triggered on record deletion.\n */\nexport interface PluginRecordDeletedArgs extends PluginFunctionArgs {\n /** The deleted record */\n oldRecord: Record<string, unknown>;\n}\n\n/**\n * Database schema type for plugins.\n * Since plugins work with dynamic types, the schema uses Record types.\n */\nexport type PluginDBSchema = Record<string, Record<string, unknown>>;\n\n/**\n * Base record type for TailorDB records.\n * All records have an id field.\n */\nexport type PluginRecord = { id: string } & Record<string, unknown>;\n\n/**\n * Define a plugin executor that receives context at runtime.\n * This allows executor definitions to be in separate files while\n * still receiving dynamic values like typeName, generated types, and namespace.\n * @param factory - Function that takes context and returns executor configuration\n * @returns The same factory function (for type inference)\n * @example\n * ```typescript\n * // executors/on-create.ts\n * import { withPluginContext } from \"@tailor-platform/sdk/plugin\";\n * import { createExecutor, recordCreatedTrigger } from \"@tailor-platform/sdk\";\n * import { getDB } from \"@tailor-platform/function-kysely-tailordb\";\n *\n * interface MyContext {\n * sourceTable: TailorAnyDBType;\n * historyType: TailorAnyDBType;\n * namespace: string;\n * }\n *\n * export default withPluginContext<MyContext>((ctx) =>\n * createExecutor({\n * name: `${ctx.sourceTable.name.toLowerCase()}-on-create`,\n * trigger: recordCreatedTrigger({ type: ctx.sourceTable }),\n * operation: {\n * kind: \"function\",\n * body: async (args) => {\n * const db = getDB(ctx.namespace);\n * await db.insertInto(ctx.historyType.name).values({\n * recordId: args.newRecord.id,\n * // ...\n * }).execute();\n * },\n * },\n * })\n * );\n * ```\n */\nexport function withPluginContext<Ctx>(\n factory: PluginExecutorFactory<Ctx>,\n): PluginExecutorFactory<Ctx> {\n return factory;\n}\n","import * as fs from \"node:fs\";\nimport { pathToFileURL } from \"node:url\";\nimport * as path from \"pathe\";\nimport type { TailorAnyDBType } from \"#/configure/services/tailordb/types\";\nimport type { Plugin, PluginOutput, TablePluginOutput } from \"#/plugin/types\";\n\n// ========================================\n// Config loading and caching\n// ========================================\n\ninterface PluginEntry {\n plugin: Plugin;\n pluginConfig: unknown;\n}\n\ninterface ConfigCache {\n config: { db?: Record<string, unknown> };\n plugins: Map<string, PluginEntry>;\n configDir: string;\n}\n\n/** Cache: resolved config path -> loaded config data */\nconst configCacheMap = new Map<string, ConfigCache>();\n\n/**\n * Check if a value is a Plugin instance.\n * @param value - Value to check\n * @returns True if value has the shape of Plugin\n */\nfunction isPlugin(value: unknown): value is Plugin {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<string, unknown>).id === \"string\" &&\n typeof (value as Record<string, unknown>).description === \"string\"\n );\n}\n\n/**\n * Load and cache config module from the given path.\n * Extracts plugins from all array exports using definePlugins() format.\n * Returns null if the config file does not exist (e.g., in bundled executor on platform server).\n * @param configPath - Absolute or relative path to tailor.config.ts\n * @returns Cached config data with plugins map, or null if config file is not available\n */\nasync function loadAndCacheConfig(configPath: string): Promise<ConfigCache | null> {\n const resolvedPath = path.resolve(configPath);\n\n const cached = configCacheMap.get(resolvedPath);\n if (cached) return cached;\n\n // Config file may not exist in bundled environments (e.g., platform server)\n if (!fs.existsSync(resolvedPath)) {\n return null;\n }\n\n const configModule = await import(pathToFileURL(resolvedPath).href);\n if (!configModule?.default) {\n throw new Error(`Invalid config module at \"${resolvedPath}\": default export not found`);\n }\n\n const config = configModule.default as { db?: Record<string, unknown> };\n const configDir = path.dirname(resolvedPath);\n const plugins = new Map<string, PluginEntry>();\n\n // Find plugin arrays from exports (definePlugins returns PluginConfig[])\n for (const value of Object.values(configModule)) {\n if (!Array.isArray(value)) continue;\n\n for (const item of value) {\n if (isPlugin(item)) {\n plugins.set(item.id, { plugin: item, pluginConfig: item.pluginConfig });\n }\n }\n }\n\n const result: ConfigCache = { config, plugins, configDir };\n configCacheMap.set(resolvedPath, result);\n return result;\n}\n\n// ========================================\n// Namespace resolution\n// ========================================\n\ninterface DbNamespaceConfig {\n files?: string[];\n external?: boolean;\n}\n\n/**\n * Resolve the namespace for a table-attached source table by checking config.db file patterns.\n * Uses ESM module cache identity: same file path yields same object references.\n * @param config - App config with db namespace definitions\n * @param config.db - DB namespace definitions\n * @param configDir - Directory containing the config file\n * @param sourceTable - The TailorDB table to look up\n * @returns The namespace name\n */\nasync function resolveNamespaceForTable(\n config: { db?: Record<string, unknown> },\n configDir: string,\n sourceTable: TailorAnyDBType,\n): Promise<string> {\n if (!config.db) {\n throw new Error(`No db configuration found in config`);\n }\n\n for (const [namespace, nsConfig] of Object.entries(config.db)) {\n const dbConfig = nsConfig as DbNamespaceConfig;\n // Skip external namespaces (no files to resolve)\n if (dbConfig.external || !dbConfig.files) continue;\n\n for (const pattern of dbConfig.files) {\n const absolutePattern = path.resolve(configDir, pattern);\n let matchedFiles: string[];\n try {\n matchedFiles = fs.globSync(absolutePattern);\n } catch {\n continue;\n }\n\n for (const file of matchedFiles) {\n const mod = await import(pathToFileURL(file).href);\n for (const exported of Object.values(mod)) {\n if (exported === sourceTable) {\n return namespace;\n }\n }\n }\n }\n }\n\n throw new Error(\n `Could not resolve namespace for table \"${sourceTable.name}\". ` +\n `Ensure the table file is included in a db namespace's files pattern.`,\n );\n}\n\n/**\n * Resolve the namespace for a namespace plugin by trying each namespace.\n * Calls onNamespaceLoaded() for each and returns the first whose output contains the requested kind.\n * @param config - App config with db namespace definitions\n * @param config.db - DB namespace definitions\n * @param plugin - Plugin instance\n * @param kind - The generated table kind to look for\n * @param pluginConfig - Plugin-level configuration\n * @returns The namespace name\n */\nasync function resolveNamespaceForNamespacePlugin(\n config: { db?: Record<string, unknown> },\n plugin: Plugin,\n kind: string,\n pluginConfig: unknown,\n): Promise<{ namespace: string; output: PluginOutput }> {\n if (!config.db) {\n throw new Error(`No db configuration found in config`);\n }\n\n if (!plugin.onNamespaceLoaded) {\n throw new Error(`Plugin \"${plugin.id}\" does not have a onNamespaceLoaded() method`);\n }\n\n for (const namespace of Object.keys(config.db)) {\n const dbConfig = config.db[namespace] as DbNamespaceConfig;\n if (dbConfig.external) continue;\n\n const output = await plugin.onNamespaceLoaded({\n pluginConfig,\n namespace,\n });\n\n if (output.tables?.[kind]) {\n return { namespace, output };\n }\n }\n\n throw new Error(\n `Could not resolve namespace for plugin \"${plugin.id}\" with kind \"${kind}\". ` +\n `No namespace produced a table with that kind.`,\n );\n}\n\n// ========================================\n// Process caching\n// ========================================\n\n// Cache: plugin -> cacheKey -> TablePluginOutput\nconst processCache = new WeakMap<Plugin, Map<string, TablePluginOutput>>();\n\n// Cache for namespace plugins: plugin -> cacheKey -> PluginOutput\nconst namespaceProcessCache = new WeakMap<Plugin, Map<string, PluginOutput>>();\n\n/**\n * Generate a cache key that includes pluginConfig.\n * @param baseKey - Base key for the cache\n * @param pluginConfig - Plugin configuration to include in the key\n * @returns Cache key string\n */\nfunction getCacheKey(baseKey: string, pluginConfig: unknown): string {\n if (pluginConfig === undefined) {\n return baseKey;\n }\n try {\n return `${baseKey}:${JSON.stringify(pluginConfig)}`;\n } catch {\n throw new Error(\n `pluginConfig must be JSON-serializable for caching. Received non-serializable value.`,\n );\n }\n}\n\n// ========================================\n// Main API\n// ========================================\n\n/**\n * Get a generated table from a plugin by loading the config and resolving everything automatically.\n * For table-attached plugins, calls onTableLoaded() with the source table.\n * For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.\n * Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.\n * @param configPath - Path to tailor.config.ts (absolute or relative to cwd)\n * @param pluginId - The plugin's unique identifier\n * @param sourceTable - The source TailorDB table (null for namespace plugins)\n * @param kind - The generated table kind (e.g., \"request\", \"step\")\n * @returns The generated TailorDB table\n */\nexport async function getGeneratedTable(\n configPath: string,\n pluginId: string,\n sourceTable: TailorAnyDBType | null,\n kind: string,\n): Promise<TailorAnyDBType> {\n const cache = await loadAndCacheConfig(configPath);\n\n if (!cache) {\n // Config not available (e.g., running in bundled executor on platform server).\n // Return a placeholder. The actual table is resolved at generate/apply time.\n return { name: `__placeholder_${kind}__`, fields: {} } as TailorAnyDBType;\n }\n\n const { config, configDir, plugins } = cache;\n\n const pluginEntry = plugins.get(pluginId);\n if (!pluginEntry) {\n throw new Error(\n `Plugin \"${pluginId}\" not found in config at \"${configPath}\". ` +\n `Ensure the plugin is registered via definePlugins().`,\n );\n }\n\n const { plugin, pluginConfig } = pluginEntry;\n\n if (sourceTable === null) {\n return getGeneratedTableForNamespacePlugin(config, plugin, kind, pluginConfig);\n }\n\n const namespace = await resolveNamespaceForTable(config, configDir, sourceTable);\n return getGeneratedTableForTableAttachedPlugin(\n plugin,\n sourceTable,\n kind,\n pluginConfig,\n namespace,\n );\n}\n\n/**\n * Get a generated table from a table-attached plugin.\n * @param plugin - The plugin instance (must have onTableLoaded() method)\n * @param sourceTable - The source TailorDB table\n * @param kind - The generated table kind\n * @param pluginConfig - Plugin-level configuration\n * @param namespace - Resolved namespace\n * @returns The generated TailorDB table\n */\nasync function getGeneratedTableForTableAttachedPlugin(\n plugin: Plugin,\n sourceTable: TailorAnyDBType,\n kind: string,\n pluginConfig: unknown,\n namespace: string,\n): Promise<TailorAnyDBType> {\n if (!plugin.onTableLoaded) {\n throw new Error(`Plugin \"${plugin.id}\" does not have an onTableLoaded() method`);\n }\n\n // Check cache first\n let pluginCache = processCache.get(plugin);\n if (!pluginCache) {\n pluginCache = new Map();\n processCache.set(plugin, pluginCache);\n }\n\n const cacheKey = getCacheKey(`${sourceTable.name}:ns=${namespace}`, pluginConfig);\n let output = pluginCache.get(cacheKey);\n\n if (!output) {\n const tableConfig = sourceTable.plugins.find((p) => p.pluginId === plugin.id)?.config;\n output = await plugin.onTableLoaded({\n table: sourceTable,\n tableConfig: tableConfig ?? {},\n pluginConfig,\n namespace,\n });\n pluginCache.set(cacheKey, output);\n }\n\n const generatedTable = output.tables?.[kind];\n if (!generatedTable) {\n throw new Error(\n `Generated table not found: plugin=${plugin.id}, sourceTable=${sourceTable.name}, kind=${kind}`,\n );\n }\n\n return generatedTable as TailorAnyDBType;\n}\n\n/**\n * Get a generated table from a namespace plugin.\n * Auto-resolves the namespace by trying each one.\n * @param config - App config with db namespace definitions\n * @param config.db - DB namespace definitions\n * @param plugin - The plugin instance (must have onNamespaceLoaded() method)\n * @param kind - The generated table kind\n * @param pluginConfig - Plugin-level configuration\n * @returns The generated TailorDB table\n */\nasync function getGeneratedTableForNamespacePlugin(\n config: { db?: Record<string, unknown> },\n plugin: Plugin,\n kind: string,\n pluginConfig: unknown,\n): Promise<TailorAnyDBType> {\n if (!plugin.onNamespaceLoaded) {\n throw new Error(`Plugin \"${plugin.id}\" does not have a onNamespaceLoaded() method`);\n }\n\n // Check cache first - try all namespaces\n let pluginCache = namespaceProcessCache.get(plugin);\n if (!pluginCache) {\n pluginCache = new Map();\n namespaceProcessCache.set(plugin, pluginCache);\n }\n\n // Try cached results first\n if (config.db) {\n for (const namespace of Object.keys(config.db)) {\n const dbConfig = config.db[namespace] as DbNamespaceConfig;\n if (dbConfig.external) continue;\n\n const cacheKey = getCacheKey(`namespace:ns=${namespace}`, pluginConfig);\n const cached = pluginCache.get(cacheKey);\n if (cached?.tables?.[kind]) {\n return cached.tables[kind] as TailorAnyDBType;\n }\n }\n }\n\n // Not in cache - resolve namespace and process\n const { namespace, output } = await resolveNamespaceForNamespacePlugin(\n config,\n plugin,\n kind,\n pluginConfig,\n );\n\n const cacheKey = getCacheKey(`namespace:ns=${namespace}`, pluginConfig);\n pluginCache.set(cacheKey, output);\n\n const generatedTable = output.tables?.[kind];\n if (!generatedTable) {\n throw new Error(`Generated table not found: plugin=${plugin.id}, kind=${kind}`);\n }\n\n return generatedTable as TailorAnyDBType;\n}\n\n/**\n * Clear all internal caches. For testing only.\n */\nexport function _clearCacheForTesting(): void {\n configCacheMap.clear();\n}\n"],"mappings":"2FAiHA,SAAgB,kBACd,EAC4B,CAC5B,OAAO,CACT,CC/FA,MAAM,EAAiB,IAAI,IAO3B,SAAS,SAAS,EAAiC,CACjD,OACE,OAAO,GAAU,YACjB,GACA,OAAQ,EAAkC,IAAO,UACjD,OAAQ,EAAkC,aAAgB,QAE9D,CASA,eAAe,mBAAmB,EAAiD,CACjF,IAAM,EAAe,EAAK,QAAQ,CAAU,EAEtC,EAAS,EAAe,IAAI,CAAY,EAC9C,GAAI,EAAQ,OAAO,EAGnB,GAAI,CAAC,EAAG,WAAW,CAAY,EAC7B,OAAO,KAGT,IAAM,EAAe,MAAM,OAAO,EAAc,CAAY,CAAC,CAAC,MAC9D,GAAI,CAAC,GAAc,QACjB,MAAU,MAAM,6BAA6B,EAAa,4BAA4B,EAGxF,IAAM,EAAS,EAAa,QACtB,EAAY,EAAK,QAAQ,CAAY,EACrC,EAAU,IAAI,IAGpB,IAAK,IAAM,KAAS,OAAO,OAAO,CAAY,EACvC,SAAM,QAAQ,CAAK,EAExB,IAAK,IAAM,KAAQ,EACb,SAAS,CAAI,GACf,EAAQ,IAAI,EAAK,GAAI,CAAE,OAAQ,EAAM,aAAc,EAAK,YAAa,CAAC,EAK5E,IAAM,EAAsB,CAAE,SAAQ,UAAS,WAAU,EAEzD,OADA,EAAe,IAAI,EAAc,CAAM,EAChC,CACT,CAoBA,eAAe,yBACb,EACA,EACA,EACiB,CACjB,GAAI,CAAC,EAAO,GACV,MAAU,MAAM,qCAAqC,EAGvD,IAAK,GAAM,CAAC,EAAW,KAAa,OAAO,QAAQ,EAAO,EAAE,EAAG,CAC7D,IAAM,EAAW,EAEb,OAAS,UAAY,CAAC,EAAS,OAEnC,IAAK,IAAM,KAAW,EAAS,MAAO,CACpC,IAAM,EAAkB,EAAK,QAAQ,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,CAAY,EAChE,EAAS,EAAY,IAAI,CAAQ,EACvC,GAAI,GAAQ,SAAS,GACnB,OAAO,EAAO,OAAO,EAEzB,CAIF,GAAM,CAAE,YAAW,UAAW,MAAM,mCAClC,EACA,EACA,EACA,CACF,EAEM,EAAW,YAAY,gBAAgB,IAAa,CAAY,EACtE,EAAY,IAAI,EAAU,CAAM,EAEhC,IAAM,EAAiB,EAAO,SAAS,GACvC,GAAI,CAAC,EACH,MAAU,MAAM,qCAAqC,EAAO,GAAG,SAAS,GAAM,EAGhF,OAAO,CACT"}
@@ -26,7 +26,7 @@ interface GeneratorResult {
26
26
  interface GeneratorAuthInput {
27
27
  name: string;
28
28
  userProfile?: {
29
- typeName: string;
29
+ tableName: string;
30
30
  namespace: string;
31
31
  usernameField: string;
32
32
  };
@@ -43,10 +43,10 @@ interface TailorDBNamespaceData {
43
43
  /** Namespace name */
44
44
  namespace: string;
45
45
  /** All TailorDB tables in this namespace, keyed by table name */
46
- types: Record<string, TailorDBType>;
47
- /** Source info for each type (file path, export name, plugin info) */
46
+ tables: Record<string, TailorDBType>;
47
+ /** Source info for each table (file path, export name, plugin info) */
48
48
  sourceInfo: ReadonlyMap<string, TypeSourceInfoEntry>;
49
- /** Plugin attachments configured on each type via .plugin() method */
49
+ /** Plugin attachments configured on each table via .plugin() method */
50
50
  pluginAttachments: ReadonlyMap<string, readonly PluginAttachment[]>;
51
51
  }
52
52
  /**
@@ -63,7 +63,7 @@ interface ResolverNamespaceData {
63
63
  * @template PluginConfig - Plugin-level configuration type
64
64
  */
65
65
  interface TailorDBReadyContext<PluginConfig = unknown> {
66
- /** All TailorDB namespaces with their types and metadata */
66
+ /** All TailorDB namespaces with their tables and metadata */
67
67
  tailordb: TailorDBNamespaceData[];
68
68
  /** Auth configuration */
69
69
  auth?: GeneratorAuthInput;
@@ -79,7 +79,7 @@ interface TailorDBReadyContext<PluginConfig = unknown> {
79
79
  * @template PluginConfig - Plugin-level configuration type
80
80
  */
81
81
  interface ResolverReadyContext<PluginConfig = unknown> {
82
- /** All TailorDB namespaces with their types and metadata */
82
+ /** All TailorDB namespaces with their tables and metadata */
83
83
  tailordb: TailorDBNamespaceData[];
84
84
  /** All resolver namespaces with their resolvers */
85
85
  resolvers: ResolverNamespaceData[];
@@ -97,7 +97,7 @@ interface ResolverReadyContext<PluginConfig = unknown> {
97
97
  * @template PluginConfig - Plugin-level configuration type
98
98
  */
99
99
  interface ExecutorReadyContext<PluginConfig = unknown> {
100
- /** All TailorDB namespaces with their types and metadata */
100
+ /** All TailorDB namespaces with their tables and metadata */
101
101
  tailordb: TailorDBNamespaceData[];
102
102
  /** All resolver namespaces with their resolvers */
103
103
  resolvers: ResolverNamespaceData[];
@@ -112,18 +112,25 @@ interface ExecutorReadyContext<PluginConfig = unknown> {
112
112
  /** Plugin-level configuration passed via definePlugins() */
113
113
  pluginConfig: PluginConfig;
114
114
  }
115
- type TypeConfigRequired<PluginConfig = unknown> = boolean | ((pluginConfig: PluginConfig | undefined) => boolean);
115
+ /** @lintignore kept exported for the zinfer-generated reference in src/types/plugin-config.generated.ts */
116
+ type TableConfigRequired<PluginConfig = unknown> = boolean | ((pluginConfig: PluginConfig | undefined) => boolean);
116
117
  /**
117
118
  * Interface for plugin configuration mapping.
118
119
  * Extend this interface via declaration merging to add typed plugin configs.
119
120
  */
120
121
  interface PluginConfigs<Fields extends string = string> {}
122
+ /**
123
+ * Registry mapping a plugin's `id` literal to its plugin-level config type.
124
+ * Extend via declaration merging, keyed by the `id` string, from the
125
+ * owning plugin's own module.
126
+ */
127
+ interface PluginConfigRegistry {}
121
128
  /**
122
129
  * Context passed to plugin's process method
123
130
  */
124
- interface PluginProcessContext<TypeConfig = unknown, PluginConfig = unknown> {
125
- type: TailorAnyDBType;
126
- typeConfig: TypeConfig;
131
+ interface PluginTableProcessContext<TableConfig = unknown, PluginConfig = unknown> {
132
+ table: TailorAnyDBType;
133
+ tableConfig: TableConfig;
127
134
  pluginConfig: PluginConfig;
128
135
  namespace: string;
129
136
  }
@@ -137,12 +144,12 @@ interface PluginNamespaceProcessContext<PluginConfig = unknown> {
137
144
  /**
138
145
  * Interface representing a TailorDB table for plugin output.
139
146
  */
140
- interface TailorDBTypeForPlugin {
147
+ interface TailorDBTableForPlugin {
141
148
  readonly name: string;
142
149
  readonly fields: Record<string, unknown>;
143
150
  }
144
- type PluginGeneratedType = TailorDBTypeForPlugin;
145
- type PluginGeneratedTypes = Record<string, PluginGeneratedType>;
151
+ type PluginGeneratedTable = TailorDBTableForPlugin;
152
+ type PluginGeneratedTables = Record<string, PluginGeneratedTable>;
146
153
  interface PluginGeneratedResolver {
147
154
  name: string;
148
155
  operation: "query" | "mutation";
@@ -153,7 +160,7 @@ interface PluginGeneratedResolver {
153
160
  interface PluginRecordTriggerConfig {
154
161
  kind: "tailordb";
155
162
  events: ("tailordb.type_record.created" | "tailordb.type_record.updated" | "tailordb.type_record.deleted")[];
156
- typeName: string;
163
+ tableName: string;
157
164
  }
158
165
  interface PluginScheduleTriggerConfig {
159
166
  kind: "schedule";
@@ -188,7 +195,7 @@ interface PluginWorkflowOperationConfig {
188
195
  type PluginOperationConfig = PluginFunctionOperationConfig | PluginGraphQLOperationConfig | PluginWebhookOperationConfig | PluginWorkflowOperationConfig;
189
196
  type PluginExecutorContextValue = TailorAnyDBType | string | number | boolean | null | undefined;
190
197
  interface PluginExecutorContextBase {
191
- sourceType: TailorAnyDBType | null;
198
+ sourceTable: TailorAnyDBType | null;
192
199
  namespace: string;
193
200
  }
194
201
  type PluginExecutorContext = PluginExecutorContextBase & {
@@ -213,30 +220,30 @@ interface PluginExtends {
213
220
  fields?: Record<string, TailorAnyDBField>;
214
221
  }
215
222
  interface PluginOutput {
216
- types?: PluginGeneratedTypes;
223
+ tables?: PluginGeneratedTables;
217
224
  resolvers?: PluginGeneratedResolver[];
218
225
  executors?: PluginGeneratedExecutor[];
219
226
  }
220
- interface TypePluginOutput extends PluginOutput {
227
+ interface TablePluginOutput extends PluginOutput {
221
228
  extends?: PluginExtends;
222
229
  }
223
230
  type NamespacePluginOutput = PluginOutput;
224
231
  /**
225
232
  * Plugin interface that all plugins must implement.
226
- * @template TypeConfig - Type for per-type configuration passed via .plugin() method
233
+ * @template TableConfig - Type for per-table configuration passed via .plugin() method
227
234
  * @template PluginConfig - Type for plugin-level configuration passed via definePlugins()
228
235
  */
229
- interface Plugin<TypeConfig = unknown, PluginConfig = unknown> {
236
+ interface Plugin<TableConfig = unknown, PluginConfig = unknown> {
230
237
  readonly id: string;
231
238
  readonly description: string;
232
239
  readonly importPath?: string;
233
- readonly typeConfigRequired?: TypeConfigRequired<PluginConfig>;
240
+ readonly tableConfigRequired?: TableConfigRequired<PluginConfig>;
234
241
  readonly pluginConfig?: PluginConfig;
235
- onTypeLoaded?(context: PluginProcessContext<TypeConfig, PluginConfig>): TypePluginOutput | Promise<TypePluginOutput>;
242
+ onTableLoaded?(context: PluginTableProcessContext<TableConfig, PluginConfig>): TablePluginOutput | Promise<TablePluginOutput>;
236
243
  onNamespaceLoaded?(context: PluginNamespaceProcessContext<PluginConfig>): NamespacePluginOutput | Promise<NamespacePluginOutput>;
237
244
  onTailorDBReady?(context: TailorDBReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
238
245
  onResolverReady?(context: ResolverReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
239
246
  onExecutorReady?(context: ExecutorReadyContext<PluginConfig>): GeneratorResult | Promise<GeneratorResult>;
240
247
  }
241
248
  //#endregion
242
- export { ExecutorReadyContext, GeneratedFile, GeneratorAuthInput, GeneratorResult, NamespacePluginOutput, Plugin, type PluginAttachment, PluginConfigs, PluginExecutorContext, PluginExecutorContextBase, PluginExecutorContextValue, PluginExecutorModule, PluginExtends, PluginFunctionOperationConfig, PluginGeneratedExecutor, PluginGeneratedExecutorLegacy, PluginGeneratedExecutorWithFile, PluginGeneratedResolver, PluginGeneratedType, PluginGeneratedTypes, PluginGraphQLOperationConfig, PluginIncomingWebhookTriggerConfig, PluginInjectMap, PluginInjectValue, PluginNamespaceProcessContext, PluginOperationConfig, PluginOutput, PluginProcessContext, PluginRecordTriggerConfig, PluginScheduleTriggerConfig, PluginTriggerConfig, PluginWebhookOperationConfig, PluginWorkflowOperationConfig, ResolverNamespaceData, ResolverReadyContext, TailorDBNamespaceData, TailorDBReadyContext, TailorDBTypeForPlugin, TypeConfigRequired, TypePluginOutput };
249
+ export { ExecutorReadyContext, GeneratorAuthInput, GeneratorResult, NamespacePluginOutput, Plugin, type PluginAttachment, PluginConfigRegistry, PluginConfigs, PluginExecutorContext, PluginExecutorContextBase, PluginGeneratedExecutor, PluginGeneratedExecutorLegacy, PluginGeneratedExecutorWithFile, PluginGeneratedResolver, PluginGeneratedTable, PluginInjectMap, PluginNamespaceProcessContext, PluginOperationConfig, PluginOutput, PluginTableProcessContext, PluginTriggerConfig, ResolverNamespaceData, ResolverReadyContext, TableConfigRequired, TablePluginOutput, TailorDBNamespaceData, TailorDBReadyContext, TailorDBTableForPlugin };
@@ -73,15 +73,15 @@ type PluginRecord = {
73
73
  * import { getDB } from "@tailor-platform/function-kysely-tailordb";
74
74
  *
75
75
  * interface MyContext {
76
- * sourceType: TailorAnyDBType;
76
+ * sourceTable: TailorAnyDBType;
77
77
  * historyType: TailorAnyDBType;
78
78
  * namespace: string;
79
79
  * }
80
80
  *
81
81
  * export default withPluginContext<MyContext>((ctx) =>
82
82
  * createExecutor({
83
- * name: `${ctx.sourceType.name.toLowerCase()}-on-create`,
84
- * trigger: recordCreatedTrigger({ type: ctx.sourceType }),
83
+ * name: `${ctx.sourceTable.name.toLowerCase()}-on-create`,
84
+ * trigger: recordCreatedTrigger({ type: ctx.sourceTable }),
85
85
  * operation: {
86
86
  * kind: "function",
87
87
  * body: async (args) => {