@modern-js/core 1.7.1-beta.peer.1 → 1.9.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 (196) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +47 -0
  3. package/bin/modern-js.js +1 -1
  4. package/compiled/ajv/codegen.js +1 -0
  5. package/compiled/ajv/dist/ajv.d.ts +16 -0
  6. package/compiled/ajv/dist/compile/codegen/code.d.ts +40 -0
  7. package/compiled/ajv/dist/compile/codegen/index.d.ts +79 -0
  8. package/compiled/ajv/dist/compile/codegen/scope.d.ts +79 -0
  9. package/compiled/ajv/dist/compile/errors.d.ts +13 -0
  10. package/compiled/ajv/dist/compile/index.d.ts +80 -0
  11. package/compiled/ajv/dist/compile/ref_error.d.ts +6 -0
  12. package/compiled/ajv/dist/compile/resolve.d.ts +12 -0
  13. package/compiled/ajv/dist/compile/rules.d.ts +28 -0
  14. package/compiled/ajv/dist/compile/util.d.ts +40 -0
  15. package/compiled/ajv/dist/compile/validate/index.d.ts +42 -0
  16. package/compiled/ajv/dist/compile/validate/subschema.d.ts +47 -0
  17. package/compiled/ajv/dist/core.d.ts +173 -0
  18. package/compiled/ajv/dist/runtime/validation_error.d.ts +7 -0
  19. package/compiled/ajv/dist/types/index.d.ts +183 -0
  20. package/compiled/ajv/dist/types/json-schema.d.ts +124 -0
  21. package/compiled/ajv/dist/types/jtd-schema.d.ts +169 -0
  22. package/compiled/ajv/index.js +9 -0
  23. package/compiled/ajv/license +22 -0
  24. package/compiled/ajv/package.json +1 -0
  25. package/compiled/ajv/uri-js/dist/es5/uri.all.d.ts +59 -0
  26. package/compiled/ajv-keywords/ajv/dist/ajv.d.ts +16 -0
  27. package/compiled/ajv-keywords/ajv/dist/compile/codegen/code.d.ts +40 -0
  28. package/compiled/ajv-keywords/ajv/dist/compile/codegen/index.d.ts +79 -0
  29. package/compiled/ajv-keywords/ajv/dist/compile/codegen/scope.d.ts +79 -0
  30. package/compiled/ajv-keywords/ajv/dist/compile/errors.d.ts +13 -0
  31. package/compiled/ajv-keywords/ajv/dist/compile/index.d.ts +80 -0
  32. package/compiled/ajv-keywords/ajv/dist/compile/ref_error.d.ts +6 -0
  33. package/compiled/ajv-keywords/ajv/dist/compile/resolve.d.ts +12 -0
  34. package/compiled/ajv-keywords/ajv/dist/compile/rules.d.ts +28 -0
  35. package/compiled/ajv-keywords/ajv/dist/compile/util.d.ts +40 -0
  36. package/compiled/ajv-keywords/ajv/dist/compile/validate/index.d.ts +42 -0
  37. package/compiled/ajv-keywords/ajv/dist/compile/validate/subschema.d.ts +47 -0
  38. package/compiled/ajv-keywords/ajv/dist/core.d.ts +173 -0
  39. package/compiled/ajv-keywords/ajv/dist/runtime/validation_error.d.ts +7 -0
  40. package/compiled/ajv-keywords/ajv/dist/types/index.d.ts +183 -0
  41. package/compiled/ajv-keywords/ajv/dist/types/json-schema.d.ts +124 -0
  42. package/compiled/ajv-keywords/ajv/dist/types/jtd-schema.d.ts +169 -0
  43. package/compiled/ajv-keywords/dist/index.d.ts +4 -0
  44. package/compiled/ajv-keywords/index.js +1 -0
  45. package/compiled/ajv-keywords/license +21 -0
  46. package/compiled/ajv-keywords/package.json +1 -0
  47. package/compiled/ajv-keywords/uri-js/dist/es5/uri.all.d.ts +59 -0
  48. package/compiled/better-ajv-errors/ajv/dist/ajv.d.ts +16 -0
  49. package/compiled/better-ajv-errors/ajv/dist/compile/codegen/code.d.ts +40 -0
  50. package/compiled/better-ajv-errors/ajv/dist/compile/codegen/index.d.ts +79 -0
  51. package/compiled/better-ajv-errors/ajv/dist/compile/codegen/scope.d.ts +79 -0
  52. package/compiled/better-ajv-errors/ajv/dist/compile/errors.d.ts +13 -0
  53. package/compiled/better-ajv-errors/ajv/dist/compile/index.d.ts +80 -0
  54. package/compiled/better-ajv-errors/ajv/dist/compile/ref_error.d.ts +6 -0
  55. package/compiled/better-ajv-errors/ajv/dist/compile/resolve.d.ts +12 -0
  56. package/compiled/better-ajv-errors/ajv/dist/compile/rules.d.ts +28 -0
  57. package/compiled/better-ajv-errors/ajv/dist/compile/util.d.ts +40 -0
  58. package/compiled/better-ajv-errors/ajv/dist/compile/validate/index.d.ts +42 -0
  59. package/compiled/better-ajv-errors/ajv/dist/compile/validate/subschema.d.ts +47 -0
  60. package/compiled/better-ajv-errors/ajv/dist/core.d.ts +173 -0
  61. package/compiled/better-ajv-errors/ajv/dist/runtime/validation_error.d.ts +7 -0
  62. package/compiled/better-ajv-errors/ajv/dist/types/index.d.ts +183 -0
  63. package/compiled/better-ajv-errors/ajv/dist/types/json-schema.d.ts +124 -0
  64. package/compiled/better-ajv-errors/ajv/dist/types/jtd-schema.d.ts +169 -0
  65. package/compiled/better-ajv-errors/index.js +1 -0
  66. package/compiled/better-ajv-errors/license +13 -0
  67. package/compiled/better-ajv-errors/package.json +1 -0
  68. package/compiled/better-ajv-errors/typings.d.ts +24 -0
  69. package/compiled/better-ajv-errors/uri-js/dist/es5/uri.all.d.ts +59 -0
  70. package/compiled/v8-compile-cache/index.js +1 -0
  71. package/compiled/v8-compile-cache/license +21 -0
  72. package/compiled/v8-compile-cache/package.json +1 -0
  73. package/dist/cli.d.ts +1 -0
  74. package/dist/cli.js +33 -0
  75. package/dist/config/defaults.d.ts +28 -0
  76. package/dist/config/defaults.js +98 -0
  77. package/dist/{types/config → config}/index.d.ts +2 -2
  78. package/dist/config/index.js +120 -0
  79. package/dist/config/mergeConfig.d.ts +30 -0
  80. package/dist/config/mergeConfig.js +26 -0
  81. package/dist/config/schema/deploy.d.ts +16 -0
  82. package/dist/config/schema/deploy.js +16 -0
  83. package/dist/config/schema/index.d.ts +466 -0
  84. package/dist/config/schema/index.js +95 -0
  85. package/dist/config/schema/output.d.ts +146 -0
  86. package/dist/config/schema/output.js +68 -0
  87. package/dist/config/schema/server.d.ts +182 -0
  88. package/dist/config/schema/server.js +107 -0
  89. package/dist/config/schema/source.d.ts +58 -0
  90. package/dist/config/schema/source.js +36 -0
  91. package/dist/config/schema/tools.d.ts +36 -0
  92. package/dist/config/schema/tools.js +19 -0
  93. package/dist/config/types/electron.d.ts +13 -0
  94. package/dist/config/types/electron.js +2 -0
  95. package/dist/config/types/index.d.ts +240 -0
  96. package/dist/config/types/index.js +2 -0
  97. package/dist/config/types/less.d.ts +10 -0
  98. package/dist/config/types/less.js +2 -0
  99. package/dist/config/types/sass.d.ts +8 -0
  100. package/dist/config/types/sass.js +2 -0
  101. package/dist/{types/config → config}/types/ssg.d.ts +8 -8
  102. package/dist/config/types/ssg.js +2 -0
  103. package/dist/config/types/test.d.ts +14 -0
  104. package/dist/config/types/test.js +2 -0
  105. package/dist/config/types/unbundle.d.ts +25 -0
  106. package/dist/config/types/unbundle.js +2 -0
  107. package/dist/{types/context.d.ts → context.d.ts} +12 -22
  108. package/dist/context.js +59 -0
  109. package/dist/index.d.ts +64 -0
  110. package/dist/index.js +177 -0
  111. package/dist/{types/initWatcher.d.ts → initWatcher.d.ts} +1 -1
  112. package/dist/initWatcher.js +75 -0
  113. package/dist/{types/loadEnv.d.ts → loadEnv.d.ts} +1 -1
  114. package/dist/loadEnv.js +21 -0
  115. package/dist/{types/loadPlugins.d.ts → loadPlugins.d.ts} +13 -16
  116. package/dist/loadPlugins.js +109 -0
  117. package/dist/manager.d.ts +72 -0
  118. package/dist/manager.js +24 -0
  119. package/dist/{types/pluginAPI.d.ts → pluginAPI.d.ts} +5 -6
  120. package/dist/pluginAPI.js +16 -0
  121. package/dist/{types/utils → utils}/commander.d.ts +1 -1
  122. package/dist/utils/commander.js +20 -0
  123. package/dist/{types/utils → utils}/repeatKeyWarning.d.ts +1 -1
  124. package/dist/utils/repeatKeyWarning.js +22 -0
  125. package/package.json +14 -28
  126. package/tsconfig.json +3 -4
  127. package/dist/js/modern/cli.js +0 -29
  128. package/dist/js/modern/config/defaults.js +0 -103
  129. package/dist/js/modern/config/index.js +0 -115
  130. package/dist/js/modern/config/mergeConfig.js +0 -22
  131. package/dist/js/modern/config/schema/deploy.js +0 -17
  132. package/dist/js/modern/config/schema/index.js +0 -107
  133. package/dist/js/modern/config/schema/output.js +0 -147
  134. package/dist/js/modern/config/schema/server.js +0 -170
  135. package/dist/js/modern/config/schema/source.js +0 -59
  136. package/dist/js/modern/config/schema/tools.js +0 -36
  137. package/dist/js/modern/config/types/electron.js +0 -1
  138. package/dist/js/modern/config/types/index.js +0 -1
  139. package/dist/js/modern/config/types/less.js +0 -0
  140. package/dist/js/modern/config/types/sass.js +0 -0
  141. package/dist/js/modern/config/types/ssg.js +0 -0
  142. package/dist/js/modern/config/types/test.js +0 -0
  143. package/dist/js/modern/config/types/unbundle.js +0 -0
  144. package/dist/js/modern/context.js +0 -63
  145. package/dist/js/modern/index.js +0 -169
  146. package/dist/js/modern/initWatcher.js +0 -62
  147. package/dist/js/modern/loadEnv.js +0 -14
  148. package/dist/js/modern/loadPlugins.js +0 -122
  149. package/dist/js/modern/manager.js +0 -28
  150. package/dist/js/modern/pluginAPI.js +0 -11
  151. package/dist/js/modern/utils/commander.js +0 -19
  152. package/dist/js/modern/utils/repeatKeyWarning.js +0 -18
  153. package/dist/js/node/cli.js +0 -35
  154. package/dist/js/node/config/defaults.js +0 -110
  155. package/dist/js/node/config/index.js +0 -182
  156. package/dist/js/node/config/mergeConfig.js +0 -32
  157. package/dist/js/node/config/schema/deploy.js +0 -26
  158. package/dist/js/node/config/schema/index.js +0 -127
  159. package/dist/js/node/config/schema/output.js +0 -156
  160. package/dist/js/node/config/schema/server.js +0 -179
  161. package/dist/js/node/config/schema/source.js +0 -68
  162. package/dist/js/node/config/schema/tools.js +0 -43
  163. package/dist/js/node/config/types/electron.js +0 -5
  164. package/dist/js/node/config/types/index.js +0 -5
  165. package/dist/js/node/config/types/less.js +0 -0
  166. package/dist/js/node/config/types/sass.js +0 -0
  167. package/dist/js/node/config/types/ssg.js +0 -0
  168. package/dist/js/node/config/types/test.js +0 -0
  169. package/dist/js/node/config/types/unbundle.js +0 -0
  170. package/dist/js/node/context.js +0 -93
  171. package/dist/js/node/index.js +0 -329
  172. package/dist/js/node/initWatcher.js +0 -82
  173. package/dist/js/node/loadEnv.js +0 -30
  174. package/dist/js/node/loadPlugins.js +0 -134
  175. package/dist/js/node/manager.js +0 -45
  176. package/dist/js/node/pluginAPI.js +0 -54
  177. package/dist/js/node/utils/commander.js +0 -32
  178. package/dist/js/node/utils/repeatKeyWarning.js +0 -31
  179. package/dist/types/cli.d.ts +0 -1
  180. package/dist/types/config/defaults.d.ts +0 -28
  181. package/dist/types/config/mergeConfig.d.ts +0 -31
  182. package/dist/types/config/schema/deploy.d.ts +0 -16
  183. package/dist/types/config/schema/index.d.ts +0 -466
  184. package/dist/types/config/schema/output.d.ts +0 -146
  185. package/dist/types/config/schema/server.d.ts +0 -182
  186. package/dist/types/config/schema/source.d.ts +0 -58
  187. package/dist/types/config/schema/tools.d.ts +0 -36
  188. package/dist/types/config/types/electron.d.ts +0 -13
  189. package/dist/types/config/types/index.d.ts +0 -252
  190. package/dist/types/config/types/less.d.ts +0 -10
  191. package/dist/types/config/types/sass.d.ts +0 -8
  192. package/dist/types/config/types/test.d.ts +0 -15
  193. package/dist/types/config/types/unbundle.d.ts +0 -28
  194. package/dist/types/index.d.ts +0 -64
  195. package/dist/types/manager.d.ts +0 -75
  196. package/modern.config.js +0 -6
