@antlur/backstage 1.0.10 → 1.1.0

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 (71) hide show
  1. package/dist/cjs/client.js +18 -5
  2. package/dist/cjs/endpoints/alerts.js +8 -5
  3. package/dist/cjs/endpoints/base.js +9 -0
  4. package/dist/cjs/endpoints/events.js +16 -18
  5. package/dist/cjs/endpoints/locations.js +21 -19
  6. package/dist/cjs/endpoints/menus.js +23 -22
  7. package/dist/cjs/endpoints/navigation.js +26 -25
  8. package/dist/cjs/endpoints/pages.js +20 -20
  9. package/dist/cjs/endpoints/press.js +8 -5
  10. package/dist/cjs/endpoints/website.js +8 -5
  11. package/dist/esm/client.d.ts +16 -1
  12. package/dist/esm/client.d.ts.map +1 -1
  13. package/dist/esm/client.js +17 -3
  14. package/dist/esm/endpoints/alerts.d.ts +4 -1
  15. package/dist/esm/endpoints/alerts.d.ts.map +1 -1
  16. package/dist/esm/endpoints/alerts.js +6 -4
  17. package/dist/esm/endpoints/base.d.ts +6 -0
  18. package/dist/esm/endpoints/base.d.ts.map +1 -0
  19. package/dist/esm/endpoints/base.js +5 -0
  20. package/dist/esm/endpoints/events.d.ts +6 -3
  21. package/dist/esm/endpoints/events.d.ts.map +1 -1
  22. package/dist/esm/endpoints/events.js +14 -15
  23. package/dist/esm/endpoints/locations.d.ts +5 -2
  24. package/dist/esm/endpoints/locations.d.ts.map +1 -1
  25. package/dist/esm/endpoints/locations.js +19 -17
  26. package/dist/esm/endpoints/menus.d.ts +6 -3
  27. package/dist/esm/endpoints/menus.d.ts.map +1 -1
  28. package/dist/esm/endpoints/menus.js +21 -19
  29. package/dist/esm/endpoints/navigation.d.ts +6 -3
  30. package/dist/esm/endpoints/navigation.d.ts.map +1 -1
  31. package/dist/esm/endpoints/navigation.js +24 -22
  32. package/dist/esm/endpoints/pages.d.ts +8 -5
  33. package/dist/esm/endpoints/pages.d.ts.map +1 -1
  34. package/dist/esm/endpoints/pages.js +18 -16
  35. package/dist/esm/endpoints/press.d.ts +4 -1
  36. package/dist/esm/endpoints/press.d.ts.map +1 -1
  37. package/dist/esm/endpoints/press.js +6 -4
  38. package/dist/esm/endpoints/website.d.ts +4 -1
  39. package/dist/esm/endpoints/website.d.ts.map +1 -1
  40. package/dist/esm/endpoints/website.js +6 -4
  41. package/dist/types/client.d.ts +16 -1
  42. package/dist/types/client.d.ts.map +1 -1
  43. package/dist/types/endpoints/alerts.d.ts +4 -1
  44. package/dist/types/endpoints/alerts.d.ts.map +1 -1
  45. package/dist/types/endpoints/base.d.ts +6 -0
  46. package/dist/types/endpoints/base.d.ts.map +1 -0
  47. package/dist/types/endpoints/events.d.ts +6 -3
  48. package/dist/types/endpoints/events.d.ts.map +1 -1
  49. package/dist/types/endpoints/locations.d.ts +5 -2
  50. package/dist/types/endpoints/locations.d.ts.map +1 -1
  51. package/dist/types/endpoints/menus.d.ts +6 -3
  52. package/dist/types/endpoints/menus.d.ts.map +1 -1
  53. package/dist/types/endpoints/navigation.d.ts +6 -3
  54. package/dist/types/endpoints/navigation.d.ts.map +1 -1
  55. package/dist/types/endpoints/pages.d.ts +8 -5
  56. package/dist/types/endpoints/pages.d.ts.map +1 -1
  57. package/dist/types/endpoints/press.d.ts +4 -1
  58. package/dist/types/endpoints/press.d.ts.map +1 -1
  59. package/dist/types/endpoints/website.d.ts +4 -1
  60. package/dist/types/endpoints/website.d.ts.map +1 -1
  61. package/package.json +1 -1
  62. package/src/client.ts +28 -4
  63. package/src/endpoints/alerts.ts +6 -4
  64. package/src/endpoints/base.ts +5 -0
  65. package/src/endpoints/events.ts +14 -15
  66. package/src/endpoints/locations.ts +21 -19
  67. package/src/endpoints/menus.ts +24 -20
  68. package/src/endpoints/navigation.ts +26 -24
  69. package/src/endpoints/pages.ts +19 -18
  70. package/src/endpoints/press.ts +6 -4
  71. package/src/endpoints/website.ts +6 -4
@@ -1,30 +1,34 @@
1
- import { client } from "../client";
2
1
  import { ApiCollectionResponse, Menu } from "../types";
