@walkeros/web-source-cmp-usercentrics 0.1.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.
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/examples/index.ts
21
+ var examples_exports = {};
22
+ __export(examples_exports, {
23
+ createMockElbFn: () => createMockElbFn,
24
+ fullConsent: () => fullConsent,
25
+ fullConsentCustomMapped: () => fullConsentCustomMapped,
26
+ fullConsentMapped: () => fullConsentMapped,
27
+ fullConsentUpperCase: () => fullConsentUpperCase,
28
+ implicitConsent: () => implicitConsent,
29
+ minimalConsent: () => minimalConsent,
30
+ minimalConsentMapped: () => minimalConsentMapped,
31
+ nonConsentEvent: () => nonConsentEvent,
32
+ noopLogger: () => noopLogger,
33
+ partialConsent: () => partialConsent,
34
+ partialConsentMapped: () => partialConsentMapped,
35
+ serviceLevelConsent: () => serviceLevelConsent,
36
+ serviceLevelMapped: () => serviceLevelMapped
37
+ });
38
+ module.exports = __toCommonJS(examples_exports);
39
+
40
+ // src/examples/inputs.ts
41
+ var fullConsent = {
42
+ event: "consent_status",
43
+ type: "explicit",
44
+ action: "onAcceptAllServices",
45
+ ucCategory: {
46
+ essential: true,
47
+ functional: true,
48
+ marketing: true
49
+ },
50
+ "Google Analytics": true,
51
+ "Google Ads Remarketing": true
52
+ };
53
+ var partialConsent = {
54
+ event: "consent_status",
55
+ type: "explicit",
56
+ action: "onUpdateServices",
57
+ ucCategory: {
58
+ essential: true,
59
+ functional: true,
60
+ marketing: false
61
+ },
62
+ "Google Analytics": true,
63
+ "Google Ads Remarketing": false
64
+ };
65
+ var minimalConsent = {
66
+ event: "consent_status",
67
+ type: "explicit",
68
+ action: "onDenyAllServices",
69
+ ucCategory: {
70
+ essential: true,
71
+ functional: false,
72
+ marketing: false
73
+ },
74
+ "Google Analytics": false,
75
+ "Google Ads Remarketing": false
76
+ };
77
+ var implicitConsent = {
78
+ event: "consent_status",
79
+ type: "implicit",
80
+ ucCategory: {
81
+ essential: true,
82
+ functional: false,
83
+ marketing: false
84
+ },
85
+ "Google Analytics": false,
86
+ "Google Ads Remarketing": false
87
+ };
88
+ var fullConsentUpperCase = {
89
+ event: "consent_status",
90
+ type: "EXPLICIT",
91
+ action: "onAcceptAllServices",
92
+ ucCategory: {
93
+ essential: true,
94
+ functional: true,
95
+ marketing: true
96
+ }
97
+ };
98
+ var serviceLevelConsent = {
99
+ event: "consent_status",
100
+ type: "explicit",
101
+ action: "onUpdateServices",
102
+ ucCategory: {
103
+ essential: true,
104
+ functional: "partial",
105
+ // Non-boolean indicates mixed service choices
106
+ marketing: "partial"
107
+ },
108
+ "Google Analytics": true,
109
+ "Google Ads Remarketing": false,
110
+ Hotjar: true
111
+ };
112
+ var nonConsentEvent = {
113
+ event: "other_event",
114
+ type: "explicit"
115
+ };
116
+
117
+ // src/examples/outputs.ts
118
+ var fullConsentMapped = {
119
+ essential: true,
120
+ functional: true,
121
+ marketing: true
122
+ };
123
+ var partialConsentMapped = {
124
+ essential: true,
125
+ functional: true,
126
+ marketing: false
127
+ };
128
+ var minimalConsentMapped = {
129
+ essential: true,
130
+ functional: false,
131
+ marketing: false
132
+ };
133
+ var fullConsentCustomMapped = {
134
+ functional: true,
135
+ marketing: true
136
+ };
137
+ var serviceLevelMapped = {
138
+ essential: true,
139
+ google_analytics: true,
140
+ google_ads_remarketing: false,
141
+ hotjar: true
142
+ };
143
+
144
+ // src/examples/env.ts
145
+ var noop = () => {
146
+ };
147
+ var createMockElbFn = () => {
148
+ const fn = (() => Promise.resolve({
149
+ ok: true
150
+ }));
151
+ return fn;
152
+ };
153
+ var noopLogger = {
154
+ error: noop,
155
+ info: noop,
156
+ debug: noop,
157
+ throw: (message) => {
158
+ throw typeof message === "string" ? new Error(message) : message;
159
+ },
160
+ scope: () => noopLogger
161
+ };
162
+ // Annotate the CommonJS export names for ESM import in node:
163
+ 0 && (module.exports = {
164
+ createMockElbFn,
165
+ fullConsent,
166
+ fullConsentCustomMapped,
167
+ fullConsentMapped,
168
+ fullConsentUpperCase,
169
+ implicitConsent,
170
+ minimalConsent,
171
+ minimalConsentMapped,
172
+ nonConsentEvent,
173
+ noopLogger,
174
+ partialConsent,
175
+ partialConsentMapped,
176
+ serviceLevelConsent,
177
+ serviceLevelMapped
178
+ });
@@ -0,0 +1,138 @@
1
+ // src/examples/inputs.ts
2
+ var fullConsent = {
3
+ event: "consent_status",
4
+ type: "explicit",
5
+ action: "onAcceptAllServices",
6
+ ucCategory: {
7
+ essential: true,
8
+ functional: true,
9
+ marketing: true
10
+ },
11
+ "Google Analytics": true,
12
+ "Google Ads Remarketing": true
13
+ };
14
+ var partialConsent = {
15
+ event: "consent_status",
16
+ type: "explicit",
17
+ action: "onUpdateServices",
18
+ ucCategory: {
19
+ essential: true,
20
+ functional: true,
21
+ marketing: false
22
+ },
23
+ "Google Analytics": true,
24
+ "Google Ads Remarketing": false
25
+ };
26
+ var minimalConsent = {
27
+ event: "consent_status",
28
+ type: "explicit",
29
+ action: "onDenyAllServices",
30
+ ucCategory: {
31
+ essential: true,
32
+ functional: false,
33
+ marketing: false
34
+ },
35
+ "Google Analytics": false,
36
+ "Google Ads Remarketing": false
37
+ };
38
+ var implicitConsent = {
39
+ event: "consent_status",
40
+ type: "implicit",
41
+ ucCategory: {
42
+ essential: true,
43
+ functional: false,
44
+ marketing: false
45
+ },
46
+ "Google Analytics": false,
47
+ "Google Ads Remarketing": false
48
+ };
49
+ var fullConsentUpperCase = {
50
+ event: "consent_status",
51
+ type: "EXPLICIT",
52
+ action: "onAcceptAllServices",
53
+ ucCategory: {
54
+ essential: true,
55
+ functional: true,
56
+ marketing: true
57
+ }
58
+ };
59
+ var serviceLevelConsent = {
60
+ event: "consent_status",
61
+ type: "explicit",
62
+ action: "onUpdateServices",
63
+ ucCategory: {
64
+ essential: true,
65
+ functional: "partial",
66
+ // Non-boolean indicates mixed service choices
67
+ marketing: "partial"
68
+ },
69
+ "Google Analytics": true,
70
+ "Google Ads Remarketing": false,
71
+ Hotjar: true
72
+ };
73
+ var nonConsentEvent = {
74
+ event: "other_event",
75
+ type: "explicit"
76
+ };
77
+
78
+ // src/examples/outputs.ts
79
+ var fullConsentMapped = {
80
+ essential: true,
81
+ functional: true,
82
+ marketing: true
83
+ };
84
+ var partialConsentMapped = {
85
+ essential: true,
86
+ functional: true,
87
+ marketing: false
88
+ };
89
+ var minimalConsentMapped = {
90
+ essential: true,
91
+ functional: false,
92
+ marketing: false
93
+ };
94
+ var fullConsentCustomMapped = {
95
+ functional: true,
96
+ marketing: true
97
+ };
98
+ var serviceLevelMapped = {
99
+ essential: true,
100
+ google_analytics: true,
101
+ google_ads_remarketing: false,
102
+ hotjar: true
103
+ };
104
+
105
+ // src/examples/env.ts
106
+ var noop = () => {
107
+ };
108
+ var createMockElbFn = () => {
109
+ const fn = (() => Promise.resolve({
110
+ ok: true
111
+ }));
112
+ return fn;
113
+ };
114
+ var noopLogger = {
115
+ error: noop,
116
+ info: noop,
117
+ debug: noop,
118
+ throw: (message) => {
119
+ throw typeof message === "string" ? new Error(message) : message;
120
+ },
121
+ scope: () => noopLogger
122
+ };
123
+ export {
124
+ createMockElbFn,
125
+ fullConsent,
126
+ fullConsentCustomMapped,
127
+ fullConsentMapped,
128
+ fullConsentUpperCase,
129
+ implicitConsent,
130
+ minimalConsent,
131
+ minimalConsentMapped,
132
+ nonConsentEvent,
133
+ noopLogger,
134
+ partialConsent,
135
+ partialConsentMapped,
136
+ serviceLevelConsent,
137
+ serviceLevelMapped
138
+ };
@@ -0,0 +1 @@
1
+ "use strict";var SourceUsercentrics=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(a,{SourceUsercentrics:()=>l,createMockElbFn:()=>k,default:()=>_,fullConsent:()=>r,fullConsentCustomMapped:()=>m,fullConsentMapped:()=>y,fullConsentUpperCase:()=>g,implicitConsent:()=>u,minimalConsent:()=>c,minimalConsentMapped:()=>d,nonConsentEvent:()=>v,noopLogger:()=>w,partialConsent:()=>s,partialConsentMapped:()=>f,serviceLevelConsent:()=>p,serviceLevelMapped:()=>C,sourceUsercentrics:()=>O});var i,l={},r={event:"consent_status",type:"explicit",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0},"Google Analytics":!0,"Google Ads Remarketing":!0},s={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:!0,marketing:!1},"Google Analytics":!0,"Google Ads Remarketing":!1},c={event:"consent_status",type:"explicit",action:"onDenyAllServices",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},u={event:"consent_status",type:"implicit",ucCategory:{essential:!0,functional:!1,marketing:!1},"Google Analytics":!1,"Google Ads Remarketing":!1},g={event:"consent_status",type:"EXPLICIT",action:"onAcceptAllServices",ucCategory:{essential:!0,functional:!0,marketing:!0}},p={event:"consent_status",type:"explicit",action:"onUpdateServices",ucCategory:{essential:!0,functional:"partial",marketing:"partial"},"Google Analytics":!0,"Google Ads Remarketing":!1,Hotjar:!0},v={event:"other_event",type:"explicit"},y={essential:!0,functional:!0,marketing:!0},f={essential:!0,functional:!0,marketing:!1},d={essential:!0,functional:!1,marketing:!1},m={functional:!0,marketing:!0},C={essential:!0,google_analytics:!0,google_ads_remarketing:!1,hotjar:!0},b=()=>{},k=()=>()=>Promise.resolve({ok:!0}),w={error:b,info:b,debug:b,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>w},A=["action","event","type","ucCategory"],O=async e=>{var t,n,o,a,i,l,r,s;const{config:c,env:u}=e,{elb:g}=u,p=null!=(t=u.window)?t:void 0!==globalThis.window?globalThis.window:void 0,v={eventName:null!=(o=null==(n=null==c?void 0:c.settings)?void 0:n.eventName)?o:"ucEvent",categoryMap:null!=(i=null==(a=null==c?void 0:c.settings)?void 0:a.categoryMap)?i:{},explicitOnly:null==(r=null==(l=null==c?void 0:c.settings)?void 0:l.explicitOnly)||r},y={settings:v};let f;if(p){const e=e=>Object.values(e).every(e=>"boolean"==typeof e),t=t=>{const n={};return t.ucCategory&&e(t.ucCategory)?Object.entries(t.ucCategory).forEach(([e,t])=>{var o,a;if("boolean"!=typeof t)return;const i=null!=(a=null==(o=v.categoryMap)?void 0:o[e])?a:e;n[i]=n[i]||t}):(t.ucCategory&&Object.entries(t.ucCategory).forEach(([e,t])=>{var o,a;if("boolean"==typeof t){const i=null!=(a=null==(o=v.categoryMap)?void 0:o[e])?a:e;n[i]=n[i]||t}}),Object.entries(t).forEach(([e,t])=>{if(A.includes(e))return;if("boolean"!=typeof t)return;const o=e.toLowerCase().replace(/ /g,"_");n[o]=t})),n},n=e=>{var n;if("consent_status"!==e.event)return;if(v.explicitOnly&&"explicit"!==(null==(n=e.type)?void 0:n.toLowerCase()))return;const o=t(e);Object.keys(o).length>0&&g("walker consent",o)},o=null!=(s=v.eventName)?s:"ucEvent";f=e=>{const t=e;t.detail&&n(t.detail)},p.addEventListener(o,f)}return{type:"usercentrics",config:y,push:g,destroy:async()=>{var e;if(p&&f){const t=null!=(e=v.eventName)?e:"ucEvent";p.removeEventListener(t,f)}}}},_=O;return i=a,((a,i,l,r)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of n(i))o.call(a,s)||s===l||e(a,s,{get:()=>i[s],enumerable:!(r=t(i,s))||r.enumerable});return a})(e({},"__esModule",{value:!0}),i)})();
@@ -0,0 +1,206 @@
1
+ import { Source, Elb, WalkerOS, Logger } from '@walkeros/core';
2
+
3
+ /**
4
+ * Usercentrics consent event detail structure.
5
+ *
6
+ * Fired as event.detail on the configured window event (e.g. 'ucEvent').
7
+ * Contains both category-level (ucCategory) and service-level consent.
8
+ */
9
+ interface UsercentricsEventDetail {
10
+ /** Always 'consent_status' for consent events */
11
+ event: string;
12
+ /** 'explicit' when user actively chose, 'implicit' for page-load defaults (casing may vary) */
13
+ type: string;
14
+ /** Action taken: 'onAcceptAllServices', 'onDenyAllServices', 'onUpdateServices' */
15
+ action?: string;
16
+ /** Category-level consent booleans (e.g. { marketing: true, functional: false }) */
17
+ ucCategory?: Record<string, boolean | unknown>;
18
+ /** Service-level consent as top-level keys (e.g. 'Google Analytics': true) */
19
+ [service: string]: unknown;
20
+ }
21
+ declare global {
22
+ interface WindowEventMap {
23
+ ucEvent: CustomEvent<UsercentricsEventDetail>;
24
+ }
25
+ }
26
+ /**
27
+ * Settings for Usercentrics source
28
+ */
29
+ interface Settings {
30
+ /**
31
+ * Window event name to listen for.
32
+ * Configured in Usercentrics admin under Implementation > Data Layer & Events.
33
+ * Can also be set to 'UC_SDK_EVENT' for the built-in Browser SDK event.
34
+ *
35
+ * Default: 'ucEvent'
36
+ */
37
+ eventName?: string;
38
+ /**
39
+ * Map Usercentrics categories to walkerOS consent groups.
40
+ * Keys: Usercentrics category names (from ucCategory)
41
+ * Values: walkerOS consent group names
42
+ *
43
+ * Applied in both group-level and service-level consent modes.
44
+ * When multiple source categories map to the same group, OR logic applies:
45
+ * if ANY source category is true, the target group is true.
46
+ *
47
+ * Default: {} (pass through category names as-is)
48
+ */
49
+ categoryMap?: Record<string, string>;
50
+ /**
51
+ * Only process explicit consent (user made a choice).
52
+ * When true: Ignores events where type !== 'explicit'
53
+ * When false: Processes any consent_status event including implicit/defaults
54
+ *
55
+ * Default: true
56
+ */
57
+ explicitOnly?: boolean;
58
+ }
59
+ /**
60
+ * User input settings (all optional)
61
+ */
62
+ type InitSettings = Partial<Settings>;
63
+ /**
64
+ * No mapping configuration for this source
65
+ */
66
+ interface Mapping {
67
+ }
68
+ /**
69
+ * Push function type - uses elb for consent commands
70
+ */
71
+ type Push = Elb.Fn;
72
+ /**
73
+ * Environment interface for Usercentrics source
74
+ */
75
+ interface Env extends Source.BaseEnv {
76
+ window?: Window & typeof globalThis;
77
+ }
78
+ /**
79
+ * Types bundle for Usercentrics source
80
+ */
81
+ type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;
82
+ /**
83
+ * Config type alias
84
+ */
85
+ type Config = Source.Config<Types>;
86
+
87
+ type index_Config = Config;
88
+ type index_Env = Env;
89
+ type index_InitSettings = InitSettings;
90
+ type index_Mapping = Mapping;
91
+ type index_Push = Push;
92
+ type index_Settings = Settings;
93
+ type index_Types = Types;
94
+ type index_UsercentricsEventDetail = UsercentricsEventDetail;
95
+ declare namespace index {
96
+ export type { index_Config as Config, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Push as Push, index_Settings as Settings, index_Types as Types, index_UsercentricsEventDetail as UsercentricsEventDetail };
97
+ }
98
+
99
+ /**
100
+ * Example Usercentrics consent event detail inputs.
101
+ *
102
+ * These represent real event.detail payloads from Usercentrics CMP.
103
+ */
104
+ /**
105
+ * Full consent - user accepted all categories (explicit)
106
+ */
107
+ declare const fullConsent: UsercentricsEventDetail;
108
+ /**
109
+ * Partial consent - user accepted only essential and functional (explicit)
110
+ */
111
+ declare const partialConsent: UsercentricsEventDetail;
112
+ /**
113
+ * Minimal consent - user denied everything except essential (explicit)
114
+ */
115
+ declare const minimalConsent: UsercentricsEventDetail;
116
+ /**
117
+ * Implicit consent - page load with default consent state
118
+ * (not an explicit user choice)
119
+ */
120
+ declare const implicitConsent: UsercentricsEventDetail;
121
+ /**
122
+ * Explicit consent with uppercase type field (Usercentrics docs are
123
+ * inconsistent about casing - some show 'EXPLICIT', others 'explicit')
124
+ */
125
+ declare const fullConsentUpperCase: UsercentricsEventDetail;
126
+ /**
127
+ * Service-level consent - ucCategory has mixed types (non-boolean values
128
+ * indicate individual service-level choice rather than group-level)
129
+ */
130
+ declare const serviceLevelConsent: UsercentricsEventDetail;
131
+ /**
132
+ * Non-consent event (should be ignored)
133
+ */
134
+ declare const nonConsentEvent: UsercentricsEventDetail;
135
+
136
+ /**
137
+ * Expected walkerOS consent outputs.
138
+ *
139
+ * These represent the consent state after parsing Usercentrics event details
140
+ * with no category mapping configured (pass-through).
141
+ */
142
+ /**
143
+ * Full consent - all categories true (group-level)
144
+ */
145
+ declare const fullConsentMapped: WalkerOS.Consent;
146
+ /**
147
+ * Partial consent - essential and functional true, marketing false
148
+ */
149
+ declare const partialConsentMapped: WalkerOS.Consent;
150
+ /**
151
+ * Minimal consent - only essential true
152
+ */
153
+ declare const minimalConsentMapped: WalkerOS.Consent;
154
+ /**
155
+ * Full consent with custom category mapping applied
156
+ * (essential->functional, functional->functional, marketing->marketing)
157
+ */
158
+ declare const fullConsentCustomMapped: WalkerOS.Consent;
159
+ /**
160
+ * Service-level consent - individual service booleans + boolean ucCategory entries
161
+ * (services normalized: lowercase, spaces to underscores)
162
+ * (ucCategory boolean entries mapped through categoryMap)
163
+ */
164
+ declare const serviceLevelMapped: WalkerOS.Consent;
165
+
166
+ /**
167
+ * Create a properly typed elb/push function mock
168
+ */
169
+ declare const createMockElbFn: () => Elb.Fn;
170
+ /**
171
+ * Simple no-op logger for demo purposes
172
+ */
173
+ declare const noopLogger: Logger.Instance;
174
+
175
+ /**
176
+ * Usercentrics consent management source for walkerOS.
177
+ *
178
+ * This source listens to Usercentrics CMP events and translates
179
+ * consent states to walkerOS consent commands.
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * import { sourceUsercentrics } from '@walkeros/web-source-cmp-usercentrics';
184
+ *
185
+ * await startFlow({
186
+ * sources: {
187
+ * consent: {
188
+ * code: sourceUsercentrics,
189
+ * config: {
190
+ * settings: {
191
+ * eventName: 'ucEvent',
192
+ * categoryMap: {
193
+ * essential: 'functional',
194
+ * functional: 'functional',
195
+ * marketing: 'marketing',
196
+ * },
197
+ * },
198
+ * },
199
+ * },
200
+ * },
201
+ * });
202
+ * ```
203
+ */
204
+ declare const sourceUsercentrics: Source.Init<Types>;
205
+
206
+ export { index as SourceUsercentrics, createMockElbFn, sourceUsercentrics as default, fullConsent, fullConsentCustomMapped, fullConsentMapped, fullConsentUpperCase, implicitConsent, minimalConsent, minimalConsentMapped, nonConsentEvent, noopLogger, partialConsent, partialConsentMapped, serviceLevelConsent, serviceLevelMapped, sourceUsercentrics };