@intuned/runtime-dev 1.3.4-dev.4 → 1.3.4-enhancements.1

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 (70) hide show
  1. package/WebTemplate.zip +0 -0
  2. package/bin/intuned +0 -0
  3. package/dist/commands/api/run.js +1 -2
  4. package/dist/commands/auth-sessions/run-check.js +0 -1
  5. package/dist/commands/auth-sessions/run-create.js +0 -1
  6. package/dist/commands/common/projectExclusions.js +1 -1
  7. package/dist/commands/common/tsNodeImport.js +1 -1
  8. package/dist/commands/common/utils/settings.js +5 -7
  9. package/dist/commands/intuned-cli/commands/attempt_api.command.js +10 -20
  10. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -7
  11. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +5 -17
  12. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
  13. package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
  14. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
  15. package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
  16. package/dist/commands/intuned-cli/commands/build.command.js +1 -1
  17. package/dist/commands/intuned-cli/commands/deploy.command.js +2 -7
  18. package/dist/commands/intuned-cli/commands/index.d.ts +2 -0
  19. package/dist/commands/intuned-cli/commands/index.js +22 -0
  20. package/dist/commands/intuned-cli/commands/init.command.js +1 -1
  21. package/dist/commands/intuned-cli/commands/run_api.command.js +13 -21
  22. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +9 -1
  23. package/dist/commands/intuned-cli/commands/run_authsession.command.js +5 -1
  24. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -1
  25. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +16 -20
  26. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -1
  27. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +16 -20
  28. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -1
  29. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +16 -20
  30. package/dist/commands/intuned-cli/commands/save.command.d.ts +3 -2
  31. package/dist/commands/intuned-cli/commands/save.command.js +6 -10
  32. package/dist/commands/intuned-cli/commands/types.d.ts +10 -0
  33. package/dist/commands/intuned-cli/commands/types.js +11 -3
  34. package/dist/commands/intuned-cli/controller/__test__/api.test.js +128 -10
  35. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +428 -45
  36. package/dist/commands/intuned-cli/controller/api.d.ts +5 -7
  37. package/dist/commands/intuned-cli/controller/api.js +16 -7
  38. package/dist/commands/intuned-cli/controller/authSession.d.ts +18 -7
  39. package/dist/commands/intuned-cli/controller/authSession.js +153 -24
  40. package/dist/commands/intuned-cli/controller/save.js +10 -3
  41. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
  42. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
  43. package/dist/commands/intuned-cli/helpers/auth.d.ts +7 -2
  44. package/dist/commands/intuned-cli/helpers/auth.js +38 -23
  45. package/dist/commands/intuned-cli/helpers/backend.d.ts +1 -1
  46. package/dist/commands/intuned-cli/helpers/backend.js +2 -2
  47. package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
  48. package/dist/commands/intuned-cli/helpers/browser.js +57 -0
  49. package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -1
  50. package/dist/commands/intuned-cli/helpers/errors.js +0 -22
  51. package/dist/commands/intuned-cli/helpers/index.d.ts +2 -0
  52. package/dist/commands/intuned-cli/helpers/index.js +22 -0
  53. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -1
  54. package/dist/commands/intuned-cli/helpers/intunedJson.js +59 -7
  55. package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
  56. package/dist/commands/intuned-cli/helpers/traces.js +32 -0
  57. package/dist/commands/intuned-cli/helpers/validation.js +5 -3
  58. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
  59. package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
  60. package/dist/common/constants.d.ts +0 -1
  61. package/dist/common/constants.js +1 -2
  62. package/dist/common/playwrightContext.d.ts +1 -0
  63. package/dist/common/playwrightContext.js +5 -18
  64. package/dist/common/runApi/types.d.ts +0 -5
  65. package/dist/common/runApi/types.js +1 -2
  66. package/dist/common/settingsSchema.d.ts +0 -513
  67. package/dist/common/settingsSchema.js +2 -40
  68. package/package.json +4 -1
  69. package/dist/common/extensionsHelpers.d.ts +0 -15
  70. package/dist/common/extensionsHelpers.js +0 -84
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.saveOrDeployCommandSchema = exports.saveCommand = void 0;
6
+ exports.saveOrDeployOptionsSchema = exports.saveOrDeployArgsSchema = exports.saveCommand = void 0;
7
7
  var _command = require("./command");
