@webbio/strapi-plugin-page-builder 0.12.2-platform → 0.12.3-platform
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 +166 -166
- package/admin/src/api/collection-type.ts +111 -111
- package/admin/src/api/entity-relation.ts +42 -42
- package/admin/src/api/has-page-relation.ts +37 -37
- package/admin/src/api/has-platform-relation.ts +40 -40
- package/admin/src/api/page-type-relation.ts +41 -41
- package/admin/src/api/platform-page-types.ts +45 -45
- package/admin/src/api/platform-relation.ts +42 -42
- package/admin/src/api/platform.ts +35 -35
- package/admin/src/api/search-filtered-entity.ts +114 -114
- package/admin/src/api/template.ts +39 -39
- package/admin/src/components/Combobox/index.tsx +83 -83
- package/admin/src/components/Combobox/react-select-custom-styles.tsx +121 -121
- package/admin/src/components/Combobox/styles.ts +46 -46
- package/admin/src/components/ConfirmModal/index.tsx +90 -90
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +127 -127
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +149 -149
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/styles.ts +19 -19
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +82 -82
- package/admin/src/components/EditView/Details/index.tsx +48 -48
- package/admin/src/components/EditView/Details/styles.ts +51 -51
- package/admin/src/components/EditView/PageSettings/index.tsx +124 -124
- package/admin/src/components/EditView/Platform/platform-select.tsx +30 -30
- package/admin/src/components/EditView/Template/TemplateConfirmModal/index.tsx +36 -36
- package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +70 -70
- package/admin/src/components/EditView/Template/TemplateSelect/use-template-modules.ts +41 -41
- package/admin/src/components/EditView/index.tsx +35 -35
- package/admin/src/components/EditView/page-type-select.tsx +32 -32
- package/admin/src/components/EditView/wrapper.tsx +41 -41
- package/admin/src/components/GlobalPlatformSelect/index.tsx +40 -40
- package/admin/src/components/GlobalPlatformSelect/styles.ts +27 -27
- package/admin/src/components/Initializer/index.tsx +24 -24
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +39 -39
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +32 -32
- package/admin/src/components/PageFilters/filters.tsx +189 -189
- package/admin/src/components/PageFilters/index.tsx +35 -35
- package/admin/src/components/PageTypeEditView/TemplatePlatformSelect/index.tsx +76 -76
- package/admin/src/components/PageTypeEditView/index.tsx +53 -53
- package/admin/src/components/PlatformFilteredSelectField/InputIcon/index.tsx +23 -23
- package/admin/src/components/PlatformFilteredSelectField/Multi/index.tsx +210 -210
- package/admin/src/components/PlatformFilteredSelectField/Single/index.tsx +197 -197
- package/admin/src/components/PlatformFilteredSelectField/hooks/useRelationLoad.tsx +128 -128
- package/admin/src/components/PlatformFilteredSelectField/index.tsx +85 -85
- package/admin/src/components/PlatformFilteredSelectField/styles.tsx +77 -77
- package/admin/src/components/PlatformFilteredSelectField/utils/get-translations.ts +3 -3
- package/admin/src/components/PlatformFilteredSelectField/utils/relation-helper.ts +147 -147
- package/admin/src/components/PluginIcon/index.tsx +94 -94
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/RelationInput.tsx +689 -689
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/RelationInputDataManager.tsx +6 -6
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/useRelation.ts +170 -170
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/utils/getRelationLink.ts +5 -5
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/utils/normalizeRelations.ts +52 -52
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/constants/attributes.ts +3 -3
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/hooks/useDragAndDrop.ts +253 -253
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/hooks/useKeyboardDragAndDrop.ts +96 -96
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/hooks/usePrev.ts +11 -11
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/dragAndDrop.ts +8 -8
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/paths.ts +29 -29
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/refs.ts +19 -19
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/translations.ts +3 -3
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/collection-types.ts +300 -300
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/components.ts +72 -72
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/content-types.ts +116 -116
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/index.ts +8 -8
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/init.ts +22 -22
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/relations.ts +80 -80
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/review-workflows.ts +88 -88
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/single-types.ts +112 -112
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/uid.ts +48 -48
- package/admin/src/components/StrapiCore/content-manager/shared/index.ts +1 -1
- package/admin/src/constants.ts +3 -3
- package/admin/src/index.tsx +101 -101
- package/admin/src/middlewares/index.tsx +37 -37
- package/admin/src/pages/app/index.tsx +14 -14
- package/admin/src/pluginId.ts +5 -5
- package/admin/src/translations/en.json +9 -9
- package/admin/src/translations/nl.json +9 -9
- package/admin/src/utils/findDomElement.ts +6 -6
- package/admin/src/utils/findElementParent.ts +20 -20
- package/admin/src/utils/getObjectFromFormName.ts +42 -42
- package/admin/src/utils/getRequestUrl.ts +11 -11
- package/admin/src/utils/getTrad.ts +5 -5
- package/admin/src/utils/hooks/useDebounce.ts +17 -17
- package/admin/src/utils/hooks/useDefaultPlatformFromLocalStorage.ts +61 -61
- package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +9 -9
- package/admin/src/utils/hooks/useHideOverviewFilterTags.ts +34 -34
- package/admin/src/utils/hooks/usePlatformFormData.ts +64 -64
- package/admin/src/utils/hooks/usePrevious.ts +12 -12
- package/admin/src/utils/sanitizeModules.ts +93 -93
- package/custom.d.ts +6 -6
- package/dist/package.json +1 -1
- package/dist/server/bootstrap.js +1 -1
- package/dist/server/graphql/page-by-path.js +20 -17
- package/dist/server/graphql/pages-by-uid.js +5 -5
- package/dist/server/services/private-content/graphql/index.js +27 -27
- package/dist/server/services/private-content/graphql/types/index.js +74 -74
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +78 -78
- package/server/bootstrap/collection-type-lifecycles.ts +47 -47
- package/server/bootstrap/permissions.ts +161 -161
- package/server/bootstrap.ts +261 -261
- package/server/config/index.ts +4 -4
- package/server/content-types/index.ts +7 -7
- package/server/content-types/user-category/schema.json +23 -23
- package/server/controllers/collection-types.ts +32 -32
- package/server/controllers/index.ts +19 -19
- package/server/controllers/page-type.ts +18 -18
- package/server/controllers/page.ts +9 -9
- package/server/controllers/platform.ts +21 -21
- package/server/controllers/private-content.ts +17 -17
- package/server/controllers/sitemap.ts +32 -32
- package/server/controllers/template.ts +16 -16
- package/server/controllers/user-category.ts +3 -3
- package/server/destroy.ts +5 -5
- package/server/graphql/index.ts +9 -9
- package/server/graphql/page-by-path.ts +135 -132
- package/server/graphql/page-type.ts +67 -67
- package/server/graphql/pages-by-uid.ts +89 -89
- package/server/index.ts +23 -23
- package/server/middlewares/index.ts +1 -1
- package/server/policies/index.ts +5 -5
- package/server/policies/isAuthorizedPage.ts +11 -11
- package/server/register.ts +22 -22
- package/server/routes/index.ts +115 -115
- package/server/routes/user-category.ts +3 -3
- package/server/schema/page-end.json +96 -96
- package/server/schema/page-start.json +87 -87
- package/server/schema/page-type-end.json +53 -53
- package/server/schema/page-type-start.json +38 -38
- package/server/schema/platform-start.json +21 -21
- package/server/schema/template-end.json +40 -40
- package/server/schema/template-start.json +35 -35
- package/server/services/builder.ts +232 -232
- package/server/services/collection-types.ts +95 -95
- package/server/services/email.ts +127 -127
- package/server/services/index.ts +23 -23
- package/server/services/page-type.ts +30 -30
- package/server/services/page.ts +24 -24
- package/server/services/platform.ts +30 -30
- package/server/services/private-content/components/admin-email.json +22 -22
- package/server/services/private-content/components/email.json +22 -22
- package/server/services/private-content/components/platform-email.json +30 -30
- package/server/services/private-content/constants/index.ts +13 -13
- package/server/services/private-content/graphql/index.ts +88 -88
- package/server/services/private-content/graphql/resolvers/findOnePage.ts +40 -40
- package/server/services/private-content/graphql/resolvers/findPage.ts +45 -45
- package/server/services/private-content/graphql/resolvers/forgot-password.ts +34 -34
- package/server/services/private-content/graphql/resolvers/login.ts +56 -56
- package/server/services/private-content/graphql/resolvers/register.ts +78 -78
- package/server/services/private-content/graphql/resolvers/reset-password.ts +44 -44
- package/server/services/private-content/graphql/types/index.ts +96 -96
- package/server/services/private-content/index.ts +95 -95
- package/server/services/private-content/mail-template/txtMail.email.template.text.ts +6 -6
- package/server/services/private-content/page.ts +20 -20
- package/server/services/private-content/platform.ts +19 -19
- package/server/services/private-content/schemas/index.ts +28 -28
- package/server/services/private-content/user.ts +197 -197
- package/server/services/sitemap.ts +83 -83
- package/server/services/template.ts +13 -13
- package/server/services/user-category.ts +3 -3
- package/server/utils/filter-underscore-arguments.ts +12 -12
- package/server/utils/reload-strapi-on-load.ts +13 -13
- package/server/utils/strapi.ts +50 -50
- package/shared/utils/constants.ts +8 -8
- package/shared/utils/sleep.ts +1 -1
- package/strapi-admin.js +3 -3
- package/strapi-server.js +3 -3
- package/tsconfig.json +20 -20
- package/tsconfig.server.json +25 -25
- package/dist/server/graphql/page-by-slug.js +0 -89
- package/dist/server/utils/graphql.js +0 -100
- package/dist/server/utils/paginationValidation.js +0 -31
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import uniqBy from 'lodash/uniqBy';
|
|
2
|
-
import { Common } from '@strapi/strapi';
|
|
3
|
-
|
|
4
|
-
import { IGetTranslationPageLinks } from '../controllers/collection-types';
|
|
5
|
-
import { PAGE_TYPE_UID, PLATFORM_UID } from '../../shared/utils/constants';
|
|
6
|
-
|
|
7
|
-
export interface ICollectionTypeGL {
|
|
8
|
-
uid: string;
|
|
9
|
-
type: string;
|
|
10
|
-
inputType: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
async hasPageRelation(uid: string): Promise<{ hasPageRelation: boolean }> {
|
|
15
|
-
const contentType = strapi.contentTypes?.[uid];
|
|
16
|
-
const pageTypesWithUid =
|
|
17
|
-
(await strapi.entityService.findMany(PAGE_TYPE_UID, {
|
|
18
|
-
filters: {
|
|
19
|
-
uid: {
|
|
20
|
-
$eq: uid
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
})) || [];
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
hasPageRelation: Boolean(
|
|
27
|
-
contentType?.attributes?.page &&
|
|
28
|
-
contentType?.attributes?.page?.morphBy === 'collectionTypeData' &&
|
|
29
|
-
(pageTypesWithUid as Record<string, any>[]).length > 0
|
|
30
|
-
)
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
async hasPlatformRelation(uid: string): Promise<{ hasPlatformRelation: boolean }> {
|
|
34
|
-
const contentType = strapi.contentTypes?.[uid];
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
hasPlatformRelation: Boolean(contentType?.attributes?.platform?.target === PLATFORM_UID)
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
withPageMorph(): ICollectionTypeGL[] {
|
|
41
|
-
const { getTypeName, getFiltersInputTypeName } = strapi.plugin('graphql').service('utils').naming;
|
|
42
|
-
|
|
43
|
-
const collectionTypes = Object.entries(strapi.contentTypes)
|
|
44
|
-
.map((ct) => {
|
|
45
|
-
const uid: string = ct?.[0];
|
|
46
|
-
const contentType = ct?.[1] as Record<string, any>;
|
|
47
|
-
const type = contentType ? getTypeName(contentType) : undefined;
|
|
48
|
-
const hasPageMorph = contentType?.attributes?.page?.morphBy === 'collectionTypeData';
|
|
49
|
-
|
|
50
|
-
if (uid && type && hasPageMorph) {
|
|
51
|
-
return {
|
|
52
|
-
uid,
|
|
53
|
-
type: getTypeName(contentType),
|
|
54
|
-
inputType: getFiltersInputTypeName(contentType)
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
.filter(Boolean) as ICollectionTypeGL[];
|
|
59
|
-
|
|
60
|
-
return collectionTypes;
|
|
61
|
-
},
|
|
62
|
-
async getTranslationPageLinks(uid: Common.UID.ContentType, ids: string[]) {
|
|
63
|
-
try {
|
|
64
|
-
const entities = await strapi.entityService.findMany(uid, {
|
|
65
|
-
filters: {
|
|
66
|
-
id: { $in: ids }
|
|
67
|
-
},
|
|
68
|
-
populate: {
|
|
69
|
-
page: {
|
|
70
|
-
populate: {
|
|
71
|
-
localizations: true
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
} as any);
|
|
76
|
-
|
|
77
|
-
let pages: IGetTranslationPageLinks[] = [];
|
|
78
|
-
|
|
79
|
-
// Get all pages linked to the entity
|
|
80
|
-
entities?.forEach((x: any) => {
|
|
81
|
-
x?.page?.forEach((p: any) => {
|
|
82
|
-
pages.push({ id: p.id, locale: p.locale });
|
|
83
|
-
|
|
84
|
-
p.localizations.forEach((l: any) => {
|
|
85
|
-
pages.push({ id: l.id, locale: l.locale });
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
return uniqBy(pages, 'id');
|
|
91
|
-
} catch {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
1
|
+
import uniqBy from 'lodash/uniqBy';
|
|
2
|
+
import { Common } from '@strapi/strapi';
|
|
3
|
+
|
|
4
|
+
import { IGetTranslationPageLinks } from '../controllers/collection-types';
|
|
5
|
+
import { PAGE_TYPE_UID, PLATFORM_UID } from '../../shared/utils/constants';
|
|
6
|
+
|
|
7
|
+
export interface ICollectionTypeGL {
|
|
8
|
+
uid: string;
|
|
9
|
+
type: string;
|
|
10
|
+
inputType: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
async hasPageRelation(uid: string): Promise<{ hasPageRelation: boolean }> {
|
|
15
|
+
const contentType = strapi.contentTypes?.[uid];
|
|
16
|
+
const pageTypesWithUid =
|
|
17
|
+
(await strapi.entityService.findMany(PAGE_TYPE_UID, {
|
|
18
|
+
filters: {
|
|
19
|
+
uid: {
|
|
20
|
+
$eq: uid
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})) || [];
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
hasPageRelation: Boolean(
|
|
27
|
+
contentType?.attributes?.page &&
|
|
28
|
+
contentType?.attributes?.page?.morphBy === 'collectionTypeData' &&
|
|
29
|
+
(pageTypesWithUid as Record<string, any>[]).length > 0
|
|
30
|
+
)
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
async hasPlatformRelation(uid: string): Promise<{ hasPlatformRelation: boolean }> {
|
|
34
|
+
const contentType = strapi.contentTypes?.[uid];
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
hasPlatformRelation: Boolean(contentType?.attributes?.platform?.target === PLATFORM_UID)
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
withPageMorph(): ICollectionTypeGL[] {
|
|
41
|
+
const { getTypeName, getFiltersInputTypeName } = strapi.plugin('graphql').service('utils').naming;
|
|
42
|
+
|
|
43
|
+
const collectionTypes = Object.entries(strapi.contentTypes)
|
|
44
|
+
.map((ct) => {
|
|
45
|
+
const uid: string = ct?.[0];
|
|
46
|
+
const contentType = ct?.[1] as Record<string, any>;
|
|
47
|
+
const type = contentType ? getTypeName(contentType) : undefined;
|
|
48
|
+
const hasPageMorph = contentType?.attributes?.page?.morphBy === 'collectionTypeData';
|
|
49
|
+
|
|
50
|
+
if (uid && type && hasPageMorph) {
|
|
51
|
+
return {
|
|
52
|
+
uid,
|
|
53
|
+
type: getTypeName(contentType),
|
|
54
|
+
inputType: getFiltersInputTypeName(contentType)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.filter(Boolean) as ICollectionTypeGL[];
|
|
59
|
+
|
|
60
|
+
return collectionTypes;
|
|
61
|
+
},
|
|
62
|
+
async getTranslationPageLinks(uid: Common.UID.ContentType, ids: string[]) {
|
|
63
|
+
try {
|
|
64
|
+
const entities = await strapi.entityService.findMany(uid, {
|
|
65
|
+
filters: {
|
|
66
|
+
id: { $in: ids }
|
|
67
|
+
},
|
|
68
|
+
populate: {
|
|
69
|
+
page: {
|
|
70
|
+
populate: {
|
|
71
|
+
localizations: true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} as any);
|
|
76
|
+
|
|
77
|
+
let pages: IGetTranslationPageLinks[] = [];
|
|
78
|
+
|
|
79
|
+
// Get all pages linked to the entity
|
|
80
|
+
entities?.forEach((x: any) => {
|
|
81
|
+
x?.page?.forEach((p: any) => {
|
|
82
|
+
pages.push({ id: p.id, locale: p.locale });
|
|
83
|
+
|
|
84
|
+
p.localizations.forEach((l: any) => {
|
|
85
|
+
pages.push({ id: l.id, locale: l.locale });
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return uniqBy(pages, 'id');
|
|
91
|
+
} catch {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
package/server/services/email.ts
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import * as AWS from '@aws-sdk/client-ses';
|
|
2
|
-
import { txtEmail } from './private-content/mail-template/txtMail.email.template.text';
|
|
3
|
-
import { USER_PERMISSION_USER_PLUGIN } from '../../shared/utils/constants';
|
|
4
|
-
|
|
5
|
-
interface SendOptions {
|
|
6
|
-
from: string;
|
|
7
|
-
to: string;
|
|
8
|
-
subject: string;
|
|
9
|
-
text: string;
|
|
10
|
-
variables?: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
async sendMail(options: SendOptions) {
|
|
15
|
-
const { from, to, subject, text, variables } = options;
|
|
16
|
-
|
|
17
|
-
const emailData = txtEmail(text, variables);
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const client = new AWS.SES();
|
|
21
|
-
await client.sendEmail({
|
|
22
|
-
Source: from,
|
|
23
|
-
Destination: {
|
|
24
|
-
ToAddresses: [to]
|
|
25
|
-
},
|
|
26
|
-
Message: {
|
|
27
|
-
Subject: { Data: subject },
|
|
28
|
-
Body: {
|
|
29
|
-
Text: { Data: emailData }
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(error);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
async sendAdminMail(user) {
|
|
38
|
-
const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
39
|
-
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
40
|
-
});
|
|
41
|
-
await this.sendMail({
|
|
42
|
-
// @ts-ignore we all love strapi typings
|
|
43
|
-
from: foundUser.platform.platformEmails.adminEmail.fromEmail,
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
to: foundUser.platform.platformEmails.adminEmail.toEmail,
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
subject: foundUser.platform.platformEmails.adminEmail.subject,
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
text: foundUser.platform.platformEmails.adminEmail.message,
|
|
50
|
-
variables: {
|
|
51
|
-
firstName: user.firstName,
|
|
52
|
-
lastName: user.lastName
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
async sendConfirmationEmail(user) {
|
|
57
|
-
const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
58
|
-
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
59
|
-
});
|
|
60
|
-
if (foundUser && foundUser.platform) {
|
|
61
|
-
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
62
|
-
const confirmationToken = await jwtService.issue(
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
{ userId: user.id, platformId: foundUser.platform.id },
|
|
65
|
-
{ expiresIn: '1d' }
|
|
66
|
-
);
|
|
67
|
-
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
data: { confirmationToken: confirmationToken }
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
const confirmEmailUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
|
|
74
|
-
|
|
75
|
-
await this.sendMail({
|
|
76
|
-
// @ts-ignore
|
|
77
|
-
from: foundUser.platform.platformEmails.accountCreatedMail.fromEmail,
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
to: foundUser.email,
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
subject: foundUser.platform.platformEmails.accountCreatedMail.subject,
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
text: foundUser.platform.platformEmails.accountCreatedMail.message,
|
|
84
|
-
variables: {
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
firstName: foundUser.firstName,
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
lastName: foundUser.lastName,
|
|
89
|
-
confirmEmailUrl
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
async sendForgotPasswordMail(user) {
|
|
95
|
-
if (user && user.platform) {
|
|
96
|
-
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
97
|
-
|
|
98
|
-
const resetPasswordToken = await jwtService.issue(
|
|
99
|
-
{ userId: user.id, platformId: user.platform.id },
|
|
100
|
-
{ expiresIn: '1d' }
|
|
101
|
-
);
|
|
102
|
-
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
data: { resetPasswordToken }
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
const searchParams = new URLSearchParams({ token: resetPasswordToken });
|
|
109
|
-
const resetPasswordUrl = `${user.platform.domain}/wachtwoord-resetten/?${searchParams.toString()}`;
|
|
110
|
-
|
|
111
|
-
await this.sendMail({
|
|
112
|
-
// @ts-ignore
|
|
113
|
-
from: user.platform.platformEmails.resetPasswordMail.fromEmail,
|
|
114
|
-
to: user.email,
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
subject: user.platform.platformEmails.resetPasswordMail.subject,
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
text: user.platform.platformEmails.resetPasswordMail.message,
|
|
119
|
-
variables: {
|
|
120
|
-
firstName: user?.firstName,
|
|
121
|
-
lastName: user?.lastName,
|
|
122
|
-
resetPasswordUrl
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
1
|
+
import * as AWS from '@aws-sdk/client-ses';
|
|
2
|
+
import { txtEmail } from './private-content/mail-template/txtMail.email.template.text';
|
|
3
|
+
import { USER_PERMISSION_USER_PLUGIN } from '../../shared/utils/constants';
|
|
4
|
+
|
|
5
|
+
interface SendOptions {
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
subject: string;
|
|
9
|
+
text: string;
|
|
10
|
+
variables?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
async sendMail(options: SendOptions) {
|
|
15
|
+
const { from, to, subject, text, variables } = options;
|
|
16
|
+
|
|
17
|
+
const emailData = txtEmail(text, variables);
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const client = new AWS.SES();
|
|
21
|
+
await client.sendEmail({
|
|
22
|
+
Source: from,
|
|
23
|
+
Destination: {
|
|
24
|
+
ToAddresses: [to]
|
|
25
|
+
},
|
|
26
|
+
Message: {
|
|
27
|
+
Subject: { Data: subject },
|
|
28
|
+
Body: {
|
|
29
|
+
Text: { Data: emailData }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error(error);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
async sendAdminMail(user) {
|
|
38
|
+
const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
39
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
40
|
+
});
|
|
41
|
+
await this.sendMail({
|
|
42
|
+
// @ts-ignore we all love strapi typings
|
|
43
|
+
from: foundUser.platform.platformEmails.adminEmail.fromEmail,
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
to: foundUser.platform.platformEmails.adminEmail.toEmail,
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
subject: foundUser.platform.platformEmails.adminEmail.subject,
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
text: foundUser.platform.platformEmails.adminEmail.message,
|
|
50
|
+
variables: {
|
|
51
|
+
firstName: user.firstName,
|
|
52
|
+
lastName: user.lastName
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
async sendConfirmationEmail(user) {
|
|
57
|
+
const foundUser = await strapi.entityService.findOne(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
58
|
+
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
59
|
+
});
|
|
60
|
+
if (foundUser && foundUser.platform) {
|
|
61
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
62
|
+
const confirmationToken = await jwtService.issue(
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
{ userId: user.id, platformId: foundUser.platform.id },
|
|
65
|
+
{ expiresIn: '1d' }
|
|
66
|
+
);
|
|
67
|
+
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
data: { confirmationToken: confirmationToken }
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
const confirmEmailUrl = `${strapi.config.server.url}/api/page-builder/activate/${confirmationToken}`;
|
|
74
|
+
|
|
75
|
+
await this.sendMail({
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
from: foundUser.platform.platformEmails.accountCreatedMail.fromEmail,
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
to: foundUser.email,
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
subject: foundUser.platform.platformEmails.accountCreatedMail.subject,
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
text: foundUser.platform.platformEmails.accountCreatedMail.message,
|
|
84
|
+
variables: {
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
firstName: foundUser.firstName,
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
lastName: foundUser.lastName,
|
|
89
|
+
confirmEmailUrl
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
async sendForgotPasswordMail(user) {
|
|
95
|
+
if (user && user.platform) {
|
|
96
|
+
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
97
|
+
|
|
98
|
+
const resetPasswordToken = await jwtService.issue(
|
|
99
|
+
{ userId: user.id, platformId: user.platform.id },
|
|
100
|
+
{ expiresIn: '1d' }
|
|
101
|
+
);
|
|
102
|
+
await strapi.entityService.update(USER_PERMISSION_USER_PLUGIN, user.id, {
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
data: { resetPasswordToken }
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
const searchParams = new URLSearchParams({ token: resetPasswordToken });
|
|
109
|
+
const resetPasswordUrl = `${user.platform.domain}/wachtwoord-resetten/?${searchParams.toString()}`;
|
|
110
|
+
|
|
111
|
+
await this.sendMail({
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
from: user.platform.platformEmails.resetPasswordMail.fromEmail,
|
|
114
|
+
to: user.email,
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
subject: user.platform.platformEmails.resetPasswordMail.subject,
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
text: user.platform.platformEmails.resetPasswordMail.message,
|
|
119
|
+
variables: {
|
|
120
|
+
firstName: user?.firstName,
|
|
121
|
+
lastName: user?.lastName,
|
|
122
|
+
resetPasswordUrl
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
package/server/services/index.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import page from './page';
|
|
2
|
-
import builder from './builder';
|
|
3
|
-
import pageType from './page-type';
|
|
4
|
-
import collectionTypes from './collection-types';
|
|
5
|
-
import template from './template';
|
|
6
|
-
import platform from './platform';
|
|
7
|
-
import sitemap from './sitemap';
|
|
8
|
-
import email from './email';
|
|
9
|
-
import privateContent from './private-content';
|
|
10
|
-
import userCategory from './user-category';
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
page,
|
|
14
|
-
builder,
|
|
15
|
-
'page-type': pageType,
|
|
16
|
-
'collection-types': collectionTypes,
|
|
17
|
-
template,
|
|
18
|
-
platform,
|
|
19
|
-
sitemap,
|
|
20
|
-
email,
|
|
21
|
-
'private-content': privateContent,
|
|
22
|
-
'user-category': userCategory
|
|
23
|
-
};
|
|
1
|
+
import page from './page';
|
|
2
|
+
import builder from './builder';
|
|
3
|
+
import pageType from './page-type';
|
|
4
|
+
import collectionTypes from './collection-types';
|
|
5
|
+
import template from './template';
|
|
6
|
+
import platform from './platform';
|
|
7
|
+
import sitemap from './sitemap';
|
|
8
|
+
import email from './email';
|
|
9
|
+
import privateContent from './private-content';
|
|
10
|
+
import userCategory from './user-category';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
page,
|
|
14
|
+
builder,
|
|
15
|
+
'page-type': pageType,
|
|
16
|
+
'collection-types': collectionTypes,
|
|
17
|
+
template,
|
|
18
|
+
platform,
|
|
19
|
+
sitemap,
|
|
20
|
+
email,
|
|
21
|
+
'private-content': privateContent,
|
|
22
|
+
'user-category': userCategory
|
|
23
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { PAGE_TYPE_UID } from '../../shared/utils/constants';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async findOneByUid(uid: string, platformId: number) {
|
|
5
|
-
const results = await strapi.entityService?.findMany(PAGE_TYPE_UID, {
|
|
6
|
-
populate: {
|
|
7
|
-
template: {
|
|
8
|
-
populate: {
|
|
9
|
-
modules: true
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
defaultParent: true
|
|
13
|
-
},
|
|
14
|
-
filters: {
|
|
15
|
-
uid,
|
|
16
|
-
platform: {
|
|
17
|
-
id: platformId
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const result = (results as any[]).length > 0 ? results?.[0] : undefined;
|
|
23
|
-
|
|
24
|
-
if (result) {
|
|
25
|
-
return result;
|
|
26
|
-
} else {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
1
|
+
import { PAGE_TYPE_UID } from '../../shared/utils/constants';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async findOneByUid(uid: string, platformId: number) {
|
|
5
|
+
const results = await strapi.entityService?.findMany(PAGE_TYPE_UID, {
|
|
6
|
+
populate: {
|
|
7
|
+
template: {
|
|
8
|
+
populate: {
|
|
9
|
+
modules: true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
defaultParent: true
|
|
13
|
+
},
|
|
14
|
+
filters: {
|
|
15
|
+
uid,
|
|
16
|
+
platform: {
|
|
17
|
+
id: platformId
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const result = (results as any[]).length > 0 ? results?.[0] : undefined;
|
|
23
|
+
|
|
24
|
+
if (result) {
|
|
25
|
+
return result;
|
|
26
|
+
} else {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
package/server/services/page.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { PAGE_UID } from '../../shared/utils/constants';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async getPage(id: string) {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const page = await strapi.db.query(PAGE_UID).findOne({
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
select: 'id',
|
|
9
|
-
populate: {
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
collectionTypeData: true,
|
|
12
|
-
pageType: true
|
|
13
|
-
},
|
|
14
|
-
where: {
|
|
15
|
-
id
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
pageType: page.pageType,
|
|
21
|
-
collectionTypeData: page.collectionTypeData?.[0] ?? null
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
};
|
|
1
|
+
import { PAGE_UID } from '../../shared/utils/constants';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async getPage(id: string) {
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
const page = await strapi.db.query(PAGE_UID).findOne({
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
select: 'id',
|
|
9
|
+
populate: {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
collectionTypeData: true,
|
|
12
|
+
pageType: true
|
|
13
|
+
},
|
|
14
|
+
where: {
|
|
15
|
+
id
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
pageType: page.pageType,
|
|
21
|
+
collectionTypeData: page.collectionTypeData?.[0] ?? null
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { PLATFORM_UID } from '../../shared/utils/constants';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async findAll() {
|
|
5
|
-
return await strapi.entityService.findMany(PLATFORM_UID, { populate: '*' });
|
|
6
|
-
},
|
|
7
|
-
async findOneById(id: string) {
|
|
8
|
-
return await strapi.entityService.findOne(PLATFORM_UID, id, {
|
|
9
|
-
populate: '*'
|
|
10
|
-
});
|
|
11
|
-
},
|
|
12
|
-
async findPageTypesByPlatform(id: string) {
|
|
13
|
-
const results = await strapi.entityService.findMany(PLATFORM_UID, {
|
|
14
|
-
populate: {
|
|
15
|
-
pagetype: true
|
|
16
|
-
},
|
|
17
|
-
filters: {
|
|
18
|
-
id: {
|
|
19
|
-
$eq: id
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if ((results as any[]).length > 0) {
|
|
25
|
-
return results;
|
|
26
|
-
} else {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
1
|
+
import { PLATFORM_UID } from '../../shared/utils/constants';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async findAll() {
|
|
5
|
+
return await strapi.entityService.findMany(PLATFORM_UID, { populate: '*' });
|
|
6
|
+
},
|
|
7
|
+
async findOneById(id: string) {
|
|
8
|
+
return await strapi.entityService.findOne(PLATFORM_UID, id, {
|
|
9
|
+
populate: '*'
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
async findPageTypesByPlatform(id: string) {
|
|
13
|
+
const results = await strapi.entityService.findMany(PLATFORM_UID, {
|
|
14
|
+
populate: {
|
|
15
|
+
pagetype: true
|
|
16
|
+
},
|
|
17
|
+
filters: {
|
|
18
|
+
id: {
|
|
19
|
+
$eq: id
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if ((results as any[]).length > 0) {
|
|
25
|
+
return results;
|
|
26
|
+
} else {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|