@tailor-platform/sdk 1.17.1 → 1.19.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 (85) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/{application-BMDE8KqK.mjs → application-A6PZjujv.mjs} +192 -1673
  3. package/dist/application-A6PZjujv.mjs.map +1 -0
  4. package/dist/application-nPS5veK6.mjs +9 -0
  5. package/dist/brand-BZJCv6UY.mjs +28 -0
  6. package/dist/brand-BZJCv6UY.mjs.map +1 -0
  7. package/dist/cli/index.mjs +40 -20
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +16 -33
  10. package/dist/cli/lib.mjs +12 -5
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/configure/index.d.mts +4 -4
  13. package/dist/configure/index.mjs +10 -19
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/enum-constants-CGVvu3dd.mjs +115 -0
  16. package/dist/enum-constants-CGVvu3dd.mjs.map +1 -0
  17. package/dist/file-utils-GX_tGWl4.mjs +139 -0
  18. package/dist/file-utils-GX_tGWl4.mjs.map +1 -0
  19. package/dist/index-B6pvy1MK.d.mts +20 -0
  20. package/dist/index-B91ZpOcd.d.mts +18 -0
  21. package/dist/index-CPzbMghQ.d.mts +18 -0
  22. package/dist/{index-CVcYqZSf.d.mts → index-ClLZCbcm.d.mts} +18 -5
  23. package/dist/index-DDqKNFh4.d.mts +18 -0
  24. package/dist/interceptor-D8MeZOxX.mjs +33 -0
  25. package/dist/interceptor-D8MeZOxX.mjs.map +1 -0
  26. package/dist/{jiti-BrELlEYT.mjs → jiti-DfS9jItj.mjs} +2 -2
  27. package/dist/{jiti-BrELlEYT.mjs.map → jiti-DfS9jItj.mjs.map} +1 -1
  28. package/dist/{job-CULA2Pvf.mjs → job-2Q82qQ6N.mjs} +27 -5
  29. package/dist/job-2Q82qQ6N.mjs.map +1 -0
  30. package/dist/kysely-type-Cpq5TNGY.mjs +260 -0
  31. package/dist/kysely-type-Cpq5TNGY.mjs.map +1 -0
  32. package/dist/package-json-DUY2kB6z.mjs +17 -0
  33. package/dist/package-json-DUY2kB6z.mjs.map +1 -0
  34. package/dist/package-json-Dd1AnA5F.mjs +3 -0
  35. package/dist/plugin/builtin/enum-constants/index.d.mts +4 -0
  36. package/dist/plugin/builtin/enum-constants/index.mjs +3 -0
  37. package/dist/plugin/builtin/file-utils/index.d.mts +4 -0
  38. package/dist/plugin/builtin/file-utils/index.mjs +3 -0
  39. package/dist/plugin/builtin/kysely-type/index.d.mts +4 -0
  40. package/dist/plugin/builtin/kysely-type/index.mjs +3 -0
  41. package/dist/plugin/builtin/seed/index.d.mts +4 -0
  42. package/dist/plugin/builtin/seed/index.mjs +3 -0
  43. package/dist/plugin/index.d.mts +3 -3
  44. package/dist/plugin/index.mjs +11 -11
  45. package/dist/plugin/index.mjs.map +1 -1
  46. package/dist/{schema-R5TxC5Pn.mjs → schema-D5Cpd8fQ.mjs} +48 -5
  47. package/dist/schema-D5Cpd8fQ.mjs.map +1 -0
  48. package/dist/seed-CeUEANfQ.mjs +1050 -0
  49. package/dist/seed-CeUEANfQ.mjs.map +1 -0
  50. package/dist/{src-DMROgdcL.mjs → src-Bb1UVstT.mjs} +2 -2
  51. package/dist/{src-DMROgdcL.mjs.map → src-Bb1UVstT.mjs.map} +1 -1
  52. package/dist/telemetry-9A1BZqbl.mjs +3 -0
  53. package/dist/telemetry-rFq0QdvJ.mjs +84 -0
  54. package/dist/telemetry-rFq0QdvJ.mjs.map +1 -0
  55. package/dist/types-CJF3Y1x8.d.mts +158 -0
  56. package/dist/{types-CZZBCaxB.d.mts → types-CblXasFV.d.mts} +1405 -1045
  57. package/dist/{types-b-ig8nW_.mjs → types-ClK_HJ0G.mjs} +1 -1
  58. package/dist/{types-b-ig8nW_.mjs.map → types-ClK_HJ0G.mjs.map} +1 -1
  59. package/dist/{update-CUBVjZbL.mjs → update-Cr5c7h1r.mjs} +485 -244
  60. package/dist/update-Cr5c7h1r.mjs.map +1 -0
  61. package/dist/utils/test/index.d.mts +4 -4
  62. package/dist/utils/test/index.mjs +3 -2
  63. package/dist/utils/test/index.mjs.map +1 -1
  64. package/docs/cli/application.md +106 -14
  65. package/docs/cli/auth.md +92 -12
  66. package/docs/cli/completion.md +18 -2
  67. package/docs/cli/executor.md +122 -14
  68. package/docs/cli/function.md +32 -4
  69. package/docs/cli/secret.md +134 -18
  70. package/docs/cli/staticwebsite.md +60 -8
  71. package/docs/cli/tailordb.md +148 -20
  72. package/docs/cli/user.md +154 -22
  73. package/docs/cli/workflow.md +100 -12
  74. package/docs/cli/workspace.md +274 -38
  75. package/docs/generator/custom.md +2 -2
  76. package/docs/plugin/custom.md +270 -163
  77. package/docs/plugin/index.md +48 -2
  78. package/package.json +28 -2
  79. package/dist/application-BMDE8KqK.mjs.map +0 -1
  80. package/dist/application-Dni_W16P.mjs +0 -4
  81. package/dist/job-CULA2Pvf.mjs.map +0 -1
  82. package/dist/schema-R5TxC5Pn.mjs.map +0 -1
  83. package/dist/types-DthzUFfx.d.mts +0 -372
  84. package/dist/update-CUBVjZbL.mjs.map +0 -1
  85. /package/dist/{chunk-GMkBE123.mjs → chunk-CqAI0b6X.mjs} +0 -0
