sass-cms-template-common 0.0.3 → 0.0.4
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 +10 -7
- package/dist/index.js +465 -503
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +10 -0
- package/dist/server.js +2 -2
- package/dist/{services-D9XCHGgK.js → services-DlTJ4HIV.js} +32 -11
- package/dist/services-DlTJ4HIV.js.map +1 -0
- package/package.json +1 -1
- package/dist/services-D9XCHGgK.js.map +0 -1
package/dist/server.d.ts
CHANGED
|
@@ -38,6 +38,14 @@ export declare interface DashboardNotification {
|
|
|
38
38
|
href?: string;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export declare function findPublicationBySlug(sites: SiteSection[], slug: string): Publication | undefined;
|
|
42
|
+
|
|
43
|
+
export declare function findPublicationLabel(sites: SiteSection[], publicationId: string): string;
|
|
44
|
+
|
|
45
|
+
export declare function getAllPublications(sites: SiteSection[]): Publication[];
|
|
46
|
+
|
|
47
|
+
export declare function getDefaultPublicationSlug(sites: SiteSection[]): string;
|
|
48
|
+
|
|
41
49
|
declare interface ICommonServices {
|
|
42
50
|
axiosApi: AxiosInstance;
|
|
43
51
|
authentication: Authentication;
|
|
@@ -76,6 +84,8 @@ export declare interface NotificationsListResponse {
|
|
|
76
84
|
total?: number;
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
export declare function parsePublicationSlug(slug: string): number;
|
|
88
|
+
|
|
79
89
|
export declare interface ProfileAdditionalInfoField {
|
|
80
90
|
name: string;
|
|
81
91
|
type: ProfileFieldType;
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as e, l as t, o as n, s as r, t as i, u as a } from "./services-DlTJ4HIV.js";
|
|
2
|
+
export { i as CmsCommonServices, n as findPublicationBySlug, r as findPublicationLabel, e as getAllPublications, t as getDefaultPublicationSlug, a as parsePublicationSlug };
|
|
@@ -1,5 +1,25 @@
|
|
|
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
|
|
1
21
|
//#region src/lib/services/index.ts
|
|
2
|
-
var
|
|
22
|
+
var l = class {
|
|
3
23
|
props;
|
|
4
24
|
authentication;
|
|
5
25
|
constructor(e) {
|
|
@@ -35,16 +55,17 @@ var e = class {
|
|
|
35
55
|
};
|
|
36
56
|
getSitesAndPublications = async () => {
|
|
37
57
|
try {
|
|
38
|
-
let [e, t, n] = await Promise.all([
|
|
58
|
+
let [e, t, n, r] = await Promise.all([
|
|
39
59
|
this.props.axiosApi.post("/sites/get", { authentication: this.authentication }),
|
|
40
60
|
this.props.axiosApi.post("/publications/get", { authentication: this.authentication }),
|
|
41
|
-
this.props.axiosApi.post("/auth/modulesAvailable", { authentication: this.authentication })
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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),
|
|
48
69
|
modules: n.data.modules
|
|
49
70
|
};
|
|
50
71
|
} catch (e) {
|
|
@@ -56,6 +77,6 @@ var e = class {
|
|
|
56
77
|
};
|
|
57
78
|
};
|
|
58
79
|
//#endregion
|
|
59
|
-
export { e as t };
|
|
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 };
|
|
60
81
|
|
|
61
|
-
//# sourceMappingURL=services-
|
|
82
|
+
//# sourceMappingURL=services-DlTJ4HIV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE;CACxC,OAAO,IAAQ,OAAO,EAAM,EAAE,IAAI;AACpC;AAEA,SAAgB,EAAqB,GAAsB;CACzD,IAAM,IAAK,OAAO,CAAI;CACtB,OAAO,OAAO,SAAS,CAAE,KAAK,IAAK,IAAI,IAAK;AAC9C;;;AC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,gBAAgB,KAAK,eACvB,CACF;IACA,KAAK,MAAM,SAAS,KAClB,qBACA,EACE,gBAAgB,KAAK,eACvB,CACF;GACF,CAAC,GAEG,IAAuB,EAAS,KAAK,MAAM,KAAK,OAAU;IAC9D,OAAO,EAAK;IACZ,cAAc,EAAgB,KAAK,aAAa,QAC7C,MAAgB,EAAY,SAAS,EAAK,IAC7C;GACF,EAAE;GAIF,OAFA,QAAQ,IAAI,GAAa,aAAa,GAE/B;IACL,OAAO,EAAM,QAAQ,MAAS,EAAK,aAAa,SAAS,CAAC;IAC1D,SAAS,EAAW,KAAK;GAC3B;EACF,SAAS,GAAO;GAEd,OADA,QAAQ,MAAM,CAAK,GACZ;IACL,OAAO,CAAC;IACR,SAAS,CAAC;GACZ;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"services-D9XCHGgK.js","names":[],"sources":["../src/lib/services/index.ts"],"sourcesContent":["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] = await Promise.all([\n this.props.axiosApi.post<SitesGetResponse>('/sites/get', {\n authentication: this.authentication,\n }),\n this.props.axiosApi.post<PublicationsGetResponse>('/publications/get', {\n authentication: this.authentication,\n }),\n this.props.axiosApi.post<ModulesAvailableResponse>(\n '/auth/modulesAvailable',\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 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":";AAoCA,IAAa,IAAb,MAA+B;CAC7B;CACA;CAEA,YAAY,GAAwB;EAElC,AADA,KAAK,QAAQ,GACb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