@intuned/runtime-dev 1.0.6-cli.8 → 1.0.6-cli.8.0.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 (71) hide show
  1. package/dist/commands/common/projectExclusions.d.ts +2 -0
  2. package/dist/commands/common/projectExclusions.js +8 -0
  3. package/dist/commands/common/tsNodeImport.js +0 -2
  4. package/dist/commands/common/utils/unixSocket.d.ts +1 -0
  5. package/dist/commands/deploy/utils.js +2 -2
  6. package/dist/commands/init/init.js +3 -4
  7. package/dist/commands/init/utils.d.ts +3 -3
  8. package/dist/commands/init/utils.js +32 -21
  9. package/dist/commands/intuned-run/intuned-run.js +8 -6
  10. package/dist/commands/intuned-run/utils.js +1 -0
  11. package/dist/common/asyncLocalStorage/index.d.ts +2 -1
  12. package/dist/common/asyncLocalStorage/index.js +2 -5
  13. package/dist/common/cli/constants.d.ts +0 -0
  14. package/dist/common/cli/constants.js +1 -0
  15. package/dist/common/cli/types.d.ts +52 -0
  16. package/dist/common/cli/types.js +7 -0
  17. package/dist/common/cli/utils.d.ts +5 -0
  18. package/dist/common/cli/utils.js +39 -0
  19. package/dist/common/runApi/index.js +0 -2
  20. package/dist/common/runApi/types.d.ts +2 -2
  21. package/package.json +2 -3
  22. package/{my-intuned-project → r}/api/book-details.ts +0 -1
  23. package/r/api/books-all.ts +35 -0
  24. package/r/api/c.ts +0 -0
  25. package/{my-intuned-project → r}/package.json +1 -4
  26. package/r/tsconfig.json +47 -0
  27. package/r/utils/books.ts +32 -0
  28. package/{my-intuned-project → r}/yarn.lock +1 -10
  29. package/WebTemplate.zip +0 -0
  30. package/my-intuned-project/api/books-all.ts +0 -68
  31. package/my-intuned-project/emp/Intuned.json +0 -18
  32. package/my-intuned-project/emp/____testParameters/learn/actions/download.json +0 -8
  33. package/my-intuned-project/emp/____testParameters/learn/actions/fillForm.json +0 -1
  34. package/my-intuned-project/emp/____testParameters/learn/actions/upload.json +0 -8
  35. package/my-intuned-project/emp/____testParameters/learn/data-extraction/ai-extraction.json +0 -1
  36. package/my-intuned-project/emp/____testParameters/learn/data-extraction/extract-data-from-content.json +0 -1
  37. package/my-intuned-project/emp/____testParameters/learn/data-extraction/markdown-extraction.json +0 -8
  38. package/my-intuned-project/emp/____testParameters/learn/data-extraction/optimized-array-exteractor.json +0 -32
  39. package/my-intuned-project/emp/____testParameters/learn/data-extraction/optimized-object-extractor.json +0 -1
  40. package/my-intuned-project/emp/____testParameters/learn/data-extraction/pdf.json +0 -8
  41. package/my-intuned-project/emp/____testParameters/learn/playwright/fill-and-submit-forms.json +0 -1
  42. package/my-intuned-project/emp/____testParameters/learn/playwright/iframes.json +0 -1
  43. package/my-intuned-project/emp/____testParameters/learn/playwright/inject-code.json +0 -1
  44. package/my-intuned-project/emp/____testParameters/learn/playwright/locators-and-actions.json +0 -1
  45. package/my-intuned-project/emp/____testParameters/learn/playwright/navigation.json +0 -1
  46. package/my-intuned-project/emp/____testParameters/learn/playwright/network-interception.json +0 -1
  47. package/my-intuned-project/emp/____testParameters/learn/playwright/scrape-data.json +0 -1
  48. package/my-intuned-project/emp/____testParameters/learn/playwright/wait-for-state-change.json +0 -1
  49. package/my-intuned-project/emp/api/learn/actions/download.ts +0 -71
  50. package/my-intuned-project/emp/api/learn/actions/fillForm.ts +0 -223
  51. package/my-intuned-project/emp/api/learn/actions/upload.ts +0 -38
  52. package/my-intuned-project/emp/api/learn/data-extraction/ai-extraction.ts +0 -72
  53. package/my-intuned-project/emp/api/learn/data-extraction/extract-data-from-content.ts +0 -76
  54. package/my-intuned-project/emp/api/learn/data-extraction/markdown-extraction.ts +0 -47
  55. package/my-intuned-project/emp/api/learn/data-extraction/optimized-array-exteractor.ts +0 -49
  56. package/my-intuned-project/emp/api/learn/data-extraction/optimized-object-extractor.ts +0 -54
  57. package/my-intuned-project/emp/api/learn/data-extraction/pdf.ts +0 -123
  58. package/my-intuned-project/emp/api/learn/playwright/fill-and-submit-forms.ts +0 -73
  59. package/my-intuned-project/emp/api/learn/playwright/iframes.ts +0 -22
  60. package/my-intuned-project/emp/api/learn/playwright/inject-code.ts +0 -40
  61. package/my-intuned-project/emp/api/learn/playwright/locators-and-actions.ts +0 -58
  62. package/my-intuned-project/emp/api/learn/playwright/navigation.ts +0 -25
  63. package/my-intuned-project/emp/api/learn/playwright/network-interception.ts +0 -43
  64. package/my-intuned-project/emp/api/learn/playwright/scrape-data.ts +0 -58
  65. package/my-intuned-project/emp/api/learn/playwright/wait-for-state-change.ts +0 -44
  66. package/my-intuned-project/emp/api/sample.ts +0 -15
  67. package/my-intuned-project/emp/package.json +0 -31
  68. package/my-intuned-project/emp/utils/helpers.ts +0 -3
  69. package/my-intuned-project/emp/yarn.lock +0 -4530
  70. package/my-intuned-project/params/bookInput.json +0 -3
  71. /package/{my-intuned-project → r}/Intuned.json +0 -0
