@supernova-studio/model 0.46.7 → 0.46.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/model",
3
- "version": "0.46.7",
3
+ "version": "0.46.8",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+ import { PublishedDocEnvironment } from "../dsm";
3
+
4
+ const BITBUCKET_SLUG = /^[-a-zA-Z0-9~]*$/;
5
+ const BITBUCKET_MAX_LENGTH = 64;
6
+
7
+ export const ExporterDestinationDocs = z.object({
8
+ environment: PublishedDocEnvironment,
9
+ });
10
+
11
+ export const ExporterDestinationS3 = z.object({});
12
+
13
+ export const ExporterDestinationGithub = z.object({
14
+ connectionId: z.string(),
15
+ branch: z.string(),
16
+ relativePath: z.string(),
17
+
18
+ // // +
19
+ // userId: z.coerce.string(),
20
+ });
21
+
22
+ export const ExporterDestinationAzure = z.object({
23
+ connectionId: z.string(),
24
+ organizationId: z.string(),
25
+ projectId: z.string(),
26
+ repositoryId: z.string(),
27
+ branch: z.string(),
28
+ relativePath: z.string(),
29
+
30
+ // // +
31
+ // userId: z.coerce.string(),
32
+ // url: z.string(),
33
+ });
34
+
35
+ export const ExporterDestinationGitlab = z.object({
36
+ connectionId: z.string(),
37
+ projectId: z.string(),
38
+ branch: z.string(),
39
+ relativePath: z.string(),
40
+
41
+ // // +
42
+ // userId: z.coerce.string(),
43
+ // url: z.string(),
44
+ });
45
+
46
+ export const ExporterDestinationBitbucket = z.object({
47
+ connectionId: z.string(),
48
+ workspaceSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
49
+ projectKey: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
50
+ repoSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
51
+ branch: z.string(),
52
+ relativePath: z.string(),
53
+
54
+ // // +
55
+ // userId: z.string(),
56
+ // url: z.string(),
57
+ });
58
+
59
+ export const ExportDestinationsMap = z.object({
60
+ webhookUrl: z.string().optional(),
61
+ destinationSnDocs: ExporterDestinationDocs.optional(),
62
+ destinationS3: ExporterDestinationS3.optional(),
63
+ destinationGithub: ExporterDestinationGithub.optional(),
64
+ destinationAzure: ExporterDestinationAzure.optional(),
65
+ destinationGitlab: ExporterDestinationGitlab.optional(),
66
+ destinationBitbucket: ExporterDestinationBitbucket.optional(),
67
+ });
68
+
69
+ export type ExporterDestinationDocs = z.infer<typeof ExporterDestinationDocs>;
70
+ export type ExporterDestinationS3 = z.infer<typeof ExporterDestinationS3>;
71
+ export type ExporterDestinationGithub = z.infer<typeof ExporterDestinationGithub>;
72
+ export type ExporterDestinationAzure = z.infer<typeof ExporterDestinationAzure>;
73
+ export type ExporterDestinationGitlab = z.infer<typeof ExporterDestinationGitlab>;
74
+ export type ExporterDestinationBitbucket = z.infer<typeof ExporterDestinationBitbucket>;
75
+ export type ExportDestinationsMap = z.infer<typeof ExportDestinationsMap>;
@@ -0,0 +1,110 @@
1
+ import { z } from "zod";
2
+ import { PublishedDocEnvironment } from "../dsm";
3
+ import { DbCreateInputOmit, DbUpdate } from "../helpers";
4
+ import { ExportDestinationsMap } from "./export-destinations";
5
+
6
+ //
7
+ // Enums
8
+ //
9
+
10
+ export const ExportJobDestinationType = z.enum(["s3", "webhookUrl", "github", "documentation", "azure", "gitlab"]);
11
+ export const ExportJobStatus = z.enum(["InProgress", "Success", "Failed", "Timeout"]);
12
+ export const ExportJobLogEntryType = z.enum(["success", "info", "warning", "error", "user"]);
13
+
14
+ export type ExportJobDestinationType = z.infer<typeof ExportJobDestinationType>;
15
+ export type ExportJobStatus = z.infer<typeof ExportJobStatus>;
16
+ export type ExportJobLogEntryType = z.infer<typeof ExportJobLogEntryType>;
17
+
18
+ //
19
+ // Results
20
+ //
21
+
22
+ export const ExportJobLogEntry = z.object({
23
+ id: z.string().optional(),
24
+ time: z.coerce.date(),
25
+ type: ExportJobLogEntryType,
26
+ message: z.string(),
27
+ });
28
+
29
+ export const ExportJobPullRequestDestinationResult = z.object({
30
+ pullRequestUrl: z.string(),
31
+ });
32
+
33
+ export const ExportJobS3DestinationResult = z.object({
34
+ bucket: z.string(),
35
+ urlPrefix: z.string().optional(),
36
+ path: z.string(),
37
+ files: z.array(z.string()),
38
+ });
39
+
40
+ export const ExportJobDocsDestinationResult = z.object({
41
+ url: z.string(),
42
+ });
43
+
44
+ export const ExportJobResult = z.object({
45
+ error: z.string().optional(),
46
+ s3: ExportJobS3DestinationResult.optional(),
47
+ github: ExportJobPullRequestDestinationResult.optional(),
48
+ azure: ExportJobPullRequestDestinationResult.optional(),
49
+ gitlab: ExportJobPullRequestDestinationResult.optional(),
50
+ bitbucket: ExportJobPullRequestDestinationResult.optional(),
51
+ sndocs: ExportJobDocsDestinationResult.optional(),
52
+ });
53
+
54
+ export type ExportJobLogEntry = z.infer<typeof ExportJobLogEntry>;
55
+ export type ExportJobPullRequestDestinationResult = z.infer<typeof ExportJobPullRequestDestinationResult>;
56
+ export type ExportJobS3DestinationResult = z.infer<typeof ExportJobS3DestinationResult>;
57
+ export type ExportJobDocsDestinationResult = z.infer<typeof ExportJobDocsDestinationResult>;
58
+ export type ExportJobResult = z.infer<typeof ExportJobResult>;
59
+
60
+ //
61
+ // Job
62
+ //
63
+
64
+ export const ExportJob = z.object({
65
+ id: z.string(),
66
+ createdAt: z.date(),
67
+ finishedAt: z.date().optional(),
68
+ designSystemId: z.string(),
69
+ designSystemVersionId: z.string(),
70
+ workspaceId: z.string(),
71
+ scheduleId: z.string().nullish(),
72
+ exporterId: z.string(),
73
+ brandId: z.string().optional(),
74
+ themeId: z.string().optional(),
75
+ estimatedExecutionTime: z.number().optional(),
76
+ status: ExportJobStatus,
77
+ result: ExportJobResult.optional(),
78
+ createdByUserId: z.string().optional(),
79
+
80
+ // Destinations
81
+ ...ExportDestinationsMap.shape,
82
+ });
83
+
84
+ export type ExportJob = z.infer<typeof ExportJob>;
85
+
86
+ export type CreateExportJob = DbCreateInputOmit<ExportJob>;
87
+ export type UpdateExportJob = Pick<DbUpdate<ExportJob>, "id" | "status" | "result" | "finishedAt">;
88
+
89
+ //
90
+ // Support
91
+ //
92
+
93
+ export const ExportJobFindByFilter = ExportJob.pick({
94
+ exporterId: true,
95
+ designSystemVersionId: true,
96
+ destinations: true,
97
+ createdByUserId: true,
98
+ status: true,
99
+ scheduleId: true,
100
+ designSystemId: true,
101
+ themeId: true,
102
+ brandId: true,
103
+ })
104
+ .extend({
105
+ destinations: z.array(ExportJobDestinationType),
106
+ docsEnvironment: PublishedDocEnvironment,
107
+ })
108
+ .partial();
109
+
110
+ export type ExportJobFindByFilter = z.infer<typeof ExportJobFindByFilter>;
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import { ExporterPropertyValue, PublishedDocEnvironment } from "../../dsm";
3
+
4
+ export const ExportJobDocumentationContext = z.object({
5
+ isSingleVersionDocs: z.boolean(),
6
+ versionSlug: z.string(),
7
+ environment: PublishedDocEnvironment,
8
+ });
9
+
10
+ export const ExportJobContext = z.object({
11
+ apiUrl: z.string(),
12
+ accessToken: z.string(),
13
+ designSystemId: z.string(),
14
+ designSystemVersionId: z.string(),
15
+ brandId: z.string().optional(),
16
+ exporterPackageUrl: z.string(),
17
+ exporterPropertyValues: ExporterPropertyValue.array(),
18
+ documentation: ExportJobDocumentationContext.optional(),
19
+ });
20
+
21
+ export type ExportJobDocumentationContext = z.infer<typeof ExportJobDocumentationContext>;
22
+ export type ExportJobContext = z.infer<typeof ExportJobContext>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const ExporterFunctionPayload = z.object({
4
+ exportJobId: z.string(),
5
+ exportContextId: z.string(),
6
+ designSystemId: z.string(),
7
+ });
8
+
9
+ export type ExporterFunctionPayload = z.infer<typeof ExporterFunctionPayload>;
@@ -0,0 +1,2 @@
1
+ export * from "./export-context";
2
+ export * from "./exporter-payload";
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import { ExportDestinationsMap } from "./export-destinations";
3
+
4
+ export const ExporterScheduleEventType = z.enum(["OnVersionReleased", "OnHeadChanged", "OnSourceUpdated", "None"]);
5
+
6
+ export const ExporterSchedule = z.object({
7
+ id: z.string(),
8
+
9
+ name: z.string(),
10
+ eventType: ExporterScheduleEventType,
11
+ isEnabled: z.boolean(),
12
+
13
+ workspaceId: z.string(),
14
+ designSystemId: z.string(),
15
+ exporterId: z.string(),
16
+
17
+ brandId: z.string().optional(),
18
+ themeId: z.string().optional(),
19
+
20
+ // Destinations
21
+ ...ExportDestinationsMap.shape,
22
+ });
23
+
24
+ export type ExporterScheduleEventType = z.infer<typeof ExporterScheduleEventType>;
25
+ export type ExporterSchedule = z.infer<typeof ExporterSchedule>;
@@ -1,3 +1,4 @@
1
+ export * from "./export-runner";
1
2
  export * from "./export-destinations";
