@simpleview/cms-foundation 0.0.1

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.
Files changed (51) hide show
  1. package/dist/.gitkeep +0 -0
  2. package/dist/components/Error/Error.js +15 -0
  3. package/dist/components/Error/Error.js.map +7 -0
  4. package/dist/components/Error/Error.types.js +1 -0
  5. package/dist/components/Error/Error.types.js.map +7 -0
  6. package/dist/components/Error/index.js +3 -0
  7. package/dist/components/Error/index.js.map +7 -0
  8. package/dist/components/Section/Section.js +32 -0
  9. package/dist/components/Section/Section.js.map +7 -0
  10. package/dist/components/Section/Section.types.js +1 -0
  11. package/dist/components/Section/Section.types.js.map +7 -0
  12. package/dist/components/Section/index.js +3 -0
  13. package/dist/components/Section/index.js.map +7 -0
  14. package/dist/components/Unknown/Unknown.js +32 -0
  15. package/dist/components/Unknown/Unknown.js.map +7 -0
  16. package/dist/components/Unknown/index.js +2 -0
  17. package/dist/components/Unknown/index.js.map +7 -0
  18. package/dist/components/index.js +4 -0
  19. package/dist/components/index.js.map +7 -0
  20. package/dist/contexts/ComponentMapContext.js +14 -0
  21. package/dist/contexts/ComponentMapContext.js.map +7 -0
  22. package/dist/contexts/index.js +2 -0
  23. package/dist/contexts/index.js.map +7 -0
  24. package/dist/types/build.d.ts +1 -0
  25. package/dist/types/cms.js +1 -0
  26. package/dist/types/cms.js.map +7 -0
  27. package/dist/types/index.js +2 -0
  28. package/dist/types/index.js.map +7 -0
  29. package/dist/types/src/components/Error/Error.d.ts +2 -0
  30. package/dist/types/src/components/Error/Error.types.d.ts +4 -0
  31. package/dist/types/src/components/Error/index.d.ts +2 -0
  32. package/dist/types/src/components/Section/Section.d.ts +2 -0
  33. package/dist/types/src/components/Section/Section.types.d.ts +4 -0
  34. package/dist/types/src/components/Section/index.d.ts +2 -0
  35. package/dist/types/src/components/Unknown/Unknown.d.ts +2 -0
  36. package/dist/types/src/components/Unknown/index.d.ts +1 -0
  37. package/dist/types/src/components/index.d.ts +3 -0
  38. package/dist/types/src/contexts/ComponentMapContext.d.ts +13 -0
  39. package/dist/types/src/contexts/index.d.ts +1 -0
  40. package/dist/types/src/types/cms.d.ts +173 -0
  41. package/dist/types/src/types/index.d.ts +1 -0
  42. package/dist/types/src/utils/getCmsUrl.d.ts +1 -0
  43. package/dist/types/src/utils/getPageContent.d.ts +3 -0
  44. package/dist/types/src/utils/index.d.ts +2 -0
  45. package/dist/utils/getCmsUrl.js +9 -0
  46. package/dist/utils/getCmsUrl.js.map +7 -0
  47. package/dist/utils/getPageContent.js +46 -0
  48. package/dist/utils/getPageContent.js.map +7 -0
  49. package/dist/utils/index.js +3 -0
  50. package/dist/utils/index.js.map +7 -0
  51. package/package.json +44 -0
