@tailor-platform/sdk 1.80.1 → 1.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/application-CP0W2sQo.mjs +3 -0
- package/dist/{application-C1d52JP9.mjs → application-CVeA53ok.mjs} +172 -27
- package/dist/application-CVeA53ok.mjs.map +1 -0
- package/dist/cli/index.mjs +19 -34
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.mjs +2 -2
- package/dist/cli/skills.mjs +1 -1
- package/dist/completion/zsh-worker.zsh +1 -1
- package/dist/configure/config/types.d.mts +3 -1
- package/dist/configure/index.d.mts +2 -1
- package/dist/configure/index.mjs +9 -0
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/idp/permission.d.mts +1 -16
- package/dist/configure/services/index.d.mts +2 -1
- package/dist/configure/services/resolver/index.d.mts +2 -1
- package/dist/configure/services/resolver/permission.d.mts +64 -0
- package/dist/configure/services/resolver/resolver.d.mts +14 -2
- package/dist/configure/services/tailordb/permission.d.mts +1 -16
- package/dist/configure/types/permission-operand.types.d.mts +20 -0
- package/dist/{crashreport-BNWUM6Kf.mjs → crashreport-DMYuHnBN.mjs} +2 -2
- package/dist/{crashreport-BNWUM6Kf.mjs.map → crashreport-DMYuHnBN.mjs.map} +1 -1
- package/dist/{crashreport-BafWvjjX.mjs → crashreport-ecqnz51B.mjs} +1 -1
- package/dist/{globals-DVJ8RVvm.mjs → globals-DUqEetIh.mjs} +11 -2
- package/dist/{globals-DVJ8RVvm.mjs.map → globals-DUqEetIh.mjs.map} +1 -1
- package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
- package/dist/logger-CXQq9YIp.mjs.map +1 -0
- package/dist/logger-t5ASCDZm.mjs +49 -0
- package/dist/logger-t5ASCDZm.mjs.map +1 -0
- package/dist/{register-typescript-runtime-Bd4bcLbW.mjs → register-typescript-runtime-O7zQNif0.mjs} +44 -17
- package/dist/register-typescript-runtime-O7zQNif0.mjs.map +1 -0
- package/dist/runtime/globals.d.mts +7 -0
- package/dist/runtime/index.d.mts +3 -1
- package/dist/runtime/index.mjs +2 -1
- package/dist/runtime/logger.d.mts +98 -0
- package/dist/runtime/logger.mjs +3 -0
- package/dist/{service-CDPatibu.mjs → service-B0MaodSg.mjs} +2 -2
- package/dist/{service-CDPatibu.mjs.map → service-B0MaodSg.mjs.map} +1 -1
- package/dist/{service-Cp0I7ZFe.mjs → service-CIGSGg9I.mjs} +2 -2
- package/dist/{service-Cp0I7ZFe.mjs.map → service-CIGSGg9I.mjs.map} +1 -1
- package/dist/service-KnAiVofD.mjs +3 -0
- package/dist/{service_pb-BoLM0X4K.mjs → service_pb-BwZRiNug.mjs} +2 -2
- package/dist/{service_pb-BoLM0X4K.mjs.map → service_pb-BwZRiNug.mjs.map} +1 -1
- package/dist/{service_pb-r1T7kpJc.mjs → service_pb-wRkxUta6.mjs} +1 -1
- package/dist/types/auth.generated.d.mts +14 -2
- package/dist/types/executor.generated.d.mts +19 -0
- package/dist/types/http-adapter.generated.d.mts +5 -0
- package/dist/types/idp.generated.d.mts +30 -0
- package/dist/types/resolver.generated.d.mts +28 -2
- package/dist/types/tailordb.generated.d.mts +15 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +4 -2
- package/dist/vitest/index.mjs +83 -2
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock.d.mts +2 -1
- package/dist/vitest/mocks/file.d.mts +1 -1
- package/dist/vitest/mocks/logger.d.mts +45 -0
- package/dist/vitest/setup.mjs +1 -1
- package/dist/{workspace_resource_pb-Db3fv68L.mjs → workspace_resource_pb-UGK1SSn_.mjs} +7 -2
- package/dist/{workspace_resource_pb-Db3fv68L.mjs.map → workspace_resource_pb-UGK1SSn_.mjs.map} +1 -1
- package/docs/configuration.md +3 -1
- package/docs/runtime.md +4 -0
- package/docs/services/resolver.md +54 -0
- package/docs/testing.md +23 -2
- package/package.json +11 -6
- package/dist/application-C1d52JP9.mjs.map +0 -1
- package/dist/application-Nlh9BHQf.mjs +0 -3
- package/dist/logger-BwS4ppwO.mjs.map +0 -1
- package/dist/register-typescript-runtime-Bd4bcLbW.mjs.map +0 -1
- package/dist/service-Cg7Qibit.mjs +0 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as file_tailor_v1_service, n as PingRequestSchema, r as PingResponseSchema, t as OperatorService } from "./service_pb-
|
|
1
|
+
import { i as file_tailor_v1_service, n as PingRequestSchema, r as PingResponseSchema, t as OperatorService } from "./service_pb-BwZRiNug.mjs";
|
|
2
2
|
|
|
3
3
|
export { OperatorService, PingRequestSchema, PingResponseSchema, file_tailor_v1_service };
|
|
@@ -14,7 +14,9 @@ type OIDC = {
|
|
|
14
14
|
clientID: string;
|
|
15
15
|
/** OAuth2 client secret */
|
|
16
16
|
clientSecret: {
|
|
17
|
+
/** Vault name containing the secret */
|
|
17
18
|
vaultName: string;
|
|
19
|
+
/** Key of the secret in the vault */
|
|
18
20
|
secretKey: string;
|
|
19
21
|
};
|
|
20
22
|
/** OIDC provider URL */
|
|
@@ -103,7 +105,9 @@ type SCIMAuthorization = {
|
|
|
103
105
|
type: "oauth2" | "bearer";
|
|
104
106
|
/** Bearer token secret (required for bearer type) */
|
|
105
107
|
bearerSecret?: {
|
|
108
|
+
/** Vault name containing the secret */
|
|
106
109
|
vaultName: string;
|
|
110
|
+
/** Key of the secret in the vault */
|
|
107
111
|
secretKey: string;
|
|
108
112
|
} | undefined;
|
|
109
113
|
};
|
|
@@ -145,17 +149,25 @@ type SCIMResource = {
|
|
|
145
149
|
tailorDBType: string;
|
|
146
150
|
/** Core SCIM schema definition */
|
|
147
151
|
coreSchema: {
|
|
148
|
-
/** SCIM
|
|
152
|
+
/** SCIM schema name */
|
|
149
153
|
name: string;
|
|
154
|
+
/** Schema attributes */
|
|
150
155
|
attributes: {
|
|
156
|
+
/** Attribute data type */
|
|
151
157
|
type: "string" | "number" | "boolean" | "datetime" | "complex";
|
|
152
|
-
/**
|
|
158
|
+
/** Attribute name */
|
|
153
159
|
name: string;
|
|
160
|
+
/** Attribute description */
|
|
154
161
|
description?: string | undefined;
|
|
162
|
+
/** Attribute mutability */
|
|
155
163
|
mutability?: "readOnly" | "readWrite" | "writeOnly" | undefined;
|
|
164
|
+
/** Whether the attribute is required */
|
|
156
165
|
required?: boolean | undefined;
|
|
166
|
+
/** Whether the attribute can have multiple values */
|
|
157
167
|
multiValued?: boolean | undefined;
|
|
168
|
+
/** Uniqueness constraint */
|
|
158
169
|
uniqueness?: "none" | "server" | "global" | undefined;
|
|
170
|
+
/** List of canonical values */
|
|
159
171
|
canonicalValues?: string[] | null | undefined;
|
|
160
172
|
subAttributes?: any[] | null | undefined;
|
|
161
173
|
}[];
|
|
@@ -63,7 +63,9 @@ type FunctionOperation = {
|
|
|
63
63
|
body: Function;
|
|
64
64
|
/** Auth invoker for the function execution */
|
|
65
65
|
authInvoker?: string | {
|
|
66
|
+
/** Auth namespace */
|
|
66
67
|
namespace: string;
|
|
68
|
+
/** Machine user name for authentication */
|
|
67
69
|
machineUserName: string;
|
|
68
70
|
} | undefined;
|
|
69
71
|
};
|
|
@@ -76,7 +78,9 @@ type GqlOperation = {
|
|
|
76
78
|
variables?: Function | undefined;
|
|
77
79
|
/** Auth invoker for the GraphQL execution */
|
|
78
80
|
authInvoker?: string | {
|
|
81
|
+
/** Auth namespace */
|
|
79
82
|
namespace: string;
|
|
83
|
+
/** Machine user name for authentication */
|
|
80
84
|
machineUserName: string;
|
|
81
85
|
} | undefined;
|
|
82
86
|
};
|
|
@@ -131,30 +135,45 @@ type Executor = {
|
|
|
131
135
|
args?: Function | {
|
|
132
136
|
[x: string]: unknown;
|
|
133
137
|
} | undefined;
|
|
138
|
+
/** Auth invoker for the function execution */
|
|
134
139
|
authInvoker?: string | {
|
|
140
|
+
/** Auth namespace */
|
|
135
141
|
namespace: string;
|
|
142
|
+
/** Machine user name for authentication */
|
|
136
143
|
machineUserName: string;
|
|
137
144
|
} | undefined;
|
|
138
145
|
} | {
|
|
139
146
|
kind: "function" | "jobFunction";
|
|
147
|
+
/** Function implementation */
|
|
140
148
|
body: Function;
|
|
149
|
+
/** Auth invoker for the function execution */
|
|
141
150
|
authInvoker?: string | {
|
|
151
|
+
/** Auth namespace */
|
|
142
152
|
namespace: string;
|
|
153
|
+
/** Machine user name for authentication */
|
|
143
154
|
machineUserName: string;
|
|
144
155
|
} | undefined;
|
|
145
156
|
} | {
|
|
146
157
|
kind: "graphql";
|
|
147
158
|
query: string;
|
|
159
|
+
/** Target application name for the GraphQL query */
|
|
148
160
|
appName?: string | undefined;
|
|
161
|
+
/** Function to compute GraphQL variables */
|
|
149
162
|
variables?: Function | undefined;
|
|
163
|
+
/** Auth invoker for the function execution */
|
|
150
164
|
authInvoker?: string | {
|
|
165
|
+
/** Auth namespace */
|
|
151
166
|
namespace: string;
|
|
167
|
+
/** Machine user name for authentication */
|
|
152
168
|
machineUserName: string;
|
|
153
169
|
} | undefined;
|
|
154
170
|
} | {
|
|
155
171
|
kind: "webhook";
|
|
172
|
+
/** Function returning the webhook URL */
|
|
156
173
|
url: Function;
|
|
174
|
+
/** Function to compute the request body */
|
|
157
175
|
requestBody?: Function | undefined;
|
|
176
|
+
/** HTTP headers for the webhook request */
|
|
158
177
|
headers?: {
|
|
159
178
|
[x: string]: string | {
|
|
160
179
|
vault: string;
|
|
@@ -6,10 +6,15 @@ type HttpAdapterConfigInput = {
|
|
|
6
6
|
pathPattern: string;
|
|
7
7
|
/** Per-method functions that transform HTTP requests to GraphQL requests */
|
|
8
8
|
input: {
|
|
9
|
+
/** Handler for GET requests */
|
|
9
10
|
get?: Function | undefined;
|
|
11
|
+
/** Handler for POST requests */
|
|
10
12
|
post?: Function | undefined;
|
|
13
|
+
/** Handler for PUT requests */
|
|
11
14
|
put?: Function | undefined;
|
|
15
|
+
/** Handler for PATCH requests */
|
|
12
16
|
patch?: Function | undefined;
|
|
17
|
+
/** Handler for DELETE requests */
|
|
13
18
|
delete?: Function | undefined;
|
|
14
19
|
};
|
|
15
20
|
/** Whether the adapter is active */
|
|
@@ -13,12 +13,19 @@ type IdPGqlOperationsInput = "query" | {
|
|
|
13
13
|
unenrollMfa?: boolean | undefined;
|
|
14
14
|
};
|
|
15
15
|
type IdPGqlOperations = {
|
|
16
|
+
/** Enable _createUser mutation (default: true) */
|
|
16
17
|
create?: boolean | undefined;
|
|
18
|
+
/** Enable _updateUser mutation (default: true) */
|
|
17
19
|
update?: boolean | undefined;
|
|
20
|
+
/** Enable _deleteUser mutation (default: true) */
|
|
18
21
|
delete?: boolean | undefined;
|
|
22
|
+
/** Enable _users and _user queries (default: true) */
|
|
19
23
|
read?: boolean | undefined;
|
|
24
|
+
/** Enable _sendPasswordResetEmail mutation (default: true) */
|
|
20
25
|
sendPasswordResetEmail?: boolean | undefined;
|
|
26
|
+
/** Enable _requestMfaSettingsUrl query (default: true) */
|
|
21
27
|
requestMfaSettingsUrl?: boolean | undefined;
|
|
28
|
+
/** Enable _unenrollMfa mutation (default: true) */
|
|
22
29
|
unenrollMfa?: boolean | undefined;
|
|
23
30
|
};
|
|
24
31
|
/**
|
|
@@ -558,33 +565,56 @@ type IdPInput = {
|
|
|
558
565
|
lang?: "en" | "ja" | undefined;
|
|
559
566
|
/** User authentication policy configuration */
|
|
560
567
|
userAuthPolicy?: {
|
|
568
|
+
/** Use non-email identifier for usernames */
|
|
561
569
|
useNonEmailIdentifier?: boolean | undefined;
|
|
570
|
+
/** Allow users to reset their own passwords */
|
|
562
571
|
allowSelfPasswordReset?: boolean | undefined;
|
|
572
|
+
/** Require uppercase letters in passwords */
|
|
563
573
|
passwordRequireUppercase?: boolean | undefined;
|
|
574
|
+
/** Require lowercase letters in passwords */
|
|
564
575
|
passwordRequireLowercase?: boolean | undefined;
|
|
576
|
+
/** Require non-alphanumeric characters in passwords */
|
|
565
577
|
passwordRequireNonAlphanumeric?: boolean | undefined;
|
|
578
|
+
/** Require numeric characters in passwords */
|
|
566
579
|
passwordRequireNumeric?: boolean | undefined;
|
|
580
|
+
/** Minimum password length (6-30) */
|
|
567
581
|
passwordMinLength?: number | undefined;
|
|
582
|
+
/** Maximum password length (6-4096) */
|
|
568
583
|
passwordMaxLength?: number | undefined;
|
|
584
|
+
/** Restrict registration to these email domains */
|
|
569
585
|
allowedEmailDomains?: string[] | undefined;
|
|
586
|
+
/** Enable Google OAuth login */
|
|
570
587
|
allowGoogleOauth?: boolean | undefined;
|
|
588
|
+
/** Enable Microsoft OAuth login */
|
|
571
589
|
allowMicrosoftOauth?: boolean | undefined;
|
|
590
|
+
/** Disable password-based authentication */
|
|
572
591
|
disablePasswordAuth?: boolean | undefined;
|
|
592
|
+
/** Make TOTP MFA available for users in this namespace */
|
|
573
593
|
enableMfa?: boolean | undefined;
|
|
594
|
+
/** Require TOTP MFA enrollment and challenge for password-authenticated users (requires enableMfa) */
|
|
574
595
|
requireMfa?: boolean | undefined;
|
|
596
|
+
/** Application origins (scheme + host + optional port) allowed as MFA self-service return targets */
|
|
575
597
|
allowedReturnOrigins?: string[] | undefined;
|
|
598
|
+
/** Label shown next to the user account in authenticator apps */
|
|
576
599
|
mfaIssuer?: string | undefined;
|
|
577
600
|
} | undefined;
|
|
578
601
|
/** Enable publishing user lifecycle events */
|
|
579
602
|
publishUserEvents?: boolean | undefined;
|
|
580
603
|
/** Configure which GraphQL operations are enabled */
|
|
581
604
|
gqlOperations?: "query" | {
|
|
605
|
+
/** Enable _createUser mutation (default: true) */
|
|
582
606
|
create?: boolean | undefined;
|
|
607
|
+
/** Enable _updateUser mutation (default: true) */
|
|
583
608
|
update?: boolean | undefined;
|
|
609
|
+
/** Enable _deleteUser mutation (default: true) */
|
|
584
610
|
delete?: boolean | undefined;
|
|
611
|
+
/** Enable _users and _user queries (default: true) */
|
|
585
612
|
read?: boolean | undefined;
|
|
613
|
+
/** Enable _sendPasswordResetEmail mutation (default: true) */
|
|
586
614
|
sendPasswordResetEmail?: boolean | undefined;
|
|
615
|
+
/** Enable _requestMfaSettingsUrl query (default: true) */
|
|
587
616
|
requestMfaSettingsUrl?: boolean | undefined;
|
|
617
|
+
/** Enable _unenrollMfa mutation (default: true) */
|
|
588
618
|
unenrollMfa?: boolean | undefined;
|
|
589
619
|
} | undefined;
|
|
590
620
|
/** Namespace-level email configuration defaults */
|
|
@@ -12,21 +12,31 @@ type Resolver = {
|
|
|
12
12
|
body: Function;
|
|
13
13
|
/** Output field definition */
|
|
14
14
|
output: {
|
|
15
|
+
/** Field data type */
|
|
15
16
|
type: "string" | "boolean" | "date" | "enum" | "uuid" | "integer" | "float" | "decimal" | "datetime" | "time" | "nested";
|
|
17
|
+
/** Field metadata configuration */
|
|
16
18
|
metadata: {
|
|
19
|
+
/** Whether the field is required */
|
|
17
20
|
required?: boolean | undefined;
|
|
21
|
+
/** Whether the field is an array */
|
|
18
22
|
array?: boolean | undefined;
|
|
19
|
-
/**
|
|
23
|
+
/** Field description */
|
|
20
24
|
description?: string | undefined;
|
|
25
|
+
/** Allowed values for enum fields */
|
|
21
26
|
allowedValues?: {
|
|
27
|
+
/** The allowed value */
|
|
22
28
|
value: string;
|
|
23
|
-
/**
|
|
29
|
+
/** Description of the allowed value */
|
|
24
30
|
description?: string | undefined;
|
|
25
31
|
}[] | undefined;
|
|
32
|
+
/** Lifecycle hooks */
|
|
26
33
|
hooks?: {
|
|
34
|
+
/** Hook function called on creation */
|
|
27
35
|
create?: Function | undefined;
|
|
36
|
+
/** Hook function called on update */
|
|
28
37
|
update?: Function | undefined;
|
|
29
38
|
} | undefined;
|
|
39
|
+
/** Type name for nested or enum fields */
|
|
30
40
|
typeName?: string | undefined;
|
|
31
41
|
};
|
|
32
42
|
fields: {
|
|
@@ -43,9 +53,25 @@ type Resolver = {
|
|
|
43
53
|
publishEvents?: boolean | undefined;
|
|
44
54
|
/** Machine user to execute this resolver as */
|
|
45
55
|
authInvoker?: string | {
|
|
56
|
+
/** Auth namespace */
|
|
46
57
|
namespace: string;
|
|
58
|
+
/** Machine user name for authentication */
|
|
47
59
|
machineUserName: string;
|
|
48
60
|
} | undefined;
|
|
61
|
+
permission?: "allowAnonymous" | readonly {
|
|
62
|
+
conditions: readonly [(string | boolean | {
|
|
63
|
+
user: string;
|
|
64
|
+
}), "=" | "!=", (string | boolean | {
|
|
65
|
+
user: string;
|
|
66
|
+
})] | readonly (readonly [(string | boolean | {
|
|
67
|
+
user: string;
|
|
68
|
+
}), "=" | "!=", (string | boolean | {
|
|
69
|
+
user: string;
|
|
70
|
+
})])[];
|
|
71
|
+
permit: boolean;
|
|
72
|
+
/** Reason recorded for this policy, used in the access-denied error message */
|
|
73
|
+
description?: string | undefined;
|
|
74
|
+
}[] | undefined;
|
|
49
75
|
};
|
|
50
76
|
type ResolverInput = Resolver;
|
|
51
77
|
//#endregion
|
|
@@ -10,9 +10,13 @@ type GqlOperationsInput = "query" | {
|
|
|
10
10
|
read?: boolean | undefined;
|
|
11
11
|
};
|
|
12
12
|
type GqlOperations = {
|
|
13
|
+
/** Enable create mutation (default: true) */
|
|
13
14
|
create?: boolean | undefined;
|
|
15
|
+
/** Enable update mutation (default: true) */
|
|
14
16
|
update?: boolean | undefined;
|
|
17
|
+
/** Enable delete mutation (default: true) */
|
|
15
18
|
delete?: boolean | undefined;
|
|
19
|
+
/** Enable read queries - get, list, aggregation (default: true) */
|
|
16
20
|
read?: boolean | undefined;
|
|
17
21
|
};
|
|
18
22
|
type DBFieldMetadata = {
|
|
@@ -27,7 +31,6 @@ type DBFieldMetadata = {
|
|
|
27
31
|
/** Allowed values for enum fields */
|
|
28
32
|
allowedValues?: {
|
|
29
33
|
value: string;
|
|
30
|
-
/** Field description */
|
|
31
34
|
description?: string | undefined;
|
|
32
35
|
}[] | undefined;
|
|
33
36
|
/** Whether the field is indexed for faster queries */
|
|
@@ -44,15 +47,20 @@ type DBFieldMetadata = {
|
|
|
44
47
|
foreignKeyField?: string | undefined;
|
|
45
48
|
/** Lifecycle hooks for the field */
|
|
46
49
|
hooks?: {
|
|
50
|
+
/** Hook function called on record creation */
|
|
47
51
|
create?: Function | undefined;
|
|
52
|
+
/** Hook function called on record update */
|
|
48
53
|
update?: Function | undefined;
|
|
49
54
|
} | undefined;
|
|
50
55
|
/** Validation functions for the field */
|
|
51
56
|
validate?: (Function | [Function, string])[] | undefined;
|
|
52
57
|
/** Serial (auto-increment) configuration */
|
|
53
58
|
serial?: {
|
|
59
|
+
/** Starting value for the serial sequence */
|
|
54
60
|
start: number;
|
|
61
|
+
/** Maximum value for the serial sequence */
|
|
55
62
|
maxValue?: number | undefined;
|
|
63
|
+
/** Format string for serial value (string type only) */
|
|
56
64
|
format?: string | undefined;
|
|
57
65
|
} | undefined;
|
|
58
66
|
/** Decimal scale (number of digits after decimal point, 0-12) */
|
|
@@ -439,14 +447,20 @@ type TailorDBServiceConfigInput = {
|
|
|
439
447
|
erdSite?: string | undefined;
|
|
440
448
|
/** Migration configuration */
|
|
441
449
|
migration?: {
|
|
450
|
+
/** Directory containing migration files */
|
|
442
451
|
directory: string;
|
|
452
|
+
/** Machine user name for migration execution */
|
|
443
453
|
machineUser?: string | undefined;
|
|
444
454
|
} | undefined;
|
|
445
455
|
/** Default GraphQL operations for all types in this service */
|
|
446
456
|
gqlOperations?: "query" | {
|
|
457
|
+
/** Enable create mutation (default: true) */
|
|
447
458
|
create?: boolean | undefined;
|
|
459
|
+
/** Enable update mutation (default: true) */
|
|
448
460
|
update?: boolean | undefined;
|
|
461
|
+
/** Enable delete mutation (default: true) */
|
|
449
462
|
delete?: boolean | undefined;
|
|
463
|
+
/** Enable read queries - get, list, aggregation (default: true) */
|
|
450
464
|
read?: boolean | undefined;
|
|
451
465
|
} | undefined;
|
|
452
466
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as cleanupPlatformGlobals, r as installPlatformGlobals, t as RUNTIME_FLAG_KEY } from "../globals-
|
|
1
|
+
import { n as cleanupPlatformGlobals, r as installPlatformGlobals, t as RUNTIME_FLAG_KEY } from "../globals-DUqEetIh.mjs";
|
|
2
2
|
import * as globals from "globals";
|
|
3
3
|
|
|
4
4
|
//#region src/vitest/environment.ts
|
package/dist/vitest/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { MockAuthconnectionOptions, mockAuthconnection } from "./mocks/authconne
|
|
|
3
3
|
import { MockFileOptions, mockFile } from "./mocks/file.mjs";
|
|
4
4
|
import { MockIconvOptions, mockIconv } from "./mocks/iconv.mjs";
|
|
5
5
|
import { MockIdpOptions, mockIdp } from "./mocks/idp.mjs";
|
|
6
|
+
import { MockLoggerOptions, mockLogger } from "./mocks/logger.mjs";
|
|
6
7
|
import { MockSecretmanagerOptions, mockSecretmanager } from "./mocks/secretmanager.mjs";
|
|
7
8
|
import { MockTailordbOptions, QueryBehavior, QueryMatch, QueryMatcher, mockTailordb } from "./mocks/tailordb.mjs";
|
|
8
9
|
import { mockWorkflow } from "./mocks/workflow.mjs";
|
|
@@ -31,7 +32,8 @@ import { Plugin } from "vitest/config";
|
|
|
31
32
|
*
|
|
32
33
|
* 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with
|
|
33
34
|
* control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`,
|
|
34
|
-
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway
|
|
35
|
+
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway`,
|
|
36
|
+
* `mockLogger`. Each
|
|
35
37
|
* provides response configuration, call recording, and reset.
|
|
36
38
|
*
|
|
37
39
|
* 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the
|
|
@@ -68,4 +70,4 @@ declare function tailorRuntime(options?: {
|
|
|
68
70
|
config?: string;
|
|
69
71
|
}): Plugin[];
|
|
70
72
|
//#endregion
|
|
71
|
-
export { type ExecutedQuery, type KyselyMock, type MockAigatewayOptions, type MockAuthconnectionOptions, type MockFileOptions, type MockIconvOptions, type MockIdpOptions, type MockSecretmanagerOptions, type MockTailordbOptions, type QueryBehavior, type QueryMatch, type QueryMatcher, createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockSecretmanager, mockTailordb, mockWorkflow, tailorRuntime };
|
|
73
|
+
export { type ExecutedQuery, type KyselyMock, type MockAigatewayOptions, type MockAuthconnectionOptions, type MockFileOptions, type MockIconvOptions, type MockIdpOptions, type MockLoggerOptions, type MockSecretmanagerOptions, type MockTailordbOptions, type QueryBehavior, type QueryMatch, type QueryMatcher, createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockLogger, mockSecretmanager, mockTailordb, mockWorkflow, tailorRuntime };
|
package/dist/vitest/index.mjs
CHANGED
|
@@ -978,6 +978,86 @@ function mockIdp(options = {}) {
|
|
|
978
978
|
});
|
|
979
979
|
}
|
|
980
980
|
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/vitest/mocks/logger.ts
|
|
983
|
+
/**
|
|
984
|
+
* Acquire a disposable mock for `tailor.logger`. Each method is a `vi.fn`, so
|
|
985
|
+
* calls can be asserted directly; `calls` returns the `debug`/`info`/`warn`/
|
|
986
|
+
* `error` entries in the order they were emitted. Restored on dispose.
|
|
987
|
+
* @param _options - Reserved for future initial fixtures
|
|
988
|
+
* @returns Disposable logger mock control object
|
|
989
|
+
* @example
|
|
990
|
+
* ```typescript
|
|
991
|
+
* import { mockLogger } from "@tailor-platform/sdk/vitest";
|
|
992
|
+
*
|
|
993
|
+
* test("logs the processed order", () => {
|
|
994
|
+
* using logger = mockLogger();
|
|
995
|
+
* // …run code that calls tailor.logger.info…
|
|
996
|
+
* expect(logger.info).toHaveBeenCalledWith("order processed", { orderId: "o-1" });
|
|
997
|
+
* });
|
|
998
|
+
* ```
|
|
999
|
+
*/
|
|
1000
|
+
function mockLogger(_options = {}) {
|
|
1001
|
+
const root = tailorRoot();
|
|
1002
|
+
const prev = root.logger;
|
|
1003
|
+
const debug = vi.fn((_message, _attributes) => {});
|
|
1004
|
+
const info = vi.fn((_message, _attributes) => {});
|
|
1005
|
+
const warn = vi.fn((_message, _attributes) => {});
|
|
1006
|
+
const error = vi.fn((_message, _attributes) => {});
|
|
1007
|
+
const setAttributes = vi.fn((_attributes) => {});
|
|
1008
|
+
root.logger = {
|
|
1009
|
+
debug,
|
|
1010
|
+
info,
|
|
1011
|
+
warn,
|
|
1012
|
+
error,
|
|
1013
|
+
setAttributes
|
|
1014
|
+
};
|
|
1015
|
+
const severityFns = {
|
|
1016
|
+
debug,
|
|
1017
|
+
info,
|
|
1018
|
+
warn,
|
|
1019
|
+
error
|
|
1020
|
+
};
|
|
1021
|
+
return withDispose({
|
|
1022
|
+
/** The `debug` `vi.fn`. */
|
|
1023
|
+
debug,
|
|
1024
|
+
/** The `info` `vi.fn`. */
|
|
1025
|
+
info,
|
|
1026
|
+
/** The `warn` `vi.fn`. */
|
|
1027
|
+
warn,
|
|
1028
|
+
/** The `error` `vi.fn`. */
|
|
1029
|
+
error,
|
|
1030
|
+
/** The `setAttributes` `vi.fn`. */
|
|
1031
|
+
setAttributes,
|
|
1032
|
+
get calls() {
|
|
1033
|
+
return Object.entries(severityFns).flatMap(([severity, fn]) => fn.mock.calls.map((args, i) => ({
|
|
1034
|
+
order: fn.mock.invocationCallOrder[i] ?? 0,
|
|
1035
|
+
call: {
|
|
1036
|
+
severity,
|
|
1037
|
+
message: args[0],
|
|
1038
|
+
attributes: args[1]
|
|
1039
|
+
}
|
|
1040
|
+
}))).toSorted((a, b) => a.order - b.order).map((e) => e.call);
|
|
1041
|
+
},
|
|
1042
|
+
clear() {
|
|
1043
|
+
debug.mockClear();
|
|
1044
|
+
info.mockClear();
|
|
1045
|
+
warn.mockClear();
|
|
1046
|
+
error.mockClear();
|
|
1047
|
+
setAttributes.mockClear();
|
|
1048
|
+
},
|
|
1049
|
+
reset() {
|
|
1050
|
+
debug.mockReset();
|
|
1051
|
+
info.mockReset();
|
|
1052
|
+
warn.mockReset();
|
|
1053
|
+
error.mockReset();
|
|
1054
|
+
setAttributes.mockReset();
|
|
1055
|
+
}
|
|
1056
|
+
}, () => {
|
|
1057
|
+
root.logger = prev;
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
981
1061
|
//#endregion
|
|
982
1062
|
//#region src/vitest/mocks/tailordb.ts
|
|
983
1063
|
function testRegex(regex, value) {
|
|
@@ -1698,7 +1778,8 @@ function createKyselyMock() {
|
|
|
1698
1778
|
*
|
|
1699
1779
|
* 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with
|
|
1700
1780
|
* control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`,
|
|
1701
|
-
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway
|
|
1781
|
+
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway`,
|
|
1782
|
+
* `mockLogger`. Each
|
|
1702
1783
|
* provides response configuration, call recording, and reset.
|
|
1703
1784
|
*
|
|
1704
1785
|
* 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the
|
|
@@ -1736,5 +1817,5 @@ function tailorRuntime(options) {
|
|
|
1736
1817
|
}
|
|
1737
1818
|
|
|
1738
1819
|
//#endregion
|
|
1739
|
-
export { createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockSecretmanager, mockTailordb, mockWorkflow, tailorRuntime };
|
|
1820
|
+
export { createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockLogger, mockSecretmanager, mockTailordb, mockWorkflow, tailorRuntime };
|
|
1740
1821
|
//# sourceMappingURL=index.mjs.map
|