@tailor-platform/sdk 1.28.0 → 1.30.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 (64) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/{application-CBJFUKrU.mjs → application-Bf8SUAtR.mjs} +97 -77
  3. package/dist/application-Bf8SUAtR.mjs.map +1 -0
  4. package/dist/{application-WyZetOky.mjs → application-DAQVP9CS.mjs} +3 -3
  5. package/dist/chunk-DEt8GZDa.mjs +8 -0
  6. package/dist/cli/index.mjs +118 -52
  7. package/dist/cli/index.mjs.map +1 -1
  8. package/dist/cli/lib.d.mts +208 -43
  9. package/dist/cli/lib.mjs +26 -28
  10. package/dist/cli/lib.mjs.map +1 -1
  11. package/dist/cli/skills.mjs +1 -1
  12. package/dist/client-CW4Oh3iz.mjs +6 -0
  13. package/dist/client-CZmQBXAY.mjs +16294 -0
  14. package/dist/client-CZmQBXAY.mjs.map +1 -0
  15. package/dist/configure/index.d.mts +4 -4
  16. package/dist/configure/index.mjs +1 -1
  17. package/dist/{crash-report-Cot_9Esm.mjs → crash-report-CYrETw1c.mjs} +2 -2
  18. package/dist/{crash-report-Ju8cQF-l.mjs → crash-report-DizNMVnm.mjs} +3 -3
  19. package/dist/{crash-report-Ju8cQF-l.mjs.map → crash-report-DizNMVnm.mjs.map} +1 -1
  20. package/dist/{env-BuMbIknz.d.mts → env-DiWYe80_.d.mts} +2 -2
  21. package/dist/{index-CbnLNm14.d.mts → index-2WQbf_LH.d.mts} +2 -2
  22. package/dist/{index-cD9sQLTh.d.mts → index-BU7Cd5I4.d.mts} +4 -4
  23. package/dist/{index-B0Lrzywd.d.mts → index-DCEMVfJA.d.mts} +2 -2
  24. package/dist/{index-D1AM_02Y.d.mts → index-HvMUWjvV.d.mts} +2 -2
  25. package/dist/{index-CyapgSFI.d.mts → index-rH_De6hM.d.mts} +2 -2
  26. package/dist/{interceptor-B0d_GrI5.mjs → interceptor-DgQNmwWJ.mjs} +2 -2
  27. package/dist/{interceptor-B0d_GrI5.mjs.map → interceptor-DgQNmwWJ.mjs.map} +1 -1
  28. package/dist/kysely/index.mjs +1 -1
  29. package/dist/{package-json-DHfTiUCS.mjs → package-json-DiZWrkIA.mjs} +1 -1
  30. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  31. package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
  32. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  33. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  34. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  35. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  36. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  37. package/dist/plugin/builtin/seed/index.mjs +1 -1
  38. package/dist/plugin/index.d.mts +2 -2
  39. package/dist/plugin/index.mjs +1 -1
  40. package/dist/{plugin-D3a0-qe0.d.mts → plugin-C-UdAM8C.d.mts} +2 -2
  41. package/dist/{query-WYq8RvYp.mjs → query-C3oQTLvb.mjs} +670 -132
  42. package/dist/query-C3oQTLvb.mjs.map +1 -0
  43. package/dist/schema-BePzTFBV.mjs.map +1 -1
  44. package/dist/seed/index.mjs +1 -1
  45. package/dist/{telemetry-VvNfsyEE.mjs → telemetry-BSUlYTs-.mjs} +2 -2
  46. package/dist/{telemetry-VvNfsyEE.mjs.map → telemetry-BSUlYTs-.mjs.map} +1 -1
  47. package/dist/telemetry-BtN2l0f1.mjs +4 -0
  48. package/dist/utils/test/index.d.mts +2 -2
  49. package/dist/utils/test/index.mjs +1 -1
  50. package/dist/{workflow.generated-BsgIlrH-.d.mts → workflow.generated-C5wMcCjB.d.mts} +2 -2
  51. package/docs/cli/function.md +1 -1
  52. package/docs/cli/organization.md +426 -0
  53. package/docs/cli/user.md +21 -22
  54. package/docs/cli/workspace.md +0 -7
  55. package/docs/cli-reference.md +32 -12
  56. package/docs/services/executor.md +46 -0
  57. package/package.json +8 -8
  58. package/dist/application-CBJFUKrU.mjs.map +0 -1
  59. package/dist/chunk-Cz-A8uMR.mjs +0 -3
  60. package/dist/client-C2_wgujH.mjs +0 -6
  61. package/dist/client-bTbnbQbB.mjs +0 -957
  62. package/dist/client-bTbnbQbB.mjs.map +0 -1
  63. package/dist/query-WYq8RvYp.mjs.map +0 -1
  64. package/dist/telemetry-BevrwWwF.mjs +0 -4
@@ -1,9 +1,9 @@
1
- import { C as TailorDBType, Ct as IncomingWebhookTrigger, Et as ScheduleTriggerInput, Mt as IdProvider, Nt as OAuth2ClientInput, mt as Resolver, n as Plugin, r as PluginAttachment, vt as Executor, w as TypeSourceInfoEntry } from "../plugin-D3a0-qe0.mjs";
2
- import { n as AppConfig } from "../workflow.generated-BsgIlrH-.mjs";
3
- import { n as kyselyTypePlugin } from "../index-CyapgSFI.mjs";
4
- import { n as enumConstantsPlugin } from "../index-CbnLNm14.mjs";
5
- import { n as fileUtilsPlugin } from "../index-B0Lrzywd.mjs";
6
- import { n as seedPlugin } from "../index-D1AM_02Y.mjs";
1
+ import { C as TailorDBType, Ct as IncomingWebhookTrigger, Et as ScheduleTriggerInput, Mt as IdProvider, Nt as OAuth2ClientInput, mt as Resolver, n as Plugin, r as PluginAttachment, vt as Executor, w as TypeSourceInfoEntry } from "../plugin-C-UdAM8C.mjs";
2
+ import { n as AppConfig } from "../workflow.generated-C5wMcCjB.mjs";
3
+ import { n as kyselyTypePlugin } from "../index-rH_De6hM.mjs";
4
+ import { n as enumConstantsPlugin } from "../index-2WQbf_LH.mjs";
5
+ import { n as fileUtilsPlugin } from "../index-DCEMVfJA.mjs";
6
+ import { n as seedPlugin } from "../index-HvMUWjvV.mjs";
7
7
  import { z } from "zod";
8
8
  import { OAuth2Client } from "@badgateway/oauth2-client";
9
9
  import { Duration, FieldMask, Timestamp, Value } from "@bufbuild/protobuf/wkt";
