@adminforth/import-export 1.5.1 → 1.5.3

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
@@ -115,6 +115,9 @@ export default class ImportExport extends AdminForthPlugin {
115
115
  path: `/plugin/${this.pluginInstanceId}/export-csv`,
116
116
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers }) {
117
117
  const { filters, sort } = body;
118
+ if (!filters || !sort) {
119
+ return { ok: false, error: 'Missing filters or sort in request body' };
120
+ }
118
121
  const access = yield this.ensureAnyAllowed(adminUser, [
119
122
  { source: ActionCheckSource.ListRequest, action: AllowedActionsEnum.list },
120
123
  { source: ActionCheckSource.ShowRequest, action: AllowedActionsEnum.show },
@@ -159,6 +162,9 @@ export default class ImportExport extends AdminForthPlugin {
159
162
  path: `/plugin/${this.pluginInstanceId}/import-csv`,
160
163
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, query, headers, cookies, requestUrl, response }) {
161
164
  const { data } = body;
165
+ if (!data || typeof data !== 'object') {
166
+ return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
167
+ }
162
168
  const createEditAccess = yield this.ensureAnyAllowed(adminUser, [
163
169
  { source: ActionCheckSource.CreateRequest, action: AllowedActionsEnum.create },
164
170
  { source: ActionCheckSource.EditRequest, action: AllowedActionsEnum.edit }
@@ -228,6 +234,9 @@ export default class ImportExport extends AdminForthPlugin {
228
234
  path: `/plugin/${this.pluginInstanceId}/import-csv-new-only`,
229
235
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, query, headers, cookies, requestUrl, response }) {
230
236
  const { data } = body;
237
+ if (!data || typeof data !== 'object') {
238
+ return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
239
+ }
231
240
  const access = yield this.ensureAnyAllowed(adminUser, [{ source: ActionCheckSource.CreateRequest, action: AllowedActionsEnum.create }], { requestBody: body });
232
241
  if (!access.ok) {
233
242
  return { ok: false, error: access.error };
package/index.ts CHANGED
@@ -129,6 +129,9 @@ export default class ImportExport extends AdminForthPlugin {
129
129
  path: `/plugin/${this.pluginInstanceId}/export-csv`,
130
130
  handler: async ({ body, adminUser, headers }) => {
131
131
  const { filters, sort } = body;
132
+ if (!filters || !sort) {
133
+ return { ok: false, error: 'Missing filters or sort in request body' };
134
+ }
132
135
  const access = await this.ensureAnyAllowed(
133
136
  adminUser,
134
137
  [
@@ -184,6 +187,9 @@ export default class ImportExport extends AdminForthPlugin {
184
187
  path: `/plugin/${this.pluginInstanceId}/import-csv`,
185
188
  handler: async ({ body, adminUser, query, headers, cookies, requestUrl, response }) => {
186
189
  const { data } = body;
190
+ if (!data || typeof data !== 'object') {
191
+ return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
192
+ }
187
193
  const createEditAccess = await this.ensureAnyAllowed(
188
194
  adminUser,
189
195
  [
@@ -263,6 +269,9 @@ export default class ImportExport extends AdminForthPlugin {
263
269
  path: `/plugin/${this.pluginInstanceId}/import-csv-new-only`,
264
270
  handler: async ({ body, adminUser, query, headers, cookies, requestUrl, response }) => {
265
271
  const { data } = body;
272
+ if (!data || typeof data !== 'object') {
273
+ return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
274
+ }
266
275
  const access = await this.ensureAnyAllowed(
267
276
  adminUser,
268
277
  [{ source: ActionCheckSource.CreateRequest, action: AllowedActionsEnum.create }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/import-export",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -25,11 +25,11 @@
25
25
  "license": "MIT",
26
26
  "description": "CSV import/export plugin for adminforth",
27
27
  "peerDependencies": {
28
- "adminforth": "^3.1.0"
28
+ "adminforth": "^3.6.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.10.7",
32
- "adminforth": "^3.4.0",
32
+ "adminforth": "^3.6.2",
33
33
  "semantic-release": "^24.2.1",
34
34
  "semantic-release-slack-bot": "^4.0.2",
35
35
  "typescript": "^5.7.3"