@supernova-studio/client 0.28.1 → 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/client",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "description": "Supernova Data Models",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,11 @@
1
1
  import { DocumentationPageV1, DocumentationPageV2, ElementGroup, slugify } from "@supernova-studio/model";
2
2
  import { mapByUnique } from "@supernova-studio/model";
3
3
 
4
+ type GroupLike = {
5
+ persistentId: string;
6
+ parentPersistentId?: string;
7
+ };
8
+
4
9
  // The fact that DTO conversion is located here instead of main backend code is due to the fact
5
10
  // that we store page and group data in YJS documents in the same way as they are stored in the database.
6
11
  // Therefore, we need to expose this conversion to the client so that it can consume data from YJS documents.
@@ -36,11 +41,11 @@ export function buildDocPagePublishPaths(
36
41
  return result;
37
42
  }
38
43
 
39
- export function calculateElementParentChain(
44
+ export function calculateElementParentChain<T extends GroupLike>(
40
45
  elementParentPersistentId: string,
41
- groupPersistentIdToGroupMap: Map<string, ElementGroup>
42
- ): ElementGroup[] {
43
- const result: ElementGroup[] = [];
46
+ groupPersistentIdToGroupMap: Map<string, T>
47
+ ): T[] {
48
+ const result: T[] = [];
44
49
 
45
50
  let parentId: string | undefined = elementParentPersistentId;
46
51
  while (parentId) {
@@ -0,0 +1 @@
1
+ export * from "./link-preview";
@@ -0,0 +1,23 @@
1
+ import { DocumentationLinkPreview } from "@supernova-studio/model";
2
+ import { z } from "zod";
3
+
4
+ //
5
+ // Read
6
+ //
7
+
8
+ export const DTODocumentationLinkPreviewResponse = z.object({
9
+ linkPreview: DocumentationLinkPreview,
10
+ });
11
+
12
+ export type DTODocumentationLinkPreviewResponse = z.infer<typeof DTODocumentationLinkPreviewResponse>;
13
+
14
+ //
15
+ // Write
16
+ //
17
+
18
+ export const DTODocumentationLinkPreviewRequest = z.object({
19
+ url: z.string().optional(),
20
+ documentationItemPersistentId: z.string().optional(),
21
+ });
22
+
23
+ export type DTODocumentationLinkPreviewRequest = z.infer<typeof DTODocumentationLinkPreviewRequest>;
@@ -50,7 +50,7 @@ export const DTOElementActionOutput = z.discriminatedUnion("type", [
50
50
  DTODocumentationGroupDeleteActionOutputV2,
51
51
  DTODocumentationTabGroupDeleteActionOutputV2,
52
52
 
53
- // // Figma frames
53
+ // Figma frames
54
54
  DTOFigmaNodeRenderActionOutput,
55
55
  ]);
56
56
 
@@ -1,2 +1,3 @@
1
1
  export * from "./documentation";
2
2
  export * from "./liveblocks";
3
+ export * from "./workspaces";
@@ -0,0 +1 @@
1
+ export * from "./workspace-configuration";
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ import { SsoProvider, WorkspaceIpSettings, WorkspaceProfile } from "@supernova-studio/model";
3
+
4
+ const prohibitedSsoKeys = ["providerId", "metadataXml", "emailDomains"];
5
+
6
+ export function validateSsoPayload(ssoPayload: Partial<SsoProvider> | undefined) {
7
+ const keys = [];
8
+ let valid = true;
9
+ if (!ssoPayload) {
10
+ valid = true;
11
+ return {
12
+ valid,
13
+ keys: [],
14
+ };
15
+ }
16
+ for (const key of Object.keys(ssoPayload)) {
17
+ if (prohibitedSsoKeys.includes(key)) {
18
+ keys.push(key);
19
+ valid = false;
20
+ }
21
+ }
22
+ return {
23
+ valid,
24
+ keys,
25
+ };
26
+ }
27
+
28
+ export const NpmRegistryInput = z.object({
29
+ enabledScopes: z.array(z.string()),
30
+ customRegistryUrl: z.string().optional(),
31
+ bypassProxy: z.boolean().optional(),
32
+ npmProxyRegistryConfigId: z.string().optional(),
33
+ npmProxyVersion: z.number().optional(),
34
+ registryType: z.string(),
35
+ authType: z.string(),
36
+ authHeaderName: z.string(),
37
+ authHeaderValue: z.string(),
38
+ accessToken: z.string(),
39
+ username: z.string(),
40
+ password: z.string(),
41
+ });
42
+
43
+ export const WorkspaceConfigurationPayload = z.object({
44
+ ipWhitelist: WorkspaceIpSettings.partial().optional(),
45
+ sso: SsoProvider.partial().optional(),
46
+ npmRegistrySettings: NpmRegistryInput.partial().optional(),
47
+ profile: WorkspaceProfile.partial().optional(),
48
+ });
49
+
50
+ export type WorkspaceConfigurationPayload = z.infer<typeof WorkspaceConfigurationPayload>;
@@ -1,8 +1,17 @@
1
1
  import { PageBlockDefinition } from "@supernova-studio/model";
2
2
 
3
3
  export function getMockPageBlockDefinitions(): PageBlockDefinition[] {
4
- // TODO Blocks
5
- return blocks;
4
+ return blocks.map(block => {
5
+ return {
6
+ ...block,
7
+ item: {
8
+ ...block.item,
9
+
10
+ // Make sure variatns array is copied
11
+ variants: [...block.item.variants],
12
+ },
13
+ };
14
+ });
6
15
  }
7
16
 
8
17
  const blocks: PageBlockDefinition[] = [
@@ -472,56 +472,34 @@ const newSchema = {
472
472
  },
473
473
  },
474
474
  image: {
475
- name: "image",
476
- spec: {
477
- group: "block",
478
- inline: false,
479
- draggable: true,
480
- attrs: {
481
- src: {
482
- default: null,
483
- },
484
- alt: {
485
- default: null,
486
- },
487
- title: {
488
- default: null,
489
- },
490
- },
491
- parseDOM: [
492
- {
493
- tag: 'img[src]:not([src^="data:"])',
494
- },
495
- ],
496
- },
497
- markSet: [],
498
- groups: ["block"],
475
+ group: "block",
476
+ atom: true,
477
+ draggable: true,
499
478
  attrs: {
500
- src: {
501
- hasDefault: true,
479
+ id: {
502
480
  default: null,
503
481
  },
504
- alt: {
505
- hasDefault: true,
482
+ definitionId: {
506
483
  default: null,
507
484
  },
508
- title: {
509
- hasDefault: true,
485
+ variantId: {
510
486
  default: null,
511
487
  },
488
+ appearance: {
489
+ default: "{}",
490
+ },
491
+ columns: {
492
+ default: 1,
493
+ },
494
+ items: {
495
+ default: "[]",
496
+ },
512
497
  },
513
- defaultAttrs: {
514
- src: null,
515
- alt: null,
516
- title: null,
517
- },
518
- contentMatch: {
519
- validEnd: true,
520
- wrapCache: [],
521
- },
522
- inlineContent: false,
523
- isBlock: true,
524
- isText: false,
498
+ parseDOM: [
499
+ {
500
+ tag: "block-node",
501
+ },
502
+ ],
525
503
  },
526
504
  },
527
505
  marks: {
@@ -177,13 +177,18 @@ function internalProsemirrorNodeToBlock(
177
177
  prosemirrorNode: ProsemirrorNode,
178
178
  definitionsMap: Map<string, PageBlockDefinition>
179
179
  ) {
180
- const definitionId = getProsemirrorAttribute(prosemirrorNode, "definitionId", z.string());
180
+ let definitionId = getProsemirrorAttribute(prosemirrorNode, "definitionId", z.string());
181
181
  if (!definitionId) {
182
182
  console.warn(`definitionId on ${prosemirrorNode.type} is required to be interpreted as a block, skipping node`);
183
183
 
184
184
  return null;
185
185
  }
186
186
 
187
+ // TODO: remove
188
+ if (definitionId === "io.supernova.block.token-detail") {
189
+ definitionId = "io.supernova.block.token-list";
190
+ }
191
+
187
192
  const definition = definitionsMap.get(definitionId);
188
193
  if (!definition) {
189
194
  console.warn(