typia 13.1.19 → 13.3.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 (235) hide show
  1. package/lib/executable/FileSystemIdentity.d.ts +23 -0
  2. package/lib/executable/FileSystemIdentity.js +30 -0
  3. package/lib/executable/FileSystemIdentity.js.map +1 -1
  4. package/lib/executable/FileSystemIdentity.mjs +4 -0
  5. package/lib/executable/FileSystemIdentity.mjs.map +1 -1
  6. package/lib/executable/TypiaGenerateWizard.js +15 -9
  7. package/lib/executable/TypiaGenerateWizard.js.map +1 -1
  8. package/lib/executable/TypiaGenerateWizard.mjs +11 -7
  9. package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
  10. package/lib/http.d.ts +3 -3
  11. package/lib/http.js.map +1 -1
  12. package/lib/http.mjs.map +1 -1
  13. package/lib/internal/_ProtobufReader.d.ts +18 -3
  14. package/lib/internal/_ProtobufReader.js +39 -11
  15. package/lib/internal/_ProtobufReader.js.map +1 -1
  16. package/lib/internal/_ProtobufReader.mjs +37 -10
  17. package/lib/internal/_ProtobufReader.mjs.map +1 -1
  18. package/lib/internal/_assertGuard.js +13 -3
  19. package/lib/internal/_assertGuard.js.map +1 -1
  20. package/lib/internal/_assertGuard.mjs +4 -2
  21. package/lib/internal/_assertGuard.mjs.map +1 -1
  22. package/lib/internal/_isFormatIdnHostname.js +5 -1
  23. package/lib/internal/_isFormatIdnHostname.js.map +1 -1
  24. package/lib/internal/_isFormatIdnHostname.mjs +1 -1
  25. package/lib/internal/_isFormatIdnHostname.mjs.map +1 -1
  26. package/lib/internal/_isFormatTime.js +19 -2
  27. package/lib/internal/_isFormatTime.js.map +1 -1
  28. package/lib/internal/_isFormatTime.mjs +9 -2
  29. package/lib/internal/_isFormatTime.mjs.map +1 -1
  30. package/lib/internal/_jsonStringifyArray.d.ts +1 -0
  31. package/lib/internal/_jsonStringifyArray.js +48 -0
  32. package/lib/internal/_jsonStringifyArray.js.map +1 -0
  33. package/lib/internal/_jsonStringifyArray.mjs +40 -0
  34. package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
  35. package/lib/internal/_jsonStringifyElement.d.ts +1 -0
  36. package/lib/internal/_jsonStringifyElement.js +23 -0
  37. package/lib/internal/_jsonStringifyElement.js.map +1 -0
  38. package/lib/internal/_jsonStringifyElement.mjs +23 -0
  39. package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
  40. package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
  41. package/lib/internal/_jsonStringifyProperty.js +31 -0
  42. package/lib/internal/_jsonStringifyProperty.js.map +1 -0
  43. package/lib/internal/_jsonStringifyProperty.mjs +31 -0
  44. package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
  45. package/lib/internal/_llmApplicationFinalize.js +1 -1
  46. package/lib/internal/_llmApplicationFinalize.js.map +1 -1
  47. package/lib/internal/_llmApplicationFinalize.mjs +1 -1
  48. package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
  49. package/lib/internal/_randomArray.js +37 -4
  50. package/lib/internal/_randomArray.js.map +1 -1
  51. package/lib/internal/_randomArray.mjs +16 -3
  52. package/lib/internal/_randomArray.mjs.map +1 -1
  53. package/lib/internal/_randomFormatByte.js +28 -2
  54. package/lib/internal/_randomFormatByte.js.map +1 -1
  55. package/lib/internal/_randomFormatByte.mjs +22 -3
  56. package/lib/internal/_randomFormatByte.mjs.map +1 -1
  57. package/lib/internal/_randomFormatDate.d.ts +3 -6
  58. package/lib/internal/_randomFormatDate.js +2 -10
  59. package/lib/internal/_randomFormatDate.js.map +1 -1
  60. package/lib/internal/_randomFormatDate.mjs +2 -6
  61. package/lib/internal/_randomFormatDate.mjs.map +1 -1
  62. package/lib/internal/_randomFormatDatetime.d.ts +3 -6
  63. package/lib/internal/_randomFormatDatetime.js +25 -8
  64. package/lib/internal/_randomFormatDatetime.js.map +1 -1
  65. package/lib/internal/_randomFormatDatetime.mjs +17 -7
  66. package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
  67. package/lib/internal/_randomFormatDuration.js +23 -15
  68. package/lib/internal/_randomFormatDuration.js.map +1 -1
  69. package/lib/internal/_randomFormatDuration.mjs +23 -15
  70. package/lib/internal/_randomFormatDuration.mjs.map +1 -1
  71. package/lib/internal/_randomFormatHostname.d.ts +2 -2
  72. package/lib/internal/_randomFormatHostname.js +2 -2
  73. package/lib/internal/_randomFormatHostname.mjs +2 -2
  74. package/lib/internal/_randomFormatHostname.mjs.map +1 -1
  75. package/lib/internal/_randomFormatIdnHostname.js +9 -10
  76. package/lib/internal/_randomFormatIdnHostname.js.map +1 -1
  77. package/lib/internal/_randomFormatIdnHostname.mjs +3 -4
  78. package/lib/internal/_randomFormatIdnHostname.mjs.map +1 -1
  79. package/lib/internal/_randomFormatIpv4.js +31 -1
  80. package/lib/internal/_randomFormatIpv4.js.map +1 -1
  81. package/lib/internal/_randomFormatIpv4.mjs +23 -2
  82. package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
  83. package/lib/internal/_randomFormatIpv6.js +57 -1
  84. package/lib/internal/_randomFormatIpv6.js.map +1 -1
  85. package/lib/internal/_randomFormatIpv6.mjs +45 -2
  86. package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
  87. package/lib/internal/_randomFormatJsonPointer.js +14 -2
  88. package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
  89. package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
  90. package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
  91. package/lib/internal/_randomFormatRegex.js +15 -2
  92. package/lib/internal/_randomFormatRegex.js.map +1 -1
  93. package/lib/internal/_randomFormatRegex.mjs +14 -3
  94. package/lib/internal/_randomFormatRegex.mjs.map +1 -1
  95. package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
  96. package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
  97. package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
  98. package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
  99. package/lib/internal/_randomFormatTime.js +38 -7
  100. package/lib/internal/_randomFormatTime.js.map +1 -1
  101. package/lib/internal/_randomFormatTime.mjs +40 -5
  102. package/lib/internal/_randomFormatTime.mjs.map +1 -1
  103. package/lib/internal/_randomPattern.js.map +1 -1
  104. package/lib/internal/_randomPattern.mjs.map +1 -1
  105. package/lib/internal/_randomStringLength.d.ts +41 -10
  106. package/lib/internal/_randomStringLength.js +49 -13
  107. package/lib/internal/_randomStringLength.js.map +1 -1
  108. package/lib/internal/_randomStringLength.mjs +48 -13
  109. package/lib/internal/_randomStringLength.mjs.map +1 -1
  110. package/lib/internal/private/__notationRename.js.map +1 -1
  111. package/lib/internal/private/__notationRename.mjs.map +1 -1
  112. package/lib/internal/private/__randomComposition.d.ts +31 -0
  113. package/lib/internal/private/__randomComposition.js +68 -0
  114. package/lib/internal/private/__randomComposition.js.map +1 -0
  115. package/lib/internal/private/__randomComposition.mjs +71 -0
  116. package/lib/internal/private/__randomComposition.mjs.map +1 -0
  117. package/lib/internal/private/__randomEpoch.d.ts +19 -0
  118. package/lib/internal/private/__randomEpoch.js +31 -0
  119. package/lib/internal/private/__randomEpoch.js.map +1 -0
  120. package/lib/internal/private/__randomEpoch.mjs +28 -0
  121. package/lib/internal/private/__randomEpoch.mjs.map +1 -0
  122. package/lib/json.d.ts +2 -2
  123. package/lib/json.js.map +1 -1
  124. package/lib/json.mjs.map +1 -1
  125. package/lib/module.d.ts +28 -13
  126. package/lib/module.js.map +1 -1
  127. package/lib/module.mjs.map +1 -1
  128. package/lib/notations.d.ts +4 -4
  129. package/lib/notations.js.map +1 -1
  130. package/lib/notations.mjs.map +1 -1
  131. package/lib/plain.d.ts +3 -3
  132. package/lib/plain.js.map +1 -1
  133. package/lib/plain.mjs.map +1 -1
  134. package/lib/protobuf.d.ts +2 -2
  135. package/lib/protobuf.js.map +1 -1
  136. package/lib/protobuf.mjs.map +1 -1
  137. package/native/cmd/ttsc-typia/assert_guard_factory_contract_test.go +17 -4
  138. package/native/cmd/ttsc-typia/build.go +3 -0
  139. package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
  140. package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
  141. package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
  142. package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
  143. package/native/cmd/ttsc-typia/create_assert_error_factory_arity_test.go +309 -0
  144. package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
  145. package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
  146. package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
  147. package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
  148. package/native/cmd/ttsc-typia/local_function_named_like_typia_operation_transform_test.go +185 -0
  149. package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
  150. package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
  151. package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
  152. package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
  153. package/native/cmd/ttsc-typia/recursive_conditional_alias_name_transform_test.go +307 -0
  154. package/native/cmd/ttsc-typia/shadowed_typia_module_declaration_diagnostic_test.go +152 -0
  155. package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
  156. package/native/cmd/ttsc-typia/template_literal_type_tags_transform_test.go +1 -3
  157. package/native/cmd/ttsc-typia/transform.go +23 -0
  158. package/native/cmd/ttsc-typia/transform_helpers_test.go +166 -25
  159. package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
  160. package/native/core/factories/FormatCheatSheet.go +2 -2
  161. package/native/core/factories/MetadataCommentTagFactory.go +26 -11
  162. package/native/core/factories/ProtobufFactory.go +6 -1
  163. package/native/core/factories/factory_utility_coverage_test.go +896 -907
  164. package/native/core/factories/internal/metadata/MetadataHelper.go +190 -58
  165. package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
  166. package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
  167. package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
  168. package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
  169. package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
  170. package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
  171. package/native/core/factories/metadata_comment_tag_factory_coverage_test.go +2 -2
  172. package/native/core/programmers/RandomProgrammer.go +5 -2
  173. package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
  174. package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
  175. package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
  176. package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
  177. package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
  178. package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
  179. package/native/core/programmers/iterate/json_schema_object.go +49 -7
  180. package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
  181. package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
  182. package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
  183. package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
  184. package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
  185. package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
  186. package/native/core/schemas/metadata/MetadataCollection.go +47 -14
  187. package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
  188. package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
  189. package/native/go.mod +4 -4
  190. package/native/transform/CallExpressionTransformer.go +167 -0
  191. package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
  192. package/package.json +3 -7
  193. package/src/executable/FileSystemIdentity.ts +33 -0
  194. package/src/executable/TypiaGenerateWizard.ts +18 -12
  195. package/src/http.ts +18 -4
  196. package/src/internal/_ProtobufReader.ts +40 -11
  197. package/src/internal/_assertGuard.ts +13 -2
  198. package/src/internal/_isFormatIdnHostname.ts +5 -1
  199. package/src/internal/_isFormatTime.ts +19 -2
  200. package/src/internal/_jsonStringifyArray.ts +50 -0
  201. package/src/internal/_jsonStringifyElement.ts +19 -0
  202. package/src/internal/_jsonStringifyProperty.ts +30 -0
  203. package/src/internal/_llmApplicationFinalize.ts +6 -1
  204. package/src/internal/_randomArray.ts +42 -6
  205. package/src/internal/_randomFormatByte.ts +36 -4
  206. package/src/internal/_randomFormatDate.ts +4 -20
  207. package/src/internal/_randomFormatDatetime.ts +34 -20
  208. package/src/internal/_randomFormatDuration.ts +19 -4
  209. package/src/internal/_randomFormatHostname.ts +2 -2
  210. package/src/internal/_randomFormatIdnHostname.ts +8 -9
  211. package/src/internal/_randomFormatIpv4.ts +43 -3
  212. package/src/internal/_randomFormatIpv6.ts +67 -3
  213. package/src/internal/_randomFormatJsonPointer.ts +23 -3
  214. package/src/internal/_randomFormatRegex.ts +22 -6
  215. package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
  216. package/src/internal/_randomFormatTime.ts +50 -12
  217. package/src/internal/_randomPattern.ts +4 -1
  218. package/src/internal/_randomStringLength.ts +61 -17
  219. package/src/internal/private/__notationRename.ts +1 -4
  220. package/src/internal/private/__randomComposition.ts +74 -0
  221. package/src/internal/private/__randomEpoch.ts +34 -0
  222. package/src/json.ts +16 -4
  223. package/src/module.ts +56 -22
  224. package/src/notations.ts +16 -4
  225. package/src/plain.ts +12 -3
  226. package/src/protobuf.ts +16 -4
  227. package/native/adapter/visit.go +0 -173
  228. package/native/adapter/visit_property_chain_edges_test.go +0 -129
  229. package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
  230. package/native/core/programmers/iterate/check_union_array_like.go +0 -422
  231. package/native/core/programmers/iterate/prune_object_properties.go +0 -105
  232. package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
  233. package/native/core/programmers/iterate/stringify_native.go +0 -14
  234. package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
  235. package/native/core/schemas/metadata/MetadataApplication.go +0 -41
