Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/nestia/e2e-tw-0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon authored Aug 9, 2023
2 parents 1541a63 + 2cca488 commit 931c8d2
Show file tree
Hide file tree
Showing 19 changed files with 502 additions and 273 deletions.
2 changes: 1 addition & 1 deletion nestia.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const NESTIA_CONFIG: INestiaConfig = {
output: "src/api",
simulate: true,
swagger: {
output: "dist/swagger.json",
output: "packages/api/swagger.json",
info: {
title: "Toss Payments API",
description:
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fake-toss-payments-server",
"version": "1.3.2",
"version": "1.4.0",
"description": "Fake toss-payments server for testing",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand All @@ -17,7 +17,7 @@
"eslint:fix": "eslint --fix src && eslint --fix --config .eslintrc.test.cjs test",
"prettier": "prettier src --write && prettier test --write",
"------------------------------------------------": "",
"package:api": "npm run build:api && cd packages/api && npm publish",
"package:api": "npm run build:swagger && npm run build:api && cd packages/api && npm publish",
"package:latest": "npm run build && npm run test && npm publish",
"package:next": "npm run package:latest -- --tag next",
"prepare": "ts-patch install",
Expand All @@ -40,7 +40,7 @@
"homepage": "https://github.com/samchon/fake-toss-payments-server",
"devDependencies": {
"@nestia/e2e": "^0.3.6",
"@nestia/sdk": "^1.4.3",
"@nestia/sdk": "^1.6.2",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@types/atob": "^2.1.2",
"@types/btoa": "^1.2.3",
Expand All @@ -51,24 +51,24 @@
"@typescript-eslint/parser": "^5.26.0",
"cli": "^1.0.1",
"copyfiles": "^2.4.1",
"nestia": "^4.3.2",
"nestia": "^4.4.0",
"pm2": "^4.5.6",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"sloc": "^0.2.1",
"ts-node": "^10.9.1",
"ts-patch": "^2.1.0",
"typescript": "^4.9.5",
"ts-patch": "^3.0.2",
"typescript": "^5.1.6",
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@nestia/core": "^1.4.1",
"@nestia/core": "^1.6.2",
"atob": "^2.1.2",
"btoa": "^1.2.1",
"serialize-error": "^4.1.0",
"source-map-support": "^0.5.19",
"tstl": "^2.5.13",
"typia": "^4.1.1",
"typia": "^4.2.1",
"uuid": "^9.0.0"
},
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toss-payments-server-api",
"version": "1.3.2",
"version": "1.4.0",
"description": "Toss Payments Server API",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand All @@ -15,8 +15,8 @@
},
"homepage": "https://github.com/samchon/fake-toss-payments-server",
"dependencies": {
"@nestia/fetcher": "^1.4.0",
"typia": "^4.1.1"
"@nestia/fetcher": "^1.6.2",
"typia": "^4.2.1"
},
"keywords": [
"toss",
Expand Down
392 changes: 276 additions & 116 deletions dist/swagger.json → packages/api/swagger.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/IConnection.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { IConnection } from "@nestia/fetcher";
export type { IConnection } from "@nestia/fetcher";
2 changes: 1 addition & 1 deletion src/api/Primitive.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { Primitive } from "@nestia/fetcher";
export type { Primitive } from "@nestia/fetcher";
24 changes: 15 additions & 9 deletions src/api/functional/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import type { ITossPayment } from "./../../structures/ITossPayment";
* 웹훅 이벤트 더미 리스너.
*
* `internal.webhook` 은 실제 토스 페이먼츠의 결제 서버에는 존재하지 않는 API 로써,
* `fake-toss-payments-server` 의 {@link Configuration.WEBHOOK_URL} 에 아무런 URL 을
* `fake-toss-payments-server` 의 {@link Configuration.WEBHOOK_URL } 에 아무런 URL 을
* 설정하지 않으면, `fake-toss-payments-server` 로부터 발생하는 모든 종류의 웹훅
* 이벤트는 이 곳으로 전달되어 무의미하게 사라진다.
*
* 따라서 `fake-toss-payments-server` 를 사용하여 토스 페이먼츠 서버와의 연동을 미리
* 검증코자 할 때는, 반드시 {@link Configuration.WEBHOOK_URL} 를 설정하여 웹훅
* 검증코자 할 때는, 반드시 {@link Configuration.WEBHOOK_URL } 를 설정하여 웹훅
* 이벤트가 귀하의 백엔드 서버로 제대로 전달되도록 하자.
*
* @param input 웹훅 이벤트 정보
Expand All @@ -35,13 +35,19 @@ export async function webhook(
connection: IConnection,
input: webhook.Input,
): Promise<void> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? webhook.simulate(
connection,
input,
)
: Fetcher.fetch(
connection,
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
webhook.ENCRYPTED,
webhook.METHOD,
webhook.path(),
Expand Down Expand Up @@ -87,7 +93,7 @@ export namespace webhook {
*
* @param paymentKey 대상 가상 계좌 결제 정보의 {@link ITossPayment.paymentKey}
* @returns 입금 완료된 가상 꼐좌 결제 정보
*
* @security basic
* @author Jeongho Nam - https://github.com/samchon
*
* @controller FakeTossInternalController.deposit()
Expand All @@ -98,7 +104,7 @@ export async function deposit(
connection: IConnection,
paymentKey: string,
): Promise<deposit.Output> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? deposit.simulate(
connection,
paymentKey,
Expand Down Expand Up @@ -136,9 +142,9 @@ export namespace deposit {
});
assert.param("paymentKey")("string")(() => typia.assert(paymentKey));
return random(
typeof (connection.simulate ?? (connection as any).random) === 'object'
&& (connection.simulate ?? (connection as any).random) !== null
? (connection.simulate ?? (connection as any).random)
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
Expand Down
18 changes: 12 additions & 6 deletions src/api/functional/v1/billing/authorizations/card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { ITossBilling } from "./../../../../../structures/ITossBilling";
*
* @param input 간편 결제 카드 등록 정보
* @returns 간편 결제 카드 정보
*
* @security basic
* @author Jeongho Nam - https://github.com/samchon
*
* @controller FakeTossBillingController.store()
Expand All @@ -36,13 +36,19 @@ export async function store(
connection: IConnection,
input: store.Input,
): Promise<store.Output> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? store.simulate(
connection,
input,
)
: Fetcher.fetch(
connection,
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
store.ENCRYPTED,
store.METHOD,
store.path(),
Expand Down Expand Up @@ -76,9 +82,9 @@ export namespace store {
});
assert.body(() => typia.assert(input));
return random(
typeof (connection.simulate ?? (connection as any).random) === 'object'
&& (connection.simulate ?? (connection as any).random) !== null
? (connection.simulate ?? (connection as any).random)
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
Expand Down
18 changes: 12 additions & 6 deletions src/api/functional/v1/billing/authorizations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export * as card from "./card";
* @param billingKey 대상 정보의 {@link ITossBilling.billingKey}
* @param input 고객 식별자 키
* @returns 간편 결제 수단 정보
*
* @security basic
* @author Jeongho Nam - https://github.com/samchon
*
* @controller FakeTossBillingController.at()
Expand All @@ -38,14 +38,20 @@ export async function at(
billingKey: string,
input: at.Input,
): Promise<at.Output> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? at.simulate(
connection,
billingKey,
input,
)
: Fetcher.fetch(
connection,
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
at.ENCRYPTED,
at.METHOD,
at.path(billingKey),
Expand Down Expand Up @@ -81,9 +87,9 @@ export namespace at {
assert.param("billingKey")("string")(() => typia.assert(billingKey));
assert.body(() => typia.assert(input));
return random(
typeof (connection.simulate ?? (connection as any).random) === 'object'
&& (connection.simulate ?? (connection as any).random) !== null
? (connection.simulate ?? (connection as any).random)
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
Expand Down
20 changes: 13 additions & 7 deletions src/api/functional/v1/billing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export * as authorizations from "./authorizations";
* 대한 별도의 설계 및 개발이 필요하니, 이 점을 염두에 두기 바란다.
*
* 더하여 `billing.pay` 는 철저히 귀사 백엔드 서버의 판단 아래 호출되는 API 함수인지라,
* 이를 통하여 이루어지는 결제는 일절 {@link payments.approve} 가 필요 없다. 다만
* 이를 통하여 이루어지는 결제는 일절 {@link payments.approve } 가 필요 없다. 다만
* `billing.pay` 는 이처럼 부차적인 승인 과정 필요없이 그 즉시로 결제가 완성되니, 이를
* 호출하는 상황에 대하여 세심히 주의를 기울일 필요가 있다
*
* @param billingKey 간편 결제에 등록한 수단의 {@link ITossBilling.billingKey}
* @param input 주문 정보
* @returns 결제 정보
*
* @security basic
* @author Jeongho Nam - https://github.com/samchon
*
* @controller FakeTossBillingController.pay()
Expand All @@ -46,14 +46,20 @@ export async function pay(
billingKey: string,
input: pay.Input,
): Promise<pay.Output> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? pay.simulate(
connection,
billingKey,
input,
)
: Fetcher.fetch(
connection,
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
pay.ENCRYPTED,
pay.METHOD,
pay.path(billingKey),
Expand Down Expand Up @@ -89,9 +95,9 @@ export namespace pay {
assert.param("billingKey")("string")(() => typia.assert(billingKey));
assert.body(() => typia.assert(input));
return random(
typeof (connection.simulate ?? (connection as any).random) === 'object'
&& (connection.simulate ?? (connection as any).random) !== null
? (connection.simulate ?? (connection as any).random)
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
Expand Down
36 changes: 24 additions & 12 deletions src/api/functional/v1/cash_receipts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { ITossCashReceipt } from "./../../../structures/ITossCashReceipt";
*
* @param input 입력 정보
* @returns 현금 영수증 정보
*
* @security basic
* @author Jeongho Nam - https://github.com/samchon
*
* @controller FakeTossCashReceiptsController.store()
Expand All @@ -27,13 +27,19 @@ export async function store(
connection: IConnection,
input: store.Input,
): Promise<store.Output> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? store.simulate(
connection,
input,
)
: Fetcher.fetch(
connection,
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
store.ENCRYPTED,
store.METHOD,
store.path(),
Expand Down Expand Up @@ -67,9 +73,9 @@ export namespace store {
});
assert.body(() => typia.assert(input));
return random(
typeof (connection.simulate ?? (connection as any).random) === 'object'
&& (connection.simulate ?? (connection as any).random) !== null
? (connection.simulate ?? (connection as any).random)
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
Expand All @@ -81,7 +87,7 @@ export namespace store {
* @param receiptKey 현금 영수증의 {@link ITossCashReceipt.receiptKey}
* @param input 취소 입력 정보
* @returns 취소된 현금 영수증 정보
*
* @security basic
* @author Jeongho Nam - https://github.com/samchon
*
* @controller FakeTossCashReceiptsController.cancel()
Expand All @@ -93,14 +99,20 @@ export async function cancel(
receiptKey: string,
input: cancel.Input,
): Promise<cancel.Output> {
return !!(connection.simulate ?? (connection as any).random)
return !!connection.simulate
? cancel.simulate(
connection,
receiptKey,
input,
)
: Fetcher.fetch(
connection,
{
...connection,
headers: {
...(connection.headers ?? {}),
"Content-Type": "application/json",
},
},
cancel.ENCRYPTED,
cancel.METHOD,
cancel.path(receiptKey),
Expand Down Expand Up @@ -136,9 +148,9 @@ export namespace cancel {
assert.param("receiptKey")("string")(() => typia.assert(receiptKey));
assert.body(() => typia.assert(input));
return random(
typeof (connection.simulate ?? (connection as any).random) === 'object'
&& (connection.simulate ?? (connection as any).random) !== null
? (connection.simulate ?? (connection as any).random)
typeof connection.simulate === 'object' &&
connection.simulate !== null
? connection.simulate
: undefined
);
}
Expand Down
Loading

0 comments on commit 931c8d2

Please sign in to comment.