@adminforth/import-export 1.6.1 → 1.6.2
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 +9 -17
- package/index.ts +9 -13
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { AdminForthPlugin,
|
|
10
|
+
import { AdminForthPlugin, suggestIfTypo, AdminForthFilterOperators, Filters, AdminForthDataTypes, rejectApiRawFilters, interpretResource, ActionCheckSource, AllowedActionsEnum } from "adminforth";
|
|
11
11
|
import pLimit from 'p-limit';
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
const exportCsvBodySchema = z.object({
|
|
@@ -121,11 +121,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
121
121
|
server.endpoint({
|
|
122
122
|
method: 'POST',
|
|
123
123
|
path: `/plugin/${this.pluginInstanceId}/export-csv`,
|
|
124
|
+
request_schema: exportCsvBodySchema,
|
|
124
125
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, response }) {
|
|
125
|
-
const
|
|
126
|
-
if ('error' in parsed)
|
|
127
|
-
return parsed.error;
|
|
128
|
-
const payload = parsed.data;
|
|
126
|
+
const payload = body;
|
|
129
127
|
const { filters, sort } = payload;
|
|
130
128
|
if (!filters || !sort) {
|
|
131
129
|
return { ok: false, error: 'Missing filters or sort in request body' };
|
|
@@ -179,11 +177,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
179
177
|
server.endpoint({
|
|
180
178
|
method: 'POST',
|
|
181
179
|
path: `/plugin/${this.pluginInstanceId}/import-csv`,
|
|
180
|
+
request_schema: importCsvBodySchema,
|
|
182
181
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, query, headers, cookies, requestUrl, response }) {
|
|
183
|
-
const
|
|
184
|
-
if ('error' in parsed)
|
|
185
|
-
return parsed.error;
|
|
186
|
-
const payload = parsed.data;
|
|
182
|
+
const payload = body;
|
|
187
183
|
const { data } = payload;
|
|
188
184
|
if (!data || typeof data !== 'object') {
|
|
189
185
|
return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
|
|
@@ -255,11 +251,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
255
251
|
server.endpoint({
|
|
256
252
|
method: 'POST',
|
|
257
253
|
path: `/plugin/${this.pluginInstanceId}/import-csv-new-only`,
|
|
254
|
+
request_schema: importCsvBodySchema,
|
|
258
255
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, query, headers, cookies, requestUrl, response }) {
|
|
259
|
-
const
|
|
260
|
-
if ('error' in parsed)
|
|
261
|
-
return parsed.error;
|
|
262
|
-
const payload = parsed.data;
|
|
256
|
+
const payload = body;
|
|
263
257
|
const { data } = payload;
|
|
264
258
|
if (!data || typeof data !== 'object') {
|
|
265
259
|
return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
|
|
@@ -311,11 +305,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
311
305
|
server.endpoint({
|
|
312
306
|
method: 'POST',
|
|
313
307
|
path: `/plugin/${this.pluginInstanceId}/check-records`,
|
|
308
|
+
request_schema: importCsvBodySchema,
|
|
314
309
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, response }) {
|
|
315
|
-
const
|
|
316
|
-
if ('error' in parsed)
|
|
317
|
-
return parsed.error;
|
|
318
|
-
const payload = parsed.data;
|
|
310
|
+
const payload = body;
|
|
319
311
|
const access = yield this.ensureAnyAllowed(adminUser, [
|
|
320
312
|
{ source: ActionCheckSource.ListRequest, action: AllowedActionsEnum.list },
|
|
321
313
|
{ source: ActionCheckSource.ShowRequest, action: AllowedActionsEnum.show },
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdminForthPlugin,
|
|
1
|
+
import { AdminForthPlugin, suggestIfTypo, AdminForthFilterOperators, Filters, AdminForthDataTypes, rejectApiRawFilters, interpretResource, ActionCheckSource, AllowedActionsEnum } from "adminforth";
|
|
2
2
|
import type { IAdminForth, IHttpServer, AdminForthResourceColumn, AdminForthComponentDeclaration, AdminForthResource, AdminUser } from "adminforth";
|
|
3
3
|
import type { PluginOptions } from './types.js';
|
|
4
4
|
import pLimit from 'p-limit';
|
|
@@ -137,10 +137,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
137
137
|
server.endpoint({
|
|
138
138
|
method: 'POST',
|
|
139
139
|
path: `/plugin/${this.pluginInstanceId}/export-csv`,
|
|
140
|
+
request_schema: exportCsvBodySchema,
|
|
140
141
|
handler: async ({ body, adminUser, headers, response }) => {
|
|
141
|
-
const
|
|
142
|
-
if ('error' in parsed) return parsed.error;
|
|
143
|
-
const payload = parsed.data;
|
|
142
|
+
const payload = body as z.infer<typeof exportCsvBodySchema>;
|
|
144
143
|
const { filters, sort } = payload;
|
|
145
144
|
if (!filters || !sort) {
|
|
146
145
|
return { ok: false, error: 'Missing filters or sort in request body' };
|
|
@@ -204,10 +203,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
204
203
|
server.endpoint({
|
|
205
204
|
method: 'POST',
|
|
206
205
|
path: `/plugin/${this.pluginInstanceId}/import-csv`,
|
|
206
|
+
request_schema: importCsvBodySchema,
|
|
207
207
|
handler: async ({ body, adminUser, query, headers, cookies, requestUrl, response }) => {
|
|
208
|
-
const
|
|
209
|
-
if ('error' in parsed) return parsed.error;
|
|
210
|
-
const payload = parsed.data;
|
|
208
|
+
const payload = body as z.infer<typeof importCsvBodySchema>;
|
|
211
209
|
const { data } = payload;
|
|
212
210
|
if (!data || typeof data !== 'object') {
|
|
213
211
|
return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
|
|
@@ -289,10 +287,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
289
287
|
server.endpoint({
|
|
290
288
|
method: 'POST',
|
|
291
289
|
path: `/plugin/${this.pluginInstanceId}/import-csv-new-only`,
|
|
290
|
+
request_schema: importCsvBodySchema,
|
|
292
291
|
handler: async ({ body, adminUser, query, headers, cookies, requestUrl, response }) => {
|
|
293
|
-
const
|
|
294
|
-
if ('error' in parsed) return parsed.error;
|
|
295
|
-
const payload = parsed.data;
|
|
292
|
+
const payload = body as z.infer<typeof importCsvBodySchema>;
|
|
296
293
|
const { data } = payload;
|
|
297
294
|
if (!data || typeof data !== 'object') {
|
|
298
295
|
return { ok: false, error: 'Invalid data format. Expected an object with column names as keys and arrays of values as values.' };
|
|
@@ -353,10 +350,9 @@ export default class ImportExport extends AdminForthPlugin {
|
|
|
353
350
|
server.endpoint({
|
|
354
351
|
method: 'POST',
|
|
355
352
|
path: `/plugin/${this.pluginInstanceId}/check-records`,
|
|
353
|
+
request_schema: importCsvBodySchema,
|
|
356
354
|
handler: async ({ body, adminUser, response }) => {
|
|
357
|
-
const
|
|
358
|
-
if ('error' in parsed) return parsed.error;
|
|
359
|
-
const payload = parsed.data;
|
|
355
|
+
const payload = body as z.infer<typeof importCsvBodySchema>;
|
|
360
356
|
const access = await this.ensureAnyAllowed(
|
|
361
357
|
adminUser,
|
|
362
358
|
[
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/import-export",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
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.
|
|
28
|
+
"adminforth": "^3.8.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.7",
|
|
32
|
-
"adminforth": "^3.
|
|
32
|
+
"adminforth": "^3.8.2",
|
|
33
33
|
"semantic-release": "^24.2.1",
|
|
34
34
|
"semantic-release-slack-bot": "^4.0.2",
|
|
35
35
|
"typescript": "^5.7.3"
|