@baasix/sdk 0.1.12 → 0.1.14

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
@@ -463,6 +463,8 @@ Baasix supports 50+ filter operators:
463
463
 
464
464
  // Dynamic variables
465
465
  { author_Id: { eq: '$CURRENT_USER' } }
466
+ { tenant_Id: { eq: '$CURRENT_TENANT' } }
467
+ { currency: { eq: '$CURRENT_SETTINGS.currency' } }
466
468
  { createdAt: { gte: '$NOW-DAYS_30' } }
467
469
  ```
468
470
 
@@ -493,7 +495,7 @@ const metadata = await baasix.files.upload({
493
495
  // Original file
494
496
  const url = baasix.files.getAssetUrl('file-uuid');
495
497
 
496
- // With transformations
498
+ // Resize to thumbnail
497
499
  const thumbnailUrl = baasix.files.getAssetUrl('file-uuid', {
498
500
  width: 200,
499
501
  height: 200,
@@ -501,8 +503,32 @@ const thumbnailUrl = baasix.files.getAssetUrl('file-uuid', {
501
503
  quality: 80,
502
504
  format: 'webp',
503
505
  });
506
+
507
+ // Convert to WebP without resizing (preserves transparency)
508
+ const webpUrl = baasix.files.getAssetUrl('file-uuid', {
509
+ format: 'webp',
510
+ quality: 85,
511
+ });
512
+
513
+ // Resize without upscaling
514
+ const safeUrl = baasix.files.getAssetUrl('file-uuid', {
515
+ width: 800,
516
+ format: 'webp',
517
+ withoutEnlargement: true,
518
+ });
504
519
  ```
505
520
 
521
+ **`AssetTransformOptions`:**
522
+
523
+ | Option | Type | Default | Description |
524
+ | -------------------- | --------------------------------- | --------- | --------------------------------------------------------------------------- |
525
+ | `width` | `number` | — | Target width in pixels |
526
+ | `height` | `number` | — | Target height in pixels |
527
+ | `fit` | `'cover'\|'contain'\|'fill'\|'inside'\|'outside'` | `'cover'` | Resize fit mode |
528
+ | `quality` | `number` (1–100) | `80` | Output quality |
529
+ | `format` | `'jpeg'\|'png'\|'webp'\|'avif'` | `'jpeg'` | Output format. `webp` and `png` preserve alpha transparency; `jpeg` flattens transparency to white |
530
+ | `withoutEnlargement` | `boolean` | `false` | Prevent upscaling images smaller than the target dimensions |
531
+
506
532
  ### File Operations
507
533
 
508
534
  ```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) {