@zenstackhq/trpc 0.6.0-pre.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/config.d.ts +9 -0
  4. package/config.js +8 -0
  5. package/config.js.map +1 -0
  6. package/generator.d.ts +4 -0
  7. package/generator.js +152 -0
  8. package/generator.js.map +1 -0
  9. package/helpers.d.ts +9 -0
  10. package/helpers.js +141 -0
  11. package/helpers.js.map +1 -0
  12. package/index.d.ts +5 -0
  13. package/index.js +21 -0
  14. package/index.js.map +1 -0
  15. package/package.json +37 -0
  16. package/project.d.ts +2 -0
  17. package/project.js +15 -0
  18. package/project.js.map +1 -0
  19. package/types.d.ts +0 -0
  20. package/types.js +2 -0
  21. package/types.js.map +1 -0
  22. package/utils/removeDir.d.ts +1 -0
  23. package/utils/removeDir.js +30 -0
  24. package/utils/removeDir.js.map +1 -0
  25. package/utils/uncapitalizeFirstLetter.d.ts +1 -0
  26. package/utils/uncapitalizeFirstLetter.js +8 -0
  27. package/utils/uncapitalizeFirstLetter.js.map +1 -0
  28. package/zod/generator.d.ts +4 -0
  29. package/zod/generator.js +92 -0
  30. package/zod/generator.js.map +1 -0
  31. package/zod/helpers/aggregate-helpers.d.ts +5 -0
  32. package/zod/helpers/aggregate-helpers.js +64 -0
  33. package/zod/helpers/aggregate-helpers.js.map +1 -0
  34. package/zod/helpers/comments-helpers.d.ts +6 -0
  35. package/zod/helpers/comments-helpers.js +99 -0
  36. package/zod/helpers/comments-helpers.js.map +1 -0
  37. package/zod/helpers/helpers.d.ts +8 -0
  38. package/zod/helpers/helpers.js +39 -0
  39. package/zod/helpers/helpers.js.map +1 -0
  40. package/zod/helpers/include-helpers.d.ts +2 -0
  41. package/zod/helpers/include-helpers.js +79 -0
  42. package/zod/helpers/include-helpers.js.map +1 -0
  43. package/zod/helpers/index.d.ts +4 -0
  44. package/zod/helpers/index.js +21 -0
  45. package/zod/helpers/index.js.map +1 -0
  46. package/zod/helpers/model-helpers.d.ts +6 -0
  47. package/zod/helpers/model-helpers.js +39 -0
  48. package/zod/helpers/model-helpers.js.map +1 -0
  49. package/zod/helpers/modelArgs-helpers.d.ts +2 -0
  50. package/zod/helpers/modelArgs-helpers.js +62 -0
  51. package/zod/helpers/modelArgs-helpers.js.map +1 -0
  52. package/zod/helpers/mongodb-helpers.d.ts +3 -0
  53. package/zod/helpers/mongodb-helpers.js +65 -0
  54. package/zod/helpers/mongodb-helpers.js.map +1 -0
  55. package/zod/helpers/select-helpers.d.ts +2 -0
  56. package/zod/helpers/select-helpers.js +137 -0
  57. package/zod/helpers/select-helpers.js.map +1 -0
  58. package/zod/index.d.ts +5 -0
  59. package/zod/index.js +21 -0
  60. package/zod/index.js.map +1 -0
  61. package/zod/transformer.d.ts +70 -0
  62. package/zod/transformer.js +467 -0
  63. package/zod/transformer.js.map +1 -0
  64. package/zod/types.d.ts +20 -0
  65. package/zod/types.js +3 -0
  66. package/zod/types.js.map +1 -0
  67. package/zod/utils/formatFile.d.ts +1 -0
  68. package/zod/utils/formatFile.js +32 -0
  69. package/zod/utils/formatFile.js.map +1 -0
  70. package/zod/utils/removeDir.d.ts +1 -0
  71. package/zod/utils/removeDir.js +30 -0
  72. package/zod/utils/removeDir.js.map +1 -0
  73. package/zod/utils/writeFileSafely.d.ts +1 -0
  74. package/zod/utils/writeFileSafely.js +26 -0
  75. package/zod/utils/writeFileSafely.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/zod/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,yCAA4D;AAC5D,6CAAsE;AACtE,2BAAoC;AACpC,uCAKmB;AACnB,mEAA+E;AAC/E,gEAAwC;AAExC,kEAA0C;AAE1C,SAAsB,QAAQ,CAAC,KAAY,EAAE,OAAsB,EAAE,IAAmB;;;QACpF,MAAM,0BAA0B,CAAC,MAAC,OAAO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GAAG,IAAI,qBAAW,CAAC;YAChC,SAAS;SACZ,CAAC,CAAC;QACH,MAAM,WAAW,CAAC,mBAAmB,EAAE,CAAC;IAC5C,CAAC;CAAA;AAED,SAAe,qBAAqB,CAAC,gBAAkC;;;QACnE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YACjD,MAAM,MAAM,GAAG,MAAA,gBAAgB,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC;YAC3C,MAAM,IAAI,GAAG,MAAA,gBAAgB,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAC;YACvC,MAAM,WAAW,GAAG,IAAI,qBAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YACtD,MAAM,WAAW,CAAC,oBAAoB,EAAE,CAAC;SAC5C;;CACJ;AAED,SAAe,oBAAoB,CAC/B,MAAoB,EACpB,eAAoC,EACpC,yBAAoD;;QAEpD,MAAM,WAAW,GAAG,IAAI,qBAAW,CAAC;YAChC,MAAM;YACN,eAAe;YACf,yBAAyB;SAC5B,CAAC,CAAC;QACH,MAAM,WAAW,CAAC,oBAAoB,EAAE,CAAC;IAC7C,CAAC;CAAA"}
