arktype 3.0.0-beta.1 → 3.0.0-rc.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 (312) hide show
  1. package/README.md +48 -144
  2. package/out/_internal/regex/charset.d.ts +24 -0
  3. package/out/_internal/regex/escape.d.ts +29 -0
  4. package/out/_internal/regex/execArray.d.ts +24 -0
  5. package/out/_internal/regex/group.d.ts +34 -0
  6. package/out/_internal/regex/index.d.ts +2 -0
  7. package/out/_internal/regex/internal.d.ts +9 -0
  8. package/out/_internal/regex/parse.d.ts +10 -0
  9. package/out/_internal/regex/quantify.d.ts +59 -0
  10. package/out/_internal/regex/regex.d.ts +38 -0
  11. package/out/_internal/regex/state.d.ts +383 -0
  12. package/out/_internal/schema/codecs.d.ts +2 -0
  13. package/out/_internal/schema/config.d.ts +103 -0
  14. package/out/_internal/schema/constraint.d.ts +78 -0
  15. package/out/_internal/schema/errors.d.ts +1 -0
  16. package/out/_internal/schema/generic.d.ts +85 -0
  17. package/out/_internal/schema/i18n.d.ts +3 -0
  18. package/out/_internal/schema/index.d.ts +54 -0
  19. package/out/_internal/schema/internal.d.ts +15 -0
  20. package/out/_internal/schema/intrinsic.d.ts +28 -0
  21. package/out/_internal/schema/kinds.d.ts +76 -0
  22. package/out/_internal/schema/module.d.ts +23 -0
  23. package/out/_internal/schema/mutatesInput.d.ts +2 -0
  24. package/out/_internal/schema/node.d.ts +349 -0
  25. package/out/_internal/schema/parse.d.ts +77 -0
  26. package/out/_internal/schema/parseSchema.d.ts +116 -0
  27. package/out/_internal/schema/predicate.d.ts +46 -0
  28. package/out/_internal/schema/refinements/after.d.ts +32 -0
  29. package/out/_internal/schema/refinements/before.d.ts +32 -0
  30. package/out/_internal/schema/refinements/divisor.d.ts +41 -0
  31. package/out/_internal/schema/refinements/exactLength.d.ts +43 -0
  32. package/out/_internal/schema/refinements/kinds.d.ts +40 -0
  33. package/out/_internal/schema/refinements/max.d.ts +33 -0
  34. package/out/_internal/schema/refinements/maxLength.d.ts +32 -0
  35. package/out/_internal/schema/refinements/min.d.ts +33 -0
  36. package/out/_internal/schema/refinements/minLength.d.ts +32 -0
  37. package/out/_internal/schema/refinements/notEqual.d.ts +38 -0
  38. package/out/_internal/schema/refinements/notEqualLength.d.ts +38 -0
  39. package/out/_internal/schema/refinements/pattern.d.ts +43 -0
  40. package/out/_internal/schema/refinements/range.d.ts +101 -0
  41. package/out/_internal/schema/roots/alias.d.ts +49 -0
  42. package/out/_internal/schema/roots/basis.d.ts +12 -0
  43. package/out/_internal/schema/roots/domain.d.ts +45 -0
  44. package/out/_internal/schema/roots/intersection.d.ts +72 -0
  45. package/out/_internal/schema/roots/morph.d.ts +59 -0
  46. package/out/_internal/schema/roots/proto.d.ts +42 -0
  47. package/out/_internal/schema/roots/root.d.ts +163 -0
  48. package/out/_internal/schema/roots/union.d.ts +146 -0
  49. package/out/_internal/schema/roots/unit.d.ts +36 -0
  50. package/out/_internal/schema/runtime.d.ts +29 -0
  51. package/out/_internal/schema/runtimeLean.d.ts +2 -0
  52. package/out/_internal/schema/runtimeNone.d.ts +2 -0
  53. package/out/_internal/schema/runtimeNoneLean.d.ts +2 -0
  54. package/out/_internal/schema/scope.d.ts +203 -0
  55. package/out/_internal/schema/shared/codecs.d.ts +5 -0
  56. package/out/_internal/schema/shared/compile.d.ts +144 -0
  57. package/out/_internal/schema/shared/configured.d.ts +14 -0
  58. package/out/_internal/schema/shared/declare.d.ts +100 -0
  59. package/out/_internal/schema/shared/disjoint.d.ts +45 -0
  60. package/out/_internal/schema/shared/enWriters.d.ts +30 -0
  61. package/out/_internal/schema/shared/errorModes.d.ts +25 -0
  62. package/out/_internal/schema/shared/errorWriters.d.ts +34 -0
  63. package/out/_internal/schema/shared/errors.d.ts +264 -0
  64. package/out/_internal/schema/shared/implement.d.ts +154 -0
  65. package/out/_internal/schema/shared/inPlace.d.ts +8 -0
  66. package/out/_internal/schema/shared/issueFeatures.d.ts +38 -0
  67. package/out/_internal/schema/shared/issues.d.ts +261 -0
  68. package/out/_internal/schema/shared/issuesLean.d.ts +80 -0
  69. package/out/_internal/schema/shared/issuesNone.d.ts +22 -0
  70. package/out/_internal/schema/shared/issuesNoneLean.d.ts +20 -0
  71. package/out/_internal/schema/shared/issuesUndetailed.d.ts +25 -0
  72. package/out/_internal/schema/shared/jsonSchema.d.ts +153 -0
  73. package/out/_internal/schema/shared/listed.d.ts +15 -0
  74. package/out/_internal/schema/shared/locale.d.ts +149 -0
  75. package/out/_internal/schema/shared/registry.d.ts +16 -0
  76. package/out/_internal/schema/shared/render.d.ts +3 -0
  77. package/out/_internal/schema/shared/rootApply.d.ts +19 -0
  78. package/out/_internal/schema/shared/sets.d.ts +26 -0
  79. package/out/_internal/schema/shared/standardFailure.d.ts +22 -0
  80. package/out/_internal/schema/shared/standardSchema.d.ts +124 -0
  81. package/out/_internal/schema/shared/toJsonSchema.d.ts +229 -0
  82. package/out/_internal/schema/shared/transform.d.ts +35 -0
  83. package/out/_internal/schema/shared/traversal.d.ts +288 -0
  84. package/out/_internal/schema/shared/utils.d.ts +59 -0
  85. package/out/_internal/schema/structure/index.d.ts +43 -0
  86. package/out/_internal/schema/structure/optional.d.ts +61 -0
  87. package/out/_internal/schema/structure/prop.d.ts +45 -0
  88. package/out/_internal/schema/structure/required.d.ts +49 -0
  89. package/out/_internal/schema/structure/sequence.d.ts +127 -0
  90. package/out/_internal/schema/structure/shared.d.ts +3 -0
  91. package/out/_internal/schema/structure/structure.d.ts +178 -0
  92. package/out/_internal/schema/units.d.ts +123 -0
  93. package/out/_internal/sets/algebra.d.ts +26 -0
  94. package/out/_internal/sets/constraint.d.ts +19 -0
  95. package/out/_internal/sets/engine.d.ts +2 -0
  96. package/out/_internal/sets/formats.d.ts +23 -0
  97. package/out/_internal/sets/fromJsonSchema.d.ts +15 -0
  98. package/out/_internal/sets/implement.d.ts +16 -0
  99. package/out/_internal/sets/index.d.ts +2 -0
  100. package/out/_internal/sets/internal.d.ts +20 -0
  101. package/out/_internal/sets/intersections.d.ts +5 -0
  102. package/out/_internal/sets/kinds.d.ts +3 -0
  103. package/out/_internal/sets/refinements.d.ts +14 -0
  104. package/out/_internal/sets/roots/alias.d.ts +3 -0
  105. package/out/_internal/sets/roots/domain.d.ts +3 -0
  106. package/out/_internal/sets/roots/intersection.d.ts +4 -0
  107. package/out/_internal/sets/roots/morph.d.ts +4 -0
  108. package/out/_internal/sets/roots/proto.d.ts +3 -0
  109. package/out/_internal/sets/roots/union.d.ts +16 -0
  110. package/out/_internal/sets/roots/unit.d.ts +3 -0
  111. package/out/_internal/sets/structure/index.d.ts +3 -0
  112. package/out/_internal/sets/structure/prop.d.ts +8 -0
  113. package/out/_internal/sets/structure/sequence.d.ts +3 -0
  114. package/out/_internal/sets/structure/structure.d.ts +3 -0
  115. package/out/_internal/sets/toJsonSchema.d.ts +25 -0
  116. package/out/_internal/util/arrays.d.ts +130 -0
  117. package/out/_internal/util/clone.d.ts +4 -0
  118. package/out/_internal/util/describe.d.ts +25 -0
  119. package/out/_internal/util/domain.d.ts +49 -0
  120. package/out/_internal/util/errors.d.ts +29 -0
  121. package/out/_internal/util/facts.d.ts +22 -0
  122. package/out/_internal/util/flatMorph.d.ts +41 -0
  123. package/out/_internal/util/formats.d.ts +8 -0
  124. package/out/_internal/util/functions.d.ts +33 -0
  125. package/out/_internal/util/generics.d.ts +65 -0
  126. package/out/_internal/util/get.d.ts +9 -0
  127. package/out/_internal/util/hkt.d.ts +27 -0
  128. package/out/_internal/util/i18n.d.ts +12 -0
  129. package/out/_internal/util/index.d.ts +28 -0
  130. package/out/_internal/util/internal.d.ts +2 -0
  131. package/out/_internal/util/intersections.d.ts +50 -0
  132. package/out/_internal/util/isomorphic.d.ts +8 -0
  133. package/out/_internal/util/keys.d.ts +18 -0
  134. package/out/_internal/util/lazily.d.ts +7 -0
  135. package/out/_internal/util/numbers.d.ts +82 -0
  136. package/out/_internal/util/objectKinds.d.ts +157 -0
  137. package/out/_internal/util/path.d.ts +16 -0
  138. package/out/_internal/util/primitive.d.ts +16 -0
  139. package/out/_internal/util/records.d.ts +173 -0
  140. package/out/_internal/util/registry.d.ts +13 -0
  141. package/out/_internal/util/scanner.d.ts +110 -0
  142. package/out/_internal/util/serialize.d.ts +40 -0
  143. package/out/_internal/util/strings.d.ts +35 -0
  144. package/out/_internal/util/traits.d.ts +89 -0
  145. package/out/_internal/util/unionToTuple.d.ts +14 -0
  146. package/out/_internal/util/weak.d.ts +8 -0
  147. package/out/attributes.d.ts +15 -11
  148. package/out/checkers.d.ts +1 -1
  149. package/out/chunk-22RQSVV3.js +0 -0
  150. package/out/chunk-3HZC67MT.js +965 -0
  151. package/out/chunk-3KBOPH3J.js +1564 -0
  152. package/out/chunk-3SH2BQ4T.js +15 -0
  153. package/out/chunk-46PLKNON.js +126 -0
  154. package/out/{chunk-G45P2CLE.js → chunk-4FTHWK63.js} +6 -1
  155. package/out/{chunk-UK5UGFOX.js → chunk-4HREHNIV.js} +23 -11
  156. package/out/chunk-4NZCLVBD.js +14 -0
  157. package/out/chunk-6FMBO47M.js +7 -0
  158. package/out/chunk-7TALAWYX.js +10 -0
  159. package/out/{chunk-DLWCO4RV.js → chunk-BCYKO54Z.js} +11 -2
  160. package/out/chunk-BDJVONP7.js +168 -0
  161. package/out/{chunk-E3DZXEZK.js → chunk-C2JOL5M2.js} +4 -2
  162. package/out/{chunk-2U2AWCI3.js → chunk-C2V6QPE3.js} +126 -97
  163. package/out/chunk-C3B4IFQL.js +6408 -0
  164. package/out/chunk-CWSF57VM.js +10 -0
  165. package/out/chunk-F5BACUJS.js +7 -0
  166. package/out/{chunk-EVCML554.js → chunk-FWRSDUJ2.js} +14 -5
  167. package/out/chunk-GID3FSQA.js +161 -0
  168. package/out/chunk-I2KLQ2HA.js +22 -0
  169. package/out/chunk-K7SLP5D2.js +84 -0
  170. package/out/chunk-KQPSKGUI.js +9 -0
  171. package/out/chunk-KXOC3JEX.js +8234 -0
  172. package/out/chunk-KXOSUYRA.js +405 -0
  173. package/out/chunk-LHNEY6QW.js +0 -0
  174. package/out/chunk-MTWKGAGO.js +323 -0
  175. package/out/chunk-NU73GNCX.js +170 -0
  176. package/out/{chunk-RAZ3TXOE.js → chunk-P5W67FQH.js} +34 -19
  177. package/out/chunk-PDLTEX6Z.js +1118 -0
  178. package/out/{chunk-VV6YDN2D.js → chunk-QUS4IAXJ.js} +304 -263
  179. package/out/chunk-R7WXIH5P.js +94 -0
  180. package/out/chunk-TACLEIDM.js +95 -0
  181. package/out/chunk-UJJGG4VQ.js +71 -0
  182. package/out/chunk-US6BWOGJ.js +109 -0
  183. package/out/chunk-VMMMOO4R.js +945 -0
  184. package/out/chunk-VYMXHSFR.js +439 -0
  185. package/out/chunk-W2XOI5DY.js +141 -0
  186. package/out/chunk-WC5L5YRP.js +25 -0
  187. package/out/{chunk-NRIGTMPM.js → chunk-WKOSL2G6.js} +4 -1
  188. package/out/chunk-XLG66ZDF.js +0 -0
  189. package/out/{chunk-5U2ZMDNI.js → chunk-XNUAQSJ4.js} +52 -30
  190. package/out/chunk-ZRYEHGSG.js +79 -0
  191. package/out/cli.d.ts +28 -0
  192. package/out/cli.js +636 -0
  193. package/out/codecs.d.ts +6 -5
  194. package/out/codecs.js +23 -7
  195. package/out/config.d.ts +5 -17
  196. package/out/config.js +11 -2
  197. package/out/declare.d.ts +40 -12
  198. package/out/deferred.d.ts +2 -2
  199. package/out/errors.d.ts +1 -1
  200. package/out/errors.js +10 -2
  201. package/out/fn.d.ts +20 -13
  202. package/out/fromJsonSchema.d.ts +18 -0
  203. package/out/generic.d.ts +9 -6
  204. package/out/i18n.d.ts +2 -2
  205. package/out/i18n.js +9 -2
  206. package/out/index.d.ts +16 -7
  207. package/out/index.js +25 -8
  208. package/out/internal.d.ts +4 -0
  209. package/out/internal.js +41 -17
  210. package/out/island.js +22 -6
  211. package/out/islandDependency.js +42 -18
  212. package/out/jsonSchema/infer.d.ts +805 -0
  213. package/out/jsonSchema/validate.d.ts +416 -0
  214. package/out/keywords/Array.d.ts +2 -2
  215. package/out/keywords/builtins.d.ts +3 -3
  216. package/out/keywords/constructors.d.ts +1 -1
  217. package/out/keywords/functions.d.ts +5 -192
  218. package/out/keywords/keywords.d.ts +3 -3
  219. package/out/keywords/number.d.ts +2 -2
  220. package/out/keywords/phrases.d.ts +4 -191
  221. package/out/keywords/string.d.ts +3 -3
  222. package/out/keywords/ts.d.ts +18 -18
  223. package/out/keywords/ts.js +19 -4
  224. package/out/locale.d.ts +6 -2
  225. package/out/locales/de.js +9 -2
  226. package/out/locales/en.js +21 -5
  227. package/out/match.d.ts +13 -10
  228. package/out/module.d.ts +2 -2
  229. package/out/mutatesInput.js +18 -3
  230. package/out/nary.d.ts +220 -194
  231. package/out/parser/ast/bounds.d.ts +2 -2
  232. package/out/parser/ast/default.d.ts +2 -2
  233. package/out/parser/ast/divisor.d.ts +2 -2
  234. package/out/parser/ast/generic.d.ts +2 -2
  235. package/out/parser/ast/infer.d.ts +1 -1
  236. package/out/parser/ast/keyof.d.ts +2 -2
  237. package/out/parser/ast/utils.d.ts +1 -1
  238. package/out/parser/ast/validate.d.ts +2 -2
  239. package/out/parser/definition.d.ts +4 -4
  240. package/out/parser/objectLiteral.d.ts +2 -2
  241. package/out/parser/property.d.ts +2 -2
  242. package/out/parser/reduce/dynamic.d.ts +2 -2
  243. package/out/parser/reduce/shared.d.ts +1 -1
  244. package/out/parser/reduce/static.d.ts +1 -1
  245. package/out/parser/shift/operand/enclosed.d.ts +2 -2
  246. package/out/parser/shift/operand/genericArgs.d.ts +2 -2
  247. package/out/parser/shift/operand/operand.d.ts +1 -1
  248. package/out/parser/shift/operand/unenclosed.d.ts +2 -2
  249. package/out/parser/shift/operand/unresolvable.d.ts +2 -2
  250. package/out/parser/shift/operator/bounds.d.ts +2 -2
  251. package/out/parser/shift/operator/brand.d.ts +2 -2
  252. package/out/parser/shift/operator/default.d.ts +4 -4
  253. package/out/parser/shift/operator/divisor.d.ts +1 -1
  254. package/out/parser/shift/operator/operator.d.ts +1 -1
  255. package/out/parser/shift/tokens.d.ts +1 -1
  256. package/out/parser/string.d.ts +2 -2
  257. package/out/parser/tupleExpressions.d.ts +6 -8
  258. package/out/parser/tupleLiteral.d.ts +2 -2
  259. package/out/precompiled.d.ts +1 -1
  260. package/out/precompiled.js +16 -2
  261. package/out/regex.d.ts +1 -0
  262. package/out/regex.js +2 -0
  263. package/out/runtime.d.ts +10 -8
  264. package/out/runtime.js +6 -4
  265. package/out/runtimeDevelopment.js +70 -52
  266. package/out/schema.d.ts +1 -0
  267. package/out/schema.js +15 -0
  268. package/out/schemaInternal.d.ts +1 -0
  269. package/out/schemaInternal.js +1401 -0
  270. package/out/schemaIssueFeatures.d.ts +1 -0
  271. package/out/schemaRuntime.d.ts +1 -0
  272. package/out/schemaRuntime.js +7 -0
  273. package/out/schemaRuntimeLean.d.ts +1 -0
  274. package/out/schemaRuntimeLean.js +1870 -0
  275. package/out/schemaRuntimeNone.d.ts +1 -0
  276. package/out/schemaRuntimeNone.js +1774 -0
  277. package/out/schemaRuntimeNoneLean.d.ts +1 -0
  278. package/out/schemaRuntimeNoneLean.js +1767 -0
  279. package/out/scope.d.ts +3 -4
  280. package/out/shared/issueFeatures.d.ts +38 -0
  281. package/out/shared/issueFeatures.js +40 -0
  282. package/out/standalone/artifact.d.ts +6 -6
  283. package/out/standalone/baking.d.ts +2 -2
  284. package/out/standalone/combinators.d.ts +1 -1
  285. package/out/standalone/compilers.d.ts +1 -1
  286. package/out/standalone/fallbacks.d.ts +1 -1
  287. package/out/standalone/keys.d.ts +1 -1
  288. package/out/standalone/sites.d.ts +3 -3
  289. package/out/standalone/units.d.ts +1 -1
  290. package/out/standalone/values.d.ts +1 -1
  291. package/out/type.d.ts +6 -6
  292. package/out/util.d.ts +1 -0
  293. package/out/util.js +137 -0
  294. package/out/variants/array.d.ts +6 -6
  295. package/out/variants/base.d.ts +61 -10
  296. package/out/variants/date.d.ts +5 -5
  297. package/out/variants/instantiate.d.ts +1 -1
  298. package/out/variants/number.d.ts +6 -6
  299. package/out/variants/object.d.ts +25 -12
  300. package/out/variants/string.d.ts +8 -8
  301. package/package.json +183 -8
  302. package/skills/arktype/SKILL.md +93 -93
  303. package/skills/arktype/references/migrating.md +144 -158
  304. package/skills/arktype/references/precompile.md +7 -7
  305. package/out/chunk-4CUA5XIP.js +0 -7
  306. package/out/chunk-GPNK5353.js +0 -2529
  307. package/out/chunk-MLKGABMK.js +0 -9
  308. package/out/chunk-PRTMQCHS.js +0 -3
  309. package/out/chunk-R5G57XC7.js +0 -7
  310. package/out/chunk-SWOOCAHN.js +0 -4
  311. package/out/chunk-TAHPKDNM.js +0 -3
  312. package/out/chunk-UETB6YE2.js +0 -14
