@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
@@ -1 +0,0 @@
1
- export{n as reportCrash}from"./crashreport-BCIy33Cz.mjs";
@@ -1,5 +0,0 @@
1
- import{s as e,u as t}from"./logger-RgtbhJ83.mjs";const n=/^[A-Za-z0-9_./:=@+-]+$/,r=/^[A-Za-z0-9_./:=@+\\-]+$/,i=/[%$"`“”„\p{Cc}]|\\$|^~(?:[\\/]|$)/u,a=/"|\s.*\\$|^~(?:[\\/]|$)/;function quotePosixArg(e){return n.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`}function isPowerShellBare(e){return r.test(e)&&!/^(@|[+-]?\.?\d)/.test(e)&&e!==`--`&&!/^-[^-].*[.:]/.test(e)}function quotePowerShellArg(e){return isPowerShellBare(e)?e:`'${e.replace(/['‘’‚‛]/g,`$&$&`)}'`}function quoteCmdArg(e){if(r.test(e)&&!e.endsWith(`\\`))return e;let t=`"`,n=0;for(let r of e)r===`\\`?n++:(t+=r===`"`?`${`\\`.repeat(n*2)}""`:`${`\\`.repeat(n)}${r===`%`?`%%cd:~,%`:r}`,n=0);return`${t}${`\\`.repeat(n*2)}"`}function formatWindowsCommandLines(e){if(e.every(e=>isPowerShellBare(e)||e!==``&&!i.test(e)))return{kind:`shared`,commandLine:e.map(e=>isPowerShellBare(e)?e:`"${e}"`).join(` `)};let t=e.map(quoteCmdArg).join(` `);return{kind:`perShell`,powershell:e.some(e=>e===``||a.test(e))?`cmd /d /s /c ${quotePowerShellArg(t)}`:e.map(quotePowerShellArg).join(` `),cmd:t}}function formatShellCommandLines(e){return process.platform===`win32`?formatWindowsCommandLines(e):{kind:`shared`,commandLine:e.map(quotePosixArg).join(` `)}}function formatCommandHint(t){let n=formatShellCommandLines([t.command,...t.args].map(t=>e(t)));return n.kind===`shared`?`\`${n.commandLine}\``:`\`${n.powershell}\` in PowerShell or \`${n.cmd}\` in cmd.exe`}function redactAndIndent(t){return e(t).split(`
2
- `).join(`
3
- `)}function formatError(e){let n=[t.error(`Error${e.code?` [${e.code}]`:``}: ${e.message}`)];return e.details&&n.push(`\n ${t.dim(`Details:`)} ${redactAndIndent(e.details)}`),e.suggestion&&n.push(`\n ${t.info(`Suggestion:`)} ${redactAndIndent(e.suggestion)}`),e.command&&n.push(`\n ${t.dim(`Help:`)} Run \`tailor ${e.command} --help\` for usage information.`),e.next&&n.push(`\n ${t.info(`Next:`)} Run ${formatCommandHint(e.next)}.`),n.join(``)}function CLIError(e){let t=Error(e.message,e.cause===void 0?void 0:{cause:e.cause});return t.name=`CLIError`,t.code=e.code,t.details=e.details,t.suggestion=e.suggestion,t.command=e.command,t.next=e.next,t.context=e.context,t.format=()=>formatError(t),t}function isCLIError(e){return e instanceof Error&&e.name===`CLIError`}function errorSummary(e){return isCLIError(e)?[e.message,e.details,e.suggestion].filter(Boolean).join(`
4
- `):e instanceof Error?e.message:String(e)}function internalError(e,t){return Error(e,t)}function toError(e){return e instanceof Error?e:Error(String(e),{cause:e})}const o=/does not provide an export named '(?!default')([^']+)'/;function typeOnlyImportHint(e){if(!(e instanceof SyntaxError))return;let t=o.exec(e.message)?.[1];if(t)return`If '${t}' is a type, import it with \`import type\` (or the inline \`type\` modifier). The CLI runs TypeScript by stripping types from each file in isolation, so type-only exports do not exist at runtime. Set "verbatimModuleSyntax": true in tsconfig.json to catch this at typecheck.`}export{isCLIError as a,internalError as i,errorSummary as n,toError as o,formatCommandHint as r,typeOnlyImportHint as s,CLIError as t};
5
- //# sourceMappingURL=errors-BOF68LJ5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-BOF68LJ5.mjs","names":["redactSecrets","styles","POSIX_BARE_ARG","CMD_BARE_ARG","WINDOWS_DOUBLE_QUOTE_UNSAFE","POWERSHELL_VERSION_SENSITIVE","value","quoted","backslashes","char","argv","cmd","commandLines","action","arg","text","parts","error","options","message","MISSING_NAMED_EXPORT_PATTERN","name"],"sources":["../src/cli/shared/shell-quote.ts","../src/cli/shared/errors.ts"],"sourcesContent":["/**\n * Command lines for a suggested command: one line when every supported shell reads it the same\n * way, otherwise one line per Windows shell.\n */\nexport type ShellCommandLines =\n | { kind: \"shared\"; commandLine: string }\n | { kind: \"perShell\"; powershell: string; cmd: string };\n\nconst POSIX_BARE_ARG = /^[A-Za-z0-9_./:=@+-]+$/;\nconst CMD_BARE_ARG = /^[A-Za-z0-9_./:=@+\\\\-]+$/;\n// PowerShell expands `$` and backtick escapes inside double quotes and reads `“ ” „` as `\"`,\n// cmd.exe expands `%` even inside quotes, a `\"` or a trailing backslash changes where the\n// quoted argument ends, and a leading `~` is version-sensitive (below).\nconst WINDOWS_DOUBLE_QUOTE_UNSAFE = /[%$\"`“”„\\p{Cc}]|\\\\$|^~(?:[\\\\/]|$)/u;\n// PowerShell versions pass these to programs differently: Windows PowerShell 5.1 and 7.3+\n// disagree on quotes and trailing backslashes, and 7.6+ expands a leading `~` inside the `.ps1`\n// shim however it was quoted.\nconst POWERSHELL_VERSION_SENSITIVE = /\"|\\s.*\\\\$|^~(?:[\\\\/]|$)/;\n\nfunction quotePosixArg(value: string): string {\n if (POSIX_BARE_ARG.test(value)) return value;\n return `'${value.replaceAll(\"'\", `'\"'\"'`)}'`;\n}\n\nfunction isPowerShellBare(value: string): boolean {\n // A leading `@` splats, a lone `--` ends parameters, a leading digit reads as a number, and a\n // single-dash token with `.` or `:` reads as parameter syntax.\n return (\n CMD_BARE_ARG.test(value) &&\n !/^(@|[+-]?\\.?\\d)/.test(value) &&\n value !== \"--\" &&\n !/^-[^-].*[.:]/.test(value)\n );\n}\n\nfunction quotePowerShellArg(value: string): string {\n if (isPowerShellBare(value)) return value;\n return `'${value.replace(/['‘’‚‛]/g, \"$&$&\")}'`;\n}\n\nfunction quoteCmdArg(value: string): string {\n // Quoting a trailing backslash keeps a command routed through `cmd /c` from ending in one,\n // which PowerShell 7 doubles when it quotes the line.\n if (CMD_BARE_ARG.test(value) && !value.endsWith(\"\\\\\")) return value;\n let quoted = '\"';\n let backslashes = 0;\n for (const char of value) {\n if (char === \"\\\\\") {\n backslashes++;\n continue;\n }\n if (char === '\"') {\n quoted += `${\"\\\\\".repeat(backslashes * 2)}\"\"`;\n } else {\n // `%%cd:~,%` reads back as a literal `%` without cmd.exe expanding a `%NAME%` around it.\n quoted += `${\"\\\\\".repeat(backslashes)}${char === \"%\" ? \"%%cd:~,%\" : char}`;\n }\n backslashes = 0;\n }\n return `${quoted}${\"\\\\\".repeat(backslashes * 2)}\"`;\n}\n\nfunction formatWindowsCommandLines(argv: readonly string[]): ShellCommandLines {\n if (\n argv.every(\n (value) =>\n isPowerShellBare(value) || (value !== \"\" && !WINDOWS_DOUBLE_QUOTE_UNSAFE.test(value)),\n )\n ) {\n return {\n kind: \"shared\",\n commandLine: argv.map((value) => (isPowerShellBare(value) ? value : `\"${value}\"`)).join(\" \"),\n };\n }\n const cmd = argv.map(quoteCmdArg).join(\" \");\n // Both PowerShell versions pass a `cmd` argument the same legacy way, so routing the cmd.exe\n // line through `cmd /c` keeps the arguments identical where their native quoting differs.\n const powershell = argv.some((value) => value === \"\" || POWERSHELL_VERSION_SENSITIVE.test(value))\n ? `cmd /d /s /c ${quotePowerShellArg(cmd)}`\n : argv.map(quotePowerShellArg).join(\" \");\n return { kind: \"perShell\", powershell, cmd };\n}\n\n/**\n * Render an argv array as command lines that the current platform's shells run with every\n * argument delivered unchanged\n * @param {readonly string[]} argv - Executable name followed by its arguments\n * @returns {ShellCommandLines} One shared command line, or one per Windows shell\n */\nexport function formatShellCommandLines(argv: readonly string[]): ShellCommandLines {\n if (process.platform === \"win32\") return formatWindowsCommandLines(argv);\n return { kind: \"shared\", commandLine: argv.map(quotePosixArg).join(\" \") };\n}\n","import { redactSecrets, styles } from \"./logger\";\nimport { formatShellCommandLines } from \"./shell-quote\";\nimport type { Jsonifiable } from \"type-fest\";\n\n/**\n * Options for creating a CLI error\n */\ninterface CLIErrorOptions {\n /** Stable machine-readable failure code, such as `WORKSPACE_NOT_FOUND`. */\n code: string;\n message: string;\n details?: string;\n suggestion?: string;\n command?: string;\n next?: CLIErrorNextAction;\n context?: Readonly<Record<string, Jsonifiable | undefined>>;\n cause?: unknown;\n}\n\nexport type CLIErrorNextAction = {\n /** Executable name, such as `tailor`. */\n command: string;\n /** Arguments passed directly to the executable. */\n args: readonly string[];\n};\n\n/**\n * CLI error interface with formatted output\n */\nexport interface CLIError extends Error {\n readonly code: string;\n readonly details?: string;\n readonly suggestion?: string;\n readonly command?: string;\n readonly next?: CLIErrorNextAction;\n readonly context?: Readonly<Record<string, Jsonifiable | undefined>>;\n format(): string;\n}\n\ntype CLIErrorInternal = Error & {\n code: string;\n details?: string;\n suggestion?: string;\n command?: string;\n next?: CLIErrorNextAction;\n context?: Readonly<Record<string, Jsonifiable | undefined>>;\n format(): string;\n};\n\n/**\n * Render a command as a user-facing hint that can be copied into the current platform's shells:\n * one backticked command line, or on Windows, when no single quoting suits both shells, a\n * PowerShell and a cmd.exe line (`` `…` in PowerShell or `…` in cmd.exe ``).\n * Registered secrets are redacted before quoting, which could otherwise split them.\n * @param {CLIErrorNextAction} action - Executable and arguments to suggest\n * @returns {string} The command part of the hint, to follow a verb such as \"Run\"\n */\nexport function formatCommandHint(action: CLIErrorNextAction): string {\n const commandLines = formatShellCommandLines(\n [action.command, ...action.args].map((arg) => redactSecrets(arg)),\n );\n if (commandLines.kind === \"shared\") {\n return `\\`${commandLines.commandLine}\\``;\n }\n return `\\`${commandLines.powershell}\\` in PowerShell or \\`${commandLines.cmd}\\` in cmd.exe`;\n}\n\n/**\n * Redact registered secrets, then indent every line after the first.\n * Redacting first keeps the indent from splitting a multi-line secret.\n * @param text - Details or suggestion text\n * @returns Redacted text with its continuation lines indented\n */\nfunction redactAndIndent(text: string): string {\n return redactSecrets(text).split(\"\\n\").join(\"\\n \");\n}\n\n/**\n * Format CLI error for output\n * @param error - CLIError instance to format\n * @returns Formatted error message\n */\nfunction formatError(error: CLIError): string {\n const parts: string[] = [\n styles.error(`Error${error.code ? ` [${error.code}]` : \"\"}: ${error.message}`),\n ];\n\n if (error.details) {\n parts.push(`\\n ${styles.dim(\"Details:\")} ${redactAndIndent(error.details)}`);\n }\n\n if (error.suggestion) {\n parts.push(`\\n ${styles.info(\"Suggestion:\")} ${redactAndIndent(error.suggestion)}`);\n }\n\n if (error.command) {\n parts.push(\n `\\n ${styles.dim(\"Help:\")} Run \\`tailor ${error.command} --help\\` for usage information.`,\n );\n }\n\n if (error.next) {\n parts.push(`\\n ${styles.info(\"Next:\")} Run ${formatCommandHint(error.next)}.`);\n }\n\n return parts.join(\"\");\n}\n\n/**\n * Create a CLI error with formatted output\n * @param options - Options to construct a CLIError\n * @returns Constructed CLIError instance\n */\nexport function CLIError(options: CLIErrorOptions): CLIError {\n const error = new Error(\n options.message,\n options.cause === undefined ? undefined : { cause: options.cause },\n ) as CLIErrorInternal;\n error.name = \"CLIError\";\n error.code = options.code;\n error.details = options.details;\n error.suggestion = options.suggestion;\n error.command = options.command;\n error.next = options.next;\n error.context = options.context;\n error.format = () => formatError(error);\n return error;\n}\n\n/**\n * Type guard to check if an error is a CLIError\n * @param error - Error to check\n * @returns True if the error is a CLIError\n */\nexport function isCLIError(error: unknown): error is CLIError {\n return error instanceof Error && error.name === \"CLIError\";\n}\n\n/**\n * Summarize a failure as plain text for reports that carry a single error string.\n * CLI errors contribute their details and suggestion so the remediation survives.\n * @param error - Failure to summarize\n * @returns Message followed by any details and suggestion, one per line\n */\nexport function errorSummary(error: unknown): string {\n if (isCLIError(error)) {\n return [error.message, error.details, error.suggestion].filter(Boolean).join(\"\\n\");\n }\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * Create an error for an SDK invariant violation that no user action can fix.\n * The result is a plain Error, so JSON output reports it as `UNEXPECTED_ERROR`\n * and crash reporting treats it like any other unexpected failure.\n * @param message - Description of the violated invariant\n * @param options - Standard Error options, such as `cause`\n * @returns Plain Error instance\n */\nexport function internalError(message: string, options?: ErrorOptions): Error {\n return new Error(message, options);\n}\n\n/**\n * Convert a caught value into an Error, keeping Error instances as-is\n * @param value - Caught value\n * @returns The value itself when it is an Error, otherwise an Error of its string form with the value as `cause`\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value), { cause: value });\n}\n\nconst MISSING_NAMED_EXPORT_PATTERN = /does not provide an export named '(?!default')([^']+)'/;\n\n/**\n * Suggest `import type` when importing user code fails on a missing named\n * export. The CLI strips types from each file in isolation, so a type-only\n * export does not exist at runtime and a plain import of it fails to link.\n * @param error - Error thrown while importing user modules\n * @returns Suggestion text, or undefined when the error is not that failure\n */\nexport function typeOnlyImportHint(error: unknown): string | undefined {\n if (!(error instanceof SyntaxError)) return undefined;\n const name = MISSING_NAMED_EXPORT_PATTERN.exec(error.message)?.[1];\n if (!name) return undefined;\n return (\n `If '${name}' is a type, import it with \\`import type\\` (or the inline \\`type\\` modifier). ` +\n \"The CLI runs TypeScript by stripping types from each file in isolation, so type-only exports do not exist at runtime. \" +\n 'Set \"verbatimModuleSyntax\": true in tsconfig.json to catch this at typecheck.'\n );\n}\n"],"mappings":"A,iDAQA,MAAME,EAAiB,yBACjBC,EAAe,2BAIfC,EAA8B,qCAI9BC,EAA+B,0BAErC,SAAS,cAAc,EAAuB,CAE5C,OADIH,EAAe,KAAKI,CAAK,EAAUA,EAChC,IAAIA,EAAM,WAAW,IAAK,OAAO,EAAE,EAC5C,CAEA,SAAS,iBAAiB,EAAwB,CAGhD,OACEH,EAAa,KAAKG,CAAK,GACvB,CAAC,kBAAkB,KAAKA,CAAK,GAC7BA,IAAU,MACV,CAAC,eAAe,KAAKA,CAAK,CAE9B,CAEA,SAAS,mBAAmB,EAAuB,C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gB,WAAW,EAAmC,CAC5D,OAAOA,aAAiB,OAASA,EAAM,OAAS,UAClD,CAQA,SAAgB,aAAa,EAAwB,CAInD,OAHI,WAAWA,CAAK,EACX,CAACA,EAAM,QAASA,EAAM,QAASA,EAAM,UAAU,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK;CAAI,EAE5EA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAC9D,CAUA,SAAgB,cAAc,EAAiB,EAA+B,CAC5E,OAAW,MAAME,EAASD,CAAO,CACnC,CAOA,SAAgB,QAAQ,EAAuB,CAC7C,OAAOZ,aAAiB,MAAQA,EAAY,MAAM,OAAOA,CAAK,EAAG,CAAE,MAAOA,CAAM,CAAC,CACnF,CAEA,MAAMc,EAA+B,yDASrC,SAAgB,mBAAmB,EAAoC,CACrE,GAAI,EAAEH,aAAiB,aAAc,OACrC,IAAMI,EAAOD,EAA6B,KAAKH,EAAM,OAAO,CAAC,GAAG,GAChE,GAAKI,EACL,MACE,OAAOA,EAAK,mRAIhB,C"}
@@ -1,2 +0,0 @@
1
- import{n as e,o as t,t as n}from"./date-CgP7gMG_.mjs";const r={uuid:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,date:/^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/,time:/^(?<hour>[01]\d|2[0-3]):(?<minute>[0-5]\d)$/,datetime:/^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})[Tt](?<hour>[01]\d|2[0-3]):(?<minute>[0-5]\d):(?<second>[0-5]\d|60)(\.(?<fraction>\d+))?(?<offset>[Zz]|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/,decimal:/^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/};function isNestedObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function validateBaseValue(e){let{field:t,value:n,pathArray:i,issues:a}=e,o=i.length>0?i:void 0,s=a.length;switch(t.type){case`string`:typeof n!=`string`&&a.push({message:`Expected a string: received ${String(n)}`,path:o});break;case`integer`:(typeof n!=`number`||!Number.isInteger(n))&&a.push({message:`Expected an integer: received ${String(n)}`,path:o});break;case`float`:(typeof n!=`number`||!Number.isFinite(n))&&a.push({message:`Expected a number: received ${String(n)}`,path:o});break;case`boolean`:typeof n!=`boolean`&&a.push({message:`Expected a boolean: received ${String(n)}`,path:o});break;case`uuid`:(typeof n!=`string`||!r.uuid.test(n))&&a.push({message:`Expected a valid UUID: received ${String(n)}`,path:o});break;case`date`:(typeof n!=`string`||!r.date.test(n))&&a.push({message:`Expected to match "yyyy-MM-dd" format: received ${String(n)}`,path:o});break;case`datetime`:(typeof n!=`string`||!r.datetime.test(n))&&a.push({message:`Expected to match ISO format: received ${String(n)}`,path:o});break;case`time`:(typeof n!=`string`||!r.time.test(n))&&a.push({message:`Expected to match "HH:mm" format: received ${String(n)}`,path:o});break;case`decimal`:(typeof n!=`string`||!r.decimal.test(n))&&a.push({message:`Expected a decimal string: received ${String(n)}`,path:o});break;case`enum`:if(t._metadata.allowedValues){let e=t._metadata.allowedValues.map(e=>e.value);(typeof n!=`string`||!e.includes(n))&&a.push({message:`Must be one of [${e.join(`, `)}]: received ${String(n)}`,path:o})}break;case`nested`:{if(!isNestedObject(n))return a.push({message:`Expected an object: received ${String(n)}`,path:o}),!1;let r=!0;for(let[a,o]of Object.entries(t.fields)){let t=n[a];validateBaseField({...e,field:o,value:t,pathArray:i.concat(a)})||(r=!1)}return r}}return a.length===s}function validateCustomValue(e,t){let{value:n,pathArray:r,issues:i}=e,a=r.length>0?r:void 0;for(let e of t){let t=e({value:n});typeof t==`string`&&i.push({message:t,path:a})}}function validateBaseField(e){let{field:t,value:n,pathArray:r,issues:i}=e,a=r.length>0?r:void 0,o=n==null;if(t._metadata.required&&o)return i.push({message:`Required field is missing`,path:a}),!1;if(!t._metadata.required&&o)return!0;let s=!0;if(t._metadata.array){if(!Array.isArray(n))return i.push({message:`Expected an array`,path:a}),!1;for(let t=0;t<n.length;t++)validateBaseValue({...e,value:n[t],pathArray:r.concat(`[${t}]`)})||(s=!1)}else s=validateBaseValue(e);return s}function validateCustomField(e){let{field:t,value:n,pathArray:r}=e;if(n==null)return;if(t.type===`nested`){let i=t._metadata.array?n:[n];for(let n=0;n<i.length;n++){let a=i[n],o=t._metadata.array?r.concat(`[${n}]`):r;for(let[n,r]of Object.entries(t.fields))validateCustomField({...e,field:r,value:a[n],pathArray:o.concat(n)})}}let i=t._metadata.validate;i?.length&&validateCustomValue(e,i)}function parseInternal(e,t=a){let{value:n}=e,r=[],i={...e,issues:r};return validateBaseField(i)&&(n=deserializeDates(i,t),r.length===0&&validateCustomField({...i,value:n})),r.length>0?{issues:r}:{value:n??null}}function rejectLeapSecond(e,t){if(e===`datetime`&&t.slice(17,19)===`60`)throw RangeError(`Leap seconds are not supported`)}function parseAsDate(t,n){rejectLeapSecond(t,n);let r=new Date(t===`date`?`${n}T00:00:00.000Z`:t===`time`?`1970-01-01T${n}:00.000Z`:n);if(!Number.isFinite(r.getTime()))throw RangeError(`Invalid Date`);if(t!==`time`){let t=n.slice(0,10);if(e(/* @__PURE__ */ new Date(`${t}T00:00:00.000Z`))!==t)throw RangeError(`Invalid calendar date`)}return r}function parseAsTemporal(e,n){rejectLeapSecond(e,n);let r=t();return e===`date`?r.PlainDate.from(n):e===`datetime`?r.Instant.from(n):r.PlainTime.from(n)}const i={date:parseAsDate,temporal:parseAsTemporal},a={date:globalThis.process?.env.__TAILOR_PLATFORM_BUNDLE_WITHOUT_DATE?void 0:parseAsDate,temporal:globalThis.process?.env.__TAILOR_PLATFORM_BUNDLE_WITHOUT_TEMPORAL?void 0:parseAsTemporal};function deserializeDates(e,t){let{field:r,value:i,issues:a,pathArray:o}=e;if(i==null)return i;let convert=(i,o)=>{let{type:s}=r,c=n(s,r._metadata.as);if(c){let e=t[c];if(!e)throw Error(`Parsing fields declared with as: "${c}" is not included in this bundle. Parse them with parseDateFields, exported by "@tailor-platform/sdk/runtime".`);try{return e(s,String(i))}catch(e){if(!(e instanceof RangeError))throw e;return a.push({message:`Expected a valid ${s===`date`?`calendar date`:s}: received ${i}`,path:o.length>0?o:void 0}),i}}if(r.type!==`nested`)return i;let l=i,u=l;for(let[n,i]of Object.entries(r.fields)){let r=deserializeDates({...e,field:i,value:l[n],pathArray:o.concat(n)},t);r!==l[n]&&(u===l&&(u={...l}),Object.defineProperty(u,n,{value:r,enumerable:!0,configurable:!0,writable:!0}))}return u};if(!r._metadata.array)return convert(i,o);let s=i,c=s.map((e,t)=>convert(e,o.concat(`[${t}]`)));return c.every((e,t)=>e===s[t])?i:c}function parseInputFields(e){let{fields:t,...n}=e;return parseInternal({...n,field:{type:`nested`,fields:t,_metadata:{required:!0}},pathArray:[]})}function parseDateFields(e,t){return parseInternal({...t,field:e,pathArray:[]},i)}export{parseInternal as i,parseDateFields as n,parseInputFields as r,isNestedObject as t};
2
- //# sourceMappingURL=field-parse-C41e3UAF.mjs.map
@@ -1,2 +0,0 @@
1
- function getRawPluginTableName(e){let t=typeof e==`object`&&e&&`name`in e?e.name:void 0;return typeof t==`string`?t:void 0}function getPluginGenerationDependencies(e){let t=/* @__PURE__ */ new Set;return e.onTailorDBReady&&t.add(`tailordb`),e.onResolverReady&&t.add(`resolver`),e.onExecutorReady&&t.add(`executor`),t}function hasGenerationHooks(e){return!!(e.onTailorDBReady||e.onResolverReady||e.onExecutorReady)}function isPluginExecutorWithFile(e){return`resolve`in e&&`context`in e}export{isPluginExecutorWithFile as i,getRawPluginTableName as n,hasGenerationHooks as r,getPluginGenerationDependencies as t};
2
- //# sourceMappingURL=guards-yDXyKC9F.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"guards-yDXyKC9F.mjs","names":["name","table","deps","plugin","executor"],"sources":["../src/plugin/guards.ts"],"sourcesContent":["// Runtime guards and helpers for plugin authoring types.\n//\n// These live outside plugin/types.ts (a pure type module) because they are\n// runtime functions. The types they operate on are imported type-only.\nimport type {\n DependencyKind,\n PluginGeneratedExecutor,\n PluginGeneratedExecutorWithFile,\n} from \"./types\";\n\n/**\n * Reads a table name without assuming plugin output is a valid table object.\n * @param table - Raw table value returned by a plugin hook.\n * @returns The table name when it is a string; otherwise, undefined.\n */\nexport function getRawPluginTableName(table: unknown): string | undefined {\n const name =\n typeof table === \"object\" && table !== null && \"name\" in table ? table.name : undefined;\n return typeof name === \"string\" ? name : undefined;\n}\n\n/**\n * Collects the generation-time dependency kinds a plugin requires.\n * @param plugin - The plugin object to inspect.\n * @param plugin.onTailorDBReady - Hook for TailorDB readiness.\n * @param plugin.onResolverReady - Hook for resolver readiness.\n * @param plugin.onExecutorReady - Hook for executor readiness.\n * @returns Set of dependency kinds required by the plugin.\n */\nexport function getPluginGenerationDependencies(plugin: {\n onTailorDBReady?: unknown;\n onResolverReady?: unknown;\n onExecutorReady?: unknown;\n}): Set<DependencyKind> {\n const deps = new Set<DependencyKind>();\n if (plugin.onTailorDBReady) {\n deps.add(\"tailordb\");\n }\n if (plugin.onResolverReady) {\n deps.add(\"resolver\");\n }\n if (plugin.onExecutorReady) {\n deps.add(\"executor\");\n }\n return deps;\n}\n\n/**\n * Checks if a plugin has any generation-time hooks.\n * @param plugin - The plugin object to inspect.\n * @param plugin.onTailorDBReady - Hook for TailorDB readiness.\n * @param plugin.onResolverReady - Hook for resolver readiness.\n * @param plugin.onExecutorReady - Hook for executor readiness.\n * @returns True if the plugin has at least one generation hook.\n */\nexport function hasGenerationHooks(plugin: {\n onTailorDBReady?: unknown;\n onResolverReady?: unknown;\n onExecutorReady?: unknown;\n}): boolean {\n return !!(plugin.onTailorDBReady || plugin.onResolverReady || plugin.onExecutorReady);\n}\n\n/**\n * Checks if a plugin executor uses file-based resolution.\n * @param executor - The plugin executor to check.\n * @returns True if the executor uses file-based resolution.\n */\nexport function isPluginExecutorWithFile(\n executor: PluginGeneratedExecutor,\n): executor is PluginGeneratedExecutorWithFile {\n return \"resolve\" in executor && \"context\" in executor;\n}\n"],"mappings":"AAeA,SAAgB,sBAAsB,EAAoC,CACxE,IAAMA,EACJ,OAAOC,GAAU,UAAYA,GAAkB,SAAUA,EAAQA,EAAM,KAAO,IAAA,GAChF,OAAO,OAAOD,GAAS,SAAWA,EAAO,IAAA,EAC3C,CAUA,SAAgB,gCAAgC,EAIxB,CACtB,IAAME,kBAAO,IAAI,IAUjB,OATIC,EAAO,iBACTD,EAAK,IAAI,UAAU,EAEjBC,EAAO,iBACTD,EAAK,IAAI,UAAU,EAEjBC,EAAO,iBACTD,EAAK,IAAI,UAAU,EAEdA,CACT,CAUA,SAAgB,mBAAmB,EAIvB,CACV,MAAO,CAAC,EAAEC,EAAO,iBAAmBA,EAAO,iBAAmBA,EAAO,gBACvE,CAOA,SAAgB,yBACd,EAC6C,CAC7C,MAAO,YAAaC,GAAY,YAAaA,CAC/C,C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-RgtbhJ83.mjs","names":["styleText","name","text","color","forced","stream","stripVTControlCharacters","ANSI_ESCAPE_PATTERN","CARRIAGE_RETURN_PATTERN","graphemeSegmenter","values","value","max","fallback","codePoint","char","sgrSequences","chars","segment","result","i","cell","ZERO_WIDTH_CLUSTER_PATTERN","RGI_EMOJI_PATTERN","width","eastAsianWidth","cellLine","left","columnWidths","join","right","columnCount","rows","row","index","data","rowCount","rowsCellLines","col","line","config","lineIndex","lines","rowHeight","cellLines","columnLines","cells","rowIndex","TRUTHY_VALUES","FALSY_VALUES","normalized","JSON_OUTPUT_ENV_VAR","isCI","agent","_jsonDefaultAgent","source","reason","_jsonMode","_jsonModeSource","message","styles","symbols","_verbose","_secrets","REDACTED_PLACEHOLDER","root","secret","secrets","node","ch","next","queue","head","parent","child","fail","_automaton","spans","protectedSpans","from","start","end","pStart","pEnd","a","b","merged","span","last","cursor","rendered","render","plain","redactedPlain","styled","TYPE_ICONS","TYPE_COLORS","opts","indentPrefix","indent","colorFn","type","mode","icon","coloredOutput","timestamp","inspectOpts","output","formatWithOptions","logger","sizeBefore","jsonEscaped","formEncoded","display","options","formatDistanceToNowStrict","pretty","key","transformer","item","headers","h","t","header"],"sources":["../../shared/src/color.ts","../src/cli/shared/ascii-table.ts","../src/cli/shared/parse-boolean.ts","../src/cli/shared/logger.ts"],"sourcesContent":["import { stripVTControlCharacters, styleText } from \"node:util\";\n\n/** Applies a style to text */\nexport type StyleFn = (text: string) => string;\n\ntype StyleName = Exclude<Parameters<typeof styleText>[0], readonly unknown[] | unknown[]>;\n\nconst style =\n (name: StyleName): StyleFn =>\n (text) =>\n styleText(name, text, { validateStream: false });\n\n/**\n * Style functions by name, so call sites read `color.bold(text)`. Styling is\n * always applied; `renderFor` drops it again when the destination stream has no\n * color support. Add a name here when a package needs one that is not listed.\n */\nexport const color = {\n bold: style(\"bold\"),\n dim: style(\"dim\"),\n italic: style(\"italic\"),\n gray: style(\"gray\"),\n white: style(\"white\"),\n red: style(\"red\"),\n green: style(\"green\"),\n yellow: style(\"yellow\"),\n cyan: style(\"cyan\"),\n magenta: style(\"magenta\"),\n redBright: style(\"redBright\"),\n greenBright: style(\"greenBright\"),\n cyanBright: style(\"cyanBright\"),\n};\n\n// Node's rules for whether a destination gets colors, applied by hand. Asking\n// styleText instead would be shorter but only correct on Node: Bun ignores both\n// the stream option and NO_COLOR (reproduced on 1.3.14), so it reports every\n// destination as color-capable and escapes end up in redirected output.\n//\n// FORCE_COLOR decides on its own when set, which is how CI keeps colors through\n// a pipe. NO_COLOR counts as set at any non-empty value, \"0\" included.\nconst supportsColor = (stream: NodeJS.WriteStream): boolean => {\n const forced = process.env.FORCE_COLOR;\n if (forced !== undefined) return forced !== \"0\" && forced !== \"false\";\n if (process.env.NODE_DISABLE_COLORS !== undefined) return false;\n if ((process.env.NO_COLOR ?? \"\") !== \"\") return false;\n if (process.env.TERM === \"dumb\") return false;\n return stream.isTTY === true;\n};\n\n/**\n * Prepares styled text for the stream it is written to.\n * @param stream - Stream the text is written to\n * @param text - Styled text\n * @returns Text with styling removed when the stream has no color support\n */\nexport function renderFor(stream: NodeJS.WriteStream, text: string): string {\n return supportsColor(stream) ? text : stripVTControlCharacters(text);\n}\n","import { eastAsianWidth } from \"get-east-asian-width\";\n\n// eslint-disable-next-line no-control-regex\nconst ANSI_ESCAPE_PATTERN = /\\x1b\\[[0-9;]*m/g;\nconst CARRIAGE_RETURN_PATTERN = /\\r\\n?/g;\n\nconst graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\n\nexport interface AsciiTableConfig {\n /** Suppress horizontal lines between rows, keeping only the outer border. */\n singleLine?: boolean;\n /** Decide whether to draw the horizontal line at `lineIndex` (range `[0, rowCount]` inclusive). */\n drawHorizontalLine?: (lineIndex: number, rowCount: number) => boolean;\n}\n\ninterface CellLine {\n text: string;\n width: number;\n}\n\nfunction maxOf(values: number[], fallback = 0): number {\n return values.reduce((max, value) => (value > max ? value : max), fallback);\n}\n\nconst TAB_WIDTH = 8;\n\nfunction isStrippableControlCharacter(char: string): boolean {\n const codePoint = char.codePointAt(0) ?? 0;\n if (char === \"\\n\") {\n return false;\n }\n return codePoint <= 0x1f || codePoint === 0x7f;\n}\n\n// Only SGR (color/style) escape sequences are meant to survive; a bare ESC\n// that isn't part of a recognized SGR sequence (e.g. a screen-clear CSI\n// sequence, or a BEL-terminated OSC sequence) is treated like any other\n// control character below and stripped, rather than passed through to the\n// terminal or left with its terminator removed.\nfunction normalizeControlCharacters(value: string): string {\n const sgrSequences = value.match(ANSI_ESCAPE_PATTERN) ?? [];\n return value\n .split(ANSI_ESCAPE_PATTERN)\n .map((segment) => {\n const chars: string[] = [];\n for (const char of segment) {\n if (char === \"\\t\") {\n chars.push(\" \".repeat(TAB_WIDTH));\n } else if (!isStrippableControlCharacter(char)) {\n chars.push(char);\n }\n }\n return chars.join(\"\");\n })\n .reduce((result, segment, i) => result + segment + (sgrSequences[i] ?? \"\"), \"\");\n}\n\nfunction sanitizeCell(cell: unknown): string {\n return normalizeControlCharacters(String(cell ?? \"\").replace(CARRIAGE_RETURN_PATTERN, \"\\n\"));\n}\n\n// Clusters made up entirely of non-printing code points (lone joiners,\n// variation selectors, combining marks, etc.) render with no visible glyph.\nconst ZERO_WIDTH_CLUSTER_PATTERN =\n /^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Nonspacing_Mark}|\\p{Enclosing_Mark}|\\p{Surrogate})+$/v;\n// RGI_Emoji covers flags, keycaps, and VS16-forced presentation sequences,\n// which render as 2 columns in terminals even though their first code point\n// alone would measure as narrow/neutral.\nconst RGI_EMOJI_PATTERN = /^\\p{RGI_Emoji}$/v;\n\nfunction displayWidth(value: string): number {\n let width = 0;\n for (const { segment } of graphemeSegmenter.segment(value.replace(ANSI_ESCAPE_PATTERN, \"\"))) {\n if (ZERO_WIDTH_CLUSTER_PATTERN.test(segment)) {\n continue;\n }\n if (RGI_EMOJI_PATTERN.test(segment)) {\n width += 2;\n continue;\n }\n const codePoint = segment.codePointAt(0);\n width += codePoint === undefined ? 0 : eastAsianWidth(codePoint);\n }\n return width;\n}\n\nfunction toCellLines(cell: string): CellLine[] {\n return cell.split(\"\\n\").map((text) => ({ text, width: displayWidth(text) }));\n}\n\nfunction padCell(cellLine: CellLine, width: number): string {\n return cellLine.text + \" \".repeat(Math.max(0, width - cellLine.width));\n}\n\nfunction renderBorder(left: string, join: string, right: string, columnWidths: number[]): string {\n return left + columnWidths.map((width) => \"─\".repeat(width + 2)).join(join) + right;\n}\n\nfunction validateConsistentColumnCount(rows: string[][]): void {\n const columnCount = rows[0]?.length;\n if (columnCount === undefined) {\n return;\n }\n rows.forEach((row, index) => {\n if (row.length !== columnCount) {\n throw new Error(\n `renderTable: all rows must have the same number of columns (expected ${columnCount}, row ${index} has ${row.length}).`,\n );\n }\n });\n}\n\n/**\n * Renders a 2D array of values as a table using single-line Unicode box-drawing borders.\n * Column widths account for East Asian wide characters (measured per grapheme cluster,\n * so combining marks and ZWJ emoji sequences aren't overcounted, non-printing clusters\n * such as a lone joiner or combining mark measure as 0, and flags, keycaps, and\n * VS16-forced emoji presentation are measured as 2 columns) and strip ANSI SGR (color/style)\n * escape codes before measuring. Use this instead of importing a table-rendering package\n * directly.\n * @param data - Table rows; every row must have the same number of columns. Each cell is\n * stringified (`null`/`undefined` become an empty string rather than the literal text\n * \"null\"/\"undefined\"), may contain embedded newlines, has `\\r`/`\\r\\n` normalized to `\\n`,\n * has tabs expanded to spaces, and has other control characters stripped.\n * @param config - Rendering options\n * @returns The rendered table terminated with a trailing newline, or `\"\"` when there are no\n * rows or no columns to display\n */\nexport function renderTable(data: unknown[][], config: AsciiTableConfig = {}): string {\n const rows = data.map((row) => row.map(sanitizeCell));\n validateConsistentColumnCount(rows);\n\n const rowCount = rows.length;\n const columnCount = rows[0]?.length ?? 0;\n if (rowCount === 0 || columnCount === 0) {\n return \"\";\n }\n\n const rowsCellLines = rows.map((row) =>\n Array.from({ length: columnCount }, (_, col) => toCellLines(row[col] ?? \"\")),\n );\n const columnWidths = Array.from({ length: columnCount }, (_, col) =>\n maxOf(rowsCellLines.map((row) => maxOf((row[col] ?? []).map((line) => line.width)))),\n );\n\n const shouldDrawLine = (lineIndex: number): boolean =>\n config.singleLine\n ? lineIndex === 0 || lineIndex === rowCount\n : (config.drawHorizontalLine ?? (() => true))(lineIndex, rowCount);\n\n const lines: string[] = [];\n if (shouldDrawLine(0)) {\n lines.push(renderBorder(\"┌\", \"┬\", \"┐\", columnWidths));\n }\n\n rowsCellLines.forEach((cellLines, rowIndex) => {\n const rowHeight = maxOf(\n cellLines.map((columnLines) => columnLines.length),\n 1,\n );\n for (let line = 0; line < rowHeight; line++) {\n const cells = cellLines.map((columnLines, col) =>\n padCell(columnLines[line] ?? { text: \"\", width: 0 }, columnWidths[col] ?? 0),\n );\n lines.push(`│ ${cells.join(\" │ \")} │`);\n }\n if (rowIndex < rowCount - 1 && shouldDrawLine(rowIndex + 1)) {\n lines.push(renderBorder(\"├\", \"┼\", \"┤\", columnWidths));\n }\n });\n\n if (shouldDrawLine(rowCount)) {\n lines.push(renderBorder(\"└\", \"┴\", \"┘\", columnWidths));\n }\n\n return `${lines.join(\"\\n\")}\\n`;\n}\n","const TRUTHY_VALUES = new Set([\"true\", \"t\", \"yes\", \"y\", \"on\", \"1\"]);\nconst FALSY_VALUES = new Set([\"false\", \"f\", \"no\", \"n\", \"off\", \"0\"]);\n\n/**\n * Parse a string value as a boolean.\n *\n * Recognized values (case-insensitive, trimmed) follow Python's\n * `distutils.util.strtobool` convention:\n * - truthy: `true, t, yes, y, on, 1`\n * - falsy: `false, f, no, n, off, 0`\n *\n * Undefined, empty strings, and unrecognized values return `undefined` so\n * that callers can fall back to their own defaults.\n * @param value - The input string (e.g. an environment variable or CLI flag value)\n * @returns `true`, `false`, or `undefined` when the value is unset or unrecognized\n */\nexport function parseBoolean(value: string | undefined): boolean | undefined {\n if (value === undefined) return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized === \"\") return undefined;\n if (TRUTHY_VALUES.has(normalized)) return true;\n if (FALSY_VALUES.has(normalized)) return false;\n return undefined;\n}\n","import { formatWithOptions, stripVTControlCharacters, type InspectOptions } from \"node:util\";\nimport { color, renderFor } from \"@tailor-platform/shared/color\";\nimport { formatDistanceToNowStrict } from \"date-fns\";\nimport { isCI } from \"std-env\";\nimport { renderTable } from \"./ascii-table\";\nimport { parseBoolean } from \"./parse-boolean\";\n\n/** Environment variable selecting JSON as the default output for every command. */\nexport const JSON_OUTPUT_ENV_VAR = \"TAILOR_JSON_OUTPUT\";\n\n/**\n * Whether the process is attached to an interactive terminal outside CI.\n * @returns True when both stdin and stdout are TTYs and CI is not detected\n */\nexport function interactiveTerminal(): boolean {\n return !isCI && process.stdin.isTTY === true && process.stdout.isTTY === true;\n}\n\n/**\n * What selected JSON output: an explicit `--json`, the environment, both, or\n * the AI coding agent running the CLI.\n */\nexport type JsonModeSource = \"flag\" | \"env\" | \"both\" | \"agent\";\n\n/**\n * Explain what selected JSON output and how to turn it off. Under an AI coding\n * agent, dropping `--json` or unsetting the variable falls back to JSON again,\n * so the remedy names the explicit `false` values instead.\n * @param source - What selected JSON output\n * @returns Sentence appended to the prompt refusal\n */\nfunction jsonModeRemedy(source: JsonModeSource): string {\n const agent = _jsonDefaultAgent;\n switch (source) {\n case \"agent\":\n return ` JSON output is enabled because an AI coding agent${agent ? ` (${agent})` : \"\"} was detected; pass --json=false or set ${JSON_OUTPUT_ENV_VAR}=false to restore prompts.`;\n case \"flag\":\n return agent\n ? \" JSON output is enabled by --json; pass --json=false instead to restore prompts.\"\n : \" JSON output is enabled by --json; drop it to restore prompts.\";\n case \"env\":\n return agent\n ? ` JSON output is enabled by ${JSON_OUTPUT_ENV_VAR}; set it to false to restore prompts.`\n : ` JSON output is enabled by ${JSON_OUTPUT_ENV_VAR}; unset it to restore prompts.`;\n case \"both\":\n return agent\n ? ` JSON output is enabled by --json and ${JSON_OUTPUT_ENV_VAR}; pass --json=false instead of the flag to restore prompts.`\n : ` JSON output is enabled by --json and ${JSON_OUTPUT_ENV_VAR}; drop the flag and unset the variable to restore prompts.`;\n }\n}\n\n/**\n * Error thrown when a prompt is attempted in a non-interactive environment.\n *\n * JSON mode suppresses prompts, so name whatever selected it: an explicit\n * `--json` stays enabled however the environment is set, while\n * `TAILOR_JSON_OUTPUT` or a detected AI coding agent leaves nothing in the\n * command line to explain the refusal.\n */\nexport class CIPromptError extends Error {\n constructor(message?: string) {\n const reason =\n _jsonMode && _jsonModeSource !== undefined && interactiveTerminal()\n ? jsonModeRemedy(_jsonModeSource)\n : \"\";\n super(\n (message ??\n \"Interactive prompts are not available in this environment. Provide the required options explicitly.\") +\n reason,\n );\n this.name = \"CIPromptError\";\n }\n}\n\n/**\n * Semantic style functions for inline text styling\n */\nexport const styles = {\n // Status colors\n success: color.green,\n error: color.red,\n warning: color.yellow,\n info: color.cyan,\n\n // Action colors (for change sets)\n create: color.green,\n update: color.yellow,\n delete: color.red,\n replace: color.magenta,\n unchanged: color.gray,\n\n // Emphasis\n bold: color.bold,\n dim: color.gray,\n highlight: color.cyanBright,\n successBright: color.greenBright,\n errorBright: color.redBright,\n\n // Resource types\n resourceType: color.bold,\n resourceName: color.cyan,\n\n // File paths\n path: color.cyan,\n\n // Values\n value: color.white,\n placeholder: (text: string) => color.italic(color.gray(text)),\n};\n\n/**\n * Standardized symbols for CLI output\n */\nexport const symbols = {\n success: styles.success(\"\\u2713\"),\n error: styles.error(\"\\u2716\"),\n warning: styles.warning(\"\\u26a0\"),\n info: styles.info(\"i\"),\n create: styles.create(\"+\"),\n update: styles.update(\"~\"),\n delete: styles.delete(\"-\"),\n replace: styles.replace(\"\\u00b1\"),\n bullet: styles.dim(\"\\u2022\"),\n arrow: styles.dim(\"\\u2192\"),\n};\n\n/**\n * Log output modes\n */\nexport type LogMode = \"default\" | \"stream\" | \"plain\";\n\nexport interface LogOptions {\n /** Output mode (default: \"default\") */\n mode?: LogMode;\n /** Number of spaces to indent the entire line (default: 0) */\n indent?: number;\n}\n\n/** Field transformer function. null excludes the field from table output. */\nexport type FieldTransformer = ((value: unknown, item: object) => string) | null;\n\nexport interface OutOptions {\n /** Table display field transform/exclude settings. Only applied in table mode (not JSON). */\n display?: Record<string, FieldTransformer>;\n\n /** Show null values in table output (default: false) */\n showNull?: boolean;\n}\n\n// In JSON mode, all logs go to stderr to keep stdout clean for JSON data\nlet _jsonMode = false;\nlet _jsonModeSource: JsonModeSource | undefined;\nlet _jsonDefaultAgent: string | undefined;\nlet _verbose = false;\n\n// Values registered via `logger.registerSecret()`, redacted from diagnostic log output\nconst _secrets = new Set<string>();\nconst REDACTED_PLACEHOLDER = \"<redacted>\";\n// Below this length, a registered value is too likely to match unrelated text.\nconst MIN_SECRET_LENGTH = 4;\n\n/**\n * Aho-Corasick trie node. Indexed by individual UTF-16 code units (not Unicode code\n * points), matching how `string.indexOf`/`.slice` already index this file's strings — a\n * surrogate-pair character occupies two nodes, same as it occupies two `string` indices.\n */\ninterface TrieNode {\n children: Map<string, TrieNode>;\n fail: TrieNode;\n /** Secrets ending at this node, including those reached via `fail` links (precomputed). */\n outputs: string[];\n}\n\n/**\n * Builds a multi-pattern matcher for every registered secret, so `findSecretSpans` below\n * can find all of their occurrences in one pass over the text (`O(text.length + matches)`)\n * instead of scanning the full text once per registered secret. Rebuilt only when\n * `registerSecret` adds a genuinely new value (see `_automaton` below), so its\n * `O(total secret length)` construction cost is amortized across every log line redacted\n * while the secret set doesn't change.\n * @param secrets - Currently registered secrets\n * @returns Root of the built trie\n */\nfunction buildAutomaton(secrets: ReadonlySet<string>): TrieNode {\n const root: TrieNode = {\n children: new Map(),\n fail: undefined as unknown as TrieNode,\n outputs: [],\n };\n root.fail = root;\n\n for (const secret of secrets) {\n let node = root;\n for (let i = 0; i < secret.length; i++) {\n const ch = secret[i] as string;\n let next = node.children.get(ch);\n if (!next) {\n next = { children: new Map(), fail: root, outputs: [] };\n node.children.set(ch, next);\n }\n node = next;\n }\n node.outputs.push(secret);\n }\n\n // A head index instead of Array#shift(): shift() re-indexes every remaining element on\n // each call, which would make this loop quadratic in the number of trie nodes rather than\n // the linear BFS this is meant to be.\n const queue: TrieNode[] = [...root.children.values()];\n for (let head = 0; head < queue.length; head++) {\n const parent = queue[head] as TrieNode;\n for (const [ch, child] of parent.children) {\n let fail = parent.fail;\n while (fail !== root && !fail.children.has(ch)) fail = fail.fail;\n child.fail = fail.children.get(ch) ?? root;\n child.outputs = child.outputs.concat(child.fail.outputs);\n queue.push(child);\n }\n }\n return root;\n}\n\n// Cached automaton for the current `_secrets` contents; `null` means rebuild on next use.\n// Invalidated only when `registerSecret` actually grows `_secrets` (Set#add on an existing\n// value is a no-op), so re-registering an already-known secret never triggers a rebuild.\nlet _automaton: TrieNode | null = null;\n\nfunction getAutomaton(): TrieNode {\n _automaton ??= buildAutomaton(_secrets);\n return _automaton;\n}\n\n/**\n * Finds every occurrence of every registered secret in `text`, including overlapping ones,\n * in a single pass over `text` via the Aho-Corasick automaton.\n * @param text - Text to search\n * @returns Match spans as `[start, end)` pairs, in the order found\n */\nfunction findSecretSpans(text: string): Array<[start: number, end: number]> {\n const spans: Array<[start: number, end: number]> = [];\n const root = getAutomaton();\n let node = root;\n for (let i = 0; i < text.length; i++) {\n const ch = text[i] as string;\n while (node !== root && !node.children.has(ch)) node = node.fail;\n node = node.children.get(ch) ?? root;\n for (const secret of node.outputs) {\n spans.push([i + 1 - secret.length, i + 1]);\n }\n }\n return spans;\n}\n\n/**\n * Redacts every registered secret from `text` in a single pass over the original text.\n *\n * Matches are found against the original text only - never against text a previous\n * replacement produced - and overlapping/adjacent matches (whether one secret contains\n * another, or two secrets merely cross, e.g. registering \"abcde\" and \"defghi\" against\n * \"abcdefghi\") are merged into one contiguous span before any substitution happens. This\n * avoids two failure modes an iterative \"replace one secret, then the next\" approach has:\n * a later secret re-matching inside a placeholder a previous replacement already inserted,\n * and a crossing (non-nested) overlap leaving a fragment of one secret unredacted.\n *\n * Idempotent: a match that falls inside an occurrence of `<redacted>` already present in\n * `text` is discarded rather than substituted again. Without this, calling this function\n * twice on the same text (which happens whenever something already redacted, such as a\n * `--json` error envelope, is later passed to a diagnostic log call) could corrupt the\n * placeholder itself if a registered secret happens to be one of its substrings (e.g. a\n * secret literally containing \"redact\").\n * @param text - Text to redact\n * @returns `text` with every registered secret occurrence replaced by `<redacted>`\n */\nexport function redactSecrets(text: string): string {\n if (_secrets.size === 0) return text;\n\n const protectedSpans: Array<[start: number, end: number]> = [];\n for (let from = 0, index: number; (index = text.indexOf(REDACTED_PLACEHOLDER, from)) !== -1;) {\n protectedSpans.push([index, index + REDACTED_PLACEHOLDER.length]);\n from = index + REDACTED_PLACEHOLDER.length;\n }\n\n // Only a match wholly inside a protected placeholder is discarded (it can only be the\n // placeholder's own text, e.g. a registered secret that is a substring of \"redacted\").\n // A match that merely overlaps one — extending outside it, e.g. a registered secret that\n // happens to be \"leak<redacted>\" — still has real secret content outside the placeholder\n // and must still be replaced.\n //\n // A registered secret wholly contained in the placeholder (up to and including a secret\n // equal to \"<redacted>\" itself) is indistinguishable from the placeholder in rendered\n // output either way: substituting REDACTED_PLACEHOLDER for text that already reads\n // REDACTED_PLACEHOLDER is a no-op. Discarding the match here (rather than \"fixing\" it to\n // substitute anyway) isn't a redaction gap — it just skips redundant work on text that's\n // already the safe, masked form.\n const spans = findSecretSpans(text).filter(\n ([start, end]) => !protectedSpans.some(([pStart, pEnd]) => start >= pStart && end <= pEnd),\n );\n if (spans.length === 0) return text;\n spans.sort(([a], [b]) => a - b);\n\n const merged: Array<[start: number, end: number]> = [];\n for (const span of spans) {\n const last = merged.at(-1);\n if (last && span[0] <= last[1]) {\n last[1] = Math.max(last[1], span[1]);\n } else {\n merged.push(span);\n }\n }\n\n let result = \"\";\n let cursor = 0;\n for (const [start, end] of merged) {\n result += text.slice(cursor, start) + REDACTED_PLACEHOLDER;\n cursor = end;\n }\n return result + text.slice(cursor);\n}\n\n/**\n * Renders styled text with registered secrets redacted.\n *\n * Redacts the styled text first, so a secret that itself contains a control sequence\n * matches its raw form, then checks the text again without colors, so inline colors\n * cannot split a secret out of a match. When they do, the text is returned without\n * colors, since redacting around the escapes would leave fragments of the secret visible.\n * @param text - Styled text\n * @param render - Removes styling from `text`, or keeps it\n * @returns Rendered text with registered secrets redacted\n */\nfunction renderWithRedaction(text: string, render: (text: string) => string): string {\n const rendered = render(redactSecrets(text));\n const plain = stripVTControlCharacters(rendered);\n const redactedPlain = redactSecrets(plain);\n return redactedPlain === plain ? rendered : redactedPlain;\n}\n\n/**\n * Prepares styled diagnostic text for the stream it is written to, with registered\n * secrets redacted.\n * @param stream - Stream the text is written to\n * @param text - Styled text\n * @returns Text with styling removed when the stream has no color support, and registered secrets redacted\n */\nexport function renderRedacted(stream: NodeJS.WriteStream, text: string): string {\n return renderWithRedaction(text, (styled) => renderFor(stream, styled));\n}\n\n/**\n * Removes styling from text, with registered secrets redacted.\n * @param text - Styled text\n * @returns Plain text with registered secrets redacted\n */\nexport function plainRedacted(text: string): string {\n return renderWithRedaction(text, stripVTControlCharacters);\n}\n\n/**\n * Reset the registered-secret redaction state. Used for testing.\n *\n * `_secrets` is process-lifetime, module-level state with no production unregister API\n * (a real process should never stop hiding a secret it once saw). Test files that call\n * `logger.registerSecret()` and run in a Vitest project with `isolate: false` share this\n * state across files, so a value registered in one file's test can still be redacted in an\n * unrelated later file's assertions unless cleared between tests.\n */\nexport function resetSecretRegistry(): void {\n _secrets.clear();\n _automaton = null;\n}\n\n// Type icons for log output\nconst TYPE_ICONS: Record<string, string> = {\n info: \"ℹ\",\n success: \"✔\",\n warn: \"⚠\",\n error: \"✖\",\n debug: \"⚙\",\n trace: \"→\",\n log: \"\",\n};\n\n// Color functions for icon and message text\nconst TYPE_COLORS: Record<string, (text: string) => string> = {\n info: styles.info,\n success: styles.success,\n warn: styles.warning,\n error: styles.error,\n debug: styles.dim,\n trace: styles.dim,\n log: (text) => text,\n};\n\ninterface FormatLogLineOptions {\n mode: string;\n indent: number;\n type: string;\n message: string;\n timestamp?: string;\n}\n\n/**\n * Formats a log line with the appropriate prefix and indentation\n * @param opts - Formatting options\n * @returns Formatted log line\n */\nexport function formatLogLine(opts: FormatLogLineOptions): string {\n const { mode, indent, type, message, timestamp } = opts;\n const indentPrefix = indent > 0 ? \" \".repeat(indent) : \"\";\n const colorFn = TYPE_COLORS[type] || ((text: string) => text);\n\n // Plain mode: color only, no icon, no timestamp\n if (mode === \"plain\") {\n return `${indentPrefix}${colorFn(message)}\\n`;\n }\n\n // Default/Stream mode: with icon and color\n const icon = TYPE_ICONS[type] || \"\";\n const prefix = icon ? `${icon} ` : \"\";\n const coloredOutput = colorFn(`${prefix}${message}`);\n const timestampPrefix = timestamp ?? \"\";\n\n return `${indentPrefix}${timestampPrefix}${coloredOutput}\\n`;\n}\n\n/**\n * Writes a formatted log line to stderr.\n * @param type - Log type (info, success, warn, error, log)\n * @param message - Log message\n * @param opts - Log options (mode and indent)\n */\nfunction writeLog(type: string, message: string, opts?: LogOptions): void {\n const mode = opts?.mode ?? \"default\";\n const indent = opts?.indent ?? 0;\n const inspectOpts: InspectOptions = {\n breakLength: process.stdout.columns || 80,\n };\n const formattedMessage = formatWithOptions(inspectOpts, message);\n const timestamp = mode === \"stream\" ? `${new Date().toLocaleTimeString()} ` : \"\";\n const output = formatLogLine({ mode, indent, type, message: formattedMessage, timestamp });\n process.stderr.write(renderRedacted(process.stderr, output));\n}\n\n/**\n * Record the AI coding agent running the Tailor CLI, which makes JSON the\n * default output. CLI plugins never record one, so they keep table output.\n * @param agent - Detected agent id (e.g. `\"claude_code\"`), or undefined when none runs the CLI\n */\nexport function setJsonDefaultAgent(agent: string | undefined): void {\n _jsonDefaultAgent = agent;\n}\n\n/**\n * The AI coding agent recorded by {@link setJsonDefaultAgent}.\n * @returns Detected agent id, or undefined when none was recorded\n */\nexport function jsonDefaultAgent(): string | undefined {\n return _jsonDefaultAgent;\n}\n\n/**\n * The CLI logger. Diagnostics go to stderr; `out()` writes primary output to\n * stdout as a table, or as JSON when `jsonMode` is on. `--json` and\n * `--verbose` feed the `jsonMode` / `verbose` state, which CLI plugins share\n * with the SDK code paths they call.\n */\nexport const logger = {\n get jsonMode(): boolean {\n return _jsonMode;\n },\n set jsonMode(value: boolean) {\n _jsonMode = value;\n if (!value) _jsonModeSource = undefined;\n },\n\n /**\n * Enable or disable JSON mode, recording what selected it so a suppressed\n * prompt can name the right remedy.\n * @param value - Whether JSON output is on\n * @param source - What turned it on; omit when turning it off\n */\n setJsonMode(value: boolean, source?: JsonModeSource): void {\n _jsonMode = value;\n _jsonModeSource = value ? source : undefined;\n },\n\n get verbose(): boolean {\n return _verbose || parseBoolean(process.env.DEBUG) === true || process.env.RUNNER_DEBUG === \"1\";\n },\n set verbose(value: boolean) {\n _verbose = value;\n },\n\n info(message: string, opts?: LogOptions): void {\n writeLog(\"info\", message, opts);\n },\n\n success(message: string, opts?: LogOptions): void {\n writeLog(\"success\", message, opts);\n },\n\n warn(message: string, opts?: LogOptions): void {\n writeLog(\"warn\", message, opts);\n },\n\n error(message: string, opts?: LogOptions): void {\n writeLog(\"error\", message, opts);\n },\n\n log(message: string): void {\n writeLog(\"log\", message, { mode: \"plain\" });\n },\n\n newline(): void {\n process.stderr.write(\"\\n\");\n },\n\n debug(message: string): void {\n if (logger.verbose) {\n writeLog(\"log\", styles.dim(message), { mode: \"plain\" });\n }\n },\n\n /**\n * Registers a value to be redacted from diagnostic log output (`info`/`success`/`warn`/\n * `error`/`log`/`debug`). Any occurrence of `value` — or of its JSON-string-escaped form\n * (so a value embedded in `JSON.stringify`d output, e.g. `--json` mode error envelopes, is\n * also caught) or its `application/x-www-form-urlencoded` form (so a value that reached the\n * process via a URL query string, e.g. an OAuth authorization code decoded from a callback\n * URL via `URLSearchParams`, is still caught if that same URL — still encoded — is later\n * echoed into a diagnostic message) — is replaced with `<redacted>` before it reaches\n * stderr. Does not affect `out()`, since some commands intentionally print secret values as\n * their primary result.\n *\n * Values shorter than 4 characters are ignored, since they are too likely to match\n * unrelated text. A non-string value (e.g. `undefined` from an unvalidated external\n * payload cast to a typed shape) is ignored the same way, rather than throwing, since a\n * logging call must never be what crashes the process.\n * @param value - The secret value to redact from future log output\n */\n registerSecret(value: string): void {\n // Counts Unicode code points, not UTF-16 code units, so a value made of surrogate-pair\n // characters (e.g. emoji) isn't undercounted as longer than it actually is.\n if (typeof value !== \"string\" || [...value].length < MIN_SECRET_LENGTH) return;\n const sizeBefore = _secrets.size;\n _secrets.add(value);\n const jsonEscaped = JSON.stringify(value).slice(1, -1);\n if (jsonEscaped !== value) _secrets.add(jsonEscaped);\n // Uses URLSearchParams rather than encodeURIComponent: form-urlencoding (what\n // URLSearchParams produces, and what a URL query string actually contains) encodes a\n // space as \"+\", not \"%20\", and unlike encodeURIComponent it never throws on a lone\n // surrogate (invalid UTF-16) — it substitutes U+FFFD instead, matching how the URL\n // itself would already have encoded that same malformed input.\n const formEncoded = new URLSearchParams([[\"v\", value]]).toString().slice(2);\n if (formEncoded !== value) _secrets.add(formEncoded);\n // Set#add on an already-registered value is a no-op, so this only invalidates the\n // cached automaton (see findSecretSpans) when a genuinely new secret was added.\n if (_secrets.size !== sizeBefore) _automaton = null;\n },\n\n out(data: string | object | object[], options?: OutOptions): void {\n if (typeof data === \"string\") {\n process.stdout.write(renderFor(process.stdout, data.endsWith(\"\\n\") ? data : data + \"\\n\"));\n return;\n }\n\n if (this.jsonMode) {\n // eslint-disable-next-line no-restricted-syntax\n console.log(JSON.stringify(data));\n return;\n }\n\n const display = options?.display;\n\n // Helper to format a value for table display\n const formatValue = (value: unknown, pretty = false): string => {\n if (options?.showNull && value === null) return \"NULL\";\n if (value === null || value === undefined) return \"N/A\";\n if (value instanceof Date) {\n return formatDistanceToNowStrict(value, { addSuffix: true });\n }\n if (typeof value === \"object\") {\n return pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);\n }\n return String(value);\n };\n\n // Helper to check if field should be excluded\n const isExcluded = (key: string): boolean => {\n return display !== undefined && key in display && display[key] === null;\n };\n\n // Helper to apply transformer or default formatting\n const transformValue = (key: string, value: unknown, item: object, pretty = false): string => {\n if (display && key in display) {\n const transformer = display[key];\n if (transformer) {\n return transformer(value, item);\n }\n }\n return formatValue(value, pretty);\n };\n\n if (!Array.isArray(data)) {\n const entries = Object.entries(data).filter(([key]) => !isExcluded(key));\n const formattedEntries = entries.map(([key, value]) => [\n key,\n transformValue(key, value, data, true),\n ]);\n const t = renderTable(formattedEntries, { singleLine: false });\n process.stdout.write(renderFor(process.stdout, t));\n return;\n }\n\n if (data.length === 0) {\n return;\n }\n\n const allHeaders = Array.from(new Set(data.flatMap((item) => Object.keys(item))));\n const headers = allHeaders.filter((h) => !isExcluded(h));\n if (headers.length === 0) {\n return;\n }\n const rows = data.map((item) =>\n headers.map((header) =>\n transformValue(header, (item as Record<string, unknown>)[header], item),\n ),\n );\n\n const t = renderTable([headers, ...rows], {\n drawHorizontalLine: (lineIndex, rowCount) => {\n return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;\n },\n });\n process.stdout.write(renderFor(process.stdout, t));\n },\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AAW,EAClB,OAIF,IAAMqF,EADa,MAAM,KAAK,IAAI,IAAIrF,EAAK,QAAS,GAAS,OAAO,KAAKoF,CAAI,CAAC,CAAC,CACtD,CAAC,CAAC,OAAQ,GAAM,CAAC,WAAWE,CAAC,CAAC,EACvD,GAAID,EAAQ,SAAW,EACrB,OAQF,IAAME,EAAI,YAAY,CAACF,EAAS,GANnBrF,EAAK,IAAK,GACrBqF,EAAQ,IAAK,GACX,eAAeG,EAASJ,EAAiCI,GAASJ,CAAI,CACxE,CAGiC,CAAI,EAAG,CACxC,oBAAqB,EAAW,IACvB9E,IAAc,GAAKA,IAAc,GAAKA,IAAcL,CAE/D,CAAC,EACD,QAAQ,OAAO,MAAM,UAAU,QAAQ,OAAQsF,CAAC,CAAC,CACnD,CACF,E"}
@@ -1,2 +0,0 @@
1
- import{t as e}from"./schema-B6hJQWp6.mjs";import{t}from"./assert-WeXvmG4j.mjs";import{n,r,t as i}from"./guards-yDXyKC9F.mjs";var PluginManager=class{plugins=/* @__PURE__ */ new Map;generatedExecutors=[];generatedTables=[];generatedResolvers=[];processedResolverNamespaces=/* @__PURE__ */ new Set;namespaceGeneratedTableKeys=/* @__PURE__ */ new Set;namespaceGeneratedExecutorKeys=/* @__PURE__ */ new Set;pluginExecutorFiles=[];constructor(e=[]){for(let t of e){if(this.plugins.has(t.id))throw Error(`Duplicate plugin ID "${t.id}" detected. Each plugin must have a unique ID.`);this.plugins.set(t.id,t)}}async processAttachment(e){let n=this.plugins.get(e.pluginId);if(!n)return{success:!1,error:`Plugin "${e.pluginId}" not found`};let r=n.tableConfigRequired;if((typeof r==`function`?r(n.pluginConfig):r===!0)&&(e.tableConfig===void 0||e.tableConfig===null))return{success:!1,error:`Plugin "${n.id}" requires tableConfig, but none was provided for table "${e.table.name}".`};if(!n.onTableLoaded)return{success:!1,error:`Plugin "${n.id}" does not support table-attached processing (missing onTableLoaded method). Use onNamespaceLoaded via definePlugins() instead.`};let i;try{i=await n.onTableLoaded({table:e.table,tableConfig:e.tableConfig,pluginConfig:n.pluginConfig,namespace:e.namespace})}catch(t){let r=t instanceof Error?t.message:String(t);return{success:!1,error:`Plugin "${n.id}" threw an error while processing table "${e.table.name}": ${r}`}}for(let t of i.resolvers??[])this.generatedResolvers.push({resolver:t,pluginId:n.id,namespace:e.namespace,sourceTableName:e.table.name});if(i.tables&&Object.keys(i.tables).length>0){let r=t(n.importPath,`plugin "${n.id}" missing importPath`);for(let[t,a]of Object.entries(i.tables))this.generatedTables.push({pluginId:e.pluginId,pluginImportPath:r,sourceTableName:e.table.name,kind:t,table:a,namespace:e.namespace,pluginConfig:n.pluginConfig})}if(i.executors&&i.executors.length>0)for(let t of i.executors)this.generatedExecutors.push({executor:t,pluginId:e.pluginId,namespace:e.namespace,sourceTableName:e.table.name});return{success:!0,output:i}}async processNamespacePlugins(e){let r=[];for(let[i,a]of this.plugins){if(!a.onNamespaceLoaded)continue;let o=a.pluginConfig,s={pluginConfig:o,namespace:e},c;try{c=await a.onNamespaceLoaded(s)}catch(t){let n=t instanceof Error?t.message:String(t);r.push({pluginId:i,config:o,result:{success:!1,error:`Plugin "${a.id}" threw an error during namespace processing for "${e}": ${n}`}});continue}let l=JSON.stringify([i,e]);if(!this.processedResolverNamespaces.has(l)){for(let t of c.resolvers??[])this.generatedResolvers.push({resolver:t,pluginId:i,namespace:e});this.processedResolverNamespaces.add(l)}if(c.executors&&c.executors.length>0)for(let t of c.executors){let n=`${i}:${t.name}`;this.namespaceGeneratedExecutorKeys.has(n)||(this.namespaceGeneratedExecutorKeys.add(n),this.generatedExecutors.push({executor:t,pluginId:i,namespace:e}))}if(c.tables&&Object.keys(c.tables).length>0){let r=t(a.importPath,`plugin "${a.id}" missing importPath`);for(let[t,o]of Object.entries(c.tables)){let s=`${i}:${t}:${n(o)??``}`;this.namespaceGeneratedTableKeys.has(s)||(this.namespaceGeneratedTableKeys.add(s),this.generatedTables.push({pluginId:i,pluginImportPath:r,sourceTableName:`(namespace)`,kind:t,table:o,namespace:e,pluginConfig:a.pluginConfig}))}}r.push({pluginId:i,config:o,result:{success:!0,output:c}})}return r}async processAttachmentsForTable(e){let{rawTable:t,attachments:r,namespace:i}=e,a=t,o,s=[],c=[];for(let e of r){let t=await this.processAttachment({table:a,tableConfig:e.config,namespace:i,pluginId:e.pluginId});if(!t.success)throw Error(t.error);let r=t.output,l=r.extends?.fields;l&&Object.keys(l).length>0&&(a=this.extendTable({originalTable:a,extendFields:l,pluginId:e.pluginId}),o=a,c.push({kind:`extended`,tableName:a.name,fieldCount:Object.keys(l).length,pluginId:e.pluginId}));let u=this.getPlugin(e.pluginId);for(let[t,i]of Object.entries(r.tables??{})){let r=n(i)??``;s.push({tableName:r,table:i,kind:t,pluginId:e.pluginId,pluginImportPath:this.getPluginImportPath(e.pluginId)??``,pluginConfig:u?.pluginConfig}),c.push({kind:`generated`,tableName:r,pluginId:e.pluginId})}}return{extendedTable:o,generatedTables:s,events:c}}getNamespacePluginIds(){return Array.from(this.plugins.entries()).filter(([,e])=>e.onNamespaceLoaded!==void 0).map(([e])=>e)}get pluginCount(){return this.plugins.size}getPlugin(e){return this.plugins.get(e)}getPluginImportPath(e){return this.plugins.get(e)?.importPath}getPluginGeneratedResolvers(){return this.generatedResolvers}getPluginGeneratedExecutors(){return this.generatedExecutors}getPluginGeneratedExecutorsWithImportPath(){return this.generatedExecutors.map(e=>({...e,pluginImportPath:this.getPluginImportPath(e.pluginId)??``}))}getPluginGeneratedTables(){return this.generatedTables}getPluginGeneratedExecutorsForNamespace(e){return this.generatedExecutors.filter(t=>t.namespace===e)}getPluginsWithGenerationHooks(){return Array.from(this.plugins.values()).filter(e=>r(e))}getPluginGenerationDependencies(e){let t=this.plugins.get(e);return t?i(t):/* @__PURE__ */ new Set}generatePluginFiles(e){let{outputDir:t,sourceTableInfoMap:n,configPath:r,tableGenerator:i,executorGenerator:a}=e,o=i(this.generatedTables,t),s=this.getPluginGeneratedExecutorsWithImportPath();return this.pluginExecutorFiles=a(s,t,o,n,r),this.pluginExecutorFiles}extendTable(t){let{originalTable:n,extendFields:r,pluginId:i}=t,a=Object.keys(n.fields),o=Object.keys(n.metadata.files),s=Object.keys(r),c=s.filter(e=>a.includes(e)),l=s.filter(e=>o.includes(e));if(c.length>0)throw Error(`Plugin "${i}" attempted to add fields that already exist in table "${n.name}": ${c.join(`, `)}. extendFields cannot overwrite existing fields.`);if(l.length>0)throw Error(`Plugin "${i}" attempted to add fields that collide with file keys already declared via .files() on table "${n.name}": ${l.join(`, `)}.`);let{id:u,...d}={...n.fields,...r},f=n.metadata.settings?.pluralForm,p=f?[n.name,f]:n.name;return copyMetadataToExtendedTable(n,e.table(p,d))}};function copyMetadataToExtendedTable(e,t){let n=t;e._description&&(n=n.description(e._description));let r=e.metadata;if(Object.keys(r.files).length>0&&(n=n.files(r.files)),r.settings){let{pluralForm:e,...t}=r.settings;Object.keys(t).length>0&&(n=n.features(t))}if(r.permissions.record&&(n=n.permission(r.permissions.record)),r.permissions.gql&&(n=n.gqlPermission(r.permissions.gql)),r.indexes&&Object.keys(r.indexes).length>0){let e=Object.entries(r.indexes).map(([e,t])=>({name:e,fields:t.fields,unique:t.unique}));n=n.indexes(...e)}if(r.typeHook&&(n=n.hooks(r.typeHook)),r.typeValidate&&(n=n.validate(r.typeValidate)),e.plugins.length>0)for(let t of e.plugins)n=n.plugin({[t.pluginId]:t.config});return n}export{PluginManager as t};
2
- //# sourceMappingURL=manager-DTRhIupk.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager-DTRhIupk.mjs","names":["db","getPluginGenerationDependencies","plugin","plugins","context","tableConfigRequired","output","error","message","resolver","importPath","assertDefined","kind","table","executor","results","pluginId","config","namespace","resolverNamespaceKey","executorKey","tableKey","getRawPluginTableName","params","currentTable","rawTable","extendedTable","generatedTables","events","attachment","attachments","result","extendFields","tableName","id","info","hasGenerationHooks","tableGenerationResult","tableGenerator","outputDir","pluginExecutors","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 {\n getPluginGenerationDependencies,\n getRawPluginTableName,\n hasGenerationHooks,\n} 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 DependencyKind,\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 /** Generated plugin executor file paths */\n private pluginExecutorFiles: string[] = [];\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 plugins that have onNamespaceLoaded method\n * @returns Array of plugin IDs that support namespace processing\n */\n getNamespacePluginIds(): string[] {\n return Array.from(this.plugins.entries())\n .filter(([, plugin]) => plugin.onNamespaceLoaded !== undefined)\n .map(([id]) => id);\n }\n\n /**\n * Get the count of registered plugins\n * @returns Number of registered plugins\n */\n get pluginCount(): number {\n return this.plugins.size;\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\n * @returns Array of plugin-generated executor info\n */\n getPluginGeneratedExecutors(): ReadonlyArray<PluginExecutorInfo> {\n return this.generatedExecutors;\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 plugin-generated executors for a specific namespace\n * @param namespace - The namespace to filter by\n * @returns Array of plugin-generated executor info for the namespace\n */\n getPluginGeneratedExecutorsForNamespace(namespace: string): ReadonlyArray<PluginExecutorInfo> {\n return this.generatedExecutors.filter((info) => info.namespace === namespace);\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 * Get the generation-time dependencies for a specific plugin.\n * @param pluginId - The plugin ID to look up\n * @returns Set of dependency kinds, or empty set if plugin not found\n */\n getPluginGenerationDependencies(pluginId: string): Set<DependencyKind> {\n const plugin = this.plugins.get(pluginId);\n if (!plugin) return new Set();\n return getPluginGenerationDependencies(plugin);\n }\n\n /**\n * Generate plugin files (tables and executors) and store the executor file paths.\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 this.pluginExecutorFiles = executorGenerator(\n pluginExecutors,\n outputDir,\n tableGenerationResult,\n sourceTableInfoMap,\n configPath,\n );\n\n return this.pluginExecutorFiles;\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,6HAsJA,IAAa,cAAb,KAA2B,CACzB,wBAAuC,IAAI,IAC3C,mBAAmD,CAAC,EACpD,gBAAsD,CAAC,EACvD,mBAAmD,CAAC,EACpD,4CAAsC,IAAI,IAC1C,4CAAmD,IAAI,IACvD,+CAAsD,IAAI,IAG1D,oBAAwC,CAAC,EAEzC,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,EAA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