@pvh-afl/graphql 1.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.
- package/README.md +135 -0
- package/dist/cart/cart.hooks.d.ts +66 -0
- package/dist/cart/cart.hooks.d.ts.map +1 -0
- package/dist/cart/cart.hooks.js +12 -0
- package/dist/cart/cart.hooks.js.map +1 -0
- package/dist/cart/cart.module.d.ts +25 -0
- package/dist/cart/cart.module.d.ts.map +1 -0
- package/dist/cart/cart.module.js +44 -0
- package/dist/cart/cart.module.js.map +1 -0
- package/dist/cart/cart.resolver.d.ts +23 -0
- package/dist/cart/cart.resolver.d.ts.map +1 -0
- package/dist/cart/cart.resolver.js +153 -0
- package/dist/cart/cart.resolver.js.map +1 -0
- package/dist/cart/cart.service.d.ts +31 -0
- package/dist/cart/cart.service.d.ts.map +1 -0
- package/dist/cart/cart.service.js +305 -0
- package/dist/cart/cart.service.js.map +1 -0
- package/dist/cart/cart.types.d.ts +144 -0
- package/dist/cart/cart.types.d.ts.map +1 -0
- package/dist/cart/cart.types.js +629 -0
- package/dist/cart/cart.types.js.map +1 -0
- package/dist/cart/index.d.ts +6 -0
- package/dist/cart/index.d.ts.map +1 -0
- package/dist/cart/index.js +9 -0
- package/dist/cart/index.js.map +1 -0
- package/dist/cms/cms.module.d.ts +3 -0
- package/dist/cms/cms.module.d.ts.map +1 -0
- package/dist/cms/cms.module.js +18 -0
- package/dist/cms/cms.module.js.map +1 -0
- package/dist/cms/cms.resolver.d.ts +15 -0
- package/dist/cms/cms.resolver.d.ts.map +1 -0
- package/dist/cms/cms.resolver.js +44 -0
- package/dist/cms/cms.resolver.js.map +1 -0
- package/dist/cms/cms.service.d.ts +14 -0
- package/dist/cms/cms.service.d.ts.map +1 -0
- package/dist/cms/cms.service.js +111 -0
- package/dist/cms/cms.service.js.map +1 -0
- package/dist/cms/cms.types.d.ts +20 -0
- package/dist/cms/cms.types.d.ts.map +1 -0
- package/dist/cms/cms.types.js +89 -0
- package/dist/cms/cms.types.js.map +1 -0
- package/dist/cms/index.d.ts +5 -0
- package/dist/cms/index.d.ts.map +1 -0
- package/dist/cms/index.js +8 -0
- package/dist/cms/index.js.map +1 -0
- package/dist/collection/collection.module.d.ts +3 -0
- package/dist/collection/collection.module.d.ts.map +1 -0
- package/dist/collection/collection.module.js +19 -0
- package/dist/collection/collection.module.js.map +1 -0
- package/dist/collection/collection.resolver.d.ts +15 -0
- package/dist/collection/collection.resolver.d.ts.map +1 -0
- package/dist/collection/collection.resolver.js +45 -0
- package/dist/collection/collection.resolver.js.map +1 -0
- package/dist/collection/collection.service.d.ts +19 -0
- package/dist/collection/collection.service.d.ts.map +1 -0
- package/dist/collection/collection.service.js +132 -0
- package/dist/collection/collection.service.js.map +1 -0
- package/dist/collection/collection.types.d.ts +18 -0
- package/dist/collection/collection.types.d.ts.map +1 -0
- package/dist/collection/collection.types.js +75 -0
- package/dist/collection/collection.types.js.map +1 -0
- package/dist/collection/index.d.ts +5 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +8 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/common/index.d.ts +8 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +16 -0
- package/dist/common/index.js.map +1 -0
- package/dist/graphql.module.d.ts +3 -0
- package/dist/graphql.module.d.ts.map +1 -0
- package/dist/graphql.module.js +46 -0
- package/dist/graphql.module.js.map +1 -0
- package/dist/header/header.module.d.ts +9 -0
- package/dist/header/header.module.d.ts.map +1 -0
- package/dist/header/header.module.js +21 -0
- package/dist/header/header.module.js.map +1 -0
- package/dist/header/header.resolver.d.ts +18 -0
- package/dist/header/header.resolver.d.ts.map +1 -0
- package/dist/header/header.resolver.js +42 -0
- package/dist/header/header.resolver.js.map +1 -0
- package/dist/header/index.d.ts +4 -0
- package/dist/header/index.d.ts.map +1 -0
- package/dist/header/index.js +7 -0
- package/dist/header/index.js.map +1 -0
- package/dist/header/types/header.types.d.ts +36 -0
- package/dist/header/types/header.types.d.ts.map +1 -0
- package/dist/header/types/header.types.js +154 -0
- package/dist/header/types/header.types.js.map +1 -0
- package/dist/header/types/index.d.ts +3 -0
- package/dist/header/types/index.d.ts.map +1 -0
- package/dist/header/types/index.js +6 -0
- package/dist/header/types/index.js.map +1 -0
- package/dist/header/types/response.types.d.ts +13 -0
- package/dist/header/types/response.types.d.ts.map +1 -0
- package/dist/header/types/response.types.js +54 -0
- package/dist/header/types/response.types.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/page-content/index.d.ts +5 -0
- package/dist/page-content/index.d.ts.map +1 -0
- package/dist/page-content/index.js +8 -0
- package/dist/page-content/index.js.map +1 -0
- package/dist/page-content/page-content.module.d.ts +9 -0
- package/dist/page-content/page-content.module.d.ts.map +1 -0
- package/dist/page-content/page-content.module.js +25 -0
- package/dist/page-content/page-content.module.js.map +1 -0
- package/dist/page-content/page-content.resolver.d.ts +18 -0
- package/dist/page-content/page-content.resolver.d.ts.map +1 -0
- package/dist/page-content/page-content.resolver.js +42 -0
- package/dist/page-content/page-content.resolver.js.map +1 -0
- package/dist/page-content/page-content.service.d.ts +59 -0
- package/dist/page-content/page-content.service.d.ts.map +1 -0
- package/dist/page-content/page-content.service.js +253 -0
- package/dist/page-content/page-content.service.js.map +1 -0
- package/dist/page-content/types/common.types.d.ts +49 -0
- package/dist/page-content/types/common.types.d.ts.map +1 -0
- package/dist/page-content/types/common.types.js +217 -0
- package/dist/page-content/types/common.types.js.map +1 -0
- package/dist/page-content/types/index.d.ts +4 -0
- package/dist/page-content/types/index.d.ts.map +1 -0
- package/dist/page-content/types/index.js +7 -0
- package/dist/page-content/types/index.js.map +1 -0
- package/dist/page-content/types/response.types.d.ts +8 -0
- package/dist/page-content/types/response.types.d.ts.map +1 -0
- package/dist/page-content/types/response.types.js +29 -0
- package/dist/page-content/types/response.types.js.map +1 -0
- package/dist/page-content/types/section.types.d.ts +276 -0
- package/dist/page-content/types/section.types.d.ts.map +1 -0
- package/dist/page-content/types/section.types.js +1252 -0
- package/dist/page-content/types/section.types.js.map +1 -0
- package/dist/product/index.d.ts +5 -0
- package/dist/product/index.d.ts.map +1 -0
- package/dist/product/index.js +8 -0
- package/dist/product/index.js.map +1 -0
- package/dist/product/product.module.d.ts +3 -0
- package/dist/product/product.module.d.ts.map +1 -0
- package/dist/product/product.module.js +19 -0
- package/dist/product/product.module.js.map +1 -0
- package/dist/product/product.resolver.d.ts +15 -0
- package/dist/product/product.resolver.d.ts.map +1 -0
- package/dist/product/product.resolver.js +45 -0
- package/dist/product/product.resolver.js.map +1 -0
- package/dist/product/product.service.d.ts +38 -0
- package/dist/product/product.service.d.ts.map +1 -0
- package/dist/product/product.service.js +337 -0
- package/dist/product/product.service.js.map +1 -0
- package/dist/product/product.types.d.ts +63 -0
- package/dist/product/product.types.d.ts.map +1 -0
- package/dist/product/product.types.js +276 -0
- package/dist/product/product.types.js.map +1 -0
- package/dist/product-content/index.d.ts +5 -0
- package/dist/product-content/index.d.ts.map +1 -0
- package/dist/product-content/index.js +8 -0
- package/dist/product-content/index.js.map +1 -0
- package/dist/product-content/product-content.module.d.ts +3 -0
- package/dist/product-content/product-content.module.d.ts.map +1 -0
- package/dist/product-content/product-content.module.js +27 -0
- package/dist/product-content/product-content.module.js.map +1 -0
- package/dist/product-content/product-content.resolver.d.ts +20 -0
- package/dist/product-content/product-content.resolver.d.ts.map +1 -0
- package/dist/product-content/product-content.resolver.js +44 -0
- package/dist/product-content/product-content.resolver.js.map +1 -0
- package/dist/product-content/product-content.service.d.ts +40 -0
- package/dist/product-content/product-content.service.d.ts.map +1 -0
- package/dist/product-content/product-content.service.js +239 -0
- package/dist/product-content/product-content.service.js.map +1 -0
- package/dist/product-content/types/common.types.d.ts +85 -0
- package/dist/product-content/types/common.types.d.ts.map +1 -0
- package/dist/product-content/types/common.types.js +384 -0
- package/dist/product-content/types/common.types.js.map +1 -0
- package/dist/product-content/types/index.d.ts +3 -0
- package/dist/product-content/types/index.d.ts.map +1 -0
- package/dist/product-content/types/index.js +6 -0
- package/dist/product-content/types/index.js.map +1 -0
- package/dist/product-content/types/response.types.d.ts +10 -0
- package/dist/product-content/types/response.types.d.ts.map +1 -0
- package/dist/product-content/types/response.types.js +39 -0
- package/dist/product-content/types/response.types.js.map +1 -0
- package/dist/serviceability/index.d.ts +5 -0
- package/dist/serviceability/index.d.ts.map +1 -0
- package/dist/serviceability/index.js +8 -0
- package/dist/serviceability/index.js.map +1 -0
- package/dist/serviceability/serviceability.module.d.ts +3 -0
- package/dist/serviceability/serviceability.module.d.ts.map +1 -0
- package/dist/serviceability/serviceability.module.js +18 -0
- package/dist/serviceability/serviceability.module.js.map +1 -0
- package/dist/serviceability/serviceability.resolver.d.ts +19 -0
- package/dist/serviceability/serviceability.resolver.d.ts.map +1 -0
- package/dist/serviceability/serviceability.resolver.js +40 -0
- package/dist/serviceability/serviceability.resolver.js.map +1 -0
- package/dist/serviceability/serviceability.service.d.ts +42 -0
- package/dist/serviceability/serviceability.service.d.ts.map +1 -0
- package/dist/serviceability/serviceability.service.js +169 -0
- package/dist/serviceability/serviceability.service.js.map +1 -0
- package/dist/serviceability/serviceability.types.d.ts +42 -0
- package/dist/serviceability/serviceability.types.d.ts.map +1 -0
- package/dist/serviceability/serviceability.types.js +184 -0
- package/dist/serviceability/serviceability.types.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.module.d.ts","sourceRoot":"","sources":["../../src/cms/cms.module.ts"],"names":[],"mappings":"AAKA,qBAIa,SAAS;CAAG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CmsModule = 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 cms_resolver_1 = require("./cms.resolver");
|
|
8
|
+
const cms_service_1 = require("./cms.service");
|
|
9
|
+
let CmsModule = class CmsModule {
|
|
10
|
+
};
|
|
11
|
+
exports.CmsModule = CmsModule;
|
|
12
|
+
exports.CmsModule = CmsModule = tslib_1.__decorate([
|
|
13
|
+
(0, common_1.Module)({
|
|
14
|
+
imports: [core_1.IntegrationsModule],
|
|
15
|
+
providers: [cms_resolver_1.CmsResolver, cms_service_1.CmsService],
|
|
16
|
+
})
|
|
17
|
+
], CmsModule);
|
|
18
|
+
//# sourceMappingURL=cms.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.module.js","sourceRoot":"","sources":["../../src/cms/cms.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,wCAAmD;AACnD,iDAA6C;AAC7C,+CAA2C;AAMpC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAJrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE,CAAC,0BAAW,EAAE,wBAAU,CAAC;KACrC,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CmsService } from './cms.service';
|
|
2
|
+
import { Page, Menu } from './cms.types';
|
|
3
|
+
interface GqlContext {
|
|
4
|
+
req: {
|
|
5
|
+
brand: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare class CmsResolver {
|
|
9
|
+
private readonly cmsService;
|
|
10
|
+
constructor(cmsService: CmsService);
|
|
11
|
+
page(ctx: GqlContext, handle: string): Promise<Page | null>;
|
|
12
|
+
menu(ctx: GqlContext, handle: string): Promise<Menu | null>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=cms.resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.resolver.d.ts","sourceRoot":"","sources":["../../src/cms/cms.resolver.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzC,UAAU,UAAU;IAClB,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACxB;AAED,qBAEa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAG7C,IAAI,CACG,GAAG,EAAE,UAAU,EACc,MAAM,EAAE,MAAM,GACrD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAKjB,IAAI,CACG,GAAG,EAAE,UAAU,EACc,MAAM,EAAE,MAAM,GACrD,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;CAGxB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CmsResolver = 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 cms_service_1 = require("./cms.service");
|
|
9
|
+
const cms_types_1 = require("./cms.types");
|
|
10
|
+
let CmsResolver = class CmsResolver {
|
|
11
|
+
cmsService;
|
|
12
|
+
constructor(cmsService) {
|
|
13
|
+
this.cmsService = cmsService;
|
|
14
|
+
}
|
|
15
|
+
async page(ctx, handle) {
|
|
16
|
+
return this.cmsService.getPage(ctx.req.brand, handle);
|
|
17
|
+
}
|
|
18
|
+
async menu(ctx, handle) {
|
|
19
|
+
return this.cmsService.getMenu(ctx.req.brand, handle);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.CmsResolver = CmsResolver;
|
|
23
|
+
tslib_1.__decorate([
|
|
24
|
+
(0, graphql_1.Query)(() => cms_types_1.Page, { nullable: true, description: 'Get page by handle' }),
|
|
25
|
+
tslib_1.__param(0, (0, graphql_1.Context)()),
|
|
26
|
+
tslib_1.__param(1, (0, graphql_1.Args)('handle', { type: () => String })),
|
|
27
|
+
tslib_1.__metadata("design:type", Function),
|
|
28
|
+
tslib_1.__metadata("design:paramtypes", [Object, String]),
|
|
29
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
30
|
+
], CmsResolver.prototype, "page", null);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, graphql_1.Query)(() => cms_types_1.Menu, { nullable: true, description: 'Get menu by handle' }),
|
|
33
|
+
tslib_1.__param(0, (0, graphql_1.Context)()),
|
|
34
|
+
tslib_1.__param(1, (0, graphql_1.Args)('handle', { type: () => String })),
|
|
35
|
+
tslib_1.__metadata("design:type", Function),
|
|
36
|
+
tslib_1.__metadata("design:paramtypes", [Object, String]),
|
|
37
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
38
|
+
], CmsResolver.prototype, "menu", null);
|
|
39
|
+
exports.CmsResolver = CmsResolver = tslib_1.__decorate([
|
|
40
|
+
(0, graphql_1.Resolver)(),
|
|
41
|
+
(0, common_1.UseGuards)(core_1.TenantGuard),
|
|
42
|
+
tslib_1.__metadata("design:paramtypes", [cms_service_1.CmsService])
|
|
43
|
+
], CmsResolver);
|
|
44
|
+
//# sourceMappingURL=cms.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.resolver.js","sourceRoot":"","sources":["../../src/cms/cms.resolver.ts"],"names":[],"mappings":";;;;AAAA,6CAAiE;AACjE,2CAA2C;AAC3C,wCAA4C;AAC5C,+CAA2C;AAC3C,2CAAyC;AAQlC,IAAM,WAAW,GAAjB,MAAM,WAAW;IACO;IAA7B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGjD,AAAN,KAAK,CAAC,IAAI,CACG,GAAe,EACc,MAAc;QAEtD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAGK,AAAN,KAAK,CAAC,IAAI,CACG,GAAe,EACc,MAAc;QAEtD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAlBY,kCAAW;AAIhB;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IAEtE,mBAAA,IAAA,iBAAO,GAAE,CAAA;IACT,mBAAA,IAAA,cAAI,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;;;;uCAGxC;AAGK;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IAEtE,mBAAA,IAAA,iBAAO,GAAE,CAAA;IACT,mBAAA,IAAA,cAAI,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;;;;uCAGxC;sBAjBU,WAAW;IAFvB,IAAA,kBAAQ,GAAE;IACV,IAAA,kBAAS,EAAC,kBAAW,CAAC;6CAEoB,wBAAU;GADxC,WAAW,CAkBvB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CacheService, ConfigService, IntegrationFactory } from '@pvh-afl/core';
|
|
2
|
+
import { Page, Menu } from './cms.types';
|
|
3
|
+
export declare class CmsService {
|
|
4
|
+
private readonly cache;
|
|
5
|
+
private readonly configService;
|
|
6
|
+
private readonly integrationFactory;
|
|
7
|
+
constructor(cache: CacheService, configService: ConfigService, integrationFactory: IntegrationFactory);
|
|
8
|
+
private getCommerceService;
|
|
9
|
+
getPage(brand: string, handle: string): Promise<Page | null>;
|
|
10
|
+
getMenu(brand: string, handle: string): Promise<Menu | null>;
|
|
11
|
+
private refreshPageInBackground;
|
|
12
|
+
private refreshMenuInBackground;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cms.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.service.d.ts","sourceRoot":"","sources":["../../src/cms/cms.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAGnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEzC,qBACa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAFlB,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB;IAGzD,OAAO,CAAC,kBAAkB;IAQpB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IA0B5D,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IA0BlE,OAAO,CAAC,uBAAuB;IA0B/B,OAAO,CAAC,uBAAuB;CAyBhC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CmsService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const core_1 = require("@pvh-afl/core");
|
|
7
|
+
let CmsService = class CmsService {
|
|
8
|
+
cache;
|
|
9
|
+
configService;
|
|
10
|
+
integrationFactory;
|
|
11
|
+
constructor(cache, configService, integrationFactory) {
|
|
12
|
+
this.cache = cache;
|
|
13
|
+
this.configService = configService;
|
|
14
|
+
this.integrationFactory = integrationFactory;
|
|
15
|
+
}
|
|
16
|
+
getCommerceService(brand) {
|
|
17
|
+
const commerce = this.integrationFactory.get(brand, 'commerce');
|
|
18
|
+
if (!commerce) {
|
|
19
|
+
throw new Error(`Commerce integration not configured for brand: ${brand}`);
|
|
20
|
+
}
|
|
21
|
+
return commerce;
|
|
22
|
+
}
|
|
23
|
+
async getPage(brand, handle) {
|
|
24
|
+
const cacheKey = `${brand}:page:${handle}`;
|
|
25
|
+
const cached = await this.cache.get(cacheKey);
|
|
26
|
+
if (cached) {
|
|
27
|
+
if (cached.isStale) {
|
|
28
|
+
this.refreshPageInBackground(brand, handle, cacheKey);
|
|
29
|
+
}
|
|
30
|
+
return cached.data;
|
|
31
|
+
}
|
|
32
|
+
const commerce = this.getCommerceService(brand);
|
|
33
|
+
const response = await commerce.getPage(handle);
|
|
34
|
+
if (!response.success) {
|
|
35
|
+
throw new Error(response.error?.message ?? 'Failed to fetch page');
|
|
36
|
+
}
|
|
37
|
+
if (!response.data)
|
|
38
|
+
return null;
|
|
39
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
40
|
+
await this.cache.set(cacheKey, response.data, defaultTTL, staleTTL);
|
|
41
|
+
return response.data;
|
|
42
|
+
}
|
|
43
|
+
async getMenu(brand, handle) {
|
|
44
|
+
const cacheKey = `${brand}:menu:${handle}`;
|
|
45
|
+
const cached = await this.cache.get(cacheKey);
|
|
46
|
+
if (cached) {
|
|
47
|
+
if (cached.isStale) {
|
|
48
|
+
this.refreshMenuInBackground(brand, handle, cacheKey);
|
|
49
|
+
}
|
|
50
|
+
return cached.data;
|
|
51
|
+
}
|
|
52
|
+
const commerce = this.getCommerceService(brand);
|
|
53
|
+
const response = await commerce.getMenu(handle);
|
|
54
|
+
if (!response.success) {
|
|
55
|
+
throw new Error(response.error?.message ?? 'Failed to fetch menu');
|
|
56
|
+
}
|
|
57
|
+
if (!response.data)
|
|
58
|
+
return null;
|
|
59
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
60
|
+
await this.cache.set(cacheKey, response.data, defaultTTL, staleTTL);
|
|
61
|
+
return response.data;
|
|
62
|
+
}
|
|
63
|
+
refreshPageInBackground(brand, handle, cacheKey) {
|
|
64
|
+
const commerce = this.integrationFactory.get(brand, 'commerce');
|
|
65
|
+
if (!commerce)
|
|
66
|
+
return;
|
|
67
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
68
|
+
commerce
|
|
69
|
+
.getPage(handle)
|
|
70
|
+
.then(async (response) => {
|
|
71
|
+
if (response.success && response.data) {
|
|
72
|
+
await this.cache.set(cacheKey, response.data, defaultTTL, staleTTL);
|
|
73
|
+
core_1.logger.info('Background refresh completed', { cacheKey });
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.catch((error) => {
|
|
77
|
+
core_1.logger.error('Background refresh failed', {
|
|
78
|
+
cacheKey,
|
|
79
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
refreshMenuInBackground(brand, handle, cacheKey) {
|
|
84
|
+
const commerce = this.integrationFactory.get(brand, 'commerce');
|
|
85
|
+
if (!commerce)
|
|
86
|
+
return;
|
|
87
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
88
|
+
commerce
|
|
89
|
+
.getMenu(handle)
|
|
90
|
+
.then(async (response) => {
|
|
91
|
+
if (response.success && response.data) {
|
|
92
|
+
await this.cache.set(cacheKey, response.data, defaultTTL, staleTTL);
|
|
93
|
+
core_1.logger.info('Background refresh completed', { cacheKey });
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
core_1.logger.error('Background refresh failed', {
|
|
98
|
+
cacheKey,
|
|
99
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.CmsService = CmsService;
|
|
105
|
+
exports.CmsService = CmsService = tslib_1.__decorate([
|
|
106
|
+
(0, common_1.Injectable)(),
|
|
107
|
+
tslib_1.__metadata("design:paramtypes", [core_1.CacheService,
|
|
108
|
+
core_1.ConfigService,
|
|
109
|
+
core_1.IntegrationFactory])
|
|
110
|
+
], CmsService);
|
|
111
|
+
//# sourceMappingURL=cms.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.service.js","sourceRoot":"","sources":["../../src/cms/cms.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,wCAMuB;AAIhB,IAAM,UAAU,GAAhB,MAAM,UAAU;IAEF;IACA;IACA;IAHnB,YACmB,KAAmB,EACnB,aAA4B,EAC5B,kBAAsC;QAFtC,UAAK,GAAL,KAAK,CAAc;QACnB,kBAAa,GAAb,aAAa,CAAe;QAC5B,uBAAkB,GAAlB,kBAAkB,CAAoB;IACtD,CAAC;IAEI,kBAAkB,CAAC,KAAa;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,QAAuC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,MAAc;QACzC,MAAM,QAAQ,GAAG,GAAG,KAAK,SAAS,MAAM,EAAE,CAAC;QAE3C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,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CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAA;AAtHY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;6CAGe,mBAAY;QACJ,oBAAa;QACR,yBAAkB;GAJ9C,UAAU,CAsHtB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Page {
|
|
2
|
+
id: string;
|
|
3
|
+
handle: string;
|
|
4
|
+
title: string;
|
|
5
|
+
body: string;
|
|
6
|
+
bodySummary: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class MenuItem {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
url: string;
|
|
12
|
+
items: MenuItem[];
|
|
13
|
+
}
|
|
14
|
+
export declare class Menu {
|
|
15
|
+
id: string;
|
|
16
|
+
handle: string;
|
|
17
|
+
title: string;
|
|
18
|
+
items: MenuItem[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=cms.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.types.d.ts","sourceRoot":"","sources":["../../src/cms/cms.types.ts"],"names":[],"mappings":"AAEA,qBACa,IAAI;IAEf,EAAE,EAAE,MAAM,CAAC;IAGX,MAAM,EAAE,MAAM,CAAC;IAGf,KAAK,EAAE,MAAM,CAAC;IAGd,IAAI,EAAE,MAAM,CAAC;IAGb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBACa,QAAQ;IAEnB,EAAE,EAAE,MAAM,CAAC;IAGX,KAAK,EAAE,MAAM,CAAC;IAGd,GAAG,EAAE,MAAM,CAAC;IAGZ,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,qBACa,IAAI;IAEf,EAAE,EAAE,MAAM,CAAC;IAGX,MAAM,EAAE,MAAM,CAAC;IAGf,KAAK,EAAE,MAAM,CAAC;IAGd,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Menu = exports.MenuItem = exports.Page = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
6
|
+
let Page = class Page {
|
|
7
|
+
id;
|
|
8
|
+
handle;
|
|
9
|
+
title;
|
|
10
|
+
body;
|
|
11
|
+
bodySummary;
|
|
12
|
+
};
|
|
13
|
+
exports.Page = Page;
|
|
14
|
+
tslib_1.__decorate([
|
|
15
|
+
(0, graphql_1.Field)(() => graphql_1.ID),
|
|
16
|
+
tslib_1.__metadata("design:type", String)
|
|
17
|
+
], Page.prototype, "id", void 0);
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, graphql_1.Field)(),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], Page.prototype, "handle", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, graphql_1.Field)(),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], Page.prototype, "title", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, graphql_1.Field)(),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], Page.prototype, "body", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, graphql_1.Field)(),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], Page.prototype, "bodySummary", void 0);
|
|
34
|
+
exports.Page = Page = tslib_1.__decorate([
|
|
35
|
+
(0, graphql_1.ObjectType)()
|
|
36
|
+
], Page);
|
|
37
|
+
let MenuItem = class MenuItem {
|
|
38
|
+
id;
|
|
39
|
+
title;
|
|
40
|
+
url;
|
|
41
|
+
items;
|
|
42
|
+
};
|
|
43
|
+
exports.MenuItem = MenuItem;
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, graphql_1.Field)(() => graphql_1.ID),
|
|
46
|
+
tslib_1.__metadata("design:type", String)
|
|
47
|
+
], MenuItem.prototype, "id", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, graphql_1.Field)(),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], MenuItem.prototype, "title", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, graphql_1.Field)(),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], MenuItem.prototype, "url", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, graphql_1.Field)(() => [MenuItem]),
|
|
58
|
+
tslib_1.__metadata("design:type", Array)
|
|
59
|
+
], MenuItem.prototype, "items", void 0);
|
|
60
|
+
exports.MenuItem = MenuItem = tslib_1.__decorate([
|
|
61
|
+
(0, graphql_1.ObjectType)()
|
|
62
|
+
], MenuItem);
|
|
63
|
+
let Menu = class Menu {
|
|
64
|
+
id;
|
|
65
|
+
handle;
|
|
66
|
+
title;
|
|
67
|
+
items;
|
|
68
|
+
};
|
|
69
|
+
exports.Menu = Menu;
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, graphql_1.Field)(() => graphql_1.ID),
|
|
72
|
+
tslib_1.__metadata("design:type", String)
|
|
73
|
+
], Menu.prototype, "id", void 0);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, graphql_1.Field)(),
|
|
76
|
+
tslib_1.__metadata("design:type", String)
|
|
77
|
+
], Menu.prototype, "handle", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, graphql_1.Field)(),
|
|
80
|
+
tslib_1.__metadata("design:type", String)
|
|
81
|
+
], Menu.prototype, "title", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, graphql_1.Field)(() => [MenuItem]),
|
|
84
|
+
tslib_1.__metadata("design:type", Array)
|
|
85
|
+
], Menu.prototype, "items", void 0);
|
|
86
|
+
exports.Menu = Menu = tslib_1.__decorate([
|
|
87
|
+
(0, graphql_1.ObjectType)()
|
|
88
|
+
], Menu);
|
|
89
|
+
//# sourceMappingURL=cms.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms.types.js","sourceRoot":"","sources":["../../src/cms/cms.types.ts"],"names":[],"mappings":";;;;AAAA,6CAAwD;AAGjD,IAAM,IAAI,GAAV,MAAM,IAAI;IAEf,EAAE,CAAS;IAGX,MAAM,CAAS;IAGf,KAAK,CAAS;IAGd,IAAI,CAAS;IAGb,WAAW,CAAS;CACrB,CAAA;AAfY,oBAAI;AAEf;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,YAAE,CAAC;;gCACL;AAGX;IADC,IAAA,eAAK,GAAE;;oCACO;AAGf;IADC,IAAA,eAAK,GAAE;;mCACM;AAGd;IADC,IAAA,eAAK,GAAE;;kCACK;AAGb;IADC,IAAA,eAAK,GAAE;;yCACY;eAdT,IAAI;IADhB,IAAA,oBAAU,GAAE;GACA,IAAI,CAehB;AAGM,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEnB,EAAE,CAAS;IAGX,KAAK,CAAS;IAGd,GAAG,CAAS;IAGZ,KAAK,CAAa;CACnB,CAAA;AAZY,4BAAQ;AAEnB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,YAAE,CAAC;;oCACL;AAGX;IADC,IAAA,eAAK,GAAE;;uCACM;AAGd;IADC,IAAA,eAAK,GAAE;;qCACI;AAGZ;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;;uCACN;mBAXP,QAAQ;IADpB,IAAA,oBAAU,GAAE;GACA,QAAQ,CAYpB;AAGM,IAAM,IAAI,GAAV,MAAM,IAAI;IAEf,EAAE,CAAS;IAGX,MAAM,CAAS;IAGf,KAAK,CAAS;IAGd,KAAK,CAAa;CACnB,CAAA;AAZY,oBAAI;AAEf;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,YAAE,CAAC;;gCACL;AAGX;IADC,IAAA,eAAK,GAAE;;oCACO;AAGf;IADC,IAAA,eAAK,GAAE;;mCACM;AAGd;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;;mCACN;eAXP,IAAI;IADhB,IAAA,oBAAU,GAAE;GACA,IAAI,CAYhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cms/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./cms.module"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./cms.resolver"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./cms.service"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./cms.types"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cms/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,yDAA+B;AAC/B,wDAA8B;AAC9B,sDAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.module.d.ts","sourceRoot":"","sources":["../../src/collection/collection.module.ts"],"names":[],"mappings":"AAKA,qBAKa,gBAAgB;CAAG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionModule = 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 collection_resolver_1 = require("./collection.resolver");
|
|
8
|
+
const collection_service_1 = require("./collection.service");
|
|
9
|
+
let CollectionModule = class CollectionModule {
|
|
10
|
+
};
|
|
11
|
+
exports.CollectionModule = CollectionModule;
|
|
12
|
+
exports.CollectionModule = CollectionModule = tslib_1.__decorate([
|
|
13
|
+
(0, common_1.Module)({
|
|
14
|
+
imports: [core_1.IntegrationsModule],
|
|
15
|
+
providers: [collection_resolver_1.CollectionResolver, collection_service_1.CollectionService],
|
|
16
|
+
exports: [collection_service_1.CollectionService],
|
|
17
|
+
})
|
|
18
|
+
], CollectionModule);
|
|
19
|
+
//# sourceMappingURL=collection.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.module.js","sourceRoot":"","sources":["../../src/collection/collection.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,wCAAmD;AACnD,+DAA2D;AAC3D,6DAAyD;AAOlD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAL5B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE,CAAC,wCAAkB,EAAE,sCAAiB,CAAC;QAClD,OAAO,EAAE,CAAC,sCAAiB,CAAC;KAC7B,CAAC;GACW,gBAAgB,CAAG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CollectionService } from './collection.service';
|
|
2
|
+
import { Collection, CollectionConnection } from './collection.types';
|
|
3
|
+
interface GqlContext {
|
|
4
|
+
req: {
|
|
5
|
+
brand: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare class CollectionResolver {
|
|
9
|
+
private readonly collectionService;
|
|
10
|
+
constructor(collectionService: CollectionService);
|
|
11
|
+
collections(ctx: GqlContext, first: number): Promise<CollectionConnection>;
|
|
12
|
+
collectionByHandle(ctx: GqlContext, handle: string, productsFirst: number): Promise<Collection | null>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=collection.resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.resolver.d.ts","sourceRoot":"","sources":["../../src/collection/collection.resolver.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,UAAU,UAAU;IAClB,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACxB;AAED,qBAEa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,iBAAiB;IAG3D,WAAW,CACJ,GAAG,EAAE,UAAU,EAC4B,KAAK,EAAE,MAAM,GAClE,OAAO,CAAC,oBAAoB,CAAC;IAK1B,kBAAkB,CACX,GAAG,EAAE,UAAU,EACc,MAAM,EAAE,MAAM,EACQ,aAAa,EAAE,MAAM,GAClF,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAG9B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionResolver = 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 collection_service_1 = require("./collection.service");
|
|
9
|
+
const collection_types_1 = require("./collection.types");
|
|
10
|
+
let CollectionResolver = class CollectionResolver {
|
|
11
|
+
collectionService;
|
|
12
|
+
constructor(collectionService) {
|
|
13
|
+
this.collectionService = collectionService;
|
|
14
|
+
}
|
|
15
|
+
async collections(ctx, first) {
|
|
16
|
+
return this.collectionService.getCollections(ctx.req.brand, { first });
|
|
17
|
+
}
|
|
18
|
+
async collectionByHandle(ctx, handle, productsFirst) {
|
|
19
|
+
return this.collectionService.getCollectionByHandle(ctx.req.brand, handle, productsFirst);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.CollectionResolver = CollectionResolver;
|
|
23
|
+
tslib_1.__decorate([
|
|
24
|
+
(0, graphql_1.Query)(() => collection_types_1.CollectionConnection, { description: 'Get paginated list of collections' }),
|
|
25
|
+
tslib_1.__param(0, (0, graphql_1.Context)()),
|
|
26
|
+
tslib_1.__param(1, (0, graphql_1.Args)('first', { type: () => graphql_1.Int, defaultValue: 20 })),
|
|
27
|
+
tslib_1.__metadata("design:type", Function),
|
|
28
|
+
tslib_1.__metadata("design:paramtypes", [Object, Number]),
|
|
29
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
30
|
+
], CollectionResolver.prototype, "collections", null);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, graphql_1.Query)(() => collection_types_1.Collection, { nullable: true, description: 'Get collection by handle' }),
|
|
33
|
+
tslib_1.__param(0, (0, graphql_1.Context)()),
|
|
34
|
+
tslib_1.__param(1, (0, graphql_1.Args)('handle', { type: () => String })),
|
|
35
|
+
tslib_1.__param(2, (0, graphql_1.Args)('productsFirst', { type: () => graphql_1.Int, defaultValue: 20 })),
|
|
36
|
+
tslib_1.__metadata("design:type", Function),
|
|
37
|
+
tslib_1.__metadata("design:paramtypes", [Object, String, Number]),
|
|
38
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
39
|
+
], CollectionResolver.prototype, "collectionByHandle", null);
|
|
40
|
+
exports.CollectionResolver = CollectionResolver = tslib_1.__decorate([
|
|
41
|
+
(0, graphql_1.Resolver)(() => collection_types_1.Collection),
|
|
42
|
+
(0, common_1.UseGuards)(core_1.TenantGuard),
|
|
43
|
+
tslib_1.__metadata("design:paramtypes", [collection_service_1.CollectionService])
|
|
44
|
+
], CollectionResolver);
|
|
45
|
+
//# sourceMappingURL=collection.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.resolver.js","sourceRoot":"","sources":["../../src/collection/collection.resolver.ts"],"names":[],"mappings":";;;;AAAA,6CAAsE;AACtE,2CAA2C;AAC3C,wCAA4C;AAC5C,6DAAyD;AACzD,yDAAsE;AAQ/D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACA;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAG/D,AAAN,KAAK,CAAC,WAAW,CACJ,GAAe,EAC4B,KAAa;QAEnE,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;IAGK,AAAN,KAAK,CAAC,kBAAkB,CACX,GAAe,EACc,MAAc,EACQ,aAAqB;QAEnF,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5F,CAAC;CACF,CAAA;AAnBY,gDAAkB;AAIvB;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,uCAAoB,EAAE,EAAE,WAAW,EAAE,mCAAmC,EAAE,CAAC;IAErF,mBAAA,IAAA,iBAAO,GAAE,CAAA;IACT,mBAAA,IAAA,cAAI,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAG,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAA;;;;qDAGtD;AAGK;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,6BAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;IAElF,mBAAA,IAAA,iBAAO,GAAE,CAAA;IACT,mBAAA,IAAA,cAAI,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;IACtC,mBAAA,IAAA,cAAI,EAAC,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAG,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAA;;;;4DAG9D;6BAlBU,kBAAkB;IAF9B,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,6BAAU,CAAC;IAC1B,IAAA,kBAAS,EAAC,kBAAW,CAAC;6CAE2B,sCAAiB;GADtD,kBAAkB,CAmB9B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CacheService, ConfigService, IntegrationFactory } from '@pvh-afl/core';
|
|
2
|
+
import { Collection, CollectionConnection } from './collection.types';
|
|
3
|
+
export declare class CollectionService {
|
|
4
|
+
private readonly cache;
|
|
5
|
+
private readonly configService;
|
|
6
|
+
private readonly integrationFactory;
|
|
7
|
+
constructor(cache: CacheService, configService: ConfigService, integrationFactory: IntegrationFactory);
|
|
8
|
+
private getCommerceService;
|
|
9
|
+
getCollections(brand: string, params?: {
|
|
10
|
+
first?: number;
|
|
11
|
+
}): Promise<CollectionConnection>;
|
|
12
|
+
getCollectionByHandle(brand: string, handle: string, productsFirst?: number): Promise<Collection | null>;
|
|
13
|
+
private refreshCollectionsInBackground;
|
|
14
|
+
private refreshCollectionByHandleInBackground;
|
|
15
|
+
private doRefreshCollectionByHandle;
|
|
16
|
+
private mapConnection;
|
|
17
|
+
private mapCollection;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=collection.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.service.d.ts","sourceRoot":"","sources":["../../src/collection/collection.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAKnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEtE,qBACa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;gBAFlB,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB;IAGzD,OAAO,CAAC,kBAAkB;IAUpB,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GAC9B,OAAO,CAAC,oBAAoB,CAAC;IA2B1B,qBAAqB,CACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,SAAK,GACjB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAoC7B,OAAO,CAAC,8BAA8B;IA8BtC,OAAO,CAAC,qCAAqC;YAmB/B,2BAA2B;IAyBzC,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;CAUtB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const core_1 = require("@pvh-afl/core");
|
|
7
|
+
let CollectionService = class CollectionService {
|
|
8
|
+
cache;
|
|
9
|
+
configService;
|
|
10
|
+
integrationFactory;
|
|
11
|
+
constructor(cache, configService, integrationFactory) {
|
|
12
|
+
this.cache = cache;
|
|
13
|
+
this.configService = configService;
|
|
14
|
+
this.integrationFactory = integrationFactory;
|
|
15
|
+
}
|
|
16
|
+
getCommerceService(brand) {
|
|
17
|
+
const commerce = this.integrationFactory.get(brand, 'commerce');
|
|
18
|
+
if (!commerce) {
|
|
19
|
+
throw new Error(`Commerce integration not configured for brand: ${brand}`);
|
|
20
|
+
}
|
|
21
|
+
return commerce;
|
|
22
|
+
}
|
|
23
|
+
async getCollections(brand, params = {}) {
|
|
24
|
+
const first = params.first ?? 20;
|
|
25
|
+
const cacheKey = `${brand}:collections:${first}`;
|
|
26
|
+
const cached = await this.cache.get(cacheKey);
|
|
27
|
+
if (cached) {
|
|
28
|
+
if (cached.isStale) {
|
|
29
|
+
this.refreshCollectionsInBackground(brand, params, cacheKey);
|
|
30
|
+
}
|
|
31
|
+
return cached.data;
|
|
32
|
+
}
|
|
33
|
+
const commerce = this.getCommerceService(brand);
|
|
34
|
+
const response = await commerce.getCollections(params);
|
|
35
|
+
if (!response.success || !response.data) {
|
|
36
|
+
throw new Error(response.error?.message ?? 'Failed to fetch collections');
|
|
37
|
+
}
|
|
38
|
+
const collections = this.mapConnection(response.data);
|
|
39
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
40
|
+
await this.cache.set(cacheKey, collections, defaultTTL, staleTTL);
|
|
41
|
+
return collections;
|
|
42
|
+
}
|
|
43
|
+
async getCollectionByHandle(brand, handle, productsFirst = 20) {
|
|
44
|
+
const cacheKey = `${brand}:collection:${handle}:${productsFirst}`;
|
|
45
|
+
const cached = await this.cache.get(cacheKey);
|
|
46
|
+
if (cached) {
|
|
47
|
+
if (cached.isStale) {
|
|
48
|
+
this.refreshCollectionByHandleInBackground(brand, handle, productsFirst, cacheKey);
|
|
49
|
+
}
|
|
50
|
+
return cached.data;
|
|
51
|
+
}
|
|
52
|
+
const commerce = this.getCommerceService(brand);
|
|
53
|
+
const response = await commerce.getCollectionByHandle(handle, productsFirst);
|
|
54
|
+
if (!response.success) {
|
|
55
|
+
throw new Error(response.error?.message ?? 'Failed to fetch collection');
|
|
56
|
+
}
|
|
57
|
+
if (!response.data)
|
|
58
|
+
return null;
|
|
59
|
+
const collection = this.mapCollection(response.data);
|
|
60
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
61
|
+
await this.cache.set(cacheKey, collection, defaultTTL, staleTTL);
|
|
62
|
+
return collection;
|
|
63
|
+
}
|
|
64
|
+
refreshCollectionsInBackground(brand, params, cacheKey) {
|
|
65
|
+
const commerce = this.integrationFactory.get(brand, 'commerce');
|
|
66
|
+
if (!commerce)
|
|
67
|
+
return;
|
|
68
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
69
|
+
commerce
|
|
70
|
+
.getCollections(params)
|
|
71
|
+
.then(async (response) => {
|
|
72
|
+
if (response.success && response.data) {
|
|
73
|
+
const collections = this.mapConnection(response.data);
|
|
74
|
+
await this.cache.set(cacheKey, collections, defaultTTL, staleTTL);
|
|
75
|
+
core_1.logger.info('Background refresh completed', { cacheKey });
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.catch((error) => {
|
|
79
|
+
core_1.logger.error('Background refresh failed', {
|
|
80
|
+
cacheKey,
|
|
81
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
refreshCollectionByHandleInBackground(brand, handle, productsFirst, cacheKey) {
|
|
86
|
+
this.doRefreshCollectionByHandle(brand, handle, productsFirst, cacheKey).catch((error) => {
|
|
87
|
+
core_1.logger.error('Background refresh failed', {
|
|
88
|
+
cacheKey,
|
|
89
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async doRefreshCollectionByHandle(brand, handle, productsFirst, cacheKey) {
|
|
94
|
+
const commerce = this.integrationFactory.get(brand, 'commerce');
|
|
95
|
+
if (!commerce)
|
|
96
|
+
return;
|
|
97
|
+
const { defaultTTL, staleTTL } = this.configService.getCacheTTL(brand);
|
|
98
|
+
const response = await commerce.getCollectionByHandle(handle, productsFirst);
|
|
99
|
+
if (response.success && response.data) {
|
|
100
|
+
const collection = this.mapCollection(response.data);
|
|
101
|
+
await this.cache.set(cacheKey, collection, defaultTTL, staleTTL);
|
|
102
|
+
core_1.logger.info('Collection cache refreshed', { cacheKey, handle });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
mapConnection(connection) {
|
|
106
|
+
return {
|
|
107
|
+
edges: connection.edges.map((edge) => ({
|
|
108
|
+
node: this.mapCollection(edge.node),
|
|
109
|
+
cursor: edge.cursor,
|
|
110
|
+
})),
|
|
111
|
+
pageInfo: connection.pageInfo,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
mapCollection(commerce) {
|
|
115
|
+
return {
|
|
116
|
+
id: commerce.id,
|
|
117
|
+
handle: commerce.handle,
|
|
118
|
+
title: commerce.title,
|
|
119
|
+
description: commerce.description,
|
|
120
|
+
image: commerce.image,
|
|
121
|
+
productHandles: commerce.productRefs?.edges.map((e) => e.node.handle),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.CollectionService = CollectionService;
|
|
126
|
+
exports.CollectionService = CollectionService = tslib_1.__decorate([
|
|
127
|
+
(0, common_1.Injectable)(),
|
|
128
|
+
tslib_1.__metadata("design:paramtypes", [core_1.CacheService,
|
|
129
|
+
core_1.ConfigService,
|
|
130
|
+
core_1.IntegrationFactory])
|
|
131
|
+
], CollectionService);
|
|
132
|
+
//# sourceMappingURL=collection.service.js.map
|