@intuned/runtime-dev 1.2.0-cli.1 → 1.2.0-cli.10

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 (87) hide show
  1. package/dist/commands/api/run.js +2 -1
  2. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  3. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +1 -1
  4. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  5. package/dist/commands/intuned-cli/commands/build.command.js +1 -1
  6. package/dist/commands/intuned-cli/commands/deploy.command.js +3 -4
  7. package/dist/commands/intuned-cli/commands/init.command.js +1 -1
  8. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  9. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -1
  10. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
  11. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +1 -1
  12. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +1 -1
  13. package/dist/{common/cli/constants.d.ts → commands/intuned-cli/constants/index.d.ts} +2 -4
  14. package/dist/{common/cli/constants.js → commands/intuned-cli/constants/index.js} +22 -5
  15. package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
  16. package/dist/{common/cli/cliReadme.js → commands/intuned-cli/constants/readme.js} +13 -15
  17. package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
  18. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
  19. package/dist/commands/intuned-cli/controller/api.d.ts +25 -0
  20. package/dist/commands/intuned-cli/controller/api.js +35 -36
  21. package/dist/commands/intuned-cli/controller/authSession.d.ts +176 -10
  22. package/dist/commands/intuned-cli/controller/authSession.js +125 -125
  23. package/dist/commands/intuned-cli/controller/build.js +1 -1
  24. package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -1
  25. package/dist/commands/intuned-cli/controller/deploy.js +47 -32
  26. package/dist/commands/intuned-cli/controller/index.js +5 -4
  27. package/dist/commands/intuned-cli/controller/init.d.ts +1 -1
  28. package/dist/commands/intuned-cli/controller/init.js +12 -15
  29. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  30. package/dist/commands/intuned-cli/helpers/api.js +19 -0
  31. package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
  32. package/dist/commands/intuned-cli/helpers/auth.js +129 -0
  33. package/dist/{common/cli/utils.d.ts → commands/intuned-cli/helpers/backend.d.ts} +0 -1
  34. package/dist/commands/intuned-cli/helpers/backend.js +26 -0
  35. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  36. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  37. package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
  38. package/dist/commands/intuned-cli/helpers/errors.js +55 -0
  39. package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
  40. package/dist/commands/intuned-cli/helpers/index.js +115 -0
  41. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
  42. package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -20
  43. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  44. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  45. package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  46. package/dist/commands/intuned-cli/{terminal.js → helpers/terminal.js} +3 -2
  47. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  48. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  49. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  50. package/dist/commands/intuned-cli/helpers/validation.js +12 -0
  51. package/dist/commands/intuned-cli/main.js +4 -1
  52. package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -32
  53. package/dist/common/runApi/types.d.ts +140 -9
  54. package/dist/common/runApi/types.js +28 -27
  55. package/package.json +2 -7
  56. package/tsconfig.json +2 -1
  57. package/bin/check-auth-session +0 -3
  58. package/bin/cli-build +0 -3
  59. package/bin/create-auth-session +0 -3
  60. package/bin/deploy +0 -3
  61. package/bin/init +0 -3
  62. package/bin/run-api +0 -3
  63. package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
  64. package/dist/commands/cli-auth-sessions/check.js +0 -40
  65. package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
  66. package/dist/commands/cli-auth-sessions/create.js +0 -53
  67. package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
  68. package/dist/commands/cli-auth-sessions/utils.js +0 -284
  69. package/dist/commands/cli-build/cli-build.d.ts +0 -2
  70. package/dist/commands/cli-build/cli-build.js +0 -20
  71. package/dist/commands/deploy/deploy.d.ts +0 -2
  72. package/dist/commands/deploy/deploy.js +0 -47
  73. package/dist/commands/deploy/utils.d.ts +0 -16
  74. package/dist/commands/deploy/utils.js +0 -407
  75. package/dist/commands/init/init.d.ts +0 -2
  76. package/dist/commands/init/init.js +0 -22
  77. package/dist/commands/init/utils.d.ts +0 -11
  78. package/dist/commands/init/utils.js +0 -175
  79. package/dist/commands/intuned-cli/commands/helpers.d.ts +0 -26
  80. package/dist/commands/intuned-cli/commands/helpers.js +0 -134
  81. package/dist/commands/intuned-cli/terminal.d.ts +0 -1
  82. package/dist/commands/run-api-cli/run-api.d.ts +0 -2
  83. package/dist/commands/run-api-cli/run-api.js +0 -57
  84. package/dist/commands/run-api-cli/utils.d.ts +0 -9
  85. package/dist/commands/run-api-cli/utils.js +0 -144
  86. package/dist/common/cli/cliReadme.d.ts +0 -1
  87. /package/dist/{common/cli → commands/intuned-cli}/types.js +0 -0
