@crvouga/mockingbird-service-paddle 2.1.0 → 2.3.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/server.d.ts CHANGED
@@ -1,34 +1,16 @@
1
1
  import { Server } from 'node:http';
2
2
  import { Hono } from 'hono';
3
3
 
4
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
5
- type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
6
- /** Mutation counters returned by {@link SqliteStatement.run}. */
7
- type SqliteRunResult$2 = {
8
- changes: number;
9
- lastInsertRowid: number | bigint;
4
+ type MountedAPI$1 = FetchAPI$2 & {
5
+ readonly prefix: string;
6
+ GET: FetchHandler$1;
7
+ POST: FetchHandler$1;
8
+ PUT: FetchHandler$1;
9
+ PATCH: FetchHandler$1;
10
+ DELETE: FetchHandler$1;
11
+ HEAD: FetchHandler$1;
12
+ OPTIONS: FetchHandler$1;
10
13
  };
11
- /**
12
- * Prepared statement bound to a {@link SqliteClient}.
13
- *
14
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
15
- */
16
- interface SqliteStatement$2 {
17
- run(...params: SqliteValue$2[]): SqliteRunResult$2;
18
- all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
19
- get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
20
- }
21
- /**
22
- * Sync SQLite client port owned by Mockingbird.
23
- *
24
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
25
- * `bun:sqlite` instances all work when they expose this surface.
26
- */
27
- interface SqliteClient$2 {
28
- exec(sql: string): void;
29
- prepare(sql: string): SqliteStatement$2;
30
- transaction<T>(fn: () => T): T;
31
- }
32
14
 
33
15
  /** A stable identifier for a point in a {@link Timeline}. */
34
16
  type CheckpointId$1 = string;
@@ -119,6 +101,37 @@ declare class Timeline$1<T> {
119
101
  interface FetchAPI$2 {
120
102
  fetch(request: Request): Promise<Response>;
121
103
  }
104
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
105
+ type FetchHandler$1 = (request: Request) => Promise<Response>;
106
+
107
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
108
+ type SqliteValue$2 = null | number | bigint | string | Uint8Array | boolean;
109
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
110
+ type SqliteRunResult$2 = {
111
+ changes: number;
112
+ lastInsertRowid: number | bigint;
113
+ };
114
+ /**
115
+ * Prepared statement bound to a {@link SqliteClient}.
116
+ *
117
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
118
+ */
119
+ interface SqliteStatement$2 {
120
+ run(...params: SqliteValue$2[]): SqliteRunResult$2;
121
+ all<T = Record<string, unknown>>(...params: SqliteValue$2[]): T[];
122
+ get<T = Record<string, unknown>>(...params: SqliteValue$2[]): T | undefined;
123
+ }
124
+ /**
125
+ * Sync SQLite client port owned by Mockingbird.
126
+ *
127
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
128
+ * `bun:sqlite` instances all work when they expose this surface.
129
+ */
130
+ interface SqliteClient$2 {
131
+ exec(sql: string): void;
132
+ prepare(sql: string): SqliteStatement$2;
133
+ transaction<T>(fn: () => T): T;
134
+ }
122
135
 
123
136
  /**
124
137
  * The single source of time for a service.
@@ -535,6 +548,8 @@ type ServiceRuntime$1<T extends ServiceInstance$1> = FetchAPI$2 & {
535
548
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
536
549
  stop?(): void;
537
550
  readonly name: string;
551
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
552
+ mount(prefix: string): MountedAPI$1;
538
553
  readonly sqlite: SqliteClient$2;
539
554
  readonly clock: Clock$1;
540
555
  readonly faults: FaultRegistry$1;
@@ -601,6 +616,9 @@ type CommonServeOptions = {
601
616
  adminKey: string | undefined;
602
617
  seed: string | undefined;
603
618
  onLog: ((entry: RequestLog$1) => void) | undefined;
619
+ /** Synthetic provider fixture objects supplied by a fleet entry. */
620
+ fixtures?: Record<string, unknown>;
621
+ baseUrl?: string;
604
622
  };
605
623
  /**
606
624
  * What a service contributes to `serve`: how to build its runtime from CLI flags,
@@ -619,76 +637,16 @@ type ServeTarget = {
619
637
  listening?(server: Listening): void;
620
638
  };
621
639
 
622
- /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
623
- type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
624
- /** Mutation counters returned by {@link SqliteStatement.run}. */
625
- type SqliteRunResult$1 = {
626
- changes: number;
627
- lastInsertRowid: number | bigint;
640
+ type MountedAPI = FetchAPI$1 & {
641
+ readonly prefix: string;
642
+ GET: FetchHandler;
643
+ POST: FetchHandler;
644
+ PUT: FetchHandler;
645
+ PATCH: FetchHandler;
646
+ DELETE: FetchHandler;
647
+ HEAD: FetchHandler;
648
+ OPTIONS: FetchHandler;
628
649
  };
629
- /**
630
- * Prepared statement bound to a {@link SqliteClient}.
631
- *
632
- * Pass bind values as rest arguments on each call (no sticky `bind()`).
633
- */
634
- interface SqliteStatement$1 {
635
- run(...params: SqliteValue$1[]): SqliteRunResult$1;
636
- all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
637
- get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
638
- }
639
- /**
640
- * Sync SQLite client port owned by Mockingbird.
641
- *
642
- * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
643
- * `bun:sqlite` instances all work when they expose this surface.
644
- */
645
- interface SqliteClient$1 {
646
- exec(sql: string): void;
647
- prepare(sql: string): SqliteStatement$1;
648
- transaction<T>(fn: () => T): T;
649
- }
650
-
651
- /** Every stored record carries a monotonically increasing sequence for stable ordering. */
652
- type Stored<T> = {
653
- seq: number;
654
- value: T;
655
- };
656
- type ListRecordsOptions<T> = {
657
- /** Keep only records passing the predicate. */
658
- where?: (value: T, seq: number) => boolean;
659
- /** Sort order; default newest first. */
660
- order?: "newest" | "oldest";
661
- };
662
- /**
663
- * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
664
- * sequence, never by id lexicographic order, so list semantics stay stable.
665
- */
666
- declare class Collection<T> {
667
- private readonly sqlite;
668
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
669
- readonly namespace: string;
670
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
671
- readonly collectionName: string;
672
- constructor(sqlite: SqliteClient$1,
673
- /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
674
- namespace: string,
675
- /** Table name inside the namespace. Stable across resets of the rows themselves. */
676
- collectionName: string);
677
- private bumpCollectionSeq;
678
- nextSequence(): number;
679
- get(id: string): T | undefined;
680
- has(id: string): boolean;
681
- /** Insert a new record, assigning it the next sequence number. */
682
- insert(id: string, value: T): Stored<T>;
683
- /** Replace an existing record's value, keeping its position. */
684
- update(id: string, value: T): Stored<T> | undefined;
685
- delete(id: string): boolean;
686
- /** How many records the collection holds, without reading them. */
687
- count(): number;
688
- list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
689
- id: string;
690
- }>;
691
- }
692
650
 
693
651
  /** A stable identifier for a point in a {@link Timeline}. */
694
652
  type CheckpointId = string;
@@ -779,6 +737,79 @@ declare class Timeline<T> {
779
737
  interface FetchAPI$1 {
780
738
  fetch(request: Request): Promise<Response>;
781
739
  }
740
+ /** A bare function form of {@link FetchAPI}, compatible with `Bun.serve`, workerd, and Deno. */
741
+ type FetchHandler = (request: Request) => Promise<Response>;
742
+
743
+ /** Bind values accepted by Mockingbird's SQLite port (matches sqlite-mem / better-sqlite3). */
744
+ type SqliteValue$1 = null | number | bigint | string | Uint8Array | boolean;
745
+ /** Mutation counters returned by {@link SqliteStatement.run}. */
746
+ type SqliteRunResult$1 = {
747
+ changes: number;
748
+ lastInsertRowid: number | bigint;
749
+ };
750
+ /**
751
+ * Prepared statement bound to a {@link SqliteClient}.
752
+ *
753
+ * Pass bind values as rest arguments on each call (no sticky `bind()`).
754
+ */
755
+ interface SqliteStatement$1 {
756
+ run(...params: SqliteValue$1[]): SqliteRunResult$1;
757
+ all<T = Record<string, unknown>>(...params: SqliteValue$1[]): T[];
758
+ get<T = Record<string, unknown>>(...params: SqliteValue$1[]): T | undefined;
759
+ }
760
+ /**
761
+ * Sync SQLite client port owned by Mockingbird.
762
+ *
763
+ * Duck-typed so `@crvouga/mockingbird-service-sqlite` `Database`, better-sqlite3, and wrapped
764
+ * `bun:sqlite` instances all work when they expose this surface.
765
+ */
766
+ interface SqliteClient$1 {
767
+ exec(sql: string): void;
768
+ prepare(sql: string): SqliteStatement$1;
769
+ transaction<T>(fn: () => T): T;
770
+ }
771
+
772
+ /** Every stored record carries a monotonically increasing sequence for stable ordering. */
773
+ type Stored<T> = {
774
+ seq: number;
775
+ value: T;
776
+ };
777
+ type ListRecordsOptions<T> = {
778
+ /** Keep only records passing the predicate. */
779
+ where?: (value: T, seq: number) => boolean;
780
+ /** Sort order; default newest first. */
781
+ order?: "newest" | "oldest";
782
+ };
783
+ /**
784
+ * A SQLite-backed table of JSON records addressed by id. Ordering is by insertion
785
+ * sequence, never by id lexicographic order, so list semantics stay stable.
786
+ */
787
+ declare class Collection<T> {
788
+ private readonly sqlite;
789
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
790
+ readonly namespace: string;
791
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
792
+ readonly collectionName: string;
793
+ constructor(sqlite: SqliteClient$1,
794
+ /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
795
+ namespace: string,
796
+ /** Table name inside the namespace. Stable across resets of the rows themselves. */
797
+ collectionName: string);
798
+ private bumpCollectionSeq;
799
+ nextSequence(): number;
800
+ get(id: string): T | undefined;
801
+ has(id: string): boolean;
802
+ /** Insert a new record, assigning it the next sequence number. */
803
+ insert(id: string, value: T): Stored<T>;
804
+ /** Replace an existing record's value, keeping its position. */
805
+ update(id: string, value: T): Stored<T> | undefined;
806
+ delete(id: string): boolean;
807
+ /** How many records the collection holds, without reading them. */
808
+ count(): number;
809
+ list(options?: ListRecordsOptions<T>): Array<Stored<T> & {
810
+ id: string;
811
+ }>;
812
+ }
782
813
 
783
814
  /** Options every provider constructor accepts. */
784
815
  type APIOptions = {
@@ -1208,6 +1239,8 @@ type ServiceRuntime<T extends ServiceInstance> = FetchAPI$1 & {
1208
1239
  /** Stop package-owned lifecycle timers when a supervisor closes the runtime. */
1209
1240
  stop?(): void;
1210
1241
  readonly name: string;
1242
+ /** Same-origin Fetch handler and App Router method exports, sharing this runtime. */
1243
+ mount(prefix: string): MountedAPI;
1211
1244
  readonly sqlite: SqliteClient$1;
1212
1245
  readonly clock: Clock;
1213
1246
  readonly faults: FaultRegistry;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-VDA33BHD.js";
6
- import "./chunk-RX7CMM47.js";
5
+ } from "./chunk-XSOS4D65.js";
6
+ import "./chunk-TQ4AJYOC.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/openapi.yaml CHANGED
@@ -2,11 +2,11 @@ openapi: 3.1.0
2
2
  info:
3
3
  title: Paddle Billing API (Mockingbird subset)
4
4
  description: |
5
- Stateful mock subset of the Paddle Billing API: customers with their addresses and
5
+ Stateful emulator subset of the Paddle Billing API: customers with their addresses and
6
6
  businesses, the catalog (products and prices), transactions with computed totals,
7
7
  subscriptions with their lifecycle (activate, pause, resume, cancel, one-time charges,
8
8
  renewals) and the events list. Subscriptions come from paid transactions, as in Paddle:
9
- the mock's admin routes stand in for the hosted checkout and the billing engine.
9
+ the emulator's admin routes stand in for the hosted checkout and the billing engine.
10
10
  version: "1"
11
11
  x-mockingbird-upstream:
12
12
  note: >-
@@ -157,7 +157,7 @@ paths:
157
157
  safe: true
158
158
  responses:
159
159
  "200":
160
- description: One balance per currency the customer holds credit in (none, in the mock)
160
+ description: One balance per currency the customer holds credit in (none, in the emulator)
161
161
  content:
162
162
  application/json:
163
163
  schema:
@@ -1346,7 +1346,7 @@ paths:
1346
1346
  operationId: GetSubscriptionPaymentMethodChangeTransaction
1347
1347
  x-mockingbird:
1348
1348
  supported: false
1349
- reason: Payment method changes go through the hosted checkout, which the mock does not serve.
1349
+ reason: Payment method changes go through the hosted checkout, which the emulator does not serve.
1350
1350
  responses:
1351
1351
  "200":
1352
1352
  description: A zero-amount transaction for updating the payment method
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-paddle",
3
- "version": "2.1.0",
4
- "description": "Stateful mock of the Paddle Billing API (customers, addresses, businesses, products, prices, transactions with computed totals, subscriptions with pause/resume/cancel and renewals, events) with Paddle-Signature webhooks and admin routes that simulate checkout, renewals and failed payments (Mockingbird service contract).",
3
+ "version": "2.3.0",
4
+ "description": "Stateful emulator of the Paddle Billing API (customers, addresses, businesses, products, prices, transactions with computed totals, subscriptions with pause/resume/cancel and renewals, events) with Paddle-Signature webhooks and admin routes that simulate checkout, renewals and failed payments (Mockingbird service contract).",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -46,7 +46,7 @@
46
46
  "subscriptions",
47
47
  "payments",
48
48
  "webhooks",
49
- "mock"
49
+ "emulator"
50
50
  ],
51
51
  "mockingbird": {
52
52
  "runtime": "portable",
@@ -105,7 +105,7 @@
105
105
  "pack:check": "bun ../../../scripts/pack-check.ts"
106
106
  },
107
107
  "dependencies": {
108
- "@crvouga/mockingbird-service-sqlite": "3.0.0",
108
+ "@crvouga/mockingbird-service-sqlite": "3.2.0",
109
109
  "hono": "4.11.9"
110
110
  },
111
111
  "devDependencies": {