@calmlens/sdk 0.10.1 → 0.11.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/README.md CHANGED
@@ -195,7 +195,7 @@ For several lenses, use `ensureLenses()` to perform all ensures in one request.
195
195
  const [normal, uhd] = await client.ensureLenses({ lenses: [normalLens, uhdLens] });
196
196
  ```
197
197
 
198
- The CDN uses named lenses with an `@` prefix in URLs, such as `/content/@picmagic-normal`. The SDK adds it automatically when you supply `lens`. Use `transform` for one-off direct transforms, for example `client.cdn.serve({ assetIdentifier: assetId, transform: "imageTransform[format=png,width=1024]" })`. Supply either `lens` or `transform`, not both. The resolved lens version is part of CalmLens's CDN cache and ETag identity, so changing a lens with the next version invalidates prior derived output.
198
+ The CDN uses named lenses with an `@` prefix in URLs, such as `/content/@picmagic-normal`. The SDK adds it automatically when you supply `lens`. Use `transform` for one-off direct transforms, either as structured steps, for example `client.cdn.serve({ assetIdentifier: assetId, transform: { type: "imageTransform", options: { format: "png", width: 1024 } } })`, or as a selector string such as `"imageTransform[format=png,width=1024]"`. Pass an array of steps to chain transforms. `assets.createSignedUrl` accepts the same forms. Supply either `lens` or `transform`, not both. The resolved lens version is part of CalmLens's CDN cache and ETag identity, so changing a lens with the next version invalidates prior derived output.
199
199
 
200
200
  ##### assets.list(options)
201
201
 
@@ -8407,6 +8407,11 @@ type LensTransform = {
8407
8407
  type: string;
8408
8408
  options: unknown;
8409
8409
  };
8410
+ /**
8411
+ * A CDN transform: a selector string such as `imageTransform[format=png,width=1024]`, or one
8412
+ * or more structured steps such as `{ type: "imageTransform", options: { format: "png" } }`.
8413
+ */
8414
+ type CdnTransform = string | LensTransform | LensTransform[];
8410
8415
  /** A named, versioned CDN transformation. */
8411
8416
  type Lens = Omit<zod.infer<typeof LENS_SCHEMA>, "transforms"> & {
8412
8417
  transforms?: LensTransform[] | null;
@@ -8467,7 +8472,7 @@ interface CdnAssetUrlOptions {
8467
8472
  assetIdentifier: string;
8468
8473
  resource?: "content" | "preview";
8469
8474
  lens?: string;
8470
- transform?: string;
8475
+ transform?: CdnTransform;
8471
8476
  }
8472
8477
  interface CdnServeOptions extends CdnAssetUrlOptions {
8473
8478
  init?: RequestInit;
@@ -8476,7 +8481,7 @@ interface CreateAssetSignedUrlOptions {
8476
8481
  assetId: string;
8477
8482
  resource?: "content" | "preview";
8478
8483
  lens?: string;
8479
- transform?: string;
8484
+ transform?: CdnTransform;
8480
8485
  expiresInSeconds?: number;
8481
8486
  }
8482
8487
  type EnsureLensOptions = Pick<Lens, "identifier" | "name" | "description" | "type" | "active" | "transforms" | "version">;
@@ -8605,4 +8610,4 @@ interface ModerateTextOptions extends Omit<SubmitAssetCommonOptions, "name" | "v
8605
8610
  name?: string;
8606
8611
  }
8607
8612
  //#endregion
8608
- export { EventCategory as $, ModerateTextOptions as A, UpdateFolderOptions as B, IterateAssetChildrenOptions as C, ListAssetChildrenOptions as D, LensTransform as E, RequestOptions as F, AssetSearchQuery as G, VerifyWebhookSignatureOptions as H, RetrieveAssetOptions as I, PostAssetSignedUrlResponse as J, WebhookEventPayload as K, RetryAssetOptions as L, MoveFolderOptions as M, MultipartUploadOptions as N, ListAssetsOptions as O, MultipartUploadPartOptions as P, TypedEvent as Q, SubmitAssetOptions as R, ImageTransformOptions as S, Lens as T, WebhookHeadersInput as U, UploadAssetPartOptions as V, WebhookPayloadInput as W, Folder as X, AssetBinaryPayloadInput as Y, Event as Z, DeleteAssetOptions as _, AssetSearchResponse as a, ClassificationCategory as at, FolderIdOptions as b, AssetType as c, MetadataItem as ct, CdnAssetUrlOptions as d, EventFact as et, CdnServeOptions as f, DeleteAssetContentOptions as g, CreateMultipartUploadPartOptions as h, AssetPage as i, EventType as it, MoveAssetOptions as j, ListEventsOptions as k, AssetVisibility as l, ProcessingOptions as lt, CreateFolderOptions as m, AssetChildrenPage as n, EventFacts as nt, AssetSearchResult as o, ClassificationCategoryReport as ot, CreateAssetSignedUrlOptions as p, GetEventsResponse as q, AssetContentOptions as r, EventSeverity as rt, AssetStatus as s, ClassificationReport as st, Asset as t, EventFactValues as tt, CalmLensClientOptions as u, EnsureLensOptions as v, IterateAssetsOptions as w, IdempotencyOptions as x, EnsureLensesOptions as y, UpdateAssetOptions as z };
8613
+ export { TypedEvent as $, ListEventsOptions as A, UpdateAssetOptions as B, ImageTransformOptions as C, LensTransform as D, Lens as E, MultipartUploadPartOptions as F, WebhookPayloadInput as G, UploadAssetPartOptions as H, RequestOptions as I, GetEventsResponse as J, AssetSearchQuery as K, RetrieveAssetOptions as L, MoveAssetOptions as M, MoveFolderOptions as N, ListAssetChildrenOptions as O, MultipartUploadOptions as P, Event as Q, RetryAssetOptions as R, IdempotencyOptions as S, IterateAssetsOptions as T, VerifyWebhookSignatureOptions as U, UpdateFolderOptions as V, WebhookHeadersInput as W, AssetBinaryPayloadInput as X, PostAssetSignedUrlResponse as Y, Folder as Z, DeleteAssetContentOptions as _, AssetSearchResponse as a, EventType as at, EnsureLensesOptions as b, AssetType as c, ClassificationReport as ct, CdnAssetUrlOptions as d, EventCategory as et, CdnServeOptions as f, CreateMultipartUploadPartOptions as g, CreateFolderOptions as h, AssetPage as i, EventSeverity as it, ModerateTextOptions as j, ListAssetsOptions as k, AssetVisibility as l, MetadataItem as lt, CreateAssetSignedUrlOptions as m, AssetChildrenPage as n, EventFactValues as nt, AssetSearchResult as o, ClassificationCategory as ot, CdnTransform as p, WebhookEventPayload as q, AssetContentOptions as r, EventFacts as rt, AssetStatus as s, ClassificationCategoryReport as st, Asset as t, EventFact as tt, CalmLensClientOptions as u, ProcessingOptions as ut, DeleteAssetOptions as v, IterateAssetChildrenOptions as w, FolderIdOptions as x, EnsureLensOptions as y, SubmitAssetOptions as z };
@@ -428,14 +428,51 @@ const encodePathSegment = (value, name) => {
428
428
  if (value === "." || value === "..") throw invalidArgument(`${name} cannot be "." or ".."`);
429
429
  return encodeURIComponent(value);
430
430
  };
431
+ const TRANSFORM_TYPE_PATTERN = /^[A-Za-z0-9_]+$/;
432
+ /** Percent-encodes everything except RFC 3986 unreserved characters (`A-Z a-z 0-9 - . _ ~`). */
433
+ const encodeTransformComponent = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
434
+ const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
435
+ const appendTransformOptions = (pairs, key, value) => {
436
+ if (value === void 0 || value === null) return;
437
+ if (isPlainObject(value)) {
438
+ for (const child of Object.keys(value).sort()) appendTransformOptions(pairs, `${key}[${child}]`, value[child]);
439
+ return;
440
+ }
441
+ let text;
442
+ if (typeof value === "string") text = value;
443
+ else if (typeof value === "boolean") text = String(value);
444
+ else if (typeof value === "number" && Number.isFinite(value)) text = String(value);
445
+ else throw invalidArgument(`Transform option "${key}" must be a string, number, boolean or object`);
446
+ pairs.push(`${encodeTransformComponent(key)}=${encodeTransformComponent(text)}`);
447
+ };
448
+ /**
449
+ * Serializes structured transforms as a CDN selector, such as
450
+ * `imageTransform[format=png,width=1024]`. Option keys are sorted so equal transforms share a
451
+ * URL; nested keys (`border[color]`) and values are percent-encoded.
452
+ */
453
+ const serializeTransform = (transform) => {
454
+ const steps = Array.isArray(transform) ? transform : [transform];
455
+ if (steps.length === 0) throw invalidArgument("Transform needs at least one step");
456
+ return steps.map((step) => {
457
+ if (!isPlainObject(step)) throw invalidArgument("Transform steps must be objects");
458
+ if (typeof step.type !== "string" || !TRANSFORM_TYPE_PATTERN.test(step.type)) throw invalidArgument("Transform type must contain only letters, digits and underscores");
459
+ if (step.options !== void 0 && step.options !== null && !isPlainObject(step.options)) throw invalidArgument("Transform options must be an object");
460
+ const pairs = [];
461
+ for (const key of Object.keys(step.options ?? {}).sort()) appendTransformOptions(pairs, key, step.options[key]);
462
+ return `${step.type}[${pairs.join(",")}]`;
463
+ }).join(",");
464
+ };
465
+ /** Returns the selector string the API and CDN accept for a string or structured transform. */
466
+ const transformSelector = (transform) => transform === void 0 || typeof transform === "string" ? transform : serializeTransform(transform);
431
467
  /** Appends a CDN lens (`/@name`) or direct transform selector to an asset URL. */
432
468
  const appendCdnSelector = (url, options) => {
433
469
  if (options.lens && options.transform) throw invalidArgument("Specify either a lens or a transform, not both");
434
470
  if (options.lens) return `${url}/@${encodePathSegment(options.lens, "Lens")}`;
435
471
  if (!options.transform) return url;
472
+ if (typeof options.transform !== "string") return `${url}/${serializeTransform(options.transform)}`;
436
473
  const transform = options.transform.replace(/^\/+/, "");
437
474
  if (transform.includes("..") || transform.includes("?") || transform.includes("#")) throw invalidArgument("Transform cannot contain \"..\", \"?\" or \"#\"");
438
- return `${url}/${encodeURI(transform)}`;
475
+ return `${url}/${encodeURI(transform).replace(/%5B/g, "[").replace(/%5D/g, "]")}`;
439
476
  };
440
477
  const appendQueryValue = (parts, key, value) => {
441
478
  if (value === void 0 || value === null) return;
@@ -715,6 +752,12 @@ Object.defineProperty(exports, "toTextAssetOptions", {
715
752
  return toTextAssetOptions;
716
753
  }
717
754
  });
755
+ Object.defineProperty(exports, "transformSelector", {
756
+ enumerable: true,
757
+ get: function() {
758
+ return transformSelector;
759
+ }
760
+ });
718
761
  Object.defineProperty(exports, "validateAssetPayload", {
719
762
  enumerable: true,
720
763
  get: function() {
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as EventCategory, A as ModerateTextOptions, B as UpdateFolderOptions, C as IterateAssetChildrenOptions, D as ListAssetChildrenOptions, E as LensTransform, F as RequestOptions, G as AssetSearchQuery, H as VerifyWebhookSignatureOptions, I as RetrieveAssetOptions, J as PostAssetSignedUrlResponse, K as WebhookEventPayload, L as RetryAssetOptions, M as MoveFolderOptions, N as MultipartUploadOptions, O as ListAssetsOptions, P as MultipartUploadPartOptions, Q as TypedEvent, R as SubmitAssetOptions, S as ImageTransformOptions, T as Lens, U as WebhookHeadersInput, V as UploadAssetPartOptions, W as WebhookPayloadInput, X as Folder, _ as DeleteAssetOptions, a as AssetSearchResponse, b as FolderIdOptions, c as AssetType, ct as MetadataItem, d as CdnAssetUrlOptions, et as EventFact, f as CdnServeOptions, g as DeleteAssetContentOptions, h as CreateMultipartUploadPartOptions, i as AssetPage, it as EventType, j as MoveAssetOptions, k as ListEventsOptions, l as AssetVisibility, lt as ProcessingOptions, m as CreateFolderOptions, n as AssetChildrenPage, nt as EventFacts, o as AssetSearchResult, ot as ClassificationCategoryReport, p as CreateAssetSignedUrlOptions, q as GetEventsResponse, r as AssetContentOptions, rt as EventSeverity, s as AssetStatus, st as ClassificationReport, t as Asset, tt as EventFactValues, u as CalmLensClientOptions, v as EnsureLensOptions, w as IterateAssetsOptions, x as IdempotencyOptions, y as EnsureLensesOptions, z as UpdateAssetOptions } from "./CalmLensTypes-DjYFaTyh.js";
1
+ import { $ as TypedEvent, A as ListEventsOptions, B as UpdateAssetOptions, C as ImageTransformOptions, D as LensTransform, E as Lens, F as MultipartUploadPartOptions, G as WebhookPayloadInput, H as UploadAssetPartOptions, I as RequestOptions, J as GetEventsResponse, K as AssetSearchQuery, L as RetrieveAssetOptions, M as MoveAssetOptions, N as MoveFolderOptions, O as ListAssetChildrenOptions, P as MultipartUploadOptions, R as RetryAssetOptions, S as IdempotencyOptions, T as IterateAssetsOptions, U as VerifyWebhookSignatureOptions, V as UpdateFolderOptions, W as WebhookHeadersInput, Y as PostAssetSignedUrlResponse, Z as Folder, _ as DeleteAssetContentOptions, a as AssetSearchResponse, at as EventType, b as EnsureLensesOptions, c as AssetType, ct as ClassificationReport, d as CdnAssetUrlOptions, et as EventCategory, f as CdnServeOptions, g as CreateMultipartUploadPartOptions, h as CreateFolderOptions, i as AssetPage, it as EventSeverity, j as ModerateTextOptions, k as ListAssetsOptions, l as AssetVisibility, lt as MetadataItem, m as CreateAssetSignedUrlOptions, n as AssetChildrenPage, nt as EventFactValues, o as AssetSearchResult, p as CdnTransform, q as WebhookEventPayload, r as AssetContentOptions, rt as EventFacts, s as AssetStatus, st as ClassificationCategoryReport, t as Asset, tt as EventFact, u as CalmLensClientOptions, ut as ProcessingOptions, v as DeleteAssetOptions, w as IterateAssetChildrenOptions, x as FolderIdOptions, y as EnsureLensOptions, z as SubmitAssetOptions } from "./CalmLensTypes-BZ-nxhr_.js";
2
2
  //#region src/client/CalmLensClient.d.ts
3
3
  interface ClientState {
4
4
  readonly options: Omit<CalmLensClientOptions, "apiKey"> & {
@@ -379,4 +379,4 @@ export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOp
379
379
  */
380
380
  export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<WebhookEventPayload>;
381
381
  //#endregion
382
- export { type ApiErrorCode, type Asset, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, CalmLensClient, type CalmLensClientOptions, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CdnAssetUrlOptions, type CdnServeOptions, type ClassificationCategoryReport, type ClassificationReport, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type EnsureLensOptions, type EnsureLensesOptions, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, type SdkErrorCode, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
382
+ export { type ApiErrorCode, type Asset, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, CalmLensClient, type CalmLensClientOptions, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategoryReport, type ClassificationReport, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type EnsureLensOptions, type EnsureLensesOptions, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, type SdkErrorCode, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_CalmLensWebhooks = require("./CalmLensWebhooks-DJnaLpRy.js");
2
+ const require_CalmLensWebhooks = require("./CalmLensWebhooks-CH2PaPs0.js");
3
3
  //#endregion
4
4
  //#region src/client/CalmLensVersion.ts
5
5
  /** This SDK's version, from its package.json. */
6
- const SDK_VERSION = "0.10.1";
6
+ const SDK_VERSION = "0.11.0";
7
7
  const runtimeName = () => {
8
8
  const runtime = globalThis;
9
9
  if (runtime.Bun?.version) return `bun/${runtime.Bun.version}`;
@@ -677,7 +677,7 @@ moderate: async (options) => this.assets.moderate(require_CalmLensWebhooks.toTex
677
677
  resource: options.resource ?? "content",
678
678
  expiresInSeconds: options.expiresInSeconds ?? 900,
679
679
  lens: options.lens,
680
- transform: options.transform
680
+ transform: require_CalmLensWebhooks.transformSelector(options.transform)
681
681
  } });
682
682
  },
683
683
  /** Moves an asset into a folder, or to the project root with `folderId: null`. */
package/cjs/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ModerateTextOptions, B as UpdateFolderOptions, C as IterateAssetChildrenOptions, D as ListAssetChildrenOptions, G as AssetSearchQuery, I as RetrieveAssetOptions, J as PostAssetSignedUrlResponse, K as WebhookEventPayload, L as RetryAssetOptions, M as MoveFolderOptions, O as ListAssetsOptions, Q as TypedEvent, R as SubmitAssetOptions, T as Lens, V as UploadAssetPartOptions, X as Folder, Y as AssetBinaryPayloadInput, Z as Event, _ as DeleteAssetOptions, a as AssetSearchResponse, at as ClassificationCategory, b as FolderIdOptions, d as CdnAssetUrlOptions, f as CdnServeOptions, g as DeleteAssetContentOptions, i as AssetPage, j as MoveAssetOptions, k as ListEventsOptions, m as CreateFolderOptions, n as AssetChildrenPage, p as CreateAssetSignedUrlOptions, q as GetEventsResponse, s as AssetStatus, t as Asset, u as CalmLensClientOptions, v as EnsureLensOptions, w as IterateAssetsOptions, y as EnsureLensesOptions, z as UpdateAssetOptions } from "./CalmLensTypes-DjYFaTyh.js";
1
+ import { $ as TypedEvent, A as ListEventsOptions, B as UpdateAssetOptions, E as Lens, H as UploadAssetPartOptions, J as GetEventsResponse, K as AssetSearchQuery, L as RetrieveAssetOptions, M as MoveAssetOptions, N as MoveFolderOptions, O as ListAssetChildrenOptions, Q as Event, R as RetryAssetOptions, T as IterateAssetsOptions, V as UpdateFolderOptions, X as AssetBinaryPayloadInput, Y as PostAssetSignedUrlResponse, Z as Folder, _ as DeleteAssetContentOptions, a as AssetSearchResponse, b as EnsureLensesOptions, d as CdnAssetUrlOptions, f as CdnServeOptions, h as CreateFolderOptions, i as AssetPage, j as ModerateTextOptions, k as ListAssetsOptions, m as CreateAssetSignedUrlOptions, n as AssetChildrenPage, ot as ClassificationCategory, q as WebhookEventPayload, s as AssetStatus, t as Asset, u as CalmLensClientOptions, v as DeleteAssetOptions, w as IterateAssetChildrenOptions, x as FolderIdOptions, y as EnsureLensOptions, z as SubmitAssetOptions } from "./CalmLensTypes-BZ-nxhr_.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/TestTriggers.d.ts
4
4
  type ClassificationTestSignal = ClassificationCategory | "sexual.involving-minors" | "violence.graphic";
package/cjs/testing.js CHANGED
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  enumerable: true
22
22
  }) : target, mod));
23
23
  //#endregion
24
- const require_CalmLensWebhooks = require("./CalmLensWebhooks-DJnaLpRy.js");
24
+ const require_CalmLensWebhooks = require("./CalmLensWebhooks-CH2PaPs0.js");
25
25
  let zod = require("zod");
26
26
  zod = __toESM(zod);
27
27
  require("zod/v4");
@@ -936,7 +936,8 @@ var MockCalmLensClient = class {
936
936
  if (options.lens && options.transform) throw require_CalmLensWebhooks.invalidArgument("Specify either a lens or a transform, not both");
937
937
  const expiresInSeconds = options.expiresInSeconds ?? 900;
938
938
  const resource = options.resource ?? "content";
939
- const selector = options.lens ? `&lens=${encodeURIComponent(options.lens)}` : options.transform ? `&transform=${encodeURIComponent(options.transform)}` : "";
939
+ const transform = require_CalmLensWebhooks.transformSelector(options.transform);
940
+ const selector = options.lens ? `&lens=${encodeURIComponent(options.lens)}` : transform ? `&transform=${encodeURIComponent(transform)}` : "";
940
941
  return {
941
942
  url: `${this.signedUrlBaseUrl}/assets/${asset.id}/${resource}?expiresInSeconds=${expiresInSeconds}${selector}`,
942
943
  expiresAt: this.now() + expiresInSeconds * 1e3
@@ -8407,6 +8407,11 @@ type LensTransform = {
8407
8407
  type: string;
8408
8408
  options: unknown;
8409
8409
  };
8410
+ /**
8411
+ * A CDN transform: a selector string such as `imageTransform[format=png,width=1024]`, or one
8412
+ * or more structured steps such as `{ type: "imageTransform", options: { format: "png" } }`.
8413
+ */
8414
+ type CdnTransform = string | LensTransform | LensTransform[];
8410
8415
  /** A named, versioned CDN transformation. */
8411
8416
  type Lens = Omit<zod.infer<typeof LENS_SCHEMA>, "transforms"> & {
8412
8417
  transforms?: LensTransform[] | null;
@@ -8467,7 +8472,7 @@ interface CdnAssetUrlOptions {
8467
8472
  assetIdentifier: string;
8468
8473
  resource?: "content" | "preview";
8469
8474
  lens?: string;
8470
- transform?: string;
8475
+ transform?: CdnTransform;
8471
8476
  }
8472
8477
  interface CdnServeOptions extends CdnAssetUrlOptions {
8473
8478
  init?: RequestInit;
@@ -8476,7 +8481,7 @@ interface CreateAssetSignedUrlOptions {
8476
8481
  assetId: string;
8477
8482
  resource?: "content" | "preview";
8478
8483
  lens?: string;
8479
- transform?: string;
8484
+ transform?: CdnTransform;
8480
8485
  expiresInSeconds?: number;
8481
8486
  }
8482
8487
  type EnsureLensOptions = Pick<Lens, "identifier" | "name" | "description" | "type" | "active" | "transforms" | "version">;
@@ -8605,4 +8610,4 @@ interface ModerateTextOptions extends Omit<SubmitAssetCommonOptions, "name" | "v
8605
8610
  name?: string;
8606
8611
  }
8607
8612
  //#endregion
8608
- export { EventCategory as $, ModerateTextOptions as A, UpdateFolderOptions as B, IterateAssetChildrenOptions as C, ListAssetChildrenOptions as D, LensTransform as E, RequestOptions as F, AssetSearchQuery as G, VerifyWebhookSignatureOptions as H, RetrieveAssetOptions as I, PostAssetSignedUrlResponse as J, WebhookEventPayload as K, RetryAssetOptions as L, MoveFolderOptions as M, MultipartUploadOptions as N, ListAssetsOptions as O, MultipartUploadPartOptions as P, TypedEvent as Q, SubmitAssetOptions as R, ImageTransformOptions as S, Lens as T, WebhookHeadersInput as U, UploadAssetPartOptions as V, WebhookPayloadInput as W, Folder as X, AssetBinaryPayloadInput as Y, Event as Z, DeleteAssetOptions as _, AssetSearchResponse as a, ClassificationCategory as at, FolderIdOptions as b, AssetType as c, MetadataItem as ct, CdnAssetUrlOptions as d, EventFact as et, CdnServeOptions as f, DeleteAssetContentOptions as g, CreateMultipartUploadPartOptions as h, AssetPage as i, EventType as it, MoveAssetOptions as j, ListEventsOptions as k, AssetVisibility as l, ProcessingOptions as lt, CreateFolderOptions as m, AssetChildrenPage as n, EventFacts as nt, AssetSearchResult as o, ClassificationCategoryReport as ot, CreateAssetSignedUrlOptions as p, GetEventsResponse as q, AssetContentOptions as r, EventSeverity as rt, AssetStatus as s, ClassificationReport as st, Asset as t, EventFactValues as tt, CalmLensClientOptions as u, EnsureLensOptions as v, IterateAssetsOptions as w, IdempotencyOptions as x, EnsureLensesOptions as y, UpdateAssetOptions as z };
8613
+ export { TypedEvent as $, ListEventsOptions as A, UpdateAssetOptions as B, ImageTransformOptions as C, LensTransform as D, Lens as E, MultipartUploadPartOptions as F, WebhookPayloadInput as G, UploadAssetPartOptions as H, RequestOptions as I, GetEventsResponse as J, AssetSearchQuery as K, RetrieveAssetOptions as L, MoveAssetOptions as M, MoveFolderOptions as N, ListAssetChildrenOptions as O, MultipartUploadOptions as P, Event as Q, RetryAssetOptions as R, IdempotencyOptions as S, IterateAssetsOptions as T, VerifyWebhookSignatureOptions as U, UpdateFolderOptions as V, WebhookHeadersInput as W, AssetBinaryPayloadInput as X, PostAssetSignedUrlResponse as Y, Folder as Z, DeleteAssetContentOptions as _, AssetSearchResponse as a, EventType as at, EnsureLensesOptions as b, AssetType as c, ClassificationReport as ct, CdnAssetUrlOptions as d, EventCategory as et, CdnServeOptions as f, CreateMultipartUploadPartOptions as g, CreateFolderOptions as h, AssetPage as i, EventSeverity as it, ModerateTextOptions as j, ListAssetsOptions as k, AssetVisibility as l, MetadataItem as lt, CreateAssetSignedUrlOptions as m, AssetChildrenPage as n, EventFactValues as nt, AssetSearchResult as o, ClassificationCategory as ot, CdnTransform as p, WebhookEventPayload as q, AssetContentOptions as r, EventFacts as rt, AssetStatus as s, ClassificationCategoryReport as st, Asset as t, EventFact as tt, CalmLensClientOptions as u, ProcessingOptions as ut, DeleteAssetOptions as v, IterateAssetChildrenOptions as w, FolderIdOptions as x, EnsureLensOptions as y, SubmitAssetOptions as z };
@@ -428,14 +428,51 @@ const encodePathSegment = (value, name) => {
428
428
  if (value === "." || value === "..") throw invalidArgument(`${name} cannot be "." or ".."`);
429
429
  return encodeURIComponent(value);
430
430
  };
431
+ const TRANSFORM_TYPE_PATTERN = /^[A-Za-z0-9_]+$/;
432
+ /** Percent-encodes everything except RFC 3986 unreserved characters (`A-Z a-z 0-9 - . _ ~`). */
433
+ const encodeTransformComponent = (value) => encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
434
+ const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
435
+ const appendTransformOptions = (pairs, key, value) => {
436
+ if (value === void 0 || value === null) return;
437
+ if (isPlainObject(value)) {
438
+ for (const child of Object.keys(value).sort()) appendTransformOptions(pairs, `${key}[${child}]`, value[child]);
439
+ return;
440
+ }
441
+ let text;
442
+ if (typeof value === "string") text = value;
443
+ else if (typeof value === "boolean") text = String(value);
444
+ else if (typeof value === "number" && Number.isFinite(value)) text = String(value);
445
+ else throw invalidArgument(`Transform option "${key}" must be a string, number, boolean or object`);
446
+ pairs.push(`${encodeTransformComponent(key)}=${encodeTransformComponent(text)}`);
447
+ };
448
+ /**
449
+ * Serializes structured transforms as a CDN selector, such as
450
+ * `imageTransform[format=png,width=1024]`. Option keys are sorted so equal transforms share a
451
+ * URL; nested keys (`border[color]`) and values are percent-encoded.
452
+ */
453
+ const serializeTransform = (transform) => {
454
+ const steps = Array.isArray(transform) ? transform : [transform];
455
+ if (steps.length === 0) throw invalidArgument("Transform needs at least one step");
456
+ return steps.map((step) => {
457
+ if (!isPlainObject(step)) throw invalidArgument("Transform steps must be objects");
458
+ if (typeof step.type !== "string" || !TRANSFORM_TYPE_PATTERN.test(step.type)) throw invalidArgument("Transform type must contain only letters, digits and underscores");
459
+ if (step.options !== void 0 && step.options !== null && !isPlainObject(step.options)) throw invalidArgument("Transform options must be an object");
460
+ const pairs = [];
461
+ for (const key of Object.keys(step.options ?? {}).sort()) appendTransformOptions(pairs, key, step.options[key]);
462
+ return `${step.type}[${pairs.join(",")}]`;
463
+ }).join(",");
464
+ };
465
+ /** Returns the selector string the API and CDN accept for a string or structured transform. */
466
+ const transformSelector = (transform) => transform === void 0 || typeof transform === "string" ? transform : serializeTransform(transform);
431
467
  /** Appends a CDN lens (`/@name`) or direct transform selector to an asset URL. */
432
468
  const appendCdnSelector = (url, options) => {
433
469
  if (options.lens && options.transform) throw invalidArgument("Specify either a lens or a transform, not both");
434
470
  if (options.lens) return `${url}/@${encodePathSegment(options.lens, "Lens")}`;
435
471
  if (!options.transform) return url;
472
+ if (typeof options.transform !== "string") return `${url}/${serializeTransform(options.transform)}`;
436
473
  const transform = options.transform.replace(/^\/+/, "");
437
474
  if (transform.includes("..") || transform.includes("?") || transform.includes("#")) throw invalidArgument("Transform cannot contain \"..\", \"?\" or \"#\"");
438
- return `${url}/${encodeURI(transform)}`;
475
+ return `${url}/${encodeURI(transform).replace(/%5B/g, "[").replace(/%5D/g, "]")}`;
439
476
  };
440
477
  const appendQueryValue = (parts, key, value) => {
441
478
  if (value === void 0 || value === null) return;
@@ -553,4 +590,4 @@ async function parseWebhookEvent(options) {
553
590
  return event;
554
591
  }
555
592
  //#endregion
556
- export { getRawBase64 as A, MIN_MULTIPART_IMAGE_UPLOAD_BYTES as C, assetDataToUint8Array as D, stringifyJsonCanonical as E, assetToData as O, MAX_IMAGE_UPLOAD_BYTES as S, isRejectedUploadMimeType as T, invalidArgument as _, parseWebhookEvent as a, API_ERROR_DEFINITIONS as b, appendCdnSelector as c, toTextAssetOptions as d, validateClientOptions as f, SDK_ERROR_CODES as g, CalmLensError as h, WEBHOOK_TIMESTAMP_HEADER as i, validateAssetPayload as j, getAssetPayloadByteLength as k, encodePathSegment as l, CALMLENS_ERROR_CODES as m, WEBHOOK_SIGNATURE_HEADER as n, verifyWebhookSignature as o, validateRequestOptions as p, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS as r, hmacSha256Hex as s, WEBHOOK_DELIVERY_HEADER as t, stringifyQuery as u, invalidConfig as v, getRejectedUploadMimeTypeError as w, DOMAIN as x, API_ERROR_CODES as y };
593
+ export { getAssetPayloadByteLength as A, MAX_IMAGE_UPLOAD_BYTES as C, stringifyJsonCanonical as D, isRejectedUploadMimeType as E, validateAssetPayload as M, assetDataToUint8Array as O, DOMAIN as S, getRejectedUploadMimeTypeError as T, SDK_ERROR_CODES as _, parseWebhookEvent as a, API_ERROR_CODES as b, appendCdnSelector as c, toTextAssetOptions as d, transformSelector as f, CalmLensError as g, CALMLENS_ERROR_CODES as h, WEBHOOK_TIMESTAMP_HEADER as i, getRawBase64 as j, assetToData as k, encodePathSegment as l, validateRequestOptions as m, WEBHOOK_SIGNATURE_HEADER as n, verifyWebhookSignature as o, validateClientOptions as p, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS as r, hmacSha256Hex as s, WEBHOOK_DELIVERY_HEADER as t, stringifyQuery as u, invalidArgument as v, MIN_MULTIPART_IMAGE_UPLOAD_BYTES as w, API_ERROR_DEFINITIONS as x, invalidConfig as y };
package/esm/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as EventCategory, A as ModerateTextOptions, B as UpdateFolderOptions, C as IterateAssetChildrenOptions, D as ListAssetChildrenOptions, E as LensTransform, F as RequestOptions, G as AssetSearchQuery, H as VerifyWebhookSignatureOptions, I as RetrieveAssetOptions, J as PostAssetSignedUrlResponse, K as WebhookEventPayload, L as RetryAssetOptions, M as MoveFolderOptions, N as MultipartUploadOptions, O as ListAssetsOptions, P as MultipartUploadPartOptions, Q as TypedEvent, R as SubmitAssetOptions, S as ImageTransformOptions, T as Lens, U as WebhookHeadersInput, V as UploadAssetPartOptions, W as WebhookPayloadInput, X as Folder, _ as DeleteAssetOptions, a as AssetSearchResponse, b as FolderIdOptions, c as AssetType, ct as MetadataItem, d as CdnAssetUrlOptions, et as EventFact, f as CdnServeOptions, g as DeleteAssetContentOptions, h as CreateMultipartUploadPartOptions, i as AssetPage, it as EventType, j as MoveAssetOptions, k as ListEventsOptions, l as AssetVisibility, lt as ProcessingOptions, m as CreateFolderOptions, n as AssetChildrenPage, nt as EventFacts, o as AssetSearchResult, ot as ClassificationCategoryReport, p as CreateAssetSignedUrlOptions, q as GetEventsResponse, r as AssetContentOptions, rt as EventSeverity, s as AssetStatus, st as ClassificationReport, t as Asset, tt as EventFactValues, u as CalmLensClientOptions, v as EnsureLensOptions, w as IterateAssetsOptions, x as IdempotencyOptions, y as EnsureLensesOptions, z as UpdateAssetOptions } from "./CalmLensTypes-DjYFaTyh.js";
1
+ import { $ as TypedEvent, A as ListEventsOptions, B as UpdateAssetOptions, C as ImageTransformOptions, D as LensTransform, E as Lens, F as MultipartUploadPartOptions, G as WebhookPayloadInput, H as UploadAssetPartOptions, I as RequestOptions, J as GetEventsResponse, K as AssetSearchQuery, L as RetrieveAssetOptions, M as MoveAssetOptions, N as MoveFolderOptions, O as ListAssetChildrenOptions, P as MultipartUploadOptions, R as RetryAssetOptions, S as IdempotencyOptions, T as IterateAssetsOptions, U as VerifyWebhookSignatureOptions, V as UpdateFolderOptions, W as WebhookHeadersInput, Y as PostAssetSignedUrlResponse, Z as Folder, _ as DeleteAssetContentOptions, a as AssetSearchResponse, at as EventType, b as EnsureLensesOptions, c as AssetType, ct as ClassificationReport, d as CdnAssetUrlOptions, et as EventCategory, f as CdnServeOptions, g as CreateMultipartUploadPartOptions, h as CreateFolderOptions, i as AssetPage, it as EventSeverity, j as ModerateTextOptions, k as ListAssetsOptions, l as AssetVisibility, lt as MetadataItem, m as CreateAssetSignedUrlOptions, n as AssetChildrenPage, nt as EventFactValues, o as AssetSearchResult, p as CdnTransform, q as WebhookEventPayload, r as AssetContentOptions, rt as EventFacts, s as AssetStatus, st as ClassificationCategoryReport, t as Asset, tt as EventFact, u as CalmLensClientOptions, ut as ProcessingOptions, v as DeleteAssetOptions, w as IterateAssetChildrenOptions, x as FolderIdOptions, y as EnsureLensOptions, z as SubmitAssetOptions } from "./CalmLensTypes-BZ-nxhr_.js";
2
2
  //#region src/client/CalmLensClient.d.ts
3
3
  interface ClientState {
4
4
  readonly options: Omit<CalmLensClientOptions, "apiKey"> & {
@@ -379,4 +379,4 @@ export declare function verifyWebhookSignature(options: VerifyWebhookSignatureOp
379
379
  */
380
380
  export declare function parseWebhookEvent(options: VerifyWebhookSignatureOptions): Promise<WebhookEventPayload>;
381
381
  //#endregion
382
- export { type ApiErrorCode, type Asset, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, CalmLensClient, type CalmLensClientOptions, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CdnAssetUrlOptions, type CdnServeOptions, type ClassificationCategoryReport, type ClassificationReport, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type EnsureLensOptions, type EnsureLensesOptions, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, type SdkErrorCode, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
382
+ export { type ApiErrorCode, type Asset, type AssetChildrenPage, type AssetContentOptions, type AssetPage, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, CalmLensClient, type CalmLensClientOptions, type CalmLensErrorCode, type CalmLensErrorDetails, type CalmLensErrorOptions, type CdnAssetUrlOptions, type CdnServeOptions, type CdnTransform, type ClassificationCategoryReport, type ClassificationReport, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type DeleteAssetContentOptions, type DeleteAssetOptions, type EnsureLensOptions, type EnsureLensesOptions, type EventCategory, type EventFact, type EventFactValues, type EventFacts, type EventSeverity, type EventType, type GetEventsResponse as EventsPage, type Folder, type FolderIdOptions, type IdempotencyOptions, type ImageTransformOptions, type IterateAssetChildrenOptions, type IterateAssetsOptions, type Lens, type LensTransform, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type MetadataItem, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type ProcessingOptions, type RequestOptions, type RetrieveAssetOptions, type RetryAssetOptions, type SdkErrorCode, type SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions, type WebhookEventPayload, type WebhookHeadersInput, type WebhookPayloadInput };
package/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { A as getRawBase64, C as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, E as stringifyJsonCanonical, O as assetToData, S as MAX_IMAGE_UPLOAD_BYTES, T as isRejectedUploadMimeType, _ as invalidArgument, a as parseWebhookEvent, c as appendCdnSelector, d as toTextAssetOptions, f as validateClientOptions, g as SDK_ERROR_CODES, h as CalmLensError, i as WEBHOOK_TIMESTAMP_HEADER, j as validateAssetPayload, k as getAssetPayloadByteLength, l as encodePathSegment, m as CALMLENS_ERROR_CODES, n as WEBHOOK_SIGNATURE_HEADER, o as verifyWebhookSignature, p as validateRequestOptions, r as WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, t as WEBHOOK_DELIVERY_HEADER, u as stringifyQuery, v as invalidConfig, w as getRejectedUploadMimeTypeError, y as API_ERROR_CODES } from "./CalmLensWebhooks-DLUozliX.js";
1
+ import { A as getAssetPayloadByteLength, C as MAX_IMAGE_UPLOAD_BYTES, D as stringifyJsonCanonical, E as isRejectedUploadMimeType, M as validateAssetPayload, T as getRejectedUploadMimeTypeError, _ as SDK_ERROR_CODES, a as parseWebhookEvent, b as API_ERROR_CODES, c as appendCdnSelector, d as toTextAssetOptions, f as transformSelector, g as CalmLensError, h as CALMLENS_ERROR_CODES, i as WEBHOOK_TIMESTAMP_HEADER, j as getRawBase64, k as assetToData, l as encodePathSegment, m as validateRequestOptions, n as WEBHOOK_SIGNATURE_HEADER, o as verifyWebhookSignature, p as validateClientOptions, r as WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, t as WEBHOOK_DELIVERY_HEADER, u as stringifyQuery, v as invalidArgument, w as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, y as invalidConfig } from "./CalmLensWebhooks-3Otbubyf.js";
2
2
  //#endregion
3
3
  //#region src/client/CalmLensVersion.ts
4
4
  /** This SDK's version, from its package.json. */
5
- const SDK_VERSION = "0.10.1";
5
+ const SDK_VERSION = "0.11.0";
6
6
  const runtimeName = () => {
7
7
  const runtime = globalThis;
8
8
  if (runtime.Bun?.version) return `bun/${runtime.Bun.version}`;
@@ -676,7 +676,7 @@ moderate: async (options) => this.assets.moderate(toTextAssetOptions(options)) }
676
676
  resource: options.resource ?? "content",
677
677
  expiresInSeconds: options.expiresInSeconds ?? 900,
678
678
  lens: options.lens,
679
- transform: options.transform
679
+ transform: transformSelector(options.transform)
680
680
  } });
681
681
  },
682
682
  /** Moves an asset into a folder, or to the project root with `folderId: null`. */
package/esm/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ModerateTextOptions, B as UpdateFolderOptions, C as IterateAssetChildrenOptions, D as ListAssetChildrenOptions, G as AssetSearchQuery, I as RetrieveAssetOptions, J as PostAssetSignedUrlResponse, K as WebhookEventPayload, L as RetryAssetOptions, M as MoveFolderOptions, O as ListAssetsOptions, Q as TypedEvent, R as SubmitAssetOptions, T as Lens, V as UploadAssetPartOptions, X as Folder, Y as AssetBinaryPayloadInput, Z as Event, _ as DeleteAssetOptions, a as AssetSearchResponse, at as ClassificationCategory, b as FolderIdOptions, d as CdnAssetUrlOptions, f as CdnServeOptions, g as DeleteAssetContentOptions, i as AssetPage, j as MoveAssetOptions, k as ListEventsOptions, m as CreateFolderOptions, n as AssetChildrenPage, p as CreateAssetSignedUrlOptions, q as GetEventsResponse, s as AssetStatus, t as Asset, u as CalmLensClientOptions, v as EnsureLensOptions, w as IterateAssetsOptions, y as EnsureLensesOptions, z as UpdateAssetOptions } from "./CalmLensTypes-DjYFaTyh.js";
1
+ import { $ as TypedEvent, A as ListEventsOptions, B as UpdateAssetOptions, E as Lens, H as UploadAssetPartOptions, J as GetEventsResponse, K as AssetSearchQuery, L as RetrieveAssetOptions, M as MoveAssetOptions, N as MoveFolderOptions, O as ListAssetChildrenOptions, Q as Event, R as RetryAssetOptions, T as IterateAssetsOptions, V as UpdateFolderOptions, X as AssetBinaryPayloadInput, Y as PostAssetSignedUrlResponse, Z as Folder, _ as DeleteAssetContentOptions, a as AssetSearchResponse, b as EnsureLensesOptions, d as CdnAssetUrlOptions, f as CdnServeOptions, h as CreateFolderOptions, i as AssetPage, j as ModerateTextOptions, k as ListAssetsOptions, m as CreateAssetSignedUrlOptions, n as AssetChildrenPage, ot as ClassificationCategory, q as WebhookEventPayload, s as AssetStatus, t as Asset, u as CalmLensClientOptions, v as DeleteAssetOptions, w as IterateAssetChildrenOptions, x as FolderIdOptions, y as EnsureLensOptions, z as SubmitAssetOptions } from "./CalmLensTypes-BZ-nxhr_.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/TestTriggers.d.ts
4
4
  type ClassificationTestSignal = ClassificationCategory | "sexual.involving-minors" | "violence.graphic";
package/esm/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as assetDataToUint8Array, E as stringifyJsonCanonical, O as assetToData, T as isRejectedUploadMimeType, _ as invalidArgument, b as API_ERROR_DEFINITIONS, c as appendCdnSelector, d as toTextAssetOptions, f as validateClientOptions, g as SDK_ERROR_CODES, h as CalmLensError, i as WEBHOOK_TIMESTAMP_HEADER, j as validateAssetPayload, k as getAssetPayloadByteLength, l as encodePathSegment, n as WEBHOOK_SIGNATURE_HEADER, s as hmacSha256Hex, t as WEBHOOK_DELIVERY_HEADER, w as getRejectedUploadMimeTypeError, y as API_ERROR_CODES } from "./CalmLensWebhooks-DLUozliX.js";
1
+ import { A as getAssetPayloadByteLength, D as stringifyJsonCanonical, E as isRejectedUploadMimeType, M as validateAssetPayload, O as assetDataToUint8Array, T as getRejectedUploadMimeTypeError, _ as SDK_ERROR_CODES, b as API_ERROR_CODES, c as appendCdnSelector, d as toTextAssetOptions, f as transformSelector, g as CalmLensError, i as WEBHOOK_TIMESTAMP_HEADER, k as assetToData, l as encodePathSegment, n as WEBHOOK_SIGNATURE_HEADER, p as validateClientOptions, s as hmacSha256Hex, t as WEBHOOK_DELIVERY_HEADER, v as invalidArgument, x as API_ERROR_DEFINITIONS } from "./CalmLensWebhooks-3Otbubyf.js";
2
2
  import * as zod from "zod";
3
3
  import "zod/v4";
4
4
  //#region ../shared/src/ModerationCategoryDefinitions.ts
@@ -912,7 +912,8 @@ var MockCalmLensClient = class {
912
912
  if (options.lens && options.transform) throw invalidArgument("Specify either a lens or a transform, not both");
913
913
  const expiresInSeconds = options.expiresInSeconds ?? 900;
914
914
  const resource = options.resource ?? "content";
915
- const selector = options.lens ? `&lens=${encodeURIComponent(options.lens)}` : options.transform ? `&transform=${encodeURIComponent(options.transform)}` : "";
915
+ const transform = transformSelector(options.transform);
916
+ const selector = options.lens ? `&lens=${encodeURIComponent(options.lens)}` : transform ? `&transform=${encodeURIComponent(transform)}` : "";
916
917
  return {
917
918
  url: `${this.signedUrlBaseUrl}/assets/${asset.id}/${resource}?expiresInSeconds=${expiresInSeconds}${selector}`,
918
919
  expiresAt: this.now() + expiresInSeconds * 1e3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calmlens/sdk",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "Official CalmLens SDK for JavaScript and TypeScript: content moderation, asset storage and CDN delivery.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://calmlens.com/docs/sdk/javascript",