@dsai-io/tools 0.0.1 → 1.0.7

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 (40) hide show
  1. package/README.md +282 -30
  2. package/dist/cli/index.cjs +6271 -2233
  3. package/dist/cli/index.cjs.map +1 -1
  4. package/dist/cli/index.d.cts +4 -0
  5. package/dist/cli/index.d.ts +4 -0
  6. package/dist/cli/index.js +6232 -2195
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/config/index.cjs +198 -61
  9. package/dist/config/index.cjs.map +1 -1
  10. package/dist/config/index.d.cts +490 -1759
  11. package/dist/config/index.d.ts +490 -1759
  12. package/dist/config/index.js +197 -61
  13. package/dist/config/index.js.map +1 -1
  14. package/dist/icons/index.cjs +1 -1
  15. package/dist/icons/index.cjs.map +1 -1
  16. package/dist/icons/index.d.cts +1 -1
  17. package/dist/icons/index.d.ts +1 -1
  18. package/dist/icons/index.js +1 -1
  19. package/dist/icons/index.js.map +1 -1
  20. package/dist/index.cjs +6733 -2888
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +3 -3
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +6774 -2963
  25. package/dist/index.js.map +1 -1
  26. package/dist/tokens/index.cjs +4457 -737
  27. package/dist/tokens/index.cjs.map +1 -1
  28. package/dist/tokens/index.d.cts +1258 -17
  29. package/dist/tokens/index.d.ts +1258 -17
  30. package/dist/tokens/index.js +4368 -683
  31. package/dist/tokens/index.js.map +1 -1
  32. package/dist/{types-Idj08nad.d.cts → types-DabOzcsj.d.cts} +236 -3
  33. package/dist/{types-Idj08nad.d.ts → types-DabOzcsj.d.ts} +236 -3
  34. package/dist/utils/circuit-breaker.cjs +173 -0
  35. package/dist/utils/circuit-breaker.cjs.map +1 -0
  36. package/dist/utils/circuit-breaker.d.cts +123 -0
  37. package/dist/utils/circuit-breaker.d.ts +123 -0
  38. package/dist/utils/circuit-breaker.js +169 -0
  39. package/dist/utils/circuit-breaker.js.map +1 -0
  40. package/package.json +10 -5
@@ -1,4 +1,5 @@
1
- import { R as ResolvedConfig, O as OutputFormat } from '../types-Idj08nad.js';
1
+ import { R as ResolvedConfig, i as ResolvedThemesConfig, j as ResolvedThemeDefinition, O as OutputFormat, b as ThemeDefinition, d as FrameworkMappingConfig, e as FrameworkMappingPattern, F as FrameworkTarget } from '../types-DabOzcsj.js';
2
+ import { z, ZodError } from 'zod';
2
3
 
3
4
  /**
4
5
  * Token-specific type definitions
@@ -48,7 +49,7 @@ interface TokenCollection {
48
49
  /**
49
50
  * Figma export format (from Tokens Studio)
50
51
  */
