prisma-nestjs-graphql 21.1.1 → 21.2.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/generate.cjs +59 -43
- package/generate.d.ts +273 -233
- package/index.cjs +1 -1
- package/package.json +1 -1
package/generate.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var require$$0 = require('await-event-emitter');
|
|
4
4
|
var assert = require('assert');
|
|
5
5
|
var lodash = require('lodash');
|
|
6
6
|
var tsMorph = require('ts-morph');
|
|
@@ -13,13 +13,6 @@ var filenamify = require('filenamify');
|
|
|
13
13
|
var flat = require('flat');
|
|
14
14
|
var pluralize = require('pluralize');
|
|
15
15
|
|
|
16
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
17
|
-
var require$1 = (
|
|
18
|
-
false
|
|
19
|
-
? /* @__PURE__ */ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('generate.cjs', document.baseURI).href)))
|
|
20
|
-
: require
|
|
21
|
-
);
|
|
22
|
-
|
|
23
16
|
function isManyAndReturnOutputType(name) {
|
|
24
17
|
const lowerName = name.toLowerCase();
|
|
25
18
|
if ((lowerName.startsWith("createmany") || lowerName.startsWith("updatemany")) && (lowerName.endsWith("andreturnoutputtype") || lowerName.endsWith("andreturn"))) {
|
|
@@ -250,8 +243,8 @@ class ImportDeclarationMap extends Map {
|
|
|
250
243
|
const value = {
|
|
251
244
|
moduleSpecifier: from,
|
|
252
245
|
namedImports: [],
|
|
253
|
-
defaultImport:
|
|
254
|
-
namespaceImport:
|
|
246
|
+
defaultImport: void 0,
|
|
247
|
+
namespaceImport: void 0
|
|
255
248
|
};
|
|
256
249
|
if (namedImport === true && namespaceImport) {
|
|
257
250
|
value.namedImports = [{ name: namespaceImport }];
|
|
@@ -284,7 +277,7 @@ async function generateFiles(args) {
|
|
|
284
277
|
const { config, eventEmitter, output, project } = args;
|
|
285
278
|
if (config.emitSingle) {
|
|
286
279
|
const rootDirectory = project.getDirectory(output) || project.createDirectory(output);
|
|
287
|
-
const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts",
|
|
280
|
+
const sourceFile = rootDirectory.getSourceFile("index.ts") || rootDirectory.createSourceFile("index.ts", void 0, { overwrite: true });
|
|
288
281
|
const statements = project.getSourceFiles().flatMap((s) => {
|
|
289
282
|
if (s === sourceFile) {
|
|
290
283
|
return [];
|
|
@@ -440,11 +433,11 @@ function getGraphqlImport(args) {
|
|
|
440
433
|
return { name: typeName, specifier: "@nestjs/graphql" };
|
|
441
434
|
}
|
|
442
435
|
case "DateTime": {
|
|
443
|
-
return { name: "Date", specifier:
|
|
436
|
+
return { name: "Date", specifier: void 0 };
|
|
444
437
|
}
|
|
445
438
|
case "true":
|
|
446
439
|
case "Boolean": {
|
|
447
|
-
return { name: "Boolean", specifier:
|
|
440
|
+
return { name: "Boolean", specifier: void 0 };
|
|
448
441
|
}
|
|
449
442
|
case "Decimal": {
|
|
450
443
|
return {
|
|
@@ -456,7 +449,7 @@ function getGraphqlImport(args) {
|
|
|
456
449
|
return { name: "GraphQLJSON", specifier: "graphql-type-json" };
|
|
457
450
|
}
|
|
458
451
|
}
|
|
459
|
-
return { name: "String", specifier:
|
|
452
|
+
return { name: "String", specifier: void 0 };
|
|
460
453
|
}
|
|
461
454
|
let sourceFileType = fileTypeByLocation(location);
|
|
462
455
|
if (sourceFileType === "output" && fileType === "model") {
|
|
@@ -696,8 +689,8 @@ function inputType(args) {
|
|
|
696
689
|
const property = propertyStructure({
|
|
697
690
|
name,
|
|
698
691
|
isNullable: !isRequired,
|
|
699
|
-
hasExclamationToken: hasExclamationToken ||
|
|
700
|
-
hasQuestionToken: hasExclamationToken ? false :
|
|
692
|
+
hasExclamationToken: hasExclamationToken || void 0,
|
|
693
|
+
hasQuestionToken: hasExclamationToken ? false : void 0,
|
|
701
694
|
propertyType,
|
|
702
695
|
isList
|
|
703
696
|
});
|
|
@@ -843,16 +836,16 @@ class ObjectSettings extends Array {
|
|
|
843
836
|
}) {
|
|
844
837
|
const fieldType = this.find((s) => s.kind === "FieldType");
|
|
845
838
|
if (!fieldType) {
|
|
846
|
-
return
|
|
839
|
+
return void 0;
|
|
847
840
|
}
|
|
848
841
|
if (fieldType.match) {
|
|
849
|
-
return fieldType.match(name) ? fieldType :
|
|
842
|
+
return fieldType.match(name) ? fieldType : void 0;
|
|
850
843
|
}
|
|
851
844
|
if (input && !fieldType.input) {
|
|
852
|
-
return
|
|
845
|
+
return void 0;
|
|
853
846
|
}
|
|
854
847
|
if (output && !fieldType.output) {
|
|
855
|
-
return
|
|
848
|
+
return void 0;
|
|
856
849
|
}
|
|
857
850
|
return fieldType;
|
|
858
851
|
}
|
|
@@ -863,16 +856,16 @@ class ObjectSettings extends Array {
|
|
|
863
856
|
}) {
|
|
864
857
|
const propertyType = this.find((s) => s.kind === "PropertyType");
|
|
865
858
|
if (!propertyType) {
|
|
866
|
-
return
|
|
859
|
+
return void 0;
|
|
867
860
|
}
|
|
868
861
|
if (propertyType.match) {
|
|
869
|
-
return propertyType.match(name) ? propertyType :
|
|
862
|
+
return propertyType.match(name) ? propertyType : void 0;
|
|
870
863
|
}
|
|
871
864
|
if (input && !propertyType.input) {
|
|
872
|
-
return
|
|
865
|
+
return void 0;
|
|
873
866
|
}
|
|
874
867
|
if (output && !propertyType.output) {
|
|
875
|
-
return
|
|
868
|
+
return void 0;
|
|
876
869
|
}
|
|
877
870
|
return propertyType;
|
|
878
871
|
}
|
|
@@ -926,7 +919,7 @@ function createObjectSettings(args) {
|
|
|
926
919
|
}
|
|
927
920
|
return {
|
|
928
921
|
settings: result,
|
|
929
|
-
documentation: documentationLines.filter(Boolean).join("\n") ||
|
|
922
|
+
documentation: documentationLines.filter(Boolean).join("\n") || void 0
|
|
930
923
|
};
|
|
931
924
|
}
|
|
932
925
|
function createSettingElement({
|
|
@@ -937,7 +930,7 @@ function createSettingElement({
|
|
|
937
930
|
}) {
|
|
938
931
|
const result = {
|
|
939
932
|
documentLine: "",
|
|
940
|
-
element:
|
|
933
|
+
element: void 0
|
|
941
934
|
};
|
|
942
935
|
if (line.startsWith("@deprecated")) {
|
|
943
936
|
fieldElement.arguments["deprecationReason"] = lodash.trim(line.slice(11));
|
|
@@ -1033,9 +1026,9 @@ function hideFieldDecorator(match) {
|
|
|
1033
1026
|
name: "HideField",
|
|
1034
1027
|
arguments: [],
|
|
1035
1028
|
from: "@nestjs/graphql",
|
|
1036
|
-
defaultImport:
|
|
1037
|
-
namespaceImport:
|
|
1038
|
-
match:
|
|
1029
|
+
defaultImport: void 0,
|
|
1030
|
+
namespaceImport: void 0,
|
|
1031
|
+
match: void 0
|
|
1039
1032
|
};
|
|
1040
1033
|
if (!match.groups?.args) {
|
|
1041
1034
|
result.output = true;
|
|
@@ -1070,8 +1063,8 @@ function parseArgs(string) {
|
|
|
1070
1063
|
}
|
|
1071
1064
|
}
|
|
1072
1065
|
function getNamespace(name) {
|
|
1073
|
-
if (name ===
|
|
1074
|
-
return
|
|
1066
|
+
if (name === void 0) {
|
|
1067
|
+
return void 0;
|
|
1075
1068
|
}
|
|
1076
1069
|
let result = String(name);
|
|
1077
1070
|
if (result.includes(".")) {
|
|
@@ -1260,7 +1253,7 @@ function modelOutputType(outputType, args) {
|
|
|
1260
1253
|
...settings?.fieldArguments(),
|
|
1261
1254
|
defaultValue: ["number", "string", "boolean"].includes(
|
|
1262
1255
|
typeof modelField?.default
|
|
1263
|
-
) ? modelField?.default :
|
|
1256
|
+
) ? modelField?.default : void 0,
|
|
1264
1257
|
description: modelField?.documentation,
|
|
1265
1258
|
nullable: Boolean(field.isNullable)
|
|
1266
1259
|
})
|
|
@@ -1403,7 +1396,7 @@ function outputType(outputType2, args) {
|
|
|
1403
1396
|
for (const field of outputType2.fields) {
|
|
1404
1397
|
const { isList, location, type } = field.outputType;
|
|
1405
1398
|
const outputTypeName = getOutputTypeName(String(type));
|
|
1406
|
-
const settings = isCountOutput ?
|
|
1399
|
+
const settings = isCountOutput ? void 0 : model && fieldSettings.get(model.name)?.get(field.name);
|
|
1407
1400
|
const propertySettings = settings?.getPropertyType({
|
|
1408
1401
|
name: outputType2.name,
|
|
1409
1402
|
output: true
|
|
@@ -1417,7 +1410,7 @@ function outputType(outputType2, args) {
|
|
|
1417
1410
|
})
|
|
1418
1411
|
);
|
|
1419
1412
|
const property = propertyStructure({
|
|
1420
|
-
hasQuestionToken: isCountOutput ? true :
|
|
1413
|
+
hasQuestionToken: isCountOutput ? true : void 0,
|
|
1421
1414
|
isList,
|
|
1422
1415
|
isNullable: field.isNullable,
|
|
1423
1416
|
name: field.name,
|
|
@@ -1616,19 +1609,41 @@ function getNamespaceExportDeclaration(directory, sourceDirectory) {
|
|
|
1616
1609
|
};
|
|
1617
1610
|
}
|
|
1618
1611
|
|
|
1612
|
+
function extractEnumValueDocs(values) {
|
|
1613
|
+
return Object.fromEntries(
|
|
1614
|
+
values.map((value) => {
|
|
1615
|
+
const { name } = value;
|
|
1616
|
+
const documentation = value.documentation;
|
|
1617
|
+
if (typeof documentation !== "string") return null;
|
|
1618
|
+
if (documentation.startsWith("@deprecated")) {
|
|
1619
|
+
return [name, { deprecationReason: documentation.slice(11).trim() }];
|
|
1620
|
+
}
|
|
1621
|
+
return [name, { description: documentation }];
|
|
1622
|
+
}).filter((entry) => entry !== null)
|
|
1623
|
+
);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1619
1626
|
function registerEnum(enumType, args) {
|
|
1620
|
-
const {
|
|
1627
|
+
const { config, enums, getSourceFile } = args;
|
|
1621
1628
|
if (!config.emitBlocks.prismaEnums && !enums[enumType.name]) return;
|
|
1622
1629
|
const dataModelEnum = enums[enumType.name];
|
|
1630
|
+
const enumTypesData = dataModelEnum?.values || [];
|
|
1623
1631
|
const sourceFile = getSourceFile({
|
|
1624
1632
|
name: enumType.name,
|
|
1625
1633
|
type: "enum"
|
|
1626
1634
|
});
|
|
1627
1635
|
const importDeclarations = new ImportDeclarationMap();
|
|
1628
1636
|
importDeclarations.set("registerEnumType", {
|
|
1629
|
-
|
|
1630
|
-
|
|
1637
|
+
moduleSpecifier: "@nestjs/graphql",
|
|
1638
|
+
namedImports: [{ name: "registerEnumType" }]
|
|
1631
1639
|
});
|
|
1640
|
+
const valuesMap = extractEnumValueDocs(enumTypesData);
|
|
1641
|
+
const filteredValuesMap = Object.fromEntries(
|
|
1642
|
+
Object.entries(valuesMap).filter(([_, v]) => Object.keys(v).length > 0)
|
|
1643
|
+
);
|
|
1644
|
+
const hasValuesMap = Object.keys(filteredValuesMap).length > 0;
|
|
1645
|
+
const formattedValuesMap = hasValuesMap ? JSON.stringify(filteredValuesMap, null, 2).replace(/"([^"]+)":/g, "$1:") : "";
|
|
1646
|
+
const valuesMapEntry = hasValuesMap ? `, valuesMap: ${formattedValuesMap}` : "";
|
|
1632
1647
|
const enumStructure = {
|
|
1633
1648
|
kind: tsMorph.StructureKind.Enum,
|
|
1634
1649
|
isExported: true,
|
|
@@ -1643,7 +1658,9 @@ function registerEnum(enumType, args) {
|
|
|
1643
1658
|
...importDeclarations.toStatements(),
|
|
1644
1659
|
enumStructure,
|
|
1645
1660
|
"\n",
|
|
1646
|
-
`registerEnumType(${enumType.name}, { name: '${enumType.name}', description: ${JSON.stringify(
|
|
1661
|
+
`registerEnumType(${enumType.name}, { name: '${enumType.name}', description: ${JSON.stringify(
|
|
1662
|
+
dataModelEnum?.documentation
|
|
1663
|
+
)}${valuesMapEntry} })`
|
|
1647
1664
|
]
|
|
1648
1665
|
});
|
|
1649
1666
|
}
|
|
@@ -1758,7 +1775,7 @@ function createConfig(data) {
|
|
|
1758
1775
|
namedImport: toBoolean(element.namedImport),
|
|
1759
1776
|
defaultImport: toBoolean(element.defaultImport) ? true : element.defaultImport,
|
|
1760
1777
|
namespaceImport: element.namespaceImport,
|
|
1761
|
-
arguments: element.arguments ? JSON5.parse(element.arguments) :
|
|
1778
|
+
arguments: element.arguments ? JSON5.parse(element.arguments) : void 0
|
|
1762
1779
|
});
|
|
1763
1780
|
}
|
|
1764
1781
|
const customImport = [];
|
|
@@ -1825,7 +1842,7 @@ function createUseInputType(data) {
|
|
|
1825
1842
|
for (const [typeName, useInputs] of Object.entries(data)) {
|
|
1826
1843
|
const entry = {
|
|
1827
1844
|
typeName,
|
|
1828
|
-
ALL:
|
|
1845
|
+
ALL: void 0
|
|
1829
1846
|
};
|
|
1830
1847
|
if (useInputs.ALL) {
|
|
1831
1848
|
entry.ALL = useInputs.ALL;
|
|
@@ -1879,7 +1896,7 @@ function factoryGetSourceFile(args) {
|
|
|
1879
1896
|
template: outputFilePattern
|
|
1880
1897
|
});
|
|
1881
1898
|
filePath = `${output}/${filePath}`;
|
|
1882
|
-
return project.getSourceFile(filePath) || project.createSourceFile(filePath,
|
|
1899
|
+
return project.getSourceFile(filePath) || project.createSourceFile(filePath, void 0, { overwrite: true });
|
|
1883
1900
|
};
|
|
1884
1901
|
}
|
|
1885
1902
|
|
|
@@ -2005,7 +2022,7 @@ const middleKeywords = [
|
|
|
2005
2022
|
["OrderBy", "Args"]
|
|
2006
2023
|
];
|
|
2007
2024
|
|
|
2008
|
-
const AwaitEventEmitter = require
|
|
2025
|
+
const AwaitEventEmitter = require$$0.default;
|
|
2009
2026
|
async function generate(args) {
|
|
2010
2027
|
const { connectCallback, dmmf, generator, skipAddOutputSourceFiles } = args;
|
|
2011
2028
|
const generatorOutputValue = generator.output?.value;
|
|
@@ -2054,7 +2071,6 @@ async function generate(args) {
|
|
|
2054
2071
|
const fieldSettings = /* @__PURE__ */ new Map();
|
|
2055
2072
|
const getModelName = createGetModelName(modelNames);
|
|
2056
2073
|
const getSourceFile = factoryGetSourceFile({
|
|
2057
|
-
eventEmitter,
|
|
2058
2074
|
getModelName,
|
|
2059
2075
|
output: generatorOutputValue,
|
|
2060
2076
|
outputFilePattern: config.outputFilePattern,
|
package/generate.d.ts
CHANGED
|
@@ -2,247 +2,287 @@ import { GeneratorOptions } from '@prisma/generator-helper';
|
|
|
2
2
|
import AwaitEventEmitter from 'await-event-emitter';
|
|
3
3
|
import { Project, SourceFile } from 'ts-morph';
|
|
4
4
|
|
|
5
|
+
declare type Datamodel = ReadonlyDeep_2<{
|
|
6
|
+
models: Model$1[];
|
|
7
|
+
enums: DatamodelEnum[];
|
|
8
|
+
types: Model$1[];
|
|
9
|
+
indexes: Index[];
|
|
10
|
+
}>;
|
|
11
|
+
|
|
12
|
+
declare type DatamodelEnum = ReadonlyDeep_2<{
|
|
13
|
+
name: string;
|
|
14
|
+
values: EnumValue[];
|
|
15
|
+
dbName?: string | null;
|
|
16
|
+
documentation?: string;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
declare function datamodelEnumToSchemaEnum(datamodelEnum: DatamodelEnum): SchemaEnum;
|
|
20
|
+
|
|
21
|
+
declare type Deprecation = ReadonlyDeep_2<{
|
|
22
|
+
sinceVersion: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
plannedRemovalVersion?: string;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
5
27
|
declare namespace DMMF {
|
|
6
|
-
export type Document
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
export { datamodelEnumToSchemaEnum, type Document_2 as Document, type Mappings, type OtherOperationMappings, type DatamodelEnum, type SchemaEnum, type EnumValue, type Datamodel, type uniqueIndex, type PrimaryKey, type Model$1 as Model, type FieldKind, type FieldNamespace, type FieldLocation, type Field$1 as Field, type FieldDefault, type FieldDefaultScalar, type Index, type IndexType, type IndexField, type SortOrder, type Schema$1 as Schema, type Query, type QueryOutput, type TypeRef, type InputTypeRef, type SchemaArg, type OutputType, type SchemaField, type OutputTypeRef, type Deprecation, type InputType, type FieldRefType, type FieldRefAllowType, type ModelMapping, ModelAction }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare type Document_2 = ReadonlyDeep_2<{
|
|
32
|
+
datamodel: Datamodel;
|
|
33
|
+
schema: Schema$1;
|
|
34
|
+
mappings: Mappings;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
declare type EnumValue = ReadonlyDeep_2<{
|
|
38
|
+
name: string;
|
|
39
|
+
dbName: string | null;
|
|
40
|
+
}>;
|
|
41
|
+
|
|
42
|
+
declare type Field$1 = ReadonlyDeep_2<{
|
|
43
|
+
kind: FieldKind;
|
|
44
|
+
name: string;
|
|
45
|
+
isRequired: boolean;
|
|
46
|
+
isList: boolean;
|
|
47
|
+
isUnique: boolean;
|
|
48
|
+
isId: boolean;
|
|
49
|
+
isReadOnly: boolean;
|
|
50
|
+
isGenerated?: boolean;
|
|
51
|
+
isUpdatedAt?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Describes the data type in the same the way it is defined in the Prisma schema:
|
|
54
|
+
* BigInt, Boolean, Bytes, DateTime, Decimal, Float, Int, JSON, String, $ModelName
|
|
55
|
+
*/
|
|
56
|
+
type: string;
|
|
57
|
+
/**
|
|
58
|
+
* Native database type, if specified.
|
|
59
|
+
* For example, `@db.VarChar(191)` is encoded as `['VarChar', ['191']]`,
|
|
60
|
+
* `@db.Text` is encoded as `['Text', []]`.
|
|
61
|
+
*/
|
|
62
|
+
nativeType?: [string, string[]] | null;
|
|
63
|
+
dbName?: string | null;
|
|
64
|
+
hasDefaultValue: boolean;
|
|
65
|
+
default?: FieldDefault | FieldDefaultScalar | FieldDefaultScalar[];
|
|
66
|
+
relationFromFields?: string[];
|
|
67
|
+
relationToFields?: string[];
|
|
68
|
+
relationOnDelete?: string;
|
|
69
|
+
relationOnUpdate?: string;
|
|
70
|
+
relationName?: string;
|
|
71
|
+
documentation?: string;
|
|
72
|
+
}>;
|
|
73
|
+
|
|
74
|
+
declare type FieldDefault = ReadonlyDeep_2<{
|
|
75
|
+
name: string;
|
|
76
|
+
args: Array<string | number>;
|
|
77
|
+
}>;
|
|
78
|
+
|
|
79
|
+
declare type FieldDefaultScalar = string | boolean | number;
|
|
80
|
+
|
|
81
|
+
declare type FieldKind = 'scalar' | 'object' | 'enum' | 'unsupported';
|
|
82
|
+
|
|
83
|
+
declare type FieldLocation = 'scalar' | 'inputObjectTypes' | 'outputObjectTypes' | 'enumTypes' | 'fieldRefTypes';
|
|
84
|
+
|
|
85
|
+
declare type FieldNamespace = 'model' | 'prisma';
|
|
86
|
+
|
|
87
|
+
declare type FieldRefAllowType = TypeRef<'scalar' | 'enumTypes'>;
|
|
88
|
+
|
|
89
|
+
declare type FieldRefType = ReadonlyDeep_2<{
|
|
90
|
+
name: string;
|
|
91
|
+
allowTypes: FieldRefAllowType[];
|
|
92
|
+
fields: SchemaArg[];
|
|
93
|
+
}>;
|
|
94
|
+
|
|
95
|
+
declare type Index = ReadonlyDeep_2<{
|
|
96
|
+
model: string;
|
|
97
|
+
type: IndexType;
|
|
98
|
+
isDefinedOnField: boolean;
|
|
99
|
+
name?: string;
|
|
100
|
+
dbName?: string;
|
|
101
|
+
algorithm?: string;
|
|
102
|
+
clustered?: boolean;
|
|
103
|
+
fields: IndexField[];
|
|
104
|
+
}>;
|
|
105
|
+
|
|
106
|
+
declare type IndexField = ReadonlyDeep_2<{
|
|
107
|
+
name: string;
|
|
108
|
+
sortOrder?: SortOrder;
|
|
109
|
+
length?: number;
|
|
110
|
+
operatorClass?: string;
|
|
111
|
+
}>;
|
|
112
|
+
|
|
113
|
+
declare type IndexType = 'id' | 'normal' | 'unique' | 'fulltext';
|
|
114
|
+
|
|
115
|
+
declare type InputType = ReadonlyDeep_2<{
|
|
116
|
+
name: string;
|
|
117
|
+
constraints: {
|
|
118
|
+
maxNumFields: number | null;
|
|
119
|
+
minNumFields: number | null;
|
|
120
|
+
fields?: string[];
|
|
121
|
+
};
|
|
122
|
+
meta?: {
|
|
123
|
+
source?: string;
|
|
124
|
+
grouping?: string;
|
|
125
|
+
};
|
|
126
|
+
fields: SchemaArg[];
|
|
127
|
+
}>;
|
|
128
|
+
|
|
129
|
+
declare type InputTypeRef = TypeRef<'scalar' | 'inputObjectTypes' | 'enumTypes' | 'fieldRefTypes'>;
|
|
130
|
+
|
|
131
|
+
declare type Mappings = ReadonlyDeep_2<{
|
|
132
|
+
modelOperations: ModelMapping[];
|
|
133
|
+
otherOperations: {
|
|
19
134
|
read: string[];
|
|
20
135
|
write: string[];
|
|
21
|
-
}>;
|
|
22
|
-
export type DatamodelEnum = ReadonlyDeep_2<{
|
|
23
|
-
name: string;
|
|
24
|
-
values: EnumValue[];
|
|
25
|
-
dbName?: string | null;
|
|
26
|
-
documentation?: string;
|
|
27
|
-
}>;
|
|
28
|
-
export type SchemaEnum = ReadonlyDeep_2<{
|
|
29
|
-
name: string;
|
|
30
|
-
values: string[];
|
|
31
|
-
}>;
|
|
32
|
-
export type EnumValue = ReadonlyDeep_2<{
|
|
33
|
-
name: string;
|
|
34
|
-
dbName: string | null;
|
|
35
|
-
}>;
|
|
36
|
-
export type Datamodel = ReadonlyDeep_2<{
|
|
37
|
-
models: Model[];
|
|
38
|
-
enums: DatamodelEnum[];
|
|
39
|
-
types: Model[];
|
|
40
|
-
indexes: Index[];
|
|
41
|
-
}>;
|
|
42
|
-
export type uniqueIndex = ReadonlyDeep_2<{
|
|
43
|
-
name: string;
|
|
44
|
-
fields: string[];
|
|
45
|
-
}>;
|
|
46
|
-
export type PrimaryKey = ReadonlyDeep_2<{
|
|
47
|
-
name: string | null;
|
|
48
|
-
fields: string[];
|
|
49
|
-
}>;
|
|
50
|
-
export type Model = ReadonlyDeep_2<{
|
|
51
|
-
name: string;
|
|
52
|
-
dbName: string | null;
|
|
53
|
-
schema: string | null;
|
|
54
|
-
fields: Field[];
|
|
55
|
-
uniqueFields: string[][];
|
|
56
|
-
uniqueIndexes: uniqueIndex[];
|
|
57
|
-
documentation?: string;
|
|
58
|
-
primaryKey: PrimaryKey | null;
|
|
59
|
-
isGenerated?: boolean;
|
|
60
|
-
}>;
|
|
61
|
-
export type FieldKind = 'scalar' | 'object' | 'enum' | 'unsupported';
|
|
62
|
-
export type FieldNamespace = 'model' | 'prisma';
|
|
63
|
-
export type FieldLocation = 'scalar' | 'inputObjectTypes' | 'outputObjectTypes' | 'enumTypes' | 'fieldRefTypes';
|
|
64
|
-
export type Field = ReadonlyDeep_2<{
|
|
65
|
-
kind: FieldKind;
|
|
66
|
-
name: string;
|
|
67
|
-
isRequired: boolean;
|
|
68
|
-
isList: boolean;
|
|
69
|
-
isUnique: boolean;
|
|
70
|
-
isId: boolean;
|
|
71
|
-
isReadOnly: boolean;
|
|
72
|
-
isGenerated?: boolean;
|
|
73
|
-
isUpdatedAt?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Describes the data type in the same the way it is defined in the Prisma schema:
|
|
76
|
-
* BigInt, Boolean, Bytes, DateTime, Decimal, Float, Int, JSON, String, $ModelName
|
|
77
|
-
*/
|
|
78
|
-
type: string;
|
|
79
|
-
/**
|
|
80
|
-
* Native database type, if specified.
|
|
81
|
-
* For example, `@db.VarChar(191)` is encoded as `['VarChar', ['191']]`,
|
|
82
|
-
* `@db.Text` is encoded as `['Text', []]`.
|
|
83
|
-
*/
|
|
84
|
-
nativeType?: [string, string[]] | null;
|
|
85
|
-
dbName?: string | null;
|
|
86
|
-
hasDefaultValue: boolean;
|
|
87
|
-
default?: FieldDefault | FieldDefaultScalar | FieldDefaultScalar[];
|
|
88
|
-
relationFromFields?: string[];
|
|
89
|
-
relationToFields?: string[];
|
|
90
|
-
relationOnDelete?: string;
|
|
91
|
-
relationName?: string;
|
|
92
|
-
documentation?: string;
|
|
93
|
-
}>;
|
|
94
|
-
export type FieldDefault = ReadonlyDeep_2<{
|
|
95
|
-
name: string;
|
|
96
|
-
args: Array<string | number>;
|
|
97
|
-
}>;
|
|
98
|
-
export type FieldDefaultScalar = string | boolean | number;
|
|
99
|
-
export type Index = ReadonlyDeep_2<{
|
|
100
|
-
model: string;
|
|
101
|
-
type: IndexType;
|
|
102
|
-
isDefinedOnField: boolean;
|
|
103
|
-
name?: string;
|
|
104
|
-
dbName?: string;
|
|
105
|
-
algorithm?: string;
|
|
106
|
-
clustered?: boolean;
|
|
107
|
-
fields: IndexField[];
|
|
108
|
-
}>;
|
|
109
|
-
export type IndexType = 'id' | 'normal' | 'unique' | 'fulltext';
|
|
110
|
-
export type IndexField = ReadonlyDeep_2<{
|
|
111
|
-
name: string;
|
|
112
|
-
sortOrder?: SortOrder;
|
|
113
|
-
length?: number;
|
|
114
|
-
operatorClass?: string;
|
|
115
|
-
}>;
|
|
116
|
-
export type SortOrder = 'asc' | 'desc';
|
|
117
|
-
export type Schema = ReadonlyDeep_2<{
|
|
118
|
-
rootQueryType?: string;
|
|
119
|
-
rootMutationType?: string;
|
|
120
|
-
inputObjectTypes: {
|
|
121
|
-
model?: InputType[];
|
|
122
|
-
prisma: InputType[];
|
|
123
|
-
};
|
|
124
|
-
outputObjectTypes: {
|
|
125
|
-
model: OutputType[];
|
|
126
|
-
prisma: OutputType[];
|
|
127
|
-
};
|
|
128
|
-
enumTypes: {
|
|
129
|
-
model?: SchemaEnum[];
|
|
130
|
-
prisma: SchemaEnum[];
|
|
131
|
-
};
|
|
132
|
-
fieldRefTypes: {
|
|
133
|
-
prisma?: FieldRefType[];
|
|
134
|
-
};
|
|
135
|
-
}>;
|
|
136
|
-
export type Query = ReadonlyDeep_2<{
|
|
137
|
-
name: string;
|
|
138
|
-
args: SchemaArg[];
|
|
139
|
-
output: QueryOutput;
|
|
140
|
-
}>;
|
|
141
|
-
export type QueryOutput = ReadonlyDeep_2<{
|
|
142
|
-
name: string;
|
|
143
|
-
isRequired: boolean;
|
|
144
|
-
isList: boolean;
|
|
145
|
-
}>;
|
|
146
|
-
export type TypeRef<AllowedLocations extends FieldLocation> = {
|
|
147
|
-
isList: boolean;
|
|
148
|
-
type: string;
|
|
149
|
-
location: AllowedLocations;
|
|
150
|
-
namespace?: FieldNamespace;
|
|
151
136
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
meta?: {
|
|
187
|
-
source?: string;
|
|
188
|
-
};
|
|
189
|
-
fields: SchemaArg[];
|
|
190
|
-
}>;
|
|
191
|
-
export type FieldRefType = ReadonlyDeep_2<{
|
|
192
|
-
name: string;
|
|
193
|
-
allowTypes: FieldRefAllowType[];
|
|
194
|
-
fields: SchemaArg[];
|
|
195
|
-
}>;
|
|
196
|
-
export type FieldRefAllowType = TypeRef<'scalar' | 'enumTypes'>;
|
|
197
|
-
export type ModelMapping = ReadonlyDeep_2<{
|
|
198
|
-
model: string;
|
|
199
|
-
plural: string;
|
|
200
|
-
findUnique?: string | null;
|
|
201
|
-
findUniqueOrThrow?: string | null;
|
|
202
|
-
findFirst?: string | null;
|
|
203
|
-
findFirstOrThrow?: string | null;
|
|
204
|
-
findMany?: string | null;
|
|
205
|
-
create?: string | null;
|
|
206
|
-
createMany?: string | null;
|
|
207
|
-
createManyAndReturn?: string | null;
|
|
208
|
-
update?: string | null;
|
|
209
|
-
updateMany?: string | null;
|
|
210
|
-
updateManyAndReturn?: string | null;
|
|
211
|
-
upsert?: string | null;
|
|
212
|
-
delete?: string | null;
|
|
213
|
-
deleteMany?: string | null;
|
|
214
|
-
aggregate?: string | null;
|
|
215
|
-
groupBy?: string | null;
|
|
216
|
-
count?: string | null;
|
|
217
|
-
findRaw?: string | null;
|
|
218
|
-
aggregateRaw?: string | null;
|
|
219
|
-
}>;
|
|
220
|
-
export enum ModelAction {
|
|
221
|
-
findUnique = "findUnique",
|
|
222
|
-
findUniqueOrThrow = "findUniqueOrThrow",
|
|
223
|
-
findFirst = "findFirst",
|
|
224
|
-
findFirstOrThrow = "findFirstOrThrow",
|
|
225
|
-
findMany = "findMany",
|
|
226
|
-
create = "create",
|
|
227
|
-
createMany = "createMany",
|
|
228
|
-
createManyAndReturn = "createManyAndReturn",
|
|
229
|
-
update = "update",
|
|
230
|
-
updateMany = "updateMany",
|
|
231
|
-
updateManyAndReturn = "updateManyAndReturn",
|
|
232
|
-
upsert = "upsert",
|
|
233
|
-
delete = "delete",
|
|
234
|
-
deleteMany = "deleteMany",
|
|
235
|
-
groupBy = "groupBy",
|
|
236
|
-
count = "count",// TODO: count does not actually exist, why?
|
|
237
|
-
aggregate = "aggregate",
|
|
238
|
-
findRaw = "findRaw",
|
|
239
|
-
aggregateRaw = "aggregateRaw"
|
|
240
|
-
}
|
|
137
|
+
}>;
|
|
138
|
+
|
|
139
|
+
declare type Model$1 = ReadonlyDeep_2<{
|
|
140
|
+
name: string;
|
|
141
|
+
dbName: string | null;
|
|
142
|
+
schema: string | null;
|
|
143
|
+
fields: Field$1[];
|
|
144
|
+
uniqueFields: string[][];
|
|
145
|
+
uniqueIndexes: uniqueIndex[];
|
|
146
|
+
documentation?: string;
|
|
147
|
+
primaryKey: PrimaryKey | null;
|
|
148
|
+
isGenerated?: boolean;
|
|
149
|
+
}>;
|
|
150
|
+
|
|
151
|
+
declare enum ModelAction {
|
|
152
|
+
findUnique = "findUnique",
|
|
153
|
+
findUniqueOrThrow = "findUniqueOrThrow",
|
|
154
|
+
findFirst = "findFirst",
|
|
155
|
+
findFirstOrThrow = "findFirstOrThrow",
|
|
156
|
+
findMany = "findMany",
|
|
157
|
+
create = "create",
|
|
158
|
+
createMany = "createMany",
|
|
159
|
+
createManyAndReturn = "createManyAndReturn",
|
|
160
|
+
update = "update",
|
|
161
|
+
updateMany = "updateMany",
|
|
162
|
+
updateManyAndReturn = "updateManyAndReturn",
|
|
163
|
+
upsert = "upsert",
|
|
164
|
+
delete = "delete",
|
|
165
|
+
deleteMany = "deleteMany",
|
|
166
|
+
groupBy = "groupBy",
|
|
167
|
+
count = "count",// TODO: count does not actually exist in DMMF
|
|
168
|
+
aggregate = "aggregate",
|
|
169
|
+
findRaw = "findRaw",
|
|
170
|
+
aggregateRaw = "aggregateRaw"
|
|
241
171
|
}
|
|
242
172
|
|
|
173
|
+
declare type ModelMapping = ReadonlyDeep_2<{
|
|
174
|
+
model: string;
|
|
175
|
+
plural: string;
|
|
176
|
+
findUnique?: string | null;
|
|
177
|
+
findUniqueOrThrow?: string | null;
|
|
178
|
+
findFirst?: string | null;
|
|
179
|
+
findFirstOrThrow?: string | null;
|
|
180
|
+
findMany?: string | null;
|
|
181
|
+
create?: string | null;
|
|
182
|
+
createMany?: string | null;
|
|
183
|
+
createManyAndReturn?: string | null;
|
|
184
|
+
update?: string | null;
|
|
185
|
+
updateMany?: string | null;
|
|
186
|
+
updateManyAndReturn?: string | null;
|
|
187
|
+
upsert?: string | null;
|
|
188
|
+
delete?: string | null;
|
|
189
|
+
deleteMany?: string | null;
|
|
190
|
+
aggregate?: string | null;
|
|
191
|
+
groupBy?: string | null;
|
|
192
|
+
count?: string | null;
|
|
193
|
+
findRaw?: string | null;
|
|
194
|
+
aggregateRaw?: string | null;
|
|
195
|
+
}>;
|
|
196
|
+
|
|
197
|
+
declare type OtherOperationMappings = ReadonlyDeep_2<{
|
|
198
|
+
read: string[];
|
|
199
|
+
write: string[];
|
|
200
|
+
}>;
|
|
201
|
+
|
|
202
|
+
declare type OutputType = ReadonlyDeep_2<{
|
|
203
|
+
name: string;
|
|
204
|
+
fields: SchemaField[];
|
|
205
|
+
}>;
|
|
206
|
+
|
|
207
|
+
declare type OutputTypeRef = TypeRef<'scalar' | 'outputObjectTypes' | 'enumTypes'>;
|
|
208
|
+
|
|
209
|
+
declare type PrimaryKey = ReadonlyDeep_2<{
|
|
210
|
+
name: string | null;
|
|
211
|
+
fields: string[];
|
|
212
|
+
}>;
|
|
213
|
+
|
|
214
|
+
declare type Query = ReadonlyDeep_2<{
|
|
215
|
+
name: string;
|
|
216
|
+
args: SchemaArg[];
|
|
217
|
+
output: QueryOutput;
|
|
218
|
+
}>;
|
|
219
|
+
|
|
220
|
+
declare type QueryOutput = ReadonlyDeep_2<{
|
|
221
|
+
name: string;
|
|
222
|
+
isRequired: boolean;
|
|
223
|
+
isList: boolean;
|
|
224
|
+
}>;
|
|
225
|
+
|
|
243
226
|
declare type ReadonlyDeep_2<O> = {
|
|
244
227
|
+readonly [K in keyof O]: ReadonlyDeep_2<O[K]>;
|
|
245
|
-
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
declare type Schema$1 = ReadonlyDeep_2<{
|
|
231
|
+
rootQueryType?: string;
|
|
232
|
+
rootMutationType?: string;
|
|
233
|
+
inputObjectTypes: {
|
|
234
|
+
model?: InputType[];
|
|
235
|
+
prisma: InputType[];
|
|
236
|
+
};
|
|
237
|
+
outputObjectTypes: {
|
|
238
|
+
model: OutputType[];
|
|
239
|
+
prisma: OutputType[];
|
|
240
|
+
};
|
|
241
|
+
enumTypes: {
|
|
242
|
+
model?: SchemaEnum[];
|
|
243
|
+
prisma: SchemaEnum[];
|
|
244
|
+
};
|
|
245
|
+
fieldRefTypes: {
|
|
246
|
+
prisma?: FieldRefType[];
|
|
247
|
+
};
|
|
248
|
+
}>;
|
|
249
|
+
|
|
250
|
+
declare type SchemaArg = ReadonlyDeep_2<{
|
|
251
|
+
name: string;
|
|
252
|
+
comment?: string;
|
|
253
|
+
isNullable: boolean;
|
|
254
|
+
isRequired: boolean;
|
|
255
|
+
inputTypes: InputTypeRef[];
|
|
256
|
+
deprecation?: Deprecation;
|
|
257
|
+
}>;
|
|
258
|
+
|
|
259
|
+
declare type SchemaEnum = ReadonlyDeep_2<{
|
|
260
|
+
name: string;
|
|
261
|
+
values: string[];
|
|
262
|
+
}>;
|
|
263
|
+
|
|
264
|
+
declare type SchemaField = ReadonlyDeep_2<{
|
|
265
|
+
name: string;
|
|
266
|
+
isNullable?: boolean;
|
|
267
|
+
outputType: OutputTypeRef;
|
|
268
|
+
args: SchemaArg[];
|
|
269
|
+
deprecation?: Deprecation;
|
|
270
|
+
documentation?: string;
|
|
271
|
+
}>;
|
|
272
|
+
|
|
273
|
+
declare type SortOrder = 'asc' | 'desc';
|
|
274
|
+
|
|
275
|
+
declare type TypeRef<AllowedLocations extends FieldLocation> = {
|
|
276
|
+
isList: boolean;
|
|
277
|
+
type: string;
|
|
278
|
+
location: AllowedLocations;
|
|
279
|
+
namespace?: FieldNamespace;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
declare type uniqueIndex = ReadonlyDeep_2<{
|
|
283
|
+
name: string;
|
|
284
|
+
fields: string[];
|
|
285
|
+
}>;
|
|
246
286
|
|
|
247
287
|
/**
|
|
248
288
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
package/index.cjs
CHANGED
package/package.json
CHANGED