@adminforth/bulk-ai-flow 1.1.0 → 1.1.2

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
@@ -10,5 +10,5 @@ custom/tsconfig.json
10
10
  custom/visionAction.vue
11
11
  custom/visionTable.vue
12
12
 
13
- sent 24,032 bytes received 115 bytes 48,294.00 bytes/sec
14
- total size is 23,613 speedup is 0.98
13
+ sent 24,084 bytes received 115 bytes 48,398.00 bytes/sec
14
+ total size is 23,659 speedup is 0.98
@@ -84,9 +84,9 @@ const openDialog = async () => {
84
84
  analyzeFields();
85
85
  }
86
86
 
87
- watch(selected, (val) => {
88
- console.log('Selected changed:', val);
89
- }, { deep: true });
87
+ // watch(selected, (val) => {
88
+ // console.log('Selected changed:', val);
89
+ // }, { deep: true });
90
90
 
91
91
  const closeDialog = () => {
92
92
  confirmDialog.value.close();
@@ -194,12 +194,12 @@ function prepareDataForSave() {
194
194
  const checkedItems = selected.value
195
195
  .filter(item => item.isChecked === true)
196
196
  .map(item => {
197
- const { isChecked, id, ...itemWithoutIsCheckedAndId } = item;
197
+ const { isChecked, primaryKey, ...itemWithoutIsCheckedAndId } = item;
198
198
  return itemWithoutIsCheckedAndId;
199
199
  });
200
200
  const checkedItemsIDs = selected.value
201
201
  .filter(item => item.isChecked === true)
202
- .map(item => item.id);
202
+ .map(item => item[primaryKey]);
203
203
  return [checkedItemsIDs, checkedItems];
204
204
  }
205
205
 
@@ -222,7 +222,7 @@ async function analyzeFields() {
222
222
  ...res.result.map((item, idx) => ({
223
223
  ...item,
224
224
  isChecked: true,
225
- id: selected.value[idx]?.id,
225
+ [primaryKey]: selected.value[idx]?.[primaryKey],
226
226
  }))
227
227
  )
228
228
  }
@@ -84,9 +84,9 @@ const openDialog = async () => {
84
84
  analyzeFields();
85
85
  }
86
86
 
87
- watch(selected, (val) => {
88
- console.log('Selected changed:', val);
89
- }, { deep: true });
87
+ // watch(selected, (val) => {
88
+ // console.log('Selected changed:', val);
89
+ // }, { deep: true });
90
90
 
91
91
  const closeDialog = () => {
92
92
  confirmDialog.value.close();
@@ -194,12 +194,12 @@ function prepareDataForSave() {
194
194
  const checkedItems = selected.value
195
195
  .filter(item => item.isChecked === true)
196
196
  .map(item => {
197
- const { isChecked, id, ...itemWithoutIsCheckedAndId } = item;
197
+ const { isChecked, primaryKey, ...itemWithoutIsCheckedAndId } = item;
198
198
  return itemWithoutIsCheckedAndId;
199
199
  });
200
200
  const checkedItemsIDs = selected.value
201
201
  .filter(item => item.isChecked === true)
202
- .map(item => item.id);
202
+ .map(item => item[primaryKey]);
203
203
  return [checkedItemsIDs, checkedItems];
204
204
  }
205
205
 
@@ -222,7 +222,7 @@ async function analyzeFields() {
222
222
  ...res.result.map((item, idx) => ({
223
223
  ...item,
224
224
  isChecked: true,
225
- id: selected.value[idx]?.id,
225
+ [primaryKey]: selected.value[idx]?.[primaryKey],
226
226
  }))
227
227
  )
228
228
  }
package/dist/index.js CHANGED
@@ -52,8 +52,22 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
52
52
  throw new Error(`⚠️ No column found for key "${key}"`);
53
53
  }
54
54
  }
55
+ if (this.options.generateImages) {
56
+ console.log('Generate Images options:', this.options.generateImages);
57
+ for (const [key, value] of Object.entries(this.options.generateImages)) {
58
+ const column = columns.find(c => c.name.toLowerCase() === key.toLowerCase());
59
+ if (!column) {
60
+ throw new Error(`⚠️ No column found for key "${key}"`);
61
+ }
62
+ const plugin = adminforth.activatedPlugins.find(p => p.resourceConfig.resourceId === key &&
63
+ p.pluginOptions.pathColumnName === this.resourceConfig.resourceId);
64
+ // if (!plugin) {
65
+ // throw new Error(`Plugin for attachment field '${key}' not found in resource '${this.options.attachments!.attachmentResource}', please check if Upload Plugin is installed on the field ${this.options.attachments!.attachmentFieldName}`);
66
+ // }
67
+ }
68
+ }
55
69
  const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
