@crvouga/mockingbird-service-customerio 0.2.0 → 1.0.1

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 CHANGED
@@ -1,6 +1,19 @@
1
1
  # Changelog — @crvouga/mockingbird-service-customerio
2
2
 
3
- ## 0.2.0 (2026-09-24)
3
+ ## 1.0.1 (2026-09-26)
4
+
5
+ ### Fixes and improvements
6
+
7
+ - take the rejected-request byte count from content-length, never by reading the body ([a0e5fb2](https://github.com/crvouga/mockingbird/commit/a0e5fb2fc80ab725c3552b612f3f091fd6c857fb))
8
+ - reject a present body by media type, and log what a rejected request sent ([12e351a](https://github.com/crvouga/mockingbird/commit/12e351aba53cfb7b41e31a7809419455fc2902eb))
9
+
10
+ ## 1.0.0 (2026-09-24)
11
+
12
+ ### ⚠️ Breaking changes
13
+
14
+ - vendor branding for every service; purge internal mocks and consumer names ([f689534](https://github.com/crvouga/mockingbird/commit/f6895343543550dafcb7d76b426cae7635e03226))
15
+
16
+ ## 0.2.0 (2026-09-23)
4
17
 
5
18
  ### Features
6
19
 
package/README.md CHANGED
@@ -76,7 +76,7 @@ await cio.close()
76
76
  | --- | --- |
77
77
  | `POST /v1/identify`, `/v1/track`, `/v1/batch` | CDP, `Authorization: Basic base64(<write key>:)` (else 401 `{error}`). Segment events (`batch` of `identify` / `track`); each needs `userId` or `anonymousId` (else 400 `{error}`, which the SDK does not retry). → `{success: true}`. Identify merges traits into the profile (`email`, `unsubscribed`); a repeated `messageId` is recorded as a duplicate and not applied. |
78
78
  | `POST /v1/send/email`, `/v1/send/sms`, `/v1/send/inbox_message` | App API, `Authorization: Bearer <app key>` (else 401 `{meta: {error}}`). `{transactional_message_id (id or trigger name), identifiers: {id \| email \| cio_id}, to?, from?, subject?, message_data?, send_to_unsubscribed?, tracked?, disable_message_retention?, headers?, attachments?}` → `{delivery_id, queued_at}`. Validation errors are 400 `{meta: {error}}`. With `strictMessages`, an id that is neither a catalog id nor a trigger name is 400 `{meta: {error: "transactional_message_id not found"}}`. A profile that unsubscribed (or switched the channel off) gets a `suppressed` delivery unless `send_to_unsubscribed`. `disable_message_retention` keeps no `message_data` in the outbox. `tracked: true` rewrites every URL in `message_data` to `<trackingBase>/click/<linkId>`. `to` defaults to the profile's email (email) or `phone` trait (SMS). |
79
- | `GET /v1/transactional` | `{messages: [{id, name, trigger_name, description, send_to_unsubscribed, link_tracking, …}]}`, no pagination. Seeded with `geviti_<key>` for every legacy email key our backend has, plus `geviti_inbox_message` and `geviti_playground_notification` (ids 1–21). |
79
+ | `GET /v1/transactional` | `{messages: [{id, name, trigger_name, description, send_to_unsubscribed, link_tracking, …}]}`, no pagination. Seeded with `acme_<key>` for every legacy email key the consumer app has, plus `acme_inbox_message` and `acme_playground_notification` (ids 1–21). |
80
80
  | `GET /v1/transactional/{id}` | `{message: {...}}` by id or trigger name, or 404. |
81
81
  | `POST /click/{linkId}` | Our backend's click report (unauthenticated) → 200, counts the click and posts a `clicked` reporting event. Unknown link: plain-text 404. |
82
82
  | `GET /click/{linkId}` | A browser following a tracked link → 302 to the original URL. |
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRuntime
3
- } from "./chunk-UZHOLS6M.js";
3
+ } from "./chunk-F2KPDA6X.js";
4
4
 
5
5
  // ../../adapters/node/dist/cli.js
6
6
  import { readFile } from "node:fs/promises";
@@ -208,7 +208,9 @@ var formatLog = (format) => {
208
208
  const ns = entry.namespace === "default" ? "" : ` [${entry.namespace}]`;
209
209
  const fault = entry.faultId ? ` fault=${entry.faultId}` : "";
210
210
  const adopted = entry.adopted ? " adopted" : "";
211
- console.log(`${entry.service} ${entry.method} ${entry.path} ${entry.status} ${op} ${entry.durationMs}ms${ns}${fault}${adopted}`);
211
+ const received = entry.request ? ` received=${entry.request.bodyBytes === null ? "?" : `${entry.request.bodyBytes}B`} ct=${entry.request.contentType ?? "-"}${entry.request.transferEncoding ? ` te=${entry.request.transferEncoding}` : ""}` : "";
212
+ const issues = entry.issues?.length ? ` issues=${entry.issues.slice(0, 3).map((issue) => `${issue.path || "$"}: ${issue.message}`).join("; ")}${entry.issues.length > 3 ? ` (+${entry.issues.length - 3})` : ""}` : "";
213
+ console.log(`${entry.service} ${entry.method} ${entry.path} ${entry.status} ${op} ${entry.durationMs}ms${ns}${fault}${adopted}${received}${issues}`);
212
214
  };
213
215
  };
214
216
  var asString = (value) => typeof value === "string" ? value : void 0;
@@ -364,4 +366,4 @@ export {
364
366
  createServer2 as createServer,
365
367
  serveTarget
366
368
  };
367
- //# sourceMappingURL=chunk-NOFJ7YFL.js.map
369
+ //# sourceMappingURL=chunk-2WKT52HW.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../adapters/node/src/cli.ts", "../../../adapters/node/src/serve.ts", "../../../adapters/node/src/listen.ts", "../src/server.ts"],
4
+ "sourcesContent": ["import { readFile } from \"node:fs/promises\"\nimport { type ParseArgsConfig, parseArgs } from \"node:util\"\nimport type { RequestLog, ServiceInstance, ServiceRuntime } from \"@crvouga/mockingbird-service\"\nimport { type Listening, listen } from \"./listen.js\"\n\nexport type CliOption = {\n type: \"string\" | \"boolean\"\n description: string\n /** Shown in help; the value placeholder, e.g. `<port>`. */\n value?: string\n default?: string | boolean\n}\n\nexport type CliValues = Record<string, string | boolean | undefined>\n\nexport type CliCommand = {\n summary: string\n usage?: string\n options?: Record<string, CliOption>\n /** Resolves to an exit code; a server command resolves only when it stops. */\n run(values: CliValues, positionals: string[]): Promise<number>\n}\n\nexport type CliSpec = {\n bin: string\n description: string\n commands: Record<string, CliCommand>\n}\n\nconst optionHelp = (options: Record<string, CliOption>): string[] =>\n Object.entries(options).map(([name, option]) => {\n const flag = `--${name}${option.type === \"string\" ? ` ${option.value ?? \"<value>\"}` : \"\"}`\n const fallback = option.default !== undefined ? ` (default: ${String(option.default)})` : \"\"\n return ` ${flag.padEnd(30)} ${option.description}${fallback}`\n })\n\nconst help = (spec: CliSpec): string =>\n [\n `${spec.bin} \u2014 ${spec.description}`,\n \"\",\n \"Usage:\",\n ` ${spec.bin} <command> [options]`,\n \"\",\n \"Commands:\",\n ...Object.entries(spec.commands).map(([name, c]) => ` ${name.padEnd(30)} ${c.summary}`),\n \"\",\n `Run \\`${spec.bin} <command> --help\\` for a command's options.`,\n ].join(\"\\n\")\n\nconst commandHelp = (spec: CliSpec, name: string, command: CliCommand): string =>\n [\n `${spec.bin} ${name} \u2014 ${command.summary}`,\n \"\",\n \"Usage:\",\n ` ${command.usage ?? `${spec.bin} ${name} [options]`}`,\n ...(command.options ? [\"\", \"Options:\", ...optionHelp(command.options)] : []),\n ].join(\"\\n\")\n\n/** Parse `argv` against `spec` and run the chosen command. Resolves to an exit code. */\nexport const runCli = async (spec: CliSpec, argv: string[]): Promise<number> => {\n // Two-word commands (`corpus pull`) win over one-word ones.\n const pair = argv.length >= 2 ? `${argv[0]} ${argv[1]}` : undefined\n const words = pair !== undefined && spec.commands[pair] ? 2 : 1\n const name = words === 2 ? pair : argv[0]\n const rest = argv.slice(words)\n if (name === undefined || name === \"--help\" || name === \"-h\" || name === \"help\") {\n console.log(help(spec))\n return 0\n }\n const command = spec.commands[name]\n if (!command) {\n console.error(`${spec.bin}: unknown command ${JSON.stringify(name)}\\n\\n${help(spec)}`)\n return 2\n }\n if (rest.includes(\"--help\") || rest.includes(\"-h\")) {\n console.log(commandHelp(spec, name, command))\n return 0\n }\n let parsed: { values: CliValues; positionals: string[] }\n try {\n parsed = parseArgs({\n args: rest,\n allowPositionals: true,\n strict: true,\n options: Object.fromEntries(\n Object.entries(command.options ?? {}).map(([key, option]) => [\n key,\n {\n type: option.type,\n ...(option.default !== undefined ? { default: option.default } : {}),\n },\n ]),\n ) as ParseArgsConfig[\"options\"],\n }) as { values: CliValues; positionals: string[] }\n } catch (error) {\n console.error(\n `${spec.bin} ${name}: ${error instanceof Error ? error.message : String(error)}\\n\\n${commandHelp(spec, name, command)}`,\n )\n return 2\n }\n return command.run(parsed.values, parsed.positionals)\n}\n\n// \u2500\u2500 serve \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type LogFormat = \"pretty\" | \"json\" | \"off\"\n\nexport type CommonServeOptions = {\n adminKey: string | undefined\n seed: string | undefined\n onLog: ((entry: RequestLog) => void) | undefined\n}\n\n/**\n * What a service contributes to `serve`: how to build its runtime from CLI flags,\n * and what to say at startup. Every service's `./server` entry exports one as\n * `serveTarget`, which is also how `serve --config` finds services by name.\n */\nexport type ServeTarget = {\n name: string\n defaultPort: number\n /** Serve flags beyond the common ones. */\n options?: Record<string, CliOption>\n create(\n values: CliValues,\n common: CommonServeOptions,\n ): Promise<ServiceRuntime<ServiceInstance>> | ServiceRuntime<ServiceInstance>\n /** Startup lines after the listen address, e.g. the loaded corpus version. */\n banner?(runtime: ServiceRuntime<ServiceInstance>): string[]\n}\n\nconst COMMON_SERVE_OPTIONS: Record<string, CliOption> = {\n port: { type: \"string\", value: \"<port>\", description: \"Port to listen on\" },\n host: { type: \"string\", value: \"<host>\", description: \"Interface to bind\", default: \"127.0.0.1\" },\n \"admin-key\": {\n type: \"string\",\n value: \"<key>\",\n description: \"Require x-mockingbird-admin-key on /__admin/* (env MOCKINGBIRD_ADMIN_KEY)\",\n },\n seed: { type: \"string\", value: \"<seed>\", description: \"Seed for every random choice\" },\n log: {\n type: \"string\",\n value: \"<pretty|json|off>\",\n description: \"Request log format\",\n default: \"pretty\",\n },\n \"log-requests\": {\n type: \"boolean\",\n description:\n \"One JSON line per request: namespace, operationId, status, ids touched (never bodies). Same as --log json\",\n },\n config: {\n type: \"string\",\n value: \"<file>\",\n description: \"Serve every service in a mockingbird.json config instead\",\n },\n}\n\nconst formatLog = (format: LogFormat) => {\n if (format === \"off\") return undefined\n if (format === \"json\") return (entry: RequestLog) => console.log(JSON.stringify(entry))\n return (entry: RequestLog) => {\n const op = entry.operationId ?? (entry.unmatched ? \"UNMATCHED\" : \"-\")\n const ns = entry.namespace === \"default\" ? \"\" : ` [${entry.namespace}]`\n const fault = entry.faultId ? ` fault=${entry.faultId}` : \"\"\n const adopted = entry.adopted ? \" adopted\" : \"\"\n // A rejection says what arrived (never the body) and why the service refused it.\n const received = entry.request\n ? ` received=${entry.request.bodyBytes === null ? \"?\" : `${entry.request.bodyBytes}B`} ct=${entry.request.contentType ?? \"-\"}${\n entry.request.transferEncoding ? ` te=${entry.request.transferEncoding}` : \"\"\n }`\n : \"\"\n const issues = entry.issues?.length\n ? ` issues=${entry.issues\n .slice(0, 3)\n .map((issue) => `${issue.path || \"$\"}: ${issue.message}`)\n .join(\"; \")}${entry.issues.length > 3 ? ` (+${entry.issues.length - 3})` : \"\"}`\n : \"\"\n console.log(\n `${entry.service} ${entry.method} ${entry.path} ${entry.status} ${op} ${entry.durationMs}ms${ns}${fault}${adopted}${received}${issues}`,\n )\n }\n}\n\nconst asString = (value: string | boolean | undefined): string | undefined =>\n typeof value === \"string\" ? value : undefined\n\n/** A service entry in `mockingbird.json`. */\nexport type ConfigService = {\n port?: number\n host?: string\n adminKey?: string\n seed?: string\n /** Service-specific serve flags, by long name: `{ \"webhook-url\": \"\u2026\" }`. */\n options?: Record<string, string | boolean>\n}\n\nexport type MockingbirdConfig = {\n /** Keyed by service name: `junction` loads `@crvouga/mockingbird-service-junction`. */\n services: Record<string, ConfigService>\n log?: LogFormat\n}\n\nconst loadTarget = async (name: string, own: ServeTarget): Promise<ServeTarget> => {\n if (name === own.name) return own\n const specifier = `@crvouga/mockingbird-service-${name}/server`\n try {\n const mod = (await import(specifier)) as { serveTarget?: ServeTarget }\n if (!mod.serveTarget) throw new Error(`${specifier} exports no serveTarget`)\n return mod.serveTarget\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(\n `cannot load service \"${name}\": ${reason}. Install @crvouga/mockingbird-service-${name}.`,\n )\n }\n}\n\nconst start = async (\n target: ServeTarget,\n values: CliValues,\n config: { port: number; host: string; adminKey?: string; seed?: string; log: LogFormat },\n): Promise<Listening> => {\n const runtime = await target.create(values, {\n adminKey: config.adminKey,\n seed: config.seed,\n onLog: formatLog(config.log),\n })\n const listening = await listen(runtime, { port: config.port, host: config.host })\n console.log(`${target.name} mock listening on ${listening.url}`)\n console.log(`${target.name} health: GET ${listening.url}/health`)\n console.log(\n `${target.name} admin: ${listening.url}/__admin (${config.adminKey ? \"x-mockingbird-admin-key required\" : \"open \u2014 pass --admin-key to lock\"})`,\n )\n for (const line of target.banner?.(runtime) ?? []) console.log(`${target.name} ${line}`)\n return listening\n}\n\nconst untilSignal = async (servers: Listening[]): Promise<number> =>\n new Promise((resolve) => {\n const stop = async () => {\n await Promise.allSettled(servers.map((s) => s.close()))\n resolve(0)\n }\n process.once(\"SIGINT\", stop)\n process.once(\"SIGTERM\", stop)\n })\n\n/** The standard `serve` command for a service, including multi-service `--config`. */\nexport const serveCommand = (target: ServeTarget): CliCommand => ({\n summary: `Serve the ${target.name} mock over HTTP`,\n options: { ...COMMON_SERVE_OPTIONS, ...target.options },\n async run(values) {\n const log = (\n values[\"log-requests\"] === true ? \"json\" : (asString(values.log) ?? \"pretty\")\n ) as LogFormat\n if (![\"pretty\", \"json\", \"off\"].includes(log)) {\n console.error(`--log must be pretty, json or off (got ${log})`)\n return 2\n }\n const configPath = asString(values.config)\n if (configPath !== undefined) {\n const config = JSON.parse(await readFile(configPath, \"utf8\")) as MockingbirdConfig\n const servers: Listening[] = []\n try {\n for (const [name, entry] of Object.entries(config.services ?? {})) {\n const each = await loadTarget(name, target)\n servers.push(\n await start(each, entry.options ?? {}, {\n port: entry.port ?? each.defaultPort,\n host: entry.host ?? \"127.0.0.1\",\n ...(entry.adminKey !== undefined ? { adminKey: entry.adminKey } : {}),\n ...(entry.seed !== undefined ? { seed: entry.seed } : {}),\n log: config.log ?? log,\n }),\n )\n }\n } catch (error) {\n await Promise.allSettled(servers.map((s) => s.close()))\n console.error(error instanceof Error ? error.message : String(error))\n return 1\n }\n return untilSignal(servers)\n }\n const port = asString(values.port)\n const adminKey = asString(values[\"admin-key\"]) ?? process.env.MOCKINGBIRD_ADMIN_KEY\n const seed = asString(values.seed)\n let listening: Listening\n try {\n listening = await start(target, values, {\n port: port === undefined ? target.defaultPort : Number.parseInt(port, 10),\n host: asString(values.host) ?? \"127.0.0.1\",\n ...(adminKey !== undefined ? { adminKey } : {}),\n ...(seed !== undefined ? { seed } : {}),\n log,\n })\n } catch (error) {\n console.error(error instanceof Error ? error.message : String(error))\n return 1\n }\n return untilSignal([listening])\n },\n})\n", "import { createServer } from \"node:http\"\nimport type { FetchAPI } from \"@crvouga/mockingbird-core\"\n\n/** Options for {@link serve}. */\nexport type NodeServeOptions = {\n port?: number\n host?: string\n}\n\n/**\n * Serve any Mockingbird {@link FetchAPI} over `node:http`.\n * Port defaults to `0`, so the OS assigns an ephemeral port (read from `server.address()`).\n */\nexport const serve = async (api: FetchAPI, options: NodeServeOptions = {}) => {\n const server = createServer(async (req, res) => {\n const chunks: Buffer[] = []\n for await (const chunk of req) {\n chunks.push(Buffer.from(chunk))\n }\n const body = Buffer.concat(chunks)\n const address = server.address()\n const port = typeof address === \"object\" && address !== null ? address.port : undefined\n const base = `http://${req.headers.host ?? `localhost:${port ?? 80}`}`\n const raw = req.url ?? \"/\"\n const url = new URL(raw.replace(/^\\/+/, \"/\"), base)\n const method = req.method ?? \"GET\"\n const init: RequestInit = { method, headers: req.headers as Record<string, string> }\n if (method !== \"GET\" && method !== \"HEAD\" && body.length > 0) {\n init.body = body\n }\n const aborted = new AbortController()\n res.once(\"close\", () => {\n if (!res.writableFinished) aborted.abort()\n })\n init.signal = aborted.signal\n const request = new Request(url, init)\n let response: Response\n try {\n response = await api.fetch(request)\n } catch (error) {\n // A `drop` fault: destroy the socket so the client sees the connection die.\n if ((error as { code?: string }).code === \"MOCKINGBIRD_DROP\") {\n req.socket.destroy()\n return\n }\n res.writeHead(500, { \"content-type\": \"application/json\" })\n res.end(\n JSON.stringify({\n error: {\n type: \"mockingbird_internal\",\n message: error instanceof Error ? error.message : String(error),\n },\n }),\n )\n return\n }\n // Headers#entries() joins repeated headers; Set-Cookie must stay one header per cookie.\n const headers: Record<string, string | string[]> = Object.fromEntries(response.headers)\n const cookies = response.headers.getSetCookie()\n if (cookies.length > 0) headers[\"set-cookie\"] = cookies\n if (!response.body) {\n res.writeHead(response.status, headers)\n res.end()\n return\n }\n // Stream the body chunk by chunk: event streams and long-polls must not be buffered.\n res.writeHead(response.status, headers)\n res.flushHeaders()\n const reader = response.body.getReader()\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) break\n if (!res.write(value)) await new Promise<void>((resolve) => res.once(\"drain\", resolve))\n }\n res.end()\n } catch {\n res.destroy()\n } finally {\n reader.releaseLock()\n }\n })\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject)\n server.listen(options.port ?? 0, options.host, resolve)\n })\n return server\n}\n", "import type { Server } from \"node:http\"\nimport type { FetchAPI } from \"@crvouga/mockingbird-core\"\nimport { serve } from \"./serve.js\"\n\nexport type ListenOptions = {\n /** Default `0`: the OS picks a free port. */\n port?: number\n /** Default `127.0.0.1`: a mock should not be reachable off the machine by accident. */\n host?: string\n}\n\n/** A running server, with the address it actually bound. */\nexport type Listening = {\n url: string\n port: number\n host: string\n server: Server\n close(): Promise<void>\n}\n\nexport const listen = async (api: FetchAPI, options: ListenOptions = {}): Promise<Listening> => {\n const host = options.host ?? \"127.0.0.1\"\n const server = await serve(api, { port: options.port ?? 0, host })\n const address = server.address()\n const port = typeof address === \"object\" && address !== null ? address.port : (options.port ?? 0)\n const shown = host.includes(\":\") ? `[${host}]` : host\n return {\n url: `http://${shown}:${port}`,\n port,\n host,\n server,\n close: () =>\n new Promise<void>((resolve, reject) => {\n // Stop accepting first, then drop keep-alive sockets so close() can finish.\n server.close((error) => {\n if (error && (error as { code?: string }).code !== \"ERR_SERVER_NOT_RUNNING\") reject(error)\n else resolve()\n })\n server.closeAllConnections?.()\n }),\n }\n}\n", "/// <reference types=\"node\" />\nimport { type Listening, listen, type ServeTarget } from \"@crvouga/mockingbird-adapter-node\"\nimport { type CustomerIoRuntime, type CustomerIoRuntimeOptions, createRuntime } from \"./runtime.js\"\n\n/** Port `mockingbird-customerio serve` listens on when none is given. */\nexport const DEFAULT_PORT = 8810\n\nexport type CustomerIoServerOptions = CustomerIoRuntimeOptions & {\n /** Default `0`: the OS picks a free port. */\n port?: number\n /** Default `127.0.0.1`. */\n host?: string\n}\n\nexport type CustomerIoServer = Listening & { runtime: CustomerIoRuntime }\n\n/** Serve the Customer.io mock (CDP, App API and click tracking) over `node:http`. */\nexport const createServer = async (\n options: CustomerIoServerOptions = {},\n): Promise<CustomerIoServer> => {\n const { port, host, ...rest } = options\n const runtime = createRuntime(rest)\n const listening = await listen(runtime, {\n port: port ?? 0,\n ...(host !== undefined ? { host } : {}),\n })\n return { ...listening, runtime }\n}\n\nconst text = (value: string | boolean | undefined) =>\n typeof value === \"string\" ? value : undefined\n\n/** How `serve` (and `serve --config`) builds the Customer.io mock from flags. */\nexport const serveTarget: ServeTarget = {\n name: \"customerio\",\n defaultPort: DEFAULT_PORT,\n options: {\n \"webhook-url\": {\n type: \"string\",\n value: \"<url>\",\n description:\n \"Deliver reporting events here (e.g. http://127.0.0.1:3000/v1/customer-io/reporting-webhook)\",\n },\n \"webhook-secret\": {\n type: \"string\",\n value: \"<secret>\",\n description: \"Signs x-cio-signature (the app's CUSTOMERIO_REPORTING_WEBHOOK_SIGNING_KEY)\",\n },\n \"strict-messages\": {\n type: \"boolean\",\n description: \"Refuse sends whose transactional_message_id is not in the workspace catalog\",\n },\n \"tracking-base\": {\n type: \"string\",\n value: \"<url>\",\n description: \"Base of rewritten tracked links (default https://links.customer.io)\",\n },\n },\n create: (values, common) => {\n const url = text(values[\"webhook-url\"])\n const secret = text(values[\"webhook-secret\"])\n const trackingBase = text(values[\"tracking-base\"])\n return createRuntime({\n ...(url ? { webhooks: { url, ...(secret ? { secret } : {}) } } : {}),\n settings: {\n ...(values[\"strict-messages\"] === true ? { strictMessages: true } : {}),\n ...(trackingBase ? { trackingBase } : {}),\n },\n ...(common.adminKey !== undefined ? { adminKey: common.adminKey } : {}),\n ...(common.seed !== undefined ? { seed: common.seed } : {}),\n ...(common.onLog ? { onLog: common.onLog } : {}),\n })\n },\n banner: () => [\n \"CDP: POST /v1/identify|track|batch with Basic <write key>: (the SDK's host)\",\n \"App API: POST /v1/send/email|sms|inbox_message, GET /v1/transactional with Bearer <app key>\",\n \"namespaces: x-mockingbird-namespace, /ns/<name>/\u2026, or PUT /__admin/credentials {<key>: <ns>}\",\n ],\n}\n"],
5
+ "mappings": ";;;;;AAAA,SAAS,gBAAgB;AACzB,SAA+B,iBAAiB;;;ACDhD,SAAS,oBAAoB;AAatB,IAAM,QAAQ,OAAO,KAAe,UAA4B,CAAA,MAAM;AAC3E,QAAM,SAAS,aAAa,OAAO,KAAK,QAAO;AAC7C,UAAM,SAAmB,CAAA;AACzB,qBAAiB,SAAS,KAAK;AAC7B,aAAO,KAAK,OAAO,KAAK,KAAK,CAAC;IAChC;AACA,UAAM,OAAO,OAAO,OAAO,MAAM;AACjC,UAAM,UAAU,OAAO,QAAO;AAC9B,UAAM,OAAO,OAAO,YAAY,YAAY,YAAY,OAAO,QAAQ,OAAO;AAC9E,UAAM,OAAO,UAAU,IAAI,QAAQ,QAAQ,aAAa,QAAQ,EAAE,EAAE;AACpE,UAAM,MAAM,IAAI,OAAO;AACvB,UAAM,MAAM,IAAI,IAAI,IAAI,QAAQ,QAAQ,GAAG,GAAG,IAAI;AAClD,UAAM,SAAS,IAAI,UAAU;AAC7B,UAAM,OAAoB,EAAE,QAAQ,SAAS,IAAI,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AQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,IAChD,CAAC;AAAA,EACH;AAAA,EACA,QAAQ,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": ["createServer"]
7
+ }
@@ -1461,6 +1461,90 @@ var operationMetadata = (operation) => {
1461
1461
 
1462
1462
  // ../core/dist/service.js
1463
1463
  import { Hono } from "hono";
1464
+
1465
+ // ../core/dist/validation.js
1466
+ var requestBodyOf = (context) => {
1467
+ const requestBody = context.operation.operation.requestBody;
1468
+ return requestBody ? deref(context.document, requestBody) : void 0;
1469
+ };
1470
+ var mediaTypeMatches = (accepted, actual) => {
1471
+ const pattern = mediaTypeOf(accepted) ?? accepted.toLowerCase();
1472
+ if (pattern === actual || pattern === "*/*")
1473
+ return true;
1474
+ const [type, subtype] = pattern.split("/");
1475
+ const [actualType, actualSubtype] = actual.split("/");
1476
+ if (type !== actualType && type !== "*")
1477
+ return false;
1478
+ if (subtype === void 0 || subtype === "*")
1479
+ return true;
1480
+ if (subtype.startsWith("*+"))
1481
+ return actualSubtype?.endsWith(subtype.slice(1)) === true;
1482
+ return false;
1483
+ };
1484
+ var acceptedKeyFor = (content, mediaType) => {
1485
+ if (!content || mediaType === void 0)
1486
+ return void 0;
1487
+ const keys = Object.keys(content);
1488
+ return keys.find((key) => mediaTypeOf(key) === mediaType) ?? keys.find((key) => mediaTypeMatches(key, mediaType));
1489
+ };
1490
+ var unsupportedMediaType = (context, options = {}) => {
1491
+ if (context.body.kind === "empty" && options.includeEmpty !== true)
1492
+ return void 0;
1493
+ const content = requestBodyOf(context)?.content;
1494
+ if (!content || Object.keys(content).length === 0)
1495
+ return void 0;
1496
+ const mediaType = mediaTypeOf(context.request.headers.get("content-type"));
1497
+ if (acceptedKeyFor(content, mediaType) !== void 0)
1498
+ return void 0;
1499
+ return { mediaType: mediaType ?? null, accepted: Object.keys(content) };
1500
+ };
1501
+ var recorded = /* @__PURE__ */ new WeakMap();
1502
+ var recordedIssues = (request) => recorded.get(request);
1503
+ var bodyIssues = (context, contentType = "application/json") => {
1504
+ const issues = findBodyIssues(context, contentType);
1505
+ if (issues.length > 0)
1506
+ recorded.set(context.request, issues);
1507
+ return issues;
1508
+ };
1509
+ var findBodyIssues = (context, contentType) => {
1510
+ const resolved = requestBodyOf(context);
1511
+ if (!resolved)
1512
+ return [];
1513
+ const unsupported = unsupportedMediaType(context);
1514
+ if (unsupported) {
1515
+ return [
1516
+ {
1517
+ path: "",
1518
+ kind: "media_type",
1519
+ message: unsupported.mediaType === null ? "request body has no content-type" : `request body media type ${unsupported.mediaType} is not supported`
1520
+ }
1521
+ ];
1522
+ }
1523
+ const key = acceptedKeyFor(resolved.content, mediaTypeOf(context.request.headers.get("content-type"))) ?? contentType;
1524
+ const schema = resolved.content?.[key]?.schema;
1525
+ if (!schema)
1526
+ return [];
1527
+ if (context.body.kind === "invalid") {
1528
+ return [
1529
+ {
1530
+ path: "",
1531
+ kind: "syntax",
1532
+ message: `request body is not valid ${context.body.mediaType}`
1533
+ }
1534
+ ];
1535
+ }
1536
+ const value = context.body.kind === "json" || context.body.kind === "form" || context.body.kind === "text" ? context.body.value : void 0;
1537
+ if (value === void 0) {
1538
+ return resolved.required && context.body.kind === "empty" ? [{ path: "", kind: "required", message: "request body is required" }] : [];
1539
+ }
1540
+ return validateValue(context.document, resolveSchema(context.document, schema), value).map((issue) => ({ path: issue.path.join("."), kind: "schema", message: issue.message }));
1541
+ };
1542
+
1543
+ // ../core/dist/service.js
1544
+ var withIssues = (request, response) => {
1545
+ const issues = response.status >= 400 ? recordedIssues(request) : void 0;
1546
+ return issues && issues.length > 0 ? annotateResponse(response, { issues }) : response;
1547
+ };
1464
1548
  var defineOperations = (handlers) => handlers;
1465
1549
  var OperationRegistryError = class extends Error {
1466
1550
  problems;
@@ -1546,9 +1630,7 @@ var createService = (options) => {
1546
1630
  now
1547
1631
  };
1548
1632
  const short = await options.before?.(context);
1549
- if (short)
1550
- return short;
1551
- return handler(context);
1633
+ return withIssues(request, short ?? await handler(context));
1552
1634
  };
1553
1635
  app.on(operation.method.toUpperCase(), honoPath(operation.path), route);
1554
1636
  }
@@ -1585,7 +1667,7 @@ var restoreNamespace = (sqlite, namespace, snapshot) => {
1585
1667
  };
1586
1668
 
1587
1669
  // ../core/dist/version.js
1588
- var PACKAGE_VERSION = true ? "0.2.0" : UNRELEASED_VERSION;
1670
+ var PACKAGE_VERSION = true ? "1.0.1" : UNRELEASED_VERSION;
1589
1671
 
1590
1672
  // ../core/dist/signing.js
1591
1673
  var encoder = new TextEncoder();
@@ -2345,8 +2427,15 @@ var createRuntime = (options) => {
2345
2427
  const started = monotonicNow();
2346
2428
  const url = new URL(request.url);
2347
2429
  const operationId = operationIdFor(request, url.pathname);
2430
+ const contentLength = request.headers.get("content-length");
2431
+ const received = {
2432
+ contentType: request.headers.get("content-type"),
2433
+ bodyBytes: contentLength !== null && /^\d+$/.test(contentLength) ? Number(contentLength) : null,
2434
+ transferEncoding: request.headers.get("transfer-encoding")
2435
+ };
2348
2436
  const log = (status, faultId, response2) => {
2349
2437
  const noted = response2 ? responseNotes(response2) : void 0;
2438
+ const rejected = status >= 400 && faultId === void 0;
2350
2439
  const entry = {
2351
2440
  service: options.name,
2352
2441
  namespace,
@@ -2358,7 +2447,9 @@ var createRuntime = (options) => {
2358
2447
  unmatched: options.document !== void 0 && operationId === void 0,
2359
2448
  ...faultId !== void 0 ? { faultId } : {},
2360
2449
  ...noted?.ids && Object.keys(noted.ids).length > 0 ? { ids: noted.ids } : {},
2361
- ...noted?.adopted ? { adopted: true } : {}
2450
+ ...noted?.adopted ? { adopted: true } : {},
2451
+ ...rejected ? { request: { ...received } } : {},
2452
+ ...rejected && noted?.issues && noted.issues.length > 0 ? { issues: noted.issues.map((issue) => ({ ...issue })) } : {}
2362
2453
  };
2363
2454
  metrics.record(entry);
2364
2455
  journal.record({ ...entry, at: new Date(clock.now()).toISOString() });
@@ -2565,25 +2656,6 @@ var presetRoutes = (presets, runtime) => ({
2565
2656
  }
2566
2657
  });
2567
2658
 
2568
- // ../core/dist/validation.js
2569
- var bodyIssues = (context, contentType = "application/json") => {
2570
- const requestBody = context.operation.operation.requestBody;
2571
- if (!requestBody)
2572
- return [];
2573
- const resolved = deref(context.document, requestBody);
2574
- const schema = resolved.content?.[contentType]?.schema;
2575
- if (!schema)
2576
- return [];
2577
- const value = context.body.kind === "json" || context.body.kind === "form" ? context.body.value : void 0;
2578
- if (context.body.kind === "invalid") {
2579
- return [{ path: "", message: `request body is not valid ${context.body.mediaType}` }];
2580
- }
2581
- if (value === void 0) {
2582
- return resolved.required ? [{ path: "", message: "request body is required" }] : [];
2583
- }
2584
- return validateValue(context.document, resolveSchema(context.document, schema), value).map((issue) => ({ path: issue.path.join("."), message: issue.message }));
2585
- };
2586
-
2587
2659
  // src/generated/openapi.ts
2588
2660
  var document = JSON.parse(`{"openapi":"3.1.0","info":{"title":"Customer.io CDP + App API (Mockingbird subset)","description":"Stateful mock subset of Customer.io: the Segment-compatible CDP ingestion endpoints\\n(\`identify\`, \`track\`, \`batch\`, as \`@customerio/cdp-analytics-node\` posts them), the App API\\ntransactional sends (email, SMS, inbox message) and transactional-message catalog, and the\\nlink-tracking click endpoint. One process serves all three hosts (\`cdp.customer.io\`,\\n\`api.customer.io\`, the tracking domain); their paths do not collide.\\n","version":"1","x-mockingbird-upstream":{"note":"Hand-authored from Customer.io's CDP (Segment spec) and App API reference, trimmed to what our consumer sends: customer-io.client.service.ts / notification-adapter.ts / transactional-email-adapter.ts (backend), transactional-client.ts (notification-processor), customerio-trigger-name-validator.ts (notification-service) and mobile-links-click-reporter.service.ts."}},"servers":[{"url":"https://api.customer.io"},{"url":"https://cdp.customer.io"}],"paths":{"/v1/identify":{"post":{"operationId":"CdpIdentify","security":[{"cdpWriteKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdentifyEvent"}}}},"responses":{"200":{"description":"Accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpSuccess"}}}},"400":{"description":"Malformed event","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpError"}}}},"401":{"description":"Missing or unknown write key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpError"}}}}}}},"/v1/track":{"post":{"operationId":"CdpTrack","security":[{"cdpWriteKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackEvent"}}}},"responses":{"200":{"description":"Accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpSuccess"}}}},"400":{"description":"Malformed event","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpError"}}}},"401":{"description":"Missing or unknown write key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpError"}}}}}}},"/v1/batch":{"post":{"operationId":"CdpBatch","description":"What \`@customerio/cdp-analytics-node\` posts: \`{batch: [...]}\`.","security":[{"cdpWriteKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["batch"],"properties":{"batch":{"type":"array","maxItems":5,"items":{"anyOf":[{"$ref":"#/components/schemas/IdentifyEvent"},{"$ref":"#/components/schemas/TrackEvent"}]}},"sentAt":{"type":"string"},"context":{"type":"object"}}}}}},"responses":{"200":{"description":"Accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpSuccess"}}}},"400":{"description":"Malformed batch","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpError"}}}},"401":{"description":"Missing or unknown write key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CdpError"}}}}}}},"/v1/send/email":{"post":{"operationId":"SendEmail","security":[{"appApiKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendEmailRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/Queued"},"400":{"$ref":"#/components/responses/AppError"},"401":{"$ref":"#/components/responses/AppError"},"404":{"$ref":"#/components/responses/AppError"}}}},"/v1/send/sms":{"post":{"operationId":"SendSms","security":[{"appApiKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendSmsRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/Queued"},"400":{"$ref":"#/components/responses/AppError"},"401":{"$ref":"#/components/responses/AppError"},"404":{"$ref":"#/components/responses/AppError"}}}},"/v1/send/inbox_message":{"post":{"operationId":"SendInboxMessage","security":[{"appApiKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendInboxRequest"}}}},"responses":{"200":{"$ref":"#/components/responses/Queued"},"400":{"$ref":"#/components/responses/AppError"},"401":{"$ref":"#/components/responses/AppError"},"404":{"$ref":"#/components/responses/AppError"}}}},"/v1/transactional":{"get":{"operationId":"ListTransactionalMessages","security":[{"appApiKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":true}},"responses":{"200":{"description":"Every transactional message in the workspace (no pagination)","content":{"application/json":{"schema":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","items":{"$ref":"#/components/schemas/TransactionalMessage"}}}}}}},"401":{"$ref":"#/components/responses/AppError"}}}},"/v1/transactional/{transactional_id}":{"parameters":[{"name":"transactional_id","in":"path","required":true,"schema":{"type":"string","x-mockingbird-resource-ref":{"type":"transactional_message","missing":"999999"}}}],"get":{"operationId":"GetTransactionalMessage","security":[{"appApiKey":[]}],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":true}},"responses":{"200":{"description":"One transactional message","content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"$ref":"#/components/schemas/TransactionalMessage"}}}}}},"401":{"$ref":"#/components/responses/AppError"},"404":{"$ref":"#/components/responses/AppError"}}}},"/click/{linkId}":{"parameters":[{"name":"linkId","in":"path","required":true,"schema":{"type":"string","pattern":"^[A-Za-z0-9_~-][A-Za-z0-9._~-]{0,63}$"}}],"post":{"operationId":"ReportClick","description":"Link-tracking click report on the tracking domain (our backend posts it when a smart\\nlink opens the app directly). Unauthenticated.\\n","security":[],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"responses":{"200":{"description":"Click recorded (no body)"},"404":{"description":"Unknown link","content":{"text/plain":{"schema":{"type":"string"}}}}}},"get":{"operationId":"FollowClick","description":"A browser following a tracked link; redirects to the original URL.","security":[],"x-mockingbird":{"supported":true,"parity":{"enabled":true,"safe":false}},"responses":{"302":{"description":"Redirect to the original URL"},"404":{"description":"Unknown link","content":{"text/plain":{"schema":{"type":"string"}}}}}}}},"components":{"securitySchemes":{"cdpWriteKey":{"type":"http","scheme":"basic","description":"\`Basic base64(<write key>:)\` (the CDP source write key as the username)."},"appApiKey":{"type":"http","scheme":"bearer","description":"\`Bearer <App API key>\`."}},"responses":{"Queued":{"description":"Queued for delivery","content":{"application/json":{"schema":{"type":"object","required":["delivery_id","queued_at"],"properties":{"delivery_id":{"type":"string","x-mockingbird-resource":{"type":"delivery","identity":true},"x-mockingbird-volatile":{"kind":"id"}},"queued_at":{"type":"integer","x-mockingbird-volatile":{"kind":"timestamp"}}}}}}},"AppError":{"description":"An App API error","content":{"application/json":{"schema":{"type":"object","required":["meta"],"properties":{"meta":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}}}}}}}},"schemas":{"CdpSuccess":{"type":"object","required":["success"],"properties":{"success":{"type":"boolean"}}},"CdpError":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"IdentifyEvent":{"type":"object","properties":{"type":{"type":"string","enum":["identify"]},"userId":{"type":"string","minLength":1,"maxLength":64},"anonymousId":{"type":"string","minLength":1,"maxLength":64},"traits":{"type":"object","additionalProperties":true},"context":{"type":"object"},"integrations":{"type":"object"},"timestamp":{"type":"string"},"messageId":{"type":"string","maxLength":128},"_metadata":{"type":"object"}}},"TrackEvent":{"type":"object","required":["event"],"properties":{"type":{"type":"string","enum":["track"]},"userId":{"type":"string","minLength":1,"maxLength":64},"anonymousId":{"type":"string","minLength":1,"maxLength":64},"event":{"type":"string","minLength":1,"maxLength":150},"properties":{"type":"object","additionalProperties":true},"context":{"type":"object"},"integrations":{"type":"object"},"timestamp":{"type":"string"},"messageId":{"type":"string","maxLength":128},"_metadata":{"type":"object"}}},"Identifiers":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":64},"email":{"type":"string","format":"email","maxLength":120},"cio_id":{"type":"string","maxLength":64}}},"TransactionalMessageId":{"oneOf":[{"type":"string","minLength":1,"maxLength":150},{"type":"integer","minimum":1}]},"SendEmailRequest":{"type":"object","required":["transactional_message_id","identifiers"],"properties":{"transactional_message_id":{"$ref":"#/components/schemas/TransactionalMessageId"},"identifiers":{"$ref":"#/components/schemas/Identifiers"},"to":{"type":"string","maxLength":200},"from":{"type":"string","maxLength":200},"subject":{"type":"string","maxLength":300},"body":{"type":"string"},"message_data":{"type":"object","additionalProperties":true},"send_to_unsubscribed":{"type":"boolean"},"tracked":{"type":"boolean"},"disable_message_retention":{"type":"boolean"},"headers":{"type":"object","additionalProperties":{"type":"string"}},"attachments":{"description":"Customer.io documents a \`{filename: base64}\` map; our backend sends an array of \`{filename, content, content_type}\`. Both are accepted.","oneOf":[{"type":"object","additionalProperties":{"type":"string"}},{"type":"array","items":{"type":"object","required":["filename","content"],"properties":{"filename":{"type":"string"},"content":{"type":"string"},"content_type":{"type":"string"}}}}]}}},"SendSmsRequest":{"type":"object","required":["transactional_message_id","identifiers"],"properties":{"transactional_message_id":{"$ref":"#/components/schemas/TransactionalMessageId"},"identifiers":{"$ref":"#/components/schemas/Identifiers"},"to":{"type":"string","maxLength":20},"message_data":{"type":"object","additionalProperties":true},"send_to_unsubscribed":{"type":"boolean"},"tracked":{"type":"boolean"},"disable_message_retention":{"type":"boolean"}}},"SendInboxRequest":{"type":"object","required":["transactional_message_id","identifiers"],"properties":{"transactional_message_id":{"$ref":"#/components/schemas/TransactionalMessageId"},"identifiers":{"$ref":"#/components/schemas/Identifiers"},"message_data":{"type":"object","additionalProperties":true}}},"TransactionalMessage":{"type":"object","required":["id","name"],"properties":{"id":{"type":"integer"},"name":{"type":"string"},"trigger_name":{"type":"string","x-mockingbird-resource":{"type":"transactional_message","identity":true}},"description":{"type":"string"},"send_to_unsubscribed":{"type":"boolean"},"link_tracking":{"type":"boolean"},"open_tracking":{"type":"boolean"},"hide_message_body":{"type":"boolean"},"queue_drafts":{"type":"boolean"},"created_at":{"type":"integer"},"updated_at":{"type":"integer"}}}}}}`);
2589
2661
  var operationIds = ["CdpIdentify", "CdpTrack", "CdpBatch", "SendEmail", "SendSms", "SendInboxMessage", "ListTransactionalMessages", "GetTransactionalMessage", "FollowClick", "ReportClick"];
@@ -2618,12 +2690,12 @@ var TRANSACTIONAL_EMAIL_KEYS = [
2618
2690
  ];
2619
2691
  var CATALOG_EPOCH = 1735689600;
2620
2692
  var DEFAULT_TRANSACTIONAL_MESSAGES = [
2621
- ...TRANSACTIONAL_EMAIL_KEYS.map((key) => `geviti_${key}`),
2622
- "geviti_inbox_message",
2623
- "geviti_playground_notification"
2693
+ ...TRANSACTIONAL_EMAIL_KEYS.map((key) => `acme_${key}`),
2694
+ "acme_inbox_message",
2695
+ "acme_playground_notification"
2624
2696
  ].map((trigger, index) => ({
2625
2697
  id: index + 1,
2626
- name: trigger.replace(/^geviti_/, "Geviti ").replace(/_/g, " "),
2698
+ name: trigger.replace(/^acme_/, "Acme ").replace(/_/g, " "),
2627
2699
  trigger_name: trigger,
2628
2700
  description: "",
2629
2701
  send_to_unsubscribed: true,
@@ -3281,4 +3353,4 @@ export {
3281
3353
  customerIoCredential,
3282
3354
  CustomerIoAPI
3283
3355
  };
3284
- //# sourceMappingURL=chunk-UZHOLS6M.js.map
3356
+ //# sourceMappingURL=chunk-F2KPDA6X.js.map