@intuned/runtime-dev 1.3.17-ws.0 → 1.3.18-dev.2

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 (120) hide show
  1. package/.babelrc +6 -0
  2. package/CHANGELOG.md +1 -1
  3. package/InterfaceTemplate/{utils.ts → __utils.ts} +3 -1
  4. package/InterfaceTemplate/index.playwright.ts +1 -1
  5. package/bin/intuned +0 -0
  6. package/bin/intuned-interface +7 -0
  7. package/dist/commands/api/run.js +7 -11
  8. package/dist/commands/auth-sessions/load.js +2 -2
  9. package/dist/commands/auth-sessions/run-check.js +8 -8
  10. package/dist/commands/auth-sessions/run-create.js +6 -6
  11. package/dist/commands/build.js +2 -3
  12. package/dist/commands/common/browserUtils.d.ts +3 -3
  13. package/dist/commands/common/browserUtils.js +3 -4
  14. package/dist/commands/common/getFirstLineNumber.test.js +1 -2
  15. package/dist/commands/common/projectExclusions.js +1 -1
  16. package/dist/commands/common/tsNodeImport.d.ts +1 -1
  17. package/dist/commands/common/tsNodeImport.js +10 -2
  18. package/dist/commands/common/utils/fileUtils.js +1 -2
  19. package/dist/commands/common/utils/{unixSocket.d.ts → interfaceClient.d.ts} +10 -2
  20. package/dist/commands/common/utils/{unixSocket.js → interfaceClient.js} +16 -5
  21. package/dist/commands/common/utils/template.js +1 -2
  22. package/dist/commands/interface/run.js +23 -49
  23. package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
  24. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +1 -1
  25. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -2
  26. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
  27. package/dist/commands/intuned-cli/commands/authsession.command.js +1 -1
  28. package/dist/commands/intuned-cli/commands/authsession_record.command.js +1 -1
  29. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
  30. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
  31. package/dist/commands/intuned-cli/commands/deploy.command.js +13 -9
  32. package/dist/commands/intuned-cli/commands/index.d.ts +2 -2
  33. package/dist/commands/intuned-cli/commands/index.js +15 -15
  34. package/dist/commands/intuned-cli/commands/{save.command.d.ts → provision.command.d.ts} +3 -3
  35. package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
  36. package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
  37. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +8 -1
  38. package/dist/commands/intuned-cli/commands/run_authsession.command.js +2 -2
  39. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
  40. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +2 -2
  41. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +2 -2
  42. package/dist/commands/intuned-cli/commands/types.d.ts +9 -1
  43. package/dist/commands/intuned-cli/commands/types.js +9 -5
  44. package/dist/commands/intuned-cli/controller/__test__/api.test.js +30 -19
  45. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +140 -77
  46. package/dist/commands/intuned-cli/controller/api.d.ts +2 -2
  47. package/dist/commands/intuned-cli/controller/api.js +6 -3
  48. package/dist/commands/intuned-cli/controller/authSession.d.ts +16 -16
  49. package/dist/commands/intuned-cli/controller/authSession.js +50 -39
  50. package/dist/commands/intuned-cli/controller/build.js +1 -2
  51. package/dist/commands/intuned-cli/controller/deploy.js +53 -12
  52. package/dist/commands/intuned-cli/controller/index.js +2 -3
  53. package/dist/commands/intuned-cli/controller/{save.d.ts → provision.d.ts} +5 -1
  54. package/dist/commands/intuned-cli/controller/provision.js +299 -0
  55. package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
  56. package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
  57. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +45 -5
  58. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +4 -3
  59. package/dist/commands/intuned-cli/helpers/api.js +4 -7
  60. package/dist/commands/intuned-cli/helpers/auth.d.ts +4 -4
  61. package/dist/commands/intuned-cli/helpers/auth.js +24 -21
  62. package/dist/commands/intuned-cli/helpers/backend.js +12 -4
  63. package/dist/commands/intuned-cli/helpers/browser.d.ts +4 -4
  64. package/dist/commands/intuned-cli/helpers/browser.js +40 -5
  65. package/dist/commands/intuned-cli/helpers/context.js +2 -2
  66. package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
  67. package/dist/commands/intuned-cli/helpers/errors.js +2 -2
  68. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +6 -5
  69. package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
  70. package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
  71. package/dist/commands/intuned-cli/helpers/timeout.js +2 -2
  72. package/dist/commands/intuned-cli/helpers/traces.d.ts +1 -1
  73. package/dist/commands/intuned-cli/helpers/wrapper.js +14 -4
  74. package/dist/commands/intuned-cli/main.js +1 -2
  75. package/dist/commands/intuned-cli/types.d.ts +41 -12
  76. package/dist/commands/intuned-cli/types.js +12 -2
  77. package/dist/commands/ts-check.js +1 -2
  78. package/dist/common/backendFunctions/getAuthSessionParameters.js +1 -1
  79. package/dist/common/binStartupScript.js +1 -2
  80. package/dist/common/browserTabs.d.ts +72 -0
  81. package/dist/common/browserTabs.js +74 -0
  82. package/dist/common/constants.d.ts +1 -0
  83. package/dist/common/constants.js +2 -1
  84. package/dist/common/contextStorageStateHelpers.d.ts +4 -3
  85. package/dist/common/contextStorageStateHelpers.js +4 -1
  86. package/dist/common/extension/extensionsHelpers.d.ts +1 -1
  87. package/dist/common/extension/types.d.ts +14 -7
  88. package/dist/common/formatZodError.d.ts +1 -1
  89. package/dist/common/intunedJson.d.ts +19 -14
  90. package/dist/common/intunedJson.js +4 -4
  91. package/dist/common/jwtTokenManager.js +10 -6
  92. package/dist/common/launchBrowser.d.ts +10 -0
  93. package/dist/common/launchBrowser.js +67 -7
  94. package/dist/common/playwrightContext.d.ts +5 -5
  95. package/dist/common/playwrightContext.js +24 -14
  96. package/dist/common/runApi/importUsingImportFunction.d.ts +1 -3
  97. package/dist/common/runApi/importUsingImportFunction.js +7 -7
  98. package/dist/common/runApi/index.d.ts +3 -6
  99. package/dist/common/runApi/index.js +28 -52
  100. package/dist/common/settingsSchema.d.ts +52 -45
  101. package/dist/common/settingsSchema.js +3 -3
  102. package/dist/common/setupContextHook.d.ts +1 -2
  103. package/dist/common/setupContextHook.js +2 -2
  104. package/dist/common/telemetry.js +1 -2
  105. package/dist/index.d.ts +0 -1
  106. package/dist/index.js +0 -7
  107. package/dist/runtime/downloadDirectory.js +2 -2
  108. package/dist/vendor/runtime-interface.d.ts +1 -0
  109. package/dist/vendor/runtime-interface.js +493 -0
  110. package/package.json +19 -11
  111. package/tsup.config.ts +12 -0
  112. package/WebTemplate.zip +0 -0
  113. package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
  114. package/dist/commands/intuned-cli/commands/init.command.js +0 -13
  115. package/dist/commands/intuned-cli/commands/save.command.js +0 -42
  116. package/dist/commands/intuned-cli/controller/save.js +0 -357
  117. package/dist/common/runApi/errors.d.ts +0 -72
  118. package/dist/common/runApi/errors.js +0 -169
  119. package/dist/common/runApi/types.d.ts +0 -830
  120. package/dist/common/runApi/types.js +0 -73
