Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.
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
2 changes: 2 additions & 0 deletions packages/orm/src/client/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export type ClientOptions<Schema extends SchemaDef> = {

/**
* Custom function definitions.
*
* @private
*/
functions?: Record<string, ZModelFunction<Schema>>;

Expand Down
10 changes: 5 additions & 5 deletions packages/orm/src/client/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { ClientContract } from '.';
import type { GetModels, SchemaDef } from '../schema';
import type { MaybePromise } from '../utils/type-utils';
import type { AllCrudOperation } from './crud/operations/base';
import type { ZModelFunction } from './options';

/**
* ZenStack runtime plugin.
Expand All @@ -24,10 +23,11 @@ export interface RuntimePlugin<Schema extends SchemaDef = SchemaDef> {
*/
description?: string;

/**
* Custom function implementations.
*/
functions?: Record<string, ZModelFunction<Schema>>;
// TODO: revisit later
// /**
// * Custom function implementations.
// */
// functions?: Record<string, ZModelFunction<Schema>>;
Comment thread
ymc9 marked this conversation as resolved.
Outdated

Comment thread
ymc9 marked this conversation as resolved.
Outdated
/**
* Intercepts an ORM query.
Expand Down
26 changes: 14 additions & 12 deletions packages/plugins/policy/src/expression-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,20 @@ export class ExpressionTransformer<Schema extends SchemaDef> {
}

private getFunctionImpl(functionName: string) {
// check built-in functions
let func = this.clientOptions.functions?.[functionName];
if (!func) {
// check plugins
for (const plugin of this.clientOptions.plugins ?? []) {
if (plugin.functions?.[functionName]) {
func = plugin.functions[functionName];
break;
}
}
}
return func;
return this.clientOptions.functions?.[functionName];
// TODO: revisit later
// // check built-in functions
// let func = this.clientOptions.functions?.[functionName];
// if (!func) {
// // check plugins
// for (const plugin of this.clientOptions.plugins ?? []) {
// if (plugin.functions?.[functionName]) {
// func = plugin.functions[functionName];
// break;
// }
// }
// }
// return func;
}

private transformCallArg(
Expand Down
10 changes: 10 additions & 0 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./ast": {
"import": {
"types": "./dist/ast.d.ts",
"default": "./dist/ast.js"
},
"require": {
"types": "./dist/ast.d.cts",
"default": "./dist/ast.cjs"
}
}
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/ast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '@zenstackhq/language/ast';
1 change: 1 addition & 0 deletions packages/sdk/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'tsup';
export default defineConfig({
entry: {
index: 'src/index.ts',
ast: 'src/ast.ts',
},
outDir: 'dist',
splitting: false,
Expand Down
Loading