strapi-plugin-comments 2.2.9 → 2.2.11
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/README.md +116 -23
- package/admin/src/index.js +1 -1
- package/admin/src/translations/index.d.ts +1 -1
- package/admin/src/translations/index.js +4 -0
- package/admin/src/translations/ru.json +192 -0
- package/admin/src/translations/zh-Hans.json +192 -0
- package/package.json +3 -3
- package/server/controllers/client.js +18 -0
- package/server/graphql/queries/findAllPerAuthor.d.ts +21 -0
- package/server/graphql/queries/findAllPerAuthor.js +40 -0
- package/server/graphql/queries/index.js +2 -0
- package/server/graphql/types/comment-author-type.d.ts +4 -0
- package/server/graphql/types/comment-author-type.js +8 -0
- package/server/graphql/types/index.js +4 -0
- package/server/graphql/types/response-find-all-per-author.d.ts +4 -0
- package/server/graphql/types/response-find-all-per-author.js +9 -0
- package/server/routes/client.js +28 -0
- package/server/services/common.js +34 -49
- package/server/services/utils/parsers.d.ts +6 -0
- package/server/services/utils/parsers.js +63 -0
- package/server/utils/constants.d.ts +4 -0
- package/server/utils/constants.js +5 -1
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-plugin-comments",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.11",
|
|
4
4
|
"description": "Strapi - Comments plugin",
|
|
5
5
|
"strapi": {
|
|
6
6
|
"name": "comments",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@strapi/plugin-graphql": "^4.
|
|
18
|
-
"@strapi/utils": "^4.
|
|
17
|
+
"@strapi/plugin-graphql": "^4.10.7",
|
|
18
|
+
"@strapi/utils": "^4.10.7",
|
|
19
19
|
"@types/axios": "^0.14.0",
|
|
20
20
|
"@types/react-intl": "^3.0.0",
|
|
21
21
|
"@types/react-query": "^1.2.9",
|
|
@@ -7,6 +7,7 @@ const functions_1 = require("./../utils/functions");
|
|
|
7
7
|
const functions_2 = require("./utils/functions");
|
|
8
8
|
const parsers_1 = require("./utils/parsers");
|
|
9
9
|
const error_1 = __importDefault(require("../utils/error"));
|
|
10
|
+
const constants_1 = require("../utils/constants");
|
|
10
11
|
const controllers = {
|
|
11
12
|
getService(name = "client") {
|
|
12
13
|
return (0, functions_1.getPluginService)(name);
|
|
@@ -49,6 +50,23 @@ const controllers = {
|
|
|
49
50
|
throw (0, functions_2.throwError)(ctx, e);
|
|
50
51
|
}
|
|
51
52
|
},
|
|
53
|
+
async findAllPerAuthor(ctx) {
|
|
54
|
+
const { params = {}, query, sort, pagination } = ctx;
|
|
55
|
+
const { id, type } = (0, functions_2.parseParams)(params);
|
|
56
|
+
const { sort: querySort, pagination: queryPagination, fields, ...filterQuery } = query || {};
|
|
57
|
+
try {
|
|
58
|
+
(0, functions_1.assertParamsPresent)(params, ["id"]);
|
|
59
|
+
return this.getService("common").findAllPerAuthor((0, parsers_1.flatInput)({
|
|
60
|
+
query: filterQuery,
|
|
61
|
+
sort: sort || querySort,
|
|
62
|
+
pagination: pagination || queryPagination,
|
|
63
|
+
fields,
|
|
64
|
+
}), id, ![constants_1.AUTHOR_TYPE.GENERIC.toLowerCase(), constants_1.AUTHOR_TYPE.GENERIC].includes(type));
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
throw (0, functions_2.throwError)(ctx, e);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
52
70
|
async post(ctx) {
|
|
53
71
|
const { request, params, state = {} } = ctx;
|
|
54
72
|
const { relation } = (0, functions_2.parseParams)(params);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Id, StrapiGraphQLContext, ToBeFixed } from "../../../types";
|
|
2
|
+
type ResponseFindAllPerAuthorResolverProps = {
|
|
3
|
+
authorId: Id;
|
|
4
|
+
authorType: 'STRAPI' | 'GENERIC' | undefined;
|
|
5
|
+
filters: ToBeFixed;
|
|
6
|
+
sort: ToBeFixed;
|
|
7
|
+
pagination: ToBeFixed;
|
|
8
|
+
};
|
|
9
|
+
declare const _default: ({ strapi, nexus }: StrapiGraphQLContext) => {
|
|
10
|
+
type: string;
|
|
11
|
+
args: {
|
|
12
|
+
authorId: any;
|
|
13
|
+
authorType: any;
|
|
14
|
+
filters: any;
|
|
15
|
+
pagination: any;
|
|
16
|
+
sort: any;
|
|
17
|
+
};
|
|
18
|
+
resolve(obj: Object, args: ResponseFindAllPerAuthorResolverProps): Promise<import("strapi-typed").StrapiPaginatedResponse<import("../../../types").Comment<import("../../../types").CommentAuthor>>>;
|
|
19
|
+
};
|
|
20
|
+
export = _default;
|
|
21
|
+
//# sourceMappingURL=findAllPerAuthor.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const comment_1 = __importDefault(require("../../../content-types/comment"));
|
|
7
|
+
const parsers_1 = require("../../controllers/utils/parsers");
|
|
8
|
+
const functions_1 = require("../../utils/functions");
|
|
9
|
+
const constants_1 = require("../../utils/constants");
|
|
10
|
+
module.exports = ({ strapi, nexus }) => {
|
|
11
|
+
const { nonNull, intArg, arg } = nexus;
|
|
12
|
+
const { service: getService } = strapi.plugin("graphql");
|
|
13
|
+
const { args } = getService("internals");
|
|
14
|
+
const { naming: { getFiltersInputTypeName }, } = getService("utils");
|
|
15
|
+
return {
|
|
16
|
+
type: "ResponseFindAllPerAuthor",
|
|
17
|
+
args: {
|
|
18
|
+
authorId: nonNull(intArg()),
|
|
19
|
+
authorType: arg({ type: 'AuthorType' }),
|
|
20
|
+
filters: getFiltersInputTypeName(comment_1.default),
|
|
21
|
+
pagination: args.PaginationArg,
|
|
22
|
+
sort: args.SortArg,
|
|
23
|
+
},
|
|
24
|
+
async resolve(obj, args) {
|
|
25
|
+
const { authorId, authorType, filters, sort, pagination } = args;
|
|
26
|
+
const isStrapiUser = authorType !== constants_1.AUTHOR_TYPE.GENERIC;
|
|
27
|
+
return await (0, functions_1.getPluginService)("common").findAllPerAuthor((0, parsers_1.flatInput)({
|
|
28
|
+
query: (0, functions_1.getPluginService)("gql").graphQLFiltersToStrapiQuery(filters, comment_1.default),
|
|
29
|
+
sort,
|
|
30
|
+
pagination: pagination
|
|
31
|
+
? {
|
|
32
|
+
...pagination,
|
|
33
|
+
withCount: !(0, lodash_1.isEmpty)(pagination),
|
|
34
|
+
}
|
|
35
|
+
: undefined,
|
|
36
|
+
}), authorId, isStrapiUser);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=findAllPerAuthor.js.map
|
|
@@ -4,10 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
const findAllFlat_1 = __importDefault(require("./findAllFlat"));
|
|
6
6
|
const findAllInHierarchy_1 = __importDefault(require("./findAllInHierarchy"));
|
|
7
|
+
const findAllPerAuthor_1 = __importDefault(require("./findAllPerAuthor"));
|
|
7
8
|
module.exports = (context) => {
|
|
8
9
|
const queries = {
|
|
9
10
|
findAllFlat: findAllFlat_1.default,
|
|
10
11
|
findAllInHierarchy: findAllInHierarchy_1.default,
|
|
12
|
+
findAllPerAuthor: findAllPerAuthor_1.default,
|
|
11
13
|
};
|
|
12
14
|
return context.nexus.extendType({
|
|
13
15
|
type: "Query",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const constants_1 = require("../../utils/constants");
|
|
3
|
+
module.exports = ({ nexus }) => nexus.enumType({
|
|
4
|
+
name: 'AuthorType',
|
|
5
|
+
description: "User type which was the author of comment - Strapi built-in or generic",
|
|
6
|
+
members: Object.values(constants_1.AUTHOR_TYPE),
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=comment-author-type.js.map
|
|
@@ -6,6 +6,7 @@ const id_1 = __importDefault(require("./id"));
|
|
|
6
6
|
const comment_1 = __importDefault(require("./comment"));
|
|
7
7
|
const comment_nested_1 = __importDefault(require("./comment-nested"));
|
|
8
8
|
const comment_author_1 = __importDefault(require("./comment-author"));
|
|
9
|
+
const comment_author_type_1 = __importDefault(require("./comment-author-type"));
|
|
9
10
|
const create_comment_1 = __importDefault(require("./create-comment"));
|
|
10
11
|
const create_comment_author_1 = __importDefault(require("./create-comment-author"));
|
|
11
12
|
const update_comment_1 = __importDefault(require("./update-comment"));
|
|
@@ -17,11 +18,13 @@ const create_report_1 = __importDefault(require("./create-report"));
|
|
|
17
18
|
const response_pagination_1 = __importDefault(require("./response-pagination"));
|
|
18
19
|
const response_meta_1 = __importDefault(require("./response-meta"));
|
|
19
20
|
const response_find_all_1 = __importDefault(require("./response-find-all"));
|
|
21
|
+
const response_find_all_per_author_1 = __importDefault(require("./response-find-all-per-author"));
|
|
20
22
|
const typesFactories = [
|
|
21
23
|
id_1.default,
|
|
22
24
|
comment_1.default,
|
|
23
25
|
comment_nested_1.default,
|
|
24
26
|
comment_author_1.default,
|
|
27
|
+
comment_author_type_1.default,
|
|
25
28
|
create_comment_1.default,
|
|
26
29
|
create_comment_author_1.default,
|
|
27
30
|
update_comment_1.default,
|
|
@@ -33,6 +36,7 @@ const typesFactories = [
|
|
|
33
36
|
response_pagination_1.default,
|
|
34
37
|
response_meta_1.default,
|
|
35
38
|
response_find_all_1.default,
|
|
39
|
+
response_find_all_per_author_1.default,
|
|
36
40
|
];
|
|
37
41
|
module.exports = (context) => typesFactories.map((factory) => factory(context));
|
|
38
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = ({ nexus }) => nexus.objectType({
|
|
3
|
+
name: "ResponseFindAllPerAuthor",
|
|
4
|
+
definition(t) {
|
|
5
|
+
t.list.field("data", { type: "CommentSingle" });
|
|
6
|
+
t.field("meta", { type: "ResponseMeta" });
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=response-find-all-per-author.js.map
|
package/server/routes/client.js
CHANGED
|
@@ -85,6 +85,34 @@ const routes = [
|
|
|
85
85
|
},
|
|
86
86
|
},
|
|
87
87
|
},
|
|
88
|
+
{
|
|
89
|
+
method: "GET",
|
|
90
|
+
path: "/author/:id",
|
|
91
|
+
handler: "client.findAllPerAuthor",
|
|
92
|
+
config: {
|
|
93
|
+
policies: [],
|
|
94
|
+
description: "Find all comments created by Strapi user",
|
|
95
|
+
tag: {
|
|
96
|
+
plugin: "comments",
|
|
97
|
+
name: "Comments",
|
|
98
|
+
actionType: "find",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
method: "GET",
|
|
104
|
+
path: "/author/:id/:type",
|
|
105
|
+
handler: "client.findAllPerAuthor",
|
|
106
|
+
config: {
|
|
107
|
+
policies: [],
|
|
108
|
+
description: "Find all comments created by specified type of user",
|
|
109
|
+
tag: {
|
|
110
|
+
plugin: "comments",
|
|
111
|
+
name: "Comments",
|
|
112
|
+
actionType: "find",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
88
116
|
];
|
|
89
117
|
exports.default = routes;
|
|
90
118
|
//# sourceMappingURL=client.js.map
|
|
@@ -7,6 +7,7 @@ const lodash_1 = require("lodash");
|
|
|
7
7
|
const constants_1 = require("../utils/constants");
|
|
8
8
|
const error_1 = __importDefault(require("./../utils/error"));
|
|
9
9
|
const functions_1 = require("./utils/functions");
|
|
10
|
+
const parsers_1 = require("./utils/parsers");
|
|
10
11
|
const PAGE_SIZE = 10;
|
|
11
12
|
module.exports = ({ strapi }) => ({
|
|
12
13
|
async getConfig(prop, defaultValue, useLocal = false) {
|
|
@@ -41,54 +42,9 @@ module.exports = ({ strapi }) => ({
|
|
|
41
42
|
const doNotPopulateAuthor = isAdmin
|
|
42
43
|
? []
|
|
43
44
|
: await this.getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...queryExtension,
|
|
48
|
-
orderBy: ((0, lodash_1.isString)(sort) ? [sort] : sort)
|
|
49
|
-
.map((_) => (constants_1.REGEX.sorting.test(_) ? _ : `${_}:asc`))
|
|
50
|
-
.reduce((prev, curr) => {
|
|
51
|
-
const [type = "asc", ...parts] = curr.split(":").reverse();
|
|
52
|
-
return { ...(0, lodash_1.set)(prev, parts.reverse().join("."), type) };
|
|
53
|
-
}, {}),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (!(0, lodash_1.isNil)(fields)) {
|
|
57
|
-
queryExtension = {
|
|
58
|
-
...queryExtension,
|
|
59
|
-
select: (0, lodash_1.isArray)(fields) ? (0, lodash_1.uniq)([...fields, ...defaultSelect]) : fields,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
let meta = {};
|
|
63
|
-
if (pagination && (0, lodash_1.isObject)(pagination)) {
|
|
64
|
-
const parsedpagination = Object.keys(pagination).reduce((prev, curr) => ({
|
|
65
|
-
...prev,
|
|
66
|
-
[curr]: (0, lodash_1.parseInt)((0, lodash_1.get)(pagination, curr)),
|
|
67
|
-
}), {});
|
|
68
|
-
const { page = 1, pageSize = PAGE_SIZE, start = 0, limit = PAGE_SIZE, } = parsedpagination;
|
|
69
|
-
const paginationByPage = !(0, lodash_1.isNil)(parsedpagination?.page) || !(0, lodash_1.isNil)(parsedpagination?.pageSize);
|
|
70
|
-
queryExtension = {
|
|
71
|
-
...queryExtension,
|
|
72
|
-
offset: paginationByPage ? (page - 1) * pageSize : start,
|
|
73
|
-
limit: paginationByPage ? pageSize : limit,
|
|
74
|
-
};
|
|
75
|
-
const metapagination = paginationByPage
|
|
76
|
-
? {
|
|
77
|
-
pagination: {
|
|
78
|
-
page,
|
|
79
|
-
pageSize,
|
|
80
|
-
},
|
|
81
|
-
}
|
|
82
|
-
: {
|
|
83
|
-
pagination: {
|
|
84
|
-
start,
|
|
85
|
-
limit,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
meta = {
|
|
89
|
-
...metapagination,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
45
|
+
const sortQuery = (0, parsers_1.parseSortQuery)(sort);
|
|
46
|
+
const fieldsQuery = (0, parsers_1.parseFieldsQuery)(fields, sortQuery, defaultSelect);
|
|
47
|
+
let [meta, queryExtension = {}] = (0, parsers_1.parsePaginationsQuery)(pagination, fieldsQuery, { PAGE_SIZE });
|
|
92
48
|
const entries = await strapi.db
|
|
93
49
|
.query((0, functions_1.getModelUid)("comment"))
|
|
94
50
|
.findMany({
|
|
@@ -154,9 +110,12 @@ module.exports = ({ strapi }) => ({
|
|
|
154
110
|
? populateClause.authorUser.populate
|
|
155
111
|
: populateClause.authorUser;
|
|
156
112
|
}
|
|
113
|
+
const primitiveThreadOf = (0, lodash_1.isString)(parsedThreadOf) || (0, lodash_1.isNumber)(parsedThreadOf) ?
|
|
114
|
+
parsedThreadOf :
|
|
115
|
+
null;
|
|
157
116
|
return this.sanitizeCommentEntity({
|
|
158
117
|
..._,
|
|
159
|
-
threadOf:
|
|
118
|
+
threadOf: primitiveThreadOf || _.threadOf,
|
|
160
119
|
gotThread: (threadedItem?.itemsInTread || 0) > 0,
|
|
161
120
|
threadFirstItemId: threadedItem?.firstThreadItemId,
|
|
162
121
|
}, doNotPopulateAuthor, authorUserPopulate);
|
|
@@ -188,6 +147,32 @@ module.exports = ({ strapi }) => ({
|
|
|
188
147
|
const doNotPopulateAuthor = await this.getConfig(constants_1.CONFIG_PARAMS.AUTHOR_BLOCKED_PROPS, []);
|
|
189
148
|
return (0, functions_1.filterOurResolvedReports)(this.sanitizeCommentEntity(entity, doNotPopulateAuthor));
|
|
190
149
|
},
|
|
150
|
+
async findAllPerAuthor({ query = {}, populate = {}, pagination, sort, fields, isAdmin = false, }, authorId, isStrapiAuthor = false) {
|
|
151
|
+
if ((0, lodash_1.isNil)(authorId)) {
|
|
152
|
+
return {
|
|
153
|
+
data: [],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const { related, ...restQuery } = query;
|
|
157
|
+
const authorQuery = isStrapiAuthor ? {
|
|
158
|
+
authorUser: {
|
|
159
|
+
id: authorId
|
|
160
|
+
},
|
|
161
|
+
} : {
|
|
162
|
+
authorId,
|
|
163
|
+
};
|
|
164
|
+
const response = await this.findAllFlat({
|
|
165
|
+
query: {
|
|
166
|
+
...restQuery,
|
|
167
|
+
...authorQuery,
|
|
168
|
+
},
|
|
169
|
+
pagination, populate, sort, fields, isAdmin
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
...response,
|
|
173
|
+
data: response.data.map(({ author, ...rest }) => rest),
|
|
174
|
+
};
|
|
175
|
+
},
|
|
191
176
|
async findRelatedEntitiesFor(entities = []) {
|
|
192
177
|
const data = entities.reduce((acc, curr) => {
|
|
193
178
|
const [relatedUid, relatedStringId] = (0, functions_1.getRelatedGroups)(curr.related);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StrapiDBQueryArgs, StrapiPagination, StrapiResponseMeta, StringMap } from "strapi-typed";
|
|
2
|
+
import { CommentModelKeys, ToBeFixed } from "../../../types";
|
|
3
|
+
export declare const parseSortQuery: (sort: StringMap<unknown> | undefined, query?: StrapiDBQueryArgs<CommentModelKeys>) => StrapiDBQueryArgs<CommentModelKeys>;
|
|
4
|
+
export declare const parseFieldsQuery: (fields: ToBeFixed, query?: StrapiDBQueryArgs<CommentModelKeys>, defaultSelect?: Array<CommentModelKeys>) => StrapiDBQueryArgs<CommentModelKeys>;
|
|
5
|
+
export declare const parsePaginationsQuery: (pagination: StrapiPagination | undefined, query?: StrapiDBQueryArgs<CommentModelKeys>, defaults?: any) => [StrapiResponseMeta, StrapiDBQueryArgs<CommentModelKeys>];
|
|
6
|
+
//# sourceMappingURL=parsers.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePaginationsQuery = exports.parseFieldsQuery = exports.parseSortQuery = void 0;
|
|
4
|
+
const constants_1 = require("./../../utils/constants");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const parseSortQuery = (sort, query = {}) => {
|
|
7
|
+
if (sort && ((0, lodash_1.isString)(sort) || (0, lodash_1.isArray)(sort))) {
|
|
8
|
+
return {
|
|
9
|
+
...query,
|
|
10
|
+
orderBy: ((0, lodash_1.isString)(sort) ? [sort] : sort)
|
|
11
|
+
.map((_) => (constants_1.REGEX.sorting.test(_) ? _ : `${_}:asc`))
|
|
12
|
+
.reduce((prev, curr) => {
|
|
13
|
+
const [type = "asc", ...parts] = curr.split(":").reverse();
|
|
14
|
+
return { ...(0, lodash_1.set)(prev, parts.reverse().join("."), type) };
|
|
15
|
+
}, {}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return query;
|
|
19
|
+
};
|
|
20
|
+
exports.parseSortQuery = parseSortQuery;
|
|
21
|
+
const parseFieldsQuery = (fields, query = {}, defaultSelect = []) => {
|
|
22
|
+
if (!(0, lodash_1.isNil)(fields)) {
|
|
23
|
+
return {
|
|
24
|
+
...query,
|
|
25
|
+
select: (0, lodash_1.isArray)(fields) ? (0, lodash_1.uniq)([...fields, ...defaultSelect]) : fields,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return query;
|
|
29
|
+
};
|
|
30
|
+
exports.parseFieldsQuery = parseFieldsQuery;
|
|
31
|
+
const parsePaginationsQuery = (pagination, query = {}, defaults = []) => {
|
|
32
|
+
if (pagination && (0, lodash_1.isObject)(pagination)) {
|
|
33
|
+
const parsedpagination = Object.keys(pagination).reduce((prev, curr) => ({
|
|
34
|
+
...prev,
|
|
35
|
+
[curr]: parseInt((0, lodash_1.get)(pagination, curr)),
|
|
36
|
+
}), {});
|
|
37
|
+
const { page = 1, pageSize = defaults.PAGE_SIZE, start = 0, limit = defaults.PAGE_SIZE, } = parsedpagination;
|
|
38
|
+
const paginationByPage = !(0, lodash_1.isNil)(parsedpagination?.page) || !(0, lodash_1.isNil)(parsedpagination?.pageSize);
|
|
39
|
+
const metapagination = paginationByPage
|
|
40
|
+
? {
|
|
41
|
+
pagination: {
|
|
42
|
+
page,
|
|
43
|
+
pageSize,
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
: {
|
|
47
|
+
pagination: {
|
|
48
|
+
start,
|
|
49
|
+
limit,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
return [{
|
|
53
|
+
...metapagination,
|
|
54
|
+
}, {
|
|
55
|
+
...query,
|
|
56
|
+
offset: paginationByPage ? (page - 1) * pageSize : start,
|
|
57
|
+
limit: paginationByPage ? pageSize : limit,
|
|
58
|
+
}];
|
|
59
|
+
}
|
|
60
|
+
return [{}, query];
|
|
61
|
+
};
|
|
62
|
+
exports.parsePaginationsQuery = parsePaginationsQuery;
|
|
63
|
+
//# sourceMappingURL=parsers.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REGEX = exports.APPROVAL_STATUS = exports.CONFIG_PARAMS = void 0;
|
|
3
|
+
exports.REGEX = exports.AUTHOR_TYPE = exports.APPROVAL_STATUS = exports.CONFIG_PARAMS = void 0;
|
|
4
4
|
exports.CONFIG_PARAMS = {
|
|
5
5
|
ENABLED_COLLECTIONS: "enabledCollections",
|
|
6
6
|
APPROVAL_FLOW: "approvalFlow",
|
|
@@ -14,6 +14,10 @@ exports.APPROVAL_STATUS = {
|
|
|
14
14
|
APPROVED: "APPROVED",
|
|
15
15
|
REJECTED: "REJECTED",
|
|
16
16
|
};
|
|
17
|
+
exports.AUTHOR_TYPE = {
|
|
18
|
+
GENERIC: 'GENERIC',
|
|
19
|
+
STRAPI: 'STRAPI',
|
|
20
|
+
};
|
|
17
21
|
exports.REGEX = {
|
|
18
22
|
uid: /^(?<type>[a-z0-9-]+)\:{2}(?<api>[a-z0-9-]+)\.{1}(?<contentType>[a-z0-9-]+)$/i,
|
|
19
23
|
relatedUid: /^(?<uid>[a-z0-9-]+\:{2}[a-z0-9-]+\.[a-z0-9-]+)\:{1}(?<id>[a-z0-9-]+)$/i,
|