@visulima/prisma-dmmf-transformer 2.0.29 → 2.0.30

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/prisma-dmmf-transformer [2.0.30](https://github.com/visulima/visulima/compare/@visulima/prisma-dmmf-transformer@2.0.29...@visulima/prisma-dmmf-transformer@2.0.30) (2025-09-10)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **prisma-dmmf-transformer:** update dependencies and ESLint configuration ([73aa16c](https://github.com/visulima/visulima/commit/73aa16c2d856a390ff72bf1f2159dffb6c8eb424))
6
+ * **prisma-dmmf-transformer:** update package.json and pnpm-lock.yaml for compatibility ([c12a482](https://github.com/visulima/visulima/commit/c12a4828f7b934a2faa532c380210addefc13428))
7
+
1
8
  ## @visulima/prisma-dmmf-transformer [2.0.29](https://github.com/visulima/visulima/compare/@visulima/prisma-dmmf-transformer@2.0.28...@visulima/prisma-dmmf-transformer@2.0.29) (2025-05-30)
2
9
 
3
10
  ### Bug Fixes
package/dist/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const getJSONSchemaProperty = require('./packem_shared/getJSONSchemaProperty-Ul9ZXvbT.cjs');
6
- const transformDMMF = require('./packem_shared/transformDMMF-BlrIBvPS.cjs');
5
+ const getJSONSchemaProperty = require('./packem_shared/getJSONSchemaProperty-E2OXsCgc.cjs');
6
+ const transformDMMF = require('./packem_shared/transformDMMF-CAcG255G.cjs');
7
7
 
8
8
 
9
9
 
package/dist/index.d.cts CHANGED
@@ -1,314 +1,3 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
-
3
- // ==================================================================================================
4
- // JSON Schema Draft 07
5
- // ==================================================================================================
6
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
7
- // --------------------------------------------------------------------------------------------------
8
-
9
- /**
10
- * Primitive type
11
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
12
- */
13
- type JSONSchema7TypeName =
14
- | "string" //
15
- | "number"
16
- | "integer"
17
- | "boolean"
18
- | "object"
19
- | "array"
20
- | "null";
21
-
22
- /**
23
- * Primitive type
24
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
25
- */
26
- type JSONSchema7Type =
27
- | string //
28
- | number
29
- | boolean
30
- | JSONSchema7Object
31
- | JSONSchema7Array
32
- | null;
33
-
34
- // Workaround for infinite type recursion
35
- interface JSONSchema7Object {
36
- [key: string]: JSONSchema7Type;
37
- }
38
-
39
- // Workaround for infinite type recursion
40
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
41
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
42
-
43
- /**
44
- * Meta schema
45
- *
46
- * Recommended values:
47
- * - 'http://json-schema.org/schema#'
48
- * - 'http://json-schema.org/hyper-schema#'
49
- * - 'http://json-schema.org/draft-07/schema#'
50
- * - 'http://json-schema.org/draft-07/hyper-schema#'
51
- *
52
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
53
- */
54
- type JSONSchema7Version = string;
55
-
56
- /**
57
- * JSON Schema v7
58
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
59
- */
60
- type JSONSchema7Definition = JSONSchema7 | boolean;
61
- interface JSONSchema7 {
62
- $id?: string | undefined;
63
- $ref?: string | undefined;
64
- $schema?: JSONSchema7Version | undefined;
65
- $comment?: string | undefined;
66
-
67
- /**
68
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
69
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
70
- */
71
- $defs?: {
72
- [key: string]: JSONSchema7Definition;
73
- } | undefined;
74
-
75
- /**
76
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
77
- */
78
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
79
- enum?: JSONSchema7Type[] | undefined;
80
- const?: JSONSchema7Type | undefined;
81
-
82
- /**
83
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
84
- */
85
- multipleOf?: number | undefined;
86
- maximum?: number | undefined;
87
- exclusiveMaximum?: number | undefined;
88
- minimum?: number | undefined;
89
- exclusiveMinimum?: number | undefined;
90
-
91
- /**
92
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
93
- */
94
- maxLength?: number | undefined;
95
- minLength?: number | undefined;
96
- pattern?: string | undefined;
97
-
98
- /**
99
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
100
- */
101
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
102
- additionalItems?: JSONSchema7Definition | undefined;
103
- maxItems?: number | undefined;
104
- minItems?: number | undefined;
105
- uniqueItems?: boolean | undefined;
106
- contains?: JSONSchema7Definition | undefined;
107
-
108
- /**
109
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
110
- */
111
- maxProperties?: number | undefined;
112
- minProperties?: number | undefined;
113
- required?: string[] | undefined;
114
- properties?: {
115
- [key: string]: JSONSchema7Definition;
116
- } | undefined;
117
- patternProperties?: {
118
- [key: string]: JSONSchema7Definition;
119
- } | undefined;
120
- additionalProperties?: JSONSchema7Definition | undefined;
121
- dependencies?: {
122
- [key: string]: JSONSchema7Definition | string[];
123
- } | undefined;
124
- propertyNames?: JSONSchema7Definition | undefined;
125
-
126
- /**
127
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
128
- */
129
- if?: JSONSchema7Definition | undefined;
130
- then?: JSONSchema7Definition | undefined;
131
- else?: JSONSchema7Definition | undefined;
132
-
133
- /**
134
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
135
- */
136
- allOf?: JSONSchema7Definition[] | undefined;
137
- anyOf?: JSONSchema7Definition[] | undefined;
138
- oneOf?: JSONSchema7Definition[] | undefined;
139
- not?: JSONSchema7Definition | undefined;
140
-
141
- /**
142
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
143
- */
144
- format?: string | undefined;
145
-
146
- /**
147
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
148
- */
149
- contentMediaType?: string | undefined;
150
- contentEncoding?: string | undefined;
151
-
152
- /**
153
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
154
- */
155
- definitions?: {
156
- [key: string]: JSONSchema7Definition;
157
- } | undefined;
158
-
159
- /**
160
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
161
- */
162
- title?: string | undefined;
163
- description?: string | undefined;
164
- default?: JSONSchema7Type | undefined;
165
- readOnly?: boolean | undefined;
166
- writeOnly?: boolean | undefined;
167
- examples?: JSONSchema7Type | undefined;
168
- }
169
-
170
- /**
171
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
172
-
173
- @category Type
174
- */
175
- type Primitive =
176
- | null
177
- | undefined
178
- | string
179
- | number
180
- | boolean
181
- | symbol
182
- | bigint;
183
-
184
- declare global {
185
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
186
- interface SymbolConstructor {
187
- readonly observable: symbol;
188
- }
189
- }
190
-
191
- /**
192
- Matches any primitive, `void`, `Date`, or `RegExp` value.
193
- */
194
- type BuiltIns = Primitive | void | Date | RegExp;
195
-
196
- /**
197
- Test if the given function has multiple call signatures.
198
-
199
- Needed to handle the case of a single call signature with properties.
200
-
201
- Multiple call signatures cannot currently be supported due to a TypeScript limitation.
202
- @see https://github.com/microsoft/TypeScript/issues/29732
203
- */
204
- type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> =
205
- T extends {(...arguments_: infer A): unknown; (...arguments_: infer B): unknown}
206
- ? B extends A
207
- ? A extends B
208
- ? false
209
- : true
210
- : true
211
- : false;
212
-
213
- /**
214
- Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
215
-
216
- This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
217
-
218
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
219
-
220
- @example
221
- ```
222
- // data.json
223
- {
224
- "foo": ["bar"]
225
- }
226
-
227
- // main.ts
228
- import type {ReadonlyDeep} from 'type-fest';
229
- import dataJson = require('./data.json');
230
-
231
- const data: ReadonlyDeep<typeof dataJson> = dataJson;
232
-
233
- export default data;
234
-
235
- // test.ts
236
- import data from './main';
237
-
238
- data.foo.push('bar');
239
- //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
240
- ```
241
-
242
- Note that types containing overloaded functions are not made deeply readonly due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
243
-
244
- @category Object
245
- @category Array
246
- @category Set
247
- @category Map
248
- */
249
- type ReadonlyDeep<T> = T extends BuiltIns
250
- ? T
251
- : T extends new (...arguments_: any[]) => unknown
252
- ? T // Skip class constructors
253
- : T extends (...arguments_: any[]) => unknown
254
- ? {} extends ReadonlyObjectDeep<T>
255
- ? T
256
- : HasMultipleCallSignatures<T> extends true
257
- ? T
258
- : ((...arguments_: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T>
259
- : T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>>
260
- ? ReadonlyMapDeep<KeyType, ValueType>
261
- : T extends Readonly<ReadonlySet<infer ItemType>>
262
- ? ReadonlySetDeep<ItemType>
263
- : // Identify tuples to avoid converting them to arrays inadvertently; special case `readonly [...never[]]`, as it emerges undesirably from recursive invocations of ReadonlyDeep below.
264
- T extends readonly [] | readonly [...never[]]
265
- ? readonly []
266
- : T extends readonly [infer U, ...infer V]
267
- ? readonly [ReadonlyDeep<U>, ...ReadonlyDeep<V>]
268
- : T extends readonly [...infer U, infer V]
269
- ? readonly [...ReadonlyDeep<U>, ReadonlyDeep<V>]
270
- : T extends ReadonlyArray<infer ItemType>
271
- ? ReadonlyArray<ReadonlyDeep<ItemType>>
272
- : T extends object
273
- ? ReadonlyObjectDeep<T>
274
- : unknown;
275
-
276
- /**
277
- Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
278
- */
279
- type ReadonlyMapDeep<KeyType, ValueType> = {} & Readonly<ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>>>;
280
-
281
- /**
282
- Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
283
- */
284
- type ReadonlySetDeep<ItemType> = {} & Readonly<ReadonlySet<ReadonlyDeep<ItemType>>>;
285
-
286
- /**
287
- Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
288
- */
289
- type ReadonlyObjectDeep<ObjectType extends object> = {
290
- readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
291
- };
292
-
293
- interface PropertyMetaData {
294
- hasDefaultValue: boolean;
295
- isScalar: boolean;
296
- required: boolean;
297
- }
298
- interface ModelMetaData {
299
- enums: ReadonlyDeep<DMMF.DatamodelEnum[]>;
300
- }
301
- type DefinitionMap = [name: string, definition: JSONSchema7Definition];
302
- type PropertyMap = [...DefinitionMap, PropertyMetaData];
303
- interface TransformOptions {
304
- includeRequiredFields?: "false" | "true";
305
- keepRelationScalarFields?: "false" | "true";
306
- persistOriginalType?: "false" | "true";
307
- schemaId?: string;
308
- }
309
-
310
- declare const getJSONSchemaProperty: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (field: DMMF.Field) => PropertyMap;
311
-
312
- declare const transformDmmf: (dmmf: DMMF.Document, transformOptions?: TransformOptions) => JSONSchema7;
313
-
314
- export { type DefinitionMap, type ModelMetaData, type PropertyMap, type PropertyMetaData, type TransformOptions, getJSONSchemaProperty, transformDmmf as transformDMMF };
1
+ export { default as getJSONSchemaProperty } from "./properties.d.cts";
2
+ export { default as transformDMMF } from "./transform-dmmf.d.cts";
3
+ export type { DefinitionMap, ModelMetaData, PropertyMap, PropertyMetaData, TransformOptions } from "./types.d.cts";
package/dist/index.d.mts CHANGED
@@ -1,314 +1,3 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
-
3
- // ==================================================================================================
4
- // JSON Schema Draft 07
5
- // ==================================================================================================
6
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
7
- // --------------------------------------------------------------------------------------------------
8
-
9
- /**
10
- * Primitive type
11
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
12
- */
13
- type JSONSchema7TypeName =
14
- | "string" //
15
- | "number"
16
- | "integer"
17
- | "boolean"
18
- | "object"
19
- | "array"
20
- | "null";
21
-
22
- /**
23
- * Primitive type
24
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
25
- */
26
- type JSONSchema7Type =
27
- | string //
28
- | number
29
- | boolean
30
- | JSONSchema7Object
31
- | JSONSchema7Array
32
- | null;
33
-
34
- // Workaround for infinite type recursion
35
- interface JSONSchema7Object {
36
- [key: string]: JSONSchema7Type;
37
- }
38
-
39
- // Workaround for infinite type recursion
40
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
41
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
42
-
43
- /**
44
- * Meta schema
45
- *
46
- * Recommended values:
47
- * - 'http://json-schema.org/schema#'
48
- * - 'http://json-schema.org/hyper-schema#'
49
- * - 'http://json-schema.org/draft-07/schema#'
50
- * - 'http://json-schema.org/draft-07/hyper-schema#'
51
- *
52
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
53
- */
54
- type JSONSchema7Version = string;
55
-
56
- /**
57
- * JSON Schema v7
58
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
59
- */
60
- type JSONSchema7Definition = JSONSchema7 | boolean;
61
- interface JSONSchema7 {
62
- $id?: string | undefined;
63
- $ref?: string | undefined;
64
- $schema?: JSONSchema7Version | undefined;
65
- $comment?: string | undefined;
66
-
67
- /**
68
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
69
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
70
- */
71
- $defs?: {
72
- [key: string]: JSONSchema7Definition;
73
- } | undefined;
74
-
75
- /**
76
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
77
- */
78
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
79
- enum?: JSONSchema7Type[] | undefined;
80
- const?: JSONSchema7Type | undefined;
81
-
82
- /**
83
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
84
- */
85
- multipleOf?: number | undefined;
86
- maximum?: number | undefined;
87
- exclusiveMaximum?: number | undefined;
88
- minimum?: number | undefined;
89
- exclusiveMinimum?: number | undefined;
90
-
91
- /**
92
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
93
- */
94
- maxLength?: number | undefined;
95
- minLength?: number | undefined;
96
- pattern?: string | undefined;
97
-
98
- /**
99
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
100
- */
101
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
102
- additionalItems?: JSONSchema7Definition | undefined;
103
- maxItems?: number | undefined;
104
- minItems?: number | undefined;
105
- uniqueItems?: boolean | undefined;
106
- contains?: JSONSchema7Definition | undefined;
107
-
108
- /**
109
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
110
- */
111
- maxProperties?: number | undefined;
112
- minProperties?: number | undefined;
113
- required?: string[] | undefined;
114
- properties?: {
115
- [key: string]: JSONSchema7Definition;
116
- } | undefined;
117
- patternProperties?: {
118
- [key: string]: JSONSchema7Definition;
119
- } | undefined;
120
- additionalProperties?: JSONSchema7Definition | undefined;
121
- dependencies?: {
122
- [key: string]: JSONSchema7Definition | string[];
123
- } | undefined;
124
- propertyNames?: JSONSchema7Definition | undefined;
125
-
126
- /**
127
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
128
- */
129
- if?: JSONSchema7Definition | undefined;
130
- then?: JSONSchema7Definition | undefined;
131
- else?: JSONSchema7Definition | undefined;
132
-
133
- /**
134
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
135
- */
136
- allOf?: JSONSchema7Definition[] | undefined;
137
- anyOf?: JSONSchema7Definition[] | undefined;
138
- oneOf?: JSONSchema7Definition[] | undefined;
139
- not?: JSONSchema7Definition | undefined;
140
-
141
- /**
142
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
143
- */
144
- format?: string | undefined;
145
-
146
- /**
147
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
148
- */
149
- contentMediaType?: string | undefined;
150
- contentEncoding?: string | undefined;
151
-
152
- /**
153
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
154
- */
155
- definitions?: {
156
- [key: string]: JSONSchema7Definition;
157
- } | undefined;
158
-
159
- /**
160
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
161
- */
162
- title?: string | undefined;
163
- description?: string | undefined;
164
- default?: JSONSchema7Type | undefined;
165
- readOnly?: boolean | undefined;
166
- writeOnly?: boolean | undefined;
167
- examples?: JSONSchema7Type | undefined;
168
- }
169
-
170
- /**
171
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
172
-
173
- @category Type
174
- */
175
- type Primitive =
176
- | null
177
- | undefined
178
- | string
179
- | number
180
- | boolean
181
- | symbol
182
- | bigint;
183
-
184
- declare global {
185
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
186
- interface SymbolConstructor {
187
- readonly observable: symbol;
188
- }
189
- }
190
-
191
- /**
192
- Matches any primitive, `void`, `Date`, or `RegExp` value.
193
- */
194
- type BuiltIns = Primitive | void | Date | RegExp;
195
-
196
- /**
197
- Test if the given function has multiple call signatures.
198
-
199
- Needed to handle the case of a single call signature with properties.
200
-
201
- Multiple call signatures cannot currently be supported due to a TypeScript limitation.
202
- @see https://github.com/microsoft/TypeScript/issues/29732
203
- */
204
- type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> =
205
- T extends {(...arguments_: infer A): unknown; (...arguments_: infer B): unknown}
206
- ? B extends A
207
- ? A extends B
208
- ? false
209
- : true
210
- : true
211
- : false;
212
-
213
- /**
214
- Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
215
-
216
- This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
217
-
218
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
219
-
220
- @example
221
- ```
222
- // data.json
223
- {
224
- "foo": ["bar"]
225
- }
226
-
227
- // main.ts
228
- import type {ReadonlyDeep} from 'type-fest';
229
- import dataJson = require('./data.json');
230
-
231
- const data: ReadonlyDeep<typeof dataJson> = dataJson;
232
-
233
- export default data;
234
-
235
- // test.ts
236
- import data from './main';
237
-
238
- data.foo.push('bar');
239
- //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
240
- ```
241
-
242
- Note that types containing overloaded functions are not made deeply readonly due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
243
-
244
- @category Object
245
- @category Array
246
- @category Set
247
- @category Map
248
- */
249
- type ReadonlyDeep<T> = T extends BuiltIns
250
- ? T
251
- : T extends new (...arguments_: any[]) => unknown
252
- ? T // Skip class constructors
253
- : T extends (...arguments_: any[]) => unknown
254
- ? {} extends ReadonlyObjectDeep<T>
255
- ? T
256
- : HasMultipleCallSignatures<T> extends true
257
- ? T
258
- : ((...arguments_: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T>
259
- : T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>>
260
- ? ReadonlyMapDeep<KeyType, ValueType>
261
- : T extends Readonly<ReadonlySet<infer ItemType>>
262
- ? ReadonlySetDeep<ItemType>
263
- : // Identify tuples to avoid converting them to arrays inadvertently; special case `readonly [...never[]]`, as it emerges undesirably from recursive invocations of ReadonlyDeep below.
264
- T extends readonly [] | readonly [...never[]]
265
- ? readonly []
266
- : T extends readonly [infer U, ...infer V]
267
- ? readonly [ReadonlyDeep<U>, ...ReadonlyDeep<V>]
268
- : T extends readonly [...infer U, infer V]
269
- ? readonly [...ReadonlyDeep<U>, ReadonlyDeep<V>]
270
- : T extends ReadonlyArray<infer ItemType>
271
- ? ReadonlyArray<ReadonlyDeep<ItemType>>
272
- : T extends object
273
- ? ReadonlyObjectDeep<T>
274
- : unknown;
275
-
276
- /**
277
- Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
278
- */
279
- type ReadonlyMapDeep<KeyType, ValueType> = {} & Readonly<ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>>>;
280
-
281
- /**
282
- Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
283
- */
284
- type ReadonlySetDeep<ItemType> = {} & Readonly<ReadonlySet<ReadonlyDeep<ItemType>>>;
285
-
286
- /**
287
- Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
288
- */
289
- type ReadonlyObjectDeep<ObjectType extends object> = {
290
- readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
291
- };
292
-
293
- interface PropertyMetaData {
294
- hasDefaultValue: boolean;
295
- isScalar: boolean;
296
- required: boolean;
297
- }
298
- interface ModelMetaData {
299
- enums: ReadonlyDeep<DMMF.DatamodelEnum[]>;
300
- }
301
- type DefinitionMap = [name: string, definition: JSONSchema7Definition];
302
- type PropertyMap = [...DefinitionMap, PropertyMetaData];
303
- interface TransformOptions {
304
- includeRequiredFields?: "false" | "true";
305
- keepRelationScalarFields?: "false" | "true";
306
- persistOriginalType?: "false" | "true";
307
- schemaId?: string;
308
- }
309
-
310
- declare const getJSONSchemaProperty: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (field: DMMF.Field) => PropertyMap;
311
-
312
- declare const transformDmmf: (dmmf: DMMF.Document, transformOptions?: TransformOptions) => JSONSchema7;
313
-
314
- export { type DefinitionMap, type ModelMetaData, type PropertyMap, type PropertyMetaData, type TransformOptions, getJSONSchemaProperty, transformDmmf as transformDMMF };
1
+ export { default as getJSONSchemaProperty } from "./properties.d.mts";
2
+ export { default as transformDMMF } from "./transform-dmmf.d.mts";
3
+ export type { DefinitionMap, ModelMetaData, PropertyMap, PropertyMetaData, TransformOptions } from "./types.d.mts";
package/dist/index.d.ts CHANGED
@@ -1,314 +1,3 @@
1
- import { DMMF } from '@prisma/generator-helper';
2
-
3
- // ==================================================================================================
4
- // JSON Schema Draft 07
5
- // ==================================================================================================
6
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
7
- // --------------------------------------------------------------------------------------------------
8
-
9
- /**
10
- * Primitive type
11
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
12
- */
13
- type JSONSchema7TypeName =
14
- | "string" //
15
- | "number"
16
- | "integer"
17
- | "boolean"
18
- | "object"
19
- | "array"
20
- | "null";
21
-
22
- /**
23
- * Primitive type
24
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
25
- */
26
- type JSONSchema7Type =
27
- | string //
28
- | number
29
- | boolean
30
- | JSONSchema7Object
31
- | JSONSchema7Array
32
- | null;
33
-
34
- // Workaround for infinite type recursion
35
- interface JSONSchema7Object {
36
- [key: string]: JSONSchema7Type;
37
- }
38
-
39
- // Workaround for infinite type recursion
40
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
41
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
42
-
43
- /**
44
- * Meta schema
45
- *
46
- * Recommended values:
47
- * - 'http://json-schema.org/schema#'
48
- * - 'http://json-schema.org/hyper-schema#'
49
- * - 'http://json-schema.org/draft-07/schema#'
50
- * - 'http://json-schema.org/draft-07/hyper-schema#'
51
- *
52
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
53
- */
54
- type JSONSchema7Version = string;
55
-
56
- /**
57
- * JSON Schema v7
58
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
59
- */
60
- type JSONSchema7Definition = JSONSchema7 | boolean;
61
- interface JSONSchema7 {
62
- $id?: string | undefined;
63
- $ref?: string | undefined;
64
- $schema?: JSONSchema7Version | undefined;
65
- $comment?: string | undefined;
66
-
67
- /**
68
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
69
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
70
- */
71
- $defs?: {
72
- [key: string]: JSONSchema7Definition;
73
- } | undefined;
74
-
75
- /**
76
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
77
- */
78
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
79
- enum?: JSONSchema7Type[] | undefined;
80
- const?: JSONSchema7Type | undefined;
81
-
82
- /**
83
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
84
- */
85
- multipleOf?: number | undefined;
86
- maximum?: number | undefined;
87
- exclusiveMaximum?: number | undefined;
88
- minimum?: number | undefined;
89
- exclusiveMinimum?: number | undefined;
90
-
91
- /**
92
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
93
- */
94
- maxLength?: number | undefined;
95
- minLength?: number | undefined;
96
- pattern?: string | undefined;
97
-
98
- /**
99
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
100
- */
101
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
102
- additionalItems?: JSONSchema7Definition | undefined;
103
- maxItems?: number | undefined;
104
- minItems?: number | undefined;
105
- uniqueItems?: boolean | undefined;
106
- contains?: JSONSchema7Definition | undefined;
107
-
108
- /**
109
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
110
- */
111
- maxProperties?: number | undefined;
112
- minProperties?: number | undefined;
113
- required?: string[] | undefined;
114
- properties?: {
115
- [key: string]: JSONSchema7Definition;
116
- } | undefined;
117
- patternProperties?: {
118
- [key: string]: JSONSchema7Definition;
119
- } | undefined;
120
- additionalProperties?: JSONSchema7Definition | undefined;
121
- dependencies?: {
122
- [key: string]: JSONSchema7Definition | string[];
123
- } | undefined;
124
- propertyNames?: JSONSchema7Definition | undefined;
125
-
126
- /**
127
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
128
- */
129
- if?: JSONSchema7Definition | undefined;
130
- then?: JSONSchema7Definition | undefined;
131
- else?: JSONSchema7Definition | undefined;
132
-
133
- /**
134
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
135
- */
136
- allOf?: JSONSchema7Definition[] | undefined;
137
- anyOf?: JSONSchema7Definition[] | undefined;
138
- oneOf?: JSONSchema7Definition[] | undefined;
139
- not?: JSONSchema7Definition | undefined;
140
-
141
- /**
142
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
143
- */
144
- format?: string | undefined;
145
-
146
- /**
147
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
148
- */
149
- contentMediaType?: string | undefined;
150
- contentEncoding?: string | undefined;
151
-
152
- /**
153
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
154
- */
155
- definitions?: {
156
- [key: string]: JSONSchema7Definition;
157
- } | undefined;
158
-
159
- /**
160
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
161
- */
162
- title?: string | undefined;
163
- description?: string | undefined;
164
- default?: JSONSchema7Type | undefined;
165
- readOnly?: boolean | undefined;
166
- writeOnly?: boolean | undefined;
167
- examples?: JSONSchema7Type | undefined;
168
- }
169
-
170
- /**
171
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
172
-
173
- @category Type
174
- */
175
- type Primitive =
176
- | null
177
- | undefined
178
- | string
179
- | number
180
- | boolean
181
- | symbol
182
- | bigint;
183
-
184
- declare global {
185
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
186
- interface SymbolConstructor {
187
- readonly observable: symbol;
188
- }
189
- }
190
-
191
- /**
192
- Matches any primitive, `void`, `Date`, or `RegExp` value.
193
- */
194
- type BuiltIns = Primitive | void | Date | RegExp;
195
-
196
- /**
197
- Test if the given function has multiple call signatures.
198
-
199
- Needed to handle the case of a single call signature with properties.
200
-
201
- Multiple call signatures cannot currently be supported due to a TypeScript limitation.
202
- @see https://github.com/microsoft/TypeScript/issues/29732
203
- */
204
- type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> =
205
- T extends {(...arguments_: infer A): unknown; (...arguments_: infer B): unknown}
206
- ? B extends A
207
- ? A extends B
208
- ? false
209
- : true
210
- : true
211
- : false;
212
-
213
- /**
214
- Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
215
-
216
- This is useful when a deeply nested structure needs to be exposed as completely immutable, for example, an imported JSON module or when receiving an API response that is passed around.
217
-
218
- Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/13923) if you want to have this type as a built-in in TypeScript.
219
-
220
- @example
221
- ```
222
- // data.json
223
- {
224
- "foo": ["bar"]
225
- }
226
-
227
- // main.ts
228
- import type {ReadonlyDeep} from 'type-fest';
229
- import dataJson = require('./data.json');
230
-
231
- const data: ReadonlyDeep<typeof dataJson> = dataJson;
232
-
233
- export default data;
234
-
235
- // test.ts
236
- import data from './main';
237
-
238
- data.foo.push('bar');
239
- //=> error TS2339: Property 'push' does not exist on type 'readonly string[]'
240
- ```
241
-
242
- Note that types containing overloaded functions are not made deeply readonly due to a [TypeScript limitation](https://github.com/microsoft/TypeScript/issues/29732).
243
-
244
- @category Object
245
- @category Array
246
- @category Set
247
- @category Map
248
- */
249
- type ReadonlyDeep<T> = T extends BuiltIns
250
- ? T
251
- : T extends new (...arguments_: any[]) => unknown
252
- ? T // Skip class constructors
253
- : T extends (...arguments_: any[]) => unknown
254
- ? {} extends ReadonlyObjectDeep<T>
255
- ? T
256
- : HasMultipleCallSignatures<T> extends true
257
- ? T
258
- : ((...arguments_: Parameters<T>) => ReturnType<T>) & ReadonlyObjectDeep<T>
259
- : T extends Readonly<ReadonlyMap<infer KeyType, infer ValueType>>
260
- ? ReadonlyMapDeep<KeyType, ValueType>
261
- : T extends Readonly<ReadonlySet<infer ItemType>>
262
- ? ReadonlySetDeep<ItemType>
263
- : // Identify tuples to avoid converting them to arrays inadvertently; special case `readonly [...never[]]`, as it emerges undesirably from recursive invocations of ReadonlyDeep below.
264
- T extends readonly [] | readonly [...never[]]
265
- ? readonly []
266
- : T extends readonly [infer U, ...infer V]
267
- ? readonly [ReadonlyDeep<U>, ...ReadonlyDeep<V>]
268
- : T extends readonly [...infer U, infer V]
269
- ? readonly [...ReadonlyDeep<U>, ReadonlyDeep<V>]
270
- : T extends ReadonlyArray<infer ItemType>
271
- ? ReadonlyArray<ReadonlyDeep<ItemType>>
272
- : T extends object
273
- ? ReadonlyObjectDeep<T>
274
- : unknown;
275
-
276
- /**
277
- Same as `ReadonlyDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `ReadonlyDeep`.
278
- */
279
- type ReadonlyMapDeep<KeyType, ValueType> = {} & Readonly<ReadonlyMap<ReadonlyDeep<KeyType>, ReadonlyDeep<ValueType>>>;
280
-
281
- /**
282
- Same as `ReadonlyDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `ReadonlyDeep`.
283
- */
284
- type ReadonlySetDeep<ItemType> = {} & Readonly<ReadonlySet<ReadonlyDeep<ItemType>>>;
285
-
286
- /**
287
- Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper for `ReadonlyDeep`.
288
- */
289
- type ReadonlyObjectDeep<ObjectType extends object> = {
290
- readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
291
- };
292
-
293
- interface PropertyMetaData {
294
- hasDefaultValue: boolean;
295
- isScalar: boolean;
296
- required: boolean;
297
- }
298
- interface ModelMetaData {
299
- enums: ReadonlyDeep<DMMF.DatamodelEnum[]>;
300
- }
301
- type DefinitionMap = [name: string, definition: JSONSchema7Definition];
302
- type PropertyMap = [...DefinitionMap, PropertyMetaData];
303
- interface TransformOptions {
304
- includeRequiredFields?: "false" | "true";
305
- keepRelationScalarFields?: "false" | "true";
306
- persistOriginalType?: "false" | "true";
307
- schemaId?: string;
308
- }
309
-
310
- declare const getJSONSchemaProperty: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (field: DMMF.Field) => PropertyMap;
311
-
312
- declare const transformDmmf: (dmmf: DMMF.Document, transformOptions?: TransformOptions) => JSONSchema7;
313
-
314
- export { type DefinitionMap, type ModelMetaData, type PropertyMap, type PropertyMetaData, type TransformOptions, getJSONSchemaProperty, transformDmmf as transformDMMF };
1
+ export { default as getJSONSchemaProperty } from "./properties.d.ts";
2
+ export { default as transformDMMF } from "./transform-dmmf.d.ts";
3
+ export type { DefinitionMap, ModelMetaData, PropertyMap, PropertyMetaData, TransformOptions } from "./types.d.ts";
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { default as getJSONSchemaProperty } from './packem_shared/getJSONSchemaProperty-CCMlB6rF.mjs';
2
- export { default as transformDMMF } from './packem_shared/transformDMMF-BtZz70Wg.mjs';
1
+ export { default as getJSONSchemaProperty } from './packem_shared/getJSONSchemaProperty-DulgsLKr.mjs';
2
+ export { default as transformDMMF } from './packem_shared/transformDMMF-DvU3tZ1x.mjs';
@@ -0,0 +1,4 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { DefinitionMap, ModelMetaData, TransformOptions } from "./types.d.cts";
3
+ declare const getJSONSchemaModel: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (model: DMMF.Model) => DefinitionMap;
4
+ export = getJSONSchemaModel;
@@ -0,0 +1,4 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { DefinitionMap, ModelMetaData, TransformOptions } from "./types.d.mts";
3
+ declare const getJSONSchemaModel: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (model: DMMF.Model) => DefinitionMap;
4
+ export default getJSONSchemaModel;
@@ -0,0 +1,4 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { DefinitionMap, ModelMetaData, TransformOptions } from "./types.d.ts";
3
+ declare const getJSONSchemaModel: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (model: DMMF.Model) => DefinitionMap;
4
+ export = getJSONSchemaModel;
@@ -5,25 +5,25 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
5
5
  const isDefined = /* @__PURE__ */ __name((value) => value !== void 0 && value !== null, "isDefined");
6
6
  const getJSONSchemaScalar = /* @__PURE__ */ __name((fieldType) => {
7
7
  switch (fieldType) {
8
- case "Int":
9
- case "BigInt": {
8
+ case "BigInt":
9
+ case "Int": {
10
10
  return "integer";
11
11
  }
12
- case "DateTime":
12
+ case "Boolean": {
13
+ return "boolean";
14
+ }
13
15
  case "Bytes":
16
+ case "DateTime":
14
17
  case "String": {
15
18
  return "string";
16
19
  }
17
- case "Float":
18
- case "Decimal": {
20
+ case "Decimal":
21
+ case "Float": {
19
22
  return "number";
20
23
  }
21
24
  case "Json": {
22
25
  return ["number", "string", "boolean", "object", "array", "null"];
23
26
  }
24
- case "Boolean": {
25
- return "boolean";
26
- }
27
27
  default: {
28
28
  throw new Error(`Unhandled discriminated union member: ${JSON.stringify(fieldType)}`);
29
29
  }
@@ -44,7 +44,7 @@ const getJSONSchemaType = /* @__PURE__ */ __name((field) => {
44
44
  }
45
45
  const isFieldUnion = Array.isArray(scalarFieldType);
46
46
  if (isFieldUnion) {
47
- return [.../* @__PURE__ */ new Set([...scalarFieldType, "null"])];
47
+ return [.../* @__PURE__ */ new Set(["null", ...scalarFieldType])];
48
48
  }
49
49
  return [scalarFieldType, "null"];
50
50
  }, "getJSONSchemaType");
@@ -60,23 +60,23 @@ const getDefaultValue = /* @__PURE__ */ __name((field) => {
60
60
  return null;
61
61
  }
62
62
  switch (field.type) {
63
- case "String":
64
63
  case "BigInt":
65
- case "DateTime": {
64
+ case "DateTime":
65
+ case "String": {
66
66
  return typeof fieldDefault === "string" ? fieldDefault : null;
67
67
  }
68
- case "Int":
69
- case "Float":
70
- case "Decimal": {
71
- return typeof fieldDefault === "number" ? fieldDefault : null;
72
- }
73
68
  case "Boolean": {
74
69
  return typeof fieldDefault === "boolean" ? fieldDefault : null;
75
70
  }
76
- case "Json":
77
- case "Bytes": {
71
+ case "Bytes":
72
+ case "Json": {
78
73
  return null;
79
74
  }
75
+ case "Decimal":
76
+ case "Float":
77
+ case "Int": {
78
+ return typeof fieldDefault === "number" ? fieldDefault : null;
79
+ }
80
80
  default: {
81
81
  throw new Error(`Unhandled discriminated union member: ${JSON.stringify(field.type)}`);
82
82
  }
@@ -11,25 +11,25 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
11
11
  const isDefined = /* @__PURE__ */ __name((value) => value !== void 0 && value !== null, "isDefined");
12
12
  const getJSONSchemaScalar = /* @__PURE__ */ __name((fieldType) => {
13
13
  switch (fieldType) {
14
- case "Int":
15
- case "BigInt": {
14
+ case "BigInt":
15
+ case "Int": {
16
16
  return "integer";
17
17
  }
18
- case "DateTime":
18
+ case "Boolean": {
19
+ return "boolean";
20
+ }
19
21
  case "Bytes":
22
+ case "DateTime":
20
23
  case "String": {
21
24
  return "string";
22
25
  }
23
- case "Float":
24
- case "Decimal": {
26
+ case "Decimal":
27
+ case "Float": {
25
28
  return "number";
26
29
  }
27
30
  case "Json": {
28
31
  return ["number", "string", "boolean", "object", "array", "null"];
29
32
  }
30
- case "Boolean": {
31
- return "boolean";
32
- }
33
33
  default: {
34
34
  throw new Error(`Unhandled discriminated union member: ${JSON.stringify(fieldType)}`);
35
35
  }
@@ -50,7 +50,7 @@ const getJSONSchemaType = /* @__PURE__ */ __name((field) => {
50
50
  }
51
51
  const isFieldUnion = Array.isArray(scalarFieldType);
52
52
  if (isFieldUnion) {
53
- return [.../* @__PURE__ */ new Set([...scalarFieldType, "null"])];
53
+ return [.../* @__PURE__ */ new Set(["null", ...scalarFieldType])];
54
54
  }
55
55
  return [scalarFieldType, "null"];
56
56
  }, "getJSONSchemaType");
@@ -66,23 +66,23 @@ const getDefaultValue = /* @__PURE__ */ __name((field) => {
66
66
  return null;
67
67
  }
68
68
  switch (field.type) {
69
- case "String":
70
69
  case "BigInt":
71
- case "DateTime": {
70
+ case "DateTime":
71
+ case "String": {
72
72
  return typeof fieldDefault === "string" ? fieldDefault : null;
73
73
  }
74
- case "Int":
75
- case "Float":
76
- case "Decimal": {
77
- return typeof fieldDefault === "number" ? fieldDefault : null;
78
- }
79
74
  case "Boolean": {
80
75
  return typeof fieldDefault === "boolean" ? fieldDefault : null;
81
76
  }
82
- case "Json":
83
- case "Bytes": {
77
+ case "Bytes":
78
+ case "Json": {
84
79
  return null;
85
80
  }
81
+ case "Decimal":
82
+ case "Float":
83
+ case "Int": {
84
+ return typeof fieldDefault === "number" ? fieldDefault : null;
85
+ }
86
86
  default: {
87
87
  throw new Error(`Unhandled discriminated union member: ${JSON.stringify(field.type)}`);
88
88
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const getJSONSchemaProperty = require('./getJSONSchemaProperty-Ul9ZXvbT.cjs');
3
+ const getJSONSchemaProperty = require('./getJSONSchemaProperty-E2OXsCgc.cjs');
4
4
 
5
5
  var __defProp$1 = Object.defineProperty;
6
6
  var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
@@ -1,4 +1,4 @@
1
- import getJSONSchemaProperty from './getJSONSchemaProperty-CCMlB6rF.mjs';
1
+ import getJSONSchemaProperty from './getJSONSchemaProperty-DulgsLKr.mjs';
2
2
 
3
3
  var __defProp$1 = Object.defineProperty;
4
4
  var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
@@ -0,0 +1,4 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { ModelMetaData, PropertyMap, TransformOptions } from "./types.d.cts";
3
+ declare const getJSONSchemaProperty: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (field: DMMF.Field) => PropertyMap;
4
+ export = getJSONSchemaProperty;
@@ -0,0 +1,4 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { ModelMetaData, PropertyMap, TransformOptions } from "./types.d.mts";
3
+ declare const getJSONSchemaProperty: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (field: DMMF.Field) => PropertyMap;
4
+ export default getJSONSchemaProperty;
@@ -0,0 +1,4 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { ModelMetaData, PropertyMap, TransformOptions } from "./types.d.ts";
3
+ declare const getJSONSchemaProperty: (modelMetaData: ModelMetaData, transformOptions: TransformOptions) => (field: DMMF.Field) => PropertyMap;
4
+ export = getJSONSchemaProperty;
@@ -0,0 +1,5 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { JSONSchema7 } from "json-schema";
3
+ import type { TransformOptions } from "./types.d.cts";
4
+ declare const transformDmmf: (dmmf: DMMF.Document, transformOptions?: TransformOptions) => JSONSchema7;
5
+ export = transformDmmf;
@@ -0,0 +1,5 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { JSONSchema7 } from "json-schema";
3
+ import type { TransformOptions } from "./types.d.mts";
4
+ declare const transformDmmf: (dmmf: DMMF.Document, transformOptions?: TransformOptions) => JSONSchema7;
5
+ export default transformDmmf;
@@ -0,0 +1,5 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { JSONSchema7 } from "json-schema";
3
+ import type { TransformOptions } from "./types.d.ts";
4
+ declare const transformDmmf: (dmmf: DMMF.Document, transformOptions?: TransformOptions) => JSONSchema7;
5
+ export = transformDmmf;
@@ -0,0 +1,20 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { JSONSchema7Definition } from "json-schema";
3
+ import type { ReadonlyDeep } from ".//index.d.d.cts";
4
+ export type PrismaPrimitive = "BigInt" | "Boolean" | "Bytes" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "String";
5
+ export interface PropertyMetaData {
6
+ hasDefaultValue: boolean;
7
+ isScalar: boolean;
8
+ required: boolean;
9
+ }
10
+ export interface ModelMetaData {
11
+ enums: ReadonlyDeep<DMMF.DatamodelEnum[]>;
12
+ }
13
+ export type DefinitionMap = [name: string, definition: JSONSchema7Definition];
14
+ export type PropertyMap = [...DefinitionMap, PropertyMetaData];
15
+ export interface TransformOptions {
16
+ includeRequiredFields?: "false" | "true";
17
+ keepRelationScalarFields?: "false" | "true";
18
+ persistOriginalType?: "false" | "true";
19
+ schemaId?: string;
20
+ }
@@ -0,0 +1,20 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { JSONSchema7Definition } from "json-schema";
3
+ import type { ReadonlyDeep } from ".//index.d.d.mts";
4
+ export type PrismaPrimitive = "BigInt" | "Boolean" | "Bytes" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "String";
5
+ export interface PropertyMetaData {
6
+ hasDefaultValue: boolean;
7
+ isScalar: boolean;
8
+ required: boolean;
9
+ }
10
+ export interface ModelMetaData {
11
+ enums: ReadonlyDeep<DMMF.DatamodelEnum[]>;
12
+ }
13
+ export type DefinitionMap = [name: string, definition: JSONSchema7Definition];
14
+ export type PropertyMap = [...DefinitionMap, PropertyMetaData];
15
+ export interface TransformOptions {
16
+ includeRequiredFields?: "false" | "true";
17
+ keepRelationScalarFields?: "false" | "true";
18
+ persistOriginalType?: "false" | "true";
19
+ schemaId?: string;
20
+ }
@@ -0,0 +1,20 @@
1
+ import type { DMMF } from "@prisma/generator-helper";
2
+ import type { JSONSchema7Definition } from "json-schema";
3
+ import type { ReadonlyDeep } from ".//index.d.d.ts";
4
+ export type PrismaPrimitive = "BigInt" | "Boolean" | "Bytes" | "DateTime" | "Decimal" | "Float" | "Int" | "Json" | "String";
5
+ export interface PropertyMetaData {
6
+ hasDefaultValue: boolean;
7
+ isScalar: boolean;
8
+ required: boolean;
9
+ }
10
+ export interface ModelMetaData {
11
+ enums: ReadonlyDeep<DMMF.DatamodelEnum[]>;
12
+ }
13
+ export type DefinitionMap = [name: string, definition: JSONSchema7Definition];
14
+ export type PropertyMap = [...DefinitionMap, PropertyMetaData];
15
+ export interface TransformOptions {
16
+ includeRequiredFields?: "false" | "true";
17
+ keepRelationScalarFields?: "false" | "true";
18
+ persistOriginalType?: "false" | "true";
19
+ schemaId?: string;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/prisma-dmmf-transformer",
3
- "version": "2.0.29",
3
+ "version": "2.0.30",
4
4
  "description": "A generator for Prisma to generate a valid JSON Schema v7.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -38,13 +38,13 @@
38
38
  "sideEffects": false,
39
39
  "exports": {
40
40
  ".": {
41
- "require": {
42
- "types": "./dist/index.d.cts",
43
- "default": "./dist/index.cjs"
44
- },
45
41
  "import": {
46
42
  "types": "./dist/index.d.mts",
47
43
  "default": "./dist/index.mjs"
44
+ },
45
+ "require": {
46
+ "types": "./dist/index.d.cts",
47
+ "default": "./dist/index.cjs"
48
48
  }
49
49
  },
50
50
  "./package.json": "./package.json"
@@ -66,14 +66,14 @@
66
66
  "LICENSE.md"
67
67
  ],
68
68
  "dependencies": {
69
- "@prisma/generator-helper": "6.8.2"
69
+ "@prisma/generator-helper": "6.15.0"
70
70
  },
71
71
  "peerDependencies": {
72
- "@prisma/client": "3.* || 4.*",
73
- "prisma": "3.* || 4.*"
72
+ "@prisma/client": "3.* || 4.* || 5.* || 6.*",
73
+ "prisma": "3.* || 4.* || 5.* || 6.*"
74
74
  },
75
75
  "engines": {
76
- "node": ">=18.0.0 <=23.x"
76
+ "node": ">=18.0.0 <=24.x"
77
77
  },
78
78
  "os": [
79
79
  "darwin",