@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.
Files changed (165) hide show
  1. package/index.ts +1 -0
  2. package/package.json +23 -0
  3. package/src/auth/index.ts +1 -0
  4. package/src/auth/plugin-oauth-request.ts +14 -0
  5. package/src/billing/card.ts +12 -0
  6. package/src/billing/checkoutSession.ts +16 -0
  7. package/src/billing/customer.ts +28 -0
  8. package/src/billing/features.ts +43 -0
  9. package/src/billing/index.ts +9 -0
  10. package/src/billing/invoice.ts +34 -0
  11. package/src/billing/portalSession.ts +19 -0
  12. package/src/billing/price.ts +24 -0
  13. package/src/billing/product.ts +5 -0
  14. package/src/billing/subscription.ts +65 -0
  15. package/src/codegen/export-jobs.ts +26 -0
  16. package/src/codegen/exporter-workspace-membership-role.ts +4 -0
  17. package/src/codegen/exporter-workspace-membership.ts +14 -0
  18. package/src/codegen/exporter.ts +52 -0
  19. package/src/codegen/git-providers.ts +11 -0
  20. package/src/codegen/index.ts +6 -0
  21. package/src/codegen/pulsar.ts +59 -0
  22. package/src/common/entity.ts +9 -0
  23. package/src/common/index.ts +2 -0
  24. package/src/common/object-meta.ts +8 -0
  25. package/src/custom-domains/custom-domains.ts +24 -0
  26. package/src/custom-domains/index.ts +1 -0
  27. package/src/docs-server/index.ts +1 -0
  28. package/src/docs-server/session.ts +39 -0
  29. package/src/dsm/assets/asset-reference.ts +18 -0
  30. package/src/dsm/assets/asset-value.ts +3 -0
  31. package/src/dsm/assets/asset.ts +48 -0
  32. package/src/dsm/assets/index.ts +3 -0
  33. package/src/dsm/brand.ts +7 -0
  34. package/src/dsm/data-sources/data-source.ts +158 -0
  35. package/src/dsm/data-sources/import-job.ts +28 -0
  36. package/src/dsm/data-sources/import-summary.ts +70 -0
  37. package/src/dsm/data-sources/index.ts +3 -0
  38. package/src/dsm/design-system.ts +33 -0
  39. package/src/dsm/desing-system-create.ts +22 -0
  40. package/src/dsm/desing-system-update.ts +25 -0
  41. package/src/dsm/documentation/block-definitions/aux.ts +8 -0
  42. package/src/dsm/documentation/block-definitions/definition.ts +104 -0
  43. package/src/dsm/documentation/block-definitions/index.ts +4 -0
  44. package/src/dsm/documentation/block-definitions/item.ts +113 -0
  45. package/src/dsm/documentation/block-definitions/variant.ts +78 -0
  46. package/src/dsm/documentation/group.ts +19 -0
  47. package/src/dsm/documentation/index.ts +3 -0
  48. package/src/dsm/documentation/page.ts +18 -0
  49. package/src/dsm/elements/base.ts +49 -0
  50. package/src/dsm/elements/component.ts +48 -0
  51. package/src/dsm/elements/data/base.ts +18 -0
  52. package/src/dsm/elements/data/blur.ts +16 -0
  53. package/src/dsm/elements/data/border-radius.ts +15 -0
  54. package/src/dsm/elements/data/border-width.ts +15 -0
  55. package/src/dsm/elements/data/border.ts +21 -0
  56. package/src/dsm/elements/data/color.ts +13 -0
  57. package/src/dsm/elements/data/component.ts +23 -0
  58. package/src/dsm/elements/data/dimension.ts +15 -0
  59. package/src/dsm/elements/data/documentation-block-v1.ts +325 -0
  60. package/src/dsm/elements/data/documentation-block-v2.ts +57 -0
  61. package/src/dsm/elements/data/documentation-page-v1.ts +13 -0
  62. package/src/dsm/elements/data/documentation-page-v2.ts +11 -0
  63. package/src/dsm/elements/data/documentation.ts +8 -0
  64. package/src/dsm/elements/data/duration.ts +15 -0
  65. package/src/dsm/elements/data/figma-file-structure.ts +65 -0
  66. package/src/dsm/elements/data/figma-node-reference.ts +20 -0
  67. package/src/dsm/elements/data/font-family.ts +8 -0
  68. package/src/dsm/elements/data/font-size.ts +15 -0
  69. package/src/dsm/elements/data/font-weight.ts +8 -0
  70. package/src/dsm/elements/data/gradient.ts +32 -0
  71. package/src/dsm/elements/data/group.ts +17 -0
  72. package/src/dsm/elements/data/index.ts +36 -0
  73. package/src/dsm/elements/data/letter-spacing.ts +15 -0
  74. package/src/dsm/elements/data/line-height.ts +15 -0
  75. package/src/dsm/elements/data/opacity.ts +12 -0
  76. package/src/dsm/elements/data/paragraph-indent.ts +15 -0
  77. package/src/dsm/elements/data/paragraph-spacing.ts +15 -0
  78. package/src/dsm/elements/data/product-copy.ts +8 -0
  79. package/src/dsm/elements/data/shadow.ts +23 -0
  80. package/src/dsm/elements/data/size.ts +15 -0
  81. package/src/dsm/elements/data/space.ts +15 -0
  82. package/src/dsm/elements/data/string.ts +8 -0
  83. package/src/dsm/elements/data/text-case.ts +10 -0
  84. package/src/dsm/elements/data/text-decoration.ts +10 -0
  85. package/src/dsm/elements/data/typography.ts +28 -0
  86. package/src/dsm/elements/data/visibility.ts +10 -0
  87. package/src/dsm/elements/data/z-index.ts +15 -0
  88. package/src/dsm/elements/documentation-page-v1.ts +30 -0
  89. package/src/dsm/elements/documentation-page-v2.ts +16 -0
  90. package/src/dsm/elements/figma-file-structures.ts +39 -0
  91. package/src/dsm/elements/figma-node-reference.ts +17 -0
  92. package/src/dsm/elements/group.ts +59 -0
  93. package/src/dsm/elements/index.ts +13 -0
  94. package/src/dsm/elements/page-block-v2.ts +24 -0
  95. package/src/dsm/elements/primitives/index.ts +2 -0
  96. package/src/dsm/elements/primitives/point.ts +8 -0
  97. package/src/dsm/elements/primitives/size.ts +28 -0
  98. package/src/dsm/elements/raw-element.ts +126 -0
  99. package/src/dsm/elements/theme.ts +74 -0
  100. package/src/dsm/elements/tokens.ts +288 -0
  101. package/src/dsm/import/asset.ts +6 -0
  102. package/src/dsm/import/base.ts +24 -0
  103. package/src/dsm/import/component.ts +36 -0
  104. package/src/dsm/import/data-source.ts +9 -0
  105. package/src/dsm/import/figma-frames.ts +74 -0
  106. package/src/dsm/import/image.ts +72 -0
  107. package/src/dsm/import/index.ts +11 -0
  108. package/src/dsm/import/origin.ts +5 -0
  109. package/src/dsm/import/support/figma-files.ts +16 -0
  110. package/src/dsm/import/support/import-context.ts +75 -0
  111. package/src/dsm/import/support/import-model-collections.ts +46 -0
  112. package/src/dsm/import/support/index.ts +3 -0
  113. package/src/dsm/import/theme.ts +76 -0
  114. package/src/dsm/import/tokens.ts +49 -0
  115. package/src/dsm/import/warning.ts +28 -0
  116. package/src/dsm/index.ts +15 -0
  117. package/src/dsm/properties/index.ts +3 -0
  118. package/src/dsm/properties/property-definition.ts +44 -0
  119. package/src/dsm/properties/property-reference.ts +5 -0
  120. package/src/dsm/properties/property-value.ts +27 -0
  121. package/src/dsm/published-doc-page.ts +25 -0
  122. package/src/dsm/published-doc.ts +30 -0
  123. package/src/dsm/reference.ts +9 -0
  124. package/src/dsm/version.ts +14 -0
  125. package/src/dsm/views/column.ts +43 -0
  126. package/src/dsm/views/index.ts +2 -0
  127. package/src/dsm/views/view.ts +11 -0
  128. package/src/feature-flags/feature-flags.ts +14 -0
  129. package/src/feature-flags/index.ts +1 -0
  130. package/src/helpers/common.ts +1 -0
  131. package/src/helpers/db.ts +37 -0
  132. package/src/helpers/index.ts +4 -0
  133. package/src/helpers/nullish-to-optional.ts +9 -0
  134. package/src/helpers/slug-helper.ts +641 -0
  135. package/src/index.ts +16 -0
  136. package/src/integrations/external-oauth-request.ts +12 -0
  137. package/src/integrations/index.ts +3 -0
  138. package/src/integrations/oauth-providers.ts +13 -0
  139. package/src/integrations/oauth-token.ts +15 -0
  140. package/src/multiplayer/design-system-version-room.ts +13 -0
  141. package/src/multiplayer/documentation-page-room.ts +14 -0
  142. package/src/multiplayer/index.ts +2 -0
  143. package/src/npm/index.ts +2 -0
  144. package/src/npm/npm-package.ts +30 -0
  145. package/src/npm/npm-proxy-token-payload.ts +7 -0
  146. package/src/tokens/index.ts +1 -0
  147. package/src/tokens/personal-access-token.ts +17 -0
  148. package/src/users/index.ts +5 -0
  149. package/src/users/linked-integrations.ts +36 -0
  150. package/src/users/user-identity.ts +8 -0
  151. package/src/users/user-profile.ts +26 -0
  152. package/src/users/user-with-pat.ts +7 -0
  153. package/src/users/user.ts +17 -0
  154. package/src/utils/content-loader-instruction.ts +31 -0
  155. package/src/utils/index.ts +1 -0
  156. package/src/workspace/index.ts +9 -0
  157. package/src/workspace/npm-registry-settings.ts +45 -0
  158. package/src/workspace/sso-provider.ts +13 -0
  159. package/src/workspace/user-invite.ts +18 -0
  160. package/src/workspace/workspace-context.ts +10 -0
  161. package/src/workspace/workspace-create.ts +27 -0
  162. package/src/workspace/workspace-invitations.ts +14 -0
  163. package/src/workspace/workspace-membership.ts +11 -0
  164. package/src/workspace/workspace-role.ts +6 -0
  165. package/src/workspace/workspace.ts +48 -0
