@bunbase-ae/js 1.0.1-next.7.bc3dec2 → 1.1.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/package.json +1 -2
- package/src/admin.ts +1 -5
- package/src/index.ts +1 -8
- package/src/storage.ts +2 -29
package/package.json
CHANGED
package/src/admin.ts
CHANGED
|
@@ -520,11 +520,7 @@ class AdminCollectionsClient {
|
|
|
520
520
|
if (opts.sort) params.sort = opts.sort;
|
|
521
521
|
if (opts.includeDeleted) params.include_deleted = "true";
|
|
522
522
|
if (opts.search) params.search = opts.search;
|
|
523
|
-
if (opts.filter)
|
|
524
|
-
for (const [field, value] of Object.entries(opts.filter)) {
|
|
525
|
-
params[`filter[${field}]`] = value;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
523
|
+
if (opts.filter) Object.assign(params, opts.filter);
|
|
528
524
|
return this.http.request<AdminListResult<AdminRecord>>(
|
|
529
525
|
"GET",
|
|
530
526
|
`/api/v1/admin/collections/${collection}/records`,
|
package/src/index.ts
CHANGED
|
@@ -38,14 +38,7 @@ export { AuthClient, type AuthSnapshot } from "./auth";
|
|
|
38
38
|
export { BunBaseClient } from "./client";
|
|
39
39
|
export { CollectionClient } from "./collection";
|
|
40
40
|
export { RealtimeClient, type SubscribeOptions } from "./realtime";
|
|
41
|
-
export {
|
|
42
|
-
type ImageTransformFit,
|
|
43
|
-
type ImageTransformFormat,
|
|
44
|
-
type ImageTransformOptions,
|
|
45
|
-
type SignedUploadResult,
|
|
46
|
-
StorageClient,
|
|
47
|
-
type UploadOptions,
|
|
48
|
-
} from "./storage";
|
|
41
|
+
export { type SignedUploadResult, StorageClient, type UploadOptions } from "./storage";
|
|
49
42
|
export {
|
|
50
43
|
type AggregateFunction,
|
|
51
44
|
type AggregateResult,
|
package/src/storage.ts
CHANGED
|
@@ -4,22 +4,6 @@ import type { HttpClient } from "./http";
|
|
|
4
4
|
import type { FileRecord } from "./types";
|
|
5
5
|
import { BunBaseError } from "./types";
|
|
6
6
|
|
|
7
|
-
export type ImageTransformFit = "cover" | "contain" | "inside";
|
|
8
|
-
export type ImageTransformFormat = "webp" | "jpeg" | "png";
|
|
9
|
-
|
|
10
|
-
export interface ImageTransformOptions {
|
|
11
|
-
/** Output width in pixels (1–4096). */
|
|
12
|
-
width?: number;
|
|
13
|
-
/** Output height in pixels (1–4096). */
|
|
14
|
-
height?: number;
|
|
15
|
-
/** How to fit the image into the given dimensions. Default: "inside". */
|
|
16
|
-
fit?: ImageTransformFit;
|
|
17
|
-
/** Convert to this output format. Omit to keep the original format. */
|
|
18
|
-
format?: ImageTransformFormat;
|
|
19
|
-
/** Quality for JPEG/WebP, 1–100. Default: 85. */
|
|
20
|
-
quality?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
7
|
export interface UploadOptions {
|
|
24
8
|
// Target storage bucket. Defaults to "default" if omitted.
|
|
25
9
|
bucket?: string;
|
|
@@ -206,21 +190,10 @@ export class StorageClient {
|
|
|
206
190
|
// Do NOT use this for private files — the browser cannot send the
|
|
207
191
|
// Authorization header via <img src>. For private files, call signedUrl()
|
|
208
192
|
// to get a time-limited signed URL instead.
|
|
209
|
-
downloadUrl(id: string, filename?: string | null
|
|
193
|
+
downloadUrl(id: string, filename?: string | null): string {
|
|
210
194
|
if (id.startsWith("http")) return id;
|
|
211
195
|
const base = `${this.http.baseUrl}/api/v1/storage/${encodeURIComponent(id)}`;
|
|
212
|
-
|
|
213
|
-
if (transform) {
|
|
214
|
-
const params = new URLSearchParams();
|
|
215
|
-
if (transform.width != null) params.set("w", String(transform.width));
|
|
216
|
-
if (transform.height != null) params.set("h", String(transform.height));
|
|
217
|
-
if (transform.fit) params.set("fit", transform.fit);
|
|
218
|
-
if (transform.format) params.set("format", transform.format);
|
|
219
|
-
if (transform.quality != null) params.set("q", String(transform.quality));
|
|
220
|
-
const qs = params.toString();
|
|
221
|
-
if (qs) url = `${url}?${qs}`;
|
|
222
|
-
}
|
|
223
|
-
return url;
|
|
196
|
+
return filename ? `${base}/${encodeURIComponent(filename)}` : base;
|
|
224
197
|
}
|
|
225
198
|
|
|
226
199
|
async list(): Promise<FileRecord[]> {
|