@@ -4,13 +4,12 @@ import { _randomHostnameLabels } from "./_randomFormatHostname.mjs";
4
4
  //#region src/internal/_randomFormatIdnHostname.ts
5
5
  const _randomFormatIdnHostname = (props) => {
6
6
  if (props?.minLength === void 0 && props?.maxLength === void 0) return `${random(10)}.${random(3)}`;
7
- return `${_randomHostnameLabels(pickLength(props) - 3)}.${random(2)}`;
7
+ return _randomHostnameLabels(pickLength(props));
8
8
  };
9
9
  const MAX_TOTAL = 253;
10
- const MIN_TOTAL = 4;
11
10
  const pickLength = (props) => {
12
- let low = props.minLength === void 0 ? MIN_TOTAL : props.minLength;
13
- if (low < MIN_TOTAL) low = MIN_TOTAL;
11
+ let low = props.minLength === void 0 ? 1 : props.minLength;
12
+ if (low < 1) low = 1;
14
13
  const high = props.maxLength === void 0 ? Math.min(MAX_TOTAL, low + 14) : Math.min(MAX_TOTAL, props.maxLength);
15
14
  if (high < low) throw new Error("unable to generate a random idn hostname satisfying both the format and the length constraints.");
16
15
  return _randomInteger({
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatIdnHostname.mjs","names":[],"sources":["../../src/internal/_randomFormatIdnHostname.ts"],"sourcesContent":["import { _randomHostnameLabels } from \"./_randomFormatHostname\";\nimport { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomFormatIdnHostname = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${random(10)}.${random(3)}`;\n // `_isFormatIdnHostname` requires at least one label, a dot, and a >=2-char\n // TLD (`(…\\.)+[a-z¡-￿]{2,}`), none of which the non-idn hostname generator\n // guarantees on its length path (it can emit a single dotless label). Reserve\n // a fixed `.<2-char TLD>` and realize the rest as dot-joined leading labels.\n const length: number = pickLength(props);\n return `${_randomHostnameLabels(length - 3)}.${random(2)}`;\n};\n\nconst MAX_TOTAL = 253;\nconst MIN_TOTAL = 4; // the shortest idn hostname, `x.yy`: label(1) + `.` + tld(2)\n\nconst pickLength = (props: _ILengthProps): number => {\n let low: number = props.minLength === undefined ? MIN_TOTAL : props.minLength;\n if (low < MIN_TOTAL) low = MIN_TOTAL;\n const high: number =\n props.maxLength === undefined\n ? Math.min(MAX_TOTAL, low + 14)\n : Math.min(MAX_TOTAL, props.maxLength);\n if (high < low)\n throw new Error(\n \"unable to generate a random idn hostname satisfying both the format and the length constraints.\",\n );\n return _randomInteger({ type: \"integer\", minimum: low, maximum: high });\n};\n\nconst random = (length: number) =>\n _randomString({ type: \"string\", minLength: length, maxLength: length });\n"],"mappings":";;;;AAKA,MAAa,4BAA4B,UAAkC;CACzE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC;CAMlC,OAAO,GAAG,sBADa,WAAW,KACG,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;AACzD;AAEA,MAAM,YAAY;AAClB,MAAM,YAAY;AAElB,MAAM,cAAc,UAAiC;CACnD,IAAI,MAAc,MAAM,cAAc,KAAA,IAAY,YAAY,MAAM;CACpE,IAAI,MAAM,WAAW,MAAM;CAC3B,MAAM,OACJ,MAAM,cAAc,KAAA,IAChB,KAAK,IAAI,WAAW,MAAM,EAAE,IAC5B,KAAK,IAAI,WAAW,MAAM,SAAS;CACzC,IAAI,OAAO,KACT,MAAM,IAAI,MACR,iGACF;CACF,OAAO,eAAe;EAAE,MAAM;EAAW,SAAS;EAAK,SAAS;CAAK,CAAC;AACxE;AAEA,MAAM,UAAU,WACd,cAAc;CAAE,MAAM;CAAU,WAAW;CAAQ,WAAW;AAAO,CAAC"}
1
+ {"version":3,"file":"_randomFormatIdnHostname.mjs","names":[],"sources":["../../src/internal/_randomFormatIdnHostname.ts"],"sourcesContent":["import { _randomHostnameLabels } from \"./_randomFormatHostname\";\nimport { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport { _ILengthProps } from \"./_randomStringLength\";\n\nexport const _randomFormatIdnHostname = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${random(10)}.${random(3)}`;\n // idn-hostname shares hostname's structure (a single label of 1..63 chars is\n // valid, no dot or trailing label required), so the requested length is\n // realized the same way: split it across dot-joined labels. #2317 dropped the\n // mandatory dot and two-character trailing label this generator used to\n // reserve, which is why it now realizes a length below four.\n return _randomHostnameLabels(pickLength(props));\n};\n\nconst MAX_TOTAL = 253;\n\nconst pickLength = (props: _ILengthProps): number => {\n let low: number = props.minLength === undefined ? 1 : props.minLength;\n if (low < 1) low = 1;\n const high: number =\n props.maxLength === undefined\n ? Math.min(MAX_TOTAL, low + 14)\n : Math.min(MAX_TOTAL, props.maxLength);\n if (high < low)\n throw new Error(\n \"unable to generate a random idn hostname satisfying both the format and the length constraints.\",\n );\n return _randomInteger({ type: \"integer\", minimum: low, maximum: high });\n};\n\nconst random = (length: number) =>\n _randomString({ type: \"string\", minLength: length, maxLength: length });\n"],"mappings":";;;;AAKA,MAAa,4BAA4B,UAAkC;CACzE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC;CAMlC,OAAO,sBAAsB,WAAW,KAAK,CAAC;AAChD;AAEA,MAAM,YAAY;AAElB,MAAM,cAAc,UAAiC;CACnD,IAAI,MAAc,MAAM,cAAc,KAAA,IAAY,IAAI,MAAM;CAC5D,IAAI,MAAM,GAAG,MAAM;CACnB,MAAM,OACJ,MAAM,cAAc,KAAA,IAChB,KAAK,IAAI,WAAW,MAAM,EAAE,IAC5B,KAAK,IAAI,WAAW,MAAM,SAAS;CACzC,IAAI,OAAO,KACT,MAAM,IAAI,MACR,iGACF;CACF,OAAO,eAAe;EAAE,MAAM;EAAW,SAAS;EAAK,SAAS;CAAK,CAAC;AACxE;AAEA,MAAM,UAAU,WACd,cAAc;CAAE,MAAM;CAAU,WAAW;CAAQ,WAAW;AAAO,CAAC"}
@@ -3,11 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._randomFormatIpv4 = void 0;
4
4
  const _randomInteger_1 = require("./_randomInteger");
5
5
  const _randomStringLength_1 = require("./_randomStringLength");
6
- const _randomFormatIpv4 = (props) => (0, _randomStringLength_1._randomFormatLength)(props, () => new Array(4).fill(0).map(random).join("."));
6
+ const __randomComposition_1 = require("./private/__randomComposition");
7
+ const _randomFormatIpv4 = (props) => {
8
+ if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
9
+ return new Array(4).fill(0).map(random).join(".");
10
+ // Three dots plus four octets of one to three digits: `0.0.0.0` is the
11
+ // shortest address and `255.255.255.255` the longest, and every length
12
+ // between them is reached by choosing how many digits each octet spends.
13
+ const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, {
14
+ minimum: 4 * DIGITS_MIN + DOTS,
15
+ maximum: 4 * DIGITS_MAX + DOTS,
16
+ spread: 8,
17
+ }));
18
+ return (0, __randomComposition_1.__randomComposition)({
19
+ total: length - DOTS,
20
+ count: 4,
21
+ minimum: DIGITS_MIN,
22
+ maximum: DIGITS_MAX,
23
+ })
24
+ .map(octet)
25
+ .join(".");
26
+ };
7
27
  exports._randomFormatIpv4 = _randomFormatIpv4;
