@adminforth/upload 2.8.7 → 2.9.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/build.log CHANGED
@@ -11,5 +11,5 @@ custom/preview.vue
11
11
  custom/tsconfig.json
12
12
  custom/uploader.vue
13
13
 
14
- sent 51,953 bytes received 134 bytes 104,174.00 bytes/sec
15
- total size is 51,471 speedup is 0.99
14
+ sent 53,885 bytes received 134 bytes 108,038.00 bytes/sec
15
+ total size is 53,396 speedup is 0.99
@@ -181,6 +181,7 @@ import { callAdminForthApi } from '@/utils';
181
181
  import { useI18n } from 'vue-i18n';
182
182
  import adminforth from '@/adminforth';
183
183
  import { ProgressBar } from '@/afcl';
184
+ import * as Handlebars from 'handlebars';
184
185
 
185
186
  const { t: $t } = useI18n();
186
187
 
@@ -214,28 +215,9 @@ onMounted(async () => {
214
215
  }
215
216
  // iterate over all variables in template and replace them with their values from props.record[field].
216
217
  // if field is not present in props.record[field] then replace it with empty string and drop warning
217
- const regex = /{{(.*?)}}/g;
218
- const matches = template.match(regex);
219
- if (matches) {
220
- matches.forEach((match) => {
221
- const field = match.replace(/{{|}}/g, '').trim();
222
- if (field in context) {
223
- return;
224
- } else if (field in props.record) {
225
- context[field] = minifyField(props.record[field]);
226
- } else {
227
- adminforth.alert({
228
- message: $t('Field {{field}} defined in template but not found in record', { field }),
229
- variant: 'warning',
230
- timeout: 15,
231
- });
232
- }
233
- });
234
- }
235
-
236
- prompt.value = template.replace(regex, (_, field) => {
237
- return context[field.trim()] || '';
238
- });
218
+ const tpl = Handlebars.compile(template);
219
+ const compiledTemplate = tpl(props.record);
220
+ prompt.value = compiledTemplate;
239
221
 
240
222
  const recordId = props.record[props.meta.recorPkFieldName];
241
223
  if (!recordId) return;
@@ -10,6 +10,7 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@iconify-prerendered/vue-mdi": "^0.25.1718880438",
13
+ "handlebars": "^4.7.8",
13
14
  "medium-zoom": "^1.1.0"
14
15
  }
15
16
  },
@@ -201,6 +202,27 @@
201
202
  "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
202
203
  "peer": true
203
204
  },
205
+ "node_modules/handlebars": {
206
+ "version": "4.7.8",
207
+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
208
+ "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
209
+ "license": "MIT",
210
+ "dependencies": {
211
+ "minimist": "^1.2.5",
212
+ "neo-async": "^2.6.2",
213
+ "source-map": "^0.6.1",
214
+ "wordwrap": "^1.0.0"
215
+ },
216
+ "bin": {
217
+ "handlebars": "bin/handlebars"
218
+ },
219
+ "engines": {
220
+ "node": ">=0.4.7"
221
+ },
222
+ "optionalDependencies": {
223
+ "uglify-js": "^3.1.4"
224
+ }
225
+ },
204
226
  "node_modules/magic-string": {
205
227
  "version": "0.30.11",
206
228
  "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz",
@@ -215,6 +237,15 @@
215
237
  "resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.1.0.tgz",
216
238
  "integrity": "sha512-ewyDsp7k4InCUp3jRmwHBRFGyjBimKps/AJLjRSox+2q/2H4p/PNpQf+pwONWlJiOudkBXtbdmVbFjqyybfTmQ=="
217
239
  },
240
+ "node_modules/minimist": {
241
+ "version": "1.2.8",
242
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
243
+ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
244
+ "license": "MIT",
245
+ "funding": {
246
+ "url": "https://github.com/sponsors/ljharb"
247
+ }
248
+ },
218
249
  "node_modules/nanoid": {
219
250
  "version": "3.3.7",
220
251
  "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
@@ -233,6 +264,12 @@
233
264
  "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
234
265
  }
235
266
  },
