@usefidel/contracts 0.1.0 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { RUN_ERROR_CODES, ERROR_CODE_META, mapSnapshotErrorToCode, mapFigmaErrorToCode, resolveRunDisplay, } from './run-errors.js';
2
2
  export type { RunErrorCode, RunErrorMeta, ErrorMapping, RunDisplay, } from './run-errors.js';
3
+ export type { IntakeFramework, UnsupportedStack, UnsupportedReason, UnresolvedReferenceSection, UnresolvedReferenceReason, UnresolvedReference, ParsedThemeColor, ParsedThemeTypography, ParsedThemeSize, ShadcnConfig, ParsedTheme, IntakeDetection, TokenSourceKind, TokenSource, PackageRole, PackageInfo, } from './theme-intake.js';
@@ -0,0 +1,160 @@
1
+ /**
2
+ * theme-intake — the wire contract for the `theme-intake` edge function's
3
+ * response, as consumed by the webapp.
4
+ *
5
+ * THIS FILE IS THE CONTRACT, NOT A MIRROR OF ONE FILE.
6
+ * ────────────────────────────────────────────────────
7
+ * The shape is assembled from TWO backend sources, which is why it can never be
8
+ * a byte-copy the way `run-errors.ts` is:
9
+ *
10
+ * 1. `supabase/functions/_shared/theme-parser/types.ts` — the ParsedTheme core.
11
+ * That file also declares parser INTERNALS (RawToken's full shape,
12
+ * SEMANTIC_COLOR_NAMES) which are deliberately NOT re-exported here: this
13
+ * package is installable by a contractor, so it carries the wire and
14
+ * nothing else.
15
+ *
16
+ * 2. `supabase/functions/theme-intake/index.ts` — adds three W3d fields to the
17
+ * response at the edge boundary: `tokenSources`, `packages`,
18
+ * `tokenSourcesTruncated`.
19
+ *
20
+ * Some type NAMES differ from the backend's on purpose (ColorToken →
21
+ * ParsedThemeColor, etc.); the FIELD names are what must stay in lockstep,
22
+ * because those are what cross the wire.
23
+ *
24
+ * ENFORCEMENT. `scripts/check-canonical-sync.mjs` asserts structurally that
25
+ * ParsedTheme here declares every field of the canonical ParsedTheme plus
26
+ * exactly the W3d extension fields. It runs in the monorepo merge gate and again
27
+ * in the publisher workflow at the pinned SHA before publishing.
28
+ *
29
+ * HISTORY. Until #591 this lived at `webapp/src/types/theme-intake.ts` with a
30
+ * `vendor-sync.config.json` pair pointing only at source (1). #591 moved webapp/
31
+ * to usefidel/fidel-web and the pair was deleted rather than migrated, leaving
32
+ * the contract spanning two repositories with nothing checking it. Recorded as
33
+ * `theme-intake-wire-contract-unguarded` (#601); this file closes it.
34
+ */
35
+ export type IntakeFramework = 'next' | 'remix' | 'astro' | 'sveltekit' | 'solidstart' | 'vite' | 'react' | 'unknown';
36
+ export type UnsupportedStack = 'chakra' | 'mui' | 'mantine' | 'antd' | 'radix-themes' | 'stitches' | 'vanilla-extract' | 'panda' | 'styled-components' | 'emotion';
37
+ export type UnsupportedReason = 'tailwind-v3-needs-js-eval' | 'tailwind-version-unknown' | 'no-token-sources' | 'token-values-not-parsed';
38
+ export type UnresolvedReferenceSection = 'colors' | 'fontFamily' | 'fontSize' | 'spacing' | 'borderRadius' | 'lineHeight' | 'letterSpacing' | 'fontWeight' | 'boxShadow' | 'dropShadow' | 'presets' | 'plugins' | 'other';
39
+ export type UnresolvedReferenceReason = 'imported_value' | 'computed_expression' | 'function_call' | 'preset_referenced' | 'plugin_referenced' | 'unparseable';
40
+ export interface UnresolvedReference {
41
+ section: UnresolvedReferenceSection;
42
+ reason: UnresolvedReferenceReason;
43
+ detail: string;
44
+ }
45
+ export interface ParsedThemeColor {
46
+ name: string;
47
+ value: string;
48
+ source: string;
49
+ layer: 'theme' | 'root';
50
+ resolved: string | null;
51
+ resolveTrail: string[];
52
+ /** Where the resolved value came from. */
53
+ resolvedFrom: 'user' | 'tailwind-default' | null;
54
+ /** sRGB hex (`#rrggbb`) for swatch rendering, or null when format unsupported. PR 27-06. */
55
+ srgb: string | null;
56
+ }
57
+ export interface ParsedThemeTypography {
58
+ name: string;
59
+ value: string;
60
+ source: string;
61
+ kind: 'family' | 'size' | 'weight' | 'leading' | 'tracking' | 'other';
62
+ }
63
+ export interface ParsedThemeSize {
64
+ category: string;
65
+ name: string;
66
+ /** Resolved value — `var(--X)` and `calc(var(--X) * N)` references are
67
+ * walked and computed against other tokens before the row is rendered.
68
+ * Falls back to the raw value when a reference can't be resolved. */
69
+ value: string;
70
+ /** Original CSS authoring value when resolution changed it. Optional —
71
+ * populated only when the resolved value differs from the source. */
72
+ raw_value?: string;
73
+ source: string;
74
+ }
75
+ export interface ShadcnConfig {
76
+ style: string | null;
77
+ rsc: boolean | null;
78
+ tsx: boolean | null;
79
+ tailwind: {
80
+ config: string | null;
81
+ css: string | null;
82
+ baseColor: string | null;
83
+ cssVariables: boolean | null;
84
+ prefix: string | null;
85
+ } | null;
86
+ aliases: {
87
+ components: string | null;
88
+ utils: string | null;
89
+ ui: string | null;
90
+ lib: string | null;
91
+ hooks: string | null;
92
+ } | null;
93
+ iconLibrary: string | null;
94
+ }
95
+ export interface ParsedTheme {
96
+ tailwindVersion: 'v3' | 'v4' | 'unknown';
97
+ unsupported_reason: UnsupportedReason | null;
98
+ rawTokens: unknown[];
99
+ colors: ParsedThemeColor[];
100
+ typography: ParsedThemeTypography[];
101
+ sizes: ParsedThemeSize[];
102
+ files: string[];
103
+ unresolvedImports: string[];
104
+ references_default_palette: boolean;
105
+ shadcn: ShadcnConfig | null;
106
+ counts: {
107
+ colors: number;
108
+ typography: number;
109
+ sizes: number;
110
+ rawTokens: number;
111
+ };
112
+ unresolvedReferences?: UnresolvedReference[];
113
+ tokenSources?: TokenSource[];
114
+ packages?: PackageInfo[];
115
+ tokenSourcesTruncated?: boolean;
116
+ }
117
+ export interface IntakeDetection {
118
+ ref: string;
119
+ detected_at: string;
120
+ framework: IntakeFramework;
121
+ tailwind_version: 'v3' | 'v4' | 'unknown' | null;
122
+ has_shadcn: boolean;
123
+ unsupported_stack: UnsupportedStack | null;
124
+ files_found: string[];
125
+ files_missing: string[];
126
+ errors: {
127
+ path: string;
128
+ code: string;
129
+ }[];
130
+ hints: {
131
+ tailwind_config_path: string | null;
132
+ components_json_path: string | null;
133
+ globals_css_path: string | null;
134
+ css_token_files: string[];
135
+ };
136
+ recursive_discovery: boolean;
137
+ tree_truncated: boolean;
138
+ parsed_theme: ParsedTheme | null;
139
+ }
140
+ export type TokenSourceKind = 'tailwind-config' | 'tailwind-v4-css' | 'style-dictionary' | 'token-json' | 'css-variables';
141
+ export interface TokenSource {
142
+ kind: TokenSourceKind;
143
+ /** Config file or representative file (GitHub tree path). */
144
+ path: string;
145
+ /** Owning workspace package name; null = repo root, no package ownership. */
146
+ packageName: string | null;
147
+ counts: {
148
+ tokens?: number;
149
+ customProperties?: number;
150
+ files?: number;
151
+ };
152
+ /** True only when values made it into parsed_theme.modes. */
153
+ parsed: boolean;
154
+ }
155
+ export type PackageRole = 'components' | 'tokens' | 'assets' | 'utilities' | 'docs' | 'unknown';
156
+ export interface PackageInfo {
157
+ name: string;
158
+ path: string;
159
+ role: PackageRole;
160
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * theme-intake — the wire contract for the `theme-intake` edge function's
3
+ * response, as consumed by the webapp.
4
+ *
5
+ * THIS FILE IS THE CONTRACT, NOT A MIRROR OF ONE FILE.
6
+ * ────────────────────────────────────────────────────
7
+ * The shape is assembled from TWO backend sources, which is why it can never be
8
+ * a byte-copy the way `run-errors.ts` is:
9
+ *
10
+ * 1. `supabase/functions/_shared/theme-parser/types.ts` — the ParsedTheme core.
11
+ * That file also declares parser INTERNALS (RawToken's full shape,
12
+ * SEMANTIC_COLOR_NAMES) which are deliberately NOT re-exported here: this
13
+ * package is installable by a contractor, so it carries the wire and
14
+ * nothing else.
15
+ *
16
+ * 2. `supabase/functions/theme-intake/index.ts` — adds three W3d fields to the
17
+ * response at the edge boundary: `tokenSources`, `packages`,
18
+ * `tokenSourcesTruncated`.
19
+ *
20
+ * Some type NAMES differ from the backend's on purpose (ColorToken →
21
+ * ParsedThemeColor, etc.); the FIELD names are what must stay in lockstep,
22
+ * because those are what cross the wire.
23
+ *
24
+ * ENFORCEMENT. `scripts/check-canonical-sync.mjs` asserts structurally that
25
+ * ParsedTheme here declares every field of the canonical ParsedTheme plus
26
+ * exactly the W3d extension fields. It runs in the monorepo merge gate and again
27
+ * in the publisher workflow at the pinned SHA before publishing.
28
+ *
29
+ * HISTORY. Until #591 this lived at `webapp/src/types/theme-intake.ts` with a
30
+ * `vendor-sync.config.json` pair pointing only at source (1). #591 moved webapp/
31
+ * to usefidel/fidel-web and the pair was deleted rather than migrated, leaving
32
+ * the contract spanning two repositories with nothing checking it. Recorded as
33
+ * `theme-intake-wire-contract-unguarded` (#601); this file closes it.
34
+ */
35
+ export {};
package/package.json CHANGED
@@ -7,8 +7,8 @@
7
7
  "The source of truth still lives in the monorepo at packages/contracts/."
8
8
  ],
9
9
  "name": "@usefidel/contracts",
10
- "version": "0.1.0",
11
- "description": "Shared, code-free contracts between Fidel surfaces. Run-error taxonomy only.",
10
+ "version": "0.2.0",
11
+ "description": "Shared, code-free contracts between Fidel surfaces. Run-error taxonomy and theme-intake wire types.",
12
12
  "license": "UNLICENSED",
13
13
  "private": false,
14
14
  "type": "module",
@@ -23,6 +23,10 @@
23
23
  "./run-errors": {
24
24
  "types": "./dist/run-errors.d.ts",
25
25
  "import": "./dist/run-errors.js"
26
+ },
27
+ "./theme-intake": {
28
+ "types": "./dist/theme-intake.d.ts",
29
+ "import": "./dist/theme-intake.js"
26
30
  }
27
31
  },
28
32
  "files": [