@tailor-platform/sdk 1.80.0 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/application-B1_7Wm37.mjs +3 -0
  3. package/dist/{application-C1d52JP9.mjs → application-DDe0er6L.mjs} +149 -20
  4. package/dist/{application-C1d52JP9.mjs.map → application-DDe0er6L.mjs.map} +1 -1
  5. package/dist/cli/index.mjs +13 -28
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.mjs +2 -2
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/index.d.mts +3 -2
  10. package/dist/configure/index.mjs +9 -0
  11. package/dist/configure/index.mjs.map +1 -1
  12. package/dist/configure/services/idp/index.d.mts +1 -1
  13. package/dist/configure/services/idp/permission.d.mts +1 -16
  14. package/dist/configure/services/idp/types.d.mts +5 -1
  15. package/dist/configure/services/index.d.mts +3 -2
  16. package/dist/configure/services/resolver/index.d.mts +2 -1
  17. package/dist/configure/services/resolver/permission.d.mts +64 -0
  18. package/dist/configure/services/resolver/resolver.d.mts +14 -2
  19. package/dist/configure/services/tailordb/permission.d.mts +1 -16
  20. package/dist/configure/types/permission-operand.types.d.mts +20 -0
  21. package/dist/{globals-B-n_3uYu.mjs → globals-DUqEetIh.mjs} +18 -2
  22. package/dist/{globals-B-n_3uYu.mjs.map → globals-DUqEetIh.mjs.map} +1 -1
  23. package/dist/logger-B-fqZe2W.mjs +50 -0
  24. package/dist/logger-B-fqZe2W.mjs.map +1 -0
  25. package/dist/{register-typescript-runtime-Bd4bcLbW.mjs → register-typescript-runtime-QAWucsg0.mjs} +40 -9
  26. package/dist/register-typescript-runtime-QAWucsg0.mjs.map +1 -0
  27. package/dist/runtime/globals.d.mts +7 -0
  28. package/dist/runtime/index.d.mts +3 -1
  29. package/dist/runtime/index.mjs +2 -1
  30. package/dist/runtime/logger.d.mts +98 -0
  31. package/dist/runtime/logger.mjs +3 -0
  32. package/dist/{service_pb-BoLM0X4K.mjs → service_pb-BwZRiNug.mjs} +2 -2
  33. package/dist/{service_pb-BoLM0X4K.mjs.map → service_pb-BwZRiNug.mjs.map} +1 -1
  34. package/dist/{service_pb-r1T7kpJc.mjs → service_pb-wRkxUta6.mjs} +1 -1
  35. package/dist/types/auth.generated.d.mts +14 -2
  36. package/dist/types/executor.generated.d.mts +19 -0
  37. package/dist/types/http-adapter.generated.d.mts +5 -0
  38. package/dist/types/idp.generated.d.mts +30 -0
  39. package/dist/types/resolver.generated.d.mts +28 -2
  40. package/dist/types/tailordb.generated.d.mts +15 -1
  41. package/dist/vitest/environment.mjs +1 -1
  42. package/dist/vitest/index.d.mts +4 -2
  43. package/dist/vitest/index.mjs +83 -2
  44. package/dist/vitest/index.mjs.map +1 -1
  45. package/dist/vitest/mock.d.mts +2 -1
  46. package/dist/vitest/mocks/logger.d.mts +45 -0
  47. package/dist/vitest/setup.mjs +1 -1
  48. package/dist/{workspace_resource_pb-Db3fv68L.mjs → workspace_resource_pb-UGK1SSn_.mjs} +7 -2
  49. package/dist/{workspace_resource_pb-Db3fv68L.mjs.map → workspace_resource_pb-UGK1SSn_.mjs.map} +1 -1
  50. package/docs/runtime.md +4 -0
  51. package/docs/services/resolver.md +54 -0
  52. package/docs/testing.md +33 -6
  53. package/package.json +12 -7
  54. package/dist/application-Nlh9BHQf.mjs +0 -3
  55. package/dist/register-typescript-runtime-Bd4bcLbW.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
+ import { IdPPermission, IdPPermissionCondition, unsafeAllowAllIdPPermission } from "./permission.mjs";
1
2
  import { IdPEmailConfig, IdPGqlOperations, IdPGqlOperationsInput, IdPInput } from "../../../types/idp.generated.mjs";
2
3
  import { IdPConfig, IdPExternalConfig, IdpDefinitionBrand } from "./types.mjs";
3
- import { IdPPermission, IdPPermissionCondition, unsafeAllowAllIdPPermission } from "./permission.mjs";
4
4
  //#region src/configure/services/idp/index.d.ts
5
5
  /**
6
6
  * Define an IdP service configuration for the Tailor SDK.
@@ -1,24 +1,9 @@
1
1
  import { InferredAttributeMap } from "../../../runtime/types.mjs";
2
+ import { UserBooleanArrayOperand, UserBooleanOperand, UserStringArrayOperand, UserStringOperand } from "../../types/permission-operand.types.mjs";
2
3
  import { IdPUserField } from "../../../parser/service/idp/types.mjs";
3
4
  //#region src/configure/services/idp/permission.d.ts
4
5
  type EqualityOperator = "=" | "!=";
5
6
  type ContainsOperator = "in" | "not in";
6
- type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never; }[keyof User];
7
- type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never; }[keyof User];
8
- type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never; }[keyof User];
9
- type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean[] ? K : never; }[keyof User];
10
- type UserStringOperand<User extends object = InferredAttributeMap> = {
11
- user: StringFieldKeys<User> | "id";
12
- };
13
- type UserStringArrayOperand<User extends object = InferredAttributeMap> = {
14
- user: StringArrayFieldKeys<User>;
15
- };
16
- type UserBooleanOperand<User extends object = InferredAttributeMap> = {
17
- user: BooleanFieldKeys<User> | "_loggedIn";
18
- };
19
- type UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {
20
- user: BooleanArrayFieldKeys<User>;
21
- };
22
7
  type IdPUserOperand<Update extends boolean = false> = Update extends true ? {
23
8
  oldIdpUser: IdPUserField;
24
9
  } | {
@@ -1,4 +1,5 @@
1
1
  import { BuiltinIdP } from "../../../types/auth.generated.mjs";
2
+ import { IdPPermission } from "./permission.mjs";
2
3
  import { IdPInput } from "../../../types/idp.generated.mjs";
3
4
  //#region src/configure/services/idp/types.d.ts
4
5
  declare const idpDefinitionBrand: unique symbol;
@@ -13,7 +14,10 @@ type IdPExternalConfig = {
13
14
  name: string;
14
15
  external: true;
15
16
  };
16
- type IdPOwnConfig = Omit<DefinedIdp<string, IdPInput, string>, "provider">;
17
+ type IdPOwnConfigInput = Omit<IdPInput, "permission"> & {
18
+ permission?: IdPPermission;
19
+ };
20
+ type IdPOwnConfig = Omit<DefinedIdp<string, IdPOwnConfigInput, string>, "provider">;
17
21
  type IdPConfig = IdPOwnConfig | IdPExternalConfig;
18
22
  //#endregion
19
23
  export { DefinedIdp, IdPConfig, IdPExternalConfig, IdPOwnConfig, IdpDefinitionBrand };
@@ -6,6 +6,7 @@ import { PermissionCondition, TailorTypeGqlPermission, TailorTypePermission, uns
6
6
  import { TailorAnyDBField, TailorAnyDBType, TailorDBField, TailorDBInstance, TailorDBType, db } from "./tailordb/schema.mjs";
7
7
  import "./tailordb/index.mjs";
8
8
  import { AIGatewayConfig } from "./aigateway/types.mjs";
9
+ import { IdPPermission, IdPPermissionCondition, unsafeAllowAllIdPPermission } from "./idp/permission.mjs";
9
10
  import { IdPEmailConfig, IdPGqlOperations, IdPGqlOperationsInput } from "../../types/idp.generated.mjs";
10
11
  import { IdPConfig, IdPExternalConfig } from "./idp/types.mjs";
11
12
  import { SecretsConfig } from "./secrets/types.mjs";
@@ -14,6 +15,7 @@ import { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExa
14
15
  import { ExecutorServiceConfig, ExecutorServiceInput, ResolverExternalConfig, ResolverServiceConfig, ResolverServiceInput, WorkflowServiceConfig, WorkflowServiceInput } from "../config/types.mjs";
15
16
  import { ConcurrencyPolicy, RetryPolicy } from "../../types/workflow.generated.mjs";
16
17
  import { AuthInvoker, defineAuth } from "./auth/index.mjs";
18
+ import { ResolverPermission, ResolverPermissionCondition, ResolverPermissionPolicy } from "./resolver/permission.mjs";
17
19
  import { createResolver } from "./resolver/resolver.mjs";
18
20
  import { QueryType } from "./resolver/types.mjs";
19
21
  import "./resolver/index.mjs";
@@ -32,9 +34,8 @@ import { WaitPointInstance, defineWaitPoint, defineWaitPoints } from "./workflow
32
34
  import "./workflow/index.mjs";
33
35
  import { defineStaticWebSite } from "./staticwebsite/index.mjs";
34
36
  import { defineAIGateway } from "./aigateway/index.mjs";
35
- import { IdPPermission, IdPPermissionCondition, unsafeAllowAllIdPPermission } from "./idp/permission.mjs";
36
37
  import { defineIdp } from "./idp/index.mjs";
37
38
  import { defineSecretManager } from "./secrets/index.mjs";
38
39
  import { HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, createHttpAdapter } from "./http-adapter/http-adapter.mjs";
39
40
  import "./http-adapter/index.mjs";
40
- export { type AIGatewayConfig, AuthAccessTokenArgs, AuthAccessTokenIssuedArgs, AuthAccessTokenRefreshedArgs, AuthAccessTokenRevokedArgs, AuthAccessTokenTrigger, type AuthConfig, type AuthConnectionConfig, type AuthConnectionOAuth2Config, type AuthConnectionTokenResult, type AuthExternalConfig, AuthInvoker, type AuthOwnConfig, type AuthServiceInput, type BeforeLoginClaims, type BeforeLoginHookArgs, type BuiltinIdP, type ConcurrencyPolicy, type DefinedAuth, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ExecutorServiceConfig, type ExecutorServiceInput, type FederatedIdentity, type FederatedIdentityClaims, type FederatedIdentityProvider, FunctionOperation, GqlOperation, HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, type IDToken, type IdPConfig, type IdPEmailConfig, type IdPExternalConfig, type IdPGqlOperations, type IdPGqlOperationsInput as IdPGqlOperationsConfig, type IdPPermission, type IdPPermissionCondition, type IdProvider as IdProviderConfig, IdpUserArgs, IdpUserCreatedArgs, IdpUserDeletedArgs, IdpUserTrigger, IdpUserUpdatedArgs, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, IncomingWebhookResponseConfig, IncomingWebhookTrigger, IncomingWebhookTriggerOptions, type OAuth2ClientInput as OAuth2Client, type OAuth2ClientGrantType, type OIDC, Operation, type PermissionCondition, type QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordUpdatedArgs, type ResolvedExecutionPolicyInstance, type Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, type ResolverExternalConfig, type ResolverServiceConfig, type ResolverServiceInput, type RetryPolicy, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleArgs, ScheduleTrigger, type SecretsConfig, type StaticWebsiteConfig, type TailorAnyDBField, type TailorAnyDBType, type TailorDBField, type TailorDBInstance, TailorDBTrigger, type TailorDBType, type TailorTypeGqlPermission, type TailorTypePermission, type TenantProvider as TenantProviderConfig, Trigger, type UserAttributeKey, type UserAttributeListKey, type UserAttributeMap, type UsernameFieldKey, type ValueOperand, WORKFLOW_TEST_ENV_KEY, WaitPointInstance, WebhookOperation, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, WorkflowOperation, type WorkflowServiceConfig, type WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createHttpAdapter, createResolver, createWorkflow, createWorkflowJob, db, defineAIGateway, defineAuth, defineIdp, defineSecretManager, defineStaticWebSite, defineWaitPoint, defineWaitPoints, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission };
41
+ export { type AIGatewayConfig, AuthAccessTokenArgs, AuthAccessTokenIssuedArgs, AuthAccessTokenRefreshedArgs, AuthAccessTokenRevokedArgs, AuthAccessTokenTrigger, type AuthConfig, type AuthConnectionConfig, type AuthConnectionOAuth2Config, type AuthConnectionTokenResult, type AuthExternalConfig, AuthInvoker, type AuthOwnConfig, type AuthServiceInput, type BeforeLoginClaims, type BeforeLoginHookArgs, type BuiltinIdP, type ConcurrencyPolicy, type DefinedAuth, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ExecutorServiceConfig, type ExecutorServiceInput, type FederatedIdentity, type FederatedIdentityClaims, type FederatedIdentityProvider, FunctionOperation, GqlOperation, HttpAdapter, HttpAdapterGraphQLQuery, HttpAdapterGraphQLRequest, HttpAdapterGraphQLResponse, HttpAdapterInput, HttpAdapterInputFn, HttpAdapterOutputFn, HttpAdapterRequest, HttpAdapterResponse, HttpAdapterTypedDocumentNode, type IDToken, type IdPConfig, type IdPEmailConfig, type IdPExternalConfig, type IdPGqlOperations, type IdPGqlOperationsInput as IdPGqlOperationsConfig, type IdPPermission, type IdPPermissionCondition, type IdProvider as IdProviderConfig, IdpUserArgs, IdpUserCreatedArgs, IdpUserDeletedArgs, IdpUserTrigger, IdpUserUpdatedArgs, IncomingWebhookArgs, IncomingWebhookRequest, IncomingWebhookResponse, IncomingWebhookResponseConfig, IncomingWebhookTrigger, IncomingWebhookTriggerOptions, type OAuth2ClientInput as OAuth2Client, type OAuth2ClientGrantType, type OIDC, Operation, type PermissionCondition, type QueryType, RecordCreatedArgs, RecordDeletedArgs, RecordUpdatedArgs, type ResolvedExecutionPolicyInstance, type Resolver, ResolverExecutedArgs, ResolverExecutedTrigger, type ResolverExternalConfig, type ResolverPermission, type ResolverPermissionCondition, type ResolverPermissionPolicy, type ResolverServiceConfig, type ResolverServiceInput, type RetryPolicy, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleArgs, ScheduleTrigger, type SecretsConfig, type StaticWebsiteConfig, type TailorAnyDBField, type TailorAnyDBType, type TailorDBField, type TailorDBInstance, TailorDBTrigger, type TailorDBType, type TailorTypeGqlPermission, type TailorTypePermission, type TenantProvider as TenantProviderConfig, Trigger, type UserAttributeKey, type UserAttributeListKey, type UserAttributeMap, type UsernameFieldKey, type ValueOperand, WORKFLOW_TEST_ENV_KEY, WaitPointInstance, WebhookOperation, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, WorkflowOperation, type WorkflowServiceConfig, type WorkflowServiceInput, authAccessTokenIssuedTrigger, authAccessTokenRefreshedTrigger, authAccessTokenRevokedTrigger, authAccessTokenTrigger, createExecutor, createHttpAdapter, createResolver, createWorkflow, createWorkflowJob, db, defineAIGateway, defineAuth, defineIdp, defineSecretManager, defineStaticWebSite, defineWaitPoint, defineWaitPoints, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy, idpUserCreatedTrigger, idpUserDeletedTrigger, idpUserTrigger, idpUserUpdatedTrigger, incomingWebhookTrigger, recordCreatedTrigger, recordDeletedTrigger, recordTrigger, recordUpdatedTrigger, resolverExecutedTrigger, scheduleTrigger, unsafeAllowAllGqlPermission, unsafeAllowAllIdPPermission, unsafeAllowAllTypePermission };
@@ -1,5 +1,6 @@
1
1
  import { Resolver } from "../../../types/resolver.generated.mjs";
2
2
  import { ResolverExternalConfig, ResolverServiceConfig, ResolverServiceInput } from "../../config/types.mjs";
3
+ import { ResolverPermission, ResolverPermissionCondition, ResolverPermissionPolicy } from "./permission.mjs";
3
4
  import { createResolver } from "./resolver.mjs";
4
5
  import { QueryType } from "./types.mjs";
5
- export { type QueryType, type Resolver, type ResolverExternalConfig, type ResolverServiceConfig, type ResolverServiceInput, createResolver };
6
+ export { type QueryType, type Resolver, type ResolverExternalConfig, type ResolverPermission, type ResolverPermissionCondition, type ResolverPermissionPolicy, type ResolverServiceConfig, type ResolverServiceInput, createResolver };
@@ -0,0 +1,64 @@
1
+ import { InferredAttributeMap } from "../../../runtime/types.mjs";
2
+ import { UserBooleanOperand, UserStringOperand } from "../../types/permission-operand.types.mjs";
3
+ //#region src/configure/services/resolver/permission.d.ts
4
+ type EqualityOperator = "=" | "!=";
5
+ type StringEqualityCondition<User extends object> = readonly [UserStringOperand<User>, EqualityOperator, string] | readonly [string, EqualityOperator, UserStringOperand<User>];
6
+ type BooleanEqualityCondition<User extends object> = readonly [UserBooleanOperand<User>, EqualityOperator, boolean] | readonly [boolean, EqualityOperator, UserBooleanOperand<User>];
7
+ /**
8
+ * A single condition for {@link ResolverPermission}.
9
+ *
10
+ * Only `user` operands are supported (unlike TailorDB's `record`/`newRecord`/
11
+ * `oldRecord` operands) — a resolver has no associated record to compare
12
+ * against. Only equality (`=`/`!=`) is supported for now.
13
+ *
14
+ * The User type is extended by `tailor.d.ts`, which is automatically generated
15
+ * when running `tailor-sdk generate`. Attributes enabled in the config file's
16
+ * `auth.userProfile.attributes` (or `auth.machineUserAttributes` when
17
+ * `userProfile` is omitted) become available as types.
18
+ */
19
+ type ResolverPermissionCondition<User extends object = InferredAttributeMap> = StringEqualityCondition<User> | BooleanEqualityCondition<User>;
20
+ /**
21
+ * A single access policy, in the same style as TailorDB's `.permission()`
22
+ * policies.
23
+ */
24
+ type ResolverPermissionPolicy<User extends object = InferredAttributeMap> = {
25
+ conditions: ResolverPermissionCondition<User> | readonly ResolverPermissionCondition<User>[];
26
+ /** Whether matching callers are granted (`true`) or denied (`false`) access. */
27
+ permit: boolean;
28
+ description?: string;
29
+ };
30
+ /**
31
+ * Access requirement for a resolver, evaluated against the original caller
32
+ * (`context.user`) before `body` runs — unaffected by `authInvoker`.
33
+ *
34
+ * At least one `permit: true` policy is required: a caller is granted only by
35
+ * a matching `permit: true` policy (deny by default), and a matching
36
+ * `permit: false` policy always overrides that grant, even when another
37
+ * policy would otherwise allow the same caller — use it to carve out an
38
+ * explicit exception from a broader grant. A policy array with only
39
+ * `permit: false` policies is rejected, since none of its conditions apply to
40
+ * a caller presenting no user attributes at all (e.g. one who simply doesn't
41
+ * authenticate), so it wouldn't actually keep anyone out. `"allowAnonymous"`
42
+ * explicitly documents that anonymous callers are allowed.
43
+ * @example
44
+ * const permission: ResolverPermission = [
45
+ * { conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true },
46
+ * ];
47
+ * @example
48
+ * // Allow machine-user callers unconditionally, gate regular users behind a role
49
+ * const permission: ResolverPermission = [
50
+ * { conditions: [[{ user: "isServiceAccount" }, "=", true]], permit: true },
51
+ * { conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true },
52
+ * ];
53
+ * @example
54
+ * // Exception: allow logged-in users broadly, but reject a banned role
55
+ * const permission: ResolverPermission = [
56
+ * { conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true },
57
+ * { conditions: [[{ user: "role" }, "=", "BANNED"]], permit: false },
58
+ * ];
59
+ * @example
60
+ * const permission: ResolverPermission = "allowAnonymous";
61
+ */
62
+ type ResolverPermission<User extends object = InferredAttributeMap> = readonly ResolverPermissionPolicy<User>[] | "allowAnonymous";
63
+ //#endregion
64
+ export { ResolverPermission, ResolverPermissionCondition, ResolverPermissionPolicy };
@@ -4,6 +4,7 @@ import { ResolverInput } from "../../../types/resolver.generated.mjs";
4
4
  import { TailorAnyField, TailorField } from "../../types/type.mjs";