267
+ "node_modules/neo-async": {
268
+ "version": "2.6.2",
269
+ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
270
+ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
271
+ "license": "MIT"
272
+ },
236
273
  "node_modules/picocolors": {
237
274
  "version": "1.1.0",
238
275
  "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz",
@@ -267,6 +304,15 @@
267
304
  "node": "^10 || ^12 || >=14"
268
305
  }
269
306
  },
307
+ "node_modules/source-map": {
308
+ "version": "0.6.1",
309
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
310
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
311
+ "license": "BSD-3-Clause",
312
+ "engines": {
313
+ "node": ">=0.10.0"
314
+ }
315
+ },
270
316
  "node_modules/source-map-js": {
271
317
  "version": "1.2.1",
272
318
  "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -285,6 +331,19 @@
285
331
  "node": ">=4"
286
332
  }
287
333
  },
334
+ "node_modules/uglify-js": {
335
+ "version": "3.19.3",
336
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
337
+ "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
338
+ "license": "BSD-2-Clause",
339
+ "optional": true,
340
+ "bin": {
341
+ "uglifyjs": "bin/uglifyjs"
342
+ },
343
+ "engines": {
344
+ "node": ">=0.8.0"
345
+ }
346
+ },
288
347
  "node_modules/vue": {
289
348
  "version": "3.5.10",
290
349
  "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.10.tgz",
@@ -305,6 +364,12 @@
305
364
  "optional": true
306
365
  }
307
366
  }
367
+ },
368
+ "node_modules/wordwrap": {
369
+ "version": "1.0.0",
370
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
371
+ "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
372
+ "license": "MIT"
308
373
  }
309
374
  }
310
375
  }
@@ -11,6 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "@iconify-prerendered/vue-mdi": "^0.25.1718880438",
14
+ "handlebars": "^4.7.8",
14
15
  "medium-zoom": "^1.1.0"
15
16
  }
16
17
  }
@@ -181,6 +181,7 @@ import { callAdminForthApi } from '@/utils';
181
181
  import { useI18n } from 'vue-i18n';
182
182
  import adminforth from '@/adminforth';
183
183
  import { ProgressBar } from '@/afcl';
184
+ import * as Handlebars from 'handlebars';
184
185
 
185
186
  const { t: $t } = useI18n();
186
187
 
@@ -214,28 +215,9 @@ onMounted(async () => {
214
215
  }
215
216
  // iterate over all variables in template and replace them with their values from props.record[field].
216
217
  // if field is not present in props.record[field] then replace it with empty string and drop warning
217
- const regex = /{{(.*?)}}/g;
218
- const matches = template.match(regex);
219
- if (matches) {
220
- matches.forEach((match) => {
221
- const field = match.replace(/{{|}}/g, '').trim();
222
- if (field in context) {
223
- return;
224
- } else if (field in props.record) {
225
- context[field] = minifyField(props.record[field]);
226
- } else {
227
- adminforth.alert({
228
- message: $t('Field {{field}} defined in template but not found in record', { field }),
229
- variant: 'warning',
230
- timeout: 15,
231
- });
232
- }
233
- });
234
- }
235
-
236
- prompt.value = template.replace(regex, (_, field) => {
237
- return context[field.trim()] || '';
238
- });
218
+ const tpl = Handlebars.compile(template);
219
+ const compiledTemplate = tpl(props.record);
220
+ prompt.value = compiledTemplate;
239
221
 
240
222
  const recordId = props.record[props.meta.recorPkFieldName];
241
223
  if (!recordId) return;
@@ -10,6 +10,7 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@iconify-prerendered/vue-mdi": "^0.25.1718880438",
13
+ "handlebars": "^4.7.8",
13
14
  "medium-zoom": "^1.1.0"
14
15
  }
15
16
  },
@@ -201,6 +202,27 @@
201
202
  "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
202
203
  "peer": true
203
204
  },
