@burdenoff/be-sdk 2026.1110.2 → 2026.1110.3
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/configs/eslint/index.js +1 -1
- package/configs/tsconfig/tsconfig.json +1 -1
- package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
- package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
- package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
- package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
- package/dist/ai-credits/index.d.ts +2 -3
- package/dist/ai-credits/index.js +3 -4
- package/dist/ai-credits/index.js.map +1 -1
- package/dist/ai-credits-Ca-NNcVx.js +546 -0
- package/dist/ai-credits-Ca-NNcVx.js.map +1 -0
- package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
- package/dist/auth/index.d.ts +2 -77
- package/dist/auth/index.js +3 -7
- package/dist/auth/index.js.map +1 -1
- package/dist/auth-CEuBEBQN.js +228 -0
- package/dist/auth-CEuBEBQN.js.map +1 -0
- package/dist/cache/index.d.ts +2 -3
- package/dist/cache/index.js +3 -7
- package/dist/cache/index.js.map +1 -1
- package/dist/cache-CU0uLwcS.js +1837 -0
- package/dist/cache-CU0uLwcS.js.map +1 -0
- package/dist/captcha/index.d.ts +2 -1
- package/dist/captcha/index.js +3 -3
- package/dist/captcha/index.js.map +1 -1
- package/dist/captcha-BT7yh1YS.js +77 -0
- package/dist/captcha-BT7yh1YS.js.map +1 -0
- package/dist/client/internal-client.d.ts +4 -7
- package/dist/client/internal-client.js +172 -4
- package/dist/client/internal-client.js.map +1 -1
- package/dist/client-BgAEvDC2.d.ts +86 -0
- package/dist/client-DcZ3iGES.js +565 -0
- package/dist/client-DcZ3iGES.js.map +1 -0
- package/dist/collector-endpoint-iyQYeI50.js +50 -0
- package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
- package/dist/context-CZnXf2yb.js +247 -0
- package/dist/context-CZnXf2yb.js.map +1 -0
- package/dist/crypto/index.d.ts +2 -1
- package/dist/crypto/index.js +3 -3
- package/dist/crypto/index.js.map +1 -1
- package/dist/crypto-DO9fM0FO.js +145 -0
- package/dist/crypto-DO9fM0FO.js.map +1 -0
- package/dist/database/index.d.ts +104 -108
- package/dist/database/index.js +468 -6
- package/dist/database/index.js.map +1 -1
- package/dist/dataloader/index.d.ts +2 -1
- package/dist/dataloader/index.js +3 -3
- package/dist/dataloader/index.js.map +1 -1
- package/dist/dataloader-DwpT3YoS.js +294 -0
- package/dist/dataloader-DwpT3YoS.js.map +1 -0
- package/dist/deployed-environment-p_Tdl3sT.js +38 -0
- package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
- package/dist/dist-BGKdXVy3.js +1718 -0
- package/dist/dist-BGKdXVy3.js.map +1 -0
- package/dist/env-DdaoGjIt.js +74 -0
- package/dist/env-DdaoGjIt.js.map +1 -0
- package/dist/event-queue/index.d.ts +2 -7
- package/dist/event-queue/index.js +7 -9
- package/dist/event-queue/index.js.map +1 -1
- package/dist/event-queue-Cw-YJPY_.js +1384 -0
- package/dist/event-queue-Cw-YJPY_.js.map +1 -0
- package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
- package/dist/export/index.d.ts +2 -2
- package/dist/export/index.js +3 -14
- package/dist/export/index.js.map +1 -1
- package/dist/export-B6fphx8a.js +642 -0
- package/dist/export-B6fphx8a.js.map +1 -0
- package/dist/feature-flags/index.d.ts +2 -10
- package/dist/feature-flags/index.js +3 -6
- package/dist/feature-flags/index.js.map +1 -1
- package/dist/feature-flags-71oDkrUe.js +422 -0
- package/dist/feature-flags-71oDkrUe.js.map +1 -0
- package/dist/files/index.d.ts +2 -3
- package/dist/files/index.js +3 -4
- package/dist/files/index.js.map +1 -1
- package/dist/files-DjH0099H.js +830 -0
- package/dist/files-DjH0099H.js.map +1 -0
- package/dist/gateway/index.d.ts +4 -6
- package/dist/gateway/index.js +7 -13
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/security/index.d.ts +2 -2
- package/dist/gateway/security/index.js +3 -5
- package/dist/gateway/security/index.js.map +1 -1
- package/dist/gateway-DBFmxWks.js +50 -0
- package/dist/gateway-DBFmxWks.js.map +1 -0
- package/dist/graph/index.d.ts +3 -10
- package/dist/graph/index.js +4 -13
- package/dist/graph/index.js.map +1 -1
- package/dist/graph-DDYgIryR.js +2152 -0
- package/dist/graph-DDYgIryR.js.map +1 -0
- package/dist/graph-emitter-CdOXP7Tn.js +621 -0
- package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
- package/dist/graphql/index.d.ts +3 -2
- package/dist/graphql/index.js +4 -6
- package/dist/graphql/index.js.map +1 -1
- package/dist/graphql/services/index.d.ts +2 -24
- package/dist/graphql/services/index.js +3 -4
- package/dist/graphql/services/index.js.map +1 -1
- package/dist/graphql-DHAHHcww.js +161 -0
- package/dist/graphql-DHAHHcww.js.map +1 -0
- package/dist/graphql-DNkMkGBZ.d.ts +21 -0
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/index.js +3 -4
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n-BBMYFd0P.js +860 -0
- package/dist/i18n-BBMYFd0P.js.map +1 -0
- package/dist/import-optional-peer-B82VYxeX.js +18 -0
- package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
- package/dist/index-3KOZ1zN9.d.ts +233 -0
- package/dist/index-BBqooJ52.d.ts +45 -0
- package/dist/index-BGzMYJsm.d.ts +209 -0
- package/dist/index-BKwHQtHQ.d.ts +63 -0
- package/dist/index-BMIMnp6T.d.ts +8 -0
- package/dist/index-BQDsNAMR.d.ts +81 -0
- package/dist/index-BVOL7458.d.ts +10 -0
- package/dist/index-BcqQs-Uq.d.ts +69 -0
- package/dist/index-BeVtqGO-.d.ts +208 -0
- package/dist/index-BiTzGUZP.d.ts +114 -0
- package/dist/index-BqYfCQSP.d.ts +500 -0
- package/dist/index-C0qLquY0.d.ts +150 -0
- package/dist/index-C5uEKchX.d.ts +60 -0
- package/dist/index-CDOqxSIi.d.ts +37 -0
- package/dist/index-CG6wj66Y.d.ts +148 -0
- package/dist/index-CIgoeobA.d.ts +145 -0
- package/dist/index-CPQDMSFS.d.ts +103 -0
- package/dist/index-CSRcgkVi.d.ts +23 -0
- package/dist/index-CZTnQIRU.d.ts +341 -0
- package/dist/index-CaM9JUcc.d.ts +144 -0
- package/dist/index-CkT2aUr3.d.ts +704 -0
- package/dist/index-CliOgq6L.d.ts +203 -0
- package/dist/index-CnzbJZP7.d.ts +999 -0
- package/dist/index-D6UeLAye.d.ts +63 -0
- package/dist/index-DGgh9DWn.d.ts +59 -0
- package/dist/index-DY3dNhMN.d.ts +420 -0
- package/dist/index-DZC-2o9R.d.ts +207 -0
- package/dist/index-DqbGqfAy.d.ts +127 -0
- package/dist/index-Dt1HJPTX.d.ts +12 -0
- package/dist/index-DtI6aBtB.d.ts +22 -0
- package/dist/index-FKohsiex.d.ts +38 -0
- package/dist/index-FbXPfen7.d.ts +132 -0
- package/dist/index-MArCb8Aq.d.ts +306 -0
- package/dist/index-N-huORcj.d.ts +303 -0
- package/dist/index-YOShAwkq.d.ts +45 -0
- package/dist/index-bZKZUvBu.d.ts +646 -0
- package/dist/index-yBSjMY32.d.ts +24 -0
- package/dist/index.d.ts +501 -544
- package/dist/index.js +1820 -2171
- package/dist/index.js.map +1 -1
- package/dist/init/index.d.ts +2 -2
- package/dist/init/index.js +3 -16
- package/dist/init/index.js.map +1 -1
- package/dist/init-Dy3KhT6Y.js +325 -0
- package/dist/init-Dy3KhT6Y.js.map +1 -0
- package/dist/instrumentation/index.d.ts +3 -4
- package/dist/instrumentation/index.js +5 -5
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/instrumentation-xkkmDgJ0.js +1678 -0
- package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
- package/dist/lake/index.d.ts +50 -54
- package/dist/lake/index.js +169 -193
- package/dist/lake/index.js.map +1 -1
- package/dist/layer/index.d.ts +3 -2
- package/dist/layer/index.js +4 -5
- package/dist/layer/index.js.map +1 -1
- package/dist/layer-BZBZZWeV.d.ts +69 -0
- package/dist/layer-Bcix-WCl.js +105 -0
- package/dist/layer-Bcix-WCl.js.map +1 -0
- package/dist/layer-CEKy6cm8.js +252 -0
- package/dist/layer-CEKy6cm8.js.map +1 -0
- package/dist/lifecycle/index.d.ts +2 -1
- package/dist/lifecycle/index.js +3 -4
- package/dist/lifecycle/index.js.map +1 -1
- package/dist/lifecycle-DeoLSX0U.js +76 -0
- package/dist/lifecycle-DeoLSX0U.js.map +1 -0
- package/dist/logger/index.d.ts +2 -3
- package/dist/logger/index.js +3 -3
- package/dist/logger/index.js.map +1 -1
- package/dist/logger-B6rCpb7D.js +290 -0
- package/dist/logger-B6rCpb7D.js.map +1 -0
- package/dist/metrics/index.d.ts +13 -14
- package/dist/metrics/index.js +3 -4
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics-BrLwNUrb.js +52 -0
- package/dist/metrics-BrLwNUrb.js.map +1 -0
- package/dist/metrics-collector-C2eShrlW.js +922 -0
- package/dist/metrics-collector-C2eShrlW.js.map +1 -0
- package/dist/middleware/index.d.ts +3 -3
- package/dist/middleware/index.js +3 -4
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware-CUxJVUpD.js +1243 -0
- package/dist/middleware-CUxJVUpD.js.map +1 -0
- package/dist/middleware-Cq0zFMGp.js +253 -0
- package/dist/middleware-Cq0zFMGp.js.map +1 -0
- package/dist/notifications/index.d.ts +2 -5
- package/dist/notifications/index.js +3 -6
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications-CdETrtFK.js +869 -0
- package/dist/notifications-CdETrtFK.js.map +1 -0
- package/dist/observability/index.d.ts +2 -3
- package/dist/observability/index.js +3 -4
- package/dist/observability/index.js.map +1 -1
- package/dist/observability-DBDXipTU.js +272 -0
- package/dist/observability-DBDXipTU.js.map +1 -0
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +3 -5
- package/dist/platform/index.js.map +1 -1
- package/dist/platform-DZwczW7v.js +1510 -0
- package/dist/platform-DZwczW7v.js.map +1 -0
- package/dist/prisma/generator/index.d.ts +1 -1
- package/dist/prisma/generator/index.js +97 -84
- package/dist/prisma/generator/index.js.map +1 -1
- package/dist/prisma/index.d.ts +4 -7
- package/dist/prisma/index.js +5 -12
- package/dist/prisma/index.js.map +1 -1
- package/dist/prisma-BzOOdt79.js +863 -0
- package/dist/prisma-BzOOdt79.js.map +1 -0
- package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
- package/dist/product-alias/index.d.ts +2 -1
- package/dist/product-alias/index.js +3 -3
- package/dist/product-alias/index.js.map +1 -1
- package/dist/product-alias-BPqtskMq.js +273 -0
- package/dist/product-alias-BPqtskMq.js.map +1 -0
- package/dist/rbac/index.d.ts +2 -122
- package/dist/rbac/index.js +3 -6
- package/dist/rbac/index.js.map +1 -1
- package/dist/rbac-BB9l9Xph.js +1486 -0
- package/dist/rbac-BB9l9Xph.js.map +1 -0
- package/dist/resource-caps/index.d.ts +66 -72
- package/dist/resource-caps/index.js +430 -5
- package/dist/resource-caps/index.js.map +1 -1
- package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
- package/dist/sdk-Dju9o-sq.js +124 -0
- package/dist/sdk-Dju9o-sq.js.map +1 -0
- package/dist/security-DIG-95Ic.js +1647 -0
- package/dist/security-DIG-95Ic.js.map +1 -0
- package/dist/server/index.d.ts +7 -164
- package/dist/server/index.js +2000 -1507
- package/dist/server/index.js.map +1 -1
- package/dist/service-jwt-Bu-WNA_-.js +80 -0
- package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
- package/dist/services-BWzfz7vG.js +102 -0
- package/dist/services-BWzfz7vG.js.map +1 -0
- package/dist/sharding/index.d.ts +41 -44
- package/dist/sharding/index.js +156 -137
- package/dist/sharding/index.js.map +1 -1
- package/dist/sharing/index.d.ts +2 -1
- package/dist/sharing/index.js +3 -4
- package/dist/sharing/index.js.map +1 -1
- package/dist/sharing-CflDsSJ-.js +911 -0
- package/dist/sharing-CflDsSJ-.js.map +1 -0
- package/dist/stub-BqwKn4eh.js +630 -0
- package/dist/stub-BqwKn4eh.js.map +1 -0
- package/dist/tags/index.d.ts +2 -3
- package/dist/tags/index.js +3 -4
- package/dist/tags/index.js.map +1 -1
- package/dist/tags-B5xpbgsk.js +868 -0
- package/dist/{chunk-PBZFAAOM.js.map → tags-B5xpbgsk.js.map} +1 -1
- package/dist/telemetry/index.d.ts +64 -76
- package/dist/telemetry/index.js +369 -201
- package/dist/telemetry/index.js.map +1 -1
- package/dist/temporal/index.d.ts +2 -148
- package/dist/temporal/index.js +3 -5
- package/dist/temporal/index.js.map +1 -1
- package/dist/temporal-B534uYK8.js +706 -0
- package/dist/temporal-B534uYK8.js.map +1 -0
- package/dist/tracker/index.d.ts +5 -11
- package/dist/tracker/index.js +5 -20
- package/dist/tracker/index.js.map +1 -1
- package/dist/tracker-BQVoEFUo.js +839 -0
- package/dist/tracker-BQVoEFUo.js.map +1 -0
- package/dist/types-BYMYND1L.js +44 -0
- package/dist/types-BYMYND1L.js.map +1 -0
- package/dist/types-C6EKaS3V.d.ts +106 -0
- package/dist/types-CWybW61E.d.ts +323 -0
- package/dist/types-C_yfu3XK.d.ts +34 -0
- package/dist/types-Cj2RWXbz.js +90 -0
- package/dist/types-Cj2RWXbz.js.map +1 -0
- package/dist/types-DgaQqvxo.d.ts +70 -0
- package/dist/usage/index.d.ts +2 -213
- package/dist/usage/index.js +3 -15
- package/dist/usage/index.js.map +1 -1
- package/dist/usage-BKFZiWQn.js +682 -0
- package/dist/usage-BKFZiWQn.js.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/index.js.map +1 -1
- package/dist/utils-DL85Tnbn.js +500 -0
- package/dist/utils-DL85Tnbn.js.map +1 -0
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +3 -3
- package/dist/validation/index.js.map +1 -1
- package/dist/validation-CPUITdMk.js +762 -0
- package/dist/validation-CPUITdMk.js.map +1 -0
- package/dist/workspace-extension-COrC0dYi.js +979 -0
- package/dist/workspace-extension-COrC0dYi.js.map +1 -0
- package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
- package/package.json +7 -10
- package/dist/EventQueueFactory-GXC3A7DH.js +0 -8
- package/dist/EventQueueFactory-GXC3A7DH.js.map +0 -1
- package/dist/chunk-4XIBXZ6J.js +0 -276
- package/dist/chunk-4XIBXZ6J.js.map +0 -1
- package/dist/chunk-554Z4C2K.js +0 -1006
- package/dist/chunk-554Z4C2K.js.map +0 -1
- package/dist/chunk-5CAFHK2Z.js +0 -107
- package/dist/chunk-5CAFHK2Z.js.map +0 -1
- package/dist/chunk-63ZXJ42X.js +0 -451
- package/dist/chunk-63ZXJ42X.js.map +0 -1
- package/dist/chunk-6XEXJATV.js +0 -304
- package/dist/chunk-6XEXJATV.js.map +0 -1
- package/dist/chunk-726AR6Q7.js +0 -1532
- package/dist/chunk-726AR6Q7.js.map +0 -1
- package/dist/chunk-A5F6Z5UE.js +0 -21
- package/dist/chunk-A5F6Z5UE.js.map +0 -1
- package/dist/chunk-A6DE32ZS.js +0 -1507
- package/dist/chunk-A6DE32ZS.js.map +0 -1
- package/dist/chunk-AXJDGQPE.js +0 -690
- package/dist/chunk-AXJDGQPE.js.map +0 -1
- package/dist/chunk-BJQOGOVW.js +0 -602
- package/dist/chunk-BJQOGOVW.js.map +0 -1
- package/dist/chunk-CFXWH2IS.js +0 -52
- package/dist/chunk-CFXWH2IS.js.map +0 -1
- package/dist/chunk-DRWH5XCJ.js +0 -876
- package/dist/chunk-DRWH5XCJ.js.map +0 -1
- package/dist/chunk-E4QNLVY4.js +0 -909
- package/dist/chunk-E4QNLVY4.js.map +0 -1
- package/dist/chunk-EBDHIL7V.js +0 -774
- package/dist/chunk-EBDHIL7V.js.map +0 -1
- package/dist/chunk-ELU7VL3E.js +0 -245
- package/dist/chunk-ELU7VL3E.js.map +0 -1
- package/dist/chunk-FZRODKIN.js +0 -31
- package/dist/chunk-FZRODKIN.js.map +0 -1
- package/dist/chunk-GCIB76AJ.js +0 -882
- package/dist/chunk-GCIB76AJ.js.map +0 -1
- package/dist/chunk-HC6MPUIH.js +0 -1571
- package/dist/chunk-HC6MPUIH.js.map +0 -1
- package/dist/chunk-HNMHPSAM.js +0 -272
- package/dist/chunk-HNMHPSAM.js.map +0 -1
- package/dist/chunk-HTLEGD3Q.js +0 -1480
- package/dist/chunk-HTLEGD3Q.js.map +0 -1
- package/dist/chunk-I3KOWRT3.js +0 -89
- package/dist/chunk-I3KOWRT3.js.map +0 -1
- package/dist/chunk-ID3WR4JS.js +0 -509
- package/dist/chunk-ID3WR4JS.js.map +0 -1
- package/dist/chunk-JS52ZHTK.js +0 -1346
- package/dist/chunk-JS52ZHTK.js.map +0 -1
- package/dist/chunk-JVMAQOA3.js +0 -521
- package/dist/chunk-JVMAQOA3.js.map +0 -1
- package/dist/chunk-KH4TRQCO.js +0 -1063
- package/dist/chunk-KH4TRQCO.js.map +0 -1
- package/dist/chunk-KJOSPVB2.js +0 -57
- package/dist/chunk-KJOSPVB2.js.map +0 -1
- package/dist/chunk-KO2ZXZ7W.js +0 -61
- package/dist/chunk-KO2ZXZ7W.js.map +0 -1
- package/dist/chunk-KS2HQCJR.js +0 -56
- package/dist/chunk-KS2HQCJR.js.map +0 -1
- package/dist/chunk-LA5KPWZ2.js +0 -413
- package/dist/chunk-LA5KPWZ2.js.map +0 -1
- package/dist/chunk-MESLAC5W.js +0 -574
- package/dist/chunk-MESLAC5W.js.map +0 -1
- package/dist/chunk-MWPYA2HD.js +0 -94
- package/dist/chunk-MWPYA2HD.js.map +0 -1
- package/dist/chunk-NUB5GQTU.js +0 -270
- package/dist/chunk-NUB5GQTU.js.map +0 -1
- package/dist/chunk-OBBCR6WY.js +0 -277
- package/dist/chunk-OBBCR6WY.js.map +0 -1
- package/dist/chunk-OQDSAOG3.js +0 -1908
- package/dist/chunk-OQDSAOG3.js.map +0 -1
- package/dist/chunk-OXNCBE7P.js +0 -971
- package/dist/chunk-OXNCBE7P.js.map +0 -1
- package/dist/chunk-PBZFAAOM.js +0 -941
- package/dist/chunk-PN6GIF3R.js +0 -1185
- package/dist/chunk-PN6GIF3R.js.map +0 -1
- package/dist/chunk-PYD44IHJ.js +0 -728
- package/dist/chunk-PYD44IHJ.js.map +0 -1
- package/dist/chunk-QVPIACWD.js +0 -679
- package/dist/chunk-QVPIACWD.js.map +0 -1
- package/dist/chunk-QWNNFE4P.js +0 -41
- package/dist/chunk-QWNNFE4P.js.map +0 -1
- package/dist/chunk-RU266375.js +0 -327
- package/dist/chunk-RU266375.js.map +0 -1
- package/dist/chunk-RYTSVGGA.js +0 -1624
- package/dist/chunk-RYTSVGGA.js.map +0 -1
- package/dist/chunk-RZOFS2BQ.js +0 -225
- package/dist/chunk-RZOFS2BQ.js.map +0 -1
- package/dist/chunk-SBS4S2PJ.js +0 -100
- package/dist/chunk-SBS4S2PJ.js.map +0 -1
- package/dist/chunk-SPRG6G6G.js +0 -530
- package/dist/chunk-SPRG6G6G.js.map +0 -1
- package/dist/chunk-STWFX5E2.js +0 -233
- package/dist/chunk-STWFX5E2.js.map +0 -1
- package/dist/chunk-UNASM5VJ.js +0 -419
- package/dist/chunk-UNASM5VJ.js.map +0 -1
- package/dist/chunk-VAT66FJA.js +0 -245
- package/dist/chunk-VAT66FJA.js.map +0 -1
- package/dist/chunk-VFCMR5GX.js +0 -49
- package/dist/chunk-VFCMR5GX.js.map +0 -1
- package/dist/chunk-VGAHZKNJ.js +0 -66
- package/dist/chunk-VGAHZKNJ.js.map +0 -1
- package/dist/chunk-VTJTAAXC.js +0 -627
- package/dist/chunk-VTJTAAXC.js.map +0 -1
- package/dist/chunk-VXVLKRU6.js +0 -758
- package/dist/chunk-VXVLKRU6.js.map +0 -1
- package/dist/chunk-WWUU5ETI.js +0 -163
- package/dist/chunk-WWUU5ETI.js.map +0 -1
- package/dist/chunk-XE4OXN2W.js +0 -10
- package/dist/chunk-XE4OXN2W.js.map +0 -1
- package/dist/chunk-XOJORS75.js +0 -1853
- package/dist/chunk-XOJORS75.js.map +0 -1
- package/dist/chunk-YMZEUTD2.js +0 -110
- package/dist/chunk-YMZEUTD2.js.map +0 -1
- package/dist/chunk-Z77BTSOK.js +0 -617
- package/dist/chunk-Z77BTSOK.js.map +0 -1
- package/dist/chunk-ZZK3WEDI.js +0 -181
- package/dist/chunk-ZZK3WEDI.js.map +0 -1
- package/dist/client-CCXpAZ2r.d.ts +0 -89
- package/dist/client-DSI_760t.d.ts +0 -36
- package/dist/client-JU6T3UPB.js +0 -11
- package/dist/client-JU6T3UPB.js.map +0 -1
- package/dist/dist-2X4Q7PJA.js +0 -1491
- package/dist/dist-2X4Q7PJA.js.map +0 -1
- package/dist/env-4UWSUS64.js +0 -4
- package/dist/env-4UWSUS64.js.map +0 -1
- package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
- package/dist/graphql-CMHMQjvd.d.ts +0 -23
- package/dist/i18n-Qm2AkPC-.d.ts +0 -33
- package/dist/index--yvpa6ay.d.ts +0 -83
- package/dist/index-4gKQKZ2B.d.ts +0 -71
- package/dist/index-5x0XMKXN.d.ts +0 -149
- package/dist/index-B70b5mYS.d.ts +0 -33
- package/dist/index-B8KrxO4j.d.ts +0 -755
- package/dist/index-BOuDKnqD.d.ts +0 -201
- package/dist/index-BTMt4OjA.d.ts +0 -201
- package/dist/index-BejbszA7.d.ts +0 -39
- package/dist/index-BkeOYZye.d.ts +0 -198
- package/dist/index-BuAj5nXg.d.ts +0 -83
- package/dist/index-BvkVcW8I.d.ts +0 -349
- package/dist/index-CWmH_-RZ.d.ts +0 -247
- package/dist/index-CbgWNcus.d.ts +0 -258
- package/dist/index-CmfPeQza.d.ts +0 -166
- package/dist/index-CmpG-zak.d.ts +0 -607
- package/dist/index-CoMKgL-p.d.ts +0 -12
- package/dist/index-D8HGwglK.d.ts +0 -541
- package/dist/index-DCaVm66D.d.ts +0 -1101
- package/dist/index-DE2w7E0d.d.ts +0 -83
- package/dist/index-DSOpj8DI.d.ts +0 -17
- package/dist/index-DW9q22GH.d.ts +0 -75
- package/dist/index-DnjJ9CwI.d.ts +0 -347
- package/dist/index-DwMJZ8PP.d.ts +0 -317
- package/dist/index-PaojfSdd.d.ts +0 -71
- package/dist/index-aHtYvc3i.d.ts +0 -284
- package/dist/index-e_18DzAg.d.ts +0 -18
- package/dist/index-ffmipXSA.d.ts +0 -55
- package/dist/index-joONjwLt.d.ts +0 -33
- package/dist/index-kssw5ziY.d.ts +0 -250
- package/dist/index-lFffh5-G.d.ts +0 -125
- package/dist/index-pxYge_6k.d.ts +0 -79
- package/dist/layer-Cv9vSwBx.d.ts +0 -70
- package/dist/pino-logger-H4HPW5P6.js +0 -5
- package/dist/pino-logger-H4HPW5P6.js.map +0 -1
- package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
- package/dist/sdk-L75WWUP3.js +0 -156
- package/dist/sdk-L75WWUP3.js.map +0 -1
- package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
- package/dist/types-Bo2wkjSP.d.ts +0 -35
- package/dist/types-DVpvrAhd.d.ts +0 -71
- package/dist/types-DgJ4lDYA.d.ts +0 -108
- package/dist/types-USOv09qy.d.ts +0 -327
- package/dist/workspace-guard-NXVYYBVJ.js +0 -5
- package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
import { a as QuotaExceededError, c as ValidationError, o as SDKError } from "./types-Cj2RWXbz.js";
|
|
2
|
+
import { t as GatewayClient } from "./client-DcZ3iGES.js";
|
|
3
|
+
import { a as logger } from "./logger-B6rCpb7D.js";
|
|
4
|
+
import "./gateway-DBFmxWks.js";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
|
|
7
|
+
// src/usage/billing.ts
|
|
8
|
+
/**
|
|
9
|
+
* Billing Usage Client
|
|
10
|
+
*
|
|
11
|
+
* Canonical cross-layer quota/usage surface for wspace services talking to
|
|
12
|
+
* `global-billing-svc`. All transport (URL resolution, actor/service header
|
|
13
|
+
* assembly, service-JWT minting, retries, circuit breaker, timeouts,
|
|
14
|
+
* telemetry) comes from the {@link GatewayClient}:
|
|
15
|
+
*
|
|
16
|
+
* - **wspace -> wspace** (resolving a workspace's org) uses `internalQuery`
|
|
17
|
+
* (same-layer internal gateway, `WSPACE_INT_GATEWAY_URL`).
|
|
18
|
+
* - **wspace -> global** (billing account + quota + usage) uses
|
|
19
|
+
* `crossLayerQuery`, which routes via the global PUBLIC gateway
|
|
20
|
+
* (`GLOBAL_PUBLIC_GATEWAY_URL`) and mints a signed `service` JWT the
|
|
21
|
+
* gateway trusts. Only `x-actor-type: service` is presented — never
|
|
22
|
+
* `x-actor-id` (auth-middleware reads that as an on-behalf-of override and
|
|
23
|
+
* downgrades the caller to `user`, yielding a 403). Actor identity for the
|
|
24
|
+
* usage record is carried in the GraphQL variables (`userId`), not in
|
|
25
|
+
* headers.
|
|
26
|
+
*
|
|
27
|
+
* Every read/write fails open (returns `null`/`false`, or `true` for the
|
|
28
|
+
* workspace quota gate) so transient billing unavailability never blocks a
|
|
29
|
+
* product operation; callers that need hard enforcement must layer it on top.
|
|
30
|
+
*
|
|
31
|
+
* @module usage/billing
|
|
32
|
+
* @category Usage
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Bound each gateway attempt so a slow billing gateway never stalls the
|
|
36
|
+
* (blocking) quota-limit read.
|
|
37
|
+
*/
|
|
38
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 5e3;
|
|
39
|
+
/** Default TTL for the in-process plan-limit cache. */
|
|
40
|
+
const DEFAULT_QUOTA_LIMIT_CACHE_TTL_MS = 3e5;
|
|
41
|
+
/** Lazy prune threshold — keeps the plan-limit cache bounded without timers. */
|
|
42
|
+
const QUOTA_LIMIT_CACHE_MAX_ENTRIES = 1e3;
|
|
43
|
+
const GET_WORKSPACE_ORG_QUERY = `
|
|
44
|
+
query GetWorkspaceOrg($workspaceId: ID!) {
|
|
45
|
+
workspace(id: $workspaceId) {
|
|
46
|
+
orgId
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const GET_DEFAULT_BILLING_ACCOUNT_QUERY = `
|
|
51
|
+
query GetDefaultBillingAccount($orgId: ID!) {
|
|
52
|
+
getDefaultBillingAccountByOrgId(orgId: $orgId) {
|
|
53
|
+
id
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
const CHECK_QUOTA_QUERY = `
|
|
58
|
+
query CheckQuotaExhausted($billingAccountId: ID!, $quotaName: String!, $productId: String) {
|
|
59
|
+
checkQuotaExhausted(
|
|
60
|
+
billingAccountId: $billingAccountId
|
|
61
|
+
quotaName: $quotaName
|
|
62
|
+
productId: $productId
|
|
63
|
+
) {
|
|
64
|
+
limitLeft
|
|
65
|
+
noLimit
|
|
66
|
+
quotaAssignmentId
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
const ADD_USAGE_MUTATION = `
|
|
71
|
+
mutation AddUsage(
|
|
72
|
+
$billingAccountId: ID!
|
|
73
|
+
$quotaName: String!
|
|
74
|
+
$value: Int!
|
|
75
|
+
$description: String!
|
|
76
|
+
$tags: JSON
|
|
77
|
+
$hash: String
|
|
78
|
+
$userId: ID
|
|
79
|
+
$productId: String
|
|
80
|
+
) {
|
|
81
|
+
addUsage(
|
|
82
|
+
billingAccountId: $billingAccountId
|
|
83
|
+
quotaName: $quotaName
|
|
84
|
+
value: $value
|
|
85
|
+
description: $description
|
|
86
|
+
tags: $tags
|
|
87
|
+
hash: $hash
|
|
88
|
+
userId: $userId
|
|
89
|
+
productId: $productId
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
const GET_QUOTA_LIMIT_QUERY = `
|
|
94
|
+
query GetQuotaLimit($billingAccountId: ID!, $quotaName: String!, $productId: String) {
|
|
95
|
+
getQuotaUsageAndLimit(
|
|
96
|
+
billingAccountId: $billingAccountId
|
|
97
|
+
quotaName: $quotaName
|
|
98
|
+
productId: $productId
|
|
99
|
+
) {
|
|
100
|
+
limit
|
|
101
|
+
noLimit
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
const FREE_UP_USAGE_MUTATION = `
|
|
106
|
+
mutation FreeUpUsage(
|
|
107
|
+
$billingAccountId: ID!
|
|
108
|
+
$quotaName: String!
|
|
109
|
+
$value: Int!
|
|
110
|
+
$description: String
|
|
111
|
+
$tags: JSON
|
|
112
|
+
$hash: String
|
|
113
|
+
$userId: ID
|
|
114
|
+
$productId: String
|
|
115
|
+
) {
|
|
116
|
+
freeUpUsage(
|
|
117
|
+
billingAccountId: $billingAccountId
|
|
118
|
+
quotaName: $quotaName
|
|
119
|
+
value: $value
|
|
120
|
+
description: $description
|
|
121
|
+
tags: $tags
|
|
122
|
+
hash: $hash
|
|
123
|
+
userId: $userId
|
|
124
|
+
productId: $productId
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
function unwrap(data) {
|
|
129
|
+
if (!data) throw new Error("GraphQL response did not include data");
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Canonical quota/usage client for wspace -> global-billing-svc traffic.
|
|
134
|
+
*
|
|
135
|
+
* See the module docstring for the transport contract. All methods fail open;
|
|
136
|
+
* see individual method docs for the exact fallback value.
|
|
137
|
+
*/
|
|
138
|
+
var BillingUsageClient = class {
|
|
139
|
+
gatewayClient;
|
|
140
|
+
quotaLimitCacheTtlMs;
|
|
141
|
+
logPrefix;
|
|
142
|
+
quotaLimitCache = /* @__PURE__ */ new Map();
|
|
143
|
+
constructor(config) {
|
|
144
|
+
if (!config.serviceName) throw new TypeError("BillingUsageClient requires a serviceName");
|
|
145
|
+
this.gatewayClient = config.gatewayClient ?? new GatewayClient({
|
|
146
|
+
layer: "wspace",
|
|
147
|
+
serviceName: config.serviceName,
|
|
148
|
+
timeout: config.timeout ?? DEFAULT_REQUEST_TIMEOUT_MS
|
|
149
|
+
});
|
|
150
|
+
this.quotaLimitCacheTtlMs = config.quotaLimitCacheTtlMs ?? DEFAULT_QUOTA_LIMIT_CACHE_TTL_MS;
|
|
151
|
+
this.logPrefix = `[billing-usage:${config.serviceName}]`;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Same-layer (wspace -> wspace) internal-gateway call.
|
|
155
|
+
*/
|
|
156
|
+
async queryWorkspaceLayer(query, variables, workspaceId) {
|
|
157
|
+
return unwrap((await this.gatewayClient.internalQuery({
|
|
158
|
+
query,
|
|
159
|
+
variables,
|
|
160
|
+
headers: { "x-workspace-id": workspaceId },
|
|
161
|
+
skipRetry: true
|
|
162
|
+
})).data);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Cross-layer (wspace -> global) public-gateway call. No actor headers — the
|
|
166
|
+
* signed service JWT carries identity; adding `x-actor-id` would 403.
|
|
167
|
+
*/
|
|
168
|
+
async queryGlobalLayer(query, variables) {
|
|
169
|
+
return unwrap((await this.gatewayClient.crossLayerQuery({
|
|
170
|
+
query,
|
|
171
|
+
variables
|
|
172
|
+
})).data);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Resolve the organization that owns a workspace. Fails open (`null`).
|
|
176
|
+
*/
|
|
177
|
+
async getOrgIdFromWorkspace(workspaceId) {
|
|
178
|
+
try {
|
|
179
|
+
return (await this.queryWorkspaceLayer(GET_WORKSPACE_ORG_QUERY, { workspaceId }, workspaceId)).workspace?.orgId ?? null;
|
|
180
|
+
} catch (error) {
|
|
181
|
+
logger.warn(`${this.logPrefix} Failed to resolve workspace org`, {
|
|
182
|
+
workspaceId,
|
|
183
|
+
error: error instanceof Error ? error.message : String(error)
|
|
184
|
+
});
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Resolve the default billing account for an organization via the global
|
|
190
|
+
* layer. Fails open (`null`).
|
|
191
|
+
*/
|
|
192
|
+
async getDefaultBillingAccountId(orgId) {
|
|
193
|
+
try {
|
|
194
|
+
return (await this.queryGlobalLayer(GET_DEFAULT_BILLING_ACCOUNT_QUERY, { orgId })).getDefaultBillingAccountByOrgId?.id ?? null;
|
|
195
|
+
} catch (error) {
|
|
196
|
+
logger.warn(`${this.logPrefix} Failed to resolve default billing account`, {
|
|
197
|
+
orgId,
|
|
198
|
+
error: error instanceof Error ? error.message : String(error)
|
|
199
|
+
});
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Check that an organization still has quota headroom for `value` units of
|
|
205
|
+
* `quotaName`. Returns `false` when no billing account exists or the quota
|
|
206
|
+
* is exhausted; rethrows nothing — transport errors propagate to the caller
|
|
207
|
+
* of this low-level variant (the workspace variant fails open instead).
|
|
208
|
+
*/
|
|
209
|
+
async ensureQuotaAvailableForOrg(input) {
|
|
210
|
+
const billingAccountId = await this.getDefaultBillingAccountId(input.orgId);
|
|
211
|
+
if (!billingAccountId) {
|
|
212
|
+
logger.warn(`${this.logPrefix} No billing account available for org quota check`, {
|
|
213
|
+
orgId: input.orgId,
|
|
214
|
+
quotaName: input.quotaName
|
|
215
|
+
});
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const amount = input.value ?? 1;
|
|
219
|
+
const result = (await this.queryGlobalLayer(CHECK_QUOTA_QUERY, {
|
|
220
|
+
billingAccountId,
|
|
221
|
+
quotaName: input.quotaName,
|
|
222
|
+
productId: input.productId
|
|
223
|
+
})).checkQuotaExhausted;
|
|
224
|
+
if (!result) return false;
|
|
225
|
+
if (result.noLimit) return true;
|
|
226
|
+
return result.limitLeft >= amount;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Workspace-addressed quota gate: resolves the org, then applies
|
|
230
|
+
* {@link ensureQuotaAvailableForOrg}. Fails OPEN (`true`) when org
|
|
231
|
+
* resolution fails (unbilled / dev / internal workspaces) so local-stack
|
|
232
|
+
* test workspaces and workspaces with a transiently broken tenant lookup
|
|
233
|
+
* are never locked out; real limits only kick in when the workspace has a
|
|
234
|
+
* billable org.
|
|
235
|
+
*/
|
|
236
|
+
async ensureQuotaAvailableForWorkspace(input) {
|
|
237
|
+
const orgId = await this.getOrgIdFromWorkspace(input.workspaceId);
|
|
238
|
+
if (!orgId) {
|
|
239
|
+
logger.warn(`${this.logPrefix} No organization available; allowing quota op (fail-open)`, {
|
|
240
|
+
workspaceId: input.workspaceId,
|
|
241
|
+
quotaName: input.quotaName
|
|
242
|
+
});
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
return this.ensureQuotaAvailableForOrg({
|
|
246
|
+
...input,
|
|
247
|
+
orgId
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Record usage against an organization's billing account. No-ops (`false`)
|
|
252
|
+
* when there is no billing account.
|
|
253
|
+
*/
|
|
254
|
+
async addUsageForOrg(input) {
|
|
255
|
+
const billingAccountId = await this.getDefaultBillingAccountId(input.orgId);
|
|
256
|
+
if (!billingAccountId) {
|
|
257
|
+
logger.warn(`${this.logPrefix} No billing account available for addUsage`, {
|
|
258
|
+
orgId: input.orgId,
|
|
259
|
+
quotaName: input.quotaName
|
|
260
|
+
});
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
return (await this.queryGlobalLayer(ADD_USAGE_MUTATION, {
|
|
264
|
+
billingAccountId,
|
|
265
|
+
quotaName: input.quotaName,
|
|
266
|
+
value: input.value ?? 1,
|
|
267
|
+
description: input.description,
|
|
268
|
+
tags: input.tags,
|
|
269
|
+
hash: input.hash,
|
|
270
|
+
userId: input.userId,
|
|
271
|
+
productId: input.productId
|
|
272
|
+
})).addUsage ?? false;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Workspace-addressed {@link addUsageForOrg}. No-ops (`false`) when the
|
|
276
|
+
* workspace has no org.
|
|
277
|
+
*/
|
|
278
|
+
async addUsageForWorkspace(input) {
|
|
279
|
+
const orgId = await this.getOrgIdFromWorkspace(input.workspaceId);
|
|
280
|
+
if (!orgId) {
|
|
281
|
+
logger.warn(`${this.logPrefix} No organization available for workspace addUsage`, {
|
|
282
|
+
workspaceId: input.workspaceId,
|
|
283
|
+
quotaName: input.quotaName
|
|
284
|
+
});
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
return this.addUsageForOrg({
|
|
288
|
+
...input,
|
|
289
|
+
orgId
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Credit usage back to an organization's billing account. No-ops (`false`)
|
|
294
|
+
* when there is no billing account.
|
|
295
|
+
*/
|
|
296
|
+
async freeUpUsageForOrg(input) {
|
|
297
|
+
const billingAccountId = await this.getDefaultBillingAccountId(input.orgId);
|
|
298
|
+
if (!billingAccountId) {
|
|
299
|
+
logger.warn(`${this.logPrefix} No billing account available for freeUpUsage`, {
|
|
300
|
+
orgId: input.orgId,
|
|
301
|
+
quotaName: input.quotaName
|
|
302
|
+
});
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
return (await this.queryGlobalLayer(FREE_UP_USAGE_MUTATION, {
|
|
306
|
+
billingAccountId,
|
|
307
|
+
quotaName: input.quotaName,
|
|
308
|
+
value: input.value ?? 1,
|
|
309
|
+
description: input.description,
|
|
310
|
+
tags: input.tags,
|
|
311
|
+
hash: input.hash,
|
|
312
|
+
userId: input.userId,
|
|
313
|
+
productId: input.productId
|
|
314
|
+
})).freeUpUsage ?? false;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Workspace-addressed {@link freeUpUsageForOrg}. No-ops (`false`) when the
|
|
318
|
+
* workspace has no org.
|
|
319
|
+
*/
|
|
320
|
+
async freeUpUsageForWorkspace(input) {
|
|
321
|
+
const orgId = await this.getOrgIdFromWorkspace(input.workspaceId);
|
|
322
|
+
if (!orgId) {
|
|
323
|
+
logger.warn(`${this.logPrefix} No organization available for workspace freeUpUsage`, {
|
|
324
|
+
workspaceId: input.workspaceId,
|
|
325
|
+
quotaName: input.quotaName
|
|
326
|
+
});
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
return this.freeUpUsageForOrg({
|
|
330
|
+
...input,
|
|
331
|
+
orgId
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Fetch the plan limit for a quota from billing-svc, bypassing billing's
|
|
336
|
+
* internal usage counter (the caller's own DB is the source of truth for
|
|
337
|
+
* current usage; billing only stores the plan maximum). Results are cached
|
|
338
|
+
* in-process per workspace/quota/product. Fails open (`null`) when billing
|
|
339
|
+
* is unreachable so dev/test workspaces without billing accounts are never
|
|
340
|
+
* blocked.
|
|
341
|
+
*/
|
|
342
|
+
async getQuotaLimitForWorkspace(workspaceId, quotaName, productId) {
|
|
343
|
+
const cacheKey = `${workspaceId}:${quotaName}:${productId}`;
|
|
344
|
+
const cached = this.quotaLimitCache.get(cacheKey);
|
|
345
|
+
if (cached && cached.expiresAt > Date.now()) return {
|
|
346
|
+
limit: cached.limit,
|
|
347
|
+
noLimit: cached.noLimit
|
|
348
|
+
};
|
|
349
|
+
const orgId = await this.getOrgIdFromWorkspace(workspaceId);
|
|
350
|
+
if (!orgId) {
|
|
351
|
+
logger.warn(`${this.logPrefix} No org found for quota limit lookup; failing open`, {
|
|
352
|
+
workspaceId,
|
|
353
|
+
quotaName
|
|
354
|
+
});
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
const billingAccountId = await this.getDefaultBillingAccountId(orgId);
|
|
358
|
+
if (!billingAccountId) {
|
|
359
|
+
logger.warn(`${this.logPrefix} No billing account found for quota limit lookup; failing open`, {
|
|
360
|
+
workspaceId,
|
|
361
|
+
quotaName
|
|
362
|
+
});
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
const result = (await this.queryGlobalLayer(GET_QUOTA_LIMIT_QUERY, {
|
|
367
|
+
billingAccountId,
|
|
368
|
+
quotaName,
|
|
369
|
+
productId
|
|
370
|
+
})).getQuotaUsageAndLimit;
|
|
371
|
+
if (!result) return null;
|
|
372
|
+
this.rememberQuotaLimit(cacheKey, {
|
|
373
|
+
limit: result.limit,
|
|
374
|
+
noLimit: result.noLimit
|
|
375
|
+
});
|
|
376
|
+
return {
|
|
377
|
+
limit: result.limit,
|
|
378
|
+
noLimit: result.noLimit
|
|
379
|
+
};
|
|
380
|
+
} catch (error) {
|
|
381
|
+
logger.warn(`${this.logPrefix} Failed to fetch quota limit; failing open`, {
|
|
382
|
+
workspaceId,
|
|
383
|
+
quotaName,
|
|
384
|
+
error: error instanceof Error ? error.message : String(error)
|
|
385
|
+
});
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
rememberQuotaLimit(cacheKey, value) {
|
|
390
|
+
if (this.quotaLimitCache.size >= QUOTA_LIMIT_CACHE_MAX_ENTRIES) {
|
|
391
|
+
const now = Date.now();
|
|
392
|
+
for (const [key, entry] of this.quotaLimitCache) if (entry.expiresAt <= now) this.quotaLimitCache.delete(key);
|
|
393
|
+
if (this.quotaLimitCache.size >= QUOTA_LIMIT_CACHE_MAX_ENTRIES) {
|
|
394
|
+
const overflow = this.quotaLimitCache.size - QUOTA_LIMIT_CACHE_MAX_ENTRIES + 1;
|
|
395
|
+
let removed = 0;
|
|
396
|
+
for (const key of this.quotaLimitCache.keys()) {
|
|
397
|
+
this.quotaLimitCache.delete(key);
|
|
398
|
+
removed += 1;
|
|
399
|
+
if (removed >= overflow) break;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
this.quotaLimitCache.set(cacheKey, {
|
|
404
|
+
...value,
|
|
405
|
+
expiresAt: Date.now() + this.quotaLimitCacheTtlMs
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// src/usage/index.ts
|
|
411
|
+
/**
|
|
412
|
+
* Usage & Quota Module
|
|
413
|
+
*
|
|
414
|
+
* Checks and records workspace quota usage against the workspace usage owner
|
|
415
|
+
* (wspace-activity-svc). The owner's published contract is:
|
|
416
|
+
*
|
|
417
|
+
* - `checkWorkspaceQuota(workspaceId, quotaName, amount): WorkspaceQuotaCheckResult!`
|
|
418
|
+
* - `trackUsage(input: TrackUsageInput!): Boolean!`
|
|
419
|
+
*
|
|
420
|
+
* Quotas are keyed by `quotaName` (for example `platform.projects.created`), not by the
|
|
421
|
+
* `entityId`/`entityType`/`metricType` triple this module used to send. That triple was
|
|
422
|
+
* never part of the owner's schema, so every legacy call failed GraphQL validation
|
|
423
|
+
* (BOFF-10955). The legacy methods remain for source compatibility and fail with
|
|
424
|
+
* {@link UsageOperationUnsupportedError} before any network call.
|
|
425
|
+
*/
|
|
426
|
+
/**
|
|
427
|
+
* Legacy usage metric names. The workspace usage owner has no metric types; quotas are
|
|
428
|
+
* addressed by `quotaName`. Kept so existing `sdk.tracker.track({ usage: { metricType } })`
|
|
429
|
+
* call sites keep compiling; the tracker does not meter a metric type on its own.
|
|
430
|
+
*/
|
|
431
|
+
let UsageMetricType = /* @__PURE__ */ function(UsageMetricType) {
|
|
432
|
+
UsageMetricType["API_CALLS"] = "api_calls";
|
|
433
|
+
UsageMetricType["STORAGE"] = "storage";
|
|
434
|
+
UsageMetricType["BANDWIDTH"] = "bandwidth";
|
|
435
|
+
UsageMetricType["USERS"] = "users";
|
|
436
|
+
UsageMetricType["PROJECTS"] = "projects";
|
|
437
|
+
UsageMetricType["WORKSPACES"] = "workspaces";
|
|
438
|
+
UsageMetricType["RECORDS"] = "records";
|
|
439
|
+
UsageMetricType["COMPUTE_TIME"] = "compute_time";
|
|
440
|
+
UsageMetricType["TRANSACTIONS"] = "transactions";
|
|
441
|
+
UsageMetricType["CUSTOM"] = "custom";
|
|
442
|
+
return UsageMetricType;
|
|
443
|
+
}({});
|
|
444
|
+
let QuotaPeriod = /* @__PURE__ */ function(QuotaPeriod) {
|
|
445
|
+
QuotaPeriod["DAILY"] = "daily";
|
|
446
|
+
QuotaPeriod["WEEKLY"] = "weekly";
|
|
447
|
+
QuotaPeriod["MONTHLY"] = "monthly";
|
|
448
|
+
QuotaPeriod["YEARLY"] = "yearly";
|
|
449
|
+
QuotaPeriod["LIFETIME"] = "lifetime";
|
|
450
|
+
return QuotaPeriod;
|
|
451
|
+
}({});
|
|
452
|
+
/** Thrown by SDK usage operations the workspace usage owner does not expose. */
|
|
453
|
+
var UsageOperationUnsupportedError = class UsageOperationUnsupportedError extends SDKError {
|
|
454
|
+
constructor(operation, guidance) {
|
|
455
|
+
super(`UsageModule.${operation} is not supported by the workspace usage owner: ${guidance}`, "USAGE_OPERATION_UNSUPPORTED", { operation });
|
|
456
|
+
this.name = "UsageOperationUnsupportedError";
|
|
457
|
+
Object.setPrototypeOf(this, UsageOperationUnsupportedError.prototype);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
/**
|
|
461
|
+
* Query sent to the owner's `checkWorkspaceQuota`. Every argument and selected field must
|
|
462
|
+
* exist on the published wspace schema (see tests/usage-module.test.ts).
|
|
463
|
+
*/
|
|
464
|
+
const CHECK_WORKSPACE_QUOTA_QUERY = `
|
|
465
|
+
query CheckWorkspaceQuota($workspaceId: ID!, $quotaName: String!, $amount: Float) {
|
|
466
|
+
checkWorkspaceQuota(workspaceId: $workspaceId, quotaName: $quotaName, amount: $amount) {
|
|
467
|
+
allowed
|
|
468
|
+
assignmentId
|
|
469
|
+
limitLeft
|
|
470
|
+
noLimit
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
`;
|
|
474
|
+
/** Mutation sent to the owner's `trackUsage`, which returns `Boolean!`. */
|
|
475
|
+
const TRACK_USAGE_MUTATION = `
|
|
476
|
+
mutation TrackUsage($input: TrackUsageInput!) {
|
|
477
|
+
trackUsage(input: $input)
|
|
478
|
+
}
|
|
479
|
+
`;
|
|
480
|
+
function legacyGuidance(replacement) {
|
|
481
|
+
return `quotas are addressed by quotaName on the workspace usage owner; use ${replacement}`;
|
|
482
|
+
}
|
|
483
|
+
function nonEmpty(value) {
|
|
484
|
+
const trimmed = value?.trim();
|
|
485
|
+
return trimmed ? trimmed : void 0;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Builds the owner's `TrackUsageInput` from SDK options, filling defaults from the context.
|
|
489
|
+
* Throws {@link ValidationError} for input the owner would refuse.
|
|
490
|
+
*/
|
|
491
|
+
function buildTrackUsageInput(options, context = {}) {
|
|
492
|
+
const quotaName = nonEmpty(options.quotaName);
|
|
493
|
+
if (!quotaName) throw new ValidationError("Quota name is required");
|
|
494
|
+
const productId = nonEmpty(options.productId) ?? nonEmpty(context.productId);
|
|
495
|
+
if (!productId) throw new ValidationError("Product ID is required");
|
|
496
|
+
const description = nonEmpty(options.description);
|
|
497
|
+
if (!description) throw new ValidationError("Description is required");
|
|
498
|
+
if (typeof options.amount !== "number" || !Number.isFinite(options.amount) || options.amount === 0) throw new ValidationError("Amount must be a finite, non-zero number");
|
|
499
|
+
const workspaceId = nonEmpty(options.workspaceId) ?? nonEmpty(context.workspaceId);
|
|
500
|
+
if (!workspaceId) throw new ValidationError("Workspace ID is required");
|
|
501
|
+
const input = {
|
|
502
|
+
quotaName,
|
|
503
|
+
productId,
|
|
504
|
+
amount: options.amount,
|
|
505
|
+
description,
|
|
506
|
+
workspaceId,
|
|
507
|
+
hash: nonEmpty(options.hash) ?? `sdk-usage:${randomUUID()}`
|
|
508
|
+
};
|
|
509
|
+
const userId = nonEmpty(options.userId) ?? nonEmpty(context.actorId);
|
|
510
|
+
if (userId) input["userId"] = userId;
|
|
511
|
+
if (options.quotaAssignmentId) input["quotaAssignmentId"] = options.quotaAssignmentId;
|
|
512
|
+
if (options.billingAccountId) input["billingAccountId"] = options.billingAccountId;
|
|
513
|
+
if (options.metadata) input["metadata"] = options.metadata;
|
|
514
|
+
return input;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Usage & Quota Module
|
|
518
|
+
*/
|
|
519
|
+
var UsageModule = class {
|
|
520
|
+
client;
|
|
521
|
+
context;
|
|
522
|
+
constructor(client, context) {
|
|
523
|
+
this.client = client;
|
|
524
|
+
this.context = context;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Context for one owner call: relayed as a platform service acting for `userId`, with the
|
|
528
|
+
* quota's workspace in scope. The owner takes the workspace from this context, never from
|
|
529
|
+
* the input, and only lets services release (decrement) usage.
|
|
530
|
+
*/
|
|
531
|
+
requestContext(workspaceId, userId) {
|
|
532
|
+
const actorId = userId ?? this.context.actorId;
|
|
533
|
+
return {
|
|
534
|
+
...this.context,
|
|
535
|
+
...actorId ? { actorId } : {},
|
|
536
|
+
actorType: "service",
|
|
537
|
+
workspaceId
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Check whether a workspace quota has capacity for `amount` (default 1).
|
|
542
|
+
*/
|
|
543
|
+
async checkWorkspaceQuota(options) {
|
|
544
|
+
const quotaName = nonEmpty(options.quotaName);
|
|
545
|
+
if (!quotaName) throw new ValidationError("Quota name is required");
|
|
546
|
+
const amount = options.amount ?? 1;
|
|
547
|
+
if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) throw new ValidationError("Quota checks need a positive amount");
|
|
548
|
+
const workspaceId = nonEmpty(options.workspaceId) ?? nonEmpty(this.context.workspaceId);
|
|
549
|
+
if (!workspaceId) throw new ValidationError("Workspace ID is required");
|
|
550
|
+
logger.debug("[Usage] Checking workspace quota", {
|
|
551
|
+
workspaceId,
|
|
552
|
+
quotaName,
|
|
553
|
+
amount
|
|
554
|
+
});
|
|
555
|
+
const result = (await this.client.query(CHECK_WORKSPACE_QUOTA_QUERY, {
|
|
556
|
+
workspaceId,
|
|
557
|
+
quotaName,
|
|
558
|
+
amount
|
|
559
|
+
}, this.requestContext(workspaceId, nonEmpty(options.userId)))).checkWorkspaceQuota;
|
|
560
|
+
logger.debug("[Usage] Workspace quota check result", {
|
|
561
|
+
workspaceId,
|
|
562
|
+
quotaName,
|
|
563
|
+
allowed: result.allowed
|
|
564
|
+
});
|
|
565
|
+
return result;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Check a workspace quota and throw {@link QuotaExceededError} when it has no capacity.
|
|
569
|
+
* Returns the check result so the caller can pass `assignmentId` to {@link trackUsage}.
|
|
570
|
+
*/
|
|
571
|
+
async requireWorkspaceQuota(options) {
|
|
572
|
+
const result = await this.checkWorkspaceQuota(options);
|
|
573
|
+
if (!result.allowed) {
|
|
574
|
+
const notProvisioned = result.assignmentId === null;
|
|
575
|
+
throw new QuotaExceededError(notProvisioned ? `Quota ${options.quotaName} is not included in this workspace's plan` : "Quota exceeded", {
|
|
576
|
+
quotaName: options.quotaName,
|
|
577
|
+
requestedAmount: options.amount ?? 1,
|
|
578
|
+
limitLeft: result.limitLeft,
|
|
579
|
+
notProvisioned
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Record workspace quota usage. A negative amount releases previously recorded usage.
|
|
586
|
+
* Resolves to `true` once the owner has stored (or deduplicated) the record.
|
|
587
|
+
*/
|
|
588
|
+
async trackUsage(options) {
|
|
589
|
+
const input = buildTrackUsageInput(options, this.context);
|
|
590
|
+
const workspaceId = input["workspaceId"];
|
|
591
|
+
logger.debug("[Usage] Tracking workspace usage", {
|
|
592
|
+
workspaceId,
|
|
593
|
+
quotaName: input["quotaName"],
|
|
594
|
+
amount: input["amount"]
|
|
595
|
+
});
|
|
596
|
+
const response = await this.client.query(TRACK_USAGE_MUTATION, { input }, this.requestContext(workspaceId, nonEmpty(options.userId)));
|
|
597
|
+
logger.info("[Usage] Workspace usage tracked", {
|
|
598
|
+
workspaceId,
|
|
599
|
+
quotaName: input["quotaName"]
|
|
600
|
+
});
|
|
601
|
+
return response.trackUsage;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* @deprecated The workspace usage owner has no `trackUsage` record shape keyed by
|
|
605
|
+
* `entityId`/`metricType`. Use {@link trackUsage} with a `quotaName`.
|
|
606
|
+
*/
|
|
607
|
+
async track(_options) {
|
|
608
|
+
throw new UsageOperationUnsupportedError("track", legacyGuidance("trackUsage({ quotaName, productId, amount })"));
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* @deprecated The owner has no `checkQuota` operation. Use {@link checkWorkspaceQuota}.
|
|
612
|
+
*/
|
|
613
|
+
async checkQuota(_options) {
|
|
614
|
+
throw new UsageOperationUnsupportedError("checkQuota", legacyGuidance("checkWorkspaceQuota({ quotaName, amount })"));
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* @deprecated The owner has no `checkQuota` operation. Use {@link requireWorkspaceQuota}.
|
|
618
|
+
*/
|
|
619
|
+
async requireQuota(_options) {
|
|
620
|
+
throw new UsageOperationUnsupportedError("requireQuota", legacyGuidance("requireWorkspaceQuota({ quotaName, amount })"));
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* @deprecated Use {@link requireWorkspaceQuota} followed by {@link trackUsage}.
|
|
624
|
+
*/
|
|
625
|
+
async trackAndCheck(_options) {
|
|
626
|
+
throw new UsageOperationUnsupportedError("trackAndCheck", legacyGuidance("requireWorkspaceQuota() and then trackUsage()"));
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* @deprecated The owner has no `getUsage` operation; read records with the owner's
|
|
630
|
+
* `getUsageRecords(filters, pagination)`.
|
|
631
|
+
*/
|
|
632
|
+
async getUsage(_options) {
|
|
633
|
+
throw new UsageOperationUnsupportedError("getUsage", legacyGuidance("the owner's getUsageRecords query"));
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* @deprecated The owner's `getUsageSummary` takes `UsageFilters` and returns a list; this
|
|
637
|
+
* signature does not map onto it.
|
|
638
|
+
*/
|
|
639
|
+
async getSummary(_entityId, _entityType, _metricType, _period) {
|
|
640
|
+
throw new UsageOperationUnsupportedError("getSummary", legacyGuidance("the owner's getUsageSummary(filters) query"));
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* @deprecated Quota limits are assigned by global-billing-svc through the owner's
|
|
644
|
+
* `assignWorkspaceQuota`, which only billing's service identity may call.
|
|
645
|
+
*/
|
|
646
|
+
async setQuota(_options) {
|
|
647
|
+
throw new UsageOperationUnsupportedError("setQuota", "quota limits are assigned by global-billing-svc");
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* @deprecated The owner has no `getQuota` operation; read `workspaceQuotaStatuses(workspaceId)`.
|
|
651
|
+
*/
|
|
652
|
+
async getQuota(_entityId, _entityType, _metricType) {
|
|
653
|
+
throw new UsageOperationUnsupportedError("getQuota", legacyGuidance("the owner's workspaceQuotaStatuses query"));
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* @deprecated The owner has no `getQuotas` operation; read `workspaceQuotaAssignments(workspaceId)`.
|
|
657
|
+
*/
|
|
658
|
+
async getQuotas(_entityId, _entityType) {
|
|
659
|
+
throw new UsageOperationUnsupportedError("getQuotas", legacyGuidance("the owner's workspaceQuotaAssignments query"));
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* @deprecated The owner has no `resetQuota` operation; quotas reset on their `resetPeriod`.
|
|
663
|
+
*/
|
|
664
|
+
async resetQuota(_entityId, _entityType, _metricType) {
|
|
665
|
+
throw new UsageOperationUnsupportedError("resetQuota", "quotas reset on the assignment's resetPeriod");
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* @deprecated The owner has no `deleteQuota` operation; billing deactivates assignments.
|
|
669
|
+
*/
|
|
670
|
+
async deleteQuota(_entityId, _entityType, _metricType) {
|
|
671
|
+
throw new UsageOperationUnsupportedError("deleteQuota", "quota assignments are deactivated by global-billing-svc");
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* @deprecated The owner has no `trackUsageBulk` operation. Call {@link trackUsage} per record.
|
|
675
|
+
*/
|
|
676
|
+
async trackBulk(_records) {
|
|
677
|
+
throw new UsageOperationUnsupportedError("trackBulk", legacyGuidance("trackUsage() per record"));
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
|
|
681
|
+
export { UsageModule as a, BillingUsageClient as c, UsageMetricType as i, QuotaPeriod as n, UsageOperationUnsupportedError as o, TRACK_USAGE_MUTATION as r, buildTrackUsageInput as s, CHECK_WORKSPACE_QUOTA_QUERY as t };
|
|
682
|
+
//# sourceMappingURL=usage-BKFZiWQn.js.map
|