@adminforth/rich-editor 1.3.0 → 1.4.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.
@@ -15,8 +15,6 @@ steps:
15
15
  from_secret: VAULT_TOKEN
16
16
  commands:
17
17
  - infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
18
- secrets:
19
- - VAULT_TOKEN
20
18
 
21
19
  release:
22
20
  image: node:20
package/build.log CHANGED
@@ -10,5 +10,5 @@ custom/package.json
10
10
  custom/quillEditor.vue
11
11
  custom/tsconfig.json
12
12
 
13
- sent 21,044 bytes received 115 bytes 42,318.00 bytes/sec
13
+ sent 21,050 bytes received 115 bytes 42,330.00 bytes/sec
14
14
  total size is 20,627 speedup is 0.97
package/dist/index.js CHANGED
@@ -51,9 +51,11 @@ export default class RichEditorPlugin extends AdminForthPlugin {
51
51
  if (!plugin) {
52
52
  throw new Error(`Plugin for attachment field '${this.options.attachments.attachmentFieldName}' not found in resource '${this.options.attachments.attachmentResource}', please check if Upload Plugin is installed on the field ${this.options.attachments.attachmentFieldName}`);
53
53
  }
54
- if (plugin.pluginOptions.s3ACL !== 'public-read') {
54
+ if (!plugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
55
55
  throw new Error(`Upload Plugin for attachment field '${this.options.attachments.attachmentFieldName}' in resource '${this.options.attachments.attachmentResource}'
56
- should have s3ACL set to 'public-read' (in vast majority of cases signed urls inside of HTML text is not desired behavior, so we did not implement it)`);
56
+ uses adapter which is not configured to store objects in public way, so it will produce only signed private URLs which can not be used in HTML text of blog posts.
57
+ Please configure adapter in such way that it will store objects publicly (e.g. for S3 use 'public-read' ACL).
58
+ `);
57
59
  }
58
60
  this.uploadPlugin = plugin;
59
61
  }
@@ -213,7 +215,7 @@ export default class RichEditorPlugin extends AdminForthPlugin {
213
215
  method: 'POST',
214
216
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
215
217
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers }) {
216
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
218
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
217
219
  const { record } = body;
218
220
  if ((_b = this.options.completion.rateLimit) === null || _b === void 0 ? void 0 : _b.limit) {
219
221
  // rate limit
@@ -232,22 +234,23 @@ export default class RichEditorPlugin extends AdminForthPlugin {
232
234
  if (currentVal && currentVal.length > promptLimit) {
233
235
  currentVal = currentVal.slice(-promptLimit);
234
236
  }
237
+ const fieldLabel = ((_m = (_l = this.resourceConfig) === null || _l === void 0 ? void 0 : _l.columns.find(c => c.name === this.options.htmlFieldName)) === null || _m === void 0 ? void 0 : _m.label) || this.options.htmlFieldName;
235
238
  const resLabel = this.resourceConfig.label;
236
239
  let content;
237
240
  if (currentVal) {
238
- content = `Continue writing for text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
241
+ content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
239
242
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
240
243
  `Current field value: ${currentVal}\n` +
241
244
  "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
242
245
  }
243
246
  else {
244
- content = `Fill text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
247
+ content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
245
248
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
246
249
  "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
247
250
  }
248
251
  process.env.HEAVY_DEBUG && console.log('🪲 OpenAI Prompt 🧠', content);
249
- const { content: respContent, finishReason } = yield this.options.completion.adapter.complete(content, (_m = (_l = this.options.completion) === null || _l === void 0 ? void 0 : _l.expert) === null || _m === void 0 ? void 0 : _m.stop, (_p = (_o = this.options.completion) === null || _o === void 0 ? void 0 : _o.expert) === null || _p === void 0 ? void 0 : _p.maxTokens);
250
- const stop = ((_q = this.options.completion.expert) === null || _q === void 0 ? void 0 : _q.stop) || ['.'];
252
+ const { content: respContent, finishReason } = yield this.options.completion.adapter.complete(content, (_p = (_o = this.options.completion) === null || _o === void 0 ? void 0 : _o.expert) === null || _p === void 0 ? void 0 : _p.stop, (_r = (_q = this.options.completion) === null || _q === void 0 ? void 0 : _q.expert) === null || _r === void 0 ? void 0 : _r.maxTokens);
253
+ const stop = ((_s = this.options.completion.expert) === null || _s === void 0 ? void 0 : _s.stop) || ['.'];
251
254
  let suggestion = respContent + (finishReason === 'stop' ? (stop[0] === '.' && stop.length === 1 ? '. ' : '') : '');
252
255
  if (suggestion.startsWith(currentVal)) {
253
256
  suggestion = suggestion.slice(currentVal.length);
package/index.ts CHANGED
@@ -57,9 +57,11 @@ export default class RichEditorPlugin extends AdminForthPlugin {
57
57
  throw new Error(`Plugin for attachment field '${this.options.attachments!.attachmentFieldName}' not found in resource '${this.options.attachments!.attachmentResource}', please check if Upload Plugin is installed on the field ${this.options.attachments!.attachmentFieldName}`);
58
58
  }
59
59
 
60
- if (plugin.pluginOptions.s3ACL !== 'public-read') {
60
+ if (!plugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
61
61
  throw new Error(`Upload Plugin for attachment field '${this.options.attachments!.attachmentFieldName}' in resource '${this.options.attachments!.attachmentResource}'
62
- should have s3ACL set to 'public-read' (in vast majority of cases signed urls inside of HTML text is not desired behavior, so we did not implement it)`);
62
+ uses adapter which is not configured to store objects in public way, so it will produce only signed private URLs which can not be used in HTML text of blog posts.
63
+ Please configure adapter in such way that it will store objects publicly (e.g. for S3 use 'public-read' ACL).
64
+ `);
63
65
  }
64
66
  this.uploadPlugin = plugin;
65
67
  }
@@ -298,18 +300,19 @@ export default class RichEditorPlugin extends AdminForthPlugin {
298
300
  currentVal = currentVal.slice(-promptLimit);
299
301
  }
300
302
 
303
+ const fieldLabel = this.resourceConfig?.columns.find(c => c.name === this.options.htmlFieldName)?.label || this.options.htmlFieldName;
301
304
  const resLabel = this.resourceConfig!.label;
302
-
305
+
303
306
  let content;
304
307
 
305
308
  if (currentVal) {
306
- content = `Continue writing for text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
309
+ content = `Continue writing for text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
307
310
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
308
311
  `Current field value: ${currentVal}\n` +
309
312
  "Don't talk to me. Just write text. No quotes. Don't repeat current field value, just write completion\n";
310
313
 
311
314
  } else {
312
- content = `Fill text/string field "${this.options.htmlFieldName}" in the table "${resLabel}"\n` +
315
+ content = `Fill text/string field "${fieldLabel}" in the table "${resLabel}"\n` +
313
316
  (Object.keys(recordNoField).length > 0 ? `Record has values for the context: ${inputContext}\n` : '') +
314
317
  "Be short, clear and precise. No quotes. Don't talk to me. Just write text\n";
315
318
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/rich-editor",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Rich editor plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",