@xbg.solutions/utils-journey-connector 1.0.0

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/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Journey Connector Barrel Export
3
+ */
4
+ export * from './types';
5
+ export * from './journey-connector';
6
+ export * from './providers/ortto-provider';
7
+ import { JourneyConnector } from './journey-connector';
8
+ export declare function initializeJourneyConnector(config: any): void;
9
+ export declare function createJourneyConnector(): JourneyConnector | null;
10
+ export declare function getJourneyConnector(): JourneyConnector | null;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAMvD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAI5D;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,GAAG,IAAI,CAuBhE;AAID,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,IAAI,CAK7D"}
package/lib/index.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * Journey Connector Barrel Export
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.initializeJourneyConnector = initializeJourneyConnector;
21
+ exports.createJourneyConnector = createJourneyConnector;
22
+ exports.getJourneyConnector = getJourneyConnector;
23
+ __exportStar(require("./types"), exports);
24
+ __exportStar(require("./journey-connector"), exports);
25
+ __exportStar(require("./providers/ortto-provider"), exports);
26
+ const journey_connector_1 = require("./journey-connector");
27
+ const ortto_provider_1 = require("./providers/ortto-provider");
28
+ // Config is provided via initializeJourneyConnector() at app startup
29
+ let connectorConfig = null;
30
+ function initializeJourneyConnector(config) {
31
+ connectorConfig = config;
32
+ // Reset singleton so it gets re-created with new config
33
+ journeyConnectorInstance = undefined;
34
+ }
35
+ function createJourneyConnector() {
36
+ if (!connectorConfig) {
37
+ throw new Error('Journey connector not initialized. Call initializeJourneyConnector() first.');
38
+ }
39
+ if (!connectorConfig.journey.enabled) {
40
+ return null;
41
+ }
42
+ const provider = connectorConfig.journey.provider;
43
+ if (provider === 'ortto') {
44
+ const config = connectorConfig.journey.providers.ortto;
45
+ if (!(config === null || config === void 0 ? void 0 : config.apiKey)) {
46
+ throw new Error('Ortto API key is required');
47
+ }
48
+ return new journey_connector_1.JourneyConnector(new ortto_provider_1.OrttoProvider(Object.assign(Object.assign({}, config), { region: config.region })));
49
+ }
50
+ throw new Error(`Unsupported journey provider: ${provider}`);
51
+ }
52
+ let journeyConnectorInstance;
53
+ function getJourneyConnector() {
54
+ if (journeyConnectorInstance === undefined) {
55
+ journeyConnectorInstance = createJourneyConnector();
56
+ }
57
+ return journeyConnectorInstance;
58
+ }
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAYH,gEAIC;AAED,wDAuBC;AAID,k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ing automation and customer journey management
4
+ */
5
+ import { JourneyContact, JourneyEnrollment, ActivityEvent, ListSubscription, JourneySegment, Journey, JourneyResponse } from './types';
6
+ /**
7
+ * Journey Provider Interface
8
+ */
9
+ export interface JourneyProvider {
10
+ /**
11
+ * Create or update a contact
12
+ */
13
+ upsertContact(contact: JourneyContact): Promise<JourneyResponse>;
14
+ /**
15
+ * Enroll contacts in a journey/campaign
16
+ */
17
+ enrollInJourney(enrollment: JourneyEnrollment): Promise<JourneyResponse>;
18
+ /**
19
+ * Remove contact from journey
20
+ */
21
+ unenrollFromJourney(journeyId: string, email: string): Promise<JourneyResponse>;
22
+ /**
23
+ * Track custom activity/event
24
+ */
25
+ trackActivity(event: ActivityEvent): Promise<JourneyResponse>;
26
+ /**
27
+ * Subscribe to list
28
+ */
29
+ subscribeToList(subscription: ListSubscription): Promise<JourneyResponse>;
30
+ /**
31
+ * Unsubscribe from list
32
+ */
33
+ unsubscribeFromList(listId: string, email: string): Promise<JourneyResponse>;
34
+ /**
35
+ * Get available journeys
36
+ */
37
+ getJourneys(): Promise<Journey[]>;
38
+ /**
39
+ * Get segments
40
+ */
41
+ getSegments(): Promise<JourneySegment[]>;
42
+ /**
43
+ * Add tags to contact
44
+ */
45
+ addTags(email: string, tags: string[]): Promise<JourneyResponse>;
46
+ /**
47
+ * Remove tags from contact
48
+ */
49
+ removeTags(email: string, tags: string[]): Promise<JourneyResponse>;
50
+ }
51
+ /**
52
+ * Journey Connector
53
+ * Unified interface for marketing automation platforms
54
+ */
55
+ export declare class JourneyConnector {
56
+ private provider;
57
+ constructor(provider: JourneyProvider);
58
+ /**
59
+ * Create or update a contact
60
+ */
61
+ upsertContact(contact: JourneyContact): Promise<JourneyResponse>;
62
+ /**
63
+ * Enroll contacts in a journey/campaign
64
+ */
65
+ enrollInJourney(enrollment: JourneyEnrollment): Promise<JourneyResponse>;
66
+ /**
67
+ * Remove contact from journey
68
+ */
69
+ unenrollFromJourney(journeyId: string, email: string): Promise<JourneyResponse>;
70
+ /**
71
+ * Track custom activity/event
72
+ */
73
+ trackActivity(event: ActivityEvent): Promise<JourneyResponse>;
74
+ /**
75
+ * Subscribe contact to list
76
+ */
77
+ subscribeToList(subscription: ListSubscription): Promise<JourneyResponse>;
78
+ /**
79
+ * Unsubscribe contact from list
80
+ */
81
+ unsubscribeFromList(listId: string, email: string): Promise<JourneyResponse>;
82
+ /**
83
+ * Get all available journeys
84
+ */
85
+ getJourneys(): Promise<Journey[]>;
86
+ /**
87
+ * Get all segments
88
+ */
89
+ getSegments(): Promise<JourneySegment[]>;
90
+ /**
91
+ * Add tags to contact
92
+ */
93
+ addTags(email: string, tags: string[]): Promise<JourneyResponse>;
94
+ /**
95
+ * Remove tags from contact
96
+ */
97
+ removeTags(email: string, tags: string[]): Promise<JourneyResponse>;
98
+ }
99
+ //# sourceMappingURL=journey-connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-connector.d.ts","sourceRoot":"","sources":["../src/journey-connector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEjE;;OAEG;IACH,eAAe,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEzE;;OAEG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEhF;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9D;;OAEG;IACH,eAAe,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,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O,CAAC,cAAc,EAAE,CAAC;IAS9C;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IActE;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;CAa1E"}
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ /**
3
+ * Journey Connector
4
+ * Marketing automation and customer journey management
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.JourneyConnector = void 0;
8
+ const utils_logger_1 = require("@xbg/utils-logger");
9
+ /**
10
+ * Journey Connector
11
+ * Unified interface for marketing automation platforms
12
+ */
13
+ class JourneyConnector {
14
+ constructor(provider) {
15
+ this.provider = provider;
16
+ }
17
+ /**
18
+ * Create or update a contact
19
+ */
20
+ async upsertContact(contact) {
21
+ utils_logger_1.logger.info('Upserting contact in journey system', {
22
+ email: contact.email,
23
+ });
24
+ try {
25
+ const response = await this.provider.upsertContact(contact);
26
+ if (response.success) {
27
+ utils_logger_1.logger.info('Contact upserted successfully');
28
+ }
29
+ else {
30
+ utils_logger_1.logger.warn('Failed to upsert contact', { errors: response.errors });
31
+ }
32
+ return response;
33
+ }
34
+ catch (error) {
35
+ utils_logger_1.logger.error('Error upserting contact', error instanceof Error ? error : new Error('Unknown error'));
36
+ throw error;
37
+ }
38
+ }
39
+ /**
40
+ * Enroll contacts in a journey/campaign
41
+ */
42
+ async enrollInJourney(enrollment) {
43
+ var _a;
44
+ utils_logger_1.logger.info('Enrolling contacts in journey', {
45
+ journeyId: enrollment.journeyId,
46
+ contactCount: enrollment.contacts.length,
47
+ });
48
+ try {
49
+ const response = await this.provider.enrollInJourney(enrollment);
50
+ utils_logger_1.logger.info('Journey enrollment completed', {
51
+ success: response.success,
52
+ enrolledCount: (_a = response.contactIds) === null || _a === void 0 ? void 0 : _a.length,
53
+ });
54
+ return response;
55
+ }
56
+ catch (error) {
57
+ utils_logger_1.logger.error('Error enrolling in journey', error instanceof Error ? error : new Error('Unknown error'));
58
+ throw error;
59
+ }
60
+ }
61
+ /**
62
+ * Remove contact from journey
63
+ */
64
+ async unenrollFromJourney(journeyId, email) {
65
+ utils_logger_1.logger.info('Unenrolling contact from journey', {
66
+ journeyId,
67
+ email,
68
+ });
69
+ try {
70
+ return await this.provider.unenrollFromJourney(journeyId, email);
71
+ }
72
+ catch (error) {
73
+ utils_logger_1.logger.error('Error unenrolling from journey', error instanceof Error ? error : new Error('Unknown error'));
74
+ throw error;
75
+ }
76
+ }
77
+ /**
78
+ * Track custom activity/event
79
+ */
80
+ async trackActivity(event) {
81
+ utils_logger_1.logger.info('Tracking activity', {
82
+ email: event.email,
83
+ activityId: event.activityId,
84
+ });
85
+ try {
86
+ return await this.provider.trackActivity(event);
87
+ }
88
+ catch (error) {
89
+ utils_logger_1.logger.error('Error tracking activity', error instanceof Error ? error : new Error('Unknown error'));
90
+ throw error;
91
+ }
92
+ }
93
+ /**
94
+ * Subscribe contact to list
95
+ */
96
+ async subscribeToList(subscription) {
97
+ utils_logger_1.logger.info('Subscribing to list', {
98
+ email: subscription.email,
99
+ listId: subscription.listId,
100
+ });
101
+ try {
102
+ return await this.provider.subscribeToList(subscription);
103
+ }
104
+ catch (error) {
105
+ utils_logger_1.logger.error('Error subscribing to list', error instanceof Error ? error : new Error('Unknown error'));
106
+ throw error;
107
+ }
108
+ }
109
+ /**
110
+ * Unsubscribe contact from list
111
+ */
112
+ async unsubscribeFromList(listId, email) {
113
+ utils_logger_1.logger.info('Unsubscribing from list', {
114
+ email,
115
+ listId,
116
+ });
117
+ try {
118
+ return await this.provider.unsubscribeFromList(listId, email);
119
+ }
120
+ catch (error) {
121
+ utils_logger_1.logger.error('Error unsubscribing from list', error instanceof Error ? error : new Error('Unknown error'));
122
+ throw error;
123
+ }
124
+ }
125
+ /**
126
+ * Get all available journeys
127
+ */
128
+ async getJourneys() {
129
+ try {
130
+ return await this.provider.getJourneys();
131
+ }
132
+ catch (error) {
133
+ utils_logger_1.logger.error('Error fetching journeys', error instanceof Error ? error : new Error('Unknown error'));
134
+ throw error;
135
+ }
136
+ }
137
+ /**
138
+ * Get all segments
139
+ */
140
+ async getSegments() {
141
+ try {
142
+ return await this.provider.getSegments();
143
+ }
144
+ catch (error) {
145
+ utils_logger_1.logger.error('Error fetching segments', error instanceof Error ? error : new Error('Unknown error'));
146
+ throw error;
147
+ }
148
+ }
149
+ /**
150
+ * Add tags to contact
151
+ */
152
+ async addTags(email, tags) {
153
+ utils_logger_1.logger.info('Adding tags to contact', {
154
+ email,
155
+ tags,
156
+ });
157
+ try {
158
+ return await this.provider.addTags(email, tags);
159
+ }
160
+ catch (error) {
161
+ utils_logger_1.logger.error('Error adding tags', error instanceof Error ? error : new Error('Unknown error'));
162
+ throw error;
163
+ }
164
+ }
165
+ /**
166
+ * Remove tags from contact
167
+ */
168
+ async removeTags(email, tags) {
169
+ utils_logger_1.logger.info('Removing tags from contact', {
170
+ email,
171
+ tags,
172
+ });
173
+ try {
174
+ return await this.provider.removeTags(email, tags);
175
+ }
176
+ catch (error) {
177
+ utils_logger_1.logger.error('Error removing tags', error instanceof Error ? error : new Error('Unknown error'));
178
+ throw error;
179
+ }
180
+ }
181
+ }
182
+ exports.JourneyConnector = JourneyConnector;
183
+ //# sourceMappingURL=journey-connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey-connector.js","sourceRoot":"","sources":["../src/journey-connector.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAWH,oDAA2C;AAyD3C;;;GAGG;AACH,MAAa,gBAAgB;IAG3B,YAAY,QAAyB;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,OAAuB;QACzC,qBAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE;YACjD,KAAK,EAAE,OAAO,CAAC,K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KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;YACjG,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AApLD,4CAoLC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Ortto Provider for Journey Connector
3
+ * https://help.ortto.com/developer/latest/
4
+ */
5
+ import { JourneyProvider } from '../journey-connector';
6
+ import { JourneyContact, JourneyEnrollment, ActivityEvent, ListSubscription, JourneySegment, Journey, JourneyResponse } from '../types';
7
+ export interface OrttoProviderConfig {
8
+ apiKey: string;
9
+ region?: 'us' | 'au' | 'eu';
10
+ }
11
+ export declare class OrttoProvider implements JourneyProvider {
12
+ private client;
13
+ constructor(config: OrttoProviderConfig);
14
+ private getBaseURL;
15
+ /**
16
+ * Create or update a contact in Ortto
17
+ */
18
+ upsertContact(contact: JourneyContact): Promise<JourneyResponse>;
19
+ /**
20
+ * Enroll contacts in a journey (campaign)
21
+ */
22
+ enrollInJourney(enrollment: JourneyEnrollment): Promise<JourneyResponse>;
23
+ /**
24
+ * Remove contact from journey
25
+ */
26
+ unenrollFromJourney(journeyId: string, email: string): Promise<JourneyResponse>;
27
+ /**
28
+ * Track custom activity
29
+ */
30
+ trackActivity(event: ActivityEvent): Promise<JourneyResponse>;
31
+ /**
32
+ * Subscribe to list
33
+ */
34
+ subscribeToList(subscription: ListSubscription): Promise<JourneyResponse>;
35
+ /**
36
+ * Unsubscribe from list
37
+ */
38
+ unsubscribeFromList(listId: string, email: string): Promise<JourneyResponse>;
39
+ /**
40
+ * Get available journeys (campaigns)
41
+ */
42
+ getJourneys(): Promise<Journey[]>;
43
+ /**
44
+ * Get segments
45
+ */
46
+ getSegments(): Promise<JourneySegment[]>;
47
+ /**
48
+ * Add tags to contact
49
+ */
50
+ addTags(email: string, tags: string[]): Promise<JourneyResponse>;
51
+ /**
52
+ * Remove tags from contact
53
+ */
54
+ removeTags(email: string, tags: string[]): Promise<JourneyResponse>;
55
+ /**
56
+ * Map custom fields to Ortto format
57
+ */
58
+ private mapCustomFields;
59
+ }
60
+ //# sourceMappingURL=ortto-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ortto-provider.d.ts","sourceRoot":"","sources":["../../src/providers/ortto-provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC7B;AAED,qBAAa,aAAc,YAAW,eAAe;IACnD,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,mBAAmB;IAYvC,OAAO,CAAC,UAAU;IASlB;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAmCtE;;OAEG;IACG,eAAe,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IA0C9E;;OAEG;IACG,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBrF;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAgCnE;;OAEG;IACG,eAAe,CAAC,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;IAiC/E;;OAEG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAuBlF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAiBvC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAe9C;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBtE;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBzE;;OAEG;IACH,OAAO,CAAC,eAAe;CAuBxB"}
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ /**
3
+ * Ortto Provider for Journey Connector
4
+ * https://help.ortto.com/developer/latest/
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.OrttoProvider = void 0;
11
+ const axios_1 = __importDefault(require("axios"));
12
+ class OrttoProvider {
13
+ constructor(config) {
14
+ const baseURL = this.getBaseURL(config.region || 'us');
15
+ this.client = axios_1.default.create({
16
+ baseURL,
17
+ headers: {
18
+ 'X-Api-Key': config.apiKey,
19
+ 'Content-Type': 'application/json',
20
+ },
21
+ });
22
+ }
23
+ getBaseURL(region) {
24
+ const regionMap = {
25
+ us: 'https://api.ortto.com',
26
+ au: 'https://api.ap-southeast-2.ortto.com',
27
+ eu: 'https://api.eu-west-1.ortto.com',
28
+ };
29
+ return regionMap[region] || regionMap.us;
30
+ }
31
+ /**
32
+ * Create or update a contact in Ortto
33
+ */
34
+ async upsertContact(contact) {
35
+ var _a, _b;
36
+ try {
37
+ const payload = {
38
+ contacts: [
39
+ {
40
+ fields: Object.assign({ 'str::email': contact.email, 'str::first': contact.firstName, 'str::last': contact.lastName, 'phn::phone': contact.phone }, this.mapCustomFields(contact.customFields)),
41
+ tags: contact.tags,
42
+ },
43
+ ],
44
+ merge_by: ['str::email'],
45
+ };
46
+ const response = await this.client.post('/v1/person/merge', payload);
47
+ return {
48
+ success: true,
49
+ contactIds: (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.contacts) === null || _b === void 0 ? void 0 : _b.map((c) => c.id),
50
+ };
51
+ }
52
+ catch (error) {
53
+ return {
54
+ success: false,
55
+ errors: [{
56
+ email: contact.email,
57
+ error: error instanceof Error ? error.message : String(error),
58
+ }],
59
+ };
60
+ }
61
+ }
62
+ /**
63
+ * Enroll contacts in a journey (campaign)
64
+ */
65
+ async enrollInJourney(enrollment) {
66
+ try {
67
+ // First, upsert all contacts
68
+ const contacts = enrollment.contacts.map(c => ({
69
+ fields: Object.assign({ 'str::email': c.email, 'str::first': c.firstName, 'str::last': c.lastName }, this.mapCustomFields(c.customFields)),
70
+ }));
71
+ await this.client.post('/v1/person/merge', {
72
+ contacts,
73
+ merge_by: ['str::email'],
74
+ });
75
+ // Then add them to the campaign
76
+ const campaignPayload = {
77
+ campaign_id: enrollment.journeyId,
78
+ contacts: enrollment.contacts.map(c => ({
79
+ email: c.email,
80
+ })),
81
+ };
82
+ await this.client.post('/v1/campaigns/enroll', campaignPayload);
83
+ return {
84
+ success: true,
85
+ message: `Enrolled ${enrollment.contacts.length} contacts in journey`,
86
+ };
87
+ }
88
+ catch (error) {
89
+ return {
90
+ success: false,
91
+ errors: [{
92
+ email: '',
93
+ error: error instanceof Error ? error.message : String(error),
94
+ }],
95
+ };
96
+ }
97
+ }
98
+ /**
99
+ * Remove contact from journey
100
+ */
101
+ async unenrollFromJourney(journeyId, email) {
102
+ try {
103
+ await this.client.post('/v1/campaigns/unenroll', {
104
+ campaign_id: journeyId,
105
+ contacts: [{ email }],
106
+ });
107
+ return {
108
+ success: true,
109
+ message: 'Contact unenrolled from journey',
110
+ };
111
+ }
112
+ catch (error) {
113
+ return {
114
+ success: false,
115
+ errors: [{
116
+ email,
117
+ error: error instanceof Error ? error.message : String(error),
118
+ }],
119
+ };
120
+ }
121
+ }
122
+ /**
123
+ * Track custom activity
124
+ */
125
+ async trackActivity(event) {
126
+ try {
127
+ const payload = {
128
+ activities: [
129
+ {
130
+ activity_id: event.activityId,
131
+ attributes: Object.assign({ 'str::email': event.email }, this.mapCustomFields(event.data)),
132
+ timestamp: event.timestamp || new Date(),
133
+ },
134
+ ],
135
+ };
136
+ await this.client.post('/v1/activities', payload);
137
+ return {
138
+ success: true,
139
+ message: 'Activity tracked successfully',
140
+ };
141
+ }
142
+ catch (error) {
143
+ return {
144
+ success: false,
145
+ errors: [{
146
+ email: event.email,
147
+ error: error instanceof Error ? error.message : String(error),
148
+ }],
149
+ };
150
+ }
151
+ }
152
+ /**
153
+ * Subscribe to list
154
+ */
155
+ async subscribeToList(subscription) {
156
+ try {
157
+ // In Ortto, lists are managed through tags
158
+ const payload = {
159
+ contacts: [
160
+ {
161
+ fields: Object.assign({ 'str::email': subscription.email }, this.mapCustomFields(subscription.customFields)),
162
+ tags: [`list:${subscription.listId}`],
163
+ },
164
+ ],
165
+ merge_by: ['str::email'],
166
+ };
167
+ await this.client.post('/v1/person/merge', payload);
168
+ return {
169
+ success: true,
170
+ message: 'Subscribed to list successfully',
171
+ };
172
+ }
173
+ catch (error) {
174
+ return {
175
+ success: false,
176
+ errors: [{
177
+ email: subscription.email,
178
+ error: error instanceof Error ? error.message : String(error),
179
+ }],
180
+ };
181
+ }
182
+ }
183
+ /**
184
+ * Unsubscribe from list
185
+ */
186
+ async unsubscribeFromList(listId, email) {
187
+ try {
188
+ // Remove the list tag
189
+ await this.client.post('/v1/person/tags/remove', {
190
+ email,
191
+ tags: [`list:${listId}`],
192
+ });
193
+ return {
194
+ success: true,
195
+ message: 'Unsubscribed from list successfully',
196
+ };
197
+ }
198
+ catch (error) {
199
+ return {
200
+ success: false,
201
+ errors: [{
202
+ email,
203
+ error: error instanceof Error ? error.message : String(error),
204
+ }],
205
+ };
206
+ }
207
+ }
208
+ /**
209
+ * Get available journeys (campaigns)
210
+ */
211
+ async getJourneys() {
212
+ var _a, _b;
213
+ try {
214
+ const response = await this.client.get('/v1/campaigns');
215
+ return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.map((campaign) => ({
216
+ id: campaign.id,
217
+ name: campaign.name,
218
+ status: campaign.status,
219
+ type: campaign.type,
220
+ enrolledCount: campaign.enrolled_count,
221
+ completedCount: campaign.completed_count,
222
+ }))) || [];
223
+ }
224
+ catch (error) {
225
+ return [];
226
+ }
227
+ }
228
+ /**
229
+ * Get segments
230
+ */
231
+ async getSegments() {
232
+ var _a, _b;
233
+ try {
234
+ const response = await this.client.get('/v1/segments');
235
+ return ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.segments) === null || _b === void 0 ? void 0 : _b.map((segment) => ({
236
+ id: segment.id,
237
+ name: segment.name,
238
+ description: segment.description,
239
+ conditions: segment.conditions,
240
+ }))) || [];
241
+ }
242
+ catch (error) {
243
+ return [];
244
+ }
245
+ }
246
+ /**
247
+ * Add tags to contact
248
+ */
249
+ async addTags(email, tags) {
250
+ try {
251
+ await this.client.post('/v1/person/tags/add', {
252
+ email,
253
+ tags,
254
+ });
255
+ return {
256
+ success: true,
257
+ message: 'Tags added successfully',
258
+ };
259
+ }
260
+ catch (error) {
261
+ return {
262
+ success: false,
263
+ errors: [{
264
+ email,
265
+ error: error instanceof Error ? error.message : String(error),
266
+ }],
267
+ };
268
+ }
269
+ }
270
+ /**
271
+ * Remove tags from contact
272
+ */
273
+ async removeTags(email, tags) {
274
+ try {
275
+ await this.client.post('/v1/person/tags/remove', {
276
+ email,
277
+ tags,
278
+ });
279
+ return {
280
+ success: true,
281
+ message: 'Tags removed successfully',
282
+ };
283
+ }
284
+ catch (error) {
285
+ return {
286
+ success: false,
287
+ errors: [{
288
+ email,
289
+ error: error instanceof Error ? error.message : String(error),
290
+ }],
291
+ };
292
+ }
293
+ }
294
+ /**
295
+ * Map custom fields to Ortto format
296
+ */
297
+ mapCustomFields(fields) {
298
+ if (!fields)
299
+ return {};
300
+ // Ortto uses typed field prefixes: str::, int::, dtz::, etc.
301
+ const mapped = {};
302
+ for (const [key, value] of Object.entries(fields)) {
303
+ const type = typeof value;
304
+ let prefix = 'str';
305
+ if (type === 'number') {
306
+ prefix = Number.isInteger(value) ? 'int' : 'dec';
307
+ }
308
+ else if (type === 'boolean') {
309
+ prefix = 'bol';
310
+ }
311
+ else if (value instanceof Date) {
312
+ prefix = 'dtz';
313
+ }
314
+ mapped[`${prefix}::${key}`] = value;
315
+ }
316
+ return mapped;
317
+ }
318
+ }
319
+ exports.OrttoProvider = OrttoProvider;
320
+ //# sourceMappingURL=ortto-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ortto-provider.js","sourceRoot":"","sources":["../../src/providers/ortto-provider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA6C;AAiB7C,MAAa,aAAa;IAGxB,YAAY,MAA2B;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;QAEvD,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO;YACP,OAAO,EAAE;gBACP,WAAW,EAAE,MAAM,CAAC,MAAM;gBAC1B,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;IACL,CAAC;IAEO,UAAU,CAAC,MAAc;QAC/B,MAAM,SAAS,GAA2B;YACxC,EAAE,EAAE,uBAAuB;YAC3B,EAAE,EAAE,sCAAsC;YAC1C,EAAE,EAAE,iCAAiC;SACtC,CAAC;QACF,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,OAAuB;;QACzC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG;gBACd,QAAQ,EAAE;oBACR;wBACE,MAAM,kBACJ,YAAY,EAAE,OAAO,CAAC,KAAK,EAC3B,YAAY,EAAE,OAAO,CAAC,SAAS,EAC/B,WAAW,EAAE,OAAO,CAAC,QAAQ,EAC7B,YAAY,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,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YACnD,CAAC;iBAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,GAAG,KAAK,CAAC;YACjB,CAAC;iBAAM,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;gBACjC,MAAM,GAAG,KAAK,CAAC;YACjB,CAAC;YAED,MAAM,CAAC,GAAG,MAAM,KAAK,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvVD,sCAuVC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Journey Connector Types
3
+ * Marketing automation and customer journey management
4
+ */
5
+ /**
6
+ * Contact/Person in marketing automation system
7
+ */
8
+ export interface JourneyContact {
9
+ email: string;
10
+ firstName?: string;
11
+ lastName?: string;
12
+ phone?: string;
13
+ customFields?: Record<string, any>;
14
+ tags?: string[];
15
+ lists?: string[];
16
+ }
17
+ /**
18
+ * Journey/Campaign enrollment
19
+ */
20
+ export interface JourneyEnrollment {
21
+ journeyId: string;
22
+ contacts: JourneyContact[];
23
+ data?: Record<string, any>;
24
+ }
25
+ /**
26
+ * Track custom activity/event
27
+ */
28
+ export interface ActivityEvent {
29
+ email: string;
30
+ activityId: string;
31
+ timestamp?: Date;
32
+ data?: Record<string, any>;
33
+ }
34
+ /**
35
+ * List subscription
36
+ */
37
+ export interface ListSubscription {
38
+ email: string;
39
+ listId: string;
40
+ customFields?: Record<string, any>;
41
+ }
42
+ /**
43
+ * Journey segment
44
+ */
45
+ export interface JourneySegment {
46
+ id: string;
47
+ name: string;
48
+ description?: string;
49
+ conditions: any;
50
+ }
51
+ /**
52
+ * Journey/Campaign
53
+ */
54
+ export interface Journey {
55
+ id: string;
56
+ name: string;
57
+ status: 'draft' | 'active' | 'paused' | 'completed';
58
+ type?: 'email' | 'sms' | 'multi-channel';
59
+ enrolledCount?: number;
60
+ completedCount?: number;
61
+ }
62
+ /**
63
+ * Journey response
64
+ */
65
+ export interface JourneyResponse {
66
+ success: boolean;
67
+ message?: string;
68
+ contactIds?: string[];
69
+ errors?: Array<{
70
+ email: string;
71
+ error: string;
72
+ }>;
73
+ }
74
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;IACpD,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,eAAe,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ"}
package/lib/types.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Journey Connector Types
4
+ * Marketing automation and customer journey management
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@xbg.solutions/utils-journey-connector",
3
+ "version": "1.0.0",
4
+ "description": "Customer journey integration with Ortto",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "build:watch": "tsc --watch",
13
+ "clean": "rm -rf lib",
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "dependencies": {
17
+ "@xbg/utils-logger": "^1.0.0",
18
+ "axios": "^1.6.2"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.11.0",
22
+ "typescript": "^5.3.3"
23
+ },
24
+ "engines": {
25
+ "node": "22"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ }
30
+ }