@adminforth/bulk-ai-flow 1.23.1 → 1.23.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/build.log +1 -1
- package/dist/index.js +25 -2
- package/index.ts +26 -2
- package/package.json +2 -2
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { AdminForthFilterOperators, AdminForthPlugin, Filters } from "adminforth";
|
|
11
|
-
import { suggestIfTypo } from "adminforth";
|
|
11
|
+
import { suggestIfTypo, filtersTools } from "adminforth";
|
|
12
12
|
import Handlebars from 'handlebars';
|
|
13
13
|
import { RateLimiter } from "adminforth";
|
|
14
14
|
import { randomUUID } from "crypto";
|
|
@@ -1035,7 +1035,30 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
1035
1035
|
server.endpoint({
|
|
1036
1036
|
method: 'POST',
|
|
1037
1037
|
path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
|
|
1038
|
-
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers }) {
|
|
1038
|
+
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, query, cookies, requestUrl }) {
|
|
1039
|
+
var _b, _c;
|
|
1040
|
+
const resource = this.resourceConfig;
|
|
1041
|
+
for (const hook of ((_c = (_b = resource.hooks) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.beforeDatasourceRequest) || []) {
|
|
1042
|
+
const filterTools = filtersTools.get(body);
|
|
1043
|
+
body.filtersTools = filterTools;
|
|
1044
|
+
const resp = yield hook({
|
|
1045
|
+
resource,
|
|
1046
|
+
query: body,
|
|
1047
|
+
adminUser,
|
|
1048
|
+
//@ts-ignore
|
|
1049
|
+
filtersTools: filterTools,
|
|
1050
|
+
extra: {
|
|
1051
|
+
body, query, headers, cookies, requestUrl
|
|
1052
|
+
},
|
|
1053
|
+
adminforth: this.adminforth,
|
|
1054
|
+
});
|
|
1055
|
+
if (!resp || (!resp.ok && !resp.error)) {
|
|
1056
|
+
throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
|
|
1057
|
+
}
|
|
1058
|
+
if (resp.error) {
|
|
1059
|
+
return { error: resp.error };
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1039
1062
|
const filters = body.filters;
|
|
1040
1063
|
const normalizedFilters = { operator: AdminForthFilterOperators.AND, subFilters: [] };
|
|
1041
1064
|
if (filters) {
|
package/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AdminForthFilterOperators, AdminForthPlugin, Filters } from "adminforth";
|
|
2
2
|
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResource } from "adminforth";
|
|
3
|
-
import { suggestIfTypo } from "adminforth";
|
|
3
|
+
import { suggestIfTypo, filtersTools } from "adminforth";
|
|
4
4
|
import type { PluginOptions } from './types.js';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
6
6
|
import { RateLimiter } from "adminforth";
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
const STUB_MODE = false;
|
|
10
11
|
const jobs = new Map();
|
|
11
12
|
export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
@@ -1068,7 +1069,30 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
1068
1069
|
server.endpoint({
|
|
1069
1070
|
method: 'POST',
|
|
1070
1071
|
path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
|
|
1071
|
-
handler: async ({ body, adminUser, headers }) => {
|
|
1072
|
+
handler: async ({ body, adminUser, headers, query, cookies, requestUrl }) => {
|
|
1073
|
+
const resource = this.resourceConfig;
|
|
1074
|
+
|
|
1075
|
+
for (const hook of resource.hooks?.list?.beforeDatasourceRequest || []) {
|
|
1076
|
+
const filterTools = filtersTools.get(body);
|
|
1077
|
+
body.filtersTools = filterTools;
|
|
1078
|
+
const resp = await hook({
|
|
1079
|
+
resource,
|
|
1080
|
+
query: body,
|
|
1081
|
+
adminUser,
|
|
1082
|
+
//@ts-ignore
|
|
1083
|
+
filtersTools: filterTools,
|
|
1084
|
+
extra: {
|
|
1085
|
+
body, query, headers, cookies, requestUrl
|
|
1086
|
+
},
|
|
1087
|
+
adminforth: this.adminforth,
|
|
1088
|
+
});
|
|
1089
|
+
if (!resp || (!resp.ok && !resp.error)) {
|
|
1090
|
+
throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
|
|
1091
|
+
}
|
|
1092
|
+
if (resp.error) {
|
|
1093
|
+
return { error: resp.error };
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1072
1096
|
const filters = body.filters;
|
|
1073
1097
|
|
|
1074
1098
|
const normalizedFilters = { operator: AdminForthFilterOperators.AND, subFilters: [] };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/bulk-ai-flow",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"handlebars": "^4.7.8"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"adminforth": "
|
|
33
|
+
"adminforth": "^2.21.1"
|
|
34
34
|
},
|
|
35
35
|
"release": {
|
|
36
36
|
"plugins": [
|