sass-cms-template-common 0.0.4 → 0.0.6
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/index.d.ts +5155 -85
- package/dist/index.js +844 -371
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +4903 -141
- package/dist/server.js +2 -2
- package/dist/services-BqEo-2mI.js +3349 -0
- package/dist/services-BqEo-2mI.js.map +1 -0
- package/package.json +2 -2
- package/dist/services-DlTJ4HIV.js +0 -82
- package/dist/services-DlTJ4HIV.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sass-cms-template-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Componentes y utilidades compartidas para CMS Bluestack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"build:watch": "vite build --watch",
|
|
35
35
|
"lint": "eslint .",
|
|
36
36
|
"preview": "vite preview",
|
|
37
|
-
"
|
|
37
|
+
"prepublishOnly": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@emotion/react": "^11.0.0",
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//#region src/lib/utils/site-selector.ts
|
|
2
|
-
var e = "#ECEDF6", t = "#D8E2FF", n = "#FFFFFF", r = "bluestack-es";
|
|
3
|
-
function i(e) {
|
|
4
|
-
return e.flatMap((e) => e.publications);
|
|
5
|
-
}
|
|
6
|
-
function a(e, t) {
|
|
7
|
-
return i(e).find((e) => String(e.id) === t);
|
|
8
|
-
}
|
|
9
|
-
function o(e, t) {
|
|
10
|
-
return i(e).find((e) => String(e.id) === t)?.description ?? "Seleccionar publicación";
|
|
11
|
-
}
|
|
12
|
-
function s(e) {
|
|
13
|
-
let t = i(e)[0];
|
|
14
|
-
return t ? String(t.id) : "1";
|
|
15
|
-
}
|
|
16
|
-
function c(e) {
|
|
17
|
-
let t = Number(e);
|
|
18
|
-
return Number.isFinite(t) && t > 0 ? t : 1;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/lib/services/index.ts
|
|
22
|
-
var l = class {
|
|
23
|
-
props;
|
|
24
|
-
authentication;
|
|
25
|
-
constructor(e) {
|
|
26
|
-
this.props = e, this.authentication = e.authentication;
|
|
27
|
-
}
|
|
28
|
-
getDefaultPublication = async () => {
|
|
29
|
-
try {
|
|
30
|
-
return (await this.props.axiosApi.post("/publications/default", { authentication: this.authentication })).data;
|
|
31
|
-
} catch (e) {
|
|
32
|
-
return console.log(`[/publications/default] Error: ${e.message}`), Promise.reject(e);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
getProfile = async () => {
|
|
36
|
-
try {
|
|
37
|
-
return (await this.props.axiosApi.post("/profile/get", { authentication: this.authentication })).data;
|
|
38
|
-
} catch (e) {
|
|
39
|
-
return console.error("[/profile/get]", e), Promise.reject(e);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
getCountNotifications = async () => {
|
|
43
|
-
try {
|
|
44
|
-
return (await this.props.axiosApi.post("/dashboard/countNotifications", { authentication: this.authentication })).data;
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return console.error("[/dashboard/countNotificatio]", e), Promise.reject(e);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
getNotifications = async () => {
|
|
50
|
-
try {
|
|
51
|
-
return (await this.props.axiosApi.post("/dashboard/notification", { authentication: this.authentication })).data;
|
|
52
|
-
} catch (e) {
|
|
53
|
-
return console.error("[/dashboard/notification]", e), Promise.reject(e);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
getSitesAndPublications = async () => {
|
|
57
|
-
try {
|
|
58
|
-
let [e, t, n, r] = await Promise.all([
|
|
59
|
-
this.props.axiosApi.post("/sites/get", { authentication: this.authentication }),
|
|
60
|
-
this.props.axiosApi.post("/publications/get", { authentication: this.authentication }),
|
|
61
|
-
this.props.axiosApi.post("/auth/modulesAvailable", { authentication: this.authentication }),
|
|
62
|
-
this.props.axiosApi.post("/auth/permissions", { authentication: this.authentication })
|
|
63
|
-
]), i = e.data.sites.map((e) => ({
|
|
64
|
-
title: e.title,
|
|
65
|
-
publications: t.data.publications.filter((t) => t.site === e.name)
|
|
66
|
-
}));
|
|
67
|
-
return console.log(r, "permissions"), {
|
|
68
|
-
sites: i.filter((e) => e.publications.length > 0),
|
|
69
|
-
modules: n.data.modules
|
|
70
|
-
};
|
|
71
|
-
} catch (e) {
|
|
72
|
-
return console.error(e), {
|
|
73
|
-
sites: [],
|
|
74
|
-
modules: []
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
//#endregion
|
|
80
|
-
export { e as a, i as c, t as i, s as l, r as n, a as o, n as r, o as s, l as t, c as u };
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=services-DlTJ4HIV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services-DlTJ4HIV.js","names":[],"sources":["../src/lib/utils/site-selector.ts","../src/lib/services/index.ts"],"sourcesContent":["import type { Publication } from '../types/publication';\nimport type { SiteSection } from '../types/site';\n\nexport const MENU_BG = '#ECEDF6';\nexport const ITEM_HOVER_BG = '#D8E2FF';\nexport const ITEM_DEFAULT_BG = '#FFFFFF';\n\nexport const DEFAULT_SITE_ID = 'bluestack-es';\n\nexport function getAllPublications(sites: SiteSection[]): Publication[] {\n return sites.flatMap((section) => section.publications);\n}\n\nexport function findPublicationBySlug(\n sites: SiteSection[],\n slug: string,\n): Publication | undefined {\n return getAllPublications(sites).find((p) => String(p.id) === slug);\n}\n\nexport function findPublicationLabel(\n sites: SiteSection[],\n publicationId: string,\n): string {\n const publication = getAllPublications(sites).find(\n (p) => String(p.id) === publicationId,\n );\n return publication?.description ?? 'Seleccionar publicación';\n}\n\nexport function getDefaultPublicationSlug(sites: SiteSection[]): string {\n const first = getAllPublications(sites)[0];\n return first ? String(first.id) : '1';\n}\n\nexport function parsePublicationSlug(slug: string): number {\n const id = Number(slug);\n return Number.isFinite(id) && id > 0 ? id : 1;\n}\n","import type { AxiosInstance } from 'axios';\n\nimport type { Authentication } from '../types/authentication';\nimport type {\n CountNotificationsResponse,\n NotificationsListResponse,\n} from '../types/notification';\nimport type { ProfileGetResponse } from '../types/profile';\nimport type { SiteSection } from '../types/site';\nimport type { Publication, PublicationsGetResponse } from './publication';\nimport type {\n ModulesAvailableResponse,\n SitesAndPublicationsResult,\n SitesGetResponse,\n} from './site';\n\nexport type {\n Publication,\n PublicationPermissions,\n PublicationsGetResponse,\n PublicationUpdateAdmin,\n PublicationZoneConfig,\n} from './publication';\n\nexport type {\n ModulesAvailableResponse,\n Site,\n SitesAndPublicationsResult,\n SitesGetResponse,\n} from './site';\n\ninterface ICommonServices {\n axiosApi: AxiosInstance;\n authentication: Authentication;\n}\n\nexport class CmsCommonServices {\n protected props: ICommonServices;\n protected authentication: Authentication;\n\n constructor(props: ICommonServices) {\n this.props = props;\n this.authentication = props.authentication;\n }\n\n getDefaultPublication = async () => {\n try {\n const response = await this.props.axiosApi.post<Publication>(\n '/publications/default',\n {\n authentication: this.authentication,\n },\n );\n return response.data;\n } catch (error: any) {\n console.log(`[/publications/default] Error: ${error.message}`);\n return Promise.reject(error);\n }\n };\n\n getProfile = async (): Promise<ProfileGetResponse> => {\n try {\n const response = await this.props.axiosApi.post<ProfileGetResponse>(\n '/profile/get',\n {\n authentication: this.authentication,\n },\n );\n return response.data;\n } catch (error: any) {\n console.error('[/profile/get]', error);\n return Promise.reject(error);\n }\n };\n\n getCountNotifications = async (): Promise<CountNotificationsResponse> => {\n try {\n const response =\n await this.props.axiosApi.post<CountNotificationsResponse>(\n '/dashboard/countNotifications',\n {\n authentication: this.authentication,\n },\n );\n return response.data;\n } catch (error: any) {\n console.error('[/dashboard/countNotificatio]', error);\n return Promise.reject(error);\n }\n };\n\n getNotifications = async (): Promise<NotificationsListResponse> => {\n try {\n const response =\n await this.props.axiosApi.post<NotificationsListResponse>(\n '/dashboard/notification',\n {\n authentication: this.authentication,\n },\n );\n return response.data;\n } catch (error: any) {\n console.error('[/dashboard/notification]', error);\n return Promise.reject(error);\n }\n };\n\n getSitesAndPublications = async (): Promise<SitesAndPublicationsResult> => {\n try {\n const [resSites, resPublications, resModules, permissions] =\n await Promise.all([\n this.props.axiosApi.post<SitesGetResponse>('/sites/get', {\n authentication: this.authentication,\n }),\n this.props.axiosApi.post<PublicationsGetResponse>(\n '/publications/get',\n {\n authentication: this.authentication,\n },\n ),\n this.props.axiosApi.post<ModulesAvailableResponse>(\n '/auth/modulesAvailable',\n {\n authentication: this.authentication,\n },\n ),\n this.props.axiosApi.post<ModulesAvailableResponse>(\n '/auth/permissions',\n {\n authentication: this.authentication,\n },\n ),\n ]);\n\n const sites: SiteSection[] = resSites.data.sites.map((site) => ({\n title: site.title,\n publications: resPublications.data.publications.filter(\n (publication) => publication.site === site.name,\n ),\n }));\n\n console.log(permissions, 'permissions');\n\n return {\n sites: sites.filter((site) => site.publications.length > 0),\n modules: resModules.data.modules,\n };\n } catch (error) {\n console.error(error);\n return {\n sites: [],\n modules: [],\n };\n }\n };\n}\n"],"mappings":";AAGA,IAAa,IAAU,WACV,IAAgB,WAChB,IAAkB,WAElB,IAAkB;AAE/B,SAAgB,EAAmB,GAAqC;CACtE,OAAO,EAAM,SAAS,MAAY,EAAQ,YAAY;AACxD;AAEA,SAAgB,EACd,GACA,GACyB;CACzB,OAAO,EAAmB,CAAK,EAAE,MAAM,MAAM,OAAO,EAAE,EAAE,MAAM,CAAI;AACpE;AAEA,SAAgB,EACd,GACA,GACQ;CAIR,OAHoB,EAAmB,CAAK,EAAE,MAC3C,MAAM,OAAO,EAAE,EAAE,MAAM,CAEnB,GAAa,eAAe;AACrC;AAEA,SAAgB,EAA0B,GAA8B;CACtE,IAAM,IAAQ,EAAmB,CAAK,EA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