@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,534 @@
|
|
|
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 { InvalidUsageError } from "src/volt.js";
|
|
9
|
+
import { Server } from "../../server.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
|
+
* @template Type The allowed type for {@link Query.type}, provided at class level.
|
|
19
|
+
*/
|
|
20
|
+
export declare class QuotaManager<Query extends QuotaManager.QueryBase> {
|
|
21
|
+
/** The initialized database collection used by this quota manager. */
|
|
22
|
+
collection: Collection<QuotaManager.Document<Query>>;
|
|
23
|
+
/**
|
|
24
|
+
* A validator for queries.
|
|
25
|
+
* If provided each query will be validated by this validator.
|
|
26
|
+
* Should return an object with an optional error when occurred.
|
|
27
|
+
*/
|
|
28
|
+
query_validator: undefined | QuotaManager.QueryValidator<Query>;
|
|
29
|
+
/** The system error options. */
|
|
30
|
+
system_error: QuotaManager.Opts<Query>["system_error"];
|
|
31
|
+
/**
|
|
32
|
+
* Construct a new quota manager with a specific quota type.
|
|
33
|
+
*/
|
|
34
|
+
constructor(opts: QuotaManager.Opts<Query>);
|
|
35
|
+
/**
|
|
36
|
+
* Format a compact, human-readable query for logs and error messages.
|
|
37
|
+
*
|
|
38
|
+
* @param query An object carrying the `type` and `name` fields.
|
|
39
|
+
*
|
|
40
|
+
* @returns A stable query of the form `<key1>:<value1>_<key2>:<value2>`.
|
|
41
|
+
*/
|
|
42
|
+
private format_query;
|
|
43
|
+
/**
|
|
44
|
+
* Get current quota status without modifying it.
|
|
45
|
+
*
|
|
46
|
+
* @note The `opts.retry` field defaults to `25`.
|
|
47
|
+
* @note System load errors are not saved inside this function.
|
|
48
|
+
*
|
|
49
|
+
* @param query The quota identifier arguments.
|
|
50
|
+
* @param opts Additional load options.
|
|
51
|
+
*
|
|
52
|
+
* @returns A load result depending on `opts`, see {@link Collection.LoadResult}
|
|
53
|
+
*
|
|
54
|
+
* @throws {Collection.NotFoundError} When `opts.throw !== false` and the quota does not exist.
|
|
55
|
+
* @throws {Collection.LoadError} When `opts.throw !== false` and a database error was encountered during the load operation.
|
|
56
|
+
* @throws {Collection.InvalidUsageError} When `opts.throw !== false` and the query is invalid.
|
|
57
|
+
*/
|
|
58
|
+
get<Default extends Collection.LoadOpts.Default<QuotaManager.Document<Query>> = undefined, Projection extends Collection.LoadOpts.Projection = undefined, Throw extends Collection.LoadOpts.Throw = undefined>(query: Query, opts?: Collection.LoadOpts<QuotaManager.Document<Query>, Default, Projection, Throw>): Promise<Collection.WithThrow<Throw, InvalidUsageError, Collection.LoadResult<QuotaManager.Document<Query>, Default, Projection, Throw>>>;
|
|
59
|
+
/**
|
|
60
|
+
* Get current quota status without modifying it.
|
|
61
|
+
*
|
|
62
|
+
* @param query The quota identifier arguments.
|
|
63
|
+
* @param opts Additional load options, see {@link Collection.LoadOpts}.
|
|
64
|
+
*
|
|
65
|
+
* @returns An object containing error or status information,
|
|
66
|
+
* see {@link QuotaManager.GetStatusResult}
|
|
67
|
+
*/
|
|
68
|
+
get_status(query: Query, opts?: Pick<Collection.LoadOpts, "timeout">): Promise<QuotaManager.GetStatusResult<Query>>;
|
|
69
|
+
/**
|
|
70
|
+
* List all quotas for a user, optionally filtered by type.
|
|
71
|
+
*
|
|
72
|
+
* @param query The partial query to list quotas by.
|
|
73
|
+
* @param type Optional quota type filter.
|
|
74
|
+
* @returns List of quotas with their current status.
|
|
75
|
+
*/
|
|
76
|
+
list({ query, timeout, }: {
|
|
77
|
+
/** The query of documents to list. */
|
|
78
|
+
query: Partial<Query>;
|
|
79
|
+
/** Per-operation timeout in milliseconds, mapped to `maxTimeoutMS`. */
|
|
80
|
+
timeout?: number;
|
|
81
|
+
}): Promise<QuotaManager.ListedQuota<Query>[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Update or save quota configuration (`max`, `interval`) for an existing quota document,
|
|
84
|
+
* automatically creating the document if it does not exist.
|
|
85
|
+
*
|
|
86
|
+
* This method never resets runtime fields on existing documents:
|
|
87
|
+
* - On update: only `max` and `interval` are changed.
|
|
88
|
+
* - On insert: `usage` is initialized to `0` and `start` to the current UNIX timestamp (seconds).
|
|
89
|
+
*
|
|
90
|
+
* @param quota The configuration document (identity + {@link Quota.Opts}). Fields `usage` and `start`
|
|
91
|
+
* are forbidden at the type level and ignored defensively at runtime.
|
|
92
|
+
* @param opts Additional save options; see {@link Collection.SaveOpts}.
|
|
93
|
+
*
|
|
94
|
+
* @note The `opts.throw` field defaults to `true`.
|
|
95
|
+
*
|
|
96
|
+
* @returns The updated (or newly created) quota document, or an error-like result depending on `opts.throw`.
|
|
97
|
+
* See {@link Collection.SaveResult}.
|
|
98
|
+
*
|
|
99
|
+
* @throws {InvalidUsageError} When `opts.throw !== false` and validation fails.
|
|
100
|
+
* @throws {Collection.SaveError} When `opts.throw !== false` and a database error occurs during the save operation.
|
|
101
|
+
*/
|
|
102
|
+
set<Throw extends Collection.SaveOpts.Throw = true>(query: Query, quota: QuotaManager.Document.Opts<Query> & {
|
|
103
|
+
usage?: never;
|
|
104
|
+
start?: never;
|
|
105
|
+
}, opts?: Pick<Collection.SaveOpts<undefined, true, Throw, true>, "throw" | "timeout">): Promise<Collection.WithThrow<Throw, InvalidUsageError, Collection.SaveResult<QuotaManager.Document<Query>, undefined, true, Throw>>>;
|
|
106
|
+
/**
|
|
107
|
+
* Reset quota usage to zero & timestamp to the current unix timestamp for the specified quota.
|
|
108
|
+
*
|
|
109
|
+
* @param query The quota identifier, see {@link QuotaManager.Query}.
|
|
110
|
+
* @param opts Additional save options, see {@link Collection.SaveOpts}
|
|
111
|
+
*
|
|
112
|
+
* @note The `opts.throw` field defaults to the default value of {@link Collection.SaveOpts.throw}.
|
|
113
|
+
*
|
|
114
|
+
* @returns The updated quota document after resetting quota or an error depending on `throw`.
|
|
115
|
+
* See {@link Collection.SaveResult}.
|
|
116
|
+
*
|
|
117
|
+
* @throws {Collection.NotFoundError} When `opts.throw !== false` and the quota does not exist.
|
|
118
|
+
* @throws {Collection.SaveError} When `opts.throw !== false` and a database error was encountered during the save operation.
|
|
119
|
+
* @throws {Collection.InvalidUsageError} When `opts.throw !== false` and the query is invalid.
|
|
120
|
+
*/
|
|
121
|
+
reset_usage<Throw extends Collection.SaveOpts.Throw = undefined>(query: Query, opts?: Pick<Collection.SaveOpts<undefined, true, Throw, false>, "throw" | "timeout">): Promise<Collection.WithThrow<Throw, InvalidUsageError, Collection.SaveResult<QuotaManager.Document<Query>, undefined, true, Throw>>>;
|
|
122
|
+
/**
|
|
123
|
+
* Validate the required {@link limit_helper} parameters.
|
|
124
|
+
* @note requested_usage may be a negative number.
|
|
125
|
+
*/
|
|
126
|
+
private validate_limit_helper_params;
|
|
127
|
+
/**
|
|
128
|
+
* Validates quota limits and atomically increments usage if within bounds.
|
|
129
|
+
* Handles interval resets automatically in a single database operation.
|
|
130
|
+
*
|
|
131
|
+
* @warning Ensure the quota exists in the database, or define `upsert` to create it when needed.
|
|
132
|
+
*
|
|
133
|
+
* @note This automatically increments the quota usage with the requested usage when `perform_increment` is true.
|
|
134
|
+
* When `perform_increment` is false, it only validates availability without modifying the database.
|
|
135
|
+
*
|
|
136
|
+
* @returns Success with updated quota info or validation/error details.
|
|
137
|
+
*
|
|
138
|
+
*/
|
|
139
|
+
limit_helper({ query, requested_usage, upsert, safety_ratio, check_limit, perform_increment, collection, }: QuotaManager.LimitOpts<Query> & {
|
|
140
|
+
/** Whether to enforce limit checks, defaults to `true`. */
|
|
141
|
+
check_limit?: boolean;
|
|
142
|
+
/** The database collection or transaction to use. */
|
|
143
|
+
collection: Collection<QuotaManager.Document<Query>> | TransactionCollection<QuotaManager.Document<Query>>;
|
|
144
|
+
}): Promise<QuotaManager.LimitFailure<Query> | QuotaManager.LimitSuccess<Query>>;
|
|
145
|
+
/**
|
|
146
|
+
* Validate quota limits and, optionally, atomically increment usage if within bounds.
|
|
147
|
+
* Handles interval resets automatically in a single database operation.
|
|
148
|
+
*
|
|
149
|
+
* @warning Ensure the quota exists in the database, or provide `upsert` to create it when needed.
|
|
150
|
+
*
|
|
151
|
+
* @param perform_increment When `true` (default), performs the atomic increment. When `false`,
|
|
152
|
+
* executes a dry-run validation without modifying the database.
|
|
153
|
+
*
|
|
154
|
+
* @note Negative `requested_usage` is not allowed. Use {@link increment} for decrements.
|
|
155
|
+
*
|
|
156
|
+
* @returns On success, returns the (possibly updated) quota and remaining capacity; on failure,
|
|
157
|
+
* returns a diagnostic indicating why the request was rejected.
|
|
158
|
+
*/
|
|
159
|
+
limit({ query, requested_usage, upsert, safety_ratio, perform_increment }: QuotaManager.LimitOpts<Query> & {
|
|
160
|
+
/** Whether to perform the increment, defaults to `true`. */
|
|
161
|
+
perform_increment?: boolean;
|
|
162
|
+
}): Promise<QuotaManager.LimitFailure<Query> | QuotaManager.LimitSuccess<Query>>;
|
|
163
|
+
/**
|
|
164
|
+
* Increment the usage on a quota.
|
|
165
|
+
*
|
|
166
|
+
* @warning This does not check for quota limits.
|
|
167
|
+
* @warning Ensure the quota exists in the database, or define `upsert` to create it when needed.
|
|
168
|
+
*
|
|
169
|
+
* @note This function allows for negative `requested_usage` values.
|
|
170
|
+
*
|
|
171
|
+
* @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.
|
|
172
|
+
*/
|
|
173
|
+
increment({ query, requested_usage, upsert, }: Omit<QuotaManager.LimitOpts<Query>, "safety_ratio">): Promise<QuotaManager.LimitFailure<Query> | QuotaManager.LimitSuccess<Query>>;
|
|
174
|
+
/**
|
|
175
|
+
* Validates multiple quota limits and atomically increments usage if within bounds.
|
|
176
|
+
* Handles interval resets automatically in a single database operation.
|
|
177
|
+
*
|
|
178
|
+
* This transaction based operation only commits changes if all quotas pass validation.
|
|
179
|
+
*
|
|
180
|
+
* @warning Ensure the quota exists in the database.
|
|
181
|
+
*
|
|
182
|
+
* @note This function does not allow for negative usage values, use {@link increment} for decrements.
|
|
183
|
+
* @note This automatically increments the quota usage with the requested usage.
|
|
184
|
+
*
|
|
185
|
+
* @param limits The quota limits to validate and increment upon success, or roll back upon failure.
|
|
186
|
+
*
|
|
187
|
+
* @returns Success with updated quota info or validation/error details.
|
|
188
|
+
*/
|
|
189
|
+
batch_limit({ limits }: {
|
|
190
|
+
limits: QuotaManager.BatchLimit<Query>[];
|
|
191
|
+
}): Promise<QuotaManager.BatchLimitFailure<Query> | QuotaManager.BatchLimitSuccess<Query>>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The quota manager module.
|
|
195
|
+
* This manager can be used to manage and enforce usage quotas for different resources,
|
|
196
|
+
* for instance limiting money spent on tokens, or for rate limiting purposes.
|
|
197
|
+
*
|
|
198
|
+
* For managing monetary quotas, it is advised to use a nano-scale amount system
|
|
199
|
+
* (smallest unit integer accounting). See {@link Quota.to_nano} for converting to nano scale.
|
|
200
|
+
*/
|
|
201
|
+
export declare namespace QuotaManager {
|
|
202
|
+
/**
|
|
203
|
+
* The constructor options of the {@link QuotaManager} class.
|
|
204
|
+
*/
|
|
205
|
+
interface Opts<Query extends QueryBase> {
|
|
206
|
+
/**
|
|
207
|
+
* The initialized server instance.
|
|
208
|
+
*/
|
|
209
|
+
server: Server;
|
|
210
|
+
/**
|
|
211
|
+
* The options for initializing the database collection.
|
|
212
|
+
*
|
|
213
|
+
* Ensure the {@link Collection.Opts.name} field is unique and only used for this quota manager.
|
|
214
|
+
* Or it will cause undefined behaviour.
|
|
215
|
+
*/
|
|
216
|
+
collection: Pick<Collection.Opts<QuotaManager.Document<Query>>, "name" | "ttl">;
|
|
217
|
+
/**
|
|
218
|
+
* A validator for queries.
|
|
219
|
+
* If provided each query will be validated by this validator.
|
|
220
|
+
* Should return a `string` error message if validation fails,
|
|
221
|
+
* otherwise `undefined`.
|
|
222
|
+
* See {@link QueryValidator}.
|
|
223
|
+
*/
|
|
224
|
+
query_validator?: QueryValidator<Query>;
|
|
225
|
+
/**
|
|
226
|
+
* Options for handling encountered system errors.
|
|
227
|
+
* See {@link SystemError}.
|
|
228
|
+
*/
|
|
229
|
+
system_error?: {
|
|
230
|
+
/**
|
|
231
|
+
* The collection used to save {@link SystemError}'s to.
|
|
232
|
+
* Defaults to {@link SystemError.collection}.
|
|
233
|
+
*
|
|
234
|
+
* @warning Ensure either {@link collection} or {@link SystemError.collection}
|
|
235
|
+
* is defined. Otherwise system errors are not saved to the database.
|
|
236
|
+
*/
|
|
237
|
+
collection?: Collection<SystemError.Document>;
|
|
238
|
+
/**
|
|
239
|
+
* The logger to use for creating system {@link SystemError}'s.
|
|
240
|
+
* Defaults to {@link SystemError.logger}.
|
|
241
|
+
*/
|
|
242
|
+
logger?: SystemError.Logger;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The base type for queries.
|
|
247
|
+
* Simply an empty interface, the actual query should be defined by user in the `QuotaManager` `Query` generic.
|
|
248
|
+
*/
|
|
249
|
+
interface QueryBase {
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* A callback to verify queries.
|
|
253
|
+
* Should return a `string` error message if validation fails,
|
|
254
|
+
* otherwise `undefined`.
|
|
255
|
+
*/
|
|
256
|
+
type QueryValidator<Query extends QueryBase> = (query: Query) => undefined | string;
|
|
257
|
+
/**
|
|
258
|
+
* Quota settings for managing costs.
|
|
259
|
+
* This interface can serves as a quota group which can be configured for account-wide, project-wide etc quotas.
|
|
260
|
+
*
|
|
261
|
+
* @dev_note Ensure this remains a FLAT interface, or update spread copies to deep copies.
|
|
262
|
+
*/
|
|
263
|
+
interface Quota {
|
|
264
|
+
/**
|
|
265
|
+
* The maximum amount of usage allowed.
|
|
266
|
+
* Allowed: positive finite floating number (decimals supported).
|
|
267
|
+
*/
|
|
268
|
+
max: number;
|
|
269
|
+
/**
|
|
270
|
+
* The time interval in SECONDS for the quota; when this interval has passed the usage will be reset.
|
|
271
|
+
* Recommended to be an integer number of seconds.
|
|
272
|
+
*/
|
|
273
|
+
interval: number;
|
|
274
|
+
/**
|
|
275
|
+
* The start timestamp in SECONDS of the quota interval period.
|
|
276
|
+
* This value is always persisted as an INTEGER (seconds since epoch).
|
|
277
|
+
*/
|
|
278
|
+
start: number;
|
|
279
|
+
/**
|
|
280
|
+
* The current amount of usage.
|
|
281
|
+
* Allowed: finite floating number (decimals supported). Never persisted below 0.
|
|
282
|
+
*/
|
|
283
|
+
usage: number;
|
|
284
|
+
}
|
|
285
|
+
/** Nested types for the {@link Quota} interface. */
|
|
286
|
+
namespace Quota {
|
|
287
|
+
/** The OpenAIQuery input options (excluding the usage & start attribute) */
|
|
288
|
+
type Opts = Omit<Quota, "usage" | "start">;
|
|
289
|
+
/** Nested types for the {@link Opts} interface. */
|
|
290
|
+
namespace Opts {
|
|
291
|
+
/** The schema to validate quota {@link Opts} */
|
|
292
|
+
const Schema: vlib.Schema.Entries.Opts;
|
|
293
|
+
/**
|
|
294
|
+
* Validate {@link Quota.Opts} at runtime.
|
|
295
|
+
* @returns An error message if the quota is invalid, or undefined if it is valid.
|
|
296
|
+
*/
|
|
297
|
+
function validate(quota: Quota.Opts): string | undefined;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Convert `undefined` to `undefined` (no-op).
|
|
301
|
+
*/
|
|
302
|
+
function to_nano(q: undefined): undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Convert a numeric amount to its nano-scale integer.
|
|
305
|
+
*/
|
|
306
|
+
function to_nano(q: number): number;
|
|
307
|
+
/**
|
|
308
|
+
* Convert quota options to nano-scale by scaling `max`; `interval` is preserved.
|
|
309
|
+
*/
|
|
310
|
+
function to_nano(q: Quota.Opts): Quota.Opts;
|
|
311
|
+
}
|
|
312
|
+
/** The OpenAIQuery quota document. */
|
|
313
|
+
type Document<Query extends QueryBase> = Omit<Query, keyof Quota> & Quota;
|
|
314
|
+
/** Nested types for the {@link Document} type. */
|
|
315
|
+
namespace Document {
|
|
316
|
+
/** Input options for creating a {@link Document} record. */
|
|
317
|
+
type Opts<Query extends QueryBase> = Omit<Query, keyof Quota> & Quota.Opts;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* The available amount scales for cost/usage values.
|
|
321
|
+
* Either 1 (base unit) or 1e9 (nano unit).
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* - Currency: 1 = dollars/euros/etc, 1e9 = nano-units of that currency.
|
|
325
|
+
* - Generic units: 1 = unit, 1e9 = nano-units.
|
|
326
|
+
*/
|
|
327
|
+
type AmountScale = AmountScale.Base | AmountScale.Nano;
|
|
328
|
+
/** Nested types for the {@link AmountScale} type. */
|
|
329
|
+
namespace AmountScale {
|
|
330
|
+
/**
|
|
331
|
+
* Base scale (1). Represents whole units (e.g., dollars, tokens, units).
|
|
332
|
+
*/
|
|
333
|
+
type Base = 1;
|
|
334
|
+
/** Base scale constant. */
|
|
335
|
+
const Base: Base;
|
|
336
|
+
/**
|
|
337
|
+
* Nano scale (1e9). Represents smallest-unit integers (e.g., nano-units).
|
|
338
|
+
*/
|
|
339
|
+
type Nano = 1_000_000_000;
|
|
340
|
+
/** Nano scale constant. */
|
|
341
|
+
const Nano: Nano;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Branded alias to document intent: value is a non-negative safe integer at nano scale.
|
|
345
|
+
* This remains a number at runtime.
|
|
346
|
+
*/
|
|
347
|
+
type NanoInt = number;
|
|
348
|
+
/**
|
|
349
|
+
* Convert an amount between {@link AmountScale} values.
|
|
350
|
+
*
|
|
351
|
+
* Semantics:
|
|
352
|
+
* - to_scale === 1 ➜ return a precision float (presentation).
|
|
353
|
+
* - to_scale === 1_000_000_000 ➜ return a rounded safe integer (nano).
|
|
354
|
+
* - Same-scale:
|
|
355
|
+
* • scale 1 ➜ return value as-is (validated finite).
|
|
356
|
+
* • scale 1_000_000_000 ➜ require integer & safe integer.
|
|
357
|
+
*
|
|
358
|
+
* @param value The numeric amount to convert.
|
|
359
|
+
* @param from_scale The current scale of {@link value}.
|
|
360
|
+
* @param to_scale The target scale.
|
|
361
|
+
* @returns The converted amount at the requested scale.
|
|
362
|
+
* @throws Error if input is invalid or conversion would overflow.
|
|
363
|
+
*/
|
|
364
|
+
function to_scaled_amount(value: number, from_scale: AmountScale, to_scale: AmountScale): number;
|
|
365
|
+
/**
|
|
366
|
+
* Assert that an amount is a non-negative safe integer in nano scale.
|
|
367
|
+
*
|
|
368
|
+
* @param label A label for diagnostics.
|
|
369
|
+
* @param value The numeric value to validate.
|
|
370
|
+
* @param prefix Optional string prepended to the error message.
|
|
371
|
+
* @throws Error if the value is not a non-negative safe integer.
|
|
372
|
+
*/
|
|
373
|
+
function assert_nano_int(label: string, value: number, prefix?: string): asserts value is NanoInt;
|
|
374
|
+
/**
|
|
375
|
+
* Multiply an integer quantity by a scaled integer price to obtain a scaled integer cost.
|
|
376
|
+
* All arithmetic is integer-safe under IEEE-754 up to ~9e15.
|
|
377
|
+
*
|
|
378
|
+
* @param quantity Non-negative safe integer count.
|
|
379
|
+
* @param price_scaled Non-negative safe integer price in some integer scale (e.g., nano).
|
|
380
|
+
* @returns The product as a safe integer.
|
|
381
|
+
* @throws Error on invalid inputs or overflow.
|
|
382
|
+
*/
|
|
383
|
+
function mul_int_safe(quantity: number, price_scaled: number): number;
|
|
384
|
+
/**
|
|
385
|
+
* Rounding mode for integer division in critical accounting paths.
|
|
386
|
+
*/
|
|
387
|
+
type RoundingMode = "exact" | "floor" | "ceil" | "round";
|
|
388
|
+
/**
|
|
389
|
+
* Divide two non-negative safe integers with explicit rounding semantics.
|
|
390
|
+
*
|
|
391
|
+
* @param numerator The non-negative safe integer dividend.
|
|
392
|
+
* @param denominator The positive safe integer divisor.
|
|
393
|
+
* @param mode Rounding strategy (default: "exact").
|
|
394
|
+
* @returns Integer quotient under the selected mode.
|
|
395
|
+
* @throws Error on invalid inputs, division by zero,
|
|
396
|
+
* non-exact remainder in "exact" mode, or overflow.
|
|
397
|
+
*/
|
|
398
|
+
function div_int_safe(numerator: number, denominator: number, mode?: RoundingMode): number;
|
|
399
|
+
/**
|
|
400
|
+
* Safely add two integer values with overflow checking.
|
|
401
|
+
*
|
|
402
|
+
* @param a The first operand; may be negative. Must be a safe integer.
|
|
403
|
+
* @param b The second operand; may be negative. Must be a safe integer.
|
|
404
|
+
* @param label A descriptive label for error reporting.
|
|
405
|
+
* @returns The sum of `a` and `b` as a safe integer.
|
|
406
|
+
* @throws {Error} If either operand is not a safe integer, or if the sum would overflow.
|
|
407
|
+
*/
|
|
408
|
+
function add_int_safe(a: number, b: number, label: string): number;
|
|
409
|
+
/** The listed quota from {@link QuotaManager.list}. */
|
|
410
|
+
interface ListedQuota<Query extends QueryBase> {
|
|
411
|
+
/** The listed quota. */
|
|
412
|
+
quota: QuotaManager.Document<Query>;
|
|
413
|
+
/** The remaining usage left for this quota. */
|
|
414
|
+
remaining: number;
|
|
415
|
+
/** Percentage used for the quota. */
|
|
416
|
+
percentage_used: number;
|
|
417
|
+
/** Quota needs a reset, interval has expired. */
|
|
418
|
+
needs_reset: boolean;
|
|
419
|
+
}
|
|
420
|
+
/** The returned type of {@link QuotaManager.get_status} */
|
|
421
|
+
type GetStatusResult<Query extends QueryBase> = {
|
|
422
|
+
found: false;
|
|
423
|
+
/** Diagnostic message. */
|
|
424
|
+
error: string;
|
|
425
|
+
/**
|
|
426
|
+
* The error reason.
|
|
427
|
+
* @note By default a {@link SystemError} is saved when the status is `system_error`.
|
|
428
|
+
*/
|
|
429
|
+
reason: "invalid_query" | "not_found" | "system_error";
|
|
430
|
+
} | {
|
|
431
|
+
/** Indicates the quota was found. */
|
|
432
|
+
found: true;
|
|
433
|
+
/** The current quota (or a virtual reset view if the window expired). */
|
|
434
|
+
quota: QuotaManager.Document<Query>;
|
|
435
|
+
/** Remaining capacity in the active window (never negative). */
|
|
436
|
+
remaining: number;
|
|
437
|
+
/** Percentage of the window used, clamped to [0, 100]. */
|
|
438
|
+
percentage_used: number;
|
|
439
|
+
/** Whether the interval needs a reset (i.e., has expired). */
|
|
440
|
+
needs_reset: boolean;
|
|
441
|
+
/** Seconds until reset (0 when the window already expired). */
|
|
442
|
+
time_until_reset: number;
|
|
443
|
+
};
|
|
444
|
+
/** The parameter options for {@link limit} and {@link increment} */
|
|
445
|
+
interface LimitOpts<Query extends QueryBase> {
|
|
446
|
+
/** The quota identifier arguments. */
|
|
447
|
+
query: Query;
|
|
448
|
+
/** The amount of usage to increment, this may be a negative amount, must it must be a finite number. */
|
|
449
|
+
requested_usage: number;
|
|
450
|
+
/** 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. */
|
|
451
|
+
upsert?: Quota.Opts;
|
|
452
|
+
/**
|
|
453
|
+
* The usage validation safety ratio, used to prevent over-usage, defaults to `1.0`.
|
|
454
|
+
*
|
|
455
|
+
* The validation will be applied as:
|
|
456
|
+
* `would_exceeded = (requested_usage * safety_ratio) + current.usage > current.max`
|
|
457
|
+
*
|
|
458
|
+
* The incrementation caused by the safety ratio is not saved to the database.
|
|
459
|
+
*/
|
|
460
|
+
safety_ratio?: number;
|
|
461
|
+
/** Whether to perform the increment, defaults to `true`. */
|
|
462
|
+
perform_increment?: boolean;
|
|
463
|
+
}
|
|
464
|
+
/** The non allowed response of {@link limit}. */
|
|
465
|
+
interface LimitFailure<Query extends QueryBase> {
|
|
466
|
+
/** Validation success indicator. */
|
|
467
|
+
success: false;
|
|
468
|
+
/**
|
|
469
|
+
* The limit failure status.
|
|
470
|
+
* @note By default a {@link SystemError} is saved when the status is `system_error`.
|
|
471
|
+
*/
|
|
472
|
+
status: "not_found" | "exceeded" | "would_exceed" | "invalid_usage" | "system_error";
|
|
473
|
+
/** The error message. */
|
|
474
|
+
error: string;
|
|
475
|
+
/** The quota document, if available. */
|
|
476
|
+
quota?: QuotaManager.Document<Query>;
|
|
477
|
+
/** The remaining quota usage. */
|
|
478
|
+
remaining?: number;
|
|
479
|
+
}
|
|
480
|
+
/** The allowed response of {@link limit}. */
|
|
481
|
+
interface LimitSuccess<Query extends QueryBase> {
|
|
482
|
+
/** Validation success indicator. */
|
|
483
|
+
success: true;
|
|
484
|
+
/** The operation status, kept for consistency. */
|
|
485
|
+
status: "success";
|
|
486
|
+
/** The returned quota document. */
|
|
487
|
+
quota: QuotaManager.Document<Query>;
|
|
488
|
+
/** The remaining quota usage. */
|
|
489
|
+
remaining: number;
|
|
490
|
+
/** Whether the quota was reset. */
|
|
491
|
+
was_reset: boolean;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* The batch limit query and requested usage for {@link batch_limit}.
|
|
495
|
+
*/
|
|
496
|
+
interface BatchLimit<Query extends QueryBase> {
|
|
497
|
+
/** The query identifying the quota */
|
|
498
|
+
query: Query;
|
|
499
|
+
/** The requested usage amount */
|
|
500
|
+
requested_usage: number;
|
|
501
|
+
/**
|
|
502
|
+
* The usage validation safety ratio, used to prevent over-usage, defaults to `1.0`.
|
|
503
|
+
*
|
|
504
|
+
* The validation will be applied as:
|
|
505
|
+
* `would_exceeded = (requested_usage * safety_ratio) + current.usage > current.max`
|
|
506
|
+
*
|
|
507
|
+
* The incrementation caused by the safety ratio is not saved to the database.
|
|
508
|
+
*/
|
|
509
|
+
safety_ratio?: number;
|
|
510
|
+
/**
|
|
511
|
+
* 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.
|
|
512
|
+
* @dev_note We use `Quota.Opts` instead of `Document.Opts` so we can derive the query attrs from field `query`
|
|
513
|
+
*/
|
|
514
|
+
upsert?: Quota.Opts;
|
|
515
|
+
/** Whether to enforce limit checks, defaults to `true`. */
|
|
516
|
+
check_limit?: boolean;
|
|
517
|
+
/** Whether to perform the increment, defaults to `true`. */
|
|
518
|
+
perform_increment?: boolean;
|
|
519
|
+
}
|
|
520
|
+
/** The batch limit failure response. */
|
|
521
|
+
interface BatchLimitFailure<Query extends QueryBase> extends LimitFailure<Query> {
|
|
522
|
+
/** The failed query identifying the quota */
|
|
523
|
+
failed_query: Query;
|
|
524
|
+
}
|
|
525
|
+
/** The batch limit success response. */
|
|
526
|
+
interface BatchLimitSuccess<Query extends QueryBase> {
|
|
527
|
+
/** Validation success indicator. */
|
|
528
|
+
success: true;
|
|
529
|
+
/** The operation status, kept for consistency. */
|
|
530
|
+
status: "success";
|
|
531
|
+
/** The individual results for each quota. */
|
|
532
|
+
results: LimitSuccess<Query>[];
|
|
533
|
+
}
|
|
534
|
+
}
|