@supernova-studio/model 0.28.0 → 0.29.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.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,9 +45,9 @@ export const PulsarContributionConfigurationProperty = PulsarBaseProperty.extend
45
45
  export const PulsarContributionVariant = z.object({
46
46
  key: z.string(),
47
47
  name: z.string(),
48
- isDefault: z.boolean().nullish(),
49
- description: z.string().nullish(),
50
- thumbnailURL: z.string().nullish(),
48
+ isDefault: nullishToOptional(z.boolean()),
49
+ description: nullishToOptional(z.string()),
50
+ thumbnailURL: nullishToOptional(z.string()),
51
51
  });
52
52
 
53
53
  export const PulsarCustomBlock = z.object({
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+
3
+ export const AssetDynamoRecord = z.object({
4
+ path: z.string(),
5
+ id: z.string(),
6
+ designSystemId: z.string(),
7
+ expiresAt: z.number(),
8
+ });
9
+
10
+ export type AssetDynamoRecord = z.infer<typeof AssetDynamoRecord>;
@@ -9,14 +9,22 @@ export const AssetFontProperties = z.object({
9
9
  subfamily: z.string(),
10
10
  });
11
11
 
12
- export const AssetProperties = z.object({
13
- fontProperties: z.array(AssetFontProperties),
14
- });
12
+ export const AssetProperties = z.union([
13
+ z.object({
14
+ fontProperties: z.array(AssetFontProperties),
15
+ }),
16
+ z.object({
17
+ width: z.number(),
18
+ height: z.number(),
19
+ }),
20
+ ]);
15
21
 
16
22
  export const AssetOrigin = z.object({
17
23
  originKey: z.string(),
18
24
  });
19
25
 
26
+ export const AssetProcessStatus = z.enum(["Pending", "Uploaded", "Processed"]);
27
+
20
28
  export const Asset = z.object({
21
29
  id: z.string(),
22
30
  designSystemId: z.string().nullish(),
@@ -25,6 +33,7 @@ export const Asset = z.object({
25
33
  filePath: z.string(),
26
34
  scope: AssetScope,
27
35
  properties: AssetProperties.nullish(),
36
+ state: AssetProcessStatus.optional(),
28
37
  origin: AssetOrigin.optional(),
29
38
  originKey: z.string().optional(),
30
39
  });
@@ -1,3 +1,4 @@
1
+ export * from "./asset-dynamo-record";
1
2
  export * from "./asset-reference";
2
3
  export * from "./asset-value";
3
4
  export * from "./asset";
@@ -1,3 +1,6 @@
1
1
  export * from "./block-definitions";
2
2
  export * from "./group";
3
+ export * from "./link-preview";
4
+ export * from "./page-content-backup";
5
+ export * from "./page-content";
3
6
  export * from "./page";
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ export const DocumentationLinkPreview = z.object({
4
+ title: z.string().optional(),
5
+ description: z.string().optional(),
6
+ thumbnailUrl: z.string().optional(),
7
+ });
8
+
9
+ export type DocumentationLinkPreview = z.infer<typeof DocumentationLinkPreview>;
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+
3
+ export const DocumentationPageContentBackup = z.object({
4
+ id: z.string(),
5
+ designSystemVersionId: z.string(),
6
+ createdAt: z.coerce.date(),
7
+ updatedAt: z.coerce.date(),
8
+ documentationPageId: z.string(),
9
+ documentationPageName: z.string(),
10
+ storagePath: z.string(),
11
+ });
12
+
13
+ export type DocumentationPageContentBackup = z.infer<typeof DocumentationPageContentBackup>;
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import { PageBlockEditorModelV2, PageSectionEditorModelV2 } from "../elements";
3
+ import { DbCreateInputOmit, DbUpdate } from "../../helpers";
4
+ import { OmitStrict } from "../../utils";
5
+
6
+ export const DocumentationPageContentItem = z.discriminatedUnion("type", [
7
+ PageBlockEditorModelV2,
8
+ PageSectionEditorModelV2,
9
+ ]);
10
+
11
+ export const DocumentationPageContentData = z.object({
12
+ items: z.array(DocumentationPageContentItem),
13
+ });
14
+
15
+ export const DocumentationPageContent = z.object({
16
+ id: z.string(),
17
+ designSystemVersionId: z.string(),
18
+ createdAt: z.coerce.date(),
19
+ updatedAt: z.coerce.date(),
20
+ documentationPageId: z.string(),
21
+ data: DocumentationPageContentData,
22
+ isDirty: z.boolean(),
23
+ });
24
+
25
+ export type DocumentationPageContentItem = z.infer<typeof DocumentationPageContentItem>;
26
+ export type DocumentationPageContentData = z.infer<typeof DocumentationPageContentData>;
27
+ export type DocumentationPageContent = z.infer<typeof DocumentationPageContent>;
28
+
29
+ export type CreateDocumentationPageContent = DbCreateInputOmit<DocumentationPageContent>;
30
+ export type UpdateDocumentationPageContent = OmitStrict<
31
+ DbUpdate<DocumentationPageContent>,
32
+ "designSystemVersionId" | "documentationPageId"
33
+ >;
@@ -27,7 +27,6 @@ export * from "./item-header";
27
27
  export * from "./letter-spacing";
28
28
  export * from "./line-height";
29
29
  export * from "./opacity";
30
- export * from "./page-asset";
31
30
  export * from "./paragraph-indent";
32
31
  export * from "./paragraph-spacing";
33
32
  export * from "./product-copy";
@@ -1,5 +1,4 @@
1
1
  import { z } from "zod";
2
- import { DocumentationPageAsset } from "./page-asset";
3
2
  import { ColorTokenData } from "./color";
4
3
  import {
5
4
  DocumentationItemHeaderAlignment,
@@ -7,6 +6,7 @@ import {
7
6
  DocumentationItemHeaderImageScaleType,
8
7
  DocumentationItemHeaderImageScaleTypeSchema,
9
8
  } from "./item-header";
9
+ import { PageBlockAsset } from "./documentation-block-v1";
10
10
 
11
11
  //
12
12
  // Definitions
@@ -17,7 +17,7 @@ export const DocumentationItemHeaderV1 = z.object({
17
17
  alignment: DocumentationItemHeaderAlignmentSchema,
18
18
  foregroundColor: ColorTokenData.nullish(),
19
19
  backgroundColor: ColorTokenData.nullish(),
20
- backgroundImageAsset: DocumentationPageAsset.nullish(),
20
+ backgroundImageAsset: PageBlockAsset.nullish(),
21
21
  backgroundImageScaleType: DocumentationItemHeaderImageScaleTypeSchema,
22
22
  showBackgroundOverlay: z.boolean(),
23
23
  showCoverText: z.boolean(),
@@ -1,5 +1,4 @@
1
1
  import { z } from "zod";
2
- import { DocumentationPageAsset } from "./page-asset";
3
2
  import {
4
3
  DocumentationItemHeaderAlignment,
5
4
  DocumentationItemHeaderAlignmentSchema,
package/src/dsm/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from "./documentation";
4
4
  export * from "./elements";
5
5
  export * from "./import";
6
6
  export * from "./properties";
7
+ export * from "./rooms";
7
8
  export * from "./views";
8
9
  export * from "./brand";
9
10
  export * from "./design-system";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
- import { Entity } from "../common/entity";
3
- import { DbCreateInputOmit, DbUpdate } from "../helpers";
4
- import { DocumentationPageV2, ElementGroup } from "../dsm";
2
+ import { Entity } from "../../common/entity";
3
+ import { DbCreateInputOmit, DbUpdate } from "../../helpers";
4
+ import { DocumentationPageV2, ElementGroup } from "..";
5
5
 
6
6
  export const DesignSystemVersionRoom = Entity.extend({
7
7
  designSystemVersionId: z.string(),
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ import { Entity } from "../../common/entity";
3
+ import { DbCreateInputOmit, DbUpdate } from "../../helpers";
4
+ import {
5
+ DocumentationItemConfigurationV2,
6
+ DocumentationPageV2,
7
+ ElementGroup,
8
+ PageBlockDefinition,
9
+ PageBlockEditorModelV2,
10
+ PageSectionEditorModelV2,
11
+ } from "..";
12
+ import { OmitStrict } from "../../utils";
13
+
14
+ export const DocumentationPageRoom = Entity.extend({
15
+ designSystemVersionId: z.string(),
16
+ documentationPageId: z.string(),
17
+ liveblocksId: z.string(),
18
+ isDirty: z.boolean(),
19
+ });
20
+
21
+ export type DocumentationPageRoom = z.infer<typeof DocumentationPageRoom>;
22
+
23
+ export type CreateDocumentationPageRoom = DbCreateInputOmit<DocumentationPageRoom>;
24
+ export type UpdateDocumentationPageRoom = OmitStrict<
25
+ DbUpdate<DocumentationPageRoom>,
26
+ "designSystemVersionId" | "documentationPageId" | "liveblocksId"
27
+ >;
28
+
29
+ //
30
+ // Room content
31
+ //
32
+
33
+ export const DocumentationPageRoomState = z.object({
34
+ pageItems: z.array(PageBlockEditorModelV2.or(PageSectionEditorModelV2)),
35
+ itemConfiguration: DocumentationItemConfigurationV2,
36
+ });
37
+
38
+ export const DocumentationPageRoomRoomUpdate = z.object({
39
+ page: DocumentationPageV2,
40
+ pageParent: ElementGroup,
41
+ });
42
+
43
+ export const DocumentationPageRoomInitialStateUpdate = DocumentationPageRoomRoomUpdate.extend({
44
+ pageItems: z.array(PageBlockEditorModelV2.or(PageSectionEditorModelV2)),
45
+ blockDefinitions: z.array(PageBlockDefinition),
46
+ });
47
+
48
+ export type DocumentationPageRoomState = z.infer<typeof DocumentationPageRoomState>;
49
+ export type DocumentationPageRoomRoomUpdate = z.infer<typeof DocumentationPageRoomRoomUpdate>;
50
+ export type DocumentationPageRoomInitialStateUpdate = z.infer<typeof DocumentationPageRoomInitialStateUpdate>;
@@ -4,6 +4,7 @@ export enum RoomTypeEnum {
4
4
  DocumentationPage = "documentation-page",
5
5
  DesignSystemVersion = "design-system-version",
6
6
  }
7
+
7
8
  export const RoomTypeSchema = z.nativeEnum(RoomTypeEnum);
8
9
 
9
10
  export type RoomType = z.infer<typeof RoomTypeSchema>;
package/src/index.ts CHANGED
@@ -8,7 +8,6 @@ export * from "./dsm";
8
8
  export * from "./feature-flags";
9
9
  export * from "./helpers";
10
10
  export * from "./integrations";
11
- export * from "./multiplayer";
12
11
  export * from "./npm";
13
12
  export * from "./tokens";
14
13
  export * from "./users";
@@ -1,11 +1,12 @@
1
1
  import { z } from "zod";
2
2
  import { ProductCodeSchema } from "../billing";
3
3
  import { WorkspaceIpSettings } from "./workspace";
4
+ import { nullishToOptional } from "../helpers";
4
5
 
5
6
  export const WorkspaceContext = z.object({
6
7
  workspaceId: z.string(),
7
8
  product: ProductCodeSchema,
8
- ipWhitelist: WorkspaceIpSettings,
9
+ ipWhitelist: nullishToOptional(WorkspaceIpSettings),
9
10
  publicDesignSystem: z.boolean().optional(),
10
11
  });
11
12
 
@@ -2,6 +2,9 @@ import { z } from "zod";
2
2
  import { UserInvites } from "./user-invite";
3
3
  import { BillingIntervalSchema, CardSchema, InternalStatusSchema, ProductCodeSchema } from "../billing";
4
4
  import { slugRegex } from "../utils/validation";
5
+ import { SsoProvider } from "./sso-provider";
6
+ import { NpmRegistryConfig } from "./npm-registry-settings";
7
+ import { WorkspaceIpSettings } from "./workspace";
5
8
 
6
9
  const WORKSPACE_NAME_MIN_LENGTH: number = 2;
7
10
  const WORKSPACE_NAME_MAX_LENGTH: number = 64;
@@ -27,6 +30,9 @@ export const CreateWorkspaceInput = z.object({
27
30
  seats: z.number().optional(),
28
31
  seatLimit: z.number().optional(),
29
32
  card: CardSchema.optional(),
33
+ sso: SsoProvider.optional(),
34
+ npmRegistrySettings: NpmRegistryConfig.optional(),
35
+ ipWhitelist: WorkspaceIpSettings.optional(),
30
36
  });
31
37
 
32
38
  export type CreateWorkspaceInput = z.infer<typeof CreateWorkspaceInput>;
@@ -3,21 +3,27 @@ import { Subscription } from "../billing";
3
3
  import { SsoProvider } from "./sso-provider";
4
4
  import { DesignSystem } from "../dsm";
5
5
  import { BillingDetails } from "../billing";
6
+ import IPCIDR from "ip-cidr";
7
+ import { NpmRegistryConfig } from "./npm-registry-settings";
6
8
  import { nullishToOptional } from "../helpers";
7
9
 
10
+ const isValidCIDR = (value: string) => {
11
+ return IPCIDR.isValidAddress(value);
12
+ };
13
+
8
14
  export const WorkspaceIpWhitelistEntry = z.object({
9
15
  isEnabled: z.boolean(),
10
16
  name: z.string(),
11
- range: z.string(),
17
+ range: z.string().refine(isValidCIDR, {
18
+ message: "Invalid IP CIDR",
19
+ }),
12
20
  });
13
21
 
14
- export const WorkspaceIpSettings = z
15
- .object({
16
- isEnabledForCloud: z.boolean(),
17
- isEnabledForDocs: z.boolean(),
18
- entries: z.array(WorkspaceIpWhitelistEntry),
19
- })
20
- .nullish();
22
+ export const WorkspaceIpSettings = z.object({
23
+ isEnabledForCloud: z.boolean(),
24
+ isEnabledForDocs: z.boolean(),
25
+ entries: z.array(WorkspaceIpWhitelistEntry),
26
+ });
21
27
 
22
28
  export const WorkspaceProfile = z.object({
23
29
  name: z.string(),
@@ -31,9 +37,9 @@ export const Workspace = z.object({
31
37
  id: z.string(),
32
38
  profile: WorkspaceProfile,
33
39
  subscription: Subscription,
34
- ipWhitelist: WorkspaceIpSettings,
35
- sso: SsoProvider.nullish(),
36
- npmRegistrySettings: z.unknown().optional(),
40
+ ipWhitelist: nullishToOptional(WorkspaceIpSettings),
41
+ sso: nullishToOptional(SsoProvider),
42
+ npmRegistrySettings: nullishToOptional(NpmRegistryConfig),
37
43
  designSystems: z.array(DesignSystem).nullish(),
38
44
  });
39
45
 
@@ -1,27 +0,0 @@
1
- import { z } from "zod";
2
- import { SafeIdSchema } from "./safe-id";
3
- import { PageBlockFrame } from "./documentation-block-v1";
4
-
5
- export const DocumentationPageAssetType = z.enum(["image", "figmaFrame"]);
6
- export type DocumentationPageAssetType = z.infer<typeof DocumentationPageAssetType>;
7
-
8
- export const DocumentationPageImageAsset = z.object({
9
- type: z.literal(DocumentationPageAssetType.Enum.image),
10
- url: z.string().optional(),
11
- id: SafeIdSchema,
12
- });
13
-
14
- export const DocumentationPageFrameAsset = z.object({
15
- type: z.literal(DocumentationPageAssetType.Enum.figmaFrame),
16
- url: z.string().optional(),
17
- figmaFrame: PageBlockFrame,
18
- });
19
-
20
- export const DocumentationPageAsset = z.discriminatedUnion("type", [
21
- DocumentationPageImageAsset,
22
- DocumentationPageFrameAsset,
23
- ]);
24
-
25
- export type DocumentationPageImageAsset = z.infer<typeof DocumentationPageImageAsset>;
26
- export type DocumentationPageFrameAsset = z.infer<typeof DocumentationPageFrameAsset>;
27
- export type DocumentationPageAsset = z.infer<typeof DocumentationPageAsset>;
@@ -1,38 +0,0 @@
1
- import { z } from "zod";
2
- import { Entity } from "../common/entity";
3
- import { DbCreateInputOmit, DbUpdate } from "../helpers";
4
- import {
5
- DocumentationPageV2,
6
- ElementGroup,
7
- PageBlockDefinition,
8
- PageBlockEditorModelV2,
9
- PageSectionEditorModelV2,
10
- } from "../dsm";
11
-
12
- export const DocumentationPageRoom = Entity.extend({
13
- designSystemVersionId: z.string(),
14
- documentationPageId: z.string(),
15
- liveblocksId: z.string(),
16
- });
17
-
18
- export type DocumentationPageRoom = z.infer<typeof DocumentationPageRoom>;
19
-
20
- export type CreateDocumentationPageRoom = DbCreateInputOmit<DocumentationPageRoom>;
21
- export type UpdateDocumentationPageRoom = DbUpdate<DocumentationPageRoom>;
22
-
23
- //
24
- // Room content
25
- //
26
-
27
- export const DocumentationPageRoomRoomUpdate = z.object({
28
- page: DocumentationPageV2,
29
- pageParent: ElementGroup,
30
- });
31
-
32
- export const DocumentationPageRoomInitialState = DocumentationPageRoomRoomUpdate.extend({
33
- pageBlocks: z.array(PageBlockEditorModelV2.or(PageSectionEditorModelV2)),
34
- blockDefinitions: z.array(PageBlockDefinition),
35
- });
36
-
37
- export type DocumentationPageRoomRoomUpdate = z.infer<typeof DocumentationPageRoomRoomUpdate>;
38
- export type DocumentationPageRoomInitialState = z.infer<typeof DocumentationPageRoomInitialState>;
File without changes