strapi-plugin-comments 2.0.10 → 2.1.0-beta.1
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 +164 -120
- package/admin/src/components/ActionButton/styles.d.ts +2 -0
- package/admin/src/components/ActionButton/styles.js +13 -8
- package/admin/src/components/ConfirmationDialog/index.d.ts +26 -0
- package/admin/src/components/ConfirmationDialog/index.js +36 -55
- package/admin/src/components/DiscussionStatus/index.d.ts +9 -0
- package/admin/src/components/DiscussionStatus/index.js +22 -31
- package/admin/src/components/DiscussionThread/index.d.ts +16 -0
- package/admin/src/components/DiscussionThread/index.js +39 -56
- package/admin/src/components/DiscussionThreadItem/index.d.ts +9 -0
- package/admin/src/components/DiscussionThreadItem/index.js +28 -52
- package/admin/src/components/DiscussionThreadItem/styles.d.ts +4 -0
- package/admin/src/components/DiscussionThreadItem/styles.js +16 -11
- package/admin/src/components/DiscussionThreadItemActions/index.d.ts +19 -0
- package/admin/src/components/DiscussionThreadItemActions/index.js +121 -158
- package/admin/src/components/DiscussionThreadItemActions/styles.d.ts +2 -0
- package/admin/src/components/DiscussionThreadItemActions/styles.js +13 -7
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.d.ts +17 -0
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/index.js +38 -48
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.d.ts +2 -0
- package/admin/src/components/DiscussionThreadItemApprovalFlowActions/styles.js +12 -6
- package/admin/src/components/DiscussionThreadItemFooter/index.d.ts +16 -0
- package/admin/src/components/DiscussionThreadItemFooter/index.js +35 -42
- package/admin/src/components/DiscussionThreadItemFooter/styles.d.ts +3 -0
- package/admin/src/components/DiscussionThreadItemFooter/styles.js +17 -12
- package/admin/src/components/DiscussionThreadItemReviewAction/index.d.ts +30 -0
- package/admin/src/components/DiscussionThreadItemReviewAction/index.js +77 -91
- package/admin/src/components/FormSwitch/index.d.ts +7 -0
- package/admin/src/components/FormSwitch/index.js +15 -18
- package/admin/src/components/FormSwitch/styles.d.ts +2 -0
- package/admin/src/components/FormSwitch/styles.js +14 -8
- package/admin/src/components/IconButton/styles.d.ts +2 -0
- package/admin/src/components/IconButton/styles.js +16 -9
- package/admin/src/components/Initializer/index.d.ts +5 -0
- package/admin/src/components/Initializer/index.js +12 -24
- package/admin/src/components/LoadingIndicatorOverlay/index.d.ts +3 -0
- package/admin/src/components/LoadingIndicatorOverlay/index.js +12 -15
- package/admin/src/components/LoadingIndicatorOverlay/styles.d.ts +3 -0
- package/admin/src/components/LoadingIndicatorOverlay/styles.js +22 -17
- package/admin/src/components/Nav/index.d.ts +7 -0
- package/admin/src/components/Nav/index.js +25 -48
- package/admin/src/components/PluginIcon/index.d.ts +3 -0
- package/admin/src/components/PluginIcon/index.js +10 -12
- package/admin/src/components/ReportsReviewModal/index.d.ts +21 -0
- package/admin/src/components/ReportsReviewModal/index.js +31 -46
- package/admin/src/components/ReportsReviewTable/index.d.ts +21 -0
- package/admin/src/components/ReportsReviewTable/index.js +120 -140
- package/admin/src/components/StatusBadge/index.d.ts +7 -0
- package/admin/src/components/StatusBadge/index.js +12 -17
- package/admin/src/components/StatusBadge/styles.d.ts +2 -0
- package/admin/src/components/StatusBadge/styles.js +19 -13
- package/admin/src/components/TableFilters/index.d.ts +10 -0
- package/admin/src/components/TableFilters/index.js +52 -49
- package/admin/src/components/TablePagination/index.d.ts +17 -0
- package/admin/src/components/TablePagination/index.js +27 -29
- package/admin/src/components/icons/comments.d.ts +6 -0
- package/admin/src/components/icons/comments.js +11 -8
- package/admin/src/components/icons/index.d.ts +6 -0
- package/admin/src/components/icons/index.js +15 -6
- package/admin/src/components/icons/lock.d.ts +7 -0
- package/admin/src/components/icons/lock.js +11 -21
- package/admin/src/components/icons/review.d.ts +7 -0
- package/admin/src/components/icons/review.js +11 -17
- package/admin/src/components/icons/unlock.d.ts +7 -0
- package/admin/src/components/icons/unlock.js +11 -19
- package/admin/src/hooks/useConfig.d.ts +8 -0
- package/admin/src/hooks/useConfig.js +40 -45
- package/admin/src/index.d.ts +7 -0
- package/admin/src/index.js +98 -92
- package/admin/src/pages/App/index.d.ts +4 -0
- package/admin/src/pages/App/index.js +43 -67
- package/admin/src/pages/App/reducer/actions.d.ts +8 -0
- package/admin/src/pages/App/reducer/actions.js +11 -7
- package/admin/src/pages/App/reducer/constants.d.ts +4 -0
- package/admin/src/pages/App/reducer/constants.js +7 -4
- package/admin/src/pages/App/reducer/index.d.ts +9 -0
- package/admin/src/pages/App/reducer/index.js +24 -22
- package/admin/src/pages/App/reducer/init.d.ts +3 -0
- package/admin/src/pages/App/reducer/init.js +6 -4
- package/admin/src/pages/App/reducer/selectors.d.ts +6 -0
- package/admin/src/pages/App/reducer/selectors.js +17 -34
- package/admin/src/pages/App/utils/api.d.ts +2 -0
- package/admin/src/pages/App/utils/api.js +14 -11
- package/admin/src/pages/ComingSoonPage/index.d.ts +3 -0
- package/admin/src/pages/ComingSoonPage/index.js +42 -24
- package/admin/src/pages/Details/components/DetailsEntity/index.d.ts +18 -0
- package/admin/src/pages/Details/components/DetailsEntity/index.js +49 -77
- package/admin/src/pages/Details/components/DetailsFilters/index.d.ts +12 -0
- package/admin/src/pages/Details/components/DetailsFilters/index.js +19 -26
- package/admin/src/pages/Details/components/DetailsFilters/styles.d.ts +2 -0
- package/admin/src/pages/Details/components/DetailsFilters/styles.js +14 -8
- package/admin/src/pages/Details/index.d.ts +4 -0
- package/admin/src/pages/Details/index.js +94 -133
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.d.ts +20 -0
- package/admin/src/pages/Discover/components/DiscoverTableRow/index.js +128 -139
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.d.ts +2 -0
- package/admin/src/pages/Discover/components/DiscoverTableRow/styles.js +14 -8
- package/admin/src/pages/Discover/index.d.ts +4 -0
- package/admin/src/pages/Discover/index.js +129 -170
- package/admin/src/pages/Discover/utils/api.d.ts +2 -0
- package/admin/src/pages/Discover/utils/api.js +15 -13
- package/admin/src/pages/Discover/utils/filtersSchema.d.ts +11 -0
- package/admin/src/pages/Discover/utils/filtersSchema.js +8 -6
- package/admin/src/pages/Settings/components/RestartAlert/styles.d.ts +2 -0
- package/admin/src/pages/Settings/components/RestartAlert/styles.js +14 -8
- package/admin/src/pages/Settings/index.d.ts +3 -0
- package/admin/src/pages/Settings/index.js +225 -391
- package/admin/src/pages/Settings/utils/api.d.ts +7 -0
- package/admin/src/pages/Settings/utils/api.js +60 -55
- package/admin/src/pages/utils/api.d.ts +12 -0
- package/admin/src/pages/utils/api.js +58 -53
- package/admin/src/permissions.d.ts +28 -0
- package/admin/src/permissions.js +31 -17
- package/admin/src/pluginId.d.ts +2 -0
- package/admin/src/pluginId.js +29 -5
- package/admin/src/reducers.d.ts +7 -0
- package/admin/src/reducers.js +10 -6
- package/admin/src/translations/en.json +131 -131
- package/admin/src/translations/fr.json +1 -1
- package/admin/src/utils/axiosInstance.d.ts +3 -0
- package/admin/src/utils/axiosInstance.js +21 -27
- package/admin/src/utils/constants.d.ts +25 -0
- package/admin/src/utils/constants.js +23 -22
- package/admin/src/utils/getApiUrl.d.ts +3 -0
- package/admin/src/utils/getApiUrl.js +6 -5
- package/admin/src/utils/getMessage.d.ts +4 -0
- package/admin/src/utils/getMessage.js +15 -15
- package/admin/src/utils/getRelatedGroups.d.ts +4 -0
- package/admin/src/utils/getRelatedGroups.js +5 -3
- package/admin/src/utils/getUrl.d.ts +3 -0
- package/admin/src/utils/getUrl.js +6 -5
- package/admin/src/utils/handleAPIError.d.ts +4 -0
- package/admin/src/utils/handleAPIError.js +12 -11
- package/admin/src/utils/index.d.ts +12 -0
- package/admin/src/utils/index.js +29 -11
- package/admin/src/utils/parseRegExp.d.ts +6 -0
- package/admin/src/utils/parseRegExp.js +6 -5
- package/admin/src/utils/renderEntryTitle.d.ts +4 -0
- package/admin/src/utils/renderEntryTitle.js +11 -12
- package/admin/src/utils/renderInitials.d.ts +3 -0
- package/admin/src/utils/renderInitials.js +10 -5
- package/admin/src/utils/resolveCommentStatus.d.ts +4 -0
- package/admin/src/utils/resolveCommentStatus.js +17 -21
- package/admin/src/utils/resolveCommentStatusColor.d.ts +4 -0
- package/admin/src/utils/resolveCommentStatusColor.js +19 -19
- package/content-types/comment.d.ts +91 -0
- package/content-types/comment.js +87 -88
- package/content-types/index.d.ts +143 -0
- package/content-types/index.js +15 -10
- package/content-types/report.d.ts +48 -0
- package/content-types/report.js +44 -49
- package/package.json +24 -19
- package/permissions.d.ts +18 -0
- package/permissions.js +12 -13
- package/server/bootstrap.d.ts +4 -0
- package/server/bootstrap.js +56 -62
- package/server/config/index.d.ts +4 -0
- package/server/config/index.js +17 -15
- package/server/controllers/admin.d.ts +4 -0
- package/server/controllers/admin.js +134 -167
- package/server/controllers/client.d.ts +4 -0
- package/server/controllers/client.js +104 -112
- package/server/controllers/index.d.ts +6 -0
- package/server/controllers/index.js +12 -8
- package/server/controllers/utils/functions.d.ts +7 -0
- package/server/controllers/utils/functions.js +22 -17
- package/server/controllers/utils/parsers.d.ts +15 -0
- package/server/controllers/utils/parsers.js +17 -17
- package/server/destroy.d.ts +3 -0
- package/server/destroy.js +3 -4
- package/server/graphql/index.d.ts +4 -0
- package/server/graphql/index.js +27 -25
- package/server/graphql/mutations/createAbuseReport.d.ts +11 -0
- package/server/graphql/mutations/createAbuseReport.js +22 -24
- package/server/graphql/mutations/createComment.d.ts +14 -0
- package/server/graphql/mutations/createComment.js +22 -24
- package/server/graphql/mutations/index.d.ts +4 -0
- package/server/graphql/mutations/index.js +24 -19
- package/server/graphql/mutations/removeComment.d.ts +11 -0
- package/server/graphql/mutations/removeComment.js +22 -24
- package/server/graphql/mutations/updateComment.d.ts +11 -0
- package/server/graphql/mutations/updateComment.js +22 -24
- package/server/graphql/queries/findAllFlat.d.ts +19 -0
- package/server/graphql/queries/findAllFlat.js +31 -34
- package/server/graphql/queries/findAllInHierarchy.d.ts +18 -0
- package/server/graphql/queries/findAllInHierarchy.js +26 -30
- package/server/graphql/queries/index.d.ts +4 -0
- package/server/graphql/queries/index.js +20 -17
- package/server/graphql/resolvers-config.d.ts +23 -0
- package/server/graphql/resolvers-config.js +11 -11
- package/server/graphql/types/comment-author.d.ts +4 -0
- package/server/graphql/types/comment-author.js +10 -8
- package/server/graphql/types/comment-nested.d.ts +4 -0
- package/server/graphql/types/comment-nested.js +17 -15
- package/server/graphql/types/comment.d.ts +4 -0
- package/server/graphql/types/comment.js +16 -14
- package/server/graphql/types/create-comment-author.d.ts +4 -0
- package/server/graphql/types/create-comment-author.js +10 -8
- package/server/graphql/types/create-comment.d.ts +4 -0
- package/server/graphql/types/create-comment.js +10 -8
- package/server/graphql/types/create-report.d.ts +4 -0
- package/server/graphql/types/create-report.js +10 -8
- package/server/graphql/types/id.d.ts +4 -0
- package/server/graphql/types/id.js +24 -23
- package/server/graphql/types/identify-comment-author.d.ts +4 -0
- package/server/graphql/types/identify-comment-author.js +7 -5
- package/server/graphql/types/index.d.ts +4 -0
- package/server/graphql/types/index.js +36 -17
- package/server/graphql/types/remove-comment.d.ts +4 -0
- package/server/graphql/types/remove-comment.js +9 -7
- package/server/graphql/types/report-reason.d.ts +4 -0
- package/server/graphql/types/report-reason.js +10 -8
- package/server/graphql/types/report.d.ts +4 -0
- package/server/graphql/types/report.js +12 -10
- package/server/graphql/types/response-find-all.d.ts +4 -0
- package/server/graphql/types/response-find-all.js +8 -6
- package/server/graphql/types/response-meta.d.ts +4 -0
- package/server/graphql/types/response-meta.js +7 -5
- package/server/graphql/types/response-pagination.d.ts +4 -0
- package/server/graphql/types/response-pagination.js +12 -10
- package/server/graphql/types/update-comment.d.ts +4 -0
- package/server/graphql/types/update-comment.js +10 -8
- package/server/index.d.ts +26 -0
- package/server/index.js +24 -21
- package/server/register.d.ts +3 -0
- package/server/register.js +3 -4
- package/server/routes/admin.d.ts +4 -0
- package/server/routes/admin.js +103 -109
- package/server/routes/client.d.ts +4 -0
- package/server/routes/client.js +48 -46
- package/server/routes/index.d.ts +11 -0
- package/server/routes/index.js +18 -14
- package/server/services/admin.d.ts +5 -0
- package/server/services/admin.js +126 -158
- package/server/services/client.d.ts +5 -0
- package/server/services/client.js +135 -151
- package/server/services/common.d.ts +5 -0
- package/server/services/common.js +165 -194
- package/server/services/graphql.d.ts +5 -0
- package/server/services/graphql.js +117 -182
- package/server/services/index.d.ts +8 -0
- package/server/services/index.js +15 -12
- package/server/services/utils/functions.d.ts +13 -0
- package/server/services/utils/functions.js +100 -109
- package/server/utils/constants.d.ts +9 -0
- package/server/utils/constants.js +19 -23
- package/server/utils/error.d.ts +19 -0
- package/server/utils/error.js +23 -18
- package/server/utils/functions.d.ts +6 -0
- package/server/utils/functions.js +35 -18
- package/strapi-admin.d.ts +3 -0
- package/strapi-admin.js +8 -3
- package/strapi-server.d.ts +177 -0
- package/strapi-server.js +43 -46
- package/tsconfig.tsbuildinfo +1 -0
- package/types/contentTypes.d.ts +44 -0
- package/types/contentTypes.js +3 -0
- package/.husky/pre-commit +0 -4
- package/LICENSE.md +0 -7
- package/__mocks__/initSetup.js +0 -108
- package/jest.config.js +0 -7
- package/server/controllers/utils/__tests__/functions.test.js +0 -43
- package/server/controllers/utils/__tests__/parsers.test.js +0 -94
- package/server/services/__tests__/common.test.js +0 -399
- package/server/services/utils/__tests__/functions.test.js +0 -53
- package/server/utils/__tests__/functions.test.js +0 -17
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { StrapiUser } from "strapi-typed";
|
|
2
|
+
import { ToBeFixed } from "./common";
|
|
3
|
+
export declare type Id = number | string;
|
|
4
|
+
export declare type Comment = {
|
|
5
|
+
id: Id;
|
|
6
|
+
content?: string;
|
|
7
|
+
author?: CommentAuthor | undefined;
|
|
8
|
+
children?: Array<Comment>;
|
|
9
|
+
reports?: Array<CommentReport>;
|
|
10
|
+
threadOf?: Comment | number | null;
|
|
11
|
+
gotThread?: boolean;
|
|
12
|
+
related?: any;
|
|
13
|
+
blocked?: boolean;
|
|
14
|
+
blockedThread?: boolean;
|
|
15
|
+
itemsInTread?: number;
|
|
16
|
+
approvalStatus?: ToBeFixed | null;
|
|
17
|
+
firstThreadItemId?: Id;
|
|
18
|
+
threadFirstItemId?: Id;
|
|
19
|
+
} & CommentAuthorPartial;
|
|
20
|
+
export declare type CommentAuthor = {
|
|
21
|
+
id: Id;
|
|
22
|
+
name?: string;
|
|
23
|
+
email?: string;
|
|
24
|
+
avatar?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare type CommentAuthorPartial = {
|
|
27
|
+
authorId?: number;
|
|
28
|
+
authorName?: string;
|
|
29
|
+
authorEmail?: string;
|
|
30
|
+
authorAvatar?: string;
|
|
31
|
+
authorUser?: StrapiUser;
|
|
32
|
+
};
|
|
33
|
+
export declare type CommentReport = {
|
|
34
|
+
id: Id;
|
|
35
|
+
reason: any;
|
|
36
|
+
content: string;
|
|
37
|
+
resolved: boolean;
|
|
38
|
+
};
|
|
39
|
+
export declare type RelatedEntity = {
|
|
40
|
+
id: Id;
|
|
41
|
+
uid: string;
|
|
42
|
+
requireCommentsApproval?: boolean;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=contentTypes.d.ts.map
|
package/.husky/pre-commit
DELETED
package/LICENSE.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2021 VirtusLab Sp. z o.o. & Strapi Solutions.
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/__mocks__/initSetup.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const { get, set, isEmpty } = require('lodash');
|
|
2
|
-
|
|
3
|
-
module.exports = (config = {}, toStore = false, database = {}) => {
|
|
4
|
-
const dbConfig = toStore ? {
|
|
5
|
-
plugin: {
|
|
6
|
-
comments: {
|
|
7
|
-
config: { ...config },
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
}: {};
|
|
11
|
-
|
|
12
|
-
let mock = {
|
|
13
|
-
db: {
|
|
14
|
-
query: (uid) => {
|
|
15
|
-
const [handler, rest] = uid.split('::');
|
|
16
|
-
const [collection] = rest.split('.');
|
|
17
|
-
const values = get(mock.db, `${handler}.${collection}.records`, []);
|
|
18
|
-
return {
|
|
19
|
-
findOne: async () => new Promise(resolve => resolve(values[0])),
|
|
20
|
-
findMany: async () => new Promise(resolve => resolve(values)),
|
|
21
|
-
findWithCount: async () => new Promise(resolve => resolve([values, values.length])),
|
|
22
|
-
count: async () => new Promise(resolve => resolve(values.length)),
|
|
23
|
-
create: async (value) => new Promise(resolve => resolve(value)),
|
|
24
|
-
update: async (value) => new Promise(resolve => resolve(value)),
|
|
25
|
-
delete: async (value) => new Promise(resolve => resolve(value)),
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
...dbConfig,
|
|
29
|
-
},
|
|
30
|
-
getRef: function() {
|
|
31
|
-
return this;
|
|
32
|
-
},
|
|
33
|
-
plugin: function(name) {
|
|
34
|
-
return this.plugins[name];
|
|
35
|
-
},
|
|
36
|
-
store: async function(storeProps) {
|
|
37
|
-
const { type, name } = storeProps; // { type: 'plugin', name: 'comments' }
|
|
38
|
-
|
|
39
|
-
const mockedStore = {
|
|
40
|
-
get: async function(props) { // { key: 'config' }
|
|
41
|
-
const { key } = props;
|
|
42
|
-
return new Promise(resolve => resolve(get(mock.db, `${type}.${name}.${key}`, undefined)));
|
|
43
|
-
},
|
|
44
|
-
set: async function(props) { // { key: 'config', value: {...} }
|
|
45
|
-
const { key, value } = props;
|
|
46
|
-
set(mock.db, `${type}.${name}.${key}`, value);
|
|
47
|
-
return this.get(key);
|
|
48
|
-
},
|
|
49
|
-
delete: async function(props) { // { key: 'config' }
|
|
50
|
-
const { key } = props;
|
|
51
|
-
set(mock.db, `${type}.${name}.${key}`, undefined);
|
|
52
|
-
return new Promise(resolve => resolve(true));
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return new Promise(resolve => resolve(mockedStore));
|
|
57
|
-
},
|
|
58
|
-
plugins: {
|
|
59
|
-
comments: {
|
|
60
|
-
service: function(name) {
|
|
61
|
-
return this.services[name]({ strapi: mock.getRef() });
|
|
62
|
-
},
|
|
63
|
-
package: require('../package.json'),
|
|
64
|
-
services: {
|
|
65
|
-
common: require('../server/services/common'),
|
|
66
|
-
client: require('../server/services/client'),
|
|
67
|
-
admin: require('../server/services/admin'),
|
|
68
|
-
},
|
|
69
|
-
contentTypes: {
|
|
70
|
-
comment: {
|
|
71
|
-
...require('../content-types/comment'),
|
|
72
|
-
uid: 'plugins::comments.comment',
|
|
73
|
-
},
|
|
74
|
-
'comment-report': {
|
|
75
|
-
...require('../content-types/report'),
|
|
76
|
-
uid: 'plugins::comments.comment-report'
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
config: {
|
|
82
|
-
get: function(prop = '') {
|
|
83
|
-
return get(this.plugins, prop.replace('plugin.', ''));
|
|
84
|
-
},
|
|
85
|
-
set: function(prop = '', value) {
|
|
86
|
-
return set(this.plugins, prop.replace('plugin.', ''), value);
|
|
87
|
-
},
|
|
88
|
-
plugins: {
|
|
89
|
-
comments: {
|
|
90
|
-
approvalFlow: ['api::blog-post.blog-post'],
|
|
91
|
-
entryLabel: {
|
|
92
|
-
'api::blog-post.blog-post': ['alternative_subject'],
|
|
93
|
-
},
|
|
94
|
-
...(toStore ? {} : config)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
if (!isEmpty(database)) {
|
|
101
|
-
Object.keys(database).forEach((uid) => {
|
|
102
|
-
const [handler, collection] = uid.split('::');
|
|
103
|
-
set(mock.db, `${handler}.${collection}.records`, database[uid]);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return mock;
|
|
108
|
-
};
|
package/jest.config.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const PluginError = require('../../../utils/error');
|
|
2
|
-
const ctx = require('koa/lib/context');
|
|
3
|
-
const { throwError } = require('../functions');
|
|
4
|
-
|
|
5
|
-
jest.mock
|
|
6
|
-
|
|
7
|
-
describe('Test Comments controller functions utils', () => {
|
|
8
|
-
|
|
9
|
-
describe('Errors serialization', () => {
|
|
10
|
-
test('Should throw error PluginError', () => {
|
|
11
|
-
try {
|
|
12
|
-
throw new PluginError(400, 'Error message', {
|
|
13
|
-
content: {
|
|
14
|
-
param: 'Parameter value'
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
} catch (e) {
|
|
18
|
-
expect(e).toBeInstanceOf(PluginError);
|
|
19
|
-
expect(e).toHaveProperty('status', 400);
|
|
20
|
-
expect(e).toHaveProperty('name', 'Strapi:Plugin:Comments');
|
|
21
|
-
expect(e).toHaveProperty('message', 'Error message');
|
|
22
|
-
expect(e).toHaveProperty('payload');
|
|
23
|
-
expect(e.payload).toEqual(expect.objectContaining({
|
|
24
|
-
content: {
|
|
25
|
-
param: 'Parameter value'
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
throwError(ctx, e);
|
|
31
|
-
} catch (eFinal) {
|
|
32
|
-
const stringifiedError = eFinal.toString();
|
|
33
|
-
expect(stringifiedError.includes('BadRequestError')).toEqual(true);
|
|
34
|
-
expect(stringifiedError.includes('Strapi:Plugin:Comments')).toEqual(true);
|
|
35
|
-
expect(stringifiedError.includes('Error message')).toEqual(true);
|
|
36
|
-
expect(stringifiedError.includes('Strapi:Plugin:Comments')).toEqual(true);
|
|
37
|
-
expect(stringifiedError.includes('content')).toEqual(true);
|
|
38
|
-
expect(stringifiedError.includes('Parameter value')).toEqual(true);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const { flatInput } = require('../parsers');
|
|
2
|
-
|
|
3
|
-
jest.mock
|
|
4
|
-
|
|
5
|
-
describe('Test Comments controller parsers utils', () => {
|
|
6
|
-
|
|
7
|
-
describe('Flat Input properties', () => {
|
|
8
|
-
const relation = 'api::test.relation';
|
|
9
|
-
const filters = {
|
|
10
|
-
content: {
|
|
11
|
-
'$eq': 'Test'
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const sort = {
|
|
15
|
-
createdAt: 'desc'
|
|
16
|
-
};
|
|
17
|
-
const pagination = {
|
|
18
|
-
page: 3,
|
|
19
|
-
pageSize: 5,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
test('Should contain default property \'populate\'', () => {
|
|
23
|
-
expect(flatInput()).toHaveProperty(['populate', 'threadOf', 'populate', 'authorUser'], true);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('Should assign relation to \'query\'', () => {
|
|
27
|
-
expect(flatInput(relation)).toHaveProperty(['query', 'related'], relation);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('Should assign filters to \'query\'', () => {
|
|
31
|
-
const result = flatInput(relation, filters);
|
|
32
|
-
expect(result).toHaveProperty(['query', 'content', '$eq'], filters.content['$eq']);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('Should assign not allow to overwrite \'removed\' in $or operator', () => {
|
|
36
|
-
const overwrittenOrOperator = {
|
|
37
|
-
$or: [{ removed: true }, { removed: false }, { removed: null }]
|
|
38
|
-
};
|
|
39
|
-
const result = flatInput(relation, overwrittenOrOperator);
|
|
40
|
-
expect(result).toHaveProperty(['query', '$or', 0, 'removed', '$null'], true);
|
|
41
|
-
expect(result).toHaveProperty(['query', '$or', 1, 'removed'], false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('Should assign sort', () => {
|
|
45
|
-
const result = flatInput(relation, filters, sort);
|
|
46
|
-
expect(result).toHaveProperty(['sort', 'createdAt'], sort.createdAt);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('Should assign pagination', () => {
|
|
50
|
-
const result = flatInput(relation, filters, sort, pagination);
|
|
51
|
-
expect(result).toHaveProperty(['pagination', 'page'], pagination.page);
|
|
52
|
-
expect(result).toHaveProperty(['pagination', 'pageSize'], pagination.pageSize);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('Should build complex output', () => {
|
|
56
|
-
const day = 24 * 60 * 60 * 1000;
|
|
57
|
-
const now = Date.now().toString();
|
|
58
|
-
const oneDayBefore = new Date(Date.now().valueOf() - day).toString();
|
|
59
|
-
const complexFilters = {
|
|
60
|
-
'$or': [{
|
|
61
|
-
createdAt: {
|
|
62
|
-
'$lte': oneDayBefore
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
createdAt: {
|
|
66
|
-
'$eq': now
|
|
67
|
-
}
|
|
68
|
-
}],
|
|
69
|
-
content: {
|
|
70
|
-
'$contains': 'Test'
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const complexSort = [{
|
|
75
|
-
createdAt: 'desc'
|
|
76
|
-
}, {
|
|
77
|
-
title: 'asc'
|
|
78
|
-
}];
|
|
79
|
-
|
|
80
|
-
const result = flatInput(relation, complexFilters, complexSort, pagination);
|
|
81
|
-
|
|
82
|
-
expect(result).toHaveProperty(['query', 'related'], relation);
|
|
83
|
-
expect(result).toHaveProperty(['query', '$or', 0, 'createdAt', '$lte'], oneDayBefore);
|
|
84
|
-
expect(result).toHaveProperty(['query', '$or', 1, 'createdAt', '$eq'], now);
|
|
85
|
-
expect(result).toHaveProperty(['query', '$or', 2, 'removed', '$null'], true);
|
|
86
|
-
expect(result).toHaveProperty(['query', '$or', 3, 'removed'], false);
|
|
87
|
-
expect(result).toHaveProperty(['query', 'content', '$contains'], complexFilters.content['$contains']);
|
|
88
|
-
expect(result).toHaveProperty(['sort', 0, 'createdAt'], complexSort[0].createdAt);
|
|
89
|
-
expect(result).toHaveProperty(['sort', 1, 'title'], complexSort[1].title);
|
|
90
|
-
expect(result).toHaveProperty(['pagination', 'page'], pagination.page);
|
|
91
|
-
expect(result).toHaveProperty(['pagination', 'pageSize'], pagination.pageSize);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|