1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "requirements": [
12 {
13 "name": "result.json",
14 "kind": "json",
15 "maxBytes": 10000,
16 "jsonSchema": {
17 "type": "object",
18 "required": [
19 "ok",
20 "count"
21 ],
22 "properties": {
23 "ok": {
24 "type": "boolean"
25 },
26 "count": {
27 "type": "integer",
28 "minimum": 0
29 }
30 },
31 "additionalProperties": false
32 }
33 },
34 {
35 "name": "records.csv",
36 "kind": "csv",
37 "maxBytes": 10000,
38 "csv": {
39 "headers": [
40 "id",
41 "name"
42 ],
43 "minRows": 2,
44 "maxRows": 2
45 }
46 },
47 {
48 "name": "test-report.md",
49 "kind": "text",
50 "maxBytes": 10000
51 }
52 ],
53 "files": [
54 {
55 "name": "result.json",
56 "content": "{\"ok\":true,\"count\":2}"
57 },
58 {
59 "name": "records.csv",
60 "content": "id,name\n1,Alice\n2,Bob\n"
61 },
62 {
63 "name": "test-report.md",
64 "content": "# Test record\nTwo synthetic records checked.\n"
65 }
66 ]
67};
68
69
70const run = await client.actor("grayt/delivery-check").call(input);
71
72
73console.log('Results from dataset');
74console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
75const { items } = await client.dataset(run.defaultDatasetId).listItems();
76items.forEach((item) => {
77 console.dir(item);
78});
79
80