@supernova-studio/client 0.55.23 → 0.55.25
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/index.d.mts +94 -55
- package/dist/index.d.ts +94 -55
- package/dist/index.js +70 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +705 -672
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/dto/design-systems/index.ts +1 -0
- package/src/api/dto/design-systems/stats.ts +15 -0
- package/src/api/endpoints/design-system/design-system-versions.ts +4 -1
- package/src/api/endpoints/design-system/versions/index.ts +1 -0
- package/src/api/endpoints/design-system/versions/stats.ts +12 -0
- package/src/api/transport/request-executor.ts +9 -3
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const DTODesignSystemVersionStats = z.object({
|
|
4
|
+
tokens: z.number(),
|
|
5
|
+
designSystemComponents: z.number(),
|
|
6
|
+
assets: z.number(),
|
|
7
|
+
documentationPages: z.number(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const DTODesignSystemVersionStatsQuery = z.object({
|
|
11
|
+
brandId: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type DTODesignSystemVersionStats = z.infer<typeof DTODesignSystemVersionStats>;
|
|
15
|
+
export type DTODesignSystemVersionStatsQuery = z.infer<typeof DTODesignSystemVersionStatsQuery>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DTODesignSystemVersionsListResponse } from "../../dto";
|
|
2
2
|
import { RequestExecutor } from "../../transport/request-executor";
|
|
3
|
-
import { TokensEndpoint } from "./versions";
|
|
3
|
+
import { TokensEndpoint, VersionStatsEndpoint } from "./versions";
|
|
4
4
|
import { BrandsEndpoint } from "./versions/brands";
|
|
5
5
|
import { ThemesEndpoint } from "./versions/themes";
|
|
6
6
|
|
|
@@ -8,10 +8,13 @@ export class DesignSystemVersionsEndpoint {
|
|
|
8
8
|
readonly themes: ThemesEndpoint;
|
|
9
9
|
readonly brands: BrandsEndpoint;
|
|
10
10
|
readonly tokens: TokensEndpoint;
|
|
11
|
+
readonly stats: VersionStatsEndpoint;
|
|
12
|
+
|
|
11
13
|
constructor(private readonly requestExecutor: RequestExecutor) {
|
|
12
14
|
this.themes = new ThemesEndpoint(requestExecutor);
|
|
13
15
|
this.brands = new BrandsEndpoint(requestExecutor);
|
|
14
16
|
this.tokens = new TokensEndpoint(requestExecutor);
|
|
17
|
+
this.stats = new VersionStatsEndpoint(requestExecutor);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
list(dsId: string) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DTODesignSystemVersionStats, DTODesignSystemVersionStatsQuery } from "../../../dto/design-systems/stats";
|
|
2
|
+
import { RequestExecutor } from "../../../transport/request-executor";
|
|
3
|
+
|
|
4
|
+
export class VersionStatsEndpoint {
|
|
5
|
+
constructor(private readonly requestExecutor: RequestExecutor) {}
|
|
6
|
+
|
|
7
|
+
get(dsId: string, vId: string, query: DTODesignSystemVersionStatsQuery = {}) {
|
|
8
|
+
return this.requestExecutor.json(`/design-systems/${dsId}/versions/${vId}/stats`, DTODesignSystemVersionStats, {
|
|
9
|
+
query: new URLSearchParams(query),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -9,6 +9,7 @@ export type RequestExecutorConfig = {
|
|
|
9
9
|
|
|
10
10
|
export type RequestExecutorJSONRequest = Omit<RequestInit, "body"> & {
|
|
11
11
|
body?: object;
|
|
12
|
+
query?: URLSearchParams;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
const ResponseWrapper = z.object({
|
|
@@ -41,7 +42,7 @@ export class RequestExecutor {
|
|
|
41
42
|
let body: string | undefined;
|
|
42
43
|
if (requestInit.body && typeof requestInit.body === "object") body = JSON.stringify(requestInit.body);
|
|
43
44
|
|
|
44
|
-
const response = await fetch(this.fullUrl(path), {
|
|
45
|
+
const response = await fetch(this.fullUrl(path, requestInit.query), {
|
|
45
46
|
...requestInit,
|
|
46
47
|
headers: {
|
|
47
48
|
...requestInit.headers,
|
|
@@ -70,7 +71,12 @@ export class RequestExecutor {
|
|
|
70
71
|
return responseParseResult.data;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
private fullUrl(path: string): string {
|
|
74
|
-
|
|
74
|
+
private fullUrl(path: string, query: URLSearchParams | undefined): string {
|
|
75
|
+
let url = `https://${this.testServerConfig.host}/api/v2${path}`;
|
|
76
|
+
|
|
77
|
+
const queryString = query?.toString();
|
|
78
|
+
if (queryString) url += `?${queryString}`;
|
|
79
|
+
|
|
80
|
+
return url;
|
|
75
81
|
}
|
|
76
82
|
}
|