@calmlens/js-sdk 0.0.2 → 0.0.3

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.
@@ -49,10 +49,19 @@ export default class CalmLensClient {
49
49
  */
50
50
  listChildren: (assetId: string, options: GetAssetChildrenQuery) => Promise<GetAssetChildrenResponse>;
51
51
  /**
52
- * Submit a new asset for processing
52
+ * Submit a new asset for processing (queued asynchronously)
53
+ * The asset will be queued for classification and returned immediately.
53
54
  * @param options - Asset submission options
54
55
  * @returns Promise with created asset
55
56
  */
56
57
  create: (options: SubmitAssetOptions) => Promise<Asset>;
58
+ /**
59
+ * Submit a new asset and analyze it synchronously
60
+ * The asset will be classified immediately before the response is returned.
61
+ * This may take longer but ensures the asset is fully processed.
62
+ * @param options - Asset submission options
63
+ * @returns Promise with created and analyzed asset
64
+ */
65
+ analyze: (options: SubmitAssetOptions) => Promise<Asset>;
57
66
  };
58
67
  }
@@ -91,6 +91,7 @@ var createEndpoints = function (api) {
91
91
  .endpoint()
92
92
  .bodyOf()
93
93
  .paramsOf()
94
+ .queryOf()
94
95
  .responseOf()
95
96
  .build({
96
97
  id: "postUploadAsset",
@@ -223,7 +224,8 @@ var CalmLensClient = /** @class */ (function () {
223
224
  });
224
225
  }); },
225
226
  /**
226
- * Submit a new asset for processing
227
+ * Submit a new asset for processing (queued asynchronously)
228
+ * The asset will be queued for classification and returned immediately.
227
229
  * @param options - Asset submission options
228
230
  * @returns Promise with created asset
229
231
  */
