@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,22 +1,24 @@
1
- import { client } from "../client";
2
- export async function getMenus() {
3
- const res = await client().get("/menus");
4
- const menus = res.data;
5
- return menus;
6
- }
7
- export async function getMenu(id) {
8
- const res = await client().get(`/menus?filter[id]=${id}&include=categories.items`);
9
- const data = res.data;
10
- if (Array.isArray(data) && data.length > 0) {
11
- return data[0];
1
+ import { BaseService } from "./base";
2
+ export class MenuService extends BaseService {
3
+ async getMenus() {
4
+ const res = await this.client.get("/menus");
5
+ const menus = res.data;
6
+ return menus;
12
7
  }
13
- return data;
14
- }
15
- export async function getMenuBySlug(slug) {
16
- const res = await client().get(`/menus?filter[slug]=${slug}&include=categories.items`);
17
- const data = res.data;
18
- if (Array.isArray(data) && data.length > 0) {
19
- return data[0];
8
+ async getMenu(id) {
9
+ const res = await this.client.get(`/menus?filter[id]=${id}&include=categories.items`);
10
+ const data = res.data;
11
+ if (Array.isArray(data) && data.length > 0) {
12
+ return data[0];
13
+ }
14
+ return data;
15
+ }
16
+ async getMenuBySlug(slug) {
17
+ const res = await this.client.get(`/menus?filter[slug]=${slug}&include=categories.items`);
18
+ const data = res.data;
19
+ if (Array.isArray(data) && data.length > 0) {
20
+ return data[0];
21
+ }
22
+ return data;
20
23
  }
21
- return data;
22
24
  }
@@ -1,5 +1,8 @@
1
1
  import { Navigation } from "../types";
2
- export declare function getDefaultNavigation(): Promise<Navigation>;
3
- export declare function getNavigations(): Promise<Navigation[]>;
4
- export declare function getNavigation(id: string): Promise<Navigation>;
2
+ import { BaseService } from "./base";
3
+ export declare class NavigationService extends BaseService {
4
+ getNavigations(): Promise<Navigation[]>;
5
+ getDefaultNavigation(): Promise<Navigation>;
6
+ getNavigation(id: string): Promise<Navigation>;
7
+ }
5
8
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/endpoints/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAA4C,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhF,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,CAGhE;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAU5D;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAanE"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/endpoints/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,UAAU,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,iBAAkB,SAAQ,WAAW;IAC1C,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAYvC,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC;IAK3C,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAcrD"}
@@ -1,23 +1,25 @@
1
- import { client } from "../client";
2
- export async function getDefaultNavigation() {
3
- const navigations = await getNavigations();
4
- return navigations[0];
5
- }
6
- export async function getNavigations() {
7
- const res = await client().get("/navigations");
8
- const navigations = res.data;
9
- return Promise.all(navigations.map(async (navigation) => {
10
- const res = await client().get("/navigations/" + navigation.id);
11
- return res.data[0];
12
- }));
13
- }
14
- export async function getNavigation(id) {
15
- const res = await client().get(`/navigations/${id}`);
16
- const navigation = res.data;
17
- const topLevelItems = navigation.items.filter((item) => item.parent_id === null);
18
- topLevelItems.forEach((item) => {
19
- item.children = navigation.items.filter((child) => child.parent_id === item.id);
20
- });
21
- navigation.items = topLevelItems;
22
- return navigation;
1
+ import { BaseService } from "./base";
2
+ export class NavigationService extends BaseService {
3
+ async getNavigations() {
4
+ const res = await this.client.get("/navigations");
5
+ const navigations = res.data;
6
+ return Promise.all(navigations.map(async (navigation) => {
7
+ const res = await this.client.get("/navigations/" + navigation.id);
8
+ return res.data[0];
9
+ }));
10
+ }
11
+ async getDefaultNavigation() {
12
+ const navigations = await this.getNavigations();
13
+ return navigations[0];
14
+ }
15
+ async getNavigation(id) {
16
+ const res = await this.client.get(`/navigations/${id}`);
17
+ const navigation = res.data;
18
+ const topLevelItems = navigation.items.filter((item) => item.parent_id === null);
19
+ topLevelItems.forEach((item) => {
20
+ item.children = navigation.items.filter((child) => child.parent_id === item.id);
21
+ });
22
+ navigation.items = topLevelItems;
23
+ return navigation;
24
+ }
23
25
  }
@@ -1,6 +1,9 @@
1
- import { Page } from "../types/page";
2
- export declare function getPage(slug: string): Promise<Page>;
3
- export declare function getPages(): Promise<Page[]>;
4
- export declare function getHomePage(): Promise<Page>;
5
- export declare function getPageBySlug(slug: string): Promise<Page>;
1
+ import { Page } from "../types";
2
+ import { BaseService } from "./base";
3
+ export declare class PageService extends BaseService {
4
+ getPages(): Promise<Page[]>;
5
+ getPage(id: string): Promise<Page>;
6
+ getPageBySlug(slug: string): Promise<Page>;
7
+ getHomePage(): Promise<Page>;
8
+ }
6
9
  //# sourceMappingURL=pages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/endpoints/pages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzD;AAED,wBAAsB,QAAQ,oBAG7B;AAED,wBAAsB,WAAW,kBAGhC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,iBAG/C"}
1
+ {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/endpoints/pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,IAAI,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAK3B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAInC"}
@@ -1,17 +1,19 @@
1
- import { client } from "../client";
2
- export async function getPage(slug) {
3
- const res = await client().get(`/pages/?filter[slug]=${slug}`);
4
- return res.data[0];
5
- }
6
- export async function getPages() {
7
- const { data } = await client().get("/pages");
8
- return data;
9
- }
10
- export async function getHomePage() {
11
- const res = await client().get("/pages?filter[slug]=/");
12
- return res.data[0];
13
- }
14
- export async function getPageBySlug(slug) {
15
- const res = await client().get("/pages?filter[slug]=" + slug);
16
- return res.data[0];
1
+ import { BaseService } from "./base";
2
+ export class PageService extends BaseService {
3
+ async getPages() {
4
+ const res = await this.client.get("/pages");
5
+ return res.data;
6
+ }
7
+ async getPage(id) {
8
+ const res = await this.client.get(`/pages/${id}`);
9
+ return res.data[0];
10
+ }
11
+ async getPageBySlug(slug) {
12
+ const res = await this.client.get(`/pages?filter[slug]=${slug}`);
13
+ return res.data[0];
14
+ }
15
+ async getHomePage() {
16
+ const res = await this.client.get("/pages?filter[slug]=/");
17
+ return res.data[0];
18
+ }
17
19
  }
@@ -1,3 +1,6 @@
1
1
  import { Press } from "../types";
2
- export declare function getPress(): Promise<Press[]>;
2
+ import { BaseService } from "./base";
3
+ export declare class PressService extends BaseService {
4
+ getPress(): Promise<Press[]>;
5
+ }
3
6
  //# sourceMappingURL=press.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/endpoints/press.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAGjD"}
1
+ {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/endpoints/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,YAAa,SAAQ,WAAW;IACrC,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAInC"}
@@ -1,5 +1,7 @@
1
- import { client } from "../client";
2
- export async function getPress() {
3
- const { data } = await client().get("/press");
4
- return data;
1
+ import { BaseService } from "./base";
2
+ export class PressService extends BaseService {
3
+ async getPress() {
4
+ const { data } = await this.client.get("/press");
5
+ return data;
6
+ }
5
7
  }
@@ -1,3 +1,6 @@
1
1
  import { Website } from "../types";
2
- export declare function getWebsite(): Promise<Website>;
2
+ import { BaseService } from "./base";
3
+ export declare class WebsiteService extends BaseService {
4
+ getWebsite(): Promise<Website>;
5
+ }
3
6
  //# sourceMappingURL=website.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1D,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAGnD"}
1
+ {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAIrC"}
@@ -1,5 +1,7 @@
1
- import { client } from "../client";
2
- export async function getWebsite() {
3
- const res = await client().get("/websites");
4
- return res.data[0];
1
+ import { BaseService } from "./base";
2
+ export class WebsiteService extends BaseService {
3
+ async getWebsite() {
4
+ const res = await this.client.get("/websites");
5
+ return res.data[0];
6
+ }
5
7
  }
@@ -1,7 +1,23 @@
1
1
  import { AxiosInstance, AxiosRequestConfig } from "axios";
2
2
  import { BackstageUserConfig } from "./config";
3
+ import { AlertService } from "./endpoints/alerts";
4
+ import { EventService } from "./endpoints/events";
5
+ import { LocationService } from "./endpoints/locations";
6
+ import { MenuService } from "./endpoints/menus";
7
+ import { NavigationService } from "./endpoints/navigation";
8
+ import { PageService } from "./endpoints/pages";
9
+ import { PressService } from "./endpoints/press";
10
+ import { WebsiteService } from "./endpoints/website";
3
11
  export declare class BackstageClient {
4
12
  private instance;
13
+ readonly alerts: AlertService;
14
+ readonly events: EventService;
15
+ readonly locations: LocationService;
16
+ readonly menus: MenuService;
17
+ readonly navigation: NavigationService;
18
+ readonly pages: PageService;
19
+ readonly press: PressService;
20
+ readonly website: WebsiteService;
5
21
  constructor(config?: BackstageUserConfig);
6
22
  get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>;
7
23
  post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
@@ -10,5 +26,4 @@ export declare class BackstageClient {
10
26
  delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T>;
11
27
  getAxiosInstance(): AxiosInstance;
12
28
  }
13
- export declare const client: (config?: BackstageUserConfig) => BackstageClient;
14
29
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAmB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEhE,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,MAAM,CAAC,EAAE,mBAAmB;IA0D3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKvF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/E,gBAAgB,IAAI,aAAa;CAGzC;AAED,eAAO,MAAM,MAAM,YAAsB,mBAAmB,KAAG,eAE9D,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAmB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAgB;IAGhC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,UAAU,EAAE,iBAAiB,CAAC;IAC9C,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,KAAK,EAAE,YAAY,CAAC;IACpC,SAAgB,OAAO,EAAE,cAAc,CAAC;gBAE5B,MAAM,CAAC,EAAE,mBAAmB;IAoE3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKvF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/E,gBAAgB,IAAI,aAAa;CAGzC"}
@@ -1,3 +1,6 @@
1
1
  import { Alert } from "../types";
2
- export declare function getAlerts(): Promise<Alert[]>;
2
+ import { BaseService } from "./base";
3
+ export declare class AlertService extends BaseService {
4
+ getAlerts(): Promise<Alert[]>;
5
+ }
3
6
  //# sourceMappingURL=alerts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../../src/endpoints/alerts.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAsB,SAAS,qBAG9B"}
1
+ {"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../../src/endpoints/alerts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,YAAa,SAAQ,WAAW;IACrC,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAIpC"}
@@ -0,0 +1,6 @@
1
+ import { BackstageClient } from "../client";
2
+ export declare class BaseService {
3
+ protected client: BackstageClient;
4
+ constructor(client: BackstageClient);
5
+ }
6
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/endpoints/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,WAAW;IACV,SAAS,CAAC,MAAM,EAAE,eAAe;gBAAvB,MAAM,EAAE,eAAe;CAC9C"}
@@ -1,5 +1,8 @@
1
1
  import { Event } from "../types";
2
- export declare function getEvents(): Promise<Event[]>;
3
- export declare function getEvent(id: string): Promise<Event>;
4
- export declare function getEventBySlug(slug: string): Promise<Event>;
2
+ import { BaseService } from "./base";
3
+ export declare class EventService extends BaseService {
4
+ getEvents(): Promise<Event[]>;
5
+ getEvent(id: string): Promise<Event>;
6
+ getEventBySlug(slug: string): Promise<Event>;
7
+ }
5
8
  //# sourceMappingURL=events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/endpoints/events.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAsB,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAIlD;AAED,wBAAsB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAIzD;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAIjE"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/endpoints/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,YAAa,SAAQ,WAAW;IACrC,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAK7B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAKpC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;CAInD"}
@@ -1,4 +1,7 @@
1
1
  import { Location } from "../types";
2
- export declare function getLocations(): Promise<Location[]>;
3
- export declare function getLocationBySlug(slug: string): Promise<Location | Location[]>;
2
+ import { BaseService } from "./base";
3
+ export declare class LocationService extends BaseService {
4
+ getLocations(): Promise<Location[]>;
5
+ getLocationBySlug(slug: string): Promise<Location | Location[]>;
6
+ }
4
7
  //# sourceMappingURL=locations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../../../src/endpoints/locations.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE3D,wBAAsB,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAUxD;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,kCASnD"}
1
+ {"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../../../src/endpoints/locations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,eAAgB,SAAQ,WAAW;IACxC,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAYnC,iBAAiB,CAAC,IAAI,EAAE,MAAM;CAUrC"}
@@ -1,5 +1,8 @@
1
1
  import { Menu } from "../types";
2
- export declare function getMenus(): Promise<Menu[]>;
3
- export declare function getMenu(id: string): Promise<Menu | Menu[]>;
4
- export declare function getMenuBySlug(slug: string): Promise<Menu | Menu[]>;
2
+ import { BaseService } from "./base";
3
+ export declare class MenuService extends BaseService {
4
+ getMenus(): Promise<Menu[]>;
5
+ getMenu(id: string): Promise<Menu | Menu[]>;
6
+ getMenuBySlug(slug: string): Promise<Menu | Menu[]>;
7
+ }
5
8
  //# sourceMappingURL=menus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../../src/endpoints/menus.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEvD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAIhD;AAED,wBAAsB,OAAO,CAAC,EAAE,EAAE,MAAM,0BASvC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,0BAS/C"}
1
+ {"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../../src/endpoints/menus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,IAAI,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAM3B,OAAO,CAAC,EAAE,EAAE,MAAM;IAWlB,aAAa,CAAC,IAAI,EAAE,MAAM;CAYjC"}
@@ -1,5 +1,8 @@
1
1
  import { Navigation } from "../types";
2
- export declare function getDefaultNavigation(): Promise<Navigation>;
3
- export declare function getNavigations(): Promise<Navigation[]>;
4
- export declare function getNavigation(id: string): Promise<Navigation>;
2
+ import { BaseService } from "./base";
3
+ export declare class NavigationService extends BaseService {
4
+ getNavigations(): Promise<Navigation[]>;
5
+ getDefaultNavigation(): Promise<Navigation>;
6
+ getNavigation(id: string): Promise<Navigation>;
7
+ }
5
8
  //# sourceMappingURL=navigation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/endpoints/navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAA4C,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhF,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,CAGhE;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAU5D;AAED,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAanE"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/endpoints/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,UAAU,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,iBAAkB,SAAQ,WAAW;IAC1C,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAYvC,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC;IAK3C,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAcrD"}
@@ -1,6 +1,9 @@
1
- import { Page } from "../types/page";
2
- export declare function getPage(slug: string): Promise<Page>;
3
- export declare function getPages(): Promise<Page[]>;
4
- export declare function getHomePage(): Promise<Page>;
5
- export declare function getPageBySlug(slug: string): Promise<Page>;
1
+ import { Page } from "../types";
2
+ import { BaseService } from "./base";
3
+ export declare class PageService extends BaseService {
4
+ getPages(): Promise<Page[]>;
5
+ getPage(id: string): Promise<Page>;
6
+ getPageBySlug(slug: string): Promise<Page>;
7
+ getHomePage(): Promise<Page>;
8
+ }
6
9
  //# sourceMappingURL=pages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/endpoints/pages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzD;AAED,wBAAsB,QAAQ,oBAG7B;AAED,wBAAsB,WAAW,kBAGhC;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,iBAG/C"}
1
+ {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../../src/endpoints/pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,IAAI,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAK3B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAInC"}
@@ -1,3 +1,6 @@
1
1
  import { Press } from "../types";
2
- export declare function getPress(): Promise<Press[]>;
2
+ import { BaseService } from "./base";
3
+ export declare class PressService extends BaseService {
4
+ getPress(): Promise<Press[]>;
5
+ }
3
6
  //# sourceMappingURL=press.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/endpoints/press.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAGjD"}
1
+ {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/endpoints/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,YAAa,SAAQ,WAAW;IACrC,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;CAInC"}
@@ -1,3 +1,6 @@
1
1
  import { Website } from "../types";
2
- export declare function getWebsite(): Promise<Website>;
2
+ import { BaseService } from "./base";
3
+ export declare class WebsiteService extends BaseService {
4
+ getWebsite(): Promise<Website>;
5
+ }
3
6
  //# sourceMappingURL=website.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1D,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAGnD"}
1
+ {"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAIrC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antlur/backstage",
3
3
  "author": "Anthony Holmes",
4
- "version": "1.0.10",
4
+ "version": "1.1.0",
5
5
  "description": "A simple client for Backstage CMS",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",
package/src/client.ts CHANGED
@@ -1,9 +1,27 @@
1
1
  import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
2
2
  import { getGlobalConfig, BackstageUserConfig } from "./config";
3
+ import { AlertService } from "./endpoints/alerts";
4
+ import { EventService } from "./endpoints/events";
5
+ import { LocationService } from "./endpoints/locations";
6
+ import { MenuService } from "./endpoints/menus";
7
+ import { NavigationService } from "./endpoints/navigation";
8
+ import { PageService } from "./endpoints/pages";
9
+ import { PressService } from "./endpoints/press";
10
+ import { WebsiteService } from "./endpoints/website";
3
11
 
4
12
  export class BackstageClient {
5
13
  private instance: AxiosInstance;
6
14
 
15
+ // Service Instances
16
+ public readonly alerts: AlertService;
17
+ public readonly events: EventService;
18
+ public readonly locations: LocationService;
19
+ public readonly menus: MenuService;
20
+ public readonly navigation: NavigationService;
21
+ public readonly pages: PageService;
22
+ public readonly press: PressService;
23
+ public readonly website: WebsiteService;
24
+
7
25
  constructor(config?: BackstageUserConfig) {
8
26
  // If no config is passed, try to get from the global config
9
27
  const globalConfig = getGlobalConfig();
@@ -60,6 +78,16 @@ export class BackstageClient {
60
78
  return Promise.reject(error);
61
79
  }
62
80
  );
81
+
82
+ // Initialize service instances
83
+ this.alerts = new AlertService(this);
84
+ this.events = new EventService(this);
85
+ this.locations = new LocationService(this);
86
+ this.menus = new MenuService(this);
87
+ this.navigation = new NavigationService(this);
88
+ this.pages = new PageService(this);
89
+ this.press = new PressService(this);
90
+ this.website = new WebsiteService(this);
63
91
  }
64
92
 
65
93
  public async get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<T> {
@@ -91,7 +119,3 @@ export class BackstageClient {
91
119
  return this.instance;
92
120
  }
93
121
  }
94
-
95
- export const client = function (config?: BackstageUserConfig): BackstageClient {
96
- return new BackstageClient(config);
97
- };
@@ -1,7 +1,9 @@
1
- import { client } from "../client";
2
1
  import { ApiCollectionResponse, Alert } from "../types";
2
+ import { BaseService } from "./base";
3
3
 
4
- export async function getAlerts() {
5
- const { data } = await client().get<ApiCollectionResponse<Alert>>("/alerts");
6
- return data;
4
+ export class AlertService extends BaseService {
5
+ async getAlerts(): Promise<Alert[]> {
6
+ const { data } = await this.client.get<ApiCollectionResponse<Alert>>("/alerts");
7
+ return data;
8
+ }
7
9
  }
@@ -0,0 +1,5 @@
1
+ import { BackstageClient } from "../client";
2
+
3
+ export class BaseService {
4
+ constructor(protected client: BackstageClient) {}
5
+ }
@@ -1,20 +1,19 @@
1
- import { client } from "../client";
2
1
  import { ApiCollectionResponse, Event } from "../types";
2
+ import { BaseService } from "./base";
3
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
- }
4
+ export class EventService extends BaseService {
5
+ async getEvents(): Promise<Event[]> {
6
+ const { data } = await this.client.get<ApiCollectionResponse<Event>>("/events");
7
+ return data;
8
+ }
9
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
- }
10
+ async getEvent(id: string): Promise<Event> {
11
+ const { data } = await this.client.get<ApiCollectionResponse<Event>>("/events" + "?filter[id]=" + id);
12
+ return data?.[0];
13
+ }
15
14
 
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;
15
+ async getEventBySlug(slug: string): Promise<Event> {
16
+ const { data } = await this.client.get<ApiCollectionResponse<Event>>("/events" + "?filter[slug]=" + slug);
17
+ return data?.[0];
18
+ }
20
19
  }
@@ -1,25 +1,27 @@
1
- import { client } from "../client";
2
1
  import { ApiCollectionResponse, Location } from "../types";
2
+ import { BaseService } from "./base";
3
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
- }
4
+ export class LocationService extends BaseService {
5
+ async getLocations(): Promise<Location[]> {
6
+ const res = await this.client.get<ApiCollectionResponse<Location>>("/locations");
7
+ let locations = res.data;
8
+ locations = locations.sort((a: any, b: any) => {
9
+ if (a.name < b.name) {
10
+ return -1;
11
+ }
12
+ return 1;
13
+ });
14
+ return locations;
15
+ }
15
16
 
16
- export async function getLocationBySlug(slug: string) {
17
- const res = await client().get<ApiCollectionResponse<Location>>(`/locations?filter[slug]=${slug}`);
18
- const data = res.data;
17
+ async getLocationBySlug(slug: string) {
18
+ const res = await this.client.get<ApiCollectionResponse<Location>>(`/locations?filter[slug]=${slug}`);
19
+ const data = res.data;
19
20
 
20
- if (Array.isArray(data) && data.length > 0) {
21
- return data[0];
22
- }
21
+ if (Array.isArray(data) && data.length > 0) {
22
+ return data[0];
23
+ }
23
24
 
24
- return data;
25
+ return data;
26
+ }
25
27
  }