28
+ const DOTS = 3;
29
+ const DIGITS_MIN = 1;
30
+ const DIGITS_MAX = 3;
8
31
  const random = () => (0, _randomInteger_1._randomInteger)({
9
32
  type: "integer",
10
33
  minimum: 0,
11
34
  maximum: 255,
12
35
  });
36
+ // An octet is bounded by 255, so a three-digit one starts at 100 and stops
37
+ // there rather than at 999.
38
+ const octet = (digits) => String((0, _randomInteger_1._randomInteger)({
39
+ type: "integer",
40
+ minimum: digits === 1 ? 0 : Math.pow(10, digits - 1),
41
+ maximum: digits === 3 ? 255 : Math.pow(10, digits) - 1,
42
+ }));
13
43
  //# sourceMappingURL=_randomFormatIpv4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatIpv4.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv4.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAA2E;AAEpE,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE,CACjE,IAAA,yCAAmB,EAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AADlE,QAAA,iBAAiB,GAAjB,iBAAiB,CACiD;AAE/E,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,IAAA,+BAAc,EAAC;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,GAAG;CACb,CAAC,CAAC"}
1
+ {"version":3,"file":"_randomFormatIpv4.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv4.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAI+B;AAC/B,uEAAoE;AAE7D,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACjE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,uEAAuE;IACvE,uEAAuE;IACvE,y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ger } from "./_randomInteger.mjs";
2
- import { _randomFormatLength } from "./_randomStringLength.mjs";
2
+ import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
3
+ import { __randomComposition } from "./private/__randomComposition.mjs";
3
4
  //#region src/internal/_randomFormatIpv4.ts
4
- const _randomFormatIpv4 = (props) => _randomFormatLength(props, () => new Array(4).fill(0).map(random).join("."));
5
+ const _randomFormatIpv4 = (props) => {
6
+ if (props?.minLength === void 0 && props?.maxLength === void 0) return new Array(4).fill(0).map(random).join(".");
7
+ return __randomComposition({
8
+ total: _randomLengthPick(_randomLengthWindow(props, {
9
+ minimum: 4 * DIGITS_MIN + DOTS,
10
+ maximum: 4 * DIGITS_MAX + DOTS,
11
+ spread: 8
12
+ })) - DOTS,
13
+ count: 4,
14
+ minimum: DIGITS_MIN,
15
+ maximum: DIGITS_MAX
16
+ }).map(octet).join(".");
17
+ };
18
+ const DOTS = 3;
19
+ const DIGITS_MIN = 1;
20
+ const DIGITS_MAX = 3;
5
21
  const random = () => _randomInteger({
6
22
  type: "integer",
7
23
  minimum: 0,
8
24
  maximum: 255
9
25
  });
26
+ const octet = (digits) => String(_randomInteger({
27
+ type: "integer",
28
+ minimum: digits === 1 ? 0 : Math.pow(10, digits - 1),
29
+ maximum: digits === 3 ? 255 : Math.pow(10, digits) - 1
30
+ }));
10
31
  //#endregion
11
32
  export { _randomFormatIpv4 };
12
33
 
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatIpv4.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv4.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _ILengthProps, _randomFormatLength } from \"./_randomStringLength\";\n\nexport const _randomFormatIpv4 = (props?: _ILengthProps): string =>\n _randomFormatLength(props, () => new Array(4).fill(0).map(random).join(\".\"));\n\nconst random = () =>\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 255,\n });\n"],"mappings":";;;AAGA,MAAa,qBAAqB,UAChC,oBAAoB,aAAa,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG,CAAC;AAE7E,MAAM,eACJ,eAAe;CACb,MAAM;CACN,SAAS;CACT,SAAS;AACX,CAAC"}
1
+ {"version":3,"file":"_randomFormatIpv4.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv4.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomComposition } from \"./private/__randomComposition\";\n\nexport const _randomFormatIpv4 = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return new Array(4).fill(0).map(random).join(\".\");\n // Three dots plus four octets of one to three digits: `0.0.0.0` is the\n // shortest address and `255.255.255.255` the longest, and every length\n // between them is reached by choosing how many digits each octet spends.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, {\n minimum: 4 * DIGITS_MIN + DOTS,\n maximum: 4 * DIGITS_MAX + DOTS,\n spread: 8,\n }),\n );\n return __randomComposition({\n total: length - DOTS,\n count: 4,\n minimum: DIGITS_MIN,\n maximum: DIGITS_MAX,\n })\n .map(octet)\n .join(\".\");\n};\n\nconst DOTS = 3;\nconst DIGITS_MIN = 1;\nconst DIGITS_MAX = 3;\n\nconst random = () =>\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 255,\n });\n\n// An octet is bounded by 255, so a three-digit one starts at 100 and stops\n// there rather than at 999.\nconst octet = (digits: number): string =>\n String(\n _randomInteger({\n type: \"integer\",\n minimum: digits === 1 ? 0 : Math.pow(10, digits - 1),\n maximum: digits === 3 ? 255 : Math.pow(10, digits) - 1,\n }),\n );\n"],"mappings":";;;;AAQA,MAAa,qBAAqB,UAAkC;CAClE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG;CAWlD,OAAO,oBAAoB;EACzB,OARqB,kBACrB,oBAAoB,OAAO;GACzB,SAAS,IAAI,aAAa;GAC1B,SAAS,IAAI,aAAa;GAC1B,QAAQ;EACV,CAAC,CAGW,IAAI;EAChB,OAAO;EACP,SAAS;EACT,SAAS;CACX,CAAC,CAAC,CACC,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;AACb;AAEA,MAAM,OAAO;AACb,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,eACJ,eAAe;CACb,MAAM;CACN,SAAS;CACT,SAAS;AACX,CAAC;AAIH,MAAM,SAAS,WACb,OACE,eAAe;CACb,MAAM;CACN,SAAS,WAAW,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,CAAC;CACnD,SAAS,WAAW,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,IAAI;AACvD,CAAC,CACH"}
@@ -1,13 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._randomFormatIpv6 = void 0;
4
+ const _randomFormatIpv4_1 = require("./_randomFormatIpv4");
4
5
  const _randomInteger_1 = require("./_randomInteger");
