@intuned/runtime-dev 1.3.0-dev-52 → 1.3.0-responseLimits.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 (131) hide show
  1. package/.babelrc +2 -2
  2. package/CHANGELOG.md +5 -1
  3. package/bin/intuned +2 -0
  4. package/dist/commands/api/run.js +4 -3
  5. package/dist/commands/common/browserUtils.d.ts +1 -1
  6. package/dist/commands/common/browserUtils.js +1 -1
  7. package/dist/commands/common/getFirstLineNumber.js +2 -4
  8. package/dist/commands/interface/run.js +5 -6
  9. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  10. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  11. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  12. package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
  13. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  14. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  15. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  16. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
  17. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  18. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
  19. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  20. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  21. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  22. package/dist/commands/intuned-cli/commands/command.js +9 -0
  23. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  24. package/dist/commands/intuned-cli/commands/deploy.command.js +46 -0
  25. package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
  26. package/dist/commands/intuned-cli/commands/index.js +170 -0
  27. package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  28. package/dist/commands/intuned-cli/commands/init.command.js +13 -0
  29. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  30. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  31. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  32. package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
  33. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +20 -0
  34. package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
  35. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  36. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
  37. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  38. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
  39. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  40. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
  41. package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
  42. package/dist/commands/intuned-cli/commands/types.js +21 -0
  43. package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
  44. package/dist/commands/intuned-cli/constants/index.js +25 -0
  45. package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
  46. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
  47. package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
  48. package/dist/commands/intuned-cli/controller/api.js +181 -0
  49. package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
  50. package/dist/commands/intuned-cli/controller/authSession.js +292 -0
  51. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  52. package/dist/commands/intuned-cli/controller/build.js +36 -0
  53. package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
  54. package/dist/commands/{deploy/utils.js → intuned-cli/controller/deploy.js} +115 -109
  55. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  56. package/dist/commands/intuned-cli/controller/index.js +46 -0
  57. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  58. package/dist/commands/intuned-cli/helpers/api.js +19 -0
  59. package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
  60. package/dist/commands/intuned-cli/helpers/auth.js +129 -0
  61. package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  62. package/dist/commands/intuned-cli/helpers/backend.js +26 -0
  63. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  64. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  65. package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
  66. package/dist/commands/intuned-cli/helpers/errors.js +55 -0
  67. package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
  68. package/dist/commands/intuned-cli/helpers/index.js +115 -0
  69. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
  70. package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
  71. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  72. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  73. package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  74. package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  75. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  76. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  77. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  78. package/dist/commands/intuned-cli/helpers/validation.js +12 -0
  79. package/dist/commands/intuned-cli/index.d.ts +1 -0
  80. package/dist/commands/intuned-cli/index.js +16 -0
  81. package/dist/commands/intuned-cli/main.d.ts +1 -0
  82. package/dist/commands/intuned-cli/main.js +15 -0
  83. package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -34
  84. package/dist/{common/cli → commands/intuned-cli}/types.js +1 -2
  85. package/dist/common/assets/browser_scripts.js +2509 -2143
  86. package/dist/common/constants.d.ts +1 -0
  87. package/dist/common/constants.js +2 -1
  88. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  89. package/dist/common/getPlaywrightConstructs.js +4 -12
  90. package/dist/common/jwtTokenManager.js +3 -5
  91. package/dist/common/runApi/errors.d.ts +9 -2
  92. package/dist/common/runApi/errors.js +21 -8
  93. package/dist/common/runApi/index.d.ts +4 -1
  94. package/dist/common/runApi/index.js +33 -21
  95. package/dist/common/runApi/types.d.ts +140 -9
  96. package/dist/common/runApi/types.js +28 -27
  97. package/dist/runtime/executionHelpers.test.js +3 -4
  98. package/dist/runtime/export.d.ts +15 -0
  99. package/dist/runtime/extendPayload.js +1 -1
  100. package/package.json +14 -13
  101. package/tsconfig.json +2 -1
  102. package/bin/check-auth-session +0 -3
  103. package/bin/cli-build +0 -3
  104. package/bin/create-auth-session +0 -3
  105. package/bin/deploy +0 -3
  106. package/bin/init +0 -3
  107. package/bin/run-api +0 -3
  108. package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
  109. package/dist/commands/cli-auth-sessions/check.js +0 -40
  110. package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
  111. package/dist/commands/cli-auth-sessions/create.js +0 -53
  112. package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
  113. package/dist/commands/cli-auth-sessions/utils.js +0 -285
  114. package/dist/commands/cli-build/cli-build.d.ts +0 -2
  115. package/dist/commands/cli-build/cli-build.js +0 -20
  116. package/dist/commands/deploy/deploy.d.ts +0 -2
  117. package/dist/commands/deploy/deploy.js +0 -47
  118. package/dist/commands/deploy/utils.d.ts +0 -16
  119. package/dist/commands/init/init.d.ts +0 -2
  120. package/dist/commands/init/init.js +0 -22
  121. package/dist/commands/init/utils.d.ts +0 -11
  122. package/dist/commands/init/utils.js +0 -181
  123. package/dist/commands/run-api-cli/run-api.d.ts +0 -2
  124. package/dist/commands/run-api-cli/run-api.js +0 -57
  125. package/dist/commands/run-api-cli/utils.d.ts +0 -9
  126. package/dist/commands/run-api-cli/utils.js +0 -144
  127. package/dist/common/cli/cliReadme.d.ts +0 -1
  128. package/dist/common/cli/cliReadme.js +0 -92
  129. package/dist/common/cli/constants.d.ts +0 -33
  130. package/dist/common/cli/constants.js +0 -39
  131. package/dist/common/cli/utils.d.ts +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.3.0-dev-52",
3
+ "version": "1.3.0-responseLimits.1",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -29,6 +29,7 @@
29
29
  "intuned-auth-session-refresh": "vite-node ./src/commands/auth/run-refresh.ts",
30
30
  "intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
31
31
  "intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
32
+ "intuned": "vite-node ./src/commands/intuned-cli/main.ts",
32
33
  "build": "rm -rf dist && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && cp -r ./src/common/assets dist/common/assets",
33
34
  "test": "vitest run",
34
35
  "test:watch": "vitest",
@@ -50,12 +51,7 @@
50
51
  "intuned-browser-start": "./bin/intuned-browser-start",
51
52
  "intuned-browser-save-state": "./bin/intuned-browser-save-state",
52
53
  "intuned-ts-check": "./bin/intuned-ts-check",
53
- "init": "./bin/init",
54
- "run-api": "./bin/run-api",
55
- "deploy": "./bin/deploy",
56
- "cli-build": "./bin/cli-build",
57
- "create-auth-session": "./bin/create-auth-session",
58
- "check-auth-session": "./bin/check-auth-session"
54
+ "intuned": "./bin/intuned"
59
55
  },
60
56
  "dependencies": {
61
57
  "@babel/plugin-syntax-dynamic-import": "7.8.3",
@@ -69,9 +65,8 @@
69
65
  "@types/node": "20.4.1",
70
66
  "applicationinsights": "2.9.2",
71
67
  "babel-plugin-dynamic-import-node": "2.3.3",
72
- "boxen": "8.0.1",
73
68
  "chalk": "^4.1.2",
74
- "commander": "^11.0.0",
69
+ "commander": "14.0.0",
75
70
  "cross-fetch": "^4.0.0",
76
71
  "dotenv": "^16.3.1",
77
72
  "fs-extra": "^11.3.0",
@@ -83,20 +78,21 @@
83
78
  "minimatch": "10.0.1",
84
79
  "nanoid": "3",
85
80
  "neverthrow": "6.1.0",
86
- "playwright": "npm:patchright@1.52.4",
87
- "playwright-core": "npm:patchright@1.52.4",
88
81
  "playwright-extra": "4.3.6",
89
82
  "prettier": "2.8.0",
90
83
  "promptly": "3.2.0",
91
84
  "rollup": "3.26.2",
92
85
  "source-map": "0.7.4",
86
+ "terminal-kit": "^3.1.2",
93
87
  "ts-morph": "21.0.1",
94
88
  "ts-node": "10.9.1",
95
89
  "tslib": "2.6.0",
96
90
  "typescript": "5.1.6",
97
91
  "uuid": "11.1.0",
98
92
  "wait-on": "7.2.0",
99
- "zod": "^3.21.4"
93
+ "zod": "^3.21.4",
94
+ "playwright": "^1.44.0",
95
+ "playwright-core": "^1.44.0"
100
96
  },
