@walkeros/server-destination-datamanager 0.4.0 → 0.4.2
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 +186 -41
- package/dist/dev.d.mts +111 -43
- package/dist/dev.d.ts +111 -43
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +105 -40
- package/dist/examples/index.d.ts +105 -40
- package/dist/examples/index.js +184 -99
- package/dist/examples/index.mjs +183 -99
- package/dist/index.d.mts +127 -34
- package/dist/index.d.ts +127 -34
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/schemas.d.mts +4 -3
- package/dist/schemas.d.ts +4 -3
- package/dist/schemas.js +1 -1
- package/dist/schemas.js.map +1 -1
- package/dist/schemas.mjs +1 -1
- package/dist/schemas.mjs.map +1 -1
- package/package.json +7 -6
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
|
|
2
2
|
import { DestinationServer } from '@walkeros/server-core';
|
|
3
|
-
|
|
4
|
-
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
3
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
5
4
|
|
|
6
5
|
interface Settings {
|
|
7
|
-
/**
|
|
8
|
-
|
|
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[];
|
|
9
24
|
/** Array of destination accounts and conversion actions/user lists */
|
|
10
25
|
destinations: Destination[];
|
|
11
|
-
/**
|
|
26
|
+
/** Event source for all events. Defaults to WEB if not specified */
|
|
12
27
|
eventSource?: EventSource;
|
|
13
28
|
/** Maximum number of events to batch before sending (max 2000) */
|
|
14
29
|
batchSize?: number;
|
|
@@ -22,8 +37,6 @@ interface Settings {
|
|
|
22
37
|
consent?: Consent;
|
|
23
38
|
/** Test event code for debugging (optional) */
|
|
24
39
|
testEventCode?: string;
|
|
25
|
-
/** Log level for debugging (optional) */
|
|
26
|
-
logLevel?: LogLevel;
|
|
27
40
|
/** Guided helpers: User data mapping (applies to all events) */
|
|
28
41
|
userData?: Mapping$1.Map;
|
|
29
42
|
/** Guided helper: First-party user ID */
|
|
@@ -45,8 +58,10 @@ interface Mapping {
|
|
|
45
58
|
}
|
|
46
59
|
interface Env extends DestinationServer.Env {
|
|
47
60
|
fetch?: typeof fetch;
|
|
61
|
+
authClient?: OAuth2Client | null;
|
|
48
62
|
}
|
|
49
|
-
type
|
|
63
|
+
type InitSettings = Partial<Settings>;
|
|
64
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
50
65
|
type Config = {
|
|
51
66
|
settings: Settings;
|
|
52
67
|
} & DestinationServer.Config<Types>;
|
|
@@ -56,21 +71,27 @@ type Rule = Mapping$1.Rule<Mapping>;
|
|
|
56
71
|
* https://developers.google.com/data-manager/api/reference/rest/v1/Destination
|
|
57
72
|
*/
|
|
58
73
|
interface Destination {
|
|
59
|
-
/**
|
|
60
|
-
|
|
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;
|
|
61
82
|
/** Product-specific destination ID (conversion action or user list) */
|
|
62
|
-
productDestinationId
|
|
83
|
+
productDestinationId?: string;
|
|
63
84
|
}
|
|
64
85
|
/**
|
|
65
|
-
*
|
|
86
|
+
* Product account information
|
|
66
87
|
*/
|
|
67
|
-
interface
|
|
88
|
+
interface ProductAccount {
|
|
68
89
|
/** Account ID (e.g., "123-456-7890" for Google Ads) */
|
|
69
90
|
accountId: string;
|
|
70
91
|
/** Type of account */
|
|
71
92
|
accountType: AccountType;
|
|
72
93
|
}
|
|
73
|
-
type AccountType = 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY';
|
|
94
|
+
type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
|
|
74
95
|
type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
|
|
75
96
|
/**
|
|
76
97
|
* Consent for Digital Markets Act (DMA) compliance
|
|
@@ -84,6 +105,75 @@ interface Consent {
|
|
|
84
105
|
}
|
|
85
106
|
type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
|
|
86
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
|
+
|
|
87
177
|
/**
|
|
88
178
|
* Purchase event mapping for Google Ads conversion
|
|
89
179
|
*/
|
|
@@ -125,29 +215,4 @@ declare namespace mapping$1 {
|
|
|
125
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 };
|
|
126
216
|
}
|
|
127
217
|
|
|
128
|
-
|
|
129
|
-
* Minimal configuration for Google Data Manager
|
|
130
|
-
*/
|
|
131
|
-
declare const minimal: Config;
|
|
132
|
-
/**
|
|
133
|
-
* Complete configuration with all options
|
|
134
|
-
*/
|
|
135
|
-
declare const complete: Config;
|
|
136
|
-
/**
|
|
137
|
-
* GA4-specific configuration
|
|
138
|
-
*/
|
|
139
|
-
declare const ga4: Config;
|
|
140
|
-
/**
|
|
141
|
-
* Debug configuration with logging enabled
|
|
142
|
-
*/
|
|
143
|
-
declare const debug: Config;
|
|
144
|
-
|
|
145
|
-
declare const basic_complete: typeof complete;
|
|
146
|
-
declare const basic_debug: typeof debug;
|
|
147
|
-
declare const basic_ga4: typeof ga4;
|
|
148
|
-
declare const basic_minimal: typeof minimal;
|
|
149
|
-
declare namespace basic {
|
|
150
|
-
export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export { basic, mapping$1 as mapping };
|
|
218
|
+
export { auth, basic, mapping$1 as mapping };
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
|
|
2
2
|
import { DestinationServer } from '@walkeros/server-core';
|
|
3
|
-
|
|
4
|
-
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
3
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
5
4
|
|
|
6
5
|
interface Settings {
|
|
7
|
-
/**
|
|
8
|
-
|
|
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[];
|
|
9
24
|
/** Array of destination accounts and conversion actions/user lists */
|
|
10
25
|
destinations: Destination[];
|
|
11
|
-
/**
|
|
26
|
+
/** Event source for all events. Defaults to WEB if not specified */
|
|
12
27
|
eventSource?: EventSource;
|
|
13
28
|
/** Maximum number of events to batch before sending (max 2000) */
|
|
14
29
|
batchSize?: number;
|
|
@@ -22,8 +37,6 @@ interface Settings {
|
|
|
22
37
|
consent?: Consent;
|
|
23
38
|
/** Test event code for debugging (optional) */
|
|
24
39
|
testEventCode?: string;
|
|
25
|
-
/** Log level for debugging (optional) */
|
|
26
|
-
logLevel?: LogLevel;
|
|
27
40
|
/** Guided helpers: User data mapping (applies to all events) */
|
|
28
41
|
userData?: Mapping$1.Map;
|
|
29
42
|
/** Guided helper: First-party user ID */
|
|
@@ -45,8 +58,10 @@ interface Mapping {
|
|
|
45
58
|
}
|
|
46
59
|
interface Env extends DestinationServer.Env {
|
|
47
60
|
fetch?: typeof fetch;
|
|
61
|
+
authClient?: OAuth2Client | null;
|
|
48
62
|
}
|
|
49
|
-
type
|
|
63
|
+
type InitSettings = Partial<Settings>;
|
|
64
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
50
65
|
type Config = {
|
|
51
66
|
settings: Settings;
|
|
52
67
|
} & DestinationServer.Config<Types>;
|
|
@@ -56,21 +71,27 @@ type Rule = Mapping$1.Rule<Mapping>;
|
|
|
56
71
|
* https://developers.google.com/data-manager/api/reference/rest/v1/Destination
|
|
57
72
|
*/
|
|
58
73
|
interface Destination {
|
|
59
|
-
/**
|
|
60
|
-
|
|
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;
|
|
61
82
|
/** Product-specific destination ID (conversion action or user list) */
|
|
62
|
-
productDestinationId
|
|
83
|
+
productDestinationId?: string;
|
|
63
84
|
}
|
|
64
85
|
/**
|
|
65
|
-
*
|
|
86
|
+
* Product account information
|
|
66
87
|
*/
|
|
67
|
-
interface
|
|
88
|
+
interface ProductAccount {
|
|
68
89
|
/** Account ID (e.g., "123-456-7890" for Google Ads) */
|
|
69
90
|
accountId: string;
|
|
70
91
|
/** Type of account */
|
|
71
92
|
accountType: AccountType;
|
|
72
93
|
}
|
|
73
|
-
type AccountType = 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY';
|
|
94
|
+
type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
|
|
74
95
|
type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
|
|
75
96
|
/**
|
|
76
97
|
* Consent for Digital Markets Act (DMA) compliance
|
|
@@ -84,6 +105,75 @@ interface Consent {
|
|
|
84
105
|
}
|
|
85
106
|
type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
|
|
86
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
|
+
|
|
87
177
|
/**
|
|
88
178
|
* Purchase event mapping for Google Ads conversion
|
|
89
179
|
*/
|
|
@@ -125,29 +215,4 @@ declare namespace mapping$1 {
|
|
|
125
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 };
|
|
126
216
|
}
|
|
127
217
|
|
|
128
|
-
|
|
129
|
-
* Minimal configuration for Google Data Manager
|
|
130
|
-
*/
|
|
131
|
-
declare const minimal: Config;
|
|
132
|
-
/**
|
|
133
|
-
* Complete configuration with all options
|
|
134
|
-
*/
|
|
135
|
-
declare const complete: Config;
|
|
136
|
-
/**
|
|
137
|
-
* GA4-specific configuration
|
|
138
|
-
*/
|
|
139
|
-
declare const ga4: Config;
|
|
140
|
-
/**
|
|
141
|
-
* Debug configuration with logging enabled
|
|
142
|
-
*/
|
|
143
|
-
declare const debug: Config;
|
|
144
|
-
|
|
145
|
-
declare const basic_complete: typeof complete;
|
|
146
|
-
declare const basic_debug: typeof debug;
|
|
147
|
-
declare const basic_ga4: typeof ga4;
|
|
148
|
-
declare const basic_minimal: typeof minimal;
|
|
149
|
-
declare namespace basic {
|
|
150
|
-
export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export { basic, mapping$1 as mapping };
|
|
218
|
+
export { auth, basic, mapping$1 as mapping };
|