@calmlens/sdk 0.8.1 → 0.9.1
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/cjs/{CalmLensTypes-B7hr0SBv.d.ts → CalmLensTypes-CZqyni4p.d.ts} +7 -1
- package/cjs/{CalmLensUtils-CJ6o7KRU.js → CalmLensUtils-B6vwJijv.js} +79 -0
- package/cjs/index.d.ts +12 -4
- package/cjs/index.js +93 -49
- package/cjs/testing.d.ts +7 -4
- package/cjs/testing.js +163 -133
- package/esm/{CalmLensTypes-B7hr0SBv.d.ts → CalmLensTypes-CZqyni4p.d.ts} +7 -1
- package/esm/{CalmLensUtils-BZsX8yeO.js → CalmLensUtils-O1xk_Ts0.js} +62 -1
- package/esm/index.d.ts +12 -4
- package/esm/index.js +92 -48
- package/esm/testing.d.ts +7 -4
- package/esm/testing.js +162 -132
- package/package.json +1 -1
|
@@ -266,6 +266,26 @@ const PUBLIC_ERROR_CODES = {
|
|
|
266
266
|
defaultMessage: "Multipart upload state is missing",
|
|
267
267
|
status: 409
|
|
268
268
|
}),
|
|
269
|
+
UPLOAD_SIZE_MISMATCH: new ErrorCode({
|
|
270
|
+
id: "upload/size-mismatch",
|
|
271
|
+
defaultMessage: "The uploaded parts do not add up to the totalSizeInBytes declared when the multipart upload started.",
|
|
272
|
+
status: 400
|
|
273
|
+
}),
|
|
274
|
+
INVALID_IDEMPOTENCY_KEY: new ErrorCode({
|
|
275
|
+
id: "idempotency/invalid-key",
|
|
276
|
+
defaultMessage: "The Idempotency-Key header must be 1 to 255 printable ASCII characters, such as a UUID.",
|
|
277
|
+
status: 400
|
|
278
|
+
}),
|
|
279
|
+
IDEMPOTENCY_KEY_REUSED: new ErrorCode({
|
|
280
|
+
id: "idempotency/key-reused",
|
|
281
|
+
defaultMessage: "This Idempotency-Key was already used for a different request. Use a new key for each distinct request.",
|
|
282
|
+
status: 409
|
|
283
|
+
}),
|
|
284
|
+
IDEMPOTENT_REQUEST_IN_PROGRESS: new ErrorCode({
|
|
285
|
+
id: "idempotency/request-in-progress",
|
|
286
|
+
defaultMessage: "A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result.",
|
|
287
|
+
status: 409
|
|
288
|
+
}),
|
|
269
289
|
ASSET_NOT_FOUND: new ErrorCode({
|
|
270
290
|
id: "asset/not-found",
|
|
271
291
|
defaultMessage: "Asset not found",
|
|
@@ -412,6 +432,7 @@ const validateClientOptions = (options) => {
|
|
|
412
432
|
if (!options || typeof options !== "object") throw invalidOptions("Client options are required");
|
|
413
433
|
if (!options.apiKey) throw invalidOptions("API key is required");
|
|
414
434
|
if (!options.projectId) throw invalidOptions("Project ID is required");
|
|
435
|
+
encodePathSegment(options.projectId, "Project ID");
|
|
415
436
|
if (options.timeoutMs !== void 0 && (!Number.isSafeInteger(options.timeoutMs) || options.timeoutMs <= 0)) throw invalidOptions("timeoutMs must be a positive integer");
|
|
416
437
|
assertHttpUrl("baseUrl", options.baseUrl);
|
|
417
438
|
assertHttpUrl("cdnBaseUrl", options.cdnBaseUrl);
|
|
@@ -427,5 +448,45 @@ const toTextAssetOptions = (_ref) => {
|
|
|
427
448
|
}
|
|
428
449
|
});
|
|
429
450
|
};
|
|
451
|
+
/**
|
|
452
|
+
* Encodes an identifier as one URL path segment. `.` and `..` are rejected because URL
|
|
453
|
+
* resolution would treat them as relative segments and send the request to another route.
|
|
454
|
+
*/
|
|
455
|
+
const encodePathSegment = (value, name) => {
|
|
456
|
+
if (typeof value !== "string" || !value) throw invalidOptions(`${name} is required`);
|
|
457
|
+
if (value === "." || value === "..") throw invalidOptions(`${name} cannot be "." or ".."`);
|
|
458
|
+
return encodeURIComponent(value);
|
|
459
|
+
};
|
|
460
|
+
/** Appends a CDN lens (`/@name`) or direct transform selector to an asset URL. */
|
|
461
|
+
const appendCdnSelector = (url, options) => {
|
|
462
|
+
if (options.lens && options.transform) throw invalidOptions("Specify either a lens or a transform, not both");
|
|
463
|
+
if (options.lens) return `${url}/@${encodePathSegment(options.lens, "Lens")}`;
|
|
464
|
+
if (!options.transform) return url;
|
|
465
|
+
const transform = options.transform.replace(/^\/+/, "");
|
|
466
|
+
if (transform.includes("..") || transform.includes("?") || transform.includes("#")) throw invalidOptions("Transform cannot contain \"..\", \"?\" or \"#\"");
|
|
467
|
+
return `${url}/${encodeURI(transform)}`;
|
|
468
|
+
};
|
|
469
|
+
const appendQueryValue = (parts, key, value) => {
|
|
470
|
+
if (value === void 0 || value === null) return;
|
|
471
|
+
if (Array.isArray(value)) {
|
|
472
|
+
for (const [index, item] of value.entries()) appendQueryValue(parts, `${key}[${index}]`, item);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (typeof value === "object") {
|
|
476
|
+
for (const [field, item] of Object.entries(value)) appendQueryValue(parts, `${key}[${field}]`, item);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Serialises a query object the way the API parses it (qs bracket notation), for example
|
|
483
|
+
* `ordering[0][field]=createdAt&ordering[0][direction]=DESC`. Every key and value is
|
|
484
|
+
* percent-encoded and missing values are omitted.
|
|
485
|
+
*/
|
|
486
|
+
const stringifyQuery = (query) => {
|
|
487
|
+
const parts = [];
|
|
488
|
+
for (const [key, value] of Object.entries(query)) appendQueryValue(parts, key, value);
|
|
489
|
+
return parts.join("&");
|
|
490
|
+
};
|
|
430
491
|
//#endregion
|
|
431
|
-
export {
|
|
492
|
+
export { _objectSpread2 as C, _asyncToGenerator as S, assetDataToUint8Array as _, validateClientOptions as a, getRawBase64 as b, SDK_ERRORS as c, MAX_IMAGE_UPLOAD_BYTES as d, MIN_MULTIPART_IMAGE_UPLOAD_BYTES as f, stringifyJsonCanonical as g, PUBLIC_ERROR_CODES as h, toTextAssetOptions as i, calmLensError as l, isRejectedUploadMimeType as m, encodePathSegment as n, _objectWithoutProperties as o, getRejectedUploadMimeTypeError as p, stringifyQuery as r, CalmLensError as s, appendCdnSelector as t, DOMAIN as u, assetToData as v, validateAssetPayload as x, getAssetPayloadByteLength as y };
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as GetAssetResponse, B as EventCategory, C as RetryAssetOptions, D as UploadAssetPartOptions, E as UpdateFolderOptions, G as EventType, H as EventFactValues, I as Lens, J as AssetType, K as Asset, L as Folder, M as GetEventsResponse, N as PostAssetSignedUrlResponse, O as VerifyWebhookSignatureOptions, P as RequestErrorCode, R as Event, S as RetrieveAssetOptions, T as UpdateAssetOptions, U as EventFacts, V as EventFact, W as EventSeverity, X as MetadataItem, Y as AssetVisibility, Z as ProcessingOptions, _ as MoveAssetOptions, a as CreateAssetSignedUrlOptions, b as MultipartUploadPartOptions, c as DeleteAssetContentOptions, d as EnsureLensesOptions, f as FolderIdOptions, g as ModerateTextOptions, h as ListEventsOptions, i as CdnServeOptions, j as GetAssetsPageResponse, k as GetAssetChildrenResponse, l as DeleteAssetOptions, m as ListAssetsOptions, n as CalmLensClientOptions, o as CreateFolderOptions, p as ListAssetChildrenOptions, q as AssetStatus, r as CdnAssetUrlOptions, s as CreateMultipartUploadPartOptions, t as AssetContentOptions, u as EnsureLensOptions, v as MoveFolderOptions, w as SubmitAssetOptions, x as RequestOptions, y as MultipartUploadOptions, z as TypedEvent } from "./CalmLensTypes-CZqyni4p.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
//#region ../shared/src/AssetSearch.d.ts
|
|
4
4
|
declare const ASSET_SEARCH_QUERY_SCHEMA: zod.ZodObject<{
|
|
@@ -7501,7 +7501,7 @@ declare class CalmLensClient {
|
|
|
7501
7501
|
* @param options - Pagination and filtering options
|
|
7502
7502
|
* @returns Promise with paginated assets
|
|
7503
7503
|
*/
|
|
7504
|
-
list: (options
|
|
7504
|
+
list: (options?: ListAssetsOptions) => Promise<GetAssetsPageResponse>;
|
|
7505
7505
|
/**
|
|
7506
7506
|
* Retrieve a specific asset by ID
|
|
7507
7507
|
* @param assetId - The asset ID
|
|
@@ -7515,7 +7515,7 @@ declare class CalmLensClient {
|
|
|
7515
7515
|
* @param options - Pagination options
|
|
7516
7516
|
* @returns Promise with paginated child assets
|
|
7517
7517
|
*/
|
|
7518
|
-
listChildren: ({ assetId, ...options }
|
|
7518
|
+
listChildren: ({ assetId, ...options }?: ListAssetChildrenOptions) => Promise<GetAssetChildrenResponse>;
|
|
7519
7519
|
/**
|
|
7520
7520
|
* Submit a new asset for processing (queued asynchronously)
|
|
7521
7521
|
* The asset will be queued for classification and returned immediately.
|
|
@@ -7550,6 +7550,14 @@ declare class CalmLensClient {
|
|
|
7550
7550
|
* moderated like a new upload; its content must still be stored.
|
|
7551
7551
|
*/
|
|
7552
7552
|
retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
|
|
7553
|
+
/**
|
|
7554
|
+
* Removes an asset's stored content (source, preview and retained extracted text) while
|
|
7555
|
+
* keeping the asset record, metadata and moderation report. The returned asset has
|
|
7556
|
+
* `storageDeletedAt` set; the CDN no longer serves it.
|
|
7557
|
+
*/
|
|
7558
|
+
deleteContent: ({ assetId }: DeleteAssetContentOptions) => Promise<Asset>;
|
|
7559
|
+
/** Deletes an asset record together with its stored content. */
|
|
7560
|
+
delete: ({ assetId }: DeleteAssetOptions) => Promise<void>;
|
|
7553
7561
|
};
|
|
7554
7562
|
get events(): {
|
|
7555
7563
|
/**
|
|
@@ -7620,4 +7628,4 @@ export declare const createWebhookHeaders: (options: {
|
|
|
7620
7628
|
*/
|
|
7621
7629
|
export declare function verifyWebhookSignature({ payload, signature, timestamp, secret, toleranceSeconds, now }: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
7622
7630
|
//#endregion
|
|
7623
|
-
export { type Asset, type GetAssetChildrenResponse as AssetChildrenPage, type AssetContentOptions, type GetAssetsPageResponse as AssetPage, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, CalmLensClient, type CalmLensClientOptions, type CalmLensErrorDetails, type CdnAssetUrlOptions, type CdnServeOptions, type ClassificationCategoryReport, type ClassificationReport, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, 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 Lens, 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 SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions, type WebhookEventPayload };
|
|
7631
|
+
export { type Asset, type GetAssetChildrenResponse as AssetChildrenPage, type AssetContentOptions, type GetAssetsPageResponse as AssetPage, type AssetSearchQuery, type AssetSearchResponse, type AssetSearchResult, type AssetStatus, type AssetType, type AssetVisibility, CalmLensClient, type CalmLensClientOptions, type CalmLensErrorDetails, 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 Lens, 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 SubmitAssetOptions, type TypedEvent, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions, type WebhookEventPayload };
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as _objectSpread2, S as _asyncToGenerator, a as validateClientOptions, b as getRawBase64, c as SDK_ERRORS, d as MAX_IMAGE_UPLOAD_BYTES, f as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, g as stringifyJsonCanonical, h as PUBLIC_ERROR_CODES, i as toTextAssetOptions, l as calmLensError, m as isRejectedUploadMimeType, n as encodePathSegment, o as _objectWithoutProperties, p as getRejectedUploadMimeTypeError, r as stringifyQuery, s as CalmLensError, t as appendCdnSelector, u as DOMAIN, v as assetToData, x as validateAssetPayload, y as getAssetPayloadByteLength } from "./CalmLensUtils-O1xk_Ts0.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";
|
|
@@ -440,12 +440,6 @@ const prepareSubmitAssetOptions = (options) => {
|
|
|
440
440
|
}
|
|
441
441
|
return options;
|
|
442
442
|
};
|
|
443
|
-
const appendCdnSelector = (url, options) => {
|
|
444
|
-
if (options.lens && options.transform) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Specify either a lens or a transform, not both" });
|
|
445
|
-
if (options.lens) return `${url}/@${encodeURIComponent(options.lens)}`;
|
|
446
|
-
if (!options.transform) return url;
|
|
447
|
-
return `${url}/${encodeURI(options.transform.replace(/^\/+/, ""))}`;
|
|
448
|
-
};
|
|
449
443
|
const getEnsureLensCacheKey = (options) => {
|
|
450
444
|
var _options$description, _options$transforms;
|
|
451
445
|
return stringifyJsonCanonical({
|
|
@@ -527,6 +521,7 @@ const createApi = (options) => {
|
|
|
527
521
|
return new Api({
|
|
528
522
|
name: "Calm Lens",
|
|
529
523
|
baseUrl: options.baseUrl,
|
|
524
|
+
config: { queryHandling: { stringify: stringifyQuery } },
|
|
530
525
|
middleware: [
|
|
531
526
|
RequestCoalescingMiddleware(),
|
|
532
527
|
{ beforeSend: (context) => {
|
|
@@ -658,12 +653,32 @@ const createEndpoints = (api) => {
|
|
|
658
653
|
method: "post",
|
|
659
654
|
path: "/assets/:assetId/retry"
|
|
660
655
|
});
|
|
656
|
+
const deleteAsset = api.endpoint().paramsOf().responseOf().build({
|
|
657
|
+
id: "deleteAsset",
|
|
658
|
+
method: "delete",
|
|
659
|
+
path: "/assets/:assetId"
|
|
660
|
+
});
|
|
661
|
+
const deleteAssetContent = api.endpoint().paramsOf().responseOf().build({
|
|
662
|
+
id: "deleteAssetContent",
|
|
663
|
+
method: "delete",
|
|
664
|
+
path: "/assets/:assetId/content"
|
|
665
|
+
});
|
|
661
666
|
const getEvents = api.endpoint().paramsOf().queryOf().responseOf().build({
|
|
662
667
|
id: "getEvents",
|
|
663
668
|
method: "get",
|
|
664
669
|
path: "/projects/:projectId/events"
|
|
665
670
|
});
|
|
666
|
-
|
|
671
|
+
const ensureLens = api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
672
|
+
id: "ensureLens",
|
|
673
|
+
method: "put",
|
|
674
|
+
path: "/lenses/:lensIdentifier"
|
|
675
|
+
});
|
|
676
|
+
const ensureLenses = api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
677
|
+
id: "ensureLenses",
|
|
678
|
+
method: "put",
|
|
679
|
+
path: "/projects/:projectId/lenses"
|
|
680
|
+
});
|
|
681
|
+
return encodePathParams({
|
|
667
682
|
getFolders,
|
|
668
683
|
getFolder,
|
|
669
684
|
postFolder,
|
|
@@ -680,18 +695,23 @@ const createEndpoints = (api) => {
|
|
|
680
695
|
postAssetPart,
|
|
681
696
|
moveAsset,
|
|
682
697
|
retryAsset,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}),
|
|
688
|
-
ensureLenses: api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
689
|
-
id: "ensureLenses",
|
|
690
|
-
method: "put",
|
|
691
|
-
path: "/projects/:projectId/lenses"
|
|
692
|
-
}),
|
|
698
|
+
deleteAsset,
|
|
699
|
+
deleteAssetContent,
|
|
700
|
+
ensureLens,
|
|
701
|
+
ensureLenses,
|
|
693
702
|
getEvents
|
|
694
|
-
};
|
|
703
|
+
});
|
|
704
|
+
};
|
|
705
|
+
/**
|
|
706
|
+
* api-def inserts `/:param` values into the path verbatim, so every endpoint encodes its path
|
|
707
|
+
* params here: an ID can never add path segments, a query string or a fragment.
|
|
708
|
+
*/
|
|
709
|
+
const encodePathParams = (endpoints) => {
|
|
710
|
+
for (const endpoint of Object.values(endpoints)) {
|
|
711
|
+
const submit = endpoint.submit.bind(endpoint);
|
|
712
|
+
endpoint.submit = (config) => submit(_objectSpread2(_objectSpread2({}, config), {}, { params: config.params && Object.fromEntries(Object.entries(config.params).map(([key, value]) => [key, encodePathSegment(value, key)])) }));
|
|
713
|
+
}
|
|
714
|
+
return endpoints;
|
|
695
715
|
};
|
|
696
716
|
var CalmLensClient = class CalmLensClient {
|
|
697
717
|
/**
|
|
@@ -817,7 +837,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
817
837
|
isFinal: String((_part$isFinal2 = part.isFinal) !== null && _part$isFinal2 !== void 0 ? _part$isFinal2 : false)
|
|
818
838
|
});
|
|
819
839
|
setOptionalQueryValue(query, "sizeInBytes", (_part$sizeInBytes2 = part.sizeInBytes) !== null && _part$sizeInBytes2 !== void 0 ? _part$sizeInBytes2 : getAssetPayloadByteLength(part));
|
|
820
|
-
const url = `${_this2.options.baseUrl.replace(/\/$/, "")}/assets/${
|
|
840
|
+
const url = `${_this2.options.baseUrl.replace(/\/$/, "")}/assets/${encodePathSegment(assetId, "Asset ID")}/part?${query}`;
|
|
821
841
|
const response = yield _this2.getUploadFetch()(url, {
|
|
822
842
|
method: "POST",
|
|
823
843
|
headers: {
|
|
@@ -892,7 +912,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
892
912
|
let { assetIdentifier } = _ref4, options = _objectWithoutProperties(_ref4, _excluded3);
|
|
893
913
|
if (!assetIdentifier) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset identifier is required" });
|
|
894
914
|
const resource = (_options$resource = options.resource) !== null && _options$resource !== void 0 ? _options$resource : "content";
|
|
895
|
-
const url = `${this.options.cdnBaseUrl.replace(/\/$/, "")}/assets/${encodeURIComponent(this.options.projectId)}/${
|
|
915
|
+
const url = `${this.options.cdnBaseUrl.replace(/\/$/, "")}/assets/${encodeURIComponent(this.options.projectId)}/${encodePathSegment(assetIdentifier, "Asset identifier")}/${resource}`;
|
|
896
916
|
return appendCdnSelector(url, options);
|
|
897
917
|
},
|
|
898
918
|
/**
|
|
@@ -944,14 +964,14 @@ var CalmLensClient = class CalmLensClient {
|
|
|
944
964
|
* @returns Promise with paginated assets
|
|
945
965
|
*/
|
|
946
966
|
list: function() {
|
|
947
|
-
var _ref9 = _asyncToGenerator(function* (options) {
|
|
967
|
+
var _ref9 = _asyncToGenerator(function* (options = {}) {
|
|
948
968
|
var _options$pageIndex;
|
|
949
969
|
return (yield _this5.endpoints.getAssetsPage.submit({
|
|
950
970
|
params: { projectId: _this5.options.projectId },
|
|
951
971
|
query: _objectSpread2(_objectSpread2({}, options), {}, { pageIndex: (_options$pageIndex = options.pageIndex) !== null && _options$pageIndex !== void 0 ? _options$pageIndex : 0 })
|
|
952
972
|
})).data;
|
|
953
973
|
});
|
|
954
|
-
return function list(
|
|
974
|
+
return function list() {
|
|
955
975
|
return _ref9.apply(this, arguments);
|
|
956
976
|
};
|
|
957
977
|
}(),
|
|
@@ -965,7 +985,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
965
985
|
if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
|
|
966
986
|
return (yield _this5.endpoints.getAsset.submit({ params: { assetId } })).data;
|
|
967
987
|
});
|
|
968
|
-
return function retrieve(
|
|
988
|
+
return function retrieve(_x7) {
|
|
969
989
|
return _ref10.apply(this, arguments);
|
|
970
990
|
};
|
|
971
991
|
}(),
|
|
@@ -978,7 +998,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
978
998
|
body
|
|
979
999
|
})).data;
|
|
980
1000
|
});
|
|
981
|
-
return function update(
|
|
1001
|
+
return function update(_x8) {
|
|
982
1002
|
return _ref12.apply(this, arguments);
|
|
983
1003
|
};
|
|
984
1004
|
}(),
|
|
@@ -989,7 +1009,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
989
1009
|
* @returns Promise with paginated child assets
|
|
990
1010
|
*/
|
|
991
1011
|
listChildren: function() {
|
|
992
|
-
var _ref14 = _asyncToGenerator(function* (_ref13) {
|
|
1012
|
+
var _ref14 = _asyncToGenerator(function* (_ref13 = {}) {
|
|
993
1013
|
var _options$pageIndex2;
|
|
994
1014
|
let { assetId } = _ref13, options = _objectWithoutProperties(_ref13, _excluded6);
|
|
995
1015
|
if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
|
|
@@ -998,7 +1018,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
998
1018
|
query: _objectSpread2(_objectSpread2({}, options), {}, { pageIndex: (_options$pageIndex2 = options.pageIndex) !== null && _options$pageIndex2 !== void 0 ? _options$pageIndex2 : 0 })
|
|
999
1019
|
})).data;
|
|
1000
1020
|
});
|
|
1001
|
-
return function listChildren(
|
|
1021
|
+
return function listChildren() {
|
|
1002
1022
|
return _ref14.apply(this, arguments);
|
|
1003
1023
|
};
|
|
1004
1024
|
}(),
|
|
@@ -1018,7 +1038,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1018
1038
|
query: { queue: true }
|
|
1019
1039
|
})).data;
|
|
1020
1040
|
});
|
|
1021
|
-
return function create(
|
|
1041
|
+
return function create(_x9) {
|
|
1022
1042
|
return _ref15.apply(this, arguments);
|
|
1023
1043
|
};
|
|
1024
1044
|
}(),
|
|
@@ -1040,7 +1060,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1040
1060
|
query: { queue: false }
|
|
1041
1061
|
})).data;
|
|
1042
1062
|
});
|
|
1043
|
-
return function moderate(
|
|
1063
|
+
return function moderate(_x10) {
|
|
1044
1064
|
return _ref16.apply(this, arguments);
|
|
1045
1065
|
};
|
|
1046
1066
|
}(),
|
|
@@ -1069,7 +1089,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1069
1089
|
}
|
|
1070
1090
|
return yield _this5.submitRawAssetPart(assetId, part, (_this$multipartUpload = _this5.multipartUploadQueues.get(assetId)) !== null && _this$multipartUpload !== void 0 ? _this$multipartUpload : false);
|
|
1071
1091
|
});
|
|
1072
|
-
return function uploadPart(
|
|
1092
|
+
return function uploadPart(_x11) {
|
|
1073
1093
|
return _ref17.apply(this, arguments);
|
|
1074
1094
|
};
|
|
1075
1095
|
}(),
|
|
@@ -1094,7 +1114,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1094
1114
|
params: { assetId }
|
|
1095
1115
|
})).data;
|
|
1096
1116
|
});
|
|
1097
|
-
return function createSignedUrl(
|
|
1117
|
+
return function createSignedUrl(_x12) {
|
|
1098
1118
|
return _ref19.apply(this, arguments);
|
|
1099
1119
|
};
|
|
1100
1120
|
}(),
|
|
@@ -1106,7 +1126,7 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1106
1126
|
body: { folderId }
|
|
1107
1127
|
})).data;
|
|
1108
1128
|
});
|
|
1109
|
-
return function move(
|
|
1129
|
+
return function move(_x13) {
|
|
1110
1130
|
return _ref20.apply(this, arguments);
|
|
1111
1131
|
};
|
|
1112
1132
|
}(),
|
|
@@ -1119,9 +1139,33 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1119
1139
|
if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
|
|
1120
1140
|
return (yield _this5.endpoints.retryAsset.submit({ params: { assetId } })).data;
|
|
1121
1141
|
});
|
|
1122
|
-
return function retry(
|
|
1142
|
+
return function retry(_x14) {
|
|
1123
1143
|
return _ref21.apply(this, arguments);
|
|
1124
1144
|
};
|
|
1145
|
+
}(),
|
|
1146
|
+
/**
|
|
1147
|
+
* Removes an asset's stored content (source, preview and retained extracted text) while
|
|
1148
|
+
* keeping the asset record, metadata and moderation report. The returned asset has
|
|
1149
|
+
* `storageDeletedAt` set; the CDN no longer serves it.
|
|
1150
|
+
*/
|
|
1151
|
+
deleteContent: function() {
|
|
1152
|
+
var _ref22 = _asyncToGenerator(function* ({ assetId }) {
|
|
1153
|
+
if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
|
|
1154
|
+
return (yield _this5.endpoints.deleteAssetContent.submit({ params: { assetId } })).data;
|
|
1155
|
+
});
|
|
1156
|
+
return function deleteContent(_x15) {
|
|
1157
|
+
return _ref22.apply(this, arguments);
|
|
1158
|
+
};
|
|
1159
|
+
}(),
|
|
1160
|
+
/** Deletes an asset record together with its stored content. */
|
|
1161
|
+
delete: function() {
|
|
1162
|
+
var _ref23 = _asyncToGenerator(function* ({ assetId }) {
|
|
1163
|
+
if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
|
|
1164
|
+
yield _this5.endpoints.deleteAsset.submit({ params: { assetId } });
|
|
1165
|
+
});
|
|
1166
|
+
return function _delete(_x16) {
|
|
1167
|
+
return _ref23.apply(this, arguments);
|
|
1168
|
+
};
|
|
1125
1169
|
}()
|
|
1126
1170
|
};
|
|
1127
1171
|
}
|
|
@@ -1134,14 +1178,14 @@ var CalmLensClient = class CalmLensClient {
|
|
|
1134
1178
|
* reshaped as `{ id, type, createdAt, projectId, data }`.
|
|
1135
1179
|
*/
|
|
1136
1180
|
list: function() {
|
|
1137
|
-
var
|
|
1181
|
+
var _ref24 = _asyncToGenerator(function* (options = {}) {
|
|
1138
1182
|
return (yield _this6.endpoints.getEvents.submit({
|
|
1139
1183
|
params: { projectId: _this6.options.projectId },
|
|
1140
1184
|
query: options
|
|
1141
1185
|
})).data;
|
|
1142
1186
|
});
|
|
1143
1187
|
return function list() {
|
|
1144
|
-
return
|
|
1188
|
+
return _ref24.apply(this, arguments);
|
|
1145
1189
|
};
|
|
1146
1190
|
}() };
|
|
1147
1191
|
}
|
|
@@ -1149,36 +1193,36 @@ list: function() {
|
|
|
1149
1193
|
var _this7 = this;
|
|
1150
1194
|
return {
|
|
1151
1195
|
list: function() {
|
|
1152
|
-
var
|
|
1196
|
+
var _ref25 = _asyncToGenerator(function* () {
|
|
1153
1197
|
return (yield _this7.endpoints.getFolders.submit({ params: { projectId: _this7.options.projectId } })).data.folders;
|
|
1154
1198
|
});
|
|
1155
1199
|
return function list() {
|
|
1156
|
-
return
|
|
1200
|
+
return _ref25.apply(this, arguments);
|
|
1157
1201
|
};
|
|
1158
1202
|
}(),
|
|
1159
1203
|
retrieve: function() {
|
|
1160
|
-
var
|
|
1204
|
+
var _ref26 = _asyncToGenerator(function* ({ folderId }) {
|
|
1161
1205
|
if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
|
|
1162
1206
|
return (yield _this7.endpoints.getFolder.submit({ params: { folderId } })).data;
|
|
1163
1207
|
});
|
|
1164
1208
|
return function retrieve(_x17) {
|
|
1165
|
-
return
|
|
1209
|
+
return _ref26.apply(this, arguments);
|
|
1166
1210
|
};
|
|
1167
1211
|
}(),
|
|
1168
1212
|
create: function() {
|
|
1169
|
-
var
|
|
1213
|
+
var _ref27 = _asyncToGenerator(function* (options) {
|
|
1170
1214
|
return (yield _this7.endpoints.postFolder.submit({
|
|
1171
1215
|
params: { projectId: _this7.options.projectId },
|
|
1172
1216
|
body: options
|
|
1173
1217
|
})).data;
|
|
1174
1218
|
});
|
|
1175
1219
|
return function create(_x18) {
|
|
1176
|
-
return
|
|
1220
|
+
return _ref27.apply(this, arguments);
|
|
1177
1221
|
};
|
|
1178
1222
|
}(),
|
|
1179
1223
|
update: function() {
|
|
1180
|
-
var
|
|
1181
|
-
let { folderId } =
|
|
1224
|
+
var _ref29 = _asyncToGenerator(function* (_ref28) {
|
|
1225
|
+
let { folderId } = _ref28, body = _objectWithoutProperties(_ref28, _excluded8);
|
|
1182
1226
|
if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
|
|
1183
1227
|
return (yield _this7.endpoints.patchFolder.submit({
|
|
1184
1228
|
params: { folderId },
|
|
@@ -1186,20 +1230,20 @@ list: function() {
|
|
|
1186
1230
|
})).data;
|
|
1187
1231
|
});
|
|
1188
1232
|
return function update(_x19) {
|
|
1189
|
-
return
|
|
1233
|
+
return _ref29.apply(this, arguments);
|
|
1190
1234
|
};
|
|
1191
1235
|
}(),
|
|
1192
1236
|
delete: function() {
|
|
1193
|
-
var
|
|
1237
|
+
var _ref30 = _asyncToGenerator(function* ({ folderId }) {
|
|
1194
1238
|
if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
|
|
1195
1239
|
yield _this7.endpoints.deleteFolder.submit({ params: { folderId } });
|
|
1196
1240
|
});
|
|
1197
1241
|
return function _delete(_x20) {
|
|
1198
|
-
return
|
|
1242
|
+
return _ref30.apply(this, arguments);
|
|
1199
1243
|
};
|
|
1200
1244
|
}(),
|
|
1201
1245
|
move: function() {
|
|
1202
|
-
var
|
|
1246
|
+
var _ref31 = _asyncToGenerator(function* ({ folderId, parentId }) {
|
|
1203
1247
|
if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
|
|
1204
1248
|
return (yield _this7.endpoints.moveFolder.submit({
|
|
1205
1249
|
params: { folderId },
|
|
@@ -1207,7 +1251,7 @@ list: function() {
|
|
|
1207
1251
|
})).data;
|
|
1208
1252
|
});
|
|
1209
1253
|
return function move(_x21) {
|
|
1210
|
-
return
|
|
1254
|
+
return _ref31.apply(this, arguments);
|
|
1211
1255
|
};
|
|
1212
1256
|
}()
|
|
1213
1257
|
};
|
package/esm/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as GetAssetResponse, C as RetryAssetOptions, D as UploadAssetPartOptions, E as UpdateFolderOptions, F as AssetBinaryPayloadInput, I as Lens, K as Asset, L as Folder, M as GetEventsResponse, N as PostAssetSignedUrlResponse, S as RetrieveAssetOptions, T as UpdateAssetOptions, _ as MoveAssetOptions, a as CreateAssetSignedUrlOptions, c as DeleteAssetContentOptions, d as EnsureLensesOptions, f as FolderIdOptions, g as ModerateTextOptions, h as ListEventsOptions, i as CdnServeOptions, j as GetAssetsPageResponse, k as GetAssetChildrenResponse, l as DeleteAssetOptions, m as ListAssetsOptions, n as CalmLensClientOptions, o as CreateFolderOptions, p as ListAssetChildrenOptions, q as AssetStatus, r as CdnAssetUrlOptions, u as EnsureLensOptions, v as MoveFolderOptions, w as SubmitAssetOptions } from "./CalmLensTypes-CZqyni4p.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
//#region ../shared/src/Permissions.d.ts
|
|
4
4
|
declare const GRANT_SCHEMA: zod.ZodObject<{
|
|
@@ -107,7 +107,7 @@ interface MockCalmLensClientOptions extends CalmLensClientOptions {
|
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
/** A `MockCalmLensClient` method, named like its path on the client. */
|
|
110
|
-
type MockCalmLensOperation = "assets.list" | "assets.retrieve" | "assets.update" | "assets.listChildren" | "assets.create" | "assets.moderate" | "assets.uploadPart" | "assets.createSignedUrl" | "assets.move" | "assets.retry" | "text.moderate" | "cdn.serve" | "events.list" | "folders.list" | "folders.retrieve" | "folders.create" | "folders.update" | "folders.delete" | "folders.move" | "ensureLens" | "ensureLenses";
|
|
110
|
+
type MockCalmLensOperation = "assets.list" | "assets.retrieve" | "assets.update" | "assets.listChildren" | "assets.create" | "assets.moderate" | "assets.uploadPart" | "assets.createSignedUrl" | "assets.move" | "assets.retry" | "assets.deleteContent" | "assets.delete" | "text.moderate" | "cdn.serve" | "events.list" | "folders.list" | "folders.retrieve" | "folders.create" | "folders.update" | "folders.delete" | "folders.move" | "ensureLens" | "ensureLenses";
|
|
111
111
|
/** One recorded call: the method and the options object it was given, exactly as passed. */
|
|
112
112
|
interface MockCalmLensCall {
|
|
113
113
|
operation: MockCalmLensOperation;
|
|
@@ -145,6 +145,7 @@ export declare class MockCalmLensClient {
|
|
|
145
145
|
}): void;
|
|
146
146
|
/** Calls recorded for one operation, oldest first. */
|
|
147
147
|
callsTo(operation: MockCalmLensOperation): MockCalmLensCall[];
|
|
148
|
+
private findOwnAsset;
|
|
148
149
|
private begin;
|
|
149
150
|
get cdn(): {
|
|
150
151
|
getAssetUrl: ({ assetIdentifier, ...options }: CdnAssetUrlOptions) => string;
|
|
@@ -158,9 +159,9 @@ export declare class MockCalmLensClient {
|
|
|
158
159
|
moderate: (options: ModerateTextOptions) => Promise<Asset>;
|
|
159
160
|
};
|
|
160
161
|
get assets(): {
|
|
161
|
-
list: (options
|
|
162
|
+
list: (options?: ListAssetsOptions) => Promise<GetAssetsPageResponse>;
|
|
162
163
|
retrieve: (options: RetrieveAssetOptions) => Promise<GetAssetResponse>;
|
|
163
|
-
listChildren: (childrenOptions
|
|
164
|
+
listChildren: (childrenOptions?: ListAssetChildrenOptions) => Promise<GetAssetChildrenResponse>;
|
|
164
165
|
update: (options: UpdateAssetOptions) => Promise<Asset>;
|
|
165
166
|
create: (options: SubmitAssetOptions) => Promise<Asset>;
|
|
166
167
|
moderate: (options: SubmitAssetOptions) => Promise<Asset>;
|
|
@@ -168,6 +169,8 @@ export declare class MockCalmLensClient {
|
|
|
168
169
|
createSignedUrl: (signedUrlOptions: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
|
|
169
170
|
move: (options: MoveAssetOptions) => Promise<Asset>;
|
|
170
171
|
retry: (options: RetryAssetOptions) => Promise<Asset>;
|
|
172
|
+
deleteContent: (options: DeleteAssetContentOptions) => Promise<Asset>;
|
|
173
|
+
delete: (options: DeleteAssetOptions) => Promise<void>;
|
|
171
174
|
};
|
|
172
175
|
get folders(): {
|
|
173
176
|
list: () => Promise<Folder[]>;
|