@yolo-croket-dev/amqp-access 0.7.257 → 0.7.258
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.
|
@@ -10,8 +10,18 @@ export interface GetExchangeRateByCountryCodeResult {
|
|
|
10
10
|
exchangeRate?: number;
|
|
11
11
|
currencyCode?: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type AsciiDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
14
|
+
type IsExactEightAsciiDigits<Value extends string, Digits extends unknown[] = []> = Value extends '' ? Digits['length'] extends 8 ? true : false : Digits['length'] extends 8 ? false : Value extends `${AsciiDigit}${infer Rest}` ? IsExactEightAsciiDigits<Rest, [...Digits, unknown]> : false;
|
|
15
|
+
export type ExchangeRateBaseDateLiteral<Value extends string> = string extends Value ? Value : IsExactEightAsciiDigits<Value> extends true ? Value : never;
|
|
16
|
+
type ExchangeRateBaseDateInput<Value extends string> = string extends Value ? unknown : ExchangeRateBaseDateLiteral<Value> extends never ? {
|
|
17
|
+
readonly exchangeRateBaseDateMustBeExactlyEightAsciiDigits: never;
|
|
18
|
+
} : unknown;
|
|
19
|
+
declare const exchangeRateBaseDateBrand: unique symbol;
|
|
20
|
+
export type ExchangeRateBaseDate = string & {
|
|
21
|
+
readonly [exchangeRateBaseDateBrand]: 'ExchangeRateBaseDate';
|
|
22
|
+
};
|
|
23
|
+
type UppercaseAsciiLetter = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z';
|
|
24
|
+
export type ExchangeRateCurrencyCode = `${UppercaseAsciiLetter}${UppercaseAsciiLetter}${UppercaseAsciiLetter}`;
|
|
15
25
|
export type GetExchangeRateByCountryCodeExactResult = {
|
|
16
26
|
readonly isSupported: true;
|
|
17
27
|
readonly baseDate: ExchangeRateBaseDate;
|
|
@@ -20,4 +30,7 @@ export type GetExchangeRateByCountryCodeExactResult = {
|
|
|
20
30
|
} | {
|
|
21
31
|
readonly isSupported: false;
|
|
22
32
|
};
|
|
33
|
+
export declare function isExchangeRateBaseDate(value: string): value is ExchangeRateBaseDate;
|
|
34
|
+
export declare function toExchangeRateBaseDate<const Value extends string>(value: Value & ExchangeRateBaseDateInput<Value>): ExchangeRateBaseDate;
|
|
23
35
|
export declare function isGetExchangeRateByCountryCodeExactResult(value: unknown): value is GetExchangeRateByCountryCodeExactResult;
|
|
36
|
+
export {};
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.isGetExchangeRateByCountryCodeExactResult = exports.GetExchangeRateByCountryCodePayload = void 0;
|
|
12
|
+
exports.isGetExchangeRateByCountryCodeExactResult = exports.toExchangeRateBaseDate = exports.isExchangeRateBaseDate = exports.GetExchangeRateByCountryCodePayload = void 0;
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
class GetExchangeRateByCountryCodePayload {
|
|
15
15
|
}
|
|
@@ -26,6 +26,17 @@ __decorate([
|
|
|
26
26
|
function isObjectRecord(value) {
|
|
27
27
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
28
28
|
}
|
|
29
|
+
function isExchangeRateBaseDate(value) {
|
|
30
|
+
return /^\d{8}$/.test(value);
|
|
31
|
+
}
|
|
32
|
+
exports.isExchangeRateBaseDate = isExchangeRateBaseDate;
|
|
33
|
+
function toExchangeRateBaseDate(value) {
|
|
34
|
+
if (!isExchangeRateBaseDate(value)) {
|
|
35
|
+
throw new TypeError('Exchange-rate baseDate must be exactly eight ASCII digits');
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
exports.toExchangeRateBaseDate = toExchangeRateBaseDate;
|
|
29
40
|
function isGetExchangeRateByCountryCodeExactResult(value) {
|
|
30
41
|
if (!isObjectRecord(value)) {
|
|
31
42
|
return false;
|
|
@@ -37,7 +48,7 @@ function isGetExchangeRateByCountryCodeExactResult(value) {
|
|
|
37
48
|
return value.isSupported === true
|
|
38
49
|
&& keys.join(',') === 'baseDate,currencyCode,exchangeRate,isSupported'
|
|
39
50
|
&& typeof value.baseDate === 'string'
|
|
40
|
-
&&
|
|
51
|
+
&& isExchangeRateBaseDate(value.baseDate)
|
|
41
52
|
&& typeof value.currencyCode === 'string'
|
|
42
53
|
&& /^[A-Z]{3}$/.test(value.currencyCode)
|
|
43
54
|
&& typeof value.exchangeRate === 'number'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolo-croket-dev/amqp-access",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.258",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "Yolo Co., Ltd.",
|
|
6
6
|
"description": "크로켓 amqp-access npm",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "node ../../node_modules/typescript/bin/tsc",
|
|
12
|
-
"lint": "eslint
|
|
12
|
+
"lint": "eslint --no-error-on-unmatched-pattern src/**/*.ts",
|
|
13
13
|
"fix": "eslint --fix src/**/*.ts",
|
|
14
14
|
"clean": "node ../../node_modules/typescript/bin/tsc --build --clean",
|
|
15
15
|
"prepublishOnly": "npm run build",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@yolo-croket-dev/domain": "0.2.40",
|
|
24
24
|
"@yolo-croket-dev/dto-v2": "0.2.23",
|
|
25
25
|
"@yolo-croket-dev/entity": "0.2.98",
|
|
26
|
-
"@yolo-croket-dev/entity-v2": "0.3.
|
|
26
|
+
"@yolo-croket-dev/entity-v2": "0.3.17",
|
|
27
27
|
"class-transformer": "^0.5.1",
|
|
28
28
|
"class-validator": "^0.13.2",
|
|
29
29
|
"dotenv": "^16.3.1"
|
|
@@ -22,8 +22,8 @@ const compileOptions = [
|
|
|
22
22
|
'--resolveJsonModule',
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
-
function
|
|
26
|
-
|
|
25
|
+
function compileTypeFixture(name) {
|
|
26
|
+
return spawnSync(
|
|
27
27
|
process.execPath,
|
|
28
28
|
[
|
|
29
29
|
'node_modules/typescript/bin/tsc',
|
|
@@ -32,8 +32,23 @@ function runTypeFixture(name, expectedExitCode) {
|
|
|
32
32
|
],
|
|
33
33
|
{ cwd: resolve(packageRoot, '../..'), encoding: 'utf8' },
|
|
34
34
|
);
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assertTypeFixturePasses(name) {
|
|
38
|
+
const result = compileTypeFixture(name);
|
|
39
|
+
if (result.status !== 0) {
|
|
40
|
+
throw new Error(`${name}: expected tsc exit 0, got ${result.status}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function assertTypeFixtureFails(name, expectedDiagnostic) {
|
|
45
|
+
const result = compileTypeFixture(name);
|
|
46
|
+
const output = `${result.stdout}${result.stderr}`;
|
|
47
|
+
if (result.status === 0) {
|
|
48
|
+
throw new Error(`${name}: expected tsc failure for ${expectedDiagnostic}`);
|
|
49
|
+
}
|
|
50
|
+
if (!expectedDiagnostic.test(output)) {
|
|
51
|
+
throw new Error(`${name}: missing expected diagnostic ${expectedDiagnostic}`);
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
|
|
@@ -42,22 +57,23 @@ function readJsonFixture(name) {
|
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
for (const name of ['legacy-compatibility', 'supported-usd', 'supported-cad', 'supported-jpy', 'unsupported-only']) {
|
|
45
|
-
|
|
60
|
+
assertTypeFixturePasses(name);
|
|
46
61
|
}
|
|
47
62
|
|
|
48
|
-
for (const name of [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
for (const [name, expectedDiagnostic] of [
|
|
64
|
+
['missing-field', /Property 'currencyCode' is missing/],
|
|
65
|
+
['bad-currency', /Type '"usd"' is not assignable/],
|
|
66
|
+
['bad-currency-digit', /Type '"US1"' is not assignable/],
|
|
67
|
+
['bad-currency-short', /Type '"US"' is not assignable/],
|
|
68
|
+
['bad-currency-long', /Type '"USDX"' is not assignable/],
|
|
69
|
+
['bad-date', /Argument of type '"2026-08-10"'[\s\S]*exchangeRateBaseDateMustBeExactlyEightAsciiDigits/],
|
|
70
|
+
['bad-date-short', /Argument of type '"2026081"'[\s\S]*exchangeRateBaseDateMustBeExactlyEightAsciiDigits/],
|
|
71
|
+
['bad-date-long', /Argument of type '"202608100"'[\s\S]*exchangeRateBaseDateMustBeExactlyEightAsciiDigits/],
|
|
72
|
+
['bad-date-alpha', /Argument of type '"20260A10"'[\s\S]*exchangeRateBaseDateMustBeExactlyEightAsciiDigits/],
|
|
73
|
+
['bad-date-fullwidth', /Argument of type '"20260810"'[\s\S]*exchangeRateBaseDateMustBeExactlyEightAsciiDigits/],
|
|
74
|
+
['unsupported-extra-key', /'baseDate' does not exist/],
|
|
75
|
+
]) {
|
|
76
|
+
assertTypeFixtureFails(name, expectedDiagnostic);
|
|
61
77
|
}
|
|
62
78
|
|
|
63
79
|
const packageBuild = spawnSync(
|
|
@@ -83,15 +99,22 @@ for (const name of ['valid-usd', 'valid-cad', 'valid-jpy', 'unsupported-only'])
|
|
|
83
99
|
}
|
|
84
100
|
}
|
|
85
101
|
|
|
86
|
-
for (const value of [
|
|
87
|
-
readJsonFixture('bad-rate'),
|
|
88
|
-
{ isSupported: true, baseDate: '20260810', exchangeRate: Number.POSITIVE_INFINITY, currencyCode: 'USD' },
|
|
89
|
-
readJsonFixture('bad-date'),
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
for (const [name, value, field] of [
|
|
103
|
+
['bad-rate', readJsonFixture('bad-rate'), 'exchangeRate'],
|
|
104
|
+
['bad-nonfinite-rate', { isSupported: true, baseDate: '20260810', exchangeRate: Number.POSITIVE_INFINITY, currencyCode: 'USD' }, 'exchangeRate'],
|
|
105
|
+
['bad-date', readJsonFixture('bad-date'), 'baseDate'],
|
|
106
|
+
['bad-date-short', { isSupported: true, baseDate: '2026081', exchangeRate: 10.25, currencyCode: 'USD' }, 'baseDate'],
|
|
107
|
+
['bad-date-long', { isSupported: true, baseDate: '202608100', exchangeRate: 10.25, currencyCode: 'USD' }, 'baseDate'],
|
|
108
|
+
['bad-date-alpha', { isSupported: true, baseDate: '20260A10', exchangeRate: 10.25, currencyCode: 'USD' }, 'baseDate'],
|
|
109
|
+
['bad-date-fullwidth', { isSupported: true, baseDate: '20260810', exchangeRate: 10.25, currencyCode: 'USD' }, 'baseDate'],
|
|
110
|
+
['bad-currency', readJsonFixture('bad-currency'), 'currencyCode'],
|
|
111
|
+
['bad-currency-digit', { isSupported: true, baseDate: '20260810', exchangeRate: 10.25, currencyCode: 'US1' }, 'currencyCode'],
|
|
112
|
+
['bad-currency-short', { isSupported: true, baseDate: '20260810', exchangeRate: 10.25, currencyCode: 'US' }, 'currencyCode'],
|
|
113
|
+
['bad-currency-long', { isSupported: true, baseDate: '20260810', exchangeRate: 10.25, currencyCode: 'USDX' }, 'currencyCode'],
|
|
114
|
+
['unsupported-extra-key', readJsonFixture('unsupported-extra-key'), 'unsupported key set'],
|
|
92
115
|
]) {
|
|
93
116
|
if (isGetExchangeRateByCountryCodeExactResult(value)) {
|
|
94
|
-
throw new Error(
|
|
117
|
+
throw new Error(`${name}: runtime validation accepted invalid ${field}`);
|
|
95
118
|
}
|
|
96
119
|
}
|
|
97
120
|
|