@adminforth/bulk-ai-flow 1.14.1 → 1.14.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.
@@ -1,7 +1,7 @@
1
1
 
2
2
  <template>
3
3
  <!-- Main modal -->
4
- <div tabindex="-1" class="[scrollbar-gutter:stable] fixed inset-0 z-10 flex justify-center items-center bg-gray-800/50 dark:bg-gray-900/50 overflow-y-auto">
4
+ <div tabindex="-1" class="[scrollbar-gutter:stable] fixed inset-0 z-20 flex justify-center items-center bg-gray-800/50 dark:bg-gray-900/50 overflow-y-auto">
5
5
  <div class="relative p-4 w-full max-w-[1600px]">
6
6
  <!-- Modal content -->
7
7
  <div class="relative bg-white rounded-lg shadow-xl dark:bg-gray-700">
@@ -1,7 +1,7 @@
1
1
 
2
2
  <template>
3
3
  <!-- Main modal -->
4
- <div tabindex="-1" class="[scrollbar-gutter:stable] fixed inset-0 z-10 flex justify-center items-center bg-gray-800/50 dark:bg-gray-900/50 overflow-y-auto">
4
+ <div tabindex="-1" class="[scrollbar-gutter:stable] fixed inset-0 z-20 flex justify-center items-center bg-gray-800/50 dark:bg-gray-900/50 overflow-y-auto">
5
5
  <div class="relative p-4 w-full max-w-[1600px]">
6
6
  <!-- Modal content -->
7
7
  <div class="relative bg-white rounded-lg shadow-xl dark:bg-gray-700">
package/dist/index.js CHANGED
@@ -253,9 +253,9 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
253
253
  recordResult[key] = images;
254
254
  });
255
255
  const result = recordResult;
256
- this.totalCalls++;
257
- this.totalDuration += (+new Date() - start) / 1000;
258
256
  if (!isError) {
257
+ this.totalCalls++;
258
+ this.totalDuration += (+new Date() - start) / 1000;
259
259
  jobs.set(jobId, { status: 'completed', result });
260
260
  return { ok: true };
261
261
  }
@@ -316,9 +316,9 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
316
316
  }
317
317
  return resp.imageURLs[0];
318
318
  })));
319
- this.totalCalls++;
320
- this.totalDuration += (+new Date() - start) / 1000;
321
319
  if (!isError) {
320
+ this.totalCalls++;
321
+ this.totalDuration += (+new Date() - start) / 1000;
322
322
  jobs.set(jobId, { status: 'completed', result: { [fieldName]: images } });
323
323
  return { ok: true };
324
324
  }
@@ -599,33 +599,14 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
599
599
  }
600
600
  }
601
601
  }
602
- try {
603
- const AuditLogPlugin = this.adminforth.getPluginByClassName('AuditLogPlugin');
604
- if (AuditLogPlugin) {
605
- for (const [key, value] of Object.entries(oldRecord)) {
606
- if (!(key in fieldsToUpdate[idx])) {
607
- delete oldRecord[key];
608
- }
609
- }
610
- const reorderedOldRecord = Object.keys(fieldsToUpdate[idx]).reduce((acc, key) => {
611
- if (key in oldRecord) {
612
- acc[key] = oldRecord[key];
613
- }
614
- return acc;
615
- }, {});
616
- AuditLogPlugin.logCustomAction({
617
- resourceId: this.resourceConfig.resourceId,
618
- recordId: ID,
619
- actionId: 'Bulk-ai-flow',
620
- oldData: reorderedOldRecord,
621
- data: fieldsToUpdate[idx],
622
- user: adminUser,
623
- headers: headers
624
- });
625
- }
626
- }
627
- catch (error) { }
628
- return this.adminforth.resource(this.resourceConfig.resourceId).update(ID, fieldsToUpdate[idx]);
602
+ const newRecord = Object.assign(Object.assign({}, oldRecord), fieldsToUpdate[idx]);
603
+ return this.adminforth.updateResourceRecord({
604
+ resource: this.resourceConfig,
605
+ recordId: ID,
606
+ oldRecord: oldRecord,
607
+ record: newRecord,
608
+ adminUser: adminUser,
609
+ });
629
610
  }));
630
611
  yield Promise.all(updates);
631
612
  return { ok: true };
package/index.ts CHANGED
@@ -257,9 +257,9 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
257
257
 
258
258
  const result = recordResult;
259
259
 
260
- this.totalCalls++;
261
- this.totalDuration += (+new Date() - start) / 1000;
262
260
  if (!isError) {
261
+ this.totalCalls++;
262
+ this.totalDuration += (+new Date() - start) / 1000;
263
263
  jobs.set(jobId, { status: 'completed', result });
264
264
  return { ok: true }
265
265
  } else {
@@ -319,9 +319,10 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
319
319
  return resp.imageURLs[0]
320
320
  })
321
321
  );
322
- this.totalCalls++;
323
- this.totalDuration += (+new Date() - start) / 1000;
322
+
324
323
  if (!isError) {
324
+ this.totalCalls++;
325
+ this.totalDuration += (+new Date() - start) / 1000;
325
326
  jobs.set(jobId, { status: 'completed', result: { [fieldName]: images } });
326
327
  return { ok: true };
327
328
  } else {
@@ -624,36 +625,17 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
624
625
  }
625
626
  }
626
627
  }
627
- try {
628
- const AuditLogPlugin:any = this.adminforth.getPluginByClassName('AuditLogPlugin');
629
- if (AuditLogPlugin) {
630
-
631
- for (const [key, value] of Object.entries(oldRecord)) {
632
- if (!(key in fieldsToUpdate[idx])) {
633
- delete oldRecord[key];
634
- }
635
- }
636
-
637
- const reorderedOldRecord = Object.keys(fieldsToUpdate[idx]).reduce((acc, key) => {
638
- if (key in oldRecord) {
639
- acc[key] = oldRecord[key];
640
- }
641
- return acc;
642
- }, {} as Record<string, unknown>);
643
-
644
- AuditLogPlugin.logCustomAction({
645
- resourceId: this.resourceConfig.resourceId,
646
- recordId: ID,
647
- actionId: 'Bulk-ai-flow',
648
- oldData: reorderedOldRecord,
649
- data: fieldsToUpdate[idx],
650
- user: adminUser,
651
- headers: headers
652
- });
653
- }
654
- } catch (error) { }
655
-
656
- return this.adminforth.resource(this.resourceConfig.resourceId).update(ID, fieldsToUpdate[idx])
628
+ const newRecord = {
629
+ ...oldRecord,
630
+ ...fieldsToUpdate[idx]
631
+ };
632
+ return this.adminforth.updateResourceRecord({
633
+ resource: this.resourceConfig,
634
+ recordId: ID,
635
+ oldRecord: oldRecord,
636
+ record: newRecord,
637
+ adminUser: adminUser,
638
+ })
657
639
  });
658
640
  await Promise.all(updates);
659
641
  return { ok: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/bulk-ai-flow",
3
- "version": "1.14.1",
3
+ "version": "1.14.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },