@ug.software/opposer 3.0.10

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 (447) hide show
  1. package/README.md +504 -0
  2. package/lib/bin/commands/build.js +75 -0
  3. package/lib/bin/commands/generate/api-key.js +28 -0
  4. package/lib/bin/commands/generate/jwt-key.js +46 -0
  5. package/lib/bin/commands/init.js +169 -0
  6. package/lib/bin/helpers/crypto.js +33 -0
  7. package/lib/bin/opposer.js +26 -0
  8. package/lib/cjs/examples/full-app/index.d.ts +1 -0
  9. package/lib/cjs/examples/full-app/index.js +102 -0
  10. package/lib/cjs/examples/full-app/models/author.d.ts +7 -0
  11. package/lib/cjs/examples/full-app/models/author.js +42 -0
  12. package/lib/cjs/examples/full-app/models/book.d.ts +9 -0
  13. package/lib/cjs/examples/full-app/models/book.js +51 -0
  14. package/lib/cjs/examples/full-app/models/category.d.ts +4 -0
  15. package/lib/cjs/examples/full-app/models/category.js +26 -0
  16. package/lib/cjs/examples/full-app/schedules/catalog-refresh.d.ts +28 -0
  17. package/lib/cjs/examples/full-app/schedules/catalog-refresh.js +149 -0
  18. package/lib/cjs/examples/full-app/schedules/inventory-sync.d.ts +12 -0
  19. package/lib/cjs/examples/full-app/schedules/inventory-sync.js +61 -0
  20. package/lib/cjs/examples/full-app/schedules/library-alerts.d.ts +11 -0
  21. package/lib/cjs/examples/full-app/schedules/library-alerts.js +55 -0
  22. package/lib/cjs/examples/minimal/src/handlers/book.d.ts +11 -0
  23. package/lib/cjs/examples/minimal/src/handlers/book.js +51 -0
  24. package/lib/cjs/examples/minimal/src/index.d.ts +1 -0
  25. package/lib/cjs/examples/minimal/src/index.js +14 -0
  26. package/lib/cjs/examples/minimal/src/models/books.d.ts +4 -0
  27. package/lib/cjs/examples/minimal/src/models/books.js +26 -0
  28. package/lib/cjs/examples/orm/models/permission.d.ts +6 -0
  29. package/lib/cjs/examples/orm/models/permission.js +38 -0
  30. package/lib/cjs/examples/orm/models/profile.d.ts +7 -0
  31. package/lib/cjs/examples/orm/models/profile.js +42 -0
  32. package/lib/cjs/examples/orm/models/user.d.ts +11 -0
  33. package/lib/cjs/examples/orm/models/user.js +70 -0
  34. package/lib/cjs/examples/orm/mysql/index.d.ts +1 -0
  35. package/lib/cjs/examples/orm/mysql/index.js +44 -0
  36. package/lib/cjs/examples/orm/postgres/index.d.ts +1 -0
  37. package/lib/cjs/examples/orm/postgres/index.js +40 -0
  38. package/lib/cjs/examples/orm/sqlite/index.d.ts +1 -0
  39. package/lib/cjs/examples/orm/sqlite/index.js +41 -0
  40. package/lib/cjs/index.d.ts +2 -0
  41. package/lib/cjs/index.js +23 -0
  42. package/lib/cjs/interfaces/controller.d.ts +109 -0
  43. package/lib/cjs/interfaces/controller.js +2 -0
  44. package/lib/cjs/interfaces/field.d.ts +23 -0
  45. package/lib/cjs/interfaces/field.js +2 -0
  46. package/lib/cjs/interfaces/handler.d.ts +18 -0
  47. package/lib/cjs/interfaces/handler.js +2 -0
  48. package/lib/cjs/interfaces/jwt.d.ts +21 -0
  49. package/lib/cjs/interfaces/jwt.js +2 -0
  50. package/lib/cjs/interfaces/model.d.ts +9 -0
  51. package/lib/cjs/interfaces/model.js +2 -0
  52. package/lib/cjs/interfaces/request.d.ts +13 -0
  53. package/lib/cjs/interfaces/request.js +2 -0
  54. package/lib/cjs/interfaces/schema.d.ts +9 -0
  55. package/lib/cjs/interfaces/schema.js +2 -0
  56. package/lib/cjs/interfaces/security.d.ts +32 -0
  57. package/lib/cjs/interfaces/security.js +2 -0
  58. package/lib/cjs/interfaces/server.d.ts +37 -0
  59. package/lib/cjs/interfaces/server.js +2 -0
  60. package/lib/cjs/interfaces/system.d.ts +41 -0
  61. package/lib/cjs/interfaces/system.js +2 -0
  62. package/lib/cjs/orm/decorators/index.d.ts +33 -0
  63. package/lib/cjs/orm/decorators/index.js +131 -0
  64. package/lib/cjs/orm/driver/mysql.d.ts +14 -0
  65. package/lib/cjs/orm/driver/mysql.js +103 -0
  66. package/lib/cjs/orm/driver/postgres.d.ts +14 -0
  67. package/lib/cjs/orm/driver/postgres.js +105 -0
  68. package/lib/cjs/orm/driver/sqlite.d.ts +14 -0
  69. package/lib/cjs/orm/driver/sqlite.js +143 -0
  70. package/lib/cjs/orm/index.d.ts +8 -0
  71. package/lib/cjs/orm/index.js +28 -0
  72. package/lib/cjs/orm/metadata.d.ts +47 -0
  73. package/lib/cjs/orm/metadata.js +47 -0
  74. package/lib/cjs/orm/opposer.d.ts +30 -0
  75. package/lib/cjs/orm/opposer.js +33 -0
  76. package/lib/cjs/orm/query-builder.d.ts +32 -0
  77. package/lib/cjs/orm/query-builder.js +278 -0
  78. package/lib/cjs/orm/repository.d.ts +54 -0
  79. package/lib/cjs/orm/repository.js +325 -0
  80. package/lib/cjs/orm/validation.d.ts +44 -0
  81. package/lib/cjs/orm/validation.js +128 -0
  82. package/lib/cjs/package.json +3 -0
  83. package/lib/cjs/persistent/cache/core-context.d.ts +17 -0
  84. package/lib/cjs/persistent/cache/core-context.js +39 -0
  85. package/lib/cjs/persistent/cache/global.d.ts +18 -0
  86. package/lib/cjs/persistent/cache/global.js +22 -0
  87. package/lib/cjs/persistent/cache/index.d.ts +3 -0
  88. package/lib/cjs/persistent/cache/index.js +12 -0
  89. package/lib/cjs/persistent/cache/session.d.ts +19 -0
  90. package/lib/cjs/persistent/cache/session.js +39 -0
  91. package/lib/cjs/persistent/cache/storage.d.ts +14 -0
  92. package/lib/cjs/persistent/cache/storage.js +88 -0
  93. package/lib/cjs/persistent/cache/store.d.ts +16 -0
  94. package/lib/cjs/persistent/cache/store.js +112 -0
  95. package/lib/cjs/persistent/context/index.d.ts +3 -0
  96. package/lib/cjs/persistent/context/index.js +5 -0
  97. package/lib/cjs/persistent/decorators/global.d.ts +1 -0
  98. package/lib/cjs/persistent/decorators/global.js +25 -0
  99. package/lib/cjs/persistent/decorators/session.d.ts +1 -0
  100. package/lib/cjs/persistent/decorators/session.js +27 -0
  101. package/lib/cjs/persistent/index.d.ts +6 -0
  102. package/lib/cjs/persistent/index.js +18 -0
  103. package/lib/cjs/persistent/interfaces/context.d.ts +5 -0
  104. package/lib/cjs/persistent/interfaces/context.js +2 -0
  105. package/lib/cjs/persistent/interfaces/system.d.ts +47 -0
  106. package/lib/cjs/persistent/interfaces/system.js +29 -0
  107. package/lib/cjs/persistent/system/index.d.ts +7 -0
  108. package/lib/cjs/persistent/system/index.js +44 -0
  109. package/lib/cjs/persistent/utils/memory.d.ts +8 -0
  110. package/lib/cjs/persistent/utils/memory.js +44 -0
  111. package/lib/cjs/persistent/utils/timer.d.ts +14 -0
  112. package/lib/cjs/persistent/utils/timer.js +21 -0
  113. package/lib/cjs/playground/build/client/assets/AddRounded-ByHfnsiW.js +4 -0
  114. package/lib/cjs/playground/build/client/assets/Button-DLrxHRm7.js +1 -0
  115. package/lib/cjs/playground/build/client/assets/Container-CgITmmbk.js +1 -0
  116. package/lib/cjs/playground/build/client/assets/Divider-B_Wx9srO.js +1 -0
  117. package/lib/cjs/playground/build/client/assets/List-juBjUmfP.js +1 -0
  118. package/lib/cjs/playground/build/client/assets/ListItemText-DgWZmgzc.js +1 -0
  119. package/lib/cjs/playground/build/client/assets/MenuItem-D_5SuVKQ.js +1 -0
  120. package/lib/cjs/playground/build/client/assets/Modal-BwXR_5Bh.js +1 -0
  121. package/lib/cjs/playground/build/client/assets/TableRow-B9hAmlnV.js +2 -0
  122. package/lib/cjs/playground/build/client/assets/TextField-UybdTIGB.js +3 -0
  123. package/lib/cjs/playground/build/client/assets/Tooltip-BGcUWUcF.js +1 -0
  124. package/lib/cjs/playground/build/client/assets/auth-CD1rXHzz.js +1 -0
  125. package/lib/cjs/playground/build/client/assets/auth-GyTIVKy5.js +1 -0
  126. package/lib/cjs/playground/build/client/assets/confirm-Dr0pbiV6.js +1 -0
  127. package/lib/cjs/playground/build/client/assets/dividerClasses-CIiqeEPO.js +1 -0
  128. package/lib/cjs/playground/build/client/assets/entry.client-D6FYz1yh.js +13 -0
  129. package/lib/cjs/playground/build/client/assets/index-CJ0wdt6Z.js +1 -0
  130. package/lib/cjs/playground/build/client/assets/index-CQc11yq_.js +1153 -0
  131. package/lib/cjs/playground/build/client/assets/index-Cr4I-4J2.js +1 -0
  132. package/lib/cjs/playground/build/client/assets/index-CtPqstFl.js +26 -0
  133. package/lib/cjs/playground/build/client/assets/index-Ct_NE85o.js +1 -0
  134. package/lib/cjs/playground/build/client/assets/index-D0I6xwmb.js +1 -0
  135. package/lib/cjs/playground/build/client/assets/index-DmDCpKb3.js +1 -0
  136. package/lib/cjs/playground/build/client/assets/index-DsSkAwyn.js +1 -0
  137. package/lib/cjs/playground/build/client/assets/index-_DMgWZ3Y.js +1 -0
  138. package/lib/cjs/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +1 -0
  139. package/lib/cjs/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +1 -0
  140. package/lib/cjs/playground/build/client/assets/manifest-c06e9a7f.js +1 -0
  141. package/lib/cjs/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +1 -0
  142. package/lib/cjs/playground/build/client/assets/playground-Hl52p9f5.js +108 -0
  143. package/lib/cjs/playground/build/client/assets/root-CQTBmuv8.js +1 -0
  144. package/lib/cjs/playground/build/client/assets/toast-CsAH5FIf.js +1 -0
  145. package/lib/cjs/playground/build/client/assets/use-request-BZNkzlTr.js +1 -0
  146. package/lib/cjs/playground/build/client/favicon.ico +0 -0
  147. package/lib/cjs/playground/build/client/index.html +6 -0
  148. package/lib/cjs/playground/index.d.ts +2 -0
  149. package/lib/cjs/playground/index.js +135 -0
  150. package/lib/cjs/scheduler/controllers/index.d.ts +19 -0
  151. package/lib/cjs/scheduler/controllers/index.js +62 -0
  152. package/lib/cjs/scheduler/decorators/index.d.ts +9 -0
  153. package/lib/cjs/scheduler/decorators/index.js +21 -0
  154. package/lib/cjs/scheduler/handlers/index.d.ts +19 -0
  155. package/lib/cjs/scheduler/handlers/index.js +62 -0
  156. package/lib/cjs/scheduler/index.d.ts +24 -0
  157. package/lib/cjs/scheduler/index.js +110 -0
  158. package/lib/cjs/scheduler/models/history.d.ts +10 -0
  159. package/lib/cjs/scheduler/models/history.js +50 -0
  160. package/lib/cjs/server/constants/index.d.ts +78 -0
  161. package/lib/cjs/server/constants/index.js +372 -0
  162. package/lib/cjs/server/context/index.d.ts +17 -0
  163. package/lib/cjs/server/context/index.js +33 -0
  164. package/lib/cjs/server/controller/index.d.ts +3 -0
  165. package/lib/cjs/server/controller/index.js +217 -0
  166. package/lib/cjs/server/controllers/index.d.ts +5 -0
  167. package/lib/cjs/server/controllers/index.js +72 -0
  168. package/lib/cjs/server/core/index.d.ts +16 -0
  169. package/lib/cjs/server/core/index.js +110 -0
  170. package/lib/cjs/server/core/middleware/body-parser.d.ts +2 -0
  171. package/lib/cjs/server/core/middleware/body-parser.js +27 -0
  172. package/lib/cjs/server/core/middleware/cors.d.ts +4 -0
  173. package/lib/cjs/server/core/middleware/cors.js +32 -0
  174. package/lib/cjs/server/core/middleware/logger.d.ts +2 -0
  175. package/lib/cjs/server/core/middleware/logger.js +15 -0
  176. package/lib/cjs/server/decorators/controller.d.ts +3 -0
  177. package/lib/cjs/server/decorators/controller.js +14 -0
  178. package/lib/cjs/server/decorators/field.d.ts +2 -0
  179. package/lib/cjs/server/decorators/field.js +36 -0
  180. package/lib/cjs/server/decorators/handler.d.ts +3 -0
  181. package/lib/cjs/server/decorators/handler.js +14 -0
  182. package/lib/cjs/server/decorators/index.d.ts +7 -0
  183. package/lib/cjs/server/decorators/index.js +26 -0
  184. package/lib/cjs/server/decorators/is-public-method.d.ts +3 -0
  185. package/lib/cjs/server/decorators/is-public-method.js +16 -0
  186. package/lib/cjs/server/decorators/is-public.d.ts +3 -0
  187. package/lib/cjs/server/decorators/is-public.js +14 -0
  188. package/lib/cjs/server/decorators/method.d.ts +3 -0
  189. package/lib/cjs/server/decorators/method.js +16 -0
  190. package/lib/cjs/server/decorators/payload.d.ts +3 -0
  191. package/lib/cjs/server/decorators/payload.js +15 -0
  192. package/lib/cjs/server/handlers/index.d.ts +5 -0
  193. package/lib/cjs/server/handlers/index.js +72 -0
  194. package/lib/cjs/server/helpers/index.d.ts +17 -0
  195. package/lib/cjs/server/helpers/index.js +39 -0
  196. package/lib/cjs/server/index.d.ts +12 -0
  197. package/lib/cjs/server/index.js +176 -0
  198. package/lib/cjs/server/security/controller/auth.d.ts +76 -0
  199. package/lib/cjs/server/security/controller/auth.js +346 -0
  200. package/lib/cjs/server/security/index.d.ts +2 -0
  201. package/lib/cjs/server/security/index.js +10 -0
  202. package/lib/cjs/server/security/jwt/index.d.ts +23 -0
  203. package/lib/cjs/server/security/jwt/index.js +108 -0
  204. package/lib/cjs/server/security/middleware/autorization.d.ts +3 -0
  205. package/lib/cjs/server/security/middleware/autorization.js +46 -0
  206. package/lib/cjs/server/security/middleware/permission.d.ts +3 -0
  207. package/lib/cjs/server/security/middleware/permission.js +138 -0
  208. package/lib/cjs/server/security/models/crp.d.ts +8 -0
  209. package/lib/cjs/server/security/models/crp.js +42 -0
  210. package/lib/cjs/server/security/models/ke.d.ts +7 -0
  211. package/lib/cjs/server/security/models/ke.js +38 -0
  212. package/lib/cjs/server/security/models/rl.d.ts +9 -0
  213. package/lib/cjs/server/security/models/rl.js +50 -0
  214. package/lib/cjs/server/security/models/se.d.ts +11 -0
  215. package/lib/cjs/server/security/models/se.js +54 -0
  216. package/lib/cjs/server/security/models/usr.d.ts +14 -0
  217. package/lib/cjs/server/security/models/usr.js +82 -0
  218. package/lib/cjs/server/services/delete.d.ts +13 -0
  219. package/lib/cjs/server/services/delete.js +49 -0
  220. package/lib/cjs/server/services/get.d.ts +4 -0
  221. package/lib/cjs/server/services/get.js +145 -0
  222. package/lib/cjs/server/services/insert.d.ts +13 -0
  223. package/lib/cjs/server/services/insert.js +74 -0
  224. package/lib/cjs/server/services/update.d.ts +13 -0
  225. package/lib/cjs/server/services/update.js +60 -0
  226. package/lib/cjs/system/index.d.ts +13 -0
  227. package/lib/cjs/system/index.js +237 -0
  228. package/lib/esm/examples/full-app/index.d.ts +1 -0
  229. package/lib/esm/examples/full-app/index.js +64 -0
  230. package/lib/esm/examples/full-app/models/author.d.ts +7 -0
  231. package/lib/esm/examples/full-app/models/author.js +37 -0
  232. package/lib/esm/examples/full-app/models/book.d.ts +9 -0
  233. package/lib/esm/examples/full-app/models/book.js +46 -0
  234. package/lib/esm/examples/full-app/models/category.d.ts +4 -0
  235. package/lib/esm/examples/full-app/models/category.js +24 -0
  236. package/lib/esm/examples/full-app/schedules/catalog-refresh.d.ts +28 -0
  237. package/lib/esm/examples/full-app/schedules/catalog-refresh.js +143 -0
  238. package/lib/esm/examples/full-app/schedules/inventory-sync.d.ts +12 -0
  239. package/lib/esm/examples/full-app/schedules/inventory-sync.js +55 -0
  240. package/lib/esm/examples/full-app/schedules/library-alerts.d.ts +11 -0
  241. package/lib/esm/examples/full-app/schedules/library-alerts.js +52 -0
  242. package/lib/esm/examples/minimal/src/handlers/book.d.ts +11 -0
  243. package/lib/esm/examples/minimal/src/handlers/book.js +49 -0
  244. package/lib/esm/examples/minimal/src/index.d.ts +1 -0
  245. package/lib/esm/examples/minimal/src/index.js +9 -0
  246. package/lib/esm/examples/minimal/src/models/books.d.ts +4 -0
  247. package/lib/esm/examples/minimal/src/models/books.js +24 -0
  248. package/lib/esm/examples/orm/models/permission.d.ts +6 -0
  249. package/lib/esm/examples/orm/models/permission.js +33 -0
  250. package/lib/esm/examples/orm/models/profile.d.ts +7 -0
  251. package/lib/esm/examples/orm/models/profile.js +37 -0
  252. package/lib/esm/examples/orm/models/user.d.ts +11 -0
  253. package/lib/esm/examples/orm/models/user.js +65 -0
  254. package/lib/esm/examples/orm/mysql/index.d.ts +1 -0
  255. package/lib/esm/examples/orm/mysql/index.js +39 -0
  256. package/lib/esm/examples/orm/postgres/index.d.ts +1 -0
  257. package/lib/esm/examples/orm/postgres/index.js +35 -0
  258. package/lib/esm/examples/orm/sqlite/index.d.ts +1 -0
  259. package/lib/esm/examples/orm/sqlite/index.js +36 -0
  260. package/lib/esm/index.d.ts +2 -0
  261. package/lib/esm/index.js +2 -0
  262. package/lib/esm/interfaces/controller.d.ts +109 -0
  263. package/lib/esm/interfaces/controller.js +1 -0
  264. package/lib/esm/interfaces/field.d.ts +23 -0
  265. package/lib/esm/interfaces/field.js +1 -0
  266. package/lib/esm/interfaces/handler.d.ts +18 -0
  267. package/lib/esm/interfaces/handler.js +1 -0
  268. package/lib/esm/interfaces/jwt.d.ts +21 -0
  269. package/lib/esm/interfaces/jwt.js +1 -0
  270. package/lib/esm/interfaces/model.d.ts +9 -0
  271. package/lib/esm/interfaces/model.js +1 -0
  272. package/lib/esm/interfaces/request.d.ts +13 -0
  273. package/lib/esm/interfaces/request.js +1 -0
  274. package/lib/esm/interfaces/schema.d.ts +9 -0
  275. package/lib/esm/interfaces/schema.js +1 -0
  276. package/lib/esm/interfaces/security.d.ts +32 -0
  277. package/lib/esm/interfaces/security.js +1 -0
  278. package/lib/esm/interfaces/server.d.ts +37 -0
  279. package/lib/esm/interfaces/server.js +1 -0
  280. package/lib/esm/interfaces/system.d.ts +41 -0
  281. package/lib/esm/interfaces/system.js +1 -0
  282. package/lib/esm/orm/decorators/index.d.ts +33 -0
  283. package/lib/esm/orm/decorators/index.js +118 -0
  284. package/lib/esm/orm/driver/mysql.d.ts +14 -0
  285. package/lib/esm/orm/driver/mysql.js +66 -0
  286. package/lib/esm/orm/driver/postgres.d.ts +14 -0
  287. package/lib/esm/orm/driver/postgres.js +68 -0
  288. package/lib/esm/orm/driver/sqlite.d.ts +14 -0
  289. package/lib/esm/orm/driver/sqlite.js +106 -0
  290. package/lib/esm/orm/index.d.ts +8 -0
  291. package/lib/esm/orm/index.js +8 -0
  292. package/lib/esm/orm/metadata.d.ts +47 -0
  293. package/lib/esm/orm/metadata.js +43 -0
  294. package/lib/esm/orm/opposer.d.ts +30 -0
  295. package/lib/esm/orm/opposer.js +29 -0
  296. package/lib/esm/orm/query-builder.d.ts +32 -0
  297. package/lib/esm/orm/query-builder.js +274 -0
  298. package/lib/esm/orm/repository.d.ts +54 -0
  299. package/lib/esm/orm/repository.js +318 -0
  300. package/lib/esm/orm/validation.d.ts +44 -0
  301. package/lib/esm/orm/validation.js +122 -0
  302. package/lib/esm/persistent/cache/core-context.d.ts +17 -0
  303. package/lib/esm/persistent/cache/core-context.js +34 -0
  304. package/lib/esm/persistent/cache/global.d.ts +18 -0
  305. package/lib/esm/persistent/cache/global.js +17 -0
  306. package/lib/esm/persistent/cache/index.d.ts +3 -0
  307. package/lib/esm/persistent/cache/index.js +3 -0
  308. package/lib/esm/persistent/cache/session.d.ts +19 -0
  309. package/lib/esm/persistent/cache/session.js +34 -0
  310. package/lib/esm/persistent/cache/storage.d.ts +14 -0
  311. package/lib/esm/persistent/cache/storage.js +82 -0
  312. package/lib/esm/persistent/cache/store.d.ts +16 -0
  313. package/lib/esm/persistent/cache/store.js +106 -0
  314. package/lib/esm/persistent/context/index.d.ts +3 -0
  315. package/lib/esm/persistent/context/index.js +3 -0
  316. package/lib/esm/persistent/decorators/global.d.ts +1 -0
  317. package/lib/esm/persistent/decorators/global.js +19 -0
  318. package/lib/esm/persistent/decorators/session.d.ts +1 -0
  319. package/lib/esm/persistent/decorators/session.js +21 -0
  320. package/lib/esm/persistent/index.d.ts +6 -0
  321. package/lib/esm/persistent/index.js +6 -0
  322. package/lib/esm/persistent/interfaces/context.d.ts +5 -0
  323. package/lib/esm/persistent/interfaces/context.js +1 -0
  324. package/lib/esm/persistent/interfaces/system.d.ts +47 -0
  325. package/lib/esm/persistent/interfaces/system.js +26 -0
  326. package/lib/esm/persistent/system/index.d.ts +7 -0
  327. package/lib/esm/persistent/system/index.js +39 -0
  328. package/lib/esm/persistent/utils/memory.d.ts +8 -0
  329. package/lib/esm/persistent/utils/memory.js +42 -0
  330. package/lib/esm/persistent/utils/timer.d.ts +14 -0
  331. package/lib/esm/persistent/utils/timer.js +16 -0
  332. package/lib/esm/playground/build/client/assets/AddRounded-ByHfnsiW.js +4 -0
  333. package/lib/esm/playground/build/client/assets/Button-DLrxHRm7.js +1 -0
  334. package/lib/esm/playground/build/client/assets/Container-CgITmmbk.js +1 -0
  335. package/lib/esm/playground/build/client/assets/Divider-B_Wx9srO.js +1 -0
  336. package/lib/esm/playground/build/client/assets/List-juBjUmfP.js +1 -0
  337. package/lib/esm/playground/build/client/assets/ListItemText-DgWZmgzc.js +1 -0
  338. package/lib/esm/playground/build/client/assets/MenuItem-D_5SuVKQ.js +1 -0
  339. package/lib/esm/playground/build/client/assets/Modal-BwXR_5Bh.js +1 -0
  340. package/lib/esm/playground/build/client/assets/TableRow-B9hAmlnV.js +2 -0
  341. package/lib/esm/playground/build/client/assets/TextField-UybdTIGB.js +3 -0
  342. package/lib/esm/playground/build/client/assets/Tooltip-BGcUWUcF.js +1 -0
  343. package/lib/esm/playground/build/client/assets/auth-CD1rXHzz.js +1 -0
  344. package/lib/esm/playground/build/client/assets/auth-GyTIVKy5.js +1 -0
  345. package/lib/esm/playground/build/client/assets/confirm-Dr0pbiV6.js +1 -0
  346. package/lib/esm/playground/build/client/assets/dividerClasses-CIiqeEPO.js +1 -0
  347. package/lib/esm/playground/build/client/assets/entry.client-D6FYz1yh.js +13 -0
  348. package/lib/esm/playground/build/client/assets/index-CJ0wdt6Z.js +1 -0
  349. package/lib/esm/playground/build/client/assets/index-CQc11yq_.js +1153 -0
  350. package/lib/esm/playground/build/client/assets/index-Cr4I-4J2.js +1 -0
  351. package/lib/esm/playground/build/client/assets/index-CtPqstFl.js +26 -0
  352. package/lib/esm/playground/build/client/assets/index-Ct_NE85o.js +1 -0
  353. package/lib/esm/playground/build/client/assets/index-D0I6xwmb.js +1 -0
  354. package/lib/esm/playground/build/client/assets/index-DmDCpKb3.js +1 -0
  355. package/lib/esm/playground/build/client/assets/index-DsSkAwyn.js +1 -0
  356. package/lib/esm/playground/build/client/assets/index-_DMgWZ3Y.js +1 -0
  357. package/lib/esm/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +1 -0
  358. package/lib/esm/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +1 -0
  359. package/lib/esm/playground/build/client/assets/manifest-c06e9a7f.js +1 -0
  360. package/lib/esm/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +1 -0
  361. package/lib/esm/playground/build/client/assets/playground-Hl52p9f5.js +108 -0
  362. package/lib/esm/playground/build/client/assets/root-CQTBmuv8.js +1 -0
  363. package/lib/esm/playground/build/client/assets/toast-CsAH5FIf.js +1 -0
  364. package/lib/esm/playground/build/client/assets/use-request-BZNkzlTr.js +1 -0
  365. package/lib/esm/playground/build/client/favicon.ico +0 -0
  366. package/lib/esm/playground/build/client/index.html +6 -0
  367. package/lib/esm/playground/index.d.ts +2 -0
  368. package/lib/esm/playground/index.js +129 -0
  369. package/lib/esm/scheduler/controllers/index.d.ts +19 -0
  370. package/lib/esm/scheduler/controllers/index.js +57 -0
  371. package/lib/esm/scheduler/decorators/index.d.ts +9 -0
  372. package/lib/esm/scheduler/decorators/index.js +16 -0
  373. package/lib/esm/scheduler/handlers/index.d.ts +19 -0
  374. package/lib/esm/scheduler/handlers/index.js +57 -0
  375. package/lib/esm/scheduler/index.d.ts +24 -0
  376. package/lib/esm/scheduler/index.js +89 -0
  377. package/lib/esm/scheduler/models/history.d.ts +10 -0
  378. package/lib/esm/scheduler/models/history.js +48 -0
  379. package/lib/esm/server/constants/index.d.ts +78 -0
  380. package/lib/esm/server/constants/index.js +369 -0
  381. package/lib/esm/server/context/index.d.ts +17 -0
  382. package/lib/esm/server/context/index.js +31 -0
  383. package/lib/esm/server/controller/index.d.ts +3 -0
  384. package/lib/esm/server/controller/index.js +179 -0
  385. package/lib/esm/server/controllers/index.d.ts +5 -0
  386. package/lib/esm/server/controllers/index.js +31 -0
  387. package/lib/esm/server/core/index.d.ts +16 -0
  388. package/lib/esm/server/core/index.js +103 -0
  389. package/lib/esm/server/core/middleware/body-parser.d.ts +2 -0
  390. package/lib/esm/server/core/middleware/body-parser.js +24 -0
  391. package/lib/esm/server/core/middleware/cors.d.ts +4 -0
  392. package/lib/esm/server/core/middleware/cors.js +29 -0
  393. package/lib/esm/server/core/middleware/logger.d.ts +2 -0
  394. package/lib/esm/server/core/middleware/logger.js +12 -0
  395. package/lib/esm/server/decorators/controller.d.ts +3 -0
  396. package/lib/esm/server/decorators/controller.js +10 -0
  397. package/lib/esm/server/decorators/field.d.ts +2 -0
  398. package/lib/esm/server/decorators/field.js +32 -0
  399. package/lib/esm/server/decorators/handler.d.ts +3 -0
  400. package/lib/esm/server/decorators/handler.js +10 -0
  401. package/lib/esm/server/decorators/index.d.ts +7 -0
  402. package/lib/esm/server/decorators/index.js +7 -0
  403. package/lib/esm/server/decorators/is-public-method.d.ts +3 -0
  404. package/lib/esm/server/decorators/is-public-method.js +12 -0
  405. package/lib/esm/server/decorators/is-public.d.ts +3 -0
  406. package/lib/esm/server/decorators/is-public.js +10 -0
  407. package/lib/esm/server/decorators/method.d.ts +3 -0
  408. package/lib/esm/server/decorators/method.js +12 -0
  409. package/lib/esm/server/decorators/payload.d.ts +3 -0
  410. package/lib/esm/server/decorators/payload.js +11 -0
  411. package/lib/esm/server/handlers/index.d.ts +5 -0
  412. package/lib/esm/server/handlers/index.js +31 -0
  413. package/lib/esm/server/helpers/index.d.ts +17 -0
  414. package/lib/esm/server/helpers/index.js +34 -0
  415. package/lib/esm/server/index.d.ts +12 -0
  416. package/lib/esm/server/index.js +147 -0
  417. package/lib/esm/server/security/controller/auth.d.ts +76 -0
  418. package/lib/esm/server/security/controller/auth.js +341 -0
  419. package/lib/esm/server/security/index.d.ts +2 -0
  420. package/lib/esm/server/security/index.js +2 -0
  421. package/lib/esm/server/security/jwt/index.d.ts +23 -0
  422. package/lib/esm/server/security/jwt/index.js +103 -0
  423. package/lib/esm/server/security/middleware/autorization.d.ts +3 -0
  424. package/lib/esm/server/security/middleware/autorization.js +41 -0
  425. package/lib/esm/server/security/middleware/permission.d.ts +3 -0
  426. package/lib/esm/server/security/middleware/permission.js +133 -0
  427. package/lib/esm/server/security/models/crp.d.ts +8 -0
  428. package/lib/esm/server/security/models/crp.js +40 -0
  429. package/lib/esm/server/security/models/ke.d.ts +7 -0
  430. package/lib/esm/server/security/models/ke.js +36 -0
  431. package/lib/esm/server/security/models/rl.d.ts +9 -0
  432. package/lib/esm/server/security/models/rl.js +45 -0
  433. package/lib/esm/server/security/models/se.d.ts +11 -0
  434. package/lib/esm/server/security/models/se.js +52 -0
  435. package/lib/esm/server/security/models/usr.d.ts +14 -0
  436. package/lib/esm/server/security/models/usr.js +77 -0
  437. package/lib/esm/server/services/delete.d.ts +13 -0
  438. package/lib/esm/server/services/delete.js +44 -0
  439. package/lib/esm/server/services/get.d.ts +4 -0
  440. package/lib/esm/server/services/get.js +140 -0
  441. package/lib/esm/server/services/insert.d.ts +13 -0
  442. package/lib/esm/server/services/insert.js +69 -0
  443. package/lib/esm/server/services/update.d.ts +13 -0
  444. package/lib/esm/server/services/update.js +55 -0
  445. package/lib/esm/system/index.d.ts +13 -0
  446. package/lib/esm/system/index.js +197 -0
  447. package/package.json +95 -0