8
8
  var _dotenv = _interopRequireDefault(require("dotenv"));
9
9
  var _save = require("../controller/save");
@@ -13,16 +13,12 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
13
13
  _dotenv.default.config({
14
14
  path: `.env`
15
15
  });
16
- const saveOrDeployCommandSchema = exports.saveOrDeployCommandSchema = _zod.z.tuple([_zod.z.union([_zod.z.string(), _zod.z.undefined()]), _zod.z.object({
16
+ const saveOrDeployArgsSchema = exports.saveOrDeployArgsSchema = _zod.z.tuple([_zod.z.union([_zod.z.string(), _zod.z.undefined()])]);
17
+ const saveOrDeployOptionsSchema = exports.saveOrDeployOptionsSchema = _zod.z.object({
17
18
  workspaceId: _zod.z.string().optional(),
18
19
  apiKey: _zod.z.string().optional()
19
- })]);
20
- const saveCommand = exports.saveCommand = _command.program.command("save").description("Save an Intuned project to the platform without deploying it").argument("[project-name]", "Name of the project to save").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action((0, _helpers.withErrorLogging)(async (inputProjectName, inputOptions) => {
21
- const parseResult = saveOrDeployCommandSchema.safeParse([inputProjectName, inputOptions]);
22
- if (!parseResult.success) {
23
- return (0, _helpers.logInvalidInput)(parseResult);
24
- }
25
- const [projectName, options] = parseResult.data;
20
+ });
21
+ const saveCommand = exports.saveCommand = _command.program.command("save").description("Save an Intuned project to the platform without deploying it").argument("[project-name]", "Name of the project to save").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action((0, _helpers.cliCommandWrapper)(saveOrDeployArgsSchema, saveOrDeployOptionsSchema, async ([projectName], options) => {
26
22
  const {
27
23
  isValid,
28
24
  errorMessage
@@ -33,7 +29,7 @@ const saveCommand = exports.saveCommand = _command.program.command("save").descr
33
29
  autoColor: false
34
30
  });
35
31
  }
36
- const _projectName = projectName || (await (0, _helpers.getSettingIntunedJSON)("projectName"));
32
+ const _projectName = projectName || (await (0, _helpers.loadIntunedJson)()).projectName;
37
33
  if (!_projectName) {
38
34
  throw new _helpers.CLIError("Project name is required");
39
35
  }
@@ -1,3 +1,4 @@
1
+ import { Command } from "commander";
1
2
  import ms from "ms";
2
3
  import { z } from "zod";
3
4
  export declare const authSessionCheckAttemptsSchema: z.ZodDefault<z.ZodNumber>;
@@ -5,17 +6,26 @@ export declare const authSessionCreateAttemptsSchema: z.ZodDefault<z.ZodNumber>;
5
6
  export declare const proxySchema: z.ZodOptional<z.ZodString>;
6
7
  export declare const timeoutSchema: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodString>, ms.StringValue, string | undefined>, number, string | undefined>;
7
8
  export declare const headlessSchema: z.ZodDefault<z.ZodBoolean>;
9
+ export declare const traceSchema: z.ZodDefault<z.ZodBoolean>;
10
+ export declare const keepBrowserOpenSchema: z.ZodDefault<z.ZodBoolean>;
8
11
  export declare const baseCommandOptionsSchema: z.ZodObject<{
9
12
  proxy: z.ZodOptional<z.ZodString>;
10
13
  timeout: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodString>, ms.StringValue, string | undefined>, number, string | undefined>;
11
14
  headless: z.ZodDefault<z.ZodBoolean>;
15
+ trace: z.ZodDefault<z.ZodBoolean>;
16
+ keepBrowserOpen: z.ZodDefault<z.ZodBoolean>;
12
17
  }, "strip", z.ZodTypeAny, {
13
18
  headless: boolean;
19
+ keepBrowserOpen: boolean;
14
20
  timeout: number;
21
+ trace: boolean;
15
22
  proxy?: string | undefined;
16
23
  }, {
17
24
  proxy?: string | undefined;
18
25
  timeout?: string | undefined;
19
26
  headless?: boolean | undefined;
27
+ trace?: boolean | undefined;
28
+ keepBrowserOpen?: boolean | undefined;
20
29
  }>;
21
30
  export type BaseCommandOptions = z.infer<typeof baseCommandOptionsSchema>;
31
+ export declare function withBaseOptions(command: Command): Command;
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.timeoutSchema = exports.proxySchema = exports.headlessSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
6
+ exports.traceSchema = exports.timeoutSchema = exports.proxySchema = exports.keepBrowserOpenSchema = exports.headlessSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
7
+ exports.withBaseOptions = withBaseOptions;
7
8
  var _ms = _interopRequireDefault(require("ms"));
8
9
  var _zod = require("zod");
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -14,8 +15,15 @@ const timeoutSchema = exports.timeoutSchema = _zod.z.string().default("10 mins")
14
15
  return (0, _ms.default)(val) !== undefined;
15
16
  }, "--timeout must be a valid integer or ms-formatted string").transform(val => (0, _ms.default)(val));
16
17
  const headlessSchema = exports.headlessSchema = _zod.z.boolean().default(false);
18
+ const traceSchema = exports.traceSchema = _zod.z.boolean().default(false);
19
+ const keepBrowserOpenSchema = exports.keepBrowserOpenSchema = _zod.z.boolean().default(false);
17
20
  const baseCommandOptionsSchema = exports.baseCommandOptionsSchema = _zod.z.object({
18
21
  proxy: proxySchema,
19
22
  timeout: timeoutSchema,
20
- headless: headlessSchema
21
- });
23
+ headless: headlessSchema,
24
+ trace: traceSchema,
25
+ keepBrowserOpen: keepBrowserOpenSchema
26
+ });
27
+ function withBaseOptions(command) {
28
+ return command.option("--proxy <url>", "Proxy URL to use for browser").option("--timeout <time>", "Timeout for each attempt - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the attempts in a headless browser (default: false). This will not open a browser window.").option("--trace", "Capture a trace of each attempt, useful for debugging.").option("--keep-browser-open", "Keep the last browser open after the command completes, useful for debugging.");
29
+ }
@@ -7,6 +7,7 @@ var _helpers = require("../../helpers");
7
7
  var _neverthrow = require("neverthrow");