@@ -243,6 +245,42 @@ var CalmLensClient = /** @class */ (function () {
243
245
  params: {
244
246
  projectId: this.options.projectId,
245
247
  },
248
+ query: {
249
+ queue: true, // Queue for async processing
250
+ },
251
+ })];
252
+ case 1:
253
+ result = _a.sent();
254
+ return [2 /*return*/, result.data];
255
+ }
256
+ });
257
+ }); },
258
+ /**
259
+ * Submit a new asset and analyze it synchronously
260
+ * The asset will be classified immediately before the response is returned.
261
+ * This may take longer but ensures the asset is fully processed.
262
+ * @param options - Asset submission options
263
+ * @returns Promise with created and analyzed asset
264
+ */
265
+ analyze: function (options) { return __awaiter(_this, void 0, void 0, function () {
266
+ var result;
267
+ return __generator(this, function (_a) {
268
+ switch (_a.label) {
269
+ case 0:
270
+ if (!("file" in options) && !("url" in options)) {
271
+ throw new Error("Either file content or URL is required");
272
+ }
273
+ if (!options.name) {
274
+ throw new Error("Asset name is required");
275
+ }
276
+ return [4 /*yield*/, this.endpoints.postUploadAsset.submit({
277
+ body: options,
278
+ params: {
279
+ projectId: this.options.projectId,
280
+ },
281
+ query: {
282
+ queue: false, // Process synchronously
283
+ },
246
284
  })];
247
285
  case 1:
248
286
  result = _a.sent();
@@ -969,6 +969,9 @@ export declare const POST_ASSET_BODY_SCHEMA: zod.ZodIntersection<zod.ZodUnion<re
969
969
  private: "private";
970
970
  }>>>>;
971
971
  }, zod.z.core.$strip>>>;
972
+ export declare const POST_ASSET_QUERY_SCHEMA: zod.ZodObject<{
973
+ queue: zod.ZodDefault<zod.ZodBoolean>;
974
+ }, zod.z.core.$strip>;
972
975
  export declare const POST_ASSET_RESPONSE_SCHEMA: zod.ZodObject<{
973
976
  id: zod.ZodString;
974
977
  projectId: zod.ZodString;
@@ -1098,6 +1101,7 @@ export declare const POST_ASSET_RESPONSE_SCHEMA: zod.ZodObject<{
1098
1101
  }, zod.z.core.$strip>>>;
1099
1102
  }, zod.z.core.$strip>;
1100
1103
  export type PostAssetParams = zod.infer<typeof POST_ASSET_PARAMS_SCHEMA>;
1104
+ export type PostAssetQuery = zod.infer<typeof POST_ASSET_QUERY_SCHEMA>;
1101
1105
  export type PostAssetBody = zod.infer<typeof POST_ASSET_BODY_SCHEMA>;
1102
1106
  export type PostAssetResponse = Asset;
1103
1107
  export declare const POST_ASSET_REQUEST: {
@@ -1112,6 +1116,9 @@ export declare const POST_ASSET_REQUEST: {
1112
1116
  readonly params: zod.ZodObject<{
1113
1117
  projectId: zod.ZodString;
1114
1118
  }, zod.z.core.$strip>;
1119
+ readonly query: zod.ZodObject<{
1120
+ queue: zod.ZodDefault<zod.ZodBoolean>;
1121
+ }, zod.z.core.$strip>;
1115
1122
  readonly body: zod.ZodIntersection<zod.ZodUnion<readonly [zod.ZodObject<{
1116
1123
  file: zod.ZodString;
1117
1124
  fileType: zod.ZodString;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.DELETE_ASSET_REQUEST = exports.DELETE_ASSET_RESPONSE_SCHEMA = exports.DELETE_ASSET_PARAMS_SCHEMA = exports.PATCH_ASSET_REQUEST = exports.PATCH_ASSET_RESPONSE_SCHEMA = exports.PATCH_ASSET_BODY_SCHEMA = exports.PATCH_ASSET_PARAMS_SCHEMA = exports.POST_ASSET_REQUEST = exports.POST_ASSET_RESPONSE_SCHEMA = exports.POST_ASSET_BODY_SCHEMA = exports.POST_ASSET_PARAMS_SCHEMA = exports.GET_ASSET_CHILDREN_REQUEST = exports.GET_ASSET_CHILDREN_RESPONSE_SCHEMA = exports.GET_ASSET_CHILDREN_QUERY_SCHEMA = exports.GET_ASSET_CHILDREN_PARAMS_SCHEMA = exports.GET_ASSET_REQUEST = exports.GET_ASSET_RESPONSE_SCHEMA = exports.GET_ASSET_PARAMS_SCHEMA = exports.GET_ASSETS_PAGE_REQUEST = exports.GET_ASSETS_PAGE_RESPONSE_SCHEMA = exports.GET_ASSETS_PAGE_QUERY_SCHEMA = exports.GET_ASSETS_PAGE_PARAMS_SCHEMA = exports.PUBLIC_ERROR_CODES = void 0;
36
+ exports.DELETE_ASSET_REQUEST = exports.DELETE_ASSET_RESPONSE_SCHEMA = exports.DELETE_ASSET_PARAMS_SCHEMA = exports.PATCH_ASSET_REQUEST = exports.PATCH_ASSET_RESPONSE_SCHEMA = exports.PATCH_ASSET_BODY_SCHEMA = exports.PATCH_ASSET_PARAMS_SCHEMA = exports.POST_ASSET_REQUEST = exports.POST_ASSET_RESPONSE_SCHEMA = exports.POST_ASSET_QUERY_SCHEMA = exports.POST_ASSET_BODY_SCHEMA = exports.POST_ASSET_PARAMS_SCHEMA = exports.GET_ASSET_CHILDREN_REQUEST = exports.GET_ASSET_CHILDREN_RESPONSE_SCHEMA = exports.GET_ASSET_CHILDREN_QUERY_SCHEMA = exports.GET_ASSET_CHILDREN_PARAMS_SCHEMA = exports.GET_ASSET_REQUEST = exports.GET_ASSET_RESPONSE_SCHEMA = exports.GET_ASSET_PARAMS_SCHEMA = exports.GET_ASSETS_PAGE_REQUEST = exports.GET_ASSETS_PAGE_RESPONSE_SCHEMA = exports.GET_ASSETS_PAGE_QUERY_SCHEMA = exports.GET_ASSETS_PAGE_PARAMS_SCHEMA = exports.PUBLIC_ERROR_CODES = void 0;
37
37
  var sendable_error_1 = require("sendable-error");
38
38
  var zod = __importStar(require("zod/v4"));
39
39
  var zod_meta_1 = require("zod-meta");
@@ -228,6 +228,17 @@ var POST_ASSET_COMMON_BODY_SCHEMA = Asset_1.ASSET_SCHEMA.pick({
228
228
  exports.POST_ASSET_BODY_SCHEMA = zod
229
229
  .union([POST_ASSET_FILE_BODY_SCHEMA, POST_ASSET_URL_BODY_SCHEMA])
230
230
  .and(POST_ASSET_COMMON_BODY_SCHEMA);
231
+ exports.POST_ASSET_QUERY_SCHEMA = zod.object({
232
+ queue: zod
233
+ .boolean()
234
+ .default(false)
235
+ .meta((0, zod_meta_1.metaStore)([
236
+ (0, DocMetaTypes_1.docPropertyInfo)({
237
+ description: "If true, queue the asset for asynchronous classification. If false, classify synchronously.",
238
+ placeholder: "false",
239
+ }),
240
+ ])),
241
+ });
231
242
  exports.POST_ASSET_RESPONSE_SCHEMA = Asset_1.ASSET_SCHEMA;
232
243
  exports.POST_ASSET_REQUEST = {
233
244
  name: "Create Asset",
@@ -239,6 +250,7 @@ exports.POST_ASSET_REQUEST = {
239
250
  sdkPath: ["assets", "create"],
240
251
  schemas: {
241
252
  params: exports.POST_ASSET_PARAMS_SCHEMA,
253
+ query: exports.POST_ASSET_QUERY_SCHEMA,
242
254
  body: exports.POST_ASSET_BODY_SCHEMA,
243
255
  response: exports.POST_ASSET_RESPONSE_SCHEMA,
244
256
  },
@@ -49,10 +49,19 @@ export default class CalmLensClient {
49
49
  */
50
50
  listChildren: (assetId: string, options: GetAssetChildrenQuery) => Promise<GetAssetChildrenResponse>;
51
51
  /**
52
- * Submit a new asset for processing
52
+ * Submit a new asset for processing (queued asynchronously)
53
+ * The asset will be queued for classification and returned immediately.
53
54
  * @param options - Asset submission options
54
55
  * @returns Promise with created asset
55
56
  */
56
57
  create: (options: SubmitAssetOptions) => Promise<Asset>;
58
+ /**
59
+ * Submit a new asset and analyze it synchronously
60
+ * The asset will be classified immediately before the response is returned.
61
+ * This may take longer but ensures the asset is fully processed.
62
+ * @param options - Asset submission options
63
+ * @returns Promise with created and analyzed asset
64
+ */
65
+ analyze: (options: SubmitAssetOptions) => Promise<Asset>;
57
66
  };
58
67
  }
@@ -62,6 +62,7 @@ const createEndpoints = (api) => {
62
62
  .endpoint()
63
63
  .bodyOf()
64
64
  .paramsOf()
65
+ .queryOf()
65
66
  .responseOf()
66
67
  .build({
67
68
  id: "postUploadAsset",
@@ -167,7 +168,8 @@ export default class CalmLensClient {
167
168
  return result.data;
168
169
  }),
169
170
  /**
170
- * Submit a new asset for processing
171
+ * Submit a new asset for processing (queued asynchronously)
172
+ * The asset will be queued for classification and returned immediately.
171
173
  * @param options - Asset submission options
172
174
  * @returns Promise with created asset
173
175
  */
@@ -183,6 +185,34 @@ export default class CalmLensClient {
183
185
  params: {
184
186
  projectId: this.options.projectId,
185
187
  },
188
+ query: {
189
+ queue: true, // Queue for async processing
190
+ },
191
+ });
192
+ return result.data;
193
+ }),
194
+ /**
195
+ * Submit a new asset and analyze it synchronously
196
+ * The asset will be classified immediately before the response is returned.
197
+ * This may take longer but ensures the asset is fully processed.
198
+ * @param options - Asset submission options
199
+ * @returns Promise with created and analyzed asset
200
+ */
201
+ analyze: (options) => __awaiter(this, void 0, void 0, function* () {
202
+ if (!("file" in options) && !("url" in options)) {
203
+ throw new Error("Either file content or URL is required");
204
+ }
205
+ if (!options.name) {
206
+ throw new Error("Asset name is required");
207
+ }
208
+ const result = yield this.endpoints.postUploadAsset.submit({
209
+ body: options,
210
+ params: {
211
+ projectId: this.options.projectId,
212
+ },
213
+ query: {
214
+ queue: false, // Process synchronously
215
+ },
186
216
  });
187
217
  return result.data;
188
218
  }),
@@ -969,6 +969,9 @@ export declare const POST_ASSET_BODY_SCHEMA: zod.ZodIntersection<zod.ZodUnion<re
969
969
  private: "private";
970
970
  }>>>>;
971
971
  }, zod.z.core.$strip>>>;
972
+ export declare const POST_ASSET_QUERY_SCHEMA: zod.ZodObject<{
973
+ queue: zod.ZodDefault<zod.ZodBoolean>;
974
+ }, zod.z.core.$strip>;
972
975
  export declare const POST_ASSET_RESPONSE_SCHEMA: zod.ZodObject<{
973
976
  id: zod.ZodString;
974
977
  projectId: zod.ZodString;
@@ -1098,6 +1101,7 @@ export declare const POST_ASSET_RESPONSE_SCHEMA: zod.ZodObject<{
1098
1101
  }, zod.z.core.$strip>>>;
1099
1102
  }, zod.z.core.$strip>;
1100
1103
  export type PostAssetParams = zod.infer<typeof POST_ASSET_PARAMS_SCHEMA>;
1104
+ export type PostAssetQuery = zod.infer<typeof POST_ASSET_QUERY_SCHEMA>;
1101
1105
  export type PostAssetBody = zod.infer<typeof POST_ASSET_BODY_SCHEMA>;
1102
1106
  export type PostAssetResponse = Asset;
1103
1107
  export declare const POST_ASSET_REQUEST: {
@@ -1112,6 +1116,9 @@ export declare const POST_ASSET_REQUEST: {
1112
1116
  readonly params: zod.ZodObject<{
1113
1117
  projectId: zod.ZodString;
1114
1118
  }, zod.z.core.$strip>;
1119
+ readonly query: zod.ZodObject<{
1120
+ queue: zod.ZodDefault<zod.ZodBoolean>;
1121
+ }, zod.z.core.$strip>;
1115
1122
  readonly body: zod.ZodIntersection<zod.ZodUnion<readonly [zod.ZodObject<{
1116
1123
  file: zod.ZodString;
1117
1124
  fileType: zod.ZodString;
@@ -192,6 +192,17 @@ const POST_ASSET_COMMON_BODY_SCHEMA = ASSET_SCHEMA.pick({
192
192
  export const POST_ASSET_BODY_SCHEMA = zod
193
193
  .union([POST_ASSET_FILE_BODY_SCHEMA, POST_ASSET_URL_BODY_SCHEMA])
194
194
  .and(POST_ASSET_COMMON_BODY_SCHEMA);
195
+ export const POST_ASSET_QUERY_SCHEMA = zod.object({
196
+ queue: zod
197
+ .boolean()
198
+ .default(false)
199
+ .meta(metaStore([
200
+ docPropertyInfo({
201
+ description: "If true, queue the asset for asynchronous classification. If false, classify synchronously.",
202
+ placeholder: "false",
203
+ }),
204
+ ])),
205
+ });
195
206
  export const POST_ASSET_RESPONSE_SCHEMA = ASSET_SCHEMA;
196
207
  export const POST_ASSET_REQUEST = {
197
208
  name: "Create Asset",
@@ -203,6 +214,7 @@ export const POST_ASSET_REQUEST = {
203
214
  sdkPath: ["assets", "create"],
204
215
  schemas: {
205
216
  params: POST_ASSET_PARAMS_SCHEMA,
217
+ query: POST_ASSET_QUERY_SCHEMA,
206
218
  body: POST_ASSET_BODY_SCHEMA,
207
219
  response: POST_ASSET_RESPONSE_SCHEMA,
208
220
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calmlens/js-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "main": "cjs/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "module": "esm/index.js",