51
- interface FigmaExport {
52
+ interface FigmaExport$1 {
52
53
  [collectionName: string]: FigmaCollection;
53
54
  }
54
55
  /**
@@ -90,7 +91,7 @@ interface ValidationIssue {
90
91
  /**
91
92
  * Result of token validation
92
93
  */
93
- interface ValidationResult {
94
+ interface ValidationResult$1 {
94
95
  /** Whether validation passed (no errors) */
95
96
  valid: boolean;
96
97
  /** Validation errors (blocking issues) */
@@ -147,6 +148,14 @@ interface TransformOptions {
147
148
  dryRun?: boolean;
148
149
  /** Enable verbose output */
149
150
  verbose?: boolean;
151
+ /** Enable strict schema validation */
152
+ strict?: boolean;
153
+ /** Enable incremental build (only process changed files) */
154
+ incremental?: boolean;
155
+ /** Force full rebuild (ignore cache) */
156
+ force?: boolean;
157
+ /** Cache directory for incremental builds */
158
+ cacheDir?: string;
150
159
  }
151
160
  /**
152
161
  * Result of token transformation
@@ -192,6 +201,8 @@ interface BuildOptions {
192
201
  skipTransform?: boolean;
193
202
  /** Only build theme CSS */
194
203
  onlyTheme?: boolean;
204
+ /** Source directory for Figma exports */
205
+ sourceDir?: string;
195
206
  /** Enable watch mode */
196
207
  watch?: boolean;
197
208
  /** Dry run (don't write files) */
@@ -200,8 +211,18 @@ interface BuildOptions {
200
211
  verbose?: boolean;
201
212
  /** Suppress output */
202
213
  quiet?: boolean;
214
+ /** Enable strict schema validation */
215
+ strict?: boolean;
216
+ /** Enable incremental build (only process changed files) */
217
+ incremental?: boolean;
218
+ /** Force full rebuild (ignore cache) */
219
+ force?: boolean;
220
+ /** Cache directory for incremental builds */
221
+ cacheDir?: string;
203
222
  /** Output directory for all formats */
204
223
  outputDir?: string;
224
+ /** Output formats to generate (default: ['css', 'scss', 'json']) */
225
+ formats?: Array<'css' | 'scss' | 'js' | 'ts' | 'json' | 'android' | 'ios'>;
205
226
  /** Per-format output directories */
206
227
  outputDirs?: Partial<Record<string, string>>;
207
228
  /** Per-format output file names */
@@ -236,6 +257,45 @@ interface BuildOptions {
236
257
  /** Style Dictionary config file name */
237
258
  styleDictionaryConfig?: string;
238
259
  };
260
+ /**
261
+ * Themes configuration for multi-theme builds.
262
+ * When provided with enabled: true, the 'multi-theme' step will
263
+ * use config-driven theme definitions instead of hardcoded themes.
264
+ */
265
+ themesConfig?: {
266
+ /** Whether theme building is enabled */
267
+ enabled?: boolean;
268
+ /** Theme definitions by name */
269
+ definitions?: Record<string, {
270
+ isDefault?: boolean;
271
+ suffix?: string | null;
272
+ selector: string;
273
+ mediaQuery?: string;
274
+ dataAttribute?: string;
275
+ outputFiles?: Partial<Record<string, string>>;
276
+ }>;
277
+ };
278
+ /**
279
+ * Post-process configuration for CSS files
280
+ */
281
+ postprocessConfig?: {
282
+ /** Whether postprocessing is enabled */
283
+ enabled?: boolean;
284
+ /** CSS output directory */
285
+ cssDir?: string;
286
+ /** CSS files to process */
287
+ files?: string[];
288
+ /** Text replacements to apply */
289
+ replacements?: Array<{
290
+ description?: string;
291
+ from: string | RegExp;
292
+ to: string;
293
+ }>;
294
+ };
295
+ /**
296
+ * CSS output directory (from SCSS config)
297
+ */
298
+ cssOutputDir?: string;
239
299
  }
240
300
  /**
241
301
  * Result of token build
@@ -396,6 +456,213 @@ declare function toDTCGToken(token: LegacyToken): DTCGToken;
396
456
  */
397
457
  declare function parseTokenReference(ref: string): string[] | null;
398
458
 
459
+ /**
460
+ * Mode Extractor Module
461
+ *
462
+ * Extracts specific modes from nested Figma token structures.
463
+ * Handles the conversion from Figma's nested mode structure to flat token files.
464
+ *
465
+ * @packageDocumentation
466
+ * @module @dsai-io/tools/tokens/mode-extractor
467
+ */
468
+ /**
469
+ * Mode extraction options
470
+ */
471
+ interface ModeExtractionOptions {
472
+ /** Mode name to extract (e.g., 'Light', 'Dark') */
473
+ modeName: string;
474
+ /** Path to the modes in the token structure (e.g., ['Foundation', 'modes']) */
475
+ modesPath?: string[];
476
+ /** Whether to preserve non-mode tokens */
477
+ preserveNonModeTokens?: boolean;
478
+ }
479
+ /**
480
+ * Mode extraction result
481
+ */
482
+ interface ModeExtractionResult {
483
+ /** Extracted tokens for the specified mode */
484
+ tokens: Record<string, unknown>;
485
+ /** Mode name that was extracted */
486
+ modeName: string;
487
+ /** Whether any tokens were found */
488
+ hasTokens: boolean;
489
+ }
490
+ /**
491
+ * Extract a specific mode from token structure
492
+ *
493
+ * @param tokens - Source token object
494
+ * @param options - Extraction options
495
+ * @returns Extracted tokens for the specified mode
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * const tokens = {
500
+ * Foundation: {
501
+ * modes: {
502
+ * Light: { colors: { primary: { $value: '#0000ff' } } },
503
+ * Dark: { colors: { primary: { $value: '#ffffff' } } }
504
+ * }
505
+ * }
506
+ * };
507
+ *
508
+ * const result = extractMode(tokens, {
509
+ * modeName: 'Light',
510
+ * modesPath: ['Foundation', 'modes']
511
+ * });
512
+ * // result.tokens = { colors: { primary: { $value: '#0000ff' } } }
513
+ * ```
514
+ */
515
+ declare function extractMode(tokens: Record<string, unknown>, options: ModeExtractionOptions): ModeExtractionResult;
516
+ /**
517
+ * Extract multiple modes from token structure
518
+ *
519
+ * @param tokens - Source token object
520
+ * @param modeNames - Array of mode names to extract
521
+ * @param modesPath - Path to modes in structure
522
+ * @returns Map of mode name to extracted tokens
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * const results = extractModes(tokens, ['Light', 'Dark']);
527
+ * // results.get('Light') = light mode tokens
528
+ * // results.get('Dark') = dark mode tokens
529
+ * ```
530
+ */
531
+ declare function extractModes(tokens: Record<string, unknown>, modeNames: string[], modesPath?: string[]): Map<string, ModeExtractionResult>;
532
+ /**
533
+ * Auto-detect available modes in token structure
534
+ *
535
+ * @param tokens - Source token object
536
+ * @param modesPath - Path to modes in structure
537
+ * @returns Array of detected mode names
538
+ *
539
+ * @example
540
+ * ```typescript
541
+ * const modes = detectModes(tokens);
542
+ * // modes = ['Light', 'Dark']
543
+ * ```
544
+ */
545
+ declare function detectModes$2(tokens: Record<string, unknown>, modesPath?: string[]): string[];
546
+ /**
547
+ * Flatten mode structure by hoisting mode tokens to top level
548
+ *
549
+ * Useful when you want to completely flatten the structure instead of preserving nesting
550
+ *
551
+ * @param tokens - Source token object
552
+ * @param modeName - Mode to extract
553
+ * @param modesPath - Path to modes
554
+ * @returns Flattened token structure
555
+ *
556
+ * @example
557
+ * ```typescript
558
+ * const flattened = flattenModeStructure(tokens, 'Light');
559
+ * // { colors: { primary: { $value: '#0000ff' } } }
560
+ * ```
561
+ */
562
+ declare function flattenModeStructure(tokens: Record<string, unknown>, modeName: string, modesPath?: string[]): Record<string, unknown>;
563
+
564
+ /**
565
+ * Mode Preprocessor Module
566
+ *
567
+ * Preprocesses token files by extracting mode-specific tokens into separate files.
568
+ * This allows theme builders to work with mode-specific token sets.
569
+ *
570
+ * @packageDocumentation
571
+ * @module @dsai-io/tools/tokens/mode-preprocessor
572
+ */
573
+ /**
574
+ * Preprocessor configuration
575
+ */
576
+ interface PreprocessorConfig {
577
+ /** Source directory containing original token files */
578
+ sourceDir: string;
579
+ /** Output directory for preprocessed files */
580
+ outputDir: string;
581
+ /** Files to preprocess (glob patterns or file paths) */
582
+ files: string[];
583
+ /** Mode names to extract (auto-detected if not provided) */
584
+ modes?: string[];
585
+ /** Path to modes in token structure */
586
+ modesPath?: string[];
587
+ /** Whether to preserve original files */
588
+ preserveOriginals?: boolean;
589
+ /** Whether to clean output directory before processing */
590
+ clean?: boolean;
591
+ /** Enable verbose logging */
592
+ verbose?: boolean;
593
+ }
594
+ /**
595
+ * Preprocessing result for a single file
596
+ */
597
+ interface FilePreprocessingResult {
598
+ /** Original file path */
599
+ sourceFile: string;
600
+ /** Detected or configured modes */
601
+ modes: string[];
602
+ /** Generated output files by mode */
603
+ outputFiles: Map<string, string>;
604
+ /** Whether preprocessing succeeded */
605
+ success: boolean;
606
+ /** Error message if failed */
607
+ error?: string;
608
+ }
609
+ /**
610
+ * Overall preprocessing result
611
+ */
612
+ interface PreprocessingResult {
613
+ /** Results for each processed file */
614
+ files: FilePreprocessingResult[];
615
+ /** Total files processed */
616
+ totalFiles: number;
617
+ /** Number of successful preprocessings */
618
+ successCount: number;
619
+ /** Number of failed preprocessings */
620
+ failureCount: number;
621
+ /** Output directory used */
622
+ outputDir: string;
623
+ /** Cleanup function to remove preprocessed files */
624
+ cleanup: () => void;
625
+ }
626
+ /**
627
+ * Preprocess a single token file
628
+ *
629
+ * @param filePath - Path to the token file
630
+ * @param config - Preprocessor configuration
631
+ * @returns Preprocessing result
632
+ */
633
+ declare function preprocessFile(filePath: string, config: PreprocessorConfig): FilePreprocessingResult;
634
+ /**
635
+ * Preprocess all token files
636
+ *
637
+ * @param config - Preprocessor configuration
638
+ * @returns Overall preprocessing result
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * const result = preprocessTokenFiles({
643
+ * sourceDir: './src/figma-exports',
644
+ * outputDir: './src/.preprocessed',
645
+ * files: ['foundation.json', 'semantic.json'],
646
+ * modes: ['Light', 'Dark'],
647
+ * clean: true,
648
+ * });
649
+ *
650
+ * // Build tokens using preprocessed files...
651
+ *
652
+ * // Cleanup when done
653
+ * result.cleanup();
654
+ * ```
655
+ */
656
+ declare function preprocessTokenFiles(config: PreprocessorConfig): PreprocessingResult;
657
+ /**
658
+ * Get list of preprocessed files for a specific mode
659
+ *
660
+ * @param result - Preprocessing result
661
+ * @param modeName - Mode to get files for
662
+ * @returns Array of file paths for the mode
663
+ */
664
+ declare function getPreprocessedFilesForMode(result: PreprocessingResult, modeName: string): string[];
665
+
399
666
  /**
400
667
  * Token validation module
401
668
  *
@@ -423,7 +690,7 @@ declare function parseTokenReference(ref: string): string[] | null;
423
690
  * }
424
691
  * ```
425
692
  */
426
- declare function validateTokens(config: ResolvedConfig, options?: ValidateOptions): Promise<ValidationResult>;
693
+ declare function validateTokens(config: ResolvedConfig, options?: ValidateOptions): Promise<ValidationResult$1>;
427
694
  /**
428
695
  * Validate tokens and exit with code (for CLI usage)
429
696
  *
@@ -432,6 +699,305 @@ declare function validateTokens(config: ResolvedConfig, options?: ValidateOption
432
699
  */
433
700
  declare function validateTokensCLI(config: ResolvedConfig, options?: ValidateOptions): Promise<void>;
434
701
 
702
+ /**
703
+ * @fileoverview Zod schemas for DTCG (Design Tokens Community Group) token format
704
+ * @see https://design-tokens.github.io/community-group/format/
705
+ */
706
+
707
+ /**
708
+ * Base DTCG token structure
709
+ */
710
+ declare const dtcgTokenBaseSchema: z.ZodObject<{
711
+ $value: z.ZodUnknown;
712
+ $type: z.ZodOptional<z.ZodEnum<{
713
+ string: "string";
714
+ number: "number";
715
+ color: "color";
716
+ dimension: "dimension";
717
+ fontFamily: "fontFamily";
718
+ fontWeight: "fontWeight";
719
+ shadow: "shadow";
720
+ duration: "duration";
721
+ cubicBezier: "cubicBezier";
722
+ strokeStyle: "strokeStyle";
723
+ border: "border";
724
+ transition: "transition";
725
+ gradient: "gradient";
726
+ typography: "typography";
727
+ }>>;
728
+ $description: z.ZodOptional<z.ZodString>;
729
+ $extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
730
+ }, z.core.$strip>;
731
+ type DTCGTokenBase = z.infer<typeof dtcgTokenBaseSchema>;
732
+ /**
733
+ * Generic DTCG token (allows any token or group)
734
+ */
735
+ declare const dtcgTokenSchema: z.ZodType<DTCGTokenOrGroup>;
736
+ type DTCGTokenOrGroup = DTCGTokenBase | {
737
+ [key: string]: DTCGTokenOrGroup;
738
+ };
739
+ /**
740
+ * DTCG token collection (root level)
741
+ */
742
+ declare const dtcgTokenCollectionSchema: z.ZodRecord<z.ZodString, z.ZodType<DTCGTokenOrGroup, unknown, z.core.$ZodTypeInternals<DTCGTokenOrGroup, unknown>>>;
743
+ type DTCGTokenCollection = z.infer<typeof dtcgTokenCollectionSchema>;
744
+ /**
745
+ * DTCG file format with optional metadata
746
+ */
747
+ declare const dtcgFileSchema: z.ZodObject<{
748
+ $schema: z.ZodOptional<z.ZodString>;
749
+ $description: z.ZodOptional<z.ZodString>;
750
+ $extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
751
+ }, z.core.$catchall<z.ZodType<DTCGTokenOrGroup, unknown, z.core.$ZodTypeInternals<DTCGTokenOrGroup, unknown>>>>;
752
+ type DTCGFile = z.infer<typeof dtcgFileSchema>;
753
+
754
+ /**
755
+ * @fileoverview Zod schemas for Figma token export format
756
+ * Validates the structure of tokens exported from Figma Variables API
757
+ */
758
+
759
+ /**
760
+ * Figma variables API response
761
+ */
762
+ declare const figmaVariablesResponseSchema: z.ZodObject<{
763
+ meta: z.ZodObject<{
764
+ variables: z.ZodRecord<z.ZodString, z.ZodObject<{
765
+ id: z.ZodString;
766
+ name: z.ZodString;
767
+ key: z.ZodOptional<z.ZodString>;
768
+ resolvedType: z.ZodEnum<{
769
+ BOOLEAN: "BOOLEAN";
770
+ FLOAT: "FLOAT";
771
+ STRING: "STRING";
772
+ COLOR: "COLOR";
773
+ }>;
774
+ valuesByMode: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
775
+ r: z.ZodNumber;
776
+ g: z.ZodNumber;
777
+ b: z.ZodNumber;
778
+ a: z.ZodNumber;
779
+ }, z.core.$strip>, z.ZodObject<{
780
+ type: z.ZodLiteral<"VARIABLE_ALIAS">;
781
+ id: z.ZodString;
782
+ }, z.core.$strip>]>>;
783
+ variableCollectionId: z.ZodString;
784
+ remote: z.ZodBoolean;
785
+ description: z.ZodString;
786
+ hiddenFromPublishing: z.ZodBoolean;
787
+ scopes: z.ZodArray<z.ZodString>;
788
+ codeSyntax: z.ZodRecord<z.ZodString, z.ZodString>;
789
+ }, z.core.$strip>>;
790
+ variableCollections: z.ZodRecord<z.ZodString, z.ZodObject<{
791
+ id: z.ZodString;
792
+ name: z.ZodString;
793
+ modes: z.ZodArray<z.ZodObject<{
794
+ modeId: z.ZodString;
795
+ name: z.ZodString;
796
+ }, z.core.$strip>>;
797
+ defaultModeId: z.ZodString;
798
+ remote: z.ZodBoolean;
799
+ hiddenFromPublishing: z.ZodBoolean;
800
+ variableIds: z.ZodArray<z.ZodString>;
801
+ }, z.core.$strip>>;
802
+ }, z.core.$strip>;
803
+ }, z.core.$strip>;
804
+ /**
805
+ * Figma export format (as produced by @dsai-io/figma-tokens)
806
+ * This is the format after exportTokens() processes the Figma API response
807
+ */
808
+ declare const figmaExportSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
809
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
810
+ }, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
811
+ /**
812
+ * Figma export with metadata
813
+ */
814
+ declare const figmaExportWithMetadataSchema: z.ZodObject<{
815
+ $schema: z.ZodOptional<z.ZodString>;
816
+ $description: z.ZodOptional<z.ZodString>;
817
+ $version: z.ZodOptional<z.ZodString>;
818
+ $source: z.ZodOptional<z.ZodString>;
819
+ $figmaFileKey: z.ZodOptional<z.ZodString>;
820
+ $exportedAt: z.ZodOptional<z.ZodString>;
821
+ }, z.core.$catchall<z.ZodUnion<readonly [z.ZodObject<{
822
+ modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
823
+ }, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
824
+ type FigmaVariablesResponse = z.infer<typeof figmaVariablesResponseSchema>;
825
+ type FigmaExport = z.infer<typeof figmaExportSchema>;
826
+ type FigmaExportWithMetadata = z.infer<typeof figmaExportWithMetadataSchema>;
827
+
828
+ /**
829
+ * @fileoverview Zod schemas for Style Dictionary token format
830
+ * @see https://amzn.github.io/style-dictionary/
831
+ */
832
+
833
+ /**
834
+ * Style Dictionary token (legacy format - uses "value" not "$value")
835
+ */
836
+ declare const styleDictionaryTokenSchema: z.ZodObject<{
837
+ value: z.ZodUnknown;
838
+ type: z.ZodOptional<z.ZodString>;
839
+ comment: z.ZodOptional<z.ZodString>;
840
+ themeable: z.ZodOptional<z.ZodBoolean>;
841
+ attributes: z.ZodOptional<z.ZodObject<{
842
+ category: z.ZodOptional<z.ZodString>;
843
+ type: z.ZodOptional<z.ZodString>;
844
+ item: z.ZodOptional<z.ZodString>;
845
+ subitem: z.ZodOptional<z.ZodString>;
846
+ state: z.ZodOptional<z.ZodString>;
847
+ }, z.core.$loose>>;
848
+ name: z.ZodOptional<z.ZodString>;
849
+ path: z.ZodOptional<z.ZodArray<z.ZodString>>;
850
+ original: z.ZodOptional<z.ZodObject<{
851
+ value: z.ZodUnknown;
852
+ }, z.core.$loose>>;
853
+ filePath: z.ZodOptional<z.ZodString>;
854
+ isSource: z.ZodOptional<z.ZodBoolean>;
855
+ }, z.core.$loose>;
856
+ type StyleDictionaryTokenOrGroup = z.infer<typeof styleDictionaryTokenSchema> | {
857
+ [key: string]: StyleDictionaryTokenOrGroup;
858
+ };
859
+ /**
860
+ * Style Dictionary tokens collection
861
+ */
862
+ declare const styleDictionaryTokensSchema: z.ZodRecord<z.ZodString, z.ZodType<StyleDictionaryTokenOrGroup, unknown, z.core.$ZodTypeInternals<StyleDictionaryTokenOrGroup, unknown>>>;
863
+ type StyleDictionaryTokens = z.infer<typeof styleDictionaryTokensSchema>;
864
+ /**
865
+ * Style Dictionary input file format
866
+ */
867
+ declare const styleDictionaryInputSchema: z.ZodRecord<z.ZodString, z.ZodType<StyleDictionaryTokenOrGroup, unknown, z.core.$ZodTypeInternals<StyleDictionaryTokenOrGroup, unknown>>>;
868
+ type StyleDictionaryInput = z.infer<typeof styleDictionaryInputSchema>;
869
+
870
+ /**
871
+ * @fileoverview Token schema validation
872
+ * Exports Zod schemas and validation functions for token formats
873
+ */
874
+
875
+ /**
876
+ * Validation error details
877
+ */
878
+ interface ValidationError {
879
+ /** Path to the invalid token (e.g., "colors.primary.$value") */
880
+ path: string;
881
+ /** Error message */
882
+ message: string;
883
+ /** The invalid value */
884
+ value?: unknown;
885
+ /** Error code from Zod */
886
+ code?: string;
887
+ }
888
+ /**
889
+ * Validation result
890
+ */
891
+ interface ValidationResult<T = unknown> {
892
+ /** Whether validation passed */
893
+ valid: boolean;
894
+ /** Validated and typed data (only if valid) */
895
+ data?: T;
896
+ /** Validation errors (only if invalid) */
897
+ errors?: ValidationError[];
898
+ /** Original Zod error (for debugging) */
899
+ zodError?: ZodError;
900
+ }
901
+ /**
902
+ * Validation options
903
+ */
904
+ interface ValidationOptions {
905
+ /** Strict mode - treat warnings as errors */
906
+ strict?: boolean;
907
+ /** Abort after first error */
908
+ abortEarly?: boolean;
909
+ }
910
+ /**
911
+ * Validate DTCG token collection
912
+ *
913
+ * @param data - Data to validate
914
+ * @param options - Validation options
915
+ * @returns Validation result with typed data
916
+ *
917
+ * @example
918
+ * ```ts
919
+ * const result = validateDTCGTokens({
920
+ * colors: {
921
+ * primary: {
922
+ * $value: '#0066ff',
923
+ * $type: 'color',
924
+ * },
925
+ * },
926
+ * });
927
+ *
928
+ * if (result.valid) {
929
+ * console.log('Valid tokens:', result.data);
930
+ * } else {
931
+ * console.error('Validation errors:', result.errors);
932
+ * }
933
+ * ```
934
+ */
935
+ declare function validateDTCGTokens(data: unknown, _options?: ValidationOptions): ValidationResult<DTCGTokenCollection>;
936
+ /**
937
+ * Validate DTCG file format
938
+ *
939
+ * @param data - Data to validate
940
+ * @param options - Validation options
941
+ * @returns Validation result with typed data
942
+ */
943
+ declare function validateDTCGFile(data: unknown, _options?: ValidationOptions): ValidationResult<DTCGFile>;
944
+ /**
945
+ * Validate Figma export format
946
+ *
947
+ * @param data - Data to validate
948
+ * @param options - Validation options
949
+ * @returns Validation result with typed data
950
+ *
951
+ * @example
952
+ * ```ts
953
+ * const result = validateFigmaExport(exportedData);
954
+ * if (!result.valid) {
955
+ * console.error('Invalid Figma export:', result.errors);
956
+ * }
957
+ * ```
958
+ */
959
+ declare function validateFigmaExport(data: unknown, _options?: ValidationOptions): ValidationResult<FigmaExport>;
960
+ /**
961
+ * Validate Figma export with metadata
962
+ *
963
+ * @param data - Data to validate
964
+ * @param options - Validation options
965
+ * @returns Validation result with typed data
966
+ */
967
+ declare function validateFigmaExportWithMetadata(data: unknown, _options?: ValidationOptions): ValidationResult<FigmaExportWithMetadata>;
968
+ /**
969
+ * Validate Figma Variables API response
970
+ *
971
+ * @param data - Data to validate
972
+ * @param options - Validation options
973
+ * @returns Validation result with typed data
974
+ */
975
+ declare function validateFigmaVariablesResponse(data: unknown, _options?: ValidationOptions): ValidationResult<FigmaVariablesResponse>;
976
+ /**
977
+ * Validate Style Dictionary input format
978
+ *
979
+ * @param data - Data to validate
980
+ * @param options - Validation options
981
+ * @returns Validation result with typed data
982
+ *
983
+ * @example
984
+ * ```ts
985
+ * const result = validateStyleDictionaryInput(tokens);
986
+ * if (!result.valid) {
987
+ * throw new Error(`Invalid tokens: ${result.errors.map(e => e.message).join(', ')}`);
988
+ * }
989
+ * ```
990
+ */
991
+ declare function validateStyleDictionaryInput(data: unknown, _options?: ValidationOptions): ValidationResult<StyleDictionaryInput>;
992
+ /**
993
+ * Validate Style Dictionary tokens
994
+ *
995
+ * @param data - Data to validate
996
+ * @param options - Validation options
997
+ * @returns Validation result with typed data
998
+ */
999
+ declare function validateStyleDictionaryTokens(data: unknown, _options?: ValidationOptions): ValidationResult<StyleDictionaryTokens>;
1000
+
435
1001
  /**
436
1002
  * Figma Export Validation module
437
1003
  *
@@ -476,9 +1042,9 @@ interface ValidateFigmaOptions {
476
1042
  /**
477
1043
  * Figma validation result
478
1044
  */
479
- interface ValidateFigmaResult extends ValidationResult {
1045
+ interface ValidateFigmaResult extends ValidationResult$1 {
480
1046
  /** Per-file validation results */
481
- files: Map<string, ValidationResult>;
1047
+ files: Map<string, ValidationResult$1>;
482
1048
  /** Detected modes across all files */
483
1049
  detectedModes: Set<string>;
484
1050
  /** Missing expected files */
@@ -487,7 +1053,7 @@ interface ValidateFigmaResult extends ValidationResult {
487
1053
  /**
488
1054
  * Validate a single Figma export file
489
1055
  */
490
- declare function validateFigmaFile(filePath: string, expectedCollection?: ExpectedCollection): ValidationResult & {
1056
+ declare function validateFigmaFile(filePath: string, expectedCollection?: ExpectedCollection): ValidationResult$1 & {
491
1057
  detectedModes: Set<string>;
492
1058
  };
493
1059
  /**
@@ -497,7 +1063,7 @@ declare function validateFigmaExports(options?: ValidateFigmaOptions): ValidateF
497
1063
  /**
498
1064
  * Detect modes from Figma export data
499
1065
  */
500
- declare function detectModes$1(data: FigmaExport, collectionName?: string): string[];
1066
+ declare function detectModes$1(data: FigmaExport$1, collectionName?: string): string[];
501
1067
  /**
502
1068
  * CLI entry point for Figma validation
503
1069
  */
@@ -532,8 +1098,10 @@ interface TokenTransformOptions {
532
1098
  declare function transformValue(value: unknown, type: string | undefined, options?: TokenTransformOptions): unknown;
533
1099
  /**
534
1100
  * Transform type from Figma to DTCG standard
1101
+ * @param figmaType - The original Figma type
1102
+ * @param scopes - Token scopes to determine type-specific handling
535
1103
  */
536
- declare function transformType(figmaType: string | undefined): TokenType | undefined;
1104
+ declare function transformType(figmaType: string | undefined, scopes?: string[]): TokenType | undefined;
537
1105
  /**
538
1106
  * Transform a single token from Figma format to DTCG-compliant format
539
1107
  */
@@ -545,7 +1113,7 @@ declare function transformTokenTree(obj: unknown, parentKey?: string, options?:
545
1113
  /**
546
1114
  * Detect modes from Figma export data
547
1115
  */
548
- declare function detectModes(data: FigmaExport, collectionPath?: string): string[];
1116
+ declare function detectModes(data: FigmaExport$1, collectionPath?: string): string[];
549
1117
  /**
550
1118
  * Transform Figma tokens to Style Dictionary format
551
1119
  */
@@ -594,8 +1162,13 @@ declare function getDefaultSyncPaths(tokensDir: string): {
594
1162
  declare function syncTokens(options: SyncOptions): SyncResult;
595
1163
  /**
596
1164
  * CLI entry point for token sync
1165
+ * @param tokensDir - The tokens package directory
1166
+ * @param customPaths - Optional custom paths for source and target files
597
1167
  */
598
- declare function syncTokensCLI(tokensDir: string): boolean;
1168
+ declare function syncTokensCLI(tokensDir: string, customPaths?: {
1169
+ syncSource?: string;
1170
+ syncTarget?: string;
1171
+ }): boolean;
599
1172
 
600
1173
  /**
601
1174
  * @file Token Build Module
@@ -643,16 +1216,380 @@ declare function syncTokensCLI(tokensDir: string): boolean;
643
1216
  * });
644
1217
  * ```
645
1218
  */
646
- declare function buildTokens(tokensDir: string, toolsDir: string, options?: BuildOptions): BuildResult;
1219
+ declare function buildTokens(tokensDir: string, toolsDir: string, options?: BuildOptions): Promise<BuildResult>;
647
1220
  /**
648
1221
  * CLI entry point for token build
649
1222
  */
650
- declare function buildTokensCLI(tokensDir: string, toolsDir: string, args?: string[]): boolean;
1223
+ declare function buildTokensCLI(tokensDir: string, toolsDir: string, args?: string[]): Promise<boolean>;
651
1224
  /**
652
1225
  * Parse CLI arguments and run build
653
1226
  * Used as the main entry point when called directly
654
1227
  */
655
- declare function runBuildCLI(tokensDir: string, toolsDir: string): void;
1228
+ declare function runBuildCLI(tokensDir: string, toolsDir: string): Promise<void>;
1229
+
1230
+ /**
1231
+ * Theme Discovery Module
1232
+ *
1233
+ * Discovers and categorizes token files by theme based on file suffix patterns.
1234
+ * Supports both auto-detection from file names and explicit theme definitions.
1235
+ *
1236
+ * @packageDocumentation
1237
+ * @module @dsai-io/tools/tokens/theme-discovery
1238
+ */
1239
+
1240
+ /**
1241
+ * Result of theme file discovery
1242
+ */
1243
+ interface ThemeFilesResult {
1244
+ /** Theme name */
1245
+ theme: string;
1246
+ /** Theme definition */
1247
+ definition: ResolvedThemeDefinition;
1248
+ /** Files belonging to this theme */
1249
+ files: string[];
1250
+ }
1251
+ /**
1252
+ * Discovery result with all themes
1253
+ */
1254
+ interface DiscoveryResult {
1255
+ /** Files organized by theme - Map of theme name to file paths */
1256
+ themes: Map<string, string[]>;
1257
+ /** Theme definitions organized by theme name */
1258
+ definitions: Map<string, ResolvedThemeDefinition>;
1259
+ /** Files that couldn't be matched to any theme (when autoDetect is false) */
1260
+ orphanFiles: string[];
1261
+ /** Themes with no files found */
1262
+ emptyThemes: string[];
1263
+ /** Total files discovered */
1264
+ totalFiles: number;
1265
+ }
1266
+ /**
1267
+ * Options for theme discovery
1268
+ */
1269
+ interface DiscoveryOptions {
1270
+ /** Base directory for file patterns */
1271
+ sourceDir: string;
1272
+ /** Glob pattern for finding token files */
1273
+ pattern?: string;
1274
+ /** Whether to include verbose logging */
1275
+ verbose?: boolean;
1276
+ }
1277
+ /**
1278
+ * Discover token files organized by theme
1279
+ *
1280
+ * This function scans the source directory for JSON token files and
1281
+ * categorizes them by theme based on their file suffix patterns.
1282
+ *
1283
+ * @param themesConfig - Resolved themes configuration
1284
+ * @param options - Discovery options including source directory
1285
+ * @returns Discovery result with files organized by theme
1286
+ *
1287
+ * @example
1288
+ * ```typescript
1289
+ * const result = discoverThemeFiles(themesConfig, {
1290
+ * sourceDir: 'src/collections',
1291
+ * pattern: '**\/*.json',
1292
+ * });
1293
+ *
1294
+ * // result.themes = [
1295
+ * // { theme: 'light', files: ['foundation.json', 'semantic.json'] },
1296
+ * // { theme: 'dark', files: ['foundation-dark.json', 'semantic-dark.json'] },
1297
+ * // ]
1298
+ * ```
1299
+ */
1300
+ declare function discoverThemeFiles(themesConfig: ResolvedThemesConfig, options: DiscoveryOptions): DiscoveryResult;
1301
+ /**
1302
+ * Get files for a specific theme
1303
+ *
1304
+ * For the default theme, this returns all files EXCEPT those
1305
+ * matching other theme suffixes.
1306
+ *
1307
+ * For non-default themes, this returns only files with the
1308
+ * matching suffix.
1309
+ *
1310
+ * @param themeName - Name of the theme to get files for
1311
+ * @param themesConfig - Resolved themes configuration
1312
+ * @param options - Discovery options
1313
+ * @returns Array of file paths for the theme
1314
+ */
1315
+ declare function getThemeFiles(themeName: string, themesConfig: ResolvedThemesConfig, options: DiscoveryOptions): string[];
1316
+ /**
1317
+ * Auto-detect themes from file suffixes
1318
+ *
1319
+ * Scans files in the source directory and extracts unique
1320
+ * theme suffixes to build a dynamic theme list.
1321
+ *
1322
+ * @param sourceDir - Directory to scan
1323
+ * @param pattern - Glob pattern for files
1324
+ * @param selectorPattern - Pattern for generating selectors
1325
+ * @returns Map of theme names to their suffixes
1326
+ */
1327
+ declare function autoDetectThemes(sourceDir: string, pattern?: string, selectorPattern?: string): Map<string, {
1328
+ suffix: string | null;
1329
+ selector: string;
1330
+ }>;
1331
+
1332
+ /**
1333
+ * @file Theme Builder Module
1334
+ * @description Builds token outputs for a single theme using Style Dictionary
1335
+ *
1336
+ * This module orchestrates the build process for individual themes, generating
1337
+ * the appropriate Style Dictionary configuration based on the theme definition.
1338
+ *
1339
+ * Key responsibilities:
1340
+ * - Generate Style Dictionary config for a theme
1341
+ * - Use correct CSS format based on theme type (default vs non-default)
1342
+ * - Support all output formats (CSS, SCSS, JS, TS, JSON)
1343
+ * - Generate output file paths from theme definition
1344
+ *
1345
+ * @example
1346
+ * ```typescript
1347
+ * import { buildTheme, generateThemeBuildConfig } from '@dsai-io/tools';
1348
+ *
1349
+ * const result = await buildTheme({
1350
+ * themeName: 'dark',
1351
+ * themeDefinition: {
1352
+ * isDefault: false,
1353
+ * suffix: '-dark',
1354
+ * selector: '[data-dsai-theme="dark"]',
1355
+ * outputFiles: { css: 'tokens-dark.css' },
1356
+ * },
1357
+ * files: ['collections/color-dark.json', 'collections/semantic-dark.json'],
1358
+ * outputDir: 'dist',
1359
+ * config: resolvedConfig,
1360
+ * });
1361
+ * ```
1362
+ *
1363
+ * @module @dsai-io/tools/tokens/theme-builder
1364
+ */
1365
+
1366
+ /**
1367
+ * Minimal configuration required for theme building
1368
+ *
1369
+ * This interface only includes the properties actually used by the theme builder,
1370
+ * allowing callers to pass either a full ResolvedTokensConfig or a minimal object.
1371
+ */
1372
+ interface ThemeBuildConfig {
1373
+ /** Output formats to generate */
1374
+ formats: OutputFormat[];
1375
+ /** Theme definitions (used by buildAllThemes to lookup theme metadata) */
1376
+ themes?: {
1377
+ definitions?: Record<string, ThemeDefinition | ResolvedThemeDefinition>;
1378
+ };
1379
+ }
1380
+ /**
1381
+ * Options for building a single theme
1382
+ */
1383
+ interface ThemeBuildOptions {
1384
+ /** Name of the theme (e.g., 'light', 'dark', 'pro') */
1385
+ themeName: string;
1386
+ /** Resolved theme definition with all required fields */
1387
+ themeDefinition: ResolvedThemeDefinition;
1388
+ /** Array of token file paths for this theme */
1389
+ files: string[];
1390
+ /** Output directory for generated files */
1391
+ outputDir: string;
1392
+ /** Build configuration (formats and optionally theme definitions) */
1393
+ config: ThemeBuildConfig;
1394
+ /** Enable verbose logging */
1395
+ verbose?: boolean;
1396
+ /** Skip cache lookup (force rebuild) */
1397
+ skipCache?: boolean;
1398
+ }
1399
+ /**
1400
+ * Result of building a single theme
1401
+ */
1402
+ interface ThemeBuildResult {
1403
+ /** Whether the build succeeded */
1404
+ success: boolean;
1405
+ /** Theme name that was built */
1406
+ themeName: string;
1407
+ /** Generated output files by format */
1408
+ outputs: Partial<Record<OutputFormat, string[]>>;
1409
+ /** Error message if build failed */
1410
+ error?: string;
1411
+ /** Duration in milliseconds */
1412
+ duration: number;
1413
+ /** Whether result was from cache */
1414
+ fromCache: boolean;
1415
+ }
1416
+ /**
1417
+ * Style Dictionary configuration for a theme
1418
+ */
1419
+ interface ThemeStyleDictionaryConfig {
1420
+ /** Source token files */
1421
+ source: string[];
1422
+ /** Platform configurations */
1423
+ platforms: Record<string, StyleDictionaryPlatformConfig>;
1424
+ /** Whether tokens use DTCG format ($value, $type, etc.) */
1425
+ usesDtcg?: boolean;
1426
+ /** Logging configuration */
1427
+ log?: {
1428
+ warnings?: 'warn' | 'error' | 'disabled';
1429
+ verbosity?: 'default' | 'silent' | 'verbose';
1430
+ errors?: {
1431
+ brokenReferences?: 'throw' | 'console';
1432
+ };
1433
+ };
1434
+ }
1435
+ /**
1436
+ * Style Dictionary platform configuration
1437
+ */
1438
+ interface StyleDictionaryPlatformConfig {
1439
+ /** Transform group to use */
1440
+ transformGroup?: string;
1441
+ /** Build path for outputs */
1442
+ buildPath: string;
1443
+ /** Output file configurations */
1444
+ files: StyleDictionaryFileConfig[];
1445
+ /** Custom options for formats */
1446
+ options?: Record<string, unknown>;
1447
+ }
1448
+ /**
1449
+ * Style Dictionary file configuration
1450
+ */
1451
+ interface StyleDictionaryFileConfig {
1452
+ /** Output file path (relative to buildPath) */
1453
+ destination: string;
1454
+ /** Format to use for output */
1455
+ format: string;
1456
+ /** Filter for tokens to include */
1457
+ filter?: Record<string, unknown>;
1458
+ /** Format-specific options */
1459
+ options?: Record<string, unknown>;
1460
+ }
1461
+ /**
1462
+ * Generate Style Dictionary configuration for a single theme
1463
+ *
1464
+ * @param options - Theme build options
1465
+ * @returns Style Dictionary configuration object
1466
+ *
1467
+ * @example
1468
+ * ```typescript
1469
+ * const sdConfig = generateThemeBuildConfig({
1470
+ * themeName: 'dark',
1471
+ * themeDefinition: { isDefault: false, selector: '[data-dsai-theme="dark"]' },
1472
+ * files: ['collections/color-dark.json'],
1473
+ * outputDir: 'dist',
1474
+ * config: resolvedConfig,
1475
+ * });
1476
+ * // Returns Style Dictionary config with dark mode format
1477
+ * ```
1478
+ */
1479
+ declare function generateThemeBuildConfig(options: ThemeBuildOptions): ThemeStyleDictionaryConfig;
1480
+ /**
1481
+ * Build token outputs for a single theme
1482
+ *
1483
+ * This function generates Style Dictionary configuration from the theme
1484
+ * definition and runs the build process. For default themes, it uses
1485
+ * `css/variables-with-comments` format with `:root` selector. For
1486
+ * non-default themes, it uses `css/variables-dark-mode` with the
1487
+ * theme-specific selector.
1488
+ *
1489
+ * @param options - Theme build options
1490
+ * @returns Build result with success status and output files
1491
+ *
1492
+ * @example
1493
+ * ```typescript
1494
+ * const result = await buildTheme({
1495
+ * themeName: 'dark',
1496
+ * themeDefinition: resolvedThemeDef,
1497
+ * files: ['collections/color-dark.json'],
1498
+ * outputDir: 'dist',
1499
+ * config: resolvedConfig,
1500
+ * verbose: true,
1501
+ * });
1502
+ *
1503
+ * if (result.success) {
1504
+ * console.log('Built files:', result.outputs);
1505
+ * }
1506
+ * ```
1507
+ */
1508
+ declare function buildTheme(options: ThemeBuildOptions): Promise<ThemeBuildResult>;
1509
+ /**
1510
+ * Options for building multiple themes
1511
+ */
1512
+ interface MultiThemeBuildOptions {
1513
+ /** Build configuration with formats and theme definitions */
1514
+ config: ThemeBuildConfig;
1515
+ /** Map of theme name to file paths */
1516
+ themeFiles: Map<string, string[]>;
1517
+ /** Output directory for all themes */
1518
+ outputDir: string;
1519
+ /** Enable verbose logging */
1520
+ verbose?: boolean;
1521
+ /** Only build these specific themes (if not set, build all) */
1522
+ themes?: string[];
1523
+ /** Skip cache lookup */
1524
+ skipCache?: boolean;
1525
+ }
1526
+ /**
1527
+ * Result of building multiple themes
1528
+ */
1529
+ interface MultiThemeBuildResult {
1530
+ /** Overall success (true if all themes succeeded) */
1531
+ success: boolean;
1532
+ /** Individual theme results */
1533
+ results: ThemeBuildResult[];
1534
+ /** Total duration in milliseconds */
1535
+ duration: number;
1536
+ /** Number of themes built successfully */
1537
+ successCount: number;
1538
+ /** Number of themes that failed */
1539
+ failCount: number;
1540
+ }
1541
+ /**
1542
+ * Build multiple themes in sequence
1543
+ *
1544
+ * This function iterates through all configured themes and builds each one
1545
+ * using the appropriate Style Dictionary configuration. It collects results
1546
+ * and returns a summary of the build process.
1547
+ *
1548
+ * @param options - Multi-theme build options
1549
+ * @returns Aggregated build results
1550
+ *
1551
+ * @example
1552
+ * ```typescript
1553
+ * const result = await buildAllThemes({
1554
+ * config: resolvedConfig,
1555
+ * themeFiles: new Map([
1556
+ * ['light', ['collections/color.json']],
1557
+ * ['dark', ['collections/color-dark.json']],
1558
+ * ]),
1559
+ * outputDir: 'dist',
1560
+ * verbose: true,
1561
+ * });
1562
+ *
1563
+ * console.log(`Built ${result.successCount}/${result.results.length} themes`);
1564
+ * ```
1565
+ */
1566
+ declare function buildAllThemes(options: MultiThemeBuildOptions): Promise<MultiThemeBuildResult>;
1567
+ /**
1568
+ * Get the appropriate CSS format for a theme
1569
+ *
1570
+ * @param isDefault - Whether this is the default theme
1571
+ * @returns Style Dictionary format name
1572
+ */
1573
+ declare function getCssFormat(isDefault: boolean): string;
1574
+ /**
1575
+ * Get the CSS selector for a theme
1576
+ *
1577
+ * @param themeDefinition - Resolved theme definition
1578
+ * @returns CSS selector string
1579
+ */
1580
+ declare function getThemeSelector(themeDefinition: ResolvedThemeDefinition): string;
1581
+ /**
1582
+ * Validate theme definitions for conflicts
1583
+ *
1584
+ * Checks for:
1585
+ * - Multiple default themes
1586
+ * - Duplicate selectors
1587
+ * - Duplicate suffixes
1588
+ *
1589
+ * @param definitions - Map of theme name to definition
1590
+ * @returns Array of validation error messages
1591
+ */
1592
+ declare function validateThemeDefinitions(definitions: Map<string, ResolvedThemeDefinition>): string[];
656
1593
 
657
1594
  /**
658
1595
  * @file Token Clean Module
@@ -1486,6 +2423,17 @@ interface SDLogConfig {
1486
2423
  /** How to handle errors */
1487
2424
  errors?: 'error' | 'throw';
1488
2425
  }
2426
+ /**
2427
+ * Expand configuration for composite tokens
2428
+ */
2429
+ interface SDExpandConfig {
2430
+ /** Optional type mapping for composite token properties */
2431
+ typesMap?: Record<string, string | string[] | Record<string, string | string[]>>;
2432
+ /** Include specific token types */
2433
+ include?: string[] | ((token: SDToken, config: SDConfig) => boolean);
2434
+ /** Exclude specific token types */
2435
+ exclude?: string[] | ((token: SDToken, config: SDConfig) => boolean);
2436
+ }
1489
2437
  /**
1490
2438
  * Full Style Dictionary configuration
1491
2439
  */
@@ -1494,6 +2442,8 @@ interface SDConfig {
1494
2442
  log?: SDLogConfig;
1495
2443
  /** Preprocessors to run on source tokens */
1496
2444
  preprocessors?: string[];
2445
+ /** Configures whether and how composite tokens will be expanded */
2446
+ expand?: boolean | SDExpandConfig | ((token: SDToken, config: SDConfig) => boolean);
1497
2447
  /** Source token file patterns */
1498
2448
  source?: string[];
1499
2449
  /** Additional files to include */
@@ -1999,11 +2949,11 @@ declare const cssTransformGroup: TransformGroupDefinition;
1999
2949
  */
2000
2950
 
2001
2951
  /**
2002
- * custom/js transform group
2952
+ * js-custom transform group
2003
2953
  *
2004
2954
  * Transforms for generating JavaScript/TypeScript exports:
2005
2955
  * - attribute/cti: Add CTI attributes
2006
- * - name/camel: camelCase names
2956
+ * - name/js-identifier: PascalCase names with numeric segment handling
2007
2957
  * - fontWeight/unitless: Keep font weights unitless
2008
2958
  * - lineHeight/unitless: Keep line heights unitless
2009
2959
  * - dimension/rem: Convert dimensions to rem
@@ -2067,4 +3017,295 @@ declare const transformGroups: TransformGroupDefinition[];
2067
3017
  */
2068
3018
  declare function registerTransformGroups(sd: StyleDictionaryInstance, customGroups?: TransformGroupDefinition[]): void;
2069
3019
 
2070
- export { type BuildOptions, type BuildResult, type BuildStep, type BundleConfig, type BundleResult, type CleanOptions, type CleanResult, type CleanedDirectory, type CreateSDConfigOptions, DEFAULT_CLEAN_DIRECTORIES, DEFAULT_FILE_NAMES, type DTCGToken, type FigmaCollection, type FigmaExport, type FormatDefinition, type LegacyToken, type MergeConfig, type MergeContent, type MergeOptions, type MergeResult, type OutputConfig, type PlaceholderValues, type PostprocessOptions, type PostprocessResult, type PreprocessorDefinition, type ReplacementRule, type SDConfig, type SDDictionary, type SDFile, type SDFormatArgs, type SDLogConfig, type SDPlatform, type SDPlatformType, type SDToken, type SDTransformOptions, type StyleDictionaryInstance, type StyleMergeResult, type StyleScannedFile, type StyleScannerOptions, type StyleScannerResult, type SyncOptions, type SyncResult, type Token, type TokenCollection, type TransformOptions as TokenTransformOptions, type TransformResult as TokenTransformResult, type TokenType, type ValidationResult as TokenValidationResult, type TransformDefinition, type TransformGroupDefinition, type TransformType, VALID_TOKEN_TYPES, type ValidateOptions, type ValidationIssue, type ValidationSeverity, addScssImportHeader, buildTokens, buildTokensCLI, builtInFormats, builtInPreprocessors, builtInTransforms, cleanTokenOutputs, cleanTokensCLI, createBundle, createBundleFromFiles, createBundles, createFixReferencesPreprocessor, createOutputConfig, createStyleDictionaryConfig, cssTransformGroup, cssVariablesWithComments, detectModes$1 as detectFigmaModes, detectModes as detectTransformModes, dimensionRem, ensureOutputDirs, filterFiles, fixReferences, fontWeightUnitless, getDefaultCssDir, getDefaultFiles, getDefaultIgnorePatterns, getDefaultSyncPaths, getDefaultTransformations, getSDTokenType, getSDTokenValue, getTokenDescription, getTokenType, getTokenValue, hasDTCGValue, isDTCGToken, isLegacyToken, isSDToken, isToken, isTokenReference, isValidTokenType, jsTransformGroup, lineHeightUnitless, loadContent, mergeCollections, mergeCollectionsCLI, mergeContent, nameKebab, parseTokenReference, postprocessCLI, postprocessCss, postprocessCssFiles, processScssImportHeader, registerAll, registerFormats, registerPreprocessors, registerTransformGroups, registerTransforms, replacePlaceholders, resolveAllOutputPaths, resolveOutputPath, runBuildCLI, scanDirectories, scssTransformGroup, setupStyleDictionary, sortFiles, syncTokens, syncTokensCLI, toDTCGToken, transformGroups, transformToken, transformTokenTree, transformTokens, transformTokensCLI, transformType, transformValue, typescriptDeclarations, validateFigmaCLI, validateFigmaExports, validateFigmaFile, validateOutputPaths, validateTokens, validateTokensCLI };
3020
+ /**
3021
+ * Bootstrap Framework Mapper
3022
+ *
3023
+ * Maps Figma/DTCG token names to Bootstrap 5.x variable names.
3024
+ * This is the complete mapping list extracted from the playground's
3025
+ * _variables.scss compatibility layer.
3026
+ *
3027
+ * @packageDocumentation
3028
+ */
3029
+
3030
+ /**
3031
+ * Complete token name → Bootstrap variable name mappings
3032
+ *
3033
+ * These mappings handle cases where Figma/DTCG token naming conventions
3034
+ * differ from Bootstrap 5.x variable naming conventions.
3035
+ *
3036
+ * The mappings are extracted from the playground's manual _variables.scss
3037
+ * compatibility layer to ensure complete parity.
3038
+ *
3039
+ * CATEGORIES:
3040
+ * - Typography: Font sizes, weights, headings, display, line heights, letter spacing
3041
+ * - Colors: Pass through (no mapping needed - names match)
3042
+ * - Spacing: Pass through (no mapping needed - names match)
3043
+ * - Layout: Pass through (no mapping needed - names match)
3044
+ * - Shadows: Custom mappings to Bootstrap shadow variable names
3045
+ * - Border Radius: Custom mappings to Bootstrap radius variable names
3046
+ */
3047
+ declare const BOOTSTRAP_MAPPINGS: Record<string, string>;
3048
+ /**
3049
+ * Pattern-based mappings for Bootstrap
3050
+ *
3051
+ * Applied after explicit mappings for tokens that follow
3052
+ * predictable naming patterns. These handle bulk transformations
3053
+ * for categories with consistent naming.
3054
+ */
3055
+ declare const BOOTSTRAP_PATTERNS: FrameworkMappingPattern[];
3056
+ /**
3057
+ * Bootstrap framework mapping configuration
3058
+ */
3059
+ declare const bootstrapMapper: FrameworkMappingConfig;
3060
+ /**
3061
+ * Apply Bootstrap-specific name mapping to a token name
3062
+ *
3063
+ * @param tokenName - Original token name (e.g., 'typography-heading-h1')
3064
+ * @returns Mapped name (e.g., 'h1-font-size')
3065
+ *
3066
+ * @example
3067
+ * ```typescript
3068
+ * mapToBootstrapName('typography-text-base')
3069
+ * // Returns: 'font-size-base'
3070
+ *
3071
+ * mapToBootstrapName('typography-heading-h1')
3072
+ * // Returns: 'h1-font-size'
3073
+ *
3074
+ * mapToBootstrapName('color-blue-500')
3075
+ * // Returns: 'color-blue-500' (pass through)
3076
+ * ```
3077
+ */
3078
+ declare function mapToBootstrapName(tokenName: string): string;
3079
+
3080
+ /**
3081
+ * shadcn/ui Framework Mapper
3082
+ *
3083
+ * Maps Figma/DTCG token names to shadcn/ui CSS variable names.
3084
+ *
3085
+ * @packageDocumentation
3086
+ */
3087
+
3088
+ /**
3089
+ * Explicit token name → shadcn/ui variable name mappings
3090
+ *
3091
+ * shadcn/ui uses a simplified naming convention with CSS custom properties.
3092
+ * @see https://ui.shadcn.com/docs/theming
3093
+ */
3094
+ declare const SHADCN_MAPPINGS: Record<string, string>;
3095
+ /**
3096
+ * shadcn/ui framework mapping configuration
3097
+ */
3098
+ declare const shadcnMapper: FrameworkMappingConfig;
3099
+ /**
3100
+ * Apply shadcn-specific name mapping to a token name
3101
+ *
3102
+ * @param tokenName - Original token name (e.g., 'semantic-primary')
3103
+ * @returns Mapped name (e.g., 'primary')
3104
+ */
3105
+ declare function mapToShadcnName(tokenName: string): string;
3106
+
3107
+ /**
3108
+ * Framework Mapper Utilities
3109
+ *
3110
+ * Core utilities for applying framework-specific name mappings to tokens.
3111
+ *
3112
+ * @packageDocumentation
3113
+ */
3114
+
3115
+ /**
3116
+ * Framework mapper function type
3117
+ */
3118
+ type FrameworkMapper = (tokenName: string) => string;
3119
+ /**
3120
+ * Framework mapper with configuration
3121
+ */
3122
+ interface FrameworkMapperWithConfig {
3123
+ /** The mapping function */
3124
+ map: FrameworkMapper;
3125
+ /** The framework configuration */
3126
+ config: FrameworkMappingConfig;
3127
+ }
3128
+ /**
3129
+ * Get the framework mapper for a specific target
3130
+ *
3131
+ * @param framework - Target framework
3132
+ * @returns Framework mapper with config
3133
+ */
3134
+ declare function getFrameworkMapper(framework: FrameworkTarget): FrameworkMapperWithConfig;
3135
+ /**
3136
+ * Create a custom framework mapper with user-provided mappings
3137
+ *
3138
+ * @param baseFramework - Base framework to extend (or 'custom' for empty)
3139
+ * @param customMappings - Additional name mappings
3140
+ * @param customPatterns - Additional pattern mappings
3141
+ * @returns Combined framework mapper
3142
+ */
3143
+ declare function createFrameworkMapper(baseFramework: FrameworkTarget, customMappings?: Record<string, string>, customPatterns?: FrameworkMappingPattern[]): FrameworkMapperWithConfig;
3144
+ /**
3145
+ * Apply name mapping to a token name using specified framework
3146
+ *
3147
+ * @param tokenName - Original token name
3148
+ * @param framework - Target framework
3149
+ * @param customMappings - Optional custom mappings to merge
3150
+ * @returns Mapped token name
3151
+ */
3152
+ declare function applyNameMapping(tokenName: string, framework?: FrameworkTarget, customMappings?: Record<string, string>): string;
3153
+
3154
+ /**
3155
+ * Token Diff Utility
3156
+ *
3157
+ * Compares token collections to detect changes for changelog generation.
3158
+ * Identifies added, removed, modified, and type-changed tokens.
3159
+ *
3160
+ * @packageDocumentation
3161
+ */
3162
+
3163
+ /**
3164
+ * Types of changes that can occur to tokens
3165
+ */
3166
+ type TokenChangeType = 'added' | 'removed' | 'modified' | 'type-changed' | 'deprecated';
3167
+ /**
3168
+ * Details about a token value change
3169
+ */
3170
+ interface TokenValueChange {
3171
+ /** Previous value */
3172
+ oldValue: unknown;
3173
+ /** New value */
3174
+ newValue: unknown;
3175
+ /** Previous type */
3176
+ oldType?: string;
3177
+ /** New type */
3178
+ newType?: string;
3179
+ }
3180
+ /**
3181
+ * Information about a single token change
3182
+ */
3183
+ interface TokenChange {
3184
+ /** Full token path (e.g., 'color.brand.primary') */
3185
+ path: string;
3186
+ /** Type of change */
3187
+ type: TokenChangeType;
3188
+ /** Value change details (for modified/type-changed) */
3189
+ valueChange?: TokenValueChange;
3190
+ /** Token description */
3191
+ description?: string;
3192
+ /** Whether this is a breaking change */
3193
+ breaking: boolean;
3194
+ }
3195
+ /**
3196
+ * Result of comparing two token collections
3197
+ */
3198
+ interface TokenDiff {
3199
+ /** Tokens that were added */
3200
+ added: TokenChange[];
3201
+ /** Tokens that were removed */
3202
+ removed: TokenChange[];
3203
+ /** Tokens whose values changed */
3204
+ modified: TokenChange[];
3205
+ /** Tokens whose types changed (breaking) */
3206
+ typeChanged: TokenChange[];
3207
+ /** Tokens marked as deprecated */
3208
+ deprecated: TokenChange[];
3209
+ /** Total number of changes */
3210
+ totalChanges: number;
3211
+ /** Whether there are breaking changes */
3212
+ hasBreaking: boolean;
3213
+ }
3214
+ /**
3215
+ * Compare two token collections and return the differences
3216
+ *
3217
+ * @param oldTokens - Previous version of tokens
3218
+ * @param newTokens - New version of tokens
3219
+ * @returns Detailed diff of all changes
3220
+ */
3221
+ declare function diffTokens(oldTokens: TokenCollection, newTokens: TokenCollection): TokenDiff;
3222
+ /**
3223
+ * Get a summary of changes as a plain text description
3224
+ */
3225
+ declare function summarizeDiff(diff: TokenDiff): string;
3226
+ /**
3227
+ * Filter diff by change type
3228
+ */
3229
+ declare function filterDiff(diff: TokenDiff, types: TokenChangeType[]): TokenChange[];
3230
+ /**
3231
+ * Get only breaking changes
3232
+ */
3233
+ declare function getBreakingChanges(diff: TokenDiff): TokenChange[];
3234
+
3235
+ /**
3236
+ * Token Changelog Generator
3237
+ *
3238
+ * Generates human-readable changelogs from token diffs in Markdown format.
3239
+ *
3240
+ * @packageDocumentation
3241
+ */
3242
+
3243
+ /**
3244
+ * Options for changelog generation
3245
+ */
3246
+ interface ChangelogOptions {
3247
+ /** Version number (e.g., '1.2.0') */
3248
+ version?: string;
3249
+ /** Release date (defaults to today) */
3250
+ date?: Date;
3251
+ /** Custom header for the changelog entry */
3252
+ header?: string;
3253
+ /** Whether to include descriptions */
3254
+ includeDescriptions?: boolean;
3255
+ /** Whether to include value changes (before/after) */
3256
+ includeValues?: boolean;
3257
+ /** Maximum value length to display (truncates longer values) */
3258
+ maxValueLength?: number;
3259
+ /** Whether to group by change type */
3260
+ groupByType?: boolean;
3261
+ }
3262
+ /**
3263
+ * Result of changelog generation
3264
+ */
3265
+ interface ChangelogResult {
3266
+ /** Generated Markdown content */
3267
+ content: string;
3268
+ /** Number of entries in the changelog */
3269
+ entryCount: number;
3270
+ /** Whether there are breaking changes */
3271
+ hasBreaking: boolean;
3272
+ }
3273
+ /**
3274
+ * Generate a changelog entry from a token diff
3275
+ *
3276
+ * @param diff - Token diff to generate changelog from
3277
+ * @param options - Changelog options
3278
+ * @returns Generated changelog content
3279
+ */
3280
+ declare function generateChangelog(diff: TokenDiff, options?: ChangelogOptions): ChangelogResult;
3281
+ /**
3282
+ * Write changelog to file (append mode)
3283
+ *
3284
+ * @param content - Changelog content to write
3285
+ * @param filePath - Path to changelog file
3286
+ * @returns Whether the write was successful
3287
+ */
3288
+ declare function writeChangelog(content: string, filePath: string): Promise<boolean>;
3289
+ /**
3290
+ * Generate and write changelog in one step
3291
+ *
3292
+ * @param diff - Token diff to generate changelog from
3293
+ * @param filePath - Path to changelog file
3294
+ * @param options - Changelog options
3295
+ * @returns Result of changelog generation
3296
+ */
3297
+ declare function generateAndWriteChangelog(diff: TokenDiff, filePath: string, options?: ChangelogOptions): Promise<ChangelogResult & {
3298
+ written: boolean;
3299
+ }>;
3300
+ /**
3301
+ * CLI entry point for generating changelog from two token files
3302
+ *
3303
+ * @param oldTokensPath - Path to old/previous tokens file
3304
+ * @param newTokensPath - Path to new/current tokens file
3305
+ * @param outputPath - Path to changelog file (default: 'TOKENS-CHANGELOG.md')
3306
+ * @param version - Version number for the changelog entry
3307
+ * @returns Whether the operation was successful
3308
+ */
3309
+ declare function generateChangelogCLI(oldTokensPath: string, newTokensPath: string, outputPath?: string, version?: string): Promise<boolean>;
3310
+
3311
+ export { BOOTSTRAP_MAPPINGS, BOOTSTRAP_PATTERNS, type BuildOptions, type BuildResult, type BuildStep, type BundleConfig, type BundleResult, type ChangelogOptions, type ChangelogResult, type CleanOptions, type CleanResult, type CleanedDirectory, type CreateSDConfigOptions, DEFAULT_CLEAN_DIRECTORIES, DEFAULT_FILE_NAMES, type DTCGFile, type DTCGToken, type DTCGTokenCollection, type DiscoveryOptions, type DiscoveryResult, type FigmaCollection, type FigmaExport$1 as FigmaExport, type FigmaExportWithMetadata, type FigmaVariablesResponse, type FilePreprocessingResult, type FormatDefinition, type FrameworkMapper, type FrameworkMapperWithConfig, FrameworkMappingConfig, FrameworkMappingPattern, FrameworkTarget, type LegacyToken, type MergeConfig, type MergeContent, type MergeOptions, type MergeResult, type ModeExtractionOptions, type ModeExtractionResult, type MultiThemeBuildOptions, type MultiThemeBuildResult, type OutputConfig, type PlaceholderValues, type PostprocessOptions, type PostprocessResult, type PreprocessingResult, type PreprocessorConfig, type PreprocessorDefinition, type ReplacementRule, type SDConfig, type SDDictionary, type SDFile, type SDFormatArgs, type SDLogConfig, type SDPlatform, type SDPlatformType, type SDToken, type SDTransformOptions, SHADCN_MAPPINGS, type ValidationError as SchemaValidationError, type ValidationOptions as SchemaValidationOptions, type ValidationResult as SchemaValidationResult, type StyleDictionaryFileConfig, type StyleDictionaryInstance, type StyleDictionaryPlatformConfig, type StyleMergeResult, type StyleScannedFile, type StyleScannerOptions, type StyleScannerResult, type SyncOptions, type SyncResult, type ThemeBuildConfig, type ThemeBuildOptions, type ThemeBuildResult, type ThemeFilesResult, type ThemeStyleDictionaryConfig, type Token, type TokenChange, type TokenChangeType, type TokenCollection, type TokenDiff, type TransformOptions as TokenTransformOptions, type TransformResult as TokenTransformResult, type TokenType, type ValidationResult$1 as TokenValidationResult, type TokenValueChange, type TransformDefinition, type TransformGroupDefinition, type TransformType, VALID_TOKEN_TYPES, type ValidateOptions, type ValidationIssue, type ValidationSeverity, addScssImportHeader, applyNameMapping, autoDetectThemes, bootstrapMapper, buildAllThemes, buildTheme, buildTokens, buildTokensCLI, builtInFormats, builtInPreprocessors, builtInTransforms, cleanTokenOutputs, cleanTokensCLI, createBundle, createBundleFromFiles, createBundles, createFixReferencesPreprocessor, createFrameworkMapper, createOutputConfig, createStyleDictionaryConfig, cssTransformGroup, cssVariablesWithComments, detectModes$1 as detectFigmaModes, detectModes$2 as detectModes, detectModes as detectTransformModes, diffTokens, dimensionRem, discoverThemeFiles, dtcgFileSchema, dtcgTokenCollectionSchema, dtcgTokenSchema, ensureOutputDirs, extractMode, extractModes, figmaExportSchema, figmaExportWithMetadataSchema, figmaVariablesResponseSchema, filterDiff, filterFiles, fixReferences, flattenModeStructure, fontWeightUnitless, generateAndWriteChangelog, generateChangelog, generateChangelogCLI, generateThemeBuildConfig, getBreakingChanges, getCssFormat, getDefaultCssDir, getDefaultFiles, getDefaultIgnorePatterns, getDefaultSyncPaths, getDefaultTransformations, getFrameworkMapper, getPreprocessedFilesForMode, getSDTokenType, getSDTokenValue, getThemeFiles, getThemeSelector, getTokenDescription, getTokenType, getTokenValue, hasDTCGValue, isDTCGToken, isLegacyToken, isSDToken, isToken, isTokenReference, isValidTokenType, jsTransformGroup, lineHeightUnitless, loadContent, mapToBootstrapName, mapToShadcnName, mergeCollections, mergeCollectionsCLI, mergeContent, nameKebab, parseTokenReference, postprocessCLI, postprocessCss, postprocessCssFiles, preprocessFile, preprocessTokenFiles, processScssImportHeader, registerAll, registerFormats, registerPreprocessors, registerTransformGroups, registerTransforms, replacePlaceholders, resolveAllOutputPaths, resolveOutputPath, runBuildCLI, scanDirectories, scssTransformGroup, setupStyleDictionary, shadcnMapper, sortFiles, styleDictionaryInputSchema, styleDictionaryTokenSchema, summarizeDiff, syncTokens, syncTokensCLI, toDTCGToken, transformGroups, transformToken, transformTokenTree, transformTokens, transformTokensCLI, transformType, transformValue, typescriptDeclarations, validateDTCGFile, validateDTCGTokens, validateFigmaCLI, validateFigmaExport, validateFigmaExportWithMetadata, validateFigmaExports, validateFigmaFile, validateFigmaVariablesResponse, validateOutputPaths, validateStyleDictionaryInput, validateStyleDictionaryTokens, validateThemeDefinitions, validateTokens, validateTokensCLI, writeChangelog };