@adminforth/i18n 3.1.4 → 3.1.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/build.log CHANGED
@@ -20,5 +20,5 @@ custom/package.json
20
20
  custom/pnpm-lock.yaml
21
21
  custom/tsconfig.json
22
22
 
23
- sent 45,486 bytes received 305 bytes 91,582.00 bytes/sec
24
- total size is 44,318 speedup is 0.97
23
+ sent 45,755 bytes received 305 bytes 92,120.00 bytes/sec
24
+ total size is 44,587 speedup is 0.97
@@ -98,8 +98,10 @@
98
98
  const allChecked = computed(() => Object.values(checkedLanguages.value).every(Boolean));
99
99
  const noneChecked = computed(() => Object.values(checkedLanguages.value).every(value => !value));
100
100
 
101
+ let unsubscribeFromTranslationProgress: () => void;
102
+
101
103
  onMounted(() => {
102
- websocket.subscribe('/translation_progress', (data) => {
104
+ unsubscribeFromTranslationProgress = websocket.subscribe('/translation_progress', (data) => {
103
105
  adminforth.list.refresh();
104
106
  });
105
107
  for (const lang of props.meta.supportedLanguages) {
@@ -108,7 +110,7 @@
108
110
  });
109
111
 
110
112
  onUnmounted( () => {
111
- websocket.unsubscribe('/translation_progress');
113
+ unsubscribeFromTranslationProgress();
112
114
  } )
113
115
 
114
116
  function selectAll() {
@@ -45,7 +45,7 @@ watch(() => selectedLanguage.value, async (newVal) => {
45
45
  return;
46
46
  }
47
47
  await setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, newVal);
48
- coreStore.getPublicConfig();
48
+ coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false });
49
49
  coreStore.getLoginFormConfig();
50
50
  });
51
51
 
@@ -135,10 +135,12 @@ async function loadPage(targetPage: number) {
135
135
  }
136
136
  }
137
137
 
138
- onMounted(async () => {
139
- await loadPage(0);
138
+ let unsubscribeFromTaskUpdates: () => void;
139
+ let unsubscribeFromTaskErrors: () => void;
140
140
 
141
- websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
141
+ onMounted(async () => {
142
+ // subscribe before the first await, so onUnmounted always has something to unsubscribe
143
+ unsubscribeFromTaskUpdates = websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
142
144
  const indexOnPage = data.taskIndex - currentOffset.value;
143
145
  if (indexOnPage >= 0 && indexOnPage < translationTasks.value.length) {
144
146
  if (data.state) {
@@ -149,15 +151,16 @@ onMounted(async () => {
149
151
  }
150
152
  }
151
153
  });
152
- websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
154
+ unsubscribeFromTaskErrors = websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
153
155
  console.log('Error received for task', data);
154
156
  });
155
157
 
158
+ await loadPage(0);
156
159
  });
157
160
 
158
161
  onUnmounted(() => {
159
- websocket.unsubscribe(`/background-jobs-task-update/${props.job.id}`);
160
- websocket.unsubscribe(`/background-jobs-task-error/${props.job.id}`);
162
+ unsubscribeFromTaskUpdates();
163
+ unsubscribeFromTaskErrors();
161
164
  });
162
165
 
163
166
 
@@ -98,8 +98,10 @@
98
98
  const allChecked = computed(() => Object.values(checkedLanguages.value).every(Boolean));
99
99
  const noneChecked = computed(() => Object.values(checkedLanguages.value).every(value => !value));
100
100
 
