@intuned/runtime-dev 1.0.6-dev-2 → 1.0.6-playwright-1.46.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 (33) hide show
  1. package/InterfaceTemplate/utils.ts +31 -53
  2. package/dist/commands/common/tsNodeImport.d.ts +1 -2
  3. package/dist/commands/common/tsNodeImport.js +5 -19
  4. package/dist/commands/common/utils/unixSocket.d.ts +0 -1
  5. package/dist/commands/interface/run.js +3 -30
  6. package/dist/common/asyncLocalStorage/index.d.ts +0 -1
  7. package/dist/common/runApi/index.d.ts +0 -1
  8. package/dist/common/runApi/index.js +2 -9
  9. package/dist/common/runApi/types.d.ts +3 -9
  10. package/package.json +4 -11
  11. package/bin/intuned-deploy +0 -3
  12. package/bin/intuned-init +0 -3
  13. package/bin/intuned-run +0 -3
  14. package/dist/commands/deploy/deploy.d.ts +0 -2
  15. package/dist/commands/deploy/deploy.js +0 -34
  16. package/dist/commands/deploy/utils.d.ts +0 -7
  17. package/dist/commands/deploy/utils.js +0 -196
  18. package/dist/commands/init/init.d.ts +0 -2
  19. package/dist/commands/init/init.js +0 -23
  20. package/dist/commands/init/types.d.ts +0 -52
  21. package/dist/commands/init/types.js +0 -7
  22. package/dist/commands/init/utils.d.ts +0 -9
  23. package/dist/commands/init/utils.js +0 -145
  24. package/dist/commands/intuned-run/intuned-run.d.ts +0 -4
  25. package/dist/commands/intuned-run/intuned-run.js +0 -84
  26. package/dist/commands/intuned-run/utils.d.ts +0 -1
  27. package/dist/commands/intuned-run/utils.js +0 -34
  28. package/my-intuned-project/Intuned.json +0 -15
  29. package/my-intuned-project/api/book-details.ts +0 -46
  30. package/my-intuned-project/api/books-all.ts +0 -68
  31. package/my-intuned-project/package.json +0 -36
  32. package/my-intuned-project/params/bookInput.json +0 -3
  33. package/my-intuned-project/yarn.lock +0 -4539