@@ -0,0 +1,5 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ import { AggregateOperationSupport } from '../types';
3
+ export declare const isAggregateInputType: (name: string) => boolean;
4
+ export declare function addMissingInputObjectTypesForAggregate(inputObjectTypes: DMMF.InputType[], outputObjectTypes: DMMF.OutputType[]): void;
5
+ export declare function resolveAggregateOperationSupport(inputObjectTypes: DMMF.InputType[]): AggregateOperationSupport;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAggregateOperationSupport = exports.addMissingInputObjectTypesForAggregate = exports.isAggregateInputType = void 0;
4
+ const isAggregateOutputType = (name) => /(?:Count|Avg|Sum|Min|Max)AggregateOutputType$/.test(name);
5
+ const isAggregateInputType = (name) => name.endsWith('CountAggregateInput') ||
6
+ name.endsWith('SumAggregateInput') ||
7
+ name.endsWith('AvgAggregateInput') ||
8
+ name.endsWith('MinAggregateInput') ||
9
+ name.endsWith('MaxAggregateInput');
10
+ exports.isAggregateInputType = isAggregateInputType;
11
+ function addMissingInputObjectTypesForAggregate(inputObjectTypes, outputObjectTypes) {
12
+ const aggregateOutputTypes = outputObjectTypes.filter(({ name }) => isAggregateOutputType(name));
13
+ for (const aggregateOutputType of aggregateOutputTypes) {
14
+ const name = aggregateOutputType.name.replace(/(?:OutputType|Output)$/, '');
15
+ inputObjectTypes.push({
16
+ constraints: { maxNumFields: null, minNumFields: null },
17
+ name: `${name}Input`,
18
+ fields: aggregateOutputType.fields.map((field) => ({
19
+ name: field.name,
20
+ isNullable: false,
21
+ isRequired: false,
22
+ inputTypes: [
23
+ {
24
+ isList: false,
25
+ type: 'True',
26
+ location: 'scalar',
27
+ },
28
+ ],
29
+ })),
30
+ });
31
+ }
32
+ }
33
+ exports.addMissingInputObjectTypesForAggregate = addMissingInputObjectTypesForAggregate;
34
+ function resolveAggregateOperationSupport(inputObjectTypes) {
35
+ const aggregateOperationSupport = {};
36
+ for (const inputType of inputObjectTypes) {
37
+ if ((0, exports.isAggregateInputType)(inputType.name)) {
38
+ const name = inputType.name.replace('AggregateInput', '');
39
+ if (name.endsWith('Count')) {
40
+ const model = name.replace('Count', '');
41
+ aggregateOperationSupport[model] = Object.assign(Object.assign({}, aggregateOperationSupport[model]), { count: true });
42
+ }
43
+ else if (name.endsWith('Min')) {
44
+ const model = name.replace('Min', '');
45
+ aggregateOperationSupport[model] = Object.assign(Object.assign({}, aggregateOperationSupport[model]), { min: true });
46
+ }
47
+ else if (name.endsWith('Max')) {
48
+ const model = name.replace('Max', '');
49
+ aggregateOperationSupport[model] = Object.assign(Object.assign({}, aggregateOperationSupport[model]), { max: true });
50
+ }
51
+ else if (name.endsWith('Sum')) {
52
+ const model = name.replace('Sum', '');
53
+ aggregateOperationSupport[model] = Object.assign(Object.assign({}, aggregateOperationSupport[model]), { sum: true });
54
+ }
55
+ else if (name.endsWith('Avg')) {
56
+ const model = name.replace('Avg', '');
57
+ aggregateOperationSupport[model] = Object.assign(Object.assign({}, aggregateOperationSupport[model]), { avg: true });
58
+ }
59
+ }
60
+ }
61
+ return aggregateOperationSupport;
62
+ }
63
+ exports.resolveAggregateOperationSupport = resolveAggregateOperationSupport;
64
+ //# sourceMappingURL=aggregate-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregate-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/aggregate-helpers.ts"],"names":[],"mappings":";;;AAGA,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,+CAA+C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEpG,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE,CACjD,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AAL1B,QAAA,oBAAoB,wBAKM;AAEvC,SAAgB,sCAAsC,CAClD,gBAAkC,EAClC,iBAAoC;IAEpC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;IACjG,KAAK,MAAM,mBAAmB,IAAI,oBAAoB,EAAE;QACpD,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;QAC5E,gBAAgB,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,EAAE,Y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AC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACtC,yBAAyB,CAAC,KAAK,CAAC,mCACzB,yBAAyB,CAAC,KAAK,CAAC,KACnC,GAAG,EAAE,IAAI,GACZ,CAAC;aACL;iBAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACtC,yBAAyB,CAAC,KAAK,CAAC,mCACzB,yBAAyB,CAAC,KAAK,CAAC,KACnC,GAAG,EAAE,IAAI,GACZ,CAAC;aACL;iBAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACtC,yBAAyB,CAAC,KAAK,CAAC,mCACzB,yBAAyB,CAAC,KAAK,CAAC,KACnC,GAAG,EAAE,IAAI,GACZ,CAAC;aACL;SACJ;KACJ;IACD,OAAO,yBAAyB,CAAC;AACrC,CAAC;AAvCD,4EAuCC"}
@@ -0,0 +1,6 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ export declare function resolveModelsComments(models: DMMF.Model[], modelOperations: DMMF.ModelMapping[], enumTypes: {
3
+ model?: DMMF.SchemaEnum[];
4
+ prisma: DMMF.SchemaEnum[];
5
+ }, hiddenModels: string[], hiddenFields: string[]): void;
6
+ export declare function hideInputObjectTypesAndRelatedFields(inputObjectTypes: DMMF.InputType[], hiddenModels: string[], hiddenFields: string[]): void;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hideInputObjectTypesAndRelatedFields = exports.resolveModelsComments = void 0;
4
+ const modelAttributeRegex = /(@@Gen\.)+([A-z])+(\()+(.+)+(\))+/;
5
+ const attributeNameRegex = /(?:\.)+([A-Za-z])+(?:\()+/;
6
+ const attributeArgsRegex = /(?:\()+([A-Za-z])+:+(.+)+(?:\))+/;
7
+ function resolveModelsComments(models, modelOperations, enumTypes, hiddenModels, hiddenFields) {
8
+ models = collectHiddenModels(models, hiddenModels);
9
+ collectHiddenFields(models, hiddenModels, hiddenFields);
10
+ hideModelOperations(models, modelOperations);
11
+ hideEnums(enumTypes, hiddenModels);
12
+ }
13
+ exports.resolveModelsComments = resolveModelsComments;
14
+ function collectHiddenModels(models, hiddenModels) {
15
+ return models
16
+ .map((model) => {
17
+ var _a, _b, _c, _d, _e, _f;
18
+ if (model.documentation) {
19
+ const attribute = (_b = (_a = model.documentation) === null || _a === void 0 ? void 0 : _a.match(modelAttributeRegex)) === null || _b === void 0 ? void 0 : _b[0];
20
+ const attributeName = (_d = (_c = attribute === null || attribute === void 0 ? void 0 : attribute.match(attributeNameRegex)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.slice(1, -1);
21
+ if (attributeName !== 'model')
22
+ model;
23
+ const rawAttributeArgs = (_f = (_e = attribute === null || attribute === void 0 ? void 0 : attribute.match(attributeArgsRegex)) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.slice(1, -1);
24
+ const parsedAttributeArgs = {};
25
+ if (rawAttributeArgs) {
26
+ const rawAttributeArgsParts = rawAttributeArgs
27
+ .split(':')
28
+ .map((it) => it.trim())
29
+ .map((part) => (part.startsWith('[') ? part : part.split(',')))
30
+ .flat()
31
+ .map((it) => it.trim());
32
+ for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
33
+ const key = rawAttributeArgsParts[i];
34
+ const value = rawAttributeArgsParts[i + 1];
35
+ parsedAttributeArgs[key] = JSON.parse(value);
36
+ }
37
+ }
38
+ if (parsedAttributeArgs.hide) {
39
+ hiddenModels.push(model.name);
40
+ return null;
41
+ }
42
+ }
43
+ return model;
44
+ })
45
+ .filter(Boolean);
46
+ }
47
+ function collectHiddenFields(models, hiddenModels, hiddenFields) {
48
+ models.forEach((model) => {
49
+ model.fields.forEach((field) => {
50
+ if (hiddenModels.includes(field.type)) {
51
+ hiddenFields.push(field.name);
52
+ if (field.relationFromFields) {
53
+ field.relationFromFields.forEach((item) => hiddenFields.push(item));
54
+ }
55
+ }
56
+ });
57
+ });
58
+ }
59
+ function hideEnums(enumTypes, hiddenModels) {
60
+ enumTypes.prisma = enumTypes.prisma.filter((item) => !hiddenModels.find((model) => item.name.startsWith(model)));
61
+ }
62
+ function hideModelOperations(models, modelOperations) {
63
+ let i = modelOperations.length;
64
+ while (i >= 0) {
65
+ --i;
66
+ const modelOperation = modelOperations[i];
67
+ if (modelOperation &&
68
+ !models.find((model) => {
69
+ return model.name === modelOperation.model;
70
+ })) {
71
+ modelOperations.splice(i, 1);
72
+ }
73
+ }
74
+ }
75
+ function hideInputObjectTypesAndRelatedFields(inputObjectTypes, hiddenModels, hiddenFields) {
76
+ var _a, _b, _c, _d;
77
+ let j = inputObjectTypes.length;
78
+ while (j >= 0) {
79
+ --j;
80
+ const inputType = inputObjectTypes[j];
81
+ if (inputType &&
82
+ (hiddenModels.includes((_a = inputType === null || inputType === void 0 ? void 0 : inputType.meta) === null || _a === void 0 ? void 0 : _a.source) ||
83
+ hiddenModels.find((model) => inputType.name.startsWith(model)))) {
84
+ inputObjectTypes.splice(j, 1);
85
+ }
86
+ else {
87
+ let k = (_c = (_b = inputType === null || inputType === void 0 ? void 0 : inputType.fields) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
88
+ while (k >= 0) {
89
+ --k;
90
+ const field = (_d = inputType === null || inputType === void 0 ? void 0 : inputType.fields) === null || _d === void 0 ? void 0 : _d[k];
91
+ if (field && hiddenFields.includes(field.name)) {
92
+ inputObjectTypes[j].fields.splice(k, 1);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ exports.hideInputObjectTypesAndRelatedFields = hideInputObjectTypesAndRelatedFields;
99
+ //# sourceMappingURL=comments-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/comments-helpers.ts"],"names":[],"mappings":";;;AAEA,MAAM,mBAAmB,GAAG,mCAAmC,CAAC;AAChE,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AACvD,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AAE9D,SAAgB,qBAAqB,CACjC,MAAoB,EACpB,eAAoC,EACpC,SAAmE,EACnE,YAAsB,EACtB,YAAsB;IAEtB,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACnD,mBAAmB,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IACxD,mBAAmB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,SAAS,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACvC,CAAC;AAXD,sDAWC;AAED,SAAS,mBAAmB,CAAC,MAAoB,EAAE,YAAsB;IACrE,OAAO,MAAM;SACR,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;;QACX,IAAI,KAAK,CAAC,aAAa,EAAE;YACrB,MAAM,SAAS,GAAG,MAAA,MAAA,KAAK,CAAC,aAAa,0CAAE,KAAK,CAAC,mBAAmB,CAAC,0CAAG,CAAC,CAAC,CAAC;YACvE,MAAM,aAAa,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,CAAC,kBAAkB,CAAC,0CAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAI,aAAa,KAAK,OAAO;gBAAE,KAAK,CAAC;YACrC,MAAM,gBAAgB,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,CAAC,kBAAkB,CAAC,0CAAG,CAAC,CAAC,0CAAE,KAAK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AG,gBAAgB,CAAC,MAAM,CAAC;IAChC,OAAO,CAAC,IAAI,CAAC,EAAE;QACX,EAAE,CAAC,CAAC;QACJ,MAAM,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACtC,IACI,SAAS;YACT,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,0CAAE,MAAgB,CAAC;gBACrD,YAAY,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EACrE;YACE,gBAAgB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACjC;aAAM;YACH,IAAI,CAAC,GAAG,MAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,0CAAE,MAAM,mCAAI,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACX,EAAE,CAAC,CAAC;gBACJ,MAAM,KAAK,GAAG,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,0CAAG,CAAC,CAAC,CAAC;gBACrC,IAAI,KAAK,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;oBAC5C,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC3C;aACJ;SACJ;KACJ;AACL,CAAC;AA1BD,oFA0BC"}
@@ -0,0 +1,8 @@
1
+ import { DMMF, ConnectorType, Dictionary } from '@prisma/generator-helper';
2
+ interface AddMissingInputObjectTypeOptions {
3
+ isGenerateSelect: boolean;
4
+ isGenerateInclude: boolean;
5
+ }
6
+ export declare function addMissingInputObjectTypes(inputObjectTypes: DMMF.InputType[], outputObjectTypes: DMMF.OutputType[], models: DMMF.Model[], modelOperations: DMMF.ModelMapping[], dataSourceProvider: ConnectorType, options: AddMissingInputObjectTypeOptions): void;
7
+ export declare function resolveAddMissingInputObjectTypeOptions(generatorConfigOptions: Dictionary<string>): AddMissingInputObjectTypeOptions;
8
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveAddMissingInputObjectTypeOptions = exports.addMissingInputObjectTypes = void 0;
7
+ const transformer_1 = __importDefault(require("../transformer"));
8
+ const mongodb_helpers_1 = require("./mongodb-helpers");
9
+ const aggregate_helpers_1 = require("./aggregate-helpers");
10
+ const select_helpers_1 = require("./select-helpers");
11
+ const include_helpers_1 = require("./include-helpers");
12
+ const modelArgs_helpers_1 = require("./modelArgs-helpers");
13
+ function addMissingInputObjectTypes(inputObjectTypes, outputObjectTypes, models, modelOperations, dataSourceProvider, options) {
14
+ // TODO: remove once Prisma fix this issue: https://github.com/prisma/prisma/issues/14900
15
+ if (dataSourceProvider === 'mongodb') {
16
+ (0, mongodb_helpers_1.addMissingInputObjectTypesForMongoDbRawOpsAndQueries)(modelOperations, outputObjectTypes, inputObjectTypes);
17
+ }
18
+ (0, aggregate_helpers_1.addMissingInputObjectTypesForAggregate)(inputObjectTypes, outputObjectTypes);
19
+ if (options.isGenerateSelect) {
20
+ (0, select_helpers_1.addMissingInputObjectTypesForSelect)(inputObjectTypes, outputObjectTypes, models);
21
+ transformer_1.default.setIsGenerateSelect(true);
22
+ }
23
+ if (options.isGenerateSelect || options.isGenerateInclude) {
24
+ (0, modelArgs_helpers_1.addMissingInputObjectTypesForModelArgs)(inputObjectTypes, models, options.isGenerateSelect, options.isGenerateInclude);
25
+ }
26
+ if (options.isGenerateInclude) {
27
+ (0, include_helpers_1.addMissingInputObjectTypesForInclude)(inputObjectTypes, models, options.isGenerateSelect);
28
+ transformer_1.default.setIsGenerateInclude(true);
29
+ }
30
+ }
31
+ exports.addMissingInputObjectTypes = addMissingInputObjectTypes;
32
+ function resolveAddMissingInputObjectTypeOptions(generatorConfigOptions) {
33
+ return {
34
+ isGenerateSelect: generatorConfigOptions.isGenerateSelect !== 'false',
35
+ isGenerateInclude: generatorConfigOptions.isGenerateInclude !== 'false',
36
+ };
37
+ }
38
+ exports.resolveAddMissingInputObjectTypeOptions = resolveAddMissingInputObjectTypeOptions;
39
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/helpers.ts"],"names":[],"mappings":";;;;;;AACA,iEAAyC;AACzC,uDAAyF;AACzF,2DAA6E;AAC7E,qDAAuE;AACvE,uDAAyE;AACzE,2DAA6E;AAO7E,SAAgB,0BAA0B,CACtC,gBAAkC,EAClC,iBAAoC,EACpC,MAAoB,EACpB,eAAoC,EACpC,kBAAiC,EACjC,OAAyC;IAEzC,yFAAyF;IACzF,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAClC,IAAA,sEAAoD,EAAC,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;KAC9G;IACD,IAAA,0DAAsC,EAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAC5E,IAAI,OAAO,CAAC,gBAAgB,EAAE;QAC1B,IAAA,oDAAmC,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACjF,qBAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;KACzC;IACD,IAAI,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,iBAAiB,EAAE;QACvD,IAAA,0DAAsC,EAClC,gBAAgB,EAChB,MAAM,EACN,OAAO,CAAC,gBAAgB,EACxB,OAAO,CAAC,iBAAiB,CAC5B,CAAC;KACL;IACD,IAAI,OAAO,CAAC,iBAAiB,EAAE;QAC3B,IAAA,sDAAoC,EAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACzF,qBAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;KAC1C;AACL,CAAC;AA7BD,gEA6BC;AAED,SAAgB,uCAAuC,CACnD,sBAA0C;IAE1C,OAAO;QACH,gBAAgB,EAAE,sBAAsB,CAAC,gBAAgB,KAAK,OAAO;QACrE,iBAAiB,EAAE,sBAAsB,CAAC,iBAAiB,KAAK,OAAO;KAC1E,CAAC;AACN,CAAC;AAPD,0FAOC"}
@@ -0,0 +1,2 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ export declare function addMissingInputObjectTypesForInclude(inputObjectTypes: DMMF.InputType[], models: DMMF.Model[], isGenerateSelect: boolean): void;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMissingInputObjectTypesForInclude = void 0;
4
+ const model_helpers_1 = require("./model-helpers");
5
+ function addMissingInputObjectTypesForInclude(inputObjectTypes, models, isGenerateSelect) {
6
+ // generate input object types necessary to support ModelInclude with relation support
7
+ const generatedIncludeInputObjectTypes = generateModelIncludeInputObjectTypes(models, isGenerateSelect);
8
+ for (const includeInputObjectType of generatedIncludeInputObjectTypes) {
9
+ inputObjectTypes.push(includeInputObjectType);
10
+ }
11
+ }
12
+ exports.addMissingInputObjectTypesForInclude = addMissingInputObjectTypesForInclude;
13
+ function generateModelIncludeInputObjectTypes(models, isGenerateSelect) {
14
+ const modelIncludeInputObjectTypes = [];
15
+ for (const model of models) {
16
+ const { name: modelName, fields: modelFields } = model;
17
+ const fields = [];
18
+ for (const modelField of modelFields) {
19
+ const { name: modelFieldName, isList, type } = modelField;
20
+ const isRelationField = (0, model_helpers_1.checkIsModelRelationField)(modelField);
21
+ if (isRelationField) {
22
+ const field = {
23
+ name: modelFieldName,
24
+ isRequired: false,
25
+ isNullable: false,
26
+ inputTypes: [
27
+ { isList: false, type: 'Boolean', location: 'scalar' },
28
+ {
29
+ isList: false,
30
+ type: isList ? `${type}FindManyArgs` : `${type}Args`,
31
+ location: 'inputObjectTypes',
32
+ namespace: 'prisma',
33
+ },
34
+ ],
35
+ };
36
+ fields.push(field);
37
+ }
38
+ }
39
+ /**
40
+ * include is not generated for models that do not have a relation with any other models
41
+ * -> continue onto the next model
42
+ */
43
+ const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
44
+ if (!hasRelationToAnotherModel) {
45
+ continue;
46
+ }
47
+ const hasManyRelationToAnotherModel = (0, model_helpers_1.checkModelHasManyModelRelation)(model);
48
+ const shouldAddCountField = hasManyRelationToAnotherModel;
49
+ if (shouldAddCountField) {
50
+ const inputTypes = [{ isList: false, type: 'Boolean', location: 'scalar' }];
51
+ if (isGenerateSelect) {
52
+ inputTypes.push({
53
+ isList: false,
54
+ type: `${modelName}CountOutputTypeArgs`,
55
+ location: 'inputObjectTypes',
56
+ namespace: 'prisma',
57
+ });
58
+ }
59
+ const _countField = {
60
+ name: '_count',
61
+ isRequired: false,
62
+ isNullable: false,
63
+ inputTypes,
64
+ };
65
+ fields.push(_countField);
66
+ }
67
+ const modelIncludeInputObjectType = {
68
+ name: `${modelName}Include`,
69
+ constraints: {
70
+ maxNumFields: null,
71
+ minNumFields: null,
72
+ },
73
+ fields,
74
+ };
75
+ modelIncludeInputObjectTypes.push(modelIncludeInputObjectType);
76
+ }
77
+ return modelIncludeInputObjectTypes;
78
+ }
79
+ //# sourceMappingURL=include-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"include-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/include-helpers.ts"],"names":[],"mappings":";;;AACA,mDAAwH;AAExH,SAAgB,oCAAoC,CAChD,gBAAkC,EAClC,MAAoB,EACpB,gBAAyB;IAEzB,sFAAsF;IACtF,MAAM,gCAAgC,GAAG,oCAAoC,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAExG,KAAK,MAAM,sBAAsB,IAAI,gCAAgC,EAAE;QACnE,gBAAgB,CAAC,IAAI,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B,CAAC;QAC1D,IAAI,mBAAmB,EAAE;YACrB,MAAM,UAAU,GAA8B,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACvG,IAAI,gBAAgB,EAAE;gBAClB,UAAU,CAAC,IAAI,CAAC;oBACZ,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,GAAG,SAAS,qBAAqB;oBACvC,QAAQ,EAAE,kBAAkB;oBAC5B,SAAS,EAAE,QAAQ;iBACtB,CAAC,CAAC;aACN;YACD,MAAM,WAAW,GAAmB;gBAChC,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,KAAK;gBACjB,UAAU;aACb,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC5B;QAED,MAAM,2BAA2B,GAAmB;YAChD,IAAI,EAAE,GAAG,SAAS,SAAS;YAC3B,WAAW,EAAE;gBACT,YAAY,EAAE,IAAI;gBAClB,YAAY,EAAE,IAAI;aACrB;YACD,MAAM;SACT,CAAC;QACF,4BAA4B,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;KAClE;IACD,OAAO,4BAA4B,CAAC;AACxC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './comments-helpers';
2
+ export * from './helpers';
3
+ export * from './model-helpers';
4
+ export * from './mongodb-helpers';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./comments-helpers"), exports);
18
+ __exportStar(require("./helpers"), exports);
19
+ __exportStar(require("./model-helpers"), exports);
20
+ __exportStar(require("./mongodb-helpers"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/zod/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,4CAA0B;AAC1B,kDAAgC;AAChC,oDAAkC"}
@@ -0,0 +1,6 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ export declare function checkModelHasModelRelation(model: DMMF.Model): boolean;
3
+ export declare function checkModelHasManyModelRelation(model: DMMF.Model): boolean;
4
+ export declare function checkIsModelRelationField(modelField: DMMF.Field): boolean;
5
+ export declare function checkIsManyModelRelationField(modelField: DMMF.Field): boolean;
6
+ export declare function findModelByName(models: DMMF.Model[], modelName: string): DMMF.Model | undefined;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findModelByName = exports.checkIsManyModelRelationField = exports.checkIsModelRelationField = exports.checkModelHasManyModelRelation = exports.checkModelHasModelRelation = void 0;
4
+ function checkModelHasModelRelation(model) {
5
+ const { fields: modelFields } = model;
6
+ for (const modelField of modelFields) {
7
+ const isRelationField = checkIsModelRelationField(modelField);
8
+ if (isRelationField) {
9
+ return true;
10
+ }
11
+ }
12
+ return false;
13
+ }
14
+ exports.checkModelHasModelRelation = checkModelHasModelRelation;
15
+ function checkModelHasManyModelRelation(model) {
16
+ const { fields: modelFields } = model;
17
+ for (const modelField of modelFields) {
18
+ const isManyRelationField = checkIsManyModelRelationField(modelField);
19
+ if (isManyRelationField) {
20
+ return true;
21
+ }
22
+ }
23
+ return false;
24
+ }
25
+ exports.checkModelHasManyModelRelation = checkModelHasManyModelRelation;
26
+ function checkIsModelRelationField(modelField) {
27
+ const { kind, relationName } = modelField;
28
+ return kind === 'object' && !!relationName;
29
+ }
30
+ exports.checkIsModelRelationField = checkIsModelRelationField;
31
+ function checkIsManyModelRelationField(modelField) {
32
+ return checkIsModelRelationField(modelField) && modelField.isList;
33
+ }
34
+ exports.checkIsManyModelRelationField = checkIsManyModelRelationField;
35
+ function findModelByName(models, modelName) {
36
+ return models.find(({ name }) => name === modelName);
37
+ }
38
+ exports.findModelByName = findModelByName;
39
+ //# sourceMappingURL=model-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/model-helpers.ts"],"names":[],"mappings":";;;AAEA,SAAgB,0BAA0B,CAAC,KAAiB;IACxD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACtC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,MAAM,eAAe,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,eAAe,EAAE;YACjB,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AATD,gEASC;AAED,SAAgB,8BAA8B,CAAC,KAAiB;IAC5D,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACtC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QAClC,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;QACtE,IAAI,mBAAmB,EAAE;YACrB,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AATD,wEASC;AAED,SAAgB,yBAAyB,CAAC,UAAsB;IAC5D,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IAC1C,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,YAAY,CAAC;AAC/C,CAAC;AAHD,8DAGC;AAED,SAAgB,6BAA6B,CAAC,UAAsB;IAChE,OAAO,yBAAyB,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC;AACtE,CAAC;AAFD,sEAEC;AAED,SAAgB,eAAe,CAAC,MAAoB,EAAE,SAAiB;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;AACzD,CAAC;AAFD,0CAEC"}
@@ -0,0 +1,2 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ export declare function addMissingInputObjectTypesForModelArgs(inputObjectTypes: DMMF.InputType[], models: DMMF.Model[], isGenerateSelect: boolean, isGenerateInclude: boolean): void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addMissingInputObjectTypesForModelArgs = void 0;
4
+ const model_helpers_1 = require("./model-helpers");
5
+ function addMissingInputObjectTypesForModelArgs(inputObjectTypes, models, isGenerateSelect, isGenerateInclude) {
6
+ const modelArgsInputObjectTypes = generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude);
7
+ for (const modelArgsInputObjectType of modelArgsInputObjectTypes) {
8
+ inputObjectTypes.push(modelArgsInputObjectType);
9
+ }
10
+ }
11
+ exports.addMissingInputObjectTypesForModelArgs = addMissingInputObjectTypesForModelArgs;
12
+ function generateModelArgsInputObjectTypes(models, isGenerateSelect, isGenerateInclude) {
13
+ const modelArgsInputObjectTypes = [];
14
+ for (const model of models) {
15
+ const { name: modelName } = model;
16
+ const fields = [];
17
+ if (isGenerateSelect) {
18
+ const selectField = {
19
+ name: 'select',
20
+ isRequired: false,
21
+ isNullable: false,
22
+ inputTypes: [
23
+ {
24
+ isList: false,
25
+ type: `${modelName}Select`,
26
+ location: 'inputObjectTypes',
27
+ namespace: 'prisma',
28
+ },
29
+ ],
30
+ };
31
+ fields.push(selectField);
32
+ }
33
+ const hasRelationToAnotherModel = (0, model_helpers_1.checkModelHasModelRelation)(model);
34
+ if (isGenerateInclude && hasRelationToAnotherModel) {
35
+ const includeField = {
36
+ name: 'include',
37
+ isRequired: false,
38
+ isNullable: false,
39
+ inputTypes: [
40
+ {
41
+ isList: false,
42
+ type: `${modelName}Include`,
43
+ location: 'inputObjectTypes',
44
+ namespace: 'prisma',
45
+ },
46
+ ],
47
+ };
48
+ fields.push(includeField);
49
+ }
50
+ const modelArgsInputObjectType = {
51
+ name: `${modelName}Args`,
52
+ constraints: {
53
+ maxNumFields: null,
54
+ minNumFields: null,
55
+ },
56
+ fields,
57
+ };
58
+ modelArgsInputObjectTypes.push(modelArgsInputObjectType);
59
+ }
60
+ return modelArgsInputObjectTypes;
61
+ }
62
+ //# sourceMappingURL=modelArgs-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelArgs-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/modelArgs-helpers.ts"],"names":[],"mappings":";;;AACA,mDAA6D;AAE7D,SAAgB,sCAAsC,CAClD,gBAAkC,EAClC,MAAoB,EACpB,gBAAyB,EACzB,iBAA0B;IAE1B,MAAM,yBAAyB,GAAG,iCAAiC,CAAC,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAEjH,KAAK,MAAM,wBAAwB,IAAI,yBAAyB,EAAE;QAC9D,gBAAgB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;KACnD;AACL,CAAC;AAXD,wFAWC;AACD,SAAS,iCAAiC,CACtC,MAAoB,EACpB,gBAAyB,EACzB,iBAA0B;IAE1B,MAAM,yBAAyB,GAAqB,EAAE,CAAC;IACvD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QACxB,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;QAClC,MAAM,MAAM,GAAqB,EAAE,CAAC;QAEpC,IAAI,gBAAgB,EAAE;YAClB,MAAM,WAAW,GAAmB;gBAChC,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE;oBACR;wBACI,MAAM,EAAE,KAAK;wBACb,IAAI,EAAE,GAAG,SAAS,QAAQ;wBAC1B,QAAQ,EAAE,kBAAkB;wBAC5B,SAAS,EAAE,QAAQ;qBACtB;iBACJ;aACJ,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC5B;QAED,MAAM,yBAAyB,GAAG,IAAA,0CAA0B,EAAC,KAAK,CAAC,CAAC;QAEpE,IAAI,iBAAiB,IAAI,yBAAyB,EAAE;YAChD,MAAM,YAAY,GAAmB;gBACjC,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE;oBACR;wBACI,MAAM,EAAE,KAAK;wBACb,IAAI,EAAE,GAAG,SAAS,SAAS;wBAC3B,QAAQ,EAAE,kBAAkB;wBAC5B,SAAS,EAAE,QAAQ;qBACtB;iBACJ;aACJ,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC7B;QAED,MAAM,wBAAwB,GAAmB;YAC7C,IAAI,EAAE,GAAG,SAAS,MAAM;YACxB,WAAW,EAAE;gBACT,YAAY,EAAE,IAAI;gBAClB,YAAY,EAAE,IAAI;aACrB;YACD,MAAM;SACT,CAAC;QACF,yBAAyB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;KAC5D;IACD,OAAO,yBAAyB,CAAC;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ export declare function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations: DMMF.ModelMapping[], outputObjectTypes: DMMF.OutputType[], inputObjectTypes: DMMF.InputType[]): void;
3
+ export declare const isMongodbRawOp: (name: string) => boolean;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isMongodbRawOp = exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = void 0;
7
+ const transformer_1 = __importDefault(require("../transformer"));
8
+ function addMissingInputObjectTypesForMongoDbRawOpsAndQueries(modelOperations, outputObjectTypes, inputObjectTypes) {
9
+ const rawOpsMap = resolveMongoDbRawOperations(modelOperations);
10
+ transformer_1.default.rawOpsMap = rawOpsMap !== null && rawOpsMap !== void 0 ? rawOpsMap : {};
11
+ const mongoDbRawQueryInputObjectTypes = resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes);
12
+ for (const mongoDbRawQueryInputType of mongoDbRawQueryInputObjectTypes) {
13
+ inputObjectTypes.push(mongoDbRawQueryInputType);
14
+ }
15
+ }
16
+ exports.addMissingInputObjectTypesForMongoDbRawOpsAndQueries = addMissingInputObjectTypesForMongoDbRawOpsAndQueries;
17
+ function resolveMongoDbRawOperations(modelOperations) {
18
+ const rawOpsMap = {};
19
+ const rawOpsNames = [
20
+ ...new Set(modelOperations.reduce((result, current) => {
21
+ const keys = Object.keys(current);
22
+ keys === null || keys === void 0 ? void 0 : keys.forEach((key) => {
23
+ if (key.includes('Raw')) {
24
+ result.push(key);
25
+ }
26
+ });
27
+ return result;
28
+ }, [])),
29
+ ];
30
+ const modelNames = modelOperations.map((item) => item.model);
31
+ rawOpsNames.forEach((opName) => {
32
+ modelNames.forEach((modelName) => {
33
+ const isFind = opName === 'findRaw';
34
+ const opWithModel = `${opName.replace('Raw', '')}${modelName}Raw`;
35
+ rawOpsMap[opWithModel] = isFind ? `${modelName}FindRawArgs` : `${modelName}AggregateRawArgs`;
36
+ });
37
+ });
38
+ return rawOpsMap;
39
+ }
40
+ function resolveMongoDbRawQueryInputObjectTypes(outputObjectTypes) {
41
+ const mongoDbRawQueries = getMongoDbRawQueries(outputObjectTypes);
42
+ const mongoDbRawQueryInputObjectTypes = mongoDbRawQueries.map((item) => ({
43
+ name: item.name,
44
+ constraints: {
45
+ maxNumFields: null,
46
+ minNumFields: null,
47
+ },
48
+ fields: item.args.map((arg) => ({
49
+ name: arg.name,
50
+ isRequired: arg.isRequired,
51
+ isNullable: arg.isNullable,
52
+ inputTypes: arg.inputTypes,
53
+ })),
54
+ }));
55
+ return mongoDbRawQueryInputObjectTypes;
56
+ }
57
+ function getMongoDbRawQueries(outputObjectTypes) {
58
+ var _a;
59
+ const queryOutputTypes = outputObjectTypes.filter((item) => item.name === 'Query');
60
+ const mongodbRawQueries = (_a = queryOutputTypes === null || queryOutputTypes === void 0 ? void 0 : queryOutputTypes[0].fields.filter((field) => field.name.includes('Raw'))) !== null && _a !== void 0 ? _a : [];
61
+ return mongodbRawQueries;
62
+ }
63
+ const isMongodbRawOp = (name) => /find([^]*?)Raw/.test(name) || /aggregate([^]*?)Raw/.test(name);
64
+ exports.isMongodbRawOp = isMongodbRawOp;
65
+ //# sourceMappingURL=mongodb-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongodb-helpers.js","sourceRoot":"","sources":["../../../src/zod/helpers/mongodb-helpers.ts"],"names":[],"mappings":";;;;;;AACA,iEAAyC;AAEzC,SAAgB,oDAAoD,CAChE,eAAoC,EACpC,iBAAoC,EACpC,gBAAkC;IAElC,MAAM,SAAS,GAAG,2BAA2B,CAAC,eAAe,CAAC,CAAC;IAC/D,qBAAW,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;IAExC,MAAM,+BAA+B,GAAG,sCAAsC,CAAC,iBAAiB,CAAC,CAAC;IAClG,KAAK,MAAM,wBAAwB,IAAI,+BAA+B,EAAE;QACpE,gBAAgB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;KACnD;AACL,CAAC;AAZD,oHAYC;AAED,SAAS,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CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrE,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE;YACT,YAAY,EAAE,IAAI;YAClB,YAAY,EAAE,IAAI;SACrB;QACD,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC5B,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,UAAU,EAAE,GAAG,CAAC,UAAU;SAC7B,CAAC,CAAC;KACN,CAAC,CAAC,CAAC;IACJ,OAAO,+BAA+B,CAAC;AAC3C,CAAC;AAED,SAAS,oBAAoB,CAAC,iBAAoC;;IAC9D,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;IAEnF,MAAM,iBAAiB,GAAG,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,mCAAI,EAAE,CAAC;IAE3G,OAAO,iBAAiB,CAAC;AAC7B,CAAC;AAEM,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAnG,QAAA,cAAc,kBAAqF"}
@@ -0,0 +1,2 @@
1
+ import { DMMF } from '@prisma/generator-helper';
2
+ export declare function addMissingInputObjectTypesForSelect(inputObjectTypes: DMMF.InputType[], outputObjectTypes: DMMF.OutputType[], models: DMMF.Model[]): void;