@crvouga/mockingbird-service-flex 3.9.0 → 4.0.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.
@@ -9,7 +9,7 @@ import {
9
9
  parseFaultHeader,
10
10
  resolveAdminPrefix,
11
11
  restoreClock
12
- } from "./chunk-5DQQEGW6.js";
12
+ } from "./chunk-3FSLZROR.js";
13
13
 
14
14
  // ../../adapters/node/dist/cli.js
15
15
  import { readFile as readFile5 } from "node:fs/promises";
@@ -3057,7 +3057,7 @@ async function preflightFleet(config, options) {
3057
3057
  break;
3058
3058
  }
3059
3059
  }
3060
- targets.set(name, { ...target, packageVersion: packageVersion ?? "3.9.0" });
3060
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "4.0.0" });
3061
3061
  } catch (error) {
3062
3062
  throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3063
3063
  }
@@ -5062,4 +5062,4 @@ export {
5062
5062
  createServer2 as createServer,
5063
5063
  serveTarget
5064
5064
  };
5065
- //# sourceMappingURL=chunk-LS6VVLOL.js.map
5065
+ //# sourceMappingURL=chunk-H6USVBBB.js.map
package/dist/cli.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  runCli,
4
4
  serveCommand,
5
5
  serveTarget
6
- } from "./chunk-LS6VVLOL.js";
7
- import "./chunk-5DQQEGW6.js";
6
+ } from "./chunk-H6USVBBB.js";
7
+ import "./chunk-3FSLZROR.js";
8
8
 
9
9
  // src/cli.ts
