@capgo/cli 7.114.0 → 7.115.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
3
  "type": "module",
4
- "version": "7.114.0",
4
+ "version": "7.115.0",
5
5
  "description": "A CLI to upload to capgo servers",
6
6
  "author": "Martin martin@capgo.app",
7
7
  "license": "Apache 2.0",
@@ -84,6 +84,7 @@
84
84
  "test:analytics": "bun test/test-analytics.mjs",
85
85
  "test:analytics-error-category": "bun test/test-analytics-error-category.mjs",
86
86
  "test:analytics-org-resolver": "bun test/test-analytics-org-resolver.mjs",
87
+ "test:supabase-perf": "bun test/test-supabase-perf.mjs",
87
88
  "test:mcp-analytics": "bun test/test-mcp-analytics.mjs",
88
89
  "test:app-created-source": "bun test/test-app-created-source.mjs",
89
90
  "test:doctor-analytics": "bun test/test-doctor-analytics.mjs",
@@ -104,7 +105,7 @@
104
105
  "test:macos-signing": "bun test/test-macos-signing.mjs",
105
106
  "test:apple-api-import-helpers": "bun test/test-apple-api-import-helpers.mjs",
106
107
  "test:manifest-path-encoding": "bun test/test-manifest-path-encoding.mjs",
107
- "test": "bun run build && bun run test:version-detection:setup && bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:build-needed && bun run test:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:mcp-analytics && bun run test:app-created-source && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-app-conflict && bun run test:init-guardrails && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths && bun run test:payload-split && bun run test:manifest-path-encoding && bun run test:macos-signing && bun run test:apple-api-import-helpers && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:ai-render-markdown",
108
+ "test": "bun run build && bun run test:version-detection:setup && bun run test:bundle && bun run test:functional && bun run test:semver && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:credentials && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:checksum && bun run test:build-needed && bun run test:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:mcp-analytics && bun run test:app-created-source && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-app-conflict && bun run test:init-guardrails && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths && bun run test:payload-split && bun run test:manifest-path-encoding && bun run test:macos-signing && bun run test:apple-api-import-helpers && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:ai-render-markdown",
108
109
  "test:build-platform-selection": "bun test/test-build-platform-selection.mjs",
109
110
  "test:ai-log-capture": "bun test/test-ai-log-capture.mjs",
110
111
  "test:ai-analyze-flow": "bun test/test-ai-analyze-flow.mjs",
@@ -1,6 +1,11 @@
1
- export type CliErrorCategory = 'network_error' | 'timeout' | 'unauthorized' | 'forbidden' | 'not_found' | 'payload_too_large' | 'validation_error' | 'server_error' | 'commander' | 'unknown';
1
+ export type CliErrorCategory = 'network_error' | 'timeout' | 'unauthorized' | 'forbidden' | 'not_found' | 'payload_too_large' | 'rate_limited' | 'validation_error' | 'server_error' | 'commander' | 'unknown';
2
2
  /**
3
3
  * Maps an arbitrary thrown value to a closed enum so telemetry never leaks
4
4
  * error text, paths, or user input. Returns 'unknown' for anything unmatched.
5
5
  */
6
6
  export declare function categorizeCliError(error: unknown): CliErrorCategory;
7
+ /**
8
+ * Maps a non-2xx HTTP status to the same closed enum, for Supabase responses
9
+ * where we have a status code but no thrown Error. Never leaks response bodies.
10
+ */
11
+ export declare function categorizeHttpStatus(status: number): CliErrorCategory;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Tags every Supabase call made inside `fn` with `source`.
3
+ *
4
+ * The Supabase JS query builder is a lazy thenable: it does not call `fetch`
5
+ * until `.then()` is invoked (i.e. when the caller `await`s it). If we only
6
+ * call `run(source, fn)` and return the builder, `.then()` fires *outside* the
7
+ * AsyncLocalStorage context and `getSupabaseSource()` returns `undefined`.
8
+ *
9
+ * To fix this, we wrap the result in `Promise.resolve()` inside the `run()`
10
+ * callback. This schedules the microtask (which calls `.then()` on the builder)
11
+ * while still inside the async context, so the source label propagates through
12
+ * to the actual fetch. For plain Promises and non-thenable values the behaviour
13
+ * is unchanged.
14
+ */
15
+ export declare function withSupabaseSource<T>(source: string, fn: () => T): Promise<Awaited<T>>;
16
+ export declare function getSupabaseSource(): string | undefined;
17
+ export declare function enableSupabaseInstrumentation(): void;
18
+ export declare function isSupabaseInstrumentationEnabled(): boolean;
19
+ export interface SupabaseCallInfo {
20
+ url: string;
21
+ method: string;
22
+ status: number;
23
+ ok: boolean;
24
+ durationMs: number;
25
+ source?: string;
26
+ apikey?: string;
27
+ error?: unknown;
28
+ }
29
+ export type SupabaseCallRecorder = (info: SupabaseCallInfo) => void;
30
+ export declare function setSupabaseCallRecorder(fn: SupabaseCallRecorder): void;
31
+ /** A Supabase call slower than this is flagged `slow` regardless of status. */
32
+ export declare const SLOW_THRESHOLD_MS = 5000;
33
+ /**
34
+ * Parses a Supabase REST/RPC URL into a low-cardinality operation label.
35
+ * Query strings are discarded so filter values never leak and cardinality
36
+ * stays bounded. `/rest/v1/rpc/get_user_id` => `rpc:get_user_id`;
37
+ * `/rest/v1/apps?...` => `GET apps`.
38
+ */
39
+ export declare function deriveSupabaseOperation(url: string, method: string): string;
40
+ /**
41
+ * A `fetch` wrapper for supabase-js's `global.fetch`. Times the real request
42
+ * (which runs regardless), captures the active source label, and hands the
43
+ * result to the injected recorder. Returns the real Response / rethrows the
44
+ * real error so supabase-js behavior is never altered. Calls `globalThis.fetch`
45
+ * dynamically (not a captured ref) so it is testable and never self-recurses.
46
+ */
47
+ export declare function createTimedFetch(): typeof fetch;
@@ -1,3 +1,4 @@
1
+ import { withSupabaseSource } from './supabase-perf';
1
2
  type InvocationSource = 'cli' | 'mcp';
2
3
  export declare function setInvocationSource(source: InvocationSource): void;
3
4
  export declare function getInvocationSource(): InvocationSource;
@@ -65,4 +66,5 @@ type AnyAsyncFn = (...args: any[]) => Promise<any>;
65
66
  */
66
67
  export declare function withMcpToolTracking<H extends AnyAsyncFn>(toolName: string, handler: H): H;
67
68
  export declare function trackMcpServerStarted(hasApikey: boolean): void;
68
- export {};
69
+ export { withSupabaseSource };
70
+ export { enableSupabaseInstrumentation } from './supabase-perf';