101
97
  "devDependencies": {
102
98
  "@babel/cli": "^7.23.4",
@@ -108,7 +104,9 @@
108
104
  "@ngneat/falso": "^7.2.0",
109
105
  "@types/jest": "^29.5.3",
110
106
  "@types/jsdom": "^21.1.1",
107
+ "@types/ms": "^2.1.0",
111
108
  "@types/promptly": "^3.0.4",
109
+ "@types/terminal-kit": "^2.5.7",
112
110
  "@types/wait-on": "^5.3.4",
113
111
  "@typescript-eslint/eslint-plugin": "^5.47.1",
114
112
  "@typescript-eslint/parser": "^7.5.0",
@@ -130,5 +128,8 @@
130
128
  "vite-node": "^1.1.3",
131
129
  "vite-plugin-babel-macros": "^1.0.6",
132
130
  "vitest": "^1.1.3"
131
+ },
132
+ "peerDependencies": {
133
+ "playwright": "*"
133
134
  }
134
- }
135
+ }
package/tsconfig.json CHANGED
@@ -12,7 +12,8 @@
12
12
  "sourceMap": false,
13
13
  "declaration": true,
14
14
  "emitDeclarationOnly": false,
15
- "skipLibCheck": true
15
+ "skipLibCheck": true,
16
+ "types": ["vitest/globals"]
16
17
  },
