@tailor-platform/sdk 1.10.1 → 1.11.1

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.
@@ -1,5 +1,6 @@
1
1
  /// <reference path="./../user-defined.d.ts" />
2
- import { E as TailorDBType, F as IdProviderConfig, L as OAuth2ClientInput, gt as Resolver, p as Executor, r as AppConfig, t as Generator } from "../index-CoqePlnt.mjs";
2
+ import { E as TailorDBType, F as IdProviderConfig, L as OAuth2ClientInput, gt as Resolver, p as Executor, r as AppConfig, t as Generator } from "../index-DcOTucF6.mjs";
3
+ import "politty";
3
4
  import { z } from "zod";
4
5
  import { OAuth2Client } from "@badgateway/oauth2-client";
5
6
  import { Duration, FieldMask, Timestamp, Value } from "@bufbuild/protobuf/wkt";
@@ -17587,6 +17588,21 @@ interface ExecutorJobAttemptInfo {
17587
17588
  finishedAt: string;
17588
17589
  operationReference: string;
17589
17590
  }
17591
+ interface ExecutorListInfo {
17592
+ name: string;
17593
+ triggerType: string;
17594
+ targetType: string;
17595
+ disabled: boolean;
17596
+ }
17597
+ interface ExecutorInfo {
17598
+ name: string;
17599
+ description: string;
17600
+ triggerType: string;
17601
+ targetType: string;
17602
+ disabled: boolean;
17603
+ triggerConfig: string;
17604
+ targetConfig: string;
17605
+ }
17590
17606
  //#endregion
17591
17607
  //#region src/cli/executor/jobs.d.ts
