@intuned/runtime-dev 0.1.0-test.10 → 0.1.0-test.12

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 (103) hide show
  1. package/.babelrc +1 -2
  2. package/dist/commands/api/run.js +170 -105
  3. package/dist/commands/api/run.ts +105 -0
  4. package/dist/commands/auth-sessions/load.js +26 -28
  5. package/dist/commands/auth-sessions/load.ts +30 -0
  6. package/dist/commands/auth-sessions/run-check.js +53 -52
  7. package/dist/commands/auth-sessions/run-check.ts +51 -0
  8. package/dist/commands/auth-sessions/run-create.js +96 -91
  9. package/dist/commands/auth-sessions/run-create.ts +91 -0
  10. package/dist/commands/browser/save-state.js +16 -14
  11. package/dist/commands/browser/save-state.ts +14 -0
  12. package/dist/commands/browser/start-browser.js +11 -11
  13. package/dist/commands/browser/start-browser.ts +11 -0
  14. package/dist/commands/build.js +108 -75
  15. package/dist/commands/build.ts +78 -0
  16. package/dist/commands/common/browserUtils.js +51 -53
  17. package/dist/commands/common/browserUtils.ts +45 -0
  18. package/dist/commands/common/getDefaultExportFromFile.js +12 -17
  19. package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
  20. package/dist/commands/common/getFirstLineNumber.js +93 -93
  21. package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
  22. package/dist/commands/common/getFirstLineNumber.ts +96 -0
  23. package/dist/commands/common/sendMessageToClient.js +4 -9
  24. package/dist/commands/common/sendMessageToClient.ts +3 -0
  25. package/dist/commands/common/utils/fileUtils.js +22 -32
  26. package/dist/commands/common/utils/fileUtils.ts +23 -0
  27. package/dist/commands/common/utils/settings.js +19 -27
  28. package/dist/commands/common/utils/settings.ts +22 -0
  29. package/dist/commands/common/utils/unixSocket.js +43 -43
  30. package/dist/commands/common/utils/unixSocket.ts +38 -0
  31. package/dist/commands/common/utils/webTemplate.js +27 -29
  32. package/dist/commands/common/utils/webTemplate.ts +22 -0
  33. package/dist/commands/interface/run.js +151 -150
  34. package/dist/commands/interface/run.ts +156 -0
  35. package/dist/commands/ts-check.js +49 -49
  36. package/dist/commands/ts-check.ts +50 -0
  37. package/dist/common/Logger/Logger/index.d.ts +1 -1
  38. package/dist/common/Logger/Logger/index.js +42 -55
  39. package/dist/common/Logger/Logger/index.ts +53 -0
  40. package/dist/common/Logger/Logger/types.js +1 -5
  41. package/dist/common/Logger/Logger/types.ts +1 -0
  42. package/dist/common/Logger/index.d.ts +1 -1
  43. package/dist/common/Logger/index.js +42 -55
  44. package/dist/common/Logger/index.ts +53 -0
  45. package/dist/common/Logger/types.js +1 -5
  46. package/dist/common/Logger/types.ts +1 -0
  47. package/dist/common/asyncLocalStorage/index.js +8 -16
  48. package/dist/common/asyncLocalStorage/index.ts +9 -0
  49. package/dist/common/cleanEnvironmentVariables.js +12 -16
  50. package/dist/common/cleanEnvironmentVariables.ts +10 -0
  51. package/dist/common/constants.js +1 -7
  52. package/dist/common/constants.ts +1 -0
  53. package/dist/common/contextStorageStateHelpers.js +38 -47
  54. package/dist/common/contextStorageStateHelpers.ts +43 -0
  55. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  56. package/dist/common/getPlaywrightConstructs.js +196 -177
  57. package/dist/common/getPlaywrightConstructs.ts +181 -0
  58. package/dist/common/jwtTokenManager.js +79 -76
  59. package/dist/common/jwtTokenManager.ts +71 -0
  60. package/dist/common/runApi/errors.d.ts +1 -1
  61. package/dist/common/runApi/errors.js +150 -159
  62. package/dist/common/runApi/errors.ts +154 -0
  63. package/dist/common/runApi/index.d.ts +4 -4
  64. package/dist/common/runApi/index.js +220 -269
  65. package/dist/common/runApi/index.ts +253 -0
  66. package/dist/common/runApi/types.d.ts +1 -1
  67. package/dist/common/runApi/types.js +56 -49
  68. package/dist/common/runApi/types.ts +43 -0
  69. package/dist/common/settingsSchema.js +10 -15
  70. package/dist/common/settingsSchema.ts +9 -0
  71. package/dist/common/telemetry.js +30 -28
  72. package/dist/common/telemetry.ts +23 -0
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +4 -69
  75. package/dist/index.ts +4 -0
  76. package/dist/runtime/RunError.d.ts +1 -1
  77. package/dist/runtime/RunError.js +11 -18
  78. package/dist/runtime/RunError.ts +12 -0
  79. package/dist/runtime/downloadDirectory.js +13 -19
  80. package/dist/runtime/downloadDirectory.ts +13 -0
  81. package/dist/runtime/enums.d.ts +1 -11
  82. package/dist/runtime/enums.js +12 -18
  83. package/dist/runtime/enums.ts +12 -0
  84. package/dist/runtime/executionHelpers.test.ts +51 -0
  85. package/dist/runtime/export.d.ts +1 -202
  86. package/dist/runtime/extendPayload.d.ts +1 -1
  87. package/dist/runtime/extendPayload.js +15 -21
  88. package/dist/runtime/extendPayload.ts +15 -0
  89. package/dist/runtime/extendTimeout.js +21 -28
  90. package/dist/runtime/extendTimeout.ts +24 -0
  91. package/dist/runtime/index.d.ts +7 -7
  92. package/dist/runtime/index.js +6 -53
  93. package/dist/runtime/index.ts +6 -0
  94. package/dist/runtime/requestMoreInfo.js +16 -23
  95. package/dist/runtime/requestMoreInfo.ts +18 -0
  96. package/dist/runtime/runInfo.d.ts +1 -1
  97. package/dist/runtime/runInfo.js +14 -21
  98. package/dist/runtime/runInfo.ts +15 -0
  99. package/package.json +3 -2
  100. package/tsconfig.json +1 -1
  101. package/dist/runtime/enums.d.js +0 -5
  102. package/dist/runtime/executionHelpers.test.js +0 -53
  103. package/dist/runtime/export.d.js +0 -5
