prisma-nestjs-graphql 21.1.1 → 22.0.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/README.md CHANGED
@@ -76,6 +76,12 @@ The path to use to import the Prisma Client package
76
76
  Type: `string | undefined`
77
77
  Default: `@prisma/client`
78
78
 
79
+ #### `importExtension`
80
+
81
+ Append an extension to relative import and export module specifiers (without dot, eg. 'js, 'ts', 'mjs')
82
+ Type: `string`
83
+ Default: `''` (empty string)
84
+
79
85
  #### `combineScalarFilters`
80
86
 
81
87
  Combine nested/nullable scalar filters to single
@@ -753,7 +759,7 @@ export class User {}
753
759
  ### Using library in other generators
754
760
 
755
761
  ```ts
756
- import { generate } from 'prisma-nestjs-graphql/generate';
762
+ import { generate } from 'prisma-nestjs-graphql';
757
763
  ```
758
764
 
759
765
  ## Similar Projects
@@ -782,6 +788,8 @@ import { generate } from 'prisma-nestjs-graphql/generate';
782
788
 
783
789
  ## TODO
784
790
 
791
+ - fin Use relation type here and fix
792
+ - run example, get rid of node-dev
785
793
  - keyof typeof SortOrder -> `SortOrder`
786
794
  - dummy-createfriends.input.ts -> `create-friends`
787
795
  - check 'TODO FIXME'
package/bin.mjs ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+
3
+ import generatorHelper from '@prisma/generator-helper';
4
+
5
+ const generatorHandlerConfig = await resoveGeneratorHandlerConfig();
6
+
7
+ generatorHelper.generatorHandler(generatorHandlerConfig);
8
+
9
+ async function resoveGeneratorHandlerConfig() {
10
+ try {
11
+ const { generatorHandlerConfig } =
12
+ await import('./prisma-nestjs-graphql.mjs');
13
+ return generatorHandlerConfig;
14
+ } catch {
15
+ // Do nothing
16
+ }
17
+
18
+ const { generatorHandlerConfig } = await import('./generate.ts');
19
+ return generatorHandlerConfig;
20
+ }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "prisma-nestjs-graphql",
3
- "version": "21.1.1",
3
+ "type": "module",
4
+ "version": "22.0.0",
4
5
  "license": "MIT",
5
6
  "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
6
- "bin": "bin.js",
7
+ "bin": "bin.mjs",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "https://github.com/unlight/prisma-nestjs-graphql.git"
@@ -16,136 +17,112 @@
16
17
  "prisma-generator",
17
18
  "nestjs-graphql"
18
19
  ],
19
- "main": "./index.cjs",
20
- "types": "./index.d.ts",
21
20
  "exports": {
22
21
  ".": {
23
- "require": "./index.cjs",
24
- "types": "./index.d.ts"
25
- },
26
- "./generate": {
27
- "require": "./generate.cjs",
28
- "types": "./generate.d.ts"
29
- }
30
- },
31
- "typesVersions": {
32
- "*": {
33
- "generate": [
34
- "./generate.d.ts"
35
- ]
22
+ "default": "./prisma-nestjs-graphql.mjs",
23
+ "types": "./prisma-nestjs-graphql.d.ts"
36
24
  }
37
25
  },
38
26
  "scripts": {
39
- "test": "npm run eslint && npm run tscheck && npm run test:cov",
40
- "mocha": "node node_modules/mocha/bin/mocha",
41
- "test:r": "npm run mocha -- -r ts-node/register --no-timeouts src/**/*.spec.ts",
42
- "test:cov": "c8 --reporter text --exclude \"**/*.spec.ts\" --exclude \"**/test/**\" npm run test:r",
43
- "test:w": "npm run test:r -- --watch-files src --watch",
44
- "test:d": "ndb -r @swc/register node_modules/mocha/bin/_mocha --no-timeouts --watch-files src/**/*.ts --watch src/**/*.spec.ts",
27
+ "test": "npm run eslint && npm run tscheck && npm run test:r",
28
+ "remove_test:w": "npm run test:r -- --watch-files src --watch",
29
+ "test:r": "vitest run",
30
+ "test:cov": "vitest run --coverage",
31
+ "test:w": "vitest watch",
45
32
  "tscheck": "tsc --noEmit",
46
33
  "tscheck:w": "npm run tscheck -- --watch",
47
34
  "eslint": "node node_modules/eslint/bin/eslint \"src/**/*.{ts,tsx}\"",
48
- "eslint:w": "watchexec -w src \"npm run eslint\"",
35
+ "eslint:w": "onchange -v \"**/*.ts\" -k -i -- npm run eslint",
49
36
  "eslint:fix": "npm run eslint -- --fix",
50
- "build": "sh Taskfile build",
51
- "prisma:g": "node node_modules/prisma/build/index.js generate",
52
- "prisma:custom:g": "node node_modules/prisma/build/index.js generate --schema=./custom-package-generator/schema.prisma",
53
- "format": "npx prettier ./@generated --write",
37
+ "build": "sh Taskfile buildMicrobundle6",
38
+ "prisma:g": "npx prisma generate",
39
+ "prisma:custom:g": "npx prisma generate --schema=./custom-package-generator/schema.prisma",
40
+ "format": "npx prettier ./@generated --write --log-level=warn",
54
41
  "regen": "rm -rf @generated && npm run prisma:g && npm run format",
55
42
  "regen:custom": "rm -rf @generated-custom && npm run prisma:custom:g && npm run format",
56
- "rt": "npm run regen && npm test",
57
- "example": "node-dev example/main.ts",
58
- "clean_cache": "rm -rf node_modules/.cache",
59
- "compatibilty_check": "sh Taskfile compatibilty_check",
60
- "commit": "cz"
43
+ "example": "node --import=@poppinss/ts-exec example/main.ts",
44
+ "compatibilty_check": "sh Taskfile compatibilty_check"
61
45
  },
