1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "rawData": "[{\"name\": \"John Doe\", \"email\": \"john@example.com\", \"phone\": \"5551234567\"}, {\"name\": \"Jane Smith\", \"email\": \"jane@test.org\", \"phone\": \"+1-555-987-6543\"}]",
12 "targetExample": {
13 "full_name": "Jane Doe",
14 "email": "jane@example.com",
15 "phone": "+1 (555) 123-4567",
16 "company": "Acme Corp",
17 "signup_date": "2026-01-15",
18 "is_active": true
19 },
20 "targetSchema": {
21 "fields": {
22 "email": {
23 "type": "string",
24 "format": "email",
25 "required": true,
26 "description": "Contact email"
27 },
28 "full_name": {
29 "type": "string",
30 "required": true,
31 "description": "Full name"
32 },
33 "phone": {
34 "type": "string",
35 "description": "Phone number"
36 },
37 "signup_date": {
38 "type": "date",
39 "description": "When they signed up"
40 },
41 "is_vip": {
42 "type": "boolean",
43 "description": "VIP customer flag"
44 }
45 }
46 },
47 "fieldMappings": {
48 "email_address": "email",
49 "full_name": "firstname",
50 "company_name": "company",
51 "phone_number": "phone",
52 "city": "city"
53 },
54 "validationRules": {
55 "email": {
56 "pattern": "^[^@]+@[^@]+\\.[^@]+$"
57 },
58 "country": {
59 "enum": [
60 "US",
61 "GB",
62 "DE",
63 "FR",
64 "CA"
65 ]
66 },
67 "age": {
68 "min": 0,
69 "max": 150
70 }
71 },
72 "transformationRules": [
73 {
74 "sourceField": "full_name",
75 "targetField": "firstname",
76 "transform": "split_name",
77 "params": {
78 "output": "first"
79 }
80 },
81 {
82 "sourceField": "full_name",
83 "targetField": "lastname",
84 "transform": "split_name",
85 "params": {
86 "output": "last"
87 }
88 },
89 {
90 "sourceField": "signup_date",
91 "targetField": "created_at",
92 "transform": "date_normalize",
93 "params": {
94 "target_format": "%Y-%m-%d"
95 }
96 }
97 ]
98};
99
100
101const run = await client.actor("filip_cicvarek/data-bridge").call(input);
102
103
104console.log('Results from dataset');
105console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
106const { items } = await client.dataset(run.defaultDatasetId).listItems();
107items.forEach((item) => {
108 console.dir(item);
109});
110
111