17592
17608
  interface ListExecutorJobsOptions {
@@ -17648,6 +17664,48 @@ declare function getExecutorJob(options: GetExecutorJobOptions): Promise<Executo
17648
17664
  */
17649
17665
  declare function watchExecutorJob(options: WatchExecutorJobOptions): Promise<WatchExecutorJobResult>;
17650
17666
  //#endregion
17667
+ //#region src/cli/executor/list.d.ts
17668
+ interface ListExecutorsOptions {
17669
+ workspaceId?: string;
17670
+ profile?: string;
17671
+ }
17672
+ /**
17673
+ * List executors in the workspace and return CLI-friendly info.
17674
+ * @param options - Executor listing options
17675
+ * @returns List of executors
17676
+ */
17677
+ declare function listExecutors(options?: ListExecutorsOptions): Promise<ExecutorListInfo[]>;
17678
+ //#endregion
17679
+ //#region src/cli/executor/get.d.ts
17680
+ interface GetExecutorOptions {
17681
+ name: string;
17682
+ workspaceId?: string;
17683
+ profile?: string;
17684
+ }
17685
+ /**
17686
+ * Get an executor by name and return CLI-friendly info.
17687
+ * @param options - Executor lookup options
17688
+ * @returns Executor information
17689
+ */
17690
+ declare function getExecutor(options: GetExecutorOptions): Promise<ExecutorInfo>;
17691
+ //#endregion
17692
+ //#region src/cli/executor/webhook.d.ts
17693
+ interface WebhookExecutorInfo {
17694
+ name: string;
17695
+ webhookUrl: string;
17696
+ disabled: boolean;
17697
+ }
17698
+ interface ListWebhookExecutorsOptions {
17699
+ workspaceId?: string;
17700
+ profile?: string;
17701
+ }
17702
+ /**
17703
+ * List executors with incoming webhook triggers and return CLI-friendly info.
17704
+ * @param options - Listing options
17705
+ * @returns List of webhook executors with URLs
17706
+ */
17707
+ declare function listWebhookExecutors(options?: ListWebhookExecutorsOptions): Promise<WebhookExecutorInfo[]>;
17708
+ //#endregion
17651
17709
  //#region src/cli/context.d.ts
17652
17710
  type LoadWorkspaceIdOptions = {
17653
17711
  workspaceId?: string;
@@ -18070,5 +18128,5 @@ declare function waitForExecution(client: OperatorClient, workspaceId: string, e
18070
18128
  */
18071
18129
  declare function executeScript(options: ScriptExecutionOptions): Promise<ScriptExecutionResult>;
18072
18130
  //#endregion
18073
- export { type AggregateArgs, type ApiCallOptions, type ApiCallResult, type AppHealthInfo, type AppInfo, type ApplicationInfo, type ApplyOptions, type AuthInvoker, type BreakingChangeInfo, type CodeGenerator, type CreateWorkspaceOptions, DB_TYPES_FILE_NAME, DIFF_FILE_NAME, type DeleteWorkspaceOptions, type DependencyKind, type ExecutionWaitResult, type Executor, type ExecutorGenerator, type ExecutorInput, type ExecutorJobAttemptInfo, type ExecutorJobDetailInfo, type ExecutorJobInfo, type ExecutorJobListInfo, type FullCodeGenerator, type FullInput, type GenerateOptions, type GeneratorResult, type HealthOptions as GetAppHealthOptions, type GetExecutorJobOptions, type GetMachineUserTokenOptions, type GetOAuth2ClientOptions, type GetWorkflowExecutionOptions, type GetWorkflowExecutionResult, type GetWorkflowOptions, type GetWorkspaceOptions, INITIAL_SCHEMA_NUMBER, type InviteUserOptions, type ListAppsOptions, type ListExecutorJobsOptions, type ListMachineUsersOptions, type ListOAuth2ClientsOptions, type ListUsersOptions, type ListWorkflowExecutionsOptions, type ListWorkflowsOptions, type ListWorkspacesOptions, type LoadedConfig, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, type MachineUserInfo, type MachineUserTokenInfo, type GenerateOptions$1 as MigrateGenerateOptions, type MigrationDiff, type MigrationInfo, type NamespaceWithMigrations, type OAuth2ClientCredentials, type OAuth2ClientInfo, type OperatorClient, type RemoveOptions, type RemoveUserOptions, type Resolver, type ResolverGenerator, type ResolverInput, type RestoreWorkspaceOptions, type ResumeWorkflowOptions, type ResumeWorkflowResultWithWait, SCHEMA_FILE_NAME, type SchemaSnapshot, type ScriptExecutionOptions, type ScriptExecutionResult, type SeedBundleResult, type ShowOptions, type SnapshotFieldConfig, type SnapshotType, type StartWorkflowOptions, type StartWorkflowResultWithWait, type TailorDBGenerator, type TailorDBInput, type TailorDBResolverGenerator, type TailorDBType, type TriggerExecutorOptions, type TriggerExecutorResult, type TruncateOptions, type UpdateUserOptions, type UserInfo, type WaitOptions, type WatchExecutorJobOptions, type WatchExecutorJobResult, type WorkflowExecutionInfo, type WorkflowInfo, type WorkflowJobExecutionInfo, type WorkflowListInfo, type WorkspaceDetails, type WorkspaceInfo, apiCall, apply, bundleSeedScript, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, createWorkspace, deleteWorkspace, executeScript, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutorJob, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, listApps, listExecutorJobs, listMachineUsers, listOAuth2Clients, listUsers, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, show, startWorkflow, triggerExecutor, truncate, updateUser, waitForExecution, watchExecutorJob };
18131
+ export { type AggregateArgs, type ApiCallOptions, type ApiCallResult, type AppHealthInfo, type AppInfo, type ApplicationInfo, type ApplyOptions, type AuthInvoker, type BreakingChangeInfo, type CodeGenerator, type CreateWorkspaceOptions, DB_TYPES_FILE_NAME, DIFF_FILE_NAME, type DeleteWorkspaceOptions, type DependencyKind, type ExecutionWaitResult, type Executor, type ExecutorGenerator, type ExecutorInfo, type ExecutorInput, type ExecutorJobAttemptInfo, type ExecutorJobDetailInfo, type ExecutorJobInfo, type ExecutorJobListInfo, type ExecutorListInfo, type FullCodeGenerator, type FullInput, type GenerateOptions, type GeneratorResult, type HealthOptions as GetAppHealthOptions, type GetExecutorJobOptions, type GetExecutorOptions, type GetMachineUserTokenOptions, type GetOAuth2ClientOptions, type GetWorkflowExecutionOptions, type GetWorkflowExecutionResult, type GetWorkflowOptions, type GetWorkspaceOptions, INITIAL_SCHEMA_NUMBER, type InviteUserOptions, type ListAppsOptions, type ListExecutorJobsOptions, type ListExecutorsOptions, type ListMachineUsersOptions, type ListOAuth2ClientsOptions, type ListUsersOptions, type ListWebhookExecutorsOptions, type ListWorkflowExecutionsOptions, type ListWorkflowsOptions, type ListWorkspacesOptions, type LoadedConfig, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, type MachineUserInfo, type MachineUserTokenInfo, type GenerateOptions$1 as MigrateGenerateOptions, type MigrationDiff, type MigrationInfo, type NamespaceWithMigrations, type OAuth2ClientCredentials, type OAuth2ClientInfo, type OperatorClient, type RemoveOptions, type RemoveUserOptions, type Resolver, type ResolverGenerator, type ResolverInput, type RestoreWorkspaceOptions, type ResumeWorkflowOptions, type ResumeWorkflowResultWithWait, SCHEMA_FILE_NAME, type SchemaSnapshot, type ScriptExecutionOptions, type ScriptExecutionResult, type SeedBundleResult, type ShowOptions, type SnapshotFieldConfig, type SnapshotType, type StartWorkflowOptions, type StartWorkflowResultWithWait, type TailorDBGenerator, type TailorDBInput, type TailorDBResolverGenerator, type TailorDBType, type TriggerExecutorOptions, type TriggerExecutorResult, type TruncateOptions, type UpdateUserOptions, type UserInfo, type WaitOptions, type WatchExecutorJobOptions, type WatchExecutorJobResult, type WebhookExecutorInfo, type WorkflowExecutionInfo, type WorkflowInfo, type WorkflowJobExecutionInfo, type WorkflowListInfo, type WorkspaceDetails, type WorkspaceInfo, apiCall, apply, bundleSeedScript, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, createWorkspace, deleteWorkspace, executeScript, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutor, getExecutorJob, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, listApps, listExecutorJobs, listExecutors, listMachineUsers, listOAuth2Clients, listUsers, listWebhookExecutors, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, show, startWorkflow, triggerExecutor, truncate, updateUser, waitForExecution, watchExecutorJob };
18074
18132
  //# sourceMappingURL=lib.d.mts.map
package/dist/cli/lib.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../chunk-CIV_ash9.mjs";
2
- import { $ as startWorkflow, At as hasChanges, B as getMachineUserToken, Bt as loadWorkspaceId, Ct as getMigrationFiles, D as truncate, Dt as reconstructSnapshotFromMigrations, E as listWorkflows, Ft as getDistDir, It as apiCall, J as getExecutorJob, Kt as initOperatorClient, L as listOAuth2Clients, M as show, Nt as generateUserTypes, Ot as formatDiffSummary, P as remove, Pt as loadConfig, St as getMigrationFilePath, U as listMachineUsers, W as generate, X as listExecutorJobs, Z as watchExecutorJob, _t as compareSnapshots, at as apply, bt as getLatestMigrationNumber, c as inviteUser, ct as waitForExecution, dt as DB_TYPES_FILE_NAME, f as listWorkspaces, ft as DIFF_FILE_NAME, g as deleteWorkspace, gt as compareLocalTypesWithSnapshot, ht as SCHEMA_FILE_NAME, i as removeUser, it as listWorkflowExecutions, jt as getNamespacesWithMigrations, k as generate$1, kt as formatMigrationDiff, lt as MIGRATION_LABEL_KEY, m as getWorkspace, mt as MIGRATE_FILE_NAME, n as updateUser, o as listUsers, pt as INITIAL_SCHEMA_NUMBER, q as triggerExecutor, rt as getWorkflowExecution, st as executeScript, tt as getWorkflow, u as restoreWorkspace, v as createWorkspace, vt as createSnapshotFromLocalTypes, w as resumeWorkflow, wt as getNextMigrationNumber, x as getAppHealth, xt as getMigrationDirPath, y as listApps, z as getOAuth2Client, zt as loadAccessToken } from "../update-Exhc9AkY.mjs";
2
+ import { At as getNextMigrationNumber, B as getMachineUserToken, Bt as loadConfig, Ct as compareSnapshots, D as truncate, Dt as getMigrationDirPath, E as listWorkflows, Et as getLatestMigrationNumber, Ft as formatMigrationDiff, Gt as loadAccessToken, Ht as apiCall, It as hasChanges, K as listWebhookExecutors, Kt as loadWorkspaceId, L as listOAuth2Clients, Lt as getNamespacesWithMigrations, M as show, Nt as reconstructSnapshotFromMigrations, Ot as getMigrationFilePath, P as remove, Pt as formatDiffSummary, Q as getExecutorJob, Qt as initOperatorClient, St as compareLocalTypesWithSnapshot, U as listMachineUsers, Vt as getDistDir, W as generate, Y as triggerExecutor, Z as listExecutors, _t as DB_TYPES_FILE_NAME, at as getWorkflow, bt as MIGRATE_FILE_NAME, c as inviteUser, ct as listWorkflowExecutions, dt as apply, et as listExecutorJobs, f as listWorkspaces, g as deleteWorkspace, ht as MIGRATION_LABEL_KEY, i as removeUser, k as generate$1, kt as getMigrationFiles, m as getWorkspace, mt as waitForExecution, n as updateUser, o as listUsers, pt as executeScript, rt as startWorkflow, st as getWorkflowExecution, tt as watchExecutorJob, u as restoreWorkspace, ut as getExecutor, v as createWorkspace, vt as DIFF_FILE_NAME, w as resumeWorkflow, wt as createSnapshotFromLocalTypes, x as getAppHealth, xt as SCHEMA_FILE_NAME, y as listApps, yt as INITIAL_SCHEMA_NUMBER, z as getOAuth2Client, zt as generateUserTypes } from "../update-D0muqqOP.mjs";
3
3
  import { u as logger } from "../application-BKBo5tGD.mjs";
4
4
  import { createRequire, register } from "node:module";
5
5
  import * as fs$1 from "node:fs";
@@ -156,5 +156,5 @@ async function bundleSeedScript(namespace, typeNames) {
156
156
  register("tsx", import.meta.url, { data: {} });
157
157
 
158
158
  //#endregion
159
- export { DB_TYPES_FILE_NAME, DIFF_FILE_NAME, INITIAL_SCHEMA_NUMBER, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, SCHEMA_FILE_NAME, apiCall, apply, bundleSeedScript, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, createWorkspace, deleteWorkspace, executeScript, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutorJob, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, listApps, listExecutorJobs, listMachineUsers, listOAuth2Clients, listUsers, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, show, startWorkflow, triggerExecutor, truncate, updateUser, waitForExecution, watchExecutorJob };
159
+ export { DB_TYPES_FILE_NAME, DIFF_FILE_NAME, INITIAL_SCHEMA_NUMBER, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, SCHEMA_FILE_NAME, apiCall, apply, bundleSeedScript, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, createWorkspace, deleteWorkspace, executeScript, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutor, getExecutorJob, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, listApps, listExecutorJobs, listExecutors, listMachineUsers, listOAuth2Clients, listUsers, listWebhookExecutors, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, show, startWorkflow, triggerExecutor, truncate, updateUser, waitForExecution, watchExecutorJob };
160
160
  //# sourceMappingURL=lib.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib.mjs","names":["fs"],"sources":["../../src/cli/bundler/seed/seed-bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\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 { createRequire } from \"node:module\";\nimport ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/utils/dist-dir\";\nimport { logger } from \"@/cli/utils/logger\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst REQUIRED_PACKAGES = [\"kysely\", \"@tailor-platform/function-kysely-tailordb\"] as const;\n\nlet dependencyCheckDone = false;\n\n/**\n * Check if required packages for seed bundling are installed.\n * Logs a warning if any are missing.\n */\nfunction checkSeedDependencies(): void {\n if (dependencyCheckDone) return;\n dependencyCheckDone = true;\n\n const require = createRequire(path.resolve(process.cwd(), \"package.json\"));\n const missing: string[] = [];\n\n for (const pkg of REQUIRED_PACKAGES) {\n try {\n require.resolve(pkg);\n } catch {\n missing.push(pkg);\n }\n }\n\n if (missing.length > 0) {\n logger.warn(\n `Missing optional dependencies for seed bundling: ${missing.join(\", \")}. ` +\n `Install them in your project: pnpm add -D ${missing.join(\" \")}`,\n );\n }\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 } from \"kysely\";\n import { TailordbDialect } from \"@tailor-platform/function-kysely-tailordb\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: 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\n try {\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 } 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 // Check for required dependencies (only once per session)\n checkSeedDependencies();\n\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 const outputPath = path.join(outputDir, `seed_${namespace}.js`);\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\n await rolldown.build(\n rolldown.defineConfig({\n input: entryPath,\n output: {\n file: outputPath,\n format: \"esm\",\n sourcemap: false,\n minify: false,\n inlineDynamicImports: true,\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\n // Read bundled output\n const bundledCode = fs.readFileSync(outputPath, \"utf-8\");\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { register } from \"node:module\";\n\n// Register tsx to handle TypeScript files when using CLI API programmatically\nregister(\"tsx\", import.meta.url, { data: {} });\n\nexport { apply } from \"./apply/index\";\nexport type { ApplyOptions } from \"./apply/index\";\nexport { generate } from \"./generator/index\";\nexport type { GenerateOptions } from \"./generator/options\";\nexport { loadConfig, type LoadedConfig } from \"./config-loader\";\nexport { generateUserTypes } from \"./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} from \"./generator/types\";\nexport type { TailorDBType } from \"@/parser/service/tailordb/types\";\nexport type { Resolver } from \"@/parser/service/resolver\";\nexport type { Executor } from \"@/parser/service/executor\";\n\nexport { show, type ShowOptions, type ApplicationInfo } from \"./show\";\nexport { remove, type RemoveOptions } from \"./remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./workspace/user/remove\";\nexport type { UserInfo } from \"./workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./workspace/app/list\";\nexport { getAppHealth, type HealthOptions as GetAppHealthOptions } from \"./workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./workspace/app/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./workflow/list\";\nexport { getWorkflow, type GetWorkflowOptions } from \"./workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n} from \"./workflow/executions\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorResult,\n} from \"./executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type GetExecutorJobOptions,\n type WatchExecutorJobOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./executor/jobs\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n} from \"./executor/transform\";\nexport { loadAccessToken, loadWorkspaceId } from \"./context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./api\";\nexport { truncate, type TruncateOptions } from \"./tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./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 \"./tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./tailordb/migrate/types\";\n\n// Seed exports\nexport { bundleSeedScript, type SeedBundleResult } from \"./bundler/seed/seed-bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./utils/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./client\";\nexport type { AuthInvoker } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAM,oBAAoB,CAAC,UAAU,4CAA4C;AAEjF,IAAI,sBAAsB;;;;;AAM1B,SAAS,wBAA8B;AACrC,KAAI,oBAAqB;AACzB,uBAAsB;CAEtB,MAAM,UAAU,cAAc,KAAK,QAAQ,QAAQ,KAAK,EAAE,eAAe,CAAC;CAC1E,MAAM,UAAoB,EAAE;AAE5B,MAAK,MAAM,OAAO,kBAChB,KAAI;AACF,UAAQ,QAAQ,IAAI;SACd;AACN,UAAQ,KAAK,IAAI;;AAIrB,KAAI,QAAQ,SAAS,EACnB,QAAO,KACL,oDAAoD,QAAQ,KAAK,KAAK,CAAC,8CACxB,QAAQ,KAAK,IAAI,GACjE;;AAIL,MAAM,aAAa;;;;;;AAOnB,SAAS,0BAA0B,WAA2B;AAC5D,QAAO,EAAY;;;;;;;;;;;;;;;;;;;;;;;0BAuBK,UAAU;;;2BAGT,OAAO,WAAW,CAAC;;;;;2BAKnB,UAAU;;;;;;;;;;;6BAWR,UAAU;;;;;6BAKV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;AAyBvC,eAAsB,iBACpB,WACA,WAC2B;AAE3B,wBAAuB;CAGvB,MAAM,YAAY,KAAK,QAAQ,YAAY,EAAE,OAAO;AACpD,MAAG,UAAU,WAAW,EAAE,WAAW,MAAM,CAAC;CAG5C,MAAM,YAAY,KAAK,KAAK,WAAW,QAAQ,UAAU,WAAW;CACpE,MAAM,aAAa,KAAK,KAAK,WAAW,QAAQ,UAAU,KAAK;CAG/D,MAAM,eAAe,0BAA0B,UAAU;AACzD,MAAG,cAAc,WAAW,aAAa;CAEzC,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,iBAAiB;SAC5B;AACN,aAAW;;AAIb,OAAM,SAAS,MACb,SAAS,aAAa;EACpB,OAAO;EACP,QAAQ;GACN,MAAM;GACN,QAAQ;GACR,WAAW;GACX,QAAQ;GACR,sBAAsB;GACtB,SAAS,EACP,UAAU,YACX;GACF;EACD,UAAU,CAAC,WAAW;EACtB,SAAS,EACP,gBAAgB,CAAC,QAAQ,SAAS,EACnC;EACD;EACA,WAAW;GACT,mBAAmB;GACnB,aAAa;GACb,0BAA0B;GAC3B;EACD,UAAU;EACX,CAAC,CACH;AAKD,QAAO;EACL;EACA,aAJkBA,KAAG,aAAa,YAAY,QAAQ;EAKtD,eAAe;EAChB;;;;;AC7LH,SAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"lib.mjs","names":["fs"],"sources":["../../src/cli/bundler/seed/seed-bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\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 { createRequire } from \"node:module\";\nimport ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/utils/dist-dir\";\nimport { logger } from \"@/cli/utils/logger\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst REQUIRED_PACKAGES = [\"kysely\", \"@tailor-platform/function-kysely-tailordb\"] as const;\n\nlet dependencyCheckDone = false;\n\n/**\n * Check if required packages for seed bundling are installed.\n * Logs a warning if any are missing.\n */\nfunction checkSeedDependencies(): void {\n if (dependencyCheckDone) return;\n dependencyCheckDone = true;\n\n const require = createRequire(path.resolve(process.cwd(), \"package.json\"));\n const missing: string[] = [];\n\n for (const pkg of REQUIRED_PACKAGES) {\n try {\n require.resolve(pkg);\n } catch {\n missing.push(pkg);\n }\n }\n\n if (missing.length > 0) {\n logger.warn(\n `Missing optional dependencies for seed bundling: ${missing.join(\", \")}. ` +\n `Install them in your project: pnpm add -D ${missing.join(\" \")}`,\n );\n }\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 } from \"kysely\";\n import { TailordbDialect } from \"@tailor-platform/function-kysely-tailordb\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: 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\n try {\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 } 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 // Check for required dependencies (only once per session)\n checkSeedDependencies();\n\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 const outputPath = path.join(outputDir, `seed_${namespace}.js`);\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\n await rolldown.build(\n rolldown.defineConfig({\n input: entryPath,\n output: {\n file: outputPath,\n format: \"esm\",\n sourcemap: false,\n minify: false,\n inlineDynamicImports: true,\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\n // Read bundled output\n const bundledCode = fs.readFileSync(outputPath, \"utf-8\");\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { register } from \"node:module\";\n\n// Register tsx to handle TypeScript files when using CLI API programmatically\nregister(\"tsx\", import.meta.url, { data: {} });\n\nexport { apply } from \"./apply/index\";\nexport type { ApplyOptions } from \"./apply/index\";\nexport { generate } from \"./generator/index\";\nexport type { GenerateOptions } from \"./generator/options\";\nexport { loadConfig, type LoadedConfig } from \"./config-loader\";\nexport { generateUserTypes } from \"./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} from \"./generator/types\";\nexport type { TailorDBType } from \"@/parser/service/tailordb/types\";\nexport type { Resolver } from \"@/parser/service/resolver\";\nexport type { Executor } from \"@/parser/service/executor\";\n\nexport { show, type ShowOptions, type ApplicationInfo } from \"./show\";\nexport { remove, type RemoveOptions } from \"./remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./workspace/user/remove\";\nexport type { UserInfo } from \"./workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./workspace/app/list\";\nexport { getAppHealth, type HealthOptions as GetAppHealthOptions } from \"./workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./workspace/app/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./workflow/list\";\nexport { getWorkflow, type GetWorkflowOptions } from \"./workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n} from \"./workflow/executions\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorResult,\n} from \"./executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type GetExecutorJobOptions,\n type WatchExecutorJobOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./executor/list\";\nexport { getExecutor, type GetExecutorOptions } from \"./executor/get\";\nexport {\n listWebhookExecutors,\n type ListWebhookExecutorsOptions,\n type WebhookExecutorInfo,\n} from \"./executor/webhook\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n ExecutorListInfo,\n ExecutorInfo,\n} from \"./executor/transform\";\nexport { loadAccessToken, loadWorkspaceId } from \"./context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./api\";\nexport { truncate, type TruncateOptions } from \"./tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./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 \"./tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./tailordb/migrate/types\";\n\n// Seed exports\nexport { bundleSeedScript, type SeedBundleResult } from \"./bundler/seed/seed-bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./utils/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./client\";\nexport type { AuthInvoker } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,MAAM,oBAAoB,CAAC,UAAU,4CAA4C;AAEjF,IAAI,sBAAsB;;;;;AAM1B,SAAS,wBAA8B;AACrC,KAAI,oBAAqB;AACzB,uBAAsB;CAEtB,MAAM,UAAU,cAAc,KAAK,QAAQ,QAAQ,KAAK,EAAE,eAAe,CAAC;CAC1E,MAAM,UAAoB,EAAE;AAE5B,MAAK,MAAM,OAAO,kBAChB,KAAI;AACF,UAAQ,QAAQ,IAAI;SACd;AACN,UAAQ,KAAK,IAAI;;AAIrB,KAAI,QAAQ,SAAS,EACnB,QAAO,KACL,oDAAoD,QAAQ,KAAK,KAAK,CAAC,8CACxB,QAAQ,KAAK,IAAI,GACjE;;AAIL,MAAM,aAAa;;;;;;AAOnB,SAAS,0BAA0B,WAA2B;AAC5D,QAAO,EAAY;;;;;;;;;;;;;;;;;;;;;;;0BAuBK,UAAU;;;2BAGT,OAAO,WAAW,CAAC;;;;;2BAKnB,UAAU;;;;;;;;;;;6BAWR,UAAU;;;;;6BAKV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;AAyBvC,eAAsB,iBACpB,WACA,WAC2B;AAE3B,wBAAuB;CAGvB,MAAM,YAAY,KAAK,QAAQ,YAAY,EAAE,OAAO;AACpD,MAAG,UAAU,WAAW,EAAE,WAAW,MAAM,CAAC;CAG5C,MAAM,YAAY,KAAK,KAAK,WAAW,QAAQ,UAAU,WAAW;CACpE,MAAM,aAAa,KAAK,KAAK,WAAW,QAAQ,UAAU,KAAK;CAG/D,MAAM,eAAe,0BAA0B,UAAU;AACzD,MAAG,cAAc,WAAW,aAAa;CAEzC,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,iBAAiB;SAC5B;AACN,aAAW;;AAIb,OAAM,SAAS,MACb,SAAS,aAAa;EACpB,OAAO;EACP,QAAQ;GACN,MAAM;GACN,QAAQ;GACR,WAAW;GACX,QAAQ;GACR,sBAAsB;GACtB,SAAS,EACP,UAAU,YACX;GACF;EACD,UAAU,CAAC,WAAW;EACtB,SAAS,EACP,gBAAgB,CAAC,QAAQ,SAAS,EACnC;EACD;EACA,WAAW;GACT,mBAAmB;GACnB,aAAa;GACb,0BAA0B;GAC3B;EACD,UAAU;EACX,CAAC,CACH;AAKD,QAAO;EACL;EACA,aAJkBA,KAAG,aAAa,YAAY,QAAQ;EAKtD,eAAe;EAChB;;;;;AC7LH,SAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
1
  /// <reference path="./../user-defined.d.ts" />
2
- import { $ as TailorDBInstance, A as AuthOwnConfig, At as unauthenticatedTailorUser, B as SCIMAttribute, D as AuthConfig, Dt as AttributeList, F as IdProviderConfig, G as SCIMResource, H as SCIMAttributeType, I as OAuth2ClientGrantType, J as UserAttributeListKey, K as TenantProviderConfig, L as OAuth2ClientInput, M as BuiltinIdP, N as DefinedAuth, O as AuthExternalConfig, Ot as AttributeMap, P as IDToken, Q as TailorDBField, R as OIDC, U as SCIMAuthorization, V as SCIMAttributeMapping, W as SCIMConfig, X as UsernameFieldKey, Y as UserAttributeMap, Z as ValueOperand, _t as ResolverExternalConfig, a as IdPExternalConfig, at as unsafeAllowAllGqlPermission, bt as ResolverServiceInput, c as WorkflowServiceConfig, d as defineStaticWebSite, et as TailorDBType, g as ExecutorServiceInput, gt as Resolver, h as ExecutorServiceConfig, ht as QueryType, i as IdPConfig, it as TailorTypePermission, j as AuthServiceInput, kt as TailorUser, l as WorkflowServiceInput, mt as TailorField, nt as PermissionCondition, ot as unsafeAllowAllTypePermission, q as UserAttributeKey, rt as TailorTypeGqlPermission, tt as db, u as StaticWebsiteConfig, wt as Env, yt as ResolverServiceConfig, z as SAML } from "../index-CoqePlnt.mjs";
3
- import { A as idpUserDeletedTrigger, B as WorkflowOperation, C as RecordUpdatedArgs, D as authAccessTokenRefreshedTrigger, E as authAccessTokenIssuedTrigger, F as resolverExecutedTrigger, G as WorkflowJob, H as WorkflowConfig, I as FunctionOperation, J as WorkflowJobOutput, K as WorkflowJobContext, L as GqlOperation, M as recordCreatedTrigger, N as recordDeletedTrigger, O as authAccessTokenRevokedTrigger, P as recordUpdatedTrigger, Q as defineAuth, R as Operation, S as RecordTrigger, T as ResolverExecutedTrigger, U as createWorkflow, V as Workflow, W as WORKFLOW_TEST_ENV_KEY, X as createResolver, Y as createWorkflowJob, Z as AuthInvoker, _ as AuthAccessTokenTrigger, a as defineGenerators, b as RecordCreatedArgs, c as Trigger, d as IncomingWebhookTrigger, f as incomingWebhookTrigger, g as AuthAccessTokenArgs, h as scheduleTrigger, i as defineConfig, j as idpUserUpdatedTrigger, k as idpUserCreatedTrigger, l as IncomingWebhookArgs, m as ScheduleTrigger, n as output, o as defineIdp, p as ScheduleArgs, q as WorkflowJobInput, r as t, s as createExecutor, t as infer, u as IncomingWebhookRequest, v as IdpUserArgs, w as ResolverExecutedArgs, x as RecordDeletedArgs, y as IdpUserTrigger, z as WebhookOperation } from "../index-BQw6I-mY.mjs";
2
+ import { $ as TailorDBInstance, A as AuthOwnConfig, At as unauthenticatedTailorUser, B as SCIMAttribute, D as AuthConfig, Dt as AttributeList, F as IdProviderConfig, G as SCIMResource, H as SCIMAttributeType, I as OAuth2ClientGrantType, J as UserAttributeListKey, K as TenantProviderConfig, L as OAuth2ClientInput, M as BuiltinIdP, N as DefinedAuth, O as AuthExternalConfig, Ot as AttributeMap, P as IDToken, Q as TailorDBField, R as OIDC, U as SCIMAuthorization, V as SCIMAttributeMapping, W as SCIMConfig, X as UsernameFieldKey, Y as UserAttributeMap, Z as ValueOperand, _t as ResolverExternalConfig, a as IdPExternalConfig, at as unsafeAllowAllGqlPermission, bt as ResolverServiceInput, c as WorkflowServiceConfig, d as defineStaticWebSite, et as TailorDBType, g as ExecutorServiceInput, gt as Resolver, h as ExecutorServiceConfig, ht as QueryType, i as IdPConfig, it as TailorTypePermission, j as AuthServiceInput, kt as TailorUser, l as WorkflowServiceInput, mt as TailorField, nt as PermissionCondition, ot as unsafeAllowAllTypePermission, q as UserAttributeKey, rt as TailorTypeGqlPermission, tt as db, u as StaticWebsiteConfig, wt as Env, yt as ResolverServiceConfig, z as SAML } from "../index-DcOTucF6.mjs";
3
+ import { A as idpUserDeletedTrigger, B as WorkflowOperation, C as RecordUpdatedArgs, D as authAccessTokenRefreshedTrigger, E as authAccessTokenIssuedTrigger, F as resolverExecutedTrigger, G as WorkflowJob, H as WorkflowConfig, I as FunctionOperation, J as WorkflowJobOutput, K as WorkflowJobContext, L as GqlOperation, M as recordCreatedTrigger, N as recordDeletedTrigger, O as authAccessTokenRevokedTrigger, P as recordUpdatedTrigger, Q as defineAuth, R as Operation, S as RecordTrigger, T as ResolverExecutedTrigger, U as createWorkflow, V as Workflow, W as WORKFLOW_TEST_ENV_KEY, X as createResolver, Y as createWorkflowJob, Z as AuthInvoker, _ as AuthAccessTokenTrigger, a as defineGenerators, b as RecordCreatedArgs, c as Trigger, d as IncomingWebhookTrigger, f as incomingWebhookTrigger, g as AuthAccessTokenArgs, h as scheduleTrigger, i as defineConfig, j as idpUserUpdatedTrigger, k as idpUserCreatedTrigger, l as IncomingWebhookArgs, m as ScheduleTrigger, n as output, o as defineIdp, p as ScheduleArgs, q as WorkflowJobInput, r as t, s as createExecutor, t as infer, u as IncomingWebhookRequest, v as IdpUserArgs, w as ResolverExecutedArgs, x as RecordDeletedArgs, y as IdpUserTrigger, z as WebhookOperation } from "../index-DnoS_Mi4.mjs";
4
4
  export { AttributeList, AttributeMap, AuthAccessTokenArgs, AuthAccessTokenTrigger, AuthConfig, AuthExternalConfig, AuthInvoker, AuthOwnConfig, AuthServiceInput, BuiltinIdP, DefinedAuth, Env, ExecutorServiceConfig, ExecutorServiceInput, FunctionOperation, GqlOperation, IDToken, IdPConfig, IdPExternalConfig, IdProviderConfig, IdpUserArgs, IdpUserTrigger, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookTrigger, OAuth2ClientInput as OAuth2Client, OAuth2ClientGrantType, OIDC, Operation, PermissionCondition, QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordTrigger, RecordUpdatedArgs, Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, ResolverExternalConfig, ResolverServiceConfig, ResolverServiceInput, SAML, SCIMAttribute, SCIMAttributeMapping, SCIMAttributeType, SCIMAuthorization, SCIMConfig, SCIMResource, ScheduleArgs, ScheduleTrigger, StaticWebsiteConfig, TailorDBField, TailorDBInstance, TailorDBType, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, TenantProviderConfig, Trigger, UserAttributeKey, UserAttributeListKey, UserAttributeMap, UsernameFieldKey, ValueOperand, WORKFLOW_TEST_ENV_KEY, WebhookOperation, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, WorkflowJobInput, WorkflowJobOutput, WorkflowOperation, WorkflowServiceConfig, WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, createExecutor, createResolver, createWorkflow, createWorkflowJob, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllTypePermission };
@@ -1,4 +1,5 @@
1
1
  import { n as createWorkflowJob, t as WORKFLOW_TEST_ENV_KEY } from "../job-l-pIR9IY.mjs";
2
+ import { cloneDeep } from "es-toolkit";
2
3
 
3
4
  //#region src/configure/types/field.ts
4
5
  /**
@@ -571,17 +572,20 @@ function createTailorDBField(type, options, fields, values) {
571
572
  return this;
572
573
  },
573
574
  clone(cloneOptions) {
574
- const clonedField = createTailorDBField(type, options, fields, values);
575
- Object.assign(clonedField._metadata, this._metadata);
575
+ let clonedFields = fields;
576
+ if (fields) {
577
+ const cloned = {};
578
+ for (const [key, field$1] of Object.entries(fields)) cloned[key] = field$1.clone();
579
+ clonedFields = cloned;
580
+ }
581
+ const clonedField = createTailorDBField(type, options, clonedFields, values);
582
+ Object.assign(clonedField._metadata, cloneDeep(this._metadata));
576
583
  if (cloneOptions) {
577
584
  if (cloneOptions.optional !== void 0) clonedField._metadata.required = !cloneOptions.optional;
578
585
  if (cloneOptions.array !== void 0) clonedField._metadata.array = cloneOptions.array;
579
586
  }
580
587
  if (_rawRelation) {
581
- const clonedRawRelation = {
582
- ..._rawRelation,
583
- toward: { ..._rawRelation.toward }
584
- };
588
+ const clonedRawRelation = cloneDeep(_rawRelation);
585
589
  clonedField._setRawRelation(clonedRawRelation);
586
590
  }
587
591
  return clonedField;