Skip to content

Commit 220e767

Browse files
committed
fix: Simplified prisma types import
1 parent 85e6cd5 commit 220e767

25 files changed

+49920
-51
lines changed

client/.eslintrc.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ module.exports = {
9393
"max-len": ["error", {
9494
"code": 100,
9595
"ignoreComments": true,
96-
"ignoreStrings": true,
96+
"ignoreStrings": true,
97+
"ignoreTemplateLiterals": true,
9798
}],
9899
"prefer-promise-reject-errors": 'off',
99100
'comma-dangle': 'off',
100101
'eol-last': 'off',
102+
"no-use-before-define": "off",
103+
"@typescript-eslint/no-use-before-define": ["error"]
101104
},
102105
};

client/src/api/RecordRoutes.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ export type RecordWithAuthor = Record & {
77
author: User;
88
};
99

10-
export type RecordUpdate = Partial<Record> & {
11-
author?: {
12-
create?: Prisma.RecordCreateWithoutAuthorInput;
13-
connect?: Prisma.RecordWhereUniqueInput;
14-
update?: Prisma.RecordUpdateWithoutAuthorInput;
15-
}
16-
};
17-
1810
const RecordRoutes = {
19-
...Super<Record, RecordUpdate>('record'),
11+
...Super<Record, Prisma.RecordUpdateInput>('record'),
2012
list: (object?: string) => Fetch<RecordWithAuthor[]>('/api/record/list', {
2113
object,
2214
}),

client/src/api/RequestRoutes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Request } from '@fullstack-typescript-monorepo/prisma';
1+
import { Prisma, Request } from '@fullstack-typescript-monorepo/prisma';
22
import Super from './Super';
33

44
export type RequestUpdate = Partial<Request>;
55

66
const RequestRoutes = {
7-
...Super<Request, RequestUpdate>('request'),
7+
...Super<Request, Prisma.RequestUpdateInput>('request'),
88
};
99

1010
export default RequestRoutes;

client/src/api/UserRoutes.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@ export interface User extends Omit<_User, 'password'> {
66
person: Person;
77
}
88