5
6
  const _randomStringLength_1 = require("./_randomStringLength");
6
- const _randomFormatIpv6 = (props) => (0, _randomStringLength_1._randomFormatLength)(props, () => new Array(8).fill(0).map(random).join(":"));
7
+ const __randomComposition_1 = require("./private/__randomComposition");
8
+ const _randomFormatIpv6 = (props) => {
9
+ if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
10
+ return new Array(GROUPS).fill(0).map(random).join(":");
11
+ const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, {
12
+ minimum: SHORTEST,
13
+ maximum: LONGEST,
14
+ spread: 12,
15
+ }));
16
+ // `::` alone is the all-zero address, and the three forms below cover every
17
+ // length between it and the padded IPv4-suffixed address: a compressed prefix
18
+ // for the short ones, eight groups of one to four hexadecimal digits for the
19
+ // middle, and six groups plus a dotted-quad tail for the long ones.
20
+ if (length === SHORTEST)
21
+ return "::";
22
+ if (length < GROUPS * DIGITS_MIN + COLONS) {
23
+ // `::` plus `count` groups spends one colon between each pair.
24
+ const count = Math.ceil((length - 1) / (DIGITS_MAX + 1));
25
+ return `::${compose(length - 1 - count, count)}`;
26
+ }
27
+ if (length <= GROUPS * DIGITS_MAX + COLONS)
28
+ return compose(length - COLONS, GROUPS);
29
+ // The dotted-quad tail is drawn at its longest so the six leading groups keep
30
+ // a composable number of digits.
31
+ const tail = (0, _randomFormatIpv4_1._randomFormatIpv4)({
32
+ minLength: IPV4_MAX,
33
+ maxLength: IPV4_MAX,
34
+ });
35
+ return `${compose(length - IPV4_MAX - EMBEDDED, EMBEDDED)}:${tail}`;
36
+ };
7
37
  exports._randomFormatIpv6 = _randomFormatIpv6;
38
+ const GROUPS = 8;
39
+ const COLONS = GROUPS - 1;
40
+ const DIGITS_MIN = 1;
41
+ const DIGITS_MAX = 4;
42
+ const EMBEDDED = 6; // groups preceding a dotted-quad tail
43
+ const IPV4_MAX = "255.255.255.255".length;
44
+ const SHORTEST = "::".length;
45
+ const LONGEST = EMBEDDED * DIGITS_MAX + EMBEDDED + IPV4_MAX;
46
+ const compose = (digits, count) => (0, __randomComposition_1.__randomComposition)({
47
+ total: digits,
48
+ count,
49
+ minimum: DIGITS_MIN,
50
+ maximum: DIGITS_MAX,
51
+ })
52
+ .map(group)
53
+ .join(":");
8
54
  const random = () => (0, _randomInteger_1._randomInteger)({
9
55
  type: "integer",
10
56
  minimum: 0,
11
57
  maximum: 65535,
12
58
  }).toString(16);
59
+ const group = (digits) => {
60
+ let text = "";
61
+ for (let i = 0; i < digits; ++i)
62
+ text += (0, _randomInteger_1._randomInteger)({
63
+ type: "integer",
64
+ minimum: 0,
65
+ maximum: 15,
66
+ }).toString(16);
67
+ return text;
68
+ };
13
69
  //# sourceMappingURL=_randomFormatIpv6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatIpv6.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv6.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAA2E;AAEpE,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE,CACjE,IAAA,yCAAmB,EAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AADlE,QAAA,iBAAiB,GAAjB,iBAAiB,CACiD;AAE/E,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,IAAA,+BAAc,EAAC;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,KAAM;CAChB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"_randomFormatIpv6.js","sourceRoot":"","sources":["../../src/internal/_randomFormatIpv6.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AACxD,qDAAkD;AAClD,+DAI+B;AAC/B,uEAAoE;AAE7D,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACjE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE;QACzB,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,OA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M,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5D,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,KAAa,EAAU,EAAE,CACxD,IAAA,yCAAmB,EAAC;IAClB,KAAK,EAAE,MAAM;IACb,KAAK;IACL,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,UAAU;CACpB,CAAC;KACC,GAAG,CAAC,KAAK,CAAC;KACV,IAAI,CAAC,GAAG,CAAC,CAAC;AAEf,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,IAAA,+BAAc,EAAC;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,KAAM;CAChB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAElB,MAAM,KAAK,GAAG,CAAC,MAAc,EAAU,EAAE;IACvC,IAAI,IAAI,GAAW,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,IAAA,+BAAc,EAAC;YACrB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,EAAE;SACZ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,12 +1,55 @@