8
8
  var _runApi = require("../../../../common/runApi");
9
9
  var _fsExtra = require("fs-extra");
10
+ var _browser = require("../../helpers/browser");
10
11
  function getTerminal() {
11
12
  return new Proxy(() => ({}), {
12
13
  get: () => getTerminal(),
@@ -14,7 +15,8 @@ function getTerminal() {
14
15
  });
15
16
  }
16
17
  _vitest.vi.mock("fs-extra", () => ({
17
- writeJSON: _vitest.vi.fn()
18
+ writeJSON: _vitest.vi.fn(),
19
+ exists: _vitest.vi.fn().mockResolvedValue(true)
18
20
  }));
19
21
  _vitest.vi.mock("../authSession", async importOriginal => {
20
22
  const original = await importOriginal();
@@ -33,6 +35,23 @@ _vitest.vi.mock("../../../../common/runApi", async importOriginal => {
33
35
  _vitest.vi.mock("../../helpers/terminal", () => ({
34
36
  terminal: getTerminal()
35
37
  }));
38
+ _vitest.vi.mock("../../helpers/proxy", async () => {
39
+ return {
40
+ parseUrlProxy: _vitest.vi.fn()
41
+ };
42
+ });
43
+ _vitest.vi.mock("../../helpers/browser", async importOriginal => {
44
+ const original = await importOriginal();
45
+ return {
46
+ getCLIRunOptions: _vitest.vi.fn(({
47
+ keepBrowserOpen: _,
48
+ ...rest
49
+ }) => original.getCLIRunOptions({
50
+ keepBrowserOpen: false,
51
+ ...rest
52
+ }))
53
+ };
54
+ });
36
55
  _vitest.vi.mock("../../helpers", async importOriginal => {
37
56
  const original = await importOriginal();
38
57
  return {
@@ -41,7 +60,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
41
60
  assertApiFileExists: _vitest.vi.fn(),
42
61
  withCLIContext: _vitest.vi.fn(fn => fn()),
43
62
  withTimeout: _vitest.vi.fn(fn => fn()),
44
- parseUrlProxy: _vitest.vi.fn(),
63
+ withCLITrace: _vitest.vi.fn(original.withCLITrace),
45
64
  registerGetAuthSessionParameters: _vitest.vi.fn()
46
65
  };
47
66
  });
@@ -55,10 +74,58 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
55
74
  apiName: "testApi",
56
75
  inputData: {},
57
76
  headless: false,
58
- timeout: 6000
77
+ timeout: 6000,
78
+ keepBrowserOpen: false
59
79
  });
60
80
  (0, _vitest.expect)(_helpers.withTimeout).toHaveBeenCalledWith(_vitest.expect.any(Function), 6000);
61
81
  });
82
+ (0, _vitest.it)("uses tracing wrapper with trace id", async () => {
83
+ await (0, _api._attemptApi)({
84
+ apiName: "testApi",
85
+ inputData: {},
86
+ headless: false,
87
+ timeout: 6000,
88
+ keepBrowserOpen: false
89
+ });
90
+ (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), undefined);
91
+ _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
92
+ _vitest.vi.mocked(_runApi.runApi).mockClear();
93
+ await (0, _api._attemptApi)({
94
+ apiName: "testApi",
95
+ inputData: {},
96
+ headless: false,
97
+ timeout: 6000,
98
+ keepBrowserOpen: false,
99
+ traceId: "trace-id"
100
+ });
101
+ (0, _vitest.expect)(_helpers.withCLITrace).toHaveBeenCalledWith(_vitest.expect.any(Function), "trace-id");
102
+ });
103
+ (0, _vitest.it)("uses cli browser helper", async () => {
104
+ await (0, _api._attemptApi)({
105
+ apiName: "testApi",
106
+ inputData: {},
107
+ headless: false,
108
+ timeout: 6000,
109
+ keepBrowserOpen: false
110
+ });
111
+ (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
112
+ headless: false,
113
+ keepBrowserOpen: false
114
+ }));
115
+ _vitest.vi.mocked(_helpers.withCLITrace).mockClear();
116
+ _vitest.vi.mocked(_runApi.runApi).mockClear();
117
+ await (0, _api._attemptApi)({
118
+ apiName: "testApi",
119
+ inputData: {},
120
+ headless: true,
121
+ timeout: 6000,
122
+ keepBrowserOpen: true
123
+ });
124
+ (0, _vitest.expect)(_browser.getCLIRunOptions).toHaveBeenCalledWith(_vitest.expect.objectContaining({
125
+ headless: true,
126
+ keepBrowserOpen: true
127
+ }));
128
+ });
62
129
  (0, _vitest.it)("calls runApi with correct parameters and parses proxy", async () => {
63
130
  _vitest.vi.mocked(_helpers.parseUrlProxy).mockReturnValueOnce("parsed-proxy");
64
131
  await (0, _api._attemptApi)({
@@ -67,7 +134,8 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
67
134
  headless: "headless",
68
135
  auth: "auth",
69
136
  proxy: "proxy",
70
- timeout: 999999999
137
+ timeout: 999999999,
138
+ keepBrowserOpen: false
71
139
  });
72
140
  (0, _vitest.expect)(_helpers.parseUrlProxy).toHaveBeenCalledWith("proxy");
73
141
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
@@ -99,7 +167,8 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
99
167
  inputData: "inputData",
100
168
  headless: "headless",
101
169
  auth: "auth",
102
- timeout: 999999999
170
+ timeout: 999999999,
171
+ keepBrowserOpen: false
103
172
  });
