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