@tailor-platform/sdk 1.58.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/{application-B59TaTk_.mjs → application-FnWOxBk7.mjs} +46 -27
  3. package/dist/application-FnWOxBk7.mjs.map +1 -0
  4. package/dist/application-VOdgMtOD.mjs +4 -0
  5. package/dist/{authconnection-TsdLYaLs.d.mts → authconnection-BIYzEh2p.d.mts} +2 -2
  6. package/dist/authconnection-D8SJGMpj.mjs.map +1 -1
  7. package/dist/cli/erd-viewer-assets/app.js +4 -4
  8. package/dist/cli/index.mjs +13 -12
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.mjs +4 -3
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/client-B-jRdlC_.mjs +4 -0
  13. package/dist/{client-62B-r3MN.mjs → client-W5P4NYYX.mjs} +117 -4
  14. package/dist/{client-62B-r3MN.mjs.map → client-W5P4NYYX.mjs.map} +1 -1
  15. package/dist/configure/index.d.mts +1 -1
  16. package/dist/configure/index.mjs +8 -8
  17. package/dist/configure/index.mjs.map +1 -1
  18. package/dist/{crashreport-CCGpLUlP.mjs → crashreport-D3DvAzdg.mjs} +3 -3
  19. package/dist/crashreport-D3DvAzdg.mjs.map +1 -0
  20. package/dist/{crashreport-CXD_Kjk-.mjs → crashreport-lnVTnbB5.mjs} +1 -1
  21. package/dist/file-B58Dm-2P.mjs.map +1 -1
  22. package/dist/{file-VTJbbOL3.d.mts → file-BzK8z3X-.d.mts} +2 -2
  23. package/dist/globals-ByrCoDip.mjs +109 -0
  24. package/dist/globals-ByrCoDip.mjs.map +1 -0
  25. package/dist/iconv-DreIffeM.mjs.map +1 -1
  26. package/dist/{iconv-Chu6Hit2.d.mts → iconv-kwrmd1U_.d.mts} +2 -2
  27. package/dist/{idp-Di9N4FSJ.d.mts → idp-BlBPtXJ-.d.mts} +2 -2
  28. package/dist/idp-Ch95ag8h.mjs.map +1 -1
  29. package/dist/{index-BWoHfE-i.d.mts → index-Cr6ufjZ5.d.mts} +10 -8
  30. package/dist/{index-DTSQthwF.d.mts → index-DRhMpdnA.d.mts} +7 -7
  31. package/dist/{job-CEAJLiGp.mjs → job-BpsFXPbi.mjs} +8 -17
  32. package/dist/job-BpsFXPbi.mjs.map +1 -0
  33. package/dist/mock-Dpu__UeJ.mjs +805 -0
  34. package/dist/mock-Dpu__UeJ.mjs.map +1 -0
  35. package/dist/registry-D0uB0OrK.mjs +178 -0
  36. package/dist/registry-D0uB0OrK.mjs.map +1 -0
  37. package/dist/{repl-editor-ihh8koiR.mjs → repl-editor-Y9QJDL0K.mjs} +3 -9
  38. package/dist/{repl-editor-ihh8koiR.mjs.map → repl-editor-Y9QJDL0K.mjs.map} +1 -1
  39. package/dist/runtime/authconnection.d.mts +1 -1
  40. package/dist/runtime/file.d.mts +1 -1
  41. package/dist/runtime/globals.d.mts +5 -5
  42. package/dist/runtime/iconv.d.mts +1 -1
  43. package/dist/runtime/idp.d.mts +1 -1
  44. package/dist/runtime/index.d.mts +7 -7
  45. package/dist/runtime/secretmanager.d.mts +1 -1
  46. package/dist/runtime/workflow.d.mts +1 -1
  47. package/dist/{runtime-BC-FbQkg.mjs → runtime-CrUa8Z2k.mjs} +238 -273
  48. package/dist/runtime-CrUa8Z2k.mjs.map +1 -0
  49. package/dist/secretmanager-B9h-U_8U.mjs.map +1 -1
  50. package/dist/{secretmanager-BhpDmxwT.d.mts → secretmanager-CKLB3wAQ.d.mts} +2 -2
  51. package/dist/utils/test/index.d.mts +5 -5
  52. package/dist/utils/test/index.mjs +7 -7
  53. package/dist/utils/test/index.mjs.map +1 -1
  54. package/dist/vitest/environment.mjs +3 -4
  55. package/dist/vitest/environment.mjs.map +1 -1
  56. package/dist/vitest/index.d.mts +167 -120
  57. package/dist/vitest/index.mjs +6 -6
  58. package/dist/vitest/index.mjs.map +1 -1
  59. package/dist/vitest/setup.d.mts +1 -1
  60. package/dist/vitest/setup.mjs +4 -3
  61. package/dist/vitest/setup.mjs.map +1 -1
  62. package/dist/workflow--aPbA8Uq.mjs.map +1 -1
  63. package/dist/{workflow-dYYH7QFa.d.mts → workflow-CMamswkK.d.mts} +2 -2
  64. package/docs/configuration.md +1 -1
  65. package/docs/runtime.md +9 -12
  66. package/docs/testing.md +92 -85
  67. package/package.json +5 -5
  68. package/dist/application-B59TaTk_.mjs.map +0 -1
  69. package/dist/application-gO_pa5BO.mjs +0 -4
  70. package/dist/client-BWl3f1XS.mjs +0 -4
  71. package/dist/crashreport-CCGpLUlP.mjs.map +0 -1
  72. package/dist/job-CEAJLiGp.mjs.map +0 -1
  73. package/dist/mock-B6PI49C_.mjs +0 -844
  74. package/dist/mock-B6PI49C_.mjs.map +0 -1
  75. package/dist/runtime-BC-FbQkg.mjs.map +0 -1
  76. package/dist/test-env-key-CSnK4W1Y.mjs +0 -30
  77. package/dist/test-env-key-CSnK4W1Y.mjs.map +0 -1
