@pvh-afl/graphql 1.1.32 → 1.1.34
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/dist/customer-orders/customer-orders.module.d.ts +9 -0
- package/dist/customer-orders/customer-orders.module.d.ts.map +1 -0
- package/dist/customer-orders/customer-orders.module.js +24 -0
- package/dist/customer-orders/customer-orders.module.js.map +1 -0
- package/dist/customer-orders/customer-orders.resolver.d.ts +15 -0
- package/dist/customer-orders/customer-orders.resolver.d.ts.map +1 -0
- package/dist/customer-orders/customer-orders.resolver.js +36 -0
- package/dist/customer-orders/customer-orders.resolver.js.map +1 -0
- package/dist/customer-orders/customer-orders.service.d.ts +51 -0
- package/dist/customer-orders/customer-orders.service.d.ts.map +1 -0
- package/dist/customer-orders/customer-orders.service.js +286 -0
- package/dist/customer-orders/customer-orders.service.js.map +1 -0
- package/dist/customer-orders/customer-orders.types.d.ts +64 -0
- package/dist/customer-orders/customer-orders.types.d.ts.map +1 -0
- package/dist/customer-orders/customer-orders.types.js +209 -0
- package/dist/customer-orders/customer-orders.types.js.map +1 -0
- package/dist/customer-orders/index.d.ts +5 -0
- package/dist/customer-orders/index.d.ts.map +1 -0
- package/dist/customer-orders/index.js +8 -0
- package/dist/customer-orders/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/order-tracking/order-tracking.service.d.ts +4 -0
- package/dist/order-tracking/order-tracking.service.d.ts.map +1 -1
- package/dist/order-tracking/order-tracking.service.js +73 -0
- package/dist/order-tracking/order-tracking.service.js.map +1 -1
- package/dist/order-tracking/order-tracking.types.d.ts +26 -0
- package/dist/order-tracking/order-tracking.types.d.ts.map +1 -1
- package/dist/order-tracking/order-tracking.types.js +100 -2
- package/dist/order-tracking/order-tracking.types.js.map +1 -1
- package/dist/product/product.service.d.ts +15 -0
- package/dist/product/product.service.d.ts.map +1 -1
- package/dist/product/product.service.js +52 -0
- package/dist/product/product.service.js.map +1 -1
- package/dist/product/product.types.d.ts +14 -0
- package/dist/product/product.types.d.ts.map +1 -1
- package/dist/product/product.types.js +76 -1
- package/dist/product/product.types.js.map +1 -1
- package/dist/product-content/product-content.service.d.ts.map +1 -1
- package/dist/product-content/product-content.service.js +1 -0
- package/dist/product-content/product-content.service.js.map +1 -1
- package/dist/product-content/types/response.types.d.ts +2 -1
- package/dist/product-content/types/response.types.d.ts.map +1 -1
- package/dist/product-content/types/response.types.js +8 -0
- package/dist/product-content/types/response.types.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.module.d.ts","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.module.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,qBAIa,oBAAoB;CAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomerOrdersModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const core_1 = require("@pvh-afl/core");
|
|
7
|
+
const customer_orders_resolver_1 = require("./customer-orders.resolver");
|
|
8
|
+
const customer_orders_service_1 = require("./customer-orders.service");
|
|
9
|
+
/**
|
|
10
|
+
* Customer Orders Module
|
|
11
|
+
*
|
|
12
|
+
* Exposes `listCustomerOrders` — a paginated "My Orders" list sourced from the
|
|
13
|
+
* Shopify Admin API.
|
|
14
|
+
*/
|
|
15
|
+
let CustomerOrdersModule = class CustomerOrdersModule {
|
|
16
|
+
};
|
|
17
|
+
exports.CustomerOrdersModule = CustomerOrdersModule;
|
|
18
|
+
exports.CustomerOrdersModule = CustomerOrdersModule = tslib_1.__decorate([
|
|
19
|
+
(0, common_1.Module)({
|
|
20
|
+
imports: [core_1.IntegrationsModule],
|
|
21
|
+
providers: [customer_orders_resolver_1.CustomerOrdersResolver, customer_orders_service_1.CustomerOrdersService],
|
|
22
|
+
})
|
|
23
|
+
], CustomerOrdersModule);
|
|
24
|
+
//# sourceMappingURL=customer-orders.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.module.js","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,wCAAmD;AACnD,yEAAoE;AACpE,uEAAkE;AAElE;;;;;GAKG;AAKI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oDAAoB;+BAApB,oBAAoB;IAJhC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE,CAAC,iDAAsB,EAAE,+CAAqB,CAAC;KAC3D,CAAC;GACW,oBAAoB,CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CustomerOrdersService } from './customer-orders.service';
|
|
2
|
+
import { ListCustomerOrdersInput, CustomerOrdersResult } from './customer-orders.types';
|
|
3
|
+
interface GqlContext {
|
|
4
|
+
brand?: string;
|
|
5
|
+
req?: {
|
|
6
|
+
brand?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare class CustomerOrdersResolver {
|
|
10
|
+
private readonly customerOrdersService;
|
|
11
|
+
constructor(customerOrdersService: CustomerOrdersService);
|
|
12
|
+
listCustomerOrders(input: ListCustomerOrdersInput, ctx: GqlContext): Promise<CustomerOrdersResult>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=customer-orders.resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.resolver.d.ts","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.resolver.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAExF,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B;AAED,qBACa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;gBAArB,qBAAqB,EAAE,qBAAqB;IAMnE,kBAAkB,CACP,KAAK,EAAE,uBAAuB,EAClC,GAAG,EAAE,UAAU,GACzB,OAAO,CAAC,oBAAoB,CAAC;CAIjC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomerOrdersResolver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const core_1 = require("@pvh-afl/core");
|
|
8
|
+
const customer_orders_service_1 = require("./customer-orders.service");
|
|
9
|
+
const customer_orders_types_1 = require("./customer-orders.types");
|
|
10
|
+
let CustomerOrdersResolver = class CustomerOrdersResolver {
|
|
11
|
+
customerOrdersService;
|
|
12
|
+
constructor(customerOrdersService) {
|
|
13
|
+
this.customerOrdersService = customerOrdersService;
|
|
14
|
+
}
|
|
15
|
+
async listCustomerOrders(input, ctx) {
|
|
16
|
+
const brand = ctx.brand ?? ctx.req?.brand ?? '';
|
|
17
|
+
return this.customerOrdersService.listCustomerOrders(brand, input);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.CustomerOrdersResolver = CustomerOrdersResolver;
|
|
21
|
+
tslib_1.__decorate([
|
|
22
|
+
(0, graphql_1.Query)(() => customer_orders_types_1.CustomerOrdersResult, {
|
|
23
|
+
description: "List a customer's orders (newest first, cursor-paginated) for the My Orders screen",
|
|
24
|
+
}),
|
|
25
|
+
(0, common_1.UseGuards)(core_1.TenantGuard),
|
|
26
|
+
tslib_1.__param(0, (0, graphql_1.Args)('input')),
|
|
27
|
+
tslib_1.__param(1, (0, graphql_1.Context)()),
|
|
28
|
+
tslib_1.__metadata("design:type", Function),
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [customer_orders_types_1.ListCustomerOrdersInput, Object]),
|
|
30
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
31
|
+
], CustomerOrdersResolver.prototype, "listCustomerOrders", null);
|
|
32
|
+
exports.CustomerOrdersResolver = CustomerOrdersResolver = tslib_1.__decorate([
|
|
33
|
+
(0, graphql_1.Resolver)(),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [customer_orders_service_1.CustomerOrdersService])
|
|
35
|
+
], CustomerOrdersResolver);
|
|
36
|
+
//# sourceMappingURL=customer-orders.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.resolver.js","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.resolver.ts"],"names":[],"mappings":";;;;AAAA,6CAAiE;AACjE,2CAA2C;AAC3C,wCAA4C;AAC5C,uEAAkE;AAClE,mEAAwF;AAQjF,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACJ;IAA7B,YAA6B,qBAA4C;QAA5C,0BAAqB,GAArB,qBAAqB,CAAuB;IAAG,CAAC;IAMvE,AAAN,KAAK,CAAC,kBAAkB,CACP,KAA8B,EAClC,GAAe;QAE1B,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;CACF,CAAA;AAdY,wDAAsB;AAO3B;IAJL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,4CAAoB,EAAE;QACjC,WAAW,EAAE,oFAAoF;KAClG,CAAC;IACD,IAAA,kBAAS,EAAC,kBAAW,CAAC;IAEpB,mBAAA,IAAA,cAAI,EAAC,OAAO,CAAC,CAAA;IACb,mBAAA,IAAA,iBAAO,GAAE,CAAA;;6CADY,+CAAuB;;gEAK9C;iCAbU,sBAAsB;IADlC,IAAA,kBAAQ,GAAE;6CAE2C,+CAAqB;GAD9D,sBAAsB,CAclC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ConfigService } from '@pvh-afl/core';
|
|
2
|
+
import { ListCustomerOrdersInput, CustomerOrdersResult } from './customer-orders.types';
|
|
3
|
+
/**
|
|
4
|
+
* Customer Orders Service
|
|
5
|
+
*
|
|
6
|
+
* Lists a customer's orders (newest first, cursor-paginated) from the Shopify
|
|
7
|
+
* Admin API for the "My Orders" screen. A customer is identified by either a
|
|
8
|
+
* Shopify customer id or an email.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CustomerOrdersService {
|
|
11
|
+
private readonly configService;
|
|
12
|
+
constructor(configService: ConfigService);
|
|
13
|
+
listCustomerOrders(brand: string, input: ListCustomerOrdersInput): Promise<CustomerOrdersResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Query a customer's orders by customer id (customer(id){ orders }).
|
|
16
|
+
*/
|
|
17
|
+
private buildCustomerIdQuery;
|
|
18
|
+
/**
|
|
19
|
+
* Query orders by customer email (orders(query: "email:...")).
|
|
20
|
+
*/
|
|
21
|
+
private buildEmailQuery;
|
|
22
|
+
/** Shared order-connection projection reused by both query paths. */
|
|
23
|
+
private readonly ORDER_CONNECTION_SELECTION;
|
|
24
|
+
/**
|
|
25
|
+
* Map a Shopify order node to a customer order card summary.
|
|
26
|
+
*/
|
|
27
|
+
private mapOrder;
|
|
28
|
+
/**
|
|
29
|
+
* Derive the normalized card status and the date it happened.
|
|
30
|
+
*
|
|
31
|
+
* Priority: cancelled → return in progress → fully refunded → delivered →
|
|
32
|
+
* shipped → placed. (Exchange states are sourced elsewhere — not here.)
|
|
33
|
+
*/
|
|
34
|
+
private deriveStatus;
|
|
35
|
+
/**
|
|
36
|
+
* Sum all refunds on the order into a single refund summary.
|
|
37
|
+
*/
|
|
38
|
+
private mapRefund;
|
|
39
|
+
private latestRefundDate;
|
|
40
|
+
/**
|
|
41
|
+
* An order is cancellable only while unfulfilled and within the window.
|
|
42
|
+
*/
|
|
43
|
+
private computeCanCancel;
|
|
44
|
+
private mapMoney;
|
|
45
|
+
private emptyResult;
|
|
46
|
+
/**
|
|
47
|
+
* Get Shopify Admin API configuration for the brand.
|
|
48
|
+
*/
|
|
49
|
+
private getShopifyAdminConfig;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=customer-orders.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.service.d.ts","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAU,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EAIrB,MAAM,yBAAyB,CAAC;AAuEjC;;;;;;GAMG;AACH,qBACa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEnD,kBAAkB,CACtB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,oBAAoB,CAAC;IAuEhC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkB5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAcvB,qEAAqE;IACrE,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CA0CzC;IAEF;;OAEG;IACH,OAAO,CAAC,QAAQ;IA8BhB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAoCpB;;OAEG;IACH,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,qBAAqB;CAc9B"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomerOrdersService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const core_1 = require("@pvh-afl/core");
|
|
7
|
+
// Cancellation window in minutes (mirrors OrderTrackingService)
|
|
8
|
+
const CANCELLATION_WINDOW_MINUTES = 30;
|
|
9
|
+
// Hard cap on page size to protect Shopify query cost
|
|
10
|
+
const MAX_PAGE_SIZE = 50;
|
|
11
|
+
// Return statuses that mean "a return is in progress"
|
|
12
|
+
const OPEN_RETURN_STATUSES = new Set(['OPEN', 'REQUESTED']);
|
|
13
|
+
/**
|
|
14
|
+
* Customer Orders Service
|
|
15
|
+
*
|
|
16
|
+
* Lists a customer's orders (newest first, cursor-paginated) from the Shopify
|
|
17
|
+
* Admin API for the "My Orders" screen. A customer is identified by either a
|
|
18
|
+
* Shopify customer id or an email.
|
|
19
|
+
*/
|
|
20
|
+
let CustomerOrdersService = class CustomerOrdersService {
|
|
21
|
+
configService;
|
|
22
|
+
constructor(configService) {
|
|
23
|
+
this.configService = configService;
|
|
24
|
+
}
|
|
25
|
+
async listCustomerOrders(brand, input) {
|
|
26
|
+
const customerId = input.customerId?.trim();
|
|
27
|
+
const email = input.email?.trim();
|
|
28
|
+
if (!customerId && !email) {
|
|
29
|
+
throw new common_1.BadRequestException('Either customerId or email is required');
|
|
30
|
+
}
|
|
31
|
+
const adminConfig = this.getShopifyAdminConfig(brand);
|
|
32
|
+
if (!adminConfig) {
|
|
33
|
+
core_1.logger.warn('Shopify Admin API not configured', { brand });
|
|
34
|
+
return this.emptyResult();
|
|
35
|
+
}
|
|
36
|
+
const first = Math.min(Math.max(input.first ?? 20, 1), MAX_PAGE_SIZE);
|
|
37
|
+
const after = input.after || null;
|
|
38
|
+
const { query, variables } = customerId
|
|
39
|
+
? this.buildCustomerIdQuery(customerId, first, after)
|
|
40
|
+
: this.buildEmailQuery(email, first, after);
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(`${adminConfig.baseUrl}/graphql.json`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
'X-Shopify-Access-Token': adminConfig.apiKey,
|
|
47
|
+
},
|
|
48
|
+
body: JSON.stringify({ query, variables }),
|
|
49
|
+
});
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
core_1.logger.error('Shopify Admin API request failed', {
|
|
52
|
+
brand,
|
|
53
|
+
status: response.status,
|
|
54
|
+
});
|
|
55
|
+
return this.emptyResult();
|
|
56
|
+
}
|
|
57
|
+
const result = (await response.json());
|
|
58
|
+
if (result.errors?.length) {
|
|
59
|
+
core_1.logger.error('Shopify GraphQL errors', { brand, errors: result.errors });
|
|
60
|
+
return this.emptyResult();
|
|
61
|
+
}
|
|
62
|
+
const connection = customerId
|
|
63
|
+
? result.data?.customer?.orders
|
|
64
|
+
: result.data?.orders;
|
|
65
|
+
if (!connection) {
|
|
66
|
+
// Unknown customer id / no customer record → empty list, not an error
|
|
67
|
+
return this.emptyResult();
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
orders: connection.edges.map(({ node }) => this.mapOrder(node)),
|
|
71
|
+
pageInfo: {
|
|
72
|
+
hasNextPage: connection.pageInfo.hasNextPage,
|
|
73
|
+
endCursor: connection.pageInfo.endCursor,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
core_1.logger.error('Shopify customer orders fetch failed', {
|
|
79
|
+
brand,
|
|
80
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
81
|
+
});
|
|
82
|
+
return this.emptyResult();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Query a customer's orders by customer id (customer(id){ orders }).
|
|
87
|
+
*/
|
|
88
|
+
buildCustomerIdQuery(customerId, first, after) {
|
|
89
|
+
const gid = customerId.startsWith('gid://')
|
|
90
|
+
? customerId
|
|
91
|
+
: `gid://shopify/Customer/${customerId.replace(/\D/g, '')}`;
|
|
92
|
+
const query = `
|
|
93
|
+
query ListCustomerOrders($customerId: ID!, $first: Int!, $after: String) {
|
|
94
|
+
customer(id: $customerId) {
|
|
95
|
+
orders(first: $first, after: $after, sortKey: CREATED_AT, reverse: true) {
|
|
96
|
+
${this.ORDER_CONNECTION_SELECTION}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
return { query, variables: { customerId: gid, first, after } };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Query orders by customer email (orders(query: "email:...")).
|
|
105
|
+
*/
|
|
106
|
+
buildEmailQuery(email, first, after) {
|
|
107
|
+
const query = `
|
|
108
|
+
query ListCustomerOrders($query: String!, $first: Int!, $after: String) {
|
|
109
|
+
orders(first: $first, after: $after, query: $query, sortKey: CREATED_AT, reverse: true) {
|
|
110
|
+
${this.ORDER_CONNECTION_SELECTION}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
// Escape quotes in the email to keep the search query well-formed
|
|
115
|
+
const searchQuery = `email:${email.replace(/"/g, '\\"')}`;
|
|
116
|
+
return { query, variables: { query: searchQuery, first, after } };
|
|
117
|
+
}
|
|
118
|
+
/** Shared order-connection projection reused by both query paths. */
|
|
119
|
+
ORDER_CONNECTION_SELECTION = `
|
|
120
|
+
edges {
|
|
121
|
+
cursor
|
|
122
|
+
node {
|
|
123
|
+
id
|
|
124
|
+
name
|
|
125
|
+
createdAt
|
|
126
|
+
updatedAt
|
|
127
|
+
cancelledAt
|
|
128
|
+
displayFinancialStatus
|
|
129
|
+
displayFulfillmentStatus
|
|
130
|
+
currentTotalPriceSet { shopMoney { amount currencyCode } }
|
|
131
|
+
fulfillments(first: 1) {
|
|
132
|
+
status
|
|
133
|
+
createdAt
|
|
134
|
+
deliveredAt
|
|
135
|
+
inTransitAt
|
|
136
|
+
trackingInfo { url }
|
|
137
|
+
}
|
|
138
|
+
lineItems(first: 50) {
|
|
139
|
+
edges {
|
|
140
|
+
node {
|
|
141
|
+
id
|
|
142
|
+
name
|
|
143
|
+
quantity
|
|
144
|
+
variantTitle
|
|
145
|
+
image { url }
|
|
146
|
+
variant { selectedOptions { name value } }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
returns(first: 5) {
|
|
151
|
+
edges { node { id status } }
|
|
152
|
+
}
|
|
153
|
+
refunds {
|
|
154
|
+
id
|
|
155
|
+
createdAt
|
|
156
|
+
totalRefundedSet { shopMoney { amount currencyCode } }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
pageInfo { hasNextPage endCursor }
|
|
161
|
+
`;
|
|
162
|
+
/**
|
|
163
|
+
* Map a Shopify order node to a customer order card summary.
|
|
164
|
+
*/
|
|
165
|
+
mapOrder(node) {
|
|
166
|
+
const fulfillment = node.fulfillments?.[0];
|
|
167
|
+
const { status, statusDate } = this.deriveStatus(node);
|
|
168
|
+
const lineItems = node.lineItems.edges.map(({ node: li }) => ({
|
|
169
|
+
id: li.id,
|
|
170
|
+
title: li.name,
|
|
171
|
+
imageUrl: li.image?.url,
|
|
172
|
+
color: li.variantTitle,
|
|
173
|
+
size: li.variant?.selectedOptions?.find(o => o.name.toLowerCase() === 'size')?.value,
|
|
174
|
+
quantity: li.quantity,
|
|
175
|
+
}));
|
|
176
|
+
const itemCount = lineItems.reduce((sum, li) => sum + li.quantity, 0);
|
|
177
|
+
return {
|
|
178
|
+
orderId: node.id,
|
|
179
|
+
orderName: node.name,
|
|
180
|
+
status,
|
|
181
|
+
statusDate,
|
|
182
|
+
createdAt: node.createdAt,
|
|
183
|
+
itemCount,
|
|
184
|
+
totalAmount: node.currentTotalPriceSet ? this.mapMoney(node.currentTotalPriceSet.shopMoney) : undefined,
|
|
185
|
+
lineItems,
|
|
186
|
+
refund: this.mapRefund(node),
|
|
187
|
+
canCancel: this.computeCanCancel(node),
|
|
188
|
+
trackingUrl: fulfillment?.trackingInfo?.[0]?.url,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Derive the normalized card status and the date it happened.
|
|
193
|
+
*
|
|
194
|
+
* Priority: cancelled → return in progress → fully refunded → delivered →
|
|
195
|
+
* shipped → placed. (Exchange states are sourced elsewhere — not here.)
|
|
196
|
+
*/
|
|
197
|
+
deriveStatus(node) {
|
|
198
|
+
if (node.cancelledAt) {
|
|
199
|
+
return { status: 'cancelled', statusDate: node.cancelledAt };
|
|
200
|
+
}
|
|
201
|
+
const hasOpenReturn = node.returns?.edges?.some(({ node: r }) => OPEN_RETURN_STATUSES.has(r.status));
|
|
202
|
+
if (hasOpenReturn) {
|
|
203
|
+
return { status: 'return_requested', statusDate: node.updatedAt };
|
|
204
|
+
}
|
|
205
|
+
if (node.displayFinancialStatus === 'REFUNDED') {
|
|
206
|
+
return { status: 'refunded', statusDate: this.latestRefundDate(node) ?? node.updatedAt };
|
|
207
|
+
}
|
|
208
|
+
const fulfillment = node.fulfillments?.[0];
|
|
209
|
+
if (fulfillment?.deliveredAt) {
|
|
210
|
+
return { status: 'delivered', statusDate: fulfillment.deliveredAt };
|
|
211
|
+
}
|
|
212
|
+
if (fulfillment ||
|
|
213
|
+
node.displayFulfillmentStatus === 'FULFILLED' ||
|
|
214
|
+
node.displayFulfillmentStatus === 'PARTIALLY_FULFILLED' ||
|
|
215
|
+
node.displayFulfillmentStatus === 'IN_PROGRESS') {
|
|
216
|
+
return {
|
|
217
|
+
status: 'shipped',
|
|
218
|
+
statusDate: fulfillment?.inTransitAt || fulfillment?.createdAt,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return { status: 'placed', statusDate: node.createdAt };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Sum all refunds on the order into a single refund summary.
|
|
225
|
+
*/
|
|
226
|
+
mapRefund(node) {
|
|
227
|
+
if (!node.refunds || node.refunds.length === 0) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
const total = node.refunds.reduce((sum, r) => sum + parseFloat(r.totalRefundedSet.shopMoney.amount || '0'), 0);
|
|
231
|
+
const currencyCode = node.refunds[0].totalRefundedSet.shopMoney.currencyCode;
|
|
232
|
+
return {
|
|
233
|
+
totalRefunded: { amount: (Math.round(total * 100) / 100).toString(), currencyCode },
|
|
234
|
+
refundedAt: this.latestRefundDate(node),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
latestRefundDate(node) {
|
|
238
|
+
if (!node.refunds || node.refunds.length === 0) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
return node.refunds
|
|
242
|
+
.map(r => r.createdAt)
|
|
243
|
+
.sort((a, b) => new Date(b).getTime() - new Date(a).getTime())[0];
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* An order is cancellable only while unfulfilled and within the window.
|
|
247
|
+
*/
|
|
248
|
+
computeCanCancel(node) {
|
|
249
|
+
if (node.cancelledAt) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (node.displayFulfillmentStatus !== 'UNFULFILLED') {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
const orderAgeMinutes = (Date.now() - new Date(node.createdAt).getTime()) / (1000 * 60);
|
|
256
|
+
return orderAgeMinutes <= CANCELLATION_WINDOW_MINUTES;
|
|
257
|
+
}
|
|
258
|
+
mapMoney(money) {
|
|
259
|
+
return { amount: money.amount, currencyCode: money.currencyCode };
|
|
260
|
+
}
|
|
261
|
+
emptyResult() {
|
|
262
|
+
return { orders: [], pageInfo: { hasNextPage: false, endCursor: undefined } };
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get Shopify Admin API configuration for the brand.
|
|
266
|
+
*/
|
|
267
|
+
getShopifyAdminConfig(brand) {
|
|
268
|
+
try {
|
|
269
|
+
const brandConfig = this.configService.getBrand(brand);
|
|
270
|
+
const adminConfig = brandConfig?.integrations?.commerceAdmin;
|
|
271
|
+
if (!adminConfig?.baseUrl || !adminConfig?.apiKey) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
return { baseUrl: adminConfig.baseUrl, apiKey: adminConfig.apiKey };
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
exports.CustomerOrdersService = CustomerOrdersService;
|
|
282
|
+
exports.CustomerOrdersService = CustomerOrdersService = tslib_1.__decorate([
|
|
283
|
+
(0, common_1.Injectable)(),
|
|
284
|
+
tslib_1.__metadata("design:paramtypes", [core_1.ConfigService])
|
|
285
|
+
], CustomerOrdersService);
|
|
286
|
+
//# sourceMappingURL=customer-orders.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.service.js","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAiE;AACjE,wCAAsD;AAuEtD,gEAAgE;AAChE,MAAM,2BAA2B,GAAG,EAAE,CAAC;AACvC,sDAAsD;AACtD,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,sDAAsD;AACtD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAE5D;;;;;;GAMG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACH;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,KAAK,CAAC,kBAAkB,CACtB,KAAa,EACb,KAA8B;QAE9B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;Q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order Listing ("My Orders")
|
|
4
|
+
*
|
|
5
|
+
* A lightweight, paginated list of a customer's orders sourced entirely from
|
|
6
|
+
* the Shopify Admin API. Each entry carries just enough to render an order
|
|
7
|
+
* card (status, date, product thumbnails, refund, quick actions); full detail
|
|
8
|
+
* is fetched on demand via `getOrderTracking(orderId)`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ListCustomerOrdersInput {
|
|
11
|
+
customerId?: string;
|
|
12
|
+
email?: string;
|
|
13
|
+
first?: number;
|
|
14
|
+
after?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A single product line shown on an order card.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CustomerOrderLineItem {
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
imageUrl?: string;
|
|
23
|
+
color?: string;
|
|
24
|
+
size?: string;
|
|
25
|
+
quantity: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Refund summary shown on cancelled / refunded order cards.
|
|
29
|
+
*/
|
|
30
|
+
export declare class CustomerOrderRefund {
|
|
31
|
+
totalRefunded: OrderMoney;
|
|
32
|
+
refundedAt?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One order card in the "My Orders" list.
|
|
36
|
+
*/
|
|
37
|
+
export declare class CustomerOrderSummary {
|
|
38
|
+
orderId: string;
|
|
39
|
+
orderName: string;
|
|
40
|
+
status: string;
|
|
41
|
+
statusDate?: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
itemCount: number;
|
|
44
|
+
totalAmount?: OrderMoney;
|
|
45
|
+
lineItems: CustomerOrderLineItem[];
|
|
46
|
+
refund?: CustomerOrderRefund;
|
|
47
|
+
canCancel: boolean;
|
|
48
|
+
trackingUrl?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Cursor pagination info for the order list.
|
|
52
|
+
*/
|
|
53
|
+
export declare class CustomerOrdersPageInfo {
|
|
54
|
+
hasNextPage: boolean;
|
|
55
|
+
endCursor?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Paginated result for listCustomerOrders.
|
|
59
|
+
*/
|
|
60
|
+
export declare class CustomerOrdersResult {
|
|
61
|
+
orders: CustomerOrderSummary[];
|
|
62
|
+
pageInfo: CustomerOrdersPageInfo;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=customer-orders.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-orders.types.d.ts","sourceRoot":"","sources":["../../src/customer-orders/customer-orders.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEpE;;;;;;;GAOG;AAMH,qBACa,uBAAuB;IAElC,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD;;GAEG;AACH,qBACa,qBAAqB;IAEhC,EAAE,EAAG,MAAM,CAAC;IAGZ,KAAK,EAAG,MAAM,CAAC;IAGf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,QAAQ,EAAG,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBACa,mBAAmB;IAE9B,aAAa,EAAG,UAAU,CAAC;IAG3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBACa,oBAAoB;IAE/B,OAAO,EAAG,MAAM,CAAC;IAGjB,SAAS,EAAG,MAAM,CAAC;IAMnB,MAAM,EAAG,MAAM,CAAC;IAGhB,UAAU,CAAC,EAAE,MAAM,CAAC;IAGpB,SAAS,EAAG,MAAM,CAAC;IAGnB,SAAS,EAAG,MAAM,CAAC;IAGnB,WAAW,CAAC,EAAE,UAAU,C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