205
+ "node_modules/handlebars": {
206
+ "version": "4.7.8",
207
+ "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
208
+ "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
209
+ "license": "MIT",
210
+ "dependencies": {
211
+ "minimist": "^1.2.5",
212
+ "neo-async": "^2.6.2",
213
+ "source-map": "^0.6.1",
214
+ "wordwrap": "^1.0.0"
215
+ },
216
+ "bin": {
217
+ "handlebars": "bin/handlebars"
218
+ },
219
+ "engines": {
220
+ "node": ">=0.4.7"
221
+ },
222
+ "optionalDependencies": {
223
+ "uglify-js": "^3.1.4"
224
+ }
225
+ },
204
226
  "node_modules/magic-string": {
205
227
  "version": "0.30.11",
206
228
  "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.11.tgz",
@@ -215,6 +237,15 @@
215
237
  "resolved": "https://registry.npmjs.org/medium-zoom/-/medium-zoom-1.1.0.tgz",
216
238
  "integrity": "sha512-ewyDsp7k4InCUp3jRmwHBRFGyjBimKps/AJLjRSox+2q/2H4p/PNpQf+pwONWlJiOudkBXtbdmVbFjqyybfTmQ=="
217
239
  },
240
+ "node_modules/minimist": {
241
+ "version": "1.2.8",
242
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
243
+ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
244
+ "license": "MIT",
245
+ "funding": {
246
+ "url": "https://github.com/sponsors/ljharb"
247
+ }
248
+ },
218
249
  "node_modules/nanoid": {
219
250
  "version": "3.3.7",
220
251
  "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
@@ -233,6 +264,12 @@
233
264
  "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
234
265
  }
235
266
  },
267
+ "node_modules/neo-async": {
268
+ "version": "2.6.2",
269
+ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
270
+ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
271
+ "license": "MIT"
272
+ },
236
273
  "node_modules/picocolors": {
237
274
  "version": "1.1.0",
238
275
  "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz",
@@ -267,6 +304,15 @@
267
304
  "node": "^10 || ^12 || >=14"
268
305
  }
269
306
  },
307
+ "node_modules/source-map": {
308
+ "version": "0.6.1",
309
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
310
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
311
+ "license": "BSD-3-Clause",
312
+ "engines": {
313
+ "node": ">=0.10.0"
314
+ }
315
+ },
270
316
  "node_modules/source-map-js": {
271
317
  "version": "1.2.1",
272
318
  "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -285,6 +331,19 @@
285
331
  "node": ">=4"
286
332
  }
287
333
  },
334
+ "node_modules/uglify-js": {
335
+ "version": "3.19.3",
336
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
337
+ "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
338
+ "license": "BSD-2-Clause",
339
+ "optional": true,
340
+ "bin": {
341
+ "uglifyjs": "bin/uglifyjs"
342
+ },
343
+ "engines": {
344
+ "node": ">=0.8.0"
345
+ }
346
+ },
288
347
  "node_modules/vue": {
289
348
  "version": "3.5.10",
290
349
  "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.10.tgz",
@@ -305,6 +364,12 @@
305
364
  "optional": true
306
365
  }
307
366
  }
367
+ },
368
+ "node_modules/wordwrap": {
369
+ "version": "1.0.0",
370
+ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
371
+ "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
372
+ "license": "MIT"
308
373
  }
309
374
  }
310
375
  }
@@ -11,6 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "@iconify-prerendered/vue-mdi": "^0.25.1718880438",
14
+ "handlebars": "^4.7.8",
14
15
  "medium-zoom": "^1.1.0"
15
16
  }
16
17
  }
package/dist/index.js CHANGED
@@ -186,7 +186,7 @@ export default class UploadPlugin extends AdminForthPlugin {
186
186
  modifyResourceConfig: { get: () => super.modifyResourceConfig }
187
187
  });
