@adminforth/i18n 1.0.5 → 1.0.6

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/dist/index.js CHANGED
@@ -398,6 +398,9 @@ ${JSON.stringify(strings.reduce((acc, s) => {
398
398
  if (exists) {
399
399
  return;
400
400
  }
401
+ if (!key) {
402
+ throw new Error(`Faced an empty key in Fronted messages, file ${file}`);
403
+ }
401
404
  const record = Object.assign({ [this.enFieldName]: key, [this.options.categoryFieldName]: category }, (this.options.sourceFieldName ? { [this.options.sourceFieldName]: file } : {}));
402
405
  try {
403
406
  yield adminforth.resource(this.resourceConfig.resourceId).create(record);
@@ -472,6 +475,9 @@ ${JSON.stringify(strings.reduce((acc, s) => {
472
475
  const resource = adminforth.resource(resourceConfig.resourceId);
473
476
  const translation = yield resource.get([Filters.EQ(this.enFieldName, msg), Filters.EQ(this.options.categoryFieldName, category)]);
474
477
  if (!translation) {
478
+ if (!msg) {
479
+ throw Error(`Empty string passed to tr function during translation`);
480
+ }
475
481
  yield resource.create({
476
482
  [this.enFieldName]: msg,
477
483
  [this.options.categoryFieldName]: category,
package/index.ts CHANGED
@@ -475,6 +475,9 @@ ${
475
475
  if (exists) {
476
476
  return;
477
477
  }
478
+ if (!key) {
479
+ throw new Error(`Faced an empty key in Fronted messages, file ${file}`);
480
+ }
478
481
  const record = {
479
482
  [this.enFieldName]: key,
480
483
  [this.options.categoryFieldName]: category,
@@ -560,6 +563,10 @@ ${
560
563
  const resource = adminforth.resource(resourceConfig.resourceId);
561
564
  const translation = await resource.get([Filters.EQ(this.enFieldName, msg), Filters.EQ(this.options.categoryFieldName, category)]);
562
565
  if (!translation) {
566
+
567
+ if (!msg) {
568
+ throw Error(`Empty string passed to tr function during translation`);
569
+ }
563
570
  await resource.create({
564
571
  [this.enFieldName]: msg,
565
572
  [this.options.categoryFieldName]: category,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",