{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.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 * from './primitives';\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';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n  accessToken: z\n    .string()\n    .min(1)\n    .describe(\n      'Meta access token for Conversions API authentication (like your_access_token)',\n    ),\n  pixelId: z\n    .string()\n    .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n    .describe(\n      'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n    ),\n  action_source: ActionSourceSchema.describe(\n    'Source of the event (website, app, phone_call, etc.) (like website)',\n  ).optional(),\n  doNotHash: z\n    .array(z.string())\n    .describe(\n      \"Array of user_data fields that should not be hashed (like ['client_ip_address', 'client_user_agent'])\",\n    )\n    .optional(),\n  test_event_code: z\n    .string()\n    .describe(\n      'Test event code for debugging Meta Conversions API events (like TEST12345)',\n    )\n    .optional(),\n  url: z\n    .string()\n    .url()\n    .describe(\n      'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v17.0)',\n    )\n    .optional(),\n  user_data: z\n    .record(z.string(), z.string())\n    .describe(\n      \"Mapping configuration for user data fields (like { email: 'user.email', phone: 'user.phone' })\",\n    )\n    .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n  'email',\n  'website',\n  'app',\n  'phone_call',\n  'chat',\n  'physical_store',\n  'system_generated',\n  'business_messaging',\n  'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n  z.enum([\n    'AddPaymentInfo',\n    'AddToCart',\n    'AddToWishlist',\n    'CompleteRegistration',\n    'Contact',\n    'CustomizeProduct',\n    'Donate',\n    'FindLocation',\n    'InitiateCheckout',\n    'Lead',\n    'Purchase',\n    'Schedule',\n    'Search',\n    'StartTrial',\n    'SubmitApplication',\n    'Subscribe',\n    'ViewContent',\n  ]),\n  z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for Meta Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nasync function mockSendServer(\n  url: string,\n  data?: SendDataValue,\n  options?: SendServerOptions,\n): Promise<SendResponse> {\n  // Simulate successful Meta API response\n  return {\n    ok: true,\n    data: {\n      events_received: 1,\n      messages: [],\n      fbtrace_id: 'mock-trace-id',\n    },\n  };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing Meta Conversions API events without making\n * actual HTTP requests to Facebook's servers.\n */\nexport const push: Env = {\n  sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Meta Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is `${settings.url}${settings.pixelId}/events`, `body` is the\n * JSON-stringified `{ data: [serverEvent] }` payload, and `options` carries the\n * access token in an `Authorization: Bearer` header (never in the URL).\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body, options]` with `body` as\n * the already-stringified JSON payload (mirroring the actual call signature).\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n *   https://graph.facebook.com/v22.0/p1x3l1d/events\n * with header `Authorization: Bearer s3cr3t`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n *   1. event_name\n *   2. event_id\n *   3. event_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n *   4. action_source\n *   5. ...mapped event data (currency, value, etc.)\n *   6. user_data (hashed per Meta's PII requirements)\n *   7. event_source_url (appended after hash when action_source === 'website')\n */\nconst ENDPOINT = 'https://graph.facebook.com/v22.0/p1x3l1d/events';\n\nconst OPTIONS = { headers: { Authorization: 'Bearer s3cr3t' } };\n\nexport const purchase: Flow.StepExample = {\n  title: 'Purchase',\n  description:\n    'A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.',\n  in: getEvent('order complete', {\n    id: 'c1d2e3f4a5b60001',\n    timestamp: 1700000900,\n    data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n    nested: [\n      { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n    ],\n    user: { id: 'user-123', device: 'device-456' },\n    source: {\n      type: 'browser',\n      platform: 'web',\n      url: 'https://shop.example.com',\n    },\n  }),\n  mapping: {\n    name: 'Purchase',\n    data: {\n      map: {\n        order_id: 'data.id',\n        currency: { key: 'data.currency', value: 'EUR' },\n        value: 'data.total',\n        contents: {\n          loop: [\n            'nested',\n            {\n              condition: (entity: unknown) =>\n                isObject(entity) && entity.entity === 'product',\n              map: {\n                id: 'data.id',\n                item_price: 'data.price',\n                quantity: { key: 'data.quantity', value: 1 },\n              },\n            },\n          ],\n        },\n        num_items: {\n          fn: (event: unknown) =>\n            (event as WalkerOS.Event).nested.filter(\n              (item) => item.entity === 'product',\n            ).length,\n        },\n      },\n    },\n  },\n  out: [\n    [\n      'sendServer',\n      ENDPOINT,\n      JSON.stringify({\n        data: [\n          {\n            event_name: 'Purchase',\n            event_id: 'c1d2e3f4a5b60001',\n            event_time: 1700001,\n            action_source: 'website',\n            order_id: 'ORD-300',\n            currency: 'EUR',\n            value: 249.99,\n            contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n            num_items: 1,\n            user_data: {},\n            event_source_url: 'https://shop.example.com',\n          },\n        ],\n      }),\n      OPTIONS,\n    ],\n  ],\n};\n\nexport const lead: Flow.StepExample = {\n  title: 'Form submit',\n  description:\n    'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n  in: getEvent('form submit', {\n    id: 'c1d2e3f4a5b60002',\n    timestamp: 1700000901,\n    data: { type: 'newsletter' },\n    user: { email: 'user@example.com' },\n    source: {\n      type: 'browser',\n      platform: 'web',\n      url: 'https://example.com',\n    },\n  }),\n  mapping: undefined,\n  out: [\n    [\n      'sendServer',\n      ENDPOINT,\n      JSON.stringify({\n        data: [\n          {\n            event_name: 'form submit',\n            event_id: 'c1d2e3f4a5b60002',\n            event_time: 1700001,\n            action_source: 'website',\n            user_data: {},\n            event_source_url: 'https://example.com',\n          },\n        ],\n      }),\n      OPTIONS,\n    ],\n  ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n  title: 'Purchase with fbclid',\n  description:\n    'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n  in: getEvent('order complete', {\n    id: 'c1d2e3f4a5b60003',\n    timestamp: 1700000902,\n    data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n    user: { id: 'cust-42' },\n    context: { fbclid: ['abc123xyz', 0] },\n    source: {\n      type: 'browser',\n      platform: 'web',\n      url: 'https://shop.example.com',\n    },\n  }),\n  mapping: {\n    name: 'Purchase',\n    data: {\n      map: {\n        currency: { key: 'data.currency', value: 'EUR' },\n        value: 'data.total',\n        order_id: 'data.id',\n        user_data: {\n          map: {\n            external_id: 'user.id',\n            fbclid: 'context.fbclid',\n          },\n        },\n      },\n    },\n  },\n  out: [\n    [\n      'sendServer',\n      ENDPOINT,\n      JSON.stringify({\n        data: [\n          {\n            event_name: 'Purchase',\n            event_id: 'c1d2e3f4a5b60003',\n            event_time: 1700001,\n            action_source: 'website',\n            currency: 'USD',\n            value: 89.99,\n            order_id: 'ORD-700',\n            user_data: {\n              // sha256('cust-42')\n              external_id:\n                '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n              // formatClickId(['abc123xyz', 0], event.timestamp) - array joins\n              // to 'abc123xyz,0' when coerced to string inside the template.\n              fbc: 'fb.1.1700000902.abc123xyz,0',\n            },\n            event_source_url: 'https://shop.example.com',\n          },\n        ],\n      }),\n      OPTIONS,\n    ],\n  ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAOX,IAAM,qBAAqB,EAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,kBAAkB,EAAE,MAAM;AAAA,EACrC,EAAE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,EAAE,OAAO;AAAA;AACX,CAAC;;;ADzCM,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,aAA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