@tailor-platform/sdk 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/application-D5ZEr4zk.mjs +4 -0
- package/dist/{application-DQ2F9UmJ.mjs → application-DYfVZVPT.mjs} +4806 -67
- package/dist/application-DYfVZVPT.mjs.map +1 -0
- package/dist/cli/index.mjs +3 -3
- package/dist/cli/lib.d.mts +147 -29
- package/dist/cli/lib.mjs +3 -3
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/configure/index.d.mts +3 -3
- package/dist/configure/index.mjs +46 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-1V_2bvT4.d.mts → index-qQXpN674.d.mts} +136 -11
- package/dist/job-CULA2Pvf.mjs +51 -0
- package/dist/job-CULA2Pvf.mjs.map +1 -0
- package/dist/plugin/index.d.mts +1 -1
- package/dist/{schema-DRYB-nzA.mjs → schema-R5TxC5Pn.mjs} +143 -1
- package/dist/schema-R5TxC5Pn.mjs.map +1 -0
- package/dist/{index-Ds8lbSJb.d.mts → types-BeNtD-fA.d.mts} +88 -115
- package/dist/{types-_sYDzqHG.d.mts → types-DzvazVmg.d.mts} +169 -11
- package/dist/update-DQKCUNmr.mjs +10701 -0
- package/dist/update-DQKCUNmr.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +3 -3
- package/dist/utils/test/index.mjs +1 -1
- package/package.json +1 -1
- package/postinstall.mjs +2 -2
- package/dist/application-CNpRSiWJ.mjs +0 -4
- package/dist/application-DQ2F9UmJ.mjs.map +0 -1
- package/dist/job-XiwGyFJt.mjs +0 -21
- package/dist/job-XiwGyFJt.mjs.map +0 -1
- package/dist/schema-DRYB-nzA.mjs.map +0 -1
- package/dist/update-C5jgLxpK.mjs +0 -15436
- package/dist/update-C5jgLxpK.mjs.map +0 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "../chunk-GMkBE123.mjs";
|
|
3
|
-
import "../schema-
|
|
4
|
-
import { $ as jobsCommand,
|
|
5
|
-
import { f as logger,
|
|
3
|
+
import "../schema-R5TxC5Pn.mjs";
|
|
4
|
+
import { $ as jobsCommand, A as generateCommand, Bt as getNamespacesWithMigrations, C as resumeCommand, F as removeCommand$1, Ft as loadDiff, G as generateCommand$1, Gt as commonArgs, H as listCommand$6, I as listCommand$7, J as triggerCommand, Jt as jsonArgs, Kt as confirmationArgs, Mt as getMigrationFiles, N as showCommand, O as truncateCommand, Ot as formatMigrationNumber, Pt as isValidMigrationNumber, R as getCommand$2, S as healthCommand, T as listCommand$8, V as tokenCommand, Vt as trnPrefix, Wt as apiCommand, X as listCommand$5, Xt as workspaceArgs, Yt as withCommonArgs, _ as createCommand$3, a as listCommand$10, b as listCommand$9, d as listCommand$11, dt as getCommand$1, h as deleteCommand$3, it as getCommand$3, j as logBetaWarning, jt as getMigrationFilePath, l as restoreCommand, lt as functionExecutionStatusToString, mt as applyCommand, nt as startCommand, ot as executionsCommand, p as getCommand$4, q as webhookCommand, qt as deploymentArgs, r as removeCommand, s as inviteCommand, t as updateCommand$2, ut as formatKeyValueTable, vt as parseMigrationLabelNumber } from "../update-DQKCUNmr.mjs";
|
|
5
|
+
import { E as readPackageJson, S as initOperatorClient, Z as PATScope, _ as writePlatformConfig, b as fetchUserInfo, ct as styles, d as fetchLatestToken, f as loadAccessToken, g as readPlatformConfig, h as loadWorkspaceId, i as loadConfig, st as logger, v as fetchAll, x as initOAuth2Client, z as FunctionExecution_Type } from "../application-DYfVZVPT.mjs";
|
|
6
6
|
import { createRequire, register } from "node:module";
|
|
7
7
|
import { arg, defineCommand, runCommand, runMain } from "politty";
|
|
8
8
|
import { withCompletionCommand } from "politty/completion";
|
package/dist/cli/lib.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="./../user-defined.d.ts" />
|
|
2
|
-
import { F as Plugin, I as PluginAttachment, d as IdProviderConfig, lt as Resolver, n as TypeSourceInfoEntry, p as OAuth2ClientInput, t as TailorDBType } from "../types-
|
|
3
|
-
import { C as ScheduleTriggerInput, b as IncomingWebhookTrigger,
|
|
2
|
+
import { F as Plugin, I as PluginAttachment, d as IdProviderConfig, lt as Resolver, n as TypeSourceInfoEntry, p as OAuth2ClientInput, t as TailorDBType } from "../types-DzvazVmg.mjs";
|
|
3
|
+
import { C as ScheduleTriggerInput, b as IncomingWebhookTrigger, c as CodeGeneratorBase, p as Executor, t as AppConfig } from "../types-BeNtD-fA.mjs";
|
|
4
4
|
import "politty";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { OAuth2Client } from "@badgateway/oauth2-client";
|
|
@@ -8,11 +8,73 @@ import { Duration, FieldMask, Timestamp, Value } from "@bufbuild/protobuf/wkt";
|
|
|
8
8
|
import { Client } from "@connectrpc/connect";
|
|
9
9
|
import * as _bufbuild_protobuf_codegenv20 from "@bufbuild/protobuf/codegenv2";
|
|
10
10
|
import { GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
|
11
|
+
import "rolldown";
|
|
11
12
|
import { JsonObject, Message } from "@bufbuild/protobuf";
|
|
12
13
|
import { Jsonifiable } from "type-fest";
|
|
13
14
|
|
|
15
|
+
//#region src/cli/config-loader.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Loaded configuration with resolved path
|
|
18
|
+
*/
|
|
19
|
+
type LoadedConfig = AppConfig & {
|
|
20
|
+
path: string;
|
|
21
|
+
};
|
|
22
|
+
declare const GeneratorConfigSchema: z.core.$ZodBranded<z.ZodPipe<z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<"@tailor-platform/kysely-type">, z.ZodObject<{
|
|
23
|
+
distPath: z.ZodString;
|
|
24
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/seed">, z.ZodObject<{
|
|
25
|
+
distPath: z.ZodString;
|
|
26
|
+
machineUserName: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/enum-constants">, z.ZodObject<{
|
|
28
|
+
distPath: z.ZodString;
|
|
29
|
+
}, z.core.$strip>], null>, z.ZodTuple<[z.ZodLiteral<"@tailor-platform/file-utils">, z.ZodObject<{
|
|
30
|
+
distPath: z.ZodString;
|
|
31
|
+
}, z.core.$strip>], null>, z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
description: z.ZodString;
|
|
34
|
+
dependencies: z.ZodArray<z.ZodEnum<{
|
|
35
|
+
executor: "executor";
|
|
36
|
+
tailordb: "tailordb";
|
|
37
|
+
resolver: "resolver";
|
|
38
|
+
}>>;
|
|
39
|
+
processType: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
40
|
+
processResolver: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
41
|
+
processExecutor: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
42
|
+
processTailorDBNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
43
|
+
processResolverNamespace: z.ZodOptional<z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>>;
|
|
44
|
+
aggregate: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodAny>;
|
|
45
|
+
}, z.core.$strip>]>, z.ZodTransform<CodeGeneratorBase, {
|
|
46
|
+
id: string;
|
|
47
|
+
description: string;
|
|
48
|
+
dependencies: ("executor" | "tailordb" | "resolver")[];
|
|
49
|
+
aggregate: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.ZodAny>;
|
|
50
|
+
processType?: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
|
|
51
|
+
processResolver?: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
|
|
52
|
+
processExecutor?: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
|
|
53
|
+
processTailorDBNamespace?: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
|
|
54
|
+
processResolverNamespace?: z.core.$InferOuterFunctionType<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut> | undefined;
|
|
55
|
+
} | ["@tailor-platform/kysely-type", {
|
|
56
|
+
distPath: string;
|
|
57
|
+
}] | ["@tailor-platform/seed", {
|
|
58
|
+
distPath: string;
|
|
59
|
+
machineUserName?: string | undefined;
|
|
60
|
+
}] | ["@tailor-platform/enum-constants", {
|
|
61
|
+
distPath: string;
|
|
62
|
+
}] | ["@tailor-platform/file-utils", {
|
|
63
|
+
distPath: string;
|
|
64
|
+
}]>>, "CodeGenerator", "out">;
|
|
65
|
+
type Generator = z.output<typeof GeneratorConfigSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* Load Tailor configuration file and associated generators and plugins.
|
|
68
|
+
* @param configPath - Optional explicit config path
|
|
69
|
+
* @returns Loaded config, generators, plugins, and config path
|
|
70
|
+
*/
|
|
71
|
+
declare function loadConfig(configPath?: string): Promise<{
|
|
72
|
+
config: LoadedConfig;
|
|
73
|
+
generators: Generator[];
|
|
74
|
+
plugins: Plugin[];
|
|
75
|
+
}>;
|
|
76
|
+
//#endregion
|
|
14
77
|
//#region ../tailor-proto/src/tailor/v1/workspace_resource_pb.d.ts
|
|
15
|
-
|
|
16
78
|
/**
|
|
17
79
|
* @generated from message tailor.v1.Organization
|
|
18
80
|
*/
|
|
@@ -16928,24 +16990,6 @@ declare function initOperatorClient(accessToken: string): Promise<Client<_bufbui
|
|
|
16928
16990
|
};
|
|
16929
16991
|
}>>>;
|
|
16930
16992
|
//#endregion
|
|
16931
|
-
//#region src/cli/config-loader.d.ts
|
|
16932
|
-
/**
|
|
16933
|
-
* Loaded configuration with resolved path
|
|
16934
|
-
*/
|
|
16935
|
-
type LoadedConfig = AppConfig & {
|
|
16936
|
-
path: string;
|
|
16937
|
-
};
|
|
16938
|
-
/**
|
|
16939
|
-
* Load Tailor configuration file and associated generators and plugins.
|
|
16940
|
-
* @param configPath - Optional explicit config path
|
|
16941
|
-
* @returns Loaded config, generators, plugins, and config path
|
|
16942
|
-
*/
|
|
16943
|
-
declare function loadConfig(configPath?: string): Promise<{
|
|
16944
|
-
config: LoadedConfig;
|
|
16945
|
-
generators: Generator[];
|
|
16946
|
-
plugins: Plugin[];
|
|
16947
|
-
}>;
|
|
16948
|
-
//#endregion
|
|
16949
16993
|
//#region src/cli/apply/index.d.ts
|
|
16950
16994
|
interface ApplyOptions {
|
|
16951
16995
|
workspaceId?: string;
|
|
@@ -17490,6 +17534,17 @@ interface ListWorkflowsOptions {
|
|
|
17490
17534
|
declare function listWorkflows(options?: ListWorkflowsOptions): Promise<WorkflowListInfo[]>;
|
|
17491
17535
|
//#endregion
|
|
17492
17536
|
//#region src/cli/workflow/get.d.ts
|
|
17537
|
+
type WorkflowLike$2 = {
|
|
17538
|
+
name: string;
|
|
17539
|
+
};
|
|
17540
|
+
type GetWorkflowTypedOptions<W extends WorkflowLike$2 = WorkflowLike$2> = {
|
|
17541
|
+
workflow: W;
|
|
17542
|
+
workspaceId?: string;
|
|
17543
|
+
profile?: string;
|
|
17544
|
+
};
|
|
17545
|
+
/**
|
|
17546
|
+
* @deprecated Use GetWorkflowTypedOptions instead.
|
|
17547
|
+
*/
|
|
17493
17548
|
interface GetWorkflowOptions {
|
|
17494
17549
|
name: string;
|
|
17495
17550
|
workspaceId?: string;
|
|
@@ -17500,10 +17555,11 @@ interface GetWorkflowOptions {
|
|
|
17500
17555
|
* @param options - Workflow lookup options
|
|
17501
17556
|
* @returns Workflow information
|
|
17502
17557
|
*/
|
|
17558
|
+
declare function getWorkflow<W extends WorkflowLike$2>(options: GetWorkflowTypedOptions<W>): Promise<WorkflowInfo>;
|
|
17503
17559
|
declare function getWorkflow(options: GetWorkflowOptions): Promise<WorkflowInfo>;
|
|
17504
17560
|
//#endregion
|
|
17505
17561
|
//#region src/cli/workflow/start.d.ts
|
|
17506
|
-
type WorkflowLike = {
|
|
17562
|
+
type WorkflowLike$1 = {
|
|
17507
17563
|
name: string;
|
|
17508
17564
|
mainJob: {
|
|
17509
17565
|
body: unknown;
|
|
@@ -17513,15 +17569,15 @@ type AuthInvoker$1<M extends string = string> = {
|
|
|
17513
17569
|
namespace: string;
|
|
17514
17570
|
machineUserName: M;
|
|
17515
17571
|
};
|
|
17516
|
-
type WorkflowInput<W extends WorkflowLike> = W extends WorkflowLike ? W["mainJob"]["body"] extends ((...args: infer Args) => unknown) ? Args[0] : never : never;
|
|
17517
|
-
type StartWorkflowArgOptionForSingleWorkflow<W extends WorkflowLike> = WorkflowLike extends W ? {
|
|
17572
|
+
type WorkflowInput<W extends WorkflowLike$1> = W extends WorkflowLike$1 ? W["mainJob"]["body"] extends ((...args: infer Args) => unknown) ? Args[0] : never : never;
|
|
17573
|
+
type StartWorkflowArgOptionForSingleWorkflow<W extends WorkflowLike$1> = WorkflowLike$1 extends W ? {
|
|
17518
17574
|
arg?: Jsonifiable;
|
|
17519
17575
|
} : undefined extends WorkflowInput<W> ? {
|
|
17520
17576
|
arg?: WorkflowInput<W>;
|
|
17521
17577
|
} : {
|
|
17522
17578
|
arg: WorkflowInput<W>;
|
|
17523
17579
|
};
|
|
17524
|
-
type StartWorkflowArgOption<W extends WorkflowLike> = W extends WorkflowLike ? StartWorkflowArgOptionForSingleWorkflow<W> : never;
|
|
17580
|
+
type StartWorkflowArgOption<W extends WorkflowLike$1> = W extends WorkflowLike$1 ? StartWorkflowArgOptionForSingleWorkflow<W> : never;
|
|
17525
17581
|
/**
|
|
17526
17582
|
* @deprecated Use StartWorkflowTypedOptions instead.
|
|
17527
17583
|
*/
|
|
@@ -17534,14 +17590,14 @@ interface StartWorkflowOptions {
|
|
|
17534
17590
|
configPath?: string;
|
|
17535
17591
|
interval?: number;
|
|
17536
17592
|
}
|
|
17537
|
-
type StartWorkflowTypedBaseOptions<W extends WorkflowLike> = {
|
|
17593
|
+
type StartWorkflowTypedBaseOptions<W extends WorkflowLike$1> = {
|
|
17538
17594
|
workflow: W;
|
|
17539
17595
|
authInvoker: AuthInvoker$1<string>;
|
|
17540
17596
|
workspaceId?: string;
|
|
17541
17597
|
profile?: string;
|
|
17542
17598
|
interval?: number;
|
|
17543
17599
|
};
|
|
17544
|
-
type StartWorkflowTypedOptions<W extends WorkflowLike = WorkflowLike> = W extends WorkflowLike ? StartWorkflowTypedBaseOptions<W> & StartWorkflowArgOption<W> : never;
|
|
17600
|
+
type StartWorkflowTypedOptions<W extends WorkflowLike$1 = WorkflowLike$1> = W extends WorkflowLike$1 ? StartWorkflowTypedBaseOptions<W> & StartWorkflowArgOption<W> : never;
|
|
17545
17601
|
interface WaitOptions {
|
|
17546
17602
|
showProgress?: boolean;
|
|
17547
17603
|
}
|
|
@@ -17554,10 +17610,22 @@ interface StartWorkflowResultWithWait {
|
|
|
17554
17610
|
* @param options - Start options
|
|
17555
17611
|
* @returns Start result with wait helper
|
|
17556
17612
|
*/
|
|
17557
|
-
declare function startWorkflow<W extends WorkflowLike>(options: StartWorkflowTypedOptions<W>): Promise<StartWorkflowResultWithWait>;
|
|
17613
|
+
declare function startWorkflow<W extends WorkflowLike$1>(options: StartWorkflowTypedOptions<W>): Promise<StartWorkflowResultWithWait>;
|
|
17558
17614
|
declare function startWorkflow(options: StartWorkflowOptions): Promise<StartWorkflowResultWithWait>;
|
|
17559
17615
|
//#endregion
|
|
17560
17616
|
//#region src/cli/workflow/executions.d.ts
|
|
17617
|
+
type WorkflowLike = {
|
|
17618
|
+
name: string;
|
|
17619
|
+
};
|
|
17620
|
+
type ListWorkflowExecutionsTypedOptions<W extends WorkflowLike = WorkflowLike> = {
|
|
17621
|
+
workflow?: W;
|
|
17622
|
+
status?: string;
|
|
17623
|
+
workspaceId?: string;
|
|
17624
|
+
profile?: string;
|
|
17625
|
+
};
|
|
17626
|
+
/**
|
|
17627
|
+
* @deprecated Use ListWorkflowExecutionsTypedOptions instead.
|
|
17628
|
+
*/
|
|
17561
17629
|
interface ListWorkflowExecutionsOptions {
|
|
17562
17630
|
workspaceId?: string;
|
|
17563
17631
|
profile?: string;
|
|
@@ -17586,6 +17654,7 @@ interface GetWorkflowExecutionResult {
|
|
|
17586
17654
|
* @param options - Workflow execution listing options
|
|
17587
17655
|
* @returns List of workflow executions
|
|
17588
17656
|
*/
|
|
17657
|
+
declare function listWorkflowExecutions<W extends WorkflowLike>(options?: ListWorkflowExecutionsTypedOptions<W>): Promise<WorkflowExecutionInfo[]>;
|
|
17589
17658
|
declare function listWorkflowExecutions(options?: ListWorkflowExecutionsOptions): Promise<WorkflowExecutionInfo[]>;
|
|
17590
17659
|
/**
|
|
17591
17660
|
* Get a single workflow execution with optional logs.
|
|
@@ -17689,6 +17758,34 @@ interface ExecutorInfo {
|
|
|
17689
17758
|
}
|
|
17690
17759
|
//#endregion
|
|
17691
17760
|
//#region src/cli/executor/jobs.d.ts
|
|
17761
|
+
type ExecutorLike$1 = {
|
|
17762
|
+
name: string;
|
|
17763
|
+
};
|
|
17764
|
+
type ListExecutorJobsTypedOptions<E extends ExecutorLike$1 = ExecutorLike$1> = {
|
|
17765
|
+
executor: E;
|
|
17766
|
+
status?: string;
|
|
17767
|
+
limit?: number;
|
|
17768
|
+
workspaceId?: string;
|
|
17769
|
+
profile?: string;
|
|
17770
|
+
};
|
|
17771
|
+
type GetExecutorJobTypedOptions<E extends ExecutorLike$1 = ExecutorLike$1> = {
|
|
17772
|
+
executor: E;
|
|
17773
|
+
jobId: string;
|
|
17774
|
+
attempts?: boolean;
|
|
17775
|
+
workspaceId?: string;
|
|
17776
|
+
profile?: string;
|
|
17777
|
+
};
|
|
17778
|
+
type WatchExecutorJobTypedOptions<E extends ExecutorLike$1 = ExecutorLike$1> = {
|
|
17779
|
+
executor: E;
|
|
17780
|
+
jobId: string;
|
|
17781
|
+
workspaceId?: string;
|
|
17782
|
+
profile?: string;
|
|
17783
|
+
interval?: number;
|
|
17784
|
+
logs?: boolean;
|
|
17785
|
+
};
|
|
17786
|
+
/**
|
|
17787
|
+
* @deprecated Use ListExecutorJobsTypedOptions instead.
|
|
17788
|
+
*/
|
|
17692
17789
|
interface ListExecutorJobsOptions {
|
|
17693
17790
|
executorName: string;
|
|
17694
17791
|
status?: string;
|
|
@@ -17696,6 +17793,9 @@ interface ListExecutorJobsOptions {
|
|
|
17696
17793
|
workspaceId?: string;
|
|
17697
17794
|
profile?: string;
|
|
17698
17795
|
}
|
|
17796
|
+
/**
|
|
17797
|
+
* @deprecated Use GetExecutorJobTypedOptions instead.
|
|
17798
|
+
*/
|
|
17699
17799
|
interface GetExecutorJobOptions {
|
|
17700
17800
|
executorName: string;
|
|
17701
17801
|
jobId: string;
|
|
@@ -17703,6 +17803,9 @@ interface GetExecutorJobOptions {
|
|
|
17703
17803
|
workspaceId?: string;
|
|
17704
17804
|
profile?: string;
|
|
17705
17805
|
}
|
|
17806
|
+
/**
|
|
17807
|
+
* @deprecated Use WatchExecutorJobTypedOptions instead.
|
|
17808
|
+
*/
|
|
17706
17809
|
interface WatchExecutorJobOptions {
|
|
17707
17810
|
executorName: string;
|
|
17708
17811
|
jobId: string;
|
|
@@ -17734,18 +17837,21 @@ interface WatchExecutorJobResult {
|
|
|
17734
17837
|
* @param options - Options for listing executor jobs
|
|
17735
17838
|
* @returns List of executor job information
|
|
17736
17839
|
*/
|
|
17840
|
+
declare function listExecutorJobs<E extends ExecutorLike$1>(options: ListExecutorJobsTypedOptions<E>): Promise<ExecutorJobListInfo[]>;
|
|
17737
17841
|
declare function listExecutorJobs(options: ListExecutorJobsOptions): Promise<ExecutorJobListInfo[]>;
|
|
17738
17842
|
/**
|
|
17739
17843
|
* Get details of a specific executor job.
|
|
17740
17844
|
* @param options - Options for getting executor job details
|
|
17741
17845
|
* @returns Executor job detail information
|
|
17742
17846
|
*/
|
|
17847
|
+
declare function getExecutorJob<E extends ExecutorLike$1>(options: GetExecutorJobTypedOptions<E>): Promise<ExecutorJobDetailInfo>;
|
|
17743
17848
|
declare function getExecutorJob(options: GetExecutorJobOptions): Promise<ExecutorJobDetailInfo>;
|
|
17744
17849
|
/**
|
|
17745
17850
|
* Watch an executor job until completion, including downstream executions.
|
|
17746
17851
|
* @param options - Options for watching executor job
|
|
17747
17852
|
* @returns Result including job details and downstream execution info
|
|
17748
17853
|
*/
|
|
17854
|
+
declare function watchExecutorJob<E extends ExecutorLike$1>(options: WatchExecutorJobTypedOptions<E>): Promise<WatchExecutorJobResult>;
|
|
17749
17855
|
declare function watchExecutorJob(options: WatchExecutorJobOptions): Promise<WatchExecutorJobResult>;
|
|
17750
17856
|
//#endregion
|
|
17751
17857
|
//#region src/cli/executor/list.d.ts
|
|
@@ -17761,6 +17867,17 @@ interface ListExecutorsOptions {
|
|
|
17761
17867
|
declare function listExecutors(options?: ListExecutorsOptions): Promise<ExecutorListInfo[]>;
|
|
17762
17868
|
//#endregion
|
|
17763
17869
|
//#region src/cli/executor/get.d.ts
|
|
17870
|
+
type ExecutorLike = {
|
|
17871
|
+
name: string;
|
|
17872
|
+
};
|
|
17873
|
+
type GetExecutorTypedOptions<E extends ExecutorLike = ExecutorLike> = {
|
|
17874
|
+
executor: E;
|
|
17875
|
+
workspaceId?: string;
|
|
17876
|
+
profile?: string;
|
|
17877
|
+
};
|
|
17878
|
+
/**
|
|
17879
|
+
* @deprecated Use GetExecutorTypedOptions instead.
|
|
17880
|
+
*/
|
|
17764
17881
|
interface GetExecutorOptions {
|
|
17765
17882
|
name: string;
|
|
17766
17883
|
workspaceId?: string;
|
|
@@ -17771,6 +17888,7 @@ interface GetExecutorOptions {
|
|
|
17771
17888
|
* @param options - Executor lookup options
|
|
17772
17889
|
* @returns Executor information
|
|
17773
17890
|
*/
|
|
17891
|
+
declare function getExecutor<E extends ExecutorLike>(options: GetExecutorTypedOptions<E>): Promise<ExecutorInfo>;
|
|
17774
17892
|
declare function getExecutor(options: GetExecutorOptions): Promise<ExecutorInfo>;
|
|
17775
17893
|
//#endregion
|
|
17776
17894
|
//#region src/cli/executor/webhook.d.ts
|
|
@@ -18403,5 +18521,5 @@ declare function waitForExecution(client: OperatorClient, workspaceId: string, e
|
|
|
18403
18521
|
*/
|
|
18404
18522
|
declare function executeScript(options: ScriptExecutionOptions): Promise<ScriptExecutionResult>;
|
|
18405
18523
|
//#endregion
|
|
18406
|
-
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 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 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 WebhookExecutorInfo, type WorkflowExecutionInfo, type WorkflowInfo, type WorkflowJobExecutionInfo, type WorkflowListInfo, type WorkspaceDetails, type WorkspaceInfo, apiCall, apply, bundleMigrationScript, bundleSeedScript, chunkSeedData, 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 };
|
|
18524
|
+
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, 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 };
|
|
18407
18525
|
//# sourceMappingURL=lib.d.mts.map
|
package/dist/cli/lib.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../chunk-GMkBE123.mjs";
|
|
2
|
-
import "../schema-
|
|
3
|
-
import { At as getMigrationDirPath, B as getMachineUserToken, Bt as getNamespacesWithMigrations, Ct as MIGRATE_FILE_NAME, D as truncate, Dt as createSnapshotFromLocalTypes, E as listWorkflows, Et as compareSnapshots,
|
|
4
|
-
import { f as logger } from "../application-
|
|
2
|
+
import "../schema-R5TxC5Pn.mjs";
|
|
3
|
+
import { At as getMigrationDirPath, B as getMachineUserToken, Bt as getNamespacesWithMigrations, Ct as MIGRATE_FILE_NAME, D as truncate, Dt as createSnapshotFromLocalTypes, E as listWorkflows, Et as compareSnapshots, Ht as generateUserTypes, It as reconstructSnapshotFromMigrations, K as listWebhookExecutors, L as listOAuth2Clients, Lt as formatDiffSummary, M as show, Mt as getMigrationFiles, Nt as getNextMigrationNumber, P as remove, Q as getExecutorJob, Rt as formatMigrationDiff, St as INITIAL_SCHEMA_NUMBER, Tt as compareLocalTypesWithSnapshot, U as listMachineUsers, Ut as apiCall, W as generate, Y as triggerExecutor, Z as listExecutors, _t as MIGRATION_LABEL_KEY, at as getWorkflow, bt as DB_TYPES_FILE_NAME, c as inviteUser, ct as listWorkflowExecutions, et as listExecutorJobs, f as listWorkspaces, ft as getExecutor, g as deleteWorkspace, gt as waitForExecution, ht as executeScript, i as removeUser, jt as getMigrationFilePath, k as generate$1, kt as getLatestMigrationNumber, m as getWorkspace, n as updateUser, o as listUsers, pt as apply, rt as startWorkflow, st as getWorkflowExecution, tt as watchExecutorJob, u as restoreWorkspace, v as createWorkspace, w as resumeWorkflow, wt as SCHEMA_FILE_NAME, x as getAppHealth, xt as DIFF_FILE_NAME, y as listApps, yt as bundleMigrationScript, z as getOAuth2Client, zt as hasChanges } from "../update-DQKCUNmr.mjs";
|
|
4
|
+
import { S as initOperatorClient, f as loadAccessToken, h as loadWorkspaceId, i as loadConfig, o as getDistDir, st as logger } from "../application-DYfVZVPT.mjs";
|
|
5
5
|
import { createRequire, register } from "node:module";
|
|
6
6
|
import * as fs$1 from "node:fs";
|
|
7
7
|
import * as path from "pathe";
|
package/dist/cli/lib.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.mjs","names":["fs"],"sources":["../../src/cli/utils/seed-chunker.ts","../../src/cli/bundler/seed/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 { 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 PluginAttachment,\n TypeSourceInfoEntry,\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 StartWorkflowTypedOptions,\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 TriggerExecutorTypedOptions,\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 { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./utils/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./bundler/seed/seed-bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./bundler/migration/migration-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":"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"}
|
|
1
|
+
{"version":3,"file":"lib.mjs","names":["fs"],"sources":["../../src/cli/utils/seed-chunker.ts","../../src/cli/bundler/seed/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 { 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 PluginAttachment,\n TypeSourceInfoEntry,\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, type GetWorkflowTypedOptions } from \"./workflow/get\";\nexport {\n startWorkflow,\n type StartWorkflowOptions,\n type StartWorkflowTypedOptions,\n type StartWorkflowResultWithWait,\n type WaitOptions,\n} from \"./workflow/start\";\nexport {\n listWorkflowExecutions,\n getWorkflowExecution,\n type ListWorkflowExecutionsOptions,\n type ListWorkflowExecutionsTypedOptions,\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 TriggerExecutorTypedOptions,\n type TriggerExecutorResult,\n} from \"./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 \"./executor/jobs\";\nexport { listExecutors, type ListExecutorsOptions } from \"./executor/list\";\nexport { getExecutor, type GetExecutorOptions, type GetExecutorTypedOptions } 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 { chunkSeedData, type SeedChunk, type ChunkSeedDataOptions } from \"./utils/seed-chunker\";\nexport { bundleSeedScript, type SeedBundleResult } from \"./bundler/seed/seed-bundler\";\nexport {\n bundleMigrationScript,\n type MigrationBundleResult,\n} from \"./bundler/migration/migration-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":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./../user-defined.d.ts" />
|
|
2
|
-
import { $ as unsafeAllowAllTypePermission, A as TailorDBField, B as PluginGeneratedExecutor, C as UserAttributeKey, Ct as unauthenticatedTailorUser, D as ValueOperand, E as UsernameFieldKey, F as Plugin, G as PluginOutput, H as PluginGeneratedResolver, I as PluginAttachment, J as TypePluginOutput, K as PluginProcessContext, L as PluginConfigs, M as TailorDBType, N as db, O as TailorAnyDBField, P as NamespacePluginOutput, Q as unsafeAllowAllGqlPermission, R as PluginExecutorContext, S as TenantProviderConfig, St as TailorUser, T as UserAttributeMap, U as PluginGeneratedType, V as PluginGeneratedExecutorWithFile, W as PluginNamespaceProcessContext, X as TailorTypeGqlPermission, Y as PermissionCondition, Z as TailorTypePermission, _ as SCIMAttributeMapping, _t as Env, b as SCIMConfig, bt as AttributeList, c as BuiltinIdP, ct as QueryType, d as IdProviderConfig, f as OAuth2ClientGrantType, ft as ResolverServiceConfig, g as SCIMAttribute, h as SAML, i as AuthExternalConfig, j as TailorDBInstance, k as TailorAnyDBType, l as DefinedAuth, lt as Resolver, m as OIDC, o as AuthOwnConfig, p as OAuth2ClientInput, pt as ResolverServiceInput, q as TailorDBTypeForPlugin, r as AuthConfig, s as AuthServiceInput, st as TailorField, u as IDToken, ut as ResolverExternalConfig, v as SCIMAttributeType, w as UserAttributeListKey, x as SCIMResource, xt as AttributeMap, y as SCIMAuthorization, z as PluginExecutorContextBase } from "../types-
|
|
3
|
-
import {
|
|
4
|
-
import { $ as defineAuth, A as idpUserCreatedTrigger, B as WebhookOperation, C as RecordTrigger, D as authAccessTokenIssuedTrigger, E as ResolverExecutedTrigger, F as recordUpdatedTrigger, G as WORKFLOW_TEST_ENV_KEY, H as Workflow, I as resolverExecutedTrigger, J as WorkflowJobInput, K as WorkflowJob, L as FunctionOperation, M as idpUserUpdatedTrigger, N as recordCreatedTrigger, O as authAccessTokenRefreshedTrigger, P as recordDeletedTrigger, Q as AuthInvoker, R as GqlOperation, S as RecordDeletedArgs, T as ResolverExecutedArgs, U as WorkflowConfig, V as WorkflowOperation, W as createWorkflow, X as createWorkflowJob, Y as WorkflowJobOutput, Z as createResolver, _ as AuthAccessTokenArgs, a as defineGenerators, b as IdpUserTrigger, c as createExecutor, d as IncomingWebhookRequest, f as IncomingWebhookTrigger, g as scheduleTrigger, h as ScheduleTrigger, i as defineConfig, j as idpUserDeletedTrigger, k as authAccessTokenRevokedTrigger, l as Trigger, m as ScheduleArgs, n as output, o as definePlugins, p as incomingWebhookTrigger, q as WorkflowJobContext, r as t, s as defineIdp, t as infer, u as IncomingWebhookArgs, v as AuthAccessTokenTrigger, w as RecordUpdatedArgs, x as RecordCreatedArgs, y as IdpUserArgs, z as Operation } from "../index-
|
|
2
|
+
import { $ as unsafeAllowAllTypePermission, A as TailorDBField, B as PluginGeneratedExecutor, C as UserAttributeKey, Ct as unauthenticatedTailorUser, D as ValueOperand, E as UsernameFieldKey, F as Plugin, G as PluginOutput, H as PluginGeneratedResolver, I as PluginAttachment, J as TypePluginOutput, K as PluginProcessContext, L as PluginConfigs, M as TailorDBType, N as db, O as TailorAnyDBField, P as NamespacePluginOutput, Q as unsafeAllowAllGqlPermission, R as PluginExecutorContext, S as TenantProviderConfig, St as TailorUser, T as UserAttributeMap, U as PluginGeneratedType, V as PluginGeneratedExecutorWithFile, W as PluginNamespaceProcessContext, X as TailorTypeGqlPermission, Y as PermissionCondition, Z as TailorTypePermission, _ as SCIMAttributeMapping, _t as Env, b as SCIMConfig, bt as AttributeList, c as BuiltinIdP, ct as QueryType, d as IdProviderConfig, f as OAuth2ClientGrantType, ft as ResolverServiceConfig, g as SCIMAttribute, h as SAML, i as AuthExternalConfig, j as TailorDBInstance, k as TailorAnyDBType, l as DefinedAuth, lt as Resolver, m as OIDC, o as AuthOwnConfig, p as OAuth2ClientInput, pt as ResolverServiceInput, q as TailorDBTypeForPlugin, r as AuthConfig, s as AuthServiceInput, st as TailorField, u as IDToken, ut as ResolverExternalConfig, v as SCIMAttributeType, w as UserAttributeListKey, x as SCIMResource, xt as AttributeMap, y as SCIMAuthorization, z as PluginExecutorContextBase } from "../types-DzvazVmg.mjs";
|
|
3
|
+
import { d as WorkflowServiceInput, g as ExecutorServiceInput, h as ExecutorServiceConfig, n as IdPConfig, o as StaticWebsiteConfig, r as IdPExternalConfig, s as defineStaticWebSite, u as WorkflowServiceConfig } from "../types-BeNtD-fA.mjs";
|
|
4
|
+
import { $ as defineAuth, A as idpUserCreatedTrigger, B as WebhookOperation, C as RecordTrigger, D as authAccessTokenIssuedTrigger, E as ResolverExecutedTrigger, F as recordUpdatedTrigger, G as WORKFLOW_TEST_ENV_KEY, H as Workflow, I as resolverExecutedTrigger, J as WorkflowJobInput, K as WorkflowJob, L as FunctionOperation, M as idpUserUpdatedTrigger, N as recordCreatedTrigger, O as authAccessTokenRefreshedTrigger, P as recordDeletedTrigger, Q as AuthInvoker, R as GqlOperation, S as RecordDeletedArgs, T as ResolverExecutedArgs, U as WorkflowConfig, V as WorkflowOperation, W as createWorkflow, X as createWorkflowJob, Y as WorkflowJobOutput, Z as createResolver, _ as AuthAccessTokenArgs, a as defineGenerators, b as IdpUserTrigger, c as createExecutor, d as IncomingWebhookRequest, f as IncomingWebhookTrigger, g as scheduleTrigger, h as ScheduleTrigger, i as defineConfig, j as idpUserDeletedTrigger, k as authAccessTokenRevokedTrigger, l as Trigger, m as ScheduleArgs, n as output, o as definePlugins, p as incomingWebhookTrigger, q as WorkflowJobContext, r as t, s as defineIdp, t as infer, u as IncomingWebhookArgs, v as AuthAccessTokenTrigger, w as RecordUpdatedArgs, x as RecordCreatedArgs, y as IdpUserArgs, z as Operation } from "../index-qQXpN674.mjs";
|
|
5
5
|
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, NamespacePluginOutput, OAuth2ClientInput as OAuth2Client, OAuth2ClientGrantType, OIDC, Operation, PermissionCondition, Plugin, PluginAttachment, PluginConfigs, PluginExecutorContext, PluginExecutorContextBase, PluginGeneratedExecutor, PluginGeneratedExecutorWithFile, PluginGeneratedResolver, PluginGeneratedType, PluginNamespaceProcessContext, PluginOutput, PluginProcessContext, QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordTrigger, RecordUpdatedArgs, Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, ResolverExternalConfig, ResolverServiceConfig, ResolverServiceInput, SAML, SCIMAttribute, SCIMAttributeMapping, SCIMAttributeType, SCIMAuthorization, SCIMConfig, SCIMResource, ScheduleArgs, ScheduleTrigger, StaticWebsiteConfig, TailorAnyDBField, TailorAnyDBType, TailorDBField, TailorDBInstance, TailorDBType, TailorDBTypeForPlugin, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, TenantProviderConfig, Trigger, TypePluginOutput, 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, definePlugins, defineStaticWebSite, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, infer, output, recordCreatedTrigger, recordDeletedTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, t, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllTypePermission };
|
package/dist/configure/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as t$1, n as unsafeAllowAllGqlPermission, r as unsafeAllowAllTypePermission, t as db } from "../schema-
|
|
2
|
-
import { n as createWorkflowJob, t as WORKFLOW_TEST_ENV_KEY } from "../job-
|
|
1
|
+
import { i as t$1, n as unsafeAllowAllGqlPermission, r as unsafeAllowAllTypePermission, t as db } from "../schema-R5TxC5Pn.mjs";
|
|
2
|
+
import { n as createWorkflowJob, t as WORKFLOW_TEST_ENV_KEY } from "../job-CULA2Pvf.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/configure/types/user.ts
|
|
5
5
|
/** Represents an unauthenticated user in the Tailor platform. */
|
|
@@ -37,10 +37,36 @@ function validateAuthConfig(config) {
|
|
|
37
37
|
//#region src/configure/services/resolver/resolver.ts
|
|
38
38
|
/**
|
|
39
39
|
* Create a resolver definition for the Tailor SDK.
|
|
40
|
+
*
|
|
41
|
+
* The `body` function receives a context with `input` (typed from `config.input`),
|
|
42
|
+
* `user` (TailorUser with id, type, workspaceId, attributes, attributeList), and `env` (TailorEnv).
|
|
43
|
+
* The return value of `body` must match the `output` type.
|
|
44
|
+
*
|
|
45
|
+
* `output` accepts either a single TailorField (e.g. `t.string()`) or a
|
|
46
|
+
* Record of fields (e.g. `{ name: t.string(), age: t.int() }`).
|
|
40
47
|
* @template Input
|
|
41
48
|
* @template Output
|
|
42
49
|
* @param config - Resolver configuration
|
|
43
50
|
* @returns Normalized resolver configuration
|
|
51
|
+
* @example
|
|
52
|
+
* import { createResolver, t } from "@tailor-platform/sdk";
|
|
53
|
+
*
|
|
54
|
+
* export default createResolver({
|
|
55
|
+
* name: "getUser",
|
|
56
|
+
* operation: "query",
|
|
57
|
+
* input: {
|
|
58
|
+
* id: t.string(),
|
|
59
|
+
* },
|
|
60
|
+
* body: async ({ input, user }) => {
|
|
61
|
+
* const db = getDB("tailordb");
|
|
62
|
+
* const result = await db.selectFrom("User").selectAll().where("id", "=", input.id).executeTakeFirst();
|
|
63
|
+
* return { name: result?.name ?? "", email: result?.email ?? "" };
|
|
64
|
+
* },
|
|
65
|
+
* output: t.object({
|
|
66
|
+
* name: t.string(),
|
|
67
|
+
* email: t.string(),
|
|
68
|
+
* }),
|
|
69
|
+
* });
|
|
44
70
|
*/
|
|
45
71
|
function createResolver(config) {
|
|
46
72
|
const isTailorField = (obj) => typeof obj === "object" && obj !== null && "type" in obj && typeof obj.type === "string";
|
|
@@ -217,9 +243,27 @@ function incomingWebhookTrigger() {
|
|
|
217
243
|
/**
|
|
218
244
|
* Create a workflow definition that can be triggered via the Tailor SDK.
|
|
219
245
|
* In production, bundler transforms .trigger() calls to tailor.workflow.triggerWorkflow().
|
|
246
|
+
*
|
|
247
|
+
* The workflow MUST be the default export of the file.
|
|
248
|
+
* All jobs referenced by the workflow MUST be named exports.
|
|
220
249
|
* @template Job
|
|
221
250
|
* @param config - Workflow configuration
|
|
222
251
|
* @returns Defined workflow
|
|
252
|
+
* @example
|
|
253
|
+
* export const fetchData = createWorkflowJob({ name: "fetch-data", body: async (input: { id: string }) => ({ id: input.id }) });
|
|
254
|
+
* export const processData = createWorkflowJob({
|
|
255
|
+
* name: "process-data",
|
|
256
|
+
* body: async (input: { id: string }) => {
|
|
257
|
+
* const data = await fetchData.trigger({ id: input.id }); // await is optional — stripped by bundler
|
|
258
|
+
* return { data };
|
|
259
|
+
* },
|
|
260
|
+
* });
|
|
261
|
+
*
|
|
262
|
+
* // Workflow must be default export; mainJob is the entry point
|
|
263
|
+
* export default createWorkflow({
|
|
264
|
+
* name: "data-processing",
|
|
265
|
+
* mainJob: processData,
|
|
266
|
+
* });
|
|
223
267
|
*/
|
|
224
268
|
function createWorkflow(config) {
|
|
225
269
|
return {
|