@adminforth/i18n 2.0.29 → 2.0.31

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.
Files changed (3) hide show
  1. package/dist/index.js +13 -0
  2. package/index.ts +16 -1
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1026,6 +1026,12 @@ export default class I18nPlugin extends AdminForthPlugin {
1026
1026
  if (resourceId !== this.resourceConfig.resourceId) {
1027
1027
  return { error: 'Invalid resourceId' };
1028
1028
  }
1029
+ if (!field) {
1030
+ return { error: 'No field provided' };
1031
+ }
1032
+ if (recordId === undefined || recordId === null) {
1033
+ return { error: 'No recordId provided' };
1034
+ }
1029
1035
  const resource = this.adminforth.config.resources.find(r => r.resourceId === resourceId);
1030
1036
  // Create update object with just the single field
1031
1037
  const updateRecord = { [field]: value };
@@ -1036,6 +1042,10 @@ export default class I18nPlugin extends AdminForthPlugin {
1036
1042
  yield lock.run(`edit-trans-${recordId}`, () => __awaiter(this, void 0, void 0, function* () {
1037
1043
  // put into lock so 2 editors will not update the same record at the same time
1038
1044
  oldRecord = yield connector.getRecordByPrimaryKey(resource, recordId);
1045
+ if (!oldRecord) {
1046
+ result = { error: 'Record not found' };
1047
+ return;
1048
+ }
1039
1049
  if (this.options.reviewedCheckboxesFieldName) {
1040
1050
  let oldValue;
1041
1051
  if (!oldRecord[this.options.reviewedCheckboxesFieldName]) {
@@ -1069,6 +1079,9 @@ export default class I18nPlugin extends AdminForthPlugin {
1069
1079
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, tr, adminUser }) {
1070
1080
  const selectedLanguages = body.selectedLanguages;
1071
1081
  const selectedIds = body.selectedIds;
1082
+ if (!Array.isArray(selectedIds) || selectedIds.length === 0) {
1083
+ return { ok: false, error: 'No records selected' };
1084
+ }
1072
1085
  const jobId = yield this.bulkTranslate({ selectedIds, selectedLanguages, adminUser });
1073
1086
  return {
1074
1087
  ok: true,
package/index.ts CHANGED
@@ -1257,6 +1257,12 @@ export default class I18nPlugin extends AdminForthPlugin {
1257
1257
  if (resourceId !== this.resourceConfig.resourceId) {
1258
1258
  return { error: 'Invalid resourceId' };
1259
1259
  }
1260
+ if (!field) {
1261
+ return { error: 'No field provided' };
1262
+ }
1263
+ if (recordId === undefined || recordId === null) {
1264
+ return { error: 'No recordId provided' };
1265
+ }
1260
1266
  const resource = this.adminforth.config.resources.find(r => r.resourceId === resourceId);
1261
1267
  // Create update object with just the single field
1262
1268
  const updateRecord = { [field]: value };
@@ -1270,6 +1276,11 @@ export default class I18nPlugin extends AdminForthPlugin {
1270
1276
  // put into lock so 2 editors will not update the same record at the same time
1271
1277
  oldRecord = await connector.getRecordByPrimaryKey(resource, recordId)
1272
1278
 
1279
+ if (!oldRecord) {
1280
+ result = { error: 'Record not found' };
1281
+ return;
1282
+ }
1283
+
1273
1284
  if (this.options.reviewedCheckboxesFieldName) {
1274
1285
  let oldValue;
1275
1286
  if (!oldRecord[this.options.reviewedCheckboxesFieldName]) {
@@ -1307,7 +1318,11 @@ export default class I18nPlugin extends AdminForthPlugin {
1307
1318
  handler: async ({ body, tr, adminUser }) => {
1308
1319
  const selectedLanguages = body.selectedLanguages;
1309
1320
  const selectedIds = body.selectedIds;
1310
-
1321
+
1322
+ if (!Array.isArray(selectedIds) || selectedIds.length === 0) {
1323
+ return { ok: false, error: 'No records selected' };
1324
+ }
1325
+
1311
1326
  const jobId = await this.bulkTranslate({ selectedIds, selectedLanguages, adminUser });
1312
1327
 
1313
1328
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "2.0.29",
3
+ "version": "2.0.31",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -38,11 +38,11 @@
38
38
  "p-limit": "^7.3.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "adminforth": "^3.6.2"
41
+ "adminforth": "^3.6.21"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^22.10.7",
45
- "adminforth": "^3.6.2",
45
+ "adminforth": "^3.6.21",
46
46
  "i18n-iso-countries": "^7.13.0",
47
47
  "semantic-release": "^24.2.1",
48
48
  "semantic-release-slack-bot": "^4.0.2",