@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.
- package/README.md +504 -0
- package/lib/bin/commands/build.js +75 -0
- package/lib/bin/commands/generate/api-key.js +28 -0
- package/lib/bin/commands/generate/jwt-key.js +46 -0
- package/lib/bin/commands/init.js +169 -0
- package/lib/bin/helpers/crypto.js +33 -0
- package/lib/bin/opposer.js +26 -0
- package/lib/cjs/examples/full-app/index.d.ts +1 -0
- package/lib/cjs/examples/full-app/index.js +102 -0
- package/lib/cjs/examples/full-app/models/author.d.ts +7 -0
- package/lib/cjs/examples/full-app/models/author.js +42 -0
- package/lib/cjs/examples/full-app/models/book.d.ts +9 -0
- package/lib/cjs/examples/full-app/models/book.js +51 -0
- package/lib/cjs/examples/full-app/models/category.d.ts +4 -0
- package/lib/cjs/examples/full-app/models/category.js +26 -0
- package/lib/cjs/examples/full-app/schedules/catalog-refresh.d.ts +28 -0
- package/lib/cjs/examples/full-app/schedules/catalog-refresh.js +149 -0
- package/lib/cjs/examples/full-app/schedules/inventory-sync.d.ts +12 -0
- package/lib/cjs/examples/full-app/schedules/inventory-sync.js +61 -0
- package/lib/cjs/examples/full-app/schedules/library-alerts.d.ts +11 -0
- package/lib/cjs/examples/full-app/schedules/library-alerts.js +55 -0
- package/lib/cjs/examples/minimal/src/handlers/book.d.ts +11 -0
- package/lib/cjs/examples/minimal/src/handlers/book.js +51 -0
- package/lib/cjs/examples/minimal/src/index.d.ts +1 -0
- package/lib/cjs/examples/minimal/src/index.js +14 -0
- package/lib/cjs/examples/minimal/src/models/books.d.ts +4 -0
- package/lib/cjs/examples/minimal/src/models/books.js +26 -0
- package/lib/cjs/examples/orm/models/permission.d.ts +6 -0
- package/lib/cjs/examples/orm/models/permission.js +38 -0
- package/lib/cjs/examples/orm/models/profile.d.ts +7 -0
- package/lib/cjs/examples/orm/models/profile.js +42 -0
- package/lib/cjs/examples/orm/models/user.d.ts +11 -0
- package/lib/cjs/examples/orm/models/user.js +70 -0
- package/lib/cjs/examples/orm/mysql/index.d.ts +1 -0
- package/lib/cjs/examples/orm/mysql/index.js +44 -0
- package/lib/cjs/examples/orm/postgres/index.d.ts +1 -0
- package/lib/cjs/examples/orm/postgres/index.js +40 -0
- package/lib/cjs/examples/orm/sqlite/index.d.ts +1 -0
- package/lib/cjs/examples/orm/sqlite/index.js +41 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +23 -0
- package/lib/cjs/interfaces/controller.d.ts +109 -0
- package/lib/cjs/interfaces/controller.js +2 -0
- package/lib/cjs/interfaces/field.d.ts +23 -0
- package/lib/cjs/interfaces/field.js +2 -0
- package/lib/cjs/interfaces/handler.d.ts +18 -0
- package/lib/cjs/interfaces/handler.js +2 -0
- package/lib/cjs/interfaces/jwt.d.ts +21 -0
- package/lib/cjs/interfaces/jwt.js +2 -0
- package/lib/cjs/interfaces/model.d.ts +9 -0
- package/lib/cjs/interfaces/model.js +2 -0
- package/lib/cjs/interfaces/request.d.ts +13 -0
- package/lib/cjs/interfaces/request.js +2 -0
- package/lib/cjs/interfaces/schema.d.ts +9 -0
- package/lib/cjs/interfaces/schema.js +2 -0
- package/lib/cjs/interfaces/security.d.ts +32 -0
- package/lib/cjs/interfaces/security.js +2 -0
- package/lib/cjs/interfaces/server.d.ts +37 -0
- package/lib/cjs/interfaces/server.js +2 -0
- package/lib/cjs/interfaces/system.d.ts +41 -0
- package/lib/cjs/interfaces/system.js +2 -0
- package/lib/cjs/orm/decorators/index.d.ts +33 -0
- package/lib/cjs/orm/decorators/index.js +131 -0
- package/lib/cjs/orm/driver/mysql.d.ts +14 -0
- package/lib/cjs/orm/driver/mysql.js +103 -0
- package/lib/cjs/orm/driver/postgres.d.ts +14 -0
- package/lib/cjs/orm/driver/postgres.js +105 -0
- package/lib/cjs/orm/driver/sqlite.d.ts +14 -0
- package/lib/cjs/orm/driver/sqlite.js +143 -0
- package/lib/cjs/orm/index.d.ts +8 -0
- package/lib/cjs/orm/index.js +28 -0
- package/lib/cjs/orm/metadata.d.ts +47 -0
- package/lib/cjs/orm/metadata.js +47 -0
- package/lib/cjs/orm/opposer.d.ts +30 -0
- package/lib/cjs/orm/opposer.js +33 -0
- package/lib/cjs/orm/query-builder.d.ts +32 -0
- package/lib/cjs/orm/query-builder.js +278 -0
- package/lib/cjs/orm/repository.d.ts +54 -0
- package/lib/cjs/orm/repository.js +325 -0
- package/lib/cjs/orm/validation.d.ts +44 -0
- package/lib/cjs/orm/validation.js +128 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/persistent/cache/core-context.d.ts +17 -0
- package/lib/cjs/persistent/cache/core-context.js +39 -0
- package/lib/cjs/persistent/cache/global.d.ts +18 -0
- package/lib/cjs/persistent/cache/global.js +22 -0
- package/lib/cjs/persistent/cache/index.d.ts +3 -0
- package/lib/cjs/persistent/cache/index.js +12 -0
- package/lib/cjs/persistent/cache/session.d.ts +19 -0
- package/lib/cjs/persistent/cache/session.js +39 -0
- package/lib/cjs/persistent/cache/storage.d.ts +14 -0
- package/lib/cjs/persistent/cache/storage.js +88 -0
- package/lib/cjs/persistent/cache/store.d.ts +16 -0
- package/lib/cjs/persistent/cache/store.js +112 -0
- package/lib/cjs/persistent/context/index.d.ts +3 -0
- package/lib/cjs/persistent/context/index.js +5 -0
- package/lib/cjs/persistent/decorators/global.d.ts +1 -0
- package/lib/cjs/persistent/decorators/global.js +25 -0
- package/lib/cjs/persistent/decorators/session.d.ts +1 -0
- package/lib/cjs/persistent/decorators/session.js +27 -0
- package/lib/cjs/persistent/index.d.ts +6 -0
- package/lib/cjs/persistent/index.js +18 -0
- package/lib/cjs/persistent/interfaces/context.d.ts +5 -0
- package/lib/cjs/persistent/interfaces/context.js +2 -0
- package/lib/cjs/persistent/interfaces/system.d.ts +47 -0
- package/lib/cjs/persistent/interfaces/system.js +29 -0
- package/lib/cjs/persistent/system/index.d.ts +7 -0
- package/lib/cjs/persistent/system/index.js +44 -0
- package/lib/cjs/persistent/utils/memory.d.ts +8 -0
- package/lib/cjs/persistent/utils/memory.js +44 -0
- package/lib/cjs/persistent/utils/timer.d.ts +14 -0
- package/lib/cjs/persistent/utils/timer.js +21 -0
- package/lib/cjs/playground/build/client/assets/AddRounded-ByHfnsiW.js +4 -0
- package/lib/cjs/playground/build/client/assets/Button-DLrxHRm7.js +1 -0
- package/lib/cjs/playground/build/client/assets/Container-CgITmmbk.js +1 -0
- package/lib/cjs/playground/build/client/assets/Divider-B_Wx9srO.js +1 -0
- package/lib/cjs/playground/build/client/assets/List-juBjUmfP.js +1 -0
- package/lib/cjs/playground/build/client/assets/ListItemText-DgWZmgzc.js +1 -0
- package/lib/cjs/playground/build/client/assets/MenuItem-D_5SuVKQ.js +1 -0
- package/lib/cjs/playground/build/client/assets/Modal-BwXR_5Bh.js +1 -0
- package/lib/cjs/playground/build/client/assets/TableRow-B9hAmlnV.js +2 -0
- package/lib/cjs/playground/build/client/assets/TextField-UybdTIGB.js +3 -0
- package/lib/cjs/playground/build/client/assets/Tooltip-BGcUWUcF.js +1 -0
- package/lib/cjs/playground/build/client/assets/auth-CD1rXHzz.js +1 -0
- package/lib/cjs/playground/build/client/assets/auth-GyTIVKy5.js +1 -0
- package/lib/cjs/playground/build/client/assets/confirm-Dr0pbiV6.js +1 -0
- package/lib/cjs/playground/build/client/assets/dividerClasses-CIiqeEPO.js +1 -0
- package/lib/cjs/playground/build/client/assets/entry.client-D6FYz1yh.js +13 -0
- package/lib/cjs/playground/build/client/assets/index-CJ0wdt6Z.js +1 -0
- package/lib/cjs/playground/build/client/assets/index-CQc11yq_.js +1153 -0
- package/lib/cjs/playground/build/client/assets/index-Cr4I-4J2.js +1 -0
- package/lib/cjs/playground/build/client/assets/index-CtPqstFl.js +26 -0
- package/lib/cjs/playground/build/client/assets/index-Ct_NE85o.js +1 -0
- package/lib/cjs/playground/build/client/assets/index-D0I6xwmb.js +1 -0
- package/lib/cjs/playground/build/client/assets/index-DmDCpKb3.js +1 -0
- package/lib/cjs/playground/build/client/assets/index-DsSkAwyn.js +1 -0
- package/lib/cjs/playground/build/client/assets/index-_DMgWZ3Y.js +1 -0
- package/lib/cjs/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +1 -0
- package/lib/cjs/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +1 -0
- package/lib/cjs/playground/build/client/assets/manifest-c06e9a7f.js +1 -0
- package/lib/cjs/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +1 -0
- package/lib/cjs/playground/build/client/assets/playground-Hl52p9f5.js +108 -0
- package/lib/cjs/playground/build/client/assets/root-CQTBmuv8.js +1 -0
- package/lib/cjs/playground/build/client/assets/toast-CsAH5FIf.js +1 -0
- package/lib/cjs/playground/build/client/assets/use-request-BZNkzlTr.js +1 -0
- package/lib/cjs/playground/build/client/favicon.ico +0 -0
- package/lib/cjs/playground/build/client/index.html +6 -0
- package/lib/cjs/playground/index.d.ts +2 -0
- package/lib/cjs/playground/index.js +135 -0
- package/lib/cjs/scheduler/controllers/index.d.ts +19 -0
- package/lib/cjs/scheduler/controllers/index.js +62 -0
- package/lib/cjs/scheduler/decorators/index.d.ts +9 -0
- package/lib/cjs/scheduler/decorators/index.js +21 -0
- package/lib/cjs/scheduler/handlers/index.d.ts +19 -0
- package/lib/cjs/scheduler/handlers/index.js +62 -0
- package/lib/cjs/scheduler/index.d.ts +24 -0
- package/lib/cjs/scheduler/index.js +110 -0
- package/lib/cjs/scheduler/models/history.d.ts +10 -0
- package/lib/cjs/scheduler/models/history.js +50 -0
- package/lib/cjs/server/constants/index.d.ts +78 -0
- package/lib/cjs/server/constants/index.js +372 -0
- package/lib/cjs/server/context/index.d.ts +17 -0
- package/lib/cjs/server/context/index.js +33 -0
- package/lib/cjs/server/controller/index.d.ts +3 -0
- package/lib/cjs/server/controller/index.js +217 -0
- package/lib/cjs/server/controllers/index.d.ts +5 -0
- package/lib/cjs/server/controllers/index.js +72 -0
- package/lib/cjs/server/core/index.d.ts +16 -0
- package/lib/cjs/server/core/index.js +110 -0
- package/lib/cjs/server/core/middleware/body-parser.d.ts +2 -0
- package/lib/cjs/server/core/middleware/body-parser.js +27 -0
- package/lib/cjs/server/core/middleware/cors.d.ts +4 -0
- package/lib/cjs/server/core/middleware/cors.js +32 -0
- package/lib/cjs/server/core/middleware/logger.d.ts +2 -0
- package/lib/cjs/server/core/middleware/logger.js +15 -0
- package/lib/cjs/server/decorators/controller.d.ts +3 -0
- package/lib/cjs/server/decorators/controller.js +14 -0
- package/lib/cjs/server/decorators/field.d.ts +2 -0
- package/lib/cjs/server/decorators/field.js +36 -0
- package/lib/cjs/server/decorators/handler.d.ts +3 -0
- package/lib/cjs/server/decorators/handler.js +14 -0
- package/lib/cjs/server/decorators/index.d.ts +7 -0
- package/lib/cjs/server/decorators/index.js +26 -0
- package/lib/cjs/server/decorators/is-public-method.d.ts +3 -0
- package/lib/cjs/server/decorators/is-public-method.js +16 -0
- package/lib/cjs/server/decorators/is-public.d.ts +3 -0
- package/lib/cjs/server/decorators/is-public.js +14 -0
- package/lib/cjs/server/decorators/method.d.ts +3 -0
- package/lib/cjs/server/decorators/method.js +16 -0
- package/lib/cjs/server/decorators/payload.d.ts +3 -0
- package/lib/cjs/server/decorators/payload.js +15 -0
- package/lib/cjs/server/handlers/index.d.ts +5 -0
- package/lib/cjs/server/handlers/index.js +72 -0
- package/lib/cjs/server/helpers/index.d.ts +17 -0
- package/lib/cjs/server/helpers/index.js +39 -0
- package/lib/cjs/server/index.d.ts +12 -0
- package/lib/cjs/server/index.js +176 -0
- package/lib/cjs/server/security/controller/auth.d.ts +76 -0
- package/lib/cjs/server/security/controller/auth.js +346 -0
- package/lib/cjs/server/security/index.d.ts +2 -0
- package/lib/cjs/server/security/index.js +10 -0
- package/lib/cjs/server/security/jwt/index.d.ts +23 -0
- package/lib/cjs/server/security/jwt/index.js +108 -0
- package/lib/cjs/server/security/middleware/autorization.d.ts +3 -0
- package/lib/cjs/server/security/middleware/autorization.js +46 -0
- package/lib/cjs/server/security/middleware/permission.d.ts +3 -0
- package/lib/cjs/server/security/middleware/permission.js +138 -0
- package/lib/cjs/server/security/models/crp.d.ts +8 -0
- package/lib/cjs/server/security/models/crp.js +42 -0
- package/lib/cjs/server/security/models/ke.d.ts +7 -0
- package/lib/cjs/server/security/models/ke.js +38 -0
- package/lib/cjs/server/security/models/rl.d.ts +9 -0
- package/lib/cjs/server/security/models/rl.js +50 -0
- package/lib/cjs/server/security/models/se.d.ts +11 -0
- package/lib/cjs/server/security/models/se.js +54 -0
- package/lib/cjs/server/security/models/usr.d.ts +14 -0
- package/lib/cjs/server/security/models/usr.js +82 -0
- package/lib/cjs/server/services/delete.d.ts +13 -0
- package/lib/cjs/server/services/delete.js +49 -0
- package/lib/cjs/server/services/get.d.ts +4 -0
- package/lib/cjs/server/services/get.js +145 -0
- package/lib/cjs/server/services/insert.d.ts +13 -0
- package/lib/cjs/server/services/insert.js +74 -0
- package/lib/cjs/server/services/update.d.ts +13 -0
- package/lib/cjs/server/services/update.js +60 -0
- package/lib/cjs/system/index.d.ts +13 -0
- package/lib/cjs/system/index.js +237 -0
- package/lib/esm/examples/full-app/index.d.ts +1 -0
- package/lib/esm/examples/full-app/index.js +64 -0
- package/lib/esm/examples/full-app/models/author.d.ts +7 -0
- package/lib/esm/examples/full-app/models/author.js +37 -0
- package/lib/esm/examples/full-app/models/book.d.ts +9 -0
- package/lib/esm/examples/full-app/models/book.js +46 -0
- package/lib/esm/examples/full-app/models/category.d.ts +4 -0
- package/lib/esm/examples/full-app/models/category.js +24 -0
- package/lib/esm/examples/full-app/schedules/catalog-refresh.d.ts +28 -0
- package/lib/esm/examples/full-app/schedules/catalog-refresh.js +143 -0
- package/lib/esm/examples/full-app/schedules/inventory-sync.d.ts +12 -0
- package/lib/esm/examples/full-app/schedules/inventory-sync.js +55 -0
- package/lib/esm/examples/full-app/schedules/library-alerts.d.ts +11 -0
- package/lib/esm/examples/full-app/schedules/library-alerts.js +52 -0
- package/lib/esm/examples/minimal/src/handlers/book.d.ts +11 -0
- package/lib/esm/examples/minimal/src/handlers/book.js +49 -0
- package/lib/esm/examples/minimal/src/index.d.ts +1 -0
- package/lib/esm/examples/minimal/src/index.js +9 -0
- package/lib/esm/examples/minimal/src/models/books.d.ts +4 -0
- package/lib/esm/examples/minimal/src/models/books.js +24 -0
- package/lib/esm/examples/orm/models/permission.d.ts +6 -0
- package/lib/esm/examples/orm/models/permission.js +33 -0
- package/lib/esm/examples/orm/models/profile.d.ts +7 -0
- package/lib/esm/examples/orm/models/profile.js +37 -0
- package/lib/esm/examples/orm/models/user.d.ts +11 -0
- package/lib/esm/examples/orm/models/user.js +65 -0
- package/lib/esm/examples/orm/mysql/index.d.ts +1 -0
- package/lib/esm/examples/orm/mysql/index.js +39 -0
- package/lib/esm/examples/orm/postgres/index.d.ts +1 -0
- package/lib/esm/examples/orm/postgres/index.js +35 -0
- package/lib/esm/examples/orm/sqlite/index.d.ts +1 -0
- package/lib/esm/examples/orm/sqlite/index.js +36 -0
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.js +2 -0
- package/lib/esm/interfaces/controller.d.ts +109 -0
- package/lib/esm/interfaces/controller.js +1 -0
- package/lib/esm/interfaces/field.d.ts +23 -0
- package/lib/esm/interfaces/field.js +1 -0
- package/lib/esm/interfaces/handler.d.ts +18 -0
- package/lib/esm/interfaces/handler.js +1 -0
- package/lib/esm/interfaces/jwt.d.ts +21 -0
- package/lib/esm/interfaces/jwt.js +1 -0
- package/lib/esm/interfaces/model.d.ts +9 -0
- package/lib/esm/interfaces/model.js +1 -0
- package/lib/esm/interfaces/request.d.ts +13 -0
- package/lib/esm/interfaces/request.js +1 -0
- package/lib/esm/interfaces/schema.d.ts +9 -0
- package/lib/esm/interfaces/schema.js +1 -0
- package/lib/esm/interfaces/security.d.ts +32 -0
- package/lib/esm/interfaces/security.js +1 -0
- package/lib/esm/interfaces/server.d.ts +37 -0
- package/lib/esm/interfaces/server.js +1 -0
- package/lib/esm/interfaces/system.d.ts +41 -0
- package/lib/esm/interfaces/system.js +1 -0
- package/lib/esm/orm/decorators/index.d.ts +33 -0
- package/lib/esm/orm/decorators/index.js +118 -0
- package/lib/esm/orm/driver/mysql.d.ts +14 -0
- package/lib/esm/orm/driver/mysql.js +66 -0
- package/lib/esm/orm/driver/postgres.d.ts +14 -0
- package/lib/esm/orm/driver/postgres.js +68 -0
- package/lib/esm/orm/driver/sqlite.d.ts +14 -0
- package/lib/esm/orm/driver/sqlite.js +106 -0
- package/lib/esm/orm/index.d.ts +8 -0
- package/lib/esm/orm/index.js +8 -0
- package/lib/esm/orm/metadata.d.ts +47 -0
- package/lib/esm/orm/metadata.js +43 -0
- package/lib/esm/orm/opposer.d.ts +30 -0
- package/lib/esm/orm/opposer.js +29 -0
- package/lib/esm/orm/query-builder.d.ts +32 -0
- package/lib/esm/orm/query-builder.js +274 -0
- package/lib/esm/orm/repository.d.ts +54 -0
- package/lib/esm/orm/repository.js +318 -0
- package/lib/esm/orm/validation.d.ts +44 -0
- package/lib/esm/orm/validation.js +122 -0
- package/lib/esm/persistent/cache/core-context.d.ts +17 -0
- package/lib/esm/persistent/cache/core-context.js +34 -0
- package/lib/esm/persistent/cache/global.d.ts +18 -0
- package/lib/esm/persistent/cache/global.js +17 -0
- package/lib/esm/persistent/cache/index.d.ts +3 -0
- package/lib/esm/persistent/cache/index.js +3 -0
- package/lib/esm/persistent/cache/session.d.ts +19 -0
- package/lib/esm/persistent/cache/session.js +34 -0
- package/lib/esm/persistent/cache/storage.d.ts +14 -0
- package/lib/esm/persistent/cache/storage.js +82 -0
- package/lib/esm/persistent/cache/store.d.ts +16 -0
- package/lib/esm/persistent/cache/store.js +106 -0
- package/lib/esm/persistent/context/index.d.ts +3 -0
- package/lib/esm/persistent/context/index.js +3 -0
- package/lib/esm/persistent/decorators/global.d.ts +1 -0
- package/lib/esm/persistent/decorators/global.js +19 -0
- package/lib/esm/persistent/decorators/session.d.ts +1 -0
- package/lib/esm/persistent/decorators/session.js +21 -0
- package/lib/esm/persistent/index.d.ts +6 -0
- package/lib/esm/persistent/index.js +6 -0
- package/lib/esm/persistent/interfaces/context.d.ts +5 -0
- package/lib/esm/persistent/interfaces/context.js +1 -0
- package/lib/esm/persistent/interfaces/system.d.ts +47 -0
- package/lib/esm/persistent/interfaces/system.js +26 -0
- package/lib/esm/persistent/system/index.d.ts +7 -0
- package/lib/esm/persistent/system/index.js +39 -0
- package/lib/esm/persistent/utils/memory.d.ts +8 -0
- package/lib/esm/persistent/utils/memory.js +42 -0
- package/lib/esm/persistent/utils/timer.d.ts +14 -0
- package/lib/esm/persistent/utils/timer.js +16 -0
- package/lib/esm/playground/build/client/assets/AddRounded-ByHfnsiW.js +4 -0
- package/lib/esm/playground/build/client/assets/Button-DLrxHRm7.js +1 -0
- package/lib/esm/playground/build/client/assets/Container-CgITmmbk.js +1 -0
- package/lib/esm/playground/build/client/assets/Divider-B_Wx9srO.js +1 -0
- package/lib/esm/playground/build/client/assets/List-juBjUmfP.js +1 -0
- package/lib/esm/playground/build/client/assets/ListItemText-DgWZmgzc.js +1 -0
- package/lib/esm/playground/build/client/assets/MenuItem-D_5SuVKQ.js +1 -0
- package/lib/esm/playground/build/client/assets/Modal-BwXR_5Bh.js +1 -0
- package/lib/esm/playground/build/client/assets/TableRow-B9hAmlnV.js +2 -0
- package/lib/esm/playground/build/client/assets/TextField-UybdTIGB.js +3 -0
- package/lib/esm/playground/build/client/assets/Tooltip-BGcUWUcF.js +1 -0
- package/lib/esm/playground/build/client/assets/auth-CD1rXHzz.js +1 -0
- package/lib/esm/playground/build/client/assets/auth-GyTIVKy5.js +1 -0
- package/lib/esm/playground/build/client/assets/confirm-Dr0pbiV6.js +1 -0
- package/lib/esm/playground/build/client/assets/dividerClasses-CIiqeEPO.js +1 -0
- package/lib/esm/playground/build/client/assets/entry.client-D6FYz1yh.js +13 -0
- package/lib/esm/playground/build/client/assets/index-CJ0wdt6Z.js +1 -0
- package/lib/esm/playground/build/client/assets/index-CQc11yq_.js +1153 -0
- package/lib/esm/playground/build/client/assets/index-Cr4I-4J2.js +1 -0
- package/lib/esm/playground/build/client/assets/index-CtPqstFl.js +26 -0
- package/lib/esm/playground/build/client/assets/index-Ct_NE85o.js +1 -0
- package/lib/esm/playground/build/client/assets/index-D0I6xwmb.js +1 -0
- package/lib/esm/playground/build/client/assets/index-DmDCpKb3.js +1 -0
- package/lib/esm/playground/build/client/assets/index-DsSkAwyn.js +1 -0
- package/lib/esm/playground/build/client/assets/index-_DMgWZ3Y.js +1 -0
- package/lib/esm/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +1 -0
- package/lib/esm/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +1 -0
- package/lib/esm/playground/build/client/assets/manifest-c06e9a7f.js +1 -0
- package/lib/esm/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +1 -0
- package/lib/esm/playground/build/client/assets/playground-Hl52p9f5.js +108 -0
- package/lib/esm/playground/build/client/assets/root-CQTBmuv8.js +1 -0
- package/lib/esm/playground/build/client/assets/toast-CsAH5FIf.js +1 -0
- package/lib/esm/playground/build/client/assets/use-request-BZNkzlTr.js +1 -0
- package/lib/esm/playground/build/client/favicon.ico +0 -0
- package/lib/esm/playground/build/client/index.html +6 -0
- package/lib/esm/playground/index.d.ts +2 -0
- package/lib/esm/playground/index.js +129 -0
- package/lib/esm/scheduler/controllers/index.d.ts +19 -0
- package/lib/esm/scheduler/controllers/index.js +57 -0
- package/lib/esm/scheduler/decorators/index.d.ts +9 -0
- package/lib/esm/scheduler/decorators/index.js +16 -0
- package/lib/esm/scheduler/handlers/index.d.ts +19 -0
- package/lib/esm/scheduler/handlers/index.js +57 -0
- package/lib/esm/scheduler/index.d.ts +24 -0
- package/lib/esm/scheduler/index.js +89 -0
- package/lib/esm/scheduler/models/history.d.ts +10 -0
- package/lib/esm/scheduler/models/history.js +48 -0
- package/lib/esm/server/constants/index.d.ts +78 -0
- package/lib/esm/server/constants/index.js +369 -0
- package/lib/esm/server/context/index.d.ts +17 -0
- package/lib/esm/server/context/index.js +31 -0
- package/lib/esm/server/controller/index.d.ts +3 -0
- package/lib/esm/server/controller/index.js +179 -0
- package/lib/esm/server/controllers/index.d.ts +5 -0
- package/lib/esm/server/controllers/index.js +31 -0
- package/lib/esm/server/core/index.d.ts +16 -0
- package/lib/esm/server/core/index.js +103 -0
- package/lib/esm/server/core/middleware/body-parser.d.ts +2 -0
- package/lib/esm/server/core/middleware/body-parser.js +24 -0
- package/lib/esm/server/core/middleware/cors.d.ts +4 -0
- package/lib/esm/server/core/middleware/cors.js +29 -0
- package/lib/esm/server/core/middleware/logger.d.ts +2 -0
- package/lib/esm/server/core/middleware/logger.js +12 -0
- package/lib/esm/server/decorators/controller.d.ts +3 -0
- package/lib/esm/server/decorators/controller.js +10 -0
- package/lib/esm/server/decorators/field.d.ts +2 -0
- package/lib/esm/server/decorators/field.js +32 -0
- package/lib/esm/server/decorators/handler.d.ts +3 -0
- package/lib/esm/server/decorators/handler.js +10 -0
- package/lib/esm/server/decorators/index.d.ts +7 -0
- package/lib/esm/server/decorators/index.js +7 -0
- package/lib/esm/server/decorators/is-public-method.d.ts +3 -0
- package/lib/esm/server/decorators/is-public-method.js +12 -0
- package/lib/esm/server/decorators/is-public.d.ts +3 -0
- package/lib/esm/server/decorators/is-public.js +10 -0
- package/lib/esm/server/decorators/method.d.ts +3 -0
- package/lib/esm/server/decorators/method.js +12 -0
- package/lib/esm/server/decorators/payload.d.ts +3 -0
- package/lib/esm/server/decorators/payload.js +11 -0
- package/lib/esm/server/handlers/index.d.ts +5 -0
- package/lib/esm/server/handlers/index.js +31 -0
- package/lib/esm/server/helpers/index.d.ts +17 -0
- package/lib/esm/server/helpers/index.js +34 -0
- package/lib/esm/server/index.d.ts +12 -0
- package/lib/esm/server/index.js +147 -0
- package/lib/esm/server/security/controller/auth.d.ts +76 -0
- package/lib/esm/server/security/controller/auth.js +341 -0
- package/lib/esm/server/security/index.d.ts +2 -0
- package/lib/esm/server/security/index.js +2 -0
- package/lib/esm/server/security/jwt/index.d.ts +23 -0
- package/lib/esm/server/security/jwt/index.js +103 -0
- package/lib/esm/server/security/middleware/autorization.d.ts +3 -0
- package/lib/esm/server/security/middleware/autorization.js +41 -0
- package/lib/esm/server/security/middleware/permission.d.ts +3 -0
- package/lib/esm/server/security/middleware/permission.js +133 -0
- package/lib/esm/server/security/models/crp.d.ts +8 -0
- package/lib/esm/server/security/models/crp.js +40 -0
- package/lib/esm/server/security/models/ke.d.ts +7 -0
- package/lib/esm/server/security/models/ke.js +36 -0
- package/lib/esm/server/security/models/rl.d.ts +9 -0
- package/lib/esm/server/security/models/rl.js +45 -0
- package/lib/esm/server/security/models/se.d.ts +11 -0
- package/lib/esm/server/security/models/se.js +52 -0
- package/lib/esm/server/security/models/usr.d.ts +14 -0
- package/lib/esm/server/security/models/usr.js +77 -0
- package/lib/esm/server/services/delete.d.ts +13 -0
- package/lib/esm/server/services/delete.js +44 -0
- package/lib/esm/server/services/get.d.ts +4 -0
- package/lib/esm/server/services/get.js +140 -0
- package/lib/esm/server/services/insert.d.ts +13 -0
- package/lib/esm/server/services/insert.js +69 -0
- package/lib/esm/server/services/update.d.ts +13 -0
- package/lib/esm/server/services/update.js +55 -0
- package/lib/esm/system/index.d.ts +13 -0
- package/lib/esm/system/index.js +197 -0
- 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,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 @@
|
|
|
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 @@
|
|
|
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
|
+
}
|