@tailor-platform/sdk 2.0.0-next.8 → 2.0.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.
- package/CHANGELOG.md +631 -0
- package/dist/{application-GzW98_Xr.mjs → application-CM6hKnSK.mjs} +489 -118
- package/dist/application-CM6hKnSK.mjs.map +1 -0
- package/dist/application-CXNaUNhv.mjs +3 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +2 -2
- package/dist/cli/commands/deploy/application.d.mts +2 -2
- package/dist/cli/commands/deploy/auth.d.mts +2 -2
- package/dist/cli/commands/deploy/deploy.d.mts +1 -0
- package/dist/cli/commands/deploy/executor.d.mts +2 -2
- package/dist/cli/commands/deploy/function-registry.d.mts +1 -2
- package/dist/cli/commands/deploy/idp.d.mts +2 -2
- package/dist/cli/commands/deploy/label.d.mts +2 -0
- package/dist/cli/commands/deploy/resolver.d.mts +2 -2
- package/dist/cli/commands/deploy/secret-manager.d.mts +1 -1
- package/dist/cli/commands/deploy/staticwebsite.d.mts +2 -2
- package/dist/cli/commands/deploy/tailordb/index.d.mts +4 -2
- package/dist/cli/commands/deploy/types.d.mts +2 -1
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -2
- package/dist/cli/commands/deploy/workflow.d.mts +2 -2
- package/dist/cli/commands/executor/get.d.mts +1 -10
- package/dist/cli/commands/executor/jobs.d.mts +1 -38
- package/dist/cli/commands/executor/trigger.d.mts +1 -11
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +3 -2
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -1
- package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
- package/dist/cli/commands/workflow/executions.d.mts +1 -13
- package/dist/cli/commands/workflow/get.d.mts +1 -10
- package/dist/cli/commands/workflow/start.d.mts +2 -14
- package/dist/cli/index.mjs +12 -6552
- package/dist/cli/lib.d.mts +14 -15
- package/dist/cli/lib.mjs +203 -46
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/{index.d.mts → main.d.mts} +1 -1
- package/dist/cli/main.mjs +6777 -0
- package/dist/cli/main.mjs.map +1 -0
- package/dist/cli/services/http-adapter/bundler.d.mts +1 -0
- package/dist/cli/services/workflow/bundler.d.mts +2 -1
- package/dist/cli/shared/client.d.mts +28 -3
- package/dist/cli/shared/config-loader.d.mts +11 -4
- package/dist/cli/shared/error-json.d.mts +23 -0
- package/dist/cli/shared/script-executor.d.mts +6 -3
- package/dist/cli/shared/seed-chunker.d.mts +2 -7
- package/dist/cli/shared/seed-context.d.mts +49 -0
- package/dist/cli/shared/tailordb-namespaces.d.mts +7 -4
- package/dist/cli/shared/tsconfig-paths-plugin.d.mts +2 -0
- package/dist/cli/shared/type-generator.d.mts +4 -3
- package/dist/completion/zsh-worker.zsh +85 -22
- package/dist/configure/config/types.d.mts +29 -4
- package/dist/configure/index.d.mts +4 -3
- package/dist/configure/index.mjs +183 -6
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/executor/index.d.mts +2 -2
- package/dist/configure/services/executor/trigger/event.d.mts +245 -2
- package/dist/configure/services/executor/trigger/index.d.mts +3 -3
- package/dist/configure/services/idp/index.d.mts +2 -2
- package/dist/configure/services/idp/permission.d.mts +1 -16
- package/dist/configure/services/idp/types.d.mts +5 -1
- package/dist/configure/services/index.d.mts +4 -3
- package/dist/configure/services/resolver/index.d.mts +2 -1
- package/dist/configure/services/resolver/permission.d.mts +64 -0
- package/dist/configure/services/resolver/resolver.d.mts +14 -2
- package/dist/configure/services/tailordb/index.d.mts +0 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -16
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/execution-policy.types.d.mts +1 -1
- package/dist/configure/services/workflow/job.d.mts +11 -2
- package/dist/configure/services/workflow/workflow.d.mts +10 -0
- package/dist/configure/types/permission-operand.types.d.mts +20 -0
- package/dist/{crashreport-CxHne11E.mjs → crashreport-B5LqCTfF.mjs} +2 -2
- package/dist/{crashreport-CxHne11E.mjs.map → crashreport-B5LqCTfF.mjs.map} +1 -1
- package/dist/{crashreport-0ioNRZ4K.mjs → crashreport-eI7ty7ok.mjs} +1 -1
- package/dist/{errors-DfnF4ibq.mjs → errors-D7583Zz7.mjs} +2 -44
- package/dist/errors-D7583Zz7.mjs.map +1 -0
- package/dist/{globals-CBZ0egXT.mjs → globals-TfAVItuK.mjs} +21 -5
- package/dist/globals-TfAVItuK.mjs.map +1 -0
- package/dist/logger-BtX0suGY.mjs +48 -0
- package/dist/logger-BtX0suGY.mjs.map +1 -0
- package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
- package/dist/logger-CXQq9YIp.mjs.map +1 -0
- package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
- package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
- package/dist/plugin/builtin/enum-constants/index.mjs +115 -2
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -0
- package/dist/plugin/builtin/file-utils/index.mjs +149 -2
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +274 -2
- package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -0
- package/dist/plugin/builtin/seed/index.d.mts +3 -2
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +21 -0
- package/dist/plugin/builtin/seed/types.d.mts +2 -0
- package/dist/{register-ts-hook-DvEs6YsL.mjs → register-ts-hook-LYV7zH-e.mjs} +2953 -996
- package/dist/register-ts-hook-LYV7zH-e.mjs.map +1 -0
- package/dist/{registry-i7EdJ-D5.mjs → registry-BIGVUrMB.mjs} +3 -3
- package/dist/registry-BIGVUrMB.mjs.map +1 -0
- package/dist/runtime/globals.d.mts +7 -0
- package/dist/runtime/index.d.mts +3 -1
- package/dist/runtime/index.mjs +3 -2
- package/dist/runtime/logger.d.mts +98 -0
- package/dist/runtime/logger.mjs +3 -0
- package/dist/runtime/workflow.d.mts +15 -7
- package/dist/runtime/workflow.mjs +1 -1
- package/dist/seed-B-yckgQY.mjs +483 -0
- package/dist/seed-B-yckgQY.mjs.map +1 -0
- package/dist/{service-DaeJlBoH.mjs → service-B5WynBHQ.mjs} +3 -3
- package/dist/{service-DaeJlBoH.mjs.map → service-B5WynBHQ.mjs.map} +1 -1
- package/dist/service-M7OYziQP.mjs +3 -0
- package/dist/{service-Dmxa2I4i.mjs → service-k1xy_A5G.mjs} +30 -4
- package/dist/service-k1xy_A5G.mjs.map +1 -0
- package/dist/{service_pb-BoLM0X4K.mjs → service_pb-D5--My_M.mjs} +5 -5
- package/dist/service_pb-D5--My_M.mjs.map +1 -0
- package/dist/{service_pb-r1T7kpJc.mjs → service_pb-i8CmnQP4.mjs} +1 -1
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +106 -1
- package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +6 -1
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +24 -1
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +49 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +89 -6
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +26 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +101 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +22 -1
- package/dist/types/auth.generated.d.mts +14 -2
- package/dist/types/executor.generated.d.mts +45 -3
- package/dist/types/http-adapter.generated.d.mts +5 -0
- package/dist/types/idp.generated.d.mts +31 -1
- package/dist/types/resolver.generated.d.mts +30 -2
- package/dist/types/tailordb.generated.d.mts +15 -3
- package/dist/utils/test/index.d.mts +1 -2
- package/dist/utils/test/index.mjs +1 -169
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +6 -4
- package/dist/vitest/index.mjs +112 -62
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock.d.mts +2 -1
- package/dist/vitest/mocks/logger.d.mts +45 -0
- package/dist/vitest/mocks/workflow.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -1
- package/dist/{workflow-CsBvRE3g.mjs → workflow-Bamae_Yc.mjs} +5 -5
- package/dist/workflow-Bamae_Yc.mjs.map +1 -0
- package/dist/{workspace_resource_pb-Db3fv68L.mjs → workspace_resource_pb-DXnO2AT-.mjs} +13 -8
- package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
- package/docs/cli/application.md +5 -1
- package/docs/cli/tailordb.md +47 -13
- package/docs/cli-reference.md +38 -30
- package/docs/configuration.md +54 -2
- package/docs/github-actions.md +2 -2
- package/docs/migration/v2.md +408 -5
- package/docs/runtime.md +5 -1
- package/docs/services/executor.md +83 -3
- package/docs/services/idp.md +8 -6
- package/docs/services/resolver.md +60 -4
- package/docs/services/tailordb-migration.md +31 -7
- package/docs/services/tailordb.md +7 -5
- package/docs/services/workflow.md +33 -3
- package/docs/testing.md +34 -7
- package/package.json +31 -24
- package/dist/application-GzW98_Xr.mjs.map +0 -1
- package/dist/application-OM0taSPn.mjs +0 -3
- package/dist/cli/index.mjs.map +0 -1
- package/dist/enum-constants-j9QBF0cB.mjs +0 -116
- package/dist/enum-constants-j9QBF0cB.mjs.map +0 -1
- package/dist/errors-DfnF4ibq.mjs.map +0 -1
- package/dist/file-utils-yEiIS4nJ.mjs +0 -150
- package/dist/file-utils-yEiIS4nJ.mjs.map +0 -1
- package/dist/globals-CBZ0egXT.mjs.map +0 -1
- package/dist/kysely-type-DqIRgDYR.mjs +0 -275
- package/dist/kysely-type-DqIRgDYR.mjs.map +0 -1
- package/dist/logger-BwS4ppwO.mjs.map +0 -1
- package/dist/register-ts-hook-DvEs6YsL.mjs.map +0 -1
- package/dist/registry-i7EdJ-D5.mjs.map +0 -1
- package/dist/seed-CRSQJI_z.mjs +0 -1170
- package/dist/seed-CRSQJI_z.mjs.map +0 -1
- package/dist/service-BJAQ70e5.mjs +0 -3
- package/dist/service-Dmxa2I4i.mjs.map +0 -1
- package/dist/service_pb-BoLM0X4K.mjs.map +0 -1
- package/dist/utils/test/mock.d.mts +0 -86
- package/dist/workflow-CsBvRE3g.mjs.map +0 -1
- package/dist/workspace_resource_pb-Db3fv68L.mjs.map +0 -1
|
@@ -1,3 +1,275 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as multiline } from "../../../multiline-sfHpTZZK.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/plugin/builtin/kysely-type/type-processor.ts
|
|
4
|
+
/**
|
|
5
|
+
* Get the enum type definition.
|
|
6
|
+
* @param fieldConfig - The field configuration
|
|
7
|
+
* @returns The enum type as a string union
|
|
8
|
+
*/
|
|
9
|
+
function getEnumType(fieldConfig) {
|
|
10
|
+
const allowedValues = fieldConfig.allowedValues;
|
|
11
|
+
if (allowedValues && Array.isArray(allowedValues)) return allowedValues.map((v) => {
|
|
12
|
+
return `"${typeof v === "string" ? v : v.value}"`;
|
|
13
|
+
}).join(" | ");
|
|
14
|
+
return "string";
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get the nested object type definition.
|
|
18
|
+
* @param fieldConfig - The field configuration
|
|
19
|
+
* @returns The nested type with used utility types
|
|
20
|
+
*/
|
|
21
|
+
function getNestedType(fieldConfig) {
|
|
22
|
+
const fields = fieldConfig.fields;
|
|
23
|
+
if (!fields || typeof fields !== "object") return {
|
|
24
|
+
type: "string",
|
|
25
|
+
usedUtilityTypes: {
|
|
26
|
+
Timestamp: false,
|
|
27
|
+
Serial: false
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const fieldResults = Object.entries(fields).map(([fieldName, config]) => {
|
|
31
|
+
const result = generateFieldType(config);
|
|
32
|
+
return {
|
|
33
|
+
fieldType: `${fieldName}${config.required !== true ? "?" : ""}: ${result.type}`,
|
|
34
|
+
usedUtilityTypes: result.usedUtilityTypes
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
|
|
38
|
+
Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
|
|
39
|
+
Serial: acc.Serial || result.usedUtilityTypes.Serial
|
|
40
|
+
}), {
|
|
41
|
+
Timestamp: false,
|
|
42
|
+
Serial: false
|
|
43
|
+
});
|
|
44
|
+
const fieldTypes = fieldResults.map((r) => r.fieldType);
|
|
45
|
+
const obj = `{\n ${fieldTypes.join(";\n ")}${fieldTypes.length > 0 ? ";" : ""}\n}`;
|
|
46
|
+
const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);
|
|
47
|
+
const hasGeneratedFields = Object.values(fields).some((config) => config.hooks?.create || config.default !== void 0);
|
|
48
|
+
if (aggregatedUtilityTypes.Timestamp || hasOptionalFields || hasGeneratedFields) return {
|
|
49
|
+
type: `ObjectColumnType<${obj}>`,
|
|
50
|
+
usedUtilityTypes: aggregatedUtilityTypes
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
type: obj,
|
|
54
|
+
usedUtilityTypes: aggregatedUtilityTypes
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the base Kysely type for a field (without array/null modifiers).
|
|
59
|
+
* @param fieldConfig - The field configuration
|
|
60
|
+
* @returns The base type with used utility types
|
|
61
|
+
*/
|
|
62
|
+
function getBaseType(fieldConfig) {
|
|
63
|
+
const fieldType = fieldConfig.type;
|
|
64
|
+
const usedUtilityTypes = {
|
|
65
|
+
Timestamp: false,
|
|
66
|
+
Serial: false
|
|
67
|
+
};
|
|
68
|
+
let type;
|
|
69
|
+
switch (fieldType) {
|
|
70
|
+
case "uuid":
|
|
71
|
+
case "string":
|
|
72
|
+
case "decimal":
|
|
73
|
+
type = "string";
|
|
74
|
+
break;
|
|
75
|
+
case "integer":
|
|
76
|
+
case "float":
|
|
77
|
+
type = "number";
|
|
78
|
+
break;
|
|
79
|
+
case "date":
|
|
80
|
+
case "datetime":
|
|
81
|
+
usedUtilityTypes.Timestamp = true;
|
|
82
|
+
type = "Timestamp";
|
|
83
|
+
break;
|
|
84
|
+
case "bool":
|
|
85
|
+
case "boolean":
|
|
86
|
+
type = "boolean";
|
|
87
|
+
break;
|
|
88
|
+
case "enum":
|
|
89
|
+
type = getEnumType(fieldConfig);
|
|
90
|
+
break;
|
|
91
|
+
case "nested": return getNestedType(fieldConfig);
|
|
92
|
+
default:
|
|
93
|
+
type = "string";
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
type,
|
|
98
|
+
usedUtilityTypes
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generate the complete field type including array and null modifiers.
|
|
103
|
+
* @param fieldConfig - The field configuration
|
|
104
|
+
* @returns The complete field type with used utility types
|
|
105
|
+
*/
|
|
106
|
+
function generateFieldType(fieldConfig) {
|
|
107
|
+
const baseTypeResult = getBaseType(fieldConfig);
|
|
108
|
+
const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };
|
|
109
|
+
const isArray = fieldConfig.array === true;
|
|
110
|
+
const isNullable = fieldConfig.required !== true;
|
|
111
|
+
const isColumnTypeBase = (/* @__PURE__ */ new Set(["Timestamp"])).has(baseTypeResult.type);
|
|
112
|
+
let finalType = baseTypeResult.type;
|
|
113
|
+
if (isArray) if (isColumnTypeBase || finalType.startsWith("ObjectColumnType<")) finalType = `ArrayColumnType<${baseTypeResult.type}>`;
|
|
114
|
+
else finalType = fieldConfig.type === "enum" ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;
|
|
115
|
+
if (isNullable) finalType = `${finalType} | null`;
|
|
116
|
+
if (fieldConfig.serial) {
|
|
117
|
+
usedUtilityTypes.Serial = true;
|
|
118
|
+
finalType = `Serial<${finalType}>`;
|
|
119
|
+
}
|
|
120
|
+
if (fieldConfig.hooks?.create || fieldConfig.default !== void 0) finalType = `Generated<${finalType}>`;
|
|
121
|
+
return {
|
|
122
|
+
type: finalType,
|
|
123
|
+
usedUtilityTypes
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Generate the table interface.
|
|
128
|
+
* @param type - The parsed TailorDB type
|
|
129
|
+
* @returns The type definition and used utility types
|
|
130
|
+
*/
|
|
131
|
+
function generateTableInterface(type) {
|
|
132
|
+
const fieldResults = Object.entries(type.fields).filter(([fieldName]) => fieldName !== "id").map(([fieldName, parsedField]) => ({
|
|
133
|
+
fieldName,
|
|
134
|
+
...generateFieldType(parsedField.config)
|
|
135
|
+
}));
|
|
136
|
+
const fields = ["id: Generated<string>;", ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`)];
|
|
137
|
+
const aggregatedUtilityTypes = fieldResults.reduce((acc, result) => ({
|
|
138
|
+
Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,
|
|
139
|
+
Serial: acc.Serial || result.usedUtilityTypes.Serial
|
|
140
|
+
}), {
|
|
141
|
+
Timestamp: false,
|
|
142
|
+
Serial: false
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
typeDef: multiline`
|
|
146
|
+
${type.name}: {
|
|
147
|
+
${fields.join("\n")}
|
|
148
|
+
}
|
|
149
|
+
`,
|
|
150
|
+
usedUtilityTypes: aggregatedUtilityTypes
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Convert a TailorDBType into KyselyTypeMetadata.
|
|
155
|
+
* @param type - Parsed TailorDB type
|
|
156
|
+
* @returns Generated Kysely type metadata
|
|
157
|
+
*/
|
|
158
|
+
async function processKyselyType(type) {
|
|
159
|
+
const result = generateTableInterface(type);
|
|
160
|
+
return {
|
|
161
|
+
name: type.name,
|
|
162
|
+
typeDef: result.typeDef,
|
|
163
|
+
usedUtilityTypes: result.usedUtilityTypes
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Generate unified types file from multiple namespaces.
|
|
168
|
+
* @param namespaceData - Namespace metadata
|
|
169
|
+
* @returns Generated types file contents
|
|
170
|
+
*/
|
|
171
|
+
function generateUnifiedKyselyTypes(namespaceData) {
|
|
172
|
+
if (namespaceData.length === 0) return "";
|
|
173
|
+
const globalUsedUtilityTypes = namespaceData.reduce((acc, ns) => ({
|
|
174
|
+
Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,
|
|
175
|
+
Serial: acc.Serial || ns.usedUtilityTypes.Serial
|
|
176
|
+
}), {
|
|
177
|
+
Timestamp: false,
|
|
178
|
+
Serial: false
|
|
179
|
+
});
|
|
180
|
+
const utilityTypeImports = ["type Generated"];
|
|
181
|
+
if (globalUsedUtilityTypes.Timestamp) utilityTypeImports.push("type Timestamp");
|
|
182
|
+
if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ObjectColumnType<")))) utilityTypeImports.push("type ObjectColumnType");
|
|
183
|
+
if (namespaceData.some((ns) => ns.types.some((t) => t.typeDef.includes("ArrayColumnType<")))) utilityTypeImports.push("type ArrayColumnType");
|
|
184
|
+
if (globalUsedUtilityTypes.Serial) utilityTypeImports.push("type Serial");
|
|
185
|
+
return [
|
|
186
|
+
multiline`
|
|
187
|
+
import {
|
|
188
|
+
createGetDB,
|
|
189
|
+
${utilityTypeImports.join(",\n")},
|
|
190
|
+
type NamespaceDB,
|
|
191
|
+
type NamespaceInsertable,
|
|
192
|
+
type NamespaceSelectable,
|
|
193
|
+
type NamespaceTable,
|
|
194
|
+
type NamespaceTableName,
|
|
195
|
+
type NamespaceTransaction,
|
|
196
|
+
type NamespaceUpdateable,
|
|
197
|
+
} from "@tailor-platform/sdk/kysely";
|
|
198
|
+
`,
|
|
199
|
+
`export interface Namespace {\n${namespaceData.map(({ namespace, types }) => {
|
|
200
|
+
return ` "${namespace}": {\n${types.map((type) => {
|
|
201
|
+
return type.typeDef.split("\n").map((line) => line.trim() ? ` ${line}` : "").join("\n");
|
|
202
|
+
}).join("\n\n")}\n }`;
|
|
203
|
+
}).join(",\n")}\n}`,
|
|
204
|
+
multiline`
|
|
205
|
+
export const getDB = createGetDB<Namespace>();
|
|
206
|
+
|
|
207
|
+
export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
|
|
208
|
+
`,
|
|
209
|
+
multiline`
|
|
210
|
+
export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
|
|
211
|
+
NamespaceTransaction<Namespace, K>;
|
|
212
|
+
|
|
213
|
+
type TableName = NamespaceTableName<Namespace>;
|
|
214
|
+
export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
|
|
215
|
+
|
|
216
|
+
export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
|
|
217
|
+
export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
|
|
218
|
+
export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
|
|
219
|
+
`
|
|
220
|
+
].join("\n\n") + "\n";
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/plugin/builtin/kysely-type/index.ts
|
|
225
|
+
/** Unique identifier for the Kysely type generator plugin. */
|
|
226
|
+
const KyselyGeneratorID = "@tailor-platform/kysely-type";
|
|
227
|
+
/**
|
|
228
|
+
* Plugin that generates Kysely type definitions for TailorDB types.
|
|
229
|
+
* @param options - Plugin options
|
|
230
|
+
* @param options.distPath - Output file path for generated types
|
|
231
|
+
* @returns Plugin instance with onTailorDBReady hook
|
|
232
|
+
*/
|
|
233
|
+
function kyselyTypePlugin(options) {
|
|
234
|
+
return {
|
|
235
|
+
id: KyselyGeneratorID,
|
|
236
|
+
description: "Generates Kysely type definitions for TailorDB types",
|
|
237
|
+
pluginConfig: options,
|
|
238
|
+
async onTailorDBReady(ctx) {
|
|
239
|
+
const allNamespaceData = [];
|
|
240
|
+
for (const ns of ctx.tailordb) {
|
|
241
|
+
const typeMetadataList = [];
|
|
242
|
+
for (const type of Object.values(ns.types)) {
|
|
243
|
+
const metadata = await processKyselyType(type);
|
|
244
|
+
typeMetadataList.push(metadata);
|
|
245
|
+
}
|
|
246
|
+
if (typeMetadataList.length === 0) continue;
|
|
247
|
+
const usedUtilityTypes = typeMetadataList.reduce((acc, type) => ({
|
|
248
|
+
Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,
|
|
249
|
+
Serial: acc.Serial || type.usedUtilityTypes.Serial
|
|
250
|
+
}), {
|
|
251
|
+
Timestamp: false,
|
|
252
|
+
Serial: false
|
|
253
|
+
});
|
|
254
|
+
allNamespaceData.push({
|
|
255
|
+
namespace: ns.namespace,
|
|
256
|
+
types: typeMetadataList,
|
|
257
|
+
usedUtilityTypes
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
const files = [];
|
|
261
|
+
if (allNamespaceData.length > 0) {
|
|
262
|
+
const content = generateUnifiedKyselyTypes(allNamespaceData);
|
|
263
|
+
files.push({
|
|
264
|
+
path: ctx.pluginConfig.distPath,
|
|
265
|
+
content
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
return { files };
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
export { KyselyGeneratorID, kyselyTypePlugin };
|
|
275
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/plugin/builtin/kysely-type/type-processor.ts","../../../../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\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, config]) => {\n const result = generateFieldType(config);\n const optional = config.required !== true ? \"?\" : \"\";\n return {\n fieldType: `${fieldName}${optional}: ${result.type}`,\n usedUtilityTypes: result.usedUtilityTypes,\n };\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 fieldTypes = fieldResults.map((r) => r.fieldType);\n const obj = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n\n const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);\n const hasGeneratedFields = Object.values(fields).some(\n (config) => config.hooks?.create || config.default !== undefined,\n );\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields || hasGeneratedFields) {\n return { type: `ObjectColumnType<${obj}>`, usedUtilityTypes: aggregatedUtilityTypes };\n }\n return { type: obj, 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 // Types that use ColumnType internally (Timestamp, ObjectColumnType) cannot be\n // directly wrapped with [] for arrays, because Kysely only resolves ColumnType at\n // the top-level table property. Use ArrayColumnType/ObjectArrayColumnType to keep\n // the ColumnType at the top level with arrays inside.\n const columnTypeBaseTypes = new Set([\"Timestamp\"]);\n const isColumnTypeBase = columnTypeBaseTypes.has(baseTypeResult.type);\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n if (isColumnTypeBase || finalType.startsWith(\"ObjectColumnType<\")) {\n finalType = `ArrayColumnType<${baseTypeResult.type}>`;\n } else {\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\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 || fieldConfig.default !== undefined) {\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\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 const hasObjectColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ObjectColumnType<\")),\n );\n if (hasObjectColumnType) {\n utilityTypeImports.push(\"type ObjectColumnType\");\n }\n const hasArrayColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ArrayColumnType<\")),\n );\n if (hasArrayColumnType) {\n utilityTypeImports.push(\"type ArrayColumnType\");\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 { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\n\n/** Unique identifier for the Kysely type generator plugin. */\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":";;;;;;;;AAgBA,SAAS,YAAY,aAA0C;CAC7D,MAAM,gBAAgB,YAAY;CAElC,IAAI,iBAAiB,MAAM,QAAQ,aAAa,GAC9C,OAAO,cACJ,KAAK,MAAkC;EAEtC,OAAO,IADO,OAAO,MAAM,WAAW,IAAI,EAAE,MAC3B;CACnB,CAAC,CAAC,CACD,KAAK,KAAK;CAEf,OAAO;AACT;;;;;;AAOA,SAAS,cAAc,aAAmD;CACxE,MAAM,SAAS,YAAY;CAC3B,IAAI,CAAC,UAAU,OAAO,WAAW,UAC/B,OAAO;EACL,MAAM;EACN,kBAAkB;GAAE,WAAW;GAAO,QAAQ;EAAM;CACtD;CAGF,MAAM,eAAe,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,WAAW,YAAY;EACvE,MAAM,SAAS,kBAAkB,MAAM;EAEvC,OAAO;GACL,WAAW,GAAG,YAFC,OAAO,aAAa,OAAO,MAAM,GAEb,IAAI,OAAO;GAC9C,kBAAkB,OAAO;EAC3B;CACF,CAAC;CAED,MAAM,yBAAyB,aAAa,QACzC,KAAK,YAAY;EAChB,WAAW,IAAI,aAAa,OAAO,iBAAiB;EACpD,QAAQ,IAAI,UAAU,OAAO,iBAAiB;CAChD,IACA;EAAE,WAAW;EAAO,QAAQ;CAAM,CACpC;CAEA,MAAM,aAAa,aAAa,KAAK,MAAM,EAAE,SAAS;CACtD,MAAM,MAAM,QAAQ,WAAW,KAAK,OAAO,IAAI,WAAW,SAAS,IAAI,MAAM,GAAG;CAEhF,MAAM,oBAAoB,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,WAAW,OAAO,aAAa,IAAI;CACzF,MAAM,qBAAqB,OAAO,OAAO,MAAM,CAAC,CAAC,MAC9C,WAAW,OAAO,OAAO,UAAU,OA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AAQ;IAAM,CACpC;IAEA,iBAAiB,KAAK;KACpB,WAAW,GAAG;KACd,OAAO;KACP;IACF,CAAC;GACH;GAEA,MAAM,QAAkC,CAAC;GACzC,IAAI,iBAAiB,SAAS,GAAG;IAC/B,MAAM,UAAU,2BAA2B,gBAAgB;IAC3D,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;IACF,CAAC;GACH;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
|
|
@@ -33,7 +33,8 @@ type SeedPluginOptions = {
|
|
|
33
33
|
disableIdpUserSync?: DisableIdpUserSyncDirections;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
|
-
* Plugin that generates seed data
|
|
36
|
+
* Plugin that generates seed data and schema files consumed by the
|
|
37
|
+
* `tailor seed` commands (@tailor-platform/sdk-plugin-seed).
|
|
37
38
|
* @param options - Plugin options
|
|
38
39
|
* @param options.distPath - Output directory path for generated seed files
|
|
39
40
|
* @param options.machineUserName - Default machine user name for authentication
|
|
@@ -42,4 +43,4 @@ type SeedPluginOptions = {
|
|
|
42
43
|
*/
|
|
43
44
|
declare function seedPlugin(options: SeedPluginOptions): Plugin<unknown, SeedPluginOptions>;
|
|
44
45
|
//#endregion
|
|
45
|
-
export { SeedGeneratorID, seedPlugin };
|
|
46
|
+
export { SeedGeneratorID, SeedPluginOptions, seedPlugin };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "../../../parser/service/tailordb/types.mjs";
|
|
2
|
+
import "../../types.mjs";
|
|
3
|
+
import "./types.mjs";
|
|
4
|
+
//#region src/plugin/builtin/seed/seed-type-processor.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Seed ordering information for a TailorDB namespace.
|
|
7
|
+
*/
|
|
8
|
+
interface SeedNamespaceConfig {
|
|
9
|
+
/** TailorDB namespace name. */
|
|
10
|
+
namespace: string;
|
|
11
|
+
/** Type names in the namespace, in definition order. */
|
|
12
|
+
types: string[];
|
|
13
|
+
/** Seed dependencies (referenced type names) per type. */
|
|
14
|
+
dependencies: Record<string, string[]>;
|
|
15
|
+
/** Types with self-referencing fields, seeded in two passes. */
|
|
16
|
+
selfRefTypes: string[];
|
|
17
|
+
/** Field names a seed row must supply per type, enforced with `--upsert`. */
|
|
18
|
+
requiredFields: Record<string, string[]>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SeedNamespaceConfig };
|