@strapi/admin 5.12.5 → 5.12.7
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/dist/admin/admin/src/core/apis/Widgets.js.map +1 -1
- package/dist/admin/admin/src/core/apis/Widgets.mjs.map +1 -1
- package/dist/admin/admin/src/features/Auth.js +2 -1
- package/dist/admin/admin/src/features/Auth.js.map +1 -1
- package/dist/admin/admin/src/features/Auth.mjs +2 -1
- package/dist/admin/admin/src/features/Auth.mjs.map +1 -1
- package/dist/admin/admin/src/features/Tracking.js +6 -2
- package/dist/admin/admin/src/features/Tracking.js.map +1 -1
- package/dist/admin/admin/src/features/Tracking.mjs +6 -2
- package/dist/admin/admin/src/features/Tracking.mjs.map +1 -1
- package/dist/admin/admin/src/layouts/AuthenticatedLayout.js.map +1 -1
- package/dist/admin/admin/src/layouts/AuthenticatedLayout.mjs.map +1 -1
- package/dist/admin/admin/src/pages/Home/HomePage.js +54 -13
- package/dist/admin/admin/src/pages/Home/HomePage.js.map +1 -1
- package/dist/admin/admin/src/pages/Home/HomePage.mjs +54 -13
- package/dist/admin/admin/src/pages/Home/HomePage.mjs.map +1 -1
- package/dist/admin/admin/src/pages/Home/components/ContentManagerWidgets.js +0 -1
- package/dist/admin/admin/src/pages/Home/components/ContentManagerWidgets.js.map +1 -1
- package/dist/admin/admin/src/pages/Home/components/ContentManagerWidgets.mjs +0 -1
- package/dist/admin/admin/src/pages/Home/components/ContentManagerWidgets.mjs.map +1 -1
- package/dist/admin/admin/src/pages/Settings/pages/Webhooks/components/HeadersInput.js +3 -1
- package/dist/admin/admin/src/pages/Settings/pages/Webhooks/components/HeadersInput.js.map +1 -1
- package/dist/admin/admin/src/pages/Settings/pages/Webhooks/components/HeadersInput.mjs +3 -1
- package/dist/admin/admin/src/pages/Settings/pages/Webhooks/components/HeadersInput.mjs.map +1 -1
- package/dist/admin/admin/src/services/homepage.js +1 -1
- package/dist/admin/admin/src/services/homepage.js.map +1 -1
- package/dist/admin/admin/src/services/homepage.mjs +1 -1
- package/dist/admin/admin/src/services/homepage.mjs.map +1 -1
- package/dist/admin/src/core/apis/Widgets.d.ts +1 -1
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/Home/HomePage.d.ts +3 -5
- package/dist/server/server/src/controllers/index.js +1 -3
- package/dist/server/server/src/controllers/index.js.map +1 -1
- package/dist/server/server/src/controllers/index.mjs +1 -3
- package/dist/server/server/src/controllers/index.mjs.map +1 -1
- package/dist/server/server/src/routes/index.js +1 -3
- package/dist/server/server/src/routes/index.js.map +1 -1
- package/dist/server/server/src/routes/index.mjs +1 -3
- package/dist/server/server/src/routes/index.mjs.map +1 -1
- package/dist/server/server/src/services/index.js +1 -3
- package/dist/server/server/src/services/index.js.map +1 -1
- package/dist/server/server/src/services/index.mjs +1 -3
- package/dist/server/server/src/services/index.mjs.map +1 -1
- package/dist/server/src/controllers/index.d.ts +0 -3
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +0 -9
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +0 -6
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/server/server/src/controllers/homepage.js +0 -58
- package/dist/server/server/src/controllers/homepage.js.map +0 -1
- package/dist/server/server/src/controllers/homepage.mjs +0 -37
- package/dist/server/server/src/controllers/homepage.mjs.map +0 -1
- package/dist/server/server/src/routes/homepage.js +0 -22
- package/dist/server/server/src/routes/homepage.js.map +0 -1
- package/dist/server/server/src/routes/homepage.mjs +0 -20
- package/dist/server/server/src/routes/homepage.mjs.map +0 -1
- package/dist/server/server/src/services/homepage.js +0 -159
- package/dist/server/server/src/services/homepage.js.map +0 -1
- package/dist/server/server/src/services/homepage.mjs +0 -157
- package/dist/server/server/src/services/homepage.mjs.map +0 -1
- package/dist/server/src/controllers/homepage.d.ts +0 -8
- package/dist/server/src/controllers/homepage.d.ts.map +0 -1
- package/dist/server/src/routes/homepage.d.ts +0 -14
- package/dist/server/src/routes/homepage.d.ts.map +0 -1
- package/dist/server/src/services/homepage.d.ts +0 -14
- package/dist/server/src/services/homepage.d.ts.map +0 -1
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as yup from 'yup';
|
|
2
|
-
import { errors } from '@strapi/utils';
|
|
3
|
-
import { getService } from '../utils/index.mjs';
|
|
4
|
-
|
|
5
|
-
const createHomepageController = ()=>{
|
|
6
|
-
const homepageService = getService('homepage');
|
|
7
|
-
const recentDocumentParamsSchema = yup.object().shape({
|
|
8
|
-
action: yup.mixed().oneOf([
|
|
9
|
-
'update',
|
|
10
|
-
'publish'
|
|
11
|
-
]).required()
|
|
12
|
-
});
|
|
13
|
-
return {
|
|
14
|
-
async getRecentDocuments (ctx) {
|
|
15
|
-
let action;
|
|
16
|
-
try {
|
|
17
|
-
action = (await recentDocumentParamsSchema.validate(ctx.query)).action;
|
|
18
|
-
} catch (error) {
|
|
19
|
-
if (error instanceof yup.ValidationError) {
|
|
20
|
-
throw new errors.ValidationError(error.message);
|
|
21
|
-
}
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
if (action === 'publish') {
|
|
25
|
-
return {
|
|
26
|
-
data: await homepageService.getRecentlyPublishedDocuments()
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
data: await homepageService.getRecentlyUpdatedDocuments()
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { createHomepageController };
|
|
37
|
-
//# sourceMappingURL=homepage.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.mjs","sources":["../../../../../server/src/controllers/homepage.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as yup from 'yup';\nimport { errors } from '@strapi/utils';\nimport { getService } from '../utils';\nimport type { GetRecentDocuments } from '../../../shared/contracts/homepage';\n\nconst createHomepageController = () => {\n const homepageService = getService('homepage');\n\n const recentDocumentParamsSchema = yup.object().shape({\n action: yup\n .mixed<GetRecentDocuments.Request['query']['action']>()\n .oneOf(['update', 'publish'])\n .required(),\n });\n\n return {\n async getRecentDocuments(ctx): Promise<GetRecentDocuments.Response> {\n let action;\n\n try {\n action = (await recentDocumentParamsSchema.validate(ctx.query)).action;\n } catch (error) {\n if (error instanceof yup.ValidationError) {\n throw new errors.ValidationError(error.message);\n }\n throw error;\n }\n\n if (action === 'publish') {\n return { data: await homepageService.getRecentlyPublishedDocuments() };\n }\n\n return { data: await homepageService.getRecentlyUpdatedDocuments() };\n },\n } satisfies Core.Controller;\n};\n\nexport { createHomepageController };\n"],"names":["createHomepageController","homepageService","getService","recentDocumentParamsSchema","yup","object","shape","action","mixed","oneOf","required","getRecentDocuments","ctx","validate","query","error","ValidationError","errors","message","data","getRecentlyPublishedDocuments","getRecentlyUpdatedDocuments"],"mappings":";;;;AAMA,MAAMA,wBAA2B,GAAA,IAAA;AAC/B,IAAA,MAAMC,kBAAkBC,UAAW,CAAA,UAAA,CAAA;AAEnC,IAAA,MAAMC,0BAA6BC,GAAAA,GAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACpDC,QAAAA,MAAAA,EAAQH,GACLI,CAAAA,KAAK,EACLC,CAAAA,KAAK,CAAC;AAAC,YAAA,QAAA;AAAU,YAAA;AAAU,SAAA,CAAA,CAC3BC,QAAQ;AACb,KAAA,CAAA;IAEA,OAAO;AACL,QAAA,MAAMC,oBAAmBC,GAAG,EAAA;YAC1B,IAAIL,MAAAA;YAEJ,IAAI;gBACFA,MAAS,GAAC,CAAA,MAAMJ,0BAA2BU,CAAAA,QAAQ,CAACD,GAAIE,CAAAA,KAAK,CAAA,EAAGP,MAAM;AACxE,aAAA,CAAE,OAAOQ,KAAO,EAAA;gBACd,IAAIA,KAAAA,YAAiBX,GAAIY,CAAAA,eAAe,EAAE;AACxC,oBAAA,MAAM,IAAIC,MAAAA,CAAOD,eAAe,CAACD,MAAMG,OAAO,CAAA;AAChD;gBACA,MAAMH,KAAAA;AACR;AAEA,YAAA,IAAIR,WAAW,SAAW,EAAA;gBACxB,OAAO;oBAAEY,IAAM,EAAA,MAAMlB,gBAAgBmB,6BAA6B;AAAG,iBAAA;AACvE;YAEA,OAAO;gBAAED,IAAM,EAAA,MAAMlB,gBAAgBoB,2BAA2B;AAAG,aAAA;AACrE;AACF,KAAA;AACF;;;;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const info = {
|
|
4
|
-
pluginName: 'admin',
|
|
5
|
-
type: 'admin'
|
|
6
|
-
};
|
|
7
|
-
var homepage = [
|
|
8
|
-
{
|
|
9
|
-
method: 'GET',
|
|
10
|
-
info,
|
|
11
|
-
path: '/homepage/recent-documents',
|
|
12
|
-
handler: 'homepage.getRecentDocuments',
|
|
13
|
-
config: {
|
|
14
|
-
policies: [
|
|
15
|
-
'admin::isAuthenticatedAdmin'
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
module.exports = homepage;
|
|
22
|
-
//# sourceMappingURL=homepage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.js","sources":["../../../../../server/src/routes/homepage.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nconst info = { pluginName: 'admin', type: 'admin' };\n\nexport default [\n {\n method: 'GET',\n info,\n path: '/homepage/recent-documents',\n handler: 'homepage.getRecentDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n] satisfies Plugin.LoadedPlugin['routes'][string]['routes'];\n"],"names":["info","pluginName","type","method","path","handler","config","policies"],"mappings":";;AAEA,MAAMA,IAAO,GAAA;IAAEC,UAAY,EAAA,OAAA;IAASC,IAAM,EAAA;AAAQ,CAAA;AAElD,eAAe;AACb,IAAA;QACEC,MAAQ,EAAA,KAAA;AACRH,QAAAA,IAAAA;QACAI,IAAM,EAAA,4BAAA;QACNC,OAAS,EAAA,6BAAA;QACTC,MAAQ,EAAA;YACNC,QAAU,EAAA;AAAC,gBAAA;AAA8B;AAC3C;AACF;CACD;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const info = {
|
|
2
|
-
pluginName: 'admin',
|
|
3
|
-
type: 'admin'
|
|
4
|
-
};
|
|
5
|
-
var homepage = [
|
|
6
|
-
{
|
|
7
|
-
method: 'GET',
|
|
8
|
-
info,
|
|
9
|
-
path: '/homepage/recent-documents',
|
|
10
|
-
handler: 'homepage.getRecentDocuments',
|
|
11
|
-
config: {
|
|
12
|
-
policies: [
|
|
13
|
-
'admin::isAuthenticatedAdmin'
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
export { homepage as default };
|
|
20
|
-
//# sourceMappingURL=homepage.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.mjs","sources":["../../../../../server/src/routes/homepage.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nconst info = { pluginName: 'admin', type: 'admin' };\n\nexport default [\n {\n method: 'GET',\n info,\n path: '/homepage/recent-documents',\n handler: 'homepage.getRecentDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n] satisfies Plugin.LoadedPlugin['routes'][string]['routes'];\n"],"names":["info","pluginName","type","method","path","handler","config","policies"],"mappings":"AAEA,MAAMA,IAAO,GAAA;IAAEC,UAAY,EAAA,OAAA;IAASC,IAAM,EAAA;AAAQ,CAAA;AAElD,eAAe;AACb,IAAA;QACEC,MAAQ,EAAA,KAAA;AACRH,QAAAA,IAAAA;QACAI,IAAM,EAAA,4BAAA;QACNC,OAAS,EAAA,6BAAA;QACTC,MAAQ,EAAA;YACNC,QAAU,EAAA;AAAC,gBAAA;AAA8B;AAC3C;AACF;CACD;;;;"}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('@strapi/utils');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* TODO: Remove this service when the future flag for the widget api is removed
|
|
7
|
-
*/ const createHomepageService = ({ strapi })=>{
|
|
8
|
-
const MAX_DOCUMENTS = 4;
|
|
9
|
-
const metadataService = strapi.plugin('content-manager').service('document-metadata');
|
|
10
|
-
const permissionService = strapi.admin.services.permission;
|
|
11
|
-
const getConfiguration = async (contentTypeUids)=>{
|
|
12
|
-
/**
|
|
13
|
-
* Don't use the strapi.store util because we need to make
|
|
14
|
-
* more precise queries than exact key matches, in order to make as few queries as possible.
|
|
15
|
-
*/ const coreStore = strapi.db.query('strapi::core-store');
|
|
16
|
-
const rawConfigurations = await coreStore.findMany({
|
|
17
|
-
where: {
|
|
18
|
-
key: {
|
|
19
|
-
$in: contentTypeUids.map((contentType)=>`plugin_content_manager_configuration_content_types::${contentType}`)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return rawConfigurations.map((rawConfiguration)=>{
|
|
24
|
-
return JSON.parse(rawConfiguration.value);
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
const getPermittedContentTypes = async ()=>{
|
|
28
|
-
const readPermissions = await permissionService.findMany({
|
|
29
|
-
where: {
|
|
30
|
-
role: {
|
|
31
|
-
users: {
|
|
32
|
-
id: strapi.requestContext.get()?.state?.user.id
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
action: 'plugin::content-manager.explorer.read'
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
return readPermissions.map((permission)=>permission.subject).filter(Boolean);
|
|
39
|
-
};
|
|
40
|
-
const getContentTypesMeta = (allowedContentTypeUids, configurations)=>{
|
|
41
|
-
return allowedContentTypeUids.map((uid)=>{
|
|
42
|
-
const configuration = configurations.find((config)=>config.uid === uid);
|
|
43
|
-
const contentType = strapi.contentType(uid);
|
|
44
|
-
const fields = [
|
|
45
|
-
'documentId',
|
|
46
|
-
'updatedAt'
|
|
47
|
-
];
|
|
48
|
-
// Add fields required to get the status if D&P is enabled
|
|
49
|
-
const hasDraftAndPublish = utils.contentTypes.hasDraftAndPublish(contentType);
|
|
50
|
-
if (hasDraftAndPublish) {
|
|
51
|
-
fields.push('publishedAt');
|
|
52
|
-
}
|
|
53
|
-
// Only add the main field if it's defined
|
|
54
|
-
if (configuration?.settings.mainField) {
|
|
55
|
-
fields.push(configuration.settings.mainField);
|
|
56
|
-
}
|
|
57
|
-
// Only add locale if it's localized
|
|
58
|
-
const isLocalized = contentType.pluginOptions?.i18n?.localized;
|
|
59
|
-
if (isLocalized) {
|
|
60
|
-
fields.push('locale');
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
fields,
|
|
64
|
-
mainField: configuration.settings.mainField,
|
|
65
|
-
contentType,
|
|
66
|
-
hasDraftAndPublish,
|
|
67
|
-
uid
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
const formatDocuments = (documents, meta)=>{
|
|
72
|
-
return documents.map((document)=>{
|
|
73
|
-
return {
|
|
74
|
-
documentId: document.documentId,
|
|
75
|
-
locale: document.locale ?? null,
|
|
76
|
-
updatedAt: new Date(document.updatedAt),
|
|
77
|
-
title: document[meta.mainField ?? 'documentId'],
|
|
78
|
-
publishedAt: meta.hasDraftAndPublish && document.publishedAt ? new Date(document.publishedAt) : null,
|
|
79
|
-
contentTypeUid: meta.uid,
|
|
80
|
-
contentTypeDisplayName: meta.contentType.info.displayName,
|
|
81
|
-
kind: meta.contentType.kind
|
|
82
|
-
};
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const addStatusToDocuments = async (documents)=>{
|
|
86
|
-
return Promise.all(documents.map(async (recentDocument)=>{
|
|
87
|
-
const hasDraftAndPublish = utils.contentTypes.hasDraftAndPublish(strapi.contentType(recentDocument.contentTypeUid));
|
|
88
|
-
/**
|
|
89
|
-
* Tries to query the other version of the document if draft and publish is enabled,
|
|
90
|
-
* so that we know when to give the "modified" status.
|
|
91
|
-
*/ const { availableStatus } = await metadataService.getMetadata(recentDocument.contentTypeUid, recentDocument, {
|
|
92
|
-
availableStatus: hasDraftAndPublish,
|
|
93
|
-
availableLocales: false
|
|
94
|
-
});
|
|
95
|
-
const status = metadataService.getStatus(recentDocument, availableStatus);
|
|
96
|
-
return {
|
|
97
|
-
...recentDocument,
|
|
98
|
-
status: hasDraftAndPublish ? status : undefined
|
|
99
|
-
};
|
|
100
|
-
}));
|
|
101
|
-
};
|
|
102
|
-
const permissionCheckerService = strapi.plugin('content-manager').service('permission-checker');
|
|
103
|
-
const getPermissionChecker = (uid)=>permissionCheckerService.create({
|
|
104
|
-
userAbility: strapi.requestContext.get()?.state.userAbility,
|
|
105
|
-
model: uid
|
|
106
|
-
});
|
|
107
|
-
return {
|
|
108
|
-
async getRecentlyPublishedDocuments () {
|
|
109
|
-
const permittedContentTypes = await getPermittedContentTypes();
|
|
110
|
-
const allowedContentTypeUids = permittedContentTypes.filter((uid)=>{
|
|
111
|
-
return utils.contentTypes.hasDraftAndPublish(strapi.contentType(uid));
|
|
112
|
-
});
|
|
113
|
-
// Fetch the configuration for each content type in a single query
|
|
114
|
-
const configurations = await getConfiguration(allowedContentTypeUids);
|
|
115
|
-
// Get the necessary metadata for the documents
|
|
116
|
-
const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);
|
|
117
|
-
// Now actually fetch and format the documents
|
|
118
|
-
const recentDocuments = await Promise.all(contentTypesMeta.map(async (meta)=>{
|
|
119
|
-
const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({
|
|
120
|
-
limit: MAX_DOCUMENTS,
|
|
121
|
-
sort: 'publishedAt:desc',
|
|
122
|
-
fields: meta.fields,
|
|
123
|
-
status: 'published'
|
|
124
|
-
});
|
|
125
|
-
const docs = await strapi.documents(meta.uid).findMany(permissionQuery);
|
|
126
|
-
return formatDocuments(docs, meta);
|
|
127
|
-
}));
|
|
128
|
-
const overallRecentDocuments = recentDocuments.flat().sort((a, b)=>{
|
|
129
|
-
if (!a.publishedAt || !b.publishedAt) return 0;
|
|
130
|
-
return b.publishedAt.valueOf() - a.publishedAt.valueOf();
|
|
131
|
-
}).slice(0, MAX_DOCUMENTS);
|
|
132
|
-
return addStatusToDocuments(overallRecentDocuments);
|
|
133
|
-
},
|
|
134
|
-
async getRecentlyUpdatedDocuments () {
|
|
135
|
-
const allowedContentTypeUids = await getPermittedContentTypes();
|
|
136
|
-
// Fetch the configuration for each content type in a single query
|
|
137
|
-
const configurations = await getConfiguration(allowedContentTypeUids);
|
|
138
|
-
// Get the necessary metadata for the documents
|
|
139
|
-
const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);
|
|
140
|
-
// Now actually fetch and format the documents
|
|
141
|
-
const recentDocuments = await Promise.all(contentTypesMeta.map(async (meta)=>{
|
|
142
|
-
const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({
|
|
143
|
-
limit: MAX_DOCUMENTS,
|
|
144
|
-
sort: 'updatedAt:desc',
|
|
145
|
-
fields: meta.fields
|
|
146
|
-
});
|
|
147
|
-
const docs = await strapi.documents(meta.uid).findMany(permissionQuery);
|
|
148
|
-
return formatDocuments(docs, meta);
|
|
149
|
-
}));
|
|
150
|
-
const overallRecentDocuments = recentDocuments.flat().sort((a, b)=>{
|
|
151
|
-
return b.updatedAt.valueOf() - a.updatedAt.valueOf();
|
|
152
|
-
}).slice(0, MAX_DOCUMENTS);
|
|
153
|
-
return addStatusToDocuments(overallRecentDocuments);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
exports.createHomepageService = createHomepageService;
|
|
159
|
-
//# sourceMappingURL=homepage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.js","sources":["../../../../../server/src/services/homepage.ts"],"sourcesContent":["import type { Core, Modules, Schema } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\nimport type { GetRecentDocuments, RecentDocument } from '../../../shared/contracts/homepage';\n\n/**\n * TODO: Remove this service when the future flag for the widget api is removed\n */\nconst createHomepageService = ({ strapi }: { strapi: Core.Strapi }) => {\n const MAX_DOCUMENTS = 4;\n\n const metadataService = strapi.plugin('content-manager').service('document-metadata');\n const permissionService = strapi.admin.services.permission as typeof import('./permission');\n\n type ContentTypeConfiguration = {\n uid: RecentDocument['contentTypeUid'];\n settings: { mainField: string };\n };\n const getConfiguration = async (\n contentTypeUids: RecentDocument['contentTypeUid'][]\n ): Promise<ContentTypeConfiguration[]> => {\n /**\n * Don't use the strapi.store util because we need to make\n * more precise queries than exact key matches, in order to make as few queries as possible.\n */\n const coreStore = strapi.db.query('strapi::core-store');\n const rawConfigurations = await coreStore.findMany({\n where: {\n key: {\n $in: contentTypeUids.map(\n (contentType) => `plugin_content_manager_configuration_content_types::${contentType}`\n ),\n },\n },\n });\n\n return rawConfigurations.map((rawConfiguration) => {\n return JSON.parse(rawConfiguration.value);\n });\n };\n\n const getPermittedContentTypes = async () => {\n const readPermissions = await permissionService.findMany({\n where: {\n role: { users: { id: strapi.requestContext.get()?.state?.user.id } },\n action: 'plugin::content-manager.explorer.read',\n },\n });\n\n return readPermissions\n .map((permission) => permission.subject)\n .filter(Boolean) as RecentDocument['contentTypeUid'][];\n };\n\n type ContentTypeMeta = {\n fields: string[];\n mainField: string;\n contentType: Schema.ContentType;\n hasDraftAndPublish: boolean;\n uid: RecentDocument['contentTypeUid'];\n };\n\n const getContentTypesMeta = (\n allowedContentTypeUids: RecentDocument['contentTypeUid'][],\n configurations: ContentTypeConfiguration[]\n ): ContentTypeMeta[] => {\n return allowedContentTypeUids.map((uid) => {\n const configuration = configurations.find((config) => config.uid === uid);\n const contentType = strapi.contentType(uid);\n const fields = ['documentId', 'updatedAt'];\n\n // Add fields required to get the status if D&P is enabled\n const hasDraftAndPublish = contentTypes.hasDraftAndPublish(contentType);\n if (hasDraftAndPublish) {\n fields.push('publishedAt');\n }\n\n // Only add the main field if it's defined\n if (configuration?.settings.mainField) {\n fields.push(configuration.settings.mainField);\n }\n\n // Only add locale if it's localized\n const isLocalized = (contentType.pluginOptions?.i18n as any)?.localized;\n if (isLocalized) {\n fields.push('locale');\n }\n\n return {\n fields,\n mainField: configuration!.settings.mainField,\n contentType,\n hasDraftAndPublish,\n uid,\n };\n });\n };\n\n const formatDocuments = (documents: Modules.Documents.AnyDocument[], meta: ContentTypeMeta) => {\n return documents.map((document) => {\n return {\n documentId: document.documentId,\n locale: document.locale ?? null,\n updatedAt: new Date(document.updatedAt),\n title: document[meta.mainField ?? 'documentId'],\n publishedAt:\n meta.hasDraftAndPublish && document.publishedAt ? new Date(document.publishedAt) : null,\n contentTypeUid: meta.uid,\n contentTypeDisplayName: meta.contentType.info.displayName,\n kind: meta.contentType.kind,\n };\n });\n };\n\n const addStatusToDocuments = async (documents: RecentDocument[]): Promise<RecentDocument[]> => {\n return Promise.all(\n documents.map(async (recentDocument) => {\n const hasDraftAndPublish = contentTypes.hasDraftAndPublish(\n strapi.contentType(recentDocument.contentTypeUid)\n );\n /**\n * Tries to query the other version of the document if draft and publish is enabled,\n * so that we know when to give the \"modified\" status.\n */\n const { availableStatus } = await metadataService.getMetadata(\n recentDocument.contentTypeUid,\n recentDocument,\n {\n availableStatus: hasDraftAndPublish,\n availableLocales: false,\n }\n );\n const status: RecentDocument['status'] = metadataService.getStatus(\n recentDocument,\n availableStatus\n );\n\n return {\n ...recentDocument,\n status: hasDraftAndPublish ? status : undefined,\n };\n })\n );\n };\n\n const permissionCheckerService = strapi.plugin('content-manager').service('permission-checker');\n const getPermissionChecker = (uid: string) =>\n permissionCheckerService.create({\n userAbility: strapi.requestContext.get()?.state.userAbility,\n model: uid,\n });\n\n return {\n async getRecentlyPublishedDocuments(): Promise<GetRecentDocuments.Response['data']> {\n const permittedContentTypes = await getPermittedContentTypes();\n const allowedContentTypeUids = permittedContentTypes.filter((uid) => {\n return contentTypes.hasDraftAndPublish(strapi.contentType(uid));\n });\n // Fetch the configuration for each content type in a single query\n const configurations = await getConfiguration(allowedContentTypeUids);\n // Get the necessary metadata for the documents\n const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);\n // Now actually fetch and format the documents\n const recentDocuments = await Promise.all(\n contentTypesMeta.map(async (meta) => {\n const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({\n limit: MAX_DOCUMENTS,\n sort: 'publishedAt:desc',\n fields: meta.fields,\n status: 'published',\n });\n\n const docs = await strapi.documents(meta.uid).findMany(permissionQuery);\n\n return formatDocuments(docs, meta);\n })\n );\n\n const overallRecentDocuments = recentDocuments\n .flat()\n .sort((a, b) => {\n if (!a.publishedAt || !b.publishedAt) return 0;\n return b.publishedAt.valueOf() - a.publishedAt.valueOf();\n })\n .slice(0, MAX_DOCUMENTS);\n\n return addStatusToDocuments(overallRecentDocuments);\n },\n\n async getRecentlyUpdatedDocuments(): Promise<GetRecentDocuments.Response['data']> {\n const allowedContentTypeUids = await getPermittedContentTypes();\n // Fetch the configuration for each content type in a single query\n const configurations = await getConfiguration(allowedContentTypeUids);\n // Get the necessary metadata for the documents\n const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);\n // Now actually fetch and format the documents\n const recentDocuments = await Promise.all(\n contentTypesMeta.map(async (meta) => {\n const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({\n limit: MAX_DOCUMENTS,\n sort: 'updatedAt:desc',\n fields: meta.fields,\n });\n\n const docs = await strapi.documents(meta.uid).findMany(permissionQuery);\n\n return formatDocuments(docs, meta);\n })\n );\n\n const overallRecentDocuments = recentDocuments\n .flat()\n .sort((a, b) => {\n return b.updatedAt.valueOf() - a.updatedAt.valueOf();\n })\n .slice(0, MAX_DOCUMENTS);\n\n return addStatusToDocuments(overallRecentDocuments);\n },\n };\n};\n\nexport { createHomepageService };\n"],"names":["createHomepageService","strapi","MAX_DOCUMENTS","metadataService","plugin","service","permissionService","admin","services","permission","getConfiguration","contentTypeUids","coreStore","db","query","rawConfigurations","findMany","where","key","$in","map","contentType","rawConfiguration","JSON","parse","value","getPermittedContentTypes","readPermissions","role","users","id","requestContext","get","state","user","action","subject","filter","Boolean","getContentTypesMeta","allowedContentTypeUids","configurations","uid","configuration","find","config","fields","hasDraftAndPublish","contentTypes","push","settings","mainField","isLocalized","pluginOptions","i18n","localized","formatDocuments","documents","meta","document","documentId","locale","updatedAt","Date","title","publishedAt","contentTypeUid","contentTypeDisplayName","info","displayName","kind","addStatusToDocuments","Promise","all","recentDocument","availableStatus","getMetadata","availableLocales","status","getStatus","undefined","permissionCheckerService","getPermissionChecker","create","userAbility","model","getRecentlyPublishedDocuments","permittedContentTypes","contentTypesMeta","recentDocuments","permissionQuery","sanitizedQuery","read","limit","sort","docs","overallRecentDocuments","flat","a","b","valueOf","slice","getRecentlyUpdatedDocuments"],"mappings":";;;;AAIA;;AAEC,IACKA,MAAAA,qBAAAA,GAAwB,CAAC,EAAEC,MAAM,EAA2B,GAAA;AAChE,IAAA,MAAMC,aAAgB,GAAA,CAAA;AAEtB,IAAA,MAAMC,kBAAkBF,MAAOG,CAAAA,MAAM,CAAC,iBAAA,CAAA,CAAmBC,OAAO,CAAC,mBAAA,CAAA;AACjE,IAAA,MAAMC,oBAAoBL,MAAOM,CAAAA,KAAK,CAACC,QAAQ,CAACC,UAAU;AAM1D,IAAA,MAAMC,mBAAmB,OACvBC,eAAAA,GAAAA;AAEA;;;AAGC,QACD,MAAMC,SAAYX,GAAAA,MAAAA,CAAOY,EAAE,CAACC,KAAK,CAAC,oBAAA,CAAA;AAClC,QAAA,MAAMC,iBAAoB,GAAA,MAAMH,SAAUI,CAAAA,QAAQ,CAAC;YACjDC,KAAO,EAAA;gBACLC,GAAK,EAAA;oBACHC,GAAKR,EAAAA,eAAAA,CAAgBS,GAAG,CACtB,CAACC,cAAgB,CAAC,oDAAoD,EAAEA,WA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
|
|
1
|
-
import { contentTypes } from '@strapi/utils';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* TODO: Remove this service when the future flag for the widget api is removed
|
|
5
|
-
*/ const createHomepageService = ({ strapi })=>{
|
|
6
|
-
const MAX_DOCUMENTS = 4;
|
|
7
|
-
const metadataService = strapi.plugin('content-manager').service('document-metadata');
|
|
8
|
-
const permissionService = strapi.admin.services.permission;
|
|
9
|
-
const getConfiguration = async (contentTypeUids)=>{
|
|
10
|
-
/**
|
|
11
|
-
* Don't use the strapi.store util because we need to make
|
|
12
|
-
* more precise queries than exact key matches, in order to make as few queries as possible.
|
|
13
|
-
*/ const coreStore = strapi.db.query('strapi::core-store');
|
|
14
|
-
const rawConfigurations = await coreStore.findMany({
|
|
15
|
-
where: {
|
|
16
|
-
key: {
|
|
17
|
-
$in: contentTypeUids.map((contentType)=>`plugin_content_manager_configuration_content_types::${contentType}`)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return rawConfigurations.map((rawConfiguration)=>{
|
|
22
|
-
return JSON.parse(rawConfiguration.value);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
const getPermittedContentTypes = async ()=>{
|
|
26
|
-
const readPermissions = await permissionService.findMany({
|
|
27
|
-
where: {
|
|
28
|
-
role: {
|
|
29
|
-
users: {
|
|
30
|
-
id: strapi.requestContext.get()?.state?.user.id
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
action: 'plugin::content-manager.explorer.read'
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return readPermissions.map((permission)=>permission.subject).filter(Boolean);
|
|
37
|
-
};
|
|
38
|
-
const getContentTypesMeta = (allowedContentTypeUids, configurations)=>{
|
|
39
|
-
return allowedContentTypeUids.map((uid)=>{
|
|
40
|
-
const configuration = configurations.find((config)=>config.uid === uid);
|
|
41
|
-
const contentType = strapi.contentType(uid);
|
|
42
|
-
const fields = [
|
|
43
|
-
'documentId',
|
|
44
|
-
'updatedAt'
|
|
45
|
-
];
|
|
46
|
-
// Add fields required to get the status if D&P is enabled
|
|
47
|
-
const hasDraftAndPublish = contentTypes.hasDraftAndPublish(contentType);
|
|
48
|
-
if (hasDraftAndPublish) {
|
|
49
|
-
fields.push('publishedAt');
|
|
50
|
-
}
|
|
51
|
-
// Only add the main field if it's defined
|
|
52
|
-
if (configuration?.settings.mainField) {
|
|
53
|
-
fields.push(configuration.settings.mainField);
|
|
54
|
-
}
|
|
55
|
-
// Only add locale if it's localized
|
|
56
|
-
const isLocalized = contentType.pluginOptions?.i18n?.localized;
|
|
57
|
-
if (isLocalized) {
|
|
58
|
-
fields.push('locale');
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
fields,
|
|
62
|
-
mainField: configuration.settings.mainField,
|
|
63
|
-
contentType,
|
|
64
|
-
hasDraftAndPublish,
|
|
65
|
-
uid
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
const formatDocuments = (documents, meta)=>{
|
|
70
|
-
return documents.map((document)=>{
|
|
71
|
-
return {
|
|
72
|
-
documentId: document.documentId,
|
|
73
|
-
locale: document.locale ?? null,
|
|
74
|
-
updatedAt: new Date(document.updatedAt),
|
|
75
|
-
title: document[meta.mainField ?? 'documentId'],
|
|
76
|
-
publishedAt: meta.hasDraftAndPublish && document.publishedAt ? new Date(document.publishedAt) : null,
|
|
77
|
-
contentTypeUid: meta.uid,
|
|
78
|
-
contentTypeDisplayName: meta.contentType.info.displayName,
|
|
79
|
-
kind: meta.contentType.kind
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
const addStatusToDocuments = async (documents)=>{
|
|
84
|
-
return Promise.all(documents.map(async (recentDocument)=>{
|
|
85
|
-
const hasDraftAndPublish = contentTypes.hasDraftAndPublish(strapi.contentType(recentDocument.contentTypeUid));
|
|
86
|
-
/**
|
|
87
|
-
* Tries to query the other version of the document if draft and publish is enabled,
|
|
88
|
-
* so that we know when to give the "modified" status.
|
|
89
|
-
*/ const { availableStatus } = await metadataService.getMetadata(recentDocument.contentTypeUid, recentDocument, {
|
|
90
|
-
availableStatus: hasDraftAndPublish,
|
|
91
|
-
availableLocales: false
|
|
92
|
-
});
|
|
93
|
-
const status = metadataService.getStatus(recentDocument, availableStatus);
|
|
94
|
-
return {
|
|
95
|
-
...recentDocument,
|
|
96
|
-
status: hasDraftAndPublish ? status : undefined
|
|
97
|
-
};
|
|
98
|
-
}));
|
|
99
|
-
};
|
|
100
|
-
const permissionCheckerService = strapi.plugin('content-manager').service('permission-checker');
|
|
101
|
-
const getPermissionChecker = (uid)=>permissionCheckerService.create({
|
|
102
|
-
userAbility: strapi.requestContext.get()?.state.userAbility,
|
|
103
|
-
model: uid
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
async getRecentlyPublishedDocuments () {
|
|
107
|
-
const permittedContentTypes = await getPermittedContentTypes();
|
|
108
|
-
const allowedContentTypeUids = permittedContentTypes.filter((uid)=>{
|
|
109
|
-
return contentTypes.hasDraftAndPublish(strapi.contentType(uid));
|
|
110
|
-
});
|
|
111
|
-
// Fetch the configuration for each content type in a single query
|
|
112
|
-
const configurations = await getConfiguration(allowedContentTypeUids);
|
|
113
|
-
// Get the necessary metadata for the documents
|
|
114
|
-
const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);
|
|
115
|
-
// Now actually fetch and format the documents
|
|
116
|
-
const recentDocuments = await Promise.all(contentTypesMeta.map(async (meta)=>{
|
|
117
|
-
const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({
|
|
118
|
-
limit: MAX_DOCUMENTS,
|
|
119
|
-
sort: 'publishedAt:desc',
|
|
120
|
-
fields: meta.fields,
|
|
121
|
-
status: 'published'
|
|
122
|
-
});
|
|
123
|
-
const docs = await strapi.documents(meta.uid).findMany(permissionQuery);
|
|
124
|
-
return formatDocuments(docs, meta);
|
|
125
|
-
}));
|
|
126
|
-
const overallRecentDocuments = recentDocuments.flat().sort((a, b)=>{
|
|
127
|
-
if (!a.publishedAt || !b.publishedAt) return 0;
|
|
128
|
-
return b.publishedAt.valueOf() - a.publishedAt.valueOf();
|
|
129
|
-
}).slice(0, MAX_DOCUMENTS);
|
|
130
|
-
return addStatusToDocuments(overallRecentDocuments);
|
|
131
|
-
},
|
|
132
|
-
async getRecentlyUpdatedDocuments () {
|
|
133
|
-
const allowedContentTypeUids = await getPermittedContentTypes();
|
|
134
|
-
// Fetch the configuration for each content type in a single query
|
|
135
|
-
const configurations = await getConfiguration(allowedContentTypeUids);
|
|
136
|
-
// Get the necessary metadata for the documents
|
|
137
|
-
const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);
|
|
138
|
-
// Now actually fetch and format the documents
|
|
139
|
-
const recentDocuments = await Promise.all(contentTypesMeta.map(async (meta)=>{
|
|
140
|
-
const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({
|
|
141
|
-
limit: MAX_DOCUMENTS,
|
|
142
|
-
sort: 'updatedAt:desc',
|
|
143
|
-
fields: meta.fields
|
|
144
|
-
});
|
|
145
|
-
const docs = await strapi.documents(meta.uid).findMany(permissionQuery);
|
|
146
|
-
return formatDocuments(docs, meta);
|
|
147
|
-
}));
|
|
148
|
-
const overallRecentDocuments = recentDocuments.flat().sort((a, b)=>{
|
|
149
|
-
return b.updatedAt.valueOf() - a.updatedAt.valueOf();
|
|
150
|
-
}).slice(0, MAX_DOCUMENTS);
|
|
151
|
-
return addStatusToDocuments(overallRecentDocuments);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export { createHomepageService };
|
|
157
|
-
//# sourceMappingURL=homepage.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.mjs","sources":["../../../../../server/src/services/homepage.ts"],"sourcesContent":["import type { Core, Modules, Schema } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\nimport type { GetRecentDocuments, RecentDocument } from '../../../shared/contracts/homepage';\n\n/**\n * TODO: Remove this service when the future flag for the widget api is removed\n */\nconst createHomepageService = ({ strapi }: { strapi: Core.Strapi }) => {\n const MAX_DOCUMENTS = 4;\n\n const metadataService = strapi.plugin('content-manager').service('document-metadata');\n const permissionService = strapi.admin.services.permission as typeof import('./permission');\n\n type ContentTypeConfiguration = {\n uid: RecentDocument['contentTypeUid'];\n settings: { mainField: string };\n };\n const getConfiguration = async (\n contentTypeUids: RecentDocument['contentTypeUid'][]\n ): Promise<ContentTypeConfiguration[]> => {\n /**\n * Don't use the strapi.store util because we need to make\n * more precise queries than exact key matches, in order to make as few queries as possible.\n */\n const coreStore = strapi.db.query('strapi::core-store');\n const rawConfigurations = await coreStore.findMany({\n where: {\n key: {\n $in: contentTypeUids.map(\n (contentType) => `plugin_content_manager_configuration_content_types::${contentType}`\n ),\n },\n },\n });\n\n return rawConfigurations.map((rawConfiguration) => {\n return JSON.parse(rawConfiguration.value);\n });\n };\n\n const getPermittedContentTypes = async () => {\n const readPermissions = await permissionService.findMany({\n where: {\n role: { users: { id: strapi.requestContext.get()?.state?.user.id } },\n action: 'plugin::content-manager.explorer.read',\n },\n });\n\n return readPermissions\n .map((permission) => permission.subject)\n .filter(Boolean) as RecentDocument['contentTypeUid'][];\n };\n\n type ContentTypeMeta = {\n fields: string[];\n mainField: string;\n contentType: Schema.ContentType;\n hasDraftAndPublish: boolean;\n uid: RecentDocument['contentTypeUid'];\n };\n\n const getContentTypesMeta = (\n allowedContentTypeUids: RecentDocument['contentTypeUid'][],\n configurations: ContentTypeConfiguration[]\n ): ContentTypeMeta[] => {\n return allowedContentTypeUids.map((uid) => {\n const configuration = configurations.find((config) => config.uid === uid);\n const contentType = strapi.contentType(uid);\n const fields = ['documentId', 'updatedAt'];\n\n // Add fields required to get the status if D&P is enabled\n const hasDraftAndPublish = contentTypes.hasDraftAndPublish(contentType);\n if (hasDraftAndPublish) {\n fields.push('publishedAt');\n }\n\n // Only add the main field if it's defined\n if (configuration?.settings.mainField) {\n fields.push(configuration.settings.mainField);\n }\n\n // Only add locale if it's localized\n const isLocalized = (contentType.pluginOptions?.i18n as any)?.localized;\n if (isLocalized) {\n fields.push('locale');\n }\n\n return {\n fields,\n mainField: configuration!.settings.mainField,\n contentType,\n hasDraftAndPublish,\n uid,\n };\n });\n };\n\n const formatDocuments = (documents: Modules.Documents.AnyDocument[], meta: ContentTypeMeta) => {\n return documents.map((document) => {\n return {\n documentId: document.documentId,\n locale: document.locale ?? null,\n updatedAt: new Date(document.updatedAt),\n title: document[meta.mainField ?? 'documentId'],\n publishedAt:\n meta.hasDraftAndPublish && document.publishedAt ? new Date(document.publishedAt) : null,\n contentTypeUid: meta.uid,\n contentTypeDisplayName: meta.contentType.info.displayName,\n kind: meta.contentType.kind,\n };\n });\n };\n\n const addStatusToDocuments = async (documents: RecentDocument[]): Promise<RecentDocument[]> => {\n return Promise.all(\n documents.map(async (recentDocument) => {\n const hasDraftAndPublish = contentTypes.hasDraftAndPublish(\n strapi.contentType(recentDocument.contentTypeUid)\n );\n /**\n * Tries to query the other version of the document if draft and publish is enabled,\n * so that we know when to give the \"modified\" status.\n */\n const { availableStatus } = await metadataService.getMetadata(\n recentDocument.contentTypeUid,\n recentDocument,\n {\n availableStatus: hasDraftAndPublish,\n availableLocales: false,\n }\n );\n const status: RecentDocument['status'] = metadataService.getStatus(\n recentDocument,\n availableStatus\n );\n\n return {\n ...recentDocument,\n status: hasDraftAndPublish ? status : undefined,\n };\n })\n );\n };\n\n const permissionCheckerService = strapi.plugin('content-manager').service('permission-checker');\n const getPermissionChecker = (uid: string) =>\n permissionCheckerService.create({\n userAbility: strapi.requestContext.get()?.state.userAbility,\n model: uid,\n });\n\n return {\n async getRecentlyPublishedDocuments(): Promise<GetRecentDocuments.Response['data']> {\n const permittedContentTypes = await getPermittedContentTypes();\n const allowedContentTypeUids = permittedContentTypes.filter((uid) => {\n return contentTypes.hasDraftAndPublish(strapi.contentType(uid));\n });\n // Fetch the configuration for each content type in a single query\n const configurations = await getConfiguration(allowedContentTypeUids);\n // Get the necessary metadata for the documents\n const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);\n // Now actually fetch and format the documents\n const recentDocuments = await Promise.all(\n contentTypesMeta.map(async (meta) => {\n const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({\n limit: MAX_DOCUMENTS,\n sort: 'publishedAt:desc',\n fields: meta.fields,\n status: 'published',\n });\n\n const docs = await strapi.documents(meta.uid).findMany(permissionQuery);\n\n return formatDocuments(docs, meta);\n })\n );\n\n const overallRecentDocuments = recentDocuments\n .flat()\n .sort((a, b) => {\n if (!a.publishedAt || !b.publishedAt) return 0;\n return b.publishedAt.valueOf() - a.publishedAt.valueOf();\n })\n .slice(0, MAX_DOCUMENTS);\n\n return addStatusToDocuments(overallRecentDocuments);\n },\n\n async getRecentlyUpdatedDocuments(): Promise<GetRecentDocuments.Response['data']> {\n const allowedContentTypeUids = await getPermittedContentTypes();\n // Fetch the configuration for each content type in a single query\n const configurations = await getConfiguration(allowedContentTypeUids);\n // Get the necessary metadata for the documents\n const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);\n // Now actually fetch and format the documents\n const recentDocuments = await Promise.all(\n contentTypesMeta.map(async (meta) => {\n const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({\n limit: MAX_DOCUMENTS,\n sort: 'updatedAt:desc',\n fields: meta.fields,\n });\n\n const docs = await strapi.documents(meta.uid).findMany(permissionQuery);\n\n return formatDocuments(docs, meta);\n })\n );\n\n const overallRecentDocuments = recentDocuments\n .flat()\n .sort((a, b) => {\n return b.updatedAt.valueOf() - a.updatedAt.valueOf();\n })\n .slice(0, MAX_DOCUMENTS);\n\n return addStatusToDocuments(overallRecentDocuments);\n },\n };\n};\n\nexport { createHomepageService };\n"],"names":["createHomepageService","strapi","MAX_DOCUMENTS","metadataService","plugin","service","permissionService","admin","services","permission","getConfiguration","contentTypeUids","coreStore","db","query","rawConfigurations","findMany","where","key","$in","map","contentType","rawConfiguration","JSON","parse","value","getPermittedContentTypes","readPermissions","role","users","id","requestContext","get","state","user","action","subject","filter","Boolean","getContentTypesMeta","allowedContentTypeUids","configurations","uid","configuration","find","config","fields","hasDraftAndPublish","contentTypes","push","settings","mainField","isLocalized","pluginOptions","i18n","localized","formatDocuments","documents","meta","document","documentId","locale","updatedAt","Date","title","publishedAt","contentTypeUid","contentTypeDisplayName","info","displayName","kind","addStatusToDocuments","Promise","all","recentDocument","availableStatus","getMetadata","availableLocales","status","getStatus","undefined","permissionCheckerService","getPermissionChecker","create","userAbility","model","getRecentlyPublishedDocuments","permittedContentTypes","contentTypesMeta","recentDocuments","permissionQuery","sanitizedQuery","read","limit","sort","docs","overallRecentDocuments","flat","a","b","valueOf","slice","getRecentlyUpdatedDocuments"],"mappings":";;AAIA;;AAEC,IACKA,MAAAA,qBAAAA,GAAwB,CAAC,EAAEC,MAAM,EAA2B,GAAA;AAChE,IAAA,MAAMC,aAAgB,GAAA,CAAA;AAEtB,IAAA,MAAMC,kBAAkBF,MAAOG,CAAAA,MAAM,CAAC,iBAAA,CAAA,CAAmBC,OAAO,CAAC,mBAAA,CAAA;AACjE,IAAA,MAAMC,oBAAoBL,MAAOM,CAAAA,KAAK,CAACC,QAAQ,CAACC,UAAU;AAM1D,IAAA,MAAMC,mBAAmB,OACvBC,eAAAA,GAAAA;AAEA;;;AAGC,QACD,MAAMC,SAAYX,GAAAA,MAAAA,CAAOY,EAAE,CAACC,KAAK,CAAC,oBAAA,CAAA;AAClC,QAAA,MAAMC,iBAAoB,GAAA,MAAMH,SAAUI,CAAAA,QAAQ,CAAC;YACjDC,KAAO,EAAA;gBACLC,GAAK,EAAA;oBACHC,GAAKR,EAAAA,eAAAA,CAAgBS,GAAG,CACtB,CAACC,cAAgB,CAAC,oDAAoD,EAAEA,WAAAA,CAAY,CAAC;AAEzF;AACF;AACF,SAAA,CAAA;QAEA,OAAON,iBAAAA,CAAkBK,GAAG,CAAC,CA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ts/homepage';
|
|
4
|
-
declare const createHomepageController: () => {
|
|
5
|
-
getRecentDocuments(ctx: import("koa").Context): Promise<GetRecentDocuments.Response>;
|
|
6
|
-
};
|
|
7
|
-
export { createHomepageController };
|
|
8
|
-
//# sourceMappingURL=homepage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/homepage.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,QAAA,MAAM,wBAAwB;oDAWK,QAAQ,2BAA2B,CAAC;CAmBtE,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../../../../server/src/routes/homepage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAIA,wBAU4D"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Core } from '@strapi/types';
|
|
3
|
-
import type { GetRecentDocuments } from '../../../shared/contracts/homepage';
|
|
4
|
-
/**
|
|
5
|
-
* TODO: Remove this service when the future flag for the widget api is removed
|
|
6
|
-
*/
|
|
7
|
-
declare const createHomepageService: ({ strapi }: {
|
|
8
|
-
strapi: Core.Strapi;
|
|
9
|
-
}) => {
|
|
10
|
-
getRecentlyPublishedDocuments(): Promise<GetRecentDocuments.Response['data']>;
|
|
11
|
-
getRecentlyUpdatedDocuments(): Promise<GetRecentDocuments.Response['data']>;
|
|
12
|
-
};
|
|
13
|
-
export { createHomepageService };
|
|
14
|
-
//# sourceMappingURL=homepage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.d.ts","sourceRoot":"","sources":["../../../../server/src/services/homepage.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAmB,MAAM,eAAe,CAAC;AAE3D,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,oCAAoC,CAAC;AAE7F;;GAEG;AACH,QAAA,MAAM,qBAAqB,eAAgB;IAAE,MAAM,EAAE,KAAK,MAAM,CAAA;CAAE;qCAiJvB,QAAQ,2BAA2B,CAAC,MAAM,CAAC,CAAC;mCAoC9C,QAAQ,2BAA2B,CAAC,MAAM,CAAC,CAAC;CA+BpF,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|