62
- "config": {
63
- "commitizen": {
64
- "path": "node_modules/cz-customizable"
65
- }
46
+ "config": {},
47
+ "peerDependencies": {
48
+ "@prisma/generator-helper": "6 - 7",
49
+ "identity-type": "1"
66
50
  },
67
51
  "dependencies": {
68
- "@prisma/generator-helper": "5 - 6",
69
52
  "await-event-emitter": "^2.0.2",
70
- "filenamify": "4.X",
71
- "flat": "5.X",
53
+ "filenamify": "^7.0.1",
54
+ "flat": "^6.0.1",
72
55
  "get-relative-path": "^1.0.2",
73
56
  "graceful-fs": "^4.2.11",
74
57
  "json5": "^2.2.3",
75
- "lodash": "^4.17.21",
58
+ "lodash": "^4.18.1",
76
59
  "outmatch": "^1.0.0",
77
60
  "pluralize": "^8.0.0",
78
- "pupa": "2.X",
79
- "ts-morph": "11 - 16"
61
+ "pupa": "^3.3.0",
62
+ "ts-morph": "^28.0.0",
63
+ "vitest": "^4.1.5"
80
64
  },
81
65
  "devDependencies": {
82
- "@apollo/server": "^4.11.3",
83
- "@eslint/compat": "^1.2.5",
84
- "@nestjs/apollo": "^13.0.1",
85
- "@nestjs/common": "^11.0.1",
86
- "@nestjs/core": "^11.0.1",
87
- "@nestjs/graphql": "^13.0.1",
88
- "@nestjs/platform-express": "^11.0.1",
89
- "@paljs/plugins": "^8.1.0",
90
- "@prisma/client": "5 - 6",
66
+ "@apollo/server": "^5.5.1",
67
+ "@as-integrations/express5": "^1.1.2",
68
+ "@babel/preset-typescript": "^7.28.5",
69
+ "@eslint/compat": "^2.1.0",
70
+ "@eslint/js": "^10.0.1",
71
+ "@nestjs/apollo": "^13.4.0",
72
+ "@nestjs/common": "^11.1.19",
73
+ "@nestjs/core": "^11.1.19",
74
+ "@nestjs/graphql": "^13.4.0",
75
+ "@nestjs/platform-express": "^11.1.19",
76
+ "@paljs/plugins": "^9.0.0",
77
+ "@poppinss/ts-exec": "^1.4.4",
78
+ "@prisma/adapter-pg": "^7.8.0",
79
+ "@prisma/client": "^7.8.0",
80
+ "@prisma/generator-helper": "^7.8.0",
91
81
  "@semantic-release/changelog": "^6.0.3",
92
82
  "@semantic-release/git": "^10.0.1",
93
- "@semantic-release/github": "^11.0.1",
94
- "@swc/core": "^1.10.7",
95
- "@swc/helpers": "^0.5.15",
96
- "@swc/register": "^0.1.10",
83
+ "@semantic-release/github": "^12.0.8",
97
84
  "@types/flat": "^5.0.5",
98
85
  "@types/graceful-fs": "^4.1.9",
99
- "@types/lodash": "^4.17.14",
100
- "@types/mocha": "^10.0.10",
101
- "@types/node": "^22.10.7",
86
+ "@types/lodash": "^4.17.24",
87
+ "@types/node": "^25.6.2",
102
88
  "@types/pluralize": "^0.0.33",
103
- "@typescript-eslint/eslint-plugin": "^8.20.0",
104
- "@typescript-eslint/parser": "^8.20.0",
105
89
  "apollo-server-express": "^3.13.0",
106
- "c8": "^10.1.3",
107
90
  "class-transformer": "^0.5.1",
108
- "class-validator": "^0.14.1",
109
- "commitizen": "^4.3.1",
110
- "conventional-changelog-conventionalcommits": "^8.0.0",
111
- "cz-customizable": "^7.4.0",
112
- "decimal.js": "^10.4.3",
113
- "eslint": "^9.18.0",
114
- "eslint-config-prettier": "^10.0.1",
115
- "eslint-import-resolver-node": "^0.3.9",
91
+ "class-validator": "^0.15.1",
92
+ "conventional-changelog-conventionalcommits": "^9.3.1",
93
+ "decimal.js": "^10.6.0",
94
+ "dts-bundle-generator": "^9.5.1",
95
+ "eslint": "^10.3.0",
96
+ "eslint-config-prettier": "^10.1.8",
97
+ "eslint-import-resolver-node": "^0.3.10",
116
98
  "eslint-plugin-etc": "^2.0.3",
117
- "eslint-plugin-import": "^2.31.0",
118
- "eslint-plugin-only-warn": "^1.1.0",
119
- "eslint-plugin-perfectionist": "^4.6.0",
120
- "eslint-plugin-prettier": "^5.2.2",
121
- "eslint-plugin-regexp": "^2.7.0",
122
- "eslint-plugin-simple-import-sort": "^12.1.1",
123
- "eslint-plugin-sort-class-members": "^1.21.0",
124
- "eslint-plugin-unicorn": "^56.0.1",
99
+ "eslint-plugin-import": "^2.32.0",
100
+ "eslint-plugin-only-warn": "^1.2.1",
101
+ "eslint-plugin-perfectionist": "^5.9.0",
102
+ "eslint-plugin-prettier": "^5.5.5",
103
+ "eslint-plugin-regexp": "^3.1.0",
104
+ "eslint-plugin-simple-import-sort": "^13.0.0",
105
+ "eslint-plugin-sort-class-members": "^1.22.1",
106
+ "eslint-plugin-unicorn": "^64.0.0",
125
107
  "eslint-plugin-wix-editor": "^3.3.0",
126
- "expect": "^29.7.0",
127
- "graphql": "^16.10.0",
128
- "graphql-scalars": "^1.24.0",
108
+ "graphql": "^16.14.0",
109
+ "graphql-scalars": "^1.25.0",
129
110
  "graphql-type-json": "^0.3.2",
130
- "mocha": "^11.0.1",
131
- "node-dev": "^8.0.0",
111
+ "identity-type": "^1.0.0",
112
+ "microbundle": "^0.15.1",
132
113
  "ololog": "^1.1.175",
133
- "pkgroll": "^2.6.1",
134
114
  "precise-commits": "^1.0.2",
135
- "prettier": "^3.4.2",
136
- "prisma": "5 - 6",
137
- "prisma-graphql-type-decimal": "^3.0.0",
115
+ "prettier": "^3.8.3",
116
+ "prisma": "7",
117
+ "prisma-graphql-type-decimal": "^4.0.3",
138
118
  "reflect-metadata": "^0.2.2",
139
- "request": "^2.88.2",
140
- "rxjs": "^7.8.1",
141
- "semantic-release": "^24.2.1",
119
+ "rxjs": "^7.8.2",
120
+ "semantic-release": "^25.0.3",
142
121
  "simplytyped": "^3.3.0",
143
- "temp-dir": "2.X",
144
- "ts-node": "^10.9.2",
122
+ "temp-dir": "^3.0.0",
145
123
  "tslib": "^2.8.1",
146
- "type-fest": "^4.32.0",
147
- "typescript": "^5.7.3",
148
- "typescript-eslint": "^8.20.0",
149
- "watchexec-bin": "^1.0.0"
124
+ "type-fest": "^5.6.0",
125
+ "typescript": "^6.0.3",
126
+ "typescript-eslint": "^8.59.2"
150
127
  }
151
128
  }