@@ -0,0 +1,44 @@
1
+ export type ValidationFunction = (value: unknown, context: object) => string | null;
2
+ export declare class FieldValidator {
3
+ protected _type: string | null;
4
+ protected _cases: ValidationFunction[];
5
+ protected _default: any;
6
+ get type(): string | null;
7
+ get defaultValue(): any;
8
+ default(value: any): this;
9
+ when(test: ValidationFunction): this;
10
+ validate(value: unknown, context: object): string[];
11
+ }
12
+ declare class NumberValidator extends FieldValidator {
13
+ constructor(message: string);
14
+ required(message: string): this;
15
+ min(min: number, message: string): this;
16
+ max(max: number, message: string): this;
17
+ }
18
+ declare class StringValidator extends FieldValidator {
19
+ constructor(message: string);
20
+ required(message: string): this;
21
+ match(regex: RegExp, message: string): this;
22
+ }
23
+ declare class BooleanValidator extends FieldValidator {
24
+ constructor(message: string);
25
+ required(message: string): this;
26
+ }
27
+ declare class DateValidator extends FieldValidator {
28
+ constructor(message: string);
29
+ required(message: string): this;
30
+ }
31
+ declare class JsonValidator extends FieldValidator {
32
+ private children?;
33
+ constructor(children?: Record<string, FieldValidator> | undefined);
34
+ validate(value: any, context: object): string[];
35
+ }
36
+ export declare class ValidationBuilder {
37
+ string(message: string): StringValidator;
38
+ number(message: string): NumberValidator;
39
+ boolean(message: string): BooleanValidator;
40
+ date(message: string): DateValidator;
41
+ json(model: Record<string, FieldValidator>): JsonValidator;
42
+ }
43
+ export declare const f: () => ValidationBuilder;
44
+ export {};
@@ -0,0 +1,122 @@
1
+ export class FieldValidator {
2
+ constructor() {
3
+ this._type = null;
4
+ this._cases = [];
5
+ this._default = undefined;
6
+ }
7
+ get type() {
8
+ return this._type;
9
+ }
10
+ get defaultValue() {
11
+ return this._default;
12
+ }
13
+ default(value) {
14
+ this._default = value;
15
+ return this;
16
+ }
17
+ when(test) {
18
+ this._cases.push(test);
19
+ return this;
20
+ }
21
+ validate(value, context) {
22
+ return this._cases.map((fn) => fn(value, context)).filter((res) => res !== null);
23
+ }
24
+ }
25
+ class NumberValidator extends FieldValidator {
26
+ constructor(message) {
27
+ super();
28
+ this._type = 'number';
29
+ this._cases.push((value) => (value === null || value === undefined ? null : typeof value !== 'number' ? message : null));
30
+ }
31
+ required(message) {
32
+ this._cases.push((value) => (value === undefined || value === null || String(value).trim() === '' ? message : null));
33
+ return this;
34
+ }
35
+ min(min, message) {
36
+ this._cases.push((value) => (typeof value === 'number' && value < min ? message : null));
37
+ return this;
38
+ }
39
+ max(max, message) {
40
+ this._cases.push((value) => (typeof value === 'number' && value > max ? message : null));
41
+ return this;
42
+ }
43
+ }
44
+ class StringValidator extends FieldValidator {
45
+ constructor(message) {
46
+ super();
47
+ this._type = 'string';
48
+ this._cases.push((value) => (value === null || value === undefined ? null : typeof value !== 'string' ? message : null));
49
+ }
50
+ required(message) {
51
+ this._cases.push((value) => (!value || String(value).trim() === '' ? message : null));
52
+ return this;
53
+ }
54
+ match(regex, message) {
55
+ this._cases.push((value) => (value === null || value === undefined ? null : !regex.test(String(value)) ? message : null));
56
+ return this;
57
+ }
58
+ }
59
+ class BooleanValidator extends FieldValidator {
60
+ constructor(message) {
61
+ super();
62
+ this._type = 'boolean';
63
+ this._cases.push((value) => (value === null || value === undefined ? null : typeof value !== 'boolean' ? message : null));
64
+ }
65
+ required(message) {
66
+ this._cases.push((value) => (typeof value !== 'boolean' ? message : null));
67
+ return this;
68
+ }
69
+ }
70
+ class DateValidator extends FieldValidator {
71
+ constructor(message) {
72
+ super();
73
+ this._type = 'date';
74
+ this._cases.push((value) => {
75
+ if (value === null || value === undefined)
76
+ return null;
77
+ const d = new Date(value);
78
+ return isNaN(d.getTime()) ? message : null;
79
+ });
80
+ }
81
+ required(message) {
82
+ return this.when((value) => (!value ? message : null));
83
+ }
84
+ }
85
+ class JsonValidator extends FieldValidator {
86
+ constructor(children) {
87
+ super();
88
+ this.children = children;
89
+ this._type = 'jsonb';
90
+ }
91
+ validate(value, context) {
92
+ if (typeof value !== 'object' || value === null) {
93
+ return ['Must be a valid JSON object.'];
94
+ }
95
+ if (!this.children)
96
+ return [];
97
+ const errors = [];
98
+ for (const [key, validator] of Object.entries(this.children)) {
99
+ const childErrors = validator.validate(value[key], context);
100
+ errors.push(...childErrors.map((e) => `${key}: ${e}`));
101
+ }
102
+ return errors;
103
+ }
104
+ }
105
+ export class ValidationBuilder {
106
+ string(message) {
107
+ return new StringValidator(message);
108
+ }
109
+ number(message) {
110
+ return new NumberValidator(message);
111
+ }
112
+ boolean(message) {
113
+ return new BooleanValidator(message);
114
+ }
115
+ date(message) {
116
+ return new DateValidator(message);
117
+ }
118
+ json(model) {
119
+ return new JsonValidator(model);
120
+ }
121
+ }
122
+ export const f = () => new ValidationBuilder();
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Especialized storage for Opposer Core Context.
3
+ * Uses GlobalStorage internally but provides a clean Singleton interface
4
+ * for the server engine and public consumption.
5
+ */
6
+ declare class ContextStorage {
7
+ private static instance;
8
+ private readonly namespace;
9
+ private constructor();
10
+ static getInstance(): ContextStorage;
11
+ set<T>(key: string, value: T): void;
12
+ get<T>(key: string): T;
13
+ has(key: string): boolean;
14
+ clear(): void;
15
+ }
16
+ declare const _default: ContextStorage;
17
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import GlobalStorage from "../cache/global.js";
2
+ /**
3
+ * Especialized storage for Opposer Core Context.
4
+ * Uses GlobalStorage internally but provides a clean Singleton interface
5
+ * for the server engine and public consumption.
6
+ */
7
+ class ContextStorage {
8
+ constructor() {
9
+ this.namespace = "opposer:core:context";
10
+ }
11
+ static getInstance() {
12
+ if (!ContextStorage.instance) {
13
+ ContextStorage.instance = new ContextStorage();
14
+ }
15
+ return ContextStorage.instance;
16
+ }
17
+ set(key, value) {
18
+ const data = GlobalStorage.get(this.namespace) || {};
19
+ data[key] = value;
20
+ GlobalStorage.set(this.namespace, data);
21
+ }
22
+ get(key) {
23
+ const data = GlobalStorage.get(this.namespace) || {};
24
+ return data[key];
25
+ }
26
+ has(key) {
27
+ const data = GlobalStorage.get(this.namespace) || {};
28
+ return Object.prototype.hasOwnProperty.call(data, key);
29
+ }
30
+ clear() {
31
+ GlobalStorage.set(this.namespace, {});
32
+ }
33
+ }
34
+ export default ContextStorage.getInstance();
@@ -0,0 +1,18 @@
1
+ import type { CacheSettings } from "../interfaces/system.js";
2
+ import Store from "./store.js";
3
+ declare const _default: {
4
+ __settings: CacheSettings;
5
+ __data: Store;
6
+ set(key: string, value: any): void;
7
+ get(key: string): any;
8
+ __isMaxSizeMemory: boolean;
9
+ __currentSizeMemory: number;
10
+ snapshot(): void;
11
+ restore(): void;
12
+ size(): boolean;
13
+ revalidate(): void | null;
14
+ notifyStoresForClearMemoryPerPolicy(): void;
15
+ clear(): void;
16
+ configure(): /*elided*/ any;
17
+ };
18
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import system from "../system/index.js";
2
+ import Storage from "./storage.js";
3
+ import Store from "./store.js";
4
+ export default new (class Global extends Storage {
5
+ constructor() {
6
+ super();
7
+ this.__settings = system.settings.cache.global;
8
+ this.__data = new Store();
9
+ this.__data.setSettings(system.settings.cache.global);
10
+ }
11
+ set(key, value) {
12
+ this.__data.set(key, value);
13
+ }
14
+ get(key) {
15
+ return this.__data.get(key);
16
+ }
17
+ })().configure();
@@ -0,0 +1,3 @@
1
+ export { default as SessionStorage } from "./session";
2
+ export { default as GlobalStorage } from "./global";
3
+ export { default as Store } from "./store";
@@ -0,0 +1,3 @@
1
+ export { default as SessionStorage } from "./session";
2
+ export { default as GlobalStorage } from "./global";
3
+ export { default as Store } from "./store";
@@ -0,0 +1,19 @@
1
+ import type { Request, Response, NextFunction } from "express";
2
+ import Store from "./store.js";
3
+ declare const _default: {
4
+ createStore(sessionId: string): Store;
5
+ loadStore(sessionId: string): Store | null;
6
+ initialize(req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>> | undefined;
7
+ __settings: import("../interfaces/system.js").CacheSettings;
8
+ __data: Record<string, any>;
9
+ __isMaxSizeMemory: boolean;
10
+ __currentSizeMemory: number;
11
+ snapshot(): void;
12
+ restore(): void;
13
+ size(): boolean;
14
+ revalidate(): void | null;
15
+ notifyStoresForClearMemoryPerPolicy(): void;
16
+ clear(): void;
17
+ configure(): /*elided*/ any;
18
+ };
19
+ export default _default;
@@ -0,0 +1,34 @@
1
+ import context from "../context/index.js";
2
+ import Storage from "./storage.js";
3
+ import Store from "./store.js";
4
+ export default new (class Session extends Storage {
5
+ createStore(sessionId) {
6
+ const store = new Store(sessionId);
7
+ Object.defineProperty(this.__data, sessionId, {
8
+ value: store,
9
+ writable: true,
10
+ enumerable: true,
11
+ configurable: true,
12
+ });
13
+ return store;
14
+ }
15
+ loadStore(sessionId) {
16
+ const store = this.__data[sessionId];
17
+ if (!store) {
18
+ if (this.__isMaxSizeMemory) {
19
+ return null;
20
+ }
21
+ return this.createStore(sessionId);
22
+ }
23
+ store.revalidateTimer();
24
+ return store;
25
+ }
26
+ initialize(req, res, next) {
27
+ const sessionId = req.headers["session-opposer-id"];
28
+ const store = this.loadStore(sessionId);
29
+ if (!sessionId) {
30
+ return res.status(401);
31
+ }
32
+ context.run({ store, sessionId }, next);
33
+ }
34
+ })().configure();
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,82 @@
1
+ import timer from "../utils/timer.js";
2
+ import system from "../system/index.js";
3
+ import Store from "./store.js";
4
+ import memory from "../utils/memory.js";
5
+ export default class Storage {
6
+ constructor() {
7
+ this.__data = {};
8
+ this.__isMaxSizeMemory = false;
9
+ this.__currentSizeMemory = 0;
10
+ }
11
+ snapshot() { }
12
+ restore() { }
13
+ size() {
14
+ this.__currentSizeMemory = memory.roughSizeOfObject(this.__data);
15
+ this.__isMaxSizeMemory =
16
+ this.__currentSizeMemory ===
17
+ memory.toBytes(this.__settings.maxmemory.size, this.__settings.maxmemory.unit);
18
+ return this.__isMaxSizeMemory;
19
+ }
20
+ revalidate() {
21
+ if (this.__data instanceof Store) {
22
+ this.__data.clearMemoryForPolicy();
23
+ var __isMaxSizeMemory = this.size();
24
+ if (__isMaxSizeMemory) {
25
+ return this.notifyStoresForClearMemoryPerPolicy();
26
+ }
27
+ return null;
28
+ }
29
+ var creared = Object.keys(this.__data).reduce((data, key) => {
30
+ var store = this.__data[key];
31
+ if (store.isValid()) {
32
+ Object.defineProperty(data, key, {
33
+ value: store,
34
+ configurable: true,
35
+ enumerable: true,
36
+ writable: true,
37
+ });
38
+ }
39
+ return data;
40
+ }, {});
41
+ Object.defineProperty(this, "__data", {
42
+ value: creared,
43
+ configurable: true,
44
+ enumerable: true,
45
+ writable: true,
46
+ });
47
+ var __isMaxSizeMemory = this.size();
48
+ if (__isMaxSizeMemory) {
49
+ return this.notifyStoresForClearMemoryPerPolicy();
50
+ }
51
+ return null;
52
+ }
53
+ notifyStoresForClearMemoryPerPolicy() {
54
+ Object.values(this.__data).forEach((store) => store.clearMemoryForPolicy());
55
+ var __isMaxSizeMemory = this.size();
56
+ if (__isMaxSizeMemory) {
57
+ this.notifyStoresForClearMemoryPerPolicy();
58
+ }
59
+ }
60
+ clear() {
61
+ Object.defineProperty(this, "__data", {
62
+ value: {},
63
+ configurable: true,
64
+ enumerable: true,
65
+ writable: true,
66
+ });
67
+ }
68
+ configure() {
69
+ if (system.settings.cache.type === "persistent") {
70
+ if (system.settings.cache.snapshot.active) {
71
+ setInterval(() => {
72
+ this.snapshot();
73
+ }, system.settings.cache.snapshot.timer * timer.msPerUnit[system.settings.cache.snapshot.unit]);
74
+ }
75
+ this.restore();
76
+ }
77
+ setInterval(() => {
78
+ this.revalidate();
79
+ }, timer.getSeconds(this.__settings.revalidate.timer, this.__settings.revalidate.unit));
80
+ return this;
81
+ }
82
+ }
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,106 @@
1
+ import timer from "../utils/timer.js";
2
+ export default class Store {
3
+ constructor(session) {
4
+ this.__expires_in = timer.getNextSessionExpireDate();
5
+ this.__data = new Map();
6
+ this.__meta = new Map();
7
+ this.__sessionId = session;
8
+ }
9
+ // Marca o acesso e frequência (para LFU/LRU)
10
+ trackAccess(key) {
11
+ if (!this.__meta.has(key)) {
12
+ this.__meta.set(key, {
13
+ lastAccess: Date.now(),
14
+ frequency: 1,
15
+ ttl: undefined,
16
+ });
17
+ }
18
+ else {
19
+ var __meta = this.__meta.get(key);
20
+ if (!__meta) {
21
+ return;
22
+ }
23
+ __meta.lastAccess = Date.now();
24
+ __meta.frequency++;
25
+ }
26
+ }
27
+ get(key) {
28
+ const value = this.__data.get(key);
29
+ if (value !== undefined) {
30
+ this.trackAccess(key);
31
+ }
32
+ return value;
33
+ }
34
+ set(key, value, ttlMs) {
35
+ this.__data.set(key, value);
36
+ this.__meta.set(key, {
37
+ lastAccess: Date.now(),
38
+ frequency: 1,
39
+ ttl: ttlMs ? Date.now() + ttlMs : undefined,
40
+ });
41
+ }
42
+ revalidateTimer() {
43
+ this.__expires_in = timer.getNextSessionExpireDate();
44
+ }
45
+ isValid() {
46
+ return this.__expires_in > new Date().getTime();
47
+ }
48
+ // Políticas de limpeza
49
+ clearMemoryForPolicy() {
50
+ const policy = this.__settings.evictionPolicy;
51
+ switch (policy) {
52
+ // Nenhuma exclusão automática
53
+ case "noeviction":
54
+ return;
55
+ // Remove o menos recentemente usado
56
+ case "volatile-lru": {
57
+ let oldestKey = null;
58
+ let oldestAccess = Infinity;
59
+ for (const [key, meta] of Object.entries(this.__meta)) {
60
+ if (meta.lastAccess < oldestAccess) {
61
+ oldestAccess = meta.lastAccess;
62
+ oldestKey = key;
63
+ }
64
+ }
65
+ if (oldestKey) {
66
+ this.__data.delete(oldestKey);
67
+ this.__meta.delete(oldestKey);
68
+ }
69
+ break;
70
+ }
71
+ // Remove o menos frequentemente usado
72
+ case "volatile-lfu": {
73
+ let leastUsedKey = null;
74
+ let leastFrequency = Infinity;
75
+ for (const [key, meta] of Object.entries(this.__meta)) {
76
+ if (meta.frequency < leastFrequency) {
77
+ leastUsedKey = key;
78
+ leastFrequency = meta.frequency;
79
+ }
80
+ }
81
+ if (leastUsedKey) {
82
+ this.__data.delete(leastUsedKey);
83
+ this.__meta.delete(leastUsedKey);
84
+ }
85
+ break;
86
+ }
87
+ // Remove chaves que passaram do TTL
88
+ case "volatile-ttl": {
89
+ const now = Date.now();
90
+ for (const [key, meta] of Object.entries(this.__meta)) {
91
+ if (meta.ttl && meta.ttl < now) {
92
+ this.__data.delete(key);
93
+ this.__meta.delete(key);
94
+ }
95
+ }
96
+ break;
97
+ }
98
+ default:
99
+ console.warn(`[Store] Unknown eviction policy: ${policy}`);
100
+ break;
101
+ }
102
+ }
103
+ setSettings(settings) {
104
+ this.__settings = settings;
105
+ }
106
+ }
@@ -0,0 +1,3 @@
1
+ import { AsyncLocalStorage } from "async_hooks";
2
+ declare const context: AsyncLocalStorage<unknown>;
3
+ export default context;
@@ -0,0 +1,3 @@
1
+ import { AsyncLocalStorage } from "async_hooks";
2
+ const context = new AsyncLocalStorage();
3
+ export default context;
@@ -0,0 +1 @@
1
+ export default function Global(): (target: any, property: string) => void;
@@ -0,0 +1,19 @@
1
+ import global from "../cache/global.js";
2
+ export default function Global() {
3
+ return function (target, property) {
4
+ const __property = Symbol(property);
5
+ const __class = target.constructor.name;
6
+ const __key = __class + ":" + property;
7
+ Object.defineProperty(target, property, {
8
+ get() {
9
+ return global.get(__key);
10
+ },
11
+ set(value) {
12
+ global.set(__key, value);
13
+ this[__property] = value;
14
+ },
15
+ enumerable: true,
16
+ configurable: true,
17
+ });
18
+ };
19
+ }
@@ -0,0 +1 @@
1
+ export default function Session(): (target: any, property: string) => void;
@@ -0,0 +1,21 @@
1
+ import context from "../context/index.js";
2
+ export default function Session() {
3
+ return function (target, property) {
4
+ const __property = Symbol(property);
5
+ const __class = target.constructor.name;
6
+ const __key = __class + ":" + property;
7
+ Object.defineProperty(target, property, {
8
+ get() {
9
+ var __context = context.getStore();
10
+ return __context.store.get(__key);
11
+ },
12
+ set(value) {
13
+ var __context = context.getStore();
14
+ __context.store.set(__key, value);
15
+ this[__property] = value;
16
+ },
17
+ enumerable: true,
18
+ configurable: true,
19
+ });
20
+ };
21
+ }
@@ -0,0 +1,6 @@
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";
@@ -0,0 +1,6 @@
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";
@@ -0,0 +1,5 @@
1
+ import type { Store } from "../cache/index.js";
2
+ export interface ContextSession {
3
+ sessionId: string;
4
+ store: Store;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
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
+ }