@supernova-studio/client 0.58.19 → 1.0.0-alpha.3
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 +1363 -1321
- package/dist/index.d.ts +1363 -1321
- package/dist/index.js +536 -339
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +839 -642
- 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 -72
- 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 -25
- 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 -13
- package/src/api/dto/design-systems/members.ts +0 -50
- 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.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 -120
- package/src/api/dto/elements/documentation/structure.ts +0 -37
- package/src/api/dto/elements/elements-action-v2.ts +0 -104
- package/src/api/dto/elements/figma-nodes/figma-node.ts +0 -106
- package/src/api/dto/elements/figma-nodes/index.ts +0 -2
- package/src/api/dto/elements/figma-nodes/node-actions-v2.ts +0 -24
- 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 -21
- 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 -95
- 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 -87
- 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 -43
- 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 -13
- package/src/api/endpoints/codegen/exporters.ts +0 -13
- package/src/api/endpoints/codegen/index.ts +0 -3
- package/src/api/endpoints/codegen/pipelines.ts +0 -37
- 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 -55
- package/src/api/endpoints/design-system/versions/elements.ts +0 -13
- 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 -79
- 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 -50
- 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/index.ts +0 -3
- package/src/utils/figma.ts +0 -53
- 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 -2104
- 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 -78
- package/src/yjs/version-room/base.ts +0 -211
- package/src/yjs/version-room/frontend.ts +0 -461
- package/src/yjs/version-room/index.ts +0 -4
- package/src/yjs/version-room/utils.ts +0 -109
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DTOWorkspaceCreateInput, DTOWorkspaceResponse } from "../../dto";
|
|
3
|
-
import { RequestExecutor } from "../../transport/request-executor";
|
|
4
|
-
import { WorkspaceInvitationsEndpoint } from "./workspace-invites";
|
|
5
|
-
import { WorkspaceMembersEndpoint } from "./workspace-members";
|
|
6
|
-
import { DTOTransferOwnershipPayload } from "../../payloads";
|
|
7
|
-
|
|
8
|
-
// TODO Response types
|
|
9
|
-
export class WorkspacesEndpoint {
|
|
10
|
-
public members: WorkspaceMembersEndpoint;
|
|
11
|
-
public invitations: WorkspaceInvitationsEndpoint;
|
|
12
|
-
|
|
13
|
-
constructor(private readonly requestExecutor: RequestExecutor) {
|
|
14
|
-
this.members = new WorkspaceMembersEndpoint(requestExecutor);
|
|
15
|
-
this.invitations = new WorkspaceInvitationsEndpoint(requestExecutor);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
create(body: DTOWorkspaceCreateInput) {
|
|
19
|
-
return this.requestExecutor.json("/workspaces", DTOWorkspaceResponse, {
|
|
20
|
-
method: "POST",
|
|
21
|
-
body: {
|
|
22
|
-
...body,
|
|
23
|
-
product: "free",
|
|
24
|
-
priceId: "yearly",
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get(workspaceId: string) {
|
|
30
|
-
return this.requestExecutor.json(`/workspaces/${workspaceId}`, DTOWorkspaceResponse, { method: "GET" });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
delete(workspaceId: string) {
|
|
34
|
-
return this.requestExecutor.json(`/workspaces/${workspaceId}`, z.any(), { method: "DELETE" });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
subscription(workspaceId: string) {
|
|
38
|
-
return this.requestExecutor.json(`/workspaces/${workspaceId}/subscription`, z.any(), { method: "GET" });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
transferOwnership(workspaceId: string, body: DTOTransferOwnershipPayload) {
|
|
42
|
-
return this.requestExecutor.json(`/workspaces/${workspaceId}/ownership`, DTOWorkspaceResponse, {
|
|
43
|
-
method: "PUT",
|
|
44
|
-
body,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/api/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { DesignSystem, DesignSystemAccessMode, ObjectMeta } from "@supernova-studio/model";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const DTODesignSystemUpdateInput = DesignSystem.partial()
|
|
5
|
-
.omit({
|
|
6
|
-
id: true,
|
|
7
|
-
workspaceId: true,
|
|
8
|
-
createdAt: true,
|
|
9
|
-
updatedAt: true,
|
|
10
|
-
docSlug: true,
|
|
11
|
-
docViewUrl: true,
|
|
12
|
-
accessMode: true,
|
|
13
|
-
})
|
|
14
|
-
.extend({
|
|
15
|
-
meta: ObjectMeta.partial().optional(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export const DTODesignSystemUpdateAccessModeInput = z.object({
|
|
19
|
-
accessMode: DesignSystemAccessMode,
|
|
20
|
-
retain: z
|
|
21
|
-
.object({
|
|
22
|
-
userIds: z.string().array(),
|
|
23
|
-
inviteIds: z.string().array(),
|
|
24
|
-
})
|
|
25
|
-
.optional(),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export type DTODesignSystemUpdateInput = z.infer<typeof DTODesignSystemUpdateInput>;
|
|
29
|
-
export type DTODesignSystemUpdateAccessModeInput = z.infer<typeof DTODesignSystemUpdateAccessModeInput>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const ObjectMeta = z.object({
|
|
4
|
-
name: z.string().max(150).optional(),
|
|
5
|
-
description: z.string().max(2000).optional(),
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export function validateDesignSystemVersion(version: string) {
|
|
9
|
-
const urlCompliantRegex = /^[a-zA-Z0-9+.-]+$/;
|
|
10
|
-
return urlCompliantRegex.test(version);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DTOCreateVersionInput = z.object({
|
|
14
|
-
meta: ObjectMeta,
|
|
15
|
-
version: z.string().refine(validateDesignSystemVersion, {
|
|
16
|
-
message: "Invalid semantic versioning format",
|
|
17
|
-
}),
|
|
18
|
-
changeLog: z.string().optional(),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export type DTOCreateVersionInput = z.infer<typeof DTOCreateVersionInput>;
|
|
22
|
-
|
|
23
|
-
export const DTOUpdateVersionInput = z.object({
|
|
24
|
-
meta: ObjectMeta,
|
|
25
|
-
version: z.string(), // required for PUT, but not editable
|
|
26
|
-
changeLog: z.string(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export type DTOUpdateVersionInput = z.infer<typeof DTOUpdateVersionInput>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DTOPageBlockDefinition } from "../../dto/documentation/block-definition";
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
// Read
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export const DTOGetBlockDefinitionsOutput = z.object({
|
|
9
|
-
definitions: z.array(DTOPageBlockDefinition),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export type DTOGetBlockDefinitionsOutput = z.infer<typeof DTOGetBlockDefinitionsOutput>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./pipeline";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExporterDestinationAzure,
|
|
3
|
-
ExporterDestinationBitbucket,
|
|
4
|
-
ExporterDestinationDocs,
|
|
5
|
-
ExporterDestinationGithub,
|
|
6
|
-
ExporterDestinationGitlab,
|
|
7
|
-
ExporterDestinationS3,
|
|
8
|
-
GitObjectsQuery,
|
|
9
|
-
PipelineDestinationType,
|
|
10
|
-
PipelineEventType,
|
|
11
|
-
} from "@supernova-studio/model";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
import { DTOExporterPropertyDefinitionValueMap } from "../../dto/export/exporter-property";
|
|
14
|
-
|
|
15
|
-
export const DTOPipelineCreateBody = z.object({
|
|
16
|
-
name: z.string(),
|
|
17
|
-
exporterId: z.string(),
|
|
18
|
-
designSystemId: z.string(),
|
|
19
|
-
isEnabled: z.boolean(),
|
|
20
|
-
eventType: PipelineEventType,
|
|
21
|
-
brandPersistentId: z.string().optional(),
|
|
22
|
-
themePersistentId: z.string().optional(),
|
|
23
|
-
themePersistentIds: z.string().array().optional(),
|
|
24
|
-
|
|
25
|
-
exporterConfiguration: DTOExporterPropertyDefinitionValueMap.optional(),
|
|
26
|
-
|
|
27
|
-
destination: PipelineDestinationType.optional(),
|
|
28
|
-
gitQuery: GitObjectsQuery,
|
|
29
|
-
destinations: z.object({
|
|
30
|
-
s3: ExporterDestinationS3.nullish(),
|
|
31
|
-
azure: ExporterDestinationAzure.nullish(),
|
|
32
|
-
bitbucket: ExporterDestinationBitbucket.nullish(),
|
|
33
|
-
github: ExporterDestinationGithub.nullish(),
|
|
34
|
-
gitlab: ExporterDestinationGitlab.nullish(),
|
|
35
|
-
documentation: ExporterDestinationDocs.nullish(),
|
|
36
|
-
webhookUrl: z.string().nullish(),
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const DTOPipelineUpdateBody = DTOPipelineCreateBody.extend({
|
|
41
|
-
id: z.string(),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export const DTOPipelineTriggerBody = z.object({
|
|
45
|
-
designSystemVersionId: z.string(),
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export type DTOPipelineCreateBody = z.infer<typeof DTOPipelineCreateBody>;
|
|
49
|
-
export type DTOPipelineUpdateBody = z.infer<typeof DTOPipelineUpdateBody>;
|
|
50
|
-
export type DTOPipelineTriggerBody = z.infer<typeof DTOPipelineTriggerBody>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./auth";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./notification-settings";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { UserNotificationSettings } from "@supernova-studio/model";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
export const DTOUpdateUserNotificationSettingsPayload = z.object({
|
|
5
|
-
notificationSettings: UserNotificationSettings,
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export type DTOUpdateUserNotificationSettingsPayload = z.infer<typeof DTOUpdateUserNotificationSettingsPayload>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const DTOUserNotificationSettingsResponse = z.object({
|
|
12
|
-
userId: z.string(),
|
|
13
|
-
workspaceId: z.string(),
|
|
14
|
-
notificationSettings: UserNotificationSettings,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export type DTOUserNotificationSettingsResponse = z.infer<typeof DTOUserNotificationSettingsResponse>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./update";
|
|
@@ -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
|
-
}
|
package/src/index.ts
DELETED
package/src/utils/figma.ts
DELETED
|
@@ -1,53 +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
|
-
type ParsedFigmaFileURL = {
|
|
6
|
-
fileId: string;
|
|
7
|
-
fileName: string | null;
|
|
8
|
-
nodeId: string | null;
|
|
9
|
-
nodeType: string | null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const FigmaUtils = {
|
|
13
|
-
tryParseFigmaFileURL(urlString: string): ParsedFigmaFileURL | null {
|
|
14
|
-
if (!URL.canParse(urlString)) return null;
|
|
15
|
-
|
|
16
|
-
// Validate that this is a Figma URL
|
|
17
|
-
const url = new URL(urlString);
|
|
18
|
-
if (!url.hostname.endsWith("figma.com")) return null;
|
|
19
|
-
|
|
20
|
-
// Validate that the URL type is the correct one (pointing to a design file)
|
|
21
|
-
const pathSegments = url.pathname.split("/");
|
|
22
|
-
if (pathSegments[0] !== "design" && pathSegments[0] !== "file") return null;
|
|
23
|
-
|
|
24
|
-
// Validate Figma file ID
|
|
25
|
-
const fileId = pathSegments[1];
|
|
26
|
-
if (!fileId || !fileId.match(figmaFileIdRegex)) return null;
|
|
27
|
-
|
|
28
|
-
// Parse Figma file name
|
|
29
|
-
let fileName: string | null = null;
|
|
30
|
-
const rawFileName = pathSegments[2];
|
|
31
|
-
if (rawFileName) {
|
|
32
|
-
fileName = rawFileName.replaceAll("-", " ");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Parse node id
|
|
36
|
-
let nodeId: string | null = null;
|
|
37
|
-
const nodeIdRaw = url.searchParams.get("node-id");
|
|
38
|
-
if (nodeIdRaw && nodeIdRaw.match(nodeIdRegex)) {
|
|
39
|
-
nodeId = nodeIdRaw.replace("-", ":");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Parse node type
|
|
43
|
-
let nodeType: string | null = null;
|
|
44
|
-
const nodeTypeRaw = url.searchParams.get("node-type");
|
|
45
|
-
if (nodeTypeRaw && nodeTypeRaw.match(nodeTypeRegex)) {
|
|
46
|
-
nodeType = nodeTypeRaw;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return { fileId, fileName, nodeId, nodeType };
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// 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
|
-
}
|