@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.
- package/dist/cjs/client.js +18 -5
- package/dist/cjs/endpoints/alerts.js +8 -5
- package/dist/cjs/endpoints/base.js +9 -0
- package/dist/cjs/endpoints/events.js +16 -18
- package/dist/cjs/endpoints/locations.js +21 -19
- package/dist/cjs/endpoints/menus.js +23 -22
- package/dist/cjs/endpoints/navigation.js +26 -25
- package/dist/cjs/endpoints/pages.js +20 -20
- package/dist/cjs/endpoints/press.js +8 -5
- package/dist/cjs/endpoints/website.js +8 -5
- package/dist/esm/client.d.ts +16 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +17 -3
- package/dist/esm/endpoints/alerts.d.ts +4 -1
- package/dist/esm/endpoints/alerts.d.ts.map +1 -1
- package/dist/esm/endpoints/alerts.js +6 -4
- package/dist/esm/endpoints/base.d.ts +6 -0
- package/dist/esm/endpoints/base.d.ts.map +1 -0
- package/dist/esm/endpoints/base.js +5 -0
- package/dist/esm/endpoints/events.d.ts +6 -3
- package/dist/esm/endpoints/events.d.ts.map +1 -1
- package/dist/esm/endpoints/events.js +14 -15
- package/dist/esm/endpoints/locations.d.ts +5 -2
- package/dist/esm/endpoints/locations.d.ts.map +1 -1
- package/dist/esm/endpoints/locations.js +19 -17
- package/dist/esm/endpoints/menus.d.ts +6 -3
- package/dist/esm/endpoints/menus.d.ts.map +1 -1
- package/dist/esm/endpoints/menus.js +21 -19
- package/dist/esm/endpoints/navigation.d.ts +6 -3
- package/dist/esm/endpoints/navigation.d.ts.map +1 -1
- package/dist/esm/endpoints/navigation.js +24 -22
- package/dist/esm/endpoints/pages.d.ts +8 -5
- package/dist/esm/endpoints/pages.d.ts.map +1 -1
- package/dist/esm/endpoints/pages.js +18 -16
- package/dist/esm/endpoints/press.d.ts +4 -1
- package/dist/esm/endpoints/press.d.ts.map +1 -1
- package/dist/esm/endpoints/press.js +6 -4
- package/dist/esm/endpoints/website.d.ts +4 -1
- package/dist/esm/endpoints/website.d.ts.map +1 -1
- package/dist/esm/endpoints/website.js +6 -4
- package/dist/types/client.d.ts +16 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/endpoints/alerts.d.ts +4 -1
- package/dist/types/endpoints/alerts.d.ts.map +1 -1
- package/dist/types/endpoints/base.d.ts +6 -0
- package/dist/types/endpoints/base.d.ts.map +1 -0
- package/dist/types/endpoints/events.d.ts +6 -3
- package/dist/types/endpoints/events.d.ts.map +1 -1
- package/dist/types/endpoints/locations.d.ts +5 -2
- package/dist/types/endpoints/locations.d.ts.map +1 -1
- package/dist/types/endpoints/menus.d.ts +6 -3
- package/dist/types/endpoints/menus.d.ts.map +1 -1
- package/dist/types/endpoints/navigation.d.ts +6 -3
- package/dist/types/endpoints/navigation.d.ts.map +1 -1
- package/dist/types/endpoints/pages.d.ts +8 -5
- package/dist/types/endpoints/pages.d.ts.map +1 -1
- package/dist/types/endpoints/press.d.ts +4 -1
- package/dist/types/endpoints/press.d.ts.map +1 -1
- package/dist/types/endpoints/website.d.ts +4 -1
- package/dist/types/endpoints/website.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +28 -4
- package/src/endpoints/alerts.ts +6 -4
- package/src/endpoints/base.ts +5 -0
- package/src/endpoints/events.ts +14 -15
- package/src/endpoints/locations.ts +21 -19
- package/src/endpoints/menus.ts +24 -20
- package/src/endpoints/navigation.ts +26 -24
- package/src/endpoints/pages.ts +19 -18
- package/src/endpoints/press.ts +6 -4
- package/src/endpoints/website.ts +6 -4
package/src/endpoints/menus.ts
CHANGED
|
@@ -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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
16
|
+
return data[0];
|
|
17
|
+
}
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
return data[0];
|
|
19
|
+
return data;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
29
|
+
return data[0];
|
|
30
|
+
}
|
|
24
31
|
|
|
25
|
-
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
navigations.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
18
|
-
);
|
|
19
|
-
}
|
|
17
|
+
async getDefaultNavigation(): Promise<Navigation> {
|
|
18
|
+
const navigations = await this.getNavigations();
|
|
19
|
+
return navigations[0];
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
+
const topLevelItems = navigation.items.filter((item: any) => item.parent_id === null);
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
topLevelItems.forEach((item: any) => {
|
|
29
|
+
item.children = navigation.items.filter((child: any) => child.parent_id === item.id);
|
|
30
|
+
});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
navigation.items = topLevelItems;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
return navigation;
|
|
35
|
+
}
|
|
34
36
|
}
|
package/src/endpoints/pages.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ApiCollectionResponse } from "../types/api";
|
|
1
|
+
import { ApiCollectionResponse, Page } from "../types";
|
|
2
|
+
import { BaseService } from "./base";
|
|
4
3
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
}
|
package/src/endpoints/press.ts
CHANGED
|
@@ -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
|
|
5
|
-
|
|
6
|
-
|
|
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
|
}
|
package/src/endpoints/website.ts
CHANGED
|
@@ -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
|
|
5
|
-
|
|
6
|
-
|
|
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
|
}
|