@aglyn/plugins-commerce 1.22.3 → 1.23.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-commerce",
3
- "version": "1.22.3",
3
+ "version": "1.23.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,18 +25,18 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.22.3",
29
- "@aglyn/shared-data-mdi": "1.22.3",
30
- "@aglyn/shared-ui-jsx": "1.22.3",
31
- "@aglyn/shared-ui-next": "1.22.3",
32
- "@aglyn/shared-ui-snackstack": "1.22.3",
33
- "@aglyn/shared-util-email": "1.22.3",
34
- "@aglyn/shared-util-http": "1.22.3",
35
- "@aglyn/shared-util-timestamp": "1.22.3",
36
- "@aglyn/shared-util-tools": "1.22.3",
37
- "@aglyn/tenant-data-admin": "1.22.3",
38
- "@aglyn/tenant-feature-instance": "1.22.3",
39
- "@aglyn/tenant-runtime": "1.22.3",
28
+ "@aglyn/aglyn": "1.23.0",
29
+ "@aglyn/shared-data-mdi": "1.23.0",
30
+ "@aglyn/shared-ui-jsx": "1.23.0",
31
+ "@aglyn/shared-ui-next": "1.23.0",
32
+ "@aglyn/shared-ui-snackstack": "1.23.0",
33
+ "@aglyn/shared-util-email": "1.23.0",
34
+ "@aglyn/shared-util-http": "1.23.0",
35
+ "@aglyn/shared-util-timestamp": "1.23.0",
36
+ "@aglyn/shared-util-tools": "1.23.0",
37
+ "@aglyn/tenant-data-admin": "1.23.0",
38
+ "@aglyn/tenant-feature-instance": "1.23.0",
39
+ "@aglyn/tenant-runtime": "1.23.0",
40
40
  "@stripe/react-stripe-js": "^7.0.1",
41
41
  "@stripe/stripe-js": "^10.2.1",
42
42
  "@swc/helpers": "0.5.24",
@@ -65,7 +65,23 @@ export interface OrderEventOrder {
65
65
  feeCents: number;
66
66
  /** Optional lines the buyer added at checkout (AGL-3635), inside `totalCents` and outside `itemsCents`. */
67
67
  extrasCents?: number;
68
+ /** A register tip (AGL-3607), on top of `totalCents`; the merchant's, not revenue. */
69
+ tipCents?: number;
68
70
  };
71
+ /**
72
+ * How a register sale was paid (AGL-3614): each tender that succeeded, with
73
+ * its tip and the application fee Stripe took from it. Only the card
74
+ * tenders (`card_present`, `card_keyed`, `card_link`) went through Stripe.
75
+ * Empty for a sale that is not the register's.
76
+ */
77
+ payments?: Array<{
78
+ method: 'cash' | 'card_present' | 'card_keyed' | 'card_link' | 'gift_card' | 'folio' | 'credit';
79
+ amountCents: number;
80
+ tipCents: number;
81
+ feeCents: number;
82
+ }>;
83
+ /** The part of `totals.discountCents` a gift card paid online (AGL-3614). */
84
+ giftCardRedeemedCents?: number;
69
85
  refundedCents: number;
70
86
  /** The tax regime: `stripe-automatic`, `manual`, `none`, or `null` when not recorded. */
