@intuned/runtime-dev 0.0.1-testing.0 → 0.1.0-test.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 (50) hide show
  1. package/InterfaceTemplate/index.ts +1 -0
  2. package/Intuned.json +5 -0
  3. package/WebTemplate/api.ts +92 -90
  4. package/WebTemplate/controllers/authSessions/check.ts +23 -29
  5. package/WebTemplate/controllers/authSessions/create.ts +46 -71
  6. package/WebTemplate/controllers/authSessions/index.ts +4 -4
  7. package/WebTemplate/controllers/authSessions/killOperation.ts +1 -1
  8. package/WebTemplate/controllers/authSessions/resumeOperation.ts +28 -52
  9. package/WebTemplate/controllers/authSessions/store.ts +11 -6
  10. package/WebTemplate/controllers/runApi/helpers.ts +47 -144
  11. package/WebTemplate/index.playwright.ts +42 -32
  12. package/WebTemplate/index.vanilla.ts +2 -20
  13. package/WebTemplate/jobs.ts +2 -13
  14. package/WebTemplate/utils.ts +1 -85
  15. package/WebTemplate.zip +0 -0
  16. package/api/authed.ts +12 -0
  17. package/api/test.ts +3 -0
  18. package/api/test2.ts +25 -0
  19. package/auth-sessions/check.ts +9 -0
  20. package/auth-sessions/create.ts +32 -0
  21. package/authSessions +1 -0
  22. package/dist/commands/api/run.d.ts +1 -1
  23. package/dist/commands/api/run.js +28 -50
  24. package/dist/commands/auth-sessions/load.js +7 -1
  25. package/dist/commands/auth-sessions/run-check.js +23 -9
  26. package/dist/commands/auth-sessions/run-create.js +51 -30
  27. package/dist/commands/build.js +5 -2
  28. package/dist/commands/common/utils/settings.js +5 -5
  29. package/dist/commands/common/utils/unixSocket.d.ts +9 -0
  30. package/dist/commands/common/utils/unixSocket.js +45 -0
  31. package/dist/commands/interface/run.d.ts +2 -0
  32. package/dist/commands/interface/run.js +161 -0
  33. package/dist/common/asyncLocalStorage/index.d.ts +1 -1
  34. package/dist/common/contextStorageStateHelpers.d.ts +1 -2
  35. package/dist/common/contextStorageStateHelpers.js +9 -7
  36. package/dist/common/getPlaywrightConstructs.d.ts +7 -5
  37. package/dist/common/getPlaywrightConstructs.js +28 -11
  38. package/dist/common/runApi/errors.d.ts +71 -0
  39. package/dist/common/runApi/errors.js +172 -0
  40. package/dist/common/runApi/index.d.ts +12 -0
  41. package/dist/common/runApi/index.js +288 -0
  42. package/dist/common/runApi/types.d.ts +486 -0
  43. package/dist/common/runApi/types.js +50 -0
  44. package/dist/runtime/extendTimeout.js +10 -6
  45. package/dist/runtime/index.d.ts +1 -0
  46. package/dist/runtime/requestMoreInfo.d.ts +1 -0
  47. package/output.txt +39 -0
  48. package/package.json +7 -5
  49. package/testing +0 -0
  50. package/tsconfig.json +2 -1
