@baasix/sdk 0.1.12 → 0.1.13

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/README.md CHANGED
@@ -493,7 +493,7 @@ const metadata = await baasix.files.upload({
493
493
  // Original file
494
494
  const url = baasix.files.getAssetUrl('file-uuid');
495
495
 
496
- // With transformations
496
+ // Resize to thumbnail
497
497
  const thumbnailUrl = baasix.files.getAssetUrl('file-uuid', {
498
498
  width: 200,
499
499
  height: 200,
@@ -501,8 +501,32 @@ const thumbnailUrl = baasix.files.getAssetUrl('file-uuid', {
501
501
  quality: 80,
502
502
  format: 'webp',
503
503
  });
504
+
505
+ // Convert to WebP without resizing (preserves transparency)
506
+ const webpUrl = baasix.files.getAssetUrl('file-uuid', {
507
+ format: 'webp',
508
+ quality: 85,
509
+ });
510
+
511
+ // Resize without upscaling
512
+ const safeUrl = baasix.files.getAssetUrl('file-uuid', {
513
+ width: 800,
514
+ format: 'webp',
515
+ withoutEnlargement: true,
516
+ });
504
517
  ```
505
518
 
519
+ **`AssetTransformOptions`:**
520
+
521
+ | Option | Type | Default | Description |
522
+ | -------------------- | --------------------------------- | --------- | --------------------------------------------------------------------------- |
523
+ | `width` | `number` | — | Target width in pixels |
524
+ | `height` | `number` | — | Target height in pixels |
525
+ | `fit` | `'cover'\|'contain'\|'fill'\|'inside'\|'outside'` | `'cover'` | Resize fit mode |
526
+ | `quality` | `number` (1–100) | `80` | Output quality |
527
+ | `format` | `'jpeg'\|'png'\|'webp'\|'avif'` | `'jpeg'` | Output format. `webp` and `png` preserve alpha transparency; `jpeg` flattens transparency to white |
528
+ | `withoutEnlargement` | `boolean` | `false` | Prevent upscaling images smaller than the target dimensions |
529
+
506
530
  ### File Operations
507
531
 
508
532
  ```typescript
package/dist/index.cjs CHANGED
@@ -1875,6 +1875,16 @@ var FilesModule = class {
1875
1875
  /**
1876
1876
  * Get the URL for an asset with optional transformations
1877
1877
  *
1878
+ * @param id - File UUID
1879
+ * @param options - Optional transformation options
1880
+ * @param options.width - Target width in pixels
1881
+ * @param options.height - Target height in pixels
1882
+ * @param options.fit - Resize fit mode: 'cover' | 'contain' | 'fill' | 'inside' | 'outside' (default: 'cover')
1883
+ * @param options.quality - Output quality 1–100 (default: 80)
1884
+ * @param options.format - Output format: 'jpeg' | 'png' | 'webp' | 'avif' (default: 'jpeg').
1885
+ * 'webp' and 'png' preserve alpha transparency; 'jpeg' composites transparency over a white background.
1886
+ * @param options.withoutEnlargement - When true, prevents upscaling images smaller than the target dimensions
1887
+ *
1878
1888
  * @example
1879
1889
  * ```typescript
1880
1890
  * // Original file
@@ -1888,11 +1898,21 @@ var FilesModule = class {
1888
1898
  * quality: 80
1889
1899
  * });
1890
1900
  *
1891
- * // Convert to WebP
1901
+ * // Convert to WebP (preserves transparency)
1892
1902
  * const webpUrl = baasix.files.getAssetUrl('file-uuid', {
1893
1903
  * format: 'webp',
1894
1904
  * quality: 85
1895
1905
  * });
1906
+ *
1907
+ * // Resize and convert to WebP
1908
+ * const optimizedUrl = baasix.files.getAssetUrl('file-uuid', {
1909
+ * width: 800,
1910
+ * height: 600,
1911
+ * fit: 'cover',
1912
+ * format: 'webp',
1913
+ * quality: 80,
1914
+ * withoutEnlargement: true
1915
+ * });
1896
1916
  * ```
1897
1917
  */
1898
1918
  getAssetUrl(id, options) {
@@ -1946,7 +1966,10 @@ var FilesModule = class {
1946
1966
  * @example
1947
1967
  * ```typescript
1948
1968
  * const base64 = await baasix.files.toBase64('file-uuid');
1949
- * // Use in Image component: <Image source={{ uri: `data:image/jpeg;base64,${base64}` }} />
1969
+ * // Use in Image component: <Image source={{ uri: `data:image/webp;base64,${base64}` }} />
1970
+ *
1971
+ * // Convert to WebP first for smaller payload
1972
+ * const base64Webp = await baasix.files.toBase64('file-uuid', { format: 'webp', quality: 80 });
1950
1973
  * ```
1951
1974
  */
1952
1975
  async toBase64(id, options) {