71
87
  taxMode: string | null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/commerce/src/lib/contracts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { definePluginDomainEvent } from '@aglyn/aglyn/plugin-manager/plugin-domain-events'\nimport { definePluginServiceContract } from '@aglyn/aglyn/plugin-manager/plugin-services'\n\n/**\n * What commerce publishes for other plugins (AGL-3980): the order and return\n * events it raises, the checkout it reports, and the order history service it\n * registers — each by its id and its shape, and nothing that runs commerce.\n *\n * Another plugin imports this module as `@aglyn/plugins-commerce/contracts`,\n * names `commerce` in its `uses` in plugins.config.json, and carries\n * `@aglyn/plugins-commerce` as an optional peer. Importing it never loads\n * commerce, so the subscriber still runs with commerce absent: an event it\n * listens for is simply never raised, and the history service resolves to\n * `null`. `check:lib-boundaries` refuses a runtime import here other than\n * `@aglyn/aglyn`, and any other import of commerce from another plugin.\n */\n\n// ── Events (AGL-3611) ────────────────────────────────────────────────────────\n//\n// Each payload carries `order` in the public API's shape (`GET\n// /v1/sites/{siteId}/orders/{orderId}`), as it stood once the fact was\n// written, so a subscriber reads one documented object rather than the\n// plugin's storage.\n\n/** A shipment as the order itself lists it. */\nexport interface OrderViewFulfillment {\n id: string | null\n lineItemIds: unknown[]\n /** Units per line; a fulfillment recorded before quantities shipped every unit of the lines it names. */\n lines: Array<{ lineItemId: number; quantity: number }>\n status: 'active' | 'cancelled'\n carrier: string | null\n trackingNumber: string | null\n trackingUrl: string | null\n labelUrl: string | null\n /** ISO 8601. */\n at: string | null\n}\n\n/** An order as the public API returns it. Money is integer cents. */\nexport interface OrderEventOrder {\n id: string\n object: 'order'\n number: number | null\n status: string | null\n channel: string\n currency: string\n customerEmail: string | null\n customerName: string | null\n /** The lines as stored, serialized; their fields are not a contract yet. */\n lineItems: unknown\n totals: {\n itemsCents: number\n shippingCents: number\n taxCents: number\n discountCents: number\n totalCents: number | null\n feeCents: number\n /** Optional lines the buyer added at checkout (AGL-3635), inside `totalCents` and outside `itemsCents`. */\n extrasCents?: number\n }\n refundedCents: number\n /** The tax regime: `stripe-automatic`, `manual`, `none`, or `null` when not recorded. */\n taxMode: string | null\n /** Whether real money moved (AGL-3699): `false` for a Stripe test-mode order. */\n livemode?: boolean\n /** The optional lines the buyer added at checkout and whose offer each was (AGL-3635). */\n extras?: Array<{\n id: string\n pluginId: string\n key: string\n label: string\n amountCents: number\n quoteRef: string | null\n }>\n /** Store credit another plugin kept that paid part of the sale (AGL-3640). */\n credits?: Array<{\n providerId: string\n pluginId: string\n reference: string\n label: string\n last4: string\n amountCents: number\n appliedAs: 'discount' | 'tender'\n }>\n /** The merchant's own tax service that priced the sale (AGL-3631); `null` when none was asked. */\n taxEngine?: {\n provider: string\n providerLabel: string\n status: 'quoted' | 'fallback'\n reason: string | null\n sandbox: boolean\n } | null\n disputed?: boolean\n /** The address as stored, serialized; `null` for an order that ships nowhere. */\n shippingAddress?: Record<string, unknown> | null\n couponCode?: string | null\n fulfillments?: OrderViewFulfillment[]\n /** ISO 8601. */\n created?: string | null\n [key: string]: unknown\n}\n\n/** A shipment as an event carries it. */\nexport interface OrderEventFulfillment {\n id: string\n lines: Array<{ lineItemId: number; quantity: number }>\n carrier: string | null\n trackingNumber: string | null\n trackingUrl: string | null\n labelUrl: string | null\n /** What the shipment cost to send — its label's cost, or the merchant's hand-entered one (AGL-3705) — in integer cents of the order's currency; `null` when unknown (AGL-3693). */\n labelCostCents: number | null\n at: string\n}\n\n/** A refund as an event carries it: what THIS refund moved. */\nexport interface OrderEventRefund {\n /** Stripe's refund id, when there is one. */\n id: string | null\n amountCents: number\n /** The line indexes refunded by name; empty for an amount-only refund. */\n lineItemIds: number[]\n /** Whether this refund left nothing more to refund. */\n full: boolean\n}\n\n/** A return as an event carries it. */\nexport interface OrderEventReturn {\n id: string\n status: string\n lines: Array<{ lineItemId: number; quantity: number; reason: string }>\n refundCents: number | null\n /** What went back in stock when the parcel arrived; `null` before then. */\n restock?: Array<{ lineItemId: number; quantity: number }> | null\n}\n\nexport interface OrderEventPayload {\n order: OrderEventOrder\n}\nexport interface OrderFulfilledEventPayload extends OrderEventPayload {\n fulfillment: OrderEventFulfillment\n}\nexport interface OrderRefundedEventPayload extends OrderEventPayload {\n refund: OrderEventRefund\n}\nexport interface ReturnEventPayload extends OrderEventPayload {\n return: OrderEventReturn\n}\n\nexport const ORDER_PAID_EVENT = definePluginDomainEvent<OrderEventPayload>('order.paid')\nexport const ORDER_FULFILLED_EVENT = definePluginDomainEvent<OrderFulfilledEventPayload>('order.fulfilled')\nexport const ORDER_DELIVERED_EVENT = definePluginDomainEvent<OrderEventPayload>('order.delivered')\nexport const ORDER_REFUNDED_EVENT = definePluginDomainEvent<OrderRefundedEventPayload>('order.refunded')\nexport const ORDER_CANCELLED_EVENT = definePluginDomainEvent<OrderEventPayload>('order.cancelled')\nexport const RETURN_REQUESTED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.requested')\nexport const RETURN_APPROVED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.approved')\nexport const RETURN_DECLINED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.declined')\nexport const RETURN_RECEIVED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.received')\nexport const RETURN_REFUNDED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.refunded')\n\n/**\n * A checkout a shopper reached with an address (AGL-3639): the fact an\n * abandoned-cart flow in a merchant's own email platform starts from. Not an\n * order event — nothing was bought — so it is raised beside them rather than\n * among them: it is not a workflow trigger and not offered to the merchant's\n * outbound webhooks, whose events are about orders.\n */\nexport interface CheckoutStartedEventPayload {\n checkout: {\n /** The checkout session's id: one event per checkout. */\n id: string\n email: string\n /** Whether the shopper ticked the store's marketing box at checkout. */\n marketingOptIn: boolean\n currency: string\n /** The basket's list value, integer cents, before discounts and shipping. */\n itemsCents: number\n /** Where the shopper can pick the checkout up again. */\n resumeUrl: string | null\n items: Array<{\n productId: string\n variantId: string | null\n name: string\n sku: string | null\n quantity: number\n unitCents: number\n }>\n }\n}\n\nexport const CHECKOUT_STARTED_EVENT = definePluginDomainEvent<CheckoutStartedEventPayload>('checkout.started')\n\n/** Every order and return event commerce raises, by name. */\nexport type CommerceEventName =\n | 'order.paid'\n | 'order.fulfilled'\n | 'order.delivered'\n | 'order.refunded'\n | 'order.cancelled'\n | 'return.requested'\n | 'return.approved'\n | 'return.declined'\n | 'return.received'\n | 'return.refunded'\n\n/** The order lifecycle's five events, by name. */\nexport type CommerceOrderEventName = Extract<CommerceEventName, `order.${string}`>\n\n/** The event names, for a webhook's event picker. */\nexport const COMMERCE_EVENT_NAMES: readonly CommerceEventName[] = [\n 'order.paid',\n 'order.fulfilled',\n 'order.delivered',\n 'order.refunded',\n 'order.cancelled',\n 'return.requested',\n 'return.approved',\n 'return.declined',\n 'return.received',\n 'return.refunded',\n]\n\n// ── Order history (AGL-3614) ─────────────────────────────────────────────────\n//\n// The events bring every order from the moment a subscriber listens. A plugin\n// that must also read the orders BEFORE that — accounting, posting a\n// merchant's earlier sales from a start date — reads them through this\n// service, in the same public shape the events carry, and never through\n// commerce's storage. Commerce registers the one implementation from its\n// console server declarations; with commerce absent it resolves to `null`.\n\n/** One stored order, as the history hands it out. */\nexport interface OrderHistoryEntry {\n id: string\n createdAtMs: number\n /** When it was paid; `null` for one never paid. */\n paidAtMs: number | null\n /** The newest refund on its timeline, or `null`. */\n lastRefundAtMs: number | null\n /** Whether its prices include the tax. */\n taxInclusive: boolean\n /** The tax rate it was charged under, when one was named. */\n taxRateId: string | null\n /** The order in the public API's shape. */\n order: OrderEventOrder\n}\n\nexport interface OrderHistoryPageRequest {\n hostId: string\n /** Orders created at or after this… */\n fromMs: number\n /** …and before this. */\n untilMs: number\n /** At most this many, oldest first; capped at 200. */\n limit: number\n}\n\nexport interface OrderHistoryReader {\n listOrders(request: OrderHistoryPageRequest): Promise<OrderHistoryEntry[]>\n}\n\nexport const ORDER_HISTORY_CONTRACT_ID = 'commerce.orderHistory'\n\nexport const ORDER_HISTORY_CONTRACT = definePluginServiceContract<OrderHistoryReader>(ORDER_HISTORY_CONTRACT_ID, {\n multiple: false,\n})\n"],"names":["definePluginDomainEvent","definePluginServiceContract","ORDER_PAID_EVENT","ORDER_FULFILLED_EVENT","ORDER_DELIVERED_EVENT","ORDER_REFUNDED_EVENT","ORDER_CANCELLED_EVENT","RETURN_REQUESTED_EVENT","RETURN_APPROVED_EVENT","RETURN_DECLINED_EVENT","RETURN_RECEIVED_EVENT","RETURN_REFUNDED_EVENT","CHECKOUT_STARTED_EVENT","COMMERCE_EVENT_NAMES","ORDER_HISTORY_CONTRACT_ID","ORDER_HISTORY_CONTRACT","multiple"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,2BAA2B,QAAQ,8CAA6C;AAqJzF,OAAO,MAAMC,mBAAmBF,wBAA2C,cAAa;AACxF,OAAO,MAAMG,wBAAwBH,wBAAoD,mBAAkB;AAC3G,OAAO,MAAMI,wBAAwBJ,wBAA2C,mBAAkB;AAClG,OAAO,MAAMK,uBAAuBL,wBAAmD,kBAAiB;AACxG,OAAO,MAAMM,wBAAwBN,wBAA2C,mBAAkB;AAClG,OAAO,MAAMO,yBAAyBP,wBAA4C,oBAAmB;AACrG,OAAO,MAAMQ,wBAAwBR,wBAA4C,mBAAkB;AACnG,OAAO,MAAMS,wBAAwBT,wBAA4C,mBAAkB;AACnG,OAAO,MAAMU,wBAAwBV,wBAA4C,mBAAkB;AACnG,OAAO,MAAMW,wBAAwBX,wBAA4C,mBAAkB;AAgCnG,OAAO,MAAMY,yBAAyBZ,wBAAqD,oBAAmB;AAkB9G,mDAAmD,GACnD,OAAO,MAAMa,uBAAqD;IAChE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAyCD,OAAO,MAAMC,4BAA4B,wBAAuB;AAEhE,OAAO,MAAMC,yBAAyBd,4BAAgDa,2BAA2B;IAC/GE,UAAU;AACZ,GAAE"}