@@ -1,3 +1,5 @@
1
+ import { Payload } from "../../../runtime/export";
2
+ import { RunApiStorageState } from "../../../common/runApi";
1
3
  import type { BaseCommandOptions } from "../commands/types";
2
4
  export declare function executeRunApiCLI({ apiName, inputData, retries, authSession, outputFile, ...rest }: {
3
5
  apiName: string;
@@ -17,3 +19,26 @@ export declare function executeAttemptApiCLI({ apiName, inputData, authSessionId
17
19
  authSessionId?: string;
18
20
  outputFile?: string;
19
21
  } & BaseCommandOptions): Promise<void>;
22
+ declare function handleApiResult({ apiResult, outputFile, }: {
23
+ apiResult: {
24
+ result: any;
25
+ payloadToAppend?: Payload[];
26
+ };
27
+ outputFile?: string;
28
+ }): Promise<void>;
29
+ export declare const _handleApiResult: typeof handleApiResult;
30
+ declare function writeResultToFile(outputFile: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
31
+ export declare const _writeResultToFile: typeof writeResultToFile;
32
+ declare function attemptApi({ apiName, inputData, auth, proxy, headless, timeout, }: {
33
+ apiName: string;
34
+ inputData: object | null | undefined;
35
+ auth?: RunApiStorageState;
36
+ proxy?: string | undefined;
37
+ headless: boolean;
38
+ timeout: number;
39
+ }): Promise<{
40
+ result: any;
41
+ payloadToAppend: Payload[] | undefined;
42
+ }>;
43
+ export declare const _attemptApi: typeof attemptApi;
44
+ export {};
@@ -3,15 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports._writeResultToFile = exports._handleApiResult = exports._attemptApi = void 0;
6
7
  exports.executeAttemptApiCLI = executeAttemptApiCLI;
7
8
  exports.executeRunApiCLI = executeRunApiCLI;
8
9
  var fs = _interopRequireWildcard(require("fs-extra"));
9
10
  var _runApi = require("../../../common/runApi");
10
11
  var _tsNodeImport = require("../../common/tsNodeImport");
11
12
  var _authSession = require("./authSession");
12
- var _utils = require("../../cli-auth-sessions/utils");
13
- var _helpers = require("../commands/helpers");
14
- var _terminal = require("../terminal");
13
+ var _helpers = require("../helpers");
14
+ var _terminal = require("../helpers/terminal");
15
15
  var _constants = require("../../../common/constants");
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -24,15 +24,15 @@ async function executeRunApiCLI({
24
24
  ...rest
25
25
  }) {
26
26
  await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
27
+ (0, _helpers.registerGetAuthSessionParameters)(authSession?.id);
27
28
  (0, _terminal.terminal)(`^+Running API ^c${apiName}^:\n`);
28
- const apiResult = await (0, _helpers.withCLIContext)(async () => {
29
+ const apiResult = await (async () => {
29
30
  for (let i = 0; i < retries; i++) {
30
31
  (0, _terminal.terminal)(`\n^+Executing ^c${apiName} ^/(Attempt ${i + 1}) ^:...\n`);
31
- let authSessionPathToUse;
32
+ let auth;
32
33
  if (authSession) {
33
- authSessionPathToUse = await (0, _authSession.executeRunValidateAuthSessionCLI)({
34
+ auth = await (0, _authSession.executeRunValidateAuthSessionCLI)({
34
35
  ...authSession,
35
- useExistingContext: true,
36
36
  ...rest
37
37
  });
38
38
  }
@@ -40,18 +40,13 @@ async function executeRunApiCLI({
40
40
  return await attemptApi({
41
41
  apiName,
42
42
  inputData,
43
- auth: authSessionPathToUse ? {
44
- session: {
45
- type: "file",
46
- path: authSessionPathToUse
47
- },
48
- runCheck: false
49
- } : undefined,
43
+ auth,
50
44
  ...rest
51
45
  });
52
46
  } catch (error) {
53
47
  if (error instanceof _runApi.AutomationError) {
54
- (0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed ^:^+${apiName}^:: ^R${error.error.message}^:\n`);
48
+ (0, _helpers.logAutomationError)(error);
49
+ (0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed^:\n`);
55
50
  continue;
56
51
  }
57
52
  throw error;
@@ -77,30 +72,27 @@ async function executeAttemptApiCLI({
77
72
  }) {
78
73
  (0, _terminal.terminal)(`^+Execute API attempt for ^c${apiName}^:\n`);
79
74
  await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
80
- let authSessionInstance;
75
+ (0, _helpers.registerGetAuthSessionParameters)(authSessionId);
76
+ let storageState;
81
77
  if (authSessionId) {
82
78
  ({
83
- authSessionInstance
84
- } = await (0, _utils.retrieveAuthSessionInstance)(authSessionId));
79
+ storageState
80
+ } = await (0, _helpers.loadAuthSessionInstance)(authSessionId));
85
81
  }
86
82
  return await (0, _helpers.withCLIContext)(async () => {
87
83
  const apiResult = await attemptApi({
88
84
  apiName,
89
85
  inputData,
90
- auth: authSessionInstance ? {
91
- session: {
92
- type: "state",
93
- state: authSessionInstance
94
- },
95
- runCheck: false
96
- } : undefined,
86
+ auth: storageState,
97
87
  ...rest
98
88
  });
99
89
  return await handleApiResult({
100
90
  apiResult,
101
91
  outputFile
102
92
  });
103
- })();
93
+ }, {
94
+ authSessionId
95
+ });
104
96
  }
105
97
  async function handleApiResult({
106
98
  apiResult,
@@ -126,6 +118,7 @@ async function handleApiResult({
126
118
  }
127
119
  await writeResultToFile(outputFile, result, payloadToAppend);
128
120
  }
121
+ const _handleApiResult = exports._handleApiResult = handleApiResult;
129
122
  async function writeResultToFile(outputFile, result, payloadToAppend) {
130
123
  const resultToWrite = {
131
124
  result
@@ -142,6 +135,7 @@ async function writeResultToFile(outputFile, result, payloadToAppend) {
142
135
  throw new _helpers.CLIError(`Failed to write result to file: ${error.message}`);
143
136
  }
144
137
  }
138
+ const _writeResultToFile = exports._writeResultToFile = writeResultToFile;
145
139
  async function attemptApi({
146
140
  apiName,
147
141
  inputData,
@@ -150,10 +144,10 @@ async function attemptApi({
150
144
  headless,
151
145
  timeout
152
146
  }) {
153
- return await (0, _helpers.withTimeout)(async () => {
147
+ return await (0, _helpers.withTimeout)(async abortSignal => {
154
148
  const runApiResult = await (0, _runApi.runApi)({
155
149
  automationFunction: {
156
- name: `api/${apiName}`,
150
+ name: `${_constants.API_FOLDER_NAME}/${apiName}`,
157
151
  params: inputData
158
152
  },
159
153
  runOptions: {
@@ -161,14 +155,18 @@ async function attemptApi({
161
155
  environment: "standalone",
162
156
  proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
163
157
  },
164
- auth,
165
- importFunction: _tsNodeImport.tsNodeImport
158
+ auth: auth ? {
159
+ session: {
160
+ type: "state",
161
+ state: auth
162
+ },
163
+ runCheck: false
164
+ } : undefined,
165
+ importFunction: _tsNodeImport.tsNodeImport,
166
+ abortSignal
166
167
  });
167
168
  if (runApiResult.isErr()) {
168
- if (runApiResult.error instanceof _runApi.AutomationError) {
169
- throw runApiResult.error;
170
- }
171
- throw new _helpers.CLIError(`An error occurred while running the API: ${runApiResult.error.message}`);
169
+ throw runApiResult.error;
172
170
  }
173
171
  const {
174
172
  result,
@@ -178,5 +176,6 @@ async function attemptApi({
178
176
  result,
179
177
  payloadToAppend
180
178
  };
181
- }, timeout)();
182
- }
179
+ }, timeout);
180
+ }
181
+ const _attemptApi = exports._attemptApi = attemptApi;
@@ -1,32 +1,198 @@
1
1
  import type { BaseCommandOptions } from "../commands/types";
2
- import { StorageState } from "../../../common/contextStorageStateHelpers";
3
- export declare function executeRunValidateAuthSessionCLI({ id, autoRecreate, checkRetries, createRetries, useExistingContext, ...rest }: {
2
+ import { RunApiStorageState } from "../../../common/runApi";
3
+ export declare function executeRunValidateAuthSessionCLI({ id, autoRecreate, checkRetries, createRetries, ...rest }: {
4
4
  id: string;
5
5
  autoRecreate: boolean;
6
6
  checkRetries: number;
7
7
  createRetries: number;
8
- useExistingContext?: boolean;
9
- } & BaseCommandOptions): Promise<string>;
8
+ } & BaseCommandOptions): Promise<RunApiStorageState>;
10
9
  export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries, createRetries, log, ...rest }: {
11
10
  id?: string;
12
11
  input: any;
13
12
  checkRetries: number;
14
13
  createRetries: number;
15
14
  log?: boolean;
16
- } & BaseCommandOptions): Promise<string>;
15
+ } & BaseCommandOptions): Promise<{
16
+ cookies: {
17
+ value: string;
18
+ name: string;
19
+ path: string;
20
+ domain: string;
21
+ expires: number;
22
+ httpOnly: boolean;
23
+ secure: boolean;
24
+ sameSite: "Strict" | "Lax" | "None";
25
+ }[];
26
+ origins: {
27
+ origin: string;
28
+ localStorage: {
29
+ value: string;
30
+ name: string;
31
+ }[];
32
+ }[];
33
+ sessionStorage?: {
34
+ sessionStorage: {
35
+ value: string;
36
+ name: string;
37
+ }[];
38
+ origin: string;
39
+ }[] | undefined;
40
+ }>;
17
41
  export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries, createRetries, ...rest }: {
18
42
  id: string;
19
43
  input?: any;
20
44
  checkRetries: number;
21
45
  createRetries: number;
22
- } & BaseCommandOptions): Promise<string>;
46
+ } & BaseCommandOptions): Promise<{
47
+ cookies: {
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
+ }[];
57
+ origins: {
58
+ origin: string;
59
+ localStorage: {
60
+ value: string;
61
+ name: string;
62
+ }[];
63
+ }[];
64
+ sessionStorage?: {
65
+ sessionStorage: {
66
+ value: string;
67
+ name: string;
68
+ }[];
69
+ origin: string;
70
+ }[] | undefined;
71
+ }>;
23
72
  export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest }: {
24
73
  id?: string;
25
74
  input: any;
26
- } & BaseCommandOptions): Promise<string>;
75
+ } & BaseCommandOptions): Promise<{
76
+ cookies: {
77
+ value: string;
78
+ name: string;
79
+ path: string;
80
+ domain: string;
81
+ expires: number;
82
+ httpOnly: boolean;
83
+ secure: boolean;
84
+ sameSite: "Strict" | "Lax" | "None";
85
+ }[];
86
+ origins: {
87
+ origin: string;
88
+ localStorage: {
89
+ value: string;
90
+ name: string;
91
+ }[];
92
+ }[];
93
+ sessionStorage?: {
94
+ sessionStorage: {
95
+ value: string;
96
+ name: string;
97
+ }[];
98
+ origin: string;
99
+ }[] | undefined;
100
+ }>;
27
101
  export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
28
102
  id: string;
29
- } & BaseCommandOptions): Promise<string>;
30
- export declare function runCreate({ authSessionInput, proxy, headless, timeout, }: {
103
+ } & BaseCommandOptions): Promise<{
104
+ cookies: {
105
+ value: string;
106
+ name: string;
107
+ path: string;
108
+ domain: string;
109
+ expires: number;
110
+ httpOnly: boolean;
111
+ secure: boolean;
112
+ sameSite: "Strict" | "Lax" | "None";
113
+ }[];
114
+ origins: {
115
+ origin: string;
116
+ localStorage: {
117
+ value: string;
118
+ name: string;
119
+ }[];
120
+ }[];
121
+ sessionStorage?: {
122
+ sessionStorage: {
123
+ value: string;
124
+ name: string;
125
+ }[];
126
+ origin: string;
127
+ }[] | undefined;
128
+ }>;
129
+ declare function runCheck({ auth, proxy, headless, timeout, }: {
130
+ auth: RunApiStorageState;
131
+ } & BaseCommandOptions): Promise<boolean>;
132
+ export declare const _runCheck: typeof runCheck;
133
+ declare function runCreate({ authSessionInput, proxy, headless, timeout, }: {
31
134
  authSessionInput: Record<string, any>;
32
- } & BaseCommandOptions): Promise<StorageState>;
135
+ } & BaseCommandOptions): Promise<{
136
+ cookies: {
137
+ value: string;
138
+ name: string;
139
+ path: string;
140
+ domain: string;
141
+ expires: number;
142
+ httpOnly: boolean;
143
+ secure: boolean;
144
+ sameSite: "Strict" | "Lax" | "None";
145
+ }[];
146
+ origins: {
147
+ origin: string;
148
+ localStorage: {
149
+ value: string;
150
+ name: string;
151
+ }[];
152
+ }[];
153
+ sessionStorage?: {
154
+ sessionStorage: {
155
+ value: string;
156
+ name: string;
157
+ }[];
158
+ origin: string;
159
+ }[] | undefined;
160
+ }>;
161
+ export declare const _runCreate: typeof runCreate;
162
+ declare function runCheckWithRetries({ auth, retries, ...rest }: {
163
+ auth: RunApiStorageState;
164
+ retries: number;
165
+ } & BaseCommandOptions): Promise<boolean>;
166
+ export declare const _runCheckWithRetries: typeof runCheckWithRetries;
167
+ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries, ...rest }: {
168
+ authSessionId: string;
169
+ authSessionInput: any;
170
+ retries: number;
171
+ } & BaseCommandOptions): Promise<{
172
+ cookies: {
173
+ value: string;
174
+ name: string;
175
+ path: string;
176
+ domain: string;
177
+ expires: number;
178
+ httpOnly: boolean;
179
+ secure: boolean;
180
+ sameSite: "Strict" | "Lax" | "None";
181
+ }[];
182
+ origins: {
183
+ origin: string;
184
+ localStorage: {
185
+ value: string;
186
+ name: string;
187
+ }[];
188
+ }[];
189
+ sessionStorage?: {
190
+ sessionStorage: {
191
+ value: string;
192
+ name: string;
193
+ }[];
194
+ origin: string;
195
+ }[] | undefined;
196
+ }>;
197
+ export declare const _runCreateWithRetries: typeof runCreateWithRetries;
198
+ export {};