@supernova-studio/model 0.47.46 → 0.47.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -456,8 +456,141 @@ function isImportedAsset(asset) {
456
456
  // src/dsm/data-sources/data-source.ts
457
457
 
458
458
 
459
- // src/dsm/data-sources/import-summary.ts
459
+ // src/dsm/import/support/figma-files.ts
460
+
461
+ var FigmaFileDownloadScope = _zod.z.object({
462
+ styles: _zod.z.boolean(),
463
+ components: _zod.z.boolean(),
464
+ currentVersion: _zod.z.literal("__latest__").nullable(),
465
+ publishedVersion: _zod.z.string().nullable(),
466
+ downloadChunkSize: _zod.z.number().optional(),
467
+ maxFileDepth: _zod.z.number().optional()
468
+ });
469
+ var FigmaFileAccessData = _zod.z.object({
470
+ accessToken: _zod.z.string()
471
+ });
472
+
473
+ // src/dsm/import/support/import-context.ts
474
+
475
+
476
+ // src/dsm/import/warning.ts
477
+
478
+ var ImportWarningType = _zod.z.enum([
479
+ "NoVersionFound",
480
+ "UnsupportedFill",
481
+ "UnsupportedStroke",
482
+ "UnsupportedEffect",
483
+ "NoPublishedElements",
484
+ "NoPublishedStyles",
485
+ "NoPublishedComponents",
486
+ "NoPublishedAssets",
487
+ "StyleNotApplied",
488
+ "ComponentHasNoThumbnail",
489
+ "DuplicateImportedStyleId",
490
+ "DuplicateImportedStylePath",
491
+ "NoUnpublishedStyles",
492
+ "ReferenceResolutionFailed"
493
+ ]);
494
+ var ImportWarning = _zod.z.object({
495
+ warningType: ImportWarningType,
496
+ componentId: _zod.z.string().optional(),
497
+ componentName: _zod.z.string().optional(),
498
+ styleId: _zod.z.string().optional(),
499
+ styleName: _zod.z.string().optional(),
500
+ unsupportedStyleValueType: _zod.z.string().optional(),
501
+ referenceId: _zod.z.string().optional()
502
+ });
503
+
504
+ // src/dsm/import/support/import-context.ts
505
+ var ImportFunctionInput = _zod.z.object({
506
+ importJobId: _zod.z.string(),
507
+ importContextId: _zod.z.string(),
508
+ designSystemId: _zod.z.string().optional()
509
+ });
510
+ var ImportedFigmaSourceData = _zod.z.object({
511
+ sourceId: _zod.z.string(),
512
+ figmaRemote: DataSourceFigmaRemote
513
+ });
514
+ var FigmaImportBaseContext = _zod.z.object({
515
+ designSystemId: _zod.z.string(),
516
+ /**
517
+ * Data required for accessing Figma files. This should contain access data for all file ids
518
+ * mentioned in the `importedSourceDataBySourceId`
519
+ *
520
+ * fileId: file data
521
+ */
522
+ fileAccessByFileId: _zod.z.record(FigmaFileAccessData),
523
+ /**
524
+ * Figma source data for which import was requested
525
+ *
526
+ * sourceId: source data
527
+ */
528
+ importedSourceDataBySourceId: _zod.z.record(ImportedFigmaSourceData),
529
+ /**
530
+ * Array of warnings that will be written into the import result summary at the end
531
+ * of import job execution and displayed by the client.
532
+ */
533
+ importWarnings: _zod.z.record(ImportWarning.array()).default({})
534
+ });
535
+ var FigmaImportContextWithSourcesState = FigmaImportBaseContext.extend({
536
+ sourcesWithMissingAccess: _zod.z.array(_zod.z.string()).default([]),
537
+ shadowOpacityOptional: _zod.z.boolean().default(false)
538
+ });
539
+ var ChangedImportedFigmaSourceData = ImportedFigmaSourceData.extend({
540
+ importMetadata: DataSourceFigmaImportMetadata
541
+ });
542
+ var FigmaImportContextWithDownloadScopes = FigmaImportContextWithSourcesState.extend({
543
+ /**
544
+ * Describes what to download from each file, this should contain all file id mentioned in
545
+ * importMetadataBySourceId.
546
+ *
547
+ * File id -> file download scope
548
+ */
549
+ fileDownloadScopesByFileId: _zod.z.record(FigmaFileDownloadScope),
550
+ /**
551
+ * Sources filtered down to the ones that have changed since last import and therefore need to be
552
+ * imported again.
553
+ *
554
+ * Source id -> import metadata
555
+ */
556
+ changedImportedSourceDataBySourceId: _zod.z.record(ChangedImportedFigmaSourceData)
557
+ });
460
558
 
559
+ // src/dsm/import/support/import-model-collections.ts
560
+
561
+
562
+ // src/dsm/import/image.ts
563
+
564
+ var ImageImportModelType = _zod.z.enum(["Url", "FigmaRender"]);
565
+ var ImageImportModelBase = _zod.z.object({
566
+ scope: AssetScope
567
+ });
568
+ var UrlImageImportModel = ImageImportModelBase.extend({
569
+ type: _zod.z.literal(ImageImportModelType.enum.Url),
570
+ url: _zod.z.string(),
571
+ originKey: _zod.z.string(),
572
+ extension: _zod.z.string()
573
+ });
574
+ var FigmaRenderFormat = _zod.z.enum(["Svg", "Png"]);
575
+ var FigmaRenderBase = ImageImportModelBase.extend({
576
+ type: _zod.z.literal(ImageImportModelType.enum.FigmaRender),
577
+ fileId: _zod.z.string(),
578
+ fileVersionId: _zod.z.string().optional(),
579
+ nodeId: _zod.z.string(),
580
+ originKey: _zod.z.string()
581
+ });
582
+ var FigmaPngRenderImportModel = FigmaRenderBase.extend({
583
+ format: _zod.z.literal(FigmaRenderFormat.enum.Png),
584
+ scale: _zod.z.number()
585
+ });
586
+ var FigmaSvgRenderImportModel = FigmaRenderBase.extend({
587
+ format: _zod.z.literal(FigmaRenderFormat.enum.Svg)
588
+ });
589
+ var FigmaRenderImportModel = _zod.z.discriminatedUnion("format", [
590
+ FigmaPngRenderImportModel,
591
+ FigmaSvgRenderImportModel
592
+ ]);
593
+ var ImageImportModel = _zod.z.union([UrlImageImportModel, FigmaRenderImportModel]);
461
594
 
462
595
  // src/dsm/elements/data/base.ts
463
596
 
@@ -1731,7 +1864,9 @@ var FigmaNodeReference = DesignElementBase.extend({
1731
1864
 
1732
1865
  var DesignTokenOriginPart = _zod.z.object({
1733
1866
  referenceOriginId: _zod.z.string().optional(),
1734
- referencePersistentId: _zod.z.string().optional()
1867
+ referencePersistentId: _zod.z.string().optional(),
1868
+ referenceResolutionFailed: _zod.z.boolean().optional(),
1869
+ key: _zod.z.string().optional()
1735
1870
  });
1736
1871
  var DesignTokenOrigin = DesignElementOrigin.extend(DesignTokenOriginPart.shape);
1737
1872
  var DesignTokenBase = DesignElementBase.extend(DesignElementGroupableRequiredPart.shape).extend(DesignElementBrandedPart.shape).extend({
@@ -1991,114 +2126,258 @@ var PageBlockDefinitionsMap = class {
1991
2126
  }
1992
2127
  };
1993
2128
 
1994
- // src/dsm/import/warning.ts
2129
+ // src/dsm/import/component.ts
1995
2130
 
1996
- var ImportWarningType = _zod.z.enum([
1997
- "NoVersionFound",
1998
- "UnsupportedFill",
1999
- "UnsupportedStroke",
2000
- "UnsupportedEffect",
2001
- "NoPublishedElements",
2002
- "NoPublishedStyles",
2003
- "NoPublishedComponents",
2004
- "NoPublishedAssets",
2005
- "StyleNotApplied",
2006
- "ComponentHasNoThumbnail",
2007
- "DuplicateImportedStyleId",
2008
- "DuplicateImportedStylePath",
2009
- "NoUnpublishedStyles"
2010
- ]);
2011
- var ImportWarning = _zod.z.object({
2012
- warningType: ImportWarningType,
2013
- componentId: _zod.z.string().optional(),
2014
- componentName: _zod.z.string().optional(),
2015
- styleId: _zod.z.string().optional(),
2016
- styleName: _zod.z.string().optional(),
2017
- unsupportedStyleValueType: _zod.z.string().optional()
2018
- });
2019
2131
 
2020
- // src/dsm/data-sources/import-summary.ts
2021
- var FileStructureStats = _zod.z.object({
2022
- frames: zeroNumberByDefault(),
2023
- components: zeroNumberByDefault(),
2024
- componentSets: zeroNumberByDefault()
2025
- });
2026
- var SourceImportSummaryByTokenTypeKey = DesignTokenType.or(
2027
- // Backward compatibility
2028
- _zod.z.enum(["Measure", "Radius", "GenericToken", "Font", "Text"])
2029
- );
2030
- var SourceImportSummaryByTokenType = _zod.z.record(SourceImportSummaryByTokenTypeKey, _zod.z.number());
2031
- var SourceImportTokenSummary = _zod.z.object({
2032
- tokensCreated: zeroNumberByDefault(),
2033
- tokensUpdated: zeroNumberByDefault(),
2034
- tokensDeleted: zeroNumberByDefault(),
2035
- tokensCreatedPerType: SourceImportSummaryByTokenType.nullish().transform((v) => _nullishCoalesce(v, () => ( {}))),
2036
- tokensUpdatedPerType: SourceImportSummaryByTokenType.nullish().transform((v) => _nullishCoalesce(v, () => ( {}))),
2037
- tokensDeletedPerType: SourceImportSummaryByTokenType.nullish().transform((v) => _nullishCoalesce(v, () => ( {})))
2038
- });
2039
- var SourceImportComponentSummary = _zod.z.object({
2040
- componentsCreated: zeroNumberByDefault(),
2041
- componentsUpdated: zeroNumberByDefault(),
2042
- componentsDeleted: zeroNumberByDefault(),
2043
- componentAssetsCreated: zeroNumberByDefault(),
2044
- componentAssetsUpdated: zeroNumberByDefault(),
2045
- componentAssetsDeleted: zeroNumberByDefault()
2046
- });
2047
- var SourceImportFrameSummary = _zod.z.object({
2048
- assetsInFile: nullishToOptional(FileStructureStats.optional()),
2049
- invalidReferencesCount: nullishToOptional(_zod.z.number().optional())
2132
+ // src/dsm/import/base.ts
2133
+
2134
+ var ImportModelBase = _zod.z.object({
2135
+ id: _zod.z.string(),
2136
+ meta: ObjectMeta,
2137
+ origin: DesignElementOrigin,
2138
+ brandPersistentId: _zod.z.string(),
2139
+ sortOrder: _zod.z.number()
2050
2140
  });
2051
- var SourceImportSummary = _zod.z.object({
2052
- sourceId: nullishToOptional(_zod.z.string()),
2053
- brandId: nullishToOptional(_zod.z.string()),
2054
- versionId: nullishToOptional(_zod.z.string()),
2055
- error: nullishToOptional(_zod.z.any()),
2056
- isFailed: _zod.z.boolean(),
2057
- warnings: _zod.z.array(ImportWarning).nullish().transform((v) => _nullishCoalesce(v, () => ( []))),
2058
- ...SourceImportTokenSummary.shape,
2059
- ...SourceImportComponentSummary.shape,
2060
- ...FileStructureStats.shape
2141
+ var ImportModelInputBase = ImportModelBase.omit({
2142
+ brandPersistentId: true,
2143
+ origin: true,
2144
+ sortOrder: true
2145
+ }).extend({
2146
+ originId: _zod.z.string(),
2147
+ originMetadata: _zod.z.record(_zod.z.any())
2061
2148
  });
2062
- function zeroNumberByDefault() {
2063
- return _zod.z.number().nullish().transform((v) => _nullishCoalesce(v, () => ( 0)));
2064
- }
2065
2149
 
2066
- // src/dsm/data-sources/data-source.ts
2067
- var DataSourceRemoteType = _zod.z.enum(["Figma", "TokenStudio", "FigmaVariablesPlugin"]);
2068
- var DataSourceUploadRemoteSource = _zod.z.enum(["TokenStudio", "FigmaVariablesPlugin", "Custom"]);
2069
- var DataSourceFigmaState = _zod.z.enum(["Active", "MissingIntegration", "MissingFileAccess", "MissingFileOwner"]);
2070
- var DataSourceAutoImportMode = _zod.z.enum(["Never", "Hourly"]);
2071
- var DataSourceStats = _zod.z.object({
2072
- tokens: zeroNumberByDefault2(),
2073
- components: zeroNumberByDefault2(),
2074
- assets: zeroNumberByDefault2(),
2075
- frames: zeroNumberByDefault2()
2076
- });
2077
- var DataSourceFigmaFileData = _zod.z.object({
2078
- lastUpdatedAt: _zod.z.coerce.date()
2150
+ // src/dsm/import/component.ts
2151
+ var ComponentImportModelPart = _zod.z.object({
2152
+ thumbnail: ImageImportModel
2079
2153
  });
2080
- var DataSourceFigmaFileVersionData = _zod.z.object({
2081
- id: _zod.z.string(),
2082
- label: _zod.z.string().optional(),
2083
- description: _zod.z.string().optional(),
2084
- createdAt: _zod.z.coerce.date()
2154
+ var ComponentImportModel = ImportModelBase.extend(ComponentImportModelPart.shape).extend({
2155
+ isAsset: _zod.z.boolean(),
2156
+ svg: FigmaSvgRenderImportModel.optional(),
2157
+ origin: ComponentOrigin
2085
2158
  });
2086
- var DataSourceFigmaScope = _zod.z.object({
2087
- assets: _zod.z.boolean(),
2088
- components: _zod.z.boolean(),
2089
- documentationFrames: _zod.z.boolean(),
2090
- tokens: _zod.z.boolean(),
2091
- themePersistentId: _zod.z.string().optional(),
2092
- isUnpublishedContentFallbackEnabled: _zod.z.boolean()
2159
+ var ComponentImportModelInput = ImportModelInputBase.extend(ComponentImportModelPart.shape).extend({
2160
+ originMetadata: ComponentOriginPart
2093
2161
  });
2094
- var DataSourceFigmaImportMetadata = _zod.z.object({
2095
- fileData: DataSourceFigmaFileData.optional(),
2096
- importedPublishedVersion: DataSourceFigmaFileVersionData.optional()
2162
+ var AssetImportModelInput = ImportModelInputBase.extend(ComponentImportModelPart.shape).extend({
2163
+ svg: FigmaSvgRenderImportModel,
2164
+ originMetadata: ComponentOriginPart
2097
2165
  });
2098
- var DataSourceFigmaRemote = _zod.z.object({
2099
- type: _zod.z.literal(DataSourceRemoteType.Enum.Figma),
2100
- fileId: _zod.z.string(),
2101
- preferredCredentialId: _zod.z.string().optional(),
2166
+
2167
+ // src/dsm/import/theme.ts
2168
+
2169
+ var ThemeOverrideImportModelBase = DesignTokenTypedData.and(
2170
+ _zod.z.object({
2171
+ id: _zod.z.string(),
2172
+ meta: ObjectMeta
2173
+ })
2174
+ );
2175
+ var ThemeOverrideImportModel = ThemeOverrideImportModelBase.and(
2176
+ _zod.z.object({
2177
+ origin: ThemeOverrideOrigin
2178
+ })
2179
+ );
2180
+ var ThemeOverrideImportModelInput = ThemeOverrideImportModelBase.and(
2181
+ _zod.z.object({
2182
+ originId: _zod.z.string(),
2183
+ originMetadata: ThemeOverrideOriginPart
2184
+ })
2185
+ );
2186
+ var ThemeImportModel = _zod.z.object({
2187
+ meta: ObjectMeta,
2188
+ brandPersistentId: _zod.z.string(),
2189
+ originSource: ThemeOriginSource,
2190
+ overrides: _zod.z.array(ThemeOverrideImportModel),
2191
+ sortOrder: _zod.z.number()
2192
+ });
2193
+ var ThemeImportModelInput = _zod.z.object({
2194
+ meta: ObjectMeta,
2195
+ originObjects: _zod.z.array(ThemeOriginObject),
2196
+ overrides: _zod.z.array(ThemeOverrideImportModelInput)
2197
+ });
2198
+ var ThemeUpdateImportModel = _zod.z.object({
2199
+ themePersistentId: _zod.z.string(),
2200
+ overrides: _zod.z.array(ThemeOverrideImportModel)
2201
+ });
2202
+ var ThemeUpdateImportModelInput = _zod.z.object({
2203
+ themePersistentId: _zod.z.string(),
2204
+ overrides: _zod.z.array(ThemeOverrideImportModelInput)
2205
+ });
2206
+
2207
+ // src/dsm/import/tokens.ts
2208
+
2209
+ var DesignTokenImportModelPart = _zod.z.object({
2210
+ collection: _zod.z.string().optional(),
2211
+ codeSyntax: _zod.z.record(_zod.z.coerce.string()).optional()
2212
+ });
2213
+ var DesignTokenImportModelBase = ImportModelBase.extend(DesignTokenImportModelPart.shape).extend({
2214
+ origin: DesignTokenOrigin
2215
+ });
2216
+ var DesignTokenImportModelInputBase = ImportModelInputBase.extend(DesignTokenImportModelPart.shape).extend({
2217
+ originMetadata: DesignTokenOriginPart
2218
+ });
2219
+ var DesignTokenImportModel = DesignTokenTypedData.and(DesignTokenImportModelBase);
2220
+ var DesignTokenImportModelInput = DesignTokenTypedData.and(DesignTokenImportModelInputBase);
2221
+ function isDesignTokenImportModelOfType(designToken, type) {
2222
+ return designToken.type === type;
2223
+ }
2224
+ function designTokenImportModelTypeFilter(type) {
2225
+ return (designToken) => isDesignTokenImportModelOfType(designToken, type);
2226
+ }
2227
+
2228
+ // src/dsm/import/figma-frames.ts
2229
+
2230
+ var FigmaFileStructureNodeImportModelBase = FigmaFileStructureNodeBase.extend({
2231
+ image: FigmaPngRenderImportModel
2232
+ });
2233
+ var FigmaFileStructureNodeImportModel = FigmaFileStructureNodeImportModelBase.extend({
2234
+ children: _zod.z.lazy(() => FigmaFileStructureNodeImportModel.array())
2235
+ });
2236
+ var FigmaFileStructureImportModelPart = _zod.z.object({
2237
+ data: _zod.z.object({
2238
+ rootNode: FigmaFileStructureNodeImportModel,
2239
+ assetsInFile: FigmaFileStructureStatistics
2240
+ })
2241
+ });
2242
+ var FigmaFileStructureImportModel = ImportModelBase.extend(FigmaFileStructureImportModelPart.shape).extend({
2243
+ origin: FigmaFileStructureOrigin
2244
+ });
2245
+ var FigmaFileStructureImportModelInput = ImportModelInputBase.extend(
2246
+ FigmaFileStructureImportModelPart.shape
2247
+ ).extend({
2248
+ fileVersionId: _zod.z.string()
2249
+ });
2250
+ function figmaFileStructureImportModelToMap(root) {
2251
+ const map = /* @__PURE__ */ new Map();
2252
+ recursiveFigmaFileStructureToMap2(root, map);
2253
+ return map;
2254
+ }
2255
+ function recursiveFigmaFileStructureToMap2(node, map) {
2256
+ map.set(node.id, node);
2257
+ for (const child of node.children)
2258
+ recursiveFigmaFileStructureToMap2(child, map);
2259
+ }
2260
+
2261
+ // src/dsm/import/data-source.ts
2262
+
2263
+ var DataSourceImportModel = _zod.z.object({
2264
+ id: _zod.z.string(),
2265
+ fileName: _zod.z.string().optional(),
2266
+ thumbnailUrl: _zod.z.string().optional()
2267
+ });
2268
+
2269
+ // src/dsm/import/support/import-model-collections.ts
2270
+ var ImportModelInputCollection = _zod.z.object({
2271
+ source: DataSourceImportModel,
2272
+ tokens: _zod.z.array(DesignTokenImportModelInput).default([]),
2273
+ components: _zod.z.array(ComponentImportModelInput).default([]),
2274
+ assets: _zod.z.array(AssetImportModelInput).default([]),
2275
+ themeUpdates: _zod.z.array(ThemeUpdateImportModelInput).default([]),
2276
+ themes: _zod.z.array(ThemeImportModelInput).default([]),
2277
+ figmaFileStructure: FigmaFileStructureImportModelInput.optional()
2278
+ });
2279
+ var ImportModelCollection = _zod.z.object({
2280
+ sources: _zod.z.array(DataSourceImportModel),
2281
+ tokens: _zod.z.array(DesignTokenImportModel).default([]),
2282
+ components: _zod.z.array(ComponentImportModel).default([]),
2283
+ themeUpdates: _zod.z.array(ThemeUpdateImportModel).default([]),
2284
+ themes: _zod.z.array(ThemeImportModel).default([]),
2285
+ figmaFileStructures: _zod.z.array(FigmaFileStructureImportModel)
2286
+ });
2287
+ function addImportModelCollections(lhs, rhs) {
2288
+ return {
2289
+ sources: [...lhs.sources, ...rhs.sources],
2290
+ tokens: [...lhs.tokens, ...rhs.tokens],
2291
+ components: [...lhs.components, ...rhs.components],
2292
+ themeUpdates: [...lhs.themeUpdates, ...rhs.themeUpdates],
2293
+ themes: [...lhs.themes, ...rhs.themes],
2294
+ figmaFileStructures: [...lhs.figmaFileStructures, ...rhs.figmaFileStructures]
2295
+ };
2296
+ }
2297
+
2298
+ // src/dsm/data-sources/import-summary.ts
2299
+
2300
+ var FileStructureStats = _zod.z.object({
2301
+ frames: zeroNumberByDefault(),
2302
+ components: zeroNumberByDefault(),
2303
+ componentSets: zeroNumberByDefault()
2304
+ });
2305
+ var SourceImportSummaryByTokenTypeKey = DesignTokenType.or(
2306
+ // Backward compatibility
2307
+ _zod.z.enum(["Measure", "Radius", "GenericToken", "Font", "Text"])
2308
+ );
2309
+ var SourceImportSummaryByTokenType = _zod.z.record(SourceImportSummaryByTokenTypeKey, _zod.z.number());
2310
+ var SourceImportTokenSummary = _zod.z.object({
2311
+ tokensCreated: zeroNumberByDefault(),
2312
+ tokensUpdated: zeroNumberByDefault(),
2313
+ tokensDeleted: zeroNumberByDefault(),
2314
+ tokensCreatedPerType: SourceImportSummaryByTokenType.nullish().transform((v) => _nullishCoalesce(v, () => ( {}))),
2315
+ tokensUpdatedPerType: SourceImportSummaryByTokenType.nullish().transform((v) => _nullishCoalesce(v, () => ( {}))),
2316
+ tokensDeletedPerType: SourceImportSummaryByTokenType.nullish().transform((v) => _nullishCoalesce(v, () => ( {})))
2317
+ });
2318
+ var SourceImportComponentSummary = _zod.z.object({
2319
+ componentsCreated: zeroNumberByDefault(),
2320
+ componentsUpdated: zeroNumberByDefault(),
2321
+ componentsDeleted: zeroNumberByDefault(),
2322
+ componentAssetsCreated: zeroNumberByDefault(),
2323
+ componentAssetsUpdated: zeroNumberByDefault(),
2324
+ componentAssetsDeleted: zeroNumberByDefault()
2325
+ });
2326
+ var SourceImportFrameSummary = _zod.z.object({
2327
+ assetsInFile: nullishToOptional(FileStructureStats.optional()),
2328
+ invalidReferencesCount: nullishToOptional(_zod.z.number().optional())
2329
+ });
2330
+ var SourceImportSummary = _zod.z.object({
2331
+ sourceId: nullishToOptional(_zod.z.string()),
2332
+ brandId: nullishToOptional(_zod.z.string()),
2333
+ versionId: nullishToOptional(_zod.z.string()),
2334
+ error: nullishToOptional(_zod.z.any()),
2335
+ isFailed: _zod.z.boolean(),
2336
+ warnings: _zod.z.array(ImportWarning).nullish().transform((v) => _nullishCoalesce(v, () => ( []))),
2337
+ ...SourceImportTokenSummary.shape,
2338
+ ...SourceImportComponentSummary.shape,
2339
+ ...FileStructureStats.shape
2340
+ });
2341
+ function zeroNumberByDefault() {
2342
+ return _zod.z.number().nullish().transform((v) => _nullishCoalesce(v, () => ( 0)));
2343
+ }
2344
+
2345
+ // src/dsm/data-sources/data-source.ts
2346
+ var DataSourceRemoteType = _zod.z.enum(["Figma", "TokenStudio", "FigmaVariablesPlugin"]);
2347
+ var DataSourceUploadRemoteSource = _zod.z.enum(["TokenStudio", "FigmaVariablesPlugin", "Custom"]);
2348
+ var DataSourceFigmaState = _zod.z.enum(["Active", "MissingIntegration", "MissingFileAccess", "MissingFileOwner"]);
2349
+ var DataSourceAutoImportMode = _zod.z.enum(["Never", "Hourly"]);
2350
+ var DataSourceStats = _zod.z.object({
2351
+ tokens: zeroNumberByDefault2(),
2352
+ components: zeroNumberByDefault2(),
2353
+ assets: zeroNumberByDefault2(),
2354
+ frames: zeroNumberByDefault2()
2355
+ });
2356
+ var DataSourceFigmaFileData = _zod.z.object({
2357
+ lastUpdatedAt: _zod.z.coerce.date()
2358
+ });
2359
+ var DataSourceFigmaFileVersionData = _zod.z.object({
2360
+ id: _zod.z.string(),
2361
+ label: _zod.z.string().optional(),
2362
+ description: _zod.z.string().optional(),
2363
+ createdAt: _zod.z.coerce.date()
2364
+ });
2365
+ var DataSourceFigmaScope = _zod.z.object({
2366
+ assets: _zod.z.boolean(),
2367
+ components: _zod.z.boolean(),
2368
+ documentationFrames: _zod.z.boolean(),
2369
+ tokens: _zod.z.boolean(),
2370
+ themePersistentId: _zod.z.string().optional(),
2371
+ isUnpublishedContentFallbackEnabled: _zod.z.boolean()
2372
+ });
2373
+ var DataSourceFigmaImportMetadata = _zod.z.object({
2374
+ fileData: DataSourceFigmaFileData.optional(),
2375
+ importedPublishedVersion: DataSourceFigmaFileVersionData.optional()
2376
+ });
2377
+ var DataSourceFigmaRemote = _zod.z.object({
2378
+ type: _zod.z.literal(DataSourceRemoteType.Enum.Figma),
2379
+ fileId: _zod.z.string(),
2380
+ preferredCredentialId: _zod.z.string().optional(),
2102
2381
  ownerId: _zod.z.string(),
2103
2382
  // todo remove or keep to reference who created data source
2104
2383
  ownerName: _zod.z.string(),
@@ -2119,7 +2398,8 @@ var DataSourceUploadRemote = _zod.z.object({
2119
2398
  type: _zod.z.literal(DataSourceRemoteType.Enum.FigmaVariablesPlugin),
2120
2399
  remoteId: _zod.z.string(),
2121
2400
  remoteSourceType: DataSourceUploadRemoteSource,
2122
- lastImportMetadata: DataSourceUploadImportMetadata.optional()
2401
+ lastImportMetadata: DataSourceUploadImportMetadata.optional(),
2402
+ warnings: nullishToOptional(ImportWarning.array())
2123
2403
  });
2124
2404
  var DataSourceRemote = _zod.z.discriminatedUnion("type", [
2125
2405
  DataSourceFigmaRemote,
@@ -2533,280 +2813,6 @@ var ElementGroupSnapshot = DesignElementSnapshotBase.extend({
2533
2813
  group: ElementGroup
2534
2814
  });
2535
2815
 
2536
- // src/dsm/import/support/figma-files.ts
2537
-
2538
- var FigmaFileDownloadScope = _zod.z.object({
2539
- styles: _zod.z.boolean(),
2540
- components: _zod.z.boolean(),
2541
- currentVersion: _zod.z.literal("__latest__").nullable(),
2542
- publishedVersion: _zod.z.string().nullable(),
2543
- downloadChunkSize: _zod.z.number().optional(),
2544
- maxFileDepth: _zod.z.number().optional()
2545
- });
2546
- var FigmaFileAccessData = _zod.z.object({
2547
- accessToken: _zod.z.string()
2548
- });
2549
-
2550
- // src/dsm/import/support/import-context.ts
2551
-
2552
- var ImportFunctionInput = _zod.z.object({
2553
- importJobId: _zod.z.string(),
2554
- importContextId: _zod.z.string(),
2555
- designSystemId: _zod.z.string().optional()
2556
- });
2557
- var ImportedFigmaSourceData = _zod.z.object({
2558
- sourceId: _zod.z.string(),
2559
- figmaRemote: DataSourceFigmaRemote
2560
- });
2561
- var FigmaImportBaseContext = _zod.z.object({
2562
- designSystemId: _zod.z.string(),
2563
- /**
2564
- * Data required for accessing Figma files. This should contain access data for all file ids
2565
- * mentioned in the `importedSourceDataBySourceId`
2566
- *
2567
- * fileId: file data
2568
- */
2569
- fileAccessByFileId: _zod.z.record(FigmaFileAccessData),
2570
- /**
2571
- * Figma source data for which import was requested
2572
- *
2573
- * sourceId: source data
2574
- */
2575
- importedSourceDataBySourceId: _zod.z.record(ImportedFigmaSourceData),
2576
- /**
2577
- * Array of warnings that will be written into the import result summary at the end
2578
- * of import job execution and displayed by the client.
2579
- */
2580
- importWarnings: _zod.z.record(ImportWarning.array()).default({})
2581
- });
2582
- var FigmaImportContextWithSourcesState = FigmaImportBaseContext.extend({
2583
- sourcesWithMissingAccess: _zod.z.array(_zod.z.string()).default([]),
2584
- shadowOpacityOptional: _zod.z.boolean().default(false)
2585
- });
2586
- var ChangedImportedFigmaSourceData = ImportedFigmaSourceData.extend({
2587
- importMetadata: DataSourceFigmaImportMetadata
2588
- });
2589
- var FigmaImportContextWithDownloadScopes = FigmaImportContextWithSourcesState.extend({
2590
- /**
2591
- * Describes what to download from each file, this should contain all file id mentioned in
2592
- * importMetadataBySourceId.
2593
- *
2594
- * File id -> file download scope
2595
- */
2596
- fileDownloadScopesByFileId: _zod.z.record(FigmaFileDownloadScope),
2597
- /**
2598
- * Sources filtered down to the ones that have changed since last import and therefore need to be
2599
- * imported again.
2600
- *
2601
- * Source id -> import metadata
2602
- */
2603
- changedImportedSourceDataBySourceId: _zod.z.record(ChangedImportedFigmaSourceData)
2604
- });
2605
-
2606
- // src/dsm/import/support/import-model-collections.ts
2607
-
2608
-
2609
- // src/dsm/import/image.ts
2610
-
2611
- var ImageImportModelType = _zod.z.enum(["Url", "FigmaRender"]);
2612
- var ImageImportModelBase = _zod.z.object({
2613
- scope: AssetScope
2614
- });
2615
- var UrlImageImportModel = ImageImportModelBase.extend({
2616
- type: _zod.z.literal(ImageImportModelType.enum.Url),
2617
- url: _zod.z.string(),
2618
- originKey: _zod.z.string(),
2619
- extension: _zod.z.string()
2620
- });
2621
- var FigmaRenderFormat = _zod.z.enum(["Svg", "Png"]);
2622
- var FigmaRenderBase = ImageImportModelBase.extend({
2623
- type: _zod.z.literal(ImageImportModelType.enum.FigmaRender),
2624
- fileId: _zod.z.string(),
2625
- fileVersionId: _zod.z.string().optional(),
2626
- nodeId: _zod.z.string(),
2627
- originKey: _zod.z.string()
2628
- });
2629
- var FigmaPngRenderImportModel = FigmaRenderBase.extend({
2630
- format: _zod.z.literal(FigmaRenderFormat.enum.Png),
2631
- scale: _zod.z.number()
2632
- });
2633
- var FigmaSvgRenderImportModel = FigmaRenderBase.extend({
2634
- format: _zod.z.literal(FigmaRenderFormat.enum.Svg)
2635
- });
2636
- var FigmaRenderImportModel = _zod.z.discriminatedUnion("format", [
2637
- FigmaPngRenderImportModel,
2638
- FigmaSvgRenderImportModel
2639
- ]);
2640
- var ImageImportModel = _zod.z.union([UrlImageImportModel, FigmaRenderImportModel]);
2641
-
2642
- // src/dsm/import/component.ts
2643
-
2644
-
2645
- // src/dsm/import/base.ts
2646
-
2647
- var ImportModelBase = _zod.z.object({
2648
- id: _zod.z.string(),
2649
- meta: ObjectMeta,
2650
- origin: DesignElementOrigin,
2651
- brandPersistentId: _zod.z.string(),
2652
- sortOrder: _zod.z.number()
2653
- });
2654
- var ImportModelInputBase = ImportModelBase.omit({
2655
- brandPersistentId: true,
2656
- origin: true,
2657
- sortOrder: true
2658
- }).extend({
2659
- originId: _zod.z.string(),
2660
- originMetadata: _zod.z.record(_zod.z.any())
2661
- });
2662
-
2663
- // src/dsm/import/component.ts
2664
- var ComponentImportModelPart = _zod.z.object({
2665
- thumbnail: ImageImportModel
2666
- });
2667
- var ComponentImportModel = ImportModelBase.extend(ComponentImportModelPart.shape).extend({
2668
- isAsset: _zod.z.boolean(),
2669
- svg: FigmaSvgRenderImportModel.optional(),
2670
- origin: ComponentOrigin
2671
- });
2672
- var ComponentImportModelInput = ImportModelInputBase.extend(ComponentImportModelPart.shape).extend({
2673
- originMetadata: ComponentOriginPart
2674
- });
2675
- var AssetImportModelInput = ImportModelInputBase.extend(ComponentImportModelPart.shape).extend({
2676
- svg: FigmaSvgRenderImportModel,
2677
- originMetadata: ComponentOriginPart
2678
- });
2679
-
2680
- // src/dsm/import/theme.ts
2681
-
2682
- var ThemeOverrideImportModelBase = DesignTokenTypedData.and(
2683
- _zod.z.object({
2684
- id: _zod.z.string(),
2685
- meta: ObjectMeta
2686
- })
2687
- );
2688
- var ThemeOverrideImportModel = ThemeOverrideImportModelBase.and(
2689
- _zod.z.object({
2690
- origin: ThemeOverrideOrigin
2691
- })
2692
- );
2693
- var ThemeOverrideImportModelInput = ThemeOverrideImportModelBase.and(
2694
- _zod.z.object({
2695
- originId: _zod.z.string(),
2696
- originMetadata: ThemeOverrideOriginPart
2697
- })
2698
- );
2699
- var ThemeImportModel = _zod.z.object({
2700
- meta: ObjectMeta,
2701
- brandPersistentId: _zod.z.string(),
2702
- originSource: ThemeOriginSource,
2703
- overrides: _zod.z.array(ThemeOverrideImportModel),
2704
- sortOrder: _zod.z.number()
2705
- });
2706
- var ThemeImportModelInput = _zod.z.object({
2707
- meta: ObjectMeta,
2708
- originObjects: _zod.z.array(ThemeOriginObject),
2709
- overrides: _zod.z.array(ThemeOverrideImportModelInput)
2710
- });
2711
- var ThemeUpdateImportModel = _zod.z.object({
2712
- themePersistentId: _zod.z.string(),
2713
- overrides: _zod.z.array(ThemeOverrideImportModel)
2714
- });
2715
- var ThemeUpdateImportModelInput = _zod.z.object({
2716
- themePersistentId: _zod.z.string(),
2717
- overrides: _zod.z.array(ThemeOverrideImportModelInput)
2718
- });
2719
-
2720
- // src/dsm/import/tokens.ts
2721
-
2722
- var DesignTokenImportModelPart = _zod.z.object({
2723
- collection: _zod.z.string().optional()
2724
- });
2725
- var DesignTokenImportModelBase = ImportModelBase.extend(DesignTokenImportModelPart.shape).extend({
2726
- origin: DesignTokenOrigin
2727
- });
2728
- var DesignTokenImportModelInputBase = ImportModelInputBase.extend(DesignTokenImportModelPart.shape).extend({
2729
- originMetadata: DesignTokenOriginPart
2730
- });
2731
- var DesignTokenImportModel = DesignTokenTypedData.and(DesignTokenImportModelBase);
2732
- var DesignTokenImportModelInput = DesignTokenTypedData.and(DesignTokenImportModelInputBase);
2733
- function isDesignTokenImportModelOfType(designToken, type) {
2734
- return designToken.type === type;
2735
- }
2736
- function designTokenImportModelTypeFilter(type) {
2737
- return (designToken) => isDesignTokenImportModelOfType(designToken, type);
2738
- }
2739
-
2740
- // src/dsm/import/figma-frames.ts
2741
-
2742
- var FigmaFileStructureNodeImportModelBase = FigmaFileStructureNodeBase.extend({
2743
- image: FigmaPngRenderImportModel
2744
- });
2745
- var FigmaFileStructureNodeImportModel = FigmaFileStructureNodeImportModelBase.extend({
2746
- children: _zod.z.lazy(() => FigmaFileStructureNodeImportModel.array())
2747
- });
2748
- var FigmaFileStructureImportModelPart = _zod.z.object({
2749
- data: _zod.z.object({
2750
- rootNode: FigmaFileStructureNodeImportModel,
2751
- assetsInFile: FigmaFileStructureStatistics
2752
- })
2753
- });
2754
- var FigmaFileStructureImportModel = ImportModelBase.extend(FigmaFileStructureImportModelPart.shape).extend({
2755
- origin: FigmaFileStructureOrigin
2756
- });
2757
- var FigmaFileStructureImportModelInput = ImportModelInputBase.extend(
2758
- FigmaFileStructureImportModelPart.shape
2759
- ).extend({
2760
- fileVersionId: _zod.z.string()
2761
- });
2762
- function figmaFileStructureImportModelToMap(root) {
2763
- const map = /* @__PURE__ */ new Map();
2764
- recursiveFigmaFileStructureToMap2(root, map);
2765
- return map;
2766
- }
2767
- function recursiveFigmaFileStructureToMap2(node, map) {
2768
- map.set(node.id, node);
2769
- for (const child of node.children)
2770
- recursiveFigmaFileStructureToMap2(child, map);
2771
- }
2772
-
2773
- // src/dsm/import/data-source.ts
2774
-
2775
- var DataSourceImportModel = _zod.z.object({
2776
- id: _zod.z.string(),
2777
- fileName: _zod.z.string().optional(),
2778
- thumbnailUrl: _zod.z.string().optional()
2779
- });
2780
-
2781
- // src/dsm/import/support/import-model-collections.ts
2782
- var ImportModelInputCollection = _zod.z.object({
2783
- source: DataSourceImportModel,
2784
- tokens: _zod.z.array(DesignTokenImportModelInput).default([]),
2785
- components: _zod.z.array(ComponentImportModelInput).default([]),
2786
- assets: _zod.z.array(AssetImportModelInput).default([]),
2787
- themeUpdates: _zod.z.array(ThemeUpdateImportModelInput).default([]),
2788
- themes: _zod.z.array(ThemeImportModelInput).default([]),
2789
- figmaFileStructure: FigmaFileStructureImportModelInput.optional()
2790
- });
2791
- var ImportModelCollection = _zod.z.object({
2792
- sources: _zod.z.array(DataSourceImportModel),
2793
- tokens: _zod.z.array(DesignTokenImportModel).default([]),
2794
- components: _zod.z.array(ComponentImportModel).default([]),
2795
- themeUpdates: _zod.z.array(ThemeUpdateImportModel).default([]),
2796
- themes: _zod.z.array(ThemeImportModel).default([]),
2797
- figmaFileStructures: _zod.z.array(FigmaFileStructureImportModel)
2798
- });
2799
- function addImportModelCollections(lhs, rhs) {
2800
- return {
2801
- sources: [...lhs.sources, ...rhs.sources],
2802
- tokens: [...lhs.tokens, ...rhs.tokens],
2803
- components: [...lhs.components, ...rhs.components],
2804
- themeUpdates: [...lhs.themeUpdates, ...rhs.themeUpdates],
2805
- themes: [...lhs.themes, ...rhs.themes],
2806
- figmaFileStructures: [...lhs.figmaFileStructures, ...rhs.figmaFileStructures]
2807
- };
2808
- }
2809
-
2810
2816
  // src/dsm/views/column.ts
2811
2817
 
2812
2818
  var ElementViewBaseColumnType = _zod.z.enum(["Name", "Description", "Value", "UpdatedAt"]);