Skip to content

Commit

Permalink
chore: pin version of @prisma/internals and @prisma/generator-helper (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Apr 11, 2024
1 parent f3796a8 commit 81c7e87
Show file tree
Hide file tree
Showing 36 changed files with 72 additions and 139 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "",
"scripts": {
"build": "pnpm -r build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "dev.zenstack"
version = "2.0.0-beta.9"
version = "2.0.0-beta.10"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetbrains",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"displayName": "ZenStack JetBrains IDE Plugin",
"description": "ZenStack JetBrains IDE plugin",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/misc/redwood/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/redwood",
"displayName": "ZenStack RedwoodJS Integration",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
"repository": {
"type": "git",
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/openapi",
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand All @@ -26,7 +26,6 @@
"author": "ZenStack Team",
"license": "MIT",
"dependencies": {
"@prisma/generator-helper": "^5.0.0",
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
Expand Down
10 changes: 8 additions & 2 deletions packages/plugins/openapi/src/generator-base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type { DMMF } from '@prisma/generator-helper';
import { PluginError, PluginOptions, PluginResult, getDataModels, hasAttribute } from '@zenstackhq/sdk';
import {
PluginError,
getDataModels,
hasAttribute,
type DMMF,
type PluginOptions,
type PluginResult,
} from '@zenstackhq/sdk';
import { Model } from '@zenstackhq/sdk/ast';
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
import semver from 'semver';
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Inspired by: https://github.com/omar-dulaimi/prisma-trpc-generator

import type { DMMF } from '@prisma/generator-helper';
import {
analyzePolicies,
getDataModels,
Expand All @@ -10,6 +9,7 @@ import {
isRelationshipField,
requireOption,
resolvePath,
type DMMF,
} from '@zenstackhq/sdk';
import { DataModel, DataModelField, DataModelFieldType, Enum, isDataModel, isEnum } from '@zenstackhq/sdk/ast';
import fs from 'fs';
Expand Down
10 changes: 3 additions & 7 deletions packages/plugins/openapi/src/rpc-generator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Inspired by: https://github.com/omar-dulaimi/prisma-trpc-generator

import type { DMMF } from '@prisma/generator-helper';
import { analyzePolicies, PluginError, requireOption, resolvePath } from '@zenstackhq/sdk';
import { analyzePolicies, PluginError, requireOption, resolvePath, type DMMF } from '@zenstackhq/sdk';
import { DataModel, isDataModel } from '@zenstackhq/sdk/ast';
import {
addMissingInputObjectTypesForAggregate,
Expand Down Expand Up @@ -773,10 +772,7 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
outputType = this.prismaTypeToOpenAPIType(field.outputType.type, !!field.isNullable);
break;
case 'outputObjectTypes':
outputType = this.prismaTypeToOpenAPIType(
typeof field.outputType.type === 'string' ? field.outputType.type : field.outputType.type.name,
!!field.isNullable
);
outputType = this.prismaTypeToOpenAPIType(field.outputType.type, !!field.isNullable);
break;
}
field.outputType;
Expand Down Expand Up @@ -805,7 +801,7 @@ export class RPCOpenAPIGenerator extends OpenAPIGeneratorBase {
}
}

private prismaTypeToOpenAPIType(type: DMMF.ArgType, nullable: boolean): OAPI.ReferenceObject | OAPI.SchemaObject {
private prismaTypeToOpenAPIType(type: string, nullable: boolean): OAPI.ReferenceObject | OAPI.SchemaObject {
const result = match(type)
.with('String', () => ({ type: 'string' }))
.with(P.union('Int', 'BigInt'), () => ({ type: 'integer' }))
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/swr",
"displayName": "ZenStack plugin for generating SWR hooks",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -38,7 +38,6 @@
}
},
"dependencies": {
"@prisma/generator-helper": "^5.0.0",
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/src/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { DMMF } from '@prisma/generator-helper';
import {
PluginOptions,
createProject,
Expand All @@ -10,6 +9,7 @@ import {
requireOption,
resolvePath,
saveProject,
type DMMF,
} from '@zenstackhq/sdk';
import { DataModel, Model } from '@zenstackhq/sdk/ast';
import { paramCase } from 'change-case';
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/tanstack-query",
"displayName": "ZenStack plugin for generating tanstack-query hooks",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"exports": {
Expand Down Expand Up @@ -80,7 +80,6 @@
"author": "ZenStack Team",
"license": "MIT",
"dependencies": {
"@prisma/generator-helper": "^5.0.0",
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/tanstack-query/src/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { DMMF } from '@prisma/generator-helper';
import {
PluginError,
PluginOptions,
Expand All @@ -11,6 +10,7 @@ import {
requireOption,
resolvePath,
saveProject,
type DMMF,
} from '@zenstackhq/sdk';
import { DataModel, Model } from '@zenstackhq/sdk/ast';
import { paramCase } from 'change-case';
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/trpc",
"displayName": "ZenStack plugin for tRPC",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand All @@ -26,7 +26,6 @@
"author": "ZenStack Team",
"license": "MIT",
"dependencies": {
"@prisma/generator-helper": "^5.0.0",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"lower-case-first": "^2.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/trpc/src/generator.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { DMMF } from '@prisma/generator-helper';
import {
CrudFailureReason,
PluginError,
PluginOptions,
RUNTIME_PACKAGE,
ensureEmptyDir,
getPrismaClientImportSpec,
parseOptionAsStrings,
requireOption,
resolvePath,
saveProject,
type DMMF,
type PluginOptions,
} from '@zenstackhq/sdk';
import { Model } from '@zenstackhq/sdk/ast';
import fs from 'fs';
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/trpc/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { DMMF } from '@prisma/generator-helper';
import { PluginError, getPrismaClientImportSpec, type PluginOptions } from '@zenstackhq/sdk';
import { PluginError, getPrismaClientImportSpec, type DMMF, type PluginOptions } from '@zenstackhq/sdk';
import { lowerCaseFirst } from 'lower-case-first';
import { CodeBlockWriter, SourceFile } from 'ts-morph';
import { upperCaseFirst } from 'upper-case-first';
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/runtime",
"displayName": "ZenStack Runtime Library",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down
3 changes: 1 addition & 2 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "zenstack",
"displayName": "ZenStack Language Tools",
"description": "Build scalable web apps with minimum code by defining authorization and validation rules inside the data schema that closer to the database",
"version": "2.0.0-beta.9",
"version": "2.0.0-beta.10",
"author": {
"name": "ZenStack Team"
},
Expand Down Expand Up @@ -79,7 +79,6 @@
},
"dependencies": {
"@paralleldrive/cuid2": "^2.2.0",
"@prisma/generator-helper": "^5.0.0",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"async-exit-hook": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/cli/plugin-runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-var-requires */
import type { DMMF } from '@prisma/generator-helper';
import { isPlugin, Model, Plugin } from '@zenstackhq/language/ast';
import {
createProject,
Expand All @@ -12,6 +11,7 @@ import {
PluginError,
resolvePath,
saveProject,
type DMMF,
type OptionValue,
type PluginDeclaredOptions,
type PluginFunction,
Expand Down
8 changes: 4 additions & 4 deletions packages/schema/src/plugins/enhancer/enhance/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import type { DMMF } from '@prisma/generator-helper';
import { DELEGATE_AUX_RELATION_PREFIX } from '@zenstackhq/runtime';
import {
PluginError,
getAttribute,
getAttributeArg,
getAuthModel,
getDataModels,
getDMMF,
getDataModels,
getPrismaClientImportSpec,
isDelegateModel,
PluginError,
type DMMF,
type PluginOptions,
} from '@zenstackhq/sdk';
import {
DataModel,
DataModelField,
ReferenceExpr,
isArrayExpr,
isDataModel,
isReferenceExpr,
ReferenceExpr,
type Model,
} from '@zenstackhq/sdk/ast';
import fs from 'fs';
Expand Down
12 changes: 2 additions & 10 deletions packages/schema/src/plugins/zod/generator.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { ConnectorType, DMMF } from '@prisma/generator-helper';
import {
PluginGlobalOptions,
PluginOptions,
ensureEmptyDir,
getDataModels,
getLiteral,
getPrismaClientImportSpec,
hasAttribute,
isEnumFieldReference,
isForeignKeyField,
isFromStdlib,
parseOptionAsStrings,
resolvePath,
type DMMF,
} from '@zenstackhq/sdk';
import { DataModel, DataSource, EnumField, Model, isDataModel, isDataSource, isEnum } from '@zenstackhq/sdk/ast';
import { DataModel, EnumField, Model, isDataModel, isEnum } from '@zenstackhq/sdk/ast';
import { addMissingInputObjectTypes, resolveAggregateOperationSupport } from '@zenstackhq/sdk/dmmf-helpers';
import { streamAllContents } from 'langium';
import path from 'path';
Expand Down Expand Up @@ -84,12 +83,6 @@ export class ZodSchemaGenerator {
prismaClientDmmf.schema.enumTypes.model ?? []
);

const dataSource = this.model.declarations.find((d): d is DataSource => isDataSource(d));

const dataSourceProvider = getLiteral<string>(
dataSource?.fields.find((f) => f.name === 'provider')?.value
) as ConnectorType;

await this.generateModelSchemas(output, excludeModels);

if (this.options.modelOnly) {
Expand All @@ -102,7 +95,6 @@ export class ZodSchemaGenerator {
);
} else {
// detailed object schemas referenced from input schemas
Transformer.provider = dataSourceProvider;
addMissingInputObjectTypes(inputObjectTypes, outputObjectTypes, models);
const aggregateOperationSupport = resolveAggregateOperationSupport(inputObjectTypes);
await this.generateObjectSchemas(inputObjectTypes, output);
Expand Down
19 changes: 9 additions & 10 deletions packages/schema/src/plugins/zod/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { DMMF, DMMF as PrismaDMMF } from '@prisma/generator-helper';
import { getPrismaClientImportSpec, getPrismaVersion, type PluginOptions } from '@zenstackhq/sdk';
import {
getPrismaClientImportSpec,
getPrismaVersion,
type PluginOptions,
type DMMF as PrismaDMMF,
} from '@zenstackhq/sdk';
import { checkModelHasModelRelation, findModelByName, isAggregateInputType } from '@zenstackhq/sdk/dmmf-helpers';
import { indentString } from '@zenstackhq/sdk/utils';
import path from 'path';
Expand All @@ -21,12 +25,11 @@ export default class Transformer {

static enumNames: string[] = [];
static rawOpsMap: { [name: string]: string } = {};
static provider: string;
private static outputPath = './generated';
private hasJson = false;
private hasDecimal = false;
private project: Project;
private inputObjectTypes: DMMF.InputType[];
private inputObjectTypes: PrismaDMMF.InputType[];
public sourceFiles: SourceFile[] = [];

constructor(params: TransformerParams) {
Expand Down Expand Up @@ -187,7 +190,7 @@ export default class Transformer {
wrapWithZodValidators(
mainValidators: string | string[],
field: PrismaDMMF.SchemaArg,
inputType: PrismaDMMF.SchemaArgInputType
inputType: PrismaDMMF.InputTypeRef
) {
let line = '';

Expand Down Expand Up @@ -217,11 +220,7 @@ export default class Transformer {
this.schemaImports.add(upperCaseFirst(name));
}

generatePrismaStringLine(
field: PrismaDMMF.SchemaArg,
inputType: PrismaDMMF.SchemaArgInputType,
inputsLength: number
) {
generatePrismaStringLine(field: PrismaDMMF.SchemaArg, inputType: PrismaDMMF.InputTypeRef, inputsLength: number) {
const isEnum = inputType.location === 'enumTypes';

const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputType.type as string);
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/src/plugins/zod/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DMMF, DMMF as PrismaDMMF } from '@prisma/generator-helper';
import type { DMMF as PrismaDMMF } from '@zenstackhq/sdk';
import { Project } from 'ts-morph';

export type TransformerParams = {
Expand All @@ -11,7 +11,7 @@ export type TransformerParams = {
isDefaultPrismaClientOutput?: boolean;
prismaClientOutputPath?: string;
project: Project;
inputObjectTypes: DMMF.InputType[];
inputObjectTypes: PrismaDMMF.InputType[];
};

export type AggregateOperationSupport = {
Expand Down
Loading

0 comments on commit 81c7e87

Please sign in to comment.