@adminforth/bulk-ai-flow 1.23.9 → 1.23.11

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/build.log CHANGED
@@ -14,5 +14,5 @@ custom/package.json
14
14
  custom/pnpm-lock.yaml
15
15
  custom/tsconfig.json
16
16
 
17
- sent 111,607 bytes received 191 bytes 223,596.00 bytes/sec
17
+ sent 111,617 bytes received 191 bytes 223,616.00 bytes/sec
18
18
  total size is 110,903 speedup is 0.99
package/dist/index.js CHANGED
@@ -108,6 +108,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
108
108
  analyze_image(jobId_1, recordId_1, adminUser_1, headers_1, customPrompt_1) {
109
109
  return __awaiter(this, arguments, void 0, function* (jobId, recordId, adminUser, headers, customPrompt, filterFilledFields = true) {
110
110
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
111
+ if (yield this.checkRateLimit("fillFieldsFromImages", this.options.rateLimits.fillFieldsFromImages, headers)) {
112
+ jobs.set(jobId, { status: 'failed', error: "Rate limit exceeded" });
113
+ return { error: "Rate limit exceeded" };
114
+ }
111
115
  const selectedId = recordId;
112
116
  let isError = false;
113
117
  // Fetch the record using the provided ID
@@ -190,6 +194,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
190
194
  }
191
195
  analyzeNoImages(jobId_1, recordId_1, adminUser_1, headers_1, customPrompt_1) {
192
196
  return __awaiter(this, arguments, void 0, function* (jobId, recordId, adminUser, headers, customPrompt, filterFilledFields = true) {
197
+ if (yield this.checkRateLimit("fillPlainFields", this.options.rateLimits.fillPlainFields, headers)) {
198
+ jobs.set(jobId, { status: 'failed', error: "Rate limit exceeded" });
199
+ return { error: "Rate limit exceeded" };
200
+ }
193
201
  const selectedId = recordId;
194
202
  let isError = false;
195
203
  if (STUB_MODE) {
@@ -249,6 +257,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
249
257
  initialImageGenerate(jobId_1, recordId_1, adminUser_1, headers_1, customPrompt_1) {
250
258
  return __awaiter(this, arguments, void 0, function* (jobId, recordId, adminUser, headers, customPrompt, filterFilledFields = true) {
251
259
  var _a, _b;
260
+ if (yield this.checkRateLimit("generateImages", this.options.rateLimits.generateImages, headers)) {
261
+ jobs.set(jobId, { status: 'failed', error: "Rate limit exceeded" });
262
+ return { error: "Rate limit exceeded" };
263
+ }
252
264
  const selectedId = recordId;
253
265
  let isError = false;
254
266
  const start = +new Date();
package/index.ts CHANGED
@@ -109,6 +109,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
109
109
  }
110
110
 
111
111
  private async analyze_image(jobId: string, recordId: string, adminUser: any, headers: Record<string, string | string[] | undefined>, customPrompt? : string, filterFilledFields: boolean = true) {
112
+ if (await this.checkRateLimit("fillFieldsFromImages" ,this.options.rateLimits.fillFieldsFromImages, headers)) {
113
+ jobs.set(jobId, { status: 'failed', error: "Rate limit exceeded" });
114
+ return { error: "Rate limit exceeded" };
115
+ }
112
116
  const selectedId = recordId;
113
117
  let isError = false;
114
118
  // Fetch the record using the provided ID
@@ -189,6 +193,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
189
193
  }
190
194
 
191
195
  private async analyzeNoImages(jobId: string, recordId: string, adminUser: any, headers: Record<string, string | string[] | undefined>, customPrompt? : string, filterFilledFields: boolean = true) {
196
+ if (await this.checkRateLimit("fillPlainFields" ,this.options.rateLimits.fillPlainFields, headers)) {
197
+ jobs.set(jobId, { status: 'failed', error: "Rate limit exceeded" });
198
+ return { error: "Rate limit exceeded" };
199
+ }
192
200
  const selectedId = recordId;
193
201
  let isError = false;
194
202
  if (STUB_MODE) {
@@ -245,6 +253,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
245
253
  }
246
254
 
247
255
  private async initialImageGenerate(jobId: string, recordId: string, adminUser: any, headers: Record<string, string | string[] | undefined>, customPrompt? : string, filterFilledFields: boolean = true) {
256
+ if (await this.checkRateLimit("generateImages" ,this.options.rateLimits.generateImages, headers)) {
257
+ jobs.set(jobId, { status: 'failed', error: "Rate limit exceeded" });
258
+ return { error: "Rate limit exceeded" };
259
+ }
248
260
  const selectedId = recordId;
249
261
  let isError = false;
250
262
  const start = +new Date();
@@ -350,7 +362,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
350
362
  return { ok: false, error: 'Error during image generation' };
351
363
  }
352
364
  }
353
-
365
+
354
366
  private async regenerateImage(jobId: string, recordId: string, fieldName: string, prompt: string, adminUser: any, headers: Record<string, string | string[] | undefined>) {
355
367
  const Id = recordId;
356
368
  let isError = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/bulk-ai-flow",
3
- "version": "1.23.9",
3
+ "version": "1.23.11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },