Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
115 changes: 115 additions & 0 deletions .github/workflows/update-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Update Sample Repos

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

jobs:
update-samples:
runs-on: ubuntu-latest
outputs:
repos: ${{ steps.get-repos.outputs.repos }}

steps:
- name: Get all public repos with v3-sample topic in @zenstackhq org
id: get-repos
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
# Get all public repos from the zenstackhq org with v3-sample topic
REPOS=$(gh repo list zenstackhq --json name,isPrivate,nameWithOwner,repositoryTopics --limit 100 | \
jq -r '.[] | select(.isPrivate == false) | select((.repositoryTopics // []) | map(.name) | contains(["v3-sample"])) | .nameWithOwner')

echo "Found repos with v3-sample topic:"
echo "$REPOS"

# Convert to JSON array for matrix
REPOS_JSON=$(echo "$REPOS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "repos=$REPOS_JSON" >> $GITHUB_OUTPUT

- name: Display repos to update
run: |
echo "Will update the following repos:"
echo '${{ steps.get-repos.outputs.repos }}' | jq -r '.[]'

update-repo:
needs: update-samples
runs-on: ubuntu-latest
if: ${{ needs.update-samples.outputs.repos != '[]' }}
strategy:
matrix:
repo: ${{ fromJson(needs.update-samples.outputs.repos) }}
fail-fast: false

steps:
- name: Checkout target repo
uses: actions/checkout@v4
with:
repository: ${{ matrix.repo }}
token: ${{ secrets.PAT_TOKEN }}

- name: Check if package.json exists
id: check-package
run: |
if [ -f "package.json" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Use Node.js
if: steps.check-package.outputs.exists == 'true'
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: Update @zenstackhq packages to next
if: steps.check-package.outputs.exists == 'true'
run: |
# Get all @zenstackhq packages in the repo
PACKAGES=$(cat package.json | jq -r '
[.dependencies, .devDependencies] |
add |
to_entries |
map(select(.key | startswith("@zenstackhq/"))) |
map(.key) |
.[]
')

if [ -z "$PACKAGES" ]; then
echo "No @zenstackhq packages found in ${{ matrix.repo }}"
exit 0
fi

echo "Updating packages in ${{ matrix.repo }}:"
echo "$PACKAGES"

# Update each package to next tag
for pkg in $PACKAGES; do
echo "Updating $pkg to next"
npm install "$pkg@next"
done

# Finally run zenstack generate
npx zen generate

- name: Commit and push changes
if: steps.check-package.outputs.exists == 'true'
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "[email protected]"

# Check if there are changes to commit
if git diff --quiet && git diff --staged --quiet; then
echo "No changes to commit"
exit 0
fi

git add .
git commit -m "chore: update @zenstackhq packages to next release"
git push
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-v3",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"description": "ZenStack",
"packageManager": "[email protected]",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "zenstack",
"displayName": "ZenStack CLI",
"description": "FullStack database toolkit with built-in access control and automatic API generation.",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"type": "module",
"author": {
"name": "ZenStack Team"
Expand Down
2 changes: 1 addition & 1 deletion packages/common-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/common-helpers",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"description": "ZenStack Common Helpers",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/config/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/eslint-config",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"type": "module",
"private": true,
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/config/typescript-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/typescript-config",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"private": true,
"license": "MIT"
}
2 changes: 1 addition & 1 deletion packages/config/vitest-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/vitest-config",
"type": "module",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"private": true,
"license": "MIT",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-zenstack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-zenstack",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"description": "Create a new ZenStack project",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dialects/sql.js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/kysely-sql-js",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"description": "Kysely dialect for sql.js",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/language",
"description": "ZenStack ZModel language specification",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"license": "MIT",
"author": "ZenStack Team",
"files": [
Expand Down
5 changes: 2 additions & 3 deletions packages/orm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/orm",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"description": "ZenStack ORM",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -63,6 +63,7 @@
},
"dependencies": {
"@paralleldrive/cuid2": "^2.2.2",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/common-helpers": "workspace:*",
"decimal.js": "catalog:",
"json-stable-stringify": "^1.3.0",
Expand Down Expand Up @@ -92,8 +93,6 @@
"@types/pg": "^8.0.0",
"@types/toposort": "^2.0.7",
"@zenstackhq/eslint-config": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"@zenstackhq/typescript-config": "workspace:*",
"@zenstackhq/vitest-config": "workspace:*",
"tsx": "^4.19.2",
Expand Down
9 changes: 7 additions & 2 deletions packages/orm/src/client/client-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ import {
type KyselyProps,
} from 'kysely';
import type { GetModels, ProcedureDef, SchemaDef } from '../schema';
import type { AuthType } from '../schema/auth';
import type { UnwrapTuplePromises } from '../utils/type-utils';
import type { ClientConstructor, ClientContract, ModelOperations, TransactionIsolationLevel } from './contract';
import type {
AuthType,
ClientConstructor,
ClientContract,
ModelOperations,
TransactionIsolationLevel,
} from './contract';
import { AggregateOperationHandler } from './crud/operations/aggregate';
import type { AllCrudOperation, CoreCrudOperation } from './crud/operations/base';
import { BaseOperationHandler } from './crud/operations/base';
Expand Down
12 changes: 11 additions & 1 deletion packages/orm/src/client/contract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type Decimal from 'decimal.js';
import { type GetModels, type IsDelegateModel, type ProcedureDef, type SchemaDef } from '../schema';
import type { AuthType } from '../schema/auth';
import type { OrUndefinedIf, Simplify, UnwrapTuplePromises } from '../utils/type-utils';
import type { TRANSACTION_UNSUPPORTED_METHODS } from './constants';
import type {
Expand Down Expand Up @@ -803,3 +802,14 @@ export type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Sc
>;

//#endregion

//#region Supporting types

export type AuthType<Schema extends SchemaDef> =
string extends GetModels<Schema>
? Record<string, unknown>
: Schema['authType'] extends GetModels<Schema>
? Partial<ModelResult<Schema, Schema['authType']>>
: never;

//#endregion
2 changes: 1 addition & 1 deletion packages/orm/src/client/crud/validator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
FieldExpression,
MemberExpression,
UnaryExpression,
} from '@zenstackhq/sdk/schema';
} from '@zenstackhq/schema';
import Decimal from 'decimal.js';
import { match, P } from 'ts-pattern';
import { z } from 'zod';
Expand Down
2 changes: 2 additions & 0 deletions packages/orm/src/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from '@zenstackhq/schema';
export type { OperandExpression } from 'kysely';
9 changes: 0 additions & 9 deletions packages/orm/src/schema/auth.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/orm/src/schema/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/orm/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'tsup';
export default defineConfig({
entry: {
index: 'src/index.ts',
schema: 'src/schema/index.ts',
schema: 'src/schema.ts',
helpers: 'src/helpers.ts',
},
outDir: 'dist',
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/policy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/plugin-policy",
"version": "3.0.0-beta.14",
"version": "3.0.0-beta.15",
"description": "ZenStack Policy Plugin",
"type": "module",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions packages/schema/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import config from '@zenstackhq/eslint-config/base.js';

/** @type {import("eslint").Linter.Config} */
export default config;
37 changes: 37 additions & 0 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@zenstackhq/schema",
"version": "3.0.0-beta.15",
"description": "ZenStack Runtime Schema",
"type": "module",
"scripts": {
"build": "tsc --noEmit && tsup-node",
"watch": "tsup-node --watch",
"lint": "eslint src --ext ts",
"pack": "pnpm pack"
},
"keywords": [],
"author": "ZenStack Team",
"license": "MIT",
"files": [
"dist"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
}
},
"dependencies": {
"decimal.js": "catalog:"
},
"devDependencies": {
"@zenstackhq/eslint-config": "workspace:*",
"@zenstackhq/typescript-config": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import type {
ThisExpression,
UnaryExpression,
UnaryOperator,
} from '.';
} from './expression';

/**
* Utility functions to create and work with Expression objects
*/
export const ExpressionUtils = {
literal: (value: string | number | boolean): LiteralExpression => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export type * from './expression';
export * from './expression-utils';
export type * from './schema';

export type { OperandExpression } from 'kysely';
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/schema/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@zenstackhq/typescript-config/base.json",
"compilerOptions": {
"noUnusedLocals": false
},
"include": ["src/**/*.ts"]
}
13 changes: 13 additions & 0 deletions packages/schema/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: {
index: 'src/index.ts',
},
outDir: 'dist',
splitting: false,
sourcemap: true,
clean: true,
dts: true,
format: ['cjs', 'esm'],
});
Loading