@hamjimin/xplat-back 0.1.0 → 0.3.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 +0 -1
- package/dist/cli/init.js +36 -0
- package/dist/cli/templates/api_code.ts.example +70 -0
- package/dist/cli/templates/constants.ts.example +113 -0
- package/dist/core/XplatSystem.d.ts +44 -0
- package/dist/core/XplatSystem.js +55 -0
- package/dist/index.d.ts +22 -3
- package/dist/index.js +40 -7
- package/dist/modules/app/app-factory.d.ts +12 -0
- package/dist/modules/app/app-factory.js +125 -0
- package/dist/modules/app/index.d.ts +11 -0
- package/dist/modules/app/index.js +16 -0
- package/dist/modules/auth/index.d.ts +36 -0
- package/dist/modules/auth/index.js +61 -0
- package/dist/modules/auth/jwt.d.ts +40 -0
- package/dist/modules/auth/jwt.js +49 -0
- package/dist/modules/auth/middleware.d.ts +20 -0
- package/dist/modules/auth/middleware.js +88 -0
- package/dist/modules/constants/api-code.d.ts +15 -0
- package/dist/modules/constants/api-code.js +50 -0
- package/dist/modules/constants/index.d.ts +30 -0
- package/dist/modules/constants/index.js +46 -0
- package/dist/modules/middleware/error-handler.d.ts +9 -0
- package/dist/modules/middleware/error-handler.js +31 -0
- package/dist/modules/middleware/index.d.ts +30 -0
- package/dist/modules/middleware/index.js +48 -0
- package/dist/modules/middleware/logger.d.ts +11 -0
- package/dist/modules/middleware/logger.js +43 -0
- package/dist/modules/middleware/validator.d.ts +13 -0
- package/dist/modules/middleware/validator.js +81 -0
- package/dist/modules/orm/index.d.ts +30 -0
- package/dist/modules/orm/index.js +46 -0
- package/dist/modules/orm/query-builder.d.ts +68 -0
- package/dist/modules/orm/query-builder.js +238 -0
- package/dist/modules/payment/index.d.ts +43 -0
- package/dist/modules/payment/index.js +92 -0
- package/dist/modules/payment/providers/kakaopay.d.ts +17 -0
- package/dist/modules/payment/providers/kakaopay.js +51 -0
- package/dist/modules/payment/providers/toss.d.ts +15 -0
- package/dist/modules/payment/providers/toss.js +54 -0
- package/dist/modules/payment/types.d.ts +46 -0
- package/dist/modules/payment/types.js +2 -0
- package/dist/modules/router/index.d.ts +10 -0
- package/dist/modules/router/index.js +16 -0
- package/dist/modules/router/route-factory.d.ts +10 -0
- package/dist/modules/router/route-factory.js +72 -0
- package/dist/modules/shipping/index.d.ts +19 -0
- package/dist/modules/shipping/index.js +66 -0
- package/dist/modules/shipping/providers/cj.d.ts +14 -0
- package/dist/modules/shipping/providers/cj.js +35 -0
- package/dist/modules/shipping/providers/cvs.d.ts +14 -0
- package/dist/modules/shipping/providers/cvs.js +35 -0
- package/dist/modules/shipping/providers/logen.d.ts +13 -0
- package/dist/modules/shipping/providers/logen.js +35 -0
- package/dist/modules/shipping/types.d.ts +54 -0
- package/dist/modules/shipping/types.js +2 -0
- package/dist/modules/storage/index.d.ts +81 -0
- package/dist/modules/storage/index.js +86 -0
- package/dist/modules/storage/s3.d.ts +80 -0
- package/dist/modules/storage/s3.js +133 -0
- package/dist/modules/utils/date.d.ts +37 -0
- package/dist/modules/utils/date.js +72 -0
- package/dist/modules/utils/index.d.ts +44 -0
- package/dist/modules/utils/index.js +139 -0
- package/dist/modules/utils/lodash.d.ts +107 -0
- package/dist/modules/utils/lodash.js +154 -0
- package/dist/modules/utils/password.d.ts +31 -0
- package/dist/modules/utils/password.js +102 -0
- package/dist/modules/utils/pk.d.ts +18 -0
- package/dist/modules/utils/pk.js +41 -0
- package/dist/modules/utils/response.d.ts +20 -0
- package/dist/modules/utils/response.js +87 -0
- package/dist/modules/utils/validation.d.ts +50 -0
- package/dist/modules/utils/validation.js +90 -0
- package/dist/types/index.d.ts +26 -0
- package/package.json +14 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface PaymentRequestParams {
|
|
2
|
+
orderId: string;
|
|
3
|
+
amount: number;
|
|
4
|
+
customerName: string;
|
|
5
|
+
customerEmail?: string;
|
|
6
|
+
customerPhone?: string;
|
|
7
|
+
successUrl?: string;
|
|
8
|
+
failUrl?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
currency?: string;
|
|
11
|
+
method?: string;
|
|
12
|
+
metadata?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
export interface PaymentResponse {
|
|
15
|
+
provider: string;
|
|
16
|
+
paymentKey?: string;
|
|
17
|
+
checkoutUrl?: string;
|
|
18
|
+
raw?: any;
|
|
19
|
+
}
|
|
20
|
+
export interface PaymentConfirmParams {
|
|
21
|
+
paymentKey: string;
|
|
22
|
+
orderId: string;
|
|
23
|
+
amount: number;
|
|
24
|
+
}
|
|
25
|
+
export interface PaymentCancelParams {
|
|
26
|
+
paymentKey: string;
|
|
27
|
+
cancelReason: string;
|
|
28
|
+
cancelAmount?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface PaymentDetails {
|
|
31
|
+
provider: string;
|
|
32
|
+
paymentKey: string;
|
|
33
|
+
status: 'requested' | 'authorized' | 'paid' | 'failed' | 'canceled';
|
|
34
|
+
amount: number;
|
|
35
|
+
raw?: any;
|
|
36
|
+
}
|
|
37
|
+
export interface PaymentProviderConfig {
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
40
|
+
export interface PaymentProvider {
|
|
41
|
+
name: string;
|
|
42
|
+
requestPayment(params: PaymentRequestParams): Promise<PaymentResponse>;
|
|
43
|
+
confirmPayment(params: PaymentConfirmParams): Promise<PaymentDetails>;
|
|
44
|
+
cancelPayment(params: PaymentCancelParams): Promise<PaymentDetails>;
|
|
45
|
+
getPayment(paymentKey: string): Promise<PaymentDetails>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouterModule = void 0;
|
|
4
|
+
const route_factory_1 = require("./route-factory");
|
|
5
|
+
/**
|
|
6
|
+
* RouterModule - 라우터 생성 모듈
|
|
7
|
+
*/
|
|
8
|
+
class RouterModule {
|
|
9
|
+
/**
|
|
10
|
+
* 파일 기반 라우터 생성
|
|
11
|
+
*/
|
|
12
|
+
create(directory) {
|
|
13
|
+
return (0, route_factory_1.createRouter)(directory);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RouterModule = RouterModule;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* 파일 경로 기준 동적 라우터 생성
|
|
4
|
+
*
|
|
5
|
+
* 디렉토리 구조를 API endpoint로 자동 매핑합니다.
|
|
6
|
+
*
|
|
7
|
+
* @param directory - 라우트 파일들이 위치한 루트 디렉토리
|
|
8
|
+
* @returns Express Router 인스턴스
|
|
9
|
+
*/
|
|
10
|
+
export declare function createRouter(directory: string): express.Router;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.createRouter = createRouter;
|
|
40
|
+
const express_1 = __importDefault(require("express"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
/**
|
|
44
|
+
* 파일 경로 기준 동적 라우터 생성
|
|
45
|
+
*
|
|
46
|
+
* 디렉토리 구조를 API endpoint로 자동 매핑합니다.
|
|
47
|
+
*
|
|
48
|
+
* @param directory - 라우트 파일들이 위치한 루트 디렉토리
|
|
49
|
+
* @returns Express Router 인스턴스
|
|
50
|
+
*/
|
|
51
|
+
function createRouter(directory) {
|
|
52
|
+
const router = express_1.default.Router();
|
|
53
|
+
const files = fs.readdirSync(directory);
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
const filePath = path.join(directory, file);
|
|
56
|
+
if (fs.statSync(filePath).isDirectory()) {
|
|
57
|
+
// 디렉토리인 경우 재귀적으로 라우터 생성
|
|
58
|
+
const subRouter = createRouter(filePath);
|
|
59
|
+
router.use(`/${file}`, subRouter);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// 파일인 경우 라우터 생성
|
|
63
|
+
if (file.endsWith('.ts') || file.endsWith('.js')) {
|
|
64
|
+
const routePath = `/${file.replace('.ts', '').replace('.js', '')}`;
|
|
65
|
+
const required = require(filePath);
|
|
66
|
+
const routeModule = required.default || required;
|
|
67
|
+
router.use(routePath, routeModule);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return router;
|
|
72
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ShippingProvider, ShippingFeeParams, ShippingFee, CreateLabelParams, ShippingLabel, TrackingInfo } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* ShippingModule - 배송 프로바이더 레지스트리
|
|
4
|
+
*/
|
|
5
|
+
export declare class ShippingModule {
|
|
6
|
+
private providers;
|
|
7
|
+
private defaultProvider;
|
|
8
|
+
registerProvider(provider: ShippingProvider, setAsDefault?: boolean): void;
|
|
9
|
+
listProviders(): string[];
|
|
10
|
+
setDefaultProvider(name: string): void;
|
|
11
|
+
private getProvider;
|
|
12
|
+
calculateFee(params: ShippingFeeParams, providerName?: string): Promise<ShippingFee>;
|
|
13
|
+
createLabel(params: CreateLabelParams, providerName?: string): Promise<ShippingLabel>;
|
|
14
|
+
track(trackingNumber: string, providerName?: string): Promise<TrackingInfo>;
|
|
15
|
+
}
|
|
16
|
+
export * from './types';
|
|
17
|
+
export * from './providers/cj';
|
|
18
|
+
export * from './providers/logen';
|
|
19
|
+
export * from './providers/cvs';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ShippingModule = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* ShippingModule - 배송 프로바이더 레지스트리
|
|
20
|
+
*/
|
|
21
|
+
class ShippingModule {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.providers = new Map();
|
|
24
|
+
this.defaultProvider = null;
|
|
25
|
+
}
|
|
26
|
+
registerProvider(provider, setAsDefault = false) {
|
|
27
|
+
this.providers.set(provider.name, provider);
|
|
28
|
+
if (setAsDefault || !this.defaultProvider) {
|
|
29
|
+
this.defaultProvider = provider.name;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
listProviders() {
|
|
33
|
+
return Array.from(this.providers.keys());
|
|
34
|
+
}
|
|
35
|
+
setDefaultProvider(name) {
|
|
36
|
+
if (!this.providers.has(name)) {
|
|
37
|
+
throw new Error(`Shipping provider "${name}" not registered`);
|
|
38
|
+
}
|
|
39
|
+
this.defaultProvider = name;
|
|
40
|
+
}
|
|
41
|
+
getProvider(name) {
|
|
42
|
+
const target = name || this.defaultProvider;
|
|
43
|
+
if (!target) {
|
|
44
|
+
throw new Error('No shipping provider registered');
|
|
45
|
+
}
|
|
46
|
+
const provider = this.providers.get(target);
|
|
47
|
+
if (!provider) {
|
|
48
|
+
throw new Error(`Shipping provider "${target}" not found`);
|
|
49
|
+
}
|
|
50
|
+
return provider;
|
|
51
|
+
}
|
|
52
|
+
async calculateFee(params, providerName) {
|
|
53
|
+
return this.getProvider(providerName).calculateFee(params);
|
|
54
|
+
}
|
|
55
|
+
async createLabel(params, providerName) {
|
|
56
|
+
return this.getProvider(providerName).createLabel(params);
|
|
57
|
+
}
|
|
58
|
+
async track(trackingNumber, providerName) {
|
|
59
|
+
return this.getProvider(providerName).track(trackingNumber);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ShippingModule = ShippingModule;
|
|
63
|
+
__exportStar(require("./types"), exports);
|
|
64
|
+
__exportStar(require("./providers/cj"), exports);
|
|
65
|
+
__exportStar(require("./providers/logen"), exports);
|
|
66
|
+
__exportStar(require("./providers/cvs"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ShippingProvider, ShippingFeeParams, ShippingFee, CreateLabelParams, ShippingLabel, TrackingInfo } from '../types';
|
|
2
|
+
export interface CJConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
customerCode?: string;
|
|
5
|
+
defaultCurrency?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class CJLogisticsProvider implements ShippingProvider {
|
|
8
|
+
readonly name = "cj";
|
|
9
|
+
private readonly config;
|
|
10
|
+
constructor(config: CJConfig);
|
|
11
|
+
calculateFee(params: ShippingFeeParams): Promise<ShippingFee>;
|
|
12
|
+
createLabel(params: CreateLabelParams): Promise<ShippingLabel>;
|
|
13
|
+
track(trackingNumber: string): Promise<TrackingInfo>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CJLogisticsProvider = void 0;
|
|
4
|
+
class CJLogisticsProvider {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.name = 'cj';
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async calculateFee(params) {
|
|
10
|
+
return {
|
|
11
|
+
provider: this.name,
|
|
12
|
+
amount: 3500,
|
|
13
|
+
currency: this.config.defaultCurrency || 'KRW',
|
|
14
|
+
estimatedDays: 2,
|
|
15
|
+
raw: params,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async createLabel(params) {
|
|
19
|
+
return {
|
|
20
|
+
provider: this.name,
|
|
21
|
+
trackingNumber: `CJ-${params.orderId}`,
|
|
22
|
+
labelUrl: '',
|
|
23
|
+
raw: params,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async track(trackingNumber) {
|
|
27
|
+
return {
|
|
28
|
+
provider: this.name,
|
|
29
|
+
trackingNumber,
|
|
30
|
+
status: 'in_transit',
|
|
31
|
+
history: [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.CJLogisticsProvider = CJLogisticsProvider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ShippingProvider, ShippingFeeParams, ShippingFee, CreateLabelParams, ShippingLabel, TrackingInfo } from '../types';
|
|
2
|
+
export interface CvsConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
carrier?: 'cvsnet' | 'easycv';
|
|
5
|
+
defaultCurrency?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class CvsProvider implements ShippingProvider {
|
|
8
|
+
readonly name = "cvs";
|
|
9
|
+
private readonly config;
|
|
10
|
+
constructor(config: CvsConfig);
|
|
11
|
+
calculateFee(params: ShippingFeeParams): Promise<ShippingFee>;
|
|
12
|
+
createLabel(params: CreateLabelParams): Promise<ShippingLabel>;
|
|
13
|
+
track(trackingNumber: string): Promise<TrackingInfo>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CvsProvider = void 0;
|
|
4
|
+
class CvsProvider {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.name = 'cvs';
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async calculateFee(params) {
|
|
10
|
+
return {
|
|
11
|
+
provider: this.name,
|
|
12
|
+
amount: 2700,
|
|
13
|
+
currency: this.config.defaultCurrency || 'KRW',
|
|
14
|
+
estimatedDays: 3,
|
|
15
|
+
raw: params,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async createLabel(params) {
|
|
19
|
+
return {
|
|
20
|
+
provider: this.name,
|
|
21
|
+
trackingNumber: `CVS-${params.orderId}`,
|
|
22
|
+
labelUrl: '',
|
|
23
|
+
raw: params,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async track(trackingNumber) {
|
|
27
|
+
return {
|
|
28
|
+
provider: this.name,
|
|
29
|
+
trackingNumber,
|
|
30
|
+
status: 'in_transit',
|
|
31
|
+
history: [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.CvsProvider = CvsProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ShippingProvider, ShippingFeeParams, ShippingFee, CreateLabelParams, ShippingLabel, TrackingInfo } from '../types';
|
|
2
|
+
export interface LogenConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
defaultCurrency?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class LogenProvider implements ShippingProvider {
|
|
7
|
+
readonly name = "logen";
|
|
8
|
+
private readonly config;
|
|
9
|
+
constructor(config: LogenConfig);
|
|
10
|
+
calculateFee(params: ShippingFeeParams): Promise<ShippingFee>;
|
|
11
|
+
createLabel(params: CreateLabelParams): Promise<ShippingLabel>;
|
|
12
|
+
track(trackingNumber: string): Promise<TrackingInfo>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogenProvider = void 0;
|
|
4
|
+
class LogenProvider {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.name = 'logen';
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async calculateFee(params) {
|
|
10
|
+
return {
|
|
11
|
+
provider: this.name,
|
|
12
|
+
amount: 3200,
|
|
13
|
+
currency: this.config.defaultCurrency || 'KRW',
|
|
14
|
+
estimatedDays: 2,
|
|
15
|
+
raw: params,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async createLabel(params) {
|
|
19
|
+
return {
|
|
20
|
+
provider: this.name,
|
|
21
|
+
trackingNumber: `LOGEN-${params.orderId}`,
|
|
22
|
+
labelUrl: '',
|
|
23
|
+
raw: params,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async track(trackingNumber) {
|
|
27
|
+
return {
|
|
28
|
+
provider: this.name,
|
|
29
|
+
trackingNumber,
|
|
30
|
+
status: 'in_transit',
|
|
31
|
+
history: [],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.LogenProvider = LogenProvider;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface ShippingFeeParams {
|
|
2
|
+
destinationZip: string;
|
|
3
|
+
weight?: number;
|
|
4
|
+
volumeWeight?: number;
|
|
5
|
+
quantity?: number;
|
|
6
|
+
options?: Record<string, any>;
|
|
7
|
+
}
|
|
8
|
+
export interface ShippingFee {
|
|
9
|
+
provider: string;
|
|
10
|
+
amount: number;
|
|
11
|
+
currency?: string;
|
|
12
|
+
estimatedDays?: number;
|
|
13
|
+
raw?: any;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateLabelParams {
|
|
16
|
+
orderId: string;
|
|
17
|
+
toName: string;
|
|
18
|
+
toPhone: string;
|
|
19
|
+
toAddress: string;
|
|
20
|
+
toZip: string;
|
|
21
|
+
fromName?: string;
|
|
22
|
+
fromPhone?: string;
|
|
23
|
+
fromAddress?: string;
|
|
24
|
+
fromZip?: string;
|
|
25
|
+
items?: Array<{
|
|
26
|
+
name: string;
|
|
27
|
+
quantity: number;
|
|
28
|
+
weight?: number;
|
|
29
|
+
}>;
|
|
30
|
+
memo?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ShippingLabel {
|
|
33
|
+
provider: string;
|
|
34
|
+
trackingNumber: string;
|
|
35
|
+
labelUrl?: string;
|
|
36
|
+
raw?: any;
|
|
37
|
+
}
|
|
38
|
+
export interface TrackingInfo {
|
|
39
|
+
provider: string;
|
|
40
|
+
trackingNumber: string;
|
|
41
|
+
status: string;
|
|
42
|
+
history?: Array<{
|
|
43
|
+
status: string;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
location?: string;
|
|
46
|
+
}>;
|
|
47
|
+
raw?: any;
|
|
48
|
+
}
|
|
49
|
+
export interface ShippingProvider {
|
|
50
|
+
name: string;
|
|
51
|
+
calculateFee(params: ShippingFeeParams): Promise<ShippingFee>;
|
|
52
|
+
createLabel(params: CreateLabelParams): Promise<ShippingLabel>;
|
|
53
|
+
track(trackingNumber: string): Promise<TrackingInfo>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { S3Config } from './s3';
|
|
2
|
+
/**
|
|
3
|
+
* StorageModule - 스토리지 관리 모듈
|
|
4
|
+
*/
|
|
5
|
+
export declare class StorageModule {
|
|
6
|
+
private s3Client;
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config?: S3Config);
|
|
9
|
+
/**
|
|
10
|
+
* S3 클라이언트 가져오기 (싱글톤)
|
|
11
|
+
*/
|
|
12
|
+
private getS3Client;
|
|
13
|
+
/**
|
|
14
|
+
* S3 클라이언트 재설정
|
|
15
|
+
*/
|
|
16
|
+
setConfig(config: S3Config): void;
|
|
17
|
+
/**
|
|
18
|
+
* 날짜 기반 접두사 생성
|
|
19
|
+
*/
|
|
20
|
+
getDatePrefix(date?: Date): string;
|
|
21
|
+
/**
|
|
22
|
+
* S3 키 생성
|
|
23
|
+
*/
|
|
24
|
+
buildKey(basePrefix: string, fileName: string, date?: Date): string;
|
|
25
|
+
/**
|
|
26
|
+
* 파일 업로드
|
|
27
|
+
*/
|
|
28
|
+
upload(params: {
|
|
29
|
+
key: string;
|
|
30
|
+
body: Buffer | string;
|
|
31
|
+
bucket: string;
|
|
32
|
+
contentType?: string;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
bucket: string;
|
|
35
|
+
key: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* PDF 버퍼 업로드
|
|
39
|
+
*/
|
|
40
|
+
uploadPdf(params: {
|
|
41
|
+
basePrefix: string;
|
|
42
|
+
fileName: string;
|
|
43
|
+
body: Buffer;
|
|
44
|
+
bucket: string;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
bucket: string;
|
|
47
|
+
key: string;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* 파일 다운로드
|
|
51
|
+
*/
|
|
52
|
+
download(params: {
|
|
53
|
+
key: string;
|
|
54
|
+
bucket: string;
|
|
55
|
+
downloadFileName?: string;
|
|
56
|
+
}): Promise<import("@aws-sdk/client-s3").GetObjectCommandOutput>;
|
|
57
|
+
/**
|
|
58
|
+
* Presigned 다운로드 URL 생성
|
|
59
|
+
*/
|
|
60
|
+
getDownloadUrl(params: {
|
|
61
|
+
key: string;
|
|
62
|
+
bucket: string;
|
|
63
|
+
expiresInSec?: number;
|
|
64
|
+
downloadFileName?: string;
|
|
65
|
+
}): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* 파일 삭제
|
|
68
|
+
*/
|
|
69
|
+
delete(params: {
|
|
70
|
+
key: string;
|
|
71
|
+
bucket: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* URL에서 키 추출
|
|
75
|
+
*/
|
|
76
|
+
extractKey(urlOrKey: string, bucket?: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* 객체 URL 생성
|
|
79
|
+
*/
|
|
80
|
+
buildUrl(key: string, bucket?: string, region?: string): string;
|
|
81
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StorageModule = void 0;
|
|
4
|
+
const s3_1 = require("./s3");
|
|
5
|
+
/**
|
|
6
|
+
* StorageModule - 스토리지 관리 모듈
|
|
7
|
+
*/
|
|
8
|
+
class StorageModule {
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.s3Client = null;
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* S3 클라이언트 가져오기 (싱글톤)
|
|
15
|
+
*/
|
|
16
|
+
getS3Client() {
|
|
17
|
+
if (!this.s3Client) {
|
|
18
|
+
this.s3Client = (0, s3_1.createS3Client)(this.config);
|
|
19
|
+
}
|
|
20
|
+
return this.s3Client;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* S3 클라이언트 재설정
|
|
24
|
+
*/
|
|
25
|
+
setConfig(config) {
|
|
26
|
+
this.config = config;
|
|
27
|
+
this.s3Client = null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 날짜 기반 접두사 생성
|
|
31
|
+
*/
|
|
32
|
+
getDatePrefix(date) {
|
|
33
|
+
return (0, s3_1.getDatePrefix)(date);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* S3 키 생성
|
|
37
|
+
*/
|
|
38
|
+
buildKey(basePrefix, fileName, date) {
|
|
39
|
+
return (0, s3_1.buildS3Key)(basePrefix, fileName, date);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 파일 업로드
|
|
43
|
+
*/
|
|
44
|
+
async upload(params) {
|
|
45
|
+
return (0, s3_1.uploadFile)(this.getS3Client(), params);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* PDF 버퍼 업로드
|
|
49
|
+
*/
|
|
50
|
+
async uploadPdf(params) {
|
|
51
|
+
return (0, s3_1.uploadPdfBuffer)(this.getS3Client(), params);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 파일 다운로드
|
|
55
|
+
*/
|
|
56
|
+
async download(params) {
|
|
57
|
+
return (0, s3_1.getObject)(this.getS3Client(), params);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Presigned 다운로드 URL 생성
|
|
61
|
+
*/
|
|
62
|
+
async getDownloadUrl(params) {
|
|
63
|
+
return (0, s3_1.getPresignedDownloadUrl)(this.getS3Client(), params);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 파일 삭제
|
|
67
|
+
*/
|
|
68
|
+
async delete(params) {
|
|
69
|
+
return (0, s3_1.deleteObjectByKey)(this.getS3Client(), params);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* URL에서 키 추출
|
|
73
|
+
*/
|
|
74
|
+
extractKey(urlOrKey, bucket) {
|
|
75
|
+
const b = bucket || this.config.bucket || process.env.S3_BUCKET || '';
|
|
76
|
+
return (0, s3_1.extractKeyFromUrl)(urlOrKey, b);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 객체 URL 생성
|
|
80
|
+
*/
|
|
81
|
+
buildUrl(key, bucket, region) {
|
|
82
|
+
const b = bucket || this.config.bucket || process.env.S3_BUCKET || '';
|
|
83
|
+
return (0, s3_1.buildObjectUrl)(key, b, region);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.StorageModule = StorageModule;
|