@intuned/runtime-dev 1.2.0-cli.0 → 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 +40 -38
  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 -126
  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,16 @@ 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
- (0, _terminal.terminal)(`^r^+Failed to run API ^:^+${apiName}^:: ^R${error.message}^:\n`);
54
- continue;
47
+ if (error instanceof _runApi.AutomationError) {
48
+ (0, _helpers.logAutomationError)(error);
49
+ (0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed^:\n`);
50
+ continue;
51
+ }
52
+ throw error;
55
53
  }
56
54
  }
57
55
  })();
@@ -74,30 +72,27 @@ async function executeAttemptApiCLI({
74
72
  }) {
75
73
  (0, _terminal.terminal)(`^+Execute API attempt for ^c${apiName}^:\n`);
76
74
  await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
77
- let authSessionInstance;
75
+ (0, _helpers.registerGetAuthSessionParameters)(authSessionId);
76
+ let storageState;
78
77
  if (authSessionId) {
79
78
  ({
80
- authSessionInstance
81
- } = await (0, _utils.retrieveAuthSessionInstance)(authSessionId));
79
+ storageState
80
+ } = await (0, _helpers.loadAuthSessionInstance)(authSessionId));
82
81
  }
83
82
  return await (0, _helpers.withCLIContext)(async () => {
84
83
  const apiResult = await attemptApi({
85
84
  apiName,
86
85
  inputData,
87
- auth: authSessionInstance ? {
88
- session: {
89
- type: "state",
90
- state: authSessionInstance
91
- },
92
- runCheck: false
93
- } : undefined,
86
+ auth: storageState,
94
87
  ...rest
95
88
  });
96
89
  return await handleApiResult({
97
90
  apiResult,
98
91
  outputFile
99
92
  });
100
- })();
93
+ }, {
94
+ authSessionId
95
+ });
101
96
  }
102
97
  async function handleApiResult({
103
98
  apiResult,
@@ -116,13 +111,14 @@ async function handleApiResult({
116
111
  (0, _terminal.terminal)(`${JSON.stringify(result, null, 2)}\n`);
117
112
  }
118
113
  if (payloadToAppend && payloadToAppend.length > 0) {
119
- (0, _terminal.terminal)(`^+^gExtended payloads:^ ^/^G(This will only take effect if this API run was part of a job.)^:\n:\n`);
114
+ (0, _terminal.terminal)(`^+^gExtended payloads:^ ^/^G(This will only take effect if this API run was part of a job.)^:\n`);
120
115
  (0, _terminal.terminal)(`${JSON.stringify(payloadToAppend, null, 2)}\n`);
121
116
  }
122
117
  return;
123
118
  }
124
119
  await writeResultToFile(outputFile, result, payloadToAppend);
125
120
  }
121
+ const _handleApiResult = exports._handleApiResult = handleApiResult;
126
122
  async function writeResultToFile(outputFile, result, payloadToAppend) {
127
123
  const resultToWrite = {
128
124
  result
@@ -139,6 +135,7 @@ async function writeResultToFile(outputFile, result, payloadToAppend) {
139
135
  throw new _helpers.CLIError(`Failed to write result to file: ${error.message}`);
140
136
  }
141
137
  }
138
+ const _writeResultToFile = exports._writeResultToFile = writeResultToFile;
142
139
  async function attemptApi({
143
140
  apiName,
144
141
  inputData,
@@ -147,10 +144,10 @@ async function attemptApi({
147
144
  headless,
148
145
  timeout
149
146
  }) {
150
- return await (0, _helpers.withTimeout)(async () => {
147
+ return await (0, _helpers.withTimeout)(async abortSignal => {
151
148
  const runApiResult = await (0, _runApi.runApi)({
152
149
  automationFunction: {
153
- name: `api/${apiName}`,
150
+ name: `${_constants.API_FOLDER_NAME}/${apiName}`,
154
151
  params: inputData
155
152
  },
156
153
  runOptions: {
@@ -158,14 +155,18 @@ async function attemptApi({
158
155
  environment: "standalone",
159
156
  proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
160
157
  },
161
- auth,
162
- 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
163
167
  });
164
168
  if (runApiResult.isErr()) {
165
- if (runApiResult.error instanceof _runApi.AutomationError) {
166
- throw runApiResult.error.error;
167
- }
168
- throw new _helpers.CLIError(`An error occurred while running the API: ${runApiResult.error.message}`);
169
+ throw runApiResult.error;
169
170
  }
170
171
  const {
171
172
  result,
@@ -175,5 +176,6 @@ async function attemptApi({
175
176
  result,
176
177
  payloadToAppend
177
178
  };
178
- }, timeout)();
179
- }
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 {};