@bridge-ds/core 0.18.0 → 0.19.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.
Files changed (63) hide show
  1. package/bridge.config.schema.json +16 -0
  2. package/dist/audit/index.js +3 -3
  3. package/dist/audit/report.d.ts +17 -2
  4. package/dist/branch-actions.d.ts +7 -1
  5. package/dist/build-requests-github.d.ts +25 -0
  6. package/dist/build-requests.d.ts +403 -0
  7. package/dist/changelog-model.d.ts +102 -0
  8. package/dist/component-spec.d.ts +3 -1
  9. package/dist/config.d.ts +21 -0
  10. package/dist/css-color.d.ts +25 -0
  11. package/dist/docs-proposal.d.ts +1 -0
  12. package/dist/explorations.d.ts +1 -0
  13. package/dist/fidelity-references.d.ts +12 -0
  14. package/dist/figma-fix-loop.d.ts +153 -0
  15. package/dist/figma-fixes.d.ts +169 -0
  16. package/dist/figma-push-github.d.ts +7 -2
  17. package/dist/figma-push.d.ts +15 -2
  18. package/dist/gap-case.d.ts +144 -0
  19. package/dist/github-client.d.ts +31 -0
  20. package/dist/id-map.d.ts +10 -0
  21. package/dist/index.d.ts +13 -0
  22. package/dist/index.js +3412 -658
  23. package/dist/index.js.map +1 -1
  24. package/dist/layered-review.d.ts +2 -0
  25. package/dist/measure-status.d.ts +127 -0
  26. package/dist/measured-only.d.ts +28 -0
  27. package/dist/measured-spec.d.ts +349 -0
  28. package/dist/measured-tokens.d.ts +25 -0
  29. package/dist/motion-docs.d.ts +51 -0
  30. package/dist/node/audit.d.ts +11 -3
  31. package/dist/node/index.d.ts +1 -0
  32. package/dist/node/index.js +1637 -24
  33. package/dist/node/index.js.map +1 -1
  34. package/dist/node/measure-script.d.ts +1 -0
  35. package/dist/node/measure.d.ts +212 -0
  36. package/dist/node/spec-css.d.ts +9 -1
  37. package/dist/node/tokens-script.d.ts +3 -0
  38. package/dist/pr-composer.d.ts +5 -0
  39. package/dist/previews.d.ts +4 -1
  40. package/dist/{prod-branch-DenQkr_e.js → prod-branch-Bdx_2bRQ.js} +197 -159
  41. package/dist/prod-branch-Bdx_2bRQ.js.map +1 -0
  42. package/dist/prod-branch.d.ts +1 -1
  43. package/dist/repo-model.d.ts +5 -1
  44. package/dist/repo-source-github.d.ts +8 -0
  45. package/dist/{repo-source-CRfhLO87.js → repo-source-m0Tc603o.js} +1406 -629
  46. package/dist/repo-source-m0Tc603o.js.map +1 -0
  47. package/dist/repo-source.d.ts +6 -0
  48. package/dist/{report-DVEmUr0p.js → report-DFPKygfk.js} +17 -6
  49. package/dist/{report-DVEmUr0p.js.map → report-DFPKygfk.js.map} +1 -1
  50. package/dist/requester.d.ts +14 -0
  51. package/dist/requests.d.ts +2 -0
  52. package/dist/review-gate.d.ts +183 -2
  53. package/dist/risk.d.ts +12 -0
  54. package/dist/share-branch.d.ts +1 -1
  55. package/dist/snapshot.d.ts +34 -0
  56. package/dist/suggestion-review.d.ts +2 -0
  57. package/dist/suggestions-github.d.ts +21 -0
  58. package/dist/suggestions.d.ts +6 -0
  59. package/dist/token-proposal.d.ts +7 -0
  60. package/dist/try-in-product.d.ts +9 -0
  61. package/package.json +1 -1
  62. package/dist/prod-branch-DenQkr_e.js.map +0 -1
  63. package/dist/repo-source-CRfhLO87.js.map +0 -1
