@adminforth/quick-filters 1.1.0 → 1.2.0
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 +1 -1
- package/dist/index.js +8 -11
- package/index.ts +8 -13
- package/package.json +1 -1
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { AdminForthPlugin } from "adminforth";
|
|
11
|
+
import { suggestIfTypo } from "adminforth";
|
|
11
12
|
export default class extends AdminForthPlugin {
|
|
12
13
|
constructor(options) {
|
|
13
14
|
super(options, import.meta.url);
|
|
@@ -33,21 +34,17 @@ export default class extends AdminForthPlugin {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
validateConfigAfterDiscover(adminforth, resourceConfig) {
|
|
36
|
-
|
|
37
|
+
for (const colOpt of this.options.columns) {
|
|
38
|
+
const column = resourceConfig.columns.find(c => c.name === colOpt.column);
|
|
39
|
+
if (!column) {
|
|
40
|
+
const similar = suggestIfTypo(resourceConfig.columns.map((column) => column.name), colOpt.column);
|
|
41
|
+
throw new Error(`QuickFilters plugin: column '${colOpt.column}' not found in resource '${resourceConfig.resourceId}'. Did you mean '${similar}'?`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
37
44
|
}
|
|
38
45
|
instanceUniqueRepresentation(pluginOptions) {
|
|
39
46
|
// optional method to return unique string representation of plugin instance.
|
|
40
47
|
// Needed if plugin can have multiple instances on one resource
|
|
41
48
|
return `single`;
|
|
42
49
|
}
|
|
43
|
-
setupEndpoints(server) {
|
|
44
|
-
server.endpoint({
|
|
45
|
-
method: 'POST',
|
|
46
|
-
path: `/plugin/${this.pluginInstanceId}/example`,
|
|
47
|
-
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body }) {
|
|
48
|
-
const { name } = body;
|
|
49
|
-
return { hey: `Hello ${name}` };
|
|
50
|
-
})
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
50
|
}
|
package/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AdminForthPlugin } from "adminforth";
|
|
2
2
|
import type { IAdminForth, IHttpServer, AdminForthResourcePages, AdminForthResourceColumn, AdminForthDataTypes, AdminForthResource, AdminForthComponentDeclaration } from "adminforth";
|
|
3
3
|
import type { PluginOptions } from './types.js';
|
|
4
|
-
|
|
4
|
+
import { suggestIfTypo } from "adminforth";
|
|
5
5
|
|
|
6
6
|
export default class extends AdminForthPlugin {
|
|
7
7
|
options: PluginOptions;
|
|
@@ -30,7 +30,13 @@ export default class extends AdminForthPlugin {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
|
|
33
|
-
|
|
33
|
+
for ( const colOpt of this.options.columns ) {
|
|
34
|
+
const column = resourceConfig.columns.find(c => c.name === colOpt.column);
|
|
35
|
+
if ( !column ) {
|
|
36
|
+
const similar = suggestIfTypo(resourceConfig.columns.map((column: any) => column.name), colOpt.column);
|
|
37
|
+
throw new Error(`QuickFilters plugin: column '${colOpt.column}' not found in resource '${resourceConfig.resourceId}'. Did you mean '${similar}'?`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
instanceUniqueRepresentation(pluginOptions: any) : string {
|
|
@@ -39,15 +45,4 @@ export default class extends AdminForthPlugin {
|
|
|
39
45
|
return `single`;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
setupEndpoints(server: IHttpServer) {
|
|
43
|
-
server.endpoint({
|
|
44
|
-
method: 'POST',
|
|
45
|
-
path: `/plugin/${this.pluginInstanceId}/example`,
|
|
46
|
-
handler: async ({ body }) => {
|
|
47
|
-
const { name } = body;
|
|
48
|
-
return { hey: `Hello ${name}` };
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
}
|