@contractspec/lib.schema 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EnumType.d.ts +29 -31
- package/dist/EnumType.d.ts.map +1 -1
- package/dist/EnumType.js +38 -54
- package/dist/EnumType.test.d.ts +2 -0
- package/dist/EnumType.test.d.ts.map +1 -0
- package/dist/FieldType.d.ts +19 -23
- package/dist/FieldType.d.ts.map +1 -1
- package/dist/FieldType.js +41 -47
- package/dist/FieldType.test.d.ts +2 -0
- package/dist/FieldType.test.d.ts.map +1 -0
- package/dist/GraphQLSchemaType.d.ts +8 -12
- package/dist/GraphQLSchemaType.d.ts.map +1 -1
- package/dist/GraphQLSchemaType.js +16 -18
- package/dist/GraphQLSchemaType.test.d.ts +2 -0
- package/dist/GraphQLSchemaType.test.d.ts.map +1 -0
- package/dist/JsonSchemaType.d.ts +67 -63
- package/dist/JsonSchemaType.d.ts.map +1 -1
- package/dist/JsonSchemaType.js +73 -123
- package/dist/JsonSchemaType.test.d.ts +2 -0
- package/dist/JsonSchemaType.test.d.ts.map +1 -0
- package/dist/ScalarTypeEnum.d.ts +23 -27
- package/dist/ScalarTypeEnum.d.ts.map +1 -1
- package/dist/ScalarTypeEnum.js +235 -235
- package/dist/ScalarTypeEnum.test.d.ts +2 -0
- package/dist/ScalarTypeEnum.test.d.ts.map +1 -0
- package/dist/SchemaModel.d.ts +38 -39
- package/dist/SchemaModel.d.ts.map +1 -1
- package/dist/SchemaModel.js +28 -55
- package/dist/SchemaModel.test.d.ts +2 -0
- package/dist/SchemaModel.test.d.ts.map +1 -0
- package/dist/SchemaModelType.d.ts +28 -24
- package/dist/SchemaModelType.d.ts.map +1 -1
- package/dist/SchemaModelType.js +6 -19
- package/dist/SchemaModelType.test.d.ts +2 -0
- package/dist/SchemaModelType.test.d.ts.map +1 -0
- package/dist/ZodSchemaType.d.ts +44 -40
- package/dist/ZodSchemaType.d.ts.map +1 -1
- package/dist/ZodSchemaType.js +30 -101
- package/dist/ZodSchemaType.test.d.ts +2 -0
- package/dist/ZodSchemaType.test.d.ts.map +1 -0
- package/dist/browser/EnumType.js +40 -0
- package/dist/browser/FieldType.js +43 -0
- package/dist/browser/GraphQLSchemaType.js +18 -0
- package/dist/browser/JsonSchemaType.js +74 -0
- package/dist/browser/ScalarTypeEnum.js +236 -0
- package/dist/browser/SchemaModel.js +30 -0
- package/dist/browser/SchemaModelType.js +7 -0
- package/dist/browser/ZodSchemaType.js +31 -0
- package/dist/browser/entity/defineEntity.js +128 -0
- package/dist/browser/entity/generator.js +283 -0
- package/dist/browser/entity/index.js +410 -0
- package/dist/browser/entity/types.js +0 -0
- package/dist/browser/index.js +840 -0
- package/dist/entity/defineEntity.d.ts +55 -34
- package/dist/entity/defineEntity.d.ts.map +1 -1
- package/dist/entity/defineEntity.js +123 -231
- package/dist/entity/defineEntity.test.d.ts +2 -0
- package/dist/entity/defineEntity.test.d.ts.map +1 -0
- package/dist/entity/generator.d.ts +16 -20
- package/dist/entity/generator.d.ts.map +1 -1
- package/dist/entity/generator.js +262 -196
- package/dist/entity/generator.test.d.ts +2 -0
- package/dist/entity/generator.test.d.ts.map +1 -0
- package/dist/entity/index.d.ts +4 -4
- package/dist/entity/index.d.ts.map +1 -0
- package/dist/entity/index.js +410 -4
- package/dist/entity/types.d.ts +99 -103
- package/dist/entity/types.d.ts.map +1 -1
- package/dist/entity/types.js +1 -1
- package/dist/index.d.ts +10 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +841 -13
- package/dist/node/EnumType.js +40 -0
- package/dist/node/FieldType.js +43 -0
- package/dist/node/GraphQLSchemaType.js +18 -0
- package/dist/node/JsonSchemaType.js +74 -0
- package/dist/node/ScalarTypeEnum.js +236 -0
- package/dist/node/SchemaModel.js +30 -0
- package/dist/node/SchemaModelType.js +7 -0
- package/dist/node/ZodSchemaType.js +31 -0
- package/dist/node/entity/defineEntity.js +128 -0
- package/dist/node/entity/generator.js +283 -0
- package/dist/node/entity/index.js +410 -0
- package/dist/node/entity/types.js +0 -0
- package/dist/node/index.js +840 -0
- package/package.json +123 -25
- package/dist/EnumType.js.map +0 -1
- package/dist/FieldType.js.map +0 -1
- package/dist/GraphQLSchemaType.js.map +0 -1
- package/dist/JsonSchemaType.js.map +0 -1
- package/dist/ScalarTypeEnum.js.map +0 -1
- package/dist/SchemaModel.js.map +0 -1
- package/dist/SchemaModelType.js.map +0 -1
- package/dist/ZodSchemaType.js.map +0 -1
- package/dist/entity/defineEntity.js.map +0 -1
- package/dist/entity/generator.js.map +0 -1
package/dist/EnumType.d.ts
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
import * as z
|
|
2
|
-
import { GraphQLEnumType } from
|
|
3
|
-
|
|
4
|
-
//#region src/EnumType.d.ts
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { GraphQLEnumType } from 'graphql';
|
|
5
3
|
/**
|
|
6
4
|
* Strongly-typed string enum wrapper with one source of truth for zod, GraphQL, and JSON Schema.
|
|
7
5
|
*/
|
|
8
|
-
declare class EnumType<T extends [string, ...string[]]> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
6
|
+
export declare class EnumType<T extends [string, ...string[]]> {
|
|
7
|
+
private readonly name;
|
|
8
|
+
private readonly values;
|
|
9
|
+
private readonly gqlEnum;
|
|
10
|
+
constructor(name: string, values: T);
|
|
11
|
+
/** Enum type name (used by GraphQL and JSON Schema). */
|
|
12
|
+
getName(): string;
|
|
13
|
+
/** Returns the literal tuple of allowed values. */
|
|
14
|
+
getEnumValues(): T;
|
|
15
|
+
/** GraphQL enum instance suitable for Pothos or vanilla GraphQL schemas. */
|
|
16
|
+
getPothos(): GraphQLEnumType;
|
|
17
|
+
/** zod schema representing this enum. */
|
|
18
|
+
getZod(): z.ZodEnum<{
|
|
19
|
+
[K in T[number]]: K;
|
|
20
|
+
}>;
|
|
21
|
+
/** Minimal JSON representation (alias of getJsonSchema). */
|
|
22
|
+
getJson(): {
|
|
23
|
+
type: 'string';
|
|
24
|
+
enum: T;
|
|
25
|
+
};
|
|
26
|
+
/** JSON Schema for this enum. */
|
|
27
|
+
getJsonSchema(): {
|
|
28
|
+
type: 'string';
|
|
29
|
+
enum: T;
|
|
30
|
+
};
|
|
31
31
|
}
|
|
32
|
-
type AnyEnumType = EnumType<[string, ...string[]]>;
|
|
32
|
+
export type AnyEnumType = EnumType<[string, ...string[]]>;
|
|
33
33
|
/**
|
|
34
34
|
* Helper to define an EnumType.
|
|
35
35
|
* @param name Display/type name used across GraphQL and JSON Schema
|
|
36
36
|
* @param values Literal tuple of allowed string values (at least one)
|
|
37
37
|
*/
|
|
38
|
-
declare const defineEnum: <T extends [string, ...string[]]>(name: string, values: T) => EnumType<T>;
|
|
39
|
-
//#endregion
|
|
40
|
-
export { AnyEnumType, EnumType, defineEnum };
|
|
38
|
+
export declare const defineEnum: <T extends [string, ...string[]]>(name: string, values: T) => EnumType<T>;
|
|
41
39
|
//# sourceMappingURL=EnumType.d.ts.map
|
package/dist/EnumType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumType.d.ts","
|
|
1
|
+
{"version":3,"file":"EnumType.d.ts","sourceRoot":"","sources":["../src/EnumType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;GAEG;AACH,qBAAa,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACnD,OAAO,CA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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type: "string",
|
|
40
|
-
enum: this.values
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/** JSON Schema for this enum. */
|
|
44
|
-
getJsonSchema() {
|
|
45
|
-
return this.getJson();
|
|
46
|
-
}
|
|
6
|
+
class EnumType {
|
|
7
|
+
name;
|
|
8
|
+
values;
|
|
9
|
+
gqlEnum;
|
|
10
|
+
constructor(name, values) {
|
|
11
|
+
this.name = name;
|
|
12
|
+
this.values = values;
|
|
13
|
+
this.gqlEnum = new GraphQLEnumType({
|
|
14
|
+
name: this.name,
|
|
15
|
+
values: Object.fromEntries(values.map((v) => [v, { value: v }]))
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
getName() {
|
|
19
|
+
return this.name;
|
|
20
|
+
}
|
|
21
|
+
getEnumValues() {
|
|
22
|
+
return this.values;
|
|
23
|
+
}
|
|
24
|
+
getPothos() {
|
|
25
|
+
return this.gqlEnum;
|
|
26
|
+
}
|
|
27
|
+
getZod() {
|
|
28
|
+
return z.enum(this.values);
|
|
29
|
+
}
|
|
30
|
+
getJson() {
|
|
31
|
+
return { type: "string", enum: this.values };
|
|
32
|
+
}
|
|
33
|
+
getJsonSchema() {
|
|
34
|
+
return this.getJson();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var defineEnum = (name, values) => new EnumType(name, values);
|
|
38
|
+
export {
|
|
39
|
+
defineEnum,
|
|
40
|
+
EnumType
|
|
47
41
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Helper to define an EnumType.
|
|
50
|
-
* @param name Display/type name used across GraphQL and JSON Schema
|
|
51
|
-
* @param values Literal tuple of allowed string values (at least one)
|
|
52
|
-
*/
|
|
53
|
-
const defineEnum = (name, values) => new EnumType(name, values);
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
export { EnumType, defineEnum };
|
|
57
|
-
//# sourceMappingURL=EnumType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnumType.test.d.ts","sourceRoot":"","sources":["../src/EnumType.test.ts"],"names":[],"mappings":""}
|
package/dist/FieldType.d.ts
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
import * as z
|
|
2
|
-
import { GraphQLScalarType, GraphQLScalarTypeConfig } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
zod: z$1.ZodType<TInternal>;
|
|
7
|
-
jsonSchema: unknown | (() => unknown);
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { GraphQLScalarType, type GraphQLScalarTypeConfig } from 'graphql';
|
|
3
|
+
export interface FieldTypeConfig<TInternal, TExternal = TInternal> extends GraphQLScalarTypeConfig<TInternal, TExternal> {
|
|
4
|
+
zod: z.ZodType<TInternal>;
|
|
5
|
+
jsonSchema: unknown | (() => unknown);
|
|
8
6
|
}
|
|
9
|
-
type AnyFieldType = FieldType<any, any>;
|
|
7
|
+
export type AnyFieldType = FieldType<any, any>;
|
|
10
8
|
/**
|
|
11
9
|
* GraphQL scalar wrapper that carries zod and JSON Schema metadata.
|
|
12
10
|
*
|
|
13
11
|
* TInternal is the runtime representation; TExternal is the GraphQL output.
|
|
14
12
|
*/
|
|
15
|
-
declare class FieldType<TInternal, TExternal = TInternal> extends GraphQLScalarType<TInternal, TExternal> {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
export declare class FieldType<TInternal, TExternal = TInternal> extends GraphQLScalarType<TInternal, TExternal> {
|
|
14
|
+
private zodSchema;
|
|
15
|
+
private readonly jsonSchemaDef?;
|
|
16
|
+
constructor(config: FieldTypeConfig<TInternal, TExternal>);
|
|
17
|
+
/** Return the attached zod schema for validation. */
|
|
18
|
+
getZod(): z.ZodType<TInternal>;
|
|
19
|
+
/** GraphQL scalar instance usable by Pothos or vanilla GraphQL. */
|
|
20
|
+
getPothos(): GraphQLScalarType<TInternal, TExternal>;
|
|
21
|
+
/** Return the JSON Schema (evaluates factory if provided). */
|
|
22
|
+
getJson(): unknown;
|
|
23
|
+
getJsonSchemaDef(): unknown | (() => unknown);
|
|
24
|
+
getJsonSchema(): unknown;
|
|
27
25
|
}
|
|
28
|
-
type ZodFieldType<Field extends AnyFieldType> = z
|
|
29
|
-
//#endregion
|
|
30
|
-
export { AnyFieldType, FieldType, FieldTypeConfig, ZodFieldType };
|
|
26
|
+
export type ZodFieldType<Field extends AnyFieldType> = z.infer<ReturnType<Field['getZod']>>;
|
|
31
27
|
//# sourceMappingURL=FieldType.d.ts.map
|
package/dist/FieldType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldType.d.ts","
|
|
1
|
+
{"version":3,"file":"FieldType.d.ts","sourceRoot":"","sources":["../src/FieldType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE1E,MAAM,WAAW,eAAe,CAC9B,SAAS,EACT,SAAS,GAAG,SAAS,CACrB,SAAQ,uBAAuB,CAAC,SAAS,EAAE,SAAS,CAAC;IACrD,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1B,UAAU,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;CACvC;AAGD,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
return deepResolve(this.getJson());
|
|
45
|
-
}
|
|
5
|
+
class FieldType extends GraphQLScalarType {
|
|
6
|
+
zodSchema;
|
|
7
|
+
jsonSchemaDef;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
super(config);
|
|
10
|
+
this.zodSchema = config.zod;
|
|
11
|
+
this.jsonSchemaDef = config.jsonSchema;
|
|
12
|
+
}
|
|
13
|
+
getZod() {
|
|
14
|
+
return this.zodSchema;
|
|
15
|
+
}
|
|
16
|
+
getPothos() {
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
getJson() {
|
|
20
|
+
return typeof this.jsonSchemaDef === "function" ? this.jsonSchemaDef() : this.jsonSchemaDef;
|
|
21
|
+
}
|
|
22
|
+
getJsonSchemaDef() {
|
|
23
|
+
return this.jsonSchemaDef;
|
|
24
|
+
}
|
|
25
|
+
getJsonSchema() {
|
|
26
|
+
const deepResolve = (v) => {
|
|
27
|
+
const value = typeof v === "function" ? v() : v;
|
|
28
|
+
if (Array.isArray(value))
|
|
29
|
+
return value.map((item) => deepResolve(item));
|
|
30
|
+
if (value && typeof value === "object") {
|
|
31
|
+
const obj = {};
|
|
32
|
+
for (const [k, val] of Object.entries(value)) {
|
|
33
|
+
obj[k] = deepResolve(val);
|
|
34
|
+
}
|
|
35
|
+
return obj;
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
39
|
+
return deepResolve(this.getJson());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
FieldType
|
|
46
44
|
};
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { FieldType };
|
|
50
|
-
//# sourceMappingURL=FieldType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldType.test.d.ts","sourceRoot":"","sources":["../src/FieldType.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/GraphQLSchemaType.d.ts
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { SchemaModelType } from './SchemaModelType';
|
|
5
3
|
/**
|
|
6
4
|
* Wrapper for GraphQL Type Definitions to be used in ContractSpec Schemas.
|
|
7
5
|
* Note: Runtime validation is limited to 'unknown' (pass-through) as SDL is not parsed at runtime.
|
|
8
6
|
*/
|
|
9
|
-
declare class GraphQLSchemaType implements SchemaModelType {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
export declare class GraphQLSchemaType implements SchemaModelType {
|
|
8
|
+
readonly typeDef: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly _isSchemaType = true;
|
|
11
|
+
constructor(typeDef: string, name: string);
|
|
12
|
+
getZod(): z.ZodType;
|
|
15
13
|
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { GraphQLSchemaType };
|
|
18
14
|
//# sourceMappingURL=GraphQLSchemaType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQLSchemaType.d.ts","
|
|
1
|
+
{"version":3,"file":"GraphQLSchemaType.d.ts","sourceRoot":"","sources":["../src/GraphQLSchemaType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,eAAe;aAIrC,OAAO,EAAE,MAAM;aACf,IAAI,EAAE,MAAM;IAJ9B,QAAQ,CAAC,aAAa,QAAQ;gBAGZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;IAG9B,MAAM,IAAI,CAAC,CAAC,OAAO;CAGpB"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/GraphQLSchemaType.ts
|
|
1
3
|
import { z } from "zod";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
class GraphQLSchemaType {
|
|
6
|
+
typeDef;
|
|
7
|
+
name;
|
|
8
|
+
_isSchemaType = true;
|
|
9
|
+
constructor(typeDef, name) {
|
|
10
|
+
this.typeDef = typeDef;
|
|
11
|
+
this.name = name;
|
|
12
|
+
}
|
|
13
|
+
getZod() {
|
|
14
|
+
return z.unknown();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
GraphQLSchemaType
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { GraphQLSchemaType };
|
|
21
|
-
//# sourceMappingURL=GraphQLSchemaType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphQLSchemaType.test.d.ts","sourceRoot":"","sources":["../src/GraphQLSchemaType.test.ts"],"names":[],"mappings":""}
|
package/dist/JsonSchemaType.d.ts
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema wrapper for ContractSpec compatibility.
|
|
3
|
+
*
|
|
4
|
+
* Wraps JSON Schema definitions to implement the SchemaType interface,
|
|
5
|
+
* enabling direct JSON Schema usage in ContractSpec definitions.
|
|
6
|
+
*
|
|
7
|
+
* @module JsonSchemaType
|
|
8
|
+
*/
|
|
9
|
+
import * as z from 'zod';
|
|
10
|
+
import type { SchemaModelType } from './SchemaModelType';
|
|
5
11
|
/**
|
|
6
12
|
* JSON Schema definition structure.
|
|
7
13
|
* Supports standard JSON Schema draft-07/2020-12 properties.
|
|
8
14
|
*/
|
|
9
|
-
interface JsonSchemaDefinition {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
export interface JsonSchemaDefinition {
|
|
16
|
+
type?: string | string[];
|
|
17
|
+
properties?: Record<string, JsonSchemaDefinition>;
|
|
18
|
+
required?: string[];
|
|
19
|
+
additionalProperties?: boolean | JsonSchemaDefinition;
|
|
20
|
+
items?: JsonSchemaDefinition | JsonSchemaDefinition[];
|
|
21
|
+
enum?: unknown[];
|
|
22
|
+
const?: unknown;
|
|
23
|
+
oneOf?: JsonSchemaDefinition[];
|
|
24
|
+
anyOf?: JsonSchemaDefinition[];
|
|
25
|
+
allOf?: JsonSchemaDefinition[];
|
|
26
|
+
$ref?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
default?: unknown;
|
|
30
|
+
format?: string;
|
|
31
|
+
minimum?: number;
|
|
32
|
+
maximum?: number;
|
|
33
|
+
minLength?: number;
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
pattern?: string;
|
|
36
|
+
[key: string]: unknown;
|
|
31
37
|
}
|
|
32
38
|
/**
|
|
33
39
|
* Options for JsonSchemaType wrapper.
|
|
34
40
|
*/
|
|
35
|
-
interface JsonSchemaTypeOptions {
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
export interface JsonSchemaTypeOptions {
|
|
42
|
+
/** Name for identification */
|
|
43
|
+
name?: string;
|
|
38
44
|
}
|
|
39
45
|
/**
|
|
40
46
|
* Wrapper to use JSON Schema as a SchemaType.
|
|
@@ -54,37 +60,37 @@ interface JsonSchemaTypeOptions {
|
|
|
54
60
|
* }, { name: 'CustomFields' });
|
|
55
61
|
* ```
|
|
56
62
|
*/
|
|
57
|
-
declare class JsonSchemaType implements SchemaModelType<Record<string, unknown>> {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
export declare class JsonSchemaType implements SchemaModelType<Record<string, unknown>> {
|
|
64
|
+
private readonly jsonSchema;
|
|
65
|
+
private readonly options;
|
|
66
|
+
constructor(jsonSchema: JsonSchemaDefinition, options?: JsonSchemaTypeOptions);
|
|
67
|
+
/**
|
|
68
|
+
* Convert JSON Schema to Zod schema for runtime validation.
|
|
69
|
+
*
|
|
70
|
+
* Note: This is a simplified conversion. For complex schemas,
|
|
71
|
+
* consider using a dedicated json-schema-to-zod library.
|
|
72
|
+
*/
|
|
73
|
+
getZod(): z.ZodType<Record<string, unknown>>;
|
|
74
|
+
/**
|
|
75
|
+
* Return the original JSON Schema.
|
|
76
|
+
*/
|
|
77
|
+
getJsonSchema(): JsonSchemaDefinition;
|
|
78
|
+
/**
|
|
79
|
+
* Return GraphQL type info.
|
|
80
|
+
* JSON Schema types map to JSON scalar in GraphQL.
|
|
81
|
+
*/
|
|
82
|
+
getPothos(): {
|
|
83
|
+
type: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Get the configured name for this schema.
|
|
88
|
+
*/
|
|
89
|
+
getName(): string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Convert a single JSON Schema property to Zod.
|
|
92
|
+
*/
|
|
93
|
+
private convertPropertyToZod;
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
96
|
* Helper to create a SchemaType from JSON Schema.
|
|
@@ -105,7 +111,5 @@ declare class JsonSchemaType implements SchemaModelType<Record<string, unknown>>
|
|
|
105
111
|
* });
|
|
106
112
|
* ```
|
|
107
113
|
*/
|
|
108
|
-
declare const fromJsonSchema: (schema: JsonSchemaDefinition, options?: JsonSchemaTypeOptions) => JsonSchemaType;
|
|
109
|
-
//#endregion
|
|
110
|
-
export { JsonSchemaDefinition, JsonSchemaType, JsonSchemaTypeOptions, fromJsonSchema };
|
|
114
|
+
export declare const fromJsonSchema: (schema: JsonSchemaDefinition, options?: JsonSchemaTypeOptions) => JsonSchemaType;
|
|
111
115
|
//# sourceMappingURL=JsonSchemaType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonSchemaType.d.ts","
|
|
1
|
+
{"version":3,"file":"JsonSchemaType.d.ts","sourceRoot":"","sources":["../src/JsonSchemaType.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,GAAG,oBAAoB,CAAC;IACtD,KAAK,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,CAAC;IACtD,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,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