@@ -0,0 +1,3 @@
1
+ import { type Index } from "../../schema/index.js";
2
+ import type { setImplementationOf } from "../implement.ts";
3
+ export declare const index: setImplementationOf<Index.Declaration>;
@@ -0,0 +1,8 @@
1
+ import { Disjoint, type BaseRoot, type IntersectionContext, type Optional, type Prop, type Required, type nodeOfKind } from "../../schema/index.js";
2
+ import type { setImplementationOf } from "../implement.ts";
3
+ export declare const intersectProps: (l: nodeOfKind<Prop.Kind>, r: nodeOfKind<Prop.Kind>, ctx: IntersectionContext) => nodeOfKind<Prop.Kind> | Disjoint | null;
4
+ export declare const required: setImplementationOf<Required.Declaration>;
5
+ export declare const optional: setImplementationOf<Optional.Declaration>;
6
+ /** an optional key or element's value without exactOptionalPropertyTypes, allowing undefined */
7
+ export declare const withUndefined: (value: BaseRoot) => BaseRoot;
8
+ export declare const writeDefaultIntersectionMessage: (lValue: unknown, rValue: unknown) => string;
@@ -0,0 +1,3 @@
1
+ import { type Sequence } from "../../schema/index.js";
2
+ import type { setImplementationOf } from "../implement.ts";
3
+ export declare const sequence: setImplementationOf<Sequence.Declaration>;
@@ -0,0 +1,3 @@
1
+ import { type Structure } from "../../schema/index.js";
2
+ import type { setImplementationOf } from "../implement.ts";
3
+ export declare const structure: setImplementationOf<Structure.Declaration>;
@@ -0,0 +1,25 @@
1
+ import { ToJsonSchema, type UnionJsonSchemaWriters, type BaseRoot, type BaseScope, type JsonSchema } from "../schema/index.js";
2
+ export declare const isNonArray: (data: object) => boolean;
3
+ interface JsonSchemaContext extends ToJsonSchema.Context {
4
+ /** where in the Type the node being converted is, for its errors */
5
+ path: string;
6
+ /** the ids of the nodes being converted, so one reached again is a cycle */
7
+ open: string[];
8
+ defNamesById: Record<string, string>;
9
+ /** the alias each node aliasDefs writes as a def is named by */
10
+ aliasNamesById: Record<string, string>;
11
+ /** the scopes whose aliases are in aliasNamesById */
12
+ aliasScopes: Set<BaseScope>;
13
+ /** the names aliasDefs lists that a scope reached has */
14
+ aliasesFound: Set<string>;
15
+ defs: Record<string, JsonSchema | undefined>;
16
+ /** what each $ref's pointer starts with, before the name of its def */
17
+ refPrefix: string;
18
+ writers: UnionJsonSchemaWriters;
19
+ }
20
+ export declare const jsonSchemaWriters: UnionJsonSchemaWriters;
21
+ export declare const jsonSchemaContextOf: (cfg: ToJsonSchema.Context, writers: UnionJsonSchemaWriters) => JsonSchemaContext;
22
+ export declare const rootToJsonSchema: (node: BaseRoot, opts: ToJsonSchema.Options) => JsonSchema;
23
+ export declare const refPrefixOf: (ctx: ToJsonSchema.Context) => string;
24
+ export declare const toJsonSchemaRecurse: (node: BaseRoot, ctx: JsonSchemaContext) => JsonSchema;
25
+ export {};
@@ -0,0 +1,130 @@
1
+ import type { GuardablePredicate } from "./functions.ts";
2
+ import type { anyOrNever, conform, noInfer } from "./generics.ts";
3
+ import type { isDisjoint } from "./intersections.ts";
4
+ import type { parseNonNegativeInteger } from "./numbers.ts";
5
+ type DuplicateData<val = unknown> = {
6
+ element: val;
7
+ indices: number[];
8
+ };
9
+ /**
10
+ * Extracts duplicated elements and their indices from an array, returning them.
11
+ *
12
+ * Note that given `a === b && b === c`, then `c === a` must be `true` for this to give accurate results.
13
+ *
14
+ * @param arr The array to extract duplicate elements from.
15
+ */ export declare const getDuplicatesOf: <const arr extends array>(arr: arr, opts?: ComparisonOptions<arr[number]>) => DuplicateData<arr[number]>[];
16
+ export type pathToString<segments extends string[], delimiter extends string = "/"> = segments extends [] ? "/" : join<segments, delimiter>;
17
+ export declare const join: <segments extends array<string>, delimiter extends string>(segments: segments, delimiter: delimiter) => join<segments, delimiter>;
18
+ export type join<segments extends array<string>, delimiter extends string, result extends string = ""> = segments extends (readonly [infer head extends string, ...infer tail extends string[]]) ? join<tail, delimiter, result extends "" ? head : `${result}${delimiter}${head}`> : result;
19
+ export declare const getPath: (root: unknown, path: string[]) => unknown;
20
+ export declare const intersectUniqueLists: <item>(l: readonly item[], r: readonly item[]) => item[];
21
+ export type filter<t extends array, constraint, result extends unknown[] = []> = t extends readonly [infer head, ...infer tail] ? filter<tail, constraint, head extends constraint ? [...result, head] : result> : result;
22
+ export type array<t = unknown> = readonly t[];
23
+ export declare namespace array {
24
+ type multiply<t extends array, count extends number> = _multiply<t, [
25
+ ], count, [
26
+ ]>;
27
+ type _multiply<base extends array, result extends array, count extends number, i extends 1[]> = i["length"] extends count ? result : _multiply<base, [...result, ...base], count, [...i, 1]>;
28
+ type repeat<element, count extends number> = powersOfTwo<seedOf<count>> extends infer segments extends 1[][] ? buildFromSegments<element, [], dropLongerThan<count, segments>, count> : never;
29
+ type buildFromSegments<element, result extends 1[], segments extends 1[][], count extends number, next extends 1[] = [...result, ...segments[0]]> = next["length"] extends count ? {
30
+ [i in keyof next]: element;
31
+ } : `${count}` extends keyof next ? buildFromSegments<element, result, nextSegments<segments>, count> : buildFromSegments<element, next, nextSegments<segments>, count>;
32
+ type nextSegments<segments extends 1[][]> = segments extends [unknown, ...infer nextSegments extends 1[][]] ? nextSegments : never;
33
+ type minLength<element, minLength extends number> = readonly [
34
+ ...multiply<[element], minLength>,
35
+ ...element[]
36
+ ];
37
+ }
38
+ export type listable<t> = t | readonly t[];
39
+ export type longerThan<t extends array, n extends number> = `${n}` extends keyof t ? true : false;
40
+ export type CollapsingList<t = unknown> = readonly [] | t | readonly [t, t, ...t[]];
41
+ export type headOf<t extends array> = t[0];
42
+ export type tailOf<t extends array> = t extends readonly [unknown, ...infer tail] ? tail : never;
43
+ export type lastIndexOf<t extends array> = tailOf<t>["length"];
44
+ export type lastOf<t extends array> = t[lastIndexOf<t>];
45
+ export type initOf<t extends array> = t extends readonly [...infer init, unknown] ? init : never;
46
+ export type numericStringKeyOf<t extends array> = Extract<keyof t, `${number}`>;
47
+ export type arrayIndexOf<a extends array> = keyof a extends infer k ? parseNonNegativeInteger<k & string> : never;
48
+ export type liftArray<t> = t extends array ? [
49
+ t
50
+ ] extends [anyOrNever] ? t[] : t : t[];
51
+ export declare const liftArray: <t>(data: t) => liftArray<t>;
52
+ /**
53
+ * Splits an array into two arrays based on the result of a predicate
54
+ *
55
+ * @param predicate - The guard function used to determine which items to include.
56
+ * @returns A tuple containing two arrays:
57
+ * - the first includes items for which `predicate` returns true
58
+ * - the second includes items for which `predicate` returns false
59
+ *
60
+ * @example
61
+ * const list = [1, "2", "3", 4, 5];
62
+ * const [numbers, strings] = spliterate(list, (x) => typeof x === "number");
63
+ * // Type: number[]
64
+ * // Output: [1, 4, 5]
65
+ * console.log(evens);
66
+ * // Type: string[]
67
+ * // Output: ["2", "3"]
68
+ * console.log(odds);
69
+ */
70
+ export declare const spliterate: <item, included extends item>(arr: readonly item[], predicate: GuardablePredicate<item, included>) => [included: included[], excluded: [item] extends [included] ? item[] : Exclude<item, included>[]];
71
+ export declare const includes: <a extends array>(array: a, element: unknown) => element is a[number];
72
+ export declare const range: (length: number, offset?: number) => number[];
73
+ export type AppendOptions = {
74
+ /** If true, adds the element to the beginning of the array instead of the end */
75
+ prepend?: boolean;
76
+ };
77
+ /**
78
+ * Adds a value or array to an array, returning the concatenated result
79
+ */
80
+ export declare const append: <to extends unknown[] | undefined, value extends appendableValue<to>>(to: to, value: value, opts?: AppendOptions) => to & {};
81
+ export type appendableValue<to extends array | undefined> = to extends array<infer element> ? element extends array ? array<element> : listable<element> : never;
82
+ /**
83
+ * Concatenates an element or list with a readonly list
84
+ */
85
+ export declare const conflatenate: <element>(to: readonly element[] | undefined | null, elementOrList: appendableValue<readonly element[]> | undefined | null) => readonly element[];
86
+ /**
87
+ * Concatenates a variadic list of elements or lists with a readonly list
88
+ */
89
+ export declare const conflatenateAll: <element>(...elementsOrLists: (listable<element> | undefined | null)[]) => readonly element[];
90
+ export interface ComparisonOptions<t = unknown> {
91
+ isEqual?: (l: t, r: t) => boolean;
92
+ }
93
+ /**
94
+ * Appends a value or concatenates an array to an array if it is not already included, returning the array
95
+ */
96
+ export declare const appendUnique: <to extends unknown[]>(to: to | undefined, value: noInfer<Readonly<to> | to[number]>, opts?: ComparisonOptions<to[number]>) => to;
97
+ export type groupableKeyOf<o> = keyof o extends infer k ? k extends keyof o ? o[k] extends PropertyKey ? k : never : never : never;
98
+ export type groupBy<element, discriminant extends groupableKeyOf<element>> = {
99
+ [k in element[discriminant] & PropertyKey]?: (element extends unknown ? isDisjoint<element[discriminant], k> extends true ? never : element : never)[];
100
+ } & unknown;
101
+ export declare const groupBy: <element, discriminant extends groupableKeyOf<element>>(array: readonly element[], discriminant: discriminant) => groupBy<element, discriminant>;
102
+ export declare const arrayEquals: <element>(l: array<element>, r: array<element>, opts?: ComparisonOptions<element>) => boolean;
103
+ export type validateExhaustiveKeys<keys extends readonly PropertyKey[], expectedKey extends PropertyKey> = keys extends readonly [infer head, ...infer tail extends PropertyKey[]] ? readonly [
104
+ conform<head, expectedKey>,
105
+ ...validateExhaustiveKeys<tail, Exclude<expectedKey, head>>
106
+ ] : [expectedKey] extends [never] ? [] : [expectedKey];
107
+ export type applyElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = labels extends [unknown, ...infer labelsTail] ? t extends readonly [infer head, ...infer tail] ? readonly [
108
+ ...labelElement<head, labels>,
109
+ ...applyElementLabels<tail, labelsTail>
110
+ ] : applyOptionalElementLabels<Required<t>, labels> : t;
111
+ type applyOptionalElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = labels extends readonly [unknown, ...infer labelsTail] ? t extends readonly [infer head, ...infer tail] ? [
112
+ ...labelOptionalElement<head, labels>,
113
+ ...applyOptionalElementLabels<tail, labelsTail>
114
+ ] : applyRestElementLabels<t, labels> : t;
115
+ type applyRestElementLabels<t extends readonly unknown[], labels extends readonly unknown[]> = t extends readonly [] ? [] : labels extends readonly [unknown, ...infer tail] ? [
116
+ ...labelOptionalElement<t[0], labels>,
117
+ ...applyRestElementLabels<t, tail>
118
+ ] : t;
119
+ type labelElement<element, labels extends readonly unknown[]> = labels extends readonly [unknown] ? {
120
+ [K in keyof labels]: element;
121
+ } : labels extends readonly [...infer head, unknown] ? labelElement<element, head> : [_: element];
122
+ type labelOptionalElement<element, label extends readonly unknown[]> = label extends readonly [unknown] ? {
123
+ [K in keyof label]?: element;
124
+ } : label extends readonly [...infer head, unknown] ? labelOptionalElement<element, head> : [_?: element];
125
+ export type setIndex<arr extends readonly unknown[], i extends number, to extends arr[number]> = arr extends arr[number][] ? _setIndex<arr, i, to, []> : Readonly<_setIndex<arr, i, to, []>>;
126
+ type _setIndex<arr extends readonly unknown[], i extends number, to extends arr[number], result extends arr[number][]> = arr extends readonly [infer head, ...infer tail] ? _setIndex<tail, i, to, [...result, result["length"] extends i ? to : head]> : result;
127
+ type powersOfTwo<segments extends 1[][]> = segments["length"] extends 15 ? segments : powersOfTwo<[[...segments[0], ...segments[0]], ...segments]>;
128
+ type seedOf<count> = count extends unknown ? [[1], []] : never;
129
+ type dropLongerThan<n extends number, segments extends 1[][]> = segments extends [infer head extends 1[], ...infer tail extends 1[][]] ? `${n}` extends keyof head ? dropLongerThan<n, tail> : segments : segments;
130
+ export {};
@@ -0,0 +1,4 @@
1
+ /** Shallowly copy the properties of the object. */
2
+ export declare const shallowClone: <input extends object>(input: input) => input;
3
+ /** Deeply copy the properties of the a non-subclassed Object, Array or Date.*/
4
+ export declare const deepClone: <input extends object>(input: input) => input;
@@ -0,0 +1,25 @@
1
+ import type { array } from "./arrays.ts";
2
+ import type { describeDomainOf, domainOf, inferDomain } from "./domain.ts";
3
+ import type { anyOrNever, satisfy, Stringifiable } from "./generics.ts";
4
+ import type { describeObject } from "./objectKinds.ts";
5
+ import type { stringifyUnion } from "./unionToTuple.ts";
6
+ export type DescribeOptions = {
7
+ includeArticles?: boolean;
8
+ branchDelimiter?: string;
9
+ };
10
+ export type typeToString<t, opts extends DescribeOptions = {}> = stringifyUnion<[
11
+ t
12
+ ] extends [anyOrNever] ? unknown extends t ? "any" : "never" : unknown extends t ? "unknown" : boolean extends t ? "boolean" | ([t] extends [boolean] ? never : typeToString<Exclude<t, boolean>, opts>) : t extends array ? arrayTypeToString<t, opts> : t extends object ? describeObject<t, opts> : t extends Stringifiable ? stringifiableToString<t, opts> : describeDomainOf<t, opts>, opts["branchDelimiter"] extends string ? opts["branchDelimiter"] : describeDefaults["branchDelimiter"]>;
13
+ type stringifiableToString<t extends Stringifiable, opts extends DescribeOptions> = inferDomain<domainOf<t>> extends t ? describeDomainOf<t, opts> : `${t}`;
14
+ export type describe<t> = typeToString<t, {
15
+ includeArticles: true;
16
+ branchDelimiter: " or ";
17
+ }>;
18
+ type arrayTypeToString<t extends array, opts extends DescribeOptions> = typeToString<t[number], opts> extends infer element extends string ? opts["includeArticles"] extends true ? describeArrayOf<element> : includesDelimiter<element, opts> extends true ? `(${element})[]` : `${element}[]` : never;
19
+ type describeArrayOf<element extends string> = element extends "unknown" ? "an array" : `an array of ${element}`;
20
+ type includesDelimiter<s extends string, opts extends DescribeOptions> = s extends (`${string}${opts["branchDelimiter"] extends string ? opts["branchDelimiter"] : describeDefaults["branchDelimiter"]}${string}`) ? true : false;
21
+ export type describeDefaults = satisfy<Required<DescribeOptions>, {
22
+ includeArticles: false;
23
+ branchDelimiter: " | ";
24
+ }>;
25
+ export {};
@@ -0,0 +1,49 @@
1
+ import type { describeDefaults, DescribeOptions } from "./describe.ts";
2
+ import type { show } from "./generics.ts";
3
+ import type { stringifyUnion } from "./unionToTuple.ts";
4
+ export type JsTypeOf = "object" | "function" | "number" | "bigint" | "boolean" | "string" | "symbol" | "undefined" | "null";
5
+ export declare const hasDomain: <data, domain extends Domain>(data: data, kind: domain) => data is data & inferDomain<domain>;
6
+ type TypesByDomain = {
7
+ bigint: bigint;
8
+ boolean: boolean;
9
+ number: number;
10
+ object: object;
11
+ string: string;
12
+ symbol: symbol;
13
+ undefined: undefined;
14
+ null: null;
15
+ };
16
+ export type inferDomain<kind extends Domain> = Domain extends kind ? unknown : TypesByDomain[kind];
17
+ export type Domain = show<keyof TypesByDomain>;
18
+ export type NullishDomain = "undefined" | "null";
19
+ export type NonNullishDomain = Exclude<Domain, NullishDomain>;
20
+ export type PrimitiveDomain = Exclude<Domain, "object">;
21
+ export type Primitive = inferDomain<PrimitiveDomain>;
22
+ export type domainOf<data> = unknown extends data ? Domain : data extends object ? "object" : data extends string ? "string" : data extends number ? "number" : data extends boolean ? "boolean" : data extends undefined ? "undefined" : data extends null ? "null" : data extends bigint ? "bigint" : data extends symbol ? "symbol" : never;
23
+ export declare const domainOf: <data>(data: data) => domainOf<data>;
24
+ /** Each domain's completion for the phrase "must be _____" */
25
+ export declare const domainDescriptions: {
26
+ readonly boolean: "boolean";
27
+ readonly null: "null";
28
+ readonly undefined: "undefined";
29
+ readonly bigint: "a bigint";
30
+ readonly number: "a number";
31
+ readonly object: "an object";
32
+ readonly string: "a string";
33
+ readonly symbol: "a symbol";
34
+ };
35
+ export declare const jsTypeOfDescriptions: {
36
+ readonly boolean: "boolean";
37
+ readonly null: "null";
38
+ readonly undefined: "undefined";
39
+ readonly bigint: "a bigint";
40
+ readonly number: "a number";
41
+ readonly object: "an object";
42
+ readonly string: "a string";
43
+ readonly symbol: "a symbol";
44
+ } & {
45
+ readonly function: "a function";
46
+ };
47
+ export type domainDescriptions = typeof domainDescriptions;
48
+ export type describeDomainOf<t, opts extends DescribeOptions = {}> = stringifyUnion<opts["includeArticles"] extends true ? domainDescriptions[domainOf<t>] : domainOf<t>, opts["branchDelimiter"] extends string ? opts["branchDelimiter"] : describeDefaults["branchDelimiter"]>;
49
+ export {};
@@ -0,0 +1,29 @@
1
+ import type { brand } from "./generics.ts";
2
+ import type { CastableBase } from "./records.ts";
3
+ export declare class InternalArktypeError extends Error {
4
+ }
5
+ export declare const throwInternalError: (message: string) => never;
6
+ export declare const throwError: (message: string, ctor?: new (message: string) => Error) => never;
7
+ export declare class ParseError extends Error {
8
+ readonly name = "ParseError";
9
+ }
10
+ export declare const throwParseError: (message: string) => never;
11
+ /**
12
+ * TypeScript won't suggest strings beginning with a space as properties.
13
+ * Useful for symbol-like string properties.
14
+ */
15
+ export declare const noSuggest: <s extends string>(s: s) => noSuggest<s>;
16
+ /**
17
+ * TypeScript won't suggest strings beginning with a space as properties.
18
+ * Useful for symbol-like string properties.
19
+ */
20
+ export type noSuggest<s extends string = string> = ` ${s}`;
21
+ /** Unrendered character (U+200B) used to mark a string type */
22
+ export declare const ZeroWidthSpace = "\u200B";
23
+ /** Unrendered character (U+200B) used to mark a string type */
24
+ export type ZeroWidthSpace = typeof ZeroWidthSpace;
25
+ export type ErrorMessage<message extends string = string> = `${message}${ZeroWidthSpace}`;
26
+ export interface ErrorType<ctx extends {} = {}> extends CastableBase<ctx> {
27
+ [brand]: "ErrorType";
28
+ }
29
+ export type Completion<text extends string = string> = `${text}${ZeroWidthSpace}${ZeroWidthSpace}`;
@@ -0,0 +1,22 @@
1
+ import type { noSuggest } from "./errors.ts";
2
+ import type { Key } from "./keys.ts";
3
+ import type { Constructor } from "./objectKinds.ts";
4
+ import type { Entry } from "./records.ts";
5
+ import type { SerializationOptions } from "./serialize.ts";
6
+ export declare const arkKind: noSuggest<"arkKind">;
7
+ export type arkKind = typeof arkKind;
8
+ export declare const arkKindOf: (value: unknown) => unknown;
9
+ export declare const isStandardSchema: (o: object) => boolean;
10
+ export declare const isDate: (value: unknown) => value is Date;
11
+ export declare const isInstanceOf: (o: object, ctor: Function) => boolean;
12
+ export declare const prototypeOf: (o: object) => object | null;
13
+ export declare const arityOf: (fn: Function) => number;
14
+ export declare const readsOnlyData: WeakSet<Function>;
15
+ export declare const returnsReports: WeakSet<Function>;
16
+ export declare const testsOrRejects: WeakSet<Function>;
17
+ export declare const functionNameOf: (fn: Function) => string;
18
+ export declare const constructorNameOf: (o: object) => string | undefined;
19
+ export declare const expressionOf: (o: object) => string | undefined;
20
+ export declare const toJsonMethodOf: (o: object) => (() => unknown) | undefined;
21
+ export declare const constructorExtends: (ctor: Constructor, base: Constructor) => boolean;
22
+ export declare const ownEntriesOf: (o: object, opts: SerializationOptions) => Entry<Key>[];
@@ -0,0 +1,41 @@
1
+ import { type array, type listable } from "./arrays.ts";
2
+ import type { conform, show } from "./generics.ts";
3
+ import type { Key } from "./keys.ts";
4
+ import type { Entry, entryOf } from "./records.ts";
5
+ import type { intersectUnion } from "./unionToTuple.ts";
6
+ type objectFromListableEntries<transformed extends readonly GroupableEntry[]> = show<intersectUnion<fromGroupableEntries<transformed>>>;
7
+ type fromGroupableEntries<entries extends readonly GroupableEntry[]> = {
8
+ [entry in entries[number] as entry extends GroupedEntry ? entry[0]["group"] : conform<entry[0], PropertyKey>]: entry extends GroupedEntry ? entry[1][] : entry[1];
9
+ };
10
+ type arrayFromListableEntries<transformed extends Entry> = Entry<number, never> extends transformed ? transformed[1][] : _arrayFromListableEntries<transformed, []>;
11
+ type _arrayFromListableEntries<transformed extends Entry, result extends unknown[]> = [
12
+ transformed
13
+ ] extends [never] ? result : Extract<transformed, Entry<result["length"]>> extends (infer next extends Entry) ? Exclude<transformed, next> extends infer remaining extends Entry ? [
14
+ transformed
15
+ ] extends [remaining] ? [
16
+ ...result,
17
+ ...transformed[1][]
18
+ ] : _arrayFromListableEntries<remaining, [...result, next[1]]> : never : [...result, ...transformed[1][]];
19
+ type extractEntrySets<e extends listable<GroupableEntry>> = e extends readonly GroupableEntry[] ? e : [e];
20
+ type extractEntries<e extends listable<Entry>> = e extends readonly Entry[] ? e[number] : e;
21
+ type entryArgsWithIndex<o> = {
22
+ [k in keyof o]-?: [k: k, v: Exclude<o[k], undefined>, i: number];
23
+ }[keyof o];
24
+ type numericArrayEntry<a extends array> = number extends a["length"] ? [number, a[number]] : {
25
+ [i in keyof a]: i extends `${infer n extends number}` ? [n, a[i]] : never;
26
+ }[number];
27
+ export type GroupedEntry = readonly [key: {
28
+ group: Key;
29
+ }, value: unknown];
30
+ export type GroupableEntry = Entry<Key> | Entry<number> | GroupedEntry;
31
+ export type ListableEntry = listable<GroupableEntry>;
32
+ export type fromMappedEntries<transformed extends ListableEntry> = [
33
+ transformed
34
+ ] extends [listable<Entry<number>>] ? arrayFromListableEntries<extractEntries<transformed>> : objectFromListableEntries<extractEntrySets<transformed>>;
35
+ export type FlatMorph = {
36
+ <const o extends array, transformed extends ListableEntry>(o: o, flatMapEntry: (...args: numericArrayEntry<o>) => transformed): fromMappedEntries<transformed>;
37
+ <const o extends object, transformed extends ListableEntry>(o: o, flatMapEntry: (...args: entryOf<o>) => transformed): fromMappedEntries<transformed>;
38
+ <const o extends object, transformed extends ListableEntry>(o: o, flatMapEntry: (...args: entryArgsWithIndex<o>) => transformed): fromMappedEntries<transformed>;
39
+ };
40
+ export declare const flatMorph: FlatMorph;
41
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare const uuidMatcher: RegExp;
2
+ export declare const isUuid: (s: string) => boolean;
3
+ export declare const ipv4Matcher: RegExp;
4
+ export declare const isIpv4: (s: string) => boolean;
5
+ export declare const ipv6Matcher: RegExp;
6
+ export declare const isIpv6: (s: string) => boolean;
7
+ export declare const iso8601Matcher: RegExp;
8
+ export declare const isIso8601: (s: string) => boolean;
@@ -0,0 +1,33 @@
1
+ export type Fn<args extends readonly any[] = readonly any[], returns = unknown> = (...args: args) => returns;
2
+ export declare const cached: <t>(thunk: () => t) => (() => t);
3
+ export declare const isThunk: <value>(value: value) => value is Extract<value, Thunk> extends never ? value & Thunk : Extract<value, Thunk>;
4
+ export type Thunk<ret = unknown> = () => ret;
5
+ export type thunkable<t> = t | Thunk<t>;
6
+ export declare const tryCatch: <returns, onError = never>(fn: () => returns, onError?: (e: unknown) => onError) => returns | onError;
7
+ export declare const DynamicFunction: DynamicFunction;
8
+ export type DynamicFunction = new <fn extends Fn>(...args: ConstructorParameters<typeof Function>) => fn & {
9
+ apply(thisArg: null, args: Parameters<fn>): ReturnType<fn>;
10
+ call(thisArg: null, ...args: Parameters<fn>): ReturnType<fn>;
11
+ };
12
+ export type CallableOptions<attachments extends object> = {
13
+ attach?: attachments;
14
+ bind?: object | null;
15
+ };
16
+ /** @ts-ignore required to cast function type */
17
+ export interface Callable<fn extends Fn, attachments extends object> extends fn, attachments {
18
+ }
19
+ export declare class Callable<fn extends Fn, attachments extends object = {}> {
20
+ constructor(fn: fn, ...args: {} extends attachments ? [opts?: CallableOptions<attachments>] : [opts: CallableOptions<attachments>]);
21
+ }
22
+ export type GuardablePredicate<input = unknown, narrowed extends input = input> = ((In: input) => In is narrowed) | ((In: input) => boolean);
23
+ export type TypeGuard<input = unknown, narrowed extends input = input> = (In: input) => In is narrowed;
24
+ /**
25
+ * Checks if the environment has Content Security Policy (CSP) enabled,
26
+ * preventing JIT-optimized code from being compiled via new Function().
27
+ *
28
+ * @returns `true` if a function created using new Function() can be
29
+ * successfully invoked in the environment, `false` otherwise.
30
+ *
31
+ * The result is cached for subsequent invocations.
32
+ */
33
+ export declare const envHasCsp: () => boolean;
@@ -0,0 +1,65 @@
1
+ import type { Primitive } from "./domain.ts";
2
+ import { type ErrorMessage } from "./errors.ts";
3
+ import type { unionToTuple } from "./unionToTuple.ts";
4
+ export type Stringifiable = string | boolean | number | bigint | null | undefined;
5
+ /** Force an operation like `{ a: 0 } & { b: 1 }` to be computed so that it displays `{ a: 0; b: 1 }`. */
6
+ export type show<t> = {
7
+ [k in keyof t]: t[k];
8
+ } & unknown;
9
+ /** @deprecated use "show" instead */
10
+ export type evaluate<t> = {
11
+ [k in keyof t]: t[k];
12
+ } & unknown;
13
+ export type get<t, k extends PropertyKey> = t[k & keyof t];
14
+ export type exact<t extends object, u extends object> = {
15
+ [k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : never;
16
+ };
17
+ export type exactMessageOnError<t extends object, u extends object> = {
18
+ [k in keyof t]: k extends keyof u ? conform<t[k], u[k]> : ErrorMessage<`'${k & string}' is not a valid key`>;
19
+ } & u;
20
+ export type promisable<t> = t | Promise<t>;
21
+ export type leftIfEqual<l, r> = [l, r] extends [r, l] ? l : r;
22
+ export type UnknownUnion = string | number | symbol | bigint | boolean | object | null | undefined;
23
+ /**
24
+ * Interesection (`&`) that avoids evaluating `unknown` to `{}`
25
+ */
26
+ export type andPreserveUnknown<l, r> = unknown extends l & r ? unknown : show<l & r>;
27
+ /** Can be used to test for the universal subtypes, `any` and `never`, e.g.:
28
+ *
29
+ * ```ts
30
+ * type isAnyOrNever<t> = [t] extends [anyOrNever] ? true : false
31
+ * ```
32
+ *
33
+ * The actual value is a string literal, but the only realistic subtypes
34
+ * of that literal are `any` and `never`.
35
+ */
36
+ export type anyOrNever = " anyOrNever";
37
+ export type conform<t, base> = t extends base ? t : base;
38
+ /**
39
+ * NoInfer, which TypeScript only declares from 5.4. It blocks inference only
40
+ * while `generic` is unresolved, so an object or function containing type
41
+ * parameters, whose check TypeScript resolves immediately, passes them.
42
+ */
43
+ export type noInfer<t, generic = t> = [t][generic extends unknown ? 0 : never];
44
+ export type equals<l, r> = [l, r] extends [r, l] ? true : false;
45
+ export type exactEquals<l, r> = (<_>() => _ extends l ? 1 : 2) extends <_>() => (_ extends r ? 1 : 2) ? true : false;
46
+ export declare const brand: " brand";
47
+ export type Brand<t = unknown, id = unknown> = t & {
48
+ readonly [brand]: [t, id];
49
+ };
50
+ export type unbrand<t> = t extends Brand<infer base, string> ? base : never;
51
+ export type satisfy<base, t extends base> = t;
52
+ export type defined<t> = t & ({} | null);
53
+ export type autocomplete<suggestions extends string> = suggestions | (string & {});
54
+ export type widen<t, supertypes> = collectWidenedType<t, unionToTuple<supertypes>>;
55
+ type collectWidenedType<t, remaining extends unknown[], result = never> = remaining extends [infer head, ...infer tail] ? collectWidenedType<t, tail, t extends head ? result | head : result> : result;
56
+ type narrowTuple<t extends readonly unknown[]> = t extends readonly [infer head, ...infer tail] ? readonly [head, ...narrowTuple<tail>] : [];
57
+ export type narrow<t> = t extends Primitive ? t : t extends readonly unknown[] ? narrowTuple<t> : {
58
+ [k in keyof t]: narrow<t[k]>;
59
+ };
60
+ export declare const narrow: <t>(t: narrow<t>) => t;
61
+ /** primitive key used to represent an inferred type at compile-time */
62
+ export declare const inferred: " arkInferred";
63
+ /** primitive key used to represent an inferred type at compile-time */
64
+ export type inferred = typeof inferred;
65
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { conform } from "./generics.ts";
2
+ import type { keyOf } from "./records.ts";
3
+ type getKey<o, k> = k extends keyof o ? o[k] : k extends `${infer n extends number & keyof o}` ? o[n] : never;
4
+ type getPath<o, path extends string> = path extends `${infer head}.${infer tail}` ? getPath<getKey<o, head>, tail> : getKey<o, path>;
5
+ type validatePath<o, path extends string, prefix extends string = ""> = path extends `${infer head}.${infer tail}` ? head extends keyOf<o> ? validatePath<getKey<o, head>, tail, `${prefix}${head}.`> : `Key '${head}' is not valid following '${prefix}'` : {
6
+ [k in keyOf<o>]: k extends `${path}${string}` ? `${prefix}${k}` : never;
7
+ }[keyOf<o>];
8
+ export declare const get: <const o extends object, path extends string>(data: o, pathStr: conform<path, string & validatePath<o, path>>) => getPath<o, path>;
9
+ export {};
@@ -0,0 +1,27 @@
1
+ declare const args: " args";
2
+ type args = typeof args;
3
+ export declare abstract class Hkt<constraints extends unknown[] = any> {
4
+ [args]: unknown[];
5
+ constraints: constraints;
6
+ args: this[args] extends infer args extends unknown[] ? args : never;
7
+ 0: this[args] extends [infer arg, ...any] ? arg : never;
8
+ 1: this[args] extends [any, infer arg, ...any] ? arg : never;
9
+ 2: this[args] extends [any, any, infer arg, ...any] ? arg : never;
10
+ 3: this[args] extends [any, any, any, infer arg, ...any] ? arg : never;
11
+ abstract body: unknown;
12
+ description?: string;
13
+ constructor();
14
+ }
15
+ /** A small set of HKT utility types based on https://github.com/gvergnaud/hotscript
16
+ * See https://github.com/gvergnaud/hotscript/blob/main/src/internals/core/Core.ts
17
+ */
18
+ export declare namespace Hkt {
19
+ type constructor<constraints extends unknown[] = any> = new () => Hkt<constraints>;
20
+ type args = typeof args;
21
+ type apply<hkt extends Hkt, args extends {
22
+ [i in keyof args]: hkt["constraints"][i];
23
+ }> = (hkt & {
24
+ [args]: args;
25
+ })["body"];
26
+ }
27
+ export {};
@@ -0,0 +1,12 @@
1
+ export type ListType = "or" | "and";
2
+ export interface ListPattern {
3
+ /** between exactly two items */
4
+ readonly two: string;
5
+ /** between items before the last */
6
+ readonly middle: string;
7
+ /** before the last of three or more */
8
+ readonly end: string;
9
+ }
10
+ export declare const listPattern: (or: ListPattern, and: ListPattern) => (items: readonly string[], type: ListType) => string;
11
+ /** wraps text in FSI and PDI so its direction can't reorder the text around it */
12
+ export declare const isolate: (text: string) => string;
@@ -0,0 +1,28 @@
1
+ export * from "./arrays.ts";
2
+ export * from "./clone.ts";
3
+ export * from "./describe.ts";
4
+ export * from "./domain.ts";
5
+ export * from "./errors.ts";
6
+ export * from "./facts.ts";
7
+ export * from "./flatMorph.ts";
8
+ export * from "./formats.ts";
9
+ export * from "./functions.ts";
10
+ export * from "./generics.ts";
11
+ export * from "./hkt.ts";
12
+ export * from "./i18n.ts";
13
+ export * from "./intersections.ts";
14
+ export * from "./isomorphic.ts";
15
+ export * from "./keys.ts";
16
+ export * from "./lazily.ts";
17
+ export * from "./numbers.ts";
18
+ export * from "./objectKinds.ts";
19
+ export * from "./path.ts";
20
+ export * from "./primitive.ts";
21
+ export * from "./records.ts";
22
+ export * from "./registry.ts";
23
+ export * from "./scanner.ts";
24
+ export * from "./serialize.ts";
25
+ export * from "./strings.ts";
26
+ export * from "./traits.ts";
27
+ export * from "./unionToTuple.ts";
28
+ export * from "./weak.ts";
@@ -0,0 +1,2 @@
1
+ export * from "./index.ts";
2
+ export { get } from "./get.ts";
@@ -0,0 +1,50 @@
1
+ import type { array } from "./arrays.ts";
2
+ import type { domainOf } from "./domain.ts";
3
+ import type { andPreserveUnknown } from "./generics.ts";
4
+ import type { Hkt } from "./hkt.ts";
5
+ import type { propValueOf, requiredKeyOf } from "./records.ts";
6
+ export interface AndPreserveUnknown extends Hkt<[unknown, unknown]> {
7
+ body: andPreserveUnknown<this[0], this[1]>;
8
+ }
9
+ type SequenceIntersectionKind = "array" | "parameters";
10
+ export type intersectArrays<l extends array, r extends array, operator extends Hkt = AndPreserveUnknown> = intersectSequences<l, r, [], [], operator, "array">;
11
+ export type intersectParameters<l extends array, r extends array, operator extends Hkt = AndPreserveUnknown> = intersectSequences<l, r, [], [], operator, "parameters">;
12
+ type intersectSequences<l extends array, r extends array, acc extends array, postfix extends array, operation extends Hkt, kind extends SequenceIntersectionKind> = l extends readonly [] ? kind extends "array" ? [
13
+ ] extends r ? [
14
+ ...acc,
15
+ ...postfix
16
+ ] : never : [...acc, ...r, ...postfix] : r extends readonly [] ? kind extends "array" ? [
17
+ ] extends l ? [
18
+ ...acc,
19
+ ...postfix
20
+ ] : never : [...acc, ...l, ...postfix] : [
21
+ l,
22
+ r
23
+ ] extends ([
24
+ readonly [(infer lHead)?, ...infer lTail],
25
+ readonly [(infer rHead)?, ...infer rTail]
26
+ ]) ? [
27
+ "0",
28
+ lHead,
29
+ rHead
30
+ ] extends [keyof l | keyof r, l[0], r[0]] ? intersectSequences<lTail, rTail, [
31
+ [],
32
+ []
33
+ ] extends [l, r] ? [
34
+ ...acc,
35
+ Hkt.apply<operation, [lHead, rHead]>?
36
+ ] : [...acc, Hkt.apply<operation, [lHead, rHead]>], postfix, operation, kind> : l extends readonly [...infer lInit, infer lLast] ? r extends readonly [...infer rInit, infer rLast] ? intersectSequences<lInit, rInit, acc, [
37
+ Hkt.apply<operation, [lLast, rLast]>,
38
+ ...postfix
39
+ ], operation, kind> : intersectSequences<lInit, r, acc, [
40
+ Hkt.apply<operation, [lLast, r[number]]>,
41
+ ...postfix
42
+ ], operation, kind> : r extends readonly [...infer rInit, infer rLast] ? intersectSequences<l, rInit, acc, [
43
+ Hkt.apply<operation, [l[number], rLast]>,
44
+ ...postfix
45
+ ], operation, kind> : [...acc, ...Hkt.apply<operation, [lHead, rHead]>[], ...postfix] : never;
46
+ export type isDisjoint<l, r> = overlaps<l, r> extends true ? false : true;
47
+ export type overlaps<l, r> = l & r extends never ? false : domainOf<l> & domainOf<r> extends never ? false : [l, r] extends [object, object] ? false extends (propValueOf<{
48
+ [k in Extract<keyof l & keyof r, requiredKeyOf<l> | requiredKeyOf<r>>]: overlaps<l[k], r[k]>;
49
+ }>) ? false : true : true;
50
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { autocomplete } from "./generics.ts";
2
+ /** get a CJS/ESM compatible string representing the current file */
3
+ declare const fileName: () => string;
4
+ export declare const isomorphic: {
5
+ fileName: typeof fileName;
6
+ env: Record<autocomplete<"ARK_DEBUG">, string | undefined>;
7
+ };
8
+ export {};