@prismatic-io/components-customer-io 0.0.0-stage → 0.0.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.
Binary file
@@ -0,0 +1,265 @@
1
+ let _prismatic_io_spectral = require("@prismatic-io/spectral");
2
+ let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
3
+ let customerio_node = require("customerio-node");
4
+ //#region src/inputs/common.ts
5
+ const id = (0, _prismatic_io_spectral.input)({
6
+ label: "ID",
7
+ type: "string",
8
+ required: true,
9
+ example: "exampleCustomerId",
10
+ placeholder: "Enter customer ID",
11
+ comments: "The unique identifier that targets a specific customer record.",
12
+ clean: _prismatic_io_spectral.util.types.toString
13
+ });
14
+ const region = (0, _prismatic_io_spectral.input)({
15
+ label: "Region",
16
+ placeholder: "Enter region",
17
+ type: "string",
18
+ model: [{
19
+ label: "US",
20
+ value: "US"
21
+ }, {
22
+ label: "EU",
23
+ value: "EU"
24
+ }],
25
+ required: true,
26
+ example: "US",
27
+ comments: "The region in which the account is configured.",
28
+ clean: _prismatic_io_spectral.util.types.toString
29
+ });
30
+ const connectionInput = (0, _prismatic_io_spectral.input)({
31
+ label: "Connection",
32
+ type: "connection",
33
+ required: true,
34
+ comments: "The Customer.io connection to use."
35
+ });
36
+ //#endregion
37
+ //#region src/utils/clean.ts
38
+ const cleanKeyValueList = (value) => _prismatic_io_spectral.util.types.keyValPairListToObject(value);
39
+ const cleanOptionalKeyValueList = (value) => {
40
+ if (!value || Array.isArray(value) && value.length === 0) return;
41
+ const result = cleanKeyValueList(value);
42
+ return Object.keys(result).length > 0 ? result : void 0;
43
+ };
44
+ //#endregion
45
+ //#region src/inputs/customers.ts
46
+ const customerData = (0, _prismatic_io_spectral.input)({
47
+ label: "Customer Data",
48
+ type: "string",
49
+ collection: "keyvaluelist",
50
+ required: true,
51
+ comments: "The key and value pairs that make up a customer record. The key must be a string, and the value can be a string, number, array, or object.",
52
+ clean: cleanKeyValueList
53
+ });
54
+ const eventData = (0, _prismatic_io_spectral.input)({
55
+ label: "Event Data",
56
+ type: "string",
57
+ collection: "keyvaluelist",
58
+ required: false,
59
+ comments: "The key and value pairs that describe the event the customer performed.",
60
+ clean: cleanOptionalKeyValueList
61
+ });
62
+ const eventName = (0, _prismatic_io_spectral.input)({
63
+ label: "Event Name",
64
+ example: "myCustomerEvent",
65
+ placeholder: "Enter event name",
66
+ type: "string",
67
+ required: true,
68
+ comments: "The identifier recorded for the tracked event.",
69
+ clean: _prismatic_io_spectral.util.types.toString
70
+ });
71
+ const url = (0, _prismatic_io_spectral.input)({
72
+ label: "URL",
73
+ type: "string",
74
+ required: true,
75
+ example: "www.example.com",
76
+ placeholder: "Enter page path",
77
+ comments: "The page path to track. Enter the full path to track a specific page, or use the asterisk '*' to track any page.",
78
+ clean: _prismatic_io_spectral.util.types.toString
79
+ });
80
+ const destroyInputs = {
81
+ id,
82
+ region,
83
+ cioConnection: connectionInput
84
+ };
85
+ const identifyInputs = {
86
+ id,
87
+ region,
88
+ customerData,
89
+ cioConnection: connectionInput
90
+ };
91
+ const trackInputs = {
92
+ id,
93
+ region,
94
+ eventData,
95
+ eventName,
96
+ cioConnection: connectionInput
97
+ };
98
+ const trackPageViewInputs = {
99
+ id,
100
+ region,
101
+ url,
102
+ cioConnection: connectionInput
103
+ };
104
+ //#endregion
105
+ //#region src/inputs/misc.ts
106
+ const rawRequestInputs = {
107
+ connection: connectionInput,
108
+ region,
109
+ ..._prismatic_io_spectral_http.inputs,
110
+ url: {
111
+ ..._prismatic_io_spectral_http.inputs.url,
112
+ comments: "The path to append to the base URL. Enter the path only (for example, /v1/accounts/region); the base URL (https://track.customer.io/api) is already included.",
113
+ example: "/v1/accounts/region"
114
+ }
115
+ };
116
+ //#endregion
117
+ //#region src/client.ts
118
+ const getRegion = (region) => {
119
+ if (region === "US") return customerio_node.RegionUS;
120
+ if (region === "EU") return customerio_node.RegionEU;
121
+ throw new Error(`Unsupported region: ${region}`);
122
+ };
123
+ const createCustomerClient = (cioConnection, region) => {
124
+ if (cioConnection.key !== "apiKey") throw new _prismatic_io_spectral.ConnectionError(cioConnection, `Unsupported authorization method: ${cioConnection.key}`);
125
+ return new customerio_node.TrackClient(_prismatic_io_spectral.util.types.toString(cioConnection.fields.siteId), _prismatic_io_spectral.util.types.toString(cioConnection.fields.apiKey), { region: getRegion(region) });
126
+ };
127
+ //#endregion
128
+ //#region src/examplePayloads.ts
129
+ const destroyExamplePayload = { data: null };
130
+ const identifyExamplePayload = { data: null };
131
+ const trackExamplePayload = { data: null };
132
+ const trackPageViewExamplePayload = { data: null };
133
+ //#endregion
134
+ //#region src/actions/customers/destroy.ts
135
+ const destroy = (0, _prismatic_io_spectral.action)({
136
+ display: {
137
+ label: "Destroy",
138
+ description: "Delete a customer by unique ID."
139
+ },
140
+ perform: async (context, { id, region, cioConnection }) => {
141
+ return { data: await createCustomerClient(cioConnection, region).destroy(id) };
142
+ },
143
+ inputs: destroyInputs,
144
+ examplePayload: destroyExamplePayload
145
+ });
146
+ //#endregion
147
+ //#region src/actions/customers/identify.ts
148
+ const identify = (0, _prismatic_io_spectral.action)({
149
+ display: {
150
+ label: "Identify",
151
+ description: "Create or update a customer."
152
+ },
153
+ perform: async (context, { id, region, customerData, cioConnection }) => {
154
+ return { data: await createCustomerClient(cioConnection, region).identify(id, customerData) };
155
+ },
156
+ inputs: identifyInputs,
157
+ examplePayload: identifyExamplePayload
158
+ });
159
+ //#endregion
160
+ //#region src/actions/customers/track.ts
161
+ const track = (0, _prismatic_io_spectral.action)({
162
+ display: {
163
+ label: "Track",
164
+ description: "Track customer events."
165
+ },
166
+ perform: async (context, { id, region, eventData, eventName, cioConnection }) => {
167
+ const client = createCustomerClient(cioConnection, region);
168
+ const payload = eventData ? {
169
+ name: eventName,
170
+ data: eventData
171
+ } : { name: eventName };
172
+ return { data: await client.track(id, payload) };
173
+ },
174
+ inputs: trackInputs,
175
+ examplePayload: trackExamplePayload
176
+ });
177
+ //#endregion
178
+ //#region src/actions/customers/trackPageView.ts
179
+ const trackPageView = (0, _prismatic_io_spectral.action)({
180
+ display: {
181
+ label: "Track Page View",
182
+ description: "Track a customer page view."
183
+ },
184
+ perform: async (context, { id, region, url, cioConnection }) => {
185
+ return { data: await createCustomerClient(cioConnection, region).trackPageView(id, url) };
186
+ },
187
+ inputs: trackPageViewInputs,
188
+ examplePayload: trackPageViewExamplePayload
189
+ });
190
+ //#endregion
191
+ //#region src/actions/misc/rawRequest.ts
192
+ const rawRequest = (0, _prismatic_io_spectral.action)({
193
+ display: {
194
+ label: "Raw Request",
195
+ description: "Send raw HTTP request to Customer.io."
196
+ },
197
+ inputs: rawRequestInputs,
198
+ perform: async (context, { connection, region, ...httpClientInputs }) => {
199
+ const client = createCustomerClient(connection, region);
200
+ const siteid = client.siteid;
201
+ const apikey = client.apikey;
202
+ try {
203
+ const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)("https://track.customer.io/api", httpClientInputs, { Authorization: `Basic ${Buffer.from(`${siteid}:${apikey}`).toString("base64")}` });
204
+ return { data };
205
+ } catch (error) {
206
+ const handled = (0, _prismatic_io_spectral_http.handleErrors)(error);
207
+ const serialized = _prismatic_io_spectral.util.types?.toJSON(handled);
208
+ throw new Error(serialized);
209
+ }
210
+ }
211
+ });
212
+ var connections_default = [(0, _prismatic_io_spectral.connection)({
213
+ key: "apiKey",
214
+ display: {
215
+ label: "API Key",
216
+ description: "Authenticate requests to Customer.io using an API key and secret."
217
+ },
218
+ inputs: {
219
+ apiKey: {
220
+ label: "API Key",
221
+ placeholder: "API Key",
222
+ type: "password",
223
+ required: true,
224
+ shown: true,
225
+ comments: "Provide the API key from the developer console.",
226
+ example: "example-a131bf1767a7"
227
+ },
228
+ siteId: {
229
+ label: "Site Id",
230
+ placeholder: "Site Id",
231
+ type: "string",
232
+ required: true,
233
+ shown: true,
234
+ comments: "Provide the Site Id obtained from the developer console.",
235
+ example: "example-a131bf1767a7"
236
+ }
237
+ }
238
+ })];
239
+ //#endregion
240
+ //#region src/index.ts
241
+ var src_default = (0, _prismatic_io_spectral.component)({
242
+ key: "customer-io",
243
+ documentationUrl: "https://prismatic.io/docs/components/customer-io/",
244
+ public: true,
245
+ display: {
246
+ label: "Customer.io",
247
+ category: "Application Connectors",
248
+ description: "Manage customers on the Customer.io platform.",
249
+ iconPath: "icon.png"
250
+ },
251
+ actions: {
252
+ destroy,
253
+ identify,
254
+ track,
255
+ trackPageView,
256
+ rawRequest
257
+ },
258
+ connections: connections_default,
259
+ hooks: { error: _prismatic_io_spectral_http.handleErrors }
260
+ });
261
+ //#endregion
262
+ //#region npm-dist/.entry.ts
263
+ var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
264
+ //#endregion
265
+ module.exports = _entry_default;
@@ -0,0 +1,369 @@
1
+ //#region node_modules/axios/index.d.ts
2
+ type UppercaseMethod = 'GET' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH' | 'PURGE' | 'LINK' | 'UNLINK' | 'QUERY';
3
+ type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
4
+ type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
5
+ //#endregion
6
+ //#region npm-dist/.entry.d.ts
7
+ declare const _default: import("@prismatic-io/spectral").CallableComponent<{
8
+ key: "customer-io";
9
+ documentationUrl: "https://prismatic.io/docs/components/customer-io/";
10
+ public: true;
11
+ display: {
12
+ label: string;
13
+ category: "Application Connectors";
14
+ description: string;
15
+ iconPath: string;
16
+ };
17
+ actions: {
18
+ destroy: import("@prismatic-io/spectral").ActionDefinition<{
19
+ id: {
20
+ label: string;
21
+ type: "string";
22
+ required: true;
23
+ example: string;
24
+ placeholder: string;
25
+ comments: string;
26
+ clean: (value: unknown, defaultValue?: string) => string;
27
+ };
28
+ region: {
29
+ label: string;
30
+ placeholder: string;
31
+ type: "string";
32
+ model: {
33
+ label: string;
34
+ value: string;
35
+ }[];
36
+ required: true;
37
+ example: string;
38
+ comments: string;
39
+ clean: (value: unknown, defaultValue?: string) => string;
40
+ };
41
+ cioConnection: {
42
+ label: string;
43
+ type: "connection";
44
+ required: true;
45
+ comments: string;
46
+ };
47
+ }, import("@prismatic-io/spectral").ConfigVarResultCollection, boolean, {
48
+ data: any;
49
+ }>;
50
+ identify: import("@prismatic-io/spectral").ActionDefinition<{
51
+ id: {
52
+ label: string;
53
+ type: "string";
54
+ required: true;
55
+ example: string;
56
+ placeholder: string;
57
+ comments: string;
58
+ clean: (value: unknown, defaultValue?: string) => string;
59
+ };
60
+ region: {
61
+ label: string;
62
+ placeholder: string;
63
+ type: "string";
64
+ model: {
65
+ label: string;
66
+ value: string;
67
+ }[];
68
+ required: true;
69
+ example: string;
70
+ comments: string;
71
+ clean: (value: unknown, defaultValue?: string) => string;
72
+ };
73
+ customerData: {
74
+ label: string;
75
+ type: "string";
76
+ collection: "keyvaluelist";
77
+ required: true;
78
+ comments: string;
79
+ clean: (value: unknown) => Record<string, unknown>;
80
+ };
81
+ cioConnection: {
82
+ label: string;
83
+ type: "connection";
84
+ required: true;
85
+ comments: string;
86
+ };
87
+ }, import("@prismatic-io/spectral").ConfigVarResultCollection, boolean, {
88
+ data: any;
89
+ }>;
90
+ track: import("@prismatic-io/spectral").ActionDefinition<{
91
+ id: {
92
+ label: string;
93
+ type: "string";
94
+ required: true;
95
+ example: string;
96
+ placeholder: string;
97
+ comments: string;
98
+ clean: (value: unknown, defaultValue?: string) => string;
99
+ };
100
+ region: {
101
+ label: string;
102
+ placeholder: string;
103
+ type: "string";
104
+ model: {
105
+ label: string;
106
+ value: string;
107
+ }[];
108
+ required: true;
109
+ example: string;
110
+ comments: string;
111
+ clean: (value: unknown, defaultValue?: string) => string;
112
+ };
113
+ eventData: {
114
+ label: string;
115
+ type: "string";
116
+ collection: "keyvaluelist";
117
+ required: false;
118
+ comments: string;
119
+ clean: (value: unknown) => Record<string, unknown> | undefined;
120
+ };
121
+ eventName: {
122
+ label: string;
123
+ example: string;
124
+ placeholder: string;
125
+ type: "string";
126
+ required: true;
127
+ comments: string;
128
+ clean: (value: unknown, defaultValue?: string) => string;
129
+ };
130
+ cioConnection: {
131
+ label: string;
132
+ type: "connection";
133
+ required: true;
134
+ comments: string;
135
+ };
136
+ }, import("@prismatic-io/spectral").ConfigVarResultCollection, boolean, {
137
+ data: any;
138
+ }>;
139
+ trackPageView: import("@prismatic-io/spectral").ActionDefinition<{
140
+ id: {
141
+ label: string;
142
+ type: "string";
143
+ required: true;
144
+ example: string;
145
+ placeholder: string;
146
+ comments: string;
147
+ clean: (value: unknown, defaultValue?: string) => string;
148
+ };
149
+ region: {
150
+ label: string;
151
+ placeholder: string;
152
+ type: "string";
153
+ model: {
154
+ label: string;
155
+ value: string;
156
+ }[];
157
+ required: true;
158
+ example: string;
159
+ comments: string;
160
+ clean: (value: unknown, defaultValue?: string) => string;
161
+ };
162
+ url: {
163
+ label: string;
164
+ type: "string";
165
+ required: true;
166
+ example: string;
167
+ placeholder: string;
168
+ comments: string;
169
+ clean: (value: unknown, defaultValue?: string) => string;
170
+ };
171
+ cioConnection: {
172
+ label: string;
173
+ type: "connection";
174
+ required: true;
175
+ comments: string;
176
+ };
177
+ }, import("@prismatic-io/spectral").ConfigVarResultCollection, boolean, {
178
+ data: any;
179
+ }>;
180
+ rawRequest: import("@prismatic-io/spectral").ActionDefinition<{
181
+ url: {
182
+ comments: string;
183
+ example: string;
184
+ label: string;
185
+ placeholder: string;
186
+ type: "string";
187
+ required: true;
188
+ clean: (value: unknown) => string;
189
+ };
190
+ method: {
191
+ label: string;
192
+ type: "string";
193
+ required: true;
194
+ model: {
195
+ label: Method;
196
+ value: Method;
197
+ }[];
198
+ comments: string;
199
+ clean: (value: unknown) => string;
200
+ };
201
+ data: {
202
+ label: string;
203
+ placeholder: string;
204
+ type: "string";
205
+ required: false;
206
+ comments: string;
207
+ example: string;
208
+ };
209
+ formData: {
210
+ label: string;
211
+ placeholder: string;
212
+ type: "string";
213
+ collection: "keyvaluelist";
214
+ required: false;
215
+ comments: string;
216
+ example: string;
217
+ };
218
+ fileData: {
219
+ label: string;
220
+ placeholder: string;
221
+ type: "string";
222
+ collection: "keyvaluelist";
223
+ required: false;
224
+ comments: string;
225
+ example: string;
226
+ };
227
+ fileDataFileNames: {
228
+ label: string;
229
+ placeholder: string;
230
+ type: "string";
231
+ collection: "keyvaluelist";
232
+ required: false;
233
+ comments: string;
234
+ clean: (values: any) => Record<string, string> | undefined;
235
+ };
236
+ queryParams: {
237
+ label: string;
238
+ placeholder: string;
239
+ type: "string";
240
+ collection: "keyvaluelist";
241
+ required: false;
242
+ comments: string;
243
+ };
244
+ headers: {
245
+ label: string;
246
+ placeholder: string;
247
+ type: "string";
248
+ collection: "keyvaluelist";
249
+ required: false;
250
+ comments: string;
251
+ example: string;
252
+ };
253
+ responseType: {
254
+ label: string;
255
+ placeholder: string;
256
+ type: "string";
257
+ default: string;
258
+ required: true;
259
+ comments: string;
260
+ model: {
261
+ label: ResponseType;
262
+ value: ResponseType;
263
+ }[];
264
+ clean: (value: unknown) => ResponseType;
265
+ };
266
+ timeout: {
267
+ label: string;
268
+ type: "string";
269
+ required: false;
270
+ comments: string;
271
+ example: string;
272
+ clean: (value: unknown) => number;
273
+ };
274
+ debugRequest: {
275
+ label: string;
276
+ type: "boolean";
277
+ required: false;
278
+ comments: string;
279
+ clean: (value: unknown) => boolean;
280
+ };
281
+ retryDelayMS: {
282
+ label: string;
283
+ placeholder: string;
284
+ type: "string";
285
+ required: false;
286
+ comments: string;
287
+ default: string;
288
+ clean: (value: unknown) => number;
289
+ };
290
+ retryAllErrors: {
291
+ label: string;
292
+ type: "boolean";
293
+ default: string;
294
+ required: false;
295
+ comments: string;
296
+ clean: (value: unknown) => boolean;
297
+ };
298
+ maxRetries: {
299
+ label: string;
300
+ placeholder: string;
301
+ type: "string";
302
+ required: false;
303
+ comments: string;
304
+ default: string;
305
+ clean: (value: unknown) => number;
306
+ };
307
+ useExponentialBackoff: {
308
+ label: string;
309
+ type: "boolean";
310
+ default: string;
311
+ required: false;
312
+ comments: string;
313
+ clean: (value: unknown) => boolean;
314
+ };
315
+ connection: {
316
+ label: string;
317
+ type: "connection";
318
+ required: true;
319
+ comments: string;
320
+ };
321
+ region: {
322
+ label: string;
323
+ placeholder: string;
324
+ type: "string";
325
+ model: {
326
+ label: string;
327
+ value: string;
328
+ }[];
329
+ required: true;
330
+ example: string;
331
+ comments: string;
332
+ clean: (value: unknown, defaultValue?: string) => string;
333
+ };
334
+ }, import("@prismatic-io/spectral").ConfigVarResultCollection, boolean, {
335
+ data: any;
336
+ }>;
337
+ };
338
+ connections: import("@prismatic-io/spectral").KeyedConnection<{
339
+ key: "apiKey";
340
+ display: {
341
+ label: string;
342
+ description: string;
343
+ };
344
+ inputs: {
345
+ apiKey: {
346
+ label: string;
347
+ placeholder: string;
348
+ type: "password";
349
+ required: true;
350
+ shown: true;
351
+ comments: string;
352
+ example: string;
353
+ };
354
+ siteId: {
355
+ label: string;
356
+ placeholder: string;
357
+ type: "string";
358
+ required: true;
359
+ shown: true;
360
+ comments: string;
361
+ example: string;
362
+ };
363
+ };
364
+ }, "apiKey">[];
365
+ hooks: {
366
+ error: (error: unknown) => unknown;
367
+ };
368
+ }>;
369
+ export = _default;
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@prismatic-io/components-customer-io",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "main": "./npm-dist/index.cjs",
5
+ "types": "./npm-dist/index.d.cts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./npm-dist/index.d.cts",
9
+ "default": "./npm-dist/index.cjs"
10
+ }
11
+ },
12
+ "description": "Manage customers on the Customer.io platform.",
13
+ "license": "Apache-2.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/prismatic-io/components.git",
17
+ "directory": "components/customer-io"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "files": [
23
+ "npm-dist",
24
+ "dist"
25
+ ],
26
+ "prismatic": {
27
+ "component": "./dist/index.js"
28
+ },
29
+ "scripts": {
30
+ "lint": "biome lint --write .",
31
+ "format": "biome format --write .",
32
+ "build": "npm run format && npm run lint && tsdown",
33
+ "typecheck": "tsc --noEmit",
34
+ "test": "vitest run",
35
+ "prepare": "npm run build",
36
+ "publish:platform": "npm run build && prism components:publish"
37
+ },
38
+ "peerDependencies": {
39
+ "@prismatic-io/spectral": "^10.38.5"
40
+ },
41
+ "dependencies": {
42
+ "customerio-node": "5.0.1"
43
+ },
44
+ "devDependencies": {
45
+ "@biomejs/biome": "2.5.1",
46
+ "@types/node": "^26.6.4",
47
+ "tsdown": "0.22.3",
48
+ "typescript": "6.0.3",
49
+ "vitest": "4.1.9",
50
+ "@prismatic-io/spectral": "^10.38.5"
51
+ }
52
+ }