Skip to content

Commit 39aad38

Browse files
committed
Merge branch 'dev' into feature/permission-checker
2 parents b53b05a + d7b75e9 commit 39aad38

File tree

16 files changed

+332
-220
lines changed

16 files changed

+332
-220
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Added
5+
- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`.
6+
### Fixed
7+
- Fixed several ZModel validation issues related to model inheritance.
48

9+
## 1.7.0
510
### Added
611
- Auto-completion is now supported inside attributes.

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.0.0-alpha.1"
12+
version = "1.9.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.0.0-alpha.1",
3+
"version": "1.9.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.0.0-alpha.1",
3+
"version": "1.9.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.0.0-alpha.1",
4+
"version": "1.9.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.0.0-alpha.1",
4+
"version": "1.9.0",
55
"description": "ZenStack plugin and runtime supporting OpenAPI",
66
"main": "index.js",
77
"repository": {

packages/plugins/tanstack-query/src/runtime/vue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function useModelQuery<TQueryFnData, TData, TError>(
6161
model: string,
6262
url: string,
6363
args?: unknown,
64-
options?: UseQueryOptions<TQueryFnData, TError, TData>,
64+
options?: Omit<UseQueryOptions<TQueryFnData, TError, TData>, 'queryKey'>,
6565
fetch?: FetchFn,
6666
optimisticUpdate = false
6767
) {
@@ -87,7 +87,7 @@ export function useInfiniteModelQuery<TQueryFnData, TData, TError>(
8787
model: string,
8888
url: string,
8989
args?: unknown,
90-
options?: UseInfiniteQueryOptions<TQueryFnData, TError, TData>,
90+
options?: Omit<UseInfiniteQueryOptions<TQueryFnData, TError, TData>, 'queryKey'>,
9191
fetch?: FetchFn
9292
) {
9393
return useInfiniteQuery<TQueryFnData, TError, TData>({

packages/schema/src/cli/actions/repl.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* eslint-disable @typescript-eslint/no-var-requires */
33
import colors from 'colors';
44
import path from 'path';
5-
import prettyRepl from 'pretty-repl';
65
import { inspect } from 'util';
76

87
// inspired by: https://github.com/Kinjalrk2k/prisma-console
@@ -11,6 +10,13 @@ import { inspect } from 'util';
1110
* CLI action for starting a REPL session
1211
*/
1312
export async function repl(projectPath: string, options: { prismaClient?: string; debug?: boolean; table?: boolean }) {
13+
if (!process?.stdout?.isTTY && process?.versions?.bun) {
14+
console.error('REPL on Bun is only available in a TTY terminal at this time. Please use npm/npx to run the command in this context instead of bun/bunx.');
15+
return;
16+
}
17+
18+
const prettyRepl = await import('pretty-repl')
19+
1420
console.log('Welcome to ZenStack REPL. See help with the ".help" command.');
1521
console.log('Global variables:');
1622
console.log(` ${colors.blue('db')} to access enhanced PrismaClient`);

packages/schema/src/language-server/validator/datamodel-validator.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
isDataModel,
66
isStringLiteral,
77
ReferenceExpr,
8+
isEnum,
89
} from '@zenstackhq/language/ast';
910
import { getLiteral, getModelIdFields, getModelUniqueFields, isDelegateModel } from '@zenstackhq/sdk';
1011
import { AstNode, DiagnosticInfo, getDocument, ValidationAcceptor } from 'langium';
@@ -61,8 +62,13 @@ export default class DataModelValidator implements AstValidator<DataModel> {
6162
if (idField.type.optional) {
6263
accept('error', 'Field with @id attribute must not be optional', { node: idField });
6364
}
64-
if (idField.type.array || !idField.type.type || !SCALAR_TYPES.includes(idField.type.type)) {
65-
accept('error', 'Field with @id attribute must be of scalar type', { node: idField });
65+
66+
const isArray = idField.type.array;
67+
const isScalar = SCALAR_TYPES.includes(idField.type.type as typeof SCALAR_TYPES[number])
68+
const isValidType = isScalar || isEnum(idField.type.reference?.ref)
69+
70+
if (isArray || !isValidType) {
71+
accept('error', 'Field with @id attribute must be of scalar or enum type', { node: idField });
6672
}
6773
});
6874
}

packages/schema/src/language-server/zmodel-linker.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,18 @@ export class ZModelLinker extends DefaultLinker {
470470
}
471471

472472
private resolveDataModel(node: DataModel, document: LangiumDocument<AstNode>, extraScopes: ScopeProvider[]) {
473+
if (node.superTypes.length > 0) {
474+
const superTypeProviders: ScopeProvider[] = [];
475+
// build scope providers for super types recursively with breadth-first search
476+
const queue = node.superTypes.map((t) => t.ref!);
477+
while (queue.length > 0) {
478+
const superType = queue.shift()!;
479+
const provider = (name: string) => superType.fields.find((f) => f.name === name);
480+
superTypeProviders.push(provider);
481+
queue.push(...superType.superTypes.map((t) => t.ref!));
482+
}
483+
extraScopes = [...superTypeProviders, ...extraScopes];
484+
}
473485
return this.resolveDefault(node, document, extraScopes);
474486
}
475487

0 commit comments

Comments
 (0)