@@ -1,3 +1,16 @@
1
+ import { t as brandValue } from "./brand-BZJCv6UY.mjs";
2
+
3
+ //#region src/configure/types/user.ts
4
+ /** Represents an unauthenticated user in the Tailor platform. */
5
+ const unauthenticatedTailorUser = {
6
+ id: "00000000-0000-0000-0000-000000000000",
7
+ type: "",
8
+ workspaceId: "00000000-0000-0000-0000-000000000000",
9
+ attributes: null,
10
+ attributeList: []
11
+ };
12
+
13
+ //#endregion
1
14
  //#region src/configure/services/workflow/job.ts
2
15
  /**
3
16
  * Environment variable key for workflow testing.
@@ -5,6 +18,11 @@
5
18
  */
6
19
  const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
7
20
  /**
21
+ * Environment variable key for workflow user testing.
22
+ * Contains JSON-serialized TailorUser object.
23
+ */
24
+ const WORKFLOW_TEST_USER_KEY = "TAILOR_TEST_WORKFLOW_USER";
25
+ /**
8
26
  * Create a workflow job definition.
9
27
  *
10
28
  * All jobs must be named exports from the workflow file.
@@ -35,17 +53,21 @@ const WORKFLOW_TEST_ENV_KEY = "TAILOR_TEST_WORKFLOW_ENV";
35
53
  * });
36
54
  */
37
55
  const createWorkflowJob = (config) => {
38
- return {
56
+ return brandValue({
39
57
  name: config.name,
40
58
  trigger: async (args) => {
41
59
  const env = JSON.parse(process.env[WORKFLOW_TEST_ENV_KEY] || "{}");
42
- const result = await config.body(args, { env });
60
+ const user = process.env[WORKFLOW_TEST_USER_KEY] ? JSON.parse(process.env[WORKFLOW_TEST_USER_KEY]) : unauthenticatedTailorUser;
61
+ const result = await config.body(args, {
62
+ env,
63
+ user
64
+ });
43
65
  return result ? JSON.parse(JSON.stringify(result)) : result;
44
66
  },
45
67
  body: config.body
46
- };
68
+ });
47
69
  };
48
70
 
49
71
  //#endregion