1
1
  import { _randomInteger } from "./_randomInteger.mjs";
2
- import { _randomFormatLength } from "./_randomStringLength.mjs";
2
+ import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
3
+ import { __randomComposition } from "./private/__randomComposition.mjs";
4
+ import { _randomFormatIpv4 } from "./_randomFormatIpv4.mjs";
3
5
  //#region src/internal/_randomFormatIpv6.ts
4
- const _randomFormatIpv6 = (props) => _randomFormatLength(props, () => new Array(8).fill(0).map(random).join(":"));
6
+ const _randomFormatIpv6 = (props) => {
7
+ if (props?.minLength === void 0 && props?.maxLength === void 0) return new Array(GROUPS).fill(0).map(random).join(":");
8
+ const length = _randomLengthPick(_randomLengthWindow(props, {
9
+ minimum: SHORTEST,
10
+ maximum: LONGEST,
11
+ spread: 12
12
+ }));
13
+ if (length === SHORTEST) return "::";
14
+ if (length < GROUPS * DIGITS_MIN + COLONS) {
15
+ const count = Math.ceil((length - 1) / (DIGITS_MAX + 1));
16
+ return `::${compose(length - 1 - count, count)}`;
17
+ }
18
+ if (length <= GROUPS * DIGITS_MAX + COLONS) return compose(length - COLONS, GROUPS);
19
+ const tail = _randomFormatIpv4({
20
+ minLength: IPV4_MAX,
21
+ maxLength: IPV4_MAX
22
+ });
23
+ return `${compose(length - IPV4_MAX - EMBEDDED, EMBEDDED)}:${tail}`;
24
+ };
25
+ const GROUPS = 8;
26
+ const COLONS = GROUPS - 1;
27
+ const DIGITS_MIN = 1;
28
+ const DIGITS_MAX = 4;
29
+ const EMBEDDED = 6;
30
+ const IPV4_MAX = 15;
31
+ const SHORTEST = 2;
32
+ const LONGEST = 45;
33
+ const compose = (digits, count) => __randomComposition({
34
+ total: digits,
35
+ count,
36
+ minimum: DIGITS_MIN,
37
+ maximum: DIGITS_MAX
38
+ }).map(group).join(":");
5
39
  const random = () => _randomInteger({
6
40
  type: "integer",
7
41
  minimum: 0,
8
42
  maximum: 65535
9
43
  }).toString(16);
44
+ const group = (digits) => {
45
+ let text = "";
46
+ for (let i = 0; i < digits; ++i) text += _randomInteger({
47
+ type: "integer",
48
+ minimum: 0,
49
+ maximum: 15
50
+ }).toString(16);
51
+ return text;
52
+ };
10
53
  //#endregion
11
54
  export { _randomFormatIpv6 };
12
55
 
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatIpv6.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv6.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _ILengthProps, _randomFormatLength } from \"./_randomStringLength\";\n\nexport const _randomFormatIpv6 = (props?: _ILengthProps): string =>\n _randomFormatLength(props, () => new Array(8).fill(0).map(random).join(\":\"));\n\nconst random = () =>\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 65_535,\n }).toString(16);\n"],"mappings":";;;AAGA,MAAa,qBAAqB,UAChC,oBAAoB,aAAa,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG,CAAC;AAE7E,MAAM,eACJ,eAAe;CACb,MAAM;CACN,SAAS;CACT,SAAS;AACX,CAAC,CAAC,CAAC,SAAS,EAAE"}
1
+ {"version":3,"file":"_randomFormatIpv6.mjs","names":[],"sources":["../../src/internal/_randomFormatIpv6.ts"],"sourcesContent":["import { _randomFormatIpv4 } from \"./_randomFormatIpv4\";\nimport { _randomInteger } from \"./_randomInteger\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomComposition } from \"./private/__randomComposition\";\n\nexport const _randomFormatIpv6 = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return new Array(GROUPS).fill(0).map(random).join(\":\");\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, {\n minimum: SHORTEST,\n maximum: LONGEST,\n spread: 12,\n }),\n );\n // `::` alone is the all-zero address, and the three forms below cover every\n // length between it and the padded IPv4-suffixed address: a compressed prefix\n // for the short ones, eight groups of one to four hexadecimal digits for the\n // middle, and six groups plus a dotted-quad tail for the long ones.\n if (length === SHORTEST) return \"::\";\n if (length < GROUPS * DIGITS_MIN + COLONS) {\n // `::` plus `count` groups spends one colon between each pair.\n const count: number = Math.ceil((length - 1) / (DIGITS_MAX + 1));\n return `::${compose(length - 1 - count, count)}`;\n }\n if (length <= GROUPS * DIGITS_MAX + COLONS)\n return compose(length - COLONS, GROUPS);\n // The dotted-quad tail is drawn at its longest so the six leading groups keep\n // a composable number of digits.\n const tail: string = _randomFormatIpv4({\n minLength: IPV4_MAX,\n maxLength: IPV4_MAX,\n });\n return `${compose(length - IPV4_MAX - EMBEDDED, EMBEDDED)}:${tail}`;\n};\n\nconst GROUPS = 8;\nconst COLONS = GROUPS - 1;\nconst DIGITS_MIN = 1;\nconst DIGITS_MAX = 4;\nconst EMBEDDED = 6; // groups preceding a dotted-quad tail\nconst IPV4_MAX = \"255.255.255.255\".length;\nconst SHORTEST = \"::\".length;\nconst LONGEST = EMBEDDED * DIGITS_MAX + EMBEDDED + IPV4_MAX;\n\nconst compose = (digits: number, count: number): string =>\n __randomComposition({\n total: digits,\n count,\n minimum: DIGITS_MIN,\n maximum: DIGITS_MAX,\n })\n .map(group)\n .join(\":\");\n\nconst random = () =>\n _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 65_535,\n }).toString(16);\n\nconst group = (digits: number): string => {\n let text: string = \"\";\n for (let i: number = 0; i < digits; ++i)\n text += _randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 15,\n }).toString(16);\n return text;\n};\n"],"mappings":";;;;;AASA,MAAa,qBAAqB,UAAkC;CAClE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,IAAI,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,GAAG;CACvD,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EACzB,SAAS;EACT,SAAS;EACT,QAAQ;CACV,CAAC,CACH;CAKA,IAAI,WAAW,UAAU,OAAO;CAChC,IAAI,SAAS,SAAS,aAAa,QAAQ;EAEzC,MAAM,QAAgB,KAAK,MAAM,SAAS,MAAM,aAAa,EAAE;EAC/D,OAAO,KAAK,QAAQ,SAAS,IAAI,OAAO,KAAK;CAC/C;CACA,IAAI,UAAU,SAAS,aAAa,QAClC,OAAO,QAAQ,SAAS,QAAQ,MAAM;CAGxC,MAAM,OAAe,kBAAkB;EACrC,WAAW;EACX,WAAW;CACb,CAAC;CACD,OAAO,GAAG,QAAQ,SAAS,WAAW,UAAU,QAAQ,EAAE,GAAG;AAC/D;AAEA,MAAM,SAAS;AACf,MAAM,SAAS,SAAS;AACxB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,UAAU;AAEhB,MAAM,WAAW,QAAgB,UAC/B,oBAAoB;CAClB,OAAO;CACP;CACA,SAAS;CACT,SAAS;AACX,CAAC,CAAC,CACC,IAAI,KAAK,CAAC,CACV,KAAK,GAAG;AAEb,MAAM,eACJ,eAAe;CACb,MAAM;CACN,SAAS;CACT,SAAS;AACX,CAAC,CAAC,CAAC,SAAS,EAAE;AAEhB,MAAM,SAAS,WAA2B;CACxC,IAAI,OAAe;CACnB,KAAK,IAAI,IAAY,GAAG,IAAI,QAAQ,EAAE,GACpC,QAAQ,eAAe;EACrB,MAAM;EACN,SAAS;EACT,SAAS;CACX,CAAC,CAAC,CAAC,SAAS,EAAE;CAChB,OAAO;AACT"}
@@ -5,11 +5,23 @@ const _randomString_1 = require("./_randomString");
5
5
  const _randomStringLength_1 = require("./_randomStringLength");
