@calmlens/sdk 0.6.0 → 0.8.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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as getRawBase64, a as SDK_ERRORS, b as _objectSpread2, c as MAX_IMAGE_UPLOAD_BYTES, d as isRejectedUploadMimeType, f as PUBLIC_ERROR_CODES, g as getAssetPayloadByteLength, h as assetToData, i as CalmLensError, l as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, n as validateClientOptions, o as calmLensError, p as stringifyJsonCanonical, r as _objectWithoutProperties, s as DOMAIN, t as toTextAssetOptions, u as getRejectedUploadMimeTypeError, v as validateAssetPayload, y as _asyncToGenerator } from "./CalmLensUtils-UthMaLx_.js";
1
+ import { _ as getRawBase64, a as SDK_ERRORS, b as _objectSpread2, c as MAX_IMAGE_UPLOAD_BYTES, d as isRejectedUploadMimeType, f as PUBLIC_ERROR_CODES, g as getAssetPayloadByteLength, h as assetToData, i as CalmLensError, l as MIN_MULTIPART_IMAGE_UPLOAD_BYTES, n as validateClientOptions, o as calmLensError, p as stringifyJsonCanonical, r as _objectWithoutProperties, s as DOMAIN, t as toTextAssetOptions, u as getRejectedUploadMimeTypeError, v as validateAssetPayload, y as _asyncToGenerator } from "./CalmLensUtils-BZsX8yeO.js";
2
2
  import * as zod from "zod";
3
3
  import "zod/v4";
4
4
  import { Api, FetchRequestBackend, RequestCoalescingMiddleware, RequestEvent, getErrorResponse, isRequestError } from "api-def";
@@ -103,15 +103,17 @@ createMetaType({ id: "docPropertyInfo" });
103
103
  const SIZE_LIMITS = {
104
104
  small: 64,
105
105
  medium: 200,
106
- large: 1500
106
+ large: 1500,
107
+ xlarge: 1e4,
108
+ token: 1e4
107
109
  };
108
110
  const saneStringField = (options) => {
109
111
  return zod.string().transform((value) => value.trim()).refine((value) => {
110
112
  if ((options === null || options === void 0 ? void 0 : options.minWidth) && value.length < options.minWidth) return false;
111
113
  return true;
112
114
  }, "Not long enough").refine((value) => {
113
- var _options$type;
114
- const sizeLimit = SIZE_LIMITS[(_options$type = options === null || options === void 0 ? void 0 : options.type) !== null && _options$type !== void 0 ? _options$type : "medium"];
115
+ var _options$maxLength, _options$type;
116
+ const sizeLimit = (_options$maxLength = options === null || options === void 0 ? void 0 : options.maxLength) !== null && _options$maxLength !== void 0 ? _options$maxLength : SIZE_LIMITS[(_options$type = options === null || options === void 0 ? void 0 : options.type) !== null && _options$type !== void 0 ? _options$type : "medium"];
115
117
  return typeof value === "string" && value.length < sizeLimit;
116
118
  }, "Too long");
117
119
  };
@@ -596,6 +598,11 @@ const createEndpoints = (api) => {
596
598
  method: "get",
597
599
  path: "/projects/:projectId/assets/page"
598
600
  });
