@supernova-studio/model 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/index.d.mts +26740 -18977
  2. package/dist/index.d.ts +26740 -18977
  3. package/dist/index.js +275 -47
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +2201 -1973
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +3 -4
  8. package/src/asset-delete-schedule/asset-delete-schedule.ts +0 -20
  9. package/src/asset-delete-schedule/index.ts +0 -1
  10. package/src/auth/index.ts +0 -1
  11. package/src/auth/plugin-oauth-request.ts +0 -14
  12. package/src/billing/card.ts +0 -12
  13. package/src/billing/checkoutSession.ts +0 -16
  14. package/src/billing/customer.ts +0 -29
  15. package/src/billing/features.ts +0 -48
  16. package/src/billing/index.ts +0 -9
  17. package/src/billing/invoice.ts +0 -34
  18. package/src/billing/portalSession.ts +0 -19
  19. package/src/billing/price.ts +0 -24
  20. package/src/billing/product.ts +0 -5
  21. package/src/billing/subscription.ts +0 -65
  22. package/src/common/entity.ts +0 -9
  23. package/src/common/index.ts +0 -2
  24. package/src/common/object-meta.ts +0 -8
  25. package/src/custom-domains/custom-domains.ts +0 -24
  26. package/src/custom-domains/index.ts +0 -1
  27. package/src/data-dumps/code-integration-dump.ts +0 -19
  28. package/src/data-dumps/design-system-dump.ts +0 -16
  29. package/src/data-dumps/design-system-version-dump.ts +0 -45
  30. package/src/data-dumps/index.ts +0 -6
  31. package/src/data-dumps/published-docs-dump.ts +0 -10
  32. package/src/data-dumps/user-data-dump.ts +0 -10
  33. package/src/data-dumps/workspace-dump.ts +0 -14
  34. package/src/docs-server/index.ts +0 -1
  35. package/src/docs-server/session.ts +0 -39
  36. package/src/dsm/assets/asset-dynamo-record.ts +0 -10
  37. package/src/dsm/assets/asset-reference.ts +0 -18
  38. package/src/dsm/assets/asset-value.ts +0 -3
  39. package/src/dsm/assets/asset.ts +0 -60
  40. package/src/dsm/assets/index.ts +0 -4
  41. package/src/dsm/brand.ts +0 -13
  42. package/src/dsm/collection.ts +0 -51
  43. package/src/dsm/components/asset-rendering.ts +0 -22
  44. package/src/dsm/components/index.ts +0 -1
  45. package/src/dsm/data-sources/data-source.ts +0 -167
  46. package/src/dsm/data-sources/import-job.ts +0 -30
  47. package/src/dsm/data-sources/import-summary.ts +0 -70
  48. package/src/dsm/data-sources/index.ts +0 -3
  49. package/src/dsm/design-system.ts +0 -47
  50. package/src/dsm/documentation/approvals/approval-state.ts +0 -4
  51. package/src/dsm/documentation/approvals/approval.ts +0 -18
  52. package/src/dsm/documentation/approvals/index.ts +0 -2
  53. package/src/dsm/documentation/block-definitions/aux.ts +0 -10
  54. package/src/dsm/documentation/block-definitions/definition.ts +0 -76
  55. package/src/dsm/documentation/block-definitions/index.ts +0 -4
  56. package/src/dsm/documentation/block-definitions/item.ts +0 -233
  57. package/src/dsm/documentation/block-definitions/variant.ts +0 -49
  58. package/src/dsm/documentation/group.ts +0 -19
  59. package/src/dsm/documentation/index.ts +0 -10
  60. package/src/dsm/documentation/link-preview.ts +0 -10
  61. package/src/dsm/documentation/page-anchor.ts +0 -9
  62. package/src/dsm/documentation/page-content-backup.ts +0 -13
  63. package/src/dsm/documentation/page-content.ts +0 -32
  64. package/src/dsm/documentation/page.ts +0 -18
  65. package/src/dsm/documentation/settings.ts +0 -18
  66. package/src/dsm/documentation/thread.ts +0 -35
  67. package/src/dsm/element-snapshots/base.ts +0 -34
  68. package/src/dsm/element-snapshots/documentation-page-snapshot.ts +0 -29
  69. package/src/dsm/element-snapshots/group-snapshot.ts +0 -27
  70. package/src/dsm/element-snapshots/index.ts +0 -3
  71. package/src/dsm/elements/base.ts +0 -49
  72. package/src/dsm/elements/component-properties.ts +0 -63
  73. package/src/dsm/elements/data/base.ts +0 -18
  74. package/src/dsm/elements/data/blur.ts +0 -16
  75. package/src/dsm/elements/data/border-radius.ts +0 -16
  76. package/src/dsm/elements/data/border-width.ts +0 -16
  77. package/src/dsm/elements/data/border.ts +0 -21
  78. package/src/dsm/elements/data/color.ts +0 -13
  79. package/src/dsm/elements/data/component.ts +0 -30
  80. package/src/dsm/elements/data/dimension.ts +0 -15
  81. package/src/dsm/elements/data/documentation-block-v1.ts +0 -498
  82. package/src/dsm/elements/data/documentation-block-v2.ts +0 -429
  83. package/src/dsm/elements/data/documentation-page-v1.ts +0 -9
  84. package/src/dsm/elements/data/documentation-page-v2.ts +0 -7
  85. package/src/dsm/elements/data/documentation-section-v2.ts +0 -47
  86. package/src/dsm/elements/data/documentation-v1.ts +0 -16
  87. package/src/dsm/elements/data/documentation-v2.ts +0 -18
  88. package/src/dsm/elements/data/duration.ts +0 -16
  89. package/src/dsm/elements/data/figma-file-structure.ts +0 -65
  90. package/src/dsm/elements/data/figma-node-reference.ts +0 -27
  91. package/src/dsm/elements/data/font-family.ts +0 -8
  92. package/src/dsm/elements/data/font-size.ts +0 -16
  93. package/src/dsm/elements/data/font-weight.ts +0 -8
  94. package/src/dsm/elements/data/font.ts +0 -9
  95. package/src/dsm/elements/data/gradient.ts +0 -32
  96. package/src/dsm/elements/data/group.ts +0 -20
  97. package/src/dsm/elements/data/index.ts +0 -43
  98. package/src/dsm/elements/data/item-header-v1.ts +0 -35
  99. package/src/dsm/elements/data/item-header-v2.ts +0 -34
  100. package/src/dsm/elements/data/item-header.ts +0 -14
  101. package/src/dsm/elements/data/letter-spacing.ts +0 -16
  102. package/src/dsm/elements/data/line-height.ts +0 -16
  103. package/src/dsm/elements/data/opacity.ts +0 -13
  104. package/src/dsm/elements/data/paragraph-indent.ts +0 -16
  105. package/src/dsm/elements/data/paragraph-spacing.ts +0 -16
  106. package/src/dsm/elements/data/product-copy.ts +0 -8
  107. package/src/dsm/elements/data/safe-id.ts +0 -13
  108. package/src/dsm/elements/data/shadow.ts +0 -23
  109. package/src/dsm/elements/data/size.ts +0 -16
  110. package/src/dsm/elements/data/space.ts +0 -16
  111. package/src/dsm/elements/data/string.ts +0 -8
  112. package/src/dsm/elements/data/text-case.ts +0 -10
  113. package/src/dsm/elements/data/text-decoration.ts +0 -10
  114. package/src/dsm/elements/data/typography.ts +0 -28
  115. package/src/dsm/elements/data/visibility.ts +0 -10
  116. package/src/dsm/elements/data/z-index.ts +0 -16
  117. package/src/dsm/elements/documentation-page-v1.ts +0 -34
  118. package/src/dsm/elements/documentation-page-v2.ts +0 -21
  119. package/src/dsm/elements/figma-component.ts +0 -67
  120. package/src/dsm/elements/figma-file-structures.ts +0 -40
  121. package/src/dsm/elements/figma-node-reference.ts +0 -25
  122. package/src/dsm/elements/group.ts +0 -40
  123. package/src/dsm/elements/index.ts +0 -15
  124. package/src/dsm/elements/page-block-v2.ts +0 -25
  125. package/src/dsm/elements/primitives/index.ts +0 -2
  126. package/src/dsm/elements/primitives/point.ts +0 -8
  127. package/src/dsm/elements/primitives/size.ts +0 -28
  128. package/src/dsm/elements/raw-element.ts +0 -164
  129. package/src/dsm/elements/theme.ts +0 -76
  130. package/src/dsm/elements/tokens.ts +0 -311
  131. package/src/dsm/elements/utils.ts +0 -114
  132. package/src/dsm/exporter-property-values-collection.ts +0 -31
  133. package/src/dsm/import/asset.ts +0 -6
  134. package/src/dsm/import/base.ts +0 -24
  135. package/src/dsm/import/collection.ts +0 -16
  136. package/src/dsm/import/component.ts +0 -40
  137. package/src/dsm/import/data-source.ts +0 -9
  138. package/src/dsm/import/figma-frames.ts +0 -74
  139. package/src/dsm/import/image.ts +0 -87
  140. package/src/dsm/import/index.ts +0 -12
  141. package/src/dsm/import/origin.ts +0 -5
  142. package/src/dsm/import/support/figma-files.ts +0 -19
  143. package/src/dsm/import/support/import-context.ts +0 -94
  144. package/src/dsm/import/support/import-model-collections.ts +0 -50
  145. package/src/dsm/import/support/index.ts +0 -3
  146. package/src/dsm/import/theme.ts +0 -76
  147. package/src/dsm/import/tokens.ts +0 -50
  148. package/src/dsm/import/warning.ts +0 -38
  149. package/src/dsm/index.ts +0 -19
  150. package/src/dsm/membership/additions.ts +0 -13
  151. package/src/dsm/membership/design-system-membership.ts +0 -92
  152. package/src/dsm/membership/ds-role.ts +0 -28
  153. package/src/dsm/membership/index.ts +0 -4
  154. package/src/dsm/membership/invitations.ts +0 -21
  155. package/src/dsm/properties/index.ts +0 -3
  156. package/src/dsm/properties/property-definition.ts +0 -57
  157. package/src/dsm/properties/property-reference.ts +0 -5
  158. package/src/dsm/properties/property-value.ts +0 -29
  159. package/src/dsm/published-doc-page-visits.ts +0 -15
  160. package/src/dsm/published-doc-page.ts +0 -37
  161. package/src/dsm/published-doc.ts +0 -32
  162. package/src/dsm/reference.ts +0 -9
  163. package/src/dsm/version.ts +0 -41
  164. package/src/dsm/views/column.ts +0 -58
  165. package/src/dsm/views/index.ts +0 -2
  166. package/src/dsm/views/view.ts +0 -19
  167. package/src/emails/design-system-invite.ts +0 -31
  168. package/src/emails/index.ts +0 -2
  169. package/src/emails/workspace-invite.ts +0 -29
  170. package/src/events/base.ts +0 -7
  171. package/src/events/data-source-imported.ts +0 -9
  172. package/src/events/index.ts +0 -3
  173. package/src/events/version-released.ts +0 -10
  174. package/src/export/export-destinations.ts +0 -127
  175. package/src/export/export-jobs.ts +0 -122
  176. package/src/export/export-runner/export-context.ts +0 -34
  177. package/src/export/export-runner/exporter-payload.ts +0 -10
  178. package/src/export/export-runner/index.ts +0 -2
  179. package/src/export/exporter-workspace-membership-role.ts +0 -4
  180. package/src/export/exporter-workspace-membership.ts +0 -14
  181. package/src/export/exporter.ts +0 -55
  182. package/src/export/git-providers.ts +0 -11
  183. package/src/export/index.ts +0 -9
  184. package/src/export/pipeline.ts +0 -34
  185. package/src/export/pulsar.ts +0 -71
  186. package/src/feature-flags/feature-flags.ts +0 -21
  187. package/src/feature-flags/index.ts +0 -1
  188. package/src/helpers/db.ts +0 -82
  189. package/src/helpers/index.ts +0 -2
  190. package/src/helpers/nullish-to-optional.ts +0 -9
  191. package/src/index.ts +0 -20
  192. package/src/integrations/external-oauth-request.ts +0 -12
  193. package/src/integrations/git.ts +0 -49
  194. package/src/integrations/index.ts +0 -6
  195. package/src/integrations/integration.ts +0 -143
  196. package/src/integrations/oauth-providers.ts +0 -13
  197. package/src/integrations/oauth-token.ts +0 -16
  198. package/src/integrations/workspace-oauth-requests.ts +0 -12
  199. package/src/liveblocks/index.ts +0 -1
  200. package/src/liveblocks/rooms/design-system-version-room.ts +0 -62
  201. package/src/liveblocks/rooms/documentation-page-room.ts +0 -65
  202. package/src/liveblocks/rooms/index.ts +0 -4
  203. package/src/liveblocks/rooms/room-type.ts +0 -12
  204. package/src/liveblocks/rooms/workspace-room.ts +0 -16
  205. package/src/npm/index.ts +0 -2
  206. package/src/npm/npm-package.ts +0 -30
  207. package/src/npm/npm-proxy-token-payload.ts +0 -7
  208. package/src/tokens/index.ts +0 -1
  209. package/src/tokens/personal-access-token.ts +0 -25
  210. package/src/users/index.ts +0 -9
  211. package/src/users/linked-integrations.ts +0 -36
  212. package/src/users/user-analytics-cleanup-schedule.ts +0 -15
  213. package/src/users/user-identity.ts +0 -8
  214. package/src/users/user-minified.ts +0 -10
  215. package/src/users/user-notification-settings.ts +0 -18
  216. package/src/users/user-profile.ts +0 -41
  217. package/src/users/user-test.ts +0 -8
  218. package/src/users/user-with-pat.ts +0 -7
  219. package/src/users/user.ts +0 -21
  220. package/src/utils/common.ts +0 -172
  221. package/src/utils/content-loader-instruction.ts +0 -31
  222. package/src/utils/errors.ts +0 -120
  223. package/src/utils/index.ts +0 -6
  224. package/src/utils/naming.ts +0 -73
  225. package/src/utils/slugify.ts +0 -636
  226. package/src/utils/validation.ts +0 -4
  227. package/src/workspace/index.ts +0 -10
  228. package/src/workspace/npm-registry-settings.ts +0 -45
  229. package/src/workspace/sso-provider.ts +0 -13
  230. package/src/workspace/user-invite.ts +0 -18
  231. package/src/workspace/workspace-configuration.ts +0 -14
  232. package/src/workspace/workspace-context.ts +0 -13
  233. package/src/workspace/workspace-create.ts +0 -25
  234. package/src/workspace/workspace-invitations.ts +0 -22
  235. package/src/workspace/workspace-membership.ts +0 -31
  236. package/src/workspace/workspace-role.ts +0 -6
  237. package/src/workspace/workspace.ts +0 -62
