@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/dist/index.d.mts +444 -48
- package/dist/index.d.ts +444 -48
- package/dist/index.js +212 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1366 -1270
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +9 -4
- package/src/api/dto/documentation/index.ts +1 -0
- package/src/api/dto/documentation/link-preview.ts +23 -0
- package/src/api/dto/elements/elements-action-v2.ts +1 -1
- package/src/api/payloads/index.ts +1 -0
- package/src/api/payloads/workspaces/index.ts +1 -0
- package/src/api/payloads/workspaces/workspace-configuration.ts +50 -0
- package/src/yjs/docs-editor/mock.ts +11 -2
- package/src/yjs/docs-editor/prosemirror/schema.ts +20 -42
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +6 -1
package/package.json
CHANGED
|
@@ -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,
|
|
42
|
-
):
|
|
43
|
-
const result:
|
|
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>;
|
|
@@ -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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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
|
-
|
|
501
|
-
hasDefault: true,
|
|
479
|
+
id: {
|
|
502
480
|
default: null,
|
|
503
481
|
},
|
|
504
|
-
|
|
505
|
-
hasDefault: true,
|
|
482
|
+
definitionId: {
|
|
506
483
|
default: null,
|
|
507
484
|
},
|
|
508
|
-
|
|
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
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
-
|
|
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(
|