@walkeros/server-destination-datamanager 0.0.0-next-20251219153324

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.
@@ -0,0 +1,218 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer } from '@walkeros/server-core';
3
+ import { OAuth2Client } from 'google-auth-library';
4
+
5
+ interface Settings {
6
+ /**
7
+ * Service account credentials (client_email + private_key)
8
+ * Recommended for serverless environments (AWS Lambda, Docker, etc.)
9
+ */
10
+ credentials?: {
11
+ client_email: string;
12
+ private_key: string;
13
+ };
14
+ /**
15
+ * Path to service account JSON file
16
+ * For local development or environments with filesystem access
17
+ */
18
+ keyFilename?: string;
19
+ /**
20
+ * OAuth scopes for Data Manager API
21
+ * @default ['https://www.googleapis.com/auth/datamanager']
22
+ */
23
+ scopes?: string[];
24
+ /** Array of destination accounts and conversion actions/user lists */
25
+ destinations: Destination[];
26
+ /** Event source for all events. Defaults to WEB if not specified */
27
+ eventSource?: EventSource;
28
+ /** Maximum number of events to batch before sending (max 2000) */
29
+ batchSize?: number;
30
+ /** Time in milliseconds to wait before auto-flushing batch */
31
+ batchInterval?: number;
32
+ /** If true, validate request without ingestion (testing mode) */
33
+ validateOnly?: boolean;
34
+ /** Override API endpoint (for testing) */
35
+ url?: string;
36
+ /** Request-level consent for all events */
37
+ consent?: Consent;
38
+ /** Test event code for debugging (optional) */
39
+ testEventCode?: string;
40
+ /** Guided helpers: User data mapping (applies to all events) */
41
+ userData?: Mapping$1.Map;
42
+ /** Guided helper: First-party user ID */
43
+ userId?: Mapping$1.Value;
44
+ /** Guided helper: GA4 client ID */
45
+ clientId?: Mapping$1.Value;
46
+ /** Guided helper: Privacy-safe attribution (Google's sessionAttributes) */
47
+ sessionAttributes?: Mapping$1.Value;
48
+ /** Consent mapping: Map consent field to adUserData (string = field name, boolean = static value) */
49
+ consentAdUserData?: string | boolean;
50
+ /** Consent mapping: Map consent field to adPersonalization (string = field name, boolean = static value) */
51
+ consentAdPersonalization?: string | boolean;
52
+ }
53
+ interface Mapping {
54
+ gclid?: Mapping$1.Value;
55
+ gbraid?: Mapping$1.Value;
56
+ wbraid?: Mapping$1.Value;
57
+ sessionAttributes?: Mapping$1.Value;
58
+ }
59
+ interface Env extends DestinationServer.Env {
60
+ fetch?: typeof fetch;
61
+ authClient?: OAuth2Client | null;
62
+ }
63
+ type InitSettings = Partial<Settings>;
64
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
65
+ type Config = {
66
+ settings: Settings;
67
+ } & DestinationServer.Config<Types>;
68
+ type Rule = Mapping$1.Rule<Mapping>;
69
+ /**
70
+ * Destination account and product identifier
71
+ * https://developers.google.com/data-manager/api/reference/rest/v1/Destination
72
+ */
73
+ interface Destination {
74
+ /** Reference identifier for this destination */
75
+ reference?: string;
76
+ /** Login account (account initiating the request) */
77
+ loginAccount?: ProductAccount;
78
+ /** Linked account (child account linked to login account) */
79
+ linkedAccount?: ProductAccount;
80
+ /** Operating account (account where data is sent) */
81
+ operatingAccount?: ProductAccount;
82
+ /** Product-specific destination ID (conversion action or user list) */
83
+ productDestinationId?: string;
84
+ }
85
+ /**
86
+ * Product account information
87
+ */
88
+ interface ProductAccount {
89
+ /** Account ID (e.g., "123-456-7890" for Google Ads) */
90
+ accountId: string;
91
+ /** Type of account */
92
+ accountType: AccountType;
93
+ }
94
+ type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
95
+ type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
96
+ /**
97
+ * Consent for Digital Markets Act (DMA) compliance
98
+ * https://developers.google.com/data-manager/api/devguides/concepts/dma
99
+ */
100
+ interface Consent {
101
+ /** Consent for data collection and use */
102
+ adUserData?: ConsentStatus;
103
+ /** Consent for ad personalization */
104
+ adPersonalization?: ConsentStatus;
105
+ }
106
+ type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
107
+
108
+ /**
109
+ * AWS Lambda / Serverless Configuration
110
+ * Uses inline credentials from environment variables
111
+ * Best for: AWS Lambda, Docker, Kubernetes, any serverless environment
112
+ */
113
+ declare const awsLambda: Config;
114
+ /**
115
+ * GCP Cloud Functions / Cloud Run Configuration
116
+ * Uses Application Default Credentials (ADC) - no explicit auth config needed
117
+ * Best for: Google Cloud Functions, Cloud Run, GCE, GKE
118
+ */
119
+ declare const gcpCloudFunctions: Config;
120
+ /**
121
+ * Local Development Configuration
122
+ * Uses service account JSON file
123
+ * Best for: Local development, testing
124
+ */
125
+ declare const localDevelopment: Config;
126
+ /**
127
+ * Docker / Kubernetes Configuration
128
+ * Uses ADC via GOOGLE_APPLICATION_CREDENTIALS environment variable
129
+ * Best for: Docker containers, Kubernetes pods
130
+ *
131
+ * Setup:
132
+ * 1. Mount service account JSON as secret/configmap
133
+ * 2. Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
134
+ * 3. ADC will automatically use it
135
+ */
136
+ declare const dockerKubernetes: Config;
137
+ /**
138
+ * Custom Scopes Configuration
139
+ * For specific use cases requiring different OAuth scopes
140
+ */
141
+ declare const customScopes: Config;
142
+
143
+ declare const auth_awsLambda: typeof awsLambda;
144
+ declare const auth_customScopes: typeof customScopes;
145
+ declare const auth_dockerKubernetes: typeof dockerKubernetes;
146
+ declare const auth_gcpCloudFunctions: typeof gcpCloudFunctions;
147
+ declare const auth_localDevelopment: typeof localDevelopment;
148
+ declare namespace auth {
149
+ export { auth_awsLambda as awsLambda, auth_customScopes as customScopes, auth_dockerKubernetes as dockerKubernetes, auth_gcpCloudFunctions as gcpCloudFunctions, auth_localDevelopment as localDevelopment };
150
+ }
151
+
152
+ /**
153
+ * Minimal configuration for Google Data Manager with inline credentials
154
+ */
155
+ declare const minimal: Config;
156
+ /**
157
+ * Complete configuration with all options
158
+ */
159
+ declare const complete: Config;
160
+ /**
161
+ * GA4-specific configuration using Application Default Credentials
162
+ */
163
+ declare const ga4: Config;
164
+ /**
165
+ * Debug configuration with logging enabled using keyFilename
166
+ */
167
+ declare const debug: Config;
168
+
169
+ declare const basic_complete: typeof complete;
170
+ declare const basic_debug: typeof debug;
171
+ declare const basic_ga4: typeof ga4;
172
+ declare const basic_minimal: typeof minimal;
173
+ declare namespace basic {
174
+ export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
175
+ }
176
+
177
+ /**
178
+ * Purchase event mapping for Google Ads conversion
179
+ */
180
+ declare const Purchase: Rule;
181
+ /**
182
+ * Lead event mapping
183
+ */
184
+ declare const Lead: Rule;
185
+ /**
186
+ * Page view mapping for GA4
187
+ */
188
+ declare const PageView: Rule;
189
+ /**
190
+ * Complete mapping configuration
191
+ */
192
+ declare const mapping: {
193
+ order: {
194
+ complete: Rule;
195
+ };
196
+ lead: {
197
+ submit: Rule;
198
+ };
199
+ page: {
200
+ view: Rule;
201
+ };
202
+ };
203
+ /**
204
+ * User data mapping configuration
205
+ * Maps walkerOS user properties to Data Manager user identifiers
206
+ */
207
+ declare const userDataMapping: Config;
208
+
209
+ declare const mapping$1_Lead: typeof Lead;
210
+ declare const mapping$1_PageView: typeof PageView;
211
+ declare const mapping$1_Purchase: typeof Purchase;
212
+ declare const mapping$1_mapping: typeof mapping;
213
+ declare const mapping$1_userDataMapping: typeof userDataMapping;
214
+ declare namespace mapping$1 {
215
+ export { mapping$1_Lead as Lead, mapping$1_PageView as PageView, mapping$1_Purchase as Purchase, mapping$1_mapping as mapping, mapping$1_userDataMapping as userDataMapping };
216
+ }
217
+
218
+ export { auth, basic, mapping$1 as mapping };
@@ -0,0 +1,218 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer } from '@walkeros/server-core';
3
+ import { OAuth2Client } from 'google-auth-library';
4
+
5
+ interface Settings {
6
+ /**
7
+ * Service account credentials (client_email + private_key)
8
+ * Recommended for serverless environments (AWS Lambda, Docker, etc.)
9
+ */
10
+ credentials?: {
11
+ client_email: string;
12
+ private_key: string;
13
+ };
14
+ /**
15
+ * Path to service account JSON file
16
+ * For local development or environments with filesystem access
17
+ */
18
+ keyFilename?: string;
19
+ /**
20
+ * OAuth scopes for Data Manager API
21
+ * @default ['https://www.googleapis.com/auth/datamanager']
22
+ */
23
+ scopes?: string[];
24
+ /** Array of destination accounts and conversion actions/user lists */
25
+ destinations: Destination[];
26
+ /** Event source for all events. Defaults to WEB if not specified */
27
+ eventSource?: EventSource;
28
+ /** Maximum number of events to batch before sending (max 2000) */
29
+ batchSize?: number;
30
+ /** Time in milliseconds to wait before auto-flushing batch */
31
+ batchInterval?: number;
32
+ /** If true, validate request without ingestion (testing mode) */
33
+ validateOnly?: boolean;
34
+ /** Override API endpoint (for testing) */
35
+ url?: string;
36
+ /** Request-level consent for all events */
37
+ consent?: Consent;
38
+ /** Test event code for debugging (optional) */
39
+ testEventCode?: string;
40
+ /** Guided helpers: User data mapping (applies to all events) */
41
+ userData?: Mapping$1.Map;
42
+ /** Guided helper: First-party user ID */
43
+ userId?: Mapping$1.Value;
44
+ /** Guided helper: GA4 client ID */
45
+ clientId?: Mapping$1.Value;
46
+ /** Guided helper: Privacy-safe attribution (Google's sessionAttributes) */
47
+ sessionAttributes?: Mapping$1.Value;
48
+ /** Consent mapping: Map consent field to adUserData (string = field name, boolean = static value) */
49
+ consentAdUserData?: string | boolean;
50
+ /** Consent mapping: Map consent field to adPersonalization (string = field name, boolean = static value) */
51
+ consentAdPersonalization?: string | boolean;
52
+ }
53
+ interface Mapping {
54
+ gclid?: Mapping$1.Value;
55
+ gbraid?: Mapping$1.Value;
56
+ wbraid?: Mapping$1.Value;
57
+ sessionAttributes?: Mapping$1.Value;
58
+ }
59
+ interface Env extends DestinationServer.Env {
60
+ fetch?: typeof fetch;
61
+ authClient?: OAuth2Client | null;
62
+ }
63
+ type InitSettings = Partial<Settings>;
64
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
65
+ type Config = {
66
+ settings: Settings;
67
+ } & DestinationServer.Config<Types>;
68
+ type Rule = Mapping$1.Rule<Mapping>;
69
+ /**
70
+ * Destination account and product identifier
71
+ * https://developers.google.com/data-manager/api/reference/rest/v1/Destination
72
+ */
73
+ interface Destination {
74
+ /** Reference identifier for this destination */
75
+ reference?: string;
76
+ /** Login account (account initiating the request) */
77
+ loginAccount?: ProductAccount;
78
+ /** Linked account (child account linked to login account) */
79
+ linkedAccount?: ProductAccount;
80
+ /** Operating account (account where data is sent) */
81
+ operatingAccount?: ProductAccount;
82
+ /** Product-specific destination ID (conversion action or user list) */
83
+ productDestinationId?: string;
84
+ }
85
+ /**
86
+ * Product account information
87
+ */
88
+ interface ProductAccount {
89
+ /** Account ID (e.g., "123-456-7890" for Google Ads) */
90
+ accountId: string;
91
+ /** Type of account */
92
+ accountType: AccountType;
93
+ }
94
+ type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
95
+ type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
96
+ /**
97
+ * Consent for Digital Markets Act (DMA) compliance
98
+ * https://developers.google.com/data-manager/api/devguides/concepts/dma
99
+ */
100
+ interface Consent {
101
+ /** Consent for data collection and use */
102
+ adUserData?: ConsentStatus;
103
+ /** Consent for ad personalization */
104
+ adPersonalization?: ConsentStatus;
105
+ }
106
+ type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
107
+
108
+ /**
109
+ * AWS Lambda / Serverless Configuration
110
+ * Uses inline credentials from environment variables
111
+ * Best for: AWS Lambda, Docker, Kubernetes, any serverless environment
112
+ */
113
+ declare const awsLambda: Config;
114
+ /**
115
+ * GCP Cloud Functions / Cloud Run Configuration
116
+ * Uses Application Default Credentials (ADC) - no explicit auth config needed
117
+ * Best for: Google Cloud Functions, Cloud Run, GCE, GKE
118
+ */
119
+ declare const gcpCloudFunctions: Config;
120
+ /**
121
+ * Local Development Configuration
122
+ * Uses service account JSON file
123
+ * Best for: Local development, testing
124
+ */
125
+ declare const localDevelopment: Config;
126
+ /**
127
+ * Docker / Kubernetes Configuration
128
+ * Uses ADC via GOOGLE_APPLICATION_CREDENTIALS environment variable
129
+ * Best for: Docker containers, Kubernetes pods
130
+ *
131
+ * Setup:
132
+ * 1. Mount service account JSON as secret/configmap
133
+ * 2. Set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
134
+ * 3. ADC will automatically use it
135
+ */
136
+ declare const dockerKubernetes: Config;
137
+ /**
138
+ * Custom Scopes Configuration
139
+ * For specific use cases requiring different OAuth scopes
140
+ */
141
+ declare const customScopes: Config;
142
+
143
+ declare const auth_awsLambda: typeof awsLambda;
144
+ declare const auth_customScopes: typeof customScopes;
145
+ declare const auth_dockerKubernetes: typeof dockerKubernetes;
146
+ declare const auth_gcpCloudFunctions: typeof gcpCloudFunctions;
147
+ declare const auth_localDevelopment: typeof localDevelopment;
148
+ declare namespace auth {
149
+ export { auth_awsLambda as awsLambda, auth_customScopes as customScopes, auth_dockerKubernetes as dockerKubernetes, auth_gcpCloudFunctions as gcpCloudFunctions, auth_localDevelopment as localDevelopment };
150
+ }
151
+
152
+ /**
153
+ * Minimal configuration for Google Data Manager with inline credentials
154
+ */
155
+ declare const minimal: Config;
156
+ /**
157
+ * Complete configuration with all options
158
+ */
159
+ declare const complete: Config;
160
+ /**
161
+ * GA4-specific configuration using Application Default Credentials
162
+ */
163
+ declare const ga4: Config;
164
+ /**
165
+ * Debug configuration with logging enabled using keyFilename
166
+ */
167
+ declare const debug: Config;
168
+
169
+ declare const basic_complete: typeof complete;
170
+ declare const basic_debug: typeof debug;
171
+ declare const basic_ga4: typeof ga4;
172
+ declare const basic_minimal: typeof minimal;
173
+ declare namespace basic {
174
+ export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
175
+ }
176
+
177
+ /**
178
+ * Purchase event mapping for Google Ads conversion
179
+ */
180
+ declare const Purchase: Rule;
181
+ /**
182
+ * Lead event mapping
183
+ */
184
+ declare const Lead: Rule;
185
+ /**
186
+ * Page view mapping for GA4
187
+ */
188
+ declare const PageView: Rule;
189
+ /**
190
+ * Complete mapping configuration
191
+ */
192
+ declare const mapping: {
193
+ order: {
194
+ complete: Rule;
195
+ };
196
+ lead: {
197
+ submit: Rule;
198
+ };
199
+ page: {
200
+ view: Rule;
201
+ };
202
+ };
203
+ /**
204
+ * User data mapping configuration
205
+ * Maps walkerOS user properties to Data Manager user identifiers
206
+ */
207
+ declare const userDataMapping: Config;
208
+
209
+ declare const mapping$1_Lead: typeof Lead;
210
+ declare const mapping$1_PageView: typeof PageView;
211
+ declare const mapping$1_Purchase: typeof Purchase;
212
+ declare const mapping$1_mapping: typeof mapping;
213
+ declare const mapping$1_userDataMapping: typeof userDataMapping;
214
+ declare namespace mapping$1 {
215
+ export { mapping$1_Lead as Lead, mapping$1_PageView as PageView, mapping$1_Purchase as Purchase, mapping$1_mapping as mapping, mapping$1_userDataMapping as userDataMapping };
216
+ }
217
+
218
+ export { auth, basic, mapping$1 as mapping };