@@ -13,40 +13,6 @@ import { GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
13
13
  import { JsonObject, Message } from "@bufbuild/protobuf";
14
14
  import { Jsonifiable } from "type-fest";
15
15
 
16
- //#region src/cli/shared/config-loader.d.ts
17
- /**
18
- * Loaded configuration with resolved path
19
- */
20
- type LoadedConfig = AppConfig & {
21
- path: string;
22
- };
23
- declare const GeneratorConfigSchema: z.core.$ZodBranded<z.ZodObject<{
24
- id: z.ZodString;
25
- description: z.ZodString;
26
- dependencies: z.ZodArray<z.ZodEnum<{
27
- executor: "executor";
28
- tailordb: "tailordb";
29
- resolver: "resolver";
30
- }>>;
31
- processType: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
32
- processResolver: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
33
- processExecutor: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
34
- processTailorDBNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
35
- processResolverNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
36
- aggregate: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodAny>;
37
- }, z.core.$strip>, "CodeGenerator", "out">;
38
- type Generator = z.output<typeof GeneratorConfigSchema>;
39
- /**
40
- * Load Tailor configuration file and associated generators and plugins.
41
- * @param configPath - Optional explicit config path
42
- * @returns Loaded config, generators, plugins, and config path
43
- */
44
- declare function loadConfig(configPath?: string): Promise<{
45
- config: LoadedConfig;
46
- generators: Generator[];
47
- plugins: Plugin[];
48
- }>;
49
- //#endregion
50
16
  //#region ../tailor-proto/src/tailor/v1/workspace_resource_pb.d.ts
51
17
  /**
52
18
  * @generated from message tailor.v1.Organization
@@ -16989,6 +16955,51 @@ declare function initOperatorClient(accessToken: string): Promise<Client<_bufbui
16989
16955
  };
16990
16956
  }>>>;
16991
16957
  //#endregion
16958
+ //#region src/cli/shared/config-loader.d.ts
16959
+ /**
16960
+ * Loaded configuration with resolved path
16961
+ */
16962
+ type LoadedConfig = AppConfig & {
16963
+ path: string;
16964
+ };
16965
+ declare const GeneratorConfigSchema: z.core.$ZodBranded<z.ZodObject<{
16966
+ id: z.ZodString;
16967
+ description: z.ZodString;
16968
+ dependencies: z.ZodArray<z.ZodEnum<{
16969
+ executor: "executor";
16970
+ tailordb: "tailordb";
16971
+ resolver: "resolver";
16972
+ }>>;
16973
+ processType: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
16974
+ processResolver: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
16975
+ processExecutor: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
16976
+ processTailorDBNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
16977
+ processResolverNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
16978
+ aggregate: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodAny>;
16979
+ }, z.core.$strip>, "CodeGenerator", "out">;
16980
+ type Generator = z.output<typeof GeneratorConfigSchema>;
16981
+ /**
16982
+ * Load Tailor configuration file and associated generators and plugins.
16983
+ * @param configPath - Optional explicit config path
16984
+ * @returns Loaded config, generators, plugins, and config path
16985
+ */
16986
+ declare function loadConfig(configPath?: string): Promise<{
16987
+ config: LoadedConfig;
16988
+ generators: Generator[];
16989
+ plugins: Plugin[];
16990
+ }>;
16991
+ //#endregion
16992
+ //#region src/cli/commands/apply/function-registry.d.ts
16993
+ /**
16994
+ * In-memory bundled scripts organized by kind.
16995
+ */
16996
+ type BundledScripts = {
16997
+ resolvers: Map<string, string>;
16998
+ executors: Map<string, string>;
16999
+ workflowJobs: Map<string, string>;
17000
+ authHooks: Map<string, string>;
17001
+ };
17002
+ //#endregion
16992
17003
  //#region src/cli/commands/apply/apply.d.ts
16993
17004
  interface ApplyOptions {
16994
17005
  workspaceId?: string;
@@ -17004,9 +17015,11 @@ interface ApplyOptions {
17004
17015
  /**
17005
17016
  * Apply the configured application to the Tailor platform.
17006
17017
  * @param options - Options for apply execution
17007
- * @returns Promise that resolves when apply completes
17018
+ * @returns Promise that resolves to `{ bundledScripts }` when `buildOnly` is true, otherwise void
17008
17019
  */
17009
- declare function apply(options?: ApplyOptions): Promise<void>;
17020
+ declare function apply(options?: ApplyOptions): Promise<{
17021
+ bundledScripts: BundledScripts;
17022
+ } | undefined>;
17010
17023
  //#endregion
17011
17024
  //#region src/cli/commands/generate/types.d.ts
17012
17025
  interface GeneratedFile {
@@ -17908,6 +17921,158 @@ interface ListWebhookExecutorsOptions {
17908
17921
  */
17909
17922
  declare function listWebhookExecutors(options?: ListWebhookExecutorsOptions): Promise<WebhookExecutorInfo[]>;
17910
17923
  //#endregion
17924
+ //#region src/cli/commands/organization/transform.d.ts
17925
+ interface UserOrganizationInfo {
17926
+ organizationId: string;
17927
+ organizationName: string;
17928
+ rootFolderId: string;
17929
+ rootFolderName: string;
17930
+ displayName: string;
17931
+ }
17932
+ interface OrganizationInfo {
17933
+ id: string;
17934
+ name: string;
17935
+ createdAt: Date | null;
17936
+ updatedAt: Date | null;
17937
+ }
17938
+ interface FolderListInfo {
17939
+ id: string;
17940
+ name: string;
17941
+ organizationId: string;
17942
+ parentFolderId: string;
17943
+ hasChildren: boolean;
17944
+ createdAt: Date | null;
17945
+ }
17946
+ interface FolderInfo extends FolderListInfo {
17947
+ updatedAt: Date | null;
17948
+ }
17949
+ //#endregion
17950
+ //#region src/cli/commands/organization/list.d.ts
17951
+ interface ListOrganizationsOptions {
17952
+ limit?: number;
17953
+ }
17954
+ /**
17955
+ * List organizations the current user belongs to.
17956
+ * @param options - Organization listing options
17957
+ * @returns List of user organizations
17958
+ */
17959
+ declare function listOrganizations(options?: ListOrganizationsOptions): Promise<UserOrganizationInfo[]>;
17960
+ //#endregion
17961
+ //#region src/cli/commands/organization/get.d.ts
17962
+ declare const getOrganizationOptionsSchema: z.ZodObject<{
17963
+ organizationId: z.ZodUUID;
17964
+ }, z.core.$strip>;
17965
+ type GetOrganizationOptions = z.input<typeof getOrganizationOptionsSchema>;
17966
+ /**
17967
+ * Get detailed information about an organization.
17968
+ * @param options - Organization get options
17969
+ * @returns Organization details
17970
+ */
17971
+ declare function getOrganization(options: GetOrganizationOptions): Promise<OrganizationInfo>;
17972
+ //#endregion
17973
+ //#region src/cli/commands/organization/update.d.ts
17974
+ declare const updateOrganizationOptionsSchema: z.ZodObject<{
17975
+ organizationId: z.ZodUUID;
17976
+ name: z.ZodString;
17977
+ }, z.core.$strip>;
17978
+ type UpdateOrganizationOptions = z.input<typeof updateOrganizationOptionsSchema>;
17979
+ /**
17980
+ * Update an organization's name.
17981
+ * @param options - Organization update options
17982
+ * @returns Updated organization details
17983
+ */
17984
+ declare function updateOrganization(options: UpdateOrganizationOptions): Promise<OrganizationInfo>;
17985
+ //#endregion
17986
+ //#region src/cli/commands/organization/tree.d.ts
17987
+ interface OrganizationTreeOptions {
17988
+ organizationId?: string;
17989
+ depth?: number;
17990
+ }
17991
+ interface OrganizationTreeJson {
17992
+ organizationId: string;
17993
+ organizationName: string;
17994
+ folders: FolderTreeJson[];
17995
+ }
17996
+ interface FolderTreeJson {
17997
+ id: string;
17998
+ name: string;
17999
+ children: FolderTreeJson[];
18000
+ }
18001
+ /**
18002
+ * Display a tree view of organizations and their folder hierarchy.
18003
+ * @param options - Tree display options
18004
+ * @returns Organization tree as structured data
18005
+ */
18006
+ declare function organizationTree(options?: OrganizationTreeOptions): Promise<OrganizationTreeJson[]>;
18007
+ //#endregion
18008
+ //#region src/cli/commands/organization/folder/list.d.ts
18009
+ declare const listFoldersOptionsSchema: z.ZodObject<{
18010
+ organizationId: z.ZodUUID;
18011
+ parentFolderId: z.ZodOptional<z.ZodString>;
18012
+ limit: z.ZodOptional<z.ZodNumber>;
18013
+ }, z.core.$strip>;
18014
+ type ListFoldersOptions = z.input<typeof listFoldersOptionsSchema>;
18015
+ /**
18016
+ * List folders in an organization.
18017
+ * @param options - Folder listing options
18018
+ * @returns List of folders
18019
+ */
18020
+ declare function listFolders(options: ListFoldersOptions): Promise<FolderListInfo[]>;
18021
+ //#endregion
18022
+ //#region src/cli/commands/organization/folder/get.d.ts
18023
+ declare const getFolderOptionsSchema: z.ZodObject<{
18024
+ organizationId: z.ZodUUID;
18025
+ folderId: z.ZodUUID;
18026
+ }, z.core.$strip>;
18027
+ type GetFolderOptions = z.input<typeof getFolderOptionsSchema>;
18028
+ /**
18029
+ * Get detailed information about a folder.
18030
+ * @param options - Folder get options
18031
+ * @returns Folder details
18032
+ */
18033
+ declare function getFolder(options: GetFolderOptions): Promise<FolderInfo>;
18034
+ //#endregion
18035
+ //#region src/cli/commands/organization/folder/create.d.ts
18036
+ declare const createFolderOptionsSchema: z.ZodObject<{
18037
+ organizationId: z.ZodUUID;
18038
+ parentFolderId: z.ZodOptional<z.ZodString>;
18039
+ name: z.ZodString;
18040
+ }, z.core.$strip>;
18041
+ type CreateFolderOptions = z.input<typeof createFolderOptionsSchema>;
18042
+ /**
18043
+ * Create a new folder in an organization.
18044
+ * @param options - Folder creation options
18045
+ * @returns Created folder details
18046
+ */
18047
+ declare function createFolder(options: CreateFolderOptions): Promise<FolderInfo>;
18048
+ //#endregion
18049
+ //#region src/cli/commands/organization/folder/update.d.ts
18050
+ declare const updateFolderOptionsSchema: z.ZodObject<{
18051
+ organizationId: z.ZodUUID;
18052
+ folderId: z.ZodUUID;
18053
+ name: z.ZodString;
18054
+ }, z.core.$strip>;
18055
+ type UpdateFolderOptions = z.input<typeof updateFolderOptionsSchema>;
18056
+ /**
18057
+ * Update a folder's name.
18058
+ * @param options - Folder update options
18059
+ * @returns Updated folder details
18060
+ */
18061
+ declare function updateFolder(options: UpdateFolderOptions): Promise<FolderInfo>;
18062
+ //#endregion
18063
+ //#region src/cli/commands/organization/folder/delete.d.ts
18064
+ declare const deleteFolderOptionsSchema: z.ZodObject<{
18065
+ organizationId: z.ZodUUID;
18066
+ folderId: z.ZodUUID;
18067
+ }, z.core.$strip>;
18068
+ type DeleteFolderOptions = z.input<typeof deleteFolderOptionsSchema>;
18069
+ /**
18070
+ * Delete a folder from an organization.
18071
+ * @param options - Folder deletion options
18072
+ * @returns Promise that resolves when deletion completes
18073
+ */
18074
+ declare function deleteFolder(options: DeleteFolderOptions): Promise<void>;
18075
+ //#endregion
17911
18076
  //#region src/cli/shared/context.d.ts
17912
18077
  type LoadWorkspaceIdOptions = {
17913
18078
  workspaceId?: string;
@@ -18552,5 +18717,5 @@ declare function waitForExecution(client: OperatorClient, workspaceId: string, e
18552
18717
  */
18553
18718
  declare function executeScript(options: ScriptExecutionOptions): Promise<ScriptExecutionResult>;
18554
18719
  //#endregion
18555
- export { type AggregateArgs, type ApiCallOptions, type ApiCallResult, type AppHealthInfo, type AppInfo, type ApplicationInfo, type ApplyOptions, type AuthInvoker, type BreakingChangeInfo, type ChunkSeedDataOptions, 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 GetExecutorJobTypedOptions, type GetExecutorOptions, type GetExecutorTypedOptions, type GetMachineUserTokenOptions, type GetOAuth2ClientOptions, type GetWorkflowExecutionOptions, type GetWorkflowExecutionResult, type GetWorkflowOptions, type GetWorkflowTypedOptions, type GetWorkspaceOptions, INITIAL_SCHEMA_NUMBER, type InviteUserOptions, type ListAppsOptions, type ListExecutorJobsOptions, type ListExecutorJobsTypedOptions, type ListExecutorsOptions, type ListMachineUsersOptions, type ListOAuth2ClientsOptions, type ListUsersOptions, type ListWebhookExecutorsOptions, type ListWorkflowExecutionsOptions, type ListWorkflowExecutionsTypedOptions, type ListWorkflowsOptions, type ListWorkspacesOptions, type LoadedConfig, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, type MachineUserInfo, type MachineUserTokenInfo, type GenerateOptions$1 as MigrateGenerateOptions, type MigrationBundleResult, type MigrationDiff, type MigrationInfo, type NamespaceWithMigrations, type OAuth2ClientCredentials, type OAuth2ClientInfo, type OperatorClient, type PluginAttachment, 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 SeedChunk, type ShowOptions, type SnapshotFieldConfig, type SnapshotType, type StartWorkflowOptions, type StartWorkflowResultWithWait, type StartWorkflowTypedOptions, type TailorDBGenerator, type TailorDBInput, type TailorDBResolverGenerator, type TailorDBType, type TriggerExecutorOptions, type TriggerExecutorResult, type TriggerExecutorTypedOptions, type TruncateOptions, type TypeSourceInfoEntry, type UpdateUserOptions, type UserInfo, type WaitOptions, type WatchExecutorJobOptions, type WatchExecutorJobResult, type WatchExecutorJobTypedOptions, type WebhookExecutorInfo, type WorkflowExecutionInfo, type WorkflowInfo, type WorkflowJobExecutionInfo, type WorkflowListInfo, type WorkspaceDetails, type WorkspaceInfo, apiCall, apply, bundleMigrationScript, bundleSeedScript, chunkSeedData, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, createWorkspace, deleteWorkspace, enumConstantsPlugin, executeScript, fileUtilsPlugin, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutor, getExecutorJob, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, kyselyTypePlugin, listApps, listExecutorJobs, listExecutors, listMachineUsers, listOAuth2Clients, listUsers, listWebhookExecutors, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, query, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, seedPlugin, show, startWorkflow, triggerExecutor, truncate, updateUser, waitForExecution, watchExecutorJob };
18720
+ export { type AggregateArgs, type ApiCallOptions, type ApiCallResult, type AppHealthInfo, type AppInfo, type ApplicationInfo, type ApplyOptions, type AuthInvoker, type BreakingChangeInfo, type BundledScripts, type ChunkSeedDataOptions, type CodeGenerator, type CreateFolderOptions, type CreateWorkspaceOptions, DB_TYPES_FILE_NAME, DIFF_FILE_NAME, type DeleteFolderOptions, 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 FolderInfo, type FolderListInfo, type FullCodeGenerator, type FullInput, type GenerateOptions, type GeneratorResult, type HealthOptions as GetAppHealthOptions, type GetExecutorJobOptions, type GetExecutorJobTypedOptions, type GetExecutorOptions, type GetExecutorTypedOptions, type GetFolderOptions, type GetMachineUserTokenOptions, type GetOAuth2ClientOptions, type GetOrganizationOptions, type GetWorkflowExecutionOptions, type GetWorkflowExecutionResult, type GetWorkflowOptions, type GetWorkflowTypedOptions, type GetWorkspaceOptions, INITIAL_SCHEMA_NUMBER, type InviteUserOptions, type ListAppsOptions, type ListExecutorJobsOptions, type ListExecutorJobsTypedOptions, type ListExecutorsOptions, type ListFoldersOptions, type ListMachineUsersOptions, type ListOAuth2ClientsOptions, type ListOrganizationsOptions, type ListUsersOptions, type ListWebhookExecutorsOptions, type ListWorkflowExecutionsOptions, type ListWorkflowExecutionsTypedOptions, type ListWorkflowsOptions, type ListWorkspacesOptions, type LoadedConfig, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, type MachineUserInfo, type MachineUserTokenInfo, type GenerateOptions$1 as MigrateGenerateOptions, type MigrationBundleResult, type MigrationDiff, type MigrationInfo, type NamespaceWithMigrations, type OAuth2ClientCredentials, type OAuth2ClientInfo, type OperatorClient, type OrganizationInfo, type OrganizationTreeOptions, type PluginAttachment, 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 SeedChunk, type ShowOptions, type SnapshotFieldConfig, type SnapshotType, type StartWorkflowOptions, type StartWorkflowResultWithWait, type StartWorkflowTypedOptions, type TailorDBGenerator, type TailorDBInput, type TailorDBResolverGenerator, type TailorDBType, type TriggerExecutorOptions, type TriggerExecutorResult, type TriggerExecutorTypedOptions, type TruncateOptions, type TypeSourceInfoEntry, type UpdateFolderOptions, type UpdateOrganizationOptions, type UpdateUserOptions, type UserInfo, type UserOrganizationInfo, type WaitOptions, type WatchExecutorJobOptions, type WatchExecutorJobResult, type WatchExecutorJobTypedOptions, type WebhookExecutorInfo, type WorkflowExecutionInfo, type WorkflowInfo, type WorkflowJobExecutionInfo, type WorkflowListInfo, type WorkspaceDetails, type WorkspaceInfo, apiCall, apply, bundleMigrationScript, bundleSeedScript, chunkSeedData, compareLocalTypesWithSnapshot, compareSnapshots, createFolder, createSnapshotFromLocalTypes, createWorkspace, deleteFolder, deleteWorkspace, enumConstantsPlugin, executeScript, fileUtilsPlugin, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutor, getExecutorJob, getFolder, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getOrganization, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, kyselyTypePlugin, listApps, listExecutorJobs, listExecutors, listFolders, listMachineUsers, listOAuth2Clients, listOrganizations, listUsers, listWebhookExecutors, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, organizationTree, query, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, seedPlugin, show, startWorkflow, triggerExecutor, truncate, updateFolder, updateOrganization, updateUser, waitForExecution, watchExecutorJob };
18556
18721
  //# sourceMappingURL=lib.d.mts.map
package/dist/cli/lib.mjs CHANGED
@@ -1,16 +1,16 @@
1
- import "../chunk-Cz-A8uMR.mjs";
1
+ import "../chunk-DEt8GZDa.mjs";
2
2
  import "../schema-BePzTFBV.mjs";
3
3
  import "../brand-GZnI4eYb.mjs";
4
4
  import "../logger-CqezTedh.mjs";
5
- import { $ as listExecutors, A as truncate, At as getLatestMigrationNumber, B as listOAuth2Clients, Bt as hasChanges, Ct as INITIAL_SCHEMA_NUMBER, D as resumeWorkflow, Dt as compareSnapshots, Et as compareLocalTypesWithSnapshot, Gt as generateUserTypes, H as getOAuth2Client, J as listWebhookExecutors, K as listMachineUsers, Kt as apiCall, L as remove, Lt as reconstructSnapshotFromMigrations, M as generate$1, Mt as getMigrationFilePath, Nt as getMigrationFiles, Ot as createSnapshotFromLocalTypes, P as show, Pt as getNextMigrationNumber, Rt as formatDiffSummary, S as listApps, St as DIFF_FILE_NAME, Tt as SCHEMA_FILE_NAME, U as getMachineUserToken, Vt as getNamespacesWithMigrations, Z as triggerExecutor, _ as getWorkspace, _t as waitForExecution, a as updateUser, at as startWorkflow, bt as bundleMigrationScript, d as inviteUser, et as getExecutorJob, gt as executeScript, h as listWorkspaces, ht as apply, jt as getMigrationDirPath, k as listWorkflows, l as listUsers, lt as getWorkflowExecution, mt as getExecutor, nt as listExecutorJobs, p as restoreWorkspace, q as generate, rt as watchExecutorJob, s as removeUser, st as getWorkflow, t as query, ut as listWorkflowExecutions, vt as MIGRATION_LABEL_KEY, w as getAppHealth, wt as MIGRATE_FILE_NAME, x as createWorkspace, xt as DB_TYPES_FILE_NAME, y as deleteWorkspace, zt as formatMigrationDiff } from "../query-WYq8RvYp.mjs";
6
- import { s as initOperatorClient } from "../client-bTbnbQbB.mjs";
5
+ import { A as truncate, B as updateOrganization, Bt as DIFF_FILE_NAME, Ct as startWorkflow, D as resumeWorkflow, Dt as getWorkflowExecution, Ft as waitForExecution, Gt as compareSnapshots, Ht as MIGRATE_FILE_NAME, It as MIGRATION_LABEL_KEY, J as updateFolder, Jt as getLatestMigrationNumber, K as getOrganization, Kt as createSnapshotFromLocalTypes, L as remove, M as generate$1, Mt as getExecutor, Nt as apply, Ot as listWorkflowExecutions, P as show, Pt as executeScript, Q as getFolder, Qt as getNextMigrationNumber, Rt as bundleMigrationScript, S as listApps, Tt as getWorkflow, Ut as SCHEMA_FILE_NAME, V as organizationTree, Vt as INITIAL_SCHEMA_NUMBER, W as listOrganizations, Wt as compareLocalTypesWithSnapshot, X as listFolders, Xt as getMigrationFilePath, Yt as getMigrationDirPath, Zt as getMigrationFiles, _ as getWorkspace, _t as listExecutors, a as updateUser, an as getNamespacesWithMigrations, bt as listExecutorJobs, d as inviteUser, dt as generate, et as deleteFolder, ft as listWebhookExecutors, h as listWorkspaces, ht as triggerExecutor, in as hasChanges, it as listOAuth2Clients, k as listWorkflows, l as listUsers, ln as generateUserTypes, nn as formatDiffSummary, nt as createFolder, ot as getOAuth2Client, p as restoreWorkspace, rn as formatMigrationDiff, s as removeUser, st as getMachineUserToken, t as query, tn as reconstructSnapshotFromMigrations, un as apiCall, ut as listMachineUsers, vt as getExecutorJob, w as getAppHealth, x as createWorkspace, xt as watchExecutorJob, y as deleteWorkspace, zt as DB_TYPES_FILE_NAME } from "../query-C3oQTLvb.mjs";
6
+ import { l as initOperatorClient } from "../client-CZmQBXAY.mjs";
7
7
  import "../package-json-D3x2nBPB.mjs";
8
- import { a as loadConfig, b as loadWorkspaceId, g as getDistDir, y as loadAccessToken } from "../application-CBJFUKrU.mjs";
8
+ import { a as loadConfig, b as loadWorkspaceId, g as getDistDir, y as loadAccessToken } from "../application-Bf8SUAtR.mjs";
9
9
  import { n as seedPlugin } from "../seed-CWkIDWMb.mjs";
10
10
  import { n as enumConstantsPlugin } from "../enum-constants-D1nfn0qD.mjs";
11
11
  import { n as fileUtilsPlugin } from "../file-utils-Bctuzn3x.mjs";
12
12
  import { n as kyselyTypePlugin } from "../kysely-type-B_IecdK9.mjs";
13
- import "../telemetry-VvNfsyEE.mjs";
13
+ import "../telemetry-BSUlYTs-.mjs";
14
14
  import { register } from "node:module";
15
15
  import * as fs from "node:fs";
16
16
  import * as path from "pathe";
@@ -243,7 +243,6 @@ async function bundleSeedScript(namespace, typeNames) {
243
243
  const outputDir = path.resolve(getDistDir(), "seed");
244
244
  fs.mkdirSync(outputDir, { recursive: true });
245
245
  const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);
246
- const outputPath = path.join(outputDir, `seed_${namespace}.js`);
247
246
  const entryContent = generateSeedScriptContent(namespace);
248
247
  fs.writeFileSync(entryPath, entryContent);
249
248
  let tsconfig;
@@ -252,29 +251,28 @@ async function bundleSeedScript(namespace, typeNames) {
252
251
  } catch {
253
252
  tsconfig = void 0;
254
253
  }
255
- await rolldown.build(rolldown.defineConfig({
256
- input: entryPath,
257
- output: {
258
- file: outputPath,
259
- format: "esm",
260
- sourcemap: false,
261
- minify: false,
262
- codeSplitting: false,
263
- globals: { tailordb: "tailordb" }
264
- },
265
- external: ["tailordb"],
266
- resolve: { conditionNames: ["node", "import"] },
267
- tsconfig,
268
- treeshake: {
269
- moduleSideEffects: false,
270
- annotations: true,
271
- unknownGlobalSideEffects: false
272
- },
273
- logLevel: "silent"
274
- }));
275
254
  return {
276
255
  namespace,
277
- bundledCode: fs.readFileSync(outputPath, "utf-8"),
256
+ bundledCode: (await rolldown.build({
257
+ input: entryPath,
258
+ write: false,
259
+ output: {
260
+ format: "esm",
261
+ sourcemap: false,
262
+ minify: false,
263
+ codeSplitting: false,
264
+ globals: { tailordb: "tailordb" }
265
+ },
266
+ external: ["tailordb"],
267
+ resolve: { conditionNames: ["node", "import"] },
268
+ tsconfig,
269
+ treeshake: {
270
+ moduleSideEffects: false,
271
+ annotations: true,
272
+ unknownGlobalSideEffects: false
273
+ },
274
+ logLevel: "silent"
275
+ })).output[0].code,
278
276
  typesIncluded: typeNames
279
277
  };
280
278
  }
@@ -284,5 +282,5 @@ async function bundleSeedScript(namespace, typeNames) {
284
282
  register("tsx", import.meta.url, { data: {} });
285
283
 
286
284
  //#endregion
287
- export { DB_TYPES_FILE_NAME, DIFF_FILE_NAME, INITIAL_SCHEMA_NUMBER, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, SCHEMA_FILE_NAME, apiCall, apply, bundleMigrationScript, bundleSeedScript, chunkSeedData, compareLocalTypesWithSnapshot, compareSnapshots, createSnapshotFromLocalTypes, createWorkspace, deleteWorkspace, enumConstantsPlugin, executeScript, fileUtilsPlugin, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutor, getExecutorJob, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, kyselyTypePlugin, listApps, listExecutorJobs, listExecutors, listMachineUsers, listOAuth2Clients, listUsers, listWebhookExecutors, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, query, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, seedPlugin, show, startWorkflow, triggerExecutor, truncate, updateUser, waitForExecution, watchExecutorJob };
285
+ export { DB_TYPES_FILE_NAME, DIFF_FILE_NAME, INITIAL_SCHEMA_NUMBER, MIGRATE_FILE_NAME, MIGRATION_LABEL_KEY, SCHEMA_FILE_NAME, apiCall, apply, bundleMigrationScript, bundleSeedScript, chunkSeedData, compareLocalTypesWithSnapshot, compareSnapshots, createFolder, createSnapshotFromLocalTypes, createWorkspace, deleteFolder, deleteWorkspace, enumConstantsPlugin, executeScript, fileUtilsPlugin, formatDiffSummary, formatMigrationDiff, generate, generateUserTypes, getAppHealth, getExecutor, getExecutorJob, getFolder, getLatestMigrationNumber, getMachineUserToken, getMigrationDirPath, getMigrationFilePath, getMigrationFiles, getNamespacesWithMigrations, getNextMigrationNumber, getOAuth2Client, getOrganization, getWorkflow, getWorkflowExecution, getWorkspace, hasChanges, initOperatorClient, inviteUser, kyselyTypePlugin, listApps, listExecutorJobs, listExecutors, listFolders, listMachineUsers, listOAuth2Clients, listOrganizations, listUsers, listWebhookExecutors, listWorkflowExecutions, listWorkflows, listWorkspaces, loadAccessToken, loadConfig, loadWorkspaceId, generate$1 as migrateGenerate, organizationTree, query, reconstructSnapshotFromMigrations, remove, removeUser, restoreWorkspace, resumeWorkflow, seedPlugin, show, startWorkflow, triggerExecutor, truncate, updateFolder, updateOrganization, updateUser, waitForExecution, watchExecutorJob };
288
286
  //# sourceMappingURL=lib.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lib.mjs","names":[],"sources":["../../src/cli/shared/seed-chunker.ts","../../src/cli/commands/generate/seed/bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\n * Seed data chunker for splitting large seed data into manageable message sizes.\n *\n * When seed data exceeds the gRPC message size limit, this module splits the data\n * into multiple chunks at type boundaries (or record boundaries for large types).\n */\n\n/**\n * Seed data keyed by type name, with an array of records per type.\n */\nexport type SeedData = Record<string, Record<string, unknown>[]>;\n\n/**\n * A single chunk of seed data with metadata for ordered execution.\n */\nexport type SeedChunk = {\n data: SeedData;\n order: string[];\n index: number;\n total: number;\n};\n\n/**\n * Options for chunking seed data.\n */\nexport type ChunkSeedDataOptions = {\n /** Seed data keyed by type name */\n data: SeedData;\n /** Ordered list of type names (dependency order) */\n order: string[];\n /** Byte size of the bundled seed script code */\n codeByteSize: number;\n /** Maximum gRPC message size in bytes (default: 3.5MB) */\n maxMessageSize?: number;\n};\n\n/** Default maximum message size: 3.5MB (conservative limit for gRPC) */\nexport const DEFAULT_MAX_MESSAGE_SIZE = 3.5 * 1024 * 1024;\n\n/** Reserved bytes for message metadata overhead */\nconst METADATA_OVERHEAD = 1024;\n\n/**\n * Split seed data into chunks that fit within the gRPC message size limit.\n *\n * Algorithm:\n * 1. Calculate the available budget for the arg field (maxMessageSize - codeByteSize - overhead)\n * 2. If all data fits in one message, return a single chunk\n * 3. Otherwise, iterate through types in dependency order:\n * - If a type fits in the current chunk, add it\n * - If adding a type would exceed the budget, finalize the current chunk and start a new one\n * - If a single type exceeds the budget, split its records across multiple chunks\n * - If a single record exceeds the budget, throw an error\n * @param options - Chunking options\n * @returns Array of seed chunks\n */\nexport function chunkSeedData(options: ChunkSeedDataOptions): SeedChunk[] {\n const { data, order, codeByteSize, maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE } = options;\n\n const argBudget = maxMessageSize - codeByteSize - METADATA_OVERHEAD;\n if (argBudget <= 0) {\n throw new Error(\n `Code size (${codeByteSize} bytes) exceeds the message size limit (${maxMessageSize} bytes). ` +\n `No space left for seed data.`,\n );\n }\n\n // Filter to types that have data\n const typesWithData = order.filter((type) => data[type] && data[type].length > 0);\n\n if (typesWithData.length === 0) {\n return [];\n }\n\n // Check if all data fits in a single message\n const fullArg = JSON.stringify({ data, order });\n if (byteSize(fullArg) <= argBudget) {\n return [{ data, order, index: 0, total: 1 }];\n }\n\n // Split into multiple chunks\n const chunks: Omit<SeedChunk, \"total\">[] = [];\n let currentData: SeedData = {};\n let currentOrder: string[] = [];\n\n for (const type of typesWithData) {\n const typeRecords = data[type];\n\n // Check if the type fits in the current chunk\n if (currentOrder.length > 0) {\n const testData = { ...currentData, [type]: typeRecords };\n const testOrder = [...currentOrder, type];\n if (byteSize(JSON.stringify({ data: testData, order: testOrder })) > argBudget) {\n // Finalize the current chunk\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n }\n\n // Check if the entire type fits in an empty chunk\n if (byteSize(JSON.stringify({ data: { [type]: typeRecords }, order: [type] })) <= argBudget) {\n currentData[type] = typeRecords;\n currentOrder.push(type);\n continue;\n }\n\n // Type is too large — split by records\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n\n let recordBatch: Record<string, unknown>[] = [];\n for (const record of typeRecords) {\n if (byteSize(JSON.stringify({ data: { [type]: [record] }, order: [type] })) > argBudget) {\n const singleRecordSize = byteSize(JSON.stringify(record));\n throw new Error(\n `A single record in type \"${type}\" (${singleRecordSize} bytes) exceeds the message size budget ` +\n `(${argBudget} bytes). Consider increasing maxMessageSize or reducing the record size.`,\n );\n }\n\n const testBatch = [...recordBatch, record];\n const testData = { ...currentData, [type]: testBatch };\n const testOrder = currentOrder.includes(type) ? currentOrder : [...currentOrder, type];\n const testSize = byteSize(JSON.stringify({ data: testData, order: testOrder }));\n\n if (testSize > argBudget && recordBatch.length > 0) {\n // Finalize current chunk with accumulated records\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n recordBatch = [record];\n } else {\n recordBatch = testBatch;\n }\n }\n\n // Add remaining records\n if (recordBatch.length > 0) {\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n }\n }\n\n // Finalize the last chunk\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n }\n\n const total = chunks.length;\n return chunks.map((chunk) => ({ ...chunk, total }));\n}\n\nfunction byteSize(str: string): number {\n return new TextEncoder().encode(str).length;\n}\n","/**\n * Seed script bundler for TailorDB seed data\n *\n * Bundles seed scripts to be executed via TestExecScript API\n */\n\nimport * as fs from \"node:fs\";\nimport ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst BATCH_SIZE = 100;\n\n/**\n * Generate seed script content for server-side execution\n * @param namespace - TailorDB namespace\n * @returns Generated seed script content\n */\nfunction generateSeedScriptContent(namespace: string): string {\n return ml /* ts */ `\n import { Kysely, TailordbDialect } from \"@tailor-platform/sdk/kysely\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: string[];\n selfRefTypes: string[];\n };\n\n type SeedResult = {\n success: boolean;\n processed: Record<string, number>;\n errors: string[];\n };\n\n function getDB(namespace: string) {\n const client = new tailordb.Client({ namespace });\n return new Kysely<Record<string, Record<string, unknown>>>({\n dialect: new TailordbDialect(client),\n });\n }\n\n export async function main(input: SeedInput): Promise<SeedResult> {\n const db = getDB(\"${namespace}\");\n const processed: Record<string, number> = {};\n const errors: string[] = [];\n const BATCH_SIZE = ${String(BATCH_SIZE)};\n\n for (const typeName of input.order) {\n const records = input.data[typeName];\n if (!records || records.length === 0) {\n console.log(\\`[${namespace}] \\${typeName}: skipped (no data)\\`);\n continue;\n }\n\n processed[typeName] = 0;\n const hasSelfRef = (input.selfRefTypes || []).includes(typeName);\n\n try {\n if (hasSelfRef) {\n // Insert one-by-one to respect self-referencing foreign key order\n for (const record of records) {\n await db.insertInto(typeName).values(record).execute();\n processed[typeName] += 1;\n }\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length} (one-by-one)\\`);\n } else {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await db.insertInto(typeName).values(batch).execute();\n processed[typeName] += batch.length;\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length}\\`);\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`\\${typeName}: \\${message}\\`);\n console.error(\\`[${namespace}] \\${typeName}: failed - \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n errors,\n };\n }\n `;\n}\n\n/**\n * Bundle a seed script for server-side execution\n *\n * Creates an entry that:\n * 1. Defines getDB() function inline\n * 2. Processes data in batches using Kysely\n * 3. Reports progress via console.log\n * 4. Exports as main() for TestExecScript\n * @param namespace - TailorDB namespace\n * @param typeNames - List of type names to include in the seed\n * @returns Bundled seed script result\n */\nexport async function bundleSeedScript(\n namespace: string,\n typeNames: string[],\n): Promise<SeedBundleResult> {\n // Output directory in .tailor-sdk (relative to project root)\n const outputDir = path.resolve(getDistDir(), \"seed\");\n fs.mkdirSync(outputDir, { recursive: true });\n\n // Entry file in output directory\n const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);\n 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 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\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 \"./commands/apply/apply\";\nexport type { ApplyOptions } from \"./commands/apply/apply\";\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 {\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 { loadAccessToken, loadWorkspaceId } from \"./shared/context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./commands/api\";\nexport { query } from \"./query\";\nexport { truncate, type TruncateOptions } from \"./commands/tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./commands/tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./commands/tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./commands/tailordb/migrate/diff-calculator\";\nexport {\n SCHEMA_FILE_NAME,\n DIFF_FILE_NAME,\n MIGRATE_FILE_NAME,\n DB_TYPES_FILE_NAME,\n INITIAL_SCHEMA_NUMBER,\n getMigrationDirPath,\n getMigrationFilePath,\n type SchemaSnapshot,\n type SnapshotType,\n type SnapshotFieldConfig,\n type MigrationInfo,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./commands/tailordb/migrate/types\";\n\n// Seed exports\nexport { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./shared/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./commands/generate/seed/bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./commands/tailordb/migrate/bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./shared/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./shared/client\";\nexport type { AuthInvoker } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;AAClD,KAAI,aAAa,EACf,OAAM,IAAI,MACR,cAAc,aAAa,0CAA0C,eAAe,uCAErF;CAIH,MAAM,gBAAgB,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,MAAM,SAAS,EAAE;AAEjF,KAAI,cAAc,WAAW,EAC3B,QAAO,EAAE;AAKX,KAAI,SADY,KAAK,UAAU;EAAE;EAAM;EAAO,CAAC,CAC1B,IAAI,UACvB,QAAO,CAAC;EAAE;EAAM;EAAO,OAAO;EAAG,OAAO;EAAG,CAAC;C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UAAU,KAAK;CAG/D,MAAM,eAAe,0BAA0B,UAAU;AACzD,IAAG,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,eAAe;GACf,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,aAJkB,GAAG,aAAa,YAAY,QAAQ;EAKtD,eAAe;EAChB;;;;;ACnKH,SAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"lib.mjs","names":[],"sources":["../../src/cli/shared/seed-chunker.ts","../../src/cli/commands/generate/seed/bundler.ts","../../src/cli/lib.ts"],"sourcesContent":["/**\n * Seed data chunker for splitting large seed data into manageable message sizes.\n *\n * When seed data exceeds the gRPC message size limit, this module splits the data\n * into multiple chunks at type boundaries (or record boundaries for large types).\n */\n\n/**\n * Seed data keyed by type name, with an array of records per type.\n */\nexport type SeedData = Record<string, Record<string, unknown>[]>;\n\n/**\n * A single chunk of seed data with metadata for ordered execution.\n */\nexport type SeedChunk = {\n data: SeedData;\n order: string[];\n index: number;\n total: number;\n};\n\n/**\n * Options for chunking seed data.\n */\nexport type ChunkSeedDataOptions = {\n /** Seed data keyed by type name */\n data: SeedData;\n /** Ordered list of type names (dependency order) */\n order: string[];\n /** Byte size of the bundled seed script code */\n codeByteSize: number;\n /** Maximum gRPC message size in bytes (default: 3.5MB) */\n maxMessageSize?: number;\n};\n\n/** Default maximum message size: 3.5MB (conservative limit for gRPC) */\nexport const DEFAULT_MAX_MESSAGE_SIZE = 3.5 * 1024 * 1024;\n\n/** Reserved bytes for message metadata overhead */\nconst METADATA_OVERHEAD = 1024;\n\n/**\n * Split seed data into chunks that fit within the gRPC message size limit.\n *\n * Algorithm:\n * 1. Calculate the available budget for the arg field (maxMessageSize - codeByteSize - overhead)\n * 2. If all data fits in one message, return a single chunk\n * 3. Otherwise, iterate through types in dependency order:\n * - If a type fits in the current chunk, add it\n * - If adding a type would exceed the budget, finalize the current chunk and start a new one\n * - If a single type exceeds the budget, split its records across multiple chunks\n * - If a single record exceeds the budget, throw an error\n * @param options - Chunking options\n * @returns Array of seed chunks\n */\nexport function chunkSeedData(options: ChunkSeedDataOptions): SeedChunk[] {\n const { data, order, codeByteSize, maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE } = options;\n\n const argBudget = maxMessageSize - codeByteSize - METADATA_OVERHEAD;\n if (argBudget <= 0) {\n throw new Error(\n `Code size (${codeByteSize} bytes) exceeds the message size limit (${maxMessageSize} bytes). ` +\n `No space left for seed data.`,\n );\n }\n\n // Filter to types that have data\n const typesWithData = order.filter((type) => data[type] && data[type].length > 0);\n\n if (typesWithData.length === 0) {\n return [];\n }\n\n // Check if all data fits in a single message\n const fullArg = JSON.stringify({ data, order });\n if (byteSize(fullArg) <= argBudget) {\n return [{ data, order, index: 0, total: 1 }];\n }\n\n // Split into multiple chunks\n const chunks: Omit<SeedChunk, \"total\">[] = [];\n let currentData: SeedData = {};\n let currentOrder: string[] = [];\n\n for (const type of typesWithData) {\n const typeRecords = data[type];\n\n // Check if the type fits in the current chunk\n if (currentOrder.length > 0) {\n const testData = { ...currentData, [type]: typeRecords };\n const testOrder = [...currentOrder, type];\n if (byteSize(JSON.stringify({ data: testData, order: testOrder })) > argBudget) {\n // Finalize the current chunk\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n }\n\n // Check if the entire type fits in an empty chunk\n if (byteSize(JSON.stringify({ data: { [type]: typeRecords }, order: [type] })) <= argBudget) {\n currentData[type] = typeRecords;\n currentOrder.push(type);\n continue;\n }\n\n // Type is too large — split by records\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n }\n\n let recordBatch: Record<string, unknown>[] = [];\n for (const record of typeRecords) {\n if (byteSize(JSON.stringify({ data: { [type]: [record] }, order: [type] })) > argBudget) {\n const singleRecordSize = byteSize(JSON.stringify(record));\n throw new Error(\n `A single record in type \"${type}\" (${singleRecordSize} bytes) exceeds the message size budget ` +\n `(${argBudget} bytes). Consider increasing maxMessageSize or reducing the record size.`,\n );\n }\n\n const testBatch = [...recordBatch, record];\n const testData = { ...currentData, [type]: testBatch };\n const testOrder = currentOrder.includes(type) ? currentOrder : [...currentOrder, type];\n const testSize = byteSize(JSON.stringify({ data: testData, order: testOrder }));\n\n if (testSize > argBudget && recordBatch.length > 0) {\n // Finalize current chunk with accumulated records\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n currentData = {};\n currentOrder = [];\n recordBatch = [record];\n } else {\n recordBatch = testBatch;\n }\n }\n\n // Add remaining records\n if (recordBatch.length > 0) {\n currentData[type] = recordBatch;\n if (!currentOrder.includes(type)) {\n currentOrder.push(type);\n }\n }\n }\n\n // Finalize the last chunk\n if (currentOrder.length > 0) {\n chunks.push({ data: currentData, order: currentOrder, index: chunks.length });\n }\n\n const total = chunks.length;\n return chunks.map((chunk) => ({ ...chunk, total }));\n}\n\nfunction byteSize(str: string): number {\n return new TextEncoder().encode(str).length;\n}\n","/**\n * Seed script bundler for TailorDB seed data\n *\n * Bundles seed scripts to be executed via TestExecScript API\n */\n\nimport * as fs from \"node:fs\";\nimport ml from \"multiline-ts\";\nimport * as path from \"pathe\";\nimport { resolveTSConfig } from \"pkg-types\";\nimport * as rolldown from \"rolldown\";\nimport { getDistDir } from \"@/cli/shared/dist-dir\";\n\nexport type SeedBundleResult = {\n namespace: string;\n bundledCode: string;\n typesIncluded: string[];\n};\n\nconst BATCH_SIZE = 100;\n\n/**\n * Generate seed script content for server-side execution\n * @param namespace - TailorDB namespace\n * @returns Generated seed script content\n */\nfunction generateSeedScriptContent(namespace: string): string {\n return ml /* ts */ `\n import { Kysely, TailordbDialect } from \"@tailor-platform/sdk/kysely\";\n\n type SeedInput = {\n data: Record<string, Record<string, unknown>[]>;\n order: string[];\n selfRefTypes: string[];\n };\n\n type SeedResult = {\n success: boolean;\n processed: Record<string, number>;\n errors: string[];\n };\n\n function getDB(namespace: string) {\n const client = new tailordb.Client({ namespace });\n return new Kysely<Record<string, Record<string, unknown>>>({\n dialect: new TailordbDialect(client),\n });\n }\n\n export async function main(input: SeedInput): Promise<SeedResult> {\n const db = getDB(\"${namespace}\");\n const processed: Record<string, number> = {};\n const errors: string[] = [];\n const BATCH_SIZE = ${String(BATCH_SIZE)};\n\n for (const typeName of input.order) {\n const records = input.data[typeName];\n if (!records || records.length === 0) {\n console.log(\\`[${namespace}] \\${typeName}: skipped (no data)\\`);\n continue;\n }\n\n processed[typeName] = 0;\n const hasSelfRef = (input.selfRefTypes || []).includes(typeName);\n\n try {\n if (hasSelfRef) {\n // Insert one-by-one to respect self-referencing foreign key order\n for (const record of records) {\n await db.insertInto(typeName).values(record).execute();\n processed[typeName] += 1;\n }\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length} (one-by-one)\\`);\n } else {\n for (let i = 0; i < records.length; i += BATCH_SIZE) {\n const batch = records.slice(i, i + BATCH_SIZE);\n await db.insertInto(typeName).values(batch).execute();\n processed[typeName] += batch.length;\n console.log(\\`[${namespace}] \\${typeName}: \\${processed[typeName]}/\\${records.length}\\`);\n }\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`\\${typeName}: \\${message}\\`);\n console.error(\\`[${namespace}] \\${typeName}: failed - \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n errors,\n };\n }\n `;\n}\n\n/**\n * Bundle a seed script for server-side execution\n *\n * Creates an entry that:\n * 1. Defines getDB() function inline\n * 2. Processes data in batches using Kysely\n * 3. Reports progress via console.log\n * 4. Exports as main() for TestExecScript\n * @param namespace - TailorDB namespace\n * @param typeNames - List of type names to include in the seed\n * @returns Bundled seed script result\n */\nexport async function bundleSeedScript(\n namespace: string,\n typeNames: string[],\n): Promise<SeedBundleResult> {\n // Output directory in .tailor-sdk (relative to project root)\n const outputDir = path.resolve(getDistDir(), \"seed\");\n fs.mkdirSync(outputDir, { recursive: true });\n\n // Entry file in output directory\n const entryPath = path.join(outputDir, `seed_${namespace}.entry.ts`);\n\n // Generate seed script content\n const entryContent = generateSeedScriptContent(namespace);\n fs.writeFileSync(entryPath, entryContent);\n\n let tsconfig: string | undefined;\n try {\n tsconfig = await resolveTSConfig();\n } catch {\n tsconfig = undefined;\n }\n\n // Bundle with tree-shaking (write: false to avoid unnecessary disk I/O)\n const result = await rolldown.build({\n input: entryPath,\n write: false,\n output: {\n format: \"esm\",\n sourcemap: false,\n minify: false,\n codeSplitting: false,\n globals: {\n tailordb: \"tailordb\",\n },\n },\n external: [\"tailordb\"],\n resolve: {\n conditionNames: [\"node\", \"import\"],\n },\n tsconfig,\n treeshake: {\n moduleSideEffects: false,\n annotations: true,\n unknownGlobalSideEffects: false,\n },\n logLevel: \"silent\",\n } as rolldown.BuildOptions);\n\n const bundledCode = result.output[0].code;\n\n return {\n namespace,\n bundledCode,\n typesIncluded: typeNames,\n };\n}\n","// CLI API exports for programmatic usage\nimport { 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 \"./commands/apply/apply\";\nexport type { ApplyOptions } from \"./commands/apply/apply\";\nexport type { BundledScripts } from \"./commands/apply/function-registry\";\nexport { generate } from \"./commands/generate/service\";\nexport type { GenerateOptions } from \"./commands/generate/options\";\nexport { loadConfig, type LoadedConfig } from \"./shared/config-loader\";\nexport { generateUserTypes } from \"./shared/type-generator\";\nexport type {\n CodeGenerator,\n TailorDBGenerator,\n ResolverGenerator,\n ExecutorGenerator,\n TailorDBResolverGenerator,\n FullCodeGenerator,\n TailorDBInput,\n ResolverInput,\n ExecutorInput,\n FullInput,\n AggregateArgs,\n GeneratorResult,\n DependencyKind,\n PluginAttachment,\n TypeSourceInfoEntry,\n} from \"./commands/generate/types\";\nexport type { TailorDBType } from \"@/types/tailordb\";\nexport type { Resolver } from \"@/types/resolver.generated\";\nexport type { Executor } from \"@/types/executor.generated\";\n\n/** @deprecated Import from '@tailor-platform/sdk/plugin/kysely-type' instead */\nexport { kyselyTypePlugin } from \"@/plugin/builtin/kysely-type\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/enum-constants' instead */\nexport { enumConstantsPlugin } from \"@/plugin/builtin/enum-constants\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/file-utils' instead */\nexport { fileUtilsPlugin } from \"@/plugin/builtin/file-utils\";\n/** @deprecated Import from '@tailor-platform/sdk/plugin/seed' instead */\nexport { seedPlugin } from \"@/plugin/builtin/seed\";\n\nexport { show, type ShowOptions, type ApplicationInfo } from \"./commands/show\";\nexport { remove, type RemoveOptions } from \"./commands/remove\";\nexport { createWorkspace, type CreateWorkspaceOptions } from \"./commands/workspace/create\";\nexport { listWorkspaces, type ListWorkspacesOptions } from \"./commands/workspace/list\";\nexport { deleteWorkspace, type DeleteWorkspaceOptions } from \"./commands/workspace/delete\";\nexport { getWorkspace, type GetWorkspaceOptions } from \"./commands/workspace/get\";\nexport { restoreWorkspace, type RestoreWorkspaceOptions } from \"./commands/workspace/restore\";\nexport type { WorkspaceInfo, WorkspaceDetails } from \"./commands/workspace/transform\";\nexport { listUsers, type ListUsersOptions } from \"./commands/workspace/user/list\";\nexport { inviteUser, type InviteUserOptions } from \"./commands/workspace/user/invite\";\nexport { updateUser, type UpdateUserOptions } from \"./commands/workspace/user/update\";\nexport { removeUser, type RemoveUserOptions } from \"./commands/workspace/user/remove\";\nexport type { UserInfo } from \"./commands/workspace/user/transform\";\nexport { listApps, type ListAppsOptions } from \"./commands/workspace/app/list\";\nexport {\n getAppHealth,\n type HealthOptions as GetAppHealthOptions,\n} from \"./commands/workspace/app/health\";\nexport type { AppInfo, AppHealthInfo } from \"./commands/workspace/app/transform\";\nexport {\n listMachineUsers,\n type ListMachineUsersOptions,\n type MachineUserInfo,\n} from \"./commands/machineuser/list\";\nexport {\n getMachineUserToken,\n type GetMachineUserTokenOptions,\n type MachineUserTokenInfo,\n} from \"./commands/machineuser/token\";\nexport { getOAuth2Client, type GetOAuth2ClientOptions } from \"./commands/oauth2client/get\";\nexport { listOAuth2Clients, type ListOAuth2ClientsOptions } from \"./commands/oauth2client/list\";\nexport type { OAuth2ClientInfo, OAuth2ClientCredentials } from \"./commands/oauth2client/transform\";\nexport { listWorkflows, type ListWorkflowsOptions } from \"./commands/workflow/list\";\nexport {\n getWorkflow,\n type GetWorkflowOptions,\n type GetWorkflowTypedOptions,\n} from \"./commands/workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowTypedOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./commands/workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type ListWorkflowExecutionsTypedOptions,\n type GetWorkflowExecutionOptions,\n type GetWorkflowExecutionResult,\n} from \"./commands/workflow/executions\";\nexport {\n resumeWorkflow,\n type ResumeWorkflowOptions,\n type ResumeWorkflowResultWithWait,\n} from \"./commands/workflow/resume\";\nexport type {\n WorkflowListInfo,\n WorkflowInfo,\n WorkflowExecutionInfo,\n WorkflowJobExecutionInfo,\n} from \"./commands/workflow/transform\";\nexport {\n triggerExecutor,\n type TriggerExecutorOptions,\n type TriggerExecutorTypedOptions,\n type TriggerExecutorResult,\n} from \"./commands/executor/trigger\";\nexport {\n listExecutorJobs,\n getExecutorJob,\n watchExecutorJob,\n type ListExecutorJobsOptions,\n type ListExecutorJobsTypedOptions,\n type GetExecutorJobOptions,\n type GetExecutorJobTypedOptions,\n type WatchExecutorJobOptions,\n type WatchExecutorJobTypedOptions,\n type ExecutorJobDetailInfo,\n type WatchExecutorJobResult,\n} from \"./commands/executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./commands/executor/list\";\nexport {\n getExecutor,\n type GetExecutorOptions,\n type GetExecutorTypedOptions,\n} from \"./commands/executor/get\";\nexport {\n listWebhookExecutors,\n type ListWebhookExecutorsOptions,\n type WebhookExecutorInfo,\n} from \"./commands/executor/webhook\";\nexport type {\n ExecutorJobListInfo,\n ExecutorJobInfo,\n ExecutorJobAttemptInfo,\n ExecutorListInfo,\n ExecutorInfo,\n} from \"./commands/executor/transform\";\nexport { listOrganizations, type ListOrganizationsOptions } from \"./commands/organization/list\";\nexport { getOrganization, type GetOrganizationOptions } from \"./commands/organization/get\";\nexport { updateOrganization, type UpdateOrganizationOptions } from \"./commands/organization/update\";\nexport { organizationTree, type OrganizationTreeOptions } from \"./commands/organization/tree\";\nexport type {\n UserOrganizationInfo,\n OrganizationInfo,\n FolderListInfo,\n FolderInfo,\n} from \"./commands/organization/transform\";\nexport { listFolders, type ListFoldersOptions } from \"./commands/organization/folder/list\";\nexport { getFolder, type GetFolderOptions } from \"./commands/organization/folder/get\";\nexport { createFolder, type CreateFolderOptions } from \"./commands/organization/folder/create\";\nexport { updateFolder, type UpdateFolderOptions } from \"./commands/organization/folder/update\";\nexport { deleteFolder, type DeleteFolderOptions } from \"./commands/organization/folder/delete\";\nexport { loadAccessToken, loadWorkspaceId } from \"./shared/context\";\nexport { apiCall, type ApiCallOptions, type ApiCallResult } from \"./commands/api\";\nexport { query } from \"./query\";\nexport { truncate, type TruncateOptions } from \"./commands/tailordb/truncate\";\n\n// Migration exports\nexport {\n generate as migrateGenerate,\n type GenerateOptions as MigrateGenerateOptions,\n} from \"./commands/tailordb/migrate/generate\";\nexport {\n createSnapshotFromLocalTypes,\n reconstructSnapshotFromMigrations,\n compareSnapshots,\n getNextMigrationNumber,\n getLatestMigrationNumber,\n getMigrationFiles,\n compareLocalTypesWithSnapshot,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport {\n getNamespacesWithMigrations,\n type NamespaceWithMigrations,\n} from \"./commands/tailordb/migrate/config\";\nexport {\n hasChanges,\n formatMigrationDiff,\n formatDiffSummary,\n type MigrationDiff,\n type BreakingChangeInfo,\n} from \"./commands/tailordb/migrate/diff-calculator\";\nexport {\n SCHEMA_FILE_NAME,\n DIFF_FILE_NAME,\n MIGRATE_FILE_NAME,\n DB_TYPES_FILE_NAME,\n INITIAL_SCHEMA_NUMBER,\n getMigrationDirPath,\n getMigrationFilePath,\n type SchemaSnapshot,\n type SnapshotType,\n type SnapshotFieldConfig,\n type MigrationInfo,\n} from \"./commands/tailordb/migrate/snapshot\";\nexport { MIGRATION_LABEL_KEY } from \"./commands/tailordb/migrate/types\";\n\n// Seed exports\nexport { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./shared/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./commands/generate/seed/bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./commands/tailordb/migrate/bundler\";\nexport {\n executeScript,\n waitForExecution,\n type ScriptExecutionOptions,\n type ScriptExecutionResult,\n type ExecutionWaitResult,\n} from \"./shared/script-executor\";\nexport { initOperatorClient, type OperatorClient } from \"./shared/client\";\nexport type { AuthInvoker } from \"@tailor-proto/tailor/v1/auth_resource_pb\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,2BAA2B,MAAM,OAAO;;AAGrD,MAAM,oBAAoB;;;;;;;;;;;;;;;AAgB1B,SAAgB,cAAc,SAA4C;CACxE,MAAM,EAAE,MAAM,OAAO,cAAc,iBAAiB,6BAA6B;CAEjF,MAAM,YAAY,iBAAiB,eAAe;AAClD,KAAI,aAAa,EACf,OAAM,IA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;+BAMR,UAAU;;;;;;6BAMZ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;AAyBvC,eAAsB,iBACpB,WACA,WAC2B;CAE3B,MAAM,YAAY,KAAK,QAAQ,YAAY,EAAE,OAAO;AACpD,IAAG,UAAU,WAAW,EAAE,WAAW,MAAM,CAAC;CAG5C,MAAM,YAAY,KAAK,KAAK,WAAW,QAAQ,UAAU,WAAW;CAGpE,MAAM,eAAe,0BAA0B,UAAU;AACzD,IAAG,cAAc,WAAW,aAAa;CAEzC,IAAI;AACJ,KAAI;AACF,aAAW,MAAM,iBAAiB;SAC5B;AACN,aAAW;;AA+Bb,QAAO;EACL;EACA,cA7Ba,MAAM,SAAS,MAAM;GAClC,OAAO;GACP,OAAO;GACP,QAAQ;IACN,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,eAAe;IACf,SAAS,EACP,UAAU,YACX;IACF;GACD,UAAU,CAAC,WAAW;GACtB,SAAS,EACP,gBAAgB,CAAC,QAAQ,SAAS,EACnC;GACD;GACA,WAAW;IACT,mBAAmB;IACnB,aAAa;IACb,0BAA0B;IAC3B;GACD,UAAU;GACX,CAA0B,EAEA,OAAO,GAAG;EAKnC,eAAe;EAChB;;;;;AC/JH,SAAS,OAAO,OAAO,KAAK,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "../chunk-Cz-A8uMR.mjs";
2
+ import "../chunk-DEt8GZDa.mjs";
3
3
  import { spawn } from "node:child_process";
4
4
 
5
5
  //#region src/cli/shared/skills-installer.ts
@@ -0,0 +1,6 @@
1
+ import "./chunk-DEt8GZDa.mjs";
2
+ import "./logger-CqezTedh.mjs";
3
+ import { a as fetchPlatformMachineUserToken, c as initOAuth2Client, d as platformBaseUrl, f as resolveStaticWebsiteUrls, i as fetchMachineUserToken, l as initOperatorClient, n as closeConnectionPool, o as fetchUserInfo, p as userAgent, r as fetchAll, s as formatRequestParams, t as MAX_PAGE_SIZE, u as parseMethodName } from "./client-CZmQBXAY.mjs";
4
+ import "./package-json-D3x2nBPB.mjs";
5
+
6
+ export { userAgent };