6
6
  const _randomFormatJsonPointer = (props) => {
7
7
  if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
8
- return `/components/schemas/${random()}`;
8
+ return `${PREFIX}${random()}`;
9
9
  // The `/components/schemas/` prefix (20 chars) is fixed; the reference token
10
10
  // after it grows or shrinks to hit the requested length.
11
- return `/components/schemas/${(0, _randomStringLength_1._randomSegmentLength)(props, 20, 10, 0)}`;
11
+ if (props.maxLength === undefined || props.maxLength >= PREFIX.length)
12
+ return `${PREFIX}${(0, _randomStringLength_1._randomSegmentLength)(props, PREFIX.length, 10, 0)}`;
13
+ // Below that prefix a pointer still exists: the empty pointer addresses the
14
+ // whole document, and one `/`-prefixed token addresses a member of it.
15
+ const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 0, spread: 6 }));
16
+ return length === 0
17
+ ? ""
18
+ : `/${(0, _randomString_1._randomString)({
19
+ type: "string",
20
+ minLength: length - 1,
21
+ maxLength: length - 1,
22
+ })}`;
12
23
  };
13
24
  exports._randomFormatJsonPointer = _randomFormatJsonPointer;
25
+ const PREFIX = "/components/schemas/";
14
26
  const random = () => (0, _randomString_1._randomString)({ type: "string", minLength: 10, maxLength: 10 });
15
27
  //# sourceMappingURL=_randomFormatJsonPointer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatJsonPointer.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+DAA4E;AAErE,MAAM,wBAAwB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACxE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,uBAAuB,MAAM,EAAE,EAAE,CAAC;IAC3C,6EAA6E;IAC7E,yDAAyD;IACzD,OAAO,uBAAuB,IAAA,0CAAoB,EAAC,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;AACzE,CAAC,CAAC;AANW,QAAA,wBAAwB,GAAxB,wBAAwB,CAMnC;AAEF,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,IAAA,6BAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"_randomFormatJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatJsonPointer.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+DAK+B;AAExB,MAAM,wBAAwB,GAAG,CAAC,KAAqB,EAAU,EAAE;IACxE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;IAChC,6EAA6E;IAC7E,yDAAyD;IACzD,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM;QACnE,OAAO,GAAG,MAAM,GAAG,IAAA,0CAAoB,EAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;IACzE,4EAA4E;IAC5E,uEAAuE;IACvE,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CACtD,CAAC;IACF,OAAO,MAAM,KAAK,CAAC;QACjB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,IAAI,IAAA,6BAAa,EAAC;YAChB,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,MAAM,GAAG,CAAC;YACrB,SAAS,EAAE,MAAM,GAAG,CAAC;SACtB,CAAC,EAAE,CAAC;AACX,CAAC,CAAC;AAnBW,QAAA,wBAAwB,GAAxB,wBAAwB,CAmBnC;AAEF,MAAM,MAAM,GAAG,sBAAsB,CAAC;AAEtC,MAAM,MAAM,GAAG,GAAG,EAAE,CAClB,IAAA,6BAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC"}
@@ -1,10 +1,20 @@
1
1
  import { _randomString } from "./_randomString.mjs";
2
- import { _randomSegmentLength } from "./_randomStringLength.mjs";
2
+ import { _randomLengthPick, _randomLengthWindow, _randomSegmentLength } from "./_randomStringLength.mjs";
3
3
  //#region src/internal/_randomFormatJsonPointer.ts
4
4
  const _randomFormatJsonPointer = (props) => {
5
- if (props?.minLength === void 0 && props?.maxLength === void 0) return `/components/schemas/${random()}`;
6
- return `/components/schemas/${_randomSegmentLength(props, 20, 10, 0)}`;
5
+ if (props?.minLength === void 0 && props?.maxLength === void 0) return `${PREFIX}${random()}`;
6
+ if (props.maxLength === void 0 || props.maxLength >= PREFIX.length) return `${PREFIX}${_randomSegmentLength(props, PREFIX.length, 10, 0)}`;
7
+ const length = _randomLengthPick(_randomLengthWindow(props, {
8
+ minimum: 0,
9
+ spread: 6
10
+ }));
11
+ return length === 0 ? "" : `/${_randomString({
12
+ type: "string",
13
+ minLength: length - 1,
14
+ maxLength: length - 1
15
+ })}`;
7
16
  };
17
+ const PREFIX = "/components/schemas/";
8
18
  const random = () => _randomString({
9
19
  type: "string",
10
20
  minLength: 10,
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatJsonPointer.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport { _ILengthProps, _randomSegmentLength } from \"./_randomStringLength\";\n\nexport const _randomFormatJsonPointer = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `/components/schemas/${random()}`;\n // The `/components/schemas/` prefix (20 chars) is fixed; the reference token\n // after it grows or shrinks to hit the requested length.\n return `/components/schemas/${_randomSegmentLength(props, 20, 10, 0)}`;\n};\n\nconst random = () =>\n _randomString({ type: \"string\", minLength: 10, maxLength: 10 });\n"],"mappings":";;;AAGA,MAAa,4BAA4B,UAAkC;CACzE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,uBAAuB,OAAO;CAGvC,OAAO,uBAAuB,qBAAqB,OAAO,IAAI,IAAI,CAAC;AACrE;AAEA,MAAM,eACJ,cAAc;CAAE,MAAM;CAAU,WAAW;CAAI,WAAW;AAAG,CAAC"}
1
+ {"version":3,"file":"_randomFormatJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatJsonPointer.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n _randomSegmentLength,\n} from \"./_randomStringLength\";\n\nexport const _randomFormatJsonPointer = (props?: _ILengthProps): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${PREFIX}${random()}`;\n // The `/components/schemas/` prefix (20 chars) is fixed; the reference token\n // after it grows or shrinks to hit the requested length.\n if (props.maxLength === undefined || props.maxLength >= PREFIX.length)\n return `${PREFIX}${_randomSegmentLength(props, PREFIX.length, 10, 0)}`;\n // Below that prefix a pointer still exists: the empty pointer addresses the\n // whole document, and one `/`-prefixed token addresses a member of it.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 0, spread: 6 }),\n );\n return length === 0\n ? \"\"\n : `/${_randomString({\n type: \"string\",\n minLength: length - 1,\n maxLength: length - 1,\n })}`;\n};\n\nconst PREFIX = \"/components/schemas/\";\n\nconst random = () =>\n _randomString({ type: \"string\", minLength: 10, maxLength: 10 });\n"],"mappings":";;;AAQA,MAAa,4BAA4B,UAAkC;CACzE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,SAAS,OAAO;CAG5B,IAAI,MAAM,cAAc,KAAA,KAAa,MAAM,aAAa,OAAO,QAC7D,OAAO,GAAG,SAAS,qBAAqB,OAAO,OAAO,QAAQ,IAAI,CAAC;CAGrE,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAE,CAAC,CACtD;CACA,OAAO,WAAW,IACd,KACA,IAAI,cAAc;EAChB,MAAM;EACN,WAAW,SAAS;EACpB,WAAW,SAAS;CACtB,CAAC;AACP;AAEA,MAAM,SAAS;AAEf,MAAM,eACJ,cAAc;CAAE,MAAM;CAAU,WAAW;CAAI,WAAW;AAAG,CAAC"}
@@ -1,8 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._randomFormatRegex = void 0;
4
+ const _randomString_1 = require("./_randomString");
4
5
  const _randomStringLength_1 = require("./_randomStringLength");
