@antlur/backstage 1.0.8 → 1.0.10

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 (225) hide show
  1. package/dist/cjs/client.js +86 -0
  2. package/dist/cjs/components/json-ld.js +8 -0
  3. package/dist/cjs/config.js +23 -0
  4. package/dist/cjs/constants/google-events.js +15 -0
  5. package/dist/cjs/endpoints/alerts.js +8 -0
  6. package/dist/cjs/endpoints/events.js +21 -0
  7. package/dist/cjs/endpoints/locations.js +24 -0
  8. package/dist/cjs/endpoints/menus.js +27 -0
  9. package/dist/cjs/endpoints/navigation.js +28 -0
  10. package/dist/cjs/endpoints/pages.js +23 -0
  11. package/dist/cjs/endpoints/press.js +8 -0
  12. package/dist/cjs/endpoints/website.js +8 -0
  13. package/dist/cjs/index.js +35 -0
  14. package/dist/cjs/types/alert.js +2 -0
  15. package/dist/cjs/types/api.js +2 -0
  16. package/dist/cjs/types/event.js +2 -0
  17. package/dist/cjs/types/index.js +29 -0
  18. package/dist/cjs/types/location.js +2 -0
  19. package/dist/cjs/types/media-item.js +2 -0
  20. package/dist/cjs/types/menu-category-item.js +2 -0
  21. package/dist/cjs/types/menu-category.js +2 -0
  22. package/dist/cjs/types/menu-item.js +2 -0
  23. package/dist/cjs/types/menu.js +2 -0
  24. package/dist/cjs/types/navigation.js +2 -0
  25. package/dist/cjs/types/page.js +2 -0
  26. package/dist/cjs/types/press.js +2 -0
  27. package/dist/cjs/types/website.js +2 -0
  28. package/dist/cjs/util/event.js +70 -0
  29. package/dist/cjs/util/gtag.js +14 -0
  30. package/dist/cjs/util/imgproxy-loader.js +14 -0
  31. package/dist/cjs/util/publishing.js +6 -0
  32. package/dist/cjs/util/special-hours.js +23 -0
  33. package/dist/{client.d.ts → esm/client.d.ts} +1 -0
  34. package/dist/esm/client.d.ts.map +1 -0
  35. package/dist/esm/components/json-ld.d.ts +7 -0
  36. package/dist/esm/components/json-ld.d.ts.map +1 -0
  37. package/dist/esm/components/json-ld.js +5 -0
  38. package/dist/{config.d.ts → esm/config.d.ts} +1 -0
  39. package/dist/esm/config.d.ts.map +1 -0
  40. package/dist/{constants → esm/constants}/google-events.d.ts +1 -0
  41. package/dist/esm/constants/google-events.d.ts.map +1 -0
  42. package/dist/{endpoints → esm/endpoints}/alerts.d.ts +1 -0
  43. package/dist/esm/endpoints/alerts.d.ts.map +1 -0
  44. package/dist/{endpoints → esm/endpoints}/events.d.ts +1 -0
  45. package/dist/esm/endpoints/events.d.ts.map +1 -0
  46. package/dist/{endpoints → esm/endpoints}/locations.d.ts +1 -0
  47. package/dist/esm/endpoints/locations.d.ts.map +1 -0
  48. package/dist/{endpoints → esm/endpoints}/menus.d.ts +1 -0
  49. package/dist/esm/endpoints/menus.d.ts.map +1 -0
  50. package/dist/{endpoints → esm/endpoints}/navigation.d.ts +1 -0
  51. package/dist/esm/endpoints/navigation.d.ts.map +1 -0
  52. package/dist/{endpoints → esm/endpoints}/pages.d.ts +1 -0
  53. package/dist/esm/endpoints/pages.d.ts.map +1 -0
  54. package/dist/{endpoints → esm/endpoints}/press.d.ts +1 -0
  55. package/dist/esm/endpoints/press.d.ts.map +1 -0
  56. package/dist/{endpoints → esm/endpoints}/website.d.ts +1 -0
  57. package/dist/esm/endpoints/website.d.ts.map +1 -0
  58. package/dist/{index.d.ts → esm/index.d.ts} +1 -0
  59. package/dist/esm/index.d.ts.map +1 -0
  60. package/dist/{types → esm/types}/alert.d.ts +1 -0
  61. package/dist/esm/types/alert.d.ts.map +1 -0
  62. package/dist/{types → esm/types}/api.d.ts +1 -0
  63. package/dist/esm/types/api.d.ts.map +1 -0
  64. package/dist/{types → esm/types}/event.d.ts +1 -0
  65. package/dist/esm/types/event.d.ts.map +1 -0
  66. package/dist/esm/types/index.d.ts +14 -0
  67. package/dist/esm/types/index.d.ts.map +1 -0
  68. package/dist/{types → esm/types}/location.d.ts +3 -0
  69. package/dist/esm/types/location.d.ts.map +1 -0
  70. package/dist/{types → esm/types}/media-item.d.ts +1 -0
  71. package/dist/esm/types/media-item.d.ts.map +1 -0
  72. package/dist/{types → esm/types}/menu-category-item.d.ts +1 -0
  73. package/dist/esm/types/menu-category-item.d.ts.map +1 -0
  74. package/dist/{types → esm/types}/menu-category.d.ts +1 -0
  75. package/dist/esm/types/menu-category.d.ts.map +1 -0
  76. package/dist/{types → esm/types}/menu-item.d.ts +1 -0
  77. package/dist/esm/types/menu-item.d.ts.map +1 -0
  78. package/dist/{types → esm/types}/menu.d.ts +1 -0
  79. package/dist/esm/types/menu.d.ts.map +1 -0
  80. package/dist/{types → esm/types}/navigation.d.ts +1 -0
  81. package/dist/esm/types/navigation.d.ts.map +1 -0
  82. package/dist/{types → esm/types}/page.d.ts +1 -0
  83. package/dist/esm/types/page.d.ts.map +1 -0
  84. package/dist/{types → esm/types}/press.d.ts +1 -0
  85. package/dist/esm/types/press.d.ts.map +1 -0
  86. package/dist/{types → esm/types}/website.d.ts +2 -0
  87. package/dist/esm/types/website.d.ts.map +1 -0
  88. package/dist/esm/util/event.d.ts +8 -0
  89. package/dist/esm/util/event.d.ts.map +1 -0
  90. package/dist/esm/util/event.js +63 -0
  91. package/dist/esm/util/gtag.d.ts +23 -0
  92. package/dist/esm/util/gtag.d.ts.map +1 -0
  93. package/dist/esm/util/gtag.js +10 -0
  94. package/dist/esm/util/imgproxy-loader.d.ts +9 -0
  95. package/dist/esm/util/imgproxy-loader.d.ts.map +1 -0
  96. package/dist/esm/util/imgproxy-loader.js +11 -0
  97. package/dist/esm/util/publishing.d.ts +2 -0
  98. package/dist/esm/util/publishing.d.ts.map +1 -0
  99. package/dist/esm/util/publishing.js +3 -0
  100. package/dist/esm/util/special-hours.d.ts +3 -0
  101. package/dist/esm/util/special-hours.d.ts.map +1 -0
  102. package/dist/esm/util/special-hours.js +20 -0
  103. package/dist/types/client.d.ts +14 -0
  104. package/dist/types/client.d.ts.map +1 -0
  105. package/dist/types/components/json-ld.d.ts +7 -0
  106. package/dist/types/components/json-ld.d.ts.map +1 -0
  107. package/dist/types/config.d.ts +10 -0
  108. package/dist/types/config.d.ts.map +1 -0
  109. package/dist/types/constants/google-events.d.ts +13 -0
  110. package/dist/types/constants/google-events.d.ts.map +1 -0
  111. package/dist/types/endpoints/alerts.d.ts +3 -0
  112. package/dist/types/endpoints/alerts.d.ts.map +1 -0
  113. package/dist/types/endpoints/events.d.ts +5 -0
  114. package/dist/types/endpoints/events.d.ts.map +1 -0
  115. package/dist/types/endpoints/locations.d.ts +4 -0
  116. package/dist/types/endpoints/locations.d.ts.map +1 -0
  117. package/dist/types/endpoints/menus.d.ts +5 -0
  118. package/dist/types/endpoints/menus.d.ts.map +1 -0
  119. package/dist/types/endpoints/navigation.d.ts +5 -0
  120. package/dist/types/endpoints/navigation.d.ts.map +1 -0
  121. package/dist/types/endpoints/pages.d.ts +6 -0
  122. package/dist/types/endpoints/pages.d.ts.map +1 -0
  123. package/dist/types/endpoints/press.d.ts +3 -0
  124. package/dist/types/endpoints/press.d.ts.map +1 -0
  125. package/dist/types/endpoints/website.d.ts +3 -0
  126. package/dist/types/endpoints/website.d.ts.map +1 -0
  127. package/dist/types/index.d.ts +12 -13
  128. package/dist/types/index.d.ts.map +1 -0
  129. package/dist/types/types/alert.d.ts +12 -0
  130. package/dist/types/types/alert.d.ts.map +1 -0
  131. package/dist/types/types/api.d.ts +12 -0
  132. package/dist/types/types/api.d.ts.map +1 -0
  133. package/dist/types/types/event.d.ts +14 -0
  134. package/dist/types/types/event.d.ts.map +1 -0
  135. package/dist/types/types/index.d.ts +14 -0
  136. package/dist/types/types/index.d.ts.map +1 -0
  137. package/dist/types/types/location.d.ts +70 -0
  138. package/dist/types/types/location.d.ts.map +1 -0
  139. package/dist/types/types/media-item.d.ts +11 -0
  140. package/dist/types/types/media-item.d.ts.map +1 -0
  141. package/dist/types/types/menu-category-item.d.ts +18 -0
  142. package/dist/types/types/menu-category-item.d.ts.map +1 -0
  143. package/dist/types/types/menu-category.d.ts +15 -0
  144. package/dist/types/types/menu-category.d.ts.map +1 -0
  145. package/dist/types/types/menu-item.d.ts +16 -0
  146. package/dist/types/types/menu-item.d.ts.map +1 -0
  147. package/dist/types/types/menu.d.ts +13 -0
  148. package/dist/types/types/menu.d.ts.map +1 -0
  149. package/dist/types/types/navigation.d.ts +17 -0
  150. package/dist/types/types/navigation.d.ts.map +1 -0
  151. package/dist/types/types/page.d.ts +22 -0
  152. package/dist/types/types/page.d.ts.map +1 -0
  153. package/dist/types/types/press.d.ts +13 -0
  154. package/dist/types/types/press.d.ts.map +1 -0
  155. package/dist/types/types/website.d.ts +69 -0
  156. package/dist/types/types/website.d.ts.map +1 -0
  157. package/dist/types/util/event.d.ts +8 -0
  158. package/dist/types/util/event.d.ts.map +1 -0
  159. package/dist/types/util/gtag.d.ts +23 -0
  160. package/dist/types/util/gtag.d.ts.map +1 -0
  161. package/dist/types/util/imgproxy-loader.d.ts +9 -0
  162. package/dist/types/util/imgproxy-loader.d.ts.map +1 -0
  163. package/dist/types/util/publishing.d.ts +2 -0
  164. package/dist/types/util/publishing.d.ts.map +1 -0
  165. package/dist/types/util/special-hours.d.ts +3 -0
  166. package/dist/types/util/special-hours.d.ts.map +1 -0
  167. package/package.json +46 -12
  168. package/src/client.ts +97 -0
  169. package/src/components/json-ld.tsx +9 -0
  170. package/src/config.ts +31 -0
  171. package/src/constants/google-events.ts +13 -0
  172. package/src/endpoints/alerts.ts +7 -0
  173. package/src/endpoints/events.ts +20 -0
  174. package/src/endpoints/locations.ts +25 -0
  175. package/src/endpoints/menus.ts +30 -0
  176. package/src/endpoints/navigation.ts +34 -0
  177. package/src/endpoints/pages.ts +23 -0
  178. package/src/endpoints/press.ts +7 -0
  179. package/src/endpoints/website.ts +7 -0
  180. package/src/index.ts +18 -0
  181. package/src/types/alert.ts +11 -0
  182. package/src/types/api.ts +12 -0
  183. package/src/types/event.ts +14 -0
  184. package/src/types/index.ts +13 -0
  185. package/src/types/location.ts +69 -0
  186. package/src/types/media-item.ts +10 -0
  187. package/src/types/menu-category-item.ts +18 -0
  188. package/src/types/menu-category.ts +15 -0
  189. package/src/types/menu-item.ts +15 -0
  190. package/src/types/menu.ts +12 -0
  191. package/src/types/navigation.ts +17 -0
  192. package/src/types/page.ts +24 -0
  193. package/src/types/press.ts +13 -0
  194. package/src/types/website.ts +76 -0
  195. package/src/util/event.ts +77 -0
  196. package/src/util/gtag.ts +40 -0
  197. package/src/util/imgproxy-loader.ts +22 -0
  198. package/src/util/publishing.ts +3 -0
  199. package/src/util/special-hours.ts +24 -0
  200. /package/dist/{client.js → esm/client.js} +0 -0
  201. /package/dist/{config.js → esm/config.js} +0 -0
  202. /package/dist/{constants → esm/constants}/google-events.js +0 -0
  203. /package/dist/{endpoints → esm/endpoints}/alerts.js +0 -0
  204. /package/dist/{endpoints → esm/endpoints}/events.js +0 -0
  205. /package/dist/{endpoints → esm/endpoints}/locations.js +0 -0
  206. /package/dist/{endpoints → esm/endpoints}/menus.js +0 -0
  207. /package/dist/{endpoints → esm/endpoints}/navigation.js +0 -0
  208. /package/dist/{endpoints → esm/endpoints}/pages.js +0 -0
  209. /package/dist/{endpoints → esm/endpoints}/press.js +0 -0
  210. /package/dist/{endpoints → esm/endpoints}/website.js +0 -0
  211. /package/dist/{index.js → esm/index.js} +0 -0
  212. /package/dist/{types → esm/types}/alert.js +0 -0
  213. /package/dist/{types → esm/types}/api.js +0 -0
  214. /package/dist/{types → esm/types}/event.js +0 -0
  215. /package/dist/{types → esm/types}/index.js +0 -0
  216. /package/dist/{types → esm/types}/location.js +0 -0
  217. /package/dist/{types → esm/types}/media-item.js +0 -0
  218. /package/dist/{types → esm/types}/menu-category-item.js +0 -0
  219. /package/dist/{types → esm/types}/menu-category.js +0 -0
  220. /package/dist/{types → esm/types}/menu-item.js +0 -0
  221. /package/dist/{types → esm/types}/menu.js +0 -0
  222. /package/dist/{types → esm/types}/navigation.js +0 -0
  223. /package/dist/{types → esm/types}/page.js +0 -0
  224. /package/dist/{types → esm/types}/press.js +0 -0
  225. /package/dist/{types → esm/types}/website.js +0 -0
