@pvh-afl/graphql 1.2.1 → 1.2.2

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": "@pvh-afl/graphql",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "AFL GraphQL - Shared GraphQL modules for multi-brand commerce platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "@nestjs/common": "^10.0.0",
23
23
  "@nestjs/core": "^10.0.0",
24
24
  "@nestjs/graphql": "^12.0.0",
25
- "@pvh-afl/core": "^1.2.1",
25
+ "@pvh-afl/core": "^1.2.2",
26
26
  "graphql": "^16.0.0"
27
27
  },
28
28
  "devDependencies": {
@@ -32,7 +32,7 @@
32
32
  "@nestjs/core": "^10.4.0",
33
33
  "@nestjs/graphql": "^12.2.0",
34
34
  "@nestjs/testing": "^10.4.0",
35
- "@pvh-afl/core": "^1.2.1",
35
+ "@pvh-afl/core": "^1.2.2",
36
36
  "@types/jest": "^29.5.0",
37
37
  "graphql": "^16.9.0",
38
38
  "graphql-type-json": "^0.3.2",
@@ -1,84 +0,0 @@
1
- /**
2
- * Canonical order status
3
- *
4
- * Single source of truth for the customer-facing order status vocabulary.
5
- * The middleware collapses the raw, technical Shopify signals
6
- * (`displayFulfillmentStatus`, `displayFinancialStatus`, `cancelledAt`,
7
- * fulfillment `deliveredAt`, return `status`, …) into ONE small, stable set of
8
- * values that every client and every brand can rely on.
9
- *
10
- * Clients map these values to their own display copy / icons / localization —
11
- * they must never interpret the raw upstream status directly. Adding, removing,
12
- * or renaming a value here is a contract change: keep this list and the
13
- * `@Field` descriptions on `OrderDetails.orderStatus` and
14
- * `CustomerOrderSummary.status` in sync.
15
- */
16
- /** The canonical, customer-facing order statuses. */
17
- export declare const ORDER_STATUSES: readonly ["placed", "confirmed", "processing", "partially_shipped", "shipped", "delivered", "return_requested", "returned", "refunded", "cancelled"];
18
- export type OrderStatus = (typeof ORDER_STATUSES)[number];
19
- /**
20
- * Shopify return statuses that mean "a return is currently in progress".
21
- * (Return `status` values are UPPER_SNAKE on the Admin API.)
22
- */
23
- export declare const OPEN_RETURN_STATUSES: Set<string>;
24
- /**
25
- * Shopify return status that means "the return completed" (items received).
26
- * `CANCELED`/`DECLINED` returns are rejected/withdrawn and must NOT count.
27
- */
28
- export declare const COMPLETED_RETURN_STATUS = "CLOSED";
29
- /** One return on the order: its Shopify status and how many units it covers. */
30
- export interface ReturnSignal {
31
- /** Shopify `Return.status` (e.g. OPEN, REQUESTED, CLOSED, CANCELED, DECLINED). */
32
- status: string;
33
- /** Total units across this return's line items. */
34
- returnedQuantity: number;
35
- }
36
- /**
37
- * Raw Shopify signals needed to derive the canonical status. Every caller
38
- * passes what it has; missing fields simply don't fire their branch, so a
39
- * caller that can't see returns behaves exactly as before for those states.
40
- */
41
- export interface OrderStatusSignals {
42
- /** `order.cancelledAt` — set once the order is cancelled. */
43
- cancelledAt?: string | null;
44
- /** `order.displayFinancialStatus` (e.g. PAID, REFUNDED, PENDING). */
45
- displayFinancialStatus?: string | null;
46
- /** `order.displayFulfillmentStatus` (e.g. FULFILLED, PARTIALLY_FULFILLED, IN_PROGRESS, UNFULFILLED). */
47
- displayFulfillmentStatus?: string | null;
48
- /** `order.confirmed` — Shopify's order-confirmed flag. */
49
- confirmed?: boolean;
50
- /** `deliveredAt` of the primary fulfillment, if the carrier confirmed delivery. */
51
- deliveredAt?: string | null;
52
- /** Whether the order has at least one fulfillment record. */
53
- hasFulfillment?: boolean;
54
- /** Every return on the order, with its status and unit count. */
55
- returns?: ReturnSignal[];
56
- /** Total units ordered across all line items (used to tell full vs partial returns). */
57
- orderedQuantity?: number;
58
- }
59
- /**
60
- * The canonical, customer-facing status of a single parcel (fulfillment).
61
- * Tracks the shipment's journey; aligned with the tracking-timeline stages.
62
- * Clients map these to their own copy — do not surface the raw Shopify
63
- * `displayStatus`/`status` to customers.
64
- */
65
- export declare const FULFILLMENT_STATUSES: readonly ["preparing", "shipped", "in_transit", "out_for_delivery", "ready_for_pickup", "attempted", "delivered", "failed", "cancelled"];
66
- export type FulfillmentStatus = (typeof FULFILLMENT_STATUSES)[number];
67
- /**
68
- * Collapse a parcel's raw Shopify `displayStatus` into a canonical
69
- * {@link FulfillmentStatus}. A confirmed delivery date always wins; an
70
- * unrecognized status on an existing fulfillment falls back to `shipped`
71
- * (the parcel provably exists, so it has at least been handed off).
72
- */
73
- export declare function deriveFulfillmentStatus(displayStatus?: string | null, deliveredAt?: string | null): FulfillmentStatus;
74
- /**
75
- * Collapse the raw Shopify signals into a single canonical {@link OrderStatus}.
76
- *
77
- * Priority runs most-terminal / most-specific first so that, e.g., a cancelled
78
- * order that also has a fulfillment still reads as `cancelled`:
79
- *
80
- * cancelled → returned → return_requested → refunded → delivered →
81
- * shipped → partially_shipped → processing → confirmed → placed
82
- */
83
- export declare function deriveOrderStatus(signals: OrderStatusSignals): OrderStatus;
84
- //# sourceMappingURL=order-status.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-status.d.ts","sourceRoot":"","sources":["../../src/common/order-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qDAAqD;AACrD,eAAO,MAAM,cAAc,sJAWjB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,aAAiC,CAAC;AAEnE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,WAAW,CAAC;AAEhD,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qEAAqE;IACrE,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,wGAAwG;IACxG,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,6DAA6D;IAC7D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iEAAiE;IACjE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,wFAAwF;IACxF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,0IAUvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAuBtE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAC1B,iBAAiB,CAMnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAqE1E"}
@@ -1,150 +0,0 @@
1
- "use strict";
2
- /**
3
- * Canonical order status
4
- *
5
- * Single source of truth for the customer-facing order status vocabulary.
6
- * The middleware collapses the raw, technical Shopify signals
7
- * (`displayFulfillmentStatus`, `displayFinancialStatus`, `cancelledAt`,
8
- * fulfillment `deliveredAt`, return `status`, …) into ONE small, stable set of
9
- * values that every client and every brand can rely on.
10
- *
11
- * Clients map these values to their own display copy / icons / localization —
12
- * they must never interpret the raw upstream status directly. Adding, removing,
13
- * or renaming a value here is a contract change: keep this list and the
14
- * `@Field` descriptions on `OrderDetails.orderStatus` and
15
- * `CustomerOrderSummary.status` in sync.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.FULFILLMENT_STATUSES = exports.COMPLETED_RETURN_STATUS = exports.OPEN_RETURN_STATUSES = exports.ORDER_STATUSES = void 0;
19
- exports.deriveFulfillmentStatus = deriveFulfillmentStatus;
20
- exports.deriveOrderStatus = deriveOrderStatus;
21
- /** The canonical, customer-facing order statuses. */
22
- exports.ORDER_STATUSES = [
23
- 'placed', // order received, not yet confirmed by the brand
24
- 'confirmed', // brand confirmed the order, not yet in fulfillment
25
- 'processing', // fulfillment in progress (Shopify IN_PROGRESS)
26
- 'partially_shipped', // some — but not all — items have shipped
27
- 'shipped', // all items handed to the carrier, not yet delivered
28
- 'delivered', // carrier confirmed delivery
29
- 'return_requested', // an open/requested return is in progress
30
- 'returned', // a full return has completed (all items returned)
31
- 'refunded', // fully refunded
32
- 'cancelled', // order cancelled
33
- ];
34
- /**
35
- * Shopify return statuses that mean "a return is currently in progress".
36
- * (Return `status` values are UPPER_SNAKE on the Admin API.)
37
- */
38
- exports.OPEN_RETURN_STATUSES = new Set(['OPEN', 'REQUESTED']);
39
- /**
40
- * Shopify return status that means "the return completed" (items received).
41
- * `CANCELED`/`DECLINED` returns are rejected/withdrawn and must NOT count.
42
- */
43
- exports.COMPLETED_RETURN_STATUS = 'CLOSED';
44
- /**
45
- * The canonical, customer-facing status of a single parcel (fulfillment).
46
- * Tracks the shipment's journey; aligned with the tracking-timeline stages.
47
- * Clients map these to their own copy — do not surface the raw Shopify
48
- * `displayStatus`/`status` to customers.
49
- */
50
- exports.FULFILLMENT_STATUSES = [
51
- 'preparing', // fulfillment created, not yet handed to the carrier
52
- 'shipped', // handed to the carrier
53
- 'in_transit', // moving through the carrier network
54
- 'out_for_delivery', // with the courier for final delivery
55
- 'ready_for_pickup', // waiting at a pickup point
56
- 'attempted', // delivery attempted but not completed
57
- 'delivered', // delivered / picked up
58
- 'failed', // fulfillment failed
59
- 'cancelled', // fulfillment cancelled / label voided
60
- ];
61
- /** Shopify `FulfillmentDisplayStatus` (+ our synthetic pending) → canonical status. */
62
- const DISPLAY_STATUS_MAP = {
63
- AWAITING_FULFILLMENT: 'preparing', // synthetic "pending" parcel
64
- SUBMITTED: 'shipped',
65
- CONFIRMED: 'shipped',
66
- LABEL_PRINTED: 'shipped',
67
- LABEL_PURCHASED: 'shipped',
68
- MARKED_AS_FULFILLED: 'shipped',
69
- FULFILLED: 'shipped',
70
- IN_TRANSIT: 'in_transit',
71
- OUT_FOR_DELIVERY: 'out_for_delivery',
72
- READY_FOR_PICKUP: 'ready_for_pickup',
73
- ATTEMPTED_DELIVERY: 'attempted',
74
- NOT_DELIVERED: 'attempted',
75
- DELIVERED: 'delivered',
76
- PICKED_UP: 'delivered',
77
- FAILURE: 'failed',
78
- CANCELED: 'cancelled',
79
- LABEL_VOIDED: 'cancelled',
80
- };
81
- /**
82
- * Collapse a parcel's raw Shopify `displayStatus` into a canonical
83
- * {@link FulfillmentStatus}. A confirmed delivery date always wins; an
84
- * unrecognized status on an existing fulfillment falls back to `shipped`
85
- * (the parcel provably exists, so it has at least been handed off).
86
- */
87
- function deriveFulfillmentStatus(displayStatus, deliveredAt) {
88
- if (deliveredAt) {
89
- return 'delivered';
90
- }
91
- const mapped = DISPLAY_STATUS_MAP[(displayStatus ?? '').toUpperCase()];
92
- return mapped ?? 'shipped';
93
- }
94
- /**
95
- * Collapse the raw Shopify signals into a single canonical {@link OrderStatus}.
96
- *
97
- * Priority runs most-terminal / most-specific first so that, e.g., a cancelled
98
- * order that also has a fulfillment still reads as `cancelled`:
99
- *
100
- * cancelled → returned → return_requested → refunded → delivered →
101
- * shipped → partially_shipped → processing → confirmed → placed
102
- */
103
- function deriveOrderStatus(signals) {
104
- const { cancelledAt, displayFinancialStatus, displayFulfillmentStatus, confirmed, deliveredAt, hasFulfillment, returns, orderedQuantity, } = signals;
105
- if (cancelledAt) {
106
- return 'cancelled';
107
- }
108
- const returnList = returns ?? [];
109
- // Full return completed: units returned across CLOSED returns cover the
110
- // whole order. Keyed off the return object's own status (not Shopify's
111
- // financial status, which is unreliable when refunds settle off-Shopify),
112
- // and only when the FULL order was returned — a partial return leaves the
113
- // headline as delivered. Requires a known, positive ordered quantity.
114
- const completedReturnedQty = returnList
115
- .filter((r) => r.status === exports.COMPLETED_RETURN_STATUS)
116
- .reduce((sum, r) => sum + (r.returnedQuantity || 0), 0);
117
- if (orderedQuantity != null &&
118
- orderedQuantity > 0 &&
119
- completedReturnedQty >= orderedQuantity) {
120
- return 'returned';
121
- }
122
- if (returnList.some((r) => exports.OPEN_RETURN_STATUSES.has(r.status))) {
123
- return 'return_requested';
124
- }
125
- if (displayFinancialStatus === 'REFUNDED') {
126
- return 'refunded';
127
- }
128
- if (deliveredAt) {
129
- return 'delivered';
130
- }
131
- if (displayFulfillmentStatus === 'FULFILLED') {
132
- return 'shipped';
133
- }
134
- if (displayFulfillmentStatus === 'PARTIALLY_FULFILLED') {
135
- return 'partially_shipped';
136
- }
137
- if (displayFulfillmentStatus === 'IN_PROGRESS') {
138
- return 'processing';
139
- }
140
- // A fulfillment exists but Shopify hasn't given it a more specific state —
141
- // treat it as shipped (preserves the customer-orders list behaviour).
142
- if (hasFulfillment) {
143
- return 'shipped';
144
- }
145
- if (confirmed) {
146
- return 'confirmed';
147
- }
148
- return 'placed';
149
- }
150
- //# sourceMappingURL=order-status.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-status.js","sourceRoot":"","sources":["../../src/common/order-status.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA6GH,0DASC;AAWD,8CAqEC;AApMD,qDAAqD;AACxC,QAAA,cAAc,GAAG;IAC5B,QAAQ,EAAE,iDAAiD;IAC3D,WAAW,EAAE,oDAAoD;IACjE,YAAY,EAAE,gDAAgD;IAC9D,mBAAmB,EAAE,0CAA0C;IAC/D,SAAS,EAAE,qDAAqD;IAChE,WAAW,EAAE,6BAA6B;IAC1C,kBAAkB,EAAE,0CAA0C;IAC9D,UAAU,EAAE,mDAAmD;IAC/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