@calmlens/sdk 0.5.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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as validateAssetPayload, a as calmLensError, c as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, d as PUBLIC_ERROR_CODES, f as stringifyJsonCanonical, g as getRawBase64, h as getAssetPayloadByteLength, i as SDK_ERRORS, l as getRejectedUploadMimeTypeError, m as assetToData, n as _objectWithoutProperties, o as DOMAIN, r as CalmLensError, s as MAX_IMAGE_UPLOAD_BYTES, t as toTextAssetOptions, u as isRejectedUploadMimeType, v as _asyncToGenerator, y as _objectSpread2 } from "./CalmLensUtils-BQEgxGWk.js";
1
+ import { _ as getRawBase64, a as SDK_ERRORS, b as _objectSpread2, c as MAX_IMAGE_UPLOAD_BYTES, d as isRejectedUploadMimeType, f as PUBLIC_ERROR_CODES, g as getAssetPayloadByteLength, h as assetToData, i as CalmLensError, l as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, n as validateClientOptions, o as calmLensError, p as stringifyJsonCanonical, r as _objectWithoutProperties, s as DOMAIN, t as toTextAssetOptions, u as getRejectedUploadMimeTypeError, v as validateAssetPayload, y as _asyncToGenerator } from "./CalmLensUtils-BZsX8yeO.js";
2
2
  import * as zod from "zod";
3
3
  import "zod/v4";
4
4
  import { Api, FetchRequestBackend, RequestCoalescingMiddleware, RequestEvent, getErrorResponse, isRequestError } from "api-def";
@@ -103,15 +103,17 @@ createMetaType({ id: "docPropertyInfo" });
103
103
  const SIZE_LIMITS = {
104
104
  small: 64,
105
105
  medium: 200,
106
- large: 1500
106
+ large: 1500,
107
+ xlarge: 1e4,
108
+ token: 1e4
107
109
  };
108
110
  const saneStringField = (options) => {
109
111
  return zod.string().transform((value) => value.trim()).refine((value) => {
110
112
  if ((options === null || options === void 0 ? void 0 : options.minWidth) && value.length < options.minWidth) return false;
111
113
  return true;
112
114
  }, "Not long enough").refine((value) => {
113
- var _options$type;
114
- const sizeLimit = SIZE_LIMITS[(_options$type = options === null || options === void 0 ? void 0 : options.type) !== null && _options$type !== void 0 ? _options$type : "medium"];
115
+ var _options$maxLength, _options$type;
116
+ const sizeLimit = (_options$maxLength = options === null || options === void 0 ? void 0 : options.maxLength) !== null && _options$maxLength !== void 0 ? _options$maxLength : SIZE_LIMITS[(_options$type = options === null || options === void 0 ? void 0 : options.type) !== null && _options$type !== void 0 ? _options$type : "medium"];
115
117
  return typeof value === "string" && value.length < sizeLimit;
116
118
  }, "Too long");
117
119
  };
