@intuned/runtime-dev 1.1.8-bot-detection → 1.2.0-cli.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 (104) hide show
  1. package/.babelrc +2 -2
  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 +8 -2
  6. package/dist/commands/auth-sessions/run-check.js +18 -4
  7. package/dist/commands/auth-sessions/run-create.js +2 -1
  8. package/dist/commands/cli-auth-sessions/create.js +1 -1
  9. package/dist/commands/cli-auth-sessions/utils.d.ts +1 -1
  10. package/dist/commands/cli-auth-sessions/utils.js +2 -3
  11. package/dist/commands/common/browserUtils.d.ts +1 -1
  12. package/dist/commands/common/browserUtils.js +1 -1
  13. package/dist/commands/common/getFirstLineNumber.js +2 -4
  14. package/dist/commands/deploy/utils.js +1 -2
  15. package/dist/commands/init/utils.js +1 -7
  16. package/dist/commands/interface/run.js +7 -6
  17. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  18. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  19. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  20. package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
  21. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  22. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  23. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  24. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
  25. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  26. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
  27. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  28. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  29. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  30. package/dist/commands/intuned-cli/commands/command.js +9 -0
  31. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  32. package/dist/commands/intuned-cli/commands/deploy.command.js +47 -0
  33. package/dist/commands/intuned-cli/commands/helpers.d.ts +26 -0
  34. package/dist/commands/intuned-cli/commands/helpers.js +134 -0
  35. package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
  36. package/dist/commands/intuned-cli/commands/index.js +170 -0
  37. package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  38. package/dist/commands/intuned-cli/commands/init.command.js +14 -0
  39. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  40. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  41. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  42. package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
  43. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +21 -0
  44. package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
  45. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  46. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
  47. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  48. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
  49. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  50. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
  51. package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
  52. package/dist/commands/intuned-cli/commands/types.js +21 -0
  53. package/dist/commands/intuned-cli/controller/api.d.ts +19 -0
  54. package/dist/commands/intuned-cli/controller/api.js +182 -0
  55. package/dist/commands/intuned-cli/controller/authSession.d.ts +32 -0
  56. package/dist/commands/intuned-cli/controller/authSession.js +295 -0
  57. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  58. package/dist/commands/intuned-cli/controller/build.js +36 -0
  59. package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
  60. package/dist/commands/intuned-cli/controller/deploy.js +397 -0
  61. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  62. package/dist/commands/intuned-cli/controller/index.js +45 -0
  63. package/dist/commands/intuned-cli/controller/init.d.ts +5 -0
  64. package/dist/commands/intuned-cli/controller/init.js +139 -0
  65. package/dist/commands/intuned-cli/index.d.ts +1 -0
  66. package/dist/commands/intuned-cli/index.js +16 -0
  67. package/dist/commands/intuned-cli/main.d.ts +1 -0
  68. package/dist/commands/intuned-cli/main.js +12 -0
  69. package/dist/commands/intuned-cli/terminal.d.ts +1 -0
  70. package/dist/commands/intuned-cli/terminal.js +12 -0
  71. package/dist/commands/run-api-cli/utils.js +6 -6
  72. package/dist/common/assets/browser_scripts.js +2509 -2143
  73. package/dist/common/asyncLocalStorage/index.d.ts +1 -2
  74. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  75. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  76. package/dist/common/cli/cliReadme.d.ts +1 -1
  77. package/dist/common/cli/cliReadme.js +14 -23
  78. package/dist/common/cli/constants.d.ts +4 -2
  79. package/dist/common/cli/constants.js +7 -3
  80. package/dist/common/cli/types.d.ts +2 -2
  81. package/dist/common/cli/utils.d.ts +5 -2
  82. package/dist/common/cli/utils.js +6 -2
  83. package/dist/common/constants.d.ts +1 -0
  84. package/dist/common/constants.js +2 -1
  85. package/dist/common/contextStorageStateHelpers.d.ts +1 -1
  86. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  87. package/dist/common/getPlaywrightConstructs.js +12 -12
  88. package/dist/common/jwtTokenManager.js +3 -5
  89. package/dist/common/runApi/errors.d.ts +1 -1
  90. package/dist/common/runApi/errors.js +5 -6
  91. package/dist/common/runApi/index.d.ts +4 -1
  92. package/dist/common/runApi/index.js +21 -21
  93. package/dist/index.d.ts +1 -1
  94. package/dist/index.js +6 -0
  95. package/dist/runtime/executionHelpers.test.js +3 -4
  96. package/dist/runtime/export.d.ts +16 -0
  97. package/dist/runtime/extendPayload.js +1 -1
  98. package/dist/runtime/extendTimeout.js +0 -7
  99. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  100. package/dist/runtime/getAuthSessionParameters.js +20 -0
  101. package/dist/runtime/index.d.ts +1 -0
  102. package/dist/runtime/index.js +7 -0
  103. package/package.json +10 -7
  104. package/template.tsconfig.json +4 -7
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.executeAttemptApiCLI = executeAttemptApiCLI;
7
+ exports.executeRunApiCLI = executeRunApiCLI;
8
+ var fs = _interopRequireWildcard(require("fs-extra"));
9
+ var _runApi = require("../../../common/runApi");
10
+ var _tsNodeImport = require("../../common/tsNodeImport");
11
+ var _authSession = require("./authSession");
12
+ var _utils = require("../../cli-auth-sessions/utils");
13
+ var _helpers = require("../commands/helpers");
14
+ var _terminal = require("../terminal");
15
+ var _constants = require("../../../common/constants");
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
+ 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; }
18
+ async function executeRunApiCLI({
19
+ apiName,
20
+ inputData,
21
+ retries,
22
+ authSession,
23
+ outputFile,
24
+ ...rest
25
+ }) {
26
+ await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
27
+ (0, _terminal.terminal)(`^+Running API ^c${apiName}^:\n`);
28
+ const apiResult = await (0, _helpers.withCLIContext)(async () => {
29
+ for (let i = 0; i < retries; i++) {
30
+ (0, _terminal.terminal)(`\n^+Executing ^c${apiName} ^/(Attempt ${i + 1}) ^:...\n`);
31
+ let authSessionPathToUse;
32
+ if (authSession) {
33
+ authSessionPathToUse = await (0, _authSession.executeRunValidateAuthSessionCLI)({
34
+ ...authSession,
35
+ useExistingContext: true,
36
+ ...rest
37
+ });
38
+ }
39
+ try {
40
+ return await attemptApi({
41
+ apiName,
42
+ inputData,
43
+ auth: authSessionPathToUse ? {
44
+ session: {
45
+ type: "file",
46
+ path: authSessionPathToUse
47
+ },
48
+ runCheck: false
49
+ } : undefined,
50
+ ...rest
51
+ });
52
+ } catch (error) {
53
+ if (error instanceof _runApi.AutomationError) {
54
+ (0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed ^:^+${apiName}^:: ^R${error.error.message}^:\n`);
55
+ continue;
56
+ }
57
+ throw error;
58
+ }
59
+ }
60
+ })();
61
+ if (apiResult === undefined) {
62
+ throw new _helpers.CLIError(`^r^+Failed to run API ^:^+${apiName}^:: ^RExceeded maximum retries of ^+${retries}^:\n`, {
63
+ autoColor: false
64
+ });
65
+ }
66
+ return handleApiResult({
67
+ apiResult,
68
+ outputFile
69
+ });
70
+ }
71
+ async function executeAttemptApiCLI({
72
+ apiName,
73
+ inputData,
74
+ authSessionId,
75
+ outputFile,
76
+ ...rest
77
+ }) {
78
+ (0, _terminal.terminal)(`^+Execute API attempt for ^c${apiName}^:\n`);
79
+ await (0, _helpers.assertApiFileExists)(_constants.API_FOLDER_NAME, apiName);
80
+ let authSessionInstance;
81
+ if (authSessionId) {
82
+ ({
83
+ authSessionInstance
84
+ } = await (0, _utils.retrieveAuthSessionInstance)(authSessionId));
85
+ }
86
+ return await (0, _helpers.withCLIContext)(async () => {
87
+ const apiResult = await attemptApi({
88
+ apiName,
89
+ inputData,
90
+ auth: authSessionInstance ? {
91
+ session: {
92
+ type: "state",
93
+ state: authSessionInstance
94
+ },
95
+ runCheck: false
96
+ } : undefined,
97
+ ...rest
98
+ });
99
+ return await handleApiResult({
100
+ apiResult,
101
+ outputFile
102
+ });
103
+ })();
104
+ }
105
+ async function handleApiResult({
106
+ apiResult,
107
+ outputFile
108
+ }) {
109
+ const {
110
+ result,
111
+ payloadToAppend
112
+ } = apiResult;
113
+ (0, _terminal.terminal)(`^+^gAPI executed successfully^:\n`);
114
+ if (!outputFile) {
115
+ if (!result) {
116
+ (0, _terminal.terminal)(`^+^yNo result returned from the API^:\n`);
117
+ } else {
118
+ (0, _terminal.terminal)(`^+^gResult:^:\n`);
119
+ (0, _terminal.terminal)(`${JSON.stringify(result, null, 2)}\n`);
120
+ }
121
+ if (payloadToAppend && payloadToAppend.length > 0) {
122
+ (0, _terminal.terminal)(`^+^gExtended payloads:^ ^/^G(This will only take effect if this API run was part of a job.)^:\n`);
123
+ (0, _terminal.terminal)(`${JSON.stringify(payloadToAppend, null, 2)}\n`);
124
+ }
125
+ return;
126
+ }
127
+ await writeResultToFile(outputFile, result, payloadToAppend);
128
+ }
129
+ async function writeResultToFile(outputFile, result, payloadToAppend) {
130
+ const resultToWrite = {
131
+ result
132
+ };
133
+ if (payloadToAppend && payloadToAppend.length > 0) {
134
+ resultToWrite["extendedPayloads"] = payloadToAppend;
135
+ }
136
+ try {
137
+ await fs.writeJSON(outputFile, resultToWrite, {
138
+ spaces: 2
139
+ });
140
+ (0, _terminal.terminal)(`^+^gResults written to^ ^_${outputFile}^:\n`);
141
+ } catch (error) {
142
+ throw new _helpers.CLIError(`Failed to write result to file: ${error.message}`);
143
+ }
144
+ }
145
+ async function attemptApi({
146
+ apiName,
147
+ inputData,
148
+ auth,
149
+ proxy,
150
+ headless,
151
+ timeout
152
+ }) {
153
+ return await (0, _helpers.withTimeout)(async () => {
154
+ const runApiResult = await (0, _runApi.runApi)({
155
+ automationFunction: {
156
+ name: `api/${apiName}`,
157
+ params: inputData
158
+ },
159
+ runOptions: {
160
+ headless,
161
+ environment: "standalone",
162
+ proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
163
+ },
164
+ auth,
165
+ importFunction: _tsNodeImport.tsNodeImport
166
+ });
167
+ 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}`);
172
+ }
173
+ const {
174
+ result,
175
+ extendedPayloads: payloadToAppend
176
+ } = runApiResult.value;
177
+ return {
178
+ result,
179
+ payloadToAppend
180
+ };
181
+ }, timeout)();
182
+ }
@@ -0,0 +1,32 @@
1
+ import type { BaseCommandOptions } from "../commands/types";
2
+ import { StorageState } from "../../../common/contextStorageStateHelpers";
3
+ export declare function executeRunValidateAuthSessionCLI({ id, autoRecreate, checkRetries, createRetries, useExistingContext, ...rest }: {
4
+ id: string;
5
+ autoRecreate: boolean;
6
+ checkRetries: number;
7
+ createRetries: number;
8
+ useExistingContext?: boolean;
9
+ } & BaseCommandOptions): Promise<string>;
10
+ export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries, createRetries, log, ...rest }: {
11
+ id?: string;
12
+ input: any;
13
+ checkRetries: number;
14
+ createRetries: number;
15
+ log?: boolean;
16
+ } & BaseCommandOptions): Promise<string>;
17
+ export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries, createRetries, ...rest }: {
18
+ id: string;
19
+ input?: any;
20
+ checkRetries: number;
21
+ createRetries: number;
22
+ } & BaseCommandOptions): Promise<string>;
23
+ export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest }: {
24
+ id?: string;
25
+ input: any;
26
+ } & BaseCommandOptions): Promise<string>;
27
+ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
28
+ id: string;
29
+ } & BaseCommandOptions): Promise<string>;
30
+ export declare function runCreate({ authSessionInput, proxy, headless, timeout, }: {
31
+ authSessionInput: Record<string, any>;
32
+ } & BaseCommandOptions): Promise<StorageState>;
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.executeAttemptCheckAuthSessionCLI = executeAttemptCheckAuthSessionCLI;
7
+ exports.executeAttemptCreateAuthSessionCLI = executeAttemptCreateAuthSessionCLI;
8
+ exports.executeRunCreateAuthSessionCLI = executeRunCreateAuthSessionCLI;
9
+ exports.executeRunUpdateAuthSessionCLI = executeRunUpdateAuthSessionCLI;
10
+ exports.executeRunValidateAuthSessionCLI = executeRunValidateAuthSessionCLI;
11
+ exports.runCreate = runCreate;
12
+ var _utils = require("../../cli-auth-sessions/utils");
13
+ var _path = _interopRequireDefault(require("path"));
14
+ var _helpers = require("../commands/helpers");
15
+ var _runApi = require("../../../common/runApi");
16
+ var _constants = require("../../../common/constants");
17
+ var _tsNodeImport = require("../../common/tsNodeImport");
18
+ var _terminal = require("../terminal");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ async function executeRunValidateAuthSessionCLI({
21
+ id,
22
+ autoRecreate,
23
+ checkRetries,
24
+ createRetries,
25
+ useExistingContext = false,
26
+ ...rest
27
+ }) {
28
+ const validate = async () => {
29
+ (0, _terminal.terminal)(`^+Validating auth session with id ^c${id}^:\n`);
30
+ const {
31
+ authSessionInstanceStoragePath
32
+ } = await (0, _utils.retrieveAuthSessionInstance)(id, true);
33
+ const authSessionPathToUse = authSessionInstanceStoragePath;
34
+ await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
35
+ const checkResult = await runCheckWithRetries({
36
+ authSessionPath: authSessionPathToUse,
37
+ retries: checkRetries,
38
+ ...rest
39
+ });
40
+ if (!checkResult) {
41
+ if (!autoRecreate) {
42
+ throw new _helpers.CLIError("Auto recreate is disabled, please provide a new auth session or update it manually");
43
+ }
44
+ const {
45
+ metadata
46
+ } = await (0, _utils.retrieveAuthSessionInstance)(id);
47
+ if (metadata?.authSessionType === "MANUAL") {
48
+ throw new _helpers.CLIError("Auth session is recorder-based, please provide a new one or update it manually");
49
+ }
50
+ (0, _terminal.terminal)("^+Auto recreate is enabled - trying to re-create it^:\n");
51
+ await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
52
+ const authSessionInput = metadata?.authSessionInput ?? {};
53
+ await runCreateWithRetries({
54
+ authSessionId: id,
55
+ authSessionInput,
56
+ retries: createRetries,
57
+ ...rest
58
+ });
59
+ const checkResult = await runCheckWithRetries({
60
+ authSessionPath: authSessionPathToUse,
61
+ retries: checkRetries,
62
+ ...rest
63
+ });
64
+ if (!checkResult) {
65
+ throw new _helpers.CLIError("Failed to re-create auth session");
66
+ }
67
+ }
68
+ (0, _terminal.terminal)(`^+^gAuth session validated successfully^:\n`);
69
+ return authSessionPathToUse;
70
+ };
71
+ if (useExistingContext) {
72
+ return await validate();
73
+ } else {
74
+ return await (0, _helpers.withCLIContext)(validate)();
75
+ }
76
+ }
77
+ async function executeRunCreateAuthSessionCLI({
78
+ id,
79
+ input,
80
+ checkRetries,
81
+ createRetries,
82
+ log = true,
83
+ ...rest
84
+ }) {
85
+ return (0, _helpers.withCLIContext)(async () => {
86
+ id = id ?? `auth-session-${Date.now()}`;
87
+ (0, _terminal.terminal)(`^+Creating auth session with id ^c${id}^:\n`);
88
+ await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
89
+ const authSessionPath = await runCreateWithRetries({
90
+ authSessionId: id,
91
+ authSessionInput: input,
92
+ retries: createRetries,
93
+ ...rest
94
+ });
95
+ const checkResult = await runCheckWithRetries({
96
+ authSessionPath: _path.default.join(authSessionPath, "auth-session.json"),
97
+ retries: checkRetries,
98
+ ...rest
99
+ });
100
+ if (!checkResult) {
101
+ throw new _helpers.CLIError("Failed to create auth session");
102
+ }
103
+ if (log) {
104
+ (0, _terminal.terminal)(`^+^gAuth session created successfully^:\n`);
105
+ }
106
+ return authSessionPath;
107
+ })();
108
+ }
109
+ async function executeRunUpdateAuthSessionCLI({
110
+ id,
111
+ input,
112
+ checkRetries,
113
+ createRetries,
114
+ ...rest
115
+ }) {
116
+ (0, _terminal.terminal)(`^+Updating auth session with id ^c${id}^:\n`);
117
+ return (0, _helpers.withCLIContext)(async () => {
118
+ if (input === undefined) {
119
+ const {
120
+ metadata
121
+ } = await (0, _utils.retrieveAuthSessionInstance)(id);
122
+ if (metadata?.authSessionType === "MANUAL") {
123
+ throw new Error("Auth session is recorder-based, it cannot be updated.");
124
+ }
125
+ input = metadata?.authSessionInput ?? {};
126
+ }
127
+ await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
128
+ const authSession = await executeRunCreateAuthSessionCLI({
129
+ id,
130
+ input,
131
+ checkRetries,
132
+ createRetries,
133
+ log: false,
134
+ ...rest
135
+ });
136
+ (0, _terminal.terminal)(`^+^gAuth session updated successfully^:\n`);
137
+ return authSession;
138
+ })();
139
+ }
140
+ async function executeAttemptCreateAuthSessionCLI({
141
+ id,
142
+ input,
143
+ ...rest
144
+ }) {
145
+ id = id ?? `auth-session-attempt-${Date.now()}`;
146
+ (0, _terminal.terminal)(`^+Executing create auth session attempt with id ^c${id}^:\n`);
147
+ await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
148
+ return await runCreateWithRetries({
149
+ authSessionId: id,
150
+ authSessionInput: input,
151
+ retries: 1,
152
+ ...rest
153
+ });
154
+ }
155
+ async function executeAttemptCheckAuthSessionCLI({
156
+ id,
157
+ ...rest
158
+ }) {
159
+ (0, _terminal.terminal)(`^+Executing check auth session attempt with id ^c${id}^:\n`);
160
+ await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
161
+ const {
162
+ authSessionInstanceStoragePath
163
+ } = await (0, _utils.retrieveAuthSessionInstance)(id, true);
164
+ const authSessionPathToUse = authSessionInstanceStoragePath;
165
+ const checkResult = await runCheckWithRetries({
166
+ authSessionPath: authSessionPathToUse,
167
+ retries: 1,
168
+ ...rest
169
+ });
170
+ if (!checkResult) {
171
+ throw new Error("Check failed");
172
+ }
173
+ (0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
174
+ return authSessionPathToUse;
175
+ }
176
+ async function runCheck({
177
+ authSessionPath,
178
+ proxy,
179
+ headless,
180
+ timeout
181
+ }) {
182
+ return await (0, _helpers.withTimeout)(async () => {
183
+ const runApiResult = await (0, _runApi.runApi)({
184
+ automationFunction: {
185
+ name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
186
+ },
187
+ runOptions: {
188
+ headless,
189
+ environment: "standalone",
190
+ proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
191
+ },
192
+ auth: {
193
+ session: {
194
+ type: "file",
195
+ path: authSessionPath
196
+ },
197
+ runCheck: false
198
+ },
199
+ importFunction: _tsNodeImport.tsNodeImport
200
+ });
201
+ if (runApiResult.isErr()) {
202
+ if (runApiResult.error instanceof _runApi.AutomationError) {
203
+ throw runApiResult.error;
204
+ }
205
+ return false;
206
+ }
207
+ const result = runApiResult.value.result;
208
+ if (!result) {
209
+ return false;
210
+ }
211
+ return result;
212
+ }, timeout)();
213
+ }
214
+ async function runCreate({
215
+ authSessionInput,
216
+ proxy,
217
+ headless,
218
+ timeout
219
+ }) {
220
+ return await (0, _helpers.withTimeout)(async () => {
221
+ const createApiName = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`;
222
+ const result = await (0, _runApi.runApi)({
223
+ automationFunction: {
224
+ name: createApiName,
225
+ params: authSessionInput
226
+ },
227
+ runOptions: {
228
+ headless,
229
+ environment: "standalone",
230
+ proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
231
+ },
232
+ retrieveSession: true,
233
+ importFunction: _tsNodeImport.tsNodeImport
234
+ });
235
+ if (result.isErr()) {
236
+ if (result.error instanceof _runApi.AutomationError) {
237
+ throw result.error.error;
238
+ }
239
+ console.error(result.error);
240
+ throw new Error("Error while running create");
241
+ }
242
+ return result.value.session;
243
+ }, timeout)();
244
+ }
245
+ async function runCheckWithRetries({
246
+ authSessionPath,
247
+ retries,
248
+ ...rest
249
+ }) {
250
+ for (let i = 0; i < retries; i++) {
251
+ (0, _terminal.terminal)(`\n^+Running ^cauth session check${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
252
+ try {
253
+ const checkResult = await runCheck({
254
+ authSessionPath,
255
+ ...rest
256
+ });
257
+ if (checkResult) {
258
+ (0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
259
+ return true;
260
+ }
261
+ } catch (error) {
262
+ (0, _terminal.terminal)(`^+^yAuth session check failed with error ^:${error.message}^:\n`);
263
+ continue;
264
+ }
265
+ (0, _terminal.terminal)(`^+^yAuth session check failed^:\n`);
266
+ }
267
+ (0, _terminal.terminal)(`^+^rAuth session check failed after ${retries} attempts^:\n`);
268
+ return false;
269
+ }
270
+ async function runCreateWithRetries({
271
+ authSessionId,
272
+ authSessionInput,
273
+ retries,
274
+ ...rest
275
+ }) {
276
+ let newAuthSessionInstance = null;
277
+ for (let i = 0; i < retries; i++) {
278
+ (0, _terminal.terminal)(`\n^+Running ^cauth session create${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
279
+ try {
280
+ newAuthSessionInstance = await runCreate({
281
+ authSessionInput,
282
+ ...rest
283
+ });
284
+ (0, _terminal.terminal)(`^+^gAuth session create succeeded^:\n`);
285
+ break;
286
+ } catch (error) {
287
+ (0, _terminal.terminal)(`^+^yAuth session create failed with error ^:${error.message}^:\n`);
288
+ continue;
289
+ }
290
+ }
291
+ if (!newAuthSessionInstance) {
292
+ throw new _helpers.CLIError(`Failed to create auth session after ${retries} retries`);
293
+ }
294
+ return await (0, _utils.storeAuthSessionInstance)(newAuthSessionInstance, authSessionId, authSessionInput);
295
+ }
@@ -0,0 +1 @@
1
+ export declare const runBuild: () => Promise<boolean>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runBuild = void 0;
7
+ var fs = _interopRequireWildcard(require("fs-extra"));
8
+ var path = _interopRequireWildcard(require("path"));
9
+ var _child_process = require("child_process");
10
+ var _util = require("util");
11
+ var _terminal = require("../terminal");
12
+ 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); }
13
+ 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; }
14
+ const execPromise = (0, _util.promisify)(_child_process.exec);
15
+ const runBuild = async () => {
16
+ const distPath = path.join(process.cwd(), "dist");
17
+ if (await fs.exists(distPath)) {
18
+ await fs.remove(distPath);
19
+ }
20
+ const buildCommand = "tsc";
21
+ try {
22
+ await execPromise(buildCommand);
23
+ (0, _terminal.terminal)(`^g^+✨ Build completed successfully!^:\n`);
24
+ return true;
25
+ } catch (error) {
26
+ (0, _terminal.terminal)(`^r^+An error occurred during the build process:^:\n`);
27
+ if ("stdout" in error) {
28
+ (0, _terminal.terminal)(`${error.stdout}\n`);
29
+ } else {
30
+ (0, _terminal.terminal)(`^${error.message}^:\n`);
31
+ }
32
+ (0, _terminal.terminal)(`^r^+Build failed^:\n`);
33
+ return false;
34
+ }
35
+ };
36
+ exports.runBuild = runBuild;
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ import { AuthCredentials, FileSystemTree } from "../../../common/cli/types";
3
+ export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
4
+ export declare function runDeployProject(projectName: string, auth: AuthCredentials): Promise<void>;
5
+ export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
6
+ export declare const validateProjectName: (projectName: string) => {
7
+ isValid: true;
8
+ } | {
9
+ isValid: false;
10
+ errorMessage: string;
11
+ };
12
+ export declare const validateIntunedProject: () => Promise<{
13
+ isValid: boolean;
14
+ errorMessage?: string;
15
+ }>;