@@ -1,52 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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"];
@@ -1,9 +0,0 @@
1
- import { AuthCredentials, FileSystemTree } from "./types";
2
- export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
3
- export declare function checkEmptyDirectory(): Promise<void>;
4
- export declare function getAuthCredentials(options: any): {
5
- workspaceId: any;
6
- apiKey: any;
7
- };
8
- export declare function selectTemplate(templateName: any): Promise<any>;
9
- export declare function scaffoldProject(templateId: string, authCredentials: AuthCredentials): Promise<void>;
@@ -1,145 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.checkEmptyDirectory = checkEmptyDirectory;
7
- exports.getAuthCredentials = getAuthCredentials;
8
- exports.mountFiles = mountFiles;
9
- exports.scaffoldProject = scaffoldProject;
10
- exports.selectTemplate = selectTemplate;
11
- var fs = _interopRequireWildcard(require("fs-extra"));
12
- var _types = require("./types");
13
- var _chalk = _interopRequireDefault(require("chalk"));
14
- var _inquirer = _interopRequireDefault(require("inquirer"));
15
- var _path = _interopRequireDefault(require("path"));
16
- var _boxen = _interopRequireDefault(require("boxen"));
17
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
- 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); }
19
- 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; }
20
- function _isDirectoryNode(node) {
21
- return node.directory !== undefined;
22
- }
23
- function _isFileNode(node) {
24
- return node.file !== undefined;
25
- }
26
- async function mountFiles(cwd, tree) {
27
- for (const name in tree) {
28
- const fullPath = _path.default.join(cwd, name);
29
- const node = tree[name];
30
- if (_isDirectoryNode(node)) {
31
- await fs.ensureDir(fullPath);
32
- await mountFiles(fullPath, node.directory);
33
- } else if (_isFileNode(node)) {
34
- await fs.writeFile(fullPath, node.file.contents);
35
- }
36
- }
37
- }
38
- async function checkEmptyDirectory() {
39
- const currentDir = process.cwd();
40
- try {
41
- const stats = await fs.stat(currentDir);
42
- if (!stats.isDirectory()) {
43
- throw new Error("The current path is not a directory.");
44
- }
45
- const files = await fs.readdir(currentDir);
46
- const significantFiles = files.filter(file => ![".git", ".DS_Store", "Thumbs.db", ".gitkeep"].includes(file));
47
- if (significantFiles.length) {
48
- throw new Error("The current directory is not empty.");
49
- }
50
- } catch (error) {
51
- if (error.code === "ENOENT") {
52
- throw new Error("The specified directory does not exist.");
53
- }
54
- throw error;
55
- }
56
- }
57
- function getAuthCredentials(options) {
58
- const workspaceId = options.workspaceId || process.env.INTUNED_WORKSPACE_ID;
59
- const apiKey = options.apiKey || process.env.INTUNED_API_KEY;
60
- const missingAuth = [];
61
- if (!workspaceId) {
62
- missingAuth.push({
63
- type: "input",
64
- name: "workspaceId",
65
- message: "Enter your Intuned workspace ID:",
66
- validate: input => input.trim() !== "" ? true : "Workspace ID is required"
67
- });
68
- }
69
- if (!apiKey) {
70
- missingAuth.push({
71
- type: "password",
72
- name: "apiKey",
73
- message: "Enter your Intuned API key:",
74
- mask: "*",
75
- validate: input => input.trim() !== "" ? true : "API key is required"
76
- });
77
- }
78
- if (missingAuth.length) {
79
- throw new Error("Authentication details are required. Please provide them via command line options or environment variables.");
80
- }
81
- return {
82
- workspaceId,
83
- apiKey
84
- };
85
- }
86
- async function selectTemplate(templateName) {
87
- if (templateName) {
88
- const validTemplate = _types.templateIds.find(t => t === templateName);
89
- if (!validTemplate) {
90
- console.log(_chalk.default.yellow(`\n⚠️ Template "${templateName}" not found.`));
91
- } else {
92
- return templateName;
93
- }
94
- }
95
- console.log(_chalk.default.yellow("\n📋 Select a Template"));
96
- const {
97
- template
98
- } = await _inquirer.default.prompt([{
99
- type: "list",
100
- name: "template",
101
- message: "Which template would you like to use?",
102
- choices: _types.templateIds,
103
- loop: false
104
- }]);
105
- return template;
106
- }
107
- async function scaffoldProject(templateId, authCredentials) {
108
- const cwd = process.cwd();
109
- console.log(_chalk.default.cyan(`\n🚀 Initializing ${_chalk.default.bold(templateId)} project...\n`));
110
- console.log(_chalk.default.cyan("📦 Fetching template..."));
111
- const template = await fetchProjectTemplate(templateId, authCredentials);
112
- console.log(_chalk.default.green(`✓ Template "${template}" fetched successfully!`));
113
- console.log(_chalk.default.cyan("🔨 Creating project files..."));
114
- const codeTree = template;
115
- await mountFiles(cwd, codeTree);
116
- console.log(_chalk.default.green("✓ Project files created!"));
117
- console.log((0, _boxen.default)(_chalk.default.green(`✅ Project initialized successfully!`) + `\n\n${_chalk.default.cyan("Project details:")}` + `\n• Template: ${_chalk.default.bold(template)}` + `\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 install")} to install dependencies` + `\n3. Run ${_chalk.default.bold("npm start")} to start the development server`, {
118
- padding: 1,
119
- margin: 1,
120
- borderStyle: "round",
121
- borderColor: "green"
122
- }));
123
- }
124
- async function fetchProjectTemplate(templateId, authCredentials) {
125
- const {
126
- workspaceId,
127
- apiKey
128
- } = authCredentials;
129
- const baseUrl = "https://rauf-2.intuned-team-local.com";
130
- const url = `${baseUrl}/api/v1/workspace/${workspaceId}/templates/${templateId}`;
131
- const headers = {
132
- "x-api-key": apiKey
133
- };
134
- const response = await fetch(url, {
135
- headers
136
- });
137
- if (!response.ok) {
138
- throw new Error(`Error fetching template: ${response.statusText} (${response.status})`);
139
- }
140
- const data = await response.json();
141
- if (!data) {
142
- throw new Error("Template not found");
143
- }
144
- return data.template;
145
- }
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare function executeCLI(apiName: string, inputData: object | null | undefined, options: {
3
- outputFileId: string | undefined;
4
- }): Promise<void>;
@@ -1,84 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.executeCLI = executeCLI;
8
- var _commander = require("commander");
9
- var _chalk = _interopRequireDefault(require("chalk"));
10
- var fs = _interopRequireWildcard(require("fs-extra"));
11
- var _runApi = require("../../common/runApi");
12
- var _tsNodeImport = require("../common/tsNodeImport");
13
- var _utils = require("./utils");
14
- var _asyncLocalStorage = require("../../common/asyncLocalStorage");
15
- var _nanoid = require("nanoid");
16
- var _enums = require("../../runtime/enums");
17
- var _Logger = require("../../common/Logger");
18
- 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); }
19
- 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; }
20
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
- async function executeCLI(apiName, inputData, options) {
22
- const runApiResult = await (0, _runApi.runApi)({
23
- automationFunction: {
24
- name: `api/${apiName}`,
25
- params: inputData
26
- },
27
- runOptions: {
28
- environment: "standalone"
29
- },
30
- importFunction: _tsNodeImport.tsNodeImport
31
- });
32
- if (runApiResult.isErr()) {
33
- if (runApiResult.error instanceof _runApi.AutomationError) {
34
- throw runApiResult.error.error;
35
- }
36
- console.error(runApiResult.error);
37
- throw new Error("An error occurred while running the API");
38
- }
39
- const {
40
- result,
41
- extendedPayloads: payloadToAppend
42
- } = runApiResult.value;
43
- const isResponseObject = typeof result === "object" && result !== null;
44
- const hasMoreThank5Keys = isResponseObject && Object.keys(result).length > 5;
45
- const hasNestedObjects = isResponseObject && Object.values(result).some(value => typeof value === "object");
46
- const shouldWriteToFile = isResponseObject && (hasMoreThank5Keys || hasNestedObjects);
47
- const resultsDir = "/tmp/run-results";
48
- if (options.outputFileId && shouldWriteToFile) {
49
- _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
50
- fs.ensureDirSync(resultsDir);
51
- const path = `${resultsDir}/${options.outputFileId}.json`;
52
- await fs.writeJson(path, result, {
53
- spaces: 2
54
- });
55
- } else {
56
- console.log("result:", result);
57
- }
58
- const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
59
- if (hasPayloadToAppend && options.outputFileId) {
60
- _Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: payloads to append (Run: ${options.outputFileId})`));
61
- fs.ensureDirSync(resultsDir);
62
- const path = `${resultsDir}/${options.outputFileId}-payloads-to-append.json`;
63
- await fs.writeJson(path, payloadToAppend, {
64
- spaces: 2
65
- });
66
- } else if (hasPayloadToAppend) {
67
- _Logger.logger.info("payload to append:", payloadToAppend);
68
- _Logger.logger.info("This will only take an effect if this API run was part of a job.");
69
- }
70
- }
71
- _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) => {
72
- const inputData = await (0, _utils.loadParameters)(options.parametersFile);
73
- try {
74
- await (0, _asyncLocalStorage.runWithContext)({
75
- runEnvironment: _enums.RunEnvironment.IDE,
76
- extendedPayloads: [],
77
- runId: (0, _nanoid.nanoid)()
78
- }, () => executeCLI(apiName, inputData, options));
79
- } catch (error) {
80
- console.error(_chalk.default.red(`\nError: ${error.message}`));
81
- process.exit(1);
82
- }
83
- });
84
- _commander.program.parse(process.argv);
@@ -1 +0,0 @@
1
- export declare function loadParameters(parametersFile: string): Promise<object | null>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.loadParameters = loadParameters;
7
- var _path = _interopRequireDefault(require("path"));
8
- var fs = _interopRequireWildcard(require("fs-extra"));
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); }
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; }
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- async function loadParameters(parametersFile) {
13
- if (!parametersFile) {
14
- return {};
15
- }
16
- try {
17
- const filePath = _path.default.resolve(process.cwd(), parametersFile);
18
- await fs.access(filePath);
19
- let inputData = null;
20
- if (parametersFile) {
21
- inputData = await fs.readJSON(parametersFile);
22
- } else {
23
- inputData = {};
24
- }
25
- return inputData;
26
- } catch (error) {
27
- if (error.code === "ENOENT") {
28
- throw new Error(`Parameters file not found: ${parametersFile}`);
29
- } else if (error instanceof SyntaxError) {
30
- throw new Error(`Invalid JSON in parameters file: ${error.message}`);
31
- }
32
- throw new Error(`Error reading parameters file: ${error.message}`);
33
- }
34
- }
@@ -1,15 +0,0 @@
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
- }
@@ -1,46 +0,0 @@
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
- }
@@ -1,68 +0,0 @@
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
- }
@@ -1,36 +0,0 @@
1
- {
2
- "name": "Nested-Scheduling",
3
- "version": "1.0.0",
4
- "description": "project uses nested scheduling feature",
5
- "tags": [
6
- "Scrapper"
7
- ],
8
- "main": "index.js",
9
- "scripts": {
10
- "dev:local": "intuned-api-run sample playwright -j '{}'",
11
- "dev": "intuned-api-run",
12
- "debug": "node --inspect-brk ./node_modules/.bin/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
- "browser-save-state": "intuned-browser-save-state",
18
- "auth-session-check": "intuned-auth-session-check",
19
- "auth-session-create": "intuned-auth-session-create",
20
- "auth-session-refresh": "intuned-auth-session-refresh",
21
- "auth-session-load": "intuned-auth-session-load"
22
- },
23
- "author": "",
24
- "license": "ISC",
25
- "dependencies": {
26
- "@intuned/runtime": "1.0.5",
27
- "@intuned/sdk": "2.0.2",
28
- "@types/intuned__sdk": "npm:@intuned/sdk-types@2.0.2",
29
- "@types/node": "^20.10.3",
30
- "axios": "^1.9.0",
31
- "lodash": "^4.17.21",
32
- "playwright": "1.44.1",
33
- "playwright-core": "1.44.1",
34
- "ts-node": "^10.9.2"
35
- }
36
- }
@@ -1,3 +0,0 @@
1
- {
2
- "bookFullUrl": "https://books.toscrape.com/catalogue/mesaerion-the-best-science-fiction-stories-1800-1849_983/index.html"
3
- }