@@ -0,0 +1,144 @@
1
+ import { type ComponentSpec, type SpecField, type SpecPart, type SpecValue, type SpecVariant } from './component-spec';
2
+ import type { FidelityComponentResult, Size } from './fidelity';
3
+ import { type MeasuredBox, type MeasuredSpec, type MeasuredSpecsFile, type MeasuredSpecsStory, type MeasuredState } from './measured-spec';
4
+ export declare const GAP_CASE_VERSION = 1;
5
+ /** How a story reaches a variant: at rest, a forced pseudo state, or disabled (an arg). */
6
+ export type GapState = 'rest' | MeasuredState | 'disabled';
7
+ /**
8
+ * What a difference is about. A Figma field (fill, paddingTop, cornerRadius, height...), or: `presence` (a part one side
9
+ * draws and the other does not), `sizing` (fixed in code, hugging in Figma), `direction` (auto layout direction).
10
+ */
11
+ export type GapProperty = SpecField | 'presence' | 'sizing' | 'direction';
12
+ /** One concrete difference. `expected` is the code (the measure), `actual` is Figma (what was drawn). */
13
+ export interface GapDifference {
14
+ /** Plain words: "Height 72 in Figma vs 84 in code: 12 px missing below the label wrapper". */
15
+ text: string;
16
+ /** Part id, as the measure and the built set name it ("root", "cds--toggle-switch"). */
17
+ part: string;
18
+ /** The part in words ("toggle switch"). */
19
+ partName: string;
20
+ property: GapProperty;
21
+ /** Code: token path, px number, null (no paint), `present`, `fixed`, `HORIZONTAL`... */
22
+ expected: SpecValue | boolean;
23
+ /** Figma: the same kinds, `missing`, `hidden`, `hug`... */
24
+ actual: SpecValue | boolean;
25
+ /** Numbers: actual minus expected, px (negative: Figma is smaller). */
26
+ delta?: number | undefined;
27
+ }
28
+ export interface GapStoryRef {
29
+ /** Storybook story id. */
30
+ id: string;
31
+ name?: string | undefined;
32
+ /** Story URL the measure opened (args in it). */
33
+ url?: string | undefined;
34
+ /** The props it rendered with (args over the component defaults), and the args Bridge passed to reach the variant. */
35
+ props: Record<string, string | number | boolean>;
36
+ overrides?: Record<string, string | number | boolean> | undefined;
37
+ state: GapState;
38
+ }
39
+ export interface GapVariant {
40
+ /** Figma variant key (variantKeyOf: "Size=md, State=Default"). */
41
+ key: string;
42
+ /** Figma props of the variant. */
43
+ props: Record<string, string>;
44
+ /** The referee's verdict for this variant: the plugin's Check fidelity (`unchecked` without one). */
45
+ verdict: 'differs' | 'unchecked';
46
+ /** Different pixels in percent, and both sizes, when the shot was compared. */
47
+ percent?: number | undefined;
48
+ size?: {
49
+ figma: Size;
50
+ code: Size;
51
+ } | undefined;
52
+ story?: GapStoryRef | undefined;
53
+ /** The story's screenshot, relative to measured-specs.json (the referee image). */
54
+ shot?: string | undefined;
55
+ /** What Figma drew for this variant: a node id or an exported PNG, when the plugin passes one. */
56
+ figmaRender?: string | undefined;
57
+ differences: GapDifference[];
58
+ /** Why the list is empty when the shots differ: no story, or the measure agrees and only the images tell. */
59
+ unexplained?: string | undefined;
60
+ }
61
+ export interface GapCase {
62
+ version: typeof GAP_CASE_VERSION;
63
+ component: string;
64
+ storybook: string;
65
+ /** `shots`: the variants come from the fidelity check. `values`: no check was passed, variants with differences. */
66
+ referee: 'shots' | 'values';
67
+ /** Variants compared, and how many differ. */
68
+ checked: number;
69
+ differing: number;
70
+ /** One sentence for a designer. */
71
+ summary: string;
72
+ /** Lines for a developer (or Claude): story, args, state, shot and every delta per variant. */
73
+ detail: string;
74
+ variants: GapVariant[];
75
+ /** Fixes from figma-fixes.json already applied to this component (the patched measure says so). */
76
+ fixes?: string[] | undefined;
77
+ }
78
+ /** What the plugin reads back from one drawn variant, laid over the spec it drew from. All optional. */
79
+ export interface GapBuiltVariant {
80
+ /** Field values the layers hold (part id -> field -> value), when they differ from the spec's. */
81
+ values?: SpecVariant['values'] | undefined;
82
+ /** Parts hidden in this variant. */
83
+ hidden?: string[] | undefined;
84
+ /** Part id -> its box relative to the variant's top-left, px: lets the gap say where space is missing. */
85
+ boxes?: Record<string, MeasuredBox> | undefined;
86
+ }
87
+ export interface GapCaseInput {
88
+ /** Set name ("Toggle"): the last segment of the stories' title. */
89
+ component: string;
90
+ measured: MeasuredSpecsFile;
91
+ /** What the pull drew the set from (specsFromMeasure's spec, or the overlaid static spec). */
92
+ spec?: ComponentSpec | undefined;
93
+ /** The plugin's Check fidelity result for this set: the referee. */
94
+ fidelity?: FidelityComponentResult | undefined;
95
+ /** Variant key -> what the layers read back. */
96
+ built?: Record<string, GapBuiltVariant> | undefined;
97
+ /** Variant key -> the story shot the set was compared with (MeasuredShots[set]). */
98
+ shots?: Record<string, {
99
+ file: string;
100
+ }> | undefined;
101
+ /** Variant key -> a reference to what Figma drew (node id, PNG path). */
102
+ figmaRenders?: Record<string, string> | undefined;
103
+ /** Token path -> its value in the measured page. Default: the measure's resolved values and token harvest. */
104
+ resolve?: ((tokenPath: string) => string | number | undefined) | undefined;
105
+ }
106
+ /** The stories of a set: the last title segment, case and punctuation ignored. */
107
+ export declare function storiesOfComponent(file: Pick<MeasuredSpecsFile, 'stories'>, component: string): MeasuredSpecsStory[];
108
+ /** A story's state: its forced pseudo state, else disabled when the arg says so, else at rest. */
109
+ export declare function storyState(s: Pick<MeasuredSpecsStory, 'state' | 'props' | 'overrides'>): GapState;
110
+ /**
111
+ * The story a Figma variant was drawn from: the one whose shot it was compared with, else the first (single instance
112
+ * before galleries) whose props, overrides and state give the variant's axis values.
113
+ */
114
+ export declare function storyForVariant(spec: Pick<ComponentSpec, 'axes'>, props: Record<string, string>, stories: MeasuredSpecsStory[], shot?: {
115
+ file: string;
116
+ }): MeasuredSpecsStory | undefined;
117
+ /** A part in words: the measure's ids are class names ("cds--toggle__switch" -> "toggle switch"). */
118
+ export declare function partWords(part: Pick<SpecPart, 'id' | 'name'> | undefined, id?: string): string;
119
+ /** Token path -> value, from the measure: components[].resolved, then the token harvest (by CSS name). */
120
+ export declare function measuredResolver(file: Pick<MeasuredSpecsFile, 'components' | 'tokens'>): (path: string) => string | number | undefined;
121
+ export interface VariantGapInput {
122
+ /** The parts the set was drawn with, and this variant's values and hidden parts. */
123
+ parts: SpecPart[];
124
+ variant: Pick<SpecVariant, 'values' | 'hidden' | 'layout'>;
125
+ properties?: ComponentSpec['properties'] | undefined;
126
+ built?: GapBuiltVariant | undefined;
127
+ measured: MeasuredSpec;
128
+ /** The fidelity check's sizes (CSS px), when the shot was compared. */
129
+ size?: {
130
+ figma: Size;
131
+ code: Size;
132
+ } | undefined;
133
+ resolve?: ((tokenPath: string) => string | number | undefined) | undefined;
134
+ }
135
+ /**
136
+ * The differences between what Figma drew for one variant and what the code renders (its measured story): the size and
137
+ * where it comes from, parts one side lacks, fixed sizes Figma hugs, auto layout direction, then field values.
138
+ */
139
+ export declare function variantDifferences(input: VariantGapInput): GapDifference[];
140
+ /**
141
+ * The gap case of one component: the variants the referee says differ (the fidelity check; without one, every variant
142
+ * with a difference), each with its story, args, state, shot, Figma render and the differences in words and deltas.
143
+ */
144
+ export declare function buildGapCase(input: GapCaseInput): GapCase;
@@ -15,6 +15,8 @@ export interface GitHubErrorInfo {
15
15
  auth?: GitHubAuthState | undefined;
16
16
  /** The permission the call needed, when GitHub or the endpoint tells (only with auth "missing-permission"). */
17
17
  permission?: GitHubPermission | undefined;
18
+ /** For a rate limit (status 429): when the limit resets, when GitHub or Bridge said. */
19
+ resetsAt?: Date | undefined;
18
20
  }