@@ -0,0 +1,2 @@
1
+ declare const exclusions: string[];
2
+ export default exclusions;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const exclusions = ["node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo"];
8
+ var _default = exports.default = exclusions;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.tsNodeImport = void 0;
7
7
  var _neverthrow = require("neverthrow");
8
8
  var _fileUtils = require("./utils/fileUtils");
9
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
10
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); }
11
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; }
12
11
  const tsNodeImport = async apiName => {
@@ -19,7 +18,6 @@ const tsNodeImport = async apiName => {
19
18
  const path = (0, _fileUtils.getFullPathInProject)(...apiName.split("/"));
20
19
  try {
21
20
  const imported = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(path);
22
- (0, _asyncLocalStorage.getExecutionContext)();
23
21
  return (0, _neverthrow.ok)(imported);
24
22
  } catch (e) {
25
23
  if ("code" in e && e.code === "MODULE_NOT_FOUND") {
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import * as net from "net";
2
3
  export declare class JSONUnixSocket {
3
4
  private readonly socket;
@@ -11,6 +11,7 @@ var path = _interopRequireWildcard(require("path"));
11
11
  var _chalk = _interopRequireDefault(require("chalk"));
12
12
  var _minimatch = require("minimatch");
13
13
  var _zod = require("zod");
14
+ var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
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); }
16
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; }
@@ -67,8 +68,7 @@ function listFilesNotIgnored(projectPath, ignorePatterns) {
67
68
  return results;
68
69
  }
69
70
  async function convertProjectToCodeTree(projectPath) {
70
- const defaultExcludes = ["node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo"];
71
- let ignorePatterns = [...defaultExcludes];
71
+ let ignorePatterns = [..._projectExclusions.default];
72
72
  let currentDir = path.normalize(projectPath);
73
73
  let gitignoreFound = false;
74
74
  while (currentDir !== path.parse(currentDir).root) {
@@ -9,12 +9,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
9
9
  _dotenv.default.config({
10
10
  path: `.env`
11
11
  });
12
- _commander.program.description("Initialize a new Intuned project from a template").argument("[template-name]", "Name of the template to use").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action(async (templateName, options) => {
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
13
  try {
14
- const auth = (0, _utils.getAuthCredentials)(options);
15
14
  const template = await (0, _utils.selectTemplate)(templateName);
16
- await (0, _utils.checkEmptyDirectory)();
17
- await (0, _utils.scaffoldProject)(template, auth);
15
+ const isTargetDirectoryEmpty = await (0, _utils.checkEmptyDirectory)();
16
+ await (0, _utils.scaffoldProject)(template, isTargetDirectoryEmpty);
18
17
  } catch (error) {
19
18
  console.error(_chalk.default.red(`\n${error.message}`));
20
19
  process.exit(1);
@@ -1,9 +1,9 @@
1
- import { AuthCredentials, FileSystemTree } from "./types";
1
+ import { FileSystemTree } from "./types";
2
2
  export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
3
- export declare function checkEmptyDirectory(): Promise<void>;
3
+ export declare function checkEmptyDirectory(): Promise<boolean>;
4
4
  export declare function getAuthCredentials(options: any): {
5
5
  workspaceId: any;
6
6
  apiKey: any;
7
7
  };
8
8
  export declare function selectTemplate(templateName: any): Promise<any>;
9
- export declare function scaffoldProject(templateId: string, authCredentials: AuthCredentials): Promise<void>;
9
+ export declare function scaffoldProject(templateId: string, isTargetDirectoryEmpty: boolean): Promise<void>;
@@ -13,6 +13,8 @@ var _types = require("./types");
13
13
  var _chalk = _interopRequireDefault(require("chalk"));
14
14
  var _inquirer = _interopRequireDefault(require("inquirer"));
15
15
  var _path = _interopRequireDefault(require("path"));
16
+ var _boxen = _interopRequireDefault(require("boxen"));
17
+ var _projectExclusions = _interopRequireDefault(require("../common/projectExclusions"));
16
18
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
19
  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); }
18
20
  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; }
@@ -42,10 +44,8 @@ async function checkEmptyDirectory() {
42
44
  throw new Error("The current path is not a directory.");
43
45
  }
44
46
  const files = await fs.readdir(currentDir);
45
- const significantFiles = files.filter(file => ![".git", ".DS_Store", "Thumbs.db", ".gitkeep"].includes(file));
46
- if (significantFiles.length) {
47
- throw new Error("The current directory is not empty.");
48
- }
47
+ const significantFiles = files.filter(file => !_projectExclusions.default.includes(file));
48
+ return significantFiles.length === 0;
49
49
  } catch (error) {
50
50
  if (error.code === "ENOENT") {
51
51
  throw new Error("The specified directory does not exist.");
@@ -103,36 +103,47 @@ async function selectTemplate(templateName) {
103
103
  }]);
104
104
  return template;
105
105
  }
106
- async function scaffoldProject(templateId, authCredentials) {
106
+ async function scaffoldProject(templateId, isTargetDirectoryEmpty) {
107
+ if (!isTargetDirectoryEmpty) {
108
+ const {
109
+ confirm
110
+ } = await _inquirer.default.prompt([{
111
+ type: "confirm",
112
+ name: "confirm",
113
+ message: `The current directory is not empty. Do you want to proceed and override files?`,
114
+ default: false,
115
+ choices: [{
116
+ name: "Yes,",
117
+ value: true
118
+ }, {
119
+ name: "No",
120
+ value: false
121
+ }]
122
+ }]);
123
+ if (!confirm) {
124
+ throw new Error("Project initialization cancelled");
125
+ }
126
+ }
107
127
  const cwd = process.cwd();
108
128
  console.log(_chalk.default.cyan(`\n🚀 Initializing ${_chalk.default.bold(templateId)} project...\n`));
109
129
  console.log(_chalk.default.cyan("📦 Fetching template..."));
110
- const template = await fetchProjectTemplate(templateId, authCredentials);
130
+ const template = await fetchProjectTemplate(templateId);
111
131
  console.log(_chalk.default.green(`✓ Template "${template}" fetched successfully`));
112
132
  console.log(_chalk.default.cyan("🔨 Creating project files..."));
113
133
  const codeTree = template;
114
134
  await mountFiles(cwd, codeTree);
115
135
  console.log(_chalk.default.green("✓ Project files created"));
116
- console.log(_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• Workspace ID: ${_chalk.default.bold(authCredentials.workspaceId.substring(0, 5) + "...")}` + `\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 APIs`, {
136
+ 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`, {
117
137
  padding: 1,
118
138
  margin: 1,
119
139
  borderStyle: "round",
120
140
  borderColor: "green"
121
- });
141
+ }));
122
142
  }
