@scopieflows/app-apify 0.1.1 → 0.2.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.
- package/package.json +10 -25
- package/src/index.d.ts +5 -4
- package/src/index.d.ts.map +1 -0
- package/src/index.js +37 -15
- package/src/index.js.map +1 -1
- package/src/lib/actions/get-dataset-items.d.ts +8 -3
- package/src/lib/actions/get-dataset-items.d.ts.map +1 -0
- package/src/lib/actions/get-dataset-items.js +34 -20
- package/src/lib/actions/get-dataset-items.js.map +1 -1
- package/src/lib/actions/get-key-value-store-record.d.ts +11 -0
- package/src/lib/actions/get-key-value-store-record.d.ts.map +1 -0
- package/src/lib/actions/get-key-value-store-record.js +92 -0
- package/src/lib/actions/get-key-value-store-record.js.map +1 -0
- package/src/lib/actions/run-actor.d.ts +16 -0
- package/src/lib/actions/run-actor.d.ts.map +1 -0
- package/src/lib/actions/run-actor.js +40 -0
- package/src/lib/actions/run-actor.js.map +1 -0
- package/src/lib/actions/run-task.d.ts +15 -0
- package/src/lib/actions/run-task.d.ts.map +1 -0
- package/src/lib/actions/run-task.js +39 -0
- package/src/lib/actions/run-task.js.map +1 -0
- package/src/lib/actions/scrape-single-url.d.ts +7 -0
- package/src/lib/actions/scrape-single-url.d.ts.map +1 -0
- package/src/lib/actions/scrape-single-url.js +105 -0
- package/src/lib/actions/scrape-single-url.js.map +1 -0
- package/src/lib/common/index.d.ts +114 -0
- package/src/lib/common/index.d.ts.map +1 -0
- package/src/lib/common/index.js +442 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/triggers/watch-actor-runs.d.ts +35 -0
- package/src/lib/triggers/watch-actor-runs.d.ts.map +1 -0
- package/src/lib/triggers/watch-actor-runs.js +46 -0
- package/src/lib/triggers/watch-actor-runs.js.map +1 -0
- package/src/lib/triggers/watch-task-runs.d.ts +31 -0
- package/src/lib/triggers/watch-task-runs.d.ts.map +1 -0
- package/src/lib/triggers/watch-task-runs.js +45 -0
- package/src/lib/triggers/watch-task-runs.js.map +1 -0
- package/README.md +0 -7
- package/src/i18n/de.json +0 -22
- package/src/i18n/es.json +0 -22
- package/src/i18n/fr.json +0 -22
- package/src/i18n/ja.json +0 -22
- package/src/i18n/nl.json +0 -22
- package/src/i18n/pt.json +0 -22
- package/src/i18n/ru.json +0 -23
- package/src/i18n/translation.json +0 -22
- package/src/i18n/vi.json +0 -23
- package/src/i18n/zh.json +0 -22
- package/src/lib/actions/get-actors.d.ts +0 -3
- package/src/lib/actions/get-actors.js +0 -32
- package/src/lib/actions/get-actors.js.map +0 -1
- package/src/lib/actions/get-last-run.d.ts +0 -5
- package/src/lib/actions/get-last-run.js +0 -43
- package/src/lib/actions/get-last-run.js.map +0 -1
- package/src/lib/actions/start-actor.d.ts +0 -6
- package/src/lib/actions/start-actor.js +0 -46
- package/src/lib/actions/start-actor.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scopieflows/app-apify",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"dependencies": {
|
|
5
|
-
"@sinclair/typebox": "0.34.11",
|
|
6
|
-
"ai": "^6.0.0",
|
|
7
|
-
"axios": "1.13.1",
|
|
8
|
-
"axios-retry": "4.4.1",
|
|
9
|
-
"deepmerge-ts": "7.1.0",
|
|
10
|
-
"form-data": "4.0.4",
|
|
11
|
-
"i18next": "23.13.0",
|
|
12
|
-
"mime-types": "2.1.35",
|
|
13
|
-
"nanoid": "3.3.8",
|
|
14
|
-
"semver": "7.6.0",
|
|
15
|
-
"socket.io-client": "4.8.1",
|
|
16
|
-
"zod": "4.1.13",
|
|
17
|
-
"@scopieflows/pieces-common": "0.11.2",
|
|
18
|
-
"@scopieflows/pieces-framework": "0.25.0",
|
|
19
|
-
"@scopieflows/shared": "0.33.0",
|
|
20
|
-
"tslib": "2.6.2"
|
|
21
|
-
},
|
|
22
|
-
"resolutions": {
|
|
23
|
-
"rollup": "npm:@rollup/wasm-node"
|
|
24
|
-
},
|
|
25
|
-
"types": "./src/index.d.ts",
|
|
3
|
+
"version": "0.2.1",
|
|
26
4
|
"main": "./src/index.js",
|
|
27
|
-
"
|
|
28
|
-
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@scopieflows/apps-common": "0.12.3",
|
|
8
|
+
"@scopieflows/apps-framework": "0.28.1",
|
|
9
|
+
"@scopieflows/shared": "0.54.0",
|
|
10
|
+
"tslib": "2.6.2",
|
|
11
|
+
"apify-client": "2.22.2"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export declare const apifyAuth: import("@scopieflows/
|
|
2
|
-
apikey: import("@scopieflows/
|
|
1
|
+
export declare const apifyAuth: import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
2
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
3
3
|
}>;
|
|
4
|
-
export declare const apify: import("@scopieflows/
|
|
5
|
-
apikey: import("@scopieflows/
|
|
4
|
+
export declare const apify: import("@scopieflows/apps-framework").Piece<import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
5
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
6
6
|
}>>;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,SAAS;;EA8BpB,CAAC;AAEH,eAAO,MAAM,KAAK;;GAoBhB,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.apify = exports.apifyAuth = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@scopieflows/
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/apps-framework");
|
|
6
6
|
const shared_1 = require("@scopieflows/shared");
|
|
7
|
+
const pieces_common_1 = require("@scopieflows/apps-common");
|
|
7
8
|
const get_dataset_items_1 = require("./lib/actions/get-dataset-items");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const run_actor_1 = require("./lib/actions/run-actor");
|
|
10
|
+
const common_1 = require("./lib/common");
|
|
11
|
+
const get_key_value_store_record_1 = require("./lib/actions/get-key-value-store-record");
|
|
12
|
+
const scrape_single_url_1 = require("./lib/actions/scrape-single-url");
|
|
13
|
+
const run_task_1 = require("./lib/actions/run-task");
|
|
14
|
+
const watch_task_runs_1 = require("./lib/triggers/watch-task-runs");
|
|
15
|
+
const watch_actor_runs_1 = require("./lib/triggers/watch-actor-runs");
|
|
11
16
|
exports.apifyAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
12
17
|
description: 'Enter API key authentication details',
|
|
13
18
|
props: {
|
|
@@ -17,29 +22,46 @@ exports.apifyAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
|
17
22
|
description: 'Find your API key on Apify in the settings, API & Integrations section.',
|
|
18
23
|
}),
|
|
19
24
|
},
|
|
20
|
-
// Optional Validation
|
|
21
25
|
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
-
|
|
26
|
+
try {
|
|
27
|
+
const client = (0, common_1.createApifyClient)(auth.apikey);
|
|
28
|
+
yield client.user('me').get();
|
|
29
|
+
return { valid: true };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error.statusCode === 401) {
|
|
33
|
+
return {
|
|
34
|
+
valid: false,
|
|
35
|
+
error: 'Invalid API token. Please check your token in Apify account settings.'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
23
38
|
return {
|
|
24
|
-
valid:
|
|
39
|
+
valid: false,
|
|
40
|
+
error: 'Unable to validate API token. Please check your connection and try again.'
|
|
25
41
|
};
|
|
26
42
|
}
|
|
27
|
-
return {
|
|
28
|
-
valid: false,
|
|
29
|
-
error: 'Invalid Api Key',
|
|
30
|
-
};
|
|
31
43
|
}),
|
|
32
44
|
required: true,
|
|
33
45
|
});
|
|
34
46
|
exports.apify = (0, pieces_framework_1.createPiece)({
|
|
35
47
|
displayName: 'Apify',
|
|
36
|
-
description: '
|
|
48
|
+
description: 'Access Apify tools for web scraping, data extraction, and automation.',
|
|
37
49
|
auth: exports.apifyAuth,
|
|
38
50
|
minimumSupportedRelease: '0.30.0',
|
|
39
|
-
logoUrl: '/pieces/apify.png',
|
|
51
|
+
logoUrl: 'https://cdn.scopieflows.com/pieces/apify.png',
|
|
40
52
|
categories: [shared_1.PieceCategory.BUSINESS_INTELLIGENCE],
|
|
41
53
|
authors: ['buttonsbond'],
|
|
42
|
-
actions: [get_dataset_items_1.getDatasetItems,
|
|
43
|
-
|
|
54
|
+
actions: [get_dataset_items_1.getDatasetItems, run_actor_1.runActor, run_task_1.runTask, get_key_value_store_record_1.getKeyValueStoreRecord, scrape_single_url_1.scrapeSingleUrl,
|
|
55
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
56
|
+
auth: exports.apifyAuth,
|
|
57
|
+
baseUrl: () => 'https://api.apify.com/v2',
|
|
58
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
return {
|
|
60
|
+
'Authorization': `Bearer ${auth.props.apikey}`
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
],
|
|
65
|
+
triggers: [watch_actor_runs_1.watchActorRunsTrigger, watch_task_runs_1.watchTaskRunsTrigger],
|
|
44
66
|
});
|
|
45
67
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[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IACjD,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,OAAO,EAAE,CAAC,mCAAe,EAAE,oBAAQ,EAAE,kBAAO,EAAE,mDAAsB,EAAE,mCAAe;QACnF,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,iBAAS;YACf,OAAO,EAAE,GAAG,EAAE,CAAC,0BAA0B;YACzC,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,eAAe,EAAE,UAAU,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;iBAC/C,CAAA;YACH,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,wCAAqB,EAAE,sCAAoB,CAAC;CACxD,CAAC,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export declare const getDatasetItems: import("@scopieflows/
|
|
2
|
-
apikey: import("@scopieflows/
|
|
1
|
+
export declare const getDatasetItems: import("@scopieflows/apps-framework").IAction<import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
2
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
3
3
|
}>, {
|
|
4
|
-
|
|
4
|
+
datasetId: import("@scopieflows/apps-framework").DropdownProperty<string, true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
5
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
6
|
+
}>>;
|
|
7
|
+
offset: import("@scopieflows/apps-framework").NumberProperty<false>;
|
|
8
|
+
limit: import("@scopieflows/apps-framework").NumberProperty<false>;
|
|
5
9
|
}>;
|
|
10
|
+
//# sourceMappingURL=get-dataset-items.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dataset-items.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-dataset-items.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe;;;;;;;;EA8C1B,CAAC"}
|
|
@@ -2,39 +2,53 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDatasetItems = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@scopieflows/
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/apps-framework");
|
|
6
6
|
const __1 = require("../..");
|
|
7
|
-
const
|
|
7
|
+
const common_1 = require("../common");
|
|
8
8
|
exports.getDatasetItems = (0, pieces_framework_1.createAction)({
|
|
9
9
|
name: 'getDatasetItems',
|
|
10
10
|
auth: __1.apifyAuth,
|
|
11
11
|
displayName: 'Get Dataset Items',
|
|
12
|
-
description: '
|
|
12
|
+
description: 'Retrieves items from a dataset.',
|
|
13
13
|
props: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
description: 'The runid of the completed Actors run [defaultDatasetId] (compulsory)',
|
|
14
|
+
datasetId: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.apifyAuth,
|
|
17
16
|
required: true,
|
|
17
|
+
refreshers: ['auth'],
|
|
18
|
+
displayName: 'Dataset',
|
|
19
|
+
description: 'Select the dataset to get items from.',
|
|
20
|
+
options: (props) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
return (0, common_1.createDropdownOptions)(props['auth'], common_1.listDatasets);
|
|
22
|
+
})
|
|
18
23
|
}),
|
|
24
|
+
offset: pieces_framework_1.Property.Number({
|
|
25
|
+
required: false,
|
|
26
|
+
displayName: 'Offset',
|
|
27
|
+
description: 'Number of items that should be skipped at the start. The default value is `0`.',
|
|
28
|
+
defaultValue: 0
|
|
29
|
+
}),
|
|
30
|
+
limit: pieces_framework_1.Property.Number({
|
|
31
|
+
required: false,
|
|
32
|
+
displayName: 'Limit',
|
|
33
|
+
description: 'Maximum number of results to return.',
|
|
34
|
+
defaultValue: 50
|
|
35
|
+
})
|
|
19
36
|
},
|
|
20
37
|
run(context) {
|
|
21
38
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
39
|
const apifyToken = context.auth.props.apikey;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
headers,
|
|
40
|
+
const { datasetId, offset, limit } = context.propsValue;
|
|
41
|
+
const client = (0, common_1.createApifyClient)(apifyToken);
|
|
42
|
+
const response = yield client.dataset(datasetId).listItems({
|
|
43
|
+
limit,
|
|
44
|
+
offset
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
items: response.items,
|
|
48
|
+
count: response.count,
|
|
49
|
+
datasetId,
|
|
34
50
|
};
|
|
35
|
-
const response = yield pieces_common_1.httpClient.sendRequest(httprequestdata);
|
|
36
|
-
return response.body;
|
|
37
51
|
});
|
|
38
|
-
}
|
|
52
|
+
}
|
|
39
53
|
});
|
|
40
54
|
//# sourceMappingURL=get-dataset-items.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-dataset-items.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"get-dataset-items.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-dataset-items.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,6BAAkC;AAClC,sCAAmF;AAEtE,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,aAAS;IACf,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,iCAAiC;IAC9C,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,IAAI,EAAE,aAAS;YACf,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,uCAAuC;YACpD,OAAO,EAAE,CAAO,KAAK,EAAE,EAAE;gBACvB,OAAO,IAAA,8BAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE,qBAAY,CAAC,CAAC;YAC5D,CAAC,CAAA;SACF,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACtB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,gFAAgF;YAC7F,YAAY,EAAE,CAAC;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,sCAAsC;YACnD,YAAY,EAAE,EAAE;SACjB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAC7C,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAExD,MAAM,MAAM,GAAG,IAAA,0BAAiB,EAAC,UAAU,CAAC,CAAC;YAE7C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC;gBACzD,KAAK;gBACL,MAAM;aACP,CAAC,CAAC;YAEH,OAAO;gBACL,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,SAAS;aACV,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const getKeyValueStoreRecord: import("@scopieflows/apps-framework").IAction<import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
2
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
3
|
+
}>, {
|
|
4
|
+
store: import("@scopieflows/apps-framework").DropdownProperty<string, true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
5
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
6
|
+
}>>;
|
|
7
|
+
recordKey: import("@scopieflows/apps-framework").DropdownProperty<string, true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
8
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
9
|
+
}>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=get-key-value-store-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-key-value-store-record.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-key-value-store-record.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,sBAAsB;;;;;;;;;EAyFjC,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getKeyValueStoreRecord = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/apps-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.getKeyValueStoreRecord = (0, pieces_framework_1.createAction)({
|
|
9
|
+
name: 'getKeyValueStoreRecord',
|
|
10
|
+
auth: __1.apifyAuth,
|
|
11
|
+
displayName: 'Get Key-Value Store Record',
|
|
12
|
+
description: 'Retrieves a value stored in the key-value store under a specific key',
|
|
13
|
+
props: {
|
|
14
|
+
store: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
auth: __1.apifyAuth,
|
|
16
|
+
required: true,
|
|
17
|
+
refreshers: ['auth'],
|
|
18
|
+
displayName: 'Key-Value Store ID',
|
|
19
|
+
description: 'The ID of the Key-Value Store.',
|
|
20
|
+
options: (props) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
return (0, common_1.createDropdownOptions)(props['auth'], common_1.listStores);
|
|
22
|
+
})
|
|
23
|
+
}),
|
|
24
|
+
recordKey: pieces_framework_1.Property.Dropdown({
|
|
25
|
+
auth: __1.apifyAuth,
|
|
26
|
+
required: true,
|
|
27
|
+
refreshers: ['auth', 'store'],
|
|
28
|
+
displayName: 'Key-Value Store Record Key',
|
|
29
|
+
description: 'The key of the record to be retrieved.',
|
|
30
|
+
options: (props) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
if (!props['auth'] || !props['store']) {
|
|
32
|
+
return {
|
|
33
|
+
disabled: true,
|
|
34
|
+
options: [],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const storeId = props['store'];
|
|
38
|
+
return (0, common_1.createDropdownOptions)(props['auth'], (apiKey) => (0, common_1.listRecords)(apiKey, storeId));
|
|
39
|
+
})
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
run(context) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
var _a;
|
|
45
|
+
const apifyToken = context.auth.props.apikey;
|
|
46
|
+
const { store, recordKey } = context.propsValue;
|
|
47
|
+
const client = (0, common_1.createApifyClient)(apifyToken);
|
|
48
|
+
const record = yield client.keyValueStore(store).getRecord(recordKey);
|
|
49
|
+
if (!record) {
|
|
50
|
+
throw new Error(`Record with key "${recordKey}" not found in store "${store}"`);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const isBinary = (0, common_1.isBinaryContentType)(record.contentType);
|
|
54
|
+
const isJson = (_a = record.contentType) === null || _a === void 0 ? void 0 : _a.includes('application/json');
|
|
55
|
+
if (isJson) {
|
|
56
|
+
return {
|
|
57
|
+
key: recordKey,
|
|
58
|
+
value: record.value,
|
|
59
|
+
contentType: record.contentType,
|
|
60
|
+
dataType: 'json'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (isBinary && Buffer.isBuffer(record.value)) {
|
|
64
|
+
const fileExtension = (0, common_1.getFileExtension)(record.contentType);
|
|
65
|
+
const fileName = recordKey + fileExtension;
|
|
66
|
+
const fileReference = yield context.files.write({
|
|
67
|
+
fileName: fileName,
|
|
68
|
+
data: record.value
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
key: recordKey,
|
|
72
|
+
file: fileReference,
|
|
73
|
+
fileName: fileName,
|
|
74
|
+
contentType: record.contentType,
|
|
75
|
+
size: record.value.length,
|
|
76
|
+
dataType: 'file'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
key: recordKey,
|
|
81
|
+
value: record.value,
|
|
82
|
+
contentType: record.contentType,
|
|
83
|
+
dataType: 'text'
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new Error(`Failed to process key-value store record: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=get-key-value-store-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-key-value-store-record.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-key-value-store-record.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,6BAAkC;AAClC,sCAOmB;AAEN,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,aAAS;IACf,WAAW,EAAE,4BAA4B;IACzC,WAAW,EAAE,sEAAsE;IACnF,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,IAAI,EAAE,aAAS;YACf,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,oBAAoB;YACjC,WAAW,EAAE,gCAAgC;YAC7C,OAAO,EAAE,CAAO,KAAK,EAAE,EAAE;gBACvB,OAAO,IAAA,8BAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE,mBAAU,CAAC,CAAC;YAC1D,CAAC,CAAA;SACF,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,IAAI,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
2
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
3
|
+
}>, {
|
|
4
|
+
actorSource: import("@scopieflows/apps-framework").StaticDropdownProperty<string, true>;
|
|
5
|
+
actorid: import("@scopieflows/apps-framework").DropdownProperty<string, true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
6
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
7
|
+
}>>;
|
|
8
|
+
input: import("@scopieflows/apps-framework").DynamicProperties<true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
9
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
10
|
+
}>>;
|
|
11
|
+
build: import("@scopieflows/apps-framework").ShortTextProperty<false>;
|
|
12
|
+
memory: import("@scopieflows/apps-framework").StaticDropdownProperty<number, false>;
|
|
13
|
+
timeout: import("@scopieflows/apps-framework").NumberProperty<false>;
|
|
14
|
+
waitForFinish: import("@scopieflows/apps-framework").CheckboxProperty<false>;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=run-actor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-actor.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/run-actor.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;EAgCnB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runActor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/apps-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.runActor = (0, pieces_framework_1.createAction)({
|
|
9
|
+
name: 'runActor',
|
|
10
|
+
auth: __1.apifyAuth,
|
|
11
|
+
displayName: 'Run Actor',
|
|
12
|
+
description: 'Runs an Actor and returns all associated details.',
|
|
13
|
+
props: {
|
|
14
|
+
actorSource: (0, common_1.createActorSourceProperty)(),
|
|
15
|
+
actorid: (0, common_1.createActorIdProperty)(),
|
|
16
|
+
input: (0, common_1.createActorInputProperty)(),
|
|
17
|
+
build: (0, common_1.createBuildProperty)(),
|
|
18
|
+
memory: (0, common_1.createMemoryProperty)(common_1.RunType.ACTOR),
|
|
19
|
+
timeout: (0, common_1.createTimeoutProperty)(common_1.RunType.ACTOR),
|
|
20
|
+
waitForFinish: (0, common_1.createWaitForFinishProperty)(common_1.RunType.ACTOR)
|
|
21
|
+
},
|
|
22
|
+
run(context) {
|
|
23
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const apifyToken = context.auth.props.apikey;
|
|
25
|
+
const { input, actorid, timeout, build, memory, waitForFinish } = context.propsValue;
|
|
26
|
+
const body = input['body'];
|
|
27
|
+
const client = (0, common_1.createApifyClient)(apifyToken);
|
|
28
|
+
const runOptions = (0, common_1.createRunOptions)({ timeout, memory, build });
|
|
29
|
+
const resourceClient = client.actor(actorid);
|
|
30
|
+
return (0, common_1.handleRun)({
|
|
31
|
+
resourceClient,
|
|
32
|
+
body,
|
|
33
|
+
runOptions,
|
|
34
|
+
waitForFinish: waitForFinish || false,
|
|
35
|
+
client
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=run-actor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-actor.js","sourceRoot":"","sources":["../../../../src/lib/actions/run-actor.ts"],"names":[],"mappings":";;;;AAAA,oEAA6D;AAC7D,6BAAkC;AAClC,sCAYmB;AAEN,QAAA,QAAQ,GAAG,IAAA,+BAAY,EAAC;IACnC,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,aAAS;IACf,WAAW,EAAE,WAAW;IACxB,WAAW,EAAE,mDAAmD;IAChE,KAAK,EAAE;QACL,WAAW,EAAE,IAAA,kCAAyB,GAAE;QACxC,OAAO,EAAE,IAAA,8BAAqB,GAAE;QAChC,KAAK,EAAE,IAAA,iCAAwB,GAAE;QACjC,KAAK,EAAE,IAAA,4BAAmB,GAAE;QAC5B,MAAM,EAAE,IAAA,6BAAoB,EAAC,gBAAO,CAAC,KAAK,CAAC;QAC3C,OAAO,EAAE,IAAA,8BAAqB,EAAC,gBAAO,CAAC,KAAK,CAAC;QAC7C,aAAa,EAAE,IAAA,oCAA2B,EAAC,gBAAO,CAAC,KAAK,CAAC;KAC1D;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAC7C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACrF,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAE3B,MAAM,MAAM,GAAG,IAAA,0BAAiB,EAAC,UAAU,CAAC,CAAC;YAE7C,MAAM,UAAU,GAAG,IAAA,yBAAgB,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAChE,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAE7C,OAAO,IAAA,kBAAS,EAAC;gBACf,cAAc;gBACd,IAAI;gBACJ,UAAU;gBACV,aAAa,EAAE,aAAa,IAAI,KAAK;gBACrC,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const runTask: import("@scopieflows/apps-framework").IAction<import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
2
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
3
|
+
}>, {
|
|
4
|
+
taskid: import("@scopieflows/apps-framework").DropdownProperty<string, true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
5
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
6
|
+
}>>;
|
|
7
|
+
input: import("@scopieflows/apps-framework").DynamicProperties<true, import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
8
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
9
|
+
}>>;
|
|
10
|
+
build: import("@scopieflows/apps-framework").ShortTextProperty<false>;
|
|
11
|
+
memory: import("@scopieflows/apps-framework").StaticDropdownProperty<number, false>;
|
|
12
|
+
timeout: import("@scopieflows/apps-framework").NumberProperty<false>;
|
|
13
|
+
waitForFinish: import("@scopieflows/apps-framework").CheckboxProperty<false>;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=run-task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-task.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/run-task.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,OAAO;;;;;;;;;;;;;EA+BlB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runTask = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/apps-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.runTask = (0, pieces_framework_1.createAction)({
|
|
9
|
+
name: 'runTask',
|
|
10
|
+
auth: __1.apifyAuth,
|
|
11
|
+
displayName: 'Run Task',
|
|
12
|
+
description: 'Runs an Actor task and returns all associated details.',
|
|
13
|
+
props: {
|
|
14
|
+
taskid: (0, common_1.createTaskIdProperty)(),
|
|
15
|
+
input: (0, common_1.createTaskInputProperty)(),
|
|
16
|
+
build: (0, common_1.createBuildProperty)(),
|
|
17
|
+
memory: (0, common_1.createMemoryProperty)(common_1.RunType.TASK),
|
|
18
|
+
timeout: (0, common_1.createTimeoutProperty)(common_1.RunType.TASK),
|
|
19
|
+
waitForFinish: (0, common_1.createWaitForFinishProperty)(common_1.RunType.TASK)
|
|
20
|
+
},
|
|
21
|
+
run(context) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const apifyToken = context.auth.props.apikey;
|
|
24
|
+
const { input, taskid, timeout, build, memory, waitForFinish } = context.propsValue;
|
|
25
|
+
const body = input['body'];
|
|
26
|
+
const client = (0, common_1.createApifyClient)(apifyToken);
|
|
27
|
+
const runOptions = (0, common_1.createRunOptions)({ timeout, memory, build });
|
|
28
|
+
const resourceClient = client.task(taskid);
|
|
29
|
+
return (0, common_1.handleRun)({
|
|
30
|
+
resourceClient,
|
|
31
|
+
body,
|
|
32
|
+
runOptions,
|
|
33
|
+
waitForFinish: waitForFinish || false,
|
|
34
|
+
client
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=run-task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-task.js","sourceRoot":"","sources":["../../../../src/lib/actions/run-task.ts"],"names":[],"mappings":";;;;AAAA,oEAA6D;AAC7D,6BAAkC;AAClC,sCAWmB;AAEN,QAAA,OAAO,GAAG,IAAA,+BAAY,EAAC;IAClC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,aAAS;IACf,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,wDAAwD;IACrE,KAAK,EAAE;QACL,MAAM,EAAE,IAAA,6BAAoB,GAAE;QAC9B,KAAK,EAAE,IAAA,gCAAuB,GAAE;QAChC,KAAK,EAAE,IAAA,4BAAmB,GAAE;QAC5B,MAAM,EAAE,IAAA,6BAAoB,EAAC,gBAAO,CAAC,IAAI,CAAC;QAC1C,OAAO,EAAE,IAAA,8BAAqB,EAAC,gBAAO,CAAC,IAAI,CAAC;QAC5C,aAAa,EAAE,IAAA,oCAA2B,EAAC,gBAAO,CAAC,IAAI,CAAC;KACzD;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YAC7C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACpF,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAE3B,MAAM,MAAM,GAAG,IAAA,0BAAiB,EAAC,UAAU,CAAC,CAAC;YAE7C,MAAM,UAAU,GAAG,IAAA,yBAAgB,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAChE,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAE3C,OAAO,IAAA,kBAAS,EAAC;gBACf,cAAc;gBACd,IAAI;gBACJ,UAAU;gBACV,aAAa,EAAE,aAAa,IAAI,KAAK;gBACrC,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const scrapeSingleUrl: import("@scopieflows/apps-framework").IAction<import("@scopieflows/apps-framework").CustomAuthProperty<{
|
|
2
|
+
apikey: import("@scopieflows/apps-framework").SecretTextProperty<true>;
|
|
3
|
+
}>, {
|
|
4
|
+
url: import("@scopieflows/apps-framework").ShortTextProperty<true>;
|
|
5
|
+
crawlerType: import("@scopieflows/apps-framework").StaticDropdownProperty<string, true>;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=scrape-single-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape-single-url.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/scrape-single-url.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe;;;;;EAkG1B,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scrapeSingleUrl = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@scopieflows/apps-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const WEBSITE_CONTENT_CRAWLER_ACTOR_ID = 'apify/website-content-crawler';
|
|
9
|
+
exports.scrapeSingleUrl = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'scrapeSingleUrl',
|
|
11
|
+
auth: __1.apifyAuth,
|
|
12
|
+
displayName: 'Scrape Single URL',
|
|
13
|
+
description: 'Scrape a single URL using the Apify Website Content Crawler Actor and get its content as markdown and HTML.',
|
|
14
|
+
props: {
|
|
15
|
+
url: pieces_framework_1.Property.ShortText({
|
|
16
|
+
displayName: 'URL',
|
|
17
|
+
description: 'URL to be scraped. Must start with http:// or https:// and be a valid URL.',
|
|
18
|
+
defaultValue: 'https://docs.apify.com/academy/web-scraping-for-beginners',
|
|
19
|
+
required: true
|
|
20
|
+
}),
|
|
21
|
+
crawlerType: pieces_framework_1.Property.StaticDropdown({
|
|
22
|
+
required: true,
|
|
23
|
+
displayName: 'Crawler Type',
|
|
24
|
+
description: 'The type of crawler to use.',
|
|
25
|
+
defaultValue: 'cheerio',
|
|
26
|
+
options: {
|
|
27
|
+
options: [
|
|
28
|
+
{
|
|
29
|
+
label: 'Cheerio',
|
|
30
|
+
value: 'cheerio',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: 'JSDOM',
|
|
34
|
+
value: 'jsdom',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Playwright Adaptive',
|
|
38
|
+
value: 'playwright:adaptive',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'Playwright Firefox',
|
|
42
|
+
value: 'playwright:firefox',
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
run(context) {
|
|
49
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
const apifyToken = context.auth.props.apikey;
|
|
52
|
+
const { crawlerType, url } = context.propsValue;
|
|
53
|
+
const client = (0, common_1.createApifyClient)(apifyToken);
|
|
54
|
+
try {
|
|
55
|
+
new URL(url);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw new Error('Invalid URL format. Please provide a valid URL with http:// or https://');
|
|
59
|
+
}
|
|
60
|
+
const input = {
|
|
61
|
+
startUrls: [{ url }],
|
|
62
|
+
crawlerType,
|
|
63
|
+
maxCrawlDepth: 0,
|
|
64
|
+
maxCrawlPages: 1,
|
|
65
|
+
maxResults: 1,
|
|
66
|
+
proxyConfiguration: {
|
|
67
|
+
useApifyProxy: true,
|
|
68
|
+
},
|
|
69
|
+
removeCookieWarnings: true,
|
|
70
|
+
saveHtml: true,
|
|
71
|
+
saveMarkdown: true,
|
|
72
|
+
};
|
|
73
|
+
let run;
|
|
74
|
+
try {
|
|
75
|
+
run = yield client.actor(WEBSITE_CONTENT_CRAWLER_ACTOR_ID).call(input);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new Error('Failed to scrape URL: ' + error.message);
|
|
79
|
+
}
|
|
80
|
+
if (run.status !== 'SUCCEEDED') {
|
|
81
|
+
throw new Error(`Website Content Crawler run finished with status "${run.status}". Run ID: ${run.id}`);
|
|
82
|
+
}
|
|
83
|
+
if (!run.defaultDatasetId) {
|
|
84
|
+
return run;
|
|
85
|
+
}
|
|
86
|
+
let result;
|
|
87
|
+
try {
|
|
88
|
+
result = yield client.dataset(run.defaultDatasetId).listItems();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
throw new Error('Failed to fetch scrape results: ' + error.message);
|
|
92
|
+
}
|
|
93
|
+
if (!result.items || result.items.length === 0) {
|
|
94
|
+
throw new Error('Scraping returned no results. The page may have been blocked or returned no content.');
|
|
95
|
+
}
|
|
96
|
+
const firstResultItem = result.items[0];
|
|
97
|
+
return {
|
|
98
|
+
url: (_a = firstResultItem['url']) !== null && _a !== void 0 ? _a : url,
|
|
99
|
+
markdown: (_b = firstResultItem['markdown']) !== null && _b !== void 0 ? _b : '',
|
|
100
|
+
html: (_c = firstResultItem['html']) !== null && _c !== void 0 ? _c : '',
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=scrape-single-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape-single-url.js","sourceRoot":"","sources":["../../../../src/lib/actions/scrape-single-url.ts"],"names":[],"mappings":";;;;AAAA,oEAAuE;AACvE,6BAAkC;AAClC,sCAA8C;AAE9C,MAAM,gCAAgC,GAAG,+BAA+B,CAAC;AAE5D,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,aAAS;IACf,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,6GAA6G;IAC1H,KAAK,EAAE;QACL,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACtB,WAAW,EAAE,KAAK;YAClB,WAAW,EAAE,4EAA4E;YACzF,YAAY,EAAE,2DAA2D;YACzE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACnC,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,6BAA6B;YAC1C,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,SAAS;wBAChB,KAAK,EAAE,SAAS;qBACjB;oB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