@gigadrive/sdk 0.6.0 → 0.7.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/index.mjs CHANGED
@@ -1903,6 +1903,45 @@ var DeploymentsResource = class extends BaseResource {
1903
1903
  }
1904
1904
  };
1905
1905
 
1906
+ // src/resources/image-optimization.ts
1907
+ var createManagedImageUrl = (options) => {
1908
+ const inferredFilename = options.source.split("/").filter(Boolean).at(-1)?.split("?")[0] || "image.image";
1909
+ const filename = (options.filename ?? inferredFilename).replace(/[^A-Za-z0-9._-]/g, "_") || "image.image";
1910
+ const url = new URL(
1911
+ `/_gigadrive/image/${encodeURIComponent(options.source)}/${encodeURIComponent(filename)}`,
1912
+ options.origin
1913
+ );
1914
+ for (const [name, value] of Object.entries({
1915
+ width: options.width,
1916
+ height: options.height,
1917
+ quality: options.quality,
1918
+ format: options.format,
1919
+ fit: options.fit,
1920
+ variant: options.variant
1921
+ })) {
1922
+ if (value !== void 0) url.searchParams.set(name, String(value));
1923
+ }
1924
+ return url.toString();
1925
+ };
1926
+ var ImageOptimizationResource = class extends BaseResource {
1927
+ /** Create a managed image URL without making an API request. */
1928
+ url(options) {
1929
+ return createManagedImageUrl(options);
1930
+ }
1931
+ /** Inspect the immutable deployment policy and Bunny cache tags used for a source. */
1932
+ inspect(deploymentId, source) {
1933
+ return this.httpClient.get(`/deployments/${deploymentId}/image-cache`, {
1934
+ query: { source }
1935
+ });
1936
+ }
1937
+ /** Purge all variants for one source, or every optimized image in the deployment when omitted. */
1938
+ purge(deploymentId, source) {
1939
+ return this.httpClient.delete(`/deployments/${deploymentId}/image-cache`, {
1940
+ query: { source }
1941
+ });
1942
+ }
1943
+ };
1944
+
1906
1945
  // src/resources/organization-ai-gateway.ts
1907
1946
  var AiGatewayUsageResource = class extends BaseResource {
1908
1947
  /** Get an aggregated usage summary with breakdowns by model, provider, and user. */
@@ -2267,6 +2306,8 @@ var GigadriveClient = class {
2267
2306
  apiKeys;
2268
2307
  /** Signed URLs that keep related requests on one MicroVM instance. */
2269
2308
  stickySessions;
2309
+ /** Managed image optimization inspection and cache purge operations. */
2310
+ imageOptimization;
2270
2311
  constructor(config = {}) {
2271
2312
  const baseUrl = config.baseUrl ?? readEnv("GIGADRIVE_API_BASE_URL") ?? DEFAULT_BASE_URL2;
2272
2313
  const fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
@@ -2279,6 +2320,7 @@ var GigadriveClient = class {
2279
2320
  this.aiGateway = new AiGatewayResource(httpClient);
2280
2321
  this.apiKeys = new ApiKeysResource(httpClient);
2281
2322
  this.stickySessions = new StickySessionsResource(httpClient);
2323
+ this.imageOptimization = new ImageOptimizationResource(httpClient);
2282
2324
  }
2283
2325
  };
2284
2326
 
@@ -2310,6 +2352,7 @@ export {
2310
2352
  DeploymentsResource,
2311
2353
  GigadriveClient,
2312
2354
  GigadriveError,
2355
+ ImageOptimizationResource,
2313
2356
  OrganizationAiGatewayResource,
2314
2357
  OrganizationEnvVarsResource,
2315
2358
  OrganizationMembersResource,
@@ -2321,6 +2364,7 @@ export {
2321
2364
  StorageUploadSessionsResource,
2322
2365
  UploadError,
2323
2366
  UploadSessionExpiredError,
2367
+ createManagedImageUrl,
2324
2368
  paginate,
2325
2369
  parseSSEStream
2326
2370
  };