@uzum-tech/design-tokens-resolver 0.0.0-stage → 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ import { ConfigTypes } from '../types/config.types';
2
+ import { ResolveTypes } from '../types/resolve.types';
3
+ export default class CliMapper {
4
+ static toConfig(args: Record<string, string | boolean>, file: ConfigTypes.FileConfig): ConfigTypes.Config;
5
+ static toRequest(args: Record<string, string | boolean>, file: ConfigTypes.FileConfig): ResolveTypes.Request;
6
+ private static toAuth;
7
+ }
@@ -0,0 +1,12 @@
1
+ import { DocumentTypes } from '../types/document.types';
2
+ import { ResolveTypes } from '../types/resolve.types';
3
+ export default class DocumentMapper {
4
+ static toJson(canonical: string, query: ResolveTypes.Query): string;
5
+ static toOutput(document: DocumentTypes.Document, query: ResolveTypes.Query): DocumentTypes.Output;
6
+ private static isCanonical;
7
+ private static toFlatDocument;
8
+ private static toTokens;
9
+ private static toDtcg;
10
+ private static groupByMode;
11
+ private static toTree;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { ReleaseTypes } from '../types/release.types';
2
+ import { ResolveTypes } from '../types/resolve.types';
3
+ export default class LockMapper {
4
+ static toLock(release: ReleaseTypes.Release, source: ResolveTypes.Source): ResolveTypes.Lock;
5
+ static toJson(lock: ResolveTypes.Lock): string;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { DocumentTypes } from '../types/document.types';
2
+ export default class ResolveMapper {
3
+ static toScope(document: DocumentTypes.Document): DocumentTypes.ResolveScope;
4
+ static toLiteralKey(collection: string, mode: string, path: string): string;
5
+ static toTarget(alias: string, state: DocumentTypes.ResolveState): DocumentTypes.ResolveTarget | null;
6
+ }
@@ -0,0 +1,50 @@
1
+ export declare namespace ConfigTypes {
2
+ enum Format {
3
+ FLAT = "FLAT",
4
+ DTCG = "DTCG"
5
+ }
6
+ enum Env {
7
+ LOCAL = "local",
8
+ DEVELOPMENT = "development",
9
+ PRODUCTION = "production"
10
+ }
11
+ interface Auth {
12
+ username: string;
13
+ password: string;
14
+ }
15
+ interface FileConfig {
16
+ env?: Env;
17
+ baseUrl?: string;
18
+ auth?: Auth;
19
+ apiKey?: string;
20
+ requestTimeoutInMs?: number;
21
+ retryCount?: number;
22
+ retryDelayInMs?: number;
23
+ collection?: string;
24
+ outputPath?: string;
25
+ fileName?: string;
26
+ channel?: string;
27
+ }
28
+ interface Config {
29
+ env?: Env;
30
+ baseUrl?: string;
31
+ auth?: Auth;
32
+ apiKey?: string;
33
+ requestTimeoutInMs?: number;
34
+ retryCount?: number;
35
+ retryDelayInMs?: number;
36
+ }
37
+ interface Resolved {
38
+ baseUrl: string;
39
+ auth: Auth | null;
40
+ apiKey: string | null;
41
+ requestTimeoutInMs: number;
42
+ retryCount: number;
43
+ retryDelayInMs: number;
44
+ }
45
+ interface LoadedFile {
46
+ path: string;
47
+ config: FileConfig;
48
+ }
49
+ type FileExport = FileConfig | (() => FileConfig) | (() => Promise<FileConfig>);
50
+ }
@@ -0,0 +1,65 @@
1
+ export declare namespace DocumentTypes {
2
+ interface RawValueObject {
3
+ [key: string]: RawValue;
4
+ }
5
+ interface Mode {
6
+ slug: string;
7
+ name: string;
8
+ brand: string | null;
9
+ theme: string | null;
10
+ isDefault: boolean;
11
+ }
12
+ interface Collection {
13
+ slug: string;
14
+ name: string;
15
+ description: string | null;
16
+ layout: string;
17
+ modes: Mode[];
18
+ }
19
+ interface Token {
20
+ collection: string;
21
+ mode: string;
22
+ path: string;
23
+ $type: string;
24
+ $value: RawValue;
25
+ }
26
+ interface Document {
27
+ schemaVersion: number;
28
+ collections: Collection[];
29
+ tokens: Token[];
30
+ }
31
+ interface DtcgNode {
32
+ $type: string;
33
+ $value: RawValue;
34
+ }
35
+ interface DtcgEntry {
36
+ path: string;
37
+ node: DtcgNode;
38
+ }
39
+ interface DtcgGroup {
40
+ [key: string]: DtcgGroup | DtcgNode;
41
+ }
42
+ interface CollectionModes {
43
+ slugs: Set<string>;
44
+ defaultSlug: string;
45
+ }
46
+ interface ResolveScope {
47
+ literals: Record<string, RawValue>;
48
+ modes: Record<string, CollectionModes>;
49
+ }
50
+ interface ResolvePoint {
51
+ collection: string;
52
+ mode: string;
53
+ }
54
+ interface ResolveState {
55
+ scope: ResolveScope;
56
+ point: ResolvePoint;
57
+ depth: number;
58
+ }
59
+ interface ResolveTarget {
60
+ path: string;
61
+ point: ResolvePoint;
62
+ }
63
+ type RawValue = string | number | boolean | RawValueObject | RawValue[] | null;
64
+ type Output = Document | DtcgGroup;
65
+ }
@@ -0,0 +1,17 @@
1
+ import { HttpTypes } from './http.types';
2
+ export declare namespace ErrorTypes {
3
+ enum Code {
4
+ CONFIG_INVALID = "CONFIG_INVALID",
5
+ REQUEST_FAILED = "REQUEST_FAILED",
6
+ RELEASE_NOT_FOUND = "RELEASE_NOT_FOUND",
7
+ CHANNEL_EMPTY = "CHANNEL_EMPTY",
8
+ INTEGRITY_MISMATCH = "INTEGRITY_MISMATCH",
9
+ WRITE_FAILED = "WRITE_FAILED"
10
+ }
11
+ interface Options {
12
+ code: Code;
13
+ cause?: unknown;
14
+ statusCode?: HttpTypes.Status;
15
+ body?: unknown;
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ export declare namespace HttpTypes {
2
+ enum Status {
3
+ UNAUTHORIZED = 401,
4
+ NOT_FOUND = 404,
5
+ TOO_MANY_REQUESTS = 429,
6
+ INTERNAL_SERVER_ERROR = 500
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ export * from './config.types';
2
+ export * from './document.types';
3
+ export * from './error.types';
4
+ export * from './http.types';
5
+ export * from './release.types';
6
+ export * from './resolve.types';
@@ -0,0 +1,31 @@
1
+ export declare namespace ReleaseTypes {
2
+ interface Stats {
3
+ collections: number;
4
+ modes: number;
5
+ tokens: number;
6
+ values: number;
7
+ }
8
+ interface Release {
9
+ version: string;
10
+ status: string;
11
+ contentHash: string;
12
+ parentVersion: string | null;
13
+ stats: Stats | null;
14
+ byteSize: number | null;
15
+ notes: string | null;
16
+ sourceLabel: string | null;
17
+ publishedBy: string | null;
18
+ createdAt: string;
19
+ }
20
+ interface Payload {
21
+ version: string;
22
+ document: string;
23
+ contentHash: string;
24
+ }
25
+ interface Channel {
26
+ slug: string;
27
+ name: string;
28
+ version: string | null;
29
+ locked: boolean | null;
30
+ }
31
+ }
@@ -0,0 +1,41 @@
1
+ import { ConfigTypes } from './config.types';
2
+ import { ReleaseTypes } from './release.types';
3
+ export declare namespace ResolveTypes {
4
+ interface Query {
5
+ collection?: string;
6
+ format?: ConfigTypes.Format;
7
+ resolve?: boolean;
8
+ }
9
+ interface Target extends Query {
10
+ version?: string;
11
+ channel?: string;
12
+ }
13
+ interface Request extends Target {
14
+ outputPath: string;
15
+ fileName?: string;
16
+ lock?: boolean;
17
+ }
18
+ interface Verified {
19
+ release: ReleaseTypes.Release;
20
+ body: string;
21
+ }
22
+ interface Source {
23
+ baseUrl: string;
24
+ }
25
+ interface Lock {
26
+ version: string;
27
+ contentHash: string;
28
+ baseUrl: string;
29
+ byteSize: number | null;
30
+ publishedAt: string;
31
+ publishedBy: string | null;
32
+ sourceLabel: string | null;
33
+ }
34
+ interface Result {
35
+ release: ReleaseTypes.Release;
36
+ source: Source;
37
+ tokensPath: string;
38
+ lockPath: string | null;
39
+ bytesWritten: number;
40
+ }
41
+ }
@@ -0,0 +1,9 @@
1
+ import { ConfigTypes } from '../types/config.types';
2
+ export default class ArgsUtils {
3
+ static parse(args: string[]): Record<string, string | boolean>;
4
+ static toFormat(value?: string | boolean): ConfigTypes.Format | undefined;
5
+ static toEnv(value?: string | boolean): ConfigTypes.Env | undefined;
6
+ static toText(value?: string | boolean): string | undefined;
7
+ private static toNormalized;
8
+ private static toKey;
9
+ }
@@ -0,0 +1,3 @@
1
+ export default class FileUtils {
2
+ static write(outputPath: string, fileName: string, body: string): string;
3
+ }
@@ -0,0 +1,3 @@
1
+ export default class HashUtils {
2
+ static toContentHash(body: string): string;
3
+ }
@@ -0,0 +1,6 @@
1
+ import { DocumentTypes } from '../types/document.types';
2
+ export default class ResolveUtils {
3
+ static resolve(value: DocumentTypes.RawValue, state: DocumentTypes.ResolveState): DocumentTypes.RawValue;
4
+ private static parseAlias;
5
+ private static resolveAlias;
6
+ }
@@ -0,0 +1,4 @@
1
+ export default class UrlUtils {
2
+ static join(...parts: string[]): string;
3
+ static toQuery(params: Record<string, string | boolean | undefined>): string;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
2
  "name": "@uzum-tech/design-tokens-resolver",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Fetches published design tokens from the design tokens service by version or channel, verifies content integrity and writes them to disk",
5
+ "type": "commonjs",
6
+ "main": "./lib/index.cjs",
7
+ "module": "./lib/index.mjs",
8
+ "types": "./lib/index.d.ts",
9
+ "bin": {
10
+ "design-tokens-resolver": "./lib/cli.cjs"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./lib/index.d.ts",
15
+ "import": "./lib/index.mjs",
16
+ "require": "./lib/index.cjs",
17
+ "default": "./lib/index.cjs"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "lib"
23
+ ],
24
+ "sideEffects": false,
25
+ "engines": {
26
+ "node": ">=20.18.1"
27
+ },
28
+ "packageManager": "pnpm@10.9.0",
29
+ "scripts": {
30
+ "clean": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\"",
31
+ "build:types": "tsc -p tsconfig.types.json",
32
+ "build:js": "node esbuild.config.mjs",
33
+ "build": "pnpm clean && pnpm build:types && pnpm build:js",
34
+ "prepare": "husky install",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit",
36
+ "lint": "eslint .",
37
+ "lint:fix": "pnpm lint --fix",
38
+ "test:build": "node esbuild.config.mjs --out-dir .test-build",
39
+ "test": "pnpm test:build && node --test \"tests/**/*.test.mjs\"",
40
+ "prepack": "npm login && pnpm i && pnpm build",
41
+ "test:watch": "pnpm test:build && node --test --watch \"tests/**/*.test.mjs\"",
42
+ "precommit": "concurrently --kill-others-on-fail \"pnpm typecheck\" \"lint-staged\" \"pnpm test\""
43
+ },
44
+ "keywords": [
45
+ "uzum",
46
+ "design-tokens",
47
+ "dtcg",
48
+ "figma",
49
+ "cli"
50
+ ],
51
+ "author": {
52
+ "name": "KapitalLab"
53
+ },
54
+ "contributors": [
55
+ {
56
+ "name": "Mardonov Baxtiyor",
57
+ "email": "jbalancer@mail.ru",
58
+ "url": "https://jbalancer.com"
59
+ }
60
+ ],
61
+ "license": "MIT",
62
+ "devDependencies": {
63
+ "@types/node": "20.11.5",
64
+ "@uzum-tech/eslint": "1.1.2",
65
+ "esbuild": "0.27.2",
66
+ "typescript": "5.7.3",
67
+ "concurrently": "9.1.2",
68
+ "lint-staged": "15.3.0",
69
+ "husky": "8.0.0"
70
+ },
71
+ "pnpm": {
72
+ "onlyBuiltDependencies": [
73
+ "esbuild"
74
+ ],
75
+ "overrides": {
76
+ "putout": "42.5.1",
77
+ "@putout/processor-toml": "1.1.20"
78
+ }
79
+ }
80
+ }