@supernova-studio/model 0.0.4
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/index.ts +1 -0
- package/package.json +23 -0
- package/src/auth/index.ts +1 -0
- package/src/auth/plugin-oauth-request.ts +14 -0
- package/src/billing/card.ts +12 -0
- package/src/billing/checkoutSession.ts +16 -0
- package/src/billing/customer.ts +28 -0
- package/src/billing/features.ts +43 -0
- package/src/billing/index.ts +9 -0
- package/src/billing/invoice.ts +34 -0
- package/src/billing/portalSession.ts +19 -0
- package/src/billing/price.ts +24 -0
- package/src/billing/product.ts +5 -0
- package/src/billing/subscription.ts +65 -0
- package/src/codegen/export-jobs.ts +26 -0
- package/src/codegen/exporter-workspace-membership-role.ts +4 -0
- package/src/codegen/exporter-workspace-membership.ts +14 -0
- package/src/codegen/exporter.ts +52 -0
- package/src/codegen/git-providers.ts +11 -0
- package/src/codegen/index.ts +6 -0
- package/src/codegen/pulsar.ts +59 -0
- package/src/common/entity.ts +9 -0
- package/src/common/index.ts +2 -0
- package/src/common/object-meta.ts +8 -0
- package/src/custom-domains/custom-domains.ts +24 -0
- package/src/custom-domains/index.ts +1 -0
- package/src/docs-server/index.ts +1 -0
- package/src/docs-server/session.ts +39 -0
- package/src/dsm/assets/asset-reference.ts +18 -0
- package/src/dsm/assets/asset-value.ts +3 -0
- package/src/dsm/assets/asset.ts +48 -0
- package/src/dsm/assets/index.ts +3 -0
- package/src/dsm/brand.ts +7 -0
- package/src/dsm/data-sources/data-source.ts +158 -0
- package/src/dsm/data-sources/import-job.ts +28 -0
- package/src/dsm/data-sources/import-summary.ts +70 -0
- package/src/dsm/data-sources/index.ts +3 -0
- package/src/dsm/design-system.ts +33 -0
- package/src/dsm/desing-system-create.ts +22 -0
- package/src/dsm/desing-system-update.ts +25 -0
- package/src/dsm/documentation/block-definitions/aux.ts +8 -0
- package/src/dsm/documentation/block-definitions/definition.ts +104 -0
- package/src/dsm/documentation/block-definitions/index.ts +4 -0
- package/src/dsm/documentation/block-definitions/item.ts +113 -0
- package/src/dsm/documentation/block-definitions/variant.ts +78 -0
- package/src/dsm/documentation/group.ts +19 -0
- package/src/dsm/documentation/index.ts +3 -0
- package/src/dsm/documentation/page.ts +18 -0
- package/src/dsm/elements/base.ts +49 -0
- package/src/dsm/elements/component.ts +48 -0
- package/src/dsm/elements/data/base.ts +18 -0
- package/src/dsm/elements/data/blur.ts +16 -0
- package/src/dsm/elements/data/border-radius.ts +15 -0
- package/src/dsm/elements/data/border-width.ts +15 -0
- package/src/dsm/elements/data/border.ts +21 -0
- package/src/dsm/elements/data/color.ts +13 -0
- package/src/dsm/elements/data/component.ts +23 -0
- package/src/dsm/elements/data/dimension.ts +15 -0
- package/src/dsm/elements/data/documentation-block-v1.ts +325 -0
- package/src/dsm/elements/data/documentation-block-v2.ts +57 -0
- package/src/dsm/elements/data/documentation-page-v1.ts +13 -0
- package/src/dsm/elements/data/documentation-page-v2.ts +11 -0
- package/src/dsm/elements/data/documentation.ts +8 -0
- package/src/dsm/elements/data/duration.ts +15 -0
- package/src/dsm/elements/data/figma-file-structure.ts +65 -0
- package/src/dsm/elements/data/figma-node-reference.ts +20 -0
- package/src/dsm/elements/data/font-family.ts +8 -0
- package/src/dsm/elements/data/font-size.ts +15 -0
- package/src/dsm/elements/data/font-weight.ts +8 -0
- package/src/dsm/elements/data/gradient.ts +32 -0
- package/src/dsm/elements/data/group.ts +17 -0
- package/src/dsm/elements/data/index.ts +36 -0
- package/src/dsm/elements/data/letter-spacing.ts +15 -0
- package/src/dsm/elements/data/line-height.ts +15 -0
- package/src/dsm/elements/data/opacity.ts +12 -0
- package/src/dsm/elements/data/paragraph-indent.ts +15 -0
- package/src/dsm/elements/data/paragraph-spacing.ts +15 -0
- package/src/dsm/elements/data/product-copy.ts +8 -0
- package/src/dsm/elements/data/shadow.ts +23 -0
- package/src/dsm/elements/data/size.ts +15 -0
- package/src/dsm/elements/data/space.ts +15 -0
- package/src/dsm/elements/data/string.ts +8 -0
- package/src/dsm/elements/data/text-case.ts +10 -0
- package/src/dsm/elements/data/text-decoration.ts +10 -0
- package/src/dsm/elements/data/typography.ts +28 -0
- package/src/dsm/elements/data/visibility.ts +10 -0
- package/src/dsm/elements/data/z-index.ts +15 -0
- package/src/dsm/elements/documentation-page-v1.ts +30 -0
- package/src/dsm/elements/documentation-page-v2.ts +16 -0
- package/src/dsm/elements/figma-file-structures.ts +39 -0
- package/src/dsm/elements/figma-node-reference.ts +17 -0
- package/src/dsm/elements/group.ts +59 -0
- package/src/dsm/elements/index.ts +13 -0
- package/src/dsm/elements/page-block-v2.ts +24 -0
- package/src/dsm/elements/primitives/index.ts +2 -0
- package/src/dsm/elements/primitives/point.ts +8 -0
- package/src/dsm/elements/primitives/size.ts +28 -0
- package/src/dsm/elements/raw-element.ts +126 -0
- package/src/dsm/elements/theme.ts +74 -0
- package/src/dsm/elements/tokens.ts +288 -0
- package/src/dsm/import/asset.ts +6 -0
- package/src/dsm/import/base.ts +24 -0
- package/src/dsm/import/component.ts +36 -0
- package/src/dsm/import/data-source.ts +9 -0
- package/src/dsm/import/figma-frames.ts +74 -0
- package/src/dsm/import/image.ts +72 -0
- package/src/dsm/import/index.ts +11 -0
- package/src/dsm/import/origin.ts +5 -0
- package/src/dsm/import/support/figma-files.ts +16 -0
- package/src/dsm/import/support/import-context.ts +75 -0
- package/src/dsm/import/support/import-model-collections.ts +46 -0
- package/src/dsm/import/support/index.ts +3 -0
- package/src/dsm/import/theme.ts +76 -0
- package/src/dsm/import/tokens.ts +49 -0
- package/src/dsm/import/warning.ts +28 -0
- package/src/dsm/index.ts +15 -0
- package/src/dsm/properties/index.ts +3 -0
- package/src/dsm/properties/property-definition.ts +44 -0
- package/src/dsm/properties/property-reference.ts +5 -0
- package/src/dsm/properties/property-value.ts +27 -0
- package/src/dsm/published-doc-page.ts +25 -0
- package/src/dsm/published-doc.ts +30 -0
- package/src/dsm/reference.ts +9 -0
- package/src/dsm/version.ts +14 -0
- package/src/dsm/views/column.ts +43 -0
- package/src/dsm/views/index.ts +2 -0
- package/src/dsm/views/view.ts +11 -0
- package/src/feature-flags/feature-flags.ts +14 -0
- package/src/feature-flags/index.ts +1 -0
- package/src/helpers/common.ts +1 -0
- package/src/helpers/db.ts +37 -0
- package/src/helpers/index.ts +4 -0
- package/src/helpers/nullish-to-optional.ts +9 -0
- package/src/helpers/slug-helper.ts +641 -0
- package/src/index.ts +16 -0
- package/src/integrations/external-oauth-request.ts +12 -0
- package/src/integrations/index.ts +3 -0
- package/src/integrations/oauth-providers.ts +13 -0
- package/src/integrations/oauth-token.ts +15 -0
- package/src/multiplayer/design-system-version-room.ts +13 -0
- package/src/multiplayer/documentation-page-room.ts +14 -0
- package/src/multiplayer/index.ts +2 -0
- package/src/npm/index.ts +2 -0
- package/src/npm/npm-package.ts +30 -0
- package/src/npm/npm-proxy-token-payload.ts +7 -0
- package/src/tokens/index.ts +1 -0
- package/src/tokens/personal-access-token.ts +17 -0
- package/src/users/index.ts +5 -0
- package/src/users/linked-integrations.ts +36 -0
- package/src/users/user-identity.ts +8 -0
- package/src/users/user-profile.ts +26 -0
- package/src/users/user-with-pat.ts +7 -0
- package/src/users/user.ts +17 -0
- package/src/utils/content-loader-instruction.ts +31 -0
- package/src/utils/index.ts +1 -0
- package/src/workspace/index.ts +9 -0
- package/src/workspace/npm-registry-settings.ts +45 -0
- package/src/workspace/sso-provider.ts +13 -0
- package/src/workspace/user-invite.ts +18 -0
- package/src/workspace/workspace-context.ts +10 -0
- package/src/workspace/workspace-create.ts +27 -0
- package/src/workspace/workspace-invitations.ts +14 -0
- package/src/workspace/workspace-membership.ts +11 -0
- package/src/workspace/workspace-role.ts +6 -0
- package/src/workspace/workspace.ts +48 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const DocumentationPage = z.object({
|
|
4
|
+
type: z.literal("DocumentationPage"),
|
|
5
|
+
id: z.string(),
|
|
6
|
+
persistentId: z.string(),
|
|
7
|
+
shortPersistentId: z.string(),
|
|
8
|
+
designSystemVersionId: z.string(),
|
|
9
|
+
parentPersistentId: z.string().nullish(),
|
|
10
|
+
sortOrder: z.number(),
|
|
11
|
+
title: z.string(),
|
|
12
|
+
slug: z.string(),
|
|
13
|
+
userSlug: z.string().nullish(),
|
|
14
|
+
createdAt: z.date(),
|
|
15
|
+
updatedAt: z.date(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export type DocumentationPage = z.infer<typeof DocumentationPage>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ObjectMeta } from "../../common";
|
|
3
|
+
|
|
4
|
+
export const DesignElementOrigin = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
sourceId: z.string(),
|
|
7
|
+
name: z.string(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const DesignElementBase = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
persistentId: z.string(),
|
|
13
|
+
meta: ObjectMeta,
|
|
14
|
+
designSystemVersionId: z.string(),
|
|
15
|
+
createdAt: z.date(),
|
|
16
|
+
updatedAt: z.date(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const DesignElementImportedBase = DesignElementBase.extend({
|
|
20
|
+
origin: DesignElementOrigin,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const DesignElementGroupablePart = z.object({
|
|
24
|
+
parentPersistentId: z.string().optional(),
|
|
25
|
+
sortOrder: z.number(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const DesignElementGroupableBase = DesignElementBase.extend(DesignElementGroupablePart.shape);
|
|
29
|
+
|
|
30
|
+
export const DesignElementGroupableRequiredPart = DesignElementGroupablePart.extend({
|
|
31
|
+
parentPersistentId: z.string(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const DesignElementBrandedPart = z.object({
|
|
35
|
+
brandPersistentId: z.string(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const DesignElementSlugPart = z.object({
|
|
39
|
+
slug: z.string().optional(),
|
|
40
|
+
userSlug: z.string().optional(),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export type DesignElementOrigin = z.infer<typeof DesignElementOrigin>;
|
|
44
|
+
export type DesignElementBase = z.infer<typeof DesignElementBase>;
|
|
45
|
+
export type DesignElementGroupablePart = z.infer<typeof DesignElementGroupablePart>;
|
|
46
|
+
export type DesignElementGroupableBase = z.infer<typeof DesignElementGroupableBase>;
|
|
47
|
+
export type DesignElementGroupableRequiredPart = z.infer<typeof DesignElementGroupableRequiredPart>;
|
|
48
|
+
export type DesignElementBrandedPart = z.infer<typeof DesignElementBrandedPart>;
|
|
49
|
+
export type DesignElementSlugPart = z.infer<typeof DesignElementSlugPart>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DbCreateInputOmit, DbUpdate, OmitStrict } from "../../helpers";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import {
|
|
4
|
+
DesignElementBase,
|
|
5
|
+
DesignElementBrandedPart,
|
|
6
|
+
DesignElementGroupableRequiredPart,
|
|
7
|
+
DesignElementOrigin,
|
|
8
|
+
} from "./base";
|
|
9
|
+
|
|
10
|
+
export const ComponentOriginPart = z.object({
|
|
11
|
+
nodeId: z.string().optional(),
|
|
12
|
+
width: z.number().optional(),
|
|
13
|
+
height: z.number().optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const ComponentAsset = z.object({
|
|
17
|
+
assetId: z.string(),
|
|
18
|
+
assetPath: z.string(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const ComponentOrigin = DesignElementOrigin.extend(ComponentOriginPart.shape);
|
|
22
|
+
|
|
23
|
+
export const Component = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape)
|
|
24
|
+
.extend(DesignElementBrandedPart.shape)
|
|
25
|
+
.extend({
|
|
26
|
+
origin: ComponentOrigin.optional(),
|
|
27
|
+
thumbnail: ComponentAsset,
|
|
28
|
+
svg: ComponentAsset.optional(),
|
|
29
|
+
isAsset: z.boolean(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type ComponentAsset = z.infer<typeof ComponentAsset>;
|
|
33
|
+
export type Component = z.infer<typeof Component>;
|
|
34
|
+
export type ComponentOrigin = z.infer<typeof ComponentOrigin>;
|
|
35
|
+
export type ImportedComponent = OmitStrict<Component, "origin"> & { origin: ComponentOrigin };
|
|
36
|
+
|
|
37
|
+
export function isImportedComponent(component: Component): component is ImportedComponent {
|
|
38
|
+
return !!component.origin;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type CreateComponent = DbCreateInputOmit<Component>;
|
|
42
|
+
export type UpdateComponent = OmitStrict<DbUpdate<Component>, "brandPersistentId" | "designSystemVersionId">;
|
|
43
|
+
|
|
44
|
+
export type ComponentDiff = {
|
|
45
|
+
toCreate: CreateComponent[];
|
|
46
|
+
toUpdate: UpdateComponent[];
|
|
47
|
+
toDelete: Component["id"][];
|
|
48
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ZodSchema, z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const TokenDataAliasSchema = z.object({
|
|
4
|
+
aliasTo: z
|
|
5
|
+
.string()
|
|
6
|
+
.optional()
|
|
7
|
+
.nullable()
|
|
8
|
+
.transform(v => v ?? undefined),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export function tokenAliasOrValue<T extends ZodSchema>(value: T) {
|
|
12
|
+
return TokenDataAliasSchema.extend({
|
|
13
|
+
value: value
|
|
14
|
+
.optional()
|
|
15
|
+
.nullable()
|
|
16
|
+
.transform(v => (v ?? undefined) as z.output<T> | undefined),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tokenAliasOrValue } from "./base";
|
|
3
|
+
import { DimensionTokenData } from "./dimension";
|
|
4
|
+
|
|
5
|
+
export const BlurType = z.enum(["Layer", "Background"]);
|
|
6
|
+
|
|
7
|
+
export const BlurValue = z.object({
|
|
8
|
+
type: BlurType,
|
|
9
|
+
radius: DimensionTokenData,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const BlurTokenData = tokenAliasOrValue(BlurValue);
|
|
13
|
+
|
|
14
|
+
export type BlurType = z.infer<typeof BlurType>;
|
|
15
|
+
export type BlurValue = z.infer<typeof BlurValue>;
|
|
16
|
+
export type BlurTokenData = z.infer<typeof BlurTokenData>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tokenAliasOrValue } from "./base";
|
|
3
|
+
|
|
4
|
+
export const BorderRadiusUnit = z.enum(["Pixels", "Rem", "Percent"]);
|
|
5
|
+
|
|
6
|
+
export const BorderRadiusValue = z.object({
|
|
7
|
+
unit: BorderRadiusUnit,
|
|
8
|
+
measure: z.number(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const BorderRadiusTokenData = tokenAliasOrValue(BorderRadiusValue);
|
|
12
|
+
|
|
13
|
+
export type BorderRadiusUnit = z.infer<typeof BorderRadiusUnit>;
|
|
14
|
+
export type BorderRadiusValue = z.infer<typeof BorderRadiusValue>;
|
|
15
|
+
export type BorderRadiusTokenData = z.infer<typeof BorderRadiusTokenData>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tokenAliasOrValue } from "./base";
|
|
3
|
+
|
|
4
|
+
export const BorderWidthUnit = z.enum(["Pixels"]);
|
|
5
|
+
|
|
6
|
+
export const BorderWidthValue = z.object({
|
|
7
|
+
unit: BorderWidthUnit,
|
|
8
|
+
measure: z.number(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const BorderWidthTokenData = tokenAliasOrValue(BorderWidthValue);
|
|
12
|
+
|
|
13
|
+
export type BorderWidthUnit = z.infer<typeof BorderWidthUnit>;
|
|
14
|
+
export type BorderWidthValue = z.infer<typeof BorderWidthValue>;
|
|
15
|
+
export type BorderWidthTokenData = z.infer<typeof BorderWidthTokenData>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ColorTokenData } from "./color";
|
|
3
|
+
import { BorderWidthTokenData } from "./border-width";
|
|
4
|
+
import { tokenAliasOrValue } from "./base";
|
|
5
|
+
|
|
6
|
+
export const BorderPosition = z.enum(["Inside", "Center", "Outside"]);
|
|
7
|
+
export const BorderStyle = z.enum(["Dashed", "Dotted", "Solid", "Groove"]);
|
|
8
|
+
|
|
9
|
+
export const BorderValue = z.object({
|
|
10
|
+
color: ColorTokenData,
|
|
11
|
+
width: BorderWidthTokenData,
|
|
12
|
+
position: BorderPosition,
|
|
13
|
+
style: BorderStyle.optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const BorderTokenData = tokenAliasOrValue(BorderValue);
|
|
17
|
+
|
|
18
|
+
export type BorderPosition = z.infer<typeof BorderPosition>;
|
|
19
|
+
export type BorderStyle = z.infer<typeof BorderStyle>;
|
|
20
|
+
export type BorderValue = z.infer<typeof BorderValue>;
|
|
21
|
+
export type BorderTokenData = z.infer<typeof BorderTokenData>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { TokenDataAliasSchema, tokenAliasOrValue } from "./base";
|
|
3
|
+
import { OpacityTokenData } from "./opacity";
|
|
4
|
+
|
|
5
|
+
export const ColorValue = z.object({
|
|
6
|
+
opacity: OpacityTokenData,
|
|
7
|
+
color: z.string().or(TokenDataAliasSchema),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const ColorTokenData = tokenAliasOrValue(ColorValue);
|
|
11
|
+
|
|
12
|
+
export type ColorValue = z.infer<typeof ColorValue>;
|
|
13
|
+
export type ColorTokenData = z.infer<typeof ColorTokenData>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const ComponentElementData = z.object({
|
|
4
|
+
value: z.object({
|
|
5
|
+
thumbnailImage: z.object({
|
|
6
|
+
value: z.object({
|
|
7
|
+
url: z.string(),
|
|
8
|
+
assetId: z.string(),
|
|
9
|
+
}),
|
|
10
|
+
}),
|
|
11
|
+
|
|
12
|
+
svg: z
|
|
13
|
+
.object({
|
|
14
|
+
value: z.object({
|
|
15
|
+
url: z.string(),
|
|
16
|
+
assetId: z.string(),
|
|
17
|
+
}),
|
|
18
|
+
})
|
|
19
|
+
.optional(),
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type ComponentElementData = z.infer<typeof ComponentElementData>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tokenAliasOrValue } from "./base";
|
|
3
|
+
|
|
4
|
+
export const DimensionUnit = z.enum(["Pixels", "Percent", "Rem", "Ms", "Raw", "Points"]);
|
|
5
|
+
|
|
6
|
+
export const DimensionValue = z.object({
|
|
7
|
+
unit: DimensionUnit,
|
|
8
|
+
measure: z.number(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const DimensionTokenData = tokenAliasOrValue(DimensionValue);
|
|
12
|
+
|
|
13
|
+
export type DimensionUnit = z.infer<typeof DimensionUnit>;
|
|
14
|
+
export type DimensionValue = z.infer<typeof DimensionValue>;
|
|
15
|
+
export type DimensionTokenData = z.infer<typeof DimensionTokenData>;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DesignTokenType } from "../raw-element";
|
|
3
|
+
import { DimensionTokenData } from "./dimension";
|
|
4
|
+
import { ColorTokenInlineData } from "../../properties";
|
|
5
|
+
import { Size } from "../primitives";
|
|
6
|
+
import { nullishToOptional } from "../../../helpers";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
// Enums
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
export enum PageBlockCalloutType {
|
|
13
|
+
info = "Info",
|
|
14
|
+
success = "Success",
|
|
15
|
+
warning = "Warning",
|
|
16
|
+
error = "Error",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const PageBlockCalloutTypeSchema = z.nativeEnum(PageBlockCalloutType);
|
|
20
|
+
|
|
21
|
+
export const PageBlockTypeV1 = z.enum([
|
|
22
|
+
"Text",
|
|
23
|
+
"Heading",
|
|
24
|
+
"Code",
|
|
25
|
+
"UnorderedList",
|
|
26
|
+
"OrderedList",
|
|
27
|
+
"Quote",
|
|
28
|
+
"Callout",
|
|
29
|
+
"Divider",
|
|
30
|
+
"Image",
|
|
31
|
+
"Embed",
|
|
32
|
+
"Link",
|
|
33
|
+
"Shortcuts",
|
|
34
|
+
"FigmaEmbed",
|
|
35
|
+
"YoutubeEmbed",
|
|
36
|
+
"StorybookEmbed",
|
|
37
|
+
"Token",
|
|
38
|
+
"TokenGroup",
|
|
39
|
+
"TokenList",
|
|
40
|
+
"Component",
|
|
41
|
+
"ComponentGroup",
|
|
42
|
+
"Theme",
|
|
43
|
+
"ComponentSandbox",
|
|
44
|
+
"Custom",
|
|
45
|
+
"FigmaFrames",
|
|
46
|
+
"ComponentAssets",
|
|
47
|
+
"RenderCode",
|
|
48
|
+
"Tabs",
|
|
49
|
+
"TabItem",
|
|
50
|
+
"Table",
|
|
51
|
+
"TableRow",
|
|
52
|
+
"TableCell",
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
export const PageBlockCodeLanguage = z.enum([
|
|
56
|
+
"Angular",
|
|
57
|
+
"Bash",
|
|
58
|
+
"C",
|
|
59
|
+
"Cpp",
|
|
60
|
+
"Csharp",
|
|
61
|
+
"CSS",
|
|
62
|
+
"Dart",
|
|
63
|
+
"Handlebars",
|
|
64
|
+
"HTML",
|
|
65
|
+
"Java",
|
|
66
|
+
"Javascript",
|
|
67
|
+
"JSON",
|
|
68
|
+
"ReactJSX",
|
|
69
|
+
"ReactTSX",
|
|
70
|
+
"Kotlin",
|
|
71
|
+
"Lua",
|
|
72
|
+
"Markdown",
|
|
73
|
+
"ObjectiveC",
|
|
74
|
+
"PHP",
|
|
75
|
+
"Plain",
|
|
76
|
+
"Python",
|
|
77
|
+
"Ruby",
|
|
78
|
+
"Rust",
|
|
79
|
+
"Sass",
|
|
80
|
+
"SCSS",
|
|
81
|
+
"Svetle",
|
|
82
|
+
"Swift",
|
|
83
|
+
"Twig",
|
|
84
|
+
"Typescript",
|
|
85
|
+
"Vue",
|
|
86
|
+
"XML",
|
|
87
|
+
"YAML",
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
export const PageBlockAlignment = z.enum(["Left", "Center", "Stretch", "Right"]);
|
|
91
|
+
export const PageBlockThemeType = z.enum(["Override", "Comparison"]);
|
|
92
|
+
export const PageBlockAssetType = z.enum(["image", "figmaFrame"]);
|
|
93
|
+
|
|
94
|
+
export const PageBlockTilesAlignment = z.enum(["Center", "FrameHeight"]);
|
|
95
|
+
|
|
96
|
+
export const PageBlockTilesLayout = z.enum(["C8", "C7", "C6", "C5", "C4", "C3", "C2", "C1", "C1_75"]);
|
|
97
|
+
|
|
98
|
+
//
|
|
99
|
+
// Support types
|
|
100
|
+
//
|
|
101
|
+
|
|
102
|
+
export const PageBlockTheme = z.object({
|
|
103
|
+
themeIds: z.array(z.string()),
|
|
104
|
+
type: PageBlockThemeType,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export const PageBlockUrlPreview = z.object({
|
|
108
|
+
title: nullishToOptional(z.string()),
|
|
109
|
+
description: nullishToOptional(z.string()),
|
|
110
|
+
thumbnailUrl: nullishToOptional(z.string()),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const PageBlockFrameOrigin = z.object({
|
|
114
|
+
sourceFileName: nullishToOptional(z.string()),
|
|
115
|
+
title: nullishToOptional(z.string()),
|
|
116
|
+
previewUrl: nullishToOptional(z.string()),
|
|
117
|
+
valid: nullishToOptional(z.boolean()),
|
|
118
|
+
referenceId: nullishToOptional(z.string()),
|
|
119
|
+
assetId: nullishToOptional(z.string()),
|
|
120
|
+
assetScale: nullishToOptional(z.number()),
|
|
121
|
+
width: nullishToOptional(z.number()),
|
|
122
|
+
height: nullishToOptional(z.number()),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const PageBlockFrame = z.object({
|
|
126
|
+
persistentId: z.string(),
|
|
127
|
+
sourceId: z.string(),
|
|
128
|
+
sourceFrameId: z.string(),
|
|
129
|
+
title: nullishToOptional(z.string()),
|
|
130
|
+
description: nullishToOptional(z.string()),
|
|
131
|
+
backgroundColor: nullishToOptional(ColorTokenInlineData),
|
|
132
|
+
origin: nullishToOptional(PageBlockFrameOrigin),
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export const PageBlockAsset = z.object({
|
|
136
|
+
type: PageBlockAssetType,
|
|
137
|
+
id: nullishToOptional(z.string()),
|
|
138
|
+
url: nullishToOptional(z.string()),
|
|
139
|
+
figmaFrame: nullishToOptional(PageBlockFrame),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const PageBlockLinkPreview = z.object({
|
|
143
|
+
title: nullishToOptional(z.string()),
|
|
144
|
+
valid: nullishToOptional(z.boolean()),
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export const PageBlockShortcut = z.object({
|
|
148
|
+
persistentId: z.string(),
|
|
149
|
+
title: nullishToOptional(z.string()),
|
|
150
|
+
description: nullishToOptional(z.string()),
|
|
151
|
+
asset: nullishToOptional(PageBlockAsset),
|
|
152
|
+
documentationItemId: nullishToOptional(z.string()),
|
|
153
|
+
url: nullishToOptional(z.string()),
|
|
154
|
+
urlPreview: nullishToOptional(PageBlockUrlPreview),
|
|
155
|
+
documentationItemPreview: nullishToOptional(PageBlockLinkPreview),
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export const PageBlockCustomBlockPropertyImageValue = z.object({
|
|
159
|
+
asset: nullishToOptional(PageBlockAsset),
|
|
160
|
+
assetId: nullishToOptional(z.string()),
|
|
161
|
+
assetUrl: nullishToOptional(z.string()),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
export const PageBlockCustomBlockPropertyValue = z.object({
|
|
165
|
+
key: z.string(),
|
|
166
|
+
value: z.any(),
|
|
167
|
+
|
|
168
|
+
// TODO Artem: for some reason there are cases when there's an array here in the DB
|
|
169
|
+
// e.g. element id 67451 in the dev db
|
|
170
|
+
|
|
171
|
+
// value: z
|
|
172
|
+
// .boolean()
|
|
173
|
+
// .or(z.number())
|
|
174
|
+
// .or(z.string())
|
|
175
|
+
// .or(ColorTokenData)
|
|
176
|
+
// .or(TypographyTokenData)
|
|
177
|
+
// .or(PageBlockCustomBlockPropertyImageValue),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export const PageBlockFigmaFrameProperties = z.object({
|
|
181
|
+
alignment: PageBlockTilesAlignment,
|
|
182
|
+
layout: PageBlockTilesLayout,
|
|
183
|
+
backgroundColor: nullishToOptional(ColorTokenInlineData),
|
|
184
|
+
showTitles: z.boolean(),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
export const PageBlockRenderCodeProperties = z.object({
|
|
188
|
+
showCode: z.boolean(),
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export const PageBlockAssetComponent = z.object({
|
|
192
|
+
persistentId: z.string(),
|
|
193
|
+
componentAssetId: z.string(),
|
|
194
|
+
title: nullishToOptional(z.string()),
|
|
195
|
+
description: nullishToOptional(z.string()),
|
|
196
|
+
backgroundColor: nullishToOptional(ColorTokenInlineData),
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
export const PageBlockTableColumn = z.object({
|
|
200
|
+
id: z.string(),
|
|
201
|
+
width: DimensionTokenData,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export const PageBlockTableProperties = z.object({
|
|
205
|
+
showBorders: z.boolean(),
|
|
206
|
+
showHeaderRow: z.boolean(),
|
|
207
|
+
showHeaderColumn: z.boolean(),
|
|
208
|
+
columns: z.array(PageBlockTableColumn),
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
export const PageBlockTextSpanAttributeType = z.enum(["Bold", "Italic", "Link", "Strikethrough", "Code"]);
|
|
212
|
+
|
|
213
|
+
export const PageBlockTextSpanAttribute = z.object({
|
|
214
|
+
type: PageBlockTextSpanAttributeType,
|
|
215
|
+
link: nullishToOptional(z.string()),
|
|
216
|
+
documentationItemId: nullishToOptional(z.string()),
|
|
217
|
+
openInNewWindow: nullishToOptional(z.boolean()),
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
export const PageBlockTextSpan = z.object({
|
|
221
|
+
text: z.string(),
|
|
222
|
+
attributes: z.array(PageBlockTextSpanAttribute),
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
export const PageBlockText = z.object({
|
|
226
|
+
spans: z.array(PageBlockTextSpan),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
export type PageBlockTypeV1 = z.infer<typeof PageBlockTypeV1>;
|
|
230
|
+
export type PageBlockTextSpanAttribute = z.infer<typeof PageBlockTextSpanAttribute>;
|
|
231
|
+
export type PageBlockTextSpan = z.infer<typeof PageBlockTextSpan>;
|
|
232
|
+
export type PageBlockText = z.infer<typeof PageBlockText>;
|
|
233
|
+
export type PageBlockFrame = z.infer<typeof PageBlockFrame>;
|
|
234
|
+
export type PageBlockFrameOrigin = z.infer<typeof PageBlockFrameOrigin>;
|
|
235
|
+
|
|
236
|
+
//
|
|
237
|
+
// Block
|
|
238
|
+
//
|
|
239
|
+
|
|
240
|
+
const PageBlockBaseV1 = z.object({
|
|
241
|
+
persistentId: z.string(),
|
|
242
|
+
type: PageBlockTypeV1,
|
|
243
|
+
|
|
244
|
+
// Element linking
|
|
245
|
+
designObjectId: nullishToOptional(z.string()),
|
|
246
|
+
designObjectIds: nullishToOptional(z.array(z.string())),
|
|
247
|
+
tokenType: nullishToOptional(DesignTokenType.or(z.literal("Font"))),
|
|
248
|
+
showNestedGroups: nullishToOptional(z.boolean()),
|
|
249
|
+
brandId: nullishToOptional(z.string()),
|
|
250
|
+
|
|
251
|
+
// Rich text
|
|
252
|
+
text: nullishToOptional(PageBlockText),
|
|
253
|
+
caption: nullishToOptional(z.string()),
|
|
254
|
+
headingType: nullishToOptional(z.number().min(1).max(3)),
|
|
255
|
+
codeLanguage: nullishToOptional(PageBlockCodeLanguage),
|
|
256
|
+
calloutType: nullishToOptional(PageBlockCalloutTypeSchema),
|
|
257
|
+
urlInput: nullishToOptional(z.string()),
|
|
258
|
+
url: nullishToOptional(z.string()),
|
|
259
|
+
urlPreview: nullishToOptional(PageBlockUrlPreview),
|
|
260
|
+
|
|
261
|
+
// Image
|
|
262
|
+
asset: nullishToOptional(PageBlockAsset),
|
|
263
|
+
alignment: nullishToOptional(PageBlockAlignment),
|
|
264
|
+
|
|
265
|
+
// Shortcuts block
|
|
266
|
+
shortcuts: nullishToOptional(z.array(PageBlockShortcut)),
|
|
267
|
+
|
|
268
|
+
// Custom blocks
|
|
269
|
+
customBlockKey: nullishToOptional(z.string()),
|
|
270
|
+
customBlockProperties: nullishToOptional(z.array(PageBlockCustomBlockPropertyValue)),
|
|
271
|
+
variantKey: nullishToOptional(z.string()),
|
|
272
|
+
|
|
273
|
+
// Figma frames
|
|
274
|
+
figmaFrameProperties: nullishToOptional(PageBlockFigmaFrameProperties),
|
|
275
|
+
figmaFrames: nullishToOptional(z.array(PageBlockFrame)),
|
|
276
|
+
|
|
277
|
+
// Generic
|
|
278
|
+
size: nullishToOptional(Size),
|
|
279
|
+
backgroundColor: nullishToOptional(ColorTokenInlineData),
|
|
280
|
+
|
|
281
|
+
// Render code
|
|
282
|
+
renderCodeProperties: nullishToOptional(PageBlockRenderCodeProperties),
|
|
283
|
+
|
|
284
|
+
// Component assets
|
|
285
|
+
componentAssets: nullishToOptional(z.array(PageBlockAssetComponent)),
|
|
286
|
+
|
|
287
|
+
// Tables
|
|
288
|
+
tableProperties: nullishToOptional(PageBlockTableProperties),
|
|
289
|
+
columnId: nullishToOptional(z.string()),
|
|
290
|
+
|
|
291
|
+
// Token spreadsheet
|
|
292
|
+
theme: nullishToOptional(PageBlockTheme),
|
|
293
|
+
blacklistedElementProperties: nullishToOptional(z.array(z.string())),
|
|
294
|
+
|
|
295
|
+
// Arbitrary
|
|
296
|
+
userMetadata: nullishToOptional(z.string()),
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
type PageBlockV1Input = z.input<typeof PageBlockBaseV1> & {
|
|
300
|
+
children: PageBlockV1Input[] | null | undefined;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const PageBlockV1: z.ZodType<PageBlockV1, z.ZodTypeDef, PageBlockV1Input> = PageBlockBaseV1.extend({
|
|
304
|
+
children: z.lazy(
|
|
305
|
+
() =>
|
|
306
|
+
PageBlockV1.array()
|
|
307
|
+
.nullish()
|
|
308
|
+
.transform(t => t ?? []) as z.ZodType<PageBlockV1[], z.ZodTypeDef, PageBlockV1Input[]>
|
|
309
|
+
),
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
export type PageBlockV1 = z.infer<typeof PageBlockBaseV1> & {
|
|
313
|
+
children: PageBlockV1[];
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
//
|
|
317
|
+
// Utility methods
|
|
318
|
+
//
|
|
319
|
+
|
|
320
|
+
export function traversePageBlocksV1(blocks: PageBlockV1[], action: (block: PageBlockV1) => void) {
|
|
321
|
+
for (const block of blocks) {
|
|
322
|
+
action(block);
|
|
323
|
+
traversePageBlocksV1(block.children, action);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ColorValue } from "./color";
|
|
3
|
+
import { PageBlockCalloutTypeSchema } from "./documentation-block-v1";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Enums
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
export enum PageBlockLinkType {
|
|
10
|
+
page = "Page",
|
|
11
|
+
pageHeading = "pageHeading",
|
|
12
|
+
group = "Group",
|
|
13
|
+
url = "url",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const PageBlockLinkTypeSchema = z.enum(["Page", "PageHeading", "Group", "Url"]);
|
|
17
|
+
|
|
18
|
+
//
|
|
19
|
+
// Definitions
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
export const PageBlockAppearanceV2 = z.object({
|
|
23
|
+
itemBackgroundColor: ColorValue,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const PageBlockItemPropertyValue = z.object({
|
|
27
|
+
value: z.any(),
|
|
28
|
+
calloutType: PageBlockCalloutTypeSchema.optional(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const PageBlockLinkV2 = z.object({
|
|
32
|
+
type: PageBlockLinkTypeSchema,
|
|
33
|
+
pageId: z.string().optional(),
|
|
34
|
+
pageHeadingId: z.string().optional(),
|
|
35
|
+
groupId: z.string().optional(),
|
|
36
|
+
url: z.string().optional(),
|
|
37
|
+
openInNewTab: z.boolean().optional(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const PageBlockItemV2 = z.object({
|
|
41
|
+
linksTo: PageBlockLinkV2.optional(),
|
|
42
|
+
props: z.record(PageBlockItemPropertyValue),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const PageBlockDataV2 = z.object({
|
|
46
|
+
packageId: z.string(),
|
|
47
|
+
variantId: z.string().optional(),
|
|
48
|
+
indentLevel: z.number(),
|
|
49
|
+
appearance: PageBlockAppearanceV2.optional(),
|
|
50
|
+
items: z.array(PageBlockItemV2),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type PageBlockAppearanceV2 = z.infer<typeof PageBlockAppearanceV2>;
|
|
54
|
+
export type PageBlockItemPropertyValue = z.infer<typeof PageBlockItemPropertyValue>;
|
|
55
|
+
export type PageBlockLinkV2 = z.infer<typeof PageBlockLinkV2>;
|
|
56
|
+
export type PageBlockItemV2 = z.infer<typeof PageBlockItemV2>;
|
|
57
|
+
export type PageBlockDataV2 = z.infer<typeof PageBlockDataV2>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DocumentationItemConfiguration } from "./documentation";
|
|
3
|
+
import { PageBlockV1 } from "./documentation-block-v1";
|
|
4
|
+
import { nullishToOptional } from "../../../helpers";
|
|
5
|
+
|
|
6
|
+
export const DocumentationPageDataV1 = z.object({
|
|
7
|
+
blocks: z.array(PageBlockV1),
|
|
8
|
+
configuration: nullishToOptional(DocumentationItemConfiguration),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const DocumentationPageElementDataV1 = z.object({
|
|
12
|
+
value: DocumentationPageDataV1,
|
|
13
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DocumentationItemConfiguration } from "./documentation";
|
|
3
|
+
import { nullishToOptional } from "../../../helpers";
|
|
4
|
+
|
|
5
|
+
export const DocumentationPageDataV2 = z.object({
|
|
6
|
+
configuration: nullishToOptional(DocumentationItemConfiguration),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const DocumentationPageElementDataV2 = z.object({
|
|
10
|
+
value: DocumentationPageDataV2,
|
|
11
|
+
});
|