2
+ import { BaseService } from "./base";
3
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
- }
4
+ export class MenuService extends BaseService {
5
+ async getMenus(): Promise<Menu[]> {
6
+ const res = await this.client.get<ApiCollectionResponse<Menu>>("/menus");
7
+ const menus = res.data;
8
+ return menus;
9
+ }
10
+
11
+ async getMenu(id: string) {
12
+ const res = await this.client.get<ApiCollectionResponse<Menu>>(`/menus?filter[id]=${id}&include=categories.items`);
13
+ const data = res.data;
9
14
 
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;
15
+ if (Array.isArray(data) && data.length > 0) {
16
+ return data[0];
17
+ }
13
18
 
14
- if (Array.isArray(data) && data.length > 0) {
15
- return data[0];
19
+ return data;
16
20
  }
17
21
 
18
- return data;
19
- }
22
+ async getMenuBySlug(slug: string) {
23
+ const res = await this.client.get<ApiCollectionResponse<Menu>>(
24
+ `/menus?filter[slug]=${slug}&include=categories.items`
25
+ );
26
+ const data = res.data;
20
27
 
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;
28
+ if (Array.isArray(data) && data.length > 0) {
29
+ return data[0];
30
+ }
24
31
 
25
- if (Array.isArray(data) && data.length > 0) {
26
- return data[0];
32
+ return data;
27
33
  }
28
-
29
- return data;
30
34
  }
@@ -1,34 +1,36 @@
1
- import { client } from "../client";
2
1
  import { ApiSingleResponse, ApiCollectionResponse, Navigation } from "../types";
2
+ import { BaseService } from "./base";
3
3
 
4
- export async function getDefaultNavigation(): Promise<Navigation> {
5
- const navigations = await getNavigations();
6
- return navigations[0];
7
- }
4
+ export class NavigationService extends BaseService {
5
+ async getNavigations(): Promise<Navigation[]> {
6
+ const res = await this.client.get<ApiCollectionResponse<Navigation>>("/navigations");
7
+ const navigations = res.data;
8
8
 
9
- export async function getNavigations(): Promise<Navigation[]> {
10
- const res = await client().get<ApiCollectionResponse<Navigation>>("/navigations");
11
- const navigations = res.data;
9
+ return Promise.all(
10
+ navigations.map(async (navigation: any) => {
11
+ const res = await this.client.get<ApiCollectionResponse<Navigation>>("/navigations/" + navigation.id);
12
+ return res.data[0];
13
+ })
14
+ );
15
+ }
12
16
 
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
- }
17
+ async getDefaultNavigation(): Promise<Navigation> {
18
+ const navigations = await this.getNavigations();
19
+ return navigations[0];
20
+ }
20
21
 
21
- export async function getNavigation(id: string): Promise<Navigation> {
22
- const res = await client().get<ApiSingleResponse<Navigation>>(`/navigations/${id}`);
23
- const navigation = res.data;
22
+ async getNavigation(id: string): Promise<Navigation> {
23
+ const res = await this.client.get<ApiSingleResponse<Navigation>>(`/navigations/${id}`);
24
+ const navigation = res.data;
24
25
 
25
- const topLevelItems = navigation.items.filter((item: any) => item.parent_id === null);
26
+ const topLevelItems = navigation.items.filter((item: any) => item.parent_id === null);
26
27
 
27
- topLevelItems.forEach((item: any) => {
28
- item.children = navigation.items.filter((child: any) => child.parent_id === item.id);
29
- });
28
+ topLevelItems.forEach((item: any) => {
29
+ item.children = navigation.items.filter((child: any) => child.parent_id === item.id);
30
+ });
30
31
 
31
- navigation.items = topLevelItems;
32
+ navigation.items = topLevelItems;
32
33
 
33
- return navigation;
34
+ return navigation;
35
+ }
34
36
  }
@@ -1,23 +1,24 @@
1
- import { client } from "../client";
2
- import { Page } from "../types/page";
3
- import { ApiCollectionResponse } from "../types/api";
1
+ import { ApiCollectionResponse, Page } from "../types";
2
+ import { BaseService } from "./base";
4
3
 
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
- }
4
+ export class PageService extends BaseService {
5
+ async getPages(): Promise<Page[]> {
6
+ const res = await this.client.get<ApiCollectionResponse<Page>>("/pages");
7
+ return res.data;
8
+ }
9
9
 
10
- export async function getPages() {
11
- const { data } = await client().get<ApiCollectionResponse<Page>>("/pages");
12
- return data;
13
- }
10
+ async getPage(id: string): Promise<Page> {
11
+ const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages/${id}`);
12
+ return res.data[0];
13
+ }
14
14
 
15
- export async function getHomePage() {
16
- const res = await client().get<ApiCollectionResponse<Page>>("/pages?filter[slug]=/");
17
- return res.data[0];
18
- }
15
+ async getPageBySlug(slug: string): Promise<Page> {
16
+ const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages?filter[slug]=${slug}`);
17
+ return res.data[0];
18
+ }
19
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];
20
+ async getHomePage(): Promise<Page> {
21
+ const res = await this.client.get<ApiCollectionResponse<Page>>("/pages?filter[slug]=/");
22
+ return res.data[0];
23
+ }
23
24
  }
@@ -1,7 +1,9 @@
1
- import { client } from "../client";
2
1
  import { ApiCollectionResponse, Press } from "../types";
2
+ import { BaseService } from "./base";
3
3
 
4
- export async function getPress(): Promise<Press[]> {
5
- const { data } = await client().get<ApiCollectionResponse<Press>>("/press");
6
- return data;
4
+ export class PressService extends BaseService {
5
+ async getPress(): Promise<Press[]> {
6
+ const { data } = await this.client.get<ApiCollectionResponse<Press>>("/press");
7
+ return data;
8
+ }
7
9
  }
@@ -1,7 +1,9 @@
1
- import { client } from "../client";
2
1
  import { ApiCollectionResponse, Website } from "../types";
2
+ import { BaseService } from "./base";
3
3
 
4
- export async function getWebsite(): Promise<Website> {
5
- const res = await client().get<ApiCollectionResponse<Website>>("/websites");
6
- return res.data[0];
4
+ export class WebsiteService extends BaseService {
5
+ async getWebsite(): Promise<Website> {
6
+ const res = await this.client.get<ApiCollectionResponse<Website>>("/websites");
7
+ return res.data[0];
8
+ }
7
9
  }