@koolbase/core 12.22.0 → 12.24.0
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/cjs/storage.d.ts +10 -1
- package/dist/cjs/storage.js +13 -1
- package/dist/esm/storage.d.ts +10 -1
- package/dist/esm/storage.js +13 -1
- package/package.json +1 -1
package/dist/cjs/storage.d.ts
CHANGED
|
@@ -201,8 +201,16 @@ export declare class KoolbaseStorage {
|
|
|
201
201
|
updateMetadata(bucket: string, path: string, metadata: Record<string, string | null>): Promise<KoolbaseObject>;
|
|
202
202
|
/**
|
|
203
203
|
* Get a signed download URL for a file.
|
|
204
|
+
*
|
|
205
|
+
* `options.preset` names one of the project's image presets (Storage →
|
|
206
|
+
* Presets): an image's current version is then given sized as the preset
|
|
207
|
+
* says -- a private bucket's as a signed, hour-long address -- after the
|
|
208
|
+
* same rules decide whether this person may see it. Anything not an image
|
|
209
|
+
* is given as it is.
|
|
204
210
|
*/
|
|
205
|
-
getDownloadUrl(bucket: string, path: string, versionId?: string
|
|
211
|
+
getDownloadUrl(bucket: string, path: string, versionId?: string, options?: {
|
|
212
|
+
preset?: string;
|
|
213
|
+
}): Promise<string>;
|
|
206
214
|
/**
|
|
207
215
|
* The stable public CDN URL for a file in a public bucket, using the project
|
|
208
216
|
* identity the SDK learned at bootstrap -- the runtime form of
|
|
@@ -216,6 +224,7 @@ export declare class KoolbaseStorage {
|
|
|
216
224
|
bucket: string;
|
|
217
225
|
path: string;
|
|
218
226
|
transform?: KoolbaseImageTransform;
|
|
227
|
+
preset?: string;
|
|
219
228
|
}): string;
|
|
220
229
|
/**
|
|
221
230
|
* Build the stable public CDN URL for a file in a public bucket.
|
package/dist/cjs/storage.js
CHANGED
|
@@ -527,13 +527,22 @@ class KoolbaseStorage {
|
|
|
527
527
|
}
|
|
528
528
|
/**
|
|
529
529
|
* Get a signed download URL for a file.
|
|
530
|
+
*
|
|
531
|
+
* `options.preset` names one of the project's image presets (Storage →
|
|
532
|
+
* Presets): an image's current version is then given sized as the preset
|
|
533
|
+
* says -- a private bucket's as a signed, hour-long address -- after the
|
|
534
|
+
* same rules decide whether this person may see it. Anything not an image
|
|
535
|
+
* is given as it is.
|
|
530
536
|
*/
|
|
531
|
-
async getDownloadUrl(bucket, path, versionId) {
|
|
537
|
+
async getDownloadUrl(bucket, path, versionId, options) {
|
|
532
538
|
let url = `${this.config.baseUrl}/v1/sdk/storage/download-url` +
|
|
533
539
|
`?bucket=${encodeURIComponent(bucket)}&path=${encodeURIComponent(path)}`;
|
|
534
540
|
if (versionId) {
|
|
535
541
|
url += `&version_id=${encodeURIComponent(versionId)}`;
|
|
536
542
|
}
|
|
543
|
+
if (options?.preset) {
|
|
544
|
+
url += `&preset=${encodeURIComponent(options.preset)}`;
|
|
545
|
+
}
|
|
537
546
|
const res = await (0, network_js_1.sessionFetch)(url, { headers: await this.buildHeaders() });
|
|
538
547
|
if (!res.ok) {
|
|
539
548
|
throw await this.error(res, 'Failed to get download URL');
|
|
@@ -556,6 +565,9 @@ class KoolbaseStorage {
|
|
|
556
565
|
this.nudgeBootstrap?.();
|
|
557
566
|
throw new storage_errors_js_1.KoolbaseStorageProjectIdentityError();
|
|
558
567
|
}
|
|
568
|
+
// A named preset (Storage → Presets): the edge sizes it; no transform.
|
|
569
|
+
if (args.preset)
|
|
570
|
+
return KoolbaseStorage.publicUrlWithPreset({ projectId: pid, presetName: args.preset, bucket: args.bucket, path: args.path });
|
|
559
571
|
return KoolbaseStorage.publicUrl({ projectId: pid, bucket: args.bucket, path: args.path, transform: args.transform });
|
|
560
572
|
}
|
|
561
573
|
/**
|
package/dist/esm/storage.d.ts
CHANGED
|
@@ -201,8 +201,16 @@ export declare class KoolbaseStorage {
|
|
|
201
201
|
updateMetadata(bucket: string, path: string, metadata: Record<string, string | null>): Promise<KoolbaseObject>;
|
|
202
202
|
/**
|
|
203
203
|
* Get a signed download URL for a file.
|
|
204
|
+
*
|
|
205
|
+
* `options.preset` names one of the project's image presets (Storage →
|
|
206
|
+
* Presets): an image's current version is then given sized as the preset
|
|
207
|
+
* says -- a private bucket's as a signed, hour-long address -- after the
|
|
208
|
+
* same rules decide whether this person may see it. Anything not an image
|
|
209
|
+
* is given as it is.
|
|
204
210
|
*/
|
|
205
|
-
getDownloadUrl(bucket: string, path: string, versionId?: string
|
|
211
|
+
getDownloadUrl(bucket: string, path: string, versionId?: string, options?: {
|
|
212
|
+
preset?: string;
|
|
213
|
+
}): Promise<string>;
|
|
206
214
|
/**
|
|
207
215
|
* The stable public CDN URL for a file in a public bucket, using the project
|
|
208
216
|
* identity the SDK learned at bootstrap -- the runtime form of
|
|
@@ -216,6 +224,7 @@ export declare class KoolbaseStorage {
|
|
|
216
224
|
bucket: string;
|
|
217
225
|
path: string;
|
|
218
226
|
transform?: KoolbaseImageTransform;
|
|
227
|
+
preset?: string;
|
|
219
228
|
}): string;
|
|
220
229
|
/**
|
|
221
230
|
* Build the stable public CDN URL for a file in a public bucket.
|
package/dist/esm/storage.js
CHANGED
|
@@ -524,13 +524,22 @@ export class KoolbaseStorage {
|
|
|
524
524
|
}
|
|
525
525
|
/**
|
|
526
526
|
* Get a signed download URL for a file.
|
|
527
|
+
*
|
|
528
|
+
* `options.preset` names one of the project's image presets (Storage →
|
|
529
|
+
* Presets): an image's current version is then given sized as the preset
|
|
530
|
+
* says -- a private bucket's as a signed, hour-long address -- after the
|
|
531
|
+
* same rules decide whether this person may see it. Anything not an image
|
|
532
|
+
* is given as it is.
|
|
527
533
|
*/
|
|
528
|
-
async getDownloadUrl(bucket, path, versionId) {
|
|
534
|
+
async getDownloadUrl(bucket, path, versionId, options) {
|
|
529
535
|
let url = `${this.config.baseUrl}/v1/sdk/storage/download-url` +
|
|
530
536
|
`?bucket=${encodeURIComponent(bucket)}&path=${encodeURIComponent(path)}`;
|
|
531
537
|
if (versionId) {
|
|
532
538
|
url += `&version_id=${encodeURIComponent(versionId)}`;
|
|
533
539
|
}
|
|
540
|
+
if (options?.preset) {
|
|
541
|
+
url += `&preset=${encodeURIComponent(options.preset)}`;
|
|
542
|
+
}
|
|
534
543
|
const res = await sessionFetch(url, { headers: await this.buildHeaders() });
|
|
535
544
|
if (!res.ok) {
|
|
536
545
|
throw await this.error(res, 'Failed to get download URL');
|
|
@@ -553,6 +562,9 @@ export class KoolbaseStorage {
|
|
|
553
562
|
this.nudgeBootstrap?.();
|
|
554
563
|
throw new KoolbaseStorageProjectIdentityError();
|
|
555
564
|
}
|
|
565
|
+
// A named preset (Storage → Presets): the edge sizes it; no transform.
|
|
566
|
+
if (args.preset)
|
|
567
|
+
return KoolbaseStorage.publicUrlWithPreset({ projectId: pid, presetName: args.preset, bucket: args.bucket, path: args.path });
|
|
556
568
|
return KoolbaseStorage.publicUrl({ projectId: pid, bucket: args.bucket, path: args.path, transform: args.transform });
|
|
557
569
|
}
|
|
558
570
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koolbase/core",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.24.0",
|
|
4
4
|
"description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|