17
18
  "include": [
18
19
  "src/**/*.ts",
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/cli-auth-sessions/check.js");
package/bin/cli-build DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/cli-build/cli-build.js");
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/cli-auth-sessions/create.js");
package/bin/deploy DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/deploy/deploy.js");
package/bin/init DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/init/init.js");
package/bin/run-api DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../dist/commands/run-api-cli/run-api.js");
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _utils = require("./utils");
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- _dotenv.default.config({
10
- path: `.env`
11
- });
12
- _commander.program.description("Check an auth session, if it is still valid or not").argument("<auth-session>", "Name/id of the auth session instance to use").action(async authSession => {
13
- try {
14
- if (!authSession) {
15
- throw new Error("Auth session instance is required, provide an ID/name for it");
16
- }
17
- const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
18
- if (!_isAuthEnabled) {
19
- throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
20
- }
21
- const checkApiExists = await (0, _utils.ensureAuthApi)("check");
22
- if (!checkApiExists) {
23
- throw new Error("Auth check API not implemented, please create it in the auth sessions specified directory");
24
- }
25
- const {
26
- authSessionInstanceStoragePath
27
- } = await (0, _utils.retrieveAuthSessionInstance)(authSession, true);
28
- const checkResult = await (0, _utils.runCheckApi)(authSessionInstanceStoragePath);
29
- if (checkResult) {
30
- console.log(_chalk.default.green("✓ Auth session checked successfully"));
31
- } else {
32
- console.log(_chalk.default.red("✗ Auth session is not valid, check failed"));
33
- }
34
- } catch (error) {
35
- console.error(_chalk.default.red(`Failed to check auth session: ${error.message}`));
36
- } finally {
37
- process.exit(0);
38
- }
39
- });
40
- _commander.program.parse(process.argv);
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _utils = require("./utils");
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
- var _utils2 = require("../run-api-cli/utils");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- _dotenv.default.config({
11
- path: `.env`
12
- });
13
- _commander.program.description("Create an auth session").argument("[auth-session-name]", "Name/id of the auth session instance to use (optional)").option("-i, --input <input>", "Auth session input parameters file").action(async (authSessionName, options) => {
14
- try {
15
- const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
16
- if (!_isAuthEnabled) {
17
- throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
18
- }
19
- const authType = await (0, _utils.getAuthType)();
20
- let authSessionInstancePath;
21
- if (authType === "MANUAL") {
22
- const recorderConfig = await (0, _utils.ensureRecorderURLs)();
23
- const {
24
- startUrl,
25
- endUrl
26
- } = recorderConfig;
27
- console.log(_chalk.default.blue("Starting auth session recorder..."));
28
- const session = await (0, _utils.recordAuthSession)(startUrl, endUrl);
29
- authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, authSessionName, {});
30
- } else {
31
- const createApiExists = await (0, _utils.ensureAuthApi)("create");
32
- if (!createApiExists) {
33
- throw new Error("Auth session create API not implemented, please create it in the auth sessions specified directory");
34
- }
35
- const authSessionInput = (await (0, _utils2.loadParameters)(options === null || options === void 0 ? void 0 : options.input)) ?? {};
36
- const session = await (0, _utils.runCreateApi)(authSessionInput);
37
- if (!session) {
38
- console.error(_chalk.default.red("Failed to create auth session."));
39
- process.exit(1);
40
- }
41
- authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, authSessionName, authSessionInput);
42
- }
43
- console.log(_chalk.default.green("✓ Auth session created successfully!"));
44
- if (authSessionInstancePath) {
45
- console.log(_chalk.default.underline.green.white(`🔒 Auth session instance and metadata stored at ${authSessionInstancePath}`));
46
- }
47
- } catch (error) {
48
- console.error(_chalk.default.red(`Failed to create auth session: ${error.message}`));
49
- } finally {
50
- process.exit(0);
51
- }
52
- });
53
- _commander.program.parse(process.argv);
@@ -1,28 +0,0 @@
1
- import { StorageState } from "../../common/contextStorageStateHelpers";
2
- import { AuthSessionMetadata, AuthSessionType } from "../../common/cli/types";
3
- import * as playwright from "playwright-core";
4
- export declare function isAuthEnabled(): Promise<boolean>;
5
- export declare function getAuthType(): Promise<AuthSessionType>;
6
- export declare function ensureRecorderURLs(): Promise<{
7
- startUrl: string;
8
- endUrl: string;
9
- }>;
10
- export declare function ensureAuthApi(operation: "create" | "check"): Promise<boolean>;
11
- export declare function runCreateApi(authSessionInput: Record<string, any>): Promise<StorageState>;
12
- export declare function runCheckApi(authSessionPath: string): Promise<boolean>;
13
- export declare function runCreateApiViaCLI(authSessionInput: Record<string, any>): Promise<StorageState>;
14
- export declare function runCheckApiViaCLI(authSessionPath: string): Promise<boolean>;
15
- export declare function storeAuthSessionInstance(authSessionInstance: StorageState, customName?: string, authSessionInput?: Record<string, any>): Promise<string>;
16
- export declare function retrieveAuthSessionInstance(authSessionId: string, pathsOnly?: boolean): Promise<{
17
- authSessionInstanceStoragePath: string;
18
- authSessionInstanceMetadataPath: string;
19
- authSessionInstance?: undefined;
20
- metadata?: undefined;
21
- } | {
22
- authSessionInstance: StorageState;
23
- metadata: AuthSessionMetadata;
24
- authSessionInstanceStoragePath?: undefined;
25
- authSessionInstanceMetadataPath?: undefined;
26
- }>;
27
- export declare function getStorageState(context: playwright.BrowserContext): Promise<StorageState>;
28
- export declare function recordAuthSession(startUrl: string, endUrl: string): Promise<StorageState>;
@@ -1,285 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ensureAuthApi = ensureAuthApi;
7
- exports.ensureRecorderURLs = ensureRecorderURLs;
8
- exports.getAuthType = getAuthType;
9
- exports.getStorageState = getStorageState;
10
- exports.isAuthEnabled = isAuthEnabled;
11
- exports.recordAuthSession = recordAuthSession;
12
- exports.retrieveAuthSessionInstance = retrieveAuthSessionInstance;
13
- exports.runCheckApi = runCheckApi;
14
- exports.runCheckApiViaCLI = runCheckApiViaCLI;
15
- exports.runCreateApi = runCreateApi;
16
- exports.runCreateApiViaCLI = runCreateApiViaCLI;
17
- exports.storeAuthSessionInstance = storeAuthSessionInstance;
18
- var _path = _interopRequireDefault(require("path"));
19
- var _constants = require("../../common/constants");
20
- var fs = _interopRequireWildcard(require("fs-extra"));
21
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
22
- var _enums = require("../../runtime/enums");
23
- var _nanoid = require("nanoid");
24
- var _runApi = require("../../common/runApi");
25
- var _tsNodeImport = require("../common/tsNodeImport");
26
- var _promptly = require("promptly");
27
- var _utils = require("../../common/cli/utils");
28
- var _types = require("../../common/cli/types");
29
- var playwright = _interopRequireWildcard(require("playwright-core"));
30
- 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); }
31
- 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; }
32
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
- async function isAuthEnabled() {
34
- try {
35
- var _intunedJson$authSess;
36
- const intunedJson = await fs.readJSON(_path.default.join(process.cwd(), "Intuned.json"));
37
- return Boolean(intunedJson === null || intunedJson === void 0 || (_intunedJson$authSess = intunedJson.authSessions) === null || _intunedJson$authSess === void 0 ? void 0 : _intunedJson$authSess.enabled);
38
- } catch (error) {
39
- return false;
40
- }
41
- }
42
- async function getAuthType() {
43
- const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
44
- return projectAuthConfig.type ?? "API";
45
- }
46
- async function ensureRecorderURLs() {
47
- const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
48
- if (projectAuthConfig.type === "MANUAL" && projectAuthConfig.startUrl && projectAuthConfig.endUrl) {
49
- return {
50
- startUrl: projectAuthConfig.startUrl,
51
- endUrl: projectAuthConfig.endUrl
52
- };
53
- }
54
- throw new Error("Auth session recorder URLs are not configured, please configure them in Intuned.json");
55
- }
56
- async function ensureAuthApi(operation) {
57
- const authApiFile = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/${operation}.ts`;
58
- const authApiFilePath = _path.default.join(process.cwd(), authApiFile);
59
- return await fs.exists(authApiFilePath);
60
- }
61
- async function runCreateApi(authSessionInput) {
62
- try {
63
- const createApiOperationId = (0, _nanoid.nanoid)();
64
- const authSessionInstance = await (0, _asyncLocalStorage.runWithContext)({
65
- runEnvironment: _enums.RunEnvironment.IDE,
66
- extendedPayloads: [],
67
- runId: createApiOperationId
68
- }, () => runCreateApiViaCLI(authSessionInput));
69
- return authSessionInstance;
70
- } catch (error) {
71
- throw new Error(`Error running the create API: ${error.message}`);
72
- }
73
- }
74
- async function runCheckApi(authSessionPath) {
75
- try {
76
- const checkApiOperationId = (0, _nanoid.nanoid)();
77
- const checkResult = await (0, _asyncLocalStorage.runWithContext)({
78
- runEnvironment: _enums.RunEnvironment.IDE,
79
- extendedPayloads: [],
80
- runId: checkApiOperationId
81
- }, () => runCheckApiViaCLI(authSessionPath));
82
- return checkResult;
83
- } catch (error) {
84
- if (error.message === _types.CHECK_FAILED_ERROR_MESSAGE) {
85
- return false;
86
- }
87
- throw new Error(`Error running the check API: ${error.message}`);
88
- }
89
- }
90
- async function runCreateApiViaCLI(authSessionInput) {
91
- const createApiName = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`;
92
- const generator = (0, _runApi.runApiGenerator)({
93
- automationFunction: {
94
- name: createApiName,
95
- params: authSessionInput
96
- },
97
- runOptions: {
98
- headless: false,
99
- environment: "standalone"
100
- },
101
- retrieveSession: true,
102
- importFunction: _tsNodeImport.tsNodeImport
103
- });
104
- let nextGeneratorParam = undefined;
105
- while (true) {
106
- const {
107
- value,
108
- done
109
- } = await generator.next(...(nextGeneratorParam ? [nextGeneratorParam] : []));
110
- if (done) {
111
- if (value.isErr()) {
112
- if (value.error instanceof _runApi.AutomationError) {
113
- throw value.error.error;
114
- }
115
- console.error(value.error);
116
- throw new Error("Error while running create");
117
- }
118
- return value.value.session;
119
- }
120
- if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
121
- nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser + `, choices: ${value.choices}`, {
122
- validator: input => {
123
- if (!value.choices.includes(input)) {
124
- throw new Error("Please type on of the allowed choices");
125
- }
126
- return input;
127
- }
128
- });
129
- } else if (value.action === "request_more_info" && value.requestType == "otp") {
130
- nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser, {});
131
- }
132
- }
133
- }
134
- async function runCheckApiViaCLI(authSessionPath) {
135
- const runApiResult = await (0, _runApi.runApi)({
136
- automationFunction: {
137
- name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
138
- },
139
- runOptions: {
140
- headless: false,
141
- environment: "standalone"
142
- },
143
- auth: {
144
- session: {
145
- type: "file",
146
- path: authSessionPath
147
- },
148
- runCheck: false
149
- },
150
- importFunction: _tsNodeImport.tsNodeImport
151
- });
152
- if (runApiResult.isErr()) {
153
- if (runApiResult.error instanceof _runApi.AutomationError) {
154
- throw runApiResult.error.error;
155
- }
156
- return false;
157
- }
158
- const result = runApiResult.value.result;
159
- if (!result) {
160
- return false;
161
- }
162
- return result;
163
- }
164
- async function storeAuthSessionInstance(authSessionInstance, customName, authSessionInput) {
165
- try {
166
- const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
167
- await fs.ensureDir(authSessionsDirectoryPath);
168
- const authSessionInstanceId = customName ?? `auth-session-${Date.now()}`;
169
- const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, authSessionInstanceId);
170
- const authSessionExists = await fs.pathExists(authSessionInstancePath);
171
- await fs.ensureDir(authSessionInstancePath);
172
- const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
173
- await fs.writeJSON(authSessionInstanceStoragePath, authSessionInstance, {
174
- spaces: 2
175
- });
176
- const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
177
- let existingMetadata = {};
178
- const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
179
- if (authSessionExists) {
180
- try {
181
- existingMetadata = await fs.readJSON(authSessionInstanceMetadataPath);
182
- } catch (readError) {
183
- existingMetadata = {};
184
- }
185
- }
186
- const authSessionMetadata = {
187
- createdAt: existingMetadata.createdAt || new Date().toISOString(),
188
- updatedAt: new Date().toISOString(),
189
- ...(projectAuthConfig.type === "API" && {
190
- authSessionInput: authSessionInput || existingMetadata.authSessionInput || {}
191
- }),
192
- authSessionId: authSessionInstanceId,
193
- authSessionType: projectAuthConfig.type ?? existingMetadata.authSessionType ?? "API",
194
- ...(projectAuthConfig.type === "MANUAL" && {
195
- recorderStartUrl: projectAuthConfig.startUrl,
196
- recorderEndUrl: projectAuthConfig.endUrl
197
- })
198
- };
199
- await fs.writeJSON(authSessionInstanceMetadataPath, authSessionMetadata, {
200
- spaces: 2
201
- });
202
- return authSessionInstancePath;
203
- } catch (error) {
204
- throw new Error(`Error storing auth session instance: ${error.message}`);
205
- }
206
- }
207
- async function retrieveAuthSessionInstance(authSessionId, pathsOnly = false) {
208
- try {
209
- const authSessionInstancePath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME, authSessionId);
210
- const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
211
- const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
212
- if (!(await fs.exists(authSessionInstanceStoragePath))) {
213
- throw new Error(`Auth session instance with ID ${authSessionId} not found`);
214
- }
215
- if (pathsOnly) {
216
- return {
217
- authSessionInstanceStoragePath,
218
- authSessionInstanceMetadataPath
219
- };
220
- }
221
- const authSessionInstance = await fs.readJSON(authSessionInstanceStoragePath);
222
- const metadata = await fs.readJSON(authSessionInstanceMetadataPath);
223
- return {
224
- authSessionInstance,
225
- metadata
226
- };
227
- } catch (error) {
228
- throw new Error(`Error retrieving auth session instance: ${error.message}`);
229
- }
230
- }
231
- async function getStorageState(context) {
232
- const result = {};
233
- const storageState = await context.storageState();
234
- result.cookies = storageState.cookies;
235
- result.origins = storageState.origins;
236
- const sessionDataList = [];
237
- const pages = context.pages();
238
- for (const page of pages) {
239
- if (page.isClosed()) continue;
240
- try {
241
- const sessionData = await page.evaluate(() => {
242
- const items = {
243
- ...window.sessionStorage
244
- };
245
- return {
246
- origin: window.location.origin,
247
- sessionStorage: Object.entries(items).map(([name, value]) => ({
248
- name,
249
- value
250
- }))
251
- };
252
- });
253
- sessionDataList.push(sessionData);
254
- } catch (error) {
255
- console.error("Error getting sessionStorage:", error);
256
- }
257
- }
258
- result.sessionStorage = sessionDataList;
259
- return result;
260
- }
261
- async function recordAuthSession(startUrl, endUrl) {
262
- let browser;
263
- try {
264
- browser = await playwright.chromium.launch({
265
- headless: false,
266
- args: ["--start-maximized", "--no-sandbox"]
267
- });
268
- const context = await browser.newContext({
269
- viewport: null
270
- });
271
- const page = await context.newPage();
272
- await page.goto(startUrl);
273
- await page.waitForURL(url => url.toString().startsWith(endUrl), {
274
- timeout: 300000
275
- });
276
- const storageState = await getStorageState(context);
277
- return storageState;
278
- } catch (error) {
279
- throw new Error(`Authentication recording failed: ${error.message}`);
280
- } finally {
281
- if (browser) {
282
- await browser.close();
283
- }
284
- }
285
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _dotenv = _interopRequireDefault(require("dotenv"));
6
- var _utils = require("../deploy/utils");
7
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
- _dotenv.default.config({
9
- path: `.env`
10
- });
11
- _commander.program.name("intuned-build-project").description("Build your current Intuned project").action(async () => {
12
- try {
13
- await (0, _utils.runBuild)();
14
- } catch (error) {
15
- process.exit(1);
16
- } finally {
17
- process.exit(0);
18
- }
19
- });
20
- _commander.program.parse(process.argv);
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _chalk = _interopRequireDefault(require("chalk"));
6
- var _dotenv = _interopRequireDefault(require("dotenv"));
7
- var _utils = require("./utils");
8
- var _utils2 = require("../../common/cli/utils");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- _dotenv.default.config({
11
- path: `.env`
12
- });
13
- _commander.program.description("Deploy an Intuned project to be public").argument("[project-name]", "Name of the project to deploy").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action(async (projectName, options) => {
14
- try {
15
- const {
16
- isValid,
17
- errorMessage
18
- } = await (0, _utils.validateIntunedProject)();
19
- if (!isValid) {
20
- const userErrorMesage = `Project to be deployed is not a valid Intuned project: ${errorMessage}, modify and check again`;
21
- throw new Error(userErrorMesage);
22
- }
23
- const _projectName = projectName || (await (0, _utils2.getSettingIntunedJSON)("projectName"));
24
- if (!_projectName) {
25
- throw new Error("Project name is required");
26
- }
27
- const projectNameValidation = (0, _utils.validateProjectName)(_projectName);
28
- if (!projectNameValidation.isValid) {
29
- throw new Error(projectNameValidation.errorMessage);
30
- }
31
- const auth = await (0, _utils2.getAuthCredentials)(options);
32
- const {
33
- deployDone,
34
- projectId,
35
- deployErrorMessage
36
- } = await (0, _utils.deployProject)(_projectName, auth);
37
- if (!deployDone) {
38
- throw new Error(`Project not deployed: ${deployErrorMessage}`);
39
- }
40
- const url = (0, _utils2.getBaseUrl)();
41
- console.log(_chalk.default.green(`\n✅ Project "${_projectName}" deployed successfully!` + `\n\nYou can check your project on the platform: ${_chalk.default.bold(`${url}/projects/${projectId}/details`)}\n`));
42
- } catch (error) {
43
- console.error(_chalk.default.red(`\n${error.message}`));
44
- process.exit(1);
45
- }
46
- });
47
- _commander.program.parse(process.argv);
@@ -1,16 +0,0 @@
1
- import { AuthCredentials, FileSystemTree } from "../../common/cli/types";
2
- export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
3
- export declare function deployProject(projectName: string, auth: AuthCredentials): Promise<{
4
- deployDone: boolean;
5
- projectId?: string;
6
- deployErrorMessage?: string;
7
- }>;
8
- export declare const validateProjectName: (projectName: string) => {
9
- isValid: boolean;
10
- errorMessage?: string;
11
- };
12
- export declare const validateIntunedProject: () => Promise<{
13
- isValid: boolean;
14
- errorMessage?: string;
15
- }>;
16
- export declare const runBuild: () => Promise<boolean>;
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _chalk = _interopRequireDefault(require("chalk"));
6
- var _dotenv = _interopRequireDefault(require("dotenv"));
7
- var _utils = require("./utils");
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- _dotenv.default.config({
10
- path: `.env`
11
- });
12
- _commander.program.description("Initialize a new Intuned project from a template").argument("[template-name]", "Name of the template to use").action(async templateName => {
13
- try {
14
- const template = await (0, _utils.selectTemplate)(templateName);
15
- const isTargetDirectoryEmpty = await (0, _utils.checkEmptyDirectory)();
16
- await (0, _utils.scaffoldProject)(template, isTargetDirectoryEmpty);
17
- } catch (error) {
18
- console.error(_chalk.default.red(`\n${error.message}`));
19
- process.exit(1);
20
- }
21
- });
22
- _commander.program.parse(process.argv);