@intuned/runtime-dev 1.2.0-dev-peer → 1.2.1-hooks.0

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 (148) hide show
  1. package/.babelrc +2 -2
  2. package/.npmrc.wtf +1 -0
  3. package/CHANGELOG.md +5 -1
  4. package/WebTemplate.zip +0 -0
  5. package/bin/intuned +2 -0
  6. package/dist/commands/api/run.js +10 -3
  7. package/dist/commands/auth-sessions/run-check.js +18 -4
  8. package/dist/commands/auth-sessions/run-create.js +2 -1
  9. package/dist/commands/common/browserUtils.d.ts +1 -1
  10. package/dist/commands/common/browserUtils.js +1 -1
  11. package/dist/commands/common/getFirstLineNumber.js +2 -4
  12. package/dist/commands/interface/run.js +7 -6
  13. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  14. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  15. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  16. package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
  17. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  18. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  19. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  20. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
  21. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  22. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
  23. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  24. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  25. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  26. package/dist/commands/intuned-cli/commands/command.js +9 -0
  27. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  28. package/dist/commands/intuned-cli/commands/deploy.command.js +46 -0
  29. package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
  30. package/dist/commands/intuned-cli/commands/index.js +170 -0
  31. package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
  32. package/dist/commands/intuned-cli/commands/init.command.js +13 -0
  33. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  34. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  35. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  36. package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
  37. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +20 -0
  38. package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
  39. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  40. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
  41. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  42. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
  43. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  44. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
  45. package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
  46. package/dist/commands/intuned-cli/commands/types.js +21 -0
  47. package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
  48. package/dist/commands/intuned-cli/constants/index.js +25 -0
  49. package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
  50. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
  51. package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
  52. package/dist/commands/intuned-cli/controller/api.js +181 -0
  53. package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
  54. package/dist/commands/intuned-cli/controller/authSession.js +292 -0
  55. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  56. package/dist/commands/intuned-cli/controller/build.js +36 -0
  57. package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
  58. package/dist/commands/{deploy/utils.js → intuned-cli/controller/deploy.js} +115 -109
  59. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  60. package/dist/commands/intuned-cli/controller/index.js +46 -0
  61. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  62. package/dist/commands/intuned-cli/helpers/api.js +19 -0
  63. package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
  64. package/dist/commands/intuned-cli/helpers/auth.js +129 -0
  65. package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  66. package/dist/commands/intuned-cli/helpers/backend.js +26 -0
  67. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  68. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  69. package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
  70. package/dist/commands/intuned-cli/helpers/errors.js +55 -0
  71. package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
  72. package/dist/commands/intuned-cli/helpers/index.js +115 -0
  73. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
  74. package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
  75. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  76. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  77. package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  78. package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  79. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  80. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  81. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  82. package/dist/commands/intuned-cli/helpers/validation.js +12 -0
  83. package/dist/commands/intuned-cli/index.d.ts +1 -0
  84. package/dist/commands/intuned-cli/index.js +16 -0
  85. package/dist/commands/intuned-cli/main.d.ts +1 -0
  86. package/dist/commands/intuned-cli/main.js +15 -0
  87. package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -34
  88. package/dist/{common/cli → commands/intuned-cli}/types.js +1 -2
  89. package/dist/common/assets/browser_scripts.js +2509 -2143
  90. package/dist/common/asyncLocalStorage/index.d.ts +2 -2
  91. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  92. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  93. package/dist/common/constants.d.ts +1 -0
  94. package/dist/common/constants.js +2 -1
  95. package/dist/common/getPlaywrightConstructs.d.ts +6 -5
  96. package/dist/common/getPlaywrightConstructs.js +73 -37
  97. package/dist/common/jwtTokenManager.js +3 -5
  98. package/dist/common/runApi/errors.d.ts +1 -1
  99. package/dist/common/runApi/errors.js +4 -5
  100. package/dist/common/runApi/index.d.ts +4 -1
  101. package/dist/common/runApi/index.js +22 -21
  102. package/dist/common/runApi/types.d.ts +144 -13
  103. package/dist/common/runApi/types.js +28 -27
  104. package/dist/index.d.ts +1 -1
  105. package/dist/index.js +6 -0
  106. package/dist/runtime/executionHelpers.test.js +3 -4
  107. package/dist/runtime/export.d.ts +18 -0
  108. package/dist/runtime/extendPayload.js +1 -1
  109. package/dist/runtime/extendTimeout.js +0 -7
  110. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  111. package/dist/runtime/getAuthSessionParameters.js +20 -0
  112. package/dist/runtime/getCdpAddress.d.ts +1 -0
  113. package/dist/runtime/getCdpAddress.js +11 -0
  114. package/dist/runtime/index.d.ts +2 -0
  115. package/dist/runtime/index.js +15 -1
  116. package/package.json +11 -10
  117. package/template.tsconfig.json +4 -7
  118. package/tsconfig.json +2 -1
  119. package/bin/check-auth-session +0 -3
  120. package/bin/cli-build +0 -3
  121. package/bin/create-auth-session +0 -3
  122. package/bin/deploy +0 -3
  123. package/bin/init +0 -3
  124. package/bin/run-api +0 -3
  125. package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
  126. package/dist/commands/cli-auth-sessions/check.js +0 -40
  127. package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
  128. package/dist/commands/cli-auth-sessions/create.js +0 -53
  129. package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
  130. package/dist/commands/cli-auth-sessions/utils.js +0 -285
  131. package/dist/commands/cli-build/cli-build.d.ts +0 -2
  132. package/dist/commands/cli-build/cli-build.js +0 -20
  133. package/dist/commands/deploy/deploy.d.ts +0 -2
  134. package/dist/commands/deploy/deploy.js +0 -47
  135. package/dist/commands/deploy/utils.d.ts +0 -16
  136. package/dist/commands/init/init.d.ts +0 -2
  137. package/dist/commands/init/init.js +0 -22
  138. package/dist/commands/init/utils.d.ts +0 -11
  139. package/dist/commands/init/utils.js +0 -181
  140. package/dist/commands/run-api-cli/run-api.d.ts +0 -2
  141. package/dist/commands/run-api-cli/run-api.js +0 -57
  142. package/dist/commands/run-api-cli/utils.d.ts +0 -9
  143. package/dist/commands/run-api-cli/utils.js +0 -144
  144. package/dist/common/cli/cliReadme.d.ts +0 -1
  145. package/dist/common/cli/cliReadme.js +0 -92
  146. package/dist/common/cli/constants.d.ts +0 -33
  147. package/dist/common/cli/constants.js +0 -39
  148. package/dist/common/cli/utils.d.ts +0 -6
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports._isDirectoryNode = _isDirectoryNode;
7
- exports._isFileNode = _isFileNode;
8
- exports.checkEmptyDirectory = checkEmptyDirectory;
9
- exports.getAuthCredentials = getAuthCredentials;
10
- exports.mountFiles = mountFiles;
11
- exports.scaffoldProject = scaffoldProject;
12
- exports.selectTemplate = selectTemplate;
13
- var fs = _interopRequireWildcard(require("fs-extra"));
14
- var _types = require("../../common/cli/types");
15
- var _chalk = _interopRequireDefault(require("chalk"));
16
- var _inquirer = _interopRequireDefault(require("inquirer"));
17
- var _path = _interopRequireDefault(require("path"));
18
- var _boxen = _interopRequireDefault(require("boxen"));
19
- var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
20
- var _constants = require("../../common/cli/constants");
21
- var _cliReadme = require("../../common/cli/cliReadme");
22
- var _utils = require("../../common/cli/utils");
23
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
- 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); }
25
- 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; }
26
- function _isDirectoryNode(node) {
27
- return node.directory !== undefined;
28
- }
29
- function _isFileNode(node) {
30
- return node.file !== undefined;
31
- }
32
- async function mountFiles(cwd, tree) {
33
- for (const name in tree) {
34
- const fullPath = _path.default.join(cwd, name);
35
- const node = tree[name];
36
- if (_isDirectoryNode(node)) {
37
- await fs.ensureDir(fullPath);
38
- await mountFiles(fullPath, node.directory);
39
- } else if (_isFileNode(node)) {
40
- await fs.writeFile(fullPath, node.file.contents);
41
- }
42
- }
43
- }
44
- async function checkEmptyDirectory() {
45
- const currentDir = process.cwd();
46
- try {
47
- const stats = await fs.stat(currentDir);
48
- if (!stats.isDirectory()) {
49
- throw new Error("The current path is not a directory.");
50
- }
51
- const files = await fs.readdir(currentDir);
52
- const significantFiles = files.filter(file => !_projectExclusions.default.includes(file));
53
- return significantFiles.length === 0;
54
- } catch (error) {
55
- if (error.code === "ENOENT") {
56
- throw new Error("The specified directory does not exist.");
57
- }
58
- throw error;
59
- }
60
- }
61
- function getAuthCredentials(options) {
62
- const workspaceId = options.workspaceId || process.env.INTUNED_WORKSPACE_ID;
63
- const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
64
- const missingAuth = [];
65
- if (!workspaceId) {
66
- missingAuth.push({
67
- type: "input",
68
- name: "workspaceId",
69
- message: "Enter your Intuned workspace ID:",
70
- validate: input => input.trim() !== "" ? true : "Workspace ID is required"
71
- });
72
- }
73
- if (!apiKey) {
74
- missingAuth.push({
75
- type: "password",
76
- name: "apiKey",
77
- message: "Enter your Intuned API key:",
78
- mask: "*",
79
- validate: input => input.trim() !== "" ? true : "API key is required"
80
- });
81
- }
82
- if (missingAuth.length) {
83
- throw new Error(`Authentication failed: Missing ${missingAuth.join(" and ")}.\n\n` + `To fix this issue:\n\n` + `1. For workspaceId:\n` + ` - Add it to your intuned.json file under the "workspaceId" property\n` + ` - OR provide via command line: --workspace-id YOUR_WORKSPACE_ID\n` + ` - See how to get your workspaceId: https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id\n\n` + `2. For API key:\n` + ` - Include in your .env file INTUNED_API_KEY=your_api_key_here \n` + ` - OR provide via command line: --api-key YOUR_API_KEY\n\n` + `Run commands from the project root directory where intuned.json is located.`);
84
- }
85
- return {
86
- workspaceId,
87
- apiKey
88
- };
89
- }
90
- async function selectTemplate(templateName) {
91
- if (templateName) {
92
- const validTemplate = _types.templateIds.find(t => t === templateName);
93
- if (!validTemplate) {
94
- console.log(_chalk.default.yellow(`\n⚠️ Template "${templateName}" not found.`));
95
- } else {
96
- return templateName;
97
- }
98
- }
99
- console.log(_chalk.default.yellow("\n📋 Select a Template"));
100
- const {
101
- template
102
- } = await _inquirer.default.prompt([{
103
- type: "list",
104
- name: "template",
105
- message: "Which template would you like to use?",
106
- choices: _types.templateIds,
107
- loop: false
108
- }]);
109
- return template;
110
- }
111
- async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
112
- if (!isTargetDirectoryEmpty) {
113
- const {
114
- confirm
115
- } = await _inquirer.default.prompt([{
116
- type: "confirm",
117
- name: "confirm",
118
- message: `The current directory is not empty. Do you want to proceed and override files?`,
119
- default: false,
120
- choices: [{
121
- name: "Yes,",
122
- value: true
123
- }, {
124
- name: "No",
125
- value: false
126
- }]
127
- }]);
128
- if (!confirm) {
129
- throw new Error("Project initialization cancelled");
130
- }
131
- }
132
- const cwd = process.cwd();
133
- console.log(_chalk.default.cyan(`\n🚀 Initializing ${_chalk.default.bold(templateId)} project...\n`));
134
- console.log(_chalk.default.cyan("📦 Fetching template..."));
135
- const template = await fetchProjectTemplate(templateId);
136
- console.log(_chalk.default.green(`✓ Template "${templateId}" fetched successfully`));
137
- console.log(_chalk.default.cyan("🔨 Creating project files..."));
138
- const codeTree = template;
139
- await prepareCLITemplate(codeTree);
140
- await mountFiles(cwd, codeTree);
141
- console.log(_chalk.default.green("✓ Project files created"));
142
- console.log((0, _boxen.default)(_chalk.default.green(`✅ Project initialized successfully`) + `\n\n${_chalk.default.cyan("Project details:")}` + `\n• Template: ${_chalk.default.bold(templateId)}` + `\n• Directory: ${_chalk.default.bold(process.cwd())}` + `\n\n${_chalk.default.cyan("Next steps:")}` + `\n1. ${_chalk.default.bold("cd")} into your project directory (if not already there)` + `\n2. Run ${_chalk.default.bold("npm/yarn install")} to install dependencies` + `\n3. Develop, test and run your automation APIs`, {
143
- padding: 1,
144
- margin: 1,
145
- borderStyle: "round",
146
- borderColor: "green"
147
- }));
148
- }
149
- async function fetchProjectTemplate(templateId) {
150
- const baseUrl = (0, _utils.getBaseUrl)();
151
- const url = `${baseUrl}/api/templates/${templateId}`;
152
- const response = await fetch(url);
153
- if (!response.ok) {
154
- throw new Error(`Error fetching template: ${response.statusText} (${response.status})`);
155
- }
156
- const data = await response.json();
157
- if (!data) {
158
- throw new Error("Template not found");
159
- }
160
- return data.template;
161
- }
162
- async function prepareCLITemplate(codeTree) {
163
- codeTree["parameters"] = {
164
- directory: {}
165
- };
166
- codeTree["tsconfig.json"] = {
167
- file: {
168
- contents: JSON.stringify(_constants.tsConfigCli, null, 2)
169
- }
170
- };
171
- if (_isFileNode(codeTree["package.json"]) && codeTree["package.json"].file) {
172
- const packageJson = JSON.parse(codeTree["package.json"].file.contents);
173
- packageJson.scripts = _constants.userCLIScripts;
174
- codeTree["package.json"].file.contents = JSON.stringify(packageJson, null, 2);
175
- }
176
- codeTree["README.md"] = {
177
- file: {
178
- contents: _cliReadme.cliReadme
179
- }
180
- };
181
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- var _commander = require("commander");
5
- var _chalk = _interopRequireDefault(require("chalk"));
6
- var _nanoid = require("nanoid");
7
- var _dotenv = _interopRequireDefault(require("dotenv"));
8
- var _utils = require("./utils");
9
- var _enums = require("../../runtime/enums");
10
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
11
- var _utils2 = require("../cli-auth-sessions/utils");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- _dotenv.default.config({
14
- path: `.env`
15
- });
16
- _commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-i, --parameters-file <file>", "JSON file containing API parameters").option("-a, --auth-session <session>", "Name of the auth session instance to use").option("-s, --store-results", "Store the results of the running API in a dedicated folder").action(async (apiName, options) => {
17
- try {
18
- if (!apiName) {
19
- throw new Error("API name is required, please provide it");
20
- }
21
- const _isAuthEnabled = await (0, _utils2.isAuthEnabled)();
22
- if (!_isAuthEnabled && options.authSession) {
23
- throw new Error("Auth session is not enabled, enable it in Intuned.json to be able to use it");
24
- }
25
- if (_isAuthEnabled && !options.authSession) {
26
- throw new Error("Auth session is enabled but no auth session provided, please provide it");
27
- }
28
- const inputData = await (0, _utils.loadParameters)(options.parametersFile);
29
- const runId = (0, _nanoid.nanoid)();
30
- const {
31
- result,
32
- payloadToAppend
33
- } = await (0, _asyncLocalStorage.runWithContext)({
34
- runEnvironment: _enums.RunEnvironment.IDE,
35
- extendedPayloads: [],
36
- runId
37
- }, () => (0, _utils.runApiViaCLI)(apiName, inputData, {
38
- authSession: options.authSession
39
- }));
40
- if (!result) {
41
- console.log(_chalk.default.yellow("No result returned from the API"));
42
- return;
43
- }
44
- if (!options.storeResults) {
45
- console.log(_chalk.default.green(`✓ API executed successfully`));
46
- console.log(_chalk.default.green("Result:"));
47
- console.log(_chalk.default.white(JSON.stringify(result, null, 2)));
48
- return;
49
- }
50
- await (0, _utils.writeResultToFile)(runId, result, payloadToAppend);
51
- } catch (error) {
52
- console.error(_chalk.default.red(`\nError: ${error.message}`));
53
- } finally {
54
- process.exit(0);
55
- }
56
- });
57
- _commander.program.parse(process.argv);
@@ -1,9 +0,0 @@
1
- import { Payload } from "../../runtime/export";
2
- export declare function loadParameters(parametersFile: string): Promise<object | null>;
3
- export declare function writeResultToFile(runId: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
4
- export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options?: {
5
- authSession?: string;
6
- }): Promise<{
7
- result: any;
8
- payloadToAppend: Payload[] | undefined;
9
- }>;
@@ -1,144 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.loadParameters = loadParameters;
7
- exports.runApiViaCLI = runApiViaCLI;
8
- exports.writeResultToFile = writeResultToFile;
9
- var _path = _interopRequireDefault(require("path"));
10
- var fs = _interopRequireWildcard(require("fs-extra"));
11
- var _Logger = require("../../common/Logger");
12
- var _chalk = _interopRequireDefault(require("chalk"));
13
- var _runApi = require("../../common/runApi");
14
- var _tsNodeImport = require("../common/tsNodeImport");
15
- var _utils = require("../cli-auth-sessions/utils");
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
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- async function loadParameters(parametersFile) {
20
- if (!parametersFile) {
21
- return {};
22
- }
23
- try {
24
- const filePath = _path.default.join(process.cwd(), parametersFile);
25
- await fs.access(filePath);
26
- let inputData = null;
27
- if (parametersFile) {
28
- inputData = await fs.readJSON(filePath);
29
- } else {
30
- inputData = {};
31
- }
32
- return inputData;
33
- } catch (error) {
34
- if (error.code === "ENOENT") {
35
- throw new Error(`Parameters file not found: ${parametersFile}`);
36
- } else if (error instanceof SyntaxError) {
37
- throw new Error(`Invalid JSON in parameters file: ${error.message}`);
38
- }
39
- throw new Error(`Error reading parameters file: ${error.message}`);
40
- }
41
- }
42
- async function writeResultToFile(runId, result, payloadToAppend) {
43
- const outputDir = _path.default.join(process.cwd(), "output", runId);
44
- const resultsPath = _path.default.join(outputDir, "results.json");
45
- const extendedPayloadsPath = _path.default.join(outputDir, "extendedPayloads.json");
46
- await fs.ensureDir(outputDir);
47
- try {
48
- await fs.writeJSON(resultsPath, result, {
49
- spaces: 2
50
- });
51
- if (payloadToAppend && payloadToAppend.length > 0) {
52
- await fs.writeJSON(extendedPayloadsPath, payloadToAppend, {
53
- spaces: 2
54
- });
55
- _Logger.logger.info(_chalk.default.underline.green.white(`Payloads to append saved into (${extendedPayloadsPath})`));
56
- }
57
- console.log(_chalk.default.underline.green.white(`✓ API executed successfully. Results stored in ${outputDir}`));
58
- console.log(_chalk.default.blue(`Run ID: ${runId}`));
59
- } catch (error) {
60
- _Logger.logger.error(`Failed to write result to file: ${error.message}`);
61
- }
62
- }
63
- async function runApiViaCLI(apiName, inputData, options) {
64
- let authSessionPathToUse = null;
65
- if (options !== null && options !== void 0 && options.authSession) {
66
- const {
67
- authSessionInstanceStoragePath
68
- } = await (0, _utils.retrieveAuthSessionInstance)(options === null || options === void 0 ? void 0 : options.authSession, true);
69
- authSessionPathToUse = authSessionInstanceStoragePath;
70
- }
71
- if (authSessionPathToUse) {
72
- const checkApiExists = await (0, _utils.ensureAuthApi)("check");
73
- if (!checkApiExists) {
74
- throw new Error("Auth session check API not implemented, please create it in the auth sessions specified directory");
75
- }
76
- const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
77
- if (!checkResult) {
78
- console.log(_chalk.default.yellow("Auth session check failed, trying to refresh it..."));
79
- const createApiExists = await (0, _utils.ensureAuthApi)("create");
80
- if (!createApiExists) {
81
- throw new Error("Auth session creation API not implemented, please create it in the auth sessions specified directory");
82
- }
83
- const {
84
- metadata
85
- } = await (0, _utils.retrieveAuthSessionInstance)(options === null || options === void 0 ? void 0 : options.authSession);
86
- if ((metadata === null || metadata === void 0 ? void 0 : metadata.authSessionType) === "MANUAL") {
87
- throw new Error("Expired Auth session is recorder-based, please provide a new one or refresh it manually");
88
- }
89
- const authSessionInput = (metadata === null || metadata === void 0 ? void 0 : metadata.authSessionInput) ?? {};
90
- try {
91
- const refresehAuthSessionInstance = await (0, _utils.runCreateApiViaCLI)(authSessionInput);
92
- if (!refresehAuthSessionInstance) {
93
- throw new Error("Failed to refresh auth session");
94
- }
95
- await (0, _utils.storeAuthSessionInstance)(refresehAuthSessionInstance, options === null || options === void 0 ? void 0 : options.authSession, authSessionInput);
96
- const checkResult = await (0, _utils.runCheckApiViaCLI)(authSessionPathToUse);
97
- if (!checkResult) {
98
- throw new Error("Failed to refresh auth session");
99
- }
100
- console.log(_chalk.default.green("✓ Auth session refreshed successfully on this run"));
101
- } catch (error) {
102
- throw new Error(`Failed to refresh auth session: ${error.message}`);
103
- }
104
- }
105
- }
106
- const runApiResult = await (0, _runApi.runApi)({
107
- automationFunction: {
108
- name: `api/${apiName}`,
109
- params: inputData
110
- },
111
- runOptions: {
112
- headless: false,
113
- environment: "standalone"
114
- },
115
- auth: authSessionPathToUse ? {
116
- session: {
117
- type: "file",
118
- path: authSessionPathToUse
119
- },
120
- runCheck: false
121
- } : undefined,
122
- importFunction: _tsNodeImport.tsNodeImport
123
- });
124
- if (runApiResult.isErr()) {
125
- if (runApiResult.error instanceof _runApi.AutomationError) {
126
- throw runApiResult.error.error;
127
- }
128
- console.error(runApiResult.error);
129
- throw new Error("An error occurred while running the API");
130
- }
131
- const {
132
- result,
133
- extendedPayloads: payloadToAppend
134
- } = runApiResult.value;
135
- const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
136
- if (hasPayloadToAppend) {
137
- _Logger.logger.info("payload to append:", payloadToAppend);
138
- _Logger.logger.info("This will only take an effect if this API run was part of a job.");
139
- }
140
- return {
141
- result,
142
- payloadToAppend
143
- };
144
- }
@@ -1 +0,0 @@
1
- export declare const cliReadme = "# Intuned CLI\n## Introduction\nThe Intuned CLI exposes a variaty of commands to develop your Intuned projects locally\n\n## Development Commands\n\n### Initialize a Project\n`npx -p @intuned/runtime init`\n\n### Run an API\n`yarn run-api <api-name>`\nor\n`npm run run-api <api-name>`\n\nOptions:\n- `-i, --parameters-file file-path`: JSON file containing API parameters\n- `-s, --store-results`: Store the results in `./output/[runId]/results.json` and `./output/[runId]/extendedPayloads.json`\n- `-a, --auth-session <session>`: Name of the auth session instance to use if project is auth-enabled\n\n### Build a Project\n`yarn cli-build`\n\n### Deploy a Project\n`yarn deploy <project-name>`\nor\n`npm run deploy <project-name>`\n\n- `project-name`: Optional name that overrides the one in intuned.json\n- Options:\n - `--workspace-id`: Overrides the workspace ID in intuned.json\n - `--api-key`: Overrides the API key from environment variables\n\n\n### Create an auth session\n`yarn create-auth-session <auth-session-name>`\nor\n`npm create-auth-session <auth-session-name>`\n\n- `auth-session-name`: Optional name/id of the auth session instance to use, if not provided, a name will be generated with the current timestamp\n- Options:\n - `--input`: Auth session input parameters file path\n\n### Check an auth session\n`yarn check-auth-session <auth-session-name>`\nor\n`npm check-auth-session <auth-session-name>`\n- `auth-session-name`: Name/id of the auth session instance to check, required\n\n## Configuration\n\n### Environment Variables and Settings\n- `workspaceId`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))\n - Set in `intuned.json` file under the `workspaceId` property\n - Or provide via CLI with `--workspace-id` flag during deployment\n \n- `projectName`: The name of your Intuned project\n - Set in `intuned.json` file under the `projectName` property\n - Or override via command line when deploying with `yarn deploy my-project-name` or `npm run deploy my-project-name`\n \n- `INTUNED_API_KEY`: Your Intuned API key\n - Set as an environment variable: `export INTUNED_API_KEY=your_api_key_here`\n - Or include in your .env file for development\n - Or provide via CLI with `--api-key` flag during deployment\n\n## Project Structure\n\n### Generated Artifacts\n- `./intuned.json`: Project configuration file\n- `./api`: Folder containing API implementation files\n- `./auth-sessions`: Folder containing auth APIs\n- `./parameters`: Folder for API parameters injection\n- `./output`: Folder containing generated output files\n- `./auth-sessions-instances`: Folder containing auth session instances\n\n## Types of auth sessions\n- `MANUAL`: Manual auth session, records the session using a recorder and stores it in the `auth-sessions-instances` folder\n- `API`: Auth session created via create API, stores the session in the `auth-sessions-instances` folder\n\n### Notes\n- You can use either `yarn` or `npm run` to execute commands\n- All commands must be run from the project root directory\n- Verify you're in the correct location by confirming the presence of package.json and intuned.json\n- Running commands from subdirectories may result in errors\n- You can manage your deployed projects through the Intuned platform\n- WARNING: \u26A0\uFE0F Changes to TS Config may break some Intuned functionalities\n";
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.cliReadme = void 0;
7
- const cliReadme = exports.cliReadme = `# Intuned CLI
8
- ## Introduction
9
- The Intuned CLI exposes a variaty of commands to develop your Intuned projects locally
10
-
11
- ## Development Commands
12
-
13
- ### Initialize a Project
14
- \`npx -p @intuned/runtime init\`
15
-
16
- ### Run an API
17
- \`yarn run-api <api-name>\`
18
- or
19
- \`npm run run-api <api-name>\`
20
-
21
- Options:
22
- - \`-i, --parameters-file file-path\`: JSON file containing API parameters
23
- - \`-s, --store-results\`: Store the results in \`./output/[runId]/results.json\` and \`./output/[runId]/extendedPayloads.json\`
24
- - \`-a, --auth-session <session>\`: Name of the auth session instance to use if project is auth-enabled
25
-
26
- ### Build a Project
27
- \`yarn cli-build\`
28
-
29
- ### Deploy a Project
30
- \`yarn deploy <project-name>\`
31
- or
32
- \`npm run deploy <project-name>\`
33
-
34
- - \`project-name\`: Optional name that overrides the one in intuned.json
35
- - Options:
36
- - \`--workspace-id\`: Overrides the workspace ID in intuned.json
37
- - \`--api-key\`: Overrides the API key from environment variables
38
-
39
-
40
- ### Create an auth session
41
- \`yarn create-auth-session <auth-session-name>\`
42
- or
43
- \`npm create-auth-session <auth-session-name>\`
44
-
45
- - \`auth-session-name\`: Optional name/id of the auth session instance to use, if not provided, a name will be generated with the current timestamp
46
- - Options:
47
- - \`--input\`: Auth session input parameters file path
48
-
49
- ### Check an auth session
50
- \`yarn check-auth-session <auth-session-name>\`
51
- or
52
- \`npm check-auth-session <auth-session-name>\`
53
- - \`auth-session-name\`: Name/id of the auth session instance to check, required
54
-
55
- ## Configuration
56
-
57
- ### Environment Variables and Settings
58
- - \`workspaceId\`: Your Intuned workspace ID ([How to get your workspaceId](https://docs.intunedhq.com/docs/guides/platform/how-to-get-a-workspace-id))
59
- - Set in \`intuned.json\` file under the \`workspaceId\` property
60
- - Or provide via CLI with \`--workspace-id\` flag during deployment
61
-
62
- - \`projectName\`: The name of your Intuned project
63
- - Set in \`intuned.json\` file under the \`projectName\` property
64
- - Or override via command line when deploying with \`yarn deploy my-project-name\` or \`npm run deploy my-project-name\`
65
-
66
- - \`INTUNED_API_KEY\`: Your Intuned API key
67
- - Set as an environment variable: \`export INTUNED_API_KEY=your_api_key_here\`
68
- - Or include in your .env file for development
69
- - Or provide via CLI with \`--api-key\` flag during deployment
70
-
71
- ## Project Structure
72
-
73
- ### Generated Artifacts
74
- - \`./intuned.json\`: Project configuration file
75
- - \`./api\`: Folder containing API implementation files
76
- - \`./auth-sessions\`: Folder containing auth APIs
77
- - \`./parameters\`: Folder for API parameters injection
78
- - \`./output\`: Folder containing generated output files
79
- - \`./auth-sessions-instances\`: Folder containing auth session instances
80
-
81
- ## Types of auth sessions
82
- - \`MANUAL\`: Manual auth session, records the session using a recorder and stores it in the \`auth-sessions-instances\` folder
83
- - \`API\`: Auth session created via create API, stores the session in the \`auth-sessions-instances\` folder
84
-
85
- ### Notes
86
- - You can use either \`yarn\` or \`npm run\` to execute commands
87
- - All commands must be run from the project root directory
88
- - Verify you're in the correct location by confirming the presence of package.json and intuned.json
89
- - Running commands from subdirectories may result in errors
90
- - You can manage your deployed projects through the Intuned platform
91
- - WARNING: ⚠️ Changes to TS Config may break some Intuned functionalities
92
- `;
@@ -1,33 +0,0 @@
1
- export declare const CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
2
- export declare const ProjectDeploymentStatus: string[];
3
- export declare const PROJECT_DEPLOY_TIMEOUT = 600000;
4
- export declare const userCLIScripts: {
5
- "dev:local": string;
6
- dev: string;
7
- build: string;
8
- "types-check": string;
9
- "pre-publish": string;
10
- start: string;
11
- "run-api": string;
12
- "cli-build": string;
13
- deploy: string;
14
- "cli-create-auth-session": string;
15
- "cli-check-auth-session": string;
16
- "browser-save-state": string;
17
- "auth-session-check": string;
18
- "auth-session-create": string;
19
- "auth-session-refresh": string;
20
- "auth-session-load": string;
21
- };
22
- export declare const tsConfigCli: {
23
- compilerOptions: {
24
- moduleResolution: string;
25
- target: string;
26
- outDir: string;
27
- sourceMap: boolean;
28
- declaration: boolean;
29
- esModuleInterop: boolean;
30
- };
31
- include: string[];
32
- exclude: string[];
33
- };
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.userCLIScripts = exports.tsConfigCli = exports.ProjectDeploymentStatus = exports.PROJECT_DEPLOY_TIMEOUT = exports.CURRENT_PLAYWRIGHT_VERSION = void 0;
7
- const CURRENT_PLAYWRIGHT_VERSION = exports.CURRENT_PLAYWRIGHT_VERSION = "1.44.1";
8
- const ProjectDeploymentStatus = exports.ProjectDeploymentStatus = ["completed", "failed", "pending", "not_found"];
9
- const PROJECT_DEPLOY_TIMEOUT = exports.PROJECT_DEPLOY_TIMEOUT = 600000;
10
- const userCLIScripts = exports.userCLIScripts = {
11
- "dev:local": "intuned-api-run sample playwright -j '{}'",
12
- dev: "intuned-api-run",
13
- build: "intuned-build",
14
- "types-check": "intuned-ts-check",
15
- "pre-publish": "intuned-ts-check && intuned-build",
16
- start: "node ./output/bundle_v2.js",
17
- "run-api": "run-api",
18
- "cli-build": "cli-build",
19
- deploy: "deploy",
20
- "cli-create-auth-session": "create-auth-session",
21
- "cli-check-auth-session": "check-auth-session",
22
- "browser-save-state": "intuned-browser-save-state",
23
- "auth-session-check": "intuned-auth-session-check",
24
- "auth-session-create": "intuned-auth-session-create",
25
- "auth-session-refresh": "intuned-auth-session-refresh",
26
- "auth-session-load": "intuned-auth-session-load"
27
- };
28
- const tsConfigCli = exports.tsConfigCli = {
29
- compilerOptions: {
30
- moduleResolution: "node",
31
- target: "ES2021",
32
- outDir: "./dist",
33
- sourceMap: false,
34
- declaration: true,
35
- esModuleInterop: true
36
- },
37
- include: ["**/*.ts"],
38
- exclude: ["node_modules", "dist"]
39
- };
@@ -1,6 +0,0 @@
1
- export declare function getAuthCredentials(options: any): Promise<{
2
- workspaceId: any;
3
- apiKey: any;
4
- }>;
5
- export declare function getBaseUrl(): string;
6
- export declare function getSettingIntunedJSON(key: string): Promise<any>;