Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/dist/**
22 changes: 22 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"error",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
}
77 changes: 77 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI

on:
pull_request:
branches:
- main
- dev

permissions:
contents: read

jobs:
build-test:
runs-on: buildjet-8vcpu-ubuntu-2204

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: abc123
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.1

- name: Use Node.js ${{ matrix.node-version }}
uses: buildjet/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: buildjet/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build
run: pnpm run build

- name: Lint
run: pnpm run lint

# install again for internal dependencies
- name: Install internal dependencies
run: pnpm install --frozen-lockfile

- name: Test
run: pnpm run test
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
"name": "zenstack-v3",
"version": "3.0.0-alpha.1",
"description": "ZenStack",
"packageManager": "pnpm@10.0.0",
"packageManager": "pnpm@10.12.1",
"scripts": {
"build": "pnpm -r build",
"watch": "pnpm -r --parallel watch",
"lint": "pnpm -r lint",
"test": "pnpm vitest"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@swc/core": "^1.10.15",
"eslint": "~8.57.1",
"npm-run-all": "^4.1.5",
"tsup": "^8.3.5",
"tsx": "^4.19.2",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"scripts": {
"build": "tsup-node",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"test": "vitest",
"pack": "pnpm pack"
},
Expand Down
13 changes: 0 additions & 13 deletions packages/language/.eslintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/language/src/validators/expression-validator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { AstUtils, type AstNode, type ValidationAcceptor } from 'langium';
import {
BinaryExpr,
DataModelAttribute,
Expression,
isArrayExpr,
isDataModel,
isDataModelAttribute,
isDataModelField,
isEnum,
isLiteralExpr,
isMemberAccessExpr,
Expand All @@ -18,7 +16,6 @@ import {

import {
findUpAst,
getAttributeArgLiteral,
isAuthInvocation,
isAuthOrAuthMemberAccess,
isDataModelFieldReference,
Expand Down
4 changes: 1 addition & 3 deletions packages/language/src/validators/schema-validator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { LangiumDocuments, ValidationAcceptor } from 'langium';
import { PLUGIN_MODULE_NAME, STD_LIB_MODULE_NAME } from '../constants';
import { isDataModel, isDataSource, type Model } from '../generated/ast';
import { isDataSource, type Model } from '../generated/ast';
import {
getAllDeclarationsIncludingImports,
getDataModelAndTypeDefs,
hasAttribute,
resolveImport,
resolveTransitiveImports,
} from '../utils';
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "tsup-node && pnpm test-typecheck",
"test-typecheck": "tsc --project tsconfig.test.json",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"test": "vitest",
"pack": "pnpm pack"
},
Expand Down Expand Up @@ -85,6 +86,7 @@
"dependencies": {
"@paralleldrive/cuid2": "^2.2.2",
"decimal.js": "^10.4.3",
"is-plain-object": "^5.0.0",
"kysely": "^0.27.5",
"nanoid": "^5.0.9",
"pg-connection-string": "^2.9.0",
Expand Down Expand Up @@ -112,8 +114,8 @@
"@types/pg": "^8.0.0",
"@types/tmp": "^0.2.6",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/testtools": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"@zenstackhq/testtools": "workspace:*",
"tmp": "^0.2.3"
}
}
1 change: 1 addition & 0 deletions packages/runtime/src/client/client-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class ClientImpl<Schema extends SchemaDef> {
);
}

// eslint-disable-next-line @typescript-eslint/ban-types
return (procOptions[name] as Function).apply(this, [this, ...args]);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/runtime/src/client/contract.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/ban-types */

import type { Decimal } from 'decimal.js';
import {
type AuthType,
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime/src/client/crud-types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/ban-types */

import type { ExpressionBuilder, OperandExpression, SqlBool } from 'kysely';
import type { Optional } from 'utility-types';
import type {
Expand Down
11 changes: 6 additions & 5 deletions packages/runtime/src/client/crud/dialects/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import type {
FieldDef,
} from '../../../schema/schema';
import { enumerate } from '../../../utils/enumerate';
import { isPlainObject } from '../../../utils/is-plain-object';
// @ts-expect-error
import { isPlainObject } from 'is-plain-object';
import type { OrArray } from '../../../utils/type-utils';
import type {
BooleanFilter,
Expand Down Expand Up @@ -54,12 +55,12 @@ export abstract class BaseCrudDialect<Schema extends SchemaDef> {
}

abstract buildRelationSelection(
query: SelectQueryBuilder<any, any, {}>,
query: SelectQueryBuilder<any, any, any>,
model: string,
relationField: string,
parentAlias: string,
payload: true | FindArgs<Schema, GetModels<Schema>, true>
): SelectQueryBuilder<any, any, {}>;
): SelectQueryBuilder<any, any, any>;

abstract buildSkipTake(
query: SelectQueryBuilder<any, any, any>,
Expand All @@ -82,7 +83,7 @@ export abstract class BaseCrudDialect<Schema extends SchemaDef> {
}

let result = this.true(eb);
let _where = flattenCompoundUniqueFilters(this.schema, model, where);
const _where = flattenCompoundUniqueFilters(this.schema, model, where);

for (const [key, payload] of Object.entries(_where)) {
if (payload === undefined) {
Expand Down Expand Up @@ -284,7 +285,7 @@ export abstract class BaseCrudDialect<Schema extends SchemaDef> {
)
.select(() => eb.fn.count(eb.lit(1)).as(filterResultField));

let conditions: Expression<SqlBool>[] = [];
const conditions: Expression<SqlBool>[] = [];

if ('is' in payload || 'isNot' in payload) {
if ('is' in payload) {
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/client/crud/dialects/postgresql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export class PostgresCrudDialect<
}

override buildRelationSelection(
query: SelectQueryBuilder<any, any, {}>,
query: SelectQueryBuilder<any, any, any>,
model: string,
relationField: string,
parentAlias: string,
payload: true | FindArgs<Schema, GetModels<Schema>, true>
): SelectQueryBuilder<any, any, {}> {
): SelectQueryBuilder<any, any, any> {
const joinedQuery = this.buildRelationJSON(
model,
query,
Expand Down Expand Up @@ -261,7 +261,7 @@ export class PostgresCrudDialect<
const objArgs: Array<
| string
| ExpressionWrapper<any, any, any>
| SelectQueryBuilder<any, any, {}>
| SelectQueryBuilder<any, any, any>
| RawBuilder<any>
> = [];

Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/src/client/crud/dialects/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export class SqliteCrudDialect<
}

override buildRelationSelection(
query: SelectQueryBuilder<any, any, {}>,
query: SelectQueryBuilder<any, any, any>,
model: string,
relationField: string,
parentAlias: string,
payload: true | FindArgs<Schema, GetModels<Schema>, true>
): SelectQueryBuilder<any, any, {}> {
): SelectQueryBuilder<any, any, any> {
return query.select((eb) =>
this.buildRelationJSON(
model,
Expand Down Expand Up @@ -184,7 +184,7 @@ export class SqliteCrudDialect<
type ArgsType =
| Expression<any>
| RawBuilder<any>
| SelectQueryBuilder<any, any, {}>;
| SelectQueryBuilder<any, any, any>;
const objArgs: ArgsType[] = [];

if (payload === true || !payload.select) {
Expand Down
Loading
Loading