Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/github-releases-to-discord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ jobs:
with:
webhook_url: ${{ secrets.RELEASE_TO_DISCORD_WEBHOOK_URL }}
avatar_url: 'https://cdn.discordapp.com/avatars/1297059323314176051/df91181b3f1cf0ef1592fbe18e0962d7.webp?size=160'
reduce_headings: true
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "2.15.1",
"version": "2.16.0",
"description": "",
"scripts": {
"build": "pnpm -r --filter=\"!./packages/ide/*\" build",
Expand Down Expand Up @@ -34,10 +34,8 @@
"eslint": "^8.57.0",
"eslint-plugin-jest": "^28.2.0",
"jest": "^29.7.0",
"replace-in-file": "^7.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsup": "^8.0.1",
"tsx": "^4.7.1",
"typescript": "^5.4.4"
Expand Down
4 changes: 2 additions & 2 deletions packages/ide/jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ changelog {
introduction.set(
"""
[ZenStack](https://zenstack.dev) is a toolkit that simplifies the development of a web app's backend. This plugin provides code editing experiences for its ZModel schema language.

## Features

- Syntax highlighting
- Error highlighting
- Go to definition
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.15.1",
"version": "2.16.0",
"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.15.1",
"version": "2.16.0",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
6 changes: 3 additions & 3 deletions packages/language/src/zmodel.langium
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Argument:
DataModel:
(comments+=TRIPLE_SLASH_COMMENT)*
(
((isAbstract?='abstract')? 'model' name=RegularID
((isAbstract?='abstract')? 'model' name=RegularID
('extends' superTypes+=[DataModel] (',' superTypes+=[DataModel])*)?) |
((isView?='view') name=RegularID)
)
Expand Down Expand Up @@ -193,7 +193,7 @@ TypeDef:
type TypeDefFieldTypes = TypeDef | Enum;

TypeDefField:
(comments+=TRIPLE_SLASH_COMMENT)*
(comments+=TRIPLE_SLASH_COMMENT)*
name=RegularIDWithTypeNames type=TypeDefFieldType (attributes+=DataModelFieldAttribute)*;

TypeDefFieldType:
Expand All @@ -208,7 +208,7 @@ Enum:
'enum' name=RegularID '{' (
fields+=EnumField
| attributes+=DataModelAttribute
)+
)+
'}';

EnumField:
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.15.1",
"version": "2.16.0",
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
"repository": {
"type": "git",
Expand Down
8 changes: 2 additions & 6 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.15.1",
"version": "2.16.0",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand All @@ -28,15 +28,11 @@
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"lower-case-first": "^2.0.2",
"openapi-types": "^12.1.0",
"semver": "^7.5.2",
"tiny-invariant": "^1.3.1",
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2",
"yaml": "^2.2.2",
"zod": "^3.22.4",
"zod": "^3.22.4",
"zod-validation-error": "^1.5.0"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import {
TypeDefFieldType,
} from '@zenstackhq/sdk/ast';
import type { DMMF } from '@zenstackhq/sdk/prisma';
import { invariant, lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
import path from 'path';
import pluralize from 'pluralize';
import invariant from 'tiny-invariant';
import { match, P } from 'ts-pattern';
import YAML from 'yaml';
import { name } from '.';
Expand Down
4 changes: 1 addition & 3 deletions packages/plugins/openapi/src/rpc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import {
resolveAggregateOperationSupport,
} from '@zenstackhq/sdk/dmmf-helpers';
import { supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { lowerCaseFirst, upperCaseFirst, invariant } from '@zenstackhq/runtime/local-helpers';
import * as fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
import * as path from 'path';
import invariant from 'tiny-invariant';
import { P, match } from 'ts-pattern';
import { upperCaseFirst } from 'upper-case-first';
import YAML from 'yaml';
import { name } from '.';
import { OpenAPIGeneratorBase } from './generator-base';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
- name: post_Item
description: Post-related operations
- name: postLike
description: PostLike operations
description: PostLike operations
paths:
/user:
get:
Expand Down
7 changes: 2 additions & 5 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.15.1",
"version": "2.16.0",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -40,13 +40,10 @@
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"cross-fetch": "^4.0.0",
"lower-case-first": "^2.0.2",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2"
"ts-pattern": "^4.3.0"
},
"peerDependencies": {
"swr": "2.2.5 - 2"
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/swr/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import {
} from '@zenstackhq/sdk';
import { DataModel, DataModelFieldType, Model, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { paramCase } from 'change-case';
import { upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';
import path from 'path';
import type { OptionalKind, ParameterDeclarationStructure, Project, SourceFile } from 'ts-morph';
import { P, match } from 'ts-pattern';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '.';

export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type ModelMeta,
type PrismaWriteActionType,
} from '@zenstackhq/runtime/cross';
import { lowerCaseFirst } from 'lower-case-first';
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import { createContext, useContext } from 'react';
import type { Cache, Fetcher, SWRConfiguration, SWRResponse } from 'swr';
import useSWR, { useSWRConfig } from 'swr';
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/tests/react-hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// <reference types="@types/jest" />

import { renderHook, waitFor } from '@testing-library/react';
import { lowerCaseFirst } from 'lower-case-first';
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import nock from 'nock';
import { SWRConfig, useSWRConfig } from 'swr';
import {
Expand Down
9 changes: 3 additions & 6 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.15.1",
"version": "2.16.0",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"exports": {
Expand Down Expand Up @@ -82,13 +82,10 @@
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"cross-fetch": "^4.0.0",
"lower-case-first": "^2.0.2",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2"
"ts-pattern": "^4.3.0"
},
"devDependencies": {
"@tanstack/react-query": "^4.29.7",
Expand All @@ -101,11 +98,11 @@
"@types/semver": "^7.3.13",
"@types/tmp": "^0.2.3",
"@zenstackhq/testtools": "workspace:*",
"glob": "^8.1.0",
"jest-environment-jsdom": "^29.7.0",
"nock": "^13.3.6",
"react": "18.2.0",
"react-test-renderer": "^18.2.0",
"replace-in-file": "^7.0.1",
"svelte": "^4.2.1",
"swr": "^2.0.3",
"tmp": "^0.2.3",
Expand Down
33 changes: 24 additions & 9 deletions packages/plugins/tanstack-query/scripts/postbuild.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
// tsup doesn't replace npm dependency aliases in the dist files, so we have to do it manually

const replace = require('replace-in-file');
const fs = require('fs');
const glob = require('glob');

function replaceSync({ file, from, to }) {
const paths = glob.sync(file, { ignore: [], nodir: true });

paths.forEach(path => {
const contents = fs.readFileSync(path, { encoding: 'utf-8' });

const newContents = contents.replace(from, to);

if (newContents !== contents) {
fs.writeFileSync(path, newContents, { encoding: 'utf-8' });
}
});
}

// tsup incorrectly resolve to legacy types, make a fix here
console.log('Replacing @tanstack/react-query-v5/build/legacy/types');
replace.sync({
files: 'dist/runtime-v5/react*(.d.ts|.d.mts)',
replaceSync({
file: 'dist/runtime-v5/react*(.d.ts|.d.mts)',
from: /@tanstack\/react-query-v5\/build\/legacy\/types/g,
to: '@tanstack/react-query',
});

console.log('Replacing @tanstack/react-query-v5');
replace.sync({
files: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
replaceSync({
file: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
from: /@tanstack\/react-query-v5/g,
to: '@tanstack/react-query',
});

console.log('Replacing @tanstack/svelte-query-v5');
replace.sync({
files: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
replaceSync({
file: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
from: /@tanstack\/svelte-query-v5/g,
to: '@tanstack/svelte-query',
});

console.log('Replacing @tanstack/vue-query-v5');
replace.sync({
files: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
replaceSync({
file: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
from: /@tanstack\/vue-query-v5/g,
to: '@tanstack/vue-query',
});
15 changes: 9 additions & 6 deletions packages/plugins/tanstack-query/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import {
ensureEmptyDir,
generateModelMeta,
getDataModels,
getPrismaClientGenerator,
isDelegateModel,
requireOption,
resolvePath,
saveProject,
} from '@zenstackhq/sdk';
import { DataModel, DataModelFieldType, Model, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { paramCase } from 'change-case';
import { lowerCaseFirst, upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';
import fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import path from 'path';
import { Project, SourceFile, VariableDeclarationKind } from 'ts-morph';
import { P, match } from 'ts-pattern';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '.';

const supportedTargets = ['react', 'vue', 'svelte'];
Expand Down Expand Up @@ -52,7 +51,6 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
`Invalid value for "portable" option: ${options.portable}, a boolean value is expected`
);
}
const portable = options.portable ?? false;

await generateModelMeta(project, models, typeDefs, {
output: path.join(outDir, '__model_meta.ts'),
Expand All @@ -70,8 +68,13 @@ export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.
generateModelHooks(target, version, project, outDir, dataModel, mapping, options);
});

if (portable) {
generateBundledTypes(project, outDir, options);
if (options.portable) {
const gen = getPrismaClientGenerator(model);
if (gen?.isNewGenerator) {
warnings.push(`The "portable" option is not supported with the "prisma-client" generator and is ignored.`);
} else {
generateBundledTypes(project, outDir, options);
}
}

await saveProject(project);
Expand Down
10 changes: 4 additions & 6 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.15.1",
"version": "2.16.0",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand All @@ -26,15 +26,13 @@
"author": "ZenStack Team",
"license": "MIT",
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"lower-case-first": "^2.0.2",
"ts-morph": "^16.0.0",
"tslib": "^2.4.1",
"upper-case-first": "^2.0.2"
"tslib": "^2.4.1"
},
"peerDependencies": {
"zod": "^3.22.4"
"zod": "^3.22.4"
},
"devDependencies": {
"@trpc/next": "^10.32.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/trpc/src/client-helper/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginError, type PluginOptions } from '@zenstackhq/sdk';
import { getPrismaClientImportSpec } from '@zenstackhq/sdk/prisma';
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
import fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import path from 'path';
import {
InterfaceDeclarationStructure,
Expand All @@ -10,7 +10,6 @@ import {
SourceFile,
StructureKind,
} from 'ts-morph';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '..';
import { SupportedClientHelpers } from '../utils';
import * as NextHelpers from './next';
Expand Down
Loading
Loading