@intuned/runtime-dev 1.0.6-cli-auth.0.1.4-test → 1.0.6-cli.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 (92) hide show
  1. package/WebTemplate.zip +0 -0
  2. package/bin/intuned-run +3 -0
  3. package/dist/commands/common/utils/unixSocket.d.ts +0 -1
  4. package/dist/commands/deploy/deploy.js +10 -23
  5. package/dist/commands/deploy/utils.d.ts +2 -11
  6. package/dist/commands/deploy/utils.js +55 -267
  7. package/dist/commands/init/init.js +4 -3
  8. package/dist/{common/cli → commands/init}/types.d.ts +0 -22
  9. package/dist/commands/init/types.js +7 -0
  10. package/dist/commands/init/utils.d.ts +3 -5
  11. package/dist/commands/init/utils.js +24 -61
  12. package/dist/commands/intuned-run/intuned-run.js +35 -0
  13. package/dist/commands/intuned-run/utils.d.ts +5 -0
  14. package/dist/commands/intuned-run/utils.js +91 -0
  15. package/dist/common/asyncLocalStorage/index.d.ts +1 -2
  16. package/dist/common/asyncLocalStorage/index.js +5 -2
  17. package/dist/common/constants.d.ts +0 -1
  18. package/dist/common/constants.js +2 -3
  19. package/dist/common/runApi/types.d.ts +2 -2
  20. package/my-intuned-project/Intuned.json +15 -0
  21. package/my-intuned-project/api/book-details.ts +46 -0
  22. package/my-intuned-project/api/books-all.ts +68 -0
  23. package/my-intuned-project/emp/Intuned.json +18 -0
  24. package/my-intuned-project/emp/____testParameters/learn/actions/download.json +8 -0
  25. package/my-intuned-project/emp/____testParameters/learn/actions/fillForm.json +1 -0
  26. package/my-intuned-project/emp/____testParameters/learn/actions/upload.json +8 -0
  27. package/my-intuned-project/emp/____testParameters/learn/data-extraction/ai-extraction.json +1 -0
  28. package/my-intuned-project/emp/____testParameters/learn/data-extraction/extract-data-from-content.json +1 -0
  29. package/my-intuned-project/emp/____testParameters/learn/data-extraction/markdown-extraction.json +8 -0
  30. package/my-intuned-project/emp/____testParameters/learn/data-extraction/optimized-array-exteractor.json +32 -0
  31. package/my-intuned-project/emp/____testParameters/learn/data-extraction/optimized-object-extractor.json +1 -0
  32. package/my-intuned-project/emp/____testParameters/learn/data-extraction/pdf.json +8 -0
  33. package/my-intuned-project/emp/____testParameters/learn/playwright/fill-and-submit-forms.json +1 -0
  34. package/my-intuned-project/emp/____testParameters/learn/playwright/iframes.json +1 -0
  35. package/my-intuned-project/emp/____testParameters/learn/playwright/inject-code.json +1 -0
  36. package/my-intuned-project/emp/____testParameters/learn/playwright/locators-and-actions.json +1 -0
  37. package/my-intuned-project/emp/____testParameters/learn/playwright/navigation.json +1 -0
  38. package/my-intuned-project/emp/____testParameters/learn/playwright/network-interception.json +1 -0
  39. package/my-intuned-project/emp/____testParameters/learn/playwright/scrape-data.json +1 -0
  40. package/my-intuned-project/emp/____testParameters/learn/playwright/wait-for-state-change.json +1 -0
  41. package/my-intuned-project/emp/api/learn/actions/download.ts +71 -0
  42. package/my-intuned-project/emp/api/learn/actions/fillForm.ts +223 -0
  43. package/my-intuned-project/emp/api/learn/actions/upload.ts +38 -0
  44. package/my-intuned-project/emp/api/learn/data-extraction/ai-extraction.ts +72 -0
  45. package/my-intuned-project/emp/api/learn/data-extraction/extract-data-from-content.ts +76 -0
  46. package/my-intuned-project/emp/api/learn/data-extraction/markdown-extraction.ts +47 -0
  47. package/my-intuned-project/emp/api/learn/data-extraction/optimized-array-exteractor.ts +49 -0
  48. package/my-intuned-project/emp/api/learn/data-extraction/optimized-object-extractor.ts +54 -0
  49. package/my-intuned-project/emp/api/learn/data-extraction/pdf.ts +123 -0
  50. package/my-intuned-project/emp/api/learn/playwright/fill-and-submit-forms.ts +73 -0
  51. package/my-intuned-project/emp/api/learn/playwright/iframes.ts +22 -0
  52. package/my-intuned-project/emp/api/learn/playwright/inject-code.ts +40 -0
  53. package/my-intuned-project/emp/api/learn/playwright/locators-and-actions.ts +58 -0
  54. package/my-intuned-project/emp/api/learn/playwright/navigation.ts +25 -0
  55. package/my-intuned-project/emp/api/learn/playwright/network-interception.ts +43 -0
  56. package/my-intuned-project/emp/api/learn/playwright/scrape-data.ts +58 -0
  57. package/my-intuned-project/emp/api/learn/playwright/wait-for-state-change.ts +44 -0
  58. package/my-intuned-project/emp/api/sample.ts +15 -0
  59. package/my-intuned-project/emp/package.json +31 -0
  60. package/my-intuned-project/emp/utils/helpers.ts +3 -0
  61. package/my-intuned-project/emp/yarn.lock +4530 -0
  62. package/my-intuned-project/package.json +36 -0
  63. package/my-intuned-project/params/bookInput.json +3 -0
  64. package/my-intuned-project/yarn.lock +4539 -0
  65. package/package.json +10 -14
  66. package/bin/check-auth-session +0 -3
  67. package/bin/cli-build +0 -3
  68. package/bin/create-auth-session +0 -3
  69. package/bin/run-api +0 -3
  70. package/dist/commands/cli-auth-sessions/check.js +0 -40
  71. package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
  72. package/dist/commands/cli-auth-sessions/create.js +0 -53
  73. package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
  74. package/dist/commands/cli-auth-sessions/utils.js +0 -285
  75. package/dist/commands/cli-build/cli-build.d.ts +0 -2
  76. package/dist/commands/cli-build/cli-build.js +0 -20
  77. package/dist/commands/common/projectExclusions.d.ts +0 -2
  78. package/dist/commands/common/projectExclusions.js +0 -8
  79. package/dist/commands/run-api-cli/run-api.d.ts +0 -2
  80. package/dist/commands/run-api-cli/run-api.js +0 -57
  81. package/dist/commands/run-api-cli/utils.d.ts +0 -9
  82. package/dist/commands/run-api-cli/utils.js +0 -144
  83. package/dist/common/cli/cliReadme.d.ts +0 -1
  84. package/dist/common/cli/cliReadme.js +0 -92
  85. package/dist/common/cli/constants.d.ts +0 -33
  86. package/dist/common/cli/constants.js +0 -39
  87. package/dist/common/cli/types.js +0 -13
  88. package/dist/common/cli/utils.d.ts +0 -6
  89. package/dist/common/cli/utils.js +0 -35
  90. /package/bin/{deploy → intuned-deploy} +0 -0
  91. /package/bin/{init → intuned-init} +0 -0
  92. /package/dist/commands/{cli-auth-sessions/check.d.ts → intuned-run/intuned-run.d.ts} +0 -0
