@supernova-studio/model 0.46.0 → 0.46.3
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 +15003 -14579
- package/dist/index.d.ts +15003 -14579
- package/dist/index.js +175 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +680 -597
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/codegen/export-destinations.ts +54 -0
- package/src/codegen/export-jobs.ts +8 -52
- package/src/codegen/export-schedule.ts +37 -0
- package/src/codegen/index.ts +2 -0
- package/src/dsm/data-sources/data-source.ts +1 -1
- package/src/dsm/elements/data/documentation-block-v1.ts +1 -0
- package/src/dsm/elements/figma-node-reference.ts +3 -2
- package/src/dsm/index.ts +0 -1
- package/src/dsm/published-doc-page.ts +0 -1
- package/src/dsm/version.ts +19 -1
- package/src/index.ts +1 -0
- package/src/integrations/integration.ts +45 -7
- package/src/liveblocks/index.ts +1 -0
- package/src/{dsm → liveblocks}/rooms/design-system-version-room.ts +1 -1
- package/src/{dsm → liveblocks}/rooms/documentation-page-room.ts +8 -8
- package/src/{dsm → liveblocks}/rooms/index.ts +1 -0
- package/src/{dsm → liveblocks}/rooms/room-type.ts +1 -0
- package/src/liveblocks/rooms/workspace-room.ts +16 -0
package/package.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
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,4 +1,12 @@
|
|
|
1
1
|
import { PublishedDocEnvironment } from "../dsm";
|
|
2
|
+
import {
|
|
3
|
+
ExporterDestinationSnDocs,
|
|
4
|
+
ExporterDestinationS3,
|
|
5
|
+
ExporterDestinationGithub,
|
|
6
|
+
ExporterDestinationGitlab,
|
|
7
|
+
ExporterDestinationBitbucket,
|
|
8
|
+
ExporterDestinationAzure,
|
|
9
|
+
} from "./export-destinations";
|
|
2
10
|
import { z } from "zod";
|
|
3
11
|
|
|
4
12
|
export const ExporterJobDestination = z.enum(["s3", "webhookUrl", "github", "documentation", "azure", "gitlab"]);
|
|
@@ -40,58 +48,6 @@ export const ExporterJobResult = z.object({
|
|
|
40
48
|
sndocs: ExporterJobResultDocsDestination.optional(),
|
|
41
49
|
});
|
|
42
50
|
|
|
43
|
-
export const ExporterDestinationSnDocs = z.object({
|
|
44
|
-
environment: PublishedDocEnvironment,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
export const ExporterDestinationS3 = z.object({});
|
|
48
|
-
|
|
49
|
-
export const ExporterDestinationGithub = z.object({
|
|
50
|
-
connectionId: z.string(),
|
|
51
|
-
url: z.string(),
|
|
52
|
-
branch: z.string(),
|
|
53
|
-
relativePath: z.string(),
|
|
54
|
-
// +
|
|
55
|
-
userId: z.coerce.string(),
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
export const ExporterDestinationAzure = z.object({
|
|
59
|
-
connectionId: z.string(),
|
|
60
|
-
organizationId: z.string(),
|
|
61
|
-
projectId: z.string(),
|
|
62
|
-
repositoryId: z.string(),
|
|
63
|
-
branch: z.string(),
|
|
64
|
-
relativePath: z.string(),
|
|
65
|
-
// +
|
|
66
|
-
userId: z.coerce.string(),
|
|
67
|
-
url: z.string(),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const ExporterDestinationGitlab = z.object({
|
|
71
|
-
connectionId: z.string(),
|
|
72
|
-
projectId: z.string(),
|
|
73
|
-
branch: z.string(),
|
|
74
|
-
relativePath: z.string(),
|
|
75
|
-
// +
|
|
76
|
-
userId: z.coerce.string(),
|
|
77
|
-
url: z.string(),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const BITBUCKET_SLUG = /^[-a-zA-Z0-9~]*$/;
|
|
81
|
-
const BITBUCKET_MAX_LENGTH = 64;
|
|
82
|
-
|
|
83
|
-
export const ExporterDestinationBitbucket = z.object({
|
|
84
|
-
connectionId: z.string(),
|
|
85
|
-
workspaceSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
|
|
86
|
-
projectKey: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
|
|
87
|
-
repoSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
|
|
88
|
-
branch: z.string(),
|
|
89
|
-
relativePath: z.string(),
|
|
90
|
-
// +
|
|
91
|
-
userId: z.coerce.string(),
|
|
92
|
-
url: z.string(),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
51
|
export const ExporterJob = z.object({
|
|
96
52
|
id: z.coerce.string(),
|
|
97
53
|
createdAt: z.coerce.date(),
|
|
@@ -0,0 +1,37 @@
|
|
|
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>;
|
package/src/codegen/index.ts
CHANGED
|
@@ -143,6 +143,7 @@ export const PageBlockShortcut = z.object({
|
|
|
143
143
|
description: nullishToOptional(z.string()),
|
|
144
144
|
asset: nullishToOptional(PageBlockAsset),
|
|
145
145
|
documentationItemId: nullishToOptional(z.string()),
|
|
146
|
+
pageHeadingId: nullishToOptional(z.string()),
|
|
146
147
|
url: nullishToOptional(z.string()),
|
|
147
148
|
openInNewTab: nullishToOptional(z.boolean()),
|
|
148
149
|
urlPreview: nullishToOptional(PageBlockUrlPreview),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { DesignElementBase } from "./base";
|
|
3
|
-
import { FigmaNodeReferenceData } from "./data/figma-node-reference";
|
|
4
2
|
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
5
3
|
import { OmitStrict } from "../../utils";
|
|
4
|
+
import { DesignElementBase } from "./base";
|
|
5
|
+
import { FigmaNodeReferenceData } from "./data/figma-node-reference";
|
|
6
6
|
|
|
7
7
|
export const FigmaNodeReferenceOrigin = z.object({
|
|
8
8
|
sourceId: z.string(),
|
|
9
|
+
parentName: z.string().optional(),
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
export const FigmaNodeReference = DesignElementBase.extend({
|
package/src/dsm/index.ts
CHANGED
package/src/dsm/version.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { OmitStrict } from "../utils";
|
|
3
|
-
import { DbCreateInputOmit, DbUpdate } from "../helpers";
|
|
3
|
+
import { DbCreateInputOmit, DbUpdate, nullishToOptional } from "../helpers";
|
|
4
4
|
|
|
5
5
|
export const DesignSystemVersion = z.object({
|
|
6
6
|
id: z.string(),
|
|
@@ -22,3 +22,21 @@ export type UpdateDesignSystemVersion = OmitStrict<
|
|
|
22
22
|
DbUpdate<DesignSystemVersion>,
|
|
23
23
|
"designSystemId" | "isReadonly" | "version" | "parentId"
|
|
24
24
|
>;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// Jobs
|
|
28
|
+
export const VersionCreationJobStatus = z.enum(["Success", "InProgress", "Error"]);
|
|
29
|
+
|
|
30
|
+
export type VersionCreationJobStatus = z.infer<typeof VersionCreationJobStatus>;
|
|
31
|
+
|
|
32
|
+
export const VersionCreationJob = z.object({
|
|
33
|
+
id: z.string(),
|
|
34
|
+
version: z.string(),
|
|
35
|
+
designSystemId: z.string(),
|
|
36
|
+
designSystemVersionId: nullishToOptional(z.string()),
|
|
37
|
+
status: VersionCreationJobStatus,
|
|
38
|
+
errorMessage: nullishToOptional(z.string()),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type VersionCreationJob = z.infer<typeof VersionCreationJob>;
|
|
42
|
+
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
export const IntegrationDesignSystem = z.object({
|
|
4
|
+
designSystemId: z.string(),
|
|
5
|
+
brandId: z.string(),
|
|
6
|
+
title: z.string().optional(),
|
|
7
|
+
userId: z.string().optional(),
|
|
8
|
+
date: z.coerce.date().optional(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type IntegrationDesignSystem = z.infer<typeof IntegrationDesignSystem>;
|
|
12
|
+
|
|
3
13
|
export const IntegrationCredentialsType = z.enum(["OAuth2", "PAT", "GithubApp"]);
|
|
4
14
|
export type IntegrationCredentialsType = z.infer<typeof IntegrationCredentialsType>;
|
|
5
15
|
|
|
6
16
|
export const IntegrationCredentialsProfile = z.object({
|
|
7
17
|
id: z.string(),
|
|
8
|
-
|
|
18
|
+
email: z.string().optional(),
|
|
19
|
+
handle: z.string().optional(),
|
|
9
20
|
avatarUrl: z.string().optional(),
|
|
10
21
|
});
|
|
11
22
|
|
|
@@ -19,13 +30,26 @@ export const IntegrationCredentials = z.object({
|
|
|
19
30
|
userId: z.string(),
|
|
20
31
|
createdAt: z.coerce.date(),
|
|
21
32
|
refreshToken: z.string().optional(),
|
|
33
|
+
tokenName: z.string().optional(),
|
|
34
|
+
expiresAt: z.coerce.date().optional(),
|
|
22
35
|
profile: IntegrationCredentialsProfile.optional(),
|
|
23
36
|
customUrl: z.string().optional(),
|
|
24
37
|
});
|
|
25
38
|
|
|
26
39
|
export type IntegrationCredentials = z.infer<typeof IntegrationCredentials>;
|
|
27
40
|
|
|
28
|
-
export const
|
|
41
|
+
export const ExtendedIntegrationType = z.enum([
|
|
42
|
+
"Figma",
|
|
43
|
+
"Github",
|
|
44
|
+
"Gitlab",
|
|
45
|
+
"Bitbucket",
|
|
46
|
+
"Azure",
|
|
47
|
+
"TokenStudio",
|
|
48
|
+
"FigmaVariablesPlugin",
|
|
49
|
+
]);
|
|
50
|
+
export type ExtendedIntegrationType = z.infer<typeof ExtendedIntegrationType>;
|
|
51
|
+
|
|
52
|
+
export const IntegrationType = ExtendedIntegrationType.exclude(["TokenStudio", "FigmaVariablesPlugin"]);
|
|
29
53
|
export type IntegrationType = z.infer<typeof IntegrationType>;
|
|
30
54
|
|
|
31
55
|
export const Integration = z.object({
|
|
@@ -36,34 +60,48 @@ export const Integration = z.object({
|
|
|
36
60
|
integrationCredentials: z.array(IntegrationCredentials).optional(),
|
|
37
61
|
});
|
|
38
62
|
export type Integration = z.infer<typeof Integration>;
|
|
63
|
+
export type ExtendedIntegration = Omit<Integration, "type"> & {
|
|
64
|
+
type: ExtendedIntegrationType;
|
|
65
|
+
integrationDesignSystems?: IntegrationDesignSystem[];
|
|
66
|
+
};
|
|
39
67
|
|
|
40
68
|
// Custom URL validation
|
|
41
69
|
const forbiddenCustomUrldomainList = ["github.com", "gitlab.com", "bitbucket.org", "figma.com", "dev.azure.com"];
|
|
42
|
-
// const azureCustomUrlRegex = /dev\.azure\.com\/.*/;
|
|
43
|
-
// const isAzureCustomUrl = (value: string) => azureCustomUrlRegex.test(value);
|
|
44
70
|
|
|
71
|
+
// Will be renamed to IntegrationToken in the future as there is already a type named IntegrationToken
|
|
45
72
|
export const IntegrationTokenResponse = z
|
|
46
73
|
.object({
|
|
47
74
|
access_token: z.string(),
|
|
48
75
|
refresh_token: z.string().optional(),
|
|
49
|
-
expires_in: z.number().optional(),
|
|
76
|
+
expires_in: z.union([z.number().optional(), z.string().optional()]),
|
|
50
77
|
token_type: z.string().optional(),
|
|
78
|
+
token_name: z.string().optional(),
|
|
79
|
+
token_azure_organization_name: z.string().optional(), // Azure only
|
|
80
|
+
token_bitbucket_username: z.string().optional(), // Bitbucket only
|
|
51
81
|
custom_url: z
|
|
52
82
|
.string()
|
|
53
83
|
.optional()
|
|
54
84
|
.refine(value => {
|
|
55
85
|
if (!value) return true;
|
|
56
86
|
if (forbiddenCustomUrldomainList.some(domain => value.includes(domain))) return false;
|
|
57
|
-
// if (isAzureCustomUrl(value)) return true;
|
|
58
87
|
return true;
|
|
59
88
|
}, "Custom URL validation failed"),
|
|
60
89
|
})
|
|
90
|
+
.refine(data => {
|
|
91
|
+
if (data.custom_url && data.token_azure_organization_name) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}, "Custom URL and Azure organization name cannot be present at the same time")
|
|
61
96
|
.transform(data => {
|
|
62
97
|
return {
|
|
63
98
|
accessToken: data.access_token,
|
|
64
99
|
refreshToken: data.refresh_token,
|
|
65
|
-
expiresIn: data.expires_in,
|
|
100
|
+
expiresIn: typeof data.expires_in === "string" ? Number(data.expires_in) : data.expires_in,
|
|
66
101
|
tokenType: data.token_type,
|
|
102
|
+
tokenName: data.token_name,
|
|
103
|
+
tokenBitbucketUsername: data.token_bitbucket_username,
|
|
104
|
+
tokenAzureOrganizationName: data.token_azure_organization_name,
|
|
67
105
|
customUrl: data.custom_url,
|
|
68
106
|
};
|
|
69
107
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rooms";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Entity } from "../../common/entity";
|
|
3
|
-
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
4
3
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "
|
|
4
|
+
DocumentationItemConfigurationV2,
|
|
5
|
+
DocumentationPageV2,
|
|
6
|
+
ElementGroup,
|
|
7
|
+
PageBlockDefinition,
|
|
8
|
+
PageBlockEditorModelV2,
|
|
9
|
+
PageSectionEditorModelV2,
|
|
10
|
+
} from "../../dsm";
|
|
11
|
+
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
12
12
|
import { OmitStrict } from "../../utils";
|
|
13
13
|
|
|
14
14
|
export const DocumentationPageRoom = Entity.extend({
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Room
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { Entity } from "../../common/entity";
|
|
7
|
+
import { DbCreateInputOmit, DbUpdate } from "../../helpers/db";
|
|
8
|
+
|
|
9
|
+
export const WorkspaceRoom = Entity.extend({
|
|
10
|
+
workspaceId: z.string(),
|
|
11
|
+
liveblocksId: z.string(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type WorkspaceRoom = z.infer<typeof WorkspaceRoom>;
|
|
15
|
+
export type CreateWorkspaceRoom = DbCreateInputOmit<WorkspaceRoom>;
|
|
16
|
+
export type UpdateWorkspaceRoom = DbUpdate<WorkspaceRoom>;
|