@antlur/backstage 1.12.5 → 1.12.7
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/client.d.ts +10 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -52
- package/dist/config.d.ts +1 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/endpoints/alerts.d.ts +1 -1
- package/dist/endpoints/alerts.d.ts.map +1 -1
- package/dist/endpoints/alerts.js +2 -2
- package/dist/endpoints/blocks.d.ts +3 -3
- package/dist/endpoints/blocks.d.ts.map +1 -1
- package/dist/endpoints/blocks.js +5 -5
- package/dist/endpoints/events.d.ts +3 -3
- package/dist/endpoints/events.d.ts.map +1 -1
- package/dist/endpoints/events.js +6 -6
- package/dist/endpoints/instagram.d.ts +1 -1
- package/dist/endpoints/instagram.d.ts.map +1 -1
- package/dist/endpoints/instagram.js +2 -2
- package/dist/endpoints/layouts.d.ts +3 -3
- package/dist/endpoints/layouts.d.ts.map +1 -1
- package/dist/endpoints/layouts.js +5 -5
- package/dist/endpoints/locations.d.ts +2 -2
- package/dist/endpoints/locations.d.ts.map +1 -1
- package/dist/endpoints/locations.js +4 -4
- package/dist/endpoints/media.d.ts +1 -1
- package/dist/endpoints/media.d.ts.map +1 -1
- package/dist/endpoints/media.js +2 -2
- package/dist/endpoints/menus.d.ts +3 -3
- package/dist/endpoints/menus.d.ts.map +1 -1
- package/dist/endpoints/menus.js +6 -6
- package/dist/endpoints/navigation.d.ts +3 -3
- package/dist/endpoints/navigation.d.ts.map +1 -1
- package/dist/endpoints/navigation.js +7 -7
- package/dist/endpoints/pages.d.ts +5 -5
- package/dist/endpoints/pages.d.ts.map +1 -1
- package/dist/endpoints/pages.js +10 -10
- package/dist/endpoints/press.d.ts +1 -1
- package/dist/endpoints/press.d.ts.map +1 -1
- package/dist/endpoints/press.js +2 -2
- package/dist/endpoints/routes.d.ts +1 -1
- package/dist/endpoints/routes.d.ts.map +1 -1
- package/dist/endpoints/routes.js +2 -2
- package/dist/endpoints/website.d.ts +2 -2
- package/dist/endpoints/website.d.ts.map +1 -1
- package/dist/endpoints/website.js +5 -5
- package/package.json +1 -2
- package/src/client.ts +52 -57
- package/src/config.ts +1 -2
- package/src/endpoints/alerts.ts +2 -2
- package/src/endpoints/blocks.ts +5 -5
- package/src/endpoints/events.ts +6 -6
- package/src/endpoints/instagram.ts +2 -2
- package/src/endpoints/layouts.ts +5 -5
- package/src/endpoints/locations.ts +4 -4
- package/src/endpoints/media.ts +2 -2
- package/src/endpoints/menus.ts +6 -6
- package/src/endpoints/navigation.ts +7 -7
- package/src/endpoints/pages.ts +10 -10
- package/src/endpoints/press.ts +2 -2
- package/src/endpoints/routes.ts +2 -2
- package/src/endpoints/website.ts +5 -5
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
1
|
import { BackstageUserConfig } from "./config.js";
|
|
3
2
|
import { AlertService } from "./endpoints/alerts.js";
|
|
4
3
|
import { BlocksService } from "./endpoints/blocks.js";
|
|
@@ -14,7 +13,10 @@ import { RouteService } from "./endpoints/routes.js";
|
|
|
14
13
|
import { WebsiteService } from "./endpoints/website.js";
|
|
15
14
|
import { MediaService } from "./endpoints/media.js";
|
|
16
15
|
export declare class BackstageClient {
|
|
17
|
-
private
|
|
16
|
+
private baseURL;
|
|
17
|
+
private token;
|
|
18
|
+
private accountId;
|
|
19
|
+
private onError?;
|
|
18
20
|
readonly alerts: AlertService;
|
|
19
21
|
readonly blocks: BlocksService;
|
|
20
22
|
readonly events: EventService;
|
|
@@ -29,11 +31,11 @@ export declare class BackstageClient {
|
|
|
29
31
|
readonly routes: RouteService;
|
|
30
32
|
readonly website: WebsiteService;
|
|
31
33
|
constructor(config?: BackstageUserConfig);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
private request;
|
|
35
|
+
get<T = unknown>(url: string, options?: RequestInit): Promise<T>;
|
|
36
|
+
post<T = unknown>(url: string, data?: unknown, options?: RequestInit): Promise<T>;
|
|
37
|
+
put<T = unknown>(url: string, data?: unknown, options?: RequestInit): Promise<T>;
|
|
38
|
+
patch<T = unknown>(url: string, data?: unknown, options?: RequestInit): Promise<T>;
|
|
39
|
+
delete<T = unknown>(url: string, options?: RequestInit): Promise<T>;
|
|
38
40
|
}
|
|
39
41
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAC,CAAyB;IAGzC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,SAAS,EAAE,gBAAgB,CAAC;IAC5C,SAAgB,OAAO,EAAE,aAAa,CAAC;IACvC,SAAgB,SAAS,EAAE,eAAe,CAAC;IAC3C,SAAgB,KAAK,EAAE,YAAY,CAAC;IACpC,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,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,OAAO,EAAE,cAAc,CAAC;gBAE5B,MAAM,CAAC,EAAE,mBAAmB;YAuC1B,OAAO;IAoCR,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAIjF,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhF,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;CAGjF"}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
1
|
import { getGlobalConfig } from "./config.js";
|
|
3
2
|
import { AlertService } from "./endpoints/alerts.js";
|
|
4
3
|
import { BlocksService } from "./endpoints/blocks.js";
|
|
@@ -14,7 +13,10 @@ import { RouteService } from "./endpoints/routes.js";
|
|
|
14
13
|
import { WebsiteService } from "./endpoints/website.js";
|
|
15
14
|
import { MediaService } from "./endpoints/media.js";
|
|
16
15
|
export class BackstageClient {
|
|
17
|
-
|
|
16
|
+
baseURL;
|
|
17
|
+
token;
|
|
18
|
+
accountId;
|
|
19
|
+
onError;
|
|
18
20
|
// Service Instances
|
|
19
21
|
alerts;
|
|
20
22
|
blocks;
|
|
@@ -43,39 +45,10 @@ export class BackstageClient {
|
|
|
43
45
|
if (!finalConfig.accountId) {
|
|
44
46
|
throw new Error("No accountId found in the Backstage config. Please provide an accountId.");
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Authorization: `Bearer ${token}`,
|
|
51
|
-
"X-Account-ID": finalConfig.accountId,
|
|
52
|
-
Accept: "application/json",
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
// Add request interceptor for debugging
|
|
57
|
-
this.instance.interceptors.request.use((requestConfig) => {
|
|
58
|
-
// console.log("Request:", {
|
|
59
|
-
// method: requestConfig.method,
|
|
60
|
-
// url: requestConfig.url,
|
|
61
|
-
// headers: requestConfig.headers,
|
|
62
|
-
// data: requestConfig.data,
|
|
63
|
-
// });
|
|
64
|
-
return requestConfig;
|
|
65
|
-
});
|
|
66
|
-
// Add response interceptor for debugging
|
|
67
|
-
this.instance.interceptors.response.use((response) => response, (error) => {
|
|
68
|
-
// console.error("API Error:", {
|
|
69
|
-
// status: error.response?.status,
|
|
70
|
-
// method: error.config?.method,
|
|
71
|
-
// url: error.config?.url,
|
|
72
|
-
// headers: error.config?.headers,
|
|
73
|
-
// data: error.response?.data,
|
|
74
|
-
// });
|
|
75
|
-
if (onError)
|
|
76
|
-
onError(error);
|
|
77
|
-
return Promise.reject(error);
|
|
78
|
-
});
|
|
48
|
+
this.baseURL = finalConfig.baseURL;
|
|
49
|
+
this.token = finalConfig.token;
|
|
50
|
+
this.accountId = finalConfig.accountId;
|
|
51
|
+
this.onError = finalConfig.onError;
|
|
79
52
|
// Initialize service instances
|
|
80
53
|
this.alerts = new AlertService(this);
|
|
81
54
|
this.blocks = new BlocksService(this);
|
|
@@ -91,27 +64,54 @@ export class BackstageClient {
|
|
|
91
64
|
this.routes = new RouteService(this);
|
|
92
65
|
this.website = new WebsiteService(this);
|
|
93
66
|
}
|
|
94
|
-
async
|
|
95
|
-
const
|
|
96
|
-
|
|
67
|
+
async request(method, url, data, options) {
|
|
68
|
+
const fullUrl = `${this.baseURL}${url}`;
|
|
69
|
+
const defaultHeaders = {
|
|
70
|
+
Authorization: `Bearer ${this.token}`,
|
|
71
|
+
"X-Account-ID": this.accountId,
|
|
72
|
+
Accept: "application/json",
|
|
73
|
+
"Content-Type": "application/json",
|
|
74
|
+
};
|
|
75
|
+
const fetchOptions = {
|
|
76
|
+
method,
|
|
77
|
+
headers: { ...defaultHeaders, ...options?.headers },
|
|
78
|
+
...options,
|
|
79
|
+
};
|
|
80
|
+
if (data && !fetchOptions.body && (method === "POST" || method === "PUT" || method === "PATCH")) {
|
|
81
|
+
fetchOptions.body = JSON.stringify(data);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const response = await fetch(fullUrl, fetchOptions);
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
const errorText = await response.text();
|
|
87
|
+
const error = new Error(`HTTP ${response.status}: ${response.statusText} - ${errorText}`);
|
|
88
|
+
error.status = response.status;
|
|
89
|
+
error.response = { status: response.status, data: errorText };
|
|
90
|
+
if (this.onError)
|
|
91
|
+
this.onError(error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return await response.json();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (this.onError)
|
|
98
|
+
this.onError(error);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
97
101
|
}
|
|
98
|
-
async
|
|
99
|
-
|
|
100
|
-
return response.data;
|
|
102
|
+
async get(url, options) {
|
|
103
|
+
return this.request("GET", url, undefined, options);
|
|
101
104
|
}
|
|
102
|
-
async
|
|
103
|
-
|
|
104
|
-
return response.data;
|
|
105
|
+
async post(url, data, options) {
|
|
106
|
+
return this.request("POST", url, data, options);
|
|
105
107
|
}
|
|
106
|
-
async
|
|
107
|
-
|
|
108
|
-
return response.data;
|
|
108
|
+
async put(url, data, options) {
|
|
109
|
+
return this.request("PUT", url, data, options);
|
|
109
110
|
}
|
|
110
|
-
async
|
|
111
|
-
|
|
112
|
-
return response.data;
|
|
111
|
+
async patch(url, data, options) {
|
|
112
|
+
return this.request("PATCH", url, data, options);
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
return this.
|
|
114
|
+
async delete(url, options) {
|
|
115
|
+
return this.request("DELETE", url, undefined, options);
|
|
116
116
|
}
|
|
117
117
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AxiosError } from "axios";
|
|
2
1
|
import type { BlockDefinition } from "./studio/types/index.js";
|
|
3
2
|
export interface BackstageUserConfig {
|
|
4
3
|
accountId?: string | undefined;
|
|
@@ -6,7 +5,7 @@ export interface BackstageUserConfig {
|
|
|
6
5
|
baseURL?: string;
|
|
7
6
|
blocks?: BlockDefinition<any>[] | undefined;
|
|
8
7
|
layouts?: any[] | undefined;
|
|
9
|
-
onError?: (error:
|
|
8
|
+
onError?: (error: Error) => void;
|
|
10
9
|
}
|
|
11
10
|
export declare function defineConfig(config: BackstageUserConfig): BackstageUserConfig;
|
|
12
11
|
export declare function getGlobalConfig(): BackstageUserConfig;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAQD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAM7E;AAED,wBAAgB,eAAe,IAAI,mBAAmB,CAGrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Alert } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class AlertService extends BaseService {
|
|
4
|
-
getAlerts(): Promise<Alert[]>;
|
|
4
|
+
getAlerts(options?: RequestInit): Promise<Alert[]>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=alerts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../src/endpoints/alerts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,SAAS,
|
|
1
|
+
{"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../src/endpoints/alerts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAIzD"}
|
package/dist/endpoints/alerts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class AlertService extends BaseService {
|
|
3
|
-
async getAlerts() {
|
|
4
|
-
const { data } = await this.client.get("/alerts");
|
|
3
|
+
async getAlerts(options) {
|
|
4
|
+
const { data } = await this.client.get("/alerts", options);
|
|
5
5
|
return data;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -10,9 +10,9 @@ export declare class BlocksService extends BaseService {
|
|
|
10
10
|
* Get all blocks
|
|
11
11
|
* @todo Implement this method when the API endpoint is available
|
|
12
12
|
*/
|
|
13
|
-
all(): Promise<void>;
|
|
14
|
-
create(params: BlockParams): Promise<BlockParams>;
|
|
15
|
-
update(id: string, params: BlockParams): Promise<BlockParams>;
|
|
13
|
+
all(options?: RequestInit): Promise<void>;
|
|
14
|
+
create(params: BlockParams, options?: RequestInit): Promise<BlockParams>;
|
|
15
|
+
update(id: string, params: BlockParams, options?: RequestInit): Promise<BlockParams>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/endpoints/blocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;OAGG;IACG,GAAG;
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/endpoints/blocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;OAGG;IACG,GAAG,CAAC,OAAO,CAAC,EAAE,WAAW;IAIzB,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW;IAKjD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW;CAIpE"}
|
package/dist/endpoints/blocks.js
CHANGED
|
@@ -4,15 +4,15 @@ export class BlocksService extends BaseService {
|
|
|
4
4
|
* Get all blocks
|
|
5
5
|
* @todo Implement this method when the API endpoint is available
|
|
6
6
|
*/
|
|
7
|
-
async all() {
|
|
7
|
+
async all(options) {
|
|
8
8
|
throw new Error("Method not implemented. Please use the Backstage API documentation for available endpoints.");
|
|
9
9
|
}
|
|
10
|
-
async create(params) {
|
|
11
|
-
const res = await this.client.post("/blocks", params);
|
|
10
|
+
async create(params, options) {
|
|
11
|
+
const res = await this.client.post("/blocks", params, options);
|
|
12
12
|
return res.data;
|
|
13
13
|
}
|
|
14
|
-
async update(id, params) {
|
|
15
|
-
const res = await this.client.put(`/blocks/${id}`, params);
|
|
14
|
+
async update(id, params, options) {
|
|
15
|
+
const res = await this.client.put(`/blocks/${id}`, params, options);
|
|
16
16
|
return res.data;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Event } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class EventService extends BaseService {
|
|
4
|
-
getEvents(): Promise<Event[]>;
|
|
5
|
-
getEvent(id: string): Promise<Event | null>;
|
|
6
|
-
getEventBySlug(slug: string): Promise<Event | null>;
|
|
4
|
+
getEvents(options?: RequestInit): Promise<Event[]>;
|
|
5
|
+
getEvent(id: string, options?: RequestInit): Promise<Event | null>;
|
|
6
|
+
getEventBySlug(slug: string, options?: RequestInit): Promise<Event | null>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/endpoints/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,SAAS,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/endpoints/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAKlD,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAQlE,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAOjF"}
|
package/dist/endpoints/events.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class EventService extends BaseService {
|
|
3
|
-
async getEvents() {
|
|
4
|
-
const { data } = await this.client.get("/events");
|
|
3
|
+
async getEvents(options) {
|
|
4
|
+
const { data } = await this.client.get("/events", options);
|
|
5
5
|
return data;
|
|
6
6
|
}
|
|
7
|
-
async getEvent(id) {
|
|
8
|
-
const { data } = await this.client.get(`/events?filter[id]=${id}
|
|
7
|
+
async getEvent(id, options) {
|
|
8
|
+
const { data } = await this.client.get(`/events?filter[id]=${id}`, options);
|
|
9
9
|
if (!data || data.length === 0) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
return data[0];
|
|
13
13
|
}
|
|
14
|
-
async getEventBySlug(slug) {
|
|
15
|
-
const { data } = await this.client.get(`/events?filter[slug]=${slug}
|
|
14
|
+
async getEventBySlug(slug, options) {
|
|
15
|
+
const { data } = await this.client.get(`/events?filter[slug]=${slug}`, options);
|
|
16
16
|
if (!data || data.length === 0) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InstagramPost } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class InstagramService extends BaseService {
|
|
4
|
-
latest(): Promise<InstagramPost[]>;
|
|
4
|
+
latest(options?: RequestInit): Promise<InstagramPost[]>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=instagram.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instagram.d.ts","sourceRoot":"","sources":["../../src/endpoints/instagram.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,gBAAiB,SAAQ,WAAW;IACzC,MAAM,
|
|
1
|
+
{"version":3,"file":"instagram.d.ts","sourceRoot":"","sources":["../../src/endpoints/instagram.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,gBAAiB,SAAQ,WAAW;IACzC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAI9D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class InstagramService extends BaseService {
|
|
3
|
-
async latest() {
|
|
4
|
-
const { data } = await this.client.get("/instagram-posts");
|
|
3
|
+
async latest(options) {
|
|
4
|
+
const { data } = await this.client.get("/instagram-posts", options);
|
|
5
5
|
return data;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -5,9 +5,9 @@ interface LayoutParams {
|
|
|
5
5
|
schema: any;
|
|
6
6
|
}
|
|
7
7
|
export declare class LayoutService extends BaseService {
|
|
8
|
-
all(): Promise<void>;
|
|
9
|
-
create({ name, slug, schema }: LayoutParams): Promise<LayoutParams>;
|
|
10
|
-
update(id: string, { name, slug, schema }: LayoutParams): Promise<LayoutParams>;
|
|
8
|
+
all(options?: RequestInit): Promise<void>;
|
|
9
|
+
create({ name, slug, schema }: LayoutParams, options?: RequestInit): Promise<LayoutParams>;
|
|
10
|
+
update(id: string, { name, slug, schema }: LayoutParams, options?: RequestInit): Promise<LayoutParams>;
|
|
11
11
|
}
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=layouts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../src/endpoints/layouts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb;AAED,qBAAa,aAAc,SAAQ,WAAW;IACtC,GAAG;
|
|
1
|
+
{"version":3,"file":"layouts.d.ts","sourceRoot":"","sources":["../../src/endpoints/layouts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb;AAED,qBAAa,aAAc,SAAQ,WAAW;IACtC,GAAG,CAAC,OAAO,CAAC,EAAE,WAAW;IAEzB,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW;IAKlE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW;CAIrF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class LayoutService extends BaseService {
|
|
3
|
-
async all() { }
|
|
4
|
-
async create({ name, slug, schema }) {
|
|
5
|
-
const res = await this.client.post("/layouts", { name, slug, schema });
|
|
3
|
+
async all(options) { }
|
|
4
|
+
async create({ name, slug, schema }, options) {
|
|
5
|
+
const res = await this.client.post("/layouts", { name, slug, schema }, options);
|
|
6
6
|
return res.data;
|
|
7
7
|
}
|
|
8
|
-
async update(id, { name, slug, schema }) {
|
|
9
|
-
const res = await this.client.put(`/layouts/${id}`, { name, slug, schema });
|
|
8
|
+
async update(id, { name, slug, schema }, options) {
|
|
9
|
+
const res = await this.client.put(`/layouts/${id}`, { name, slug, schema }, options);
|
|
10
10
|
return res.data;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Location } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class LocationService extends BaseService {
|
|
4
|
-
getLocations(): Promise<Location[]>;
|
|
5
|
-
getLocationBySlug(slug: string): Promise<Location | null>;
|
|
4
|
+
getLocations(options?: RequestInit): Promise<Location[]>;
|
|
5
|
+
getLocationBySlug(slug: string, options?: RequestInit): Promise<Location | null>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=locations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../../src/endpoints/locations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,eAAgB,SAAQ,WAAW;IACxC,YAAY,
|
|
1
|
+
{"version":3,"file":"locations.d.ts","sourceRoot":"","sources":["../../src/endpoints/locations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,eAAgB,SAAQ,WAAW;IACxC,YAAY,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOxD,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAUvF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class LocationService extends BaseService {
|
|
3
|
-
async getLocations() {
|
|
4
|
-
const res = await this.client.get("/locations");
|
|
3
|
+
async getLocations(options) {
|
|
4
|
+
const res = await this.client.get("/locations", options);
|
|
5
5
|
let locations = res.data;
|
|
6
6
|
locations = locations.sort((a, b) => a.name.localeCompare(b.name));
|
|
7
7
|
return locations;
|
|
8
8
|
}
|
|
9
|
-
async getLocationBySlug(slug) {
|
|
10
|
-
const res = await this.client.get(`/locations?filter[slug]=${slug}
|
|
9
|
+
async getLocationBySlug(slug, options) {
|
|
10
|
+
const res = await this.client.get(`/locations?filter[slug]=${slug}`, options);
|
|
11
11
|
const data = res.data;
|
|
12
12
|
if (!data || data.length === 0) {
|
|
13
13
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/endpoints/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,GAAG;
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/endpoints/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,GAAG,CAAC,OAAO,CAAC,EAAE,WAAW;CAIhC"}
|
package/dist/endpoints/media.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Menu } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
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[]>;
|
|
4
|
+
getMenus(options?: RequestInit): Promise<Menu[]>;
|
|
5
|
+
getMenu(id: string, options?: RequestInit): Promise<Menu | Menu[]>;
|
|
6
|
+
getMenuBySlug(slug: string, options?: RequestInit): Promise<Menu | Menu[]>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=menus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../src/endpoints/menus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,
|
|
1
|
+
{"version":3,"file":"menus.d.ts","sourceRoot":"","sources":["../../src/endpoints/menus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAMhD,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;IAWzC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;CAYxD"}
|
package/dist/endpoints/menus.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class MenuService extends BaseService {
|
|
3
|
-
async getMenus() {
|
|
4
|
-
const res = await this.client.get("/menus");
|
|
3
|
+
async getMenus(options) {
|
|
4
|
+
const res = await this.client.get("/menus", options);
|
|
5
5
|
const menus = res.data;
|
|
6
6
|
return menus;
|
|
7
7
|
}
|
|
8
|
-
async getMenu(id) {
|
|
9
|
-
const res = await this.client.get(`/menus?filter[id]=${id}&include=categories.items
|
|
8
|
+
async getMenu(id, options) {
|
|
9
|
+
const res = await this.client.get(`/menus?filter[id]=${id}&include=categories.items`, options);
|
|
10
10
|
const data = res.data;
|
|
11
11
|
if (Array.isArray(data) && data.length > 0) {
|
|
12
12
|
return data[0];
|
|
13
13
|
}
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
|
-
async getMenuBySlug(slug) {
|
|
17
|
-
const res = await this.client.get(`/menus?filter[slug]=${slug}&include=categories.items
|
|
16
|
+
async getMenuBySlug(slug, options) {
|
|
17
|
+
const res = await this.client.get(`/menus?filter[slug]=${slug}&include=categories.items`, options);
|
|
18
18
|
const data = res.data;
|
|
19
19
|
if (Array.isArray(data) && data.length > 0) {
|
|
20
20
|
return data[0];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Navigation } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class NavigationService extends BaseService {
|
|
4
|
-
getNavigations(): Promise<Navigation[]>;
|
|
5
|
-
getDefaultNavigation(): Promise<Navigation>;
|
|
6
|
-
getNavigation(id: string): Promise<Navigation>;
|
|
4
|
+
getNavigations(options?: RequestInit): Promise<Navigation[]>;
|
|
5
|
+
getDefaultNavigation(options?: RequestInit): Promise<Navigation>;
|
|
6
|
+
getNavigation(id: string, options?: RequestInit): Promise<Navigation>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/endpoints/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4C,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,iBAAkB,SAAQ,WAAW;IAC1C,cAAc,
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/endpoints/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4C,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,iBAAkB,SAAQ,WAAW;IAC1C,cAAc,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAY5D,oBAAoB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAKhE,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;CAc5E"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class NavigationService extends BaseService {
|
|
3
|
-
async getNavigations() {
|
|
4
|
-
const res = await this.client.get("/navigations");
|
|
3
|
+
async getNavigations(options) {
|
|
4
|
+
const res = await this.client.get("/navigations", options);
|
|
5
5
|
const navigations = res.data;
|
|
6
6
|
return Promise.all(navigations.map(async (navigation) => {
|
|
7
|
-
const res = await this.client.get("/navigations/" + navigation.id);
|
|
7
|
+
const res = await this.client.get("/navigations/" + navigation.id, options);
|
|
8
8
|
return res.data[0];
|
|
9
9
|
}));
|
|
10
10
|
}
|
|
11
|
-
async getDefaultNavigation() {
|
|
12
|
-
const navigations = await this.getNavigations();
|
|
11
|
+
async getDefaultNavigation(options) {
|
|
12
|
+
const navigations = await this.getNavigations(options);
|
|
13
13
|
return navigations[0];
|
|
14
14
|
}
|
|
15
|
-
async getNavigation(id) {
|
|
16
|
-
const res = await this.client.get(`/navigations/${id}
|
|
15
|
+
async getNavigation(id, options) {
|
|
16
|
+
const res = await this.client.get(`/navigations/${id}`, options);
|
|
17
17
|
const navigation = res.data;
|
|
18
18
|
const topLevelItems = navigation.items.filter((item) => item.parent_id === null);
|
|
19
19
|
topLevelItems.forEach((item) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Page } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class PageService extends BaseService {
|
|
4
|
-
getPages(): Promise<Page[]>;
|
|
5
|
-
getPage(id: string): Promise<Page | null>;
|
|
6
|
-
getPageBySlug(slug: string): Promise<Page | null>;
|
|
7
|
-
getHomePage(): Promise<Page | null>;
|
|
8
|
-
getPageByPathname(pathname: string): Promise<Page | null>;
|
|
4
|
+
getPages(options?: RequestInit): Promise<Page[]>;
|
|
5
|
+
getPage(id: string, options?: RequestInit): Promise<Page | null>;
|
|
6
|
+
getPageBySlug(slug: string, options?: RequestInit): Promise<Page | null>;
|
|
7
|
+
getHomePage(options?: RequestInit): Promise<Page | null>;
|
|
8
|
+
getPageByPathname(pathname: string, options?: RequestInit): Promise<Page | null>;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=pages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../src/endpoints/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../../src/endpoints/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAY,SAAQ,WAAW;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAKhD,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAQhE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAQxE,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAQxD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;CAOvF"}
|
package/dist/endpoints/pages.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class PageService extends BaseService {
|
|
3
|
-
async getPages() {
|
|
4
|
-
const res = await this.client.get("/pages");
|
|
3
|
+
async getPages(options) {
|
|
4
|
+
const res = await this.client.get("/pages", options);
|
|
5
5
|
return res.data;
|
|
6
6
|
}
|
|
7
|
-
async getPage(id) {
|
|
8
|
-
const res = await this.client.get(`/pages/${id}
|
|
7
|
+
async getPage(id, options) {
|
|
8
|
+
const res = await this.client.get(`/pages/${id}`, options);
|
|
9
9
|
if (!res.data || res.data.length === 0) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
12
|
return res.data[0];
|
|
13
13
|
}
|
|
14
|
-
async getPageBySlug(slug) {
|
|
15
|
-
const res = await this.client.get(`/pages?filter[slug]=${slug}
|
|
14
|
+
async getPageBySlug(slug, options) {
|
|
15
|
+
const res = await this.client.get(`/pages?filter[slug]=${slug}`, options);
|
|
16
16
|
if (!res.data || res.data.length === 0) {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
19
|
return res.data[0];
|
|
20
20
|
}
|
|
21
|
-
async getHomePage() {
|
|
22
|
-
const res = await this.client.get("/pages?filter[slug]=/");
|
|
21
|
+
async getHomePage(options) {
|
|
22
|
+
const res = await this.client.get("/pages?filter[slug]=/", options);
|
|
23
23
|
if (!res.data || res.data.length === 0) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
return res.data[0];
|
|
27
27
|
}
|
|
28
|
-
async getPageByPathname(pathname) {
|
|
29
|
-
const res = await this.client.get(`/pages?filter[pathname]=${pathname}
|
|
28
|
+
async getPageByPathname(pathname, options) {
|
|
29
|
+
const res = await this.client.get(`/pages?filter[pathname]=${pathname}`, options);
|
|
30
30
|
if (!res.data || res.data.length === 0) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Press } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class PressService extends BaseService {
|
|
4
|
-
getPress(): Promise<Press[]>;
|
|
4
|
+
getPress(options?: RequestInit): Promise<Press[]>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=press.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../src/endpoints/press.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,QAAQ,
|
|
1
|
+
{"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../src/endpoints/press.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAIxD"}
|
package/dist/endpoints/press.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class PressService extends BaseService {
|
|
3
|
-
async getPress() {
|
|
4
|
-
const { data } = await this.client.get("/press");
|
|
3
|
+
async getPress(options) {
|
|
4
|
+
const { data } = await this.client.get("/press", options);
|
|
5
5
|
return data;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Route } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class RouteService extends BaseService {
|
|
4
|
-
resolve<T = Route>(path: string): Promise<T>;
|
|
4
|
+
resolve<T = Route>(path: string, options?: RequestInit): Promise<T>;
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/endpoints/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/endpoints/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,YAAa,SAAQ,WAAW;IACrC,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;CAI1E"}
|
package/dist/endpoints/routes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class RouteService extends BaseService {
|
|
3
|
-
async resolve(path) {
|
|
3
|
+
async resolve(path, options) {
|
|
4
4
|
const query = new URLSearchParams({ path }).toString();
|
|
5
|
-
return this.client.get(`/routes/resolve?${query}
|
|
5
|
+
return this.client.get(`/routes/resolve?${query}`, options);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Website } from "../types/index";
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
export declare class WebsiteService extends BaseService {
|
|
4
|
-
getWebsite(): Promise<Website>;
|
|
5
|
-
routes(): Promise<string[]>;
|
|
4
|
+
getWebsite(options?: RequestInit): Promise<Website>;
|
|
5
|
+
routes(options?: RequestInit): Promise<string[]>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=website.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,
|
|
1
|
+
{"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../src/endpoints/website.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,cAAe,SAAQ,WAAW;IACvC,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnD,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAKvD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BaseService } from "./base.js";
|
|
2
2
|
export class WebsiteService extends BaseService {
|
|
3
|
-
async getWebsite() {
|
|
4
|
-
const res = await this.client.get("/websites");
|
|
3
|
+
async getWebsite(options) {
|
|
4
|
+
const res = await this.client.get("/websites", options);
|
|
5
5
|
return res.data[0];
|
|
6
6
|
}
|
|
7
|
-
async routes() {
|
|
8
|
-
const website = await this.getWebsite();
|
|
9
|
-
return this.client.get(`/websites/${website.id}/routes
|
|
7
|
+
async routes(options) {
|
|
8
|
+
const website = await this.getWebsite(options);
|
|
9
|
+
return this.client.get(`/websites/${website.id}/routes`, options);
|
|
10
10
|
}
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antlur/backstage",
|
|
3
3
|
"author": "Anthony Holmes",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.7",
|
|
5
5
|
"description": "A simple client for Backstage CMS",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"axios": "^1.13.2",
|
|
64
63
|
"commander": "^13.1.0",
|
|
65
64
|
"dotenv": "^16.4.7",
|
|
66
65
|
"schema-dts": "^1.1.2",
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from "axios";
|
|
2
1
|
import { getGlobalConfig, BackstageUserConfig } from "./config.js";
|
|
3
2
|
import { AlertService } from "./endpoints/alerts.js";
|
|
4
3
|
import { BlocksService } from "./endpoints/blocks.js";
|
|
@@ -15,7 +14,10 @@ import { WebsiteService } from "./endpoints/website.js";
|
|
|
15
14
|
import { MediaService } from "./endpoints/media.js";
|
|
16
15
|
|
|
17
16
|
export class BackstageClient {
|
|
18
|
-
private
|
|
17
|
+
private baseURL: string;
|
|
18
|
+
private token: string;
|
|
19
|
+
private accountId: string;
|
|
20
|
+
private onError?: (error: Error) => void;
|
|
19
21
|
|
|
20
22
|
// Service Instances
|
|
21
23
|
public readonly alerts: AlertService;
|
|
@@ -50,44 +52,10 @@ export class BackstageClient {
|
|
|
50
52
|
throw new Error("No accountId found in the Backstage config. Please provide an accountId.");
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
headers: {
|
|
58
|
-
Authorization: `Bearer ${token}`,
|
|
59
|
-
"X-Account-ID": finalConfig.accountId,
|
|
60
|
-
Accept: "application/json",
|
|
61
|
-
"Content-Type": "application/json",
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Add request interceptor for debugging
|
|
66
|
-
this.instance.interceptors.request.use((requestConfig) => {
|
|
67
|
-
// console.log("Request:", {
|
|
68
|
-
// method: requestConfig.method,
|
|
69
|
-
// url: requestConfig.url,
|
|
70
|
-
// headers: requestConfig.headers,
|
|
71
|
-
// data: requestConfig.data,
|
|
72
|
-
// });
|
|
73
|
-
return requestConfig;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Add response interceptor for debugging
|
|
77
|
-
this.instance.interceptors.response.use(
|
|
78
|
-
(response) => response,
|
|
79
|
-
(error) => {
|
|
80
|
-
// console.error("API Error:", {
|
|
81
|
-
// status: error.response?.status,
|
|
82
|
-
// method: error.config?.method,
|
|
83
|
-
// url: error.config?.url,
|
|
84
|
-
// headers: error.config?.headers,
|
|
85
|
-
// data: error.response?.data,
|
|
86
|
-
// });
|
|
87
|
-
if (onError) onError(error);
|
|
88
|
-
return Promise.reject(error);
|
|
89
|
-
}
|
|
90
|
-
);
|
|
55
|
+
this.baseURL = finalConfig.baseURL!;
|
|
56
|
+
this.token = finalConfig.token;
|
|
57
|
+
this.accountId = finalConfig.accountId;
|
|
58
|
+
this.onError = finalConfig.onError;
|
|
91
59
|
|
|
92
60
|
// Initialize service instances
|
|
93
61
|
this.alerts = new AlertService(this);
|
|
@@ -105,32 +73,59 @@ export class BackstageClient {
|
|
|
105
73
|
this.website = new WebsiteService(this);
|
|
106
74
|
}
|
|
107
75
|
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
76
|
+
private async request<T = unknown>(method: string, url: string, data?: unknown, options?: RequestInit): Promise<T> {
|
|
77
|
+
const fullUrl = `${this.baseURL}${url}`;
|
|
78
|
+
const defaultHeaders: Record<string, string> = {
|
|
79
|
+
Authorization: `Bearer ${this.token}`,
|
|
80
|
+
"X-Account-ID": this.accountId,
|
|
81
|
+
Accept: "application/json",
|
|
82
|
+
"Content-Type": "application/json",
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const fetchOptions: RequestInit = {
|
|
86
|
+
method,
|
|
87
|
+
headers: { ...defaultHeaders, ...options?.headers },
|
|
88
|
+
...options,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (data && !fetchOptions.body && (method === "POST" || method === "PUT" || method === "PATCH")) {
|
|
92
|
+
fetchOptions.body = JSON.stringify(data);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const response = await fetch(fullUrl, fetchOptions);
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
const errorText = await response.text();
|
|
99
|
+
const error = new Error(`HTTP ${response.status}: ${response.statusText} - ${errorText}`);
|
|
100
|
+
(error as any).status = response.status;
|
|
101
|
+
(error as any).response = { status: response.status, data: errorText };
|
|
102
|
+
if (this.onError) this.onError(error);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
return await response.json();
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (this.onError) this.onError(error as Error);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
public async
|
|
114
|
-
|
|
115
|
-
return response.data;
|
|
112
|
+
public async get<T = unknown>(url: string, options?: RequestInit): Promise<T> {
|
|
113
|
+
return this.request<T>("GET", url, undefined, options);
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
public async
|
|
119
|
-
|
|
120
|
-
return response.data;
|
|
116
|
+
public async post<T = unknown>(url: string, data?: unknown, options?: RequestInit): Promise<T> {
|
|
117
|
+
return this.request<T>("POST", url, data, options);
|
|
121
118
|
}
|
|
122
119
|
|
|
123
|
-
public async
|
|
124
|
-
|
|
125
|
-
return response.data;
|
|
120
|
+
public async put<T = unknown>(url: string, data?: unknown, options?: RequestInit): Promise<T> {
|
|
121
|
+
return this.request<T>("PUT", url, data, options);
|
|
126
122
|
}
|
|
127
123
|
|
|
128
|
-
public async
|
|
129
|
-
|
|
130
|
-
return response.data;
|
|
124
|
+
public async patch<T = unknown>(url: string, data?: unknown, options?: RequestInit): Promise<T> {
|
|
125
|
+
return this.request<T>("PATCH", url, data, options);
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
public
|
|
134
|
-
return this.
|
|
128
|
+
public async delete<T = unknown>(url: string, options?: RequestInit): Promise<T> {
|
|
129
|
+
return this.request<T>("DELETE", url, undefined, options);
|
|
135
130
|
}
|
|
136
131
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AxiosError } from "axios";
|
|
2
1
|
import type { BlockDefinition } from "./studio/types/index.js";
|
|
3
2
|
|
|
4
3
|
const DEFAULT_BASE_URL = "https://bckstg.app/api";
|
|
@@ -9,7 +8,7 @@ export interface BackstageUserConfig {
|
|
|
9
8
|
baseURL?: string;
|
|
10
9
|
blocks?: BlockDefinition<any>[] | undefined;
|
|
11
10
|
layouts?: any[] | undefined;
|
|
12
|
-
onError?: (error:
|
|
11
|
+
onError?: (error: Error) => void;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
let globalConfig: BackstageUserConfig = {
|
package/src/endpoints/alerts.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { ApiCollectionResponse, Alert } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class AlertService extends BaseService {
|
|
5
|
-
async getAlerts(): Promise<Alert[]> {
|
|
6
|
-
const { data } = await this.client.get<ApiCollectionResponse<Alert>>("/alerts");
|
|
5
|
+
async getAlerts(options?: RequestInit): Promise<Alert[]> {
|
|
6
|
+
const { data } = await this.client.get<ApiCollectionResponse<Alert>>("/alerts", options);
|
|
7
7
|
return data;
|
|
8
8
|
}
|
|
9
9
|
}
|
package/src/endpoints/blocks.ts
CHANGED
|
@@ -13,17 +13,17 @@ export class BlocksService extends BaseService {
|
|
|
13
13
|
* Get all blocks
|
|
14
14
|
* @todo Implement this method when the API endpoint is available
|
|
15
15
|
*/
|
|
16
|
-
async all() {
|
|
16
|
+
async all(options?: RequestInit) {
|
|
17
17
|
throw new Error("Method not implemented. Please use the Backstage API documentation for available endpoints.");
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async create(params: BlockParams) {
|
|
21
|
-
const res = await this.client.post<ApiSingleResponse<BlockParams>>("/blocks", params);
|
|
20
|
+
async create(params: BlockParams, options?: RequestInit) {
|
|
21
|
+
const res = await this.client.post<ApiSingleResponse<BlockParams>>("/blocks", params, options);
|
|
22
22
|
return res.data;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
async update(id: string, params: BlockParams) {
|
|
26
|
-
const res = await this.client.put<ApiSingleResponse<BlockParams>>(`/blocks/${id}`, params);
|
|
25
|
+
async update(id: string, params: BlockParams, options?: RequestInit) {
|
|
26
|
+
const res = await this.client.put<ApiSingleResponse<BlockParams>>(`/blocks/${id}`, params, options);
|
|
27
27
|
return res.data;
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/endpoints/events.ts
CHANGED
|
@@ -2,21 +2,21 @@ import type { ApiCollectionResponse, Event } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class EventService extends BaseService {
|
|
5
|
-
async getEvents(): Promise<Event[]> {
|
|
6
|
-
const { data } = await this.client.get<ApiCollectionResponse<Event>>("/events");
|
|
5
|
+
async getEvents(options?: RequestInit): Promise<Event[]> {
|
|
6
|
+
const { data } = await this.client.get<ApiCollectionResponse<Event>>("/events", options);
|
|
7
7
|
return data;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
async getEvent(id: string): Promise<Event | null> {
|
|
11
|
-
const { data } = await this.client.get<ApiCollectionResponse<Event>>(`/events?filter[id]=${id}
|
|
10
|
+
async getEvent(id: string, options?: RequestInit): Promise<Event | null> {
|
|
11
|
+
const { data } = await this.client.get<ApiCollectionResponse<Event>>(`/events?filter[id]=${id}`, options);
|
|
12
12
|
if (!data || data.length === 0) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
return data[0];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async getEventBySlug(slug: string): Promise<Event | null> {
|
|
19
|
-
const { data } = await this.client.get<ApiCollectionResponse<Event>>(`/events?filter[slug]=${slug}
|
|
18
|
+
async getEventBySlug(slug: string, options?: RequestInit): Promise<Event | null> {
|
|
19
|
+
const { data } = await this.client.get<ApiCollectionResponse<Event>>(`/events?filter[slug]=${slug}`, options);
|
|
20
20
|
if (!data || data.length === 0) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
@@ -2,8 +2,8 @@ import type { ApiCollectionResponse, InstagramPost } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class InstagramService extends BaseService {
|
|
5
|
-
async latest(): Promise<InstagramPost[]> {
|
|
6
|
-
const { data } = await this.client.get<ApiCollectionResponse<InstagramPost>>("/instagram-posts");
|
|
5
|
+
async latest(options?: RequestInit): Promise<InstagramPost[]> {
|
|
6
|
+
const { data } = await this.client.get<ApiCollectionResponse<InstagramPost>>("/instagram-posts", options);
|
|
7
7
|
return data;
|
|
8
8
|
}
|
|
9
9
|
}
|
package/src/endpoints/layouts.ts
CHANGED
|
@@ -8,15 +8,15 @@ interface LayoutParams {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class LayoutService extends BaseService {
|
|
11
|
-
async all() {}
|
|
11
|
+
async all(options?: RequestInit) {}
|
|
12
12
|
|
|
13
|
-
async create({ name, slug, schema }: LayoutParams) {
|
|
14
|
-
const res = await this.client.post<ApiSingleResponse<LayoutParams>>("/layouts", { name, slug, schema });
|
|
13
|
+
async create({ name, slug, schema }: LayoutParams, options?: RequestInit) {
|
|
14
|
+
const res = await this.client.post<ApiSingleResponse<LayoutParams>>("/layouts", { name, slug, schema }, options);
|
|
15
15
|
return res.data;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async update(id: string, { name, slug, schema }: LayoutParams) {
|
|
19
|
-
const res = await this.client.put<ApiSingleResponse<LayoutParams>>(`/layouts/${id}`, { name, slug, schema });
|
|
18
|
+
async update(id: string, { name, slug, schema }: LayoutParams, options?: RequestInit) {
|
|
19
|
+
const res = await this.client.put<ApiSingleResponse<LayoutParams>>(`/layouts/${id}`, { name, slug, schema }, options);
|
|
20
20
|
return res.data;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -2,15 +2,15 @@ import type { ApiCollectionResponse, Location } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class LocationService extends BaseService {
|
|
5
|
-
async getLocations(): Promise<Location[]> {
|
|
6
|
-
const res = await this.client.get<ApiCollectionResponse<Location>>("/locations");
|
|
5
|
+
async getLocations(options?: RequestInit): Promise<Location[]> {
|
|
6
|
+
const res = await this.client.get<ApiCollectionResponse<Location>>("/locations", options);
|
|
7
7
|
let locations = res.data;
|
|
8
8
|
locations = locations.sort((a, b) => a.name.localeCompare(b.name));
|
|
9
9
|
return locations;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
async getLocationBySlug(slug: string): Promise<Location | null> {
|
|
13
|
-
const res = await this.client.get<ApiCollectionResponse<Location>>(`/locations?filter[slug]=${slug}
|
|
12
|
+
async getLocationBySlug(slug: string, options?: RequestInit): Promise<Location | null> {
|
|
13
|
+
const res = await this.client.get<ApiCollectionResponse<Location>>(`/locations?filter[slug]=${slug}`, options);
|
|
14
14
|
const data = res.data;
|
|
15
15
|
|
|
16
16
|
if (!data || data.length === 0) {
|
package/src/endpoints/media.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { ApiCollectionResponse, Media } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class MediaService extends BaseService {
|
|
5
|
-
async all() {
|
|
6
|
-
const res = await this.client.get<ApiCollectionResponse<Media>>("/media");
|
|
5
|
+
async all(options?: RequestInit) {
|
|
6
|
+
const res = await this.client.get<ApiCollectionResponse<Media>>("/media", options);
|
|
7
7
|
return res.data;
|
|
8
8
|
}
|
|
9
9
|
}
|
package/src/endpoints/menus.ts
CHANGED
|
@@ -2,14 +2,14 @@ import type { ApiCollectionResponse, Menu } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class MenuService extends BaseService {
|
|
5
|
-
async getMenus(): Promise<Menu[]> {
|
|
6
|
-
const res = await this.client.get<ApiCollectionResponse<Menu>>("/menus");
|
|
5
|
+
async getMenus(options?: RequestInit): Promise<Menu[]> {
|
|
6
|
+
const res = await this.client.get<ApiCollectionResponse<Menu>>("/menus", options);
|
|
7
7
|
const menus = res.data;
|
|
8
8
|
return menus;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
async getMenu(id: string) {
|
|
12
|
-
const res = await this.client.get<ApiCollectionResponse<Menu>>(`/menus?filter[id]=${id}&include=categories.items
|
|
11
|
+
async getMenu(id: string, options?: RequestInit) {
|
|
12
|
+
const res = await this.client.get<ApiCollectionResponse<Menu>>(`/menus?filter[id]=${id}&include=categories.items`, options);
|
|
13
13
|
const data = res.data;
|
|
14
14
|
|
|
15
15
|
if (Array.isArray(data) && data.length > 0) {
|
|
@@ -19,9 +19,9 @@ export class MenuService extends BaseService {
|
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async getMenuBySlug(slug: string) {
|
|
22
|
+
async getMenuBySlug(slug: string, options?: RequestInit) {
|
|
23
23
|
const res = await this.client.get<ApiCollectionResponse<Menu>>(
|
|
24
|
-
`/menus?filter[slug]=${slug}&include=categories.items
|
|
24
|
+
`/menus?filter[slug]=${slug}&include=categories.items`, options
|
|
25
25
|
);
|
|
26
26
|
const data = res.data;
|
|
27
27
|
|
|
@@ -2,25 +2,25 @@ import type { ApiSingleResponse, ApiCollectionResponse, Navigation } from "../ty
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class NavigationService extends BaseService {
|
|
5
|
-
async getNavigations(): Promise<Navigation[]> {
|
|
6
|
-
const res = await this.client.get<ApiCollectionResponse<Navigation>>("/navigations");
|
|
5
|
+
async getNavigations(options?: RequestInit): Promise<Navigation[]> {
|
|
6
|
+
const res = await this.client.get<ApiCollectionResponse<Navigation>>("/navigations", options);
|
|
7
7
|
const navigations = res.data;
|
|
8
8
|
|
|
9
9
|
return Promise.all(
|
|
10
10
|
navigations.map(async (navigation: any) => {
|
|
11
|
-
const res = await this.client.get<ApiCollectionResponse<Navigation>>("/navigations/" + navigation.id);
|
|
11
|
+
const res = await this.client.get<ApiCollectionResponse<Navigation>>("/navigations/" + navigation.id, options);
|
|
12
12
|
return res.data[0];
|
|
13
13
|
})
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async getDefaultNavigation(): Promise<Navigation> {
|
|
18
|
-
const navigations = await this.getNavigations();
|
|
17
|
+
async getDefaultNavigation(options?: RequestInit): Promise<Navigation> {
|
|
18
|
+
const navigations = await this.getNavigations(options);
|
|
19
19
|
return navigations[0];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async getNavigation(id: string): Promise<Navigation> {
|
|
23
|
-
const res = await this.client.get<ApiSingleResponse<Navigation>>(`/navigations/${id}
|
|
22
|
+
async getNavigation(id: string, options?: RequestInit): Promise<Navigation> {
|
|
23
|
+
const res = await this.client.get<ApiSingleResponse<Navigation>>(`/navigations/${id}`, options);
|
|
24
24
|
const navigation = res.data;
|
|
25
25
|
|
|
26
26
|
const topLevelItems = navigation.items.filter((item: any) => item.parent_id === null);
|
package/src/endpoints/pages.ts
CHANGED
|
@@ -2,37 +2,37 @@ import type { ApiCollectionResponse, Page } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class PageService extends BaseService {
|
|
5
|
-
async getPages(): Promise<Page[]> {
|
|
6
|
-
const res = await this.client.get<ApiCollectionResponse<Page>>("/pages");
|
|
5
|
+
async getPages(options?: RequestInit): Promise<Page[]> {
|
|
6
|
+
const res = await this.client.get<ApiCollectionResponse<Page>>("/pages", options);
|
|
7
7
|
return res.data;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
async getPage(id: string): Promise<Page | null> {
|
|
11
|
-
const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages/${id}
|
|
10
|
+
async getPage(id: string, options?: RequestInit): Promise<Page | null> {
|
|
11
|
+
const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages/${id}`, options);
|
|
12
12
|
if (!res.data || res.data.length === 0) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
return res.data[0];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async getPageBySlug(slug: string): Promise<Page | null> {
|
|
19
|
-
const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages?filter[slug]=${slug}
|
|
18
|
+
async getPageBySlug(slug: string, options?: RequestInit): Promise<Page | null> {
|
|
19
|
+
const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages?filter[slug]=${slug}`, options);
|
|
20
20
|
if (!res.data || res.data.length === 0) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
return res.data[0];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async getHomePage(): Promise<Page | null> {
|
|
27
|
-
const res = await this.client.get<ApiCollectionResponse<Page>>("/pages?filter[slug]=/");
|
|
26
|
+
async getHomePage(options?: RequestInit): Promise<Page | null> {
|
|
27
|
+
const res = await this.client.get<ApiCollectionResponse<Page>>("/pages?filter[slug]=/", options);
|
|
28
28
|
if (!res.data || res.data.length === 0) {
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
return res.data[0];
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async getPageByPathname(pathname: string): Promise<Page | null> {
|
|
35
|
-
const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages?filter[pathname]=${pathname}
|
|
34
|
+
async getPageByPathname(pathname: string, options?: RequestInit): Promise<Page | null> {
|
|
35
|
+
const res = await this.client.get<ApiCollectionResponse<Page>>(`/pages?filter[pathname]=${pathname}`, options);
|
|
36
36
|
if (!res.data || res.data.length === 0) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
package/src/endpoints/press.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { ApiCollectionResponse, Press } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class PressService extends BaseService {
|
|
5
|
-
async getPress(): Promise<Press[]> {
|
|
6
|
-
const { data } = await this.client.get<ApiCollectionResponse<Press>>("/press");
|
|
5
|
+
async getPress(options?: RequestInit): Promise<Press[]> {
|
|
6
|
+
const { data } = await this.client.get<ApiCollectionResponse<Press>>("/press", options);
|
|
7
7
|
return data;
|
|
8
8
|
}
|
|
9
9
|
}
|
package/src/endpoints/routes.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { Route } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class RouteService extends BaseService {
|
|
5
|
-
async resolve<T = Route>(path: string): Promise<T> {
|
|
5
|
+
async resolve<T = Route>(path: string, options?: RequestInit): Promise<T> {
|
|
6
6
|
const query = new URLSearchParams({ path }).toString();
|
|
7
|
-
return this.client.get<T>(`/routes/resolve?${query}
|
|
7
|
+
return this.client.get<T>(`/routes/resolve?${query}`, options);
|
|
8
8
|
}
|
|
9
9
|
}
|
package/src/endpoints/website.ts
CHANGED
|
@@ -2,14 +2,14 @@ import type { ApiCollectionResponse, Website } from "../types/index";
|
|
|
2
2
|
import { BaseService } from "./base.js";
|
|
3
3
|
|
|
4
4
|
export class WebsiteService extends BaseService {
|
|
5
|
-
async getWebsite(): Promise<Website> {
|
|
6
|
-
const res = await this.client.get<ApiCollectionResponse<Website>>("/websites");
|
|
5
|
+
async getWebsite(options?: RequestInit): Promise<Website> {
|
|
6
|
+
const res = await this.client.get<ApiCollectionResponse<Website>>("/websites", options);
|
|
7
7
|
return res.data[0];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
async routes(): Promise<string[]> {
|
|
11
|
-
const website = await this.getWebsite();
|
|
10
|
+
async routes(options?: RequestInit): Promise<string[]> {
|
|
11
|
+
const website = await this.getWebsite(options);
|
|
12
12
|
|
|
13
|
-
return this.client.get<string[]>(`/websites/${website.id}/routes
|
|
13
|
+
return this.client.get<string[]>(`/websites/${website.id}/routes`, options);
|
|
14
14
|
}
|
|
15
15
|
}
|