@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
@@ -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,18 +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
- "proxy": {
16
- "enabled": false
17
- }
18
- }
@@ -1,8 +0,0 @@
1
- [
2
- {
3
- "name": "Params #1",
4
- "value": "{\n \n}",
5
- "lastUsed": true,
6
- "id": "bd298105-4f2c-4795-b51f-9bdb7a7b2af6"
7
- }
8
- ]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"5db5d935-de48-4169-9de5-563930eec8d4"}]
@@ -1,8 +0,0 @@
1
- [
2
- {
3
- "name": "Params #1",
4
- "value": "{\n \n}",
5
- "lastUsed": true,
6
- "id": "6b18ea52-c56c-4eed-8ccd-6a07b24447c3"
7
- }
8
- ]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"fa888364-320a-4e59-ae31-ef215c5e21b7"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"fbae2096-c738-4351-8ddd-ca1416c13e06"}]
@@ -1,8 +0,0 @@
1
- [
2
- {
3
- "name": "Params #1",
4
- "value": "{\n \n}",
5
- "lastUsed": true,
6
- "id": "fbae2096-c738-4351-8ddd-ca1416c13e06"
7
- }
8
- ]
@@ -1,32 +0,0 @@
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
- ]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"fbae2096-c738-4351-8ddd-ca1416c13e06"}]
@@ -1,8 +0,0 @@
1
- [
2
- {
3
- "name": "Params #1",
4
- "value": "{\n \n}",
5
- "lastUsed": true,
6
- "id": "b56a67ee-c455-4572-978d-d90511b7395d"
7
- }
8
- ]
@@ -1 +0,0 @@
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"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"1979f992-0fc0-4b05-ad05-f0c3121cbf40"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"e871442d-ee30-4aa8-8d88-c390b0820a10"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"62424473-51c3-4af9-951b-9517142e8be7"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"eee7997c-523a-4be1-a731-4f680d959bcc"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"cc1e1dd2-bb31-4579-9f70-aa7dd834bb1f"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"70a5e237-a9a7-4450-b3b1-8356a7e77e96"}]
@@ -1 +0,0 @@
1
- [{"name":"Params #1","value":"{\n \n}","lastUsed":true,"id":"359a79a7-f069-4ad6-8a4a-145b0e3e555e"}]
@@ -1,71 +0,0 @@
1
- import { BrowserContext, Page } from "playwright-core";
2
- import { downloadFile } from "@intuned/sdk/files";
3
- import { extendPlaywrightPage } from "@intuned/sdk/playwright";
4
-
5
- interface Params {
6
- // Add your params here
7
- }
8
-
9
- export default async function handler(
10
- params: Params,
11
- _playwrightPage: Page,
12
- context: BrowserContext
13
- ) {
14
- const page = extendPlaywrightPage(_playwrightPage);
15
-
16
- /**
17
- * Download by clicking a locator that results in a downloaded file
18
- */
19
- await page.goto("https://www.princexml.com/samples/");
20
- const downloadlXmlFile = await downloadFile(page, {
21
- locator: page.locator("#dictionary > p.links > a:nth-child(2)"),
22
- });
23
- console.log({
24
- path: await downloadlXmlFile.path(),
25
- suggestedName: downloadlXmlFile.suggestedFilename(),
26
- });
27
-
28
- /**
29
- * directly download file from URL
30
- */
31
- const downloadedDirectPdf = await downloadFile(page, {
32
- url: "https://pdfobject.com/pdf/sample.pdf",
33
- });
34
- console.log({
35
- path: await downloadedDirectPdf.path(),
36
- suggestedName: downloadedDirectPdf.suggestedFilename(),
37
- });
38
-
39
- /**
40
- * Download by providing a trigger function that triggers the download
41
- */
42
- await page.goto("https://sandbox.intuned.dev/pdfs");
43
- const download = await downloadFile(page, {
44
- trigger: (page) =>
45
- page
46
- .locator(
47
- 'xpath=//*[@id="root"]/div/main/div/div/div/table/tbody/tr[1]/td[4]/a'
48
- )
49
- .click(),
50
- });
51
- console.log({
52
- path: await download.path(),
53
- suggestedName: download.suggestedFilename(),
54
- });
55
-
56
- /**
57
- * Print site and download as pdf
58
- */
59
- await page.goto(
60
- "https://css-tricks.com/quick-tip-making-a-print-this-page-button/"
61
- );
62
- const downloadPrintedPdf = await downloadFile(page, {
63
- type: "PrintPageAsPdf",
64
- });
65
- console.log({
66
- path: await downloadPrintedPdf.path(),
67
- suggestedName: downloadPrintedPdf.suggestedFilename(),
68
- });
69
-
70
- return {};
71
- }
@@ -1,223 +0,0 @@
1
- import { FormInputItem, extendPlaywrightPage } from "@intuned/sdk/playwright";
2
- import { BrowserContext, Locator, Page } from "playwright-core";
3
-
4
- export type Step = "ShippingAddress" | "PaymentDetails" | "Review";
5
-
6
- async function formSubmit(locator: Locator) {
7
- const nextButtonLocator = locator
8
- .page()
9
- .getByRole("button", { name: "Next" });
10
- await nextButtonLocator.waitFor({ state: "visible" });
11
- await nextButtonLocator.click();
12
- }
13
-
14
- async function getCurrentStep(page: Page): Promise<Step> {
15
- const title = await page.locator(
16
- "//html/body/div/div/main/div/div[2]/div[1]/h1"
17
- );
18
- if ((await title.textContent()) === "Shipping address")
19
- return "ShippingAddress";
20
- if ((await title.textContent()) === "Payment Details")
21
- return "PaymentDetails";
22
- if ((await title.textContent()) === "Review your order") return "Review";
23
- return "ShippingAddress";
24
- }
25
-
26
- const getFields = (step: Step, input: any): FormInputItem[] => {
27
- switch (step) {
28
- case "ShippingAddress":
29
- return getShippingAddressFields(input);
30
- case "PaymentDetails":
31
- return getPaymentDetailsFields(input);
32
- default:
33
- return [];
34
- }
35
- };
36
-
37
- const didFormSucceed = async (locator: Locator): Promise<boolean> => {
38
- return (await locator.page().locator(".error-message").count()) === 0;
39
- };
40
-
41
- async function run(_params: any, _page: Page, context: BrowserContext) {
42
- const page = extendPlaywrightPage(_page);
43
- await page.goto(
44
- "https://demo-site-eta.vercel.app/steps-form/ShippingAddress"
45
- );
46
-
47
- let currentStep = await getCurrentStep(page);
48
- while (currentStep !== "Review") {
49
- const fields = getFields(currentStep, params);
50
- await page.fillForm({
51
- formLocator: page.locator("main"),
52
- formInput: fields,
53
- isSubmitSuccessful: didFormSucceed,
54
- submitForm: formSubmit,
55
- autoRecoveryOptions: {
56
- enabled: true,
57
- recoveryData: params,
58
- },
59
- });
60
- currentStep = await getCurrentStep(page);
61
- }
62
-
63
- await page.getByRole("heading", { name: "Review your order" }).waitFor({
64
- state: "visible",
65
- });
66
-
67
- const res = await page.extractObjectOptimized({
68
- entityName: "checkout_details",
69
- label: "checkout_details",
70
- entitySchema: {
71
- type: "object",
72
- required: ["totalPrice", "cardType"],
73
- properties: {
74
- totalPrice: {
75
- type: "string",
76
- description: "total price of order",
77
- },
78
- cardType: {
79
- type: "string",
80
- description: "card type",
81
- },
82
- },
83
- },
84
- });
85
-
86
- return res;
87
- }
88
-
89
- const params = {
90
- firstName: "Ahmad",
91
- lastName: "Alhour",
92
- address1: "123 Main St",
93
- address2: "Apt 1",
94
- city: "San Francisco",
95
- state: "CA",
96
- zip: "94105",
97
- country: "US",
98
- nameOnCard: "Ahmad Alhour",
99
- cardNumber: "4242424242424242",
100
- expiration: "12/21",
101
- cvv: "123",
102
- saveAddress: true,
103
- };
104
-
105
- export const getShippingAddressFields = (input: any): FormInputItem[] => [
106
- {
107
- fieldSelector: {
108
- selector: "[name='firstName']",
109
- type: "css",
110
- },
111
- value: { type: "static", value: input.firstName },
112
- fieldType: "text-input",
113
- },
114
- {
115
- fieldSelector: {
116
- selector: "[name='lastName']",
117
- type: "css",
118
- },
119
- value: { type: "static", value: input.lastName },
120
- fieldType: "text-input",
121
- },
122
- {
123
- fieldSelector: {
124
- selector: "[name='addressLine1']",
125
- type: "css",
126
- },
127
- value: { type: "static", value: input.address1 },
128
- fieldType: "text-input",
129
- },
130
- {
131
- fieldSelector: {
132
- selector: "[name='addressLine2']",
133
- type: "css",
134
- },
135
- value: { type: "static", value: input.address2 },
136
- fieldType: "text-input",
137
- },
138
- {
139
- fieldSelector: {
140
- selector: "[name='city']",
141
- type: "css",
142
- },
143
- value: { type: "static", value: input.city },
144
- fieldType: "text-input",
145
- },
146
- {
147
- fieldSelector: {
148
- selector: "[name='state']",
149
- type: "css",
150
- },
151
- value: { type: "static", value: input.state },
152
- fieldType: "text-input",
153
- },
154
- {
155
- fieldSelector: {
156
- selector: "[name='zipCode']",
157
- type: "css",
158
- },
159
- value: { type: "static", value: input.zip },
160
- fieldType: "text-input",
161
- },
162
- {
163
- fieldSelector: {
164
- selector: "[name='country']",
165
- type: "css",
166
- },
167
- value: { type: "dynamic", source: { country: input.country } },
168
- fieldType: "select",
169
- },
170
- {
171
- fieldSelector: {
172
- selector: "[name='futurePurchase']",
173
- type: "css",
174
- },
175
- fieldType: "checkbox",
176
- value: { type: "static", value: true },
177
- },
178
- ];
179
-
180
- export const getPaymentDetailsFields = (input: any): FormInputItem[] => [
181
- {
182
- fieldSelector: {
183
- selector: "[name='nameOnCard']",
184
- type: "css",
185
- },
186
- value: { type: "static", value: input.nameOnCard },
187
- fieldType: "text-input",
188
- },
189
- {
190
- fieldSelector: {
191
- selector: "[name='cardNumber']",
192
- type: "css",
193
- },
194
- value: { type: "static", value: input.cardNumber },
195
- fieldType: "text-input",
196
- },
197
- {
198
- fieldSelector: {
199
- selector: "[name='expiryDate']",
200
- type: "css",
201
- },
202
- value: { type: "static", value: input.expiration },
203
- fieldType: "text-input",
204
- },
205
- {
206
- fieldSelector: {
207
- selector: "[name='cvv']",
208
- type: "css",
209
- },
210
- value: { type: "static", value: input.cvv },
211
- fieldType: "text-input",
212
- },
213
- {
214
- fieldSelector: {
215
- selector: "[name='rememberCreditCardDetails']",
216
- type: "css",
217
- },
218
- fieldType: "checkbox",
219
- value: { type: "static", value: true },
220
- },
221
- ];
222
-
223
- export default run;
@@ -1,38 +0,0 @@
1
- import { BrowserContext, Page } from "playwright-core";
2
- import { downloadFile, uploadFileToS3 } from "@intuned/sdk/files";
3
- import { extendPlaywrightPage } from "@intuned/sdk/playwright";
4
-
5
- interface Params {
6
- // Add your params here
7
- }
8
-
9
- export default async function handler(
10
- params: Params,
11
- _playwrightPage: Page,
12
- context: BrowserContext
13
- ) {
14
- const page = extendPlaywrightPage(_playwrightPage);
15
- await page.goto("https://www.princexml.com/samples/");
16
- const downloadlXmlFile = await downloadFile(page, {
17
- type: "DownloadFromDirectLink",
18
- downloadTrigger: page.locator("#dictionary > p.links > a:nth-child(2)"),
19
- });
20
- console.log({
21
- path: await downloadlXmlFile.path(),
22
- suggestedName: downloadlXmlFile.suggestedFilename(),
23
- });
24
-
25
- const file = await uploadFileToS3(downloadlXmlFile, {
26
- s3Configs: {
27
- accessKeyId: "xxxxxx",
28
- bucket: "xxxxx",
29
- region: "xxxxxx",
30
- secretAccessKey: "xxxxxx",
31
- },
32
- });
33
-
34
- return {
35
- signedUrl: await file.generateSignedUrl(),
36
- descriptor: file.urlDescriptor(),
37
- };
38
- }
@@ -1,72 +0,0 @@
1
- import { BrowserContext, Page } from "playwright-core";
2
- import { extendPlaywrightPage } from "@intuned/sdk/playwright";
3
-
4
- interface Params {
5
- // Add your params here
6
- }
7
-
8
- export default async function handler(
9
- params: Params,
10
- _playwrightPage: Page,
11
- context: BrowserContext
12
- ) {
13
- const page = extendPlaywrightPage(_playwrightPage);
14
- const url = [
15
- "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
16
- "https://books.toscrape.com/catalogue/tipping-the-velvet_999/index.html",
17
- "https://books.toscrape.com/catalogue/soumission_998/index.html",
18
- "https://books.toscrape.com/catalogue/the-requiem-red_995/index.html",
19
- "https://books.toscrape.com/catalogue/the-dirty-little-secrets-of-getting-your-dream-job_994/index.html",
20
- "https://books.toscrape.com/catalogue/the-coming-woman-a-novel-based-on-the-life-of-the-infamous-feminist-victoria-woodhull_993/index.html",
21
- ];
22
- const books = [] as any[];
23
- for (const link of url) {
24
- await page.goto(link);
25
- const result = await page.extractStructuredData({
26
- label: "books_to_scrape",
27
- dataSchema: {
28
- type: "object",
29
- properties: {
30
- title: {
31
- type: "string",
32
- description: "title of the book",
33
- },
34
- in_stock: {
35
- type: "boolean",
36
- },
37
- UPC: {
38
- type: "string",
39
- },
40
- product_type: {
41
- type: "string",
42
- },
43
- availableBooks: {
44
- type: "number",
45
- description: "number of avaible books",
46
- },
47
- price: {
48
- type: "object",
49
- properties: {
50
- price_include_tax: {
51
- type: "number",
52
- },
53
- price_execluding_tax: {
54
- type: "number",
55
- },
56
- tax_amount: {
57
- type: "number",
58
- },
59
- currency: {
60
- type: "string",
61
- enum: ["pound", "dollar"],
62
- },
63
- },
64
- },
65
- },
66
- required: [],
67
- },
68
- });
69
- books.push(result);
70
- }
71
- return books;
72
- }
@@ -1,76 +0,0 @@
1
- import { BrowserContext, Page } from "playwright-core";
2
- import { extractStructuredDataFromContent } from "@intuned/sdk/ai-extractors";
3
- import { extendPlaywrightPage } from "@intuned/sdk/playwright";
4
-
5
- interface Params {
6
- // Add your params here
7
- }
8
-
9
- export default async function handler(
10
- params: Params,
11
- _playwrightPage: Page,
12
- context: BrowserContext
13
- ) {
14
- const page = extendPlaywrightPage(_playwrightPage);
15
- const textData = extractStructuredDataFromContent(
16
- {
17
- type: "text",
18
- data: `"To Kill a Mockingbird" is a fiction novel written by Harper Lee. Published in 1960, this classic book delves into the themes of racial injustice and moral growth. The story is set in the American South during the 1930s. The book's ISBN is 978-0-06-112008-4.`,
19
- },
20
- {
21
- label: "book",
22
- model: "claude-3-haiku",
23
- dataSchema: {
24
- type: "object",
25
- properties: {
26
- title: {
27
- type: "string",
28
- description: "The title of the book",
29
- },
30
- author: {
31
- type: "string",
32
- description: "The author of the book",
33
- },
34
- published_year: {
35
- type: "integer",
36
- description: "The year the book was published",
37
- },
38
- genre: {
39
- type: "string",
40
- description: "The genre of the book",
41
- },
42
- ISBN: {
43
- type: "string",
44
- description: "The International Standard Book Number of the book",
45
- },
46
- },
47
- required: ["title", "author", "published_year", "genre", "ISBN"],
48
- },
49
- }
50
- );
51
-
52
- const imageData = extractStructuredDataFromContent(
53
- {
54
- type: "image-url",
55
- image_type: "png",
56
- data: "https://intuned-docs-public-images.s3.amazonaws.com/guides/book-details.png",
57
- },
58
- {
59
- label: "image",
60
- model: "claude-3-haiku",
61
- dataSchema: {
62
- type: "object",
63
- properties: {
64
- title: {
65
- type: "string",
66
- },
67
- in_stock: {
68
- type: "boolean",
69
- },
70
- },
71
- required: ["title", "in_stock"],
72
- },
73
- }
74
- );
75
- return { imageData, textData };
76
- }