Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

Commit 369ffc0

Browse files
fix: 211 kahn, tarjan algorithm for topological sort (#230)
* feat: wip mapi client with retry mechanism * feat: freeze mechanism for retry * feat: wip concurrency limit * refactor: replaced custom fetch with mapi client with retry mechanism for component internal tags * refactor: replace customFetch with mapiClient on all component related operations * refactor: replace upserting logic with local saved target data and maps lookouts * refactor: implement graph-based dependency resolution for push * fix(progress-display): Adds centralized progress tracking and display * refactor: add optional existingId for efficient upsert operations * fix(dep-refs): update references after ID changes * feat(graph-operations): add dependency graph and utils for processing * refactor(graph-operations): Remove unused processed property * refactor(graph): implement node classes with reference resolution * refactor(graph): add preset nodes and dependencies to graph * fix(resource-processing): handle circular deps via stubs * chore: add minimatch dependency * refactor(graph-operations): remove unused imports and code * refactor(remove): delete obsolete test files * refactor(utils): fix import of minimatch module * refactor(comparison-utils): improve array normalization handling * refactor(constants): add new color constants for groups, tags, and presets; update logging to use chalk for better readability * refactor(push): use konsola ok * refactor(progress-display): enhance progress tracking with elapsed time for events * chore: temporarely log requests made * fix(push): Remove unused force parameter from functions * refactor(push): simplify space data filtering logic * chore: remove deprecated graph-operations.ts file * chore: update lock file * refactor: enhance dependency collection for push components * chore: disable max-statements-per-line rule in ESLint configuration * fix(push): remove duplicate return statement in updateComponentGroup function * refactor(dep-graph): add preset dependency handling and resolve preset IDs --------- Co-authored-by: alvarosabu <alvaro.saburido@gmail.com>
1 parent ed72ec0 commit 369ffc0

21 files changed

Lines changed: 2479 additions & 3417 deletions

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { storyblokLintConfig } from '@storyblok/eslint-config';
33
export default storyblokLintConfig({
44
rules: {
55
'no-console': 'off',
6+
'style/max-statements-per-line': 'off',
67
},
78
});

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"commander": "^13.1.0",
4444
"dotenv": "^16.5.0",
4545
"json-schema-to-typescript": "^15.0.4",
46+
"minimatch": "^10.0.3",
4647
"ohash": "^2.0.11",
4748
"pathe": "^2.0.3",
4849
"read-package-up": "^11.0.0",
@@ -61,6 +62,7 @@
6162
"release-it": "^18.1.2",
6263
"typescript": "^5.8.3",
6364
"unbuild": "^3.5.0",
65+
"uuid": "^11.1.0",
6466
"vite": "^6.3.5",
6567
"vitest": "^3.1.3"
6668
}

pnpm-lock.yaml

Lines changed: 31 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface ManagementApiClientOptions {
99
maxRetries?: number;
1010
baseDelay?: number;
1111
verbose?: boolean;
12+
onRequest?: (request: { path: string; method: string; headers: HeadersInit; body?: any }) => void;
13+
onResponse?: (response: { path: string; method: string; status: number; data: any; attempt: number }) => void;
1214
}
1315

1416
export interface FetchOptions {
@@ -30,6 +32,7 @@ export interface MapiClient {
3032
post: <T>(path: string, fetchOptions?: FetchOptions) => Promise<GetResponse<T>>;
3133
put: <T>(path: string, fetchOptions?: FetchOptions) => Promise<GetResponse<T>>;
3234
dispose: () => void;
35+
getRequestCount: () => number;
3336
}
3437

3538
let instance: MapiClient | null = null;
@@ -79,11 +82,22 @@ const createMapiClient = (options: ManagementApiClientOptions): MapiClient => {
7982
console.log(`${state.url}/${path} - Attempt ${attempt}`);
8083
}
8184

82-
const res = await fetch(`${state.url}/${path}`, {
85+
// Prepare request data for interceptor
86+
const requestData = {
87+
path,
88+
method: fetchOptions?.method || 'GET',
8389
headers: {
8490
...state.baseHeaders,
8591
...fetchOptions?.headers,
86-
} as HeadersInit,
92+
} as Record<string, string>,
93+
body: fetchOptions?.body,
94+
};
95+
96+
// Call request interceptor if provided
97+
options?.onRequest?.(requestData);
98+
99+
const res = await fetch(`${state.url}/${path}`, {
100+
headers: requestData.headers as HeadersInit,
87101
...fetchOptions,
88102
});
89103

@@ -98,6 +112,16 @@ const createMapiClient = (options: ManagementApiClientOptions): MapiClient => {
98112
data: null,
99113
});
100114
}
115+
116+
// Call response interceptor if provided
117+
options?.onResponse?.({
118+
path,
119+
method: requestData.method,
120+
status: res.status,
121+
data,
122+
attempt,
123+
});
124+
101125
if (res.ok) {
102126
if (options?.verbose) {
103127
console.log(`✅ ${path}`);

src/commands/components/constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,13 @@ export interface SpaceData {
5454
presets: SpaceComponentPreset[];
5555
internalTags: SpaceComponentInternalTag[];
5656
}
57+
58+
export interface SpaceDataState {
59+
local: SpaceData;
60+
target: {
61+
components: Map<string, SpaceComponent>;
62+
tags: Map<string, SpaceComponentInternalTag>;
63+
groups: Map<string, SpaceComponentGroup>;
64+
presets: Map<string, SpaceComponentPreset>;
65+
};
66+
}

0 commit comments

Comments
 (0)