package/src/config.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { AxiosError } from "axios";
2
+
3
+ const ROOT = process.cwd();
4
+ const CONFIG_PATH = process.env.BACKSTAGE_CONFIG_PATH || "./backstage.config";
5
+ const DEFAULT_BASE_URL = "https://bckstg.app/api";
6
+
7
+ export interface BackstageUserConfig {
8
+ accountId?: string | undefined;
9
+ token?: string | undefined;
10
+ baseURL?: string;
11
+ onError?: (error: AxiosError) => void;
12
+ }
13
+
14
+ let globalConfig: BackstageUserConfig = {
15
+ baseURL: process.env.BACKSTAGE_API_URL ?? DEFAULT_BASE_URL,
16
+ token: process.env.BACKSTAGE_API_KEY ?? undefined,
17
+ accountId: process.env.BACKSTAGE_ACCOUNT_ID ?? undefined,
18
+ };
19
+
20
+ export function defineConfig(config: BackstageUserConfig): BackstageUserConfig {
21
+ globalConfig = {
22
+ ...globalConfig,
23
+ ...config,
24
+ };
25
+ return globalConfig;
26
+ }
27
+
28
+ export function getGlobalConfig(): BackstageUserConfig {
29
+ // read the config from the project root
30
+ return globalConfig;
31
+ }
@@ -0,0 +1,13 @@
1
+ export const GAEvents = {
2
+ CLICK_TO_MAP: "click_to_map",
3
+ CLICK_TO_CALL: "click_to_call",
4
+ CLICK_TO_SOCIAL: "click_to_social",
5
+ CLICK_TO_WAITLIST: "click_to_waitlist",
6
+ FIND_LOCATION: "find_location",
7
+ CLICK_TO_ORDER: "click_to_order",
8
+ };
9
+
10
+ export const GALocations = {
11
+ LOCATION_CARD: "location_card",
12
+ TOPBAR: "topbar",
13
+ };
@@ -0,0 +1,7 @@
1
+ import { client } from "../client";
2
+ import { ApiCollectionResponse, Alert } from "../types";
3
+
4
+ export async function getAlerts() {
5
+ const { data } = await client().get<ApiCollectionResponse<Alert>>("/alerts");
6
+ return data;
7
+ }
@@ -0,0 +1,20 @@
1
+ import { client } from "../client";
2
+ import { ApiCollectionResponse, Event } from "../types";
3
+
4
+ export async function getEvents(): Promise<Event[]> {
5
+ const res = await client().get<ApiCollectionResponse<Event>>("/events");
6
+ const pages = res.data;
7
+ return pages;
8
+ }
9
+
10
+ export async function getEvent(id: string): Promise<Event> {
11
+ const res = await client().get<ApiCollectionResponse<Event>>("/events" + "?filter[id]=" + id);
12
+ const pages = res.data?.[0];
13
+ return pages;
14
+ }
15
+
16
+ export async function getEventBySlug(slug: string): Promise<Event> {
17
+ const res = await client().get<ApiCollectionResponse<Event>>("/events" + "?filter[slug]=" + slug);
18
+ const pages = res.data?.[0];
19
+ return pages;
20
+ }
@@ -0,0 +1,25 @@
1
+ import { client } from "../client";
2
+ import { ApiCollectionResponse, Location } from "../types";
3
+
4
+ export async function getLocations(): Promise<Location[]> {
5
+ const res = await client().get<ApiCollectionResponse<Location>>("/locations");
6
+ let locations = res.data;
7
+ locations = locations.sort((a: any, b: any) => {
8
+ if (a.name < b.name) {
9
+ return -1;
10
+ }
11
+ return 1;
12
+ });
13
+ return locations;
14
+ }
15
+
16
+ export async function getLocationBySlug(slug: string) {
17
+ const res = await client().get<ApiCollectionResponse<Location>>(`/locations?filter[slug]=${slug}`);
18
+ const data = res.data;
19
+
20
+ if (Array.isArray(data) && data.length > 0) {
21
+ return data[0];
22
+ }
23
+
24
+ return data;
25
+ }
@@ -0,0 +1,30 @@
1
+ import { client } from "../client";
2
+ import { ApiCollectionResponse, Menu } from "../types";
3
+
4
+ export async function getMenus(): Promise<Menu[]> {
5
+ const res = await client().get<ApiCollectionResponse<Menu>>("/menus");
6
+ const menus = res.data;
7
+ return menus;
8
+ }
9
+
10
+ export async function getMenu(id: string) {
11
+ const res = await client().get<ApiCollectionResponse<Menu>>(`/menus?filter[id]=${id}&include=categories.items`);
12
+ const data = res.data;
13
+
14
+ if (Array.isArray(data) && data.length > 0) {
15
+ return data[0];
16
+ }
17
+
18
+ return data;
19
+ }
20
+
21
+ export async function getMenuBySlug(slug: string) {
22
+ const res = await client().get<ApiCollectionResponse<Menu>>(`/menus?filter[slug]=${slug}&include=categories.items`);
23
+ const data = res.data;
24
+
25
+ if (Array.isArray(data) && data.length > 0) {
26
+ return data[0];
27
+ }
28
+
29
+ return data;
30
+ }
@@ -0,0 +1,34 @@
1
+ import { client } from "../client";
2
+ import { ApiSingleResponse, ApiCollectionResponse, Navigation } from "../types";
3
+
4
+ export async function getDefaultNavigation(): Promise<Navigation> {
5
+ const navigations = await getNavigations();
6
+ return navigations[0];
7
+ }
8
+
9
+ export async function getNavigations(): Promise<Navigation[]> {
10
+ const res = await client().get<ApiCollectionResponse<Navigation>>("/navigations");
11
+ const navigations = res.data;
12
+
13
+ return Promise.all(
14
+ navigations.map(async (navigation: any) => {
15
+ const res = await client().get<ApiCollectionResponse<Navigation>>("/navigations/" + navigation.id);
16
+ return res.data[0];
17
+ })
18
+ );
19
+ }
20
+
21
+ export async function getNavigation(id: string): Promise<Navigation> {
22
+ const res = await client().get<ApiSingleResponse<Navigation>>(`/navigations/${id}`);
23
+ const navigation = res.data;
24
+
25
+ const topLevelItems = navigation.items.filter((item: any) => item.parent_id === null);
26
+
27
+ topLevelItems.forEach((item: any) => {
28
+ item.children = navigation.items.filter((child: any) => child.parent_id === item.id);
29
+ });
30
+
31
+ navigation.items = topLevelItems;
32
+
33
+ return navigation;
34
+ }
@@ -0,0 +1,23 @@
1
+ import { client } from "../client";
2
+ import { Page } from "../types/page";
3
+ import { ApiCollectionResponse } from "../types/api";
4
+
5
+ export async function getPage(slug: string): Promise<Page> {
6
+ const res = await client().get<ApiCollectionResponse<Page>>(`/pages/?filter[slug]=${slug}`);
7
+ return res.data[0];
8
+ }
9
+
10
+ export async function getPages() {
11
+ const { data } = await client().get<ApiCollectionResponse<Page>>("/pages");
12
+ return data;
13
+ }
14
+
15
+ export async function getHomePage() {
16
+ const res = await client().get<ApiCollectionResponse<Page>>("/pages?filter[slug]=/");
17
+ return res.data[0];
18
+ }
19
+
20
+ export async function getPageBySlug(slug: string) {
21
+ const res = await client().get<ApiCollectionResponse<Page>>("/pages?filter[slug]=" + slug);
22
+ return res.data[0];
23
+ }
@@ -0,0 +1,7 @@
1
+ import { client } from "../client";
2
+ import { ApiCollectionResponse, Press } from "../types";
3
+
4
+ export async function getPress(): Promise<Press[]> {
5
+ const { data } = await client().get<ApiCollectionResponse<Press>>("/press");
6
+ return data;
7
+ }
@@ -0,0 +1,7 @@
1
+ import { client } from "../client";
2
+ import { ApiCollectionResponse, Website } from "../types";
3
+
4
+ export async function getWebsite(): Promise<Website> {
5
+ const res = await client().get<ApiCollectionResponse<Website>>("/websites");
6
+ return res.data[0];
7
+ }
package/src/index.ts ADDED
@@ -0,0 +1,18 @@
1
+ // Re-export config
2
+ export { defineConfig, getGlobalConfig } from "./config";
3
+
4
+ // Re-export the client class
5
+ export { BackstageClient } from "./client";
6
+
7
+ // Re-export endpoints
8
+ export * from "./endpoints/alerts";
9
+ export * from "./endpoints/events";
10
+ export * from "./endpoints/locations";
11
+ export * from "./endpoints/menus";
12
+ export * from "./endpoints/navigation";
13
+ export * from "./endpoints/pages";
14
+ export * from "./endpoints/press";
15
+ export * from "./endpoints/website";
16
+
17
+ // Re-export domain types
18
+ export * from "./types";
@@ -0,0 +1,11 @@
1
+ export interface Alert {
2
+ id: string;
3
+ title: string;
4
+ type: string;
5
+ is_global: boolean;
6
+ published: boolean;
7
+ pages: {
8
+ id: string;
9
+ slug: string;
10
+ }[];
11
+ }
@@ -0,0 +1,12 @@
1
+ export interface ApiCollectionResponse<T> {
2
+ data: T[];
3
+ meta: {
4
+ current_page: number;
5
+ from: number;
6
+ last_page: number;
7
+ };
8
+ }
9
+
10
+ export interface ApiSingleResponse<T> {
11
+ data: T;
12
+ }
@@ -0,0 +1,14 @@
1
+ import { MediaItem } from "./media-item";
2
+
3
+ export interface Event {
4
+ id: number;
5
+ title: string;
6
+ short_description: string;
7
+ description: string;
8
+ start_time: string; // or Date if the date is being converted before being used in TypeScript
9
+ end_time: string; // or Date if the date is being converted before being used in TypeScript
10
+ timezone: string;
11
+ cover_media_id: number;
12
+ cover_media: MediaItem; // Replace 'any' with the actual type of the cover_media
13
+ account_id: number;
14
+ }
@@ -0,0 +1,13 @@
1
+ export * from "./alert";
2
+ export * from "./api";
3
+ export * from "./event";
4
+ export * from "./location";
5
+ export * from "./media-item";
6
+ export * from "./menu-category-item";
7
+ export * from "./menu-category";
8
+ export * from "./menu-item";
9
+ export * from "./menu";
10
+ export * from "./navigation";
11
+ export * from "./page";
12
+ export * from "./press";
13
+ export * from "./website";
@@ -0,0 +1,69 @@
1
+ export interface Location {
2
+ id: string;
3
+ account_id: string;
4
+ google_my_business_id: string | null;
5
+ name: string;
6
+ slug: string | null;
7
+ description: string | null;
8
+ featured_media_id: number;
9
+ address: string;
10
+ address2: string;
11
+ city: string;
12
+ state: string;
13
+ zip: string;
14
+ map_link: string | null;
15
+ map_embed: string | null;
16
+ latitude: number | null;
17
+ longitude: number | null;
18
+ phone: string;
19
+ email: string;
20
+ timezone: string | null;
21
+ hours: {
22
+ day: string;
23
+ openTime: string;
24
+ closeTime: string;
25
+ open24Hours: boolean;
26
+ closed24Hours: boolean;
27
+ notes: string;
28
+ }[];
29
+ special_hours: {
30
+ id: string;
31
+ date: string;
32
+ openTime: string;
33
+ closeTime: string;
34
+ open24Hours: boolean;
35
+ closed24Hours: boolean;
36
+ notes: string;
37
+ }[];
38
+ ordering_links: {
39
+ service: string;
40
+ url: string;
41
+ }[];
42
+ delivery_links: {
43
+ service: string;
44
+ url: string;
45
+ }[];
46
+ reservation_links: {
47
+ service: string;
48
+ url: string;
49
+ }[];
50
+ waitlist_links: {
51
+ service: string;
52
+ url: string;
53
+ }[];
54
+ loyalty_url: string | null;
55
+ created_at: string;
56
+ updated_at: string;
57
+ featured_media: {
58
+ id: number;
59
+ file_name: string;
60
+ url: string;
61
+ transform_url: string;
62
+ path: string;
63
+ width: number;
64
+ height: number;
65
+ alt: string;
66
+ };
67
+ status: string;
68
+ status_text: string;
69
+ }
@@ -0,0 +1,10 @@
1
+ export interface MediaItem {
2
+ id: string;
3
+ file_name: string;
4
+ url: string;
5
+ transform_url: string;
6
+ path: string;
7
+ width: number;
8
+ height: number;
9
+ alt: string;
10
+ }
@@ -0,0 +1,18 @@
1
+ import { MenuItem } from "./menu-item";
2
+
3
+ export interface MenuCategoryItem {
4
+ id: string;
5
+ menu_category_id: string;
6
+ menu_item_id: string;
7
+ title: string;
8
+ post_title: string | null;
9
+ subtitle: string | null;
10
+ description: string | null;
11
+ price: number | null;
12
+ order: number;
13
+ price2: number | null;
14
+ image_id: string | null;
15
+ created_at: string;
16
+ updated_at: string;
17
+ menu_item: MenuItem;
18
+ }
@@ -0,0 +1,15 @@
1
+ import { MenuCategoryItem } from "./menu-category-item";
2
+
3
+ export interface MenuCategory {
4
+ id: string;
5
+ title: string;
6
+ subtitle: string | null;
7
+ description: string | null;
8
+ after_description: string | null;
9
+ column_count: number | null;
10
+ menu_id: string;
11
+ order: number;
12
+ created_at: string;
13
+ updated_at: string;
14
+ items: MenuCategoryItem[];
15
+ }
@@ -0,0 +1,15 @@
1
+ export interface MenuItem {
2
+ id: string;
3
+ account_id: string;
4
+ title: string;
5
+ post_title: string | null;
6
+ subtitle: string | null;
7
+ description: string | null;
8
+ price: number | null;
9
+ price2: number | null;
10
+ image_id: string | null;
11
+ type: string | null;
12
+ overrides: string | null;
13
+ created_at: string;
14
+ updated_at: string;
15
+ }
@@ -0,0 +1,12 @@
1
+ export interface Menu {
2
+ id: string;
3
+ slug: string;
4
+ is_default: boolean;
5
+ title: string;
6
+ subtitle: string | null;
7
+ account_id: string;
8
+ pdf_url: string | null;
9
+ categories: string[]; // You can replace this with the actual type for categories if needed
10
+ created_at: string;
11
+ updated_at: string;
12
+ }
@@ -0,0 +1,17 @@
1
+ export interface NavigationItem {
2
+ id: string;
3
+ text: string;
4
+ url: string;
5
+ html: string;
6
+ new_window: boolean;
7
+ type: string;
8
+ style: string;
9
+ parent_id: string;
10
+ children: NavigationItem[];
11
+ }
12
+
13
+ export interface Navigation {
14
+ id: string;
15
+ name: string;
16
+ items: NavigationItem[];
17
+ }
@@ -0,0 +1,24 @@
1
+ export interface Block {
2
+ id: string;
3
+ block: string;
4
+ data: any;
5
+ }
6
+
7
+ export interface Settings {
8
+ background_color: string;
9
+ }
10
+
11
+ export interface Meta {
12
+ title: string;
13
+ description: string;
14
+ }
15
+
16
+ export interface Page {
17
+ id: string;
18
+ title: string;
19
+ slug: string;
20
+ blocks: Block[];
21
+ settings: Settings;
22
+ meta: Meta;
23
+ is_home: boolean;
24
+ }
@@ -0,0 +1,13 @@
1
+ import { MediaItem } from "./media-item";
2
+
3
+ export interface Press {
4
+ id: string;
5
+ slug: string;
6
+ title: string;
7
+ source: string;
8
+ url: string;
9
+ published_at: string;
10
+ featured_media?: MediaItem;
11
+ excerpt: string;
12
+ content: string;
13
+ }
@@ -0,0 +1,76 @@
1
+ export interface SocialLink {
2
+ name: string;
3
+ url: string | null;
4
+ }
5
+
6
+ export interface FontFamily {
7
+ name: string;
8
+ value: string;
9
+ }
10
+
11
+ export interface ThemeColors {
12
+ primary?: string;
13
+ primaryForeground: string;
14
+ secondary?: string;
15
+ secondaryForeground: string;
16
+ tertiary?: string;
17
+ tertiaryForeground: string;
18
+ topbar?: string;
19
+ topbarForeground: string;
20
+ header?: string;
21
+ headerForeground: string;
22
+ footerLocation?: string;
23
+ footerLocationForeground: string;
24
+ footer?: string;
25
+ footerForeground: string;
26
+ }
27
+
28
+ export interface Theme {
29
+ name: string | null;
30
+ colors: ThemeColors;
31
+ }
32
+
33
+ export interface WebsiteMeta {
34
+ title: string | null;
35
+ description: string | null;
36
+ }
37
+
38
+ export interface OpenGraph {
39
+ title: string | null;
40
+ description: string | null;
41
+ image: string | null;
42
+ }
43
+
44
+ export interface Logo {
45
+ url: string;
46
+ width: number;
47
+ height: number;
48
+ thumb: string;
49
+ }
50
+
51
+ export interface Account {
52
+ id: string;
53
+ name: string;
54
+ }
55
+
56
+ export interface Website {
57
+ id: string;
58
+ app_name: string;
59
+ domain: string;
60
+ favicon_url: string | null;
61
+ logo: Logo | null;
62
+ account: Account;
63
+ meta: WebsiteMeta;
64
+ open_graph: OpenGraph;
65
+ theme: Theme;
66
+ google_analytics_id: string | null;
67
+ facebook_pixel_id: string | null;
68
+ font_urls: string[] | null;
69
+ font_families: FontFamily[] | null;
70
+ header_navigation_id: string | null;
71
+ footer_navigation_id: string | null;
72
+ social_links: SocialLink[];
73
+ home_cta_text: string | null;
74
+ home_cta_url: string | null;
75
+ has_accessibility_widget: boolean;
76
+ }
@@ -0,0 +1,77 @@
1
+ import type { Event, Location, Website } from "../types";
2
+ import { Event as SchemaEvent, WithContext } from "schema-dts";
3
+
4
+ export function isMultipleDays(start: Date, end: Date) {
5
+ return start.getDate() !== end.getDate();
6
+ }
7
+
8
+ export function dateString(event: Event) {
9
+ const startTime = new Date(event.start_time);
10
+ const endTime = new Date(event.end_time);
11
+
12
+ if (isMultipleDays(startTime, endTime)) {
13
+ const startDayShort = startTime.toLocaleDateString("en-US", { weekday: "short" });
14
+ const startDate = startTime.toLocaleDateString("en-US", { month: "short", day: "numeric" });
15
+ const endDate = endTime.toLocaleDateString("en-US", { month: "short", day: "numeric" });
16
+
17
+ return `${startDayShort}, ${startDate} - ${endDate}`;
18
+ }
19
+
20
+ const startDay = startTime.toLocaleDateString("en-US", { weekday: "short" });
21
+ const startDate = startTime.toLocaleDateString("en-US", { month: "short", day: "numeric" });
22
+ const startTimeString = startTime.toLocaleTimeString("en-US", { hour: "numeric", minute: "numeric" });
23
+ const endTimeString = endTime.toLocaleTimeString("en-US", { hour: "numeric", minute: "numeric" });
24
+
25
+ return `${startDay}, ${startDate}`;
26
+ }
27
+
28
+ export function timeString(event: Event) {
29
+ const startTime = new Date(event.start_time);
30
+ const endTime = new Date(event.end_time);
31
+
32
+ const startTimeString = startTime.toLocaleTimeString("en-US", { hour: "numeric", minute: "numeric" });
33
+ const endTimeString = endTime.toLocaleTimeString("en-US", { hour: "numeric", minute: "numeric" });
34
+
35
+ return `${startTimeString} - ${endTimeString}`;
36
+ }
37
+
38
+ export function shortDescription(event: Event) {
39
+ // event.description is html
40
+ // strip html tags
41
+ // keep newlines
42
+ // return first 50 chars
43
+
44
+ const shortDescription = event.description.substring(0, 100);
45
+ return shortDescription;
46
+ }
47
+
48
+ export function makeEventSchema(website: Website, event: Event, locations: Location[]): WithContext<SchemaEvent> {
49
+ return {
50
+ "@context": "https://schema.org",
51
+ "@type": "Event",
52
+ "@id": `https://${website.domain}/events/${event.id}//#event`,
53
+ eventAttendanceMode: "https://schema.org/OfflineEventAttendanceMode",
54
+ url: `https://${website.domain}/events/${event.id}`,
55
+ name: event.title,
56
+ description: event.description,
57
+ startDate: event.start_time,
58
+ endDate: event.end_time,
59
+ location: [
60
+ {
61
+ "@type": "Place",
62
+ address: {
63
+ "@type": "PostalAddress",
64
+ streetAddress: locations[0].address,
65
+ addressLocality: locations[0].city,
66
+ addressRegion: locations[0].state,
67
+ postalCode: locations[0].zip,
68
+ addressCountry: "US",
69
+ },
70
+ },
71
+ ],
72
+ image: {
73
+ "@type": "ImageObject",
74
+ url: event.cover_media?.transform_url,
75
+ },
76
+ };
77
+ }