@intuned/runtime 1.1.5 → 1.2.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 (121) hide show
  1. package/.npmrc.d +1 -0
  2. package/CHANGELOG.md +5 -1
  3. package/WebTemplate.zip +0 -0
  4. package/bin/intuned +2 -0
  5. package/dist/commands/api/run.js +2 -1
  6. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  7. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  8. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  9. package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
  10. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  11. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  12. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  13. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
  14. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  15. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
  16. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  17. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  18. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  19. package/dist/commands/intuned-cli/commands/command.js +9 -0
  20. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  21. package/dist/commands/intuned-cli/commands/deploy.command.js +46 -0
  22. package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
  23. package/dist/commands/intuned-cli/commands/index.js +170 -0
  24. package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  25. package/dist/commands/intuned-cli/commands/init.command.js +14 -0
  26. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  27. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  28. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  29. package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
  30. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +20 -0
  31. package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
  32. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  33. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
  34. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  35. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
  36. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  37. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
  38. package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
  39. package/dist/commands/intuned-cli/commands/types.js +21 -0
  40. package/dist/{common/cli/constants.d.ts → commands/intuned-cli/constants/index.d.ts} +5 -6
  41. package/dist/{common/cli/constants.js → commands/intuned-cli/constants/index.js} +27 -7
  42. package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
  43. package/dist/commands/intuned-cli/constants/readme.js +150 -0
  44. package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
  45. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
  46. package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
  47. package/dist/commands/intuned-cli/controller/api.js +181 -0
  48. package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
  49. package/dist/commands/intuned-cli/controller/authSession.js +292 -0
  50. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  51. package/dist/commands/intuned-cli/controller/build.js +36 -0
  52. package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
  53. package/dist/commands/{deploy/utils.js → intuned-cli/controller/deploy.js} +114 -107
  54. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  55. package/dist/commands/intuned-cli/controller/index.js +46 -0
  56. package/dist/commands/intuned-cli/controller/init.d.ts +5 -0
  57. package/dist/commands/intuned-cli/controller/init.js +136 -0
  58. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  59. package/dist/commands/intuned-cli/helpers/api.js +19 -0
  60. package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
  61. package/dist/commands/intuned-cli/helpers/auth.js +129 -0
  62. package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  63. package/dist/commands/intuned-cli/helpers/backend.js +26 -0
  64. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  65. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  66. package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
  67. package/dist/commands/intuned-cli/helpers/errors.js +55 -0
  68. package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
  69. package/dist/commands/intuned-cli/helpers/index.js +115 -0
  70. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
  71. package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
  72. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  73. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  74. package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  75. package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  76. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  77. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  78. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  79. package/dist/commands/intuned-cli/helpers/validation.js +12 -0
  80. package/dist/commands/intuned-cli/index.d.ts +1 -0
  81. package/dist/commands/intuned-cli/index.js +16 -0
  82. package/dist/commands/intuned-cli/main.d.ts +1 -0
  83. package/dist/commands/intuned-cli/main.js +15 -0
  84. package/dist/{common/cli → commands/intuned-cli}/types.d.ts +2 -33
  85. package/dist/common/constants.d.ts +1 -0
  86. package/dist/common/constants.js +2 -1
  87. package/dist/common/runApi/index.d.ts +3 -0
  88. package/dist/common/runApi/index.js +13 -10
  89. package/dist/common/runApi/types.d.ts +140 -9
  90. package/dist/common/runApi/types.js +28 -27
  91. package/package.json +8 -8
  92. package/tsconfig.json +2 -1
  93. package/bin/check-auth-session +0 -3
  94. package/bin/cli-build +0 -3
  95. package/bin/create-auth-session +0 -3
  96. package/bin/deploy +0 -3
  97. package/bin/init +0 -3
  98. package/bin/run-api +0 -3
  99. package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
  100. package/dist/commands/cli-auth-sessions/check.js +0 -40
  101. package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
  102. package/dist/commands/cli-auth-sessions/create.js +0 -53
  103. package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
  104. package/dist/commands/cli-auth-sessions/utils.js +0 -284
  105. package/dist/commands/cli-build/cli-build.d.ts +0 -2
  106. package/dist/commands/cli-build/cli-build.js +0 -20
  107. package/dist/commands/deploy/deploy.d.ts +0 -2
  108. package/dist/commands/deploy/deploy.js +0 -47
  109. package/dist/commands/deploy/utils.d.ts +0 -16
  110. package/dist/commands/init/init.d.ts +0 -2
  111. package/dist/commands/init/init.js +0 -22
  112. package/dist/commands/init/utils.d.ts +0 -11
  113. package/dist/commands/init/utils.js +0 -175
  114. package/dist/commands/run-api-cli/run-api.d.ts +0 -2
  115. package/dist/commands/run-api-cli/run-api.js +0 -57
  116. package/dist/commands/run-api-cli/utils.d.ts +0 -9
  117. package/dist/commands/run-api-cli/utils.js +0 -144
  118. package/dist/common/cli/cliReadme.d.ts +0 -1
  119. package/dist/common/cli/cliReadme.js +0 -92
  120. package/dist/common/cli/utils.d.ts +0 -6
  121. /package/dist/{common/cli → commands/intuned-cli}/types.js +0 -0