package/dist/.gitkeep ADDED
File without changes
@@ -0,0 +1,15 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ function Error({ status, message }) {
3
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4
+ /* @__PURE__ */ jsx("h1", { children: "Error" }),
5
+ /* @__PURE__ */ jsxs("h3", { children: [
6
+ "Status Code: ",
7
+ status
8
+ ] }),
9
+ /* @__PURE__ */ jsx("p", { children: message })
10
+ ] });
11
+ }
12
+ export {
13
+ Error
14
+ };
15
+ //# sourceMappingURL=Error.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Error/Error.tsx"],
4
+ "sourcesContent": ["import type { ErrorProps } from \"./Error.types\";\r\n\r\nexport function Error({ status, message }: ErrorProps) {\r\n\treturn (\r\n\t\t<>\r\n\t\t\t<h1>Error</h1>\r\n\t\t\t<h3>Status Code: {status}</h3>\r\n\t\t\t<p>{message}</p>\r\n\t\t</>\r\n\t);\r\n}\r\n"],
5
+ "mappings": "AAIE,mBACC,KACA,YAFD;AAFK,SAAS,MAAM,EAAE,QAAQ,QAAQ,GAAe;AACtD,SACC,iCACC;AAAA,wBAAC,QAAG,mBAAK;AAAA,IACT,qBAAC,QAAG;AAAA;AAAA,MAAc;AAAA,OAAO;AAAA,IACzB,oBAAC,OAAG,mBAAQ;AAAA,KACb;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Error.types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Error";
2
+ export * from "./Error.types";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Error/index.ts"],
4
+ "sourcesContent": ["export * from \"./Error\";\r\nexport * from \"./Error.types\";\r\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { useComponentMap } from "../../contexts";
3
+ function Section({ section }) {
4
+ const map = useComponentMap();
5
+ if (!Array.isArray(section) || !section.length) {
6
+ return null;
7
+ }
8
+ return /* @__PURE__ */ jsx(Fragment, { children: section.map((civ) => {
9
+ if (civ === void 0) {
10
+ return /* @__PURE__ */ jsx(
11
+ map.Error,
12
+ {
13
+ status: 500,
14
+ message: "Is the CMS API running? I bet it isn't \u{1F609}"
15
+ },
16
+ "error"
17
+ );
18
+ }
19
+ const Component = map.civs[civ.component];
20
+ if (Component === void 0) {
21
+ return /* @__PURE__ */ jsx(map.Unknown, { ...civ }, civ.civid);
22
+ }
23
+ return (
24
+ // <DC.PreviewSectionWrapper key={civ.civid}>
25
+ /* @__PURE__ */ jsx(Component, { ...civ }, civ.civid)
26
+ );
27
+ }) });
28
+ }
29
+ export {
30
+ Section
31
+ };
32
+ //# sourceMappingURL=Section.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Section/Section.tsx"],
4
+ "sourcesContent": ["import type { SectionProps } from \"./Section.types\";\r\n\r\nimport { useComponentMap } from \"../../contexts\";\r\n\r\nexport function Section({ section }: SectionProps) {\r\n\tconst map = useComponentMap();\r\n\r\n\tif (!Array.isArray(section) || !section.length) {\r\n\t\treturn null;\r\n\t}\r\n\r\n\treturn (\r\n\t\t<>\r\n\t\t\t{section.map((civ) => {\r\n\t\t\t\tif (civ === undefined) {\r\n\t\t\t\t\treturn (\r\n\t\t\t\t\t\t<map.Error\r\n\t\t\t\t\t\t\tkey=\"error\"\r\n\t\t\t\t\t\t\tstatus={500}\r\n\t\t\t\t\t\t\tmessage=\"Is the CMS API running? I bet it isn't \uD83D\uDE09\"\r\n\t\t\t\t\t\t/>\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst Component = map.civs[civ.component];\r\n\r\n\t\t\t\tif (Component === undefined) {\r\n\t\t\t\t\treturn <map.Unknown key={civ.civid} {...civ} />;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn (\r\n\t\t\t\t\t// <DC.PreviewSectionWrapper key={civ.civid}>\r\n\t\t\t\t\t<Component key={civ.civid} {...civ} />\r\n\t\t\t\t\t// </DC.PreviewSectionWrapper >\r\n\t\t\t\t);\r\n\t\t\t})}\r\n\t\t</>\r\n\t);\r\n}\r\n"],
5
+ "mappings": "AAYE,mBAII,WAJJ;AAVF,SAAS,uBAAuB;AAEzB,SAAS,QAAQ,EAAE,QAAQ,GAAiB;AAClD,QAAM,MAAM,gBAAgB;AAE5B,MAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,CAAC,QAAQ,QAAQ;AAC/C,WAAO;AAAA,EACR;AAEA,SACC,gCACE,kBAAQ,IAAI,CAAC,QAAQ;AACrB,QAAI,QAAQ,QAAW;AACtB,aACC;AAAA,QAAC,IAAI;AAAA,QAAJ;AAAA,UAEA,QAAQ;AAAA,UACR,SAAQ;AAAA;AAAA,QAFJ;AAAA,MAGL;AAAA,IAEF;AAEA,UAAM,YAAY,IAAI,KAAK,IAAI,SAAS;AAExC,QAAI,cAAc,QAAW;AAC5B,aAAO,oBAAC,IAAI,SAAJ,EAA6B,GAAG,OAAf,IAAI,KAAgB;AAAA,IAC9C;AAEA;AAAA;AAAA,MAEC,oBAAC,aAA2B,GAAG,OAAf,IAAI,KAAgB;AAAA;AAAA,EAGtC,CAAC,GACF;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=Section.types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Section";
2
+ export * from "./Section.types";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Section/index.ts"],
4
+ "sourcesContent": ["export * from \"./Section\";\r\nexport * from \"./Section.types\";\r\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,32 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import {} from "../../types";
3
+ const Unknown = ({ civid, name, type, component }) => {
4
+ return /* @__PURE__ */ jsxs("div", { className: "bg-red-900 text-white p-6 my-5 flex flex-col rounded-lg", children: [
5
+ /* @__PURE__ */ jsxs("div", { children: [
6
+ /* @__PURE__ */ jsx("strong", { children: "Unknown Component" }),
7
+ component && /* @__PURE__ */ jsxs(Fragment, { children: [
8
+ /* @__PURE__ */ jsx("span", { children: " " }),
9
+ /* @__PURE__ */ jsxs("span", { children: [
10
+ "(",
11
+ component,
12
+ ")"
13
+ ] })
14
+ ] })
15
+ ] }),
16
+ /* @__PURE__ */ jsxs("div", { children: [
17
+ "civid: ",
18
+ civid
19
+ ] }),
20
+ /* @__PURE__ */ jsxs("div", { children: [
21
+ "name: ",
22
+ name,
23
+ " (",
24
+ type,
25
+ ")"
26
+ ] })
27
+ ] });
28
+ };
29
+ export {
30
+ Unknown
31
+ };
32
+ //# sourceMappingURL=Unknown.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Unknown/Unknown.tsx"],
4
+ "sourcesContent": ["import { type CivProps } from \"../../types\";\n\nexport const Unknown = ({ civid, name, type, component }: CivProps) => {\n\treturn (\n\t\t<div className=\"bg-red-900 text-white p-6 my-5 flex flex-col rounded-lg\">\n\t\t\t<div>\n\t\t\t\t<strong>Unknown Component</strong>\n\t\t\t\t{component && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span> </span>\n\t\t\t\t\t\t<span>({component})</span>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div>civid: {civid}</div>\n\t\t\t<div>\n\t\t\t\tname: {name} ({type})\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n"],
5
+ "mappings": "AAMI,SAEC,UAFD,KAIE,YAJF;AANJ,eAA8B;AAEvB,MAAM,UAAU,CAAC,EAAE,OAAO,MAAM,MAAM,UAAU,MAAgB;AACtE,SACC,qBAAC,SAAI,WAAU,2DACd;AAAA,yBAAC,SACA;AAAA,0BAAC,YAAO,+BAAiB;AAAA,MACxB,aACA,iCACC;AAAA,4BAAC,UAAK,eAAC;AAAA,QACP,qBAAC,UAAK;AAAA;AAAA,UAAE;AAAA,UAAU;AAAA,WAAC;AAAA,SACpB;AAAA,OAEF;AAAA,IACA,qBAAC,SAAI;AAAA;AAAA,MAAQ;AAAA,OAAM;AAAA,IACnB,qBAAC,SAAI;AAAA;AAAA,MACG;AAAA,MAAK;AAAA,MAAG;AAAA,MAAK;AAAA,OACrB;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Unknown";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Unknown/index.ts"],
4
+ "sourcesContent": ["export * from \"./Unknown\";\r\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./Error";
2
+ export * from "./Section";
3
+ export * from "./Unknown";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/components/index.ts"],
4
+ "sourcesContent": ["export * from \"./Error\";\r\nexport * from \"./Section\";\r\nexport * from \"./Unknown\";\r\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,14 @@
1
+ import { Unknown, Error } from "../components";
2
+ import { createContext, useContext } from "react";
3
+ const ComponentMapContext = createContext({
4
+ civs: {},
5
+ Error,
6
+ Unknown
7
+ });
8
+ const ComponentMapProvider = ComponentMapContext.Provider;
9
+ const useComponentMap = () => useContext(ComponentMapContext);
10
+ export {
11
+ ComponentMapProvider,
12
+ useComponentMap
13
+ };
14
+ //# sourceMappingURL=ComponentMapContext.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/contexts/ComponentMapContext.tsx"],
4
+ "sourcesContent": ["import { Unknown, Error, type ErrorProps } from \"../components\";\r\nimport type { CivProps, ComponentMap } from \"../types\";\r\nimport { createContext, useContext, type FC } from \"react\";\r\n\r\nconst ComponentMapContext = createContext<{\r\n\tcivs: ComponentMap;\r\n\tError: FC<ErrorProps>;\r\n\tUnknown: FC<CivProps>;\r\n}>({\r\n\tcivs: {},\r\n\tError,\r\n\tUnknown,\r\n});\r\n\r\nexport const ComponentMapProvider = ComponentMapContext.Provider;\r\n\r\nexport const useComponentMap = () => useContext(ComponentMapContext);\r\n"],
5
+ "mappings": "AAAA,SAAS,SAAS,aAA8B;AAEhD,SAAS,eAAe,kBAA2B;AAEnD,MAAM,sBAAsB,cAIzB;AAAA,EACF,MAAM,CAAC;AAAA,EACP;AAAA,EACA;AACD,CAAC;AAEM,MAAM,uBAAuB,oBAAoB;AAEjD,MAAM,kBAAkB,MAAM,WAAW,mBAAmB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./ComponentMapContext";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/contexts/index.ts"],
4
+ "sourcesContent": ["export * from \"./ComponentMapContext\";\r\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=cms.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./cms";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types/index.ts"],
4
+ "sourcesContent": ["export * from \"./cms\";\r\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { ErrorProps } from "./Error.types";
2
+ export declare function Error({ status, message }: ErrorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export interface ErrorProps {
2
+ status: number;
3
+ message: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Error";
2
+ export * from "./Error.types";
@@ -0,0 +1,2 @@
1
+ import type { SectionProps } from "./Section.types";
2
+ export declare function Section({ section }: SectionProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import type { CivProps } from "../../types";
2
+ export interface SectionProps {
3
+ section: CivProps[];
4
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Section";
2
+ export * from "./Section.types";
@@ -0,0 +1,2 @@
1
+ import { type CivProps } from "../../types";
2
+ export declare const Unknown: ({ civid, name, type, component }: CivProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Unknown";
@@ -0,0 +1,3 @@
1
+ export * from "./Error";
2
+ export * from "./Section";
3
+ export * from "./Unknown";
@@ -0,0 +1,13 @@
1
+ import { type ErrorProps } from "../components";
2
+ import type { CivProps, ComponentMap } from "../types";
3
+ import { type FC } from "react";
4
+ export declare const ComponentMapProvider: import("react").Provider<{
5
+ civs: ComponentMap;
6
+ Error: FC<ErrorProps>;
7
+ Unknown: FC<CivProps>;
8
+ }>;
9
+ export declare const useComponentMap: () => {
10
+ civs: ComponentMap;
11
+ Error: FC<ErrorProps>;
12
+ Unknown: FC<CivProps>;
13
+ };
@@ -0,0 +1 @@
1
+ export * from "./ComponentMapContext";
@@ -0,0 +1,173 @@
1
+ export interface PageData<T> {
2
+ body: T;
3
+ status: number;
4
+ headers: Array<{
5
+ name: string;
6
+ value: string | number;
7
+ }>;
8
+ cookies: Array<unknown>;
9
+ config: {
10
+ siteConfig: {
11
+ clientLong: string;
12
+ logo: string;
13
+ address1: string;
14
+ city: string;
15
+ state: string;
16
+ zip: string;
17
+ phone: string;
18
+ gtmId: string;
19
+ timezone: string;
20
+ latitude: number;
21
+ longitude: number;
22
+ maxRangeMiles: number;
23
+ distanceFormat: string;
24
+ assetCdnHostname: string;
25
+ urlNoSlash: string;
26
+ url: string;
27
+ cloudName: string;
28
+ gmaps: {
29
+ apiKey: string;
30
+ };
31
+ plugins: {
32
+ _sitetest: {
33
+ active: boolean;
34
+ };
35
+ ab_testing: {
36
+ active: boolean;
37
+ };
38
+ apex: {
39
+ active: boolean;
40
+ };
41
+ apis_yelp_v3: {
42
+ active: boolean;
43
+ };
44
+ asset_request: {
45
+ active: boolean;
46
+ };
47
+ assets: {
48
+ active: boolean;
49
+ };
50
+ autoresponder: {
51
+ active: boolean;
52
+ };
53
+ blog: {
54
+ active: boolean;
55
+ };
56
+ cms: {
57
+ active: boolean;
58
+ };
59
+ collections: {
60
+ active: boolean;
61
+ };
62
+ common: {
63
+ active: boolean;
64
+ };
65
+ core: {
66
+ active: boolean;
67
+ };
68
+ crm: {
69
+ active: boolean;
70
+ };
71
+ cron: {
72
+ active: boolean;
73
+ };
74
+ dam: {
75
+ active: boolean;
76
+ };
77
+ developer: {
78
+ active: boolean;
79
+ };
80
+ disqus: {
81
+ active: boolean;
82
+ };
83
+ dtn: {
84
+ active: boolean;
85
+ };
86
+ dynamic_content: {
87
+ active: boolean;
88
+ };
89
+ events: {
90
+ active: boolean;
91
+ };
92
+ googletranslate: {
93
+ active: boolean;
94
+ };
95
+ legacy: {
96
+ active: boolean;
97
+ };
98
+ listings: {
99
+ active: boolean;
100
+ };
101
+ mapexplorer: {
102
+ active: boolean;
103
+ };
104
+ mappublisher: {
105
+ active: boolean;
106
+ };
107
+ maps: {
108
+ active: boolean;
109
+ };
110
+ mediagallery: {
111
+ active: boolean;
112
+ };
113
+ nav: {
114
+ active: boolean;
115
+ };
116
+ offers: {
117
+ active: boolean;
118
+ };
119
+ reporting: {
120
+ active: boolean;
121
+ };
122
+ search: {
123
+ active: boolean;
124
+ };
125
+ social: {
126
+ active: boolean;
127
+ };
128
+ task: {
129
+ active: boolean;
130
+ };
131
+ test: {
132
+ active: boolean;
133
+ };
134
+ translations: {
135
+ active: boolean;
136
+ };
137
+ tripbuilder: {
138
+ active: boolean;
139
+ };
140
+ visitors: {
141
+ active: boolean;
142
+ };
143
+ weather: {
144
+ active: boolean;
145
+ };
146
+ };
147
+ };
148
+ env: string;
149
+ acctId: number;
150
+ site: string;
151
+ locales: Array<{
152
+ code: string;
153
+ label: string;
154
+ cmsLabel: string;
155
+ countryCode: string;
156
+ }>;
157
+ cmsUrl: string;
158
+ headless: {
159
+ api: boolean;
160
+ frontend: boolean;
161
+ };
162
+ };
163
+ token: string;
164
+ }
165
+ export interface CivProps<D = any> {
166
+ civid: string;
167
+ name: string;
168
+ type: string;
169
+ component: string;
170
+ content: Record<string, CivProps[]>;
171
+ data: D;
172
+ }
173
+ export type ComponentMap = Record<string, React.FC<CivProps>>;
@@ -0,0 +1 @@
1
+ export * from "./cms";
@@ -0,0 +1 @@
1
+ export declare function getCmsUrl(host: string): URL;
@@ -0,0 +1,3 @@
1
+ import type { CivProps, PageData } from "../types";
2
+ export type { PageData };
3
+ export declare function getPageContent(req: Request): Promise<PageData<CivProps>>;
@@ -0,0 +1,2 @@
1
+ export * from "./getCmsUrl";
2
+ export * from "./getPageContent";
@@ -0,0 +1,9 @@
1
+ const { CMS_DOMAIN } = process.env;
2
+ function getCmsUrl(host) {
3
+ const siteClient = host.split(".")[0];
4
+ return new URL(`https://${siteClient}.${CMS_DOMAIN}`);
5
+ }
6
+ export {
7
+ getCmsUrl
8
+ };
9
+ //# sourceMappingURL=getCmsUrl.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/getCmsUrl.ts"],
4
+ "sourcesContent": ["const { CMS_DOMAIN } = process.env;\r\n\r\nexport function getCmsUrl(host: string): URL {\r\n\tconst siteClient = host.split(\".\")[0];\r\n\treturn new URL(`https://${siteClient}.${CMS_DOMAIN}`);\r\n}\r\n"],
5
+ "mappings": "AAAA,MAAM,EAAE,WAAW,IAAI,QAAQ;AAExB,SAAS,UAAU,MAAmB;AAC5C,QAAM,aAAa,KAAK,MAAM,GAAG,EAAE,CAAC;AACpC,SAAO,IAAI,IAAI,WAAW,UAAU,IAAI,UAAU,EAAE;AACrD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,46 @@
1
+ import { IncomingMessage } from "http";
2
+ import { getCmsUrl } from "./getCmsUrl";
3
+ async function getPageContent(req) {
4
+ let data;
5
+ const parsed_url = new URL(req.url, "http://placeholder.com");
6
+ const cmsUrl = getCmsUrl(parsed_url.host);
7
+ if (/\.[^/]+$/.test(parsed_url.pathname)) {
8
+ cmsUrl.pathname = parsed_url.pathname + "/content.json";
9
+ } else {
10
+ cmsUrl.pathname = parsed_url.pathname + "content.json";
11
+ }
12
+ const headers = {
13
+ "Accept-Encoding": "gzip"
14
+ };
15
+ if (req.headers.get("x-real-ip")) {
16
+ headers["X-Forwarded-For"] = req.headers.get("x-real-ip") || "";
17
+ }
18
+ if (req.headers.get("x-forwarded-host")) {
19
+ headers["X-Forwarded-For"] = req.headers.get("x-forwarded-host") || "";
20
+ }
21
+ if (req.headers.get("user-agent")) {
22
+ headers["User-Agent"] = req.headers.get("user-agent") || "";
23
+ }
24
+ try {
25
+ const response = await fetch(cmsUrl.toString(), {
26
+ method: req.method,
27
+ headers,
28
+ body: JSON.stringify(data)
29
+ });
30
+ const result = await response.json();
31
+ const resultWithData = {
32
+ ...result,
33
+ headers: result.headers ?? [],
34
+ body: result.body
35
+ };
36
+ return resultWithData;
37
+ } catch (err) {
38
+ const status = err?.response?.status || 500;
39
+ const message = err?.response?.statusText || "Server Error";
40
+ throw new Error(`Status ${status}: ${message}`);
41
+ }
42
+ }
43
+ export {
44
+ getPageContent
45
+ };
46
+ //# sourceMappingURL=getPageContent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/getPageContent.ts"],
4
+ "sourcesContent": ["import { IncomingMessage } from \"http\";\r\nimport type { CivProps, PageData } from \"../types\";\r\nimport { getCmsUrl } from \"./getCmsUrl\";\r\n\r\nexport type { PageData };\r\n\r\nexport async function getPageContent(\r\n\treq: Request\r\n): Promise<PageData<CivProps>> {\r\n\tlet data: undefined | IncomingMessage;\r\n\r\n\t// if (req.method === \"POST\") {\r\n\t// \t// if we have a POST req (most likely for Page Editor preview) then\r\n\t// \t// we'll pass the incoming req stream directly on to our outgoing\r\n\t// \t// req to the CMS. We don't do anything with the data here.\r\n\t// \tdata = req;\r\n\t// }\r\n\r\n\tconst parsed_url = new URL(req.url, \"http://placeholder.com\");\r\n\tconst cmsUrl = getCmsUrl(parsed_url.host);\r\n\r\n\tif (/\\.[^/]+$/.test(parsed_url.pathname)) {\r\n\t\t// If it's a file request, we append /content.json\r\n\t\tcmsUrl.pathname = parsed_url.pathname + \"/content.json\";\r\n\t} else {\r\n\t\t// If it's not a file request, we just append content.json since it already ends with a \"/\"\r\n\t\tcmsUrl.pathname = parsed_url.pathname + \"content.json\";\r\n\t}\r\n\r\n\tconst headers: Record<string, string> = {\r\n\t\t\"Accept-Encoding\": \"gzip\",\r\n\t};\r\n\r\n\tif (req.headers.get(\"x-real-ip\")) {\r\n\t\theaders[\"X-Forwarded-For\"] = req.headers.get(\"x-real-ip\") || \"\";\r\n\t}\r\n\tif (req.headers.get(\"x-forwarded-host\")) {\r\n\t\theaders[\"X-Forwarded-For\"] = req.headers.get(\"x-forwarded-host\") || \"\";\r\n\t}\r\n\tif (req.headers.get(\"user-agent\")) {\r\n\t\theaders[\"User-Agent\"] = req.headers.get(\"user-agent\") || \"\";\r\n\t}\r\n\r\n\ttry {\r\n\t\tconst response = await fetch(cmsUrl.toString(), {\r\n\t\t\tmethod: req.method,\r\n\t\t\theaders,\r\n\t\t\tbody: JSON.stringify(data),\r\n\t\t});\r\n\t\tconst result: PageData<CivProps> = await response.json();\r\n\r\n\t\tconst resultWithData = {\r\n\t\t\t...result,\r\n\t\t\theaders: result.headers ?? [],\r\n\t\t\tbody: result.body,\r\n\t\t};\r\n\r\n\t\treturn resultWithData;\r\n\t} catch (err: unknown) {\r\n\t\tconst status =\r\n\t\t\t(err as { response?: { status?: number } })?.response?.status ||\r\n\t\t\t500;\r\n\t\tconst message =\r\n\t\t\t(err as { response?: { statusText?: string } })?.response\r\n\t\t\t\t?.statusText || \"Server Error\";\r\n\t\tthrow new Error(`Status ${status}: ${message}`);\r\n\t}\r\n}\r\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAEhC,SAAS,iBAAiB;AAI1B,eAAsB,eACrB,KAC8B;AAC9B,MAAI;AASJ,QAAM,aAAa,IAAI,IAAI,IAAI,KAAK,wBAAwB;AAC5D,QAAM,SAAS,UAAU,WAAW,IAAI;AAExC,MAAI,WAAW,KAAK,WAAW,QAAQ,GAAG;AAEzC,WAAO,WAAW,WAAW,WAAW;AAAA,EACzC,OAAO;AAEN,WAAO,WAAW,WAAW,WAAW;AAAA,EACzC;AAEA,QAAM,UAAkC;AAAA,IACvC,mBAAmB;AAAA,EACpB;AAEA,MAAI,IAAI,QAAQ,IAAI,WAAW,GAAG;AACjC,YAAQ,iBAAiB,IAAI,IAAI,QAAQ,IAAI,WAAW,KAAK;AAAA,EAC9D;AACA,MAAI,IAAI,QAAQ,IAAI,kBAAkB,GAAG;AACxC,YAAQ,iBAAiB,IAAI,IAAI,QAAQ,IAAI,kBAAkB,KAAK;AAAA,EACrE;AACA,MAAI,IAAI,QAAQ,IAAI,YAAY,GAAG;AAClC,YAAQ,YAAY,IAAI,IAAI,QAAQ,IAAI,YAAY,KAAK;AAAA,EAC1D;AAEA,MAAI;AACH,UAAM,WAAW,MAAM,MAAM,OAAO,SAAS,GAAG;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC1B,CAAC;AACD,UAAM,SAA6B,MAAM,SAAS,KAAK;AAEvD,UAAM,iBAAiB;AAAA,MACtB,GAAG;AAAA,MACH,SAAS,OAAO,WAAW,CAAC;AAAA,MAC5B,MAAM,OAAO;AAAA,IACd;AAEA,WAAO;AAAA,EACR,SAAS,KAAc;AACtB,UAAM,SACJ,KAA4C,UAAU,UACvD;AACD,UAAM,UACJ,KAAgD,UAC9C,cAAc;AAClB,UAAM,IAAI,MAAM,UAAU,MAAM,KAAK,OAAO,EAAE;AAAA,EAC/C;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./getCmsUrl";
2
+ export * from "./getPageContent";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/index.ts"],
4
+ "sourcesContent": ["export * from \"./getCmsUrl\";\r\nexport * from \"./getPageContent\";\r\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@simpleview/cms-foundation",
3
+ "version": "0.0.1",
4
+ "description": "Provides helper types and components to assist when working with Granicus CMS Reactor.",
5
+ "packageManager": "yarn@4.6.0+sha224.acd0786f07ffc6c933940eb65fc1d627131ddf5455bddcc295dc90fd",
6
+ "scripts": {
7
+ "build": "tsx build",
8
+ "start": "tsx build --watch"
9
+ },
10
+ "exports": {
11
+ "./types": {
12
+ "types": "./dist/types/types/index.d.ts"
13
+ },
14
+ "./utils": {
15
+ "import": "./dist/utils/index.js",
16
+ "types": "./dist/types/utils/index.d.ts"
17
+ },
18
+ "./contexts": {
19
+ "import": "./dist/contexts/index.js",
20
+ "types": "./dist/types/contexts/index.d.ts"
21
+ },
22
+ "./components": {
23
+ "import": "./dist/components/index.js",
24
+ "types": "./dist/types/components/index.d.ts"
25
+ }
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^24.1.0",
29
+ "@types/react": "^19",
30
+ "esbuild": "^0.25.8",
31
+ "tsx": "^4.20.3",
32
+ "typescript": "^5.8.3"
33
+ },
34
+ "dependencies": {
35
+ "react": "^19.1.1"
36
+ },
37
+ "files": [
38
+ "dist/"
39
+ ],
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/simpleviewinc/cms-reactor.git"
43
+ }
44
+ }