@@ -0,0 +1,183 @@
1
+ import * as URI from '../../../uri-js';
2
+ import type { CodeGen, Code, Name, ScopeValueSets, ValueScopeName } from '../compile/codegen';
3
+ import type { SchemaEnv, SchemaCxt, SchemaObjCxt } from '../compile';
4
+ import type { JSONType } from '../compile/rules';
5
+ import type { KeywordCxt } from '../compile/validate';
6
+ import type Ajv from '../core';
7
+ interface _SchemaObject {
8
+ id?: string;
9
+ $id?: string;
10
+ $schema?: string;
11
+ [x: string]: any;
12
+ }
13
+ export interface SchemaObject extends _SchemaObject {
14
+ id?: string;
15
+ $id?: string;
16
+ $schema?: string;
17
+ $async?: false;
18
+ [x: string]: any;
19
+ }
20
+ export interface AsyncSchema extends _SchemaObject {
21
+ $async: true;
22
+ }
23
+ export declare type AnySchemaObject = SchemaObject | AsyncSchema;
24
+ export declare type Schema = SchemaObject | boolean;
25
+ export declare type AnySchema = Schema | AsyncSchema;
26
+ export declare type SchemaMap = {
27
+ [Key in string]?: AnySchema;
28
+ };
29
+ export interface SourceCode {
30
+ validateName: ValueScopeName;
31
+ validateCode: string;
32
+ scopeValues: ScopeValueSets;
33
+ evaluated?: Code;
34
+ }
35
+ export interface DataValidationCxt<T extends string | number = string | number> {
36
+ instancePath: string;
37
+ parentData: {
38
+ [K in T]: any;
39
+ };
40
+ parentDataProperty: T;
41
+ rootData: Record<string, any> | any[];
42
+ dynamicAnchors: {
43
+ [Ref in string]?: ValidateFunction;
44
+ };
45
+ }
46
+ export interface ValidateFunction<T = unknown> {
47
+ (this: Ajv | any, data: any, dataCxt?: DataValidationCxt): data is T;
48
+ errors?: null | ErrorObject[];
49
+ evaluated?: Evaluated;
50
+ schema: AnySchema;
51
+ schemaEnv: SchemaEnv;
52
+ source?: SourceCode;
53
+ }
54
+ export interface JTDParser<T = unknown> {
55
+ (json: string): T | undefined;
56
+ message?: string;
57
+ position?: number;
58
+ }
59
+ export declare type EvaluatedProperties = {
60
+ [K in string]?: true;
61
+ } | true;
62
+ export declare type EvaluatedItems = number | true;
63
+ export interface Evaluated {
64
+ props?: EvaluatedProperties;
65
+ items?: EvaluatedItems;
66
+ dynamicProps: boolean;
67
+ dynamicItems: boolean;
68
+ }
69
+ export interface AsyncValidateFunction<T = unknown> extends ValidateFunction<T> {
70
+ (...args: Parameters<ValidateFunction<T>>): Promise<T>;
71
+ $async: true;
72
+ }
73
+ export declare type AnyValidateFunction<T = any> = ValidateFunction<T> | AsyncValidateFunction<T>;
74
+ export interface ErrorObject<K extends string = string, P = Record<string, any>, S = unknown> {
75
+ keyword: K;
76
+ instancePath: string;
77
+ schemaPath: string;
78
+ params: P;
79
+ propertyName?: string;
80
+ message?: string;
81
+ schema?: S;
82
+ parentSchema?: AnySchemaObject;
83
+ data?: unknown;
84
+ }
85
+ export declare type ErrorNoParams<K extends string, S = unknown> = ErrorObject<K, Record<string, never>, S>;
86
+ interface _KeywordDef {
87
+ keyword: string | string[];
88
+ type?: JSONType | JSONType[];
89
+ schemaType?: JSONType | JSONType[];
90
+ allowUndefined?: boolean;
91
+ $data?: boolean;
92
+ implements?: string[];
93
+ before?: string;
94
+ post?: boolean;
95
+ metaSchema?: AnySchemaObject;
96
+ validateSchema?: AnyValidateFunction;
97
+ dependencies?: string[];
98
+ error?: KeywordErrorDefinition;
99
+ $dataError?: KeywordErrorDefinition;
100
+ }
101
+ export interface CodeKeywordDefinition extends _KeywordDef {
102
+ code: (cxt: KeywordCxt, ruleType?: string) => void;
103
+ trackErrors?: boolean;
104
+ }
105
+ export declare type MacroKeywordFunc = (schema: any, parentSchema: AnySchemaObject, it: SchemaCxt) => AnySchema;
106
+ export declare type CompileKeywordFunc = (schema: any, parentSchema: AnySchemaObject, it: SchemaObjCxt) => DataValidateFunction;
107
+ export interface DataValidateFunction {
108
+ (...args: Parameters<ValidateFunction>): boolean | Promise<any>;
109
+ errors?: Partial<ErrorObject>[];
110
+ }
111
+ export interface SchemaValidateFunction {
112
+ (schema: any, data: any, parentSchema?: AnySchemaObject, dataCxt?: DataValidationCxt): boolean | Promise<any>;
113
+ errors?: Partial<ErrorObject>[];
114
+ }
115
+ export interface FuncKeywordDefinition extends _KeywordDef {
116
+ validate?: SchemaValidateFunction | DataValidateFunction;
117
+ compile?: CompileKeywordFunc;
118
+ schema?: boolean;
119
+ modifying?: boolean;
120
+ async?: boolean;
121
+ valid?: boolean;
122
+ errors?: boolean | "full";
123
+ }
124
+ export interface MacroKeywordDefinition extends FuncKeywordDefinition {
125
+ macro: MacroKeywordFunc;
126
+ }
127
+ export declare type KeywordDefinition = CodeKeywordDefinition | FuncKeywordDefinition | MacroKeywordDefinition;
128
+ export declare type AddedKeywordDefinition = KeywordDefinition & {
129
+ type: JSONType[];
130
+ schemaType: JSONType[];
131
+ };
132
+ export interface KeywordErrorDefinition {
133
+ message: string | Code | ((cxt: KeywordErrorCxt) => string | Code);
134
+ params?: Code | ((cxt: KeywordErrorCxt) => Code);
135
+ }
136
+ export declare type Vocabulary = (KeywordDefinition | string)[];
137
+ export interface KeywordErrorCxt {
138
+ gen: CodeGen;
139
+ keyword: string;
140
+ data: Name;
141
+ $data?: string | false;
142
+ schema: any;
143
+ parentSchema?: AnySchemaObject;
144
+ schemaCode: Code | number | boolean;
145
+ schemaValue: Code | number | boolean;
146
+ schemaType?: JSONType[];
147
+ errsCount?: Name;
148
+ params: KeywordCxtParams;
149
+ it: SchemaCxt;
150
+ }
151
+ export declare type KeywordCxtParams = {
152
+ [P in string]?: Code | string | number;
153
+ };
154
+ export declare type FormatValidator<T extends string | number> = (data: T) => boolean;
155
+ export declare type FormatCompare<T extends string | number> = (data1: T, data2: T) => number | undefined;
156
+ export declare type AsyncFormatValidator<T extends string | number> = (data: T) => Promise<boolean>;
157
+ export interface FormatDefinition<T extends string | number> {
158
+ type?: T extends string ? "string" | undefined : "number";
159
+ validate: FormatValidator<T> | (T extends string ? string | RegExp : never);
160
+ async?: false | undefined;
161
+ compare?: FormatCompare<T>;
162
+ }
163
+ export interface AsyncFormatDefinition<T extends string | number> {
164
+ type?: T extends string ? "string" | undefined : "number";
165
+ validate: AsyncFormatValidator<T>;
166
+ async: true;
167
+ compare?: FormatCompare<T>;
168
+ }
169
+ export declare type AddedFormat = true | RegExp | FormatValidator<string> | FormatDefinition<string> | FormatDefinition<number> | AsyncFormatDefinition<string> | AsyncFormatDefinition<number>;
170
+ export declare type Format = AddedFormat | string;
171
+ export interface RegExpEngine {
172
+ (pattern: string, u: string): RegExpLike;
173
+ code: string;
174
+ }
175
+ export interface RegExpLike {
176
+ test: (s: string) => boolean;
177
+ }
178
+ export interface UriResolver {
179
+ parse(uri: string): URI.URIComponents;
180
+ resolve(base: string, path: string): string;
181
+ serialize(component: URI.URIComponents): string;
182
+ }
183
+ export {};
@@ -0,0 +1,124 @@
1
+ declare type StrictNullChecksWrapper<Name extends string, Type> = undefined extends null ? `strictNullChecks must be true in tsconfig to use ${Name}` : Type;
2
+ declare type UnionToIntersection<U> = (U extends any ? (_: U) => void : never) extends (_: infer I) => void ? I : never;
3
+ export declare type SomeJSONSchema = UncheckedJSONSchemaType<Known, true>;
4
+ declare type UncheckedPartialSchema<T> = Partial<UncheckedJSONSchemaType<T, true>>;
5
+ export declare type PartialSchema<T> = StrictNullChecksWrapper<"PartialSchema", UncheckedPartialSchema<T>>;
6
+ declare type JSONType<T extends string, IsPartial extends boolean> = IsPartial extends true ? T | undefined : T;
7
+ interface NumberKeywords {
8
+ minimum?: number;
9
+ maximum?: number;
10
+ exclusiveMinimum?: number;
11
+ exclusiveMaximum?: number;
12
+ multipleOf?: number;
13
+ format?: string;
14
+ }
15
+ interface StringKeywords {
16
+ minLength?: number;
17
+ maxLength?: number;
18
+ pattern?: string;
19
+ format?: string;
20
+ }
21
+ declare type UncheckedJSONSchemaType<T, IsPartial extends boolean> = (// these two unions allow arbitrary unions of types
22
+ {
23
+ anyOf: readonly UncheckedJSONSchemaType<T, IsPartial>[];
24
+ } | {
25
+ oneOf: readonly UncheckedJSONSchemaType<T, IsPartial>[];
26
+ } | ({
27
+ type: readonly (T extends number ? JSONType<"number" | "integer", IsPartial> : T extends string ? JSONType<"string", IsPartial> : T extends boolean ? JSONType<"boolean", IsPartial> : never)[];
28
+ } & UnionToIntersection<T extends number ? NumberKeywords : T extends string ? StringKeywords : T extends boolean ? {} : never>) | ((T extends number ? {
29
+ type: JSONType<"number" | "integer", IsPartial>;
30
+ } & NumberKeywords : T extends string ? {
31
+ type: JSONType<"string", IsPartial>;
32
+ } & StringKeywords : T extends boolean ? {
33
+ type: JSONType<"boolean", IsPartial>;
34
+ } : T extends readonly [any, ...any[]] ? {
35
+ type: JSONType<"array", IsPartial>;
36
+ items: {
37
+ readonly [K in keyof T]-?: UncheckedJSONSchemaType<T[K], false> & Nullable<T[K]>;
38
+ } & {
39
+ length: T["length"];
40
+ };
41
+ minItems: T["length"];
42
+ } & ({
43
+ maxItems: T["length"];
44
+ } | {
45
+ additionalItems: false;
46
+ }) : T extends readonly any[] ? {
47
+ type: JSONType<"array", IsPartial>;
48
+ items: UncheckedJSONSchemaType<T[0], false>;
49
+ contains?: UncheckedPartialSchema<T[0]>;
50
+ minItems?: number;
51
+ maxItems?: number;
52
+ minContains?: number;
53
+ maxContains?: number;
54
+ uniqueItems?: true;
55
+ additionalItems?: never;
56
+ } : T extends Record<string, any> ? {
57
+ type: JSONType<"object", IsPartial>;
58
+ additionalProperties?: boolean | UncheckedJSONSchemaType<T[string], false>;
59
+ unevaluatedProperties?: boolean | UncheckedJSONSchemaType<T[string], false>;
60
+ properties?: IsPartial extends true ? Partial<UncheckedPropertiesSchema<T>> : UncheckedPropertiesSchema<T>;
61
+ patternProperties?: Record<string, UncheckedJSONSchemaType<T[string], false>>;
62
+ propertyNames?: Omit<UncheckedJSONSchemaType<string, false>, "type"> & {
63
+ type?: "string";
64
+ };
65
+ dependencies?: {
66
+ [K in keyof T]?: Readonly<(keyof T)[]> | UncheckedPartialSchema<T>;
67
+ };
68
+ dependentRequired?: {
69
+ [K in keyof T]?: Readonly<(keyof T)[]>;
70
+ };
71
+ dependentSchemas?: {
72
+ [K in keyof T]?: UncheckedPartialSchema<T>;
73
+ };
74
+ minProperties?: number;
75
+ maxProperties?: number;
76
+ } & (IsPartial extends true ? {
77
+ required: Readonly<(keyof T)[]>;
78
+ } : [UncheckedRequiredMembers<T>] extends [never] ? {
79
+ required?: Readonly<UncheckedRequiredMembers<T>[]>;
80
+ } : {
81
+ required: Readonly<UncheckedRequiredMembers<T>[]>;
82
+ }) : T extends null ? {
83
+ type: JSONType<"null", IsPartial>;
84
+ nullable: true;
85
+ } : never) & {
86
+ allOf?: Readonly<UncheckedPartialSchema<T>[]>;
87
+ anyOf?: Readonly<UncheckedPartialSchema<T>[]>;
88
+ oneOf?: Readonly<UncheckedPartialSchema<T>[]>;
89
+ if?: UncheckedPartialSchema<T>;
90
+ then?: UncheckedPartialSchema<T>;
91
+ else?: UncheckedPartialSchema<T>;
92
+ not?: UncheckedPartialSchema<T>;
93
+ })) & {
94
+ [keyword: string]: any;
95
+ $id?: string;
96
+ $ref?: string;
97
+ $defs?: Record<string, UncheckedJSONSchemaType<Known, true>>;
98
+ definitions?: Record<string, UncheckedJSONSchemaType<Known, true>>;
99
+ };
100
+ export declare type JSONSchemaType<T> = StrictNullChecksWrapper<"JSONSchemaType", UncheckedJSONSchemaType<T, false>>;
101
+ declare type Known = {
102
+ [key: string]: Known;
103
+ } | [Known, ...Known[]] | Known[] | number | string | boolean | null;
104
+ declare type UncheckedPropertiesSchema<T> = {
105
+ [K in keyof T]-?: (UncheckedJSONSchemaType<T[K], false> & Nullable<T[K]>) | {
106
+ $ref: string;
107
+ };
108
+ };
109
+ export declare type PropertiesSchema<T> = StrictNullChecksWrapper<"PropertiesSchema", UncheckedPropertiesSchema<T>>;
110
+ declare type UncheckedRequiredMembers<T> = {
111
+ [K in keyof T]-?: undefined extends T[K] ? never : K;
112
+ }[keyof T];
113
+ export declare type RequiredMembers<T> = StrictNullChecksWrapper<"RequiredMembers", UncheckedRequiredMembers<T>>;
114
+ declare type Nullable<T> = undefined extends T ? {
115
+ nullable: true;
116
+ const?: null;
117
+ enum?: Readonly<(T | null)[]>;
118
+ default?: T | null;
119
+ } : {
120
+ const?: T;
121
+ enum?: Readonly<T[]>;
122
+ default?: T;
123
+ };
124
+ export {};
@@ -0,0 +1,169 @@
1
+ /** numeric strings */
2
+ declare type NumberType = "float32" | "float64" | "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32";
3
+ /** string strings */
4
+ declare type StringType = "string" | "timestamp";
5
+ /** Generic JTD Schema without inference of the represented type */
6
+ export declare type SomeJTDSchemaType = (// ref
7
+ {
8
+ ref: string;
9
+ } | {
10
+ type: NumberType | StringType | "boolean";
11
+ } | {
12
+ enum: string[];
13
+ } | {
14
+ elements: SomeJTDSchemaType;
15
+ } | {
16
+ values: SomeJTDSchemaType;
17
+ } | {
18
+ properties: Record<string, SomeJTDSchemaType>;
19
+ optionalProperties?: Record<string, SomeJTDSchemaType>;
20
+ additionalProperties?: boolean;
21
+ } | {
22
+ properties?: Record<string, SomeJTDSchemaType>;
23
+ optionalProperties: Record<string, SomeJTDSchemaType>;
24
+ additionalProperties?: boolean;
25
+ } | {
26
+ discriminator: string;
27
+ mapping: Record<string, SomeJTDSchemaType>;
28
+ } | {}) & {
29
+ nullable?: boolean;
30
+ metadata?: Record<string, unknown>;
31
+ definitions?: Record<string, SomeJTDSchemaType>;
32
+ };
33
+ /** required keys of an object, not undefined */
34
+ declare type RequiredKeys<T> = {
35
+ [K in keyof T]-?: undefined extends T[K] ? never : K;
36
+ }[keyof T];
37
+ /** optional or undifined-able keys of an object */
38
+ declare type OptionalKeys<T> = {
39
+ [K in keyof T]-?: undefined extends T[K] ? K : never;
40
+ }[keyof T];
41
+ /** type is true if T is a union type */
42
+ declare type IsUnion_<T, U extends T = T> = false extends (T extends unknown ? ([U] extends [T] ? false : true) : never) ? false : true;
43
+ declare type IsUnion<T> = IsUnion_<T>;
44
+ /** type is true if T is identically E */
45
+ declare type TypeEquality<T, E> = [T] extends [E] ? ([E] extends [T] ? true : false) : false;
46
+ /** type is true if T or null is identically E or null*/
47
+ declare type NullTypeEquality<T, E> = TypeEquality<T | null, E | null>;
48
+ /** gets only the string literals of a type or null if a type isn't a string literal */
49
+ declare type EnumString<T> = [T] extends [never] ? null : T extends string ? string extends T ? null : T : null;
50
+ /** true if type is a union of string literals */
51
+ declare type IsEnum<T> = null extends EnumString<Exclude<T, null>> ? false : true;
52
+ /** true only if all types are array types (not tuples) */
53
+ declare type IsElements<T> = false extends IsUnion<T> ? [T] extends [readonly unknown[]] ? undefined extends T[0.5] ? false : true : false : false;
54
+ /** true if the the type is a values type */
55
+ declare type IsValues<T> = false extends IsUnion<Exclude<T, null>> ? TypeEquality<keyof Exclude<T, null>, string> : false;
56
+ /** true if type is a proeprties type and Union is false, or type is a discriminator type and Union is true */
57
+ declare type IsRecord<T, Union extends boolean> = Union extends IsUnion<Exclude<T, null>> ? null extends EnumString<keyof Exclude<T, null>> ? false : true : false;
58
+ /** actual schema */
59
+ export declare type JTDSchemaType<T, D extends Record<string, unknown> = Record<string, never>> = (// refs - where null wasn't specified, must match exactly
60
+ (null extends EnumString<keyof D> ? never : ({
61
+ [K in keyof D]: [T] extends [D[K]] ? {
62
+ ref: K;
63
+ } : never;
64
+ }[keyof D] & {
65
+ nullable?: false;
66
+ }) | (null extends T ? {
67
+ [K in keyof D]: [Exclude<T, null>] extends [Exclude<D[K], null>] ? {
68
+ ref: K;
69
+ } : never;
70
+ }[keyof D] & {
71
+ nullable: true;
72
+ } : never)) | (unknown extends T ? {
73
+ nullable?: boolean;
74
+ } : never) | ((true extends NullTypeEquality<T, number> ? {
75
+ type: NumberType;
76
+ } : true extends NullTypeEquality<T, boolean> ? {
77
+ type: "boolean";
78
+ } : true extends NullTypeEquality<T, string> ? {
79
+ type: StringType;
80
+ } : true extends NullTypeEquality<T, Date> ? {
81
+ type: "timestamp";
82
+ } : true extends IsEnum<T> ? {
83
+ enum: EnumString<Exclude<T, null>>[];
84
+ } : true extends IsElements<Exclude<T, null>> ? T extends readonly (infer E)[] ? {
85
+ elements: JTDSchemaType<E, D>;
86
+ } : never : true extends IsValues<T> ? T extends Record<string, infer V> ? {
87
+ values: JTDSchemaType<V, D>;
88
+ } : never : true extends IsRecord<T, false> ? ([RequiredKeys<Exclude<T, null>>] extends [never] ? {
89
+ properties?: Record<string, never>;
90
+ } : {
91
+ properties: {
92
+ [K in RequiredKeys<T>]: JTDSchemaType<T[K], D>;
93
+ };
94
+ }) & ([OptionalKeys<Exclude<T, null>>] extends [never] ? {
95
+ optionalProperties?: Record<string, never>;
96
+ } : {
97
+ optionalProperties: {
98
+ [K in OptionalKeys<T>]: JTDSchemaType<Exclude<T[K], undefined>, D>;
99
+ };
100
+ }) & {
101
+ additionalProperties?: boolean;
102
+ } : true extends IsRecord<T, true> ? {
103
+ [K in keyof Exclude<T, null>]-?: Exclude<T, null>[K] extends string ? {
104
+ discriminator: K;
105
+ mapping: {
106
+ [M in Exclude<T, null>[K]]: JTDSchemaType<Omit<T extends {
107
+ [C in K]: M;
108
+ } ? T : never, K>, D>;
109
+ };
110
+ } : never;
111
+ }[keyof Exclude<T, null>] : never) & (null extends T ? {
112
+ nullable: true;
113
+ } : {
114
+ nullable?: false;
115
+ }))) & {
116
+ metadata?: Record<string, unknown>;
117
+ definitions?: {
118
+ [K in keyof D]: JTDSchemaType<D[K], D>;
119
+ };
120
+ };
121
+ declare type JTDDataDef<S, D extends Record<string, unknown>> = // ref
122
+ (S extends {
123
+ ref: string;
124
+ } ? D extends {
125
+ [K in S["ref"]]: infer V;
126
+ } ? JTDDataDef<V, D> : never : S extends {
127
+ type: NumberType;
128
+ } ? number : S extends {
129
+ type: "boolean";
130
+ } ? boolean : S extends {
131
+ type: "string";
132
+ } ? string : S extends {
133
+ type: "timestamp";
134
+ } ? string | Date : S extends {
135
+ enum: readonly (infer E)[];
136
+ } ? string extends E ? never : [E] extends [string] ? E : never : S extends {
137
+ elements: infer E;
138
+ } ? JTDDataDef<E, D>[] : S extends {
139
+ properties: Record<string, unknown>;
140
+ optionalProperties?: Record<string, unknown>;
141
+ additionalProperties?: boolean;
142
+ } ? {
143
+ -readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>;
144
+ } & {
145
+ -readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<S["optionalProperties"][K], D>;
146
+ } & ([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown) : S extends {
147
+ properties?: Record<string, unknown>;
148
+ optionalProperties: Record<string, unknown>;
149
+ additionalProperties?: boolean;
150
+ } ? {
151
+ -readonly [K in keyof S["properties"]]-?: JTDDataDef<S["properties"][K], D>;
152
+ } & {
153
+ -readonly [K in keyof S["optionalProperties"]]+?: JTDDataDef<S["optionalProperties"][K], D>;
154
+ } & ([S["additionalProperties"]] extends [true] ? Record<string, unknown> : unknown) : S extends {
155
+ values: infer V;
156
+ } ? Record<string, JTDDataDef<V, D>> : S extends {
157
+ discriminator: infer M;
158
+ mapping: Record<string, unknown>;
159
+ } ? [M] extends [string] ? {
160
+ [K in keyof S["mapping"]]: JTDDataDef<S["mapping"][K], D> & {
161
+ [KM in M]: K;
162
+ };
163
+ }[keyof S["mapping"]] : never : unknown) | (S extends {
164
+ nullable: true;
165
+ } ? null : never);
166
+ export declare type JTDDataType<S> = S extends {
167
+ definitions: Record<string, unknown>;
168
+ } ? JTDDataDef<S, S["definitions"]> : JTDDataDef<S, Record<string, never>>;
169
+ export {};