@@ -150,20 +150,23 @@ async function* runApiGenerator({
150
150
  }
151
151
  (0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
152
152
  if (checkFn !== undefined) {
153
- console.log("Running auth check");
154
- const authCheckResult = await checkAuthSessionWithRetries(page, context, checkFn, 2);
155
- if (authCheckResult.isErr()) {
156
- const error = authCheckResult.error;
157
- if (["APINotFoundError", "InvalidAPIError"].includes(error.code)) {
158
- return (0, _neverthrow.err)(new _errors.InvalidCheckError(`Auth session check function failed`, error));
153
+ try {
154
+ console.log("Running auth check");
155
+ const authCheckResult = await checkAuthSessionWithRetries(page, context, checkFn, 2);
156
+ if (authCheckResult.isErr()) {
157
+ const error = authCheckResult.error;
158
+ if (["APINotFoundError", "InvalidAPIError"].includes(error.code)) {
159
+ return (0, _neverthrow.err)(new _errors.InvalidCheckError(`Auth session check function failed`, error));
160
+ }
161
+ return authCheckResult;
159
162
  }
160
- return authCheckResult;
161
- }
162
- if (!authCheckResult.value) {
163
+ if (!authCheckResult.value) {
164
+ return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
165
+ }
166
+ } catch (error) {
163
167
  return (0, _neverthrow.err)(new _errors.AuthCheckFailedError());
164
168
  }
165
169
  }
166
- console.log("Running automation");
167
170
  const automationFunctionParameters = [...(automationFunction.params !== undefined ? [automationFunction.params] : []), page, context];
168
171
  let result;
169
172
  if (importedModule.type === "async-generator") {
@@ -25,15 +25,146 @@ export interface RunAutomationResponse {
25
25
  status: number;
26
26
  body: RunAutomationResult;
27
27
  }
28
+ export declare const runApiStorageStateSchema: z.ZodObject<{
29
+ cookies: z.ZodArray<z.ZodObject<{
30
+ name: z.ZodString;
31
+ value: z.ZodString;
32
+ domain: z.ZodString;
33
+ path: z.ZodString;
34
+ expires: z.ZodNumber;
35
+ httpOnly: z.ZodBoolean;
36
+ secure: z.ZodBoolean;
37
+ sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
38
+ }, "strip", z.ZodTypeAny, {
39
+ value: string;
40
+ name: string;
41
+ path: string;
42
+ domain: string;
43
+ expires: number;
44
+ httpOnly: boolean;
45
+ secure: boolean;
46
+ sameSite: "Strict" | "Lax" | "None";
47
+ }, {
48
+ value: string;
49
+ name: string;
50
+ path: string;
51
+ domain: string;
52
+ expires: number;
53
+ httpOnly: boolean;
54
+ secure: boolean;
55
+ sameSite: "Strict" | "Lax" | "None";
56
+ }>, "many">;
57
+ origins: z.ZodArray<z.ZodObject<{
58
+ origin: z.ZodString;
59
+ localStorage: z.ZodArray<z.ZodObject<{
60
+ name: z.ZodString;
61
+ value: z.ZodString;
62
+ }, "strip", z.ZodTypeAny, {
63
+ value: string;
64
+ name: string;
65
+ }, {
66
+ value: string;
67
+ name: string;
68
+ }>, "many">;
69
+ }, "strip", z.ZodTypeAny, {
70
+ origin: string;
71
+ localStorage: {
72
+ value: string;
73
+ name: string;
74
+ }[];
75
+ }, {
76
+ origin: string;
77
+ localStorage: {
78
+ value: string;
79
+ name: string;
80
+ }[];
81
+ }>, "many">;
82
+ sessionStorage: z.ZodOptional<z.ZodArray<z.ZodObject<{
83
+ origin: z.ZodString;
84
+ sessionStorage: z.ZodArray<z.ZodObject<{
85
+ name: z.ZodString;
86
+ value: z.ZodString;
87
+ }, "strip", z.ZodTypeAny, {
88
+ value: string;
89
+ name: string;
90
+ }, {
91
+ value: string;
92
+ name: string;
93
+ }>, "many">;
94
+ }, "strip", z.ZodTypeAny, {
95
+ sessionStorage: {
96
+ value: string;
97
+ name: string;
98
+ }[];
99
+ origin: string;
100
+ }, {
101
+ sessionStorage: {
102
+ value: string;
103
+ name: string;
104
+ }[];
105
+ origin: string;
106
+ }>, "many">>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ cookies: {
109
+ value: string;
110
+ name: string;
111
+ path: string;
112
+ domain: string;
113
+ expires: number;
114
+ httpOnly: boolean;
115
+ secure: boolean;
116
+ sameSite: "Strict" | "Lax" | "None";
117
+ }[];
118
+ origins: {
119
+ origin: string;
120
+ localStorage: {
121
+ value: string;
122
+ name: string;
123
+ }[];
124
+ }[];
125
+ sessionStorage?: {
126
+ sessionStorage: {
127
+ value: string;
128
+ name: string;
129
+ }[];
130
+ origin: string;
131
+ }[] | undefined;
132
+ }, {
133
+ cookies: {
134
+ value: string;
135
+ name: string;
136
+ path: string;
137
+ domain: string;
138
+ expires: number;
139
+ httpOnly: boolean;
140
+ secure: boolean;
141
+ sameSite: "Strict" | "Lax" | "None";
142
+ }[];
143
+ origins: {
144
+ origin: string;
145
+ localStorage: {
146
+ value: string;
147
+ name: string;
148
+ }[];
149
+ }[];
150
+ sessionStorage?: {
151
+ sessionStorage: {
152
+ value: string;
153
+ name: string;
154
+ }[];
155
+ origin: string;
156
+ }[] | undefined;
157
+ }>;
158
+ export type RunApiStorageState = z.input<typeof runApiStorageStateSchema>;
28
159
  export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
29
160
  type: z.ZodLiteral<"file">;
30
161
  path: z.ZodString;
31
162
  }, "strip", z.ZodTypeAny, {
32
- type: "file";
33
163
  path: string;
34
- }, {
35
164
  type: "file";
165
+ }, {
36
166
  path: string;
167
+ type: "file";
37
168
  }>, z.ZodObject<{
38
169
  type: z.ZodLiteral<"state">;
39
170
  state: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -255,11 +386,11 @@ export declare const runApiParametersSchema: z.ZodObject<{
255
386
  type: z.ZodLiteral<"file">;
256
387
  path: z.ZodString;
257
388
  }, "strip", z.ZodTypeAny, {
258
- type: "file";
259
389
  path: string;
260
- }, {
261
390
  type: "file";
391
+ }, {
262
392
  path: string;
393
+ type: "file";
263
394
  }>, z.ZodObject<{
264
395
  type: z.ZodLiteral<"state">;
265
396
  state: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -452,8 +583,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
452
583
  runCheck: z.ZodDefault<z.ZodBoolean>;
453
584
  }, "strip", z.ZodTypeAny, {
454
585
  session: {
455
- type: "file";
456
586
  path: string;
587
+ type: "file";
457
588
  } | {
458
589
  type: "state";
459
590
  state?: {
@@ -486,8 +617,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
486
617
  runCheck: boolean;
487
618
  }, {
488
619
  session: {
489
- type: "file";
490
620
  path: string;
621
+ type: "file";
491
622
  } | {
492
623
  type: "state";
493
624
  state?: {
@@ -592,8 +723,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
592
723
  retrieveSession: boolean;
593
724
  auth?: {
594
725
  session: {
595
- type: "file";
596
726
  path: string;
727
+ type: "file";
597
728
  } | {
598
729
  type: "state";
599
730
  state?: {
@@ -638,8 +769,8 @@ export declare const runApiParametersSchema: z.ZodObject<{
638
769
  } | undefined;
639
770
  auth?: {
640
771
  session: {
641
- type: "file";
642
772
  path: string;
773
+ type: "file";
643
774
  } | {
644
775
  type: "state";
645
776
  state?: {
@@ -703,6 +834,6 @@ export type RunApiResultOk<R = any> = {
703
834
  extendedPayloads?: Payload[];
704
835
  };
705
836
  export type RunApiResultWithSessionOk<R = any> = RunApiResultOk<R> & {
706
- session: StorageState;
837
+ session: RunApiStorageState;
707
838
  };
708
839
  export type RunApiResult<R = any, FullResult extends RunApiResultOk<R> = RunApiResultOk<R>> = Result<FullResult, RunAutomationError>;
@@ -3,40 +3,41 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.runApiSessionSchema = exports.runApiParametersSchema = void 0;
6
+ exports.runApiStorageStateSchema = exports.runApiSessionSchema = exports.runApiParametersSchema = void 0;
7
7
  var _zod = _interopRequireDefault(require("zod"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const runApiStorageStateSchema = exports.runApiStorageStateSchema = _zod.default.object({
10
+ cookies: _zod.default.array(_zod.default.object({
11
+ name: _zod.default.string(),
12
+ value: _zod.default.string(),
13
+ domain: _zod.default.string(),
14
+ path: _zod.default.string(),
15
+ expires: _zod.default.number(),
16
+ httpOnly: _zod.default.boolean(),
17
+ secure: _zod.default.boolean(),
18
+ sameSite: _zod.default.enum(["Strict", "Lax", "None"])
19
+ })),
20
+ origins: _zod.default.array(_zod.default.object({
21
+ origin: _zod.default.string(),
22
+ localStorage: _zod.default.array(_zod.default.object({
23
+ name: _zod.default.string(),
24
+ value: _zod.default.string()
25
+ }))
26
+ })),
27
+ sessionStorage: _zod.default.array(_zod.default.object({
28
+ origin: _zod.default.string(),
29
+ sessionStorage: _zod.default.array(_zod.default.object({
30
+ name: _zod.default.string(),
31
+ value: _zod.default.string()
32
+ }))
33
+ })).optional()
34
+ });
9
35
  const runApiSessionSchema = exports.runApiSessionSchema = _zod.default.discriminatedUnion("type", [_zod.default.object({
10
36
  type: _zod.default.literal("file"),
11
37
  path: _zod.default.string()
12
38
  }), _zod.default.object({
13
39
  type: _zod.default.literal("state"),
14
- state: _zod.default.object({
15
- cookies: _zod.default.array(_zod.default.object({
16
- name: _zod.default.string(),
17
- value: _zod.default.string(),
18
- domain: _zod.default.string(),
19
- path: _zod.default.string(),
20
- expires: _zod.default.number(),
21
- httpOnly: _zod.default.boolean(),
22
- secure: _zod.default.boolean(),
23
- sameSite: _zod.default.enum(["Strict", "Lax", "None"])
24
- })),
25
- origins: _zod.default.array(_zod.default.object({
26
- origin: _zod.default.string(),
27
- localStorage: _zod.default.array(_zod.default.object({
28
- name: _zod.default.string(),
29
- value: _zod.default.string()
30
- }))
31
- })),
32
- sessionStorage: _zod.default.array(_zod.default.object({
33
- origin: _zod.default.string(),
34
- sessionStorage: _zod.default.array(_zod.default.object({
35
- name: _zod.default.string(),
36
- value: _zod.default.string()
37
- }))
38
- })).optional()
39
- }).nullable().optional()
40
+ state: runApiStorageStateSchema.nullable().optional()
40
41
  })]);
41
42
  const runApiParametersSchema = exports.runApiParametersSchema = _zod.default.object({
42
43
  automationFunction: _zod.default.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -29,6 +29,7 @@
29
29
  "intuned-auth-session-refresh": "vite-node ./src/commands/auth/run-refresh.ts",
30
30
  "intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
31
31
  "intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
32
+ "intuned": "vite-node ./src/commands/intuned-cli/main.ts",
32
33
  "build": "rm -rf dist && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && cp -r ./src/common/assets dist/common/assets",
33
34
  "test": "vitest run",
34
35
  "test:watch": "vitest",
@@ -50,12 +51,7 @@
50
51
  "intuned-browser-start": "./bin/intuned-browser-start",
51
52
  "intuned-browser-save-state": "./bin/intuned-browser-save-state",
52
53
  "intuned-ts-check": "./bin/intuned-ts-check",
53
- "init": "./bin/init",
54
- "run-api": "./bin/run-api",
55
- "deploy": "./bin/deploy",
56
- "cli-build": "./bin/cli-build",
57
- "create-auth-session": "./bin/create-auth-session",
58
- "check-auth-session": "./bin/check-auth-session"
54
+ "intuned": "./bin/intuned"
59
55
  },
60
56
  "dependencies": {
61
57
  "@babel/plugin-syntax-dynamic-import": "7.8.3",
@@ -70,7 +66,7 @@
70
66
  "applicationinsights": "2.9.2",
71
67
  "babel-plugin-dynamic-import-node": "2.3.3",
72
68
  "chalk": "^4.1.2",
73
- "commander": "^11.0.0",
69
+ "commander": "14.0.0",
74
70
  "cross-fetch": "^4.0.0",
75
71
  "dotenv": "^16.3.1",
76
72
  "fs-extra": "^11.3.0",
@@ -87,6 +83,7 @@
87
83
  "promptly": "3.2.0",
88
84
  "rollup": "3.26.2",
89
85
  "source-map": "0.7.4",
86
+ "terminal-kit": "^3.1.2",
90
87
  "ts-morph": "21.0.1",
91
88
  "ts-node": "10.9.1",
92
89
  "tslib": "2.6.0",
@@ -105,7 +102,9 @@
105
102
  "@ngneat/falso": "^7.2.0",
106
103
  "@types/jest": "^29.5.3",
107
104
  "@types/jsdom": "^21.1.1",
105
+ "@types/ms": "^2.1.0",
108
106
  "@types/promptly": "^3.0.4",
107
+ "@types/terminal-kit": "^2.5.7",
109
108
  "@types/wait-on": "^5.3.4",
110
109
  "@typescript-eslint/eslint-plugin": "^5.47.1",
111
110
  "@typescript-eslint/parser": "^7.5.0",
@@ -119,6 +118,7 @@
119
118
  "eslint-plugin-deprecation": "^1.3.3",
120
119
  "eslint-plugin-prettier": "^4.2.1",
121
120
  "msw": "^2.1.2",
121
+ "playwright": "1.44.1",
122
122
  "typedoc": "^0.25.13",
123
123
  "typedoc-plugin-frontmatter": "^1.0.0",
124
124
  "typedoc-plugin-markdown": "^4.0.2",
package/tsconfig.json CHANGED
@@ -12,7 +12,8 @@
12
12
  "sourceMap": false,
13
13
  "declaration": true,
14
14
  "emitDeclarationOnly": false,
15
- "skipLibCheck": true
15
+ "skipLibCheck": true,
16
+ "types": ["vitest/globals"]
16
17
  },
17
18
  "include": [
18
19
  "src/**/*.ts",
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/cli-auth-sessions/check.js");
package/bin/cli-build DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/cli-build/cli-build.js");
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/cli-auth-sessions/create.js");
package/bin/deploy DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/deploy/deploy.js");
package/bin/init DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/init/init.js");
package/bin/run-api DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/run-api-cli/run-api.js");
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _utils = require("./utils");
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- _dotenv.default.config({
10
- path: `.env`
11
- });
12
- _commander.program.description("Check an auth session, if it is still valid or not").argument("<auth-session>", "Name/id of the auth session instance to use").action(async authSession => {
13
- try {
14
- if (!authSession) {
15
- throw new Error("Auth session instance is required, provide an ID/name for it");
16
- }
17
- const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
18
- if (!_isAuthEnabled) {
19
- throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
20
- }
21
- const checkApiExists = await (0, _utils.ensureAuthApi)("check");
22
- if (!checkApiExists) {
23
- throw new Error("Auth check API not implemented, please create it in the auth sessions specified directory");
24
- }
25
- const {
26
- authSessionInstanceStoragePath
27
- } = await (0, _utils.retrieveAuthSessionInstance)(authSession, true);
28
- const checkResult = await (0, _utils.runCheckApi)(authSessionInstanceStoragePath);
29
- if (checkResult) {
30
- console.log(_chalk.default.green("✓ Auth session checked successfully"));
31
- } else {
32
- console.log(_chalk.default.red("✗ Auth session is not valid, check failed"));
33
- }
34
- } catch (error) {
35
- console.error(_chalk.default.red(`Failed to check auth session: ${error.message}`));
36
- } finally {
37
- process.exit(0);
38
- }
39
- });
40
- _commander.program.parse(process.argv);
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _utils = require("./utils");
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _utils2 = require("../run-api-cli/utils");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- _dotenv.default.config({
11
- path: `.env`
12
- });
13
- _commander.program.description("Create an auth session").argument("[auth-session-name]", "Name/id of the auth session instance to use (optional)").option("-i, --input <input>", "Auth session input parameters file").action(async (authSessionName, options) => {
14
- try {
15
- const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
16
- if (!_isAuthEnabled) {
17
- throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
18
- }
19
- const authType = await (0, _utils.getAuthType)();
20
- let authSessionInstancePath;
21
- if (authType === "MANUAL") {
22
- const recorderConfig = await (0, _utils.ensureRecorderURLs)();
23
- const {
24
- startUrl,
25
- endUrl
26
- } = recorderConfig;
27
- console.log(_chalk.default.blue("Starting auth session recorder..."));
28
- const session = await (0, _utils.recordAuthSession)(startUrl, endUrl);
29
- authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, authSessionName, {});
30
- } else {
31
- const createApiExists = await (0, _utils.ensureAuthApi)("create");
32
- if (!createApiExists) {
33
- throw new Error("Auth session create API not implemented, please create it in the auth sessions specified directory");
34
- }
35
- const authSessionInput = (await (0, _utils2.loadParameters)(options?.input)) ?? {};
36
- const session = await (0, _utils.runCreateApi)(authSessionInput);
37
- if (!session) {
38
- console.error(_chalk.default.red("Failed to create auth session."));
39
- process.exit(1);
40
- }
41
- authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, authSessionName, authSessionInput);
42
- }
43
- console.log(_chalk.default.green("✓ Auth session created successfully!"));
44
- if (authSessionInstancePath) {
45
- console.log(_chalk.default.underline.green.white(`🔒 Auth session instance and metadata stored at ${authSessionInstancePath}`));
46
- }
47
- } catch (error) {
48
- console.error(_chalk.default.red(`Failed to create auth session: ${error.message}`));
49
- } finally {
50
- process.exit(0);
51
- }
52
- });
53
- _commander.program.parse(process.argv);
@@ -1,28 +0,0 @@
1
- import { StorageState } from "../../common/contextStorageStateHelpers";
2
- import { AuthSessionMetadata, AuthSessionType } from "../../common/cli/types";
3
- import * as playwright from "playwright-core";
4
- export declare function isAuthEnabled(): Promise<boolean>;
5
- export declare function getAuthType(): Promise<AuthSessionType>;
6
- export declare function ensureRecorderURLs(): Promise<{
7
- startUrl: string;
8
- endUrl: string;
9
- }>;
10
- export declare function ensureAuthApi(operation: "create" | "check"): Promise<boolean>;
11
- export declare function runCreateApi(authSessionInput: Record<string, any>): Promise<StorageState>;
12
- export declare function runCheckApi(authSessionPath: string): Promise<boolean>;
13
- export declare function runCreateApiViaCLI(authSessionInput: Record<string, any>): Promise<StorageState>;
14
- export declare function runCheckApiViaCLI(authSessionPath: string): Promise<boolean>;
15
- export declare function storeAuthSessionInstance(authSessionInstance: StorageState, customName?: string, authSessionInput?: Record<string, any>): Promise<string>;
16
- export declare function retrieveAuthSessionInstance(authSessionId: string, pathsOnly?: boolean): Promise<{
17
- authSessionInstanceStoragePath: string;
18
- authSessionInstanceMetadataPath: string;
19
- authSessionInstance?: undefined;
20
- metadata?: undefined;
21
- } | {
22
- authSessionInstance: StorageState;
23
- metadata: AuthSessionMetadata;
24
- authSessionInstanceStoragePath?: undefined;
25
- authSessionInstanceMetadataPath?: undefined;
26
- }>;
27
- export declare function getStorageState(context: playwright.BrowserContext): Promise<StorageState>;
28
- export declare function recordAuthSession(startUrl: string, endUrl: string): Promise<StorageState>;