@zenstackhq/plugin-policy 3.8.0 → 3.8.1
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 +20 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1300,29 +1300,26 @@ var PolicyHandler = class extends OperationNodeTransformer {
|
|
|
1300
1300
|
return result;
|
|
1301
1301
|
}
|
|
1302
1302
|
resolveManyToManyJoinTable(tableName) {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
};
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1303
|
+
const endpoints = QueryUtils.getManyToManyJoinTable(this.client.$schema, tableName);
|
|
1304
|
+
if (!endpoints) return;
|
|
1305
|
+
const sortedRecord = [{
|
|
1306
|
+
model: endpoints.model,
|
|
1307
|
+
field: endpoints.field
|
|
1308
|
+
}, {
|
|
1309
|
+
model: endpoints.otherModel,
|
|
1310
|
+
field: endpoints.otherField
|
|
1311
|
+
}].sort(this.manyToManySorter);
|
|
1312
|
+
const firstIdFields = QueryUtils.requireIdFields(this.client.$schema, sortedRecord[0].model);
|
|
1313
|
+
const secondIdFields = QueryUtils.requireIdFields(this.client.$schema, sortedRecord[1].model);
|
|
1314
|
+
invariant(firstIdFields.length === 1 && secondIdFields.length === 1, "only single-field id is supported for implicit many-to-many join table");
|
|
1315
|
+
return {
|
|
1316
|
+
firstModel: sortedRecord[0].model,
|
|
1317
|
+
firstField: sortedRecord[0].field,
|
|
1318
|
+
firstIdField: firstIdFields[0],
|
|
1319
|
+
secondModel: sortedRecord[1].model,
|
|
1320
|
+
secondField: sortedRecord[1].field,
|
|
1321
|
+
secondIdField: secondIdFields[0]
|
|
1322
|
+
};
|
|
1326
1323
|
}
|
|
1327
1324
|
manyToManySorter(a, b) {
|
|
1328
1325
|
return a.model !== b.model ? a.model.localeCompare(b.model) : a.field.localeCompare(b.field);
|