@@ -0,0 +1,154 @@
1
+ import { RunError } from "../../runtime";
2
+ import * as playwright from "@intuned/playwright-core";
3
+ export const apiNotFoundErrorCode = "APINotFoundError";
4
+ export const invalidApiErrorCode = "InvalidAPIError";
5
+ export const invalidCheckErrorCode = "InvalidCheckError";
6
+ export const abortedErrorCode = "AbortedError";
7
+ export const authRequiredErrorCode = "AuthRequiredError";
8
+ export const authCheckNotFoundErrorCode = "AuthCheckNotFoundError";
9
+ export const authCheckFailedErrorCode = "AuthCheckFailedError";
10
+ export const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
11
+ export const automationError = "AutomationError";
12
+ export const runAutomationErrorCodes = [apiNotFoundErrorCode, invalidApiErrorCode, invalidCheckErrorCode, abortedErrorCode, authRequiredErrorCode, authCheckNotFoundErrorCode, authCheckFailedErrorCode, maxLevelsExceededErrorCode, automationError];
13
+ export class RunAutomationError {
14
+ wrapped = false;
15
+ get apiResponse() {
16
+ if (this.wrapped) {
17
+ return {
18
+ status: 200,
19
+ body: {
20
+ status: this.statusCode,
21
+ error: this.code,
22
+ message: this.message
23
+ }
24
+ };
25
+ }
26
+ return {
27
+ status: this.statusCode,
28
+ body: {
29
+ error: this.code,
30
+ message: this.message
31
+ }
32
+ };
33
+ }
34
+ get json() {
35
+ var _this$cause;
36
+ return {
37
+ code: this.code,
38
+ details: this.details,
39
+ cause: (_this$cause = this.cause) === null || _this$cause === void 0 ? void 0 : _this$cause.json
40
+ };
41
+ }
42
+ }
43
+ export class ApiNotFoundError extends RunAutomationError {
44
+ constructor(apiName) {
45
+ super();
46
+ this.code = apiNotFoundErrorCode;
47
+ this.statusCode = 404;
48
+ this.message = `API ${apiName} not found`;
49
+ }
50
+ }
51
+ export class InvalidApiError extends RunAutomationError {
52
+ constructor(message) {
53
+ super();
54
+ this.code = invalidApiErrorCode;
55
+ this.statusCode = 400;
56
+ this.message = `API is invalid: ${message}`;
57
+ }
58
+ }
59
+ export class InvalidCheckError extends RunAutomationError {
60
+ constructor(message, cause) {
61
+ super();
62
+ this.code = invalidCheckErrorCode;
63
+ this.statusCode = 400;
64
+ this.message = message;
65
+ this.cause = cause;
66
+ }
67
+ }
68
+ export class AbortedError extends RunAutomationError {
69
+ constructor() {
70
+ super();
71
+ this.code = abortedErrorCode;
72
+ this.statusCode = 200;
73
+ this.message = "Operation was aborted";
74
+ }
75
+ }
76
+ export class AuthRequiredError extends RunAutomationError {
77
+ constructor() {
78
+ super();
79
+ this.code = authRequiredErrorCode;
80
+ this.statusCode = 401;
81
+ this.message = "Authentication is required";
82
+ }
83
+ }
84
+ export class AuthCheckNotFoundError extends RunAutomationError {
85
+ constructor() {
86
+ super();
87
+ this.code = authCheckNotFoundErrorCode;
88
+ this.statusCode = 404;
89
+ this.message = "Auth check not found";
90
+ }
91
+ }
92
+ export class AuthCheckFailedError extends RunAutomationError {
93
+ constructor() {
94
+ super();
95
+ this.code = authCheckFailedErrorCode;
96
+ this.statusCode = 401;
97
+ this.message = "auth session check failed";
98
+ }
99
+ get apiResponse() {
100
+ return {
101
+ status: 200,
102
+ body: {
103
+ status: this.statusCode,
104
+ error: "AUTH_SESSION_CHECK_FAILED",
105
+ message: this.message
106
+ }
107
+ };
108
+ }
109
+ }
110
+ export class MaxLevelsExceededError extends RunAutomationError {
111
+ constructor(levels) {
112
+ super();
113
+ this.code = maxLevelsExceededErrorCode;
114
+ this.statusCode = 400;
115
+ this.message = `Max levels exceeded. Only ${levels} levels are supported`;
116
+ this.details = {
117
+ levels
118
+ };
119
+ }
120
+ }
121
+ export class AutomationError extends RunAutomationError {
122
+ constructor(error) {
123
+ super();
124
+ this.error = error;
125
+ this.code = automationError;
126
+ if (error instanceof playwright.errors.TimeoutError) {
127
+ this.statusCode = 500;
128
+ this.message = `[${error.name}] ${error.message}`;
129
+ this.details = {
130
+ name: error.name,
131
+ message: error.message
132
+ };
133
+ return;
134
+ }
135
+ if (error instanceof RunError) {
136
+ this.wrapped = true;
137
+ this.statusCode = error.options.status_code ?? 500;
138
+ this.message = `[${error.options.error_code ?? error.name}] ${error.message}`;
139
+ this.details = {
140
+ name: error.name,
141
+ statusCode: error.options.status_code,
142
+ errorCode: error.options.error_code,
143
+ message: error.message,
144
+ options: error.options
145
+ };
146
+ }
147
+ this.statusCode = 500;
148
+ this.message = `[${(error === null || error === void 0 ? void 0 : error.name) ?? error}] ${error === null || error === void 0 ? void 0 : error.message}`;
149
+ this.details = {
150
+ name: error === null || error === void 0 ? void 0 : error.name,
151
+ message: error === null || error === void 0 ? void 0 : error.message
152
+ };
153
+ }
154
+ }
@@ -1,9 +1,9 @@
1
1
  import { Result } from "neverthrow";
2
- import { RunAutomationError } from "./errors";
2
+ import { RunAutomationError } from "./errors.js";
3
3
  import { Page, BrowserContext } from "@intuned/playwright-core";
4
- import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
5
- export * from "./types";
6
- export * from "./errors";
4
+ import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types.js";
5
+ export * from "./types.js";
6
+ export * from "./errors.js";
7
7
  export declare function runApiGenerator<ResultType = any, _YieldType = any, _NextType = any>(params: ExtendedRunApiParameters & {
8
8
  retrieveSession: true;
9
9
  }): AsyncGenerator<_YieldType, RunApiResult<ResultType, RunApiResultWithSessionOk>, _NextType>;