2
3
  export * from "./export-jobs";
3
4
  export * from "./export-schedule";
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  export * from "./auth";
2
2
  export * from "./billing";
3
- export * from "./codegen";
4
3
  export * from "./common";
5
4
  export * from "./custom-domains";
6
5
  export * from "./docs-server";
7
6
  export * from "./dsm";
7
+ export * from "./export";
8
8
  export * from "./feature-flags";
9
9
  export * from "./helpers";
10
10
  export * from "./integrations";
@@ -1,54 +0,0 @@
1
- import { PublishedDocEnvironment } from "../dsm";
2
- import { z } from "zod";
3
-
4
- export const ExporterDestinationSnDocs = z.object({
5
- environment: PublishedDocEnvironment,
6
- });
7
-
8
- export const ExporterDestinationS3 = z.object({});
9
-
10
- export const ExporterDestinationGithub = z.object({
11
- connectionId: z.string(),
12
- url: z.string(),
13
- branch: z.string(),
14
- relativePath: z.string(),
15
- // +
16
- userId: z.coerce.string(),
17
- });
18
-
19
- export const ExporterDestinationAzure = z.object({
20
- connectionId: z.string(),
21
- organizationId: z.string(),
22
- projectId: z.string(),
23
- repositoryId: z.string(),
24
- branch: z.string(),
25
- relativePath: z.string(),
26
- // +
27
- userId: z.coerce.string(),
28
- url: z.string(),
29
- });
30
-
31
- export const ExporterDestinationGitlab = z.object({
32
- connectionId: z.string(),
33
- projectId: z.string(),
34
- branch: z.string(),
35
- relativePath: z.string(),
36
- // +
37
- userId: z.coerce.string(),
38
- url: z.string(),
39
- });
40
-
41
- const BITBUCKET_SLUG = /^[-a-zA-Z0-9~]*$/;
42
- const BITBUCKET_MAX_LENGTH = 64;
43
-
44
- export const ExporterDestinationBitbucket = z.object({
45
- connectionId: z.string(),
46
- workspaceSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
47
- projectKey: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
48
- repoSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
49
- branch: z.string(),
50
- relativePath: z.string(),
51
- // +
52
- userId: z.coerce.string(),
53
- url: z.string(),
54
- });
@@ -1,97 +0,0 @@
1
- import { PublishedDocEnvironment } from "../dsm";
2
- import {
3
- ExporterDestinationSnDocs,
4
- ExporterDestinationS3,
5
- ExporterDestinationGithub,
6
- ExporterDestinationGitlab,
7
- ExporterDestinationBitbucket,
8
- ExporterDestinationAzure,
9
- } from "./export-destinations";
10
- import { z } from "zod";
11
-
12
- export const ExporterJobDestination = z.enum(["s3", "webhookUrl", "github", "documentation", "azure", "gitlab"]);
13
-
14
- export const ExporterJobStatus = z.enum(["InProgress", "Success", "Failed", "Timeout"]);
15
-
16
- export const ExporterJobLogEntryType = z.enum(["success", "info", "warning", "error", "user"]);
17
-
18
- export const ExporterJobLogEntry = z.object({
19
- id: z.string().optional(),
20
- time: z.coerce.date(),
21
- type: ExporterJobLogEntryType,
22
- message: z.string(),
23
- });
24
-
25
- export const ExporterJobResultPullRequestDestination = z.object({
26
- pullRequestUrl: z.string(),
27
- });
28
-
29
- export const ExporterJobResultS3Destination = z.object({
30
- bucket: z.string(),
31
- urlPrefix: z.string().optional(),
32
- path: z.string(),
33
- files: z.array(z.string()),
34
- });
35
-
36
- export const ExporterJobResultDocsDestination = z.object({
37
- url: z.string(),
38
- });
39
-
40
- export const ExporterJobResult = z.object({
41
- error: z.string().optional(),
42
- logs: z.array(ExporterJobLogEntry).optional(),
43
- s3: ExporterJobResultS3Destination.optional(),
44
- github: ExporterJobResultPullRequestDestination.optional(),
45
- azure: ExporterJobResultPullRequestDestination.optional(),
46
- gitlab: ExporterJobResultPullRequestDestination.optional(),
47
- bitbucket: ExporterJobResultPullRequestDestination.optional(),
48
- sndocs: ExporterJobResultDocsDestination.optional(),
49
- });
50
-
51
- export const ExporterJob = z.object({
52
- id: z.coerce.string(),
53
- createdAt: z.coerce.date(),
54
- finishedAt: z.coerce.date().optional(),
55
- designSystemId: z.coerce.string(),
56
- designSystemVersionId: z.coerce.string(),
57
- workspaceId: z.coerce.string(),
58
- scheduleId: z.coerce.string().nullish(),
59
- exporterId: z.coerce.string(),
60
- brandId: z.coerce.string().optional(),
61
- themeId: z.coerce.string().optional(),
62
- estimatedExecutionTime: z.number().optional(),
63
- status: ExporterJobStatus,
64
- result: ExporterJobResult.optional(),
65
- createdByUserId: z.string().optional(),
66
-
67
- // CodegenDestinationsModel
68
- webhookUrl: z.string().optional(),
69
- destinationSnDocs: ExporterDestinationSnDocs.optional(),
70
- destinationS3: ExporterDestinationS3.optional(),
71
- destinationGithub: ExporterDestinationGithub.optional(),
72
- destinationAzure: ExporterDestinationAzure.optional(),
73
- destinationGitlab: ExporterDestinationGitlab.optional(),
74
- destinationBitbucket: ExporterDestinationBitbucket.optional(),
75
- });
76
-
77
- export const ExporterJobFindByFilter = ExporterJob.pick({
78
- exporterId: true,
79
- designSystemVersionId: true,
80
- destinations: true,
81
- createdByUserId: true,
82
- status: true,
83
- scheduleId: true,
84
- designSystemId: true,
85
- themeId: true,
86
- brandId: true,
87
- })
88
- .extend({
89
- destinations: z.array(ExporterJobDestination),
90
- docsEnvironment: PublishedDocEnvironment,
91
- })
92
- .partial();
93
-
94
- export type ExporterJobDestination = z.infer<typeof ExporterJobDestination>;
95
- export type ExporterJobStatus = z.infer<typeof ExporterJobStatus>;
96
- export type ExporterJob = z.infer<typeof ExporterJob>;
97
- export type ExporterJobFindByFilter = z.infer<typeof ExporterJobFindByFilter>;
@@ -1,37 +0,0 @@
1
- import {
2
- ExporterDestinationSnDocs,
3
- ExporterDestinationS3,
4
- ExporterDestinationGithub,
5
- ExporterDestinationGitlab,
6
- ExporterDestinationBitbucket,
7
- ExporterDestinationAzure,
8
- } from "./export-destinations";
9
- import { z } from "zod";
10
-
11
- export const ExporterScheduleEventType = z.enum(["InProgress", "Success", "Failed", "Timeout"]);
12
-
13
- export const ExporterSchedule = z.object({
14
- id: z.coerce.string(),
15
-
16
- name: z.coerce.string(),
17
- eventType: ExporterScheduleEventType,
18
- isEnabled: z.coerce.boolean(),
19
-
20
- workspaceId: z.coerce.string(),
21
- designSystemId: z.coerce.string(),
22
- exporterId: z.coerce.string(),
23
- brandId: z.coerce.string().optional(),
24
- themeId: z.coerce.string().optional(),
25
-
26
- // CodegenDestinationsModel
27
- webhookUrl: z.string().optional(),
28
- destinationSnDocs: ExporterDestinationSnDocs.optional(),
29
- destinationS3: ExporterDestinationS3.optional(),
30
- destinationGithub: ExporterDestinationGithub.optional(),
31
- destinationAzure: ExporterDestinationAzure.optional(),
32
- destinationGitlab: ExporterDestinationGitlab.optional(),
33
- destinationBitbucket: ExporterDestinationBitbucket.optional(),
34
- });
35
-
36
- export type ExporterScheduleEventType = z.infer<typeof ExporterScheduleEventType>;
37
- export type ExporterSchedule = z.infer<typeof ExporterSchedule>;
File without changes
File without changes
File without changes