{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n  appId: z\n    .string()\n    .min(1)\n    .describe(\n      'Heap App ID. Find it in your Heap project under Settings > App ID.',\n    ),\n  disableTextCapture: z\n    .boolean()\n    .describe('Disable Heap auto text capture. Default: true.')\n    .optional(),\n  disablePageviewAutocapture: z\n    .boolean()\n    .describe(\n      'Disable Heap automatic pageview tracking. Default: true (walkerOS sources handle pageviews).',\n    )\n    .optional(),\n  disableSessionReplay: z\n    .boolean()\n    .describe('Disable Heap session replay.')\n    .optional(),\n  secureCookie: z.boolean().describe('SSL-only cookies.').optional(),\n  ingestServer: z\n    .string()\n    .url()\n    .describe('Custom server endpoint for proxying Heap data.')\n    .optional(),\n  identify: z\n    .unknown()\n    .describe(\n      'Destination-level identity mapping. Resolves to a string for heap.identify(). Example: { \"key\": \"user.id\" }.',\n    )\n    .optional(),\n  userProperties: z\n    .unknown()\n    .describe(\n      'Destination-level user properties mapping. Resolves to object for heap.addUserProperties(). Example: { \"map\": { \"plan\": \"data.plan\" } }.',\n    )\n    .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n  identify: z\n    .unknown()\n    .describe(\n      'Per-event identity. Resolves to a string for heap.identify(). Example: { \"key\": \"data.email\" }.',\n    )\n    .optional(),\n  reset: z\n    .unknown()\n    .describe(\n      'Reset Heap identity on this event. Set to true to call heap.resetIdentity().',\n    )\n    .optional(),\n  userProperties: z\n    .unknown()\n    .describe(\n      'Per-event user properties. Resolves to object for heap.addUserProperties().',\n    )\n    .optional(),\n  eventProperties: z\n    .unknown()\n    .describe(\n      'Per-event persistent event properties. Resolves to object for heap.addEventProperties() (persisted across page loads).',\n    )\n    .optional(),\n  clearEventProperties: z\n    .unknown()\n    .describe(\n      'Clear all persistent event properties. Set to true to call heap.clearEventProperties().',\n    )\n    .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { Env, HeapSDK } from '../types';\n\n/**\n * Example environment configurations for the Heap destination.\n *\n * Tests clone `push` and replace individual methods with jest spies.\n * Production leaves env undefined — the destination uses the real\n * window.heap command queue it creates during init.\n */\n\n// Narrow helper type aliases so the noop casts don't use `as any`.\ntype HeapLoad = HeapSDK['load'];\ntype HeapTrack = HeapSDK['track'];\ntype HeapIdentify = HeapSDK['identify'];\ntype HeapAddUserProperties = HeapSDK['addUserProperties'];\ntype HeapAddEventProperties = HeapSDK['addEventProperties'];\n\nconst noop = (() => {}) as (...args: unknown[]) => void;\n\nfunction createMockHeap(): HeapSDK {\n  return {\n    load: noop as HeapLoad,\n    track: noop as HeapTrack,\n    identify: noop as HeapIdentify,\n    resetIdentity: noop,\n    addUserProperties: noop as HeapAddUserProperties,\n    addEventProperties: noop as HeapAddEventProperties,\n    clearEventProperties: noop,\n    startTracking: noop,\n    stopTracking: noop,\n  };\n}\n\n/**\n * Pre-init env — window.heap is a no-op queue until init wires it.\n */\nexport const init: Env | undefined = {\n  window: {\n    heap: createMockHeap(),\n  },\n};\n\n/**\n * Post-init env — window.heap methods are spy-able no-ops.\n * Tests clone this and replace individual methods with jest.fn() for assertions.\n */\nexport const push: Env = {\n  window: {\n    heap: createMockHeap(),\n  },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n  'call:window.heap.track',\n  'call:window.heap.identify',\n  'call:window.heap.resetIdentity',\n  'call:window.heap.addUserProperties',\n  'call:window.heap.addEventProperties',\n  'call:window.heap.clearEventProperties',\n  'call:window.heap.startTracking',\n  'call:window.heap.stopTracking',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Examples may optionally carry destination-level settings overrides.\n * The test runner reads `settings` from the example and merges it on top\n * of the fixed appId when registering the destination.\n */\nexport type HeapStepExample = Flow.StepExample & {\n  settings?: Partial<Settings>;\n  /** Consent granted before `in` so a gated destination is loaded first. */\n  before?: WalkerOS.Consent;\n};\n\n/**\n * Default event forwarding - every walkerOS event becomes\n * heap.track(event.name, properties). With no mapping, properties is `{}`.\n */\nexport const defaultEventForwarding: HeapStepExample = {\n  title: 'Default track',\n  description:\n    'A walker event becomes a Heap track call with the event name and empty properties.',\n  in: getEvent('product view', { timestamp: 1700000100 }),\n  out: [['heap.track', 'product view', {}]],\n};\n\n/**\n * Rename + map event properties via rule.data.map.\n * data resolves to { order_id, total, currency } → heap.track('purchase', props).\n */\nexport const destinationLevelInclude: HeapStepExample = {\n  title: 'Renamed purchase',\n  description:\n    'An order complete is renamed to purchase and mapped to Heap track properties such as order_id, total, and currency.',\n  in: getEvent('order complete', { timestamp: 1700000101 }),\n  mapping: {\n    name: 'purchase',\n    data: {\n      map: {\n        order_id: 'data.id',\n        total: 'data.total',\n        currency: { key: 'data.currency', value: 'EUR' },\n      },\n    },\n  },\n  out: [\n    [\n      'heap.track',\n      'purchase',\n      { order_id: '0rd3r1d', total: 555, currency: 'EUR' },\n    ],\n  ],\n};\n\n/**\n * Destination-level settings.identify - heap.identify() resolves user.id,\n * then the default heap.track() call fires.\n */\nexport const destinationLevelIdentify: HeapStepExample = {\n  title: 'Destination identify',\n  description:\n    'Destination-level identify calls heap.identify with the user id before firing the default track.',\n  in: getEvent('page view', { timestamp: 1700000102 }),\n  settings: {\n    identify: 'user.id',\n  },\n  out: [\n    ['heap.identify', 'us3r'],\n    ['heap.track', 'page view', {}],\n  ],\n};\n\n/**\n * Per-event login identify - heap.identify() from data.email + user\n * properties from the same rule. silent: true suppresses the track() call.\n */\nexport const userLoginIdentify: HeapStepExample = {\n  title: 'User login identify',\n  description:\n    'A user login identifies the Heap user by email and adds user properties while skipping the track.',\n  in: getEvent('user login', {\n    timestamp: 1700000103,\n    data: {\n      email: 'user@example.com',\n      plan: 'premium',\n      company: 'Acme',\n    },\n  }),\n  mapping: {\n    silent: true,\n    settings: {\n      identify: 'data.email',\n      userProperties: {\n        map: {\n          plan: 'data.plan',\n          company: 'data.company',\n        },\n      },\n    },\n  },\n  out: [\n    ['heap.identify', 'user@example.com'],\n    ['heap.addUserProperties', { plan: 'premium', company: 'Acme' }],\n  ],\n};\n\n/**\n * User logout - heap.resetIdentity(). silent: true suppresses the track() call.\n */\nexport const userLogoutReset: HeapStepExample = {\n  title: 'User logout reset',\n  description:\n    'A user logout calls heap.resetIdentity to clear the identified user from the Heap client.',\n  in: getEvent('user logout', { timestamp: 1700000104 }),\n  mapping: {\n    silent: true,\n    settings: {\n      reset: true,\n    },\n  },\n  out: [['heap.resetIdentity']],\n};\n\n/**\n * Event with user properties from mapping - heap.addUserProperties() fires,\n * then the default heap.track() call.\n */\nexport const eventWithUserProperties: HeapStepExample = {\n  title: 'User properties on event',\n  description:\n    'An order fires Heap addUserProperties with last-order fields and then tracks the event.',\n  in: getEvent('order complete', {\n    timestamp: 1700000105,\n    data: {\n      id: '0rd3r1d',\n      total: 555,\n      currency: 'EUR',\n    },\n  }),\n  mapping: {\n    settings: {\n      userProperties: {\n        map: {\n          last_order_value: 'data.total',\n          last_order_currency: 'data.currency',\n        },\n      },\n    },\n  },\n  out: [\n    [\n      'heap.addUserProperties',\n      { last_order_value: 555, last_order_currency: 'EUR' },\n    ],\n    ['heap.track', 'order complete', {}],\n  ],\n};\n\n/**\n * Global event properties - heap.addEventProperties() sets persistent\n * properties on all subsequent events. silent: true on this rule.\n */\nexport const globalEventProperties: HeapStepExample = {\n  title: 'Global event properties',\n  description:\n    'A page view sets persistent Heap event properties so all subsequent events include the page category.',\n  in: getEvent('page view', {\n    timestamp: 1700000106,\n    data: { category: 'docs' },\n  }),\n  mapping: {\n    silent: true,\n    settings: {\n      eventProperties: {\n        map: {\n          page_category: 'data.category',\n        },\n      },\n    },\n  },\n  out: [['heap.addEventProperties', { page_category: 'docs' }]],\n};\n\n/**\n * Consent granted then revoked: the destination loads under the grant\n * (heap.startTracking), and the later revoke calls heap.stopTracking via the\n * on('consent') handler. A gated destination never loads under denial, so the\n * stop is a real revocation of an already-granted destination.\n */\nexport const consentRevokeStopTracking: HeapStepExample = {\n  title: 'Consent revoked',\n  description:\n    'After analytics consent is granted (Heap loads and starts tracking), revoking it calls heap.stopTracking to pause event capture.',\n  command: 'consent',\n  before: { analytics: true },\n  in: { analytics: false },\n  out: [['heap.startTracking'], ['heap.stopTracking']],\n};\n\n/**\n * Consent granted - on('consent') handler calls heap.startTracking()\n * when all required consent keys are true.\n */\nexport const consentGrantStartTracking: HeapStepExample = {\n  title: 'Consent granted',\n  description:\n    'A walker consent grant for analytics calls heap.startTracking to resume event capture.',\n  command: 'consent',\n  in: { analytics: true },\n  out: [['heap.startTracking']],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,OAAO,EACJ,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,oBAAoB,EACjB,QAAQ,EACR,SAAS,gDAAgD,EACzD,SAAS;AAAA,EACZ,4BAA4B,EACzB,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,sBAAsB,EACnB,QAAQ,EACR,SAAS,8BAA8B,EACvC,SAAS;AAAA,EACZ,cAAc,EAAE,QAAQ,EAAE,SAAS,mBAAmB,EAAE,SAAS;AAAA,EACjE,cAAc,EACX,OAAO,EACP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