calmlens 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AssetBinaryPayloadInput, D as GetEventsResponse, E as GetAssetsPageResponse, M as Folder, N as Asset, O as PostAssetSignedUrlResponse, P as AssetStatus, S as UploadAssetPartOptions, T as GetAssetResponse, a as CreateFolderOptions, c as EnsureLensesOptions, d as ListAssetsOptions, f as ListEventsOptions, h as MoveFolderOptions, i as CreateAssetSignedUrlOptions, j as Lens, 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, w as GetAssetChildrenResponse, x as UpdateFolderOptions, y as SubmitAssetOptions } from "./CalmLensTypes-Bnq4u8HJ.js";
1
+ import { A as GetEventsResponse, D as GetAssetChildrenResponse, F as Folder, N as AssetBinaryPayloadInput, O as GetAssetResponse, P as Lens, S as SubmitAssetOptions, T as UploadAssetPartOptions, U as Asset, W as AssetStatus, a as CreateAssetSignedUrlOptions, b as RetrieveAssetOptions, c as EnsureLensOptions, d as ListAssetChildrenOptions, f as ListAssetsOptions, g as MoveFolderOptions, h as MoveAssetOptions, i as CdnServeOptions, j as PostAssetSignedUrlResponse, k as GetAssetsPageResponse, l as EnsureLensesOptions, m as ModerateTextOptions, n as CalmLensClientOptions, o as CreateFolderOptions, p as ListEventsOptions, r as CdnAssetUrlOptions, u as FolderIdOptions, w as UpdateFolderOptions, x as RetryAssetOptions } from "./CalmLensTypes-DG_kHVqY.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/Permissions.d.ts
4
4
  declare const GRANT_SCHEMA: zod.ZodObject<{
@@ -124,10 +124,11 @@ export declare class MockCalmLensClient {
124
124
  retrieve: ({ assetId }: RetrieveAssetOptions) => Promise<GetAssetResponse>;
125
125
  listChildren: ({ assetId, ...options }: ListAssetChildrenOptions) => Promise<GetAssetChildrenResponse>;
126
126
  create: (options: SubmitAssetOptions) => Promise<Asset>;
127
- analyze: (options: SubmitAssetOptions) => Promise<Asset>;
127
+ moderate: (options: SubmitAssetOptions) => Promise<Asset>;
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--N_91gHC.js";
1
+ import { _ as validateAssetPayload, a as calmLensError, d as PUBLIC_ERROR_CODES, f as stringifyJsonCanonical, h as getAssetPayloadByteLength, l as getRejectedUploadMimeTypeError, m as assetToData, n as _objectWithoutProperties, p as assetDataToUint8Array, t as toTextAssetOptions, u as isRejectedUploadMimeType, v as _asyncToGenerator, y as _objectSpread2 } from "./CalmLensUtils-BQEgxGWk.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/Permissions.ts
4
4
  const ACTION_SCHEMA = zod.enum([
@@ -330,7 +330,7 @@ list: function() {
330
330
  var _this3 = this;
331
331
  return { moderate: function() {
332
332
  var _ref5 = _asyncToGenerator(function* (options) {
333
- return _this3.assets.analyze(toTextAssetOptions(options));
333
+ return _this3.assets.moderate(toTextAssetOptions(options));
334
334
  });
335
335
  return function moderate(_x2) {
336
336
  return _ref5.apply(this, arguments);
@@ -381,11 +381,12 @@ list: function() {
381
381
  return _ref10.apply(this, arguments);
382
382
  };
383
383
  }(),
384
- analyze: function() {
384
+ moderate: function() {
385
385
  var _ref11 = _asyncToGenerator(function* (options) {
386
+ if ("content" in options && "plainText" in options.content && (typeof options.content.plainText !== "string" || !options.content.plainText.trim())) throw calmLensError(PUBLIC_ERROR_CODES.INVALID_UPLOAD_PAYLOAD, { message: "Text to moderate must be a non-empty string" });
386
387
  return _this4.createAsset(options, _this4.analyzedStatus);
387
388
  });
388
- return function analyze(_x7) {
389
+ return function moderate(_x7) {
389
390
  return _ref11.apply(this, arguments);
390
391
  };
391
392
  }(),
@@ -449,6 +450,21 @@ list: function() {
449
450
  return function move(_x10) {
450
451
  return _ref15.apply(this, arguments);
451
452
  };
453
+ }(),
454
+ retry: function() {
455
+ var _ref16 = _asyncToGenerator(function* ({ assetId }) {
456
+ if (!assetId) throw new Error("Asset ID is required");
457
+ const asset = yield _this4.databaseStorage.getAsset(assetId);
458
+ if (!asset || asset.projectId !== _this4.options.projectId) throw calmLensError(PUBLIC_ERROR_CODES.ASSET_NOT_FOUND);
459
+ if (asset.status !== "error") throw calmLensError(PUBLIC_ERROR_CODES.ASSET_NOT_RETRYABLE);
460
+ return _this4.databaseStorage.updateAsset(_objectSpread2(_objectSpread2({}, asset), {}, {
461
+ status: "pending",
462
+ updatedAt: _this4.now()
463
+ }));
464
+ });
465
+ return function retry(_x11) {
466
+ return _ref16.apply(this, arguments);
467
+ };
452
468
  }()
453
469
  };
454
470
  }
@@ -456,26 +472,26 @@ list: function() {
456
472
  var _this5 = this;
457
473
  return {
458
474
  list: function() {
459
- var _ref16 = _asyncToGenerator(function* () {
475
+ var _ref17 = _asyncToGenerator(function* () {
460
476
  return [..._this5.databaseStorage.listFolders ? yield _this5.databaseStorage.listFolders(_this5.options.projectId) : []].sort((a, b) => a.name.localeCompare(b.name));
461
477
  });
462
478
  return function list() {
463
- return _ref16.apply(this, arguments);
479
+ return _ref17.apply(this, arguments);
464
480
  };
465
481
  }(),
466
482
  retrieve: function() {
467
- var _ref17 = _asyncToGenerator(function* ({ folderId }) {
483
+ var _ref18 = _asyncToGenerator(function* ({ folderId }) {
468
484
  if (!folderId) throw new Error("Folder ID is required");
469
485
  const folder = yield _this5.resolveFolder(folderId);
470
486
  if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
471
487
  return folder;
472
488
  });
473
- return function retrieve(_x11) {
474
- return _ref17.apply(this, arguments);
489
+ return function retrieve(_x12) {
490
+ return _ref18.apply(this, arguments);
475
491
  };
476
492
  }(),
477
493
  create: function() {
478
- var _ref18 = _asyncToGenerator(function* (options) {
494
+ var _ref19 = _asyncToGenerator(function* (options) {
479
495
  var _options$parentId, _options$parentId2;
480
496
  if (!options.name) throw new Error("Folder name is required");
481
497
  if (options.parentId) {
@@ -493,13 +509,13 @@ list: function() {
493
509
  if (_this5.databaseStorage.createFolder) return yield _this5.databaseStorage.createFolder(folder);
494
510
  return folder;
495
511
  });
496
- return function create(_x12) {
497
- return _ref18.apply(this, arguments);
512
+ return function create(_x13) {
513
+ return _ref19.apply(this, arguments);
498
514
  };
499
515
  }(),
500
516
  update: function() {
501
- var _ref20 = _asyncToGenerator(function* (_ref19) {
502
- let { folderId } = _ref19, body = _objectWithoutProperties(_ref19, _excluded5);
517
+ var _ref21 = _asyncToGenerator(function* (_ref20) {
518
+ let { folderId } = _ref20, body = _objectWithoutProperties(_ref20, _excluded5);
503
519
  if (!folderId) throw new Error("Folder ID is required");
504
520
  const folder = yield _this5.resolveFolder(folderId);
505
521
  if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
@@ -511,12 +527,12 @@ list: function() {
511
527
  if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
512
528
  return updated;
513
529
  });
514
- return function update(_x13) {
515
- return _ref20.apply(this, arguments);
530
+ return function update(_x14) {
531
+ return _ref21.apply(this, arguments);
516
532
  };
517
533
  }(),
518
534
  delete: function() {
519
- var _ref21 = _asyncToGenerator(function* ({ folderId }) {
535
+ var _ref22 = _asyncToGenerator(function* ({ folderId }) {
520
536
  if (!folderId) throw new Error("Folder ID is required");
521
537
  if (!(yield _this5.resolveFolder(folderId))) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
522
538
  const hasAssets = (yield _this5.databaseStorage.listAssets(_this5.options.projectId)).some((asset) => asset.folderId === folderId);
@@ -527,12 +543,12 @@ list: function() {
527
543
  } });
528
544
  if (_this5.databaseStorage.deleteFolder) yield _this5.databaseStorage.deleteFolder(folderId);
529
545
  });
530
- return function _delete(_x14) {
531
- return _ref21.apply(this, arguments);
546
+ return function _delete(_x15) {
547
+ return _ref22.apply(this, arguments);
532
548
  };
533
549
  }(),
534
550
  move: function() {
535
- var _ref22 = _asyncToGenerator(function* ({ folderId, parentId }) {
551
+ var _ref23 = _asyncToGenerator(function* ({ folderId, parentId }) {
536
552
  if (!folderId) throw new Error("Folder ID is required");
537
553
  const folder = yield _this5.resolveFolder(folderId);
538
554
  if (!folder) throw calmLensError(PUBLIC_ERROR_CODES.FOLDER_NOT_FOUND);
@@ -556,8 +572,8 @@ list: function() {
556
572
  if (_this5.databaseStorage.updateFolder) return yield _this5.databaseStorage.updateFolder(updated);
557
573
  return updated;
558
574
  });
559
- return function move(_x15) {
560
- return _ref22.apply(this, arguments);
575
+ return function move(_x16) {
576
+ return _ref23.apply(this, arguments);
561
577
  };
562
578
  }()
563
579
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "calmlens",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Censkh/CalmLens.git",
@@ -87,5 +87,5 @@
87
87
  }
88
88
  }
89
89
  },
90
- "description": "CalmLens SDK Also published as @calmlens/js-sdk."
90
+ "description": "CalmLens SDK Also published as @calmlens/sdk."
91
91
  }