@vandenberghinc/volt 1.2.6 → 1.2.8
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/.libris/config.json +82 -0
- package/backend/dist/cjs/backend/src/blacklist.d.ts +12 -0
- package/backend/dist/cjs/backend/src/blacklist.js +78 -0
- package/backend/dist/cjs/backend/src/cli.d.ts +2 -0
- package/backend/dist/cjs/backend/src/cli.js +198 -0
- package/backend/dist/cjs/backend/src/database/collection.d.ts +1765 -0
- package/backend/dist/cjs/backend/src/database/collection.js +3301 -0
- package/backend/dist/cjs/backend/src/database/database.d.ts +92 -0
- package/backend/dist/cjs/backend/src/database/database.js +170 -0
- package/backend/dist/cjs/backend/src/database/document.d.ts +1 -0
- package/backend/dist/cjs/backend/src/database/document.js +15 -0
- 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.d.ts +1 -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.d.ts +1 -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 +78 -0
- package/backend/dist/cjs/backend/src/database/flatten.js +53 -0
- package/backend/dist/cjs/backend/src/database/flatten_test.d.ts +1 -0
- package/backend/dist/cjs/backend/src/database/flatten_test.js +175 -0
- package/backend/dist/cjs/backend/src/database/quota/quoata_v2.d.ts +533 -0
- package/backend/dist/cjs/backend/src/database/quota/quoata_v2.js +1046 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.d.ts +551 -0
- package/backend/dist/cjs/backend/src/database/quota/quota.js +1108 -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 +412 -0
- package/backend/dist/cjs/backend/src/database/quota/safe_int.js +745 -0
- package/backend/dist/cjs/backend/src/endpoint.d.ts +346 -0
- package/backend/dist/cjs/backend/src/endpoint.js +468 -0
- 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/cjs/backend/src/errors/internal_external.d.ts +52 -0
- package/backend/dist/cjs/backend/src/errors/internal_external.js +95 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.d.ts +41 -0
- package/backend/dist/cjs/backend/src/errors/invalid_usage_error.js +47 -0
- package/backend/dist/cjs/backend/src/errors/system_error.d.ts +261 -0
- package/backend/dist/cjs/backend/src/errors/system_error.js +436 -0
- package/backend/dist/cjs/backend/src/events.d.ts +97 -0
- package/backend/dist/cjs/backend/src/events.js +15 -0
- package/backend/dist/cjs/backend/src/frontend.d.ts +13 -0
- package/backend/dist/cjs/backend/src/frontend.js +56 -0
- package/backend/dist/cjs/backend/src/image_endpoint.d.ts +44 -0
- package/backend/dist/cjs/backend/src/image_endpoint.js +185 -0
- package/backend/dist/cjs/backend/src/index.d.ts +23 -0
- package/backend/dist/cjs/backend/src/index.js +70 -0
- 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 +112 -0
- package/backend/dist/cjs/backend/src/meta.js +181 -0
- package/backend/dist/cjs/backend/src/payments/paddle.d.ts +329 -0
- package/backend/dist/cjs/backend/src/payments/paddle.js +1996 -0
- package/backend/dist/cjs/backend/src/payments/stripe/checkout.d.ts +113 -0
- package/backend/dist/cjs/backend/src/payments/stripe/checkout.js +295 -0
- package/backend/dist/cjs/backend/src/payments/stripe/customers.d.ts +17 -0
- package/backend/dist/cjs/backend/src/payments/stripe/customers.js +164 -0
- package/backend/dist/cjs/backend/src/payments/stripe/error.d.ts +74 -0
- package/backend/dist/cjs/backend/src/payments/stripe/error.js +64 -0
- package/backend/dist/cjs/backend/src/payments/stripe/events.d.ts +155 -0
- package/backend/dist/cjs/backend/src/payments/stripe/events.js +15 -0
- package/backend/dist/cjs/backend/src/payments/stripe/meters.d.ts +105 -0
- package/backend/dist/cjs/backend/src/payments/stripe/meters.js +230 -0
- package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.d.ts +58 -0
- package/backend/dist/cjs/backend/src/payments/stripe/payment_methods.js +109 -0
- package/backend/dist/cjs/backend/src/payments/stripe/products.d.ts +519 -0
- package/backend/dist/cjs/backend/src/payments/stripe/products.js +650 -0
- package/backend/dist/cjs/backend/src/payments/stripe/stripe.d.ts +215 -0
- package/backend/dist/cjs/backend/src/payments/stripe/stripe.js +468 -0
- package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.d.ts +172 -0
- package/backend/dist/cjs/backend/src/payments/stripe/subscriptions.js +557 -0
- package/backend/dist/cjs/backend/src/payments/stripe/utils.d.ts +63 -0
- package/backend/dist/cjs/backend/src/payments/stripe/utils.js +118 -0
- package/backend/dist/cjs/backend/src/payments/stripe/webhooks.d.ts +105 -0
- package/backend/dist/cjs/backend/src/payments/stripe/webhooks.js +627 -0
- 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/communication.d.ts +70 -0
- package/backend/dist/cjs/backend/src/plugins/communication.js +196 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.d.ts +255 -0
- package/backend/dist/cjs/backend/src/plugins/mail/mail.js +381 -0
- package/backend/dist/cjs/backend/src/plugins/mail/ui.d.ts +297 -0
- package/backend/dist/cjs/backend/src/plugins/mail/ui.js +1370 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/cjs/backend/src/plugins/pdf.js +1456 -0
- package/backend/dist/cjs/backend/src/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/cjs/backend/src/plugins/thread_monitor.js +116 -0
- package/backend/dist/cjs/backend/src/rate_limit.d.ts +148 -0
- package/backend/dist/cjs/backend/src/rate_limit.js +543 -0
- package/backend/dist/cjs/backend/src/route.d.ts +39 -0
- package/backend/dist/cjs/backend/src/route.js +172 -0
- package/backend/dist/cjs/backend/src/server.d.ts +502 -0
- package/backend/dist/cjs/backend/src/server.js +1710 -0
- package/backend/dist/cjs/backend/src/server.old.d.ts +594 -0
- package/backend/dist/cjs/backend/src/server.old.js +2058 -0
- package/backend/dist/cjs/backend/src/splash_screen.d.ts +93 -0
- package/backend/dist/cjs/backend/src/splash_screen.js +119 -0
- package/backend/dist/cjs/backend/src/status.d.ts +89 -0
- package/backend/dist/cjs/backend/src/status.js +211 -0
- package/backend/dist/cjs/backend/src/stream.d.ts +494 -0
- package/backend/dist/cjs/backend/src/stream.js +1370 -0
- package/backend/dist/cjs/backend/src/users.d.ts +926 -0
- package/backend/dist/cjs/backend/src/users.js +2223 -0
- package/backend/dist/cjs/backend/src/utils.d.ts +22 -0
- package/backend/dist/cjs/backend/src/utils.js +626 -0
- package/backend/dist/cjs/backend/src/view.d.ts +115 -0
- package/backend/dist/cjs/backend/src/view.js +519 -0
- package/backend/dist/cjs/backend/src/vinc.d.ts +6 -0
- package/backend/dist/cjs/backend/src/vinc.js +40 -0
- package/backend/dist/cjs/backend/src/volt.d.ts +24 -0
- package/backend/dist/cjs/backend/src/volt.js +72 -0
- 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/cjs/package.json +1 -0
- package/backend/dist/esm/backend/src/blacklist.d.ts +12 -0
- package/backend/dist/esm/backend/src/blacklist.js +52 -0
- package/backend/dist/esm/backend/src/cli.d.ts +2 -0
- package/backend/dist/esm/backend/src/cli.js +211 -0
- package/backend/dist/esm/backend/src/database/collection.d.ts +1765 -0
- package/backend/dist/esm/backend/src/database/collection.js +3779 -0
- package/backend/dist/esm/backend/src/database/database.d.ts +92 -0
- package/backend/dist/esm/backend/src/database/database.js +214 -0
- 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 +415 -0
- package/backend/dist/esm/backend/src/database/flatten.d.ts +78 -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/quoata_v2.d.ts +533 -0
- package/backend/dist/esm/backend/src/database/quota/quoata_v2.js +1155 -0
- package/backend/dist/esm/backend/src/database/quota/quota.d.ts +551 -0
- package/backend/dist/esm/backend/src/database/quota/quota.js +1219 -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 +412 -0
- package/backend/dist/esm/backend/src/database/quota/safe_int.js +810 -0
- package/backend/dist/esm/backend/src/endpoint.d.ts +346 -0
- package/backend/dist/esm/backend/src/endpoint.js +479 -0
- 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/esm/backend/src/errors/internal_external.d.ts +52 -0
- package/backend/dist/esm/backend/src/errors/internal_external.js +86 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.d.ts +41 -0
- package/backend/dist/esm/backend/src/errors/invalid_usage_error.js +33 -0
- package/backend/dist/esm/backend/src/errors/system_error.d.ts +261 -0
- package/backend/dist/esm/backend/src/errors/system_error.js +444 -0
- package/backend/dist/esm/backend/src/events.d.ts +97 -0
- package/backend/dist/esm/backend/src/events.js +5 -0
- package/backend/dist/esm/backend/src/frontend.d.ts +13 -0
- package/backend/dist/esm/backend/src/frontend.js +23 -0
- package/backend/dist/esm/backend/src/image_endpoint.d.ts +44 -0
- package/backend/dist/esm/backend/src/image_endpoint.js +196 -0
- package/backend/dist/esm/backend/src/index.d.ts +23 -0
- package/backend/dist/esm/backend/src/index.js +26 -0
- 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 +112 -0
- package/backend/dist/esm/backend/src/meta.js +152 -0
- package/backend/dist/esm/backend/src/payments/paddle.d.ts +329 -0
- package/backend/dist/esm/backend/src/payments/paddle.js +2276 -0
- package/backend/dist/esm/backend/src/payments/stripe/checkout.d.ts +113 -0
- package/backend/dist/esm/backend/src/payments/stripe/checkout.js +356 -0
- package/backend/dist/esm/backend/src/payments/stripe/customers.d.ts +17 -0
- package/backend/dist/esm/backend/src/payments/stripe/customers.js +193 -0
- package/backend/dist/esm/backend/src/payments/stripe/error.d.ts +74 -0
- package/backend/dist/esm/backend/src/payments/stripe/error.js +51 -0
- package/backend/dist/esm/backend/src/payments/stripe/events.d.ts +155 -0
- package/backend/dist/esm/backend/src/payments/stripe/events.js +5 -0
- package/backend/dist/esm/backend/src/payments/stripe/meters.d.ts +105 -0
- package/backend/dist/esm/backend/src/payments/stripe/meters.js +318 -0
- package/backend/dist/esm/backend/src/payments/stripe/payment_methods.d.ts +58 -0
- package/backend/dist/esm/backend/src/payments/stripe/payment_methods.js +135 -0
- package/backend/dist/esm/backend/src/payments/stripe/products.d.ts +519 -0
- package/backend/dist/esm/backend/src/payments/stripe/products.js +896 -0
- package/backend/dist/esm/backend/src/payments/stripe/stripe.d.ts +215 -0
- package/backend/dist/esm/backend/src/payments/stripe/stripe.js +464 -0
- package/backend/dist/esm/backend/src/payments/stripe/subscriptions.d.ts +172 -0
- package/backend/dist/esm/backend/src/payments/stripe/subscriptions.js +754 -0
- package/backend/dist/esm/backend/src/payments/stripe/utils.d.ts +63 -0
- package/backend/dist/esm/backend/src/payments/stripe/utils.js +131 -0
- package/backend/dist/esm/backend/src/payments/stripe/webhooks.d.ts +105 -0
- package/backend/dist/esm/backend/src/payments/stripe/webhooks.js +752 -0
- 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/communication.d.ts +70 -0
- package/backend/dist/esm/backend/src/plugins/communication.js +169 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.d.ts +255 -0
- package/backend/dist/esm/backend/src/plugins/mail/mail.js +396 -0
- package/backend/dist/esm/backend/src/plugins/mail/ui.d.ts +297 -0
- package/backend/dist/esm/backend/src/plugins/mail/ui.js +1400 -0
- package/backend/dist/esm/backend/src/plugins/pdf.d.ts +1 -0
- package/backend/dist/esm/backend/src/plugins/pdf.js +1694 -0
- package/backend/dist/esm/backend/src/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm/backend/src/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm/backend/src/rate_limit.d.ts +148 -0
- package/backend/dist/esm/backend/src/rate_limit.js +667 -0
- package/backend/dist/esm/backend/src/route.d.ts +39 -0
- package/backend/dist/esm/backend/src/route.js +222 -0
- package/backend/dist/esm/backend/src/server.d.ts +502 -0
- package/backend/dist/esm/backend/src/server.js +2031 -0
- package/backend/dist/esm/backend/src/server.old.d.ts +594 -0
- package/backend/dist/esm/backend/src/server.old.js +2630 -0
- package/backend/dist/esm/backend/src/splash_screen.d.ts +93 -0
- package/backend/dist/esm/backend/src/splash_screen.js +156 -0
- package/backend/dist/esm/backend/src/status.d.ts +89 -0
- package/backend/dist/esm/backend/src/status.js +213 -0
- package/backend/dist/esm/backend/src/stream.d.ts +494 -0
- package/backend/dist/esm/backend/src/stream.js +1611 -0
- package/backend/dist/esm/backend/src/users.d.ts +926 -0
- package/backend/dist/esm/backend/src/users.js +2423 -0
- package/backend/dist/esm/backend/src/utils.d.ts +22 -0
- package/backend/dist/esm/backend/src/utils.js +463 -0
- package/backend/dist/esm/backend/src/view.d.ts +115 -0
- package/backend/dist/esm/backend/src/view.js +584 -0
- package/backend/dist/esm/backend/src/vinc.d.ts +6 -0
- package/backend/dist/esm/backend/src/vinc.js +6 -0
- package/backend/dist/esm/backend/src/volt.d.ts +24 -0
- package/backend/dist/esm/backend/src/volt.js +27 -0
- package/backend/dist/esm/frontend/src/modules/request.d.ts +70 -0
- package/backend/dist/esm/frontend/src/modules/request.js +117 -0
- package/backend/old/file_watcher.ts +359 -0
- package/backend/old/request.deprc.js +626 -0
- package/backend/old/response.deprc.js +354 -0
- package/frontend/dist/backend/src/database/collection.d.ts +1765 -0
- package/frontend/dist/backend/src/database/collection.js +3779 -0
- package/frontend/dist/backend/src/database/database.d.ts +92 -0
- package/frontend/dist/backend/src/database/database.js +214 -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 +78 -0
- package/frontend/dist/backend/src/database/flatten.js +22 -0
- package/frontend/dist/backend/src/endpoint.d.ts +346 -0
- package/frontend/dist/backend/src/endpoint.js +479 -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 +52 -0
- package/frontend/dist/backend/src/errors/internal_external.js +86 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.d.ts +41 -0
- package/frontend/dist/backend/src/errors/invalid_usage_error.js +33 -0
- package/frontend/dist/backend/src/errors/system_error.d.ts +261 -0
- package/frontend/dist/backend/src/errors/system_error.js +444 -0
- package/frontend/dist/backend/src/events.d.ts +97 -0
- package/frontend/dist/backend/src/events.js +5 -0
- package/frontend/dist/backend/src/frontend.d.ts +13 -0
- package/frontend/dist/backend/src/frontend.js +23 -0
- package/frontend/dist/backend/src/image_endpoint.d.ts +44 -0
- package/frontend/dist/backend/src/image_endpoint.js +196 -0
- package/frontend/dist/backend/src/meta.d.ts +112 -0
- package/frontend/dist/backend/src/meta.js +152 -0
- package/frontend/dist/backend/src/payments/paddle.d.ts +329 -0
- package/frontend/dist/backend/src/payments/paddle.js +2276 -0
- package/frontend/dist/backend/src/payments/stripe/checkout.d.ts +113 -0
- package/frontend/dist/backend/src/payments/stripe/checkout.js +356 -0
- package/frontend/dist/backend/src/payments/stripe/customers.d.ts +17 -0
- package/frontend/dist/backend/src/payments/stripe/customers.js +193 -0
- package/frontend/dist/backend/src/payments/stripe/error.d.ts +74 -0
- package/frontend/dist/backend/src/payments/stripe/error.js +51 -0
- package/frontend/dist/backend/src/payments/stripe/events.d.ts +155 -0
- package/frontend/dist/backend/src/payments/stripe/events.js +5 -0
- package/frontend/dist/backend/src/payments/stripe/meters.d.ts +105 -0
- package/frontend/dist/backend/src/payments/stripe/meters.js +318 -0
- package/frontend/dist/backend/src/payments/stripe/payment_methods.d.ts +58 -0
- package/frontend/dist/backend/src/payments/stripe/payment_methods.js +135 -0
- package/frontend/dist/backend/src/payments/stripe/products.d.ts +519 -0
- package/frontend/dist/backend/src/payments/stripe/products.js +896 -0
- package/frontend/dist/backend/src/payments/stripe/stripe.d.ts +215 -0
- package/frontend/dist/backend/src/payments/stripe/stripe.js +464 -0
- package/frontend/dist/backend/src/payments/stripe/subscriptions.d.ts +172 -0
- package/frontend/dist/backend/src/payments/stripe/subscriptions.js +754 -0
- package/frontend/dist/backend/src/payments/stripe/utils.d.ts +63 -0
- package/frontend/dist/backend/src/payments/stripe/utils.js +131 -0
- package/frontend/dist/backend/src/payments/stripe/webhooks.d.ts +105 -0
- package/frontend/dist/backend/src/payments/stripe/webhooks.js +752 -0
- package/frontend/dist/backend/src/plugins/mail/mail.d.ts +255 -0
- package/frontend/dist/backend/src/plugins/mail/mail.js +396 -0
- package/frontend/dist/backend/src/plugins/mail/ui.d.ts +297 -0
- package/frontend/dist/backend/src/plugins/mail/ui.js +1400 -0
- package/frontend/dist/backend/src/rate_limit.d.ts +148 -0
- package/frontend/dist/backend/src/rate_limit.js +667 -0
- package/frontend/dist/backend/src/route.d.ts +39 -0
- package/frontend/dist/backend/src/route.js +222 -0
- package/frontend/dist/backend/src/server.d.ts +502 -0
- package/frontend/dist/backend/src/server.js +2031 -0
- package/frontend/dist/backend/src/splash_screen.d.ts +93 -0
- package/frontend/dist/backend/src/splash_screen.js +156 -0
- package/frontend/dist/backend/src/status.d.ts +89 -0
- package/frontend/dist/backend/src/status.js +213 -0
- package/frontend/dist/backend/src/stream.d.ts +494 -0
- package/frontend/dist/backend/src/stream.js +1611 -0
- package/frontend/dist/backend/src/users.d.ts +926 -0
- package/frontend/dist/backend/src/users.js +2423 -0
- package/frontend/dist/backend/src/utils.d.ts +22 -0
- package/frontend/dist/backend/src/utils.js +463 -0
- package/frontend/dist/backend/src/view.d.ts +115 -0
- package/frontend/dist/backend/src/view.js +584 -0
- package/frontend/dist/frontend/src/css/adyen.css +92 -0
- package/frontend/dist/frontend/src/css/volt.css +75 -0
- package/frontend/dist/frontend/src/elements/base.d.ts +3743 -0
- package/frontend/dist/frontend/src/elements/base.js +12151 -0
- package/frontend/dist/frontend/src/elements/module.d.ts +95 -0
- package/frontend/dist/frontend/src/elements/module.js +216 -0
- package/frontend/dist/frontend/src/elements/register_element.d.ts +3 -0
- package/frontend/dist/frontend/src/elements/register_element.js +22 -0
- package/frontend/dist/frontend/src/elements/resize_query_manager.d.ts +0 -0
- package/frontend/dist/frontend/src/elements/resize_query_manager.js +150 -0
- 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/index.d.ts +21 -0
- package/frontend/dist/frontend/src/index.js +29 -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/frontend/src/modules/color.d.ts +160 -0
- package/frontend/dist/frontend/src/modules/color.js +316 -0
- 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 +79 -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/frontend/src/modules/meta.js +48 -0
- package/frontend/dist/frontend/src/modules/paddle.d.ts +1207 -0
- package/frontend/dist/frontend/src/modules/paddle.js +2594 -0
- 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/frontend/src/modules/statics.js +43 -0
- package/frontend/dist/frontend/src/modules/stripe/cart.d.ts +112 -0
- package/frontend/dist/frontend/src/modules/stripe/cart.js +321 -0
- package/frontend/dist/frontend/src/modules/stripe/checkout.d.ts +7 -0
- package/frontend/dist/frontend/src/modules/stripe/checkout.js +37 -0
- package/frontend/dist/frontend/src/modules/stripe/index.m.d.ts +6 -0
- package/frontend/dist/frontend/src/modules/stripe/index.m.js +6 -0
- package/frontend/dist/frontend/src/modules/stripe/payments.d.ts +58 -0
- package/frontend/dist/frontend/src/modules/stripe/payments.js +92 -0
- package/frontend/dist/frontend/src/modules/support.d.ts +30 -0
- package/frontend/dist/frontend/src/modules/support.js +53 -0
- package/frontend/dist/frontend/src/modules/theme.d.ts +133 -0
- package/frontend/dist/frontend/src/modules/theme.js +406 -0
- 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 +270 -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/frontend/src/types/gradient.js +79 -0
- package/frontend/dist/frontend/src/ui/border_button.d.ts +94 -0
- package/frontend/dist/frontend/src/ui/border_button.js +228 -0
- package/frontend/dist/frontend/src/ui/button.d.ts +241 -0
- package/frontend/dist/frontend/src/ui/button.js +682 -0
- package/frontend/dist/frontend/src/ui/canvas.d.ts +138 -0
- package/frontend/dist/frontend/src/ui/canvas.js +444 -0
- package/frontend/dist/frontend/src/ui/checkbox.d.ts +74 -0
- package/frontend/dist/frontend/src/ui/checkbox.js +321 -0
- package/frontend/dist/frontend/src/ui/code.d.ts +235 -0
- package/frontend/dist/frontend/src/ui/code.js +1007 -0
- package/frontend/dist/frontend/src/ui/context_menu.d.ts +36 -0
- package/frontend/dist/frontend/src/ui/context_menu.js +205 -0
- package/frontend/dist/frontend/src/ui/css.d.ts +16 -0
- package/frontend/dist/frontend/src/ui/css.js +48 -0
- package/frontend/dist/frontend/src/ui/divider.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/divider.js +78 -0
- package/frontend/dist/frontend/src/ui/dropdown.d.ts +176 -0
- package/frontend/dist/frontend/src/ui/dropdown.js +481 -0
- package/frontend/dist/frontend/src/ui/for_each.d.ts +37 -0
- package/frontend/dist/frontend/src/ui/for_each.js +92 -0
- package/frontend/dist/frontend/src/ui/form.d.ts +34 -0
- package/frontend/dist/frontend/src/ui/form.js +233 -0
- package/frontend/dist/frontend/src/ui/frame_modes.d.ts +37 -0
- package/frontend/dist/frontend/src/ui/frame_modes.js +108 -0
- package/frontend/dist/frontend/src/ui/google_map.d.ts +24 -0
- package/frontend/dist/frontend/src/ui/google_map.js +106 -0
- package/frontend/dist/frontend/src/ui/gradient.d.ts +25 -0
- package/frontend/dist/frontend/src/ui/gradient.js +131 -0
- package/frontend/dist/frontend/src/ui/image.d.ts +111 -0
- package/frontend/dist/frontend/src/ui/image.js +576 -0
- package/frontend/dist/frontend/src/ui/input.d.ts +392 -0
- package/frontend/dist/frontend/src/ui/input.js +1201 -0
- package/frontend/dist/frontend/src/ui/link.d.ts +25 -0
- package/frontend/dist/frontend/src/ui/link.js +140 -0
- package/frontend/dist/frontend/src/ui/list.d.ts +37 -0
- package/frontend/dist/frontend/src/ui/list.js +170 -0
- package/frontend/dist/frontend/src/ui/loader_button.d.ts +80 -0
- package/frontend/dist/frontend/src/ui/loader_button.js +193 -0
- package/frontend/dist/frontend/src/ui/loaders.d.ts +57 -0
- package/frontend/dist/frontend/src/ui/loaders.js +157 -0
- package/frontend/dist/frontend/src/ui/popup.d.ts +94 -0
- package/frontend/dist/frontend/src/ui/popup.js +510 -0
- package/frontend/dist/frontend/src/ui/pseudo.d.ts +44 -0
- package/frontend/dist/frontend/src/ui/pseudo.js +154 -0
- package/frontend/dist/frontend/src/ui/scroller.d.ts +105 -0
- package/frontend/dist/frontend/src/ui/scroller.js +1253 -0
- package/frontend/dist/frontend/src/ui/slider.d.ts +45 -0
- package/frontend/dist/frontend/src/ui/slider.js +217 -0
- package/frontend/dist/frontend/src/ui/spacer.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/spacer.js +78 -0
- package/frontend/dist/frontend/src/ui/span.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/span.js +73 -0
- package/frontend/dist/frontend/src/ui/stack.d.ts +66 -0
- package/frontend/dist/frontend/src/ui/stack.js +335 -0
- package/frontend/dist/frontend/src/ui/steps.d.ts +131 -0
- package/frontend/dist/frontend/src/ui/steps.js +308 -0
- package/frontend/dist/frontend/src/ui/style.d.ts +17 -0
- package/frontend/dist/frontend/src/ui/style.js +73 -0
- package/frontend/dist/frontend/src/ui/switch.d.ts +69 -0
- package/frontend/dist/frontend/src/ui/switch.js +357 -0
- package/frontend/dist/frontend/src/ui/table.d.ts +100 -0
- package/frontend/dist/frontend/src/ui/table.js +405 -0
- package/frontend/dist/frontend/src/ui/tabs.d.ts +111 -0
- package/frontend/dist/frontend/src/ui/tabs.js +424 -0
- package/frontend/dist/frontend/src/ui/text.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/text.js +83 -0
- package/frontend/dist/frontend/src/ui/title.d.ts +91 -0
- package/frontend/dist/frontend/src/ui/title.js +272 -0
- package/frontend/dist/frontend/src/ui/ui.d.ts +35 -0
- package/frontend/dist/frontend/src/ui/ui.js +38 -0
- package/frontend/dist/frontend/src/ui/view.d.ts +15 -0
- package/frontend/dist/frontend/src/ui/view.js +88 -0
- package/frontend/dist/frontend/src/volt.d.ts +20 -0
- package/frontend/dist/frontend/src/volt.js +27 -0
- package/frontend/examples/theme/theme.ts +58 -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/frontend/tools/scan_mixed_imports.js +69 -0
- package/package.json +1 -5
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
MeterProduct: () => MeterProduct,
|
|
21
|
+
initialize_products: () => initialize_products,
|
|
22
|
+
resolve_plan_to_parent_subscription: () => resolve_plan_to_parent_subscription
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
25
|
+
var import_error = require("./error.js");
|
|
26
|
+
var import_utils = require("./utils.js");
|
|
27
|
+
var MeterProduct;
|
|
28
|
+
(function(MeterProduct2) {
|
|
29
|
+
MeterProduct2.MONEY_METER_MAJOR_TO_PICO_CENTS_SHIFT = 14;
|
|
30
|
+
MeterProduct2.MONEY_METER_UNIT_AMOUNT_DECIMAL_CENTS = "0.000000000001";
|
|
31
|
+
})(MeterProduct || (MeterProduct = {}));
|
|
32
|
+
const app_product_id_metadata_key = "__volt_app_product_id";
|
|
33
|
+
const app_price_id_metadata_key = "__volt_app_price_id";
|
|
34
|
+
const app_price_signature_metadata_key = "__volt_app_price_signature";
|
|
35
|
+
const stripe_list_page_size = 100;
|
|
36
|
+
function validate_unit_amount(unit_amount, field_name) {
|
|
37
|
+
(0, import_utils.assert)(Number.isInteger(unit_amount), "invalid_product", `Property '${field_name}' must be an integer (smallest currency unit)`, { field_name, unit_amount });
|
|
38
|
+
(0, import_utils.assert)(unit_amount > 0, "invalid_product", `Property '${field_name}' must be > 0`, { field_name, unit_amount });
|
|
39
|
+
}
|
|
40
|
+
function normalize_unit_amount_decimal(unit_amount_decimal, field_name) {
|
|
41
|
+
(0, import_utils.assert)(typeof unit_amount_decimal === "string", "invalid_product", `Property '${field_name}' must be a string`, { field_name, unit_amount_decimal });
|
|
42
|
+
let s = unit_amount_decimal.trim();
|
|
43
|
+
(0, import_utils.assert)(s.length > 0, "invalid_product", `Property '${field_name}' must be non-empty`, { field_name });
|
|
44
|
+
(0, import_utils.assert)(/^\d+(\.\d{1,12})?$/.test(s), "invalid_product", `Property '${field_name}' must be a non-negative decimal with up to 12 decimals`, { field_name, unit_amount_decimal: s });
|
|
45
|
+
const dot = s.indexOf(".");
|
|
46
|
+
const whole_raw = dot >= 0 ? s.slice(0, dot) : s;
|
|
47
|
+
const frac_raw = dot >= 0 ? s.slice(dot + 1) : "";
|
|
48
|
+
let whole = whole_raw.replace(/^0+/, "");
|
|
49
|
+
if (whole === "")
|
|
50
|
+
whole = "0";
|
|
51
|
+
let frac = frac_raw;
|
|
52
|
+
if (frac.length > 0) {
|
|
53
|
+
frac = frac.replace(/0+$/, "");
|
|
54
|
+
}
|
|
55
|
+
s = frac.length > 0 ? `${whole}.${frac}` : whole;
|
|
56
|
+
(0, import_utils.assert)(s !== "0", "invalid_product", `Property '${field_name}' must be > 0`, { field_name, unit_amount_decimal: s });
|
|
57
|
+
(0, import_utils.assert)(/^\d+(\.\d{1,12})?$/.test(s), "invalid_product", "Normalization produced invalid decimal.", { s });
|
|
58
|
+
return s;
|
|
59
|
+
}
|
|
60
|
+
function resolve_unit_price_fields(product) {
|
|
61
|
+
if (product.kind === "money") {
|
|
62
|
+
return { unit_amount_decimal: MeterProduct.MONEY_METER_UNIT_AMOUNT_DECIMAL_CENTS };
|
|
63
|
+
}
|
|
64
|
+
if (product.kind === "units") {
|
|
65
|
+
const p = product.price;
|
|
66
|
+
if (typeof p === "number") {
|
|
67
|
+
(0, import_utils.assert)(Number.isInteger(p), "invalid_product", "Property 'price' must be an integer (smallest currency unit)", { field_name: "price", unit_amount: p });
|
|
68
|
+
(0, import_utils.assert)(p > 0, "invalid_product", "Property 'price' must be > 0", { field_name: "price", unit_amount: p });
|
|
69
|
+
return { unit_amount: p };
|
|
70
|
+
}
|
|
71
|
+
(0, import_utils.assert)(p !== null && typeof p === "object", "invalid_product", "Property 'price' must be a number or { decimals: string }", { price: p });
|
|
72
|
+
const decimals = p.decimals;
|
|
73
|
+
(0, import_utils.assert)(typeof decimals === "string", "invalid_product", "Property 'price.decimals' must be a string", { price: p });
|
|
74
|
+
return { unit_amount_decimal: normalize_unit_amount_decimal(decimals, "price.decimals") };
|
|
75
|
+
}
|
|
76
|
+
product.kind.toString();
|
|
77
|
+
throw new import_error.InternalStripeError("invalid_product", `Unsupported meter product kind: ${product.kind}`, { kind: product.kind });
|
|
78
|
+
}
|
|
79
|
+
function validate_quantity_rules(quantity_rules) {
|
|
80
|
+
if (!quantity_rules) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { min, max } = quantity_rules;
|
|
84
|
+
if (min !== void 0) {
|
|
85
|
+
(0, import_utils.assert)(Number.isInteger(min) && min >= 1, "invalid_product", "Quantity_rules.min must be an integer >= 1", {
|
|
86
|
+
min
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (max !== void 0) {
|
|
90
|
+
(0, import_utils.assert)(Number.isInteger(max) && max >= 1, "invalid_product", "Quantity_rules.max must be an integer >= 1", {
|
|
91
|
+
max
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (min !== void 0 && max !== void 0) {
|
|
95
|
+
(0, import_utils.assert)(min <= max, "invalid_product", "Quantity_rules.min must be <= quantity_rules.max", { min, max });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function validate_images(images) {
|
|
99
|
+
if (!images) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
(0, import_utils.assert)(Array.isArray(images), "invalid_product", "Images must be an array", { images });
|
|
103
|
+
(0, import_utils.assert)(images.length <= 8, "invalid_product", "Images must contain at most 8 URLs", { count: images.length });
|
|
104
|
+
for (const image of images) {
|
|
105
|
+
(0, import_utils.assert)(typeof image === "string" && image.trim().length > 0, "invalid_product", "Image URL must be a non-empty string", { image });
|
|
106
|
+
(0, import_utils.assert)(/^https:\/\/\S+$/i.test(image.trim()), "invalid_product", "Image URL must be an https URL", { image });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function make_one_time_price_signature(opts) {
|
|
110
|
+
return `v1|one_time|${opts.currency}|${opts.unit_amount}|${opts.tax_behavior}`;
|
|
111
|
+
}
|
|
112
|
+
function make_recurring_price_signature(opts) {
|
|
113
|
+
const meter_part = opts.usage_type === "metered" ? `|meter:${opts.meter_id ?? ""}` : "|meter:";
|
|
114
|
+
const amount_part = opts.unit_amount_decimal !== void 0 ? opts.unit_amount_decimal : opts.unit_amount ?? 0;
|
|
115
|
+
return `v1|recurring|${opts.currency}|${amount_part}|${opts.tax_behavior}|${opts.interval}|${opts.interval_count}|usage:${opts.usage_type}${meter_part}`;
|
|
116
|
+
}
|
|
117
|
+
function make_price_app_id(product_id, plan_id) {
|
|
118
|
+
return plan_id ? `${product_id}__plan__${plan_id}` : `${product_id}__one_time`;
|
|
119
|
+
}
|
|
120
|
+
async function list_all_stripe_products(client) {
|
|
121
|
+
const all_products = [];
|
|
122
|
+
let starting_after;
|
|
123
|
+
for (; ; ) {
|
|
124
|
+
const page = await (0, import_utils.stripe_api_call)(() => client.products.list({
|
|
125
|
+
limit: stripe_list_page_size,
|
|
126
|
+
starting_after,
|
|
127
|
+
expand: ["data.default_price"]
|
|
128
|
+
}), { operation: "products.list_all", starting_after });
|
|
129
|
+
all_products.push(...page.data);
|
|
130
|
+
if (!page.has_more || page.data.length === 0) {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
const last = page.data[page.data.length - 1];
|
|
134
|
+
(0, import_utils.assert)(last !== void 0, "api_error", "Stripe products pagination returned an empty last item", {
|
|
135
|
+
returned: page.data.length
|
|
136
|
+
});
|
|
137
|
+
starting_after = last.id;
|
|
138
|
+
}
|
|
139
|
+
return all_products;
|
|
140
|
+
}
|
|
141
|
+
async function list_all_stripe_prices(client) {
|
|
142
|
+
const all_prices = [];
|
|
143
|
+
let starting_after;
|
|
144
|
+
for (; ; ) {
|
|
145
|
+
const page = await (0, import_utils.stripe_api_call)(() => client.prices.list({
|
|
146
|
+
limit: stripe_list_page_size,
|
|
147
|
+
// We list only active prices because inactive ones are not usable for new purchases,
|
|
148
|
+
// and we only need active ones for initialization comparisons.
|
|
149
|
+
active: true,
|
|
150
|
+
starting_after
|
|
151
|
+
}), { operation: "prices.list_all", starting_after });
|
|
152
|
+
all_prices.push(...page.data);
|
|
153
|
+
if (!page.has_more || page.data.length === 0) {
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
const last = page.data[page.data.length - 1];
|
|
157
|
+
(0, import_utils.assert)(last !== void 0, "api_error", "Stripe prices pagination returned an empty last item", {
|
|
158
|
+
returned: page.data.length
|
|
159
|
+
});
|
|
160
|
+
starting_after = last.id;
|
|
161
|
+
}
|
|
162
|
+
return all_prices;
|
|
163
|
+
}
|
|
164
|
+
async function list_all_stripe_meters(client) {
|
|
165
|
+
const all_meters = [];
|
|
166
|
+
let starting_after;
|
|
167
|
+
for (; ; ) {
|
|
168
|
+
const page = await (0, import_utils.stripe_api_call)(() => client.billing.meters.list({
|
|
169
|
+
limit: stripe_list_page_size,
|
|
170
|
+
starting_after
|
|
171
|
+
}), { operation: "billing.meters.list_all", starting_after });
|
|
172
|
+
all_meters.push(...page.data);
|
|
173
|
+
if (!page.has_more || page.data.length === 0) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
const last = page.data[page.data.length - 1];
|
|
177
|
+
(0, import_utils.assert)(last !== void 0, "api_error", "Stripe meters pagination returned an empty last item", {
|
|
178
|
+
returned: page.data.length
|
|
179
|
+
});
|
|
180
|
+
starting_after = last.id;
|
|
181
|
+
}
|
|
182
|
+
return all_meters;
|
|
183
|
+
}
|
|
184
|
+
function index_stripe_products_by_app_id(stripe_products) {
|
|
185
|
+
const map = /* @__PURE__ */ new Map();
|
|
186
|
+
for (const product of stripe_products) {
|
|
187
|
+
const app_id = product.metadata?.[app_product_id_metadata_key];
|
|
188
|
+
if (app_id) {
|
|
189
|
+
(0, import_utils.assert)(!map.has(app_id), "api_error", "Duplicate Stripe product metadata app id", {
|
|
190
|
+
app_id,
|
|
191
|
+
existing_stripe_product_id: map.get(app_id)?.id,
|
|
192
|
+
duplicate_stripe_product_id: product.id
|
|
193
|
+
});
|
|
194
|
+
map.set(app_id, product);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return map;
|
|
198
|
+
}
|
|
199
|
+
function index_active_prices_by_stripe_product_id(stripe_prices) {
|
|
200
|
+
const map = /* @__PURE__ */ new Map();
|
|
201
|
+
for (const price of stripe_prices) {
|
|
202
|
+
if (typeof price.product !== "string") {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const list = map.get(price.product) ?? [];
|
|
206
|
+
list.push(price);
|
|
207
|
+
map.set(price.product, list);
|
|
208
|
+
}
|
|
209
|
+
return map;
|
|
210
|
+
}
|
|
211
|
+
function index_stripe_meters_by_event_name(stripe_meters) {
|
|
212
|
+
const map = /* @__PURE__ */ new Map();
|
|
213
|
+
for (const meter of stripe_meters) {
|
|
214
|
+
const event_name = meter.event_name;
|
|
215
|
+
if (event_name) {
|
|
216
|
+
(0, import_utils.assert)(!map.has(event_name), "api_error", "Duplicate Stripe meter event_name", {
|
|
217
|
+
event_name,
|
|
218
|
+
existing_stripe_meter_id: map.get(event_name)?.id,
|
|
219
|
+
duplicate_stripe_meter_id: meter.id
|
|
220
|
+
});
|
|
221
|
+
map.set(event_name, meter);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return map;
|
|
225
|
+
}
|
|
226
|
+
function find_matching_active_price(active_prices, app_price_id, expected_signature) {
|
|
227
|
+
const match = active_prices.find((p) => {
|
|
228
|
+
const meta_price_id = p.metadata?.[app_price_id_metadata_key];
|
|
229
|
+
const meta_signature = p.metadata?.[app_price_signature_metadata_key];
|
|
230
|
+
return meta_price_id === app_price_id && meta_signature === expected_signature;
|
|
231
|
+
});
|
|
232
|
+
return match ?? null;
|
|
233
|
+
}
|
|
234
|
+
async function create_stripe_product(client, server, product) {
|
|
235
|
+
server.log(0, `Creating Stripe product for product '${product.id}'`);
|
|
236
|
+
return await (0, import_utils.stripe_api_call)(() => client.products.create({
|
|
237
|
+
name: product.name,
|
|
238
|
+
description: product.description,
|
|
239
|
+
tax_code: product.tax_code,
|
|
240
|
+
images: product.images,
|
|
241
|
+
metadata: {
|
|
242
|
+
[app_product_id_metadata_key]: product.id
|
|
243
|
+
},
|
|
244
|
+
expand: ["default_price"]
|
|
245
|
+
}, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`create_product_${product.id}`) }), { operation: "products.create", app_product_id: product.id });
|
|
246
|
+
}
|
|
247
|
+
async function update_stripe_product_if_needed(client, server, stripe_product, product) {
|
|
248
|
+
const stripe_images = stripe_product.images ?? [];
|
|
249
|
+
const app_images = product.images ?? [];
|
|
250
|
+
const images_equal = stripe_images.length === app_images.length && stripe_images.every((url, index) => url === app_images[index]);
|
|
251
|
+
const needs_update = stripe_product.name !== product.name || (stripe_product.description ?? "") !== (product.description ?? "") || (stripe_product.tax_code ?? "") !== (product.tax_code ?? "") || !images_equal;
|
|
252
|
+
if (!needs_update) {
|
|
253
|
+
return stripe_product;
|
|
254
|
+
}
|
|
255
|
+
server.log(0, `Updating Stripe product '${stripe_product.id}' to match app product '${product.id}'`);
|
|
256
|
+
return await (0, import_utils.stripe_api_call)(() => client.products.update(stripe_product.id, {
|
|
257
|
+
name: product.name,
|
|
258
|
+
description: product.description,
|
|
259
|
+
tax_code: product.tax_code,
|
|
260
|
+
images: product.images,
|
|
261
|
+
expand: ["default_price"]
|
|
262
|
+
}, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`update_product_${product.id}_${stripe_product.id}`) }), { operation: "products.update", app_product_id: product.id, stripe_product_id: stripe_product.id });
|
|
263
|
+
}
|
|
264
|
+
async function update_stripe_product_default_price_if_needed(client, server, stripe_product, default_price, other_plans_from_parent_subscription) {
|
|
265
|
+
let default_price_id = null;
|
|
266
|
+
if (typeof stripe_product.default_price === "string") {
|
|
267
|
+
default_price_id = stripe_product.default_price;
|
|
268
|
+
} else if (stripe_product.default_price && typeof stripe_product.default_price === "object") {
|
|
269
|
+
default_price_id = stripe_product.default_price.id;
|
|
270
|
+
}
|
|
271
|
+
if (!default_price_id) {
|
|
272
|
+
const fetched = await (0, import_utils.stripe_api_call)(() => client.products.retrieve(stripe_product.id, {
|
|
273
|
+
expand: ["default_price"]
|
|
274
|
+
}), { operation: "products.retrieve_for_default_price", stripe_product_id: stripe_product.id });
|
|
275
|
+
default_price_id = typeof fetched.default_price === "string" ? fetched.default_price : fetched.default_price?.id ?? null;
|
|
276
|
+
}
|
|
277
|
+
if (default_price_id === default_price.id || other_plans_from_parent_subscription?.some((plan) => plan.stripe_price_id === default_price_id)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
server.log(0, `Updating default price for Stripe product '${stripe_product.id}' to price '${default_price.id}'`);
|
|
281
|
+
await (0, import_utils.stripe_api_call)(() => client.products.update(stripe_product.id, {
|
|
282
|
+
default_price: default_price.id
|
|
283
|
+
}, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`update_product_default_price_${stripe_product.id}_${default_price.id}`) }), { operation: "products.update", app_product_id: stripe_product.metadata?.[app_product_id_metadata_key], stripe_product_id: stripe_product.id, action: "update_default_price" });
|
|
284
|
+
}
|
|
285
|
+
async function create_one_time_price(client, server, opts) {
|
|
286
|
+
server.log(0, `Creating stripe one-time price for product: ${opts.product_id}`);
|
|
287
|
+
return await (0, import_utils.stripe_api_call)(() => client.prices.create({
|
|
288
|
+
product: opts.stripe_product_id,
|
|
289
|
+
currency: opts.currency,
|
|
290
|
+
unit_amount: opts.unit_amount,
|
|
291
|
+
// Docs: https://docs.stripe.com/tax/tax-behavior
|
|
292
|
+
tax_behavior: opts.tax_behavior,
|
|
293
|
+
nickname: opts.nickname,
|
|
294
|
+
metadata: {
|
|
295
|
+
[app_price_id_metadata_key]: opts.app_price_id,
|
|
296
|
+
[app_price_signature_metadata_key]: make_one_time_price_signature({
|
|
297
|
+
currency: opts.currency,
|
|
298
|
+
unit_amount: opts.unit_amount,
|
|
299
|
+
tax_behavior: opts.tax_behavior
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
}, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`create_one_time_price_${opts.app_price_id}_${opts.stripe_product_id}`) }), { operation: "prices.create", app_price_id: opts.app_price_id, stripe_product_id: opts.stripe_product_id });
|
|
303
|
+
}
|
|
304
|
+
async function create_recurring_price(client, server, opts) {
|
|
305
|
+
const recurring = {
|
|
306
|
+
interval: opts.interval,
|
|
307
|
+
interval_count: opts.interval_count,
|
|
308
|
+
// "metered" links the price to a billing meter; "licensed" is standard recurring.
|
|
309
|
+
// Docs: https://docs.stripe.com/api/prices/create (recurring.usage_type)
|
|
310
|
+
usage_type: opts.recurring_usage.usage_type,
|
|
311
|
+
// For metered prices, connect the Stripe price to a meter id.
|
|
312
|
+
// Docs: https://docs.stripe.com/api/prices/create (recurring.meter)
|
|
313
|
+
...opts.recurring_usage.usage_type === "metered" ? { meter: opts.recurring_usage.meter_id } : {}
|
|
314
|
+
};
|
|
315
|
+
const signature = make_recurring_price_signature({
|
|
316
|
+
currency: opts.currency,
|
|
317
|
+
..."unit_amount_decimal" in opts ? { unit_amount_decimal: opts.unit_amount_decimal } : { unit_amount: opts.unit_amount },
|
|
318
|
+
tax_behavior: opts.tax_behavior,
|
|
319
|
+
interval: opts.interval,
|
|
320
|
+
interval_count: opts.interval_count,
|
|
321
|
+
usage_type: opts.recurring_usage.usage_type,
|
|
322
|
+
meter_id: opts.recurring_usage.usage_type === "metered" ? opts.recurring_usage.meter_id : void 0
|
|
323
|
+
});
|
|
324
|
+
server.log(0, `Creating stripe recurring price for product: ${opts.product_id}`);
|
|
325
|
+
return await (0, import_utils.stripe_api_call)(() => client.prices.create({
|
|
326
|
+
product: opts.stripe_product_id,
|
|
327
|
+
currency: opts.currency,
|
|
328
|
+
..."unit_amount_decimal" in opts ? { unit_amount_decimal: opts.unit_amount_decimal } : { unit_amount: opts.unit_amount },
|
|
329
|
+
tax_behavior: opts.tax_behavior,
|
|
330
|
+
nickname: opts.nickname,
|
|
331
|
+
// Docs: https://docs.stripe.com/billing/prices-guide#create-prices
|
|
332
|
+
recurring,
|
|
333
|
+
metadata: {
|
|
334
|
+
[app_price_id_metadata_key]: opts.app_price_id,
|
|
335
|
+
[app_price_signature_metadata_key]: signature
|
|
336
|
+
}
|
|
337
|
+
}, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`create_recurring_price_${opts.app_price_id}_${opts.stripe_product_id}`) }), { operation: "prices.create", app_price_id: opts.app_price_id, stripe_product_id: opts.stripe_product_id });
|
|
338
|
+
}
|
|
339
|
+
async function create_stripe_meter(client, server, product) {
|
|
340
|
+
const aggregation_formula = product.aggregation_formula ?? "sum";
|
|
341
|
+
const customer_mapping_event_payload_key = product.customer_mapping_event_payload_key ?? "stripe_customer_id";
|
|
342
|
+
const value_settings_event_payload_key = product.value_settings_event_payload_key ?? "value";
|
|
343
|
+
server.log(0, `Creating stripe billing meter for product: ${product.id}`);
|
|
344
|
+
return await (0, import_utils.stripe_api_call)(() => client.billing.meters.create({
|
|
345
|
+
display_name: product.name,
|
|
346
|
+
event_name: product.meter_event_name,
|
|
347
|
+
default_aggregation: {
|
|
348
|
+
formula: aggregation_formula
|
|
349
|
+
},
|
|
350
|
+
// Stripe currently requires by_id mapping and a payload key that contains the customer id.
|
|
351
|
+
// Docs: https://docs.stripe.com/api/billing/meter/create#billing_meter_create-customer_mapping
|
|
352
|
+
customer_mapping: {
|
|
353
|
+
type: "by_id",
|
|
354
|
+
event_payload_key: customer_mapping_event_payload_key
|
|
355
|
+
},
|
|
356
|
+
// Value key used as the numeric value for "sum"/"last" aggregation.
|
|
357
|
+
// Docs: https://docs.stripe.com/api/billing/meter/create#billing_meter_create-value_settings
|
|
358
|
+
value_settings: {
|
|
359
|
+
event_payload_key: value_settings_event_payload_key
|
|
360
|
+
},
|
|
361
|
+
...product.event_time_window ? { event_time_window: product.event_time_window } : {}
|
|
362
|
+
}, { idempotencyKey: (0, import_utils.generate_random_idempotency_key)(`create_billing_meter_${product.id}_${product.meter_event_name}`) }), {
|
|
363
|
+
operation: "billing.meters.create",
|
|
364
|
+
app_meter_product_id: product.id,
|
|
365
|
+
event_name: product.meter_event_name,
|
|
366
|
+
aggregation_formula,
|
|
367
|
+
customer_mapping_event_payload_key,
|
|
368
|
+
value_settings_event_payload_key,
|
|
369
|
+
event_time_window: product.event_time_window ?? null
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
async function map_with_concurrency(items, concurrency, mapper) {
|
|
373
|
+
(0, import_utils.assert)(Number.isInteger(concurrency) && concurrency >= 1, "invalid_argument", "Concurrency must be an integer >= 1", { concurrency });
|
|
374
|
+
const results = new Array(items.length);
|
|
375
|
+
let next_index = 0;
|
|
376
|
+
let first_error = null;
|
|
377
|
+
const worker = async () => {
|
|
378
|
+
for (; ; ) {
|
|
379
|
+
if (first_error)
|
|
380
|
+
return;
|
|
381
|
+
const current_index = next_index;
|
|
382
|
+
next_index += 1;
|
|
383
|
+
if (current_index >= items.length) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const current_item = items[current_index];
|
|
387
|
+
(0, import_utils.assert)(current_item !== void 0, "invalid_argument", "Missing item for concurrency worker index", { current_index, items_length: items.length });
|
|
388
|
+
try {
|
|
389
|
+
results[current_index] = await mapper(current_item, current_index);
|
|
390
|
+
} catch (e) {
|
|
391
|
+
if (!first_error)
|
|
392
|
+
first_error = e;
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const worker_count = Math.min(concurrency, items.length);
|
|
398
|
+
await Promise.allSettled(Array.from({ length: worker_count }, () => worker()));
|
|
399
|
+
if (first_error)
|
|
400
|
+
throw first_error;
|
|
401
|
+
return results;
|
|
402
|
+
}
|
|
403
|
+
async function initialize_product(client, server, product, stripe_products_by_app_id, active_prices_by_stripe_product_id, stripe_meters_by_event_name) {
|
|
404
|
+
(0, import_utils.assert)(product.id.trim().length > 0, "invalid_product", "Product.id must be non-empty", { product_id: product.id });
|
|
405
|
+
(0, import_utils.assert)(product.name.trim().length > 0, "invalid_product", "Product.name must be non-empty", { product_id: product.id });
|
|
406
|
+
(0, import_utils.assert)(product.currency.trim().length > 0, "invalid_product", "Product.currency must be non-empty", { product_id: product.id });
|
|
407
|
+
(0, import_utils.assert)(product.tax_code.trim().length > 0, "invalid_product", "Product.tax_code must be non-empty", { product_id: product.id });
|
|
408
|
+
(0, import_utils.assert)(product.tax_behavior === "inclusive" || product.tax_behavior === "exclusive" || product.tax_behavior === "unspecified", "invalid_product", "Product.tax_behavior is invalid", { product_id: product.id, tax_behavior: product.tax_behavior });
|
|
409
|
+
validate_images(product.images);
|
|
410
|
+
product.currency = product.currency.trim().toLowerCase();
|
|
411
|
+
(0, import_utils.assert)(/^[a-z]{3}$/.test(product.currency), "invalid_product", `Invalid currency code: "${product.currency}"`, { currency: product.currency });
|
|
412
|
+
if (product.type === "one_time") {
|
|
413
|
+
validate_unit_amount(product.price, "Product.price");
|
|
414
|
+
validate_quantity_rules(product.quantity_rules);
|
|
415
|
+
} else if (product.type === "subscription") {
|
|
416
|
+
(0, import_utils.assert)(Array.isArray(product.plans) && product.plans.length > 0, "invalid_product", "Subscription product must have plans", { product_id: product.id });
|
|
417
|
+
if (product.trial_days !== void 0) {
|
|
418
|
+
(0, import_utils.assert)(Number.isInteger(product.trial_days) && product.trial_days >= 1, "invalid_product", "Subscription.trial_days must be an integer >= 1", { product_id: product.id, trial_days: product.trial_days });
|
|
419
|
+
}
|
|
420
|
+
if (product.billing_anchor !== void 0) {
|
|
421
|
+
const anchor = product.billing_anchor;
|
|
422
|
+
(0, import_utils.assert)(anchor === "immediately" || anchor === "first_of_month", "invalid_product", "Subscription.billing_anchor is invalid", { product_id: product.id, billing_anchor: anchor });
|
|
423
|
+
} else {
|
|
424
|
+
product.billing_anchor = "immediately";
|
|
425
|
+
}
|
|
426
|
+
for (const plan of product.plans) {
|
|
427
|
+
(0, import_utils.assert)(plan.id.trim().length > 0, "invalid_product", "Plan.id must be non-empty", { product_id: product.id });
|
|
428
|
+
(0, import_utils.assert)(plan.name.trim().length > 0, "invalid_product", "Plan.name must be non-empty", { product_id: product.id, plan_id: plan.id });
|
|
429
|
+
validate_unit_amount(plan.price, "Plan.price");
|
|
430
|
+
(0, import_utils.assert)(Number.isInteger(plan.interval_count) && plan.interval_count >= 1, "invalid_product", "Plan.interval_count must be >= 1", { product_id: product.id, plan_id: plan.id, interval_count: plan.interval_count });
|
|
431
|
+
(0, import_utils.assert)(plan.interval === "day" || plan.interval === "week" || plan.interval === "month" || plan.interval === "year", "invalid_product", "Plan.interval is invalid", { product_id: product.id, plan_id: plan.id, interval: plan.interval });
|
|
432
|
+
}
|
|
433
|
+
} else if (product.type === "meter") {
|
|
434
|
+
(0, import_utils.assert)(product.interval === "day" || product.interval === "week" || product.interval === "month" || product.interval === "year", "invalid_product", "Property 'interval' is invalid", { product_id: product.id, interval: product.interval });
|
|
435
|
+
if (product.kind === "units") {
|
|
436
|
+
(0, import_utils.assert)(product.price !== void 0, "invalid_product", "MeterProduct with kind='units' must define 'price'.", { product_id: product.id });
|
|
437
|
+
resolve_unit_price_fields(product);
|
|
438
|
+
} else if (product.kind === "money") {
|
|
439
|
+
(0, import_utils.assert)(product.price === void 0, "invalid_product", "MeterProduct with kind='money' must not define 'price'.", { product_id: product.id });
|
|
440
|
+
} else {
|
|
441
|
+
product.kind.toString();
|
|
442
|
+
throw new import_error.InternalStripeError("invalid_product", `Invalid 'kind': ${product.kind}`, { product_id: product.id, kind: product.kind });
|
|
443
|
+
}
|
|
444
|
+
(0, import_utils.assert)(Number.isInteger(product.interval_count) && product.interval_count >= 1, "invalid_product", "Property 'interval_count' must be >= 1", { product_id: product.id, interval_count: product.interval_count });
|
|
445
|
+
(0, import_utils.assert)(product.meter_event_name.trim().length > 0, "invalid_product", "Property 'meter_event_name' must be non-empty", {
|
|
446
|
+
product_id: product.id,
|
|
447
|
+
meter_event_name: product.meter_event_name
|
|
448
|
+
});
|
|
449
|
+
(0, import_utils.assert)(product.meter_event_name.length <= 100, "invalid_product", "Property 'meter_event_name' must be <= 100 characters", { product_id: product.id, meter_event_name_length: product.meter_event_name.length });
|
|
450
|
+
if (product.aggregation_formula !== void 0) {
|
|
451
|
+
const formula = product.aggregation_formula;
|
|
452
|
+
(0, import_utils.assert)(formula === "count" || formula === "sum" || formula === "last", "invalid_product", "Property 'aggregation_formula' is invalid", { product_id: product.id, aggregation_formula: formula });
|
|
453
|
+
}
|
|
454
|
+
if (product.customer_mapping_event_payload_key !== void 0) {
|
|
455
|
+
(0, import_utils.assert)(product.customer_mapping_event_payload_key.trim().length > 0, "invalid_product", "Property 'customer_mapping_event_payload_key' must be non-empty", { product_id: product.id, customer_mapping_event_payload_key: product.customer_mapping_event_payload_key });
|
|
456
|
+
}
|
|
457
|
+
if (product.value_settings_event_payload_key !== void 0) {
|
|
458
|
+
(0, import_utils.assert)(product.value_settings_event_payload_key.trim().length > 0, "invalid_product", "Property 'value_settings_event_payload_key' must be non-empty", { product_id: product.id, value_settings_event_payload_key: product.value_settings_event_payload_key });
|
|
459
|
+
}
|
|
460
|
+
if (product.event_time_window !== void 0) {
|
|
461
|
+
const window = product.event_time_window;
|
|
462
|
+
(0, import_utils.assert)(window === "hour" || window === "day", "invalid_product", "Property 'event_time_window' is invalid", { product_id: product.id, event_time_window: window });
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
product.type.toString();
|
|
466
|
+
throw new import_error.InternalStripeError("invalid_product", `Invalid product type: ${product.type}`, {
|
|
467
|
+
product_id: product.id,
|
|
468
|
+
product_type: product.type
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
let stripe_meter = null;
|
|
472
|
+
if (product.type === "meter") {
|
|
473
|
+
stripe_meter = stripe_meters_by_event_name.get(product.meter_event_name) ?? null;
|
|
474
|
+
if (!stripe_meter) {
|
|
475
|
+
stripe_meter = await create_stripe_meter(client, server, product);
|
|
476
|
+
stripe_meters_by_event_name.set(product.meter_event_name, stripe_meter);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
let stripe_product = stripe_products_by_app_id.get(product.id) ?? null;
|
|
480
|
+
if (!stripe_product) {
|
|
481
|
+
stripe_product = await create_stripe_product(client, server, product);
|
|
482
|
+
stripe_products_by_app_id.set(product.id, stripe_product);
|
|
483
|
+
} else {
|
|
484
|
+
stripe_product = await update_stripe_product_if_needed(client, server, stripe_product, product);
|
|
485
|
+
stripe_products_by_app_id.set(product.id, stripe_product);
|
|
486
|
+
}
|
|
487
|
+
const active_prices = active_prices_by_stripe_product_id.get(stripe_product.id) ?? [];
|
|
488
|
+
if (product.type === "one_time") {
|
|
489
|
+
const app_price_id = make_price_app_id(product.id, void 0);
|
|
490
|
+
const signature = make_one_time_price_signature({
|
|
491
|
+
currency: product.currency,
|
|
492
|
+
unit_amount: product.price,
|
|
493
|
+
tax_behavior: product.tax_behavior
|
|
494
|
+
});
|
|
495
|
+
let stripe_price = find_matching_active_price(active_prices, app_price_id, signature);
|
|
496
|
+
if (!stripe_price) {
|
|
497
|
+
stripe_price = await create_one_time_price(client, server, {
|
|
498
|
+
product_id: product.id,
|
|
499
|
+
stripe_product_id: stripe_product.id,
|
|
500
|
+
app_price_id,
|
|
501
|
+
currency: product.currency,
|
|
502
|
+
unit_amount: product.price,
|
|
503
|
+
tax_behavior: product.tax_behavior,
|
|
504
|
+
nickname: product.name
|
|
505
|
+
});
|
|
506
|
+
const updated_prices = [...active_prices, stripe_price];
|
|
507
|
+
active_prices_by_stripe_product_id.set(stripe_product.id, updated_prices);
|
|
508
|
+
}
|
|
509
|
+
await update_stripe_product_default_price_if_needed(client, server, stripe_product, stripe_price);
|
|
510
|
+
return {
|
|
511
|
+
...product,
|
|
512
|
+
stripe_product_id: stripe_product.id,
|
|
513
|
+
stripe_price_id: stripe_price.id
|
|
514
|
+
};
|
|
515
|
+
} else if (product.type === "subscription") {
|
|
516
|
+
const initialized_plans = [];
|
|
517
|
+
for (const plan of product.plans) {
|
|
518
|
+
const app_price_id = make_price_app_id(product.id, plan.id);
|
|
519
|
+
const signature = make_recurring_price_signature({
|
|
520
|
+
currency: product.currency,
|
|
521
|
+
unit_amount: plan.price,
|
|
522
|
+
tax_behavior: product.tax_behavior,
|
|
523
|
+
interval: plan.interval,
|
|
524
|
+
interval_count: plan.interval_count,
|
|
525
|
+
usage_type: "licensed"
|
|
526
|
+
});
|
|
527
|
+
let stripe_price = find_matching_active_price(active_prices, app_price_id, signature);
|
|
528
|
+
if (!stripe_price) {
|
|
529
|
+
stripe_price = await create_recurring_price(client, server, {
|
|
530
|
+
product_id: product.id,
|
|
531
|
+
stripe_product_id: stripe_product.id,
|
|
532
|
+
app_price_id,
|
|
533
|
+
currency: product.currency,
|
|
534
|
+
unit_amount: plan.price,
|
|
535
|
+
tax_behavior: product.tax_behavior,
|
|
536
|
+
nickname: `${product.name} - ${plan.name}`,
|
|
537
|
+
interval: plan.interval,
|
|
538
|
+
interval_count: plan.interval_count,
|
|
539
|
+
recurring_usage: { usage_type: "licensed" }
|
|
540
|
+
});
|
|
541
|
+
const updated_prices = [...active_prices, stripe_price];
|
|
542
|
+
active_prices_by_stripe_product_id.set(stripe_product.id, updated_prices);
|
|
543
|
+
}
|
|
544
|
+
await update_stripe_product_default_price_if_needed(client, server, stripe_product, stripe_price, initialized_plans);
|
|
545
|
+
initialized_plans.push({
|
|
546
|
+
...plan,
|
|
547
|
+
type: "subscription_plan",
|
|
548
|
+
subscription_id: product.id,
|
|
549
|
+
stripe_price_id: stripe_price.id
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
...product,
|
|
554
|
+
stripe_product_id: stripe_product.id,
|
|
555
|
+
plans: initialized_plans
|
|
556
|
+
};
|
|
557
|
+
} else if (product.type === "meter") {
|
|
558
|
+
(0, import_utils.assert)(stripe_meter !== null, "api_error", "Stripe meter must be resolved for meter product initialization", {
|
|
559
|
+
product_id: product.id,
|
|
560
|
+
meter_event_name: product.meter_event_name
|
|
561
|
+
});
|
|
562
|
+
const app_price_id = `${product.id}__meter`;
|
|
563
|
+
const unit_price_fields = resolve_unit_price_fields(product);
|
|
564
|
+
const signature = make_recurring_price_signature({
|
|
565
|
+
currency: product.currency,
|
|
566
|
+
...unit_price_fields,
|
|
567
|
+
tax_behavior: product.tax_behavior,
|
|
568
|
+
interval: product.interval,
|
|
569
|
+
interval_count: product.interval_count,
|
|
570
|
+
usage_type: "metered",
|
|
571
|
+
meter_id: stripe_meter.id
|
|
572
|
+
});
|
|
573
|
+
let stripe_price = find_matching_active_price(active_prices, app_price_id, signature);
|
|
574
|
+
if (!stripe_price) {
|
|
575
|
+
const new_price = await create_recurring_price(client, server, {
|
|
576
|
+
product_id: product.id,
|
|
577
|
+
stripe_product_id: stripe_product.id,
|
|
578
|
+
app_price_id,
|
|
579
|
+
currency: product.currency,
|
|
580
|
+
...unit_price_fields,
|
|
581
|
+
tax_behavior: product.tax_behavior,
|
|
582
|
+
nickname: product.name,
|
|
583
|
+
interval: product.interval,
|
|
584
|
+
interval_count: product.interval_count,
|
|
585
|
+
recurring_usage: { usage_type: "metered", meter_id: stripe_meter.id }
|
|
586
|
+
});
|
|
587
|
+
stripe_price = new_price;
|
|
588
|
+
active_prices_by_stripe_product_id.set(stripe_product.id, [...active_prices, new_price]);
|
|
589
|
+
}
|
|
590
|
+
await update_stripe_product_default_price_if_needed(client, server, stripe_product, stripe_price);
|
|
591
|
+
return {
|
|
592
|
+
...product,
|
|
593
|
+
stripe_meter_id: stripe_meter.id,
|
|
594
|
+
stripe_product_id: stripe_product.id,
|
|
595
|
+
stripe_price_id: stripe_price.id
|
|
596
|
+
};
|
|
597
|
+
} else {
|
|
598
|
+
product.type.toString();
|
|
599
|
+
throw new import_error.InternalStripeError("invalid_product", `Invalid product type: ${product.type}`, {
|
|
600
|
+
product_id: product.id,
|
|
601
|
+
product_type: product.type
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function resolve_plan_to_parent_subscription(opts) {
|
|
606
|
+
for (const product of opts.all_products) {
|
|
607
|
+
if (product.type === "subscription" && product.id === opts.plan.subscription_id) {
|
|
608
|
+
return product;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
throw new import_error.InternalStripeError("invalid_product", "Subscription plan refers to a missing parent subscription product.", { plan_id: opts.plan.id, subscription_id: opts.plan.subscription_id });
|
|
612
|
+
}
|
|
613
|
+
async function initialize_products(client, server, products) {
|
|
614
|
+
(0, import_utils.assert)(Array.isArray(products), "invalid_argument", "Products must be an array");
|
|
615
|
+
const seen_ids = /* @__PURE__ */ new Set();
|
|
616
|
+
const seen_meter_event_names = /* @__PURE__ */ new Set();
|
|
617
|
+
for (const product of products) {
|
|
618
|
+
(0, import_utils.assert)(!seen_ids.has(product.id), "invalid_product", `Duplicate product id: ${product.id}`, { product_id: product.id });
|
|
619
|
+
seen_ids.add(product.id);
|
|
620
|
+
if (product.type === "subscription") {
|
|
621
|
+
for (const plan of product.plans) {
|
|
622
|
+
(0, import_utils.assert)(!seen_ids.has(plan.id), "invalid_product", `Duplicate plan id: ${plan.id} in product ${product.id}`, { product_id: product.id, plan_id: plan.id });
|
|
623
|
+
seen_ids.add(plan.id);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (product.type === "meter") {
|
|
627
|
+
(0, import_utils.assert)(!seen_meter_event_names.has(product.meter_event_name), "invalid_product", `Duplicate meter_event_name: ${product.meter_event_name}`, { product_id: product.id, meter_event_name: product.meter_event_name });
|
|
628
|
+
seen_meter_event_names.add(product.meter_event_name);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const [all_stripe_products, all_active_stripe_prices, all_stripe_meters] = await Promise.all([
|
|
632
|
+
list_all_stripe_products(client),
|
|
633
|
+
list_all_stripe_prices(client),
|
|
634
|
+
list_all_stripe_meters(client)
|
|
635
|
+
]);
|
|
636
|
+
const stripe_products_by_app_id = index_stripe_products_by_app_id(all_stripe_products);
|
|
637
|
+
const active_prices_by_stripe_product_id = index_active_prices_by_stripe_product_id(all_active_stripe_prices);
|
|
638
|
+
const stripe_meters_by_event_name = index_stripe_meters_by_event_name(all_stripe_meters);
|
|
639
|
+
const concurrency = 5;
|
|
640
|
+
const initialized_products = await map_with_concurrency(products, concurrency, async (product) => {
|
|
641
|
+
return await initialize_product(client, server, product, stripe_products_by_app_id, active_prices_by_stripe_product_id, stripe_meters_by_event_name);
|
|
642
|
+
});
|
|
643
|
+
return initialized_products;
|
|
644
|
+
}
|
|
645
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
646
|
+
0 && (module.exports = {
|
|
647
|
+
MeterProduct,
|
|
648
|
+
initialize_products,
|
|
649
|
+
resolve_plan_to_parent_subscription
|
|
650
|
+
});
|