5
5
  import { MachineUserName } from "../../types/machine-user.mjs";
6
6
  import { AuthInvoker } from "../auth/index.mjs";
7
+ import { ResolverPermission } from "./permission.mjs";
7
8
  //#region src/configure/services/resolver/resolver.d.ts
8
9
  type Context<Input extends Record<string, TailorAnyField> | undefined> = {
9
10
  input: Input extends Record<string, TailorAnyField> ? InferFieldsOutput<Input> : never;
@@ -21,11 +22,12 @@ type NormalizedOutput<Output extends TailorAnyField | Record<string, TailorAnyFi
21
22
  type: "nested";
22
23
  array: false;
23
24
  }, InferFieldsOutput<Extract<Output, Record<string, TailorAnyField>>>>;
24
- type ResolverReturn<Input extends Record<string, TailorAnyField> | undefined, Output extends TailorAnyField | Record<string, TailorAnyField>> = Omit<ResolverInput, "input" | "output" | "body" | "authInvoker"> & Readonly<{
25
+ type ResolverReturn<Input extends Record<string, TailorAnyField> | undefined, Output extends TailorAnyField | Record<string, TailorAnyField>> = Omit<ResolverInput, "input" | "output" | "body" | "authInvoker" | "permission"> & Readonly<{
25
26
  input?: Input;
26
27
  output: NormalizedOutput<Output>;
27
28
  body: (context: Context<Input>) => OutputType<Output> | Promise<OutputType<Output>>;
28
29
  authInvoker?: AuthInvoker<string> | MachineUserName;
30
+ permission?: ResolverPermission;
29
31
  }>;
30
32
  /**
31
33
  * Create a resolver definition for the Tailor SDK.
@@ -41,6 +43,14 @@ type ResolverReturn<Input extends Record<string, TailorAnyField> | undefined, Ou
41
43
  * If not specified, this is automatically set to true when an executor uses this resolver
42
44
  * with `resolverExecutedTrigger`. If explicitly set to false while an executor uses this
43
45
  * resolver, an error will be thrown during apply.
46
+ *
47
+ * `permission` declares the resolver's access requirement, checked against `context.user` (the
48
+ * original caller, unaffected by `authInvoker`) before `body` runs. Omitted (default):
49
+ * unchanged, anonymous callers can reach the resolver. `"allowAnonymous"`: explicitly documents
50
+ * that anonymous callers are allowed. An array of `{ conditions, permit }` policies (in the same
51
+ * style as TailorDB's `.permission()`) rejects non-matching callers: at least one `permit: true`
52
+ * policy is required (denied unless it matches), and a matching `permit: false` policy always
53
+ * overrides that grant.
44
54
  * @template Input
45
55
  * @template Output
46
56
  * @param config - Resolver configuration
@@ -51,6 +61,7 @@ type ResolverReturn<Input extends Record<string, TailorAnyField> | undefined, Ou
51
61
  * export default createResolver({
52
62
  * name: "getUser",
53
63
  * operation: "query",
64
+ * permission: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
54
65
  * input: {
55
66
  * id: t.string(),
56
67
  * },
@@ -65,11 +76,12 @@ type ResolverReturn<Input extends Record<string, TailorAnyField> | undefined, Ou
65
76
  * }),
66
77
  * });
67
78
  */
68
- declare function createResolver<Input extends Record<string, TailorAnyField> | undefined = undefined, Output extends TailorAnyField | Record<string, TailorAnyField> = TailorAnyField>(config: Omit<ResolverInput, "input" | "output" | "body" | "authInvoker"> & Readonly<{
79
+ declare function createResolver<Input extends Record<string, TailorAnyField> | undefined = undefined, Output extends TailorAnyField | Record<string, TailorAnyField> = TailorAnyField>(config: Omit<ResolverInput, "input" | "output" | "body" | "authInvoker" | "permission"> & Readonly<{
69
80
  input?: Input;
70
81
  output: Output;
71
82
  body: (context: Context<Input>) => OutputType<Output> | Promise<OutputType<Output>>;
72
83
  authInvoker?: AuthInvoker<string> | MachineUserName;
84
+ permission?: ResolverPermission;
73
85
  }>): ResolverReturn<Input, Output>;
74
86
  type ResolverConfig = ReturnType<typeof createResolver<any, any>>;
75
87
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { InferredAttributeMap } from "../../../runtime/types.mjs";
2
+ import { UserBooleanArrayOperand, UserBooleanOperand, UserStringArrayOperand, UserStringOperand } from "../../types/permission-operand.types.mjs";
2
3
  //#region src/configure/services/tailordb/permission.d.ts
3
4
  /**
4
5
  * Record-level permission configuration for a TailorDB type.
@@ -47,22 +48,6 @@ type GqlPermissionAction = "read" | "create" | "update" | "delete" | "aggregate"
47
48
  type EqualityOperator = "=" | "!=";
48
49
  type ContainsOperator = "in" | "not in";
49
50
  type HasAnyOperator = "hasAny" | "not hasAny";
50
- type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never; }[keyof User];
51
- type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never; }[keyof User];
52
- type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never; }[keyof User];
53
- type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean[] ? K : never; }[keyof User];
54
- type UserStringOperand<User extends object = InferredAttributeMap> = {
55
- user: StringFieldKeys<User> | "id";
56
- };
57
- type UserStringArrayOperand<User extends object = InferredAttributeMap> = {
58
- user: StringArrayFieldKeys<User>;
59
- };
60
- type UserBooleanOperand<User extends object = InferredAttributeMap> = {
61
- user: BooleanFieldKeys<User> | "_loggedIn";
62
- };
63
- type UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {
64
- user: BooleanArrayFieldKeys<User>;
65
- };
66
51
  type RecordOperand<Type extends object, Update extends boolean = false> = Update extends true ? {
67
52
  oldRecord: (keyof Type & string) | "id";
68
53
  } | {
@@ -0,0 +1,20 @@
1
+ import { InferredAttributeMap } from "../../runtime/types.mjs";
2
+ //#region src/configure/types/permission-operand.types.d.ts
3
+ type StringFieldKeys<User extends object> = { [K in keyof User]: NonNullable<User[K]> extends string ? K : never; }[keyof User];
4
+ type StringArrayFieldKeys<User extends object> = { [K in keyof User]: NonNullable<User[K]> extends string[] ? K : never; }[keyof User];
5
+ type BooleanFieldKeys<User extends object> = { [K in keyof User]: NonNullable<User[K]> extends boolean ? K : never; }[keyof User];
6
+ type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: NonNullable<User[K]> extends boolean[] ? K : never; }[keyof User];
7
+ type UserStringOperand<User extends object = InferredAttributeMap> = {
8
+ user: StringFieldKeys<User> | "id";
9
+ };
10
+ type UserStringArrayOperand<User extends object = InferredAttributeMap> = {
11
+ user: StringArrayFieldKeys<User>;
12
+ };
13
+ type UserBooleanOperand<User extends object = InferredAttributeMap> = {
14
+ user: BooleanFieldKeys<User> | "_loggedIn";
15
+ };
16
+ type UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {
17
+ user: BooleanArrayFieldKeys<User>;
18
+ };
19
+ //#endregion
20
+ export { BooleanArrayFieldKeys, BooleanFieldKeys, StringArrayFieldKeys, StringFieldKeys, UserBooleanArrayOperand, UserBooleanOperand, UserStringArrayOperand, UserStringOperand };
@@ -77,23 +77,39 @@ var TailorDBFileErrorMock = class extends Error {
77
77
  function defaultGetInvoker() {
78
78
  return null;
79
79
  }
80
+ function noop() {}
81
+ const defaultLogger = {
82
+ debug: noop,
83
+ info: noop,
84
+ warn: noop,
85
+ error: noop,
86
+ setAttributes: noop
87
+ };
80
88
  /**
81
89
  * Install the always-present base platform globals (containers, context stub,
82
90
  * error classes, runtime flag). Per-namespace mocks are layered on top by the
83
91
  * `xMock()` factories in `./mock`.
92
+ *
93
+ * Acquire with a `using` declaration and the globals are removed when the
94
+ * scope exits; alternatively call `cleanupPlatformGlobals` yourself.
84
95
  * @param global - The global object to install into (typically `globalThis`)
96
+ * @returns A `Disposable` that removes the installed globals
85
97
  */
86
98
  function installPlatformGlobals(global) {
87
99
  const g = global;
88
100
  g[RUNTIME_FLAG_KEY] = true;
89
101
  g.tailor = {
90
102
  context: { getInvoker: defaultGetInvoker },
91
- workflow: createDefaultWorkflowRuntime()
103
+ workflow: createDefaultWorkflowRuntime(),
104
+ logger: { ...defaultLogger }
92
105
  };
93
106
  g.tailordb = {};
94
107
  g.TailorErrors = TailorErrorsMock;
95
108
  g.TailorErrorMessage = TailorErrorMessageMock;
96
109
  g.TailorDBFileError = TailorDBFileErrorMock;
110
+ return { [Symbol.dispose]() {
111
+ cleanupPlatformGlobals(global);
112
+ } };
97
113
  }
98
114
  /**
99
115
  * Remove the base platform globals (and anything the namespace mocks layered on
@@ -112,4 +128,4 @@ function cleanupPlatformGlobals(global) {
112
128
 
113
129
  //#endregion
114
130
  export { cleanupPlatformGlobals as n, installPlatformGlobals as r, RUNTIME_FLAG_KEY as t };
115
- //# sourceMappingURL=globals-B-n_3uYu.mjs.map
131
+ //# sourceMappingURL=globals-DUqEetIh.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"globals-B-n_3uYu.mjs","names":[],"sources":["../src/vitest/workflow-runtime.ts","../src/vitest/globals.ts"],"sourcesContent":["// Default `tailor.workflow` runner installed by the `tailor-runtime` environment.\n// Must stay free of `vitest` (`vi`): it loads via `./globals` in the environment\n// realm where `vi` is unavailable, hence relative imports only (no `@/` alias).\nimport { runRegisteredJob, runRegisteredWorkflow } from \"../configure/services/workflow/registry\";\nimport type { StartJobFunctionOptions, StartWorkflowOptions } from \"../runtime/workflow\";\n\nexport interface DefaultWorkflowRuntime {\n startJobFunction: (name: string, args?: unknown, options?: StartJobFunctionOptions) => unknown;\n triggerJobFunction: (name: string, args?: unknown, options?: StartJobFunctionOptions) => unknown;\n startWorkflow: (name: string, args?: unknown, options?: StartWorkflowOptions) => Promise<string>;\n triggerWorkflow: (\n name: string,\n args?: unknown,\n options?: StartWorkflowOptions,\n ) => Promise<string>;\n resumeWorkflowExecution: (executionId: string) => Promise<string>;\n resumeWorkflow: (executionId: string) => Promise<string>;\n wait: (key: string, payload?: unknown) => unknown;\n resolve: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n}\n\nexport function createDefaultWorkflowRuntime(): DefaultWorkflowRuntime {\n const startJobFunction: DefaultWorkflowRuntime[\"startJobFunction\"] = (name, args) =>\n runRegisteredJob(name, args);\n const startWorkflow: DefaultWorkflowRuntime[\"startWorkflow\"] = (name, args) =>\n runRegisteredWorkflow(name, args);\n const resumeWorkflowExecution: DefaultWorkflowRuntime[\"resumeWorkflowExecution\"] = async (\n executionId,\n ) => executionId;\n return {\n startJobFunction,\n triggerJobFunction: startJobFunction,\n startWorkflow,\n triggerWorkflow: startWorkflow,\n resumeWorkflowExecution,\n resumeWorkflow: resumeWorkflowExecution,\n wait: (key: string): unknown => {\n throw new Error(\n `No wait handler for \"${key}\". Acquire mockWorkflow() and call setWaitHandler(...).`,\n );\n },\n resolve: async (): Promise<void> => {\n throw new Error(\n \"No resolve handler. Acquire mockWorkflow() and call setResolveHandler(...).\",\n );\n },\n };\n}\n","/**\n * Base platform globals for the tailor-runtime test environment.\n *\n * This module is intentionally free of any `vitest` (`vi`) dependency so it can\n * be imported from the Vitest *environment* module (which runs in a realm where\n * `vi` is not available). It installs only the always-present structural pieces:\n *\n * - `globalThis.tailor` / `globalThis.tailordb` container objects\n * - `globalThis.tailor.context.getInvoker` default stub\n * - the platform error classes (`TailorErrors`, `TailorErrorMessage`,\n * `TailorDBFileError`)\n * - the `__tailorRuntimeActive` sentinel flag\n *\n * The per-namespace mock behavior (TailorDB client, workflow, secretmanager, …)\n * is installed on demand by the `xMock()` factories in `./mock`, which run in\n * test context where `vi` *is* available.\n */\n\nimport { createDefaultWorkflowRuntime } from \"./workflow-runtime\";\nimport type { ContextInvoker } from \"../runtime/context\";\nimport type { TailorDBFileErrorCode } from \"../runtime/file\";\n\n// Sentinel set when the tailor-runtime environment is active. setup.ts reads it\n// to decide whether to run its blocked-globals lifecycle and config-secret\n// loading.\nexport const RUNTIME_FLAG_KEY = \"__tailorRuntimeActive\";\n\n// ---------------------------------------------------------------------------\n// Error class mocks\n// ---------------------------------------------------------------------------\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\nclass TailorErrorsMock extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n if (!Array.isArray(errors)) {\n throw new TypeError(\"TailorErrors: errors must be an array\");\n }\n const validated = errors.map((e, i) => {\n if (typeof e.message !== \"string\") {\n throw new TypeError(`TailorErrors: errors[${i}].message must be a string`);\n }\n if (!Array.isArray(e.path)) {\n throw new TypeError(`TailorErrors: errors[${i}].path must be an array`);\n }\n return { message: e.message, path: e.path };\n });\n // Match the PF runtime's TailorErrors serialization, which prefixes the\n // JSON payload with \"TailorErrors: \". Other SDK code (e.g. apply\n // integration fixtures) strips this prefix before JSON.parse.\n super(`TailorErrors: ${JSON.stringify({ errors: validated })}`);\n this.name = \"TailorErrors\";\n this.errors = validated;\n }\n}\n\nclass TailorErrorMessageMock extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"TailorErrorMessage\";\n }\n}\n\nclass TailorDBFileErrorMock extends Error {\n code?: TailorDBFileErrorCode;\n override cause: unknown;\n\n constructor(message: string, code?: TailorDBFileErrorCode, cause?: unknown) {\n super(message);\n this.name = \"TailorDBFileError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Base install / cleanup\n// ---------------------------------------------------------------------------\n\n// Stub-only injection. SDK consumers configure invokers at the body level\n// (resolver/executor/workflow `.body()` `invoker` arg) or, for bundled tests,\n// via `vi.spyOn(globalThis.tailor.context, \"getInvoker\")`.\nfunction defaultGetInvoker(): ContextInvoker | null {\n return null;\n}\n\n/**\n * Install the always-present base platform globals (containers, context stub,\n * error classes, runtime flag). Per-namespace mocks are layered on top by the\n * `xMock()` factories in `./mock`.\n * @param global - The global object to install into (typically `globalThis`)\n */\nexport function installPlatformGlobals(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n\n g[RUNTIME_FLAG_KEY] = true;\n\n // Containers. Namespace mocks (secretmanager, …) are added to these by the\n // corresponding `xMock()` on acquisition. `workflow` carries a default runner\n // so `.trigger()` runs the real job chain locally without `mockWorkflow()`;\n // `mockWorkflow()` overlays and restores it.\n g.tailor = {\n context: { getInvoker: defaultGetInvoker },\n workflow: createDefaultWorkflowRuntime(),\n };\n g.tailordb = {};\n\n g.TailorErrors = TailorErrorsMock;\n g.TailorErrorMessage = TailorErrorMessageMock;\n g.TailorDBFileError = TailorDBFileErrorMock;\n}\n\n/**\n * Remove the base platform globals (and anything the namespace mocks layered on\n * top, since they live under the same containers).\n * @param global - The global object to clean up (typically `globalThis`)\n */\nexport function cleanupPlatformGlobals(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n delete g.tailordb;\n delete g.tailor;\n delete g.TailorErrors;\n delete g.TailorErrorMessage;\n delete g.TailorDBFileError;\n delete g[RUNTIME_FLAG_KEY];\n}\n"],"mappings":";;;AAyBA,SAAgB,+BAAuD;CACrE,MAAM,oBAAgE,MAAM,SAC1E,iBAAiB,MAAM,IAAI;CAC7B,MAAM,iBAA0D,MAAM,SACpE,sBAAsB,MAAM,IAAI;CAClC,MAAM,0BAA6E,OACjF,gBACG;CACL,OAAO;EACL;EACA,oBAAoB;EACpB;EACA,iBAAiB;EACjB;EACA,gBAAgB;EAChB,OAAO,QAAyB;GAC9B,MAAM,IAAI,MACR,wBAAwB,IAAI,wDAC9B;EACF;EACA,SAAS,YAA2B;GAClC,MAAM,IAAI,MACR,6EACF;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;AC1BA,MAAa,mBAAmB;AAWhC,IAAM,mBAAN,cAA+B,MAAM;CACnC;CAEA,YAAY,QAA2B;EACrC,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,MAAM,IAAI,UAAU,uCAAuC;EAE7D,MAAM,YAAY,OAAO,KAAK,GAAG,MAAM;GACrC,IAAI,OAAO,EAAE,YAAY,UACvB,MAAM,IAAI,UAAU,wBAAwB,EAAE,2BAA2B;GAE3E,IAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,GACvB,MAAM,IAAI,UAAU,wBAAwB,EAAE,wBAAwB;GAExE,OAAO;IAAE,SAAS,EAAE;IAAS,MAAM,EAAE;GAAK;EAC5C,CAAC;EAID,MAAM,iBAAiB,KAAK,UAAU,EAAE,QAAQ,UAAU,CAAC,GAAG;EAC9D,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAEA,IAAM,yBAAN,cAAqC,MAAM;CACzC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,IAAM,wBAAN,cAAoC,MAAM;CACxC;CACA,AAAS;CAET,YAAY,SAAiB,MAA8B,OAAiB;EAC1E,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AASA,SAAS,oBAA2C;CAClD,OAAO;AACT;;;;;;;AAQA,SAAgB,uBAAuB,QAAiC;CACtE,MAAM,IAAI;CAEV,EAAE,oBAAoB;CAMtB,EAAE,SAAS;EACT,SAAS,EAAE,YAAY,kBAAkB;EACzC,UAAU,6BAA6B;CACzC;CACA,EAAE,WAAW,CAAC;CAEd,EAAE,eAAe;CACjB,EAAE,qBAAqB;CACvB,EAAE,oBAAoB;AACxB;;;;;;AAOA,SAAgB,uBAAuB,QAAiC;CACtE,MAAM,IAAI;CACV,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;AACX"}
1
+ {"version":3,"file":"globals-DUqEetIh.mjs","names":[],"sources":["../src/vitest/workflow-runtime.ts","../src/vitest/globals.ts"],"sourcesContent":["// Default `tailor.workflow` runner installed by the `tailor-runtime` environment.\n// Must stay free of `vitest` (`vi`): it loads via `./globals` in the environment\n// realm where `vi` is unavailable, hence relative imports only (no `@/` alias).\nimport { runRegisteredJob, runRegisteredWorkflow } from \"../configure/services/workflow/registry\";\nimport type { StartJobFunctionOptions, StartWorkflowOptions } from \"../runtime/workflow\";\n\nexport interface DefaultWorkflowRuntime {\n startJobFunction: (name: string, args?: unknown, options?: StartJobFunctionOptions) => unknown;\n triggerJobFunction: (name: string, args?: unknown, options?: StartJobFunctionOptions) => unknown;\n startWorkflow: (name: string, args?: unknown, options?: StartWorkflowOptions) => Promise<string>;\n triggerWorkflow: (\n name: string,\n args?: unknown,\n options?: StartWorkflowOptions,\n ) => Promise<string>;\n resumeWorkflowExecution: (executionId: string) => Promise<string>;\n resumeWorkflow: (executionId: string) => Promise<string>;\n wait: (key: string, payload?: unknown) => unknown;\n resolve: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n}\n\nexport function createDefaultWorkflowRuntime(): DefaultWorkflowRuntime {\n const startJobFunction: DefaultWorkflowRuntime[\"startJobFunction\"] = (name, args) =>\n runRegisteredJob(name, args);\n const startWorkflow: DefaultWorkflowRuntime[\"startWorkflow\"] = (name, args) =>\n runRegisteredWorkflow(name, args);\n const resumeWorkflowExecution: DefaultWorkflowRuntime[\"resumeWorkflowExecution\"] = async (\n executionId,\n ) => executionId;\n return {\n startJobFunction,\n triggerJobFunction: startJobFunction,\n startWorkflow,\n triggerWorkflow: startWorkflow,\n resumeWorkflowExecution,\n resumeWorkflow: resumeWorkflowExecution,\n wait: (key: string): unknown => {\n throw new Error(\n `No wait handler for \"${key}\". Acquire mockWorkflow() and call setWaitHandler(...).`,\n );\n },\n resolve: async (): Promise<void> => {\n throw new Error(\n \"No resolve handler. Acquire mockWorkflow() and call setResolveHandler(...).\",\n );\n },\n };\n}\n","/**\n * Base platform globals for the tailor-runtime test environment.\n *\n * This module is intentionally free of any `vitest` (`vi`) dependency so it can\n * be imported from the Vitest *environment* module (which runs in a realm where\n * `vi` is not available). It installs only the always-present structural pieces:\n *\n * - `globalThis.tailor` / `globalThis.tailordb` container objects\n * - `globalThis.tailor.context.getInvoker` default stub\n * - the platform error classes (`TailorErrors`, `TailorErrorMessage`,\n * `TailorDBFileError`)\n * - the `__tailorRuntimeActive` sentinel flag\n *\n * The per-namespace mock behavior (TailorDB client, workflow, secretmanager, …)\n * is installed on demand by the `xMock()` factories in `./mock`, which run in\n * test context where `vi` *is* available.\n */\n\nimport { createDefaultWorkflowRuntime } from \"./workflow-runtime\";\nimport type { ContextInvoker } from \"../runtime/context\";\nimport type { TailorDBFileErrorCode } from \"../runtime/file\";\n\n// Sentinel set when the tailor-runtime environment is active. setup.ts reads it\n// to decide whether to run its blocked-globals lifecycle and config-secret\n// loading.\nexport const RUNTIME_FLAG_KEY = \"__tailorRuntimeActive\";\n\n// ---------------------------------------------------------------------------\n// Error class mocks\n// ---------------------------------------------------------------------------\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\nclass TailorErrorsMock extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n if (!Array.isArray(errors)) {\n throw new TypeError(\"TailorErrors: errors must be an array\");\n }\n const validated = errors.map((e, i) => {\n if (typeof e.message !== \"string\") {\n throw new TypeError(`TailorErrors: errors[${i}].message must be a string`);\n }\n if (!Array.isArray(e.path)) {\n throw new TypeError(`TailorErrors: errors[${i}].path must be an array`);\n }\n return { message: e.message, path: e.path };\n });\n // Match the PF runtime's TailorErrors serialization, which prefixes the\n // JSON payload with \"TailorErrors: \". Other SDK code (e.g. apply\n // integration fixtures) strips this prefix before JSON.parse.\n super(`TailorErrors: ${JSON.stringify({ errors: validated })}`);\n this.name = \"TailorErrors\";\n this.errors = validated;\n }\n}\n\nclass TailorErrorMessageMock extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"TailorErrorMessage\";\n }\n}\n\nclass TailorDBFileErrorMock extends Error {\n code?: TailorDBFileErrorCode;\n override cause: unknown;\n\n constructor(message: string, code?: TailorDBFileErrorCode, cause?: unknown) {\n super(message);\n this.name = \"TailorDBFileError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Base install / cleanup\n// ---------------------------------------------------------------------------\n\n// Stub-only injection. SDK consumers configure invokers at the body level\n// (resolver/executor/workflow `.body()` `invoker` arg) or, for bundled tests,\n// via `vi.spyOn(globalThis.tailor.context, \"getInvoker\")`.\nfunction defaultGetInvoker(): ContextInvoker | null {\n return null;\n}\n\n// No-op logger stub so `tailor.logger.*` calls in code under test don't throw\n// without an explicit `mockLogger()`. `mockLogger()` overlays vi.fn spies and\n// restores this on dispose.\nfunction noop(): void {}\nconst defaultLogger = {\n debug: noop,\n info: noop,\n warn: noop,\n error: noop,\n setAttributes: noop,\n};\n\n/**\n * Install the always-present base platform globals (containers, context stub,\n * error classes, runtime flag). Per-namespace mocks are layered on top by the\n * `xMock()` factories in `./mock`.\n *\n * Acquire with a `using` declaration and the globals are removed when the\n * scope exits; alternatively call `cleanupPlatformGlobals` yourself.\n * @param global - The global object to install into (typically `globalThis`)\n * @returns A `Disposable` that removes the installed globals\n */\nexport function installPlatformGlobals(global: typeof globalThis): Disposable {\n const g = global as Record<string, unknown>;\n\n g[RUNTIME_FLAG_KEY] = true;\n\n // Containers. Namespace mocks (secretmanager, …) are added to these by the\n // corresponding `xMock()` on acquisition. `workflow` carries a default runner\n // so `.trigger()` runs the real job chain locally without `mockWorkflow()`;\n // `mockWorkflow()` overlays and restores it.\n g.tailor = {\n context: { getInvoker: defaultGetInvoker },\n workflow: createDefaultWorkflowRuntime(),\n logger: { ...defaultLogger },\n };\n g.tailordb = {};\n\n g.TailorErrors = TailorErrorsMock;\n g.TailorErrorMessage = TailorErrorMessageMock;\n g.TailorDBFileError = TailorDBFileErrorMock;\n\n return {\n [Symbol.dispose]() {\n cleanupPlatformGlobals(global);\n },\n };\n}\n\n/**\n * Remove the base platform globals (and anything the namespace mocks layered on\n * top, since they live under the same containers).\n * @param global - The global object to clean up (typically `globalThis`)\n */\nexport function cleanupPlatformGlobals(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n delete g.tailordb;\n delete g.tailor;\n delete g.TailorErrors;\n delete g.TailorErrorMessage;\n delete g.TailorDBFileError;\n delete g[RUNTIME_FLAG_KEY];\n}\n"],"mappings":";;;AAyBA,SAAgB,+BAAuD;CACrE,MAAM,oBAAgE,MAAM,SAC1E,iBAAiB,MAAM,IAAI;CAC7B,MAAM,iBAA0D,MAAM,SACpE,sBAAsB,MAAM,IAAI;CAClC,MAAM,0BAA6E,OACjF,gBACG;CACL,OAAO;EACL;EACA,oBAAoB;EACpB;EACA,iBAAiB;EACjB;EACA,gBAAgB;EAChB,OAAO,QAAyB;GAC9B,MAAM,IAAI,MACR,wBAAwB,IAAI,wDAC9B;EACF;EACA,SAAS,YAA2B;GAClC,MAAM,IAAI,MACR,6EACF;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;AC1BA,MAAa,mBAAmB;AAWhC,IAAM,mBAAN,cAA+B,MAAM;CACnC;CAEA,YAAY,QAA2B;EACrC,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,MAAM,IAAI,UAAU,uCAAuC;EAE7D,MAAM,YAAY,OAAO,KAAK,GAAG,MAAM;GACrC,IAAI,OAAO,EAAE,YAAY,UACvB,MAAM,IAAI,UAAU,wBAAwB,EAAE,2BAA2B;GAE3E,IAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,GACvB,MAAM,IAAI,UAAU,wBAAwB,EAAE,wBAAwB;GAExE,OAAO;IAAE,SAAS,EAAE;IAAS,MAAM,EAAE;GAAK;EAC5C,CAAC;EAID,MAAM,iBAAiB,KAAK,UAAU,EAAE,QAAQ,UAAU,CAAC,GAAG;EAC9D,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAEA,IAAM,yBAAN,cAAqC,MAAM;CACzC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,IAAM,wBAAN,cAAoC,MAAM;CACxC;CACA,AAAS;CAET,YAAY,SAAiB,MAA8B,OAAiB;EAC1E,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AASA,SAAS,oBAA2C;CAClD,OAAO;AACT;AAKA,SAAS,OAAa,CAAC;AACvB,MAAM,gBAAgB;CACpB,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,eAAe;AACjB;;;;;;;;;;;AAYA,SAAgB,uBAAuB,QAAuC;CAC5E,MAAM,IAAI;CAEV,EAAE,oBAAoB;CAMtB,EAAE,SAAS;EACT,SAAS,EAAE,YAAY,kBAAkB;EACzC,UAAU,6BAA6B;EACvC,QAAQ,EAAE,GAAG,cAAc;CAC7B;CACA,EAAE,WAAW,CAAC;CAEd,EAAE,eAAe;CACjB,EAAE,qBAAqB;CACvB,EAAE,oBAAoB;CAEtB,OAAO,EACL,CAAC,OAAO,WAAW;EACjB,uBAAuB,MAAM;CAC/B,EACF;AACF;;;;;;AAOA,SAAgB,uBAAuB,QAAiC;CACtE,MAAM,IAAI;CACV,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;AACX"}
@@ -0,0 +1,50 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DXywRVcq.mjs";
2
+
3
+ //#region src/runtime/logger.ts
4
+ var logger_exports = /* @__PURE__ */ __exportAll({
5
+ debug: () => debug,
6
+ error: () => error,
7
+ info: () => info,
8
+ setAttributes: () => setAttributes,
9
+ warn: () => warn
10
+ });
11
+ const api = () => globalThis.tailor.logger;
12
+ /**
13
+ * See {@link TailorLoggerAPI.debug}.
14
+ * @param args - Forwarded to {@link TailorLoggerAPI.debug}
15
+ */
16
+ const debug = (...args) => {
17
+ api().debug(...args);
18
+ };
19
+ /**
20
+ * See {@link TailorLoggerAPI.info}.
21
+ * @param args - Forwarded to {@link TailorLoggerAPI.info}
22
+ */
23
+ const info = (...args) => {
24
+ api().info(...args);
25
+ };
26
+ /**
27
+ * See {@link TailorLoggerAPI.warn}.
28
+ * @param args - Forwarded to {@link TailorLoggerAPI.warn}
29
+ */
30
+ const warn = (...args) => {
31
+ api().warn(...args);
32
+ };
33
+ /**
34
+ * See {@link TailorLoggerAPI.error}.
35
+ * @param args - Forwarded to {@link TailorLoggerAPI.error}
36
+ */
37
+ const error = (...args) => {
38
+ api().error(...args);
39
+ };
40
+ /**
41
+ * See {@link TailorLoggerAPI.setAttributes}.
42
+ * @param args - Forwarded to {@link TailorLoggerAPI.setAttributes}
43
+ */
44
+ const setAttributes = (...args) => {
45
+ api().setAttributes(...args);
46
+ };
47
+
48
+ //#endregion
49
+ export { setAttributes as a, logger_exports as i, error as n, warn as o, info as r, debug as t };
50
+ //# sourceMappingURL=logger-B-fqZe2W.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-B-fqZe2W.mjs","names":[],"sources":["../src/runtime/logger.ts"],"sourcesContent":["/**\n * Structured logging utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.logger` runtime API.\n * At runtime this delegates to `globalThis.tailor.logger`. Use `mockLogger`\n * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n *\n * Unlike `console.*`, each call carries a severity and structured attributes.\n * The message is written to standard output, and the full entry with its\n * attributes is exported over OpenTelemetry, where the attributes are queryable.\n * @example\n * import { logger } from \"@tailor-platform/sdk/runtime\";\n *\n * logger.setAttributes({ requestId: \"r-123\" });\n * logger.info(\"order processed\", { orderId: \"o-1\", total: 99.5 });\n */\n\n/**\n * A single log attribute value. Values outside this union (`null`, nested\n * objects, mixed-type arrays) are silently dropped by the platform.\n */\nexport type LogAttributeValue =\n | string\n | number\n | boolean\n | readonly string[]\n | readonly number[]\n | readonly boolean[];\n\n/**\n * Structured attributes attached to a log entry. The platform keeps at most 32\n * entries, drops any entry whose key exceeds 128 bytes, and truncates string\n * values over 4096 bytes and arrays over 64 elements.\n */\nexport type LogAttributes = Record<string, LogAttributeValue>;\n\n/**\n * Platform API surface for `tailor.logger`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.logger`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module so callers can either `import * as logger from\n * \"@tailor-platform/sdk/runtime/logger\"` or pick individual methods.\n */\nexport interface TailorLoggerAPI {\n /**\n * Emits a `debug`-severity log entry.\n * @param message - The log message\n * @param attributes - Structured attributes to attach to this entry\n */\n debug(message: string, attributes?: LogAttributes): void;\n\n /**\n * Emits an `info`-severity log entry.\n * @param message - The log message\n * @param attributes - Structured attributes to attach to this entry\n */\n info(message: string, attributes?: LogAttributes): void;\n\n /**\n * Emits a `warn`-severity log entry.\n * @param message - The log message\n * @param attributes - Structured attributes to attach to this entry\n */\n warn(message: string, attributes?: LogAttributes): void;\n\n /**\n * Emits an `error`-severity log entry.\n * @param message - The log message\n * @param attributes - Structured attributes to attach to this entry\n */\n error(message: string, attributes?: LogAttributes): void;\n\n /**\n * Merges attributes into every subsequent log entry from the current\n * execution. Later keys overwrite earlier ones; per-call attributes passed to\n * `debug`/`info`/`warn`/`error` take precedence.\n * @param attributes - Attributes to attach to subsequent entries\n */\n setAttributes(attributes: LogAttributes): void;\n}\n\nconst api = (): TailorLoggerAPI =>\n (globalThis as { tailor: { logger: TailorLoggerAPI } }).tailor.logger;\n\n/**\n * See {@link TailorLoggerAPI.debug}.\n * @param args - Forwarded to {@link TailorLoggerAPI.debug}\n */\nexport const debug: TailorLoggerAPI[\"debug\"] = (...args) => {\n api().debug(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.info}.\n * @param args - Forwarded to {@link TailorLoggerAPI.info}\n */\nexport const info: TailorLoggerAPI[\"info\"] = (...args) => {\n api().info(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.warn}.\n * @param args - Forwarded to {@link TailorLoggerAPI.warn}\n */\nexport const warn: TailorLoggerAPI[\"warn\"] = (...args) => {\n api().warn(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.error}.\n * @param args - Forwarded to {@link TailorLoggerAPI.error}\n */\nexport const error: TailorLoggerAPI[\"error\"] = (...args) => {\n api().error(...args);\n};\n\n/**\n * See {@link TailorLoggerAPI.setAttributes}.\n * @param args - Forwarded to {@link TailorLoggerAPI.setAttributes}\n */\nexport const setAttributes: TailorLoggerAPI[\"setAttributes\"] = (...args) => {\n api().setAttributes(...args);\n};\n"],"mappings":";;;;;;;;;;AAkFA,MAAM,YACH,WAAuD,OAAO;;;;;AAMjE,MAAa,SAAmC,GAAG,SAAS;CAC1D,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI;AACrB;;;;;AAMA,MAAa,QAAiC,GAAG,SAAS;CACxD,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI;AACpB;;;;;AAMA,MAAa,QAAiC,GAAG,SAAS;CACxD,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI;AACpB;;;;;AAMA,MAAa,SAAmC,GAAG,SAAS;CAC1D,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI;AACrB;;;;;AAMA,MAAa,iBAAmD,GAAG,SAAS;CAC1E,IAAI,CAAC,CAAC,cAAc,GAAG,IAAI;AAC7B"}
@@ -1,8 +1,8 @@
1
1
  import { t as db } from "./schema-CYrle8JZ.mjs";
2
- import { $ as CreateAuthIDPConfigRequestSchema, A as CreatePipelineResolverRequestSchema, At as TenantProviderConfig_TenantProviderType, B as IdPPermissionOperator, Bt as CreateAIGatewayRequestSchema, C as UpdateStaticWebsiteRequestSchema, Ct as AuthOAuth2Client_ClientType, D as CreateSecretManagerVaultRequestSchema, Dt as AuthSCIMAttribute_Uniqueness, E as CreateSecretManagerSecretRequestSchema, Et as AuthSCIMAttribute_Type, F as PipelineResolver_OperationType, Ft as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, G as CreateExecutorExecutorRequestSchema, Gt as ConditionSchema, H as FunctionExecution_Status, I as CreateIdPServiceRequestSchema, It as UpdateApplicationRequestSchema, J as ExecutorJobStatus, Jt as PageDirection, K as UpdateExecutorExecutorRequestSchema, Kt as Condition_Operator, L as UpdateIdPServiceRequestSchema, M as UpdatePipelineResolverRequestSchema, N as UpdatePipelineServiceRequestSchema, O as UpdateSecretManagerSecretRequestSchema, Ot as AuthSCIMConfig_AuthorizationType, Pt as CreateApplicationRequestSchema, Q as CreateAuthHookRequestSchema, Rt as ApplicationSchemaUpdateAttemptStatus, S as CreateStaticWebsiteRequestSchema, St as AuthInvokerSchema, Tt as AuthSCIMAttribute_Mutability, V as IdPPermissionPermit, Vt as UpdateAIGatewayRequestSchema, X as ExecutorTriggerType, Y as ExecutorTargetType, Z as CreateAuthConnectionRequestSchema, _ as TailorDBGQLPermission_Permit, a as CreateWorkflowRequestSchema, at as CreateTenantConfigRequestSchema, b as TailorDBType_PermitAction, bt as AuthHookPoint, ct as UpdateAuthHookRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as UpdateAuthOAuth2ClientRequestSchema, et as CreateAuthMachineUserRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as UpdateAuthSCIMConfigRequestSchema, g as TailorDBGQLPermission_Operator, gt as UpdateUserProfileConfigRequestSchema, h as TailorDBGQLPermission_Action, ht as UpdateTenantConfigRequestSchema, i as CreateWorkflowJobFunctionRequestSchema, it as CreateAuthServiceRequestSchema, j as CreatePipelineServiceRequestSchema, jt as UserProfileProviderConfig_UserProfileProviderType, l as WorkflowExecution_Status, lt as UpdateAuthIDPConfigRequestSchema, mt as UpdateAuthServiceRequestSchema, nt as CreateAuthSCIMConfigRequestSchema, o as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as CreateUserProfileConfigRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as UpdateAuthSCIMResourceRequestSchema, qt as FilterSchema, r as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, rt as CreateAuthSCIMResourceRequestSchema, s as UpdateWorkflowRequestSchema, st as UpdateAuthConnectionRequestSchema, t as WorkspacePlatformUserRole, tt as CreateAuthOAuth2ClientRequestSchema, u as WorkflowJobExecution_Status, ut as UpdateAuthMachineUserRequestSchema, v as TailorDBType_Permission_Operator, vt as AuthConnection_Status, wt as AuthOAuth2Client_GrantType, x as AddCustomDomainRequestSchema, xt as AuthIDPConfig_AuthType, y as TailorDBType_Permission_Permit, yt as AuthConnection_Type, z as IdPLang, zt as Subgraph_ServiceType } from "./workspace_resource_pb-Db3fv68L.mjs";
2
+ import { $ as CreateAuthHookRequestSchema, B as IdPLang, Bt as Subgraph_ServiceType, C as CreateStaticWebsiteRequestSchema, Ct as AuthInvokerSchema, D as CreateSecretManagerSecretRequestSchema, Dt as AuthSCIMAttribute_Type, Et as AuthSCIMAttribute_Mutability, Ft as CreateApplicationRequestSchema, H as IdPPermissionPermit, Ht as UpdateAIGatewayRequestSchema, I as PipelineResolver_OperationType, It as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, Jt as FilterSchema, K as CreateExecutorExecutorRequestSchema, Kt as ConditionSchema, L as CreateIdPServiceRequestSchema, Lt as UpdateApplicationRequestSchema, M as CreatePipelineServiceRequestSchema, Mt as UserProfileProviderConfig_UserProfileProviderType, N as UpdatePipelineResolverRequestSchema, O as CreateSecretManagerVaultRequestSchema, Ot as AuthSCIMAttribute_Uniqueness, P as UpdatePipelineServiceRequestSchema, Q as CreateAuthConnectionRequestSchema, R as UpdateIdPServiceRequestSchema, S as AddCustomDomainRequestSchema, St as AuthIDPConfig_AuthType, Tt as AuthOAuth2Client_GrantType, U as FunctionExecution_Status, V as IdPPermissionOperator, Vt as CreateAIGatewayRequestSchema, X as ExecutorTargetType, Y as ExecutorJobStatus, Yt as PageDirection, Z as ExecutorTriggerType, _ as TailorDBGQLPermission_Permit, _t as UpdateUserProfileConfigRequestSchema, a as CreateWorkflowRequestSchema, at as CreateAuthServiceRequestSchema, b as TailorDBType_Permission_Permit, bt as AuthConnection_Type, ct as UpdateAuthConnectionRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as UpdateAuthMachineUserRequestSchema, et as CreateAuthIDPConfigRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as UpdateAuthOAuth2ClientRequestSchema, g as TailorDBGQLPermission_Operator, gt as UpdateTenantConfigRequestSchema, h as TailorDBGQLPermission_Action, ht as UpdateAuthServiceRequestSchema, i as CreateWorkflowJobFunctionRequestSchema, it as CreateAuthSCIMResourceRequestSchema, j as CreatePipelineResolverRequestSchema, jt as TenantProviderConfig_TenantProviderType, k as UpdateSecretManagerSecretRequestSchema, kt as AuthSCIMConfig_AuthorizationType, l as WorkflowExecution_Status, lt as UpdateAuthHookRequestSchema, mt as UpdateAuthSCIMResourceRequestSchema, nt as CreateAuthOAuth2ClientRequestSchema, o as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as CreateTenantConfigRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as UpdateAuthSCIMConfigRequestSchema, q as UpdateExecutorExecutorRequestSchema, qt as Condition_Operator, r as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, rt as CreateAuthSCIMConfigRequestSchema, s as UpdateWorkflowRequestSchema, st as CreateUserProfileConfigRequestSchema, t as WorkspacePlatformUserRole, tt as CreateAuthMachineUserRequestSchema, u as WorkflowJobExecution_Status, ut as UpdateAuthIDPConfigRequestSchema, v as TailorDBTypeSchema, w as UpdateStaticWebsiteRequestSchema, wt as AuthOAuth2Client_ClientType, x as TailorDBType_PermitAction, xt as AuthHookPoint, y as TailorDBType_Permission_Operator, yt as AuthConnection_Status, zt as ApplicationSchemaUpdateAttemptStatus } from "./workspace_resource_pb-UGK1SSn_.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-BwS4ppwO.mjs";
5
- import { A as fetchAll, B as initOAuth2Client, C as hasGenerationHooks, D as hashFile, E as hashContent, G as resolveStaticWebsiteUrls, H as isDefaultPlatform, I as getConsoleBaseUrl, J as LOG_LEVELS, K as byName, L as getOAuth2ClientId, M as fetchMachineUserToken, N as fetchPaged, R as getOrNull, S as getPluginGenerationDependencies, T as getDistDir, U as normalizeBaseUrl, V as initOperatorClient, W as rememberPlatformConfigForToken, _ as resolveTSConfigWithFallback, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, g as stringifyFunction, h as TailorDBTypeSchema, i as resolverBundleKey, j as fetchAllTolerant, k as defaultPlatformBaseUrl, l as HTTP_METHODS, m as assertUniqueTailorDBTypeNamesWithExternal, n as generatePluginFilesIfNeeded, o as WorkflowJobFunctionExecutionPolicySchema, p as assertUniqueLocalTailorDBTypeNames, q as createApplyLimiter, r as loadApplication, t as defineApplication, v as platformBundleDefinePlugin, w as createBundleCache, z as getPlatformBaseUrl } from "./application-C1d52JP9.mjs";
5
+ import { A as defaultPlatformBaseUrl, B as getPlatformBaseUrl, C as getPluginGenerationDependencies, D as hashContent, E as getDistDir, G as rememberPlatformConfigForToken, H as initOperatorClient, J as createApplyLimiter, K as resolveStaticWebsiteUrls, L as getConsoleBaseUrl, M as fetchAllTolerant, N as fetchMachineUserToken, O as hashFile, P as fetchPaged, R as getOAuth2ClientId, T as createBundleCache, U as isDefaultPlatform, V as initOAuth2Client, W as normalizeBaseUrl, Y as LOG_LEVELS, _ as stringifyFunction, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, g as TailorDBTypeSchema$1, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, j as fetchAll, l as HTTP_METHODS, m as assertUniqueLocalTailorDBTypeNames, n as generatePluginFilesIfNeeded, o as WorkflowJobFunctionExecutionPolicySchema, q as byName, r as loadApplication, t as defineApplication, v as resolveTSConfigWithFallback, w as hasGenerationHooks, y as platformBundleDefinePlugin, z as getOrNull } from "./application-DDe0er6L.mjs";
6
6
  import { o as loadFilesWithIgnores, s as functionSchema, t as createExecutorService } from "./service-CDPatibu.mjs";
7
7
  import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "./enum-constants-j9QBF0cB.mjs";
8
8
  import { t as multiline } from "./multiline-sfHpTZZK.mjs";
@@ -2096,6 +2096,21 @@ function formatPlanSummary(summary) {
2096
2096
  //#endregion
2097
2097
  //#region src/cli/commands/deploy/compare.ts
2098
2098
  /**
2099
+ * Canonicalize a proto message (or init shape) into proto JSON for comparison.
2100
+ *
2101
+ * Deserialized messages materialize implicit proto3 fields with their zero
2102
+ * values while locally built init shapes omit them, so comparing the raw
2103
+ * objects reports a diff for every field the SDK does not set — including
2104
+ * fields newly added to the proto. Proto JSON omits implicit zero values on
2105
+ * both sides, which matches wire semantics (unset == zero value).
2106
+ * @param schema - Message schema describing the value
2107
+ * @param value - Message or init shape to canonicalize
2108
+ * @returns Proto JSON representation of the value
2109
+ */
2110
+ function toComparableProtoJson(schema, value) {
2111
+ return toJson(schema, create(schema, value));
2112
+ }
2113
+ /**
2099
2114
  * Stable JSON-like serialization that sorts object keys and ignores proto runtime metadata.
2100
2115
  * @param value - Value to serialize
2101
2116
  * @returns Stable serialized string
@@ -4078,8 +4093,8 @@ function normalizeComparableUserAuthPolicy(policy) {
4078
4093
  passwordRequireLowercase: policy?.passwordRequireLowercase ?? false,
4079
4094
  passwordRequireNonAlphanumeric: policy?.passwordRequireNonAlphanumeric ?? false,
4080
4095
  passwordRequireNumeric: policy?.passwordRequireNumeric ?? false,
4081
- passwordMinLength: policy?.passwordMinLength ?? 0,
4082
- passwordMaxLength: policy?.passwordMaxLength ?? 0,
4096
+ passwordMinLength: policy?.passwordMinLength || 6,
4097
+ passwordMaxLength: policy?.passwordMaxLength || 4096,
4083
4098
  allowedEmailDomains: (policy?.allowedEmailDomains ?? []).toSorted(),
4084
4099
  allowGoogleOauth: policy?.allowGoogleOauth ?? false,
4085
4100
  disablePasswordAuth: policy?.disablePasswordAuth ?? false,
@@ -10211,6 +10226,21 @@ async function applyTailorDB(client, result, phase = "create-update") {
10211
10226
  deletedResources.reset();
10212
10227
  migrationSnapshotCache.reset();
10213
10228
  await executeServicesCreation(client, changeSet);
10229
+ const migratingNamespaces = new Set(pendingMigrations.map((m) => m.namespace));
10230
+ const isOutsideMigrations = (namespaceName) => namespaceName !== void 0 && !migratingNamespaces.has(namespaceName);
10231
+ try {
10232
+ for (const create of changeSet.type.creates) {
10233
+ if (!isOutsideMigrations(create.request.namespaceName)) continue;
10234
+ await client.createTailorDBType(create.request);
10235
+ }
10236
+ for (const update of changeSet.type.updates) {
10237
+ if (!isOutsideMigrations(update.request.namespaceName)) continue;
10238
+ await client.updateTailorDBType(update.request);
10239
+ }
10240
+ } catch (error) {
10241
+ handleOptionalToRequiredError(error, ["Run 'tailor-sdk tailordb migration generate' to create migration files.", "Migration scripts allow you to handle existing data before applying the schema change."]);
10242
+ }
10243
+ await Promise.all([...changeSet.gqlPermission.creates.filter((create) => isOutsideMigrations(create.request.namespaceName)).map((create) => client.createTailorDBGQLPermission(create.request)), ...changeSet.gqlPermission.updates.filter((update) => isOutsideMigrations(update.request.namespaceName)).map((update) => client.updateTailorDBGQLPermission(update.request))]);
10214
10244
  const migrationsRequiringScripts = pendingMigrations.filter((m) => m.hasScript);
10215
10245
  const migrationCtx = migrationsRequiringScripts.length > 0 ? buildMigrationContextForScripts(client, migrationContext, migrationsRequiringScripts) : void 0;
10216
10246
  if (migrationsRequiringScripts.length > 0) {
@@ -10241,6 +10271,7 @@ async function applyTailorDB(client, result, phase = "create-update") {
10241
10271
  return !deletedResources.gqlPermissions.has(permKey);
10242
10272
  });
10243
10273
  if (remainingGqlPermissionDeletes.length > 0) await Promise.all(remainingGqlPermissionDeletes.map((del) => client.deleteTailorDBGQLPermission(del.request)));
10274
+ await Promise.all(changeSet.type.deletes.filter((del) => isOutsideMigrations(del.request.namespaceName) && !deletedResources.types.has(del.name)).map((del) => client.deleteTailorDBType(del.request)));
10244
10275
  } else {
10245
10276
  await Promise.all([...changeSet.service.creates.map(async (create) => {
10246
10277
  await client.createTailorDBService(create.request);
@@ -10840,7 +10871,7 @@ const tailordbCompareKnownDefaults = {
10840
10871
  ])
10841
10872
  };
10842
10873
  function normalizeComparableTailorDBType(type) {
10843
- const normalized = normalizeProtoConfig(type);
10874
+ const normalized = normalizeProtoConfig(toComparableProtoJson(TailorDBTypeSchema, type));
10844
10875
  return normalizeTailorDBCompareValue({
10845
10876
  name: normalized?.name ?? "",
10846
10877
  schema: {
@@ -10866,7 +10897,7 @@ function normalizeTailorDBCompareValue(value, path) {
10866
10897
  const normalizedEntries = Object.entries(value).map(([key, entryValue]) => [key, normalizeTailorDBCompareValue(entryValue, [...path, key])]).filter(([, entryValue]) => entryValue !== void 0);
10867
10898
  const normalizedObject = Object.fromEntries(normalizedEntries);
10868
10899
  if (path.at(-1) === "fields" && Object.keys(normalizedObject).length === 0) return;
10869
- if (path.at(-1) === "disableGqlOperations" && areNormalizedEqual(normalizedObject, tailordbCompareKnownDefaults.disableGqlOperations)) return;
10900
+ if (path.at(-1) === "disableGqlOperations" && (Object.keys(normalizedObject).length === 0 || areNormalizedEqual(normalizedObject, tailordbCompareKnownDefaults.disableGqlOperations))) return;
10870
10901
  return normalizedObject;
10871
10902
  }
10872
10903
  function matchesNumericStringPath(path) {
@@ -18922,7 +18953,7 @@ async function generate(options) {
18922
18953
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
18923
18954
  let pluginManager;
18924
18955
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
18925
- const { defineApplication } = await import("./application-Nlh9BHQf.mjs");
18956
+ const { defineApplication } = await import("./application-B1_7Wm37.mjs");
18926
18957
  const application = defineApplication({
18927
18958
  config,
18928
18959
  pluginManager
@@ -20402,7 +20433,7 @@ async function loadTypeFieldOrder(config, namespace) {
20402
20433
  try {
20403
20434
  const module = await import(pathToFileURL(typeFile).href);
20404
20435
  for (const exportedValue of Object.values(module)) {
20405
- const result = TailorDBTypeSchema.safeParse(exportedValue);
20436
+ const result = TailorDBTypeSchema$1.safeParse(exportedValue);
20406
20437
  if (!result.success) continue;
20407
20438
  fieldOrder.set(result.data.name, Object.keys(result.data.fields));
20408
20439
  }
@@ -21051,4 +21082,4 @@ async function registerTypeScriptRuntime(hookUrl) {
21051
21082
 
21052
21083
  //#endregion
21053
21084
  export { listFolders as $, deploymentArgs as $n, handleOptionalToRequiredError as $t, generate as A, generateUserTypes as An, startCommand as At, remove as B, loadConsoleBaseUrl as Bn, deploy as Bt, waitWorkflowExecution as C, formatDiffSummary as Cn, listCommand$8 as Ct, listWorkflows as D, resourceTrn as Dn, jobsCommand as Dt, listCommand$2 as E, getNamespacesWithMigrations as En, getExecutorWaitFailureMessage as Et, openInConfiguredEditor as F, deleteUserTokens as Fn, getWorkflowExecution as Ft, treeCommand as G, readPlatformConfig as Gn, createWorkspace$1 as Gt, updateCommand$1 as H, loadStoredUserTokens as Hn, listCommand$9 as Ht, show as I, fetchLatestToken as In, listWorkflowExecutions as It, getCommand$1 as J, writePlatformConfig as Jn, ensureConfigId as Jt, listCommand$3 as K, resolveUserTokenKey as Kn, formatKeyValueTable as Kt, showCommand as L, hasAnyUserTokenEntry as Ln, functionExecutionStatusToString as Lt, generateMigrationScript as M, apiCall as Mn, getCommand$5 as Mt, writeDbTypesFile as N, assertWritable as Nn, getWorkflow as Nt, truncate as O, sdkNameLabelKey as On, listExecutorJobs as Ot, getConfiguredEditorCommand as P, loadConfig as Pn, executionsCommand as Pt, listCommand$4 as Q, confirmationArgs as Qn, MIGRATION_LABEL_KEY as Qt, extractOwnedNamespaces as R, hasUserTokenEntry as Rn, getCommand$6 as Rt, waitCommand as S, parseMigrationNumberArg as Sn, triggerExecutor as St, resumeWorkflow as T, hasChanges as Tn, getExecutorJob as Tt, updateOrganization as U, loadWorkspaceId as Un, listWorkspaces as Ut, removeCommand$1 as V, loadMachineUserName as Vn, deployFromCLI as Vt, organizationTree as W, platformConfigFromProfile as Wn, createCommand$1 as Wt, updateCommand$2 as X, commonArgs as Xn, waitForExecution as Xt, getOrganization as Y, defineAppCommand as Yn, executeScript as Yt, updateFolder as Z, configArg as Zn, bundleMigrationScript as Zt, deleteWorkspace as _, getNextMigrationNumber as _n, getCommand$4 as _t, updateUser as a, DIFF_FILE_NAME as an, toPageDirection as ar, createFolder as at, getAppHealth as b, reconstructSnapshotFromMigrations as bn, webhookCommand as bt, listCommand as c, SCHEMA_FILE_NAME as cn, getCommand$3 as ct, inviteUser as d, compareSnapshots as dn, tokenCommand as dt, parseMigrationLabelNumber as en, isVerbose as er, getCommand$2 as et, restoreCommand as f, createSnapshotFromLocalTypes as fn, listCommand$6 as ft, deleteCommand as g, getMigrationFiles as gn, listFunctionRegistries as gt, getWorkspace as h, getMigrationFilePath as hn, listCommand$7 as ht, updateCommand as i, DB_TYPES_FILE_NAME as in, resolveMachineUserInputSource as ir, createCommand as it, generateCommand as j, prompt as jn, startWorkflow as jt, truncateCommand as k, PluginManager as kn, watchExecutorJob as kt, listUsers as l, assertValidMigrationFiles as ln, getOAuth2Client as lt, getCommand as m, getMigrationDirPath as mn, generate$1 as mt, query as n, generateAllTypeManifestsFromSnapshot as nn, pagedLogArgs as nr, deleteCommand$1 as nt, removeCommand as o, INITIAL_SCHEMA_NUMBER as on, workspaceArgs as or, listCommand$5 as ot, restoreWorkspace as p, getLatestMigrationNumber as pn, listMachineUsers as pt, listOrganizations as q, saveUserTokens as qn, workspaceNameSchema as qt, queryCommand as r, protoGqlPermission as rn, paginationArgs as rr, deleteFolder as rt, removeUser as s, MIGRATE_FILE_NAME as sn, listOAuth2Clients as st, registerTypeScriptRuntime as t, compareSnapshotWithRemote as tn, multiConfigArg as tr, getFolder as tt, inviteCommand as u, compareLocalTypesWithSnapshot as un, getMachineUserToken as ut, listApps as v, isValidMigrationNumber as vn, getFunctionRegistry as vt, resumeCommand as w, formatMigrationDiff as wn, listExecutors as wt, healthCommand as x, formatMigrationNumber as xn, triggerCommand as xt, listCommand$1 as y, loadDiff as yn, listWebhookExecutors as yt, logBetaWarning as z, loadAccessToken as zn, getExecutor as zt };
21054
- //# sourceMappingURL=register-typescript-runtime-Bd4bcLbW.mjs.map
21085
+ //# sourceMappingURL=register-typescript-runtime-QAWucsg0.mjs.map