Skip to content

Commit

Permalink
feature userAccessPolicy: grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
light-source committed Jan 6, 2025
1 parent 6f4af7f commit 5e56bd7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Schema} from "mongoose";
import type Rule from "../rule.js";
import mongooseIp from "../../ip/mongooseIp.js";
import mongooseConfig from "../../config/mongooseConfig.js";
import type Rule from "../../rule.js";
import mongooseIp from "../../../ip/mongooseIp.js";
import mongooseConfig from "../../../config/mongooseConfig.js";

const mongooseRule = new Schema<Rule>({
isUserBlocked: { type: Boolean, required: true },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Types } from "mongoose";
import type Rule from "../rule.js";
import type RuleRecord from "../ruleRecord";

interface MongooseRuleRecord extends Rule {
interface MongooseRuleRecord extends RuleRecord {
_id: Types.ObjectId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// limitations under the License.
import { Address4, type Address6 } from "ip-address";
import type { Model } from "mongoose";
import type RulesStorage from "./rulesStorage.js";
import type Rule from "../rule.js";
import type RuleRecord from "../mongoose/mongooseRuleRecord.js";
import type SearchRuleFilters from "./filters/search/searchRuleFilters.js";
import type SearchRuleFilterSettings from "./filters/search/searchRuleFilterSettings.js";
import IpVersion from "../../ip/ipVersion.js";
import type RulesStorage from "../rulesStorage.js";
import type Rule from "../../rule.js";
import type SearchRuleFilters from "../filters/search/searchRuleFilters.js";
import type SearchRuleFilterSettings from "../filters/search/searchRuleFilterSettings.js";
import IpVersion from "../../../ip/ipVersion.js";
import type MongooseRuleRecord from "../mongoose/mongooseRuleRecord.js";

class MongooseRulesStorage implements RulesStorage {
private model: Model<Rule> | null;
Expand All @@ -27,7 +27,7 @@ class MongooseRulesStorage implements RulesStorage {
this.model = model;
}

public async insertMany(records: Rule[]): Promise<RuleRecord[]> {
public async insertMany(records: Rule[]): Promise<MongooseRuleRecord[]> {
if (!this.model) {
throw new Error("Model is not set");
}
Expand All @@ -38,7 +38,7 @@ class MongooseRulesStorage implements RulesStorage {
public async find(
filters: SearchRuleFilters,
filterSettings?: SearchRuleFilterSettings,
): Promise<RuleRecord[]> {
): Promise<MongooseRuleRecord[]> {
if (!this.model) {
throw new Error("Model is not set");
}
Expand Down
7 changes: 7 additions & 0 deletions packages/user-access-policy/src/rule/storage/ruleRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type Rule from "../rule";

interface RuleRecord extends Rule {
_id: unknown;
}

export default RuleRecord;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import type Rule from "../rule.js";
import type RuleRecord from "../ruleRecord.js";
import type RuleRecord from "./ruleRecord.js";
import type DeleteRuleFilters from "./filters/deleteRuleFilters.js";
import type SearchRuleFilters from "./filters/search/searchRuleFilters.js";
import type SearchRuleFilterSettings from "./filters/search/searchRuleFilterSettings.js";
Expand Down

0 comments on commit 5e56bd7

Please sign in to comment.