@zenstackhq/plugin-policy 3.0.0-beta.12 → 3.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +67 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as kysely from 'kysely';
|
|
2
|
-
import * as
|
|
3
|
-
import { RuntimePlugin, OnKyselyQueryArgs } from '@zenstackhq/
|
|
4
|
-
import { SchemaDef } from '@zenstackhq/
|
|
2
|
+
import * as _zenstackhq_orm from '@zenstackhq/orm';
|
|
3
|
+
import { RuntimePlugin, OnKyselyQueryArgs } from '@zenstackhq/orm';
|
|
4
|
+
import { SchemaDef } from '@zenstackhq/orm/schema';
|
|
5
5
|
|
|
6
6
|
declare class PolicyPlugin<Schema extends SchemaDef> implements RuntimePlugin<Schema> {
|
|
7
7
|
get id(): string;
|
|
8
8
|
get name(): string;
|
|
9
9
|
get description(): string;
|
|
10
10
|
get functions(): {
|
|
11
|
-
check:
|
|
11
|
+
check: _zenstackhq_orm.ZModelFunction<any>;
|
|
12
12
|
};
|
|
13
13
|
onKyselyQuery({ query, client, proceed }: OnKyselyQueryArgs<Schema>): Promise<kysely.QueryResult<any>>;
|
|
14
14
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as kysely from 'kysely';
|
|
2
|
-
import * as
|
|
3
|
-
import { RuntimePlugin, OnKyselyQueryArgs } from '@zenstackhq/
|
|
4
|
-
import { SchemaDef } from '@zenstackhq/
|
|
2
|
+
import * as _zenstackhq_orm from '@zenstackhq/orm';
|
|
3
|
+
import { RuntimePlugin, OnKyselyQueryArgs } from '@zenstackhq/orm';
|
|
4
|
+
import { SchemaDef } from '@zenstackhq/orm/schema';
|
|
5
5
|
|
|
6
6
|
declare class PolicyPlugin<Schema extends SchemaDef> implements RuntimePlugin<Schema> {
|
|
7
7
|
get id(): string;
|
|
8
8
|
get name(): string;
|
|
9
9
|
get description(): string;
|
|
10
10
|
get functions(): {
|
|
11
|
-
check:
|
|
11
|
+
check: _zenstackhq_orm.ZModelFunction<any>;
|
|
12
12
|
};
|
|
13
13
|
onKyselyQuery({ query, client, proceed }: OnKyselyQueryArgs<Schema>): Promise<kysely.QueryResult<any>>;
|
|
14
14
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,18 +3,18 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/functions.ts
|
|
5
5
|
import { invariant as invariant4 } from "@zenstackhq/common-helpers";
|
|
6
|
-
import { CRUD, QueryUtils as QueryUtils3 } from "@zenstackhq/
|
|
6
|
+
import { CRUD, QueryUtils as QueryUtils3 } from "@zenstackhq/orm";
|
|
7
7
|
import { ExpressionWrapper as ExpressionWrapper2, ValueNode as ValueNode4 } from "kysely";
|
|
8
8
|
|
|
9
9
|
// src/policy-handler.ts
|
|
10
10
|
import { invariant as invariant3 } from "@zenstackhq/common-helpers";
|
|
11
|
-
import { getCrudDialect as getCrudDialect2, InternalError as InternalError2, QueryError as QueryError2, QueryUtils as QueryUtils2, RejectedByPolicyError, RejectedByPolicyReason, SchemaUtils } from "@zenstackhq/
|
|
12
|
-
import { ExpressionUtils as ExpressionUtils4 } from "@zenstackhq/
|
|
11
|
+
import { getCrudDialect as getCrudDialect2, InternalError as InternalError2, QueryError as QueryError2, QueryUtils as QueryUtils2, RejectedByPolicyError, RejectedByPolicyReason, SchemaUtils } from "@zenstackhq/orm";
|
|
12
|
+
import { ExpressionUtils as ExpressionUtils4 } from "@zenstackhq/orm/schema";
|
|
13
13
|
import { AliasNode as AliasNode3, BinaryOperationNode as BinaryOperationNode3, ColumnNode as ColumnNode2, DeleteQueryNode, expressionBuilder as expressionBuilder2, ExpressionWrapper, FromNode as FromNode2, FunctionNode as FunctionNode3, IdentifierNode as IdentifierNode2, InsertQueryNode, OperationNodeTransformer, OperatorNode as OperatorNode3, ParensNode as ParensNode2, PrimitiveValueListNode, RawNode, ReferenceNode as ReferenceNode3, ReturningNode, SelectAllNode, SelectionNode as SelectionNode2, SelectQueryNode as SelectQueryNode2, sql, TableNode as TableNode3, UpdateQueryNode, ValueListNode as ValueListNode2, ValueNode as ValueNode3, ValuesNode, WhereNode as WhereNode2 } from "kysely";
|
|
14
14
|
import { match as match3 } from "ts-pattern";
|
|
15
15
|
|
|
16
16
|
// src/column-collector.ts
|
|
17
|
-
import { KyselyUtils } from "@zenstackhq/
|
|
17
|
+
import { KyselyUtils } from "@zenstackhq/orm";
|
|
18
18
|
var ColumnCollector = class extends KyselyUtils.DefaultOperationNodeVisitor {
|
|
19
19
|
static {
|
|
20
20
|
__name(this, "ColumnCollector");
|
|
@@ -34,15 +34,15 @@ var ColumnCollector = class extends KyselyUtils.DefaultOperationNodeVisitor {
|
|
|
34
34
|
|
|
35
35
|
// src/expression-transformer.ts
|
|
36
36
|
import { invariant as invariant2 } from "@zenstackhq/common-helpers";
|
|
37
|
-
import { getCrudDialect, InternalError, QueryError, QueryUtils } from "@zenstackhq/
|
|
38
|
-
import { ExpressionUtils as ExpressionUtils3 } from "@zenstackhq/
|
|
37
|
+
import { getCrudDialect, InternalError, QueryError, QueryUtils } from "@zenstackhq/orm";
|
|
38
|
+
import { ExpressionUtils as ExpressionUtils3 } from "@zenstackhq/orm/schema";
|
|
39
39
|
import { AliasNode as AliasNode2, BinaryOperationNode as BinaryOperationNode2, ColumnNode, expressionBuilder, FromNode, FunctionNode as FunctionNode2, IdentifierNode, OperatorNode as OperatorNode2, ReferenceNode as ReferenceNode2, SelectionNode, SelectQueryNode, TableNode as TableNode2, ValueListNode, ValueNode as ValueNode2, WhereNode } from "kysely";
|
|
40
40
|
import { match as match2 } from "ts-pattern";
|
|
41
41
|
|
|
42
42
|
// src/expression-evaluator.ts
|
|
43
43
|
import { invariant } from "@zenstackhq/common-helpers";
|
|
44
44
|
import { match } from "ts-pattern";
|
|
45
|
-
import { ExpressionUtils } from "@zenstackhq/
|
|
45
|
+
import { ExpressionUtils } from "@zenstackhq/orm/schema";
|
|
46
46
|
var ExpressionEvaluator = class {
|
|
47
47
|
static {
|
|
48
48
|
__name(this, "ExpressionEvaluator");
|
|
@@ -111,7 +111,7 @@ var ExpressionEvaluator = class {
|
|
|
111
111
|
};
|
|
112
112
|
|
|
113
113
|
// src/utils.ts
|
|
114
|
-
import { ExpressionUtils as ExpressionUtils2 } from "@zenstackhq/
|
|
114
|
+
import { ExpressionUtils as ExpressionUtils2 } from "@zenstackhq/orm/schema";
|
|
115
115
|
import { AliasNode, AndNode, BinaryOperationNode, FunctionNode, OperatorNode, OrNode, ParensNode, ReferenceNode, TableNode, UnaryOperationNode, ValueNode } from "kysely";
|
|
116
116
|
function trueNode(dialect) {
|
|
117
117
|
return ValueNode.createImmediate(dialect.transformPrimitive(true, "Boolean", false));
|
|
@@ -813,7 +813,7 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
813
813
|
if (constCondition === true) {
|
|
814
814
|
needCheckPreCreate = false;
|
|
815
815
|
} else if (constCondition === false) {
|
|
816
|
-
throw new RejectedByPolicyError(mutationModel);
|
|
816
|
+
throw new RejectedByPolicyError(mutationModel, RejectedByPolicyReason.NO_ACCESS);
|
|
817
817
|
}
|
|
818
818
|
}
|
|
819
819
|
if (needCheckPreCreate) {
|
|
@@ -1176,7 +1176,7 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
1176
1176
|
};
|
|
1177
1177
|
const result = await proceed(preCreateCheck);
|
|
1178
1178
|
if (!result.rows[0]?.$condition) {
|
|
1179
|
-
throw new RejectedByPolicyError(model);
|
|
1179
|
+
throw new RejectedByPolicyError(model, RejectedByPolicyReason.NO_ACCESS);
|
|
1180
1180
|
}
|
|
1181
1181
|
}
|
|
1182
1182
|
unwrapCreateValueRows(node, model, fields, isManyToManyJoinTable) {
|