123
- async function fetchProjectTemplate(templateId, authCredentials) {
124
- const {
125
- workspaceId,
126
- apiKey
127
- } = authCredentials;
128
- const baseUrl = "https://omarh.intuned-team-local.com";
129
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/templates/${templateId}`;
130
- const headers = {
131
- "x-api-key": apiKey
132
- };
133
- const response = await fetch(url, {
134
- headers
135
- });
143
+ async function fetchProjectTemplate(templateId) {
144
+ const baseUrl = "https://rauf-2.intuned-team-local.com";
145
+ const url = `${baseUrl}/api/templates/${templateId}`;
146
+ const response = await fetch(url);
136
147
  if (!response.ok) {
137
148
  throw new Error(`Error fetching template: ${response.statusText} (${response.status})`);
138
149
  }
@@ -3,22 +3,24 @@
3
3
 
4
4
  var _commander = require("commander");
5
5
  var _chalk = _interopRequireDefault(require("chalk"));
6
- var _utils = require("./utils");
7
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
8
6
  var _nanoid = require("nanoid");
7
+ var _dotenv = _interopRequireDefault(require("dotenv"));
8
+ var _utils = require("./utils");
9
9
  var _enums = require("../../runtime/enums");
10
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ _dotenv.default.config({
13
+ path: `.env`
14
+ });
11
15
  _commander.program.name("intuned-run").description("Run an Intuned API with parameters").argument("<api-name>", "Name of the API to run").option("-p, --parameters-file <file>", "JSON file containing API parameters").option("-o, --output-file <file>", "File to write the API output to").action(async (apiName, options) => {
12
16
  const inputData = await (0, _utils.loadParameters)(options.parametersFile);
17
+ console.log(options);
13
18
  try {
14
19
  const result = await (0, _asyncLocalStorage.runWithContext)({
15
20
  runEnvironment: _enums.RunEnvironment.IDE,
16
21
  extendedPayloads: [],
17
22
  runId: (0, _nanoid.nanoid)()
18
- }, async () => {
19
- const result = await (0, _utils.runApiViaCLI)(apiName, inputData, options);
20
- return result;
21
- });
23
+ }, () => (0, _utils.runApiViaCLI)(apiName, inputData, options));
22
24
  if (!result) {
23
25
  console.log(_chalk.default.yellow("No result returned from the API"));
24
26
  return;
@@ -45,6 +45,7 @@ async function writeResultToFile(outputFileId, result, runId) {
45
45
  await fs.writeJSON(outputPath, result, {
46
46
  spaces: 2
47
47
  });
48
+ console.log(_chalk.default.green(`✓ API executed successfully. Result written to ${outputPath}`));
48
49
  _Logger.logger.info(`Result written to ${outputPath}`);
49
50
  } catch (error) {
50
51
  _Logger.logger.error(`Failed to write result to file: ${error.message}`);
@@ -1,4 +1,5 @@
1
- import { AsyncLocalStorage } from "async_hooks";
1
+ /// <reference types="node" />
2
+ import { AsyncLocalStorage } from "node:async_hooks";
2
3
  import { Payload, RunInfo } from "../../runtime/export";
3
4
  export declare const asyncLocalStorage: AsyncLocalStorage<InternalRunInfo>;
4
5
  export declare function runWithContext<R, TArgs extends any[]>(contextData: InternalRunInfo, callback: (...args: TArgs) => R, ...args: TArgs): R;
@@ -6,15 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.asyncLocalStorage = void 0;
7
7
  exports.getExecutionContext = getExecutionContext;
8
8
  exports.runWithContext = runWithContext;
9
- var _async_hooks = require("async_hooks");
10
- const asyncLocalStorage = exports.asyncLocalStorage = new _async_hooks.AsyncLocalStorage();
9
+ var _nodeAsync_hooks = require("node:async_hooks");
10
+ const asyncLocalStorage = exports.asyncLocalStorage = new _nodeAsync_hooks.AsyncLocalStorage();
11
11
  function runWithContext(contextData, callback, ...args) {
12
12
  return asyncLocalStorage.run(contextData, callback, ...args);
13
13
  }
14
14
  function getExecutionContext() {
15
15
  const contextData = asyncLocalStorage.getStore();
16
- console.log({
17
- getExecutionContext: contextData
18
- });
19
16
  return contextData;
20
17
  }
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,52 @@
1
+ export declare const templateIds: string[];
2
+ export type TemplateId = (typeof templateIds)[number];
3
+ /**
4
+ * A simple, tree-like structure to describe the contents of a folder to be mounted.
5
+ *
6
+ * @example
7
+ * ```
8
+ * const tree = {
9
+ * myproject: {
10
+ * directory: {
11
+ * 'foo.js': {
12
+ * file: {
13
+ * contents: 'const x = 1;',
14
+ * },
15
+ * },
16
+ * .envrc: {
17
+ * file: {
18
+ * contents: 'ENVIRONMENT=staging'
19
+ * }
20
+ * },
21
+ * },
22
+ * },
23
+ * emptyFolder: {
24
+ * directory: {}
25
+ * },
26
+ * };
27
+ * ```
28
+ */
29
+ export interface FileSystemTree {
30
+ [name: string]: DirectoryNode | FileNode;
31
+ }
32
+ /**
33
+ * Represents a directory, see {@link FileSystemTree}.
34
+ */
35
+ export interface DirectoryNode {
36
+ directory: FileSystemTree;
37
+ }
38
+ /**
39
+ * Represents a file, see {@link FileSystemTree}.
40
+ */
41
+ export interface FileNode {
42
+ file: {
43
+ /**
44
+ * The contents of the file, either as a UTF-8 string or as raw binary.
45
+ */
46
+ contents: string | Uint8Array;
47
+ };
48
+ }
49
+ export interface AuthCredentials {
50
+ workspaceId: string;
51
+ apiKey: string;
52
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.templateIds = void 0;
7
+ const templateIds = exports.templateIds = ["default", "empty", "linkedin-recorder", "api-auth-sessions", "nested-scheduling", "ai-extractors", "npm-auth-sessions", "python-empty"];
@@ -0,0 +1,5 @@
1
+ export declare function getAuthCredentials(options: any): {
2
+ workspaceId: any;
3
+ apiKey: any;
4
+ };
5
+ export declare function getSettingIntunedJSON(key: string): null;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAuthCredentials = getAuthCredentials;
7
+ exports.getSettingIntunedJSON = getSettingIntunedJSON;
8
+ function getAuthCredentials(options) {
9
+ const workspaceId = options.workspaceId || process.env.INTUNED_WORKSPACE_ID;
10
+ const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
11
+ const missingAuth = [];
12
+ if (!workspaceId) {
13
+ missingAuth.push({
14
+ type: "input",
15
+ name: "workspaceId",
16
+ message: "Enter your Intuned workspace ID:",
17
+ validate: input => input.trim() !== "" ? true : "Workspace ID is required"
18
+ });
19
+ }
20
+ if (!apiKey) {
21
+ missingAuth.push({
22
+ type: "password",
23
+ name: "apiKey",
24
+ message: "Enter your Intuned API key:",
25
+ mask: "*",
26
+ validate: input => input.trim() !== "" ? true : "API key is required"
27
+ });
28
+ }
29
+ if (missingAuth.length) {
30
+ throw new Error("Authentication details are required. Please provide them via command line options or environment variables.");
31
+ }
32
+ return {
33
+ workspaceId,
34
+ apiKey
35
+ };
36
+ }
37
+ function getSettingIntunedJSON(key) {
38
+ return null;
39
+ }
@@ -181,7 +181,6 @@ async function* runApiGenerator({
181
181
  break;
182
182
  }
183
183
  } else {
184
- (0, _asyncLocalStorage.getExecutionContext)();
185
184
  result = await importedModule.func(...automationFunctionParameters);
186
185
  }
187
186
  return (0, _neverthrow.ok)({
@@ -261,7 +260,6 @@ async function importUsingImportFunction(path, importFunction) {
261
260
  });
262
261
  }
263
262
  if (imported.default.constructor.name === "AsyncFunction") {
264
- (0, _asyncLocalStorage.getExecutionContext)();
265
263
  return (0, _neverthrow.ok)({
266
264
  type: "async",
267
265
  func: imported.default
@@ -545,12 +545,12 @@ export declare const runApiParametersSchema: z.ZodObject<{
545
545
  } | undefined;
546
546
  }, {
547
547
  environment: "standalone";
548
+ headless?: boolean | undefined;
548
549
  proxy?: {
549
550
  server: string;
550
551
  username: string;
551
552
  password: string;
552
553
  } | undefined;
553
- headless?: boolean | undefined;
554
554
  }>, z.ZodObject<{
555
555
  environment: z.ZodLiteral<"cdp">;
556
556
  cdpAddress: z.ZodString;
@@ -673,12 +673,12 @@ export declare const runApiParametersSchema: z.ZodObject<{
673
673
  } | undefined;
674
674
  runOptions?: {
675
675
  environment: "standalone";
676
+ headless?: boolean | undefined;
676
677
  proxy?: {
677
678
  server: string;
678
679
  username: string;
679
680
  password: string;
680
681
  } | undefined;
681
- headless?: boolean | undefined;
682
682
  } | {
683
683
  mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
684
684
  environment: "cdp";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.0.6-cli.8",
3
+ "version": "1.0.6-cli.8.0.2",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -69,7 +69,6 @@
69
69
  "applicationinsights": "^2.9.2",
70
70
  "async-retry": "^1.3.3",
71
71
  "babel-plugin-dynamic-import-node": "^2.3.3",
72
- "box": "^0.0.4",
73
72
  "boxen": "^8.0.1",
74
73
  "chalk": "^4.1.2",
75
74
  "commander": "^11.0.0",
@@ -141,4 +140,4 @@
141
140
  "peerDependencies": {
142
141
  "@intuned/runtime": "*"
143
142
  }
144
- }
143
+ }
@@ -12,7 +12,6 @@ export default async function handler(
12
12
  ) {
13
13
  const page = extendPlaywrightPage(_playwrightPage);
14
14
 
15
- console.log(params);
16
15
  // go to the url that is passed in the params
17
16
  await page.goto(params.bookFullUrl);
18
17
 
@@ -0,0 +1,35 @@
1
+ import { BrowserContext, Page } from "playwright-core";
2
+ import { extendPlaywrightPage } from "@intuned/sdk/playwright";
3
+ import { extendPayload } from "@intuned/sdk/runtime";
4
+ import { extractBooks } from "../utils/books";
5
+
6
+ interface Params {
7
+ // Add your params here
8
+ }
9
+
10
+ export default async function handler(
11
+ params: Params,
12
+ _playwrightPage: Page,
13
+ context: BrowserContext
14
+ ) {
15
+ // extends playwright page with Intuned helpers.
16
+ const page = extendPlaywrightPage(_playwrightPage);
17
+
18
+ await page.goto("https://books.toscrape.com/");
19
+
20
+ // optimized extractor!
21
+ // for more info checkout
22
+ // https://docs.intunedhq.com/docs/data-extraction/web-data-extraction
23
+
24
+ const result = await extractBooks(page);
25
+ // for each book on the main page, schedule api to get details
26
+ result.forEach((book) => {
27
+ // Extend job payload so it runs API `book-details` with provided params
28
+ extendPayload({
29
+ api: "book-details",
30
+ parameters: {
31
+ bookFullUrl: `${page.url()}${book.bookUrl}`,
32
+ },
33
+ });
34
+ });
35
+ }
package/r/api/c.ts ADDED
File without changes
@@ -27,10 +27,7 @@
27
27
  "@intuned/sdk": "2.0.2",
28
28
  "@types/intuned__sdk": "npm:@intuned/sdk-types@2.0.2",
29
29
  "@types/node": "^20.10.3",
30
- "axios": "^1.9.0",
31
- "lodash": "^4.17.21",
32
30
  "playwright": "1.44.1",
33
- "playwright-core": "1.44.1",
34
- "ts-node": "^10.9.2"
31
+ "playwright-core": "1.44.1"
35
32
  }
36
33
  }
@@ -0,0 +1,47 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": false,
4
+ "experimentalDecorators": true,
5
+ "sourceMap": true,
6
+ "baseUrl": ".",
7
+ "lib": ["dom", "dom.iterable", "esnext", "es2021"],
8
+ "module": "commonjs",
9
+ "target": "es2021",
10
+ "allowJs": true,
11
+ "skipLibCheck": true,
12
+ "strict": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "noEmit": false,
15
+ "incremental": true,
16
+ "esModuleInterop": true,
17
+ "resolveJsonModule": true,
18
+ "isolatedModules": true,
19
+ "jsx": "preserve",
20
+ "noImplicitAny": false,
21
+ "composite": false,
22
+ "inlineSources": false,
23
+ "moduleResolution": "node",
24
+ "noUnusedLocals": false,
25
+ "noUnusedParameters": false,
26
+ "preserveWatchOutput": true,
27
+ "rootDir": "./",
28
+ "outDir": "./dist",
29
+ "paths": {
30
+ "primitives/*": ["components/primitives/*"]
31
+ }
32
+ },
33
+ "include": [
34
+ "next-env.d.ts",
35
+ "**/*.ts",
36
+ "**/*.tsx",
37
+ "node_modules/monaco-editor/**/*.d.ts",
38
+ "node_modules/@monaco-editor/**/*.d.ts",
39
+ "node_modules/@kusto/monaco-kusto/**/*.d.ts"
40
+ ],
41
+ "exclude": [
42
+ "public",
43
+ "dist",
44
+ "packagerWorkerAssets/packagerTemplates",
45
+ "httpRequests"
46
+ ]
47
+ }
@@ -0,0 +1,32 @@
1
+ import { Page } from "playwright-core";
2
+
3
+ interface BookItem {
4
+ name: string;
5
+ bookUrl: string;
6
+ }
7
+
8
+ export async function extractBooks(page: Page): Promise<BookItem[]> {
9
+ await page.waitForSelector("article.product_pod");
10
+
11
+ const books: BookItem[] = [];
12
+
13
+ const bookElements = await page.getByRole("article").all();
14
+
15
+ for (const bookElement of bookElements) {
16
+ const linkElement = bookElement.getByRole("link").first();
17
+
18
+ const name =
19
+ (await linkElement.getAttribute("title")) ||
20
+ (await linkElement.textContent()) ||
21
+ "Unknown Title";
22
+
23
+ const bookUrl = (await linkElement.getAttribute("href")) || "";
24
+
25
+ books.push({
26
+ name: name.trim(),
27
+ bookUrl: bookUrl.trim(),
28
+ });
29
+ }
30
+
31
+ return books;
32
+ }
@@ -2264,15 +2264,6 @@ axios@^1.6.1:
2264
2264
  form-data "^4.0.0"
2265
2265
  proxy-from-env "^1.1.0"
2266
2266
 
2267
- axios@^1.9.0:
2268
- version "1.9.0"
2269
- resolved "https://registry.yarnpkg.com/axios/-/axios-1.9.0.tgz#25534e3b72b54540077d33046f77e3b8d7081901"
2270
- integrity sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==
2271
- dependencies:
2272
- follow-redirects "^1.15.6"
2273
- form-data "^4.0.0"
2274
- proxy-from-env "^1.1.0"
2275
-
2276
2267
  babel-plugin-dynamic-import-node@^2.3.3:
2277
2268
  version "2.3.3"
2278
2269
  resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3"
@@ -4334,7 +4325,7 @@ ts-node@10.9.1:
4334
4325
  v8-compile-cache-lib "^3.0.1"
4335
4326
  yn "3.1.1"
4336
4327
 
4337
- ts-node@^10.9.1, ts-node@^10.9.2:
4328
+ ts-node@^10.9.1:
4338
4329
  version "10.9.2"
4339
4330
  resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f"
4340
4331
  integrity sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==
package/WebTemplate.zip DELETED
Binary file