@walkeros/server-destination-klaviyo 3.4.0-next-1776749829492
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/README.md +73 -0
- package/dist/dev.d.mts +164 -0
- package/dist/dev.d.ts +164 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +128 -0
- package/dist/examples/index.d.ts +128 -0
- package/dist/examples/index.js +369 -0
- package/dist/examples/index.mjs +347 -0
- package/dist/index.d.mts +97 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/walkerOS.json +790 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @walkeros/server-destination-klaviyo
|
|
2
|
+
|
|
3
|
+
Server-side Klaviyo destination for
|
|
4
|
+
[walkerOS](https://github.com/elbwalker/walkerOS). Forwards events to Klaviyo
|
|
5
|
+
via the official `klaviyo-api` SDK with event tracking and profile management.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @walkeros/server-destination-klaviyo
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"destinations": {
|
|
18
|
+
"klaviyo": {
|
|
19
|
+
"package": "@walkeros/server-destination-klaviyo",
|
|
20
|
+
"config": {
|
|
21
|
+
"settings": {
|
|
22
|
+
"apiKey": "$KLAVIYO_API_KEY",
|
|
23
|
+
"email": "user.email",
|
|
24
|
+
"externalId": "user.id"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Settings
|
|
33
|
+
|
|
34
|
+
| Setting | Type | Required | Default | Description |
|
|
35
|
+
| ------------- | ------------ | -------- | -------------- | -------------------------------------------------------- |
|
|
36
|
+
| `apiKey` | string | Yes | -- | Klaviyo private API key (starts with `pk_`) |
|
|
37
|
+
| `email` | string | No | `'user.email'` | Mapping path to resolve email from events |
|
|
38
|
+
| `externalId` | string | No | `'user.id'` | Mapping path to resolve external ID from events |
|
|
39
|
+
| `phoneNumber` | string | No | -- | Mapping path to resolve phone number (E.164) from events |
|
|
40
|
+
| `identify` | MappingValue | No | -- | Destination-level profile upsert mapping |
|
|
41
|
+
| `currency` | string | No | -- | Default ISO 4217 currency code for revenue events |
|
|
42
|
+
|
|
43
|
+
## Mapping Settings
|
|
44
|
+
|
|
45
|
+
Per-event mapping settings control additional behavior:
|
|
46
|
+
|
|
47
|
+
| Setting | Effect | Use with `skip: true` |
|
|
48
|
+
| ---------- | ------------------------------------------ | ---------------------------- |
|
|
49
|
+
| `identify` | Calls `createOrUpdateProfile()` | Yes, for login/signup events |
|
|
50
|
+
| `value` | Sets revenue value + currency on the event | No |
|
|
51
|
+
|
|
52
|
+
## Identity
|
|
53
|
+
|
|
54
|
+
Klaviyo requires at least one profile identifier per event: `email`,
|
|
55
|
+
`phoneNumber`, or `externalId`. The destination resolves these from each
|
|
56
|
+
walkerOS event using the configured mapping paths. Events without any identifier
|
|
57
|
+
are skipped with a warning.
|
|
58
|
+
|
|
59
|
+
## Revenue Tracking
|
|
60
|
+
|
|
61
|
+
Map `settings.value` to a numeric event property. The destination sets the
|
|
62
|
+
Klaviyo `value` property and `valueCurrency` (from `settings.currency`).
|
|
63
|
+
|
|
64
|
+
## Ecommerce
|
|
65
|
+
|
|
66
|
+
Use `mapping.name` to map walkerOS event names to Klaviyo's expected metric
|
|
67
|
+
names:
|
|
68
|
+
|
|
69
|
+
| walkerOS Event | Klaviyo Metric | Unlocks |
|
|
70
|
+
| ---------------- | ---------------- | ---------------------- |
|
|
71
|
+
| `product view` | `Viewed Product` | Product analytics |
|
|
72
|
+
| `product add` | `Added to Cart` | Cart abandonment flows |
|
|
73
|
+
| `order complete` | `Placed Order` | Revenue reporting, CLV |
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
4
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
5
|
+
|
|
6
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
7
|
+
apiKey: z.ZodString;
|
|
8
|
+
email: z.ZodOptional<z.ZodString>;
|
|
9
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
10
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
12
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
15
|
+
|
|
16
|
+
declare const MappingSchema: z.ZodObject<{
|
|
17
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type Mapping = z.infer<typeof MappingSchema>;
|
|
21
|
+
|
|
22
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
23
|
+
declare const mapping: _walkeros_core_dev.JSONSchema;
|
|
24
|
+
|
|
25
|
+
type index$1_Mapping = Mapping;
|
|
26
|
+
declare const index$1_MappingSchema: typeof MappingSchema;
|
|
27
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
28
|
+
declare const index$1_mapping: typeof mapping;
|
|
29
|
+
declare const index$1_settings: typeof settings;
|
|
30
|
+
declare namespace index$1 {
|
|
31
|
+
export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Settings {
|
|
35
|
+
/** Klaviyo private API key (required). Starts with 'pk_'. */
|
|
36
|
+
apiKey: string;
|
|
37
|
+
/** walkerOS mapping value path to resolve email from each event. */
|
|
38
|
+
email?: string;
|
|
39
|
+
/** walkerOS mapping value path to resolve phone number (E.164) from each event. */
|
|
40
|
+
phoneNumber?: string;
|
|
41
|
+
/** walkerOS mapping value path to resolve external ID from each event. */
|
|
42
|
+
externalId?: string;
|
|
43
|
+
/** Destination-level identify mapping. Resolves to profile attributes for upsert. */
|
|
44
|
+
identify?: Mapping$1.Value;
|
|
45
|
+
/** Default currency for revenue events (ISO 4217, e.g. 'USD', 'EUR'). */
|
|
46
|
+
currency?: string;
|
|
47
|
+
/** Runtime state -- not user-facing. Mutated by init/push. */
|
|
48
|
+
_eventsApi?: KlaviyoEventsApiMock;
|
|
49
|
+
_profilesApi?: KlaviyoProfilesApiMock;
|
|
50
|
+
_state?: RuntimeState;
|
|
51
|
+
}
|
|
52
|
+
interface RuntimeState {
|
|
53
|
+
lastIdentity?: {
|
|
54
|
+
email?: string;
|
|
55
|
+
externalId?: string;
|
|
56
|
+
phoneNumber?: string;
|
|
57
|
+
traitsHash?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Env -- optional SDK override. Production leaves this undefined and the
|
|
62
|
+
* destination creates real API instances. Tests provide mocks via
|
|
63
|
+
* env.eventsApi and env.profilesApi.
|
|
64
|
+
*/
|
|
65
|
+
interface Env extends DestinationServer.Env {
|
|
66
|
+
eventsApi?: KlaviyoEventsApiMock;
|
|
67
|
+
profilesApi?: KlaviyoProfilesApiMock;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Mock-friendly interface for EventsApi.createEvent().
|
|
71
|
+
*/
|
|
72
|
+
interface KlaviyoEventsApiMock {
|
|
73
|
+
createEvent: (body: Record<string, unknown>) => Promise<unknown>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Mock-friendly interface for ProfilesApi.createOrUpdateProfile().
|
|
77
|
+
*/
|
|
78
|
+
interface KlaviyoProfilesApiMock {
|
|
79
|
+
createOrUpdateProfile: (body: Record<string, unknown>) => Promise<unknown>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare const push: Env;
|
|
83
|
+
declare const simulation: string[];
|
|
84
|
+
|
|
85
|
+
declare const env_push: typeof push;
|
|
86
|
+
declare const env_simulation: typeof simulation;
|
|
87
|
+
declare namespace env {
|
|
88
|
+
export { env_push as push, env_simulation as simulation };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Klaviyo SDK step examples.
|
|
93
|
+
*
|
|
94
|
+
* At push time, the destination invokes the `klaviyo-api` SDK. The public
|
|
95
|
+
* method paths users see on the client are:
|
|
96
|
+
*
|
|
97
|
+
* - `eventsApi.createEvent(body)` — fires a metric event with inline profile
|
|
98
|
+
* - `profilesApi.createOrUpdateProfile(body)` — upserts a profile
|
|
99
|
+
*
|
|
100
|
+
* Each `out` is therefore `[['method.path', ...args], ...]` matching the
|
|
101
|
+
* actual SDK call order. `identify` fires before the event. When the rule
|
|
102
|
+
* uses `skip: true` or `ignore: true`, `out` is `[]` or the identify-only
|
|
103
|
+
* list.
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* Extended step example that may carry destination-level settings overrides.
|
|
107
|
+
*/
|
|
108
|
+
type KlaviyoStepExample = Flow.StepExample & {
|
|
109
|
+
settings?: Partial<Settings>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Default event forwarding -- eventsApi.createEvent() with event name and
|
|
113
|
+
* inline profile. Email resolved from default settings.email = 'user.email'.
|
|
114
|
+
*/
|
|
115
|
+
declare const defaultEvent: KlaviyoStepExample;
|
|
116
|
+
/**
|
|
117
|
+
* Mapped event name -- mapping.name renames the event to Klaviyo's expected
|
|
118
|
+
* metric name for ecommerce reporting.
|
|
119
|
+
*/
|
|
120
|
+
declare const mappedEventName: KlaviyoStepExample;
|
|
121
|
+
/**
|
|
122
|
+
* Revenue event -- order complete with value mapping. Sets $value and
|
|
123
|
+
* valueCurrency on the Klaviyo event for revenue tracking.
|
|
124
|
+
*/
|
|
125
|
+
declare const revenueEvent: KlaviyoStepExample;
|
|
126
|
+
/**
|
|
127
|
+
* Per-event identify with skip -- user login fires
|
|
128
|
+
* profilesApi.createOrUpdateProfile() only, no event tracked.
|
|
129
|
+
*/
|
|
130
|
+
declare const userLoginIdentify: KlaviyoStepExample;
|
|
131
|
+
/**
|
|
132
|
+
* Destination-level identify -- fires profilesApi.createOrUpdateProfile()
|
|
133
|
+
* on first push when settings.identify resolves, then fires createEvent().
|
|
134
|
+
*/
|
|
135
|
+
declare const destinationIdentify: KlaviyoStepExample;
|
|
136
|
+
/**
|
|
137
|
+
* Email only -- no externalId. Klaviyo accepts email as sole identifier.
|
|
138
|
+
*/
|
|
139
|
+
declare const emailOnly: KlaviyoStepExample;
|
|
140
|
+
/**
|
|
141
|
+
* Wildcard ignore -- the event matches a mapping rule with ignore: true.
|
|
142
|
+
* The destination fires zero API calls.
|
|
143
|
+
*/
|
|
144
|
+
declare const wildcardIgnored: KlaviyoStepExample;
|
|
145
|
+
|
|
146
|
+
type step_KlaviyoStepExample = KlaviyoStepExample;
|
|
147
|
+
declare const step_defaultEvent: typeof defaultEvent;
|
|
148
|
+
declare const step_destinationIdentify: typeof destinationIdentify;
|
|
149
|
+
declare const step_emailOnly: typeof emailOnly;
|
|
150
|
+
declare const step_mappedEventName: typeof mappedEventName;
|
|
151
|
+
declare const step_revenueEvent: typeof revenueEvent;
|
|
152
|
+
declare const step_userLoginIdentify: typeof userLoginIdentify;
|
|
153
|
+
declare const step_wildcardIgnored: typeof wildcardIgnored;
|
|
154
|
+
declare namespace step {
|
|
155
|
+
export { type step_KlaviyoStepExample as KlaviyoStepExample, step_defaultEvent as defaultEvent, step_destinationIdentify as destinationIdentify, step_emailOnly as emailOnly, step_mappedEventName as mappedEventName, step_revenueEvent as revenueEvent, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare const index_env: typeof env;
|
|
159
|
+
declare const index_step: typeof step;
|
|
160
|
+
declare namespace index {
|
|
161
|
+
export { index_env as env, index_step as step };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
4
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
5
|
+
|
|
6
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
7
|
+
apiKey: z.ZodString;
|
|
8
|
+
email: z.ZodOptional<z.ZodString>;
|
|
9
|
+
phoneNumber: z.ZodOptional<z.ZodString>;
|
|
10
|
+
externalId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
12
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
15
|
+
|
|
16
|
+
declare const MappingSchema: z.ZodObject<{
|
|
17
|
+
identify: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type Mapping = z.infer<typeof MappingSchema>;
|
|
21
|
+
|
|
22
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
23
|
+
declare const mapping: _walkeros_core_dev.JSONSchema;
|
|
24
|
+
|
|
25
|
+
type index$1_Mapping = Mapping;
|
|
26
|
+
declare const index$1_MappingSchema: typeof MappingSchema;
|
|
27
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
28
|
+
declare const index$1_mapping: typeof mapping;
|
|
29
|
+
declare const index$1_settings: typeof settings;
|
|
30
|
+
declare namespace index$1 {
|
|
31
|
+
export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Settings {
|
|
35
|
+
/** Klaviyo private API key (required). Starts with 'pk_'. */
|
|
36
|
+
apiKey: string;
|
|
37
|
+
/** walkerOS mapping value path to resolve email from each event. */
|
|
38
|
+
email?: string;
|
|
39
|
+
/** walkerOS mapping value path to resolve phone number (E.164) from each event. */
|
|
40
|
+
phoneNumber?: string;
|
|
41
|
+
/** walkerOS mapping value path to resolve external ID from each event. */
|
|
42
|
+
externalId?: string;
|
|
43
|
+
/** Destination-level identify mapping. Resolves to profile attributes for upsert. */
|
|
44
|
+
identify?: Mapping$1.Value;
|
|
45
|
+
/** Default currency for revenue events (ISO 4217, e.g. 'USD', 'EUR'). */
|
|
46
|
+
currency?: string;
|
|
47
|
+
/** Runtime state -- not user-facing. Mutated by init/push. */
|
|
48
|
+
_eventsApi?: KlaviyoEventsApiMock;
|
|
49
|
+
_profilesApi?: KlaviyoProfilesApiMock;
|
|
50
|
+
_state?: RuntimeState;
|
|
51
|
+
}
|
|
52
|
+
interface RuntimeState {
|
|
53
|
+
lastIdentity?: {
|
|
54
|
+
email?: string;
|
|
55
|
+
externalId?: string;
|
|
56
|
+
phoneNumber?: string;
|
|
57
|
+
traitsHash?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Env -- optional SDK override. Production leaves this undefined and the
|
|
62
|
+
* destination creates real API instances. Tests provide mocks via
|
|
63
|
+
* env.eventsApi and env.profilesApi.
|
|
64
|
+
*/
|
|
65
|
+
interface Env extends DestinationServer.Env {
|
|
66
|
+
eventsApi?: KlaviyoEventsApiMock;
|
|
67
|
+
profilesApi?: KlaviyoProfilesApiMock;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Mock-friendly interface for EventsApi.createEvent().
|
|
71
|
+
*/
|
|
72
|
+
interface KlaviyoEventsApiMock {
|
|
73
|
+
createEvent: (body: Record<string, unknown>) => Promise<unknown>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Mock-friendly interface for ProfilesApi.createOrUpdateProfile().
|
|
77
|
+
*/
|
|
78
|
+
interface KlaviyoProfilesApiMock {
|
|
79
|
+
createOrUpdateProfile: (body: Record<string, unknown>) => Promise<unknown>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
declare const push: Env;
|
|
83
|
+
declare const simulation: string[];
|
|
84
|
+
|
|
85
|
+
declare const env_push: typeof push;
|
|
86
|
+
declare const env_simulation: typeof simulation;
|
|
87
|
+
declare namespace env {
|
|
88
|
+
export { env_push as push, env_simulation as simulation };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Klaviyo SDK step examples.
|
|
93
|
+
*
|
|
94
|
+
* At push time, the destination invokes the `klaviyo-api` SDK. The public
|
|
95
|
+
* method paths users see on the client are:
|
|
96
|
+
*
|
|
97
|
+
* - `eventsApi.createEvent(body)` — fires a metric event with inline profile
|
|
98
|
+
* - `profilesApi.createOrUpdateProfile(body)` — upserts a profile
|
|
99
|
+
*
|
|
100
|
+
* Each `out` is therefore `[['method.path', ...args], ...]` matching the
|
|
101
|
+
* actual SDK call order. `identify` fires before the event. When the rule
|
|
102
|
+
* uses `skip: true` or `ignore: true`, `out` is `[]` or the identify-only
|
|
103
|
+
* list.
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* Extended step example that may carry destination-level settings overrides.
|
|
107
|
+
*/
|
|
108
|
+
type KlaviyoStepExample = Flow.StepExample & {
|
|
109
|
+
settings?: Partial<Settings>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Default event forwarding -- eventsApi.createEvent() with event name and
|
|
113
|
+
* inline profile. Email resolved from default settings.email = 'user.email'.
|
|
114
|
+
*/
|
|
115
|
+
declare const defaultEvent: KlaviyoStepExample;
|
|
116
|
+
/**
|
|
117
|
+
* Mapped event name -- mapping.name renames the event to Klaviyo's expected
|
|
118
|
+
* metric name for ecommerce reporting.
|
|
119
|
+
*/
|
|
120
|
+
declare const mappedEventName: KlaviyoStepExample;
|
|
121
|
+
/**
|
|
122
|
+
* Revenue event -- order complete with value mapping. Sets $value and
|
|
123
|
+
* valueCurrency on the Klaviyo event for revenue tracking.
|
|
124
|
+
*/
|
|
125
|
+
declare const revenueEvent: KlaviyoStepExample;
|
|
126
|
+
/**
|
|
127
|
+
* Per-event identify with skip -- user login fires
|
|
128
|
+
* profilesApi.createOrUpdateProfile() only, no event tracked.
|
|
129
|
+
*/
|
|
130
|
+
declare const userLoginIdentify: KlaviyoStepExample;
|
|
131
|
+
/**
|
|
132
|
+
* Destination-level identify -- fires profilesApi.createOrUpdateProfile()
|
|
133
|
+
* on first push when settings.identify resolves, then fires createEvent().
|
|
134
|
+
*/
|
|
135
|
+
declare const destinationIdentify: KlaviyoStepExample;
|
|
136
|
+
/**
|
|
137
|
+
* Email only -- no externalId. Klaviyo accepts email as sole identifier.
|
|
138
|
+
*/
|
|
139
|
+
declare const emailOnly: KlaviyoStepExample;
|
|
140
|
+
/**
|
|
141
|
+
* Wildcard ignore -- the event matches a mapping rule with ignore: true.
|
|
142
|
+
* The destination fires zero API calls.
|
|
143
|
+
*/
|
|
144
|
+
declare const wildcardIgnored: KlaviyoStepExample;
|
|
145
|
+
|
|
146
|
+
type step_KlaviyoStepExample = KlaviyoStepExample;
|
|
147
|
+
declare const step_defaultEvent: typeof defaultEvent;
|
|
148
|
+
declare const step_destinationIdentify: typeof destinationIdentify;
|
|
149
|
+
declare const step_emailOnly: typeof emailOnly;
|
|
150
|
+
declare const step_mappedEventName: typeof mappedEventName;
|
|
151
|
+
declare const step_revenueEvent: typeof revenueEvent;
|
|
152
|
+
declare const step_userLoginIdentify: typeof userLoginIdentify;
|
|
153
|
+
declare const step_wildcardIgnored: typeof wildcardIgnored;
|
|
154
|
+
declare namespace step {
|
|
155
|
+
export { type step_KlaviyoStepExample as KlaviyoStepExample, step_defaultEvent as defaultEvent, step_destinationIdentify as destinationIdentify, step_emailOnly as emailOnly, step_mappedEventName as mappedEventName, step_revenueEvent as revenueEvent, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare const index_env: typeof env;
|
|
159
|
+
declare const index_step: typeof step;
|
|
160
|
+
declare namespace index {
|
|
161
|
+
export { index_env as env, index_step as step };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(e,a)=>{for(var r in a)t(e,r,{get:a[r],enumerable:!0})},s={};n(s,{examples:()=>g,schemas:()=>o}),module.exports=(e=s,((e,n,s,o)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let p of r(n))i.call(e,p)||p===s||t(e,p,{get:()=>n[p],enumerable:!(o=a(n,p))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o={};n(o,{MappingSchema:()=>d,SettingsSchema:()=>l,mapping:()=>v,settings:()=>c});var p=require("@walkeros/core/dev"),m=require("@walkeros/core/dev"),l=m.z.object({apiKey:m.z.string().min(1).describe("Klaviyo private API key. Starts with pk_. Find it under Settings > API Keys in your Klaviyo account."),email:m.z.string().describe("walkerOS mapping value path to resolve email from each event (like user.email).").optional(),phoneNumber:m.z.string().describe("walkerOS mapping value path to resolve phone number in E.164 format from each event.").optional(),externalId:m.z.string().describe("walkerOS mapping value path to resolve external ID from each event (like user.id).").optional(),identify:m.z.unknown().describe("Destination-level identity mapping. Resolves to profile attributes { firstName?, lastName?, organization?, properties? }. Fires createOrUpdateProfile() on first push and re-fires when values change.").optional(),currency:m.z.string().length(3).describe("Default ISO 4217 currency code for revenue events (like USD, EUR). Sets valueCurrency on Klaviyo events.").optional()}),u=require("@walkeros/core/dev"),d=u.z.object({identify:u.z.unknown().describe("Per-event identify mapping. Resolves to profile attributes for createOrUpdateProfile(). Use with rule-level skip: true on login/signup events.").optional(),value:u.z.unknown().describe("Revenue value mapping. Resolves to a numeric value for Klaviyo revenue tracking. Sets the value property and valueCurrency on the event.").optional()}),c=(0,p.zodToSchema)(l),v=(0,p.zodToSchema)(d),g={};n(g,{env:()=>f,step:()=>O});var f={};n(f,{push:()=>b,simulation:()=>w});var y=()=>Promise.resolve({});var b={eventsApi:{createEvent:y},profilesApi:{createOrUpdateProfile:y}},w=["call:eventsApi.createEvent","call:profilesApi.createOrUpdateProfile"],O={};n(O,{defaultEvent:()=>P,destinationIdentify:()=>N,emailOnly:()=>E,mappedEventName:()=>S,revenueEvent:()=>h,userLoginIdentify:()=>x,wildcardIgnored:()=>k});var I=require("@walkeros/core"),P={in:(0,I.getEvent)("product view",{timestamp:1700000100,user:{id:"us3r",email:"user@example.com"}}),out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"product view"}}},properties:{},time:new Date(1700000100).toISOString()}}}]]},S={in:(0,I.getEvent)("product view",{timestamp:1700000101,user:{id:"us3r",email:"user@example.com"},data:{name:"USB Cable",id:"PROD-1",price:9.99}}),mapping:{name:"Viewed Product",data:{map:{ProductName:"data.name",ProductID:"data.id",Price:"data.price"}}},out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"Viewed Product"}}},properties:{ProductName:"USB Cable",ProductID:"PROD-1",Price:9.99},time:new Date(1700000101).toISOString()}}}]]},h={in:(0,I.getEvent)("order complete",{timestamp:1700000102,user:{id:"us3r",email:"user@example.com"},data:{id:"ORD-123",total:99.99,itemNames:["Widget A","Widget B"]}}),settings:{currency:"EUR"},mapping:{name:"Placed Order",data:{map:{OrderId:"data.id",value:"data.total",ItemNames:"data.itemNames"}},settings:{value:"data.total"}},out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"Placed Order"}}},properties:{OrderId:"ORD-123",value:99.99,ItemNames:["Widget A","Widget B"]},time:new Date(1700000102).toISOString(),valueCurrency:"EUR"}}}]]},x={in:(0,I.getEvent)("user login",{timestamp:1700000103,user:{id:"us3r",email:"user@acme.com"},data:{firstName:"Jane",lastName:"Doe",company:"Acme Corp",plan:"premium"}}),mapping:{skip:!0,settings:{identify:{map:{firstName:"data.firstName",lastName:"data.lastName",organization:"data.company",properties:{map:{plan:"data.plan"}}}}}},out:[["profilesApi.createOrUpdateProfile",{data:{type:"profile",attributes:{email:"user@acme.com",externalId:"us3r",firstName:"Jane",lastName:"Doe",organization:"Acme Corp",properties:{plan:"premium"}}}}]]},N={in:(0,I.getEvent)("page view",{timestamp:1700000104,user:{id:"us3r",email:"user@example.com",firstName:"Jane"}}),settings:{identify:{map:{firstName:"user.firstName"}}},out:[["profilesApi.createOrUpdateProfile",{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r",firstName:"Jane"}}}],["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"page view"}}},properties:{},time:new Date(1700000104).toISOString()}}}]]},E={in:(0,I.getEvent)("newsletter signup",{timestamp:1700000105,user:{email:"subscriber@example.com"}}),settings:{externalId:void 0},out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"subscriber@example.com"}}},metric:{data:{type:"metric",attributes:{name:"newsletter signup"}}},properties:{},time:new Date(1700000105).toISOString()}}}]]},k={in:(0,I.getEvent)("debug noise",{timestamp:1700000106,user:{id:"us3r",email:"user@example.com"}}),mapping:{ignore:!0},out:[]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'Klaviyo private API key. Starts with pk_. Find it under Settings > API Keys in your Klaviyo account.',\n ),\n email: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve email from each event (like user.email).',\n )\n .optional(),\n phoneNumber: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve phone number in E.164 format from each event.',\n )\n .optional(),\n externalId: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve external ID from each event (like user.id).',\n )\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'Destination-level identity mapping. Resolves to profile attributes { firstName?, lastName?, organization?, properties? }. Fires createOrUpdateProfile() on first push and re-fires when values change.',\n )\n .optional(),\n currency: z\n .string()\n .length(3)\n .describe(\n 'Default ISO 4217 currency code for revenue events (like USD, EUR). Sets valueCurrency on Klaviyo events.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identify mapping. Resolves to profile attributes for createOrUpdateProfile(). Use with rule-level skip: true on login/signup events.',\n )\n .optional(),\n value: z\n .unknown()\n .describe(\n 'Revenue value mapping. Resolves to a numeric value for Klaviyo revenue tracking. Sets the value property and valueCurrency on the event.',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type {\n Env,\n KlaviyoEventsApiMock,\n KlaviyoProfilesApiMock,\n} from '../types';\n\nconst asyncNoop = () => Promise.resolve({});\n\nfunction createMockEventsApi(): KlaviyoEventsApiMock {\n return {\n createEvent: asyncNoop,\n };\n}\n\nfunction createMockProfilesApi(): KlaviyoProfilesApiMock {\n return {\n createOrUpdateProfile: asyncNoop,\n };\n}\n\nexport const push: Env = {\n eventsApi: createMockEventsApi(),\n profilesApi: createMockProfilesApi(),\n};\n\nexport const simulation = [\n 'call:eventsApi.createEvent',\n 'call:profilesApi.createOrUpdateProfile',\n];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Klaviyo SDK step examples.\n *\n * At push time, the destination invokes the `klaviyo-api` SDK. The public\n * method paths users see on the client are:\n *\n * - `eventsApi.createEvent(body)` — fires a metric event with inline profile\n * - `profilesApi.createOrUpdateProfile(body)` — upserts a profile\n *\n * Each `out` is therefore `[['method.path', ...args], ...]` matching the\n * actual SDK call order. `identify` fires before the event. When the rule\n * uses `skip: true` or `ignore: true`, `out` is `[]` or the identify-only\n * list.\n */\n\n/**\n * Extended step example that may carry destination-level settings overrides.\n */\nexport type KlaviyoStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n};\n\n/**\n * Default event forwarding -- eventsApi.createEvent() with event name and\n * inline profile. Email resolved from default settings.email = 'user.email'.\n */\nexport const defaultEvent: KlaviyoStepExample = {\n in: getEvent('product view', {\n timestamp: 1700000100,\n user: { id: 'us3r', email: 'user@example.com' },\n }),\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'product view' },\n },\n },\n properties: {},\n time: new Date(1700000100).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Mapped event name -- mapping.name renames the event to Klaviyo's expected\n * metric name for ecommerce reporting.\n */\nexport const mappedEventName: KlaviyoStepExample = {\n in: getEvent('product view', {\n timestamp: 1700000101,\n user: { id: 'us3r', email: 'user@example.com' },\n data: {\n name: 'USB Cable',\n id: 'PROD-1',\n price: 9.99,\n },\n }),\n mapping: {\n name: 'Viewed Product',\n data: {\n map: {\n ProductName: 'data.name',\n ProductID: 'data.id',\n Price: 'data.price',\n },\n },\n },\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'Viewed Product' },\n },\n },\n properties: {\n ProductName: 'USB Cable',\n ProductID: 'PROD-1',\n Price: 9.99,\n },\n time: new Date(1700000101).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Revenue event -- order complete with value mapping. Sets $value and\n * valueCurrency on the Klaviyo event for revenue tracking.\n */\nexport const revenueEvent: KlaviyoStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000102,\n user: { id: 'us3r', email: 'user@example.com' },\n data: {\n id: 'ORD-123',\n total: 99.99,\n itemNames: ['Widget A', 'Widget B'],\n },\n }),\n settings: {\n currency: 'EUR',\n },\n mapping: {\n name: 'Placed Order',\n data: {\n map: {\n OrderId: 'data.id',\n value: 'data.total',\n ItemNames: 'data.itemNames',\n },\n },\n settings: {\n value: 'data.total',\n },\n },\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'Placed Order' },\n },\n },\n properties: {\n OrderId: 'ORD-123',\n value: 99.99,\n ItemNames: ['Widget A', 'Widget B'],\n },\n time: new Date(1700000102).toISOString(),\n valueCurrency: 'EUR',\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Per-event identify with skip -- user login fires\n * profilesApi.createOrUpdateProfile() only, no event tracked.\n */\nexport const userLoginIdentify: KlaviyoStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000103,\n user: { id: 'us3r', email: 'user@acme.com' },\n data: {\n firstName: 'Jane',\n lastName: 'Doe',\n company: 'Acme Corp',\n plan: 'premium',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n firstName: 'data.firstName',\n lastName: 'data.lastName',\n organization: 'data.company',\n properties: {\n map: {\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'profilesApi.createOrUpdateProfile',\n {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@acme.com',\n externalId: 'us3r',\n firstName: 'Jane',\n lastName: 'Doe',\n organization: 'Acme Corp',\n properties: {\n plan: 'premium',\n },\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Destination-level identify -- fires profilesApi.createOrUpdateProfile()\n * on first push when settings.identify resolves, then fires createEvent().\n */\nexport const destinationIdentify: KlaviyoStepExample = {\n in: getEvent('page view', {\n timestamp: 1700000104,\n user: { id: 'us3r', email: 'user@example.com', firstName: 'Jane' },\n }),\n settings: {\n identify: {\n map: {\n firstName: 'user.firstName',\n },\n },\n },\n out: [\n [\n 'profilesApi.createOrUpdateProfile',\n {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n firstName: 'Jane',\n },\n },\n },\n ],\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'page view' },\n },\n },\n properties: {},\n time: new Date(1700000104).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Email only -- no externalId. Klaviyo accepts email as sole identifier.\n */\nexport const emailOnly: KlaviyoStepExample = {\n in: getEvent('newsletter signup', {\n timestamp: 1700000105,\n user: { email: 'subscriber@example.com' },\n }),\n settings: {\n externalId: undefined,\n },\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'subscriber@example.com',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'newsletter signup' },\n },\n },\n properties: {},\n time: new Date(1700000105).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Wildcard ignore -- the event matches a mapping rule with ignore: true.\n * The destination fires zero API calls.\n */\nexport const wildcardIgnored: KlaviyoStepExample = {\n in: getEvent('debug noise', {\n timestamp: 1700000106,\n user: { id: 'us3r', email: 'user@example.com' },\n }),\n mapping: { ignore: true },\n out: [],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,QAAQ,aACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,OAAO,aACJ,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,aAAa,aACV,OAAO,EACP;AAAA,IACC;AAA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DED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,a)=>{for(var r in a)e(t,r,{get:a[r],enumerable:!0})},a={};t(a,{MappingSchema:()=>p,SettingsSchema:()=>n,mapping:()=>m,settings:()=>o});import{zodToSchema as r}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";var n=i.object({apiKey:i.string().min(1).describe("Klaviyo private API key. Starts with pk_. Find it under Settings > API Keys in your Klaviyo account."),email:i.string().describe("walkerOS mapping value path to resolve email from each event (like user.email).").optional(),phoneNumber:i.string().describe("walkerOS mapping value path to resolve phone number in E.164 format from each event.").optional(),externalId:i.string().describe("walkerOS mapping value path to resolve external ID from each event (like user.id).").optional(),identify:i.unknown().describe("Destination-level identity mapping. Resolves to profile attributes { firstName?, lastName?, organization?, properties? }. Fires createOrUpdateProfile() on first push and re-fires when values change.").optional(),currency:i.string().length(3).describe("Default ISO 4217 currency code for revenue events (like USD, EUR). Sets valueCurrency on Klaviyo events.").optional()});import{z as s}from"@walkeros/core/dev";var p=s.object({identify:s.unknown().describe("Per-event identify mapping. Resolves to profile attributes for createOrUpdateProfile(). Use with rule-level skip: true on login/signup events.").optional(),value:s.unknown().describe("Revenue value mapping. Resolves to a numeric value for Klaviyo revenue tracking. Sets the value property and valueCurrency on the event.").optional()}),o=r(n),m=r(p),l={};t(l,{env:()=>u,step:()=>f});var u={};t(u,{push:()=>c,simulation:()=>v});var d=()=>Promise.resolve({});var c={eventsApi:{createEvent:d},profilesApi:{createOrUpdateProfile:d}},v=["call:eventsApi.createEvent","call:profilesApi.createOrUpdateProfile"],f={};t(f,{defaultEvent:()=>y,destinationIdentify:()=>O,emailOnly:()=>S,mappedEventName:()=>b,revenueEvent:()=>w,userLoginIdentify:()=>I,wildcardIgnored:()=>x});import{getEvent as g}from"@walkeros/core";var y={in:g("product view",{timestamp:1700000100,user:{id:"us3r",email:"user@example.com"}}),out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"product view"}}},properties:{},time:new Date(1700000100).toISOString()}}}]]},b={in:g("product view",{timestamp:1700000101,user:{id:"us3r",email:"user@example.com"},data:{name:"USB Cable",id:"PROD-1",price:9.99}}),mapping:{name:"Viewed Product",data:{map:{ProductName:"data.name",ProductID:"data.id",Price:"data.price"}}},out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"Viewed Product"}}},properties:{ProductName:"USB Cable",ProductID:"PROD-1",Price:9.99},time:new Date(1700000101).toISOString()}}}]]},w={in:g("order complete",{timestamp:1700000102,user:{id:"us3r",email:"user@example.com"},data:{id:"ORD-123",total:99.99,itemNames:["Widget A","Widget B"]}}),settings:{currency:"EUR"},mapping:{name:"Placed Order",data:{map:{OrderId:"data.id",value:"data.total",ItemNames:"data.itemNames"}},settings:{value:"data.total"}},out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"Placed Order"}}},properties:{OrderId:"ORD-123",value:99.99,ItemNames:["Widget A","Widget B"]},time:new Date(1700000102).toISOString(),valueCurrency:"EUR"}}}]]},I={in:g("user login",{timestamp:1700000103,user:{id:"us3r",email:"user@acme.com"},data:{firstName:"Jane",lastName:"Doe",company:"Acme Corp",plan:"premium"}}),mapping:{skip:!0,settings:{identify:{map:{firstName:"data.firstName",lastName:"data.lastName",organization:"data.company",properties:{map:{plan:"data.plan"}}}}}},out:[["profilesApi.createOrUpdateProfile",{data:{type:"profile",attributes:{email:"user@acme.com",externalId:"us3r",firstName:"Jane",lastName:"Doe",organization:"Acme Corp",properties:{plan:"premium"}}}}]]},O={in:g("page view",{timestamp:1700000104,user:{id:"us3r",email:"user@example.com",firstName:"Jane"}}),settings:{identify:{map:{firstName:"user.firstName"}}},out:[["profilesApi.createOrUpdateProfile",{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r",firstName:"Jane"}}}],["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"user@example.com",externalId:"us3r"}}},metric:{data:{type:"metric",attributes:{name:"page view"}}},properties:{},time:new Date(1700000104).toISOString()}}}]]},S={in:g("newsletter signup",{timestamp:1700000105,user:{email:"subscriber@example.com"}}),settings:{externalId:void 0},out:[["eventsApi.createEvent",{data:{type:"event",attributes:{profile:{data:{type:"profile",attributes:{email:"subscriber@example.com"}}},metric:{data:{type:"metric",attributes:{name:"newsletter signup"}}},properties:{},time:new Date(1700000105).toISOString()}}}]]},x={in:g("debug noise",{timestamp:1700000106,user:{id:"us3r",email:"user@example.com"}}),mapping:{ignore:!0},out:[]};export{l as examples,a as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'Klaviyo private API key. Starts with pk_. Find it under Settings > API Keys in your Klaviyo account.',\n ),\n email: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve email from each event (like user.email).',\n )\n .optional(),\n phoneNumber: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve phone number in E.164 format from each event.',\n )\n .optional(),\n externalId: z\n .string()\n .describe(\n 'walkerOS mapping value path to resolve external ID from each event (like user.id).',\n )\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'Destination-level identity mapping. Resolves to profile attributes { firstName?, lastName?, organization?, properties? }. Fires createOrUpdateProfile() on first push and re-fires when values change.',\n )\n .optional(),\n currency: z\n .string()\n .length(3)\n .describe(\n 'Default ISO 4217 currency code for revenue events (like USD, EUR). Sets valueCurrency on Klaviyo events.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identify mapping. Resolves to profile attributes for createOrUpdateProfile(). Use with rule-level skip: true on login/signup events.',\n )\n .optional(),\n value: z\n .unknown()\n .describe(\n 'Revenue value mapping. Resolves to a numeric value for Klaviyo revenue tracking. Sets the value property and valueCurrency on the event.',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type {\n Env,\n KlaviyoEventsApiMock,\n KlaviyoProfilesApiMock,\n} from '../types';\n\nconst asyncNoop = () => Promise.resolve({});\n\nfunction createMockEventsApi(): KlaviyoEventsApiMock {\n return {\n createEvent: asyncNoop,\n };\n}\n\nfunction createMockProfilesApi(): KlaviyoProfilesApiMock {\n return {\n createOrUpdateProfile: asyncNoop,\n };\n}\n\nexport const push: Env = {\n eventsApi: createMockEventsApi(),\n profilesApi: createMockProfilesApi(),\n};\n\nexport const simulation = [\n 'call:eventsApi.createEvent',\n 'call:profilesApi.createOrUpdateProfile',\n];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Klaviyo SDK step examples.\n *\n * At push time, the destination invokes the `klaviyo-api` SDK. The public\n * method paths users see on the client are:\n *\n * - `eventsApi.createEvent(body)` — fires a metric event with inline profile\n * - `profilesApi.createOrUpdateProfile(body)` — upserts a profile\n *\n * Each `out` is therefore `[['method.path', ...args], ...]` matching the\n * actual SDK call order. `identify` fires before the event. When the rule\n * uses `skip: true` or `ignore: true`, `out` is `[]` or the identify-only\n * list.\n */\n\n/**\n * Extended step example that may carry destination-level settings overrides.\n */\nexport type KlaviyoStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n};\n\n/**\n * Default event forwarding -- eventsApi.createEvent() with event name and\n * inline profile. Email resolved from default settings.email = 'user.email'.\n */\nexport const defaultEvent: KlaviyoStepExample = {\n in: getEvent('product view', {\n timestamp: 1700000100,\n user: { id: 'us3r', email: 'user@example.com' },\n }),\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'product view' },\n },\n },\n properties: {},\n time: new Date(1700000100).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Mapped event name -- mapping.name renames the event to Klaviyo's expected\n * metric name for ecommerce reporting.\n */\nexport const mappedEventName: KlaviyoStepExample = {\n in: getEvent('product view', {\n timestamp: 1700000101,\n user: { id: 'us3r', email: 'user@example.com' },\n data: {\n name: 'USB Cable',\n id: 'PROD-1',\n price: 9.99,\n },\n }),\n mapping: {\n name: 'Viewed Product',\n data: {\n map: {\n ProductName: 'data.name',\n ProductID: 'data.id',\n Price: 'data.price',\n },\n },\n },\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'Viewed Product' },\n },\n },\n properties: {\n ProductName: 'USB Cable',\n ProductID: 'PROD-1',\n Price: 9.99,\n },\n time: new Date(1700000101).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Revenue event -- order complete with value mapping. Sets $value and\n * valueCurrency on the Klaviyo event for revenue tracking.\n */\nexport const revenueEvent: KlaviyoStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000102,\n user: { id: 'us3r', email: 'user@example.com' },\n data: {\n id: 'ORD-123',\n total: 99.99,\n itemNames: ['Widget A', 'Widget B'],\n },\n }),\n settings: {\n currency: 'EUR',\n },\n mapping: {\n name: 'Placed Order',\n data: {\n map: {\n OrderId: 'data.id',\n value: 'data.total',\n ItemNames: 'data.itemNames',\n },\n },\n settings: {\n value: 'data.total',\n },\n },\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'Placed Order' },\n },\n },\n properties: {\n OrderId: 'ORD-123',\n value: 99.99,\n ItemNames: ['Widget A', 'Widget B'],\n },\n time: new Date(1700000102).toISOString(),\n valueCurrency: 'EUR',\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Per-event identify with skip -- user login fires\n * profilesApi.createOrUpdateProfile() only, no event tracked.\n */\nexport const userLoginIdentify: KlaviyoStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000103,\n user: { id: 'us3r', email: 'user@acme.com' },\n data: {\n firstName: 'Jane',\n lastName: 'Doe',\n company: 'Acme Corp',\n plan: 'premium',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n firstName: 'data.firstName',\n lastName: 'data.lastName',\n organization: 'data.company',\n properties: {\n map: {\n plan: 'data.plan',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'profilesApi.createOrUpdateProfile',\n {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@acme.com',\n externalId: 'us3r',\n firstName: 'Jane',\n lastName: 'Doe',\n organization: 'Acme Corp',\n properties: {\n plan: 'premium',\n },\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Destination-level identify -- fires profilesApi.createOrUpdateProfile()\n * on first push when settings.identify resolves, then fires createEvent().\n */\nexport const destinationIdentify: KlaviyoStepExample = {\n in: getEvent('page view', {\n timestamp: 1700000104,\n user: { id: 'us3r', email: 'user@example.com', firstName: 'Jane' },\n }),\n settings: {\n identify: {\n map: {\n firstName: 'user.firstName',\n },\n },\n },\n out: [\n [\n 'profilesApi.createOrUpdateProfile',\n {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n firstName: 'Jane',\n },\n },\n },\n ],\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'user@example.com',\n externalId: 'us3r',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'page view' },\n },\n },\n properties: {},\n time: new Date(1700000104).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Email only -- no externalId. Klaviyo accepts email as sole identifier.\n */\nexport const emailOnly: KlaviyoStepExample = {\n in: getEvent('newsletter signup', {\n timestamp: 1700000105,\n user: { email: 'subscriber@example.com' },\n }),\n settings: {\n externalId: undefined,\n },\n out: [\n [\n 'eventsApi.createEvent',\n {\n data: {\n type: 'event',\n attributes: {\n profile: {\n data: {\n type: 'profile',\n attributes: {\n email: 'subscriber@example.com',\n },\n },\n },\n metric: {\n data: {\n type: 'metric',\n attributes: { name: 'newsletter signup' },\n },\n },\n properties: {},\n time: new Date(1700000105).toISOString(),\n },\n },\n },\n ],\n ],\n};\n\n/**\n * Wildcard ignore -- the event matches a mapping rule with ignore: true.\n * The destination fires zero API calls.\n */\nexport const wildcardIgnored: KlaviyoStepExample = {\n in: getEvent('debug noise', {\n timestamp: 1700000106,\n user: { id: 'us3r', email: 'user@example.com' },\n }),\n mapping: { ignore: true },\n out: [],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QA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AW;AAAA,IACX,MAAM,EAAE,IAAI,QAAQ,OAAO,mBAAmB;AAAA,EAChD,CAAC;AAAA,EACD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","names":["z"]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Mapping, Flow } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
3
|
+
|
|
4
|
+
interface Settings {
|
|
5
|
+
/** Klaviyo private API key (required). Starts with 'pk_'. */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** walkerOS mapping value path to resolve email from each event. */
|
|
8
|
+
email?: string;
|
|
9
|
+
/** walkerOS mapping value path to resolve phone number (E.164) from each event. */
|
|
10
|
+
phoneNumber?: string;
|
|
11
|
+
/** walkerOS mapping value path to resolve external ID from each event. */
|
|
12
|
+
externalId?: string;
|
|
13
|
+
/** Destination-level identify mapping. Resolves to profile attributes for upsert. */
|
|
14
|
+
identify?: Mapping.Value;
|
|
15
|
+
/** Default currency for revenue events (ISO 4217, e.g. 'USD', 'EUR'). */
|
|
16
|
+
currency?: string;
|
|
17
|
+
/** Runtime state -- not user-facing. Mutated by init/push. */
|
|
18
|
+
_eventsApi?: KlaviyoEventsApiMock;
|
|
19
|
+
_profilesApi?: KlaviyoProfilesApiMock;
|
|
20
|
+
_state?: RuntimeState;
|
|
21
|
+
}
|
|
22
|
+
interface RuntimeState {
|
|
23
|
+
lastIdentity?: {
|
|
24
|
+
email?: string;
|
|
25
|
+
externalId?: string;
|
|
26
|
+
phoneNumber?: string;
|
|
27
|
+
traitsHash?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Env -- optional SDK override. Production leaves this undefined and the
|
|
32
|
+
* destination creates real API instances. Tests provide mocks via
|
|
33
|
+
* env.eventsApi and env.profilesApi.
|
|
34
|
+
*/
|
|
35
|
+
interface Env extends DestinationServer.Env {
|
|
36
|
+
eventsApi?: KlaviyoEventsApiMock;
|
|
37
|
+
profilesApi?: KlaviyoProfilesApiMock;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Mock-friendly interface for EventsApi.createEvent().
|
|
41
|
+
*/
|
|
42
|
+
interface KlaviyoEventsApiMock {
|
|
43
|
+
createEvent: (body: Record<string, unknown>) => Promise<unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mock-friendly interface for ProfilesApi.createOrUpdateProfile().
|
|
47
|
+
*/
|
|
48
|
+
interface KlaviyoProfilesApiMock {
|
|
49
|
+
createOrUpdateProfile: (body: Record<string, unknown>) => Promise<unknown>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare const push: Env;
|
|
53
|
+
declare const simulation: string[];
|
|
54
|
+
|
|
55
|
+
declare const env_push: typeof push;
|
|
56
|
+
declare const env_simulation: typeof simulation;
|
|
57
|
+
declare namespace env {
|
|
58
|
+
export { env_push as push, env_simulation as simulation };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Klaviyo SDK step examples.
|
|
63
|
+
*
|
|
64
|
+
* At push time, the destination invokes the `klaviyo-api` SDK. The public
|
|
65
|
+
* method paths users see on the client are:
|
|
66
|
+
*
|
|
67
|
+
* - `eventsApi.createEvent(body)` — fires a metric event with inline profile
|
|
68
|
+
* - `profilesApi.createOrUpdateProfile(body)` — upserts a profile
|
|
69
|
+
*
|
|
70
|
+
* Each `out` is therefore `[['method.path', ...args], ...]` matching the
|
|
71
|
+
* actual SDK call order. `identify` fires before the event. When the rule
|
|
72
|
+
* uses `skip: true` or `ignore: true`, `out` is `[]` or the identify-only
|
|
73
|
+
* list.
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* Extended step example that may carry destination-level settings overrides.
|
|
77
|
+
*/
|
|
78
|
+
type KlaviyoStepExample = Flow.StepExample & {
|
|
79
|
+
settings?: Partial<Settings>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Default event forwarding -- eventsApi.createEvent() with event name and
|
|
83
|
+
* inline profile. Email resolved from default settings.email = 'user.email'.
|
|
84
|
+
*/
|
|
85
|
+
declare const defaultEvent: KlaviyoStepExample;
|
|
86
|
+
/**
|
|
87
|
+
* Mapped event name -- mapping.name renames the event to Klaviyo's expected
|
|
88
|
+
* metric name for ecommerce reporting.
|
|
89
|
+
*/
|
|
90
|
+
declare const mappedEventName: KlaviyoStepExample;
|
|
91
|
+
/**
|
|
92
|
+
* Revenue event -- order complete with value mapping. Sets $value and
|
|
93
|
+
* valueCurrency on the Klaviyo event for revenue tracking.
|
|
94
|
+
*/
|
|
95
|
+
declare const revenueEvent: KlaviyoStepExample;
|
|
96
|
+
/**
|
|
97
|
+
* Per-event identify with skip -- user login fires
|
|
98
|
+
* profilesApi.createOrUpdateProfile() only, no event tracked.
|
|
99
|
+
*/
|
|
100
|
+
declare const userLoginIdentify: KlaviyoStepExample;
|
|
101
|
+
/**
|
|
102
|
+
* Destination-level identify -- fires profilesApi.createOrUpdateProfile()
|
|
103
|
+
* on first push when settings.identify resolves, then fires createEvent().
|
|
104
|
+
*/
|
|
105
|
+
declare const destinationIdentify: KlaviyoStepExample;
|
|
106
|
+
/**
|
|
107
|
+
* Email only -- no externalId. Klaviyo accepts email as sole identifier.
|
|
108
|
+
*/
|
|
109
|
+
declare const emailOnly: KlaviyoStepExample;
|
|
110
|
+
/**
|
|
111
|
+
* Wildcard ignore -- the event matches a mapping rule with ignore: true.
|
|
112
|
+
* The destination fires zero API calls.
|
|
113
|
+
*/
|
|
114
|
+
declare const wildcardIgnored: KlaviyoStepExample;
|
|
115
|
+
|
|
116
|
+
type step_KlaviyoStepExample = KlaviyoStepExample;
|
|
117
|
+
declare const step_defaultEvent: typeof defaultEvent;
|
|
118
|
+
declare const step_destinationIdentify: typeof destinationIdentify;
|
|
119
|
+
declare const step_emailOnly: typeof emailOnly;
|
|
120
|
+
declare const step_mappedEventName: typeof mappedEventName;
|
|
121
|
+
declare const step_revenueEvent: typeof revenueEvent;
|
|
122
|
+
declare const step_userLoginIdentify: typeof userLoginIdentify;
|
|
123
|
+
declare const step_wildcardIgnored: typeof wildcardIgnored;
|
|
124
|
+
declare namespace step {
|
|
125
|
+
export { type step_KlaviyoStepExample as KlaviyoStepExample, step_defaultEvent as defaultEvent, step_destinationIdentify as destinationIdentify, step_emailOnly as emailOnly, step_mappedEventName as mappedEventName, step_revenueEvent as revenueEvent, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { env, step };
|