@@ -201,7 +203,8 @@ zod.object({
201
203
  source: zod.enum([
202
204
  "frame",
203
205
  "speech",
204
- "frame-text"
206
+ "frame-text",
207
+ "clip"
205
208
  ]),
206
209
  startSeconds: zod.number().nonnegative(),
207
210
  endSeconds: zod.number().nonnegative(),
@@ -245,6 +248,24 @@ const WEBHOOK_TIMESTAMP_HEADER = "x-calmlens-timestamp";
245
248
  const WEBHOOK_SIGNATURE_HEADER = "x-calmlens-signature";
246
249
  /** Deliveries whose timestamp is further than this from the receiver's clock are rejected. */
247
250
  const WEBHOOK_SIGNATURE_TOLERANCE_SECONDS = 300;
251
+ /** The JSON body of a webhook delivery for a stored event. */
252
+ const toWebhookEventPayload = (event) => {
253
+ var _event$description, _event$assetId, _event$asset;
254
+ return {
255
+ id: event.id,
256
+ type: event.type,
257
+ createdAt: event.createdAt,
258
+ projectId: event.projectId,
259
+ data: {
260
+ severity: event.severity,
261
+ title: event.title,
262
+ description: (_event$description = event.description) !== null && _event$description !== void 0 ? _event$description : null,
263
+ assetId: (_event$assetId = event.assetId) !== null && _event$assetId !== void 0 ? _event$assetId : null,
264
+ asset: (_event$asset = event.asset) !== null && _event$asset !== void 0 ? _event$asset : null,
265
+ facts: event.facts
266
+ }
267
+ };
268
+ };
248
269
  const encoder = new TextEncoder();
249
270
  const hmacSha256Hex = function() {
250
271
  var _ref = _asyncToGenerator(function* (secret, message) {
@@ -275,7 +296,8 @@ const createWebhookSignatureHeader = function() {
275
296
  return _ref2.apply(this, arguments);
276
297
  };
277
298
  }();
278
- (function() {
299
+ /** Headers for one signed delivery of `body`. */
300
+ const createWebhookHeaders = function() {
279
301
  var _ref3 = _asyncToGenerator(function* (options) {
280
302
  var _options$timestampSec;
281
303
  const timestamp = (_options$timestampSec = options.timestampSeconds) !== null && _options$timestampSec !== void 0 ? _options$timestampSec : Math.floor(Date.now() / 1e3);
@@ -289,7 +311,7 @@ const createWebhookSignatureHeader = function() {
289
311
  return function createWebhookHeaders(_x6) {
290
312
  return _ref3.apply(this, arguments);
291
313
  };
292
- })();
314
+ }();
293
315
  /**
294
316
  * Verifies a webhook delivery: `x-calmlens-signature` must contain a `v1=` HMAC-SHA256 of
295
317
  * `"<x-calmlens-timestamp>.<raw body>"`, and the timestamp must be within `toleranceSeconds`
@@ -438,16 +460,42 @@ const requestSignal = (options, signal) => {
438
460
  ].filter((value) => value != null);
439
461
  return AbortSignal.any(signals);
440
462
  };
441
- const safeFetch = (fetchImpl, options) => function() {
442
- var _ref = _asyncToGenerator(function* (input, init) {
463
+ /** Copies a fully read body into a new Response, so later JSON parsing cannot hit the network. */
464
+ const toBufferedResponse = function() {
465
+ var _ref = _asyncToGenerator(function* (response) {
466
+ const body = response.status === 204 || response.status === 304 ? null : yield response.arrayBuffer();
467
+ const headers = new Headers(response.headers);
468
+ headers.delete("content-encoding");
469
+ headers.delete("content-length");
470
+ const buffered = new Response(body, {
471
+ status: response.status,
472
+ statusText: response.statusText,
473
+ headers
474
+ });
475
+ Object.defineProperty(buffered, "url", { value: response.url });
476
+ return buffered;
477
+ });
478
+ return function toBufferedResponse(_x) {
479
+ return _ref.apply(this, arguments);
480
+ };
481
+ }();
482
+ /**
483
+ * Wraps fetch with the client's deadline, cancellation and redirect policy. Every failure,
484
+ * including body reads, decompression and truncated bodies when `bufferBody` is set, becomes a
485
+ * `CalmLensError` (`sdk/transport-error`, `sdk/timeout` or `sdk/cancelled`) with the original
486
+ * error as its `cause`.
487
+ */
488
+ const safeFetch = (fetchImpl, options, { bufferBody }) => function() {
489
+ var _ref2 = _asyncToGenerator(function* (input, init) {
443
490
  var _init$signal;
444
491
  const signal = requestSignal(options, (_init$signal = init === null || init === void 0 ? void 0 : init.signal) !== null && _init$signal !== void 0 ? _init$signal : input instanceof Request ? input.signal : void 0);
445
492
  try {
446
493
  signal.throwIfAborted();
447
- return yield fetchImpl(input, _objectSpread2(_objectSpread2({}, init), {}, {
494
+ const response = yield fetchImpl(input, _objectSpread2(_objectSpread2({}, init), {}, {
448
495
  redirect: "error",
449
496
  signal
450
497
  }));
498
+ return bufferBody ? yield toBufferedResponse(response) : response;
451
499
  } catch (cause) {
452
500
  var _signal$reason;
453
501
  throw calmLensError({ id: signal.aborted ? ((_signal$reason = signal.reason) === null || _signal$reason === void 0 ? void 0 : _signal$reason.name) === "TimeoutError" ? "sdk/timeout" : "sdk/cancelled" : "sdk/transport-error" }, {
@@ -456,8 +504,8 @@ const safeFetch = (fetchImpl, options) => function() {
456
504
  });
457
505
  }
458
506
  });
459
- return function(_x, _x2) {
460
- return _ref.apply(this, arguments);
507
+ return function(_x2, _x3) {
508
+ return _ref2.apply(this, arguments);
461
509
  };
462
510
  }();
463
511
  const createApi = (options) => {
@@ -473,7 +521,7 @@ const createApi = (options) => {
473
521
  if (context.error) throw normalizeApiError(context.error);
474
522
  } }
475
523
  ],
476
- requestBackend: options.requestBackend ? Object.assign(Object.create(options.requestBackend), "fetch" in options.requestBackend && typeof options.requestBackend.fetch === "function" ? { fetch: safeFetch(options.requestBackend.fetch, options) } : {}) : new FetchRequestBackend(safeFetch(globalThis.fetch, options))
524
+ requestBackend: options.requestBackend ? Object.assign(Object.create(options.requestBackend), "fetch" in options.requestBackend && typeof options.requestBackend.fetch === "function" ? { fetch: safeFetch(options.requestBackend.fetch, options, { bufferBody: true }) } : {}) : new FetchRequestBackend(safeFetch(globalThis.fetch, options, { bufferBody: true }))
477
525
  });
478
526
  };
479
527
  const isApiErrorPayload = (value) => {
@@ -550,6 +598,11 @@ const createEndpoints = (api) => {
550
598
  method: "get",
551
599
  path: "/projects/:projectId/assets/page"
552
600
  });
601
+ const searchAssets = api.endpoint().paramsOf().queryOf().responseOf().build({
602
+ id: "searchAssets",
603
+ method: "get",
604
+ path: "/projects/:projectId/assets/search"
605
+ });
553
606
  const getAsset = api.endpoint().paramsOf().responseOf().build({
554
607
  id: "getAsset",
555
608
  method: "get",
@@ -603,6 +656,7 @@ const createEndpoints = (api) => {
603
656
  deleteFolder,
604
657
  moveFolder,
605
658
  getAssetsPage,
659
+ searchAssets,
606
660
  getAsset,
607
661
  getAssetChildren,
608
662
  patchAsset,
@@ -667,9 +721,7 @@ var CalmLensClient = class CalmLensClient {
667
721
  this.pendingEnsureLenses = /* @__PURE__ */ new Map();
668
722
  this.multipartImageUploadSizes = /* @__PURE__ */ new Map();
669
723
  this.multipartUploadQueues = /* @__PURE__ */ new Map();
670
- if (!options.apiKey) throw calmLensError({ id: "upload/invalid-payload" }, { message: "API key is required" });
671
- if (!options.projectId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Project ID is required" });
672
- if (options.timeoutMs !== void 0 && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs <= 0)) throw calmLensError({ id: "upload/invalid-payload" }, { message: "timeoutMs must be a positive integer" });
724
+ validateClientOptions(options);
673
725
  this.options = _objectSpread2({}, options);
674
726
  this.options.baseUrl = (_this$options$baseUrl = this.options.baseUrl) !== null && _this$options$baseUrl !== void 0 ? _this$options$baseUrl : `https://api.${DOMAIN}/v1`;
675
727
  this.options.cdnBaseUrl = (_this$options$cdnBase = this.options.cdnBaseUrl) !== null && _this$options$cdnBase !== void 0 ? _this$options$cdnBase : `https://cdn.${DOMAIN}/v1`;
@@ -684,11 +736,11 @@ var CalmLensClient = class CalmLensClient {
684
736
  return client;
685
737
  }
686
738
  getUploadFetch() {
687
- var _this$options$request, _ref2, _this$options$uploadF;
739
+ var _this$options$request, _ref3, _this$options$uploadF;
688
740
  const requestBackendFetch = (_this$options$request = this.options.requestBackend) === null || _this$options$request === void 0 ? void 0 : _this$options$request.fetch;
689
- const fetchImpl = (_ref2 = (_this$options$uploadF = this.options.uploadFetch) !== null && _this$options$uploadF !== void 0 ? _this$options$uploadF : requestBackendFetch) !== null && _ref2 !== void 0 ? _ref2 : globalThis.fetch;
741
+ const fetchImpl = (_ref3 = (_this$options$uploadF = this.options.uploadFetch) !== null && _this$options$uploadF !== void 0 ? _this$options$uploadF : requestBackendFetch) !== null && _ref3 !== void 0 ? _ref3 : globalThis.fetch;
690
742
  if (!fetchImpl) throw calmLensError(SDK_ERRORS.NO_CDN_FETCH);
691
- return safeFetch(fetchImpl, this.options);
743
+ return safeFetch(fetchImpl, this.options, { bufferBody: true });
692
744
  }
693
745
  submitRawAssetUpload(options, queue) {
694
746
  var _this = this;
@@ -777,7 +829,7 @@ var CalmLensClient = class CalmLensClient {
777
829
  try {
778
830
  data = yield response.json();
779
831
  } catch (cause) {
780
- throw calmLensError({ id: cause instanceof Error && ["TimeoutError", "AbortError"].includes(cause.name) ? cause.name === "TimeoutError" ? "sdk/timeout" : "sdk/cancelled" : response.ok ? "sdk/invalid-response" : "sdk/http-error" }, {
832
+ throw calmLensError({ id: response.ok ? "sdk/invalid-response" : "sdk/http-error" }, {
781
833
  message: `Invalid JSON response (HTTP ${response.status})`,
782
834
  status: response.status,
783
835
  cause
@@ -820,9 +872,9 @@ var CalmLensClient = class CalmLensClient {
820
872
  * Create a CDN URL for asset content or previews.
821
873
  * Private assets require an authenticated request or signed URL.
822
874
  */
823
- getAssetUrl: (_ref3) => {
875
+ getAssetUrl: (_ref4) => {
824
876
  var _options$resource;
825
- let { assetIdentifier } = _ref3, options = _objectWithoutProperties(_ref3, _excluded3);
877
+ let { assetIdentifier } = _ref4, options = _objectWithoutProperties(_ref4, _excluded3);
826
878
  if (!assetIdentifier) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset identifier is required" });
827
879
  const resource = (_options$resource = options.resource) !== null && _options$resource !== void 0 ? _options$resource : "content";
828
880
  const url = `${this.options.cdnBaseUrl.replace(/\/$/, "")}/assets/${encodeURIComponent(this.options.projectId)}/${encodeURIComponent(assetIdentifier)}/${resource}`;
@@ -833,15 +885,15 @@ var CalmLensClient = class CalmLensClient {
833
885
  * Private assets are authenticated with the client's API key.
834
886
  */
835
887
  serve: function() {
836
- var _ref5 = _asyncToGenerator(function* (_ref4) {
888
+ var _ref6 = _asyncToGenerator(function* (_ref5) {
837
889
  var _this$options$cdnFetc;
838
- let { assetIdentifier, init } = _ref4, urlOptions = _objectWithoutProperties(_ref4, _excluded4);
890
+ let { assetIdentifier, init } = _ref5, urlOptions = _objectWithoutProperties(_ref5, _excluded4);
839
891
  const fetchImpl = (_this$options$cdnFetc = _this3.options.cdnFetch) !== null && _this$options$cdnFetc !== void 0 ? _this$options$cdnFetc : globalThis.fetch;
840
892
  if (!fetchImpl) throw calmLensError(SDK_ERRORS.NO_CDN_FETCH);
841
- return safeFetch(fetchImpl, _this3.options)(_this3.cdn.getAssetUrl(_objectSpread2({ assetIdentifier }, urlOptions)), withApiKeyHeader(init, _this3.options.apiKey));
893
+ return safeFetch(fetchImpl, _this3.options, { bufferBody: false })(_this3.cdn.getAssetUrl(_objectSpread2({ assetIdentifier }, urlOptions)), withApiKeyHeader(init, _this3.options.apiKey));
842
894
  });
843
- return function serve(_x3) {
844
- return _ref5.apply(this, arguments);
895
+ return function serve(_x4) {
896
+ return _ref6.apply(this, arguments);
845
897
  };
846
898
  }()
847
899
  };
@@ -849,32 +901,43 @@ var CalmLensClient = class CalmLensClient {
849
901
  get text() {
850
902
  var _this4 = this;
851
903
  return { moderate: function() {
852
- var _ref6 = _asyncToGenerator(function* (options) {
904
+ var _ref7 = _asyncToGenerator(function* (options) {
853
905
  return _this4.assets.moderate(toTextAssetOptions(options));
854
906
  });
855
- return function moderate(_x4) {
856
- return _ref6.apply(this, arguments);
907
+ return function moderate(_x5) {
908
+ return _ref7.apply(this, arguments);
857
909
  };
858
910
  }() };
859
911
  }
860
912
  get assets() {
861
913
  var _this5 = this;
862
914
  return {
915
+ search: function() {
916
+ var _ref8 = _asyncToGenerator(function* (options) {
917
+ return (yield _this5.endpoints.searchAssets.submit({
918
+ params: { projectId: _this5.options.projectId },
919
+ query: options
920
+ })).data;
921
+ });
922
+ return function search(_x6) {
923
+ return _ref8.apply(this, arguments);
924
+ };
925
+ }(),
863
926
  /**
864
927
  * List all assets for a project
865
928
  * @param options - Pagination and filtering options
866
929
  * @returns Promise with paginated assets
867
930
  */
868
931
  list: function() {
869
- var _ref7 = _asyncToGenerator(function* (options) {
932
+ var _ref9 = _asyncToGenerator(function* (options) {
870
933
  var _options$pageIndex;
871
934
  return (yield _this5.endpoints.getAssetsPage.submit({
872
935
  params: { projectId: _this5.options.projectId },
873
936
  query: _objectSpread2(_objectSpread2({}, options), {}, { pageIndex: (_options$pageIndex = options.pageIndex) !== null && _options$pageIndex !== void 0 ? _options$pageIndex : 0 })
874
937
  })).data;
875
938
  });
876
- return function list(_x5) {
877
- return _ref7.apply(this, arguments);
939
+ return function list(_x7) {
940
+ return _ref9.apply(this, arguments);
878
941
  };
879
942
  }(),
880
943
  /**
@@ -883,25 +946,25 @@ var CalmLensClient = class CalmLensClient {
883
946
  * @returns Promise with asset data
884
947
  */
885
948
  retrieve: function() {
886
- var _ref8 = _asyncToGenerator(function* ({ assetId }) {
949
+ var _ref10 = _asyncToGenerator(function* ({ assetId }) {
887
950
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
888
951
  return (yield _this5.endpoints.getAsset.submit({ params: { assetId } })).data;
889
952
  });
890
- return function retrieve(_x6) {
891
- return _ref8.apply(this, arguments);
953
+ return function retrieve(_x8) {
954
+ return _ref10.apply(this, arguments);
892
955
  };
893
956
  }(),
894
957
  update: function() {
895
- var _ref10 = _asyncToGenerator(function* (_ref9) {
896
- let { assetId } = _ref9, body = _objectWithoutProperties(_ref9, _excluded5);
958
+ var _ref12 = _asyncToGenerator(function* (_ref11) {
959
+ let { assetId } = _ref11, body = _objectWithoutProperties(_ref11, _excluded5);
897
960
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
898
961
  return (yield _this5.endpoints.patchAsset.submit({
899
962
  params: { assetId },
900
963
  body
901
964
  })).data;
902
965
  });
903
- return function update(_x7) {
904
- return _ref10.apply(this, arguments);
966
+ return function update(_x9) {
967
+ return _ref12.apply(this, arguments);
905
968
  };
906
969
  }(),
907
970
  /**
@@ -911,17 +974,17 @@ var CalmLensClient = class CalmLensClient {
911
974
  * @returns Promise with paginated child assets
912
975
  */
913
976
  listChildren: function() {
914
- var _ref12 = _asyncToGenerator(function* (_ref11) {
977
+ var _ref14 = _asyncToGenerator(function* (_ref13) {
915
978
  var _options$pageIndex2;
916
- let { assetId } = _ref11, options = _objectWithoutProperties(_ref11, _excluded6);
979
+ let { assetId } = _ref13, options = _objectWithoutProperties(_ref13, _excluded6);
917
980
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
918
981
  return (yield _this5.endpoints.getAssetChildren.submit({
919
982
  params: { assetId },
920
983
  query: _objectSpread2(_objectSpread2({}, options), {}, { pageIndex: (_options$pageIndex2 = options.pageIndex) !== null && _options$pageIndex2 !== void 0 ? _options$pageIndex2 : 0 })
921
984
  })).data;
922
985
  });
923
- return function listChildren(_x8) {
924
- return _ref12.apply(this, arguments);
986
+ return function listChildren(_x10) {
987
+ return _ref14.apply(this, arguments);
925
988
  };
926
989
  }(),
927
990
  /**
@@ -931,7 +994,7 @@ var CalmLensClient = class CalmLensClient {
931
994
  * @returns Promise with created asset
932
995
  */
933
996
  create: function() {
934
- var _ref13 = _asyncToGenerator(function* (options) {
997
+ var _ref15 = _asyncToGenerator(function* (options) {
935
998
  const body = prepareSubmitAssetOptions(options);
936
999
  if ("content" in body || "part" in body) return yield _this5.submitRawAssetUpload(body, true);
937
1000
  return (yield _this5.endpoints.postUploadAsset.submit({
@@ -940,8 +1003,8 @@ var CalmLensClient = class CalmLensClient {
940
1003
  query: { queue: true }
941
1004
  })).data;
942
1005
  });
943
- return function create(_x9) {
944
- return _ref13.apply(this, arguments);
1006
+ return function create(_x11) {
1007
+ return _ref15.apply(this, arguments);
945
1008
  };
946
1009
  }(),
947
1010
  /**
@@ -952,7 +1015,7 @@ var CalmLensClient = class CalmLensClient {
952
1015
  * @returns Promise with created and analyzed asset
953
1016
  */
954
1017
  moderate: function() {
955
- var _ref14 = _asyncToGenerator(function* (options) {
1018
+ var _ref16 = _asyncToGenerator(function* (options) {
956
1019
  if ("content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) throw calmLensError(PUBLIC_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message: "Text to moderate must be a non-empty string" });
957
1020
  const body = prepareSubmitAssetOptions(options);
958
1021
  if ("content" in body || "part" in body) return yield _this5.submitRawAssetUpload(body, false);
@@ -962,8 +1025,8 @@ var CalmLensClient = class CalmLensClient {
962
1025
  query: { queue: false }
963
1026
  })).data;
964
1027
  });
965
- return function moderate(_x10) {
966
- return _ref14.apply(this, arguments);
1028
+ return function moderate(_x12) {
1029
+ return _ref16.apply(this, arguments);
967
1030
  };
968
1031
  }(),
969
1032
  /**
@@ -973,7 +1036,7 @@ var CalmLensClient = class CalmLensClient {
973
1036
  * @returns Promise with asset data
974
1037
  */
975
1038
  uploadPart: function() {
976
- var _ref15 = _asyncToGenerator(function* ({ assetId, part }) {
1039
+ var _ref17 = _asyncToGenerator(function* ({ assetId, part }) {
977
1040
  var _part$sizeInBytes3, _this$multipartUpload;
978
1041
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
979
1042
  if (!part) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Part options are required" });
@@ -991,8 +1054,8 @@ var CalmLensClient = class CalmLensClient {
991
1054
  }
992
1055
  return yield _this5.submitRawAssetPart(assetId, part, (_this$multipartUpload = _this5.multipartUploadQueues.get(assetId)) !== null && _this$multipartUpload !== void 0 ? _this$multipartUpload : false);
993
1056
  });
994
- return function uploadPart(_x11) {
995
- return _ref15.apply(this, arguments);
1057
+ return function uploadPart(_x13) {
1058
+ return _ref17.apply(this, arguments);
996
1059
  };
997
1060
  }(),
998
1061
  /**
@@ -1001,9 +1064,9 @@ var CalmLensClient = class CalmLensClient {
1001
1064
  * auth cookies or API keys to the CDN on every media request.
1002
1065
  */
1003
1066
  createSignedUrl: function() {
1004
- var _ref17 = _asyncToGenerator(function* (_ref16) {
1067
+ var _ref19 = _asyncToGenerator(function* (_ref18) {
1005
1068
  var _options$resource2, _options$expiresInSec;
1006
- let { assetId } = _ref16, options = _objectWithoutProperties(_ref16, _excluded7);
1069
+ let { assetId } = _ref18, options = _objectWithoutProperties(_ref18, _excluded7);
1007
1070
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1008
1071
  if (options.lens && options.transform) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Specify either a lens or a transform, not both" });
1009
1072
  return (yield _this5.endpoints.postAssetSignedUrl.submit({
@@ -1016,20 +1079,20 @@ var CalmLensClient = class CalmLensClient {
1016
1079
  params: { assetId }
1017
1080
  })).data;
1018
1081
  });
1019
- return function createSignedUrl(_x12) {
1020
- return _ref17.apply(this, arguments);
1082
+ return function createSignedUrl(_x14) {
1083
+ return _ref19.apply(this, arguments);
1021
1084
  };
1022
1085
  }(),
1023
1086
  move: function() {
1024
- var _ref18 = _asyncToGenerator(function* ({ assetId, folderId }) {
1087
+ var _ref20 = _asyncToGenerator(function* ({ assetId, folderId }) {
1025
1088
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1026
1089
  return (yield _this5.endpoints.moveAsset.submit({
1027
1090
  params: { assetId },
1028
1091
  body: { folderId }
1029
1092
  })).data;
1030
1093
  });
1031
- return function move(_x13) {
1032
- return _ref18.apply(this, arguments);
1094
+ return function move(_x15) {
1095
+ return _ref20.apply(this, arguments);
1033
1096
  };
1034
1097
  }(),
1035
1098
  /**
@@ -1037,12 +1100,12 @@ var CalmLensClient = class CalmLensClient {
1037
1100
  * moderated like a new upload; its content must still be stored.
1038
1101
  */
1039
1102
  retry: function() {
1040
- var _ref19 = _asyncToGenerator(function* ({ assetId }) {
1103
+ var _ref21 = _asyncToGenerator(function* ({ assetId }) {
1041
1104
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1042
1105
  return (yield _this5.endpoints.retryAsset.submit({ params: { assetId } })).data;
1043
1106
  });
1044
- return function retry(_x14) {
1045
- return _ref19.apply(this, arguments);
1107
+ return function retry(_x16) {
1108
+ return _ref21.apply(this, arguments);
1046
1109
  };
1047
1110
  }()
1048
1111
  };
@@ -1056,14 +1119,14 @@ var CalmLensClient = class CalmLensClient {
1056
1119
  * reshaped as `{ id, type, createdAt, projectId, data }`.
1057
1120
  */
1058
1121
  list: function() {
1059
- var _ref20 = _asyncToGenerator(function* (options = {}) {
1122
+ var _ref22 = _asyncToGenerator(function* (options = {}) {
1060
1123
  return (yield _this6.endpoints.getEvents.submit({
1061
1124
  params: { projectId: _this6.options.projectId },
1062
1125
  query: options
1063
1126
  })).data;
1064
1127
  });
1065
1128
  return function list() {
1066
- return _ref20.apply(this, arguments);
1129
+ return _ref22.apply(this, arguments);
1067
1130
  };
1068
1131
  }() };
1069
1132
  }
@@ -1071,65 +1134,65 @@ list: function() {
1071
1134
  var _this7 = this;
1072
1135
  return {
1073
1136
  list: function() {
1074
- var _ref21 = _asyncToGenerator(function* () {
1137
+ var _ref23 = _asyncToGenerator(function* () {
1075
1138
  return (yield _this7.endpoints.getFolders.submit({ params: { projectId: _this7.options.projectId } })).data.folders;
1076
1139
  });
1077
1140
  return function list() {
1078
- return _ref21.apply(this, arguments);
1141
+ return _ref23.apply(this, arguments);
1079
1142
  };
1080
1143
  }(),
1081
1144
  retrieve: function() {
1082
- var _ref22 = _asyncToGenerator(function* ({ folderId }) {
1145
+ var _ref24 = _asyncToGenerator(function* ({ folderId }) {
1083
1146
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1084
1147
  return (yield _this7.endpoints.getFolder.submit({ params: { folderId } })).data;
1085
1148
  });
1086
- return function retrieve(_x15) {
1087
- return _ref22.apply(this, arguments);
1149
+ return function retrieve(_x17) {
1150
+ return _ref24.apply(this, arguments);
1088
1151
  };
1089
1152
  }(),
1090
1153
  create: function() {
1091
- var _ref23 = _asyncToGenerator(function* (options) {
1154
+ var _ref25 = _asyncToGenerator(function* (options) {
1092
1155
  return (yield _this7.endpoints.postFolder.submit({
1093
1156
  params: { projectId: _this7.options.projectId },
1094
1157
  body: options
1095
1158
  })).data;
1096
1159
  });
1097
- return function create(_x16) {
1098
- return _ref23.apply(this, arguments);
1160
+ return function create(_x18) {
1161
+ return _ref25.apply(this, arguments);
1099
1162
  };
1100
1163
  }(),
1101
1164
  update: function() {
1102
- var _ref25 = _asyncToGenerator(function* (_ref24) {
1103
- let { folderId } = _ref24, body = _objectWithoutProperties(_ref24, _excluded8);
1165
+ var _ref27 = _asyncToGenerator(function* (_ref26) {
1166
+ let { folderId } = _ref26, body = _objectWithoutProperties(_ref26, _excluded8);
1104
1167
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1105
1168
  return (yield _this7.endpoints.patchFolder.submit({
1106
1169
  params: { folderId },
1107
1170
  body
1108
1171
  })).data;
1109
1172
  });
1110
- return function update(_x17) {
1111
- return _ref25.apply(this, arguments);
1173
+ return function update(_x19) {
1174
+ return _ref27.apply(this, arguments);
1112
1175
  };
1113
1176
  }(),
1114
1177
  delete: function() {
1115
- var _ref26 = _asyncToGenerator(function* ({ folderId }) {
1178
+ var _ref28 = _asyncToGenerator(function* ({ folderId }) {
1116
1179
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1117
1180
  yield _this7.endpoints.deleteFolder.submit({ params: { folderId } });
1118
1181
  });
1119
- return function _delete(_x18) {
1120
- return _ref26.apply(this, arguments);
1182
+ return function _delete(_x20) {
1183
+ return _ref28.apply(this, arguments);
1121
1184
  };
1122
1185
  }(),
1123
1186
  move: function() {
1124
- var _ref27 = _asyncToGenerator(function* ({ folderId, parentId }) {
1187
+ var _ref29 = _asyncToGenerator(function* ({ folderId, parentId }) {
1125
1188
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1126
1189
  return (yield _this7.endpoints.moveFolder.submit({
1127
1190
  params: { folderId },
1128
1191
  body: { parentId }
1129
1192
  })).data;
1130
1193
  });
1131
- return function move(_x19) {
1132
- return _ref27.apply(this, arguments);
1194
+ return function move(_x21) {
1195
+ return _ref29.apply(this, arguments);
1133
1196
  };
1134
1197
  }()
1135
1198
  };
@@ -1193,4 +1256,4 @@ list: function() {
1193
1256
  }
1194
1257
  };
1195
1258
  //#endregion
1196
- export { CalmLensClient, CalmLensError, MEDIA_TEST_SIGNALS, WEBHOOK_DELIVERY_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, WEBHOOK_TIMESTAMP_HEADER, generateMediaTestCode, verifyWebhookSignature };
1259
+ export { CalmLensClient, CalmLensError, MEDIA_TEST_SIGNALS, WEBHOOK_DELIVERY_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_TOLERANCE_SECONDS, WEBHOOK_TIMESTAMP_HEADER, createWebhookHeaders, generateMediaTestCode, toWebhookEventPayload, verifyWebhookSignature };