Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Store and ObjectRepository #2529

Merged
merged 9 commits into from
May 7, 2024
Prev Previous commit
Next Next commit
refactor(cacheDbEnum): JS -> TS plus correction of imports
fmauNeko committed May 7, 2024

Verified

This commit was signed with the committer’s verified signature. The key has been revoked.
fmauNeko Florian Maunier
commit 5c63f3b5b4ecb769bbe934f780416072d46e9468
20 changes: 5 additions & 15 deletions lib/core/cache/cacheDbEnum.js → lib/core/cache/cacheDbEnum.ts
Original file line number Diff line number Diff line change
@@ -19,22 +19,12 @@
* limitations under the License.
*/

"use strict";

/**
* @typedef {string} cacheDbEnum
*/

/**
* Enum for the cache engine target (used by classes using either the
* internal or the public DB)
* @readOnly
* @enum {cacheDbEnum}
*/
const cacheDbEnum = Object.freeze({
INTERNAL: "internal",
NONE: "none",
PUBLIC: "public",
});

module.exports = cacheDbEnum;
export enum cacheDbEnum {
INTERNAL = "internal",
NONE = "none",
PUBLIC = "public",
}
2 changes: 1 addition & 1 deletion lib/core/plugin/pluginRepository.js
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ const { merge } = require("lodash");

const { NotFoundError } = require("../../kerror/errors");
const { ObjectRepository } = require("../shared/ObjectRepository");
const cacheDbEnum = require("../cache/cacheDbEnum");
const { cacheDbEnum } = require("../cache/cacheDbEnum");

class PluginRepository extends ObjectRepository {
constructor(store, collection) {
2 changes: 1 addition & 1 deletion lib/core/security/profileRepository.ts
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ import { JSONObject } from "kuzzle-sdk";
import { OptimizedPolicy, Policy } from "../../../index";
import * as kerror from "../../kerror";
import { Profile } from "../../model/security/profile";
import cacheDbEnum from "../cache/cacheDbEnum";
import { cacheDbEnum } from "../cache/cacheDbEnum";
import { ObjectRepository } from "../shared/ObjectRepository";

/** @internal */
2 changes: 1 addition & 1 deletion lib/core/security/roleRepository.js
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ const { Role } = require("../../model/security/role");
const { ObjectRepository } = require("../shared/ObjectRepository");
const kerror = require("../../kerror");
const didYouMean = require("../../util/didYouMean");
const cacheDbEnum = require("../cache/cacheDbEnum");
const { cacheDbEnum } = require("../cache/cacheDbEnum");

const roleRightsError = kerror.wrap("security", "role");

4 changes: 2 additions & 2 deletions lib/core/shared/ObjectRepository.ts
Original file line number Diff line number Diff line change
@@ -21,15 +21,15 @@

import { JSONObject } from "kuzzle-sdk";
import * as kerror from "../../kerror";
import cacheDbEnum from "../cache/cacheDbEnum";
import { cacheDbEnum } from "../cache/cacheDbEnum";

export class ObjectRepository<TObject extends { _id: string }> {
protected ttl: number;
protected index: string;
protected collection: string;
protected ObjectConstructor: any;
protected store: any;
protected cacheDb: any;
protected cacheDb: cacheDbEnum;

constructor({ cache = cacheDbEnum.INTERNAL, store = null } = {}) {
this.ttl = global.kuzzle.config.repositories.common.cacheTTL;
2 changes: 1 addition & 1 deletion test/core/plugin/pluginRepository.test.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ const should = require("should");
const KuzzleMock = require("../../mocks/kuzzle.mock");

const PluginRepository = require("../../../lib/core/plugin/pluginRepository");
const cacheDbEnum = require("../../../lib/core/cache/cacheDbEnum");
const { cacheDbEnum } = require("../../../lib/core/cache/cacheDbEnum");
const { storeScopeEnum } = require("../../../lib/core/storage/storeScopeEnum");
const { Store } = require("../../../lib/core/shared/store");

2 changes: 1 addition & 1 deletion test/core/shared/repository.test.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ const KuzzleMock = require("../../mocks/kuzzle.mock");
const {
ObjectRepository,
} = require("../../../lib/core/shared/ObjectRepository");
const cacheDbEnum = require("../../../lib/core/cache/cacheDbEnum");
const { cacheDbEnum } = require("../../../lib/core/cache/cacheDbEnum");

describe("Test: repositories/repository", () => {
let kuzzle;