@supernova-studio/client 0.59.12 → 1.0.0-alpha.11
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 +1592 -1952
- package/dist/index.d.ts +1592 -1952
- package/dist/index.js +865 -392
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2569 -2096
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/src/api/client.ts +0 -31
- package/src/api/conversion/documentation/documentation-group-v1-to-dto.ts +0 -114
- package/src/api/conversion/documentation/documentation-group-v2-to-dto.ts +0 -92
- package/src/api/conversion/documentation/documentation-item-configuration-v1-to-dto.ts +0 -52
- package/src/api/conversion/documentation/documentation-item-configuration-v2-to-dto.ts +0 -34
- package/src/api/conversion/documentation/documentation-page-to-dto-utils.ts +0 -131
- package/src/api/conversion/documentation/documentation-page-v1-to-dto.ts +0 -69
- package/src/api/conversion/documentation/documentation-page-v2-to-dto.ts +0 -78
- package/src/api/conversion/documentation/index.ts +0 -7
- package/src/api/conversion/export/index.ts +0 -1
- package/src/api/conversion/export/pipeline.ts +0 -26
- package/src/api/conversion/index.ts +0 -3
- package/src/api/conversion/integrations/git.ts +0 -37
- package/src/api/conversion/integrations/index.ts +0 -2
- package/src/api/conversion/integrations/integration.ts +0 -37
- package/src/api/dto/aux/color.ts +0 -7
- package/src/api/dto/aux/index.ts +0 -3
- package/src/api/dto/aux/meta.ts +0 -8
- package/src/api/dto/aux/pagination.ts +0 -8
- package/src/api/dto/bff/app-bootstrap-data.ts +0 -20
- package/src/api/dto/bff/index.ts +0 -1
- package/src/api/dto/collections/index.ts +0 -1
- package/src/api/dto/collections/token-collection.ts +0 -24
- package/src/api/dto/design-systems/brand.ts +0 -44
- package/src/api/dto/design-systems/component.ts +0 -40
- package/src/api/dto/design-systems/contact.ts +0 -11
- package/src/api/dto/design-systems/data-source.ts +0 -141
- package/src/api/dto/design-systems/design-system.ts +0 -68
- package/src/api/dto/design-systems/elements-diff.ts +0 -14
- package/src/api/dto/design-systems/figma-variables.ts +0 -108
- package/src/api/dto/design-systems/import-job.ts +0 -61
- package/src/api/dto/design-systems/index.ts +0 -15
- package/src/api/dto/design-systems/members.ts +0 -50
- package/src/api/dto/design-systems/redirects.ts +0 -33
- package/src/api/dto/design-systems/role.ts +0 -11
- package/src/api/dto/design-systems/stats.ts +0 -19
- package/src/api/dto/design-systems/version-room.ts +0 -12
- package/src/api/dto/design-systems/version.ts +0 -56
- package/src/api/dto/design-systems/view.ts +0 -45
- package/src/api/dto/design-tokens/design-token.ts +0 -78
- package/src/api/dto/design-tokens/index.ts +0 -1
- package/src/api/dto/documentation/anchor.ts +0 -15
- package/src/api/dto/documentation/approvals.ts +0 -15
- package/src/api/dto/documentation/block-definition.ts +0 -28
- package/src/api/dto/documentation/block.ts +0 -6
- package/src/api/dto/documentation/documentation-page-snapshot.ts +0 -18
- package/src/api/dto/documentation/index.ts +0 -8
- package/src/api/dto/documentation/link-preview.ts +0 -23
- package/src/api/dto/documentation/publish.ts +0 -23
- package/src/api/dto/documentation/room.ts +0 -12
- package/src/api/dto/elements/components/figma-component-group.ts +0 -19
- package/src/api/dto/elements/components/figma-component.ts +0 -56
- package/src/api/dto/elements/components/index.ts +0 -2
- package/src/api/dto/elements/documentation/draft-state.ts +0 -37
- package/src/api/dto/elements/documentation/group-action.ts +0 -108
- package/src/api/dto/elements/documentation/group-v1.ts +0 -35
- package/src/api/dto/elements/documentation/group-v2.ts +0 -117
- package/src/api/dto/elements/documentation/hierarchy.ts +0 -22
- package/src/api/dto/elements/documentation/index.ts +0 -13
- package/src/api/dto/elements/documentation/item-configuration-v1.ts +0 -24
- package/src/api/dto/elements/documentation/item-configuration-v2.ts +0 -14
- package/src/api/dto/elements/documentation/metadata.ts +0 -8
- package/src/api/dto/elements/documentation/page-actions-v2.ts +0 -121
- package/src/api/dto/elements/documentation/page-content.ts +0 -15
- package/src/api/dto/elements/documentation/page-v1.ts +0 -21
- package/src/api/dto/elements/documentation/page-v2.ts +0 -123
- package/src/api/dto/elements/documentation/structure.ts +0 -37
- package/src/api/dto/elements/elements-action-v2.ts +0 -117
- package/src/api/dto/elements/figma-nodes/figma-node-v1.ts +0 -32
- package/src/api/dto/elements/figma-nodes/figma-node-v2.ts +0 -32
- package/src/api/dto/elements/figma-nodes/figma-node.ts +0 -103
- package/src/api/dto/elements/figma-nodes/index.ts +0 -4
- package/src/api/dto/elements/figma-nodes/node-actions-v2.ts +0 -44
- package/src/api/dto/elements/frame-node-structures/frame-node-structure.ts +0 -17
- package/src/api/dto/elements/frame-node-structures/index.ts +0 -1
- package/src/api/dto/elements/get-elements-v2.ts +0 -27
- package/src/api/dto/elements/index.ts +0 -7
- package/src/api/dto/elements/properties/index.ts +0 -2
- package/src/api/dto/elements/properties/property-definitions.ts +0 -75
- package/src/api/dto/elements/properties/property-values.ts +0 -38
- package/src/api/dto/export/exporter-property.ts +0 -105
- package/src/api/dto/export/exporter.ts +0 -87
- package/src/api/dto/export/filter.ts +0 -6
- package/src/api/dto/export/index.ts +0 -5
- package/src/api/dto/export/job.ts +0 -96
- package/src/api/dto/export/pipeline.ts +0 -43
- package/src/api/dto/figma-components/assets/download.ts +0 -30
- package/src/api/dto/figma-components/assets/index.ts +0 -1
- package/src/api/dto/figma-components/index.ts +0 -1
- package/src/api/dto/index.ts +0 -13
- package/src/api/dto/liveblocks/auth-response.ts +0 -7
- package/src/api/dto/liveblocks/index.ts +0 -1
- package/src/api/dto/themes/index.ts +0 -2
- package/src/api/dto/themes/override.ts +0 -27
- package/src/api/dto/themes/theme.ts +0 -45
- package/src/api/dto/users/authenticated-user.ts +0 -46
- package/src/api/dto/users/index.ts +0 -3
- package/src/api/dto/users/update.ts +0 -8
- package/src/api/dto/users/user.ts +0 -31
- package/src/api/dto/workspaces/git.ts +0 -32
- package/src/api/dto/workspaces/index.ts +0 -6
- package/src/api/dto/workspaces/integrations.ts +0 -34
- package/src/api/dto/workspaces/invitations.ts +0 -30
- package/src/api/dto/workspaces/membership.ts +0 -41
- package/src/api/dto/workspaces/npm-registry.ts +0 -35
- package/src/api/dto/workspaces/workspace.ts +0 -34
- package/src/api/endpoints/codegen/codegen.ts +0 -16
- package/src/api/endpoints/codegen/exporters.ts +0 -25
- package/src/api/endpoints/codegen/index.ts +0 -4
- package/src/api/endpoints/codegen/jobs.ts +0 -15
- package/src/api/endpoints/codegen/pipelines.ts +0 -44
- package/src/api/endpoints/design-system/bff.ts +0 -13
- package/src/api/endpoints/design-system/contact.ts +0 -12
- package/src/api/endpoints/design-system/design-systems.ts +0 -55
- package/src/api/endpoints/design-system/index.ts +0 -6
- package/src/api/endpoints/design-system/members.ts +0 -24
- package/src/api/endpoints/design-system/sources.ts +0 -35
- package/src/api/endpoints/design-system/versions/brands.ts +0 -45
- package/src/api/endpoints/design-system/versions/documentation.ts +0 -27
- package/src/api/endpoints/design-system/versions/ds-components.ts +0 -28
- package/src/api/endpoints/design-system/versions/elements-action.ts +0 -63
- package/src/api/endpoints/design-system/versions/elements.ts +0 -27
- package/src/api/endpoints/design-system/versions/figma-component-groups.ts +0 -13
- package/src/api/endpoints/design-system/versions/figma-components.ts +0 -13
- package/src/api/endpoints/design-system/versions/figma-frame-structures.ts +0 -13
- package/src/api/endpoints/design-system/versions/import-jobs.ts +0 -13
- package/src/api/endpoints/design-system/versions/index.ts +0 -18
- package/src/api/endpoints/design-system/versions/overrides.ts +0 -17
- package/src/api/endpoints/design-system/versions/property-definitions.ts +0 -43
- package/src/api/endpoints/design-system/versions/property-values.ts +0 -25
- package/src/api/endpoints/design-system/versions/stats.ts +0 -12
- package/src/api/endpoints/design-system/versions/themes.ts +0 -35
- package/src/api/endpoints/design-system/versions/token-collections.ts +0 -13
- package/src/api/endpoints/design-system/versions/token-groups.ts +0 -28
- package/src/api/endpoints/design-system/versions/tokens.ts +0 -27
- package/src/api/endpoints/design-system/versions/versions.ts +0 -87
- package/src/api/endpoints/index.ts +0 -5
- package/src/api/endpoints/liveblocks.ts +0 -14
- package/src/api/endpoints/users.ts +0 -26
- package/src/api/endpoints/workspaces/index.ts +0 -3
- package/src/api/endpoints/workspaces/workspace-invites.ts +0 -34
- package/src/api/endpoints/workspaces/workspace-members.ts +0 -31
- package/src/api/endpoints/workspaces/workspaces.ts +0 -47
- package/src/api/index.ts +0 -6
- package/src/api/payloads/design-systems/index.ts +0 -2
- package/src/api/payloads/design-systems/update-design-system.ts +0 -29
- package/src/api/payloads/design-systems/version.ts +0 -29
- package/src/api/payloads/documentation/block-definitions.ts +0 -12
- package/src/api/payloads/documentation/design-data-doc-diff.ts +0 -7
- package/src/api/payloads/documentation/index.ts +0 -2
- package/src/api/payloads/export/index.ts +0 -1
- package/src/api/payloads/export/pipeline.ts +0 -74
- package/src/api/payloads/index.ts +0 -6
- package/src/api/payloads/liveblocks/auth.ts +0 -7
- package/src/api/payloads/liveblocks/index.ts +0 -1
- package/src/api/payloads/users/index.ts +0 -2
- package/src/api/payloads/users/notifications/index.ts +0 -1
- package/src/api/payloads/users/notifications/notification-settings.ts +0 -17
- package/src/api/payloads/users/profile/index.ts +0 -1
- package/src/api/payloads/users/profile/update.ts +0 -4
- package/src/api/payloads/workspaces/index.ts +0 -3
- package/src/api/payloads/workspaces/transfer-ownership.ts +0 -7
- package/src/api/payloads/workspaces/workspace-configuration.ts +0 -50
- package/src/api/payloads/workspaces/workspace-integrations.ts +0 -26
- package/src/api/transport/index.ts +0 -2
- package/src/api/transport/request-executor-error.ts +0 -66
- package/src/api/transport/request-executor.ts +0 -87
- package/src/events/design-system.ts +0 -21
- package/src/events/event.ts +0 -6
- package/src/events/index.ts +0 -2
- package/src/index.ts +0 -4
- package/src/utils/figma.ts +0 -72
- package/src/utils/hash.ts +0 -62
- package/src/utils/index.ts +0 -3
- package/src/utils/query.ts +0 -18
- package/src/yjs/design-system-content/documentation-hierarchy.ts +0 -35
- package/src/yjs/design-system-content/index.ts +0 -2
- package/src/yjs/design-system-content/item-configuration.ts +0 -93
- package/src/yjs/docs-editor/blocks-to-prosemirror.ts +0 -764
- package/src/yjs/docs-editor/index.ts +0 -7
- package/src/yjs/docs-editor/list-tree-builder.ts +0 -127
- package/src/yjs/docs-editor/mock.ts +0 -2142
- package/src/yjs/docs-editor/model/block.ts +0 -8
- package/src/yjs/docs-editor/model/index.ts +0 -2
- package/src/yjs/docs-editor/model/page.ts +0 -8
- package/src/yjs/docs-editor/prosemirror/index.ts +0 -3
- package/src/yjs/docs-editor/prosemirror/inner-editor-schema.ts +0 -145
- package/src/yjs/docs-editor/prosemirror/main-editor-schema.ts +0 -577
- package/src/yjs/docs-editor/prosemirror/types.ts +0 -19
- package/src/yjs/docs-editor/prosemirror-to-blocks.ts +0 -975
- package/src/yjs/docs-editor/utils.ts +0 -115
- package/src/yjs/index.ts +0 -3
- package/src/yjs/version-room/backend.ts +0 -83
- package/src/yjs/version-room/base.ts +0 -252
- package/src/yjs/version-room/frontend.ts +0 -463
- package/src/yjs/version-room/index.ts +0 -4
- package/src/yjs/version-room/utils.ts +0 -109
|
@@ -1,50 +0,0 @@
|
|
|
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,26 +0,0 @@
|
|
|
1
|
-
import { IntegrationToken, IntegrationType } from "@supernova-studio/model";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const DTOWorkspaceIntegrationOauthInput = z.object({
|
|
5
|
-
type: IntegrationType,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export type DTOWorkspaceIntegrationOauthInput = z.infer<typeof DTOWorkspaceIntegrationOauthInput>;
|
|
9
|
-
|
|
10
|
-
export const DTOWorkspaceIntegrationPATInput = z.object({
|
|
11
|
-
userId: z.string(),
|
|
12
|
-
type: IntegrationType,
|
|
13
|
-
token: IntegrationToken,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export type DTOWorkspaceIntegrationPATInput = z.infer<typeof DTOWorkspaceIntegrationPATInput>;
|
|
17
|
-
|
|
18
|
-
export const DTOWorkspaceIntegrationGetGitObjectsInput = z.object({
|
|
19
|
-
organization: z.string().optional(), // Azure Organization | Bitbucket Workspace slug | Gitlab Group and Sub-Groups | Github Account (User or Organization)
|
|
20
|
-
project: z.string().optional(), // Only for Bitbucket and Azure
|
|
21
|
-
repository: z.string().optional(), // For all providers. Pay attention for Gitlab, they call repositories "projects".
|
|
22
|
-
branch: z.string().optional(), // For all providers, useful for PR creations.
|
|
23
|
-
user: z.string().optional(), // Only for Gitlab User Repositories
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export type DTOWorkspaceIntegrationGetGitObjectsInput = z.infer<typeof DTOWorkspaceIntegrationGetGitObjectsInput>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { SupernovaExceptionType } from "@supernova-studio/model";
|
|
2
|
-
|
|
3
|
-
export type RequestExecutorErrorType = "ServerError" | "ResponseParsingError";
|
|
4
|
-
export type RequestEexecutorServerErrorCode = SupernovaExceptionType | undefined;
|
|
5
|
-
|
|
6
|
-
export class RequestExecutorError extends Error {
|
|
7
|
-
readonly type: RequestExecutorErrorType;
|
|
8
|
-
readonly errorCode: RequestEexecutorServerErrorCode | undefined;
|
|
9
|
-
readonly serverErrorType: SupernovaExceptionType | undefined;
|
|
10
|
-
|
|
11
|
-
static tryParseErrorCode(body: string) {
|
|
12
|
-
try {
|
|
13
|
-
const errorObj = JSON.parse(body);
|
|
14
|
-
if (errorObj && typeof errorObj.errorCode === "string") {
|
|
15
|
-
return errorObj.errorCode;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static tryParseServerErrorType(body: string) {
|
|
24
|
-
try {
|
|
25
|
-
const errorObj = JSON.parse(body);
|
|
26
|
-
if (errorObj && typeof errorObj.errorCode === "string") {
|
|
27
|
-
return errorObj.type;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
} catch (e) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static serverError(endpoint: string, status: number, bodyText: string) {
|
|
36
|
-
return new RequestExecutorError(
|
|
37
|
-
"ServerError",
|
|
38
|
-
`Endpoint ${endpoint} returned ${status}\n${bodyText}`,
|
|
39
|
-
this.tryParseErrorCode(bodyText),
|
|
40
|
-
this.tryParseServerErrorType(bodyText)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static responseParsingError(endpoint: string, cause: Error) {
|
|
45
|
-
return new RequestExecutorError(
|
|
46
|
-
"ResponseParsingError",
|
|
47
|
-
`Endpoint ${endpoint} returned incompatible JSON`,
|
|
48
|
-
undefined,
|
|
49
|
-
undefined,
|
|
50
|
-
cause
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private constructor(
|
|
55
|
-
type: RequestExecutorErrorType,
|
|
56
|
-
message: string,
|
|
57
|
-
errorCode: RequestEexecutorServerErrorCode | undefined,
|
|
58
|
-
serverErrorType?: SupernovaExceptionType | undefined,
|
|
59
|
-
cause?: unknown
|
|
60
|
-
) {
|
|
61
|
-
super(`${type}: ${message}`, { cause });
|
|
62
|
-
this.type = type;
|
|
63
|
-
this.errorCode = errorCode;
|
|
64
|
-
this.serverErrorType = serverErrorType;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import fetch, { RequestInit } from "node-fetch";
|
|
2
|
-
import { z, ZodSchema, ZodTypeDef } from "zod";
|
|
3
|
-
import { RequestExecutorError } from "./request-executor-error";
|
|
4
|
-
|
|
5
|
-
export type RequestExecutorConfig = {
|
|
6
|
-
host: string;
|
|
7
|
-
accessToken?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type RequestExecutorJSONRequest = Omit<RequestInit, "body"> & {
|
|
11
|
-
body?: object;
|
|
12
|
-
query?: URLSearchParams;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const ResponseWrapper = z.object({
|
|
16
|
-
result: z.record(z.any()),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export class RequestExecutor {
|
|
20
|
-
private readonly testServerConfig: RequestExecutorConfig;
|
|
21
|
-
|
|
22
|
-
constructor(testServerConfig: RequestExecutorConfig) {
|
|
23
|
-
this.testServerConfig = testServerConfig;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async json<O, I>(
|
|
27
|
-
path: `/${string}`,
|
|
28
|
-
schema: ZodSchema<O, ZodTypeDef, I>,
|
|
29
|
-
requestInit: RequestExecutorJSONRequest = {}
|
|
30
|
-
) {
|
|
31
|
-
// Headers
|
|
32
|
-
const defaultHeaders: Record<string, string> = {
|
|
33
|
-
Accept: "application/json",
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (requestInit.body) defaultHeaders["Content-Type"] = "application/json";
|
|
37
|
-
if (this.testServerConfig.accessToken) {
|
|
38
|
-
defaultHeaders["Authorization"] = `Bearer ${this.testServerConfig.accessToken}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Body
|
|
42
|
-
let body: string | undefined;
|
|
43
|
-
if (requestInit.body && typeof requestInit.body === "object") body = JSON.stringify(requestInit.body);
|
|
44
|
-
|
|
45
|
-
const response = await fetch(this.fullUrl(path, requestInit.query), {
|
|
46
|
-
...requestInit,
|
|
47
|
-
headers: {
|
|
48
|
-
...requestInit.headers,
|
|
49
|
-
...defaultHeaders,
|
|
50
|
-
},
|
|
51
|
-
body: body,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const endpoint = `${requestInit.method ?? "GET"} ${path}`;
|
|
55
|
-
|
|
56
|
-
if (!response.ok) {
|
|
57
|
-
const bodyString = await response.text();
|
|
58
|
-
throw RequestExecutorError.serverError(endpoint, response.status, bodyString);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const json = await response.json();
|
|
62
|
-
const wrapperParseResult = ResponseWrapper.safeParse(json);
|
|
63
|
-
if (!wrapperParseResult.success) {
|
|
64
|
-
console.error(`Response was:`);
|
|
65
|
-
console.error(json);
|
|
66
|
-
throw RequestExecutorError.responseParsingError(endpoint, wrapperParseResult.error);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const responseParseResult = schema.safeParse(wrapperParseResult.data.result);
|
|
70
|
-
if (!responseParseResult.success) {
|
|
71
|
-
console.error(`Response was:`);
|
|
72
|
-
console.error(wrapperParseResult.data.result);
|
|
73
|
-
throw RequestExecutorError.responseParsingError(endpoint, responseParseResult.error);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return responseParseResult.data;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private fullUrl(path: string, query: URLSearchParams | undefined): string {
|
|
80
|
-
let url = `https://${this.testServerConfig.host}/api/v2${path}`;
|
|
81
|
-
|
|
82
|
-
const queryString = query?.toString();
|
|
83
|
-
if (queryString) url += `?${queryString}`;
|
|
84
|
-
|
|
85
|
-
return url;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DataSourceRemoteType } from "@supernova-studio/model";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const DTOEventFigmaNodesRendered = z.object({
|
|
5
|
-
type: z.literal("DesignSystem.FigmaNodesRendered"),
|
|
6
|
-
designSystemId: z.string(),
|
|
7
|
-
versionId: z.string(),
|
|
8
|
-
figmaNodePersistentIds: z.string().array(),
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export const DTOEventDataSourcesImported = z.object({
|
|
12
|
-
type: z.literal("DesignSystem.ImportJobFinished"),
|
|
13
|
-
designSystemId: z.string(),
|
|
14
|
-
versionId: z.string(),
|
|
15
|
-
importJobId: z.string(),
|
|
16
|
-
dataSourceType: DataSourceRemoteType,
|
|
17
|
-
dataSourceIds: z.string().array(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export type DTOEventFigmaNodesRendered = z.infer<typeof DTOEventFigmaNodesRendered>;
|
|
21
|
-
export type DTOEventDataSourcesImported = z.infer<typeof DTOEventDataSourcesImported>;
|
package/src/events/event.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DTOEventDataSourcesImported, DTOEventFigmaNodesRendered } from "./design-system";
|
|
3
|
-
|
|
4
|
-
export const DTOEvent = z.discriminatedUnion("type", [DTOEventDataSourcesImported, DTOEventFigmaNodesRendered]);
|
|
5
|
-
|
|
6
|
-
export type DTOEvent = z.infer<typeof DTOEvent>;
|
package/src/events/index.ts
DELETED
package/src/index.ts
DELETED
package/src/utils/figma.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const figmaFileIdRegex = /^[0-9a-zA-Z]{22,128}$/;
|
|
2
|
-
const nodeIdRegex = /^\d+-\d+$/;
|
|
3
|
-
const nodeTypeRegex = /^[0-9a-zA-Z]^/;
|
|
4
|
-
|
|
5
|
-
export enum ParsedFigmaFileURLError {
|
|
6
|
-
InvalidUrl = "InvalidUrl",
|
|
7
|
-
InvalidFigmaFileId = "InvalidFigmaFileId",
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type ParsedFigmaFileURL =
|
|
11
|
-
| {
|
|
12
|
-
status: "Success";
|
|
13
|
-
fileId: string;
|
|
14
|
-
fileName: string | null;
|
|
15
|
-
nodeId: string | null;
|
|
16
|
-
nodeType: string | null;
|
|
17
|
-
}
|
|
18
|
-
| {
|
|
19
|
-
status: "Error";
|
|
20
|
-
error: ParsedFigmaFileURLError;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const FigmaUtils = {
|
|
24
|
-
tryParseFigmaFileURL(urlString: string): ParsedFigmaFileURL {
|
|
25
|
-
if (!URL.canParse(urlString)) {
|
|
26
|
-
return { status: "Error", error: ParsedFigmaFileURLError.InvalidUrl };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Validate that this is a Figma URL
|
|
30
|
-
const url = new URL(urlString);
|
|
31
|
-
if (!url.hostname.endsWith("figma.com")) {
|
|
32
|
-
return { status: "Error", error: ParsedFigmaFileURLError.InvalidUrl };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Validate that the URL type is the correct one (pointing to a design file)
|
|
36
|
-
const pathSegments = url.pathname.split("/");
|
|
37
|
-
if (pathSegments[1] !== "design" && pathSegments[1] !== "file") {
|
|
38
|
-
return { status: "Error", error: ParsedFigmaFileURLError.InvalidUrl };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Validate Figma file ID
|
|
42
|
-
const fileId = pathSegments[2];
|
|
43
|
-
if (!fileId || !fileId.match(figmaFileIdRegex)) {
|
|
44
|
-
return { status: "Error", error: ParsedFigmaFileURLError.InvalidFigmaFileId };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Parse Figma file name
|
|
48
|
-
let fileName: string | null = null;
|
|
49
|
-
const rawFileName = pathSegments[3];
|
|
50
|
-
if (rawFileName) {
|
|
51
|
-
fileName = rawFileName.replaceAll("-", " ");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Parse node id
|
|
55
|
-
let nodeId: string | null = null;
|
|
56
|
-
const nodeIdRaw = url.searchParams.get("node-id");
|
|
57
|
-
if (nodeIdRaw && nodeIdRaw.match(nodeIdRegex)) {
|
|
58
|
-
nodeId = nodeIdRaw.replace("-", ":");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Parse node type
|
|
62
|
-
let nodeType: string | null = null;
|
|
63
|
-
const nodeTypeRaw = url.searchParams.get("node-type");
|
|
64
|
-
if (nodeTypeRaw && nodeTypeRaw.match(nodeTypeRegex)) {
|
|
65
|
-
nodeType = nodeTypeRaw;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return { status: "Success", fileId, fileName, nodeId, nodeType };
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// https://www.figma.com/design/U3Mg3I8WbvqF6CcZtRJM7w?node-id=2-3&t=9Qev2vhsldyFMhuE-1
|
package/src/utils/hash.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
function hash(input: string): string {
|
|
2
|
-
return farmhash(input).toString(16);
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function farmhash(input: string): number {
|
|
6
|
-
const seed = 0x9e3779b9;
|
|
7
|
-
let hash = seed;
|
|
8
|
-
|
|
9
|
-
for (let i = 0; i < input.length; i++) {
|
|
10
|
-
const charCode = input.charCodeAt(i);
|
|
11
|
-
hash ^= charCode;
|
|
12
|
-
hash = Math.imul(hash, 0x5bd1e995);
|
|
13
|
-
hash ^= hash >>> 15;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
hash = Math.imul(hash, 0x5bd1e995);
|
|
17
|
-
hash ^= hash >>> 13;
|
|
18
|
-
hash = Math.imul(hash, 0x5bd1e995);
|
|
19
|
-
hash ^= hash >>> 15;
|
|
20
|
-
|
|
21
|
-
return hash >>> 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function prepareObject(obj: any): any {
|
|
25
|
-
if (obj === null || typeof obj !== "object") {
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(obj)) {
|
|
29
|
-
return obj.map(prepareObject);
|
|
30
|
-
}
|
|
31
|
-
const sortedObj: any = {};
|
|
32
|
-
for (const key of Object.keys(obj).sort()) {
|
|
33
|
-
if (obj[key] === null || obj[key] === undefined) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
sortedObj[key] = prepareObject(obj[key]);
|
|
37
|
-
}
|
|
38
|
-
return sortedObj;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function generateHash(input: object | string, debug = false): string {
|
|
42
|
-
if (typeof input === "object") {
|
|
43
|
-
const sanitized = JSON.stringify(prepareObject(input));
|
|
44
|
-
if (debug) {
|
|
45
|
-
console.log("Hashing sanitized string:");
|
|
46
|
-
console.log(sanitized);
|
|
47
|
-
}
|
|
48
|
-
return hash(sanitized);
|
|
49
|
-
} else {
|
|
50
|
-
try {
|
|
51
|
-
const obj = JSON.parse(input);
|
|
52
|
-
const sanitized = JSON.stringify(prepareObject(obj));
|
|
53
|
-
if (debug) {
|
|
54
|
-
console.log("Hashing sanitized string:");
|
|
55
|
-
console.log(sanitized);
|
|
56
|
-
}
|
|
57
|
-
return hash(sanitized);
|
|
58
|
-
} catch {
|
|
59
|
-
return hash(input);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
package/src/utils/index.ts
DELETED
package/src/utils/query.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
type CompatibleValue = number | string | boolean | undefined;
|
|
2
|
-
type QueryObject = Record<string, CompatibleValue | CompatibleValue[]>;
|
|
3
|
-
|
|
4
|
-
export function serializeQuery(query: QueryObject): URLSearchParams {
|
|
5
|
-
const queryWithStrings = Object.fromEntries(
|
|
6
|
-
Object.entries(query)
|
|
7
|
-
.filter(e => !!e[1])
|
|
8
|
-
.map(([k, v]) => {
|
|
9
|
-
if (Array.isArray(v)) {
|
|
10
|
-
return [k, v.join(", ")];
|
|
11
|
-
} else {
|
|
12
|
-
return [k, v!.toString()];
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
return new URLSearchParams(queryWithStrings);
|
|
18
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { DTODocumentationHierarchyV2 } from "../../api";
|
|
4
|
-
import { FrontendVersionRoomYDoc } from "../version-room/frontend";
|
|
5
|
-
|
|
6
|
-
// We store pages and groups in the same way they are stored in the database.
|
|
7
|
-
// This means that instead of groups having childrenIds array, all items have
|
|
8
|
-
// parentPersistentId property that points to the parent item in the tree.
|
|
9
|
-
// Upon read this gets converted to the format that client expects, which is
|
|
10
|
-
// ordered childrenIds array on all groups.
|
|
11
|
-
//
|
|
12
|
-
// The decision behind it is that we potentially want to get rid of childrenIds
|
|
13
|
-
// array entirely because it makes group updates more complicated. For now
|
|
14
|
-
// resolving it on fly is a tradeoff for not rewriting client to stop relying
|
|
15
|
-
// on children ids array.
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
// Types
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
export const DocumentationHierarchySettings = z.object({
|
|
22
|
-
routingVersion: z.string(),
|
|
23
|
-
isDraftFeatureAdopted: z.boolean(),
|
|
24
|
-
isApprovalFeatureEnabled: z.boolean(),
|
|
25
|
-
approvalRequiredForPublishing: z.boolean(),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export type DocumentationHierarchySettings = z.infer<typeof DocumentationHierarchySettings>;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated - Use FrontendVersionRoomYDoc.getDocumentationHierarchy
|
|
32
|
-
*/
|
|
33
|
-
export function yjsToDocumentationHierarchy(doc: Y.Doc): DTODocumentationHierarchyV2 {
|
|
34
|
-
return new FrontendVersionRoomYDoc(doc).getDocumentationHierarchy();
|
|
35
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { DocumentationItemHeaderV2 } from "@supernova-studio/model";
|
|
2
|
-
import * as Y from "yjs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { DTODocumentationItemConfigurationV2 } from "../../api/dto/elements/documentation/item-configuration-v2";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
// Types
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
export const DTODocumentationPageRoomHeaderData = z.object({
|
|
11
|
-
title: z.string(),
|
|
12
|
-
configuration: DTODocumentationItemConfigurationV2,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const DTODocumentationPageRoomHeaderDataUpdate = z.object({
|
|
16
|
-
title: z.string().optional(),
|
|
17
|
-
configuration: DTODocumentationItemConfigurationV2.omit({ header: true })
|
|
18
|
-
.extend({ header: DocumentationItemHeaderV2.partial() })
|
|
19
|
-
.optional(),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export type DTODocumentationPageRoomHeaderData = z.infer<typeof DTODocumentationPageRoomHeaderData>;
|
|
23
|
-
export type DTODocumentationPageRoomHeaderDataUpdate = z.infer<typeof DTODocumentationPageRoomHeaderDataUpdate>;
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
// YJS Bindings
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
export function itemConfigurationToYjs(yDoc: Y.Doc, item: DTODocumentationPageRoomHeaderDataUpdate) {
|
|
30
|
-
yDoc.transact(trx => {
|
|
31
|
-
const { title, configuration } = item;
|
|
32
|
-
|
|
33
|
-
const header = configuration?.header;
|
|
34
|
-
|
|
35
|
-
if (title !== undefined) {
|
|
36
|
-
const headerYMap = trx.doc.getMap("itemTitle");
|
|
37
|
-
headerYMap.set("title", title);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (header) {
|
|
41
|
-
const headerYMap = trx.doc.getMap("itemHeader");
|
|
42
|
-
|
|
43
|
-
header.description !== undefined && headerYMap.set("description", header.description);
|
|
44
|
-
header.alignment !== undefined && headerYMap.set("alignment", header.alignment);
|
|
45
|
-
header.foregroundColor !== undefined && headerYMap.set("foregroundColor", header.foregroundColor);
|
|
46
|
-
header.backgroundColor !== undefined && headerYMap.set("backgroundColor", header.backgroundColor);
|
|
47
|
-
header.backgroundImageAsset !== undefined && headerYMap.set("backgroundImageAsset", header.backgroundImageAsset);
|
|
48
|
-
header.backgroundImageScaleType !== undefined &&
|
|
49
|
-
headerYMap.set("backgroundImageScaleType", header.backgroundImageScaleType);
|
|
50
|
-
header.showBackgroundOverlay !== undefined &&
|
|
51
|
-
headerYMap.set("showBackgroundOverlay", header.showBackgroundOverlay);
|
|
52
|
-
header.showCoverText !== undefined && headerYMap.set("showCoverText", header.showCoverText);
|
|
53
|
-
header.minHeight !== undefined && headerYMap.set("minHeight", header.minHeight);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const configYMap = trx.doc.getMap("itemConfiguration");
|
|
57
|
-
|
|
58
|
-
configuration?.showSidebar !== undefined && configYMap.set("showSidebar", configuration.showSidebar);
|
|
59
|
-
configuration?.isHidden !== undefined && configYMap.set("isHidden", configuration.isHidden);
|
|
60
|
-
configuration?.isPrivate !== undefined && configYMap.set("isPrivate", configuration.isPrivate);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function yjsToItemConfiguration(yDoc: Y.Doc): DTODocumentationPageRoomHeaderData {
|
|
65
|
-
const title = yDoc.getMap("itemTitle").get("title");
|
|
66
|
-
|
|
67
|
-
const headerYMap = yDoc.getMap("itemHeader");
|
|
68
|
-
const rawHeader = {
|
|
69
|
-
description: headerYMap.get("description"),
|
|
70
|
-
alignment: headerYMap.get("alignment"),
|
|
71
|
-
foregroundColor: headerYMap.get("foregroundColor"),
|
|
72
|
-
backgroundColor: headerYMap.get("backgroundColor"),
|
|
73
|
-
backgroundImageAsset: headerYMap.get("backgroundImageAsset"),
|
|
74
|
-
backgroundImageScaleType: headerYMap.get("backgroundImageScaleType"),
|
|
75
|
-
showBackgroundOverlay: headerYMap.get("showBackgroundOverlay"),
|
|
76
|
-
showCoverText: headerYMap.get("showCoverText"),
|
|
77
|
-
minHeight: headerYMap.get("minHeight"),
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const configYMap = yDoc.getMap("itemConfiguration");
|
|
81
|
-
|
|
82
|
-
const rawConfig = {
|
|
83
|
-
showSidebar: configYMap.get("showSidebar"),
|
|
84
|
-
isHidden: configYMap.get("isHidden") ?? false,
|
|
85
|
-
isPrivate: configYMap.get("isPrivate") ?? false,
|
|
86
|
-
header: rawHeader,
|
|
87
|
-
} satisfies Record<keyof DTODocumentationItemConfigurationV2, unknown>;
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
title: z.string().parse(title),
|
|
91
|
-
configuration: DTODocumentationItemConfigurationV2.parse(rawConfig),
|
|
92
|
-
};
|
|
93
|
-
}
|