@supernova-studio/model 0.40.0 → 0.41.0

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.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/dsm/brand.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { DbCreateInputOmit } from "../helpers";
2
3
 
3
4
  export const Brand = z.object({
4
5
  id: z.string(),
@@ -9,3 +10,4 @@ export const Brand = z.object({
9
10
  });
10
11
 
11
12
  export type Brand = z.infer<typeof Brand>;
13
+ export type CreateBrand = DbCreateInputOmit<Brand>;
@@ -2,12 +2,11 @@ import { z } from "zod";
2
2
 
3
3
  const DS_NAME_MIN_LENGTH: number = 2;
4
4
  const DS_NAME_MAX_LENGTH: number = 64;
5
- const DS_DESC_MIN_LENGTH: number = 2;
6
5
  const DS_DESC_MAX_LENGTH: number = 64;
7
6
 
8
7
  const DesignSystemCreateInputMetadata = z.object({
9
8
  name: z.string().min(DS_NAME_MIN_LENGTH).max(DS_NAME_MAX_LENGTH).trim(),
10
- description: z.string().min(DS_DESC_MIN_LENGTH).max(DS_DESC_MAX_LENGTH).trim(),
9
+ description: z.string().max(DS_DESC_MAX_LENGTH).trim(),
11
10
  });
12
11
 
13
12
  export const DesignSystemCreateInput = z.object({
@@ -2,12 +2,11 @@ import { z } from "zod";
2
2
 
3
3
  const DS_NAME_MIN_LENGTH: number = 2;
4
4
  const DS_NAME_MAX_LENGTH: number = 64;
5
- const DS_DESC_MIN_LENGTH: number = 2;
6
5
  const DS_DESC_MAX_LENGTH: number = 64;
7
6
 
8
7
  const DesignSystemUpdateInputMetadata = z.object({
9
8
  name: z.string().min(DS_NAME_MIN_LENGTH).max(DS_NAME_MAX_LENGTH).trim().optional(),
10
- description: z.string().min(DS_DESC_MIN_LENGTH).max(DS_DESC_MAX_LENGTH).trim().optional(),
9
+ description: z.string().max(DS_DESC_MAX_LENGTH).trim().optional(),
11
10
  });
12
11
 
13
12
  export const DesignSystemUpdateInput = z.object({
@@ -18,7 +17,7 @@ export const DesignSystemUpdateInput = z.object({
18
17
  docUserSlug: z.string().nullish().optional(),
19
18
  source: z.array(z.string()).optional(),
20
19
  name: z.string().min(DS_NAME_MIN_LENGTH).max(DS_NAME_MAX_LENGTH).trim().optional(),
21
- description: z.string().min(DS_DESC_MIN_LENGTH).max(DS_DESC_MAX_LENGTH).trim().optional(),
20
+ description: z.string().max(DS_DESC_MAX_LENGTH).trim().optional(),
22
21
  docExporterId: z.string().optional(),
23
22
  });
24
23
 
@@ -1,6 +1,7 @@
1
1
  export * from "./block-definitions";
2
2
  export * from "./group";
3
3
  export * from "./link-preview";
4
+ export * from "./page-anchor";
4
5
  export * from "./page-content-backup";
5
6
  export * from "./page-content";
6
7
  export * from "./page";
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const DocumentationPageAnchor = z.object({
4
+ blockId: z.string(),
5
+ level: z.number(),
6
+ text: z.string(),
7
+ });
8
+
9
+ export type DocumentationPageAnchor = z.infer<typeof DocumentationPageAnchor>;
@@ -19,7 +19,6 @@ export const DocumentationPageContent = z.object({
19
19
  updatedAt: z.coerce.date(),
20
20
  documentationPageId: z.string(),
21
21
  data: DocumentationPageContentData,
22
- isDirty: z.boolean(),
23
22
  });
24
23
 
25
24
  export type DocumentationPageContentItem = z.infer<typeof DocumentationPageContentItem>;
@@ -144,6 +144,7 @@ export const PageBlockShortcut = z.object({
144
144
  asset: nullishToOptional(PageBlockAsset),
145
145
  documentationItemId: nullishToOptional(z.string()),
146
146
  url: nullishToOptional(z.string()),
147
+ openInNewTab: nullishToOptional(z.boolean()),
147
148
  urlPreview: nullishToOptional(PageBlockUrlPreview),
148
149
  documentationItemPreview: nullishToOptional(PageBlockLinkPreview),
149
150
  });
@@ -212,7 +213,8 @@ export const PageBlockTextSpanAttribute = z.object({
212
213
  type: PageBlockTextSpanAttributeType,
213
214
  link: nullishToOptional(z.string()),
214
215
  documentationItemId: nullishToOptional(z.string()),
215
- openInNewWindow: nullishToOptional(z.boolean()),
216
+ openInNewWindow: nullishToOptional(z.boolean()), // deprecated. use openInNewTab
217
+ openInNewTab: nullishToOptional(z.boolean()),
216
218
  });
217
219
 
218
220
  export const PageBlockTextSpan = z.object({
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { ColorTokenData, PageBlockAsset, TypographyTokenData } from "./elements";
3
+
4
+ export const ExporterPropertyImageValue = z.object({
5
+ asset: PageBlockAsset.optional(),
6
+ assetId: z.string().optional(),
7
+ assetUrl: z.string().optional(),
8
+ });
9
+
10
+ export const ExporterPropertyValue = z.object({
11
+ key: z.string(),
12
+ value: z.union([
13
+ z.number(),
14
+ z.string(),
15
+ z.boolean(),
16
+ ExporterPropertyImageValue,
17
+ ColorTokenData,
18
+ TypographyTokenData,
19
+ ]),
20
+ });
21
+
22
+ export const ExporterPropertyValuesCollection = z.object({
23
+ id: z.string(),
24
+ designSystemId: z.string(),
25
+ exporterId: z.string(),
26
+ values: z.array(ExporterPropertyValue),
27
+ });
28
+
29
+ export type ExporterPropertyImageValue = z.infer<typeof ExporterPropertyImageValue>;
30
+ export type ExporterPropertyValue = z.infer<typeof ExporterPropertyValue>;
31
+ export type ExporterPropertyValuesCollection = z.infer<typeof ExporterPropertyValuesCollection>;
package/src/dsm/index.ts CHANGED
@@ -10,6 +10,7 @@ export * from "./brand";
10
10
  export * from "./design-system";
11
11
  export * from "./desing-system-create";
12
12
  export * from "./desing-system-update";
13
+ export * from "./exporter-property-values-collection";
13
14
  export * from "./published-doc-page";
14
15
  export * from "./published-doc";
15
16
  export * from "./reference";
@@ -1,10 +1,13 @@
1
1
  import { z } from "zod";
2
2
  import { DbCreateInputOmit, DbUpdate } from "../../helpers";
3
+ import { OmitStrict } from "../../utils";
3
4
 
4
5
  export const ElementPropertyTypeSchema = z.enum(["Text", "Number", "Boolean", "Select", "Generic", "Link", "URL"]);
5
6
  export const ElementPropertyTargetType = z.enum(["Token", "Component", "DocumentationPage"]);
6
7
  export const ElementPropertyLinkType = z.enum(["FigmaComponent", "DocumentationPage"]);
7
8
 
9
+ const CODE_NAME_REGEX = /^[a-zA-Z_$][a-zA-Z_$0-9]{1,99}$/;
10
+
8
11
  export const ColorTokenInlineData = z.object({
9
12
  value: z.string(),
10
13
  });
@@ -20,7 +23,7 @@ export const ElementPropertyDefinition = z.object({
20
23
  designSystemVersionId: z.string(),
21
24
  persistentId: z.string(),
22
25
  name: z.string(),
23
- codeName: z.string(),
26
+ codeName: z.string().regex(CODE_NAME_REGEX),
24
27
  description: z.string(),
25
28
  type: ElementPropertyTypeSchema,
26
29
  targetElementType: ElementPropertyTargetType,
@@ -38,7 +41,10 @@ export type ElementPropertyDefinitionOption = z.infer<typeof ElementPropertyDefi
38
41
  export type ElementPropertyDefinition = z.infer<typeof ElementPropertyDefinition>;
39
42
 
40
43
  export type CreateElementPropertyDefinition = DbCreateInputOmit<ElementPropertyDefinition>;
41
- export type UpdateElementPropertyDefinition = DbUpdate<ElementPropertyDefinition>;
44
+ export type UpdateElementPropertyDefinition = OmitStrict<
45
+ DbUpdate<ElementPropertyDefinition>,
46
+ "designSystemVersionId" | "targetElementType" | "type"
47
+ >;
42
48
 
43
49
  export type ElementPropertyDefinitionDiff = {
44
50
  toCreate: CreateElementPropertyDefinition[];
@@ -1,5 +1,7 @@
1
- import { ElementPropertyTargetType } from "../properties";
2
1
  import { z } from "zod";
2
+ import { DbCreateInputOmit, DbUpdate } from "../../helpers";
3
+ import { OmitStrict } from "../../utils";
4
+ import { ElementPropertyTargetType } from "../properties";
3
5
 
4
6
  export const ElementView = z.object({
5
7
  id: z.string(),
@@ -12,3 +14,6 @@ export const ElementView = z.object({
12
14
  });
13
15
 
14
16
  export type ElementView = z.infer<typeof ElementView>;
17
+
18
+ export type CreateElementView = DbCreateInputOmit<ElementView>;
19
+ export type UpdateElementView = OmitStrict<DbUpdate<ElementView>, "designSystemVersionId" | "targetElementType">;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
 
3
- export const FlaggedFeature = z.enum(["FigmaImporterV2", "ShadowOpacityOptional"]);
3
+ export const FlaggedFeature = z.enum(["FigmaImporterV2", "ShadowOpacityOptional", "DisableImporter"]);
4
4
  export const FeatureFlagMap = z.record(FlaggedFeature, z.boolean());
5
5
  export const FeatureFlag = z.object({
6
6
  id: z.string(),
@@ -1,3 +1,5 @@
1
1
  export * from "./external-oauth-request";
2
+ export * from "./integration";
2
3
  export * from "./oauth-providers";
3
4
  export * from "./oauth-token";
5
+ export * from "./workspace-oauth-requests";
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+
3
+ export const IntegrationType = z.enum(["Figma", "Github", "Gitlab", "Bitbucket", "Azure"]);
4
+ export type IntegrationType = z.infer<typeof IntegrationType>;
5
+
6
+ export const Integration = z.object({
7
+ id: z.string(),
8
+ workspaceId: z.string(),
9
+ type: IntegrationType,
10
+ createdAt: z.coerce.date(),
11
+ });
12
+ export type Integration = z.infer<typeof Integration>;
13
+
14
+ export const IntegrationCredentialsType = z.enum(["OAuth2", "PAT"]);
15
+ export type IntegrationCredentialsType = z.infer<typeof IntegrationCredentialsType>;
16
+
17
+ export const IntegrationCredentialsProfile = z.object({
18
+ id: z.string(),
19
+ username: z.string().optional(),
20
+ avatarUrl: z.string().optional(),
21
+ });
22
+
23
+ export type IntegrationCredentialsProfile = z.infer<typeof IntegrationCredentialsProfile>;
24
+
25
+ export const IntegrationCredentialsSchema = z.object({
26
+ id: z.string(),
27
+ type: IntegrationCredentialsType,
28
+ integrationId: z.string(),
29
+ accessToken: z.string(),
30
+ userId: z.string(),
31
+ createdAt: z.coerce.date(),
32
+ refreshToken: z.string().optional(),
33
+ profile: IntegrationCredentialsProfile.optional(),
34
+ });
35
+
36
+ export type IntegrationCredentials = z.infer<typeof IntegrationCredentialsSchema>;
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ import { OAuthProviderSchema } from "./oauth-providers";
3
+
4
+ export const WorkspaceOAuthRequestSchema = z.object({
5
+ id: z.string(),
6
+ workspaceId: z.string(),
7
+ provider: OAuthProviderSchema,
8
+ userId: z.string(),
9
+ createdAt: z.coerce.date(),
10
+ });
11
+
12
+ export type WorkspaceOAuthRequest = z.infer<typeof WorkspaceOAuthRequestSchema>;
@@ -1,17 +1,25 @@
1
1
  import { z } from "zod";
2
+ import { DbCreateInputOmit } from "../helpers";
3
+ import { OmitStrict } from "../utils";
2
4
  import { WorkspaceRoleSchema } from "../workspace";
3
5
 
4
6
  export const PersonalAccessToken = z.object({
5
7
  id: z.string(),
6
8
  userId: z.string(),
9
+
10
+ workspaceId: z.string().optional(),
11
+ workspaceRole: WorkspaceRoleSchema.optional(),
12
+
7
13
  name: z.string(),
14
+ hidden: z.boolean(),
15
+
8
16
  token: z.string(),
17
+ scope: z.string().optional(),
18
+
9
19
  createdAt: z.coerce.date(),
10
- hidden: z.boolean(),
11
- workspaceId: z.string().optional(),
12
- workspaceRole: WorkspaceRoleSchema.optional(),
13
20
  expireAt: z.coerce.date().optional(),
14
- scope: z.string().optional(),
15
21
  });
16
22
 
17
23
  export type PersonalAccessToken = z.infer<typeof PersonalAccessToken>;
24
+
25
+ export type CreatePersonalAccessToken = DbCreateInputOmit<PersonalAccessToken>;
@@ -14,7 +14,8 @@ export type SupernovaExceptionType =
14
14
  | "PlanRestricted"
15
15
  | "MissingWorkspacePermission"
16
16
  | "MissingExporterPermission"
17
- | "NoAccess";
17
+ | "NoAccess"
18
+ | "MissingCredentials";
18
19
 
19
20
  export class SupernovaException extends Error {
20
21
  static wrongFormat(message?: string): SupernovaException {
@@ -81,6 +82,10 @@ export class SupernovaException extends Error {
81
82
  return new SupernovaException("NoAccess", message);
82
83
  }
83
84
 
85
+ static missingCredentials(message?: string): SupernovaException {
86
+ return new SupernovaException("MissingCredentials", message);
87
+ }
88
+
84
89
  //
85
90
  // To refactor
86
91
  //