Skip to content

Commit cb2e423

Browse files
authored
merge dev to main (v2.6.0) (#1732)
2 parents 61b32cb + 9fb8d5b commit cb2e423

File tree

50 files changed

+1696
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1696
-196
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-monorepo",
3-
"version": "2.5.1",
3+
"version": "2.6.0",
44
"description": "",
55
"scripts": {
66
"build": "pnpm -r build",

packages/ide/jetbrains/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = "dev.zenstack"
12-
version = "2.5.1"
12+
version = "2.6.0"
1313

1414
repositories {
1515
mavenCentral()

packages/ide/jetbrains/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jetbrains",
3-
"version": "2.5.1",
3+
"version": "2.6.0",
44
"displayName": "ZenStack JetBrains IDE Plugin",
55
"description": "ZenStack JetBrains IDE plugin",
66
"homepage": "https://zenstack.dev",

packages/language/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/language",
3-
"version": "2.5.1",
3+
"version": "2.6.0",
44
"displayName": "ZenStack modeling language compiler",
55
"description": "ZenStack modeling language compiler",
66
"homepage": "https://zenstack.dev",

packages/misc/redwood/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/redwood",
33
"displayName": "ZenStack RedwoodJS Integration",
4-
"version": "2.5.1",
4+
"version": "2.6.0",
55
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
66
"repository": {
77
"type": "git",

packages/plugins/openapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/openapi",
33
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
4-
"version": "2.5.1",
4+
"version": "2.6.0",
55
"description": "ZenStack plugin and runtime supporting OpenAPI",
66
"main": "index.js",
77
"repository": {

packages/plugins/swr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/swr",
33
"displayName": "ZenStack plugin for generating SWR hooks",
4-
"version": "2.5.1",
4+
"version": "2.6.0",
55
"description": "ZenStack plugin for generating SWR hooks",
66
"main": "index.js",
77
"repository": {

packages/plugins/tanstack-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/tanstack-query",
33
"displayName": "ZenStack plugin for generating tanstack-query hooks",
4-
"version": "2.5.1",
4+
"version": "2.6.0",
55
"description": "ZenStack plugin for generating tanstack-query hooks",
66
"main": "index.js",
77
"exports": {

packages/plugins/trpc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/trpc",
33
"displayName": "ZenStack plugin for tRPC",
4-
"version": "2.5.1",
4+
"version": "2.6.0",
55
"description": "ZenStack plugin for tRPC",
66
"main": "index.js",
77
"repository": {

packages/plugins/trpc/src/helpers.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ function getPrismaOperationTypes(model: string, operation: string) {
4848

4949
let argsType: string;
5050
let resultType: string;
51+
const argsOptional = ['findMany', 'findFirst', 'findFirstOrThrow', 'createMany', 'deleteMany', 'count'].includes(
52+
operation
53+
);
5154

5255
switch (operation) {
5356
case 'findUnique':
@@ -178,7 +181,7 @@ function getPrismaOperationTypes(model: string, operation: string) {
178181
throw new PluginError(name, `Unsupported operation: "${operation}"`);
179182
}
180183

181-
return { genericBase, argsType, resultType };
184+
return { genericBase, argsType, resultType, argsOptional };
182185
}
183186

184187
/**
@@ -192,22 +195,23 @@ export function generateRouterTyping(
192195
version: string
193196
) {
194197
const procType = getProcedureTypeByOpName(baseOpType);
195-
const { genericBase, argsType, resultType } = getPrismaOperationTypes(modelName, opType);
198+
const { genericBase, argsType, argsOptional, resultType } = getPrismaOperationTypes(modelName, opType);
196199
const errorType = `TRPCClientErrorLike<AppRouter>`;
200+
const inputOptional = argsOptional ? '?' : '';
197201

198202
writer.block(() => {
199203
if (procType === 'query') {
200204
if (version === 'v10') {
201205
writer.writeLine(`
202206
useQuery: <T extends ${genericBase}, TData = ${resultType}>(
203-
input: ${argsType},
207+
input${inputOptional}: ${argsType},
204208
opts?: UseTRPCQueryOptions<string, T, ${resultType}, TData, Error>
205209
) => UseTRPCQueryResult<
206210
TData,
207211
${errorType}
208212
>;
209213
useInfiniteQuery: <T extends ${genericBase}>(
210-
input: Omit<${argsType}, 'cursor'>,
214+
input${inputOptional}: Omit<${argsType}, 'cursor'>,
211215
opts?: UseTRPCInfiniteQueryOptions<string, T, ${resultType}, Error>
212216
) => UseTRPCInfiniteQueryResult<
213217
${resultType},
@@ -217,26 +221,26 @@ export function generateRouterTyping(
217221
} else {
218222
writer.writeLine(`
219223
useQuery: <T extends ${genericBase}, TData = ${resultType}>(
220-
input: ${argsType},
224+
input${inputOptional}: ${argsType},
221225
opts?: UseTRPCQueryOptions<${resultType}, TData, Error>
222226
) => UseTRPCQueryResult<
223227
TData,
224228
${errorType}
225229
>;
226230
useInfiniteQuery: <T extends ${genericBase}>(
227-
input: Omit<${argsType}, 'cursor'>,
231+
input${inputOptional}: Omit<${argsType}, 'cursor'>,
228232
opts?: UseTRPCInfiniteQueryOptions<T, ${resultType}, Error>
229233
) => UseTRPCInfiniteQueryResult<
230234
${resultType},
231235
${errorType},
232236
T
233237
>;
234238
useSuspenseQuery: <T extends ${genericBase}, TData = ${resultType}>(
235-
input: ${argsType},
239+
input${inputOptional}: ${argsType},
236240
opts?: UseTRPCSuspenseQueryOptions<${resultType}, TData, Error>
237241
) => UseTRPCSuspenseQueryResult<TData, ${errorType}>;
238242
useSuspenseInfiniteQuery: <T extends ${genericBase}>(
239-
input: Omit<${argsType}, 'cursor'>,
243+
input${inputOptional}: Omit<${argsType}, 'cursor'>,
240244
opts?: UseTRPCSuspenseInfiniteQueryOptions<T, ${resultType}, Error>
241245
) => UseTRPCSuspenseInfiniteQueryResult<${resultType}, ${errorType}, T>;
242246
`);
@@ -298,10 +302,10 @@ export const getInputSchemaByOpName = (opName: string, modelName: string) => {
298302
inputType = `$Schema.${capModelName}InputSchema.findUnique`;
299303
break;
300304
case 'findFirst':
301-
inputType = `$Schema.${capModelName}InputSchema.findFirst`;
305+
inputType = `$Schema.${capModelName}InputSchema.findFirst.optional()`;
302306
break;
303307
case 'findMany':
304-
inputType = `$Schema.${capModelName}InputSchema.findMany`;
308+
inputType = `$Schema.${capModelName}InputSchema.findMany.optional()`;
305309
break;
306310
case 'findRaw':
307311
inputType = `$Schema.${capModelName}InputSchema.findRawObject`;
@@ -310,7 +314,7 @@ export const getInputSchemaByOpName = (opName: string, modelName: string) => {
310314
inputType = `$Schema.${capModelName}InputSchema.create`;
311315
break;
312316
case 'createMany':
313-
inputType = `$Schema.${capModelName}InputSchema.createMany`;
317+
inputType = `$Schema.${capModelName}InputSchema.createMany.optional()`;
314318
break;
315319
case 'deleteOne':
316320
inputType = `$Schema.${capModelName}InputSchema.delete`;
@@ -319,7 +323,7 @@ export const getInputSchemaByOpName = (opName: string, modelName: string) => {
319323
inputType = `$Schema.${capModelName}InputSchema.update`;
320324
break;
321325
case 'deleteMany':
322-
inputType = `$Schema.${capModelName}InputSchema.deleteMany`;
326+
inputType = `$Schema.${capModelName}InputSchema.deleteMany.optional()`;
323327
break;
324328
case 'updateMany':
325329
inputType = `$Schema.${capModelName}InputSchema.updateMany`;
@@ -337,7 +341,7 @@ export const getInputSchemaByOpName = (opName: string, modelName: string) => {
337341
inputType = `$Schema.${capModelName}InputSchema.groupBy`;
338342
break;
339343
case 'count':
340-
inputType = `$Schema.${capModelName}InputSchema.count`;
344+
inputType = `$Schema.${capModelName}InputSchema.count.optional()`;
341345
break;
342346
default:
343347
break;

0 commit comments

Comments
 (0)