@final-commerce/command-frame 0.9.0-staging.1 → 0.9.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.
Files changed (56) hide show
  1. package/dist/CommonTypes.d.ts +1 -25
  2. package/dist/actions/add-product-fee/mock.d.ts +1 -1
  3. package/dist/actions/add-product-fee/mock.js +9 -15
  4. package/dist/actions/add-product-to-cart/mock.d.ts +0 -23
  5. package/dist/actions/add-product-to-cart/mock.js +1 -300
  6. package/dist/actions/add-product-to-cart/types.d.ts +1 -27
  7. package/dist/actions/adjust-inventory/mock.js +20 -0
  8. package/dist/actions/adjust-inventory/types.d.ts +13 -0
  9. package/dist/actions/adjust-inventory/types.js +1 -0
  10. package/dist/actions/get-current-cart/mock.d.ts +1 -1
  11. package/dist/actions/get-current-cart/mock.js +3 -13
  12. package/dist/actions/get-current-cart/types.d.ts +1 -7
  13. package/dist/actions/get-custom-stock-actions/action.d.ts +5 -0
  14. package/dist/actions/get-custom-stock-actions/action.js +7 -0
  15. package/dist/actions/get-custom-stock-actions/mock.d.ts +2 -0
  16. package/dist/actions/get-custom-stock-actions/mock.js +11 -0
  17. package/dist/actions/get-custom-stock-actions/types.d.ts +12 -0
  18. package/dist/actions/get-custom-stock-actions/types.js +2 -0
  19. package/dist/actions/get-product-modifier-selections/mock.js +0 -12
  20. package/dist/actions/get-products/mock.js +3 -7
  21. package/dist/actions/get-products/types.d.ts +1 -1
  22. package/dist/actions/get-refund-plan/mock.d.ts +4 -0
  23. package/dist/actions/get-refund-plan/mock.js +8 -0
  24. package/dist/actions/get-refund-plan/mockRows.d.ts +6 -0
  25. package/dist/actions/get-refund-plan/mockRows.js +114 -0
  26. package/dist/actions/get-refund-plan/types.d.ts +89 -0
  27. package/dist/actions/set-product-modifier-selections/mock.js +0 -12
  28. package/dist/demo/database.d.ts +1 -39
  29. package/dist/demo/database.js +1 -214
  30. package/dist/index.d.ts +4 -6
  31. package/dist/index.js +2 -4
  32. package/dist/projects/render/mocks.js +2 -4
  33. package/dist/projects/render/types.d.ts +2 -3
  34. package/dist/pubsub/topics/products/index.d.ts +2 -2
  35. package/dist/pubsub/topics/products/index.js +18 -33
  36. package/dist/pubsub/topics/products/types.d.ts +10 -16
  37. package/dist/pubsub/topics/products/types.js +4 -7
  38. package/package.json +2 -2
  39. package/dist/actions/get-composite-availability/action.d.ts +0 -6
  40. package/dist/actions/get-composite-availability/action.js +0 -8
  41. package/dist/actions/get-composite-availability/mock.d.ts +0 -2
  42. package/dist/actions/get-composite-availability/mock.js +0 -45
  43. package/dist/actions/get-composite-availability/types.d.ts +0 -29
  44. package/dist/actions/get-composite-availability/types.js +0 -1
  45. package/dist/actions/get-composite-price/action.d.ts +0 -6
  46. package/dist/actions/get-composite-price/action.js +0 -8
  47. package/dist/actions/get-composite-price/mock.d.ts +0 -2
  48. package/dist/actions/get-composite-price/mock.js +0 -37
  49. package/dist/actions/get-composite-price/types.d.ts +0 -31
  50. package/dist/actions/get-composite-price/types.js +0 -1
  51. package/dist/pubsub/topics/products/catalog-visibility-changed/types.d.ts +0 -17
  52. package/dist/pubsub/topics/products/catalog-visibility-changed/types.js +0 -1
  53. package/dist/pubsub/topics/products/composite-changed/types.d.ts +0 -17
  54. package/dist/pubsub/topics/products/composite-changed/types.js +0 -1
  55. package/dist/pubsub/topics/products/inventory-changed/types.d.ts +0 -18
  56. package/dist/pubsub/topics/products/inventory-changed/types.js +0 -1