188
188
  return __awaiter(this, void 0, void 0, function* () {
189
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
189
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
190
190
  _super.modifyResourceConfig.call(this, adminforth, resourceConfig);
191
191
  this.resourceConfig = resourceConfig;
192
192
  // after column to store the path of the uploaded file, add new VirtualColumn,
@@ -197,15 +197,6 @@ export default class UploadPlugin extends AdminForthPlugin {
197
197
  if (pathColumnIndex === -1) {
198
198
  throw new Error(`Column with name "${pathColumnName}" not found in resource "${resourceConfig.label}"`);
199
199
  }
200
- if ((_a = this.options.generation) === null || _a === void 0 ? void 0 : _a.fieldsForContext) {
201
- (_b = this.options.generation) === null || _b === void 0 ? void 0 : _b.fieldsForContext.forEach((field) => {
202
- if (!resourceConfig.columns.find((column) => column.name === field)) {
203
- const similar = suggestIfTypo(resourceConfig.columns.map((column) => column.name), field);
204
- throw new Error(`Field "${field}" specified in fieldsForContext not found in
205
- resource "${resourceConfig.label}". ${similar ? `Did you mean "${similar}"?` : ''}`);
206
- }
207
- });
208
- }
209
200
  const pluginFrontendOptions = {
210
201
  allowedExtensions: this.options.allowedFileExtensions,
211
202
  maxFileSize: this.options.maxFileSize,
@@ -213,14 +204,14 @@ export default class UploadPlugin extends AdminForthPlugin {
213
204
  resourceLabel: resourceConfig.label,
214
205
  generateImages: this.options.generation ? true : false,
215
206
  pathColumnLabel: resourceConfig.columns[pathColumnIndex].label,
216
- maxWidth: (_c = this.options.preview) === null || _c === void 0 ? void 0 : _c.maxWidth,
217
- maxListWidth: (_d = this.options.preview) === null || _d === void 0 ? void 0 : _d.maxListWidth,
218
- maxShowWidth: (_e = this.options.preview) === null || _e === void 0 ? void 0 : _e.maxShowWidth,
219
- minWidth: (_f = this.options.preview) === null || _f === void 0 ? void 0 : _f.minWidth,
220
- minListWidth: (_g = this.options.preview) === null || _g === void 0 ? void 0 : _g.minListWidth,
221
- minShowWidth: (_h = this.options.preview) === null || _h === void 0 ? void 0 : _h.minShowWidth,
222
- generationPrompt: (_j = this.options.generation) === null || _j === void 0 ? void 0 : _j.generationPrompt,
223
- recorPkFieldName: (_k = this.resourceConfig.columns.find((column) => column.primaryKey)) === null || _k === void 0 ? void 0 : _k.name,
207
+ maxWidth: (_a = this.options.preview) === null || _a === void 0 ? void 0 : _a.maxWidth,
208
+ maxListWidth: (_b = this.options.preview) === null || _b === void 0 ? void 0 : _b.maxListWidth,
209
+ maxShowWidth: (_c = this.options.preview) === null || _c === void 0 ? void 0 : _c.maxShowWidth,
210
+ minWidth: (_d = this.options.preview) === null || _d === void 0 ? void 0 : _d.minWidth,
211
+ minListWidth: (_e = this.options.preview) === null || _e === void 0 ? void 0 : _e.minListWidth,
212
+ minShowWidth: (_f = this.options.preview) === null || _f === void 0 ? void 0 : _f.minShowWidth,
213
+ generationPrompt: (_g = this.options.generation) === null || _g === void 0 ? void 0 : _g.generationPrompt,
214
+ recorPkFieldName: (_h = this.resourceConfig.columns.find((column) => column.primaryKey)) === null || _h === void 0 ? void 0 : _h.name,
224
215
  pathColumnName: this.options.pathColumnName,
225
216
  };
226
217
  // define components which will be imported from other components
@@ -230,7 +221,7 @@ export default class UploadPlugin extends AdminForthPlugin {
230
221
  }
231
222
  const pathColumn = resourceConfig.columns[pathColumnIndex];
232
223
  // add preview column to list
233
- if (((_l = this.options.preview) === null || _l === void 0 ? void 0 : _l.usePreviewComponents) !== false) {
224
+ if (((_j = this.options.preview) === null || _j === void 0 ? void 0 : _j.usePreviewComponents) !== false) {
234
225
  resourceConfig.columns[pathColumnIndex].components.list = {
235
226
  file: this.componentPath('preview.vue'),
236
227
  meta: pluginFrontendOptions,
@@ -333,7 +324,28 @@ export default class UploadPlugin extends AdminForthPlugin {
333
324
  });
334
325
  }
335
326
  validateConfigAfterDiscover(adminforth, resourceConfig) {
327
+ var _a;
336
328
  this.adminforth = adminforth;
329
+ if (this.options.generation) {
330
+ const template = (_a = this.options.generation) === null || _a === void 0 ? void 0 : _a.generationPrompt;
331
+ const regex = /{{(.*?)}}/g;
332
+ const matches = template.match(regex);
333
+ if (matches) {
334
+ matches.forEach((match) => {
335
+ const field = match.replace(/{{|}}/g, '').trim();
336
+ if (!resourceConfig.columns.find((column) => column.name === field)) {
337
+ const similar = suggestIfTypo(resourceConfig.columns.map((column) => column.name), field);
338
+ throw new Error(`Field "${field}" specified in generationPrompt not found in resource "${resourceConfig.label}". ${similar ? `Did you mean "${similar}"?` : ''}`);
339
+ }
340
+ else {
341
+ let column = resourceConfig.columns.find((column) => column.name === field);
342
+ if (column.backendOnly === true) {
343
+ throw new Error(`Field "${field}" specified in generationPrompt is marked as backendOnly in resource "${resourceConfig.label}". Please remove backendOnly or choose another field.`);
344
+ }
345
+ }
346
+ });
347
+ }
348
+ }
337
349
  // called here because modifyResourceConfig can be called in build time where there is no environment and AWS secrets
338
350
  this.setupLifecycleRule();
339
351
  }
package/index.ts CHANGED
@@ -219,16 +219,6 @@ export default class UploadPlugin extends AdminForthPlugin {
219
219
  throw new Error(`Column with name "${pathColumnName}" not found in resource "${resourceConfig.label}"`);
220
220
  }
221
221
 
222
- if (this.options.generation?.fieldsForContext) {
223
- this.options.generation?.fieldsForContext.forEach((field: string) => {
224
- if (!resourceConfig.columns.find((column: any) => column.name === field)) {
225
- const similar = suggestIfTypo(resourceConfig.columns.map((column: any) => column.name), field);
226
- throw new Error(`Field "${field}" specified in fieldsForContext not found in
227
- resource "${resourceConfig.label}". ${similar ? `Did you mean "${similar}"?` : ''}`);
228
- }
229
- });
230
- }
231
-
232
222
  const pluginFrontendOptions = {
233
223
  allowedExtensions: this.options.allowedFileExtensions,
234
224
  maxFileSize: this.options.maxFileSize,
@@ -386,6 +376,26 @@ export default class UploadPlugin extends AdminForthPlugin {
386
376
 
387
377
  validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: any) {
388
378
  this.adminforth = adminforth;
379
+
380
+ if (this.options.generation) {
381
+ const template = this.options.generation?.generationPrompt;
382
+ const regex = /{{(.*?)}}/g;
383
+ const matches = template.match(regex);
384
+ if (matches) {
385
+ matches.forEach((match) => {
386
+ const field = match.replace(/{{|}}/g, '').trim();
387
+ if (!resourceConfig.columns.find((column: any) => column.name === field)) {
388
+ const similar = suggestIfTypo(resourceConfig.columns.map((column: any) => column.name), field);
389
+ throw new Error(`Field "${field}" specified in generationPrompt not found in resource "${resourceConfig.label}". ${similar ? `Did you mean "${similar}"?` : ''}`);
390
+ } else {
391
+ let column = resourceConfig.columns.find((column: any) => column.name === field);
392
+ if (column.backendOnly === true) {
393
+ throw new Error(`Field "${field}" specified in generationPrompt is marked as backendOnly in resource "${resourceConfig.label}". Please remove backendOnly or choose another field.`);
394
+ }
395
+ }
396
+ });
397
+ }
398
+ }
389
399
  // called here because modifyResourceConfig can be called in build time where there is no environment and AWS secrets
390
400
  this.setupLifecycleRule();
391
401
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "2.8.7",
3
+ "version": "2.9.0",
4
4
  "description": "Plugin for uploading files for adminforth",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types.ts CHANGED
@@ -102,12 +102,6 @@ export type PluginOptions = {
102
102
  */
103
103
  outputSize?: string,
104
104
 
105
- /**
106
- * Fields for conetext which will be used to generate the image.
107
- * If specified, the plugin will use fields from the record to provide additional context to the AI model.
108
- */
109
- fieldsForContext?: string[],
110
-
111
105
  /**
112
106
  * The number of images to generate
113
107
  * in one request