@@ -0,0 +1,486 @@
1
+ import type { IntunedStorageState } from "../contextStorageStateHelpers";
2
+ import type { Payload } from "../../runtime/export";
3
+ import type { Result } from "neverthrow";
4
+ import type { RunAutomationError } from "./errors";
5
+ import z from "zod";
6
+ export interface PayloadToAppend {
7
+ apiName: string;
8
+ parameters: Record<string, any>;
9
+ }
10
+ export interface RunAutomationSuccessResult {
11
+ result: any;
12
+ status: number;
13
+ payloadToAppend: PayloadToAppend[] | null;
14
+ session?: IntunedStorageState;
15
+ }
16
+ export interface RunAutomationErrorResult {
17
+ error: string;
18
+ message: string;
19
+ status?: number;
20
+ details?: any;
21
+ [key: string]: any;
22
+ }
23
+ export type RunAutomationResult = RunAutomationSuccessResult | RunAutomationErrorResult;
24
+ export interface RunAutomationResponse {
25
+ status: number;
26
+ body: RunAutomationResult;
27
+ }
28
+ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
29
+ type: z.ZodLiteral<"file">;
30
+ path: z.ZodString;
31
+ }, "strip", z.ZodTypeAny, {
32
+ type: "file";
33
+ path: string;
34
+ }, {
35
+ type: "file";
36
+ path: string;
37
+ }>, z.ZodObject<{
38
+ type: z.ZodLiteral<"state">;
39
+ state: z.ZodType<{
40
+ cookies: {
41
+ name: string;
42
+ value: string;
43
+ domain: string;
44
+ path: string;
45
+ expires: number;
46
+ httpOnly: boolean;
47
+ secure: boolean;
48
+ sameSite: "Strict" | "Lax" | "None";
49
+ }[];
50
+ origins: {
51
+ origin: string;
52
+ localStorage: {
53
+ name: string;
54
+ value: string;
55
+ }[];
56
+ }[];
57
+ } & {
58
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
59
+ }, z.ZodTypeDef, {
60
+ cookies: {
61
+ name: string;
62
+ value: string;
63
+ domain: string;
64
+ path: string;
65
+ expires: number;
66
+ httpOnly: boolean;
67
+ secure: boolean;
68
+ sameSite: "Strict" | "Lax" | "None";
69
+ }[];
70
+ origins: {
71
+ origin: string;
72
+ localStorage: {
73
+ name: string;
74
+ value: string;
75
+ }[];
76
+ }[];
77
+ } & {
78
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
79
+ }>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ type: "state";
82
+ state: {
83
+ cookies: {
84
+ name: string;
85
+ value: string;
86
+ domain: string;
87
+ path: string;
88
+ expires: number;
89
+ httpOnly: boolean;
90
+ secure: boolean;
91
+ sameSite: "Strict" | "Lax" | "None";
92
+ }[];
93
+ origins: {
94
+ origin: string;
95
+ localStorage: {
96
+ name: string;
97
+ value: string;
98
+ }[];
99
+ }[];
100
+ } & {
101
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
102
+ };
103
+ }, {
104
+ type: "state";
105
+ state: {
106
+ cookies: {
107
+ name: string;
108
+ value: string;
109
+ domain: string;
110
+ path: string;
111
+ expires: number;
112
+ httpOnly: boolean;
113
+ secure: boolean;
114
+ sameSite: "Strict" | "Lax" | "None";
115
+ }[];
116
+ origins: {
117
+ origin: string;
118
+ localStorage: {
119
+ name: string;
120
+ value: string;
121
+ }[];
122
+ }[];
123
+ } & {
124
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
125
+ };
126
+ }>]>;
127
+ export declare const runApiParametersSchema: z.ZodObject<{
128
+ functionsToken: z.ZodOptional<z.ZodString>;
129
+ automationFunction: z.ZodObject<{
130
+ name: z.ZodString;
131
+ params: z.ZodOptional<z.ZodAny>;
132
+ }, "strip", z.ZodTypeAny, {
133
+ name: string;
134
+ params?: any;
135
+ }, {
136
+ name: string;
137
+ params?: any;
138
+ }>;
139
+ tracing: z.ZodDefault<z.ZodOptional<z.ZodDiscriminatedUnion<"enabled", [z.ZodObject<{
140
+ enabled: z.ZodLiteral<false>;
141
+ }, "strip", z.ZodTypeAny, {
142
+ enabled: false;
143
+ }, {
144
+ enabled: false;
145
+ }>, z.ZodObject<{
146
+ enabled: z.ZodLiteral<true>;
147
+ filePath: z.ZodString;
148
+ }, "strip", z.ZodTypeAny, {
149
+ enabled: true;
150
+ filePath: string;
151
+ }, {
152
+ enabled: true;
153
+ filePath: string;
154
+ }>]>>>;
155
+ auth: z.ZodOptional<z.ZodObject<{
156
+ session: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
157
+ type: z.ZodLiteral<"file">;
158
+ path: z.ZodString;
159
+ }, "strip", z.ZodTypeAny, {
160
+ type: "file";
161
+ path: string;
162
+ }, {
163
+ type: "file";
164
+ path: string;
165
+ }>, z.ZodObject<{
166
+ type: z.ZodLiteral<"state">;
167
+ state: z.ZodType<{
168
+ cookies: {
169
+ name: string;
170
+ value: string;
171
+ domain: string;
172
+ path: string;
173
+ expires: number;
174
+ httpOnly: boolean;
175
+ secure: boolean;
176
+ sameSite: "Strict" | "Lax" | "None";
177
+ }[];
178
+ origins: {
179
+ origin: string;
180
+ localStorage: {
181
+ name: string;
182
+ value: string;
183
+ }[];
184
+ }[];
185
+ } & {
186
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
187
+ }, z.ZodTypeDef, {
188
+ cookies: {
189
+ name: string;
190
+ value: string;
191
+ domain: string;
192
+ path: string;
193
+ expires: number;
194
+ httpOnly: boolean;
195
+ secure: boolean;
196
+ sameSite: "Strict" | "Lax" | "None";
197
+ }[];
198
+ origins: {
199
+ origin: string;
200
+ localStorage: {
201
+ name: string;
202
+ value: string;
203
+ }[];
204
+ }[];
205
+ } & {
206
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
207
+ }>;
208
+ }, "strip", z.ZodTypeAny, {
209
+ type: "state";
210
+ state: {
211
+ cookies: {
212
+ name: string;
213
+ value: string;
214
+ domain: string;
215
+ path: string;
216
+ expires: number;
217
+ httpOnly: boolean;
218
+ secure: boolean;
219
+ sameSite: "Strict" | "Lax" | "None";
220
+ }[];
221
+ origins: {
222
+ origin: string;
223
+ localStorage: {
224
+ name: string;
225
+ value: string;
226
+ }[];
227
+ }[];
228
+ } & {
229
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
230
+ };
231
+ }, {
232
+ type: "state";
233
+ state: {
234
+ cookies: {
235
+ name: string;
236
+ value: string;
237
+ domain: string;
238
+ path: string;
239
+ expires: number;
240
+ httpOnly: boolean;
241
+ secure: boolean;
242
+ sameSite: "Strict" | "Lax" | "None";
243
+ }[];
244
+ origins: {
245
+ origin: string;
246
+ localStorage: {
247
+ name: string;
248
+ value: string;
249
+ }[];
250
+ }[];
251
+ } & {
252
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
253
+ };
254
+ }>]>;
255
+ runCheck: z.ZodDefault<z.ZodBoolean>;
256
+ }, "strip", z.ZodTypeAny, {
257
+ session: {
258
+ type: "file";
259
+ path: string;
260
+ } | {
261
+ type: "state";
262
+ state: {
263
+ cookies: {
264
+ name: string;
265
+ value: string;
266
+ domain: string;
267
+ path: string;
268
+ expires: number;
269
+ httpOnly: boolean;
270
+ secure: boolean;
271
+ sameSite: "Strict" | "Lax" | "None";
272
+ }[];
273
+ origins: {
274
+ origin: string;
275
+ localStorage: {
276
+ name: string;
277
+ value: string;
278
+ }[];
279
+ }[];
280
+ } & {
281
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
282
+ };
283
+ };
284
+ runCheck: boolean;
285
+ }, {
286
+ session: {
287
+ type: "file";
288
+ path: string;
289
+ } | {
290
+ type: "state";
291
+ state: {
292
+ cookies: {
293
+ name: string;
294
+ value: string;
295
+ domain: string;
296
+ path: string;
297
+ expires: number;
298
+ httpOnly: boolean;
299
+ secure: boolean;
300
+ sameSite: "Strict" | "Lax" | "None";
301
+ }[];
302
+ origins: {
303
+ origin: string;
304
+ localStorage: {
305
+ name: string;
306
+ value: string;
307
+ }[];
308
+ }[];
309
+ } & {
310
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
311
+ };
312
+ };
313
+ runCheck?: boolean | undefined;
314
+ }>>;
315
+ runOptions: z.ZodDefault<z.ZodDiscriminatedUnion<"environment", [z.ZodObject<{
316
+ environment: z.ZodLiteral<"deployed">;
317
+ headless: z.ZodDefault<z.ZodBoolean>;
318
+ proxy: z.ZodOptional<z.ZodObject<{
319
+ server: z.ZodString;
320
+ username: z.ZodString;
321
+ password: z.ZodString;
322
+ }, "strip", z.ZodTypeAny, {
323
+ server: string;
324
+ username: string;
325
+ password: string;
326
+ }, {
327
+ server: string;
328
+ username: string;
329
+ password: string;
330
+ }>>;
331
+ }, "strip", z.ZodTypeAny, {
332
+ environment: "deployed";
333
+ headless: boolean;
334
+ proxy?: {
335
+ server: string;
336
+ username: string;
337
+ password: string;
338
+ } | undefined;
339
+ }, {
340
+ environment: "deployed";
341
+ headless?: boolean | undefined;
342
+ proxy?: {
343
+ server: string;
344
+ username: string;
345
+ password: string;
346
+ } | undefined;
347
+ }>, z.ZodObject<{
348
+ environment: z.ZodLiteral<"ide">;
349
+ cdpAddress: z.ZodString;
350
+ mode: z.ZodUnion<[z.ZodLiteral<"vanilla">, z.ZodLiteral<"playwright">, z.ZodLiteral<"playwright-standalone">, z.ZodLiteral<"playwright-headless">]>;
351
+ }, "strip", z.ZodTypeAny, {
352
+ mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
353
+ environment: "ide";
354
+ cdpAddress: string;
355
+ }, {
356
+ mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
357
+ environment: "ide";
358
+ cdpAddress: string;
359
+ }>]>>;
360
+ retrieveSession: z.ZodDefault<z.ZodBoolean>;
361
+ }, "strip", z.ZodTypeAny, {
362
+ automationFunction: {
363
+ name: string;
364
+ params?: any;
365
+ };
366
+ tracing: {
367
+ enabled: false;
368
+ } | {
369
+ enabled: true;
370
+ filePath: string;
371
+ };
372
+ runOptions: {
373
+ environment: "deployed";
374
+ headless: boolean;
375
+ proxy?: {
376
+ server: string;
377
+ username: string;
378
+ password: string;
379
+ } | undefined;
380
+ } | {
381
+ mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
382
+ environment: "ide";
383
+ cdpAddress: string;
384
+ };
385
+ retrieveSession: boolean;
386
+ functionsToken?: string | undefined;
387
+ auth?: {
388
+ session: {
389
+ type: "file";
390
+ path: string;
391
+ } | {
392
+ type: "state";
393
+ state: {
394
+ cookies: {
395
+ name: string;
396
+ value: string;
397
+ domain: string;
398
+ path: string;
399
+ expires: number;
400
+ httpOnly: boolean;
401
+ secure: boolean;
402
+ sameSite: "Strict" | "Lax" | "None";
403
+ }[];
404
+ origins: {
405
+ origin: string;
406
+ localStorage: {
407
+ name: string;
408
+ value: string;
409
+ }[];
410
+ }[];
411
+ } & {
412
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
413
+ };
414
+ };
415
+ runCheck: boolean;
416
+ } | undefined;
417
+ }, {
418
+ automationFunction: {
419
+ name: string;
420
+ params?: any;
421
+ };
422
+ functionsToken?: string | undefined;
423
+ tracing?: {
424
+ enabled: false;
425
+ } | {
426
+ enabled: true;
427
+ filePath: string;
428
+ } | undefined;
429
+ auth?: {
430
+ session: {
431
+ type: "file";
432
+ path: string;
433
+ } | {
434
+ type: "state";
435
+ state: {
436
+ cookies: {
437
+ name: string;
438
+ value: string;
439
+ domain: string;
440
+ path: string;
441
+ expires: number;
442
+ httpOnly: boolean;
443
+ secure: boolean;
444
+ sameSite: "Strict" | "Lax" | "None";
445
+ }[];
446
+ origins: {
447
+ origin: string;
448
+ localStorage: {
449
+ name: string;
450
+ value: string;
451
+ }[];
452
+ }[];
453
+ } & {
454
+ sessionStorage?: import("../contextStorageStateHelpers").OriginSessionStorage[] | undefined;
455
+ };
456
+ };
457
+ runCheck?: boolean | undefined;
458
+ } | undefined;
459
+ runOptions?: {
460
+ environment: "deployed";
461
+ headless?: boolean | undefined;
462
+ proxy?: {
463
+ server: string;
464
+ username: string;
465
+ password: string;
466
+ } | undefined;
467
+ } | {
468
+ mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
469
+ environment: "ide";
470
+ cdpAddress: string;
471
+ } | undefined;
472
+ retrieveSession?: boolean | undefined;
473
+ }>;
474
+ export type RunApiSession = z.infer<typeof runApiSessionSchema>;
475
+ export type RunApiParameters = z.input<typeof runApiParametersSchema>;
476
+ export type ExtendedRunApiParameters = RunApiParameters & {
477
+ abortSignal?: AbortSignal;
478
+ };
479
+ export type RunApiResultOk<R = any> = {
480
+ result: R;
481
+ extendedPayloads?: Payload[];
482
+ };
483
+ export type RunApiResultWithSessionOk<R = any> = RunApiResultOk<R> & {
484
+ session: IntunedStorageState;
485
+ };
486
+ export type RunApiResult<R = any, FullResult extends RunApiResultOk<R> = RunApiResultOk<R>> = Result<FullResult, RunAutomationError>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runApiSessionSchema = exports.runApiParametersSchema = void 0;
7
+ var _zod = _interopRequireDefault(require("zod"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const runApiSessionSchema = exports.runApiSessionSchema = _zod.default.discriminatedUnion("type", [_zod.default.object({
10
+ type: _zod.default.literal("file"),
11
+ path: _zod.default.string()
12
+ }), _zod.default.object({
13
+ type: _zod.default.literal("state"),
14
+ state: _zod.default.custom(v => v)
15
+ })]);
16
+ const runApiParametersSchema = exports.runApiParametersSchema = _zod.default.object({
17
+ functionsToken: _zod.default.string().optional(),
18
+ automationFunction: _zod.default.object({
19
+ name: _zod.default.string(),
20
+ params: _zod.default.any().optional()
21
+ }),
22
+ tracing: _zod.default.discriminatedUnion("enabled", [_zod.default.object({
23
+ enabled: _zod.default.literal(false)
24
+ }), _zod.default.object({
25
+ enabled: _zod.default.literal(true),
26
+ filePath: _zod.default.string()
27
+ })]).optional().default({
28
+ enabled: false
29
+ }),
30
+ auth: _zod.default.object({
31
+ session: runApiSessionSchema,
32
+ runCheck: _zod.default.boolean().default(false)
33
+ }).optional(),
34
+ runOptions: _zod.default.discriminatedUnion("environment", [_zod.default.object({
35
+ environment: _zod.default.literal("deployed"),
36
+ headless: _zod.default.boolean().default(true),
37
+ proxy: _zod.default.object({
38
+ server: _zod.default.string(),
39
+ username: _zod.default.string(),
40
+ password: _zod.default.string()
41
+ }).optional()
42
+ }), _zod.default.object({
43
+ environment: _zod.default.literal("ide"),
44
+ cdpAddress: _zod.default.string(),
45
+ mode: _zod.default.union([_zod.default.literal("vanilla"), _zod.default.literal("playwright"), _zod.default.literal("playwright-standalone"), _zod.default.literal("playwright-headless")])
46
+ })]).default({
47
+ environment: "deployed"
48
+ }),
49
+ retrieveSession: _zod.default.boolean().default(false)
50
+ });
@@ -14,13 +14,17 @@ function extendTimeout() {
14
14
  const {
15
15
  timeoutInfo
16
16
  } = context;
17
- if (!timeoutInfo || timeoutInfo.timeoutTimestamp === undefined || timeoutInfo.timeoutDuration === undefined || timeoutInfo.extendTimeoutCallback === undefined) {
17
+ if (!timeoutInfo) {
18
18
  return;
19
19
  }
20
- const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
21
- if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
22
- return;
20
+ if (timeoutInfo.timeoutTimestamp !== undefined && timeoutInfo.timeoutDuration !== undefined) {
21
+ const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
22
+ if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
23
+ return;
24
+ }
25
+ timeoutInfo.timeoutTimestamp = newTimeoutStamp;
26
+ }
27
+ if (timeoutInfo.extendTimeoutCallback !== undefined) {
28
+ void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
23
29
  }
24
- timeoutInfo.timeoutTimestamp = newTimeoutStamp;
25
- void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
26
30
  }
@@ -3,4 +3,5 @@ export { extendTimeout } from "./extendTimeout";
3
3
  export { runInfo } from "./runInfo";
4
4
  export { RunError } from "./RunError";
5
5
  export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
6
+ export type { RequestMoreInfoDetails } from "./requestMoreInfo";
6
7
  export { getDownloadDirectoryPath } from "./downloadDirectory";
@@ -14,4 +14,5 @@ interface RequestOtpReturnType extends RequestMoreInfoReturnTypeBase {
14
14
  declare const REQUEST_MORE_INFO_KEY: unique symbol;
15
15
  export declare function requestOTP(messageToUser: string): RequestOtpReturnType;
16
16
  export declare function requestMultipleChoice(messageToUser: string, choices: string[]): RequestMultipleChoiceReturnType;
17
+ export type RequestMoreInfoDetails = RequestMultipleChoiceReturnType | RequestOtpReturnType;
17
18
  export {};