@supernova-studio/model 1.0.0 → 1.0.2
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 +26740 -18977
- package/dist/index.d.ts +26740 -18977
- package/dist/index.js +275 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2201 -1973
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
- package/src/asset-delete-schedule/asset-delete-schedule.ts +0 -20
- package/src/asset-delete-schedule/index.ts +0 -1
- package/src/auth/index.ts +0 -1
- package/src/auth/plugin-oauth-request.ts +0 -14
- package/src/billing/card.ts +0 -12
- package/src/billing/checkoutSession.ts +0 -16
- package/src/billing/customer.ts +0 -29
- package/src/billing/features.ts +0 -48
- package/src/billing/index.ts +0 -9
- package/src/billing/invoice.ts +0 -34
- package/src/billing/portalSession.ts +0 -19
- package/src/billing/price.ts +0 -24
- package/src/billing/product.ts +0 -5
- package/src/billing/subscription.ts +0 -65
- package/src/common/entity.ts +0 -9
- package/src/common/index.ts +0 -2
- package/src/common/object-meta.ts +0 -8
- package/src/custom-domains/custom-domains.ts +0 -24
- package/src/custom-domains/index.ts +0 -1
- package/src/data-dumps/code-integration-dump.ts +0 -19
- package/src/data-dumps/design-system-dump.ts +0 -16
- package/src/data-dumps/design-system-version-dump.ts +0 -45
- package/src/data-dumps/index.ts +0 -6
- package/src/data-dumps/published-docs-dump.ts +0 -10
- package/src/data-dumps/user-data-dump.ts +0 -10
- package/src/data-dumps/workspace-dump.ts +0 -14
- package/src/docs-server/index.ts +0 -1
- package/src/docs-server/session.ts +0 -39
- package/src/dsm/assets/asset-dynamo-record.ts +0 -10
- package/src/dsm/assets/asset-reference.ts +0 -18
- package/src/dsm/assets/asset-value.ts +0 -3
- package/src/dsm/assets/asset.ts +0 -60
- package/src/dsm/assets/index.ts +0 -4
- package/src/dsm/brand.ts +0 -13
- package/src/dsm/collection.ts +0 -51
- package/src/dsm/components/asset-rendering.ts +0 -22
- package/src/dsm/components/index.ts +0 -1
- package/src/dsm/data-sources/data-source.ts +0 -167
- package/src/dsm/data-sources/import-job.ts +0 -30
- package/src/dsm/data-sources/import-summary.ts +0 -70
- package/src/dsm/data-sources/index.ts +0 -3
- package/src/dsm/design-system.ts +0 -47
- package/src/dsm/documentation/approvals/approval-state.ts +0 -4
- package/src/dsm/documentation/approvals/approval.ts +0 -18
- package/src/dsm/documentation/approvals/index.ts +0 -2
- package/src/dsm/documentation/block-definitions/aux.ts +0 -10
- package/src/dsm/documentation/block-definitions/definition.ts +0 -76
- package/src/dsm/documentation/block-definitions/index.ts +0 -4
- package/src/dsm/documentation/block-definitions/item.ts +0 -233
- package/src/dsm/documentation/block-definitions/variant.ts +0 -49
- package/src/dsm/documentation/group.ts +0 -19
- package/src/dsm/documentation/index.ts +0 -10
- package/src/dsm/documentation/link-preview.ts +0 -10
- package/src/dsm/documentation/page-anchor.ts +0 -9
- package/src/dsm/documentation/page-content-backup.ts +0 -13
- package/src/dsm/documentation/page-content.ts +0 -32
- package/src/dsm/documentation/page.ts +0 -18
- package/src/dsm/documentation/settings.ts +0 -18
- package/src/dsm/documentation/thread.ts +0 -35
- package/src/dsm/element-snapshots/base.ts +0 -34
- package/src/dsm/element-snapshots/documentation-page-snapshot.ts +0 -29
- package/src/dsm/element-snapshots/group-snapshot.ts +0 -27
- package/src/dsm/element-snapshots/index.ts +0 -3
- package/src/dsm/elements/base.ts +0 -49
- package/src/dsm/elements/component-properties.ts +0 -63
- package/src/dsm/elements/data/base.ts +0 -18
- package/src/dsm/elements/data/blur.ts +0 -16
- package/src/dsm/elements/data/border-radius.ts +0 -16
- package/src/dsm/elements/data/border-width.ts +0 -16
- package/src/dsm/elements/data/border.ts +0 -21
- package/src/dsm/elements/data/color.ts +0 -13
- package/src/dsm/elements/data/component.ts +0 -30
- package/src/dsm/elements/data/dimension.ts +0 -15
- package/src/dsm/elements/data/documentation-block-v1.ts +0 -498
- package/src/dsm/elements/data/documentation-block-v2.ts +0 -429
- package/src/dsm/elements/data/documentation-page-v1.ts +0 -9
- package/src/dsm/elements/data/documentation-page-v2.ts +0 -7
- package/src/dsm/elements/data/documentation-section-v2.ts +0 -47
- package/src/dsm/elements/data/documentation-v1.ts +0 -16
- package/src/dsm/elements/data/documentation-v2.ts +0 -18
- package/src/dsm/elements/data/duration.ts +0 -16
- package/src/dsm/elements/data/figma-file-structure.ts +0 -65
- package/src/dsm/elements/data/figma-node-reference.ts +0 -27
- package/src/dsm/elements/data/font-family.ts +0 -8
- package/src/dsm/elements/data/font-size.ts +0 -16
- package/src/dsm/elements/data/font-weight.ts +0 -8
- package/src/dsm/elements/data/font.ts +0 -9
- package/src/dsm/elements/data/gradient.ts +0 -32
- package/src/dsm/elements/data/group.ts +0 -20
- package/src/dsm/elements/data/index.ts +0 -43
- package/src/dsm/elements/data/item-header-v1.ts +0 -35
- package/src/dsm/elements/data/item-header-v2.ts +0 -34
- package/src/dsm/elements/data/item-header.ts +0 -14
- package/src/dsm/elements/data/letter-spacing.ts +0 -16
- package/src/dsm/elements/data/line-height.ts +0 -16
- package/src/dsm/elements/data/opacity.ts +0 -13
- package/src/dsm/elements/data/paragraph-indent.ts +0 -16
- package/src/dsm/elements/data/paragraph-spacing.ts +0 -16
- package/src/dsm/elements/data/product-copy.ts +0 -8
- package/src/dsm/elements/data/safe-id.ts +0 -13
- package/src/dsm/elements/data/shadow.ts +0 -23
- package/src/dsm/elements/data/size.ts +0 -16
- package/src/dsm/elements/data/space.ts +0 -16
- package/src/dsm/elements/data/string.ts +0 -8
- package/src/dsm/elements/data/text-case.ts +0 -10
- package/src/dsm/elements/data/text-decoration.ts +0 -10
- package/src/dsm/elements/data/typography.ts +0 -28
- package/src/dsm/elements/data/visibility.ts +0 -10
- package/src/dsm/elements/data/z-index.ts +0 -16
- package/src/dsm/elements/documentation-page-v1.ts +0 -34
- package/src/dsm/elements/documentation-page-v2.ts +0 -21
- package/src/dsm/elements/figma-component.ts +0 -67
- package/src/dsm/elements/figma-file-structures.ts +0 -40
- package/src/dsm/elements/figma-node-reference.ts +0 -25
- package/src/dsm/elements/group.ts +0 -40
- package/src/dsm/elements/index.ts +0 -15
- package/src/dsm/elements/page-block-v2.ts +0 -25
- package/src/dsm/elements/primitives/index.ts +0 -2
- package/src/dsm/elements/primitives/point.ts +0 -8
- package/src/dsm/elements/primitives/size.ts +0 -28
- package/src/dsm/elements/raw-element.ts +0 -164
- package/src/dsm/elements/theme.ts +0 -76
- package/src/dsm/elements/tokens.ts +0 -311
- package/src/dsm/elements/utils.ts +0 -114
- package/src/dsm/exporter-property-values-collection.ts +0 -31
- package/src/dsm/import/asset.ts +0 -6
- package/src/dsm/import/base.ts +0 -24
- package/src/dsm/import/collection.ts +0 -16
- package/src/dsm/import/component.ts +0 -40
- package/src/dsm/import/data-source.ts +0 -9
- package/src/dsm/import/figma-frames.ts +0 -74
- package/src/dsm/import/image.ts +0 -87
- package/src/dsm/import/index.ts +0 -12
- package/src/dsm/import/origin.ts +0 -5
- package/src/dsm/import/support/figma-files.ts +0 -19
- package/src/dsm/import/support/import-context.ts +0 -94
- package/src/dsm/import/support/import-model-collections.ts +0 -50
- package/src/dsm/import/support/index.ts +0 -3
- package/src/dsm/import/theme.ts +0 -76
- package/src/dsm/import/tokens.ts +0 -50
- package/src/dsm/import/warning.ts +0 -38
- package/src/dsm/index.ts +0 -19
- package/src/dsm/membership/additions.ts +0 -13
- package/src/dsm/membership/design-system-membership.ts +0 -92
- package/src/dsm/membership/ds-role.ts +0 -28
- package/src/dsm/membership/index.ts +0 -4
- package/src/dsm/membership/invitations.ts +0 -21
- package/src/dsm/properties/index.ts +0 -3
- package/src/dsm/properties/property-definition.ts +0 -57
- package/src/dsm/properties/property-reference.ts +0 -5
- package/src/dsm/properties/property-value.ts +0 -29
- package/src/dsm/published-doc-page-visits.ts +0 -15
- package/src/dsm/published-doc-page.ts +0 -37
- package/src/dsm/published-doc.ts +0 -32
- package/src/dsm/reference.ts +0 -9
- package/src/dsm/version.ts +0 -41
- package/src/dsm/views/column.ts +0 -58
- package/src/dsm/views/index.ts +0 -2
- package/src/dsm/views/view.ts +0 -19
- package/src/emails/design-system-invite.ts +0 -31
- package/src/emails/index.ts +0 -2
- package/src/emails/workspace-invite.ts +0 -29
- package/src/events/base.ts +0 -7
- package/src/events/data-source-imported.ts +0 -9
- package/src/events/index.ts +0 -3
- package/src/events/version-released.ts +0 -10
- package/src/export/export-destinations.ts +0 -127
- package/src/export/export-jobs.ts +0 -122
- package/src/export/export-runner/export-context.ts +0 -34
- package/src/export/export-runner/exporter-payload.ts +0 -10
- package/src/export/export-runner/index.ts +0 -2
- package/src/export/exporter-workspace-membership-role.ts +0 -4
- package/src/export/exporter-workspace-membership.ts +0 -14
- package/src/export/exporter.ts +0 -55
- package/src/export/git-providers.ts +0 -11
- package/src/export/index.ts +0 -9
- package/src/export/pipeline.ts +0 -34
- package/src/export/pulsar.ts +0 -71
- package/src/feature-flags/feature-flags.ts +0 -21
- package/src/feature-flags/index.ts +0 -1
- package/src/helpers/db.ts +0 -82
- package/src/helpers/index.ts +0 -2
- package/src/helpers/nullish-to-optional.ts +0 -9
- package/src/index.ts +0 -20
- package/src/integrations/external-oauth-request.ts +0 -12
- package/src/integrations/git.ts +0 -49
- package/src/integrations/index.ts +0 -6
- package/src/integrations/integration.ts +0 -143
- package/src/integrations/oauth-providers.ts +0 -13
- package/src/integrations/oauth-token.ts +0 -16
- package/src/integrations/workspace-oauth-requests.ts +0 -12
- package/src/liveblocks/index.ts +0 -1
- package/src/liveblocks/rooms/design-system-version-room.ts +0 -62
- package/src/liveblocks/rooms/documentation-page-room.ts +0 -65
- package/src/liveblocks/rooms/index.ts +0 -4
- package/src/liveblocks/rooms/room-type.ts +0 -12
- package/src/liveblocks/rooms/workspace-room.ts +0 -16
- package/src/npm/index.ts +0 -2
- package/src/npm/npm-package.ts +0 -30
- package/src/npm/npm-proxy-token-payload.ts +0 -7
- package/src/tokens/index.ts +0 -1
- package/src/tokens/personal-access-token.ts +0 -25
- package/src/users/index.ts +0 -9
- package/src/users/linked-integrations.ts +0 -36
- package/src/users/user-analytics-cleanup-schedule.ts +0 -15
- package/src/users/user-identity.ts +0 -8
- package/src/users/user-minified.ts +0 -10
- package/src/users/user-notification-settings.ts +0 -18
- package/src/users/user-profile.ts +0 -41
- package/src/users/user-test.ts +0 -8
- package/src/users/user-with-pat.ts +0 -7
- package/src/users/user.ts +0 -21
- package/src/utils/common.ts +0 -172
- package/src/utils/content-loader-instruction.ts +0 -31
- package/src/utils/errors.ts +0 -120
- package/src/utils/index.ts +0 -6
- package/src/utils/naming.ts +0 -73
- package/src/utils/slugify.ts +0 -636
- package/src/utils/validation.ts +0 -4
- package/src/workspace/index.ts +0 -10
- package/src/workspace/npm-registry-settings.ts +0 -45
- package/src/workspace/sso-provider.ts +0 -13
- package/src/workspace/user-invite.ts +0 -18
- package/src/workspace/workspace-configuration.ts +0 -14
- package/src/workspace/workspace-context.ts +0 -13
- package/src/workspace/workspace-create.ts +0 -25
- package/src/workspace/workspace-invitations.ts +0 -22
- package/src/workspace/workspace-membership.ts +0 -31
- package/src/workspace/workspace-role.ts +0 -6
- package/src/workspace/workspace.ts +0 -62
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
3
|
-
import { OmitStrict } from "../../utils";
|
|
4
|
-
import { DesignElementBase, DesignElementBrandedPart, DesignElementGroupablePart, DesignElementSlugPart } from "./base";
|
|
5
|
-
import { ElementGroupDataV2 } from "./data";
|
|
6
|
-
import { DesignElementType } from "./raw-element";
|
|
7
|
-
|
|
8
|
-
export const ElementGroup = DesignElementBase.extend(DesignElementGroupablePart.shape)
|
|
9
|
-
.extend(DesignElementSlugPart.shape)
|
|
10
|
-
.extend(DesignElementBrandedPart.partial().shape)
|
|
11
|
-
.extend({
|
|
12
|
-
shortPersistentId: z.string().optional(),
|
|
13
|
-
childType: DesignElementType,
|
|
14
|
-
data: ElementGroupDataV2.optional(),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const BrandedElementGroup = ElementGroup.extend(DesignElementBrandedPart.shape);
|
|
18
|
-
|
|
19
|
-
export type ElementGroup = z.infer<typeof ElementGroup>;
|
|
20
|
-
export type BrandedElementGroup = z.infer<typeof BrandedElementGroup>;
|
|
21
|
-
|
|
22
|
-
export type CreateElementGroup = OmitStrict<DbCreateInputOmit<ElementGroup>, "parentPersistentId"> & {
|
|
23
|
-
parentPersistentId: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type UpdateElementGroup = DbUpdate<
|
|
27
|
-
OmitStrict<ElementGroup, "brandPersistentId" | "childType" | "designSystemVersionId" | "parentPersistentId"> & {
|
|
28
|
-
parentPersistentId: string;
|
|
29
|
-
}
|
|
30
|
-
>;
|
|
31
|
-
|
|
32
|
-
export type RestoreElementGroup = OmitStrict<ElementGroup, "parentPersistentId"> & {
|
|
33
|
-
parentPersistentId: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type ElementGroupsDiff = {
|
|
37
|
-
toCreate: CreateElementGroup[];
|
|
38
|
-
toUpdate: UpdateElementGroup[];
|
|
39
|
-
toDelete: ElementGroup["id"][];
|
|
40
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from "./data";
|
|
2
|
-
export * from "./primitives";
|
|
3
|
-
export * from "./base";
|
|
4
|
-
export * from "./component-properties";
|
|
5
|
-
export * from "./documentation-page-v1";
|
|
6
|
-
export * from "./documentation-page-v2";
|
|
7
|
-
export * from "./figma-component";
|
|
8
|
-
export * from "./figma-file-structures";
|
|
9
|
-
export * from "./figma-node-reference";
|
|
10
|
-
export * from "./group";
|
|
11
|
-
export * from "./page-block-v2";
|
|
12
|
-
export * from "./raw-element";
|
|
13
|
-
export * from "./theme";
|
|
14
|
-
export * from "./tokens";
|
|
15
|
-
export * from "./utils";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DesignElementBase, DesignElementGroupableRequiredPart } from "./base";
|
|
3
|
-
import { PageBlockDataV2 } from "./data";
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Element
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
export const PageBlockV2 = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape).extend({
|
|
10
|
-
data: PageBlockDataV2,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export type PageBlockV2 = z.infer<typeof PageBlockV2>;
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
// Editor Model
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
export const PageBlockEditorModelV2 = z.object({
|
|
20
|
-
id: z.string(),
|
|
21
|
-
type: z.literal("Block"),
|
|
22
|
-
data: PageBlockDataV2,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export type PageBlockEditorModelV2 = z.infer<typeof PageBlockEditorModelV2>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
const nullSize = { height: -1, width: -1 };
|
|
4
|
-
|
|
5
|
-
function isNullSize(size: Size): boolean {
|
|
6
|
-
return size.height === nullSize.height && size.width === nullSize.width;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const Size = z.object({
|
|
10
|
-
width: z
|
|
11
|
-
.number()
|
|
12
|
-
.nullish()
|
|
13
|
-
.transform(v => v ?? nullSize.width),
|
|
14
|
-
|
|
15
|
-
height: z
|
|
16
|
-
.number()
|
|
17
|
-
.nullish()
|
|
18
|
-
.transform(v => v ?? nullSize.height),
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const SizeOrUndefined = Size.optional().transform(v => {
|
|
22
|
-
if (!v) return undefined;
|
|
23
|
-
if (isNullSize(v)) return undefined;
|
|
24
|
-
|
|
25
|
-
return v;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
export type Size = z.infer<typeof Size>;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { ObjectMeta } from "../../common";
|
|
3
|
-
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
4
|
-
import { OmitStrict } from "../../utils";
|
|
5
|
-
|
|
6
|
-
export type CreateDesignElement = DbCreateInputOmit<DesignElement>;
|
|
7
|
-
export type UpdateDesignElement = OmitStrict<
|
|
8
|
-
DbUpdate<DesignElement>,
|
|
9
|
-
"brandPersistentId" | "childType" | "designSystemVersionId" | "shortPersistentId"
|
|
10
|
-
>;
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
// Token types
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
export const DesignTokenType = z.enum([
|
|
17
|
-
"Color",
|
|
18
|
-
"Border",
|
|
19
|
-
"Gradient",
|
|
20
|
-
"Shadow",
|
|
21
|
-
"Dimension",
|
|
22
|
-
"Duration",
|
|
23
|
-
"Size",
|
|
24
|
-
"Space",
|
|
25
|
-
"Opacity",
|
|
26
|
-
"FontSize",
|
|
27
|
-
"LineHeight",
|
|
28
|
-
"LetterSpacing",
|
|
29
|
-
"ParagraphSpacing",
|
|
30
|
-
"BorderWidth",
|
|
31
|
-
"BorderRadius",
|
|
32
|
-
"ZIndex",
|
|
33
|
-
"Image",
|
|
34
|
-
"String",
|
|
35
|
-
"ProductCopy",
|
|
36
|
-
"FontFamily",
|
|
37
|
-
"FontWeight",
|
|
38
|
-
"TextDecoration",
|
|
39
|
-
"TextCase",
|
|
40
|
-
"Visibility",
|
|
41
|
-
"Typography",
|
|
42
|
-
"Blur",
|
|
43
|
-
"Font",
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
export const tokenElementTypes: DesignTokenType[] = [...DesignTokenType.options.filter(v => v !== "Font")];
|
|
47
|
-
|
|
48
|
-
export type DesignTokenType = z.infer<typeof DesignTokenType>;
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
// Non-token types
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
export const DesignElementType = DesignTokenType.or(
|
|
55
|
-
z.enum([
|
|
56
|
-
"Component",
|
|
57
|
-
"Theme",
|
|
58
|
-
"Documentation",
|
|
59
|
-
"DocumentationPage",
|
|
60
|
-
"DesignSystemComponent",
|
|
61
|
-
"ElementGroup",
|
|
62
|
-
"FigmaNodeStructure",
|
|
63
|
-
"FigmaNodeReference",
|
|
64
|
-
"PageBlock",
|
|
65
|
-
])
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
export type DesignElementType = z.infer<typeof DesignElementType>;
|
|
69
|
-
|
|
70
|
-
export function isTokenType(type: DesignElementType): type is DesignTokenType {
|
|
71
|
-
return DesignTokenType.safeParse(type).success;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const numberTokenTypes: Set<DesignTokenType> = new Set([
|
|
75
|
-
"Dimension",
|
|
76
|
-
"Duration",
|
|
77
|
-
"Size",
|
|
78
|
-
"Space",
|
|
79
|
-
"Opacity",
|
|
80
|
-
"FontSize",
|
|
81
|
-
"LineHeight",
|
|
82
|
-
"LetterSpacing",
|
|
83
|
-
"ParagraphSpacing",
|
|
84
|
-
"BorderWidth",
|
|
85
|
-
"BorderRadius",
|
|
86
|
-
"ZIndex",
|
|
87
|
-
] satisfies DesignTokenType[]);
|
|
88
|
-
|
|
89
|
-
const stringTokenTypes: Set<DesignTokenType> = new Set([
|
|
90
|
-
"String",
|
|
91
|
-
"ProductCopy",
|
|
92
|
-
"FontFamily",
|
|
93
|
-
"FontWeight",
|
|
94
|
-
] satisfies DesignTokenType[]);
|
|
95
|
-
|
|
96
|
-
export function areTokenTypesCompatible(lhs: DesignTokenType, rhs: DesignTokenType): boolean {
|
|
97
|
-
if (lhs === rhs) return true;
|
|
98
|
-
if (numberTokenTypes.has(lhs) && numberTokenTypes.has(rhs)) return true;
|
|
99
|
-
if (stringTokenTypes.has(lhs) && stringTokenTypes.has(rhs)) return true;
|
|
100
|
-
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
// Element category
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
export const DesignElementCategory = z.enum([
|
|
109
|
-
"Token",
|
|
110
|
-
"Component",
|
|
111
|
-
"DesignSystemComponent",
|
|
112
|
-
"DocumentationPage",
|
|
113
|
-
"Theme",
|
|
114
|
-
"PageBlock",
|
|
115
|
-
]);
|
|
116
|
-
|
|
117
|
-
export type DesignElementCategory = z.infer<typeof DesignElementCategory>;
|
|
118
|
-
|
|
119
|
-
// Elements
|
|
120
|
-
|
|
121
|
-
export const DesignSystemElementExportProps = z.object({
|
|
122
|
-
isAsset: z
|
|
123
|
-
.boolean()
|
|
124
|
-
.nullish()
|
|
125
|
-
.transform(v => v ?? false),
|
|
126
|
-
|
|
127
|
-
codeName: z.string().nullish(),
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
export type DesignSystemElementExportProps = z.infer<typeof DesignSystemElementExportProps>;
|
|
131
|
-
|
|
132
|
-
export const ShallowDesignElement = z.object({
|
|
133
|
-
id: z.string(),
|
|
134
|
-
persistentId: z.string(),
|
|
135
|
-
designSystemVersionId: z.string(),
|
|
136
|
-
type: DesignElementType,
|
|
137
|
-
brandPersistentId: z.string().optional(),
|
|
138
|
-
collectionPersistentId: z.string().optional(),
|
|
139
|
-
parentPersistentId: z.string().optional(),
|
|
140
|
-
shortPersistentId: z.string().optional(),
|
|
141
|
-
childType: DesignElementType.optional(),
|
|
142
|
-
sortOrder: z.number(),
|
|
143
|
-
origin: z.record(z.any()).optional(),
|
|
144
|
-
createdAt: z.coerce.date(),
|
|
145
|
-
updatedAt: z.coerce.date(),
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
export const DesignElement = ShallowDesignElement.extend({
|
|
149
|
-
meta: ObjectMeta,
|
|
150
|
-
slug: z.string().optional(),
|
|
151
|
-
userSlug: z.string().optional(),
|
|
152
|
-
exportProperties: DesignSystemElementExportProps.optional(),
|
|
153
|
-
data: z.record(z.any()),
|
|
154
|
-
origin: z.record(z.any()).optional(),
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
export type ShallowDesignElement = z.infer<typeof ShallowDesignElement>;
|
|
158
|
-
export type DesignElement = z.infer<typeof DesignElement>;
|
|
159
|
-
|
|
160
|
-
export const HierarchicalElements = DesignTokenType.or(
|
|
161
|
-
z.enum(["Component", "DesignSystemComponent", "DocumentationPage"])
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
export type HierarchicalElements = z.infer<typeof HierarchicalElements>;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
3
|
-
import { OmitStrict } from "../../utils";
|
|
4
|
-
import { DesignElementBase, DesignElementBrandedPart } from "./base";
|
|
5
|
-
import { DesignTokenType } from "./raw-element";
|
|
6
|
-
import { DesignTokenOrigin, DesignTokenOriginPart, DesignTokenTypedData } from "./tokens";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
// Overrides
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
export const ThemeOverrideOriginPart = DesignTokenOriginPart;
|
|
13
|
-
export const ThemeOverrideOrigin = DesignTokenOrigin;
|
|
14
|
-
|
|
15
|
-
export const ThemeOverride = DesignTokenTypedData.and(
|
|
16
|
-
z.object({
|
|
17
|
-
tokenPersistentId: z.string(),
|
|
18
|
-
origin: ThemeOverrideOrigin.optional()
|
|
19
|
-
.nullable()
|
|
20
|
-
.transform(v => v ?? undefined),
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export type ThemeOverride = z.infer<typeof ThemeOverride>;
|
|
25
|
-
export type ThemeOverrideOfType<T extends DesignTokenType> = Extract<ThemeOverride, { type: T }>;
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
// Theme data
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
export const ThemeElementData = z.object({
|
|
32
|
-
value: z.object({
|
|
33
|
-
overrides: z.array(ThemeOverride),
|
|
34
|
-
}),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export type ThemeElementData = z.infer<typeof ThemeElementData>;
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
// Theme
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
export const ThemeOriginPart = z.object({});
|
|
44
|
-
|
|
45
|
-
export const ThemeOriginObject = z.object({
|
|
46
|
-
id: z.string(),
|
|
47
|
-
name: z.string(),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export const ThemeOriginSource = z.object({
|
|
51
|
-
sourceId: z.string(),
|
|
52
|
-
sourceObjects: z.array(ThemeOriginObject),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export const ThemeOrigin = z.object({
|
|
56
|
-
sources: z.array(ThemeOriginSource),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export const Theme = DesignElementBase.extend(DesignElementBrandedPart.shape).extend({
|
|
60
|
-
origin: ThemeOrigin.optional(),
|
|
61
|
-
overrides: z.array(ThemeOverride),
|
|
62
|
-
codeName: z.string(),
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export type Theme = z.infer<typeof Theme>;
|
|
66
|
-
export type ThemeOrigin = z.infer<typeof ThemeOrigin>;
|
|
67
|
-
export type ThemeOriginSource = z.infer<typeof ThemeOriginSource>;
|
|
68
|
-
export type ThemeOriginObject = z.infer<typeof ThemeOriginObject>;
|
|
69
|
-
|
|
70
|
-
export type CreateTheme = DbCreateInputOmit<Theme>;
|
|
71
|
-
export type UpdateTheme = OmitStrict<DbUpdate<Theme>, "brandPersistentId" | "designSystemVersionId">;
|
|
72
|
-
|
|
73
|
-
export type ThemeDiff = {
|
|
74
|
-
toCreate: CreateTheme[];
|
|
75
|
-
toUpdate: UpdateTheme[];
|
|
76
|
-
};
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { DbUpdate, zodCreateInputOmit, zodUpdateInputOmit } from "../../helpers";
|
|
3
|
-
import { OmitStrict, SupernovaException } from "../../utils";
|
|
4
|
-
import {
|
|
5
|
-
DesignElementBase,
|
|
6
|
-
DesignElementBrandedPart,
|
|
7
|
-
DesignElementGroupableRequiredPart,
|
|
8
|
-
DesignElementOrigin,
|
|
9
|
-
} from "./base";
|
|
10
|
-
import {
|
|
11
|
-
BlurTokenData,
|
|
12
|
-
BorderRadiusTokenData,
|
|
13
|
-
BorderTokenData,
|
|
14
|
-
BorderWidthTokenData,
|
|
15
|
-
ColorTokenData,
|
|
16
|
-
DimensionTokenData,
|
|
17
|
-
DurationTokenData,
|
|
18
|
-
FontFamilyTokenData,
|
|
19
|
-
FontSizeTokenData,
|
|
20
|
-
FontTokenData,
|
|
21
|
-
FontWeightTokenData,
|
|
22
|
-
GradientTokenData,
|
|
23
|
-
LetterSpacingTokenData,
|
|
24
|
-
LineHeightTokenData,
|
|
25
|
-
OpacityTokenData,
|
|
26
|
-
ParagraphSpacingTokenData,
|
|
27
|
-
ProductCopyTokenData,
|
|
28
|
-
ShadowTokenData,
|
|
29
|
-
SizeTokenData,
|
|
30
|
-
SpaceTokenData,
|
|
31
|
-
StringTokenData,
|
|
32
|
-
TextCaseTokenData,
|
|
33
|
-
TextDecorationTokenData,
|
|
34
|
-
TypographyTokenData,
|
|
35
|
-
VisibilityTokenData,
|
|
36
|
-
ZIndexTokenData,
|
|
37
|
-
} from "./data";
|
|
38
|
-
import { areTokenTypesCompatible, DesignTokenType } from "./raw-element";
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
// Base
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
export const DesignTokenOriginPart = z.object({
|
|
45
|
-
referenceOriginId: z.string().optional(),
|
|
46
|
-
referenceOriginKey: z.string().optional(),
|
|
47
|
-
referenceOriginName: z.string().optional(),
|
|
48
|
-
referenceOriginRemote: z.boolean().optional(),
|
|
49
|
-
referencePersistentId: z.string().optional(),
|
|
50
|
-
referenceResolutionFailed: z.boolean().optional(),
|
|
51
|
-
key: z.string().optional(),
|
|
52
|
-
sortOrder: z.number().optional(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export const DesignTokenOrigin = DesignElementOrigin.extend(DesignTokenOriginPart.shape);
|
|
56
|
-
|
|
57
|
-
const DesignTokenBase = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
|
|
58
|
-
.extend(DesignElementBrandedPart.shape)
|
|
59
|
-
.extend({
|
|
60
|
-
origin: DesignTokenOrigin.optional(),
|
|
61
|
-
collectionPersistentId: z.string().optional(),
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const CreateDesignTokenBase = DesignTokenBase.omit(zodCreateInputOmit());
|
|
65
|
-
const UpdateDesignTokenBase = DesignTokenBase.omit({
|
|
66
|
-
...zodUpdateInputOmit(),
|
|
67
|
-
brandPersistentId: true,
|
|
68
|
-
designSystemVersionId: true,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
// Per type
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
const BlurTokenTypedData = z.object({
|
|
76
|
-
type: z.literal("Blur"),
|
|
77
|
-
data: BlurTokenData,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const ColorTokenTypedData = z.object({
|
|
81
|
-
type: z.literal("Color"),
|
|
82
|
-
data: ColorTokenData,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
const GradientTokenTypedData = z.object({
|
|
86
|
-
type: z.literal("Gradient"),
|
|
87
|
-
data: GradientTokenData,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const OpacityTokenTypedData = z.object({
|
|
91
|
-
type: z.literal("Opacity"),
|
|
92
|
-
data: OpacityTokenData,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const ShadowTokenTypedData = z.object({
|
|
96
|
-
type: z.literal("Shadow"),
|
|
97
|
-
data: ShadowTokenData,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const TypographyTokenTypedData = z.object({
|
|
101
|
-
type: z.literal("Typography"),
|
|
102
|
-
data: TypographyTokenData,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const StringTokenTypedData = z.object({
|
|
106
|
-
type: z.literal("String"),
|
|
107
|
-
data: StringTokenData,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const DimensionTokenTypedData = z.object({
|
|
111
|
-
type: z.literal("Dimension"),
|
|
112
|
-
data: DimensionTokenData,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const FontSizeTokenTypedData = z.object({
|
|
116
|
-
type: z.literal("FontSize"),
|
|
117
|
-
data: FontSizeTokenData,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const FontFamilyTokenTypedData = z.object({
|
|
121
|
-
type: z.literal("FontFamily"),
|
|
122
|
-
data: FontFamilyTokenData,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const FontWeightTokenTypedData = z.object({
|
|
126
|
-
type: z.literal("FontWeight"),
|
|
127
|
-
data: FontWeightTokenData,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const LetterSpacingTokenTypedData = z.object({
|
|
131
|
-
type: z.literal("LetterSpacing"),
|
|
132
|
-
data: LetterSpacingTokenData,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const LineHeightTokenTypedData = z.object({
|
|
136
|
-
type: z.literal("LineHeight"),
|
|
137
|
-
data: LineHeightTokenData,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const ParagraphSpacingTokenTypedData = z.object({
|
|
141
|
-
type: z.literal("ParagraphSpacing"),
|
|
142
|
-
data: ParagraphSpacingTokenData,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const TextCaseTokenTypedData = z.object({
|
|
146
|
-
type: z.literal("TextCase"),
|
|
147
|
-
data: TextCaseTokenData,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
const TextDecorationTokenTypedData = z.object({
|
|
151
|
-
type: z.literal("TextDecoration"),
|
|
152
|
-
data: TextDecorationTokenData,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const BorderRadiusTokenTypedData = z.object({
|
|
156
|
-
type: z.literal("BorderRadius"),
|
|
157
|
-
data: BorderRadiusTokenData,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
const BorderWidthTokenTypedData = z.object({
|
|
161
|
-
type: z.literal("BorderWidth"),
|
|
162
|
-
data: BorderWidthTokenData,
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const BorderTypedData = z.object({
|
|
166
|
-
type: z.literal("Border"),
|
|
167
|
-
data: BorderTokenData,
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const ProductCopyTypedData = z.object({
|
|
171
|
-
type: z.literal("ProductCopy"),
|
|
172
|
-
data: ProductCopyTokenData,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
const SizeTypedData = z.object({
|
|
176
|
-
type: z.literal("Size"),
|
|
177
|
-
data: SizeTokenData,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const SpaceTypedData = z.object({
|
|
181
|
-
type: z.literal("Space"),
|
|
182
|
-
data: SpaceTokenData,
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const VisibilityTypedData = z.object({
|
|
186
|
-
type: z.literal("Visibility"),
|
|
187
|
-
data: VisibilityTokenData,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const ZIndexTypedData = z.object({
|
|
191
|
-
type: z.literal("ZIndex"),
|
|
192
|
-
data: ZIndexTokenData,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const DurationTypedData = z.object({
|
|
196
|
-
type: z.literal("Duration"),
|
|
197
|
-
data: DurationTokenData,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
const FontTypedData = z.object({
|
|
201
|
-
type: z.literal("Font"),
|
|
202
|
-
data: FontTokenData,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
//
|
|
206
|
-
// Global types
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
export const DesignTokenTypedData = z.discriminatedUnion("type", [
|
|
210
|
-
BlurTokenTypedData,
|
|
211
|
-
BorderRadiusTokenTypedData,
|
|
212
|
-
BorderWidthTokenTypedData,
|
|
213
|
-
BorderTypedData,
|
|
214
|
-
ColorTokenTypedData,
|
|
215
|
-
|
|
216
|
-
DimensionTokenTypedData,
|
|
217
|
-
DurationTypedData,
|
|
218
|
-
FontSizeTokenTypedData,
|
|
219
|
-
FontFamilyTokenTypedData,
|
|
220
|
-
FontWeightTokenTypedData,
|
|
221
|
-
|
|
222
|
-
GradientTokenTypedData,
|
|
223
|
-
LetterSpacingTokenTypedData,
|
|
224
|
-
LineHeightTokenTypedData,
|
|
225
|
-
OpacityTokenTypedData,
|
|
226
|
-
ParagraphSpacingTokenTypedData,
|
|
227
|
-
|
|
228
|
-
ProductCopyTypedData,
|
|
229
|
-
ShadowTokenTypedData,
|
|
230
|
-
SizeTypedData,
|
|
231
|
-
SpaceTypedData,
|
|
232
|
-
StringTokenTypedData,
|
|
233
|
-
|
|
234
|
-
TextCaseTokenTypedData,
|
|
235
|
-
TextDecorationTokenTypedData,
|
|
236
|
-
TypographyTokenTypedData,
|
|
237
|
-
VisibilityTypedData,
|
|
238
|
-
ZIndexTypedData,
|
|
239
|
-
FontTypedData,
|
|
240
|
-
]);
|
|
241
|
-
|
|
242
|
-
export type DesignTokenOriginPart = z.infer<typeof DesignTokenOriginPart>;
|
|
243
|
-
export type DesignTokenOrigin = z.infer<typeof DesignTokenOrigin>;
|
|
244
|
-
|
|
245
|
-
export type DesignTokenBase = z.infer<typeof DesignTokenBase>;
|
|
246
|
-
|
|
247
|
-
export const DesignToken = DesignTokenTypedData.and(DesignTokenBase);
|
|
248
|
-
export const CreateDesignToken = DesignTokenTypedData.and(CreateDesignTokenBase);
|
|
249
|
-
|
|
250
|
-
export type DesignTokenTypedData = z.infer<typeof DesignTokenTypedData>;
|
|
251
|
-
export type DesignTokenTypedDataOfType<T extends DesignTokenType> = Extract<DesignTokenTypedData, { type: T }>;
|
|
252
|
-
|
|
253
|
-
export type DesignToken = z.infer<typeof DesignToken>;
|
|
254
|
-
export type ImportedDesignToken = OmitStrict<DesignToken, "origin"> & { origin: DesignTokenOrigin };
|
|
255
|
-
|
|
256
|
-
export type DesignTokenOfType<T extends DesignTokenType> = Extract<DesignToken, { type: T }>;
|
|
257
|
-
export type ImportedDesignTokenOfType<T extends DesignTokenType> = Extract<ImportedDesignToken, { type: T }>;
|
|
258
|
-
|
|
259
|
-
export type CreateDesignToken = z.infer<typeof CreateDesignToken>;
|
|
260
|
-
export type UpdateDesignToken = OmitStrict<DbUpdate<DesignToken>, "brandPersistentId" | "designSystemVersionId">;
|
|
261
|
-
|
|
262
|
-
export type DesignTokensDiff = {
|
|
263
|
-
toCreate: CreateDesignToken[];
|
|
264
|
-
toUpdate: UpdateDesignToken[];
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
//
|
|
268
|
-
// Utilities
|
|
269
|
-
//
|
|
270
|
-
|
|
271
|
-
export function extractTokenTypedData<T extends DesignTokenType, I extends DesignTokenTypedDataOfType<T>>(
|
|
272
|
-
source: I
|
|
273
|
-
): DesignTokenTypedDataOfType<T> {
|
|
274
|
-
return {
|
|
275
|
-
type: source.type,
|
|
276
|
-
data: source.data,
|
|
277
|
-
} as DesignTokenTypedDataOfType<T>;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export function convertTokenTypedData<I extends DesignTokenType, O extends DesignTokenType>(
|
|
281
|
-
source: DesignTokenTypedDataOfType<I>,
|
|
282
|
-
type: O
|
|
283
|
-
): DesignTokenTypedDataOfType<O> {
|
|
284
|
-
if (!areTokenTypesCompatible(source.type, type)) {
|
|
285
|
-
throw SupernovaException.invalidOperation(`Cannot convert token from ${source.type} to ${type}`);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
return {
|
|
289
|
-
type: type,
|
|
290
|
-
data: source.data,
|
|
291
|
-
} as DesignTokenTypedDataOfType<O>;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export function isImportedDesignToken<T extends DesignTokenType>(
|
|
295
|
-
designToken: DesignTokenOfType<T>
|
|
296
|
-
): designToken is ImportedDesignTokenOfType<T> {
|
|
297
|
-
return !!designToken.origin;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export function isDesignTokenOfType<T extends DesignTokenType>(
|
|
301
|
-
designToken: DesignToken,
|
|
302
|
-
type: T
|
|
303
|
-
): designToken is DesignTokenOfType<T> {
|
|
304
|
-
return designToken.type === type;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export function designTokenTypeFilter<T extends DesignTokenType>(
|
|
308
|
-
type: T
|
|
309
|
-
): (designToken: DesignToken) => designToken is DesignTokenOfType<T> {
|
|
310
|
-
return (designToken): designToken is DesignTokenOfType<T> => isDesignTokenOfType(designToken, type);
|
|
311
|
-
}
|