Skip to content

Commit 1e131e4

Browse files
authored
Merge pull request #861 from samchon/features/record
Fix #853 - `Record<string & tags.Format<"uuid">, T>` case.
2 parents ec9159c + f421b61 commit 1e131e4

File tree

425 files changed

+8687
-2179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

425 files changed

+8687
-2179
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typia",
3-
"version": "5.2.4",
3+
"version": "5.2.5",
44
"description": "Superfast runtime validators with only one line",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -134,7 +134,7 @@
134134
"zod": "^3.19.1"
135135
},
136136
"stackblitzs": {
137-
"startCommand": "npm run prepare && npm run build && npm run build:test && npm run test"
137+
"startCommand": "npm run prepare && npm run build:test:actions && npm run build:test && npm run test"
138138
},
139139
"files": [
140140
"LICENSE",

packages/typescript-json/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-json",
3-
"version": "5.2.4",
3+
"version": "5.2.5",
44
"description": "Superfast runtime validators with only one line",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -72,13 +72,13 @@
7272
},
7373
"homepage": "https://typia.io",
7474
"dependencies": {
75-
"typia": "5.2.4"
75+
"typia": "5.2.5"
7676
},
7777
"peerDependencies": {
7878
"typescript": ">=4.8.0 <5.3.0"
7979
},
8080
"stackblitzs": {
81-
"startCommand": "npm run prepare && npm run build && npm run build:test && npm run test"
81+
"startCommand": "npm run prepare && npm run build:test:actions && npm run build:test && npm run test"
8282
},
8383
"files": [
8484
"LICENSE",

src/factories/internal/metadata/emplace_metadata_object.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,34 @@ export const emplace_metadata_object =
126126
const key: Metadata = analyzer(index.keyType)(null);
127127
const value: Metadata = analyzer(index.type)({});
128128

129+
if (
130+
key.atomics.length +
131+
key.constants
132+
.map((c) => c.values.length)
133+
.reduce((a, b) => a + b, 0) +
134+
key.templates.length +
135+
key.natives.filter(
136+
(type) =>
137+
type === "Boolean" ||
138+
type === "BigInt" ||
139+
type === "Number" ||
140+
type === "String",
141+
).length !==
142+
key.size()
143+
)
144+
errors.push({
145+
name: key.getName(),
146+
explore: {
147+
top: false,
148+
object: obj,
149+
property: "[key]",
150+
nested: null,
151+
escaped: false,
152+
aliased: false,
153+
},
154+
messages: [],
155+
});
156+
129157
// INSERT WITH REQUIRED CONFIGURATION
130158
insert(key)(value)(
131159
index.declaration?.parent

src/functional/$stoll.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const $is_bigint_string = (str: string): boolean => {
2+
try {
3+
BigInt(str);
4+
return true;
5+
} catch {
6+
return false;
7+
}
8+
};

src/functional/Namespace.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { $join } from "./$join";
1818
import { $number } from "./$number";
1919
import { $report } from "./$report";
2020
import { $rest } from "./$rest";
21+
import { $is_bigint_string } from "./$stoll";
2122
import { $string } from "./$string";
2223
import { $strlen } from "./$strlen";
2324
import { $tail } from "./$tail";
@@ -28,6 +29,7 @@ import { $tail } from "./$tail";
2829
export namespace Namespace {
2930
export const is = () => ({
3031
is_between: $is_between,
32+
is_bigint_string: $is_bigint_string,
3133
});
3234

3335
export const assert = (method: string) => ({
@@ -97,11 +99,13 @@ export namespace Namespace {
9799

98100
export namespace protobuf {
99101
export const decode = (method: string) => ({
102+
...is(),
100103
Reader: $ProtobufReader,
101104
throws: $throws(`protobuf.${method}`),
102105
});
103106

104107
export const encode = (method: string) => ({
108+
...is(),
105109
Sizer: $ProtobufSizer,
106110
Writer: $ProtobufWriter,
107111
strlen: $strlen,

src/programmers/AssertProgrammer.ts

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ export namespace AssertProgrammer {
9191
),
9292
]),
9393
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
94-
combiner: combiner(equals)(importer),
95-
joiner: joiner(equals)(importer),
94+
combiner: combiner(equals)(project)(importer),
95+
joiner: joiner(equals)(project)(importer),
9696
success: ts.factory.createTrue(),
9797
addition: () => importer.declare(modulo),
9898
})(importer)(type, name);
@@ -148,13 +148,14 @@ export namespace AssertProgrammer {
148148

149149
const combiner =
150150
(equals: boolean) =>
151+
(project: IProject) =>
151152
(importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
152153
(explore: CheckerProgrammer.IExplore) => {
153154
if (explore.tracable === false)
154155
return IsProgrammer.configure({
155-
object: assert_object(equals)(importer),
156+
object: assert_object(equals)(project)(importer),
156157
numeric: true,
157-
})(importer).combiner(explore);
158+
})(project)(importer).combiner(explore);
158159

159160
const path: string = explore.postfix
160161
? `_path + ${explore.postfix}`
@@ -219,40 +220,44 @@ export namespace AssertProgrammer {
219220
// })();
220221
};
221222

222-
const assert_object = (equals: boolean) => (importer: FunctionImporter) =>
223-
check_object({
224-
equals,
225-
assert: true,
226-
undefined: true,
227-
reduce: ts.factory.createLogicalAnd,
228-
positive: ts.factory.createTrue(),
229-
superfluous: (value) =>
230-
create_guard_call(importer)()(
231-
ts.factory.createAdd(
232-
ts.factory.createIdentifier("_path"),
233-
ts.factory.createCallExpression(
234-
importer.use("join"),
235-
undefined,
236-
[ts.factory.createIdentifier("key")],
223+
const assert_object =
224+
(equals: boolean) =>
225+
(project: IProject) =>
226+
(importer: FunctionImporter) =>
227+
check_object({
228+
equals,
229+
assert: true,
230+
undefined: true,
231+
reduce: ts.factory.createLogicalAnd,
232+
positive: ts.factory.createTrue(),
233+
superfluous: (value) =>
234+
create_guard_call(importer)()(
235+
ts.factory.createAdd(
236+
ts.factory.createIdentifier("_path"),
237+
ts.factory.createCallExpression(
238+
importer.use("join"),
239+
undefined,
240+
[ts.factory.createIdentifier("key")],
241+
),
237242
),
243+
"undefined",
244+
value,
238245
),
239-
"undefined",
240-
value,
241-
),
242-
halt: (expr) =>
243-
ts.factory.createLogicalOr(
244-
ts.factory.createStrictEquality(
245-
ts.factory.createFalse(),
246-
ts.factory.createIdentifier("_exceptionable"),
246+
halt: (expr) =>
247+
ts.factory.createLogicalOr(
248+
ts.factory.createStrictEquality(
249+
ts.factory.createFalse(),
250+
ts.factory.createIdentifier("_exceptionable"),
251+
),
252+
expr,
247253
),
248-
expr,
249-
),
250-
})(importer);
254+
})(project)(importer);
251255

252256
const joiner =
253257
(equals: boolean) =>
258+
(project: IProject) =>
254259
(importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
255-
object: assert_object(equals)(importer),
260+
object: assert_object(equals)(project)(importer),
256261
array: (input, arrow) =>
257262
ts.factory.createCallExpression(
258263
IdentifierFactory.access(input)("every"),

src/programmers/IsProgrammer.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { feature_object_entries } from "./internal/feature_object_entries";
2121
export namespace IsProgrammer {
2222
export const configure =
2323
(options?: Partial<CONFIG.IOptions>) =>
24+
(project: IProject) =>
2425
(importer: FunctionImporter): CheckerProgrammer.IConfig => ({
2526
prefix: "$i",
2627
equals: !!options?.object,
@@ -79,7 +80,7 @@ export namespace IsProgrammer {
7980
reduce: ts.factory.createLogicalAnd,
8081
positive: ts.factory.createTrue(),
8182
superfluous: () => ts.factory.createFalse(),
82-
})(importer),
83+
})(project)(importer),
8384
array: (input, arrow) =>
8485
ts.factory.createCallExpression(
8586
IdentifierFactory.access(input)("every"),
@@ -126,9 +127,9 @@ export namespace IsProgrammer {
126127
reduce: ts.factory.createLogicalAnd,
127128
positive: ts.factory.createTrue(),
128129
superfluous: () => ts.factory.createFalse(),
129-
})(importer),
130+
})(project)(importer),
130131
numeric: OptionPredicator.numeric(project.options),
131-
})(importer),
132+
})(project)(importer),
132133
trace: equals,
133134
addition: () => importer.declare(modulo),
134135
};
@@ -185,7 +186,7 @@ export namespace IsProgrammer {
185186
(project: IProject) =>
186187
(importer: FunctionImporter) =>
187188
(collection: MetadataCollection) => {
188-
const config = configure()(importer);
189+
const config = configure()(project)(importer);
189190
const objects =
190191
CheckerProgrammer.write_object_functions(project)(config)(
191192
importer,
@@ -223,10 +224,15 @@ export namespace IsProgrammer {
223224
DECODERS
224225
----------------------------------------------------------- */
225226
export const decode = (project: IProject) => (importer: FunctionImporter) =>
226-
CheckerProgrammer.decode(project)(configure()(importer))(importer);
227+
CheckerProgrammer.decode(project)(configure()(project)(importer))(
228+
importer,
229+
);
227230

228-
export const decode_object = (importer: FunctionImporter) =>
229-
CheckerProgrammer.decode_object(configure()(importer))(importer);
231+
export const decode_object =
232+
(project: IProject) => (importer: FunctionImporter) =>
233+
CheckerProgrammer.decode_object(configure()(project)(importer))(
234+
importer,
235+
);
230236

231237
export const decode_to_json =
232238
(checkNull: boolean) =>

src/programmers/ValidateProgrammer.ts

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export namespace ValidateProgrammer {
9797
),
9898
]),
9999
].reduce((x, y) => ts.factory.createLogicalAnd(x, y)),
100-
combiner: combine(equals)(importer),
101-
joiner: joiner(equals)(importer),
100+
combiner: combine(equals)(project)(importer),
101+
joiner: joiner(equals)(project)(importer),
102102
success: ts.factory.createTrue(),
103103
addition: () => importer.declare(modulo),
104104
},
@@ -195,13 +195,14 @@ export namespace ValidateProgrammer {
195195

196196
const combine =
197197
(equals: boolean) =>
198+
(project: IProject) =>
198199
(importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
199200
(explore: CheckerProgrammer.IExplore) => {
200201
if (explore.tracable === false)
201202
return IsProgrammer.configure({
202-
object: validate_object(equals)(importer),
203+
object: validate_object(equals)(project)(importer),
203204
numeric: true,
204-
})(importer).combiner(explore);
205+
})(project)(importer).combiner(explore);
205206

206207
const path: string = explore.postfix
207208
? `_path + ${explore.postfix}`
@@ -240,40 +241,42 @@ const combine =
240241
);
241242
};
242243

243-
const validate_object = (equals: boolean) => (importer: FunctionImporter) =>
244-
check_object({
245-
equals,
246-
undefined: true,
247-
assert: false,
248-
reduce: ts.factory.createLogicalAnd,
249-
positive: ts.factory.createTrue(),
250-
superfluous: (value) =>
251-
create_report_call()(
252-
ts.factory.createAdd(
253-
ts.factory.createIdentifier("_path"),
254-
ts.factory.createCallExpression(
255-
importer.use("join"),
256-
undefined,
257-
[ts.factory.createIdentifier("key")],
244+
const validate_object =
245+
(equals: boolean) => (project: IProject) => (importer: FunctionImporter) =>
246+
check_object({
247+
equals,
248+
undefined: true,
249+
assert: false,
250+
reduce: ts.factory.createLogicalAnd,
251+
positive: ts.factory.createTrue(),
252+
superfluous: (value) =>
253+
create_report_call()(
254+
ts.factory.createAdd(
255+
ts.factory.createIdentifier("_path"),
256+
ts.factory.createCallExpression(
257+
importer.use("join"),
258+
undefined,
259+
[ts.factory.createIdentifier("key")],
260+
),
258261
),
262+
"undefined",
263+
value,
259264
),
260-
"undefined",
261-
value,
262-
),
263-
halt: (expr) =>
264-
ts.factory.createLogicalOr(
265-
ts.factory.createStrictEquality(
266-
ts.factory.createFalse(),
267-
ts.factory.createIdentifier("_exceptionable"),
265+
halt: (expr) =>
266+
ts.factory.createLogicalOr(
267+
ts.factory.createStrictEquality(
268+
ts.factory.createFalse(),
269+
ts.factory.createIdentifier("_exceptionable"),
270+
),
271+
expr,
268272
),
269-
expr,
270-
),
271-
})(importer);
273+
})(project)(importer);
272274

273275
const joiner =
274276
(equals: boolean) =>
277+
(project: IProject) =>
275278
(importer: FunctionImporter): CheckerProgrammer.IConfig.IJoiner => ({
276-
object: validate_object(equals)(importer),
279+
object: validate_object(equals)(project)(importer),
277280
array: (input, arrow) =>
278281
check_everything(
279282
ts.factory.createCallExpression(

0 commit comments

Comments
 (0)