@supernova-studio/model 0.47.16 → 0.47.18
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 +614 -317
- package/dist/index.d.ts +614 -317
- package/dist/index.js +94 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +157 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/export/export-destinations.ts +29 -19
- package/src/export/export-jobs.ts +9 -1
- package/src/export/exporter.ts +6 -3
- package/src/export/index.ts +1 -1
- package/src/export/pipeline.ts +33 -0
- package/src/integrations/git.ts +10 -0
- package/src/integrations/integration.ts +16 -1
- package/src/utils/common.ts +10 -0
- package/src/export/export-schedule.ts +0 -25
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PublishedDocEnvironment } from "../dsm";
|
|
3
|
+
import { nullishToOptional } from "../helpers";
|
|
3
4
|
|
|
4
5
|
const BITBUCKET_SLUG = /^[-a-zA-Z0-9~]*$/;
|
|
5
6
|
const BITBUCKET_MAX_LENGTH = 64;
|
|
@@ -11,48 +12,57 @@ export const ExporterDestinationDocs = z.object({
|
|
|
11
12
|
export const ExporterDestinationS3 = z.object({});
|
|
12
13
|
|
|
13
14
|
export const ExporterDestinationGithub = z.object({
|
|
15
|
+
credentialId: z.string().optional(),
|
|
16
|
+
|
|
17
|
+
// Repository
|
|
14
18
|
url: z.string(),
|
|
19
|
+
|
|
20
|
+
// Location
|
|
15
21
|
branch: z.string(),
|
|
16
|
-
|
|
17
|
-
connectionId: z.string(),
|
|
18
|
-
relativePath: z.string(),
|
|
22
|
+
relativePath: nullishToOptional(z.string()),
|
|
19
23
|
});
|
|
20
24
|
|
|
21
25
|
export const ExporterDestinationAzure = z.object({
|
|
22
|
-
|
|
26
|
+
credentialId: z.string().optional(),
|
|
27
|
+
|
|
28
|
+
// Repository
|
|
23
29
|
organizationId: z.string(),
|
|
24
30
|
projectId: z.string(),
|
|
25
31
|
repositoryId: z.string(),
|
|
32
|
+
|
|
33
|
+
// Location
|
|
26
34
|
branch: z.string(),
|
|
27
|
-
relativePath: z.string(),
|
|
35
|
+
relativePath: nullishToOptional(z.string()),
|
|
28
36
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
// url: z.string(),
|
|
37
|
+
// Maybe not needed
|
|
38
|
+
url: nullishToOptional(z.string()),
|
|
32
39
|
});
|
|
33
40
|
|
|
34
41
|
export const ExporterDestinationGitlab = z.object({
|
|
35
|
-
|
|
42
|
+
credentialId: z.string().optional(),
|
|
43
|
+
|
|
44
|
+
// Repository
|
|
36
45
|
projectId: z.string(),
|
|
46
|
+
|
|
47
|
+
// Location
|
|
37
48
|
branch: z.string(),
|
|
38
|
-
relativePath: z.string(),
|
|
49
|
+
relativePath: nullishToOptional(z.string()),
|
|
39
50
|
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
// url: z.string(),
|
|
51
|
+
// Maybe not needed
|
|
52
|
+
url: nullishToOptional(z.string()),
|
|
43
53
|
});
|
|
44
54
|
|
|
45
55
|
export const ExporterDestinationBitbucket = z.object({
|
|
46
|
-
|
|
56
|
+
credentialId: z.string().optional(),
|
|
57
|
+
|
|
58
|
+
// Repository
|
|
47
59
|
workspaceSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
|
|
48
60
|
projectKey: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
|
|
49
61
|
repoSlug: z.string().max(BITBUCKET_MAX_LENGTH).regex(BITBUCKET_SLUG),
|
|
50
|
-
branch: z.string(),
|
|
51
|
-
relativePath: z.string(),
|
|
52
62
|
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
// Location
|
|
64
|
+
branch: z.string(),
|
|
65
|
+
relativePath: nullishToOptional(z.string()),
|
|
56
66
|
});
|
|
57
67
|
|
|
58
68
|
export const ExportDestinationsMap = z.object({
|
|
@@ -7,7 +7,15 @@ import { ExportDestinationsMap } from "./export-destinations";
|
|
|
7
7
|
// Enums
|
|
8
8
|
//
|
|
9
9
|
|
|
10
|
-
export const ExportJobDestinationType = z.enum([
|
|
10
|
+
export const ExportJobDestinationType = z.enum([
|
|
11
|
+
"s3",
|
|
12
|
+
"webhookUrl",
|
|
13
|
+
"github",
|
|
14
|
+
"documentation",
|
|
15
|
+
"azure",
|
|
16
|
+
"gitlab",
|
|
17
|
+
"bitbucket",
|
|
18
|
+
]);
|
|
11
19
|
export const ExportJobStatus = z.enum(["InProgress", "Success", "Failed", "Timeout"]);
|
|
12
20
|
export const ExportJobLogEntryType = z.enum(["success", "info", "warning", "error", "user"]);
|
|
13
21
|
|
package/src/export/exporter.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { GitProvider } from "./git-providers";
|
|
3
|
-
import { PulsarCustomBlock, PulsarContributionConfigurationProperty, PulsarContributionVariant } from "./pulsar";
|
|
4
2
|
import { nullishToOptional } from "../helpers";
|
|
3
|
+
import { GitProvider } from "./git-providers";
|
|
4
|
+
import { PulsarContributionConfigurationProperty, PulsarContributionVariant, PulsarCustomBlock } from "./pulsar";
|
|
5
5
|
|
|
6
6
|
export const ExporterType = z.enum(["code", "documentation"]);
|
|
7
7
|
export const ExporterSource = z.enum(["git", "upload"]);
|
|
8
8
|
export const ExporterTag = z.string().regex(/^[0-9a-zA-Z]+(\s[0-9a-zA-Z]+)*$/);
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const ExporterPulsarDetails = z.object({
|
|
11
11
|
description: z.string(),
|
|
12
12
|
version: z.string(),
|
|
13
13
|
routingVersion: nullishToOptional(z.string()),
|
|
@@ -25,7 +25,9 @@ export const ExporterDetails = z.object({
|
|
|
25
25
|
|
|
26
26
|
usesBrands: nullishToOptional(z.boolean()).default(false),
|
|
27
27
|
usesThemes: nullishToOptional(z.boolean()).default(false),
|
|
28
|
+
});
|
|
28
29
|
|
|
30
|
+
export const ExporterDetails = ExporterPulsarDetails.extend({
|
|
29
31
|
source: ExporterSource,
|
|
30
32
|
|
|
31
33
|
gitProvider: nullishToOptional(GitProvider),
|
|
@@ -47,5 +49,6 @@ export const Exporter = z.object({
|
|
|
47
49
|
export type ExporterType = z.infer<typeof ExporterType>;
|
|
48
50
|
export type ExporterSource = z.infer<typeof ExporterSource>;
|
|
49
51
|
export type ExporterTag = z.infer<typeof ExporterTag>;
|
|
52
|
+
export type ExporterPulsarDetails = z.infer<typeof ExporterPulsarDetails>;
|
|
50
53
|
export type ExporterDetails = z.infer<typeof ExporterDetails>;
|
|
51
54
|
export type Exporter = z.infer<typeof Exporter>;
|
package/src/export/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from "./export-runner";
|
|
2
2
|
export * from "./export-destinations";
|
|
3
3
|
export * from "./export-jobs";
|
|
4
|
-
export * from "./export-schedule";
|
|
5
4
|
export * from "./exporter-workspace-membership-role";
|
|
6
5
|
export * from "./exporter-workspace-membership";
|
|
7
6
|
export * from "./exporter";
|
|
8
7
|
export * from "./git-providers";
|
|
8
|
+
export * from "./pipeline";
|
|
9
9
|
export * from "./pulsar";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ExportDestinationsMap } from "./export-destinations";
|
|
3
|
+
|
|
4
|
+
export const PipelineEventType = z.enum(["OnVersionReleased", "OnHeadChanged", "OnSourceUpdated", "None"]);
|
|
5
|
+
|
|
6
|
+
export const PipelineDestinationGitType = z.enum(["Github", "Gitlab", "Bitbucket", "Azure"]);
|
|
7
|
+
export const PipelineDestinationExtraType = z.enum(["WebhookUrl", "S3", "Documentation"]);
|
|
8
|
+
export const PipelineDestinationType = z.union([PipelineDestinationGitType, PipelineDestinationExtraType]);
|
|
9
|
+
|
|
10
|
+
export const Pipeline = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
|
|
13
|
+
name: z.string(),
|
|
14
|
+
eventType: PipelineEventType,
|
|
15
|
+
isEnabled: z.boolean(),
|
|
16
|
+
|
|
17
|
+
workspaceId: z.string(),
|
|
18
|
+
designSystemId: z.string(),
|
|
19
|
+
exporterId: z.string(),
|
|
20
|
+
|
|
21
|
+
brandPersistentId: z.string().optional(),
|
|
22
|
+
themePersistentId: z.string().optional(),
|
|
23
|
+
|
|
24
|
+
// Destinations
|
|
25
|
+
...ExportDestinationsMap.shape,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type PipelineEventType = z.infer<typeof PipelineEventType>;
|
|
29
|
+
export type PipelineDestinationGitType = z.infer<typeof PipelineDestinationGitType>;
|
|
30
|
+
export type PipelineDestinationExtraType = z.infer<typeof PipelineDestinationExtraType>;
|
|
31
|
+
export type PipelineDestinationType = z.infer<typeof PipelineDestinationType>;
|
|
32
|
+
|
|
33
|
+
export type Pipeline = z.infer<typeof Pipeline>;
|
package/src/integrations/git.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
export const GitObjectsQuery = z.object({
|
|
4
|
+
organization: z.string().optional(), // Azure Organization | Bitbucket Workspace slug | Gitlab Group | Github Account (User or Organization)
|
|
5
|
+
project: z.string().optional(), // Only for Bitbucket and Azure
|
|
6
|
+
repository: z.string().optional(), // For all providers. For Gitlab, it's called "project".
|
|
7
|
+
branch: z.string().optional(), // For all providers.
|
|
8
|
+
user: z.string().optional(), // Gitlab user
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type GitObjectsQuery = z.infer<typeof GitObjectsQuery>;
|
|
12
|
+
|
|
3
13
|
export const GitOrganization = z.object({
|
|
4
14
|
id: z.string(),
|
|
5
15
|
name: z.string(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { UserMinified } from "../users/user-minified";
|
|
3
|
+
|
|
3
4
|
export const IntegrationDesignSystem = z.object({
|
|
4
5
|
designSystemId: z.string(),
|
|
5
6
|
brandId: z.string(),
|
|
@@ -57,6 +58,9 @@ export type ExtendedIntegrationType = z.infer<typeof ExtendedIntegrationType>;
|
|
|
57
58
|
export const IntegrationType = ExtendedIntegrationType.exclude(["TokenStudio", "FigmaVariablesPlugin"]);
|
|
58
59
|
export type IntegrationType = z.infer<typeof IntegrationType>;
|
|
59
60
|
|
|
61
|
+
export const GitIntegrationType = IntegrationType.exclude(["Figma"]);
|
|
62
|
+
export type GitIntegrationType = z.infer<typeof GitIntegrationType>;
|
|
63
|
+
|
|
60
64
|
export const Integration = z.object({
|
|
61
65
|
id: z.string(),
|
|
62
66
|
workspaceId: z.string(),
|
|
@@ -106,8 +110,19 @@ export const IntegrationToken = z
|
|
|
106
110
|
tokenName: data.token_name,
|
|
107
111
|
tokenBitbucketUsername: data.token_bitbucket_username,
|
|
108
112
|
tokenAzureOrganizationName: data.token_azure_organization_name,
|
|
109
|
-
customUrl: data.custom_url,
|
|
113
|
+
customUrl: data.custom_url ? formatCustomUrl(data.custom_url) : undefined,
|
|
110
114
|
};
|
|
115
|
+
|
|
116
|
+
function formatCustomUrl(url: string): string {
|
|
117
|
+
let formattedUrl = url.trim();
|
|
118
|
+
if (!formattedUrl.startsWith("http://") && !formattedUrl.startsWith("https://")) {
|
|
119
|
+
formattedUrl = "http://" + formattedUrl;
|
|
120
|
+
}
|
|
121
|
+
if (formattedUrl.endsWith("/")) {
|
|
122
|
+
formattedUrl = formattedUrl.slice(0, -1);
|
|
123
|
+
}
|
|
124
|
+
return formattedUrl;
|
|
125
|
+
}
|
|
111
126
|
});
|
|
112
127
|
|
|
113
128
|
export type IntegrationToken = z.infer<typeof IntegrationToken>;
|
package/src/utils/common.ts
CHANGED
|
@@ -39,6 +39,16 @@ export function trimTrailingSlash(string: string): string {
|
|
|
39
39
|
return string.endsWith("/") ? string.substring(0, string.length - 1) : string;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export function tryParseUrl(url: string): URL | null {
|
|
43
|
+
try {
|
|
44
|
+
return parseUrl(url);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(`Error parsing URL ${url}`);
|
|
47
|
+
console.error(e);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
42
52
|
export function parseUrl(url: string): URL {
|
|
43
53
|
return new URL(url.startsWith("https://") || url.startsWith("http://") ? url : `https://${url}`);
|
|
44
54
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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>;
|