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
3 changes: 1 addition & 2 deletions packages/orm/package.json
Original file line number Diff line number Diff line change
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
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.14",
"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'],
});
10 changes: 0 additions & 10 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./schema": {
"import": {
"types": "./dist/schema.d.ts",
"default": "./dist/schema.js"
},
"require": {
"types": "./dist/schema.d.cts",
"default": "./dist/schema.cjs"
}
}
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { defineConfig } from 'tsup';
export default defineConfig({
entry: {
index: 'src/index.ts',
schema: 'src/schema/index.ts',
},
outDir: 'dist',
splitting: false,
Expand Down
1 change: 1 addition & 0 deletions packages/testtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dependencies": {
"@zenstackhq/common-helpers": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/orm": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"@zenstackhq/plugin-policy": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/testtools/src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { invariant } from '@zenstackhq/common-helpers';
import { TsSchemaGenerator } from '@zenstackhq/sdk';
import type { SchemaDef } from '@zenstackhq/sdk/schema';
import type { SchemaDef } from '@zenstackhq/schema';
import { execSync } from 'node:child_process';
import crypto from 'node:crypto';
import fs from 'node:fs';
Expand Down
28 changes: 22 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/e2e/orm/schemas/basic/helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DataSourceProviderType } from '@zenstackhq/sdk/schema';
import type { DataSourceProviderType } from '@zenstackhq/schema';
import { schema } from './schema';

export function getSchema<ProviderType extends DataSourceProviderType>(type: ProviderType) {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@paralleldrive/cuid2": "^2.2.2",
"@zenstackhq/cli": "workspace:*",
"@zenstackhq/language": "workspace:*",
"@zenstackhq/schema": "workspace:*",
"@zenstackhq/orm": "workspace:*",
"@zenstackhq/plugin-policy": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
Expand Down