@crvouga/mockingbird-service-flex 3.10.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-NKBXNJ5B.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.10.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-OATZRDML.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-OATZRDML.js";
7
- import "./chunk-NKBXNJ5B.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
@@ -1494,6 +1494,12 @@ declare const FLEX_NAMESPACE = "flex";
1494
1494
  /** Every webhook event type the mock sends (our receiver reconciles on each). */
1495
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"];
1496
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;
1497
1503
  /** The event inside the `{event: {...}}` webhook envelope. */
1498
1504
  type FlexEvent = {
1499
1505
  event_id: string;
@@ -1569,8 +1575,21 @@ declare class FlexAPI implements FetchAPI$1 {
1569
1575
  private getSession;
1570
1576
  private listSessions;
1571
1577
  private refund;
1572
- /** 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
+ */
1573
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;
1574
1593
  private createCustomer;
1575
1594
  private newCustomer;
1576
1595
  private getSetupIntent;
@@ -1621,5 +1640,5 @@ declare class FlexAPI implements FetchAPI$1 {
1621
1640
  /** Whether a string is one of the next-action types. */
1622
1641
  declare const isNextActionType: (value: unknown) => value is NextActionType;
1623
1642
 
1624
- 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 };
1625
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-NKBXNJ5B.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
@@ -2289,8 +2289,21 @@ declare class FlexAPI implements FetchAPI {
2289
2289
  private getSession;
2290
2290
  private listSessions;
2291
2291
  private refund;
2292
- /** 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
+ */
2293
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;
2294
2307
  private createCustomer;
2295
2308
  private newCustomer;
2296
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-OATZRDML.js";
6
- import "./chunk-NKBXNJ5B.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.10.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",