@withgus/debug 0.1.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/components/DebugDrawer/DebugDrawer.d.ts +19 -0
- package/dist/components/DebugDrawer/EndpointBlock.d.ts +9 -0
- package/dist/debug.css +1 -0
- package/dist/hooks/useRegisterMockEndpoints.d.ts +2 -0
- package/dist/index.cjs +68 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3075 -0
- package/dist/mocks/types.d.ts +25 -0
- package/dist/store/debugDrawerStore.d.ts +30 -0
- package/package.json +59 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { HttpHandler } from 'msw';
|
|
2
|
+
export type MockScenario = 'success' | 'error' | 'loading' | 'not_found' | 'forbidden' | 'network_error';
|
|
3
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
4
|
+
export interface MockOption {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description: string;
|
|
8
|
+
statusCode: number | null;
|
|
9
|
+
scenario: MockScenario;
|
|
10
|
+
payload?: Record<string, unknown> | unknown[];
|
|
11
|
+
}
|
|
12
|
+
export interface EndpointConfig {
|
|
13
|
+
id: string;
|
|
14
|
+
method: HttpMethod;
|
|
15
|
+
path: string;
|
|
16
|
+
selectedScenario: MockScenario;
|
|
17
|
+
options: MockOption[];
|
|
18
|
+
}
|
|
19
|
+
export type ScenarioHandlerMap = Record<string, () => HttpHandler>;
|
|
20
|
+
export interface PageMockConfig {
|
|
21
|
+
/** Unique page identifier — typically the route path, e.g. '/team' */
|
|
22
|
+
pageId: string;
|
|
23
|
+
endpoints: EndpointConfig[];
|
|
24
|
+
handlers: Record<string, ScenarioHandlerMap>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SetupWorker } from "msw/browser";
|
|
2
|
+
import { EndpointConfig, MockScenario, PageMockConfig, ScenarioHandlerMap } from "../mocks/types";
|
|
3
|
+
export type GlobalPreset = "success" | "error" | "loading" | null;
|
|
4
|
+
interface PageEntry {
|
|
5
|
+
endpoints: EndpointConfig[];
|
|
6
|
+
handlers: Record<string, ScenarioHandlerMap>;
|
|
7
|
+
}
|
|
8
|
+
interface DebugDrawerState {
|
|
9
|
+
pages: Record<string, PageEntry>;
|
|
10
|
+
currentPageId: string | null;
|
|
11
|
+
expandedIds: Set<string>;
|
|
12
|
+
globalPreset: GlobalPreset;
|
|
13
|
+
pendingChanges: boolean;
|
|
14
|
+
mockEnabled: boolean;
|
|
15
|
+
_worker: SetupWorker | null;
|
|
16
|
+
_setWorker: (worker: SetupWorker) => void;
|
|
17
|
+
registerPage: (config: PageMockConfig) => void;
|
|
18
|
+
unregisterPage: (pageId: string) => void;
|
|
19
|
+
setCurrentPage: (pageId: string) => void;
|
|
20
|
+
toggleEndpoint: (id: string) => void;
|
|
21
|
+
selectScenario: (endpointId: string, scenario: MockScenario) => void;
|
|
22
|
+
applyGlobalPreset: (preset: GlobalPreset) => void;
|
|
23
|
+
applyChanges: () => void;
|
|
24
|
+
resetCurrentPage: () => void;
|
|
25
|
+
toggleMockEnabled: () => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare const useDebugDrawerStore: import("zustand").UseBoundStore<import("zustand").StoreApi<DebugDrawerState>>;
|
|
28
|
+
export declare const selectCurrentEndpoints: (s: DebugDrawerState) => EndpointConfig[];
|
|
29
|
+
export declare const selectFabStatus: (s: DebugDrawerState) => "ok" | "warn" | "error" | "off";
|
|
30
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@withgus/debug",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A debug drawer for switching MSW mock scenarios per page at runtime",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Gustavo S Souza",
|
|
18
|
+
"email": "kyoro_souza@hotmail.com",
|
|
19
|
+
"url": "https://github.com/Futhememe-official"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"msw": ">=2.0.0",
|
|
26
|
+
"react": ">=18.0.0",
|
|
27
|
+
"react-dom": ">=18.0.0",
|
|
28
|
+
"vaul": ">=1.0.0",
|
|
29
|
+
"zustand": ">=4.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@changesets/cli": "^2.30.0",
|
|
33
|
+
"@types/react": "^19.0.0",
|
|
34
|
+
"@types/react-dom": "^19.0.0",
|
|
35
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
36
|
+
"autoprefixer": "^10.4.20",
|
|
37
|
+
"postcss": "^8.5.1",
|
|
38
|
+
"tailwindcss": "^3.4.17",
|
|
39
|
+
"typescript": "~5.7.2",
|
|
40
|
+
"vite": "^6.0.5",
|
|
41
|
+
"vite-plugin-dts": "^4.3.0"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"msw",
|
|
45
|
+
"mock",
|
|
46
|
+
"debug",
|
|
47
|
+
"drawer",
|
|
48
|
+
"testing",
|
|
49
|
+
"react",
|
|
50
|
+
"vaul"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"dev": "vite build --watch",
|
|
57
|
+
"release": "pnpm build && changeset publish"
|
|
58
|
+
}
|
|
59
|
+
}
|