@emesoft_company/playwright-core 2.1.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/README.md +62 -0
- package/dist/api/index.cjs +248 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.d.cts +12 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.js +245 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api-client-C_StjpPX.d.ts +58 -0
- package/dist/api-client-CpXo_NOU.d.cts +58 -0
- package/dist/auth/index.cjs +310 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +98 -0
- package/dist/auth/index.d.ts +98 -0
- package/dist/auth/index.js +304 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/config/index.cjs +268 -0
- package/dist/config/index.cjs.map +1 -0
- package/dist/config/index.d.cts +105 -0
- package/dist/config/index.d.ts +105 -0
- package/dist/config/index.js +254 -0
- package/dist/config/index.js.map +1 -0
- package/dist/data/index.cjs +59 -0
- package/dist/data/index.cjs.map +1 -0
- package/dist/data/index.d.cts +25 -0
- package/dist/data/index.d.ts +25 -0
- package/dist/data/index.js +50 -0
- package/dist/data/index.js.map +1 -0
- package/dist/di/index.cjs +47 -0
- package/dist/di/index.cjs.map +1 -0
- package/dist/di/index.d.cts +19 -0
- package/dist/di/index.d.ts +19 -0
- package/dist/di/index.js +45 -0
- package/dist/di/index.js.map +1 -0
- package/dist/errors/index.cjs +90 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +38 -0
- package/dist/errors/index.d.ts +38 -0
- package/dist/errors/index.js +83 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/expect/index.cjs +36 -0
- package/dist/expect/index.cjs.map +1 -0
- package/dist/expect/index.d.cts +30 -0
- package/dist/expect/index.d.ts +30 -0
- package/dist/expect/index.js +34 -0
- package/dist/expect/index.js.map +1 -0
- package/dist/fixtures/index.cjs +660 -0
- package/dist/fixtures/index.cjs.map +1 -0
- package/dist/fixtures/index.d.cts +68 -0
- package/dist/fixtures/index.d.ts +68 -0
- package/dist/fixtures/index.js +651 -0
- package/dist/fixtures/index.js.map +1 -0
- package/dist/index.cjs +1322 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1248 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/index.cjs +32 -0
- package/dist/logging/index.cjs.map +1 -0
- package/dist/logging/index.d.cts +18 -0
- package/dist/logging/index.d.ts +18 -0
- package/dist/logging/index.js +25 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/reporting/index.cjs +59 -0
- package/dist/reporting/index.cjs.map +1 -0
- package/dist/reporting/index.d.cts +63 -0
- package/dist/reporting/index.d.ts +63 -0
- package/dist/reporting/index.js +52 -0
- package/dist/reporting/index.js.map +1 -0
- package/dist/retry-XqnSC8YL.d.cts +27 -0
- package/dist/retry-XqnSC8YL.d.ts +27 -0
- package/dist/schema-y5w2hbT-.d.cts +292 -0
- package/dist/schema-y5w2hbT-.d.ts +292 -0
- package/dist/types-CbWnSYEK.d.cts +5 -0
- package/dist/types-CbWnSYEK.d.ts +5 -0
- package/dist/types-CopwwpSW.d.cts +8 -0
- package/dist/types-CopwwpSW.d.ts +8 -0
- package/dist/types-hInbkPXf.d.cts +59 -0
- package/dist/types-hInbkPXf.d.ts +59 -0
- package/dist/ui/index.cjs +366 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +190 -0
- package/dist/ui/index.d.ts +190 -0
- package/dist/ui/index.js +348 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/utils/index.cjs +72 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +27 -0
- package/dist/utils/index.d.ts +27 -0
- package/dist/utils/index.js +66 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +133 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Environments seen most often across projects — autocompleted, but any string is accepted. */
|
|
4
|
+
declare const KNOWN_ENVIRONMENTS: readonly ["local", "dev", "qa", "uat", "staging", "prod"];
|
|
5
|
+
/**
|
|
6
|
+
* Free-form on purpose: teams run `uat`, `qa`, `sit`, per-tenant envs and so on. The union
|
|
7
|
+
* below keeps editor autocomplete for the common ones without rejecting anything else
|
|
8
|
+
* (`(string & {})` is the TS idiom that preserves suggestions on an open string type).
|
|
9
|
+
*/
|
|
10
|
+
type Environment = (typeof KNOWN_ENVIRONMENTS)[number] | (string & {});
|
|
11
|
+
declare const EnvironmentSchema: z.ZodString;
|
|
12
|
+
declare const TimeoutsSchema: z.ZodObject<{
|
|
13
|
+
actionMs: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
navigationMs: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
testMs: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
/** Default budget for `waitForCondition` and other non-locator polling. */
|
|
17
|
+
waitMs: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
actionMs: number;
|
|
20
|
+
navigationMs: number;
|
|
21
|
+
testMs: number;
|
|
22
|
+
waitMs: number;
|
|
23
|
+
}, {
|
|
24
|
+
actionMs?: number | undefined;
|
|
25
|
+
navigationMs?: number | undefined;
|
|
26
|
+
testMs?: number | undefined;
|
|
27
|
+
waitMs?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
declare const AuthConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
30
|
+
tokenUrl: z.ZodOptional<z.ZodString>;
|
|
31
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
33
|
+
username: z.ZodOptional<z.ZodString>;
|
|
34
|
+
password: z.ZodOptional<z.ZodString>;
|
|
35
|
+
/** Single-session storage state file (see `buildGlobalSetup`). */
|
|
36
|
+
storageStatePath: z.ZodOptional<z.ZodString>;
|
|
37
|
+
/** Directory used for per-role storage state files in multi-role setups. */
|
|
38
|
+
storageStateDir: z.ZodDefault<z.ZodString>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
storageStateDir: string;
|
|
41
|
+
tokenUrl?: string | undefined;
|
|
42
|
+
clientId?: string | undefined;
|
|
43
|
+
clientSecret?: string | undefined;
|
|
44
|
+
username?: string | undefined;
|
|
45
|
+
password?: string | undefined;
|
|
46
|
+
storageStatePath?: string | undefined;
|
|
47
|
+
}, {
|
|
48
|
+
tokenUrl?: string | undefined;
|
|
49
|
+
clientId?: string | undefined;
|
|
50
|
+
clientSecret?: string | undefined;
|
|
51
|
+
username?: string | undefined;
|
|
52
|
+
password?: string | undefined;
|
|
53
|
+
storageStatePath?: string | undefined;
|
|
54
|
+
storageStateDir?: string | undefined;
|
|
55
|
+
}>>;
|
|
56
|
+
declare const ReportingConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
57
|
+
allureEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
58
|
+
resultsDir: z.ZodDefault<z.ZodString>;
|
|
59
|
+
/** `{id}` is replaced with a test-case id — see `meta()` in `@emesoft_company/playwright-core/reporting`. */
|
|
60
|
+
testCaseUrlTemplate: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
allureEnabled: boolean;
|
|
63
|
+
resultsDir: string;
|
|
64
|
+
testCaseUrlTemplate?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
allureEnabled?: boolean | undefined;
|
|
67
|
+
resultsDir?: string | undefined;
|
|
68
|
+
testCaseUrlTemplate?: string | undefined;
|
|
69
|
+
}>>;
|
|
70
|
+
declare const RetryConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
71
|
+
retries: z.ZodDefault<z.ZodNumber>;
|
|
72
|
+
minDelayMs: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
maxDelayMs: z.ZodDefault<z.ZodNumber>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
retries: number;
|
|
76
|
+
minDelayMs: number;
|
|
77
|
+
maxDelayMs: number;
|
|
78
|
+
}, {
|
|
79
|
+
retries?: number | undefined;
|
|
80
|
+
minDelayMs?: number | undefined;
|
|
81
|
+
maxDelayMs?: number | undefined;
|
|
82
|
+
}>>;
|
|
83
|
+
declare const DiagnosticsConfigSchema: z.ZodDefault<z.ZodObject<{
|
|
84
|
+
/** Collect browser console errors + failed requests and attach them to the report. */
|
|
85
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
86
|
+
/** Fail the test if the page logged a console error. Off by default — many apps are noisy. */
|
|
87
|
+
failOnConsoleError: z.ZodDefault<z.ZodBoolean>;
|
|
88
|
+
/** Fail the test on an uncaught page exception. */
|
|
89
|
+
failOnPageError: z.ZodDefault<z.ZodBoolean>;
|
|
90
|
+
/** Console messages matching any of these substrings are ignored entirely. */
|
|
91
|
+
ignoreConsolePatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
enabled: boolean;
|
|
94
|
+
failOnConsoleError: boolean;
|
|
95
|
+
failOnPageError: boolean;
|
|
96
|
+
ignoreConsolePatterns: string[];
|
|
97
|
+
}, {
|
|
98
|
+
enabled?: boolean | undefined;
|
|
99
|
+
failOnConsoleError?: boolean | undefined;
|
|
100
|
+
failOnPageError?: boolean | undefined;
|
|
101
|
+
ignoreConsolePatterns?: string[] | undefined;
|
|
102
|
+
}>>;
|
|
103
|
+
/**
|
|
104
|
+
* Base config schema shared by every project. Projects extend this via
|
|
105
|
+
* `AppConfigSchema.extend({ ... })` or by nesting project-specific fields
|
|
106
|
+
* under `custom` — core never hardcodes project business fields here.
|
|
107
|
+
*/
|
|
108
|
+
declare const AppConfigSchema: z.ZodObject<{
|
|
109
|
+
environment: z.ZodString;
|
|
110
|
+
baseUrl: z.ZodString;
|
|
111
|
+
apiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
112
|
+
tenant: z.ZodOptional<z.ZodString>;
|
|
113
|
+
timeouts: z.ZodDefault<z.ZodObject<{
|
|
114
|
+
actionMs: z.ZodDefault<z.ZodNumber>;
|
|
115
|
+
navigationMs: z.ZodDefault<z.ZodNumber>;
|
|
116
|
+
testMs: z.ZodDefault<z.ZodNumber>;
|
|
117
|
+
/** Default budget for `waitForCondition` and other non-locator polling. */
|
|
118
|
+
waitMs: z.ZodDefault<z.ZodNumber>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
actionMs: number;
|
|
121
|
+
navigationMs: number;
|
|
122
|
+
testMs: number;
|
|
123
|
+
waitMs: number;
|
|
124
|
+
}, {
|
|
125
|
+
actionMs?: number | undefined;
|
|
126
|
+
navigationMs?: number | undefined;
|
|
127
|
+
testMs?: number | undefined;
|
|
128
|
+
waitMs?: number | undefined;
|
|
129
|
+
}>>;
|
|
130
|
+
auth: z.ZodDefault<z.ZodObject<{
|
|
131
|
+
tokenUrl: z.ZodOptional<z.ZodString>;
|
|
132
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
133
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
134
|
+
username: z.ZodOptional<z.ZodString>;
|
|
135
|
+
password: z.ZodOptional<z.ZodString>;
|
|
136
|
+
/** Single-session storage state file (see `buildGlobalSetup`). */
|
|
137
|
+
storageStatePath: z.ZodOptional<z.ZodString>;
|
|
138
|
+
/** Directory used for per-role storage state files in multi-role setups. */
|
|
139
|
+
storageStateDir: z.ZodDefault<z.ZodString>;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
storageStateDir: string;
|
|
142
|
+
tokenUrl?: string | undefined;
|
|
143
|
+
clientId?: string | undefined;
|
|
144
|
+
clientSecret?: string | undefined;
|
|
145
|
+
username?: string | undefined;
|
|
146
|
+
password?: string | undefined;
|
|
147
|
+
storageStatePath?: string | undefined;
|
|
148
|
+
}, {
|
|
149
|
+
tokenUrl?: string | undefined;
|
|
150
|
+
clientId?: string | undefined;
|
|
151
|
+
clientSecret?: string | undefined;
|
|
152
|
+
username?: string | undefined;
|
|
153
|
+
password?: string | undefined;
|
|
154
|
+
storageStatePath?: string | undefined;
|
|
155
|
+
storageStateDir?: string | undefined;
|
|
156
|
+
}>>;
|
|
157
|
+
reporting: z.ZodDefault<z.ZodObject<{
|
|
158
|
+
allureEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
159
|
+
resultsDir: z.ZodDefault<z.ZodString>;
|
|
160
|
+
/** `{id}` is replaced with a test-case id — see `meta()` in `@emesoft_company/playwright-core/reporting`. */
|
|
161
|
+
testCaseUrlTemplate: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, "strip", z.ZodTypeAny, {
|
|
163
|
+
allureEnabled: boolean;
|
|
164
|
+
resultsDir: string;
|
|
165
|
+
testCaseUrlTemplate?: string | undefined;
|
|
166
|
+
}, {
|
|
167
|
+
allureEnabled?: boolean | undefined;
|
|
168
|
+
resultsDir?: string | undefined;
|
|
169
|
+
testCaseUrlTemplate?: string | undefined;
|
|
170
|
+
}>>;
|
|
171
|
+
retry: z.ZodDefault<z.ZodObject<{
|
|
172
|
+
retries: z.ZodDefault<z.ZodNumber>;
|
|
173
|
+
minDelayMs: z.ZodDefault<z.ZodNumber>;
|
|
174
|
+
maxDelayMs: z.ZodDefault<z.ZodNumber>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
retries: number;
|
|
177
|
+
minDelayMs: number;
|
|
178
|
+
maxDelayMs: number;
|
|
179
|
+
}, {
|
|
180
|
+
retries?: number | undefined;
|
|
181
|
+
minDelayMs?: number | undefined;
|
|
182
|
+
maxDelayMs?: number | undefined;
|
|
183
|
+
}>>;
|
|
184
|
+
diagnostics: z.ZodDefault<z.ZodObject<{
|
|
185
|
+
/** Collect browser console errors + failed requests and attach them to the report. */
|
|
186
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
187
|
+
/** Fail the test if the page logged a console error. Off by default — many apps are noisy. */
|
|
188
|
+
failOnConsoleError: z.ZodDefault<z.ZodBoolean>;
|
|
189
|
+
/** Fail the test on an uncaught page exception. */
|
|
190
|
+
failOnPageError: z.ZodDefault<z.ZodBoolean>;
|
|
191
|
+
/** Console messages matching any of these substrings are ignored entirely. */
|
|
192
|
+
ignoreConsolePatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
enabled: boolean;
|
|
195
|
+
failOnConsoleError: boolean;
|
|
196
|
+
failOnPageError: boolean;
|
|
197
|
+
ignoreConsolePatterns: string[];
|
|
198
|
+
}, {
|
|
199
|
+
enabled?: boolean | undefined;
|
|
200
|
+
failOnConsoleError?: boolean | undefined;
|
|
201
|
+
failOnPageError?: boolean | undefined;
|
|
202
|
+
ignoreConsolePatterns?: string[] | undefined;
|
|
203
|
+
}>>;
|
|
204
|
+
logLevel: z.ZodDefault<z.ZodEnum<["fatal", "error", "warn", "info", "debug", "trace", "silent"]>>;
|
|
205
|
+
custom: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
206
|
+
}, "strip", z.ZodTypeAny, {
|
|
207
|
+
environment: string;
|
|
208
|
+
baseUrl: string;
|
|
209
|
+
timeouts: {
|
|
210
|
+
actionMs: number;
|
|
211
|
+
navigationMs: number;
|
|
212
|
+
testMs: number;
|
|
213
|
+
waitMs: number;
|
|
214
|
+
};
|
|
215
|
+
auth: {
|
|
216
|
+
storageStateDir: string;
|
|
217
|
+
tokenUrl?: string | undefined;
|
|
218
|
+
clientId?: string | undefined;
|
|
219
|
+
clientSecret?: string | undefined;
|
|
220
|
+
username?: string | undefined;
|
|
221
|
+
password?: string | undefined;
|
|
222
|
+
storageStatePath?: string | undefined;
|
|
223
|
+
};
|
|
224
|
+
reporting: {
|
|
225
|
+
allureEnabled: boolean;
|
|
226
|
+
resultsDir: string;
|
|
227
|
+
testCaseUrlTemplate?: string | undefined;
|
|
228
|
+
};
|
|
229
|
+
retry: {
|
|
230
|
+
retries: number;
|
|
231
|
+
minDelayMs: number;
|
|
232
|
+
maxDelayMs: number;
|
|
233
|
+
};
|
|
234
|
+
diagnostics: {
|
|
235
|
+
enabled: boolean;
|
|
236
|
+
failOnConsoleError: boolean;
|
|
237
|
+
failOnPageError: boolean;
|
|
238
|
+
ignoreConsolePatterns: string[];
|
|
239
|
+
};
|
|
240
|
+
logLevel: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent";
|
|
241
|
+
custom: Record<string, unknown>;
|
|
242
|
+
apiBaseUrl?: string | undefined;
|
|
243
|
+
tenant?: string | undefined;
|
|
244
|
+
}, {
|
|
245
|
+
environment: string;
|
|
246
|
+
baseUrl: string;
|
|
247
|
+
apiBaseUrl?: string | undefined;
|
|
248
|
+
tenant?: string | undefined;
|
|
249
|
+
timeouts?: {
|
|
250
|
+
actionMs?: number | undefined;
|
|
251
|
+
navigationMs?: number | undefined;
|
|
252
|
+
testMs?: number | undefined;
|
|
253
|
+
waitMs?: number | undefined;
|
|
254
|
+
} | undefined;
|
|
255
|
+
auth?: {
|
|
256
|
+
tokenUrl?: string | undefined;
|
|
257
|
+
clientId?: string | undefined;
|
|
258
|
+
clientSecret?: string | undefined;
|
|
259
|
+
username?: string | undefined;
|
|
260
|
+
password?: string | undefined;
|
|
261
|
+
storageStatePath?: string | undefined;
|
|
262
|
+
storageStateDir?: string | undefined;
|
|
263
|
+
} | undefined;
|
|
264
|
+
reporting?: {
|
|
265
|
+
allureEnabled?: boolean | undefined;
|
|
266
|
+
resultsDir?: string | undefined;
|
|
267
|
+
testCaseUrlTemplate?: string | undefined;
|
|
268
|
+
} | undefined;
|
|
269
|
+
retry?: {
|
|
270
|
+
retries?: number | undefined;
|
|
271
|
+
minDelayMs?: number | undefined;
|
|
272
|
+
maxDelayMs?: number | undefined;
|
|
273
|
+
} | undefined;
|
|
274
|
+
diagnostics?: {
|
|
275
|
+
enabled?: boolean | undefined;
|
|
276
|
+
failOnConsoleError?: boolean | undefined;
|
|
277
|
+
failOnPageError?: boolean | undefined;
|
|
278
|
+
ignoreConsolePatterns?: string[] | undefined;
|
|
279
|
+
} | undefined;
|
|
280
|
+
logLevel?: "fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent" | undefined;
|
|
281
|
+
custom?: Record<string, unknown> | undefined;
|
|
282
|
+
}>;
|
|
283
|
+
type AppConfig = Omit<z.infer<typeof AppConfigSchema>, "environment"> & {
|
|
284
|
+
environment: Environment;
|
|
285
|
+
};
|
|
286
|
+
type TimeoutsConfig = z.infer<typeof TimeoutsSchema>;
|
|
287
|
+
type AuthConfig = z.infer<typeof AuthConfigSchema>;
|
|
288
|
+
type ReportingConfig = z.infer<typeof ReportingConfigSchema>;
|
|
289
|
+
type RetryConfig = z.infer<typeof RetryConfigSchema>;
|
|
290
|
+
type DiagnosticsConfig = z.infer<typeof DiagnosticsConfigSchema>;
|
|
291
|
+
|
|
292
|
+
export { type AppConfig as A, type DiagnosticsConfig as D, type Environment as E, KNOWN_ENVIRONMENTS as K, type ReportingConfig as R, type TimeoutsConfig as T, AppConfigSchema as a, type AuthConfig as b, AuthConfigSchema as c, DiagnosticsConfigSchema as d, EnvironmentSchema as e, ReportingConfigSchema as f, type RetryConfig as g, RetryConfigSchema as h, TimeoutsSchema as i };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface TokenProvider {
|
|
2
|
+
/** Returns a valid access token, refreshing/caching internally as needed. */
|
|
3
|
+
getToken(): Promise<string>;
|
|
4
|
+
/** Drops any cached token, forcing the next `getToken()` to re-authenticate. */
|
|
5
|
+
invalidate(): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type { TokenProvider as T };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface TokenProvider {
|
|
2
|
+
/** Returns a valid access token, refreshing/caching internally as needed. */
|
|
3
|
+
getToken(): Promise<string>;
|
|
4
|
+
/** Drops any cached token, forcing the next `getToken()` to re-authenticate. */
|
|
5
|
+
invalidate(): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type { TokenProvider as T };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** File payload for a multipart upload. */
|
|
4
|
+
interface MultipartFile {
|
|
5
|
+
name: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
buffer: Buffer;
|
|
8
|
+
}
|
|
9
|
+
interface ApiRequestOptions<T = unknown> {
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
12
|
+
/** JSON body (objects are serialized by Playwright). */
|
|
13
|
+
data?: unknown;
|
|
14
|
+
/** `application/x-www-form-urlencoded` body. */
|
|
15
|
+
form?: Record<string, string | number | boolean>;
|
|
16
|
+
/** `multipart/form-data` body, for file uploads. */
|
|
17
|
+
multipart?: Record<string, string | number | boolean | MultipartFile>;
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
/** Skip attaching the Authorization header for this call (e.g. public endpoints). */
|
|
20
|
+
skipAuth?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Status code(s) to treat as success. Defaults to any 2xx. Set it to assert an exact
|
|
23
|
+
* contract (`expectStatus: 201`) or to accept an expected error (`expectStatus: [200, 404]`)
|
|
24
|
+
* without the call throwing.
|
|
25
|
+
*/
|
|
26
|
+
expectStatus?: number | number[];
|
|
27
|
+
/**
|
|
28
|
+
* Validates (and types) the response body. When given, `T` is inferred from the schema and a
|
|
29
|
+
* shape mismatch fails the call with a clear error instead of surfacing later as `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
schema?: ZodType<T>;
|
|
32
|
+
}
|
|
33
|
+
/** Full response, for when the status/headers matter as much as the body. */
|
|
34
|
+
interface ApiResponse<T = unknown> {
|
|
35
|
+
status: number;
|
|
36
|
+
ok: boolean;
|
|
37
|
+
headers: Record<string, string>;
|
|
38
|
+
data: T;
|
|
39
|
+
url: string;
|
|
40
|
+
method: string;
|
|
41
|
+
}
|
|
42
|
+
interface RequestContext {
|
|
43
|
+
method: string;
|
|
44
|
+
url: string;
|
|
45
|
+
headers: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
interface ResponseContext {
|
|
48
|
+
method: string;
|
|
49
|
+
url: string;
|
|
50
|
+
status: number;
|
|
51
|
+
}
|
|
52
|
+
interface ApiClientInterceptors {
|
|
53
|
+
/** Runs right before the request is sent; return modified headers or void to leave them as-is. */
|
|
54
|
+
onRequest?: (ctx: RequestContext) => Record<string, string> | void | Promise<Record<string, string> | void>;
|
|
55
|
+
/** Runs after every response, success or failure, before retry/error handling. */
|
|
56
|
+
onResponse?: (ctx: ResponseContext) => void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type { ApiClientInterceptors as A, MultipartFile as M, RequestContext as R, ApiRequestOptions as a, ApiResponse as b, ResponseContext as c };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** File payload for a multipart upload. */
|
|
4
|
+
interface MultipartFile {
|
|
5
|
+
name: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
buffer: Buffer;
|
|
8
|
+
}
|
|
9
|
+
interface ApiRequestOptions<T = unknown> {
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
12
|
+
/** JSON body (objects are serialized by Playwright). */
|
|
13
|
+
data?: unknown;
|
|
14
|
+
/** `application/x-www-form-urlencoded` body. */
|
|
15
|
+
form?: Record<string, string | number | boolean>;
|
|
16
|
+
/** `multipart/form-data` body, for file uploads. */
|
|
17
|
+
multipart?: Record<string, string | number | boolean | MultipartFile>;
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
/** Skip attaching the Authorization header for this call (e.g. public endpoints). */
|
|
20
|
+
skipAuth?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Status code(s) to treat as success. Defaults to any 2xx. Set it to assert an exact
|
|
23
|
+
* contract (`expectStatus: 201`) or to accept an expected error (`expectStatus: [200, 404]`)
|
|
24
|
+
* without the call throwing.
|
|
25
|
+
*/
|
|
26
|
+
expectStatus?: number | number[];
|
|
27
|
+
/**
|
|
28
|
+
* Validates (and types) the response body. When given, `T` is inferred from the schema and a
|
|
29
|
+
* shape mismatch fails the call with a clear error instead of surfacing later as `undefined`.
|
|
30
|
+
*/
|
|
31
|
+
schema?: ZodType<T>;
|
|
32
|
+
}
|
|
33
|
+
/** Full response, for when the status/headers matter as much as the body. */
|
|
34
|
+
interface ApiResponse<T = unknown> {
|
|
35
|
+
status: number;
|
|
36
|
+
ok: boolean;
|
|
37
|
+
headers: Record<string, string>;
|
|
38
|
+
data: T;
|
|
39
|
+
url: string;
|
|
40
|
+
method: string;
|
|
41
|
+
}
|
|
42
|
+
interface RequestContext {
|
|
43
|
+
method: string;
|
|
44
|
+
url: string;
|
|
45
|
+
headers: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
interface ResponseContext {
|
|
48
|
+
method: string;
|
|
49
|
+
url: string;
|
|
50
|
+
status: number;
|
|
51
|
+
}
|
|
52
|
+
interface ApiClientInterceptors {
|
|
53
|
+
/** Runs right before the request is sent; return modified headers or void to leave them as-is. */
|
|
54
|
+
onRequest?: (ctx: RequestContext) => Record<string, string> | void | Promise<Record<string, string> | void>;
|
|
55
|
+
/** Runs after every response, success or failure, before retry/error handling. */
|
|
56
|
+
onResponse?: (ctx: ResponseContext) => void | Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type { ApiClientInterceptors as A, MultipartFile as M, RequestContext as R, ApiRequestOptions as a, ApiResponse as b, ResponseContext as c };
|