calmlens 0.3.1 → 0.4.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 +11 -0
- package/bin/calmlens.js +24 -0
- package/cjs/{CalmLensTypes-Bnq4u8HJ.d.ts → CalmLensTypes-DkqoKBwF.d.ts} +4 -1
- package/cjs/{CalmLensUtils-DocJkqQj.js → CalmLensUtils-CjdO9v--.js} +10 -0
- package/cjs/index.d.ts +7 -2
- package/cjs/index.js +40 -21
- package/cjs/testing.d.ts +2 -1
- package/cjs/testing.js +34 -19
- package/esm/{CalmLensTypes-Bnq4u8HJ.d.ts → CalmLensTypes-DkqoKBwF.d.ts} +4 -1
- package/esm/{CalmLensUtils--N_91gHC.js → CalmLensUtils-B3Eiz2Ro.js} +10 -0
- package/esm/index.d.ts +7 -2
- package/esm/index.js +40 -21
- package/esm/testing.d.ts +2 -1
- package/esm/testing.js +34 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -255,6 +255,17 @@ await client.assets.move({
|
|
|
255
255
|
});
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
+
##### assets.retry(options)
|
|
259
|
+
|
|
260
|
+
Process an asset that failed (status `error`) again. It returns to `pending` and is moderated like a
|
|
261
|
+
new upload, so handle the result the same way (webhook or polling). Its content must still be stored:
|
|
262
|
+
otherwise this throws `asset/content-unavailable`, and you need to upload it again.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const asset = await client.assets.retry({ assetId: "asset-uuid" });
|
|
266
|
+
// asset.status === "pending"
|
|
267
|
+
```
|
|
268
|
+
|
|
258
269
|
##### folders.list()
|
|
259
270
|
|
|
260
271
|
List all folders in the current project.
|
package/bin/calmlens.js
CHANGED
|
@@ -190,6 +190,16 @@ const PUBLIC_ERROR_CODES = {
|
|
|
190
190
|
defaultMessage: "Asset access is restricted by a safety hold.",
|
|
191
191
|
status: 423
|
|
192
192
|
}),
|
|
193
|
+
ASSET_NOT_RETRYABLE: new sendable_error.ErrorCode({
|
|
194
|
+
id: "asset/not-retryable",
|
|
195
|
+
defaultMessage: "Only assets that failed to process (status error) can be retried.",
|
|
196
|
+
status: 409
|
|
197
|
+
}),
|
|
198
|
+
ASSET_CONTENT_UNAVAILABLE: new sendable_error.ErrorCode({
|
|
199
|
+
id: "asset/content-unavailable",
|
|
200
|
+
defaultMessage: "This asset's content is no longer stored, so it can't be processed again. Upload it again instead.",
|
|
201
|
+
status: 409
|
|
202
|
+
}),
|
|
193
203
|
SUPPORT_TICKET_NOT_FOUND: new sendable_error.ErrorCode({
|
|
194
204
|
id: "support/ticket-not-found",
|
|
195
205
|
defaultMessage: "Support ticket not found.",
|
|
@@ -512,6 +522,11 @@ const createEndpoints = (api) => {
|
|
|
512
522
|
method: "post",
|
|
513
523
|
path: "/assets/:assetId/move"
|
|
514
524
|
});
|
|
525
|
+
const retryAsset = api.endpoint().paramsOf().responseOf().build({
|
|
526
|
+
id: "retryAsset",
|
|
527
|
+
method: "post",
|
|
528
|
+
path: "/assets/:assetId/retry"
|
|
529
|
+
});
|
|
515
530
|
const getEvents = api.endpoint().paramsOf().queryOf().responseOf().build({
|
|
516
531
|
id: "getEvents",
|
|
517
532
|
method: "get",
|
|
@@ -532,6 +547,7 @@ const createEndpoints = (api) => {
|
|
|
532
547
|
postAssetSignedUrl,
|
|
533
548
|
postAssetPart,
|
|
534
549
|
moveAsset,
|
|
550
|
+
retryAsset,
|
|
535
551
|
ensureLens: api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
536
552
|
id: "ensureLens",
|
|
537
553
|
method: "put",
|
|
@@ -838,6 +854,14 @@ moderate: async (options) => this.assets.analyze(toTextAssetOptions(options)) };
|
|
|
838
854
|
params: { assetId },
|
|
839
855
|
body: { folderId }
|
|
840
856
|
})).data;
|
|
857
|
+
},
|
|
858
|
+
/**
|
|
859
|
+
* Processes an asset that failed (status `error`) again. It returns to `pending` and is
|
|
860
|
+
* moderated like a new upload; its content must still be stored.
|
|
861
|
+
*/
|
|
862
|
+
retry: async ({ assetId }) => {
|
|
863
|
+
if (!assetId) throw new Error("Asset ID is required");
|
|
864
|
+
return (await this.endpoints.retryAsset.submit({ params: { assetId } })).data;
|
|
841
865
|
}
|
|
842
866
|
};
|
|
843
867
|
}
|
|
@@ -1683,6 +1683,9 @@ type ListEventsOptions = GetEventsQuery;
|
|
|
1683
1683
|
interface RetrieveAssetOptions {
|
|
1684
1684
|
assetId: string;
|
|
1685
1685
|
}
|
|
1686
|
+
interface RetryAssetOptions {
|
|
1687
|
+
assetId: string;
|
|
1688
|
+
}
|
|
1686
1689
|
type UpdateAssetOptions = PatchAssetBody & {
|
|
1687
1690
|
assetId: string;
|
|
1688
1691
|
};
|
|
@@ -1755,4 +1758,4 @@ interface VerifyWebhookSignatureOptions {
|
|
|
1755
1758
|
secret: string;
|
|
1756
1759
|
}
|
|
1757
1760
|
//#endregion
|
|
1758
|
-
export {
|
|
1761
|
+
export { RequestErrorCode as A, UploadAssetPartOptions as C, GetAssetsPageResponse as D, GetAssetResponse as E, AssetStatus as F, Lens as M, Folder as N, GetEventsResponse as O, Asset as P, UpdateFolderOptions as S, GetAssetChildrenResponse as T, MultipartUploadPartOptions as _, CreateFolderOptions as a, SubmitAssetOptions as b, EnsureLensesOptions as c, ListAssetsOptions as d, ListEventsOptions as f, MultipartUploadOptions as g, MoveFolderOptions as h, CreateAssetSignedUrlOptions as i, AssetBinaryPayloadInput as j, PostAssetSignedUrlResponse as k, FolderIdOptions as l, MoveAssetOptions as m, CdnAssetUrlOptions as n, CreateMultipartUploadPartOptions as o, ModerateTextOptions as p, CdnServeOptions as r, EnsureLensOptions as s, CalmLensClientOptions as t, ListAssetChildrenOptions as u, RetrieveAssetOptions as v, VerifyWebhookSignatureOptions as w, UpdateAssetOptions as x, RetryAssetOptions as y };
|
|
@@ -225,6 +225,16 @@ const PUBLIC_ERROR_CODES = {
|
|
|
225
225
|
defaultMessage: "Asset access is restricted by a safety hold.",
|
|
226
226
|
status: 423
|
|
227
227
|
}),
|
|
228
|
+
ASSET_NOT_RETRYABLE: new sendable_error.ErrorCode({
|
|
229
|
+
id: "asset/not-retryable",
|
|
230
|
+
defaultMessage: "Only assets that failed to process (status error) can be retried.",
|
|
231
|
+
status: 409
|
|
232
|
+
}),
|
|
233
|
+
ASSET_CONTENT_UNAVAILABLE: new sendable_error.ErrorCode({
|
|
234
|
+
id: "asset/content-unavailable",
|
|
235
|
+
defaultMessage: "This asset's content is no longer stored, so it can't be processed again. Upload it again instead.",
|
|
236
|
+
status: 409
|
|
237
|
+
}),
|
|
228
238
|
SUPPORT_TICKET_NOT_FOUND: new sendable_error.ErrorCode({
|
|
229
239
|
id: "support/ticket-not-found",
|
|
230
240
|
defaultMessage: "Support ticket not found.",
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as RequestErrorCode, C as UploadAssetPartOptions, D as GetAssetsPageResponse, E as GetAssetResponse, M as Lens, N as Folder, O as GetEventsResponse, P as Asset, S as UpdateFolderOptions, T as GetAssetChildrenResponse, _ as MultipartUploadPartOptions, a as CreateFolderOptions, b as SubmitAssetOptions, c as EnsureLensesOptions, d as ListAssetsOptions, f as ListEventsOptions, g as MultipartUploadOptions, h as MoveFolderOptions, i as CreateAssetSignedUrlOptions, k as PostAssetSignedUrlResponse, l as FolderIdOptions, m as MoveAssetOptions, n as CdnAssetUrlOptions, o as CreateMultipartUploadPartOptions, p as ModerateTextOptions, r as CdnServeOptions, s as EnsureLensOptions, t as CalmLensClientOptions, u as ListAssetChildrenOptions, v as RetrieveAssetOptions, w as VerifyWebhookSignatureOptions, x as UpdateAssetOptions, y as RetryAssetOptions } from "./CalmLensTypes-DkqoKBwF.js";
|
|
2
2
|
//#region src/client/CalmLensClient.d.ts
|
|
3
3
|
declare class CalmLensClient {
|
|
4
4
|
private options;
|
|
@@ -108,6 +108,11 @@ declare class CalmLensClient {
|
|
|
108
108
|
*/
|
|
109
109
|
createSignedUrl: ({ assetId, ...options }: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
|
|
110
110
|
move: ({ assetId, folderId }: MoveAssetOptions) => Promise<Asset>;
|
|
111
|
+
/**
|
|
112
|
+
* Processes an asset that failed (status `error`) again. It returns to `pending` and is
|
|
113
|
+
* moderated like a new upload; its content must still be stored.
|
|
114
|
+
*/
|
|
115
|
+
retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
|
|
111
116
|
};
|
|
112
117
|
get events(): {
|
|
113
118
|
/**
|
|
@@ -155,4 +160,4 @@ export declare class CalmLensError extends Error {
|
|
|
155
160
|
//#region src/client/CalmLensUtils.d.ts
|
|
156
161
|
export declare function verifyWebhookSignature({ payload, signatureHex, secret }: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
157
162
|
//#endregion
|
|
158
|
-
export { CalmLensClient, type CalmLensClientOptions, type CalmLensErrorDetails, type CdnAssetUrlOptions, type CdnServeOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type EnsureLensOptions, type EnsureLensesOptions, type FolderIdOptions, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type RetrieveAssetOptions, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions };
|
|
163
|
+
export { CalmLensClient, type CalmLensClientOptions, type CalmLensErrorDetails, type CdnAssetUrlOptions, type CdnServeOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type EnsureLensOptions, type EnsureLensesOptions, type FolderIdOptions, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type RetrieveAssetOptions, type RetryAssetOptions, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions };
|
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-CjdO9v--.js");
|
|
3
3
|
let api_def = require("api-def");
|
|
4
4
|
//#region src/client/CalmLensClient.ts
|
|
5
5
|
const _excluded = ["uint8Array"];
|
|
@@ -218,6 +218,11 @@ const createEndpoints = (api) => {
|
|
|
218
218
|
method: "post",
|
|
219
219
|
path: "/assets/:assetId/move"
|
|
220
220
|
});
|
|
221
|
+
const retryAsset = api.endpoint().paramsOf().responseOf().build({
|
|
222
|
+
id: "retryAsset",
|
|
223
|
+
method: "post",
|
|
224
|
+
path: "/assets/:assetId/retry"
|
|
225
|
+
});
|
|
221
226
|
const getEvents = api.endpoint().paramsOf().queryOf().responseOf().build({
|
|
222
227
|
id: "getEvents",
|
|
223
228
|
method: "get",
|
|
@@ -238,6 +243,7 @@ const createEndpoints = (api) => {
|
|
|
238
243
|
postAssetSignedUrl,
|
|
239
244
|
postAssetPart,
|
|
240
245
|
moveAsset,
|
|
246
|
+
retryAsset,
|
|
241
247
|
ensureLens: api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
242
248
|
id: "ensureLens",
|
|
243
249
|
method: "put",
|
|
@@ -625,6 +631,19 @@ moderate: function() {
|
|
|
625
631
|
return function move(_x11) {
|
|
626
632
|
return _ref17.apply(this, arguments);
|
|
627
633
|
};
|
|
634
|
+
}(),
|
|
635
|
+
/**
|
|
636
|
+
* Processes an asset that failed (status `error`) again. It returns to `pending` and is
|
|
637
|
+
* moderated like a new upload; its content must still be stored.
|
|
638
|
+
*/
|
|
639
|
+
retry: function() {
|
|
640
|
+
var _ref18 = require_CalmLensUtils._asyncToGenerator(function* ({ assetId }) {
|
|
641
|
+
if (!assetId) throw new Error("Asset ID is required");
|
|
642
|
+
return (yield _this5.endpoints.retryAsset.submit({ params: { assetId } })).data;
|
|
643
|
+
});
|
|
644
|
+
return function retry(_x12) {
|
|
645
|
+
return _ref18.apply(this, arguments);
|
|
646
|
+
};
|
|
628
647
|
}()
|
|
629
648
|
};
|
|
630
649
|
}
|
|
@@ -636,14 +655,14 @@ moderate: function() {
|
|
|
636
655
|
* for "now", then poll with the returned `cursor`. Event bodies match webhook deliveries.
|
|
637
656
|
*/
|
|
638
657
|
list: function() {
|
|
639
|
-
var
|
|
658
|
+
var _ref19 = require_CalmLensUtils._asyncToGenerator(function* (options = {}) {
|
|
640
659
|
return (yield _this6.endpoints.getEvents.submit({
|
|
641
660
|
params: { projectId: _this6.options.projectId },
|
|
642
661
|
query: options
|
|
643
662
|
})).data;
|
|
644
663
|
});
|
|
645
664
|
return function list() {
|
|
646
|
-
return
|
|
665
|
+
return _ref19.apply(this, arguments);
|
|
647
666
|
};
|
|
648
667
|
}() };
|
|
649
668
|
}
|
|
@@ -651,65 +670,65 @@ list: function() {
|
|
|
651
670
|
var _this7 = this;
|
|
652
671
|
return {
|
|
653
672
|
list: function() {
|
|
654
|
-
var
|
|
673
|
+
var _ref20 = require_CalmLensUtils._asyncToGenerator(function* () {
|
|
655
674
|
return (yield _this7.endpoints.getFolders.submit({ params: { projectId: _this7.options.projectId } })).data.folders;
|
|
656
675
|
});
|
|
657
676
|
return function list() {
|
|
658
|
-
return
|
|
677
|
+
return _ref20.apply(this, arguments);
|
|
659
678
|
};
|
|
660
679
|
}(),
|
|
661
680
|
retrieve: function() {
|
|
662
|
-
var
|
|
681
|
+
var _ref21 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId }) {
|
|
663
682
|
if (!folderId) throw new Error("Folder ID is required");
|
|
664
683
|
return (yield _this7.endpoints.getFolder.submit({ params: { folderId } })).data;
|
|
665
684
|
});
|
|
666
|
-
return function retrieve(
|
|
667
|
-
return
|
|
685
|
+
return function retrieve(_x13) {
|
|
686
|
+
return _ref21.apply(this, arguments);
|
|
668
687
|
};
|
|
669
688
|
}(),
|
|
670
689
|
create: function() {
|
|
671
|
-
var
|
|
690
|
+
var _ref22 = require_CalmLensUtils._asyncToGenerator(function* (options) {
|
|
672
691
|
return (yield _this7.endpoints.postFolder.submit({
|
|
673
692
|
params: { projectId: _this7.options.projectId },
|
|
674
693
|
body: options
|
|
675
694
|
})).data;
|
|
676
695
|
});
|
|
677
|
-
return function create(
|
|
678
|
-
return
|
|
696
|
+
return function create(_x14) {
|
|
697
|
+
return _ref22.apply(this, arguments);
|
|
679
698
|
};
|
|
680
699
|
}(),
|
|
681
700
|
update: function() {
|
|
682
|
-
var
|
|
683
|
-
let { folderId } =
|
|
701
|
+
var _ref24 = require_CalmLensUtils._asyncToGenerator(function* (_ref23) {
|
|
702
|
+
let { folderId } = _ref23, body = require_CalmLensUtils._objectWithoutProperties(_ref23, _excluded8);
|
|
684
703
|
if (!folderId) throw new Error("Folder ID is required");
|
|
685
704
|
return (yield _this7.endpoints.patchFolder.submit({
|
|
686
705
|
params: { folderId },
|
|
687
706
|
body
|
|
688
707
|
})).data;
|
|
689
708
|
});
|
|
690
|
-
return function update(
|
|
691
|
-
return
|
|
709
|
+
return function update(_x15) {
|
|
710
|
+
return _ref24.apply(this, arguments);
|
|
692
711
|
};
|
|
693
712
|
}(),
|
|
694
713
|
delete: function() {
|
|
695
|
-
var
|
|
714
|
+
var _ref25 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId }) {
|
|
696
715
|
if (!folderId) throw new Error("Folder ID is required");
|
|
697
716
|
yield _this7.endpoints.deleteFolder.submit({ params: { folderId } });
|
|
698
717
|
});
|
|
699
|
-
return function _delete(
|
|
700
|
-
return
|
|
718
|
+
return function _delete(_x16) {
|
|
719
|
+
return _ref25.apply(this, arguments);
|
|
701
720
|
};
|
|
702
721
|
}(),
|
|
703
722
|
move: function() {
|
|
704
|
-
var
|
|
723
|
+
var _ref26 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId, parentId }) {
|
|
705
724
|
if (!folderId) throw new Error("Folder ID is required");
|
|
706
725
|
return (yield _this7.endpoints.moveFolder.submit({
|
|
707
726
|
params: { folderId },
|
|
708
727
|
body: { parentId }
|
|
709
728
|
})).data;
|
|
710
729
|
});
|
|
711
|
-
return function move(
|
|
712
|
-
return
|
|
730
|
+
return function move(_x17) {
|
|
731
|
+
return _ref26.apply(this, arguments);
|
|
713
732
|
};
|
|
714
733
|
}()
|
|
715
734
|
};
|
package/cjs/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as UploadAssetPartOptions, D as GetAssetsPageResponse, E as GetAssetResponse, F as AssetStatus, M as Lens, N as Folder, O as GetEventsResponse, P as Asset, S as UpdateFolderOptions, T as GetAssetChildrenResponse, a as CreateFolderOptions, b as SubmitAssetOptions, c as EnsureLensesOptions, d as ListAssetsOptions, f as ListEventsOptions, h as MoveFolderOptions, i as CreateAssetSignedUrlOptions, j as AssetBinaryPayloadInput, k as PostAssetSignedUrlResponse, l as FolderIdOptions, m as MoveAssetOptions, n as CdnAssetUrlOptions, p as ModerateTextOptions, r as CdnServeOptions, s as EnsureLensOptions, t as CalmLensClientOptions, u as ListAssetChildrenOptions, v as RetrieveAssetOptions, y as RetryAssetOptions } from "./CalmLensTypes-DkqoKBwF.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
//#region ../shared/src/Permissions.d.ts
|
|
4
4
|
declare const GRANT_SCHEMA: zod.ZodObject<{
|
|
@@ -128,6 +128,7 @@ export declare class MockCalmLensClient {
|
|
|
128
128
|
uploadPart: ({ assetId, part }: UploadAssetPartOptions) => Promise<Asset>;
|
|
129
129
|
createSignedUrl: ({ assetId, ...options }: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
|
|
130
130
|
move: ({ assetId, folderId }: MoveAssetOptions) => Promise<Asset>;
|
|
131
|
+
retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
|
|
131
132
|
};
|
|
132
133
|
get folders(): {
|
|
133
134
|
list: () => Promise<Folder[]>;
|
package/cjs/testing.js
CHANGED
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_CalmLensUtils = require("./CalmLensUtils-
|
|
24
|
+
const require_CalmLensUtils = require("./CalmLensUtils-CjdO9v--.js");
|
|
25
25
|
let zod = require("zod");
|
|
26
26
|
zod = __toESM(zod);
|
|
27
27
|
//#region ../shared/src/Permissions.ts
|
|
@@ -473,6 +473,21 @@ list: function() {
|
|
|
473
473
|
return function move(_x10) {
|
|
474
474
|
return _ref15.apply(this, arguments);
|
|
475
475
|
};
|
|
476
|
+
}(),
|
|
477
|
+
retry: function() {
|
|
478
|
+
var _ref16 = require_CalmLensUtils._asyncToGenerator(function* ({ assetId }) {
|
|
479
|
+
if (!assetId) throw new Error("Asset ID is required");
|
|
480
|
+
const asset = yield _this4.databaseStorage.getAsset(assetId);
|
|
481
|
+
if (!asset || asset.projectId !== _this4.options.projectId) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.ASSET_NOT_FOUND);
|
|
482
|
+
if (asset.status !== "error") throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.ASSET_NOT_RETRYABLE);
|
|
483
|
+
return _this4.databaseStorage.updateAsset(require_CalmLensUtils._objectSpread2(require_CalmLensUtils._objectSpread2({}, asset), {}, {
|
|
484
|
+
status: "pending",
|
|
485
|
+
updatedAt: _this4.now()
|
|
486
|
+
}));
|
|
487
|
+
});
|
|
488
|
+
return function retry(_x11) {
|
|
489
|
+
return _ref16.apply(this, arguments);
|
|
490
|
+
};
|
|
476
491
|
}()
|
|
477
492
|
};
|
|
478
493
|
}
|
|
@@ -480,26 +495,26 @@ list: function() {
|
|
|
480
495
|
var _this5 = this;
|
|
481
496
|
return {
|
|
482
497
|
list: function() {
|
|
483
|
-
var
|
|
498
|
+
var _ref17 = require_CalmLensUtils._asyncToGenerator(function* () {
|
|
484
499
|
return [..._this5.databaseStorage.listFolders ? yield _this5.databaseStorage.listFolders(_this5.options.projectId) : []].sort((a, b) => a.name.localeCompare(b.name));
|
|
485
500
|
});
|
|
486
501
|
return function list() {
|
|
487
|
-
return
|
|
502
|
+
return _ref17.apply(this, arguments);
|
|
488
503
|
};
|
|
489
504
|
}(),
|
|
490
505
|
retrieve: function() {
|
|
491
|
-
var
|
|
506
|
+
var _ref18 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId }) {
|
|
492
507
|
if (!folderId) throw new Error("Folder ID is required");
|
|
493
508
|
const folder = yield _this5.resolveFolder(folderId);
|
|
494
509
|
if (!folder) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
495
510
|
return folder;
|
|
496
511
|
});
|
|
497
|
-
return function retrieve(
|
|
498
|
-
return
|
|
512
|
+
return function retrieve(_x12) {
|
|
513
|
+
return _ref18.apply(this, arguments);
|
|
499
514
|
};
|
|
500
515
|
}(),
|
|
501
516
|
create: function() {
|
|
502
|
-
var
|
|
517
|
+
var _ref19 = require_CalmLensUtils._asyncToGenerator(function* (options) {
|
|
503
518
|
var _options$parentId, _options$parentId2;
|
|
504
519
|
if (!options.name) throw new Error("Folder name is required");
|
|
505
520
|
if (options.parentId) {
|
|
@@ -517,13 +532,13 @@ list: function() {
|
|
|
517
532
|
if (_this5.databaseStorage.createFolder) return yield _this5.databaseStorage.createFolder(folder);
|
|
518
533
|
return folder;
|
|
519
534
|
});
|
|
520
|
-
return function create(
|
|
521
|
-
return
|
|
535
|
+
return function create(_x13) {
|
|
536
|
+
return _ref19.apply(this, arguments);
|
|
522
537
|
};
|
|
523
538
|
}(),
|
|
524
539
|
update: function() {
|
|
525
|
-
var
|
|
526
|
-
let { folderId } =
|
|
540
|
+
var _ref21 = require_CalmLensUtils._asyncToGenerator(function* (_ref20) {
|
|
541
|
+
let { folderId } = _ref20, body = require_CalmLensUtils._objectWithoutProperties(_ref20, _excluded5);
|
|
527
542
|
if (!folderId) throw new Error("Folder ID is required");
|
|
528
543
|
const folder = yield _this5.resolveFolder(folderId);
|
|
529
544
|
if (!folder) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -535,12 +550,12 @@ list: function() {
|
|
|
535
550
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
536
551
|
return updated;
|
|
537
552
|
});
|
|
538
|
-
return function update(
|
|
539
|
-
return
|
|
553
|
+
return function update(_x14) {
|
|
554
|
+
return _ref21.apply(this, arguments);
|
|
540
555
|
};
|
|
541
556
|
}(),
|
|
542
557
|
delete: function() {
|
|
543
|
-
var
|
|
558
|
+
var _ref22 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId }) {
|
|
544
559
|
if (!folderId) throw new Error("Folder ID is required");
|
|
545
560
|
if (!(yield _this5.resolveFolder(folderId))) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
546
561
|
const hasAssets = (yield _this5.databaseStorage.listAssets(_this5.options.projectId)).some((asset) => asset.folderId === folderId);
|
|
@@ -551,12 +566,12 @@ list: function() {
|
|
|
551
566
|
} });
|
|
552
567
|
if (_this5.databaseStorage.deleteFolder) yield _this5.databaseStorage.deleteFolder(folderId);
|
|
553
568
|
});
|
|
554
|
-
return function _delete(
|
|
555
|
-
return
|
|
569
|
+
return function _delete(_x15) {
|
|
570
|
+
return _ref22.apply(this, arguments);
|
|
556
571
|
};
|
|
557
572
|
}(),
|
|
558
573
|
move: function() {
|
|
559
|
-
var
|
|
574
|
+
var _ref23 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId, parentId }) {
|
|
560
575
|
if (!folderId) throw new Error("Folder ID is required");
|
|
561
576
|
const folder = yield _this5.resolveFolder(folderId);
|
|
562
577
|
if (!folder) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -580,8 +595,8 @@ list: function() {
|
|
|
580
595
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
581
596
|
return updated;
|
|
582
597
|
});
|
|
583
|
-
return function move(
|
|
584
|
-
return
|
|
598
|
+
return function move(_x16) {
|
|
599
|
+
return _ref23.apply(this, arguments);
|
|
585
600
|
};
|
|
586
601
|
}()
|
|
587
602
|
};
|
|
@@ -1683,6 +1683,9 @@ type ListEventsOptions = GetEventsQuery;
|
|
|
1683
1683
|
interface RetrieveAssetOptions {
|
|
1684
1684
|
assetId: string;
|
|
1685
1685
|
}
|
|
1686
|
+
interface RetryAssetOptions {
|
|
1687
|
+
assetId: string;
|
|
1688
|
+
}
|
|
1686
1689
|
type UpdateAssetOptions = PatchAssetBody & {
|
|
1687
1690
|
assetId: string;
|
|
1688
1691
|
};
|
|
@@ -1755,4 +1758,4 @@ interface VerifyWebhookSignatureOptions {
|
|
|
1755
1758
|
secret: string;
|
|
1756
1759
|
}
|
|
1757
1760
|
//#endregion
|
|
1758
|
-
export {
|
|
1761
|
+
export { RequestErrorCode as A, UploadAssetPartOptions as C, GetAssetsPageResponse as D, GetAssetResponse as E, AssetStatus as F, Lens as M, Folder as N, GetEventsResponse as O, Asset as P, UpdateFolderOptions as S, GetAssetChildrenResponse as T, MultipartUploadPartOptions as _, CreateFolderOptions as a, SubmitAssetOptions as b, EnsureLensesOptions as c, ListAssetsOptions as d, ListEventsOptions as f, MultipartUploadOptions as g, MoveFolderOptions as h, CreateAssetSignedUrlOptions as i, AssetBinaryPayloadInput as j, PostAssetSignedUrlResponse as k, FolderIdOptions as l, MoveAssetOptions as m, CdnAssetUrlOptions as n, CreateMultipartUploadPartOptions as o, ModerateTextOptions as p, CdnServeOptions as r, EnsureLensOptions as s, CalmLensClientOptions as t, ListAssetChildrenOptions as u, RetrieveAssetOptions as v, VerifyWebhookSignatureOptions as w, UpdateAssetOptions as x, RetryAssetOptions as y };
|
|
@@ -225,6 +225,16 @@ const PUBLIC_ERROR_CODES = {
|
|
|
225
225
|
defaultMessage: "Asset access is restricted by a safety hold.",
|
|
226
226
|
status: 423
|
|
227
227
|
}),
|
|
228
|
+
ASSET_NOT_RETRYABLE: new ErrorCode({
|
|
229
|
+
id: "asset/not-retryable",
|
|
230
|
+
defaultMessage: "Only assets that failed to process (status error) can be retried.",
|
|
231
|
+
status: 409
|
|
232
|
+
}),
|
|
233
|
+
ASSET_CONTENT_UNAVAILABLE: new ErrorCode({
|
|
234
|
+
id: "asset/content-unavailable",
|
|
235
|
+
defaultMessage: "This asset's content is no longer stored, so it can't be processed again. Upload it again instead.",
|
|
236
|
+
status: 409
|
|
237
|
+
}),
|
|
228
238
|
SUPPORT_TICKET_NOT_FOUND: new ErrorCode({
|
|
229
239
|
id: "support/ticket-not-found",
|
|
230
240
|
defaultMessage: "Support ticket not found.",
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as RequestErrorCode, C as UploadAssetPartOptions, D as GetAssetsPageResponse, E as GetAssetResponse, M as Lens, N as Folder, O as GetEventsResponse, P as Asset, S as UpdateFolderOptions, T as GetAssetChildrenResponse, _ as MultipartUploadPartOptions, a as CreateFolderOptions, b as SubmitAssetOptions, c as EnsureLensesOptions, d as ListAssetsOptions, f as ListEventsOptions, g as MultipartUploadOptions, h as MoveFolderOptions, i as CreateAssetSignedUrlOptions, k as PostAssetSignedUrlResponse, l as FolderIdOptions, m as MoveAssetOptions, n as CdnAssetUrlOptions, o as CreateMultipartUploadPartOptions, p as ModerateTextOptions, r as CdnServeOptions, s as EnsureLensOptions, t as CalmLensClientOptions, u as ListAssetChildrenOptions, v as RetrieveAssetOptions, w as VerifyWebhookSignatureOptions, x as UpdateAssetOptions, y as RetryAssetOptions } from "./CalmLensTypes-DkqoKBwF.js";
|
|
2
2
|
//#region src/client/CalmLensClient.d.ts
|
|
3
3
|
declare class CalmLensClient {
|
|
4
4
|
private options;
|
|
@@ -108,6 +108,11 @@ declare class CalmLensClient {
|
|
|
108
108
|
*/
|
|
109
109
|
createSignedUrl: ({ assetId, ...options }: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
|
|
110
110
|
move: ({ assetId, folderId }: MoveAssetOptions) => Promise<Asset>;
|
|
111
|
+
/**
|
|
112
|
+
* Processes an asset that failed (status `error`) again. It returns to `pending` and is
|
|
113
|
+
* moderated like a new upload; its content must still be stored.
|
|
114
|
+
*/
|
|
115
|
+
retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
|
|
111
116
|
};
|
|
112
117
|
get events(): {
|
|
113
118
|
/**
|
|
@@ -155,4 +160,4 @@ export declare class CalmLensError extends Error {
|
|
|
155
160
|
//#region src/client/CalmLensUtils.d.ts
|
|
156
161
|
export declare function verifyWebhookSignature({ payload, signatureHex, secret }: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
157
162
|
//#endregion
|
|
158
|
-
export { CalmLensClient, type CalmLensClientOptions, type CalmLensErrorDetails, type CdnAssetUrlOptions, type CdnServeOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type EnsureLensOptions, type EnsureLensesOptions, type FolderIdOptions, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type RetrieveAssetOptions, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions };
|
|
163
|
+
export { CalmLensClient, type CalmLensClientOptions, type CalmLensErrorDetails, type CdnAssetUrlOptions, type CdnServeOptions, type CreateAssetSignedUrlOptions, type CreateFolderOptions, type CreateMultipartUploadPartOptions, type EnsureLensOptions, type EnsureLensesOptions, type FolderIdOptions, type ListAssetChildrenOptions, type ListAssetsOptions, type ListEventsOptions, type ModerateTextOptions, type MoveAssetOptions, type MoveFolderOptions, type MultipartUploadOptions, type MultipartUploadPartOptions, type RetrieveAssetOptions, type RetryAssetOptions, type UpdateAssetOptions, type UpdateFolderOptions, type UploadAssetPartOptions, type VerifyWebhookSignatureOptions };
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as getAssetPayloadByteLength, a as CalmLensError, b as _asyncToGenerator, c as DOMAIN, d as getRejectedUploadMimeTypeError, f as isRejectedUploadMimeType, g as assetToData, i as _objectWithoutProperties, m as stringifyJsonCanonical, n as verifyWebhookSignature, o as SDK_ERRORS, p as PUBLIC_ERROR_CODES, r as _objectSpread2, s as calmLensError, t as toTextAssetOptions, v as getRawBase64, y as validateAssetPayload } from "./CalmLensUtils
|
|
1
|
+
import { _ as getAssetPayloadByteLength, a as CalmLensError, b as _asyncToGenerator, c as DOMAIN, d as getRejectedUploadMimeTypeError, f as isRejectedUploadMimeType, g as assetToData, i as _objectWithoutProperties, m as stringifyJsonCanonical, n as verifyWebhookSignature, o as SDK_ERRORS, p as PUBLIC_ERROR_CODES, r as _objectSpread2, s as calmLensError, t as toTextAssetOptions, v as getRawBase64, y as validateAssetPayload } from "./CalmLensUtils-B3Eiz2Ro.js";
|
|
2
2
|
import { Api, RequestCoalescingMiddleware, RequestEvent, getErrorResponse, isRequestError } from "api-def";
|
|
3
3
|
//#region src/client/CalmLensClient.ts
|
|
4
4
|
const _excluded = ["uint8Array"];
|
|
@@ -217,6 +217,11 @@ const createEndpoints = (api) => {
|
|
|
217
217
|
method: "post",
|
|
218
218
|
path: "/assets/:assetId/move"
|
|
219
219
|
});
|
|
220
|
+
const retryAsset = api.endpoint().paramsOf().responseOf().build({
|
|
221
|
+
id: "retryAsset",
|
|
222
|
+
method: "post",
|
|
223
|
+
path: "/assets/:assetId/retry"
|
|
224
|
+
});
|
|
220
225
|
const getEvents = api.endpoint().paramsOf().queryOf().responseOf().build({
|
|
221
226
|
id: "getEvents",
|
|
222
227
|
method: "get",
|
|
@@ -237,6 +242,7 @@ const createEndpoints = (api) => {
|
|
|
237
242
|
postAssetSignedUrl,
|
|
238
243
|
postAssetPart,
|
|
239
244
|
moveAsset,
|
|
245
|
+
retryAsset,
|
|
240
246
|
ensureLens: api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
241
247
|
id: "ensureLens",
|
|
242
248
|
method: "put",
|
|
@@ -624,6 +630,19 @@ moderate: function() {
|
|
|
624
630
|
return function move(_x11) {
|
|
625
631
|
return _ref17.apply(this, arguments);
|
|
626
632
|
};
|
|
633
|
+
}(),
|
|
634
|
+
/**
|
|
635
|
+
* Processes an asset that failed (status `error`) again. It returns to `pending` and is
|
|
636
|
+
* moderated like a new upload; its content must still be stored.
|
|
637
|
+
*/
|
|
638
|
+
retry: function() {
|
|
639
|
+
var _ref18 = _asyncToGenerator(function* ({ assetId }) {
|
|
640
|
+
if (!assetId) throw new Error("Asset ID is required");
|
|
641
|
+
return (yield _this5.endpoints.retryAsset.submit({ params: { assetId } })).data;
|
|
642
|
+
});
|
|
643
|
+
return function retry(_x12) {
|
|
644
|
+
return _ref18.apply(this, arguments);
|
|
645
|
+
};
|
|
627
646
|
}()
|
|
628
647
|
};
|
|
629
648
|
}
|
|
@@ -635,14 +654,14 @@ moderate: function() {
|
|
|
635
654
|
* for "now", then poll with the returned `cursor`. Event bodies match webhook deliveries.
|
|
636
655
|
*/
|
|
637
656
|
list: function() {
|
|
638
|
-
var
|
|
657
|
+
var _ref19 = _asyncToGenerator(function* (options = {}) {
|
|
639
658
|
return (yield _this6.endpoints.getEvents.submit({
|
|
640
659
|
params: { projectId: _this6.options.projectId },
|
|
641
660
|
query: options
|
|
642
661
|
})).data;
|
|
643
662
|
});
|
|
644
663
|
return function list() {
|
|
645
|
-
return
|
|
664
|
+
return _ref19.apply(this, arguments);
|
|
646
665
|
};
|
|
647
666
|
}() };
|
|
648
667
|
}
|
|
@@ -650,65 +669,65 @@ list: function() {
|
|
|
650
669
|
var _this7 = this;
|
|
651
670
|
return {
|
|
652
671
|
list: function() {
|
|
653
|
-
var
|
|
672
|
+
var _ref20 = _asyncToGenerator(function* () {
|
|
654
673
|
return (yield _this7.endpoints.getFolders.submit({ params: { projectId: _this7.options.projectId } })).data.folders;
|
|
655
674
|
});
|
|
656
675
|
return function list() {
|
|
657
|
-
return
|
|
676
|
+
return _ref20.apply(this, arguments);
|
|
658
677
|
};
|
|
659
678
|
}(),
|
|
660
679
|
retrieve: function() {
|
|
661
|
-
var
|
|
680
|
+
var _ref21 = _asyncToGenerator(function* ({ folderId }) {
|
|
662
681
|
if (!folderId) throw new Error("Folder ID is required");
|
|
663
682
|
return (yield _this7.endpoints.getFolder.submit({ params: { folderId } })).data;
|
|
664
683
|
});
|
|
665
|
-
return function retrieve(
|
|
666
|
-
return
|
|
684
|
+
return function retrieve(_x13) {
|
|
685
|
+
return _ref21.apply(this, arguments);
|
|
667
686
|
};
|
|
668
687
|
}(),
|
|
669
688
|
create: function() {
|
|
670
|
-
var
|
|
689
|
+
var _ref22 = _asyncToGenerator(function* (options) {
|
|
671
690
|
return (yield _this7.endpoints.postFolder.submit({
|
|
672
691
|
params: { projectId: _this7.options.projectId },
|
|
673
692
|
body: options
|
|
674
693
|
})).data;
|
|
675
694
|
});
|
|
676
|
-
return function create(
|
|
677
|
-
return
|
|
695
|
+
return function create(_x14) {
|
|
696
|
+
return _ref22.apply(this, arguments);
|
|
678
697
|
};
|
|
679
698
|
}(),
|
|
680
699
|
update: function() {
|
|
681
|
-
var
|
|
682
|
-
let { folderId } =
|
|
700
|
+
var _ref24 = _asyncToGenerator(function* (_ref23) {
|
|
701
|
+
let { folderId } = _ref23, body = _objectWithoutProperties(_ref23, _excluded8);
|
|
683
702
|
if (!folderId) throw new Error("Folder ID is required");
|
|
684
703
|
return (yield _this7.endpoints.patchFolder.submit({
|
|
685
704
|
params: { folderId },
|
|
686
705
|
body
|
|
687
706
|
})).data;
|
|
688
707
|
});
|
|
689
|
-
return function update(
|
|
690
|
-
return
|
|
708
|
+
return function update(_x15) {
|
|
709
|
+
return _ref24.apply(this, arguments);
|
|
691
710
|
};
|
|
692
711
|
}(),
|
|
693
712
|
delete: function() {
|
|
694
|
-
var
|
|
713
|
+
var _ref25 = _asyncToGenerator(function* ({ folderId }) {
|
|
695
714
|
if (!folderId) throw new Error("Folder ID is required");
|
|
696
715
|
yield _this7.endpoints.deleteFolder.submit({ params: { folderId } });
|
|
697
716
|
});
|
|
698
|
-
return function _delete(
|
|
699
|
-
return
|
|
717
|
+
return function _delete(_x16) {
|
|
718
|
+
return _ref25.apply(this, arguments);
|
|
700
719
|
};
|
|
701
720
|
}(),
|
|
702
721
|
move: function() {
|
|
703
|
-
var
|
|
722
|
+
var _ref26 = _asyncToGenerator(function* ({ folderId, parentId }) {
|
|
704
723
|
if (!folderId) throw new Error("Folder ID is required");
|
|
705
724
|
return (yield _this7.endpoints.moveFolder.submit({
|
|
706
725
|
params: { folderId },
|
|
707
726
|
body: { parentId }
|
|
708
727
|
})).data;
|
|
709
728
|
});
|
|
710
|
-
return function move(
|
|
711
|
-
return
|
|
729
|
+
return function move(_x17) {
|
|
730
|
+
return _ref26.apply(this, arguments);
|
|
712
731
|
};
|
|
713
732
|
}()
|
|
714
733
|
};
|
package/esm/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as UploadAssetPartOptions, D as GetAssetsPageResponse, E as GetAssetResponse, F as AssetStatus, M as Lens, N as Folder, O as GetEventsResponse, P as Asset, S as UpdateFolderOptions, T as GetAssetChildrenResponse, a as CreateFolderOptions, b as SubmitAssetOptions, c as EnsureLensesOptions, d as ListAssetsOptions, f as ListEventsOptions, h as MoveFolderOptions, i as CreateAssetSignedUrlOptions, j as AssetBinaryPayloadInput, k as PostAssetSignedUrlResponse, l as FolderIdOptions, m as MoveAssetOptions, n as CdnAssetUrlOptions, p as ModerateTextOptions, r as CdnServeOptions, s as EnsureLensOptions, t as CalmLensClientOptions, u as ListAssetChildrenOptions, v as RetrieveAssetOptions, y as RetryAssetOptions } from "./CalmLensTypes-DkqoKBwF.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
//#region ../shared/src/Permissions.d.ts
|
|
4
4
|
declare const GRANT_SCHEMA: zod.ZodObject<{
|
|
@@ -128,6 +128,7 @@ export declare class MockCalmLensClient {
|
|
|
128
128
|
uploadPart: ({ assetId, part }: UploadAssetPartOptions) => Promise<Asset>;
|
|
129
129
|
createSignedUrl: ({ assetId, ...options }: CreateAssetSignedUrlOptions) => Promise<PostAssetSignedUrlResponse>;
|
|
130
130
|
move: ({ assetId, folderId }: MoveAssetOptions) => Promise<Asset>;
|
|
131
|
+
retry: ({ assetId }: RetryAssetOptions) => Promise<Asset>;
|
|
131
132
|
};
|
|
132
133
|
get folders(): {
|
|
133
134
|
list: () => Promise<Folder[]>;
|
package/esm/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as getAssetPayloadByteLength, b as _asyncToGenerator, d as getRejectedUploadMimeTypeError, f as isRejectedUploadMimeType, g as assetToData, h as assetDataToUint8Array, i as _objectWithoutProperties, m as stringifyJsonCanonical, p as PUBLIC_ERROR_CODES, r as _objectSpread2, s as calmLensError, t as toTextAssetOptions, y as validateAssetPayload } from "./CalmLensUtils
|
|
1
|
+
import { _ as getAssetPayloadByteLength, b as _asyncToGenerator, d as getRejectedUploadMimeTypeError, f as isRejectedUploadMimeType, g as assetToData, h as assetDataToUint8Array, i as _objectWithoutProperties, m as stringifyJsonCanonical, p as PUBLIC_ERROR_CODES, r as _objectSpread2, s as calmLensError, t as toTextAssetOptions, y as validateAssetPayload } from "./CalmLensUtils-B3Eiz2Ro.js";
|
|
2
2
|
import * as zod from "zod";
|
|
3
3
|
//#region ../shared/src/Permissions.ts
|
|
4
4
|
const ACTION_SCHEMA = zod.enum([
|
|
@@ -449,6 +449,21 @@ list: function() {
|
|
|
449
449
|
return function move(_x10) {
|
|
450
450
|
return _ref15.apply(this, arguments);
|
|
451
451
|
};
|
|
452
|
+
}(),
|
|
453
|
+
retry: function() {
|
|
454
|
+
var _ref16 = _asyncToGenerator(function* ({ assetId }) {
|
|
455
|
+
if (!assetId) throw new Error("Asset ID is required");
|
|
456
|
+
const asset = yield _this4.databaseStorage.getAsset(assetId);
|
|
457
|
+
if (!asset || asset.projectId !== _this4.options.projectId) throw calmLensError(PUBLIC_ERROR_CODES.ASSET_NOT_FOUND);
|
|
458
|
+
if (asset.status !== "error") throw calmLensError(PUBLIC_ERROR_CODES.ASSET_NOT_RETRYABLE);
|
|
459
|
+
return _this4.databaseStorage.updateAsset(_objectSpread2(_objectSpread2({}, asset), {}, {
|
|
460
|
+
status: "pending",
|
|
461
|
+
updatedAt: _this4.now()
|
|
462
|
+
}));
|
|
463
|
+
});
|
|
464
|
+
return function retry(_x11) {
|
|
465
|
+
return _ref16.apply(this, arguments);
|
|
466
|
+
};
|
|
452
467
|
}()
|
|
453
468
|
};
|
|
454
469
|
}
|
|
@@ -456,26 +471,26 @@ list: function() {
|
|
|
456
471
|
var _this5 = this;
|
|
457
472
|
return {
|
|
458
473
|
list: function() {
|
|
459
|
-
var
|
|
474
|
+
var _ref17 = _asyncToGenerator(function* () {
|
|
460
475
|
return [..._this5.databaseStorage.listFolders ? yield _this5.databaseStorage.listFolders(_this5.options.projectId) : []].sort((a, b) => a.name.localeCompare(b.name));
|
|
461
476
|
});
|
|
462
477
|
return function list() {
|
|
463
|
-
return
|
|
478
|
+
return _ref17.apply(this, arguments);
|
|
464
479
|
};
|
|
465
480
|
}(),
|
|
466
481
|
retrieve: function() {
|
|
467
|
-
var
|
|
482
|
+
var _ref18 = _asyncToGenerator(function* ({ folderId }) {
|
|
468
483
|
if (!folderId) throw new Error("Folder ID is required");
|
|
469
484
|
const folder = yield _this5.resolveFolder(folderId);
|
|
470
485
|
if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
471
486
|
return folder;
|
|
472
487
|
});
|
|
473
|
-
return function retrieve(
|
|
474
|
-
return
|
|
488
|
+
return function retrieve(_x12) {
|
|
489
|
+
return _ref18.apply(this, arguments);
|
|
475
490
|
};
|
|
476
491
|
}(),
|
|
477
492
|
create: function() {
|
|
478
|
-
var
|
|
493
|
+
var _ref19 = _asyncToGenerator(function* (options) {
|
|
479
494
|
var _options$parentId, _options$parentId2;
|
|
480
495
|
if (!options.name) throw new Error("Folder name is required");
|
|
481
496
|
if (options.parentId) {
|
|
@@ -493,13 +508,13 @@ list: function() {
|
|
|
493
508
|
if (_this5.databaseStorage.createFolder) return yield _this5.databaseStorage.createFolder(folder);
|
|
494
509
|
return folder;
|
|
495
510
|
});
|
|
496
|
-
return function create(
|
|
497
|
-
return
|
|
511
|
+
return function create(_x13) {
|
|
512
|
+
return _ref19.apply(this, arguments);
|
|
498
513
|
};
|
|
499
514
|
}(),
|
|
500
515
|
update: function() {
|
|
501
|
-
var
|
|
502
|
-
let { folderId } =
|
|
516
|
+
var _ref21 = _asyncToGenerator(function* (_ref20) {
|
|
517
|
+
let { folderId } = _ref20, body = _objectWithoutProperties(_ref20, _excluded5);
|
|
503
518
|
if (!folderId) throw new Error("Folder ID is required");
|
|
504
519
|
const folder = yield _this5.resolveFolder(folderId);
|
|
505
520
|
if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -511,12 +526,12 @@ list: function() {
|
|
|
511
526
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
512
527
|
return updated;
|
|
513
528
|
});
|
|
514
|
-
return function update(
|
|
515
|
-
return
|
|
529
|
+
return function update(_x14) {
|
|
530
|
+
return _ref21.apply(this, arguments);
|
|
516
531
|
};
|
|
517
532
|
}(),
|
|
518
533
|
delete: function() {
|
|
519
|
-
var
|
|
534
|
+
var _ref22 = _asyncToGenerator(function* ({ folderId }) {
|
|
520
535
|
if (!folderId) throw new Error("Folder ID is required");
|
|
521
536
|
if (!(yield _this5.resolveFolder(folderId))) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
522
537
|
const hasAssets = (yield _this5.databaseStorage.listAssets(_this5.options.projectId)).some((asset) => asset.folderId === folderId);
|
|
@@ -527,12 +542,12 @@ list: function() {
|
|
|
527
542
|
} });
|
|
528
543
|
if (_this5.databaseStorage.deleteFolder) yield _this5.databaseStorage.deleteFolder(folderId);
|
|
529
544
|
});
|
|
530
|
-
return function _delete(
|
|
531
|
-
return
|
|
545
|
+
return function _delete(_x15) {
|
|
546
|
+
return _ref22.apply(this, arguments);
|
|
532
547
|
};
|
|
533
548
|
}(),
|
|
534
549
|
move: function() {
|
|
535
|
-
var
|
|
550
|
+
var _ref23 = _asyncToGenerator(function* ({ folderId, parentId }) {
|
|
536
551
|
if (!folderId) throw new Error("Folder ID is required");
|
|
537
552
|
const folder = yield _this5.resolveFolder(folderId);
|
|
538
553
|
if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -556,8 +571,8 @@ list: function() {
|
|
|
556
571
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
557
572
|
return updated;
|
|
558
573
|
});
|
|
559
|
-
return function move(
|
|
560
|
-
return
|
|
574
|
+
return function move(_x16) {
|
|
575
|
+
return _ref23.apply(this, arguments);
|
|
561
576
|
};
|
|
562
577
|
}()
|
|
563
578
|
};
|