@tailor-platform/sdk 1.84.0 → 1.85.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 +26 -0
- package/dist/application-C-zsrNjn.mjs +3 -0
- package/dist/{application-CnCljDwk.mjs → application-m5tYtz0-.mjs} +235 -62
- package/dist/application-m5tYtz0-.mjs.map +1 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +1 -0
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
- package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
- package/dist/cli/index.mjs +229 -22
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.mjs +92 -36
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/completion/zsh-worker.zsh +52 -2
- package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
- package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/{register-typescript-runtime-BCvWR3HC.mjs → register-typescript-runtime-nG-n9lPw.mjs} +336 -268
- package/dist/register-typescript-runtime-nG-n9lPw.mjs.map +1 -0
- package/dist/{seed-DFFigL8V.mjs → seed-6eTFj-3Q.mjs} +158 -41
- package/dist/seed-6eTFj-3Q.mjs.map +1 -0
- package/dist/vitest/index.mjs +3 -35
- package/dist/vitest/index.mjs.map +1 -1
- package/docs/cli/tailordb.md +29 -7
- package/docs/cli-reference.md +16 -15
- package/docs/generator/builtin.md +7 -0
- package/docs/services/tailordb-migration.md +11 -2
- package/package.json +7 -8
- package/dist/application-5FOWIxFQ.mjs +0 -3
- package/dist/application-CnCljDwk.mjs.map +0 -1
- package/dist/register-typescript-runtime-BCvWR3HC.mjs.map +0 -1
- package/dist/seed-DFFigL8V.mjs.map +0 -1
package/dist/cli/lib.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
|
|
2
|
-
import { $ as listFolders, A as generate$1, An as
|
|
3
|
-
import {
|
|
2
|
+
import { $ as listFolders, A as generate$1, An as hasChanges, B as remove, Bt as deploy, C as waitWorkflowExecution, D as listWorkflows, Et as getExecutorWaitFailureMessage, Fn as generateUserTypes, Ft as getWorkflowExecution, Gt as createWorkspace, I as show, It as listWorkflowExecutions, Jn as loadWorkspaceId, Ln as apiCall, Nt as getWorkflow, O as truncate, On as formatDiffSummary, Ot as listExecutorJobs, Sn as getNextMigrationNumber, St as triggerExecutor, T as resumeWorkflow, Tn as reconstructSnapshotFromMigrations, Tt as getExecutorJob, U as updateOrganization, Ut as listWorkspaces, W as organizationTree, Wn as loadAccessToken, Xt as waitForExecution, Y as getOrganization, Yt as executeScript, Z as updateFolder, Zt as bundleMigrationScript, _ as deleteWorkspace, a as updateUser, at as createFolder, b as getAppHealth, bn as getMigrationFilePath, cn as DB_TYPES_FILE_NAME, d as inviteUser, dn as MIGRATE_FILE_NAME, fn as SCHEMA_FILE_NAME, gn as createSnapshotFromLocalTypes, gt as listFunctionRegistries, h as getWorkspace, hn as compareSnapshots, jn as getNamespacesWithMigrations, jt as startWorkflow, kn as formatMigrationDiff, kt as watchExecutorJob, l as listUsers, ln as DIFF_FILE_NAME, lt as getOAuth2Client, mn as compareLocalTypesWithSnapshot, mt as generate, n as query, nn as MIGRATION_LABEL_KEY, p as restoreWorkspace, pt as listMachineUsers, q as listOrganizations, rt as deleteFolder, s as removeUser, st as listOAuth2Clients, t as registerTypeScriptRuntime, tt as getFolder, un as INITIAL_SCHEMA_NUMBER, ut as getMachineUserToken, v as listApps, vn as getLatestMigrationNumber, vt as getFunctionRegistry, wt as listExecutors, xn as getMigrationFiles, yn as getMigrationDirPath, yt as listWebhookExecutors, zn as loadConfig, zt as getExecutor } from "../register-typescript-runtime-nG-n9lPw.mjs";
|
|
3
|
+
import { G as initOperatorClient, T as createBundleLog, k as getDistDir, v as createGeneratedEntryResolverPlugin, x as platformBundleDefinePlugin, y as createTsconfigPathsPlugin } from "../application-m5tYtz0-.mjs";
|
|
4
4
|
import { n as enumConstantsPlugin } from "../enum-constants-j9QBF0cB.mjs";
|
|
5
5
|
import { t as multiline } from "../multiline-sfHpTZZK.mjs";
|
|
6
6
|
import { n as fileUtilsPlugin } from "../file-utils-DcyIPFQh.mjs";
|
|
7
7
|
import { n as kyselyTypePlugin } from "../kysely-type-D-zflMGf.mjs";
|
|
8
|
-
import { n as seedPlugin } from "../seed-
|
|
8
|
+
import { n as seedPlugin } from "../seed-6eTFj-3Q.mjs";
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "pathe";
|
|
11
11
|
import { resolveTSConfig } from "pkg-types";
|
|
@@ -164,11 +164,12 @@ function generateSeedScriptContent(namespace) {
|
|
|
164
164
|
data: Record<string, Record<string, unknown>[]>;
|
|
165
165
|
order: string[];
|
|
166
166
|
selfRefTypes: string[];
|
|
167
|
+
upsert?: boolean;
|
|
167
168
|
};
|
|
168
169
|
|
|
169
170
|
type SeedResult = {
|
|
170
171
|
success: boolean;
|
|
171
|
-
processed: Record<string, number>;
|
|
172
|
+
processed: Record<string, { inserted: number; updated: number; skipped: number }>;
|
|
172
173
|
errors: string[];
|
|
173
174
|
};
|
|
174
175
|
|
|
@@ -181,9 +182,13 @@ function generateSeedScriptContent(namespace) {
|
|
|
181
182
|
|
|
182
183
|
export async function main(input: SeedInput): Promise<SeedResult> {
|
|
183
184
|
const db = getDB("${namespace}");
|
|
184
|
-
const processed: Record<
|
|
185
|
+
const processed: Record<
|
|
186
|
+
string,
|
|
187
|
+
{ inserted: number; updated: number; skipped: number }
|
|
188
|
+
> = {};
|
|
185
189
|
const errors: string[] = [];
|
|
186
190
|
const BATCH_SIZE = ${String(BATCH_SIZE)};
|
|
191
|
+
const upsert = input.upsert === true;
|
|
187
192
|
|
|
188
193
|
for (const typeName of input.order) {
|
|
189
194
|
const records = input.data[typeName];
|
|
@@ -192,25 +197,68 @@ function generateSeedScriptContent(namespace) {
|
|
|
192
197
|
continue;
|
|
193
198
|
}
|
|
194
199
|
|
|
195
|
-
processed[typeName] = 0;
|
|
200
|
+
processed[typeName] = { inserted: 0, updated: 0, skipped: 0 };
|
|
196
201
|
const hasSelfRef = (input.selfRefTypes || []).includes(typeName);
|
|
197
202
|
|
|
198
203
|
try {
|
|
204
|
+
let recordsToInsert = records;
|
|
205
|
+
let recordsToUpdate: Record<string, unknown>[] = [];
|
|
206
|
+
if (upsert) {
|
|
207
|
+
const existing = await db
|
|
208
|
+
.selectFrom(typeName)
|
|
209
|
+
.select("id")
|
|
210
|
+
.where(
|
|
211
|
+
"id",
|
|
212
|
+
"in",
|
|
213
|
+
records.map((record) => record.id),
|
|
214
|
+
)
|
|
215
|
+
.execute();
|
|
216
|
+
const existingIds = new Set(existing.map((record) => record.id));
|
|
217
|
+
recordsToInsert = records.filter((record) => !existingIds.has(record.id));
|
|
218
|
+
recordsToUpdate = records.filter((record) => existingIds.has(record.id));
|
|
219
|
+
}
|
|
220
|
+
|
|
199
221
|
if (hasSelfRef) {
|
|
200
222
|
// Insert one-by-one to respect self-referencing foreign key order
|
|
201
|
-
for (const record of
|
|
223
|
+
for (const record of recordsToInsert) {
|
|
202
224
|
await db.insertInto(typeName).values(record).execute();
|
|
203
|
-
processed[typeName] += 1;
|
|
225
|
+
processed[typeName].inserted += 1;
|
|
226
|
+
}
|
|
227
|
+
if (!upsert) {
|
|
228
|
+
console.log(
|
|
229
|
+
\`[${namespace}] \${typeName}: \${processed[typeName].inserted}/\${records.length} (one-by-one)\`,
|
|
230
|
+
);
|
|
204
231
|
}
|
|
205
|
-
console.log(\`[${namespace}] \${typeName}: \${processed[typeName]}/\${records.length} (one-by-one)\`);
|
|
206
232
|
} else {
|
|
207
|
-
for (let i = 0; i <
|
|
208
|
-
const batch =
|
|
233
|
+
for (let i = 0; i < recordsToInsert.length; i += BATCH_SIZE) {
|
|
234
|
+
const batch = recordsToInsert.slice(i, i + BATCH_SIZE);
|
|
209
235
|
await db.insertInto(typeName).values(batch).execute();
|
|
210
|
-
processed[typeName] += batch.length;
|
|
211
|
-
|
|
236
|
+
processed[typeName].inserted += batch.length;
|
|
237
|
+
if (!upsert) {
|
|
238
|
+
console.log(
|
|
239
|
+
\`[${namespace}] \${typeName}: \${processed[typeName].inserted}/\${records.length}\`,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
212
242
|
}
|
|
213
243
|
}
|
|
244
|
+
|
|
245
|
+
for (const record of recordsToUpdate) {
|
|
246
|
+
const { id, ...values } = record;
|
|
247
|
+
if (Object.keys(values).length === 0) {
|
|
248
|
+
processed[typeName].skipped += 1;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
await db.updateTable(typeName).set(values).where("id", "=", id).execute();
|
|
252
|
+
processed[typeName].updated += 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const counts = processed[typeName];
|
|
256
|
+
if (upsert) {
|
|
257
|
+
const skipped = counts.skipped > 0 ? \`, \${counts.skipped} skipped\` : "";
|
|
258
|
+
console.log(
|
|
259
|
+
\`[${namespace}] \${typeName}: \${counts.inserted} inserted, \${counts.updated} updated\${skipped}\`,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
214
262
|
} catch (error) {
|
|
215
263
|
const message = error instanceof Error ? error.message : String(error);
|
|
216
264
|
errors.push(\`\${typeName}: \${message}\`);
|
|
@@ -236,9 +284,10 @@ function generateSeedScriptContent(namespace) {
|
|
|
236
284
|
* 4. Exports as main() for TestExecScript
|
|
237
285
|
* @param namespace - TailorDB namespace
|
|
238
286
|
* @param typeNames - List of type names to include in the seed
|
|
287
|
+
* @param baseDir - Directory whose dependencies and tsconfig the generated entry uses
|
|
239
288
|
* @returns Bundled seed script result
|
|
240
289
|
*/
|
|
241
|
-
async function bundleSeedScript(namespace, typeNames) {
|
|
290
|
+
async function bundleSeedScript(namespace, typeNames, baseDir = process.cwd()) {
|
|
242
291
|
const outputDir = path.resolve(getDistDir(), "seed");
|
|
243
292
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
244
293
|
const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);
|
|
@@ -246,33 +295,40 @@ async function bundleSeedScript(namespace, typeNames) {
|
|
|
246
295
|
fs.writeFileSync(entryPath, entryContent);
|
|
247
296
|
let tsconfig;
|
|
248
297
|
try {
|
|
249
|
-
tsconfig = await resolveTSConfig();
|
|
298
|
+
tsconfig = await resolveTSConfig(baseDir);
|
|
250
299
|
} catch {
|
|
251
300
|
tsconfig = void 0;
|
|
252
301
|
}
|
|
302
|
+
const bundleLog = createBundleLog({ tsconfig });
|
|
303
|
+
const result = await rolldown.build({
|
|
304
|
+
plugins: [
|
|
305
|
+
createGeneratedEntryResolverPlugin(entryPath, baseDir),
|
|
306
|
+
createTsconfigPathsPlugin(),
|
|
307
|
+
platformBundleDefinePlugin
|
|
308
|
+
],
|
|
309
|
+
input: entryPath,
|
|
310
|
+
write: false,
|
|
311
|
+
output: {
|
|
312
|
+
format: "esm",
|
|
313
|
+
sourcemap: false,
|
|
314
|
+
minify: false,
|
|
315
|
+
codeSplitting: false,
|
|
316
|
+
globals: { tailordb: "tailordb" }
|
|
317
|
+
},
|
|
318
|
+
external: ["tailordb"],
|
|
319
|
+
resolve: { conditionNames: ["node", "import"] },
|
|
320
|
+
tsconfig,
|
|
321
|
+
treeshake: {
|
|
322
|
+
moduleSideEffects: false,
|
|
323
|
+
annotations: true,
|
|
324
|
+
unknownGlobalSideEffects: false
|
|
325
|
+
},
|
|
326
|
+
...bundleLog.options
|
|
327
|
+
});
|
|
328
|
+
bundleLog.assertAllResolved();
|
|
253
329
|
return {
|
|
254
330
|
namespace,
|
|
255
|
-
bundledCode:
|
|
256
|
-
plugins: [platformBundleDefinePlugin],
|
|
257
|
-
input: entryPath,
|
|
258
|
-
write: false,
|
|
259
|
-
output: {
|
|
260
|
-
format: "esm",
|
|
261
|
-
sourcemap: false,
|
|
262
|
-
minify: false,
|
|
263
|
-
codeSplitting: false,
|
|
264
|
-
globals: { tailordb: "tailordb" }
|
|
265
|
-
},
|
|
266
|
-
external: ["tailordb"],
|
|
267
|
-
resolve: { conditionNames: ["node", "import"] },
|
|
268
|
-
tsconfig,
|
|
269
|
-
treeshake: {
|
|
270
|
-
moduleSideEffects: false,
|
|
271
|
-
annotations: true,
|
|
272
|
-
unknownGlobalSideEffects: false
|
|
273
|
-
},
|
|
274
|
-
logLevel: "silent"
|
|
275
|
-
})).output[0].code,
|
|
331
|
+
bundledCode: result.output[0].code,
|
|
276
332
|
typesIncluded: typeNames
|
|
277
333
|
};
|
|
278
334
|
}
|
package/dist/cli/lib.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.mjs","names":[],"sources":["../../src/cli/shared/seed-chunker.ts","../../src/cli/commands/generate/seed/bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\n * Seed data chunker for splitting large seed data into manageable message sizes.\n *\n * When seed data exceeds the gRPC message size limit, this module splits the data\n * into multiple chunks at type boundaries (or record boundaries for large types).\n */\n\nimport { assertDefined } from \"#/utils/assert\";\n\n/**\n * Seed data keyed by type name, with an array of records per type.\n */\nexport type SeedData = Record<string, Record<string, unknown>[]>;\n\n/**\n * A single chunk of seed data with metadata for ordered execution.\n */\nexport type SeedChunk = {\n data: SeedData;\n order: string[];\n index: number;\n total: number;\n};\n\n/**\n * Options for chunking seed data.\n */\nexport type ChunkSeedDataOptions = {\n /** Seed data keyed by type name */\n data: SeedData;\n /** Ordered list of type names (dependency order) */\n order: string[];\n /** Byte size of the bundled seed script code */\n codeByteSize: number;\n /** Maximum gRPC message size in bytes (default: 3.5MB) */\n maxMessageSize?: number;\n};\n\n/** Default maximum message size: 3.5MB (conservative limit for gRPC) */\nexport const DEFAULT_MAX_MESSAGE_SIZE = 3.5 * 1024 * 1024;\n\n/** Reserved bytes for message metadata overhead */\nconst METADATA_OVERHEAD = 1024;\n\n/**\n * Split seed data into chunks that fit within the gRPC message size limit.\n *\n * Algorithm:\n * 1. Calculate the available budget for the arg field (maxMessageSize - codeByteSize - overhead)\n * 2. If all data fits in one message, return a single chunk\n * 3. Otherwise, iterate through types in dependency order:\n * - If a type fits in the current chunk, add it\n * - If adding a type would exceed the budget, finalize the current chunk and start a new one\n * - If a single type exceeds the budget, split its records across multiple chunks\n * - If a single record exceeds the budget, throw an error\n * @param options - Chunking options\n * @returns Array of seed chunks\n */\nexport function chunkSeedData(options: ChunkSeedDataOptions): SeedChunk[] {\n const { data, order, codeByteSize, maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE } = options;\n\n const argBudget = maxMessageSize - codeByteSize - METADATA_OVERHEAD;\n if (argBudget <= 0) {\n throw new Error(\n `Code size (${codeByteSize} bytes) exceeds the message size limit (${maxMessageSize} bytes). ` +\n `No space left for seed data.`,\n );\n }\n\n // Filter to types that have data\n const typesWithData = order.filter((type) => (data[type]?.length ?? 0) > 0);\n\n if (typesWithData.length === 0) {\n return [];\n }\n\n // Check if all data fits in a single message\n const fullArg = JSON.stringify({ data, order });\n if (byteSize(fullArg) <= argBudget) {\n return [{ data, order, index: 0, total: 1 }];\n }\n\n // Split into multiple chunks\n const chunks: Omit<SeedChunk, \"total\">[] = [];\n let currentData: SeedData = {};\n let currentOrder: string[] = [];\n\n for (const type of typesWithData) {\n const typeRecords = assertDefined(data[type], `seed data missing for type: ${type}`);\n\n // Check if the type fits in the current chunk\n if (currentOrder.length > 0) {\n const testData = { ...currentData, [type]: typeRecords };\n const testOrder = [...currentOrder, type];\n if (byteSize(JSON.stringify({ data: testData, order: testOrder })) > argBudget) {\n // Finalize the current chunk\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n }\n\n // Check if the entire type fits in an empty chunk\n if (byteSize(JSON.stringify({ data: { [type]: typeRecords }, order: [type] })) <= argBudget) {\n currentData[type] = typeRecords;\n currentOrder.push(type);\n continue;\n }\n\n // Type is too large — split by records\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n\n let recordBatch: Record<string, unknown>[] = [];\n for (const record of typeRecords) {\n if (byteSize(JSON.stringify({ data: { [type]: [record] }, order: [type] })) > argBudget) {\n const singleRecordSize = byteSize(JSON.stringify(record));\n throw new Error(\n `A single record in type \"${type}\" (${singleRecordSize} bytes) exceeds the message size budget ` +\n `(${argBudget} bytes). Consider increasing maxMessageSize or reducing the record size.`,\n );\n }\n\n const testBatch = [...recordBatch, record];\n const testData = { ...currentData, [type]: testBatch };\n const testOrder = currentOrder.includes(type) ? currentOrder : [...currentOrder, type];\n const testSize = byteSize(JSON.stringify({ data: testData, order: testOrder }));\n\n if (testSize > argBudget && recordBatch.length > 0) {\n // Finalize current chunk with accumulated records\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n recordBatch = [record];\n } else {\n recordBatch = testBatch;\n }\n }\n\n // Add remaining records\n if (recordBatch.length > 0) {\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n }\n }\n\n // Finalize the last chunk\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n }\n\n const total = chunks.length;\n return chunks.map((chunk) => ({ ...chunk, total }));\n}\n\nfunction byteSize(str: string): number {\n return new TextEncoder().encode(str).length;\n}\n","/**\n * Seed script bundler for TailorDB seed data\n *\n * Bundles seed scripts to be executed via TestExecScript API\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"#/cli/shared/dist-dir\";\nimport { platformBundleDefinePlugin } from \"#/cli/shared/platform-bundle-plugin\";\nimport ml from \"#/utils/multiline\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst BATCH_SIZE = 100;\n\n/**\n * Generate seed script content for server-side execution\n * @param namespace - TailorDB namespace\n * @returns Generated seed script content\n */\nfunction generateSeedScriptContent(namespace: string): string {\n return ml /* ts */ `\n import { Kysely, TailordbDialect } from \"@tailor-platform/sdk/kysely\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: string[];\n selfRefTypes: string[];\n };\n\n type SeedResult = {\n success: boolean;\n processed: Record<string, number>;\n errors: string[];\n };\n\n function getDB(namespace: string) {\n const client = new tailordb.Client({ namespace });\n return new Kysely<Record<string, Record<string, unknown>>>({\n dialect: new TailordbDialect(client),\n });\n }\n\n export async function main(input: SeedInput): Promise<SeedResult> {\n const db = getDB(\"${namespace}\");\n const processed: Record<string, number> = {};\n const errors: string[] = [];\n const BATCH_SIZE = ${String(BATCH_SIZE)};\n\n for (const typeName of input.order) {\n const records = input.data[typeName];\n if (!records || records.length === 0) {\n console.log(\\`[${namespace}] \\${typeName}: skipped (no data)\\`);\n continue;\n }\n\n processed[typeName] = 0;\n const hasSelfRef = (input.selfRefTypes || []).includes(typeName);\n\n try {\n if (hasSelfRef) {\n // Insert one-by-one to respect self-referencing foreign key order\n for (const record of records) {\n await db.insertInto(typeName).values(record).execute();\n processed[typeName] += 1;\n }\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length} (one-by-one)\\`);\n } else {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await db.insertInto(typeName).values(batch).execute();\n processed[typeName] += batch.length;\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length}\\`);\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`\\${typeName}: \\${message}\\`);\n console.error(\\`[${namespace}] \\${typeName}: failed - \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n errors,\n };\n }\n `;\n}\n\n/**\n * Bundle a seed script for server-side execution\n *\n * Creates an entry that:\n * 1. Defines getDB() function inline\n * 2. Processes data in batches using Kysely\n * 3. Reports progress via console.log\n * 4. Exports as main() for TestExecScript\n * @param namespace - TailorDB namespace\n * @param typeNames - List of type names to include in the seed\n * @returns Bundled seed script result\n */\nexport async function bundleSeedScript(\n namespace: string,\n typeNames: string[],\n): Promise<SeedBundleResult> {\n // Output directory in .tailor-sdk (relative to project root)\n const outputDir = path.resolve(getDistDir(), \"seed\");\n fs.mkdirSync(outputDir, { recursive: true });\n\n // Entry file in output directory\n const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);\n\n // Generate seed script content\n const entryContent = generateSeedScriptContent(namespace);\n fs.writeFileSync(entryPath, entryContent);\n\n let tsconfig: string | undefined;\n try {\n tsconfig = await resolveTSConfig();\n } catch {\n tsconfig = undefined;\n }\n\n // Bundle with tree-shaking (write: false to avoid unnecessary disk I/O)\n const result = await rolldown.build({\n plugins: [platformBundleDefinePlugin],\n input: entryPath,\n write: false,\n output: {\n format: \"esm\",\n sourcemap: false,\n minify: false,\n codeSplitting: false,\n globals: {\n tailordb: \"tailordb\",\n },\n },\n external: [\"tailordb\"],\n resolve: {\n conditionNames: [\"node\", \"import\"],\n },\n tsconfig,\n treeshake: {\n moduleSideEffects: false,\n annotations: true,\n unknownGlobalSideEffects: false,\n },\n logLevel: \"silent\",\n } as rolldown.BuildOptions);\n\n const bundledCode = result.output[0].code;\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { registerTypeScriptRuntime } from \"./shared/register-typescript-runtime\";\n\nawait registerTypeScriptRuntime(new URL(\"./tsconfig-paths-hook.mjs\", import.meta.url));\n\nexport { deploy, deploy as apply } from \"./commands/deploy/deploy\";\nexport type { DeployOptions, DeployOptions as ApplyOptions } from \"./commands/deploy/deploy\";\nexport type { BundledScripts } from \"./commands/deploy/function-registry\";\nexport { generate } from \"./commands/generate/service\";\nexport type { GenerateOptions } from \"./commands/generate/options\";\nexport { loadConfig, type LoadedConfig } from \"./shared/config-loader\";\nexport { generateUserTypes } from \"./shared/type-generator\";\nexport type {\n CodeGenerator,\n TailorDBGenerator,\n ResolverGenerator,\n ExecutorGenerator,\n TailorDBResolverGenerator,\n FullCodeGenerator,\n TailorDBInput,\n ResolverInput,\n ExecutorInput,\n FullInput,\n AggregateArgs,\n GeneratorResult,\n DependencyKind,\n PluginAttachment,\n TypeSourceInfoEntry,\n} from \"./commands/generate/types\";\nexport type { TailorDBType } from \"#/parser/service/tailordb/types\";\nexport type { Resolver } from \"#/types/resolver.generated\";\nexport type { Executor } from \"#/types/executor.generated\";\n\n/** @deprecated Import from '@tailor-platform/sdk/plugin/kysely-type' instead */\nexport { kyselyTypePlugin } from \"#/plugin/builtin/kysely-type/index\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"#/plugin/builtin/enum-constants/index\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"#/plugin/builtin/file-utils/index\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"#/plugin/builtin/seed/index\";\n\nexport {\n show,\n type ShowOptions,\n type ApplicationInfo,\n type ShowInfo,\n type AIGatewayInfo,\n} from \"./commands/show\";\nexport { remove, type RemoveOptions } from \"./commands/remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./commands/workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./commands/workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./commands/workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./commands/workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./commands/workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./commands/workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./commands/workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./commands/workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./commands/workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./commands/workspace/user/remove\";\nexport type { UserInfo } from \"./commands/workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./commands/workspace/app/list\";\nexport {\n getAppHealth,\n type HealthOptions as GetAppHealthOptions,\n} from \"./commands/workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./commands/workspace/app/transform\";\nexport { getFunctionRegistry, type GetFunctionRegistryOptions } from \"./commands/function/get\";\nexport {\n listFunctionRegistries,\n type ListFunctionRegistriesOptions,\n} from \"./commands/function/list\";\nexport type { FunctionRegistryInfo } from \"./commands/function/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./commands/machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./commands/machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./commands/oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./commands/oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./commands/oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./commands/workflow/list\";\nexport {\n getWorkflow,\n type GetWorkflowOptions,\n type GetWorkflowTypedOptions,\n} from \"./commands/workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowTypedOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./commands/workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type ListWorkflowExecutionsTypedOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n type WorkflowExecutionWaitInfo,\n} from \"./commands/workflow/executions\";\nexport { waitWorkflowExecution, type WorkflowWaitOutput } from \"./commands/workflow/wait\";\nexport type { WaitWorkflowExecutionOptions, WorkflowWaitResult } from \"./commands/workflow/waiter\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./commands/workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./commands/workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorTypedOptions,\n type TriggerExecutorResult,\n} from \"./commands/executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n getExecutorWaitFailureMessage,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type ListExecutorJobsTypedOptions,\n type GetExecutorJobOptions,\n type GetExecutorJobTypedOptions,\n type WatchExecutorJobOptions,\n type WatchExecutorJobTypedOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./commands/executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./commands/executor/list\";\nexport {\n getExecutor,\n type GetExecutorOptions,\n type GetExecutorTypedOptions,\n} from \"./commands/executor/get\";\nexport {\n listWebhookExecutors,\n type ListWebhookExecutorsOptions,\n type WebhookExecutorInfo,\n} from \"./commands/executor/webhook\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n ExecutorListInfo,\n ExecutorInfo,\n} from \"./commands/executor/transform\";\nexport { listOrganizations, type ListOrganizationsOptions } from \"./commands/organization/list\";\nexport { getOrganization, type GetOrganizationOptions } from \"./commands/organization/get\";\nexport { updateOrganization, type UpdateOrganizationOptions } from \"./commands/organization/update\";\nexport { organizationTree, type OrganizationTreeOptions } from \"./commands/organization/tree\";\nexport type {\n UserOrganizationInfo,\n OrganizationInfo,\n FolderListInfo,\n FolderInfo,\n} from \"./commands/organization/transform\";\nexport { listFolders, type ListFoldersOptions } from \"./commands/organization/folder/list\";\nexport { getFolder, type GetFolderOptions } from \"./commands/organization/folder/get\";\nexport { createFolder, type CreateFolderOptions } from \"./commands/organization/folder/create\";\nexport { updateFolder, type UpdateFolderOptions } from \"./commands/organization/folder/update\";\nexport { deleteFolder, type DeleteFolderOptions } from \"./commands/organization/folder/delete\";\nexport { loadAccessToken, loadWorkspaceId } from \"./shared/context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./commands/api\";\nexport { query } from \"./query\";\nexport { truncate, type TruncateOptions } from \"./commands/tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./commands/tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./commands/tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./commands/tailordb/migrate/diff-calculator\";\nexport {\n SCHEMA_FILE_NAME,\n DIFF_FILE_NAME,\n MIGRATE_FILE_NAME,\n DB_TYPES_FILE_NAME,\n INITIAL_SCHEMA_NUMBER,\n getMigrationDirPath,\n getMigrationFilePath,\n type SchemaSnapshot,\n type NormalizedSchemaSnapshot,\n type TailorDBSnapshotType,\n type SnapshotFieldConfig,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./commands/tailordb/migrate/types\";\n\n// Seed exports\nexport { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./shared/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./commands/generate/seed/bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./commands/tailordb/migrate/bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./shared/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./shared/client\";\nexport type { AuthInvoker } from \"@tailor-platform/tailor-proto/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;CAClD,IAAI,aAAa,GACf,MAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,sCAEtF;CAIF,MAAM,gBAAgB,MAAM,QAAQ,UAAU,KAAK,KAAK,EAAE,UAAU,KAAK,CAAC;CAE1E,IAAI,cAAc,WAAW,GAC3B,OAAO,CAAC;CAKV,IAAI,SADY,KAAK,UAAU;EAAE;EAAM;CAAM,CAC1B,CAAC,KAAK,WACvB,OAAO,CAAC;EAAE;EAAM;EAAO,OAAO;EAAG,OAAO;CAAE,CAAC;CAI7C,MAAM,SAAqC,CAAC;CAC5C,IAAI,cAAwB,CAAC;CAC7B,IAAI,eAAyB,CAAC;CAE9B,KAAK,MAAM,QAAQ,eAAe;EAChC,MAAM,cAAc,cAAc,KAAK,OAAO,+BAA+B,MAAM;EAGnF,IAAI,aAAa,SAAS,GAAG;GAC3B,MAAM,WAAW;IAAE,GAAG;KAAc,OAAO;GAAY;GACvD,MAAM,YAAY,CAAC,GAAG,cAAc,IAAI;GACxC,IAAI,SAAS,KAAK,UAAU;IAAE,MAAM;IAAU,OAAO;GAAU,CAAC,CAAC,IAAI,WAAW;IAE9E,OAAO,KAAK;KAAE,MAAM;KAAa,OAAO;KAAc,OAAO,OAAO;IAAO,CAAC;IAC5E,cAAc,CAAC;IACf,eAAe,CAAC;GAClB;EACF;EAGA,IAAI,SAAS,KAAK,UAAU;GAAE,MAAM,GAAG,OAAO,YAAY;GAAG,OAAO,CAAC,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ACnKA,MAAM,0BAA0B,IAAI,IAAI,6BAA6B,OAAO,KAAK,GAAG,CAAC"}
|
|
1
|
+
{"version":3,"file":"lib.mjs","names":[],"sources":["../../src/cli/shared/seed-chunker.ts","../../src/cli/commands/generate/seed/bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\n * Seed data chunker for splitting large seed data into manageable message sizes.\n *\n * When seed data exceeds the gRPC message size limit, this module splits the data\n * into multiple chunks at type boundaries (or record boundaries for large types).\n */\n\nimport { assertDefined } from \"#/utils/assert\";\n\n/**\n * Seed data keyed by type name, with an array of records per type.\n */\nexport type SeedData = Record<string, Record<string, unknown>[]>;\n\n/**\n * A single chunk of seed data with metadata for ordered execution.\n */\nexport type SeedChunk = {\n data: SeedData;\n order: string[];\n index: number;\n total: number;\n};\n\n/**\n * Options for chunking seed data.\n */\nexport type ChunkSeedDataOptions = {\n /** Seed data keyed by type name */\n data: SeedData;\n /** Ordered list of type names (dependency order) */\n order: string[];\n /** Byte size of the bundled seed script code */\n codeByteSize: number;\n /** Maximum gRPC message size in bytes (default: 3.5MB) */\n maxMessageSize?: number;\n};\n\n/** Default maximum message size: 3.5MB (conservative limit for gRPC) */\nexport const DEFAULT_MAX_MESSAGE_SIZE = 3.5 * 1024 * 1024;\n\n/** Reserved bytes for message metadata overhead */\nconst METADATA_OVERHEAD = 1024;\n\n/**\n * Split seed data into chunks that fit within the gRPC message size limit.\n *\n * Algorithm:\n * 1. Calculate the available budget for the arg field (maxMessageSize - codeByteSize - overhead)\n * 2. If all data fits in one message, return a single chunk\n * 3. Otherwise, iterate through types in dependency order:\n * - If a type fits in the current chunk, add it\n * - If adding a type would exceed the budget, finalize the current chunk and start a new one\n * - If a single type exceeds the budget, split its records across multiple chunks\n * - If a single record exceeds the budget, throw an error\n * @param options - Chunking options\n * @returns Array of seed chunks\n */\nexport function chunkSeedData(options: ChunkSeedDataOptions): SeedChunk[] {\n const { data, order, codeByteSize, maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE } = options;\n\n const argBudget = maxMessageSize - codeByteSize - METADATA_OVERHEAD;\n if (argBudget <= 0) {\n throw new Error(\n `Code size (${codeByteSize} bytes) exceeds the message size limit (${maxMessageSize} bytes). ` +\n `No space left for seed data.`,\n );\n }\n\n // Filter to types that have data\n const typesWithData = order.filter((type) => (data[type]?.length ?? 0) > 0);\n\n if (typesWithData.length === 0) {\n return [];\n }\n\n // Check if all data fits in a single message\n const fullArg = JSON.stringify({ data, order });\n if (byteSize(fullArg) <= argBudget) {\n return [{ data, order, index: 0, total: 1 }];\n }\n\n // Split into multiple chunks\n const chunks: Omit<SeedChunk, \"total\">[] = [];\n let currentData: SeedData = {};\n let currentOrder: string[] = [];\n\n for (const type of typesWithData) {\n const typeRecords = assertDefined(data[type], `seed data missing for type: ${type}`);\n\n // Check if the type fits in the current chunk\n if (currentOrder.length > 0) {\n const testData = { ...currentData, [type]: typeRecords };\n const testOrder = [...currentOrder, type];\n if (byteSize(JSON.stringify({ data: testData, order: testOrder })) > argBudget) {\n // Finalize the current chunk\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n }\n\n // Check if the entire type fits in an empty chunk\n if (byteSize(JSON.stringify({ data: { [type]: typeRecords }, order: [type] })) <= argBudget) {\n currentData[type] = typeRecords;\n currentOrder.push(type);\n continue;\n }\n\n // Type is too large — split by records\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n\n let recordBatch: Record<string, unknown>[] = [];\n for (const record of typeRecords) {\n if (byteSize(JSON.stringify({ data: { [type]: [record] }, order: [type] })) > argBudget) {\n const singleRecordSize = byteSize(JSON.stringify(record));\n throw new Error(\n `A single record in type \"${type}\" (${singleRecordSize} bytes) exceeds the message size budget ` +\n `(${argBudget} bytes). Consider increasing maxMessageSize or reducing the record size.`,\n );\n }\n\n const testBatch = [...recordBatch, record];\n const testData = { ...currentData, [type]: testBatch };\n const testOrder = currentOrder.includes(type) ? currentOrder : [...currentOrder, type];\n const testSize = byteSize(JSON.stringify({ data: testData, order: testOrder }));\n\n if (testSize > argBudget && recordBatch.length > 0) {\n // Finalize current chunk with accumulated records\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n recordBatch = [record];\n } else {\n recordBatch = testBatch;\n }\n }\n\n // Add remaining records\n if (recordBatch.length > 0) {\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n }\n }\n\n // Finalize the last chunk\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n }\n\n const total = chunks.length;\n return chunks.map((chunk) => ({ ...chunk, total }));\n}\n\nfunction byteSize(str: string): number {\n return new TextEncoder().encode(str).length;\n}\n","/**\n * Seed script bundler for TailorDB seed data\n *\n * Bundles seed scripts to be executed via TestExecScript API\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { createBundleLog } from \"#/cli/shared/bundle-log\";\nimport { getDistDir } from \"#/cli/shared/dist-dir\";\nimport { platformBundleDefinePlugin } from \"#/cli/shared/platform-bundle-plugin\";\nimport { createTsconfigPathsPlugin } from \"#/cli/shared/tsconfig-paths-plugin\";\nimport { createGeneratedEntryResolverPlugin } from \"#/cli/shared/virtual-entry\";\nimport ml from \"#/utils/multiline\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst BATCH_SIZE = 100;\n\n/**\n * Generate seed script content for server-side execution\n * @param namespace - TailorDB namespace\n * @returns Generated seed script content\n */\nfunction generateSeedScriptContent(namespace: string): string {\n return ml /* ts */ `\n import { Kysely, TailordbDialect } from \"@tailor-platform/sdk/kysely\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: string[];\n selfRefTypes: string[];\n upsert?: boolean;\n };\n\n type SeedResult = {\n success: boolean;\n processed: Record<string, { inserted: number; updated: number; skipped: number }>;\n errors: string[];\n };\n\n function getDB(namespace: string) {\n const client = new tailordb.Client({ namespace });\n return new Kysely<Record<string, Record<string, unknown>>>({\n dialect: new TailordbDialect(client),\n });\n }\n\n export async function main(input: SeedInput): Promise<SeedResult> {\n const db = getDB(\"${namespace}\");\n const processed: Record<\n string,\n { inserted: number; updated: number; skipped: number }\n > = {};\n const errors: string[] = [];\n const BATCH_SIZE = ${String(BATCH_SIZE)};\n const upsert = input.upsert === true;\n\n for (const typeName of input.order) {\n const records = input.data[typeName];\n if (!records || records.length === 0) {\n console.log(\\`[${namespace}] \\${typeName}: skipped (no data)\\`);\n continue;\n }\n\n processed[typeName] = { inserted: 0, updated: 0, skipped: 0 };\n const hasSelfRef = (input.selfRefTypes || []).includes(typeName);\n\n try {\n let recordsToInsert = records;\n let recordsToUpdate: Record<string, unknown>[] = [];\n if (upsert) {\n const existing = await db\n .selectFrom(typeName)\n .select(\"id\")\n .where(\n \"id\",\n \"in\",\n records.map((record) => record.id),\n )\n .execute();\n const existingIds = new Set(existing.map((record) => record.id));\n recordsToInsert = records.filter((record) => !existingIds.has(record.id));\n recordsToUpdate = records.filter((record) => existingIds.has(record.id));\n }\n\n if (hasSelfRef) {\n // Insert one-by-one to respect self-referencing foreign key order\n for (const record of recordsToInsert) {\n await db.insertInto(typeName).values(record).execute();\n processed[typeName].inserted += 1;\n }\n if (!upsert) {\n console.log(\n \\`[${namespace}] \\${typeName}: \\${processed[typeName].inserted}/\\${records.length} (one-by-one)\\`,\n );\n }\n } else {\n for (let i = 0; i < recordsToInsert.length; i += BATCH_SIZE) {\n const batch = recordsToInsert.slice(i, i + BATCH_SIZE);\n await db.insertInto(typeName).values(batch).execute();\n processed[typeName].inserted += batch.length;\n if (!upsert) {\n console.log(\n \\`[${namespace}] \\${typeName}: \\${processed[typeName].inserted}/\\${records.length}\\`,\n );\n }\n }\n }\n\n for (const record of recordsToUpdate) {\n const { id, ...values } = record;\n if (Object.keys(values).length === 0) {\n processed[typeName].skipped += 1;\n continue;\n }\n await db.updateTable(typeName).set(values).where(\"id\", \"=\", id).execute();\n processed[typeName].updated += 1;\n }\n\n const counts = processed[typeName];\n if (upsert) {\n const skipped = counts.skipped > 0 ? \\`, \\${counts.skipped} skipped\\` : \"\";\n console.log(\n \\`[${namespace}] \\${typeName}: \\${counts.inserted} inserted, \\${counts.updated} updated\\${skipped}\\`,\n );\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`\\${typeName}: \\${message}\\`);\n console.error(\\`[${namespace}] \\${typeName}: failed - \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n errors,\n };\n }\n `;\n}\n\n/**\n * Bundle a seed script for server-side execution\n *\n * Creates an entry that:\n * 1. Defines getDB() function inline\n * 2. Processes data in batches using Kysely\n * 3. Reports progress via console.log\n * 4. Exports as main() for TestExecScript\n * @param namespace - TailorDB namespace\n * @param typeNames - List of type names to include in the seed\n * @param baseDir - Directory whose dependencies and tsconfig the generated entry uses\n * @returns Bundled seed script result\n */\nexport async function bundleSeedScript(\n namespace: string,\n typeNames: string[],\n baseDir: string = process.cwd(),\n): Promise<SeedBundleResult> {\n // Output directory in .tailor-sdk (relative to project root)\n const outputDir = path.resolve(getDistDir(), \"seed\");\n fs.mkdirSync(outputDir, { recursive: true });\n\n // Entry file in output directory\n const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);\n\n // Generate seed script content\n const entryContent = generateSeedScriptContent(namespace);\n fs.writeFileSync(entryPath, entryContent);\n\n let tsconfig: string | undefined;\n try {\n tsconfig = await resolveTSConfig(baseDir);\n } catch {\n tsconfig = undefined;\n }\n\n // Bundle with tree-shaking (write: false to avoid unnecessary disk I/O)\n const bundleLog = createBundleLog({ tsconfig });\n const result = await rolldown.build({\n plugins: [\n createGeneratedEntryResolverPlugin(entryPath, baseDir),\n createTsconfigPathsPlugin(),\n platformBundleDefinePlugin,\n ],\n input: entryPath,\n write: false,\n output: {\n format: \"esm\",\n sourcemap: false,\n minify: false,\n codeSplitting: false,\n globals: {\n tailordb: \"tailordb\",\n },\n },\n external: [\"tailordb\"],\n resolve: {\n conditionNames: [\"node\", \"import\"],\n },\n tsconfig,\n treeshake: {\n moduleSideEffects: false,\n annotations: true,\n unknownGlobalSideEffects: false,\n },\n ...bundleLog.options,\n } as rolldown.BuildOptions);\n bundleLog.assertAllResolved();\n\n const bundledCode = result.output[0].code;\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { registerTypeScriptRuntime } from \"./shared/register-typescript-runtime\";\n\nawait registerTypeScriptRuntime(new URL(\"./tsconfig-paths-hook.mjs\", import.meta.url));\n\nexport { deploy, deploy as apply } from \"./commands/deploy/deploy\";\nexport type { DeployOptions, DeployOptions as ApplyOptions } from \"./commands/deploy/deploy\";\nexport type { BundledScripts } from \"./commands/deploy/function-registry\";\nexport { generate } from \"./commands/generate/service\";\nexport type { GenerateOptions } from \"./commands/generate/options\";\nexport { loadConfig, type LoadedConfig } from \"./shared/config-loader\";\nexport { generateUserTypes } from \"./shared/type-generator\";\nexport type {\n CodeGenerator,\n TailorDBGenerator,\n ResolverGenerator,\n ExecutorGenerator,\n TailorDBResolverGenerator,\n FullCodeGenerator,\n TailorDBInput,\n ResolverInput,\n ExecutorInput,\n FullInput,\n AggregateArgs,\n GeneratorResult,\n DependencyKind,\n PluginAttachment,\n TypeSourceInfoEntry,\n} from \"./commands/generate/types\";\nexport type { TailorDBType } from \"#/parser/service/tailordb/types\";\nexport type { Resolver } from \"#/types/resolver.generated\";\nexport type { Executor } from \"#/types/executor.generated\";\n\n/** @deprecated Import from '@tailor-platform/sdk/plugin/kysely-type' instead */\nexport { kyselyTypePlugin } from \"#/plugin/builtin/kysely-type/index\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"#/plugin/builtin/enum-constants/index\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"#/plugin/builtin/file-utils/index\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"#/plugin/builtin/seed/index\";\n\nexport {\n show,\n type ShowOptions,\n type ApplicationInfo,\n type ShowInfo,\n type AIGatewayInfo,\n} from \"./commands/show\";\nexport { remove, type RemoveOptions } from \"./commands/remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./commands/workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./commands/workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./commands/workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./commands/workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./commands/workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./commands/workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./commands/workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./commands/workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./commands/workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./commands/workspace/user/remove\";\nexport type { UserInfo } from \"./commands/workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./commands/workspace/app/list\";\nexport {\n getAppHealth,\n type HealthOptions as GetAppHealthOptions,\n} from \"./commands/workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./commands/workspace/app/transform\";\nexport { getFunctionRegistry, type GetFunctionRegistryOptions } from \"./commands/function/get\";\nexport {\n listFunctionRegistries,\n type ListFunctionRegistriesOptions,\n} from \"./commands/function/list\";\nexport type { FunctionRegistryInfo } from \"./commands/function/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./commands/machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./commands/machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./commands/oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./commands/oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./commands/oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./commands/workflow/list\";\nexport {\n getWorkflow,\n type GetWorkflowOptions,\n type GetWorkflowTypedOptions,\n} from \"./commands/workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowTypedOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./commands/workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type ListWorkflowExecutionsTypedOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n type WorkflowExecutionWaitInfo,\n} from \"./commands/workflow/executions\";\nexport { waitWorkflowExecution, type WorkflowWaitOutput } from \"./commands/workflow/wait\";\nexport type { WaitWorkflowExecutionOptions, WorkflowWaitResult } from \"./commands/workflow/waiter\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./commands/workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./commands/workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorTypedOptions,\n type TriggerExecutorResult,\n} from \"./commands/executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n getExecutorWaitFailureMessage,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type ListExecutorJobsTypedOptions,\n type GetExecutorJobOptions,\n type GetExecutorJobTypedOptions,\n type WatchExecutorJobOptions,\n type WatchExecutorJobTypedOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./commands/executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./commands/executor/list\";\nexport {\n getExecutor,\n type GetExecutorOptions,\n type GetExecutorTypedOptions,\n} from \"./commands/executor/get\";\nexport {\n listWebhookExecutors,\n type ListWebhookExecutorsOptions,\n type WebhookExecutorInfo,\n} from \"./commands/executor/webhook\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n ExecutorListInfo,\n ExecutorInfo,\n} from \"./commands/executor/transform\";\nexport { listOrganizations, type ListOrganizationsOptions } from \"./commands/organization/list\";\nexport { getOrganization, type GetOrganizationOptions } from \"./commands/organization/get\";\nexport { updateOrganization, type UpdateOrganizationOptions } from \"./commands/organization/update\";\nexport { organizationTree, type OrganizationTreeOptions } from \"./commands/organization/tree\";\nexport type {\n UserOrganizationInfo,\n OrganizationInfo,\n FolderListInfo,\n FolderInfo,\n} from \"./commands/organization/transform\";\nexport { listFolders, type ListFoldersOptions } from \"./commands/organization/folder/list\";\nexport { getFolder, type GetFolderOptions } from \"./commands/organization/folder/get\";\nexport { createFolder, type CreateFolderOptions } from \"./commands/organization/folder/create\";\nexport { updateFolder, type UpdateFolderOptions } from \"./commands/organization/folder/update\";\nexport { deleteFolder, type DeleteFolderOptions } from \"./commands/organization/folder/delete\";\nexport { loadAccessToken, loadWorkspaceId } from \"./shared/context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./commands/api\";\nexport { query } from \"./query\";\nexport { truncate, type TruncateOptions } from \"./commands/tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./commands/tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./commands/tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./commands/tailordb/migrate/diff-calculator\";\nexport {\n SCHEMA_FILE_NAME,\n DIFF_FILE_NAME,\n MIGRATE_FILE_NAME,\n DB_TYPES_FILE_NAME,\n INITIAL_SCHEMA_NUMBER,\n getMigrationDirPath,\n getMigrationFilePath,\n type SchemaSnapshot,\n type NormalizedSchemaSnapshot,\n type TailorDBSnapshotType,\n type SnapshotFieldConfig,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./commands/tailordb/migrate/types\";\n\n// Seed exports\nexport { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./shared/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./commands/generate/seed/bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./commands/tailordb/migrate/bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./shared/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./shared/client\";\nexport type { AuthInvoker } from \"@tailor-platform/tailor-proto/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;CAClD,IAAI,aAAa,GACf,MAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,sCAEtF;CAIF,MAAM,gBAAgB,MAAM,QAAQ,UAAU,KAAK,KAAK,EAAE,UAAU,KAAK,CAAC;CAE1E,IAAI,cAAc,W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UAAU;;;;;;6BAMA,UAAU;;;;;;;;;;;AAWvC;;;;;;;;;;;;;;AAeA,eAAsB,iBACpB,WACA,WACA,UAAkB,QAAQ,IAAI,GACH;CAE3B,MAAM,YAAY,KAAK,QAAQ,WAAW,GAAG,MAAM;CACnD,GAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;CAG3C,MAAM,YAAY,KAAK,KAAK,WAAW,QAAQ,UAAU,UAAU;CAGnE,MAAM,eAAe,0BAA0B,SAAS;CACxD,GAAG,cAAc,WAAW,YAAY;CAExC,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,gBAAgB,OAAO;CAC1C,QAAQ;EACN,WAAW;CACb;CAGA,MAAM,YAAY,gBAAgB,EAAE,SAAS,CAAC;CAC9C,MAAM,SAAS,MAAM,SAAS,MAAM;EAClC,SAAS;GACP,mCAAmC,WAAW,OAAO;GACrD,0BAA0B;GAC1B;EACF;EACA,OAAO;EACP,OAAO;EACP,QAAQ;GACN,QAAQ;GACR,WAAW;GACX,QAAQ;GACR,eAAe;GACf,SAAS,EACP,UAAU,WACZ;EACF;EACA,UAAU,CAAC,UAAU;EACrB,SAAS,EACP,gBAAgB,CAAC,QAAQ,QAAQ,EACnC;EACA;EACA,WAAW;GACT,mBAAmB;GACnB,aAAa;GACb,0BAA0B;EAC5B;EACA,GAAG,UAAU;CACf,CAA0B;CAC1B,UAAU,kBAAkB;CAI5B,OAAO;EACL;EACA,aAJkB,OAAO,OAAO,EAAE,CAAC;EAKnC,eAAe;CACjB;AACF;;;;AC9NA,MAAM,0BAA0B,IAAI,IAAI,6BAA6B,OAAO,KAAK,GAAG,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# politty-completion-version: 1
|
|
2
|
-
# politty-bin-sig:
|
|
2
|
+
# politty-bin-sig: 1785476175
|
|
3
3
|
# politty-bin-path: /home/runner/work/sdk/sdk/node_modules/.bin/tailor-sdk
|
|
4
4
|
# program: tailor-sdk
|
|
5
5
|
# shell: zsh
|
|
@@ -764,6 +764,10 @@ __tailor_sdk_worker_opt_takes_value() {
|
|
|
764
764
|
tailordb:migration:sync:--profile|tailordb:migration:sync:-p|tailordb:migration:sync:--p) return 0 ;;
|
|
765
765
|
tailordb:migration:sync:--config|tailordb:migration:sync:-c|tailordb:migration:sync:--c) return 0 ;;
|
|
766
766
|
tailordb:migration:sync:--namespace|tailordb:migration:sync:-n|tailordb:migration:sync:--n) return 0 ;;
|
|
767
|
+
tailordb:migration:validate:--workspace-id|tailordb:migration:validate:--workspaceId|tailordb:migration:validate:-w|tailordb:migration:validate:--w) return 0 ;;
|
|
768
|
+
tailordb:migration:validate:--profile|tailordb:migration:validate:-p|tailordb:migration:validate:--p) return 0 ;;
|
|
769
|
+
tailordb:migration:validate:--config|tailordb:migration:validate:-c|tailordb:migration:validate:--c) return 0 ;;
|
|
770
|
+
tailordb:migration:validate:--namespace|tailordb:migration:validate:-n|tailordb:migration:validate:--n) return 0 ;;
|
|
767
771
|
tailordb:erd:export:--config|tailordb:erd:export:-c|tailordb:erd:export:--c) return 0 ;;
|
|
768
772
|
tailordb:erd:export:--namespace|tailordb:erd:export:-n|tailordb:erd:export:--n) return 0 ;;
|
|
769
773
|
tailordb:erd:export:--output|tailordb:erd:export:-o|tailordb:erd:export:--o) return 0 ;;
|
|
@@ -972,6 +976,7 @@ __tailor_sdk_worker_is_subcmd() {
|
|
|
972
976
|
tailordb:migration:set) return 0 ;;
|
|
973
977
|
tailordb:migration:status) return 0 ;;
|
|
974
978
|
tailordb:migration:sync) return 0 ;;
|
|
979
|
+
tailordb:migration:validate) return 0 ;;
|
|
975
980
|
tailordb:migration) return 0 ;;
|
|
976
981
|
tailordb:erd:export) return 0 ;;
|
|
977
982
|
tailordb:erd:diff) return 0 ;;
|
|
@@ -3232,6 +3237,50 @@ __tailor_sdk_worker_complete_tailordb_migration_sync() {
|
|
|
3232
3237
|
esac
|
|
3233
3238
|
}
|
|
3234
3239
|
|
|
3240
|
+
__tailor_sdk_worker_complete_tailordb_migration_validate() {
|
|
3241
|
+
local -a _vals=()
|
|
3242
|
+
case "${words[CURRENT-1]}" in
|
|
3243
|
+
--config|-c|--c)
|
|
3244
|
+
setopt local_options null_glob
|
|
3245
|
+
local _cur="${words[CURRENT]:-}" _dir _prefix _f _out
|
|
3246
|
+
local -a _exts=("ts")
|
|
3247
|
+
if [[ -z "$_cur" || "$_cur" != */* ]]; then
|
|
3248
|
+
_dir="."
|
|
3249
|
+
_prefix="$_cur"
|
|
3250
|
+
elif [[ "$_cur" == */ ]]; then
|
|
3251
|
+
_dir="${_cur%/}"
|
|
3252
|
+
_prefix=""
|
|
3253
|
+
else
|
|
3254
|
+
_dir="${_cur%/*}"
|
|
3255
|
+
_prefix="${_cur##*/}"
|
|
3256
|
+
fi
|
|
3257
|
+
for _f in "$_dir"/"$_prefix"*(N/); do
|
|
3258
|
+
_out="${_f#./}"
|
|
3259
|
+
__tailor_sdk_worker_add_path_candidate "$_out"
|
|
3260
|
+
done
|
|
3261
|
+
local _ext
|
|
3262
|
+
for _f in "$_dir"/"$_prefix"*(N.); do
|
|
3263
|
+
_out="${_f#./}"
|
|
3264
|
+
for _ext in "${_exts[@]}"; do
|
|
3265
|
+
[[ -n "$_ext" && "$_out" == *."$_ext" ]] && { __tailor_sdk_worker_add_path_candidate "$_out"; break; }
|
|
3266
|
+
done
|
|
3267
|
+
done
|
|
3268
|
+
return 0 ;;
|
|
3269
|
+
esac
|
|
3270
|
+
if __tailor_sdk_worker_opt_takes_value "tailordb:migration:validate" "${words[CURRENT-1]}"; then return 0; fi
|
|
3271
|
+
if (( _after_dd )); then return 0; fi
|
|
3272
|
+
if [[ "${words[CURRENT]}" == -* ]]; then
|
|
3273
|
+
local -a _opts=()
|
|
3274
|
+
__tailor_sdk_worker_not_used "--workspace-id" "--workspaceId" "-w" "--w" && _opts+=("--workspace-id:Workspace ID")
|
|
3275
|
+
__tailor_sdk_worker_not_used "--profile" "-p" "--p" && _opts+=("--profile:Workspace profile")
|
|
3276
|
+
__tailor_sdk_worker_not_used "--config" "-c" "--c" && _opts+=("--config:Path to SDK config file")
|
|
3277
|
+
__tailor_sdk_worker_not_used "--namespace" "-n" "--n" && _opts+=("--namespace:Target TailorDB namespace (validates all namespaces if not specified)")
|
|
3278
|
+
__tailor_sdk_worker_not_used "--help" && _opts+=("--help:Show help")
|
|
3279
|
+
__tailor_sdk_worker_cdescribe 'options' _opts
|
|
3280
|
+
return 0
|
|
3281
|
+
fi
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3235
3284
|
__tailor_sdk_worker_complete_tailordb_migration() {
|
|
3236
3285
|
local -a _vals=()
|
|
3237
3286
|
if __tailor_sdk_worker_opt_takes_value "tailordb:migration" "${words[CURRENT-1]}"; then return 0; fi
|
|
@@ -3242,7 +3291,7 @@ __tailor_sdk_worker_complete_tailordb_migration() {
|
|
|
3242
3291
|
__tailor_sdk_worker_cdescribe 'options' _opts
|
|
3243
3292
|
return 0
|
|
3244
3293
|
fi
|
|
3245
|
-
local -a _subs=("generate:Generate migration files by detecting schema differences between current local types and the previous migration snapshot." "script:Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none." "set:Set migration checkpoint to a specific number." "status:Show the current migration status for TailorDB namespaces, including applied and pending migrations." "sync:Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift).")
|
|
3294
|
+
local -a _subs=("generate:Generate migration files by detecting schema differences between current local types and the previous migration snapshot." "script:Add a migration script (migrate.ts) template to an existing migration directory, or record with --no-script that a migration intentionally has none." "set:Set migration checkpoint to a specific number." "status:Show the current migration status for TailorDB namespaces, including applied and pending migrations." "sync:Sync remote TailorDB schema to a specific migration snapshot (recovery from --no-schema-check drift)." "validate:Validate the full migration history and detect schema drift (local types vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.")
|
|
3246
3295
|
__tailor_sdk_worker_cdescribe 'subcommands' _subs
|
|
3247
3296
|
}
|
|
3248
3297
|
|
|
@@ -4383,6 +4432,7 @@ _tailor_sdk_worker_completions() {
|
|
|
4383
4432
|
tailordb:migration:set) __tailor_sdk_worker_complete_tailordb_migration_set ;;
|
|
4384
4433
|
tailordb:migration:status) __tailor_sdk_worker_complete_tailordb_migration_status ;;
|
|
4385
4434
|
tailordb:migration:sync) __tailor_sdk_worker_complete_tailordb_migration_sync ;;
|
|
4435
|
+
tailordb:migration:validate) __tailor_sdk_worker_complete_tailordb_migration_validate ;;
|
|
4386
4436
|
tailordb:migration) __tailor_sdk_worker_complete_tailordb_migration ;;
|
|
4387
4437
|
tailordb:erd:export) __tailor_sdk_worker_complete_tailordb_erd_export ;;
|
|
4388
4438
|
tailordb:erd:diff) __tailor_sdk_worker_complete_tailordb_erd_diff ;;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isBuiltin } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/node-builtins.ts
|
|
4
|
+
const SUGGESTIONS = {
|
|
5
|
+
crypto: "Use the Web Crypto API (globalThis.crypto) instead.",
|
|
6
|
+
buffer: "Use Uint8Array or ArrayBuffer instead.",
|
|
7
|
+
fs: "File system access is not available in the Tailor Platform runtime.",
|
|
8
|
+
"fs/promises": "File system access is not available in the Tailor Platform runtime.",
|
|
9
|
+
path: "Use URL or URLPattern for path manipulation.",
|
|
10
|
+
http: "Use the Fetch API (globalThis.fetch) for HTTP requests instead.",
|
|
11
|
+
https: "Use the Fetch API (globalThis.fetch) for HTTPS requests instead.",
|
|
12
|
+
url: "Use the URL and URLSearchParams Web APIs instead.",
|
|
13
|
+
util: "Use Web Standard APIs instead.",
|
|
14
|
+
stream: "Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.",
|
|
15
|
+
"stream/web": "Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.",
|
|
16
|
+
events: "Use EventTarget instead.",
|
|
17
|
+
zlib: "Use CompressionStream and DecompressionStream Web APIs instead.",
|
|
18
|
+
querystring: "Use URLSearchParams instead.",
|
|
19
|
+
string_decoder: "Use TextDecoder instead."
|
|
20
|
+
};
|
|
21
|
+
function isNodeBuiltinImport(specifier) {
|
|
22
|
+
return isBuiltin(specifier);
|
|
23
|
+
}
|
|
24
|
+
function getNodeBuiltinMessage(specifier) {
|
|
25
|
+
const bare = normalizeNodeBuiltinSpecifier(specifier);
|
|
26
|
+
const suggestion = SUGGESTIONS[bare];
|
|
27
|
+
const base = `"${specifier}" is not available in the Tailor Platform runtime.`;
|
|
28
|
+
return suggestion ? `${base} ${suggestion}` : base;
|
|
29
|
+
}
|
|
30
|
+
function normalizeNodeBuiltinSpecifier(specifier) {
|
|
31
|
+
return specifier.startsWith("node:") ? specifier.slice(5) : specifier;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { isNodeBuiltinImport as n, getNodeBuiltinMessage as t };
|
|
36
|
+
//# sourceMappingURL=node-builtins-CmaL2Cbq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-builtins-CmaL2Cbq.mjs","names":[],"sources":["../src/utils/node-builtins.ts"],"sourcesContent":["import { isBuiltin } from \"node:module\";\n\nconst SUGGESTIONS: Record<string, string> = {\n crypto: \"Use the Web Crypto API (globalThis.crypto) instead.\",\n buffer: \"Use Uint8Array or ArrayBuffer instead.\",\n fs: \"File system access is not available in the Tailor Platform runtime.\",\n \"fs/promises\": \"File system access is not available in the Tailor Platform runtime.\",\n path: \"Use URL or URLPattern for path manipulation.\",\n http: \"Use the Fetch API (globalThis.fetch) for HTTP requests instead.\",\n https: \"Use the Fetch API (globalThis.fetch) for HTTPS requests instead.\",\n url: \"Use the URL and URLSearchParams Web APIs instead.\",\n util: \"Use Web Standard APIs instead.\",\n stream: \"Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.\",\n \"stream/web\": \"Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.\",\n events: \"Use EventTarget instead.\",\n zlib: \"Use CompressionStream and DecompressionStream Web APIs instead.\",\n querystring: \"Use URLSearchParams instead.\",\n string_decoder: \"Use TextDecoder instead.\",\n};\n\nexport function isNodeBuiltinImport(specifier: string): boolean {\n return isBuiltin(specifier);\n}\n\nexport function getNodeBuiltinMessage(specifier: string): string {\n const bare = normalizeNodeBuiltinSpecifier(specifier);\n const suggestion = SUGGESTIONS[bare];\n const base = `\"${specifier}\" is not available in the Tailor Platform runtime.`;\n return suggestion ? `${base} ${suggestion}` : base;\n}\n\nfunction normalizeNodeBuiltinSpecifier(specifier: string): string {\n return specifier.startsWith(\"node:\") ? specifier.slice(5) : specifier;\n}\n"],"mappings":";;;AAEA,MAAM,cAAsC;CAC1C,QAAQ;CACR,QAAQ;CACR,IAAI;CACJ,eAAe;CACf,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,MAAM;CACN,QAAQ;CACR,cAAc;CACd,QAAQ;CACR,MAAM;CACN,aAAa;CACb,gBAAgB;AAClB;AAEA,SAAgB,oBAAoB,WAA4B;CAC9D,OAAO,UAAU,SAAS;AAC5B;AAEA,SAAgB,sBAAsB,WAA2B;CAC/D,MAAM,OAAO,8BAA8B,SAAS;CACpD,MAAM,aAAa,YAAY;CAC/B,MAAM,OAAO,IAAI,UAAU;CAC3B,OAAO,aAAa,GAAG,KAAK,GAAG,eAAe;AAChD;AAEA,SAAS,8BAA8B,WAA2B;CAChE,OAAO,UAAU,WAAW,OAAO,IAAI,UAAU,MAAM,CAAC,IAAI;AAC9D"}
|