@@ -1,114 +0,0 @@
1
- import { DocumentationPageContentItem, PageBlockDefinition, PageBlockDefinitionProperty } from "../documentation";
2
- import { PageBlockItemUntypedValue, PageBlockItemV2 } from "./data";
3
- import { PageBlockEditorModelV2 } from "./page-block-v2";
4
-
5
- //
6
- // Traverse
7
- //
8
-
9
- /**
10
- * Pay attention to correct types!
11
- */
12
- export function mapPageBlockItemValuesV2(
13
- pageItems: DocumentationPageContentItem[],
14
- definitionsMap: PageBlockDefinitionsMap,
15
- fn: (
16
- block: PageBlockEditorModelV2,
17
- item: PageBlockItemV2,
18
- property: PageBlockDefinitionProperty,
19
- value: PageBlockItemUntypedValue
20
- ) => PageBlockItemUntypedValue
21
- ) {
22
- traversePageBlockItemsV2(pageItems, (block, item) => {
23
- Object.entries(item.props).forEach(([propKey, value]) => {
24
- const property = definitionsMap.getDefinitionProperty(block.data.packageId, propKey);
25
- if (!property) return;
26
-
27
- item.props[propKey] = fn(block, item, property, value);
28
- });
29
- });
30
- }
31
-
32
- export function traversePageBlockItemValuesV2(
33
- pageItems: DocumentationPageContentItem[],
34
- definitionsMap: PageBlockDefinitionsMap,
35
- fn: (
36
- block: PageBlockEditorModelV2,
37
- item: PageBlockItemV2,
38
- property: PageBlockDefinitionProperty,
39
- value: PageBlockItemUntypedValue
40
- ) => void
41
- ) {
42
- traversePageBlockItemsV2(pageItems, (block, item) => {
43
- Object.entries(item.props).forEach(([propKey, value]) => {
44
- const property = definitionsMap.getDefinitionProperty(block.data.packageId, propKey);
45
- if (!property) return;
46
-
47
- fn(block, item, property, value);
48
- });
49
- });
50
- }
51
-
52
- export function traversePageBlockItemsV2(
53
- pageItems: DocumentationPageContentItem[],
54
- fn: (block: PageBlockEditorModelV2, item: PageBlockItemV2) => void
55
- ) {
56
- traversePageItemsV2(pageItems, block => {
57
- block.data.items.forEach(item => {
58
- fn(block, item);
59
- });
60
- });
61
- }
62
-
63
- export function traversePageItemsV2(
64
- pageItems: DocumentationPageContentItem[],
65
- fn: (item: PageBlockEditorModelV2) => void
66
- ): void {
67
- for (const item of pageItems) {
68
- switch (item.type) {
69
- case "Block":
70
- fn(item);
71
-
72
- break;
73
-
74
- case "Section":
75
- item.items.forEach(i => {
76
- i.columns.forEach(c => {
77
- traversePageItemsV2(c.blocks, fn);
78
- });
79
- });
80
-
81
- break;
82
- }
83
- }
84
- }
85
-
86
- //
87
- // Definitions map
88
- //
89
-
90
- export class PageBlockDefinitionsMap {
91
- private definitionsMap = new Map<string, PageBlockDefinition>();
92
- private propertiesMap = new Map<string, PageBlockDefinitionProperty>();
93
-
94
- constructor(definitions: PageBlockDefinition[]) {
95
- definitions.forEach(d => {
96
- this.definitionsMap.set(d.id, d);
97
- d.item.properties.forEach(p => {
98
- this.propertiesMap.set(this.propertyKey(d.id, p.id), p);
99
- });
100
- });
101
- }
102
-
103
- getDefinition(id: string): PageBlockDefinition | undefined {
104
- return this.definitionsMap.get(id);
105
- }
106
-
107
- getDefinitionProperty(defId: string, propId: string): PageBlockDefinitionProperty | undefined {
108
- return this.propertiesMap.get(this.propertyKey(defId, propId));
109
- }
110
-
111
- private propertyKey(defId: string, propId: string): string {
112
- return `${defId}.${propId}`;
113
- }
114
- }
@@ -1,31 +0,0 @@
1
- import { z } from "zod";
2
- import { ColorTokenData, PageBlockAsset, TypographyTokenData } from "./elements";
3
-
4
- export const ExporterPropertyImageValue = z.object({
5
- asset: PageBlockAsset.optional(),
6
- assetId: z.string().optional(),
7
- assetUrl: z.string().optional(),
8
- });
9
-
10
- export const ExporterPropertyValue = z.object({
11
- key: z.string(),
12
- value: z.union([
13
- z.number(),
14
- z.string(),
15
- z.boolean(),
16
- ExporterPropertyImageValue,
17
- ColorTokenData,
18
- TypographyTokenData,
19
- ]),
20
- });
21
-
22
- export const ExporterPropertyValuesCollection = z.object({
23
- id: z.string(),
24
- designSystemId: z.string(),
25
- exporterId: z.string(),
26
- values: z.array(ExporterPropertyValue),
27
- });
28
-
29
- export type ExporterPropertyImageValue = z.infer<typeof ExporterPropertyImageValue>;
30
- export type ExporterPropertyValue = z.infer<typeof ExporterPropertyValue>;
31
- export type ExporterPropertyValuesCollection = z.infer<typeof ExporterPropertyValuesCollection>;
@@ -1,6 +0,0 @@
1
- import { FigmaComponentImportModelInput } from "./component";
2
- import { FigmaSvgRenderImportModel } from "./image";
3
-
4
- export type AssetImportModel = FigmaComponentImportModelInput & {
5
- svg: FigmaSvgRenderImportModel;
6
- };
@@ -1,24 +0,0 @@
1
- import { z } from "zod";
2
- import { DesignElementOrigin } from "../elements";
3
- import { ObjectMeta } from "../../common";
4
-
5
- export const ImportModelBase = z.object({
6
- id: z.string(),
7
- meta: ObjectMeta,
8
- origin: DesignElementOrigin,
9
- brandPersistentId: z.string(),
10
- sortOrder: z.number(),
11
- });
12
-
13
- export type ImportModelBase = z.infer<typeof ImportModelBase>;
14
-
15
- export const ImportModelInputBase = ImportModelBase.omit({
16
- brandPersistentId: true,
17
- origin: true,
18
- sortOrder: true,
19
- }).extend({
20
- originId: z.string(),
21
- originMetadata: z.record(z.any()),
22
- });
23
-
24
- export type ImportModelInputBase = z.infer<typeof ImportModelInputBase>;
@@ -1,16 +0,0 @@
1
- import { z } from "zod";
2
- import { CollectionOrigin } from "../collection";
3
-
4
- export const CollectionImportModelInput = z.object({
5
- id: z.string(),
6
- name: z.string(),
7
- });
8
-
9
- export const CollectionImportModel = z.object({
10
- id: z.string(),
11
- name: z.string(),
12
- origin: CollectionOrigin,
13
- });
14
-
15
- export type CollectionImportModelInput = z.infer<typeof CollectionImportModelInput>;
16
- export type CollectionImportModel = z.infer<typeof CollectionImportModel>;
@@ -1,40 +0,0 @@
1
- import { z } from "zod";
2
- import { FigmaComponentOrigin, FigmaComponentOriginPart, FigmaComponentPropertyMap } from "../elements";
3
- import { ImportModelBase, ImportModelInputBase } from "./base";
4
- import { FigmaSvgRenderImportModel, ImageImportModel } from "./image";
5
-
6
- //
7
- // Import model
8
- //
9
-
10
- const FigmaComponentImportModelPart = z.object({
11
- thumbnail: ImageImportModel,
12
- parentComponentId: z.string().optional(),
13
- componentPropertyDefinitions: FigmaComponentPropertyMap.optional(),
14
- variantPropertyValues: z.record(z.string()).optional(),
15
- renderNodeId: z.string(),
16
- });
17
-
18
- export const FigmaComponentImportModel = ImportModelBase.extend(FigmaComponentImportModelPart.shape).extend({
19
- isAsset: z.boolean(),
20
- svg: FigmaSvgRenderImportModel.optional(),
21
- origin: FigmaComponentOrigin,
22
- });
23
-
24
- export type FigmaComponentImportModel = z.infer<typeof FigmaComponentImportModel>;
25
-
26
- //
27
- // Import model input
28
- //
29
-
30
- export const FigmaComponentImportModelInput = ImportModelInputBase.extend(FigmaComponentImportModelPart.shape).extend({
31
- originMetadata: FigmaComponentOriginPart,
32
- });
33
-
34
- export const AssetImportModelInput = ImportModelInputBase.extend(FigmaComponentImportModelPart.shape).extend({
35
- svg: FigmaSvgRenderImportModel,
36
- originMetadata: FigmaComponentOriginPart,
37
- });
38
-
39
- export type FigmaComponentImportModelInput = z.infer<typeof FigmaComponentImportModelInput>;
40
- export type AssetImportModelInput = z.infer<typeof AssetImportModelInput>;
@@ -1,9 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const DataSourceImportModel = z.object({
4
- id: z.string(),
5
- fileName: z.string().optional(),
6
- thumbnailUrl: z.string().optional(),
7
- });
8
-
9
- export type DataSourceImportModel = z.infer<typeof DataSourceImportModel>;
@@ -1,74 +0,0 @@
1
- import { ZodTypeDef, z } from "zod";
2
- import { FigmaFileStructureNodeBase, FigmaFileStructureOrigin, FigmaFileStructureStatistics } from "../elements";
3
- import { ImportModelBase, ImportModelInputBase } from "./base";
4
- import { FigmaPngRenderImportModel, FigmaSvgRenderImportModel } from "./image";
5
-
6
- //
7
- // Nodes Import Model
8
- //
9
-
10
- const FigmaFileStructureNodeImportModelBase = FigmaFileStructureNodeBase.extend({
11
- png: FigmaPngRenderImportModel,
12
- svg: FigmaSvgRenderImportModel,
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
- }
@@ -1,87 +0,0 @@
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.string(),
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", "Pdf"]);
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>;
73
-
74
- //
75
- // Utils
76
- //
77
-
78
- export function getFigmaRenderFormatFileExtension(format: FigmaRenderFormat): string {
79
- switch (format) {
80
- case "Pdf":
81
- return "pdf";
82
- case "Png":
83
- return "png";
84
- case "Svg":
85
- return "svg";
86
- }
87
- }
@@ -1,12 +0,0 @@
1
- export * from "./support";
2
- export * from "./asset";
3
- export * from "./base";
4
- export * from "./collection";
5
- export * from "./component";
6
- export * from "./data-source";
7
- export * from "./figma-frames";
8
- export * from "./image";
9
- export * from "./origin";
10
- export * from "./theme";
11
- export * from "./tokens";
12
- export * from "./warning";
@@ -1,5 +0,0 @@
1
- export type DesignElementOriginImportModel = {
2
- id: string;
3
- name: string;
4
- sourceId: string;
5
- };
@@ -1,19 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const FigmaFileDownloadScope = z.object({
4
- styles: z.boolean(),
5
- components: z.boolean(),
6
- componentSets: z.boolean(),
7
- currentVersion: z.literal("__latest__").nullable(),
8
- publishedVersion: z.string().nullable(),
9
- downloadChunkSize: z.number().optional(),
10
- maxFileDepth: z.number().optional(),
11
- });
12
-
13
- export const FigmaFileAccessData = z.object({
14
- accessToken: z.string(),
15
- accessTokenType: z.enum(["OAuth2", "PAT"]).default("OAuth2"),
16
- });
17
-
18
- export type FigmaFileDownloadScope = z.infer<typeof FigmaFileDownloadScope>;
19
- export type FigmaFileAccessData = z.infer<typeof FigmaFileAccessData>;
@@ -1,94 +0,0 @@
1
- import { z } from "zod";
2
- import { DataSourceFigmaImportMetadata, DataSourceFigmaRemote } from "../../data-sources";
3
- import { ImportWarning } from "../warning";
4
- import { FigmaFileAccessData, FigmaFileDownloadScope } from "./figma-files";
5
-
6
- //
7
- // Importer payload
8
- //
9
-
10
- export const ImportFunctionInput = z.object({
11
- importJobId: z.string(),
12
- importContextId: z.string(),
13
- designSystemId: z.string().optional(),
14
- });
15
-
16
- export type ImportFunctionInput = z.infer<typeof ImportFunctionInput>;
17
-
18
- //
19
- // Base context
20
- //
21
-
22
- export const ImportedFigmaSourceData = z.object({
23
- sourceId: z.string(),
24
- figmaRemote: DataSourceFigmaRemote,
25
- });
26
-
27
- export const FigmaImportBaseContext = z.object({
28
- designSystemId: z.string(),
29
-
30
- /**
31
- * Data required for accessing Figma files. This should contain access data for all file ids
32
- * mentioned in the `importedSourceDataBySourceId`
33
- *
34
- * fileId: file data
35
- */
36
- fileAccessByFileId: z.record(FigmaFileAccessData),
37
-
38
- /**
39
- * Figma source data for which import was requested
40
- *
41
- * sourceId: source data
42
- */
43
- importedSourceDataBySourceId: z.record(ImportedFigmaSourceData),
44
-
45
- /**
46
- * Array of warnings that will be written into the import result summary at the end
47
- * of import job execution and displayed by the client.
48
- */
49
- importWarnings: z.record(ImportWarning.array()).default({}),
50
- });
51
-
52
- export type ImportedFigmaSourceData = z.infer<typeof ImportedFigmaSourceData>;
53
- export type FigmaImportBaseContext = z.infer<typeof FigmaImportBaseContext>;
54
-
55
- //
56
- // Context with source state updates
57
- //
58
-
59
- export const FigmaImportContextWithSourcesState = FigmaImportBaseContext.extend({
60
- sourcesWithMissingAccess: z.array(z.string()).default([]),
61
- shadowOpacityOptional: z.boolean().default(false),
62
- typographyPropsKeepAliases: z.boolean().default(false),
63
- });
64
-
65
- export type FigmaImportContextWithSourcesState = z.infer<typeof FigmaImportContextWithSourcesState>;
66
-
67
- //
68
- // Context with file download scope
69
- //
70
-
71
- export const ChangedImportedFigmaSourceData = ImportedFigmaSourceData.extend({
72
- importMetadata: DataSourceFigmaImportMetadata,
73
- });
74
-
75
- export const FigmaImportContextWithDownloadScopes = FigmaImportContextWithSourcesState.extend({
76
- /**
77
- * Describes what to download from each file, this should contain all file id mentioned in
78
- * importMetadataBySourceId.
79
- *
80
- * File id -> file download scope
81
- */
82
- fileDownloadScopesByFileId: z.record(FigmaFileDownloadScope),
83
-
84
- /**
85
- * Sources filtered down to the ones that have changed since last import and therefore need to be
86
- * imported again.
87
- *
88
- * Source id -> import metadata
89
- */
90
- changedImportedSourceDataBySourceId: z.record(ChangedImportedFigmaSourceData),
91
- });
92
-
93
- export type ChangedImportedFigmaSourceData = z.infer<typeof ChangedImportedFigmaSourceData>;
94
- export type FigmaImportContextWithDownloadScopes = z.infer<typeof FigmaImportContextWithDownloadScopes>;
@@ -1,50 +0,0 @@
1
- import { z } from "zod";
2
- import { CollectionImportModel, CollectionImportModelInput } from "../collection";
3
- import { AssetImportModelInput, FigmaComponentImportModel, FigmaComponentImportModelInput } from "../component";
4
- import { DataSourceImportModel } from "../data-source";
5
- import { FigmaFileStructureImportModel, FigmaFileStructureImportModelInput } from "../figma-frames";
6
- import { ThemeImportModel, ThemeImportModelInput, ThemeUpdateImportModel, ThemeUpdateImportModelInput } from "../theme";
7
- import { DesignTokenImportModel, DesignTokenImportModelInput } from "../tokens";
8
-
9
- //
10
- // Collections
11
- //
12
-
13
- export const ImportModelInputCollection = z.object({
14
- source: DataSourceImportModel,
15
- tokens: z.array(DesignTokenImportModelInput).default([]),
16
- components: z.array(FigmaComponentImportModelInput).default([]),
17
- assets: z.array(AssetImportModelInput).default([]),
18
- themeUpdates: z.array(ThemeUpdateImportModelInput).default([]),
19
- themes: z.array(ThemeImportModelInput).default([]),
20
- figmaFileStructure: FigmaFileStructureImportModelInput.optional(),
21
- collections: z.array(CollectionImportModelInput),
22
- });
23
-
24
- export const ImportModelCollection = z.object({
25
- sources: z.array(DataSourceImportModel),
26
- tokens: z.array(DesignTokenImportModel).default([]),
27
- components: z.array(FigmaComponentImportModel).default([]),
28
- themeUpdates: z.array(ThemeUpdateImportModel).default([]),
29
- themes: z.array(ThemeImportModel).default([]),
30
- figmaFileStructures: z.array(FigmaFileStructureImportModel),
31
- collections: z.array(CollectionImportModel),
32
- });
33
-
34
- export type ImportModelCollection = z.infer<typeof ImportModelCollection>;
35
- export type ImportModelInputCollection = z.infer<typeof ImportModelInputCollection>;
36
-
37
- export function addImportModelCollections(
38
- lhs: ImportModelCollection,
39
- rhs: ImportModelCollection
40
- ): ImportModelCollection {
41
- return {
42
- sources: [...lhs.sources, ...rhs.sources],
43
- tokens: [...lhs.tokens, ...rhs.tokens],
44
- components: [...lhs.components, ...rhs.components],
45
- themeUpdates: [...lhs.themeUpdates, ...rhs.themeUpdates],
46
- themes: [...lhs.themes, ...rhs.themes],
47
- figmaFileStructures: [...lhs.figmaFileStructures, ...rhs.figmaFileStructures],
48
- collections: [...lhs.collections, ...rhs.collections],
49
- };
50
- }
@@ -1,3 +0,0 @@
1
- export * from "./figma-files";
2
- export * from "./import-context";
3
- export * from "./import-model-collections";
@@ -1,76 +0,0 @@
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>;