@supabase/storage-js 2.100.0 → 2.100.1
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/dist/index.cjs +147 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -23
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +145 -23
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +147 -25
- package/dist/index.mjs.map +1 -1
- package/dist/umd/supabase.js +1 -1
- package/package.json +1 -1
- package/src/StorageClient.ts +2 -2
- package/src/lib/common/BaseApiClient.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/src/packages/StorageAnalyticsClient.ts +12 -1
- package/src/packages/StorageBucketApi.ts +36 -0
- package/src/packages/StorageFileApi.ts +77 -2
- package/src/packages/StorageVectorsClient.ts +18 -18
package/dist/umd/supabase.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var supabase=(function(e){var t=class extends Error{constructor(e,t=`storage`,n,r){super(e),this.__isStorageError=!0,this.namespace=t,this.name=t===`vectors`?`StorageVectorsError`:`StorageError`,this.status=n,this.statusCode=r}};function n(e){return typeof e==`object`&&!!e&&`__isStorageError`in e}var r=class extends t{constructor(e,t,n,r=`storage`){super(e,r,t,n),this.name=r===`vectors`?`StorageVectorsApiError`:`StorageApiError`,this.status=t,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},i=class extends t{constructor(e,t,n=`storage`){super(e,n),this.name=n===`vectors`?`StorageVectorsUnknownError`:`StorageUnknownError`,this.originalError=t}},a=class extends t{constructor(e){super(e,`vectors`)}};function o(e){return n(e)&&e.namespace===`vectors`}var s=class extends r{constructor(e,t,n){super(e,t,n,`vectors`)}},c=class extends i{constructor(e,t){super(e,t,`vectors`)}};let l=function(e){return e.InternalError=`InternalError`,e.S3VectorConflictException=`S3VectorConflictException`,e.S3VectorNotFoundException=`S3VectorNotFoundException`,e.S3VectorBucketNotEmpty=`S3VectorBucketNotEmpty`,e.S3VectorMaxBucketsExceeded=`S3VectorMaxBucketsExceeded`,e.S3VectorMaxIndexesExceeded=`S3VectorMaxIndexesExceeded`,e}({}),u=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),d=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},f=e=>{if(Array.isArray(e))return e.map(e=>f(e));if(typeof e==`function`||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,n])=>{let r=e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,``));t[r]=f(n)}),t},p=e=>!e||typeof e!=`string`||e.length===0||e.length>100||e.trim()!==e||e.includes(`/`)||e.includes(`\\`)?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(e),m=e=>e.msg||e.message||e.error_description||(typeof e.error==`string`?e.error:e.error?.message)||JSON.stringify(e),h=async(e,t,n,a)=>{if(typeof e==`object`&&e&&typeof e.json==`function`){let n=e,i=parseInt(n.status,10);Number.isFinite(i)||(i=500),n.json().then(e=>{let n=e?.statusCode||e?.code||i+``;t(new r(m(e),i,n,a))}).catch(()=>{let e=i+``;t(new r(n.statusText||`HTTP ${i} error`,i,e,a))})}else t(new i(m(e),e,a))},g=(e,t,n,r)=>{let i={method:e,headers:t?.headers||{}};return e===`GET`||e===`HEAD`||!r?{...i,...n}:(d(r)?(i.headers={"Content-Type":`application/json`,...t?.headers},i.body=JSON.stringify(r)):i.body=r,t?.duplex&&(i.duplex=t.duplex),{...i,...n})};async function _(e,t,n,r,i,a,o){return new Promise((s,c)=>{e(n,g(t,r,i,a)).then(e=>{if(!e.ok)throw e;if(r?.noResolveJson)return e;if(o===`vectors`){let t=e.headers.get(`content-type`);if(e.headers.get(`content-length`)===`0`||e.status===204||!t||!t.includes(`application/json`))return{}}return e.json()}).then(e=>s(e)).catch(e=>h(e,c,r,o))})}function v(e=`storage`){return{get:async(t,n,r,i)=>_(t,`GET`,n,r,i,void 0,e),post:async(t,n,r,i,a)=>_(t,`POST`,n,i,a,r,e),put:async(t,n,r,i,a)=>_(t,`PUT`,n,i,a,r,e),head:async(t,n,r,i)=>_(t,`HEAD`,n,{...r,noResolveJson:!0},i,void 0,e),remove:async(t,n,r,i,a)=>_(t,`DELETE`,n,i,a,r,e)}}let{get:y,post:b,put:x,head:S,remove:C}=v(`storage`),w=v(`vectors`);var T=class{constructor(e,t={},n,r=`storage`){this.shouldThrowOnError=!1,this.url=e,this.headers=t,this.fetch=u(n),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers={...this.headers,[e]:t},this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e))return{data:null,error:e};throw e}}},E=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e))return{data:null,error:e};throw e}}};let D;var O=class{static{D=Symbol.toStringTag}constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[D]=`BlobDownloadBuilder`,this.promise=null}asStream(){return new E(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||=this.execute(),this.promise}async execute(){try{return{data:await(await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e))return{data:null,error:e};throw e}}};let k={limit:100,offset:0,sortBy:{column:`name`,order:`asc`}},A={cacheControl:`3600`,contentType:`text/plain;charset=UTF-8`,upsert:!1};var j=class extends T{constructor(e,t={},n,r){super(e,t,r,`storage`),this.bucketId=n}async uploadOrUpdate(e,t,n,r){return this.handleOperation(async()=>{let i,a={...A,...r},o={...this.headers,...e===`POST`&&{"x-upsert":String(a.upsert)}},s=a.metadata;typeof Blob<`u`&&n instanceof Blob?(i=new FormData,i.append(`cacheControl`,a.cacheControl),s&&i.append(`metadata`,this.encodeMetadata(s)),i.append(``,n)):typeof FormData<`u`&&n instanceof FormData?(i=n,i.has(`cacheControl`)||i.append(`cacheControl`,a.cacheControl),s&&!i.has(`metadata`)&&i.append(`metadata`,this.encodeMetadata(s))):(i=n,o[`cache-control`]=`max-age=${a.cacheControl}`,o[`content-type`]=a.contentType,s&&(o[`x-metadata`]=this.toBase64(this.encodeMetadata(s))),(typeof ReadableStream<`u`&&i instanceof ReadableStream||i&&typeof i==`object`&&`pipe`in i&&typeof i.pipe==`function`)&&!a.duplex&&(a.duplex=`half`)),r?.headers&&(o={...o,...r.headers});let c=this._removeEmptyFolders(t),l=this._getFinalPath(c),u=await(e==`PUT`?x:b)(this.fetch,`${this.url}/object/${l}`,i,{headers:o,...a?.duplex?{duplex:a.duplex}:{}});return{path:c,id:u.Id,fullPath:u.Key}})}async upload(e,t,n){return this.uploadOrUpdate(`POST`,e,t,n)}async uploadToSignedUrl(e,t,n,r){let i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);return o.searchParams.set(`token`,t),this.handleOperation(async()=>{let e,t={upsert:A.upsert,...r},a={...this.headers,"x-upsert":String(t.upsert)};return typeof Blob<`u`&&n instanceof Blob?(e=new FormData,e.append(`cacheControl`,t.cacheControl),e.append(``,n)):typeof FormData<`u`&&n instanceof FormData?(e=n,e.append(`cacheControl`,t.cacheControl)):(e=n,a[`cache-control`]=`max-age=${t.cacheControl}`,a[`content-type`]=t.contentType),{path:i,fullPath:(await x(this.fetch,o.toString(),e,{headers:a})).Key}})}async createSignedUploadUrl(e,n){return this.handleOperation(async()=>{let r=this._getFinalPath(e),i={...this.headers};n?.upsert&&(i[`x-upsert`]=`true`);let a=await b(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:i}),o=new URL(this.url+a.url),s=o.searchParams.get(`token`);if(!s)throw new t(`No token returned by API`);return{signedUrl:o.toString(),path:e,token:s}})}async update(e,t,n){return this.uploadOrUpdate(`PUT`,e,t,n)}async move(e,t,n){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n?.destinationBucket},{headers:this.headers}))}async copy(e,t,n){return this.handleOperation(async()=>({path:(await b(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n?.destinationBucket},{headers:this.headers})).Key}))}async createSignedUrl(e,t,n){return this.handleOperation(async()=>{let r=this._getFinalPath(e),i=typeof n?.transform==`object`&&n.transform!==null&&Object.keys(n.transform).length>0,a=await b(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:t,...i?{transform:n.transform}:{}},{headers:this.headers}),o=n?.download?`&download=${n.download===!0?``:n.download}`:``,s=i&&a.signedURL.includes(`/object/sign/`)?a.signedURL.replace(`/object/sign/`,`/render/image/sign/`):a.signedURL;return{signedUrl:encodeURI(`${this.url}${s}${o}`)}})}async createSignedUrls(e,t,n){return this.handleOperation(async()=>{let r=await b(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=n?.download?`&download=${n.download===!0?``:n.download}`:``;return r.map(e=>({...e,signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null}))})}download(e,t,n){let r=t?.transform===void 0?`object`:`render/image/authenticated`,i=this.transformOptsToQueryString(t?.transform||{}),a=i?`?${i}`:``,o=this._getFinalPath(e);return new O(()=>y(this.fetch,`${this.url}/${r}/${o}${a}`,{headers:this.headers,noResolveJson:!0},n),this.shouldThrowOnError)}async info(e){let t=this._getFinalPath(e);return this.handleOperation(async()=>f(await y(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers})))}async exists(e){let t=this._getFinalPath(e);try{return await S(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e)){let t=e instanceof r?e.status:e instanceof i?e.originalError?.status:void 0;if(t!==void 0&&[400,404].includes(t))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){let n=this._getFinalPath(e),r=[],i=t?.download?`download=${t.download===!0?``:t.download}`:``;i!==``&&r.push(i);let a=t?.transform===void 0?`object`:`render/image`,o=this.transformOptsToQueryString(t?.transform||{});o!==``&&r.push(o);let s=r.join(`&`);return s!==``&&(s=`?${s}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${s}`)}}}async remove(e){return this.handleOperation(async()=>await C(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}))}async list(e,t,n){return this.handleOperation(async()=>{let r={...k,...t,prefix:e||``};return await b(this.fetch,`${this.url}/object/list/${this.bucketId}`,r,{headers:this.headers},n)})}async listV2(e,t){return this.handleOperation(async()=>{let n={...e};return await b(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<`u`?Buffer.from(e).toString(`base64`):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,``)}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,``).replace(/\/+/g,`/`)}transformOptsToQueryString(e){let t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join(`&`)}};let M={"X-Client-Info":`storage-js/2.100.0`};var N=class extends T{constructor(e,t={},n,r){let i=new URL(e);r?.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes(`storage.supabase.`)&&(i.hostname=i.hostname.replace(`supabase.`,`storage.supabase.`));let a=i.href.replace(/\/$/,``),o={...M,...t};super(a,o,n,`storage`)}async listBuckets(e){return this.handleOperation(async()=>{let t=this.listBucketOptionsToQueryString(e);return await y(this.fetch,`${this.url}/bucket${t}`,{headers:this.headers})})}async getBucket(e){return this.handleOperation(async()=>await y(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}))}async createBucket(e,t={public:!1}){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}))}async updateBucket(e,t){return this.handleOperation(async()=>await x(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}))}async emptyBucket(e){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}))}async deleteBucket(e){return this.handleOperation(async()=>await C(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}))}listBucketOptionsToQueryString(e){let t={};return e&&(`limit`in e&&(t.limit=String(e.limit)),`offset`in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?`?`+new URLSearchParams(t).toString():``}},P=class extends Error{constructor(e,t){super(e),this.name=`IcebergError`,this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown=t.icebergType===`CommitStateUnknownException`||[500,502,504].includes(t.status)&&t.icebergType?.includes(`CommitState`)===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function F(e,t,n){let r=new URL(t,e);if(n)for(let[e,t]of Object.entries(n))t!==void 0&&r.searchParams.set(e,t);return r.toString()}async function I(e){return!e||e.type===`none`?{}:e.type===`bearer`?{Authorization:`Bearer ${e.token}`}:e.type===`header`?{[e.name]:e.value}:e.type===`custom`?await e.getHeaders():{}}function L(e){let t=e.fetchImpl??globalThis.fetch;return{async request({method:n,path:r,query:i,body:a,headers:o}){let s=F(e.baseUrl,r,i),c=await I(e.auth),l=await t(s,{method:n,headers:{...a?{"Content-Type":`application/json`}:{},...c,...o},body:a?JSON.stringify(a):void 0}),u=await l.text(),d=(l.headers.get(`content-type`)||``).includes(`application/json`),f=d&&u?JSON.parse(u):u;if(!l.ok){let e=d?f:void 0,t=e?.error;throw new P(t?.message??`Request failed with status ${l.status}`,{status:l.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:l.status,headers:l.headers,data:f}}}}function R(e){return e.join(``)}var z=class{constructor(e,t=``){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:R(e.namespace)}:void 0;return(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let n={namespace:e.namespace,properties:t?.properties};return(await this.client.request({method:`POST`,path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(e){await this.client.request({method:`DELETE`,path:`${this.prefix}/namespaces/${R(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces/${R(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:`HEAD`,path:`${this.prefix}/namespaces/${R(e.namespace)}`}),!0}catch(e){if(e instanceof P&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof P&&e.status===409)return;throw e}}};function B(e){return e.join(``)}var V=class{constructor(e,t=``,n){this.client=e,this.prefix=t,this.accessDelegation=n}async listTables(e){return(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){let n={};return this.accessDelegation&&(n[`X-Iceberg-Access-Delegation`]=this.accessDelegation),(await this.client.request({method:`POST`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables`,body:t,headers:n})).data.metadata}async updateTable(e,t){let n=await this.client.request({method:`POST`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":n.data[`metadata-location`],metadata:n.data.metadata}}async dropTable(e,t){await this.client.request({method:`DELETE`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String(t?.purge??!1)}})}async loadTable(e){let t={};return this.accessDelegation&&(t[`X-Iceberg-Access-Delegation`]=this.accessDelegation),(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t[`X-Iceberg-Access-Delegation`]=this.accessDelegation);try{return await this.client.request({method:`HEAD`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof P&&e.status===404)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(n){if(n instanceof P&&n.status===409)return await this.loadTable({namespace:e.namespace,name:t.name});throw n}}},H=class{constructor(e){let t=`v1`;e.catalogName&&(t+=`/${e.catalogName}`),this.client=L({baseUrl:e.baseUrl.endsWith(`/`)?e.baseUrl:`${e.baseUrl}/`,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=e.accessDelegation?.join(`,`),this.namespaceOps=new z(this.client,t),this.tableOps=new V(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}},U=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,...t};super(r,i,n,`storage`)}async createBucket(e){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/bucket`,{name:e},{headers:this.headers}))}async listBuckets(e){return this.handleOperation(async()=>{let t=new URLSearchParams;e?.limit!==void 0&&t.set(`limit`,e.limit.toString()),e?.offset!==void 0&&t.set(`offset`,e.offset.toString()),e?.sortColumn&&t.set(`sortColumn`,e.sortColumn),e?.sortOrder&&t.set(`sortOrder`,e.sortOrder),e?.search&&t.set(`search`,e.search);let n=t.toString(),r=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return await y(this.fetch,r,{headers:this.headers})})}async deleteBucket(e){return this.handleOperation(async()=>await C(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}))}from(e){if(!p(e))throw new t(`Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.`);let n=new H({baseUrl:this.url,catalogName:e,auth:{type:`custom`,getHeaders:async()=>this.headers},fetch:this.fetch}),r=this.shouldThrowOnError;return new Proxy(n,{get(e,t){let n=e[t];return typeof n==`function`?async(...t)=>{try{return{data:await n.apply(e,t),error:null}}catch(e){if(r)throw e;return{data:null,error:e}}}:n}})}},W=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,"Content-Type":`application/json`,...t};super(r,i,n,`vectors`)}async createIndex(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/CreateIndex`,e,{headers:this.headers})||{})}async getIndex(e,t){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers}))}async listIndexes(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/ListIndexes`,e,{headers:this.headers}))}async deleteIndex(e,t){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers})||{})}},G=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,"Content-Type":`application/json`,...t};super(r,i,n,`vectors`)}async putVectors(e){if(e.vectors.length<1||e.vectors.length>500)throw Error(`Vector batch size must be between 1 and 500 items`);return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/PutVectors`,e,{headers:this.headers})||{})}async getVectors(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/GetVectors`,e,{headers:this.headers}))}async listVectors(e){if(e.segmentCount!==void 0){if(e.segmentCount<1||e.segmentCount>16)throw Error(`segmentCount must be between 1 and 16`);if(e.segmentIndex!==void 0&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/ListVectors`,e,{headers:this.headers}))}async queryVectors(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/QueryVectors`,e,{headers:this.headers}))}async deleteVectors(e){if(e.keys.length<1||e.keys.length>500)throw Error(`Keys batch size must be between 1 and 500 items`);return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/DeleteVectors`,e,{headers:this.headers})||{})}},K=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,"Content-Type":`application/json`,...t};super(r,i,n,`vectors`)}async createBucket(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:this.headers})||{})}async getBucket(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:e},{headers:this.headers}))}async listBuckets(e={}){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/ListVectorBuckets`,e,{headers:this.headers}))}async deleteBucket(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:this.headers})||{})}},q=class extends K{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new J(this.url,this.headers,e,this.fetch)}async createBucket(e){return super.createBucket(e)}async getBucket(e){return super.getBucket(e)}async listBuckets(e={}){return super.listBuckets(e)}async deleteBucket(e){return super.deleteBucket(e)}},J=class extends W{constructor(e,t,n,r){super(e,t,r),this.vectorBucketName=n}async createIndex(e){return super.createIndex({...e,vectorBucketName:this.vectorBucketName})}async listIndexes(e={}){return super.listIndexes({...e,vectorBucketName:this.vectorBucketName})}async getIndex(e){return super.getIndex(this.vectorBucketName,e)}async deleteIndex(e){return super.deleteIndex(this.vectorBucketName,e)}index(e){return new Y(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},Y=class extends G{constructor(e,t,n,r,i){super(e,t,i),this.vectorBucketName=n,this.indexName=r}async putVectors(e){return super.putVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async getVectors(e){return super.getVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async listVectors(e={}){return super.listVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async queryVectors(e){return super.queryVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async deleteVectors(e){return super.deleteVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}},X=class extends N{constructor(e,t={},n,r){super(e,t,n,r)}from(e){return new j(this.url,this.headers,e,this.fetch)}get vectors(){return new q(this.url+`/vector`,{headers:this.headers,fetch:this.fetch})}get analytics(){return new U(this.url+`/iceberg`,this.headers,this.fetch)}};return e.StorageAnalyticsClient=U,e.StorageApiError=r,e.StorageClient=X,e.StorageError=t,e.StorageUnknownError=i,e.StorageVectorsApiError=s,e.StorageVectorsClient=q,e.StorageVectorsError=a,e.StorageVectorsErrorCode=l,e.StorageVectorsUnknownError=c,e.VectorBucketApi=K,e.VectorBucketScope=J,e.VectorDataApi=G,e.VectorIndexApi=W,e.VectorIndexScope=Y,e.isStorageError=n,e.isStorageVectorsError=o,e})({});
|
|
1
|
+
var supabase=(function(e){var t=class extends Error{constructor(e,t=`storage`,n,r){super(e),this.__isStorageError=!0,this.namespace=t,this.name=t===`vectors`?`StorageVectorsError`:`StorageError`,this.status=n,this.statusCode=r}};function n(e){return typeof e==`object`&&!!e&&`__isStorageError`in e}var r=class extends t{constructor(e,t,n,r=`storage`){super(e,r,t,n),this.name=r===`vectors`?`StorageVectorsApiError`:`StorageApiError`,this.status=t,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},i=class extends t{constructor(e,t,n=`storage`){super(e,n),this.name=n===`vectors`?`StorageVectorsUnknownError`:`StorageUnknownError`,this.originalError=t}},a=class extends t{constructor(e){super(e,`vectors`)}};function o(e){return n(e)&&e.namespace===`vectors`}var s=class extends r{constructor(e,t,n){super(e,t,n,`vectors`)}},c=class extends i{constructor(e,t){super(e,t,`vectors`)}};let l=function(e){return e.InternalError=`InternalError`,e.S3VectorConflictException=`S3VectorConflictException`,e.S3VectorNotFoundException=`S3VectorNotFoundException`,e.S3VectorBucketNotEmpty=`S3VectorBucketNotEmpty`,e.S3VectorMaxBucketsExceeded=`S3VectorMaxBucketsExceeded`,e.S3VectorMaxIndexesExceeded=`S3VectorMaxIndexesExceeded`,e}({}),u=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),d=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},f=e=>{if(Array.isArray(e))return e.map(e=>f(e));if(typeof e==`function`||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,n])=>{let r=e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,``));t[r]=f(n)}),t},p=e=>!e||typeof e!=`string`||e.length===0||e.length>100||e.trim()!==e||e.includes(`/`)||e.includes(`\\`)?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(e),m=e=>e.msg||e.message||e.error_description||(typeof e.error==`string`?e.error:e.error?.message)||JSON.stringify(e),h=async(e,t,n,a)=>{if(typeof e==`object`&&e&&typeof e.json==`function`){let n=e,i=parseInt(n.status,10);Number.isFinite(i)||(i=500),n.json().then(e=>{let n=e?.statusCode||e?.code||i+``;t(new r(m(e),i,n,a))}).catch(()=>{let e=i+``;t(new r(n.statusText||`HTTP ${i} error`,i,e,a))})}else t(new i(m(e),e,a))},g=(e,t,n,r)=>{let i={method:e,headers:t?.headers||{}};return e===`GET`||e===`HEAD`||!r?{...i,...n}:(d(r)?(i.headers={"Content-Type":`application/json`,...t?.headers},i.body=JSON.stringify(r)):i.body=r,t?.duplex&&(i.duplex=t.duplex),{...i,...n})};async function _(e,t,n,r,i,a,o){return new Promise((s,c)=>{e(n,g(t,r,i,a)).then(e=>{if(!e.ok)throw e;if(r?.noResolveJson)return e;if(o===`vectors`){let t=e.headers.get(`content-type`);if(e.headers.get(`content-length`)===`0`||e.status===204||!t||!t.includes(`application/json`))return{}}return e.json()}).then(e=>s(e)).catch(e=>h(e,c,r,o))})}function v(e=`storage`){return{get:async(t,n,r,i)=>_(t,`GET`,n,r,i,void 0,e),post:async(t,n,r,i,a)=>_(t,`POST`,n,i,a,r,e),put:async(t,n,r,i,a)=>_(t,`PUT`,n,i,a,r,e),head:async(t,n,r,i)=>_(t,`HEAD`,n,{...r,noResolveJson:!0},i,void 0,e),remove:async(t,n,r,i,a)=>_(t,`DELETE`,n,i,a,r,e)}}let{get:y,post:b,put:x,head:S,remove:C}=v(`storage`),w=v(`vectors`);var T=class{constructor(e,t={},n,r=`storage`){this.shouldThrowOnError=!1,this.url=e,this.headers=t,this.fetch=u(n),this.namespace=r}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers={...this.headers,[e]:t},this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e))return{data:null,error:e};throw e}}},E=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e))return{data:null,error:e};throw e}}};let D;var O=class{static{D=Symbol.toStringTag}constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[D]=`BlobDownloadBuilder`,this.promise=null}asStream(){return new E(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||=this.execute(),this.promise}async execute(){try{return{data:await(await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e))return{data:null,error:e};throw e}}};let k={limit:100,offset:0,sortBy:{column:`name`,order:`asc`}},A={cacheControl:`3600`,contentType:`text/plain;charset=UTF-8`,upsert:!1};var j=class extends T{constructor(e,t={},n,r){super(e,t,r,`storage`),this.bucketId=n}async uploadOrUpdate(e,t,n,r){return this.handleOperation(async()=>{let i,a={...A,...r},o={...this.headers,...e===`POST`&&{"x-upsert":String(a.upsert)}},s=a.metadata;typeof Blob<`u`&&n instanceof Blob?(i=new FormData,i.append(`cacheControl`,a.cacheControl),s&&i.append(`metadata`,this.encodeMetadata(s)),i.append(``,n)):typeof FormData<`u`&&n instanceof FormData?(i=n,i.has(`cacheControl`)||i.append(`cacheControl`,a.cacheControl),s&&!i.has(`metadata`)&&i.append(`metadata`,this.encodeMetadata(s))):(i=n,o[`cache-control`]=`max-age=${a.cacheControl}`,o[`content-type`]=a.contentType,s&&(o[`x-metadata`]=this.toBase64(this.encodeMetadata(s))),(typeof ReadableStream<`u`&&i instanceof ReadableStream||i&&typeof i==`object`&&`pipe`in i&&typeof i.pipe==`function`)&&!a.duplex&&(a.duplex=`half`)),r?.headers&&(o={...o,...r.headers});let c=this._removeEmptyFolders(t),l=this._getFinalPath(c),u=await(e==`PUT`?x:b)(this.fetch,`${this.url}/object/${l}`,i,{headers:o,...a?.duplex?{duplex:a.duplex}:{}});return{path:c,id:u.Id,fullPath:u.Key}})}async upload(e,t,n){return this.uploadOrUpdate(`POST`,e,t,n)}async uploadToSignedUrl(e,t,n,r){let i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);return o.searchParams.set(`token`,t),this.handleOperation(async()=>{let e,t={...A,...r},a={...this.headers,"x-upsert":String(t.upsert)};return typeof Blob<`u`&&n instanceof Blob?(e=new FormData,e.append(`cacheControl`,t.cacheControl),e.append(``,n)):typeof FormData<`u`&&n instanceof FormData?(e=n,e.append(`cacheControl`,t.cacheControl)):(e=n,a[`cache-control`]=`max-age=${t.cacheControl}`,a[`content-type`]=t.contentType),{path:i,fullPath:(await x(this.fetch,o.toString(),e,{headers:a})).Key}})}async createSignedUploadUrl(e,n){return this.handleOperation(async()=>{let r=this._getFinalPath(e),i={...this.headers};n?.upsert&&(i[`x-upsert`]=`true`);let a=await b(this.fetch,`${this.url}/object/upload/sign/${r}`,{},{headers:i}),o=new URL(this.url+a.url),s=o.searchParams.get(`token`);if(!s)throw new t(`No token returned by API`);return{signedUrl:o.toString(),path:e,token:s}})}async update(e,t,n){return this.uploadOrUpdate(`PUT`,e,t,n)}async move(e,t,n){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n?.destinationBucket},{headers:this.headers}))}async copy(e,t,n){return this.handleOperation(async()=>({path:(await b(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n?.destinationBucket},{headers:this.headers})).Key}))}async createSignedUrl(e,t,n){return this.handleOperation(async()=>{let r=this._getFinalPath(e),i=typeof n?.transform==`object`&&n.transform!==null&&Object.keys(n.transform).length>0,a=await b(this.fetch,`${this.url}/object/sign/${r}`,{expiresIn:t,...i?{transform:n.transform}:{}},{headers:this.headers}),o=n?.download?`&download=${n.download===!0?``:n.download}`:``,s=i&&a.signedURL.includes(`/object/sign/`)?a.signedURL.replace(`/object/sign/`,`/render/image/sign/`):a.signedURL;return{signedUrl:encodeURI(`${this.url}${s}${o}`)}})}async createSignedUrls(e,t,n){return this.handleOperation(async()=>{let r=await b(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=n?.download?`&download=${n.download===!0?``:n.download}`:``;return r.map(e=>({...e,signedUrl:e.signedURL?encodeURI(`${this.url}${e.signedURL}${i}`):null}))})}download(e,t,n){let r=t?.transform===void 0?`object`:`render/image/authenticated`,i=this.transformOptsToQueryString(t?.transform||{}),a=i?`?${i}`:``,o=this._getFinalPath(e);return new O(()=>y(this.fetch,`${this.url}/${r}/${o}${a}`,{headers:this.headers,noResolveJson:!0},n),this.shouldThrowOnError)}async info(e){let t=this._getFinalPath(e);return this.handleOperation(async()=>f(await y(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers})))}async exists(e){let t=this._getFinalPath(e);try{return await S(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(n(e)){let t=e instanceof r?e.status:e instanceof i?e.originalError?.status:void 0;if(t!==void 0&&[400,404].includes(t))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){let n=this._getFinalPath(e),r=[],i=t?.download?`download=${t.download===!0?``:t.download}`:``;i!==``&&r.push(i);let a=t?.transform===void 0?`object`:`render/image`,o=this.transformOptsToQueryString(t?.transform||{});o!==``&&r.push(o);let s=r.join(`&`);return s!==``&&(s=`?${s}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${n}${s}`)}}}async remove(e){return this.handleOperation(async()=>await C(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}))}async list(e,t,n){return this.handleOperation(async()=>{let r={...k,...t,prefix:e||``};return await b(this.fetch,`${this.url}/object/list/${this.bucketId}`,r,{headers:this.headers},n)})}async listV2(e,t){return this.handleOperation(async()=>{let n={...e};return await b(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<`u`?Buffer.from(e).toString(`base64`):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,``)}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,``).replace(/\/+/g,`/`)}transformOptsToQueryString(e){let t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join(`&`)}};let M={"X-Client-Info":`storage-js/2.100.1`};var N=class extends T{constructor(e,t={},n,r){let i=new URL(e);r?.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes(`storage.supabase.`)&&(i.hostname=i.hostname.replace(`supabase.`,`storage.supabase.`));let a=i.href.replace(/\/$/,``),o={...M,...t};super(a,o,n,`storage`)}async listBuckets(e){return this.handleOperation(async()=>{let t=this.listBucketOptionsToQueryString(e);return await y(this.fetch,`${this.url}/bucket${t}`,{headers:this.headers})})}async getBucket(e){return this.handleOperation(async()=>await y(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}))}async createBucket(e,t={public:!1}){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}))}async updateBucket(e,t){return this.handleOperation(async()=>await x(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}))}async emptyBucket(e){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}))}async deleteBucket(e){return this.handleOperation(async()=>await C(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}))}listBucketOptionsToQueryString(e){let t={};return e&&(`limit`in e&&(t.limit=String(e.limit)),`offset`in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?`?`+new URLSearchParams(t).toString():``}},P=class extends Error{constructor(e,t){super(e),this.name=`IcebergError`,this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown=t.icebergType===`CommitStateUnknownException`||[500,502,504].includes(t.status)&&t.icebergType?.includes(`CommitState`)===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function F(e,t,n){let r=new URL(t,e);if(n)for(let[e,t]of Object.entries(n))t!==void 0&&r.searchParams.set(e,t);return r.toString()}async function I(e){return!e||e.type===`none`?{}:e.type===`bearer`?{Authorization:`Bearer ${e.token}`}:e.type===`header`?{[e.name]:e.value}:e.type===`custom`?await e.getHeaders():{}}function L(e){let t=e.fetchImpl??globalThis.fetch;return{async request({method:n,path:r,query:i,body:a,headers:o}){let s=F(e.baseUrl,r,i),c=await I(e.auth),l=await t(s,{method:n,headers:{...a?{"Content-Type":`application/json`}:{},...c,...o},body:a?JSON.stringify(a):void 0}),u=await l.text(),d=(l.headers.get(`content-type`)||``).includes(`application/json`),f=d&&u?JSON.parse(u):u;if(!l.ok){let e=d?f:void 0,t=e?.error;throw new P(t?.message??`Request failed with status ${l.status}`,{status:l.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:l.status,headers:l.headers,data:f}}}}function R(e){return e.join(``)}var z=class{constructor(e,t=``){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:R(e.namespace)}:void 0;return(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let n={namespace:e.namespace,properties:t?.properties};return(await this.client.request({method:`POST`,path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(e){await this.client.request({method:`DELETE`,path:`${this.prefix}/namespaces/${R(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces/${R(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:`HEAD`,path:`${this.prefix}/namespaces/${R(e.namespace)}`}),!0}catch(e){if(e instanceof P&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof P&&e.status===409)return;throw e}}};function B(e){return e.join(``)}var V=class{constructor(e,t=``,n){this.client=e,this.prefix=t,this.accessDelegation=n}async listTables(e){return(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){let n={};return this.accessDelegation&&(n[`X-Iceberg-Access-Delegation`]=this.accessDelegation),(await this.client.request({method:`POST`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables`,body:t,headers:n})).data.metadata}async updateTable(e,t){let n=await this.client.request({method:`POST`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":n.data[`metadata-location`],metadata:n.data.metadata}}async dropTable(e,t){await this.client.request({method:`DELETE`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String(t?.purge??!1)}})}async loadTable(e){let t={};return this.accessDelegation&&(t[`X-Iceberg-Access-Delegation`]=this.accessDelegation),(await this.client.request({method:`GET`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t[`X-Iceberg-Access-Delegation`]=this.accessDelegation);try{return await this.client.request({method:`HEAD`,path:`${this.prefix}/namespaces/${B(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof P&&e.status===404)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(n){if(n instanceof P&&n.status===409)return await this.loadTable({namespace:e.namespace,name:t.name});throw n}}},H=class{constructor(e){let t=`v1`;e.catalogName&&(t+=`/${e.catalogName}`),this.client=L({baseUrl:e.baseUrl.endsWith(`/`)?e.baseUrl:`${e.baseUrl}/`,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=e.accessDelegation?.join(`,`),this.namespaceOps=new z(this.client,t),this.tableOps=new V(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}},U=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,...t};super(r,i,n,`storage`)}async createBucket(e){return this.handleOperation(async()=>await b(this.fetch,`${this.url}/bucket`,{name:e},{headers:this.headers}))}async listBuckets(e){return this.handleOperation(async()=>{let t=new URLSearchParams;e?.limit!==void 0&&t.set(`limit`,e.limit.toString()),e?.offset!==void 0&&t.set(`offset`,e.offset.toString()),e?.sortColumn&&t.set(`sortColumn`,e.sortColumn),e?.sortOrder&&t.set(`sortOrder`,e.sortOrder),e?.search&&t.set(`search`,e.search);let n=t.toString(),r=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return await y(this.fetch,r,{headers:this.headers})})}async deleteBucket(e){return this.handleOperation(async()=>await C(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}))}from(e){if(!p(e))throw new t(`Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.`);let n=new H({baseUrl:this.url,catalogName:e,auth:{type:`custom`,getHeaders:async()=>this.headers},fetch:this.fetch}),r=this.shouldThrowOnError;return new Proxy(n,{get(e,t){let n=e[t];return typeof n==`function`?async(...t)=>{try{return{data:await n.apply(e,t),error:null}}catch(e){if(r)throw e;return{data:null,error:e}}}:n}})}},W=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,"Content-Type":`application/json`,...t};super(r,i,n,`vectors`)}async createIndex(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/CreateIndex`,e,{headers:this.headers})||{})}async getIndex(e,t){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers}))}async listIndexes(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/ListIndexes`,e,{headers:this.headers}))}async deleteIndex(e,t){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:this.headers})||{})}},G=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,"Content-Type":`application/json`,...t};super(r,i,n,`vectors`)}async putVectors(e){if(e.vectors.length<1||e.vectors.length>500)throw Error(`Vector batch size must be between 1 and 500 items`);return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/PutVectors`,e,{headers:this.headers})||{})}async getVectors(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/GetVectors`,e,{headers:this.headers}))}async listVectors(e){if(e.segmentCount!==void 0){if(e.segmentCount<1||e.segmentCount>16)throw Error(`segmentCount must be between 1 and 16`);if(e.segmentIndex!==void 0&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/ListVectors`,e,{headers:this.headers}))}async queryVectors(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/QueryVectors`,e,{headers:this.headers}))}async deleteVectors(e){if(e.keys.length<1||e.keys.length>500)throw Error(`Keys batch size must be between 1 and 500 items`);return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/DeleteVectors`,e,{headers:this.headers})||{})}},K=class extends T{constructor(e,t={},n){let r=e.replace(/\/$/,``),i={...M,"Content-Type":`application/json`,...t};super(r,i,n,`vectors`)}async createBucket(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:this.headers})||{})}async getBucket(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:e},{headers:this.headers}))}async listBuckets(e={}){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/ListVectorBuckets`,e,{headers:this.headers}))}async deleteBucket(e){return this.handleOperation(async()=>await w.post(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:this.headers})||{})}},q=class extends K{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new J(this.url,this.headers,e,this.fetch)}async createBucket(e){return super.createBucket(e)}async getBucket(e){return super.getBucket(e)}async listBuckets(e={}){return super.listBuckets(e)}async deleteBucket(e){return super.deleteBucket(e)}},J=class extends W{constructor(e,t,n,r){super(e,t,r),this.vectorBucketName=n}async createIndex(e){return super.createIndex({...e,vectorBucketName:this.vectorBucketName})}async listIndexes(e={}){return super.listIndexes({...e,vectorBucketName:this.vectorBucketName})}async getIndex(e){return super.getIndex(this.vectorBucketName,e)}async deleteIndex(e){return super.deleteIndex(this.vectorBucketName,e)}index(e){return new Y(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},Y=class extends G{constructor(e,t,n,r,i){super(e,t,i),this.vectorBucketName=n,this.indexName=r}async putVectors(e){return super.putVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async getVectors(e){return super.getVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async listVectors(e={}){return super.listVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async queryVectors(e){return super.queryVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}async deleteVectors(e){return super.deleteVectors({...e,vectorBucketName:this.vectorBucketName,indexName:this.indexName})}},X=class extends N{constructor(e,t={},n,r){super(e,t,n,r)}from(e){return new j(this.url,this.headers,e,this.fetch)}get vectors(){return new q(this.url+`/vector`,{headers:this.headers,fetch:this.fetch})}get analytics(){return new U(this.url+`/iceberg`,this.headers,this.fetch)}};return e.StorageAnalyticsClient=U,e.StorageApiError=r,e.StorageClient=X,e.StorageError=t,e.StorageUnknownError=i,e.StorageVectorsApiError=s,e.StorageVectorsClient=q,e.StorageVectorsError=a,e.StorageVectorsErrorCode=l,e.StorageVectorsUnknownError=c,e.VectorBucketApi=K,e.VectorBucketScope=J,e.VectorDataApi=G,e.VectorIndexApi=W,e.VectorIndexScope=Y,e.isStorageError=n,e.isStorageVectorsError=o,e})({});
|
package/package.json
CHANGED
package/src/StorageClient.ts
CHANGED
|
@@ -13,7 +13,7 @@ export class StorageClient extends StorageBucketApi {
|
|
|
13
13
|
* Creates a client for Storage buckets, files, analytics, and vectors.
|
|
14
14
|
*
|
|
15
15
|
* @category File Buckets
|
|
16
|
-
* @example
|
|
16
|
+
* @example Creating a Storage client
|
|
17
17
|
* ```ts
|
|
18
18
|
* import { StorageClient } from '@supabase/storage-js'
|
|
19
19
|
*
|
|
@@ -38,7 +38,7 @@ export class StorageClient extends StorageBucketApi {
|
|
|
38
38
|
* @category File Buckets
|
|
39
39
|
* @param id The bucket id to operate on.
|
|
40
40
|
*
|
|
41
|
-
* @example
|
|
41
|
+
* @example Accessing a bucket
|
|
42
42
|
* ```typescript
|
|
43
43
|
* const avatars = supabase.storage.from('avatars')
|
|
44
44
|
* ```
|
|
@@ -73,7 +73,7 @@ export default abstract class BaseApiClient<TError extends StorageError = Storag
|
|
|
73
73
|
* @param operation - Async function that performs the API call
|
|
74
74
|
* @returns Promise with { data, error } tuple
|
|
75
75
|
*
|
|
76
|
-
* @example
|
|
76
|
+
* @example Handling an operation
|
|
77
77
|
* ```typescript
|
|
78
78
|
* async listBuckets() {
|
|
79
79
|
* return this.handleOperation(async () => {
|
package/src/lib/version.ts
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// - Debugging and support (identifying which version is running)
|
|
5
5
|
// - Telemetry and logging (version reporting in errors/analytics)
|
|
6
6
|
// - Ensuring build artifacts match the published package version
|
|
7
|
-
export const version = '2.100.
|
|
7
|
+
export const version = '2.100.1'
|
|
@@ -31,7 +31,7 @@ export default class StorageAnalyticsClient extends BaseApiClient<StorageError>
|
|
|
31
31
|
* @param headers - HTTP headers to include in requests
|
|
32
32
|
* @param fetch - Optional custom fetch implementation
|
|
33
33
|
*
|
|
34
|
-
* @example
|
|
34
|
+
* @example Creating a StorageAnalyticsClient instance
|
|
35
35
|
* ```typescript
|
|
36
36
|
* const client = new StorageAnalyticsClient(url, headers)
|
|
37
37
|
* ```
|
|
@@ -75,6 +75,10 @@ export default class StorageAnalyticsClient extends BaseApiClient<StorageError>
|
|
|
75
75
|
* "error": null
|
|
76
76
|
* }
|
|
77
77
|
* ```
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* - Creates a new analytics bucket using Iceberg tables
|
|
81
|
+
* - Analytics buckets are optimized for analytical queries and data processing
|
|
78
82
|
*/
|
|
79
83
|
async createBucket(name: string): Promise<
|
|
80
84
|
| {
|
|
@@ -136,6 +140,10 @@ export default class StorageAnalyticsClient extends BaseApiClient<StorageError>
|
|
|
136
140
|
* "error": null
|
|
137
141
|
* }
|
|
138
142
|
* ```
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* - Retrieves the details of all Analytics Storage buckets within an existing project
|
|
146
|
+
* - Only returns buckets of type 'ANALYTICS'
|
|
139
147
|
*/
|
|
140
148
|
async listBuckets(options?: {
|
|
141
149
|
limit?: number
|
|
@@ -199,6 +207,9 @@ export default class StorageAnalyticsClient extends BaseApiClient<StorageError>
|
|
|
199
207
|
* "error": null
|
|
200
208
|
* }
|
|
201
209
|
* ```
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* - Deletes an analytics bucket
|
|
202
213
|
*/
|
|
203
214
|
async deleteBucket(bucketName: string): Promise<
|
|
204
215
|
| {
|
|
@@ -60,6 +60,12 @@ export default class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
|
60
60
|
* search: 'prod'
|
|
61
61
|
* })
|
|
62
62
|
* ```
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* - RLS policy permissions required:
|
|
66
|
+
* - `buckets` table permissions: `select`
|
|
67
|
+
* - `objects` table permissions: none
|
|
68
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
63
69
|
*/
|
|
64
70
|
async listBuckets(options?: ListBucketOptions): Promise<
|
|
65
71
|
| {
|
|
@@ -111,6 +117,12 @@ export default class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
|
111
117
|
* "error": null
|
|
112
118
|
* }
|
|
113
119
|
* ```
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* - RLS policy permissions required:
|
|
123
|
+
* - `buckets` table permissions: `select`
|
|
124
|
+
* - `objects` table permissions: none
|
|
125
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
114
126
|
*/
|
|
115
127
|
async getBucket(id: string): Promise<
|
|
116
128
|
| {
|
|
@@ -163,6 +175,12 @@ export default class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
|
163
175
|
* "error": null
|
|
164
176
|
* }
|
|
165
177
|
* ```
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* - RLS policy permissions required:
|
|
181
|
+
* - `buckets` table permissions: `insert`
|
|
182
|
+
* - `objects` table permissions: none
|
|
183
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
166
184
|
*/
|
|
167
185
|
async createBucket(
|
|
168
186
|
id: string,
|
|
@@ -235,6 +253,12 @@ export default class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
|
235
253
|
* "error": null
|
|
236
254
|
* }
|
|
237
255
|
* ```
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* - RLS policy permissions required:
|
|
259
|
+
* - `buckets` table permissions: `select` and `update`
|
|
260
|
+
* - `objects` table permissions: none
|
|
261
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
238
262
|
*/
|
|
239
263
|
async updateBucket(
|
|
240
264
|
id: string,
|
|
@@ -292,6 +316,12 @@ export default class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
|
292
316
|
* "error": null
|
|
293
317
|
* }
|
|
294
318
|
* ```
|
|
319
|
+
*
|
|
320
|
+
* @remarks
|
|
321
|
+
* - RLS policy permissions required:
|
|
322
|
+
* - `buckets` table permissions: `select`
|
|
323
|
+
* - `objects` table permissions: `select` and `delete`
|
|
324
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
295
325
|
*/
|
|
296
326
|
async emptyBucket(id: string): Promise<
|
|
297
327
|
| {
|
|
@@ -332,6 +362,12 @@ export default class StorageBucketApi extends BaseApiClient<StorageError> {
|
|
|
332
362
|
* "error": null
|
|
333
363
|
* }
|
|
334
364
|
* ```
|
|
365
|
+
*
|
|
366
|
+
* @remarks
|
|
367
|
+
* - RLS policy permissions required:
|
|
368
|
+
* - `buckets` table permissions: `select` and `delete`
|
|
369
|
+
* - `objects` table permissions: none
|
|
370
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
335
371
|
*/
|
|
336
372
|
async deleteBucket(id: string): Promise<
|
|
337
373
|
| {
|
|
@@ -189,6 +189,13 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
189
189
|
* contentType: 'image/png'
|
|
190
190
|
* })
|
|
191
191
|
* ```
|
|
192
|
+
*
|
|
193
|
+
* @remarks
|
|
194
|
+
* - RLS policy permissions required:
|
|
195
|
+
* - `buckets` table permissions: none
|
|
196
|
+
* - `objects` table permissions: only `insert` when you are uploading new files and `select`, `insert` and `update` when you are upserting files
|
|
197
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
198
|
+
* - For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Upload file using `ArrayBuffer` from base64 file data instead, see example below.
|
|
192
199
|
*/
|
|
193
200
|
async upload(
|
|
194
201
|
path: string,
|
|
@@ -237,6 +244,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
237
244
|
* "error": null
|
|
238
245
|
* }
|
|
239
246
|
* ```
|
|
247
|
+
*
|
|
248
|
+
* @remarks
|
|
249
|
+
* - RLS policy permissions required:
|
|
250
|
+
* - `buckets` table permissions: none
|
|
251
|
+
* - `objects` table permissions: none
|
|
252
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
240
253
|
*/
|
|
241
254
|
async uploadToSignedUrl(
|
|
242
255
|
path: string,
|
|
@@ -252,7 +265,7 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
252
265
|
|
|
253
266
|
return this.handleOperation(async () => {
|
|
254
267
|
let body
|
|
255
|
-
const options = {
|
|
268
|
+
const options = { ...DEFAULT_FILE_OPTIONS, ...fileOptions }
|
|
256
269
|
const headers: Record<string, string> = {
|
|
257
270
|
...this.headers,
|
|
258
271
|
...{ 'x-upsert': String(options.upsert as boolean) },
|
|
@@ -306,6 +319,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
306
319
|
* "error": null
|
|
307
320
|
* }
|
|
308
321
|
* ```
|
|
322
|
+
*
|
|
323
|
+
* @remarks
|
|
324
|
+
* - RLS policy permissions required:
|
|
325
|
+
* - `buckets` table permissions: none
|
|
326
|
+
* - `objects` table permissions: `insert`
|
|
327
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
309
328
|
*/
|
|
310
329
|
async createSignedUploadUrl(
|
|
311
330
|
path: string,
|
|
@@ -391,6 +410,13 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
391
410
|
* contentType: 'image/png'
|
|
392
411
|
* })
|
|
393
412
|
* ```
|
|
413
|
+
*
|
|
414
|
+
* @remarks
|
|
415
|
+
* - RLS policy permissions required:
|
|
416
|
+
* - `buckets` table permissions: none
|
|
417
|
+
* - `objects` table permissions: `update` and `select`
|
|
418
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
419
|
+
* - For React Native, using either `Blob`, `File` or `FormData` does not work as intended. Update file using `ArrayBuffer` from base64 file data instead, see example below.
|
|
394
420
|
*/
|
|
395
421
|
async update(
|
|
396
422
|
path: string,
|
|
@@ -445,6 +471,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
445
471
|
* "error": null
|
|
446
472
|
* }
|
|
447
473
|
* ```
|
|
474
|
+
*
|
|
475
|
+
* @remarks
|
|
476
|
+
* - RLS policy permissions required:
|
|
477
|
+
* - `buckets` table permissions: none
|
|
478
|
+
* - `objects` table permissions: `update` and `select`
|
|
479
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
448
480
|
*/
|
|
449
481
|
async move(
|
|
450
482
|
fromPath: string,
|
|
@@ -501,6 +533,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
501
533
|
* "error": null
|
|
502
534
|
* }
|
|
503
535
|
* ```
|
|
536
|
+
*
|
|
537
|
+
* @remarks
|
|
538
|
+
* - RLS policy permissions required:
|
|
539
|
+
* - `buckets` table permissions: none
|
|
540
|
+
* - `objects` table permissions: `insert` and `select`
|
|
541
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
504
542
|
*/
|
|
505
543
|
async copy(
|
|
506
544
|
fromPath: string,
|
|
@@ -582,6 +620,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
582
620
|
* download: true,
|
|
583
621
|
* })
|
|
584
622
|
* ```
|
|
623
|
+
*
|
|
624
|
+
* @remarks
|
|
625
|
+
* - RLS policy permissions required:
|
|
626
|
+
* - `buckets` table permissions: none
|
|
627
|
+
* - `objects` table permissions: `select`
|
|
628
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
585
629
|
*/
|
|
586
630
|
async createSignedUrl(
|
|
587
631
|
path: string,
|
|
@@ -663,6 +707,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
663
707
|
* "error": null
|
|
664
708
|
* }
|
|
665
709
|
* ```
|
|
710
|
+
*
|
|
711
|
+
* @remarks
|
|
712
|
+
* - RLS policy permissions required:
|
|
713
|
+
* - `buckets` table permissions: none
|
|
714
|
+
* - `objects` table permissions: `select`
|
|
715
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
666
716
|
*/
|
|
667
717
|
async createSignedUrls(
|
|
668
718
|
paths: string[],
|
|
@@ -755,6 +805,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
755
805
|
* .from('avatars')
|
|
756
806
|
* .download('folder/avatar1.png', {}, { signal: controller.signal })
|
|
757
807
|
* ```
|
|
808
|
+
*
|
|
809
|
+
* @remarks
|
|
810
|
+
* - RLS policy permissions required:
|
|
811
|
+
* - `buckets` table permissions: none
|
|
812
|
+
* - `objects` table permissions: `select`
|
|
813
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
758
814
|
*/
|
|
759
815
|
download<Options extends { transform?: TransformOptions }>(
|
|
760
816
|
path: string,
|
|
@@ -927,6 +983,13 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
927
983
|
* download: true,
|
|
928
984
|
* })
|
|
929
985
|
* ```
|
|
986
|
+
*
|
|
987
|
+
* @remarks
|
|
988
|
+
* - The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public"
|
|
989
|
+
* - RLS policy permissions required:
|
|
990
|
+
* - `buckets` table permissions: none
|
|
991
|
+
* - `objects` table permissions: none
|
|
992
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
930
993
|
*/
|
|
931
994
|
getPublicUrl(
|
|
932
995
|
path: string,
|
|
@@ -986,6 +1049,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
986
1049
|
* "error": null
|
|
987
1050
|
* }
|
|
988
1051
|
* ```
|
|
1052
|
+
*
|
|
1053
|
+
* @remarks
|
|
1054
|
+
* - RLS policy permissions required:
|
|
1055
|
+
* - `buckets` table permissions: none
|
|
1056
|
+
* - `objects` table permissions: `delete` and `select`
|
|
1057
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
989
1058
|
*/
|
|
990
1059
|
async remove(paths: string[]): Promise<
|
|
991
1060
|
| {
|
|
@@ -1107,7 +1176,7 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
1107
1176
|
* })
|
|
1108
1177
|
* ```
|
|
1109
1178
|
*
|
|
1110
|
-
* Response
|
|
1179
|
+
* Response:
|
|
1111
1180
|
* ```json
|
|
1112
1181
|
* {
|
|
1113
1182
|
* "data": [
|
|
@@ -1144,6 +1213,12 @@ export default class StorageFileApi extends BaseApiClient<StorageError> {
|
|
|
1144
1213
|
* search: 'jon'
|
|
1145
1214
|
* })
|
|
1146
1215
|
* ```
|
|
1216
|
+
*
|
|
1217
|
+
* @remarks
|
|
1218
|
+
* - RLS policy permissions required:
|
|
1219
|
+
* - `buckets` table permissions: none
|
|
1220
|
+
* - `objects` table permissions: `select`
|
|
1221
|
+
* - Refer to the [Storage guide](/docs/guides/storage/security/access-control) on how access control works
|
|
1147
1222
|
*/
|
|
1148
1223
|
async list(
|
|
1149
1224
|
path?: string,
|
|
@@ -90,7 +90,7 @@ export class StorageVectorsClient extends VectorBucketApi {
|
|
|
90
90
|
* @param options.headers - Optional headers (for example `Authorization`) applied to every request.
|
|
91
91
|
* @param options.fetch - Optional custom `fetch` implementation for non-browser runtimes.
|
|
92
92
|
*
|
|
93
|
-
* @example
|
|
93
|
+
* @example Creating a StorageVectorsClient instance
|
|
94
94
|
* ```typescript
|
|
95
95
|
* const client = new StorageVectorsClient(url, options)
|
|
96
96
|
* ```
|
|
@@ -112,7 +112,7 @@ export class StorageVectorsClient extends VectorBucketApi {
|
|
|
112
112
|
* @param vectorBucketName - Name of the vector bucket
|
|
113
113
|
* @returns Bucket-scoped client with index and vector operations
|
|
114
114
|
*
|
|
115
|
-
* @example
|
|
115
|
+
* @example Accessing a vector bucket
|
|
116
116
|
* ```typescript
|
|
117
117
|
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
118
118
|
* ```
|
|
@@ -134,7 +134,7 @@ export class StorageVectorsClient extends VectorBucketApi {
|
|
|
134
134
|
* @param vectorBucketName - Unique name for the vector bucket
|
|
135
135
|
* @returns Promise with empty response on success or error
|
|
136
136
|
*
|
|
137
|
-
* @example
|
|
137
|
+
* @example Creating a vector bucket
|
|
138
138
|
* ```typescript
|
|
139
139
|
* const { data, error } = await supabase
|
|
140
140
|
* .storage
|
|
@@ -158,7 +158,7 @@ export class StorageVectorsClient extends VectorBucketApi {
|
|
|
158
158
|
* @param vectorBucketName - Name of the vector bucket
|
|
159
159
|
* @returns Promise with bucket metadata or error
|
|
160
160
|
*
|
|
161
|
-
* @example
|
|
161
|
+
* @example Get bucket metadata
|
|
162
162
|
* ```typescript
|
|
163
163
|
* const { data, error } = await supabase
|
|
164
164
|
* .storage
|
|
@@ -184,7 +184,7 @@ export class StorageVectorsClient extends VectorBucketApi {
|
|
|
184
184
|
* @param options - Optional filters (prefix, maxResults, nextToken)
|
|
185
185
|
* @returns Promise with list of buckets or error
|
|
186
186
|
*
|
|
187
|
-
* @example
|
|
187
|
+
* @example List vector buckets
|
|
188
188
|
* ```typescript
|
|
189
189
|
* const { data, error } = await supabase
|
|
190
190
|
* .storage
|
|
@@ -215,7 +215,7 @@ export class StorageVectorsClient extends VectorBucketApi {
|
|
|
215
215
|
* @param vectorBucketName - Name of the vector bucket to delete
|
|
216
216
|
* @returns Promise with empty response on success or error
|
|
217
217
|
*
|
|
218
|
-
* @example
|
|
218
|
+
* @example Delete a vector bucket
|
|
219
219
|
* ```typescript
|
|
220
220
|
* const { data, error } = await supabase
|
|
221
221
|
* .storage
|
|
@@ -248,7 +248,7 @@ export class VectorBucketScope extends VectorIndexApi {
|
|
|
248
248
|
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
249
249
|
*
|
|
250
250
|
* @category Vector Buckets
|
|
251
|
-
* @example
|
|
251
|
+
* @example Creating a vector bucket scope
|
|
252
252
|
* ```typescript
|
|
253
253
|
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
254
254
|
* ```
|
|
@@ -276,7 +276,7 @@ export class VectorBucketScope extends VectorIndexApi {
|
|
|
276
276
|
* @param options - Index configuration (vectorBucketName is automatically set)
|
|
277
277
|
* @returns Promise with empty response on success or error
|
|
278
278
|
*
|
|
279
|
-
* @example
|
|
279
|
+
* @example Creating a vector index
|
|
280
280
|
* ```typescript
|
|
281
281
|
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
282
282
|
* await bucket.createIndex({
|
|
@@ -310,7 +310,7 @@ export class VectorBucketScope extends VectorIndexApi {
|
|
|
310
310
|
* @param options - Listing options (vectorBucketName is automatically set)
|
|
311
311
|
* @returns Promise with response containing indexes array and pagination token or error
|
|
312
312
|
*
|
|
313
|
-
* @example
|
|
313
|
+
* @example List indexes
|
|
314
314
|
* ```typescript
|
|
315
315
|
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
316
316
|
* const { data } = await bucket.listIndexes({ prefix: 'documents-' })
|
|
@@ -336,7 +336,7 @@ export class VectorBucketScope extends VectorIndexApi {
|
|
|
336
336
|
* @param indexName - Name of the index to retrieve
|
|
337
337
|
* @returns Promise with index metadata or error
|
|
338
338
|
*
|
|
339
|
-
* @example
|
|
339
|
+
* @example Get index metadata
|
|
340
340
|
* ```typescript
|
|
341
341
|
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
342
342
|
* const { data } = await bucket.getIndex('documents-openai')
|
|
@@ -360,7 +360,7 @@ export class VectorBucketScope extends VectorIndexApi {
|
|
|
360
360
|
* @param indexName - Name of the index to delete
|
|
361
361
|
* @returns Promise with empty response on success or error
|
|
362
362
|
*
|
|
363
|
-
* @example
|
|
363
|
+
* @example Delete an index
|
|
364
364
|
* ```typescript
|
|
365
365
|
* const bucket = supabase.storage.vectors.from('embeddings-prod')
|
|
366
366
|
* await bucket.deleteIndex('old-index')
|
|
@@ -383,7 +383,7 @@ export class VectorBucketScope extends VectorIndexApi {
|
|
|
383
383
|
* @param indexName - Name of the index
|
|
384
384
|
* @returns Index-scoped client with vector data operations
|
|
385
385
|
*
|
|
386
|
-
* @example
|
|
386
|
+
* @example Accessing an index
|
|
387
387
|
* ```typescript
|
|
388
388
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
389
389
|
*
|
|
@@ -434,7 +434,7 @@ export class VectorIndexScope extends VectorDataApi {
|
|
|
434
434
|
* **Public alpha:** This API is part of a public alpha release and may not be available to your account type.
|
|
435
435
|
*
|
|
436
436
|
* @category Vector Buckets
|
|
437
|
-
* @example
|
|
437
|
+
* @example Creating a vector index scope
|
|
438
438
|
* ```typescript
|
|
439
439
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
440
440
|
* ```
|
|
@@ -464,7 +464,7 @@ export class VectorIndexScope extends VectorDataApi {
|
|
|
464
464
|
* @param options - Vector insertion options (bucket and index names automatically set)
|
|
465
465
|
* @returns Promise with empty response on success or error
|
|
466
466
|
*
|
|
467
|
-
* @example
|
|
467
|
+
* @example Insert vectors into an index
|
|
468
468
|
* ```typescript
|
|
469
469
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
470
470
|
* await index.putVectors({
|
|
@@ -499,7 +499,7 @@ export class VectorIndexScope extends VectorDataApi {
|
|
|
499
499
|
* @param options - Vector retrieval options (bucket and index names automatically set)
|
|
500
500
|
* @returns Promise with response containing vectors array or error
|
|
501
501
|
*
|
|
502
|
-
* @example
|
|
502
|
+
* @example Get vectors by keys
|
|
503
503
|
* ```typescript
|
|
504
504
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
505
505
|
* const { data } = await index.getVectors({
|
|
@@ -529,7 +529,7 @@ export class VectorIndexScope extends VectorDataApi {
|
|
|
529
529
|
* @param options - Listing options (bucket and index names automatically set)
|
|
530
530
|
* @returns Promise with response containing vectors array and pagination token or error
|
|
531
531
|
*
|
|
532
|
-
* @example
|
|
532
|
+
* @example List vectors with pagination
|
|
533
533
|
* ```typescript
|
|
534
534
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
535
535
|
* const { data } = await index.listVectors({
|
|
@@ -561,7 +561,7 @@ export class VectorIndexScope extends VectorDataApi {
|
|
|
561
561
|
* @param options - Query options (bucket and index names automatically set)
|
|
562
562
|
* @returns Promise with response containing matches array of similar vectors ordered by distance or error
|
|
563
563
|
*
|
|
564
|
-
* @example
|
|
564
|
+
* @example Query similar vectors
|
|
565
565
|
* ```typescript
|
|
566
566
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
567
567
|
* const { data } = await index.queryVectors({
|
|
@@ -596,7 +596,7 @@ export class VectorIndexScope extends VectorDataApi {
|
|
|
596
596
|
* @param options - Deletion options (bucket and index names automatically set)
|
|
597
597
|
* @returns Promise with empty response on success or error
|
|
598
598
|
*
|
|
599
|
-
* @example
|
|
599
|
+
* @example Delete vectors by keys
|
|
600
600
|
* ```typescript
|
|
601
601
|
* const index = supabase.storage.vectors.from('embeddings-prod').index('documents-openai')
|
|
602
602
|
* await index.deleteVectors({
|