@tailor-platform/sdk 2.33.0 → 2.34.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 (329) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/ai/index.d.mts +1 -3
  3. package/dist/{application-Bet1K5C4.mjs → application-CwpOIOTt.mjs} +1 -1
  4. package/dist/application-Nce5z46R.mjs +207 -0
  5. package/dist/application-Nce5z46R.mjs.map +1 -0
  6. package/dist/cli/cache/bundle-cache.d.mts +1 -0
  7. package/dist/cli/commands/api/api-call.d.mts +1 -3
  8. package/dist/cli/commands/deploy/aigateway.d.mts +1 -0
  9. package/dist/cli/commands/deploy/app-id-lock.d.mts +1 -3
  10. package/dist/cli/commands/deploy/application.d.mts +1 -0
  11. package/dist/cli/commands/deploy/auth.d.mts +1 -0
  12. package/dist/cli/commands/deploy/config-id-injector.d.mts +1 -3
  13. package/dist/cli/commands/deploy/confirm.d.mts +1 -0
  14. package/dist/cli/commands/deploy/deploy.d.mts +4 -3
  15. package/dist/cli/commands/deploy/executor.d.mts +1 -0
  16. package/dist/cli/commands/deploy/function-registry-types.d.mts +1 -3
  17. package/dist/cli/commands/deploy/function-registry.d.mts +1 -0
  18. package/dist/cli/commands/deploy/idp.d.mts +1 -0
  19. package/dist/cli/commands/deploy/owned-resource.d.mts +3 -0
  20. package/dist/cli/commands/deploy/resolver.d.mts +1 -0
  21. package/dist/cli/commands/deploy/secret-manager.d.mts +1 -0
  22. package/dist/cli/commands/deploy/staticwebsite.d.mts +1 -0
  23. package/dist/cli/commands/deploy/tailordb/plan.d.mts +1 -0
  24. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +2 -1
  25. package/dist/cli/commands/deploy/workflow.d.mts +1 -0
  26. package/dist/cli/commands/executor/get.d.mts +0 -2
  27. package/dist/cli/commands/executor/jobs.d.mts +0 -2
  28. package/dist/cli/commands/executor/list.d.mts +1 -3
  29. package/dist/cli/commands/executor/transform.d.mts +1 -3
  30. package/dist/cli/commands/executor/trigger.d.mts +0 -2
  31. package/dist/cli/commands/executor/webhook.d.mts +1 -3
  32. package/dist/cli/commands/function/get.d.mts +0 -2
  33. package/dist/cli/commands/function/list.d.mts +0 -2
  34. package/dist/cli/commands/function/transform.d.mts +1 -3
  35. package/dist/cli/commands/generate/options.d.mts +1 -3
  36. package/dist/cli/commands/generate/seed/bundler.d.mts +1 -3
  37. package/dist/cli/commands/generate/service.d.mts +1 -3
  38. package/dist/cli/commands/machineuser/list.d.mts +1 -3
  39. package/dist/cli/commands/machineuser/token.d.mts +1 -3
  40. package/dist/cli/commands/oauth2client/get.d.mts +1 -3
  41. package/dist/cli/commands/oauth2client/list.d.mts +1 -3
  42. package/dist/cli/commands/oauth2client/transform.d.mts +1 -3
  43. package/dist/cli/commands/organization/folder/create.d.mts +0 -2
  44. package/dist/cli/commands/organization/folder/delete.d.mts +0 -2
  45. package/dist/cli/commands/organization/folder/get.d.mts +0 -2
  46. package/dist/cli/commands/organization/folder/list.d.mts +0 -2
  47. package/dist/cli/commands/organization/folder/update.d.mts +0 -2
  48. package/dist/cli/commands/organization/get.d.mts +0 -2
  49. package/dist/cli/commands/organization/list.d.mts +1 -3
  50. package/dist/cli/commands/organization/transform.d.mts +1 -3
  51. package/dist/cli/commands/organization/tree.d.mts +0 -2
  52. package/dist/cli/commands/organization/update.d.mts +0 -2
  53. package/dist/cli/commands/remove.d.mts +1 -3
  54. package/dist/cli/commands/show.d.mts +0 -2
  55. package/dist/cli/commands/staticwebsite/deploy.d.mts +1 -3
  56. package/dist/cli/commands/tailordb/migrate/bundler.d.mts +1 -3
  57. package/dist/cli/commands/tailordb/migrate/config.d.mts +1 -3
  58. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +0 -2
  59. package/dist/cli/commands/tailordb/migrate/generate.d.mts +1 -3
  60. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -3
  61. package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +1 -3
  62. package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +1 -3
  63. package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +1 -3
  64. package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +1 -3
  65. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +0 -2
  66. package/dist/cli/commands/tailordb/migrate/types.d.mts +1 -3
  67. package/dist/cli/commands/tailordb/truncate.d.mts +1 -3
  68. package/dist/cli/commands/workflow/executions.d.mts +0 -2
  69. package/dist/cli/commands/workflow/get.d.mts +0 -2
  70. package/dist/cli/commands/workflow/list.d.mts +1 -3
  71. package/dist/cli/commands/workflow/resume.d.mts +1 -3
  72. package/dist/cli/commands/workflow/start.d.mts +0 -2
  73. package/dist/cli/commands/workflow/status.d.mts +1 -3
  74. package/dist/cli/commands/workflow/transform.d.mts +1 -3
  75. package/dist/cli/commands/workflow/wait.d.mts +1 -3
  76. package/dist/cli/commands/workflow/waiter.d.mts +1 -3
  77. package/dist/cli/commands/workspace/app/health.d.mts +0 -2
  78. package/dist/cli/commands/workspace/app/list.d.mts +0 -2
  79. package/dist/cli/commands/workspace/app/transform.d.mts +1 -3
  80. package/dist/cli/commands/workspace/create.d.mts +0 -2
  81. package/dist/cli/commands/workspace/delete.d.mts +0 -2
  82. package/dist/cli/commands/workspace/expiry.d.mts +1 -3
  83. package/dist/cli/commands/workspace/get.d.mts +0 -2
  84. package/dist/cli/commands/workspace/list.d.mts +1 -3
  85. package/dist/cli/commands/workspace/restore.d.mts +0 -2
  86. package/dist/cli/commands/workspace/transform.d.mts +1 -3
  87. package/dist/cli/commands/workspace/user/invite.d.mts +0 -2
  88. package/dist/cli/commands/workspace/user/list.d.mts +0 -2
  89. package/dist/cli/commands/workspace/user/remove.d.mts +0 -2
  90. package/dist/cli/commands/workspace/user/transform.d.mts +1 -3
  91. package/dist/cli/commands/workspace/user/update.d.mts +0 -2
  92. package/dist/cli/lib.d.mts +1 -1
  93. package/dist/cli/lib.mjs +1 -1
  94. package/dist/cli/lib.mjs.map +1 -1
  95. package/dist/cli/main.d.mts +1 -3
  96. package/dist/cli/main.mjs +55 -51
  97. package/dist/cli/main.mjs.map +1 -1
  98. package/dist/cli/query/index.d.mts +0 -2
  99. package/dist/cli/services/application.d.mts +5 -4
  100. package/dist/cli/services/executor/service.d.mts +2 -2
  101. package/dist/cli/services/function-bundle.d.mts +7 -0
  102. package/dist/cli/services/http-adapter/bundler.d.mts +7 -1
  103. package/dist/cli/services/resolver/service.d.mts +2 -2
  104. package/dist/cli/services/workflow/bundler.d.mts +2 -3
  105. package/dist/cli/shared/args.d.mts +0 -2
  106. package/dist/cli/shared/beta.d.mts +1 -3
  107. package/dist/cli/shared/client.d.mts +4 -3
  108. package/dist/cli/shared/command.d.mts +2 -4
  109. package/dist/cli/shared/config-loader.d.mts +2 -4
  110. package/dist/cli/shared/config.d.mts +1 -3
  111. package/dist/cli/shared/context.d.mts +0 -2
  112. package/dist/cli/shared/error-diagnostics.d.mts +1 -3
  113. package/dist/cli/shared/error-json.d.mts +1 -3
  114. package/dist/cli/shared/function-execution.d.mts +1 -3
  115. package/dist/cli/shared/github-actions.d.mts +1 -3
  116. package/dist/cli/shared/logger.d.mts +7 -4
  117. package/dist/cli/shared/platform-bundle-plugin.d.mts +1 -0
  118. package/dist/cli/shared/prompt.d.mts +1 -3
  119. package/dist/cli/shared/readonly-guard.d.mts +0 -2
  120. package/dist/cli/shared/script-executor.d.mts +1 -3
  121. package/dist/cli/shared/seed-chunker.d.mts +1 -3
  122. package/dist/cli/shared/seed-context.d.mts +0 -2
  123. package/dist/cli/shared/sourcemap-sources.d.mts +1 -0
  124. package/dist/cli/shared/tailordb-namespaces.d.mts +1 -3
  125. package/dist/cli/shared/type-generator.d.mts +0 -2
  126. package/dist/cli/shared/workspace-name.d.mts +1 -3
  127. package/dist/completion/zsh-worker.zsh +2 -2
  128. package/dist/configure/config/index.d.mts +2 -4
  129. package/dist/configure/config/types.d.mts +27 -4
  130. package/dist/configure/index.d.mts +7 -9
  131. package/dist/configure/index.mjs +1 -1
  132. package/dist/configure/services/aigateway/index.d.mts +0 -2
  133. package/dist/configure/services/aigateway/types.d.mts +0 -2
  134. package/dist/configure/services/auth/index.d.mts +0 -2
  135. package/dist/configure/services/auth/types.d.mts +0 -2
  136. package/dist/configure/services/executor/executor.d.mts +0 -2
  137. package/dist/configure/services/executor/operation.d.mts +0 -2
  138. package/dist/configure/services/executor/trigger/event.d.mts +0 -2
  139. package/dist/configure/services/executor/trigger/index.d.mts +0 -2
  140. package/dist/configure/services/executor/trigger/schedule.d.mts +0 -2
  141. package/dist/configure/services/executor/trigger/webhook.d.mts +1 -3
  142. package/dist/configure/services/http-adapter/http-adapter.d.mts +0 -2
  143. package/dist/configure/services/idp/index.d.mts +0 -2
  144. package/dist/configure/services/idp/permission.d.mts +0 -2
  145. package/dist/configure/services/idp/types.d.mts +0 -2
  146. package/dist/configure/services/index.d.mts +5 -5
  147. package/dist/configure/services/resolver/index.d.mts +1 -1
  148. package/dist/configure/services/resolver/permission.d.mts +0 -2
  149. package/dist/configure/services/resolver/resolver.d.mts +1 -3
  150. package/dist/configure/services/resolver/types.d.mts +1 -3
  151. package/dist/configure/services/secrets/index.d.mts +0 -2
  152. package/dist/configure/services/secrets/types.d.mts +0 -2
  153. package/dist/configure/services/staticwebsite/index.d.mts +0 -2
  154. package/dist/configure/services/staticwebsite/types.d.mts +0 -2
  155. package/dist/configure/services/tailordb/permission.d.mts +0 -2
  156. package/dist/configure/services/tailordb/schema.d.mts +0 -2
  157. package/dist/configure/services/tailordb/types.d.mts +0 -2
  158. package/dist/configure/services/workflow/execution-policy.d.mts +0 -2
  159. package/dist/configure/services/workflow/execution-policy.types.d.mts +0 -2
  160. package/dist/configure/services/workflow/job.d.mts +0 -2
  161. package/dist/configure/services/workflow/wait-point.d.mts +0 -2
  162. package/dist/configure/services/workflow/workflow.d.mts +0 -2
  163. package/dist/configure/types/aigateway-name.d.mts +1 -3
  164. package/dist/configure/types/auth-namespace-name.d.mts +1 -3
  165. package/dist/configure/types/connection-name.d.mts +1 -3
  166. package/dist/configure/types/field.d.mts +1 -3
  167. package/dist/configure/types/field.types.d.mts +0 -2
  168. package/dist/configure/types/idp-name.d.mts +1 -3
  169. package/dist/configure/types/permission-operand.types.d.mts +0 -2
  170. package/dist/configure/types/secret-vault-name.d.mts +1 -3
  171. package/dist/configure/types/type.d.mts +0 -2
  172. package/dist/{crashreport-BCIy33Cz.mjs → crashreport-DGU6lwiX.mjs} +2 -2
  173. package/dist/{crashreport-BCIy33Cz.mjs.map → crashreport-DGU6lwiX.mjs.map} +1 -1
  174. package/dist/crashreport-WsYAWARW.mjs +1 -0
  175. package/dist/{logger-RgtbhJ83.mjs → errors-BXmGBX-7.mjs} +6 -3
  176. package/dist/errors-BXmGBX-7.mjs.map +1 -0
  177. package/dist/field-parse-BQhUAbpM.mjs +2 -0
  178. package/dist/{field-parse-C41e3UAF.mjs.map → field-parse-BQhUAbpM.mjs.map} +1 -1
  179. package/dist/guards-CiFVxoXR.mjs +2 -0
  180. package/dist/guards-CiFVxoXR.mjs.map +1 -0
  181. package/dist/kysely/index.d.mts +0 -2
  182. package/dist/manager-B813m43t.mjs +2 -0
  183. package/dist/manager-B813m43t.mjs.map +1 -0
  184. package/dist/parser/service/idp/types.d.mts +1 -3
  185. package/dist/parser/service/tailordb/type-source.d.mts +1 -3
  186. package/dist/parser/service/tailordb/types.d.mts +0 -2
  187. package/dist/plugin/builtin/enum-constants/index.d.mts +0 -2
  188. package/dist/plugin/builtin/file-utils/index.d.mts +0 -2
  189. package/dist/plugin/builtin/kysely-type/index.d.mts +0 -2
  190. package/dist/plugin/builtin/seed/index.d.mts +0 -2
  191. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +1 -3
  192. package/dist/plugin/get-generated-table.d.mts +1 -3
  193. package/dist/plugin/index.mjs +1 -1
  194. package/dist/plugin/types.d.mts +0 -2
  195. package/dist/plugin/with-context.d.mts +1 -3
  196. package/dist/register-ts-hook-CtWJL3EO.mjs +1054 -0
  197. package/dist/register-ts-hook-CtWJL3EO.mjs.map +1 -0
  198. package/dist/runtime/aigateway.d.mts +1 -3
  199. package/dist/runtime/authconnection.d.mts +1 -3
  200. package/dist/runtime/context.d.mts +0 -2
  201. package/dist/runtime/date.d.mts +0 -2
  202. package/dist/runtime/field-parse.d.mts +0 -2
  203. package/dist/runtime/file.d.mts +0 -2
  204. package/dist/runtime/globals.d.mts +0 -2
  205. package/dist/runtime/iconv.d.mts +1 -3
  206. package/dist/runtime/idp.d.mts +1 -3
  207. package/dist/runtime/index.d.mts +1 -3
  208. package/dist/runtime/index.mjs +1 -1
  209. package/dist/runtime/logger.d.mts +1 -3
  210. package/dist/runtime/secretmanager.d.mts +1 -3
  211. package/dist/runtime/temporal.d.mts +0 -2
  212. package/dist/runtime/types.d.mts +0 -2
  213. package/dist/runtime/workflow.d.mts +0 -2
  214. package/dist/{schema-B6hJQWp6.mjs → schema-BU1aIQ63.mjs} +2 -2
  215. package/dist/{schema-B6hJQWp6.mjs.map → schema-BU1aIQ63.mjs.map} +1 -1
  216. package/dist/secret-file-BxZ-J_Nz.mjs +2 -0
  217. package/dist/secret-file-BxZ-J_Nz.mjs.map +1 -0
  218. package/dist/seed/idp-user-password.d.mts +0 -2
  219. package/dist/seed/index.d.mts +0 -2
  220. package/dist/service-CaGmqg0r.mjs +2 -0
  221. package/dist/{service-9rwi_I4d.mjs.map → service-CaGmqg0r.mjs.map} +1 -1
  222. package/dist/service-DEq_hdht.mjs +1 -0
  223. package/dist/{service-9SBPNpK8.mjs → service-eeXdVrDK.mjs} +4 -4
  224. package/dist/service-eeXdVrDK.mjs.map +1 -0
  225. package/dist/shared/src/color.d.mts +1 -3
  226. package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +1 -3
  227. package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +1 -3
  228. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +1 -3
  229. package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +1 -3
  230. package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +1 -3
  231. package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +1 -3
  232. package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +1 -3
  233. package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +1 -3
  234. package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +1 -3
  235. package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +1 -3
  236. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +1 -3
  237. package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +1 -3
  238. package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +1 -3
  239. package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +1 -3
  240. package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +1 -3
  241. package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +1 -3
  242. package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +1 -3
  243. package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +1 -3
  244. package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +1 -3
  245. package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +1 -3
  246. package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +1 -3
  247. package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +1 -3
  248. package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +1 -3
  249. package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +1 -3
  250. package/dist/tailor-proto/src/tailor/v1/security_pb.d.mts +1 -3
  251. package/dist/tailor-proto/src/tailor/v1/security_resource_pb.d.mts +1 -3
  252. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -3
  253. package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +1 -3
  254. package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +1 -3
  255. package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +1 -3
  256. package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +1 -3
  257. package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +1 -3
  258. package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +1 -3
  259. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +1 -3
  260. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +1 -3
  261. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +1 -3
  262. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +1 -3
  263. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +1 -3
  264. package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +1 -3
  265. package/dist/types/aigateway.generated.d.mts +1 -3
  266. package/dist/types/app-config.generated.d.mts +1 -3
  267. package/dist/types/auth-connection.generated.d.mts +1 -3
  268. package/dist/types/auth.generated.d.mts +1 -3
  269. package/dist/types/executor.generated.d.mts +1 -3
  270. package/dist/types/field.generated.d.mts +1 -3
  271. package/dist/types/helpers.d.mts +1 -3
  272. package/dist/types/http-adapter.generated.d.mts +1 -3
  273. package/dist/types/idp.generated.d.mts +1 -3
  274. package/dist/types/resolver.generated.d.mts +1 -3
  275. package/dist/types/secrets.generated.d.mts +1 -3
  276. package/dist/types/staticwebsite.generated.d.mts +1 -3
  277. package/dist/types/tailordb.generated.d.mts +1 -3
  278. package/dist/types/workflow.generated.d.mts +1 -3
  279. package/dist/utils/test/index.d.mts +1 -3
  280. package/dist/utils/test/index.mjs +1 -1
  281. package/dist/vitest/date-representation.d.mts +1 -3
  282. package/dist/vitest/environment.d.mts +0 -2
  283. package/dist/vitest/index.d.mts +0 -2
  284. package/dist/vitest/migration-steps.d.mts +1 -3
  285. package/dist/vitest/mock-kysely.d.mts +0 -2
  286. package/dist/vitest/mocks/aigateway.d.mts +0 -2
  287. package/dist/vitest/mocks/authconnection.d.mts +0 -2
  288. package/dist/vitest/mocks/file.d.mts +0 -2
  289. package/dist/vitest/mocks/iconv.d.mts +0 -2
  290. package/dist/vitest/mocks/idp.d.mts +0 -2
  291. package/dist/vitest/mocks/logger.d.mts +0 -2
  292. package/dist/vitest/mocks/secretmanager.d.mts +0 -2
  293. package/dist/vitest/mocks/tailordb-pglite.d.mts +0 -2
  294. package/dist/vitest/mocks/tailordb.d.mts +0 -2
  295. package/dist/vitest/mocks/workflow.d.mts +0 -2
  296. package/dist/vitest/pglite-kysely.d.mts +0 -2
  297. package/dist/vitest/pglite-temporal.d.mts +1 -3
  298. package/dist/vitest/setup.d.mts +0 -2
  299. package/dist/vitest/workflow-local.d.mts +0 -2
  300. package/docs/cli/application.md +2 -1
  301. package/docs/cli/tailordb.md +1 -1
  302. package/docs/cli/user.md +5 -5
  303. package/docs/cli/workspace.md +1 -1
  304. package/docs/cli-reference.md +26 -25
  305. package/docs/configuration.md +13 -2
  306. package/docs/github-actions.md +33 -10
  307. package/docs/services/secret.md +6 -0
  308. package/docs/services/tailordb/index.md +19 -0
  309. package/docs/services/tailordb/migration.md +2 -2
  310. package/docs/testing.md +2 -2
  311. package/package.json +12 -12
  312. package/dist/application-B9_NHiUC.mjs +0 -207
  313. package/dist/application-B9_NHiUC.mjs.map +0 -1
  314. package/dist/crashreport-IN6H7GX3.mjs +0 -1
  315. package/dist/errors-BOF68LJ5.mjs +0 -5
  316. package/dist/errors-BOF68LJ5.mjs.map +0 -1
  317. package/dist/field-parse-C41e3UAF.mjs +0 -2
  318. package/dist/guards-yDXyKC9F.mjs +0 -2
  319. package/dist/guards-yDXyKC9F.mjs.map +0 -1
  320. package/dist/logger-RgtbhJ83.mjs.map +0 -1
  321. package/dist/manager-DTRhIupk.mjs +0 -2
  322. package/dist/manager-DTRhIupk.mjs.map +0 -1
  323. package/dist/register-ts-hook-Dp9reSRG.mjs +0 -1053
  324. package/dist/register-ts-hook-Dp9reSRG.mjs.map +0 -1
  325. package/dist/secret-file-C9wp_FCX.mjs +0 -2
  326. package/dist/secret-file-C9wp_FCX.mjs.map +0 -1
  327. package/dist/service-9SBPNpK8.mjs.map +0 -1
  328. package/dist/service-9rwi_I4d.mjs +0 -2
  329. package/dist/service-Ca1WwyIt.mjs +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager-B813m43t.mjs","names":["db","getRawPluginTableName","plugin","plugins","context","tableConfigRequired","output","error","message","resolver","importPath","assertDefined","kind","table","executor","results","pluginId","config","namespace","resolverNamespaceKey","executorKey","tableKey","params","currentTable","rawTable","extendedTable","generatedTables","events","attachment","attachments","result","extendFields","tableName","info","hasGenerationHooks","tableGenerationResult","tableGenerator","outputDir","executorGenerator","sourceTableInfoMap","configPath","existingFieldNames","originalTable","existingFileNames","newFieldNames","duplicateFields","name","duplicateFiles","_id","fieldsWithoutId","pluralForm","extended","original","metadata","_pluralForm","features","indexDefs","def"],"sources":["../src/plugin/manager.ts"],"sourcesContent":["import { db, type TailorAnyDBType } from \"#/configure/services/tailordb/index\";\nimport { getRawPluginTableName, hasGenerationHooks } from \"#/plugin/guards\";\nimport { assertDefined } from \"#/utils/assert\";\nimport type {\n TailorTypePermission,\n TailorTypeGqlPermission,\n} from \"#/configure/services/tailordb/permission\";\nimport type {\n TailorAnyDBField,\n TypeHook,\n TypeValidateFn,\n} from \"#/configure/services/tailordb/types\";\nimport type {\n Plugin,\n PluginAttachment,\n PluginGeneratedExecutor,\n PluginGeneratedResolver,\n PluginGeneratedTable,\n PluginNamespaceProcessContext,\n PluginOutput,\n TablePluginOutput,\n} from \"#/plugin/types\";\nimport type { TailorDBTypeRaw } from \"#/types/tailordb.generated\";\n\n/**\n * Context for processing a single plugin attachment on a raw TailorDBType\n */\nexport interface ProcessAttachmentContext {\n table: TailorAnyDBType;\n tableConfig: unknown;\n namespace: string;\n pluginId: string;\n}\n\n/**\n * Information about a plugin-generated table (for table file generation)\n */\nexport interface PluginGeneratedTableInfo {\n /** Plugin ID that generated this table */\n pluginId: string;\n /** Plugin import path for resolving executor files */\n pluginImportPath: string;\n /** Source table name that triggered the plugin */\n sourceTableName: string;\n /** Kind identifier for this generated table */\n kind: string;\n /** The generated TailorDB table object */\n table: PluginGeneratedTable;\n /** Namespace where this table was generated */\n namespace: string;\n /** Plugin config used to generate this table */\n pluginConfig?: unknown;\n}\n\n/**\n * Extended executor info with plugin import path\n */\nexport interface PluginExecutorInfoExtended extends PluginExecutorInfo {\n /** Plugin's import path for resolving executor files */\n pluginImportPath: string;\n}\n\n/**\n * Result of processing a table-attached plugin\n */\nexport type ProcessAttachmentResult =\n | { success: true; output: TablePluginOutput }\n | { success: false; error: string };\n\n/**\n * Result of processing a namespace plugin\n */\nexport type ProcessNamespaceResult =\n | { success: true; output: PluginOutput }\n | { success: false; error: string };\n\n/**\n * Parameters for processing all plugin attachments of a TailorDB table.\n */\nexport interface ProcessAttachmentsForTableParams {\n rawTable: TailorDBTypeRaw;\n attachments: PluginAttachment[];\n namespace: string;\n}\n\n/**\n * Progress event emitted while processing plugin attachments for a TailorDB table.\n * Plain data so the caller (typically the cli) can format and output it.\n */\ntype ProcessAttachmentEvent =\n | { kind: \"extended\"; tableName: string; fieldCount: number; pluginId: string }\n | { kind: \"generated\"; tableName: string; pluginId: string };\n\n/**\n * Generated table produced by a plugin during attachment processing.\n * `table` is raw plugin output; the caller must validate it before use.\n */\ninterface ProcessAttachmentsGeneratedTable {\n tableName: string;\n table: unknown;\n kind: string;\n pluginId: string;\n pluginImportPath: string;\n pluginConfig?: unknown;\n}\n\n/**\n * Result of {@link PluginManager.processAttachmentsForTable}.\n */\nexport interface ProcessAttachmentsForTableResult {\n /**\n * Final table after all extends are applied; undefined if no plugin extended the table.\n * Raw builder output; the caller must validate it before use.\n */\n extendedTable?: unknown;\n /** Tables newly generated by plugins for this attachment chain. */\n generatedTables: ProcessAttachmentsGeneratedTable[];\n /** Events for the caller to render. */\n events: ProcessAttachmentEvent[];\n}\n\n/**\n * Information about a plugin-generated executor\n */\nexport interface PluginExecutorInfo {\n /** The executor definition */\n executor: PluginGeneratedExecutor;\n /** Plugin ID that generated this executor */\n pluginId: string;\n /** Namespace where the executor was generated */\n namespace: string;\n /** Source table name (for table-attached executors, undefined for namespace) */\n sourceTableName?: string;\n}\n\nexport interface PluginResolverInfo {\n resolver: PluginGeneratedResolver;\n pluginId: string;\n namespace: string;\n sourceTableName?: string;\n}\n\n/**\n * Manages plugin registration and processing\n */\nexport class PluginManager {\n private plugins: Map<string, Plugin> = new Map();\n private generatedExecutors: PluginExecutorInfo[] = [];\n private generatedTables: PluginGeneratedTableInfo[] = [];\n private generatedResolvers: PluginResolverInfo[] = [];\n private processedResolverNamespaces = new Set<string>();\n private namespaceGeneratedTableKeys: Set<string> = new Set();\n private namespaceGeneratedExecutorKeys: Set<string> = new Set();\n\n constructor(plugins: Plugin[] = []) {\n for (const plugin of plugins) {\n if (this.plugins.has(plugin.id)) {\n throw new Error(\n `Duplicate plugin ID \"${plugin.id}\" detected. Each plugin must have a unique ID.`,\n );\n }\n this.plugins.set(plugin.id, plugin);\n }\n }\n\n /**\n * Process a single plugin attachment on a raw TailorDBType.\n * This method is called during table loading before parsing.\n * @param context - Context containing the raw table, config, namespace, and plugin ID\n * @returns Result with plugin output on success, or error message on failure\n */\n async processAttachment(context: ProcessAttachmentContext): Promise<ProcessAttachmentResult> {\n const plugin = this.plugins.get(context.pluginId);\n if (!plugin) {\n return {\n success: false,\n error: `Plugin \"${context.pluginId}\" not found`,\n };\n }\n\n const tableConfigRequired = plugin.tableConfigRequired;\n const resolvedRequired =\n typeof tableConfigRequired === \"function\"\n ? tableConfigRequired(plugin.pluginConfig)\n : tableConfigRequired === true;\n if (resolvedRequired && (context.tableConfig === undefined || context.tableConfig === null)) {\n return {\n success: false,\n error: `Plugin \"${plugin.id}\" requires tableConfig, but none was provided for table \"${context.table.name}\".`,\n };\n }\n\n // Check if plugin supports table-attached processing\n if (!plugin.onTableLoaded) {\n return {\n success: false,\n error: `Plugin \"${plugin.id}\" does not support table-attached processing (missing onTableLoaded method). Use onNamespaceLoaded via definePlugins() instead.`,\n };\n }\n\n // Execute plugin onTableLoaded with the raw TailorDB table\n let output: TablePluginOutput;\n try {\n output = await plugin.onTableLoaded({\n table: context.table,\n tableConfig: context.tableConfig,\n pluginConfig: plugin.pluginConfig,\n namespace: context.namespace,\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n success: false,\n error: `Plugin \"${plugin.id}\" threw an error while processing table \"${context.table.name}\": ${message}`,\n };\n }\n\n for (const resolver of output.resolvers ?? []) {\n this.generatedResolvers.push({\n resolver,\n pluginId: plugin.id,\n namespace: context.namespace,\n sourceTableName: context.table.name,\n });\n }\n\n // Collect generated tables\n if (output.tables && Object.keys(output.tables).length > 0) {\n // importPath is guaranteed by schema validation for plugins with definition-time hooks\n const importPath = assertDefined(\n plugin.importPath,\n `plugin \"${plugin.id}\" missing importPath`,\n );\n for (const [kind, table] of Object.entries(output.tables)) {\n this.generatedTables.push({\n pluginId: context.pluginId,\n pluginImportPath: importPath,\n sourceTableName: context.table.name,\n kind,\n table,\n namespace: context.namespace,\n pluginConfig: plugin.pluginConfig,\n });\n }\n }\n\n // Collect generated executors\n if (output.executors && output.executors.length > 0) {\n for (const executor of output.executors) {\n this.generatedExecutors.push({\n executor,\n pluginId: context.pluginId,\n namespace: context.namespace,\n sourceTableName: context.table.name,\n });\n }\n }\n\n return { success: true, output };\n }\n\n /**\n * Process namespace plugins that don't require a source table.\n * This method is called once per namespace for plugins with onNamespaceLoaded method.\n * @param namespace - The target namespace for generated tables\n * @returns Array of results with plugin outputs and configs\n */\n async processNamespacePlugins(\n namespace: string,\n ): Promise<Array<{ pluginId: string; config: unknown; result: ProcessNamespaceResult }>> {\n const results: Array<{ pluginId: string; config: unknown; result: ProcessNamespaceResult }> =\n [];\n\n for (const [pluginId, plugin] of this.plugins) {\n // Skip plugins without onNamespaceLoaded method\n if (!plugin.onNamespaceLoaded) {\n continue;\n }\n\n // Use stored plugin config (from definePlugins)\n const config = plugin.pluginConfig;\n\n // Execute plugin onNamespaceLoaded\n const context: PluginNamespaceProcessContext = {\n pluginConfig: config,\n namespace,\n };\n\n let output: Awaited<ReturnType<NonNullable<Plugin[\"onNamespaceLoaded\"]>>>;\n try {\n output = await plugin.onNamespaceLoaded(context);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n results.push({\n pluginId,\n config,\n result: {\n success: false,\n error: `Plugin \"${plugin.id}\" threw an error during namespace processing for \"${namespace}\": ${message}`,\n },\n });\n continue;\n }\n\n const resolverNamespaceKey = JSON.stringify([pluginId, namespace]);\n if (!this.processedResolverNamespaces.has(resolverNamespaceKey)) {\n for (const resolver of output.resolvers ?? []) {\n this.generatedResolvers.push({ resolver, pluginId, namespace });\n }\n this.processedResolverNamespaces.add(resolverNamespaceKey);\n }\n\n // Collect generated executors (namespace - no source table)\n if (output.executors && output.executors.length > 0) {\n for (const executor of output.executors) {\n const executorKey = `${pluginId}:${executor.name}`;\n if (this.namespaceGeneratedExecutorKeys.has(executorKey)) {\n continue;\n }\n this.namespaceGeneratedExecutorKeys.add(executorKey);\n this.generatedExecutors.push({\n executor,\n pluginId,\n namespace,\n });\n }\n }\n\n // Collect generated tables (namespace - no source table)\n if (output.tables && Object.keys(output.tables).length > 0) {\n // importPath is guaranteed by schema validation for plugins with definition-time hooks\n const importPath = assertDefined(\n plugin.importPath,\n `plugin \"${plugin.id}\" missing importPath`,\n );\n for (const [kind, table] of Object.entries(output.tables)) {\n const tableKey = `${pluginId}:${kind}:${getRawPluginTableName(table) ?? \"\"}`;\n if (this.namespaceGeneratedTableKeys.has(tableKey)) {\n continue;\n }\n this.namespaceGeneratedTableKeys.add(tableKey);\n this.generatedTables.push({\n pluginId,\n pluginImportPath: importPath,\n sourceTableName: \"(namespace)\",\n kind,\n table,\n namespace,\n pluginConfig: plugin.pluginConfig,\n });\n }\n }\n\n results.push({\n pluginId,\n config,\n result: { success: true, output },\n });\n }\n\n return results;\n }\n\n /**\n * Run every plugin attachment for a single TailorDB table in order, threading the\n * extended table through the chain. Returns plain data (no logging, no shared state)\n * so the caller decides how to apply updates and render progress.\n * @param params - The raw table, its attachments, and the target namespace\n * @returns Final extended table (if any), generated tables, and render events\n */\n async processAttachmentsForTable(\n params: ProcessAttachmentsForTableParams,\n ): Promise<ProcessAttachmentsForTableResult> {\n const { rawTable, attachments, namespace } = params;\n // The runtime value is a configure-layer builder instance; we accept the structural\n // TailorDBTypeRaw at the boundary so callers (cli) don't need to depend on TailorAnyDBType.\n let currentTable: TailorAnyDBType = rawTable as unknown as TailorAnyDBType;\n let extendedTable: TailorAnyDBType | undefined;\n const generatedTables: ProcessAttachmentsGeneratedTable[] = [];\n const events: ProcessAttachmentEvent[] = [];\n\n for (const attachment of attachments) {\n const result = await this.processAttachment({\n table: currentTable,\n tableConfig: attachment.config,\n namespace,\n pluginId: attachment.pluginId,\n });\n if (!result.success) {\n throw new Error(result.error);\n }\n\n const output = result.output;\n const extendFields = output.extends?.fields;\n if (extendFields && Object.keys(extendFields).length > 0) {\n currentTable = this.extendTable({\n originalTable: currentTable,\n extendFields,\n pluginId: attachment.pluginId,\n });\n extendedTable = currentTable;\n events.push({\n kind: \"extended\",\n tableName: currentTable.name,\n fieldCount: Object.keys(extendFields).length,\n pluginId: attachment.pluginId,\n });\n }\n\n const plugin = this.getPlugin(attachment.pluginId);\n for (const [kind, table] of Object.entries(output.tables ?? {})) {\n const tableName = getRawPluginTableName(table) ?? \"\";\n generatedTables.push({\n tableName,\n table,\n kind,\n pluginId: attachment.pluginId,\n pluginImportPath: this.getPluginImportPath(attachment.pluginId) ?? \"\",\n pluginConfig: plugin?.pluginConfig,\n });\n events.push({ kind: \"generated\", tableName, pluginId: attachment.pluginId });\n }\n }\n\n return { extendedTable, generatedTables, events };\n }\n\n /**\n * Get a plugin by its ID\n * @param pluginId - The plugin ID to look up\n * @returns The plugin instance, or undefined if not found\n */\n getPlugin(pluginId: string): Plugin | undefined {\n return this.plugins.get(pluginId);\n }\n\n /**\n * Get the import path for a plugin\n * @param pluginId - The plugin ID to look up\n * @returns The plugin's import path, or undefined if not found\n */\n getPluginImportPath(pluginId: string): string | undefined {\n return this.plugins.get(pluginId)?.importPath;\n }\n\n /**\n * Get all plugin-generated resolvers.\n * @returns Resolver definitions with their source plugin and namespace\n */\n getPluginGeneratedResolvers(): ReadonlyArray<PluginResolverInfo> {\n return this.generatedResolvers;\n }\n\n /**\n * Get all plugin-generated executors with import paths\n * @returns Array of plugin-generated executor info with import paths\n */\n getPluginGeneratedExecutorsWithImportPath(): ReadonlyArray<PluginExecutorInfoExtended> {\n return this.generatedExecutors.map((info) => ({\n ...info,\n pluginImportPath: this.getPluginImportPath(info.pluginId) ?? \"\",\n }));\n }\n\n /**\n * Get all plugin-generated tables\n * @returns Array of plugin-generated table info\n */\n getPluginGeneratedTables(): ReadonlyArray<PluginGeneratedTableInfo> {\n return this.generatedTables;\n }\n\n /**\n * Get plugins that have any generation-time hooks.\n * @returns Array of plugins with generation hooks\n */\n getPluginsWithGenerationHooks(): Plugin[] {\n return Array.from(this.plugins.values()).filter((plugin) => hasGenerationHooks(plugin));\n }\n\n /**\n * Generate plugin files (tables and executors).\n * @param params - Parameters for file generation\n * @returns Generated executor file paths\n */\n generatePluginFiles(params: GeneratePluginFilesParams): string[] {\n const { outputDir, sourceTableInfoMap, configPath, tableGenerator, executorGenerator } = params;\n\n // Generate table files\n const tableGenerationResult = tableGenerator(this.generatedTables, outputDir);\n\n // Generate executor files\n const pluginExecutors = this.getPluginGeneratedExecutorsWithImportPath();\n return executorGenerator(\n pluginExecutors,\n outputDir,\n tableGenerationResult,\n sourceTableInfoMap,\n configPath,\n );\n }\n\n /**\n * Extend a TailorDB table with new fields.\n * This method handles the `db.table()` call and metadata copying internally.\n * @param params - Parameters for table extension\n * @returns The extended TailorDB table\n */\n extendTable(params: ExtendTableParams): TailorAnyDBType {\n const { originalTable, extendFields, pluginId } = params;\n const existingFieldNames = Object.keys(originalTable.fields);\n const existingFileNames = Object.keys(originalTable.metadata.files);\n const newFieldNames = Object.keys(extendFields);\n const duplicateFields = newFieldNames.filter((name) => existingFieldNames.includes(name));\n const duplicateFiles = newFieldNames.filter((name) => existingFileNames.includes(name));\n\n if (duplicateFields.length > 0) {\n throw new Error(\n `Plugin \"${pluginId}\" attempted to add fields that already exist in table \"${originalTable.name}\": ${duplicateFields.join(\", \")}. ` +\n `extendFields cannot overwrite existing fields.`,\n );\n }\n\n if (duplicateFiles.length > 0) {\n throw new Error(\n `Plugin \"${pluginId}\" attempted to add fields that collide with file keys already declared via .files() on table \"${originalTable.name}\": ${duplicateFiles.join(\", \")}.`,\n );\n }\n\n const mergedFields = {\n ...originalTable.fields,\n ...extendFields,\n };\n\n const { id: _id, ...fieldsWithoutId } = mergedFields;\n const pluralForm = originalTable.metadata.settings?.pluralForm;\n const tableName = pluralForm\n ? ([originalTable.name, pluralForm] as [string, string])\n : originalTable.name;\n const extendedTable = db.table(tableName, fieldsWithoutId);\n return copyMetadataToExtendedTable(originalTable, extendedTable);\n }\n}\n\n/**\n * Source info for user-defined tables\n */\nexport type SourceTableInfo = {\n filePath: string;\n exportName: string;\n};\n\n/**\n * Result of generating plugin table files\n */\nexport interface PluginTableGenerationResult {\n /** Map of table name to generated file path (relative to outputDir) */\n tableFilePaths: Map<string, string>;\n /** List of all generated file paths (absolute) */\n generatedFiles: string[];\n}\n\n/**\n * Parameters for generating plugin files\n */\nexport interface GeneratePluginFilesParams {\n /** Base output directory (e.g., .tailor/plugin) */\n outputDir: string;\n /** Map of source table names to their source info */\n sourceTableInfoMap: Map<string, SourceTableInfo>;\n /** Path to tailor.config.ts (used for resolving plugin import paths) */\n configPath: string;\n /** Function to generate table files */\n tableGenerator: (\n tables: ReadonlyArray<PluginGeneratedTableInfo>,\n outputDir: string,\n ) => PluginTableGenerationResult;\n /** Function to generate executor files */\n executorGenerator: (\n executors: ReadonlyArray<PluginExecutorInfoExtended>,\n outputDir: string,\n tableGenerationResult: PluginTableGenerationResult,\n sourceTableInfoMap: Map<string, SourceTableInfo>,\n configPath: string,\n ) => string[];\n}\n\n/**\n * Parameters for extending a TailorDB table\n */\nexport interface ExtendTableParams {\n /** The original TailorDB table to extend */\n originalTable: TailorAnyDBType;\n /** New fields to add to the table */\n extendFields: Record<string, unknown>;\n /** The ID of the plugin extending the table */\n pluginId: string;\n}\n\n/**\n * Copy metadata from original table to extended table.\n * Preserves files, settings, permissions, indexes, and plugins.\n * @param original - The original TailorDB table with metadata\n * @param extended - The newly created extended table\n * @returns The extended table with copied metadata\n */\nfunction copyMetadataToExtendedTable(\n original: TailorAnyDBType,\n extended: TailorAnyDBType,\n): TailorAnyDBType {\n let result = extended;\n\n // Copy description\n if (original._description) {\n result = result.description(original._description);\n }\n\n // Copy files metadata\n const metadata = original.metadata;\n if (Object.keys(metadata.files).length > 0) {\n result = result.files(metadata.files);\n }\n\n // Copy settings/features (excluding pluralForm which is set during construction)\n if (metadata.settings) {\n const { pluralForm: _pluralForm, ...features } = metadata.settings;\n if (Object.keys(features).length > 0) {\n result = result.features(\n features as typeof features & { aggregation?: true; bulkUpsert?: true },\n );\n }\n }\n\n // Copy permissions from metadata\n // Zod schema operand types are wider unions than the configure layer's discriminated PermissionCondition,\n // so type assertions are needed here.\n if (metadata.permissions.record) {\n result = result.permission(metadata.permissions.record as TailorTypePermission);\n }\n if (metadata.permissions.gql) {\n result = result.gqlPermission(metadata.permissions.gql as TailorTypeGqlPermission);\n }\n\n // Copy indexes from metadata (indexes are stored in metadata, not as a direct property)\n if (metadata.indexes && Object.keys(metadata.indexes).length > 0) {\n const indexDefs = Object.entries(metadata.indexes).map(([name, def]) => ({\n name,\n // Cast fields array to tuple type (IndexDef expects [T, T, ...T[]])\n fields: def.fields as [string, string, ...string[]],\n unique: def.unique,\n }));\n result = result.indexes(...indexDefs);\n }\n\n if (metadata.typeHook) {\n result = result.hooks(metadata.typeHook as TypeHook<Record<string, TailorAnyDBField>>);\n }\n if (metadata.typeValidate) {\n result = result.validate(\n metadata.typeValidate as TypeValidateFn<Record<string, TailorAnyDBField>>,\n );\n }\n\n // Copy plugins (but don't re-process them)\n if (original.plugins.length > 0) {\n for (const plugin of original.plugins) {\n // Use type assertion as plugin ID is dynamic at runtime\n result = result.plugin({\n [plugin.pluginId]: plugin.config,\n });\n }\n }\n\n return result;\n}\n"],"mappings":"A,2HAiJA,IAAa,cAAb,KAA2B,CACzB,wBAAuC,IAAI,IAC3C,mBAAmD,CAAC,EACpD,gBAAsD,CAAC,EACvD,mBAAmD,CAAC,EACpD,4CAAsC,IAAI,IAC1C,4CAAmD,IAAI,IACvD,+CAAsD,IAAI,IAE1D,YAAY,EAAoB,CAAC,EAAG,CAClC,IAAK,IAAME,KAAUC,EAAS,CAC5B,GAAI,KAAK,QAAQ,IAAID,EAAO,EAAE,EAC5B,MAAU,MACR,wBAAwBA,EAAO,GAAG,+CACpC,EAEF,KAAK,QAAQ,IAAIA,EAAO,GAAIA,CAAM,CACpC,CACF,CAQA,MAAM,kBAAkB,EAAqE,CAC3F,IAAMA,EAAS,KAAK,QAAQ,IAAIE,EAAQ,QAAQ,EAChD,GAAI,CAACF,EACH,MAAO,CACL,QAAS,GACT,MAAO,WAAWE,EAAQ,SAAS,YACrC,EAGF,IAAMC,EAAsBH,EAAO,oBAKnC,IAHE,OAAOG,GAAwB,WAC3BA,EAAoBH,EAAO,YAAY,EACvCG,IAAwB,MACLD,EAAQ,cAAgB,IAAA,IAAaA,EAAQ,cAAgB,MACpF,MAAO,CACL,QAAS,GACT,MAAO,WAAWF,EAAO,GAAG,2DAA2DE,EAAQ,MAAM,KAAK,GAC5G,EAIF,GAAI,CAACF,EAAO,cACV,MAAO,CACL,QAAS,GACT,MAAO,WAAWA,EAAO,GAAG,gIAC9B,EAIF,IAAII,EACJ,GAAI,CACF,EAAS,MAAMJ,EAAO,cAA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}