601
+ const searchAssets = api.endpoint().paramsOf().queryOf().responseOf().build({
602
+ id: "searchAssets",
603
+ method: "get",
604
+ path: "/projects/:projectId/assets/search"
605
+ });
599
606
  const getAsset = api.endpoint().paramsOf().responseOf().build({
600
607
  id: "getAsset",
601
608
  method: "get",
@@ -649,6 +656,7 @@ const createEndpoints = (api) => {
649
656
  deleteFolder,
650
657
  moveFolder,
651
658
  getAssetsPage,
659
+ searchAssets,
652
660
  getAsset,
653
661
  getAssetChildren,
654
662
  patchAsset,
@@ -904,21 +912,32 @@ var CalmLensClient = class CalmLensClient {
904
912
  get assets() {
905
913
  var _this5 = this;
906
914
  return {
915
+ search: function() {
916
+ var _ref8 = _asyncToGenerator(function* (options) {
917
+ return (yield _this5.endpoints.searchAssets.submit({
918
+ params: { projectId: _this5.options.projectId },
919
+ query: options
920
+ })).data;
921
+ });
922
+ return function search(_x6) {
923
+ return _ref8.apply(this, arguments);
924
+ };
925
+ }(),
907
926
  /**
908
927
  * List all assets for a project
909
928
  * @param options - Pagination and filtering options
910
929
  * @returns Promise with paginated assets
911
930
  */
912
931
  list: function() {
913
- var _ref8 = _asyncToGenerator(function* (options) {
932
+ var _ref9 = _asyncToGenerator(function* (options) {
914
933
  var _options$pageIndex;
915
934
  return (yield _this5.endpoints.getAssetsPage.submit({
916
935
  params: { projectId: _this5.options.projectId },
917
936
  query: _objectSpread2(_objectSpread2({}, options), {}, { pageIndex: (_options$pageIndex = options.pageIndex) !== null && _options$pageIndex !== void 0 ? _options$pageIndex : 0 })
918
937
  })).data;
919
938
  });
920
- return function list(_x6) {
921
- return _ref8.apply(this, arguments);
939
+ return function list(_x7) {
940
+ return _ref9.apply(this, arguments);
922
941
  };
923
942
  }(),
924
943
  /**
@@ -927,25 +946,25 @@ var CalmLensClient = class CalmLensClient {
927
946
  * @returns Promise with asset data
928
947
  */
929
948
  retrieve: function() {
930
- var _ref9 = _asyncToGenerator(function* ({ assetId }) {
949
+ var _ref10 = _asyncToGenerator(function* ({ assetId }) {
931
950
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
932
951
  return (yield _this5.endpoints.getAsset.submit({ params: { assetId } })).data;
933
952
  });
934
- return function retrieve(_x7) {
935
- return _ref9.apply(this, arguments);
953
+ return function retrieve(_x8) {
954
+ return _ref10.apply(this, arguments);
936
955
  };
937
956
  }(),
938
957
  update: function() {
939
- var _ref11 = _asyncToGenerator(function* (_ref10) {
940
- let { assetId } = _ref10, body = _objectWithoutProperties(_ref10, _excluded5);
958
+ var _ref12 = _asyncToGenerator(function* (_ref11) {
959
+ let { assetId } = _ref11, body = _objectWithoutProperties(_ref11, _excluded5);
941
960
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
942
961
  return (yield _this5.endpoints.patchAsset.submit({
943
962
  params: { assetId },
944
963
  body
945
964
  })).data;
946
965
  });
947
- return function update(_x8) {
948
- return _ref11.apply(this, arguments);
966
+ return function update(_x9) {
967
+ return _ref12.apply(this, arguments);
949
968
  };
950
969
  }(),
951
970
  /**
@@ -955,17 +974,17 @@ var CalmLensClient = class CalmLensClient {
955
974
  * @returns Promise with paginated child assets
956
975
  */
957
976
  listChildren: function() {
958
- var _ref13 = _asyncToGenerator(function* (_ref12) {
977
+ var _ref14 = _asyncToGenerator(function* (_ref13) {
959
978
  var _options$pageIndex2;
960
- let { assetId } = _ref12, options = _objectWithoutProperties(_ref12, _excluded6);
979
+ let { assetId } = _ref13, options = _objectWithoutProperties(_ref13, _excluded6);
961
980
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
962
981
  return (yield _this5.endpoints.getAssetChildren.submit({
963
982
  params: { assetId },
964
983
  query: _objectSpread2(_objectSpread2({}, options), {}, { pageIndex: (_options$pageIndex2 = options.pageIndex) !== null && _options$pageIndex2 !== void 0 ? _options$pageIndex2 : 0 })
965
984
  })).data;
966
985
  });
967
- return function listChildren(_x9) {
968
- return _ref13.apply(this, arguments);
986
+ return function listChildren(_x10) {
987
+ return _ref14.apply(this, arguments);
969
988
  };
970
989
  }(),
971
990
  /**
@@ -975,7 +994,7 @@ var CalmLensClient = class CalmLensClient {
975
994
  * @returns Promise with created asset
976
995
  */
977
996
  create: function() {
978
- var _ref14 = _asyncToGenerator(function* (options) {
997
+ var _ref15 = _asyncToGenerator(function* (options) {
979
998
  const body = prepareSubmitAssetOptions(options);
980
999
  if ("content" in body || "part" in body) return yield _this5.submitRawAssetUpload(body, true);
981
1000
  return (yield _this5.endpoints.postUploadAsset.submit({
@@ -984,8 +1003,8 @@ var CalmLensClient = class CalmLensClient {
984
1003
  query: { queue: true }
985
1004
  })).data;
986
1005
  });
987
- return function create(_x10) {
988
- return _ref14.apply(this, arguments);
1006
+ return function create(_x11) {
1007
+ return _ref15.apply(this, arguments);
989
1008
  };
990
1009
  }(),
991
1010
  /**
@@ -996,7 +1015,7 @@ var CalmLensClient = class CalmLensClient {
996
1015
  * @returns Promise with created and analyzed asset
997
1016
  */
998
1017
  moderate: function() {
999
- var _ref15 = _asyncToGenerator(function* (options) {
1018
+ var _ref16 = _asyncToGenerator(function* (options) {
1000
1019
  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" });
1001
1020
  const body = prepareSubmitAssetOptions(options);
1002
1021
  if ("content" in body || "part" in body) return yield _this5.submitRawAssetUpload(body, false);
@@ -1006,8 +1025,8 @@ var CalmLensClient = class CalmLensClient {
1006
1025
  query: { queue: false }
1007
1026
  })).data;
1008
1027
  });
1009
- return function moderate(_x11) {
1010
- return _ref15.apply(this, arguments);
1028
+ return function moderate(_x12) {
1029
+ return _ref16.apply(this, arguments);
1011
1030
  };
1012
1031
  }(),
1013
1032
  /**
@@ -1017,7 +1036,7 @@ var CalmLensClient = class CalmLensClient {
1017
1036
  * @returns Promise with asset data
1018
1037
  */
1019
1038
  uploadPart: function() {
1020
- var _ref16 = _asyncToGenerator(function* ({ assetId, part }) {
1039
+ var _ref17 = _asyncToGenerator(function* ({ assetId, part }) {
1021
1040
  var _part$sizeInBytes3, _this$multipartUpload;
1022
1041
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1023
1042
  if (!part) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Part options are required" });
@@ -1035,8 +1054,8 @@ var CalmLensClient = class CalmLensClient {
1035
1054
  }
1036
1055
  return yield _this5.submitRawAssetPart(assetId, part, (_this$multipartUpload = _this5.multipartUploadQueues.get(assetId)) !== null && _this$multipartUpload !== void 0 ? _this$multipartUpload : false);
1037
1056
  });
1038
- return function uploadPart(_x12) {
1039
- return _ref16.apply(this, arguments);
1057
+ return function uploadPart(_x13) {
1058
+ return _ref17.apply(this, arguments);
1040
1059
  };
1041
1060
  }(),
1042
1061
  /**
@@ -1045,9 +1064,9 @@ var CalmLensClient = class CalmLensClient {
1045
1064
  * auth cookies or API keys to the CDN on every media request.
1046
1065
  */
1047
1066
  createSignedUrl: function() {
1048
- var _ref18 = _asyncToGenerator(function* (_ref17) {
1067
+ var _ref19 = _asyncToGenerator(function* (_ref18) {
1049
1068
  var _options$resource2, _options$expiresInSec;
1050
- let { assetId } = _ref17, options = _objectWithoutProperties(_ref17, _excluded7);
1069
+ let { assetId } = _ref18, options = _objectWithoutProperties(_ref18, _excluded7);
1051
1070
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1052
1071
  if (options.lens && options.transform) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Specify either a lens or a transform, not both" });
1053
1072
  return (yield _this5.endpoints.postAssetSignedUrl.submit({
@@ -1060,20 +1079,20 @@ var CalmLensClient = class CalmLensClient {
1060
1079
  params: { assetId }
1061
1080
  })).data;
1062
1081
  });
1063
- return function createSignedUrl(_x13) {
1064
- return _ref18.apply(this, arguments);
1082
+ return function createSignedUrl(_x14) {
1083
+ return _ref19.apply(this, arguments);
1065
1084
  };
1066
1085
  }(),
1067
1086
  move: function() {
1068
- var _ref19 = _asyncToGenerator(function* ({ assetId, folderId }) {
1087
+ var _ref20 = _asyncToGenerator(function* ({ assetId, folderId }) {
1069
1088
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1070
1089
  return (yield _this5.endpoints.moveAsset.submit({
1071
1090
  params: { assetId },
1072
1091
  body: { folderId }
1073
1092
  })).data;
1074
1093
  });
1075
- return function move(_x14) {
1076
- return _ref19.apply(this, arguments);
1094
+ return function move(_x15) {
1095
+ return _ref20.apply(this, arguments);
1077
1096
  };
1078
1097
  }(),
1079
1098
  /**
@@ -1081,12 +1100,12 @@ var CalmLensClient = class CalmLensClient {
1081
1100
  * moderated like a new upload; its content must still be stored.
1082
1101
  */
1083
1102
  retry: function() {
1084
- var _ref20 = _asyncToGenerator(function* ({ assetId }) {
1103
+ var _ref21 = _asyncToGenerator(function* ({ assetId }) {
1085
1104
  if (!assetId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Asset ID is required" });
1086
1105
  return (yield _this5.endpoints.retryAsset.submit({ params: { assetId } })).data;
1087
1106
  });
1088
- return function retry(_x15) {
1089
- return _ref20.apply(this, arguments);
1107
+ return function retry(_x16) {
1108
+ return _ref21.apply(this, arguments);
1090
1109
  };
1091
1110
  }()
1092
1111
  };
@@ -1100,14 +1119,14 @@ var CalmLensClient = class CalmLensClient {
1100
1119
  * reshaped as `{ id, type, createdAt, projectId, data }`.
1101
1120
  */
1102
1121
  list: function() {
1103
- var _ref21 = _asyncToGenerator(function* (options = {}) {
1122
+ var _ref22 = _asyncToGenerator(function* (options = {}) {
1104
1123
  return (yield _this6.endpoints.getEvents.submit({
1105
1124
  params: { projectId: _this6.options.projectId },
1106
1125
  query: options
1107
1126
  })).data;
1108
1127
  });
1109
1128
  return function list() {
1110
- return _ref21.apply(this, arguments);
1129
+ return _ref22.apply(this, arguments);
1111
1130
  };
1112
1131
  }() };
1113
1132
  }
@@ -1115,65 +1134,65 @@ list: function() {
1115
1134
  var _this7 = this;
1116
1135
  return {
1117
1136
  list: function() {
1118
- var _ref22 = _asyncToGenerator(function* () {
1137
+ var _ref23 = _asyncToGenerator(function* () {
1119
1138
  return (yield _this7.endpoints.getFolders.submit({ params: { projectId: _this7.options.projectId } })).data.folders;
1120
1139
  });
1121
1140
  return function list() {
1122
- return _ref22.apply(this, arguments);
1141
+ return _ref23.apply(this, arguments);
1123
1142
  };
1124
1143
  }(),
1125
1144
  retrieve: function() {
1126
- var _ref23 = _asyncToGenerator(function* ({ folderId }) {
1145
+ var _ref24 = _asyncToGenerator(function* ({ folderId }) {
1127
1146
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1128
1147
  return (yield _this7.endpoints.getFolder.submit({ params: { folderId } })).data;
1129
1148
  });
1130
- return function retrieve(_x16) {
1131
- return _ref23.apply(this, arguments);
1149
+ return function retrieve(_x17) {
1150
+ return _ref24.apply(this, arguments);
1132
1151
  };
1133
1152
  }(),
1134
1153
  create: function() {
1135
- var _ref24 = _asyncToGenerator(function* (options) {
1154
+ var _ref25 = _asyncToGenerator(function* (options) {
1136
1155
  return (yield _this7.endpoints.postFolder.submit({
1137
1156
  params: { projectId: _this7.options.projectId },
1138
1157
  body: options
1139
1158
  })).data;
1140
1159
  });
1141
- return function create(_x17) {
1142
- return _ref24.apply(this, arguments);
1160
+ return function create(_x18) {
1161
+ return _ref25.apply(this, arguments);
1143
1162
  };
1144
1163
  }(),
1145
1164
  update: function() {
1146
- var _ref26 = _asyncToGenerator(function* (_ref25) {
1147
- let { folderId } = _ref25, body = _objectWithoutProperties(_ref25, _excluded8);
1165
+ var _ref27 = _asyncToGenerator(function* (_ref26) {
1166
+ let { folderId } = _ref26, body = _objectWithoutProperties(_ref26, _excluded8);
1148
1167
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1149
1168
  return (yield _this7.endpoints.patchFolder.submit({
1150
1169
  params: { folderId },
1151
1170
  body
1152
1171
  })).data;
1153
1172
  });
1154
- return function update(_x18) {
1155
- return _ref26.apply(this, arguments);
1173
+ return function update(_x19) {
1174
+ return _ref27.apply(this, arguments);
1156
1175
  };
1157
1176
  }(),
1158
1177
  delete: function() {
1159
- var _ref27 = _asyncToGenerator(function* ({ folderId }) {
1178
+ var _ref28 = _asyncToGenerator(function* ({ folderId }) {
1160
1179
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1161
1180
  yield _this7.endpoints.deleteFolder.submit({ params: { folderId } });
1162
1181
  });
1163
- return function _delete(_x19) {
1164
- return _ref27.apply(this, arguments);
1182
+ return function _delete(_x20) {
1183
+ return _ref28.apply(this, arguments);
1165
1184
  };
1166
1185
  }(),
1167
1186
  move: function() {
1168
- var _ref28 = _asyncToGenerator(function* ({ folderId, parentId }) {
1187
+ var _ref29 = _asyncToGenerator(function* ({ folderId, parentId }) {
1169
1188
  if (!folderId) throw calmLensError({ id: "upload/invalid-payload" }, { message: "Folder ID is required" });
1170
1189
  return (yield _this7.endpoints.moveFolder.submit({
1171
1190
  params: { folderId },
1172
1191
  body: { parentId }
1173
1192
  })).data;
1174
1193
  });
1175
- return function move(_x20) {
1176
- return _ref28.apply(this, arguments);
1194
+ return function move(_x21) {
1195
+ return _ref29.apply(this, arguments);
1177
1196
  };
1178
1197
  }()
1179
1198
  };
package/esm/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as GetEventsResponse, C as UpdateAssetOptions, D as GetAssetChildrenResponse, F as Folder, G as AssetStatus, N as AssetBinaryPayloadInput, O as GetAssetResponse, P as Lens, S as SubmitAssetOptions, T as UploadAssetPartOptions, W as Asset, 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-BpmT60j-.js";
1
+ import { A as GetEventsResponse, C as UpdateAssetOptions, D as GetAssetChildrenResponse, F as Folder, G as AssetStatus, N as AssetBinaryPayloadInput, O as GetAssetResponse, P as Lens, S as SubmitAssetOptions, T as UploadAssetPartOptions, W as Asset, 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-B7hr0SBv.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/Permissions.d.ts
4
4
  declare const GRANT_SCHEMA: zod.ZodObject<{
package/esm/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as _objectSpread2, d as isRejectedUploadMimeType, f as PUBLIC_ERROR_CODES, g as getAssetPayloadByteLength, h as assetToData, m as assetDataToUint8Array, n as validateClientOptions, o as calmLensError, p as stringifyJsonCanonical, r as _objectWithoutProperties, t as toTextAssetOptions, u as getRejectedUploadMimeTypeError, v as validateAssetPayload, y as _asyncToGenerator } from "./CalmLensUtils-UthMaLx_.js";
1
+ import { b as _objectSpread2, d as isRejectedUploadMimeType, f as PUBLIC_ERROR_CODES, g as getAssetPayloadByteLength, h as assetToData, m as assetDataToUint8Array, n as validateClientOptions, o as calmLensError, p as stringifyJsonCanonical, r as _objectWithoutProperties, t as toTextAssetOptions, u as getRejectedUploadMimeTypeError, v as validateAssetPayload, y as _asyncToGenerator } from "./CalmLensUtils-BZsX8yeO.js";
2
2
  import * as zod from "zod";
3
3
  //#region ../shared/src/Permissions.ts
4
4
  const ACTION_SCHEMA = zod.enum([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calmlens/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Censkh/CalmLens.git",
@@ -49,13 +49,13 @@
49
49
  "cjs/"
50
50
  ],
51
51
  "devDependencies": {
52
- "@biomejs/biome": "^2.5.13",
52
+ "@biomejs/biome": "^2.5.15",
53
53
  "@oxc-project/runtime": "0.148.0",
54
54
  "@types/bun": "^1.3.13",
55
55
  "@types/node": "22.20.2",
56
56
  "rimraf": "6.1.3",
57
- "rolldown": "1.2.7",
58
- "rolldown-plugin-dts": "0.28.6",
57
+ "rolldown": "1.2.13",
58
+ "rolldown-plugin-dts": "0.28.7",
59
59
  "typescript": "catalog:"
60
60
  },
61
61
  "dependencies": {