@@ -0,0 +1,7 @@
1
+ export type Brand = {
2
+ id: string;
3
+ designSystemVersionId: string;
4
+ persistentId: string;
5
+ name: string;
6
+ description: string;
7
+ };
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+ import { SourceImportSummary } from "./import-summary";
3
+ import { DbCreateInputOmit, DbUpdate, OmitStrict } from "../../helpers";
4
+
5
+ //
6
+ // Enums
7
+ //
8
+
9
+ export const DataSourceRemoteType = z.enum(["Figma", "TokenStudio", "FigmaVariablesPlugin"]);
10
+ export const DataSourceUploadRemoteSource = z.enum(["TokenStudio", "FigmaVariablesPlugin", "Custom"]);
11
+ export const DataSourceFigmaState = z.enum(["Active", "MissingIntegration", "MissingFileAccess", "MissingFileOwner"]);
12
+ export const DataSourceAutoImportMode = z.enum(["Never", "Hourly"]);
13
+
14
+ export type DataSourceRemoteType = z.infer<typeof DataSourceRemoteType>;
15
+ export type DataSourceUploadRemoteSource = z.infer<typeof DataSourceUploadRemoteSource>;
16
+ export type DataSourceFigmaState = z.infer<typeof DataSourceFigmaState>;
17
+ export type DataSourceAutoImportMode = z.infer<typeof DataSourceAutoImportMode>;
18
+
19
+ //
20
+ // Aux
21
+ //
22
+
23
+ export const DataSourceStats = z.object({
24
+ tokens: zeroNumberByDefault(),
25
+ components: zeroNumberByDefault(),
26
+ assets: zeroNumberByDefault(),
27
+ frames: zeroNumberByDefault(),
28
+ });
29
+
30
+ export type DataSourceStats = z.infer<typeof DataSourceStats>;
31
+
32
+ //
33
+ // Figma
34
+ //
35
+
36
+ export const DataSourceFigmaFileData = z.object({
37
+ lastUpdatedAt: z.coerce.date(),
38
+ });
39
+
40
+ export const DataSourceFigmaFileVersionData = z.object({
41
+ id: z.string(),
42
+ label: z.string().optional(),
43
+ description: z.string().optional(),
44
+ createdAt: z.coerce.date(),
45
+ });
46
+
47
+ export const DataSourceFigmaScope = z.object({
48
+ assets: z.boolean(),
49
+ components: z.boolean(),
50
+ documentationFrames: z.boolean(),
51
+ tokens: z.boolean(),
52
+ themePersistentId: z.string().optional(),
53
+ });
54
+
55
+ export const DataSourceFigmaImportMetadata = z.object({
56
+ fileData: DataSourceFigmaFileData.optional(),
57
+ importedPublishedVersion: DataSourceFigmaFileVersionData.optional(),
58
+ });
59
+
60
+ export const DataSourceFigmaRemote = z.object({
61
+ type: z.literal(DataSourceRemoteType.Enum.Figma),
62
+ fileId: z.string(),
63
+ ownerId: z.string(),
64
+ ownerName: z.string(),
65
+ scope: DataSourceFigmaScope,
66
+ state: DataSourceFigmaState,
67
+ lastImportMetadata: DataSourceFigmaImportMetadata.optional(),
68
+ downloadChunkSize: z.number().optional(),
69
+ });
70
+
71
+ export type DataSourceFigmaFileData = z.infer<typeof DataSourceFigmaFileData>;
72
+ export type DataSourceFigmaFileVersionData = z.infer<typeof DataSourceFigmaFileVersionData>;
73
+ export type DataSourceFigmaScope = z.infer<typeof DataSourceFigmaScope>;
74
+ export type DataSourceFigmaImportMetadata = z.infer<typeof DataSourceFigmaImportMetadata>;
75
+ export type DataSourceFigmaRemote = z.infer<typeof DataSourceFigmaRemote>;
76
+
77
+ //
78
+ // Token Studio
79
+ //
80
+
81
+ export const DataSourceTokenStudioRemote = z.object({
82
+ type: z.literal(DataSourceRemoteType.Enum.TokenStudio),
83
+ });
84
+
85
+ export type DataSourceTokenStudioRemote = z.infer<typeof DataSourceTokenStudioRemote>;
86
+
87
+ //
88
+ // Figma Variables Plugin
89
+ //
90
+
91
+ export const DataSourceUploadImportMetadata = z.record(z.any());
92
+
93
+ export const DataSourceUploadRemote = z.object({
94
+ type: z.literal(DataSourceRemoteType.Enum.FigmaVariablesPlugin),
95
+ remoteId: z.string(),
96
+ remoteSourceType: DataSourceUploadRemoteSource,
97
+ lastImportMetadata: DataSourceUploadImportMetadata.optional(),
98
+ });
99
+
100
+ export type DataSourceUploadImportMetadata = z.infer<typeof DataSourceUploadImportMetadata>;
101
+ export type DataSourceUploadRemote = z.infer<typeof DataSourceUploadRemote>;
102
+
103
+ //
104
+ // Base
105
+ //
106
+
107
+ export const DataSourceRemote = z.discriminatedUnion("type", [
108
+ DataSourceFigmaRemote,
109
+ DataSourceUploadRemote,
110
+ DataSourceTokenStudioRemote,
111
+ ]);
112
+
113
+ export type DataSource = {
114
+ id: string;
115
+
116
+ name: string;
117
+ thumbnailUrl: string | undefined;
118
+
119
+ // createdAt: Date;
120
+ // updatedAt: Date;
121
+
122
+ lastImportedAt: Date | undefined;
123
+ lastImportSummary: SourceImportSummary | undefined;
124
+
125
+ // lastImportJobId: Nullish<string>;
126
+ // lastNonEmptyImportJobId: Nullish<string>;
127
+
128
+ designSystemId: string;
129
+ brandPersistentId: string;
130
+
131
+ autoImportMode: DataSourceAutoImportMode;
132
+ stats: DataSourceStats;
133
+
134
+ remote: DataSourceRemote;
135
+
136
+ sortOrder: number;
137
+ };
138
+
139
+ export const DataSourceVersion = z.object({
140
+ id: z.string(),
141
+ createdAt: z.date(),
142
+ label: z.string().nullish(),
143
+ description: z.string().nullish(),
144
+ });
145
+
146
+ export type DataSourceVersion = z.infer<typeof DataSourceVersion>;
147
+
148
+ export type DataSourceRemote = z.infer<typeof DataSourceRemote>;
149
+
150
+ export type CreateDataSource = OmitStrict<DbCreateInputOmit<DataSource>, "sortOrder">;
151
+ export type UpdateDataSource = OmitStrict<DbUpdate<DataSource>, "brandPersistentId" | "designSystemId">;
152
+
153
+ function zeroNumberByDefault() {
154
+ return z
155
+ .number()
156
+ .nullish()
157
+ .transform(v => v ?? 0);
158
+ }
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { DbCreateInputOmit, DbUpdate, OmitStrict } from "../../helpers";
3
+ import { DataSourceRemoteType } from "./data-source";
4
+ import { Entity } from "../../common";
5
+
6
+ export const ImportJobState = z.enum(["PendingInput", "Queued", "InProgress", "Failed", "Success"]);
7
+ export const ImportJobOperation = z.enum(["Check", "Import"]);
8
+
9
+ export const ImportJob = Entity.extend({
10
+ designSystemId: z.string(),
11
+ designSystemVersionId: z.string(),
12
+ sourceIds: z.array(z.string()),
13
+ state: ImportJobState,
14
+ createdByUserId: z.string().optional(),
15
+ importContextId: z.string(),
16
+ error: z.string().optional(),
17
+ sourceType: DataSourceRemoteType,
18
+ });
19
+
20
+ export type ImportJobState = z.infer<typeof ImportJobState>;
21
+ export type ImportJobOperation = z.infer<typeof ImportJobOperation>;
22
+ export type ImportJob = z.infer<typeof ImportJob>;
23
+
24
+ export type CreateImportJob = DbCreateInputOmit<ImportJob>;
25
+ export type UpdateImportJob = OmitStrict<
26
+ DbUpdate<ImportJob>,
27
+ "designSystemId" | "createdByUserId" | "sourceIds" | "importContextId"
28
+ >;
@@ -0,0 +1,70 @@
1
+ import { z } from "zod";
2
+ import { DesignTokenType } from "../elements";
3
+ import { nullishToOptional } from "../../helpers";
4
+ import { ImportWarning } from "../import";
5
+
6
+ export const FileStructureStats = z.object({
7
+ frames: zeroNumberByDefault(),
8
+ components: zeroNumberByDefault(),
9
+ componentSets: zeroNumberByDefault(),
10
+ });
11
+
12
+ const SourceImportSummaryByTokenTypeKey = DesignTokenType.or(
13
+ // Backward compatibility
14
+ z.enum(["Measure", "Radius", "GenericToken", "Font", "Text"])
15
+ );
16
+
17
+ export const SourceImportSummaryByTokenType = z.record(SourceImportSummaryByTokenTypeKey, z.number());
18
+
19
+ export const SourceImportTokenSummary = z.object({
20
+ tokensCreated: zeroNumberByDefault(),
21
+ tokensUpdated: zeroNumberByDefault(),
22
+ tokensDeleted: zeroNumberByDefault(),
23
+ tokensCreatedPerType: SourceImportSummaryByTokenType.nullish().transform(v => v ?? {}),
24
+ tokensUpdatedPerType: SourceImportSummaryByTokenType.nullish().transform(v => v ?? {}),
25
+ tokensDeletedPerType: SourceImportSummaryByTokenType.nullish().transform(v => v ?? {}),
26
+ });
27
+
28
+ export const SourceImportComponentSummary = z.object({
29
+ componentsCreated: zeroNumberByDefault(),
30
+ componentsUpdated: zeroNumberByDefault(),
31
+ componentsDeleted: zeroNumberByDefault(),
32
+ componentAssetsCreated: zeroNumberByDefault(),
33
+ componentAssetsUpdated: zeroNumberByDefault(),
34
+ componentAssetsDeleted: zeroNumberByDefault(),
35
+ });
36
+
37
+ export const SourceImportFrameSummary = z.object({
38
+ assetsInFile: nullishToOptional(FileStructureStats.optional()),
39
+ invalidReferencesCount: nullishToOptional(z.number().optional()),
40
+ });
41
+
42
+ export const SourceImportSummary = z.object({
43
+ sourceId: nullishToOptional(z.string()),
44
+ brandId: nullishToOptional(z.string()),
45
+ versionId: nullishToOptional(z.string()),
46
+ error: nullishToOptional(z.any()),
47
+ isFailed: z.boolean(),
48
+ warnings: z
49
+ .array(ImportWarning)
50
+ .nullish()
51
+ .transform(v => v ?? []),
52
+
53
+ ...SourceImportTokenSummary.shape,
54
+ ...SourceImportComponentSummary.shape,
55
+ ...FileStructureStats.shape,
56
+ });
57
+
58
+ export type FileStructureStats = z.infer<typeof FileStructureStats>;
59
+ export type SourceImportSummaryByTokenType = z.infer<typeof SourceImportSummaryByTokenType>;
60
+ export type SourceImportTokenSummary = z.infer<typeof SourceImportTokenSummary>;
61
+ export type SourceImportComponentSummary = z.infer<typeof SourceImportComponentSummary>;
62
+ export type SourceImportFrameSummary = z.infer<typeof SourceImportFrameSummary>;
63
+ export type SourceImportSummary = z.infer<typeof SourceImportSummary>;
64
+
65
+ function zeroNumberByDefault() {
66
+ return z
67
+ .number()
68
+ .nullish()
69
+ .transform(v => v ?? 0);
70
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./data-source";
2
+ export * from "./import-job";
3
+ export * from "./import-summary";
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import { Workspace } from "../workspace";
3
+ export const DesignSystemSwitcher = z.object({
4
+ isEnabled: z.boolean(),
5
+ designSystemIds: z.string(),
6
+ });
7
+
8
+ export const DesignSystem = z.object({
9
+ id: z.string(),
10
+ workspaceId: z.string(),
11
+ name: z.string(),
12
+ description: z.string(),
13
+ docExporterId: z.string().nullish(),
14
+ docSlug: z.string(),
15
+ docUserSlug: z.string().nullish(),
16
+ docSlugDeprecated: z.string(),
17
+ isPublic: z.boolean(),
18
+ isMultibrand: z.boolean(),
19
+ docViewUrl: z.string().nullish(),
20
+ basePrefixes: z.array(z.string()),
21
+ designSystemSwitcher: DesignSystemSwitcher.nullish(),
22
+ createdAt: z.date(),
23
+ updatedAt: z.date(),
24
+ });
25
+
26
+ export const DesignSystemWithWorkspace = z.object({
27
+ designSystem: DesignSystem,
28
+ workspace: Workspace,
29
+ });
30
+
31
+ export type DesignSystemSwitcher = z.infer<typeof DesignSystemSwitcher>;
32
+ export type DesignSystem = z.infer<typeof DesignSystem>;
33
+ export type DesignSystemWithWorkspace = z.infer<typeof DesignSystemWithWorkspace>;
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+
3
+ const DS_NAME_MIN_LENGTH: number = 2;
4
+ const DS_NAME_MAX_LENGTH: number = 64;
5
+ const DS_DESC_MIN_LENGTH: number = 2;
6
+ const DS_DESC_MAX_LENGTH: number = 64;
7
+
8
+ const DesignSystemCreateInputMetadata = z.object({
9
+ name: z.string().min(DS_NAME_MIN_LENGTH).max(DS_NAME_MAX_LENGTH).trim(),
10
+ description: z.string().min(DS_DESC_MIN_LENGTH).max(DS_DESC_MAX_LENGTH).trim(),
11
+ });
12
+
13
+ export const DesignSystemCreateInput = z.object({
14
+ meta: DesignSystemCreateInputMetadata,
15
+ workspaceId: z.string(),
16
+ isPublic: z.boolean().optional(),
17
+ basePrefixes: z.array(z.string()).optional(),
18
+ docUserSlug: z.string().nullish().optional(),
19
+ source: z.array(z.string()).optional(),
20
+ });
21
+
22
+ export type DesignSystemCreateInput = z.infer<typeof DesignSystemCreateInput>;
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+
3
+ const DS_NAME_MIN_LENGTH: number = 2;
4
+ const DS_NAME_MAX_LENGTH: number = 64;
5
+ const DS_DESC_MIN_LENGTH: number = 2;
6
+ const DS_DESC_MAX_LENGTH: number = 64;
7
+
8
+ const DesignSystemUpdateInputMetadata = z.object({
9
+ name: z.string().min(DS_NAME_MIN_LENGTH).max(DS_NAME_MAX_LENGTH).trim().optional(),
10
+ description: z.string().min(DS_DESC_MIN_LENGTH).max(DS_DESC_MAX_LENGTH).trim().optional(),
11
+ });
12
+
13
+ export const DesignSystemUpdateInput = z.object({
14
+ meta: DesignSystemUpdateInputMetadata.optional(),
15
+ workspaceId: z.string().optional(),
16
+ isPublic: z.boolean().optional(),
17
+ basePrefixes: z.array(z.string()).optional(),
18
+ docUserSlug: z.string().nullish().optional(),
19
+ source: z.array(z.string()).optional(),
20
+ name: z.string().min(DS_NAME_MIN_LENGTH).max(DS_NAME_MAX_LENGTH).trim().optional(),
21
+ description: z.string().min(DS_DESC_MIN_LENGTH).max(DS_DESC_MAX_LENGTH).trim().optional(),
22
+ docExporterId: z.string().optional(),
23
+ });
24
+
25
+ export type DesignSystemUpdateInput = z.infer<typeof DesignSystemUpdateInput>;
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+
3
+ export const PageBlockDefinitionAppearance = z.object({
4
+ isBordered: z.boolean().optional(),
5
+ hasBackground: z.boolean().optional(),
6
+ });
7
+
8
+ export type PageBlockDefinitionAppearance = z.infer<typeof PageBlockDefinitionAppearance>;
@@ -0,0 +1,104 @@
1
+ import { z } from "zod";
2
+ import { AssetValue } from "../../assets/asset-value";
3
+ import { PageBlockDefinitionItem } from "./item";
4
+ import { PageBlockDefinitionAppearance } from "./aux";
5
+
6
+ //
7
+ // Enums
8
+ //
9
+
10
+ export enum PageBlockCategory {
11
+ /** Shows as a "Text Blocks" */
12
+ text = "Text",
13
+ /** Show as "Layout blocks" */
14
+ layout = "Layout",
15
+ /** Show as "Media blocks" */
16
+ media = "Media",
17
+ /** Show as "Embed blocks" */
18
+ embed = "Embed",
19
+ /** Show as "Figma blocks" */
20
+ figma = "Figma",
21
+ /** Show as "Code blocks" */
22
+ code = "Code",
23
+ /** Show as "Guidelines blocks" */
24
+ guidelines = "Guidelines",
25
+ /** Show as "Token blocks" */
26
+ token = "Tokens",
27
+ /** Show as "Component blocks" */
28
+ component = "Components",
29
+ /** Shows as "Asset blocks" */
30
+ asset = "Assets",
31
+ /** Show as "Data blocks" */
32
+ data = "Data",
33
+ /** Shows as "Other blocks" */
34
+ other = "Other",
35
+ }
36
+
37
+ export enum PageBlockBehaviorDataType {
38
+ /** Item type uses item definition alone to construct items - examples of this are RichText, Shortcut, etc. In this mode, data panel will be hidden */
39
+ item = "Item",
40
+ /** Token type allows selection of token entity and associated groups * */
41
+ token = "Token",
42
+ /** Asset type allows selection of asset entity and associated groups * */
43
+ asset = "Asset",
44
+ /** Component type allows selection of asset entity and associated groups * */
45
+ component = "Component",
46
+ }
47
+
48
+ export enum PageBlockBehaviorSelectionType {
49
+ /** Allows selection of data entities only */
50
+ entity = "Entity",
51
+ /** Allows selection of groups only */
52
+ group = "Group",
53
+ /** Allows combined selection of data entities and groups */
54
+ entityAndGroup = "EntityAndGroup",
55
+ }
56
+
57
+ export const PageBlockCategorySchema = z.nativeEnum(PageBlockCategory);
58
+ export const PageBlockBehaviorDataTypeSchema = z.nativeEnum(PageBlockBehaviorDataType);
59
+ export const PageBlockBehaviorSelectionTypeSchema = z.nativeEnum(PageBlockBehaviorSelectionType);
60
+
61
+ //
62
+ // Definitions
63
+ //
64
+
65
+ export const PageBlockDefinitionBehavior = z.object({
66
+ dataType: PageBlockBehaviorDataTypeSchema,
67
+ items: z
68
+ .object({
69
+ numberOfItems: z.number(),
70
+ allowLinks: z.boolean(),
71
+ })
72
+ .optional(),
73
+ entities: z
74
+ .object({
75
+ selectionType: PageBlockBehaviorSelectionTypeSchema,
76
+ maxSelected: z.number(),
77
+ })
78
+ .optional(),
79
+ });
80
+
81
+ export const PageBlockDefinitionOnboarding = z.object({
82
+ helpText: z.string(),
83
+ documentationLink: z.string().optional(),
84
+ });
85
+
86
+ export const PageBlockDefinition = z.object({
87
+ id: z.string(),
88
+ name: z.string(),
89
+ description: z.string(),
90
+ category: PageBlockCategorySchema,
91
+ icon: AssetValue.optional(),
92
+ documentationLink: z.string().optional(),
93
+ searchKeywords: z.array(z.string()).optional(),
94
+ item: PageBlockDefinitionItem,
95
+ behavior: PageBlockDefinitionBehavior,
96
+ editorOptions: z.object({
97
+ onboarding: PageBlockDefinitionOnboarding.optional(),
98
+ }),
99
+ appearance: PageBlockDefinitionAppearance.optional(),
100
+ });
101
+
102
+ export type PageBlockDefinitionBehavior = z.infer<typeof PageBlockDefinitionBehavior>;
103
+ export type PageBlockDefinitionOnboarding = z.infer<typeof PageBlockDefinitionOnboarding>;
104
+ export type PageBlockDefinition = z.infer<typeof PageBlockDefinition>;
@@ -0,0 +1,4 @@
1
+ export * from "./aux";
2
+ export * from "./definition";
3
+ export * from "./item";
4
+ export * from "./variant";
@@ -0,0 +1,113 @@
1
+ import { z } from "zod";
2
+ import { PageBlockDefinitionAppearance } from "./aux";
3
+ import { PageBlockDefinitionVariant } from "./variant";
4
+
5
+ //
6
+ // Enums
7
+ //
8
+
9
+ export enum PageBlockDefinitionPropertyType {
10
+ /** Rich text property allows user to input rich text (with additional attributes like bold, links etc.) */
11
+ richText = "RichText",
12
+ /** Text property allows user to input plain text */
13
+ text = "Text",
14
+ /** Boolean property allows user to input true/false value */
15
+ boolean = "Boolean",
16
+ /** Number property allows user to input number */
17
+ number = "Number",
18
+ /** Single-select property allows user to select one of the options */
19
+ singleSelect = "SingleSelect",
20
+ /** Multi-select property allows user to select multiple of the options */
21
+ multiSelect = "MultiSelect",
22
+ /** Image property allows user to select or upload image */
23
+ image = "Image",
24
+ /** Token type allows data access to the tokens defined in design system */
25
+ token = "Token",
26
+ /** Token type allows selection of type(s) such as color, typography etc., for further use such as filtering */
27
+ tokenType = "TokenType",
28
+ /** Token property allows selection of custom token properties (columns) */
29
+ tokenProperty = "TokenProperty",
30
+ /** Component type allows data access to the components defined in design system */
31
+ component = "Component",
32
+ /** Component property allows selection of custom component properties (columns) */
33
+ componentProperty = "ComponentProperty",
34
+ /** Asset type allows data access to the assets defined in design system */
35
+ asset = "Asset",
36
+ /** Asset property allows selection of custom asset properties (columns) */
37
+ assetProperty = "AssetProperty",
38
+ /** Page type allows data access to the pages defined in design system */
39
+ /** Page property allows selection of custom page properties (columns) */
40
+ /** Embed property allows user to input page to be embedded via URL */
41
+ embedURL = "EmbedURL",
42
+ /** Embed property allows user to input page to be embedded via iframe */
43
+ /** Markdown property allows user to add markdown to render */
44
+ markdown = "Markdown",
45
+ /** Code property allows user to add code to render */
46
+ code = "Code",
47
+ /** Sandbox property allows user to add code sandbox to render live component */
48
+ codeSandbox = "CodeSandbox",
49
+ /** Table property allows user to add table to render */
50
+ table = "Table",
51
+ /** Divider property that puts visual divider into the block. It has no user input */
52
+ divider = "Divider",
53
+ /** Storybook property allows user to add Storybook story to render */
54
+ storybook = "Storybook",
55
+ }
56
+
57
+ export enum PageBlockDefinitionRichTextPropertyStyle {
58
+ /** Title type 1, roughly equivalent of h2 in size */
59
+ title1 = "Title1",
60
+ /** Title type 2, roughly equivalent of h3 in size */
61
+ title2 = "Title2",
62
+ /** Title type 3, roughly equivalent of h4 in size */
63
+ title3 = "Title3",
64
+ /** Title type 4, roughly equivalent of h5 in size */
65
+ title4 = "Title4",
66
+ /** Title type 5, roughly equivalent of h6 in size */
67
+ title5 = "Title5",
68
+ /** Quote */
69
+ quote = "Quote",
70
+ /** Callout */
71
+ callout = "Callout",
72
+ /** Ordered list */
73
+ ol = "OL",
74
+ /** Unordered list */
75
+ ul = "UL",
76
+ /** Default option */
77
+ default = "Default",
78
+ }
79
+
80
+ export const PageBlockDefinitionPropertyTypeSchema = z.nativeEnum(PageBlockDefinitionPropertyType);
81
+ export const PageBlockDefinitionRichTextPropertyStyleSchema = z.nativeEnum(PageBlockDefinitionRichTextPropertyStyle);
82
+
83
+ //
84
+ // Definitions
85
+ //
86
+
87
+ export const PageBlockDefinitionPropertyOptions = z
88
+ .object({
89
+ style: PageBlockDefinitionRichTextPropertyStyleSchema.optional(),
90
+ placeholder: z.string().optional(),
91
+ })
92
+ .and(z.record(z.any()));
93
+
94
+ export const PageBlockDefinitionProperty = z.object({
95
+ id: z.string(),
96
+ name: z.string(),
97
+ type: PageBlockDefinitionPropertyTypeSchema,
98
+ description: z.string().optional(),
99
+ // TODO Docs
100
+ options: PageBlockDefinitionPropertyOptions.optional(),
101
+ variantOptions: z.record(PageBlockDefinitionPropertyOptions).optional(),
102
+ });
103
+
104
+ export const PageBlockDefinitionItem = z.object({
105
+ properties: z.array(PageBlockDefinitionProperty),
106
+ appearance: PageBlockDefinitionAppearance.optional(),
107
+ variants: z.array(PageBlockDefinitionVariant),
108
+ defaultVariantKey: z.string(),
109
+ });
110
+
111
+ export type PageBlockDefinitionPropertyOptions = z.infer<typeof PageBlockDefinitionPropertyOptions>;
112
+ export type PageBlockDefinitionProperty = z.infer<typeof PageBlockDefinitionProperty>;
113
+ export type PageBlockDefinitionItem = z.infer<typeof PageBlockDefinitionItem>;
@@ -0,0 +1,78 @@
1
+ import { ZodTypeDef, z } from "zod";
2
+ import { PageBlockDefinitionAppearance } from "./aux";
3
+
4
+ //
5
+ // Enums
6
+ //
7
+
8
+ export enum PageBlockDefinitionLayoutType {
9
+ /** Layout will stack all its items in this group into column */
10
+ column = "Column",
11
+ /** Layout will stack all its items in this group into row */
12
+ row = "Row",
13
+ }
14
+
15
+ export enum PageBlockDefinitionLayoutGap {
16
+ /** small gap between columns/row */
17
+ small = "Small",
18
+ /** medium gap between columns/row */
19
+ medium = "Medium",
20
+ /** large gap between columns/row */
21
+ large = "Large",
22
+ /** no gap between columns/row */
23
+ none = "None",
24
+ }
25
+
26
+ export enum PageBlockDefinitionLayoutAlign {
27
+ /** Vertically on top */
28
+ start = "Start",
29
+ /** Vertically centered */
30
+ center = "Center",
31
+ /** Vertically on the bottom */
32
+ end = "End",
33
+ }
34
+
35
+ export enum PageBlockDefinitionLayoutResizing {
36
+ /** Will fill all available space for the column */
37
+ fill = "Fill",
38
+ /** Will hug content inside the column */
39
+ hug = "Hug",
40
+ }
41
+
42
+ export const PageBlockDefinitionLayoutTypeSchema = z.nativeEnum(PageBlockDefinitionLayoutType);
43
+ export const PageBlockDefinitionLayoutGapSchema = z.nativeEnum(PageBlockDefinitionLayoutGap);
44
+ export const PageBlockDefinitionLayoutAlignSchema = z.nativeEnum(PageBlockDefinitionLayoutAlign);
45
+ export const PageBlockDefinitionLayoutResizingSchema = z.nativeEnum(PageBlockDefinitionLayoutResizing);
46
+
47
+ //
48
+ // Definitions
49
+ //
50
+
51
+ export const PageBlockDefinitionLayoutBase = z.object({
52
+ type: PageBlockDefinitionLayoutTypeSchema,
53
+ gap: PageBlockDefinitionLayoutGapSchema.optional(),
54
+ columnAlign: PageBlockDefinitionLayoutAlignSchema.optional(),
55
+ columnResizing: PageBlockDefinitionLayoutResizingSchema.optional(),
56
+ });
57
+
58
+ export const PageBlockDefinitionLayout: z.ZodType<PageBlockDefinitionLayout, ZodTypeDef, PageBlockDefinitionLayout> =
59
+ PageBlockDefinitionLayoutBase.extend({
60
+ children: z.lazy(() => z.array(PageBlockDefinitionLayout.or(z.string()))),
61
+ });
62
+
63
+ export const PageBlockDefinitionVariant = z.object({
64
+ id: z.string(),
65
+ name: z.string(),
66
+ image: z.string().optional(),
67
+ description: z.string().optional(),
68
+ documentationLink: z.string().optional(),
69
+ layout: PageBlockDefinitionLayout,
70
+ maxColumns: z.number().optional(),
71
+ defaultColumns: z.number().optional(),
72
+ appearance: PageBlockDefinitionAppearance.optional(),
73
+ });
74
+
75
+ export type PageBlockDefinitionVariant = z.infer<typeof PageBlockDefinitionVariant>;
76
+ export type PageBlockDefinitionLayout = z.infer<typeof PageBlockDefinitionLayoutBase> & {
77
+ children: (PageBlockDefinitionLayout | string)[];
78
+ };
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+
3
+ export const DocumentationPageGroup = z.object({
4
+ type: z.literal("ElementGroup"),
5
+ childType: z.literal("DocumentationPage"),
6
+ id: z.string(),
7
+ persistentId: z.string(),
8
+ shortPersistentId: z.string(),
9
+ designSystemVersionId: z.string(),
10
+ parentPersistentId: z.string().nullish(),
11
+ sortOrder: z.number(),
12
+ title: z.string(),
13
+ slug: z.string(),
14
+ userSlug: z.string().nullish(),
15
+ createdAt: z.date(),
16
+ updatedAt: z.date(),
17
+ });
18
+
19
+ export type DocumentationPageGroup = z.infer<typeof DocumentationPageGroup>;