@vandenberghinc/volt 1.1.26 → 1.1.28
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/backend/dist/cjs/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
- package/backend/dist/cjs/{blacklist.js → backend/src/blacklist.js} +8 -5
- package/backend/dist/cjs/{cli.js → backend/src/cli.js} +29 -47
- package/backend/dist/cjs/backend/src/database/collection.d.ts +1543 -0
- package/backend/dist/cjs/backend/src/database/collection.js +3042 -0
- package/backend/dist/cjs/backend/src/database/database.d.ts +66 -0
- package/backend/dist/cjs/{database → backend/src/database}/database.js +48 -43
- package/backend/dist/cjs/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/cjs/backend/src/database/filters/filters.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test.js +443 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_test_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v0.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v1.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v2.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_filter_v3.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter.js +15 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/cjs/backend/src/database/filters/strict_update_filter_test.js +355 -0
- package/backend/dist/cjs/backend/src/database/flatten.d.ts +75 -0
- package/backend/dist/cjs/{logger.js → backend/src/database/flatten.js} +18 -7
- package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +461 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.js +1014 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/cjs/backend/src/database/quota/quota_v1.js +1087 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.d.ts +293 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.js +573 -0
- package/backend/dist/{esm → cjs/backend/src}/endpoint.d.ts +69 -46
- package/backend/dist/cjs/{endpoint.js → backend/src/endpoint.js} +87 -101
- package/backend/dist/cjs/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/cjs/backend/src/errors/index.js +25 -0
- package/backend/dist/{esm/utils.d.ts → cjs/backend/src/errors/internal_external.d.ts} +14 -22
- package/backend/dist/cjs/backend/src/errors/internal_external.js +85 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/backend/dist/cjs/{mutex.js → backend/src/errors/invalid_usage_error.js} +20 -37
- package/backend/dist/cjs/backend/src/errors/system_error.d.ts +230 -0
- package/backend/dist/cjs/backend/src/errors/system_error.js +393 -0
- package/backend/dist/cjs/backend/src/events.d.ts +54 -0
- package/backend/dist/cjs/backend/src/events.js +15 -0
- package/backend/dist/cjs/{frontend.js → backend/src/frontend.js} +1 -1
- package/backend/dist/cjs/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
- package/backend/dist/cjs/{image_endpoint.js → backend/src/image_endpoint.js} +3 -5
- package/backend/dist/cjs/backend/src/logger.d.ts +5 -0
- package/backend/dist/cjs/backend/src/logger.js +15 -0
- package/backend/dist/cjs/backend/src/meta.d.ts +64 -0
- package/backend/dist/cjs/{meta.js → backend/src/meta.js} +9 -12
- package/backend/dist/cjs/backend/src/payments/paddle.d.ts +326 -0
- package/backend/dist/cjs/{payments → backend/src/payments}/paddle.js +377 -327
- package/backend/dist/cjs/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/cjs/backend/src/plugins/browser.js +15 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +248 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.js +379 -0
- package/backend/dist/{esm → cjs/backend/src}/plugins/mail/ui.d.ts +23 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/cjs/backend/src/rate_limit.d.ts +145 -0
- package/backend/dist/cjs/backend/src/rate_limit.js +549 -0
- package/backend/dist/cjs/{route.d.ts → backend/src/route.d.ts} +3 -10
- package/backend/dist/cjs/{route.js → backend/src/route.js} +23 -21
- package/backend/dist/cjs/backend/src/server.d.ts +485 -0
- package/backend/dist/cjs/{server.js → backend/src/server.js} +688 -873
- package/backend/dist/cjs/backend/src/splash_screen.d.ts +80 -0
- package/backend/dist/cjs/{splash_screen.js → backend/src/splash_screen.js} +24 -3
- package/backend/dist/cjs/backend/src/status.d.ts +74 -0
- package/backend/dist/cjs/{status.js → backend/src/status.js} +64 -64
- package/backend/dist/cjs/backend/src/stream.d.ts +376 -0
- package/backend/dist/cjs/{stream.js → backend/src/stream.js} +299 -276
- package/backend/dist/cjs/backend/src/users.d.ts +807 -0
- package/backend/dist/cjs/backend/src/users.js +1971 -0
- package/backend/dist/cjs/backend/src/utils.d.ts +16 -0
- package/backend/dist/cjs/{utils.js → backend/src/utils.js} +14 -77
- package/backend/dist/{esm → cjs/backend/src}/view.d.ts +33 -11
- package/backend/dist/cjs/backend/src/view.js +508 -0
- package/backend/dist/{esm → cjs/backend/src}/volt.d.ts +10 -1
- package/backend/dist/cjs/{volt.js → backend/src/volt.js} +8 -5
- package/backend/dist/cjs/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/cjs/frontend/src/modules/request.js +99 -0
- package/backend/dist/esm/{blacklist.d.ts → backend/src/blacklist.d.ts} +5 -3
- package/backend/dist/esm/{blacklist.js → backend/src/blacklist.js} +9 -6
- package/backend/dist/esm/{cli.js → backend/src/cli.js} +43 -60
- package/backend/dist/esm/backend/src/database/collection.d.ts +1543 -0
- package/backend/dist/esm/backend/src/database/collection.js +3510 -0
- package/backend/dist/esm/backend/src/database/database.d.ts +66 -0
- package/backend/dist/esm/{database → backend/src/database}/database.js +62 -103
- package/backend/dist/esm/backend/src/database/document.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/document.js +558 -0
- package/backend/dist/esm/backend/src/database/filters/filters.d.ts +6 -0
- package/backend/dist/esm/backend/src/database/filters/filters.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter.js +3 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test.js +505 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_test_v0.js +712 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.d.ts +50 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v0.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.d.ts +76 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v1.js +44 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v2.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.d.ts +219 -0
- package/backend/dist/esm/backend/src/database/filters/strict_filter_v3.js +1 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter.js +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.d.ts +5 -0
- package/backend/dist/esm/backend/src/database/filters/strict_update_filter_test.js +405 -0
- package/backend/dist/esm/backend/src/database/flatten.d.ts +75 -0
- package/backend/dist/esm/backend/src/database/flatten.js +22 -0
- package/backend/dist/esm/backend/src/database/flatten_test.d.ts +1 -0
- package/backend/dist/esm/backend/src/database/flatten_test.js +174 -0
- package/backend/dist/esm/backend/src/database/quota/quota.d.ts +461 -0
- package/backend/dist/esm/backend/src/database/quota/quota.js +1118 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.d.ts +534 -0
- package/backend/dist/esm/backend/src/database/quota/quota_v1.js +1242 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.d.ts +293 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.js +602 -0
- package/backend/dist/{cjs → esm/backend/src}/endpoint.d.ts +69 -46
- package/backend/dist/esm/{endpoint.js → backend/src/endpoint.js} +136 -127
- package/backend/dist/esm/backend/src/errors/index.d.ts +7 -0
- package/backend/dist/esm/backend/src/errors/index.js +7 -0
- package/backend/dist/{cjs/utils.d.ts → esm/backend/src/errors/internal_external.d.ts} +14 -22
- package/backend/dist/esm/backend/src/errors/internal_external.js +70 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +30 -0
- package/backend/dist/esm/backend/src/errors/system_error.d.ts +230 -0
- package/backend/dist/esm/backend/src/errors/system_error.js +402 -0
- package/backend/dist/esm/backend/src/events.d.ts +54 -0
- package/backend/dist/esm/backend/src/events.js +5 -0
- package/backend/dist/esm/{frontend.js → backend/src/frontend.js} +1 -1
- package/backend/dist/esm/{image_endpoint.d.ts → backend/src/image_endpoint.d.ts} +16 -1
- package/backend/dist/esm/{image_endpoint.js → backend/src/image_endpoint.js} +16 -20
- package/backend/dist/esm/backend/src/logger.d.ts +5 -0
- package/backend/dist/esm/backend/src/logger.js +8 -0
- package/backend/dist/esm/backend/src/meta.d.ts +64 -0
- package/backend/dist/esm/{meta.js → backend/src/meta.js} +15 -54
- package/backend/dist/esm/backend/src/payments/paddle.d.ts +326 -0
- package/backend/dist/esm/{payments → backend/src/payments}/paddle.js +417 -452
- package/backend/dist/esm/backend/src/plugins/browser.d.ts +1 -0
- package/backend/dist/esm/backend/src/plugins/browser.js +170 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +248 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.js +389 -0
- package/backend/dist/{cjs → esm/backend/src}/plugins/mail/ui.d.ts +23 -0
- package/backend/dist/esm/{plugins → backend/src/plugins}/mail/ui.js +3 -6
- package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/esm/{plugins → backend/src/plugins}/pdf.js +3 -3
- package/backend/dist/esm/backend/src/rate_limit.d.ts +145 -0
- package/backend/dist/esm/backend/src/rate_limit.js +667 -0
- package/backend/dist/esm/{route.d.ts → backend/src/route.d.ts} +3 -10
- package/backend/dist/esm/{route.js → backend/src/route.js} +26 -21
- package/backend/dist/esm/backend/src/server.d.ts +485 -0
- package/backend/dist/esm/{server.js → backend/src/server.js} +891 -1441
- package/backend/dist/esm/backend/src/splash_screen.d.ts +80 -0
- package/backend/dist/esm/{splash_screen.js → backend/src/splash_screen.js} +42 -55
- package/backend/dist/esm/backend/src/status.d.ts +74 -0
- package/backend/dist/esm/backend/src/status.js +199 -0
- package/backend/dist/esm/backend/src/stream.d.ts +376 -0
- package/backend/dist/esm/{stream.js → backend/src/stream.js} +327 -292
- package/backend/dist/esm/backend/src/users.d.ts +809 -0
- package/backend/dist/esm/backend/src/users.js +2140 -0
- package/backend/dist/esm/backend/src/utils.d.ts +16 -0
- package/backend/dist/esm/{utils.js → backend/src/utils.js} +20 -81
- package/backend/dist/{cjs → esm/backend/src}/view.d.ts +33 -11
- package/backend/dist/esm/{view.js → backend/src/view.js} +266 -86
- package/backend/dist/{cjs → esm/backend/src}/volt.d.ts +10 -1
- package/backend/dist/esm/{volt.js → backend/src/volt.js} +7 -4
- package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/esm/frontend/src/modules/request.js +117 -0
- package/frontend/dist/backend/src/database/collection.d.ts +1543 -0
- package/frontend/dist/backend/src/database/collection.js +3510 -0
- package/frontend/dist/backend/src/database/database.d.ts +66 -0
- package/frontend/dist/backend/src/database/database.js +196 -0
- package/frontend/dist/backend/src/database/filters/filters.d.ts +6 -0
- package/frontend/dist/backend/src/database/filters/filters.js +1 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.d.ts +223 -0
- package/frontend/dist/backend/src/database/filters/strict_filter.js +3 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.d.ts +165 -0
- package/frontend/dist/backend/src/database/filters/strict_update_filter.js +5 -0
- package/frontend/dist/backend/src/database/flatten.d.ts +75 -0
- package/frontend/dist/backend/src/database/flatten.js +22 -0
- package/frontend/dist/backend/src/endpoint.d.ts +204 -0
- package/frontend/dist/backend/src/endpoint.js +570 -0
- package/frontend/dist/backend/src/errors/index.d.ts +7 -0
- package/frontend/dist/backend/src/errors/index.js +7 -0
- package/frontend/dist/backend/src/errors/internal_external.d.ts +38 -0
- package/frontend/dist/backend/src/errors/internal_external.js +70 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +38 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.js +30 -0
- package/frontend/dist/backend/src/errors/system_error.d.ts +230 -0
- package/frontend/dist/backend/src/errors/system_error.js +402 -0
- package/frontend/dist/backend/src/events.d.ts +54 -0
- package/frontend/dist/backend/src/events.js +5 -0
- package/frontend/dist/backend/src/frontend.d.ts +11 -0
- package/frontend/dist/backend/src/frontend.js +12 -0
- package/frontend/dist/backend/src/image_endpoint.d.ts +39 -0
- package/frontend/dist/backend/src/image_endpoint.js +202 -0
- package/frontend/dist/backend/src/meta.d.ts +64 -0
- package/frontend/dist/backend/src/meta.js +110 -0
- package/frontend/dist/backend/src/payments/paddle.d.ts +326 -0
- package/frontend/dist/backend/src/payments/paddle.js +2256 -0
- package/frontend/dist/backend/src/plugins/mail/mail.d.ts +248 -0
- package/frontend/dist/backend/src/plugins/mail/mail.js +389 -0
- package/{backend/dist/esm/plugins/mail.d.ts → frontend/dist/backend/src/plugins/mail/ui.d.ts} +23 -0
- package/{backend/dist/esm/plugins/mail.js → frontend/dist/backend/src/plugins/mail/ui.js} +3 -6
- package/frontend/dist/backend/src/rate_limit.d.ts +145 -0
- package/frontend/dist/backend/src/rate_limit.js +673 -0
- package/frontend/dist/backend/src/route.d.ts +35 -0
- package/frontend/dist/backend/src/route.js +212 -0
- package/frontend/dist/backend/src/server.d.ts +485 -0
- package/frontend/dist/backend/src/server.js +2670 -0
- package/frontend/dist/backend/src/splash_screen.d.ts +80 -0
- package/frontend/dist/backend/src/splash_screen.js +135 -0
- package/frontend/dist/backend/src/status.d.ts +74 -0
- package/frontend/dist/backend/src/status.js +199 -0
- package/frontend/dist/backend/src/stream.d.ts +376 -0
- package/frontend/dist/backend/src/stream.js +1007 -0
- package/frontend/dist/backend/src/users.d.ts +807 -0
- package/frontend/dist/backend/src/users.js +2118 -0
- package/frontend/dist/backend/src/utils.d.ts +16 -0
- package/frontend/dist/backend/src/utils.js +241 -0
- package/frontend/dist/backend/src/view.d.ts +162 -0
- package/frontend/dist/backend/src/view.js +720 -0
- package/frontend/dist/frontend/src/elements/base.d.ts +4414 -0
- package/frontend/dist/{elements → frontend/src/elements}/base.js +3624 -260
- package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
- package/frontend/dist/{elements → frontend/src/elements}/module.js +53 -52
- package/frontend/dist/frontend/src/elements/types.d.ts +52 -0
- package/frontend/dist/frontend/src/elements/types.js +5 -0
- package/frontend/dist/frontend/src/modules/attachment.d.ts +126 -0
- package/frontend/dist/frontend/src/modules/attachment.js +306 -0
- package/frontend/dist/frontend/src/modules/auth.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/auth.js +80 -0
- package/frontend/dist/{modules → frontend/src/modules}/color.js +2 -2
- package/frontend/dist/frontend/src/modules/compression.d.ts +39 -0
- package/frontend/dist/frontend/src/modules/compression.js +102 -0
- package/frontend/dist/frontend/src/modules/cookies.d.ts +44 -0
- package/frontend/dist/frontend/src/modules/cookies.js +143 -0
- package/frontend/dist/frontend/src/modules/events.d.ts +31 -0
- package/frontend/dist/frontend/src/modules/events.js +74 -0
- package/frontend/dist/frontend/src/modules/google.d.ts +23 -0
- package/frontend/dist/frontend/src/modules/google.js +52 -0
- package/frontend/dist/frontend/src/modules/meta.d.ts +14 -0
- package/frontend/dist/{modules → frontend/src/modules}/meta.js +9 -7
- package/frontend/dist/{modules → frontend/src/modules}/paddle.d.ts +37 -134
- package/frontend/dist/{modules → frontend/src/modules}/paddle.js +620 -568
- package/frontend/dist/frontend/src/modules/request.d.ts +70 -0
- package/frontend/dist/frontend/src/modules/request.js +117 -0
- package/frontend/dist/frontend/src/modules/settings.d.ts +3 -0
- package/frontend/dist/frontend/src/modules/settings.js +5 -0
- package/frontend/dist/frontend/src/modules/statics.d.ts +21 -0
- package/frontend/dist/{modules → frontend/src/modules}/statics.js +15 -18
- package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
- package/frontend/dist/frontend/src/modules/support.js +53 -0
- package/frontend/dist/{modules → frontend/src/modules}/theme.d.ts +67 -0
- package/frontend/dist/{modules → frontend/src/modules}/theme.js +68 -38
- package/frontend/dist/frontend/src/modules/themes.d.ts +12 -0
- package/frontend/dist/frontend/src/modules/themes.js +22 -0
- package/frontend/dist/frontend/src/modules/user.d.ts +164 -0
- package/frontend/dist/frontend/src/modules/user.js +268 -0
- package/frontend/dist/frontend/src/modules/utils.d.ts +176 -0
- package/frontend/dist/frontend/src/modules/utils.js +569 -0
- package/frontend/dist/frontend/src/types/gradient.d.ts +29 -0
- package/frontend/dist/{types → frontend/src/types}/gradient.js +14 -18
- package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
- package/frontend/dist/{ui → frontend/src/ui}/border_button.js +7 -13
- package/frontend/dist/frontend/src/ui/button.d.ts +28 -0
- package/frontend/dist/{ui → frontend/src/ui}/button.js +21 -12
- package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
- package/frontend/dist/{ui → frontend/src/ui}/canvas.js +88 -55
- package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
- package/frontend/dist/{ui → frontend/src/ui}/checkbox.js +80 -41
- package/frontend/dist/{ui → frontend/src/ui}/code.d.ts +73 -6
- package/frontend/dist/{ui → frontend/src/ui}/code.js +55 -52
- package/frontend/dist/{ui → frontend/src/ui}/context_menu.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/context_menu.js +12 -17
- package/frontend/dist/{ui → frontend/src/ui}/css.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/css.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/divider.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/divider.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/dropdown.d.ts +57 -2
- package/frontend/dist/{ui → frontend/src/ui}/dropdown.js +87 -94
- package/frontend/dist/{ui → frontend/src/ui}/for_each.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/for_each.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/form.d.ts +6 -2
- package/frontend/dist/{ui → frontend/src/ui}/form.js +10 -7
- package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
- package/frontend/dist/{ui → frontend/src/ui}/frame_modes.js +16 -22
- package/frontend/dist/{ui → frontend/src/ui}/google_map.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/google_map.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/gradient.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/gradient.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/image.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/image.js +5 -5
- package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
- package/frontend/dist/{ui → frontend/src/ui}/input.js +346 -360
- package/frontend/dist/{ui → frontend/src/ui}/link.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/link.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/list.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/list.js +12 -6
- package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
- package/frontend/dist/{ui → frontend/src/ui}/loader_button.js +35 -47
- package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
- package/frontend/dist/{ui → frontend/src/ui}/loaders.js +11 -11
- package/frontend/dist/{ui → frontend/src/ui}/popup.d.ts +11 -6
- package/frontend/dist/{ui → frontend/src/ui}/popup.js +32 -18
- package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
- package/frontend/dist/{ui → frontend/src/ui}/pseudo.js +84 -8
- package/frontend/dist/{ui → frontend/src/ui}/scroller.d.ts +14 -2
- package/frontend/dist/{ui → frontend/src/ui}/scroller.js +37 -43
- package/frontend/dist/{ui → frontend/src/ui}/slider.d.ts +5 -1
- package/frontend/dist/{ui → frontend/src/ui}/slider.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/spacer.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/spacer.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/span.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/span.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/stack.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/stack.js +3 -9
- package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
- package/frontend/dist/{ui → frontend/src/ui}/steps.js +30 -45
- package/frontend/dist/{ui → frontend/src/ui}/style.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/style.js +3 -3
- package/frontend/dist/{ui → frontend/src/ui}/switch.d.ts +5 -1
- package/frontend/dist/{ui → frontend/src/ui}/switch.js +4 -4
- package/frontend/dist/{ui → frontend/src/ui}/table.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/table.js +6 -6
- package/frontend/dist/{ui → frontend/src/ui}/tabs.d.ts +45 -3
- package/frontend/dist/{ui → frontend/src/ui}/tabs.js +65 -40
- package/frontend/dist/{ui → frontend/src/ui}/text.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/text.js +3 -3
- package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
- package/frontend/dist/frontend/src/ui/title.js +272 -0
- package/frontend/dist/{ui → frontend/src/ui}/view.d.ts +4 -0
- package/frontend/dist/{ui → frontend/src/ui}/view.js +3 -3
- package/frontend/dist/{volt.d.ts → frontend/src/volt.d.ts} +3 -0
- package/frontend/dist/{volt.js → frontend/src/volt.js} +4 -0
- package/frontend/tools/bundle_d_ts.js +71 -0
- package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
- package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
- package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
- package/package.json +11 -12
- package/backend/dist/cjs/database/collection.d.ts +0 -160
- package/backend/dist/cjs/database/collection.js +0 -842
- package/backend/dist/cjs/database/database.d.ts +0 -121
- package/backend/dist/cjs/database/document.d.ts +0 -131
- package/backend/dist/cjs/database/document.js +0 -224
- package/backend/dist/cjs/database.d.ts +0 -502
- package/backend/dist/cjs/database.js +0 -2248
- package/backend/dist/cjs/logger.d.ts +0 -3
- package/backend/dist/cjs/meta.d.ts +0 -50
- package/backend/dist/cjs/mutex.d.ts +0 -24
- package/backend/dist/cjs/payments/paddle.d.ts +0 -160
- package/backend/dist/cjs/plugins/browser.d.ts +0 -36
- package/backend/dist/cjs/plugins/browser.js +0 -198
- package/backend/dist/cjs/plugins/css.d.ts +0 -11
- package/backend/dist/cjs/plugins/css.js +0 -80
- package/backend/dist/cjs/plugins/mail.d.ts +0 -277
- package/backend/dist/cjs/plugins/mail.js +0 -1370
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +0 -139
- package/backend/dist/cjs/plugins/ts/compiler.js +0 -750
- package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +0 -14
- package/backend/dist/cjs/plugins/ts/preprocessing.js +0 -440
- package/backend/dist/cjs/rate_limit.d.ts +0 -63
- package/backend/dist/cjs/rate_limit.js +0 -348
- package/backend/dist/cjs/request.deprc.d.ts +0 -48
- package/backend/dist/cjs/request.deprc.js +0 -572
- package/backend/dist/cjs/response.deprc.d.ts +0 -55
- package/backend/dist/cjs/response.deprc.js +0 -275
- package/backend/dist/cjs/server.d.ts +0 -342
- package/backend/dist/cjs/splash_screen.d.ts +0 -35
- package/backend/dist/cjs/status.d.ts +0 -61
- package/backend/dist/cjs/stream.d.ts +0 -79
- package/backend/dist/cjs/users.d.ts +0 -111
- package/backend/dist/cjs/users.js +0 -1817
- package/backend/dist/cjs/view.js +0 -352
- package/backend/dist/cjs/vinc.dev.d.ts +0 -3
- package/backend/dist/cjs/vinc.dev.js +0 -7
- package/backend/dist/css/adyen.css +0 -92
- package/backend/dist/css/volt.css +0 -70
- package/backend/dist/esm/database/collection.d.ts +0 -160
- package/backend/dist/esm/database/collection.js +0 -1328
- package/backend/dist/esm/database/database.d.ts +0 -121
- package/backend/dist/esm/database/document.d.ts +0 -131
- package/backend/dist/esm/database/document.js +0 -247
- package/backend/dist/esm/database.d.ts +0 -502
- package/backend/dist/esm/database.js +0 -2423
- package/backend/dist/esm/file_watcher.js +0 -329
- package/backend/dist/esm/logger.d.ts +0 -3
- package/backend/dist/esm/logger.js +0 -11
- package/backend/dist/esm/meta.d.ts +0 -50
- package/backend/dist/esm/mutex.d.ts +0 -24
- package/backend/dist/esm/mutex.js +0 -48
- package/backend/dist/esm/payments/paddle.d.ts +0 -160
- package/backend/dist/esm/plugins/browser.d.ts +0 -36
- package/backend/dist/esm/plugins/browser.js +0 -176
- package/backend/dist/esm/plugins/css.d.ts +0 -11
- package/backend/dist/esm/plugins/css.js +0 -90
- package/backend/dist/esm/plugins/ts/compiler.d.ts +0 -139
- package/backend/dist/esm/plugins/ts/compiler.js +0 -1194
- package/backend/dist/esm/plugins/ts/preprocessing.d.ts +0 -14
- package/backend/dist/esm/plugins/ts/preprocessing.js +0 -726
- package/backend/dist/esm/rate_limit.d.ts +0 -63
- package/backend/dist/esm/rate_limit.js +0 -417
- package/backend/dist/esm/request.deprc.d.ts +0 -48
- package/backend/dist/esm/request.deprc.js +0 -572
- package/backend/dist/esm/response.deprc.d.ts +0 -55
- package/backend/dist/esm/response.deprc.js +0 -275
- package/backend/dist/esm/server.d.ts +0 -342
- package/backend/dist/esm/splash_screen.d.ts +0 -35
- package/backend/dist/esm/status.d.ts +0 -61
- package/backend/dist/esm/status.js +0 -197
- package/backend/dist/esm/stream.d.ts +0 -79
- package/backend/dist/esm/users.d.ts +0 -111
- package/backend/dist/esm/users.js +0 -1935
- package/backend/dist/esm/vinc.dev.d.ts +0 -3
- package/backend/dist/esm/vinc.dev.js +0 -7
- package/frontend/dist/elements/base.d.ts +0 -9889
- package/frontend/dist/elements/module.d.ts +0 -30
- package/frontend/dist/modules/array.d.ts +0 -94
- package/frontend/dist/modules/array.js +0 -634
- package/frontend/dist/modules/auth.d.ts +0 -46
- package/frontend/dist/modules/auth.js +0 -139
- package/frontend/dist/modules/colors.d.ts +0 -1
- package/frontend/dist/modules/colors.js +0 -417
- package/frontend/dist/modules/compression.d.ts +0 -6
- package/frontend/dist/modules/compression.js +0 -999
- package/frontend/dist/modules/cookies.d.ts +0 -18
- package/frontend/dist/modules/cookies.js +0 -167
- package/frontend/dist/modules/date.d.ts +0 -142
- package/frontend/dist/modules/date.js +0 -493
- package/frontend/dist/modules/events.d.ts +0 -8
- package/frontend/dist/modules/events.js +0 -91
- package/frontend/dist/modules/google.d.ts +0 -11
- package/frontend/dist/modules/google.js +0 -54
- package/frontend/dist/modules/meta.d.ts +0 -10
- package/frontend/dist/modules/mutex.d.ts +0 -7
- package/frontend/dist/modules/mutex.js +0 -51
- package/frontend/dist/modules/number.d.ts +0 -16
- package/frontend/dist/modules/number.js +0 -23
- package/frontend/dist/modules/object.d.ts +0 -52
- package/frontend/dist/modules/object.js +0 -383
- package/frontend/dist/modules/scheme.d.ts +0 -227
- package/frontend/dist/modules/scheme.js +0 -531
- package/frontend/dist/modules/settings.d.ts +0 -3
- package/frontend/dist/modules/settings.js +0 -4
- package/frontend/dist/modules/statics.d.ts +0 -5
- package/frontend/dist/modules/string.d.ts +0 -124
- package/frontend/dist/modules/string.js +0 -745
- package/frontend/dist/modules/support.d.ts +0 -19
- package/frontend/dist/modules/support.js +0 -103
- package/frontend/dist/modules/themes.d.ts +0 -8
- package/frontend/dist/modules/themes.js +0 -18
- package/frontend/dist/modules/user.d.ts +0 -59
- package/frontend/dist/modules/user.js +0 -280
- package/frontend/dist/modules/utils.d.ts +0 -87
- package/frontend/dist/modules/utils.js +0 -923
- package/frontend/dist/types/gradient.d.ts +0 -12
- package/frontend/dist/ui/border_button.d.ts +0 -152
- package/frontend/dist/ui/button.d.ts +0 -21
- package/frontend/dist/ui/canvas.d.ts +0 -56
- package/frontend/dist/ui/checkbox.d.ts +0 -52
- package/frontend/dist/ui/frame_modes.d.ts +0 -25
- package/frontend/dist/ui/input.d.ts +0 -241
- package/frontend/dist/ui/loader_button.d.ts +0 -93
- package/frontend/dist/ui/loaders.d.ts +0 -57
- package/frontend/dist/ui/pseudo.d.ts +0 -16
- package/frontend/dist/ui/steps.d.ts +0 -59
- package/frontend/dist/ui/title.d.ts +0 -21
- package/frontend/dist/ui/title.js +0 -121
- package/frontend/examples/dashboard/dashboard.ts +0 -776
- /package/backend/dist/cjs/{cli.d.ts → backend/src/cli.d.ts} +0 -0
- /package/backend/dist/cjs/{file_watcher.d.ts → backend/src/database/document.d.ts} +0 -0
- /package/backend/dist/cjs/{file_watcher.js → backend/src/database/document.js} +0 -0
- /package/backend/dist/cjs/{plugins/pdf.d.ts → backend/src/database/filters/strict_filter_test.d.ts} +0 -0
- /package/backend/dist/{esm/file_watcher.d.ts → cjs/backend/src/database/filters/strict_filter_test_v0.d.ts} +0 -0
- /package/backend/dist/{esm/plugins/pdf.d.ts → cjs/backend/src/database/flatten_test.d.ts} +0 -0
- /package/backend/dist/cjs/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.d.ts +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/communication.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/mail/ui.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/pdf.js +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
- /package/backend/dist/cjs/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
- /package/backend/dist/cjs/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
- /package/backend/dist/cjs/{vinc.js → backend/src/vinc.js} +0 -0
- /package/backend/dist/esm/{cli.d.ts → backend/src/cli.d.ts} +0 -0
- /package/backend/dist/esm/{frontend.d.ts → backend/src/frontend.d.ts} +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.d.ts +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/communication.js +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.d.ts +0 -0
- /package/backend/dist/esm/{plugins → backend/src/plugins}/thread_monitor.js +0 -0
- /package/backend/dist/esm/{vinc.d.ts → backend/src/vinc.d.ts} +0 -0
- /package/backend/dist/esm/{vinc.js → backend/src/vinc.js} +0 -0
- /package/frontend/dist/{elements → frontend/src/elements}/register_element.d.ts +0 -0
- /package/frontend/dist/{elements → frontend/src/elements}/register_element.js +0 -0
- /package/frontend/dist/{modules → frontend/src/modules}/color.d.ts +0 -0
- /package/frontend/dist/{ui → frontend/src/ui}/ui.d.ts +0 -0
- /package/frontend/dist/{ui → frontend/src/ui}/ui.js +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Daan van den Bergh
|
|
3
|
+
* @copyright © 2025 - 2025 Daan van den Bergh. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import * as vlib from "@vandenberghinc/vlib";
|
|
6
|
+
import { SystemError } from "../../errors/system_error.js";
|
|
7
|
+
import { Collection, TransactionCollection } from "../collection.js";
|
|
8
|
+
import type { Server } from "../../server.js";
|
|
9
|
+
import { InvalidUsageError } from "../../errors/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* The quota manager.
|
|
12
|
+
* This manager can be used to manage and enforce usage quotas for different resources,
|
|
13
|
+
* for instance limiting money spent on tokens, or for rate limiting purposes.
|
|
14
|
+
*
|
|
15
|
+
* For managing monetary quotas, it is advised to use a nano-scale amount system
|
|
16
|
+
* (smallest unit integer accounting). See {@link Quota.to_nano} for converting to nano scale.
|
|
17
|
+
*
|
|
18
|
+
* The quota manager ties each operation to a specific user id. For creating system quota's you can
|
|
19
|
+
* use a non numeric `uid` to simulate a `uid` if needed.
|
|
20
|
+
*
|
|
21
|
+
* @template Type The allowed type for {@link Query.type}, provided at class level.
|
|
22
|
+
*/
|
|
23
|
+
export declare class QuotaManager {
|
|
24
|
+
/** The collection for database operations. */
|
|
25
|
+
collection: Collection<QuotaManager.Document>;
|
|
26
|
+
/** The system error options. */
|
|
27
|
+
system_error: QuotaManager.Opts["system_error"];
|
|
28
|
+
/**
|
|
29
|
+
* Construct a new quota manager with a specific quota type.
|
|
30
|
+
*
|
|
31
|
+
* @throws {InvalidUsageError} If {@link QuotaManager.Opts.collection} is already initialized and does not have the correct index.
|
|
32
|
+
* If the passed collection has manually assigned fields for {@link Collection.record_version} or {@link Collection.on_transform_version}.
|
|
33
|
+
* If the passed collection is transaction based.
|
|
34
|
+
*/
|
|
35
|
+
constructor(opts: QuotaManager.Opts);
|
|
36
|
+
/**
|
|
37
|
+
* Helper to create consistent query objects for MongoDB.
|
|
38
|
+
*/
|
|
39
|
+
private create_db_query;
|
|
40
|
+
/**
|
|
41
|
+
* Format a compact, human-readable quota identifier for logs and error messages.
|
|
42
|
+
*
|
|
43
|
+
* @param query An object carrying the `uid` and `id` fields.
|
|
44
|
+
* @returns A stable identifier of the form `<uid>:<id>`.
|
|
45
|
+
*/
|
|
46
|
+
private format_quota_id;
|
|
47
|
+
/**
|
|
48
|
+
* Get current quota status without modifying it.
|
|
49
|
+
*
|
|
50
|
+
* @note The `opts.retry` field defaults to `25`.
|
|
51
|
+
* @note System load errors are not saved inside this function.
|
|
52
|
+
*
|
|
53
|
+
* @param query The quota identifier arguments.
|
|
54
|
+
* @param opts Additional load options.
|
|
55
|
+
*
|
|
56
|
+
* @returns A load result depending on `opts`, see {@link Collection.LoadResult}
|
|
57
|
+
*
|
|
58
|
+
* @throws {Collection.NotFoundError} When `opts.throw !== false` and the quota does not exist.
|
|
59
|
+
* @throws {Collection.LoadError} When `opts.throw !== false` and a database error was encountered during the load operation.
|
|
60
|
+
* @throws {Collection.InvalidUsageError} When `opts.throw !== false` and the query is invalid.
|
|
61
|
+
*/
|
|
62
|
+
get<Default extends Collection.LoadOpts.Default<QuotaManager.Document> = undefined, Projection extends Collection.LoadOpts.Projection = undefined, Throw extends Collection.LoadOpts.Throw = undefined>(query: QuotaManager.Query, opts?: Collection.LoadOpts<QuotaManager.Document, Default, Projection, Throw>): Promise<Collection.WithThrow<Throw, InvalidUsageError, Collection.LoadResult<QuotaManager.Document, Default, Projection, Throw>>>;
|
|
63
|
+
/**
|
|
64
|
+
* Get current quota status without modifying it.
|
|
65
|
+
*
|
|
66
|
+
* @param query The quota identifier arguments.
|
|
67
|
+
* @param opts Additional load options, see {@link Collection.LoadOpts}.
|
|
68
|
+
*
|
|
69
|
+
* @returns An object containing error or status information,
|
|
70
|
+
* see {@link QuotaManager.GetStatusResult}
|
|
71
|
+
*/
|
|
72
|
+
get_status(query: QuotaManager.Query, opts?: Pick<Collection.LoadOpts, "timeout">): Promise<QuotaManager.GetStatusResult>;
|
|
73
|
+
/**
|
|
74
|
+
* List all quotas for a user, optionally filtered by type.
|
|
75
|
+
*
|
|
76
|
+
* @param uid The user identifier.
|
|
77
|
+
* @param type Optional quota type filter.
|
|
78
|
+
* @returns List of quotas with their current status.
|
|
79
|
+
*/
|
|
80
|
+
list({ uid, timeout, }: {
|
|
81
|
+
/** The user id of the quotas to list. */
|
|
82
|
+
uid: string;
|
|
83
|
+
/** Per-operation timeout in milliseconds, mapped to `maxTimeoutMS`. */
|
|
84
|
+
timeout?: number;
|
|
85
|
+
}): Promise<QuotaManager.ListedQuota[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Update or save quota configuration (`max`, `interval`) for an existing quota document,
|
|
88
|
+
* automatically creating the document if it does not exist.
|
|
89
|
+
*
|
|
90
|
+
* This method never resets runtime fields on existing documents:
|
|
91
|
+
* - On update: only `max` and `interval` are changed.
|
|
92
|
+
* - On insert: `usage` is initialized to `0` and `start` to the current UNIX timestamp (seconds).
|
|
93
|
+
*
|
|
94
|
+
* @param quota The configuration document (identity + {@link Quota.Opts}). Fields `usage` and `start`
|
|
95
|
+
* are forbidden at the type level and ignored defensively at runtime.
|
|
96
|
+
* @param opts Additional save options; see {@link Collection.SaveOpts}.
|
|
97
|
+
*
|
|
98
|
+
* @note The `opts.throw` field defaults to `true`.
|
|
99
|
+
*
|
|
100
|
+
* @returns The updated (or newly created) quota document, or an error-like result depending on `opts.throw`.
|
|
101
|
+
* See {@link Collection.SaveResult}.
|
|
102
|
+
*
|
|
103
|
+
* @throws {InvalidUsageError} When `opts.throw !== false` and validation fails.
|
|
104
|
+
* @throws {Collection.SaveError} When `opts.throw !== false` and a database error occurs during the save operation.
|
|
105
|
+
*/
|
|
106
|
+
set<Throw extends Collection.SaveOpts.Throw = true>(quota: QuotaManager.Document.Opts & {
|
|
107
|
+
usage?: never;
|
|
108
|
+
start?: never;
|
|
109
|
+
}, opts?: Pick<Collection.SaveOpts<undefined, true, Throw, true>, "throw" | "timeout">): Promise<Collection.WithThrow<Throw, InvalidUsageError, Collection.SaveResult<QuotaManager.Document, undefined, true, Throw>>>;
|
|
110
|
+
/**
|
|
111
|
+
* Reset quota usage to zero & timestamp to the current unix timestamp for the specified quota.
|
|
112
|
+
*
|
|
113
|
+
* @param query The quota identifier, see {@link QuotaManager.Query}.
|
|
114
|
+
* @param opts Additional save options, see {@link Collection.SaveOpts}
|
|
115
|
+
*
|
|
116
|
+
* @note The `opts.throw` field defaults to the default value of {@link Collection.SaveOpts.throw}.
|
|
117
|
+
*
|
|
118
|
+
* @returns The updated quota document after resetting quota or an error depending on `throw`.
|
|
119
|
+
* See {@link Collection.SaveResult}.
|
|
120
|
+
*
|
|
121
|
+
* @throws {Collection.NotFoundError} When `opts.throw !== false` and the quota does not exist.
|
|
122
|
+
* @throws {Collection.SaveError} When `opts.throw !== false` and a database error was encountered during the save operation.
|
|
123
|
+
* @throws {Collection.InvalidUsageError} When `opts.throw !== false` and the query is invalid.
|
|
124
|
+
*/
|
|
125
|
+
reset_usage<Throw extends Collection.SaveOpts.Throw = undefined>(query: QuotaManager.Query, opts?: Pick<Collection.SaveOpts<undefined, true, Throw, false>, "throw" | "timeout">): Promise<Collection.WithThrow<Throw, InvalidUsageError, Collection.SaveResult<QuotaManager.Document, undefined, true, Throw>>>;
|
|
126
|
+
/** Delete all quotas for a user. */
|
|
127
|
+
delete_by_user({ uid }: {
|
|
128
|
+
uid: string;
|
|
129
|
+
}): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Validate the required {@link limit_helper} parameters.
|
|
132
|
+
* @note requested_usage may be a negative number.
|
|
133
|
+
*/
|
|
134
|
+
private validate_limit_helper_params;
|
|
135
|
+
/**
|
|
136
|
+
* Validates quota limits and atomically increments usage if within bounds.
|
|
137
|
+
* Handles interval resets automatically in a single database operation.
|
|
138
|
+
*
|
|
139
|
+
* @warning Ensure the quota exists in the database, or define `upsert` to create it when needed.
|
|
140
|
+
*
|
|
141
|
+
* @note This automatically increments the quota usage with the requested usage when `perform_increment` is true.
|
|
142
|
+
* When `perform_increment` is false, it only validates availability without modifying the database.
|
|
143
|
+
*
|
|
144
|
+
* @returns Success with updated quota info or validation/error details.
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
limit_helper({ query, requested_usage, upsert, safety_ratio, check_limit, perform_increment, collection, }: QuotaManager.LimitOpts & {
|
|
148
|
+
/** Whether to enforce limit checks, defaults to `true`. */
|
|
149
|
+
check_limit?: boolean;
|
|
150
|
+
/** The database collection or transaction to use. */
|
|
151
|
+
collection: Collection<QuotaManager.Document> | TransactionCollection<QuotaManager.Document>;
|
|
152
|
+
}): Promise<QuotaManager.LimitFailure | QuotaManager.LimitSuccess>;
|
|
153
|
+
/**
|
|
154
|
+
* Validate quota limits and, optionally, atomically increment usage if within bounds.
|
|
155
|
+
* Handles interval resets automatically in a single database operation.
|
|
156
|
+
*
|
|
157
|
+
* @warning Ensure the quota exists in the database, or provide `upsert` to create it when needed.
|
|
158
|
+
*
|
|
159
|
+
* @param perform_increment When `true` (default), performs the atomic increment. When `false`,
|
|
160
|
+
* executes a dry-run validation without modifying the database.
|
|
161
|
+
*
|
|
162
|
+
* @note Negative `requested_usage` is not allowed. Use {@link increment} for decrements.
|
|
163
|
+
*
|
|
164
|
+
* @returns On success, returns the (possibly updated) quota and remaining capacity; on failure,
|
|
165
|
+
* returns a diagnostic indicating why the request was rejected.
|
|
166
|
+
*/
|
|
167
|
+
limit({ query, requested_usage, upsert, safety_ratio, perform_increment }: QuotaManager.LimitOpts & {
|
|
168
|
+
/** Whether to perform the increment, defaults to `true`. */
|
|
169
|
+
perform_increment?: boolean;
|
|
170
|
+
}): Promise<QuotaManager.LimitFailure | QuotaManager.LimitSuccess>;
|
|
171
|
+
/**
|
|
172
|
+
* Increment the usage on a quota.
|
|
173
|
+
*
|
|
174
|
+
* @warning This does not check for quota limits.
|
|
175
|
+
* @warning Ensure the quota exists in the database, or define `upsert` to create it when needed.
|
|
176
|
+
*
|
|
177
|
+
* @note This function allows for negative `requested_usage` values.
|
|
178
|
+
*
|
|
179
|
+
* @returns The updated quota record or a diagnostic if the quota was not found in the database or if the max retries have been exceeded.
|
|
180
|
+
*/
|
|
181
|
+
increment({ query, requested_usage, upsert, }: Omit<QuotaManager.LimitOpts, "safety_ratio">): Promise<QuotaManager.LimitFailure | QuotaManager.LimitSuccess>;
|
|
182
|
+
/**
|
|
183
|
+
* Validates multiple quota limits and atomically increments usage if within bounds.
|
|
184
|
+
* Handles interval resets automatically in a single database operation.
|
|
185
|
+
*
|
|
186
|
+
* This transaction based operation only commits changes if all quotas pass validation.
|
|
187
|
+
*
|
|
188
|
+
* @warning Ensure the quota exists in the database.
|
|
189
|
+
*
|
|
190
|
+
* @note This function does not allow for negative usage values, use {@link increment} for decrements.
|
|
191
|
+
* @note This automatically increments the quota usage with the requested usage.
|
|
192
|
+
*
|
|
193
|
+
* @param limits The quota limits to validate and increment upon success, or roll back upon failure.
|
|
194
|
+
*
|
|
195
|
+
* @returns Success with updated quota info or validation/error details.
|
|
196
|
+
*/
|
|
197
|
+
batch_limit({ limits }: {
|
|
198
|
+
limits: QuotaManager.BatchLimit[];
|
|
199
|
+
}): Promise<QuotaManager.BatchLimitFailure | QuotaManager.BatchLimitSuccess>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The quota manager module.
|
|
203
|
+
* This manager can be used to manage and enforce usage quotas for different resources,
|
|
204
|
+
* for instance limiting money spent on tokens, or for rate limiting purposes.
|
|
205
|
+
*
|
|
206
|
+
* For managing monetary quotas, it is advised to use a nano-scale amount system
|
|
207
|
+
* (smallest unit integer accounting). See {@link Quota.to_nano} for converting to nano scale.
|
|
208
|
+
*/
|
|
209
|
+
export declare namespace QuotaManager {
|
|
210
|
+
/**
|
|
211
|
+
* The constructor options of the {@link QuotaManager} class.
|
|
212
|
+
*/
|
|
213
|
+
interface Opts {
|
|
214
|
+
/** The parent server instance, used to create the database collection. */
|
|
215
|
+
server: Server;
|
|
216
|
+
/**s
|
|
217
|
+
* The options for initialized the collection.
|
|
218
|
+
* @warning
|
|
219
|
+
* Ensure the chosen collection name is unique for this quota manager when using multiple quota managers.
|
|
220
|
+
* Since there is only a single configurable `id` index field per quota.
|
|
221
|
+
* Therefore using multiple purpose specific quota managers is required.
|
|
222
|
+
* @warning
|
|
223
|
+
* The {@link Quota.interval} may not exceed the `ttl` duration, if passed.
|
|
224
|
+
*/
|
|
225
|
+
collection: Pick<Collection.Opts<QuotaManager.Document>, "ttl" | "name">;
|
|
226
|
+
/**
|
|
227
|
+
* Options for handling encountered system errors.
|
|
228
|
+
* See {@link SystemError}.
|
|
229
|
+
*/
|
|
230
|
+
system_error?: {
|
|
231
|
+
/**
|
|
232
|
+
* The collection used to save {@link SystemError}'s to.
|
|
233
|
+
* Defaults to {@link SystemError.collection}.
|
|
234
|
+
*
|
|
235
|
+
* @warning Ensure either {@link collection} or {@link SystemError.collection}
|
|
236
|
+
* is defined. Otherwise system errors are not saved to the database.
|
|
237
|
+
*/
|
|
238
|
+
collection?: Collection<SystemError.Document>;
|
|
239
|
+
/**
|
|
240
|
+
* The logger to use for creating system {@link SystemError}'s.
|
|
241
|
+
* Defaults to {@link SystemError.logger}.
|
|
242
|
+
*/
|
|
243
|
+
logger?: SystemError.Logger;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The interface for a quota search query.
|
|
248
|
+
*
|
|
249
|
+
* @dev_note Ensure this remains a FLAT interface, or update spread copies to deep copies.
|
|
250
|
+
*/
|
|
251
|
+
interface Query {
|
|
252
|
+
/** The user id (index attribute). */
|
|
253
|
+
uid: string;
|
|
254
|
+
/** The quota id, e.g. "my-project" (index attribute). */
|
|
255
|
+
id: string;
|
|
256
|
+
}
|
|
257
|
+
/** Nested types for the {@link QuotaManager.Query} type. */
|
|
258
|
+
namespace Query {
|
|
259
|
+
/**
|
|
260
|
+
* Validate {@link QuotaManager.Query} at runtime.
|
|
261
|
+
* @returns An error message if the query is invalid, or undefined if it is valid.
|
|
262
|
+
*/
|
|
263
|
+
function validate(query: Query): string | undefined;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Quota settings for managing costs.
|
|
267
|
+
* This interface can serves as a quota group which can be configured for account-wide, project-wide etc quotas.
|
|
268
|
+
*
|
|
269
|
+
* @dev_note Ensure this remains a FLAT interface, or update spread copies to deep copies.
|
|
270
|
+
*/
|
|
271
|
+
interface Quota {
|
|
272
|
+
/**
|
|
273
|
+
* The maximum amount of usage allowed.
|
|
274
|
+
* Allowed: positive finite floating number (decimals supported).
|
|
275
|
+
*/
|
|
276
|
+
max: number;
|
|
277
|
+
/**
|
|
278
|
+
* The time interval in SECONDS for the quota; when this interval has passed the usage will be reset.
|
|
279
|
+
* Recommended to be an integer number of seconds.
|
|
280
|
+
* @note This may not exceed the collections `ttl` duration, if set.
|
|
281
|
+
*/
|
|
282
|
+
interval: number;
|
|
283
|
+
/**
|
|
284
|
+
* The start timestamp in SECONDS of the quota interval period.
|
|
285
|
+
* This value is always persisted as an INTEGER (seconds since epoch).
|
|
286
|
+
*/
|
|
287
|
+
start: number;
|
|
288
|
+
/**
|
|
289
|
+
* The current amount of usage.
|
|
290
|
+
* Allowed: finite floating number (decimals supported). Never persisted below 0.
|
|
291
|
+
*/
|
|
292
|
+
usage: number;
|
|
293
|
+
}
|
|
294
|
+
/** Nested types for the {@link Quota} interface. */
|
|
295
|
+
namespace Quota {
|
|
296
|
+
/** The OpenAIQuery input options (excluding the usage & start attribute) */
|
|
297
|
+
type Opts = Omit<Quota, "usage" | "start">;
|
|
298
|
+
/** Nested types for the {@link Opts} interface. */
|
|
299
|
+
namespace Opts {
|
|
300
|
+
/** The schema to validate quota {@link Opts} */
|
|
301
|
+
const Schema: vlib.Schema.Entries.Opts;
|
|
302
|
+
/**
|
|
303
|
+
* Validate {@link Quota.Opts} at runtime.
|
|
304
|
+
* @returns An error message if the quota is invalid, or undefined if it is valid.
|
|
305
|
+
*/
|
|
306
|
+
function validate(quota: Quota.Opts, collection: Collection<QuotaManager.Document>): string | undefined;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Convert `null | undefined` to `undefined` (no-op).
|
|
310
|
+
*/
|
|
311
|
+
function to_nano(q: null | undefined): undefined;
|
|
312
|
+
/**
|
|
313
|
+
* Convert a numeric amount to its nano-scale integer.
|
|
314
|
+
*/
|
|
315
|
+
function to_nano(q: number): number;
|
|
316
|
+
/**
|
|
317
|
+
* Convert quota options to nano-scale by scaling `max`; `interval` is preserved.
|
|
318
|
+
*/
|
|
319
|
+
function to_nano(q: Quota.Opts): Quota.Opts;
|
|
320
|
+
}
|
|
321
|
+
/** The OpenAIQuery quota document. */
|
|
322
|
+
type Document = Quota & Query;
|
|
323
|
+
/** Nested types for the {@link Document} type. */
|
|
324
|
+
namespace Document {
|
|
325
|
+
/** Input options for creating a {@link Document} record. */
|
|
326
|
+
type Opts = Quota.Opts & Query;
|
|
327
|
+
/** Nested types for the {@link Document.Opts} type. */
|
|
328
|
+
namespace Opts {
|
|
329
|
+
/**
|
|
330
|
+
* Validate {@link Document.Opts} at runtime.
|
|
331
|
+
* @returns An error message if the quota is invalid, or undefined if it is valid.
|
|
332
|
+
*/
|
|
333
|
+
function validate(quota: QuotaManager.Document.Opts, collection: Collection<QuotaManager.Document>): string | undefined;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/** The listed quota from {@link QuotaManager.list}. */
|
|
337
|
+
interface ListedQuota {
|
|
338
|
+
/** The listed quota. */
|
|
339
|
+
quota: QuotaManager.Document;
|
|
340
|
+
/** The remaining usage left for this quota. */
|
|
341
|
+
remaining: number;
|
|
342
|
+
/** Percentage used for the quota. */
|
|
343
|
+
percentage_used: number;
|
|
344
|
+
/** Quota needs a reset, interval has expired. */
|
|
345
|
+
needs_reset: boolean;
|
|
346
|
+
}
|
|
347
|
+
/** The returned type of {@link QuotaManager.get_status} */
|
|
348
|
+
type GetStatusResult = {
|
|
349
|
+
found: false;
|
|
350
|
+
/** Diagnostic message. */
|
|
351
|
+
error: string;
|
|
352
|
+
/**
|
|
353
|
+
* The error reason.
|
|
354
|
+
* @note By default a {@link SystemError} is saved when the status is `system_error`.
|
|
355
|
+
*/
|
|
356
|
+
reason: "invalid_query" | "not_found" | "system_error";
|
|
357
|
+
} | {
|
|
358
|
+
/** Indicates the quota was found. */
|
|
359
|
+
found: true;
|
|
360
|
+
/** The current quota (or a virtual reset view if the window expired). */
|
|
361
|
+
quota: QuotaManager.Document;
|
|
362
|
+
/** Remaining capacity in the active window (never negative). */
|
|
363
|
+
remaining: number;
|
|
364
|
+
/** Percentage of the window used, clamped to [0, 100]. */
|
|
365
|
+
percentage_used: number;
|
|
366
|
+
/** Whether the interval needs a reset (i.e., has expired). */
|
|
367
|
+
needs_reset: boolean;
|
|
368
|
+
/** Seconds until reset (0 when the window already expired). */
|
|
369
|
+
time_until_reset: number;
|
|
370
|
+
};
|
|
371
|
+
/** The parameter options for {@link limit} and {@link increment} */
|
|
372
|
+
interface LimitOpts {
|
|
373
|
+
/** The quota identifier arguments. */
|
|
374
|
+
query: Query;
|
|
375
|
+
/** The amount of usage to increment, this may be a negative amount, must it must be a finite number. */
|
|
376
|
+
requested_usage: number;
|
|
377
|
+
/** The quota document to create if it doesn't exist, if left undefined, the quota document must exist in the collection, or the validation will fail. */
|
|
378
|
+
upsert?: Quota.Opts;
|
|
379
|
+
/**
|
|
380
|
+
* The usage validation safety ratio, used to prevent over-usage, defaults to `1.0`.
|
|
381
|
+
*
|
|
382
|
+
* The validation will be applied as:
|
|
383
|
+
* `would_exceeded = (requested_usage * safety_ratio) + current.usage > current.max`
|
|
384
|
+
*
|
|
385
|
+
* The incrementation caused by the safety ratio is not saved to the database.
|
|
386
|
+
*/
|
|
387
|
+
safety_ratio?: number;
|
|
388
|
+
/** Whether to perform the increment, defaults to `true`. */
|
|
389
|
+
perform_increment?: boolean;
|
|
390
|
+
}
|
|
391
|
+
/** The non allowed response of {@link limit}. */
|
|
392
|
+
interface LimitFailure {
|
|
393
|
+
/** Validation success indicator. */
|
|
394
|
+
success: false;
|
|
395
|
+
/**
|
|
396
|
+
* The limit failure status.
|
|
397
|
+
* @note By default a {@link SystemError} is saved when the status is `system_error`.
|
|
398
|
+
*/
|
|
399
|
+
status: "not_found" | "exceeded" | "would_exceed" | "invalid_usage" | "system_error";
|
|
400
|
+
/** The error message. */
|
|
401
|
+
error: string;
|
|
402
|
+
/** The quota document, if available. */
|
|
403
|
+
quota?: QuotaManager.Document;
|
|
404
|
+
/** The remaining quota usage. */
|
|
405
|
+
remaining?: number;
|
|
406
|
+
}
|
|
407
|
+
/** The allowed response of {@link limit}. */
|
|
408
|
+
interface LimitSuccess {
|
|
409
|
+
/** Validation success indicator. */
|
|
410
|
+
success: true;
|
|
411
|
+
/** The operation status, kept for consistency. */
|
|
412
|
+
status: "success";
|
|
413
|
+
/** The returned quota document. */
|
|
414
|
+
quota: QuotaManager.Document;
|
|
415
|
+
/** The remaining quota usage. */
|
|
416
|
+
remaining: number;
|
|
417
|
+
/** Whether the quota was reset. */
|
|
418
|
+
was_reset: boolean;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The batch limit query and requested usage for {@link batch_limit}.
|
|
422
|
+
*/
|
|
423
|
+
interface BatchLimit {
|
|
424
|
+
/** The query identifying the quota */
|
|
425
|
+
query: Query;
|
|
426
|
+
/** The requested usage amount */
|
|
427
|
+
requested_usage: number;
|
|
428
|
+
/**
|
|
429
|
+
* The usage validation safety ratio, used to prevent over-usage, defaults to `1.0`.
|
|
430
|
+
*
|
|
431
|
+
* The validation will be applied as:
|
|
432
|
+
* `would_exceeded = (requested_usage * safety_ratio) + current.usage > current.max`
|
|
433
|
+
*
|
|
434
|
+
* The incrementation caused by the safety ratio is not saved to the database.
|
|
435
|
+
*/
|
|
436
|
+
safety_ratio?: number;
|
|
437
|
+
/**
|
|
438
|
+
* The quota document to create if it doesn't exist, if left undefined, the quota document must exist in the collection, or the validation will fail.
|
|
439
|
+
* @dev_note We use `Quota.Opts` instead of `Document.Opts` so we can derive the query attrs from field `query`
|
|
440
|
+
*/
|
|
441
|
+
upsert?: Quota.Opts;
|
|
442
|
+
/** Whether to enforce limit checks, defaults to `true`. */
|
|
443
|
+
check_limit?: boolean;
|
|
444
|
+
/** Whether to perform the increment, defaults to `true`. */
|
|
445
|
+
perform_increment?: boolean;
|
|
446
|
+
}
|
|
447
|
+
/** The batch limit failure response. */
|
|
448
|
+
interface BatchLimitFailure extends LimitFailure {
|
|
449
|
+
/** The failed query identifying the quota */
|
|
450
|
+
failed_query: Query;
|
|
451
|
+
}
|
|
452
|
+
/** The batch limit success response. */
|
|
453
|
+
interface BatchLimitSuccess {
|
|
454
|
+
/** Validation success indicator. */
|
|
455
|
+
success: true;
|
|
456
|
+
/** The operation status, kept for consistency. */
|
|
457
|
+
status: "success";
|
|
458
|
+
/** The individual results for each quota. */
|
|
459
|
+
results: LimitSuccess[];
|
|
460
|
+
}
|
|
461
|
+
}
|