@pvh-afl/core 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 +97 -0
- package/dist/cache/cache.module.d.ts +3 -0
- package/dist/cache/cache.module.d.ts.map +1 -0
- package/dist/cache/cache.module.js +17 -0
- package/dist/cache/cache.module.js.map +1 -0
- package/dist/cache/cache.service.d.ts +38 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +173 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +6 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/common/guards/tenant.guard.d.ts +8 -0
- package/dist/common/guards/tenant.guard.d.ts.map +1 -0
- package/dist/common/guards/tenant.guard.js +44 -0
- package/dist/common/guards/tenant.guard.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +6 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/logger.d.ts +7 -0
- package/dist/common/logger.d.ts.map +1 -0
- package/dist/common/logger.js +28 -0
- package/dist/common/logger.js.map +1 -0
- package/dist/config/config.module.d.ts +3 -0
- package/dist/config/config.module.d.ts.map +1 -0
- package/dist/config/config.module.js +17 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/config.service.d.ts +55 -0
- package/dist/config/config.service.d.ts.map +1 -0
- package/dist/config/config.service.js +212 -0
- package/dist/config/config.service.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/base-integration.service.d.ts +59 -0
- package/dist/integrations/base-integration.service.d.ts.map +1 -0
- package/dist/integrations/base-integration.service.js +227 -0
- package/dist/integrations/base-integration.service.js.map +1 -0
- package/dist/integrations/commerce/commerce.types.d.ts +301 -0
- package/dist/integrations/commerce/commerce.types.d.ts.map +1 -0
- package/dist/integrations/commerce/commerce.types.js +9 -0
- package/dist/integrations/commerce/commerce.types.js.map +1 -0
- package/dist/integrations/commerce/index.d.ts +4 -0
- package/dist/integrations/commerce/index.d.ts.map +1 -0
- package/dist/integrations/commerce/index.js +7 -0
- package/dist/integrations/commerce/index.js.map +1 -0
- package/dist/integrations/commerce/shopify-admin.service.d.ts +35 -0
- package/dist/integrations/commerce/shopify-admin.service.d.ts.map +1 -0
- package/dist/integrations/commerce/shopify-admin.service.js +269 -0
- package/dist/integrations/commerce/shopify-admin.service.js.map +1 -0
- package/dist/integrations/commerce/shopify.service.d.ts +43 -0
- package/dist/integrations/commerce/shopify.service.d.ts.map +1 -0
- package/dist/integrations/commerce/shopify.service.js +735 -0
- package/dist/integrations/commerce/shopify.service.js.map +1 -0
- package/dist/integrations/index.d.ts +9 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +18 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/integration.factory.d.ts +23 -0
- package/dist/integrations/integration.factory.d.ts.map +1 -0
- package/dist/integrations/integration.factory.js +119 -0
- package/dist/integrations/integration.factory.js.map +1 -0
- package/dist/integrations/integration.types.d.ts +80 -0
- package/dist/integrations/integration.types.d.ts.map +1 -0
- package/dist/integrations/integration.types.js +9 -0
- package/dist/integrations/integration.types.js.map +1 -0
- package/dist/integrations/integrations.module.d.ts +3 -0
- package/dist/integrations/integrations.module.d.ts.map +1 -0
- package/dist/integrations/integrations.module.js +46 -0
- package/dist/integrations/integrations.module.js.map +1 -0
- package/dist/integrations/loyalty/capillary-auth.service.d.ts +30 -0
- package/dist/integrations/loyalty/capillary-auth.service.d.ts.map +1 -0
- package/dist/integrations/loyalty/capillary-auth.service.js +112 -0
- package/dist/integrations/loyalty/capillary-auth.service.js.map +1 -0
- package/dist/integrations/loyalty/capillary-coupon.service.d.ts +24 -0
- package/dist/integrations/loyalty/capillary-coupon.service.d.ts.map +1 -0
- package/dist/integrations/loyalty/capillary-coupon.service.js +383 -0
- package/dist/integrations/loyalty/capillary-coupon.service.js.map +1 -0
- package/dist/integrations/loyalty/capillary.types.d.ts +218 -0
- package/dist/integrations/loyalty/capillary.types.d.ts.map +1 -0
- package/dist/integrations/loyalty/capillary.types.js +21 -0
- package/dist/integrations/loyalty/capillary.types.js.map +1 -0
- package/dist/integrations/loyalty/index.d.ts +4 -0
- package/dist/integrations/loyalty/index.d.ts.map +1 -0
- package/dist/integrations/loyalty/index.js +7 -0
- package/dist/integrations/loyalty/index.js.map +1 -0
- package/dist/integrations/oms/index.d.ts +4 -0
- package/dist/integrations/oms/index.d.ts.map +1 -0
- package/dist/integrations/oms/index.js +7 -0
- package/dist/integrations/oms/index.js.map +1 -0
- package/dist/integrations/oms/omuni-auth.service.d.ts +29 -0
- package/dist/integrations/oms/omuni-auth.service.d.ts.map +1 -0
- package/dist/integrations/oms/omuni-auth.service.js +164 -0
- package/dist/integrations/oms/omuni-auth.service.js.map +1 -0
- package/dist/integrations/oms/omuni.service.d.ts +17 -0
- package/dist/integrations/oms/omuni.service.d.ts.map +1 -0
- package/dist/integrations/oms/omuni.service.js +128 -0
- package/dist/integrations/oms/omuni.service.js.map +1 -0
- package/dist/integrations/oms/omuni.types.d.ts +65 -0
- package/dist/integrations/oms/omuni.types.d.ts.map +1 -0
- package/dist/integrations/oms/omuni.types.js +3 -0
- package/dist/integrations/oms/omuni.types.js.map +1 -0
- package/dist/integrations/shopify-theme/index.d.ts +3 -0
- package/dist/integrations/shopify-theme/index.d.ts.map +1 -0
- package/dist/integrations/shopify-theme/index.js +6 -0
- package/dist/integrations/shopify-theme/index.js.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.d.ts +3 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.d.ts.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.js +16 -0
- package/dist/integrations/shopify-theme/shopify-theme.module.js.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.d.ts +35 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.d.ts.map +1 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.js +155 -0
- package/dist/integrations/shopify-theme/shopify-theme.service.js.map +1 -0
- package/dist/queue/index.d.ts +3 -0
- package/dist/queue/index.d.ts.map +1 -0
- package/dist/queue/index.js +8 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/queue.module.d.ts +3 -0
- package/dist/queue/queue.module.d.ts.map +1 -0
- package/dist/queue/queue.module.js +17 -0
- package/dist/queue/queue.module.js.map +1 -0
- package/dist/queue/queue.service.d.ts +20 -0
- package/dist/queue/queue.service.d.ts.map +1 -0
- package/dist/queue/queue.service.js +119 -0
- package/dist/queue/queue.service.js.map +1 -0
- package/dist/theme/header-content.service.d.ts +142 -0
- package/dist/theme/header-content.service.d.ts.map +1 -0
- package/dist/theme/header-content.service.js +626 -0
- package/dist/theme/header-content.service.js.map +1 -0
- package/dist/theme/index.d.ts +5 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +17 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/theme-content.interfaces.d.ts +79 -0
- package/dist/theme/theme-content.interfaces.d.ts.map +1 -0
- package/dist/theme/theme-content.interfaces.js +14 -0
- package/dist/theme/theme-content.interfaces.js.map +1 -0
- package/dist/theme/theme-content.service.d.ts +125 -0
- package/dist/theme/theme-content.service.d.ts.map +1 -0
- package/dist/theme/theme-content.service.js +738 -0
- package/dist/theme/theme-content.service.js.map +1 -0
- package/dist/theme/theme.module.d.ts +46 -0
- package/dist/theme/theme.module.d.ts.map +1 -0
- package/dist/theme/theme.module.js +76 -0
- package/dist/theme/theme.module.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @afl/core
|
|
2
|
+
|
|
3
|
+
Core shared services and utilities for the AFL multi-brand commerce platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @afl/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
This package requires the following peer dependencies:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @nestjs/common @nestjs/core ioredis rxjs
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Modules
|
|
20
|
+
|
|
21
|
+
### CacheModule
|
|
22
|
+
Redis-based caching service for application data.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { CacheModule } from '@afl/core';
|
|
26
|
+
|
|
27
|
+
@Module({
|
|
28
|
+
imports: [CacheModule],
|
|
29
|
+
})
|
|
30
|
+
export class AppModule {}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### ConfigModule
|
|
34
|
+
Brand configuration management with support for multi-brand setups.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { ConfigModule, ConfigService } from '@afl/core';
|
|
38
|
+
|
|
39
|
+
@Module({
|
|
40
|
+
imports: [ConfigModule.forRoot({ brand: 'tommy' })],
|
|
41
|
+
})
|
|
42
|
+
export class AppModule {}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### IntegrationsModule
|
|
46
|
+
Unified integrations for commerce (Shopify), OMS (Omuni), and loyalty (Capillary) services.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { IntegrationsModule, ShopifyService } from '@afl/core';
|
|
50
|
+
|
|
51
|
+
@Module({
|
|
52
|
+
imports: [IntegrationsModule],
|
|
53
|
+
})
|
|
54
|
+
export class AppModule {}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Common Utilities
|
|
58
|
+
Shared utilities including logging, guards, and decorators.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { Logger, TenantGuard, Brand } from '@afl/core';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### QueueModule
|
|
65
|
+
Background job processing with Bull/Redis.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { QueueModule, QueueService } from '@afl/core';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### ThemeModule
|
|
72
|
+
Shopify theme content fetching and processing.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { ThemeModule, ThemeContentService } from '@afl/core';
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## API Reference
|
|
79
|
+
|
|
80
|
+
See the [API documentation](../../docs/API.md) for detailed usage information.
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Build the package
|
|
86
|
+
npm run build
|
|
87
|
+
|
|
88
|
+
# Run tests
|
|
89
|
+
npm test
|
|
90
|
+
|
|
91
|
+
# Run linting
|
|
92
|
+
npm run lint
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
UNLICENSED - Private package
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.module.d.ts","sourceRoot":"","sources":["../../src/cache/cache.module.ts"],"names":[],"mappings":"AAGA,qBAKa,WAAW;CAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const cache_service_1 = require("./cache.service");
|
|
7
|
+
let CacheModule = class CacheModule {
|
|
8
|
+
};
|
|
9
|
+
exports.CacheModule = CacheModule;
|
|
10
|
+
exports.CacheModule = CacheModule = tslib_1.__decorate([
|
|
11
|
+
(0, common_1.Global)(),
|
|
12
|
+
(0, common_1.Module)({
|
|
13
|
+
providers: [cache_service_1.CacheService],
|
|
14
|
+
exports: [cache_service_1.CacheService],
|
|
15
|
+
})
|
|
16
|
+
], CacheModule);
|
|
17
|
+
//# sourceMappingURL=cache.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.module.js","sourceRoot":"","sources":["../../src/cache/cache.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,mDAA+C;AAOxC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;KACxB,CAAC;GACW,WAAW,CAAG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '../config/config.service';
|
|
3
|
+
export interface CacheResult<T> {
|
|
4
|
+
data: T;
|
|
5
|
+
isStale: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class CacheService implements OnModuleInit, OnModuleDestroy {
|
|
8
|
+
private readonly configService;
|
|
9
|
+
private redis;
|
|
10
|
+
constructor(configService: ConfigService);
|
|
11
|
+
onModuleInit(): void;
|
|
12
|
+
onModuleDestroy(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Get cached data with stale-while-revalidate semantics
|
|
15
|
+
*/
|
|
16
|
+
get<T>(key: string): Promise<CacheResult<T> | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Set cached data with TTL and stale TTL
|
|
19
|
+
* @param key Cache key
|
|
20
|
+
* @param data Data to cache
|
|
21
|
+
* @param ttlSeconds Total TTL in seconds (default: 300 = 5 min)
|
|
22
|
+
* @param staleTTLSeconds Time until data becomes stale (default: 60 = 1 min)
|
|
23
|
+
*/
|
|
24
|
+
set<T>(key: string, data: T, ttlSeconds?: number, staleTTLSeconds?: number): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Mark all keys matching pattern as stale (for webhook invalidation)
|
|
27
|
+
*/
|
|
28
|
+
markStale(pattern: string): Promise<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete specific key
|
|
31
|
+
*/
|
|
32
|
+
delete(key: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete all keys matching pattern
|
|
35
|
+
*/
|
|
36
|
+
deletePattern(pattern: string): Promise<number>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=cache.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.service.d.ts","sourceRoot":"","sources":["../../src/cache/cache.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASzD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBACa,YAAa,YAAW,YAAY,EAAE,eAAe;IAGpD,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,OAAO,CAAC,KAAK,CAAsB;gBAEN,aAAa,EAAE,aAAa;IAEzD,YAAY;IAoBN,eAAe;IAMrB;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAmCzD;;;;;;OAMG;IACG,GAAG,CAAC,CAAC,EACT,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,CAAC,EACP,UAAU,SAAM,EAChB,eAAe,SAAK,GACnB,OAAO,CAAC,IAAI,CAAC;IAoBhB;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCjD;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxC;;OAEG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAkBtD"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CacheService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const ioredis_1 = require("ioredis");
|
|
7
|
+
const config_service_1 = require("../config/config.service");
|
|
8
|
+
const logger_1 = require("../common/logger");
|
|
9
|
+
let CacheService = class CacheService {
|
|
10
|
+
configService;
|
|
11
|
+
redis = null;
|
|
12
|
+
constructor(configService) {
|
|
13
|
+
this.configService = configService;
|
|
14
|
+
}
|
|
15
|
+
onModuleInit() {
|
|
16
|
+
const redisUrl = this.configService.getRedisUrl();
|
|
17
|
+
try {
|
|
18
|
+
this.redis = new ioredis_1.Redis(redisUrl);
|
|
19
|
+
this.redis.on('connect', () => {
|
|
20
|
+
logger_1.logger.info('Redis connected');
|
|
21
|
+
});
|
|
22
|
+
this.redis.on('error', (err) => {
|
|
23
|
+
logger_1.logger.error('Redis error', { error: err.message });
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
logger_1.logger.warn('Redis not available, caching disabled', {
|
|
28
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async onModuleDestroy() {
|
|
33
|
+
if (this.redis) {
|
|
34
|
+
await this.redis.quit();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get cached data with stale-while-revalidate semantics
|
|
39
|
+
*/
|
|
40
|
+
async get(key) {
|
|
41
|
+
if (!this.redis) {
|
|
42
|
+
logger_1.logger.warn('Redis not connected, returning null', { key });
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const raw = await this.redis.get(key);
|
|
47
|
+
if (!raw) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const cached = JSON.parse(raw);
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
// Check if completely expired
|
|
53
|
+
if (now > cached.expiresAt) {
|
|
54
|
+
await this.redis.del(key);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
// Return data with stale flag
|
|
58
|
+
return {
|
|
59
|
+
data: cached.data,
|
|
60
|
+
isStale: now > cached.staleAt,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
logger_1.logger.warn('Cache get error', {
|
|
65
|
+
key,
|
|
66
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
67
|
+
});
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Set cached data with TTL and stale TTL
|
|
73
|
+
* @param key Cache key
|
|
74
|
+
* @param data Data to cache
|
|
75
|
+
* @param ttlSeconds Total TTL in seconds (default: 300 = 5 min)
|
|
76
|
+
* @param staleTTLSeconds Time until data becomes stale (default: 60 = 1 min)
|
|
77
|
+
*/
|
|
78
|
+
async set(key, data, ttlSeconds = 300, staleTTLSeconds = 60) {
|
|
79
|
+
if (!this.redis)
|
|
80
|
+
return;
|
|
81
|
+
try {
|
|
82
|
+
const now = Date.now();
|
|
83
|
+
const cached = {
|
|
84
|
+
data,
|
|
85
|
+
staleAt: now + staleTTLSeconds * 1000,
|
|
86
|
+
expiresAt: now + ttlSeconds * 1000,
|
|
87
|
+
};
|
|
88
|
+
await this.redis.set(key, JSON.stringify(cached), 'EX', ttlSeconds);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
logger_1.logger.warn('Cache set error', {
|
|
92
|
+
key,
|
|
93
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Mark all keys matching pattern as stale (for webhook invalidation)
|
|
99
|
+
*/
|
|
100
|
+
async markStale(pattern) {
|
|
101
|
+
if (!this.redis)
|
|
102
|
+
return 0;
|
|
103
|
+
try {
|
|
104
|
+
const keys = await this.redis.keys(pattern);
|
|
105
|
+
let count = 0;
|
|
106
|
+
for (const key of keys) {
|
|
107
|
+
const raw = await this.redis.get(key);
|
|
108
|
+
if (raw) {
|
|
109
|
+
const cached = JSON.parse(raw);
|
|
110
|
+
cached.staleAt = Date.now(); // Mark as stale now
|
|
111
|
+
// Keep the original TTL
|
|
112
|
+
const ttl = await this.redis.ttl(key);
|
|
113
|
+
if (ttl > 0) {
|
|
114
|
+
await this.redis.set(key, JSON.stringify(cached), 'EX', ttl);
|
|
115
|
+
count++;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return count;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
logger_1.logger.warn('Cache markStale error', {
|
|
123
|
+
pattern,
|
|
124
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
125
|
+
});
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Delete specific key
|
|
131
|
+
*/
|
|
132
|
+
async delete(key) {
|
|
133
|
+
if (!this.redis)
|
|
134
|
+
return;
|
|
135
|
+
try {
|
|
136
|
+
await this.redis.del(key);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
logger_1.logger.warn('Cache delete error', {
|
|
140
|
+
key,
|
|
141
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Delete all keys matching pattern
|
|
147
|
+
*/
|
|
148
|
+
async deletePattern(pattern) {
|
|
149
|
+
if (!this.redis)
|
|
150
|
+
return 0;
|
|
151
|
+
try {
|
|
152
|
+
const keys = await this.redis.keys(pattern);
|
|
153
|
+
if (keys.length > 0) {
|
|
154
|
+
await this.redis.del(...keys);
|
|
155
|
+
}
|
|
156
|
+
logger_1.logger.info('Deleted keys', { pattern, count: keys.length });
|
|
157
|
+
return keys.length;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
logger_1.logger.warn('Cache deletePattern error', {
|
|
161
|
+
pattern,
|
|
162
|
+
error: error instanceof Error ? error.message : 'Unknown',
|
|
163
|
+
});
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
exports.CacheService = CacheService;
|
|
169
|
+
exports.CacheService = CacheService = tslib_1.__decorate([
|
|
170
|
+
(0, common_1.Injectable)(),
|
|
171
|
+
tslib_1.__metadata("design:paramtypes", [config_service_1.ConfigService])
|
|
172
|
+
], CacheService);
|
|
173
|
+
//# sourceMappingURL=cache.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.service.js","sourceRoot":"","sources":["../../src/cache/cache.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA2E;AAC3E,qCAAgC;AAChC,6DAAyD;AACzD,6CAA0C;AAcnC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGM;IAFrB,KAAK,GAAiB,IAAI,CAAC;IAEnC,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAE7D,YAAY;QACV,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;QAElD,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,eAAK,CAAC,QAAQ,CAAC,CAAC;YAEjC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;gBAC5B,eAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACjC,CAAC,CAA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ings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./cache.module"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./cache.service"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cache/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,0DAAgC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '../../config/config.service';
|
|
3
|
+
export declare class TenantGuard implements CanActivate {
|
|
4
|
+
private readonly configService;
|
|
5
|
+
constructor(configService: ConfigService);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=tenant.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.guard.d.ts","sourceRoot":"","sources":["../../../src/common/guards/tenant.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,gBAAgB,EAEjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBACa,WAAY,YAAW,WAAW;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,aAAa;IAEzD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;CAiChD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TenantGuard = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
7
|
+
const config_service_1 = require("../../config/config.service");
|
|
8
|
+
let TenantGuard = class TenantGuard {
|
|
9
|
+
configService;
|
|
10
|
+
constructor(configService) {
|
|
11
|
+
this.configService = configService;
|
|
12
|
+
}
|
|
13
|
+
canActivate(context) {
|
|
14
|
+
const ctx = graphql_1.GqlExecutionContext.create(context);
|
|
15
|
+
const { req } = ctx.getContext();
|
|
16
|
+
// Single-brand mode: use active brand from env, ignore header
|
|
17
|
+
if (this.configService.isSingleBrandMode()) {
|
|
18
|
+
const activeBrand = this.configService.getActiveBrand();
|
|
19
|
+
const brandConfig = this.configService.getActiveBrandConfig();
|
|
20
|
+
req.brand = activeBrand;
|
|
21
|
+
req.brandConfig = brandConfig;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// Multi-brand mode: require header
|
|
25
|
+
const brandSlug = req.headers['x-brand-slug'];
|
|
26
|
+
if (!brandSlug) {
|
|
27
|
+
throw new common_1.BadRequestException('X-Brand-Slug header is required');
|
|
28
|
+
}
|
|
29
|
+
const brandConfig = this.configService.getBrand(brandSlug);
|
|
30
|
+
if (!brandConfig) {
|
|
31
|
+
throw new common_1.BadRequestException(`Unknown brand: ${brandSlug}`);
|
|
32
|
+
}
|
|
33
|
+
// Attach brand to request context for use in resolvers
|
|
34
|
+
req.brand = brandSlug;
|
|
35
|
+
req.brandConfig = brandConfig;
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.TenantGuard = TenantGuard;
|
|
40
|
+
exports.TenantGuard = TenantGuard = tslib_1.__decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
tslib_1.__metadata("design:paramtypes", [config_service_1.ConfigService])
|
|
43
|
+
], TenantGuard);
|
|
44
|
+
//# sourceMappingURL=tenant.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AAC;IACd,CAAC;CACF,CAAA;AApCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;6CAEiC,8BAAa;GAD9C,WAAW,CAoCvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./logger"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./guards/tenant.guard"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,gEAAsC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function log(level: 'info' | 'warn' | 'error', message: string, meta?: Record<string, unknown>): void;
|
|
2
|
+
export declare const logger: {
|
|
3
|
+
info: (message: string, meta?: Record<string, unknown>) => void;
|
|
4
|
+
warn: (message: string, meta?: Record<string, unknown>) => void;
|
|
5
|
+
error: (message: string, meta?: Record<string, unknown>) => void;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAiBpG;AAED,eAAO,MAAM,MAAM;oBACD,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBACtC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;qBACrC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CACxD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logger = void 0;
|
|
4
|
+
exports.log = log;
|
|
5
|
+
function log(level, message, meta) {
|
|
6
|
+
const entry = {
|
|
7
|
+
timestamp: new Date().toISOString(),
|
|
8
|
+
level,
|
|
9
|
+
message,
|
|
10
|
+
...meta,
|
|
11
|
+
};
|
|
12
|
+
const output = JSON.stringify(entry);
|
|
13
|
+
if (level === 'error') {
|
|
14
|
+
console.error(output);
|
|
15
|
+
}
|
|
16
|
+
else if (level === 'warn') {
|
|
17
|
+
console.warn(output);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(output);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.logger = {
|
|
24
|
+
info: (message, meta) => log('info', message, meta),
|
|
25
|
+
warn: (message, meta) => log('warn', message, meta),
|
|
26
|
+
error: (message, meta) => log('error', message, meta),
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":";;;AAAA,kBAiBC;AAjBD,SAAgB,GAAG,CAAC,KAAgC,EAAE,OAAe,EAAE,IAA8B;IACnG,MAAM,KAAK,GAAG;QACZ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,KAAK;QACL,OAAO;QACP,GAAG,IAAI;KACR,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAErC,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;SAAM,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;AACH,CAAC;AAEY,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;IACrF,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;IACrF,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;CACxF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.module.d.ts","sourceRoot":"","sources":["../../src/config/config.module.ts"],"names":[],"mappings":"AAGA,qBAKa,YAAY;CAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const config_service_1 = require("./config.service");
|
|
7
|
+
let ConfigModule = class ConfigModule {
|
|
8
|
+
};
|
|
9
|
+
exports.ConfigModule = ConfigModule;
|
|
10
|
+
exports.ConfigModule = ConfigModule = tslib_1.__decorate([
|
|
11
|
+
(0, common_1.Global)(),
|
|
12
|
+
(0, common_1.Module)({
|
|
13
|
+
providers: [config_service_1.ConfigService],
|
|
14
|
+
exports: [config_service_1.ConfigService],
|
|
15
|
+
})
|
|
16
|
+
], ConfigModule);
|
|
17
|
+
//# sourceMappingURL=config.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.module.js","sourceRoot":"","sources":["../../src/config/config.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,qDAAiD;AAO1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IALxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { BrandIntegrationConfig } from '../integrations/integration.types';
|
|
3
|
+
export interface FeatureFlags {
|
|
4
|
+
[key: string]: boolean | string | number | FeatureFlags;
|
|
5
|
+
}
|
|
6
|
+
export interface BrandConfig {
|
|
7
|
+
slug: string;
|
|
8
|
+
integrations?: Record<string, BrandIntegrationConfig>;
|
|
9
|
+
cache?: {
|
|
10
|
+
defaultTTL?: number;
|
|
11
|
+
staleTTL?: number;
|
|
12
|
+
landingPage?: {
|
|
13
|
+
staleTTL?: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
features?: FeatureFlags;
|
|
17
|
+
}
|
|
18
|
+
export declare class ConfigService implements OnModuleInit {
|
|
19
|
+
private brands;
|
|
20
|
+
private activeBrand;
|
|
21
|
+
private singleBrandMode;
|
|
22
|
+
private brandConfigPath;
|
|
23
|
+
/**
|
|
24
|
+
* Set custom brand config path (for brand repos)
|
|
25
|
+
*/
|
|
26
|
+
setBrandConfigPath(configPath: string): void;
|
|
27
|
+
onModuleInit(): void;
|
|
28
|
+
private initializeMode;
|
|
29
|
+
private loadBrands;
|
|
30
|
+
private loadBrandsFromDirectory;
|
|
31
|
+
private loadFromEnv;
|
|
32
|
+
private resolveEnvVars;
|
|
33
|
+
getBrand(slug: string): BrandConfig | undefined;
|
|
34
|
+
getAllBrands(): string[];
|
|
35
|
+
isSingleBrandMode(): boolean;
|
|
36
|
+
getActiveBrand(): string | null;
|
|
37
|
+
getActiveBrandConfig(): BrandConfig | undefined;
|
|
38
|
+
isFeatureEnabled(brand: string, featurePath: string): boolean;
|
|
39
|
+
getFeature(brand: string, featurePath: string): unknown;
|
|
40
|
+
getShopifyAdminToken(brand?: string): string | undefined;
|
|
41
|
+
getShopifyThemeId(brand?: string): string | undefined;
|
|
42
|
+
getShopifyStoreDomain(brand?: string): string | undefined;
|
|
43
|
+
getShopifyGraphqlUrl(brand?: string): string | undefined;
|
|
44
|
+
getShopifyStorefrontToken(brand?: string): string | undefined;
|
|
45
|
+
getRedisUrl(): string;
|
|
46
|
+
getCacheTTL(brand?: string): {
|
|
47
|
+
defaultTTL: number;
|
|
48
|
+
staleTTL: number;
|
|
49
|
+
};
|
|
50
|
+
getLandingPageCacheTTL(brand?: string): {
|
|
51
|
+
defaultTTL: number;
|
|
52
|
+
staleTTL: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=config.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.service.d.ts","sourceRoot":"","sources":["../../src/config/config.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;CACzD;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACtD,KAAK,CAAC,EAAE;QACN,UAAU,CAA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