@@ -1,4 +1,2 @@
1
1
  import "../../../configure/services/auth/types.mjs";
2
- //#region src/parser/service/idp/types.d.ts
3
- export type IdPUserField = "id" | "name" | "disabled";
4
- //#endregion
2
+ export type IdPUserField = "id" | "name" | "disabled";
@@ -1,9 +1,7 @@
1
1
  import { PluginGeneratedTableSource, TypeSourceInfoEntry } from "./types.mjs";
2
- //#region src/parser/service/tailordb/type-source.d.ts
3
2
  /**
4
3
  * Checks if a table source is generated by a plugin.
5
4
  * @param source - The table source entry to check.
6
5
  * @returns True if the source was generated by a plugin.
7
6
  */
8
- export declare function isPluginGeneratedTable(source: TypeSourceInfoEntry): source is PluginGeneratedTableSource;
9
- //#endregion
7
+ export declare function isPluginGeneratedTable(source: TypeSourceInfoEntry): source is PluginGeneratedTableSource;
@@ -2,7 +2,6 @@ import { EnumValue } from "../../../configure/types/field.types.mjs";
2
2
  import { TailorDBTypeParsedSettings } from "../../../types/tailordb.generated.mjs";
3
3
  import { RawRelationConfig, TailorDBTypeMetadata } from "../../../configure/services/tailordb/types.mjs";
