@zenstackhq/plugin-policy 3.0.0-beta.30 → 3.0.0-beta.31
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 +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -911,6 +911,7 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
911
911
|
return proceed(this.transformNode(node));
|
|
912
912
|
}
|
|
913
913
|
const { mutationModel } = this.getMutationModel(node);
|
|
914
|
+
this.tryRejectNonexistentModel(mutationModel);
|
|
914
915
|
if (InsertQueryNode.is(node)) {
|
|
915
916
|
const isManyToManyJoinTable = this.isManyToManyJoinTable(mutationModel);
|
|
916
917
|
let needCheckPreCreate = true;
|
|
@@ -1077,6 +1078,7 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
1077
1078
|
if (!table) {
|
|
1078
1079
|
return super.transformJoin(node);
|
|
1079
1080
|
}
|
|
1081
|
+
this.tryRejectNonexistentModel(table.model);
|
|
1080
1082
|
const filter = this.buildPolicyFilter(table.model, table.alias, "read");
|
|
1081
1083
|
const nestedSelect = {
|
|
1082
1084
|
kind: "SelectQueryNode",
|
|
@@ -1469,6 +1471,7 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
1469
1471
|
const extractResult = this.extractTableName(table);
|
|
1470
1472
|
if (extractResult) {
|
|
1471
1473
|
const { model, alias } = extractResult;
|
|
1474
|
+
this.tryRejectNonexistentModel(model);
|
|
1472
1475
|
const filter = this.buildPolicyFilter(model, alias, "read");
|
|
1473
1476
|
return acc ? conjunction(this.dialect, [
|
|
1474
1477
|
acc,
|
|
@@ -1556,6 +1559,11 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
1556
1559
|
bQuery
|
|
1557
1560
|
]).toOperationNode();
|
|
1558
1561
|
}
|
|
1562
|
+
tryRejectNonexistentModel(model) {
|
|
1563
|
+
if (!QueryUtils2.hasModel(this.client.$schema, model) && !this.isManyToManyJoinTable(model)) {
|
|
1564
|
+
throw createRejectedByPolicyError(model, RejectedByPolicyReason.NO_ACCESS);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1559
1567
|
};
|
|
1560
1568
|
|
|
1561
1569
|
// src/functions.ts
|