@intuned/runtime-dev 1.0.6-cli-auth.0.1.3-test → 1.0.6-cli.1

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 +2 -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
@@ -0,0 +1,71 @@
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
+ }
@@ -0,0 +1,223 @@
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;
@@ -0,0 +1,38 @@
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
+ }
@@ -0,0 +1,72 @@
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
+ }
@@ -0,0 +1,76 @@
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
+ }
@@ -0,0 +1,47 @@
1
+ import { BrowserContext, Page } from "playwright-core";
2
+ import {
3
+ extractMarkdownFromFile,
4
+ extractMarkdownFromPage,
5
+ extractTablesFromFile,
6
+ } from "@intuned/sdk/ai-extractors";
7
+ import { extendPlaywrightPage } from "@intuned/sdk/playwright";
8
+
9
+ interface Params {
10
+ // Add your params here
11
+ }
12
+
13
+ export default async function handler(
14
+ params: Params,
15
+ _playwrightPage: Page,
16
+ context: BrowserContext
17
+ ) {
18
+ const page = extendPlaywrightPage(_playwrightPage);
19
+ await page.goto(
20
+ "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
21
+ );
22
+ const siteMarkdown = extractMarkdownFromPage(page);
23
+
24
+ const specMarkdown = await extractMarkdownFromFile(
25
+ {
26
+ type: "pdf",
27
+ source: {
28
+ type: "url",
29
+ data: "https://intuned-docs-public-images.s3.amazonaws.com/27UP600_27UP650_ENG_US.pdf",
30
+ },
31
+ },
32
+ { label: "pdf_markdown" }
33
+ );
34
+
35
+ const fileTables = await extractTablesFromFile(
36
+ {
37
+ type: "pdf",
38
+ source: {
39
+ type: "url",
40
+ data: "https://intuned-docs-public-images.s3.amazonaws.com/27UP600_27UP650_ENG_US.pdf",
41
+ },
42
+ },
43
+ { label: "pdf_markdown" }
44
+ );
45
+
46
+ return { siteMarkdown, specMarkdown, fileTables };
47
+ }
@@ -0,0 +1,49 @@
1
+ import { BrowserContext, Page } from "playwright-core";
2
+ import { extendPlaywrightPage } from "@intuned/sdk/playwright";
3
+
4
+ interface Params {
5
+ category?: 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
+ await page.goto("https://books.toscrape.com/");
15
+ if (params.category)
16
+ await page
17
+ .locator("div.side_categories")
18
+ .getByText(params.category)
19
+ .click();
20
+ const books = await page.extractArrayOptimized({
21
+ label: "books_list",
22
+ itemEntityName: "book",
23
+ prompt: "scrape the books list from the page.",
24
+ strategy: {
25
+ model: "claude-3.5-sonnet",
26
+ type: "HTML",
27
+ },
28
+ itemEntitySchema: {
29
+ type: "object",
30
+ properties: {
31
+ title: {
32
+ type: "string",
33
+ primary: true,
34
+ description: "book title",
35
+ },
36
+ price: {
37
+ type: "string",
38
+ description: "book price",
39
+ },
40
+ in_stock: {
41
+ type: "string",
42
+ description: "book in stock or out of stock",
43
+ },
44
+ },
45
+ required: ["title", "price", "in_stock"],
46
+ },
47
+ });
48
+ return books;
49
+ }
@@ -0,0 +1,54 @@
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.extractObjectOptimized({
26
+ label: "books_to_scrape",
27
+ entityName: "book_info",
28
+ entitySchema: {
29
+ type: "object",
30
+ properties: {
31
+ title: {
32
+ type: "string",
33
+ description: "title of the book",
34
+ },
35
+ price: {
36
+ type: "string",
37
+ },
38
+ in_stock: {
39
+ type: "string",
40
+ },
41
+ UPC: {
42
+ type: "string",
43
+ },
44
+ product_type: {
45
+ type: "string",
46
+ },
47
+ },
48
+ required: ["title", "price", "in_stock", "UPC", "product_type"],
49
+ },
50
+ });
51
+ books.push(result);
52
+ }
53
+ return books;
54
+ }