sass-cms-template-common 0.0.1 → 0.0.3

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.
@@ -0,0 +1,207 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ElementType } from 'react';
3
+
4
+ /** Credenciales de sesión CMS usadas por los servicios HTTP. */
5
+ export declare type Authentication = {
6
+ browserId: string;
7
+ project: string;
8
+ publication: number;
9
+ siteName: string;
10
+ token: string;
11
+ };
12
+
13
+ export declare class CmsCommonServices {
14
+ protected props: ICommonServices;
15
+ protected authentication: Authentication;
16
+ constructor(props: ICommonServices);
17
+ getDefaultPublication: () => Promise<Publication>;
18
+ getProfile: () => Promise<ProfileGetResponse>;
19
+ getCountNotifications: () => Promise<CountNotificationsResponse>;
20
+ getNotifications: () => Promise<NotificationsListResponse>;
21
+ getSitesAndPublications: () => Promise<SitesAndPublicationsResult>;
22
+ }
23
+
24
+ /** POST /dashboard/countNotificatio */
25
+ export declare interface CountNotificationsResponse {
26
+ status: string;
27
+ count: number;
28
+ unreadNotifications?: number;
29
+ }
30
+
31
+ export declare interface DashboardNotification {
32
+ id: string;
33
+ title: string;
34
+ message: string;
35
+ severity: NotificationSeverity;
36
+ read: boolean;
37
+ createdAt: string;
38
+ href?: string;
39
+ }
40
+
41
+ declare interface ICommonServices {
42
+ axiosApi: AxiosInstance;
43
+ authentication: Authentication;
44
+ }
45
+
46
+ /** Cuerpo de la respuesta de POST /auth/modulesAvailable */
47
+ export declare interface ModulesAvailableResponse {
48
+ modules: NavItemPermissions[];
49
+ }
50
+
51
+ export declare type NavBlock = NavLinkItem;
52
+
53
+ export declare type NavItemPermissions = {
54
+ module: string;
55
+ isnew: boolean;
56
+ };
57
+
58
+ export declare type NavLinkItem = {
59
+ href: string;
60
+ icon: ElementType;
61
+ /** Clave de POST /auth/modulesAvailable (p. ej. `NEWSWIRES`, `MENUS`) */
62
+ module: string;
63
+ /** Override opcional del label traducido vía i18n (`navigation.{module}`). */
64
+ label?: string;
65
+ badge?: string;
66
+ children?: NavLinkItem[];
67
+ defaultOpen?: boolean;
68
+ };
69
+
70
+ export declare type NotificationSeverity = 'info' | 'warning' | 'error' | 'success';
71
+
72
+ /** POST /dashboard/notification */
73
+ export declare interface NotificationsListResponse {
74
+ status: string;
75
+ notifications: DashboardNotification[];
76
+ total?: number;
77
+ }
78
+
79
+ export declare interface ProfileAdditionalInfoField {
80
+ name: string;
81
+ type: ProfileFieldType;
82
+ options: string[];
83
+ categoryPath: string;
84
+ depends: string;
85
+ }
86
+
87
+ export declare type ProfileFieldType = 'string' | 'textarea' | 'date' | 'option' | 'category';
88
+
89
+ /** POST /profile/get */
90
+ export declare interface ProfileGetResponse {
91
+ status: string;
92
+ creationDate: string;
93
+ defaultPublication: string;
94
+ defaultSite: string;
95
+ email: string;
96
+ firstName: string;
97
+ fullName: string;
98
+ image: string;
99
+ lastName: string;
100
+ locale: string;
101
+ userName: string;
102
+ userStatus: string;
103
+ viewNews: string;
104
+ viewPins: string;
105
+ imageAllowedFileTypes: string;
106
+ additionalInfo: ProfileAdditionalInfoField[];
107
+ documentation: unknown[];
108
+ }
109
+
110
+ /** Publicación devuelta por POST /publications/get y POST /publications/default */
111
+ export declare interface Publication {
112
+ baseURL: string;
113
+ ckeditor: string;
114
+ customDomain?: string;
115
+ dateFormat: string;
116
+ description: string;
117
+ gmtRedaction: string;
118
+ gmtRedactionName: string;
119
+ gmtServer: string;
120
+ gmtServerName: string;
121
+ googleApiKey: string;
122
+ hasCategory: boolean;
123
+ hasCategoryData: string;
124
+ hasComplianceActive: boolean;
125
+ hasZone: boolean;
126
+ hasZoneJson: PublicationZoneConfig;
127
+ id: number;
128
+ imagePath: string;
129
+ /** Nombre del campo tal como viene del API */
130
+ languaje: string;
131
+ mercado: string;
132
+ name: string;
133
+ newsFormTarget: string;
134
+ permitions: PublicationPermissions;
135
+ pinedMax: string;
136
+ publication: number;
137
+ site: string;
138
+ sitio: string;
139
+ timeFormat: string;
140
+ type: string;
141
+ updateAdmin: PublicationUpdateAdmin;
142
+ }
143
+
144
+ /** Permisos de la publicación en el CMS */
145
+ export declare interface PublicationPermissions {
146
+ hasAccess: boolean;
147
+ NEWS_EDIT: boolean;
148
+ NEWS_SHARE: boolean;
149
+ [key: string]: boolean;
150
+ }
151
+
152
+ /** Cuerpo de la respuesta de POST /publications/get */
153
+ export declare interface PublicationsGetResponse {
154
+ status: string;
155
+ publications: Publication[];
156
+ }
157
+
158
+ /** Banner / actualizaciones de administración */
159
+ export declare interface PublicationUpdateAdmin {
160
+ rebootBannerDate: string;
161
+ rebootBannerDurationMin: string;
162
+ rebootBannerEnable: boolean;
163
+ updateBannerEnable: boolean;
164
+ updateBannerLink: string;
165
+ updateBannerVFSLink: boolean;
166
+ }
167
+
168
+ /** Zonas por publicación (hasZoneJson) */
169
+ export declare interface PublicationZoneConfig {
170
+ home: boolean;
171
+ section: boolean;
172
+ defaultPublication: string;
173
+ entro: number;
174
+ zones: unknown[];
175
+ }
176
+
177
+ /** Entrada de sitio devuelta por POST /sites/get */
178
+ export declare interface Site {
179
+ /** Slug del sitio; cadena vacía para la raíz */
180
+ name: string;
181
+ /** Etiqueta visible (p. ej. "Generic Site 1", "Laboratorio") */
182
+ title: string;
183
+ }
184
+
185
+ /** Resultado de combinar sitios, publicaciones y módulos disponibles */
186
+ export declare interface SitesAndPublicationsResult {
187
+ sites: SiteSection[];
188
+ modules: NavItemPermissions[];
189
+ }
190
+
191
+ export declare type SiteSection = {
192
+ title: string;
193
+ publications: Publication[];
194
+ fullWidth?: boolean;
195
+ };
196
+
197
+ /** Cuerpo de la respuesta de POST /sites/get */
198
+ export declare interface SitesGetResponse {
199
+ /** Ruta del sitio activo (p. ej. "/sites/generic1") */
200
+ root: string;
201
+ /** Misma ruta que `root`; el API la repite con esta clave */
202
+ 'root.': string;
203
+ status: string;
204
+ sites: Site[];
205
+ }
206
+
207
+ export { }
package/dist/server.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as e } from "./services-D9XCHGgK.js";
2
+ export { e as CmsCommonServices };
@@ -0,0 +1,61 @@
1
+ //#region src/lib/services/index.ts
2
+ var e = class {
3
+ props;
4
+ authentication;
5
+ constructor(e) {
6
+ this.props = e, this.authentication = e.authentication;
7
+ }
8
+ getDefaultPublication = async () => {
9
+ try {
10
+ return (await this.props.axiosApi.post("/publications/default", { authentication: this.authentication })).data;
11
+ } catch (e) {
12
+ return console.log(`[/publications/default] Error: ${e.message}`), Promise.reject(e);
13
+ }
14
+ };
15
+ getProfile = async () => {
16
+ try {
17
+ return (await this.props.axiosApi.post("/profile/get", { authentication: this.authentication })).data;
18
+ } catch (e) {
19
+ return console.error("[/profile/get]", e), Promise.reject(e);
20
+ }
21
+ };
22
+ getCountNotifications = async () => {
23
+ try {
24
+ return (await this.props.axiosApi.post("/dashboard/countNotifications", { authentication: this.authentication })).data;
25
+ } catch (e) {
26
+ return console.error("[/dashboard/countNotificatio]", e), Promise.reject(e);
27
+ }
28
+ };
29
+ getNotifications = async () => {
30
+ try {
31
+ return (await this.props.axiosApi.post("/dashboard/notification", { authentication: this.authentication })).data;
32
+ } catch (e) {
33
+ return console.error("[/dashboard/notification]", e), Promise.reject(e);
34
+ }
35
+ };
36
+ getSitesAndPublications = async () => {
37
+ try {
38
+ let [e, t, n] = await Promise.all([
39
+ this.props.axiosApi.post("/sites/get", { authentication: this.authentication }),
40
+ this.props.axiosApi.post("/publications/get", { authentication: this.authentication }),
41
+ this.props.axiosApi.post("/auth/modulesAvailable", { authentication: this.authentication })
42
+ ]);
43
+ return {
44
+ sites: e.data.sites.map((e) => ({
45
+ title: e.title,
46
+ publications: t.data.publications.filter((t) => t.site === e.name)
47
+ })).filter((e) => e.publications.length > 0),
48
+ modules: n.data.modules
49
+ };
50
+ } catch (e) {
51
+ return console.error(e), {
52
+ sites: [],
53
+ modules: []
54
+ };
55
+ }
56
+ };
57
+ };
58
+ //#endregion
59
+ export { e as t };
60
+
61
+ //# sourceMappingURL=services-D9XCHGgK.js.map
@@ -0,0 +1 @@
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,KAAK,iBAAiB,EAAM;CAC9B;CAEA,wBAAwB,YAAY;EAClC,IAAI;GAOF,QAAO,MANgB,KAAK,MAAM,SAAS,KACzC,yBACA,EACE,gBAAgB,KAAK,eACvB,CACF,GACgB;EAClB,SAAS,GAAY;GAEnB,OADA,QAAQ,IAAI,kCAAkC,EAAM,SAAS,GACtD,QAAQ,OAAO,CAAK;EAC7B;CACF;CAEA,aAAa,YAAyC;EACpD,IAAI;GAOF,QAAO,MANgB,KAAK,MAAM,SAAS,KACzC,gBACA,EACE,gBAAgB,KAAK,eACvB,CACF,GACgB;EAClB,SAAS,GAAY;GAEnB,OADA,QAAQ,MAAM,kBAAkB,CAAK,GAC9B,QAAQ,OAAO,CAAK;EAC7B;CACF;CAEA,wBAAwB,YAAiD;EACvE,IAAI;GAQF,QAAO,MANC,KAAK,MAAM,SAAS,KACxB,iCACA,EACE,gBAAgB,KAAK,eACvB,CACF,GACc;EAClB,SAAS,GAAY;GAEnB,OADA,QAAQ,MAAM,iCAAiC,CAAK,GAC7C,QAAQ,OAAO,CAAK;EAC7B;CACF;CAEA,mBAAmB,YAAgD;EACjE,IAAI;GAQF,QAAO,MANC,KAAK,MAAM,SAAS,KACxB,2BACA,EACE,gBAAgB,KAAK,eACvB,CACF,GACc;EAClB,SAAS,GAAY;GAEnB,OADA,QAAQ,MAAM,6BAA6B,CAAK,GACzC,QAAQ,OAAO,CAAK;EAC7B;CACF;CAEA,0BAA0B,YAAiD;EACzE,IAAI;GACF,IAAM,CAAC,GAAU,GAAiB,KAAc,MAAM,QAAQ,IAAI;IAChE,KAAK,MAAM,SAAS,KAAuB,cAAc,EACvD,gBAAgB,KAAK,eACvB,CAAC;IACD,KAAK,MAAM,SAAS,KAA8B,qBAAqB,EACrE,gBAAgB,KAAK,eACvB,CAAC;IACD,KAAK,MAAM,SAAS,KAClB,0BACA,EACE,gBAAgB,KAAK,eACvB,CACF;GACF,CAAC;GASD,OAAO;IACL,OAR2B,EAAS,KAAK,MAAM,KAAK,OAAU;KAC9D,OAAO,EAAK;KACZ,cAAc,EAAgB,KAAK,aAAa,QAC7C,MAAgB,EAAY,SAAS,EAAK,IAC7C;IACF,EAGS,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,6 +1,6 @@
1
1
  {
2
2
  "name": "sass-cms-template-common",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Componentes y utilidades compartidas para CMS Bluestack",
5
5
  "type": "module",
6
6
  "engines": {
@@ -21,11 +21,17 @@
21
21
  "import": "./dist/index.js",
22
22
  "default": "./dist/index.js"
23
23
  },
24
+ "./server": {
25
+ "types": "./dist/server.d.ts",
26
+ "import": "./dist/server.js",
27
+ "default": "./dist/server.js"
28
+ },
24
29
  "./package.json": "./package.json"
25
30
  },
26
31
  "scripts": {
27
32
  "dev": "vite",
28
33
  "build": "vite build",
34
+ "build:watch": "vite build --watch",
29
35
  "lint": "eslint .",
30
36
  "preview": "vite preview",
31
37
  "prepack": "npm run build"
@@ -67,6 +73,6 @@
67
73
  "vite-plugin-dts": "^4.5.4"
68
74
  },
69
75
  "dependencies": {
70
- "sass-cms-template-common": "^0.0.0"
76
+ "axios": "^1.17.0"
71
77
  }
72
78
  }