101
+ let unsubscribeFromTranslationProgress: () => void;
102
+
101
103
  onMounted(() => {
102
- websocket.subscribe('/translation_progress', (data) => {
104
+ unsubscribeFromTranslationProgress = websocket.subscribe('/translation_progress', (data) => {
103
105
  adminforth.list.refresh();
104
106
  });
105
107
  for (const lang of props.meta.supportedLanguages) {
@@ -108,7 +110,7 @@
108
110
  });
109
111
 
110
112
  onUnmounted( () => {
111
- websocket.unsubscribe('/translation_progress');
113
+ unsubscribeFromTranslationProgress();
112
114
  } )
113
115
 
114
116
  function selectAll() {
@@ -45,7 +45,7 @@ watch(() => selectedLanguage.value, async (newVal) => {
45
45
  return;
46
46
  }
47
47
  await setLang({ setLocaleMessage, locale }, props.meta.pluginInstanceId, newVal);
48
- coreStore.getPublicConfig();
48
+ coreStore.fetchConfig({ redirectToLoginIfNotLoggedIn: false });
49
49
  coreStore.getLoginFormConfig();
50
50
  });
51
51
 
@@ -135,10 +135,12 @@ async function loadPage(targetPage: number) {
135
135
  }
136
136
  }
137
137
 
138
- onMounted(async () => {
139
- await loadPage(0);
138
+ let unsubscribeFromTaskUpdates: () => void;
139
+ let unsubscribeFromTaskErrors: () => void;
140
140
 
141
- websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
141
+ onMounted(async () => {
142
+ // subscribe before the first await, so onUnmounted always has something to unsubscribe
143
+ unsubscribeFromTaskUpdates = websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
142
144
  const indexOnPage = data.taskIndex - currentOffset.value;
143
145
  if (indexOnPage >= 0 && indexOnPage < translationTasks.value.length) {
144
146
  if (data.state) {
@@ -149,15 +151,16 @@ onMounted(async () => {
149
151
  }
150
152
  }
151
153
  });
152
- websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
154
+ unsubscribeFromTaskErrors = websocket.subscribe(`/background-jobs-task-error/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => {
153
155
  console.log('Error received for task', data);
154
156
  });
155
157
 
158
+ await loadPage(0);
156
159
  });
157
160
 
158
161
  onUnmounted(() => {
159
- websocket.unsubscribe(`/background-jobs-task-update/${props.job.id}`);
160
- websocket.unsubscribe(`/background-jobs-task-error/${props.job.id}`);
162
+ unsubscribeFromTaskUpdates();
163
+ unsubscribeFromTaskErrors();
161
164
  });
162
165
 
163
166
 
package/dist/index.js CHANGED
@@ -280,10 +280,10 @@ export default class I18nPlugin extends I18nBase {
280
280
  return { ok: true };
281
281
  }));
282
282
  // also add edit hook beforeSave to update completedFieldName
283
- resourceConfig.hooks.edit.beforeSave.push((_a) => __awaiter(this, [_a], void 0, function* ({ record, oldRecord }) {
284
- const futureRecord = Object.assign(Object.assign({}, oldRecord), record);
283
+ resourceConfig.hooks.edit.beforeSave.push((_a) => __awaiter(this, [_a], void 0, function* ({ updates, oldRecord }) {
284
+ const futureRecord = Object.assign(Object.assign({}, oldRecord), updates);
285
285
  const futureCompletedFieldValue = yield this.computeCompletedFieldValue(futureRecord);
286
- record[this.options.completedFieldName] = futureCompletedFieldValue;
286
+ updates[this.options.completedFieldName] = futureCompletedFieldValue;
287
287
  return { ok: true };
288
288
  }));
289
289
  // add list hook to support filtering by fully_translated virtual field
@@ -860,6 +860,7 @@ export default class I18nPlugin extends I18nBase {
860
860
  server.endpoint({
861
861
  method: 'POST',
862
862
  path: `/plugin/${this.pluginInstanceId}/update-field`,
863
+ agent: { hiddenFromAgents: true },
863
864
  request_schema: updateFieldBodySchema,
864
865
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, response }) {
865
866
  const data = body;
@@ -907,7 +908,7 @@ export default class I18nPlugin extends I18nBase {
907
908
  result = yield this.adminforth.updateResourceRecord({
908
909
  resource,
909
910
  recordId,
910
- record: updateRecord,
911
+ updates: updateRecord,
911
912
  oldRecord,
912
913
  adminUser
913
914
  });
@@ -945,6 +946,7 @@ export default class I18nPlugin extends I18nBase {
945
946
  server.endpoint({
946
947
  method: 'POST',
947
948
  path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
949
+ agent: { hiddenFromAgents: true },
948
950
  request_schema: getFilteredIdsBodySchema,
949
951
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, query, cookies, requestUrl, response }) {
950
952
  var _b, _c;
package/index.ts CHANGED
@@ -332,12 +332,12 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
332
332
  });
333
333
 
334
334
  // also add edit hook beforeSave to update completedFieldName
335
- resourceConfig.hooks.edit.beforeSave.push(async ({ record, oldRecord }: { record: any, oldRecord: any }): Promise<{ ok: boolean, error?: string }> => {
336
- const futureRecord = { ...oldRecord, ...record };
335
+ resourceConfig.hooks.edit.beforeSave.push(async ({ updates, oldRecord }: { updates: any, oldRecord: any }): Promise<{ ok: boolean, error?: string }> => {
336
+ const futureRecord = { ...oldRecord, ...updates };
337
337
 
338
338
  const futureCompletedFieldValue = await this.computeCompletedFieldValue(futureRecord);
339
339
 
340
- record[this.options.completedFieldName] = futureCompletedFieldValue;
340
+ updates[this.options.completedFieldName] = futureCompletedFieldValue;
341
341
  return { ok: true };
342
342
  });
343
343
 
@@ -1071,6 +1071,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
1071
1071
  server.endpoint({
1072
1072
  method: 'POST',
1073
1073
  path: `/plugin/${this.pluginInstanceId}/update-field`,
1074
+ agent: { hiddenFromAgents: true },
1074
1075
  request_schema: updateFieldBodySchema,
1075
1076
  handler: async ({ body, adminUser, headers, response }) => {
1076
1077
  const data = body as z.infer<typeof updateFieldBodySchema>;
@@ -1129,7 +1130,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
1129
1130
  result = await this.adminforth.updateResourceRecord({
1130
1131
  resource,
1131
1132
  recordId,
1132
- record: updateRecord,
1133
+ updates: updateRecord,
1133
1134
  oldRecord,
1134
1135
  adminUser
1135
1136
  });
@@ -1175,6 +1176,7 @@ export default class I18nPlugin extends I18nBase<PluginOptions> {
1175
1176
  server.endpoint({
1176
1177
  method: 'POST',
1177
1178
  path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
1179
+ agent: { hiddenFromAgents: true },
1178
1180
  request_schema: getFilteredIdsBodySchema,
1179
1181
  handler: async ({ body, adminUser, headers, query, cookies, requestUrl, response }) => {
1180
1182
  const resource = this.resourceConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^22.10.7",
46
- "adminforth": "^3.8.2",
46
+ "adminforth": "^4.7.3",
47
47
  "i18n-iso-countries": "^7.13.0",
48
48
  "semantic-release": "^24.2.1",
49
49
  "semantic-release-slack-bot": "^4.0.2",