• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase-community / supabase-mcp / 16727694595

04 Aug 2025 03:41PM UTC coverage: 96.357% (+0.03%) from 96.328%
16727694595

push

github

web-flow
Merge pull request #119 from supabase-community/charis/user-agent

fix: add user-agent string to content api requests

225 of 244 branches covered (92.21%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 3 files covered. (100.0%)

2076 of 2144 relevant lines covered (96.83%)

34.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.67
/packages/mcp-server-supabase/src/util.ts
1
export type ValueOf<T> = T[keyof T];
2

3
// UnionToIntersection<A | B> = A & B
4
export type UnionToIntersection<U> = (
5
  U extends unknown
6
    ? (arg: U) => 0
7
    : never
8
) extends (arg: infer I) => 0
9
  ? I
10
  : never;
11

12
// LastInUnion<A | B> = B
13
export type LastInUnion<U> = UnionToIntersection<
14
  U extends unknown ? (x: U) => 0 : never
15
> extends (x: infer L) => 0
16
  ? L
17
  : never;
18

19
// UnionToTuple<A, B> = [A, B]
20
export type UnionToTuple<T, Last = LastInUnion<T>> = [T] extends [never]
21
  ? []
22
  : [Last, ...UnionToTuple<Exclude<T, Last>>];
23

24
/**
25
 * Parses a key-value string into an object.
26
 *
27
 * @returns An object representing the key-value pairs
28
 *
29
 * @example
30
 * const result = parseKeyValueList("key1=value1\nkey2=value2");
31
 * console.log(result); // { key1: "value1", key2: "value2" }
32
 */
33
export function parseKeyValueList(data: string): { [key: string]: string } {
3✔
34
  return Object.fromEntries(
8✔
35
    data
8✔
36
      .split('\n')
8✔
37
      .map((item) => item.split(/=(.*)/)) // split only on the first '='
8✔
38
      .filter(([key]) => key) // filter out empty keys
8✔
39
      .map(([key, value]) => [key, value ?? '']) // ensure value is not undefined
8!
40
  );
8✔
41
}
8✔
42

43
/**
44
 * Creates a unique hash from a JavaScript object.
45
 * @param obj - The object to hash
46
 * @param length - Optional length to truncate the hash (default: full length)
47
 */
48
export async function hashObject(
26✔
49
  obj: Record<string, any>,
26✔
50
  length?: number
26✔
51
): Promise<string> {
26✔
52
  // Sort object keys to ensure consistent output regardless of original key order
53
  const str = JSON.stringify(obj, (_, value) => {
26✔
54
    if (value && typeof value === 'object' && !Array.isArray(value)) {
104✔
55
      return Object.keys(value)
28✔
56
        .sort()
28✔
57
        .reduce<Record<string, any>>((result, key) => {
28✔
58
          result[key] = value[key];
72✔
59
          return result;
72✔
60
        }, {});
28✔
61
    }
28✔
62
    return value;
76✔
63
  });
26✔
64

65
  const buffer = await crypto.subtle.digest(
26✔
66
    'SHA-256',
26✔
67
    new TextEncoder().encode(str)
26✔
68
  );
26✔
69

70
  // Convert to base64
71
  const base64Hash = btoa(String.fromCharCode(...new Uint8Array(buffer)));
26✔
72
  return base64Hash.slice(0, length);
26✔
73
}
26✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc