typia 13.2.0 → 14.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/lib/http.d.ts +3 -3
- package/lib/http.js.map +1 -1
- package/lib/http.mjs.map +1 -1
- package/lib/internal/_assertGuard.js +13 -3
- package/lib/internal/_assertGuard.js.map +1 -1
- package/lib/internal/_assertGuard.mjs +4 -2
- package/lib/internal/_assertGuard.mjs.map +1 -1
- package/lib/internal/_isFormatIdnHostname.js +5 -1
- package/lib/internal/_isFormatIdnHostname.js.map +1 -1
- package/lib/internal/_isFormatIdnHostname.mjs +1 -1
- package/lib/internal/_isFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_isFormatTime.js +19 -2
- package/lib/internal/_isFormatTime.js.map +1 -1
- package/lib/internal/_isFormatTime.mjs +9 -2
- package/lib/internal/_isFormatTime.mjs.map +1 -1
- package/lib/internal/_randomArray.js +37 -4
- package/lib/internal/_randomArray.js.map +1 -1
- package/lib/internal/_randomArray.mjs +16 -3
- package/lib/internal/_randomArray.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +15 -12
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +11 -10
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +1 -1
- package/lib/internal/_randomFormatHostname.d.ts +2 -2
- package/lib/internal/_randomFormatHostname.js +2 -2
- package/lib/internal/_randomFormatHostname.mjs +2 -2
- package/lib/internal/_randomFormatHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.js +9 -10
- package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
- package/lib/internal/_randomFormatIdnHostname.mjs +3 -4
- package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +4 -4
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +1 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +15 -10
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +6 -3
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js +20 -3
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs +5 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.js +9 -2
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +3 -1
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +8 -0
- package/lib/internal/private/__randomComposition.js +21 -1
- package/lib/internal/private/__randomComposition.js.map +1 -1
- package/lib/internal/private/__randomComposition.mjs +18 -1
- package/lib/internal/private/__randomComposition.mjs.map +1 -1
- package/lib/json.d.ts +2 -2
- package/lib/json.js.map +1 -1
- package/lib/json.mjs.map +1 -1
- package/lib/module.d.ts +28 -13
- package/lib/module.js.map +1 -1
- package/lib/module.mjs.map +1 -1
- package/lib/notations.d.ts +4 -4
- package/lib/notations.js.map +1 -1
- package/lib/notations.mjs.map +1 -1
- package/lib/plain.d.ts +3 -3
- package/lib/plain.js.map +1 -1
- package/lib/plain.mjs.map +1 -1
- package/lib/protobuf.d.ts +2 -2
- package/lib/protobuf.js.map +1 -1
- package/lib/protobuf.mjs.map +1 -1
- package/lib/transform.mjs +1 -1
- package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +17 -4
- package/native/cmd/ttsc-typia/create_assert_error_factory_arity_test.go +309 -0
- package/native/cmd/ttsc-typia/dynamic_key_tags_transform_test.go +206 -0
- package/native/cmd/ttsc-typia/local_function_named_like_typia_operation_transform_test.go +185 -0
- package/native/cmd/ttsc-typia/notation_kebab_case_transform_test.go +2 -2
- package/native/cmd/ttsc-typia/project_catalog_transform_coverage_test.go +84 -85
- package/native/cmd/ttsc-typia/recursive_conditional_alias_name_transform_test.go +307 -0
- package/native/cmd/ttsc-typia/shadowed_typia_module_declaration_diagnostic_test.go +152 -0
- package/native/cmd/ttsc-typia/transform.go +2 -2
- package/native/cmd/ttsc-typia/transform_helpers_test.go +96 -18
- package/native/core/factories/FormatCheatSheet.go +2 -2
- package/native/core/factories/MetadataCommentTagFactory.go +91 -7
- package/native/core/factories/factory_utility_coverage_test.go +896 -907
- package/native/core/factories/internal/metadata/MetadataHelper.go +5 -28
- package/native/core/factories/metadata_comment_tag_factory_rejects_out_of_range_integer_test.go +124 -0
- package/native/core/programmers/AssertProgrammer.go +20 -6
- package/native/core/programmers/RandomProgrammer.go +78 -3
- package/native/core/programmers/ValidateProgrammer.go +21 -6
- package/native/core/programmers/helpers/RandomJoiner.go +8 -1
- package/native/core/programmers/iterate/check_dynamic_properties.go +177 -3
- package/native/core/programmers/iterate/check_object.go +12 -1
- package/native/core/schemas/metadata/MetadataCollection.go +47 -5
- package/native/transform/CallExpressionTransformer.go +167 -0
- package/package.json +3 -12
- package/src/http.ts +18 -4
- package/src/internal/_assertGuard.ts +13 -2
- package/src/internal/_isFormatIdnHostname.ts +5 -1
- package/src/internal/_isFormatTime.ts +19 -2
- package/src/internal/_randomArray.ts +42 -6
- package/src/internal/_randomFormatByte.ts +17 -12
- package/src/internal/_randomFormatHostname.ts +2 -2
- package/src/internal/_randomFormatIdnHostname.ts +8 -9
- package/src/internal/_randomFormatRegex.ts +4 -6
- package/src/internal/_randomFormatTime.ts +15 -10
- package/src/internal/_randomPattern.ts +18 -3
- package/src/internal/_randomStringLength.ts +9 -2
- package/src/internal/private/__randomComposition.ts +24 -0
- package/src/json.ts +16 -4
- package/src/module.ts +56 -22
- package/src/notations.ts +16 -4
- package/src/plain.ts +12 -3
- package/src/protobuf.ts +16 -4
- package/lib/executable/FileSystemIdentity.d.ts +0 -44
- package/lib/executable/FileSystemIdentity.js +0 -213
- package/lib/executable/FileSystemIdentity.js.map +0 -1
- package/lib/executable/FileSystemIdentity.mjs +0 -133
- package/lib/executable/FileSystemIdentity.mjs.map +0 -1
- package/lib/executable/TypiaGenerateWizard.d.ts +0 -9
- package/lib/executable/TypiaGenerateWizard.js +0 -852
- package/lib/executable/TypiaGenerateWizard.js.map +0 -1
- package/lib/executable/TypiaGenerateWizard.mjs +0 -618
- package/lib/executable/TypiaGenerateWizard.mjs.map +0 -1
- package/lib/executable/generate/ttsc.d.ts +0 -1
- package/lib/executable/generate/ttsc.js +0 -53
- package/lib/executable/generate/ttsc.js.map +0 -1
- package/lib/executable/generate/ttsc.mjs +0 -37
- package/lib/executable/generate/ttsc.mjs.map +0 -1
- package/lib/executable/typia.d.ts +0 -2
- package/lib/executable/typia.js +0 -84
- package/lib/executable/typia.js.map +0 -1
- package/lib/executable/typia.mjs +0 -60
- package/lib/executable/typia.mjs.map +0 -1
- package/src/executable/FileSystemIdentity.ts +0 -222
- package/src/executable/TypiaGenerateWizard.ts +0 -1133
- package/src/executable/generate/ttsc.ts +0 -70
- package/src/executable/typia.ts +0 -80
|
@@ -196,6 +196,34 @@ func (metadataCommentTagFactoryNamespace) Get(props struct {
|
|
|
196
196
|
return output
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
// metadataCommentTagFactory_PARSER maps a JSDoc tag name to the tag records it
|
|
200
|
+
// produces. Each record's `Validate` is the runtime check the transform splices
|
|
201
|
+
// into the emitted validator, and it must spell the same check as the matching
|
|
202
|
+
// declaration in `packages/interface/src/tags` -- the two are one constraint.
|
|
203
|
+
//
|
|
204
|
+
// # WHEN A RECORD MAY NAME A RUNTIME HELPER
|
|
205
|
+
//
|
|
206
|
+
// A `Validate` may write `$importInternal("x")`, here or in the matching
|
|
207
|
+
// declaration, only under the rule below.
|
|
208
|
+
//
|
|
209
|
+
// That call makes the emitted validator `require("typia/lib/internal/_x")`. The
|
|
210
|
+
// type-tag half of each constraint is declared in `@typia/interface`, which
|
|
211
|
+
// `typia` depends on through a caret range, and a caret only floats upward. So
|
|
212
|
+
// inside one major an older `typia` installs a newer `@typia/interface` and
|
|
213
|
+
// emits an import its own runtime never published; that is #2330, and it is why
|
|
214
|
+
// #2336 and #2339 reverted these very templates to inline expressions.
|
|
215
|
+
//
|
|
216
|
+
// The rule: a template may name only a helper that every `typia` inside the
|
|
217
|
+
// caret range already ships. `isTypeInt8` and its siblings satisfy it --
|
|
218
|
+
// `@typia/interface` 13.0.0 named them and `typia` 13.0.0 shipped them. The
|
|
219
|
+
// four this file and `Type.ts` now name do not: `_stringLength`, `_isMultipleOf`
|
|
220
|
+
// (both first published in 13.1.19), `_isTypeInt64Bigint`, and
|
|
221
|
+
// `_isTypeUint64Bigint` (13.1.19). They are safe only because the release that
|
|
222
|
+
// carries them is a major, where the caret cannot reach a `typia` that predates
|
|
223
|
+
// them. A minor or patch release of this tree reopens #2330.
|
|
224
|
+
//
|
|
225
|
+
// Nothing here can enforce that; the release version is the maintainer's, and a
|
|
226
|
+
// campaign pull request never assigns one. This comment is the record.
|
|
199
227
|
var metadataCommentTagFactory_PARSER = map[string]metadataCommentTagFactory_parser{
|
|
200
228
|
"items": func(props struct {
|
|
201
229
|
Report func(msg string) any
|
|
@@ -268,6 +296,12 @@ var metadataCommentTagFactory_PARSER = map[string]metadataCommentTagFactory_pars
|
|
|
268
296
|
Report func(msg string) any
|
|
269
297
|
Value string
|
|
270
298
|
}) metadataCommentTagFactory_TagRecord {
|
|
299
|
+
// `@multipleOf` and `MultipleOf<N>` are two spellings of one constraint, so
|
|
300
|
+
// the number arm divides exact decimals through the same helper the type tag
|
|
301
|
+
// names. `%` would divide the binary doubles that are actually stored, which
|
|
302
|
+
// answers a different question than the `multipleOf` keyword this tag emits.
|
|
303
|
+
// The bigint arm needs no helper: a bigint remainder is already exact.
|
|
304
|
+
// `_isMultipleOf` first shipped in 13.1.19; see the doc comment above.
|
|
271
305
|
return metadataCommentTagFactory_numeric(props, "MultipleOf", "multipleOf", "$importInternal(\"_isMultipleOf\")($input, "+props.Value+")", "$input % "+props.Value+"n === 0n")
|
|
272
306
|
},
|
|
273
307
|
"format": func(props struct {
|
|
@@ -291,6 +325,13 @@ var metadataCommentTagFactory_PARSER = map[string]metadataCommentTagFactory_pars
|
|
|
291
325
|
Value string
|
|
292
326
|
}) metadataCommentTagFactory_TagRecord {
|
|
293
327
|
value := metadataCommentTagFactory_parse_number(props)
|
|
328
|
+
// `@length`, `@minLength`, and `@maxLength` measure through the same helper
|
|
329
|
+
// `MinLength<N>` and `MaxLength<N>` name, because the JSDoc spelling and the
|
|
330
|
+
// type-tag spelling of one constraint must never mean different things.
|
|
331
|
+
// `$input.length` counts UTF-16 code units, while the `minLength` and
|
|
332
|
+
// `maxLength` keywords these tags emit count characters, so one astral
|
|
333
|
+
// character would measure 2 against a schema that measures 1.
|
|
334
|
+
// `_stringLength` first shipped in 13.1.19; see the doc comment above.
|
|
294
335
|
return metadataCommentTagFactory_TagRecord{"string": {
|
|
295
336
|
{Name: "MinLength<" + props.Value + ">", Target: "string", Kind: "minLength", Value: value, Validate: props.Value + " <= $importInternal(\"_stringLength\")($input)", Exclusive: metadataCommentTagFactory_exclusive("minLength"), Schema: map[string]any{"minLength": value}},
|
|
296
337
|
{Name: "MaxLength<" + props.Value + ">", Target: "string", Kind: "maxLength", Value: value, Validate: "$importInternal(\"_stringLength\")($input) <= " + props.Value, Exclusive: metadataCommentTagFactory_exclusive("maxLength"), Schema: map[string]any{"maxLength": value}},
|
|
@@ -407,10 +448,20 @@ func metadataCommentTagFactory_parse_type(props struct {
|
|
|
407
448
|
"number": {{Name: "Type<" + strconv.Quote(value) + ">", Target: "number", Kind: "type", Value: value, Validate: validate, Exclusive: metadataCommentTagFactory_exclusive("type"), Schema: numberSchema}},
|
|
408
449
|
}
|
|
409
450
|
if value == "int64" || value == "uint64" {
|
|
410
|
-
//
|
|
411
|
-
//
|
|
412
|
-
//
|
|
413
|
-
//
|
|
451
|
+
// `@type int64` and `bigint & Type<"int64">` are two spellings of one
|
|
452
|
+
// constraint, so both delegate to the helper that holds the exact inclusive
|
|
453
|
+
// bound. The bigint form used to emit `true` for int64 and a lower bound
|
|
454
|
+
// only for uint64, which certified any magnitude at all -- and
|
|
455
|
+
// `typia.protobuf.encode` then truncated the value to 64 bits, so a
|
|
456
|
+
// certified value came back different.
|
|
457
|
+
//
|
|
458
|
+
// The bound has to live in a helper rather than an inline literal here
|
|
459
|
+
// because it is only exact as a string: `BigInt(9223372036854775807)` rounds
|
|
460
|
+
// its `number` literal to 2**63 before BigInt ever parses it.
|
|
461
|
+
//
|
|
462
|
+
// See the `metadataCommentTagFactory_PARSER` doc comment: naming a helper
|
|
463
|
+
// here is safe only under a major bump, and `_isTypeInt64Bigint` /
|
|
464
|
+
// `_isTypeUint64Bigint` first shipped in 13.1.19.
|
|
414
465
|
bigintValidate := "$importInternal(\"isTypeUint64Bigint\")($input)"
|
|
415
466
|
if value == "int64" {
|
|
416
467
|
bigintValidate = "$importInternal(\"isTypeInt64Bigint\")($input)"
|
|
@@ -437,7 +488,7 @@ func metadataCommentTagFactory_numeric(props struct {
|
|
|
437
488
|
"number": {{Name: name + "<" + props.Value + ">", Target: "number", Kind: kind, Value: number, Validate: numberValidate, Exclusive: exclusive, Schema: map[string]any{kind: number}}},
|
|
438
489
|
}
|
|
439
490
|
if integer != nil {
|
|
440
|
-
record["bigint"] = []schemametadata.IMetadataTypeTag{{Name: name + "<" + props.Value + "n>", Target: "bigint", Kind: kind, Value:
|
|
491
|
+
record["bigint"] = []schemametadata.IMetadataTypeTag{{Name: name + "<" + props.Value + "n>", Target: "bigint", Kind: kind, Value: *integer, Validate: bigintValidate, Exclusive: exclusive, Schema: map[string]any{kind: number}}}
|
|
441
492
|
}
|
|
442
493
|
return record
|
|
443
494
|
}
|
|
@@ -458,7 +509,7 @@ func metadataCommentTagFactory_parse_integer(props struct {
|
|
|
458
509
|
Report func(msg string) any
|
|
459
510
|
Unsigned bool
|
|
460
511
|
Value string
|
|
461
|
-
}) *
|
|
512
|
+
}) *int64 {
|
|
462
513
|
parsedAny := metadataCommentTagFactory_parse_number(struct {
|
|
463
514
|
Report func(msg string) any
|
|
464
515
|
Value string
|
|
@@ -475,10 +526,43 @@ func metadataCommentTagFactory_parse_integer(props struct {
|
|
|
475
526
|
props.Report("invalid unsigned integer")
|
|
476
527
|
return nil
|
|
477
528
|
}
|
|
478
|
-
|
|
529
|
+
// A float64 outside the destination range converts by an
|
|
530
|
+
// implementation-defined rule, not by wrapping: on amd64 both `1e19` and
|
|
531
|
+
// `-1e19` become -9223372036854775808, so a magnitude and its negation
|
|
532
|
+
// collapse to the same wrong number. Reject instead, because a tag whose value
|
|
533
|
+
// cannot be carried is a tag whose meaning is already lost.
|
|
534
|
+
if parsed < metadataCommentTagFactory_INT64_MINIMUM || parsed >= metadataCommentTagFactory_INT64_EXCLUSIVE_MAXIMUM {
|
|
535
|
+
props.Report("integer out of range")
|
|
536
|
+
return nil
|
|
537
|
+
}
|
|
538
|
+
value := int64(parsed)
|
|
479
539
|
return &value
|
|
480
540
|
}
|
|
481
541
|
|
|
542
|
+
// The int64 range as float64 bounds.
|
|
543
|
+
//
|
|
544
|
+
// int64 rather than int, because `int` is 32 bits on the 32-bit platforms ttsc
|
|
545
|
+
// publishes a binary for (`@ttsc/linux-arm`). Bounding by `int` would make the
|
|
546
|
+
// same `@minimum 3000000000` on a `bigint` compile on x64 and either be rejected
|
|
547
|
+
// or silently converted out of range on arm, and the value is already widened to
|
|
548
|
+
// int64 at its only numeric use. Bounding by int64 is what the tag means on
|
|
549
|
+
// every platform.
|
|
550
|
+
//
|
|
551
|
+
// The maximum is exclusive and spelled 2**63 rather than math.MaxInt64, because
|
|
552
|
+
// the inclusive form does not survive the comparison. An untyped constant
|
|
553
|
+
// 9223372036854775807.0 rounds to 2**63 once it meets a float64 operand, so
|
|
554
|
+
// `parsed > max` compares 2**63 against 2**63 and lets the one value through
|
|
555
|
+
// that int64 cannot hold. A strict `>=` against 2**63 is exact instead: no
|
|
556
|
+
// float64 lies between 2**63 - 1024 and 2**63, so rejecting from 2**63 up
|
|
557
|
+
// rejects exactly the magnitudes int64 cannot represent.
|
|
558
|
+
//
|
|
559
|
+
// The minimum needs no such care -- -2**63 is math.MinInt64 and is exactly
|
|
560
|
+
// representable as a float64.
|
|
561
|
+
const (
|
|
562
|
+
metadataCommentTagFactory_INT64_MINIMUM = -9223372036854775808.0
|
|
563
|
+
metadataCommentTagFactory_INT64_EXCLUSIVE_MAXIMUM = 9223372036854775808.0
|
|
564
|
+
)
|
|
565
|
+
|
|
482
566
|
func metadataCommentTagFactory_includes(values []string, target string) bool {
|
|
483
567
|
for _, value := range values {
|
|
484
568
|
if value == target {
|