@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,74 @@
|
|
|
1
|
+
import { ZodType, ZodTypeDef, z } from "zod";
|
|
2
|
+
import { ImportModelBase, ImportModelInputBase } from "./base";
|
|
3
|
+
import { FigmaFileStructureOrigin } from "../elements";
|
|
4
|
+
import { FigmaFileStructureNodeBase, FigmaFileStructureStatistics } from "../elements";
|
|
5
|
+
import { FigmaPngRenderImportModel } from "./image";
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
// Nodes Import Model
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
const FigmaFileStructureNodeImportModelBase = FigmaFileStructureNodeBase.extend({
|
|
12
|
+
image: FigmaPngRenderImportModel,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const FigmaFileStructureNodeImportModel: z.ZodType<
|
|
16
|
+
FigmaFileStructureNodeImportModel,
|
|
17
|
+
ZodTypeDef,
|
|
18
|
+
FigmaFileStructureNodeImportModelBaseInput
|
|
19
|
+
> = FigmaFileStructureNodeImportModelBase.extend({
|
|
20
|
+
children: z.lazy(() => FigmaFileStructureNodeImportModel.array()),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
type FigmaFileStructureNodeImportModelBaseInput = z.input<typeof FigmaFileStructureNodeImportModelBase> & {
|
|
24
|
+
children: FigmaFileStructureNodeImportModelBaseInput[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type FigmaFileStructureNodeImportModel = z.infer<typeof FigmaFileStructureNodeImportModelBase> & {
|
|
28
|
+
children: FigmaFileStructureNodeImportModel[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Structure Import Model
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
const FigmaFileStructureImportModelPart = z.object({
|
|
36
|
+
data: z.object({
|
|
37
|
+
rootNode: FigmaFileStructureNodeImportModel,
|
|
38
|
+
assetsInFile: FigmaFileStructureStatistics,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const FigmaFileStructureImportModel = ImportModelBase.extend(FigmaFileStructureImportModelPart.shape).extend({
|
|
43
|
+
origin: FigmaFileStructureOrigin,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type FigmaFileStructureImportModel = z.infer<typeof FigmaFileStructureImportModel>;
|
|
47
|
+
|
|
48
|
+
//
|
|
49
|
+
// Import model input
|
|
50
|
+
//
|
|
51
|
+
|
|
52
|
+
export const FigmaFileStructureImportModelInput = ImportModelInputBase.extend(
|
|
53
|
+
FigmaFileStructureImportModelPart.shape
|
|
54
|
+
).extend({
|
|
55
|
+
fileVersionId: z.string(),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export type FigmaFileStructureImportModelInput = z.infer<typeof FigmaFileStructureImportModelInput>;
|
|
59
|
+
|
|
60
|
+
export function figmaFileStructureImportModelToMap(
|
|
61
|
+
root: FigmaFileStructureNodeImportModel
|
|
62
|
+
): Map<string, FigmaFileStructureNodeImportModel> {
|
|
63
|
+
const map = new Map<string, FigmaFileStructureNodeImportModel>();
|
|
64
|
+
recursiveFigmaFileStructureToMap(root, map);
|
|
65
|
+
return map;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function recursiveFigmaFileStructureToMap(
|
|
69
|
+
node: FigmaFileStructureNodeImportModel,
|
|
70
|
+
map: Map<string, FigmaFileStructureNodeImportModel>
|
|
71
|
+
) {
|
|
72
|
+
map.set(node.id, node);
|
|
73
|
+
for (const child of node.children) recursiveFigmaFileStructureToMap(child, map);
|
|
74
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AssetScope } from "../assets";
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Abstract
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export const ImageImportModelType = z.enum(["Url", "FigmaRender"]);
|
|
9
|
+
export type ImageImportModelType = z.infer<typeof ImageImportModelType>;
|
|
10
|
+
|
|
11
|
+
const ImageImportModelBase = z.object({
|
|
12
|
+
scope: AssetScope,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//
|
|
16
|
+
// Url
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
export const UrlImageImportModel = ImageImportModelBase.extend({
|
|
20
|
+
type: z.literal(ImageImportModelType.enum.Url),
|
|
21
|
+
url: z.string(),
|
|
22
|
+
originKey: z.string(),
|
|
23
|
+
extension: z.enum(["png", "svg", "jpg"]),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type UrlImageImportModel = z.infer<typeof UrlImageImportModel>;
|
|
27
|
+
|
|
28
|
+
//
|
|
29
|
+
// Figma Render
|
|
30
|
+
//
|
|
31
|
+
|
|
32
|
+
export const FigmaRenderFormat = z.enum(["Svg", "Png"]);
|
|
33
|
+
|
|
34
|
+
const FigmaRenderBase = ImageImportModelBase.extend({
|
|
35
|
+
type: z.literal(ImageImportModelType.enum.FigmaRender),
|
|
36
|
+
fileId: z.string(),
|
|
37
|
+
fileVersionId: z.string().optional(),
|
|
38
|
+
nodeId: z.string(),
|
|
39
|
+
originKey: z.string(),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const FigmaPngRenderImportModel = FigmaRenderBase.extend({
|
|
43
|
+
format: z.literal(FigmaRenderFormat.enum.Png),
|
|
44
|
+
scale: z.number(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const FigmaSvgRenderImportModel = FigmaRenderBase.extend({
|
|
48
|
+
format: z.literal(FigmaRenderFormat.enum.Svg),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const FigmaRenderImportModel = z.discriminatedUnion("format", [
|
|
52
|
+
FigmaPngRenderImportModel,
|
|
53
|
+
FigmaSvgRenderImportModel,
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
//
|
|
57
|
+
// Union
|
|
58
|
+
//
|
|
59
|
+
|
|
60
|
+
// Unfortunately discriminated union doesn't support inserting another discriminated union
|
|
61
|
+
export const ImageImportModel = z.union([UrlImageImportModel, FigmaRenderImportModel]);
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
// Types
|
|
65
|
+
//
|
|
66
|
+
|
|
67
|
+
export type FigmaRenderFormat = z.infer<typeof FigmaRenderFormat>;
|
|
68
|
+
export type FigmaRenderBase = z.infer<typeof FigmaRenderBase>;
|
|
69
|
+
export type FigmaPngRenderImportModel = z.infer<typeof FigmaPngRenderImportModel>;
|
|
70
|
+
export type FigmaSvgRenderImportModel = z.infer<typeof FigmaSvgRenderImportModel>;
|
|
71
|
+
export type FigmaRenderImportModel = z.infer<typeof FigmaRenderImportModel>;
|
|
72
|
+
export type ImageImportModel = z.infer<typeof ImageImportModel>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./support";
|
|
2
|
+
export * from "./asset";
|
|
3
|
+
export * from "./base";
|
|
4
|
+
export * from "./component";
|
|
5
|
+
export * from "./data-source";
|
|
6
|
+
export * from "./figma-frames";
|
|
7
|
+
export * from "./image";
|
|
8
|
+
export * from "./origin";
|
|
9
|
+
export * from "./theme";
|
|
10
|
+
export * from "./tokens";
|
|
11
|
+
export * from "./warning";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const FigmaFileDownloadScope = z.object({
|
|
4
|
+
styles: z.boolean(),
|
|
5
|
+
components: z.boolean(),
|
|
6
|
+
currentVersion: z.literal("__latest__").nullable(),
|
|
7
|
+
publishedVersion: z.string().nullable(),
|
|
8
|
+
downloadChunkSize: z.number().optional(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export const FigmaFileAccessData = z.object({
|
|
12
|
+
accessToken: z.string(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type FigmaFileDownloadScope = z.infer<typeof FigmaFileDownloadScope>;
|
|
16
|
+
export type FigmaFileAccessData = z.infer<typeof FigmaFileAccessData>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DataSourceFigmaImportMetadata, DataSourceFigmaRemote } from "../../data-sources";
|
|
3
|
+
import { FigmaFileAccessData, FigmaFileDownloadScope } from "./figma-files";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Importer payload
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
export const ImportFunctionInput = z.object({
|
|
10
|
+
importJobId: z.string(),
|
|
11
|
+
importContextId: z.string(),
|
|
12
|
+
designSystemId: z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type ImportFunctionInput = z.infer<typeof ImportFunctionInput>;
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Base context
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export const ImportedFigmaSourceData = z.object({
|
|
22
|
+
sourceId: z.string(),
|
|
23
|
+
figmaRemote: DataSourceFigmaRemote,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const FigmaImportBaseContext = z.object({
|
|
27
|
+
designSystemId: z.string(),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Data required for accessing Figma files. This should contain access data for all file ids
|
|
31
|
+
* mentioned in the `importedSourceDataBySourceId`
|
|
32
|
+
*
|
|
33
|
+
* fileId: file data
|
|
34
|
+
*/
|
|
35
|
+
fileAccessByFileId: z.record(FigmaFileAccessData),
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Figma source data for which import was requested
|
|
39
|
+
*
|
|
40
|
+
* sourceId: source data
|
|
41
|
+
*/
|
|
42
|
+
importedSourceDataBySourceId: z.record(ImportedFigmaSourceData),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export type ImportedFigmaSourceData = z.infer<typeof ImportedFigmaSourceData>;
|
|
46
|
+
export type FigmaImportBaseContext = z.infer<typeof FigmaImportBaseContext>;
|
|
47
|
+
|
|
48
|
+
//
|
|
49
|
+
// Context with file download scope
|
|
50
|
+
//
|
|
51
|
+
|
|
52
|
+
export const ChangedImportedFigmaSourceData = ImportedFigmaSourceData.extend({
|
|
53
|
+
importMetadata: DataSourceFigmaImportMetadata,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const FigmaImportContextWithDownloadScopes = FigmaImportBaseContext.extend({
|
|
57
|
+
/**
|
|
58
|
+
* Describes what to download from each file, this should contain all file id mentioned in
|
|
59
|
+
* importMetadataBySourceId.
|
|
60
|
+
*
|
|
61
|
+
* File id -> file download scope
|
|
62
|
+
*/
|
|
63
|
+
fileDownloadScopesByFileId: z.record(FigmaFileDownloadScope),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Sources filtered down to the ones that have changed since last import and therefore need to be
|
|
67
|
+
* imported again.
|
|
68
|
+
*
|
|
69
|
+
* Source id -> import metadata
|
|
70
|
+
*/
|
|
71
|
+
changedImportedSourceDataBySourceId: z.record(ChangedImportedFigmaSourceData),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export type ChangedImportedFigmaSourceData = z.infer<typeof ChangedImportedFigmaSourceData>;
|
|
75
|
+
export type FigmaImportContextWithDownloadScopes = z.infer<typeof FigmaImportContextWithDownloadScopes>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AssetImportModelInput, ComponentImportModel, ComponentImportModelInput } from "../component";
|
|
3
|
+
import { ThemeImportModel, ThemeImportModelInput, ThemeUpdateImportModel, ThemeUpdateImportModelInput } from "../theme";
|
|
4
|
+
import { DesignTokenImportModel, DesignTokenImportModelInput } from "../tokens";
|
|
5
|
+
import { FigmaFileStructureImportModel, FigmaFileStructureImportModelInput } from "../figma-frames";
|
|
6
|
+
import { DataSourceImportModel } from "../data-source";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
// Collections
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
export const ImportModelInputCollection = z.object({
|
|
13
|
+
source: DataSourceImportModel,
|
|
14
|
+
tokens: z.array(DesignTokenImportModelInput).default([]),
|
|
15
|
+
components: z.array(ComponentImportModelInput).default([]),
|
|
16
|
+
assets: z.array(AssetImportModelInput).default([]),
|
|
17
|
+
themeUpdates: z.array(ThemeUpdateImportModelInput).default([]),
|
|
18
|
+
themes: z.array(ThemeImportModelInput).default([]),
|
|
19
|
+
figmaFileStructure: FigmaFileStructureImportModelInput.optional(),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const ImportModelCollection = z.object({
|
|
23
|
+
sources: z.array(DataSourceImportModel),
|
|
24
|
+
tokens: z.array(DesignTokenImportModel).default([]),
|
|
25
|
+
components: z.array(ComponentImportModel).default([]),
|
|
26
|
+
themeUpdates: z.array(ThemeUpdateImportModel).default([]),
|
|
27
|
+
themes: z.array(ThemeImportModel).default([]),
|
|
28
|
+
figmaFileStructures: z.array(FigmaFileStructureImportModel),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type ImportModelCollection = z.infer<typeof ImportModelCollection>;
|
|
32
|
+
export type ImportModelInputCollection = z.infer<typeof ImportModelInputCollection>;
|
|
33
|
+
|
|
34
|
+
export function addImportModelCollections(
|
|
35
|
+
lhs: ImportModelCollection,
|
|
36
|
+
rhs: ImportModelCollection
|
|
37
|
+
): ImportModelCollection {
|
|
38
|
+
return {
|
|
39
|
+
sources: [...lhs.sources, ...rhs.sources],
|
|
40
|
+
tokens: [...lhs.tokens, ...rhs.tokens],
|
|
41
|
+
components: [...lhs.components, ...rhs.components],
|
|
42
|
+
themeUpdates: [...lhs.themeUpdates, ...rhs.themeUpdates],
|
|
43
|
+
themes: [...lhs.themes, ...rhs.themes],
|
|
44
|
+
figmaFileStructures: [...lhs.figmaFileStructures, ...rhs.figmaFileStructures],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DesignTokenTypedData } from "../elements";
|
|
3
|
+
import { DesignTokenType } from "../elements";
|
|
4
|
+
import { ThemeOriginObject, ThemeOriginSource, ThemeOverrideOrigin, ThemeOverrideOriginPart } from "../elements";
|
|
5
|
+
import { ObjectMeta } from "../../common";
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
// Overrides
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
export const ThemeOverrideImportModelBase = DesignTokenTypedData.and(
|
|
12
|
+
z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
meta: ObjectMeta,
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const ThemeOverrideImportModel = ThemeOverrideImportModelBase.and(
|
|
19
|
+
z.object({
|
|
20
|
+
origin: ThemeOverrideOrigin,
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export const ThemeOverrideImportModelInput = ThemeOverrideImportModelBase.and(
|
|
25
|
+
z.object({
|
|
26
|
+
originId: z.string(),
|
|
27
|
+
originMetadata: ThemeOverrideOriginPart,
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export type ThemeOverrideImportModel = z.infer<typeof ThemeOverrideImportModel>;
|
|
32
|
+
export type ThemeOverrideImportModelOfType<T extends DesignTokenType> = Extract<ThemeOverrideImportModel, { type: T }>;
|
|
33
|
+
|
|
34
|
+
export type ThemeOverrideImportModelInput = z.infer<typeof ThemeOverrideImportModelInput>;
|
|
35
|
+
export type ThemeOverrideImportModelInputOfType<T extends DesignTokenType> = Extract<
|
|
36
|
+
ThemeOverrideImportModelInput,
|
|
37
|
+
{ type: T }
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
//
|
|
41
|
+
// Themes
|
|
42
|
+
//
|
|
43
|
+
|
|
44
|
+
export const ThemeImportModel = z.object({
|
|
45
|
+
meta: ObjectMeta,
|
|
46
|
+
brandPersistentId: z.string(),
|
|
47
|
+
originSource: ThemeOriginSource,
|
|
48
|
+
overrides: z.array(ThemeOverrideImportModel),
|
|
49
|
+
sortOrder: z.number(),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const ThemeImportModelInput = z.object({
|
|
53
|
+
meta: ObjectMeta,
|
|
54
|
+
originObjects: z.array(ThemeOriginObject),
|
|
55
|
+
overrides: z.array(ThemeOverrideImportModelInput),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export type ThemeImportModel = z.infer<typeof ThemeImportModel>;
|
|
59
|
+
export type ThemeImportModelInput = z.infer<typeof ThemeImportModelInput>;
|
|
60
|
+
|
|
61
|
+
//
|
|
62
|
+
// Theme Update
|
|
63
|
+
//
|
|
64
|
+
|
|
65
|
+
export const ThemeUpdateImportModel = z.object({
|
|
66
|
+
themePersistentId: z.string(),
|
|
67
|
+
overrides: z.array(ThemeOverrideImportModel),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const ThemeUpdateImportModelInput = z.object({
|
|
71
|
+
themePersistentId: z.string(),
|
|
72
|
+
overrides: z.array(ThemeOverrideImportModelInput),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export type ThemeUpdateImportModel = z.infer<typeof ThemeUpdateImportModel>;
|
|
76
|
+
export type ThemeUpdateImportModelInput = z.infer<typeof ThemeUpdateImportModelInput>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DesignTokenType } from "../elements";
|
|
3
|
+
import { DesignTokenOrigin, DesignTokenOriginPart, DesignTokenTypedData } from "../elements";
|
|
4
|
+
import { ImportModelBase, ImportModelInputBase } from "./base";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
// Base
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const DesignTokenImportModelPart = z.object({
|
|
11
|
+
collection: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const DesignTokenImportModelBase = ImportModelBase.extend(DesignTokenImportModelPart.shape).extend({
|
|
15
|
+
origin: DesignTokenOrigin,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const DesignTokenImportModelInputBase = ImportModelInputBase.extend(DesignTokenImportModelPart.shape).extend({
|
|
19
|
+
originMetadata: DesignTokenOriginPart,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
//
|
|
23
|
+
// Import models
|
|
24
|
+
//
|
|
25
|
+
|
|
26
|
+
export const DesignTokenImportModel = DesignTokenTypedData.and(DesignTokenImportModelBase);
|
|
27
|
+
export const DesignTokenImportModelInput = DesignTokenTypedData.and(DesignTokenImportModelInputBase);
|
|
28
|
+
|
|
29
|
+
export type DesignTokenImportModelInputBase = z.infer<typeof DesignTokenImportModelInputBase>;
|
|
30
|
+
|
|
31
|
+
export type DesignTokenImportModel = z.infer<typeof DesignTokenImportModel>;
|
|
32
|
+
export type DesignTokenImportModelOfType<T extends DesignTokenType> = Extract<DesignTokenImportModel, { type: T }>;
|
|
33
|
+
|
|
34
|
+
export type DesignTokenImportModelInput = z.infer<typeof DesignTokenImportModelInput>;
|
|
35
|
+
export type DesignTokenImportModelInputOfType<T extends DesignTokenType> = Extract<DesignTokenImportModel, { type: T }>;
|
|
36
|
+
|
|
37
|
+
export function isDesignTokenImportModelOfType<T extends DesignTokenType>(
|
|
38
|
+
designToken: DesignTokenImportModel,
|
|
39
|
+
type: T
|
|
40
|
+
): designToken is DesignTokenImportModelOfType<T> {
|
|
41
|
+
return designToken.type === type;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function designTokenImportModelTypeFilter<T extends DesignTokenType>(
|
|
45
|
+
type: T
|
|
46
|
+
): (designToken: DesignTokenImportModel) => designToken is DesignTokenImportModelOfType<T> {
|
|
47
|
+
return (designToken): designToken is DesignTokenImportModelOfType<T> =>
|
|
48
|
+
isDesignTokenImportModelOfType(designToken, type);
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const ImportWarningType = z.enum([
|
|
4
|
+
"NoVersionFound",
|
|
5
|
+
"UnsupportedFill",
|
|
6
|
+
"UnsupportedStroke",
|
|
7
|
+
"UnsupportedEffect",
|
|
8
|
+
"NoPublishedElements",
|
|
9
|
+
"NoPublishedStyles",
|
|
10
|
+
"NoPublishedComponents",
|
|
11
|
+
"NoPublishedAssets",
|
|
12
|
+
"StyleNotApplied",
|
|
13
|
+
"ComponentHasNoThumbnail",
|
|
14
|
+
"DuplicateImportedStyleId",
|
|
15
|
+
"DuplicateImportedStylePath",
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export const ImportWarning = z.object({
|
|
19
|
+
warningType: ImportWarningType,
|
|
20
|
+
componentId: z.string().optional(),
|
|
21
|
+
componentName: z.string().optional(),
|
|
22
|
+
styleId: z.string().optional(),
|
|
23
|
+
styleName: z.string().optional(),
|
|
24
|
+
unsupportedStyleValueType: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type ImportWarningType = z.infer<typeof ImportWarningType>;
|
|
28
|
+
export type ImportWarning = z.infer<typeof ImportWarning>;
|
package/src/dsm/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./assets";
|
|
2
|
+
export * from "./data-sources";
|
|
3
|
+
export * from "./documentation";
|
|
4
|
+
export * from "./elements";
|
|
5
|
+
export * from "./import";
|
|
6
|
+
export * from "./properties";
|
|
7
|
+
export * from "./views";
|
|
8
|
+
export * from "./brand";
|
|
9
|
+
export * from "./design-system";
|
|
10
|
+
export * from "./desing-system-create";
|
|
11
|
+
export * from "./desing-system-update";
|
|
12
|
+
export * from "./published-doc-page";
|
|
13
|
+
export * from "./published-doc";
|
|
14
|
+
export * from "./reference";
|
|
15
|
+
export * from "./version";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DbCreateInputOmit, DbUpdate } from "../../helpers";
|
|
3
|
+
|
|
4
|
+
export const ElementPropertyType = z.enum(["Text", "Number", "Boolean", "Select", "Generic", "Link", "URL"]);
|
|
5
|
+
export const ElementPropertyTargetType = z.enum(["Token", "Component", "DocumentationPage"]);
|
|
6
|
+
export const ElementPropertyLinkType = z.enum(["FigmaComponent", "DocumentationPage"]);
|
|
7
|
+
|
|
8
|
+
export const ColorTokenInlineData = z.object({
|
|
9
|
+
value: z.string(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const ElementPropertyDefinitionOption = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
name: z.string(),
|
|
15
|
+
backgroundColor: ColorTokenInlineData.optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const ElementPropertyDefinition = z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
designSystemVersionId: z.string(),
|
|
21
|
+
persistentId: z.string(),
|
|
22
|
+
name: z.string(),
|
|
23
|
+
codeName: z.string(),
|
|
24
|
+
description: z.string(),
|
|
25
|
+
type: ElementPropertyType,
|
|
26
|
+
targetElementType: ElementPropertyTargetType,
|
|
27
|
+
options: z.array(ElementPropertyDefinitionOption).nullish(),
|
|
28
|
+
linkElementType: ElementPropertyLinkType.nullish(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type ElementPropertyType = z.infer<typeof ElementPropertyType>;
|
|
32
|
+
export type ElementPropertyTargetType = z.infer<typeof ElementPropertyTargetType>;
|
|
33
|
+
export type ElementPropertyLinkType = z.infer<typeof ElementPropertyLinkType>;
|
|
34
|
+
export type ColorTokenInlineData = z.infer<typeof ColorTokenInlineData>;
|
|
35
|
+
export type ElementPropertyDefinitionOption = z.infer<typeof ElementPropertyDefinitionOption>;
|
|
36
|
+
export type ElementPropertyDefinition = z.infer<typeof ElementPropertyDefinition>;
|
|
37
|
+
|
|
38
|
+
export type CreateElementPropertyDefinition = DbCreateInputOmit<ElementPropertyDefinition>;
|
|
39
|
+
export type UpdateElementPropertyDefinition = DbUpdate<ElementPropertyDefinition>;
|
|
40
|
+
|
|
41
|
+
export type ElementPropertyDefinitionDiff = {
|
|
42
|
+
toCreate: CreateElementPropertyDefinition[];
|
|
43
|
+
toUpdate: UpdateElementPropertyDefinition[];
|
|
44
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DbCreateInputOmit, DbUpdate, OmitStrict } from "../../helpers";
|
|
3
|
+
|
|
4
|
+
export const ElementPropertyValue = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
designSystemVersionId: z.string(),
|
|
7
|
+
targetElementPersistentId: z.string(),
|
|
8
|
+
definitionPersistentId: z.string(),
|
|
9
|
+
stringValue: z.string().nullish(),
|
|
10
|
+
numberValue: z.number().nullish(),
|
|
11
|
+
booleanValue: z.boolean().nullish(),
|
|
12
|
+
referenceValue: z.string().nullish(),
|
|
13
|
+
referenceValuePreview: z.string().nullish(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type ElementPropertyValue = z.infer<typeof ElementPropertyValue>;
|
|
17
|
+
|
|
18
|
+
export type CreateElementPropertyValue = DbCreateInputOmit<ElementPropertyValue>;
|
|
19
|
+
export type UpdateElementPropertyValue = OmitStrict<
|
|
20
|
+
DbUpdate<ElementPropertyValue>,
|
|
21
|
+
"designSystemVersionId" | "definitionPersistentId" | "targetElementPersistentId"
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export type ElementPropertyValueDiff = {
|
|
25
|
+
toCreate: CreateElementPropertyValue[];
|
|
26
|
+
toUpdate: UpdateElementPropertyValue[];
|
|
27
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DbCreateInputOmit, DbUpdate, OmitStrict } from "../helpers";
|
|
2
|
+
|
|
3
|
+
export const SHORT_PERSISTENT_ID_LENGTH = 8;
|
|
4
|
+
|
|
5
|
+
export function tryParseShortPersistentId(url = "/") {
|
|
6
|
+
const lastUrlPart = url.split("/").pop() || "";
|
|
7
|
+
const shortPersistentId = lastUrlPart.split("-").pop()?.replaceAll(".html", "") || null;
|
|
8
|
+
|
|
9
|
+
return shortPersistentId?.length === SHORT_PERSISTENT_ID_LENGTH ? shortPersistentId : null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PublishedDocPage = {
|
|
13
|
+
id: string;
|
|
14
|
+
publishedDocId: string;
|
|
15
|
+
pageShortPersistentId: string;
|
|
16
|
+
pathV1: string;
|
|
17
|
+
pathV2: string;
|
|
18
|
+
storagePath: string;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
locale: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type CreatePublishedDocPage = DbCreateInputOmit<PublishedDocPage>;
|
|
25
|
+
export type UpdatePublishedDocPage = DbUpdate<OmitStrict<PublishedDocPage, "pageShortPersistentId" | "publishedDocId">>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const publishedDocEnvironments = ["Live", "Preview"] as const;
|
|
4
|
+
export const PublishedDocEnvironment = z.enum(publishedDocEnvironments);
|
|
5
|
+
|
|
6
|
+
export const PublishedDocsChecksums = z.record(z.string());
|
|
7
|
+
|
|
8
|
+
export const PublishedDocRoutingVersion = z.enum(["1", "2"]);
|
|
9
|
+
|
|
10
|
+
export const PublishedDoc = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
designSystemVersionId: z.string(),
|
|
13
|
+
createdAt: z.date(),
|
|
14
|
+
updatedAt: z.date(),
|
|
15
|
+
lastPublishedAt: z.date(),
|
|
16
|
+
isDefault: z.boolean(),
|
|
17
|
+
isPublic: z.boolean(),
|
|
18
|
+
environment: PublishedDocEnvironment,
|
|
19
|
+
checksums: PublishedDocsChecksums,
|
|
20
|
+
storagePath: z.string(),
|
|
21
|
+
wasMigrated: z.boolean(),
|
|
22
|
+
routingVersion: PublishedDocRoutingVersion,
|
|
23
|
+
usesLocalizations: z.boolean(),
|
|
24
|
+
wasPublishedWithLocalizations: z.boolean(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type PublishedDocEnvironment = z.infer<typeof PublishedDocEnvironment>;
|
|
28
|
+
export type PublishedDocsChecksums = z.infer<typeof PublishedDocsChecksums>;
|
|
29
|
+
export type PublishedDocRoutingVersion = z.infer<typeof PublishedDocRoutingVersion>;
|
|
30
|
+
export type PublishedDoc = z.infer<typeof PublishedDoc>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type DesignSystemVersion = {
|
|
2
|
+
id: string;
|
|
3
|
+
version: string;
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
designSystemId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
comment: string;
|
|
8
|
+
isReadonly: boolean;
|
|
9
|
+
parentId: string | null;
|
|
10
|
+
changeLog: string;
|
|
11
|
+
|
|
12
|
+
// TODO Artem
|
|
13
|
+
// customProperties: Prisma.JsonValue | null;
|
|
14
|
+
};
|