9-
export type UserUpdate = Partial<_User> & {
10-
person?: {
11-
create?: Prisma.PersonCreateWithoutUserInput;
12-
connect?: Prisma.PersonWhereUniqueInput;
13-
update?: Prisma.PersonUpdateWithoutUserInput;
14-
},
15-
};
16-
179
const UserRoutes = {
18-
...Super<User, UserUpdate>('user'),
10+
...Super<User, Prisma.UserUpdateInput>('user'),
1911
authenticate: (login: string, password: string): Promise<User> => Fetch<User>('/api/user/authenticate', {
2012
login,
2113
password,

client/src/components/forms/UserForm.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { Prisma } from '@fullstack-typescript-monorepo/prisma';
12
import { LoadingButton } from '@mui/lab';
23
import { Box, Checkbox, Divider, FormControlLabel, Grid, TextField } from '@mui/material';
34
import React from 'react';
45
import { useTranslation } from 'react-i18next';
56
import { useNavigate } from 'react-router';
6-
import UserRoutes, { UserUpdate } from '../../api/UserRoutes';
7+
import UserRoutes from '../../api/UserRoutes';
78
import { useAlert } from '../../hooks/useAlert';
89
import useForm from '../../hooks/useForm';
910
import { useLoader } from '../../hooks/useLoader';
@@ -38,7 +39,7 @@ const UserForm = ({ data }: Props) => {
3839

3940
// Submit user data
4041
const onSubmit = async (formData: Data) => {
41-
const processedData: UserUpdate = {
42+
const processedData: Prisma.UserUpdateInput = {
4243
admin: formData.admin,
4344
login: formData.login,
4445
active: true,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"node": "16.13.1"
88
},
99
"scripts": {
10-
"clean": "rimraf \"client/build\" \"core/lib\" \"prisma/lib\" \"server/lib\" \"**/node_modules\" \"**/tsconfig.tsbuildinfo\"",
10+
"clean": "rimraf \"client/build\" \"core/lib\" \"server/lib\" \"**/node_modules\" \"**/tsconfig.tsbuildinfo\"",
1111
"compile": "tsc -b tsconfig.build.json",
1212
"front": "npm run start --workspace=client",
1313
"back": "npm run start:watch --workspace=server",

postInstall.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
if [ "$NODE_ENV" = "production" ]; then
2+
# Sync DB
23
npm run db:sync:prod
4+
5+
# Compile Typescript
36
npm run compile
7+
8+
# Seed DB
49
npm run db:seed
5-
npm run build --workspace=client
10+
11+
# Build client
12+
npm run build --workspace=client
613
else
14+
# Generate schema types + Sync DB
715
npm run db:sync:dev
16+
17+
# Overwrite ./prisma/package.json with ./prisma/package.reference.json
18+
cp ./prisma/package.reference.json ./prisma/package.json
19+
20+
# Compile Typescript
821
npm run compile
22+
23+
# Seed DB
924
npm run db:seed
1025
fi

prisma/index-browser.js

+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
4+
const {
5+
Decimal,
6+
objectEnumValues,
7+
makeStrictEnum
8+
} = require('./runtime/index-browser')
9+
10+
11+
const Prisma = {}
12+
13+
exports.Prisma = Prisma
14+
15+
/**
16+
* Prisma Client JS version: 4.7.1
17+
* Query Engine version: 272861e07ab64f234d3ffc4094e32bd61775599c
18+
*/
19+
Prisma.prismaVersion = {
20+
client: "4.7.1",
21+
engine: "272861e07ab64f234d3ffc4094e32bd61775599c"
22+
}
23+
24+
Prisma.PrismaClientKnownRequestError = () => {
25+
throw new Error(`PrismaClientKnownRequestError is unable to be run in the browser.
26+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
27+
)};
28+
Prisma.PrismaClientUnknownRequestError = () => {
29+
throw new Error(`PrismaClientUnknownRequestError is unable to be run in the browser.
30+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
31+
)}
32+
Prisma.PrismaClientRustPanicError = () => {
33+
throw new Error(`PrismaClientRustPanicError is unable to be run in the browser.
34+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
35+
)}
36+
Prisma.PrismaClientInitializationError = () => {
37+
throw new Error(`PrismaClientInitializationError is unable to be run in the browser.
38+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
39+
)}
40+
Prisma.PrismaClientValidationError = () => {
41+
throw new Error(`PrismaClientValidationError is unable to be run in the browser.
42+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
43+
)}
44+
Prisma.NotFoundError = () => {
45+
throw new Error(`NotFoundError is unable to be run in the browser.
46+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
47+
)}
48+
Prisma.Decimal = Decimal
49+
50+
/**
51+
* Re-export of sql-template-tag
52+
*/
53+
Prisma.sql = () => {
54+
throw new Error(`sqltag is unable to be run in the browser.
55+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
56+
)}
57+
Prisma.empty = () => {
58+
throw new Error(`empty is unable to be run in the browser.
59+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
60+
)}
61+
Prisma.join = () => {
62+
throw new Error(`join is unable to be run in the browser.
63+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
64+
)}
65+
Prisma.raw = () => {
66+
throw new Error(`raw is unable to be run in the browser.
67+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
68+
)}
69+
Prisma.validator = () => (val) => val
70+
71+
72+
/**
73+
* Shorthand utilities for JSON filtering
74+
*/
75+
Prisma.DbNull = objectEnumValues.instances.DbNull
76+
Prisma.JsonNull = objectEnumValues.instances.JsonNull
77+
Prisma.AnyNull = objectEnumValues.instances.AnyNull
78+
79+
Prisma.NullTypes = {
80+
DbNull: objectEnumValues.classes.DbNull,
81+
JsonNull: objectEnumValues.classes.JsonNull,
82+
AnyNull: objectEnumValues.classes.AnyNull
83+
}
84+
85+
/**
86+
* Enums
87+
*/
88+
// Based on
89+
// https://github.com/microsoft/TypeScript/issues/3192#issuecomment-261720275
90+
function makeEnum(x) { return x; }
91+
92+
exports.Prisma.AddressScalarFieldEnum = makeEnum({
93+
id: 'id',
94+
streetNumber: 'streetNumber',
95+
street: 'street',
96+
zip: 'zip',
97+
city: 'city',
98+
country: 'country',
99+
placeId: 'placeId'
100+
});
101+
102+
exports.Prisma.JsonNullValueFilter = makeEnum({
103+
DbNull: Prisma.DbNull,
104+
JsonNull: Prisma.JsonNull,
105+
AnyNull: Prisma.AnyNull
106+
});
107+
108+
exports.Prisma.JsonNullValueInput = makeEnum({
109+
JsonNull: Prisma.JsonNull
110+
});
111+
112+
exports.Prisma.PersonScalarFieldEnum = makeEnum({
113+
id: 'id',
114+
firstName: 'firstName',
115+
lastName: 'lastName',
116+
email: 'email',
117+
phone: 'phone',
118+
phone2: 'phone2',
119+
addressId: 'addressId'
120+
});
121+
122+
exports.Prisma.QueryMode = makeEnum({
123+
default: 'default',
124+
insensitive: 'insensitive'
125+
});
126+
127+
exports.Prisma.RecordScalarFieldEnum = makeEnum({
128+
id: 'id',
129+
date: 'date',
130+
action: 'action',
131+
object: 'object',
132+
newValue: 'newValue',
133+
authorId: 'authorId'
134+
});
135+
136+
exports.Prisma.RequestScalarFieldEnum = makeEnum({
137+
id: 'id',
138+
date: 'date',
139+
status: 'status',
140+
response: 'response'
141+
});
142+
143+
exports.Prisma.SortOrder = makeEnum({
144+
asc: 'asc',
145+
desc: 'desc'
146+
});
147+
148+
exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
149+
ReadUncommitted: 'ReadUncommitted',
150+
ReadCommitted: 'ReadCommitted',
151+
RepeatableRead: 'RepeatableRead',
152+
Serializable: 'Serializable'
153+
});
154+
155+
exports.Prisma.UserScalarFieldEnum = makeEnum({
156+
id: 'id',
157+
login: 'login',
158+
admin: 'admin',
159+
password: 'password',
160+
active: 'active',
161+
connexionToken: 'connexionToken',
162+
personId: 'personId'
163+
});
164+
exports.RecordAction = makeEnum({
165+
CREATE: 'CREATE',
166+
UPDATE: 'UPDATE',
167+
DELETE: 'DELETE'
168+
});
169+
170+
exports.RequestStatus = makeEnum({
171+
PENDING: 'PENDING',
172+
SUCCESS: 'SUCCESS',
173+
ERROR: 'ERROR'
174+
});
175+
176+
exports.Prisma.ModelName = makeEnum({
177+
Address: 'Address',
178+
Person: 'Person',
179+
User: 'User',
180+
Request: 'Request',
181+
Record: 'Record'
182+
});
183+
184+
/**
185+
* Create the Client
186+
*/
187+
class PrismaClient {
188+
constructor() {
189+
throw new Error(
190+
`PrismaClient is unable to be run in the browser.
191+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`,
192+
)
193+
}
194+
}
195+
exports.PrismaClient = PrismaClient
196+
197+
Object.assign(exports, Prisma)

0 commit comments

Comments
 (0)