calmlens 0.3.0 → 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 +29 -0
- package/cjs/{CalmLensTypes-Bnq4u8HJ.d.ts → CalmLensTypes-DkqoKBwF.d.ts} +4 -1
- package/cjs/{CalmLensUtils-DioFUAmI.js → CalmLensUtils-CjdO9v--.js} +15 -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 +41 -19
- package/esm/{CalmLensTypes-Bnq4u8HJ.d.ts → CalmLensTypes-DkqoKBwF.d.ts} +4 -1
- package/esm/{CalmLensUtils-Dixed1Ox.js → CalmLensUtils-B3Eiz2Ro.js} +15 -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 +41 -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
|
@@ -100,6 +100,11 @@ const PUBLIC_ERROR_CODES = {
|
|
|
100
100
|
defaultMessage: "This API key belongs to a different project. Use a key created for the project that owns this resource.",
|
|
101
101
|
status: 403
|
|
102
102
|
}),
|
|
103
|
+
API_KEY_NOT_ACCEPTED: new sendable_error.ErrorCode({
|
|
104
|
+
id: "auth/api-key-not-accepted",
|
|
105
|
+
defaultMessage: "API keys are only accepted by the public API at /v1.",
|
|
106
|
+
status: 403
|
|
107
|
+
}),
|
|
103
108
|
FILE_TOO_LARGE: new sendable_error.ErrorCode({
|
|
104
109
|
id: "upload/file-too-large",
|
|
105
110
|
defaultMessage: "File size exceeds limit. Maximum size for images is 10MB, for other files is 5GB.",
|
|
@@ -185,6 +190,16 @@ const PUBLIC_ERROR_CODES = {
|
|
|
185
190
|
defaultMessage: "Asset access is restricted by a safety hold.",
|
|
186
191
|
status: 423
|
|
187
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
|
+
}),
|
|
188
203
|
SUPPORT_TICKET_NOT_FOUND: new sendable_error.ErrorCode({
|
|
189
204
|
id: "support/ticket-not-found",
|
|
190
205
|
defaultMessage: "Support ticket not found.",
|
|
@@ -507,6 +522,11 @@ const createEndpoints = (api) => {
|
|
|
507
522
|
method: "post",
|
|
508
523
|
path: "/assets/:assetId/move"
|
|
509
524
|
});
|
|
525
|
+
const retryAsset = api.endpoint().paramsOf().responseOf().build({
|
|
526
|
+
id: "retryAsset",
|
|
527
|
+
method: "post",
|
|
528
|
+
path: "/assets/:assetId/retry"
|
|
529
|
+
});
|
|
510
530
|
const getEvents = api.endpoint().paramsOf().queryOf().responseOf().build({
|
|
511
531
|
id: "getEvents",
|
|
512
532
|
method: "get",
|
|
@@ -527,6 +547,7 @@ const createEndpoints = (api) => {
|
|
|
527
547
|
postAssetSignedUrl,
|
|
528
548
|
postAssetPart,
|
|
529
549
|
moveAsset,
|
|
550
|
+
retryAsset,
|
|
530
551
|
ensureLens: api.endpoint().bodyOf().paramsOf().responseOf().build({
|
|
531
552
|
id: "ensureLens",
|
|
532
553
|
method: "put",
|
|
@@ -833,6 +854,14 @@ moderate: async (options) => this.assets.analyze(toTextAssetOptions(options)) };
|
|
|
833
854
|
params: { assetId },
|
|
834
855
|
body: { folderId }
|
|
835
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;
|
|
836
865
|
}
|
|
837
866
|
};
|
|
838
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 };
|
|
@@ -135,6 +135,11 @@ const PUBLIC_ERROR_CODES = {
|
|
|
135
135
|
defaultMessage: "This API key belongs to a different project. Use a key created for the project that owns this resource.",
|
|
136
136
|
status: 403
|
|
137
137
|
}),
|
|
138
|
+
API_KEY_NOT_ACCEPTED: new sendable_error.ErrorCode({
|
|
139
|
+
id: "auth/api-key-not-accepted",
|
|
140
|
+
defaultMessage: "API keys are only accepted by the public API at /v1.",
|
|
141
|
+
status: 403
|
|
142
|
+
}),
|
|
138
143
|
FILE_TOO_LARGE: new sendable_error.ErrorCode({
|
|
139
144
|
id: "upload/file-too-large",
|
|
140
145
|
defaultMessage: "File size exceeds limit. Maximum size for images is 10MB, for other files is 5GB.",
|
|
@@ -220,6 +225,16 @@ const PUBLIC_ERROR_CODES = {
|
|
|
220
225
|
defaultMessage: "Asset access is restricted by a safety hold.",
|
|
221
226
|
status: 423
|
|
222
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
|
+
}),
|
|
223
238
|
SUPPORT_TICKET_NOT_FOUND: new sendable_error.ErrorCode({
|
|
224
239
|
id: "support/ticket-not-found",
|
|
225
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
|
|
@@ -64,6 +64,13 @@ const permits = (grants, action, folderId, folders) => grants.some((grant) => {
|
|
|
64
64
|
}
|
|
65
65
|
return false;
|
|
66
66
|
});
|
|
67
|
+
const SYSTEM_PERMISSION_SCHEMA = zod.enum([
|
|
68
|
+
"system:admin",
|
|
69
|
+
"system:assets:read-all",
|
|
70
|
+
"system:uploads:unlimited"
|
|
71
|
+
]);
|
|
72
|
+
zod.array(SYSTEM_PERMISSION_SCHEMA);
|
|
73
|
+
zod.enum(["active", "banned"]);
|
|
67
74
|
//#endregion
|
|
68
75
|
//#region src/testing/MockApiKey.ts
|
|
69
76
|
const MOCK_API_KEY_PREFIX = "sk_test_";
|
|
@@ -466,6 +473,21 @@ list: function() {
|
|
|
466
473
|
return function move(_x10) {
|
|
467
474
|
return _ref15.apply(this, arguments);
|
|
468
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
|
+
};
|
|
469
491
|
}()
|
|
470
492
|
};
|
|
471
493
|
}
|
|
@@ -473,26 +495,26 @@ list: function() {
|
|
|
473
495
|
var _this5 = this;
|
|
474
496
|
return {
|
|
475
497
|
list: function() {
|
|
476
|
-
var
|
|
498
|
+
var _ref17 = require_CalmLensUtils._asyncToGenerator(function* () {
|
|
477
499
|
return [..._this5.databaseStorage.listFolders ? yield _this5.databaseStorage.listFolders(_this5.options.projectId) : []].sort((a, b) => a.name.localeCompare(b.name));
|
|
478
500
|
});
|
|
479
501
|
return function list() {
|
|
480
|
-
return
|
|
502
|
+
return _ref17.apply(this, arguments);
|
|
481
503
|
};
|
|
482
504
|
}(),
|
|
483
505
|
retrieve: function() {
|
|
484
|
-
var
|
|
506
|
+
var _ref18 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId }) {
|
|
485
507
|
if (!folderId) throw new Error("Folder ID is required");
|
|
486
508
|
const folder = yield _this5.resolveFolder(folderId);
|
|
487
509
|
if (!folder) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
488
510
|
return folder;
|
|
489
511
|
});
|
|
490
|
-
return function retrieve(
|
|
491
|
-
return
|
|
512
|
+
return function retrieve(_x12) {
|
|
513
|
+
return _ref18.apply(this, arguments);
|
|
492
514
|
};
|
|
493
515
|
}(),
|
|
494
516
|
create: function() {
|
|
495
|
-
var
|
|
517
|
+
var _ref19 = require_CalmLensUtils._asyncToGenerator(function* (options) {
|
|
496
518
|
var _options$parentId, _options$parentId2;
|
|
497
519
|
if (!options.name) throw new Error("Folder name is required");
|
|
498
520
|
if (options.parentId) {
|
|
@@ -510,13 +532,13 @@ list: function() {
|
|
|
510
532
|
if (_this5.databaseStorage.createFolder) return yield _this5.databaseStorage.createFolder(folder);
|
|
511
533
|
return folder;
|
|
512
534
|
});
|
|
513
|
-
return function create(
|
|
514
|
-
return
|
|
535
|
+
return function create(_x13) {
|
|
536
|
+
return _ref19.apply(this, arguments);
|
|
515
537
|
};
|
|
516
538
|
}(),
|
|
517
539
|
update: function() {
|
|
518
|
-
var
|
|
519
|
-
let { folderId } =
|
|
540
|
+
var _ref21 = require_CalmLensUtils._asyncToGenerator(function* (_ref20) {
|
|
541
|
+
let { folderId } = _ref20, body = require_CalmLensUtils._objectWithoutProperties(_ref20, _excluded5);
|
|
520
542
|
if (!folderId) throw new Error("Folder ID is required");
|
|
521
543
|
const folder = yield _this5.resolveFolder(folderId);
|
|
522
544
|
if (!folder) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -528,12 +550,12 @@ list: function() {
|
|
|
528
550
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
529
551
|
return updated;
|
|
530
552
|
});
|
|
531
|
-
return function update(
|
|
532
|
-
return
|
|
553
|
+
return function update(_x14) {
|
|
554
|
+
return _ref21.apply(this, arguments);
|
|
533
555
|
};
|
|
534
556
|
}(),
|
|
535
557
|
delete: function() {
|
|
536
|
-
var
|
|
558
|
+
var _ref22 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId }) {
|
|
537
559
|
if (!folderId) throw new Error("Folder ID is required");
|
|
538
560
|
if (!(yield _this5.resolveFolder(folderId))) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
539
561
|
const hasAssets = (yield _this5.databaseStorage.listAssets(_this5.options.projectId)).some((asset) => asset.folderId === folderId);
|
|
@@ -544,12 +566,12 @@ list: function() {
|
|
|
544
566
|
} });
|
|
545
567
|
if (_this5.databaseStorage.deleteFolder) yield _this5.databaseStorage.deleteFolder(folderId);
|
|
546
568
|
});
|
|
547
|
-
return function _delete(
|
|
548
|
-
return
|
|
569
|
+
return function _delete(_x15) {
|
|
570
|
+
return _ref22.apply(this, arguments);
|
|
549
571
|
};
|
|
550
572
|
}(),
|
|
551
573
|
move: function() {
|
|
552
|
-
var
|
|
574
|
+
var _ref23 = require_CalmLensUtils._asyncToGenerator(function* ({ folderId, parentId }) {
|
|
553
575
|
if (!folderId) throw new Error("Folder ID is required");
|
|
554
576
|
const folder = yield _this5.resolveFolder(folderId);
|
|
555
577
|
if (!folder) throw require_CalmLensUtils.calmLensError(require_CalmLensUtils.PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -573,8 +595,8 @@ list: function() {
|
|
|
573
595
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
574
596
|
return updated;
|
|
575
597
|
});
|
|
576
|
-
return function move(
|
|
577
|
-
return
|
|
598
|
+
return function move(_x16) {
|
|
599
|
+
return _ref23.apply(this, arguments);
|
|
578
600
|
};
|
|
579
601
|
}()
|
|
580
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 };
|
|
@@ -135,6 +135,11 @@ const PUBLIC_ERROR_CODES = {
|
|
|
135
135
|
defaultMessage: "This API key belongs to a different project. Use a key created for the project that owns this resource.",
|
|
136
136
|
status: 403
|
|
137
137
|
}),
|
|
138
|
+
API_KEY_NOT_ACCEPTED: new ErrorCode({
|
|
139
|
+
id: "auth/api-key-not-accepted",
|
|
140
|
+
defaultMessage: "API keys are only accepted by the public API at /v1.",
|
|
141
|
+
status: 403
|
|
142
|
+
}),
|
|
138
143
|
FILE_TOO_LARGE: new ErrorCode({
|
|
139
144
|
id: "upload/file-too-large",
|
|
140
145
|
defaultMessage: "File size exceeds limit. Maximum size for images is 10MB, for other files is 5GB.",
|
|
@@ -220,6 +225,16 @@ const PUBLIC_ERROR_CODES = {
|
|
|
220
225
|
defaultMessage: "Asset access is restricted by a safety hold.",
|
|
221
226
|
status: 423
|
|
222
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
|
+
}),
|
|
223
238
|
SUPPORT_TICKET_NOT_FOUND: new ErrorCode({
|
|
224
239
|
id: "support/ticket-not-found",
|
|
225
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([
|
|
@@ -40,6 +40,13 @@ const permits = (grants, action, folderId, folders) => grants.some((grant) => {
|
|
|
40
40
|
}
|
|
41
41
|
return false;
|
|
42
42
|
});
|
|
43
|
+
const SYSTEM_PERMISSION_SCHEMA = zod.enum([
|
|
44
|
+
"system:admin",
|
|
45
|
+
"system:assets:read-all",
|
|
46
|
+
"system:uploads:unlimited"
|
|
47
|
+
]);
|
|
48
|
+
zod.array(SYSTEM_PERMISSION_SCHEMA);
|
|
49
|
+
zod.enum(["active", "banned"]);
|
|
43
50
|
//#endregion
|
|
44
51
|
//#region src/testing/MockApiKey.ts
|
|
45
52
|
const MOCK_API_KEY_PREFIX = "sk_test_";
|
|
@@ -442,6 +449,21 @@ list: function() {
|
|
|
442
449
|
return function move(_x10) {
|
|
443
450
|
return _ref15.apply(this, arguments);
|
|
444
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
|
+
};
|
|
445
467
|
}()
|
|
446
468
|
};
|
|
447
469
|
}
|
|
@@ -449,26 +471,26 @@ list: function() {
|
|
|
449
471
|
var _this5 = this;
|
|
450
472
|
return {
|
|
451
473
|
list: function() {
|
|
452
|
-
var
|
|
474
|
+
var _ref17 = _asyncToGenerator(function* () {
|
|
453
475
|
return [..._this5.databaseStorage.listFolders ? yield _this5.databaseStorage.listFolders(_this5.options.projectId) : []].sort((a, b) => a.name.localeCompare(b.name));
|
|
454
476
|
});
|
|
455
477
|
return function list() {
|
|
456
|
-
return
|
|
478
|
+
return _ref17.apply(this, arguments);
|
|
457
479
|
};
|
|
458
480
|
}(),
|
|
459
481
|
retrieve: function() {
|
|
460
|
-
var
|
|
482
|
+
var _ref18 = _asyncToGenerator(function* ({ folderId }) {
|
|
461
483
|
if (!folderId) throw new Error("Folder ID is required");
|
|
462
484
|
const folder = yield _this5.resolveFolder(folderId);
|
|
463
485
|
if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
464
486
|
return folder;
|
|
465
487
|
});
|
|
466
|
-
return function retrieve(
|
|
467
|
-
return
|
|
488
|
+
return function retrieve(_x12) {
|
|
489
|
+
return _ref18.apply(this, arguments);
|
|
468
490
|
};
|
|
469
491
|
}(),
|
|
470
492
|
create: function() {
|
|
471
|
-
var
|
|
493
|
+
var _ref19 = _asyncToGenerator(function* (options) {
|
|
472
494
|
var _options$parentId, _options$parentId2;
|
|
473
495
|
if (!options.name) throw new Error("Folder name is required");
|
|
474
496
|
if (options.parentId) {
|
|
@@ -486,13 +508,13 @@ list: function() {
|
|
|
486
508
|
if (_this5.databaseStorage.createFolder) return yield _this5.databaseStorage.createFolder(folder);
|
|
487
509
|
return folder;
|
|
488
510
|
});
|
|
489
|
-
return function create(
|
|
490
|
-
return
|
|
511
|
+
return function create(_x13) {
|
|
512
|
+
return _ref19.apply(this, arguments);
|
|
491
513
|
};
|
|
492
514
|
}(),
|
|
493
515
|
update: function() {
|
|
494
|
-
var
|
|
495
|
-
let { folderId } =
|
|
516
|
+
var _ref21 = _asyncToGenerator(function* (_ref20) {
|
|
517
|
+
let { folderId } = _ref20, body = _objectWithoutProperties(_ref20, _excluded5);
|
|
496
518
|
if (!folderId) throw new Error("Folder ID is required");
|
|
497
519
|
const folder = yield _this5.resolveFolder(folderId);
|
|
498
520
|
if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -504,12 +526,12 @@ list: function() {
|
|
|
504
526
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
505
527
|
return updated;
|
|
506
528
|
});
|
|
507
|
-
return function update(
|
|
508
|
-
return
|
|
529
|
+
return function update(_x14) {
|
|
530
|
+
return _ref21.apply(this, arguments);
|
|
509
531
|
};
|
|
510
532
|
}(),
|
|
511
533
|
delete: function() {
|
|
512
|
-
var
|
|
534
|
+
var _ref22 = _asyncToGenerator(function* ({ folderId }) {
|
|
513
535
|
if (!folderId) throw new Error("Folder ID is required");
|
|
514
536
|
if (!(yield _this5.resolveFolder(folderId))) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
515
537
|
const hasAssets = (yield _this5.databaseStorage.listAssets(_this5.options.projectId)).some((asset) => asset.folderId === folderId);
|
|
@@ -520,12 +542,12 @@ list: function() {
|
|
|
520
542
|
} });
|
|
521
543
|
if (_this5.databaseStorage.deleteFolder) yield _this5.databaseStorage.deleteFolder(folderId);
|
|
522
544
|
});
|
|
523
|
-
return function _delete(
|
|
524
|
-
return
|
|
545
|
+
return function _delete(_x15) {
|
|
546
|
+
return _ref22.apply(this, arguments);
|
|
525
547
|
};
|
|
526
548
|
}(),
|
|
527
549
|
move: function() {
|
|
528
|
-
var
|
|
550
|
+
var _ref23 = _asyncToGenerator(function* ({ folderId, parentId }) {
|
|
529
551
|
if (!folderId) throw new Error("Folder ID is required");
|
|
530
552
|
const folder = yield _this5.resolveFolder(folderId);
|
|
531
553
|
if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
|
|
@@ -549,8 +571,8 @@ list: function() {
|
|
|
549
571
|
if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
|
|
550
572
|
return updated;
|
|
551
573
|
});
|
|
552
|
-
return function move(
|
|
553
|
-
return
|
|
574
|
+
return function move(_x16) {
|
|
575
|
+
return _ref23.apply(this, arguments);
|
|
554
576
|
};
|
|
555
577
|
}()
|
|
556
578
|
};
|