104
173
  (0, _vitest.expect)(result).toEqual({
105
174
  result: "result",
@@ -114,11 +183,37 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
114
183
  inputData: "inputData",
115
184
  headless: "headless",
116
185
  auth: "auth",
117
- timeout: 999999999
186
+ timeout: 999999999,
187
+ keepBrowserOpen: false
118
188
  })).rejects.toThrow(error);
119
189
  });
120
190
  });
121
191
  (0, _vitest.describe)("executeRunApiCLI", () => {
192
+ (0, _vitest.it)("enables tracing correctly", async () => {
193
+ await (0, _api.executeRunApiCLI)({
194
+ apiName: "testApi",
195
+ inputData: {},
196
+ retries: 1,
197
+ trace: false
198
+ });
199
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
200
+ tracing: {
201
+ enabled: false
202
+ }
203
+ }));
204
+ _vitest.vi.mocked(_runApi.runApi).mockClear();
205
+ await (0, _api.executeRunApiCLI)({
206
+ apiName: "testApi",
207
+ inputData: {},
208
+ retries: 1,
209
+ trace: true
210
+ });
211
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
212
+ tracing: _vitest.expect.objectContaining({
213
+ enabled: true
214
+ })
215
+ }));
216
+ });
122
217
  (0, _vitest.it)("calls attemptApi once if success", async () => {
123
218
  await (0, _api.executeRunApiCLI)({
124
219
  apiName: "testApi",
@@ -172,12 +267,12 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
172
267
  retries: 10
173
268
  });
174
269
  (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toBeCalledTimes(2);
175
- (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith({
270
+ (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith(_vitest.expect.objectContaining({
176
271
  id: "authSessionId",
177
272
  autoRecreate: false,
178
273
  checkRetries: 1,
179
274
  createRetries: 2
180
- });
275
+ }));
181
276
  });
182
277
  (0, _vitest.it)("doesn't validate auth session if not provided", async () => {
183
278
  _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.ok)({
@@ -203,12 +298,12 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
203
298
  },
204
299
  retries: 10
205
300
  })).rejects.toThrow("Auth session validation failed");
206
- (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith({
301
+ (0, _vitest.expect)(_authSession.executeRunValidateAuthSessionCLI).toHaveBeenCalledWith(_vitest.expect.objectContaining({
207
302
  id: "authSessionId",
208
303
  autoRecreate: false,
209
304
  checkRetries: 1,
210
305
  createRetries: 2
211
- });
306
+ }));
212
307
  (0, _vitest.expect)(_runApi.runApi).not.toHaveBeenCalled();
213
308
  });
214
309
  (0, _vitest.it)("writes result to file if outputFile is provided", async () => {
@@ -237,6 +332,29 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
237
332
  });
238
333
  });
239
334
  (0, _vitest.describe)("executeAttemptApiCLI", () => {
335
+ (0, _vitest.it)("enables tracing correctly", async () => {
336
+ await (0, _api.executeAttemptApiCLI)({
337
+ apiName: "testApi",
338
+ inputData: {},
339
+ trace: false
340
+ });
341
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
342
+ tracing: {
343
+ enabled: false
344
+ }
345
+ }));
346
+ _vitest.vi.mocked(_runApi.runApi).mockClear();
347
+ await (0, _api.executeAttemptApiCLI)({
348
+ apiName: "testApi",
349
+ inputData: {},
350
+ trace: true
351
+ });
352
+ (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledWith(_vitest.expect.objectContaining({
353
+ tracing: _vitest.expect.objectContaining({
354
+ enabled: true
355
+ })
356
+ }));
357
+ });
240
358
  (0, _vitest.it)("calls attemptApi once", async () => {
241
359
  await (0, _api.executeAttemptApiCLI)({
242
360
  apiName: "testApi",