package/dist/cli/lib.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
- import { d as initOperatorClient } from "../client-62B-r3MN.mjs";
3
- import { $t as compareSnapshots, A as truncate, Bt as getExecutor, Ct as triggerExecutor, D as resumeWorkflow, Et as getExecutorJob, Ft as getWorkflowExecution, G as organizationTree, Ht as executeScript, It as listWorkflowExecutions, J as listOrganizations, Jt as DIFF_FILE_NAME, Kt as bundleMigrationScript, M as generate$1, Nt as getWorkflow, Ot as listExecutorJobs, Q as updateFolder, Qt as compareLocalTypesWithSnapshot, R as show, S as listApps, Tt as listExecutors, Ut as waitForExecution, V as remove, Vt as deploy, W as updateOrganization, Wt as MIGRATION_LABEL_KEY, X as getOrganization, Xt as MIGRATE_FILE_NAME, Yt as INITIAL_SCHEMA_NUMBER, Zt as SCHEMA_FILE_NAME, _ as getWorkspace, _n as generateUserTypes, _t as listFunctionRegistries, a as updateUser, an as getNextMigrationNumber, bn as apiCall, bt as listWebhookExecutors, cn as reconstructSnapshotFromMigrations, ct as listOAuth2Clients, d as inviteUser, dn as formatMigrationDiff, dt as getMachineUserToken, en as createSnapshotFromLocalTypes, et as listFolders, fn as hasChanges, h as listWorkspaces, ht as generate, in as getMigrationFiles, it as deleteFolder, jt as startWorkflow, k as listWorkflows, kt as watchExecutorJob, l as listUsers, mt as listMachineUsers, n as query, nn as getMigrationDirPath, nt as getFolder, ot as createFolder, p as restoreWorkspace, pn as getNamespacesWithMigrations, qt as DB_TYPES_FILE_NAME, rn as getMigrationFilePath, s as removeUser, t as isNativeTypeScriptRuntime, tn as getLatestMigrationNumber, un as formatDiffSummary, ut as getOAuth2Client, w as getAppHealth, x as createWorkspace, y as deleteWorkspace, yt as getFunctionRegistry } from "../runtime-BC-FbQkg.mjs";
4
- import { C as loadConfig, E as loadAccessToken, O as loadWorkspaceId, b as getDistDir } from "../application-B59TaTk_.mjs";
2
+ import { f as initOperatorClient } from "../client-W5P4NYYX.mjs";
3
+ import { $t as compareSnapshots, A as truncate, Bt as getExecutor, Ct as triggerExecutor, D as resumeWorkflow, Et as getExecutorJob, Ft as getWorkflowExecution, G as organizationTree, Ht as executeScript, It as listWorkflowExecutions, J as listOrganizations, Jt as DIFF_FILE_NAME, Kt as bundleMigrationScript, M as generate$1, Nt as getWorkflow, Ot as listExecutorJobs, Q as updateFolder, Qt as compareLocalTypesWithSnapshot, R as show, S as listApps, Tt as listExecutors, Ut as waitForExecution, V as remove, Vt as deploy, W as updateOrganization, Wt as MIGRATION_LABEL_KEY, X as getOrganization, Xt as MIGRATE_FILE_NAME, Yt as INITIAL_SCHEMA_NUMBER, Zt as SCHEMA_FILE_NAME, _ as getWorkspace, _n as generateUserTypes, _t as listFunctionRegistries, a as updateUser, an as getNextMigrationNumber, bn as apiCall, bt as listWebhookExecutors, cn as reconstructSnapshotFromMigrations, ct as listOAuth2Clients, d as inviteUser, dn as formatMigrationDiff, dt as getMachineUserToken, en as createSnapshotFromLocalTypes, et as listFolders, fn as hasChanges, h as listWorkspaces, ht as generate, in as getMigrationFiles, it as deleteFolder, jt as startWorkflow, k as listWorkflows, kt as watchExecutorJob, l as listUsers, mt as listMachineUsers, n as query, nn as getMigrationDirPath, nt as getFolder, ot as createFolder, p as restoreWorkspace, pn as getNamespacesWithMigrations, qt as DB_TYPES_FILE_NAME, rn as getMigrationFilePath, s as removeUser, t as isNativeTypeScriptRuntime, tn as getLatestMigrationNumber, un as formatDiffSummary, ut as getOAuth2Client, w as getAppHealth, x as createWorkspace, y as deleteWorkspace, yt as getFunctionRegistry } from "../runtime-CrUa8Z2k.mjs";
4
+ import { D as loadAccessToken, g as platformBundleDefinePlugin, k as loadWorkspaceId, w as loadConfig, x as getDistDir } from "../application-FnWOxBk7.mjs";
5
5
  import { n as enumConstantsPlugin } from "../enum-constants-C7DaWeQo.mjs";