5
- const _randomFormatRegex = (props) => (0, _randomStringLength_1._randomFormatLength)(props, () => FIXED);
6
+ const _randomFormatRegex = (props) => {
7
+ // Every character `_randomString` emits is a literal in regular expression
8
+ // syntax, so a source of any length — including the empty source `new
9
+ // RegExp("")` accepts — compiles. An unconstrained draw is therefore an
10
+ // unconstrained string, and a constrained one fixes the length first.
11
+ if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
12
+ return (0, _randomString_1._randomString)({ type: "string" });
13
+ const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 0, spread: 16 }));
14
+ return (0, _randomString_1._randomString)({
15
+ type: "string",
16
+ minLength: length,
17
+ maxLength: length,
18
+ });
19
+ };
6
20
  exports._randomFormatRegex = _randomFormatRegex;
7
- const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
8
21
  //# sourceMappingURL=_randomFormatRegex.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatRegex.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRegex.ts"],"names":[],"mappings":";;;AAAA,+DAA2E;AAEpE,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE,CAClE,IAAA,yCAAmB,EAAC,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAD7B,QAAA,kBAAkB,GAAlB,kBAAkB,CACW;AAE1C,MAAM,KAAK,GACT,8FAA8F,CAAC"}
1
+ {"version":3,"file":"_randomFormatRegex.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRegex.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,+DAI+B;AAExB,MAAM,kBAAkB,GAAG,CAAC,KAAqB,EAAU,EAAE;IAClE,2EAA2E;IAC3E,sEAAsE;IACtE,wEAAwE;IACxE,sEAAsE;IACtE,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,IAAA,6BAAa,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACvD,CAAC;IACF,OAAO,IAAA,6BAAa,EAAC;QACnB,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,MAAM;KAClB,CAAC,CAAC;AACL,CAAC,CAAC;AAfW,QAAA,kBAAkB,GAAlB,kBAAkB,CAe7B"}
@@ -1,7 +1,18 @@
1
- import { _randomFormatLength } from "./_randomStringLength.mjs";
1
+ import { _randomString } from "./_randomString.mjs";
2
+ import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
2
3
  //#region src/internal/_randomFormatRegex.ts
3
- const _randomFormatRegex = (props) => _randomFormatLength(props, () => FIXED);
4
- const FIXED = "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/";
4
+ const _randomFormatRegex = (props) => {
5
+ if (props?.minLength === void 0 && props?.maxLength === void 0) return _randomString({ type: "string" });
6
+ const length = _randomLengthPick(_randomLengthWindow(props, {
7
+ minimum: 0,
8
+ spread: 16
9
+ }));
10
+ return _randomString({
11
+ type: "string",
12
+ minLength: length,
13
+ maxLength: length
14
+ });
15
+ };
5
16
  //#endregion
6
17
  export { _randomFormatRegex };
7
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import { _ILengthProps, _randomFormatLength } from \"./_randomStringLength\";\n\nexport const _randomFormatRegex = (props?: _ILengthProps): string =>\n _randomFormatLength(props, () => FIXED);\n\nconst FIXED =\n \"/^(?:(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)\\\\.){3}(?:25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]?\\\\d)$/\";\n"],"mappings":";;AAEA,MAAa,sBAAsB,UACjC,oBAAoB,aAAa,KAAK;AAExC,MAAM,QACJ"}
1
+ {"version":3,"file":"_randomFormatRegex.mjs","names":[],"sources":["../../src/internal/_randomFormatRegex.ts"],"sourcesContent":["import { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\n\nexport const _randomFormatRegex = (props?: _ILengthProps): string => {\n // Every character `_randomString` emits is a literal in regular expression\n // syntax, so a source of any length — including the empty source `new\n // RegExp(\"\")` accepts — compiles. An unconstrained draw is therefore an\n // unconstrained string, and a constrained one fixes the length first.\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return _randomString({ type: \"string\" });\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 0, spread: 16 }),\n );\n return _randomString({\n type: \"string\",\n minLength: length,\n maxLength: length,\n });\n};\n"],"mappings":";;;AAOA,MAAa,sBAAsB,UAAkC;CAKnE,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,cAAc,EAAE,MAAM,SAAS,CAAC;CACzC,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAG,CAAC,CACvD;CACA,OAAO,cAAc;EACnB,MAAM;EACN,WAAW;EACX,WAAW;CACb,CAAC;AACH"}
@@ -2,11 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._randomFormatRelativeJsonPointer = void 0;
4
4
  const _randomInteger_1 = require("./_randomInteger");
5
+ const _randomString_1 = require("./_randomString");
5
6
  const _randomStringLength_1 = require("./_randomStringLength");
6
- const _randomFormatRelativeJsonPointer = (props) => (0, _randomStringLength_1._randomFormatLength)(props, () => `${(0, _randomInteger_1._randomInteger)({
7
- type: "integer",
8
- minimum: 0,
9
- maximum: 10,
10
- })}#`);
7
+ const __randomComposition_1 = require("./private/__randomComposition");
8
+ const _randomFormatRelativeJsonPointer = (props) => {
9
+ if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
10
+ return `${(0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 10 })}#`;
11
+ // The leading non-negative integer stands alone as a pointer, so a single
12
+ // digit is the shortest form; `#` names the key and a `/`-prefixed token names
13
+ // a member, which absorbs any remaining length.
14
+ const length = (0, _randomStringLength_1._randomLengthPick)((0, _randomStringLength_1._randomLengthWindow)(props, { minimum: 1, spread: 6 }));
15
+ if (length === 1)
16
+ return (0, __randomComposition_1.__randomNumeric)(1);
17
+ if (length === 2)
18
+ return `${(0, __randomComposition_1.__randomNumeric)(1)}#`;
19
+ return `${(0, __randomComposition_1.__randomNumeric)(1)}/${(0, _randomString_1._randomString)({
20
+ type: "string",
21
+ minLength: length - 2,
22
+ maxLength: length - 2,
23
+ })}`;
24
+ };
11
25
  exports._randomFormatRelativeJsonPointer = _randomFormatRelativeJsonPointer;
12
26
  //# sourceMappingURL=_randomFormatRelativeJsonPointer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatRelativeJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAA2E;AAEpE,MAAM,gCAAgC,GAAG,CAC9C,KAAqB,EACb,EAAE,CACV,IAAA,yCAAmB,EACjB,KAAK,EACL,GAAG,EAAE,CACH,GAAG,IAAA,+BAAc,EAAC;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;CACZ,CAAC,GAAG,CACR,CAAC;AAXS,QAAA,gCAAgC,GAAhC,gCAAgC,CAWzC"}
1
+ {"version":3,"file":"_randomFormatRelativeJsonPointer.js","sourceRoot":"","sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,mDAAgD;AAChD,+DAI+B;AAC/B,uEAAgE;AAEzD,MAAM,gCAAgC,GAAG,CAC9C,KAAqB,EACb,EAAE;IACV,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,SAAS;QAClE,OAAO,GAAG,IAAA,+BAAc,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,gDAAgD;IAChD,MAAM,MAAM,GAAW,IAAA,uCAAiB,EACtC,IAAA,yCAAmB,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CACtD,CAAC;IACF,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,IAAA,qCAAe,EAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,IAAA,qCAAe,EAAC,CAAC,CAAC,GAAG,CAAC;IAClD,OAAO,GAAG,IAAA,qCAAe,EAAC,CAAC,CAAC,IAAI,IAAA,6BAAa,EAAC;QAC5C,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM,GAAG,CAAC;QACrB,SAAS,EAAE,MAAM,GAAG,CAAC;KACtB,CAAC,EAAE,CAAC;AACP,CAAC,CAAC;AAlBW,QAAA,gCAAgC,GAAhC,gCAAgC,CAkB3C"}
@@ -1,11 +1,26 @@
1
1
  import { _randomInteger } from "./_randomInteger.mjs";
2
- import { _randomFormatLength } from "./_randomStringLength.mjs";
2
+ import { _randomString } from "./_randomString.mjs";
3
+ import { _randomLengthPick, _randomLengthWindow } from "./_randomStringLength.mjs";
4
+ import { __randomNumeric } from "./private/__randomComposition.mjs";
3
5
  //#region src/internal/_randomFormatRelativeJsonPointer.ts