@@ -1,29 +0,0 @@
1
- import type { CFCompositePick } from '../../CommonTypes';
2
- export interface GetCompositeAvailabilityParams {
3
- /** The composite's variant — the one `addProductToCart` takes. Its `composite.needsDate` is true. */
4
- variantId: string;
5
- /** The picks so far; their bookable items decide the seats asked. Absent = each part's `defaultPick`. */
6
- composite?: CFCompositePick[];
7
- /** First shop day, `YYYY-MM-DD` in the shop's zone. Defaults to today. */
8
- fromDay?: string;
9
- /** How many shop days from `fromDay`. Defaults to 1. */
10
- days?: number;
11
- }
12
- /** A start every bookable of the composite can be held at, with the seats its picks need. */
13
- export interface CFCompositeSlot {
14
- /** ISO 8601 — send it back as `addProductToCart({ compositeSlot: { startAt } })`. */
15
- startAt: string;
16
- /** The shop day it falls on, `YYYY-MM-DD` — what a day picker groups by. */
17
- dayKey: string;
18
- }
19
- export interface GetCompositeAvailabilityResponse {
20
- /** False when the host refused: not a composite, nothing bookable picked, no booking rules on this till yet. */
21
- success: boolean;
22
- reason?: string;
23
- /** In time order. Empty = nothing free for all of them in those days. */
24
- slots: CFCompositeSlot[];
25
- /** The clock `startAt` and `dayKey` read on; null when no bookable serves here. */
26
- timeZone: string | null;
27
- timestamp: string;
28
- }
29
- export type GetCompositeAvailability = (params: GetCompositeAvailabilityParams) => Promise<GetCompositeAvailabilityResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Get composite price action (read-only)
3
- * Calls the getCompositePrice action on the parent window
4
- */
5
- import type { GetCompositePrice } from './types';
6
- export declare const getCompositePrice: GetCompositePrice;
@@ -1,8 +0,0 @@
1
- /**
2
- * Get composite price action (read-only)
3
- * Calls the getCompositePrice action on the parent window
4
- */
5
- import { commandFrameClient } from '../../client';
6
- export const getCompositePrice = async (params) => {
7
- return await commandFrameClient.call('getCompositePrice', params);
8
- };
@@ -1,2 +0,0 @@
1
- import { GetCompositePrice } from './types';
2
- export declare const mockGetCompositePrice: GetCompositePrice;
@@ -1,37 +0,0 @@
1
- import { MOCK_CART, MOCK_PRODUCTS, buildModifierRows, mockCompositeAtOutlet, mockCompositeStockRefusal, mockHiddenProductIds, } from '../../demo/database';
2
- import { compositePicksRefusal, mockCompositeLine, mockNeedsDateRefusal, mockPicksStillNeeded, } from '../add-product-to-cart/mock';
3
- // The same line the mock addProductToCart builds, priced for ONE composite and added to nothing.
4
- export const mockGetCompositePrice = async (params) => {
5
- console.log('[Mock] getCompositePrice called', params);
6
- const timestamp = new Date().toISOString();
7
- const product = MOCK_PRODUCTS.find((candidate) => candidate.variants.some((v) => v._id === params?.variantId));
8
- if (!product)
9
- throw new Error(`Variant with ID ${params?.variantId} not found`);
10
- if (!product.composite) {
11
- return {
12
- success: false,
13
- reason: `${product.name} is not a composite: it takes no composite picks`,
14
- missing: [],
15
- timestamp,
16
- };
17
- }
18
- const picks = params.composite ?? [];
19
- // What this outlet sells (the host's catalog-visibility rules).
20
- const composite = mockCompositeAtOutlet(product.composite, undefined, params.compositeSlot);
21
- const missing = mockPicksStillNeeded(composite, picks);
22
- if (mockHiddenProductIds().has(product._id)) {
23
- return { success: false, reason: `${product.name} is not sold at this outlet`, missing, timestamp };
24
- }
25
- const line = mockNeedsDateRefusal(product.name, composite, params.compositeSlot) ??
26
- compositePicksRefusal(composite, picks) ??
27
- mockCompositeLine(composite, picks, !product.taxTable);
28
- if (typeof line === 'string')
29
- return { success: false, reason: line, missing, timestamp };
30
- const shortOfStock = mockCompositeStockRefusal([
31
- ...MOCK_CART.products,
32
- { variantId: params.variantId, quantity: 1, components: line.components },
33
- ]);
34
- if (shortOfStock)
35
- return { success: false, reason: shortOfStock, missing, timestamp };
36
- return { success: true, total: line.price + buildModifierRows(line.modifiers, 1).modifiersTotal, missing, timestamp };
37
- };
@@ -1,31 +0,0 @@
1
- import type { CFCompositePick } from '../../CommonTypes';
2
- export interface GetCompositePriceParams {
3
- /** The composite's variant — the one `addProductToCart` takes. */
4
- variantId: string;
5
- /** The picks so far, exactly as `addProductToCart({ composite })` would send them. */
6
- composite: CFCompositePick[];
7
- /** B41: the date and time a bookable pick is for, as `addProductToCart` takes it; without one a bookable pick is refused. */
8
- compositeSlot?: {
9
- startAt: string;
10
- };
11
- }
12
- export interface GetCompositePriceResponse {
13
- success: boolean;
14
- /** Why these picks are refused — the same refusal and text `addProductToCart` would give. */
15
- reason?: string;
16
- /**
17
- * What ONE composite with these picks adds to the cart, minor units: the line price the host would build plus the
18
- * picked items' modifiers. Before discounts, fees and tax. Show it; do not recompute it. Absent when refused.
19
- */
20
- total?: number;
21
- /**
22
- * The parts that still need picks before the composite can be added, and how many ("Pick 2 more"); empty when every
23
- * required part is filled. Decided by the host — keep Add to cart disabled while this is not empty.
24
- */
25
- missing: {
26
- partId: string;
27
- needed: number;
28
- }[];
29
- timestamp: string;
30
- }
31
- export type GetCompositePrice = (params: GetCompositePriceParams) => Promise<GetCompositePriceResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import type { TopicEvent } from '../../../types';
2
- /**
3
- * Payload for catalog-visibility-changed: a product was hidden or shown at an outlet. `getProducts` leaves hidden
4
- * products out and a composite offers only items sold at the till's outlet — debounce, then re-ask `getProducts`.
5
- */
6
- export interface CatalogVisibilityChangedPayload {
7
- visibility: {
8
- _id: string;
9
- productId: string;
10
- outletId: string;
11
- isDeleted?: boolean;
12
- };
13
- }
14
- /**
15
- * Typed event for catalog-visibility-changed
16
- */
17
- export type CatalogVisibilityChangedEvent = TopicEvent<CatalogVisibilityChangedPayload>;
@@ -1,17 +0,0 @@
1
- import type { TopicEvent } from '../../../types';
2
- /**
3
- * Payload for composite-changed (FT-83): a part or item of a composite arrived. A save replaces all of a composite's
4
- * parts and items at once (old rows come as `isDeleted: true`, new ones with new ids), so one save fires this many
5
- * times — debounce, then re-ask `getProducts`; never patch `product.composite` from the row.
6
- */
7
- export interface CompositeChangedPayload {
8
- compositeRow: {
9
- _id: string;
10
- compositeProductId: string;
11
- isDeleted?: boolean;
12
- };
13
- }
14
- /**
15
- * Typed event for composite-changed
16
- */
17
- export type CompositeChangedEvent = TopicEvent<CompositeChangedPayload>;
@@ -1,18 +0,0 @@
1
- import type { TopicEvent } from '../../../types';
2
- /**
3
- * Payload for inventory-changed (B35): a variant's stock at an outlet moved. A composite may turn Sold out or
4
- * Unavailable by its components' shelves — debounce, then re-ask `getProducts`.
5
- */
6
- export interface InventoryChangedPayload {
7
- inventory: {
8
- _id: string;
9
- variantId: string;
10
- outletId: string;
11
- quantity?: number | null;
12
- manageStock?: boolean;
13
- };
14
- }
15
- /**
16
- * Typed event for inventory-changed
17
- */
18
- export type InventoryChangedEvent = TopicEvent<InventoryChangedPayload>;