@strapi/content-manager 0.0.0-experimental.06e300737ca79fa320fff00b809f095a5d7fe7c4 → 0.0.0-experimental.072258cbcd42181dea057515b972de0e71a24ebc
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/components/Widgets.js +253 -0
- package/dist/admin/components/Widgets.js.map +1 -1
- package/dist/admin/components/Widgets.mjs +236 -3
- package/dist/admin/components/Widgets.mjs.map +1 -1
- package/dist/admin/index.js +22 -2
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +22 -3
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +12 -5
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +14 -7
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +26 -16
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +27 -17
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +74 -65
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +75 -66
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/services/api.js +3 -1
- package/dist/admin/services/api.js.map +1 -1
- package/dist/admin/services/api.mjs +3 -1
- package/dist/admin/services/api.mjs.map +1 -1
- package/dist/admin/services/documents.js +30 -14
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +30 -14
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/services/homepage.js +11 -2
- package/dist/admin/services/homepage.js.map +1 -1
- package/dist/admin/services/homepage.mjs +11 -3
- package/dist/admin/services/homepage.mjs.map +1 -1
- package/dist/admin/src/components/Widgets.d.ts +2 -1
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +16 -16
- package/dist/admin/src/services/homepage.d.ts +6 -2
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/translations/en.json.js +2 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +2 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/translations/es.json.js +5 -2
- package/dist/admin/translations/es.json.js.map +1 -1
- package/dist/admin/translations/es.json.mjs +5 -2
- package/dist/admin/translations/es.json.mjs.map +1 -1
- package/dist/admin/translations/fr.json.js +4 -1
- package/dist/admin/translations/fr.json.js.map +1 -1
- package/dist/admin/translations/fr.json.mjs +4 -1
- package/dist/admin/translations/fr.json.mjs.map +1 -1
- package/dist/server/homepage/controllers/homepage.js +5 -0
- package/dist/server/homepage/controllers/homepage.js.map +1 -1
- package/dist/server/homepage/controllers/homepage.mjs +5 -0
- package/dist/server/homepage/controllers/homepage.mjs.map +1 -1
- package/dist/server/homepage/routes/homepage.js +11 -0
- package/dist/server/homepage/routes/homepage.js.map +1 -1
- package/dist/server/homepage/routes/homepage.mjs +11 -0
- package/dist/server/homepage/routes/homepage.mjs.map +1 -1
- package/dist/server/homepage/services/homepage.js +86 -46
- package/dist/server/homepage/services/homepage.js.map +1 -1
- package/dist/server/homepage/services/homepage.mjs +86 -46
- package/dist/server/homepage/services/homepage.mjs.map +1 -1
- package/dist/server/src/homepage/controllers/homepage.d.ts +2 -1
- package/dist/server/src/homepage/controllers/homepage.d.ts.map +1 -1
- package/dist/server/src/homepage/index.d.ts +7 -0
- package/dist/server/src/homepage/index.d.ts.map +1 -1
- package/dist/server/src/homepage/routes/homepage.d.ts.map +1 -1
- package/dist/server/src/homepage/services/homepage.d.ts +4 -1
- package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
- package/dist/server/src/homepage/services/index.d.ts +7 -0
- package/dist/server/src/homepage/services/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +7 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +7 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/shared/contracts/homepage.d.ts +13 -0
- package/dist/shared/contracts/homepage.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -304,6 +304,8 @@ var en = {
|
|
|
304
304
|
"validation.error": "There are validation errors in your document. Please fix them before saving.",
|
|
305
305
|
"validation.error.unreadable-required-field": "Your current permissions prevent access to certain required fields. Please request access from an administrator to proceed.",
|
|
306
306
|
"bulk-publish.edit": "Edit",
|
|
307
|
+
"widget.chart-entries.title": "Entries",
|
|
308
|
+
"widget.chart-entries.tooltip": "{count} {label}",
|
|
307
309
|
"widget.last-edited.title": "Last edited entries",
|
|
308
310
|
"widget.last-edited.single-type": "Single-Type",
|
|
309
311
|
"widget.last-edited.no-data": "No edited entries",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -92,8 +92,9 @@ var es = {
|
|
|
92
92
|
"containers.Home.pluginHeaderDescription": "Gestiona sus registros en una bella y poderoza interfaz.",
|
|
93
93
|
"containers.Home.pluginHeaderTitle": "Gestor de Contenido",
|
|
94
94
|
"containers.List.draft": "Borrador",
|
|
95
|
-
"containers.List.errorFetchRecords": "Error",
|
|
96
95
|
"containers.List.published": "Publicado",
|
|
96
|
+
"containers.List.modified": "Modificado",
|
|
97
|
+
"containers.List.errorFetchRecords": "Error",
|
|
97
98
|
"containers.list.displayedFields": "Campos mostrados",
|
|
98
99
|
"containers.list.items": "{number, plural, =0 {elementos} one {elemento} other {elementos}}",
|
|
99
100
|
"containers.list.table-headers.publishedAt": "Estado",
|
|
@@ -189,7 +190,9 @@ var es = {
|
|
|
189
190
|
"success.record.unpublish": "Sin publicar",
|
|
190
191
|
"utils.data-loaded": "{number, plural, =1 {La entrada se ha cargado correctamente} other {Las entradas se han cargado correctamente}}",
|
|
191
192
|
"popUpWarning.warning.publish-question": "¿Aún quieres publicarlo?",
|
|
192
|
-
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar"
|
|
193
|
+
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar",
|
|
194
|
+
"widget.chart-entries.title": "Entradas",
|
|
195
|
+
"widget.chart-entries.tooltip": "{count} {label}"
|
|
193
196
|
};
|
|
194
197
|
|
|
195
198
|
exports.default = es;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"es.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"es.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -88,8 +88,9 @@ var es = {
|
|
|
88
88
|
"containers.Home.pluginHeaderDescription": "Gestiona sus registros en una bella y poderoza interfaz.",
|
|
89
89
|
"containers.Home.pluginHeaderTitle": "Gestor de Contenido",
|
|
90
90
|
"containers.List.draft": "Borrador",
|
|
91
|
-
"containers.List.errorFetchRecords": "Error",
|
|
92
91
|
"containers.List.published": "Publicado",
|
|
92
|
+
"containers.List.modified": "Modificado",
|
|
93
|
+
"containers.List.errorFetchRecords": "Error",
|
|
93
94
|
"containers.list.displayedFields": "Campos mostrados",
|
|
94
95
|
"containers.list.items": "{number, plural, =0 {elementos} one {elemento} other {elementos}}",
|
|
95
96
|
"containers.list.table-headers.publishedAt": "Estado",
|
|
@@ -185,7 +186,9 @@ var es = {
|
|
|
185
186
|
"success.record.unpublish": "Sin publicar",
|
|
186
187
|
"utils.data-loaded": "{number, plural, =1 {La entrada se ha cargado correctamente} other {Las entradas se han cargado correctamente}}",
|
|
187
188
|
"popUpWarning.warning.publish-question": "¿Aún quieres publicarlo?",
|
|
188
|
-
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar"
|
|
189
|
+
"popUpwarning.warning.has-draft-relations.button-confirm": "Si, publicar",
|
|
190
|
+
"widget.chart-entries.title": "Entradas",
|
|
191
|
+
"widget.chart-entries.tooltip": "{count} {label}"
|
|
189
192
|
};
|
|
190
193
|
|
|
191
194
|
export { es as default, groups, models, pageNotFound };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"es.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"es.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -95,8 +95,9 @@ var fr = {
|
|
|
95
95
|
"containers.Home.pluginHeaderDescription": "Créer et modifier votre type de contenu",
|
|
96
96
|
"containers.Home.pluginHeaderTitle": "Type de contenu",
|
|
97
97
|
"containers.List.draft": "Brouillon",
|
|
98
|
-
"containers.List.errorFetchRecords": "Erreur",
|
|
99
98
|
"containers.List.published": "Publié",
|
|
99
|
+
"containers.List.modified": "Modifié",
|
|
100
|
+
"containers.List.errorFetchRecords": "Erreur",
|
|
100
101
|
"containers.list.displayedFields": "Champs affichés",
|
|
101
102
|
"containers.list.items": "{number, plural, =0 {élements} one {élement} other {élements}}",
|
|
102
103
|
"containers.list.table-headers.publishedAt": "Statut",
|
|
@@ -213,6 +214,8 @@ var fr = {
|
|
|
213
214
|
"history.restore.confirm.message": "{isDraft, select, true {Le contenu restauré écrasera votre brouillon.} other {Le contenu restauré ne sera pas publié, il écrasera le brouillon et sera sauvegardé en tant que changement en attente de publication. Vous pourrez publier les changements à tout moment.}}",
|
|
214
215
|
"history.restore.success.title": "Version restaurée.",
|
|
215
216
|
"history.restore.success.message": "Le contenu de la version restaurée n'a pas encore été publié.",
|
|
217
|
+
"widget.chart-entries.title": "Entrées",
|
|
218
|
+
"widget.chart-entries.tooltip": "{count} {label}",
|
|
216
219
|
"widget.last-edited.title": "Dernières entrées éditées",
|
|
217
220
|
"widget.last-edited.single-type": "Types uniques",
|
|
218
221
|
"widget.last-edited.no-data": "Aucune entrée éditée",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fr.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fr.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -91,8 +91,9 @@ var fr = {
|
|
|
91
91
|
"containers.Home.pluginHeaderDescription": "Créer et modifier votre type de contenu",
|
|
92
92
|
"containers.Home.pluginHeaderTitle": "Type de contenu",
|
|
93
93
|
"containers.List.draft": "Brouillon",
|
|
94
|
-
"containers.List.errorFetchRecords": "Erreur",
|
|
95
94
|
"containers.List.published": "Publié",
|
|
95
|
+
"containers.List.modified": "Modifié",
|
|
96
|
+
"containers.List.errorFetchRecords": "Erreur",
|
|
96
97
|
"containers.list.displayedFields": "Champs affichés",
|
|
97
98
|
"containers.list.items": "{number, plural, =0 {élements} one {élement} other {élements}}",
|
|
98
99
|
"containers.list.table-headers.publishedAt": "Statut",
|
|
@@ -209,6 +210,8 @@ var fr = {
|
|
|
209
210
|
"history.restore.confirm.message": "{isDraft, select, true {Le contenu restauré écrasera votre brouillon.} other {Le contenu restauré ne sera pas publié, il écrasera le brouillon et sera sauvegardé en tant que changement en attente de publication. Vous pourrez publier les changements à tout moment.}}",
|
|
210
211
|
"history.restore.success.title": "Version restaurée.",
|
|
211
212
|
"history.restore.success.message": "Le contenu de la version restaurée n'a pas encore été publié.",
|
|
213
|
+
"widget.chart-entries.title": "Entrées",
|
|
214
|
+
"widget.chart-entries.tooltip": "{count} {label}",
|
|
212
215
|
"widget.last-edited.title": "Dernières entrées éditées",
|
|
213
216
|
"widget.last-edited.single-type": "Types uniques",
|
|
214
217
|
"widget.last-edited.no-data": "Aucune entrée éditée",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fr.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fr.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.js","sources":["../../../../server/src/homepage/controllers/homepage.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as yup from 'yup';\nimport { errors } from '@strapi/utils';\nimport type { GetRecentDocuments } from '../../../../shared/contracts/homepage';\n\nconst createHomepageController = () => {\n const homepageService = strapi.plugin('content-manager').service('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","strapi","plugin","service","recentDocumentParamsSchema","yup","object","shape","action","mixed","oneOf","required","getRecentDocuments","ctx","validate","query","error","ValidationError","errors","message","data","getRecentlyPublishedDocuments","getRecentlyUpdatedDocuments"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,wBAA2B,GAAA,IAAA;AAC/B,IAAA,MAAMC,kBAAkBC,MAAOC,CAAAA,MAAM,CAAC,iBAAA,CAAA,CAAmBC,OAAO,CAAC,UAAA,CAAA;AAEjE,IAAA,MAAMC,0BAA6BC,GAAAA,cAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACpDC,QAAAA,MAAAA,EAAQH,cACLI,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,cAAIY,CAAAA,eAAe,EAAE;AACxC,oBAAA,MAAM,IAAIC,kBAAAA,CAAOD,eAAe,CAACD,MAAMG,OAAO,CAAA;AAChD;gBACA,MAAMH,KAAAA;AACR;AAEA,YAAA,IAAIR,WAAW,SAAW,EAAA;gBACxB,OAAO;oBAAEY,IAAM,EAAA,MAAMpB,gBAAgBqB,6BAA6B;AAAG,iBAAA;AACvE;YAEA,OAAO;gBAAED,IAAM,EAAA,MAAMpB,gBAAgBsB,2BAA2B;AAAG,aAAA;AACrE;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"homepage.js","sources":["../../../../server/src/homepage/controllers/homepage.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as yup from 'yup';\nimport { errors } from '@strapi/utils';\nimport type { GetRecentDocuments, GetCountDocuments } from '../../../../shared/contracts/homepage';\n\nconst createHomepageController = () => {\n const homepageService = strapi.plugin('content-manager').service('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 async getCountDocuments(): Promise<GetCountDocuments.Response> {\n return { data: await homepageService.getCountDocuments() };\n },\n } satisfies Core.Controller;\n};\n\nexport { createHomepageController };\n"],"names":["createHomepageController","homepageService","strapi","plugin","service","recentDocumentParamsSchema","yup","object","shape","action","mixed","oneOf","required","getRecentDocuments","ctx","validate","query","error","ValidationError","errors","message","data","getRecentlyPublishedDocuments","getRecentlyUpdatedDocuments","getCountDocuments"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAMA,wBAA2B,GAAA,IAAA;AAC/B,IAAA,MAAMC,kBAAkBC,MAAOC,CAAAA,MAAM,CAAC,iBAAA,CAAA,CAAmBC,OAAO,CAAC,UAAA,CAAA;AAEjE,IAAA,MAAMC,0BAA6BC,GAAAA,cAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AACpDC,QAAAA,MAAAA,EAAQH,cACLI,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,cAAIY,CAAAA,eAAe,EAAE;AACxC,oBAAA,MAAM,IAAIC,kBAAAA,CAAOD,eAAe,CAACD,MAAMG,OAAO,CAAA;AAChD;gBACA,MAAMH,KAAAA;AACR;AAEA,YAAA,IAAIR,WAAW,SAAW,EAAA;gBACxB,OAAO;oBAAEY,IAAM,EAAA,MAAMpB,gBAAgBqB,6BAA6B;AAAG,iBAAA;AACvE;YAEA,OAAO;gBAAED,IAAM,EAAA,MAAMpB,gBAAgBsB,2BAA2B;AAAG,aAAA;AACrE,SAAA;QACA,MAAMC,iBAAAA,CAAAA,GAAAA;YACJ,OAAO;gBAAEH,IAAM,EAAA,MAAMpB,gBAAgBuB,iBAAiB;AAAG,aAAA;AAC3D;AACF,KAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.mjs","sources":["../../../../server/src/homepage/controllers/homepage.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as yup from 'yup';\nimport { errors } from '@strapi/utils';\nimport type { GetRecentDocuments } from '../../../../shared/contracts/homepage';\n\nconst createHomepageController = () => {\n const homepageService = strapi.plugin('content-manager').service('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","strapi","plugin","service","recentDocumentParamsSchema","yup","object","shape","action","mixed","oneOf","required","getRecentDocuments","ctx","validate","query","error","ValidationError","errors","message","data","getRecentlyPublishedDocuments","getRecentlyUpdatedDocuments"],"mappings":";;;AAKA,MAAMA,wBAA2B,GAAA,IAAA;AAC/B,IAAA,MAAMC,kBAAkBC,MAAOC,CAAAA,MAAM,CAAC,iBAAA,CAAA,CAAmBC,OAAO,CAAC,UAAA,CAAA;AAEjE,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,MAAMpB,gBAAgBqB,6BAA6B;AAAG,iBAAA;AACvE;YAEA,OAAO;gBAAED,IAAM,EAAA,MAAMpB,gBAAgBsB,2BAA2B;AAAG,aAAA;AACrE;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"homepage.mjs","sources":["../../../../server/src/homepage/controllers/homepage.ts"],"sourcesContent":["import type { Core } from '@strapi/types';\nimport * as yup from 'yup';\nimport { errors } from '@strapi/utils';\nimport type { GetRecentDocuments, GetCountDocuments } from '../../../../shared/contracts/homepage';\n\nconst createHomepageController = () => {\n const homepageService = strapi.plugin('content-manager').service('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 async getCountDocuments(): Promise<GetCountDocuments.Response> {\n return { data: await homepageService.getCountDocuments() };\n },\n } satisfies Core.Controller;\n};\n\nexport { createHomepageController };\n"],"names":["createHomepageController","homepageService","strapi","plugin","service","recentDocumentParamsSchema","yup","object","shape","action","mixed","oneOf","required","getRecentDocuments","ctx","validate","query","error","ValidationError","errors","message","data","getRecentlyPublishedDocuments","getRecentlyUpdatedDocuments","getCountDocuments"],"mappings":";;;AAKA,MAAMA,wBAA2B,GAAA,IAAA;AAC/B,IAAA,MAAMC,kBAAkBC,MAAOC,CAAAA,MAAM,CAAC,iBAAA,CAAA,CAAmBC,OAAO,CAAC,UAAA,CAAA;AAEjE,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,MAAMpB,gBAAgBqB,6BAA6B;AAAG,iBAAA;AACvE;YAEA,OAAO;gBAAED,IAAM,EAAA,MAAMpB,gBAAgBsB,2BAA2B;AAAG,aAAA;AACrE,SAAA;QACA,MAAMC,iBAAAA,CAAAA,GAAAA;YACJ,OAAO;gBAAEH,IAAM,EAAA,MAAMpB,gBAAgBuB,iBAAiB;AAAG,aAAA;AAC3D;AACF,KAAA;AACF;;;;"}
|
|
@@ -17,6 +17,17 @@ const homepageRouter = {
|
|
|
17
17
|
'admin::isAuthenticatedAdmin'
|
|
18
18
|
]
|
|
19
19
|
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
method: 'GET',
|
|
23
|
+
info,
|
|
24
|
+
path: '/homepage/count-documents',
|
|
25
|
+
handler: 'homepage.getCountDocuments',
|
|
26
|
+
config: {
|
|
27
|
+
policies: [
|
|
28
|
+
'admin::isAuthenticatedAdmin'
|
|
29
|
+
]
|
|
30
|
+
}
|
|
20
31
|
}
|
|
21
32
|
]
|
|
22
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.js","sources":["../../../../server/src/homepage/routes/homepage.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nconst info = { pluginName: 'content-manager', type: 'admin' };\n\nconst homepageRouter: Plugin.LoadedPlugin['routes'][string] = {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n info,\n path: '/homepage/recent-documents',\n handler: 'homepage.getRecentDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n\nexport { homepageRouter };\n"],"names":["info","pluginName","type","homepageRouter","routes","method","path","handler","config","policies"],"mappings":";;AAEA,MAAMA,IAAO,GAAA;IAAEC,UAAY,EAAA,iBAAA;IAAmBC,IAAM,EAAA;AAAQ,CAAA;AAE5D,MAAMC,cAAwD,GAAA;IAC5DD,IAAM,EAAA,OAAA;IACNE,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;AACRL,YAAAA,IAAAA;YACAM,IAAM,EAAA,4BAAA;YACNC,OAAS,EAAA,6BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"homepage.js","sources":["../../../../server/src/homepage/routes/homepage.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nconst info = { pluginName: 'content-manager', type: 'admin' };\n\nconst homepageRouter: Plugin.LoadedPlugin['routes'][string] = {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n info,\n path: '/homepage/recent-documents',\n handler: 'homepage.getRecentDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'GET',\n info,\n path: '/homepage/count-documents',\n handler: 'homepage.getCountDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n\nexport { homepageRouter };\n"],"names":["info","pluginName","type","homepageRouter","routes","method","path","handler","config","policies"],"mappings":";;AAEA,MAAMA,IAAO,GAAA;IAAEC,UAAY,EAAA,iBAAA;IAAmBC,IAAM,EAAA;AAAQ,CAAA;AAE5D,MAAMC,cAAwD,GAAA;IAC5DD,IAAM,EAAA,OAAA;IACNE,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;AACRL,YAAAA,IAAAA;YACAM,IAAM,EAAA,4BAAA;YACNC,OAAS,EAAA,6BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF,SAAA;AACA,QAAA;YACEJ,MAAQ,EAAA,KAAA;AACRL,YAAAA,IAAAA;YACAM,IAAM,EAAA,2BAAA;YACNC,OAAS,EAAA,4BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH;;;;"}
|
|
@@ -15,6 +15,17 @@ const homepageRouter = {
|
|
|
15
15
|
'admin::isAuthenticatedAdmin'
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
method: 'GET',
|
|
21
|
+
info,
|
|
22
|
+
path: '/homepage/count-documents',
|
|
23
|
+
handler: 'homepage.getCountDocuments',
|
|
24
|
+
config: {
|
|
25
|
+
policies: [
|
|
26
|
+
'admin::isAuthenticatedAdmin'
|
|
27
|
+
]
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
]
|
|
20
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.mjs","sources":["../../../../server/src/homepage/routes/homepage.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nconst info = { pluginName: 'content-manager', type: 'admin' };\n\nconst homepageRouter: Plugin.LoadedPlugin['routes'][string] = {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n info,\n path: '/homepage/recent-documents',\n handler: 'homepage.getRecentDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n\nexport { homepageRouter };\n"],"names":["info","pluginName","type","homepageRouter","routes","method","path","handler","config","policies"],"mappings":"AAEA,MAAMA,IAAO,GAAA;IAAEC,UAAY,EAAA,iBAAA;IAAmBC,IAAM,EAAA;AAAQ,CAAA;AAE5D,MAAMC,cAAwD,GAAA;IAC5DD,IAAM,EAAA,OAAA;IACNE,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;AACRL,YAAAA,IAAAA;YACAM,IAAM,EAAA,4BAAA;YACNC,OAAS,EAAA,6BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"homepage.mjs","sources":["../../../../server/src/homepage/routes/homepage.ts"],"sourcesContent":["import type { Plugin } from '@strapi/types';\n\nconst info = { pluginName: 'content-manager', type: 'admin' };\n\nconst homepageRouter: Plugin.LoadedPlugin['routes'][string] = {\n type: 'admin',\n routes: [\n {\n method: 'GET',\n info,\n path: '/homepage/recent-documents',\n handler: 'homepage.getRecentDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n {\n method: 'GET',\n info,\n path: '/homepage/count-documents',\n handler: 'homepage.getCountDocuments',\n config: {\n policies: ['admin::isAuthenticatedAdmin'],\n },\n },\n ],\n};\n\nexport { homepageRouter };\n"],"names":["info","pluginName","type","homepageRouter","routes","method","path","handler","config","policies"],"mappings":"AAEA,MAAMA,IAAO,GAAA;IAAEC,UAAY,EAAA,iBAAA;IAAmBC,IAAM,EAAA;AAAQ,CAAA;AAE5D,MAAMC,cAAwD,GAAA;IAC5DD,IAAM,EAAA,OAAA;IACNE,MAAQ,EAAA;AACN,QAAA;YACEC,MAAQ,EAAA,KAAA;AACRL,YAAAA,IAAAA;YACAM,IAAM,EAAA,4BAAA;YACNC,OAAS,EAAA,6BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF,SAAA;AACA,QAAA;YACEJ,MAAQ,EAAA,KAAA;AACRL,YAAAA,IAAAA;YACAM,IAAM,EAAA,2BAAA;YACNC,OAAS,EAAA,4BAAA;YACTC,MAAQ,EAAA;gBACNC,QAAU,EAAA;AAAC,oBAAA;AAA8B;AAC3C;AACF;AACD;AACH;;;;"}
|
|
@@ -66,8 +66,12 @@ const createHomepageService = ({ strapi })=>{
|
|
|
66
66
|
};
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
-
const formatDocuments = (documents, meta)=>{
|
|
69
|
+
const formatDocuments = (documents, meta, populate)=>{
|
|
70
70
|
return documents.map((document)=>{
|
|
71
|
+
const additionalFields = populate?.reduce((acc, key)=>{
|
|
72
|
+
acc[key] = document[key];
|
|
73
|
+
return acc;
|
|
74
|
+
}, {}) || {};
|
|
71
75
|
return {
|
|
72
76
|
documentId: document.documentId,
|
|
73
77
|
locale: document.locale ?? null,
|
|
@@ -76,79 +80,115 @@ const createHomepageService = ({ strapi })=>{
|
|
|
76
80
|
publishedAt: meta.hasDraftAndPublish && document.publishedAt ? new Date(document.publishedAt) : null,
|
|
77
81
|
contentTypeUid: meta.uid,
|
|
78
82
|
contentTypeDisplayName: meta.contentType.info.displayName,
|
|
79
|
-
kind: meta.contentType.kind
|
|
83
|
+
kind: meta.contentType.kind,
|
|
84
|
+
...additionalFields
|
|
80
85
|
};
|
|
81
86
|
});
|
|
82
87
|
};
|
|
83
|
-
const addStatusToDocuments = async (documents)=>{
|
|
84
|
-
return Promise.all(documents.map(async (recentDocument)=>{
|
|
85
|
-
const hasDraftAndPublish = strapiUtils.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
88
|
const permissionCheckerService = strapi.plugin('content-manager').service('permission-checker');
|
|
101
89
|
const getPermissionChecker = (uid)=>permissionCheckerService.create({
|
|
102
90
|
userAbility: strapi.requestContext.get()?.state.userAbility,
|
|
103
91
|
model: uid
|
|
104
92
|
});
|
|
105
93
|
return {
|
|
106
|
-
async
|
|
94
|
+
async addStatusToDocuments (documents) {
|
|
95
|
+
return Promise.all(documents.map(async (recentDocument)=>{
|
|
96
|
+
const hasDraftAndPublish = strapiUtils.contentTypes.hasDraftAndPublish(strapi.contentType(recentDocument.contentTypeUid));
|
|
97
|
+
/**
|
|
98
|
+
* Tries to query the other version of the document if draft and publish is enabled,
|
|
99
|
+
* so that we know when to give the "modified" status.
|
|
100
|
+
*/ const { availableStatus } = await metadataService.getMetadata(recentDocument.contentTypeUid, recentDocument, {
|
|
101
|
+
availableStatus: hasDraftAndPublish,
|
|
102
|
+
availableLocales: false
|
|
103
|
+
});
|
|
104
|
+
const status = metadataService.getStatus(recentDocument, availableStatus);
|
|
105
|
+
return {
|
|
106
|
+
...recentDocument,
|
|
107
|
+
status: hasDraftAndPublish ? status : undefined
|
|
108
|
+
};
|
|
109
|
+
}));
|
|
110
|
+
},
|
|
111
|
+
async queryLastDocuments (additionalQueryParams, draftAndPublishOnly) {
|
|
107
112
|
const permittedContentTypes = await getPermittedContentTypes();
|
|
108
|
-
const allowedContentTypeUids = permittedContentTypes.filter((uid)=>{
|
|
113
|
+
const allowedContentTypeUids = draftAndPublishOnly ? permittedContentTypes.filter((uid)=>{
|
|
109
114
|
return strapiUtils.contentTypes.hasDraftAndPublish(strapi.contentType(uid));
|
|
110
|
-
});
|
|
115
|
+
}) : permittedContentTypes;
|
|
111
116
|
// Fetch the configuration for each content type in a single query
|
|
112
117
|
const configurations = await getConfiguration(allowedContentTypeUids);
|
|
113
118
|
// Get the necessary metadata for the documents
|
|
114
119
|
const contentTypesMeta = getContentTypesMeta(allowedContentTypeUids, configurations);
|
|
115
|
-
// Now actually fetch and format the documents
|
|
116
120
|
const recentDocuments = await Promise.all(contentTypesMeta.map(async (meta)=>{
|
|
117
121
|
const permissionQuery = await getPermissionChecker(meta.uid).sanitizedQuery.read({
|
|
118
122
|
limit: MAX_DOCUMENTS,
|
|
119
|
-
sort: 'publishedAt:desc',
|
|
120
123
|
fields: meta.fields,
|
|
121
|
-
|
|
124
|
+
...additionalQueryParams
|
|
122
125
|
});
|
|
123
126
|
const docs = await strapi.documents(meta.uid).findMany(permissionQuery);
|
|
124
|
-
|
|
127
|
+
const populate = additionalQueryParams?.populate;
|
|
128
|
+
return formatDocuments(docs, meta, populate);
|
|
125
129
|
}));
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
return recentDocuments.flat().sort((a, b)=>{
|
|
131
|
+
switch(additionalQueryParams?.sort){
|
|
132
|
+
case 'publishedAt:desc':
|
|
133
|
+
if (!a.publishedAt || !b.publishedAt) return 0;
|
|
134
|
+
return b.publishedAt.valueOf() - a.publishedAt.valueOf();
|
|
135
|
+
case 'publishedAt:asc':
|
|
136
|
+
if (!a.publishedAt || !b.publishedAt) return 0;
|
|
137
|
+
return a.publishedAt.valueOf() - b.publishedAt.valueOf();
|
|
138
|
+
case 'updatedAt:desc':
|
|
139
|
+
if (!a.updatedAt || !b.updatedAt) return 0;
|
|
140
|
+
return b.updatedAt.valueOf() - a.updatedAt.valueOf();
|
|
141
|
+
case 'updatedAt:asc':
|
|
142
|
+
if (!a.updatedAt || !b.updatedAt) return 0;
|
|
143
|
+
return a.updatedAt.valueOf() - b.updatedAt.valueOf();
|
|
144
|
+
default:
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
129
147
|
}).slice(0, MAX_DOCUMENTS);
|
|
130
|
-
|
|
148
|
+
},
|
|
149
|
+
async getRecentlyPublishedDocuments () {
|
|
150
|
+
const recentlyPublishedDocuments = await this.queryLastDocuments({
|
|
151
|
+
sort: 'publishedAt:desc',
|
|
152
|
+
status: 'published'
|
|
153
|
+
}, true);
|
|
154
|
+
return this.addStatusToDocuments(recentlyPublishedDocuments);
|
|
131
155
|
},
|
|
132
156
|
async getRecentlyUpdatedDocuments () {
|
|
133
|
-
const
|
|
157
|
+
const recentlyUpdatedDocuments = await this.queryLastDocuments({
|
|
158
|
+
sort: 'updatedAt:desc'
|
|
159
|
+
});
|
|
160
|
+
return this.addStatusToDocuments(recentlyUpdatedDocuments);
|
|
161
|
+
},
|
|
162
|
+
async getCountDocuments () {
|
|
163
|
+
const permittedContentTypes = await getPermittedContentTypes();
|
|
134
164
|
// Fetch the configuration for each content type in a single query
|
|
135
|
-
const configurations = await getConfiguration(
|
|
165
|
+
const configurations = await getConfiguration(permittedContentTypes);
|
|
136
166
|
// Get the necessary metadata for the documents
|
|
137
|
-
const contentTypesMeta = getContentTypesMeta(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
167
|
+
const contentTypesMeta = getContentTypesMeta(permittedContentTypes, configurations);
|
|
168
|
+
const countDocuments = {
|
|
169
|
+
draft: 0,
|
|
170
|
+
published: 0,
|
|
171
|
+
modified: 0
|
|
172
|
+
};
|
|
173
|
+
await Promise.all(contentTypesMeta.map(async (meta)=>{
|
|
174
|
+
const strapiDBConnection = strapi.db.connection;
|
|
175
|
+
const tableName = strapi.contentType(meta.uid).collectionName;
|
|
176
|
+
if (tableName) {
|
|
177
|
+
const draftDocuments = await strapiDBConnection(tableName).whereNull('published_at').whereIn('document_id', function() {
|
|
178
|
+
this.select('document_id').from(tableName).groupBy('document_id').havingRaw('COUNT(*) = 1');
|
|
179
|
+
}).count('* as count').first();
|
|
180
|
+
countDocuments.draft += Number(draftDocuments?.count) || 0;
|
|
181
|
+
const publishedDocuments = meta.hasDraftAndPublish ? await strapiDBConnection(tableName).select('draft.document_id').from(`${tableName} as draft`).join(`${tableName} as published`, function() {
|
|
182
|
+
this.on('draft.document_id', '=', 'published.document_id').andOn('draft.updated_at', '=', 'published.updated_at').andOnNull('draft.published_at').andOnNotNull('published.published_at');
|
|
183
|
+
}).countDistinct('draft.document_id as count').first() : await strapiDBConnection(tableName).select('document_id').from(`${tableName}`).countDistinct('document_id as count').first();
|
|
184
|
+
countDocuments.published += Number(publishedDocuments?.count) || 0;
|
|
185
|
+
const modifiedDocuments = await strapiDBConnection(tableName).select('draft.document_id').from(`${tableName} as draft`).join(`${tableName} as published`, function() {
|
|
186
|
+
this.on('draft.document_id', '=', 'published.document_id').andOn('draft.updated_at', '!=', 'published.updated_at').andOnNull('draft.published_at').andOnNotNull('published.published_at');
|
|
187
|
+
}).countDistinct('draft.document_id as count').first();
|
|
188
|
+
countDocuments.modified += Number(modifiedDocuments?.count) || 0;
|
|
189
|
+
}
|
|
147
190
|
}));
|
|
148
|
-
|
|
149
|
-
return b.updatedAt.valueOf() - a.updatedAt.valueOf();
|
|
150
|
-
}).slice(0, MAX_DOCUMENTS);
|
|
151
|
-
return addStatusToDocuments(overallRecentDocuments);
|
|
191
|
+
return countDocuments;
|
|
152
192
|
}
|
|
153
193
|
};
|
|
154
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homepage.js","sources":["../../../../server/src/homepage/services/homepage.ts"],"sourcesContent":["import type { Core, Modules, Schema } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\nimport type { GetRecentDocuments, RecentDocument } from '../../../../shared/contracts/homepage';\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;\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: Modules.Permissions.PermissionRule[] = 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":";;;;AAKA,MAAMA,qBAAwB,GAAA,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,MA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EAAA;aAEnDC,CAAAA,CAAAA,KAAK,CAAC,CAAGnG,EAAAA,aAAAA,CAAAA;AAEZ,YAAA,OAAOqE,oBAAqByB,CAAAA,sBAAAA,CAAAA;AAC9B;AACF,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"homepage.js","sources":["../../../../server/src/homepage/services/homepage.ts"],"sourcesContent":["import type { Core, Modules, Schema } from '@strapi/types';\nimport { contentTypes } from '@strapi/utils';\n\nimport type {\n GetCountDocuments,\n GetRecentDocuments,\n RecentDocument,\n} from '../../../../shared/contracts/homepage';\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;\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: Modules.Permissions.PermissionRule[] = 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 = (\n documents: Modules.Documents.AnyDocument[],\n meta: ContentTypeMeta,\n populate?: string[]\n ) => {\n return documents.map((document) => {\n const additionalFields =\n populate?.reduce(\n (acc, key) => {\n acc[key] = document[key];\n return acc;\n },\n {} as Record<string, any>\n ) || {};\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 ...additionalFields,\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 addStatusToDocuments(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 async queryLastDocuments(\n additionalQueryParams?: Record<string, unknown>,\n draftAndPublishOnly?: boolean\n ): Promise<RecentDocument[]> {\n const permittedContentTypes = await getPermittedContentTypes();\n const allowedContentTypeUids = draftAndPublishOnly\n ? permittedContentTypes.filter((uid) => {\n return contentTypes.hasDraftAndPublish(strapi.contentType(uid));\n })\n : permittedContentTypes;\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\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 fields: meta.fields,\n ...additionalQueryParams,\n });\n\n const docs = await strapi.documents(meta.uid).findMany(permissionQuery);\n const populate = additionalQueryParams?.populate as string[];\n\n return formatDocuments(docs, meta, populate);\n })\n );\n\n return recentDocuments\n .flat()\n .sort((a, b) => {\n switch (additionalQueryParams?.sort) {\n case 'publishedAt:desc':\n if (!a.publishedAt || !b.publishedAt) return 0;\n return b.publishedAt.valueOf() - a.publishedAt.valueOf();\n case 'publishedAt:asc':\n if (!a.publishedAt || !b.publishedAt) return 0;\n return a.publishedAt.valueOf() - b.publishedAt.valueOf();\n case 'updatedAt:desc':\n if (!a.updatedAt || !b.updatedAt) return 0;\n return b.updatedAt.valueOf() - a.updatedAt.valueOf();\n case 'updatedAt:asc':\n if (!a.updatedAt || !b.updatedAt) return 0;\n return a.updatedAt.valueOf() - b.updatedAt.valueOf();\n default:\n return 0;\n }\n })\n .slice(0, MAX_DOCUMENTS);\n },\n\n async getRecentlyPublishedDocuments(): Promise<GetRecentDocuments.Response['data']> {\n const recentlyPublishedDocuments = await this.queryLastDocuments(\n {\n sort: 'publishedAt:desc',\n status: 'published',\n },\n true\n );\n\n return this.addStatusToDocuments(recentlyPublishedDocuments);\n },\n\n async getRecentlyUpdatedDocuments(): Promise<GetRecentDocuments.Response['data']> {\n const recentlyUpdatedDocuments = await this.queryLastDocuments({\n sort: 'updatedAt:desc',\n });\n\n return this.addStatusToDocuments(recentlyUpdatedDocuments);\n },\n\n async getCountDocuments(): Promise<GetCountDocuments.Response['data']> {\n const permittedContentTypes = await getPermittedContentTypes();\n // Fetch the configuration for each content type in a single query\n const configurations = await getConfiguration(permittedContentTypes);\n // Get the necessary metadata for the documents\n const contentTypesMeta = getContentTypesMeta(permittedContentTypes, configurations);\n\n const countDocuments = {\n draft: 0,\n published: 0,\n modified: 0,\n };\n\n await Promise.all(\n contentTypesMeta.map(async (meta) => {\n const strapiDBConnection = strapi.db.connection;\n const tableName = strapi.contentType(meta.uid).collectionName;\n if (tableName) {\n const draftDocuments = await strapiDBConnection(tableName)\n .whereNull('published_at')\n .whereIn('document_id', function () {\n this.select('document_id')\n .from(tableName)\n .groupBy('document_id')\n .havingRaw('COUNT(*) = 1');\n })\n .count('* as count')\n .first();\n countDocuments.draft += Number(draftDocuments?.count) || 0;\n\n const publishedDocuments = meta.hasDraftAndPublish\n ? await strapiDBConnection(tableName)\n .select('draft.document_id')\n .from(`${tableName} as draft`)\n .join(`${tableName} as published`, function () {\n this.on('draft.document_id', '=', 'published.document_id')\n .andOn('draft.updated_at', '=', 'published.updated_at')\n .andOnNull('draft.published_at')\n .andOnNotNull('published.published_at');\n })\n .countDistinct('draft.document_id as count')\n .first()\n : await strapiDBConnection(tableName)\n .select('document_id')\n .from(`${tableName}`)\n .countDistinct('document_id as count')\n .first();\n countDocuments.published += Number(publishedDocuments?.count) || 0;\n\n const modifiedDocuments = await strapiDBConnection(tableName)\n .select('draft.document_id')\n .from(`${tableName} as draft`)\n .join(`${tableName} as published`, function () {\n this.on('draft.document_id', '=', 'published.document_id')\n .andOn('draft.updated_at', '!=', 'published.updated_at')\n .andOnNull('draft.published_at')\n .andOnNotNull('published.published_at');\n })\n .countDistinct('draft.document_id as count')\n .first();\n countDocuments.modified += Number(modifiedDocuments?.count) || 0;\n }\n })\n );\n\n return countDocuments;\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","populate","document","additionalFields","reduce","acc","documentId","locale","updatedAt","Date","title","publishedAt","contentTypeUid","contentTypeDisplayName","info","displayName","kind","permissionCheckerService","getPermissionChecker","create","userAbility","model","addStatusToDocuments","Promise","all","recentDocument","availableStatus","getMetadata","availableLocales","status","getStatus","undefined","queryLastDocuments","additionalQueryParams","draftAndPublishOnly","permittedContentTypes","contentTypesMeta","recentDocuments","permissionQuery","sanitizedQuery","read","limit","docs","flat","sort","a","b","valueOf","slice","getRecentlyPublishedDocuments","recentlyPublishedDocuments","getRecentlyUpdatedDocuments","recentlyUpdatedDocuments","getCountDocuments","countDocuments","draft","published","modified","strapiDBConnection","connection","tableName","collectionName","draftDocuments","whereNull","whereIn","select","from","groupBy","havingRaw","count","first","Number","publishedDocuments","join","on","andOn","andOnNull","andOnNotNull","countDistinct","modifiedDocuments"],"mappings":";;;;AASA,MAAMA,qBAAwB,GAAA,CAAC,EAAEC,MAAM,EAA2B,GAAA;AAChE,IAAA,MAAMC,aAAgB,GAAA,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