@tailor-platform/sdk 1.43.0 → 1.44.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 +24 -0
- package/dist/application-BZRbA1pL.mjs +4 -0
- package/dist/{application-DQpD_kHR.mjs → application-DkVNbIuh.mjs} +9 -9
- package/dist/application-DkVNbIuh.mjs.map +1 -0
- package/dist/cli/index.mjs +27 -19
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +29 -14
- package/dist/cli/lib.mjs +8 -8
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/skills.mjs.map +1 -1
- package/dist/{client-CcV6Jjds.mjs → client-DQl5NPG9.mjs} +103 -43
- package/dist/{client-CcV6Jjds.mjs.map → client-DQl5NPG9.mjs.map} +1 -1
- package/dist/{client-Cn9SqhZT.mjs → client-EI4pMzvm.mjs} +1 -1
- package/dist/configure/index.mjs +1 -1
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crash-report-CUbm1ErM.mjs → crash-report-CSSrblUv.mjs} +4 -4
- package/dist/{crash-report-CUbm1ErM.mjs.map → crash-report-CSSrblUv.mjs.map} +1 -1
- package/dist/{crash-report-CSYupJ0T.mjs → crash-report-DtkFq9JF.mjs} +1 -1
- package/dist/{enum-constants-Dx82rSjf.mjs → enum-constants-C3KSpsYj.mjs} +1 -1
- package/dist/{enum-constants-Dx82rSjf.mjs.map → enum-constants-C3KSpsYj.mjs.map} +1 -1
- package/dist/{errors-ChWX5ZG8.mjs → errors-_M2TVoWh.mjs} +1 -1
- package/dist/{errors-ChWX5ZG8.mjs.map → errors-_M2TVoWh.mjs.map} +1 -1
- package/dist/{file-utils-DeWpvq3T.mjs → file-utils-775qWKoo.mjs} +1 -1
- package/dist/{file-utils-DeWpvq3T.mjs.map → file-utils-775qWKoo.mjs.map} +1 -1
- package/dist/interceptor-4UC-KTno.mjs.map +1 -1
- package/dist/job-BOvKyNdT.mjs.map +1 -1
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{kysely-type-CwtvQuxh.mjs → kysely-type-BQsYEZoY.mjs} +1 -1
- package/dist/kysely-type-BQsYEZoY.mjs.map +1 -0
- package/dist/logger-DTNAMYGy.mjs.map +1 -1
- package/dist/{package-json-CWp8s9dE.mjs → package-json-CRzw5eUf.mjs} +1 -1
- package/dist/{package-json-CWp8s9dE.mjs.map → package-json-CRzw5eUf.mjs.map} +1 -1
- package/dist/package-json-DR_mqrCW.mjs +4 -0
- package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/repl-editor-DjycioU-.mjs.map +1 -1
- package/dist/{runtime-Bn68JXnL.mjs → runtime-l7GFD3Xg.mjs} +312 -123
- package/dist/runtime-l7GFD3Xg.mjs.map +1 -0
- package/dist/{schema-CEcfEyPN.mjs → schema-DBq6hr6h.mjs} +13 -2
- package/dist/{schema-CEcfEyPN.mjs.map → schema-DBq6hr6h.mjs.map} +1 -1
- package/dist/{seed-CyYPhvNL.mjs → seed-BkVKgsxf.mjs} +1 -1
- package/dist/{seed-CyYPhvNL.mjs.map → seed-BkVKgsxf.mjs.map} +1 -1
- package/dist/{service-SrG26B9T.mjs → service-CCnx_IFw.mjs} +2 -2
- package/dist/{service-SrG26B9T.mjs.map → service-CCnx_IFw.mjs.map} +1 -1
- package/dist/{telemetry-BuDto_2q.mjs → telemetry-B6Le9XT-.mjs} +2 -2
- package/dist/{telemetry-BuDto_2q.mjs.map → telemetry-B6Le9XT-.mjs.map} +1 -1
- package/dist/telemetry-C_WXxIo0.mjs +4 -0
- package/dist/types-Duhhsx3R.mjs.map +1 -1
- package/dist/utils/test/index.mjs.map +1 -1
- package/docs/cli/application.md +130 -5
- package/docs/cli/crash-report.md +12 -1
- package/docs/cli/executor.md +6 -4
- package/docs/cli/organization.md +6 -5
- package/docs/cli/workspace.md +16 -13
- package/docs/cli-reference.md +10 -9
- package/package.json +9 -9
- package/dist/application-DQpD_kHR.mjs.map +0 -1
- package/dist/application-DUcmoFdc.mjs +0 -4
- package/dist/kysely-type-CwtvQuxh.mjs.map +0 -1
- package/dist/package-json-CPR7s5hf.mjs +0 -4
- package/dist/runtime-Bn68JXnL.mjs.map +0 -1
- package/dist/telemetry-C1hzFaiV.mjs +0 -4
package/dist/cli/lib.d.mts
CHANGED
|
@@ -17524,12 +17524,23 @@ type CreateWorkspaceOptions = z.input<typeof createWorkspaceOptionsSchema>;
|
|
|
17524
17524
|
*/
|
|
17525
17525
|
declare function createWorkspace(options: CreateWorkspaceOptions): Promise<WorkspaceInfo>;
|
|
17526
17526
|
//#endregion
|
|
17527
|
+
//#region src/cli/shared/args.d.ts
|
|
17528
|
+
/**
|
|
17529
|
+
* Schema for sort order (`asc` or `desc`).
|
|
17530
|
+
*/
|
|
17531
|
+
declare const orderArg: z.ZodEnum<{
|
|
17532
|
+
asc: "asc";
|
|
17533
|
+
desc: "desc";
|
|
17534
|
+
}>;
|
|
17535
|
+
type Order = z.infer<typeof orderArg>;
|
|
17536
|
+
//#endregion
|
|
17527
17537
|
//#region src/cli/commands/workspace/list.d.ts
|
|
17528
17538
|
interface ListWorkspacesOptions {
|
|
17539
|
+
order?: Order;
|
|
17529
17540
|
limit?: number;
|
|
17530
17541
|
}
|
|
17531
17542
|
/**
|
|
17532
|
-
* List workspaces with an optional limit.
|
|
17543
|
+
* List workspaces with an optional order and limit.
|
|
17533
17544
|
* @param options - Workspace listing options
|
|
17534
17545
|
* @returns List of workspaces
|
|
17535
17546
|
*/
|
|
@@ -17583,11 +17594,15 @@ interface UserInfo {
|
|
|
17583
17594
|
declare const listUsersOptionsSchema: z.ZodObject<{
|
|
17584
17595
|
workspaceId: z.ZodOptional<z.ZodUUID>;
|
|
17585
17596
|
profile: z.ZodOptional<z.ZodString>;
|
|
17597
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
17598
|
+
asc: "asc";
|
|
17599
|
+
desc: "desc";
|
|
17600
|
+
}>>;
|
|
17586
17601
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
17587
17602
|
}, z.core.$strip>;
|
|
17588
17603
|
type ListUsersOptions = z.input<typeof listUsersOptionsSchema>;
|
|
17589
17604
|
/**
|
|
17590
|
-
* List users in a workspace with an optional limit.
|
|
17605
|
+
* List users in a workspace with an optional order and limit.
|
|
17591
17606
|
* @param options - User listing options
|
|
17592
17607
|
* @returns List of workspace users
|
|
17593
17608
|
*/
|
|
@@ -17666,11 +17681,15 @@ interface AppHealthInfo {
|
|
|
17666
17681
|
declare const listAppsOptionsSchema: z.ZodObject<{
|
|
17667
17682
|
workspaceId: z.ZodOptional<z.ZodUUID>;
|
|
17668
17683
|
profile: z.ZodOptional<z.ZodString>;
|
|
17684
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
17685
|
+
asc: "asc";
|
|
17686
|
+
desc: "desc";
|
|
17687
|
+
}>>;
|
|
17669
17688
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
17670
17689
|
}, z.core.$strip>;
|
|
17671
17690
|
type ListAppsOptions = z.input<typeof listAppsOptionsSchema>;
|
|
17672
17691
|
/**
|
|
17673
|
-
* List applications in a workspace with an optional limit.
|
|
17692
|
+
* List applications in a workspace with an optional order and limit.
|
|
17674
17693
|
* @param options - Application listing options
|
|
17675
17694
|
* @returns List of applications
|
|
17676
17695
|
*/
|
|
@@ -17732,16 +17751,6 @@ type ListFunctionRegistriesOptions = z.input<typeof listFunctionRegistriesOption
|
|
|
17732
17751
|
*/
|
|
17733
17752
|
declare function listFunctionRegistries(options: ListFunctionRegistriesOptions): Promise<FunctionRegistryInfo[]>;
|
|
17734
17753
|
//#endregion
|
|
17735
|
-
//#region src/cli/shared/args.d.ts
|
|
17736
|
-
/**
|
|
17737
|
-
* Schema for sort order (`asc` or `desc`).
|
|
17738
|
-
*/
|
|
17739
|
-
declare const orderArg: z.ZodEnum<{
|
|
17740
|
-
asc: "asc";
|
|
17741
|
-
desc: "desc";
|
|
17742
|
-
}>;
|
|
17743
|
-
type Order = z.infer<typeof orderArg>;
|
|
17744
|
-
//#endregion
|
|
17745
17754
|
//#region src/cli/commands/machineuser/list.d.ts
|
|
17746
17755
|
interface ListMachineUsersOptions {
|
|
17747
17756
|
workspaceId?: string;
|
|
@@ -18263,6 +18272,8 @@ interface WebhookExecutorInfo {
|
|
|
18263
18272
|
interface ListWebhookExecutorsOptions {
|
|
18264
18273
|
workspaceId?: string;
|
|
18265
18274
|
profile?: string;
|
|
18275
|
+
order?: Order;
|
|
18276
|
+
limit?: number;
|
|
18266
18277
|
}
|
|
18267
18278
|
/**
|
|
18268
18279
|
* List executors with incoming webhook triggers and return CLI-friendly info.
|
|
@@ -18359,6 +18370,10 @@ declare function organizationTree(options?: OrganizationTreeOptions): Promise<Or
|
|
|
18359
18370
|
declare const listFoldersOptionsSchema: z.ZodObject<{
|
|
18360
18371
|
organizationId: z.ZodUUID;
|
|
18361
18372
|
parentFolderId: z.ZodOptional<z.ZodString>;
|
|
18373
|
+
order: z.ZodOptional<z.ZodEnum<{
|
|
18374
|
+
asc: "asc";
|
|
18375
|
+
desc: "desc";
|
|
18376
|
+
}>>;
|
|
18362
18377
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
18363
18378
|
}, z.core.$strip>;
|
|
18364
18379
|
type ListFoldersOptions = z.input<typeof listFoldersOptionsSchema>;
|
|
@@ -18453,7 +18468,7 @@ declare function loadWorkspaceId(opts?: LoadWorkspaceIdOptions): Promise<string>
|
|
|
18453
18468
|
*/
|
|
18454
18469
|
declare function loadAccessToken(opts?: LoadAccessTokenOptions): Promise<string>;
|
|
18455
18470
|
//#endregion
|
|
18456
|
-
//#region src/cli/commands/api.d.ts
|
|
18471
|
+
//#region src/cli/commands/api/api-call.d.ts
|
|
18457
18472
|
interface ApiCallOptions {
|
|
18458
18473
|
profile?: string;
|
|
18459
18474
|
endpoint: string;
|
package/dist/cli/lib.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import { d as initOperatorClient } from "../client-
|
|
3
|
-
import { $t as getMigrationDirPath, A as truncate, B as updateOrganization, Bt as MIGRATION_LABEL_KEY, D as resumeWorkflow, Dt as startWorkflow, Gt as INITIAL_SCHEMA_NUMBER, Ht as bundleMigrationScript, It as getExecutor, J as updateFolder, Jt as compareLocalTypesWithSnapshot, K as getOrganization, Kt as MIGRATE_FILE_NAME, L as remove, Lt as apply, M as generate$1, Mt as listWorkflowExecutions, P as show, Q as getFolder, Qt as getLatestMigrationNumber, Rt as executeScript, S as listApps, St as getExecutorJob, Tt as watchExecutorJob, Ut as DB_TYPES_FILE_NAME, V as organizationTree, W as listOrganizations, Wt as DIFF_FILE_NAME, X as listFolders, Xt as createSnapshotFromLocalTypes, Yt as compareSnapshots, _ as getWorkspace, a as updateUser, an as reconstructSnapshotFromMigrations, cn as hasChanges, d as inviteUser, dt as generate, en as getMigrationFilePath, et as deleteFolder, gt as listWebhookExecutors, h as listWorkspaces, ht as getFunctionRegistry, it as listOAuth2Clients, jt as getWorkflowExecution, k as listWorkflows, kt as getWorkflow, l as listUsers, ln as getNamespacesWithMigrations,
|
|
4
|
-
import { C as loadWorkspaceId, S as loadAccessToken, _ as getDistDir, y as loadConfig } from "../application-
|
|
5
|
-
import { n as enumConstantsPlugin } from "../enum-constants-
|
|
6
|
-
import { n as fileUtilsPlugin } from "../file-utils-
|
|
7
|
-
import { n as kyselyTypePlugin } from "../kysely-type-
|
|
8
|
-
import { n as seedPlugin } from "../seed-
|
|
2
|
+
import { d as initOperatorClient } from "../client-DQl5NPG9.mjs";
|
|
3
|
+
import { $t as getMigrationDirPath, A as truncate, B as updateOrganization, Bt as MIGRATION_LABEL_KEY, D as resumeWorkflow, Dt as startWorkflow, Gt as INITIAL_SCHEMA_NUMBER, Ht as bundleMigrationScript, It as getExecutor, J as updateFolder, Jt as compareLocalTypesWithSnapshot, K as getOrganization, Kt as MIGRATE_FILE_NAME, L as remove, Lt as apply, M as generate$1, Mt as listWorkflowExecutions, P as show, Q as getFolder, Qt as getLatestMigrationNumber, Rt as executeScript, S as listApps, St as getExecutorJob, Tt as watchExecutorJob, Ut as DB_TYPES_FILE_NAME, V as organizationTree, W as listOrganizations, Wt as DIFF_FILE_NAME, X as listFolders, Xt as createSnapshotFromLocalTypes, Yt as compareSnapshots, _ as getWorkspace, a as updateUser, an as reconstructSnapshotFromMigrations, cn as hasChanges, d as inviteUser, dt as generate, en as getMigrationFilePath, et as deleteFolder, gt as listWebhookExecutors, h as listWorkspaces, hn as apiCall, ht as getFunctionRegistry, it as listOAuth2Clients, jt as getWorkflowExecution, k as listWorkflows, kt as getWorkflow, l as listUsers, ln as getNamespacesWithMigrations, n as query, nn as getNextMigrationNumber, nt as createFolder, on as formatDiffSummary, ot as getOAuth2Client, p as restoreWorkspace, pn as generateUserTypes, pt as listFunctionRegistries, qt as SCHEMA_FILE_NAME, s as removeUser, sn as formatMigrationDiff, st as getMachineUserToken, t as isNativeTypeScriptRuntime, tn as getMigrationFiles, ut as listMachineUsers, w as getAppHealth, wt as listExecutorJobs, x as createWorkspace, xt as listExecutors, y as deleteWorkspace, yt as triggerExecutor, zt as waitForExecution } from "../runtime-l7GFD3Xg.mjs";
|
|
4
|
+
import { C as loadWorkspaceId, S as loadAccessToken, _ as getDistDir, y as loadConfig } from "../application-DkVNbIuh.mjs";
|
|
5
|
+
import { n as enumConstantsPlugin } from "../enum-constants-C3KSpsYj.mjs";
|
|
6
|
+
import { n as fileUtilsPlugin } from "../file-utils-775qWKoo.mjs";
|
|
7
|
+
import { n as kyselyTypePlugin } from "../kysely-type-BQsYEZoY.mjs";
|
|
8
|
+
import { n as seedPlugin } from "../seed-BkVKgsxf.mjs";
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import * as path from "pathe";
|
|
11
|
-
import { resolveTSConfig } from "pkg-types";
|
|
12
11
|
import ml from "multiline-ts";
|
|
12
|
+
import { resolveTSConfig } from "pkg-types";
|
|
13
13
|
import * as rolldown from "rolldown";
|
|
14
14
|
|
|
15
15
|
//#region src/cli/shared/seed-chunker.ts
|
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\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] && data[type].length > 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 = data[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 ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\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 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 { isNativeTypeScriptRuntime } from \"./shared/runtime\";\n\n// Register tsx to handle TypeScript files when using CLI API programmatically.\n// Bun and Deno handle TypeScript natively, so registration is skipped.\nif (!isNativeTypeScriptRuntime()) {\n const { register } = await import(\"node:module\");\n register(\"tsx\", import.meta.url, { data: {} });\n}\n\nexport { apply } from \"./commands/apply/apply\";\nexport type { ApplyOptions } from \"./commands/apply/apply\";\nexport type { BundledScripts } from \"./commands/apply/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 \"@/types/tailordb\";\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\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"@/plugin/builtin/enum-constants\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"@/plugin/builtin/file-utils\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"@/plugin/builtin/seed\";\n\nexport { show, type ShowOptions, type ApplicationInfo } 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} from \"./commands/workflow/executions\";\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 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 SnapshotType,\n type SnapshotFieldConfig,\n type MigrationInfo,\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-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;AAClD,KAAI,aAAa,EACf,OAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,uCAErF;CAIH,MAAM,gBAAgB,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,SAAS,EAAE;AAEjF,KAAI,cAAc,WAAW,E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AO;AACpD,IAAG,UAAU,WAAW,EAAE,WAAW,MAAM,CAAC;CAG5C,MAAM,YAAY,KAAK,KAAK,WAAW,QAAQ,UAAU,WAAW;CAGpE,MAAM,eAAe,0BAA0B,UAAU;AACzD,IAAG,cAAc,WAAW,aAAa;CAEzC,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,iBAAiB;SAC5B;AACN,aAAW;;AA+Bb,QAAO;EACL;EACA,cA7Ba,MAAM,SAAS,MAAM;GAClC,OAAO;GACP,OAAO;GACP,QAAQ;IACN,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,eAAe;IACf,SAAS,EACP,UAAU,YACX;IACF;GACD,UAAU,CAAC,WAAW;GACtB,SAAS,EACP,gBAAgB,CAAC,QAAQ,SAAS,EACnC;GACD;GACA,WAAW;IACT,mBAAmB;IACnB,aAAa;IACb,0BAA0B;IAC3B;GACD,UAAU;GACX,CAA0B,EAEA,OAAO,GAAG;EAKnC,eAAe;EAChB;;;;;AC9JH,IAAI,CAAC,2BAA2B,EAAE;CAChC,MAAM,EAAE,aAAa,MAAM,OAAO;AAClC,UAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,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\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] && data[type].length > 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 = data[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 ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\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 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 { isNativeTypeScriptRuntime } from \"./shared/runtime\";\n\n// Register tsx to handle TypeScript files when using CLI API programmatically.\n// Bun and Deno handle TypeScript natively, so registration is skipped.\nif (!isNativeTypeScriptRuntime()) {\n const { register } = await import(\"node:module\");\n register(\"tsx\", import.meta.url, { data: {} });\n}\n\nexport { apply } from \"./commands/apply/apply\";\nexport type { ApplyOptions } from \"./commands/apply/apply\";\nexport type { BundledScripts } from \"./commands/apply/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 \"@/types/tailordb\";\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\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"@/plugin/builtin/enum-constants\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"@/plugin/builtin/file-utils\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"@/plugin/builtin/seed\";\n\nexport { show, type ShowOptions, type ApplicationInfo } 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} from \"./commands/workflow/executions\";\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 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 SnapshotType,\n type SnapshotFieldConfig,\n type MigrationInfo,\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-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;AAClD,KAAI,aAAa,EACf,OAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,uCAErF;CAIH,MAAM,gBAAgB,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,SAAS,EAAE;AAEjF,KAAI,cAAc,WAAW,EAC3B,QAAO,EAAE;AAKX,KAAI,SADY,KAAK,UAAU;EAAE;EAAM;EAAO,CAC1B,CAAC,IAAI,UACvB,QAAO,CAAC;EAAE;EAAM;EAAO,OAAO;EAAG,OAAO;EAAG,CAAC;CAI9C,MAAM,SAAqC,EAAE;CAC7C,IAAI,cAAwB,EAAE;CAC9B,IAAI,eAAyB,EAAE;AAE/B,MAAK,MAAM,QAAQ,eAAe;EAChC,MAAM,cAAc,KAAK;AAGzB,MAAI,aAAa,SAAS,GAAG;GAC3B,MAAM,WAAW;IAAE,GAAG;KAAc,OAAO;IAAa;GACxD,MAAM,YAAY,CAAC,GAAG,cAAc,KAAK;AACzC,OAAI,SAAS,KAAK,UAAU;IAAE,MAAM;IAAU,OAAO;IAAW,CAAC,CAAC,GAAG,WAAW;AAE9E,WAAO,KAAK;KAAE,MAAM;KAAa,OAAO;KAAc,OAAO,OAAO;KAAQ,CAAC;AAC7E,kBAAc,EAAE;AAChB,mBAAe,EAAE;;;AAKrB,MAAI,SAAS,KAAK,UAAU;GAAE,MAAM,GAAG,OAAO,aAAa;GAAE,OAAO,CAAC,KAAK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O,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
|
package/dist/cli/skills.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.mjs","names":[],"sources":["../../src/cli/skills.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { spawn } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { dirname, resolve } from \"pathe\";\nimport { logger } from \"./shared/logger\";\n\nlogger.warn(\n \"`tailor-sdk-skills` is deprecated and will be removed in v2. Use `tailor-sdk skills install` instead.\",\n);\n\nconst here = dirname(fileURLToPath(import.meta.url));\nconst mainCli = resolve(here, \"index.mjs\");\n\nconst child = spawn(process.execPath, [mainCli, \"skills\", \"install\", ...process.argv.slice(2)], {\n stdio: \"inherit\",\n});\n\nchild.on(\"exit\", (code) => {\n process.exit(code ?? 1);\n});\n"],"mappings":";;;;;;;;AAOA,OAAO,KACL,wGACD;AAGD,MAAM,UAAU,QADH,QAAQ,cAAc,OAAO,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"skills.mjs","names":[],"sources":["../../src/cli/skills.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { spawn } from \"node:child_process\";\nimport { fileURLToPath } from \"node:url\";\nimport { dirname, resolve } from \"pathe\";\nimport { logger } from \"./shared/logger\";\n\nlogger.warn(\n \"`tailor-sdk-skills` is deprecated and will be removed in v2. Use `tailor-sdk skills install` instead.\",\n);\n\nconst here = dirname(fileURLToPath(import.meta.url));\nconst mainCli = resolve(here, \"index.mjs\");\n\nconst child = spawn(process.execPath, [mainCli, \"skills\", \"install\", ...process.argv.slice(2)], {\n stdio: \"inherit\",\n});\n\nchild.on(\"exit\", (code) => {\n process.exit(code ?? 1);\n});\n"],"mappings":";;;;;;;;AAOA,OAAO,KACL,wGACD;AAGD,MAAM,UAAU,QADH,QAAQ,cAAc,OAAO,KAAK,IAAI,CACvB,EAAE,YAAY;AAE5B,MAAM,QAAQ,UAAU;CAAC;CAAS;CAAU;CAAW,GAAG,QAAQ,KAAK,MAAM,EAAE;CAAC,EAAE,EAC9F,OAAO,WACR,CAEI,CAAC,GAAG,SAAS,SAAS;AACzB,SAAQ,KAAK,QAAQ,EAAE;EACvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { n as logger } from "./logger-DTNAMYGy.mjs";
|
|
3
|
-
import { t as readPackageJson } from "./package-json-
|
|
3
|
+
import { t as readPackageJson } from "./package-json-CRzw5eUf.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { enumDesc, fileDesc, messageDesc, serviceDesc, tsEnum } from "@bufbuild/protobuf/codegenv2";
|
|
@@ -23,6 +23,39 @@ const file_buf_validate_validate = /* @__PURE__ */ fileDesc("ChtidWYvdmFsaWRhdGU
|
|
|
23
23
|
file_google_protobuf_timestamp
|
|
24
24
|
]);
|
|
25
25
|
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../tailor-proto/src/tailor/v1/resource_pb.js
|
|
28
|
+
/**
|
|
29
|
+
* Describes the file tailor/v1/resource.proto.
|
|
30
|
+
*/
|
|
31
|
+
const file_tailor_v1_resource = /* @__PURE__ */ fileDesc("Chh0YWlsb3IvdjEvcmVzb3VyY2UucHJvdG8SCXRhaWxvci52MSKqAgoHU2VydmljZRInCgluYW1lc3BhY2UYASABKAsyFC50YWlsb3IudjEuTmFtZXNwYWNlEjQKDHNlcnZpY2VfdHlwZRgCIAEoDjIeLnRhaWxvci52MS5TZXJ2aWNlLlNlcnZpY2VUeXBlIr8BCgtTZXJ2aWNlVHlwZRIcChhTRVJWSUNFX1RZUEVfVU5TUEVDSUZJRUQQABIZChVTRVJWSUNFX1RZUEVfVEFJTE9SREIQARIVChFTRVJWSUNFX1RZUEVfQVVUSBACEhkKFVNFUlZJQ0VfVFlQRV9QSVBFTElORRADEhoKFlNFUlZJQ0VfVFlQRV9TVEFURUZMT1cQBBITCg9TRVJWSUNFX1RZUEVfQUkQBRIUChBTRVJWSUNFX1RZUEVfSURQEAYiGQoJTmFtZXNwYWNlEgwKBG5hbWUYASABKAkiFgoGU2NyaXB0EgwKBGV4cHIYASABKAkicAoGRmlsdGVyEicKCWNvbmRpdGlvbhgBIAEoCzIULnRhaWxvci52MS5Db25kaXRpb24SHgoDYW5kGAIgAygLMhEudGFpbG9yLnYxLkZpbHRlchIdCgJvchgDIAMoCzIRLnRhaWxvci52MS5GaWx0ZXIirAIKCUNvbmRpdGlvbhINCgVmaWVsZBgBIAEoCRI7CghvcGVyYXRvchgCIAEoDjIdLnRhaWxvci52MS5Db25kaXRpb24uT3BlcmF0b3JCCrpIB4IBBBABIAASJQoFdmFsdWUYAyABKAsyFi5nb29nbGUucHJvdG9idWYuVmFsdWUiqwEKCE9wZXJhdG9yEhgKFE9QRVJBVE9SX1VOU1BFQ0lGSUVEEAASDwoLT1BFUkFUT1JfRVEQARIVChFPUEVSQVRPUl9DT05UQUlOUxACEg8KC09QRVJBVE9SX0dUEAMSDwoLT1BFUkFUT1JfR0UQBBIPCgtPUEVSQVRPUl9MVBAFEg8KC09QRVJBVE9SX0xFEAYSGQoVT1BFUkFUT1JfTk9UX0NPTlRBSU5TEAcqYAoNUGFnZURpcmVjdGlvbhIeChpQQUdFX0RJUkVDVElPTl9VTlNQRUNJRklFRBAAEhYKElBBR0VfRElSRUNUSU9OX0FTQxABEhcKE1BBR0VfRElSRUNUSU9OX0RFU0MQAmIGcHJvdG8z", [file_buf_validate_validate, file_google_protobuf_struct]);
|
|
32
|
+
/**
|
|
33
|
+
* Describes the message tailor.v1.Filter.
|
|
34
|
+
* Use `create(FilterSchema)` to create a new message.
|
|
35
|
+
*/
|
|
36
|
+
const FilterSchema = /* @__PURE__ */ messageDesc(file_tailor_v1_resource, 3);
|
|
37
|
+
/**
|
|
38
|
+
* Describes the message tailor.v1.Condition.
|
|
39
|
+
* Use `create(ConditionSchema)` to create a new message.
|
|
40
|
+
*/
|
|
41
|
+
const ConditionSchema = /* @__PURE__ */ messageDesc(file_tailor_v1_resource, 4);
|
|
42
|
+
/**
|
|
43
|
+
* Describes the enum tailor.v1.Condition.Operator.
|
|
44
|
+
*/
|
|
45
|
+
const Condition_OperatorSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_resource, 4, 0);
|
|
46
|
+
/**
|
|
47
|
+
* @generated from enum tailor.v1.Condition.Operator
|
|
48
|
+
*/
|
|
49
|
+
const Condition_Operator = /* @__PURE__ */ tsEnum(Condition_OperatorSchema);
|
|
50
|
+
/**
|
|
51
|
+
* Describes the enum tailor.v1.PageDirection.
|
|
52
|
+
*/
|
|
53
|
+
const PageDirectionSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_resource, 0);
|
|
54
|
+
/**
|
|
55
|
+
* @generated from enum tailor.v1.PageDirection
|
|
56
|
+
*/
|
|
57
|
+
const PageDirection = /* @__PURE__ */ tsEnum(PageDirectionSchema);
|
|
58
|
+
|
|
26
59
|
//#endregion
|
|
27
60
|
//#region ../tailor-proto/src/tailor/fieldmask/v1/option_pb.js
|
|
28
61
|
/**
|
|
@@ -64,39 +97,6 @@ const ApplicationSchemaUpdateAttemptStatusSchema = /* @__PURE__ */ enumDesc(file
|
|
|
64
97
|
*/
|
|
65
98
|
const ApplicationSchemaUpdateAttemptStatus = /* @__PURE__ */ tsEnum(ApplicationSchemaUpdateAttemptStatusSchema);
|
|
66
99
|
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../tailor-proto/src/tailor/v1/resource_pb.js
|
|
69
|
-
/**
|
|
70
|
-
* Describes the file tailor/v1/resource.proto.
|
|
71
|
-
*/
|
|
72
|
-
const file_tailor_v1_resource = /* @__PURE__ */ fileDesc("Chh0YWlsb3IvdjEvcmVzb3VyY2UucHJvdG8SCXRhaWxvci52MSKqAgoHU2VydmljZRInCgluYW1lc3BhY2UYASABKAsyFC50YWlsb3IudjEuTmFtZXNwYWNlEjQKDHNlcnZpY2VfdHlwZRgCIAEoDjIeLnRhaWxvci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);
|
|
73
|
-
/**
|
|
74
|
-
* Describes the message tailor.v1.Filter.
|
|
75
|
-
* Use `create(FilterSchema)` to create a new message.
|
|
76
|
-
*/
|
|
77
|
-
const FilterSchema = /* @__PURE__ */ messageDesc(file_tailor_v1_resource, 3);
|
|
78
|
-
/**
|
|
79
|
-
* Describes the message tailor.v1.Condition.
|
|
80
|
-
* Use `create(ConditionSchema)` to create a new message.
|
|
81
|
-
*/
|
|
82
|
-
const ConditionSchema = /* @__PURE__ */ messageDesc(file_tailor_v1_resource, 4);
|
|
83
|
-
/**
|
|
84
|
-
* Describes the enum tailor.v1.Condition.Operator.
|
|
85
|
-
*/
|
|
86
|
-
const Condition_OperatorSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_resource, 4, 0);
|
|
87
|
-
/**
|
|
88
|
-
* @generated from enum tailor.v1.Condition.Operator
|
|
89
|
-
*/
|
|
90
|
-
const Condition_Operator = /* @__PURE__ */ tsEnum(Condition_OperatorSchema);
|
|
91
|
-
/**
|
|
92
|
-
* Describes the enum tailor.v1.PageDirection.
|
|
93
|
-
*/
|
|
94
|
-
const PageDirectionSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_resource, 0);
|
|
95
|
-
/**
|
|
96
|
-
* @generated from enum tailor.v1.PageDirection
|
|
97
|
-
*/
|
|
98
|
-
const PageDirection = /* @__PURE__ */ tsEnum(PageDirectionSchema);
|
|
99
|
-
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region ../tailor-proto/src/tailor/v1/application_pb.js
|
|
102
102
|
/**
|
|
@@ -2561,9 +2561,26 @@ var require_timers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2561
2561
|
* used as a drop-in replacement for the native functions.
|
|
2562
2562
|
*/
|
|
2563
2563
|
module.exports = {
|
|
2564
|
+
/**
|
|
2565
|
+
* The setTimeout() method sets a timer which executes a function once the
|
|
2566
|
+
* timer expires.
|
|
2567
|
+
* @param {Function} callback A function to be executed after the timer
|
|
2568
|
+
* expires.
|
|
2569
|
+
* @param {number} delay The time, in milliseconds that the timer should
|
|
2570
|
+
* wait before the specified function or code is executed.
|
|
2571
|
+
* @param {*} [arg] An optional argument to be passed to the callback function
|
|
2572
|
+
* when the timer expires.
|
|
2573
|
+
* @returns {NodeJS.Timeout|FastTimer}
|
|
2574
|
+
*/
|
|
2564
2575
|
setTimeout(callback, delay, arg) {
|
|
2565
2576
|
return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg);
|
|
2566
2577
|
},
|
|
2578
|
+
/**
|
|
2579
|
+
* The clearTimeout method cancels an instantiated Timer previously created
|
|
2580
|
+
* by calling setTimeout.
|
|
2581
|
+
*
|
|
2582
|
+
* @param {NodeJS.Timeout|FastTimer} timeout
|
|
2583
|
+
*/
|
|
2567
2584
|
clearTimeout(timeout) {
|
|
2568
2585
|
if (timeout[kFastTimer])
|
|
2569
2586
|
/**
|
|
@@ -2572,26 +2589,66 @@ var require_timers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2572
2589
|
timeout.clear();
|
|
2573
2590
|
else clearTimeout(timeout);
|
|
2574
2591
|
},
|
|
2592
|
+
/**
|
|
2593
|
+
* The setFastTimeout() method sets a fastTimer which executes a function once
|
|
2594
|
+
* the timer expires.
|
|
2595
|
+
* @param {Function} callback A function to be executed after the timer
|
|
2596
|
+
* expires.
|
|
2597
|
+
* @param {number} delay The time, in milliseconds that the timer should
|
|
2598
|
+
* wait before the specified function or code is executed.
|
|
2599
|
+
* @param {*} [arg] An optional argument to be passed to the callback function
|
|
2600
|
+
* when the timer expires.
|
|
2601
|
+
* @returns {FastTimer}
|
|
2602
|
+
*/
|
|
2575
2603
|
setFastTimeout(callback, delay, arg) {
|
|
2576
2604
|
return new FastTimer(callback, delay, arg);
|
|
2577
2605
|
},
|
|
2606
|
+
/**
|
|
2607
|
+
* The clearTimeout method cancels an instantiated FastTimer previously
|
|
2608
|
+
* created by calling setFastTimeout.
|
|
2609
|
+
*
|
|
2610
|
+
* @param {FastTimer} timeout
|
|
2611
|
+
*/
|
|
2578
2612
|
clearFastTimeout(timeout) {
|
|
2579
2613
|
timeout.clear();
|
|
2580
2614
|
},
|
|
2615
|
+
/**
|
|
2616
|
+
* The now method returns the value of the internal fast timer clock.
|
|
2617
|
+
*
|
|
2618
|
+
* @returns {number}
|
|
2619
|
+
*/
|
|
2581
2620
|
now() {
|
|
2582
2621
|
return fastNow;
|
|
2583
2622
|
},
|
|
2623
|
+
/**
|
|
2624
|
+
* Trigger the onTick function to process the fastTimers array.
|
|
2625
|
+
* Exported for testing purposes only.
|
|
2626
|
+
* Marking as deprecated to discourage any use outside of testing.
|
|
2627
|
+
* @deprecated
|
|
2628
|
+
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
|
|
2629
|
+
*/
|
|
2584
2630
|
tick(delay = 0) {
|
|
2585
2631
|
fastNow += delay - RESOLUTION_MS + 1;
|
|
2586
2632
|
onTick();
|
|
2587
2633
|
onTick();
|
|
2588
2634
|
},
|
|
2635
|
+
/**
|
|
2636
|
+
* Reset FastTimers.
|
|
2637
|
+
* Exported for testing purposes only.
|
|
2638
|
+
* Marking as deprecated to discourage any use outside of testing.
|
|
2639
|
+
* @deprecated
|
|
2640
|
+
*/
|
|
2589
2641
|
reset() {
|
|
2590
2642
|
fastNow = 0;
|
|
2591
2643
|
fastTimers.length = 0;
|
|
2592
2644
|
clearTimeout(fastNowTimeout);
|
|
2593
2645
|
fastNowTimeout = null;
|
|
2594
2646
|
},
|
|
2647
|
+
/**
|
|
2648
|
+
* Exporting for testing purposes only.
|
|
2649
|
+
* Marking as deprecated to discourage any use outside of testing.
|
|
2650
|
+
* @deprecated
|
|
2651
|
+
*/
|
|
2595
2652
|
kFastTimer
|
|
2596
2653
|
};
|
|
2597
2654
|
}));
|
|
@@ -3515,6 +3572,7 @@ var require_data_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3515
3572
|
const mimeType = {
|
|
3516
3573
|
type: typeLowercase,
|
|
3517
3574
|
subtype: subtypeLowercase,
|
|
3575
|
+
/** @type {Map<string, string>} */
|
|
3518
3576
|
parameters: /* @__PURE__ */ new Map(),
|
|
3519
3577
|
essence: `${typeLowercase}/${subtypeLowercase}`
|
|
3520
3578
|
};
|
|
@@ -16379,10 +16437,13 @@ async function fetchUserInfo(accessToken) {
|
|
|
16379
16437
|
* @param workspaceId - Workspace ID
|
|
16380
16438
|
* @param urls - URLs or name:url patterns
|
|
16381
16439
|
* @param context - Logging context (e.g., "CORS", "OAuth2 redirect URIs")
|
|
16382
|
-
* @
|
|
16440
|
+
* @param options - Optional behavior overrides
|
|
16441
|
+
* @returns Resolved URLs (or the original pattern for entries marked as
|
|
16442
|
+
* expected-but-not-yet-deployed via `options.expectedLocalNames`)
|
|
16383
16443
|
*/
|
|
16384
|
-
async function resolveStaticWebsiteUrls(client, workspaceId, urls, context) {
|
|
16444
|
+
async function resolveStaticWebsiteUrls(client, workspaceId, urls, context, options = {}) {
|
|
16385
16445
|
if (!urls) return [];
|
|
16446
|
+
const { expectedLocalNames } = options;
|
|
16386
16447
|
return (await Promise.all(urls.map(async (url) => {
|
|
16387
16448
|
const match = url.match(/:url(\/.*)?$/);
|
|
16388
16449
|
if (match && match.index !== void 0) {
|
|
@@ -16394,11 +16455,10 @@ async function resolveStaticWebsiteUrls(client, workspaceId, urls, context) {
|
|
|
16394
16455
|
name: siteName
|
|
16395
16456
|
});
|
|
16396
16457
|
if (response.staticwebsite?.url) return [response.staticwebsite.url + pathSuffix];
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
} catch {
|
|
16458
|
+
logger.warn(`Static website "${siteName}" has no URL assigned yet. Excluding from ${context}.`);
|
|
16459
|
+
return [];
|
|
16460
|
+
} catch (error) {
|
|
16461
|
+
if (error instanceof ConnectError && error.code === Code.NotFound && expectedLocalNames?.has(siteName)) return [url];
|
|
16402
16462
|
logger.warn(`Static website "${siteName}" not found for ${context} configuration. Excluding from ${context}.`);
|
|
16403
16463
|
return [];
|
|
16404
16464
|
}
|
|
@@ -16459,5 +16519,5 @@ async function closeConnectionPool() {
|
|
|
16459
16519
|
}
|
|
16460
16520
|
|
|
16461
16521
|
//#endregion
|
|
16462
|
-
export {
|
|
16463
|
-
//# sourceMappingURL=client-
|
|
16522
|
+
export { FilterSchema as $, FunctionExecution_Status as A, AuthOAuth2Client_GrantType as B, TailorDBType_Permission_Operator as C, IdPLang as D, PipelineResolver_OperationType as E, AuthConnection_Type as F, PATScope as G, AuthSCIMAttribute_Type as H, AuthHookPoint as I, GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus as J, TenantProviderConfig_TenantProviderType as K, AuthIDPConfig_AuthType as L, ExecutorJobStatus as M, ExecutorTargetType as N, IdPPermissionOperator as O, ExecutorTriggerType as P, Condition_Operator as Q, AuthInvokerSchema as R, TailorDBGQLPermission_Permit as S, TailorDBType_PermitAction as T, AuthSCIMAttribute_Uniqueness as U, AuthSCIMAttribute_Mutability as V, AuthSCIMConfig_AuthorizationType as W, Subgraph_ServiceType as X, ApplicationSchemaUpdateAttemptStatus as Y, ConditionSchema as Z, WorkspacePlatformUserRole as _, fetchMachineUserToken as a, TailorDBGQLPermission_Action as b, fetchUserInfo as c, initOperatorClient as d, PageDirection as et, parseMethodName as f, OperatorService as g, userAgent as h, fetchAll as i, FunctionExecution_Type as j, IdPPermissionPermit as k, formatRequestParams as l, resolveStaticWebsiteUrls as m, closeConnectionPool as n, fetchPaged as o, platformBaseUrl as p, UserProfileProviderConfig_UserProfileProviderType as q, createTransport as r, fetchPlatformMachineUserToken as s, MAX_PAGE_SIZE as t, initOAuth2Client as u, WorkflowExecution_Status as v, TailorDBType_Permission_Permit as w, TailorDBGQLPermission_Operator as x, WorkflowJobExecution_Status as y, AuthOAuth2Client_ClientType as z };
|
|
16523
|
+
//# sourceMappingURL=client-DQl5NPG9.mjs.map
|