@@ -1,357 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.projectNameSchema = void 0;
7
- exports.runSaveProject = runSaveProject;
8
- exports.validateProjectName = exports.validateIntunedProject = void 0;
9
- var fs = _interopRequireWildcard(require("fs-extra"));
10
- var path = _interopRequireWildcard(require("path"));
11
- var _minimatch = require("minimatch");
12
- var _zod = require("zod");
13
- var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
14
- var _constants = require("../constants");
15
- var _helpers = require("../helpers");
16
- var _lodash = require("lodash");
17
- var _uuid = require("uuid");
18
- var _terminal = require("../helpers/terminal");
19
- var _build = require("./build");
20
- var dotenv = _interopRequireWildcard(require("dotenv"));
21
- var _constants2 = require("../../../common/constants");
22
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
- 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); }
24
- 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; }
25
- const saveProjectApiResponseSchema = _zod.z.string().transform((val, ctx) => {
26
- try {
27
- return JSON.parse(val);
28
- } catch (e) {
29
- ctx.addIssue({
30
- code: _zod.z.ZodIssueCode.custom,
31
- message: "Response is not valid JSON"
32
- });
33
- return _zod.z.NEVER;
34
- }
35
- }).pipe(_zod.z.object({
36
- id: _zod.z.string().uuid(),
37
- enableFirstRunExperience: _zod.z.boolean().optional()
38
- }));
39
- async function runSaveProject(projectName, auth) {
40
- const {
41
- workspaceId,
42
- apiKey
43
- } = auth;
44
- const baseUrl = (0, _helpers.getBaseUrl)();
45
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}`;
46
- const headers = {
47
- [_constants2.API_KEY_HEADER_NAME]: apiKey,
48
- "Content-Type": "application/json"
49
- };
50
- const projectPath = process.cwd();
51
- const codeTree = await convertProjectToCodeTree(projectPath);
52
- const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
53
- codeTree["Intuned.json"] = {
54
- file: {
55
- contents: JSON.stringify(intunedSettingsFile.parse(await fs.readFile(intunedSettingsFile.path, "utf-8")))
56
- }
57
- };
58
- codeTree["tsconfig.json"] = {
59
- file: {
60
- contents: JSON.stringify(_constants.tsConfigCli, null, 2)
61
- }
62
- };
63
- const saveProjectPayload = {
64
- codeTree,
65
- platformType: "CLI",
66
- language: "typescript"
67
- };
68
- const response = await fetch(url, {
69
- headers,
70
- method: "PUT",
71
- body: JSON.stringify(saveProjectPayload)
72
- });
73
- if (!response.ok) {
74
- if (response.status === 401) {
75
- throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
76
- }
77
- throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project save failed^:\n`, {
78
- autoColor: false
79
- });
80
- }
81
- (0, _terminal.terminal)("^g^+Project saved successfully!^:\n");
82
- const body = await response.text();
83
- const parseResult = saveProjectApiResponseSchema.safeParse(body);
84
- if (!parseResult.success) {
85
- (0, _terminal.terminal)(`^yWarning: Could not parse save project response:^:\n`);
86
- (0, _terminal.terminal)(body + "\n");
87
- return;
88
- }
89
- const {
90
- id: projectId,
91
- enableFirstRunExperience
92
- } = parseResult.data;
93
- const dotEnvPath = path.join(projectPath, ".env");
94
- if (!(await fs.exists(dotEnvPath))) {
95
- await fs.writeFile(dotEnvPath, `${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}
96
- ${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}
97
- ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
98
- (0, _terminal.terminal)(`^g^+Created .env file with project credentials.^:\n`);
99
- return;
100
- }
101
- const envContent = await fs.readFile(dotEnvPath, "utf-8");
102
- const dotenvContent = dotenv.parse(envContent);
103
- let contentToAppend = "";
104
- const projectCredentialsEnvVars = {
105
- [_constants2.PROJECT_ID_ENV_VAR_KEY]: projectId,
106
- [_constants2.WORKSPACE_ID_ENV_VAR_KEY]: workspaceId,
107
- [_constants2.API_KEY_ENV_VAR_KEY]: apiKey
108
- };
109
- for (const key in projectCredentialsEnvVars) {
110
- if (dotenvContent[key] === projectCredentialsEnvVars[key]) {
111
- continue;
112
- }
113
- if (dotenvContent[key]) {
114
- (0, _terminal.terminal)(`^yWarning: Existing ${key} in .env has invalid value. Appending correct value.^:\n`);
115
- }
116
- contentToAppend += `${key}=${projectCredentialsEnvVars[key]}\n`;
117
- }
118
- if (contentToAppend) {
119
- await fs.appendFile(dotEnvPath, contentToAppend + "\n");
120
- (0, _terminal.terminal)(`^g^+Updated .env file with project credentials.^:\n`);
121
- }
122
- return {
123
- projectId,
124
- enableFirstRunExperience
125
- };
126
- }
127
- const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
128
- message: "Name cannot be a UUID"
129
- });
130
- const validateProjectName = projectName => {
131
- const validation = projectNameSchema.safeParse(projectName);
132
- if (!validation.success) {
133
- return {
134
- isValid: false,
135
- errorMessage: validation.error.errors[0].message
136
- };
137
- }
138
- return {
139
- isValid: true
140
- };
141
- };
142
- exports.validateProjectName = validateProjectName;
143
- const validateIntunedProject = async () => {
144
- const currentDirectoryToSave = process.cwd();
145
- const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
146
- const validationSteps = [{
147
- name: "build",
148
- check: async () => {
149
- try {
150
- const buildResult = await (0, _build.runBuild)();
151
- if (!buildResult) {
152
- return {
153
- isValid: false,
154
- errorMessage: "Build failed"
155
- };
156
- }
157
- return {
158
- isValid: true
159
- };
160
- } catch (error) {
161
- return {
162
- isValid: false,
163
- errorMessage: "Build failed"
164
- };
165
- }
166
- }
167
- }, {
168
- name: intunedSettingsFile.name,
169
- check: async () => {
170
- try {
171
- const intunedJsonPath = path.join(currentDirectoryToSave, intunedSettingsFile.name);
172
- await fs.exists(intunedJsonPath);
173
- return {
174
- isValid: true
175
- };
176
- } catch (error) {
177
- return {
178
- isValid: false,
179
- errorMessage: `${intunedSettingsFile.name} file not found`
180
- };
181
- }
182
- }
183
- }, {
184
- name: "api folder",
185
- check: async () => {
186
- try {
187
- const apiFolderPath = path.join(currentDirectoryToSave, "api");
188
- await fs.access(apiFolderPath);
189
- return {
190
- isValid: true
191
- };
192
- } catch (error) {
193
- return {
194
- isValid: false,
195
- errorMessage: "API folder not found"
196
- };
197
- }
198
- }
199
- }];
200
- for (const step of validationSteps) {
201
- const result = await step.check();
202
- if (!result.isValid) {
203
- return result;
204
- }
205
- }
206
- return {
207
- isValid: true
208
- };
209
- };
210
- exports.validateIntunedProject = validateIntunedProject;
211
- function ignoreFilesByPattern(filePath, patterns, projectPath) {
212
- const relativePath = path.relative(projectPath, filePath);
213
- if (relativePath.startsWith("node_modules")) {
214
- return true;
215
- }
216
- for (const pattern of patterns) {
217
- if (!pattern || pattern.startsWith("#")) continue;
218
- if (pattern.startsWith("!")) {
219
- if ((0, _minimatch.minimatch)(relativePath, pattern.substring(1))) {
220
- return false;
221
- }
222
- } else if ((0, _minimatch.minimatch)(relativePath, pattern)) {
223
- return true;
224
- }
225
- }
226
- return false;
227
- }
228
- function listFilesNotIgnored(projectPath, ignorePatterns) {
229
- const results = [];
230
- function traverseDirectory(dirPath) {
231
- try {
232
- const entries = fs.readdirSync(dirPath);
233
- for (const entry of entries) {
234
- const fullPath = path.join(dirPath, entry);
235
- if (ignoreFilesByPattern(fullPath, ignorePatterns, projectPath)) {
236
- continue;
237
- }
238
- try {
239
- const stats = fs.statSync(fullPath);
240
- if (stats.isDirectory()) {
241
- traverseDirectory(fullPath);
242
- } else if (stats.isFile()) {
243
- results.push(path.relative(projectPath, fullPath));
244
- }
245
- } catch (error) {
246
- (0, _terminal.terminal)(`^yWarning: Could not access ${fullPath}^:\n`);
247
- }
248
- }
249
- } catch (error) {
250
- (0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
251
- }
252
- }
253
- traverseDirectory(projectPath);
254
- return results;
255
- }
256
- async function convertProjectToCodeTree(projectPath) {
257
- const filesToSave = listFilesNotIgnored(projectPath, _projectExclusions.default);
258
- const filesToSaveText = " " + filesToSave.join("\n ");
259
- (0, _terminal.terminal)("^CFiles to be saved:^:\n");
260
- (0, _terminal.terminal)(filesToSaveText + "\n");
261
- function readDirectory(dirPath) {
262
- const tree = {};
263
- try {
264
- const entries = fs.readdirSync(dirPath);
265
- for (const entry of entries) {
266
- const entryPath = path.join(dirPath, entry);
267
- if (ignoreFilesByPattern(entryPath, _projectExclusions.default, projectPath)) {
268
- continue;
269
- }
270
- try {
271
- const stats = fs.statSync(entryPath);
272
- if (stats.isFile()) {
273
- try {
274
- const content = fs.readFileSync(entryPath, "utf-8");
275
- tree[entry] = {
276
- file: {
277
- contents: content
278
- }
279
- };
280
- } catch (error) {
281
- (0, _terminal.terminal)(`^yWarning: Could not read file ${entryPath}^:\n`);
282
- }
283
- } else if (stats.isDirectory()) {
284
- const subTree = readDirectory(entryPath);
285
- if (Object.keys(subTree).length > 0) {
286
- tree[entry] = {
287
- directory: subTree
288
- };
289
- }
290
- }
291
- } catch (error) {
292
- (0, _terminal.terminal)(`^yWarning: Could not access ${entryPath}^:\n`);
293
- }
294
- }
295
- } catch (error) {
296
- (0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
297
- }
298
- return tree;
299
- }
300
- const tree = readDirectory(projectPath);
301
- mapToIDEParams(tree);
302
- return tree;
303
- }
304
- function mapToIDEParams(tree) {
305
- if (!tree) {
306
- return;
307
- }
308
- if (!tree["parameters"] || "file" in tree["parameters"]) {
309
- return;
310
- }
311
- const apiParametersMap = {};
312
- const cliParameters = Object.keys(tree["parameters"].directory);
313
- const ____testParameters = {
314
- directory: {}
315
- };
316
- for (const parameterKey of cliParameters) {
317
- const parameter = tree["parameters"].directory[parameterKey];
318
- if ("directory" in parameter) {
319
- continue;
320
- }
321
- if ((0, _lodash.isEmpty)(parameter.file.contents)) {
322
- continue;
323
- }
324
- const parameterPayload = JSON.parse(parameter.file.contents);
325
- if (!parameterPayload["__api-name"]) {
326
- continue;
327
- }
328
- const api = parameterPayload["__api-name"];
329
- const {
330
- "__api-name": _,
331
- ...parameterValue
332
- } = parameterPayload;
333
- const testParameter = {
334
- name: parameterKey.replace(".json", ""),
335
- lastUsed: false,
336
- id: (0, _uuid.v4)(),
337
- value: JSON.stringify(parameterValue)
338
- };
339
- if (!apiParametersMap[api]) {
340
- apiParametersMap[api] = [];
341
- }
342
- apiParametersMap[api].push(testParameter);
343
- }
344
- for (const api in apiParametersMap) {
345
- if (apiParametersMap[api].length > 0) {
346
- apiParametersMap[api][apiParametersMap[api].length - 1].lastUsed = true;
347
- }
348
- ____testParameters.directory[`${api}.json`] = {
349
- file: {
350
- contents: JSON.stringify(apiParametersMap[api], null, 2)
351
- }
352
- };
353
- }
354
- delete tree["parameters"];
355
- tree["____testParameters"] = ____testParameters;
356
- return;
357
- }
@@ -1,72 +0,0 @@
1
- import { RunErrorOptions } from "../../runtime/export";
2
- export declare const apiNotFoundErrorCode = "APINotFoundError";
3
- export declare const invalidApiErrorCode = "InvalidAPIError";
4
- export declare const invalidCheckErrorCode = "InvalidCheckError";
5
- export declare const abortedErrorCode = "AbortedError";
6
- export declare const authRequiredErrorCode = "AuthRequiredError";
7
- export declare const authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
8
- export declare const authCheckFailedErrorCode = "AuthCheckFailedError";
9
- export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
10
- export declare const automationError = "AutomationError";
11
- export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
12
- export declare const resultTooBigErrorCode = "ResultTooBigError";
13
- export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError", "ResultTooBigError"];
14
- export type RunAutomationErrorCode = typeof runAutomationErrorCodes[number];
15
- export declare abstract class RunAutomationError<T = any> {
16
- code: RunAutomationErrorCode;
17
- statusCode: number;
18
- wrapped: boolean;
19
- message: string;
20
- cause?: RunAutomationError;
21
- details?: T;
22
- get json(): {
23
- code: "APINotFoundError" | "InvalidAPIError" | "InvalidCheckError" | "AbortedError" | "AuthRequiredError" | "AuthCheckNotFoundError" | "AuthCheckFailedError" | "MaxLevelsExceededError" | "AutomationError" | "InternalInvalidInputError" | "ResultTooBigError";
24
- details: T | undefined;
25
- cause: any;
26
- };
27
- }
28
- export declare class ApiNotFoundError extends RunAutomationError {
29
- constructor(apiName: string);
30
- }
31
- export declare class InvalidApiError extends RunAutomationError {
32
- constructor(message: string);
33
- }
34
- export declare class InvalidCheckError extends RunAutomationError {
35
- constructor(message: string, cause?: RunAutomationError);
36
- }
37
- export declare class AbortedError extends RunAutomationError {
38
- constructor();
39
- }
40
- export declare class AuthRequiredError extends RunAutomationError {
41
- constructor();
42
- }
43
- export declare class AuthCheckNotFoundError extends RunAutomationError {
44
- constructor();
45
- }
46
- export declare class AuthCheckFailedError extends RunAutomationError {
47
- constructor();
48
- }
49
- export declare class MaxLevelsExceededError extends RunAutomationError<{
50
- levels: number;
51
- }> {
52
- constructor(levels: number);
53
- }
54
- export declare class AutomationError extends RunAutomationError<{
55
- name?: string;
56
- message?: string;
57
- statusCode?: number;
58
- errorCode?: string;
59
- options?: RunErrorOptions;
60
- }> {
61
- error: any;
62
- constructor(error: any);
63
- }
64
- export declare class InternalInvalidInputError extends RunAutomationError {
65
- constructor(message: string, details?: any);
66
- }
67
- export declare class ResultTooBigError extends RunAutomationError<{
68
- sizeInBytes: number;
69
- maxSizeInBytes: number;
70
- }> {
71
- constructor(sizeInBytes: number, maxSizeInBytes: number);
72
- }
@@ -1,169 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.runAutomationErrorCodes = exports.resultTooBigErrorCode = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.ResultTooBigError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
7
- var _runtime = require("../../runtime");
8
- var playwright = _interopRequireWildcard(require("playwright-core"));
9
- 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); }
10
- 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; }
11
- const apiNotFoundErrorCode = exports.apiNotFoundErrorCode = "APINotFoundError";
12
- const invalidApiErrorCode = exports.invalidApiErrorCode = "InvalidAPIError";
13
- const invalidCheckErrorCode = exports.invalidCheckErrorCode = "InvalidCheckError";
14
- const abortedErrorCode = exports.abortedErrorCode = "AbortedError";
15
- const authRequiredErrorCode = exports.authRequiredErrorCode = "AuthRequiredError";
16
- const authCheckNotFoundErrorCode = exports.authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
17
- const authCheckFailedErrorCode = exports.authCheckFailedErrorCode = "AuthCheckFailedError";
18
- const maxLevelsExceededErrorCode = exports.maxLevelsExceededErrorCode = "MaxLevelsExceededError";
19
- const automationError = exports.automationError = "AutomationError";
20
- const internalInvalidInputErrorCode = exports.internalInvalidInputErrorCode = "InternalInvalidInputError";
21
- const resultTooBigErrorCode = exports.resultTooBigErrorCode = "ResultTooBigError";
22
- const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError, internalInvalidInputErrorCode, resultTooBigErrorCode];
23
- class RunAutomationError {
24
- wrapped = false;
25
- get json() {
26
- return {
27
- code: this.code,
28
- details: this.details,
29
- cause: this.cause?.json
30
- };
31
- }
32
- }
33
- exports.RunAutomationError = RunAutomationError;
34
- class ApiNotFoundError extends RunAutomationError {
35
- constructor(apiName) {
36
- super();
37
- this.code = apiNotFoundErrorCode;
38
- this.statusCode = 404;
39
- this.message = `API ${apiName} not found`;
40
- }
41
- }
42
- exports.ApiNotFoundError = ApiNotFoundError;
43
- class InvalidApiError extends RunAutomationError {
44
- constructor(message) {
45
- super();
46
- this.code = invalidApiErrorCode;
47
- this.statusCode = 400;
48
- this.message = `API is invalid: ${message}`;
49
- }
50
- }
51
- exports.InvalidApiError = InvalidApiError;
52
- class InvalidCheckError extends RunAutomationError {
53
- constructor(message, cause) {
54
- super();
55
- this.code = invalidCheckErrorCode;
56
- this.statusCode = 400;
57
- this.message = message;
58
- this.cause = cause;
59
- }
60
- }
61
- exports.InvalidCheckError = InvalidCheckError;
62
- class AbortedError extends RunAutomationError {
63
- constructor() {
64
- super();
65
- this.code = abortedErrorCode;
66
- this.statusCode = 200;
67
- this.message = "Operation was aborted";
68
- }
69
- }
70
- exports.AbortedError = AbortedError;
71
- class AuthRequiredError extends RunAutomationError {
72
- constructor() {
73
- super();
74
- this.code = authRequiredErrorCode;
75
- this.statusCode = 401;
76
- this.message = "Authentication is required";
77
- this.wrapped = true;
78
- }
79
- }
80
- exports.AuthRequiredError = AuthRequiredError;
81
- class AuthCheckNotFoundError extends RunAutomationError {
82
- constructor() {
83
- super();
84
- this.code = authCheckNotFoundErrorCode;
85
- this.statusCode = 404;
86
- this.message = "Auth check not found";
87
- }
88
- }
89
- exports.AuthCheckNotFoundError = AuthCheckNotFoundError;
90
- class AuthCheckFailedError extends RunAutomationError {
91
- constructor() {
92
- super();
93
- this.code = authCheckFailedErrorCode;
94
- this.statusCode = 401;
95
- this.message = "auth session check failed";
96
- this.wrapped = true;
97
- }
98
- }
99
- exports.AuthCheckFailedError = AuthCheckFailedError;
100
- class MaxLevelsExceededError extends RunAutomationError {
101
- constructor(levels) {
102
- super();
103
- this.code = maxLevelsExceededErrorCode;
104
- this.statusCode = 400;
105
- this.message = `Max levels exceeded. Only ${levels} levels are supported`;
106
- this.details = {
107
- levels
108
- };
109
- }
110
- }
111
- exports.MaxLevelsExceededError = MaxLevelsExceededError;
112
- class AutomationError extends RunAutomationError {
113
- constructor(error) {
114
- super();
115
- this.error = error;
116
- this.code = automationError;
117
- if (error instanceof playwright.errors.TimeoutError) {
118
- this.statusCode = 500;
119
- this.message = `[${error.name}] ${error.message}`;
120
- this.details = {
121
- name: error.name,
122
- message: error.message
123
- };
124
- return;
125
- }
126
- if (error instanceof _runtime.RunError) {
127
- this.wrapped = true;
128
- this.statusCode = error.options.status_code ?? 500;
129
- this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
130
- this.details = {
131
- name: error.name,
132
- statusCode: error.options.status_code,
133
- errorCode: error.options.error_code,
134
- message: error.message,
135
- options: error.options
136
- };
137
- }
138
- this.statusCode = 500;
139
- this.message = `[${error?.name ?? error}] ${error?.message}`;
140
- this.details = {
141
- name: error?.name,
142
- message: error?.message
143
- };
144
- }
145
- }
146
- exports.AutomationError = AutomationError;
147
- class InternalInvalidInputError extends RunAutomationError {
148
- constructor(message, details) {
149
- super();
150
- this.code = internalInvalidInputErrorCode;
151
- this.statusCode = 500;
152
- this.message = message;
153
- this.details = details;
154
- }
155
- }
156
- exports.InternalInvalidInputError = InternalInvalidInputError;
157
- class ResultTooBigError extends RunAutomationError {
158
- constructor(sizeInBytes, maxSizeInBytes) {
159
- super();
160
- this.code = resultTooBigErrorCode;
161
- this.statusCode = 413;
162
- this.message = `Automation result is too big. Size: ${Math.round(sizeInBytes / 1024 / 1024 * 100) / 100}MB, Max allowed: ${Math.round(maxSizeInBytes / 1024 / 1024 * 100) / 100}MB`;
163
- this.details = {
164
- sizeInBytes,
165
- maxSizeInBytes
166
- };
167
- }
168
- }
169
- exports.ResultTooBigError = ResultTooBigError;