50
- export { createWorkflowJob as n, WORKFLOW_TEST_ENV_KEY as t };
51
- //# sourceMappingURL=job-CULA2Pvf.mjs.map
72
+ export { unauthenticatedTailorUser as i, WORKFLOW_TEST_USER_KEY as n, createWorkflowJob as r, WORKFLOW_TEST_ENV_KEY as t };
73
+ //# sourceMappingURL=job-2Q82qQ6N.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-2Q82qQ6N.mjs","names":[],"sources":["../src/configure/types/user.ts","../src/configure/services/workflow/job.ts"],"sourcesContent":["// Interfaces for module augmentation\n// Users can extend these via: declare module \"@tailor-platform/sdk\" { interface AttributeMap { ... } }\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface AttributeMap {}\nexport interface AttributeList {\n __tuple?: []; // Marker for tuple type\n}\n\nexport type InferredAttributeMap = keyof AttributeMap extends never\n ? Record<string, string | string[] | boolean | boolean[] | undefined>\n : AttributeMap;\n\nexport type InferredAttributeList = AttributeList[\"__tuple\"] extends []\n ? string[]\n : AttributeList[\"__tuple\"];\n\n/** Represents a user in the Tailor platform. */\nexport type TailorUser = {\n /**\n * The ID of the user.\n * For unauthenticated users, this will be a nil UUID.\n */\n id: string;\n /**\n * The type of the user.\n * For unauthenticated users, this will be an empty string.\n */\n type: \"user\" | \"machine_user\" | \"\";\n /** The ID of the workspace the user belongs to. */\n workspaceId: string;\n /**\n * A map of the user's attributes.\n * For unauthenticated users, this will be null.\n */\n attributes: InferredAttributeMap | null;\n /**\n * A list of the user's attributes.\n * For unauthenticated users, this will be an empty array.\n */\n attributeList: InferredAttributeList;\n};\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser: TailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n};\n","import { unauthenticatedTailorUser } from \"@/configure/types/user\";\nimport { brandValue } from \"@/utils/brand\";\nimport type { TailorEnv } from \"@/configure/types/env\";\nimport type { JsonCompatible } from \"@/configure/types/helpers\";\nimport type { TailorUser } from \"@/configure/types/user\";\nimport type { Jsonifiable, Jsonify, JsonPrimitive } from \"type-fest\";\n\n/**\n * Context object passed as the second argument to workflow job body functions.\n */\nexport type WorkflowJobContext = {\n env: TailorEnv;\n user: TailorUser;\n};\n\n/**\n * Allowed output types for workflow job body functions.\n * Includes Jsonifiable (JSON-serializable values including objects with toJSON like Date),\n * undefined, and void.\n */\nexport type WorkflowJobOutput = Jsonifiable | undefined | void;\n\n/**\n * Convert output type to what trigger returns after JSON serialization.\n * - Jsonifiable values are converted via Jsonify (Date -> string, etc.)\n * - undefined remains undefined\n * - void becomes void\n */\ntype JsonifyOutput<T> = T extends Jsonifiable ? Jsonify<T> : T;\n\n/**\n * Input type constraint for workflow jobs.\n * Accepts any type that is JSON-compatible (primitives, arrays, objects with JSON-compatible values).\n * Excludes objects with toJSON method (like Date) since they won't be serialized in input.\n */\nexport type WorkflowJobInput = undefined | JsonCompatible<unknown>;\n\n/**\n * WorkflowJob represents a job that can be triggered in a workflow.\n *\n * Type constraints:\n * - Input: Must be JSON-compatible (no Date/toJSON objects) or undefined. Interfaces are allowed.\n * - Output: Must be Jsonifiable, undefined, or void\n * - Trigger returns Jsonify<Output> (Date becomes string after JSON.stringify)\n */\nexport interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {\n name: Name;\n /**\n * Trigger this job with the given input.\n * At runtime, this is a placeholder that calls the body function.\n * During bundling, calls to .trigger() are transformed to\n * tailor.workflow.triggerJobFunction(\"<job-name>\", args).\n *\n * Returns Jsonify<Output> because the value passes through JSON.stringify.\n *\n * Inside a workflow job body, .trigger() calls are transformed by the bundler\n * into synchronous `triggerJobFunction` calls. You may use `await` for\n * readability — the bundler strips it automatically at build time.\n * @example\n * // Both styles work — await is stripped by the bundler:\n * body: async (input) => {\n * const a = await jobA.trigger({ id: input.id });\n * const b = await jobB.trigger({ id: input.id });\n * return { a, b };\n * }\n */\n trigger: [Input] extends [undefined]\n ? () => Promise<JsonifyOutput<Awaited<Output>>>\n : (input: Input) => Promise<JsonifyOutput<Awaited<Output>>>;\n body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;\n}\n\n/**\n * Helper type to check if all property types are valid.\n * Uses -? to remove optional modifiers so all properties are treated uniformly.\n */\ntype AllPropertiesValid<T> = {\n [K in keyof T]-?: IsValidInput<T[K]> extends true ? true : false;\n}[keyof T] extends true\n ? true\n : false;\n\n/**\n * Check if a type contains any non-JSON-compatible values.\n * Returns `true` if the type is valid for input, `false` otherwise.\n *\n * Accepts:\n * - JSON primitives (string, number, boolean, null)\n * - undefined\n * - Optional primitives (e.g., string | undefined)\n * - Arrays of valid types\n * - Objects with valid field types\n *\n * Rejects:\n * - Objects with toJSON methods (like Date)\n * - Other non-JSON-serializable types\n */\ntype IsValidInput<T> = T extends undefined\n ? true\n : T extends JsonPrimitive\n ? true\n : T extends readonly (infer U)[]\n ? IsValidInput<U>\n : T extends object\n ? T extends { toJSON: () => unknown }\n ? false\n : AllPropertiesValid<T>\n : false;\n\n/**\n * Helper type to check if all property types are valid for output.\n * Uses -? to remove optional modifiers so all properties are treated uniformly.\n */\ntype AllPropertiesValidOutput<T> = {\n [K in keyof T]-?: IsValidOutput<T[K]> extends true ? true : false;\n}[keyof T] extends true\n ? true\n : false;\n\n/**\n * Check if a type is valid for output.\n * Returns `true` if the type is valid, `false` otherwise.\n *\n * Accepts:\n * - JSON primitives (string, number, boolean, null)\n * - undefined and void\n * - Optional primitives (e.g., string | undefined)\n * - Jsonifiable types (Date, objects with toJSON)\n * - Arrays of valid types\n * - Objects with valid field types\n */\ntype IsValidOutput<T> = T extends undefined | void\n ? true\n : T extends JsonPrimitive\n ? true\n : T extends readonly (infer U)[]\n ? IsValidOutput<U>\n : T extends object\n ? AllPropertiesValidOutput<T>\n : false;\n\n/**\n * Body function type with conditional constraint.\n * If input contains invalid types (like Date), the body type becomes `never` to cause an error.\n */\ntype WorkflowJobBody<I, O> =\n IsValidInput<I> extends true\n ? IsValidOutput<O> extends true\n ? (input: I, context: WorkflowJobContext) => O | Promise<O>\n : never\n : never;\n\n/**\n * Environment variable key for workflow testing.\n * Contains JSON-serialized TailorEnv object.\n */\nexport const WORKFLOW_TEST_ENV_KEY = \"TAILOR_TEST_WORKFLOW_ENV\";\n\n/**\n * Environment variable key for workflow user testing.\n * Contains JSON-serialized TailorUser object.\n */\nexport const WORKFLOW_TEST_USER_KEY = \"TAILOR_TEST_WORKFLOW_USER\";\n\n/**\n * Create a workflow job definition.\n *\n * All jobs must be named exports from the workflow file.\n * Job names must be unique across the entire project.\n * @param config - Job configuration with name and body function\n * @param config.name - Unique job name across the project\n * @param config.body - Async function that processes the job input\n * @returns A WorkflowJob that can be triggered from other jobs\n * @example\n * // Simple job with async body:\n * export const fetchData = createWorkflowJob({\n * name: \"fetch-data\",\n * body: async (input: { id: string }) => {\n * const db = getDB(\"tailordb\");\n * return await db.selectFrom(\"Table\").selectAll().where(\"id\", \"=\", input.id).executeTakeFirst();\n * },\n * });\n * @example\n * // Orchestrator job that fans out to other jobs.\n * // await is optional — the bundler strips it at build time.\n * export const orchestrate = createWorkflowJob({\n * name: \"orchestrate\",\n * body: async (input: { orderId: string }) => {\n * const inventory = await checkInventory.trigger({ orderId: input.orderId });\n * const payment = await processPayment.trigger({ orderId: input.orderId });\n * return { inventory, payment };\n * },\n * });\n */\nexport const createWorkflowJob = <const Name extends string, I = undefined, O = undefined>(config: {\n readonly name: Name;\n readonly body: WorkflowJobBody<I, O>;\n}): WorkflowJob<Name, I, Awaited<O>> => {\n return brandValue({\n name: config.name,\n // JSON.parse(JSON.stringify(...)) ensures the return value matches Jsonify<Output> type.\n // This converts Date objects to strings, matching actual runtime behavior.\n // In production, bundler transforms .trigger() calls to tailor.workflow.triggerJobFunction().\n trigger: async (args?: unknown) => {\n const env: TailorEnv = JSON.parse(process.env[WORKFLOW_TEST_ENV_KEY] || \"{}\");\n const user: TailorUser = process.env[WORKFLOW_TEST_USER_KEY]\n ? JSON.parse(process.env[WORKFLOW_TEST_USER_KEY])\n : unauthenticatedTailorUser;\n const result = await config.body(args as I, { env, user });\n return result ? JSON.parse(JSON.stringify(result)) : result;\n },\n body: config.body,\n } as WorkflowJob<Name, I, Awaited<O>>);\n};\n"],"mappings":";;;;AA2CA,MAAa,4BAAwC;CACnD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,YAAY;CACZ,eAAe,EAAE;CAClB;;;;;;;;AC2GD,MAAa,wBAAwB;;;;;AAMrC,MAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCtC,MAAa,qBAA8E,WAGnD;AACtC,QAAO,WAAW;EAChB,MAAM,OAAO;EAIb,SAAS,OAAO,SAAmB;GACjC,MAAM,MAAiB,KAAK,MAAM,QAAQ,IAAI,0BAA0B,KAAK;GAC7E,MAAM,OAAmB,QAAQ,IAAI,0BACjC,KAAK,MAAM,QAAQ,IAAI,wBAAwB,GAC/C;GACJ,MAAM,SAAS,MAAM,OAAO,KAAK,MAAW;IAAE;IAAK;IAAM,CAAC;AAC1D,UAAO,SAAS,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC,GAAG;;EAEvD,MAAM,OAAO;EACd,CAAqC"}
@@ -0,0 +1,260 @@
1
+ import ml from "multiline-ts";
2
+
3
+ //#region src/plugin/builtin/kysely-type/type-processor.ts
4
+ /**
5
+ * Get the enum type definition.
6
+ * @param fieldConfig - The field configuration
7
+ * @returns The enum type as a string union
8
+ */
9
+ function getEnumType(fieldConfig) {
10
+ const allowedValues = fieldConfig.allowedValues;
11
+ if (allowedValues && Array.isArray(allowedValues)) return allowedValues.map((v) => {
12
+ return `"${typeof v === "string" ? v : v.value}"`;
13
+ }).join(" | ");
14
+ return "string";
15
+ }
16
+ /**
17
+ * Get the nested object type definition.
18
+ * @param fieldConfig - The field configuration
19
+ * @returns The nested type with used utility types
20
+ */
21
+ function getNestedType(fieldConfig) {
22
+ const fields = fieldConfig.fields;
23
+ if (!fields || typeof fields !== "object") return {
24
+ type: "string",
25
+ usedUtilityTypes: {
26
+ Timestamp: false,
27
+ Serial: false
28
+ }
29
+ };
30
+ const fieldResults = Object.entries(fields).map(([fieldName, nestedOperatorFieldConfig]) => ({
31
+ fieldName,
32
+ ...generateFieldType(nestedOperatorFieldConfig)
33
+ }));
34
+ const fieldTypes = fieldResults.map((result) => `${result.fieldName}: ${result.type}`);
35
+ const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
36
+ Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
37
+ Serial: acc.Serial || result.usedUtilityTypes.Serial
38
+ }), {
39
+ Timestamp: false,
40
+ Serial: false
41
+ });
42
+ return {
43
+ type: `{\n ${fieldTypes.join(";\n ")}${fieldTypes.length > 0 ? ";" : ""}\n}`,
44
+ usedUtilityTypes: aggregatedUtilityTypes
45
+ };
46
+ }
47
+ /**
48
+ * Get the base Kysely type for a field (without array/null modifiers).
49
+ * @param fieldConfig - The field configuration
50
+ * @returns The base type with used utility types
51
+ */
52
+ function getBaseType(fieldConfig) {
53
+ const fieldType = fieldConfig.type;
54
+ const usedUtilityTypes = {
55
+ Timestamp: false,
56
+ Serial: false
57
+ };
58
+ let type;
59
+ switch (fieldType) {
60
+ case "uuid":
61
+ case "string":
62
+ case "decimal":
63
+ type = "string";
64
+ break;
65
+ case "integer":
66
+ case "float":
67
+ type = "number";
68
+ break;
69
+ case "date":
70
+ case "datetime":
71
+ usedUtilityTypes.Timestamp = true;
72
+ type = "Timestamp";
73
+ break;
74
+ case "bool":
75
+ case "boolean":
76
+ type = "boolean";
77
+ break;
78
+ case "enum":
79
+ type = getEnumType(fieldConfig);
80
+ break;
81
+ case "nested": return getNestedType(fieldConfig);
82
+ default:
83
+ type = "string";
84
+ break;
85
+ }
86
+ return {
87
+ type,
88
+ usedUtilityTypes
89
+ };
90
+ }
91
+ /**
92
+ * Generate the complete field type including array and null modifiers.
93
+ * @param fieldConfig - The field configuration
94
+ * @returns The complete field type with used utility types
95
+ */
96
+ function generateFieldType(fieldConfig) {
97
+ const baseTypeResult = getBaseType(fieldConfig);
98
+ const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };
99
+ const isArray = fieldConfig.array === true;
100
+ const isNullable = fieldConfig.required !== true;
101
+ let finalType = baseTypeResult.type;
102
+ if (isArray) finalType = fieldConfig.type === "enum" ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;
103
+ if (isNullable) finalType = `${finalType} | null`;
104
+ if (fieldConfig.serial) {
105
+ usedUtilityTypes.Serial = true;
106
+ finalType = `Serial<${finalType}>`;
107
+ }
108
+ if (fieldConfig.hooks?.create) finalType = `Generated<${finalType}>`;
109
+ return {
110
+ type: finalType,
111
+ usedUtilityTypes
112
+ };
113
+ }
114
+ /**
115
+ * Generate the table interface.
116
+ * @param type - The parsed TailorDB type
117
+ * @returns The type definition and used utility types
118
+ */
119
+ function generateTableInterface(type) {
120
+ const fieldResults = Object.entries(type.fields).filter(([fieldName]) => fieldName !== "id").map(([fieldName, parsedField]) => ({
121
+ fieldName,
122
+ ...generateFieldType(parsedField.config)
123
+ }));
124
+ const fields = ["id: Generated<string>;", ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`)];
125
+ const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
126
+ Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
127
+ Serial: acc.Serial || result.usedUtilityTypes.Serial
128
+ }), {
129
+ Timestamp: false,
130
+ Serial: false
131
+ });
132
+ return {
133
+ typeDef: ml`
134
+ ${type.name}: {
135
+ ${fields.join("\n")}
136
+ }
137
+ `,
138
+ usedUtilityTypes: aggregatedUtilityTypes
139
+ };
140
+ }
141
+ /**
142
+ * Convert a TailorDBType into KyselyTypeMetadata.
143
+ * @param type - Parsed TailorDB type
144
+ * @returns Generated Kysely type metadata
145
+ */
146
+ async function processKyselyType(type) {
147
+ const result = generateTableInterface(type);
148
+ return {
149
+ name: type.name,
150
+ typeDef: result.typeDef,
151
+ usedUtilityTypes: result.usedUtilityTypes
152
+ };
153
+ }
154
+ /**
155
+ * Generate unified types file from multiple namespaces.
156
+ * @param namespaceData - Namespace metadata
157
+ * @returns Generated types file contents
158
+ */
159
+ function generateUnifiedKyselyTypes(namespaceData) {
160
+ if (namespaceData.length === 0) return "";
161
+ const globalUsedUtilityTypes = namespaceData.reduce((acc, ns) => ({
162
+ Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,
163
+ Serial: acc.Serial || ns.usedUtilityTypes.Serial
164
+ }), {
165
+ Timestamp: false,
166
+ Serial: false
167
+ });
168
+ const utilityTypeImports = ["type Generated"];
169
+ if (globalUsedUtilityTypes.Timestamp) utilityTypeImports.push("type Timestamp");
170
+ if (globalUsedUtilityTypes.Serial) utilityTypeImports.push("type Serial");
171
+ return [
172
+ ml`
173
+ import {
174
+ createGetDB,
175
+ ${utilityTypeImports.join(",\n")},
176
+ type NamespaceDB,
177
+ type NamespaceInsertable,
178
+ type NamespaceSelectable,
179
+ type NamespaceTable,
180
+ type NamespaceTableName,
181
+ type NamespaceTransaction,
182
+ type NamespaceUpdateable,
183
+ } from "@tailor-platform/sdk/kysely";
184
+ `,
185
+ `export interface Namespace {\n${namespaceData.map(({ namespace, types }) => {
186
+ return ` "${namespace}": {\n${types.map((type) => {
187
+ return type.typeDef.split("\n").map((line) => line.trim() ? ` ${line}` : "").join("\n");
188
+ }).join("\n\n")}\n }`;
189
+ }).join(",\n")}\n}`,
190
+ ml`
191
+ export const getDB = createGetDB<Namespace>();
192
+
193
+ export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
194
+ `,
195
+ ml`
196
+ export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
197
+ NamespaceTransaction<Namespace, K>;
198
+
199
+ type TableName = NamespaceTableName<Namespace>;
200
+ export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
201
+
202
+ export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
203
+ export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
204
+ export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
205
+ `
206
+ ].join("\n\n") + "\n";
207
+ }
208
+
209
+ //#endregion
210
+ //#region src/plugin/builtin/kysely-type/index.ts
211
+ const KyselyGeneratorID = "@tailor-platform/kysely-type";
212
+ /**
213
+ * Plugin that generates Kysely type definitions for TailorDB types.
214
+ * @param options - Plugin options
215
+ * @param options.distPath - Output file path for generated types
216
+ * @returns Plugin instance with onTailorDBReady hook
217
+ */
218
+ function kyselyTypePlugin(options) {
219
+ return {
220
+ id: KyselyGeneratorID,
221
+ description: "Generates Kysely type definitions for TailorDB types",
222
+ pluginConfig: options,
223
+ async onTailorDBReady(ctx) {
224
+ const allNamespaceData = [];
225
+ for (const ns of ctx.tailordb) {
226
+ const typeMetadataList = [];
227
+ for (const type of Object.values(ns.types)) {
228
+ const metadata = await processKyselyType(type);
229
+ typeMetadataList.push(metadata);
230
+ }
231
+ if (typeMetadataList.length === 0) continue;
232
+ const usedUtilityTypes = typeMetadataList.reduce((acc, type) => ({
233
+ Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,
234
+ Serial: acc.Serial || type.usedUtilityTypes.Serial
235
+ }), {
236
+ Timestamp: false,
237
+ Serial: false
238
+ });
239
+ allNamespaceData.push({
240
+ namespace: ns.namespace,
241
+ types: typeMetadataList,
242
+ usedUtilityTypes
243
+ });
244
+ }
245
+ const files = [];
246
+ if (allNamespaceData.length > 0) {
247
+ const content = generateUnifiedKyselyTypes(allNamespaceData);
248
+ files.push({
249
+ path: ctx.pluginConfig.distPath,
250
+ content
251
+ });
252
+ }
253
+ return { files };
254
+ }
255
+ };
256
+ }
257
+
258
+ //#endregion
259
+ export { kyselyTypePlugin as n, KyselyGeneratorID as t };
260
+ //# sourceMappingURL=kysely-type-Cpq5TNGY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-type-Cpq5TNGY.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"multiline-ts\";\nimport { type KyselyNamespaceMetadata, type KyselyTypeMetadata } from \"./types\";\nimport type { OperatorFieldConfig, TailorDBType } from \"@/parser/service/tailordb/types\";\n\ntype UsedUtilityTypes = { Timestamp: boolean; Serial: boolean };\n\ntype FieldTypeResult = {\n type: string;\n usedUtilityTypes: UsedUtilityTypes;\n};\n\n/**\n * Get the enum type definition.\n * @param fieldConfig - The field configuration\n * @returns The enum type as a string union\n */\nfunction getEnumType(fieldConfig: OperatorFieldConfig): string {\n const allowedValues = fieldConfig.allowedValues;\n\n if (allowedValues && Array.isArray(allowedValues)) {\n return allowedValues\n .map((v: string | { value: string }) => {\n const value = typeof v === \"string\" ? v : v.value;\n return `\"${value}\"`;\n })\n .join(\" | \");\n }\n return \"string\";\n}\n\n/**\n * Get the nested object type definition.\n * @param fieldConfig - The field configuration\n * @returns The nested type with used utility types\n */\nfunction getNestedType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fields = fieldConfig.fields;\n if (!fields || typeof fields !== \"object\") {\n return {\n type: \"string\",\n usedUtilityTypes: { Timestamp: false, Serial: false },\n };\n }\n\n const fieldResults = Object.entries(fields).map(([fieldName, nestedOperatorFieldConfig]) => ({\n fieldName,\n ...generateFieldType(nestedOperatorFieldConfig),\n }));\n\n const fieldTypes = fieldResults.map((result) => `${result.fieldName}: ${result.type}`);\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const type = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n return { type, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Get the base Kysely type for a field (without array/null modifiers).\n * @param fieldConfig - The field configuration\n * @returns The base type with used utility types\n */\nfunction getBaseType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n let type: string;\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n type = \"string\";\n break;\n case \"integer\":\n case \"float\":\n type = \"number\";\n break;\n case \"date\":\n case \"datetime\":\n usedUtilityTypes.Timestamp = true;\n type = \"Timestamp\";\n break;\n case \"bool\":\n case \"boolean\":\n type = \"boolean\";\n break;\n case \"enum\":\n type = getEnumType(fieldConfig);\n break;\n case \"nested\": {\n const nestedResult = getNestedType(fieldConfig);\n return nestedResult;\n }\n default:\n type = \"string\";\n break;\n }\n\n return { type, usedUtilityTypes };\n}\n\n/**\n * Generate the complete field type including array and null modifiers.\n * @param fieldConfig - The field configuration\n * @returns The complete field type with used utility types\n */\nfunction generateFieldType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const baseTypeResult = getBaseType(fieldConfig);\n const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };\n\n const isArray = fieldConfig.array === true;\n const isNullable = fieldConfig.required !== true;\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n // Wrap enum types in parentheses before adding array suffix\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\n if (isNullable) {\n finalType = `${finalType} | null`;\n }\n\n if (fieldConfig.serial) {\n usedUtilityTypes.Serial = true;\n finalType = `Serial<${finalType}>`;\n }\n if (fieldConfig.hooks?.create) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param type - The parsed TailorDB type\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(type: TailorDBType): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(type.fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, parsedField]) => ({\n fieldName,\n ...generateFieldType(parsedField.config),\n }));\n\n const fields = [\n \"id: Generated<string>;\",\n ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`),\n ];\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const typeDef = multiline /* ts */ `\n ${type.name}: {\n ${fields.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB type\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n const result = generateTableInterface(type);\n\n return {\n name: type.name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Generate unified types file from multiple namespaces.\n * @param namespaceData - Namespace metadata\n * @returns Generated types file contents\n */\nexport function generateUnifiedKyselyTypes(namespaceData: KyselyNamespaceMetadata[]): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Aggregate used utility types from all namespaces\n const globalUsedUtilityTypes = namespaceData.reduce(\n (acc, ns) => ({\n Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || ns.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const utilityTypeImports: string[] = [\"type Generated\"];\n if (globalUsedUtilityTypes.Timestamp) {\n utilityTypeImports.push(\"type Timestamp\");\n }\n if (globalUsedUtilityTypes.Serial) {\n utilityTypeImports.push(\"type Serial\");\n }\n\n const importsSection = multiline /* ts */ `\n import {\n createGetDB,\n ${utilityTypeImports.join(\",\\n\")},\n type NamespaceDB,\n type NamespaceInsertable,\n type NamespaceSelectable,\n type NamespaceTable,\n type NamespaceTableName,\n type NamespaceTransaction,\n type NamespaceUpdateable,\n } from \"@tailor-platform/sdk/kysely\";\n `;\n\n // Generate Namespace interface with multiple namespaces\n const namespaceInterfaces = namespaceData\n .map(({ namespace, types }) => {\n const typeDefsWithIndent = types\n .map((type) => {\n return type.typeDef\n .split(\"\\n\")\n .map((line) => (line.trim() ? ` ${line}` : \"\"))\n .join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return ` \"${namespace}\": {\\n${typeDefsWithIndent}\\n }`;\n })\n .join(\",\\n\");\n\n const namespaceInterface = `export interface Namespace {\\n${namespaceInterfaces}\\n}`;\n\n const getDBFunction = multiline /* ts */ `\n export const getDB = createGetDB<Namespace>();\n\n export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;\n `;\n\n const utilityTypeExports = multiline /* ts */ `\n export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =\n NamespaceTransaction<Namespace, K>;\n\n type TableName = NamespaceTableName<Namespace>;\n export type Table<T extends TableName> = NamespaceTable<Namespace, T>;\n\n export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;\n export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;\n export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;\n `;\n\n return (\n [importsSection, namespaceInterface, getDBFunction, utilityTypeExports].join(\"\\n\\n\") + \"\\n\"\n );\n}\n","import { processKyselyType, generateUnifiedKyselyTypes } from \"./type-processor\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\nimport type {\n GeneratorResult,\n TailorDBReadyContext,\n} from \"@/parser/plugin-config/generation-types\";\nimport type { Plugin } from \"@/parser/plugin-config/types\";\n\nexport const KyselyGeneratorID = \"@tailor-platform/kysely-type\";\n\ntype KyselyTypePluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB types.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated types\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function kyselyTypePlugin(\n options: KyselyTypePluginOptions,\n): Plugin<unknown, KyselyTypePluginOptions> {\n return {\n id: KyselyGeneratorID,\n description: \"Generates Kysely type definitions for TailorDB types\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<KyselyTypePluginOptions>,\n ): Promise<GeneratorResult> {\n const allNamespaceData: KyselyNamespaceMetadata[] = [];\n\n for (const ns of ctx.tailordb) {\n const typeMetadataList: KyselyTypeMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processKyselyType(type);\n typeMetadataList.push(metadata);\n }\n\n if (typeMetadataList.length === 0) continue;\n\n const usedUtilityTypes = typeMetadataList.reduce(\n (acc, type) => ({\n Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || type.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n allNamespaceData.push({\n namespace: ns.namespace,\n types: typeMetadataList,\n usedUtilityTypes,\n });\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allNamespaceData.length > 0) {\n const content = generateUnifiedKyselyTypes(allNamespaceData);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,17 @@
1
+ import { readPackageJSON } from "pkg-types";
2
+
3
+ //#region src/cli/utils/package-json.ts
4
+ let packageJson = null;
5
+ /**
6
+ * Read and cache the package.json of the SDK package.
7
+ * @returns Parsed package.json contents
8
+ */
9
+ async function readPackageJson() {
10
+ if (packageJson) return packageJson;
11
+ packageJson = await readPackageJSON(import.meta.url);
12
+ return packageJson;
13
+ }
14
+
15
+ //#endregion
16
+ export { readPackageJson as t };
17
+ //# sourceMappingURL=package-json-DUY2kB6z.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-json-DUY2kB6z.mjs","names":[],"sources":["../src/cli/utils/package-json.ts"],"sourcesContent":["import { readPackageJSON, type PackageJson } from \"pkg-types\";\n\nlet packageJson: PackageJson | null = null;\n\n/**\n * Read and cache the package.json of the SDK package.\n * @returns Parsed package.json contents\n */\nexport async function readPackageJson() {\n if (packageJson) {\n return packageJson;\n }\n packageJson = await readPackageJSON(import.meta.url);\n return packageJson;\n}\n"],"mappings":";;;AAEA,IAAI,cAAkC;;;;;AAMtC,eAAsB,kBAAkB;AACtC,KAAI,YACF,QAAO;AAET,eAAc,MAAM,gBAAgB,OAAO,KAAK,IAAI;AACpD,QAAO"}
@@ -0,0 +1,3 @@
1
+ import { t as readPackageJson } from "./package-json-DUY2kB6z.mjs";
2
+
3
+ export { readPackageJson };
@@ -0,0 +1,4 @@
1
+ /// <reference path="./../../../user-defined.d.ts" />
2
+ import "../../../types-CblXasFV.mjs";
3
+ import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../index-B91ZpOcd.mjs";
4
+ export { EnumConstantsGeneratorID, enumConstantsPlugin };
@@ -0,0 +1,3 @@
1
+ import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "../../../enum-constants-CGVvu3dd.mjs";
2
+
3
+ export { EnumConstantsGeneratorID, enumConstantsPlugin };
@@ -0,0 +1,4 @@
1
+ /// <reference path="./../../../user-defined.d.ts" />
2
+ import "../../../types-CblXasFV.mjs";
3
+ import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../index-DDqKNFh4.mjs";
4
+ export { FileUtilsGeneratorID, fileUtilsPlugin };
@@ -0,0 +1,3 @@
1
+ import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../file-utils-GX_tGWl4.mjs";
2
+
3
+ export { FileUtilsGeneratorID, fileUtilsPlugin };
@@ -0,0 +1,4 @@
1
+ /// <reference path="./../../../user-defined.d.ts" />
2
+ import "../../../types-CblXasFV.mjs";
3
+ import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../index-CPzbMghQ.mjs";
4
+ export { KyselyGeneratorID, kyselyTypePlugin };
@@ -0,0 +1,3 @@
1
+ import { n as kyselyTypePlugin, t as KyselyGeneratorID } from "../../../kysely-type-Cpq5TNGY.mjs";
2
+
3
+ export { KyselyGeneratorID, kyselyTypePlugin };
@@ -0,0 +1,4 @@
1
+ /// <reference path="./../../../user-defined.d.ts" />
2
+ import "../../../types-CblXasFV.mjs";
3
+ import { n as seedPlugin, t as SeedGeneratorID } from "../../../index-B6pvy1MK.mjs";
4
+ export { SeedGeneratorID, seedPlugin };
@@ -0,0 +1,3 @@
1
+ import { n as seedPlugin, t as SeedGeneratorID } from "../../../seed-CeUEANfQ.mjs";
2
+
3
+ export { SeedGeneratorID, seedPlugin };
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./../user-defined.d.ts" />
2
- import { k as TailorAnyDBType, vt as TailorEnv, yt as TailorActor } from "../types-CZZBCaxB.mjs";
2
+ import { Bt as TailorActor, i as TailorAnyDBType, zt as TailorEnv } from "../types-CblXasFV.mjs";
3
3
 
4
4
  //#region src/plugin/with-context.d.ts
5
5
 
@@ -104,8 +104,8 @@ declare function withPluginContext<Ctx>(factory: PluginExecutorFactory<Ctx>): Pl
104
104
  //#region src/plugin/get-generated-type.d.ts
105
105
  /**
106
106
  * Get a generated type from a plugin by loading the config and resolving everything automatically.
107
- * For type-attached plugins, calls processType() with the sourceType.
108
- * For namespace plugins, calls processNamespace() with auto-resolved namespace.
107
+ * For type-attached plugins, calls onTypeLoaded() with the sourceType.
108
+ * For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.
109
109
  * Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.
110
110
  * @param configPath - Path to tailor.config.ts (absolute or relative to cwd)
111
111
  * @param pluginId - The plugin's unique identifier
@@ -54,7 +54,7 @@ const configCacheMap = /* @__PURE__ */ new Map();
54
54
  * @returns True if value has the shape of Plugin
55
55
  */
56
56
  function isPlugin(value) {
57
- return typeof value === "object" && value !== null && typeof value.id === "string" && typeof value.importPath === "string";
57
+ return typeof value === "object" && value !== null && typeof value.id === "string" && typeof value.description === "string";
58
58
  }
59
59
  /**
60
60
  * Load and cache config module from the given path.
@@ -120,7 +120,7 @@ async function resolveNamespaceForType(config, configDir, sourceType) {
120
120
  }
121
121
  /**
122
122
  * Resolve the namespace for a namespace plugin by trying each namespace.
123
- * Calls processNamespace() for each and returns the first whose output contains the requested kind.
123
+ * Calls onNamespaceLoaded() for each and returns the first whose output contains the requested kind.
124
124
  * @param config - App config with db namespace definitions
125
125
  * @param config.db - DB namespace definitions
126
126
  * @param plugin - Plugin instance
@@ -130,10 +130,10 @@ async function resolveNamespaceForType(config, configDir, sourceType) {
130
130
  */
131
131
  async function resolveNamespaceForNamespacePlugin(config, plugin, kind, pluginConfig) {
132
132
  if (!config.db) throw new Error(`No db configuration found in config`);
133
- if (!plugin.processNamespace) throw new Error(`Plugin "${plugin.id}" does not have a processNamespace() method`);
133
+ if (!plugin.onNamespaceLoaded) throw new Error(`Plugin "${plugin.id}" does not have a onNamespaceLoaded() method`);
134
134
  for (const namespace of Object.keys(config.db)) {
135
135
  if (config.db[namespace].external) continue;
136
- const output = await plugin.processNamespace({
136
+ const output = await plugin.onNamespaceLoaded({
137
137
  pluginConfig,
138
138
  namespace
139
139
  });
@@ -162,8 +162,8 @@ function getCacheKey(baseKey, pluginConfig) {
162
162
  }
163
163
  /**
164
164
  * Get a generated type from a plugin by loading the config and resolving everything automatically.
165
- * For type-attached plugins, calls processType() with the sourceType.
166
- * For namespace plugins, calls processNamespace() with auto-resolved namespace.
165
+ * For type-attached plugins, calls onTypeLoaded() with the sourceType.
166
+ * For namespace plugins, calls onNamespaceLoaded() with auto-resolved namespace.
167
167
  * Results are cached per config path, plugin, namespace, and pluginConfig to avoid redundant processing.
168
168
  * @param configPath - Path to tailor.config.ts (absolute or relative to cwd)
169
169
  * @param pluginId - The plugin's unique identifier
@@ -186,7 +186,7 @@ async function getGeneratedType(configPath, pluginId, sourceType, kind) {
186
186
  }
187
187
  /**
188
188
  * Get a generated type from a type-attached plugin.
189
- * @param plugin - The plugin instance (must have processType() method)
189
+ * @param plugin - The plugin instance (must have onTypeLoaded() method)
190
190
  * @param sourceType - The source TailorDB type
191
191
  * @param kind - The generated type kind
192
192
  * @param pluginConfig - Plugin-level configuration
@@ -194,7 +194,7 @@ async function getGeneratedType(configPath, pluginId, sourceType, kind) {
194
194
  * @returns The generated TailorDB type
195
195
  */
196
196
  async function getGeneratedTypeForTypeAttachedPlugin(plugin, sourceType, kind, pluginConfig, namespace) {
197
- if (!plugin.processType) throw new Error(`Plugin "${plugin.id}" does not have a processType() method`);
197
+ if (!plugin.onTypeLoaded) throw new Error(`Plugin "${plugin.id}" does not have a onTypeLoaded() method`);
198
198
  let pluginCache = processCache.get(plugin);
199
199
  if (!pluginCache) {
200
200
  pluginCache = /* @__PURE__ */ new Map();
@@ -204,7 +204,7 @@ async function getGeneratedTypeForTypeAttachedPlugin(plugin, sourceType, kind, p
204
204
  let output = pluginCache.get(cacheKey);
205
205
  if (!output) {
206
206
  const typeConfig = sourceType.plugins?.find((p) => p.pluginId === plugin.id)?.config;
207
- output = await plugin.processType({
207
+ output = await plugin.onTypeLoaded({
208
208
  type: sourceType,
209
209
  typeConfig: typeConfig ?? {},
210
210
  pluginConfig,
@@ -221,13 +221,13 @@ async function getGeneratedTypeForTypeAttachedPlugin(plugin, sourceType, kind, p
221
221
  * Auto-resolves the namespace by trying each one.
222
222
  * @param config - App config with db namespace definitions
223
223
  * @param config.db - DB namespace definitions
224
- * @param plugin - The plugin instance (must have processNamespace() method)
224
+ * @param plugin - The plugin instance (must have onNamespaceLoaded() method)
225
225
  * @param kind - The generated type kind
226
226
  * @param pluginConfig - Plugin-level configuration
227
227
  * @returns The generated TailorDB type
228
228
  */
229
229
  async function getGeneratedTypeForNamespacePlugin(config, plugin, kind, pluginConfig) {
230
- if (!plugin.processNamespace) throw new Error(`Plugin "${plugin.id}" does not have a processNamespace() method`);
230
+ if (!plugin.onNamespaceLoaded) throw new Error(`Plugin "${plugin.id}" does not have a onNamespaceLoaded() method`);
231
231
  let pluginCache = namespaceProcessCache.get(plugin);
232
232
  if (!pluginCache) {
233
233
  pluginCache = /* @__PURE__ */ new Map();