@intuned/runtime-dev 1.2.0-cli.5 → 1.2.0-cli.6
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.
- package/dist/commands/api/run.js +2 -1
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/constants/index.d.ts +1 -4
- package/dist/commands/intuned-cli/constants/index.js +2 -5
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +25 -0
- package/dist/commands/intuned-cli/controller/api.js +24 -27
- package/dist/commands/intuned-cli/controller/authSession.d.ts +176 -10
- package/dist/commands/intuned-cli/controller/authSession.js +121 -132
- package/dist/commands/intuned-cli/helpers/auth.d.ts +35 -11
- package/dist/commands/intuned-cli/helpers/auth.js +38 -14
- package/dist/commands/intuned-cli/helpers/context.js +1 -1
- package/dist/commands/intuned-cli/main.js +4 -1
- package/dist/commands/intuned-cli/types.d.ts +1 -0
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- package/package.json +2 -1
- package/tsconfig.json +2 -1
- package/dist/common/cli/cliReadme.d.ts +0 -0
- package/dist/common/cli/cliReadme.js +0 -1
- package/dist/common/cli/constants.d.ts +0 -0
- package/dist/common/cli/constants.js +0 -1
- package/dist/common/cli/types.d.ts +0 -0
- package/dist/common/cli/types.js +0 -1
- package/dist/common/cli/utils.d.ts +0 -0
- package/dist/common/cli/utils.js +0 -1
|
@@ -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,6 +3,7 @@
|
|
|
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"));
|
|
@@ -23,15 +24,15 @@ async function executeRunApiCLI({
|
|
|
23
24
|
...rest
|
|
24
25
|
}) {
|
|
25
26
|
await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
|
|
27
|
+
(0, _helpers.registerGetAuthSessionParameters)(authSession?.id);
|
|
26
28
|
(0, _terminal.terminal)(`^+Running API ^c${apiName}^:\n`);
|
|
27
|
-
const apiResult = await (
|
|
29
|
+
const apiResult = await (async () => {
|
|
28
30
|
for (let i = 0; i < retries; i++) {
|
|
29
31
|
(0, _terminal.terminal)(`\n^+Executing ^c${apiName} ^/(Attempt ${i + 1}) ^:...\n`);
|
|
30
|
-
let
|
|
32
|
+
let auth;
|
|
31
33
|
if (authSession) {
|
|
32
|
-
|
|
34
|
+
auth = await (0, _authSession.executeRunValidateAuthSessionCLI)({
|
|
33
35
|
...authSession,
|
|
34
|
-
useExistingContext: true,
|
|
35
36
|
...rest
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -39,13 +40,7 @@ async function executeRunApiCLI({
|
|
|
39
40
|
return await attemptApi({
|
|
40
41
|
apiName,
|
|
41
42
|
inputData,
|
|
42
|
-
auth
|
|
43
|
-
session: {
|
|
44
|
-
type: "file",
|
|
45
|
-
path: authSessionPathToUse
|
|
46
|
-
},
|
|
47
|
-
runCheck: false
|
|
48
|
-
} : undefined,
|
|
43
|
+
auth,
|
|
49
44
|
...rest
|
|
50
45
|
});
|
|
51
46
|
} catch (error) {
|
|
@@ -57,9 +52,7 @@ async function executeRunApiCLI({
|
|
|
57
52
|
throw error;
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
|
-
}
|
|
61
|
-
authSessionId: authSession?.id
|
|
62
|
-
});
|
|
55
|
+
})();
|
|
63
56
|
if (apiResult === undefined) {
|
|
64
57
|
throw new _helpers.CLIError(`^r^+Failed to run API ^:^+${apiName}^:: ^RExceeded maximum retries of ^+${retries}^:\n`, {
|
|
65
58
|
autoColor: false
|
|
@@ -79,23 +72,18 @@ async function executeAttemptApiCLI({
|
|
|
79
72
|
}) {
|
|
80
73
|
(0, _terminal.terminal)(`^+Execute API attempt for ^c${apiName}^:\n`);
|
|
81
74
|
await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
|
|
82
|
-
|
|
75
|
+
(0, _helpers.registerGetAuthSessionParameters)(authSessionId);
|
|
76
|
+
let storageState;
|
|
83
77
|
if (authSessionId) {
|
|
84
78
|
({
|
|
85
|
-
|
|
86
|
-
} = await (0, _helpers.
|
|
79
|
+
storageState
|
|
80
|
+
} = await (0, _helpers.loadAuthSessionInstance)(authSessionId));
|
|
87
81
|
}
|
|
88
82
|
return await (0, _helpers.withCLIContext)(async () => {
|
|
89
83
|
const apiResult = await attemptApi({
|
|
90
84
|
apiName,
|
|
91
85
|
inputData,
|
|
92
|
-
auth:
|
|
93
|
-
session: {
|
|
94
|
-
type: "state",
|
|
95
|
-
state: authSessionInstance
|
|
96
|
-
},
|
|
97
|
-
runCheck: false
|
|
98
|
-
} : undefined,
|
|
86
|
+
auth: storageState,
|
|
99
87
|
...rest
|
|
100
88
|
});
|
|
101
89
|
return await handleApiResult({
|
|
@@ -130,6 +118,7 @@ async function handleApiResult({
|
|
|
130
118
|
}
|
|
131
119
|
await writeResultToFile(outputFile, result, payloadToAppend);
|
|
132
120
|
}
|
|
121
|
+
const _handleApiResult = exports._handleApiResult = handleApiResult;
|
|
133
122
|
async function writeResultToFile(outputFile, result, payloadToAppend) {
|
|
134
123
|
const resultToWrite = {
|
|
135
124
|
result
|
|
@@ -146,6 +135,7 @@ async function writeResultToFile(outputFile, result, payloadToAppend) {
|
|
|
146
135
|
throw new _helpers.CLIError(`Failed to write result to file: ${error.message}`);
|
|
147
136
|
}
|
|
148
137
|
}
|
|
138
|
+
const _writeResultToFile = exports._writeResultToFile = writeResultToFile;
|
|
149
139
|
async function attemptApi({
|
|
150
140
|
apiName,
|
|
151
141
|
inputData,
|
|
@@ -157,7 +147,7 @@ async function attemptApi({
|
|
|
157
147
|
return await (0, _helpers.withTimeout)(async abortSignal => {
|
|
158
148
|
const runApiResult = await (0, _runApi.runApi)({
|
|
159
149
|
automationFunction: {
|
|
160
|
-
name:
|
|
150
|
+
name: `${_constants.API_FOLDER_NAME}/${apiName}`,
|
|
161
151
|
params: inputData
|
|
162
152
|
},
|
|
163
153
|
runOptions: {
|
|
@@ -165,7 +155,13 @@ async function attemptApi({
|
|
|
165
155
|
environment: "standalone",
|
|
166
156
|
proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
|
|
167
157
|
},
|
|
168
|
-
auth
|
|
158
|
+
auth: auth ? {
|
|
159
|
+
session: {
|
|
160
|
+
type: "state",
|
|
161
|
+
state: auth
|
|
162
|
+
},
|
|
163
|
+
runCheck: false
|
|
164
|
+
} : undefined,
|
|
169
165
|
importFunction: _tsNodeImport.tsNodeImport,
|
|
170
166
|
abortSignal
|
|
171
167
|
});
|
|
@@ -181,4 +177,5 @@ async function attemptApi({
|
|
|
181
177
|
payloadToAppend
|
|
182
178
|
};
|
|
183
179
|
}, timeout);
|
|
184
|
-
}
|
|
180
|
+
}
|
|
181
|
+
const _attemptApi = exports._attemptApi = attemptApi;
|
|
@@ -1,32 +1,198 @@
|
|
|
1
1
|
import type { BaseCommandOptions } from "../commands/types";
|
|
2
|
-
import {
|
|
3
|
-
export declare function executeRunValidateAuthSessionCLI({ id, autoRecreate, checkRetries, createRetries,
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
30
|
-
|
|
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<
|
|
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 {};
|