@tailor-platform/sdk 2.22.0 → 2.23.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 +18 -0
- package/dist/aigateway-DsWDjzk4.mjs.map +1 -1
- package/dist/application-BtZ8hmx9.mjs +1 -0
- package/dist/{application-BzO9ywXQ.mjs → application-m2G91kKI.mjs} +2 -2
- package/dist/application-m2G91kKI.mjs.map +1 -0
- package/dist/assert-WeXvmG4j.mjs.map +1 -1
- package/dist/authconnection-CynFBIv8.mjs.map +1 -1
- package/dist/brand-C8nMKhJC.mjs.map +1 -1
- package/dist/cli/lib.mjs +1 -1
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +33 -33
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/client.d.mts +17 -2
- package/dist/completion/zsh-worker.zsh +13 -7
- package/dist/configure/index.mjs.map +1 -1
- package/dist/context-D0QjfxzD.mjs.map +1 -1
- package/dist/crashreport-DFpRn-LS.mjs.map +1 -1
- package/dist/date-Dri6Yas-.mjs.map +1 -1
- package/dist/errors-CpvSChyL.mjs +7 -0
- package/dist/errors-CpvSChyL.mjs.map +1 -0
- package/dist/es-builtins-SfvXRVoG.mjs.map +1 -1
- package/dist/field-parse-DhnFs9WG.mjs.map +1 -1
- package/dist/file-DKBOj5q4.mjs.map +1 -1
- package/dist/globals-BCmGX05J.mjs.map +1 -1
- package/dist/guards-yDXyKC9F.mjs.map +1 -1
- package/dist/iconv-DlFMt2gW.mjs.map +1 -1
- package/dist/idp-G_ojPBB5.mjs.map +1 -1
- package/dist/interceptor-DQg3cR_9.mjs.map +1 -1
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/kysely-type-C-iyFFH7.mjs.map +1 -1
- package/dist/logger-DP2BjQ93.mjs.map +1 -1
- package/dist/logger-Db-YRTwK.mjs.map +1 -1
- package/dist/manager-8-JOvuLl.mjs.map +1 -1
- package/dist/multiline-EyzjEwn9.mjs.map +1 -1
- package/dist/node-builtins-DYfhPBnz.mjs.map +1 -1
- package/dist/package-json-C690ceex.mjs.map +1 -1
- package/dist/platform-serialize-DkiTdHOt.mjs.map +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/{register-ts-hook-z7ggXQy4.mjs → register-ts-hook-ztnEFW6n.mjs} +49 -49
- package/dist/register-ts-hook-ztnEFW6n.mjs.map +1 -0
- package/dist/registry-BijIDRVA.mjs.map +1 -1
- package/dist/repl-editor-DGJBfIt1.mjs.map +1 -1
- package/dist/schema-CRtAmDcl.mjs.map +1 -1
- package/dist/secret-file-C9wp_FCX.mjs.map +1 -1
- package/dist/secretmanager-5olfnI1b.mjs.map +1 -1
- package/dist/secretmanager-vHQoXdQz.mjs.map +1 -1
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-C3P_T_Eh.mjs.map +1 -1
- package/dist/service-CL1Bp4It.mjs.map +1 -1
- package/dist/{service-DHVuH7-X.mjs → service-DFmt9UJP.mjs} +2 -2
- package/dist/service-DFmt9UJP.mjs.map +1 -0
- package/dist/service_pb-ZClWtj1X.mjs +2 -0
- package/dist/service_pb-ZClWtj1X.mjs.map +1 -0
- package/dist/service_pb-dB3RrGeh.mjs +1 -0
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +83 -1
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +7 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +79 -7
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +40 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +119 -2
- package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +7 -0
- package/dist/tailordb-ddl-DqInYupv.mjs.map +1 -1
- package/dist/telemetry-Bklv9kQY.mjs.map +1 -1
- package/dist/type-source--ZNcV8RJ.mjs.map +1 -1
- package/dist/user-agent-vdHYF3QL.mjs.map +1 -1
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -1
- package/dist/wait-point-registry-B-ESkTZX.mjs.map +1 -1
- package/dist/workflow-Cs9ISw6j.mjs.map +1 -1
- package/dist/{workspace_resource_pb-D2njwgsE.mjs → workspace_resource_pb-CxR_6fyN.mjs} +2 -2
- package/dist/workspace_resource_pb-CxR_6fyN.mjs.map +1 -0
- package/docs/cli/application.md +23 -5
- package/docs/cli/function.md +2 -2
- package/package.json +3 -3
- package/dist/application-BE4vehXW.mjs +0 -1
- package/dist/application-BzO9ywXQ.mjs.map +0 -1
- package/dist/errors-C9zGf4nz.mjs +0 -7
- package/dist/errors-C9zGf4nz.mjs.map +0 -1
- package/dist/register-ts-hook-z7ggXQy4.mjs.map +0 -1
- package/dist/service-DHVuH7-X.mjs.map +0 -1
- package/dist/service_pb-DNskuJQC.mjs +0 -1
- package/dist/service_pb-y2GYIgfs.mjs +0 -2
- package/dist/service_pb-y2GYIgfs.mjs.map +0 -1
- package/dist/workspace_resource_pb-D2njwgsE.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Filter, PageDirection } from "./resource_pb.mjs";
|
|
2
2
|
import { AuthInvoker } from "./auth_resource_pb.mjs";
|
|
3
|
-
import { FunctionExecution } from "./function_resource_pb.mjs";
|
|
3
|
+
import { FunctionExecution, FunctionExecution_Status } from "./function_resource_pb.mjs";
|
|
4
4
|
import { GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
5
5
|
import { Message } from "@bufbuild/protobuf";
|
|
6
6
|
//#region ../tailor-proto/src/tailor/v1/function_pb.d.ts
|
|
@@ -25,6 +25,8 @@ export declare type TestExecScriptRequest = Message<"tailor.v1.TestExecScriptReq
|
|
|
25
25
|
*/
|
|
26
26
|
arg?: string;
|
|
27
27
|
/**
|
|
28
|
+
* Machine user the script runs as. Omit to run it as the anonymous dataplane identity.
|
|
29
|
+
*
|
|
28
30
|
* @generated from field: tailor.v1.AuthInvoker invoker = 5;
|
|
29
31
|
*/
|
|
30
32
|
invoker?: AuthInvoker;
|
|
@@ -73,6 +75,8 @@ export declare type ExecScriptRequest = Message<"tailor.v1.ExecScriptRequest"> &
|
|
|
73
75
|
*/
|
|
74
76
|
arg?: string;
|
|
75
77
|
/**
|
|
78
|
+
* Machine user the script runs as. Omit to run it as the anonymous dataplane identity.
|
|
79
|
+
*
|
|
76
80
|
* @generated from field: tailor.v1.AuthInvoker invoker = 5;
|
|
77
81
|
*/
|
|
78
82
|
invoker?: AuthInvoker;
|
|
@@ -132,6 +136,84 @@ export declare type GetFunctionExecutionResponse = Message<"tailor.v1.GetFunctio
|
|
|
132
136
|
* Use `create(GetFunctionExecutionResponseSchema)` to create a new message.
|
|
133
137
|
*/
|
|
134
138
|
export declare const GetFunctionExecutionResponseSchema: GenMessage<GetFunctionExecutionResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* @generated from message tailor.v1.StartJobFunctionRequest
|
|
141
|
+
*/
|
|
142
|
+
export declare type StartJobFunctionRequest = Message<"tailor.v1.StartJobFunctionRequest"> & {
|
|
143
|
+
/**
|
|
144
|
+
* @generated from field: string workspace_id = 1;
|
|
145
|
+
*/
|
|
146
|
+
workspaceId: string;
|
|
147
|
+
/**
|
|
148
|
+
* Name of a function in the function registry.
|
|
149
|
+
*
|
|
150
|
+
* @generated from field: string script_ref = 2;
|
|
151
|
+
*/
|
|
152
|
+
scriptRef: string;
|
|
153
|
+
/**
|
|
154
|
+
* @generated from field: optional string arg = 3;
|
|
155
|
+
*/
|
|
156
|
+
arg?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Machine user the job function runs as. Omit to run it as the anonymous dataplane identity.
|
|
159
|
+
*
|
|
160
|
+
* @generated from field: tailor.v1.AuthInvoker invoker = 4;
|
|
161
|
+
*/
|
|
162
|
+
invoker?: AuthInvoker;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Describes the message tailor.v1.StartJobFunctionRequest.
|
|
166
|
+
* Use `create(StartJobFunctionRequestSchema)` to create a new message.
|
|
167
|
+
*/
|
|
168
|
+
export declare const StartJobFunctionRequestSchema: GenMessage<StartJobFunctionRequest>;
|
|
169
|
+
/**
|
|
170
|
+
* @generated from message tailor.v1.StartJobFunctionResponse
|
|
171
|
+
*/
|
|
172
|
+
export declare type StartJobFunctionResponse = Message<"tailor.v1.StartJobFunctionResponse"> & {
|
|
173
|
+
/**
|
|
174
|
+
* @generated from field: string execution_id = 1;
|
|
175
|
+
*/
|
|
176
|
+
executionId: string;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Describes the message tailor.v1.StartJobFunctionResponse.
|
|
180
|
+
* Use `create(StartJobFunctionResponseSchema)` to create a new message.
|
|
181
|
+
*/
|
|
182
|
+
export declare const StartJobFunctionResponseSchema: GenMessage<StartJobFunctionResponse>;
|
|
183
|
+
/**
|
|
184
|
+
* @generated from message tailor.v1.CancelJobFunctionExecutionRequest
|
|
185
|
+
*/
|
|
186
|
+
export declare type CancelJobFunctionExecutionRequest = Message<"tailor.v1.CancelJobFunctionExecutionRequest"> & {
|
|
187
|
+
/**
|
|
188
|
+
* @generated from field: string workspace_id = 1;
|
|
189
|
+
*/
|
|
190
|
+
workspaceId: string;
|
|
191
|
+
/**
|
|
192
|
+
* @generated from field: string execution_id = 2;
|
|
193
|
+
*/
|
|
194
|
+
executionId: string;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Describes the message tailor.v1.CancelJobFunctionExecutionRequest.
|
|
198
|
+
* Use `create(CancelJobFunctionExecutionRequestSchema)` to create a new message.
|
|
199
|
+
*/
|
|
200
|
+
export declare const CancelJobFunctionExecutionRequestSchema: GenMessage<CancelJobFunctionExecutionRequest>;
|
|
201
|
+
/**
|
|
202
|
+
* @generated from message tailor.v1.CancelJobFunctionExecutionResponse
|
|
203
|
+
*/
|
|
204
|
+
export declare type CancelJobFunctionExecutionResponse = Message<"tailor.v1.CancelJobFunctionExecutionResponse"> & {
|
|
205
|
+
/**
|
|
206
|
+
* Status after the cancel request took effect (CANCELING or CANCELED).
|
|
207
|
+
*
|
|
208
|
+
* @generated from field: tailor.v1.FunctionExecution.Status status = 1;
|
|
209
|
+
*/
|
|
210
|
+
status: FunctionExecution_Status;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Describes the message tailor.v1.CancelJobFunctionExecutionResponse.
|
|
214
|
+
* Use `create(CancelJobFunctionExecutionResponseSchema)` to create a new message.
|
|
215
|
+
*/
|
|
216
|
+
export declare const CancelJobFunctionExecutionResponseSchema: GenMessage<CancelJobFunctionExecutionResponse>;
|
|
135
217
|
/**
|
|
136
218
|
* @generated from message tailor.v1.ListFunctionExecutionsRequest
|
|
137
219
|
*/
|
|
@@ -59,7 +59,11 @@ export declare type FunctionExecution = Message<"tailor.v1.FunctionExecution"> &
|
|
|
59
59
|
*/
|
|
60
60
|
status: FunctionExecution_Status;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Deprecated: use log_entries instead. Only populated in GetFunctionExecution,
|
|
63
|
+
* not in ListFunctionExecutions.
|
|
64
|
+
*
|
|
65
|
+
* @generated from field: string logs = 5 [deprecated = true];
|
|
66
|
+
* @deprecated
|
|
63
67
|
*/
|
|
64
68
|
logs: string;
|
|
65
69
|
/**
|
|
@@ -91,6 +95,8 @@ export declare type FunctionExecution = Message<"tailor.v1.FunctionExecution"> &
|
|
|
91
95
|
*/
|
|
92
96
|
contentHash: string;
|
|
93
97
|
/**
|
|
98
|
+
* Only populated in GetFunctionExecution, not in ListFunctionExecutions.
|
|
99
|
+
*
|
|
94
100
|
* @generated from field: repeated tailor.v1.FunctionLogEntry log_entries = 13;
|
|
95
101
|
*/
|
|
96
102
|
logEntries: FunctionLogEntry[];
|
|
@@ -8,12 +8,12 @@ import { CreateExecutorExecutorRequestSchema, CreateExecutorExecutorResponseSche
|
|
|
8
8
|
import { CreateSecretManagerSecretRequestSchema, CreateSecretManagerSecretResponseSchema, CreateSecretManagerVaultRequestSchema, CreateSecretManagerVaultResponseSchema, DeleteSecretManagerSecretRequestSchema, DeleteSecretManagerSecretResponseSchema, DeleteSecretManagerVaultRequestSchema, DeleteSecretManagerVaultResponseSchema, GetSecretManagerSecretRequestSchema, GetSecretManagerSecretResponseSchema, GetSecretManagerVaultRequestSchema, GetSecretManagerVaultResponseSchema, ListSecretManagerSecretsRequestSchema, ListSecretManagerSecretsResponseSchema, ListSecretManagerVaultsRequestSchema, ListSecretManagerVaultsResponseSchema, UpdateSecretManagerSecretRequestSchema, UpdateSecretManagerSecretResponseSchema } from "./secret_manager_pb.mjs";
|
|
9
9
|
import { CreateAuthConnectionRequestSchema, CreateAuthConnectionResponseSchema, CreateAuthHookRequestSchema, CreateAuthHookResponseSchema, CreateAuthIDPConfigRequestSchema, CreateAuthIDPConfigResponseSchema, CreateAuthMachineUserRequestSchema, CreateAuthMachineUserResponseSchema, CreateAuthOAuth2ClientRequestSchema, CreateAuthOAuth2ClientResponseSchema, CreateAuthSCIMConfigRequestSchema, CreateAuthSCIMConfigResponseSchema, CreateAuthSCIMResourceRequestSchema, CreateAuthSCIMResourceResponseSchema, CreateAuthServiceRequestSchema, CreateAuthServiceResponseSchema, CreateControlplaneMachineUserRequestSchema, CreateControlplaneMachineUserResponseSchema, CreatePersonalAccessTokenRequestSchema, CreatePersonalAccessTokenResponseSchema, CreateTenantConfigRequestSchema, CreateTenantConfigResponseSchema, CreateUserProfileConfigRequestSchema, CreateUserProfileConfigResponseSchema, DeleteAuthConnectionRequestSchema, DeleteAuthConnectionResponseSchema, DeleteAuthHookRequestSchema, DeleteAuthHookResponseSchema, DeleteAuthIDPConfigRequestSchema, DeleteAuthIDPConfigResponseSchema, DeleteAuthMachineUserRequestSchema, DeleteAuthMachineUserResponseSchema, DeleteAuthOAuth2ClientRequestSchema, DeleteAuthOAuth2ClientResponseSchema, DeleteAuthSCIMConfigRequestSchema, DeleteAuthSCIMConfigResponseSchema, DeleteAuthSCIMResourceRequestSchema, DeleteAuthSCIMResourceResponseSchema, DeleteAuthServiceRequestSchema, DeleteAuthServiceResponseSchema, DeleteControlplaneMachineUserRequestSchema, DeleteControlplaneMachineUserResponseSchema, DeletePersonalAccessTokenRequestSchema, DeletePersonalAccessTokenResponseSchema, DeleteTenantConfigRequestSchema, DeleteTenantConfigResponseSchema, DeleteUserProfileConfigRequestSchema, DeleteUserProfileConfigResponseSchema, ExchangeAuthConnectionAuthorizationCodeRequestSchema, ExchangeAuthConnectionAuthorizationCodeResponseSchema, GetAuthHookRequestSchema, GetAuthHookResponseSchema, GetAuthIDPConfigRequestSchema, GetAuthIDPConfigResponseSchema, GetAuthMachineUserRequestSchema, GetAuthMachineUserResponseSchema, GetAuthOAuth2ClientRequestSchema, GetAuthOAuth2ClientResponseSchema, GetAuthSCIMConfigRequestSchema, GetAuthSCIMConfigResponseSchema, GetAuthSCIMResourceRequestSchema, GetAuthSCIMResourceResponseSchema, GetAuthSCIMResourcesRequestSchema, GetAuthSCIMResourcesResponseSchema, GetAuthServiceRequestSchema, GetAuthServiceResponseSchema, GetControlplaneMachineUserByNameRequestSchema, GetControlplaneMachineUserByNameResponseSchema, GetControlplaneMachineUserRequestSchema, GetControlplaneMachineUserResponseSchema, GetTenantConfigRequestSchema, GetTenantConfigResponseSchema, GetUserProfileConfigRequestSchema, GetUserProfileConfigResponseSchema, ListAuthConnectionsRequestSchema, ListAuthConnectionsResponseSchema, ListAuthIDPConfigsRequestSchema, ListAuthIDPConfigsResponseSchema, ListAuthMachineUsersRequestSchema, ListAuthMachineUsersResponseSchema, ListAuthOAuth2ClientsRequestSchema, ListAuthOAuth2ClientsResponseSchema, ListAuthServicesRequestSchema, ListAuthServicesResponseSchema, ListControlplaneMachineUsersRequestSchema, ListControlplaneMachineUsersResponseSchema, ListPersonalAccessTokensRequestSchema, ListPersonalAccessTokensResponseSchema, RegisterAuthConnectionSessionRequestSchema, RegisterAuthConnectionSessionResponseSchema, RevokeAuthConnectionRequestSchema, RevokeAuthConnectionResponseSchema, UpdateAuthConnectionRequestSchema, UpdateAuthConnectionResponseSchema, UpdateAuthHookRequestSchema, UpdateAuthHookResponseSchema, UpdateAuthIDPConfigRequestSchema, UpdateAuthIDPConfigResponseSchema, UpdateAuthMachineUserRequestSchema, UpdateAuthMachineUserResponseSchema, UpdateAuthOAuth2ClientRequestSchema, UpdateAuthOAuth2ClientResponseSchema, UpdateAuthSCIMConfigRequestSchema, UpdateAuthSCIMConfigResponseSchema, UpdateAuthSCIMResourceRequestSchema, UpdateAuthSCIMResourceResponseSchema, UpdateAuthServiceRequestSchema, UpdateAuthServiceResponseSchema, UpdateControlplaneMachineUserRequestSchema, UpdateControlplaneMachineUserResponseSchema, UpdateTenantConfigRequestSchema, UpdateTenantConfigResponseSchema, UpdateUserProfileConfigRequestSchema, UpdateUserProfileConfigResponseSchema } from "./auth_pb.mjs";
|
|
10
10
|
import { ListControlplaneActivityLogsRequestSchema, ListControlplaneActivityLogsResponseSchema, ListDataplaneEventsRequestSchema, ListDataplaneEventsResponseSchema } from "./events_pb.mjs";
|
|
11
|
-
import { ExecScriptRequestSchema, ExecScriptResponseSchema, GetFunctionExecutionRequestSchema, GetFunctionExecutionResponseSchema, ListFunctionExecutionsRequestSchema, ListFunctionExecutionsResponseSchema, TestExecScriptRequestSchema, TestExecScriptResponseSchema } from "./function_pb.mjs";
|
|
11
|
+
import { CancelJobFunctionExecutionRequestSchema, CancelJobFunctionExecutionResponseSchema, ExecScriptRequestSchema, ExecScriptResponseSchema, GetFunctionExecutionRequestSchema, GetFunctionExecutionResponseSchema, ListFunctionExecutionsRequestSchema, ListFunctionExecutionsResponseSchema, StartJobFunctionRequestSchema, StartJobFunctionResponseSchema, TestExecScriptRequestSchema, TestExecScriptResponseSchema } from "./function_pb.mjs";
|
|
12
12
|
import { CreateFunctionRegistryRequestSchema, CreateFunctionRegistryResponseSchema, DeleteFunctionRegistryRequestSchema, DeleteFunctionRegistryResponseSchema, DownloadFunctionRegistryScriptRequestSchema, DownloadFunctionRegistryScriptResponseSchema, GetFunctionRegistryRequestSchema, GetFunctionRegistryResponseSchema, ListFunctionRegistriesRequestSchema, ListFunctionRegistriesResponseSchema, UpdateFunctionRegistryRequestSchema, UpdateFunctionRegistryResponseSchema } from "./function_registry_pb.mjs";
|
|
13
13
|
import { ListMeterAITokenUsagesRequestSchema, ListMeterAITokenUsagesResponseSchema, ListMeterEventCountsRequestSchema, ListMeterEventCountsResponseSchema, ListMeterExecutionCountsRequestSchema, ListMeterExecutionCountsResponseSchema, ListMeterRequestCountsRequestSchema, ListMeterRequestCountsResponseSchema } from "./meter_pb.mjs";
|
|
14
14
|
import { CreateIdPClientRequestSchema, CreateIdPClientResponseSchema, CreateIdPServiceRequestSchema, CreateIdPServiceResponseSchema, DeleteIdPClientRequestSchema, DeleteIdPClientResponseSchema, DeleteIdPServiceRequestSchema, DeleteIdPServiceResponseSchema, GetIdPClientRequestSchema, GetIdPClientResponseSchema, GetIdPServiceRequestSchema, GetIdPServiceResponseSchema, ListIdPClientsRequestSchema, ListIdPClientsResponseSchema, ListIdPServicesRequestSchema, ListIdPServicesResponseSchema, UpdateIdPServiceRequestSchema, UpdateIdPServiceResponseSchema } from "./idp_pb.mjs";
|
|
15
15
|
import { AddCustomDomainRequestSchema, AddCustomDomainResponseSchema, CreateDeploymentRequestSchema, CreateDeploymentResponseSchema, CreateStaticWebsiteRequestSchema, CreateStaticWebsiteResponseSchema, DeleteStaticWebsiteRequestSchema, DeleteStaticWebsiteResponseSchema, GetCustomDomainRequestSchema, GetCustomDomainResponseSchema, GetStaticWebsiteRequestSchema, GetStaticWebsiteResponseSchema, ListCustomDomainsRequestSchema, ListCustomDomainsResponseSchema, ListStaticWebsitesRequestSchema, ListStaticWebsitesResponseSchema, PublishDeploymentRequestSchema, PublishDeploymentResponseSchema, RemoveCustomDomainRequestSchema, RemoveCustomDomainResponseSchema, UpdateStaticWebsiteRequestSchema, UpdateStaticWebsiteResponseSchema, UploadFileRequestSchema, UploadFileResponseSchema } from "./staticwebsite_pb.mjs";
|
|
16
|
-
import { CreateWorkflowJobFunctionExecutionPolicyRequestSchema, CreateWorkflowJobFunctionExecutionPolicyResponseSchema, CreateWorkflowJobFunctionRequestSchema, CreateWorkflowJobFunctionResponseSchema, CreateWorkflowRequestSchema, CreateWorkflowResponseSchema, DeleteWorkflowJobFunctionExecutionPolicyRequestSchema, DeleteWorkflowJobFunctionExecutionPolicyResponseSchema, DeleteWorkflowJobFunctionRequestSchema, DeleteWorkflowJobFunctionResponseSchema, DeleteWorkflowRequestSchema, DeleteWorkflowResponseSchema, GetWorkflowByNameRequestSchema, GetWorkflowByNameResponseSchema, GetWorkflowExecutionRequestSchema, GetWorkflowExecutionResponseSchema, GetWorkflowJobFunctionByNameRequestSchema, GetWorkflowJobFunctionByNameResponseSchema, GetWorkflowJobFunctionExecutionPolicyByKeyRequestSchema, GetWorkflowJobFunctionExecutionPolicyByKeyResponseSchema, GetWorkflowJobFunctionExecutionPolicyRequestSchema, GetWorkflowJobFunctionExecutionPolicyResponseSchema, GetWorkflowJobFunctionRequestSchema, GetWorkflowJobFunctionResponseSchema, GetWorkflowRequestSchema, GetWorkflowResponseSchema, ListWorkflowExecutionsRequestSchema, ListWorkflowExecutionsResponseSchema, ListWorkflowJobFunctionExecutionPoliciesRequestSchema, ListWorkflowJobFunctionExecutionPoliciesResponseSchema, ListWorkflowJobFunctionsRequestSchema, ListWorkflowJobFunctionsResponseSchema, ListWorkflowsRequestSchema, ListWorkflowsResponseSchema, ResumeWorkflowExecutionRequestSchema, ResumeWorkflowExecutionResponseSchema, StartWorkflowRequestSchema, StartWorkflowResponseSchema, TestResumeWorkflowRequestSchema, TestResumeWorkflowResponseSchema, TestStartWorkflowRequestSchema, TestStartWorkflowResponseSchema, UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, UpdateWorkflowJobFunctionExecutionPolicyResponseSchema, UpdateWorkflowJobFunctionRequestSchema, UpdateWorkflowJobFunctionResponseSchema, UpdateWorkflowRequestSchema, UpdateWorkflowResponseSchema } from "./workflow_pb.mjs";
|
|
16
|
+
import { CancelWorkflowExecutionRequestSchema, CancelWorkflowExecutionResponseSchema, CreateWorkflowJobFunctionExecutionPolicyRequestSchema, CreateWorkflowJobFunctionExecutionPolicyResponseSchema, CreateWorkflowJobFunctionRequestSchema, CreateWorkflowJobFunctionResponseSchema, CreateWorkflowRequestSchema, CreateWorkflowResponseSchema, DeleteWorkflowJobFunctionExecutionPolicyRequestSchema, DeleteWorkflowJobFunctionExecutionPolicyResponseSchema, DeleteWorkflowJobFunctionRequestSchema, DeleteWorkflowJobFunctionResponseSchema, DeleteWorkflowRequestSchema, DeleteWorkflowResponseSchema, GetWorkflowByNameRequestSchema, GetWorkflowByNameResponseSchema, GetWorkflowExecutionRequestSchema, GetWorkflowExecutionResponseSchema, GetWorkflowJobFunctionByNameRequestSchema, GetWorkflowJobFunctionByNameResponseSchema, GetWorkflowJobFunctionExecutionPolicyByKeyRequestSchema, GetWorkflowJobFunctionExecutionPolicyByKeyResponseSchema, GetWorkflowJobFunctionExecutionPolicyRequestSchema, GetWorkflowJobFunctionExecutionPolicyResponseSchema, GetWorkflowJobFunctionRequestSchema, GetWorkflowJobFunctionResponseSchema, GetWorkflowRequestSchema, GetWorkflowResponseSchema, ListWorkflowExecutionsRequestSchema, ListWorkflowExecutionsResponseSchema, ListWorkflowJobFunctionExecutionPoliciesRequestSchema, ListWorkflowJobFunctionExecutionPoliciesResponseSchema, ListWorkflowJobFunctionsRequestSchema, ListWorkflowJobFunctionsResponseSchema, ListWorkflowsRequestSchema, ListWorkflowsResponseSchema, ResumeWorkflowExecutionRequestSchema, ResumeWorkflowExecutionResponseSchema, StartWorkflowRequestSchema, StartWorkflowResponseSchema, TestResumeWorkflowRequestSchema, TestResumeWorkflowResponseSchema, TestStartWorkflowRequestSchema, TestStartWorkflowResponseSchema, UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, UpdateWorkflowJobFunctionExecutionPolicyResponseSchema, UpdateWorkflowJobFunctionRequestSchema, UpdateWorkflowJobFunctionResponseSchema, UpdateWorkflowRequestSchema, UpdateWorkflowResponseSchema } from "./workflow_pb.mjs";
|
|
17
17
|
import { BulkSetMetadataRequestSchema, BulkSetMetadataResponseSchema, GetMetadataRequestSchema, GetMetadataResponseSchema, ListMetadataRequestSchema, ListMetadataResponseSchema, SetMetadataRequestSchema, SetMetadataResponseSchema } from "./metadata_pb.mjs";
|
|
18
18
|
import { CreateOTLPExporterRequestSchema, CreateOTLPExporterResponseSchema, CreateResourceAttributesConfigRequestSchema, CreateResourceAttributesConfigResponseSchema, DeleteOTLPExporterRequestSchema, DeleteOTLPExporterResponseSchema, DeleteResourceAttributesConfigRequestSchema, DeleteResourceAttributesConfigResponseSchema, GetOTLPExporterRequestSchema, GetOTLPExporterResponseSchema, GetResourceAttributesConfigRequestSchema, GetResourceAttributesConfigResponseSchema, ListOTLPExportersRequestSchema, ListOTLPExportersResponseSchema, TestOTLPExporterRequestSchema, TestOTLPExporterResponseSchema, UpdateOTLPExporterRequestSchema, UpdateOTLPExporterResponseSchema, UpdateResourceAttributesConfigRequestSchema, UpdateResourceAttributesConfigResponseSchema } from "./telemetryrouter_pb.mjs";
|
|
19
19
|
import { GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
|
|
@@ -244,12 +244,14 @@ export declare const OperatorService: GenService<{
|
|
|
244
244
|
output: typeof UpdateWorkspacePlatformUserResponseSchema;
|
|
245
245
|
};
|
|
246
246
|
/**
|
|
247
|
-
* GetWorkspacePlatformUser returns
|
|
247
|
+
* GetWorkspacePlatformUser returns the workspace platform user identified by
|
|
248
|
+
* email. GetWorkspaceRole returns the caller's own role instead.
|
|
248
249
|
*
|
|
249
250
|
* [Errors]
|
|
250
251
|
* - Unauthenticated: token is missing, expired, or invalid
|
|
251
252
|
* - InvalidArgument: request is invalid
|
|
252
|
-
* - NotFound: workspace does not exist or can not be accessed
|
|
253
|
+
* - NotFound: workspace does not exist or can not be accessed, no platform
|
|
254
|
+
* user has that email, or the user is not a platform user of the workspace
|
|
253
255
|
*
|
|
254
256
|
* @generated from rpc tailor.v1.OperatorService.GetWorkspacePlatformUser
|
|
255
257
|
*/
|
|
@@ -259,7 +261,7 @@ export declare const OperatorService: GenService<{
|
|
|
259
261
|
output: typeof GetWorkspacePlatformUserResponseSchema;
|
|
260
262
|
};
|
|
261
263
|
/**
|
|
262
|
-
* GetWorkspaceRole returns
|
|
264
|
+
* GetWorkspaceRole returns the caller's own workspace role.
|
|
263
265
|
*
|
|
264
266
|
* [Errors]
|
|
265
267
|
* - Unauthenticated: token is missing, expired, or invalid
|
|
@@ -927,14 +929,15 @@ export declare const OperatorService: GenService<{
|
|
|
927
929
|
};
|
|
928
930
|
/**
|
|
929
931
|
* CloneApplicationData clones data for an application from a source to a target.
|
|
930
|
-
* The RPC returns immediately and the clone runs asynchronously.
|
|
932
|
+
* The RPC returns immediately and the clone runs asynchronously. The target must be
|
|
933
|
+
* empty for every namespace and copy type in scope; a non-empty target is rejected.
|
|
931
934
|
*
|
|
932
935
|
* [Errors]
|
|
933
936
|
* - Unauthenticated: token is missing, expired, or invalid
|
|
934
937
|
* - Unimplemented: feature flag is disabled
|
|
935
938
|
* - InvalidArgument: request is invalid
|
|
936
939
|
* - NotFound: workspace or application does not exist or cannot be accessed
|
|
937
|
-
* - FailedPrecondition: cross-region clone or
|
|
940
|
+
* - FailedPrecondition: cross-region clone, namespace mismatch, or target is not empty
|
|
938
941
|
*
|
|
939
942
|
* @generated from rpc tailor.v1.OperatorService.CloneApplicationData
|
|
940
943
|
*/
|
|
@@ -1149,6 +1152,10 @@ export declare const OperatorService: GenService<{
|
|
|
1149
1152
|
* - Unauthenticated: token is missing, expired, or invalid
|
|
1150
1153
|
* - InvalidArgument: request is invalid
|
|
1151
1154
|
* - NotFound: TailorDB type does not exist or can not be accessed
|
|
1155
|
+
* - FailedPrecondition: a field cannot be changed from optional to required while
|
|
1156
|
+
* existing records contain null values for it. The error carries a
|
|
1157
|
+
* google.rpc.PreconditionFailure detail with violation type
|
|
1158
|
+
* "REQUIRED_FIELD_HAS_NULL_VALUES" and the field name as subject.
|
|
1152
1159
|
*
|
|
1153
1160
|
* @generated from rpc tailor.v1.OperatorService.UpdateTailorDBType
|
|
1154
1161
|
*/
|
|
@@ -2504,6 +2511,12 @@ export declare const OperatorService: GenService<{
|
|
|
2504
2511
|
/**
|
|
2505
2512
|
* Function ---------------------------------------------------------
|
|
2506
2513
|
* ExecScript executes specified JavaScript code in which I/O operations are allowed and returns the result.
|
|
2514
|
+
* Omitting invoker runs the script as the anonymous dataplane identity.
|
|
2515
|
+
*
|
|
2516
|
+
* [Errors]
|
|
2517
|
+
* - Unauthenticated: token is missing, expired, or invalid
|
|
2518
|
+
* - InvalidArgument: request is invalid, or invoker names only one of namespace / machine_user_name
|
|
2519
|
+
* - NotFound: workspace does not exist or can not be accessed
|
|
2507
2520
|
*
|
|
2508
2521
|
* @generated from rpc tailor.v1.OperatorService.ExecScript
|
|
2509
2522
|
*/
|
|
@@ -2535,6 +2548,43 @@ export declare const OperatorService: GenService<{
|
|
|
2535
2548
|
input: typeof GetFunctionExecutionRequestSchema;
|
|
2536
2549
|
output: typeof GetFunctionExecutionResponseSchema;
|
|
2537
2550
|
};
|
|
2551
|
+
/**
|
|
2552
|
+
* StartJobFunction runs a function from the Function Registry as an
|
|
2553
|
+
* asynchronous job and returns its execution id without waiting for the run
|
|
2554
|
+
* to finish. It is the asynchronous counterpart of ExecScript, but takes a
|
|
2555
|
+
* script_ref instead of inline code. The returned execution_id can be passed
|
|
2556
|
+
* to GetFunctionExecution and CancelJobFunctionExecution.
|
|
2557
|
+
*
|
|
2558
|
+
* [Errors]
|
|
2559
|
+
* - Unauthenticated: token is missing, expired, or invalid
|
|
2560
|
+
* - InvalidArgument: request is invalid
|
|
2561
|
+
* - PermissionDenied: can view workspace but no permission to start a job function
|
|
2562
|
+
* - NotFound: workspace or script_ref does not exist or can not be accessed
|
|
2563
|
+
*
|
|
2564
|
+
* @generated from rpc tailor.v1.OperatorService.StartJobFunction
|
|
2565
|
+
*/
|
|
2566
|
+
startJobFunction: {
|
|
2567
|
+
methodKind: "unary";
|
|
2568
|
+
input: typeof StartJobFunctionRequestSchema;
|
|
2569
|
+
output: typeof StartJobFunctionResponseSchema;
|
|
2570
|
+
};
|
|
2571
|
+
/**
|
|
2572
|
+
* CancelJobFunctionExecution cancels an in-flight job function execution by
|
|
2573
|
+
* execution_id, regardless of how it was started (workflow, executor, or
|
|
2574
|
+
* directly). RUNNING transitions to CANCELING and is finalized to CANCELED
|
|
2575
|
+
* by reconciliation. SUSPEND transitions directly to CANCELED. Canceling an
|
|
2576
|
+
* already CANCELING/CANCELED execution succeeds (idempotent).
|
|
2577
|
+
* SUCCESS/FAILED returns FailedPrecondition, as does a standard (synchronous)
|
|
2578
|
+
* function execution, which is not cancelable. An unknown execution_id
|
|
2579
|
+
* returns NotFound.
|
|
2580
|
+
*
|
|
2581
|
+
* @generated from rpc tailor.v1.OperatorService.CancelJobFunctionExecution
|
|
2582
|
+
*/
|
|
2583
|
+
cancelJobFunctionExecution: {
|
|
2584
|
+
methodKind: "unary";
|
|
2585
|
+
input: typeof CancelJobFunctionExecutionRequestSchema;
|
|
2586
|
+
output: typeof CancelJobFunctionExecutionResponseSchema;
|
|
2587
|
+
};
|
|
2538
2588
|
/**
|
|
2539
2589
|
* ListFunctionExecutions lists function executions.
|
|
2540
2590
|
*
|
|
@@ -3214,6 +3264,7 @@ export declare const OperatorService: GenService<{
|
|
|
3214
3264
|
};
|
|
3215
3265
|
/**
|
|
3216
3266
|
* StartWorkflow starts a workflow execution.
|
|
3267
|
+
* Omitting auth_invoker runs the execution as the anonymous dataplane identity.
|
|
3217
3268
|
*
|
|
3218
3269
|
* [Errors]
|
|
3219
3270
|
* - Unauthenticated: token is missing, expired, or invalid
|
|
@@ -3243,6 +3294,27 @@ export declare const OperatorService: GenService<{
|
|
|
3243
3294
|
input: typeof ResumeWorkflowExecutionRequestSchema;
|
|
3244
3295
|
output: typeof ResumeWorkflowExecutionResponseSchema;
|
|
3245
3296
|
};
|
|
3297
|
+
/**
|
|
3298
|
+
* CancelWorkflowExecution cancels an in-flight workflow execution by
|
|
3299
|
+
* execution_id. The execution and every job function execution still in
|
|
3300
|
+
* flight under it are CANCELED together before the RPC returns; only the
|
|
3301
|
+
* teardown of the job functions' compute happens asynchronously afterwards.
|
|
3302
|
+
* CANCELED is terminal and, unlike FAILED, not resumable. Canceling an
|
|
3303
|
+
* already CANCELED execution succeeds (idempotent).
|
|
3304
|
+
*
|
|
3305
|
+
* [Errors]
|
|
3306
|
+
* - Unauthenticated: token is missing, expired, or invalid
|
|
3307
|
+
* - InvalidArgument: request is invalid
|
|
3308
|
+
* - NotFound: execution does not exist or can not be accessed
|
|
3309
|
+
* - FailedPrecondition: execution already reached SUCCESS or FAILED
|
|
3310
|
+
*
|
|
3311
|
+
* @generated from rpc tailor.v1.OperatorService.CancelWorkflowExecution
|
|
3312
|
+
*/
|
|
3313
|
+
cancelWorkflowExecution: {
|
|
3314
|
+
methodKind: "unary";
|
|
3315
|
+
input: typeof CancelWorkflowExecutionRequestSchema;
|
|
3316
|
+
output: typeof CancelWorkflowExecutionResponseSchema;
|
|
3317
|
+
};
|
|
3246
3318
|
/**
|
|
3247
3319
|
* TestStartWorkflow is the deprecated legacy alias of StartWorkflow, kept so tailorctl / Console callers can migrate on their own cadence.
|
|
3248
3320
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Filter, PageDirection } from "./resource_pb.mjs";
|
|
2
2
|
import { AuthInvoker } from "./auth_resource_pb.mjs";
|
|
3
|
-
import { ConcurrencyPolicy, RetryPolicy, Workflow, WorkflowExecution, WorkflowJobFunction, WorkflowJobFunctionExecutionPolicy, WorkflowJobFunctionSummary } from "./workflow_resource_pb.mjs";
|
|
3
|
+
import { ConcurrencyPolicy, RetryPolicy, Workflow, WorkflowExecution, WorkflowExecution_Status, WorkflowJobFunction, WorkflowJobFunctionExecutionPolicy, WorkflowJobFunctionSummary } from "./workflow_resource_pb.mjs";
|
|
4
4
|
import { GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
5
5
|
import { Message } from "@bufbuild/protobuf";
|
|
6
6
|
//#region ../tailor-proto/src/tailor/v1/workflow_pb.d.ts
|
|
@@ -611,6 +611,8 @@ export declare type TestStartWorkflowRequest = Message<"tailor.v1.TestStartWorkf
|
|
|
611
611
|
*/
|
|
612
612
|
workflowId: string;
|
|
613
613
|
/**
|
|
614
|
+
* Machine user the execution runs as. Omit to run it as the anonymous dataplane identity.
|
|
615
|
+
*
|
|
614
616
|
* @generated from field: tailor.v1.AuthInvoker auth_invoker = 3;
|
|
615
617
|
*/
|
|
616
618
|
authInvoker?: AuthInvoker;
|
|
@@ -683,6 +685,8 @@ export declare type StartWorkflowRequest = Message<"tailor.v1.StartWorkflowReque
|
|
|
683
685
|
*/
|
|
684
686
|
workflowId: string;
|
|
685
687
|
/**
|
|
688
|
+
* Machine user the execution runs as. Omit to run it as the anonymous dataplane identity.
|
|
689
|
+
*
|
|
686
690
|
* @generated from field: tailor.v1.AuthInvoker auth_invoker = 3;
|
|
687
691
|
*/
|
|
688
692
|
authInvoker?: AuthInvoker;
|
|
@@ -742,6 +746,41 @@ export declare type ResumeWorkflowExecutionResponse = Message<"tailor.v1.ResumeW
|
|
|
742
746
|
* Use `create(ResumeWorkflowExecutionResponseSchema)` to create a new message.
|
|
743
747
|
*/
|
|
744
748
|
export declare const ResumeWorkflowExecutionResponseSchema: GenMessage<ResumeWorkflowExecutionResponse>;
|
|
749
|
+
/**
|
|
750
|
+
* @generated from message tailor.v1.CancelWorkflowExecutionRequest
|
|
751
|
+
*/
|
|
752
|
+
export declare type CancelWorkflowExecutionRequest = Message<"tailor.v1.CancelWorkflowExecutionRequest"> & {
|
|
753
|
+
/**
|
|
754
|
+
* @generated from field: string workspace_id = 1;
|
|
755
|
+
*/
|
|
756
|
+
workspaceId: string;
|
|
757
|
+
/**
|
|
758
|
+
* @generated from field: string execution_id = 2;
|
|
759
|
+
*/
|
|
760
|
+
executionId: string;
|
|
761
|
+
};
|
|
762
|
+
/**
|
|
763
|
+
* Describes the message tailor.v1.CancelWorkflowExecutionRequest.
|
|
764
|
+
* Use `create(CancelWorkflowExecutionRequestSchema)` to create a new message.
|
|
765
|
+
*/
|
|
766
|
+
export declare const CancelWorkflowExecutionRequestSchema: GenMessage<CancelWorkflowExecutionRequest>;
|
|
767
|
+
/**
|
|
768
|
+
* @generated from message tailor.v1.CancelWorkflowExecutionResponse
|
|
769
|
+
*/
|
|
770
|
+
export declare type CancelWorkflowExecutionResponse = Message<"tailor.v1.CancelWorkflowExecutionResponse"> & {
|
|
771
|
+
/**
|
|
772
|
+
* Status after the cancel took effect. Always STATUS_CANCELED; carried so
|
|
773
|
+
* the caller does not need a follow-up GetWorkflowExecution.
|
|
774
|
+
*
|
|
775
|
+
* @generated from field: tailor.v1.WorkflowExecution.Status status = 1;
|
|
776
|
+
*/
|
|
777
|
+
status: WorkflowExecution_Status;
|
|
778
|
+
};
|
|
779
|
+
/**
|
|
780
|
+
* Describes the message tailor.v1.CancelWorkflowExecutionResponse.
|
|
781
|
+
* Use `create(CancelWorkflowExecutionResponseSchema)` to create a new message.
|
|
782
|
+
*/
|
|
783
|
+
export declare const CancelWorkflowExecutionResponseSchema: GenMessage<CancelWorkflowExecutionResponse>;
|
|
745
784
|
/**
|
|
746
785
|
* @generated from message tailor.v1.CreateWorkflowJobFunctionExecutionPolicyRequest
|
|
747
786
|
*/
|
|
@@ -209,6 +209,10 @@ export declare type WorkflowJobExecution = Message<"tailor.v1.WorkflowJobExecuti
|
|
|
209
209
|
*/
|
|
210
210
|
status: WorkflowJobExecution_Status;
|
|
211
211
|
/**
|
|
212
|
+
* The function service execution behind this job. Meaningful only when kind
|
|
213
|
+
* is job_function; a wait checkpoint runs no function and carries the nil
|
|
214
|
+
* UUID here.
|
|
215
|
+
*
|
|
212
216
|
* execution_id in Function Execution
|
|
213
217
|
*
|
|
214
218
|
* @generated from field: string execution_id = 4;
|
|
@@ -222,6 +226,101 @@ export declare type WorkflowJobExecution = Message<"tailor.v1.WorkflowJobExecuti
|
|
|
222
226
|
* @generated from field: google.protobuf.Timestamp finished_at = 6;
|
|
223
227
|
*/
|
|
224
228
|
finishedAt?: Timestamp;
|
|
229
|
+
/**
|
|
230
|
+
* Where this job sits in the run's execution tree.
|
|
231
|
+
*
|
|
232
|
+
* @generated from field: tailor.v1.WorkflowJobExecution.Position position = 7;
|
|
233
|
+
*/
|
|
234
|
+
position?: WorkflowJobExecution_Position;
|
|
235
|
+
/**
|
|
236
|
+
* What kind of job this row is. wait() occupies a call_index in its parent's
|
|
237
|
+
* script and returns a value, exactly like a triggered job function, so it is
|
|
238
|
+
* one of these jobs rather than a separate concept. A reader that does not
|
|
239
|
+
* recognize the variant must still place the job using position.
|
|
240
|
+
*
|
|
241
|
+
* @generated from oneof tailor.v1.WorkflowJobExecution.kind
|
|
242
|
+
*/
|
|
243
|
+
kind: {
|
|
244
|
+
/**
|
|
245
|
+
* @generated from field: tailor.v1.WorkflowJobExecution.JobFunctionCall job_function = 8;
|
|
246
|
+
*/
|
|
247
|
+
value: WorkflowJobExecution_JobFunctionCall;
|
|
248
|
+
case: "jobFunction";
|
|
249
|
+
} | {
|
|
250
|
+
/**
|
|
251
|
+
* @generated from field: tailor.v1.WorkflowJobExecution.WaitCheckpoint wait = 9;
|
|
252
|
+
*/
|
|
253
|
+
value: WorkflowJobExecution_WaitCheckpoint;
|
|
254
|
+
case: "wait";
|
|
255
|
+
} | {
|
|
256
|
+
case: undefined;
|
|
257
|
+
value?: undefined;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Position of a job within its run's execution tree. Siblings are ordered
|
|
262
|
+
* by (call_index, branch_index); started_at is not an ordering, because the
|
|
263
|
+
* branches of one parallel group start together.
|
|
264
|
+
*
|
|
265
|
+
* @generated from message tailor.v1.WorkflowJobExecution.Position
|
|
266
|
+
*/
|
|
267
|
+
export declare type WorkflowJobExecution_Position = Message<"tailor.v1.WorkflowJobExecution.Position"> & {
|
|
268
|
+
/**
|
|
269
|
+
* The parent job execution's id (field 1 of this message), not its
|
|
270
|
+
* execution_id. Empty on the main job function, which has no caller, and
|
|
271
|
+
* on jobs recorded before this field existed. Otherwise set, but not
|
|
272
|
+
* always resolvable: job executions are deleted by age and nothing
|
|
273
|
+
* clears the references to them, so a parent can be gone while its
|
|
274
|
+
* children still name it.
|
|
275
|
+
*
|
|
276
|
+
* @generated from field: string parent_workflow_job_execution_id = 1;
|
|
277
|
+
*/
|
|
278
|
+
parentWorkflowJobExecutionId: string;
|
|
279
|
+
/**
|
|
280
|
+
* Zero-based order of the call within the parent's script. Unset on the
|
|
281
|
+
* main job function, and on jobs recorded before this field existed.
|
|
282
|
+
*
|
|
283
|
+
* @generated from field: optional int32 call_index = 2;
|
|
284
|
+
*/
|
|
285
|
+
callIndex?: number;
|
|
286
|
+
/**
|
|
287
|
+
* Zero-based branch within a parallelJobFunctions.all() group sharing one
|
|
288
|
+
* call_index. Unset when the call did not fan out.
|
|
289
|
+
*
|
|
290
|
+
* @generated from field: optional int32 branch_index = 3;
|
|
291
|
+
*/
|
|
292
|
+
branchIndex?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Distance from the main job function, which is 0. Redundant with walking
|
|
295
|
+
* the parent links, and carried so a reader can still indent a job whose
|
|
296
|
+
* parent is outside the set it holds.
|
|
297
|
+
*
|
|
298
|
+
* @generated from field: int32 depth = 4;
|
|
299
|
+
*/
|
|
300
|
+
depth: number;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* @generated from message tailor.v1.WorkflowJobExecution.JobFunctionCall
|
|
304
|
+
*/
|
|
305
|
+
export declare type WorkflowJobExecution_JobFunctionCall = Message<"tailor.v1.WorkflowJobExecution.JobFunctionCall"> & {
|
|
306
|
+
/**
|
|
307
|
+
* Matches WorkflowJobFunction.name.
|
|
308
|
+
*
|
|
309
|
+
* @generated from field: string name = 1;
|
|
310
|
+
*/
|
|
311
|
+
name: string;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* @generated from message tailor.v1.WorkflowJobExecution.WaitCheckpoint
|
|
315
|
+
*/
|
|
316
|
+
export declare type WorkflowJobExecution_WaitCheckpoint = Message<"tailor.v1.WorkflowJobExecution.WaitCheckpoint"> & {
|
|
317
|
+
/**
|
|
318
|
+
* The key passed to tailor.workflow.wait(), as accepted by
|
|
319
|
+
* ResolveWaitingExecution. The payload stays on the wait / resolve APIs.
|
|
320
|
+
*
|
|
321
|
+
* @generated from field: string key = 1;
|
|
322
|
+
*/
|
|
323
|
+
key: string;
|
|
225
324
|
};
|
|
226
325
|
/**
|
|
227
326
|
* @generated from enum tailor.v1.WorkflowJobExecution.Status
|
|
@@ -250,7 +349,16 @@ export declare enum WorkflowJobExecution_Status {
|
|
|
250
349
|
/**
|
|
251
350
|
* @generated from enum value: STATUS_WAITING = 5;
|
|
252
351
|
*/
|
|
253
|
-
WAITING = 5
|
|
352
|
+
WAITING = 5,
|
|
353
|
+
/**
|
|
354
|
+
* Terminal state. The execution was canceled, either directly via
|
|
355
|
+
* CancelJobFunctionExecution or as a descendant of an ancestor that was
|
|
356
|
+
* canceled. Never retried automatically. Must stay integer-aligned with
|
|
357
|
+
* the controlplane enum (the operator transform casts directly).
|
|
358
|
+
*
|
|
359
|
+
* @generated from enum value: STATUS_CANCELED = 6;
|
|
360
|
+
*/
|
|
361
|
+
CANCELED = 6
|
|
254
362
|
}
|
|
255
363
|
/**
|
|
256
364
|
* @generated from message tailor.v1.WorkflowExecution
|
|
@@ -324,6 +432,15 @@ export declare enum WorkflowExecution_Status {
|
|
|
324
432
|
/**
|
|
325
433
|
* @generated from enum value: STATUS_WAITING = 7;
|
|
326
434
|
*/
|
|
327
|
-
WAITING = 7
|
|
435
|
+
WAITING = 7,
|
|
436
|
+
/**
|
|
437
|
+
* Terminal state. The execution was canceled via
|
|
438
|
+
* CancelWorkflowExecution. Never retried automatically and not resumable.
|
|
439
|
+
* Must stay integer-aligned with the controlplane enum (the operator
|
|
440
|
+
* transform casts directly).
|
|
441
|
+
*
|
|
442
|
+
* @generated from enum value: STATUS_CANCELED = 8;
|
|
443
|
+
*/
|
|
444
|
+
CANCELED = 8
|
|
328
445
|
}
|
|
329
446
|
//#endregion
|
|
@@ -478,6 +478,13 @@ export declare type GetWorkspacePlatformUserRequest = Message<"tailor.v1.GetWork
|
|
|
478
478
|
* @generated from field: string workspace_id = 1;
|
|
479
479
|
*/
|
|
480
480
|
workspaceId: string;
|
|
481
|
+
/**
|
|
482
|
+
* email identifies the member to read. Use GetWorkspaceRole to read the
|
|
483
|
+
* caller's own role.
|
|
484
|
+
*
|
|
485
|
+
* @generated from field: string email = 2;
|
|
486
|
+
*/
|
|
487
|
+
email: string;
|
|
481
488
|
};
|
|
482
489
|
/**
|
|
483
490
|
* Describes the message tailor.v1.GetWorkspacePlatformUserRequest.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailordb-ddl-DqInYupv.mjs","names":[],"sources":["../src/utils/field-column-type.ts","../src/utils/tailordb-ddl.ts"],"sourcesContent":["/** The Kysely column type a TailorDB field maps to, before array/null modifiers. */\nexport type FieldColumnType = \"string\" | \"number\" | \"boolean\" | \"Timestamp\";\n\n/**\n * Map a scalar TailorDB field type to the column type generated code uses for it.\n *\n * `date` resolves to `Timestamp` because the function runtime hands back a\n * `Date` for a date column, same as for datetime.\n *\n * `enum` and `nested` carry their own shape, so each generator resolves them\n * before reaching here; passing either is a caller bug rather than a `string`\n * column.\n * @param fieldType - TailorDB scalar field type name\n * @returns The column type for the field, defaulting to `string`\n * @throws If given `enum` or `nested`\n */\nexport function mapFieldTypeToColumnType(fieldType: string): FieldColumnType {\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n return \"string\";\n case \"integer\":\n case \"float\":\n return \"number\";\n case \"date\":\n case \"datetime\":\n return \"Timestamp\";\n case \"bool\":\n case \"boolean\":\n return \"boolean\";\n case \"enum\":\n case \"nested\":\n throw new Error(\n `Field type \"${fieldType}\" has no scalar column type; resolve it before mapping.`,\n );\n default:\n return \"string\";\n }\n}\n\n/** The select and write types a `ColumnType`-shaped alias expands to. */\nexport type ColumnTypeAliasExpansion = {\n /** Type the alias reads back as. */\n readonly select: string;\n /** Type the alias accepts on insert and update. */\n readonly write: string;\n};\n\n/**\n * Column types whose alias expands to a `ColumnType`, mapped to that expansion.\n *\n * Kysely only unwraps a `ColumnType` at the top level of a table property, so an\n * array of one of these stays wrapped in `ArrayColumnType<...>` rather than taking\n * a `[]` suffix, which would nest the `ColumnType` out of Kysely's reach. Where a\n * generator has to spell out the slots itself, it reads the expansion from here\n * rather than inlining the alias, which would nest just the same.\n *\n * Both type generators track alias usage per alias to decide which declarations to\n * emit, so adding an entry here also means teaching them to report the new alias.\n */\nexport const COLUMN_TYPE_ALIASES: ReadonlyMap<string, ColumnTypeAliasExpansion> = new Map<\n FieldColumnType,\n ColumnTypeAliasExpansion\n>([[\"Timestamp\", { select: \"Date\", write: \"Date | string\" }]]);\n","/**\n * PostgreSQL DDL derived from TailorDB table definitions, for creating the\n * tables a PGlite-backed test needs. The columns match the flat shape the\n * Kysely type generators emit, not TailorDB's storage layout.\n */\n\n/** The field shape the DDL generator reads; parsed and snapshot field configs are both assignable. */\nexport interface DDLFieldConfig {\n type: string;\n required?: boolean;\n array?: boolean;\n unique?: boolean;\n serial?: { start: number; maxValue?: number; format?: string };\n scale?: number;\n default?: unknown;\n optionalOnCreate?: boolean;\n hooks?: { create?: unknown; update?: unknown };\n fields?: Record<string, DDLFieldConfig>;\n}\n\n/** A table to emit DDL for. */\nexport interface DDLTableConfig {\n name: string;\n fields: Record<string, DDLFieldConfig>;\n indexes?: Record<string, { fields: string[]; unique?: boolean }>;\n}\n\nconst MAX_IDENTIFIER_BYTES = 63;\n// The platform rounds decimals to their scale (6 unless configured); numeric\n// needs a precision to carry a scale, and the maximum leaves it unconstrained.\nconst DECIMAL_PRECISION = 1000;\nconst DEFAULT_DECIMAL_SCALE = 6;\nconst utf8 = new TextEncoder();\n\n/**\n * Map a TailorDB field type to the PostgreSQL column type PGlite tests use for it.\n * @param fieldType - TailorDB field type name\n * @returns The PostgreSQL type name\n * @throws If the type is not a TailorDB field type\n */\nexport function mapFieldTypeToPostgresType(fieldType: string): string {\n switch (fieldType) {\n case \"uuid\":\n return \"uuid\";\n case \"string\":\n case \"enum\":\n return \"text\";\n case \"boolean\":\n case \"bool\":\n return \"boolean\";\n case \"integer\":\n return \"integer\";\n case \"float\":\n return \"double precision\";\n case \"decimal\":\n return \"numeric\";\n case \"date\":\n return \"date\";\n case \"datetime\":\n return \"timestamptz\";\n case \"time\":\n return \"time\";\n case \"nested\":\n return \"jsonb\";\n default:\n throw new Error(`Field type \"${fieldType}\" has no PostgreSQL column type.`);\n }\n}\n\nfunction identifier(name: string): string {\n return `\"${name.replaceAll('\"', '\"\"')}\"`;\n}\n\nfunction fnv1aHex(value: string): string {\n let hash = 0x811c9dc5;\n for (const byte of utf8.encode(value)) {\n hash = Math.imul(hash ^ byte, 0x01000193) >>> 0;\n }\n return hash.toString(16).padStart(8, \"0\");\n}\n\nfunction derivedIdentifier(tableName: string, memberName: string, kind: \"seq\" | \"idx\"): string {\n const suffix = `_${fnv1aHex(JSON.stringify([tableName, memberName, kind]))}_${kind}`;\n let head = `${tableName}_${memberName}`;\n while (utf8.encode(head + suffix).length > MAX_IDENTIFIER_BYTES) head = head.slice(0, -1);\n return identifier(head + suffix);\n}\n\nfunction stringLiteral(value: string): string {\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n\nfunction columnType(field: DDLFieldConfig): string {\n const base =\n field.type === \"decimal\"\n ? `numeric(${DECIMAL_PRECISION}, ${field.scale ?? DEFAULT_DECIMAL_SCALE})`\n : mapFieldTypeToPostgresType(field.type);\n return field.array && field.type !== \"nested\" ? `${base}[]` : base;\n}\n\nfunction scalarLiteral(value: unknown, field: DDLFieldConfig, label: string): string {\n const pgType = mapFieldTypeToPostgresType(field.type);\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) {\n throw new Error(`Default of field ${label} is an invalid Date.`);\n }\n return `${stringLiteral(value.toISOString())}::${pgType}`;\n }\n switch (typeof value) {\n case \"string\":\n return pgType === \"text\" ? stringLiteral(value) : `${stringLiteral(value)}::${pgType}`;\n case \"number\":\n if (!Number.isFinite(value)) {\n throw new Error(`Default of field ${label} is not a finite number.`);\n }\n return String(value);\n case \"boolean\":\n return value ? \"TRUE\" : \"FALSE\";\n default:\n throw new Error(`Default of field ${label} cannot be rendered as a SQL literal.`);\n }\n}\n\nconst CURRENT_TIME_EXPRESSIONS = new Map([\n [\"datetime\", \"now()\"],\n [\"date\", \"CURRENT_DATE\"],\n [\"time\", \"LOCALTIME\"],\n]);\n\nfunction defaultExpression(field: DDLFieldConfig, label: string): string {\n const value = field.default;\n const currentTime = CURRENT_TIME_EXPRESSIONS.get(field.type);\n if (value === \"now\" && currentTime !== undefined) {\n return currentTime;\n }\n if (field.array) {\n if (!Array.isArray(value)) {\n throw new Error(`Default of array field ${label} must be an array.`);\n }\n const pgType = columnType(field);\n if (value.length === 0) return `'{}'::${pgType}`;\n return `ARRAY[${value.map((v) => scalarLiteral(v, field, label)).join(\", \")}]::${pgType}`;\n }\n return scalarLiteral(value, field, label);\n}\n\ninterface SerialFormat {\n prefix: string;\n width: number;\n zeroPad: boolean;\n conversion: \"d\" | \"x\" | \"X\";\n suffix: string;\n}\n\n// printf-style with exactly one conversion specifier; octal has no Postgres\n// formatting function to stand in for it.\nfunction parseSerialFormat(format: string, label: string): SerialFormat {\n const match =\n /^(?<prefix>[^%]*)%(?<zero>0?)(?<width>\\d*)(?<conversion>[a-zA-Z])(?<suffix>[^%]*)$/.exec(\n format,\n );\n const groups = match?.groups;\n const conversion = groups?.conversion;\n if (!groups || (conversion !== \"d\" && conversion !== \"x\" && conversion !== \"X\")) {\n throw new Error(\n `Serial format \"${format}\" of field ${label} is not supported; use a single %d, %x, or %X specifier with an optional width (e.g. \"INV-%05d\").`,\n );\n }\n return {\n prefix: groups.prefix ?? \"\",\n zeroPad: groups.zero === \"0\",\n width: groups.width ? Number(groups.width) : 0,\n conversion,\n suffix: groups.suffix ?? \"\",\n };\n}\n\nfunction sequenceName(tableName: string, fieldName: string): string {\n return derivedIdentifier(tableName, fieldName, \"seq\");\n}\n\n// A sequence's minimum defaults to 1, which rejects a start of 0.\nfunction sequenceRange(serial: NonNullable<DDLFieldConfig[\"serial\"]>): string {\n const range = [`START WITH ${serial.start}`, `MINVALUE ${serial.start}`];\n if (serial.maxValue !== undefined) range.push(`MAXVALUE ${serial.maxValue}`);\n return range.join(\" \");\n}\n\nconst SERIAL_CONVERSIONS: Record<SerialFormat[\"conversion\"], (nextval: string) => string> = {\n d: (nextval) => nextval,\n x: (nextval) => `to_hex(${nextval})`,\n X: (nextval) => `upper(to_hex(${nextval}))`,\n};\n\nfunction serialStringDefault(sequence: string, format: string | undefined, label: string): string {\n const nextval = `nextval(${stringLiteral(sequence)})`;\n if (format === undefined) return `(${nextval}::text)`;\n const { prefix, width, zeroPad, conversion, suffix } = parseSerialFormat(format, label);\n const number = SERIAL_CONVERSIONS[conversion](nextval);\n let value = conversion === \"d\" ? `${number}::text` : number;\n if (width > 0) {\n value = `format('%${width}s', ${number})`;\n if (zeroPad) value = `translate(${value}, ' ', '0')`;\n }\n const parts = [\n ...(prefix ? [stringLiteral(prefix)] : []),\n value,\n ...(suffix ? [stringLiteral(suffix)] : []),\n ];\n return `(${parts.join(\" || \")})`;\n}\n\nfunction columnDefinition(tableName: string, fieldName: string, field: DDLFieldConfig): string {\n const column = identifier(fieldName);\n const label = `${identifier(tableName)}.${column}`;\n const parts = [column, columnType(field)];\n\n if (field.serial) {\n if (field.type === \"integer\") {\n parts.push(`GENERATED BY DEFAULT AS IDENTITY (${sequenceRange(field.serial)})`);\n if (field.unique) parts.push(\"UNIQUE\");\n return parts.join(\" \");\n }\n if (field.required) parts.push(\"NOT NULL\");\n if (field.unique) parts.push(\"UNIQUE\");\n parts.push(\n `DEFAULT ${serialStringDefault(sequenceName(tableName, fieldName), field.serial.format, label)}`,\n );\n return parts.join(\" \");\n }\n\n const hasDefault = field.default !== undefined;\n const filledOnCreate = field.hooks?.create !== undefined || field.optionalOnCreate === true;\n if (field.required && (hasDefault || !filledOnCreate)) parts.push(\"NOT NULL\");\n if (field.unique) parts.push(\"UNIQUE\");\n if (hasDefault) parts.push(`DEFAULT ${defaultExpression(field, label)}`);\n return parts.join(\" \");\n}\n\n/**\n * DDL statements that create one table: any sequences its string serial\n * fields draw from, the table, the sequences' ownership of their columns,\n * then its unique indexes. Every statement is `IF NOT EXISTS` or otherwise\n * idempotent, so re-applying the script on a database that already has the\n * table is a no-op. Owning a sequence makes `DROP TABLE` drop it and\n * `TRUNCATE ... RESTART IDENTITY` reset it to the configured start. Index\n * names end in `_idx` so they cannot take the `<table>_<column>_key` name\n * Postgres gives a UNIQUE column, which `IF NOT EXISTS` would otherwise\n * silently skip.\n * @param table - Table name, fields, and indexes\n * @returns Statements in execution order, without trailing semicolons\n * @throws If a field type, default, or serial format cannot be expressed\n */\nexport function generateTableDDL(table: DDLTableConfig): string[] {\n const tableIdentifier = identifier(table.name);\n const sequences: string[] = [];\n const ownerships: string[] = [];\n const columns = [` \"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid()`];\n\n for (const [fieldName, field] of Object.entries(table.fields)) {\n if (fieldName === \"id\") continue;\n if (field.serial && field.type !== \"integer\") {\n const sequence = sequenceName(table.name, fieldName);\n sequences.push(`CREATE SEQUENCE IF NOT EXISTS ${sequence} ${sequenceRange(field.serial)}`);\n ownerships.push(\n `ALTER SEQUENCE ${sequence} OWNED BY ${tableIdentifier}.${identifier(fieldName)}`,\n );\n }\n columns.push(` ${columnDefinition(table.name, fieldName, field)}`);\n }\n\n const indexes = Object.entries(table.indexes ?? {})\n .filter(([, index]) => index.unique)\n .map(\n ([name, index]) =>\n `CREATE UNIQUE INDEX IF NOT EXISTS ${derivedIdentifier(table.name, name, \"idx\")} ON ${tableIdentifier} (${index.fields.map(identifier).join(\", \")})`,\n );\n\n return [\n ...sequences,\n `CREATE TABLE IF NOT EXISTS ${tableIdentifier} (\\n${columns.join(\",\\n\")}\\n)`,\n ...ownerships,\n ...indexes,\n ];\n}\n\n/**\n * A single SQL script creating every given table, for `pglite.exec()`.\n * @param tables - Tables in the order to create them\n * @returns The script, empty when there are no tables\n */\nexport function generateSchemaDDL(tables: readonly DDLTableConfig[]): string {\n return tables\n .map((table) =>\n generateTableDDL(table)\n .map((statement) => `${statement};`)\n .join(\"\\n\"),\n )\n .join(\"\\n\\n\");\n}\n\n/** One namespace's tables, as the schema module groups them. */\nexport interface PgliteSchemaNamespace {\n namespace: string;\n tables: readonly DDLTableConfig[];\n}\n\n/** Options for {@link generatePgliteSchemaModule}. */\nexport interface PgliteSchemaModuleOptions {\n /** Named in the generated header as the producer users must not edit around. */\n generatedBy: string;\n}\n\n// A template literal keeps line feeds but folds a carriage return into one.\nfunction templateLiteral(value: string): string {\n const escaped = value\n .replaceAll(\"\\\\\", \"\\\\\\\\\")\n .replaceAll(\"`\", \"\\\\`\")\n .replaceAll(\"${\", \"\\\\${\")\n .replaceAll(\"\\r\", \"\\\\r\");\n return `\\`${escaped}\\``;\n}\n\n/**\n * Render the module that exports each namespace's `CREATE TABLE` script for\n * `pglite.exec()`.\n * @param namespaces - Namespaces with the tables to create\n * @param options - Header wording\n * @returns TypeScript source of the schema module\n */\nexport function generatePgliteSchemaModule(\n namespaces: readonly PgliteSchemaNamespace[],\n options: PgliteSchemaModuleOptions,\n): string {\n const entries = namespaces.map(\n ({ namespace, tables }) =>\n ` ${JSON.stringify(namespace)}: ${templateLiteral(generateSchemaDDL(tables))},`,\n );\n return [\n \"/**\",\n \" * Auto-generated PGlite schema for TailorDB tables.\",\n \" * Create a namespace's tables in a test with `pglite.exec(pgliteSchema[namespace])`.\",\n \" *\",\n ` * DO NOT EDIT - This file is auto-generated by ${options.generatedBy}.`,\n \" */\",\n \"\",\n \"export const pgliteSchema = {\",\n ...entries,\n \"} as const;\",\n \"\",\n ].join(\"\\n\");\n}\n"],"mappings":"AAgBA,SAAgB,yBAAyB,EAAoC,CAC3E,OAAQ,EAAR,CACE,IAAK,OACL,IAAK,SACL,IAAK,UACH,MAAO,SACT,IAAK,UACL,IAAK,QACH,MAAO,SACT,IAAK,OACL,IAAK,WACH,MAAO,YACT,IAAK,OACL,IAAK,UACH,MAAO,UACT,IAAK,OACL,IAAK,SACH,MAAU,MACR,eAAe,EAAU,wDAC3B,EACF,QACE,MAAO,QACX,CACF,CAsBA,MAAa,kBAAqE,IAAI,IAGpF,CAAC,CAAC,YAAa,CAAE,OAAQ,OAAQ,MAAO,eAAgB,CAAC,CAAC,CAAC,EChCvD,EAAO,IAAI,YAQjB,SAAgB,2BAA2B,EAA2B,CACpE,OAAQ,EAAR,CACE,IAAK,OACH,MAAO,OACT,IAAK,SACL,IAAK,OACH,MAAO,OACT,IAAK,UACL,IAAK,OACH,MAAO,UACT,IAAK,UACH,MAAO,UACT,IAAK,QACH,MAAO,mBACT,IAAK,UACH,MAAO,UACT,IAAK,OACH,MAAO,OACT,IAAK,WACH,MAAO,cACT,IAAK,OACH,MAAO,OACT,IAAK,SACH,MAAO,QACT,QACE,MAAU,MAAM,eAAe,EAAU,iCAAiC,CAC9E,CACF,CAEA,SAAS,WAAW,EAAsB,CACxC,MAAO,IAAI,EAAK,WAAW,IAAK,IAAI,EAAE,EACxC,CAEA,SAAS,SAAS,EAAuB,CACvC,IAAI,EAAO,WACX,IAAK,IAAM,KAAQ,EAAK,OAAO,CAAK,EAClC,EAAO,KAAK,KAAK,EAAO,EAAM,QAAU,IAAM,EAEhD,OAAO,EAAK,SAAS,EAAE,CAAC,CAAC,SAA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AAK,CAAC,CACtB,WAAW,KAAM,MAAM,CAAC,CACxB,WAAW,KAAM,KACF,EAAE,GACtB,CASA,SAAgB,2BACd,EACA,EACQ,CACR,IAAM,EAAU,EAAW,KACxB,CAAE,YAAW,YACZ,KAAK,KAAK,UAAU,CAAS,EAAE,IAAI,gBAAgB,kBAAkB,CAAM,CAAC,EAAE,EAClF,EACA,MAAO,CACL,MACA,uDACA,wFACA,KACA,mDAAmD,EAAQ,YAAY,GACvE,MACA,GACA,gCACA,GAAG,EACH,cACA,EACF,CAAC,CAAC,KAAK;CAAI,CACb"}
|
|
1
|
+
{"version":3,"file":"tailordb-ddl-DqInYupv.mjs","names":["fieldType","COLUMN_TYPE_ALIASES","utf8","name","hash","byte","value","suffix","tableName","memberName","kind","head","base","field","pgType","label","CURRENT_TIME_EXPRESSIONS","currentTime","v","groups","format","conversion","fieldName","range","serial","SERIAL_CONVERSIONS","nextval","sequence","number","width","zeroPad","prefix","column","parts","hasDefault","filledOnCreate","tableIdentifier","table","sequences","ownerships","columns","indexes","index","tables","statement","entries","namespaces","namespace","options"],"sources":["../src/utils/field-column-type.ts","../src/utils/tailordb-ddl.ts"],"sourcesContent":["/** The Kysely column type a TailorDB field maps to, before array/null modifiers. */\nexport type FieldColumnType = \"string\" | \"number\" | \"boolean\" | \"Timestamp\";\n\n/**\n * Map a scalar TailorDB field type to the column type generated code uses for it.\n *\n * `date` resolves to `Timestamp` because the function runtime hands back a\n * `Date` for a date column, same as for datetime.\n *\n * `enum` and `nested` carry their own shape, so each generator resolves them\n * before reaching here; passing either is a caller bug rather than a `string`\n * column.\n * @param fieldType - TailorDB scalar field type name\n * @returns The column type for the field, defaulting to `string`\n * @throws If given `enum` or `nested`\n */\nexport function mapFieldTypeToColumnType(fieldType: string): FieldColumnType {\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n return \"string\";\n case \"integer\":\n case \"float\":\n return \"number\";\n case \"date\":\n case \"datetime\":\n return \"Timestamp\";\n case \"bool\":\n case \"boolean\":\n return \"boolean\";\n case \"enum\":\n case \"nested\":\n throw new Error(\n `Field type \"${fieldType}\" has no scalar column type; resolve it before mapping.`,\n );\n default:\n return \"string\";\n }\n}\n\n/** The select and write types a `ColumnType`-shaped alias expands to. */\nexport type ColumnTypeAliasExpansion = {\n /** Type the alias reads back as. */\n readonly select: string;\n /** Type the alias accepts on insert and update. */\n readonly write: string;\n};\n\n/**\n * Column types whose alias expands to a `ColumnType`, mapped to that expansion.\n *\n * Kysely only unwraps a `ColumnType` at the top level of a table property, so an\n * array of one of these stays wrapped in `ArrayColumnType<...>` rather than taking\n * a `[]` suffix, which would nest the `ColumnType` out of Kysely's reach. Where a\n * generator has to spell out the slots itself, it reads the expansion from here\n * rather than inlining the alias, which would nest just the same.\n *\n * Both type generators track alias usage per alias to decide which declarations to\n * emit, so adding an entry here also means teaching them to report the new alias.\n */\nexport const COLUMN_TYPE_ALIASES: ReadonlyMap<string, ColumnTypeAliasExpansion> = new Map<\n FieldColumnType,\n ColumnTypeAliasExpansion\n>([[\"Timestamp\", { select: \"Date\", write: \"Date | string\" }]]);\n","/**\n * PostgreSQL DDL derived from TailorDB table definitions, for creating the\n * tables a PGlite-backed test needs. The columns match the flat shape the\n * Kysely type generators emit, not TailorDB's storage layout.\n */\n\n/** The field shape the DDL generator reads; parsed and snapshot field configs are both assignable. */\nexport interface DDLFieldConfig {\n type: string;\n required?: boolean;\n array?: boolean;\n unique?: boolean;\n serial?: { start: number; maxValue?: number; format?: string };\n scale?: number;\n default?: unknown;\n optionalOnCreate?: boolean;\n hooks?: { create?: unknown; update?: unknown };\n fields?: Record<string, DDLFieldConfig>;\n}\n\n/** A table to emit DDL for. */\nexport interface DDLTableConfig {\n name: string;\n fields: Record<string, DDLFieldConfig>;\n indexes?: Record<string, { fields: string[]; unique?: boolean }>;\n}\n\nconst MAX_IDENTIFIER_BYTES = 63;\n// The platform rounds decimals to their scale (6 unless configured); numeric\n// needs a precision to carry a scale, and the maximum leaves it unconstrained.\nconst DECIMAL_PRECISION = 1000;\nconst DEFAULT_DECIMAL_SCALE = 6;\nconst utf8 = new TextEncoder();\n\n/**\n * Map a TailorDB field type to the PostgreSQL column type PGlite tests use for it.\n * @param fieldType - TailorDB field type name\n * @returns The PostgreSQL type name\n * @throws If the type is not a TailorDB field type\n */\nexport function mapFieldTypeToPostgresType(fieldType: string): string {\n switch (fieldType) {\n case \"uuid\":\n return \"uuid\";\n case \"string\":\n case \"enum\":\n return \"text\";\n case \"boolean\":\n case \"bool\":\n return \"boolean\";\n case \"integer\":\n return \"integer\";\n case \"float\":\n return \"double precision\";\n case \"decimal\":\n return \"numeric\";\n case \"date\":\n return \"date\";\n case \"datetime\":\n return \"timestamptz\";\n case \"time\":\n return \"time\";\n case \"nested\":\n return \"jsonb\";\n default:\n throw new Error(`Field type \"${fieldType}\" has no PostgreSQL column type.`);\n }\n}\n\nfunction identifier(name: string): string {\n return `\"${name.replaceAll('\"', '\"\"')}\"`;\n}\n\nfunction fnv1aHex(value: string): string {\n let hash = 0x811c9dc5;\n for (const byte of utf8.encode(value)) {\n hash = Math.imul(hash ^ byte, 0x01000193) >>> 0;\n }\n return hash.toString(16).padStart(8, \"0\");\n}\n\nfunction derivedIdentifier(tableName: string, memberName: string, kind: \"seq\" | \"idx\"): string {\n const suffix = `_${fnv1aHex(JSON.stringify([tableName, memberName, kind]))}_${kind}`;\n let head = `${tableName}_${memberName}`;\n while (utf8.encode(head + suffix).length > MAX_IDENTIFIER_BYTES) head = head.slice(0, -1);\n return identifier(head + suffix);\n}\n\nfunction stringLiteral(value: string): string {\n return `'${value.replaceAll(\"'\", \"''\")}'`;\n}\n\nfunction columnType(field: DDLFieldConfig): string {\n const base =\n field.type === \"decimal\"\n ? `numeric(${DECIMAL_PRECISION}, ${field.scale ?? DEFAULT_DECIMAL_SCALE})`\n : mapFieldTypeToPostgresType(field.type);\n return field.array && field.type !== \"nested\" ? `${base}[]` : base;\n}\n\nfunction scalarLiteral(value: unknown, field: DDLFieldConfig, label: string): string {\n const pgType = mapFieldTypeToPostgresType(field.type);\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) {\n throw new Error(`Default of field ${label} is an invalid Date.`);\n }\n return `${stringLiteral(value.toISOString())}::${pgType}`;\n }\n switch (typeof value) {\n case \"string\":\n return pgType === \"text\" ? stringLiteral(value) : `${stringLiteral(value)}::${pgType}`;\n case \"number\":\n if (!Number.isFinite(value)) {\n throw new Error(`Default of field ${label} is not a finite number.`);\n }\n return String(value);\n case \"boolean\":\n return value ? \"TRUE\" : \"FALSE\";\n default:\n throw new Error(`Default of field ${label} cannot be rendered as a SQL literal.`);\n }\n}\n\nconst CURRENT_TIME_EXPRESSIONS = new Map([\n [\"datetime\", \"now()\"],\n [\"date\", \"CURRENT_DATE\"],\n [\"time\", \"LOCALTIME\"],\n]);\n\nfunction defaultExpression(field: DDLFieldConfig, label: string): string {\n const value = field.default;\n const currentTime = CURRENT_TIME_EXPRESSIONS.get(field.type);\n if (value === \"now\" && currentTime !== undefined) {\n return currentTime;\n }\n if (field.array) {\n if (!Array.isArray(value)) {\n throw new Error(`Default of array field ${label} must be an array.`);\n }\n const pgType = columnType(field);\n if (value.length === 0) return `'{}'::${pgType}`;\n return `ARRAY[${value.map((v) => scalarLiteral(v, field, label)).join(\", \")}]::${pgType}`;\n }\n return scalarLiteral(value, field, label);\n}\n\ninterface SerialFormat {\n prefix: string;\n width: number;\n zeroPad: boolean;\n conversion: \"d\" | \"x\" | \"X\";\n suffix: string;\n}\n\n// printf-style with exactly one conversion specifier; octal has no Postgres\n// formatting function to stand in for it.\nfunction parseSerialFormat(format: string, label: string): SerialFormat {\n const match =\n /^(?<prefix>[^%]*)%(?<zero>0?)(?<width>\\d*)(?<conversion>[a-zA-Z])(?<suffix>[^%]*)$/.exec(\n format,\n );\n const groups = match?.groups;\n const conversion = groups?.conversion;\n if (!groups || (conversion !== \"d\" && conversion !== \"x\" && conversion !== \"X\")) {\n throw new Error(\n `Serial format \"${format}\" of field ${label} is not supported; use a single %d, %x, or %X specifier with an optional width (e.g. \"INV-%05d\").`,\n );\n }\n return {\n prefix: groups.prefix ?? \"\",\n zeroPad: groups.zero === \"0\",\n width: groups.width ? Number(groups.width) : 0,\n conversion,\n suffix: groups.suffix ?? \"\",\n };\n}\n\nfunction sequenceName(tableName: string, fieldName: string): string {\n return derivedIdentifier(tableName, fieldName, \"seq\");\n}\n\n// A sequence's minimum defaults to 1, which rejects a start of 0.\nfunction sequenceRange(serial: NonNullable<DDLFieldConfig[\"serial\"]>): string {\n const range = [`START WITH ${serial.start}`, `MINVALUE ${serial.start}`];\n if (serial.maxValue !== undefined) range.push(`MAXVALUE ${serial.maxValue}`);\n return range.join(\" \");\n}\n\nconst SERIAL_CONVERSIONS: Record<SerialFormat[\"conversion\"], (nextval: string) => string> = {\n d: (nextval) => nextval,\n x: (nextval) => `to_hex(${nextval})`,\n X: (nextval) => `upper(to_hex(${nextval}))`,\n};\n\nfunction serialStringDefault(sequence: string, format: string | undefined, label: string): string {\n const nextval = `nextval(${stringLiteral(sequence)})`;\n if (format === undefined) return `(${nextval}::text)`;\n const { prefix, width, zeroPad, conversion, suffix } = parseSerialFormat(format, label);\n const number = SERIAL_CONVERSIONS[conversion](nextval);\n let value = conversion === \"d\" ? `${number}::text` : number;\n if (width > 0) {\n value = `format('%${width}s', ${number})`;\n if (zeroPad) value = `translate(${value}, ' ', '0')`;\n }\n const parts = [\n ...(prefix ? [stringLiteral(prefix)] : []),\n value,\n ...(suffix ? [stringLiteral(suffix)] : []),\n ];\n return `(${parts.join(\" || \")})`;\n}\n\nfunction columnDefinition(tableName: string, fieldName: string, field: DDLFieldConfig): string {\n const column = identifier(fieldName);\n const label = `${identifier(tableName)}.${column}`;\n const parts = [column, columnType(field)];\n\n if (field.serial) {\n if (field.type === \"integer\") {\n parts.push(`GENERATED BY DEFAULT AS IDENTITY (${sequenceRange(field.serial)})`);\n if (field.unique) parts.push(\"UNIQUE\");\n return parts.join(\" \");\n }\n if (field.required) parts.push(\"NOT NULL\");\n if (field.unique) parts.push(\"UNIQUE\");\n parts.push(\n `DEFAULT ${serialStringDefault(sequenceName(tableName, fieldName), field.serial.format, label)}`,\n );\n return parts.join(\" \");\n }\n\n const hasDefault = field.default !== undefined;\n const filledOnCreate = field.hooks?.create !== undefined || field.optionalOnCreate === true;\n if (field.required && (hasDefault || !filledOnCreate)) parts.push(\"NOT NULL\");\n if (field.unique) parts.push(\"UNIQUE\");\n if (hasDefault) parts.push(`DEFAULT ${defaultExpression(field, label)}`);\n return parts.join(\" \");\n}\n\n/**\n * DDL statements that create one table: any sequences its string serial\n * fields draw from, the table, the sequences' ownership of their columns,\n * then its unique indexes. Every statement is `IF NOT EXISTS` or otherwise\n * idempotent, so re-applying the script on a database that already has the\n * table is a no-op. Owning a sequence makes `DROP TABLE` drop it and\n * `TRUNCATE ... RESTART IDENTITY` reset it to the configured start. Index\n * names end in `_idx` so they cannot take the `<table>_<column>_key` name\n * Postgres gives a UNIQUE column, which `IF NOT EXISTS` would otherwise\n * silently skip.\n * @param table - Table name, fields, and indexes\n * @returns Statements in execution order, without trailing semicolons\n * @throws If a field type, default, or serial format cannot be expressed\n */\nexport function generateTableDDL(table: DDLTableConfig): string[] {\n const tableIdentifier = identifier(table.name);\n const sequences: string[] = [];\n const ownerships: string[] = [];\n const columns = [` \"id\" uuid PRIMARY KEY DEFAULT gen_random_uuid()`];\n\n for (const [fieldName, field] of Object.entries(table.fields)) {\n if (fieldName === \"id\") continue;\n if (field.serial && field.type !== \"integer\") {\n const sequence = sequenceName(table.name, fieldName);\n sequences.push(`CREATE SEQUENCE IF NOT EXISTS ${sequence} ${sequenceRange(field.serial)}`);\n ownerships.push(\n `ALTER SEQUENCE ${sequence} OWNED BY ${tableIdentifier}.${identifier(fieldName)}`,\n );\n }\n columns.push(` ${columnDefinition(table.name, fieldName, field)}`);\n }\n\n const indexes = Object.entries(table.indexes ?? {})\n .filter(([, index]) => index.unique)\n .map(\n ([name, index]) =>\n `CREATE UNIQUE INDEX IF NOT EXISTS ${derivedIdentifier(table.name, name, \"idx\")} ON ${tableIdentifier} (${index.fields.map(identifier).join(\", \")})`,\n );\n\n return [\n ...sequences,\n `CREATE TABLE IF NOT EXISTS ${tableIdentifier} (\\n${columns.join(\",\\n\")}\\n)`,\n ...ownerships,\n ...indexes,\n ];\n}\n\n/**\n * A single SQL script creating every given table, for `pglite.exec()`.\n * @param tables - Tables in the order to create them\n * @returns The script, empty when there are no tables\n */\nexport function generateSchemaDDL(tables: readonly DDLTableConfig[]): string {\n return tables\n .map((table) =>\n generateTableDDL(table)\n .map((statement) => `${statement};`)\n .join(\"\\n\"),\n )\n .join(\"\\n\\n\");\n}\n\n/** One namespace's tables, as the schema module groups them. */\nexport interface PgliteSchemaNamespace {\n namespace: string;\n tables: readonly DDLTableConfig[];\n}\n\n/** Options for {@link generatePgliteSchemaModule}. */\nexport interface PgliteSchemaModuleOptions {\n /** Named in the generated header as the producer users must not edit around. */\n generatedBy: string;\n}\n\n// A template literal keeps line feeds but folds a carriage return into one.\nfunction templateLiteral(value: string): string {\n const escaped = value\n .replaceAll(\"\\\\\", \"\\\\\\\\\")\n .replaceAll(\"`\", \"\\\\`\")\n .replaceAll(\"${\", \"\\\\${\")\n .replaceAll(\"\\r\", \"\\\\r\");\n return `\\`${escaped}\\``;\n}\n\n/**\n * Render the module that exports each namespace's `CREATE TABLE` script for\n * `pglite.exec()`.\n * @param namespaces - Namespaces with the tables to create\n * @param options - Header wording\n * @returns TypeScript source of the schema module\n */\nexport function generatePgliteSchemaModule(\n namespaces: readonly PgliteSchemaNamespace[],\n options: PgliteSchemaModuleOptions,\n): string {\n const entries = namespaces.map(\n ({ namespace, tables }) =>\n ` ${JSON.stringify(namespace)}: ${templateLiteral(generateSchemaDDL(tables))},`,\n );\n return [\n \"/**\",\n \" * Auto-generated PGlite schema for TailorDB tables.\",\n \" * Create a namespace's tables in a test with `pglite.exec(pgliteSchema[namespace])`.\",\n \" *\",\n ` * DO NOT EDIT - This file is auto-generated by ${options.generatedBy}.`,\n \" */\",\n \"\",\n \"export const pgliteSchema = {\",\n ...entries,\n \"} as const;\",\n \"\",\n ].join(\"\\n\");\n}\n"],"mappings":"AAgBA,SAAgB,yBAAyB,EAAoC,CAC3E,OAAQA,EAAR,CACE,IAAK,OACL,IAAK,SACL,IAAK,UACH,MAAO,SACT,IAAK,UACL,IAAK,QACH,MAAO,SACT,IAAK,OACL,IAAK,WACH,MAAO,YACT,IAAK,OACL,IAAK,UACH,MAAO,UACT,IAAK,OACL,IAAK,SACH,MAAU,MACR,eAAeA,EAAU,wDAC3B,EACF,QACE,MAAO,QACX,CACF,CAsBA,MAAaC,kBAAqE,IAAI,IAGpF,CAAC,CAAC,YAAa,CAAE,OAAQ,OAAQ,MAAO,eAAgB,CAAC,CAAC,CAAC,EChCvDC,EAAO,IAAI,YAQjB,SAAgB,2BAA2B,EAA2B,CACpE,OAAQF,EAAR,CACE,IAAK,OACH,MAAO,OACT,IAAK,SACL,IAAK,OACH,MAAO,OACT,IAAK,UACL,IAAK,OACH,MAAO,UACT,IAAK,UACH,MAAO,UACT,IAAK,QACH,MAAO,mBACT,IAAK,UACH,MAAO,UACT,IAAK,OACH,MAAO,OACT,IAAK,WACH,MAAO,cACT,IAAK,OACH,MAAO,OACT,IAAK,SACH,MAAO,QACT,QACE,MAAU,MAAM,eAAeA,EAAU,iCAAiC,CAC9E,CACF,CAEA,SAAS,WAAW,EAAsB,CACxC,MAAO,IAAIG,EAAK,WAAW,IAAK,IAAI,EAAE,EACxC,CAEA,SAAS,SAAS,EAAuB,CACvC,IAAIC,EAAO,WACX,IAAK,IAAMC,KAAQH,EAAK,OAAOI,CAAK,EAClC,EAAO,KAAK,KAAKF,EAAOC,EAAM,QAAU,IAAM,EAEhD,OAAOD,EAAK,SAAS,EAAE,CAAC,CAAC,SAAS,EAAG,GAAG,CAC1C,CAEA,SAAS,kBAAkB,EAAmB,EAAoB,EAA6B,CAC7F,IAAMG,EAAS,IAAI,SAAS,K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