4
- const _randomFormatRelativeJsonPointer = (props) => _randomFormatLength(props, () => `${_randomInteger({
5
- type: "integer",
6
- minimum: 0,
7
- maximum: 10
8
- })}#`);
6
+ const _randomFormatRelativeJsonPointer = (props) => {
7
+ if (props?.minLength === void 0 && props?.maxLength === void 0) return `${_randomInteger({
8
+ type: "integer",
9
+ minimum: 0,
10
+ maximum: 10
11
+ })}#`;
12
+ const length = _randomLengthPick(_randomLengthWindow(props, {
13
+ minimum: 1,
14
+ spread: 6
15
+ }));
16
+ if (length === 1) return __randomNumeric(1);
17
+ if (length === 2) return `${__randomNumeric(1)}#`;
18
+ return `${__randomNumeric(1)}/${_randomString({
19
+ type: "string",
20
+ minLength: length - 2,
21
+ maxLength: length - 2
22
+ })}`;
23
+ };
9
24
  //#endregion
10
25
  export { _randomFormatRelativeJsonPointer };
11
26
 
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatRelativeJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _ILengthProps, _randomFormatLength } from \"./_randomStringLength\";\n\nexport const _randomFormatRelativeJsonPointer = (\n props?: _ILengthProps,\n): string =>\n _randomFormatLength(\n props,\n () =>\n `${_randomInteger({\n type: \"integer\",\n minimum: 0,\n maximum: 10,\n })}#`,\n );\n"],"mappings":";;;AAGA,MAAa,oCACX,UAEA,oBACE,aAEE,GAAG,eAAe;CAChB,MAAM;CACN,SAAS;CACT,SAAS;AACX,CAAC,EAAE,EACP"}
1
+ {"version":3,"file":"_randomFormatRelativeJsonPointer.mjs","names":[],"sources":["../../src/internal/_randomFormatRelativeJsonPointer.ts"],"sourcesContent":["import { _randomInteger } from \"./_randomInteger\";\nimport { _randomString } from \"./_randomString\";\nimport {\n _ILengthProps,\n _randomLengthPick,\n _randomLengthWindow,\n} from \"./_randomStringLength\";\nimport { __randomNumeric } from \"./private/__randomComposition\";\n\nexport const _randomFormatRelativeJsonPointer = (\n props?: _ILengthProps,\n): string => {\n if (props?.minLength === undefined && props?.maxLength === undefined)\n return `${_randomInteger({ type: \"integer\", minimum: 0, maximum: 10 })}#`;\n // The leading non-negative integer stands alone as a pointer, so a single\n // digit is the shortest form; `#` names the key and a `/`-prefixed token names\n // a member, which absorbs any remaining length.\n const length: number = _randomLengthPick(\n _randomLengthWindow(props, { minimum: 1, spread: 6 }),\n );\n if (length === 1) return __randomNumeric(1);\n if (length === 2) return `${__randomNumeric(1)}#`;\n return `${__randomNumeric(1)}/${_randomString({\n type: \"string\",\n minLength: length - 2,\n maxLength: length - 2,\n })}`;\n};\n"],"mappings":";;;;;AASA,MAAa,oCACX,UACW;CACX,IAAI,OAAO,cAAc,KAAA,KAAa,OAAO,cAAc,KAAA,GACzD,OAAO,GAAG,eAAe;EAAE,MAAM;EAAW,SAAS;EAAG,SAAS;CAAG,CAAC,EAAE;CAIzE,MAAM,SAAiB,kBACrB,oBAAoB,OAAO;EAAE,SAAS;EAAG,QAAQ;CAAE,CAAC,CACtD;CACA,IAAI,WAAW,GAAG,OAAO,gBAAgB,CAAC;CAC1C,IAAI,WAAW,GAAG,OAAO,GAAG,gBAAgB,CAAC,EAAE;CAC/C,OAAO,GAAG,gBAAgB,CAAC,EAAE,GAAG,cAAc;EAC5C,MAAM;EACN,WAAW,SAAS;EACpB,WAAW,SAAS;CACtB,CAAC;AACH"}
@@ -3,13 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._randomFormatTime = void 0;
4
4
  const _randomInteger_1 = require("./_randomInteger");
5
5
  const _randomStringLength_1 = require("./_randomStringLength");
6
- const _randomFormatTime = (props) => (0, _randomStringLength_1._randomFormatLength)(props, () => new Date((0, _randomInteger_1._randomInteger)({
7
- type: "integer",
8
- minimum: 0,
9
- maximum: DAY,
10
- }))
11
- .toISOString()
12
- .substring(11));
6
+ const __randomComposition_1 = require("./private/__randomComposition");
7
+ const _randomFormatTime = (props) => {
8
+ const clock = () => new Date((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: DAY })).toISOString();
9
+ if ((props === null || props === void 0 ? void 0 : props.minLength) === undefined && (props === null || props === void 0 ? void 0 : props.maxLength) === undefined)
10
+ return clock().substring(11);
11
+ // `HH:MM:SS` carries a mandatory offset — one character as `Z`, six as
12
+ // `+HH:MM` — and an optional fraction between them that RFC 3339 leaves
13
+ // open above. Together they express 9 and every length from 11 upward; 10 is
14
+ // the one gap, because a fraction needs both a dot and a digit.
15
+ const window = (0, _randomStringLength_1._randomLengthWindow)(props, {
16
+ minimum: CLOCK + 1,
17
+ spread: 6,
18
+ });
19
+ let length = (0, _randomStringLength_1._randomLengthPick)(window);
20
+ if (length === CLOCK + 2)
21
+ length = window.high >= CLOCK + 3 ? CLOCK + 3 : CLOCK + 1;
22
+ if (length < window.low || length > window.high)
23
+ throw new Error(_randomStringLength_1._RANDOM_LENGTH_ERROR);
24
+ const base = clock().substring(11, 11 + CLOCK);
25
+ if (length === CLOCK + 1)
26
+ return `${base}Z`;
27
+ // The `Z` form reaches every remaining length by itself, so the numeric
28
+ // offset is a choice rather than a fallback: it spends six characters, which
29
+ // leaves either nothing (14, `HH:MM:SS+HH:MM`) or a whole fraction (16 and
30
+ // up). At 15 only the `Z` form fits, since the offset would demand a dot
31
+ // with no digit after it.
32
+ const fraction = length - CLOCK - OFFSET - 1;
33
+ return (fraction === -1 || fraction >= 1) &&
34
+ (0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 1 }) === 1
35
+ ? fraction === -1
36
+ ? `${base}${offset()}`
37
+ : `${base}.${(0, __randomComposition_1.__randomDigits)(fraction)}${offset()}`
38
+ : `${base}.${(0, __randomComposition_1.__randomDigits)(length - CLOCK - 2)}Z`;
39
+ };
13
40
  exports._randomFormatTime = _randomFormatTime;
14
41
  const DAY = 86400000;
42
+ const CLOCK = "00:00:00".length;
43
+ const OFFSET = "+00:00".length;
44
+ const offset = () => `${(0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 1 }) === 0 ? "+" : "-"}${pad((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 23 }))}:${pad((0, _randomInteger_1._randomInteger)({ type: "integer", minimum: 0, maximum: 59 }))}`;
45
+ const pad = (value) => String(value).padStart(2, "0");
15
46
  //# sourceMappingURL=_randomFormatTime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_randomFormatTime.js","sourceRoot":"","sources":["../../src/internal/_randomFormatTime.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAA2E;AAEpE,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAU,EAAE,CACjE,IAAA,yCAAmB,EAAC,KAAK,EAAE,GAAG,EAAE,CAC9B,IAAI,IAAI,CACN,IAAA,+BAAc,EAAC;IACb,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,GAAG;CACb,CAAC,CACH;KACE,WAAW,EAAE;KACb,SAAS,CAAC,EAAE,CAAC,CACjB,CAAC;AAXS,QAAA,iBAAiB,GAAjB,iBAAiB,CAW1B;AAEJ,MAAM,GAAG,GAAG,QAAU,CAAC"}
1
+ {"version":3,"file":"_randomFormatTime.js","sourceRoot":"","sources":["../../src/internal/_randomFormatTime.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,+DAK+B;AAC/B,uEAA+D;AAExD,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EA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