@adminforth/upload 2.8.6 → 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/.woodpecker/buildSlackNotify.sh +3 -1
- package/.woodpecker/release.yml +24 -7
- package/build.log +2 -2
- package/custom/imageGenerator.vue +4 -22
- package/custom/package-lock.json +65 -0
- package/custom/package.json +1 -0
- package/dist/custom/imageGenerator.vue +4 -22
- package/dist/custom/package-lock.json +65 -0
- package/dist/custom/package.json +1 -0
- package/dist/index.js +31 -19
- package/index.ts +20 -10
- package/package.json +1 -1
- package/types.ts +0 -6
|
@@ -4,8 +4,10 @@ set -x
|
|
|
4
4
|
|
|
5
5
|
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
6
|
|
|
7
|
+
STATUS=${1}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
if [ "$STATUS" = "success" ]; then
|
|
9
11
|
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
10
12
|
|
|
11
13
|
curl -s -X POST -H "Content-Type: application/json" -d '{
|
package/.woodpecker/release.yml
CHANGED
|
@@ -16,25 +16,42 @@ steps:
|
|
|
16
16
|
commands:
|
|
17
17
|
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
build:
|
|
20
20
|
image: node:20
|
|
21
21
|
when:
|
|
22
22
|
- event: push
|
|
23
23
|
commands:
|
|
24
24
|
- apt update && apt install -y rsync
|
|
25
|
-
-
|
|
25
|
+
- . /woodpecker/deploy.vault.env
|
|
26
26
|
- npm clean-install
|
|
27
27
|
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
28
28
|
- npm audit signatures
|
|
29
|
+
|
|
30
|
+
release:
|
|
31
|
+
image: node:20
|
|
32
|
+
when:
|
|
33
|
+
- event:
|
|
34
|
+
- push
|
|
35
|
+
branch:
|
|
36
|
+
- main
|
|
37
|
+
commands:
|
|
38
|
+
- . /woodpecker/deploy.vault.env
|
|
29
39
|
- npx semantic-release
|
|
30
40
|
|
|
31
41
|
slack-on-failure:
|
|
42
|
+
image: curlimages/curl
|
|
32
43
|
when:
|
|
33
44
|
- event: push
|
|
34
|
-
status: [failure
|
|
35
|
-
|
|
45
|
+
status: [failure]
|
|
46
|
+
commands:
|
|
47
|
+
- . /woodpecker/deploy.vault.env
|
|
48
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
|
|
49
|
+
|
|
50
|
+
slack-on-success:
|
|
36
51
|
image: curlimages/curl
|
|
52
|
+
when:
|
|
53
|
+
- event: push
|
|
54
|
+
status: [success]
|
|
37
55
|
commands:
|
|
38
|
-
-
|
|
39
|
-
- /bin/sh ./.woodpecker/buildSlackNotify.sh
|
|
40
|
-
|
|
56
|
+
- . /woodpecker/deploy.vault.env
|
|
57
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success
|
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
|
|
15
|
-
total size is
|
|
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
|
|
218
|
-
const
|
|
219
|
-
|
|
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;
|
package/custom/package-lock.json
CHANGED
|
@@ -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
|
}
|
package/custom/package.json
CHANGED
|
@@ -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
|
|
218
|
-
const
|
|
219
|
-
|
|
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
|
}
|
package/dist/custom/package.json
CHANGED
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
|
|
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: (
|
|
217
|
-
maxListWidth: (
|
|
218
|
-
maxShowWidth: (
|
|
219
|
-
minWidth: (
|
|
220
|
-
minListWidth: (
|
|
221
|
-
minShowWidth: (
|
|
222
|
-
generationPrompt: (
|
|
223
|
-
recorPkFieldName: (
|
|
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 (((
|
|
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
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
|