@@ -3,23 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports._isDirectoryNode = _isDirectoryNode;
7
- exports._isFileNode = _isFileNode;
8
6
  exports.checkEmptyDirectory = checkEmptyDirectory;
9
7
  exports.getAuthCredentials = getAuthCredentials;
10
8
  exports.mountFiles = mountFiles;
11
9
  exports.scaffoldProject = scaffoldProject;
12
10
  exports.selectTemplate = selectTemplate;
13
11
  var fs = _interopRequireWildcard(require("fs-extra"));
14
- var _types = require("../../common/cli/types");
12
+ var _types = require("./types");
15
13
  var _chalk = _interopRequireDefault(require("chalk"));
16
14
  var _inquirer = _interopRequireDefault(require("inquirer"));
17
15
  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
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
17
  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
18
  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; }
@@ -49,8 +42,10 @@ async function checkEmptyDirectory() {
49
42
  throw new Error("The current path is not a directory.");
50
43
  }
51
44
  const files = await fs.readdir(currentDir);
52
- const significantFiles = files.filter(file => !_projectExclusions.default.includes(file));
53
- return significantFiles.length === 0;
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
+ }
54
49
  } catch (error) {
55
50
  if (error.code === "ENOENT") {
56
51
  throw new Error("The specified directory does not exist.");
@@ -80,7 +75,7 @@ function getAuthCredentials(options) {
80
75
  });
81
76
  }