@@ -0,0 +1,131 @@
1
+ import { DMMF, GeneratorOptions } from '@prisma/generator-helper';
2
+ import AwaitEventEmitter from 'await-event-emitter';
3
+ import { Project, SourceFile } from 'ts-morph';
4
+ import { ValueOf, WritableDeep } from 'type-fest';
5
+
6
+ declare const ReExport: {
7
+ readonly All: "All";
8
+ readonly Directories: "Directories";
9
+ readonly None: "None";
10
+ readonly Single: "Single";
11
+ };
12
+ export type ReExportType = ValueOf<typeof ReExport>;
13
+ export type DecorateElement = {
14
+ isMatchField: (s: string) => boolean;
15
+ isMatchType: (s: string) => boolean;
16
+ from: string;
17
+ name: string;
18
+ arguments?: string[];
19
+ namedImport: boolean;
20
+ defaultImport?: string | true;
21
+ namespaceImport?: string;
22
+ };
23
+ export type CustomImport = {
24
+ from: string;
25
+ name: string;
26
+ namedImport: boolean;
27
+ defaultImport?: string | true;
28
+ namespaceImport?: string;
29
+ };
30
+ declare function createConfig(data: Record<string, unknown>): {
31
+ $warnings: string[];
32
+ combineScalarFilters: boolean;
33
+ customImport: CustomImport[];
34
+ decorate: DecorateElement[];
35
+ emitBlocks: Record<"models" | "inputs" | "args" | "outputs" | "prismaEnums" | "schemaEnums", boolean>;
36
+ emitCompiled: boolean;
37
+ emitSingle: boolean;
38
+ fields: Record<string, Partial<Omit<ObjectSetting, "name">> | undefined>;
39
+ graphqlScalars: Record<string, ImportNameSpec | undefined>;
40
+ importExtension: string;
41
+ noAtomicOperations: boolean;
42
+ noTypeId: boolean;
43
+ omitModelsCount: boolean;
44
+ outputFilePattern: string;
45
+ prismaClientImport: string;
46
+ purgeOutput: boolean;
47
+ reExport: ReExportType;
48
+ requireSingleFieldsInWhereUniqueInput: boolean;
49
+ tsConfigFilePath: string | undefined;
50
+ unsafeCompatibleWhereUniqueInput: boolean;
51
+ useInputType: ConfigInputItem[];
52
+ };
53
+ export type ConfigInputItem = {
54
+ typeName: string;
55
+ ALL?: string;
56
+ [index: string]: string | undefined;
57
+ };
58
+ export type ObjectSetting = {
59
+ /**
60
+ * Act as named import or namespaceImport or defaultImport
61
+ */
62
+ name: string;
63
+ kind: "Decorator" | "Field" | "FieldType" | "PropertyType" | "ObjectType";
64
+ arguments?: string[] | Record<string, unknown>;
65
+ input: boolean;
66
+ output: boolean;
67
+ model: boolean;
68
+ match?: (test: string) => boolean;
69
+ from: string;
70
+ namespace?: string;
71
+ defaultImport?: string | true;
72
+ namespaceImport?: string;
73
+ namedImport?: boolean;
74
+ };
75
+ export interface ObjectSettingsFilterArgs {
76
+ name: string;
77
+ input?: boolean;
78
+ output?: boolean;
79
+ }
80
+ declare class ObjectSettings extends Array<ObjectSetting> {
81
+ shouldHideField({ input, name, output, }: ObjectSettingsFilterArgs): boolean;
82
+ getFieldType({ input, name, output, }: ObjectSettingsFilterArgs): ObjectSetting | undefined;
83
+ getPropertyType({ input, name, output, }: ObjectSettingsFilterArgs): ObjectSetting | undefined;
84
+ getObjectTypeArguments(options: Record<string, any>): string[];
85
+ fieldArguments(): Record<string, unknown> | undefined;
86
+ }
87
+ export type TAwaitEventEmitter = AwaitEventEmitter.default;
88
+ export type Model = WritableDeep<DMMF.Model>;
89
+ export type Schema = WritableDeep<DMMF.Schema>;
90
+ export type GeneratorConfiguration = ReturnType<typeof createConfig>;
91
+ export type EventArguments = {
92
+ schema: Schema;
93
+ models: Map<string, Model>;
94
+ modelNames: string[];
95
+ modelFields: Map<string, Map<string, Field>>;
96
+ fieldSettings: Map<string, Map<string, ObjectSettings>>;
97
+ config: GeneratorConfiguration;
98
+ project: Project;
99
+ output: string;
100
+ getSourceFile(args: {
101
+ type: string;
102
+ name: string;
103
+ }): SourceFile;
104
+ eventEmitter: TAwaitEventEmitter;
105
+ typeNames: Set<string>;
106
+ removeTypes: Set<string>;
107
+ enums: Record<string, DMMF.DatamodelEnum | undefined>;
108
+ getModelName(name: string): string | undefined;
109
+ /**
110
+ * Input types for this models should be decorated @Type(() => Self)
111
+ */
112
+ classTransformerTypeModels: Set<string>;
113
+ };
114
+ export type ImportNameSpec = {
115
+ name: string;
116
+ specifier?: string;
117
+ };
118
+ export type Field = DMMF.Field;
119
+ export declare function generate(args: GeneratorOptions & {
120
+ skipAddOutputSourceFiles?: boolean;
121
+ connectCallback?: (emitter: TAwaitEventEmitter, eventArguments: EventArguments) => void | Promise<void>;
122
+ }): Promise<void>;
123
+ export declare const generatorHandlerConfig: {
124
+ onGenerate(options: GeneratorOptions): Promise<void>;
125
+ onManifest(): {
126
+ defaultOutput: string;
127
+ prettyName: string;
128
+ };
129
+ };
130
+
131
+ export {};