6
6
  import { t as multiline } from "../multiline-Cf9ODpr1.mjs";
7
7
  import { n as fileUtilsPlugin } from "../file-utils-BHPxPXmn.mjs";
@@ -248,6 +248,7 @@ async function bundleSeedScript(namespace, typeNames) {
248
248
  return {
249
249
  namespace,
250
250
  bundledCode: (await rolldown.build({
251
+ plugins: [platformBundleDefinePlugin],
251
252
  input: entryPath,
252
253
  write: false,
253
254
  output: {
@@ -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 * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\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 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.\n// tsx's own register() picks `module.registerHooks` on Node ≥ 24.11.1 / 25.1 / 26\n// (avoiding the DEP0205 deprecation) and falls back to `module.register` on older runtimes.\nif (!isNativeTypeScriptRuntime()) {\n const { register } = await import(\"tsx/esm/api\");\n register();\n}\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 \"@/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 TailorDBSnapshotType,\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;CAClD,IAAI,aAAa,GACf,MAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,sCAEtF;CAIF,MAAM,gBAAgB,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,SAAS,CAAC;CAEhF,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,KAAK;EAGzB,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,O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;IACb,0BAA0B;GAC5B;GACA,UAAU;EACZ,CAA0B,GAEC,OAAO,GAAG;EAKnC,eAAe;CACjB;AACF;;;;AC7JA,IAAI,CAAC,0BAA0B,GAAG;CAChC,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,SAAS;AACX"}
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 * 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 { 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.\n// tsx's own register() picks `module.registerHooks` on Node ≥ 24.11.1 / 25.1 / 26\n// (avoiding the DEP0205 deprecation) and falls back to `module.register` on older runtimes.\nif (!isNativeTypeScriptRuntime()) {\n const { register } = await import(\"tsx/esm/api\");\n register();\n}\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 \"@/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 TailorDBSnapshotType,\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;CAClD,IAAI,a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AU;;;;;;;;;;;;;;6BAcR,UAAU;;;;;;+BAMR,UAAU;;;;;;6BAMZ,UAAU;;;;;;;;;;;AAWvC;;;;;;;;;;;;;AAcA,eAAsB,iBACpB,WACA,WAC2B;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;CACnC,QAAQ;EACN,WAAW;CACb;CA+BA,OAAO;EACL;EACA,cAJkB,MA1BC,SAAS,MAAM;GAClC,SAAS,CAAC,0BAA0B;GACpC,OAAO;GACP,OAAO;GACP,QAAQ;IACN,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,eAAe;IACf,SAAS,EACP,UAAU,WACZ;GACF;GACA,UAAU,CAAC,UAAU;GACrB,SAAS,EACP,gBAAgB,CAAC,QAAQ,QAAQ,EACnC;GACA;GACA,WAAW;IACT,mBAAmB;IACnB,aAAa;IACb,0BAA0B;GAC5B;GACA,UAAU;EACZ,CAA0B,GAEC,OAAO,GAAG;EAKnC,eAAe;CACjB;AACF;;;;AC/JA,IAAI,CAAC,0BAA0B,GAAG;CAChC,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,SAAS;AACX"}
@@ -0,0 +1,4 @@
1
+
2
+ import { _ as userAgent, a as fetchAll, c as fetchPlatformMachineUserToken, d as initOAuth2Client, f as initOperatorClient, g as retryInterceptor, h as resolveStaticWebsiteUrls, i as createTransport, l as fetchUserInfo, m as platformBaseUrl, n as RETRY_SAFE_CREATE_METHODS, o as fetchMachineUserToken, p as parseMethodName, r as closeConnectionPool, s as fetchPaged, t as MAX_PAGE_SIZE, u as formatRequestParams } from "./client-W5P4NYYX.mjs";
3
+
4
+ export { userAgent };
@@ -2,6 +2,7 @@
2
2
  import { n as logger } from "./logger-DpJyJvNz.mjs";
3
3
  import { t as readPackageJson } from "./package-json-DcQApfPQ.mjs";
4
4
  import { z } from "zod";
5
+ import { create } from "@bufbuild/protobuf";
5
6
  import { enumDesc, fileDesc, messageDesc, serviceDesc, tsEnum } from "@bufbuild/protobuf/codegenv2";
6
7
  import { MethodOptions_IdempotencyLevel, file_google_protobuf_descriptor, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_protobuf_struct, file_google_protobuf_timestamp } from "@bufbuild/protobuf/wkt";
7
8
  import { OAuth2Client } from "@badgateway/oauth2-client";
@@ -838,7 +839,17 @@ async function bearerTokenInterceptor(accessToken) {
838
839
  };
839
840
  }
840
841
  /**
841
- * Create an interceptor that retries idempotent requests with backoff.
842
+ * Create an interceptor that retries failed unary requests with backoff.
843
+ *
844
+ * Retries any unary method on `Unavailable`/`ResourceExhausted`, and `Internal`
845
+ * only for methods declared idempotent, up to 3 attempts (despite the historical
846
+ * "idempotent" naming, the first two codes are retried regardless of idempotency).
847
+ * As a targeted exception for the deploy/apply flow, a post-retry `AlreadyExists`
848
+ * from an allowlisted Create (see `RETRY_SAFE_CREATE_METHODS`) is treated as
849
+ * success, since it means a prior attempt already committed the resource
850
+ * server-side. Emits `logger.debug` traces on every retry and swallow so the
851
+ * cause of field `already_exists` failures can be diagnosed.
852
+ * @internal
842
853
  * @returns Retry interceptor
843
854
  */
844
855
  function retryInterceptor() {
@@ -850,8 +861,13 @@ function retryInterceptor() {
850
861
  try {
851
862
  return await next(req);
852
863
  } catch (error) {
864
+ if (i > 0 && isRetrySafeCreateAlreadyExists(error, req.method.name)) {
865
+ logger.debug(`retry: ${req.method.name} returned AlreadyExists on attempt ${i + 1}; treating as success (prior attempt likely committed)`);
866
+ return synthesizeEmptyUnaryResponse(req);
867
+ }
853
868
  if (isRetirable(error, req.method.idempotency)) {
854
869
  lastError = error;
870
+ logger.debug(`retry: ${req.method.name} attempt ${i + 1} failed with ${connectCodeName(error)}; retrying`);
855
871
  continue;
856
872
  }
857
873
  throw error;
@@ -861,12 +877,109 @@ function retryInterceptor() {
861
877
  };
862
878
  }
863
879
  /**
880
+ * Human-readable name for the Connect status code of an error, for diagnostics.
881
+ * @param error - Error thrown by a request (expected to be a ConnectError)
882
+ * @returns The Code name (e.g., "Unavailable"), or "unknown" for non-ConnectError
883
+ */
884
+ function connectCodeName(error) {
885
+ return error instanceof ConnectError ? Code[error.code] : "unknown";
886
+ }
887
+ /**
888
+ * Create RPCs for which a post-retry `AlreadyExists` may be treated as success.
889
+ *
890
+ * Membership is deliberately an allowlist, not `startsWith("Create")`: swallowing
891
+ * synthesizes an empty response (see `synthesizeEmptyUnaryResponse`), which is only
892
+ * safe when every caller ignores the response body. These are the deploy/apply
893
+ * resource creations that fire under heavy parallelism and discard their response.
894
+ *
895
+ * Intentionally excluded because their callers read the response body — swallowing
896
+ * would hand back an empty message and corrupt downstream state:
897
+ * - `CreateIdPClient` (uses `resp.client.clientSecret` to seed the secret vault)
898
+ * - `CreateWorkflowJobFunction` (uses `response.jobFunction.version`)
899
+ * - `CreateWorkspace` / `CreatePersonalAccessToken` / `CreateDeployment` /
900
+ * `CreateOrganizationFolder` (interactive commands that return created data)
901
+ *
902
+ * `CreateFunctionRegistry` is client-streaming and never reaches this path
903
+ * (streaming requests bypass the retry loop entirely).
904
+ *
905
+ * An allowlist miss is safe: the resource simply loses race protection and an
906
+ * `already_exists` surfaces loudly, as before — never a silent empty response.
907
+ *
908
+ * A drift guard (see client.test.ts) fails CI if any `client.create*` used in the
909
+ * deploy flow is neither listed here nor explicitly classified as response-consuming,
910
+ * so a newly added apply create cannot silently miss this list.
911
+ * @internal
912
+ */
913
+ const RETRY_SAFE_CREATE_METHODS = new Set([
914
+ "CreateApplication",
915
+ "CreateAuthConnection",
916
+ "CreateAuthHook",
917
+ "CreateAuthIDPConfig",
918
+ "CreateAuthMachineUser",
919
+ "CreateAuthOAuth2Client",
920
+ "CreateAuthSCIMConfig",
921
+ "CreateAuthSCIMResource",
922
+ "CreateAuthService",
923
+ "CreateExecutorExecutor",
924
+ "CreateIdPService",
925
+ "CreatePipelineResolver",
926
+ "CreatePipelineService",
927
+ "CreateSecretManagerSecret",
928
+ "CreateSecretManagerVault",
929
+ "CreateStaticWebsite",
930
+ "CreateTailorDBGQLPermission",
931
+ "CreateTailorDBService",
932
+ "CreateTailorDBType",
933
+ "CreateTenantConfig",
934
+ "CreateUserProfileConfig",
935
+ "CreateWorkflow"
936
+ ]);
937
+ /**
938
+ * Whether an error is an `AlreadyExists` from a retry-safe Create RPC.
939
+ *
940
+ * Only `AlreadyExists` stands in for "my prior write already landed"; for other
941
+ * verbs/codes it would be a real conflict that must surface.
942
+ * @param error - Error thrown by the request
943
+ * @param methodName - RPC method name (e.g., "CreateTailorDBType")
944
+ * @returns True if the error is an `AlreadyExists` from a retry-safe Create method
945
+ */
946
+ function isRetrySafeCreateAlreadyExists(error, methodName) {
947
+ return error instanceof ConnectError && error.code === Code.AlreadyExists && RETRY_SAFE_CREATE_METHODS.has(methodName);
948
+ }
949
+ /**
950
+ * Build a default (empty) unary response for the request's output message.
951
+ *
952
+ * Used when a retried Create is determined to have already succeeded on a prior
953
+ * attempt: callers in the deploy pipeline ignore Create response bodies, so an
954
+ * empty message faithfully represents the already-applied state.
955
+ * @param req - Unary request whose output schema is used
956
+ * @returns A synthesized unary response with an empty output message
957
+ */
958
+ function synthesizeEmptyUnaryResponse(req) {
959
+ return {
960
+ stream: false,
961
+ service: req.service,
962
+ method: req.method,
963
+ header: new Headers(),
964
+ message: create(req.method.output),
965
+ trailer: new Headers()
966
+ };
967
+ }
968
+ /**
969
+ * Base delay (ms) for the first retry. Subsequent attempts double it.
970
+ *
971
+ * Kept relatively large so a retry does not immediately race an original request
972
+ * that is still settling server-side under load (e.g. a compound create whose
973
+ * response was lost), which is what triggers the `already_exists` race.
974
+ */
975
+ const RETRY_BASE_DELAY_MS = 500;
976
+ /**
864
977
  * Wait for an exponential backoff delay with jitter.
865
978
  * @param attempt - Current retry attempt number (1-based)
866
979
  * @returns Promise that resolves after the delay
867
980
  */
868
981
  function waitRetryBackoff(attempt) {
869
- const backoff = 50 * 2 ** (attempt - 1) * (1 + .1 * (Math.random() * 2 - 1));
982
+ const backoff = RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * (1 + .1 * (Math.random() * 2 - 1));
870
983
  return new Promise((resolve) => setTimeout(resolve, backoff));
871
984
  }
872
985
  /**
@@ -1091,5 +1204,5 @@ async function closeConnectionPool() {
1091
1204
  }
1092
1205
 
1093
1206
  //#endregion
1094
- export { Condition_Operator as $, IdPPermissionPermit as A, AuthOAuth2Client_ClientType as B, TailorDBType_Permission_Operator as C, PipelineResolver_OperationType as D, CustomDomainStatus as E, ExecutorTriggerType as F, AuthSCIMConfig_AuthorizationType as G, AuthSCIMAttribute_Mutability as H, AuthConnection_Type as I, UserProfileProviderConfig_UserProfileProviderType as J, PATScope as K, AuthHookPoint as L, FunctionExecution_Type as M, ExecutorJobStatus as N, IdPLang as O, ExecutorTargetType as P, ConditionSchema as Q, AuthIDPConfig_AuthType as R, TailorDBGQLPermission_Permit as S, TailorDBType_PermitAction as T, AuthSCIMAttribute_Type as U, AuthOAuth2Client_GrantType as V, AuthSCIMAttribute_Uniqueness as W, ApplicationSchemaUpdateAttemptStatus as X, GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus as Y, Subgraph_ServiceType as Z, WorkspacePlatformUserRole as _, fetchMachineUserToken as a, TailorDBGQLPermission_Action as b, fetchUserInfo as c, initOperatorClient as d, FilterSchema as et, parseMethodName as f, OperatorService as g, userAgent as h, fetchAll as i, FunctionExecution_Status as j, IdPPermissionOperator as k, formatRequestParams as l, resolveStaticWebsiteUrls as m, closeConnectionPool as n, fetchPaged as o, platformBaseUrl as p, TenantProviderConfig_TenantProviderType as q, createTransport as r, fetchPlatformMachineUserToken as s, MAX_PAGE_SIZE as t, PageDirection as tt, initOAuth2Client as u, WorkflowExecution_Status as v, TailorDBType_Permission_Permit as w, TailorDBGQLPermission_Operator as x, WorkflowJobExecution_Status as y, AuthInvokerSchema as z };
1095
- //# sourceMappingURL=client-62B-r3MN.mjs.map
1207
+ export { Subgraph_ServiceType as $, IdPLang as A, AuthIDPConfig_AuthType as B, TailorDBGQLPermission_Operator as C, TailorDBType_PermitAction as D, TailorDBType_Permission_Permit as E, ExecutorJobStatus as F, AuthSCIMAttribute_Type as G, AuthOAuth2Client_ClientType as H, ExecutorTargetType as I, PATScope as J, AuthSCIMAttribute_Uniqueness as K, ExecutorTriggerType as L, IdPPermissionPermit as M, FunctionExecution_Status as N, CustomDomainStatus as O, FunctionExecution_Type as P, ApplicationSchemaUpdateAttemptStatus as Q, AuthConnection_Type as R, TailorDBGQLPermission_Action as S, TailorDBType_Permission_Operator as T, AuthOAuth2Client_GrantType as U, AuthInvokerSchema as V, AuthSCIMAttribute_Mutability as W, UserProfileProviderConfig_UserProfileProviderType as X, TenantProviderConfig_TenantProviderType as Y, GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus as Z, userAgent as _, fetchAll as a, WorkflowExecution_Status as b, fetchPlatformMachineUserToken as c, initOAuth2Client as d, ConditionSchema as et, initOperatorClient as f, retryInterceptor as g, resolveStaticWebsiteUrls as h, createTransport as i, IdPPermissionOperator as j, PipelineResolver_OperationType as k, fetchUserInfo as l, platformBaseUrl as m, RETRY_SAFE_CREATE_METHODS as n, FilterSchema as nt, fetchMachineUserToken as o, parseMethodName as p, AuthSCIMConfig_AuthorizationType as q, closeConnectionPool as r, PageDirection as rt, fetchPaged as s, MAX_PAGE_SIZE as t, Condition_Operator as tt, formatRequestParams as u, OperatorService as v, TailorDBGQLPermission_Permit as w, WorkflowJobExecution_Status as x, WorkspacePlatformUserRole as y, AuthHookPoint as z };
1208
+ //# sourceMappingURL=client-W5P4NYYX.mjs.map