@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.
Files changed (227) hide show
  1. package/lib/bin/commands/build.js +15 -28
  2. package/lib/bin/commands/init.js +27 -30
  3. package/lib/esm/server/security/jwt/index.d.ts +1 -1
  4. package/lib/esm/server/security/jwt/index.js +21 -29
  5. package/lib/esm/system/index.d.ts +1 -1
  6. package/lib/esm/system/index.js +42 -55
  7. package/package.json +3 -3
  8. package/lib/cjs/examples/full-app/index.d.ts +0 -1
  9. package/lib/cjs/examples/full-app/index.js +0 -102
  10. package/lib/cjs/examples/full-app/models/author.d.ts +0 -7
  11. package/lib/cjs/examples/full-app/models/author.js +0 -42
  12. package/lib/cjs/examples/full-app/models/book.d.ts +0 -9
  13. package/lib/cjs/examples/full-app/models/book.js +0 -51
  14. package/lib/cjs/examples/full-app/models/category.d.ts +0 -4
  15. package/lib/cjs/examples/full-app/models/category.js +0 -26
  16. package/lib/cjs/examples/full-app/schedules/catalog-refresh.d.ts +0 -28
  17. package/lib/cjs/examples/full-app/schedules/catalog-refresh.js +0 -149
  18. package/lib/cjs/examples/full-app/schedules/inventory-sync.d.ts +0 -12
  19. package/lib/cjs/examples/full-app/schedules/inventory-sync.js +0 -61
  20. package/lib/cjs/examples/full-app/schedules/library-alerts.d.ts +0 -11
  21. package/lib/cjs/examples/full-app/schedules/library-alerts.js +0 -55
  22. package/lib/cjs/examples/minimal/src/handlers/book.d.ts +0 -11
  23. package/lib/cjs/examples/minimal/src/handlers/book.js +0 -51
  24. package/lib/cjs/examples/minimal/src/index.d.ts +0 -1
  25. package/lib/cjs/examples/minimal/src/index.js +0 -14
  26. package/lib/cjs/examples/minimal/src/models/books.d.ts +0 -4
  27. package/lib/cjs/examples/minimal/src/models/books.js +0 -26
  28. package/lib/cjs/examples/orm/models/permission.d.ts +0 -6
  29. package/lib/cjs/examples/orm/models/permission.js +0 -38
  30. package/lib/cjs/examples/orm/models/profile.d.ts +0 -7
  31. package/lib/cjs/examples/orm/models/profile.js +0 -42
  32. package/lib/cjs/examples/orm/models/user.d.ts +0 -11
  33. package/lib/cjs/examples/orm/models/user.js +0 -70
  34. package/lib/cjs/examples/orm/mysql/index.d.ts +0 -1
  35. package/lib/cjs/examples/orm/mysql/index.js +0 -44
  36. package/lib/cjs/examples/orm/postgres/index.d.ts +0 -1
  37. package/lib/cjs/examples/orm/postgres/index.js +0 -40
  38. package/lib/cjs/examples/orm/sqlite/index.d.ts +0 -1
  39. package/lib/cjs/examples/orm/sqlite/index.js +0 -41
  40. package/lib/cjs/index.d.ts +0 -2
  41. package/lib/cjs/index.js +0 -23
  42. package/lib/cjs/interfaces/controller.d.ts +0 -109
  43. package/lib/cjs/interfaces/controller.js +0 -2
  44. package/lib/cjs/interfaces/field.d.ts +0 -23
  45. package/lib/cjs/interfaces/field.js +0 -2
  46. package/lib/cjs/interfaces/handler.d.ts +0 -18
  47. package/lib/cjs/interfaces/handler.js +0 -2
  48. package/lib/cjs/interfaces/jwt.d.ts +0 -21
  49. package/lib/cjs/interfaces/jwt.js +0 -2
  50. package/lib/cjs/interfaces/model.d.ts +0 -9
  51. package/lib/cjs/interfaces/model.js +0 -2
  52. package/lib/cjs/interfaces/request.d.ts +0 -13
  53. package/lib/cjs/interfaces/request.js +0 -2
  54. package/lib/cjs/interfaces/schema.d.ts +0 -9
  55. package/lib/cjs/interfaces/schema.js +0 -2
  56. package/lib/cjs/interfaces/security.d.ts +0 -32
  57. package/lib/cjs/interfaces/security.js +0 -2
  58. package/lib/cjs/interfaces/server.d.ts +0 -37
  59. package/lib/cjs/interfaces/server.js +0 -2
  60. package/lib/cjs/interfaces/system.d.ts +0 -41
  61. package/lib/cjs/interfaces/system.js +0 -2
  62. package/lib/cjs/orm/decorators/index.d.ts +0 -33
  63. package/lib/cjs/orm/decorators/index.js +0 -131
  64. package/lib/cjs/orm/driver/mysql.d.ts +0 -14
  65. package/lib/cjs/orm/driver/mysql.js +0 -103
  66. package/lib/cjs/orm/driver/postgres.d.ts +0 -14
  67. package/lib/cjs/orm/driver/postgres.js +0 -105
  68. package/lib/cjs/orm/driver/sqlite.d.ts +0 -14
  69. package/lib/cjs/orm/driver/sqlite.js +0 -143
  70. package/lib/cjs/orm/index.d.ts +0 -8
  71. package/lib/cjs/orm/index.js +0 -28
  72. package/lib/cjs/orm/metadata.d.ts +0 -47
  73. package/lib/cjs/orm/metadata.js +0 -47
  74. package/lib/cjs/orm/opposer.d.ts +0 -30
  75. package/lib/cjs/orm/opposer.js +0 -33
  76. package/lib/cjs/orm/query-builder.d.ts +0 -32
  77. package/lib/cjs/orm/query-builder.js +0 -278
  78. package/lib/cjs/orm/repository.d.ts +0 -54
  79. package/lib/cjs/orm/repository.js +0 -325
  80. package/lib/cjs/orm/validation.d.ts +0 -44
  81. package/lib/cjs/orm/validation.js +0 -128
  82. package/lib/cjs/package.json +0 -3
  83. package/lib/cjs/persistent/cache/core-context.d.ts +0 -17
  84. package/lib/cjs/persistent/cache/core-context.js +0 -39
  85. package/lib/cjs/persistent/cache/global.d.ts +0 -18
  86. package/lib/cjs/persistent/cache/global.js +0 -22
  87. package/lib/cjs/persistent/cache/index.d.ts +0 -3
  88. package/lib/cjs/persistent/cache/index.js +0 -12
  89. package/lib/cjs/persistent/cache/session.d.ts +0 -19
  90. package/lib/cjs/persistent/cache/session.js +0 -39
  91. package/lib/cjs/persistent/cache/storage.d.ts +0 -14
  92. package/lib/cjs/persistent/cache/storage.js +0 -88
  93. package/lib/cjs/persistent/cache/store.d.ts +0 -16
  94. package/lib/cjs/persistent/cache/store.js +0 -112
  95. package/lib/cjs/persistent/context/index.d.ts +0 -3
  96. package/lib/cjs/persistent/context/index.js +0 -5
  97. package/lib/cjs/persistent/decorators/global.d.ts +0 -1
  98. package/lib/cjs/persistent/decorators/global.js +0 -25
  99. package/lib/cjs/persistent/decorators/session.d.ts +0 -1
  100. package/lib/cjs/persistent/decorators/session.js +0 -27
  101. package/lib/cjs/persistent/index.d.ts +0 -6
  102. package/lib/cjs/persistent/index.js +0 -18
  103. package/lib/cjs/persistent/interfaces/context.d.ts +0 -5
  104. package/lib/cjs/persistent/interfaces/context.js +0 -2
  105. package/lib/cjs/persistent/interfaces/system.d.ts +0 -47
  106. package/lib/cjs/persistent/interfaces/system.js +0 -29
  107. package/lib/cjs/persistent/system/index.d.ts +0 -7
  108. package/lib/cjs/persistent/system/index.js +0 -44
  109. package/lib/cjs/persistent/utils/memory.d.ts +0 -8
  110. package/lib/cjs/persistent/utils/memory.js +0 -44
  111. package/lib/cjs/persistent/utils/timer.d.ts +0 -14
  112. package/lib/cjs/persistent/utils/timer.js +0 -21
  113. package/lib/cjs/playground/build/client/assets/AddRounded-ByHfnsiW.js +0 -4
  114. package/lib/cjs/playground/build/client/assets/Button-DLrxHRm7.js +0 -1
  115. package/lib/cjs/playground/build/client/assets/Container-CgITmmbk.js +0 -1
  116. package/lib/cjs/playground/build/client/assets/Divider-B_Wx9srO.js +0 -1
  117. package/lib/cjs/playground/build/client/assets/List-juBjUmfP.js +0 -1
  118. package/lib/cjs/playground/build/client/assets/ListItemText-DgWZmgzc.js +0 -1
  119. package/lib/cjs/playground/build/client/assets/MenuItem-D_5SuVKQ.js +0 -1
  120. package/lib/cjs/playground/build/client/assets/Modal-BwXR_5Bh.js +0 -1
  121. package/lib/cjs/playground/build/client/assets/TableRow-B9hAmlnV.js +0 -2
  122. package/lib/cjs/playground/build/client/assets/TextField-UybdTIGB.js +0 -3
  123. package/lib/cjs/playground/build/client/assets/Tooltip-BGcUWUcF.js +0 -1
  124. package/lib/cjs/playground/build/client/assets/auth-CD1rXHzz.js +0 -1
  125. package/lib/cjs/playground/build/client/assets/auth-GyTIVKy5.js +0 -1
  126. package/lib/cjs/playground/build/client/assets/confirm-Dr0pbiV6.js +0 -1
  127. package/lib/cjs/playground/build/client/assets/dividerClasses-CIiqeEPO.js +0 -1
  128. package/lib/cjs/playground/build/client/assets/entry.client-D6FYz1yh.js +0 -13
  129. package/lib/cjs/playground/build/client/assets/index-CJ0wdt6Z.js +0 -1
  130. package/lib/cjs/playground/build/client/assets/index-CQc11yq_.js +0 -1153
  131. package/lib/cjs/playground/build/client/assets/index-Cr4I-4J2.js +0 -1
  132. package/lib/cjs/playground/build/client/assets/index-CtPqstFl.js +0 -26
  133. package/lib/cjs/playground/build/client/assets/index-Ct_NE85o.js +0 -1
  134. package/lib/cjs/playground/build/client/assets/index-D0I6xwmb.js +0 -1
  135. package/lib/cjs/playground/build/client/assets/index-DmDCpKb3.js +0 -1
  136. package/lib/cjs/playground/build/client/assets/index-DsSkAwyn.js +0 -1
  137. package/lib/cjs/playground/build/client/assets/index-_DMgWZ3Y.js +0 -1
  138. package/lib/cjs/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +0 -1
  139. package/lib/cjs/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +0 -1
  140. package/lib/cjs/playground/build/client/assets/manifest-c06e9a7f.js +0 -1
  141. package/lib/cjs/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +0 -1
  142. package/lib/cjs/playground/build/client/assets/playground-Hl52p9f5.js +0 -108
  143. package/lib/cjs/playground/build/client/assets/root-CQTBmuv8.js +0 -1
  144. package/lib/cjs/playground/build/client/assets/toast-CsAH5FIf.js +0 -1
  145. package/lib/cjs/playground/build/client/assets/use-request-BZNkzlTr.js +0 -1
  146. package/lib/cjs/playground/build/client/favicon.ico +0 -0
  147. package/lib/cjs/playground/build/client/index.html +0 -6
  148. package/lib/cjs/playground/index.d.ts +0 -2
  149. package/lib/cjs/playground/index.js +0 -135
  150. package/lib/cjs/scheduler/controllers/index.d.ts +0 -19
  151. package/lib/cjs/scheduler/controllers/index.js +0 -62
  152. package/lib/cjs/scheduler/decorators/index.d.ts +0 -9
  153. package/lib/cjs/scheduler/decorators/index.js +0 -21
  154. package/lib/cjs/scheduler/handlers/index.d.ts +0 -19
  155. package/lib/cjs/scheduler/handlers/index.js +0 -62
  156. package/lib/cjs/scheduler/index.d.ts +0 -24
  157. package/lib/cjs/scheduler/index.js +0 -110
  158. package/lib/cjs/scheduler/models/history.d.ts +0 -10
  159. package/lib/cjs/scheduler/models/history.js +0 -50
  160. package/lib/cjs/server/constants/index.d.ts +0 -78
  161. package/lib/cjs/server/constants/index.js +0 -372
  162. package/lib/cjs/server/context/index.d.ts +0 -17
  163. package/lib/cjs/server/context/index.js +0 -33
  164. package/lib/cjs/server/controller/index.d.ts +0 -3
  165. package/lib/cjs/server/controller/index.js +0 -217
  166. package/lib/cjs/server/controllers/index.d.ts +0 -5
  167. package/lib/cjs/server/controllers/index.js +0 -72
  168. package/lib/cjs/server/core/index.d.ts +0 -16
  169. package/lib/cjs/server/core/index.js +0 -110
  170. package/lib/cjs/server/core/middleware/body-parser.d.ts +0 -2
  171. package/lib/cjs/server/core/middleware/body-parser.js +0 -27
  172. package/lib/cjs/server/core/middleware/cors.d.ts +0 -4
  173. package/lib/cjs/server/core/middleware/cors.js +0 -32
  174. package/lib/cjs/server/core/middleware/logger.d.ts +0 -2
  175. package/lib/cjs/server/core/middleware/logger.js +0 -15
  176. package/lib/cjs/server/decorators/controller.d.ts +0 -3
  177. package/lib/cjs/server/decorators/controller.js +0 -14
  178. package/lib/cjs/server/decorators/field.d.ts +0 -2
  179. package/lib/cjs/server/decorators/field.js +0 -36
  180. package/lib/cjs/server/decorators/handler.d.ts +0 -3
  181. package/lib/cjs/server/decorators/handler.js +0 -14
  182. package/lib/cjs/server/decorators/index.d.ts +0 -7
  183. package/lib/cjs/server/decorators/index.js +0 -26
  184. package/lib/cjs/server/decorators/is-public-method.d.ts +0 -3
  185. package/lib/cjs/server/decorators/is-public-method.js +0 -16
  186. package/lib/cjs/server/decorators/is-public.d.ts +0 -3
  187. package/lib/cjs/server/decorators/is-public.js +0 -14
  188. package/lib/cjs/server/decorators/method.d.ts +0 -3
  189. package/lib/cjs/server/decorators/method.js +0 -16
  190. package/lib/cjs/server/decorators/payload.d.ts +0 -3
  191. package/lib/cjs/server/decorators/payload.js +0 -15
  192. package/lib/cjs/server/handlers/index.d.ts +0 -5
  193. package/lib/cjs/server/handlers/index.js +0 -72
  194. package/lib/cjs/server/helpers/index.d.ts +0 -17
  195. package/lib/cjs/server/helpers/index.js +0 -39
  196. package/lib/cjs/server/index.d.ts +0 -12
  197. package/lib/cjs/server/index.js +0 -176
  198. package/lib/cjs/server/security/controller/auth.d.ts +0 -76
  199. package/lib/cjs/server/security/controller/auth.js +0 -346
  200. package/lib/cjs/server/security/index.d.ts +0 -2
  201. package/lib/cjs/server/security/index.js +0 -10
  202. package/lib/cjs/server/security/jwt/index.d.ts +0 -23
  203. package/lib/cjs/server/security/jwt/index.js +0 -108
  204. package/lib/cjs/server/security/middleware/autorization.d.ts +0 -3
  205. package/lib/cjs/server/security/middleware/autorization.js +0 -46
  206. package/lib/cjs/server/security/middleware/permission.d.ts +0 -3
  207. package/lib/cjs/server/security/middleware/permission.js +0 -138
  208. package/lib/cjs/server/security/models/crp.d.ts +0 -8
  209. package/lib/cjs/server/security/models/crp.js +0 -42
  210. package/lib/cjs/server/security/models/ke.d.ts +0 -7
  211. package/lib/cjs/server/security/models/ke.js +0 -38
  212. package/lib/cjs/server/security/models/rl.d.ts +0 -9
  213. package/lib/cjs/server/security/models/rl.js +0 -50
  214. package/lib/cjs/server/security/models/se.d.ts +0 -11
  215. package/lib/cjs/server/security/models/se.js +0 -54
  216. package/lib/cjs/server/security/models/usr.d.ts +0 -14
  217. package/lib/cjs/server/security/models/usr.js +0 -82
  218. package/lib/cjs/server/services/delete.d.ts +0 -13
  219. package/lib/cjs/server/services/delete.js +0 -49
  220. package/lib/cjs/server/services/get.d.ts +0 -4
  221. package/lib/cjs/server/services/get.js +0 -145
  222. package/lib/cjs/server/services/insert.d.ts +0 -13
  223. package/lib/cjs/server/services/insert.js +0 -74
  224. package/lib/cjs/server/services/update.d.ts +0 -13
  225. package/lib/cjs/server/services/update.js +0 -60
  226. package/lib/cjs/system/index.d.ts +0 -13
  227. 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,3 +0,0 @@
1
- import { AsyncLocalStorage } from "async_hooks";
2
- declare const context: AsyncLocalStorage<unknown>;
3
- export default context;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const async_hooks_1 = require("async_hooks");
4
- const context = new async_hooks_1.AsyncLocalStorage();
5
- exports.default = context;
@@ -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,5 +0,0 @@
1
- import type { Store } from "../cache/index.js";
2
- export interface ContextSession {
3
- sessionId: string;
4
- store: Store;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,7 +0,0 @@
1
- import type { OpposerSystemConfigOptions } from "../interfaces/system.js";
2
- declare const _default: {
3
- settings: OpposerSystemConfigOptions;
4
- getSettingsFile(): OpposerSystemConfigOptions;
5
- getAllSessionData(): void;
6
- };
7
- export default _default;
@@ -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 };