@tencent-ai/workbuddy-cloud-sdk 0.1.1-dev.520de95.202609090209 → 0.1.2-dev.1b37f73.202609222026
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/lib/index.cjs +154 -1600
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +45 -15
- package/lib/index.d.ts +45 -15
- package/lib/index.global.js +5 -5
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +154 -1600
- package/lib/index.js.map +1 -1
- package/lib/miniprogram.cjs +154 -1600
- package/lib/miniprogram.cjs.map +1 -1
- package/lib/miniprogram.d.cts +47 -17
- package/lib/miniprogram.d.ts +47 -17
- package/lib/miniprogram.js +154 -1600
- package/lib/miniprogram.js.map +1 -1
- package/miniprogram_dist/miniprogram.js +339 -2410
- package/package.json +5 -8
package/lib/index.cjs
CHANGED
|
@@ -159,6 +159,8 @@ var AUTH_PATHS = {
|
|
|
159
159
|
token: "/v1/token",
|
|
160
160
|
/** 小程序微信登录:本地认人后仍需用 custom 票据换取 TCB session。 */
|
|
161
161
|
loginWechat: "/v1/login-wechat",
|
|
162
|
+
/** 网页微信扫码:Relay 回调后换 Genie session。 */
|
|
163
|
+
loginWechatWeb: "/v1/login-wechat-web",
|
|
162
164
|
signOut: "/v1/user/signout",
|
|
163
165
|
userMe: "/v1/user/me",
|
|
164
166
|
/** 发码。 */
|
|
@@ -526,6 +528,22 @@ function isStoredSession(value) {
|
|
|
526
528
|
__name(isStoredSession, "isStoredSession");
|
|
527
529
|
|
|
528
530
|
// src/modules/auth/index.ts
|
|
531
|
+
var OAUTH_ERROR_MESSAGE_MAX = 200;
|
|
532
|
+
function truncateMessage(message, max) {
|
|
533
|
+
const chars = Array.from(message);
|
|
534
|
+
return chars.length <= max ? message : `${chars.slice(0, max).join("")}\u2026`;
|
|
535
|
+
}
|
|
536
|
+
__name(truncateMessage, "truncateMessage");
|
|
537
|
+
function oauthProviderRejectMessage(params) {
|
|
538
|
+
const error = params.get("error");
|
|
539
|
+
if (!error) {
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
const description = params.get("error_description");
|
|
543
|
+
const message = description ? `oauth provider rejected the request: ${error}: ${description}` : `oauth provider rejected the request: ${error}`;
|
|
544
|
+
return truncateMessage(message, OAUTH_ERROR_MESSAGE_MAX);
|
|
545
|
+
}
|
|
546
|
+
__name(oauthProviderRejectMessage, "oauthProviderRejectMessage");
|
|
529
547
|
var AuthModule = class {
|
|
530
548
|
static {
|
|
531
549
|
__name(this, "AuthModule");
|
|
@@ -588,6 +606,7 @@ var AuthModule = class {
|
|
|
588
606
|
* 小程序 wx.login 的 code 换 Genie session。
|
|
589
607
|
* 试用与正式是两套独立小程序,必须带当前账号的 appid
|
|
590
608
|
*(`wx.getAccountInfoSync().miniProgram.appId`)。
|
|
609
|
+
* 成功后 session.user.id 为 TCB custom uid:`wx:` + 微信 openid(长度需 ≤32)。
|
|
591
610
|
*/
|
|
592
611
|
async signInWithWechat(code, appid) {
|
|
593
612
|
if (!code) {
|
|
@@ -616,6 +635,9 @@ var AuthModule = class {
|
|
|
616
635
|
if (!credentials.verificationToken) {
|
|
617
636
|
return fail(badRequest("signUp requires a verificationToken; run sendOtp + verifyOtp first (the provider rejects username+password-only signup)"));
|
|
618
637
|
}
|
|
638
|
+
if (credentials.email && !credentials.password) {
|
|
639
|
+
return fail(badRequest("signUp with email requires a password; an account created without one can never sign in by password"));
|
|
640
|
+
}
|
|
619
641
|
const body = {
|
|
620
642
|
verification_token: credentials.verificationToken
|
|
621
643
|
};
|
|
@@ -634,7 +656,7 @@ var AuthModule = class {
|
|
|
634
656
|
* SDK 不猜。
|
|
635
657
|
*
|
|
636
658
|
* 两条渠道的请求体差异是刻意的(runtime-auth-design §3.1):
|
|
637
|
-
* - 邮箱:`{ email, usage: '
|
|
659
|
+
* - 邮箱:`{ email, usage: 'email' }`,与上游 `VerificationUsage.EMAIL` 的值一致,区分大小写。
|
|
638
660
|
* - 手机:`{ phone_number, target: 'ANY' }` —— **不带 `usage`**(普通短信登录
|
|
639
661
|
* 发码时省略即可,上游没有对应的短信枚举值),`target: 'ANY'` 表示新老用户
|
|
640
662
|
* 都允许发码。
|
|
@@ -646,7 +668,7 @@ var AuthModule = class {
|
|
|
646
668
|
body.target = "ANY";
|
|
647
669
|
} else if (credentials.email) {
|
|
648
670
|
body.email = credentials.email;
|
|
649
|
-
body.usage = "
|
|
671
|
+
body.usage = "email";
|
|
650
672
|
if (credentials.emailRedirectTo) {
|
|
651
673
|
body.email_redirect_to = credentials.emailRedirectTo;
|
|
652
674
|
}
|
|
@@ -734,7 +756,7 @@ var AuthModule = class {
|
|
|
734
756
|
return this.signUp({
|
|
735
757
|
email: params.email,
|
|
736
758
|
phone: params.phone,
|
|
737
|
-
password: params.password
|
|
759
|
+
password: params.password,
|
|
738
760
|
verificationToken
|
|
739
761
|
});
|
|
740
762
|
}
|
|
@@ -744,21 +766,17 @@ var AuthModule = class {
|
|
|
744
766
|
/**
|
|
745
767
|
* 发起第三方登录,返回该把用户送去的地址。
|
|
746
768
|
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
* state 校验或回调白名单。
|
|
750
|
-
*
|
|
751
|
-
* SDK 不自己跳转(不写 `location.href`):跳转时机应由应用决定 —— 有的要
|
|
752
|
-
* 先存草稿,有的在 iframe 里要开弹窗。返回 url 交调用方处置。
|
|
769
|
+
* 走 Cloud Backend Service OAuth Relay。IdP 回调白名单只登记平台统一域名。
|
|
770
|
+
* SDK 不自己跳转:返回 url 交调用方 `location.assign`。
|
|
753
771
|
*
|
|
754
|
-
*
|
|
772
|
+
* `google` 已下线,仅存量应用;新应用用 `wechat` 做网页扫码登录。
|
|
755
773
|
*/
|
|
756
774
|
async signInWithOAuth(options) {
|
|
757
775
|
if (!this.oauthRelayBaseUrl) {
|
|
758
776
|
return fail(badRequest("signInWithOAuth requires oauthRelayBaseUrl"));
|
|
759
777
|
}
|
|
760
|
-
if (options.provider !== "google") {
|
|
761
|
-
return fail(badRequest("signInWithOAuth
|
|
778
|
+
if (options.provider !== "google" && options.provider !== "wechat") {
|
|
779
|
+
return fail(badRequest("signInWithOAuth supports google or wechat"));
|
|
762
780
|
}
|
|
763
781
|
const redirectTo = options.redirectTo ?? currentPageUrl();
|
|
764
782
|
if (!redirectTo) {
|
|
@@ -766,6 +784,15 @@ var AuthModule = class {
|
|
|
766
784
|
}
|
|
767
785
|
return this.startRelayOAuth(options, redirectTo);
|
|
768
786
|
}
|
|
787
|
+
/** 回调输入的 query 归一:接受完整 URL 或裸 query。 */
|
|
788
|
+
parseCallbackQuery(input) {
|
|
789
|
+
try {
|
|
790
|
+
const query = /^https?:\/\//i.test(input) ? new URL(input).search : input;
|
|
791
|
+
return ok(new URLSearchParams(query));
|
|
792
|
+
} catch {
|
|
793
|
+
return fail(badRequest("oauth callback URL is invalid"));
|
|
794
|
+
}
|
|
795
|
+
}
|
|
769
796
|
/**
|
|
770
797
|
* 完成第三方登录:读回调 URL 上的参数换会话。
|
|
771
798
|
*
|
|
@@ -775,21 +802,16 @@ var AuthModule = class {
|
|
|
775
802
|
* @deprecated Google 登录已下线,新应用不应再调用该方法。
|
|
776
803
|
*/
|
|
777
804
|
async handleOAuthCallback(search) {
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
if (/^https?:\/\//i.test(callbackInput)) {
|
|
782
|
-
query = new URL(callbackInput).search;
|
|
783
|
-
}
|
|
784
|
-
} catch {
|
|
785
|
-
return fail(badRequest("oauth callback URL is invalid"));
|
|
805
|
+
const parsed = this.parseCallbackQuery(search ?? currentPageSearch());
|
|
806
|
+
if (parsed.error || !parsed.data) {
|
|
807
|
+
return fail(parsed.error ?? badRequest("oauth callback URL is invalid"));
|
|
786
808
|
}
|
|
787
|
-
const params =
|
|
788
|
-
const oauthError =
|
|
809
|
+
const params = parsed.data;
|
|
810
|
+
const oauthError = oauthProviderRejectMessage(params);
|
|
789
811
|
if (oauthError) {
|
|
790
812
|
return fail({
|
|
791
813
|
kind: "unauthenticated",
|
|
792
|
-
message:
|
|
814
|
+
message: oauthError,
|
|
793
815
|
status: 0
|
|
794
816
|
});
|
|
795
817
|
}
|
|
@@ -798,13 +820,13 @@ var AuthModule = class {
|
|
|
798
820
|
return ok(null);
|
|
799
821
|
}
|
|
800
822
|
const state = params.get("state") ?? "";
|
|
823
|
+
if (!state) {
|
|
824
|
+
return fail(badRequest("oauth callback requires state"));
|
|
825
|
+
}
|
|
801
826
|
const providerId = params.get("provider_id");
|
|
802
827
|
if (providerId !== "custom-oauth") {
|
|
803
828
|
return fail(badRequest("oauth callback requires provider_id=custom-oauth"));
|
|
804
829
|
}
|
|
805
|
-
if (!state) {
|
|
806
|
-
return fail(badRequest("oauth callback requires state"));
|
|
807
|
-
}
|
|
808
830
|
const body = {
|
|
809
831
|
provider_id: providerId,
|
|
810
832
|
provider_code: code,
|
|
@@ -815,6 +837,47 @@ var AuthModule = class {
|
|
|
815
837
|
};
|
|
816
838
|
return this.postForSession(AUTH_PATHS.signInWithProvider, body);
|
|
817
839
|
}
|
|
840
|
+
/**
|
|
841
|
+
* 网页微信扫码回调:用 Relay 带回的 code/state 换 Genie session。
|
|
842
|
+
*
|
|
843
|
+
* 仅用于 **微信扫码** 落地页。Google 存量应用必须继续调用
|
|
844
|
+
* `handleOAuthCallback`(custom-oauth 路径)。两者不可互换:本方法会拒绝
|
|
845
|
+
* `provider != "wechat"` 的回调,报错看起来像前端传错参数。
|
|
846
|
+
*/
|
|
847
|
+
async handleWechatWebCallback(search) {
|
|
848
|
+
const parsed = this.parseCallbackQuery(search ?? currentPageSearch());
|
|
849
|
+
if (parsed.error || !parsed.data) {
|
|
850
|
+
return fail(parsed.error ?? badRequest("oauth callback URL is invalid"));
|
|
851
|
+
}
|
|
852
|
+
const params = parsed.data;
|
|
853
|
+
const oauthError = oauthProviderRejectMessage(params);
|
|
854
|
+
if (oauthError) {
|
|
855
|
+
return fail({
|
|
856
|
+
kind: "unauthenticated",
|
|
857
|
+
message: oauthError,
|
|
858
|
+
status: 0
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
const code = params.get("code");
|
|
862
|
+
if (!code) {
|
|
863
|
+
return ok(null);
|
|
864
|
+
}
|
|
865
|
+
const state = params.get("state") ?? "";
|
|
866
|
+
if (!state) {
|
|
867
|
+
return fail(badRequest("oauth callback requires state"));
|
|
868
|
+
}
|
|
869
|
+
const provider = params.get("provider");
|
|
870
|
+
if (provider && provider !== "wechat") {
|
|
871
|
+
return fail(badRequest("wechat callback requires provider=wechat"));
|
|
872
|
+
}
|
|
873
|
+
if (params.get("provider_id") === "custom-oauth") {
|
|
874
|
+
return fail(badRequest("wechat callback must not use provider_id=custom-oauth"));
|
|
875
|
+
}
|
|
876
|
+
return this.postForSession(AUTH_PATHS.loginWechatWeb, {
|
|
877
|
+
code,
|
|
878
|
+
state
|
|
879
|
+
});
|
|
880
|
+
}
|
|
818
881
|
/** 忘记密码:发码,验证码通过后更新密码并自动登录。 */
|
|
819
882
|
async resetPasswordForEmail(email) {
|
|
820
883
|
if (!email) {
|
|
@@ -1009,8 +1072,6 @@ var AuthModule = class {
|
|
|
1009
1072
|
// ------------------------------------------------------------------
|
|
1010
1073
|
/**
|
|
1011
1074
|
* 拼出平台 Relay 授权地址;state 由 Relay 自己签发、校验并一次性消费。
|
|
1012
|
-
*
|
|
1013
|
-
* @deprecated Google 登录已下线,仅保留给存量应用的回调落地页。
|
|
1014
1075
|
*/
|
|
1015
1076
|
async startRelayOAuth(options, redirectTo) {
|
|
1016
1077
|
const callback = new URL(redirectTo);
|
|
@@ -5174,6 +5235,43 @@ function booleanField(...values) {
|
|
|
5174
5235
|
return values.find((value) => typeof value === "boolean");
|
|
5175
5236
|
}
|
|
5176
5237
|
__name(booleanField, "booleanField");
|
|
5238
|
+
function contextWindowField(...values) {
|
|
5239
|
+
for (const value of values) {
|
|
5240
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
5241
|
+
return value;
|
|
5242
|
+
}
|
|
5243
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
5244
|
+
return normalizeContextWindowObject(value);
|
|
5245
|
+
}
|
|
5246
|
+
}
|
|
5247
|
+
return void 0;
|
|
5248
|
+
}
|
|
5249
|
+
__name(contextWindowField, "contextWindowField");
|
|
5250
|
+
function normalizeContextWindowObject(raw) {
|
|
5251
|
+
const result = {};
|
|
5252
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
5253
|
+
if (key === "supportedLengths") {
|
|
5254
|
+
if (Array.isArray(value)) {
|
|
5255
|
+
result.supportedLengths = value.filter((item) => typeof item === "number" && Number.isFinite(item));
|
|
5256
|
+
}
|
|
5257
|
+
continue;
|
|
5258
|
+
}
|
|
5259
|
+
if (key === "defaultLength") {
|
|
5260
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
5261
|
+
result.defaultLength = value;
|
|
5262
|
+
}
|
|
5263
|
+
continue;
|
|
5264
|
+
}
|
|
5265
|
+
Object.defineProperty(result, key, {
|
|
5266
|
+
value,
|
|
5267
|
+
writable: true,
|
|
5268
|
+
enumerable: true,
|
|
5269
|
+
configurable: true
|
|
5270
|
+
});
|
|
5271
|
+
}
|
|
5272
|
+
return result;
|
|
5273
|
+
}
|
|
5274
|
+
__name(normalizeContextWindowObject, "normalizeContextWindowObject");
|
|
5177
5275
|
function modalitiesField(value) {
|
|
5178
5276
|
if (!value || typeof value !== "object") return void 0;
|
|
5179
5277
|
const raw = value;
|
|
@@ -5279,8 +5377,8 @@ function normalizeModel(raw) {
|
|
|
5279
5377
|
...stringField(raw.iconUrl, raw.IconURL) ? {
|
|
5280
5378
|
iconUrl: stringField(raw.iconUrl, raw.IconURL)
|
|
5281
5379
|
} : {},
|
|
5282
|
-
...
|
|
5283
|
-
contextWindow:
|
|
5380
|
+
...contextWindowField(raw.contextWindow, raw.ContextWindow) !== void 0 ? {
|
|
5381
|
+
contextWindow: contextWindowField(raw.contextWindow, raw.ContextWindow)
|
|
5284
5382
|
} : {},
|
|
5285
5383
|
...numberField(raw.maxInputTokens, raw.MaxInputTokens) !== void 0 ? {
|
|
5286
5384
|
maxInputTokens: numberField(raw.maxInputTokens, raw.MaxInputTokens)
|
|
@@ -5960,22 +6058,6 @@ var recursiveToCamel = /* @__PURE__ */ __name((item) => {
|
|
|
5960
6058
|
});
|
|
5961
6059
|
return result;
|
|
5962
6060
|
}, "recursiveToCamel");
|
|
5963
|
-
var isValidBucketName = /* @__PURE__ */ __name((bucketName) => {
|
|
5964
|
-
if (!bucketName || typeof bucketName !== "string") {
|
|
5965
|
-
return false;
|
|
5966
|
-
}
|
|
5967
|
-
if (bucketName.length === 0 || bucketName.length > 100) {
|
|
5968
|
-
return false;
|
|
5969
|
-
}
|
|
5970
|
-
if (bucketName.trim() !== bucketName) {
|
|
5971
|
-
return false;
|
|
5972
|
-
}
|
|
5973
|
-
if (bucketName.includes("/") || bucketName.includes("\\")) {
|
|
5974
|
-
return false;
|
|
5975
|
-
}
|
|
5976
|
-
const bucketNameRegex = /^[\w!.\*'() &$@=;:+,?-]+$/;
|
|
5977
|
-
return bucketNameRegex.test(bucketName);
|
|
5978
|
-
}, "isValidBucketName");
|
|
5979
6061
|
var encodeStoragePath = /* @__PURE__ */ __name((path) => path.split("/").map(encodeURIComponent).join("/"), "encodeStoragePath");
|
|
5980
6062
|
|
|
5981
6063
|
// src/vendor/storage/lib/common/fetch.ts
|
|
@@ -7526,1565 +7608,35 @@ var DEFAULT_HEADERS = {
|
|
|
7526
7608
|
"X-Client-Info": `storage-js/${version}`
|
|
7527
7609
|
};
|
|
7528
7610
|
|
|
7529
|
-
// src/
|
|
7530
|
-
var
|
|
7611
|
+
// src/modules/storage.ts
|
|
7612
|
+
var RUNTIME_STORAGE_BUCKET = "runtime";
|
|
7613
|
+
var DEFAULT_SIGNED_URL_TTL_SECONDS = 10 * 60;
|
|
7614
|
+
var MAX_SIGNED_URL_TTL_SECONDS = 60 * 60;
|
|
7615
|
+
var CloudStoragePathError = class extends Error {
|
|
7531
7616
|
static {
|
|
7532
|
-
__name(this, "
|
|
7533
|
-
}
|
|
7534
|
-
constructor(url, headers = {}, fetch2, opts) {
|
|
7535
|
-
const baseUrl = new URL(url);
|
|
7536
|
-
if (opts?.useNewHostname) {
|
|
7537
|
-
const isSupabaseHost = /supabase\.(co|in|red)$/.test(baseUrl.hostname);
|
|
7538
|
-
if (isSupabaseHost && !baseUrl.hostname.includes("storage.supabase.")) {
|
|
7539
|
-
baseUrl.hostname = baseUrl.hostname.replace("supabase.", "storage.supabase.");
|
|
7540
|
-
}
|
|
7541
|
-
}
|
|
7542
|
-
const finalUrl = baseUrl.href.replace(/\/$/, "");
|
|
7543
|
-
const finalHeaders = {
|
|
7544
|
-
...DEFAULT_HEADERS,
|
|
7545
|
-
...headers
|
|
7546
|
-
};
|
|
7547
|
-
super(finalUrl, finalHeaders, fetch2, "storage");
|
|
7617
|
+
__name(this, "CloudStoragePathError");
|
|
7548
7618
|
}
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
* @category Storage
|
|
7553
|
-
* @subcategory File Buckets
|
|
7554
|
-
* @param options Query parameters for listing buckets
|
|
7555
|
-
* @param options.limit Maximum number of buckets to return
|
|
7556
|
-
* @param options.offset Number of buckets to skip
|
|
7557
|
-
* @param options.sortColumn Column to sort by ('id', 'name', 'created_at', 'updated_at')
|
|
7558
|
-
* @param options.sortOrder Sort order ('asc' or 'desc')
|
|
7559
|
-
* @param options.search Search term to filter bucket names
|
|
7560
|
-
* @returns Promise with response containing array of buckets or error
|
|
7561
|
-
*
|
|
7562
|
-
* @example List buckets
|
|
7563
|
-
* ```js
|
|
7564
|
-
* const { data, error } = await supabase
|
|
7565
|
-
* .storage
|
|
7566
|
-
* .listBuckets()
|
|
7567
|
-
* ```
|
|
7568
|
-
*
|
|
7569
|
-
* @example List buckets with options
|
|
7570
|
-
* ```js
|
|
7571
|
-
* const { data, error } = await supabase
|
|
7572
|
-
* .storage
|
|
7573
|
-
* .listBuckets({
|
|
7574
|
-
* limit: 10,
|
|
7575
|
-
* offset: 0,
|
|
7576
|
-
* sortColumn: 'created_at',
|
|
7577
|
-
* sortOrder: 'desc',
|
|
7578
|
-
* search: 'prod'
|
|
7579
|
-
* })
|
|
7580
|
-
* ```
|
|
7581
|
-
*
|
|
7582
|
-
* @remarks
|
|
7583
|
-
* - RLS policy permissions required:
|
|
7584
|
-
* - `buckets` table permissions: `select`
|
|
7585
|
-
* - `objects` table permissions: none
|
|
7586
|
-
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
7587
|
-
*/
|
|
7588
|
-
async listBuckets(options) {
|
|
7589
|
-
return this.handleOperation(async () => {
|
|
7590
|
-
const queryString = this.listBucketOptionsToQueryString(options);
|
|
7591
|
-
return await get(this.fetch, `${this.url}/bucket${queryString}`, {
|
|
7592
|
-
headers: this.headers
|
|
7593
|
-
});
|
|
7594
|
-
});
|
|
7619
|
+
constructor(message) {
|
|
7620
|
+
super(message);
|
|
7621
|
+
this.name = "CloudStoragePathError";
|
|
7595
7622
|
}
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
* @subcategory File Buckets
|
|
7601
|
-
* @param id The unique identifier of the bucket you would like to retrieve.
|
|
7602
|
-
* @returns Promise with response containing bucket details or error
|
|
7603
|
-
*
|
|
7604
|
-
* @example Get bucket
|
|
7605
|
-
* ```js
|
|
7606
|
-
* const { data, error } = await supabase
|
|
7607
|
-
* .storage
|
|
7608
|
-
* .getBucket('avatars')
|
|
7609
|
-
* ```
|
|
7610
|
-
*
|
|
7611
|
-
* Response:
|
|
7612
|
-
* ```json
|
|
7613
|
-
* {
|
|
7614
|
-
* "data": {
|
|
7615
|
-
* "id": "avatars",
|
|
7616
|
-
* "name": "avatars",
|
|
7617
|
-
* "owner": "",
|
|
7618
|
-
* "public": false,
|
|
7619
|
-
* "file_size_limit": 1024,
|
|
7620
|
-
* "allowed_mime_types": [
|
|
7621
|
-
* "image/png"
|
|
7622
|
-
* ],
|
|
7623
|
-
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
7624
|
-
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
7625
|
-
* },
|
|
7626
|
-
* "error": null
|
|
7627
|
-
* }
|
|
7628
|
-
* ```
|
|
7629
|
-
*
|
|
7630
|
-
* @remarks
|
|
7631
|
-
* - RLS policy permissions required:
|
|
7632
|
-
* - `buckets` table permissions: `select`
|
|
7633
|
-
* - `objects` table permissions: none
|
|
7634
|
-
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
7635
|
-
*/
|
|
7636
|
-
async getBucket(id) {
|
|
7637
|
-
return this.handleOperation(async () => {
|
|
7638
|
-
return await get(this.fetch, `${this.url}/bucket/${id}`, {
|
|
7639
|
-
headers: this.headers
|
|
7640
|
-
});
|
|
7641
|
-
});
|
|
7623
|
+
};
|
|
7624
|
+
var WorkBuddyStorageDownload = class {
|
|
7625
|
+
static {
|
|
7626
|
+
__name(this, "WorkBuddyStorageDownload");
|
|
7642
7627
|
}
|
|
7643
|
-
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.
|
|
7650
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
7651
|
-
* The global file size limit takes precedence over this value.
|
|
7652
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
7653
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
7654
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
7655
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
7656
|
-
* @param options.type (private-beta) specifies the bucket type. see `BucketType` for more details.
|
|
7657
|
-
* - default bucket type is `STANDARD`
|
|
7658
|
-
* @returns Promise with response containing newly created bucket name or error
|
|
7659
|
-
*
|
|
7660
|
-
* @example Create bucket
|
|
7661
|
-
* ```js
|
|
7662
|
-
* const { data, error } = await supabase
|
|
7663
|
-
* .storage
|
|
7664
|
-
* .createBucket('avatars', {
|
|
7665
|
-
* public: false,
|
|
7666
|
-
* allowedMimeTypes: ['image/png'],
|
|
7667
|
-
* fileSizeLimit: 1024
|
|
7668
|
-
* })
|
|
7669
|
-
* ```
|
|
7670
|
-
*
|
|
7671
|
-
* Response:
|
|
7672
|
-
* ```json
|
|
7673
|
-
* {
|
|
7674
|
-
* "data": {
|
|
7675
|
-
* "name": "avatars"
|
|
7676
|
-
* },
|
|
7677
|
-
* "error": null
|
|
7678
|
-
* }
|
|
7679
|
-
* ```
|
|
7680
|
-
*
|
|
7681
|
-
* @remarks
|
|
7682
|
-
* - RLS policy permissions required:
|
|
7683
|
-
* - `buckets` table permissions: `insert`
|
|
7684
|
-
* - `objects` table permissions: none
|
|
7685
|
-
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
7686
|
-
*/
|
|
7687
|
-
async createBucket(id, options = {
|
|
7688
|
-
public: false
|
|
7689
|
-
}) {
|
|
7690
|
-
return this.handleOperation(async () => {
|
|
7691
|
-
return await post(this.fetch, `${this.url}/bucket`, {
|
|
7692
|
-
id,
|
|
7693
|
-
name: id,
|
|
7694
|
-
type: options.type,
|
|
7695
|
-
public: options.public,
|
|
7696
|
-
file_size_limit: options.fileSizeLimit,
|
|
7697
|
-
allowed_mime_types: options.allowedMimeTypes
|
|
7698
|
-
}, {
|
|
7699
|
-
headers: this.headers
|
|
7700
|
-
});
|
|
7701
|
-
});
|
|
7628
|
+
blob;
|
|
7629
|
+
stream;
|
|
7630
|
+
[Symbol.toStringTag] = "WorkBuddyStorageDownload";
|
|
7631
|
+
constructor(blob, stream) {
|
|
7632
|
+
this.blob = blob;
|
|
7633
|
+
this.stream = stream;
|
|
7702
7634
|
}
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
*
|
|
7706
|
-
* @category Storage
|
|
7707
|
-
* @subcategory File Buckets
|
|
7708
|
-
* @param id A unique identifier for the bucket you are updating.
|
|
7709
|
-
* @param options.public The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations.
|
|
7710
|
-
* @param options.fileSizeLimit specifies the max file size in bytes that can be uploaded to this bucket.
|
|
7711
|
-
* The global file size limit takes precedence over this value.
|
|
7712
|
-
* The default value is null, which doesn't set a per bucket file size limit.
|
|
7713
|
-
* @param options.allowedMimeTypes specifies the allowed mime types that this bucket can accept during upload.
|
|
7714
|
-
* The default value is null, which allows files with all mime types to be uploaded.
|
|
7715
|
-
* Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
|
|
7716
|
-
* @returns Promise with response containing success message or error
|
|
7717
|
-
*
|
|
7718
|
-
* @example Update bucket
|
|
7719
|
-
* ```js
|
|
7720
|
-
* const { data, error } = await supabase
|
|
7721
|
-
* .storage
|
|
7722
|
-
* .updateBucket('avatars', {
|
|
7723
|
-
* public: false,
|
|
7724
|
-
* allowedMimeTypes: ['image/png'],
|
|
7725
|
-
* fileSizeLimit: 1024
|
|
7726
|
-
* })
|
|
7727
|
-
* ```
|
|
7728
|
-
*
|
|
7729
|
-
* Response:
|
|
7730
|
-
* ```json
|
|
7731
|
-
* {
|
|
7732
|
-
* "data": {
|
|
7733
|
-
* "message": "Successfully updated"
|
|
7734
|
-
* },
|
|
7735
|
-
* "error": null
|
|
7736
|
-
* }
|
|
7737
|
-
* ```
|
|
7738
|
-
*
|
|
7739
|
-
* @remarks
|
|
7740
|
-
* - RLS policy permissions required:
|
|
7741
|
-
* - `buckets` table permissions: `select` and `update`
|
|
7742
|
-
* - `objects` table permissions: none
|
|
7743
|
-
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
7744
|
-
*/
|
|
7745
|
-
async updateBucket(id, options) {
|
|
7746
|
-
return this.handleOperation(async () => {
|
|
7747
|
-
return await put(this.fetch, `${this.url}/bucket/${id}`, {
|
|
7748
|
-
id,
|
|
7749
|
-
name: id,
|
|
7750
|
-
public: options.public,
|
|
7751
|
-
file_size_limit: options.fileSizeLimit,
|
|
7752
|
-
allowed_mime_types: options.allowedMimeTypes
|
|
7753
|
-
}, {
|
|
7754
|
-
headers: this.headers
|
|
7755
|
-
});
|
|
7756
|
-
});
|
|
7635
|
+
asStream() {
|
|
7636
|
+
return this.stream();
|
|
7757
7637
|
}
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
*
|
|
7761
|
-
* @category Storage
|
|
7762
|
-
* @subcategory File Buckets
|
|
7763
|
-
* @param id The unique identifier of the bucket you would like to empty.
|
|
7764
|
-
* @returns Promise with success message or error
|
|
7765
|
-
*
|
|
7766
|
-
* @example Empty bucket
|
|
7767
|
-
* ```js
|
|
7768
|
-
* const { data, error } = await supabase
|
|
7769
|
-
* .storage
|
|
7770
|
-
* .emptyBucket('avatars')
|
|
7771
|
-
* ```
|
|
7772
|
-
*
|
|
7773
|
-
* Response:
|
|
7774
|
-
* ```json
|
|
7775
|
-
* {
|
|
7776
|
-
* "data": {
|
|
7777
|
-
* "message": "Successfully emptied"
|
|
7778
|
-
* },
|
|
7779
|
-
* "error": null
|
|
7780
|
-
* }
|
|
7781
|
-
* ```
|
|
7782
|
-
*
|
|
7783
|
-
* @remarks
|
|
7784
|
-
* - RLS policy permissions required:
|
|
7785
|
-
* - `buckets` table permissions: `select`
|
|
7786
|
-
* - `objects` table permissions: `select` and `delete`
|
|
7787
|
-
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
7788
|
-
*/
|
|
7789
|
-
async emptyBucket(id) {
|
|
7790
|
-
return this.handleOperation(async () => {
|
|
7791
|
-
return await post(this.fetch, `${this.url}/bucket/${id}/empty`, {}, {
|
|
7792
|
-
headers: this.headers
|
|
7793
|
-
});
|
|
7794
|
-
});
|
|
7795
|
-
}
|
|
7796
|
-
/**
|
|
7797
|
-
* Deletes an existing bucket. A bucket can't be deleted with existing objects inside it.
|
|
7798
|
-
* You must first `empty()` the bucket.
|
|
7799
|
-
*
|
|
7800
|
-
* @category Storage
|
|
7801
|
-
* @subcategory File Buckets
|
|
7802
|
-
* @param id The unique identifier of the bucket you would like to delete.
|
|
7803
|
-
* @returns Promise with success message or error
|
|
7804
|
-
*
|
|
7805
|
-
* @example Delete bucket
|
|
7806
|
-
* ```js
|
|
7807
|
-
* const { data, error } = await supabase
|
|
7808
|
-
* .storage
|
|
7809
|
-
* .deleteBucket('avatars')
|
|
7810
|
-
* ```
|
|
7811
|
-
*
|
|
7812
|
-
* Response:
|
|
7813
|
-
* ```json
|
|
7814
|
-
* {
|
|
7815
|
-
* "data": {
|
|
7816
|
-
* "message": "Successfully deleted"
|
|
7817
|
-
* },
|
|
7818
|
-
* "error": null
|
|
7819
|
-
* }
|
|
7820
|
-
* ```
|
|
7821
|
-
*
|
|
7822
|
-
* @remarks
|
|
7823
|
-
* - RLS policy permissions required:
|
|
7824
|
-
* - `buckets` table permissions: `select` and `delete`
|
|
7825
|
-
* - `objects` table permissions: none
|
|
7826
|
-
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
7827
|
-
*/
|
|
7828
|
-
async deleteBucket(id) {
|
|
7829
|
-
return this.handleOperation(async () => {
|
|
7830
|
-
return await remove(this.fetch, `${this.url}/bucket/${id}`, {}, {
|
|
7831
|
-
headers: this.headers
|
|
7832
|
-
});
|
|
7833
|
-
});
|
|
7834
|
-
}
|
|
7835
|
-
/**
|
|
7836
|
-
* Purges the CDN cache for an entire bucket.
|
|
7837
|
-
*
|
|
7838
|
-
* Maps to `DELETE /cdn/{bucket}` on the Storage API. The server
|
|
7839
|
-
* issues a CDN invalidation for the bucket and returns `{ message: 'success' }`.
|
|
7840
|
-
*
|
|
7841
|
-
* **Requires the `service_role` key.** The underlying endpoint enforces
|
|
7842
|
-
* `service_role` JWT — calls made with the anon key or a user JWT will be
|
|
7843
|
-
* rejected by the server.
|
|
7844
|
-
*
|
|
7845
|
-
* **Hosted CDN feature.** On self-hosted Supabase, the Storage service must
|
|
7846
|
-
* have `CDN_PURGE_ENDPOINT_URL` configured and the `purgeCache` tenant
|
|
7847
|
-
* feature enabled, otherwise the server returns an error.
|
|
7848
|
-
*
|
|
7849
|
-
* @category Storage
|
|
7850
|
-
* @subcategory File Buckets
|
|
7851
|
-
* @param id The unique identifier of the bucket you would like to purge from cache.
|
|
7852
|
-
* @param options Optional purge cache options.
|
|
7853
|
-
* @param options.transformations If true, purges only transformations (resized/formatted variants), leaving original cached files intact.
|
|
7854
|
-
* @param parameters Optional fetch parameters such as an `AbortController` signal.
|
|
7855
|
-
* @returns Promise with `{ data: { message }, error: null }` on success or `{ data: null, error }` on failure.
|
|
7856
|
-
*
|
|
7857
|
-
* @example Purge cache for an entire bucket
|
|
7858
|
-
* ```js
|
|
7859
|
-
* const { data, error } = await supabase
|
|
7860
|
-
* .storage
|
|
7861
|
-
* .purgeBucketCache('avatars')
|
|
7862
|
-
* ```
|
|
7863
|
-
*
|
|
7864
|
-
* @example Purge only transformations for an entire bucket
|
|
7865
|
-
* ```js
|
|
7866
|
-
* const { data, error } = await supabase
|
|
7867
|
-
* .storage
|
|
7868
|
-
* .purgeBucketCache('avatars', { transformations: true })
|
|
7869
|
-
* ```
|
|
7870
|
-
*/
|
|
7871
|
-
async purgeBucketCache(id, options, parameters) {
|
|
7872
|
-
return this.handleOperation(async () => {
|
|
7873
|
-
const query = new URLSearchParams();
|
|
7874
|
-
if (options?.transformations) {
|
|
7875
|
-
query.set("transformations", "true");
|
|
7876
|
-
}
|
|
7877
|
-
const queryString = query.toString();
|
|
7878
|
-
return await remove(this.fetch, `${this.url}/cdn/${encodeStoragePath(id)}${queryString ? `?${queryString}` : ""}`, {}, {
|
|
7879
|
-
headers: this.headers
|
|
7880
|
-
}, parameters);
|
|
7881
|
-
});
|
|
7882
|
-
}
|
|
7883
|
-
listBucketOptionsToQueryString(options) {
|
|
7884
|
-
const params = {};
|
|
7885
|
-
if (options) {
|
|
7886
|
-
if ("limit" in options) {
|
|
7887
|
-
params.limit = String(options.limit);
|
|
7888
|
-
}
|
|
7889
|
-
if ("offset" in options) {
|
|
7890
|
-
params.offset = String(options.offset);
|
|
7891
|
-
}
|
|
7892
|
-
if (options.search) {
|
|
7893
|
-
params.search = options.search;
|
|
7894
|
-
}
|
|
7895
|
-
if (options.sortColumn) {
|
|
7896
|
-
params.sortColumn = options.sortColumn;
|
|
7897
|
-
}
|
|
7898
|
-
if (options.sortOrder) {
|
|
7899
|
-
params.sortOrder = options.sortOrder;
|
|
7900
|
-
}
|
|
7901
|
-
}
|
|
7902
|
-
return Object.keys(params).length > 0 ? "?" + new URLSearchParams(params).toString() : "";
|
|
7903
|
-
}
|
|
7904
|
-
};
|
|
7905
|
-
|
|
7906
|
-
// src/vendor/storage/packages/StorageAnalyticsClient.ts
|
|
7907
|
-
var import_iceberg_js = require("iceberg-js");
|
|
7908
|
-
var StorageAnalyticsClient = class extends BaseApiClient {
|
|
7909
|
-
static {
|
|
7910
|
-
__name(this, "StorageAnalyticsClient");
|
|
7911
|
-
}
|
|
7912
|
-
/**
|
|
7913
|
-
* @alpha
|
|
7914
|
-
*
|
|
7915
|
-
* Creates a new StorageAnalyticsClient instance
|
|
7916
|
-
*
|
|
7917
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
7918
|
-
*
|
|
7919
|
-
* @category Storage
|
|
7920
|
-
* @subcategory Analytics Buckets
|
|
7921
|
-
* @param url - The base URL for the storage API
|
|
7922
|
-
* @param headers - HTTP headers to include in requests
|
|
7923
|
-
* @param fetch - Optional custom fetch implementation
|
|
7924
|
-
*
|
|
7925
|
-
* @example Using supabase-js (recommended)
|
|
7926
|
-
* ```typescript
|
|
7927
|
-
* import { createClient } from '@supabase/supabase-js'
|
|
7928
|
-
*
|
|
7929
|
-
* const supabase = createClient('https://xyzcompany.supabase.co', 'your-publishable-key')
|
|
7930
|
-
* const { data, error } = await supabase.storage.analytics.listBuckets()
|
|
7931
|
-
* ```
|
|
7932
|
-
*
|
|
7933
|
-
* @example Standalone import for bundle-sensitive environments
|
|
7934
|
-
* ```typescript
|
|
7935
|
-
* import { StorageAnalyticsClient } from '@supabase/storage-js'
|
|
7936
|
-
*
|
|
7937
|
-
* const client = new StorageAnalyticsClient(url, headers)
|
|
7938
|
-
* ```
|
|
7939
|
-
*/
|
|
7940
|
-
constructor(url, headers = {}, fetch2) {
|
|
7941
|
-
const finalUrl = url.replace(/\/$/, "");
|
|
7942
|
-
const finalHeaders = {
|
|
7943
|
-
...DEFAULT_HEADERS,
|
|
7944
|
-
...headers
|
|
7945
|
-
};
|
|
7946
|
-
super(finalUrl, finalHeaders, fetch2, "storage");
|
|
7947
|
-
}
|
|
7948
|
-
/**
|
|
7949
|
-
* @alpha
|
|
7950
|
-
*
|
|
7951
|
-
* Creates a new analytics bucket using Iceberg tables
|
|
7952
|
-
* Analytics buckets are optimized for analytical queries and data processing
|
|
7953
|
-
*
|
|
7954
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
7955
|
-
*
|
|
7956
|
-
* @category Storage
|
|
7957
|
-
* @subcategory Analytics Buckets
|
|
7958
|
-
* @param name A unique name for the bucket you are creating
|
|
7959
|
-
* @returns Promise with response containing newly created analytics bucket or error
|
|
7960
|
-
*
|
|
7961
|
-
* @example Create analytics bucket
|
|
7962
|
-
* ```js
|
|
7963
|
-
* const { data, error } = await supabase
|
|
7964
|
-
* .storage
|
|
7965
|
-
* .analytics
|
|
7966
|
-
* .createBucket('analytics-data')
|
|
7967
|
-
* ```
|
|
7968
|
-
*
|
|
7969
|
-
* Response:
|
|
7970
|
-
* ```json
|
|
7971
|
-
* {
|
|
7972
|
-
* "data": {
|
|
7973
|
-
* "name": "analytics-data",
|
|
7974
|
-
* "type": "ANALYTICS",
|
|
7975
|
-
* "format": "iceberg",
|
|
7976
|
-
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
7977
|
-
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
7978
|
-
* },
|
|
7979
|
-
* "error": null
|
|
7980
|
-
* }
|
|
7981
|
-
* ```
|
|
7982
|
-
*
|
|
7983
|
-
* @remarks
|
|
7984
|
-
* - Creates a new analytics bucket using Iceberg tables
|
|
7985
|
-
* - Analytics buckets are optimized for analytical queries and data processing
|
|
7986
|
-
*/
|
|
7987
|
-
async createBucket(name) {
|
|
7988
|
-
return this.handleOperation(async () => {
|
|
7989
|
-
return await post(this.fetch, `${this.url}/bucket`, {
|
|
7990
|
-
name
|
|
7991
|
-
}, {
|
|
7992
|
-
headers: this.headers
|
|
7993
|
-
});
|
|
7994
|
-
});
|
|
7995
|
-
}
|
|
7996
|
-
/**
|
|
7997
|
-
* @alpha
|
|
7998
|
-
*
|
|
7999
|
-
* Retrieves the details of all Analytics Storage buckets within an existing project
|
|
8000
|
-
* Only returns buckets of type 'ANALYTICS'
|
|
8001
|
-
*
|
|
8002
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8003
|
-
*
|
|
8004
|
-
* @category Storage
|
|
8005
|
-
* @subcategory Analytics Buckets
|
|
8006
|
-
* @param options Query parameters for listing buckets
|
|
8007
|
-
* @param options.limit Maximum number of buckets to return
|
|
8008
|
-
* @param options.offset Number of buckets to skip
|
|
8009
|
-
* @param options.sortColumn Column to sort by ('name', 'created_at', 'updated_at')
|
|
8010
|
-
* @param options.sortOrder Sort order ('asc' or 'desc')
|
|
8011
|
-
* @param options.search Search term to filter bucket names
|
|
8012
|
-
* @returns Promise with response containing array of analytics buckets or error
|
|
8013
|
-
*
|
|
8014
|
-
* @example List analytics buckets
|
|
8015
|
-
* ```js
|
|
8016
|
-
* const { data, error } = await supabase
|
|
8017
|
-
* .storage
|
|
8018
|
-
* .analytics
|
|
8019
|
-
* .listBuckets({
|
|
8020
|
-
* limit: 10,
|
|
8021
|
-
* offset: 0,
|
|
8022
|
-
* sortColumn: 'created_at',
|
|
8023
|
-
* sortOrder: 'desc'
|
|
8024
|
-
* })
|
|
8025
|
-
* ```
|
|
8026
|
-
*
|
|
8027
|
-
* Response:
|
|
8028
|
-
* ```json
|
|
8029
|
-
* {
|
|
8030
|
-
* "data": [
|
|
8031
|
-
* {
|
|
8032
|
-
* "name": "analytics-data",
|
|
8033
|
-
* "type": "ANALYTICS",
|
|
8034
|
-
* "format": "iceberg",
|
|
8035
|
-
* "created_at": "2024-05-22T22:26:05.100Z",
|
|
8036
|
-
* "updated_at": "2024-05-22T22:26:05.100Z"
|
|
8037
|
-
* }
|
|
8038
|
-
* ],
|
|
8039
|
-
* "error": null
|
|
8040
|
-
* }
|
|
8041
|
-
* ```
|
|
8042
|
-
*
|
|
8043
|
-
* @remarks
|
|
8044
|
-
* - Retrieves the details of all Analytics Storage buckets within an existing project
|
|
8045
|
-
* - Only returns buckets of type 'ANALYTICS'
|
|
8046
|
-
*/
|
|
8047
|
-
async listBuckets(options) {
|
|
8048
|
-
return this.handleOperation(async () => {
|
|
8049
|
-
const queryParams = new URLSearchParams();
|
|
8050
|
-
if (options?.limit !== void 0) queryParams.set("limit", options.limit.toString());
|
|
8051
|
-
if (options?.offset !== void 0) queryParams.set("offset", options.offset.toString());
|
|
8052
|
-
if (options?.sortColumn) queryParams.set("sortColumn", options.sortColumn);
|
|
8053
|
-
if (options?.sortOrder) queryParams.set("sortOrder", options.sortOrder);
|
|
8054
|
-
if (options?.search) queryParams.set("search", options.search);
|
|
8055
|
-
const queryString = queryParams.toString();
|
|
8056
|
-
const url = queryString ? `${this.url}/bucket?${queryString}` : `${this.url}/bucket`;
|
|
8057
|
-
return await get(this.fetch, url, {
|
|
8058
|
-
headers: this.headers
|
|
8059
|
-
});
|
|
8060
|
-
});
|
|
8061
|
-
}
|
|
8062
|
-
/**
|
|
8063
|
-
* @alpha
|
|
8064
|
-
*
|
|
8065
|
-
* Deletes an existing analytics bucket
|
|
8066
|
-
* A bucket can't be deleted with existing objects inside it
|
|
8067
|
-
* You must first empty the bucket before deletion
|
|
8068
|
-
*
|
|
8069
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8070
|
-
*
|
|
8071
|
-
* @category Storage
|
|
8072
|
-
* @subcategory Analytics Buckets
|
|
8073
|
-
* @param bucketName The unique identifier of the bucket you would like to delete
|
|
8074
|
-
* @returns Promise with response containing success message or error
|
|
8075
|
-
*
|
|
8076
|
-
* @example Delete analytics bucket
|
|
8077
|
-
* ```js
|
|
8078
|
-
* const { data, error } = await supabase
|
|
8079
|
-
* .storage
|
|
8080
|
-
* .analytics
|
|
8081
|
-
* .deleteBucket('analytics-data')
|
|
8082
|
-
* ```
|
|
8083
|
-
*
|
|
8084
|
-
* Response:
|
|
8085
|
-
* ```json
|
|
8086
|
-
* {
|
|
8087
|
-
* "data": {
|
|
8088
|
-
* "message": "Successfully deleted"
|
|
8089
|
-
* },
|
|
8090
|
-
* "error": null
|
|
8091
|
-
* }
|
|
8092
|
-
* ```
|
|
8093
|
-
*
|
|
8094
|
-
* @remarks
|
|
8095
|
-
* - Deletes an analytics bucket
|
|
8096
|
-
*/
|
|
8097
|
-
async deleteBucket(bucketName) {
|
|
8098
|
-
return this.handleOperation(async () => {
|
|
8099
|
-
return await remove(this.fetch, `${this.url}/bucket/${bucketName}`, {}, {
|
|
8100
|
-
headers: this.headers
|
|
8101
|
-
});
|
|
8102
|
-
});
|
|
8103
|
-
}
|
|
8104
|
-
/**
|
|
8105
|
-
* @alpha
|
|
8106
|
-
*
|
|
8107
|
-
* Get an Iceberg REST Catalog client configured for a specific analytics bucket
|
|
8108
|
-
* Use this to perform advanced table and namespace operations within the bucket
|
|
8109
|
-
* The returned client provides full access to the Apache Iceberg REST Catalog API
|
|
8110
|
-
* with the Supabase `{ data, error }` pattern for consistent error handling on all operations.
|
|
8111
|
-
*
|
|
8112
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8113
|
-
*
|
|
8114
|
-
* @category Storage
|
|
8115
|
-
* @subcategory Analytics Buckets
|
|
8116
|
-
* @param bucketName - The name of the analytics bucket (warehouse) to connect to
|
|
8117
|
-
* @returns The wrapped Iceberg catalog client
|
|
8118
|
-
* @throws {StorageError} If the bucket name is invalid
|
|
8119
|
-
*
|
|
8120
|
-
* @example Get catalog and create table
|
|
8121
|
-
* ```js
|
|
8122
|
-
* // First, create an analytics bucket
|
|
8123
|
-
* const { data: bucket, error: bucketError } = await supabase
|
|
8124
|
-
* .storage
|
|
8125
|
-
* .analytics
|
|
8126
|
-
* .createBucket('analytics-data')
|
|
8127
|
-
*
|
|
8128
|
-
* // Get the Iceberg catalog for that bucket
|
|
8129
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
8130
|
-
*
|
|
8131
|
-
* // Create a namespace
|
|
8132
|
-
* const { error: nsError } = await catalog.createNamespace({ namespace: ['default'] })
|
|
8133
|
-
*
|
|
8134
|
-
* // Create a table with schema
|
|
8135
|
-
* const { data: tableMetadata, error: tableError } = await catalog.createTable(
|
|
8136
|
-
* { namespace: ['default'] },
|
|
8137
|
-
* {
|
|
8138
|
-
* name: 'events',
|
|
8139
|
-
* schema: {
|
|
8140
|
-
* type: 'struct',
|
|
8141
|
-
* fields: [
|
|
8142
|
-
* { id: 1, name: 'id', type: 'long', required: true },
|
|
8143
|
-
* { id: 2, name: 'timestamp', type: 'timestamp', required: true },
|
|
8144
|
-
* { id: 3, name: 'user_id', type: 'string', required: false }
|
|
8145
|
-
* ],
|
|
8146
|
-
* 'schema-id': 0,
|
|
8147
|
-
* 'identifier-field-ids': [1]
|
|
8148
|
-
* },
|
|
8149
|
-
* 'partition-spec': {
|
|
8150
|
-
* 'spec-id': 0,
|
|
8151
|
-
* fields: []
|
|
8152
|
-
* },
|
|
8153
|
-
* 'write-order': {
|
|
8154
|
-
* 'order-id': 0,
|
|
8155
|
-
* fields: []
|
|
8156
|
-
* },
|
|
8157
|
-
* properties: {
|
|
8158
|
-
* 'write.format.default': 'parquet'
|
|
8159
|
-
* }
|
|
8160
|
-
* }
|
|
8161
|
-
* )
|
|
8162
|
-
* ```
|
|
8163
|
-
*
|
|
8164
|
-
* @example List tables in namespace
|
|
8165
|
-
* ```js
|
|
8166
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
8167
|
-
*
|
|
8168
|
-
* // List all tables in the default namespace
|
|
8169
|
-
* const { data: tables, error: listError } = await catalog.listTables({ namespace: ['default'] })
|
|
8170
|
-
* if (listError) {
|
|
8171
|
-
* if (listError.isNotFound()) {
|
|
8172
|
-
* console.log('Namespace not found')
|
|
8173
|
-
* }
|
|
8174
|
-
* return
|
|
8175
|
-
* }
|
|
8176
|
-
* console.log(tables) // [{ namespace: ['default'], name: 'events' }]
|
|
8177
|
-
* ```
|
|
8178
|
-
*
|
|
8179
|
-
* @example Working with namespaces
|
|
8180
|
-
* ```js
|
|
8181
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
8182
|
-
*
|
|
8183
|
-
* // List all namespaces
|
|
8184
|
-
* const { data: namespaces } = await catalog.listNamespaces()
|
|
8185
|
-
*
|
|
8186
|
-
* // Create namespace with properties
|
|
8187
|
-
* await catalog.createNamespace(
|
|
8188
|
-
* { namespace: ['production'] },
|
|
8189
|
-
* { properties: { owner: 'data-team', env: 'prod' } }
|
|
8190
|
-
* )
|
|
8191
|
-
* ```
|
|
8192
|
-
*
|
|
8193
|
-
* @example Cleanup operations
|
|
8194
|
-
* ```js
|
|
8195
|
-
* const catalog = supabase.storage.analytics.from('analytics-data')
|
|
8196
|
-
*
|
|
8197
|
-
* // Drop table with purge option (removes all data)
|
|
8198
|
-
* const { error: dropError } = await catalog.dropTable(
|
|
8199
|
-
* { namespace: ['default'], name: 'events' },
|
|
8200
|
-
* { purge: true }
|
|
8201
|
-
* )
|
|
8202
|
-
*
|
|
8203
|
-
* if (dropError?.isNotFound()) {
|
|
8204
|
-
* console.log('Table does not exist')
|
|
8205
|
-
* }
|
|
8206
|
-
*
|
|
8207
|
-
* // Drop namespace (must be empty)
|
|
8208
|
-
* await catalog.dropNamespace({ namespace: ['default'] })
|
|
8209
|
-
* ```
|
|
8210
|
-
*
|
|
8211
|
-
* @remarks
|
|
8212
|
-
* This method provides a bridge between Supabase's bucket management and the standard
|
|
8213
|
-
* Apache Iceberg REST Catalog API. The bucket name maps to the Iceberg warehouse parameter.
|
|
8214
|
-
* All authentication and configuration is handled automatically using your Supabase credentials.
|
|
8215
|
-
*
|
|
8216
|
-
* **Error Handling**: Invalid bucket names throw immediately. All catalog
|
|
8217
|
-
* operations return `{ data, error }` where errors are `IcebergError` instances from iceberg-js.
|
|
8218
|
-
* Use helper methods like `error.isNotFound()` or check `error.status` for specific error handling.
|
|
8219
|
-
* Use `.throwOnError()` on the analytics client if you prefer exceptions for catalog operations.
|
|
8220
|
-
*
|
|
8221
|
-
* **Cleanup Operations**: When using `dropTable`, the `purge: true` option permanently
|
|
8222
|
-
* deletes all table data. Without it, the table is marked as deleted but data remains.
|
|
8223
|
-
*
|
|
8224
|
-
* **Library Dependency**: The returned catalog wraps `IcebergRestCatalog` from iceberg-js.
|
|
8225
|
-
* For complete API documentation and advanced usage, refer to the
|
|
8226
|
-
* [iceberg-js documentation](https://supabase.github.io/iceberg-js/).
|
|
8227
|
-
*/
|
|
8228
|
-
from(bucketName) {
|
|
8229
|
-
if (!isValidBucketName(bucketName)) {
|
|
8230
|
-
throw new StorageError("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");
|
|
8231
|
-
}
|
|
8232
|
-
const catalog = new import_iceberg_js.IcebergRestCatalog({
|
|
8233
|
-
baseUrl: this.url,
|
|
8234
|
-
catalogName: bucketName,
|
|
8235
|
-
auth: {
|
|
8236
|
-
type: "custom",
|
|
8237
|
-
getHeaders: /* @__PURE__ */ __name(async () => this.headers, "getHeaders")
|
|
8238
|
-
},
|
|
8239
|
-
fetch: this.fetch
|
|
8240
|
-
});
|
|
8241
|
-
const shouldThrowOnError = this.shouldThrowOnError;
|
|
8242
|
-
const wrappedCatalog = new Proxy(catalog, {
|
|
8243
|
-
get(target, prop) {
|
|
8244
|
-
const value = target[prop];
|
|
8245
|
-
if (typeof value !== "function") {
|
|
8246
|
-
return value;
|
|
8247
|
-
}
|
|
8248
|
-
return async (...args) => {
|
|
8249
|
-
try {
|
|
8250
|
-
const data = await value.apply(target, args);
|
|
8251
|
-
return {
|
|
8252
|
-
data,
|
|
8253
|
-
error: null
|
|
8254
|
-
};
|
|
8255
|
-
} catch (error) {
|
|
8256
|
-
if (shouldThrowOnError) {
|
|
8257
|
-
throw error;
|
|
8258
|
-
}
|
|
8259
|
-
return {
|
|
8260
|
-
data: null,
|
|
8261
|
-
error
|
|
8262
|
-
};
|
|
8263
|
-
}
|
|
8264
|
-
};
|
|
8265
|
-
}
|
|
8266
|
-
});
|
|
8267
|
-
return wrappedCatalog;
|
|
8268
|
-
}
|
|
8269
|
-
};
|
|
8270
|
-
|
|
8271
|
-
// src/vendor/storage/packages/VectorIndexApi.ts
|
|
8272
|
-
var VectorIndexApi = class extends BaseApiClient {
|
|
8273
|
-
static {
|
|
8274
|
-
__name(this, "VectorIndexApi");
|
|
8275
|
-
}
|
|
8276
|
-
/** Creates a new VectorIndexApi instance */
|
|
8277
|
-
constructor(url, headers = {}, fetch2) {
|
|
8278
|
-
const finalUrl = url.replace(/\/$/, "");
|
|
8279
|
-
const finalHeaders = {
|
|
8280
|
-
...DEFAULT_HEADERS,
|
|
8281
|
-
"Content-Type": "application/json",
|
|
8282
|
-
...headers
|
|
8283
|
-
};
|
|
8284
|
-
super(finalUrl, finalHeaders, fetch2, "vectors");
|
|
8285
|
-
}
|
|
8286
|
-
/** Creates a new vector index within a bucket */
|
|
8287
|
-
async createIndex(options) {
|
|
8288
|
-
return this.handleOperation(async () => {
|
|
8289
|
-
const data = await vectorsApi.post(this.fetch, `${this.url}/CreateIndex`, options, {
|
|
8290
|
-
headers: this.headers
|
|
8291
|
-
});
|
|
8292
|
-
return data || {};
|
|
8293
|
-
});
|
|
8294
|
-
}
|
|
8295
|
-
/** Retrieves metadata for a specific vector index */
|
|
8296
|
-
async getIndex(vectorBucketName, indexName) {
|
|
8297
|
-
return this.handleOperation(async () => {
|
|
8298
|
-
return await vectorsApi.post(this.fetch, `${this.url}/GetIndex`, {
|
|
8299
|
-
vectorBucketName,
|
|
8300
|
-
indexName
|
|
8301
|
-
}, {
|
|
8302
|
-
headers: this.headers
|
|
8303
|
-
});
|
|
8304
|
-
});
|
|
8305
|
-
}
|
|
8306
|
-
/** Lists vector indexes within a bucket with optional filtering and pagination */
|
|
8307
|
-
async listIndexes(options) {
|
|
8308
|
-
return this.handleOperation(async () => {
|
|
8309
|
-
return await vectorsApi.post(this.fetch, `${this.url}/ListIndexes`, options, {
|
|
8310
|
-
headers: this.headers
|
|
8311
|
-
});
|
|
8312
|
-
});
|
|
8313
|
-
}
|
|
8314
|
-
/** Deletes a vector index and all its data */
|
|
8315
|
-
async deleteIndex(vectorBucketName, indexName) {
|
|
8316
|
-
return this.handleOperation(async () => {
|
|
8317
|
-
const data = await vectorsApi.post(this.fetch, `${this.url}/DeleteIndex`, {
|
|
8318
|
-
vectorBucketName,
|
|
8319
|
-
indexName
|
|
8320
|
-
}, {
|
|
8321
|
-
headers: this.headers
|
|
8322
|
-
});
|
|
8323
|
-
return data || {};
|
|
8324
|
-
});
|
|
8325
|
-
}
|
|
8326
|
-
};
|
|
8327
|
-
|
|
8328
|
-
// src/vendor/storage/packages/VectorDataApi.ts
|
|
8329
|
-
var VectorDataApi = class extends BaseApiClient {
|
|
8330
|
-
static {
|
|
8331
|
-
__name(this, "VectorDataApi");
|
|
8332
|
-
}
|
|
8333
|
-
/** Creates a new VectorDataApi instance */
|
|
8334
|
-
constructor(url, headers = {}, fetch2) {
|
|
8335
|
-
const finalUrl = url.replace(/\/$/, "");
|
|
8336
|
-
const finalHeaders = {
|
|
8337
|
-
...DEFAULT_HEADERS,
|
|
8338
|
-
"Content-Type": "application/json",
|
|
8339
|
-
...headers
|
|
8340
|
-
};
|
|
8341
|
-
super(finalUrl, finalHeaders, fetch2, "vectors");
|
|
8342
|
-
}
|
|
8343
|
-
/** Inserts or updates vectors in batch (1-500 per request) */
|
|
8344
|
-
async putVectors(options) {
|
|
8345
|
-
if (options.vectors.length < 1 || options.vectors.length > 500) {
|
|
8346
|
-
throw new Error("Vector batch size must be between 1 and 500 items");
|
|
8347
|
-
}
|
|
8348
|
-
return this.handleOperation(async () => {
|
|
8349
|
-
const data = await vectorsApi.post(this.fetch, `${this.url}/PutVectors`, options, {
|
|
8350
|
-
headers: this.headers
|
|
8351
|
-
});
|
|
8352
|
-
return data || {};
|
|
8353
|
-
});
|
|
8354
|
-
}
|
|
8355
|
-
/** Retrieves vectors by their keys in batch */
|
|
8356
|
-
async getVectors(options) {
|
|
8357
|
-
return this.handleOperation(async () => {
|
|
8358
|
-
return await vectorsApi.post(this.fetch, `${this.url}/GetVectors`, options, {
|
|
8359
|
-
headers: this.headers
|
|
8360
|
-
});
|
|
8361
|
-
});
|
|
8362
|
-
}
|
|
8363
|
-
/** Lists vectors in an index with pagination */
|
|
8364
|
-
async listVectors(options) {
|
|
8365
|
-
if (options.segmentCount !== void 0) {
|
|
8366
|
-
if (options.segmentCount < 1 || options.segmentCount > 16) {
|
|
8367
|
-
throw new Error("segmentCount must be between 1 and 16");
|
|
8368
|
-
}
|
|
8369
|
-
if (options.segmentIndex !== void 0) {
|
|
8370
|
-
if (options.segmentIndex < 0 || options.segmentIndex >= options.segmentCount) {
|
|
8371
|
-
throw new Error(`segmentIndex must be between 0 and ${options.segmentCount - 1}`);
|
|
8372
|
-
}
|
|
8373
|
-
}
|
|
8374
|
-
}
|
|
8375
|
-
return this.handleOperation(async () => {
|
|
8376
|
-
return await vectorsApi.post(this.fetch, `${this.url}/ListVectors`, options, {
|
|
8377
|
-
headers: this.headers
|
|
8378
|
-
});
|
|
8379
|
-
});
|
|
8380
|
-
}
|
|
8381
|
-
/** Queries for similar vectors using approximate nearest neighbor search */
|
|
8382
|
-
async queryVectors(options) {
|
|
8383
|
-
return this.handleOperation(async () => {
|
|
8384
|
-
return await vectorsApi.post(this.fetch, `${this.url}/QueryVectors`, options, {
|
|
8385
|
-
headers: this.headers
|
|
8386
|
-
});
|
|
8387
|
-
});
|
|
8388
|
-
}
|
|
8389
|
-
/** Deletes vectors by their keys in batch (1-500 per request) */
|
|
8390
|
-
async deleteVectors(options) {
|
|
8391
|
-
if (options.keys.length < 1 || options.keys.length > 500) {
|
|
8392
|
-
throw new Error("Keys batch size must be between 1 and 500 items");
|
|
8393
|
-
}
|
|
8394
|
-
return this.handleOperation(async () => {
|
|
8395
|
-
const data = await vectorsApi.post(this.fetch, `${this.url}/DeleteVectors`, options, {
|
|
8396
|
-
headers: this.headers
|
|
8397
|
-
});
|
|
8398
|
-
return data || {};
|
|
8399
|
-
});
|
|
8400
|
-
}
|
|
8401
|
-
};
|
|
8402
|
-
|
|
8403
|
-
// src/vendor/storage/packages/VectorBucketApi.ts
|
|
8404
|
-
var VectorBucketApi = class extends BaseApiClient {
|
|
8405
|
-
static {
|
|
8406
|
-
__name(this, "VectorBucketApi");
|
|
8407
|
-
}
|
|
8408
|
-
/** Creates a new VectorBucketApi instance */
|
|
8409
|
-
constructor(url, headers = {}, fetch2) {
|
|
8410
|
-
const finalUrl = url.replace(/\/$/, "");
|
|
8411
|
-
const finalHeaders = {
|
|
8412
|
-
...DEFAULT_HEADERS,
|
|
8413
|
-
"Content-Type": "application/json",
|
|
8414
|
-
...headers
|
|
8415
|
-
};
|
|
8416
|
-
super(finalUrl, finalHeaders, fetch2, "vectors");
|
|
8417
|
-
}
|
|
8418
|
-
/** Creates a new vector bucket */
|
|
8419
|
-
async createBucket(vectorBucketName) {
|
|
8420
|
-
return this.handleOperation(async () => {
|
|
8421
|
-
const data = await vectorsApi.post(this.fetch, `${this.url}/CreateVectorBucket`, {
|
|
8422
|
-
vectorBucketName
|
|
8423
|
-
}, {
|
|
8424
|
-
headers: this.headers
|
|
8425
|
-
});
|
|
8426
|
-
return data || {};
|
|
8427
|
-
});
|
|
8428
|
-
}
|
|
8429
|
-
/** Retrieves metadata for a specific vector bucket */
|
|
8430
|
-
async getBucket(vectorBucketName) {
|
|
8431
|
-
return this.handleOperation(async () => {
|
|
8432
|
-
return await vectorsApi.post(this.fetch, `${this.url}/GetVectorBucket`, {
|
|
8433
|
-
vectorBucketName
|
|
8434
|
-
}, {
|
|
8435
|
-
headers: this.headers
|
|
8436
|
-
});
|
|
8437
|
-
});
|
|
8438
|
-
}
|
|
8439
|
-
/** Lists vector buckets with optional filtering and pagination */
|
|
8440
|
-
async listBuckets(options = {}) {
|
|
8441
|
-
return this.handleOperation(async () => {
|
|
8442
|
-
return await vectorsApi.post(this.fetch, `${this.url}/ListVectorBuckets`, options, {
|
|
8443
|
-
headers: this.headers
|
|
8444
|
-
});
|
|
8445
|
-
});
|
|
8446
|
-
}
|
|
8447
|
-
/** Deletes a vector bucket (must be empty first) */
|
|
8448
|
-
async deleteBucket(vectorBucketName) {
|
|
8449
|
-
return this.handleOperation(async () => {
|
|
8450
|
-
const data = await vectorsApi.post(this.fetch, `${this.url}/DeleteVectorBucket`, {
|
|
8451
|
-
vectorBucketName
|
|
8452
|
-
}, {
|
|
8453
|
-
headers: this.headers
|
|
8454
|
-
});
|
|
8455
|
-
return data || {};
|
|
8456
|
-
});
|
|
8457
|
-
}
|
|
8458
|
-
};
|
|
8459
|
-
|
|
8460
|
-
// src/vendor/storage/packages/StorageVectorsClient.ts
|
|
8461
|
-
var StorageVectorsClient = class extends VectorBucketApi {
|
|
8462
|
-
static {
|
|
8463
|
-
__name(this, "StorageVectorsClient");
|
|
8464
|
-
}
|
|
8465
|
-
/**
|
|
8466
|
-
* @alpha
|
|
8467
|
-
*
|
|
8468
|
-
* Creates a StorageVectorsClient that can manage buckets, indexes, and vectors.
|
|
8469
|
-
*
|
|
8470
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8471
|
-
*
|
|
8472
|
-
* @category Storage
|
|
8473
|
-
* @subcategory Vector Buckets
|
|
8474
|
-
* @param url - Base URL of the Storage Vectors REST API.
|
|
8475
|
-
* @param options.headers - Optional headers (for example `Authorization`) applied to every request.
|
|
8476
|
-
* @param options.fetch - Optional custom `fetch` implementation for non-browser runtimes.
|
|
8477
|
-
*
|
|
8478
|
-
* @example Using supabase-js (recommended)
|
|
8479
|
-
* ```typescript
|
|
8480
|
-
* import { createClient } from '@supabase/supabase-js'
|
|
8481
|
-
*
|
|
8482
|
-
* const supabase = createClient('https://xyzcompany.supabase.co', 'your-publishable-key')
|
|
8483
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8484
|
-
* ```
|
|
8485
|
-
*
|
|
8486
|
-
* @example Standalone import for bundle-sensitive environments
|
|
8487
|
-
* ```typescript
|
|
8488
|
-
* import { StorageVectorsClient } from '@supabase/storage-js'
|
|
8489
|
-
*
|
|
8490
|
-
* const client = new StorageVectorsClient(url, options)
|
|
8491
|
-
* ```
|
|
8492
|
-
*/
|
|
8493
|
-
constructor(url, options = {}) {
|
|
8494
|
-
super(url, options.headers || {}, options.fetch);
|
|
8495
|
-
}
|
|
8496
|
-
/**
|
|
8497
|
-
*
|
|
8498
|
-
* @alpha
|
|
8499
|
-
*
|
|
8500
|
-
* Access operations for a specific vector bucket
|
|
8501
|
-
* Returns a scoped client for index and vector operations within the bucket
|
|
8502
|
-
*
|
|
8503
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8504
|
-
*
|
|
8505
|
-
* @category Storage
|
|
8506
|
-
* @subcategory Vector Buckets
|
|
8507
|
-
* @param vectorBucketName - Name of the vector bucket
|
|
8508
|
-
* @returns Bucket-scoped client with index and vector operations
|
|
8509
|
-
*
|
|
8510
|
-
* @example Accessing a vector bucket
|
|
8511
|
-
* ```typescript
|
|
8512
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8513
|
-
* ```
|
|
8514
|
-
*/
|
|
8515
|
-
from(vectorBucketName) {
|
|
8516
|
-
return new VectorBucketScope(this.url, this.headers, vectorBucketName, this.fetch);
|
|
8517
|
-
}
|
|
8518
|
-
/**
|
|
8519
|
-
*
|
|
8520
|
-
* @alpha
|
|
8521
|
-
*
|
|
8522
|
-
* Creates a new vector bucket
|
|
8523
|
-
* Vector buckets are containers for vector indexes and their data
|
|
8524
|
-
*
|
|
8525
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8526
|
-
*
|
|
8527
|
-
* @category Storage
|
|
8528
|
-
* @subcategory Vector Buckets
|
|
8529
|
-
* @param vectorBucketName - Unique name for the vector bucket
|
|
8530
|
-
* @returns Promise with empty response on success or error
|
|
8531
|
-
*
|
|
8532
|
-
* @example Creating a vector bucket
|
|
8533
|
-
* ```typescript
|
|
8534
|
-
* const { data, error } = await supabase
|
|
8535
|
-
* .storage
|
|
8536
|
-
* .vectors
|
|
8537
|
-
* .createBucket('embeddings-prod')
|
|
8538
|
-
* ```
|
|
8539
|
-
*/
|
|
8540
|
-
async createBucket(vectorBucketName) {
|
|
8541
|
-
return super.createBucket(vectorBucketName);
|
|
8542
|
-
}
|
|
8543
|
-
/**
|
|
8544
|
-
*
|
|
8545
|
-
* @alpha
|
|
8546
|
-
*
|
|
8547
|
-
* Retrieves metadata for a specific vector bucket
|
|
8548
|
-
*
|
|
8549
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8550
|
-
*
|
|
8551
|
-
* @category Storage
|
|
8552
|
-
* @subcategory Vector Buckets
|
|
8553
|
-
* @param vectorBucketName - Name of the vector bucket
|
|
8554
|
-
* @returns Promise with bucket metadata or error
|
|
8555
|
-
*
|
|
8556
|
-
* @example Get bucket metadata
|
|
8557
|
-
* ```typescript
|
|
8558
|
-
* const { data, error } = await supabase
|
|
8559
|
-
* .storage
|
|
8560
|
-
* .vectors
|
|
8561
|
-
* .getBucket('embeddings-prod')
|
|
8562
|
-
*
|
|
8563
|
-
* console.log('Bucket created:', data?.vectorBucket.creationTime)
|
|
8564
|
-
* ```
|
|
8565
|
-
*/
|
|
8566
|
-
async getBucket(vectorBucketName) {
|
|
8567
|
-
return super.getBucket(vectorBucketName);
|
|
8568
|
-
}
|
|
8569
|
-
/**
|
|
8570
|
-
*
|
|
8571
|
-
* @alpha
|
|
8572
|
-
*
|
|
8573
|
-
* Lists all vector buckets with optional filtering and pagination
|
|
8574
|
-
*
|
|
8575
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8576
|
-
*
|
|
8577
|
-
* @category Storage
|
|
8578
|
-
* @subcategory Vector Buckets
|
|
8579
|
-
* @param options - Optional filters (prefix, maxResults, nextToken)
|
|
8580
|
-
* @returns Promise with list of buckets or error
|
|
8581
|
-
*
|
|
8582
|
-
* @example List vector buckets
|
|
8583
|
-
* ```typescript
|
|
8584
|
-
* const { data, error } = await supabase
|
|
8585
|
-
* .storage
|
|
8586
|
-
* .vectors
|
|
8587
|
-
* .listBuckets({ prefix: 'embeddings-' })
|
|
8588
|
-
*
|
|
8589
|
-
* data?.vectorBuckets.forEach(bucket => {
|
|
8590
|
-
* console.log(bucket.vectorBucketName)
|
|
8591
|
-
* })
|
|
8592
|
-
* ```
|
|
8593
|
-
*/
|
|
8594
|
-
async listBuckets(options = {}) {
|
|
8595
|
-
return super.listBuckets(options);
|
|
8596
|
-
}
|
|
8597
|
-
/**
|
|
8598
|
-
*
|
|
8599
|
-
* @alpha
|
|
8600
|
-
*
|
|
8601
|
-
* Deletes a vector bucket (bucket must be empty)
|
|
8602
|
-
* All indexes must be deleted before deleting the bucket
|
|
8603
|
-
*
|
|
8604
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8605
|
-
*
|
|
8606
|
-
* @category Storage
|
|
8607
|
-
* @subcategory Vector Buckets
|
|
8608
|
-
* @param vectorBucketName - Name of the vector bucket to delete
|
|
8609
|
-
* @returns Promise with empty response on success or error
|
|
8610
|
-
*
|
|
8611
|
-
* @example Delete a vector bucket
|
|
8612
|
-
* ```typescript
|
|
8613
|
-
* const { data, error } = await supabase
|
|
8614
|
-
* .storage
|
|
8615
|
-
* .vectors
|
|
8616
|
-
* .deleteBucket('embeddings-old')
|
|
8617
|
-
* ```
|
|
8618
|
-
*/
|
|
8619
|
-
async deleteBucket(vectorBucketName) {
|
|
8620
|
-
return super.deleteBucket(vectorBucketName);
|
|
8621
|
-
}
|
|
8622
|
-
};
|
|
8623
|
-
var VectorBucketScope = class extends VectorIndexApi {
|
|
8624
|
-
static {
|
|
8625
|
-
__name(this, "VectorBucketScope");
|
|
8626
|
-
}
|
|
8627
|
-
vectorBucketName;
|
|
8628
|
-
/**
|
|
8629
|
-
* @alpha
|
|
8630
|
-
*
|
|
8631
|
-
* Creates a helper that automatically scopes all index operations to the provided bucket.
|
|
8632
|
-
*
|
|
8633
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8634
|
-
*
|
|
8635
|
-
* @category Storage
|
|
8636
|
-
* @subcategory Vector Buckets
|
|
8637
|
-
* @example Creating a vector bucket scope
|
|
8638
|
-
* ```typescript
|
|
8639
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8640
|
-
* ```
|
|
8641
|
-
*/
|
|
8642
|
-
constructor(url, headers, vectorBucketName, fetch2) {
|
|
8643
|
-
super(url, headers, fetch2);
|
|
8644
|
-
this.vectorBucketName = vectorBucketName;
|
|
8645
|
-
}
|
|
8646
|
-
/**
|
|
8647
|
-
*
|
|
8648
|
-
* @alpha
|
|
8649
|
-
*
|
|
8650
|
-
* Creates a new vector index in this bucket
|
|
8651
|
-
* Convenience method that automatically includes the bucket name
|
|
8652
|
-
*
|
|
8653
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8654
|
-
*
|
|
8655
|
-
* @category Storage
|
|
8656
|
-
* @subcategory Vector Buckets
|
|
8657
|
-
* @param options - Index configuration (vectorBucketName is automatically set)
|
|
8658
|
-
* @returns Promise with empty response on success or error
|
|
8659
|
-
*
|
|
8660
|
-
* @example Creating a vector index
|
|
8661
|
-
* ```typescript
|
|
8662
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8663
|
-
* await bucket.createIndex({
|
|
8664
|
-
* indexName: 'documents-openai',
|
|
8665
|
-
* dataType: 'float32',
|
|
8666
|
-
* dimension: 1536,
|
|
8667
|
-
* distanceMetric: 'cosine',
|
|
8668
|
-
* metadataConfiguration: {
|
|
8669
|
-
* nonFilterableMetadataKeys: ['raw_text']
|
|
8670
|
-
* }
|
|
8671
|
-
* })
|
|
8672
|
-
* ```
|
|
8673
|
-
*/
|
|
8674
|
-
async createIndex(options) {
|
|
8675
|
-
return super.createIndex({
|
|
8676
|
-
...options,
|
|
8677
|
-
vectorBucketName: this.vectorBucketName
|
|
8678
|
-
});
|
|
8679
|
-
}
|
|
8680
|
-
/**
|
|
8681
|
-
*
|
|
8682
|
-
* @alpha
|
|
8683
|
-
*
|
|
8684
|
-
* Lists indexes in this bucket
|
|
8685
|
-
* Convenience method that automatically includes the bucket name
|
|
8686
|
-
*
|
|
8687
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8688
|
-
*
|
|
8689
|
-
* @category Storage
|
|
8690
|
-
* @subcategory Vector Buckets
|
|
8691
|
-
* @param options - Listing options (vectorBucketName is automatically set)
|
|
8692
|
-
* @returns Promise with response containing indexes array and pagination token or error
|
|
8693
|
-
*
|
|
8694
|
-
* @example List indexes
|
|
8695
|
-
* ```typescript
|
|
8696
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8697
|
-
* const { data } = await bucket.listIndexes({ prefix: 'documents-' })
|
|
8698
|
-
* ```
|
|
8699
|
-
*/
|
|
8700
|
-
async listIndexes(options = {}) {
|
|
8701
|
-
return super.listIndexes({
|
|
8702
|
-
...options,
|
|
8703
|
-
vectorBucketName: this.vectorBucketName
|
|
8704
|
-
});
|
|
8705
|
-
}
|
|
8706
|
-
/**
|
|
8707
|
-
*
|
|
8708
|
-
* @alpha
|
|
8709
|
-
*
|
|
8710
|
-
* Retrieves metadata for a specific index in this bucket
|
|
8711
|
-
* Convenience method that automatically includes the bucket name
|
|
8712
|
-
*
|
|
8713
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8714
|
-
*
|
|
8715
|
-
* @category Storage
|
|
8716
|
-
* @subcategory Vector Buckets
|
|
8717
|
-
* @param indexName - Name of the index to retrieve
|
|
8718
|
-
* @returns Promise with index metadata or error
|
|
8719
|
-
*
|
|
8720
|
-
* @example Get index metadata
|
|
8721
|
-
* ```typescript
|
|
8722
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8723
|
-
* const { data } = await bucket.getIndex('documents-openai')
|
|
8724
|
-
* console.log('Dimension:', data?.index.dimension)
|
|
8725
|
-
* ```
|
|
8726
|
-
*/
|
|
8727
|
-
async getIndex(indexName) {
|
|
8728
|
-
return super.getIndex(this.vectorBucketName, indexName);
|
|
8729
|
-
}
|
|
8730
|
-
/**
|
|
8731
|
-
*
|
|
8732
|
-
* @alpha
|
|
8733
|
-
*
|
|
8734
|
-
* Deletes an index from this bucket
|
|
8735
|
-
* Convenience method that automatically includes the bucket name
|
|
8736
|
-
*
|
|
8737
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8738
|
-
*
|
|
8739
|
-
* @category Storage
|
|
8740
|
-
* @subcategory Vector Buckets
|
|
8741
|
-
* @param indexName - Name of the index to delete
|
|
8742
|
-
* @returns Promise with empty response on success or error
|
|
8743
|
-
*
|
|
8744
|
-
* @example Delete an index
|
|
8745
|
-
* ```typescript
|
|
8746
|
-
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
8747
|
-
* await bucket.deleteIndex('old-index')
|
|
8748
|
-
* ```
|
|
8749
|
-
*/
|
|
8750
|
-
async deleteIndex(indexName) {
|
|
8751
|
-
return super.deleteIndex(this.vectorBucketName, indexName);
|
|
8752
|
-
}
|
|
8753
|
-
/**
|
|
8754
|
-
*
|
|
8755
|
-
* @alpha
|
|
8756
|
-
*
|
|
8757
|
-
* Access operations for a specific index within this bucket
|
|
8758
|
-
* Returns a scoped client for vector data operations
|
|
8759
|
-
*
|
|
8760
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8761
|
-
*
|
|
8762
|
-
* @category Storage
|
|
8763
|
-
* @subcategory Vector Buckets
|
|
8764
|
-
* @param indexName - Name of the index
|
|
8765
|
-
* @returns Index-scoped client with vector data operations
|
|
8766
|
-
*
|
|
8767
|
-
* @example Accessing an index
|
|
8768
|
-
* ```typescript
|
|
8769
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8770
|
-
*
|
|
8771
|
-
* // Insert vectors
|
|
8772
|
-
* await index.putVectors({
|
|
8773
|
-
* vectors: [
|
|
8774
|
-
* { key: 'doc-1', data: { float32: [...] }, metadata: { title: 'Intro' } }
|
|
8775
|
-
* ]
|
|
8776
|
-
* })
|
|
8777
|
-
*
|
|
8778
|
-
* // Query similar vectors
|
|
8779
|
-
* const { data } = await index.queryVectors({
|
|
8780
|
-
* queryVector: { float32: [...] },
|
|
8781
|
-
* topK: 5
|
|
8782
|
-
* })
|
|
8783
|
-
* ```
|
|
8784
|
-
*/
|
|
8785
|
-
index(indexName) {
|
|
8786
|
-
return new VectorIndexScope(this.url, this.headers, this.vectorBucketName, indexName, this.fetch);
|
|
8787
|
-
}
|
|
8788
|
-
};
|
|
8789
|
-
var VectorIndexScope = class extends VectorDataApi {
|
|
8790
|
-
static {
|
|
8791
|
-
__name(this, "VectorIndexScope");
|
|
8792
|
-
}
|
|
8793
|
-
vectorBucketName;
|
|
8794
|
-
indexName;
|
|
8795
|
-
/**
|
|
8796
|
-
*
|
|
8797
|
-
* @alpha
|
|
8798
|
-
*
|
|
8799
|
-
* Creates a helper that automatically scopes all vector operations to the provided bucket/index names.
|
|
8800
|
-
*
|
|
8801
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8802
|
-
*
|
|
8803
|
-
* @category Storage
|
|
8804
|
-
* @subcategory Vector Buckets
|
|
8805
|
-
* @example Creating a vector index scope
|
|
8806
|
-
* ```typescript
|
|
8807
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8808
|
-
* ```
|
|
8809
|
-
*/
|
|
8810
|
-
constructor(url, headers, vectorBucketName, indexName, fetch2) {
|
|
8811
|
-
super(url, headers, fetch2);
|
|
8812
|
-
this.vectorBucketName = vectorBucketName;
|
|
8813
|
-
this.indexName = indexName;
|
|
8814
|
-
}
|
|
8815
|
-
/**
|
|
8816
|
-
*
|
|
8817
|
-
* @alpha
|
|
8818
|
-
*
|
|
8819
|
-
* Inserts or updates vectors in this index
|
|
8820
|
-
* Convenience method that automatically includes bucket and index names
|
|
8821
|
-
*
|
|
8822
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8823
|
-
*
|
|
8824
|
-
* @category Storage
|
|
8825
|
-
* @subcategory Vector Buckets
|
|
8826
|
-
* @param options - Vector insertion options (bucket and index names automatically set)
|
|
8827
|
-
* @returns Promise with empty response on success or error
|
|
8828
|
-
*
|
|
8829
|
-
* @example Insert vectors into an index
|
|
8830
|
-
* ```typescript
|
|
8831
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8832
|
-
* await index.putVectors({
|
|
8833
|
-
* vectors: [
|
|
8834
|
-
* {
|
|
8835
|
-
* key: 'doc-1',
|
|
8836
|
-
* data: { float32: [0.1, 0.2, ...] },
|
|
8837
|
-
* metadata: { title: 'Introduction', page: 1 }
|
|
8838
|
-
* }
|
|
8839
|
-
* ]
|
|
8840
|
-
* })
|
|
8841
|
-
* ```
|
|
8842
|
-
*/
|
|
8843
|
-
async putVectors(options) {
|
|
8844
|
-
return super.putVectors({
|
|
8845
|
-
...options,
|
|
8846
|
-
vectorBucketName: this.vectorBucketName,
|
|
8847
|
-
indexName: this.indexName
|
|
8848
|
-
});
|
|
8849
|
-
}
|
|
8850
|
-
/**
|
|
8851
|
-
*
|
|
8852
|
-
* @alpha
|
|
8853
|
-
*
|
|
8854
|
-
* Retrieves vectors by keys from this index
|
|
8855
|
-
* Convenience method that automatically includes bucket and index names
|
|
8856
|
-
*
|
|
8857
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8858
|
-
*
|
|
8859
|
-
* @category Storage
|
|
8860
|
-
* @subcategory Vector Buckets
|
|
8861
|
-
* @param options - Vector retrieval options (bucket and index names automatically set)
|
|
8862
|
-
* @returns Promise with response containing vectors array or error
|
|
8863
|
-
*
|
|
8864
|
-
* @example Get vectors by keys
|
|
8865
|
-
* ```typescript
|
|
8866
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8867
|
-
* const { data } = await index.getVectors({
|
|
8868
|
-
* keys: ['doc-1', 'doc-2'],
|
|
8869
|
-
* returnMetadata: true
|
|
8870
|
-
* })
|
|
8871
|
-
* ```
|
|
8872
|
-
*/
|
|
8873
|
-
async getVectors(options) {
|
|
8874
|
-
return super.getVectors({
|
|
8875
|
-
...options,
|
|
8876
|
-
vectorBucketName: this.vectorBucketName,
|
|
8877
|
-
indexName: this.indexName
|
|
8878
|
-
});
|
|
8879
|
-
}
|
|
8880
|
-
/**
|
|
8881
|
-
*
|
|
8882
|
-
* @alpha
|
|
8883
|
-
*
|
|
8884
|
-
* Lists vectors in this index with pagination
|
|
8885
|
-
* Convenience method that automatically includes bucket and index names
|
|
8886
|
-
*
|
|
8887
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8888
|
-
*
|
|
8889
|
-
* @category Storage
|
|
8890
|
-
* @subcategory Vector Buckets
|
|
8891
|
-
* @param options - Listing options (bucket and index names automatically set)
|
|
8892
|
-
* @returns Promise with response containing vectors array and pagination token or error
|
|
8893
|
-
*
|
|
8894
|
-
* @example List vectors with pagination
|
|
8895
|
-
* ```typescript
|
|
8896
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8897
|
-
* const { data } = await index.listVectors({
|
|
8898
|
-
* maxResults: 500,
|
|
8899
|
-
* returnMetadata: true
|
|
8900
|
-
* })
|
|
8901
|
-
* ```
|
|
8902
|
-
*/
|
|
8903
|
-
async listVectors(options = {}) {
|
|
8904
|
-
return super.listVectors({
|
|
8905
|
-
...options,
|
|
8906
|
-
vectorBucketName: this.vectorBucketName,
|
|
8907
|
-
indexName: this.indexName
|
|
8908
|
-
});
|
|
8909
|
-
}
|
|
8910
|
-
/**
|
|
8911
|
-
*
|
|
8912
|
-
* @alpha
|
|
8913
|
-
*
|
|
8914
|
-
* Queries for similar vectors in this index
|
|
8915
|
-
* Convenience method that automatically includes bucket and index names
|
|
8916
|
-
*
|
|
8917
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8918
|
-
*
|
|
8919
|
-
* @category Storage
|
|
8920
|
-
* @subcategory Vector Buckets
|
|
8921
|
-
* @param options - Query options (bucket and index names automatically set)
|
|
8922
|
-
* @returns Promise with response containing matches array of similar vectors ordered by distance or error
|
|
8923
|
-
*
|
|
8924
|
-
* @example Query similar vectors
|
|
8925
|
-
* ```typescript
|
|
8926
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8927
|
-
* const { data } = await index.queryVectors({
|
|
8928
|
-
* queryVector: { float32: [0.1, 0.2, ...] },
|
|
8929
|
-
* topK: 5,
|
|
8930
|
-
* filter: { category: 'technical' },
|
|
8931
|
-
* returnDistance: true,
|
|
8932
|
-
* returnMetadata: true
|
|
8933
|
-
* })
|
|
8934
|
-
* ```
|
|
8935
|
-
*/
|
|
8936
|
-
async queryVectors(options) {
|
|
8937
|
-
return super.queryVectors({
|
|
8938
|
-
...options,
|
|
8939
|
-
vectorBucketName: this.vectorBucketName,
|
|
8940
|
-
indexName: this.indexName
|
|
8941
|
-
});
|
|
8942
|
-
}
|
|
8943
|
-
/**
|
|
8944
|
-
*
|
|
8945
|
-
* @alpha
|
|
8946
|
-
*
|
|
8947
|
-
* Deletes vectors by keys from this index
|
|
8948
|
-
* Convenience method that automatically includes bucket and index names
|
|
8949
|
-
*
|
|
8950
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
8951
|
-
*
|
|
8952
|
-
* @category Storage
|
|
8953
|
-
* @subcategory Vector Buckets
|
|
8954
|
-
* @param options - Deletion options (bucket and index names automatically set)
|
|
8955
|
-
* @returns Promise with empty response on success or error
|
|
8956
|
-
*
|
|
8957
|
-
* @example Delete vectors by keys
|
|
8958
|
-
* ```typescript
|
|
8959
|
-
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
8960
|
-
* await index.deleteVectors({
|
|
8961
|
-
* keys: ['doc-1', 'doc-2', 'doc-3']
|
|
8962
|
-
* })
|
|
8963
|
-
* ```
|
|
8964
|
-
*/
|
|
8965
|
-
async deleteVectors(options) {
|
|
8966
|
-
return super.deleteVectors({
|
|
8967
|
-
...options,
|
|
8968
|
-
vectorBucketName: this.vectorBucketName,
|
|
8969
|
-
indexName: this.indexName
|
|
8970
|
-
});
|
|
8971
|
-
}
|
|
8972
|
-
};
|
|
8973
|
-
|
|
8974
|
-
// src/vendor/storage/StorageClient.ts
|
|
8975
|
-
var StorageClient = class extends StorageBucketApi {
|
|
8976
|
-
static {
|
|
8977
|
-
__name(this, "StorageClient");
|
|
8978
|
-
}
|
|
8979
|
-
/**
|
|
8980
|
-
* Creates a client for Storage buckets, files, analytics, and vectors.
|
|
8981
|
-
*
|
|
8982
|
-
* @category Storage
|
|
8983
|
-
* @subcategory File Buckets
|
|
8984
|
-
*
|
|
8985
|
-
* @example Using supabase-js (recommended)
|
|
8986
|
-
* ```ts
|
|
8987
|
-
* import { createClient } from '@supabase/supabase-js'
|
|
8988
|
-
*
|
|
8989
|
-
* const supabase = createClient('https://xyzcompany.supabase.co', 'your-publishable-key')
|
|
8990
|
-
* const avatars = supabase.storage.from('avatars')
|
|
8991
|
-
* ```
|
|
8992
|
-
*
|
|
8993
|
-
* @example Standalone import for bundle-sensitive environments
|
|
8994
|
-
* ```ts
|
|
8995
|
-
* import { StorageClient } from '@supabase/storage-js'
|
|
8996
|
-
*
|
|
8997
|
-
* const storage = new StorageClient('https://xyzcompany.supabase.co/storage/v1', {
|
|
8998
|
-
* apikey: 'your-publishable-key',
|
|
8999
|
-
* })
|
|
9000
|
-
* const avatars = storage.from('avatars')
|
|
9001
|
-
* ```
|
|
9002
|
-
*/
|
|
9003
|
-
constructor(url, headers = {}, fetch2, opts) {
|
|
9004
|
-
super(url, headers, fetch2, opts);
|
|
9005
|
-
}
|
|
9006
|
-
/**
|
|
9007
|
-
* Perform file operation in a bucket.
|
|
9008
|
-
*
|
|
9009
|
-
* @category Storage
|
|
9010
|
-
* @subcategory File Buckets
|
|
9011
|
-
*
|
|
9012
|
-
* @param id The bucket id to operate on.
|
|
9013
|
-
*
|
|
9014
|
-
* @example Accessing a bucket
|
|
9015
|
-
* ```typescript
|
|
9016
|
-
* const avatars = supabase.storage.from('avatars')
|
|
9017
|
-
* ```
|
|
9018
|
-
*/
|
|
9019
|
-
from(id) {
|
|
9020
|
-
return new StorageFileApi(this.url, this.headers, id, this.fetch);
|
|
9021
|
-
}
|
|
9022
|
-
/**
|
|
9023
|
-
*
|
|
9024
|
-
* @alpha
|
|
9025
|
-
*
|
|
9026
|
-
* Access vector storage operations.
|
|
9027
|
-
*
|
|
9028
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
9029
|
-
*
|
|
9030
|
-
* @category Storage
|
|
9031
|
-
* @subcategory Vector Buckets
|
|
9032
|
-
*
|
|
9033
|
-
* @returns A StorageVectorsClient instance configured with the current storage settings.
|
|
9034
|
-
*/
|
|
9035
|
-
get vectors() {
|
|
9036
|
-
return new StorageVectorsClient(this.url + "/vector", {
|
|
9037
|
-
headers: this.headers,
|
|
9038
|
-
fetch: this.fetch
|
|
9039
|
-
});
|
|
9040
|
-
}
|
|
9041
|
-
/**
|
|
9042
|
-
*
|
|
9043
|
-
* @alpha
|
|
9044
|
-
*
|
|
9045
|
-
* Access analytics storage operations using Iceberg tables.
|
|
9046
|
-
*
|
|
9047
|
-
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
9048
|
-
*
|
|
9049
|
-
* @category Storage
|
|
9050
|
-
* @subcategory Analytics Buckets
|
|
9051
|
-
*
|
|
9052
|
-
* @returns A StorageAnalyticsClient instance configured with the current storage settings.
|
|
9053
|
-
*/
|
|
9054
|
-
get analytics() {
|
|
9055
|
-
return new StorageAnalyticsClient(this.url + "/iceberg", this.headers, this.fetch);
|
|
9056
|
-
}
|
|
9057
|
-
};
|
|
9058
|
-
|
|
9059
|
-
// src/modules/storage.ts
|
|
9060
|
-
var RUNTIME_STORAGE_BUCKET = "runtime";
|
|
9061
|
-
var DEFAULT_SIGNED_URL_TTL_SECONDS = 10 * 60;
|
|
9062
|
-
var MAX_SIGNED_URL_TTL_SECONDS = 60 * 60;
|
|
9063
|
-
var CloudStoragePathError = class extends Error {
|
|
9064
|
-
static {
|
|
9065
|
-
__name(this, "CloudStoragePathError");
|
|
9066
|
-
}
|
|
9067
|
-
constructor(message) {
|
|
9068
|
-
super(message);
|
|
9069
|
-
this.name = "CloudStoragePathError";
|
|
9070
|
-
}
|
|
9071
|
-
};
|
|
9072
|
-
var WorkBuddyStorageDownload = class {
|
|
9073
|
-
static {
|
|
9074
|
-
__name(this, "WorkBuddyStorageDownload");
|
|
9075
|
-
}
|
|
9076
|
-
blob;
|
|
9077
|
-
stream;
|
|
9078
|
-
[Symbol.toStringTag] = "WorkBuddyStorageDownload";
|
|
9079
|
-
constructor(blob, stream) {
|
|
9080
|
-
this.blob = blob;
|
|
9081
|
-
this.stream = stream;
|
|
9082
|
-
}
|
|
9083
|
-
asStream() {
|
|
9084
|
-
return this.stream();
|
|
9085
|
-
}
|
|
9086
|
-
then(onfulfilled, onrejected) {
|
|
9087
|
-
return this.blob().then(onfulfilled, onrejected);
|
|
7638
|
+
then(onfulfilled, onrejected) {
|
|
7639
|
+
return this.blob().then(onfulfilled, onrejected);
|
|
9088
7640
|
}
|
|
9089
7641
|
catch(onrejected) {
|
|
9090
7642
|
return this.blob().catch(onrejected);
|
|
@@ -9198,7 +7750,9 @@ var WorkBuddyStorageModule = class extends WorkBuddyStorageBucket {
|
|
|
9198
7750
|
}
|
|
9199
7751
|
};
|
|
9200
7752
|
function createStorageModule(config, fetch2) {
|
|
9201
|
-
const client =
|
|
7753
|
+
const client = {
|
|
7754
|
+
from: /* @__PURE__ */ __name((bucketID) => new StorageFileApi(`${config.endpoint}${CLOUD_MODULE_PATHS.storage}`, DEFAULT_HEADERS, bucketID, fetch2), "from")
|
|
7755
|
+
};
|
|
9202
7756
|
return new WorkBuddyStorageModule(client);
|
|
9203
7757
|
}
|
|
9204
7758
|
__name(createStorageModule, "createStorageModule");
|