1
+ {"version":3,"sources":["../../../../../../libs/plugins/commerce/src/lib/contracts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { definePluginDomainEvent } from '@aglyn/aglyn/plugin-manager/plugin-domain-events'\nimport { definePluginServiceContract } from '@aglyn/aglyn/plugin-manager/plugin-services'\n\n/**\n * What commerce publishes for other plugins (AGL-3980): the order and return\n * events it raises, the checkout it reports, and the order history service it\n * registers — each by its id and its shape, and nothing that runs commerce.\n *\n * Another plugin imports this module as `@aglyn/plugins-commerce/contracts`,\n * names `commerce` in its `uses` in plugins.config.json, and carries\n * `@aglyn/plugins-commerce` as an optional peer. Importing it never loads\n * commerce, so the subscriber still runs with commerce absent: an event it\n * listens for is simply never raised, and the history service resolves to\n * `null`. `check:lib-boundaries` refuses a runtime import here other than\n * `@aglyn/aglyn`, and any other import of commerce from another plugin.\n */\n\n// ── Events (AGL-3611) ────────────────────────────────────────────────────────\n//\n// Each payload carries `order` in the public API's shape (`GET\n// /v1/sites/{siteId}/orders/{orderId}`), as it stood once the fact was\n// written, so a subscriber reads one documented object rather than the\n// plugin's storage.\n\n/** A shipment as the order itself lists it. */\nexport interface OrderViewFulfillment {\n id: string | null\n lineItemIds: unknown[]\n /** Units per line; a fulfillment recorded before quantities shipped every unit of the lines it names. */\n lines: Array<{ lineItemId: number; quantity: number }>\n status: 'active' | 'cancelled'\n carrier: string | null\n trackingNumber: string | null\n trackingUrl: string | null\n labelUrl: string | null\n /** ISO 8601. */\n at: string | null\n}\n\n/** An order as the public API returns it. Money is integer cents. */\nexport interface OrderEventOrder {\n id: string\n object: 'order'\n number: number | null\n status: string | null\n channel: string\n currency: string\n customerEmail: string | null\n customerName: string | null\n /** The lines as stored, serialized; their fields are not a contract yet. */\n lineItems: unknown\n totals: {\n itemsCents: number\n shippingCents: number\n taxCents: number\n discountCents: number\n totalCents: number | null\n feeCents: number\n /** Optional lines the buyer added at checkout (AGL-3635), inside `totalCents` and outside `itemsCents`. */\n extrasCents?: number\n /** A register tip (AGL-3607), on top of `totalCents`; the merchant's, not revenue. */\n tipCents?: number\n }\n /**\n * How a register sale was paid (AGL-3614): each tender that succeeded, with\n * its tip and the application fee Stripe took from it. Only the card\n * tenders (`card_present`, `card_keyed`, `card_link`) went through Stripe.\n * Empty for a sale that is not the register's.\n */\n payments?: Array<{\n method: 'cash' | 'card_present' | 'card_keyed' | 'card_link' | 'gift_card' | 'folio' | 'credit'\n amountCents: number\n tipCents: number\n feeCents: number\n }>\n /** The part of `totals.discountCents` a gift card paid online (AGL-3614). */\n giftCardRedeemedCents?: number\n refundedCents: number\n /** The tax regime: `stripe-automatic`, `manual`, `none`, or `null` when not recorded. */\n taxMode: string | null\n /** Whether real money moved (AGL-3699): `false` for a Stripe test-mode order. */\n livemode?: boolean\n /** The optional lines the buyer added at checkout and whose offer each was (AGL-3635). */\n extras?: Array<{\n id: string\n pluginId: string\n key: string\n label: string\n amountCents: number\n quoteRef: string | null\n }>\n /** Store credit another plugin kept that paid part of the sale (AGL-3640). */\n credits?: Array<{\n providerId: string\n pluginId: string\n reference: string\n label: string\n last4: string\n amountCents: number\n appliedAs: 'discount' | 'tender'\n }>\n /** The merchant's own tax service that priced the sale (AGL-3631); `null` when none was asked. */\n taxEngine?: {\n provider: string\n providerLabel: string\n status: 'quoted' | 'fallback'\n reason: string | null\n sandbox: boolean\n } | null\n disputed?: boolean\n /** The address as stored, serialized; `null` for an order that ships nowhere. */\n shippingAddress?: Record<string, unknown> | null\n couponCode?: string | null\n fulfillments?: OrderViewFulfillment[]\n /** ISO 8601. */\n created?: string | null\n [key: string]: unknown\n}\n\n/** A shipment as an event carries it. */\nexport interface OrderEventFulfillment {\n id: string\n lines: Array<{ lineItemId: number; quantity: number }>\n carrier: string | null\n trackingNumber: string | null\n trackingUrl: string | null\n labelUrl: string | null\n /** What the shipment cost to send — its label's cost, or the merchant's hand-entered one (AGL-3705) — in integer cents of the order's currency; `null` when unknown (AGL-3693). */\n labelCostCents: number | null\n at: string\n}\n\n/** A refund as an event carries it: what THIS refund moved. */\nexport interface OrderEventRefund {\n /** Stripe's refund id, when there is one. */\n id: string | null\n amountCents: number\n /** The line indexes refunded by name; empty for an amount-only refund. */\n lineItemIds: number[]\n /** Whether this refund left nothing more to refund. */\n full: boolean\n}\n\n/** A return as an event carries it. */\nexport interface OrderEventReturn {\n id: string\n status: string\n lines: Array<{ lineItemId: number; quantity: number; reason: string }>\n refundCents: number | null\n /** What went back in stock when the parcel arrived; `null` before then. */\n restock?: Array<{ lineItemId: number; quantity: number }> | null\n}\n\nexport interface OrderEventPayload {\n order: OrderEventOrder\n}\nexport interface OrderFulfilledEventPayload extends OrderEventPayload {\n fulfillment: OrderEventFulfillment\n}\nexport interface OrderRefundedEventPayload extends OrderEventPayload {\n refund: OrderEventRefund\n}\nexport interface ReturnEventPayload extends OrderEventPayload {\n return: OrderEventReturn\n}\n\nexport const ORDER_PAID_EVENT = definePluginDomainEvent<OrderEventPayload>('order.paid')\nexport const ORDER_FULFILLED_EVENT = definePluginDomainEvent<OrderFulfilledEventPayload>('order.fulfilled')\nexport const ORDER_DELIVERED_EVENT = definePluginDomainEvent<OrderEventPayload>('order.delivered')\nexport const ORDER_REFUNDED_EVENT = definePluginDomainEvent<OrderRefundedEventPayload>('order.refunded')\nexport const ORDER_CANCELLED_EVENT = definePluginDomainEvent<OrderEventPayload>('order.cancelled')\nexport const RETURN_REQUESTED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.requested')\nexport const RETURN_APPROVED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.approved')\nexport const RETURN_DECLINED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.declined')\nexport const RETURN_RECEIVED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.received')\nexport const RETURN_REFUNDED_EVENT = definePluginDomainEvent<ReturnEventPayload>('return.refunded')\n\n/**\n * A checkout a shopper reached with an address (AGL-3639): the fact an\n * abandoned-cart flow in a merchant's own email platform starts from. Not an\n * order event — nothing was bought — so it is raised beside them rather than\n * among them: it is not a workflow trigger and not offered to the merchant's\n * outbound webhooks, whose events are about orders.\n */\nexport interface CheckoutStartedEventPayload {\n checkout: {\n /** The checkout session's id: one event per checkout. */\n id: string\n email: string\n /** Whether the shopper ticked the store's marketing box at checkout. */\n marketingOptIn: boolean\n currency: string\n /** The basket's list value, integer cents, before discounts and shipping. */\n itemsCents: number\n /** Where the shopper can pick the checkout up again. */\n resumeUrl: string | null\n items: Array<{\n productId: string\n variantId: string | null\n name: string\n sku: string | null\n quantity: number\n unitCents: number\n }>\n }\n}\n\nexport const CHECKOUT_STARTED_EVENT = definePluginDomainEvent<CheckoutStartedEventPayload>('checkout.started')\n\n/** Every order and return event commerce raises, by name. */\nexport type CommerceEventName =\n | 'order.paid'\n | 'order.fulfilled'\n | 'order.delivered'\n | 'order.refunded'\n | 'order.cancelled'\n | 'return.requested'\n | 'return.approved'\n | 'return.declined'\n | 'return.received'\n | 'return.refunded'\n\n/** The order lifecycle's five events, by name. */\nexport type CommerceOrderEventName = Extract<CommerceEventName, `order.${string}`>\n\n/** The event names, for a webhook's event picker. */\nexport const COMMERCE_EVENT_NAMES: readonly CommerceEventName[] = [\n 'order.paid',\n 'order.fulfilled',\n 'order.delivered',\n 'order.refunded',\n 'order.cancelled',\n 'return.requested',\n 'return.approved',\n 'return.declined',\n 'return.received',\n 'return.refunded',\n]\n\n// ── Order history (AGL-3614) ─────────────────────────────────────────────────\n//\n// The events bring every order from the moment a subscriber listens. A plugin\n// that must also read the orders BEFORE that — accounting, posting a\n// merchant's earlier sales from a start date — reads them through this\n// service, in the same public shape the events carry, and never through\n// commerce's storage. Commerce registers the one implementation from its\n// console server declarations; with commerce absent it resolves to `null`.\n\n/** One stored order, as the history hands it out. */\nexport interface OrderHistoryEntry {\n id: string\n createdAtMs: number\n /** When it was paid; `null` for one never paid. */\n paidAtMs: number | null\n /** The newest refund on its timeline, or `null`. */\n lastRefundAtMs: number | null\n /** Whether its prices include the tax. */\n taxInclusive: boolean\n /** The tax rate it was charged under, when one was named. */\n taxRateId: string | null\n /** The order in the public API's shape. */\n order: OrderEventOrder\n}\n\nexport interface OrderHistoryPageRequest {\n hostId: string\n /** Orders created at or after this… */\n fromMs: number\n /** …and before this. */\n untilMs: number\n /** At most this many, oldest first; capped at 200. */\n limit: number\n}\n\nexport interface OrderHistoryReader {\n listOrders(request: OrderHistoryPageRequest): Promise<OrderHistoryEntry[]>\n}\n\nexport const ORDER_HISTORY_CONTRACT_ID = 'commerce.orderHistory'\n\nexport const ORDER_HISTORY_CONTRACT = definePluginServiceContract<OrderHistoryReader>(ORDER_HISTORY_CONTRACT_ID, {\n multiple: false,\n})\n"],"names":["definePluginDomainEvent","definePluginServiceContract","ORDER_PAID_EVENT","ORDER_FULFILLED_EVENT","ORDER_DELIVERED_EVENT","ORDER_REFUNDED_EVENT","ORDER_CANCELLED_EVENT","RETURN_REQUESTED_EVENT","RETURN_APPROVED_EVENT","RETURN_DECLINED_EVENT","RETURN_RECEIVED_EVENT","RETURN_REFUNDED_EVENT","CHECKOUT_STARTED_EVENT","COMMERCE_EVENT_NAMES","ORDER_HISTORY_CONTRACT_ID","ORDER_HISTORY_CONTRACT","multiple"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,2BAA2B,QAAQ,8CAA6C;AAqKzF,OAAO,MAAMC,mBAAmBF,wBAA2C,cAAa;AACxF,OAAO,MAAMG,wBAAwBH,wBAAoD,mBAAkB;AAC3G,OAAO,MAAMI,wBAAwBJ,wBAA2C,mBAAkB;AAClG,OAAO,MAAMK,uBAAuBL,wBAAmD,kBAAiB;AACxG,OAAO,MAAMM,wBAAwBN,wBAA2C,mBAAkB;AAClG,OAAO,MAAMO,yBAAyBP,wBAA4C,oBAAmB;AACrG,OAAO,MAAMQ,wBAAwBR,wBAA4C,mBAAkB;AACnG,OAAO,MAAMS,wBAAwBT,wBAA4C,mBAAkB;AACnG,OAAO,MAAMU,wBAAwBV,wBAA4C,mBAAkB;AACnG,OAAO,MAAMW,wBAAwBX,wBAA4C,mBAAkB;AAgCnG,OAAO,MAAMY,yBAAyBZ,wBAAqD,oBAAmB;AAkB9G,mDAAmD,GACnD,OAAO,MAAMa,uBAAqD;IAChE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAyCD,OAAO,MAAMC,4BAA4B,wBAAuB;AAEhE,OAAO,MAAMC,yBAAyBd,4BAAgDa,2BAA2B;IAC/GE,UAAU;AACZ,GAAE"}
@@ -105,6 +105,11 @@ export interface OrderLineItem {
105
105
  variantLabel?: string;
106
106
  sku?: string;
107
107
  productType?: ProductType;
108
+ /**
109
+ * A gift card was sold on this line (AGL-3614): the buyer paid for value the
110
+ * store still owes, so a ledger books it as a liability and not as revenue.
111
+ */
112
+ giftCard?: boolean;
108
113
  quantity: number;
109
114
  /** Per-unit price in cents at purchase time, its modifiers included. */
110
115
  unitAmountCents: number;
@@ -442,6 +447,12 @@ export interface HostOrder {
442
447
  useDayKeys?: string[];
443
448
  /** Optional lines the buyer added at checkout (AGL-3635); see {@link OrderExtra}. */
444
449
  extras?: OrderExtra[];
450
+ /**
451
+ * The part of `totals.discountCents` a gift card paid (AGL-3614): an online
452
+ * redemption is taken as a Stripe discount, but the card was money the store
453
+ * already holds, so a ledger reduces its gift card liability by this much.
454
+ */
455
+ giftCardRedeemedCents?: number;
445
456
  /**
446
457
  * Store credit another plugin kept that came off an ONLINE sale (AGL-3640),
447
458
  * as its provider recorded it. A register sale's credit is one of its