82
77
  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.`);
78
+ throw new Error("Authentication details are required. Please provide them via command line options or environment variables.");
84
79
  }
85
80
  return {
86
81
  workspaceId,
@@ -108,48 +103,36 @@ async function selectTemplate(templateName) {
108
103
  }]);
109
104
  return template;
110
105
  }
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
- }
106
+ async function scaffoldProject(templateId, authCredentials) {
132
107
  const cwd = process.cwd();
133
108
  console.log(_chalk.default.cyan(`\n🚀 Initializing ${_chalk.default.bold(templateId)} project...\n`));
134
109
  console.log(_chalk.default.cyan("📦 Fetching template..."));
135
- const template = await fetchProjectTemplate(templateId);
136
- console.log(_chalk.default.green(`✓ Template "${templateId}" fetched successfully`));
110
+ const template = await fetchProjectTemplate(templateId, authCredentials);
111
+ console.log(_chalk.default.green(`✓ Template "${template}" fetched successfully`));
137
112
  console.log(_chalk.default.cyan("🔨 Creating project files..."));
138
113
  const codeTree = template;
139
- await prepareCLITemplate(codeTree);
140
114
  await mountFiles(cwd, codeTree);
141
115
  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`, {
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`, {
143
117
  padding: 1,
144
118
  margin: 1,
145
119
  borderStyle: "round",
146
120
  borderColor: "green"
147
- }));
121
+ });
148
122
  }
149
- async function fetchProjectTemplate(templateId) {
150
- const baseUrl = (0, _utils.getBaseUrl)();
151
- const url = `${baseUrl}/api/templates/${templateId}`;
152
- const response = await fetch(url);
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
+ });
153
136
  if (!response.ok) {
154
137
  throw new Error(`Error fetching template: ${response.statusText} (${response.status})`);
155
138
  }
@@ -158,24 +141,4 @@ async function fetchProjectTemplate(templateId) {
158
141
  throw new Error("Template not found");
159
142
  }
160
143
  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
144
  }
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _chalk = _interopRequireDefault(require("chalk"));
6
+ var _utils = require("./utils");
7
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
8
+ var _nanoid = require("nanoid");
9
+ var _enums = require("../../runtime/enums");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ _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
+ const inputData = await (0, _utils.loadParameters)(options.parametersFile);
13
+ try {
14
+ const result = await (0, _asyncLocalStorage.runWithContext)({
15
+ runEnvironment: _enums.RunEnvironment.IDE,
16
+ extendedPayloads: [],
17
+ runId: (0, _nanoid.nanoid)()
18
+ }, () => (0, _utils.runApiViaCLI)(apiName, inputData, options));
19
+ if (!result) {
20
+ console.log(_chalk.default.yellow("No result returned from the API"));
21
+ return;
22
+ }
23
+ if (!options.outputFile) {
24
+ console.log(_chalk.default.green(`✓ API executed successfully`));
25
+ return;
26
+ }
27
+ const outputFileId = options.outputFile;
28
+ await (0, _utils.writeResultToFile)(outputFileId, result);
29
+ process.exit(0);
30
+ } catch (error) {
31
+ console.error(_chalk.default.red(`\nError: ${error.message}`));
32
+ process.exit(1);
33
+ }
34
+ });
35
+ _commander.program.parse(process.argv);
@@ -0,0 +1,5 @@
1
+ export declare function loadParameters(parametersFile: string): Promise<object | null>;
2
+ export declare function writeResultToFile(outputFileId: string, result: any, runId?: string): Promise<void>;
3
+ export declare function runApiViaCLI(apiName: string, inputData: object | null | undefined, options: {
4
+ outputFileId?: string;
5
+ }): Promise<any>;
@@ -0,0 +1,91 @@
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
+ 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
+ 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; }
17
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
+ async function loadParameters(parametersFile) {
19
+ if (!parametersFile) {
20
+ return {};
21
+ }
22
+ try {
23
+ const filePath = _path.default.join(process.cwd(), parametersFile);
24
+ await fs.access(filePath);
25
+ let inputData = null;
26
+ if (parametersFile) {
27
+ inputData = await fs.readJSON(parametersFile);
28
+ } else {
29
+ inputData = {};
30
+ }
31
+ return inputData;
32
+ } catch (error) {
33
+ if (error.code === "ENOENT") {
34
+ throw new Error(`Parameters file not found: ${parametersFile}`);
35
+ } else if (error instanceof SyntaxError) {
36
+ throw new Error(`Invalid JSON in parameters file: ${error.message}`);
37
+ }
38
+ throw new Error(`Error reading parameters file: ${error.message}`);
39
+ }
40
+ }
41
+ async function writeResultToFile(outputFileId, result, runId) {
42
+ const outputPath = _path.default.join(process.cwd(), `${outputFileId}.json`);
43
+ await fs.ensureDir(_path.default.dirname(outputPath));
44
+ try {
45
+ await fs.writeJSON(outputPath, result, {
46
+ spaces: 2
47
+ });
48
+ _Logger.logger.info(`Result written to ${outputPath}`);
49
+ } catch (error) {
50
+ _Logger.logger.error(`Failed to write result to file: ${error.message}`);
51
+ }
52
+ }
53
+ async function runApiViaCLI(apiName, inputData, options) {
54
+ const runApiResult = await (0, _runApi.runApi)({
55
+ automationFunction: {
56
+ name: `api/${apiName}`,
57
+ params: inputData
58
+ },
59
+ runOptions: {
60
+ headless: false,
61
+ environment: "standalone"
62
+ },
63
+ importFunction: _tsNodeImport.tsNodeImport
64
+ });
65
+ if (runApiResult.isErr()) {
66
+ if (runApiResult.error instanceof _runApi.AutomationError) {
67
+ throw runApiResult.error.error;
68
+ }
69
+ console.error(runApiResult.error);
70
+ throw new Error("An error occurred while running the API");
71
+ }
72
+ const {
73
+ result,
74
+ extendedPayloads: payloadToAppend
75
+ } = runApiResult.value;
76
+ const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
77
+ console.log("result:", result);
78
+ if (hasPayloadToAppend && options.outputFileId) {
79
+ const fileKey = `${options.outputFileId}-payloads-to-append.json`;
80
+ const outputPath = _path.default.join(process.cwd(), fileKey);
81
+ await fs.ensureDir(_path.default.dirname(outputPath));
82
+ await fs.writeJson(outputPath, payloadToAppend, {
83
+ spaces: 2
84
+ });
85
+ _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Payloads to append saved into (${outputPath})`));
86
+ } else if (hasPayloadToAppend) {
87
+ _Logger.logger.info("payload to append:", payloadToAppend);
88
+ _Logger.logger.info("This will only take an effect if this API run was part of a job.");
89
+ }
90
+ return result;
91
+ }
@@ -1,5 +1,4 @@
1
- /// <reference types="node" />
2
- import { AsyncLocalStorage } from "node:async_hooks";
1
+ import { AsyncLocalStorage } from "async_hooks";
3
2
  import { Payload, RunInfo } from "../../runtime/export";
