@walkeros/web-source-cmp-cookiefirst 3.3.1 → 3.4.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/dist/dev.d.mts +40 -19
- package/dist/dev.d.ts +40 -19
- 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.js +44 -20
- package/dist/examples/index.mjs +44 -20
- package/dist/index.browser.js +1 -1
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +83 -30
- package/package.json +3 -3
package/dist/dev.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { WalkerOS, Elb, Source, Logger, Flow, Trigger } from '@walkeros/core';
|
|
2
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
3
|
+
import { z } from '@walkeros/core/dev';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* CookieFirst consent object structure
|
|
@@ -150,25 +152,44 @@ declare const trigger: (input: unknown, env: Record<string, unknown>) => void;
|
|
|
150
152
|
* CookieFirst source examples for testing and documentation.
|
|
151
153
|
*/
|
|
152
154
|
|
|
153
|
-
declare const
|
|
154
|
-
declare const
|
|
155
|
-
declare const
|
|
156
|
-
declare const
|
|
157
|
-
declare const
|
|
158
|
-
declare const
|
|
159
|
-
declare const
|
|
160
|
-
declare const
|
|
161
|
-
declare const
|
|
162
|
-
declare const
|
|
163
|
-
declare const
|
|
164
|
-
declare const
|
|
165
|
-
declare const
|
|
166
|
-
declare const
|
|
167
|
-
declare const
|
|
168
|
-
declare const
|
|
169
|
-
declare const
|
|
155
|
+
declare const index$1_analyticsOnlyConsent: typeof analyticsOnlyConsent;
|
|
156
|
+
declare const index$1_analyticsOnlyMapped: typeof analyticsOnlyMapped;
|
|
157
|
+
declare const index$1_createMockCookieFirstAPI: typeof createMockCookieFirstAPI;
|
|
158
|
+
declare const index$1_createMockElbFn: typeof createMockElbFn;
|
|
159
|
+
declare const index$1_createMockWindow: typeof createMockWindow;
|
|
160
|
+
declare const index$1_createTrigger: typeof createTrigger;
|
|
161
|
+
declare const index$1_fullConsentMapped: typeof fullConsentMapped;
|
|
162
|
+
declare const index$1_marketingOnlyConsent: typeof marketingOnlyConsent;
|
|
163
|
+
declare const index$1_marketingOnlyMapped: typeof marketingOnlyMapped;
|
|
164
|
+
declare const index$1_minimalConsent: typeof minimalConsent;
|
|
165
|
+
declare const index$1_minimalConsentMapped: typeof minimalConsentMapped;
|
|
166
|
+
declare const index$1_mockEnv: typeof mockEnv;
|
|
167
|
+
declare const index$1_noConsent: typeof noConsent;
|
|
168
|
+
declare const index$1_noopLogger: typeof noopLogger;
|
|
169
|
+
declare const index$1_partialConsentMapped: typeof partialConsentMapped;
|
|
170
|
+
declare const index$1_step: typeof step;
|
|
171
|
+
declare const index$1_trigger: typeof trigger;
|
|
172
|
+
declare namespace index$1 {
|
|
173
|
+
export { index$1_analyticsOnlyConsent as analyticsOnlyConsent, index$1_analyticsOnlyMapped as analyticsOnlyMapped, index$1_createMockCookieFirstAPI as createMockCookieFirstAPI, index$1_createMockElbFn as createMockElbFn, index$1_createMockWindow as createMockWindow, index$1_createTrigger as createTrigger, fullConsent$1 as fullConsent, index$1_fullConsentMapped as fullConsentMapped, index$1_marketingOnlyConsent as marketingOnlyConsent, index$1_marketingOnlyMapped as marketingOnlyMapped, index$1_minimalConsent as minimalConsent, index$1_minimalConsentMapped as minimalConsentMapped, index$1_mockEnv as mockEnv, index$1_noConsent as noConsent, index$1_noopLogger as noopLogger, partialConsent$1 as partialConsent, index$1_partialConsentMapped as partialConsentMapped, index$1_step as step, index$1_trigger as trigger };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* CookieFirst source settings schema
|
|
178
|
+
*/
|
|
179
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
180
|
+
categoryMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
181
|
+
explicitOnly: z.ZodOptional<z.ZodBoolean>;
|
|
182
|
+
globalName: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
185
|
+
|
|
186
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
187
|
+
|
|
188
|
+
type index_Settings = Settings;
|
|
189
|
+
declare const index_SettingsSchema: typeof SettingsSchema;
|
|
190
|
+
declare const index_settings: typeof settings;
|
|
170
191
|
declare namespace index {
|
|
171
|
-
export {
|
|
192
|
+
export { type index_Settings as Settings, index_SettingsSchema as SettingsSchema, index_settings as settings };
|
|
172
193
|
}
|
|
173
194
|
|
|
174
|
-
export { index as examples };
|
|
195
|
+
export { index$1 as examples, index as schemas };
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { WalkerOS, Elb, Source, Logger, Flow, Trigger } from '@walkeros/core';
|
|
2
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
3
|
+
import { z } from '@walkeros/core/dev';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* CookieFirst consent object structure
|
|
@@ -150,25 +152,44 @@ declare const trigger: (input: unknown, env: Record<string, unknown>) => void;
|
|
|
150
152
|
* CookieFirst source examples for testing and documentation.
|
|
151
153
|
*/
|
|
152
154
|
|
|
153
|
-
declare const
|
|
154
|
-
declare const
|
|
155
|
-
declare const
|
|
156
|
-
declare const
|
|
157
|
-
declare const
|
|
158
|
-
declare const
|
|
159
|
-
declare const
|
|
160
|
-
declare const
|
|
161
|
-
declare const
|
|
162
|
-
declare const
|
|
163
|
-
declare const
|
|
164
|
-
declare const
|
|
165
|
-
declare const
|
|
166
|
-
declare const
|
|
167
|
-
declare const
|
|
168
|
-
declare const
|
|
169
|
-
declare const
|
|
155
|
+
declare const index$1_analyticsOnlyConsent: typeof analyticsOnlyConsent;
|
|
156
|
+
declare const index$1_analyticsOnlyMapped: typeof analyticsOnlyMapped;
|
|
157
|
+
declare const index$1_createMockCookieFirstAPI: typeof createMockCookieFirstAPI;
|
|
158
|
+
declare const index$1_createMockElbFn: typeof createMockElbFn;
|
|
159
|
+
declare const index$1_createMockWindow: typeof createMockWindow;
|
|
160
|
+
declare const index$1_createTrigger: typeof createTrigger;
|
|
161
|
+
declare const index$1_fullConsentMapped: typeof fullConsentMapped;
|
|
162
|
+
declare const index$1_marketingOnlyConsent: typeof marketingOnlyConsent;
|
|
163
|
+
declare const index$1_marketingOnlyMapped: typeof marketingOnlyMapped;
|
|
164
|
+
declare const index$1_minimalConsent: typeof minimalConsent;
|
|
165
|
+
declare const index$1_minimalConsentMapped: typeof minimalConsentMapped;
|
|
166
|
+
declare const index$1_mockEnv: typeof mockEnv;
|
|
167
|
+
declare const index$1_noConsent: typeof noConsent;
|
|
168
|
+
declare const index$1_noopLogger: typeof noopLogger;
|
|
169
|
+
declare const index$1_partialConsentMapped: typeof partialConsentMapped;
|
|
170
|
+
declare const index$1_step: typeof step;
|
|
171
|
+
declare const index$1_trigger: typeof trigger;
|
|
172
|
+
declare namespace index$1 {
|
|
173
|
+
export { index$1_analyticsOnlyConsent as analyticsOnlyConsent, index$1_analyticsOnlyMapped as analyticsOnlyMapped, index$1_createMockCookieFirstAPI as createMockCookieFirstAPI, index$1_createMockElbFn as createMockElbFn, index$1_createMockWindow as createMockWindow, index$1_createTrigger as createTrigger, fullConsent$1 as fullConsent, index$1_fullConsentMapped as fullConsentMapped, index$1_marketingOnlyConsent as marketingOnlyConsent, index$1_marketingOnlyMapped as marketingOnlyMapped, index$1_minimalConsent as minimalConsent, index$1_minimalConsentMapped as minimalConsentMapped, index$1_mockEnv as mockEnv, index$1_noConsent as noConsent, index$1_noopLogger as noopLogger, partialConsent$1 as partialConsent, index$1_partialConsentMapped as partialConsentMapped, index$1_step as step, index$1_trigger as trigger };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* CookieFirst source settings schema
|
|
178
|
+
*/
|
|
179
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
180
|
+
categoryMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
181
|
+
explicitOnly: z.ZodOptional<z.ZodBoolean>;
|
|
182
|
+
globalName: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
185
|
+
|
|
186
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
187
|
+
|
|
188
|
+
type index_Settings = Settings;
|
|
189
|
+
declare const index_SettingsSchema: typeof SettingsSchema;
|
|
190
|
+
declare const index_settings: typeof settings;
|
|
170
191
|
declare namespace index {
|
|
171
|
-
export {
|
|
192
|
+
export { type index_Settings as Settings, index_SettingsSchema as SettingsSchema, index_settings as settings };
|
|
172
193
|
}
|
|
173
194
|
|
|
174
|
-
export { index as examples };
|
|
195
|
+
export { index$1 as examples, index as schemas };
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,
|
|
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:()=>_}),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:()=>M,createMockElbFn:()=>b,createMockWindow:()=>O,createTrigger:()=>x,fullConsent:()=>c,fullConsentMapped:()=>m,marketingOnlyConsent:()=>f,marketingOnlyMapped:()=>v,minimalConsent:()=>g,minimalConsentMapped:()=>d,mockEnv:()=>h,noConsent:()=>p,noopLogger:()=>C,partialConsent:()=>l,partialConsentMapped:()=>y,step:()=>F,trigger:()=>D});var c={necessary:!0,functional:!0,performance:!0,advertising:!0},l={necessary:!0,functional:!0,performance:!1,advertising:!1},g={necessary:!0,functional:!1,performance:!1,advertising:!1},p=null,u={necessary:!0,functional:!1,performance:!0,advertising:!1},f={necessary:!0,functional:!1,performance:!1,advertising:!0},m={functional:!0,analytics:!0,marketing:!0},y={functional:!0,analytics:!1,marketing:!1},d={functional:!0,analytics:!1,marketing:!1},k={functional:!0,analytics:!0,marketing:!1},v={functional:!0,analytics:!1,marketing:!0},w=()=>{},b=()=>()=>Promise.resolve({ok:!0}),C={error:w,warn:w,info:w,debug:w,throw:e=>{throw"string"==typeof e?new Error(e):e},json:w,scope:()=>C},M=(e=null)=>({consent:e}),O=(e=null)=>({CookieFirst:M(e),addEventListener:w,removeEventListener:w}),h={get push(){return b()},get command(){return b()},get elb(){return b()},get window(){return O()},logger:C},F={};a(F,{categoryMapOverride:()=>E,cfInitDetection:()=>z,fullConsent:()=>P,partialConsent:()=>j});var P={trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!0,advertising:!0},out:[["elb","walker consent",{functional:!0,analytics:!0,marketing:!0}]]},j={trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!1,advertising:!1},out:[["elb","walker consent",{functional:!0,analytics:!1,marketing:!1}]]},E={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={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"),x=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});t={collector:n.collector,elb:n.elb}}window.dispatchEvent(new Event("cf_init"))}}},D=(e,t)=>{e&&"object"==typeof e&&(t.window.CookieFirst={consent:e})},_={};a(_,{SettingsSchema:()=>L,settings:()=>N});var q=require("@walkeros/core/dev"),I=require("@walkeros/core/dev"),L=I.z.object({categoryMap:I.z.record(I.z.string(),I.z.string()).describe("Map the CMP's consent categories (keys) to walkerOS consent groups (values).").optional(),explicitOnly:I.z.boolean().describe("Only process consent after the user made an explicit choice. Ignores default/implicit states. Default: true.").optional(),globalName:I.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."}),N=(0,q.zodToSchema)(L);//# 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"],"sourcesContent":["/**\n * Development exports for testing and tooling.\n */\nexport * as examples from './examples';\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 trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n },\n out: {\n functional: true,\n analytics: true,\n marketing: true,\n },\n};\n\nexport const partialConsent: Flow.StepExample = {\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n },\n out: {\n functional: true,\n analytics: false,\n marketing: false,\n },\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\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 functional: true,\n statistics: true,\n marketing: false,\n },\n};\n\nexport const cfInitDetection: Flow.StepExample = {\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 functional: true,\n analytics: false,\n marketing: true,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AA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,IAAI;AAAA,IACF,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA,SAAS;AAAA,IACP,UAAU;AAAA,MACR,aAAa;AAAA,QACX,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AACF;AAEO,IAAM,kBAAoC;AAAA,EAC/C,aAAa;AAAA,EACb,SAAS,EAAE,MAAM,UAAU;AAAA,EAC3B,IAAI;AAAA,IACF,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA,KAAK;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;;;ACrEA,uBAA0B;AAU1B,IAAM,gBAA4D,OAChE,WACG;AACH,MAAI;AAEJ,QAAMC,WACJ,MAAM,OAAO,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;","names":["fullConsent","partialConsent","trigger"]}
|
|
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 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 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 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 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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c,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"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e=Object.defineProperty,n=(n,t)=>{for(var r in t)e(n,r,{get:t[r],enumerable:!0})},t={};n(t,{analyticsOnlyConsent:()=>s,analyticsOnlyMapped:()=>f,createMockCookieFirstAPI:()=>k,createMockElbFn:()=>d,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},f={functional:!0,analytics:!0,marketing:!1},m={functional:!0,analytics:!1,marketing:!0},u=()=>{},d=()=>()=>Promise.resolve({ok:!0}),y={error:u,warn:u,info:u,debug:u,throw:e=>{throw"string"==typeof e?new Error(e):e},json:u,scope:()=>y},k=(e=null)=>({consent:e}),v=(e=null)=>({CookieFirst:k(e),addEventListener:u,removeEventListener:u}),w={get push(){return d()},get command(){return d()},get elb(){return d()},get window(){return v()},logger:y},C={};n(C,{categoryMapOverride:()=>h,cfInitDetection:()=>F,fullConsent:()=>b,partialConsent:()=>M});var b={trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!0,advertising:!0},out:[["elb","walker consent",{functional:!0,analytics:!0,marketing:!0}]]},M={trigger:{type:"consent"},in:{necessary:!0,functional:!0,performance:!1,advertising:!1},out:[["elb","walker consent",{functional:!0,analytics:!1,marketing:!1}]]},h={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={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 n;return{get flow(){return n},trigger:()=>async t=>{var r;if(window.CookieFirst={consent:t},!n){const t=await O({...e,run:null==(r=e.run)||r});n={collector:t.collector,elb:t.elb}}window.dispatchEvent(new Event("cf_init"))}}},P=(e,n)=>{e&&"object"==typeof e&&(n.window.CookieFirst={consent:e})},S={};n(S,{SettingsSchema:()=>D,settings:()=>I});import{zodToSchema as j}from"@walkeros/core/dev";import{z as x}from"@walkeros/core/dev";var D=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."}),I=j(D);export{t as examples,S 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"],"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 trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: true,\n advertising: true,\n },\n out: {\n functional: true,\n analytics: true,\n marketing: true,\n },\n};\n\nexport const partialConsent: Flow.StepExample = {\n trigger: { type: 'consent' },\n in: {\n necessary: true,\n functional: true,\n performance: false,\n advertising: false,\n },\n out: {\n functional: true,\n analytics: false,\n marketing: false,\n },\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\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 functional: true,\n statistics: true,\n marketing: false,\n },\n};\n\nexport const cfInitDetection: Flow.StepExample = {\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 functional: true,\n analytics: false,\n marketing: true,\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"],"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,aA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/C,aAAa;AAAA,EACb,SAAS,EAAE,MAAM,UAAU;AAAA,EAC3B,IAAI;AAAA,IACF,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA,KAAK;AAAA,IACH,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,EACb;AACF;;;ACrEA,SAAS,iBAAiB;AAU1B,IAAM,gBAA4D,OAChE,WACG;AACH,MAAI;AAEJ,QAAMC,WACJ,MAAM,OAAO,YAAgC;AAjBjD;AAmBM,IAAC,OAA8C,cAAc;AAAA,MAC3D,SAAS;AAAA,IACX;AAGA,QAAI,CAAC,MAAM;AACT,YAAM,SAAS,MAAM,UAAU,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;","names":["fullConsent","partialConsent","trigger"]}
|
|
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 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 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 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 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,E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G,EAAE,OAAO,CAAC,EAC7B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,cAAc,EACX,QAAQ,EACR;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"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -162,11 +162,17 @@ var fullConsent2 = {
|
|
|
162
162
|
performance: true,
|
|
163
163
|
advertising: true
|
|
164
164
|
},
|
|
165
|
-
out:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
out: [
|
|
166
|
+
[
|
|
167
|
+
"elb",
|
|
168
|
+
"walker consent",
|
|
169
|
+
{
|
|
170
|
+
functional: true,
|
|
171
|
+
analytics: true,
|
|
172
|
+
marketing: true
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
]
|
|
170
176
|
};
|
|
171
177
|
var partialConsent2 = {
|
|
172
178
|
trigger: { type: "consent" },
|
|
@@ -176,11 +182,17 @@ var partialConsent2 = {
|
|
|
176
182
|
performance: false,
|
|
177
183
|
advertising: false
|
|
178
184
|
},
|
|
179
|
-
out:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
out: [
|
|
186
|
+
[
|
|
187
|
+
"elb",
|
|
188
|
+
"walker consent",
|
|
189
|
+
{
|
|
190
|
+
functional: true,
|
|
191
|
+
analytics: false,
|
|
192
|
+
marketing: false
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
]
|
|
184
196
|
};
|
|
185
197
|
var categoryMapOverride = {
|
|
186
198
|
description: "Custom categoryMap remaps performance to statistics instead of analytics",
|
|
@@ -198,11 +210,17 @@ var categoryMapOverride = {
|
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
},
|
|
201
|
-
out:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
213
|
+
out: [
|
|
214
|
+
[
|
|
215
|
+
"elb",
|
|
216
|
+
"walker consent",
|
|
217
|
+
{
|
|
218
|
+
functional: true,
|
|
219
|
+
statistics: true,
|
|
220
|
+
marketing: false
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
]
|
|
206
224
|
};
|
|
207
225
|
var cfInitDetection = {
|
|
208
226
|
description: "CMP detected via cf_init CustomEvent (primary detection path)",
|
|
@@ -213,11 +231,17 @@ var cfInitDetection = {
|
|
|
213
231
|
performance: false,
|
|
214
232
|
advertising: true
|
|
215
233
|
},
|
|
216
|
-
out:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
234
|
+
out: [
|
|
235
|
+
[
|
|
236
|
+
"elb",
|
|
237
|
+
"walker consent",
|
|
238
|
+
{
|
|
239
|
+
functional: true,
|
|
240
|
+
analytics: false,
|
|
241
|
+
marketing: true
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
]
|
|
221
245
|
};
|
|
222
246
|
|
|
223
247
|
// src/examples/trigger.ts
|
package/dist/examples/index.mjs
CHANGED
|
@@ -124,11 +124,17 @@ var fullConsent2 = {
|
|
|
124
124
|
performance: true,
|
|
125
125
|
advertising: true
|
|
126
126
|
},
|
|
127
|
-
out:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
out: [
|
|
128
|
+
[
|
|
129
|
+
"elb",
|
|
130
|
+
"walker consent",
|
|
131
|
+
{
|
|
132
|
+
functional: true,
|
|
133
|
+
analytics: true,
|
|
134
|
+
marketing: true
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
]
|
|
132
138
|
};
|
|
133
139
|
var partialConsent2 = {
|
|
134
140
|
trigger: { type: "consent" },
|
|
@@ -138,11 +144,17 @@ var partialConsent2 = {
|
|
|
138
144
|
performance: false,
|
|
139
145
|
advertising: false
|
|
140
146
|
},
|
|
141
|
-
out:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
out: [
|
|
148
|
+
[
|
|
149
|
+
"elb",
|
|
150
|
+
"walker consent",
|
|
151
|
+
{
|
|
152
|
+
functional: true,
|
|
153
|
+
analytics: false,
|
|
154
|
+
marketing: false
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
]
|
|
146
158
|
};
|
|
147
159
|
var categoryMapOverride = {
|
|
148
160
|
description: "Custom categoryMap remaps performance to statistics instead of analytics",
|
|
@@ -160,11 +172,17 @@ var categoryMapOverride = {
|
|
|
160
172
|
}
|
|
161
173
|
}
|
|
162
174
|
},
|
|
163
|
-
out:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
175
|
+
out: [
|
|
176
|
+
[
|
|
177
|
+
"elb",
|
|
178
|
+
"walker consent",
|
|
179
|
+
{
|
|
180
|
+
functional: true,
|
|
181
|
+
statistics: true,
|
|
182
|
+
marketing: false
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
]
|
|
168
186
|
};
|
|
169
187
|
var cfInitDetection = {
|
|
170
188
|
description: "CMP detected via cf_init CustomEvent (primary detection path)",
|
|
@@ -175,11 +193,17 @@ var cfInitDetection = {
|
|
|
175
193
|
performance: false,
|
|
176
194
|
advertising: true
|
|
177
195
|
},
|
|
178
|
-
out:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
196
|
+
out: [
|
|
197
|
+
[
|
|
198
|
+
"elb",
|
|
199
|
+
"walker consent",
|
|
200
|
+
{
|
|
201
|
+
functional: true,
|
|
202
|
+
analytics: false,
|
|
203
|
+
marketing: true
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
]
|
|
183
207
|
};
|
|
184
208
|
|
|
185
209
|
// src/examples/trigger.ts
|