@vibeunion/devtools-protocol 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/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # @vibeunion/devtools-protocol
2
+
3
+ Shared JSON-safe contracts for frontend and SupaCloud DevTools adapters.
4
+
5
+ The package contains no transport, database, logging, or UI dependency. It
6
+ defines trace/correlation metadata, diagnostics, events, snapshots, and
7
+ recursive redaction for credentials and signed URLs. It also defines the
8
+ complete local cache mutation vocabulary, including query and mutation cache
9
+ operations, plus the svadmin snapshot/provider/query diagnostic shapes so a
10
+ single contract serves frontend, svadmin, and SupaCloud adapters.
@@ -0,0 +1,116 @@
1
+ export type DevtoolsSource = 'frontend' | 'supacloud' | 'compiler';
2
+ export type DevtoolsSeverity = 'info' | 'warning' | 'error';
3
+ export type DevtoolsTraceContext = {
4
+ requestId?: string;
5
+ traceId?: string;
6
+ correlationId?: string;
7
+ };
8
+ export type DevtoolsLocation = {
9
+ file?: string;
10
+ line?: number;
11
+ column?: number;
12
+ };
13
+ export type DevtoolsDiagnostic = DevtoolsTraceContext & {
14
+ code: string;
15
+ source: DevtoolsSource;
16
+ severity: DevtoolsSeverity;
17
+ message: string;
18
+ location?: DevtoolsLocation;
19
+ fix?: {
20
+ kind: string;
21
+ safe: boolean;
22
+ input?: Record<string, unknown>;
23
+ };
24
+ };
25
+ export type DevtoolsEvent = (DevtoolsTraceContext & {
26
+ type: 'request.started' | 'request.finished' | 'request.failed';
27
+ durationMs?: number;
28
+ }) | (DevtoolsTraceContext & {
29
+ type: 'query.started' | 'query.finished' | 'query.failed';
30
+ provider: string;
31
+ resource?: string;
32
+ operation: string;
33
+ }) | (DevtoolsTraceContext & {
34
+ type: 'task.updated';
35
+ taskId: string;
36
+ status: string;
37
+ }) | {
38
+ type: 'diagnostic.emitted';
39
+ diagnostic: DevtoolsDiagnostic;
40
+ };
41
+ export type DevtoolsSnapshot = DevtoolsTraceContext & {
42
+ version: 1;
43
+ source: DevtoolsSource;
44
+ diagnostics: DevtoolsDiagnostic[];
45
+ events: DevtoolsEvent[];
46
+ };
47
+ export type DevtoolsCacheSelector = {
48
+ provider?: string;
49
+ resource?: string;
50
+ operation?: string;
51
+ queryHash?: string;
52
+ mutationKey?: string;
53
+ };
54
+ export type DevtoolsCacheMutation = 'cancel' | 'invalidate' | 'refetch' | 'remove' | 'reset' | 'clear' | 'clearMutations' | 'cancelMutations' | 'removeMutations' | 'resetMutations';
55
+ export type DevtoolsCacheCapabilities = {
56
+ query: DevtoolsCacheMutation[];
57
+ mutation: DevtoolsCacheMutation[];
58
+ };
59
+ export type DevtoolsCacheActionRequest = {
60
+ action: DevtoolsCacheMutation;
61
+ selector?: DevtoolsCacheSelector;
62
+ confirmation?: string;
63
+ };
64
+ export type DevtoolsCacheActionResult = {
65
+ action: DevtoolsCacheMutation;
66
+ matched: number;
67
+ changed: number;
68
+ };
69
+ export type DevtoolsCacheDiagnostics = {
70
+ queries: {
71
+ total: number;
72
+ fetching: number;
73
+ stale: number;
74
+ errors: number;
75
+ };
76
+ mutations: {
77
+ total: number;
78
+ pending: number;
79
+ paused: number;
80
+ errors: number;
81
+ };
82
+ };
83
+ export type DevtoolsProviderDiagnostic = {
84
+ name: string;
85
+ configured: boolean;
86
+ capabilities: string;
87
+ };
88
+ export type DevtoolsQueryDiagnostic = {
89
+ provider: string;
90
+ resource: string;
91
+ operation: string;
92
+ status: string;
93
+ retries: number;
94
+ duration: string;
95
+ cacheAge: string;
96
+ invalidation: string;
97
+ };
98
+ /**
99
+ * Svadmin-specific devtools snapshot shape. It extends the shared versioned
100
+ * snapshot vocabulary while staying JSON-safe and dependency-free so the same
101
+ * contract can be consumed by frontend adapters and SupaCloud tooling.
102
+ */
103
+ export type SvadminDevtoolsSnapshot = {
104
+ version: 1;
105
+ environment: 'development';
106
+ route: string;
107
+ locale: string;
108
+ theme: string;
109
+ colorTheme: string;
110
+ resourceCount: number;
111
+ providers: DevtoolsProviderDiagnostic[];
112
+ cache: DevtoolsCacheDiagnostics;
113
+ queries: DevtoolsQueryDiagnostic[];
114
+ };
115
+ export declare function redactDevtoolsRecord(value: unknown): unknown;
116
+ export declare function createDevtoolsSnapshot(input: Omit<DevtoolsSnapshot, 'version'>): DevtoolsSnapshot;
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // src/index.ts
2
+ var SECRET_KEY = /token|secret|password|credential|authorization|cookie|signed.?url|service.?role|api.?key|private.?key|jwt/i;
3
+ function redactDevtoolsRecord(value) {
4
+ if (Array.isArray(value))
5
+ return value.map(redactDevtoolsRecord);
6
+ if (value && typeof value === "object") {
7
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
8
+ key,
9
+ SECRET_KEY.test(key) ? "[redacted]" : redactDevtoolsRecord(entry)
10
+ ]));
11
+ }
12
+ return value;
13
+ }
14
+ function createDevtoolsSnapshot(input) {
15
+ return redactDevtoolsRecord({ version: 1, ...input });
16
+ }
17
+ export {
18
+ createDevtoolsSnapshot,
19
+ redactDevtoolsRecord
20
+ };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@vibeunion/devtools-protocol",
3
+ "version": "0.1.0",
4
+ "description": "Shared JSON-safe DevTools protocol for frontend and SupaCloud adapters",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "scripts": {
20
+ "clean": "rm -rf dist",
21
+ "build": "bun run clean && bun build src/index.ts --outdir dist --target node && tsc -b tsconfig.json --force",
22
+ "test": "bun test"
23
+ },
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+ssh://git@github.com/vibeunion/devtools.git",
28
+ "directory": "packages/protocol"
29
+ }
30
+ }