4
4
  import { ValueOperand } from "../../../configure/services/auth/types.mjs";
5
- //#region src/parser/service/tailordb/types.d.ts
6
5
  interface UserDefinedTypeSource {
7
6
  filePath: string;
8
7
  exportName: string;
@@ -128,5 +127,4 @@ export interface TailorDBType {
128
127
  };
129
128
  typeValidateExpr?: string;
130
129
  }
131
- //#endregion
132
130
  export {};
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "../../types.mjs";
2
- //#region src/plugin/builtin/enum-constants/index.d.ts
3
2
  /** Unique identifier for the enum constants generator plugin. */
4
3
  export declare const EnumConstantsGeneratorID = "@tailor-platform/enum-constants";
5
4
  type EnumConstantsPluginOptions = {
@@ -12,5 +11,4 @@ type EnumConstantsPluginOptions = {
12
11
  * @returns Plugin instance with onTailorDBReady hook
13
12
  */
14
13
  export declare function enumConstantsPlugin(options: EnumConstantsPluginOptions): Plugin<unknown, EnumConstantsPluginOptions>;
15
- //#endregion
16
14
  export {};
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "../../types.mjs";
2
- //#region src/plugin/builtin/file-utils/index.d.ts
3
2
  /** Unique identifier for the file utilities generator plugin. */
4
3
  export declare const FileUtilsGeneratorID = "@tailor-platform/file-utils";
5
4
  type FileUtilsPluginOptions = {
@@ -12,5 +11,4 @@ type FileUtilsPluginOptions = {
12
11
  * @returns Plugin instance with onTailorDBReady hook
13
12
  */
14
13
  export declare function fileUtilsPlugin(options: FileUtilsPluginOptions): Plugin<unknown, FileUtilsPluginOptions>;
15
- //#endregion
16
14
  export {};
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "../../types.mjs";
2
- //#region src/plugin/builtin/kysely-type/index.d.ts
3
2
  /** Unique identifier for the Kysely type generator plugin. */
4
3
  export declare const KyselyGeneratorID = "@tailor-platform/kysely-type";
5
4
  type KyselyTypePluginOptions = {
@@ -32,5 +31,4 @@ export declare const DEFAULT_KYSELY_TYPES_DIST_PATH = "./generated/tailordb.ts";
32
31
  * @returns Plugin instance with onTailorDBReady hook
33
32
  */
34
33
  export declare function kyselyTypePlugin(options: KyselyTypePluginOptions): Plugin<unknown, KyselyTypePluginOptions>;
35
- //#endregion
36
34
  export {};
@@ -1,5 +1,4 @@
1
1
  import { Plugin } from "../../types.mjs";
2
- //#region src/plugin/builtin/seed/index.d.ts
3
2
  /** Unique identifier for the seed generator plugin. */
4
3
  export declare const SeedGeneratorID = "@tailor-platform/seed";
5
4
  type DisableIdpUserSyncDirections = {
@@ -56,5 +55,4 @@ declare module "@tailor-platform/sdk/plugin" {
56
55
  * @returns Plugin instance with onTailorDBReady hook
57
56
  */
58
57
  export declare function seedPlugin(options: SeedPluginOptions): Plugin<unknown, SeedPluginOptions>;
59
- //#endregion
60
58
  export {};
@@ -1,5 +1,4 @@
1
1
  import "../../types.mjs";
2
- //#region src/plugin/builtin/seed/seed-type-processor.d.ts
3
2
  /**
4
3
  * Seed ordering information for a TailorDB namespace.
5
4
  */
@@ -31,5 +30,4 @@ export interface SeedNamespaceConfig {
31
30
  * instead of assuming `id`.
32
31
  */
33
32
  selfRefKeys?: Record<string, Record<string, string>>;
34
- }
35
- //#endregion
33
+ }
@@ -1,5 +1,4 @@
1
1
  import { TailorAnyDBType } from "../configure/services/tailordb/types.mjs";
2
- //#region src/plugin/get-generated-table.d.ts
3
2
  /**
4
3
  * Get a generated table from a plugin by loading the config and resolving everything automatically.
5
4
  * For table-attached plugins, calls onTableLoaded() with the source table.
@@ -24,5 +23,4 @@ export declare function getGeneratedTable(configPath: string, pluginId: string,
24
23
  * @param sourceTable - The TailorDB table as exported from its source file
25
24
  * @returns The table with every plugin-added field
26
25
  */
27
- export declare function getExtendedTable<T extends TailorAnyDBType>(configPath: string, sourceTable: T): Promise<T>;
28
- //#endregion
26
+ export declare function getExtendedTable<T extends TailorAnyDBType>(configPath: string, sourceTable: T): Promise<T>;
@@ -1,2 +1,2 @@
1
- import{t as e}from"../manager-DTRhIupk.mjs";import*as t from"pathe";import*as n from"node:fs";import{pathToFileURL as r}from"node:url";function withPluginContext(e){return e}const i=/* @__PURE__ */ new Map,a=[`onTableLoaded`,`onNamespaceLoaded`,`onTailorDBReady`,`onResolverReady`,`onExecutorReady`,`onDeployed`];function isPlugin(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;if(typeof t.id!=`string`||typeof t.description!=`string`||t.importPath!==void 0&&typeof t.importPath!=`string`||t.tableConfigRequired!==void 0&&typeof t.tableConfigRequired!=`boolean`&&typeof t.tableConfigRequired!=`function`)return!1;for(let e of a)if(t[e]!==void 0&&typeof t[e]!=`function`)return!1;return!((t.onTableLoaded||t.onNamespaceLoaded)&&!t.importPath)}async function loadAndCacheConfig(e){let a=t.resolve(e),o=i.get(a);if(o)return o;if(!n.existsSync(a))return null;let s=await import(r(a).href);if(!s?.default)throw Error(`Invalid config module at "${a}": default export not found`);let c=s.default,l=t.dirname(a),u=/* @__PURE__ */ new Map;if(Object.hasOwn(s,`plugins`)){let e=s.plugins;if(!Array.isArray(e))throw Error(`Invalid \`plugins\` export in "${a}": expected an array returned by definePlugins(), got ${typeof e}`);for(let t of e){if(!isPlugin(t))throw Error(`Invalid \`plugins\` export in "${a}": every item must be a plugin created by definePlugins()`);if(u.has(t.id))throw Error(`Duplicate plugin ID "${t.id}" detected in "${a}". Each plugin must have a unique ID.`);u.set(t.id,{plugin:t,pluginConfig:t.pluginConfig})}}let d={config:c,plugins:u,configDir:l};return i.set(a,d),d}async function resolveNamespaceForTable(e,i,a){if(!e.db)throw Error(`No db configuration found in config`);for(let[o,s]of Object.entries(e.db)){let e=s;if(!e.external&&e.files)for(let s of e.files){let e=t.resolve(i,s),c;try{c=n.globSync(e)}catch{continue}for(let e of c){let t=await import(r(e).href);for(let e of Object.values(t))if(e===a)return o}}}throw Error(`Could not resolve namespace for table "${a.name}". Ensure the table file is included in a db namespace's files pattern.`)}async function resolveNamespaceForNamespacePlugin(e,t,n,r){if(!e.db)throw Error(`No db configuration found in config`);if(!t.onNamespaceLoaded)throw Error(`Plugin "${t.id}" does not have a onNamespaceLoaded() method`);for(let i of Object.keys(e.db)){if(e.db[i].external)continue;let a=await t.onNamespaceLoaded({pluginConfig:r,namespace:i});if(a.tables?.[n])return{namespace:i,output:a}}throw Error(`Could not resolve namespace for plugin "${t.id}" with kind "${n}". No namespace produced a table with that kind.`)}const o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new WeakMap;function getCacheKey(e,t){if(t===void 0)return e;try{return`${e}:${JSON.stringify(t)}`}catch{throw Error(`pluginConfig must be JSON-serializable for caching. Received non-serializable value.`)}}async function getGeneratedTable(e,t,n,r){let i=await loadAndCacheConfig(e);if(!i)return{name:`__placeholder_${r}__`,fields:{}};let{config:a,configDir:o,plugins:s}=i,c=s.get(t);if(!c)throw Error(`Plugin "${t}" not found in config at "${e}". Ensure the plugin is registered via definePlugins().`);let{plugin:l,pluginConfig:u}=c;return n===null?getGeneratedTableForNamespacePlugin(a,l,r,u):getGeneratedTableForTableAttachedPlugin(l,n,r,u,await resolveNamespaceForTable(a,o,n))}async function getGeneratedTableForTableAttachedPlugin(e,t,n,r,i){if(!e.onTableLoaded)throw Error(`Plugin "${e.id}" does not have an onTableLoaded() method`);let a=o.get(e);a||(a=/* @__PURE__ */ new Map,o.set(e,a));let s=getCacheKey(`${t.name}:ns=${i}`,r),c=a.get(s);if(!c){let n=t.plugins.find(t=>t.pluginId===e.id)?.config;c=await e.onTableLoaded({table:t,tableConfig:n??{},pluginConfig:r,namespace:i}),a.set(s,c)}let l=c.tables?.[n];if(!l)throw Error(`Generated table not found: plugin=${e.id}, sourceTable=${t.name}, kind=${n}`);return l}async function getGeneratedTableForNamespacePlugin(e,t,n,r){if(!t.onNamespaceLoaded)throw Error(`Plugin "${t.id}" does not have a onNamespaceLoaded() method`);let i=s.get(t);if(i||(i=/* @__PURE__ */ new Map,s.set(t,i)),e.db)for(let t of Object.keys(e.db)){if(e.db[t].external)continue;let a=getCacheKey(`namespace:ns=${t}`,r),o=i.get(a);if(o?.tables?.[n])return o.tables[n]}let{namespace:a,output:o}=await resolveNamespaceForNamespacePlugin(e,t,n,r),c=getCacheKey(`namespace:ns=${a}`,r);i.set(c,o);let l=o.tables?.[n];if(!l)throw Error(`Generated table not found: plugin=${t.id}, kind=${n}`);return l}const c=/* @__PURE__ */ new Map;async function getExtendedTable(e,n){if(n.plugins.length===0)return n;let r=t.resolve(e),i=c.get(r);i||(i=/* @__PURE__ */ new WeakMap,c.set(r,i));let a=i.get(n);if(a)return a;let o=applyPluginExtensions(r,n);return i.set(n,o),o.catch(()=>i.delete(n)),o}async function applyPluginExtensions(t,n){let r=await loadAndCacheConfig(t);if(!r)return n;let{config:i,configDir:a,plugins:o}=r,s=await resolveNamespaceForTable(i,a,n),{extendedTable:c}=await new e([...o.values()].map(e=>e.plugin)).processAttachmentsForTable({rawTable:n,attachments:[...n.plugins],namespace:s});return c??n}export{getExtendedTable,getGeneratedTable,withPluginContext};
1
+ import{t as e}from"../manager-B813m43t.mjs";import*as t from"pathe";import*as n from"node:fs";import{pathToFileURL as r}from"node:url";function withPluginContext(e){return e}const i=/* @__PURE__ */ new Map,a=[`onTableLoaded`,`onNamespaceLoaded`,`onTailorDBReady`,`onResolverReady`,`onExecutorReady`,`onDeployed`];function isPlugin(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;if(typeof t.id!=`string`||typeof t.description!=`string`||t.importPath!==void 0&&typeof t.importPath!=`string`||t.tableConfigRequired!==void 0&&typeof t.tableConfigRequired!=`boolean`&&typeof t.tableConfigRequired!=`function`)return!1;for(let e of a)if(t[e]!==void 0&&typeof t[e]!=`function`)return!1;return!((t.onTableLoaded||t.onNamespaceLoaded)&&!t.importPath)}async function loadAndCacheConfig(e){let a=t.resolve(e),o=i.get(a);if(o)return o;if(!n.existsSync(a))return null;let s=await import(r(a).href);if(!s?.default)throw Error(`Invalid config module at "${a}": default export not found`);let c=s.default,l=t.dirname(a),u=/* @__PURE__ */ new Map;if(Object.hasOwn(s,`plugins`)){let e=s.plugins;if(!Array.isArray(e))throw Error(`Invalid \`plugins\` export in "${a}": expected an array returned by definePlugins(), got ${typeof e}`);for(let t of e){if(!isPlugin(t))throw Error(`Invalid \`plugins\` export in "${a}": every item must be a plugin created by definePlugins()`);if(u.has(t.id))throw Error(`Duplicate plugin ID "${t.id}" detected in "${a}". Each plugin must have a unique ID.`);u.set(t.id,{plugin:t,pluginConfig:t.pluginConfig})}}let d={config:c,plugins:u,configDir:l};return i.set(a,d),d}async function resolveNamespaceForTable(e,i,a){if(!e.db)throw Error(`No db configuration found in config`);for(let[o,s]of Object.entries(e.db)){let e=s;if(!e.external&&e.files)for(let s of e.files){let e=t.resolve(i,s),c;try{c=n.globSync(e)}catch{continue}for(let e of c){let t=await import(r(e).href);for(let e of Object.values(t))if(e===a)return o}}}throw Error(`Could not resolve namespace for table "${a.name}". Ensure the table file is included in a db namespace's files pattern.`)}async function resolveNamespaceForNamespacePlugin(e,t,n,r){if(!e.db)throw Error(`No db configuration found in config`);if(!t.onNamespaceLoaded)throw Error(`Plugin "${t.id}" does not have a onNamespaceLoaded() method`);for(let i of Object.keys(e.db)){if(e.db[i].external)continue;let a=await t.onNamespaceLoaded({pluginConfig:r,namespace:i});if(a.tables?.[n])return{namespace:i,output:a}}throw Error(`Could not resolve namespace for plugin "${t.id}" with kind "${n}". No namespace produced a table with that kind.`)}const o=/* @__PURE__ */ new WeakMap,s=/* @__PURE__ */ new WeakMap;function getCacheKey(e,t){if(t===void 0)return e;try{return`${e}:${JSON.stringify(t)}`}catch{throw Error(`pluginConfig must be JSON-serializable for caching. Received non-serializable value.`)}}async function getGeneratedTable(e,t,n,r){let i=await loadAndCacheConfig(e);if(!i)return{name:`__placeholder_${r}__`,fields:{}};let{config:a,configDir:o,plugins:s}=i,c=s.get(t);if(!c)throw Error(`Plugin "${t}" not found in config at "${e}". Ensure the plugin is registered via definePlugins().`);let{plugin:l,pluginConfig:u}=c;return n===null?getGeneratedTableForNamespacePlugin(a,l,r,u):getGeneratedTableForTableAttachedPlugin(l,n,r,u,await resolveNamespaceForTable(a,o,n))}async function getGeneratedTableForTableAttachedPlugin(e,t,n,r,i){if(!e.onTableLoaded)throw Error(`Plugin "${e.id}" does not have an onTableLoaded() method`);let a=o.get(e);a||(a=/* @__PURE__ */ new Map,o.set(e,a));let s=getCacheKey(`${t.name}:ns=${i}`,r),c=a.get(s);if(!c){let n=t.plugins.find(t=>t.pluginId===e.id)?.config;c=await e.onTableLoaded({table:t,tableConfig:n??{},pluginConfig:r,namespace:i}),a.set(s,c)}let l=c.tables?.[n];if(!l)throw Error(`Generated table not found: plugin=${e.id}, sourceTable=${t.name}, kind=${n}`);return l}async function getGeneratedTableForNamespacePlugin(e,t,n,r){if(!t.onNamespaceLoaded)throw Error(`Plugin "${t.id}" does not have a onNamespaceLoaded() method`);let i=s.get(t);if(i||(i=/* @__PURE__ */ new Map,s.set(t,i)),e.db)for(let t of Object.keys(e.db)){if(e.db[t].external)continue;let a=getCacheKey(`namespace:ns=${t}`,r),o=i.get(a);if(o?.tables?.[n])return o.tables[n]}let{namespace:a,output:o}=await resolveNamespaceForNamespacePlugin(e,t,n,r),c=getCacheKey(`namespace:ns=${a}`,r);i.set(c,o);let l=o.tables?.[n];if(!l)throw Error(`Generated table not found: plugin=${t.id}, kind=${n}`);return l}const c=/* @__PURE__ */ new Map;async function getExtendedTable(e,n){if(n.plugins.length===0)return n;let r=t.resolve(e),i=c.get(r);i||(i=/* @__PURE__ */ new WeakMap,c.set(r,i));let a=i.get(n);if(a)return a;let o=applyPluginExtensions(r,n);return i.set(n,o),o.catch(()=>i.delete(n)),o}async function applyPluginExtensions(t,n){let r=await loadAndCacheConfig(t);if(!r)return n;let{config:i,configDir:a,plugins:o}=r,s=await resolveNamespaceForTable(i,a,n),{extendedTable:c}=await new e([...o.values()].map(e=>e.plugin)).processAttachmentsForTable({rawTable:n,attachments:[...n.plugins],namespace:s});return c??n}export{getExtendedTable,getGeneratedTable,withPluginContext};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -3,7 +3,6 @@ import { IdProvider, OAuth2Client } from "../types/auth.generated.mjs";
3
3
  import { TailorDBType, TypeSourceInfoEntry } from "../parser/service/tailordb/types.mjs";
4
4
  import { Executor } from "../types/executor.generated.mjs";
5
5
  import { Resolver } from "../types/resolver.generated.mjs";
6
- //#region src/plugin/types.d.ts
7
6
  /**
8
7
  * A single generated file to write to disk.
9
8
  */
@@ -355,5 +354,4 @@ export interface DeployedHookResult {
355
354
  /** Values included in deploy's JSON result. Interface-typed values are accepted, but a `Date` or class instance nested inside one fails the deploy instead of the type check. */
356
355
  outputs?: Record<string, PluginOutputValue>;
357
356
  }
358
- //#endregion
359
357
  export type { PluginAttachment };
@@ -1,5 +1,4 @@
1
1
  import { TailorEnv, TailorPrincipal } from "../runtime/types.mjs";
2
- //#region src/plugin/with-context.d.ts
3
2
  /**
4
3
  * Plugin executor factory function type.
5
4
  * Takes context and returns an executor configuration.
@@ -96,5 +95,4 @@ export type PluginRecord = {
96
95
  * );
97
96
  * ```
98
97
  */
99
- export declare function withPluginContext<Ctx>(factory: PluginExecutorFactory<Ctx>): PluginExecutorFactory<Ctx>;
100
- //#endregion
98
+ export declare function withPluginContext<Ctx>(factory: PluginExecutorFactory<Ctx>): PluginExecutorFactory<Ctx>;