@supernova-studio/client 0.57.6 → 0.57.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/client",
3
- "version": "0.57.6",
3
+ "version": "0.57.8",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
package/src/api/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WorkspacesEndpoint } from "./endpoints";
1
+ import { CodegenEndpoint, WorkspacesEndpoint } from "./endpoints";
2
2
  import { DesignSystemsEndpoint } from "./endpoints/design-system";
3
3
  import { UsersEndpoint } from "./endpoints/users";
4
4
  import { RequestExecutor } from "./transport/request-executor";
@@ -12,6 +12,7 @@ export class SupernovaApiClient {
12
12
  readonly users: UsersEndpoint;
13
13
  readonly workspaces: WorkspacesEndpoint;
14
14
  readonly designSystems: DesignSystemsEndpoint;
15
+ readonly codegen: CodegenEndpoint;
15
16
 
16
17
  constructor(config: SupernovaApiClientConfig) {
17
18
  const requestExecutor = new RequestExecutor({
@@ -22,5 +23,6 @@ export class SupernovaApiClient {
22
23
  this.users = new UsersEndpoint(requestExecutor);
23
24
  this.workspaces = new WorkspacesEndpoint(requestExecutor);
24
25
  this.designSystems = new DesignSystemsEndpoint(requestExecutor);
26
+ this.codegen = new CodegenEndpoint(requestExecutor);
25
27
  }
26
28
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ nullishToOptional,
2
3
  PulsarContributionConfigurationProperty,
3
4
  PulsarContributionVariant,
4
5
  PulsarCustomBlock,
@@ -13,6 +14,10 @@ export const DTOExporterType = z.enum(["documentation", "code"]);
13
14
  export const DTOExporterSource = z.enum(["git", "upload"]);
14
15
  export const DTOExporterMembershipRole = z.enum(["Owner", "OwnerArchived", "User"]);
15
16
 
17
+ export const DTOExporterListQuery = z.object({
18
+ limit: z.coerce.number().optional(),
19
+ });
20
+
16
21
  export const DTOExporter = z.object({
17
22
  id: z.string(),
18
23
  name: z.string(),
@@ -30,9 +35,9 @@ export const DTOExporter = z.object({
30
35
 
31
36
  source: DTOExporterSource,
32
37
 
33
- gitUrl: z.string().optional(),
34
- gitBranch: z.string().optional(),
35
- gitDirectory: z.string().optional(),
38
+ gitUrl: nullishToOptional(z.string()),
39
+ gitBranch: nullishToOptional(z.string()),
40
+ gitDirectory: nullishToOptional(z.string()),
36
41
  });
37
42
 
38
43
  export const DTOExporterMembership = z.object({
@@ -46,12 +51,19 @@ export const DTOExporterCreateOutput = z.object({
46
51
  membership: DTOExporterMembership,
47
52
  });
48
53
 
54
+ export const DTOExporterListResponse = z.object({
55
+ exporters: DTOExporter.array(),
56
+ membership: DTOExporterMembership.array(),
57
+ });
58
+
59
+ export type DTOExporterListQuery = z.infer<typeof DTOExporterListQuery>;
49
60
  export type DTOExporterType = z.infer<typeof DTOExporterType>;
50
61
  export type DTOExporterSource = z.infer<typeof DTOExporterSource>;
51
62
  export type DTOExporterMembershipRole = z.infer<typeof DTOExporterMembershipRole>;
52
63
  export type DTOExporter = z.infer<typeof DTOExporter>;
53
64
  export type DTOExporterMembership = z.infer<typeof DTOExporterMembership>;
54
65
  export type DTOExporterCreateOutput = z.infer<typeof DTOExporterCreateOutput>;
66
+ export type DTOExporterListResponse = z.infer<typeof DTOExporterListResponse>;
55
67
 
56
68
  //
57
69
  // Write
@@ -2,6 +2,12 @@ import { ExportDestinationsMap, PipelineEventType } from "@supernova-studio/mode
2
2
  import { z } from "zod";
3
3
  import { DTOExportJob } from "./job";
4
4
 
5
+ export const DTOPipelineListQuery = z.object({
6
+ designSystemId: z.string().optional(),
7
+ exporterId: z.string().optional(),
8
+ latestJobsLimit: z.coerce.number().optional(),
9
+ });
10
+
5
11
  export const DTOPipeline = z.object({
6
12
  id: z.string(),
7
13
  name: z.string(),
@@ -20,4 +26,15 @@ export const DTOPipeline = z.object({
20
26
  latestJobs: DTOExportJob.array(),
21
27
  });
22
28
 
29
+ export const DTOPipelineListResponse = z.object({
30
+ pipelines: DTOPipeline.array(),
31
+ });
32
+
33
+ export const DTOPipelineResponse = z.object({
34
+ pipeline: DTOPipeline,
35
+ });
36
+
37
+ export type DTOPipelineListQuery = z.infer<typeof DTOPipelineListQuery>;
23
38
  export type DTOPipeline = z.infer<typeof DTOPipeline>;
39
+ export type DTOPipelineResponse = z.infer<typeof DTOPipelineResponse>;
40
+ export type DTOPipelineListResponse = z.infer<typeof DTOPipelineListResponse>;
@@ -0,0 +1,13 @@
1
+ import { RequestExecutor } from "../../transport";
2
+ import { ExportersEndpoint } from "./exporters";
3
+ import { PipelinesEndpoint } from "./pipelines";
4
+
5
+ export class CodegenEndpoint {
6
+ readonly exporters: ExportersEndpoint;
7
+ readonly pipelines: PipelinesEndpoint;
8
+
9
+ constructor(private readonly requestExecutor: RequestExecutor) {
10
+ this.pipelines = new PipelinesEndpoint(requestExecutor);
11
+ this.exporters = new ExportersEndpoint(requestExecutor);
12
+ }
13
+ }
@@ -0,0 +1,18 @@
1
+ import { DTOExporterListQuery, DTOExporterListResponse } from "../../dto";
2
+ import { RequestExecutor } from "../../transport";
3
+
4
+ export class ExportersEndpoint {
5
+ constructor(private readonly requestExecutor: RequestExecutor) {}
6
+
7
+ list(workspaceId: string, query: DTOExporterListQuery) {
8
+ const queryWithStrings = Object.fromEntries(
9
+ Object.entries(query)
10
+ .filter(e => !!e[1])
11
+ .map(([k, v]) => [k, v.toString()])
12
+ );
13
+
14
+ return this.requestExecutor.json(`/codegen/workspaces/${workspaceId}/exporters`, DTOExporterListResponse, {
15
+ query: new URLSearchParams(queryWithStrings),
16
+ });
17
+ }
18
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./codegen";
2
+ export * from "./exporters";
3
+ export * from "./pipelines";
@@ -0,0 +1,37 @@
1
+ import { DTOExportJobResponse, DTOPipelineListQuery, DTOPipelineListResponse, DTOPipelineResponse } from "../../dto";
2
+ import { DTOPipelineCreateBody, DTOPipelineTriggerBody } from "../../payloads";
3
+ import { RequestExecutor } from "../../transport";
4
+
5
+ export class PipelinesEndpoint {
6
+ constructor(private readonly requestExecutor: RequestExecutor) {}
7
+
8
+ list(workspaceId: string, query: DTOPipelineListQuery) {
9
+ const queryWithStrings = Object.fromEntries(
10
+ Object.entries(query)
11
+ .filter(e => !!e[1])
12
+ .map(([k, v]) => [k, v.toString()])
13
+ );
14
+
15
+ return this.requestExecutor.json(`/codegen/workspaces/${workspaceId}/pipelines`, DTOPipelineListResponse, {
16
+ query: new URLSearchParams(queryWithStrings),
17
+ });
18
+ }
19
+
20
+ create(workspaceId: string, payload: DTOPipelineCreateBody) {
21
+ return this.requestExecutor.json(`/codegen/workspaces/${workspaceId}/pipelines`, DTOPipelineResponse, {
22
+ body: payload,
23
+ method: "POST",
24
+ });
25
+ }
26
+
27
+ trigger(workspaceId: string, pipelineId: string, payload: DTOPipelineTriggerBody) {
28
+ return this.requestExecutor.json(
29
+ `/codegen/workspaces/${workspaceId}/pipelines/${pipelineId}/trigger`,
30
+ DTOExportJobResponse,
31
+ {
32
+ body: payload,
33
+ method: "POST",
34
+ }
35
+ );
36
+ }
37
+ }
@@ -29,7 +29,7 @@ export class DesignSystemsEndpoint {
29
29
  }
30
30
 
31
31
  get(dsId: string) {
32
- return this.requestExecutor.json(`/design-systems/${dsId}`, z.any());
32
+ return this.requestExecutor.json(`/design-systems/${dsId}`, DTODesignSystemResponse);
33
33
  }
34
34
 
35
35
  delete(dsId: string) {
@@ -1,3 +1,4 @@
1
+ export * from "./codegen";
1
2
  export * from "./design-system";
2
3
  export * from "./workspaces";
3
4
  export * from "./token-collections";