@ug.software/opposer 3.0.10 → 3.0.11
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/lib/bin/commands/build.js +15 -28
- package/lib/bin/commands/init.js +27 -30
- package/lib/esm/server/security/jwt/index.d.ts +1 -1
- package/lib/esm/server/security/jwt/index.js +21 -29
- package/lib/esm/system/index.d.ts +1 -1
- package/lib/esm/system/index.js +42 -55
- package/package.json +3 -3
- package/lib/cjs/examples/full-app/index.d.ts +0 -1
- package/lib/cjs/examples/full-app/index.js +0 -102
- package/lib/cjs/examples/full-app/models/author.d.ts +0 -7
- package/lib/cjs/examples/full-app/models/author.js +0 -42
- package/lib/cjs/examples/full-app/models/book.d.ts +0 -9
- package/lib/cjs/examples/full-app/models/book.js +0 -51
- package/lib/cjs/examples/full-app/models/category.d.ts +0 -4
- package/lib/cjs/examples/full-app/models/category.js +0 -26
- package/lib/cjs/examples/full-app/schedules/catalog-refresh.d.ts +0 -28
- package/lib/cjs/examples/full-app/schedules/catalog-refresh.js +0 -149
- package/lib/cjs/examples/full-app/schedules/inventory-sync.d.ts +0 -12
- package/lib/cjs/examples/full-app/schedules/inventory-sync.js +0 -61
- package/lib/cjs/examples/full-app/schedules/library-alerts.d.ts +0 -11
- package/lib/cjs/examples/full-app/schedules/library-alerts.js +0 -55
- package/lib/cjs/examples/minimal/src/handlers/book.d.ts +0 -11
- package/lib/cjs/examples/minimal/src/handlers/book.js +0 -51
- package/lib/cjs/examples/minimal/src/index.d.ts +0 -1
- package/lib/cjs/examples/minimal/src/index.js +0 -14
- package/lib/cjs/examples/minimal/src/models/books.d.ts +0 -4
- package/lib/cjs/examples/minimal/src/models/books.js +0 -26
- package/lib/cjs/examples/orm/models/permission.d.ts +0 -6
- package/lib/cjs/examples/orm/models/permission.js +0 -38
- package/lib/cjs/examples/orm/models/profile.d.ts +0 -7
- package/lib/cjs/examples/orm/models/profile.js +0 -42
- package/lib/cjs/examples/orm/models/user.d.ts +0 -11
- package/lib/cjs/examples/orm/models/user.js +0 -70
- package/lib/cjs/examples/orm/mysql/index.d.ts +0 -1
- package/lib/cjs/examples/orm/mysql/index.js +0 -44
- package/lib/cjs/examples/orm/postgres/index.d.ts +0 -1
- package/lib/cjs/examples/orm/postgres/index.js +0 -40
- package/lib/cjs/examples/orm/sqlite/index.d.ts +0 -1
- package/lib/cjs/examples/orm/sqlite/index.js +0 -41
- package/lib/cjs/index.d.ts +0 -2
- package/lib/cjs/index.js +0 -23
- package/lib/cjs/interfaces/controller.d.ts +0 -109
- package/lib/cjs/interfaces/controller.js +0 -2
- package/lib/cjs/interfaces/field.d.ts +0 -23
- package/lib/cjs/interfaces/field.js +0 -2
- package/lib/cjs/interfaces/handler.d.ts +0 -18
- package/lib/cjs/interfaces/handler.js +0 -2
- package/lib/cjs/interfaces/jwt.d.ts +0 -21
- package/lib/cjs/interfaces/jwt.js +0 -2
- package/lib/cjs/interfaces/model.d.ts +0 -9
- package/lib/cjs/interfaces/model.js +0 -2
- package/lib/cjs/interfaces/request.d.ts +0 -13
- package/lib/cjs/interfaces/request.js +0 -2
- package/lib/cjs/interfaces/schema.d.ts +0 -9
- package/lib/cjs/interfaces/schema.js +0 -2
- package/lib/cjs/interfaces/security.d.ts +0 -32
- package/lib/cjs/interfaces/security.js +0 -2
- package/lib/cjs/interfaces/server.d.ts +0 -37
- package/lib/cjs/interfaces/server.js +0 -2
- package/lib/cjs/interfaces/system.d.ts +0 -41
- package/lib/cjs/interfaces/system.js +0 -2
- package/lib/cjs/orm/decorators/index.d.ts +0 -33
- package/lib/cjs/orm/decorators/index.js +0 -131
- package/lib/cjs/orm/driver/mysql.d.ts +0 -14
- package/lib/cjs/orm/driver/mysql.js +0 -103
- package/lib/cjs/orm/driver/postgres.d.ts +0 -14
- package/lib/cjs/orm/driver/postgres.js +0 -105
- package/lib/cjs/orm/driver/sqlite.d.ts +0 -14
- package/lib/cjs/orm/driver/sqlite.js +0 -143
- package/lib/cjs/orm/index.d.ts +0 -8
- package/lib/cjs/orm/index.js +0 -28
- package/lib/cjs/orm/metadata.d.ts +0 -47
- package/lib/cjs/orm/metadata.js +0 -47
- package/lib/cjs/orm/opposer.d.ts +0 -30
- package/lib/cjs/orm/opposer.js +0 -33
- package/lib/cjs/orm/query-builder.d.ts +0 -32
- package/lib/cjs/orm/query-builder.js +0 -278
- package/lib/cjs/orm/repository.d.ts +0 -54
- package/lib/cjs/orm/repository.js +0 -325
- package/lib/cjs/orm/validation.d.ts +0 -44
- package/lib/cjs/orm/validation.js +0 -128
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/persistent/cache/core-context.d.ts +0 -17
- package/lib/cjs/persistent/cache/core-context.js +0 -39
- package/lib/cjs/persistent/cache/global.d.ts +0 -18
- package/lib/cjs/persistent/cache/global.js +0 -22
- package/lib/cjs/persistent/cache/index.d.ts +0 -3
- package/lib/cjs/persistent/cache/index.js +0 -12
- package/lib/cjs/persistent/cache/session.d.ts +0 -19
- package/lib/cjs/persistent/cache/session.js +0 -39
- package/lib/cjs/persistent/cache/storage.d.ts +0 -14
- package/lib/cjs/persistent/cache/storage.js +0 -88
- package/lib/cjs/persistent/cache/store.d.ts +0 -16
- package/lib/cjs/persistent/cache/store.js +0 -112
- package/lib/cjs/persistent/context/index.d.ts +0 -3
- package/lib/cjs/persistent/context/index.js +0 -5
- package/lib/cjs/persistent/decorators/global.d.ts +0 -1
- package/lib/cjs/persistent/decorators/global.js +0 -25
- package/lib/cjs/persistent/decorators/session.d.ts +0 -1
- package/lib/cjs/persistent/decorators/session.js +0 -27
- package/lib/cjs/persistent/index.d.ts +0 -6
- package/lib/cjs/persistent/index.js +0 -18
- package/lib/cjs/persistent/interfaces/context.d.ts +0 -5
- package/lib/cjs/persistent/interfaces/context.js +0 -2
- package/lib/cjs/persistent/interfaces/system.d.ts +0 -47
- package/lib/cjs/persistent/interfaces/system.js +0 -29
- package/lib/cjs/persistent/system/index.d.ts +0 -7
- package/lib/cjs/persistent/system/index.js +0 -44
- package/lib/cjs/persistent/utils/memory.d.ts +0 -8
- package/lib/cjs/persistent/utils/memory.js +0 -44
- package/lib/cjs/persistent/utils/timer.d.ts +0 -14
- package/lib/cjs/persistent/utils/timer.js +0 -21
- package/lib/cjs/playground/build/client/assets/AddRounded-ByHfnsiW.js +0 -4
- package/lib/cjs/playground/build/client/assets/Button-DLrxHRm7.js +0 -1
- package/lib/cjs/playground/build/client/assets/Container-CgITmmbk.js +0 -1
- package/lib/cjs/playground/build/client/assets/Divider-B_Wx9srO.js +0 -1
- package/lib/cjs/playground/build/client/assets/List-juBjUmfP.js +0 -1
- package/lib/cjs/playground/build/client/assets/ListItemText-DgWZmgzc.js +0 -1
- package/lib/cjs/playground/build/client/assets/MenuItem-D_5SuVKQ.js +0 -1
- package/lib/cjs/playground/build/client/assets/Modal-BwXR_5Bh.js +0 -1
- package/lib/cjs/playground/build/client/assets/TableRow-B9hAmlnV.js +0 -2
- package/lib/cjs/playground/build/client/assets/TextField-UybdTIGB.js +0 -3
- package/lib/cjs/playground/build/client/assets/Tooltip-BGcUWUcF.js +0 -1
- package/lib/cjs/playground/build/client/assets/auth-CD1rXHzz.js +0 -1
- package/lib/cjs/playground/build/client/assets/auth-GyTIVKy5.js +0 -1
- package/lib/cjs/playground/build/client/assets/confirm-Dr0pbiV6.js +0 -1
- package/lib/cjs/playground/build/client/assets/dividerClasses-CIiqeEPO.js +0 -1
- package/lib/cjs/playground/build/client/assets/entry.client-D6FYz1yh.js +0 -13
- package/lib/cjs/playground/build/client/assets/index-CJ0wdt6Z.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-CQc11yq_.js +0 -1153
- package/lib/cjs/playground/build/client/assets/index-Cr4I-4J2.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-CtPqstFl.js +0 -26
- package/lib/cjs/playground/build/client/assets/index-Ct_NE85o.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-D0I6xwmb.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-DmDCpKb3.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-DsSkAwyn.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-_DMgWZ3Y.js +0 -1
- package/lib/cjs/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +0 -1
- package/lib/cjs/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +0 -1
- package/lib/cjs/playground/build/client/assets/manifest-c06e9a7f.js +0 -1
- package/lib/cjs/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +0 -1
- package/lib/cjs/playground/build/client/assets/playground-Hl52p9f5.js +0 -108
- package/lib/cjs/playground/build/client/assets/root-CQTBmuv8.js +0 -1
- package/lib/cjs/playground/build/client/assets/toast-CsAH5FIf.js +0 -1
- package/lib/cjs/playground/build/client/assets/use-request-BZNkzlTr.js +0 -1
- package/lib/cjs/playground/build/client/favicon.ico +0 -0
- package/lib/cjs/playground/build/client/index.html +0 -6
- package/lib/cjs/playground/index.d.ts +0 -2
- package/lib/cjs/playground/index.js +0 -135
- package/lib/cjs/scheduler/controllers/index.d.ts +0 -19
- package/lib/cjs/scheduler/controllers/index.js +0 -62
- package/lib/cjs/scheduler/decorators/index.d.ts +0 -9
- package/lib/cjs/scheduler/decorators/index.js +0 -21
- package/lib/cjs/scheduler/handlers/index.d.ts +0 -19
- package/lib/cjs/scheduler/handlers/index.js +0 -62
- package/lib/cjs/scheduler/index.d.ts +0 -24
- package/lib/cjs/scheduler/index.js +0 -110
- package/lib/cjs/scheduler/models/history.d.ts +0 -10
- package/lib/cjs/scheduler/models/history.js +0 -50
- package/lib/cjs/server/constants/index.d.ts +0 -78
- package/lib/cjs/server/constants/index.js +0 -372
- package/lib/cjs/server/context/index.d.ts +0 -17
- package/lib/cjs/server/context/index.js +0 -33
- package/lib/cjs/server/controller/index.d.ts +0 -3
- package/lib/cjs/server/controller/index.js +0 -217
- package/lib/cjs/server/controllers/index.d.ts +0 -5
- package/lib/cjs/server/controllers/index.js +0 -72
- package/lib/cjs/server/core/index.d.ts +0 -16
- package/lib/cjs/server/core/index.js +0 -110
- package/lib/cjs/server/core/middleware/body-parser.d.ts +0 -2
- package/lib/cjs/server/core/middleware/body-parser.js +0 -27
- package/lib/cjs/server/core/middleware/cors.d.ts +0 -4
- package/lib/cjs/server/core/middleware/cors.js +0 -32
- package/lib/cjs/server/core/middleware/logger.d.ts +0 -2
- package/lib/cjs/server/core/middleware/logger.js +0 -15
- package/lib/cjs/server/decorators/controller.d.ts +0 -3
- package/lib/cjs/server/decorators/controller.js +0 -14
- package/lib/cjs/server/decorators/field.d.ts +0 -2
- package/lib/cjs/server/decorators/field.js +0 -36
- package/lib/cjs/server/decorators/handler.d.ts +0 -3
- package/lib/cjs/server/decorators/handler.js +0 -14
- package/lib/cjs/server/decorators/index.d.ts +0 -7
- package/lib/cjs/server/decorators/index.js +0 -26
- package/lib/cjs/server/decorators/is-public-method.d.ts +0 -3
- package/lib/cjs/server/decorators/is-public-method.js +0 -16
- package/lib/cjs/server/decorators/is-public.d.ts +0 -3
- package/lib/cjs/server/decorators/is-public.js +0 -14
- package/lib/cjs/server/decorators/method.d.ts +0 -3
- package/lib/cjs/server/decorators/method.js +0 -16
- package/lib/cjs/server/decorators/payload.d.ts +0 -3
- package/lib/cjs/server/decorators/payload.js +0 -15
- package/lib/cjs/server/handlers/index.d.ts +0 -5
- package/lib/cjs/server/handlers/index.js +0 -72
- package/lib/cjs/server/helpers/index.d.ts +0 -17
- package/lib/cjs/server/helpers/index.js +0 -39
- package/lib/cjs/server/index.d.ts +0 -12
- package/lib/cjs/server/index.js +0 -176
- package/lib/cjs/server/security/controller/auth.d.ts +0 -76
- package/lib/cjs/server/security/controller/auth.js +0 -346
- package/lib/cjs/server/security/index.d.ts +0 -2
- package/lib/cjs/server/security/index.js +0 -10
- package/lib/cjs/server/security/jwt/index.d.ts +0 -23
- package/lib/cjs/server/security/jwt/index.js +0 -108
- package/lib/cjs/server/security/middleware/autorization.d.ts +0 -3
- package/lib/cjs/server/security/middleware/autorization.js +0 -46
- package/lib/cjs/server/security/middleware/permission.d.ts +0 -3
- package/lib/cjs/server/security/middleware/permission.js +0 -138
- package/lib/cjs/server/security/models/crp.d.ts +0 -8
- package/lib/cjs/server/security/models/crp.js +0 -42
- package/lib/cjs/server/security/models/ke.d.ts +0 -7
- package/lib/cjs/server/security/models/ke.js +0 -38
- package/lib/cjs/server/security/models/rl.d.ts +0 -9
- package/lib/cjs/server/security/models/rl.js +0 -50
- package/lib/cjs/server/security/models/se.d.ts +0 -11
- package/lib/cjs/server/security/models/se.js +0 -54
- package/lib/cjs/server/security/models/usr.d.ts +0 -14
- package/lib/cjs/server/security/models/usr.js +0 -82
- package/lib/cjs/server/services/delete.d.ts +0 -13
- package/lib/cjs/server/services/delete.js +0 -49
- package/lib/cjs/server/services/get.d.ts +0 -4
- package/lib/cjs/server/services/get.js +0 -145
- package/lib/cjs/server/services/insert.d.ts +0 -13
- package/lib/cjs/server/services/insert.js +0 -74
- package/lib/cjs/server/services/update.d.ts +0 -13
- package/lib/cjs/server/services/update.js +0 -60
- package/lib/cjs/system/index.d.ts +0 -13
- package/lib/cjs/system/index.js +0 -237
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type CacheSettings } from "../interfaces/system.js";
|
|
2
|
-
export default class Storage {
|
|
3
|
-
__settings: CacheSettings;
|
|
4
|
-
__data: Record<string, any>;
|
|
5
|
-
__isMaxSizeMemory: boolean;
|
|
6
|
-
__currentSizeMemory: number;
|
|
7
|
-
snapshot(): void;
|
|
8
|
-
restore(): void;
|
|
9
|
-
size(): boolean;
|
|
10
|
-
revalidate(): void | null;
|
|
11
|
-
notifyStoresForClearMemoryPerPolicy(): void;
|
|
12
|
-
clear(): void;
|
|
13
|
-
configure(): this;
|
|
14
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const timer_js_1 = __importDefault(require("../utils/timer.js"));
|
|
7
|
-
const index_js_1 = __importDefault(require("../system/index.js"));
|
|
8
|
-
const store_js_1 = __importDefault(require("./store.js"));
|
|
9
|
-
const memory_js_1 = __importDefault(require("../utils/memory.js"));
|
|
10
|
-
class Storage {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.__data = {};
|
|
13
|
-
this.__isMaxSizeMemory = false;
|
|
14
|
-
this.__currentSizeMemory = 0;
|
|
15
|
-
}
|
|
16
|
-
snapshot() { }
|
|
17
|
-
restore() { }
|
|
18
|
-
size() {
|
|
19
|
-
this.__currentSizeMemory = memory_js_1.default.roughSizeOfObject(this.__data);
|
|
20
|
-
this.__isMaxSizeMemory =
|
|
21
|
-
this.__currentSizeMemory ===
|
|
22
|
-
memory_js_1.default.toBytes(this.__settings.maxmemory.size, this.__settings.maxmemory.unit);
|
|
23
|
-
return this.__isMaxSizeMemory;
|
|
24
|
-
}
|
|
25
|
-
revalidate() {
|
|
26
|
-
if (this.__data instanceof store_js_1.default) {
|
|
27
|
-
this.__data.clearMemoryForPolicy();
|
|
28
|
-
var __isMaxSizeMemory = this.size();
|
|
29
|
-
if (__isMaxSizeMemory) {
|
|
30
|
-
return this.notifyStoresForClearMemoryPerPolicy();
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
var creared = Object.keys(this.__data).reduce((data, key) => {
|
|
35
|
-
var store = this.__data[key];
|
|
36
|
-
if (store.isValid()) {
|
|
37
|
-
Object.defineProperty(data, key, {
|
|
38
|
-
value: store,
|
|
39
|
-
configurable: true,
|
|
40
|
-
enumerable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return data;
|
|
45
|
-
}, {});
|
|
46
|
-
Object.defineProperty(this, "__data", {
|
|
47
|
-
value: creared,
|
|
48
|
-
configurable: true,
|
|
49
|
-
enumerable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
});
|
|
52
|
-
var __isMaxSizeMemory = this.size();
|
|
53
|
-
if (__isMaxSizeMemory) {
|
|
54
|
-
return this.notifyStoresForClearMemoryPerPolicy();
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
notifyStoresForClearMemoryPerPolicy() {
|
|
59
|
-
Object.values(this.__data).forEach((store) => store.clearMemoryForPolicy());
|
|
60
|
-
var __isMaxSizeMemory = this.size();
|
|
61
|
-
if (__isMaxSizeMemory) {
|
|
62
|
-
this.notifyStoresForClearMemoryPerPolicy();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
clear() {
|
|
66
|
-
Object.defineProperty(this, "__data", {
|
|
67
|
-
value: {},
|
|
68
|
-
configurable: true,
|
|
69
|
-
enumerable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
configure() {
|
|
74
|
-
if (index_js_1.default.settings.cache.type === "persistent") {
|
|
75
|
-
if (index_js_1.default.settings.cache.snapshot.active) {
|
|
76
|
-
setInterval(() => {
|
|
77
|
-
this.snapshot();
|
|
78
|
-
}, index_js_1.default.settings.cache.snapshot.timer * timer_js_1.default.msPerUnit[index_js_1.default.settings.cache.snapshot.unit]);
|
|
79
|
-
}
|
|
80
|
-
this.restore();
|
|
81
|
-
}
|
|
82
|
-
setInterval(() => {
|
|
83
|
-
this.revalidate();
|
|
84
|
-
}, timer_js_1.default.getSeconds(this.__settings.revalidate.timer, this.__settings.revalidate.unit));
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.default = Storage;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CacheSettings } from "../interfaces/system.js";
|
|
2
|
-
export default class Store {
|
|
3
|
-
private __sessionId;
|
|
4
|
-
private __settings;
|
|
5
|
-
private __expires_in;
|
|
6
|
-
private __data;
|
|
7
|
-
private __meta;
|
|
8
|
-
constructor(session?: string);
|
|
9
|
-
private trackAccess;
|
|
10
|
-
get(key: string): any;
|
|
11
|
-
set(key: string, value: any, ttlMs?: number): void;
|
|
12
|
-
revalidateTimer(): void;
|
|
13
|
-
isValid(): boolean;
|
|
14
|
-
clearMemoryForPolicy(): void;
|
|
15
|
-
setSettings(settings: CacheSettings): void;
|
|
16
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const timer_js_1 = __importDefault(require("../utils/timer.js"));
|
|
7
|
-
class Store {
|
|
8
|
-
constructor(session) {
|
|
9
|
-
this.__expires_in = timer_js_1.default.getNextSessionExpireDate();
|
|
10
|
-
this.__data = new Map();
|
|
11
|
-
this.__meta = new Map();
|
|
12
|
-
this.__sessionId = session;
|
|
13
|
-
}
|
|
14
|
-
// Marca o acesso e frequência (para LFU/LRU)
|
|
15
|
-
trackAccess(key) {
|
|
16
|
-
if (!this.__meta.has(key)) {
|
|
17
|
-
this.__meta.set(key, {
|
|
18
|
-
lastAccess: Date.now(),
|
|
19
|
-
frequency: 1,
|
|
20
|
-
ttl: undefined,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
var __meta = this.__meta.get(key);
|
|
25
|
-
if (!__meta) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
__meta.lastAccess = Date.now();
|
|
29
|
-
__meta.frequency++;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
get(key) {
|
|
33
|
-
const value = this.__data.get(key);
|
|
34
|
-
if (value !== undefined) {
|
|
35
|
-
this.trackAccess(key);
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
set(key, value, ttlMs) {
|
|
40
|
-
this.__data.set(key, value);
|
|
41
|
-
this.__meta.set(key, {
|
|
42
|
-
lastAccess: Date.now(),
|
|
43
|
-
frequency: 1,
|
|
44
|
-
ttl: ttlMs ? Date.now() + ttlMs : undefined,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
revalidateTimer() {
|
|
48
|
-
this.__expires_in = timer_js_1.default.getNextSessionExpireDate();
|
|
49
|
-
}
|
|
50
|
-
isValid() {
|
|
51
|
-
return this.__expires_in > new Date().getTime();
|
|
52
|
-
}
|
|
53
|
-
// Políticas de limpeza
|
|
54
|
-
clearMemoryForPolicy() {
|
|
55
|
-
const policy = this.__settings.evictionPolicy;
|
|
56
|
-
switch (policy) {
|
|
57
|
-
// Nenhuma exclusão automática
|
|
58
|
-
case "noeviction":
|
|
59
|
-
return;
|
|
60
|
-
// Remove o menos recentemente usado
|
|
61
|
-
case "volatile-lru": {
|
|
62
|
-
let oldestKey = null;
|
|
63
|
-
let oldestAccess = Infinity;
|
|
64
|
-
for (const [key, meta] of Object.entries(this.__meta)) {
|
|
65
|
-
if (meta.lastAccess < oldestAccess) {
|
|
66
|
-
oldestAccess = meta.lastAccess;
|
|
67
|
-
oldestKey = key;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (oldestKey) {
|
|
71
|
-
this.__data.delete(oldestKey);
|
|
72
|
-
this.__meta.delete(oldestKey);
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
// Remove o menos frequentemente usado
|
|
77
|
-
case "volatile-lfu": {
|
|
78
|
-
let leastUsedKey = null;
|
|
79
|
-
let leastFrequency = Infinity;
|
|
80
|
-
for (const [key, meta] of Object.entries(this.__meta)) {
|
|
81
|
-
if (meta.frequency < leastFrequency) {
|
|
82
|
-
leastUsedKey = key;
|
|
83
|
-
leastFrequency = meta.frequency;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (leastUsedKey) {
|
|
87
|
-
this.__data.delete(leastUsedKey);
|
|
88
|
-
this.__meta.delete(leastUsedKey);
|
|
89
|
-
}
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
// Remove chaves que passaram do TTL
|
|
93
|
-
case "volatile-ttl": {
|
|
94
|
-
const now = Date.now();
|
|
95
|
-
for (const [key, meta] of Object.entries(this.__meta)) {
|
|
96
|
-
if (meta.ttl && meta.ttl < now) {
|
|
97
|
-
this.__data.delete(key);
|
|
98
|
-
this.__meta.delete(key);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
default:
|
|
104
|
-
console.warn(`[Store] Unknown eviction policy: ${policy}`);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
setSettings(settings) {
|
|
109
|
-
this.__settings = settings;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.default = Store;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function Global(): (target: any, property: string) => void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = Global;
|
|
7
|
-
const global_js_1 = __importDefault(require("../cache/global.js"));
|
|
8
|
-
function Global() {
|
|
9
|
-
return function (target, property) {
|
|
10
|
-
const __property = Symbol(property);
|
|
11
|
-
const __class = target.constructor.name;
|
|
12
|
-
const __key = __class + ":" + property;
|
|
13
|
-
Object.defineProperty(target, property, {
|
|
14
|
-
get() {
|
|
15
|
-
return global_js_1.default.get(__key);
|
|
16
|
-
},
|
|
17
|
-
set(value) {
|
|
18
|
-
global_js_1.default.set(__key, value);
|
|
19
|
-
this[__property] = value;
|
|
20
|
-
},
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function Session(): (target: any, property: string) => void;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = Session;
|
|
7
|
-
const index_js_1 = __importDefault(require("../context/index.js"));
|
|
8
|
-
function Session() {
|
|
9
|
-
return function (target, property) {
|
|
10
|
-
const __property = Symbol(property);
|
|
11
|
-
const __class = target.constructor.name;
|
|
12
|
-
const __key = __class + ":" + property;
|
|
13
|
-
Object.defineProperty(target, property, {
|
|
14
|
-
get() {
|
|
15
|
-
var __context = index_js_1.default.getStore();
|
|
16
|
-
return __context.store.get(__key);
|
|
17
|
-
},
|
|
18
|
-
set(value) {
|
|
19
|
-
var __context = index_js_1.default.getStore();
|
|
20
|
-
__context.store.set(__key, value);
|
|
21
|
-
this[__property] = value;
|
|
22
|
-
},
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { default as SessionStorage } from "./cache/session.js";
|
|
2
|
-
export { default as GlobalStorage } from "./cache/global.js";
|
|
3
|
-
export { default as Store } from "./cache/store.js";
|
|
4
|
-
export { default as Session } from "./decorators/session.js";
|
|
5
|
-
export { default as Global } from "./decorators/global.js";
|
|
6
|
-
export { default as Context } from "./context/index.js";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Context = exports.Global = exports.Session = exports.Store = exports.GlobalStorage = exports.SessionStorage = void 0;
|
|
7
|
-
var session_js_1 = require("./cache/session.js");
|
|
8
|
-
Object.defineProperty(exports, "SessionStorage", { enumerable: true, get: function () { return __importDefault(session_js_1).default; } });
|
|
9
|
-
var global_js_1 = require("./cache/global.js");
|
|
10
|
-
Object.defineProperty(exports, "GlobalStorage", { enumerable: true, get: function () { return __importDefault(global_js_1).default; } });
|
|
11
|
-
var store_js_1 = require("./cache/store.js");
|
|
12
|
-
Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return __importDefault(store_js_1).default; } });
|
|
13
|
-
var session_js_2 = require("./decorators/session.js");
|
|
14
|
-
Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return __importDefault(session_js_2).default; } });
|
|
15
|
-
var global_js_2 = require("./decorators/global.js");
|
|
16
|
-
Object.defineProperty(exports, "Global", { enumerable: true, get: function () { return __importDefault(global_js_2).default; } });
|
|
17
|
-
var index_js_1 = require("./context/index.js");
|
|
18
|
-
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return __importDefault(index_js_1).default; } });
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export declare enum MemoryUnit {
|
|
2
|
-
MB = "mb",
|
|
3
|
-
GB = "gb"
|
|
4
|
-
}
|
|
5
|
-
export declare enum TimerUnit {
|
|
6
|
-
seconds = "seconds",
|
|
7
|
-
minutes = "minutes",
|
|
8
|
-
hours = "hours",
|
|
9
|
-
days = "days"
|
|
10
|
-
}
|
|
11
|
-
export declare enum EvictionPolicy {
|
|
12
|
-
noeviction = "noeviction",
|
|
13
|
-
volatileLru = "volatile-lru",
|
|
14
|
-
allkeysLru = "allkeys-lru",
|
|
15
|
-
volatileLfu = "volatile-lfu",
|
|
16
|
-
allkeysLfu = "allkeys-lfu",
|
|
17
|
-
volatileTtl = "volatile-ttl"
|
|
18
|
-
}
|
|
19
|
-
export declare enum CacheType {
|
|
20
|
-
inMemory = "in-memory",
|
|
21
|
-
persistent = "persistent"
|
|
22
|
-
}
|
|
23
|
-
export interface CacheSettings {
|
|
24
|
-
expire: number;
|
|
25
|
-
unit: TimerUnit;
|
|
26
|
-
evictionPolicy: EvictionPolicy;
|
|
27
|
-
maxmemory: {
|
|
28
|
-
size: number;
|
|
29
|
-
unit: MemoryUnit;
|
|
30
|
-
};
|
|
31
|
-
revalidate: {
|
|
32
|
-
timer: number;
|
|
33
|
-
unit: TimerUnit;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export interface OpposerSystemConfigOptions {
|
|
37
|
-
cache: {
|
|
38
|
-
type: CacheType;
|
|
39
|
-
snapshot: {
|
|
40
|
-
active: boolean;
|
|
41
|
-
timer: number;
|
|
42
|
-
unit: TimerUnit;
|
|
43
|
-
};
|
|
44
|
-
session: CacheSettings;
|
|
45
|
-
global: CacheSettings;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CacheType = exports.EvictionPolicy = exports.TimerUnit = exports.MemoryUnit = void 0;
|
|
4
|
-
var MemoryUnit;
|
|
5
|
-
(function (MemoryUnit) {
|
|
6
|
-
MemoryUnit["MB"] = "mb";
|
|
7
|
-
MemoryUnit["GB"] = "gb";
|
|
8
|
-
})(MemoryUnit || (exports.MemoryUnit = MemoryUnit = {}));
|
|
9
|
-
var TimerUnit;
|
|
10
|
-
(function (TimerUnit) {
|
|
11
|
-
TimerUnit["seconds"] = "seconds";
|
|
12
|
-
TimerUnit["minutes"] = "minutes";
|
|
13
|
-
TimerUnit["hours"] = "hours";
|
|
14
|
-
TimerUnit["days"] = "days";
|
|
15
|
-
})(TimerUnit || (exports.TimerUnit = TimerUnit = {}));
|
|
16
|
-
var EvictionPolicy;
|
|
17
|
-
(function (EvictionPolicy) {
|
|
18
|
-
EvictionPolicy["noeviction"] = "noeviction";
|
|
19
|
-
EvictionPolicy["volatileLru"] = "volatile-lru";
|
|
20
|
-
EvictionPolicy["allkeysLru"] = "allkeys-lru";
|
|
21
|
-
EvictionPolicy["volatileLfu"] = "volatile-lfu";
|
|
22
|
-
EvictionPolicy["allkeysLfu"] = "allkeys-lfu";
|
|
23
|
-
EvictionPolicy["volatileTtl"] = "volatile-ttl";
|
|
24
|
-
})(EvictionPolicy || (exports.EvictionPolicy = EvictionPolicy = {}));
|
|
25
|
-
var CacheType;
|
|
26
|
-
(function (CacheType) {
|
|
27
|
-
CacheType["inMemory"] = "in-memory";
|
|
28
|
-
CacheType["persistent"] = "persistent";
|
|
29
|
-
})(CacheType || (exports.CacheType = CacheType = {}));
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
exports.default = new (class {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.settings = this.getSettingsFile();
|
|
11
|
-
}
|
|
12
|
-
getSettingsFile() {
|
|
13
|
-
let config = {};
|
|
14
|
-
try {
|
|
15
|
-
const root = process.cwd();
|
|
16
|
-
const configPath = path_1.default.resolve(root, "opposer-settings.json");
|
|
17
|
-
if (fs_1.default.existsSync(configPath)) {
|
|
18
|
-
const fileContent = fs_1.default.readFileSync(configPath, "utf8");
|
|
19
|
-
config = JSON.parse(fileContent);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
// It's okay if the file doesn't exist, we fallback to defaults and env vars
|
|
24
|
-
}
|
|
25
|
-
// Default structure
|
|
26
|
-
config.cache = config.cache || {};
|
|
27
|
-
config.cache.snapshot = config.cache.snapshot || {};
|
|
28
|
-
config.cache.session = config.cache.session || {};
|
|
29
|
-
config.cache.global = config.cache.global || {};
|
|
30
|
-
// Override with Environment Variables
|
|
31
|
-
config.cache.type = process.env.OPPOSER_CACHE_TYPE || config.cache.type || "in-memory";
|
|
32
|
-
config.cache.snapshot.active = process.env.OPPOSER_CACHE_SNAPSHOT === "true"
|
|
33
|
-
|| config.cache.snapshot.active
|
|
34
|
-
|| false;
|
|
35
|
-
config.cache.snapshot.timer = process.env.OPPOSER_CACHE_SNAPSHOT_TIMER
|
|
36
|
-
? parseInt(process.env.OPPOSER_CACHE_SNAPSHOT_TIMER)
|
|
37
|
-
: config.cache.snapshot.timer || 1;
|
|
38
|
-
config.cache.snapshot.unit = process.env.OPPOSER_CACHE_SNAPSHOT_UNIT
|
|
39
|
-
|| config.cache.snapshot.unit
|
|
40
|
-
|| "minutes";
|
|
41
|
-
return config;
|
|
42
|
-
}
|
|
43
|
-
getAllSessionData() { }
|
|
44
|
-
})();
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { MemoryUnit } from "../interfaces/system.js";
|
|
2
|
-
declare function toBytes(value: number, unit: MemoryUnit): number;
|
|
3
|
-
declare function roughSizeOfObject(object: Object): number;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
toBytes: typeof toBytes;
|
|
6
|
-
roughSizeOfObject: typeof roughSizeOfObject;
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function toBytes(value, unit) {
|
|
4
|
-
const base = 1024;
|
|
5
|
-
const units = {
|
|
6
|
-
mb: base ** 2,
|
|
7
|
-
gb: base ** 3,
|
|
8
|
-
};
|
|
9
|
-
return value * units[unit];
|
|
10
|
-
}
|
|
11
|
-
function roughSizeOfObject(object) {
|
|
12
|
-
const seen = new WeakSet();
|
|
13
|
-
function sizeOf(value) {
|
|
14
|
-
if (value === null || value === undefined)
|
|
15
|
-
return 0;
|
|
16
|
-
switch (typeof value) {
|
|
17
|
-
case "boolean":
|
|
18
|
-
return 4;
|
|
19
|
-
case "number":
|
|
20
|
-
return 8;
|
|
21
|
-
case "string":
|
|
22
|
-
return value.length * 2; // cada caractere ~2 bytes (UTF-16)
|
|
23
|
-
case "object":
|
|
24
|
-
if (seen.has(value))
|
|
25
|
-
return 0;
|
|
26
|
-
seen.add(value);
|
|
27
|
-
let bytes = 0;
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
value.forEach((el) => (bytes += sizeOf(el)));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
Object.keys(value).forEach((key) => {
|
|
33
|
-
bytes += sizeOf(key);
|
|
34
|
-
bytes += sizeOf(value[key]);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return bytes;
|
|
38
|
-
default:
|
|
39
|
-
return 0;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return sizeOf(object);
|
|
43
|
-
}
|
|
44
|
-
exports.default = { toBytes, roughSizeOfObject };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TimerUnit } from "../interfaces/system.js";
|
|
2
|
-
declare function getNextSessionExpireDate(): number;
|
|
3
|
-
declare function getSeconds(time: number, unit: TimerUnit): number;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
getNextSessionExpireDate: typeof getNextSessionExpireDate;
|
|
6
|
-
getSeconds: typeof getSeconds;
|
|
7
|
-
msPerUnit: {
|
|
8
|
-
seconds: number;
|
|
9
|
-
minutes: number;
|
|
10
|
-
hours: number;
|
|
11
|
-
days: number;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_js_1 = __importDefault(require("../system/index.js"));
|
|
7
|
-
const msPerUnit = {
|
|
8
|
-
seconds: 1000,
|
|
9
|
-
minutes: 1000 * 60,
|
|
10
|
-
hours: 1000 * 60 * 60,
|
|
11
|
-
days: 1000 * 60 * 60 * 24,
|
|
12
|
-
};
|
|
13
|
-
function getNextSessionExpireDate() {
|
|
14
|
-
return (new Date().getTime() +
|
|
15
|
-
index_js_1.default.settings.cache.session.expire *
|
|
16
|
-
msPerUnit[index_js_1.default.settings.cache.session.unit]);
|
|
17
|
-
}
|
|
18
|
-
function getSeconds(time, unit) {
|
|
19
|
-
return time * msPerUnit[unit];
|
|
20
|
-
}
|
|
21
|
-
exports.default = { getNextSessionExpireDate, getSeconds, msPerUnit };
|