@walkeros/web-source-cmp-cookiefirst 4.7.0-next-1790245733116 → 4.7.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/CHANGELOG.md +25 -15
- package/dist/dev.d.mts +11 -18
- package/dist/dev.d.ts +11 -18
- 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 +11 -18
- package/dist/examples/index.d.ts +11 -18
- package/dist/examples/index.js +16 -6
- package/dist/examples/index.mjs +16 -6
- package/dist/walkerOS.json +5 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
# @walkeros/web-source-cmp-cookiefirst
|
|
2
2
|
|
|
3
|
-
## 4.7.0
|
|
3
|
+
## 4.7.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 64b06de: Simulating the CookieFirst source now records one `walker consent`
|
|
8
|
+
per example, as a browser does. The example trigger no longer replays
|
|
9
|
+
`cf_init` after the initial consent read. Runtime behaviour is unchanged.
|
|
10
|
+
- Updated dependencies [786a860]
|
|
11
|
+
- Updated dependencies [74821ed]
|
|
8
12
|
- Updated dependencies [06b498a]
|
|
9
|
-
- Updated dependencies [
|
|
10
|
-
- Updated dependencies [
|
|
11
|
-
- Updated dependencies [
|
|
13
|
+
- Updated dependencies [7e5e3de]
|
|
14
|
+
- Updated dependencies [b9668bf]
|
|
15
|
+
- Updated dependencies [74821ed]
|
|
16
|
+
- Updated dependencies [64b06de]
|
|
17
|
+
- Updated dependencies [4b4937f]
|
|
18
|
+
- Updated dependencies [74821ed]
|
|
19
|
+
- Updated dependencies [74821ed]
|
|
20
|
+
- Updated dependencies [74821ed]
|
|
12
21
|
- Updated dependencies [06b498a]
|
|
13
|
-
- Updated dependencies [
|
|
14
|
-
- Updated dependencies [
|
|
15
|
-
- Updated dependencies [
|
|
16
|
-
- Updated dependencies [
|
|
17
|
-
- Updated dependencies [
|
|
18
|
-
- Updated dependencies [
|
|
19
|
-
- Updated dependencies [
|
|
20
|
-
- Updated dependencies [
|
|
21
|
-
|
|
22
|
-
- @walkeros/collector@4.7.0
|
|
22
|
+
- Updated dependencies [74821ed]
|
|
23
|
+
- Updated dependencies [74821ed]
|
|
24
|
+
- Updated dependencies [74821ed]
|
|
25
|
+
- Updated dependencies [74821ed]
|
|
26
|
+
- Updated dependencies [74821ed]
|
|
27
|
+
- Updated dependencies [e860006]
|
|
28
|
+
- Updated dependencies [74821ed]
|
|
29
|
+
- Updated dependencies [74821ed]
|
|
30
|
+
- Updated dependencies [4f89234]
|
|
31
|
+
- @walkeros/collector@4.7.0
|
|
32
|
+
- @walkeros/core@4.7.0
|
|
23
33
|
|
|
24
34
|
## 4.6.1
|
|
25
35
|
|
package/dist/dev.d.mts
CHANGED
|
@@ -13,7 +13,7 @@ declare module '@walkeros/core' {
|
|
|
13
13
|
/**
|
|
14
14
|
* CookieFirst consent object structure
|
|
15
15
|
*/
|
|
16
|
-
interface CookieFirstConsent
|
|
16
|
+
interface CookieFirstConsent {
|
|
17
17
|
necessary?: boolean;
|
|
18
18
|
functional?: boolean;
|
|
19
19
|
performance?: boolean;
|
|
@@ -24,7 +24,7 @@ interface CookieFirstConsent$1 {
|
|
|
24
24
|
* CookieFirst global API interface
|
|
25
25
|
*/
|
|
26
26
|
interface CookieFirstAPI {
|
|
27
|
-
consent: CookieFirstConsent
|
|
27
|
+
consent: CookieFirstConsent | null;
|
|
28
28
|
}
|
|
29
29
|
declare global {
|
|
30
30
|
interface Window {
|
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
}
|
|
34
34
|
interface WindowEventMap {
|
|
35
35
|
cf_init: Event;
|
|
36
|
-
cf_consent: CustomEvent<CookieFirstConsent
|
|
36
|
+
cf_consent: CustomEvent<CookieFirstConsent>;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -45,28 +45,28 @@ declare global {
|
|
|
45
45
|
/**
|
|
46
46
|
* Full consent - user accepted all categories
|
|
47
47
|
*/
|
|
48
|
-
declare const fullConsent$1: CookieFirstConsent
|
|
48
|
+
declare const fullConsent$1: CookieFirstConsent;
|
|
49
49
|
/**
|
|
50
50
|
* Partial consent - user accepted only necessary and functional
|
|
51
51
|
*/
|
|
52
|
-
declare const partialConsent$1: CookieFirstConsent
|
|
52
|
+
declare const partialConsent$1: CookieFirstConsent;
|
|
53
53
|
/**
|
|
54
54
|
* Minimal consent - user accepted only necessary (required)
|
|
55
55
|
*/
|
|
56
|
-
declare const minimalConsent: CookieFirstConsent
|
|
56
|
+
declare const minimalConsent: CookieFirstConsent;
|
|
57
57
|
/**
|
|
58
58
|
* No consent - user hasn't made a choice yet
|
|
59
59
|
* CookieFirst returns null when no explicit choice has been made
|
|
60
60
|
*/
|
|
61
|
-
declare const noConsent: CookieFirstConsent
|
|
61
|
+
declare const noConsent: CookieFirstConsent | null;
|
|
62
62
|
/**
|
|
63
63
|
* Analytics only - user accepted performance tracking
|
|
64
64
|
*/
|
|
65
|
-
declare const analyticsOnlyConsent: CookieFirstConsent
|
|
65
|
+
declare const analyticsOnlyConsent: CookieFirstConsent;
|
|
66
66
|
/**
|
|
67
67
|
* Marketing only - user accepted advertising
|
|
68
68
|
*/
|
|
69
|
-
declare const marketingOnlyConsent: CookieFirstConsent
|
|
69
|
+
declare const marketingOnlyConsent: CookieFirstConsent;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Expected walkerOS consent outputs.
|
|
@@ -117,11 +117,11 @@ interface CookieFirstEnv extends Source.BaseEnv {
|
|
|
117
117
|
/**
|
|
118
118
|
* Create a mock CookieFirst API object
|
|
119
119
|
*/
|
|
120
|
-
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent
|
|
120
|
+
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent | null) => CookieFirstAPI;
|
|
121
121
|
/**
|
|
122
122
|
* Create a mock window object with CookieFirst
|
|
123
123
|
*/
|
|
124
|
-
declare const createMockWindow: (consent?: CookieFirstConsent
|
|
124
|
+
declare const createMockWindow: (consent?: CookieFirstConsent | null) => Partial<Window> & {
|
|
125
125
|
CookieFirst: CookieFirstAPI;
|
|
126
126
|
};
|
|
127
127
|
/**
|
|
@@ -145,13 +145,6 @@ declare namespace step {
|
|
|
145
145
|
export { step_categoryMapOverride as categoryMapOverride, step_cfInitDetection as cfInitDetection, step_fullConsent as fullConsent, step_partialConsent as partialConsent };
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
interface CookieFirstConsent {
|
|
149
|
-
necessary?: boolean;
|
|
150
|
-
functional?: boolean;
|
|
151
|
-
performance?: boolean;
|
|
152
|
-
advertising?: boolean;
|
|
153
|
-
[category: string]: boolean | undefined;
|
|
154
|
-
}
|
|
155
148
|
declare const createTrigger: Trigger.CreateFn<CookieFirstConsent, void>;
|
|
156
149
|
/** Sets window.CookieFirst.consent before source init (legacy). */
|
|
157
150
|
declare const trigger: (input: unknown, env: Record<string, unknown>) => void;
|
package/dist/dev.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare module '@walkeros/core' {
|
|
|
13
13
|
/**
|
|
14
14
|
* CookieFirst consent object structure
|
|
15
15
|
*/
|
|
16
|
-
interface CookieFirstConsent
|
|
16
|
+
interface CookieFirstConsent {
|
|
17
17
|
necessary?: boolean;
|
|
18
18
|
functional?: boolean;
|
|
19
19
|
performance?: boolean;
|
|
@@ -24,7 +24,7 @@ interface CookieFirstConsent$1 {
|
|
|
24
24
|
* CookieFirst global API interface
|
|
25
25
|
*/
|
|
26
26
|
interface CookieFirstAPI {
|
|
27
|
-
consent: CookieFirstConsent
|
|
27
|
+
consent: CookieFirstConsent | null;
|
|
28
28
|
}
|
|
29
29
|
declare global {
|
|
30
30
|
interface Window {
|
|
@@ -33,7 +33,7 @@ declare global {
|
|
|
33
33
|
}
|
|
34
34
|
interface WindowEventMap {
|
|
35
35
|
cf_init: Event;
|
|
36
|
-
cf_consent: CustomEvent<CookieFirstConsent
|
|
36
|
+
cf_consent: CustomEvent<CookieFirstConsent>;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -45,28 +45,28 @@ declare global {
|
|
|
45
45
|
/**
|
|
46
46
|
* Full consent - user accepted all categories
|
|
47
47
|
*/
|
|
48
|
-
declare const fullConsent$1: CookieFirstConsent
|
|
48
|
+
declare const fullConsent$1: CookieFirstConsent;
|
|
49
49
|
/**
|
|
50
50
|
* Partial consent - user accepted only necessary and functional
|
|
51
51
|
*/
|
|
52
|
-
declare const partialConsent$1: CookieFirstConsent
|
|
52
|
+
declare const partialConsent$1: CookieFirstConsent;
|
|
53
53
|
/**
|
|
54
54
|
* Minimal consent - user accepted only necessary (required)
|
|
55
55
|
*/
|
|
56
|
-
declare const minimalConsent: CookieFirstConsent
|
|
56
|
+
declare const minimalConsent: CookieFirstConsent;
|
|
57
57
|
/**
|
|
58
58
|
* No consent - user hasn't made a choice yet
|
|
59
59
|
* CookieFirst returns null when no explicit choice has been made
|
|
60
60
|
*/
|
|
61
|
-
declare const noConsent: CookieFirstConsent
|
|
61
|
+
declare const noConsent: CookieFirstConsent | null;
|
|
62
62
|
/**
|
|
63
63
|
* Analytics only - user accepted performance tracking
|
|
64
64
|
*/
|
|
65
|
-
declare const analyticsOnlyConsent: CookieFirstConsent
|
|
65
|
+
declare const analyticsOnlyConsent: CookieFirstConsent;
|
|
66
66
|
/**
|
|
67
67
|
* Marketing only - user accepted advertising
|
|
68
68
|
*/
|
|
69
|
-
declare const marketingOnlyConsent: CookieFirstConsent
|
|
69
|
+
declare const marketingOnlyConsent: CookieFirstConsent;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Expected walkerOS consent outputs.
|
|
@@ -117,11 +117,11 @@ interface CookieFirstEnv extends Source.BaseEnv {
|
|
|
117
117
|
/**
|
|
118
118
|
* Create a mock CookieFirst API object
|
|
119
119
|
*/
|
|
120
|
-
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent
|
|
120
|
+
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent | null) => CookieFirstAPI;
|
|
121
121
|
/**
|
|
122
122
|
* Create a mock window object with CookieFirst
|
|
123
123
|
*/
|
|
124
|
-
declare const createMockWindow: (consent?: CookieFirstConsent
|
|
124
|
+
declare const createMockWindow: (consent?: CookieFirstConsent | null) => Partial<Window> & {
|
|
125
125
|
CookieFirst: CookieFirstAPI;
|
|
126
126
|
};
|
|
127
127
|
/**
|
|
@@ -145,13 +145,6 @@ declare namespace step {
|
|
|
145
145
|
export { step_categoryMapOverride as categoryMapOverride, step_cfInitDetection as cfInitDetection, step_fullConsent as fullConsent, step_partialConsent as partialConsent };
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
interface CookieFirstConsent {
|
|
149
|
-
necessary?: boolean;
|
|
150
|
-
functional?: boolean;
|
|
151
|
-
performance?: boolean;
|
|
152
|
-
advertising?: boolean;
|
|
153
|
-
[category: string]: boolean | undefined;
|
|
154
|
-
}
|
|
155
148
|
declare const createTrigger: Trigger.CreateFn<CookieFirstConsent, void>;
|
|
156
149
|
/** Sets window.CookieFirst.consent before source init (legacy). */
|
|
157
150
|
declare const trigger: (input: unknown, env: Record<string, unknown>) => void;
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},i={};a(i,{examples:()=>s,schemas:()=>
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},i={};a(i,{examples:()=>s,schemas:()=>A}),module.exports=(e=i,((e,a,i,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let c of r(a))o.call(e,c)||c===i||t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};a(s,{analyticsOnlyConsent:()=>u,analyticsOnlyMapped:()=>k,createMockCookieFirstAPI:()=>h,createMockElbFn:()=>C,createMockWindow:()=>M,createTrigger:()=>_,fullConsent:()=>c,fullConsentMapped:()=>f,marketingOnlyConsent:()=>d,marketingOnlyMapped:()=>v,minimalConsent:()=>p,minimalConsentMapped:()=>y,mockEnv:()=>O,noConsent:()=>g,noopLogger:()=>b,partialConsent:()=>l,partialConsentMapped:()=>m,step:()=>F,trigger:()=>x});var c={necessary:!0,functional:!0,performance:!0,advertising:!0},l={necessary:!0,functional:!0,performance:!1,advertising:!1},p={necessary:!0,functional:!1,performance:!1,advertising:!1},g=null,u={necessary:!0,functional:!1,performance:!0,advertising:!1},d={necessary:!0,functional:!1,performance:!1,advertising:!0},f={functional:!0,analytics:!0,marketing:!0},m={functional:!0,analytics:!1,marketing:!1},y={functional:!0,analytics:!1,marketing:!1},k={functional:!0,analytics:!0,marketing:!1},v={functional:!0,analytics:!1,marketing:!0},w=()=>{},C=()=>()=>Promise.resolve({ok:!0}),b={error:w,warn:w,info:w,debug:w,throw:e=>{throw"string"==typeof e?new Error(e):e},json:w,scope:()=>b},h=(e=null)=>({consent:e}),M=(e=null)=>({CookieFirst:h(e),addEventListener:w,removeEventListener:w}),O={get push(){return C()},get command(){return C()},get elb(){return C()},get window(){return M()},logger:b},F={};a(F,{categoryMapOverride:()=>E,cfInitDetection:()=>z,fullConsent:()=>j,partialConsent:()=>P});var j={title:"Full consent",description:"CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.",trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!0,advertising:!0},out:[["elb","walker consent",{functional:!0,analytics:!0,marketing:!0}]]},P={title:"Partial consent",description:"A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.",trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!1,advertising:!1},out:[["elb","walker consent",{functional:!0,analytics:!1,marketing:!1}]]},E={title:"Category map override",description:"Custom categoryMap remaps performance to statistics instead of analytics",trigger:{type:"consent"},in:{necessary:!0,functional:!1,performance:!0,advertising:!1},mapping:{settings:{categoryMap:{performance:"statistics"}}},out:[["elb","walker consent",{functional:!0,statistics:!0,marketing:!1}]]},z={title:"cf_init detection",description:"CMP detected via cf_init CustomEvent (primary detection path)",trigger:{type:"consent"},in:{necessary:!0,functional:!1,performance:!1,advertising:!0},out:[["elb","walker consent",{functional:!0,analytics:!1,marketing:!0}]]},S=require("@walkeros/collector"),_=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{var r;if(window.CookieFirst={consent:n},!t){const n=await(0,S.startFlow)({...e,run:null==(r=e.run)||r});return void(t={collector:n.collector,elb:n.elb})}window.dispatchEvent(new CustomEvent("cf_consent",{detail:n}))}}},x=(e,t)=>{const n=t.window;var r;"object"==typeof(r=e)&&null!==r&&!Array.isArray(r)&&Object.values(r).every(e=>void 0===e||"boolean"==typeof e)&&function(e){return"object"==typeof e&&null!==e&&"addEventListener"in e}(n)&&(n.CookieFirst={consent:e})};var A={};a(A,{SettingsSchema:()=>q,settings:()=>I});var D=require("@walkeros/core/dev"),L=require("@walkeros/core/dev"),q=L.z.object({categoryMap:L.z.record(L.z.string(),L.z.string()).describe("Map the CMP's consent categories (keys) to walkerOS consent groups (values).").optional(),explicitOnly:L.z.boolean().describe("Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.").optional(),globalName:L.z.string().describe("Custom name for the CookieFirst global on window. Default: 'CookieFirst'.").optional()}).meta({id:"CookieFirstSettings",title:"Settings",description:"Settings for the CookieFirst CMP source."}),I=(0,D.zodToSchema)(q);//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/trigger.ts","../src/schemas/index.ts","../src/schemas/settings.ts"],"sourcesContent":["/**\n * Development exports for testing and tooling.\n */\nexport * as examples from './examples';\nexport * as schemas from './schemas';\n","/**\n * CookieFirst source examples for testing and documentation.\n */\n\nexport * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { CookieFirstConsent } from '../types';\n\n/**\n * Example CookieFirst consent inputs.\n *\n * These represent real consent states from CookieFirst CMP.\n */\n\n/**\n * Full consent - user accepted all categories\n */\nexport const fullConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n};\n\n/**\n * Partial consent - user accepted only necessary and functional\n */\nexport const partialConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n};\n\n/**\n * Minimal consent - user accepted only necessary (required)\n */\nexport const minimalConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: false,\n};\n\n/**\n * No consent - user hasn't made a choice yet\n * CookieFirst returns null when no explicit choice has been made\n */\nexport const noConsent: CookieFirstConsent | null = null;\n\n/**\n * Analytics only - user accepted performance tracking\n */\nexport const analyticsOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n};\n\n/**\n * Marketing only - user accepted advertising\n */\nexport const marketingOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after mapping CookieFirst categories\n * to walkerOS consent groups using the default category map.\n */\n\n/**\n * Full consent mapped to walkerOS groups\n * (necessary + functional → functional, performance → analytics, advertising → marketing)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n\n/**\n * Partial consent mapped to walkerOS groups\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Minimal consent mapped to walkerOS groups\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Analytics only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const analyticsOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: false,\n};\n\n/**\n * Marketing only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const marketingOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: true,\n};\n","import type { Source, Elb, Logger } from '@walkeros/core';\nimport type { CookieFirstAPI, CookieFirstConsent } from '../types';\n\n/**\n * Example environment configurations for CookieFirst source testing.\n *\n * These provide mock structures for testing consent handling\n * without requiring a real browser environment.\n */\n\n// Simple no-op function for mocking\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock that returns a promise with PushResult\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n\n/**\n * Environment interface for CookieFirst source\n */\ninterface CookieFirstEnv extends Source.BaseEnv {\n window?: typeof window;\n}\n\n/**\n * Create a mock CookieFirst API object\n */\nexport const createMockCookieFirstAPI = (\n consent: CookieFirstConsent | null = null,\n): CookieFirstAPI => ({\n consent,\n});\n\n/**\n * Create a mock window object with CookieFirst\n */\nexport const createMockWindow = (\n consent: CookieFirstConsent | null = null,\n): Partial<Window> & { CookieFirst: CookieFirstAPI } => ({\n CookieFirst: createMockCookieFirstAPI(consent),\n addEventListener: noop,\n removeEventListener: noop,\n});\n\n/**\n * Standard mock environment for testing CookieFirst source\n *\n * Use this for testing consent handling without requiring\n * a real browser environment.\n */\nexport const mockEnv: CookieFirstEnv = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n get window() {\n return createMockWindow() as unknown as typeof window;\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: true,\n marketing: true,\n },\n ],\n ],\n};\n\nexport const partialConsent: Flow.StepExample = {\n title: 'Partial consent',\n description:\n 'A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n title: 'Category map override',\n description:\n 'Custom categoryMap remaps performance to statistics instead of analytics',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n },\n mapping: {\n settings: {\n categoryMap: {\n performance: 'statistics',\n },\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n statistics: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const cfInitDetection: Flow.StepExample = {\n title: 'cf_init detection',\n description: 'CMP detected via cf_init CustomEvent (primary detection path)',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: true,\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\ninterface CookieFirstConsent {\n necessary?: boolean;\n functional?: boolean;\n performance?: boolean;\n advertising?: boolean;\n [category: string]: boolean | undefined;\n}\n\nconst createTrigger: Trigger.CreateFn<CookieFirstConsent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<CookieFirstConsent, void> =\n () => async (content: CookieFirstConsent) => {\n // Pre-init: set CookieFirst global (source reads this during init)\n (window as unknown as Record<string, unknown>).CookieFirst = {\n consent: content,\n };\n\n // Lazy startFlow — source reads global + registers event listeners\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n }\n\n // Post-init: dispatch cf_init to trigger consent processing\n window.dispatchEvent(new Event('cf_init'));\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Sets window.CookieFirst.consent before source init (legacy). */\nconst trigger = (input: unknown, env: Record<string, unknown>): void => {\n if (!input || typeof input !== 'object') return;\n (env.window as Record<string, unknown>).CookieFirst = { consent: input };\n};\n\nexport { createTrigger, trigger };\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * CookieFirst source settings schema\n */\nexport const SettingsSchema = z\n .object({\n categoryMap: z\n .record(z.string(), z.string())\n .describe(\n \"Map the CMP's consent categories (keys) to walkerOS consent groups (values).\",\n )\n .optional(),\n\n explicitOnly: z\n .boolean()\n .describe(\n 'Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.',\n )\n .optional(),\n\n globalName: z\n .string()\n .describe(\n \"Custom name for the CookieFirst global on window. Default: 'CookieFirst'.\",\n )\n .optional(),\n })\n .meta({\n id: 'CookieFirstSettings',\n title: 'Settings',\n description: 'Settings for the CookieFirst CMP source.',\n });\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAkC;AAAA,EAC7C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAMO,IAAM,YAAuC;AAK7C,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;;;ACjDO,IAAM,oBAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,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AAO,YAAgC;AAjBjD;AAmBM,IAAC,OAA8C,cAAc;AAAA,MAC3D,SAAS;AAAA,IACX;AAGA,QAAI,CAAC,MAAM;AACT,YAAM,SAAS,UAAM,4BAAU,EAAE,GAAG,QAAQ,MAAK,YAAO,QAAP,YAAc,KAAK,CAAC;AACrE,aAAO,EAAE,WAAW,OAAO,WAAW,KAAK,OAAO,IAAI;AAAA,IACxD;AAGA,WAAO,cAAc,IAAI,MAAM,SAAS,CAAC;AAAA,EAC3C;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA,SAAAA;AAAA,EACF;AACF;AAGA,IAAM,UAAU,CAAC,OAAgB,QAAuC;AACtE,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,EAAC,IAAI,OAAmC,cAAc,EAAE,SAAS,MAAM;AACzE;;;AC7CA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAC,cAA4B;;;ACA5B,iBAAkB;AAKX,IAAM,iBAAiB,aAC3B,OAAO;AAAA,EACN,aAAa,aACV,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAC7B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,cAAc,aACX,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,YAAY,aACT,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC,EACA,KAAK;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf,CAAC;;;ADzBI,IAAM,eAAW,yBAAY,cAAc;","names":["fullConsent","partialConsent","trigger","import_dev"]}
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/trigger.ts","../src/schemas/index.ts","../src/schemas/settings.ts"],"sourcesContent":["/**\n * Development exports for testing and tooling.\n */\nexport * as examples from './examples';\nexport * as schemas from './schemas';\n","/**\n * CookieFirst source examples for testing and documentation.\n */\n\nexport * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { CookieFirstConsent } from '../types';\n\n/**\n * Example CookieFirst consent inputs.\n *\n * These represent real consent states from CookieFirst CMP.\n */\n\n/**\n * Full consent - user accepted all categories\n */\nexport const fullConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n};\n\n/**\n * Partial consent - user accepted only necessary and functional\n */\nexport const partialConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n};\n\n/**\n * Minimal consent - user accepted only necessary (required)\n */\nexport const minimalConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: false,\n};\n\n/**\n * No consent - user hasn't made a choice yet\n * CookieFirst returns null when no explicit choice has been made\n */\nexport const noConsent: CookieFirstConsent | null = null;\n\n/**\n * Analytics only - user accepted performance tracking\n */\nexport const analyticsOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n};\n\n/**\n * Marketing only - user accepted advertising\n */\nexport const marketingOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after mapping CookieFirst categories\n * to walkerOS consent groups using the default category map.\n */\n\n/**\n * Full consent mapped to walkerOS groups\n * (necessary + functional → functional, performance → analytics, advertising → marketing)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n\n/**\n * Partial consent mapped to walkerOS groups\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Minimal consent mapped to walkerOS groups\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Analytics only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const analyticsOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: false,\n};\n\n/**\n * Marketing only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const marketingOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: true,\n};\n","import type { Source, Elb, Logger } from '@walkeros/core';\nimport type { CookieFirstAPI, CookieFirstConsent } from '../types';\n\n/**\n * Example environment configurations for CookieFirst source testing.\n *\n * These provide mock structures for testing consent handling\n * without requiring a real browser environment.\n */\n\n// Simple no-op function for mocking\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock that returns a promise with PushResult\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n\n/**\n * Environment interface for CookieFirst source\n */\ninterface CookieFirstEnv extends Source.BaseEnv {\n window?: typeof window;\n}\n\n/**\n * Create a mock CookieFirst API object\n */\nexport const createMockCookieFirstAPI = (\n consent: CookieFirstConsent | null = null,\n): CookieFirstAPI => ({\n consent,\n});\n\n/**\n * Create a mock window object with CookieFirst\n */\nexport const createMockWindow = (\n consent: CookieFirstConsent | null = null,\n): Partial<Window> & { CookieFirst: CookieFirstAPI } => ({\n CookieFirst: createMockCookieFirstAPI(consent),\n addEventListener: noop,\n removeEventListener: noop,\n});\n\n/**\n * Standard mock environment for testing CookieFirst source\n *\n * Use this for testing consent handling without requiring\n * a real browser environment.\n */\nexport const mockEnv: CookieFirstEnv = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n get window() {\n return createMockWindow() as unknown as typeof window;\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: true,\n marketing: true,\n },\n ],\n ],\n};\n\nexport const partialConsent: Flow.StepExample = {\n title: 'Partial consent',\n description:\n 'A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n title: 'Category map override',\n description:\n 'Custom categoryMap remaps performance to statistics instead of analytics',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n },\n mapping: {\n settings: {\n categoryMap: {\n performance: 'statistics',\n },\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n statistics: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const cfInitDetection: Flow.StepExample = {\n title: 'cf_init detection',\n description: 'CMP detected via cf_init CustomEvent (primary detection path)',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: true,\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport type { CookieFirstConsent } from '../types';\n\nconst createTrigger: Trigger.CreateFn<CookieFirstConsent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<CookieFirstConsent, void> =\n () => async (content: CookieFirstConsent) => {\n // The banner keeps window.CookieFirst current.\n window.CookieFirst = { consent: content };\n\n // First call, the page load: the source reads the global at init and\n // emits once. No cf_init follows: in a browser it fires when the global\n // appears, so a page where the global is already set has seen it before\n // the source started. One page load emits one consent.\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n return;\n }\n\n // Later calls are a decision on the loaded page: CookieFirst announces\n // it with cf_consent, carrying the new consent.\n window.dispatchEvent(\n new CustomEvent<CookieFirstConsent>('cf_consent', { detail: content }),\n );\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Sets window.CookieFirst.consent before source init (legacy). */\nconst trigger = (input: unknown, env: Record<string, unknown>): void => {\n const win = env.window;\n if (!isConsent(input) || !isWindow(win)) return;\n win.CookieFirst = { consent: input };\n};\n\nfunction isWindow(value: unknown): value is Window {\n return (\n typeof value === 'object' && value !== null && 'addEventListener' in value\n );\n}\n\nfunction isConsent(value: unknown): value is CookieFirstConsent {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.values(value).every(\n (state) => state === undefined || typeof state === 'boolean',\n )\n );\n}\n\nexport { createTrigger, trigger };\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * CookieFirst source settings schema\n */\nexport const SettingsSchema = z\n .object({\n categoryMap: z\n .record(z.string(), z.string())\n .describe(\n \"Map the CMP's consent categories (keys) to walkerOS consent groups (values).\",\n )\n .optional(),\n\n explicitOnly: z\n .boolean()\n .describe(\n 'Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.',\n )\n .optional(),\n\n globalName: z\n .string()\n .describe(\n \"Custom name for the CookieFirst global on window. Default: 'CookieFirst'.\",\n )\n .optional(),\n })\n .meta({\n id: 'CookieFirstSettings',\n title: 'Settings',\n description: 'Settings for the CookieFirst CMP source.',\n });\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAkC;AAAA,EAC7C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAMO,IAAM,YAAuC;AAK7C,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;;;ACjDO,IAAM,oBAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,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aACT,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC,EACA,KAAK;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf,CAAC;;;ADzBI,IAAM,eAAW,yBAAY,cAAc;","names":["fullConsent","partialConsent","trigger","import_dev"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},n={};t(n,{analyticsOnlyConsent:()=>s,analyticsOnlyMapped:()=>
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},n={};t(n,{analyticsOnlyConsent:()=>s,analyticsOnlyMapped:()=>u,createMockCookieFirstAPI:()=>k,createMockElbFn:()=>f,createMockWindow:()=>v,createTrigger:()=>E,fullConsent:()=>r,fullConsentMapped:()=>l,marketingOnlyConsent:()=>c,marketingOnlyMapped:()=>m,minimalConsent:()=>o,minimalConsentMapped:()=>p,mockEnv:()=>w,noConsent:()=>i,noopLogger:()=>y,partialConsent:()=>a,partialConsentMapped:()=>g,step:()=>C,trigger:()=>P});var r={necessary:!0,functional:!0,performance:!0,advertising:!0},a={necessary:!0,functional:!0,performance:!1,advertising:!1},o={necessary:!0,functional:!1,performance:!1,advertising:!1},i=null,s={necessary:!0,functional:!1,performance:!0,advertising:!1},c={necessary:!0,functional:!1,performance:!1,advertising:!0},l={functional:!0,analytics:!0,marketing:!0},g={functional:!0,analytics:!1,marketing:!1},p={functional:!0,analytics:!1,marketing:!1},u={functional:!0,analytics:!0,marketing:!1},m={functional:!0,analytics:!1,marketing:!0},d=()=>{},f=()=>()=>Promise.resolve({ok:!0}),y={error:d,warn:d,info:d,debug:d,throw:e=>{throw"string"==typeof e?new Error(e):e},json:d,scope:()=>y},k=(e=null)=>({consent:e}),v=(e=null)=>({CookieFirst:k(e),addEventListener:d,removeEventListener:d}),w={get push(){return f()},get command(){return f()},get elb(){return f()},get window(){return v()},logger:y},C={};t(C,{categoryMapOverride:()=>h,cfInitDetection:()=>F,fullConsent:()=>b,partialConsent:()=>M});var b={title:"Full consent",description:"CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.",trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!0,advertising:!0},out:[["elb","walker consent",{functional:!0,analytics:!0,marketing:!0}]]},M={title:"Partial consent",description:"A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.",trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!1,advertising:!1},out:[["elb","walker consent",{functional:!0,analytics:!1,marketing:!1}]]},h={title:"Category map override",description:"Custom categoryMap remaps performance to statistics instead of analytics",trigger:{type:"consent"},in:{necessary:!0,functional:!1,performance:!0,advertising:!1},mapping:{settings:{categoryMap:{performance:"statistics"}}},out:[["elb","walker consent",{functional:!0,statistics:!0,marketing:!1}]]},F={title:"cf_init detection",description:"CMP detected via cf_init CustomEvent (primary detection path)",trigger:{type:"consent"},in:{necessary:!0,functional:!1,performance:!1,advertising:!0},out:[["elb","walker consent",{functional:!0,analytics:!1,marketing:!0}]]};import{startFlow as O}from"@walkeros/collector";var E=async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{var r;if(window.CookieFirst={consent:n},!t){const n=await O({...e,run:null==(r=e.run)||r});return void(t={collector:n.collector,elb:n.elb})}window.dispatchEvent(new CustomEvent("cf_consent",{detail:n}))}}},P=(e,t)=>{const n=t.window;var r;"object"==typeof(r=e)&&null!==r&&!Array.isArray(r)&&Object.values(r).every(e=>void 0===e||"boolean"==typeof e)&&function(e){return"object"==typeof e&&null!==e&&"addEventListener"in e}(n)&&(n.CookieFirst={consent:e})};var j={};t(j,{SettingsSchema:()=>A,settings:()=>L});import{zodToSchema as S}from"@walkeros/core/dev";import{z as x}from"@walkeros/core/dev";var A=x.object({categoryMap:x.record(x.string(),x.string()).describe("Map the CMP's consent categories (keys) to walkerOS consent groups (values).").optional(),explicitOnly:x.boolean().describe("Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.").optional(),globalName:x.string().describe("Custom name for the CookieFirst global on window. Default: 'CookieFirst'.").optional()}).meta({id:"CookieFirstSettings",title:"Settings",description:"Settings for the CookieFirst CMP source."}),L=S(A);export{n as examples,j as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/trigger.ts","../src/schemas/index.ts","../src/schemas/settings.ts"],"sourcesContent":["/**\n * CookieFirst source examples for testing and documentation.\n */\n\nexport * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { CookieFirstConsent } from '../types';\n\n/**\n * Example CookieFirst consent inputs.\n *\n * These represent real consent states from CookieFirst CMP.\n */\n\n/**\n * Full consent - user accepted all categories\n */\nexport const fullConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n};\n\n/**\n * Partial consent - user accepted only necessary and functional\n */\nexport const partialConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n};\n\n/**\n * Minimal consent - user accepted only necessary (required)\n */\nexport const minimalConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: false,\n};\n\n/**\n * No consent - user hasn't made a choice yet\n * CookieFirst returns null when no explicit choice has been made\n */\nexport const noConsent: CookieFirstConsent | null = null;\n\n/**\n * Analytics only - user accepted performance tracking\n */\nexport const analyticsOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n};\n\n/**\n * Marketing only - user accepted advertising\n */\nexport const marketingOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after mapping CookieFirst categories\n * to walkerOS consent groups using the default category map.\n */\n\n/**\n * Full consent mapped to walkerOS groups\n * (necessary + functional → functional, performance → analytics, advertising → marketing)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n\n/**\n * Partial consent mapped to walkerOS groups\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Minimal consent mapped to walkerOS groups\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Analytics only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const analyticsOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: false,\n};\n\n/**\n * Marketing only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const marketingOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: true,\n};\n","import type { Source, Elb, Logger } from '@walkeros/core';\nimport type { CookieFirstAPI, CookieFirstConsent } from '../types';\n\n/**\n * Example environment configurations for CookieFirst source testing.\n *\n * These provide mock structures for testing consent handling\n * without requiring a real browser environment.\n */\n\n// Simple no-op function for mocking\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock that returns a promise with PushResult\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n\n/**\n * Environment interface for CookieFirst source\n */\ninterface CookieFirstEnv extends Source.BaseEnv {\n window?: typeof window;\n}\n\n/**\n * Create a mock CookieFirst API object\n */\nexport const createMockCookieFirstAPI = (\n consent: CookieFirstConsent | null = null,\n): CookieFirstAPI => ({\n consent,\n});\n\n/**\n * Create a mock window object with CookieFirst\n */\nexport const createMockWindow = (\n consent: CookieFirstConsent | null = null,\n): Partial<Window> & { CookieFirst: CookieFirstAPI } => ({\n CookieFirst: createMockCookieFirstAPI(consent),\n addEventListener: noop,\n removeEventListener: noop,\n});\n\n/**\n * Standard mock environment for testing CookieFirst source\n *\n * Use this for testing consent handling without requiring\n * a real browser environment.\n */\nexport const mockEnv: CookieFirstEnv = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n get window() {\n return createMockWindow() as unknown as typeof window;\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: true,\n marketing: true,\n },\n ],\n ],\n};\n\nexport const partialConsent: Flow.StepExample = {\n title: 'Partial consent',\n description:\n 'A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n title: 'Category map override',\n description:\n 'Custom categoryMap remaps performance to statistics instead of analytics',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n },\n mapping: {\n settings: {\n categoryMap: {\n performance: 'statistics',\n },\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n statistics: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const cfInitDetection: Flow.StepExample = {\n title: 'cf_init detection',\n description: 'CMP detected via cf_init CustomEvent (primary detection path)',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: true,\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\ninterface CookieFirstConsent {\n necessary?: boolean;\n functional?: boolean;\n performance?: boolean;\n advertising?: boolean;\n [category: string]: boolean | undefined;\n}\n\nconst createTrigger: Trigger.CreateFn<CookieFirstConsent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<CookieFirstConsent, void> =\n () => async (content: CookieFirstConsent) => {\n // Pre-init: set CookieFirst global (source reads this during init)\n (window as unknown as Record<string, unknown>).CookieFirst = {\n consent: content,\n };\n\n // Lazy startFlow — source reads global + registers event listeners\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n }\n\n // Post-init: dispatch cf_init to trigger consent processing\n window.dispatchEvent(new Event('cf_init'));\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Sets window.CookieFirst.consent before source init (legacy). */\nconst trigger = (input: unknown, env: Record<string, unknown>): void => {\n if (!input || typeof input !== 'object') return;\n (env.window as Record<string, unknown>).CookieFirst = { consent: input };\n};\n\nexport { createTrigger, trigger };\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * CookieFirst source settings schema\n */\nexport const SettingsSchema = z\n .object({\n categoryMap: z\n .record(z.string(), z.string())\n .describe(\n \"Map the CMP's consent categories (keys) to walkerOS consent groups (values).\",\n )\n .optional(),\n\n explicitOnly: z\n .boolean()\n .describe(\n 'Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.',\n )\n .optional(),\n\n globalName: z\n .string()\n .describe(\n \"Custom name for the CookieFirst global on window. Default: 'CookieFirst'.\",\n )\n .optional(),\n })\n .meta({\n id: 'CookieFirstSettings',\n title: 'Settings',\n description: 'Settings for the CookieFirst CMP source.',\n });\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAkC;AAAA,EAC7C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAMO,IAAM,YAAuC;AAK7C,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;;;ACjDO,IAAM,oBAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EAC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../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/trigger.ts","../src/schemas/index.ts","../src/schemas/settings.ts"],"sourcesContent":["/**\n * CookieFirst source examples for testing and documentation.\n */\n\nexport * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { CookieFirstConsent } from '../types';\n\n/**\n * Example CookieFirst consent inputs.\n *\n * These represent real consent states from CookieFirst CMP.\n */\n\n/**\n * Full consent - user accepted all categories\n */\nexport const fullConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n};\n\n/**\n * Partial consent - user accepted only necessary and functional\n */\nexport const partialConsent: CookieFirstConsent = {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n};\n\n/**\n * Minimal consent - user accepted only necessary (required)\n */\nexport const minimalConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: false,\n};\n\n/**\n * No consent - user hasn't made a choice yet\n * CookieFirst returns null when no explicit choice has been made\n */\nexport const noConsent: CookieFirstConsent | null = null;\n\n/**\n * Analytics only - user accepted performance tracking\n */\nexport const analyticsOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n};\n\n/**\n * Marketing only - user accepted advertising\n */\nexport const marketingOnlyConsent: CookieFirstConsent = {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after mapping CookieFirst categories\n * to walkerOS consent groups using the default category map.\n */\n\n/**\n * Full consent mapped to walkerOS groups\n * (necessary + functional → functional, performance → analytics, advertising → marketing)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n\n/**\n * Partial consent mapped to walkerOS groups\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Minimal consent mapped to walkerOS groups\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Analytics only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const analyticsOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: false,\n};\n\n/**\n * Marketing only consent mapped to walkerOS groups\n * Note: functional is true because necessary=true maps to functional\n * (OR logic: if ANY source category is true, target group is true)\n */\nexport const marketingOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: true,\n};\n","import type { Source, Elb, Logger } from '@walkeros/core';\nimport type { CookieFirstAPI, CookieFirstConsent } from '../types';\n\n/**\n * Example environment configurations for CookieFirst source testing.\n *\n * These provide mock structures for testing consent handling\n * without requiring a real browser environment.\n */\n\n// Simple no-op function for mocking\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock that returns a promise with PushResult\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n warn: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n json: noop,\n scope: () => noopLogger,\n};\n\n/**\n * Environment interface for CookieFirst source\n */\ninterface CookieFirstEnv extends Source.BaseEnv {\n window?: typeof window;\n}\n\n/**\n * Create a mock CookieFirst API object\n */\nexport const createMockCookieFirstAPI = (\n consent: CookieFirstConsent | null = null,\n): CookieFirstAPI => ({\n consent,\n});\n\n/**\n * Create a mock window object with CookieFirst\n */\nexport const createMockWindow = (\n consent: CookieFirstConsent | null = null,\n): Partial<Window> & { CookieFirst: CookieFirstAPI } => ({\n CookieFirst: createMockCookieFirstAPI(consent),\n addEventListener: noop,\n removeEventListener: noop,\n});\n\n/**\n * Standard mock environment for testing CookieFirst source\n *\n * Use this for testing consent handling without requiring\n * a real browser environment.\n */\nexport const mockEnv: CookieFirstEnv = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n get window() {\n return createMockWindow() as unknown as typeof window;\n },\n logger: noopLogger,\n};\n","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'CookieFirst reports all categories granted and the source forwards a walker consent command with all groups true.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: true,\n marketing: true,\n },\n ],\n ],\n};\n\nexport const partialConsent: Flow.StepExample = {\n title: 'Partial consent',\n description:\n 'A partial CookieFirst grant maps analytics and marketing to false in the emitted walker consent command.',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n title: 'Category map override',\n description:\n 'Custom categoryMap remaps performance to statistics instead of analytics',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: true,\n advertising: false,\n },\n mapping: {\n settings: {\n categoryMap: {\n performance: 'statistics',\n },\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n statistics: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const cfInitDetection: Flow.StepExample = {\n title: 'cf_init detection',\n description: 'CMP detected via cf_init CustomEvent (primary detection path)',\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: false,\n performance: false,\n advertising: true,\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: false,\n marketing: true,\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\nimport type { CookieFirstConsent } from '../types';\n\nconst createTrigger: Trigger.CreateFn<CookieFirstConsent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<CookieFirstConsent, void> =\n () => async (content: CookieFirstConsent) => {\n // The banner keeps window.CookieFirst current.\n window.CookieFirst = { consent: content };\n\n // First call, the page load: the source reads the global at init and\n // emits once. No cf_init follows: in a browser it fires when the global\n // appears, so a page where the global is already set has seen it before\n // the source started. One page load emits one consent.\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n return;\n }\n\n // Later calls are a decision on the loaded page: CookieFirst announces\n // it with cf_consent, carrying the new consent.\n window.dispatchEvent(\n new CustomEvent<CookieFirstConsent>('cf_consent', { detail: content }),\n );\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Sets window.CookieFirst.consent before source init (legacy). */\nconst trigger = (input: unknown, env: Record<string, unknown>): void => {\n const win = env.window;\n if (!isConsent(input) || !isWindow(win)) return;\n win.CookieFirst = { consent: input };\n};\n\nfunction isWindow(value: unknown): value is Window {\n return (\n typeof value === 'object' && value !== null && 'addEventListener' in value\n );\n}\n\nfunction isConsent(value: unknown): value is CookieFirstConsent {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n Object.values(value).every(\n (state) => state === undefined || typeof state === 'boolean',\n )\n );\n}\n\nexport { createTrigger, trigger };\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * CookieFirst source settings schema\n */\nexport const SettingsSchema = z\n .object({\n categoryMap: z\n .record(z.string(), z.string())\n .describe(\n \"Map the CMP's consent categories (keys) to walkerOS consent groups (values).\",\n )\n .optional(),\n\n explicitOnly: z\n .boolean()\n .describe(\n 'Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.',\n )\n .optional(),\n\n globalName: z\n .string()\n .describe(\n \"Custom name for the CookieFirst global on window. Default: 'CookieFirst'.\",\n )\n .optional(),\n })\n .meta({\n id: 'CookieFirstSettings',\n title: 'Settings',\n description: 'Settings for the CookieFirst CMP source.',\n });\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAkC;AAAA,EAC7C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,iBAAqC;AAAA,EAChD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAMO,IAAM,YAAuC;AAK7C,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;AAKO,IAAM,uBAA2C;AAAA,EACtD,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AACf;;;ACjDO,IAAM,oBAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAKO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AAC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ACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,YAAY,EACT,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC,EACA,KAAK;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf,CAAC;;;ADzBI,IAAM,WAAW,YAAY,cAAc;","names":["fullConsent","partialConsent","trigger"]}
|
|
@@ -11,7 +11,7 @@ declare module '@walkeros/core' {
|
|
|
11
11
|
/**
|
|
12
12
|
* CookieFirst consent object structure
|
|
13
13
|
*/
|
|
14
|
-
interface CookieFirstConsent
|
|
14
|
+
interface CookieFirstConsent {
|
|
15
15
|
necessary?: boolean;
|
|
16
16
|
functional?: boolean;
|
|
17
17
|
performance?: boolean;
|
|
@@ -22,7 +22,7 @@ interface CookieFirstConsent$1 {
|
|
|
22
22
|
* CookieFirst global API interface
|
|
23
23
|
*/
|
|
24
24
|
interface CookieFirstAPI {
|
|
25
|
-
consent: CookieFirstConsent
|
|
25
|
+
consent: CookieFirstConsent | null;
|
|
26
26
|
}
|
|
27
27
|
declare global {
|
|
28
28
|
interface Window {
|
|
@@ -31,7 +31,7 @@ declare global {
|
|
|
31
31
|
}
|
|
32
32
|
interface WindowEventMap {
|
|
33
33
|
cf_init: Event;
|
|
34
|
-
cf_consent: CustomEvent<CookieFirstConsent
|
|
34
|
+
cf_consent: CustomEvent<CookieFirstConsent>;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -43,28 +43,28 @@ declare global {
|
|
|
43
43
|
/**
|
|
44
44
|
* Full consent - user accepted all categories
|
|
45
45
|
*/
|
|
46
|
-
declare const fullConsent$1: CookieFirstConsent
|
|
46
|
+
declare const fullConsent$1: CookieFirstConsent;
|
|
47
47
|
/**
|
|
48
48
|
* Partial consent - user accepted only necessary and functional
|
|
49
49
|
*/
|
|
50
|
-
declare const partialConsent$1: CookieFirstConsent
|
|
50
|
+
declare const partialConsent$1: CookieFirstConsent;
|
|
51
51
|
/**
|
|
52
52
|
* Minimal consent - user accepted only necessary (required)
|
|
53
53
|
*/
|
|
54
|
-
declare const minimalConsent: CookieFirstConsent
|
|
54
|
+
declare const minimalConsent: CookieFirstConsent;
|
|
55
55
|
/**
|
|
56
56
|
* No consent - user hasn't made a choice yet
|
|
57
57
|
* CookieFirst returns null when no explicit choice has been made
|
|
58
58
|
*/
|
|
59
|
-
declare const noConsent: CookieFirstConsent
|
|
59
|
+
declare const noConsent: CookieFirstConsent | null;
|
|
60
60
|
/**
|
|
61
61
|
* Analytics only - user accepted performance tracking
|
|
62
62
|
*/
|
|
63
|
-
declare const analyticsOnlyConsent: CookieFirstConsent
|
|
63
|
+
declare const analyticsOnlyConsent: CookieFirstConsent;
|
|
64
64
|
/**
|
|
65
65
|
* Marketing only - user accepted advertising
|
|
66
66
|
*/
|
|
67
|
-
declare const marketingOnlyConsent: CookieFirstConsent
|
|
67
|
+
declare const marketingOnlyConsent: CookieFirstConsent;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Expected walkerOS consent outputs.
|
|
@@ -115,11 +115,11 @@ interface CookieFirstEnv extends Source.BaseEnv {
|
|
|
115
115
|
/**
|
|
116
116
|
* Create a mock CookieFirst API object
|
|
117
117
|
*/
|
|
118
|
-
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent
|
|
118
|
+
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent | null) => CookieFirstAPI;
|
|
119
119
|
/**
|
|
120
120
|
* Create a mock window object with CookieFirst
|
|
121
121
|
*/
|
|
122
|
-
declare const createMockWindow: (consent?: CookieFirstConsent
|
|
122
|
+
declare const createMockWindow: (consent?: CookieFirstConsent | null) => Partial<Window> & {
|
|
123
123
|
CookieFirst: CookieFirstAPI;
|
|
124
124
|
};
|
|
125
125
|
/**
|
|
@@ -143,13 +143,6 @@ declare namespace step {
|
|
|
143
143
|
export { step_categoryMapOverride as categoryMapOverride, step_cfInitDetection as cfInitDetection, step_fullConsent as fullConsent, step_partialConsent as partialConsent };
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
interface CookieFirstConsent {
|
|
147
|
-
necessary?: boolean;
|
|
148
|
-
functional?: boolean;
|
|
149
|
-
performance?: boolean;
|
|
150
|
-
advertising?: boolean;
|
|
151
|
-
[category: string]: boolean | undefined;
|
|
152
|
-
}
|
|
153
146
|
declare const createTrigger: Trigger.CreateFn<CookieFirstConsent, void>;
|
|
154
147
|
/** Sets window.CookieFirst.consent before source init (legacy). */
|
|
155
148
|
declare const trigger: (input: unknown, env: Record<string, unknown>) => void;
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare module '@walkeros/core' {
|
|
|
11
11
|
/**
|
|
12
12
|
* CookieFirst consent object structure
|
|
13
13
|
*/
|
|
14
|
-
interface CookieFirstConsent
|
|
14
|
+
interface CookieFirstConsent {
|
|
15
15
|
necessary?: boolean;
|
|
16
16
|
functional?: boolean;
|
|
17
17
|
performance?: boolean;
|
|
@@ -22,7 +22,7 @@ interface CookieFirstConsent$1 {
|
|
|
22
22
|
* CookieFirst global API interface
|
|
23
23
|
*/
|
|
24
24
|
interface CookieFirstAPI {
|
|
25
|
-
consent: CookieFirstConsent
|
|
25
|
+
consent: CookieFirstConsent | null;
|
|
26
26
|
}
|
|
27
27
|
declare global {
|
|
28
28
|
interface Window {
|
|
@@ -31,7 +31,7 @@ declare global {
|
|
|
31
31
|
}
|
|
32
32
|
interface WindowEventMap {
|
|
33
33
|
cf_init: Event;
|
|
34
|
-
cf_consent: CustomEvent<CookieFirstConsent
|
|
34
|
+
cf_consent: CustomEvent<CookieFirstConsent>;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -43,28 +43,28 @@ declare global {
|
|
|
43
43
|
/**
|
|
44
44
|
* Full consent - user accepted all categories
|
|
45
45
|
*/
|
|
46
|
-
declare const fullConsent$1: CookieFirstConsent
|
|
46
|
+
declare const fullConsent$1: CookieFirstConsent;
|
|
47
47
|
/**
|
|
48
48
|
* Partial consent - user accepted only necessary and functional
|
|
49
49
|
*/
|
|
50
|
-
declare const partialConsent$1: CookieFirstConsent
|
|
50
|
+
declare const partialConsent$1: CookieFirstConsent;
|
|
51
51
|
/**
|
|
52
52
|
* Minimal consent - user accepted only necessary (required)
|
|
53
53
|
*/
|
|
54
|
-
declare const minimalConsent: CookieFirstConsent
|
|
54
|
+
declare const minimalConsent: CookieFirstConsent;
|
|
55
55
|
/**
|
|
56
56
|
* No consent - user hasn't made a choice yet
|
|
57
57
|
* CookieFirst returns null when no explicit choice has been made
|
|
58
58
|
*/
|
|
59
|
-
declare const noConsent: CookieFirstConsent
|
|
59
|
+
declare const noConsent: CookieFirstConsent | null;
|
|
60
60
|
/**
|
|
61
61
|
* Analytics only - user accepted performance tracking
|
|
62
62
|
*/
|
|
63
|
-
declare const analyticsOnlyConsent: CookieFirstConsent
|
|
63
|
+
declare const analyticsOnlyConsent: CookieFirstConsent;
|
|
64
64
|
/**
|
|
65
65
|
* Marketing only - user accepted advertising
|
|
66
66
|
*/
|
|
67
|
-
declare const marketingOnlyConsent: CookieFirstConsent
|
|
67
|
+
declare const marketingOnlyConsent: CookieFirstConsent;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Expected walkerOS consent outputs.
|
|
@@ -115,11 +115,11 @@ interface CookieFirstEnv extends Source.BaseEnv {
|
|
|
115
115
|
/**
|
|
116
116
|
* Create a mock CookieFirst API object
|
|
117
117
|
*/
|
|
118
|
-
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent
|
|
118
|
+
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent | null) => CookieFirstAPI;
|
|
119
119
|
/**
|
|
120
120
|
* Create a mock window object with CookieFirst
|
|
121
121
|
*/
|
|
122
|
-
declare const createMockWindow: (consent?: CookieFirstConsent
|
|
122
|
+
declare const createMockWindow: (consent?: CookieFirstConsent | null) => Partial<Window> & {
|
|
123
123
|
CookieFirst: CookieFirstAPI;
|
|
124
124
|
};
|
|
125
125
|
/**
|
|
@@ -143,13 +143,6 @@ declare namespace step {
|
|
|
143
143
|
export { step_categoryMapOverride as categoryMapOverride, step_cfInitDetection as cfInitDetection, step_fullConsent as fullConsent, step_partialConsent as partialConsent };
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
interface CookieFirstConsent {
|
|
147
|
-
necessary?: boolean;
|
|
148
|
-
functional?: boolean;
|
|
149
|
-
performance?: boolean;
|
|
150
|
-
advertising?: boolean;
|
|
151
|
-
[category: string]: boolean | undefined;
|
|
152
|
-
}
|
|
153
146
|
declare const createTrigger: Trigger.CreateFn<CookieFirstConsent, void>;
|
|
154
147
|
/** Sets window.CookieFirst.consent before source init (legacy). */
|
|
155
148
|
declare const trigger: (input: unknown, env: Record<string, unknown>) => void;
|
package/dist/examples/index.js
CHANGED
|
@@ -256,14 +256,15 @@ var createTrigger = async (config) => {
|
|
|
256
256
|
let flow;
|
|
257
257
|
const trigger2 = () => async (content) => {
|
|
258
258
|
var _a;
|
|
259
|
-
window.CookieFirst = {
|
|
260
|
-
consent: content
|
|
261
|
-
};
|
|
259
|
+
window.CookieFirst = { consent: content };
|
|
262
260
|
if (!flow) {
|
|
263
261
|
const result = await (0, import_collector.startFlow)({ ...config, run: (_a = config.run) != null ? _a : true });
|
|
264
262
|
flow = { collector: result.collector, elb: result.elb };
|
|
263
|
+
return;
|
|
265
264
|
}
|
|
266
|
-
window.dispatchEvent(
|
|
265
|
+
window.dispatchEvent(
|
|
266
|
+
new CustomEvent("cf_consent", { detail: content })
|
|
267
|
+
);
|
|
267
268
|
};
|
|
268
269
|
return {
|
|
269
270
|
get flow() {
|
|
@@ -273,9 +274,18 @@ var createTrigger = async (config) => {
|
|
|
273
274
|
};
|
|
274
275
|
};
|
|
275
276
|
var trigger = (input, env) => {
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
const win = env.window;
|
|
278
|
+
if (!isConsent(input) || !isWindow(win)) return;
|
|
279
|
+
win.CookieFirst = { consent: input };
|
|
278
280
|
};
|
|
281
|
+
function isWindow(value) {
|
|
282
|
+
return typeof value === "object" && value !== null && "addEventListener" in value;
|
|
283
|
+
}
|
|
284
|
+
function isConsent(value) {
|
|
285
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every(
|
|
286
|
+
(state) => state === void 0 || typeof state === "boolean"
|
|
287
|
+
);
|
|
288
|
+
}
|
|
279
289
|
// Annotate the CommonJS export names for ESM import in node:
|
|
280
290
|
0 && (module.exports = {
|
|
281
291
|
analyticsOnlyConsent,
|
package/dist/examples/index.mjs
CHANGED
|
@@ -218,14 +218,15 @@ var createTrigger = async (config) => {
|
|
|
218
218
|
let flow;
|
|
219
219
|
const trigger2 = () => async (content) => {
|
|
220
220
|
var _a;
|
|
221
|
-
window.CookieFirst = {
|
|
222
|
-
consent: content
|
|
223
|
-
};
|
|
221
|
+
window.CookieFirst = { consent: content };
|
|
224
222
|
if (!flow) {
|
|
225
223
|
const result = await startFlow({ ...config, run: (_a = config.run) != null ? _a : true });
|
|
226
224
|
flow = { collector: result.collector, elb: result.elb };
|
|
225
|
+
return;
|
|
227
226
|
}
|
|
228
|
-
window.dispatchEvent(
|
|
227
|
+
window.dispatchEvent(
|
|
228
|
+
new CustomEvent("cf_consent", { detail: content })
|
|
229
|
+
);
|
|
229
230
|
};
|
|
230
231
|
return {
|
|
231
232
|
get flow() {
|
|
@@ -235,9 +236,18 @@ var createTrigger = async (config) => {
|
|
|
235
236
|
};
|
|
236
237
|
};
|
|
237
238
|
var trigger = (input, env) => {
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
const win = env.window;
|
|
240
|
+
if (!isConsent(input) || !isWindow(win)) return;
|
|
241
|
+
win.CookieFirst = { consent: input };
|
|
240
242
|
};
|
|
243
|
+
function isWindow(value) {
|
|
244
|
+
return typeof value === "object" && value !== null && "addEventListener" in value;
|
|
245
|
+
}
|
|
246
|
+
function isConsent(value) {
|
|
247
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every(
|
|
248
|
+
(state) => state === void 0 || typeof state === "boolean"
|
|
249
|
+
);
|
|
250
|
+
}
|
|
241
251
|
export {
|
|
242
252
|
analyticsOnlyConsent,
|
|
243
253
|
analyticsOnlyMapped,
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/web-source-cmp-cookiefirst",
|
|
4
|
-
"version": "4.7.0
|
|
4
|
+
"version": "4.7.0",
|
|
5
5
|
"type": "source",
|
|
6
6
|
"platform": [
|
|
7
7
|
"web"
|
|
8
8
|
],
|
|
9
9
|
"renderer": "codebox",
|
|
10
|
+
"exports": {},
|
|
10
11
|
"docs": "https://www.walkeros.io/docs/sources/web/cmps/cookiefirst",
|
|
11
12
|
"source": "https://github.com/elbwalker/walkerOS/tree/main/packages/web/sources/cmps/cookiefirst/src"
|
|
12
13
|
},
|
|
@@ -58,10 +59,10 @@
|
|
|
58
59
|
"$code": "()=>()=>Promise.resolve({ok:!0})"
|
|
59
60
|
},
|
|
60
61
|
"createMockWindow": {
|
|
61
|
-
"$code": "(e=null)=>({CookieFirst:k(e),addEventListener:
|
|
62
|
+
"$code": "(e=null)=>({CookieFirst:k(e),addEventListener:d,removeEventListener:d})"
|
|
62
63
|
},
|
|
63
64
|
"createTrigger": {
|
|
64
|
-
"$code": "async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{var r;if(window.CookieFirst={consent:n},!t){const n=await O({...e,run:null==(r=e.run)||r});t={collector:n.collector,elb:n.elb}}window.dispatchEvent(new
|
|
65
|
+
"$code": "async e=>{let t;return{get flow(){return t},trigger:()=>async n=>{var r;if(window.CookieFirst={consent:n},!t){const n=await O({...e,run:null==(r=e.run)||r});return void(t={collector:n.collector,elb:n.elb})}window.dispatchEvent(new CustomEvent(\"cf_consent\",{detail:n}))}}}"
|
|
65
66
|
},
|
|
66
67
|
"fullConsent": {
|
|
67
68
|
"necessary": true,
|
|
@@ -282,7 +283,7 @@
|
|
|
282
283
|
}
|
|
283
284
|
},
|
|
284
285
|
"trigger": {
|
|
285
|
-
"$code": "(e,t)=>{e
|
|
286
|
+
"$code": "(e,t)=>{const n=t.window;var r;\"object\"==typeof(r=e)&&null!==r&&!Array.isArray(r)&&Object.values(r).every(e=>void 0===e||\"boolean\"==typeof e)&&function(e){return\"object\"==typeof e&&null!==e&&\"addEventListener\"in e}(n)&&(n.CookieFirst={consent:e})}"
|
|
286
287
|
}
|
|
287
288
|
}
|
|
288
289
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/web-source-cmp-cookiefirst",
|
|
3
3
|
"description": "CookieFirst consent management source for walkerOS",
|
|
4
|
-
"version": "4.7.0
|
|
4
|
+
"version": "4.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"walkerOS": {
|
|
7
7
|
"type": "source",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"update": "npx npm-check-updates -u && npm update"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@walkeros/core": "4.7.0
|
|
50
|
-
"@walkeros/collector": "4.7.0
|
|
49
|
+
"@walkeros/core": "4.7.0",
|
|
50
|
+
"@walkeros/collector": "4.7.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {},
|
|
53
53
|
"repository": {
|