@tailor-platform/sdk 2.0.0-next.4 → 2.0.0-next.5
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 +97 -0
- package/dist/{application-BX13RArL.mjs → application-Bf8wxOi6.mjs} +417 -589
- package/dist/application-Bf8wxOi6.mjs.map +1 -0
- package/dist/application-CUkjzfij.mjs +3 -0
- package/dist/cli/cache/bundle-cache.d.mts +2 -1
- package/dist/cli/cache/store.d.mts +1 -1
- package/dist/cli/commands/api/index.d.mts +1 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +5 -1
- package/dist/cli/commands/deploy/application.d.mts +7 -1
- package/dist/cli/commands/deploy/apply-phases.d.mts +14 -1
- package/dist/cli/commands/deploy/auth.d.mts +5 -1
- package/dist/cli/commands/deploy/deploy.d.mts +5 -0
- package/dist/cli/commands/deploy/executor.d.mts +7 -1
- package/dist/cli/commands/deploy/function-registry.d.mts +5 -0
- package/dist/cli/commands/deploy/idp.d.mts +5 -1
- package/dist/cli/commands/deploy/resolver.d.mts +5 -1
- package/dist/cli/commands/deploy/secret-manager.d.mts +5 -1
- package/dist/cli/commands/deploy/staticwebsite.d.mts +5 -1
- package/dist/cli/commands/deploy/tailordb/index.d.mts +8 -1
- package/dist/cli/commands/deploy/types.d.mts +3 -1
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +3 -1
- package/dist/cli/commands/deploy/workflow.d.mts +4 -1
- package/dist/cli/commands/executor/get.d.mts +0 -1
- package/dist/cli/commands/executor/jobs.d.mts +0 -1
- package/dist/cli/commands/executor/list.d.mts +0 -1
- package/dist/cli/commands/executor/transform.d.mts +1 -0
- package/dist/cli/commands/executor/trigger.d.mts +0 -1
- package/dist/cli/commands/executor/webhook.d.mts +0 -1
- package/dist/cli/commands/function/get.d.mts +0 -1
- package/dist/cli/commands/function/list.d.mts +0 -1
- package/dist/cli/commands/function/transform.d.mts +1 -0
- package/dist/cli/commands/generate/service.d.mts +5 -1
- package/dist/cli/commands/machineuser/list.d.mts +0 -1
- package/dist/cli/commands/machineuser/token.d.mts +0 -1
- package/dist/cli/commands/oauth2client/get.d.mts +0 -1
- package/dist/cli/commands/oauth2client/list.d.mts +0 -1
- package/dist/cli/commands/oauth2client/transform.d.mts +1 -0
- package/dist/cli/commands/organization/folder/create.d.mts +0 -1
- package/dist/cli/commands/organization/folder/delete.d.mts +0 -1
- package/dist/cli/commands/organization/folder/get.d.mts +0 -1
- package/dist/cli/commands/organization/folder/list.d.mts +0 -1
- package/dist/cli/commands/organization/folder/update.d.mts +0 -1
- package/dist/cli/commands/organization/get.d.mts +0 -1
- package/dist/cli/commands/organization/list.d.mts +0 -1
- package/dist/cli/commands/organization/transform.d.mts +2 -0
- package/dist/cli/commands/organization/tree.d.mts +0 -1
- package/dist/cli/commands/organization/update.d.mts +0 -1
- package/dist/cli/commands/remove.d.mts +0 -1
- package/dist/cli/commands/show.d.mts +9 -4
- package/dist/cli/commands/tailordb/migrate/config.d.mts +0 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +16 -3
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +0 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +6 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
- package/dist/cli/commands/tailordb/truncate.d.mts +0 -1
- package/dist/cli/commands/workflow/executions.d.mts +0 -1
- package/dist/cli/commands/workflow/get.d.mts +2 -1
- package/dist/cli/commands/workflow/list.d.mts +0 -1
- package/dist/cli/commands/workflow/resume.d.mts +0 -1
- package/dist/cli/commands/workflow/start.d.mts +0 -1
- package/dist/cli/commands/workflow/status.d.mts +1 -0
- package/dist/cli/commands/workflow/transform.d.mts +1 -0
- package/dist/cli/commands/workflow/wait.d.mts +0 -1
- package/dist/cli/commands/workflow/waiter.d.mts +1 -1
- package/dist/cli/commands/workspace/app/health.d.mts +0 -1
- package/dist/cli/commands/workspace/app/list.d.mts +0 -1
- package/dist/cli/commands/workspace/app/transform.d.mts +2 -0
- package/dist/cli/commands/workspace/create.d.mts +0 -1
- package/dist/cli/commands/workspace/delete.d.mts +0 -1
- package/dist/cli/commands/workspace/get.d.mts +0 -1
- package/dist/cli/commands/workspace/list.d.mts +0 -1
- package/dist/cli/commands/workspace/restore.d.mts +0 -1
- package/dist/cli/commands/workspace/transform.d.mts +2 -0
- package/dist/cli/commands/workspace/user/invite.d.mts +0 -1
- package/dist/cli/commands/workspace/user/list.d.mts +0 -1
- package/dist/cli/commands/workspace/user/remove.d.mts +0 -1
- package/dist/cli/commands/workspace/user/transform.d.mts +1 -0
- package/dist/cli/commands/workspace/user/update.d.mts +0 -1
- package/dist/cli/index.d.mts +6 -3
- package/dist/cli/index.mjs +142 -73
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +4 -2
- package/dist/cli/lib.mjs +3 -3
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/query/index.d.mts +0 -1
- package/dist/cli/services/application.d.mts +12 -1
- package/dist/cli/services/auth/service.d.mts +2 -0
- package/dist/cli/services/executor/service.d.mts +1 -1
- package/dist/cli/services/http-adapter/bundler.d.mts +3 -1
- package/dist/cli/services/http-adapter/service.d.mts +2 -1
- package/dist/cli/services/resolver/service.d.mts +1 -1
- package/dist/cli/services/tailordb/service.d.mts +3 -1
- package/dist/cli/services/workflow/bundler.d.mts +2 -1
- package/dist/cli/services/workflow/service.d.mts +1 -1
- package/dist/cli/shared/args.d.mts +1 -1
- package/dist/cli/shared/client.d.mts +1 -1
- package/dist/cli/shared/config-loader.d.mts +0 -1
- package/dist/cli/shared/context.d.mts +2 -1
- package/dist/cli/shared/script-executor.d.mts +0 -1
- package/dist/cli/shared/seed-chunker.d.mts +7 -3
- package/dist/cli/shared/type-generator.d.mts +0 -1
- package/dist/completion/zsh-worker.zsh +1 -1
- package/dist/configure/config/index.d.mts +0 -1
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +14 -4
- package/dist/configure/index.mjs +196 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +0 -1
- package/dist/configure/services/aigateway/types.d.mts +0 -1
- package/dist/configure/services/auth/index.d.mts +0 -1
- package/dist/configure/services/auth/types.d.mts +15 -14
- package/dist/configure/services/executor/executor.d.mts +1 -1
- package/dist/configure/services/executor/index.d.mts +1 -0
- package/dist/configure/services/executor/operation.d.mts +2 -2
- package/dist/configure/services/executor/trigger/event.d.mts +0 -1
- package/dist/configure/services/executor/trigger/index.d.mts +0 -1
- package/dist/configure/services/executor/trigger/schedule.d.mts +0 -1
- package/dist/configure/services/executor/trigger/webhook.d.mts +0 -1
- package/dist/configure/services/http-adapter/http-adapter.d.mts +1 -2
- package/dist/configure/services/idp/index.d.mts +1 -5
- package/dist/configure/services/idp/permission.d.mts +4 -5
- package/dist/configure/services/idp/types.d.mts +0 -1
- package/dist/configure/services/index.d.mts +5 -0
- package/dist/configure/services/resolver/resolver.d.mts +1 -0
- package/dist/configure/services/resolver/types.d.mts +0 -1
- package/dist/configure/services/secrets/index.d.mts +0 -1
- package/dist/configure/services/secrets/types.d.mts +0 -1
- package/dist/configure/services/staticwebsite/index.d.mts +0 -1
- package/dist/configure/services/staticwebsite/types.d.mts +0 -1
- package/dist/configure/services/tailordb/permission.d.mts +4 -5
- package/dist/configure/services/tailordb/schema.d.mts +85 -49
- package/dist/configure/services/tailordb/types.d.mts +66 -17
- package/dist/configure/services/workflow/execution-policy.d.mts +0 -1
- package/dist/configure/services/workflow/execution-policy.types.d.mts +0 -1
- package/dist/configure/services/workflow/index.d.mts +1 -0
- package/dist/configure/services/workflow/job.d.mts +0 -1
- package/dist/configure/services/workflow/wait-point.d.mts +0 -1
- package/dist/configure/services/workflow/workflow.d.mts +1 -1
- package/dist/configure/types/field-runtime.d.mts +0 -1
- package/dist/configure/types/field.d.mts +1 -2
- package/dist/configure/types/field.types.d.mts +6 -45
- package/dist/configure/types/index.d.mts +1 -0
- package/dist/configure/types/type.d.mts +1 -2
- package/dist/kysely/index.d.mts +3 -4
- package/dist/{kysely-type-D-zflMGf.mjs → kysely-type-DqIRgDYR.mjs} +4 -3
- package/dist/kysely-type-DqIRgDYR.mjs.map +1 -0
- package/dist/parser/service/auth/index.d.mts +1 -1
- package/dist/parser/service/auth/schema.d.mts +2 -0
- package/dist/parser/service/http-adapter/index.d.mts +1 -1
- package/dist/parser/service/idp/types.d.mts +1 -0
- package/dist/parser/service/tailordb/types.d.mts +6 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +0 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +0 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +0 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +0 -1
- package/dist/plugin/get-generated-type.d.mts +0 -1
- package/dist/plugin/manager.d.mts +2 -1
- package/dist/plugin/types.d.mts +0 -1
- package/dist/plugin/with-context.d.mts +0 -1
- package/dist/{register-ts-hook-BM1caLT0.mjs → register-ts-hook-BhzVkej0.mjs} +553 -199
- package/dist/register-ts-hook-BhzVkej0.mjs.map +1 -0
- package/dist/runtime/aigateway.d.mts +0 -1
- package/dist/runtime/authconnection.d.mts +0 -1
- package/dist/runtime/context.d.mts +0 -1
- package/dist/runtime/globals.d.mts +0 -1
- package/dist/runtime/index.d.mts +0 -1
- package/dist/runtime/types.d.mts +9 -4
- package/dist/{schema-C4LYbXVG.mjs → schema-iCd1ugGp.mjs} +253 -50
- package/dist/schema-iCd1ugGp.mjs.map +1 -0
- package/dist/seed/index.d.mts +3 -2
- package/dist/service-BT0GPd01.mjs +3 -0
- package/dist/{service-ufH7sS8o.mjs → service-CzZEVrp9.mjs} +14 -9
- package/dist/service-CzZEVrp9.mjs.map +1 -0
- package/dist/{service_pb-B5w9rjPY.mjs → service_pb-Bk7dL-yT.mjs} +12 -2
- package/dist/{service_pb-B5w9rjPY.mjs.map → service_pb-Bk7dL-yT.mjs.map} +1 -1
- package/dist/{service_pb-B2FF59sP.mjs → service_pb-DZkfjB_6.mjs} +1 -1
- package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +0 -1
- package/dist/types/aigateway.generated.d.mts +5 -2
- package/dist/types/auth-connection.generated.d.mts +24 -11
- package/dist/types/auth.generated.d.mts +115 -84
- package/dist/types/executor.generated.d.mts +76 -84
- package/dist/types/helpers.d.mts +7 -6
- package/dist/types/http-adapter.generated.d.mts +11 -5
- package/dist/types/idp.generated.d.mts +536 -524
- package/dist/types/resolver.generated.d.mts +26 -11
- package/dist/types/staticwebsite.generated.d.mts +7 -3
- package/dist/types/tailordb.generated.d.mts +57 -29
- package/dist/types/workflow.generated.d.mts +9 -4
- package/dist/utils/test/index.d.mts +1 -2
- package/dist/utils/test/index.mjs +36 -10
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/utils/test/mock.d.mts +0 -1
- package/dist/vitest/index.d.mts +1 -1
- package/dist/vitest/mock-kysely.d.mts +0 -1
- package/dist/vitest/mocks/aigateway.d.mts +2 -2
- package/dist/vitest/mocks/authconnection.d.mts +2 -2
- package/dist/vitest/mocks/idp.d.mts +2 -2
- package/dist/vitest/mocks/secretmanager.d.mts +3 -1
- package/dist/vitest/mocks/tailordb.d.mts +6 -3
- package/dist/vitest/mocks/workflow.d.mts +11 -6
- package/dist/vitest/workflow-local.d.mts +1 -0
- package/docs/cli/setup.md +1 -1
- package/docs/cli-reference.md +7 -6
- package/docs/migration/v2.md +206 -0
- package/docs/services/aigateway.md +2 -0
- package/docs/services/tailordb.md +100 -68
- package/docs/services/workflow.md +1 -1
- package/package.json +22 -22
- package/dist/application-BO4ZF8wP.mjs +0 -3
- package/dist/application-BX13RArL.mjs.map +0 -1
- package/dist/cli/shared/trigger-context.d.mts +0 -1
- package/dist/field-runtime-CAnh_oow.mjs +0 -183
- package/dist/field-runtime-CAnh_oow.mjs.map +0 -1
- package/dist/kysely-type-D-zflMGf.mjs.map +0 -1
- package/dist/register-ts-hook-BM1caLT0.mjs.map +0 -1
- package/dist/schema-C4LYbXVG.mjs.map +0 -1
- package/dist/service-CkIwEctX.mjs +0 -3
- package/dist/service-ufH7sS8o.mjs.map +0 -1
- package/dist/types-C-lQ4se3.mjs +0 -4
- package/dist/types-CXF2OYdR.mjs +0 -199
- package/dist/types-CXF2OYdR.mjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { t as db } from "./schema-
|
|
1
|
+
import { t as db } from "./schema-iCd1ugGp.mjs";
|
|
2
2
|
import { i as PageDirection, n as Condition_Operator, r as FilterSchema, t as ConditionSchema } from "./resource_pb-BRv7AMXK.mjs";
|
|
3
3
|
import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
|
|
4
4
|
import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-BEiZZ3qT.mjs";
|
|
5
|
-
import { B as readPlatformConfig, C as createBundleCache, Ct as positiveIntArg, D as loadConfig, E as hashFile, Et as workspaceArgs, F as loadMachineUserName, G as writePlatformConfig, H as resolveConfigUser, I as loadPlatformClientConfig, J as fetchAll, M as loadAccessToken, N as loadConfigPath, R as loadWorkspaceId, S as hasGenerationHooks, St as parseDuration, T as hashContent, Tt as toPageDirection, X as fetchMachineUserToken, Y as fetchAllTolerant, Z as fetchPaged, _ as platformBundleDefinePlugin, _t as nonNegativeIntArg, at as initOperatorClient, bt as pagedLogArgs, ct as byName, dt as confirmationArgs, et as getConsoleBaseUrl, f as buildExecutorArgsExpr, ft as deploymentArgs, g as stringifyFunction, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, m as assertUniqueLocalTailorDBTypeNames, mt as folderArgs, n as generatePluginFilesIfNeeded, nt as getOrNull, o as getApplicationAuthNamespace, ot as isDefaultPlatform, p as buildResolverOperationHookExpr, pt as durationArg, r as loadApplication, rt as getPlatformBaseUrl, s as WorkflowJobFunctionExecutionPolicySchema, st as resolveStaticWebsiteUrls, t as defineApplication, tt as getOAuth2ClientId, u as HTTP_METHODS, ut as configArg, vt as orderArg, w as getDistDir, wt as resolveMachineUserInputSource, x as getPluginGenerationDependencies, xt as paginationArgs, yt as organizationArgs, z as platformConfigFromProfile } from "./application-
|
|
6
|
-
import { c as stripTailorDBTypeBuilderHelpers, h as loadFilesWithIgnores, t as createExecutorService, u as TailorDBTypeSchema } from "./service-
|
|
5
|
+
import { B as readPlatformConfig, C as createBundleCache, Ct as positiveIntArg, D as loadConfig, E as hashFile, Et as workspaceArgs, F as loadMachineUserName, G as writePlatformConfig, H as resolveConfigUser, I as loadPlatformClientConfig, J as fetchAll, M as loadAccessToken, N as loadConfigPath, R as loadWorkspaceId, S as hasGenerationHooks, St as parseDuration, T as hashContent, Tt as toPageDirection, X as fetchMachineUserToken, Y as fetchAllTolerant, Z as fetchPaged, _ as platformBundleDefinePlugin, _t as nonNegativeIntArg, at as initOperatorClient, bt as pagedLogArgs, ct as byName, dt as confirmationArgs, et as getConsoleBaseUrl, f as buildExecutorArgsExpr, ft as deploymentArgs, g as stringifyFunction, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, m as assertUniqueLocalTailorDBTypeNames, mt as folderArgs, n as generatePluginFilesIfNeeded, nt as getOrNull, o as getApplicationAuthNamespace, ot as isDefaultPlatform, p as buildResolverOperationHookExpr, pt as durationArg, r as loadApplication, rt as getPlatformBaseUrl, s as WorkflowJobFunctionExecutionPolicySchema, st as resolveStaticWebsiteUrls, t as defineApplication, tt as getOAuth2ClientId, u as HTTP_METHODS, ut as configArg, vt as orderArg, w as getDistDir, wt as resolveMachineUserInputSource, x as getPluginGenerationDependencies, xt as paginationArgs, yt as organizationArgs, z as platformConfigFromProfile } from "./application-Bf8wxOi6.mjs";
|
|
6
|
+
import { c as stripTailorDBTypeBuilderHelpers, h as loadFilesWithIgnores, t as createExecutorService, u as TailorDBTypeSchema } from "./service-CzZEVrp9.mjs";
|
|
7
7
|
import { t as multiline } from "./multiline-sfHpTZZK.mjs";
|
|
8
8
|
import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
|
|
9
9
|
import { i as userAgent } from "./secret-file-aoNXJmKa.mjs";
|
|
10
10
|
import { n as isCLIError, t as createCLIError } from "./errors-118wUDRr.mjs";
|
|
11
|
-
import { $ as CreateAuthServiceRequestSchema, A as CreatePipelineServiceRequestSchema, At as Subgraph_ServiceType, C as CreateStaticWebsiteRequestSchema, D as CreateSecretManagerVaultRequestSchema, Dt as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, E as CreateSecretManagerSecretRequestSchema, Et as CreateApplicationRequestSchema, F as UpdateIdPServiceRequestSchema, G as ExecutorTriggerType, H as UpdateExecutorExecutorRequestSchema, I as IdPLang, J as CreateAuthIDPConfigRequestSchema, K as CreateAuthConnectionRequestSchema, L as IdPPermissionOperator, M as UpdatePipelineServiceRequestSchema, N as PipelineResolver_OperationType, O as UpdateSecretManagerSecretRequestSchema, Ot as UpdateApplicationRequestSchema, P as CreateIdPServiceRequestSchema, Q as CreateAuthSCIMResourceRequestSchema, R as IdPPermissionPermit, S as AddCustomDomainRequestSchema, St as AuthSCIMConfig_AuthorizationType, Tt as UserProfileProviderConfig_UserProfileProviderType, U as ExecutorJobStatus, V as CreateExecutorExecutorRequestSchema, W as ExecutorTargetType, X as CreateAuthOAuth2ClientRequestSchema, Y as CreateAuthMachineUserRequestSchema, Z as CreateAuthSCIMConfigRequestSchema, _ as TailorDBGQLPermission_Operator, _t as AuthOAuth2Client_ClientType, a as WorkspacePlatformUserRole, at as UpdateAuthMachineUserRequestSchema, b as TailorDBType_Permission_Permit, bt as AuthSCIMAttribute_Type, c as CreateWorkflowRequestSchema, ct as UpdateAuthSCIMResourceRequestSchema, d as WorkflowExecution_Status, dt as UpdateUserProfileConfigRequestSchema, et as CreateTenantConfigRequestSchema, f as WorkflowJobExecution_Status, ft as AuthConnection_Status, g as TailorDBGQLPermission_Action, gt as AuthInvokerSchema, h as UpdateTailorDBTypeRequestSchema, ht as AuthIDPConfig_AuthType, it as UpdateAuthIDPConfigRequestSchema, j as UpdatePipelineResolverRequestSchema, k as CreatePipelineResolverRequestSchema, kt as ApplicationSchemaUpdateAttemptStatus, l as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, lt as UpdateAuthServiceRequestSchema, m as CreateTailorDBTypeRequestSchema, mt as AuthHookPoint, nt as UpdateAuthConnectionRequestSchema, o as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as UpdateAuthOAuth2ClientRequestSchema, p as CreateTailorDBServiceRequestSchema, pt as AuthConnection_Type, q as CreateAuthHookRequestSchema, rt as UpdateAuthHookRequestSchema, s as CreateWorkflowJobFunctionRequestSchema, st as UpdateAuthSCIMConfigRequestSchema, t as OperatorService, tt as CreateUserProfileConfigRequestSchema, u as UpdateWorkflowRequestSchema, ut as UpdateTenantConfigRequestSchema, v as TailorDBGQLPermission_Permit, vt as AuthOAuth2Client_GrantType, w as UpdateStaticWebsiteRequestSchema, wt as TenantProviderConfig_TenantProviderType, x as TailorDBType_PermitAction, xt as AuthSCIMAttribute_Uniqueness, y as TailorDBType_Permission_Operator, yt as AuthSCIMAttribute_Mutability, z as FunctionExecution_Status } from "./service_pb-
|
|
11
|
+
import { $ as CreateAuthServiceRequestSchema, A as CreatePipelineServiceRequestSchema, At as Subgraph_ServiceType, C as CreateStaticWebsiteRequestSchema, D as CreateSecretManagerVaultRequestSchema, Dt as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, E as CreateSecretManagerSecretRequestSchema, Et as CreateApplicationRequestSchema, F as UpdateIdPServiceRequestSchema, G as ExecutorTriggerType, H as UpdateExecutorExecutorRequestSchema, I as IdPLang, J as CreateAuthIDPConfigRequestSchema, K as CreateAuthConnectionRequestSchema, L as IdPPermissionOperator, M as UpdatePipelineServiceRequestSchema, Mt as UpdateAIGatewayRequestSchema, N as PipelineResolver_OperationType, O as UpdateSecretManagerSecretRequestSchema, Ot as UpdateApplicationRequestSchema, P as CreateIdPServiceRequestSchema, Q as CreateAuthSCIMResourceRequestSchema, R as IdPPermissionPermit, S as AddCustomDomainRequestSchema, St as AuthSCIMConfig_AuthorizationType, Tt as UserProfileProviderConfig_UserProfileProviderType, U as ExecutorJobStatus, V as CreateExecutorExecutorRequestSchema, W as ExecutorTargetType, X as CreateAuthOAuth2ClientRequestSchema, Y as CreateAuthMachineUserRequestSchema, Z as CreateAuthSCIMConfigRequestSchema, _ as TailorDBGQLPermission_Operator, _t as AuthOAuth2Client_ClientType, a as WorkspacePlatformUserRole, at as UpdateAuthMachineUserRequestSchema, b as TailorDBType_Permission_Permit, bt as AuthSCIMAttribute_Type, c as CreateWorkflowRequestSchema, ct as UpdateAuthSCIMResourceRequestSchema, d as WorkflowExecution_Status, dt as UpdateUserProfileConfigRequestSchema, et as CreateTenantConfigRequestSchema, f as WorkflowJobExecution_Status, ft as AuthConnection_Status, g as TailorDBGQLPermission_Action, gt as AuthInvokerSchema, h as UpdateTailorDBTypeRequestSchema, ht as AuthIDPConfig_AuthType, it as UpdateAuthIDPConfigRequestSchema, j as UpdatePipelineResolverRequestSchema, jt as CreateAIGatewayRequestSchema, k as CreatePipelineResolverRequestSchema, kt as ApplicationSchemaUpdateAttemptStatus, l as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, lt as UpdateAuthServiceRequestSchema, m as CreateTailorDBTypeRequestSchema, mt as AuthHookPoint, nt as UpdateAuthConnectionRequestSchema, o as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as UpdateAuthOAuth2ClientRequestSchema, p as CreateTailorDBServiceRequestSchema, pt as AuthConnection_Type, q as CreateAuthHookRequestSchema, rt as UpdateAuthHookRequestSchema, s as CreateWorkflowJobFunctionRequestSchema, st as UpdateAuthSCIMConfigRequestSchema, t as OperatorService, tt as CreateUserProfileConfigRequestSchema, u as UpdateWorkflowRequestSchema, ut as UpdateTenantConfigRequestSchema, v as TailorDBGQLPermission_Permit, vt as AuthOAuth2Client_GrantType, w as UpdateStaticWebsiteRequestSchema, wt as TenantProviderConfig_TenantProviderType, x as TailorDBType_PermitAction, xt as AuthSCIMAttribute_Uniqueness, y as TailorDBType_Permission_Operator, yt as AuthSCIMAttribute_Mutability, z as FunctionExecution_Status } from "./service_pb-Bk7dL-yT.mjs";
|
|
12
12
|
import { r as withSpan } from "./telemetry-BRVdwh14.mjs";
|
|
13
13
|
import * as mod from "node:module";
|
|
14
14
|
import * as path from "pathe";
|
|
@@ -17,7 +17,7 @@ import { arg, createDefineCommand, defineCommand, runCommand } from "politty";
|
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import { ScalarType, create, fromJson, toJson } from "@bufbuild/protobuf";
|
|
19
19
|
import * as fs$1 from "node:fs";
|
|
20
|
-
import {
|
|
20
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
21
21
|
import { ValueSchema, timestampDate } from "@bufbuild/protobuf/wkt";
|
|
22
22
|
import { formatDistanceToNowStrict } from "date-fns";
|
|
23
23
|
import { getBorderCharacters, table } from "table";
|
|
@@ -2297,35 +2297,59 @@ const SecretsStateSchema = z.object({
|
|
|
2297
2297
|
vaults: z.record(z.string(), z.record(z.string(), z.string())),
|
|
2298
2298
|
connections: z.record(z.string(), z.string()).optional()
|
|
2299
2299
|
});
|
|
2300
|
+
const PersistedSecretsStateSchema = z.object({
|
|
2301
|
+
version: z.literal(1),
|
|
2302
|
+
workspaceId: z.string(),
|
|
2303
|
+
applicationKey: z.string(),
|
|
2304
|
+
state: SecretsStateSchema
|
|
2305
|
+
});
|
|
2300
2306
|
/**
|
|
2301
|
-
* Get the file path for
|
|
2302
|
-
* @
|
|
2307
|
+
* Get the file path for one workspace and application's secrets state JSON.
|
|
2308
|
+
* @param scope - Workspace and application identity for the deployment
|
|
2309
|
+
* @returns Absolute path to the scoped state file
|
|
2303
2310
|
*/
|
|
2304
|
-
function getSecretsStatePath() {
|
|
2305
|
-
|
|
2311
|
+
function getSecretsStatePath(scope) {
|
|
2312
|
+
const scopeHash = hashValue(JSON.stringify([scope.workspaceId, applicationStateKey(scope)]));
|
|
2313
|
+
return path.join(getDistDir(), "secrets-state", `${scopeHash}.json`);
|
|
2306
2314
|
}
|
|
2307
|
-
|
|
2308
|
-
* Load secrets hash state from disk.
|
|
2309
|
-
* @returns Persisted state, or empty state if file is missing or corrupted
|
|
2310
|
-
*/
|
|
2311
|
-
function loadSecretsState() {
|
|
2312
|
-
const filePath = getSecretsStatePath();
|
|
2313
|
-
if (!existsSync(filePath)) return { vaults: {} };
|
|
2315
|
+
function loadPersistedSecretsState(scope) {
|
|
2314
2316
|
try {
|
|
2315
|
-
const raw = readFileSync(
|
|
2316
|
-
|
|
2317
|
+
const raw = readFileSync(getSecretsStatePath(scope), "utf-8");
|
|
2318
|
+
const persistedState = PersistedSecretsStateSchema.parse(JSON.parse(raw));
|
|
2319
|
+
if (persistedState.workspaceId !== scope.workspaceId || persistedState.applicationKey !== applicationStateKey(scope)) return;
|
|
2320
|
+
return persistedState;
|
|
2317
2321
|
} catch {
|
|
2318
|
-
return
|
|
2322
|
+
return;
|
|
2319
2323
|
}
|
|
2320
2324
|
}
|
|
2325
|
+
function applicationStateKey(scope) {
|
|
2326
|
+
if (!scope.applicationId) throw new Error(`Application "${scope.applicationName}" has no stable id for secrets state`);
|
|
2327
|
+
return `id:${scope.applicationId}`;
|
|
2328
|
+
}
|
|
2321
2329
|
/**
|
|
2322
|
-
*
|
|
2330
|
+
* Load secrets hash state for one workspace and application from disk.
|
|
2331
|
+
* @param scope - Workspace and application identity for the deployment
|
|
2332
|
+
* @returns Persisted state, or empty state if the scope is missing or the file is invalid
|
|
2333
|
+
*/
|
|
2334
|
+
function loadSecretsState(scope) {
|
|
2335
|
+
if (!scope.applicationId) return { vaults: {} };
|
|
2336
|
+
return loadPersistedSecretsState(scope)?.state ?? { vaults: {} };
|
|
2337
|
+
}
|
|
2338
|
+
/**
|
|
2339
|
+
* Save secrets hash state for one workspace and application to disk.
|
|
2340
|
+
* @param scope - Workspace and application identity for the deployment
|
|
2323
2341
|
* @param state - The secrets state to persist
|
|
2324
2342
|
*/
|
|
2325
|
-
function saveSecretsState(state) {
|
|
2326
|
-
|
|
2343
|
+
function saveSecretsState(scope, state) {
|
|
2344
|
+
if (!scope.applicationId) return;
|
|
2345
|
+
const filePath = getSecretsStatePath(scope);
|
|
2327
2346
|
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
2328
|
-
writeFileSync(filePath, JSON.stringify(
|
|
2347
|
+
writeFileSync(filePath, JSON.stringify({
|
|
2348
|
+
version: 1,
|
|
2349
|
+
workspaceId: scope.workspaceId,
|
|
2350
|
+
applicationKey: applicationStateKey(scope),
|
|
2351
|
+
state
|
|
2352
|
+
}, null, 2), "utf-8");
|
|
2329
2353
|
}
|
|
2330
2354
|
/**
|
|
2331
2355
|
* Compute SHA-256 hex digest of a value.
|
|
@@ -2391,6 +2415,11 @@ function buildUpdateMask(existing, desired, secretChanged) {
|
|
|
2391
2415
|
* @returns Planned changes for auth connections
|
|
2392
2416
|
*/
|
|
2393
2417
|
async function planAuthConnections(client, workspaceId, appName, appId, auths) {
|
|
2418
|
+
const stateScope = {
|
|
2419
|
+
workspaceId,
|
|
2420
|
+
applicationId: appId,
|
|
2421
|
+
applicationName: appName
|
|
2422
|
+
};
|
|
2394
2423
|
const changeSet = createChangeSet("Auth connections");
|
|
2395
2424
|
const conflicts = [];
|
|
2396
2425
|
const unmanaged = [];
|
|
@@ -2414,7 +2443,7 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
|
|
|
2414
2443
|
allLabels: metadata?.labels
|
|
2415
2444
|
};
|
|
2416
2445
|
}));
|
|
2417
|
-
const state = loadSecretsState();
|
|
2446
|
+
const state = loadSecretsState(stateScope);
|
|
2418
2447
|
for (const [name, config] of Object.entries(desiredConnections)) {
|
|
2419
2448
|
const existing = existingConnections[name];
|
|
2420
2449
|
const metaRequest = await buildMetaRequest({
|
|
@@ -2475,7 +2504,8 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
|
|
|
2475
2504
|
changeSet,
|
|
2476
2505
|
conflicts,
|
|
2477
2506
|
unmanaged,
|
|
2478
|
-
resourceOwners
|
|
2507
|
+
resourceOwners,
|
|
2508
|
+
stateScope
|
|
2479
2509
|
};
|
|
2480
2510
|
}
|
|
2481
2511
|
/**
|
|
@@ -2485,7 +2515,7 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
|
|
|
2485
2515
|
* @param phase - Apply phase
|
|
2486
2516
|
*/
|
|
2487
2517
|
async function applyAuthConnections(client, result, phase) {
|
|
2488
|
-
const { changeSet } = result;
|
|
2518
|
+
const { changeSet, stateScope } = result;
|
|
2489
2519
|
if (phase === "create-update") {
|
|
2490
2520
|
await Promise.all(changeSet.creates.map(async (create) => {
|
|
2491
2521
|
await client.createAuthConnection(create.request);
|
|
@@ -2499,26 +2529,29 @@ async function applyAuthConnections(client, result, phase) {
|
|
|
2499
2529
|
await Promise.all(changeSet.updates.map(async (update) => {
|
|
2500
2530
|
await client.setMetadata(update.metaRequest);
|
|
2501
2531
|
}));
|
|
2502
|
-
const
|
|
2503
|
-
if (
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2532
|
+
const secretReplaces = changeSet.replaces.filter((replace) => replace.updateRequest.updateMask?.paths?.includes("oauth2.client_secret"));
|
|
2533
|
+
if (changeSet.creates.length > 0 || secretReplaces.length > 0) {
|
|
2534
|
+
const state = loadSecretsState(stateScope);
|
|
2535
|
+
if (!state.connections) state.connections = {};
|
|
2536
|
+
for (const create of changeSet.creates) {
|
|
2537
|
+
const conn = create.request.connection;
|
|
2538
|
+
if (conn?.config?.case === "oauth2") state.connections[create.name] = hashValue(conn.config.value.clientSecret ?? "");
|
|
2539
|
+
}
|
|
2540
|
+
for (const replace of secretReplaces) {
|
|
2541
|
+
const conn = replace.updateRequest.connection;
|
|
2542
|
+
if (conn?.config?.case === "oauth2") state.connections[replace.name] = hashValue(conn.config.value.clientSecret ?? "");
|
|
2543
|
+
}
|
|
2544
|
+
saveSecretsState(stateScope, state);
|
|
2511
2545
|
}
|
|
2512
|
-
saveSecretsState(state);
|
|
2513
2546
|
} else {
|
|
2514
2547
|
await Promise.all(changeSet.deletes.map(async (del) => {
|
|
2515
2548
|
await client.deleteAuthConnection(del.request);
|
|
2516
2549
|
}));
|
|
2517
2550
|
if (changeSet.deletes.length > 0) {
|
|
2518
|
-
const state = loadSecretsState();
|
|
2551
|
+
const state = loadSecretsState(stateScope);
|
|
2519
2552
|
if (state.connections) {
|
|
2520
2553
|
for (const del of changeSet.deletes) delete state.connections[del.name];
|
|
2521
|
-
saveSecretsState(state);
|
|
2554
|
+
saveSecretsState(stateScope, state);
|
|
2522
2555
|
}
|
|
2523
2556
|
}
|
|
2524
2557
|
}
|
|
@@ -3681,7 +3714,10 @@ async function applyAuth(client, result, phase = "create-update") {
|
|
|
3681
3714
|
await Promise.all([...changeSet.machineUser.creates.map((create) => client.createAuthMachineUser(create.request)), ...changeSet.machineUser.updates.map((update) => client.updateAuthMachineUser(update.request))]);
|
|
3682
3715
|
};
|
|
3683
3716
|
const applyCreateUpdateDependents = async () => {
|
|
3684
|
-
await applyAuthConnections(client, {
|
|
3717
|
+
await applyAuthConnections(client, {
|
|
3718
|
+
changeSet: changeSet.connection,
|
|
3719
|
+
stateScope: result.connectionStateScope
|
|
3720
|
+
}, "create-update");
|
|
3685
3721
|
await Promise.all([...changeSet.idpConfig.creates.map(async (create) => {
|
|
3686
3722
|
if (create.idpConfig.kind === "BuiltInIdP") assertDefined(create.request.idpConfig, "request missing idpConfig").config = await protoBuiltinIdPConfig(client, assertDefined(create.request.workspaceId, "request missing workspaceId"), create.idpConfig);
|
|
3687
3723
|
return client.createAuthIDPConfig(create.request);
|
|
@@ -3724,7 +3760,10 @@ async function applyAuth(client, result, phase = "create-update") {
|
|
|
3724
3760
|
await Promise.all(changeSet.tenantConfig.deletes.map((del) => client.deleteTenantConfig(del.request)));
|
|
3725
3761
|
await Promise.all(changeSet.userProfileConfig.deletes.map((del) => client.deleteUserProfileConfig(del.request)));
|
|
3726
3762
|
await Promise.all(changeSet.idpConfig.deletes.map((del) => client.deleteAuthIDPConfig(del.request)));
|
|
3727
|
-
await applyAuthConnections(client, {
|
|
3763
|
+
await applyAuthConnections(client, {
|
|
3764
|
+
changeSet: changeSet.connection,
|
|
3765
|
+
stateScope: result.connectionStateScope
|
|
3766
|
+
}, "delete-resources");
|
|
3728
3767
|
} else if (phase === "delete-services") await Promise.all(changeSet.service.deletes.map((del) => client.deleteAuthService(del.request)));
|
|
3729
3768
|
}
|
|
3730
3769
|
/**
|
|
@@ -3768,7 +3807,8 @@ async function planAuth(context) {
|
|
|
3768
3807
|
},
|
|
3769
3808
|
conflicts: [...conflicts, ...connectionResult.conflicts],
|
|
3770
3809
|
unmanaged: [...unmanaged, ...connectionResult.unmanaged],
|
|
3771
|
-
resourceOwners: /* @__PURE__ */ new Set([...resourceOwners, ...connectionResult.resourceOwners])
|
|
3810
|
+
resourceOwners: /* @__PURE__ */ new Set([...resourceOwners, ...connectionResult.resourceOwners]),
|
|
3811
|
+
connectionStateScope: connectionResult.stateScope
|
|
3772
3812
|
};
|
|
3773
3813
|
}
|
|
3774
3814
|
async function planServices$2(client, workspaceId, appName, appId, auths, forceApplyAll = false) {
|
|
@@ -5644,7 +5684,12 @@ async function planSecretManager(context) {
|
|
|
5644
5684
|
getName: (resource) => resource.name,
|
|
5645
5685
|
getTrn: (name) => resourceTrn(workspaceId, "vault", name)
|
|
5646
5686
|
});
|
|
5647
|
-
const
|
|
5687
|
+
const stateScope = {
|
|
5688
|
+
workspaceId,
|
|
5689
|
+
applicationId: application.id,
|
|
5690
|
+
applicationName: application.name
|
|
5691
|
+
};
|
|
5692
|
+
const state = loadSecretsState(stateScope);
|
|
5648
5693
|
const skippedSecrets = [];
|
|
5649
5694
|
await Promise.all(secretVaults.map(async (vault) => {
|
|
5650
5695
|
const vaultName = vault.vaultName;
|
|
@@ -5753,7 +5798,8 @@ async function planSecretManager(context) {
|
|
|
5753
5798
|
skippedSecrets,
|
|
5754
5799
|
conflicts,
|
|
5755
5800
|
unmanaged,
|
|
5756
|
-
resourceOwners
|
|
5801
|
+
resourceOwners,
|
|
5802
|
+
stateScope
|
|
5757
5803
|
};
|
|
5758
5804
|
}
|
|
5759
5805
|
/**
|
|
@@ -5761,11 +5807,11 @@ async function planSecretManager(context) {
|
|
|
5761
5807
|
* @param client - Operator client instance
|
|
5762
5808
|
* @param result - Planned secret changes
|
|
5763
5809
|
* @param phase - Apply phase
|
|
5764
|
-
* @param application - Application
|
|
5810
|
+
* @param application - Application used for ownership metadata and hash state persistence
|
|
5765
5811
|
* @returns Promise that resolves when secret changes are applied
|
|
5766
5812
|
*/
|
|
5767
5813
|
async function applySecretManager(client, result, phase = "create-update", application) {
|
|
5768
|
-
const { vaultChangeSet, secretChangeSet } = result;
|
|
5814
|
+
const { vaultChangeSet, secretChangeSet, stateScope } = result;
|
|
5769
5815
|
if (phase === "create-update") {
|
|
5770
5816
|
await Promise.all(vaultChangeSet.creates.map(async (create) => {
|
|
5771
5817
|
await client.createSecretManagerVault(vaultCreateRequest(create));
|
|
@@ -5788,13 +5834,14 @@ async function applySecretManager(client, result, phase = "create-update", appli
|
|
|
5788
5834
|
}));
|
|
5789
5835
|
await Promise.all(secretChangeSet.creates.map((create) => client.createSecretManagerSecret(secretCreateRequest(create))));
|
|
5790
5836
|
await Promise.all(secretChangeSet.updates.map((update) => client.updateSecretManagerSecret(secretUpdateRequest(update))));
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5837
|
+
const secretHashUpdates = [...secretChangeSet.creates, ...secretChangeSet.updates];
|
|
5838
|
+
if (application && secretHashUpdates.length > 0) {
|
|
5839
|
+
const state = loadSecretsState(stateScope);
|
|
5840
|
+
for (const secret of secretHashUpdates) {
|
|
5841
|
+
if (!Object.hasOwn(state.vaults, secret.vaultName)) state.vaults[secret.vaultName] = {};
|
|
5842
|
+
assertDefined(state.vaults[secret.vaultName], "vault state entry missing")[secret.secretName] = hashValue(secret.value);
|
|
5796
5843
|
}
|
|
5797
|
-
saveSecretsState(state);
|
|
5844
|
+
saveSecretsState(stateScope, state);
|
|
5798
5845
|
}
|
|
5799
5846
|
} else {
|
|
5800
5847
|
await Promise.all(secretChangeSet.deletes.map((del) => client.deleteSecretManagerSecret({
|
|
@@ -5807,13 +5854,13 @@ async function applySecretManager(client, result, phase = "create-update", appli
|
|
|
5807
5854
|
secretmanagerVaultName: del.name
|
|
5808
5855
|
})));
|
|
5809
5856
|
if (secretChangeSet.deletes.length > 0 || vaultChangeSet.deletes.length > 0) {
|
|
5810
|
-
const state = loadSecretsState();
|
|
5857
|
+
const state = loadSecretsState(stateScope);
|
|
5811
5858
|
for (const del of secretChangeSet.deletes) if (Object.hasOwn(state.vaults, del.vaultName)) {
|
|
5812
5859
|
delete assertDefined(state.vaults[del.vaultName], "vault state entry missing")[del.secretName];
|
|
5813
5860
|
if (Object.keys(assertDefined(state.vaults[del.vaultName], "vault state entry missing")).length === 0) delete state.vaults[del.vaultName];
|
|
5814
5861
|
}
|
|
5815
5862
|
for (const del of vaultChangeSet.deletes) delete state.vaults[del.name];
|
|
5816
|
-
saveSecretsState(state);
|
|
5863
|
+
saveSecretsState(stateScope, state);
|
|
5817
5864
|
}
|
|
5818
5865
|
}
|
|
5819
5866
|
}
|
|
@@ -5908,6 +5955,7 @@ function formatDiffChange(change) {
|
|
|
5908
5955
|
case "relationship_removed": return ` - [Relationship${change.relationshipType ? ` (${change.relationshipType})` : ""}] ${change.relationshipName}`;
|
|
5909
5956
|
case "relationship_modified": return ` ~ [Relationship${change.relationshipType ? ` (${change.relationshipType})` : ""}] ${change.relationshipName}: ${change.reason ?? "modified"}`;
|
|
5910
5957
|
case "permission_modified": return ` ~ [Permission] ${change.reason ?? "modified"}`;
|
|
5958
|
+
case "type_scripts_modified": return ` ~ [Type Scripts] ${change.typeName}: ${change.reason ?? "type-level hooks/validate changed"}`;
|
|
5911
5959
|
default: {
|
|
5912
5960
|
const unknown = change;
|
|
5913
5961
|
return ` ? ${unknown.typeName}.${unknown.fieldName ?? ""}`;
|
|
@@ -6002,7 +6050,8 @@ const DIFF_CHANGE_LABELS = {
|
|
|
6002
6050
|
relationship_added: "relationship(s) added",
|
|
6003
6051
|
relationship_removed: "relationship(s) removed",
|
|
6004
6052
|
relationship_modified: "relationship(s) modified",
|
|
6005
|
-
permission_modified: "permission(s) modified"
|
|
6053
|
+
permission_modified: "permission(s) modified",
|
|
6054
|
+
type_scripts_modified: "type script(s) modified"
|
|
6006
6055
|
};
|
|
6007
6056
|
/**
|
|
6008
6057
|
* Format a summary of the migration diff
|
|
@@ -6016,6 +6065,181 @@ function formatDiffSummary(diff) {
|
|
|
6016
6065
|
return parts.length > 0 ? parts.join(", ") : "No changes";
|
|
6017
6066
|
}
|
|
6018
6067
|
|
|
6068
|
+
//#endregion
|
|
6069
|
+
//#region src/parser/service/tailordb/type-script.ts
|
|
6070
|
+
const INPUT = "_input";
|
|
6071
|
+
const NEW_RECORD = "_newRecord";
|
|
6072
|
+
const OLD_RECORD = "_oldRecord";
|
|
6073
|
+
const NOW = "_now";
|
|
6074
|
+
const SOURCE_HASH_PREFIX = "// @sdk-source-hash:";
|
|
6075
|
+
const TIME_TYPES = /* @__PURE__ */ new Set([
|
|
6076
|
+
"datetime",
|
|
6077
|
+
"date",
|
|
6078
|
+
"time"
|
|
6079
|
+
]);
|
|
6080
|
+
const key = (name) => JSON.stringify(name);
|
|
6081
|
+
function collectFieldScriptSources(fields) {
|
|
6082
|
+
const entries = [];
|
|
6083
|
+
for (const [name, config] of Object.entries(fields).toSorted(([a], [b]) => a.localeCompare(b))) {
|
|
6084
|
+
const data = {};
|
|
6085
|
+
if (config.hooks?.create?.expr) data.hc = config.hooks.create.expr;
|
|
6086
|
+
if (config.hooks?.update?.expr) data.hu = config.hooks.update.expr;
|
|
6087
|
+
if (config.validate?.some((v) => v.script?.expr)) data.v = config.validate.filter((v) => v.script?.expr).map((v) => [v.script?.expr, v.errorMessage]);
|
|
6088
|
+
if (config.default !== void 0) {
|
|
6089
|
+
data.d = config.default instanceof Date ? config.default.toISOString() : config.default;
|
|
6090
|
+
data.t = config.type;
|
|
6091
|
+
}
|
|
6092
|
+
if (config.fields) {
|
|
6093
|
+
const nested = collectFieldScriptSources(config.fields);
|
|
6094
|
+
if (nested.length > 0) {
|
|
6095
|
+
data.f = nested;
|
|
6096
|
+
data.a = !!config.array;
|
|
6097
|
+
}
|
|
6098
|
+
}
|
|
6099
|
+
if (Object.keys(data).length > 0) entries.push([name, data]);
|
|
6100
|
+
}
|
|
6101
|
+
return entries;
|
|
6102
|
+
}
|
|
6103
|
+
function computeSourceScriptHash(fields, options) {
|
|
6104
|
+
const fieldSources = collectFieldScriptSources(fields);
|
|
6105
|
+
if (!(fieldSources.length > 0 || options?.typeHookExpr?.create || options?.typeHookExpr?.update || options?.typeValidateExpr)) return void 0;
|
|
6106
|
+
const payload = [fieldSources];
|
|
6107
|
+
if (options?.typeHookExpr?.create) payload.push(["thc", options.typeHookExpr.create]);
|
|
6108
|
+
if (options?.typeHookExpr?.update) payload.push(["thu", options.typeHookExpr.update]);
|
|
6109
|
+
if (options?.typeValidateExpr) payload.push(["tve", options.typeValidateExpr]);
|
|
6110
|
+
return createHash("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
6111
|
+
}
|
|
6112
|
+
function extractSourceScriptHash(expr) {
|
|
6113
|
+
return expr.match(/\/\/ @sdk-source-hash:([0-9a-f]+)\s*$/)?.[1];
|
|
6114
|
+
}
|
|
6115
|
+
const isNestedType = (config) => config.type === "nested" && config.fields !== void 0;
|
|
6116
|
+
function serializeDefault(value, fieldType) {
|
|
6117
|
+
if (value === "now" && TIME_TYPES.has(fieldType)) return NOW;
|
|
6118
|
+
if (value instanceof Date) return `new Date(${JSON.stringify(value.toISOString())})`;
|
|
6119
|
+
return JSON.stringify(value);
|
|
6120
|
+
}
|
|
6121
|
+
/**
|
|
6122
|
+
* Build the object literal that reconstructs one record level with hook
|
|
6123
|
+
* overrides and defaults applied. For create, defaults are appended as
|
|
6124
|
+
* `?? defaultValue` after the hook expression (field hook → default).
|
|
6125
|
+
* Returns null when no field under this level has a hook or default for
|
|
6126
|
+
* the operation.
|
|
6127
|
+
* @param {Record<string, ScriptFieldConfig>} fields - Field configurations
|
|
6128
|
+
* @param {string} accessExpr - JS expression to access the parent object
|
|
6129
|
+
* @param {string} oldAccessExpr - JS expression to access the old record parent
|
|
6130
|
+
* @param {HookOperation} operation - Hook operation type
|
|
6131
|
+
* @param {boolean} nested - Whether building inside a nested field (rejects defaults)
|
|
6132
|
+
* @returns {string | null} Object literal expression or null
|
|
6133
|
+
*/
|
|
6134
|
+
function buildHookObject(fields, accessExpr, oldAccessExpr, operation, nested = false) {
|
|
6135
|
+
const parts = [];
|
|
6136
|
+
for (const [name, config] of Object.entries(fields)) {
|
|
6137
|
+
const access = `${accessExpr}[${key(name)}]`;
|
|
6138
|
+
const oldAccess = `${oldAccessExpr}?.[${key(name)}]`;
|
|
6139
|
+
if (isNestedType(config) && config.fields) {
|
|
6140
|
+
if (config.array) {
|
|
6141
|
+
const inner = buildHookObject(config.fields, "__el", "undefined", operation, true);
|
|
6142
|
+
if (inner !== null) parts.push(`${key(name)}: (${access} || []).map((__el) => Object.assign({}, __el, ${inner}))`);
|
|
6143
|
+
} else {
|
|
6144
|
+
const inner = buildHookObject(config.fields, `(${access} || {})`, oldAccess, operation, true);
|
|
6145
|
+
if (inner !== null) parts.push(`${key(name)}: Object.assign({}, ${access}, ${inner})`);
|
|
6146
|
+
}
|
|
6147
|
+
continue;
|
|
6148
|
+
}
|
|
6149
|
+
const hook = config.hooks?.[operation];
|
|
6150
|
+
if (nested && config.default !== void 0) throw new Error(`.default() cannot be used on nested inner field "${name}"`);
|
|
6151
|
+
const hasDefault = operation === "create" && config.default !== void 0;
|
|
6152
|
+
if (hook && hasDefault) parts.push(`${key(name)}: ((_value) => (${hook.expr}))(${access}) ?? ${serializeDefault(config.default, config.type)}`);
|
|
6153
|
+
else if (hook && operation === "create") parts.push(`${key(name)}: ((_value) => (${hook.expr}))(${access})`);
|
|
6154
|
+
else if (hook) parts.push(`${key(name)}: ((_value, _oldValue) => (${hook.expr}))(${access}, ${oldAccess} ?? null)`);
|
|
6155
|
+
else if (hasDefault) parts.push(`${key(name)}: ${access} ?? ${serializeDefault(config.default, config.type)}`);
|
|
6156
|
+
}
|
|
6157
|
+
if (parts.length === 0) return null;
|
|
6158
|
+
return `{ ${parts.join(", ")} }`;
|
|
6159
|
+
}
|
|
6160
|
+
/**
|
|
6161
|
+
* Build validation statements for one record level.
|
|
6162
|
+
* Each leaf field with validators contributes a block that runs every
|
|
6163
|
+
* validator and records all failing messages keyed by dotted field path.
|
|
6164
|
+
* @param {Record<string, ScriptFieldConfig>} fields - Field configurations
|
|
6165
|
+
* @param {string} accessExpr - JS expression to access the parent object
|
|
6166
|
+
* @param {string} keyPrefix - Dotted path prefix for error keys
|
|
6167
|
+
* @returns {string[]} Array of validation statement strings
|
|
6168
|
+
*/
|
|
6169
|
+
function buildValidateStatements(fields, accessExpr, keyPrefix) {
|
|
6170
|
+
const statements = [];
|
|
6171
|
+
for (const [name, config] of Object.entries(fields)) {
|
|
6172
|
+
const access = `${accessExpr}[${key(name)}]`;
|
|
6173
|
+
const fieldPath = keyPrefix ? `${keyPrefix}.${name}` : name;
|
|
6174
|
+
const validators = (config.validate ?? []).filter((v) => v.script?.expr);
|
|
6175
|
+
if (validators.length > 0) {
|
|
6176
|
+
const checks = validators.map((v) => `{ const __r = (${v.script?.expr}); if (typeof __r === "string") { __errs[${key(fieldPath)}] = __r; } }`).join("\n");
|
|
6177
|
+
statements.push(`{ const _value = ${access};\n${checks}\n}`);
|
|
6178
|
+
}
|
|
6179
|
+
if (isNestedType(config) && config.fields) if (config.array) {
|
|
6180
|
+
const innerParts = [];
|
|
6181
|
+
for (const [innerName, innerConfig] of Object.entries(config.fields)) {
|
|
6182
|
+
const innerValidators = (innerConfig.validate ?? []).filter((v) => v.script?.expr);
|
|
6183
|
+
if (innerValidators.length > 0) {
|
|
6184
|
+
const errorKeyExpr = `${JSON.stringify(fieldPath + "[")} + __idx + ${JSON.stringify("]." + innerName)}`;
|
|
6185
|
+
const checks = innerValidators.map((v) => `{ const __r = (${v.script?.expr}); if (typeof __r === "string") { __errs[${errorKeyExpr}] = __r; } }`).join("\n");
|
|
6186
|
+
innerParts.push(`{ const _value = __el[${key(innerName)}];\n${checks}\n}`);
|
|
6187
|
+
}
|
|
6188
|
+
}
|
|
6189
|
+
if (innerParts.length > 0) statements.push(`(${access} || []).forEach((__el, __idx) => {\n${innerParts.join("\n")}\n});`);
|
|
6190
|
+
} else {
|
|
6191
|
+
const nested = buildValidateStatements(config.fields, access, fieldPath);
|
|
6192
|
+
if (nested.length > 0) statements.push(`if (${access} != null) {\n${nested.join("\n")}\n}`);
|
|
6193
|
+
}
|
|
6194
|
+
}
|
|
6195
|
+
return statements;
|
|
6196
|
+
}
|
|
6197
|
+
function wrapHook(objectExpr) {
|
|
6198
|
+
return `((_invoker) => { const ${NOW} = new Date(); return ${objectExpr}; })(typeof _invoker !== "undefined" ? _invoker : undefined)`;
|
|
6199
|
+
}
|
|
6200
|
+
function wrapValidate(statements, typeValidateExpr) {
|
|
6201
|
+
const issuesFn = typeValidateExpr ? " const __issues = (f, m) => { __errs[f] = m; };" : "";
|
|
6202
|
+
const typeValidateStmt = typeValidateExpr ? ` ${typeValidateExpr};` : "";
|
|
6203
|
+
return `((_invoker) => { const __errs = {};${issuesFn}\n${statements.join("\n")}${typeValidateStmt}\nreturn __errs; })(typeof _invoker !== "undefined" ? _invoker : undefined)`;
|
|
6204
|
+
}
|
|
6205
|
+
/**
|
|
6206
|
+
* Aggregate every field's create/update hook, default, and validate into
|
|
6207
|
+
* type-level scripts. Hooks compute a single shared timestamp (`now`) per
|
|
6208
|
+
* operation, so all fields touched in one create/update observe the same
|
|
6209
|
+
* instant. Defaults are applied after hooks on create only. Validators
|
|
6210
|
+
* run with the same rules on create and update.
|
|
6211
|
+
* @param fields - Per-field script configuration
|
|
6212
|
+
* @param options - Optional type-level hook/validate expressions
|
|
6213
|
+
* @returns Aggregated type-level scripts
|
|
6214
|
+
*/
|
|
6215
|
+
function buildTypeScripts(fields, options) {
|
|
6216
|
+
const result = {};
|
|
6217
|
+
const typeHookExpr = options?.typeHookExpr;
|
|
6218
|
+
const typeValidateExpr = options?.typeValidateExpr;
|
|
6219
|
+
const hash = computeSourceScriptHash(fields, options);
|
|
6220
|
+
const hashSuffix = hash ? ` ${SOURCE_HASH_PREFIX}${hash}` : "";
|
|
6221
|
+
const hook = {};
|
|
6222
|
+
for (const operation of ["create", "update"]) {
|
|
6223
|
+
const perFieldExpr = buildHookObject(fields, INPUT, OLD_RECORD, operation);
|
|
6224
|
+
const typeLevelExpr = typeHookExpr?.[operation];
|
|
6225
|
+
let expr;
|
|
6226
|
+
if (perFieldExpr !== null && typeLevelExpr) expr = `((_invoker) => { const ${NOW} = new Date(); const __fl = ${perFieldExpr}; return Object.assign({}, __fl, ((${INPUT}) => ${typeLevelExpr})(Object.assign({}, ${INPUT}, __fl))); })(typeof _invoker !== "undefined" ? _invoker : undefined)`;
|
|
6227
|
+
else if (typeLevelExpr) expr = wrapHook(typeLevelExpr);
|
|
6228
|
+
else if (perFieldExpr !== null) expr = wrapHook(perFieldExpr);
|
|
6229
|
+
if (expr) hook[operation] = { expr: expr + hashSuffix };
|
|
6230
|
+
}
|
|
6231
|
+
if (hook.create || hook.update) result.typeHook = hook;
|
|
6232
|
+
const statements = buildValidateStatements(fields, NEW_RECORD, "");
|
|
6233
|
+
if (statements.length > 0 || typeValidateExpr) {
|
|
6234
|
+
const expr = wrapValidate(statements, typeValidateExpr) + hashSuffix;
|
|
6235
|
+
result.typeValidate = {
|
|
6236
|
+
create: { expr },
|
|
6237
|
+
update: { expr }
|
|
6238
|
+
};
|
|
6239
|
+
}
|
|
6240
|
+
return result;
|
|
6241
|
+
}
|
|
6242
|
+
|
|
6019
6243
|
//#endregion
|
|
6020
6244
|
//#region src/cli/commands/tailordb/migrate/migration-number.ts
|
|
6021
6245
|
/**
|
|
@@ -6107,6 +6331,7 @@ const snapshotFieldConfigSchema = z.looseObject({
|
|
|
6107
6331
|
validate: z.array(snapshotValidationSchema).optional(),
|
|
6108
6332
|
serial: snapshotSerialSchema.optional(),
|
|
6109
6333
|
scale: z.number().optional(),
|
|
6334
|
+
default: z.unknown().optional(),
|
|
6110
6335
|
fields: z.lazy(() => snapshotRecordSchema(snapshotFieldConfigSchema)).optional()
|
|
6111
6336
|
});
|
|
6112
6337
|
const snapshotIndexConfigSchema = z.looseObject({
|
|
@@ -6352,6 +6577,20 @@ const permissionModifiedChangeSchema = z.looseObject({
|
|
|
6352
6577
|
before: snapshotPermissionStateSchema.optional(),
|
|
6353
6578
|
after: snapshotPermissionStateSchema.optional()
|
|
6354
6579
|
});
|
|
6580
|
+
const typeScriptsStateSchema = z.looseObject({
|
|
6581
|
+
typeHookExpr: z.looseObject({
|
|
6582
|
+
create: z.string().optional(),
|
|
6583
|
+
update: z.string().optional()
|
|
6584
|
+
}).optional(),
|
|
6585
|
+
typeValidateExpr: z.string().optional()
|
|
6586
|
+
});
|
|
6587
|
+
const typeScriptsModifiedChangeSchema = z.looseObject({
|
|
6588
|
+
kind: z.literal("type_scripts_modified"),
|
|
6589
|
+
typeName: z.string(),
|
|
6590
|
+
reason: z.string().optional(),
|
|
6591
|
+
before: typeScriptsStateSchema,
|
|
6592
|
+
after: typeScriptsStateSchema
|
|
6593
|
+
});
|
|
6355
6594
|
const diffChangeSchema = z.discriminatedUnion("kind", [
|
|
6356
6595
|
typeAddedChangeSchema,
|
|
6357
6596
|
typeRemovedChangeSchema,
|
|
@@ -6369,7 +6608,8 @@ const diffChangeSchema = z.discriminatedUnion("kind", [
|
|
|
6369
6608
|
relationshipAddedChangeSchema,
|
|
6370
6609
|
relationshipRemovedChangeSchema,
|
|
6371
6610
|
relationshipModifiedChangeSchema,
|
|
6372
|
-
permissionModifiedChangeSchema
|
|
6611
|
+
permissionModifiedChangeSchema,
|
|
6612
|
+
typeScriptsModifiedChangeSchema
|
|
6373
6613
|
]);
|
|
6374
6614
|
const breakingChangeInfoSchema = z.looseObject({
|
|
6375
6615
|
typeName: z.string(),
|
|
@@ -6573,6 +6813,7 @@ function createSnapshotFieldConfigFromOperatorConfig(fieldConfig) {
|
|
|
6573
6813
|
...fieldConfig.serial.format && { format: fieldConfig.serial.format }
|
|
6574
6814
|
};
|
|
6575
6815
|
if (fieldConfig.scale !== void 0) config.scale = fieldConfig.scale;
|
|
6816
|
+
if (fieldConfig.default !== void 0) config.default = fieldConfig.default;
|
|
6576
6817
|
if (fieldConfig.fields && Object.keys(fieldConfig.fields).length > 0) {
|
|
6577
6818
|
config.fields = {};
|
|
6578
6819
|
for (const [nestedName, nestedConfig] of Object.entries(fieldConfig.fields)) config.fields[nestedName] = createSnapshotFieldConfigFromOperatorConfig(nestedConfig);
|
|
@@ -6614,6 +6855,8 @@ function createSnapshotType(type) {
|
|
|
6614
6855
|
};
|
|
6615
6856
|
}
|
|
6616
6857
|
if (type.files && Object.keys(type.files).length > 0) snapshotType.files = { ...type.files };
|
|
6858
|
+
if (type.typeHookExpr) snapshotType.typeHookExpr = type.typeHookExpr;
|
|
6859
|
+
if (type.typeValidateExpr) snapshotType.typeValidateExpr = type.typeValidateExpr;
|
|
6617
6860
|
if (Object.keys(type.forwardRelationships).length > 0) {
|
|
6618
6861
|
snapshotType.forwardRelationships = {};
|
|
6619
6862
|
for (const [relName, rel] of Object.entries(type.forwardRelationships)) snapshotType.forwardRelationships[relName] = {
|
|
@@ -6797,6 +7040,18 @@ function applyDiffToSnapshot(snapshot, diff) {
|
|
|
6797
7040
|
};
|
|
6798
7041
|
break;
|
|
6799
7042
|
}
|
|
7043
|
+
case "type_scripts_modified": {
|
|
7044
|
+
const existing = types[change.typeName];
|
|
7045
|
+
if (existing) {
|
|
7046
|
+
const { typeHookExpr: _, typeValidateExpr: __, ...rest } = existing;
|
|
7047
|
+
types[change.typeName] = {
|
|
7048
|
+
...rest,
|
|
7049
|
+
...change.after.typeHookExpr && { typeHookExpr: change.after.typeHookExpr },
|
|
7050
|
+
...change.after.typeValidateExpr !== void 0 && { typeValidateExpr: change.after.typeValidateExpr }
|
|
7051
|
+
};
|
|
7052
|
+
}
|
|
7053
|
+
break;
|
|
7054
|
+
}
|
|
6800
7055
|
case "field_added":
|
|
6801
7056
|
case "field_modified": {
|
|
6802
7057
|
const existing = types[change.typeName];
|
|
@@ -7021,6 +7276,10 @@ function areFieldsDifferent(oldField, newField) {
|
|
|
7021
7276
|
if ((oldSerial.format ?? "") !== (newSerial.format ?? "")) return true;
|
|
7022
7277
|
}
|
|
7023
7278
|
if (oldField.scale !== newField.scale) return true;
|
|
7279
|
+
if (oldField.default !== newField.default) {
|
|
7280
|
+
if (typeof oldField.default !== typeof newField.default) return true;
|
|
7281
|
+
if (JSON.stringify(oldField.default) !== JSON.stringify(newField.default)) return true;
|
|
7282
|
+
}
|
|
7024
7283
|
const oldFields = oldField.fields ?? {};
|
|
7025
7284
|
const newFields = newField.fields ?? {};
|
|
7026
7285
|
const oldFieldNames = Object.keys(oldFields);
|
|
@@ -7383,6 +7642,24 @@ function compareTypeSettings(ctx, typeName, previous, current) {
|
|
|
7383
7642
|
after: snapshotTypeSettingsState(current)
|
|
7384
7643
|
});
|
|
7385
7644
|
}
|
|
7645
|
+
function typeScriptsState(type) {
|
|
7646
|
+
return {
|
|
7647
|
+
...type.typeHookExpr && { typeHookExpr: type.typeHookExpr },
|
|
7648
|
+
...type.typeValidateExpr !== void 0 && { typeValidateExpr: type.typeValidateExpr }
|
|
7649
|
+
};
|
|
7650
|
+
}
|
|
7651
|
+
function compareTypeScripts(ctx, typeName, previous, current) {
|
|
7652
|
+
const prevState = typeScriptsState(previous);
|
|
7653
|
+
const currState = typeScriptsState(current);
|
|
7654
|
+
if (JSON.stringify(prevState) === JSON.stringify(currState)) return;
|
|
7655
|
+
ctx.changes.push({
|
|
7656
|
+
kind: "type_scripts_modified",
|
|
7657
|
+
typeName,
|
|
7658
|
+
reason: "type-level scripts changed",
|
|
7659
|
+
before: prevState,
|
|
7660
|
+
after: currState
|
|
7661
|
+
});
|
|
7662
|
+
}
|
|
7386
7663
|
/**
|
|
7387
7664
|
* Compare two snapshots and generate a diff
|
|
7388
7665
|
* @param {SchemaSnapshot} previous - Previous schema snapshot
|
|
@@ -7421,6 +7698,7 @@ function compareNormalizedSnapshots(previous, current) {
|
|
|
7421
7698
|
const prevType = assertDefined(previous.types[typeName], `type "${typeName}" missing from previous snapshot`);
|
|
7422
7699
|
const currType = assertDefined(current.types[typeName], `type "${typeName}" missing from current snapshot`);
|
|
7423
7700
|
compareTypeSettings(ctx, typeName, prevType, currType);
|
|
7701
|
+
compareTypeScripts(ctx, typeName, prevType, currType);
|
|
7424
7702
|
compareTypeFields(ctx, typeName, prevType, currType);
|
|
7425
7703
|
compareIndexes(ctx, typeName, prevType.indexes, currType.indexes);
|
|
7426
7704
|
compareFiles(ctx, typeName, prevType.files, currType.files);
|
|
@@ -7910,7 +8188,66 @@ const SYSTEM_FIELDS = /* @__PURE__ */ new Set(["id"]);
|
|
|
7910
8188
|
* @returns {SchemaDrift[]} List of drifts detected
|
|
7911
8189
|
*/
|
|
7912
8190
|
function compareRemoteWithSnapshot(remoteTypes, snapshot, remoteGqlPermissions = []) {
|
|
7913
|
-
|
|
8191
|
+
const structuralDrifts = compareNormalizedRemoteWithSnapshot(createRemoteComparableSnapshot(createSnapshotFromRemoteTypes(remoteTypes, snapshot.namespace, remoteGqlPermissions, snapshot)), createRemoteComparableSnapshot(snapshot));
|
|
8192
|
+
const scriptDrifts = compareScriptHashes(remoteTypes, snapshot);
|
|
8193
|
+
return [...structuralDrifts, ...scriptDrifts];
|
|
8194
|
+
}
|
|
8195
|
+
function extractRemoteScriptHash(remoteType) {
|
|
8196
|
+
const exprs = [
|
|
8197
|
+
remoteType.schema?.typeHook?.create?.expr,
|
|
8198
|
+
remoteType.schema?.typeHook?.update?.expr,
|
|
8199
|
+
remoteType.schema?.typeValidate?.create?.expr,
|
|
8200
|
+
remoteType.schema?.typeValidate?.update?.expr
|
|
8201
|
+
];
|
|
8202
|
+
let found;
|
|
8203
|
+
for (const expr of exprs) if (expr) {
|
|
8204
|
+
const hash = extractSourceScriptHash(expr);
|
|
8205
|
+
if (hash) {
|
|
8206
|
+
if (found && found !== hash) return void 0;
|
|
8207
|
+
found = hash;
|
|
8208
|
+
}
|
|
8209
|
+
}
|
|
8210
|
+
return found;
|
|
8211
|
+
}
|
|
8212
|
+
function remoteHasScripts(remoteType) {
|
|
8213
|
+
return !!(remoteType.schema?.typeHook?.create?.expr || remoteType.schema?.typeHook?.update?.expr || remoteType.schema?.typeValidate?.create?.expr || remoteType.schema?.typeValidate?.update?.expr);
|
|
8214
|
+
}
|
|
8215
|
+
function compareScriptHashes(remoteTypes, snapshot) {
|
|
8216
|
+
const drifts = [];
|
|
8217
|
+
const remoteByName = new Map(remoteTypes.map((t) => [t.name, t]));
|
|
8218
|
+
for (const [typeName, snapshotType] of Object.entries(snapshot.types)) {
|
|
8219
|
+
const localHash = computeSourceScriptHash(snapshotType.fields, {
|
|
8220
|
+
typeHookExpr: snapshotType.typeHookExpr,
|
|
8221
|
+
typeValidateExpr: snapshotType.typeValidateExpr
|
|
8222
|
+
});
|
|
8223
|
+
const remoteType = remoteByName.get(typeName);
|
|
8224
|
+
if (!remoteType) continue;
|
|
8225
|
+
if (localHash) {
|
|
8226
|
+
const remoteHash = extractRemoteScriptHash(remoteType);
|
|
8227
|
+
if (localHash !== remoteHash) drifts.push({
|
|
8228
|
+
typeName,
|
|
8229
|
+
kind: "script_mismatch",
|
|
8230
|
+
details: remoteHash ? `Type '${typeName}' scripts differ between remote and snapshot` : `Type '${typeName}' has no script hash on remote`
|
|
8231
|
+
});
|
|
8232
|
+
} else if (remoteHasScripts(remoteType)) drifts.push({
|
|
8233
|
+
typeName,
|
|
8234
|
+
kind: "script_mismatch",
|
|
8235
|
+
details: `Type '${typeName}' has scripts on remote but not in snapshot`
|
|
8236
|
+
});
|
|
8237
|
+
}
|
|
8238
|
+
return drifts;
|
|
8239
|
+
}
|
|
8240
|
+
function stripFieldScriptProps(field) {
|
|
8241
|
+
const { hooks: _hooks, validate: _validate, default: _default, ...rest } = field;
|
|
8242
|
+
if (rest.fields) {
|
|
8243
|
+
const nested = createSnapshotRecord();
|
|
8244
|
+
for (const [name, f] of Object.entries(rest.fields)) nested[name] = stripFieldScriptProps(f);
|
|
8245
|
+
return {
|
|
8246
|
+
...rest,
|
|
8247
|
+
fields: nested
|
|
8248
|
+
};
|
|
8249
|
+
}
|
|
8250
|
+
return rest;
|
|
7914
8251
|
}
|
|
7915
8252
|
function createRemoteComparableSnapshot(snapshot) {
|
|
7916
8253
|
const types = createSnapshotRecord();
|
|
@@ -7918,10 +8255,11 @@ function createRemoteComparableSnapshot(snapshot) {
|
|
|
7918
8255
|
const fields = createSnapshotRecord();
|
|
7919
8256
|
for (const [fieldName, field] of Object.entries(type.fields)) {
|
|
7920
8257
|
if (SYSTEM_FIELDS.has(fieldName)) continue;
|
|
7921
|
-
fields[fieldName] = field;
|
|
8258
|
+
fields[fieldName] = stripFieldScriptProps(field);
|
|
7922
8259
|
}
|
|
8260
|
+
const { typeHookExpr: _, typeValidateExpr: __, ...typeRest } = type;
|
|
7923
8261
|
types[typeName] = {
|
|
7924
|
-
...
|
|
8262
|
+
...typeRest,
|
|
7925
8263
|
fields
|
|
7926
8264
|
};
|
|
7927
8265
|
}
|
|
@@ -8031,6 +8369,11 @@ function schemaDriftFromDiffChange(change) {
|
|
|
8031
8369
|
kind: "permission_mismatch",
|
|
8032
8370
|
details: change.reason ?? "Permissions differ between remote and snapshot"
|
|
8033
8371
|
};
|
|
8372
|
+
case "type_scripts_modified": return {
|
|
8373
|
+
typeName: change.typeName,
|
|
8374
|
+
kind: "script_mismatch",
|
|
8375
|
+
details: change.reason ?? "Type-level scripts differ between remote and snapshot"
|
|
8376
|
+
};
|
|
8034
8377
|
default: throw new Error("Unsupported diff change");
|
|
8035
8378
|
}
|
|
8036
8379
|
}
|
|
@@ -8115,6 +8458,10 @@ function generateTailorDBTypeManifestFromSnapshot(snapshotType, options = {}) {
|
|
|
8115
8458
|
update: [],
|
|
8116
8459
|
delete: []
|
|
8117
8460
|
};
|
|
8461
|
+
const { typeHook, typeValidate } = buildTypeScripts(snapshotType.fields, {
|
|
8462
|
+
typeHookExpr: snapshotType.typeHookExpr,
|
|
8463
|
+
typeValidateExpr: snapshotType.typeValidateExpr
|
|
8464
|
+
});
|
|
8118
8465
|
return {
|
|
8119
8466
|
name: snapshotType.name,
|
|
8120
8467
|
schema: {
|
|
@@ -8126,10 +8473,15 @@ function generateTailorDBTypeManifestFromSnapshot(snapshotType, options = {}) {
|
|
|
8126
8473
|
directives: [],
|
|
8127
8474
|
indexes,
|
|
8128
8475
|
files,
|
|
8129
|
-
permission
|
|
8476
|
+
permission,
|
|
8477
|
+
...typeHook && { typeHook },
|
|
8478
|
+
...typeValidate && { typeValidate }
|
|
8130
8479
|
}
|
|
8131
8480
|
};
|
|
8132
8481
|
}
|
|
8482
|
+
function optionalOnCreate(config) {
|
|
8483
|
+
return config.hooks?.create || config.default !== void 0 ? { optionalOnCreate: true } : {};
|
|
8484
|
+
}
|
|
8133
8485
|
/**
|
|
8134
8486
|
* Convert a snapshot field config to proto format
|
|
8135
8487
|
* @param {SnapshotFieldConfig} config - Snapshot field config
|
|
@@ -8140,7 +8492,6 @@ function convertFieldConfigToProto(config) {
|
|
|
8140
8492
|
type: config.type,
|
|
8141
8493
|
allowedValues: config.type === "enum" ? config.allowedValues?.map((v) => ({ ...v })) ?? [] : [],
|
|
8142
8494
|
description: config.description || "",
|
|
8143
|
-
validate: toProtoSnapshotFieldValidate(config),
|
|
8144
8495
|
array: config.array ?? false,
|
|
8145
8496
|
index: config.index ?? false,
|
|
8146
8497
|
unique: config.unique ?? false,
|
|
@@ -8149,7 +8500,7 @@ function convertFieldConfigToProto(config) {
|
|
|
8149
8500
|
foreignKeyField: config.foreignKeyField,
|
|
8150
8501
|
required: config.required,
|
|
8151
8502
|
vector: config.vector ?? false,
|
|
8152
|
-
...
|
|
8503
|
+
...optionalOnCreate(config),
|
|
8153
8504
|
...config.serial && { serial: {
|
|
8154
8505
|
start: BigInt(config.serial.start),
|
|
8155
8506
|
...config.serial.maxValue !== void 0 && { maxValue: BigInt(config.serial.maxValue) },
|
|
@@ -8160,20 +8511,6 @@ function convertFieldConfigToProto(config) {
|
|
|
8160
8511
|
if (config.type === "nested" && config.fields) fieldEntry.fields = processNestedFieldsFromSnapshot(config.fields);
|
|
8161
8512
|
return fieldEntry;
|
|
8162
8513
|
}
|
|
8163
|
-
function toProtoSnapshotFieldValidate(config) {
|
|
8164
|
-
return (config.validate ?? []).map((val) => ({
|
|
8165
|
-
action: TailorDBType_PermitAction.DENY,
|
|
8166
|
-
errorMessage: val.errorMessage || "",
|
|
8167
|
-
script: { expr: val.script && val.script.expr ? `!${val.script.expr}` : "" }
|
|
8168
|
-
}));
|
|
8169
|
-
}
|
|
8170
|
-
function toProtoSnapshotFieldHooks(config) {
|
|
8171
|
-
if (!config.hooks) return {};
|
|
8172
|
-
return { hooks: {
|
|
8173
|
-
create: config.hooks.create ? { expr: config.hooks.create.expr || "" } : void 0,
|
|
8174
|
-
update: config.hooks.update ? { expr: config.hooks.update.expr || "" } : void 0
|
|
8175
|
-
} };
|
|
8176
|
-
}
|
|
8177
8514
|
/**
|
|
8178
8515
|
* Process nested fields from snapshot format to proto format
|
|
8179
8516
|
* @param {Record<string, SnapshotFieldConfig>} fields - Nested fields
|
|
@@ -8187,14 +8524,12 @@ function processNestedFieldsFromSnapshot(fields) {
|
|
|
8187
8524
|
type: "nested",
|
|
8188
8525
|
allowedValues: fieldConfig.allowedValues?.map((v) => ({ ...v })) ?? [],
|
|
8189
8526
|
description: fieldConfig.description || "",
|
|
8190
|
-
validate: toProtoSnapshotFieldValidate(fieldConfig),
|
|
8191
8527
|
required: fieldConfig.required,
|
|
8192
8528
|
array: fieldConfig.array ?? false,
|
|
8193
8529
|
index: false,
|
|
8194
8530
|
unique: false,
|
|
8195
8531
|
foreignKey: false,
|
|
8196
8532
|
vector: false,
|
|
8197
|
-
...toProtoSnapshotFieldHooks(fieldConfig),
|
|
8198
8533
|
fields: deepNestedFields,
|
|
8199
8534
|
...fieldConfig.scale !== void 0 && { scale: fieldConfig.scale }
|
|
8200
8535
|
};
|
|
@@ -8202,14 +8537,13 @@ function processNestedFieldsFromSnapshot(fields) {
|
|
|
8202
8537
|
type: fieldConfig.type,
|
|
8203
8538
|
allowedValues: fieldConfig.type === "enum" ? fieldConfig.allowedValues?.map((v) => ({ ...v })) ?? [] : [],
|
|
8204
8539
|
description: fieldConfig.description || "",
|
|
8205
|
-
validate: toProtoSnapshotFieldValidate(fieldConfig),
|
|
8206
8540
|
required: fieldConfig.required,
|
|
8207
8541
|
array: fieldConfig.array ?? false,
|
|
8208
8542
|
index: false,
|
|
8209
8543
|
unique: false,
|
|
8210
8544
|
foreignKey: false,
|
|
8211
8545
|
vector: false,
|
|
8212
|
-
...
|
|
8546
|
+
...optionalOnCreate(fieldConfig),
|
|
8213
8547
|
...fieldConfig.serial && { serial: {
|
|
8214
8548
|
start: BigInt(fieldConfig.serial.start),
|
|
8215
8549
|
...fieldConfig.serial.maxValue !== void 0 && { maxValue: BigInt(fieldConfig.serial.maxValue) },
|
|
@@ -9530,14 +9864,6 @@ const migrationSnapshotCache = {
|
|
|
9530
9864
|
return snapshot;
|
|
9531
9865
|
}
|
|
9532
9866
|
};
|
|
9533
|
-
/**
|
|
9534
|
-
* Build the TailorDBType manifest for `typeName` from migration N's snapshot.
|
|
9535
|
-
* @param migration - The pending migration whose snapshot to consult
|
|
9536
|
-
* @param typeName - The type name to look up in the snapshot
|
|
9537
|
-
* @param tailorDBInputs - Deploy inputs, used to resolve namespace gqlOperations
|
|
9538
|
-
* @param executorUsedTypes - Types used by executors (drives publishRecordEvents default)
|
|
9539
|
-
* @returns The manifest, or undefined if `typeName` is not in that snapshot.
|
|
9540
|
-
*/
|
|
9541
9867
|
function buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes) {
|
|
9542
9868
|
const snapshotType = migrationSnapshotCache.load(migration).types[typeName];
|
|
9543
9869
|
if (!snapshotType) return void 0;
|
|
@@ -10048,18 +10374,28 @@ function normalizeComparableTailorDBType(type) {
|
|
|
10048
10374
|
settings: normalized?.schema?.settings ?? {},
|
|
10049
10375
|
indexes: normalized?.schema?.indexes ?? {},
|
|
10050
10376
|
files: normalized?.schema?.files ?? {},
|
|
10051
|
-
permission: normalized?.schema?.permission ?? {}
|
|
10377
|
+
permission: normalized?.schema?.permission ?? {},
|
|
10378
|
+
typeHook: normalized?.schema?.typeHook ?? {},
|
|
10379
|
+
typeValidate: normalized?.schema?.typeValidate ?? {}
|
|
10052
10380
|
}
|
|
10053
10381
|
}, []);
|
|
10054
10382
|
}
|
|
10055
10383
|
function normalizeTailorDBCompareValue(value, path) {
|
|
10056
10384
|
if (value === void 0 || value === null) return value;
|
|
10385
|
+
if (typeof value === "boolean") {
|
|
10386
|
+
if (path.at(-1) === "optionalOnCreate" && value === false) return;
|
|
10387
|
+
return value;
|
|
10388
|
+
}
|
|
10057
10389
|
if (typeof value === "number" || typeof value === "bigint" || typeof value === "string") {
|
|
10058
10390
|
if (matchesNumericStringPath(path) && isNumericLikeValue(value)) return String(value);
|
|
10059
10391
|
if ((path.at(-1) === "expr" || path.at(-1) === "description") && value === tailordbCompareKnownDefaults.emptyExpression) return;
|
|
10060
10392
|
return value;
|
|
10061
10393
|
}
|
|
10062
|
-
if (Array.isArray(value))
|
|
10394
|
+
if (Array.isArray(value)) {
|
|
10395
|
+
const items = value.map((item, index) => normalizeTailorDBCompareValue(item, [...path, index])).filter((item) => item !== void 0);
|
|
10396
|
+
if (items.length === 0 && path.at(-1) === "validate") return;
|
|
10397
|
+
return items;
|
|
10398
|
+
}
|
|
10063
10399
|
if (!isPlainObject(value)) return value;
|
|
10064
10400
|
const normalizedEntries = Object.entries(value).map(([key, entryValue]) => [key, normalizeTailorDBCompareValue(entryValue, [...path, key])]).filter(([, entryValue]) => entryValue !== void 0);
|
|
10065
10401
|
const normalizedObject = Object.fromEntries(normalizedEntries);
|
|
@@ -10312,11 +10648,11 @@ async function registerJobFunctions(client, changeSet, appName, appId, unchanged
|
|
|
10312
10648
|
const allUsedJobNames = /* @__PURE__ */ new Set();
|
|
10313
10649
|
unchangedWorkflowJobNames.forEach((jobName) => allUsedJobNames.add(jobName));
|
|
10314
10650
|
for (const item of [...changeSet.creates, ...changeSet.updates]) for (const jobName of item.usedJobNames) allUsedJobNames.add(jobName);
|
|
10315
|
-
const existingJobFunctions = await fetchAll(async (pageToken,
|
|
10651
|
+
const existingJobFunctions = await fetchAll(async (pageToken, maxPageSize) => {
|
|
10316
10652
|
const response = await client.listWorkflowJobFunctions({
|
|
10317
10653
|
workspaceId,
|
|
10318
10654
|
pageToken,
|
|
10319
|
-
pageSize:
|
|
10655
|
+
pageSize: maxPageSize
|
|
10320
10656
|
});
|
|
10321
10657
|
return [response.jobFunctions.map((j) => j.name), response.nextPageToken];
|
|
10322
10658
|
});
|
|
@@ -10496,11 +10832,11 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
|
|
|
10496
10832
|
}
|
|
10497
10833
|
async function planWorkflowJobFunctionDeletes(params) {
|
|
10498
10834
|
const { client, workspaceId, appName, appId, retainedWorkflowJobNames } = params;
|
|
10499
|
-
const existingJobFunctions = await fetchAll(async (pageToken,
|
|
10835
|
+
const existingJobFunctions = await fetchAll(async (pageToken, maxPageSize) => {
|
|
10500
10836
|
const response = await client.listWorkflowJobFunctions({
|
|
10501
10837
|
workspaceId,
|
|
10502
10838
|
pageToken,
|
|
10503
|
-
pageSize:
|
|
10839
|
+
pageSize: maxPageSize
|
|
10504
10840
|
});
|
|
10505
10841
|
return [response.jobFunctions.map((jobFunction) => jobFunction.name), response.nextPageToken];
|
|
10506
10842
|
});
|
|
@@ -11119,13 +11455,14 @@ function validateItems(params) {
|
|
|
11119
11455
|
*
|
|
11120
11456
|
* Collections not validated: idp client, tailorDB gqlPermission, functionRegistry — no
|
|
11121
11457
|
* buf.validate annotations.
|
|
11122
|
-
* Application cors and IdP userAuthPolicy.allowedReturnOrigins receive
|
|
11123
|
-
* handling: static-website URL placeholders are resolved at apply time, so the
|
|
11458
|
+
* Application cors, AIGateway cors, and IdP userAuthPolicy.allowedReturnOrigins receive
|
|
11459
|
+
* special handling: static-website URL placeholders are resolved at apply time, so the
|
|
11124
11460
|
* relevant origin/URL constraints would false-positive on `<name>:url` entries
|
|
11125
|
-
* here. Application cors
|
|
11126
|
-
*
|
|
11127
|
-
*
|
|
11128
|
-
*
|
|
11461
|
+
* here. Application cors and AIGateway cors are dropped entirely, forgoing their
|
|
11462
|
+
* per-item URL/origin constraints for the whole list rather than substituting
|
|
11463
|
+
* placeholders; IdP `allowedReturnOrigins` instead substitutes placeholder entries
|
|
11464
|
+
* with a dummy origin so the per-item regex and the cross-field `enable_mfa requires
|
|
11465
|
+
* ≥1 origin` rule still get exercised on the rest of the payload.
|
|
11129
11466
|
* Workflow jobFunctions map excluded: versions are registered at apply time (registerJobFunctions)
|
|
11130
11467
|
* and the map field carries no min_items constraint. Job names are validated separately via
|
|
11131
11468
|
* CreateWorkflowJobFunctionRequestSchema using usedJobNames from the workflow change set.
|
|
@@ -11135,7 +11472,7 @@ function validateItems(params) {
|
|
|
11135
11472
|
* @param input - Plan results from the plan phase
|
|
11136
11473
|
*/
|
|
11137
11474
|
async function validatePlan(input) {
|
|
11138
|
-
const { tailorDB, staticWebsite, idp, auth, pipeline, app, executor, workflow, workflowExecutionPolicy, secretManager } = input;
|
|
11475
|
+
const { tailorDB, staticWebsite, aiGateway, idp, auth, pipeline, app, executor, workflow, workflowExecutionPolicy, secretManager } = input;
|
|
11139
11476
|
const validator = createValidator();
|
|
11140
11477
|
const violations = [];
|
|
11141
11478
|
function creates(schema, kind, items) {
|
|
@@ -11188,6 +11525,20 @@ async function validatePlan(input) {
|
|
|
11188
11525
|
creates(CreateStaticWebsiteRequestSchema, "StaticWebsite", staticWebsite.changeSet.creates);
|
|
11189
11526
|
updates(UpdateStaticWebsiteRequestSchema, "StaticWebsite", staticWebsite.changeSet.updates);
|
|
11190
11527
|
creates(AddCustomDomainRequestSchema, "StaticWebsite custom domain", staticWebsite.customDomainChangeSet.creates);
|
|
11528
|
+
creates(CreateAIGatewayRequestSchema, "AIGateway", aiGateway.changeSet.creates.map((item) => ({
|
|
11529
|
+
name: item.name,
|
|
11530
|
+
request: {
|
|
11531
|
+
...item.request,
|
|
11532
|
+
cors: void 0
|
|
11533
|
+
}
|
|
11534
|
+
})));
|
|
11535
|
+
updates(UpdateAIGatewayRequestSchema, "AIGateway", aiGateway.changeSet.updates.map((item) => ({
|
|
11536
|
+
name: item.name,
|
|
11537
|
+
request: {
|
|
11538
|
+
...item.request,
|
|
11539
|
+
cors: void 0
|
|
11540
|
+
}
|
|
11541
|
+
})));
|
|
11191
11542
|
const placeholderOriginReplacement = "https://placeholder.invalid";
|
|
11192
11543
|
const substituteIdpReturnOrigins = (item) => {
|
|
11193
11544
|
const request = item.request;
|
|
@@ -11973,50 +12324,25 @@ function deploymentPlanResults(deployment) {
|
|
|
11973
12324
|
const { application: _application, ...results } = deployment;
|
|
11974
12325
|
return results;
|
|
11975
12326
|
}
|
|
12327
|
+
/**
|
|
12328
|
+
* Every `PlanResults` entry except `app` carries ownership-tracking fields;
|
|
12329
|
+
* deriving the list from `results` itself (instead of naming each key) keeps
|
|
12330
|
+
* these collectors in sync with `PlannedDeployment` as resource types are added.
|
|
12331
|
+
* @param results - Plan results for a single deployment
|
|
12332
|
+
* @returns The ownership-tracking plan entries, `app` excluded
|
|
12333
|
+
*/
|
|
12334
|
+
function ownershipTrackedPlans(results) {
|
|
12335
|
+
const { app: _app, ...rest } = results;
|
|
12336
|
+
return Object.values(rest);
|
|
12337
|
+
}
|
|
11976
12338
|
function collectOwnerConflicts(results) {
|
|
11977
|
-
return
|
|
11978
|
-
...results.functionRegistry.conflicts,
|
|
11979
|
-
...results.tailorDB.conflicts,
|
|
11980
|
-
...results.staticWebsite.conflicts,
|
|
11981
|
-
...results.aiGateway.conflicts,
|
|
11982
|
-
...results.idp.conflicts,
|
|
11983
|
-
...results.auth.conflicts,
|
|
11984
|
-
...results.pipeline.conflicts,
|
|
11985
|
-
...results.executor.conflicts,
|
|
11986
|
-
...results.workflow.conflicts,
|
|
11987
|
-
...results.workflowExecutionPolicy.conflicts,
|
|
11988
|
-
...results.secretManager.conflicts
|
|
11989
|
-
];
|
|
12339
|
+
return ownershipTrackedPlans(results).flatMap((plan) => plan.conflicts);
|
|
11990
12340
|
}
|
|
11991
12341
|
function collectUnmanagedResources(results) {
|
|
11992
|
-
return
|
|
11993
|
-
...results.functionRegistry.unmanaged,
|
|
11994
|
-
...results.tailorDB.unmanaged,
|
|
11995
|
-
...results.staticWebsite.unmanaged,
|
|
11996
|
-
...results.aiGateway.unmanaged,
|
|
11997
|
-
...results.idp.unmanaged,
|
|
11998
|
-
...results.auth.unmanaged,
|
|
11999
|
-
...results.pipeline.unmanaged,
|
|
12000
|
-
...results.executor.unmanaged,
|
|
12001
|
-
...results.workflow.unmanaged,
|
|
12002
|
-
...results.workflowExecutionPolicy.unmanaged,
|
|
12003
|
-
...results.secretManager.unmanaged
|
|
12004
|
-
];
|
|
12342
|
+
return ownershipTrackedPlans(results).flatMap((plan) => plan.unmanaged);
|
|
12005
12343
|
}
|
|
12006
12344
|
function collectResourceOwners(results) {
|
|
12007
|
-
return
|
|
12008
|
-
...results.functionRegistry.resourceOwners,
|
|
12009
|
-
...results.tailorDB.resourceOwners,
|
|
12010
|
-
...results.staticWebsite.resourceOwners,
|
|
12011
|
-
...results.aiGateway.resourceOwners,
|
|
12012
|
-
...results.idp.resourceOwners,
|
|
12013
|
-
...results.auth.resourceOwners,
|
|
12014
|
-
...results.pipeline.resourceOwners,
|
|
12015
|
-
...results.executor.resourceOwners,
|
|
12016
|
-
...results.workflow.resourceOwners,
|
|
12017
|
-
...results.workflowExecutionPolicy.resourceOwners,
|
|
12018
|
-
...results.secretManager.resourceOwners
|
|
12019
|
-
]);
|
|
12345
|
+
return new Set(ownershipTrackedPlans(results).flatMap((plan) => [...plan.resourceOwners]));
|
|
12020
12346
|
}
|
|
12021
12347
|
function collectImportantResourceDeletions(results) {
|
|
12022
12348
|
const importantDeletions = [];
|
|
@@ -16294,62 +16620,67 @@ async function execRemove(client, workspaceId, application, config, confirm) {
|
|
|
16294
16620
|
forRemoval: true,
|
|
16295
16621
|
config
|
|
16296
16622
|
};
|
|
16297
|
-
const
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16301
|
-
|
|
16302
|
-
|
|
16303
|
-
|
|
16304
|
-
|
|
16305
|
-
|
|
16306
|
-
|
|
16307
|
-
|
|
16623
|
+
const plans = {
|
|
16624
|
+
tailorDB: await planTailorDB(ctx),
|
|
16625
|
+
staticWebsite: await planStaticWebsite(ctx),
|
|
16626
|
+
aiGateway: await planAIGateway(ctx),
|
|
16627
|
+
idp: await planIdP(ctx),
|
|
16628
|
+
auth: await planAuth(ctx),
|
|
16629
|
+
pipeline: await planPipeline(ctx),
|
|
16630
|
+
app: await planApplication(ctx),
|
|
16631
|
+
executor: await planExecutor(ctx),
|
|
16632
|
+
workflow: await planWorkflow(client, workspaceId, application.name, application.id, {}, {}),
|
|
16633
|
+
workflowExecutionPolicy: await planWorkflowJobFunctionExecutionPolicy(client, workspaceId, application.name, application.id, {}),
|
|
16634
|
+
functionRegistry: await planFunctionRegistry(client, workspaceId, application.name, application.id, []),
|
|
16635
|
+
secretManager: await planSecretManager(ctx)
|
|
16636
|
+
};
|
|
16308
16637
|
const removeLines = [
|
|
16309
|
-
...functionRegistry.changeSet.lines(),
|
|
16310
|
-
...staticWebsite.changeSet.lines(),
|
|
16311
|
-
...aiGateway.changeSet.lines(),
|
|
16312
|
-
...app.lines(),
|
|
16313
|
-
...tailorDB.changeSet.service.lines(),
|
|
16314
|
-
...tailorDB.changeSet.type.lines(),
|
|
16315
|
-
...tailorDB.changeSet.gqlPermission.lines(),
|
|
16316
|
-
...pipeline.changeSet.service.lines(),
|
|
16317
|
-
...pipeline.changeSet.resolver.lines(),
|
|
16318
|
-
...executor.changeSet.lines(),
|
|
16319
|
-
...workflow.changeSet.lines(),
|
|
16320
|
-
...
|
|
16321
|
-
...idp.changeSet.
|
|
16322
|
-
...
|
|
16323
|
-
...auth.changeSet.
|
|
16324
|
-
...auth.changeSet.
|
|
16325
|
-
...auth.changeSet.
|
|
16326
|
-
...auth.changeSet.
|
|
16327
|
-
...auth.changeSet.
|
|
16328
|
-
...auth.changeSet.
|
|
16329
|
-
...auth.changeSet.
|
|
16330
|
-
...auth.changeSet.
|
|
16331
|
-
...auth.changeSet.
|
|
16332
|
-
...
|
|
16333
|
-
...secretManager.
|
|
16638
|
+
...plans.functionRegistry.changeSet.lines(),
|
|
16639
|
+
...plans.staticWebsite.changeSet.lines(),
|
|
16640
|
+
...plans.aiGateway.changeSet.lines(),
|
|
16641
|
+
...plans.app.lines(),
|
|
16642
|
+
...plans.tailorDB.changeSet.service.lines(),
|
|
16643
|
+
...plans.tailorDB.changeSet.type.lines(),
|
|
16644
|
+
...plans.tailorDB.changeSet.gqlPermission.lines(),
|
|
16645
|
+
...plans.pipeline.changeSet.service.lines(),
|
|
16646
|
+
...plans.pipeline.changeSet.resolver.lines(),
|
|
16647
|
+
...plans.executor.changeSet.lines(),
|
|
16648
|
+
...plans.workflow.changeSet.lines(),
|
|
16649
|
+
...plans.workflowExecutionPolicy.changeSet.lines(),
|
|
16650
|
+
...plans.idp.changeSet.service.lines(),
|
|
16651
|
+
...plans.idp.changeSet.client.lines(),
|
|
16652
|
+
...plans.auth.changeSet.service.lines(),
|
|
16653
|
+
...plans.auth.changeSet.idpConfig.lines(),
|
|
16654
|
+
...plans.auth.changeSet.userProfileConfig.lines(),
|
|
16655
|
+
...plans.auth.changeSet.tenantConfig.lines(),
|
|
16656
|
+
...plans.auth.changeSet.machineUser.lines(),
|
|
16657
|
+
...plans.auth.changeSet.oauth2Client.lines(),
|
|
16658
|
+
...plans.auth.changeSet.authHook.lines(),
|
|
16659
|
+
...plans.auth.changeSet.scim.lines(),
|
|
16660
|
+
...plans.auth.changeSet.scimResource.lines(),
|
|
16661
|
+
...plans.auth.changeSet.connection.lines(),
|
|
16662
|
+
...plans.secretManager.vaultChangeSet.lines(),
|
|
16663
|
+
...plans.secretManager.secretChangeSet.lines()
|
|
16334
16664
|
];
|
|
16335
16665
|
if (removeLines.length > 0) logger.log(removeLines.join("\n"));
|
|
16336
|
-
if (tailorDB.changeSet.service.deletes.length === 0 && staticWebsite.changeSet.deletes.length === 0 && aiGateway.changeSet.deletes.length === 0 && idp.changeSet.service.deletes.length === 0 && auth.changeSet.service.deletes.length === 0 && pipeline.changeSet.service.deletes.length === 0 && app.deletes.length === 0 && executor.changeSet.deletes.length === 0 && workflow.changeSet.deletes.length === 0 && functionRegistry.changeSet.deletes.length === 0 && secretManager.vaultChangeSet.deletes.length === 0 && secretManager.secretChangeSet.deletes.length === 0) return;
|
|
16666
|
+
if (plans.tailorDB.changeSet.service.deletes.length === 0 && plans.staticWebsite.changeSet.deletes.length === 0 && plans.aiGateway.changeSet.deletes.length === 0 && plans.idp.changeSet.service.deletes.length === 0 && plans.auth.changeSet.service.deletes.length === 0 && plans.pipeline.changeSet.service.deletes.length === 0 && plans.app.deletes.length === 0 && plans.executor.changeSet.deletes.length === 0 && plans.workflow.changeSet.deletes.length === 0 && plans.workflowExecutionPolicy.changeSet.deletes.length === 0 && plans.functionRegistry.changeSet.deletes.length === 0 && plans.secretManager.vaultChangeSet.deletes.length === 0 && plans.secretManager.secretChangeSet.deletes.length === 0) return;
|
|
16337
16667
|
if (confirm) await confirm();
|
|
16338
|
-
await applyWorkflow(client, workflow, "delete");
|
|
16339
|
-
await
|
|
16340
|
-
await
|
|
16341
|
-
await
|
|
16342
|
-
await
|
|
16343
|
-
await
|
|
16344
|
-
await applyPipeline(client, pipeline, "delete-
|
|
16345
|
-
await
|
|
16346
|
-
await applyAuth(client, auth, "delete-
|
|
16347
|
-
await
|
|
16348
|
-
await applyIdP(client, idp, "delete-
|
|
16349
|
-
await
|
|
16350
|
-
await applyTailorDB(client, tailorDB, "delete-
|
|
16351
|
-
await
|
|
16352
|
-
await
|
|
16668
|
+
await applyWorkflow(client, plans.workflow, "delete");
|
|
16669
|
+
await applyWorkflowJobFunctionExecutionPolicy(client, plans.workflowExecutionPolicy, "delete");
|
|
16670
|
+
await applyExecutor(client, plans.executor, "delete");
|
|
16671
|
+
await applyStaticWebsite(client, plans.staticWebsite, "delete");
|
|
16672
|
+
await applyAIGateway(client, plans.aiGateway, "delete");
|
|
16673
|
+
await applyApplication(client, plans.app, "delete");
|
|
16674
|
+
await applyPipeline(client, plans.pipeline, "delete-resources");
|
|
16675
|
+
await applyPipeline(client, plans.pipeline, "delete-services");
|
|
16676
|
+
await applyAuth(client, plans.auth, "delete-resources");
|
|
16677
|
+
await applyAuth(client, plans.auth, "delete-services");
|
|
16678
|
+
await applyIdP(client, plans.idp, "delete-resources");
|
|
16679
|
+
await applyIdP(client, plans.idp, "delete-services");
|
|
16680
|
+
await applyTailorDB(client, plans.tailorDB, "delete-resources");
|
|
16681
|
+
await applyTailorDB(client, plans.tailorDB, "delete-services");
|
|
16682
|
+
await applyFunctionRegistry(client, workspaceId, plans.functionRegistry, "delete");
|
|
16683
|
+
await applySecretManager(client, plans.secretManager, "delete");
|
|
16353
16684
|
}
|
|
16354
16685
|
/**
|
|
16355
16686
|
* Remove all resources managed by the current application.
|
|
@@ -16525,10 +16856,27 @@ function applicationInfo(app) {
|
|
|
16525
16856
|
updatedAt: app.updateTime ? timestampDate(app.updateTime) : null
|
|
16526
16857
|
};
|
|
16527
16858
|
}
|
|
16859
|
+
async function fetchAIGateways(client, workspaceId, names) {
|
|
16860
|
+
return (await Promise.all(names.map(async (name) => {
|
|
16861
|
+
try {
|
|
16862
|
+
const { aigateway } = await client.getAIGateway({
|
|
16863
|
+
workspaceId,
|
|
16864
|
+
aigatewayName: name
|
|
16865
|
+
});
|
|
16866
|
+
return aigateway ? {
|
|
16867
|
+
name: aigateway.name,
|
|
16868
|
+
url: aigateway.url
|
|
16869
|
+
} : void 0;
|
|
16870
|
+
} catch (error) {
|
|
16871
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) return;
|
|
16872
|
+
throw error;
|
|
16873
|
+
}
|
|
16874
|
+
}))).filter((gateway) => gateway !== void 0);
|
|
16875
|
+
}
|
|
16528
16876
|
/**
|
|
16529
16877
|
* Show applied application information for the current workspace.
|
|
16530
16878
|
* @param options - Show options
|
|
16531
|
-
* @returns
|
|
16879
|
+
* @returns Deployed application, workspace, and AI Gateway information
|
|
16532
16880
|
*/
|
|
16533
16881
|
async function show(options) {
|
|
16534
16882
|
const client = await initOperatorClient(await loadAccessToken({ profile: options?.profile }));
|
|
@@ -16537,10 +16885,15 @@ async function show(options) {
|
|
|
16537
16885
|
profile: options?.profile
|
|
16538
16886
|
});
|
|
16539
16887
|
const { config } = await loadConfig(options?.configPath);
|
|
16540
|
-
const
|
|
16541
|
-
|
|
16542
|
-
|
|
16543
|
-
|
|
16888
|
+
const aiGatewayNames = config.aiGateways?.length ? [...new Set(config.aiGateways.map((gateway) => gateway.name))] : [];
|
|
16889
|
+
const [workspaceResp, resp, aiGateways] = await Promise.all([
|
|
16890
|
+
client.getWorkspace({ workspaceId }),
|
|
16891
|
+
client.getApplication({
|
|
16892
|
+
workspaceId,
|
|
16893
|
+
applicationName: config.name
|
|
16894
|
+
}),
|
|
16895
|
+
fetchAIGateways(client, workspaceId, aiGatewayNames)
|
|
16896
|
+
]);
|
|
16544
16897
|
const { name, ...appInfo } = applicationInfo(assertDefined(resp.application, `application "${config.name}" not found in workspace`));
|
|
16545
16898
|
const workspace = workspaceResp.workspace;
|
|
16546
16899
|
const workspaceFolderName = workspace ? await resolveWorkspaceFolderName(client, workspace) : "";
|
|
@@ -16550,7 +16903,8 @@ async function show(options) {
|
|
|
16550
16903
|
workspaceName: workspace?.name ?? "",
|
|
16551
16904
|
...workspaceFolderName ? { workspaceFolderName } : {},
|
|
16552
16905
|
workspaceRegion: workspace?.region ?? "",
|
|
16553
|
-
...appInfo
|
|
16906
|
+
...appInfo,
|
|
16907
|
+
aiGateways
|
|
16554
16908
|
};
|
|
16555
16909
|
}
|
|
16556
16910
|
const showWorkspaceNameTransformer = createWorkspaceNameTransformer("workspaceName", "workspaceFolderName");
|
|
@@ -17177,7 +17531,7 @@ async function generate(options) {
|
|
|
17177
17531
|
if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
|
|
17178
17532
|
let pluginManager;
|
|
17179
17533
|
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
17180
|
-
const { defineApplication } = await import("./application-
|
|
17534
|
+
const { defineApplication } = await import("./application-CUkjzfij.mjs");
|
|
17181
17535
|
const application = defineApplication({
|
|
17182
17536
|
config,
|
|
17183
17537
|
pluginManager
|
|
@@ -19456,4 +19810,4 @@ async function registerTsHook(tsHookUrl) {
|
|
|
19456
19810
|
|
|
19457
19811
|
//#endregion
|
|
19458
19812
|
export { getOrganization as $, compareSnapshotWithRemote as $t, listCommand$3 as A, apiCommand as An, getExecutorWaitFailureMessage as At, show as B, listWorkflowExecutions as Bt, listCommand$2 as C, hasChanges as Cn, listWebhookExecutors as Ct, waitWorkflowExecution as D, PluginManager as Dn, listCommand$9 as Dt, waitCommand as E, sdkNameLabelKey as En, triggerExecutor as Et, generateCommand as F, startWorkflow as Ft, removeCommand$1 as G, deploy as Gt, extractOwnedNamespaces as H, formatKeyValueTable as Ht, generateMigrationScript as I, getCommand$5 as It, organizationTree as J, waitForExecution as Jt, updateCommand$1 as K, ensureConfigId as Kt, writeDbTypesFile as L, getWorkflow as Lt, truncate as M, assertWritable as Mn, listExecutorJobs as Mt, truncateCommand as N, defineAppCommand as Nn, watchExecutorJob as Nt, resumeCommand as O, generateUserTypes as On, listExecutors as Ot, generate as P, startCommand as Pt, getCommand$1 as Q, parseMigrationLabelNumber as Qt, getConfiguredEditorCommand as R, executionsCommand as Rt, listApps as S, formatMigrationDiff as Sn, getFunctionRegistry as St, healthCommand as T, resourceTrn as Tn, triggerCommand as Tt, logBetaWarning as U, getCommand$6 as Ut, showCommand as V, functionExecutionStatusToString as Vt, remove as W, getExecutor as Wt, listCommand$4 as X, MIGRATION_LABEL_KEY as Xt, treeCommand as Y, bundleMigrationScript as Yt, listOrganizations as Z, handleOptionalToRequiredError as Zt, getWorkspace as _, loadDiff as _n, listMachineUsers as _t, updateUser as a, MIGRATE_FILE_NAME as an, getFolder as at, createCommand as b, parseMigrationNumberArg as bn, listFunctionRegistries as bt, listCommand as c, compareLocalTypesWithSnapshot as cn, createCommand$1 as ct, inviteUser as d, getLatestMigrationNumber as dn, listOAuth2Clients as dt, generateAllTypeManifestsFromSnapshot as en, updateCommand$2 as et, restoreCommand as f, getMigrationDirPath as fn, getCommand$3 as ft, getCommand as g, isValidMigrationNumber as gn, listCommand$7 as gt, listWorkspaces as h, getNextMigrationNumber as hn, tokenCommand as ht, updateCommand as i, INITIAL_SCHEMA_NUMBER as in, getCommand$2 as it, listWorkflows as j, apiCall as jn, jobsCommand as jt, resumeWorkflow as k, prompt as kn, getExecutorJob as kt, listUsers as l, compareSnapshots as ln, createFolder as lt, listCommand$1 as m, getMigrationFiles as mn, getMachineUserToken as mt, query as n, DB_TYPES_FILE_NAME as nn, listCommand$5 as nt, removeCommand as o, SCHEMA_FILE_NAME as on, deleteCommand$1 as ot, restoreWorkspace as p, getMigrationFilePath as pn, getOAuth2Client as pt, updateOrganization as q, executeScript as qt, queryCommand as r, DIFF_FILE_NAME as rn, listFolders as rt, removeUser as s, assertValidMigrationFiles as sn, deleteFolder as st, registerTsHook as t, protoGqlPermission as tn, updateFolder as tt, inviteCommand as u, createSnapshotFromLocalTypes as un, listCommand$6 as ut, deleteCommand as v, reconstructSnapshotFromMigrations as vn, generate$1 as vt, getAppHealth as w, getNamespacesWithMigrations as wn, webhookCommand as wt, createWorkspace as x, formatDiffSummary as xn, getCommand$4 as xt, deleteWorkspace as y, formatMigrationNumber as yn, listCommand$8 as yt, openInConfiguredEditor as z, getWorkflowExecution as zt };
|
|
19459
|
-
//# sourceMappingURL=register-ts-hook-
|
|
19813
|
+
//# sourceMappingURL=register-ts-hook-BhzVkej0.mjs.map
|