@burdenoff/be-sdk 2026.1110.1 → 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-PP534MBQ.js +0 -8
- package/dist/EventQueueFactory-PP534MBQ.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-7EISSMFP.js +0 -617
- package/dist/chunk-7EISSMFP.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-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-DIOS6L7M.js +0 -690
- package/dist/chunk-DIOS6L7M.js.map +0 -1
- package/dist/chunk-DJNHR37J.js +0 -1185
- package/dist/chunk-DJNHR37J.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-E6OAFS7A.js +0 -1346
- package/dist/chunk-E6OAFS7A.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-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-JVMAQOA3.js +0 -521
- package/dist/chunk-JVMAQOA3.js.map +0 -1
- package/dist/chunk-K56L7NUR.js +0 -1444
- package/dist/chunk-K56L7NUR.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-O2JMZHNH.js +0 -1908
- package/dist/chunk-O2JMZHNH.js.map +0 -1
- package/dist/chunk-OBBCR6WY.js +0 -277
- package/dist/chunk-OBBCR6WY.js.map +0 -1
- package/dist/chunk-OBZQ4AJC.js +0 -272
- package/dist/chunk-OBZQ4AJC.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-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-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
package/dist/chunk-OXNCBE7P.js
DELETED
|
@@ -1,971 +0,0 @@
|
|
|
1
|
-
import { GatewayError } from './chunk-QWNNFE4P.js';
|
|
2
|
-
import { __export, __name } from './chunk-XE4OXN2W.js';
|
|
3
|
-
import { createHash } from 'crypto';
|
|
4
|
-
|
|
5
|
-
// src/files/index.ts
|
|
6
|
-
var files_exports = {};
|
|
7
|
-
__export(files_exports, {
|
|
8
|
-
FILES_CLIENT_GRAPHQL_CODES: () => FILES_CLIENT_GRAPHQL_CODES,
|
|
9
|
-
FILE_ACTOR_TYPES: () => FILE_ACTOR_TYPES,
|
|
10
|
-
FILE_REFERENCE_KIND: () => FILE_REFERENCE_KIND,
|
|
11
|
-
FILE_VISIBILITIES: () => FILE_VISIBILITIES,
|
|
12
|
-
FilesClient: () => FilesClient,
|
|
13
|
-
FilesClientError: () => FilesClientError,
|
|
14
|
-
MAX_DOWNLOAD_URL_TTL_SECONDS: () => MAX_DOWNLOAD_URL_TTL_SECONDS,
|
|
15
|
-
MIN_DOWNLOAD_URL_TTL_SECONDS: () => MIN_DOWNLOAD_URL_TTL_SECONDS,
|
|
16
|
-
clampDownloadUrlTtl: () => clampDownloadUrlTtl,
|
|
17
|
-
classifyFilesErrors: () => classifyFilesErrors,
|
|
18
|
-
fileExtensionOf: () => fileExtensionOf,
|
|
19
|
-
isFileReference: () => isFileReference,
|
|
20
|
-
isFilesClientError: () => isFilesClientError,
|
|
21
|
-
mapFileMetadata: () => mapFileMetadata,
|
|
22
|
-
toFileReference: () => toFileReference,
|
|
23
|
-
toFilesClientError: () => toFilesClientError
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// src/files/types.ts
|
|
27
|
-
var FILE_ACTOR_TYPES = [
|
|
28
|
-
"user",
|
|
29
|
-
"app",
|
|
30
|
-
"service",
|
|
31
|
-
"super_admin"
|
|
32
|
-
];
|
|
33
|
-
var FILE_VISIBILITIES = [
|
|
34
|
-
"PRIVATE",
|
|
35
|
-
"PUBLIC",
|
|
36
|
-
"TEAM",
|
|
37
|
-
"WORKSPACE"
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
// src/files/errors.ts
|
|
41
|
-
var FILES_CLIENT_GRAPHQL_CODES = {
|
|
42
|
-
INVALID_INPUT: "BAD_USER_INPUT",
|
|
43
|
-
MISSING_CONTEXT: "UNAUTHENTICATED",
|
|
44
|
-
// Never FORBIDDEN: a file the actor cannot see must be indistinguishable from one that does not exist.
|
|
45
|
-
NOT_FOUND: "NOT_FOUND",
|
|
46
|
-
QUOTA_EXCEEDED: "QUOTA_EXCEEDED",
|
|
47
|
-
TOO_LARGE: "BAD_USER_INPUT",
|
|
48
|
-
STORAGE_ERROR: "INTERNAL_SERVER_ERROR",
|
|
49
|
-
UPSTREAM_ERROR: "INTERNAL_SERVER_ERROR",
|
|
50
|
-
CONFIGURATION_ERROR: "INTERNAL_SERVER_ERROR"
|
|
51
|
-
};
|
|
52
|
-
var FilesClientError = class extends Error {
|
|
53
|
-
static {
|
|
54
|
-
__name(this, "FilesClientError");
|
|
55
|
-
}
|
|
56
|
-
code;
|
|
57
|
-
details;
|
|
58
|
-
constructor(code, message, details = {}) {
|
|
59
|
-
super(message);
|
|
60
|
-
this.name = "FilesClientError";
|
|
61
|
-
this.code = code;
|
|
62
|
-
this.details = details;
|
|
63
|
-
}
|
|
64
|
-
/** The GraphQL `extensions.code` this error maps to. */
|
|
65
|
-
get graphqlCode() {
|
|
66
|
-
return FILES_CLIENT_GRAPHQL_CODES[this.code];
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
function isFilesClientError(error) {
|
|
70
|
-
return error instanceof FilesClientError;
|
|
71
|
-
}
|
|
72
|
-
__name(isFilesClientError, "isFilesClientError");
|
|
73
|
-
var NOT_FOUND_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
74
|
-
"NOT_FOUND",
|
|
75
|
-
"FORBIDDEN"
|
|
76
|
-
]);
|
|
77
|
-
var QUOTA_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
78
|
-
"QUOTA_EXCEEDED",
|
|
79
|
-
"QUOTA_EXHAUSTED",
|
|
80
|
-
"USAGE_LIMIT_EXCEEDED"
|
|
81
|
-
]);
|
|
82
|
-
var INVALID_UPSTREAM_CODES = /* @__PURE__ */ new Set([
|
|
83
|
-
"BAD_USER_INPUT",
|
|
84
|
-
"EXPIRED"
|
|
85
|
-
]);
|
|
86
|
-
function upstreamCode(error) {
|
|
87
|
-
const code = error.extensions?.["code"];
|
|
88
|
-
return typeof code === "string" ? code : null;
|
|
89
|
-
}
|
|
90
|
-
__name(upstreamCode, "upstreamCode");
|
|
91
|
-
function classifyFilesErrors(errors) {
|
|
92
|
-
const codes = errors.map(upstreamCode).filter((code) => code !== null);
|
|
93
|
-
if (codes.some((code) => QUOTA_UPSTREAM_CODES.has(code))) return "QUOTA_EXCEEDED";
|
|
94
|
-
if (codes.some((code) => NOT_FOUND_UPSTREAM_CODES.has(code))) return "NOT_FOUND";
|
|
95
|
-
if (codes.some((code) => INVALID_UPSTREAM_CODES.has(code))) return "INVALID_INPUT";
|
|
96
|
-
return "UPSTREAM_ERROR";
|
|
97
|
-
}
|
|
98
|
-
__name(classifyFilesErrors, "classifyFilesErrors");
|
|
99
|
-
function toFilesClientError(error, operation) {
|
|
100
|
-
if (error instanceof FilesClientError) return error;
|
|
101
|
-
if (error instanceof GatewayError) {
|
|
102
|
-
const graphqlErrors = error.graphqlErrors ?? [];
|
|
103
|
-
const code = graphqlErrors.length > 0 ? classifyFilesErrors(graphqlErrors) : "UPSTREAM_ERROR";
|
|
104
|
-
return new FilesClientError(code, `wspace-files-svc ${operation} failed: ${error.message}`, {
|
|
105
|
-
operation,
|
|
106
|
-
gatewayErrorType: error.type,
|
|
107
|
-
statusCode: error.statusCode,
|
|
108
|
-
errors: graphqlErrors.map((graphqlError) => ({
|
|
109
|
-
message: graphqlError.message,
|
|
110
|
-
code: upstreamCode(graphqlError)
|
|
111
|
-
}))
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
115
|
-
return new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} failed: ${message}`, {
|
|
116
|
-
operation
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
__name(toFilesClientError, "toFilesClientError");
|
|
120
|
-
var MIB = 1024 * 1024;
|
|
121
|
-
var MAX_DOWNLOAD_URL_TTL_SECONDS = 604800;
|
|
122
|
-
var MIN_DOWNLOAD_URL_TTL_SECONDS = 60;
|
|
123
|
-
var DEFAULT_REQUEST_TIMEOUT_MS = 15e3;
|
|
124
|
-
var DEFAULT_TRANSFER_TIMEOUT_MS = 12e4;
|
|
125
|
-
var DEFAULT_MAX_UPLOAD_BYTES = 100 * MIB;
|
|
126
|
-
var DEFAULT_MAX_DOWNLOAD_BYTES = 25 * MIB;
|
|
127
|
-
var DEFAULT_DOWNLOAD_URL_TTL_SECONDS = 3600;
|
|
128
|
-
var INTERNAL_DOWNLOAD_URL_TTL_SECONDS = 300;
|
|
129
|
-
var PART_URL_BATCH_SIZE = 20;
|
|
130
|
-
var SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
131
|
-
var FILE_FIELDS = "id name mimeType extension size status visibility workspaceId folderId uploadedById description sha256Hash createdAt updatedAt canRead canDelete";
|
|
132
|
-
var INITIATE_UPLOAD = `mutation FilesClientInitiateUpload($input: InitiateUploadInput!) {
|
|
133
|
-
initiateUpload(input: $input) {
|
|
134
|
-
uploadUrl
|
|
135
|
-
session { id uploadType partSize totalParts fileSize expiresAt }
|
|
136
|
-
}
|
|
137
|
-
}`;
|
|
138
|
-
var PART_URLS = `query FilesClientPartUploadUrls($sessionId: ID!, $partNumbers: [Int!]!) {
|
|
139
|
-
getBatchPartUploadUrls(sessionId: $sessionId, partNumbers: $partNumbers) { partNumber url }
|
|
140
|
-
}`;
|
|
141
|
-
var REGISTER_PART = `mutation FilesClientRegisterUploadedPart($input: UploadPartInput!) {
|
|
142
|
-
registerUploadedPart(input: $input) { session { id uploadedParts } }
|
|
143
|
-
}`;
|
|
144
|
-
var COMPLETE_UPLOAD = `mutation FilesClientCompleteUpload($input: CompleteUploadInput!) {
|
|
145
|
-
completeUpload(input: $input) { fileId file { id name mimeType size workspaceId sha256Hash } }
|
|
146
|
-
}`;
|
|
147
|
-
var ABORT_UPLOAD = `mutation FilesClientAbortUpload($sessionId: ID!) { abortUpload(sessionId: $sessionId) }`;
|
|
148
|
-
var GET_FILE = `query FilesClientGetFile($id: ID!) { getFile(id: $id) { ${FILE_FIELDS} } }`;
|
|
149
|
-
var GET_DOWNLOAD_URL = `query FilesClientGetFileDownloadUrl($id: ID!, $expiresIn: Int) {
|
|
150
|
-
getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
|
|
151
|
-
}`;
|
|
152
|
-
var RESOLVE_FOR_DOWNLOAD = `query FilesClientResolveForDownload($id: ID!, $expiresIn: Int) {
|
|
153
|
-
getFile(id: $id) { ${FILE_FIELDS} }
|
|
154
|
-
getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
|
|
155
|
-
}`;
|
|
156
|
-
var DELETE_FILE = `mutation FilesClientDeleteFile($id: ID!) { deleteFile(id: $id) }`;
|
|
157
|
-
var PERMANENTLY_DELETE_FILE = `mutation FilesClientPermanentlyDeleteFile($id: ID!) { permanentlyDeleteFile(id: $id) }`;
|
|
158
|
-
function requireNonEmpty(value, field) {
|
|
159
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
160
|
-
if (!trimmed) {
|
|
161
|
-
throw new FilesClientError("INVALID_INPUT", `${field} is required`, {
|
|
162
|
-
field
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
return trimmed;
|
|
166
|
-
}
|
|
167
|
-
__name(requireNonEmpty, "requireNonEmpty");
|
|
168
|
-
function requirePositiveInteger(value, field) {
|
|
169
|
-
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
170
|
-
throw new FilesClientError("CONFIGURATION_ERROR", `${field} must be a positive integer`, {
|
|
171
|
-
field,
|
|
172
|
-
value
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return value;
|
|
176
|
-
}
|
|
177
|
-
__name(requirePositiveInteger, "requirePositiveInteger");
|
|
178
|
-
function toNumber(value, field) {
|
|
179
|
-
const parsed = typeof value === "number" ? value : Number(value);
|
|
180
|
-
if (!Number.isSafeInteger(parsed) || parsed < 0) {
|
|
181
|
-
throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc returned an invalid ${field}`, {
|
|
182
|
-
field,
|
|
183
|
-
value
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return parsed;
|
|
187
|
-
}
|
|
188
|
-
__name(toNumber, "toNumber");
|
|
189
|
-
function toDate(value) {
|
|
190
|
-
if (!value) return null;
|
|
191
|
-
const date = new Date(value);
|
|
192
|
-
return Number.isNaN(date.getTime()) ? null : date;
|
|
193
|
-
}
|
|
194
|
-
__name(toDate, "toDate");
|
|
195
|
-
function toBytes(data) {
|
|
196
|
-
if (data instanceof ArrayBuffer) return new Uint8Array(data);
|
|
197
|
-
const { buffer } = data;
|
|
198
|
-
if (buffer instanceof ArrayBuffer) return new Uint8Array(buffer, data.byteOffset, data.byteLength);
|
|
199
|
-
return new Uint8Array(data);
|
|
200
|
-
}
|
|
201
|
-
__name(toBytes, "toBytes");
|
|
202
|
-
function fileExtensionOf(fileName) {
|
|
203
|
-
const base = fileName.trim().split(/[\\/]/).pop() ?? "";
|
|
204
|
-
const dot = base.lastIndexOf(".");
|
|
205
|
-
if (dot <= 0 || dot === base.length - 1) return "bin";
|
|
206
|
-
const extension = base.slice(dot + 1).toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
207
|
-
return extension || "bin";
|
|
208
|
-
}
|
|
209
|
-
__name(fileExtensionOf, "fileExtensionOf");
|
|
210
|
-
function clampDownloadUrlTtl(seconds, fallback) {
|
|
211
|
-
const value = seconds === null || seconds === void 0 || !Number.isFinite(seconds) ? fallback : seconds;
|
|
212
|
-
return Math.min(Math.max(Math.trunc(value), MIN_DOWNLOAD_URL_TTL_SECONDS), MAX_DOWNLOAD_URL_TTL_SECONDS);
|
|
213
|
-
}
|
|
214
|
-
__name(clampDownloadUrlTtl, "clampDownloadUrlTtl");
|
|
215
|
-
function isHttpUrl(value) {
|
|
216
|
-
if (typeof value !== "string" || value.length === 0) return false;
|
|
217
|
-
try {
|
|
218
|
-
const { protocol } = new URL(value);
|
|
219
|
-
return protocol === "https:" || protocol === "http:";
|
|
220
|
-
} catch {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
__name(isHttpUrl, "isHttpUrl");
|
|
225
|
-
function normalizeSha256(value) {
|
|
226
|
-
if (value === null || value === void 0 || value.trim() === "") return null;
|
|
227
|
-
const normalized = value.trim().toLowerCase();
|
|
228
|
-
if (!SHA256_HEX.test(normalized)) {
|
|
229
|
-
throw new FilesClientError("INVALID_INPUT", "sha256Hash must be 64 hex characters", {
|
|
230
|
-
field: "sha256Hash"
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
return normalized;
|
|
234
|
-
}
|
|
235
|
-
__name(normalizeSha256, "normalizeSha256");
|
|
236
|
-
function normalizeUploadedParts(parts) {
|
|
237
|
-
const seen = /* @__PURE__ */ new Set();
|
|
238
|
-
const normalized = parts.map((part) => {
|
|
239
|
-
const etag = typeof part.etag === "string" ? part.etag.trim() : "";
|
|
240
|
-
if (!Number.isSafeInteger(part.partNumber) || part.partNumber <= 0 || seen.has(part.partNumber) || !etag) {
|
|
241
|
-
throw new FilesClientError("INVALID_INPUT", "parts must have unique positive part numbers and an ETag", {
|
|
242
|
-
field: "parts",
|
|
243
|
-
partNumber: part.partNumber
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
seen.add(part.partNumber);
|
|
247
|
-
return {
|
|
248
|
-
partNumber: part.partNumber,
|
|
249
|
-
etag
|
|
250
|
-
};
|
|
251
|
-
});
|
|
252
|
-
return normalized.sort((a, b) => a.partNumber - b.partNumber);
|
|
253
|
-
}
|
|
254
|
-
__name(normalizeUploadedParts, "normalizeUploadedParts");
|
|
255
|
-
function mapFileMetadata(raw) {
|
|
256
|
-
return {
|
|
257
|
-
id: raw.id,
|
|
258
|
-
name: raw.name,
|
|
259
|
-
mimeType: raw.mimeType,
|
|
260
|
-
extension: raw.extension,
|
|
261
|
-
size: toNumber(raw.size, "size"),
|
|
262
|
-
status: raw.status,
|
|
263
|
-
visibility: raw.visibility,
|
|
264
|
-
workspaceId: raw.workspaceId,
|
|
265
|
-
folderId: raw.folderId ?? null,
|
|
266
|
-
uploadedById: raw.uploadedById,
|
|
267
|
-
description: raw.description ?? null,
|
|
268
|
-
sha256Hash: raw.sha256Hash ?? null,
|
|
269
|
-
createdAt: toDate(raw.createdAt),
|
|
270
|
-
updatedAt: toDate(raw.updatedAt),
|
|
271
|
-
canRead: raw.canRead ?? null,
|
|
272
|
-
canDelete: raw.canDelete ?? null
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
__name(mapFileMetadata, "mapFileMetadata");
|
|
276
|
-
var FilesClient = class {
|
|
277
|
-
static {
|
|
278
|
-
__name(this, "FilesClient");
|
|
279
|
-
}
|
|
280
|
-
clientOption;
|
|
281
|
-
serviceName;
|
|
282
|
-
fetchImpl;
|
|
283
|
-
requestTimeoutMs;
|
|
284
|
-
transferTimeoutMs;
|
|
285
|
-
maxUploadBytes;
|
|
286
|
-
maxDownloadBytes;
|
|
287
|
-
defaultDownloadUrlTtlSeconds;
|
|
288
|
-
clientPromise = null;
|
|
289
|
-
constructor(options = {}) {
|
|
290
|
-
this.clientOption = options.client;
|
|
291
|
-
this.serviceName = options.serviceName;
|
|
292
|
-
this.fetchImpl = options.fetch ?? ((url, init) => fetch(url, init));
|
|
293
|
-
this.requestTimeoutMs = requirePositiveInteger(options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS, "requestTimeoutMs");
|
|
294
|
-
this.transferTimeoutMs = requirePositiveInteger(options.transferTimeoutMs ?? DEFAULT_TRANSFER_TIMEOUT_MS, "transferTimeoutMs");
|
|
295
|
-
this.maxUploadBytes = requirePositiveInteger(options.maxUploadBytes ?? DEFAULT_MAX_UPLOAD_BYTES, "maxUploadBytes");
|
|
296
|
-
this.maxDownloadBytes = requirePositiveInteger(options.maxDownloadBytes ?? DEFAULT_MAX_DOWNLOAD_BYTES, "maxDownloadBytes");
|
|
297
|
-
const ttl = options.defaultDownloadUrlTtlSeconds ?? DEFAULT_DOWNLOAD_URL_TTL_SECONDS;
|
|
298
|
-
if (!Number.isSafeInteger(ttl) || ttl < MIN_DOWNLOAD_URL_TTL_SECONDS || ttl > MAX_DOWNLOAD_URL_TTL_SECONDS) {
|
|
299
|
-
throw new FilesClientError("CONFIGURATION_ERROR", `defaultDownloadUrlTtlSeconds must be between ${MIN_DOWNLOAD_URL_TTL_SECONDS} and ${MAX_DOWNLOAD_URL_TTL_SECONDS}`, {
|
|
300
|
-
value: ttl
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
this.defaultDownloadUrlTtlSeconds = ttl;
|
|
304
|
-
}
|
|
305
|
-
// ── Upload ────────────────────────────────────────────────────────────
|
|
306
|
-
/**
|
|
307
|
-
* Store bytes in the actor's workspace file library and return the File's id.
|
|
308
|
-
* Throws {@link FilesClientError}; on any failure after the session was opened
|
|
309
|
-
* the session is aborted so no half-uploaded object is left behind.
|
|
310
|
-
*/
|
|
311
|
-
async uploadFile(input, actor) {
|
|
312
|
-
const context = this.requireActor(actor);
|
|
313
|
-
const fileName = requireNonEmpty(input.fileName, "fileName");
|
|
314
|
-
const mimeType = requireNonEmpty(input.mimeType, "mimeType");
|
|
315
|
-
const bytes = toBytes(input.data);
|
|
316
|
-
if (bytes.byteLength === 0) {
|
|
317
|
-
throw new FilesClientError("INVALID_INPUT", "data must not be empty", {
|
|
318
|
-
field: "data"
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
if (bytes.byteLength > this.maxUploadBytes) {
|
|
322
|
-
throw new FilesClientError("TOO_LARGE", `File is larger than ${this.maxUploadBytes} bytes`, {
|
|
323
|
-
size: bytes.byteLength,
|
|
324
|
-
maxBytes: this.maxUploadBytes
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
if (input.visibility !== void 0 && !FILE_VISIBILITIES.includes(input.visibility)) {
|
|
328
|
-
throw new FilesClientError("INVALID_INPUT", `Unknown file visibility "${String(input.visibility)}"`, {
|
|
329
|
-
field: "visibility"
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
const extension = input.extension?.trim() ? input.extension.trim().replace(/^\./, "").toLowerCase() : fileExtensionOf(fileName);
|
|
333
|
-
const fileSize = String(bytes.byteLength);
|
|
334
|
-
const sha256Hash = input.declareSha256 === false ? null : createHash("sha256").update(bytes).digest("hex");
|
|
335
|
-
const folderId = input.folderId?.trim() || void 0;
|
|
336
|
-
const initiated = await this.request("initiateUpload", INITIATE_UPLOAD, {
|
|
337
|
-
input: {
|
|
338
|
-
fileName,
|
|
339
|
-
fileSize,
|
|
340
|
-
mimeType,
|
|
341
|
-
extension,
|
|
342
|
-
...folderId ? {
|
|
343
|
-
folderId
|
|
344
|
-
} : {},
|
|
345
|
-
...input.visibility ? {
|
|
346
|
-
visibility: input.visibility
|
|
347
|
-
} : {},
|
|
348
|
-
...sha256Hash ? {
|
|
349
|
-
sha256Hash
|
|
350
|
-
} : {}
|
|
351
|
-
}
|
|
352
|
-
}, context);
|
|
353
|
-
const rawSession = initiated.initiateUpload?.session;
|
|
354
|
-
if (!rawSession?.id) {
|
|
355
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no session");
|
|
356
|
-
}
|
|
357
|
-
const session = {
|
|
358
|
-
id: rawSession.id,
|
|
359
|
-
uploadType: rawSession.uploadType,
|
|
360
|
-
partSize: toNumber(rawSession.partSize, "partSize"),
|
|
361
|
-
totalParts: toNumber(rawSession.totalParts, "totalParts")
|
|
362
|
-
};
|
|
363
|
-
try {
|
|
364
|
-
if (session.uploadType === "MULTIPART") {
|
|
365
|
-
await this.uploadParts(session, bytes, context);
|
|
366
|
-
} else {
|
|
367
|
-
await this.putDirect(initiated.initiateUpload?.uploadUrl, bytes, mimeType);
|
|
368
|
-
}
|
|
369
|
-
return await this.completeSession(session.id, {
|
|
370
|
-
fileSize,
|
|
371
|
-
fallbackName: fileName,
|
|
372
|
-
fallbackMimeType: mimeType,
|
|
373
|
-
fallbackSize: bytes.byteLength,
|
|
374
|
-
sha256Hash,
|
|
375
|
-
folderId,
|
|
376
|
-
description: input.description ?? null
|
|
377
|
-
}, context);
|
|
378
|
-
} catch (error) {
|
|
379
|
-
await this.abortQuietly(session.id, context);
|
|
380
|
-
throw toFilesClientError(error, "uploadFile");
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
// ── Delegated upload ──────────────────────────────────────────────────
|
|
384
|
-
/**
|
|
385
|
-
* Open a files-svc upload session on the actor's behalf for bytes that
|
|
386
|
-
* someone else holds (an agent, a CLI, a browser), and return the presigned
|
|
387
|
-
* URL(s) to hand them. The uploader PUTs the bytes — one PUT to `uploadUrl`
|
|
388
|
-
* for DIRECT, one PUT per `parts` entry for MULTIPART (files-svc picks
|
|
389
|
-
* MULTIPART above 5 MiB) — and the service then calls
|
|
390
|
-
* {@link completeUploadSession} with the same `fileSize` (and the part ETags)
|
|
391
|
-
* to turn the session into a File. The service never sees the bytes and never
|
|
392
|
-
* holds storage credentials.
|
|
393
|
-
*
|
|
394
|
-
* Throws {@link FilesClientError}. If files-svc opened the session but the
|
|
395
|
-
* client cannot hand it out (an unsupported upload type, missing part URLs),
|
|
396
|
-
* the session is aborted before the error is thrown.
|
|
397
|
-
*/
|
|
398
|
-
async createUploadSession(input, actor) {
|
|
399
|
-
const context = this.requireActor(actor);
|
|
400
|
-
const fileName = requireNonEmpty(input.fileName, "fileName");
|
|
401
|
-
const mimeType = requireNonEmpty(input.mimeType, "mimeType");
|
|
402
|
-
if (!Number.isSafeInteger(input.fileSize) || input.fileSize <= 0) {
|
|
403
|
-
throw new FilesClientError("INVALID_INPUT", "fileSize must be a positive integer", {
|
|
404
|
-
field: "fileSize"
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
if (input.fileSize > this.maxUploadBytes) {
|
|
408
|
-
throw new FilesClientError("TOO_LARGE", `File is larger than ${this.maxUploadBytes} bytes`, {
|
|
409
|
-
size: input.fileSize,
|
|
410
|
-
maxBytes: this.maxUploadBytes
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
if (input.visibility !== void 0 && !FILE_VISIBILITIES.includes(input.visibility)) {
|
|
414
|
-
throw new FilesClientError("INVALID_INPUT", `Unknown file visibility "${String(input.visibility)}"`, {
|
|
415
|
-
field: "visibility"
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
const sha256Hash = normalizeSha256(input.sha256Hash);
|
|
419
|
-
const extension = input.extension?.trim() ? input.extension.trim().replace(/^\./, "").toLowerCase() : fileExtensionOf(fileName);
|
|
420
|
-
const folderId = input.folderId?.trim() || void 0;
|
|
421
|
-
const initiated = await this.request("initiateUpload", INITIATE_UPLOAD, {
|
|
422
|
-
input: {
|
|
423
|
-
fileName,
|
|
424
|
-
fileSize: String(input.fileSize),
|
|
425
|
-
mimeType,
|
|
426
|
-
extension,
|
|
427
|
-
...folderId ? {
|
|
428
|
-
folderId
|
|
429
|
-
} : {},
|
|
430
|
-
...input.visibility ? {
|
|
431
|
-
visibility: input.visibility
|
|
432
|
-
} : {},
|
|
433
|
-
...sha256Hash ? {
|
|
434
|
-
sha256Hash
|
|
435
|
-
} : {}
|
|
436
|
-
}
|
|
437
|
-
}, context);
|
|
438
|
-
const rawSession = initiated.initiateUpload?.session;
|
|
439
|
-
if (!rawSession?.id) {
|
|
440
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no session");
|
|
441
|
-
}
|
|
442
|
-
try {
|
|
443
|
-
const partSize = toNumber(rawSession.partSize, "partSize");
|
|
444
|
-
const totalParts = toNumber(rawSession.totalParts, "totalParts");
|
|
445
|
-
const base = {
|
|
446
|
-
sessionId: rawSession.id,
|
|
447
|
-
partSize,
|
|
448
|
-
totalParts,
|
|
449
|
-
fileSize: input.fileSize,
|
|
450
|
-
sha256Hash,
|
|
451
|
-
expiresAt: toDate(rawSession.expiresAt)
|
|
452
|
-
};
|
|
453
|
-
if (rawSession.uploadType === "MULTIPART") {
|
|
454
|
-
const session = {
|
|
455
|
-
id: rawSession.id,
|
|
456
|
-
uploadType: "MULTIPART",
|
|
457
|
-
partSize,
|
|
458
|
-
totalParts
|
|
459
|
-
};
|
|
460
|
-
this.assertMultipartPlan(session, input.fileSize);
|
|
461
|
-
const parts = await this.presignParts(session, input.fileSize, context);
|
|
462
|
-
return {
|
|
463
|
-
...base,
|
|
464
|
-
uploadType: "MULTIPART",
|
|
465
|
-
uploadUrl: null,
|
|
466
|
-
requiredHeaders: {},
|
|
467
|
-
parts
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
if (rawSession.uploadType !== "DIRECT") {
|
|
471
|
-
throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc opened an unsupported ${String(rawSession.uploadType)} session`, {
|
|
472
|
-
sessionId: rawSession.id
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
const uploadUrl = initiated.initiateUpload?.uploadUrl;
|
|
476
|
-
if (!isHttpUrl(uploadUrl)) {
|
|
477
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no upload URL", {
|
|
478
|
-
sessionId: rawSession.id
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
return {
|
|
482
|
-
...base,
|
|
483
|
-
uploadType: "DIRECT",
|
|
484
|
-
uploadUrl,
|
|
485
|
-
requiredHeaders: {
|
|
486
|
-
"Content-Type": mimeType
|
|
487
|
-
},
|
|
488
|
-
parts: []
|
|
489
|
-
};
|
|
490
|
-
} catch (error) {
|
|
491
|
-
await this.abortQuietly(rawSession.id, context);
|
|
492
|
-
throw toFilesClientError(error, "createUploadSession");
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Turn a session opened by {@link createUploadSession} into a File once the
|
|
497
|
-
* uploader has PUT the bytes: registers the MULTIPART part ETags, then runs
|
|
498
|
-
* `completeUpload` with the declared size (and SHA-256). files-svc verifies
|
|
499
|
-
* the stored object; a size or checksum mismatch surfaces as `INVALID_INPUT`.
|
|
500
|
-
* The session is left open on failure so the caller can retry or
|
|
501
|
-
* {@link abortUploadSession} it.
|
|
502
|
-
*/
|
|
503
|
-
async completeUploadSession(sessionId, input, actor) {
|
|
504
|
-
const context = this.requireActor(actor);
|
|
505
|
-
const id = requireNonEmpty(sessionId, "sessionId");
|
|
506
|
-
if (!Number.isSafeInteger(input.fileSize) || input.fileSize <= 0) {
|
|
507
|
-
throw new FilesClientError("INVALID_INPUT", "fileSize must be a positive integer", {
|
|
508
|
-
field: "fileSize"
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
const sha256Hash = normalizeSha256(input.sha256Hash);
|
|
512
|
-
const parts = normalizeUploadedParts(input.parts ?? []);
|
|
513
|
-
const folderId = input.folderId?.trim() || void 0;
|
|
514
|
-
for (const part of parts) {
|
|
515
|
-
await this.request("registerUploadedPart", REGISTER_PART, {
|
|
516
|
-
input: {
|
|
517
|
-
sessionId: id,
|
|
518
|
-
partNumber: part.partNumber,
|
|
519
|
-
etag: part.etag
|
|
520
|
-
}
|
|
521
|
-
}, context);
|
|
522
|
-
}
|
|
523
|
-
return this.completeSession(id, {
|
|
524
|
-
fileSize: String(input.fileSize),
|
|
525
|
-
fallbackName: "",
|
|
526
|
-
fallbackMimeType: "",
|
|
527
|
-
fallbackSize: input.fileSize,
|
|
528
|
-
sha256Hash,
|
|
529
|
-
folderId,
|
|
530
|
-
description: input.description ?? null
|
|
531
|
-
}, context);
|
|
532
|
-
}
|
|
533
|
-
/** Abandon a session opened by {@link createUploadSession}. `true` when files-svc aborted it. */
|
|
534
|
-
async abortUploadSession(sessionId, actor) {
|
|
535
|
-
const id = requireNonEmpty(sessionId, "sessionId");
|
|
536
|
-
const data = await this.request("abortUpload", ABORT_UPLOAD, {
|
|
537
|
-
sessionId: id
|
|
538
|
-
}, actor);
|
|
539
|
-
return data.abortUpload === true;
|
|
540
|
-
}
|
|
541
|
-
// ── Read ──────────────────────────────────────────────────────────────
|
|
542
|
-
/** File metadata, or `null` when it does not exist or the actor cannot see it. */
|
|
543
|
-
async getFile(fileId, actor) {
|
|
544
|
-
const id = requireNonEmpty(fileId, "fileId");
|
|
545
|
-
try {
|
|
546
|
-
const data = await this.request("getFile", GET_FILE, {
|
|
547
|
-
id
|
|
548
|
-
}, actor);
|
|
549
|
-
return data.getFile ? mapFileMetadata(data.getFile) : null;
|
|
550
|
-
} catch (error) {
|
|
551
|
-
if (error instanceof FilesClientError && error.code === "NOT_FOUND") return null;
|
|
552
|
-
throw error;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Prove that an opaque file id the caller supplied names a File in the actor's
|
|
557
|
-
* workspace that they may read, before the service stores or acts on it.
|
|
558
|
-
* Throws `NOT_FOUND` (never a permission error) otherwise.
|
|
559
|
-
*/
|
|
560
|
-
async requireFile(fileId, actor, options = {}) {
|
|
561
|
-
const context = this.requireActor(actor);
|
|
562
|
-
const file = await this.getFile(fileId, context);
|
|
563
|
-
this.assertUsable(file, fileId, context, options);
|
|
564
|
-
return file;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* A presigned download URL for the file, minted for the actor. Mint it when the
|
|
568
|
-
* user opens the file; never persist it. The lifetime is clamped to
|
|
569
|
-
* [60, 604800] seconds.
|
|
570
|
-
*/
|
|
571
|
-
async getDownloadUrl(fileId, actor, options = {}) {
|
|
572
|
-
const id = requireNonEmpty(fileId, "fileId");
|
|
573
|
-
const expiresIn = clampDownloadUrlTtl(options.expiresInSeconds, this.defaultDownloadUrlTtlSeconds);
|
|
574
|
-
const data = await this.request("getFileDownloadUrl", GET_DOWNLOAD_URL, {
|
|
575
|
-
id,
|
|
576
|
-
expiresIn
|
|
577
|
-
}, actor);
|
|
578
|
-
if (!isHttpUrl(data.getFileDownloadUrl)) {
|
|
579
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc returned no usable download URL", {
|
|
580
|
-
fileId: id
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
return data.getFileDownloadUrl;
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* Fetch the file's bytes for server-side processing (vision models, parsers,
|
|
587
|
-
* workflow nodes). Checks the file is active, readable by the actor and within
|
|
588
|
-
* `maxBytes` before downloading, and verifies the downloaded size.
|
|
589
|
-
*/
|
|
590
|
-
async downloadFile(fileId, actor, options = {}) {
|
|
591
|
-
const context = this.requireActor(actor);
|
|
592
|
-
const id = requireNonEmpty(fileId, "fileId");
|
|
593
|
-
const maxBytes = options.maxBytes ?? this.maxDownloadBytes;
|
|
594
|
-
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
|
|
595
|
-
throw new FilesClientError("INVALID_INPUT", "maxBytes must be a positive integer", {
|
|
596
|
-
field: "maxBytes"
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
const data = await this.request("downloadFile", RESOLVE_FOR_DOWNLOAD, {
|
|
600
|
-
id,
|
|
601
|
-
expiresIn: INTERNAL_DOWNLOAD_URL_TTL_SECONDS
|
|
602
|
-
}, context);
|
|
603
|
-
const file = data.getFile ? mapFileMetadata(data.getFile) : null;
|
|
604
|
-
this.assertUsable(file, id, context, {});
|
|
605
|
-
if (file.size > maxBytes) {
|
|
606
|
-
throw new FilesClientError("TOO_LARGE", `File is larger than ${maxBytes} bytes`, {
|
|
607
|
-
fileId: id,
|
|
608
|
-
size: file.size,
|
|
609
|
-
maxBytes
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
const url = data.getFileDownloadUrl;
|
|
613
|
-
if (!isHttpUrl(url)) {
|
|
614
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc returned no usable download URL", {
|
|
615
|
-
fileId: id
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
const response = await this.transfer(url, {
|
|
619
|
-
method: "GET"
|
|
620
|
-
}, "download");
|
|
621
|
-
const bytes = await this.readBounded(response, maxBytes, id);
|
|
622
|
-
if (bytes.byteLength !== file.size) {
|
|
623
|
-
throw new FilesClientError("STORAGE_ERROR", "Downloaded size does not match the stored file size", {
|
|
624
|
-
fileId: id,
|
|
625
|
-
expected: file.size,
|
|
626
|
-
actual: bytes.byteLength
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
return {
|
|
630
|
-
bytes,
|
|
631
|
-
mimeType: file.mimeType,
|
|
632
|
-
name: file.name,
|
|
633
|
-
size: bytes.byteLength
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
/** {@link downloadFile} as base64, for payloads that must stay JSON (model inputs). */
|
|
637
|
-
async downloadFileAsBase64(fileId, actor, options = {}) {
|
|
638
|
-
const file = await this.downloadFile(fileId, actor, options);
|
|
639
|
-
return {
|
|
640
|
-
base64: Buffer.from(file.bytes).toString("base64"),
|
|
641
|
-
mimeType: file.mimeType,
|
|
642
|
-
name: file.name,
|
|
643
|
-
size: file.size
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
// ── Delete ────────────────────────────────────────────────────────────
|
|
647
|
-
/** Move the file to trash (or hard-delete with `permanent`). `true` when files-svc deleted it. */
|
|
648
|
-
async deleteFile(fileId, actor, options = {}) {
|
|
649
|
-
const id = requireNonEmpty(fileId, "fileId");
|
|
650
|
-
if (options.permanent) {
|
|
651
|
-
const data2 = await this.request("permanentlyDeleteFile", PERMANENTLY_DELETE_FILE, {
|
|
652
|
-
id
|
|
653
|
-
}, actor);
|
|
654
|
-
return data2.permanentlyDeleteFile === true;
|
|
655
|
-
}
|
|
656
|
-
const data = await this.request("deleteFile", DELETE_FILE, {
|
|
657
|
-
id
|
|
658
|
-
}, actor);
|
|
659
|
-
return data.deleteFile === true;
|
|
660
|
-
}
|
|
661
|
-
// ── Upload legs ───────────────────────────────────────────────────────
|
|
662
|
-
async putDirect(uploadUrl, bytes, mimeType) {
|
|
663
|
-
if (!isHttpUrl(uploadUrl)) {
|
|
664
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc initiateUpload returned no upload URL");
|
|
665
|
-
}
|
|
666
|
-
await this.transfer(uploadUrl, {
|
|
667
|
-
method: "PUT",
|
|
668
|
-
body: bytes,
|
|
669
|
-
headers: {
|
|
670
|
-
"Content-Type": mimeType
|
|
671
|
-
}
|
|
672
|
-
}, "upload");
|
|
673
|
-
}
|
|
674
|
-
async uploadParts(session, bytes, actor) {
|
|
675
|
-
this.assertMultipartPlan(session, bytes.byteLength);
|
|
676
|
-
for (let first = 1; first <= session.totalParts; first += PART_URL_BATCH_SIZE) {
|
|
677
|
-
const partNumbers = [];
|
|
678
|
-
for (let part = first; part < first + PART_URL_BATCH_SIZE && part <= session.totalParts; part += 1) {
|
|
679
|
-
partNumbers.push(part);
|
|
680
|
-
}
|
|
681
|
-
const data = await this.request("getBatchPartUploadUrls", PART_URLS, {
|
|
682
|
-
sessionId: session.id,
|
|
683
|
-
partNumbers
|
|
684
|
-
}, actor);
|
|
685
|
-
const urls = new Map((data.getBatchPartUploadUrls ?? []).map((entry) => [
|
|
686
|
-
entry.partNumber,
|
|
687
|
-
entry.url
|
|
688
|
-
]));
|
|
689
|
-
for (const partNumber of partNumbers) {
|
|
690
|
-
const url = urls.get(partNumber);
|
|
691
|
-
if (!isHttpUrl(url)) {
|
|
692
|
-
throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc returned no URL for part ${partNumber}`, {
|
|
693
|
-
sessionId: session.id,
|
|
694
|
-
partNumber
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
const start = (partNumber - 1) * session.partSize;
|
|
698
|
-
const body = bytes.subarray(start, Math.min(start + session.partSize, bytes.byteLength));
|
|
699
|
-
const response = await this.transfer(url, {
|
|
700
|
-
method: "PUT",
|
|
701
|
-
body
|
|
702
|
-
}, "upload");
|
|
703
|
-
const etag = response.headers.get("etag");
|
|
704
|
-
if (!etag) {
|
|
705
|
-
throw new FilesClientError("STORAGE_ERROR", `Object storage returned no ETag for part ${partNumber}`, {
|
|
706
|
-
sessionId: session.id,
|
|
707
|
-
partNumber
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
await this.request("registerUploadedPart", REGISTER_PART, {
|
|
711
|
-
input: {
|
|
712
|
-
sessionId: session.id,
|
|
713
|
-
partNumber,
|
|
714
|
-
etag
|
|
715
|
-
}
|
|
716
|
-
}, actor);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
async completeSession(sessionId, args, actor) {
|
|
721
|
-
const completed = await this.request("completeUpload", COMPLETE_UPLOAD, {
|
|
722
|
-
input: {
|
|
723
|
-
sessionId,
|
|
724
|
-
fileSize: args.fileSize,
|
|
725
|
-
...args.folderId ? {
|
|
726
|
-
folderId: args.folderId
|
|
727
|
-
} : {},
|
|
728
|
-
...args.description ? {
|
|
729
|
-
description: args.description
|
|
730
|
-
} : {},
|
|
731
|
-
...args.sha256Hash ? {
|
|
732
|
-
sha256Hash: args.sha256Hash
|
|
733
|
-
} : {}
|
|
734
|
-
}
|
|
735
|
-
}, actor);
|
|
736
|
-
const file = completed.completeUpload?.file;
|
|
737
|
-
const fileId = completed.completeUpload?.fileId ?? file?.id;
|
|
738
|
-
if (!fileId) {
|
|
739
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc completeUpload returned no fileId", {
|
|
740
|
-
sessionId
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
return {
|
|
744
|
-
fileId,
|
|
745
|
-
name: file?.name ?? args.fallbackName,
|
|
746
|
-
mimeType: file?.mimeType ?? args.fallbackMimeType,
|
|
747
|
-
size: file ? toNumber(file.size, "size") : args.fallbackSize,
|
|
748
|
-
workspaceId: file?.workspaceId ?? actor.workspaceId,
|
|
749
|
-
sha256Hash: file?.sha256Hash ?? args.sha256Hash
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
assertMultipartPlan(session, size) {
|
|
753
|
-
if (session.partSize <= 0 || session.totalParts !== Math.ceil(size / session.partSize)) {
|
|
754
|
-
throw new FilesClientError("UPSTREAM_ERROR", "wspace-files-svc returned an inconsistent multipart plan", {
|
|
755
|
-
sessionId: session.id,
|
|
756
|
-
partSize: session.partSize,
|
|
757
|
-
totalParts: session.totalParts,
|
|
758
|
-
size
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
/** Presigned URL for every part, fetched in batches. */
|
|
763
|
-
async partUrls(session, actor) {
|
|
764
|
-
const urls = /* @__PURE__ */ new Map();
|
|
765
|
-
for (let first = 1; first <= session.totalParts; first += PART_URL_BATCH_SIZE) {
|
|
766
|
-
const partNumbers = [];
|
|
767
|
-
for (let part = first; part < first + PART_URL_BATCH_SIZE && part <= session.totalParts; part += 1) {
|
|
768
|
-
partNumbers.push(part);
|
|
769
|
-
}
|
|
770
|
-
const data = await this.request("getBatchPartUploadUrls", PART_URLS, {
|
|
771
|
-
sessionId: session.id,
|
|
772
|
-
partNumbers
|
|
773
|
-
}, actor);
|
|
774
|
-
for (const entry of data.getBatchPartUploadUrls ?? []) urls.set(entry.partNumber, entry.url);
|
|
775
|
-
}
|
|
776
|
-
return urls;
|
|
777
|
-
}
|
|
778
|
-
async presignParts(session, size, actor) {
|
|
779
|
-
const urls = await this.partUrls(session, actor);
|
|
780
|
-
const parts = [];
|
|
781
|
-
for (let partNumber = 1; partNumber <= session.totalParts; partNumber += 1) {
|
|
782
|
-
const url = urls.get(partNumber);
|
|
783
|
-
if (!isHttpUrl(url)) {
|
|
784
|
-
throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc returned no URL for part ${partNumber}`, {
|
|
785
|
-
sessionId: session.id,
|
|
786
|
-
partNumber
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
const offset = (partNumber - 1) * session.partSize;
|
|
790
|
-
parts.push({
|
|
791
|
-
partNumber,
|
|
792
|
-
url,
|
|
793
|
-
offset,
|
|
794
|
-
length: Math.min(session.partSize, size - offset)
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
return parts;
|
|
798
|
-
}
|
|
799
|
-
async abortQuietly(sessionId, actor) {
|
|
800
|
-
try {
|
|
801
|
-
await this.request("abortUpload", ABORT_UPLOAD, {
|
|
802
|
-
sessionId
|
|
803
|
-
}, actor);
|
|
804
|
-
} catch {
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
// ── Transport ─────────────────────────────────────────────────────────
|
|
808
|
-
assertUsable(file, fileId, actor, options) {
|
|
809
|
-
const requireActive = options.requireActive ?? true;
|
|
810
|
-
const requireReadable = options.requireReadable ?? true;
|
|
811
|
-
if (!file || file.id !== fileId.trim() || file.workspaceId !== actor.workspaceId || requireActive && file.status !== "ACTIVE" || requireReadable && file.canRead !== true) {
|
|
812
|
-
throw new FilesClientError("NOT_FOUND", "File not found", {
|
|
813
|
-
fileId
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
async transfer(url, init, leg) {
|
|
818
|
-
let response;
|
|
819
|
-
try {
|
|
820
|
-
response = await this.fetchImpl(url, {
|
|
821
|
-
...init,
|
|
822
|
-
signal: AbortSignal.timeout(this.transferTimeoutMs)
|
|
823
|
-
});
|
|
824
|
-
} catch (error) {
|
|
825
|
-
throw new FilesClientError("STORAGE_ERROR", `Object storage ${leg} failed`, {
|
|
826
|
-
leg,
|
|
827
|
-
cause: error instanceof Error ? error.message : String(error)
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
if (!response.ok) {
|
|
831
|
-
throw new FilesClientError("STORAGE_ERROR", `Object storage ${leg} failed with HTTP ${response.status}`, {
|
|
832
|
-
leg,
|
|
833
|
-
status: response.status
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
return response;
|
|
837
|
-
}
|
|
838
|
-
async readBounded(response, maxBytes, fileId) {
|
|
839
|
-
const tooLarge = /* @__PURE__ */ __name(() => new FilesClientError("TOO_LARGE", `File is larger than ${maxBytes} bytes`, {
|
|
840
|
-
fileId,
|
|
841
|
-
maxBytes
|
|
842
|
-
}), "tooLarge");
|
|
843
|
-
const declared = Number(response.headers.get("content-length") ?? Number.NaN);
|
|
844
|
-
if (Number.isFinite(declared) && declared > maxBytes) throw tooLarge();
|
|
845
|
-
if (!response.body) {
|
|
846
|
-
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
847
|
-
if (buffer.byteLength > maxBytes) throw tooLarge();
|
|
848
|
-
return buffer;
|
|
849
|
-
}
|
|
850
|
-
const reader = response.body.getReader();
|
|
851
|
-
const chunks = [];
|
|
852
|
-
let total = 0;
|
|
853
|
-
for (; ; ) {
|
|
854
|
-
const { done, value } = await reader.read();
|
|
855
|
-
if (done) break;
|
|
856
|
-
total += value.byteLength;
|
|
857
|
-
if (total > maxBytes) {
|
|
858
|
-
await reader.cancel();
|
|
859
|
-
throw tooLarge();
|
|
860
|
-
}
|
|
861
|
-
chunks.push(value);
|
|
862
|
-
}
|
|
863
|
-
const bytes = new Uint8Array(total);
|
|
864
|
-
let offset = 0;
|
|
865
|
-
for (const chunk of chunks) {
|
|
866
|
-
bytes.set(chunk, offset);
|
|
867
|
-
offset += chunk.byteLength;
|
|
868
|
-
}
|
|
869
|
-
return bytes;
|
|
870
|
-
}
|
|
871
|
-
requireActor(actor) {
|
|
872
|
-
if (!actor.actorId?.trim() || !actor.workspaceId?.trim()) {
|
|
873
|
-
throw new FilesClientError("MISSING_CONTEXT", "File operations need an authenticated actor and a workspace");
|
|
874
|
-
}
|
|
875
|
-
if (actor.actorType !== void 0 && !FILE_ACTOR_TYPES.includes(actor.actorType)) {
|
|
876
|
-
throw new FilesClientError("MISSING_CONTEXT", `Unknown actor type "${String(actor.actorType)}"`);
|
|
877
|
-
}
|
|
878
|
-
return actor;
|
|
879
|
-
}
|
|
880
|
-
getClient() {
|
|
881
|
-
if (!this.clientPromise) {
|
|
882
|
-
const option = this.clientOption;
|
|
883
|
-
this.clientPromise = (async () => {
|
|
884
|
-
try {
|
|
885
|
-
if (typeof option === "function") return await option();
|
|
886
|
-
if (option) return option;
|
|
887
|
-
const gateway = await import('./client-JU6T3UPB.js');
|
|
888
|
-
if (this.serviceName) {
|
|
889
|
-
return new gateway.GatewayClient({
|
|
890
|
-
layer: "wspace",
|
|
891
|
-
serviceName: this.serviceName,
|
|
892
|
-
serviceIdentity: this.serviceName
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
return gateway.createGatewayClientFromEnv();
|
|
896
|
-
} catch (error) {
|
|
897
|
-
throw new FilesClientError("CONFIGURATION_ERROR", "Files gateway client is not configured", {
|
|
898
|
-
cause: error instanceof Error ? error.message : String(error)
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
})();
|
|
902
|
-
this.clientPromise.catch(() => {
|
|
903
|
-
this.clientPromise = null;
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
|
-
return this.clientPromise;
|
|
907
|
-
}
|
|
908
|
-
async request(operation, query, variables, actor) {
|
|
909
|
-
const { actorId, workspaceId, actorType } = this.requireActor(actor);
|
|
910
|
-
const client = await this.getClient();
|
|
911
|
-
let response;
|
|
912
|
-
try {
|
|
913
|
-
response = await client.internalQuery({
|
|
914
|
-
query,
|
|
915
|
-
variables,
|
|
916
|
-
timeout: this.requestTimeoutMs,
|
|
917
|
-
headers: {
|
|
918
|
-
"x-actor-id": actorId,
|
|
919
|
-
"x-actor-type": actorType ?? "user",
|
|
920
|
-
"x-workspace-id": workspaceId
|
|
921
|
-
}
|
|
922
|
-
});
|
|
923
|
-
} catch (error) {
|
|
924
|
-
throw toFilesClientError(error, operation);
|
|
925
|
-
}
|
|
926
|
-
if (response.errors?.length) {
|
|
927
|
-
throw new FilesClientError(classifyFilesErrors(response.errors), `wspace-files-svc ${operation} failed`, {
|
|
928
|
-
operation,
|
|
929
|
-
errors: response.errors.map((error) => ({
|
|
930
|
-
message: error.message,
|
|
931
|
-
code: error.extensions?.["code"] ?? null
|
|
932
|
-
}))
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
if (!response.data) {
|
|
936
|
-
throw new FilesClientError("UPSTREAM_ERROR", `wspace-files-svc ${operation} returned no data`, {
|
|
937
|
-
operation
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
return response.data;
|
|
941
|
-
}
|
|
942
|
-
};
|
|
943
|
-
|
|
944
|
-
// src/files/reference.ts
|
|
945
|
-
var FILE_REFERENCE_KIND = "burdenoff.file";
|
|
946
|
-
function toFileReference(file) {
|
|
947
|
-
return {
|
|
948
|
-
kind: FILE_REFERENCE_KIND,
|
|
949
|
-
fileId: "fileId" in file ? file.fileId : file.id,
|
|
950
|
-
name: file.name,
|
|
951
|
-
mimeType: file.mimeType,
|
|
952
|
-
size: file.size,
|
|
953
|
-
sha256Hash: file.sha256Hash
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
__name(toFileReference, "toFileReference");
|
|
957
|
-
function isRecord(value) {
|
|
958
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
959
|
-
}
|
|
960
|
-
__name(isRecord, "isRecord");
|
|
961
|
-
function isFileReference(value) {
|
|
962
|
-
if (!isRecord(value)) return false;
|
|
963
|
-
const size = value["size"];
|
|
964
|
-
const sha256Hash = value["sha256Hash"];
|
|
965
|
-
return value["kind"] === FILE_REFERENCE_KIND && typeof value["fileId"] === "string" && value["fileId"].length > 0 && typeof value["name"] === "string" && typeof value["mimeType"] === "string" && typeof size === "number" && Number.isSafeInteger(size) && size >= 0 && (sha256Hash === null || sha256Hash === void 0 || typeof sha256Hash === "string");
|
|
966
|
-
}
|
|
967
|
-
__name(isFileReference, "isFileReference");
|
|
968
|
-
|
|
969
|
-
export { FILES_CLIENT_GRAPHQL_CODES, FILE_ACTOR_TYPES, FILE_REFERENCE_KIND, FILE_VISIBILITIES, FilesClient, FilesClientError, MAX_DOWNLOAD_URL_TTL_SECONDS, MIN_DOWNLOAD_URL_TTL_SECONDS, clampDownloadUrlTtl, classifyFilesErrors, fileExtensionOf, files_exports, isFileReference, isFilesClientError, mapFileMetadata, toFileReference, toFilesClientError };
|
|
970
|
-
//# sourceMappingURL=chunk-OXNCBE7P.js.map
|
|
971
|
-
//# sourceMappingURL=chunk-OXNCBE7P.js.map
|