10
10
  var code = await runCli(
package/dist/index.d.ts CHANGED
@@ -163,6 +163,8 @@ declare class Collection<T> {
163
163
  readonly namespace: string;
164
164
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
165
165
  readonly collectionName: string;
166
+ private readonly statements;
167
+ private prepare;
166
168
  constructor(sqlite: SqliteClient$1,
167
169
  /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
168
170
  namespace: string,
@@ -1492,6 +1494,12 @@ declare const FLEX_NAMESPACE = "flex";
1492
1494
  /** Every webhook event type the mock sends (our receiver reconciles on each). */
1493
1495
  declare const FLEX_EVENT_TYPES: readonly ["product.updated", "checkout.session.completed", "checkout_session.completed", "checkout.session.async_payment_succeeded", "checkout.session.async_payment_failed", "checkout.session.refunded", "checkout.session.expired", "checkout_session.expired", "payment_intent.succeeded", "customer.subscription.created", "refund.created", "refund.updated", "charge.refunded", "charge.refund.updated"];
1494
1496
  type FlexEventType = (typeof FLEX_EVENT_TYPES)[number];
1497
+ /**
1498
+ * The key Flex nests an event's object under (`EventObject` in Flex's OpenAPI): a
1499
+ * `refund.created` event carries `{refund: {...}}`, a `checkout.session.completed` event
1500
+ * `{checkout_session: {...}}`. `charge.refund.updated` carries the refund.
1501
+ */
1502
+ declare const eventObjectKey: (type: string) => string;
1495
1503
  /** The event inside the `{event: {...}}` webhook envelope. */
1496
1504
  type FlexEvent = {
1497
1505
  event_id: string;
@@ -1567,8 +1575,21 @@ declare class FlexAPI implements FetchAPI$1 {
1567
1575
  private getSession;
1568
1576
  private listSessions;
1569
1577
  private refund;
1570
- /** Refund part or all of a paid session, emitting the refund events. */
1578
+ /**
1579
+ * Refund part or all of a paid session, emitting the refund events in the order Flex sends
1580
+ * them for a dashboard refund: `refund.created` twice, `charge.refunded`, then
1581
+ * `refund.updated` and `charge.refund.updated`.
1582
+ */
1571
1583
  applyRefund(id: string, amount: number): SessionRecord | undefined;
1584
+ /** Refund a paid session from Flex's dashboard (`POST /__admin/sessions/:id/refund`). */
1585
+ dashboardRefund(id: string, amount?: number): {
1586
+ session: SessionRecord;
1587
+ } | {
1588
+ status: 400 | 404 | 409;
1589
+ message: string;
1590
+ };
1591
+ private presentRefund;
1592
+ private presentCharge;
1572
1593
  private createCustomer;
1573
1594
  private newCustomer;
1574
1595
  private getSetupIntent;
@@ -1619,5 +1640,5 @@ declare class FlexAPI implements FetchAPI$1 {
1619
1640
  /** Whether a string is one of the next-action types. */
1620
1641
  declare const isNextActionType: (value: unknown) => value is NextActionType;
1621
1642
 
1622
- export { CARDS, CORPUS_ROWS, DEFAULT_SETTINGS, ELIGIBILITIES, FLEX_EVENT_TYPES, FLEX_NAMESPACE, FLEX_PRESETS, FlexAPI, NEXT_ACTION_TYPES, PAYMENT_INTENT_STATUSES, SUBSCRIPTION_STATUSES, classifyCard, corpusProduct, createRuntime, document, isNextActionType, keyMode, operationIds, periodEnd, substituteSessionId, supportedOperationIds };
1643
+ export { CARDS, CORPUS_ROWS, DEFAULT_SETTINGS, ELIGIBILITIES, FLEX_EVENT_TYPES, FLEX_NAMESPACE, FLEX_PRESETS, FlexAPI, NEXT_ACTION_TYPES, PAYMENT_INTENT_STATUSES, SUBSCRIPTION_STATUSES, classifyCard, corpusProduct, createRuntime, document, eventObjectKey, isNextActionType, keyMode, operationIds, periodEnd, substituteSessionId, supportedOperationIds };
1623
1644
  export type { CardOutcome, CorpusRow, CustomerRecord, Eligibility, FetchAPI$1 as FetchAPI, FlexAPIOptions, FlexEvent, FlexEventType, FlexRuntime, FlexRuntimeOptions, LineItemRecord, NextAction, NextActionType, OperationId, PaymentIntentRecord, PaymentIntentStatus, PaymentMethodRecord, ProductRecord, Recurring, RefundRecord, SessionMode, SessionRecord, SessionStatus, Settings, SetupIntentRecord, SqliteClient, SubscriptionData, SubscriptionRecord, SubscriptionStatus, SupportedOperationId };
package/dist/index.js CHANGED
@@ -14,13 +14,14 @@ import {
14
14
  corpusProduct,
15
15
  createRuntime,
16
16
  document,
17
+ eventObjectKey,
17
18
  isNextActionType,
18
19
  keyMode,
19
20
  operationIds,
20
21
  periodEnd,
21
22
  substituteSessionId,
22
23
  supportedOperationIds
23
- } from "./chunk-5DQQEGW6.js";
24
+ } from "./chunk-3FSLZROR.js";
24
25
  export {
25
26
  CARDS,
26
27
  CORPUS_ROWS,
@@ -37,6 +38,7 @@ export {
37
38
  corpusProduct,
38
39
  createRuntime,
39
40
  document,
41
+ eventObjectKey,
40
42
  isNextActionType,
41
43
  keyMode,
42
44
  operationIds,
package/dist/server.d.ts CHANGED
@@ -1147,6 +1147,8 @@ declare class Collection<T> {
1147
1147
  readonly namespace: string;
1148
1148
  /** Table name inside the namespace. Stable across resets of the rows themselves. */
1149
1149
  readonly collectionName: string;
1150
+ private readonly statements;
1151
+ private prepare;
1150
1152
  constructor(sqlite: SqliteClient$1,
1151
1153
  /** Storage namespace. Admin introspection uses this to ignore another namespace's tables. */
1152
1154
  namespace: string,
@@ -2287,8 +2289,21 @@ declare class FlexAPI implements FetchAPI {
2287
2289
  private getSession;
2288
2290
  private listSessions;
2289
2291
  private refund;
2290
- /** Refund part or all of a paid session, emitting the refund events. */
2292
+ /**
2293
+ * Refund part or all of a paid session, emitting the refund events in the order Flex sends
2294
+ * them for a dashboard refund: `refund.created` twice, `charge.refunded`, then
2295
+ * `refund.updated` and `charge.refund.updated`.
2296
+ */
2291
2297
  applyRefund(id: string, amount: number): SessionRecord | undefined;
2298
+ /** Refund a paid session from Flex's dashboard (`POST /__admin/sessions/:id/refund`). */
2299
+ dashboardRefund(id: string, amount?: number): {
2300
+ session: SessionRecord;
2301
+ } | {
2302
+ status: 400 | 404 | 409;
2303
+ message: string;
2304
+ };
2305
+ private presentRefund;
2306
+ private presentCharge;
2292
2307
  private createCustomer;
2293
2308
  private newCustomer;
2294
2309
  private getSetupIntent;
package/dist/server.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  DEFAULT_PORT,
3
3
  createServer,
4
4
  serveTarget
5
- } from "./chunk-LS6VVLOL.js";
6
- import "./chunk-5DQQEGW6.js";
5
+ } from "./chunk-H6USVBBB.js";
6
+ import "./chunk-3FSLZROR.js";
7
7
  export {
8
8
  DEFAULT_PORT,
9
9
  createServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/mockingbird-service-flex",
3
- "version": "3.9.0",
3
+ "version": "4.0.0",
4
4
  "description": "Stateful emulator of the Flex HSA/FSA payments API: products (recorded catalog corpus), checkout sessions in payment, subscription, off-session and setup modes, subscriptions, customers, setup intents, refunds, the hosted checkout page, and Svix-signed webhooks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -106,7 +106,7 @@
106
106
  "pack:check": "bun ../../../scripts/pack-check.ts"
107
107
  },
108
108
  "dependencies": {
109
- "@crvouga/mockingbird-service-sqlite": "3.3.0",
109
+ "@crvouga/mockingbird-service-sqlite": "3.4.0",
110
110
  "hono": "4.11.9"
111
111
  },
112
112
  "devDependencies": {