4
3
  export declare const asyncLocalStorage: AsyncLocalStorage<InternalRunInfo>;
5
4
  export declare function runWithContext<R, TArgs extends any[]>(contextData: InternalRunInfo, callback: (...args: TArgs) => R, ...args: TArgs): R;
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.asyncLocalStorage = void 0;
7
7
  exports.getExecutionContext = getExecutionContext;
8
8
  exports.runWithContext = runWithContext;
9
- var _nodeAsync_hooks = require("node:async_hooks");
10
- const asyncLocalStorage = exports.asyncLocalStorage = new _nodeAsync_hooks.AsyncLocalStorage();
9
+ var _async_hooks = require("async_hooks");
10
+ const asyncLocalStorage = exports.asyncLocalStorage = new _async_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
+ });
16
19
  return contextData;
17
20
  }
@@ -1,2 +1 @@
1
1
  export declare const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
2
- export declare const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
@@ -3,6 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
7
- const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
8
- const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
6
+ exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
7
+ const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
@@ -545,12 +545,12 @@ export declare const runApiParametersSchema: z.ZodObject<{
545
545
  } | undefined;
546
546
  }, {
547
547
  environment: "standalone";
548
- headless?: boolean | undefined;
549
548
  proxy?: {
550
549
  server: string;
551
550
  username: string;
552
551
  password: string;
553
552
  } | 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;
677
676
  proxy?: {
678
677
  server: string;
679
678
  username: string;
680
679
  password: string;
681
680
  } | undefined;
681
+ headless?: boolean | undefined;
682
682
  } | {
683
683
  mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
684
684
  environment: "cdp";
@@ -0,0 +1,15 @@
1
+ {
2
+ "apiAccess": {
3
+ "enabled": true
4
+ },
5
+ "authSessions": {
6
+ "enabled": false
7
+ },
8
+ "scale": {
9
+ "machineCount": 1,
10
+ "softLimit": 8,
11
+ "hardLimit": 10,
12
+ "memory": 2048,
13
+ "cpus": 6
14
+ }
15
+ }
@@ -0,0 +1,46 @@
1
+ import { BrowserContext, Page } from "playwright-core";
2
+ import { extendPlaywrightPage } from "@intuned/sdk/playwright";
3
+
4
+ interface Params {
5
+ bookFullUrl: string;
6
+ }
7
+
8
+ export default async function handler(
9
+ params: Params,
10
+ _playwrightPage: Page,
11
+ context: BrowserContext
12
+ ) {
13
+ const page = extendPlaywrightPage(_playwrightPage);
14
+
15
+ console.log(params);
16
+ // go to the url that is passed in the params
17
+ await page.goto(params.bookFullUrl);
18
+
19
+ // optimized extractor!
20
+ // for more info checkout
21
+ // https://docs.intunedhq.com/docs/data-extraction/web-data-extraction
22
+ const result = await page.extractObjectOptimized({
23
+ label: "book-deatils",
24
+ entityName: "book_info",
25
+ entitySchema: {
26
+ type: "object",
27
+ properties: {
28
+ name: {
29
+ type: "string",
30
+ description: "book name",
31
+ },
32
+ upc: {
33
+ type: "string",
34
+ description: "upc of the book",
35
+ },
36
+ numberOfReviews: {
37
+ type: "string",
38
+ description: "Number of reviews on the book",
39
+ },
40
+ },
41
+ required: ["name", "upc"],
42
+ },
43
+ });
44
+
45
+ return result;
46
+ }
@@ -0,0 +1,68 @@
1
+ import { BrowserContext, Page } from "playwright-core";
2
+ import { extendPlaywrightPage } from "@intuned/sdk/playwright";
3
+ import { extendPayload } from "@intuned/sdk/runtime";
4
+ import { AsyncLocalStorage } from "async_hooks";
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
+ const result = await page.extractArrayOptimized({
24
+ itemEntityName: "book",
25
+ label: "books-scraper",
26
+ itemEntitySchema: {
27
+ type: "object",
28
+ properties: {
29
+ name: {
30
+ type: "string",
31
+ description: "name of the book",
32
+ primary: true,
33
+ },
34
+ bookUrl: {
35
+ type: "string",
36
+ description: "url of the book",
37
+ },
38
+ },
39
+ required: ["name", "bookUrl"],
40
+ },
41
+ // you can change the model and strategy type,
42
+ // for links, HTML is the right strategy to use
43
+ strategy: {
44
+ type: "HTML",
45
+ model: "claude-3-sonnet",
46
+ },
47
+ });
48
+
49
+ console.log(result);
50
+
51
+ extendPayload({
52
+ api: "book-details",
53
+ parameters: {
54
+ bookFullUrl: `${page.url()}${result[0].bookUrl}`,
55
+ },
56
+ });
57
+
58
+ // // for each book on the main page, schedule api to get details
59
+ // result.forEach((book) => {
60
+ // // Extend job payload so it runs API `book-details` with provided params
61
+ // extendPayload({
62
+ // api: "book-details",
63
+ // parameters: {
64
+ // bookFullUrl: `${page.url()}${book.bookUrl}`,
65
+ // },
66
+ // });
67
+ // });
68
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "apiAccess": {
3
+ "enabled": true
4
+ },
5
+ "authSessions": {
6
+ "enabled": false
7
+ },
8
+ "scale": {
9
+ "machineCount": 1,
10
+ "softLimit": 8,
11
+ "hardLimit": 10,
12
+ "memory": 2048,
13
+ "cpus": 6
14
+ },
15
+ "proxy": {
16
+ "enabled": false
17
+ }
18
+ }
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "name": "Params #1",
4
+ "value": "{\n \n}",
5
+ "lastUsed": true,
6
+ "id": "bd298105-4f2c-4795-b51f-9bdb7a7b2af6"
7
+ }
8
+ ]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"5db5d935-de48-4169-9de5-563930eec8d4"}]
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "name": "Params #1",
4
+ "value": "{\n \n}",
5
+ "lastUsed": true,
6
+ "id": "6b18ea52-c56c-4eed-8ccd-6a07b24447c3"
7
+ }
8
+ ]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"fa888364-320a-4e59-ae31-ef215c5e21b7"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"fbae2096-c738-4351-8ddd-ca1416c13e06"}]
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "name": "Params #1",
4
+ "value": "{\n \n}",
5
+ "lastUsed": true,
6
+ "id": "fbae2096-c738-4351-8ddd-ca1416c13e06"
7
+ }
8
+ ]
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "name": "Travel",
4
+ "value": "{\n \"category\": \"Travel\" \n}",
5
+ "lastUsed": false,
6
+ "id": "35975c22-13eb-4ba9-9781-888166c8bb99"
7
+ },
8
+ {
9
+ "name": "Fiction",
10
+ "value": "{\n \"category\": \"Fiction\" \n}",
11
+ "lastUsed": false,
12
+ "id": "1914cf7f-54c8-45be-b3eb-369c9a212975"
13
+ },
14
+ {
15
+ "name": "Horror",
16
+ "value": "{\n \"category\": \"Horror\" \n}",
17
+ "lastUsed": true,
18
+ "id": "31fc9623-d4bf-417c-a13f-c537c6167c28"
19
+ },
20
+ {
21
+ "name": "History",
22
+ "value": "{\n \"category\": \"History\" \n}",
23
+ "lastUsed": false,
24
+ "id": "02831c81-b198-4352-99bb-cbbbd4866883"
25
+ },
26
+ {
27
+ "name": "default",
28
+ "value": "{\n \n}",
29
+ "lastUsed": false,
30
+ "id": "e5f9d6f9-752b-4ef2-819c-e7168030a84c"
31
+ }
32
+ ]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"fbae2096-c738-4351-8ddd-ca1416c13e06"}]
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "name": "Params #1",
4
+ "value": "{\n \n}",
5
+ "lastUsed": true,
6
+ "id": "b56a67ee-c455-4572-978d-d90511b7395d"
7
+ }
8
+ ]
@@ -0,0 +1 @@
1
+ [{"name":"user 1","value":"{\n \"firstName\": \"Ahmad\",\n \"lastName\": \"Alhour\",\n \"address1\": \"123 Main St\",\n \"address2\": \"Apt 1\",\n \"city\": \"San Francisco\",\n \"state\": \"CA\",\n \"zip\": \"94105\",\n \"country\": \"United States\",\n \"nameOnCard\": \"Ahmad Alhour\",\n \"cardNumber\": \"4242424242424242\",\n \"expiration\": \"12/21\",\n \"cvv\": \"123\",\n \"saveAddress\": true\n}","lastUsed":true,"id":"9a8a55a0-1b8b-4f04-9ba0-7a205b59c887"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"1979f992-0fc0-4b05-ad05-f0c3121cbf40"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"e871442d-ee30-4aa8-8d88-c390b0820a10"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"62424473-51c3-4af9-951b-9517142e8be7"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"eee7997c-523a-4be1-a731-4f680d959bcc"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"cc1e1dd2-bb31-4579-9f70-aa7dd834bb1f"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"70a5e237-a9a7-4450-b3b1-8356a7e77e96"}]
@@ -0,0 +1 @@
1
+ [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"359a79a7-f069-4ad6-8a4a-145b0e3e555e"}]