@crvouga/mockingbird-service-customerio 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-JFPKZWBO.js";
7
- import "./chunk-BOZCY34D.js";
6
+ } from "./chunk-NL7M7QLP.js";
7
+ import "./chunk-XGFF36NR.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -814,6 +814,15 @@ type Profile = {
814
814
  preferences: SubscriptionPreferences;
815
815
  updatedAt: string;
816
816
  };
817
+ /** Sender opt-outs are independent of marketing subscription preferences. */
818
+ type SenderOptOut = {
819
+ channel: "sms" | "whatsapp";
820
+ from: string;
821
+ };
822
+ type CustomerOptOuts = {
823
+ customerId: string;
824
+ optouts: SenderOptOut[];
825
+ };
817
826
  type TrackedLink = {
818
827
  linkId: string;
819
828
  deliveryId: string;
@@ -862,6 +871,7 @@ declare class CustomerIoState {
862
871
  readonly deliveries: OutboxStore<Delivery>;
863
872
  readonly cdp: Collection<CdpEvent>;
864
873
  readonly profiles: Collection<Profile>;
874
+ readonly optouts: Collection<CustomerOptOuts>;
865
875
  readonly messages: Collection<TransactionalMessage>;
866
876
  readonly links: Collection<TrackedLink>;
867
877
  readonly settings: Collection<Settings>;
@@ -876,6 +886,7 @@ declare class CustomerIoState {
876
886
  catalog(): TransactionalMessage[];
877
887
  /** A catalog message by numeric id or (case-insensitive) trigger name. */
878
888
  message(idOrTrigger: string): TransactionalMessage | undefined;
889
+ setOptOut(customerId: string, from: string, channel: SenderOptOut["channel"], optout: boolean): CustomerOptOuts | undefined;
879
890
  profile(id: string): Profile | undefined;
880
891
  profileByEmail(email: string): Profile | undefined;
881
892
  profileByCioId(cioId: string): Profile | undefined;
@@ -1057,10 +1068,10 @@ type OpenAPIDocument = {
1057
1068
  };
1058
1069
 
1059
1070
  declare const document: OpenAPIDocument;
1060
- type OperationId = "CdpIdentify" | "CdpTrack" | "CdpBatch" | "SendEmail" | "SendSms" | "SendInboxMessage" | "ListTransactionalMessages" | "GetTransactionalMessage" | "GetCustomerAttributes" | "GetMessage" | "FollowClick" | "ReportClick";
1061
- type SupportedOperationId = "CdpIdentify" | "CdpTrack" | "CdpBatch" | "SendEmail" | "SendSms" | "SendInboxMessage" | "ListTransactionalMessages" | "GetTransactionalMessage" | "GetCustomerAttributes" | "GetMessage" | "FollowClick" | "ReportClick";
1062
- declare const operationIds: readonly ["CdpIdentify", "CdpTrack", "CdpBatch", "SendEmail", "SendSms", "SendInboxMessage", "ListTransactionalMessages", "GetTransactionalMessage", "GetCustomerAttributes", "GetMessage", "FollowClick", "ReportClick"];
1063
- declare const supportedOperationIds: readonly ["CdpIdentify", "CdpTrack", "CdpBatch", "SendEmail", "SendSms", "SendInboxMessage", "ListTransactionalMessages", "GetTransactionalMessage", "GetCustomerAttributes", "GetMessage", "FollowClick", "ReportClick"];
1071
+ type OperationId = "CdpIdentify" | "CdpTrack" | "CdpBatch" | "SendEmail" | "SendSms" | "SendInboxMessage" | "ListTransactionalMessages" | "GetTransactionalMessage" | "GetCustomerAttributes" | "ListOptOuts" | "GetCustomerOptOuts" | "GetMessage" | "FollowClick" | "ReportClick";
1072
+ type SupportedOperationId = "CdpIdentify" | "CdpTrack" | "CdpBatch" | "SendEmail" | "SendSms" | "SendInboxMessage" | "ListTransactionalMessages" | "GetTransactionalMessage" | "GetCustomerAttributes" | "ListOptOuts" | "GetCustomerOptOuts" | "GetMessage" | "FollowClick" | "ReportClick";
1073
+ declare const operationIds: readonly ["CdpIdentify", "CdpTrack", "CdpBatch", "SendEmail", "SendSms", "SendInboxMessage", "ListTransactionalMessages", "GetTransactionalMessage", "GetCustomerAttributes", "ListOptOuts", "GetCustomerOptOuts", "GetMessage", "FollowClick", "ReportClick"];
1074
+ declare const supportedOperationIds: readonly ["CdpIdentify", "CdpTrack", "CdpBatch", "SendEmail", "SendSms", "SendInboxMessage", "ListTransactionalMessages", "GetTransactionalMessage", "GetCustomerAttributes", "ListOptOuts", "GetCustomerOptOuts", "GetMessage", "FollowClick", "ReportClick"];
1064
1075
 
1065
1076
  /** Where our backend receives reporting webhooks (`customer-io.reporting.controller.ts`). */
1066
1077
  declare const REPORTING_WEBHOOK_PATH = "/v1/customer-io/reporting-webhook";
@@ -1180,6 +1191,8 @@ declare class CustomerIoAPI implements FetchAPI$1 {
1180
1191
  private send;
1181
1192
  private listMessages;
1182
1193
  private oneMessage;
1194
+ private listOptOuts;
1195
+ private customerOptOuts;
1183
1196
  private attributes;
1184
1197
  private deliveryMessage;
1185
1198
  private click;
@@ -1206,4 +1219,4 @@ declare class CustomerIoAPI implements FetchAPI$1 {
1206
1219
  }
1207
1220
 
1208
1221
  export { CUSTOMERIO_NAMESPACE, CUSTOMERIO_PRESETS, CustomerIoAPI, DEFAULT_SETTINGS, DEFAULT_TRANSACTIONAL_MESSAGES, DELIVERY_STATES, FAILURE_STATES, REPORTING_WEBHOOK_PATH, TRANSACTIONAL_EMAIL_KEYS, createRuntime, customerIoCredential, document, operationIds, signReporting, supportedOperationIds };
1209
- export type { CdpEvent, Channel, CustomerIoAPIOptions, CustomerIoRuntime, CustomerIoRuntimeOptions, Delivery, DeliveryState, FetchAPI$1 as FetchAPI, OperationId, Profile, ReportInput, ReportingEvent, Settings, SqliteClient, SubscriptionPreferences, SupportedOperationId, TrackedLink, TransactionalMessage };
1222
+ export type { CdpEvent, Channel, CustomerIoAPIOptions, CustomerIoRuntime, CustomerIoRuntimeOptions, CustomerOptOuts, Delivery, DeliveryState, FetchAPI$1 as FetchAPI, OperationId, Profile, ReportInput, ReportingEvent, SenderOptOut, Settings, SqliteClient, SubscriptionPreferences, SupportedOperationId, TrackedLink, TransactionalMessage };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  operationIds,
15
15
  signReporting,
16
16
  supportedOperationIds
17
- } from "./chunk-BOZCY34D.js";
17
+ } from "./chunk-XGFF36NR.js";
18
18
  export {
19
19
  CUSTOMERIO_NAMESPACE,
20
20
  CUSTOMERIO_PRESETS,
package/dist/server.d.ts CHANGED
@@ -1414,6 +1414,15 @@ type Profile = {
1414
1414
  preferences: SubscriptionPreferences;
1415
1415
  updatedAt: string;
1416
1416
  };
1417
+ /** Sender opt-outs are independent of marketing subscription preferences. */
1418
+ type SenderOptOut = {
1419
+ channel: "sms" | "whatsapp";
1420
+ from: string;
1421
+ };
1422
+ type CustomerOptOuts = {
1423
+ customerId: string;
1424
+ optouts: SenderOptOut[];
1425
+ };
1417
1426
  type TrackedLink = {
1418
1427
  linkId: string;
1419
1428
  deliveryId: string;
@@ -1454,6 +1463,7 @@ declare class CustomerIoState {
1454
1463
  readonly deliveries: OutboxStore<Delivery>;
1455
1464
  readonly cdp: Collection<CdpEvent>;
1456
1465
  readonly profiles: Collection<Profile>;
1466
+ readonly optouts: Collection<CustomerOptOuts>;
1457
1467
  readonly messages: Collection<TransactionalMessage>;
1458
1468
  readonly links: Collection<TrackedLink>;
1459
1469
  readonly settings: Collection<Settings>;
@@ -1468,6 +1478,7 @@ declare class CustomerIoState {
1468
1478
  catalog(): TransactionalMessage[];
1469
1479
  /** A catalog message by numeric id or (case-insensitive) trigger name. */
1470
1480
  message(idOrTrigger: string): TransactionalMessage | undefined;
1481
+ setOptOut(customerId: string, from: string, channel: SenderOptOut["channel"], optout: boolean): CustomerOptOuts | undefined;
1471
1482
  profile(id: string): Profile | undefined;
1472
1483
  profileByEmail(email: string): Profile | undefined;
1473
1484
  profileByCioId(cioId: string): Profile | undefined;
@@ -1557,6 +1568,8 @@ declare class CustomerIoAPI implements FetchAPI {
1557
1568
  private send;
1558
1569
  private listMessages;
1559
1570
  private oneMessage;
1571
+ private listOptOuts;
1572
+ private customerOptOuts;
1560
1573
  private attributes;
1561
1574
  private deliveryMessage;
1562
1575
  private click;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-JFPKZWBO.js";
6
- import "./chunk-BOZCY34D.js";
5
+ } from "./chunk-NL7M7QLP.js";
6
+ import "./chunk-XGFF36NR.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/openapi.yaml CHANGED
@@ -313,6 +313,80 @@ paths:
313
313
  $ref: "#/components/responses/AppError"
314
314
  "404":
315
315
  $ref: "#/components/responses/AppError"
316
+ /v1/optouts:
317
+ get:
318
+ operationId: ListOptOuts
319
+ description: Sender-specific SMS and WhatsApp opt-outs, paginated by an opaque start cursor.
320
+ security:
321
+ - appApiKey: []
322
+ x-mockingbird:
323
+ supported: true
324
+ parity: { enabled: true, safe: true }
325
+ parameters:
326
+ - name: limit
327
+ in: query
328
+ schema: { type: integer, minimum: 1, maximum: 1000, default: 100 }
329
+ - name: start
330
+ in: query
331
+ schema: { type: string }
332
+ - name: from
333
+ in: query
334
+ schema: { type: string }
335
+ responses:
336
+ "200":
337
+ description: A page of opted-out customers
338
+ content:
339
+ application/json:
340
+ schema:
341
+ type: object
342
+ required: [optouts]
343
+ properties:
344
+ next: { type: string }
345
+ optouts:
346
+ type: array
347
+ items:
348
+ type: object
349
+ required: [customer_id, cio_id, optouts]
350
+ properties:
351
+ customer_id: { type: string }
352
+ cio_id: { type: string }
353
+ optouts:
354
+ type: array
355
+ items: { $ref: "#/components/schemas/SenderOptOut" }
356
+ "400": { $ref: "#/components/responses/AppError" }
357
+ "401": { $ref: "#/components/responses/AppError" }
358
+ /v1/customers/{customer_id}/optouts:
359
+ get:
360
+ operationId: GetCustomerOptOuts
361
+ description: Sender opt-outs for an existing person; marketing preferences are separate.
362
+ security:
363
+ - appApiKey: []
364
+ x-mockingbird:
365
+ supported: true
366
+ parity: { enabled: true, safe: true }
367
+ parameters:
368
+ - name: customer_id
369
+ in: path
370
+ required: true
371
+ schema: { type: string, minLength: 1 }
372
+ - name: id_type
373
+ in: query
374
+ schema: { type: string, enum: [id, email, cio_id], default: id }
375
+ responses:
376
+ "200":
377
+ description: The customer's sender opt-outs
378
+ content:
379
+ application/json:
380
+ schema:
381
+ type: object
382
+ required: [optouts]
383
+ properties:
384
+ optouts:
385
+ type: array
386
+ items: { $ref: "#/components/schemas/SenderOptOut" }
387
+ "400": { $ref: "#/components/responses/AppError" }
388
+ "401": { $ref: "#/components/responses/AppError" }
389
+ "404": { $ref: "#/components/responses/AppError" }
316
390
  /v1/messages/{message_id}:
317
391
  parameters:
318
392
  - name: message_id
@@ -439,6 +513,12 @@ components:
439
513
  error:
440
514
  type: string
441
515
  schemas:
516
+ SenderOptOut:
517
+ type: object
518
+ required: [channel, from]
519
+ properties:
520
+ channel: { type: string, enum: [sms, whatsapp] }
521
+ from: { type: string }
442
522
  CdpSuccess:
443
523
  type: object
444
524
  required: [success]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-customerio",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Stateful mock of Customer.io: Segment-compatible CDP (identify/track/batch, SDK drop-in), App API transactional email/SMS/inbox sends with an outbox, message catalog, link-click tracking, and signed reporting webhooks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -98,7 +98,7 @@
98
98
  "pack:check": "bun ../../../scripts/pack-check.ts"
99
99
  },
100
100
  "dependencies": {
101
- "@crvouga/mockingbird-service-sqlite": "2.0.0",
101
+ "@crvouga/mockingbird-service-sqlite": "2.1.0",
102
102
  "hono": "4.11.9"
103
103
  },
104
104
  "devDependencies": {