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.
Files changed (135) hide show
  1. package/lib/http.d.ts +3 -3
  2. package/lib/http.js.map +1 -1
  3. package/lib/http.mjs.map +1 -1
  4. package/lib/internal/_assertGuard.js +13 -3
  5. package/lib/internal/_assertGuard.js.map +1 -1
  6. package/lib/internal/_assertGuard.mjs +4 -2
  7. package/lib/internal/_assertGuard.mjs.map +1 -1
  8. package/lib/internal/_isFormatIdnHostname.js +5 -1
  9. package/lib/internal/_isFormatIdnHostname.js.map +1 -1
  10. package/lib/internal/_isFormatIdnHostname.mjs +1 -1
  11. package/lib/internal/_isFormatIdnHostname.mjs.map +1 -1
  12. package/lib/internal/_isFormatTime.js +19 -2
  13. package/lib/internal/_isFormatTime.js.map +1 -1
  14. package/lib/internal/_isFormatTime.mjs +9 -2
  15. package/lib/internal/_isFormatTime.mjs.map +1 -1
  16. package/lib/internal/_randomArray.js +37 -4
  17. package/lib/internal/_randomArray.js.map +1 -1
  18. package/lib/internal/_randomArray.mjs +16 -3
  19. package/lib/internal/_randomArray.mjs.map +1 -1
  20. package/lib/internal/_randomFormatByte.js +15 -12
  21. package/lib/internal/_randomFormatByte.js.map +1 -1
  22. package/lib/internal/_randomFormatByte.mjs +11 -10
  23. package/lib/internal/_randomFormatByte.mjs.map +1 -1
  24. package/lib/internal/_randomFormatDatetime.mjs +1 -1
  25. package/lib/internal/_randomFormatHostname.d.ts +2 -2
  26. package/lib/internal/_randomFormatHostname.js +2 -2
  27. package/lib/internal/_randomFormatHostname.mjs +2 -2
  28. package/lib/internal/_randomFormatHostname.mjs.map +1 -1
  29. package/lib/internal/_randomFormatIdnHostname.js +9 -10
  30. package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
  31. package/lib/internal/_randomFormatIdnHostname.mjs +3 -4
  32. package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
  33. package/lib/internal/_randomFormatRegex.js +4 -4
  34. package/lib/internal/_randomFormatRegex.js.map +1 -1
  35. package/lib/internal/_randomFormatRegex.mjs +1 -2
  36. package/lib/internal/_randomFormatRegex.mjs.map +1 -1
  37. package/lib/internal/_randomFormatTime.js +15 -10
  38. package/lib/internal/_randomFormatTime.js.map +1 -1
  39. package/lib/internal/_randomFormatTime.mjs +6 -3
  40. package/lib/internal/_randomFormatTime.mjs.map +1 -1
  41. package/lib/internal/_randomPattern.js +20 -3
  42. package/lib/internal/_randomPattern.js.map +1 -1
  43. package/lib/internal/_randomPattern.mjs +5 -1
  44. package/lib/internal/_randomPattern.mjs.map +1 -1
  45. package/lib/internal/_randomStringLength.js +9 -2
  46. package/lib/internal/_randomStringLength.js.map +1 -1
  47. package/lib/internal/_randomStringLength.mjs +3 -1
  48. package/lib/internal/_randomStringLength.mjs.map +1 -1
  49. package/lib/internal/private/__randomComposition.d.ts +8 -0
  50. package/lib/internal/private/__randomComposition.js +21 -1
  51. package/lib/internal/private/__randomComposition.js.map +1 -1
  52. package/lib/internal/private/__randomComposition.mjs +18 -1
  53. package/lib/internal/private/__randomComposition.mjs.map +1 -1
  54. package/lib/json.d.ts +2 -2
  55. package/lib/json.js.map +1 -1
  56. package/lib/json.mjs.map +1 -1
  57. package/lib/module.d.ts +28 -13
  58. package/lib/module.js.map +1 -1
  59. package/lib/module.mjs.map +1 -1
  60. package/lib/notations.d.ts +4 -4
  61. package/lib/notations.js.map +1 -1
  62. package/lib/notations.mjs.map +1 -1
  63. package/lib/plain.d.ts +3 -3
  64. package/lib/plain.js.map +1 -1
  65. package/lib/plain.mjs.map +1 -1
  66. package/lib/protobuf.d.ts +2 -2
  67. package/lib/protobuf.js.map +1 -1
  68. package/lib/protobuf.mjs.map +1 -1
  69. package/lib/transform.mjs +1 -1
  70. package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +17 -4
  71. package/native/cmd/ttsc-typia/create_assert_error_factory_arity_test.go +309 -0
  72. package/native/cmd/ttsc-typia/dynamic_key_tags_transform_test.go +206 -0
  73. package/native/cmd/ttsc-typia/local_function_named_like_typia_operation_transform_test.go +185 -0
  74. package/native/cmd/ttsc-typia/notation_kebab_case_transform_test.go +2 -2
  75. package/native/cmd/ttsc-typia/project_catalog_transform_coverage_test.go +84 -85
  76. package/native/cmd/ttsc-typia/recursive_conditional_alias_name_transform_test.go +307 -0
  77. package/native/cmd/ttsc-typia/shadowed_typia_module_declaration_diagnostic_test.go +152 -0
  78. package/native/cmd/ttsc-typia/transform.go +2 -2
  79. package/native/cmd/ttsc-typia/transform_helpers_test.go +96 -18
  80. package/native/core/factories/FormatCheatSheet.go +2 -2
  81. package/native/core/factories/MetadataCommentTagFactory.go +91 -7
  82. package/native/core/factories/factory_utility_coverage_test.go +896 -907
  83. package/native/core/factories/internal/metadata/MetadataHelper.go +5 -28
  84. package/native/core/factories/metadata_comment_tag_factory_rejects_out_of_range_integer_test.go +124 -0
  85. package/native/core/programmers/AssertProgrammer.go +20 -6
  86. package/native/core/programmers/RandomProgrammer.go +78 -3
  87. package/native/core/programmers/ValidateProgrammer.go +21 -6
  88. package/native/core/programmers/helpers/RandomJoiner.go +8 -1
  89. package/native/core/programmers/iterate/check_dynamic_properties.go +177 -3
  90. package/native/core/programmers/iterate/check_object.go +12 -1
  91. package/native/core/schemas/metadata/MetadataCollection.go +47 -5
  92. package/native/transform/CallExpressionTransformer.go +167 -0
  93. package/package.json +3 -12
  94. package/src/http.ts +18 -4
  95. package/src/internal/_assertGuard.ts +13 -2
  96. package/src/internal/_isFormatIdnHostname.ts +5 -1
  97. package/src/internal/_isFormatTime.ts +19 -2
  98. package/src/internal/_randomArray.ts +42 -6
  99. package/src/internal/_randomFormatByte.ts +17 -12
  100. package/src/internal/_randomFormatHostname.ts +2 -2
  101. package/src/internal/_randomFormatIdnHostname.ts +8 -9
  102. package/src/internal/_randomFormatRegex.ts +4 -6
  103. package/src/internal/_randomFormatTime.ts +15 -10
  104. package/src/internal/_randomPattern.ts +18 -3
  105. package/src/internal/_randomStringLength.ts +9 -2
  106. package/src/internal/private/__randomComposition.ts +24 -0
  107. package/src/json.ts +16 -4
  108. package/src/module.ts +56 -22
  109. package/src/notations.ts +16 -4
  110. package/src/plain.ts +12 -3
  111. package/src/protobuf.ts +16 -4
  112. package/lib/executable/FileSystemIdentity.d.ts +0 -44
  113. package/lib/executable/FileSystemIdentity.js +0 -213
  114. package/lib/executable/FileSystemIdentity.js.map +0 -1
  115. package/lib/executable/FileSystemIdentity.mjs +0 -133
  116. package/lib/executable/FileSystemIdentity.mjs.map +0 -1
  117. package/lib/executable/TypiaGenerateWizard.d.ts +0 -9
  118. package/lib/executable/TypiaGenerateWizard.js +0 -852
  119. package/lib/executable/TypiaGenerateWizard.js.map +0 -1
  120. package/lib/executable/TypiaGenerateWizard.mjs +0 -618
  121. package/lib/executable/TypiaGenerateWizard.mjs.map +0 -1
  122. package/lib/executable/generate/ttsc.d.ts +0 -1
  123. package/lib/executable/generate/ttsc.js +0 -53
  124. package/lib/executable/generate/ttsc.js.map +0 -1
  125. package/lib/executable/generate/ttsc.mjs +0 -37
  126. package/lib/executable/generate/ttsc.mjs.map +0 -1
  127. package/lib/executable/typia.d.ts +0 -2
  128. package/lib/executable/typia.js +0 -84
  129. package/lib/executable/typia.js.map +0 -1
  130. package/lib/executable/typia.mjs +0 -60
  131. package/lib/executable/typia.mjs.map +0 -1
  132. package/src/executable/FileSystemIdentity.ts +0 -222
  133. package/src/executable/TypiaGenerateWizard.ts +0 -1133
  134. package/src/executable/generate/ttsc.ts +0 -70
  135. 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
- // The bigint form used to emit `true` for int64 and a lower bound only for
411
- // uint64, so `bigint & Type<"int64">` -- the spelling the documentation
412
- // recommends -- certified any magnitude at all. Both now delegate to the
413
- // helper that holds the exact inclusive bound a bigint can represent.
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: int64(*integer), Validate: bigintValidate, Exclusive: exclusive, Schema: map[string]any{kind: number}}}
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
- }) *int {
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
- value := int(parsed)
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 {