@walkeros/web-source-cmp-usercentrics 4.2.0 → 4.2.1-next-1781538735002
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 +15 -0
- package/README.md +36 -3
- package/dist/dev.d.mts +69 -50
- package/dist/dev.d.ts +69 -50
- 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 +65 -43
- package/dist/examples/index.d.ts +65 -43
- package/dist/examples/index.js +101 -180
- package/dist/examples/index.mjs +97 -172
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +25 -16
- package/dist/index.d.ts +25 -16
- 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 +439 -140
- package/package.json +3 -3
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","export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\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","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'A Usercentrics onAcceptAllServices event emits a walker consent command with essential, functional, and marketing granted.',\n trigger: { type: 'consent' },\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: true,\n marketing: true,\n },\n ],\n ],\n};\n\nexport const minimalConsent: Flow.StepExample = {\n title: 'Minimal consent',\n description:\n 'A Usercentrics onDenyAllServices event emits a walker consent command with only essential granted.',\n trigger: { type: 'consent' },\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: 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 essential to functional and functional to analytics',\n trigger: { type: 'consent' },\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n },\n mapping: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const customEventName: Flow.StepExample = {\n title: 'Custom event name',\n description: 'Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2',\n trigger: { type: 'consent', options: { eventName: 'UC_SDK_EVENT' } },\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n mapping: { eventName: 'UC_SDK_EVENT' },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: true,\n marketing: true,\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\ninterface UsercentricsContent {\n event: string;\n type: string;\n action?: string;\n ucCategory?: Record<string, boolean | unknown>;\n [service: string]: unknown;\n}\n\nconst createTrigger: Trigger.CreateFn<UsercentricsContent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<UsercentricsContent, void> =\n (type?: string, opts?: unknown) => async (content: UsercentricsContent) => {\n // Lazy startFlow — source registers ucEvent listener during init\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n }\n\n // Dispatch the CMP event — source's listener catches it\n const eventName =\n (opts as { eventName?: string })?.eventName || 'ucEvent';\n window.dispatchEvent(new CustomEvent(eventName, { detail: content }));\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Dispatches ucEvent CustomEvent after source init (post-init trigger). */\nconst trigger = (\n input: unknown,\n env: Record<string, unknown>,\n): void | (() => void) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n (env.window as Window).dispatchEvent(\n new CustomEvent('ucEvent', { detail: input }),\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 * Usercentrics source settings schema\n */\nexport const SettingsSchema = z\n .object({\n eventName: z\n .string()\n .describe(\n \"Window event name to listen for, configured in the Usercentrics admin (Implementation > Data Layer & Events). Use 'UC_SDK_EVENT' for the built-in Browser SDK event. Default: 'ucEvent'.\",\n )\n .optional(),\n\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_status events where type is 'explicit'. Ignores implicit/default page-load events. Default: true.\",\n )\n .optional(),\n })\n .meta({\n id: 'UsercentricsSettings',\n title: 'Settings',\n description: 'Settings for the Usercentrics 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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K;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf,CAAC;;;ADzBI,IAAM,eAAW,yBAAY,cAAc;","names":["fullConsent","minimalConsent","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","export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { UsercentricsV2Service } from '../types';\n\n/**\n * Example Usercentrics V2 service inputs.\n *\n * These mirror the shape returned by `window.UC_UI.getServicesBaseInfo()`:\n * an array of services, each carrying a `categorySlug`, optional display\n * `name`, and a `consent` block with the current `status` plus a decision\n * `history`. The adapter derives the explicit/implicit gate from whether any\n * history entry is `explicit`, and aggregates services into group-level\n * consent via strict AND per `categorySlug`.\n */\n\n/**\n * Full consent - every category accepted via an explicit decision\n * (user clicked \"Accept all\").\n */\nexport const servicesFullExplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n];\n\n/**\n * Minimal consent - only essential accepted, others denied via an explicit\n * decision (user clicked \"Deny all\").\n */\nexport const servicesMinimalExplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: false, history: [{ type: 'explicit', status: false }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: false, history: [{ type: 'explicit', status: false }] },\n },\n];\n\n/**\n * Partial consent - essential and functional accepted, marketing denied,\n * all via an explicit decision (user saved a custom selection).\n */\nexport const servicesPartialExplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: false, history: [{ type: 'explicit', status: false }] },\n },\n];\n\n/**\n * First-visit implicit state - the CMP reports page-load defaults with only\n * implicit history. The default `explicitOnly` gate suppresses this, so no\n * consent command is emitted.\n */\nexport const servicesFirstVisitImplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'implicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: false, history: [{ type: 'implicit', status: false }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: false, history: [{ type: 'implicit', status: false }] },\n },\n];\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state emitted via `elb('walker consent', state)`\n * after the V2 adapter aggregates `getServicesBaseInfo()` into group-level\n * consent (no category mapping configured: pass-through by `categorySlug`).\n */\n\n/**\n * Full consent - all categories granted.\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional granted, marketing denied.\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential granted.\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with a custom category mapping applied\n * (essential->functional, functional->analytics).\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\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","import type { Flow } from '@walkeros/core';\nimport {\n servicesFullExplicit,\n servicesMinimalExplicit,\n servicesPartialExplicit,\n servicesFirstVisitImplicit,\n} from './inputs';\nimport {\n fullConsentMapped,\n minimalConsentMapped,\n fullConsentCustomMapped,\n} from './outputs';\n\n/**\n * Step examples for the Usercentrics V2 path.\n *\n * `in` is the array returned by `window.UC_UI.getServicesBaseInfo()`. The test\n * runner attaches it as the V2 API, then drives the official trigger named in\n * `trigger.options.dispatch`:\n * - 'init' (default): UC_UI is present when the source runs, so the static\n * read at init emits the snapshot (also the `UC_UI_INITIALIZED` path).\n * - 'cmp': UC_UI is attached only after init, then a `UC_UI_CMP_EVENT`\n * decision (ACCEPT_ALL) re-reads and emits — the consent-change path.\n */\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'Usercentrics reports every category accepted via an explicit decision; the source emits a walker consent command granting essential, functional, and marketing.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesFullExplicit,\n out: [['elb', 'walker consent', fullConsentMapped]],\n};\n\nexport const minimalConsent: Flow.StepExample = {\n title: 'Minimal consent',\n description:\n 'A \"Deny all\" explicit decision leaves only essential granted; functional and marketing are emitted as false.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesMinimalExplicit,\n out: [['elb', 'walker consent', minimalConsentMapped]],\n};\n\nexport const returningVisitor: Flow.StepExample = {\n title: 'Returning visitor static read',\n description:\n 'When the CMP is already initialized with a stored explicit decision, the static read at init re-publishes that choice without any further event.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesPartialExplicit,\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const firstVisitImplicit: Flow.StepExample = {\n title: 'First visit implicit (suppressed)',\n description:\n 'A first-visit snapshot carrying only implicit history is suppressed by the default explicitOnly gate, so no consent command is emitted.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesFirstVisitImplicit,\n out: [],\n};\n\nexport const consentChange: Flow.StepExample = {\n title: 'Consent change via CMP event',\n description:\n 'An ACCEPT_ALL decision fires UC_UI_CMP_EVENT; the source re-reads the services and emits the updated consent.',\n trigger: { type: 'consent', options: { dispatch: 'cmp' } },\n in: servicesFullExplicit,\n out: [['elb', 'walker consent', fullConsentMapped]],\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n title: 'Category map override',\n description:\n 'A custom categoryMap remaps essential to functional and functional to analytics before emitting the walker consent command.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesFullExplicit,\n mapping: {\n settings: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n },\n out: [['elb', 'walker consent', fullConsentCustomMapped]],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\ninterface UsercentricsContent {\n event: string;\n type: string;\n action?: string;\n ucCategory?: Record<string, boolean | unknown>;\n [service: string]: unknown;\n}\n\nconst createTrigger: Trigger.CreateFn<UsercentricsContent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<UsercentricsContent, void> =\n (type?: string, opts?: unknown) => async (content: UsercentricsContent) => {\n // Lazy startFlow — source registers ucEvent listener during init\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n }\n\n // Dispatch the CMP event — source's listener catches it\n const eventName =\n (opts as { eventName?: string })?.eventName || 'ucEvent';\n window.dispatchEvent(new CustomEvent(eventName, { detail: content }));\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Dispatches ucEvent CustomEvent after source init (post-init trigger). */\nconst trigger = (\n input: unknown,\n env: Record<string, unknown>,\n): void | (() => void) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n (env.window as Window).dispatchEvent(\n new CustomEvent('ucEvent', { detail: input }),\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 * Usercentrics 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 publish when the user has actively decided (V3: consent.type EXPLICIT; V2: an EXPLICIT entry in service consent history). Implicit/default page-load states are suppressed. Set false to publish any snapshot including implicit. Default: true.',\n )\n .optional(),\n })\n .meta({\n id: 'UsercentricsSettings',\n title: 'Settings',\n description: 'Settings for the Usercentrics 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;;;ACiBO,IAAM,uBAAgD;AAAA,EAC3D;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE;AAAA,EACzE;AAAA,EACA;AAAA,IACE,cAAc;AAAA,IACd,SAAS,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J,CAAC,MAAe,SAAmB,OAAO,YAAiC;AAjB/E;AAmBM,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,UAAM,aACH,6BAAiC,cAAa;AACjD,WAAO,cAAc,IAAI,YAAY,WAAW,EAAE,QAAQ,QAAQ,CAAC,CAAC;AAAA,EACtE;AAEF,SAAO;AAAA,IACL,IAAI,OAAO;AACT,aAAO;AAAA,IACT;AAAA,IACA,SAAAA;AAAA,EACF;AACF;AAGA,IAAM,UAAU,CACd,OACA,QACwB;AACxB,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,SAAO,MAAM;AACX,IAAC,IAAI,OAAkB;AAAA,MACrB,IAAI,YAAY,WAAW,EAAE,QAAQ,MAAM,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;;;ACjDA;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;AACd,CAAC,EACA,KAAK;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf,CAAC;;;ADlBI,IAAM,eAAW,yBAAY,cAAc;","names":["trigger","import_dev"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var t=Object.defineProperty,e=(e,i)=>{for(var s in i)t(e,s,{get:i[s],enumerable:!0})},i={};e(i,{createMockElbFn:()=>g,createTrigger:()=>b,fullConsentCustomMapped:()=>p,fullConsentMapped:()=>r,minimalConsentMapped:()=>l,noopLogger:()=>y,partialConsentMapped:()=>c,servicesFirstVisitImplicit:()=>o,servicesFullExplicit:()=>s,servicesMinimalExplicit:()=>n,servicesPartialExplicit:()=>a,step:()=>d,trigger:()=>x});var s=[{categorySlug:"essential",consent:{status:!0,history:[{type:"explicit",status:!0}]}},{categorySlug:"functional",consent:{status:!0,history:[{type:"explicit",status:!0}]}},{categorySlug:"marketing",consent:{status:!0,history:[{type:"explicit",status:!0}]}}],n=[{categorySlug:"essential",consent:{status:!0,history:[{type:"explicit",status:!0}]}},{categorySlug:"functional",consent:{status:!1,history:[{type:"explicit",status:!1}]}},{categorySlug:"marketing",consent:{status:!1,history:[{type:"explicit",status:!1}]}}],a=[{categorySlug:"essential",consent:{status:!0,history:[{type:"explicit",status:!0}]}},{categorySlug:"functional",consent:{status:!0,history:[{type:"explicit",status:!0}]}},{categorySlug:"marketing",consent:{status:!1,history:[{type:"explicit",status:!1}]}}],o=[{categorySlug:"essential",consent:{status:!0,history:[{type:"implicit",status:!0}]}},{categorySlug:"functional",consent:{status:!1,history:[{type:"implicit",status:!1}]}},{categorySlug:"marketing",consent:{status:!1,history:[{type:"implicit",status:!1}]}}],r={essential:!0,functional:!0,marketing:!0},c={essential:!0,functional:!0,marketing:!1},l={essential:!0,functional:!1,marketing:!1},p={functional:!0,analytics:!0,marketing:!0},u=()=>{},g=()=>()=>Promise.resolve({ok:!0}),y={error:u,warn:u,info:u,debug:u,throw:t=>{throw"string"==typeof t?new Error(t):t},json:u,scope:()=>y},d={};e(d,{categoryMapOverride:()=>k,consentChange:()=>w,firstVisitImplicit:()=>v,fullConsent:()=>m,minimalConsent:()=>h,returningVisitor:()=>f});var m={title:"Full consent",description:"Usercentrics reports every category accepted via an explicit decision; the source emits a walker consent command granting essential, functional, and marketing.",trigger:{type:"consent",options:{dispatch:"init"}},in:s,out:[["elb","walker consent",r]]},h={title:"Minimal consent",description:'A "Deny all" explicit decision leaves only essential granted; functional and marketing are emitted as false.',trigger:{type:"consent",options:{dispatch:"init"}},in:n,out:[["elb","walker consent",l]]},f={title:"Returning visitor static read",description:"When the CMP is already initialized with a stored explicit decision, the static read at init re-publishes that choice without any further event.",trigger:{type:"consent",options:{dispatch:"init"}},in:a,out:[["elb","walker consent",{essential:!0,functional:!0,marketing:!1}]]},v={title:"First visit implicit (suppressed)",description:"A first-visit snapshot carrying only implicit history is suppressed by the default explicitOnly gate, so no consent command is emitted.",trigger:{type:"consent",options:{dispatch:"init"}},in:o,out:[]},w={title:"Consent change via CMP event",description:"An ACCEPT_ALL decision fires UC_UI_CMP_EVENT; the source re-reads the services and emits the updated consent.",trigger:{type:"consent",options:{dispatch:"cmp"}},in:s,out:[["elb","walker consent",r]]},k={title:"Category map override",description:"A custom categoryMap remaps essential to functional and functional to analytics before emitting the walker consent command.",trigger:{type:"consent",options:{dispatch:"init"}},in:s,mapping:{settings:{categoryMap:{essential:"functional",functional:"analytics"}}},out:[["elb","walker consent",p]]};import{startFlow as C}from"@walkeros/collector";var b=async t=>{let e;return{get flow(){return e},trigger:(i,s)=>async i=>{var n;if(!e){const i=await C({...t,run:null==(n=t.run)||n});e={collector:i.collector,elb:i.elb}}const a=(null==s?void 0:s.eventName)||"ucEvent";window.dispatchEvent(new CustomEvent(a,{detail:i}))}}},x=(t,e)=>{if(t&&"object"==typeof t)return()=>{e.window.dispatchEvent(new CustomEvent("ucEvent",{detail:t}))}},S={};e(S,{SettingsSchema:()=>P,settings:()=>I});import{zodToSchema as M}from"@walkeros/core/dev";import{z as E}from"@walkeros/core/dev";var P=E.object({categoryMap:E.record(E.string(),E.string()).describe("Map the CMP's consent categories (keys) to walkerOS consent groups (values).").optional(),explicitOnly:E.boolean().describe("Only publish when the user has actively decided (V3: consent.type EXPLICIT; V2: an EXPLICIT entry in service consent history). Implicit/default page-load states are suppressed. Set false to publish any snapshot including implicit. Default: true.").optional()}).meta({id:"UsercentricsSettings",title:"Settings",description:"Settings for the Usercentrics CMP source."}),I=M(P);export{i 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","../src/schemas/index.ts","../src/schemas/settings.ts"],"sourcesContent":["export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { UsercentricsEventDetail } from '../types';\n\n/**\n * Example Usercentrics consent event detail inputs.\n *\n * These represent real event.detail payloads from Usercentrics CMP.\n */\n\n/**\n * Full consent - user accepted all categories (explicit)\n */\nexport const fullConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': true,\n};\n\n/**\n * Partial consent - user accepted only essential and functional (explicit)\n */\nexport const partialConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Minimal consent - user denied everything except essential (explicit)\n */\nexport const minimalConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Implicit consent - page load with default consent state\n * (not an explicit user choice)\n */\nexport const implicitConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'implicit',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n 'Google Analytics': false,\n 'Google Ads Remarketing': false,\n};\n\n/**\n * Explicit consent with uppercase type field (Usercentrics docs are\n * inconsistent about casing - some show 'EXPLICIT', others 'explicit')\n */\nexport const fullConsentUpperCase: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'EXPLICIT',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n};\n\n/**\n * Service-level consent - ucCategory has mixed types (non-boolean values\n * indicate individual service-level choice rather than group-level)\n */\nexport const serviceLevelConsent: UsercentricsEventDetail = {\n event: 'consent_status',\n type: 'explicit',\n action: 'onUpdateServices',\n ucCategory: {\n essential: true,\n functional: 'partial', // Non-boolean indicates mixed service choices\n marketing: 'partial',\n },\n 'Google Analytics': true,\n 'Google Ads Remarketing': false,\n Hotjar: true,\n};\n\n/**\n * Non-consent event (should be ignored)\n */\nexport const nonConsentEvent: UsercentricsEventDetail = {\n event: 'other_event',\n type: 'explicit',\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing Usercentrics event details\n * with no category mapping configured (pass-through).\n */\n\n/**\n * Full consent - all categories true (group-level)\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional true, marketing false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential true\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with custom category mapping applied\n * (essential->functional, functional->functional, marketing->marketing)\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n marketing: true,\n};\n\n/**\n * Service-level consent - individual service booleans + boolean ucCategory entries\n * (services normalized: lowercase, spaces to underscores)\n * (ucCategory boolean entries mapped through categoryMap)\n */\nexport const serviceLevelMapped: WalkerOS.Consent = {\n essential: true,\n google_analytics: true,\n google_ads_remarketing: false,\n hotjar: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\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","import type { Flow } from '@walkeros/core';\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'A Usercentrics onAcceptAllServices event emits a walker consent command with essential, functional, and marketing granted.',\n trigger: { type: 'consent' },\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onAcceptAllServices',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: true,\n marketing: true,\n },\n ],\n ],\n};\n\nexport const minimalConsent: Flow.StepExample = {\n title: 'Minimal consent',\n description:\n 'A Usercentrics onDenyAllServices event emits a walker consent command with only essential granted.',\n trigger: { type: 'consent' },\n in: {\n event: 'consent_status',\n type: 'explicit',\n action: 'onDenyAllServices',\n ucCategory: {\n essential: true,\n functional: false,\n marketing: false,\n },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: 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 essential to functional and functional to analytics',\n trigger: { type: 'consent' },\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: false,\n },\n },\n mapping: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n functional: true,\n analytics: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const customEventName: Flow.StepExample = {\n title: 'Custom event name',\n description: 'Using UC_SDK_EVENT instead of ucEvent for Usercentrics SDK v2',\n trigger: { type: 'consent', options: { eventName: 'UC_SDK_EVENT' } },\n in: {\n event: 'consent_status',\n type: 'explicit',\n ucCategory: {\n essential: true,\n functional: true,\n marketing: true,\n },\n },\n mapping: { eventName: 'UC_SDK_EVENT' },\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: true,\n marketing: true,\n },\n ],\n ],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\ninterface UsercentricsContent {\n event: string;\n type: string;\n action?: string;\n ucCategory?: Record<string, boolean | unknown>;\n [service: string]: unknown;\n}\n\nconst createTrigger: Trigger.CreateFn<UsercentricsContent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<UsercentricsContent, void> =\n (type?: string, opts?: unknown) => async (content: UsercentricsContent) => {\n // Lazy startFlow — source registers ucEvent listener during init\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n }\n\n // Dispatch the CMP event — source's listener catches it\n const eventName =\n (opts as { eventName?: string })?.eventName || 'ucEvent';\n window.dispatchEvent(new CustomEvent(eventName, { detail: content }));\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Dispatches ucEvent CustomEvent after source init (post-init trigger). */\nconst trigger = (\n input: unknown,\n env: Record<string, unknown>,\n): void | (() => void) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n (env.window as Window).dispatchEvent(\n new CustomEvent('ucEvent', { detail: input }),\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 * Usercentrics source settings schema\n */\nexport const SettingsSchema = z\n .object({\n eventName: z\n .string()\n .describe(\n \"Window event name to listen for, configured in the Usercentrics admin (Implementation > Data Layer & Events). Use 'UC_SDK_EVENT' for the built-in Browser SDK event. Default: 'ucEvent'.\",\n )\n .optional(),\n\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_status events where type is 'explicit'. Ignores implicit/default page-load events. Default: true.\",\n )\n .optional(),\n })\n .meta({\n id: 'UsercentricsSettings',\n title: 'Settings',\n description: 'Settings for the Usercentrics 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;;;ACWO,IAAM,cAAuC;AAAA,EAClD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAKO,IAAM,iBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,EACb;AAAA,EACA,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;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M,UAAU,CACd,OACA,QACwB;AACxB,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU;AACzC,SAAO,MAAM;AACX,IAAC,IAAI,OAAkB;AAAA,MACrB,IAAI,YAAY,WAAW,EAAE,QAAQ,MAAM,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;;;ACjDA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAKX,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,WAAW,EACR,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,aAAa,EACV,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,cAAc,EACX,QAAQ,EACR;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","minimalConsent","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":["export * from './inputs';\nexport * from './outputs';\nexport * from './env';\nexport * as step from './step';\nexport { createTrigger, trigger } from './trigger';\n","import type { UsercentricsV2Service } from '../types';\n\n/**\n * Example Usercentrics V2 service inputs.\n *\n * These mirror the shape returned by `window.UC_UI.getServicesBaseInfo()`:\n * an array of services, each carrying a `categorySlug`, optional display\n * `name`, and a `consent` block with the current `status` plus a decision\n * `history`. The adapter derives the explicit/implicit gate from whether any\n * history entry is `explicit`, and aggregates services into group-level\n * consent via strict AND per `categorySlug`.\n */\n\n/**\n * Full consent - every category accepted via an explicit decision\n * (user clicked \"Accept all\").\n */\nexport const servicesFullExplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n];\n\n/**\n * Minimal consent - only essential accepted, others denied via an explicit\n * decision (user clicked \"Deny all\").\n */\nexport const servicesMinimalExplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: false, history: [{ type: 'explicit', status: false }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: false, history: [{ type: 'explicit', status: false }] },\n },\n];\n\n/**\n * Partial consent - essential and functional accepted, marketing denied,\n * all via an explicit decision (user saved a custom selection).\n */\nexport const servicesPartialExplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: true, history: [{ type: 'explicit', status: true }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: false, history: [{ type: 'explicit', status: false }] },\n },\n];\n\n/**\n * First-visit implicit state - the CMP reports page-load defaults with only\n * implicit history. The default `explicitOnly` gate suppresses this, so no\n * consent command is emitted.\n */\nexport const servicesFirstVisitImplicit: UsercentricsV2Service[] = [\n {\n categorySlug: 'essential',\n consent: { status: true, history: [{ type: 'implicit', status: true }] },\n },\n {\n categorySlug: 'functional',\n consent: { status: false, history: [{ type: 'implicit', status: false }] },\n },\n {\n categorySlug: 'marketing',\n consent: { status: false, history: [{ type: 'implicit', status: false }] },\n },\n];\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state emitted via `elb('walker consent', state)`\n * after the V2 adapter aggregates `getServicesBaseInfo()` into group-level\n * consent (no category mapping configured: pass-through by `categorySlug`).\n */\n\n/**\n * Full consent - all categories granted.\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: true,\n};\n\n/**\n * Partial consent - essential and functional granted, marketing denied.\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: true,\n marketing: false,\n};\n\n/**\n * Minimal consent - only essential granted.\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n essential: true,\n functional: false,\n marketing: false,\n};\n\n/**\n * Full consent with a custom category mapping applied\n * (essential->functional, functional->analytics).\n */\nexport const fullConsentCustomMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n","import type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for Usercentrics source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\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","import type { Flow } from '@walkeros/core';\nimport {\n servicesFullExplicit,\n servicesMinimalExplicit,\n servicesPartialExplicit,\n servicesFirstVisitImplicit,\n} from './inputs';\nimport {\n fullConsentMapped,\n minimalConsentMapped,\n fullConsentCustomMapped,\n} from './outputs';\n\n/**\n * Step examples for the Usercentrics V2 path.\n *\n * `in` is the array returned by `window.UC_UI.getServicesBaseInfo()`. The test\n * runner attaches it as the V2 API, then drives the official trigger named in\n * `trigger.options.dispatch`:\n * - 'init' (default): UC_UI is present when the source runs, so the static\n * read at init emits the snapshot (also the `UC_UI_INITIALIZED` path).\n * - 'cmp': UC_UI is attached only after init, then a `UC_UI_CMP_EVENT`\n * decision (ACCEPT_ALL) re-reads and emits — the consent-change path.\n */\n\nexport const fullConsent: Flow.StepExample = {\n title: 'Full consent',\n description:\n 'Usercentrics reports every category accepted via an explicit decision; the source emits a walker consent command granting essential, functional, and marketing.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesFullExplicit,\n out: [['elb', 'walker consent', fullConsentMapped]],\n};\n\nexport const minimalConsent: Flow.StepExample = {\n title: 'Minimal consent',\n description:\n 'A \"Deny all\" explicit decision leaves only essential granted; functional and marketing are emitted as false.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesMinimalExplicit,\n out: [['elb', 'walker consent', minimalConsentMapped]],\n};\n\nexport const returningVisitor: Flow.StepExample = {\n title: 'Returning visitor static read',\n description:\n 'When the CMP is already initialized with a stored explicit decision, the static read at init re-publishes that choice without any further event.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesPartialExplicit,\n out: [\n [\n 'elb',\n 'walker consent',\n {\n essential: true,\n functional: true,\n marketing: false,\n },\n ],\n ],\n};\n\nexport const firstVisitImplicit: Flow.StepExample = {\n title: 'First visit implicit (suppressed)',\n description:\n 'A first-visit snapshot carrying only implicit history is suppressed by the default explicitOnly gate, so no consent command is emitted.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesFirstVisitImplicit,\n out: [],\n};\n\nexport const consentChange: Flow.StepExample = {\n title: 'Consent change via CMP event',\n description:\n 'An ACCEPT_ALL decision fires UC_UI_CMP_EVENT; the source re-reads the services and emits the updated consent.',\n trigger: { type: 'consent', options: { dispatch: 'cmp' } },\n in: servicesFullExplicit,\n out: [['elb', 'walker consent', fullConsentMapped]],\n};\n\nexport const categoryMapOverride: Flow.StepExample = {\n title: 'Category map override',\n description:\n 'A custom categoryMap remaps essential to functional and functional to analytics before emitting the walker consent command.',\n trigger: { type: 'consent', options: { dispatch: 'init' } },\n in: servicesFullExplicit,\n mapping: {\n settings: {\n categoryMap: { essential: 'functional', functional: 'analytics' },\n },\n },\n out: [['elb', 'walker consent', fullConsentCustomMapped]],\n};\n","import type { Trigger, Collector } from '@walkeros/core';\nimport { startFlow } from '@walkeros/collector';\n\ninterface UsercentricsContent {\n event: string;\n type: string;\n action?: string;\n ucCategory?: Record<string, boolean | unknown>;\n [service: string]: unknown;\n}\n\nconst createTrigger: Trigger.CreateFn<UsercentricsContent, void> = async (\n config: Collector.InitConfig,\n) => {\n let flow: Trigger.FlowHandle | undefined;\n\n const trigger: Trigger.Fn<UsercentricsContent, void> =\n (type?: string, opts?: unknown) => async (content: UsercentricsContent) => {\n // Lazy startFlow — source registers ucEvent listener during init\n if (!flow) {\n const result = await startFlow({ ...config, run: config.run ?? true });\n flow = { collector: result.collector, elb: result.elb };\n }\n\n // Dispatch the CMP event — source's listener catches it\n const eventName =\n (opts as { eventName?: string })?.eventName || 'ucEvent';\n window.dispatchEvent(new CustomEvent(eventName, { detail: content }));\n };\n\n return {\n get flow() {\n return flow;\n },\n trigger,\n };\n};\n\n/** Dispatches ucEvent CustomEvent after source init (post-init trigger). */\nconst trigger = (\n input: unknown,\n env: Record<string, unknown>,\n): void | (() => void) => {\n if (!input || typeof input !== 'object') return;\n return () => {\n (env.window as Window).dispatchEvent(\n new CustomEvent('ucEvent', { detail: input }),\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 * Usercentrics 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 publish when the user has actively decided (V3: consent.type EXPLICIT; V2: an EXPLICIT entry in service consent history). Implicit/default page-load states are suppressed. Set false to publish any snapshot including implicit. Default: true.',\n )\n .optional(),\n })\n .meta({\n id: 'UsercentricsSettings',\n title: 'Settings',\n description: 'Settings for the Usercentrics 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;;;ACiBO,IAAM,uBAAgD;AAAA,EAC3D;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE;AAAA,EACzE;AAAA,EACA;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE;AAAA,EACzE;AAAA,EACA;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE;AAAA,EACzE;AACF;AAMO,IAAM,0BAAmD;AAAA,EAC9D;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE;AAAA,EACzE;AAAA,EACA;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,OAAO,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,MAAM,CAAC,EAAE;AAAA,EAC3E;AAAA,EACA;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,OAAO,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,MAAM,CAAC,EAAE;AAAA,EAC3E;AACF;AAMO,IAAM,0BAAmD;AAAA,EAC9D;AAAA,IACE,cAAc;AAAA,IACd,SAAS,EAAE,QAAQ,MAAM,SAAS,CAAC,EAAE,MAAM,YAAY,QAAQ,KAAK,CAAC,EAAE;AAAA,EACzE;AAAA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AC7B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAEZ,cAAc,EACX,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC,EACA,KAAK;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,aAAa;AACf,CAAC;;;ADlBI,IAAM,WAAW,YAAY,cAAc;","names":["trigger"]}
|
|
@@ -29,9 +29,20 @@ interface UsercentricsEventDetail {
|
|
|
29
29
|
declare global {
|
|
30
30
|
interface WindowEventMap {
|
|
31
31
|
ucEvent: CustomEvent<UsercentricsEventDetail>;
|
|
32
|
+
UC_UI_INITIALIZED: Event;
|
|
32
33
|
UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
/** Usercentrics CONSENT_TYPE values (history entry type / V3 consent type). */
|
|
37
|
+
type UsercentricsConsentType = 'explicit' | 'implicit';
|
|
38
|
+
/** A single entry in a V2 service's consent history (getServicesBaseInfo). */
|
|
39
|
+
interface UsercentricsV2ConsentHistoryEntry {
|
|
40
|
+
type: UsercentricsConsentType;
|
|
41
|
+
status: boolean;
|
|
42
|
+
/** CONSENT_ACTION, e.g. 'onAcceptAllServices' | 'onInitialPageLoad'. Not read for the gate. */
|
|
43
|
+
action?: string;
|
|
44
|
+
timestamp?: number;
|
|
45
|
+
}
|
|
35
46
|
/**
|
|
36
47
|
* Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
|
|
37
48
|
* Only the fields we use are typed - minimal surface, not a full V2 API mirror.
|
|
@@ -39,9 +50,13 @@ declare global {
|
|
|
39
50
|
interface UsercentricsV2Service {
|
|
40
51
|
/** Category slug: 'essential' | 'functional' | 'marketing' | custom */
|
|
41
52
|
categorySlug: string;
|
|
53
|
+
/** Service display name (used for service-level consent keys) */
|
|
54
|
+
name?: string;
|
|
42
55
|
/** Consent state for this service */
|
|
43
56
|
consent: {
|
|
44
57
|
status: boolean;
|
|
58
|
+
/** Consent decision history; an 'explicit' entry proves a real user decision. */
|
|
59
|
+
history?: UsercentricsV2ConsentHistoryEntry[];
|
|
45
60
|
};
|
|
46
61
|
}
|
|
47
62
|
/**
|
|
@@ -53,6 +68,7 @@ interface UsercentricsV2Service {
|
|
|
53
68
|
interface UsercentricsV2Api {
|
|
54
69
|
isInitialized?: () => boolean;
|
|
55
70
|
getServicesBaseInfo?: () => UsercentricsV2Service[];
|
|
71
|
+
getServicesFullInfo?: () => Promise<UsercentricsV2Service[]>;
|
|
56
72
|
areAllConsentsAccepted?: () => boolean;
|
|
57
73
|
}
|
|
58
74
|
/**
|
|
@@ -99,8 +115,9 @@ interface UsercentricsV3Api {
|
|
|
99
115
|
* `source: 'CMP'` + a decision `type` tells us a user action has been taken.
|
|
100
116
|
*/
|
|
101
117
|
interface UsercentricsV3CmpEventDetail {
|
|
102
|
-
source?: string;
|
|
118
|
+
source?: 'none' | 'button' | 'first' | 'second' | 'embeddings' | '__ucCmp' | string;
|
|
103
119
|
type?: string;
|
|
120
|
+
abTestVariant?: string;
|
|
104
121
|
}
|
|
105
122
|
declare global {
|
|
106
123
|
interface Window {
|
|
@@ -120,71 +137,61 @@ declare global {
|
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
/**
|
|
123
|
-
* Example Usercentrics
|
|
140
|
+
* Example Usercentrics V2 service inputs.
|
|
124
141
|
*
|
|
125
|
-
* These
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
142
|
+
* These mirror the shape returned by `window.UC_UI.getServicesBaseInfo()`:
|
|
143
|
+
* an array of services, each carrying a `categorySlug`, optional display
|
|
144
|
+
* `name`, and a `consent` block with the current `status` plus a decision
|
|
145
|
+
* `history`. The adapter derives the explicit/implicit gate from whether any
|
|
146
|
+
* history entry is `explicit`, and aggregates services into group-level
|
|
147
|
+
* consent via strict AND per `categorySlug`.
|
|
129
148
|
*/
|
|
130
|
-
declare const fullConsent$1: UsercentricsEventDetail;
|
|
131
149
|
/**
|
|
132
|
-
*
|
|
150
|
+
* Full consent - every category accepted via an explicit decision
|
|
151
|
+
* (user clicked "Accept all").
|
|
133
152
|
*/
|
|
134
|
-
declare const
|
|
153
|
+
declare const servicesFullExplicit: UsercentricsV2Service[];
|
|
135
154
|
/**
|
|
136
|
-
* Minimal consent -
|
|
155
|
+
* Minimal consent - only essential accepted, others denied via an explicit
|
|
156
|
+
* decision (user clicked "Deny all").
|
|
137
157
|
*/
|
|
138
|
-
declare const
|
|
158
|
+
declare const servicesMinimalExplicit: UsercentricsV2Service[];
|
|
139
159
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
160
|
+
* Partial consent - essential and functional accepted, marketing denied,
|
|
161
|
+
* all via an explicit decision (user saved a custom selection).
|
|
142
162
|
*/
|
|
143
|
-
declare const
|
|
163
|
+
declare const servicesPartialExplicit: UsercentricsV2Service[];
|
|
144
164
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
165
|
+
* First-visit implicit state - the CMP reports page-load defaults with only
|
|
166
|
+
* implicit history. The default `explicitOnly` gate suppresses this, so no
|
|
167
|
+
* consent command is emitted.
|
|
147
168
|
*/
|
|
148
|
-
declare const
|
|
149
|
-
/**
|
|
150
|
-
* Service-level consent - ucCategory has mixed types (non-boolean values
|
|
151
|
-
* indicate individual service-level choice rather than group-level)
|
|
152
|
-
*/
|
|
153
|
-
declare const serviceLevelConsent: UsercentricsEventDetail;
|
|
154
|
-
/**
|
|
155
|
-
* Non-consent event (should be ignored)
|
|
156
|
-
*/
|
|
157
|
-
declare const nonConsentEvent: UsercentricsEventDetail;
|
|
169
|
+
declare const servicesFirstVisitImplicit: UsercentricsV2Service[];
|
|
158
170
|
|
|
159
171
|
/**
|
|
160
172
|
* Expected walkerOS consent outputs.
|
|
161
173
|
*
|
|
162
|
-
* These represent the consent state
|
|
163
|
-
*
|
|
174
|
+
* These represent the consent state emitted via `elb('walker consent', state)`
|
|
175
|
+
* after the V2 adapter aggregates `getServicesBaseInfo()` into group-level
|
|
176
|
+
* consent (no category mapping configured: pass-through by `categorySlug`).
|
|
164
177
|
*/
|
|
165
178
|
/**
|
|
166
|
-
* Full consent - all categories
|
|
179
|
+
* Full consent - all categories granted.
|
|
167
180
|
*/
|
|
168
181
|
declare const fullConsentMapped: WalkerOS.Consent;
|
|
169
182
|
/**
|
|
170
|
-
* Partial consent - essential and functional
|
|
183
|
+
* Partial consent - essential and functional granted, marketing denied.
|
|
171
184
|
*/
|
|
172
185
|
declare const partialConsentMapped: WalkerOS.Consent;
|
|
173
186
|
/**
|
|
174
|
-
* Minimal consent - only essential
|
|
187
|
+
* Minimal consent - only essential granted.
|
|
175
188
|
*/
|
|
176
189
|
declare const minimalConsentMapped: WalkerOS.Consent;
|
|
177
190
|
/**
|
|
178
|
-
* Full consent with custom category mapping applied
|
|
179
|
-
* (essential->functional, functional->
|
|
191
|
+
* Full consent with a custom category mapping applied
|
|
192
|
+
* (essential->functional, functional->analytics).
|
|
180
193
|
*/
|
|
181
194
|
declare const fullConsentCustomMapped: WalkerOS.Consent;
|
|
182
|
-
/**
|
|
183
|
-
* Service-level consent - individual service booleans + boolean ucCategory entries
|
|
184
|
-
* (services normalized: lowercase, spaces to underscores)
|
|
185
|
-
* (ucCategory boolean entries mapped through categoryMap)
|
|
186
|
-
*/
|
|
187
|
-
declare const serviceLevelMapped: WalkerOS.Consent;
|
|
188
195
|
|
|
189
196
|
/**
|
|
190
197
|
* Create a properly typed elb/push function mock
|
|
@@ -195,17 +202,32 @@ declare const createMockElbFn: () => Elb.Fn;
|
|
|
195
202
|
*/
|
|
196
203
|
declare const noopLogger: Logger.Instance;
|
|
197
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Step examples for the Usercentrics V2 path.
|
|
207
|
+
*
|
|
208
|
+
* `in` is the array returned by `window.UC_UI.getServicesBaseInfo()`. The test
|
|
209
|
+
* runner attaches it as the V2 API, then drives the official trigger named in
|
|
210
|
+
* `trigger.options.dispatch`:
|
|
211
|
+
* - 'init' (default): UC_UI is present when the source runs, so the static
|
|
212
|
+
* read at init emits the snapshot (also the `UC_UI_INITIALIZED` path).
|
|
213
|
+
* - 'cmp': UC_UI is attached only after init, then a `UC_UI_CMP_EVENT`
|
|
214
|
+
* decision (ACCEPT_ALL) re-reads and emits — the consent-change path.
|
|
215
|
+
*/
|
|
198
216
|
declare const fullConsent: Flow.StepExample;
|
|
199
217
|
declare const minimalConsent: Flow.StepExample;
|
|
218
|
+
declare const returningVisitor: Flow.StepExample;
|
|
219
|
+
declare const firstVisitImplicit: Flow.StepExample;
|
|
220
|
+
declare const consentChange: Flow.StepExample;
|
|
200
221
|
declare const categoryMapOverride: Flow.StepExample;
|
|
201
|
-
declare const customEventName: Flow.StepExample;
|
|
202
222
|
|
|
203
223
|
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
204
|
-
declare const
|
|
224
|
+
declare const step_consentChange: typeof consentChange;
|
|
225
|
+
declare const step_firstVisitImplicit: typeof firstVisitImplicit;
|
|
205
226
|
declare const step_fullConsent: typeof fullConsent;
|
|
206
227
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
228
|
+
declare const step_returningVisitor: typeof returningVisitor;
|
|
207
229
|
declare namespace step {
|
|
208
|
-
export { step_categoryMapOverride as categoryMapOverride,
|
|
230
|
+
export { step_categoryMapOverride as categoryMapOverride, step_consentChange as consentChange, step_firstVisitImplicit as firstVisitImplicit, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent, step_returningVisitor as returningVisitor };
|
|
209
231
|
}
|
|
210
232
|
|
|
211
233
|
interface UsercentricsContent {
|
|
@@ -219,4 +241,4 @@ declare const createTrigger: Trigger.CreateFn<UsercentricsContent, void>;
|
|
|
219
241
|
/** Dispatches ucEvent CustomEvent after source init (post-init trigger). */
|
|
220
242
|
declare const trigger: (input: unknown, env: Record<string, unknown>) => void | (() => void);
|
|
221
243
|
|
|
222
|
-
export { createMockElbFn, createTrigger,
|
|
244
|
+
export { createMockElbFn, createTrigger, fullConsentCustomMapped, fullConsentMapped, minimalConsentMapped, noopLogger, partialConsentMapped, servicesFirstVisitImplicit, servicesFullExplicit, servicesMinimalExplicit, servicesPartialExplicit, step, trigger };
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -29,9 +29,20 @@ interface UsercentricsEventDetail {
|
|
|
29
29
|
declare global {
|
|
30
30
|
interface WindowEventMap {
|
|
31
31
|
ucEvent: CustomEvent<UsercentricsEventDetail>;
|
|
32
|
+
UC_UI_INITIALIZED: Event;
|
|
32
33
|
UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
/** Usercentrics CONSENT_TYPE values (history entry type / V3 consent type). */
|
|
37
|
+
type UsercentricsConsentType = 'explicit' | 'implicit';
|
|
38
|
+
/** A single entry in a V2 service's consent history (getServicesBaseInfo). */
|
|
39
|
+
interface UsercentricsV2ConsentHistoryEntry {
|
|
40
|
+
type: UsercentricsConsentType;
|
|
41
|
+
status: boolean;
|
|
42
|
+
/** CONSENT_ACTION, e.g. 'onAcceptAllServices' | 'onInitialPageLoad'. Not read for the gate. */
|
|
43
|
+
action?: string;
|
|
44
|
+
timestamp?: number;
|
|
45
|
+
}
|
|
35
46
|
/**
|
|
36
47
|
* Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
|
|
37
48
|
* Only the fields we use are typed - minimal surface, not a full V2 API mirror.
|
|
@@ -39,9 +50,13 @@ declare global {
|
|
|
39
50
|
interface UsercentricsV2Service {
|
|
40
51
|
/** Category slug: 'essential' | 'functional' | 'marketing' | custom */
|
|
41
52
|
categorySlug: string;
|
|
53
|
+
/** Service display name (used for service-level consent keys) */
|
|
54
|
+
name?: string;
|
|
42
55
|
/** Consent state for this service */
|
|
43
56
|
consent: {
|
|
44
57
|
status: boolean;
|
|
58
|
+
/** Consent decision history; an 'explicit' entry proves a real user decision. */
|
|
59
|
+
history?: UsercentricsV2ConsentHistoryEntry[];
|
|
45
60
|
};
|
|
46
61
|
}
|
|
47
62
|
/**
|
|
@@ -53,6 +68,7 @@ interface UsercentricsV2Service {
|
|
|
53
68
|
interface UsercentricsV2Api {
|
|
54
69
|
isInitialized?: () => boolean;
|
|
55
70
|
getServicesBaseInfo?: () => UsercentricsV2Service[];
|
|
71
|
+
getServicesFullInfo?: () => Promise<UsercentricsV2Service[]>;
|
|
56
72
|
areAllConsentsAccepted?: () => boolean;
|
|
57
73
|
}
|
|
58
74
|
/**
|
|
@@ -99,8 +115,9 @@ interface UsercentricsV3Api {
|
|
|
99
115
|
* `source: 'CMP'` + a decision `type` tells us a user action has been taken.
|
|
100
116
|
*/
|
|
101
117
|
interface UsercentricsV3CmpEventDetail {
|
|
102
|
-
source?: string;
|
|
118
|
+
source?: 'none' | 'button' | 'first' | 'second' | 'embeddings' | '__ucCmp' | string;
|
|
103
119
|
type?: string;
|
|
120
|
+
abTestVariant?: string;
|
|
104
121
|
}
|
|
105
122
|
declare global {
|
|
106
123
|
interface Window {
|
|
@@ -120,71 +137,61 @@ declare global {
|
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
/**
|
|
123
|
-
* Example Usercentrics
|
|
140
|
+
* Example Usercentrics V2 service inputs.
|
|
124
141
|
*
|
|
125
|
-
* These
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
142
|
+
* These mirror the shape returned by `window.UC_UI.getServicesBaseInfo()`:
|
|
143
|
+
* an array of services, each carrying a `categorySlug`, optional display
|
|
144
|
+
* `name`, and a `consent` block with the current `status` plus a decision
|
|
145
|
+
* `history`. The adapter derives the explicit/implicit gate from whether any
|
|
146
|
+
* history entry is `explicit`, and aggregates services into group-level
|
|
147
|
+
* consent via strict AND per `categorySlug`.
|
|
129
148
|
*/
|
|
130
|
-
declare const fullConsent$1: UsercentricsEventDetail;
|
|
131
149
|
/**
|
|
132
|
-
*
|
|
150
|
+
* Full consent - every category accepted via an explicit decision
|
|
151
|
+
* (user clicked "Accept all").
|
|
133
152
|
*/
|
|
134
|
-
declare const
|
|
153
|
+
declare const servicesFullExplicit: UsercentricsV2Service[];
|
|
135
154
|
/**
|
|
136
|
-
* Minimal consent -
|
|
155
|
+
* Minimal consent - only essential accepted, others denied via an explicit
|
|
156
|
+
* decision (user clicked "Deny all").
|
|
137
157
|
*/
|
|
138
|
-
declare const
|
|
158
|
+
declare const servicesMinimalExplicit: UsercentricsV2Service[];
|
|
139
159
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
160
|
+
* Partial consent - essential and functional accepted, marketing denied,
|
|
161
|
+
* all via an explicit decision (user saved a custom selection).
|
|
142
162
|
*/
|
|
143
|
-
declare const
|
|
163
|
+
declare const servicesPartialExplicit: UsercentricsV2Service[];
|
|
144
164
|
/**
|
|
145
|
-
*
|
|
146
|
-
*
|
|
165
|
+
* First-visit implicit state - the CMP reports page-load defaults with only
|
|
166
|
+
* implicit history. The default `explicitOnly` gate suppresses this, so no
|
|
167
|
+
* consent command is emitted.
|
|
147
168
|
*/
|
|
148
|
-
declare const
|
|
149
|
-
/**
|
|
150
|
-
* Service-level consent - ucCategory has mixed types (non-boolean values
|
|
151
|
-
* indicate individual service-level choice rather than group-level)
|
|
152
|
-
*/
|
|
153
|
-
declare const serviceLevelConsent: UsercentricsEventDetail;
|
|
154
|
-
/**
|
|
155
|
-
* Non-consent event (should be ignored)
|
|
156
|
-
*/
|
|
157
|
-
declare const nonConsentEvent: UsercentricsEventDetail;
|
|
169
|
+
declare const servicesFirstVisitImplicit: UsercentricsV2Service[];
|
|
158
170
|
|
|
159
171
|
/**
|
|
160
172
|
* Expected walkerOS consent outputs.
|
|
161
173
|
*
|
|
162
|
-
* These represent the consent state
|
|
163
|
-
*
|
|
174
|
+
* These represent the consent state emitted via `elb('walker consent', state)`
|
|
175
|
+
* after the V2 adapter aggregates `getServicesBaseInfo()` into group-level
|
|
176
|
+
* consent (no category mapping configured: pass-through by `categorySlug`).
|
|
164
177
|
*/
|
|
165
178
|
/**
|
|
166
|
-
* Full consent - all categories
|
|
179
|
+
* Full consent - all categories granted.
|
|
167
180
|
*/
|
|
168
181
|
declare const fullConsentMapped: WalkerOS.Consent;
|
|
169
182
|
/**
|
|
170
|
-
* Partial consent - essential and functional
|
|
183
|
+
* Partial consent - essential and functional granted, marketing denied.
|
|
171
184
|
*/
|
|
172
185
|
declare const partialConsentMapped: WalkerOS.Consent;
|
|
173
186
|
/**
|
|
174
|
-
* Minimal consent - only essential
|
|
187
|
+
* Minimal consent - only essential granted.
|
|
175
188
|
*/
|
|
176
189
|
declare const minimalConsentMapped: WalkerOS.Consent;
|
|
177
190
|
/**
|
|
178
|
-
* Full consent with custom category mapping applied
|
|
179
|
-
* (essential->functional, functional->
|
|
191
|
+
* Full consent with a custom category mapping applied
|
|
192
|
+
* (essential->functional, functional->analytics).
|
|
180
193
|
*/
|
|
181
194
|
declare const fullConsentCustomMapped: WalkerOS.Consent;
|
|
182
|
-
/**
|
|
183
|
-
* Service-level consent - individual service booleans + boolean ucCategory entries
|
|
184
|
-
* (services normalized: lowercase, spaces to underscores)
|
|
185
|
-
* (ucCategory boolean entries mapped through categoryMap)
|
|
186
|
-
*/
|
|
187
|
-
declare const serviceLevelMapped: WalkerOS.Consent;
|
|
188
195
|
|
|
189
196
|
/**
|
|
190
197
|
* Create a properly typed elb/push function mock
|
|
@@ -195,17 +202,32 @@ declare const createMockElbFn: () => Elb.Fn;
|
|
|
195
202
|
*/
|
|
196
203
|
declare const noopLogger: Logger.Instance;
|
|
197
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Step examples for the Usercentrics V2 path.
|
|
207
|
+
*
|
|
208
|
+
* `in` is the array returned by `window.UC_UI.getServicesBaseInfo()`. The test
|
|
209
|
+
* runner attaches it as the V2 API, then drives the official trigger named in
|
|
210
|
+
* `trigger.options.dispatch`:
|
|
211
|
+
* - 'init' (default): UC_UI is present when the source runs, so the static
|
|
212
|
+
* read at init emits the snapshot (also the `UC_UI_INITIALIZED` path).
|
|
213
|
+
* - 'cmp': UC_UI is attached only after init, then a `UC_UI_CMP_EVENT`
|
|
214
|
+
* decision (ACCEPT_ALL) re-reads and emits — the consent-change path.
|
|
215
|
+
*/
|
|
198
216
|
declare const fullConsent: Flow.StepExample;
|
|
199
217
|
declare const minimalConsent: Flow.StepExample;
|
|
218
|
+
declare const returningVisitor: Flow.StepExample;
|
|
219
|
+
declare const firstVisitImplicit: Flow.StepExample;
|
|
220
|
+
declare const consentChange: Flow.StepExample;
|
|
200
221
|
declare const categoryMapOverride: Flow.StepExample;
|
|
201
|
-
declare const customEventName: Flow.StepExample;
|
|
202
222
|
|
|
203
223
|
declare const step_categoryMapOverride: typeof categoryMapOverride;
|
|
204
|
-
declare const
|
|
224
|
+
declare const step_consentChange: typeof consentChange;
|
|
225
|
+
declare const step_firstVisitImplicit: typeof firstVisitImplicit;
|
|
205
226
|
declare const step_fullConsent: typeof fullConsent;
|
|
206
227
|
declare const step_minimalConsent: typeof minimalConsent;
|
|
228
|
+
declare const step_returningVisitor: typeof returningVisitor;
|
|
207
229
|
declare namespace step {
|
|
208
|
-
export { step_categoryMapOverride as categoryMapOverride,
|
|
230
|
+
export { step_categoryMapOverride as categoryMapOverride, step_consentChange as consentChange, step_firstVisitImplicit as firstVisitImplicit, step_fullConsent as fullConsent, step_minimalConsent as minimalConsent, step_returningVisitor as returningVisitor };
|
|
209
231
|
}
|
|
210
232
|
|
|
211
233
|
interface UsercentricsContent {
|
|
@@ -219,4 +241,4 @@ declare const createTrigger: Trigger.CreateFn<UsercentricsContent, void>;
|
|
|
219
241
|
/** Dispatches ucEvent CustomEvent after source init (post-init trigger). */
|
|
220
242
|
declare const trigger: (input: unknown, env: Record<string, unknown>) => void | (() => void);
|
|
221
243
|
|
|
222
|
-
export { createMockElbFn, createTrigger,
|
|
244
|
+
export { createMockElbFn, createTrigger, fullConsentCustomMapped, fullConsentMapped, minimalConsentMapped, noopLogger, partialConsentMapped, servicesFirstVisitImplicit, servicesFullExplicit, servicesMinimalExplicit, servicesPartialExplicit, step, trigger };
|