56
- console.log('Primary Key Column:', primaryKeyColumn);
70
+ //console.log('Primary Key Column:', primaryKeyColumn);
57
71
  const pageInjection = {
58
72
  file: this.componentPath('visionAction.vue'),
59
73
  meta: {
@@ -90,7 +104,8 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
90
104
  const tasks = selectedIds.map((ID) => __awaiter(this, void 0, void 0, function* () {
91
105
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
92
106
  // Fetch the record using the provided ID
93
- const record = yield this.adminforth.resource(this.resourceConfig.resourceId).get([Filters.EQ('id', ID)]);
107
+ const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
108
+ const record = yield this.adminforth.resource(this.resourceConfig.resourceId).get([Filters.EQ(primaryKeyColumn.name, ID)]);
94
109
  //recieve image URLs to analyze
95
110
  const attachmentFiles = yield this.options.attachFiles({ record: record });
96
111
  //create prompt for OpenAI
@@ -123,8 +138,9 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
123
138
  path: `/plugin/${this.pluginInstanceId}/get_records`,
124
139
  handler: (body) => __awaiter(this, void 0, void 0, function* () {
125
140
  let records = [];
141
+ const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
126
142
  for (const record of body.body.record) {
127
- records.push(yield this.adminforth.resource(this.resourceConfig.resourceId).get([Filters.EQ('id', record)]));
143
+ records.push(yield this.adminforth.resource(this.resourceConfig.resourceId).get([Filters.EQ(primaryKeyColumn.name, record)]));
128
144
  records[records.length - 1]._label = this.resourceConfig.recordLabel(records[records.length - 1]);
129
145
  }
130
146
  return {
package/index.ts CHANGED
@@ -7,6 +7,7 @@ import Handlebars from 'handlebars';
7
7
 
8
8
  export default class BulkAiFlowPlugin extends AdminForthPlugin {
9
9
  options: PluginOptions;
10
+ uploadPlugin: AdminForthPlugin;
10
11
 
11
12
  constructor(options: PluginOptions) {
12
13
  super(options, import.meta.url);
@@ -48,8 +49,27 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
48
49
  }
49
50
  }
50
51
 
52
+
53
+ if (this.options.generateImages) {
54
+ console.log('Generate Images options:', this.options.generateImages);
55
+ for (const [key, value] of Object.entries(this.options.generateImages)) {
56
+ const column = columns.find(c => c.name.toLowerCase() === key.toLowerCase());
57
+ if (!column) {
58
+ throw new Error(`⚠️ No column found for key "${key}"`);
59
+ }
60
+ const plugin = adminforth.activatedPlugins.find(p =>
61
+ p.resourceConfig!.resourceId === key &&
62
+ p.pluginOptions.pathColumnName === this.resourceConfig.resourceId
63
+ );
64
+ // if (!plugin) {
65
+ // throw new Error(`Plugin for attachment field '${key}' not found in resource '${this.options.attachments!.attachmentResource}', please check if Upload Plugin is installed on the field ${this.options.attachments!.attachmentFieldName}`);
66
+ // }
67
+ }
68
+ }
69
+
70
+
51
71
  const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
52
- console.log('Primary Key Column:', primaryKeyColumn);
72
+ //console.log('Primary Key Column:', primaryKeyColumn);
53
73
 
54
74
  const pageInjection = {
55
75
  file: this.componentPath('visionAction.vue'),
@@ -90,7 +110,8 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
90
110
  const selectedIds = body.selectedIds || [];
91
111
  const tasks = selectedIds.map(async (ID) => {
92
112
  // Fetch the record using the provided ID
93
- const record = await this.adminforth.resource(this.resourceConfig.resourceId).get( [Filters.EQ('id', ID)] );
113
+ const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
114
+ const record = await this.adminforth.resource(this.resourceConfig.resourceId).get( [Filters.EQ(primaryKeyColumn.name, ID)] );
94
115
 
95
116
  //recieve image URLs to analyze
96
117
  const attachmentFiles = await this.options.attachFiles({ record: record });
@@ -131,8 +152,9 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
131
152
  path: `/plugin/${this.pluginInstanceId}/get_records`,
132
153
  handler: async ( body ) => {
133
154
  let records = [];
155
+ const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
134
156
  for( const record of body.body.record ) {
135
- records.push(await this.adminforth.resource(this.resourceConfig.resourceId).get( [Filters.EQ('id', record)] ));
157
+ records.push(await this.adminforth.resource(this.resourceConfig.resourceId).get( [Filters.EQ(primaryKeyColumn.name, record)] ));
136
158
  records[records.length - 1]._label = this.resourceConfig.recordLabel(records[records.length - 1]);
137
159
  }
138
160
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/bulk-ai-flow",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/types.ts CHANGED
@@ -4,7 +4,8 @@ import { ImageVisionAdapter, AdminUser, IAdminForth, StorageAdapter } from "admi
4
4
  export interface PluginOptions {
5
5
  actionName: string,
6
6
  visionAdapter: ImageVisionAdapter,
7
- fillFieldsFromImages: Record<string, string>,
7
+ fillFieldsFromImages?: Record<string, string>, // can analyze what is on image and fill fields, typical tasks "find dominant color", "describe what is on image", "clasify to one enum item, e.g. what is on image dog/cat/plant"
8
+ generateImages?: Record<string, string>, // can generate from images or just from another fields, e.g. "remove text from images", "improve image quality", "turn image into ghibli style"
8
9
  attachFiles?: ({ record }: {
9
10
  record: any,
10
11
  }) => string[] | Promise<string[]>,