19
21
  export declare class GitHubError extends Error {
20
22
  readonly status: number;
@@ -23,6 +25,8 @@ export declare class GitHubError extends Error {
23
25
  readonly auth: GitHubAuthState | undefined;
24
26
  /** With auth "missing-permission": the permission the call needed, when known. */
25
27
  readonly permission: GitHubPermission | undefined;
28
+ /** For a rate limit (status 429): when the limit resets, when known. */
29
+ readonly resetsAt: Date | undefined;
26
30
  constructor(status: number, message: string, detail?: string | undefined, info?: GitHubErrorInfo);
27
31
  }
28
32
  /** True when `err` says GitHub refused the token itself (revoked, regenerated or expired). */
@@ -96,6 +100,8 @@ export interface Review {
96
100
  state: string;
97
101
  body: string;
98
102
  submittedAt?: string | undefined;
103
+ /** The commit the review was given on (GitHub `commit_id`). */
104
+ commitId?: string | undefined;
99
105
  }
100
106
  export interface PullRequestSummary {
101
107
  number: number;
@@ -112,6 +118,11 @@ export interface PullRequestSummary {
112
118
  updatedAt: string;
113
119
  /** Description, when the list endpoint returns it (component change requests read "Closes #n" from it). */
114
120
  body?: string | undefined;
121
+ /** ISO dates, when GitHub returns them (build requests: in progress since, shipped on). */
122
+ createdAt?: string | undefined;
123
+ mergedAt?: string | undefined;
124
+ /** Who is assigned (logins), when any. */
125
+ assignees?: string[] | undefined;
115
126
  }
116
127
  export interface ClientOptions {
117
128
  /** API base, for GitHub Enterprise or tests. */
@@ -340,8 +351,23 @@ export declare class GitHubClient {
340
351
  */
341
352
  private paged;
342
353
  getRepo(): Promise<RepoInfo>;
354
+ /**
355
+ * What the token may write here, found without writing anything: each probe is invalid on purpose (a zero sha, a
356
+ * missing head branch, an empty title), so GitHub answers 422 when the token has the permission and 403 or 404 when
357
+ * it does not. repo.permissions.push says what the user may do, not what a fine-grained token may do.
358
+ */
359
+ writeAccess(base: string): Promise<{
360
+ contents: boolean;
361
+ pullRequests: boolean;
362
+ issues: boolean;
363
+ }>;
343
364
  /** Commit sha a branch points to, or undefined when the branch does not exist. */
344
365
  getBranchSha(branch: string): Promise<string | undefined>;
366
+ /**
367
+ * Whether a branch exists, through the matching-refs list: it answers 200 with an empty list when the branch is
368
+ * missing, so asking never leaves a 404 in the browser console (an optional branch like bridge-data).
369
+ */
370
+ hasBranch(branch: string): Promise<boolean>;
345
371
  getCommitTree(commitSha: string): Promise<string>;
346
372
  getTree(treeSha: string, recursive?: boolean): Promise<{
347
373
  entries: TreeEntry[];
@@ -609,6 +635,7 @@ export declare class GitHubClient {
609
635
  body: string;
610
636
  mergeable: boolean | null;
611
637
  requestedReviewers: string[];
638
+ autoMerge: boolean;
612
639
  }>;
613
640
  listPullRequestFiles(n: number): Promise<PullRequestFile[]>;
614
641
  updatePullRequest(n: number, patch: {
@@ -782,4 +809,8 @@ export interface IssueSummary {
782
809
  author: string;
783
810
  createdAt: string;
784
811
  updatedAt: string;
812
+ /** Who is assigned (logins), when any (build requests: "Ana is on it"). */
813
+ assignees?: string[] | undefined;
814
+ /** ISO date it was closed, when closed. */
815
+ closedAt?: string | undefined;
785
816
  }
package/dist/id-map.d.ts CHANGED
@@ -17,6 +17,16 @@ export interface ReconcileResult {
17
17
  export declare function levenshtein(a: string, b: string): number;
18
18
  export declare function pathSimilarity(a: string, b: string): number;
19
19
  export declare const SIMILARITY_THRESHOLD = 0.5;
20
+ /**
21
+ * Tokens the code renamed between two commits: removed and added between `base` and `head` with the same type, tier
22
+ * and values and a similar path. One pair per token; a token that matches more than one counterpart equally is left
23
+ * as a removal and an addition (no guess). Lets a pull rename the Figma variable instead of orphaning it and adding a
24
+ * new one, so everything bound to it keeps its binding.
25
+ */
26
+ export declare function remoteRenames(base: Map<string, LogicalToken>, head: Map<string, LogicalToken>): {
27
+ from: LogicalToken;
28
+ to: LogicalToken;
29
+ }[];
20
30
  /**
21
31
  * Align Figma token ids with Git ids. `git` is every token known on the Git side (base and head).
22
32
  * Heuristic candidates are restricted to Git tokens that no Figma variable claims.
package/dist/index.d.ts CHANGED
@@ -43,8 +43,16 @@ export * from './explorations';
43
43
  export * from './explorations-github';
44
44
  export * from './requests-github';
45
45
  export * from './component-spec';
46
+ export * from './measured-spec';
47
+ export * from './measured-tokens';
48
+ export * from './measure-status';
46
49
  export * from './fidelity';
47
50
  export * from './fidelity-references';
51
+ export * from './gap-case';
52
+ export * from './figma-fixes';
53
+ export * from './measured-only';
54
+ export * from './css-color';
55
+ export * from './figma-fix-loop';
48
56
  export * from './review-gate';
49
57
  export * from './library-update';
50
58
  export * from './branch-actions';
@@ -72,5 +80,10 @@ export * from './component-scan';
72
80
  export * from './repo-model';
73
81
  export * from './repo-source-github';
74
82
  export * from './repo-access';
83
+ export * from './changelog-model';
84
+ export * from './motion-docs';
75
85
  export * from './snapshot';
86
+ export * from './requester';
76
87
  export * from './activity';
88
+ export * from './build-requests';
89
+ export * from './build-requests-github';