@supabase/mcp-server-supabase 0.3.6 → 0.4.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/chunk-OAQOSHL7.cjs +296 -0
- package/dist/chunk-OAQOSHL7.cjs.map +1 -0
- package/dist/chunk-SNNCNMFQ.js +296 -0
- package/dist/chunk-SNNCNMFQ.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/stdio.cjs +1 -1
- package/dist/stdio.cjs.map +1 -1
- package/dist/stdio.js +1 -1
- package/dist/stdio.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-M3JU5DW7.cjs +0 -295
- package/dist/chunk-M3JU5DW7.cjs.map +0 -1
- package/dist/chunk-ZOKJ3UPH.js +0 -295
- package/dist/chunk-ZOKJ3UPH.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,13 @@ type SupabaseMcpServerOptions = {
|
|
|
15
15
|
* Platform options for Supabase.
|
|
16
16
|
*/
|
|
17
17
|
platform: SupabasePlatformOptions;
|
|
18
|
+
/**
|
|
19
|
+
* The project ID to scope the server to.
|
|
20
|
+
*
|
|
21
|
+
* If undefined, the server will have access
|
|
22
|
+
* to all organizations and projects for the user.
|
|
23
|
+
*/
|
|
24
|
+
projectId?: string;
|
|
18
25
|
/**
|
|
19
26
|
* Executes database queries in read-only mode if true.
|
|
20
27
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,13 @@ type SupabaseMcpServerOptions = {
|
|
|
15
15
|
* Platform options for Supabase.
|
|
16
16
|
*/
|
|
17
17
|
platform: SupabasePlatformOptions;
|
|
18
|
+
/**
|
|
19
|
+
* The project ID to scope the server to.
|
|
20
|
+
*
|
|
21
|
+
* If undefined, the server will have access
|
|
22
|
+
* to all organizations and projects for the user.
|
|
23
|
+
*/
|
|
24
|
+
projectId?: string;
|
|
18
25
|
/**
|
|
19
26
|
* Executes database queries in read-only mode if true.
|
|
20
27
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as o}from"./chunk-
|
|
1
|
+
import{b as o}from"./chunk-SNNCNMFQ.js";export{o as createSupabaseMcpServer};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/stdio.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict"; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var
|
|
2
|
+
"use strict"; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkOAQOSHL7cjs = require('./chunk-OAQOSHL7.cjs');var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');var _util = require('util');var{version:v}=_chunkOAQOSHL7cjs.a;async function S(){let{values:{["access-token"]:s,["project-ref"]:n,["read-only"]:t,["api-url"]:a,["version"]:c}}=_util.parseArgs.call(void 0, {options:{"access-token":{type:"string"},"project-ref":{type:"string"},"read-only":{type:"boolean",default:!1},"api-url":{type:"string"},version:{type:"boolean"}}});c&&(console.log(v),process.exit(0));let e=_nullishCoalesce(s, () => (process.env.SUPABASE_ACCESS_TOKEN));e||(console.error("Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable"),process.exit(1));let i=_chunkOAQOSHL7cjs.b.call(void 0, {platform:{accessToken:e,apiUrl:a},projectId:n,readOnly:t}),p=new _stdiojs.StdioServerTransport;await i.connect(p)}S().catch(console.error);
|
|
3
3
|
//# sourceMappingURL=stdio.cjs.map
|
package/dist/stdio.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/stdio.cjs","../src/stdio.ts"],"names":["version","package_default","main","cliAccessToken","readOnly","apiUrl","showVersion","parseArgs","accessToken","server","createSupabaseMcpServer","transport","StdioServerTransport"],"mappings":"AAAA;AACA,yKAA+C,oECCV,4BACX,GAIpB,CAAE,OAAA,CAAAA,CAAQ,CAAA,CAAIC,mBAAAA,CAEpB,MAAA,SAAeC,CAAAA,CAAAA,CAAO,CACpB,GAAM,CACJ,MAAA,CAAQ,CACN,CAAC,cAAc,CAAA,CAAGC,CAAAA,CAClB,CAAC,WAAW,CAAA,CAAGC,CAAAA,CACf,CAAC,SAAS,CAAA,CAAGC,CAAAA,CACb,CAAC,SAAS,CAAA,CAAGC,CACf,CACF,CAAA,CAAIC,6BAAAA,CACF,OAAA,CAAS,CACN,cAAA,CAAiB,CAChB,IAAA,CAAM,QACR,CAAA,CACC,WAAA,CAAc,CACb,IAAA,CAAM,SAAA,CACN,OAAA,CAAS,CAAA,CACX,CAAA,CACC,SAAA,CAAY,CACX,IAAA,CAAM,QACR,CAAA,CACC,OAAA,CAAY,CACX,IAAA,CAAM,SACR,CACF,CACF,CAAC,CAAA,CAEGD,CAAAA,EAAAA,CACF,OAAA,CAAQ,GAAA,
|
|
1
|
+
{"version":3,"sources":["/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/stdio.cjs","../src/stdio.ts"],"names":["version","package_default","main","cliAccessToken","projectId","readOnly","apiUrl","showVersion","parseArgs","accessToken","server","createSupabaseMcpServer","transport","StdioServerTransport"],"mappings":"AAAA;AACA,yKAA+C,oECCV,4BACX,GAIpB,CAAE,OAAA,CAAAA,CAAQ,CAAA,CAAIC,mBAAAA,CAEpB,MAAA,SAAeC,CAAAA,CAAAA,CAAO,CACpB,GAAM,CACJ,MAAA,CAAQ,CACN,CAAC,cAAc,CAAA,CAAGC,CAAAA,CAClB,CAAC,aAAa,CAAA,CAAGC,CAAAA,CACjB,CAAC,WAAW,CAAA,CAAGC,CAAAA,CACf,CAAC,SAAS,CAAA,CAAGC,CAAAA,CACb,CAAC,SAAS,CAAA,CAAGC,CACf,CACF,CAAA,CAAIC,6BAAAA,CACF,OAAA,CAAS,CACN,cAAA,CAAiB,CAChB,IAAA,CAAM,QACR,CAAA,CACC,aAAA,CAAgB,CACf,IAAA,CAAM,QACR,CAAA,CACC,WAAA,CAAc,CACb,IAAA,CAAM,SAAA,CACN,OAAA,CAAS,CAAA,CACX,CAAA,CACC,SAAA,CAAY,CACX,IAAA,CAAM,QACR,CAAA,CACC,OAAA,CAAY,CACX,IAAA,CAAM,SACR,CACF,CACF,CAAC,CAAA,CAEGD,CAAAA,EAAAA,CACF,OAAA,CAAQ,GAAA,CAAIP,CAAO,CAAA,CACnB,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAAA,CAIhB,IAAMS,CAAAA,kBAAcN,CAAAA,SAAkB,OAAA,CAAQ,GAAA,CAAI,uBAAA,CAE7CM,CAAAA,EAAAA,CACH,OAAA,CAAQ,KAAA,CACN,iIACF,CAAA,CACA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAAA,CAGhB,IAAMC,CAAAA,CAASC,iCAAAA,CACb,QAAA,CAAU,CACR,WAAA,CAAAF,CAAAA,CACA,MAAA,CAAAH,CACF,CAAA,CACA,SAAA,CAAAF,CAAAA,CACA,QAAA,CAAAC,CACF,CAAC,CAAA,CAEKO,CAAAA,CAAY,IAAIC,6BAAAA,CAEtB,MAAMH,CAAAA,CAAO,OAAA,CAAQE,CAAS,CAChC,CAEAV,CAAAA,CAAK,CAAA,CAAE,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA","file":"/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/stdio.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseMcpServer } from './server.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['project-ref']: projectId,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['version']: showVersion,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['project-ref']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n // Use access token from CLI argument or environment variable\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n apiUrl,\n },\n projectId,\n readOnly,\n });\n\n const transport = new StdioServerTransport();\n\n await server.connect(transport);\n}\n\nmain().catch(console.error);\n"]}
|
package/dist/stdio.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as o,b as r}from"./chunk-
|
|
2
|
+
import{a as o,b as r}from"./chunk-SNNCNMFQ.js";import{StdioServerTransport as l}from"@modelcontextprotocol/sdk/server/stdio.js";import{parseArgs as f}from"node:util";var{version:v}=o;async function S(){let{values:{["access-token"]:s,["project-ref"]:n,["read-only"]:t,["api-url"]:a,["version"]:c}}=f({options:{"access-token":{type:"string"},"project-ref":{type:"string"},"read-only":{type:"boolean",default:!1},"api-url":{type:"string"},version:{type:"boolean"}}});c&&(console.log(v),process.exit(0));let e=s??process.env.SUPABASE_ACCESS_TOKEN;e||(console.error("Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable"),process.exit(1));let i=r({platform:{accessToken:e,apiUrl:a},projectId:n,readOnly:t}),p=new l;await i.connect(p)}S().catch(console.error);
|
|
3
3
|
//# sourceMappingURL=stdio.js.map
|
package/dist/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/stdio.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseMcpServer } from './server.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['version']: showVersion,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n // Use access token from CLI argument or environment variable\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n apiUrl,\n },\n readOnly,\n });\n\n const transport = new StdioServerTransport();\n\n await server.connect(transport);\n}\n\nmain().catch(console.error);\n"],"mappings":";+CAEA,OAAS,wBAAAA,MAA4B,4CACrC,OAAS,aAAAC,MAAiB,YAI1B,GAAM,CAAE,QAAAC,CAAQ,EAAIC,EAEpB,eAAeC,GAAO,CACpB,GAAM,CACJ,OAAQ,CACN,CAAC,cAAc,EAAGC,EAClB,CAAC,WAAW,EAAGC,EACf,CAAC,SAAS,EAAGC,EACb,CAAC,SAAS,EAAGC,CACf,CACF,EAAIC,EAAU,CACZ,QAAS,CACN,eAAiB,CAChB,KAAM,QACR,EACC,YAAc,CACb,KAAM,UACN,QAAS,EACX,EACC,UAAY,CACX,KAAM,QACR,EACC,QAAY,CACX,KAAM,SACR,CACF,CACF,CAAC,EAEGD,IACF,QAAQ,
|
|
1
|
+
{"version":3,"sources":["../src/stdio.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseMcpServer } from './server.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['project-ref']: projectId,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['version']: showVersion,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['project-ref']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n // Use access token from CLI argument or environment variable\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n apiUrl,\n },\n projectId,\n readOnly,\n });\n\n const transport = new StdioServerTransport();\n\n await server.connect(transport);\n}\n\nmain().catch(console.error);\n"],"mappings":";+CAEA,OAAS,wBAAAA,MAA4B,4CACrC,OAAS,aAAAC,MAAiB,YAI1B,GAAM,CAAE,QAAAC,CAAQ,EAAIC,EAEpB,eAAeC,GAAO,CACpB,GAAM,CACJ,OAAQ,CACN,CAAC,cAAc,EAAGC,EAClB,CAAC,aAAa,EAAGC,EACjB,CAAC,WAAW,EAAGC,EACf,CAAC,SAAS,EAAGC,EACb,CAAC,SAAS,EAAGC,CACf,CACF,EAAIC,EAAU,CACZ,QAAS,CACN,eAAiB,CAChB,KAAM,QACR,EACC,cAAgB,CACf,KAAM,QACR,EACC,YAAc,CACb,KAAM,UACN,QAAS,EACX,EACC,UAAY,CACX,KAAM,QACR,EACC,QAAY,CACX,KAAM,SACR,CACF,CACF,CAAC,EAEGD,IACF,QAAQ,IAAIP,CAAO,EACnB,QAAQ,KAAK,CAAC,GAIhB,IAAMS,EAAcN,GAAkB,QAAQ,IAAI,sBAE7CM,IACH,QAAQ,MACN,iIACF,EACA,QAAQ,KAAK,CAAC,GAGhB,IAAMC,EAASC,EAAwB,CACrC,SAAU,CACR,YAAAF,EACA,OAAAH,CACF,EACA,UAAAF,EACA,SAAAC,CACF,CAAC,EAEKO,EAAY,IAAIC,EAEtB,MAAMH,EAAO,QAAQE,CAAS,CAChC,CAEAV,EAAK,EAAE,MAAM,QAAQ,KAAK","names":["StdioServerTransport","parseArgs","version","package_default","main","cliAccessToken","projectId","readOnly","apiUrl","showVersion","parseArgs","accessToken","server","createSupabaseMcpServer","transport","StdioServerTransport"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/mcp-server-supabase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MCP server for interacting with Supabase",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@deno/eszip": "^0.84.0",
|
|
33
33
|
"@modelcontextprotocol/sdk": "^1.4.1",
|
|
34
|
-
"@supabase/mcp-utils": "0.
|
|
34
|
+
"@supabase/mcp-utils": "0.2.0",
|
|
35
35
|
"common-tags": "^1.8.2",
|
|
36
36
|
"openapi-fetch": "^0.13.5",
|
|
37
37
|
"zod": "^3.24.1"
|
package/dist/chunk-M3JU5DW7.cjs
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var x={name:"@supabase/mcp-server-supabase",version:"0.3.6",description:"MCP server for interacting with Supabase",license:"Apache-2.0",type:"module",main:"dist/index.cjs",types:"dist/index.d.ts",sideEffects:!1,scripts:{build:"tsup --clean",prepublishOnly:"npm run build",test:"vitest","test:e2e":"vitest --project e2e","test:unit":"vitest --project unit","generate:management-api-types":"openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts"},files:["dist/**/*"],bin:{"mcp-server-supabase":"./dist/stdio.js"},exports:{".":{import:"./dist/index.js",types:"./dist/index.d.ts",default:"./dist/index.cjs"}},dependencies:{"@deno/eszip":"^0.84.0","@modelcontextprotocol/sdk":"^1.4.1","@supabase/mcp-utils":"0.1.3","common-tags":"^1.8.2","openapi-fetch":"^0.13.5",zod:"^3.24.1"},devDependencies:{"@ai-sdk/anthropic":"^1.2.9","@electric-sql/pglite":"^0.2.17","@total-typescript/tsconfig":"^1.0.4","@types/common-tags":"^1.8.4","@types/node":"^22.8.6",ai:"^4.3.4","date-fns":"^4.1.0",dotenv:"^16.5.0",msw:"^2.7.3",nanoid:"^5.1.5","openapi-typescript":"^7.5.0","openapi-typescript-helpers":"^0.0.15",prettier:"^3.3.3",tsup:"^8.3.5",tsx:"^4.19.2",typescript:"^5.6.3",vitest:"^2.1.9"}};var _mcputils = require('@supabase/mcp-utils');var _zod = require('zod');var _commontags = require('common-tags');var _url = require('url');var _eszip = require('@deno/eszip');var _path = require('path');var b=await _eszip.Parser.createInstance(),ae=_zod.z.object({version:_zod.z.number(),sources:_zod.z.array(_zod.z.string()),sourcesContent:_zod.z.array(_zod.z.string()).optional(),names:_zod.z.array(_zod.z.string()),mappings:_zod.z.string()});async function O(s,r="/"){let n=[];if(s instanceof ReadableStream){let l=s.getReader({mode:"byob"});n=await b.parse(l)}else n=await b.parseBytes(s);await b.load();let g=n.filter(l=>l.startsWith("file://"));return await Promise.all(g.map(async l=>{let e=await b.getModuleSource(l),t=await b.getModuleSourceMap(l),o=_path.relative.call(void 0, r,_url.fileURLToPath.call(void 0, l)),i=new File([e],o,{type:"text/plain"});if(!t)return i;let u=ae.parse(JSON.parse(t)),[m]=_nullishCoalesce(u.sourcesContent, () => ([]));return m?new File([m],o,{type:"application/typescript"}):i}))}var _openapifetch = require('openapi-fetch'); var _openapifetch2 = _interopRequireDefault(_openapifetch);function I(s,r,n={}){return _openapifetch2.default.call(void 0, {baseUrl:s,headers:{Authorization:`Bearer ${r}`,...n}})}var se=_zod.z.object({message:_zod.z.string()});function c(s,r){if("error"in s){if(s.response.status===401)throw new Error("Unauthorized. Please provide a valid access token to the MCP server via the --access-token flag or SUPABASE_ACCESS_TOKEN.");let{data:n}=se.safeParse(s.error);throw n?new Error(n.message):new Error(r)}}function oe(s,r,n){return`${s}_${r}_${n}`}function ie(s){return`/tmp/user_fn_${s}/`}var F=_commontags.codeBlock`
|
|
2
|
-
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
|
|
3
|
-
|
|
4
|
-
Deno.serve(async (req: Request) => {
|
|
5
|
-
const data = {
|
|
6
|
-
message: "Hello there!"
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
return new Response(JSON.stringify(data), {
|
|
10
|
-
headers: {
|
|
11
|
-
'Content-Type': 'application/json',
|
|
12
|
-
'Connection': 'keep-alive'
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
`;async function w(s,r,n){let g=await s.GET("/v1/projects/{ref}/functions/{function_slug}",{params:{path:{ref:r,function_slug:n}}});if(g.error)return{data:void 0,error:g.error};c(g,"Failed to fetch Edge Function");let d=g.data,l=oe(r,d.id,d.version),e=ie(l),t=d.entrypoint_path?_url.fileURLToPath.call(void 0, d.entrypoint_path).replace(e,""):void 0,o=d.import_map_path?_url.fileURLToPath.call(void 0, d.import_map_path).replace(e,""):void 0,i=await s.GET("/v1/projects/{ref}/functions/{function_slug}/body",{params:{path:{ref:r,function_slug:n}},parseAs:"arrayBuffer"});c(i,"Failed to fetch Edge Function eszip bundle");let u=await O(new Uint8Array(i.data),e),m=await Promise.all(u.map(async y=>({name:y.name,content:await y.text()})));return{data:{...d,entrypoint_path:t,import_map_path:o,files:m},error:void 0}}function M(s,r=100){switch(s){case"api":return _commontags.stripIndent`
|
|
17
|
-
select id, identifier, timestamp, event_message, request.method, request.path, response.status_code
|
|
18
|
-
from edge_logs
|
|
19
|
-
cross join unnest(metadata) as m
|
|
20
|
-
cross join unnest(m.request) as request
|
|
21
|
-
cross join unnest(m.response) as response
|
|
22
|
-
order by timestamp desc
|
|
23
|
-
limit ${r}
|
|
24
|
-
`;case"branch-action":return _commontags.stripIndent`
|
|
25
|
-
select workflow_run, workflow_run_logs.timestamp, id, event_message from workflow_run_logs
|
|
26
|
-
order by timestamp desc
|
|
27
|
-
limit ${r}
|
|
28
|
-
`;case"postgres":return _commontags.stripIndent`
|
|
29
|
-
select identifier, postgres_logs.timestamp, id, event_message, parsed.error_severity from postgres_logs
|
|
30
|
-
cross join unnest(metadata) as m
|
|
31
|
-
cross join unnest(m.parsed) as parsed
|
|
32
|
-
order by timestamp desc
|
|
33
|
-
limit ${r}
|
|
34
|
-
`;case"edge-function":return _commontags.stripIndent`
|
|
35
|
-
select id, function_edge_logs.timestamp, event_message, response.status_code, request.method, m.function_id, m.execution_time_ms, m.deployment_id, m.version from function_edge_logs
|
|
36
|
-
cross join unnest(metadata) as m
|
|
37
|
-
cross join unnest(m.response) as response
|
|
38
|
-
cross join unnest(m.request) as request
|
|
39
|
-
order by timestamp desc
|
|
40
|
-
limit ${r}
|
|
41
|
-
`;case"auth":return _commontags.stripIndent`
|
|
42
|
-
select id, auth_logs.timestamp, event_message, metadata.level, metadata.status, metadata.path, metadata.msg as msg, metadata.error from auth_logs
|
|
43
|
-
cross join unnest(metadata) as metadata
|
|
44
|
-
order by timestamp desc
|
|
45
|
-
limit ${r}
|
|
46
|
-
`;case"storage":return _commontags.stripIndent`
|
|
47
|
-
select id, storage_logs.timestamp, event_message from storage_logs
|
|
48
|
-
order by timestamp desc
|
|
49
|
-
limit ${r}
|
|
50
|
-
`;case"realtime":return _commontags.stripIndent`
|
|
51
|
-
select id, realtime_logs.timestamp, event_message from realtime_logs
|
|
52
|
-
order by timestamp desc
|
|
53
|
-
limit ${r}
|
|
54
|
-
`;default:throw new Error(`unsupported log service type: ${s}`)}}var le="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ce="abcdefghijklmnopqrstuvwxyz",pe="0123456789",ge="!@#$%^&*()_+~`|}{[]:;?><,./-=",U=({length:s=10,numbers:r=!1,symbols:n=!1,uppercase:g=!0,lowercase:d=!0}={})=>{let l="";if(g&&(l+=le),d&&(l+=ce),r&&(l+=pe),n&&(l+=ge),l.length===0)throw new Error("at least one character set must be selected");let e=new Uint32Array(s);crypto.getRandomValues(e);let t="";for(let o=0;o<s;o++){let i=e[o]%l.length;t+=l.charAt(i)}return t};var D=`-- Adapted from information_schema.columns
|
|
55
|
-
|
|
56
|
-
SELECT
|
|
57
|
-
c.oid :: int8 AS table_id,
|
|
58
|
-
nc.nspname AS schema,
|
|
59
|
-
c.relname AS table,
|
|
60
|
-
(c.oid || '.' || a.attnum) AS id,
|
|
61
|
-
a.attnum AS ordinal_position,
|
|
62
|
-
a.attname AS name,
|
|
63
|
-
CASE
|
|
64
|
-
WHEN a.atthasdef THEN pg_get_expr(ad.adbin, ad.adrelid)
|
|
65
|
-
ELSE NULL
|
|
66
|
-
END AS default_value,
|
|
67
|
-
CASE
|
|
68
|
-
WHEN t.typtype = 'd' THEN CASE
|
|
69
|
-
WHEN bt.typelem <> 0 :: oid
|
|
70
|
-
AND bt.typlen = -1 THEN 'ARRAY'
|
|
71
|
-
WHEN nbt.nspname = 'pg_catalog' THEN format_type(t.typbasetype, NULL)
|
|
72
|
-
ELSE 'USER-DEFINED'
|
|
73
|
-
END
|
|
74
|
-
ELSE CASE
|
|
75
|
-
WHEN t.typelem <> 0 :: oid
|
|
76
|
-
AND t.typlen = -1 THEN 'ARRAY'
|
|
77
|
-
WHEN nt.nspname = 'pg_catalog' THEN format_type(a.atttypid, NULL)
|
|
78
|
-
ELSE 'USER-DEFINED'
|
|
79
|
-
END
|
|
80
|
-
END AS data_type,
|
|
81
|
-
COALESCE(bt.typname, t.typname) AS format,
|
|
82
|
-
a.attidentity IN ('a', 'd') AS is_identity,
|
|
83
|
-
CASE
|
|
84
|
-
a.attidentity
|
|
85
|
-
WHEN 'a' THEN 'ALWAYS'
|
|
86
|
-
WHEN 'd' THEN 'BY DEFAULT'
|
|
87
|
-
ELSE NULL
|
|
88
|
-
END AS identity_generation,
|
|
89
|
-
a.attgenerated IN ('s') AS is_generated,
|
|
90
|
-
NOT (
|
|
91
|
-
a.attnotnull
|
|
92
|
-
OR t.typtype = 'd' AND t.typnotnull
|
|
93
|
-
) AS is_nullable,
|
|
94
|
-
(
|
|
95
|
-
c.relkind IN ('r', 'p')
|
|
96
|
-
OR c.relkind IN ('v', 'f') AND pg_column_is_updatable(c.oid, a.attnum, FALSE)
|
|
97
|
-
) AS is_updatable,
|
|
98
|
-
uniques.table_id IS NOT NULL AS is_unique,
|
|
99
|
-
check_constraints.definition AS "check",
|
|
100
|
-
array_to_json(
|
|
101
|
-
array(
|
|
102
|
-
SELECT
|
|
103
|
-
enumlabel
|
|
104
|
-
FROM
|
|
105
|
-
pg_catalog.pg_enum enums
|
|
106
|
-
WHERE
|
|
107
|
-
enums.enumtypid = coalesce(bt.oid, t.oid)
|
|
108
|
-
OR enums.enumtypid = coalesce(bt.typelem, t.typelem)
|
|
109
|
-
ORDER BY
|
|
110
|
-
enums.enumsortorder
|
|
111
|
-
)
|
|
112
|
-
) AS enums,
|
|
113
|
-
col_description(c.oid, a.attnum) AS comment
|
|
114
|
-
FROM
|
|
115
|
-
pg_attribute a
|
|
116
|
-
LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid
|
|
117
|
-
AND a.attnum = ad.adnum
|
|
118
|
-
JOIN (
|
|
119
|
-
pg_class c
|
|
120
|
-
JOIN pg_namespace nc ON c.relnamespace = nc.oid
|
|
121
|
-
) ON a.attrelid = c.oid
|
|
122
|
-
JOIN (
|
|
123
|
-
pg_type t
|
|
124
|
-
JOIN pg_namespace nt ON t.typnamespace = nt.oid
|
|
125
|
-
) ON a.atttypid = t.oid
|
|
126
|
-
LEFT JOIN (
|
|
127
|
-
pg_type bt
|
|
128
|
-
JOIN pg_namespace nbt ON bt.typnamespace = nbt.oid
|
|
129
|
-
) ON t.typtype = 'd'
|
|
130
|
-
AND t.typbasetype = bt.oid
|
|
131
|
-
LEFT JOIN (
|
|
132
|
-
SELECT DISTINCT ON (table_id, ordinal_position)
|
|
133
|
-
conrelid AS table_id,
|
|
134
|
-
conkey[1] AS ordinal_position
|
|
135
|
-
FROM pg_catalog.pg_constraint
|
|
136
|
-
WHERE contype = 'u' AND cardinality(conkey) = 1
|
|
137
|
-
) AS uniques ON uniques.table_id = c.oid AND uniques.ordinal_position = a.attnum
|
|
138
|
-
LEFT JOIN (
|
|
139
|
-
-- We only select the first column check
|
|
140
|
-
SELECT DISTINCT ON (table_id, ordinal_position)
|
|
141
|
-
conrelid AS table_id,
|
|
142
|
-
conkey[1] AS ordinal_position,
|
|
143
|
-
substring(
|
|
144
|
-
pg_get_constraintdef(pg_constraint.oid, true),
|
|
145
|
-
8,
|
|
146
|
-
length(pg_get_constraintdef(pg_constraint.oid, true)) - 8
|
|
147
|
-
) AS "definition"
|
|
148
|
-
FROM pg_constraint
|
|
149
|
-
WHERE contype = 'c' AND cardinality(conkey) = 1
|
|
150
|
-
ORDER BY table_id, ordinal_position, oid asc
|
|
151
|
-
) AS check_constraints ON check_constraints.table_id = c.oid AND check_constraints.ordinal_position = a.attnum
|
|
152
|
-
WHERE
|
|
153
|
-
NOT pg_is_other_temp_schema(nc.oid)
|
|
154
|
-
AND a.attnum > 0
|
|
155
|
-
AND NOT a.attisdropped
|
|
156
|
-
AND (c.relkind IN ('r', 'v', 'm', 'f', 'p'))
|
|
157
|
-
AND (
|
|
158
|
-
pg_has_role(c.relowner, 'USAGE')
|
|
159
|
-
OR has_column_privilege(
|
|
160
|
-
c.oid,
|
|
161
|
-
a.attnum,
|
|
162
|
-
'SELECT, INSERT, UPDATE, REFERENCES'
|
|
163
|
-
)
|
|
164
|
-
)
|
|
165
|
-
`;var P=`SELECT
|
|
166
|
-
e.name,
|
|
167
|
-
n.nspname AS schema,
|
|
168
|
-
e.default_version,
|
|
169
|
-
x.extversion AS installed_version,
|
|
170
|
-
e.comment
|
|
171
|
-
FROM
|
|
172
|
-
pg_available_extensions() e(name, default_version, comment)
|
|
173
|
-
LEFT JOIN pg_extension x ON e.name = x.extname
|
|
174
|
-
LEFT JOIN pg_namespace n ON x.extnamespace = n.oid
|
|
175
|
-
`;var k=`SELECT
|
|
176
|
-
c.oid :: int8 AS id,
|
|
177
|
-
nc.nspname AS schema,
|
|
178
|
-
c.relname AS name,
|
|
179
|
-
c.relrowsecurity AS rls_enabled,
|
|
180
|
-
c.relforcerowsecurity AS rls_forced,
|
|
181
|
-
CASE
|
|
182
|
-
WHEN c.relreplident = 'd' THEN 'DEFAULT'
|
|
183
|
-
WHEN c.relreplident = 'i' THEN 'INDEX'
|
|
184
|
-
WHEN c.relreplident = 'f' THEN 'FULL'
|
|
185
|
-
ELSE 'NOTHING'
|
|
186
|
-
END AS replica_identity,
|
|
187
|
-
pg_total_relation_size(format('%I.%I', nc.nspname, c.relname)) :: int8 AS bytes,
|
|
188
|
-
pg_size_pretty(
|
|
189
|
-
pg_total_relation_size(format('%I.%I', nc.nspname, c.relname))
|
|
190
|
-
) AS size,
|
|
191
|
-
pg_stat_get_live_tuples(c.oid) AS live_rows_estimate,
|
|
192
|
-
pg_stat_get_dead_tuples(c.oid) AS dead_rows_estimate,
|
|
193
|
-
obj_description(c.oid) AS comment,
|
|
194
|
-
coalesce(pk.primary_keys, '[]') as primary_keys,
|
|
195
|
-
coalesce(
|
|
196
|
-
jsonb_agg(relationships) filter (where relationships is not null),
|
|
197
|
-
'[]'
|
|
198
|
-
) as relationships
|
|
199
|
-
FROM
|
|
200
|
-
pg_namespace nc
|
|
201
|
-
JOIN pg_class c ON nc.oid = c.relnamespace
|
|
202
|
-
left join (
|
|
203
|
-
select
|
|
204
|
-
table_id,
|
|
205
|
-
jsonb_agg(_pk.*) as primary_keys
|
|
206
|
-
from (
|
|
207
|
-
select
|
|
208
|
-
n.nspname as schema,
|
|
209
|
-
c.relname as table_name,
|
|
210
|
-
a.attname as name,
|
|
211
|
-
c.oid :: int8 as table_id
|
|
212
|
-
from
|
|
213
|
-
pg_index i,
|
|
214
|
-
pg_class c,
|
|
215
|
-
pg_attribute a,
|
|
216
|
-
pg_namespace n
|
|
217
|
-
where
|
|
218
|
-
i.indrelid = c.oid
|
|
219
|
-
and c.relnamespace = n.oid
|
|
220
|
-
and a.attrelid = c.oid
|
|
221
|
-
and a.attnum = any (i.indkey)
|
|
222
|
-
and i.indisprimary
|
|
223
|
-
) as _pk
|
|
224
|
-
group by table_id
|
|
225
|
-
) as pk
|
|
226
|
-
on pk.table_id = c.oid
|
|
227
|
-
left join (
|
|
228
|
-
select
|
|
229
|
-
c.oid :: int8 as id,
|
|
230
|
-
c.conname as constraint_name,
|
|
231
|
-
nsa.nspname as source_schema,
|
|
232
|
-
csa.relname as source_table_name,
|
|
233
|
-
sa.attname as source_column_name,
|
|
234
|
-
nta.nspname as target_table_schema,
|
|
235
|
-
cta.relname as target_table_name,
|
|
236
|
-
ta.attname as target_column_name
|
|
237
|
-
from
|
|
238
|
-
pg_constraint c
|
|
239
|
-
join (
|
|
240
|
-
pg_attribute sa
|
|
241
|
-
join pg_class csa on sa.attrelid = csa.oid
|
|
242
|
-
join pg_namespace nsa on csa.relnamespace = nsa.oid
|
|
243
|
-
) on sa.attrelid = c.conrelid and sa.attnum = any (c.conkey)
|
|
244
|
-
join (
|
|
245
|
-
pg_attribute ta
|
|
246
|
-
join pg_class cta on ta.attrelid = cta.oid
|
|
247
|
-
join pg_namespace nta on cta.relnamespace = nta.oid
|
|
248
|
-
) on ta.attrelid = c.confrelid and ta.attnum = any (c.confkey)
|
|
249
|
-
where
|
|
250
|
-
c.contype = 'f'
|
|
251
|
-
) as relationships
|
|
252
|
-
on (relationships.source_schema = nc.nspname and relationships.source_table_name = c.relname)
|
|
253
|
-
or (relationships.target_table_schema = nc.nspname and relationships.target_table_name = c.relname)
|
|
254
|
-
WHERE
|
|
255
|
-
c.relkind IN ('r', 'p')
|
|
256
|
-
AND NOT pg_is_other_temp_schema(nc.oid)
|
|
257
|
-
AND (
|
|
258
|
-
pg_has_role(c.relowner, 'USAGE')
|
|
259
|
-
OR has_table_privilege(
|
|
260
|
-
c.oid,
|
|
261
|
-
'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'
|
|
262
|
-
)
|
|
263
|
-
OR has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES')
|
|
264
|
-
)
|
|
265
|
-
group by
|
|
266
|
-
c.oid,
|
|
267
|
-
c.relname,
|
|
268
|
-
c.relrowsecurity,
|
|
269
|
-
c.relforcerowsecurity,
|
|
270
|
-
c.relreplident,
|
|
271
|
-
nc.nspname,
|
|
272
|
-
pk.primary_keys
|
|
273
|
-
`;var he=["information_schema","pg_catalog","pg_toast"];function G(s=[]){let r=_commontags.stripIndent`
|
|
274
|
-
with
|
|
275
|
-
tables as (${k}),
|
|
276
|
-
columns as (${D})
|
|
277
|
-
select
|
|
278
|
-
*,
|
|
279
|
-
${fe("columns","columns.table_id = tables.id")}
|
|
280
|
-
from tables
|
|
281
|
-
`;return s.length>0?r+=` where schema in (${s.map(n=>`'${n}'`).join(",")})`:r+=` where schema not in (${he.map(n=>`'${n}'`).join(",")})`,r}function W(){return P}var fe=(s,r)=>_commontags.stripIndent`
|
|
282
|
-
COALESCE(
|
|
283
|
-
(
|
|
284
|
-
SELECT
|
|
285
|
-
array_agg(row_to_json(${s})) FILTER (WHERE ${r})
|
|
286
|
-
FROM
|
|
287
|
-
${s}
|
|
288
|
-
),
|
|
289
|
-
'{}'
|
|
290
|
-
) AS ${s}
|
|
291
|
-
`;var _e=10,ye=.01344;async function N(s,r){let n=await s.GET("/v1/organizations/{slug}",{params:{path:{slug:r}}});c(n,"Failed to fetch organization");let g=await s.GET("/v1/projects");c(g,"Failed to fetch projects");let d=n.data,l=g.data.filter(t=>t.organization_id===r&&!["INACTIVE","GOING_DOWN","REMOVED"].includes(t.status)),e=0;return d.plan!=="free"&&l.length>0&&(e=_e),{type:"project",recurrence:"monthly",amount:e}}function j(){return{type:"branch",recurrence:"hourly",amount:ye}}function q(s){return Object.fromEntries(s.split(`
|
|
292
|
-
`).map(r=>r.split(/=(.*)/)).filter(([r])=>r).map(([r,n])=>[r,_nullishCoalesce(n, () => (""))]))}async function S(s,r){let n=JSON.stringify(s,(l,e)=>e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).sort().reduce((t,o)=>(t[o]=e[o],t),{}):e),g=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return btoa(String.fromCharCode(...new Uint8Array(g))).slice(0,r)}var be=6371,Ee="https://www.cloudflare.com/cdn-cgi/trace",Se={AF:{lat:33,lng:65},AX:{lat:60.116667,lng:19.9},AL:{lat:41,lng:20},DZ:{lat:28,lng:3},AS:{lat:-14.3333,lng:-170},AD:{lat:42.5,lng:1.6},AO:{lat:-12.5,lng:18.5},AI:{lat:18.25,lng:-63.1667},AQ:{lat:-90,lng:0},AG:{lat:17.05,lng:-61.8},AR:{lat:-34,lng:-64},AM:{lat:40,lng:45},AW:{lat:12.5,lng:-69.9667},AU:{lat:-27,lng:133},AT:{lat:47.3333,lng:13.3333},AZ:{lat:40.5,lng:47.5},BS:{lat:24.25,lng:-76},BH:{lat:26,lng:50.55},BD:{lat:24,lng:90},BB:{lat:13.1667,lng:-59.5333},BY:{lat:53,lng:28},BE:{lat:50.8333,lng:4},BZ:{lat:17.25,lng:-88.75},BJ:{lat:9.5,lng:2.25},BM:{lat:32.3333,lng:-64.75},BT:{lat:27.5,lng:90.5},BO:{lat:-17,lng:-65},BQ:{lat:12.183333,lng:-68.233333},BA:{lat:44,lng:18},BW:{lat:-22,lng:24},BV:{lat:-54.4333,lng:3.4},BR:{lat:-10,lng:-55},IO:{lat:-6,lng:71.5},BN:{lat:4.5,lng:114.6667},BG:{lat:43,lng:25},BF:{lat:13,lng:-2},MM:{lat:22,lng:98},BI:{lat:-3.5,lng:30},KH:{lat:13,lng:105},CM:{lat:6,lng:12},CA:{lat:60,lng:-95},CV:{lat:16,lng:-24},KY:{lat:19.5,lng:-80.5},CF:{lat:7,lng:21},TD:{lat:15,lng:19},CL:{lat:-30,lng:-71},CN:{lat:35,lng:105},CX:{lat:-10.5,lng:105.6667},CC:{lat:-12.5,lng:96.8333},CO:{lat:4,lng:-72},KM:{lat:-12.1667,lng:44.25},CD:{lat:0,lng:25},CG:{lat:-1,lng:15},CK:{lat:-21.2333,lng:-159.7667},CR:{lat:10,lng:-84},CI:{lat:8,lng:-5},HR:{lat:45.1667,lng:15.5},CU:{lat:21.5,lng:-80},CW:{lat:12.166667,lng:-68.966667},CY:{lat:35,lng:33},CZ:{lat:49.75,lng:15.5},DK:{lat:56,lng:10},DJ:{lat:11.5,lng:43},DM:{lat:15.4167,lng:-61.3333},DO:{lat:19,lng:-70.6667},EC:{lat:-2,lng:-77.5},EG:{lat:27,lng:30},SV:{lat:13.8333,lng:-88.9167},GQ:{lat:2,lng:10},ER:{lat:15,lng:39},EE:{lat:59,lng:26},ET:{lat:8,lng:38},FK:{lat:-51.75,lng:-59},FO:{lat:62,lng:-7},FJ:{lat:-18,lng:175},FI:{lat:64,lng:26},FR:{lat:46,lng:2},GF:{lat:4,lng:-53},PF:{lat:-15,lng:-140},TF:{lat:-43,lng:67},GA:{lat:-1,lng:11.75},GM:{lat:13.4667,lng:-16.5667},GE:{lat:42,lng:43.5},DE:{lat:51,lng:9},GH:{lat:8,lng:-2},GI:{lat:36.1833,lng:-5.3667},GR:{lat:39,lng:22},GL:{lat:72,lng:-40},GD:{lat:12.1167,lng:-61.6667},GP:{lat:16.25,lng:-61.5833},GU:{lat:13.4667,lng:144.7833},GT:{lat:15.5,lng:-90.25},GG:{lat:49.5,lng:-2.56},GW:{lat:12,lng:-15},GN:{lat:11,lng:-10},GY:{lat:5,lng:-59},HT:{lat:19,lng:-72.4167},HM:{lat:-53.1,lng:72.5167},VA:{lat:41.9,lng:12.45},HN:{lat:15,lng:-86.5},HK:{lat:22.25,lng:114.1667},HU:{lat:47,lng:20},IS:{lat:65,lng:-18},IN:{lat:20,lng:77},ID:{lat:-5,lng:120},IR:{lat:32,lng:53},IQ:{lat:33,lng:44},IE:{lat:53,lng:-8},IM:{lat:54.23,lng:-4.55},IL:{lat:31.5,lng:34.75},IT:{lat:42.8333,lng:12.8333},JM:{lat:18.25,lng:-77.5},JP:{lat:36,lng:138},JE:{lat:49.21,lng:-2.13},JO:{lat:31,lng:36},KZ:{lat:48,lng:68},KE:{lat:1,lng:38},KI:{lat:1.4167,lng:173},KP:{lat:40,lng:127},KR:{lat:37,lng:127.5},XK:{lat:42.583333,lng:21},KW:{lat:29.3375,lng:47.6581},KG:{lat:41,lng:75},LA:{lat:18,lng:105},LV:{lat:57,lng:25},LB:{lat:33.8333,lng:35.8333},LS:{lat:-29.5,lng:28.5},LR:{lat:6.5,lng:-9.5},LY:{lat:25,lng:17},LI:{lat:47.1667,lng:9.5333},LT:{lat:56,lng:24},LU:{lat:49.75,lng:6.1667},MO:{lat:22.1667,lng:113.55},MK:{lat:41.8333,lng:22},MG:{lat:-20,lng:47},MW:{lat:-13.5,lng:34},MY:{lat:2.5,lng:112.5},MV:{lat:3.25,lng:73},ML:{lat:17,lng:-4},MT:{lat:35.8333,lng:14.5833},MH:{lat:9,lng:168},MQ:{lat:14.6667,lng:-61},MR:{lat:20,lng:-12},MU:{lat:-20.2833,lng:57.55},YT:{lat:-12.8333,lng:45.1667},MX:{lat:23,lng:-102},FM:{lat:6.9167,lng:158.25},MD:{lat:47,lng:29},MC:{lat:43.7333,lng:7.4},MN:{lat:46,lng:105},ME:{lat:42,lng:19},MS:{lat:16.75,lng:-62.2},MA:{lat:32,lng:-5},MZ:{lat:-18.25,lng:35},NA:{lat:-22,lng:17},NR:{lat:-.5333,lng:166.9167},NP:{lat:28,lng:84},AN:{lat:12.25,lng:-68.75},NL:{lat:52.5,lng:5.75},NC:{lat:-21.5,lng:165.5},NZ:{lat:-41,lng:174},NI:{lat:13,lng:-85},NE:{lat:16,lng:8},NG:{lat:10,lng:8},NU:{lat:-19.0333,lng:-169.8667},NF:{lat:-29.0333,lng:167.95},MP:{lat:15.2,lng:145.75},NO:{lat:62,lng:10},OM:{lat:21,lng:57},PK:{lat:30,lng:70},PW:{lat:7.5,lng:134.5},PS:{lat:32,lng:35.25},PA:{lat:9,lng:-80},PG:{lat:-6,lng:147},PY:{lat:-23,lng:-58},PE:{lat:-10,lng:-76},PH:{lat:13,lng:122},PN:{lat:-24.7,lng:-127.4},PL:{lat:52,lng:20},PT:{lat:39.5,lng:-8},PR:{lat:18.25,lng:-66.5},QA:{lat:25.5,lng:51.25},RE:{lat:-21.1,lng:55.6},RO:{lat:46,lng:25},RU:{lat:60,lng:100},RW:{lat:-2,lng:30},BL:{lat:17.897728,lng:-62.834244},SH:{lat:-15.9333,lng:-5.7},KN:{lat:17.3333,lng:-62.75},LC:{lat:13.8833,lng:-61.1333},MF:{lat:18.075278,lng:-63.06},PM:{lat:46.8333,lng:-56.3333},VC:{lat:13.25,lng:-61.2},WS:{lat:-13.5833,lng:-172.3333},SM:{lat:43.7667,lng:12.4167},ST:{lat:1,lng:7},SA:{lat:25,lng:45},SN:{lat:14,lng:-14},RS:{lat:44,lng:21},SC:{lat:-4.5833,lng:55.6667},SL:{lat:8.5,lng:-11.5},SG:{lat:1.3667,lng:103.8},SX:{lat:18.033333,lng:-63.05},SK:{lat:48.6667,lng:19.5},SI:{lat:46,lng:15},SB:{lat:-8,lng:159},SO:{lat:10,lng:49},ZA:{lat:-29,lng:24},GS:{lat:-54.5,lng:-37},SS:{lat:8,lng:30},ES:{lat:40,lng:-4},LK:{lat:7,lng:81},SD:{lat:15,lng:30},SR:{lat:4,lng:-56},SJ:{lat:78,lng:20},SZ:{lat:-26.5,lng:31.5},SE:{lat:62,lng:15},CH:{lat:47,lng:8},SY:{lat:35,lng:38},TW:{lat:23.5,lng:121},TJ:{lat:39,lng:71},TZ:{lat:-6,lng:35},TH:{lat:15,lng:100},TL:{lat:-8.55,lng:125.5167},TG:{lat:8,lng:1.1667},TK:{lat:-9,lng:-172},TO:{lat:-20,lng:-175},TT:{lat:11,lng:-61},TN:{lat:34,lng:9},TR:{lat:39,lng:35},TM:{lat:40,lng:60},TC:{lat:21.75,lng:-71.5833},TV:{lat:-8,lng:178},UG:{lat:1,lng:32},UA:{lat:49,lng:32},AE:{lat:24,lng:54},GB:{lat:54,lng:-2},UM:{lat:19.2833,lng:166.6},US:{lat:38,lng:-97},UY:{lat:-33,lng:-56},UZ:{lat:41,lng:64},VU:{lat:-16,lng:167},VE:{lat:8,lng:-66},VN:{lat:16,lng:106},VG:{lat:18.5,lng:-64.5},VI:{lat:18.3333,lng:-64.8333},WF:{lat:-13.3,lng:-176.2},EH:{lat:24.5,lng:-13},YE:{lat:15,lng:48},ZM:{lat:-15,lng:30},ZW:{lat:-20,lng:30}},C={WEST_US:{code:"us-west-1",displayName:"West US (North California)",location:{lat:37.774929,lng:-122.419418}},EAST_US:{code:"us-east-1",displayName:"East US (North Virginia)",location:{lat:37.926868,lng:-78.024902}},EAST_US_2:{code:"us-east-2",displayName:"East US (Ohio)",location:{lat:39.9612,lng:-82.9988}},CENTRAL_CANADA:{code:"ca-central-1",displayName:"Canada (Central)",location:{lat:56.130367,lng:-106.346771}},WEST_EU:{code:"eu-west-1",displayName:"West EU (Ireland)",location:{lat:53.3498,lng:-6.2603}},WEST_EU_2:{code:"eu-west-2",displayName:"West Europe (London)",location:{lat:51.507351,lng:-.127758}},WEST_EU_3:{code:"eu-west-3",displayName:"West EU (Paris)",location:{lat:2.352222,lng:48.856613}},CENTRAL_EU:{code:"eu-central-1",displayName:"Central EU (Frankfurt)",location:{lat:50.110924,lng:8.682127}},CENTRAL_EU_2:{code:"eu-central-2",displayName:"Central Europe (Zurich)",location:{lat:47.3744489,lng:8.5410422}},NORTH_EU:{code:"eu-north-1",displayName:"North EU (Stockholm)",location:{lat:59.3251172,lng:18.0710935}},SOUTH_ASIA:{code:"ap-south-1",displayName:"South Asia (Mumbai)",location:{lat:18.9733536,lng:72.8281049}},SOUTHEAST_ASIA:{code:"ap-southeast-1",displayName:"Southeast Asia (Singapore)",location:{lat:1.357107,lng:103.8194992}},NORTHEAST_ASIA:{code:"ap-northeast-1",displayName:"Northeast Asia (Tokyo)",location:{lat:35.6895,lng:139.6917}},NORTHEAST_ASIA_2:{code:"ap-northeast-2",displayName:"Northeast Asia (Seoul)",location:{lat:37.5665,lng:126.978}},OCEANIA:{code:"ap-southeast-2",displayName:"Oceania (Sydney)",location:{lat:-33.8688,lng:151.2093}},SOUTH_AMERICA:{code:"sa-east-1",displayName:"South America (S\xE3o Paulo)",location:{lat:-1.2043218,lng:-47.1583944}}},B=Object.values(C).map(s=>s.code);function $(s){let n=Object.entries(C).map(([d,l])=>[d,Te(s,l.location)]).reduce((d,l)=>d===void 0||l[1]<d[1]?l:d,void 0);if(!n)throw new Error("no closest region found");let[g]=n;return C[g]}async function z(){let r=await(await fetch(Ee)).text(),g=q(r).loc;if(!g)throw new Error("location not found");return g}function J(s){let r=Se[s];if(!r)throw new Error(`unknown location code: ${s}`);return r}function Te(s,r){let n=T(r.lat-s.lat),g=T(r.lng-s.lng),d=Math.sin(n/2)*Math.sin(n/2)+Math.cos(T(s.lat))*Math.cos(T(r.lat))*Math.sin(g/2)*Math.sin(g/2),l=2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d));return be*l}function T(s){return s*(Math.PI/180)}var{version:K}=x;function mt(s){let r=_nullishCoalesce(s.platform.apiUrl, () => ("https://api.supabase.com")),n;async function g(e,t){let o=await n.POST("/v1/projects/{ref}/database/query",{params:{path:{ref:e}},body:{query:t,read_only:s.readOnly}});return c(o,"Failed to execute SQL query"),o.data}async function d(){return $(J(await z())).code}return _mcputils.createMcpServer.call(void 0, {name:"supabase",version:K,onInitialize(e){n=I(r,s.platform.accessToken,{"User-Agent":`supabase-mcp/${K} (${e.name}/${e.version})`})},tools:{list_projects:_mcputils.tool.call(void 0, {description:"Lists all Supabase projects for the user.",parameters:_zod.z.object({}),execute:async()=>{let e=await n.GET("/v1/projects");return c(e,"Failed to fetch projects"),e.data}}),get_project:_mcputils.tool.call(void 0, {description:"Gets details for a Supabase project.",parameters:_zod.z.object({id:_zod.z.string().describe("The project ID")}),execute:async({id:e})=>{let t=await n.GET("/v1/projects/{ref}",{params:{path:{ref:e}}});return c(t,"Failed to fetch project"),t.data}}),get_cost:_mcputils.tool.call(void 0, {description:"Gets the cost of creating a new project or branch. Never assume organization as costs can be different for each.",parameters:_zod.z.object({type:_zod.z.enum(["project","branch"]),organization_id:_zod.z.string().describe("The organization ID. Always ask the user.")}),execute:async({type:e,organization_id:t})=>{function o(i){return`The new ${e} will cost $${i.amount} ${i.recurrence}. You must repeat this to the user and confirm their understanding.`}switch(e){case"project":{let i=await N(n,t);return o(i)}case"branch":{let i=j();return o(i)}default:throw new Error(`Unknown cost type: ${e}`)}}}),confirm_cost:_mcputils.tool.call(void 0, {description:"Ask the user to confirm their understanding of the cost of creating a new project or branch. Call `get_cost` first. Returns a unique ID for this confirmation which should be passed to `create_project` or `create_branch`.",parameters:_zod.z.object({type:_zod.z.enum(["project","branch"]),recurrence:_zod.z.enum(["hourly","monthly"]),amount:_zod.z.number()}),execute:async e=>await S(e)}),create_project:_mcputils.tool.call(void 0, {description:"Creates a new Supabase project. Always ask the user which organization to create the project in. The project can take a few minutes to initialize - use `get_project` to check the status.",parameters:_zod.z.object({name:_zod.z.string().describe("The name of the project"),region:_zod.z.optional(_zod.z.enum(B).describe("The region to create the project in. Defaults to the closest region.")),organization_id:_zod.z.string(),confirm_cost_id:_zod.z.string({required_error:"User must confirm understanding of costs before creating a project."}).describe("The cost confirmation ID. Call `confirm_cost` first.")}),execute:async({name:e,region:t,organization_id:o,confirm_cost_id:i})=>{let u=await N(n,o);if(await S(u)!==i)throw new Error("Cost confirmation ID does not match the expected cost of creating a project.");let h=await n.POST("/v1/projects",{body:{name:e,region:await _asyncNullishCoalesce(t, async () => (await d())),organization_id:o,db_pass:U({length:16,numbers:!0,uppercase:!0,lowercase:!0})}});return c(h,"Failed to create project"),h.data}}),pause_project:_mcputils.tool.call(void 0, {description:"Pauses a Supabase project.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.POST("/v1/projects/{ref}/pause",{params:{path:{ref:e}}});c(t,"Failed to pause project")}}),restore_project:_mcputils.tool.call(void 0, {description:"Restores a Supabase project.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.POST("/v1/projects/{ref}/restore",{params:{path:{ref:e}},body:{}});c(t,"Failed to restore project")}}),list_organizations:_mcputils.tool.call(void 0, {description:"Lists all organizations that the user is a member of.",parameters:_zod.z.object({}),execute:async()=>{let e=await n.GET("/v1/organizations");return c(e,"Failed to fetch organizations"),e.data}}),get_organization:_mcputils.tool.call(void 0, {description:"Gets details for an organization. Includes subscription plan.",parameters:_zod.z.object({id:_zod.z.string().describe("The organization ID")}),execute:async({id:e})=>{let t=await n.GET("/v1/organizations/{slug}",{params:{path:{slug:e}}});return c(t,"Failed to fetch organization"),t.data}}),list_tables:_mcputils.tool.call(void 0, {description:"Lists all tables in a schema.",parameters:_zod.z.object({project_id:_zod.z.string(),schemas:_zod.z.optional(_zod.z.array(_zod.z.string())).describe("Optional list of schemas to include. Defaults to all schemas.")}),execute:async({project_id:e,schemas:t})=>{let o=G(t);return await g(e,o)}}),list_extensions:_mcputils.tool.call(void 0, {description:"Lists all extensions in the database.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=W();return await g(e,t)}}),list_migrations:_mcputils.tool.call(void 0, {description:"Lists all migrations in the database.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.GET("/v1/projects/{ref}/database/migrations",{params:{path:{ref:e}}});return c(t,"Failed to fetch migrations"),t.data}}),apply_migration:_mcputils.tool.call(void 0, {description:"Applies a migration to the database. Use this when executing DDL operations. Do not hardcode references to generated IDs in data migrations.",parameters:_zod.z.object({project_id:_zod.z.string(),name:_zod.z.string().describe("The name of the migration in snake_case"),query:_zod.z.string().describe("The SQL query to apply")}),execute:async({project_id:e,name:t,query:o})=>{if(s.readOnly)throw new Error("Cannot apply migration in read-only mode.");let i=await n.POST("/v1/projects/{ref}/database/migrations",{params:{path:{ref:e}},body:{name:t,query:o}});return c(i,"Failed to apply migration"),i.data}}),execute_sql:_mcputils.tool.call(void 0, {description:"Executes raw SQL in the Postgres database. Use `apply_migration` instead for DDL operations.",parameters:_zod.z.object({project_id:_zod.z.string(),query:_zod.z.string().describe("The SQL query to execute")}),execute:async({query:e,project_id:t})=>await g(t,e)}),list_edge_functions:_mcputils.tool.call(void 0, {description:"Lists all Edge Functions in a Supabase project.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.GET("/v1/projects/{ref}/functions",{params:{path:{ref:e}}});return c(t,"Failed to fetch Edge Functions"),await Promise.all(t.data.map(async i=>{let{data:u,error:m}=await w(n,e,i.slug);if(m)throw m;return u}))}}),deploy_edge_function:_mcputils.tool.call(void 0, {description:`Deploys an Edge Function to a Supabase project. If the function already exists, this will create a new version. Example:
|
|
293
|
-
|
|
294
|
-
${F}`,parameters:_zod.z.object({project_id:_zod.z.string(),name:_zod.z.string().describe("The name of the function"),entrypoint_path:_zod.z.string().default("index.ts").describe("The entrypoint of the function"),import_map_path:_zod.z.string().describe("The import map for the function.").optional(),files:_zod.z.array(_zod.z.object({name:_zod.z.string(),content:_zod.z.string()})).describe("The files to upload. This should include the entrypoint and any relative dependencies.")}),execute:async({project_id:e,name:t,entrypoint_path:o,import_map_path:i,files:u})=>{let{data:m}=await w(n,e,t),h=u.find(E=>["deno.json","import_map.json"].includes(E.name));i??=_nullishCoalesce(_optionalChain([m, 'optionalAccess', _2 => _2.import_map_path]), () => (_optionalChain([h, 'optionalAccess', _3 => _3.name])));let y=await n.POST("/v1/projects/{ref}/functions/deploy",{params:{path:{ref:e},query:{slug:t}},body:{metadata:{name:t,entrypoint_path:o,import_map_path:i},file:u},bodySerializer(E){let A=new FormData,Y=new Blob([JSON.stringify(E.metadata)],{type:"application/json"});return A.append("metadata",Y),_optionalChain([E, 'access', _4 => _4.file, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6(V=>{let R=V,Z=new Blob([R.content],{type:"application/typescript"});A.append("file",Z,R.name)})]),A}});return c(y,"Failed to deploy Edge Function"),y.data}}),get_logs:_mcputils.tool.call(void 0, {description:"Gets logs for a Supabase project by service type. Use this to help debug problems with your app. This will only return logs within the last minute. If the logs you are looking for are older than 1 minute, re-run your test to reproduce them.",parameters:_zod.z.object({project_id:_zod.z.string(),service:_zod.z.enum(["api","branch-action","postgres","edge-function","auth","storage","realtime"]).describe("The service to fetch logs for")}),execute:async({project_id:e,service:t})=>{let o=t==="branch-action"?new Date(Date.now()-3e5):void 0,i=await n.GET("/v1/projects/{ref}/analytics/endpoints/logs.all",{params:{path:{ref:e},query:{iso_timestamp_start:_optionalChain([o, 'optionalAccess', _7 => _7.toISOString, 'call', _8 => _8()]),sql:M(t)}}});return c(i,"Failed to fetch logs"),i.data}}),get_project_url:_mcputils.tool.call(void 0, {description:"Gets the API URL for a project.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>`https://${e}.supabase.co`}),get_anon_key:_mcputils.tool.call(void 0, {description:"Gets the anonymous API key for a project.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.GET("/v1/projects/{ref}/api-keys",{params:{path:{ref:e},query:{reveal:!1}}});c(t,"Failed to fetch API keys");let o=_optionalChain([t, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.find, 'call', _11 => _11(i=>i.name==="anon")]);if(!o)throw new Error("Anonymous key not found");return o.api_key}}),generate_typescript_types:_mcputils.tool.call(void 0, {description:"Generates TypeScript types for a project.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.GET("/v1/projects/{ref}/types/typescript",{params:{path:{ref:e}}});return c(t,"Failed to fetch TypeScript types"),t.data}}),create_branch:_mcputils.tool.call(void 0, {description:"Creates a development branch on a Supabase project. This will apply all migrations from the main project to a fresh branch database. Note that production data will not carry over. The branch will get its own project_id via the resulting project_ref. Use this ID to execute queries and migrations on the branch.",parameters:_zod.z.object({project_id:_zod.z.string(),name:_zod.z.string().default("develop").describe("Name of the branch to create"),confirm_cost_id:_zod.z.string({required_error:"User must confirm understanding of costs before creating a branch."}).describe("The cost confirmation ID. Call `confirm_cost` first.")}),execute:async({project_id:e,name:t,confirm_cost_id:o})=>{let i=j();if(await S(i)!==o)throw new Error("Cost confirmation ID does not match the expected cost of creating a branch.");let m=await n.POST("/v1/projects/{ref}/branches",{params:{path:{ref:e}},body:{branch_name:t}});if(c(m,"Failed to create branch"),m.data.is_default){await n.PATCH("/v1/branches/{branch_id}",{params:{path:{branch_id:m.data.id}},body:{branch_name:"main"}});let h=await n.POST("/v1/projects/{ref}/branches",{params:{path:{ref:e}},body:{branch_name:t}});return c(h,"Failed to create branch"),h.data}return m.data}}),list_branches:_mcputils.tool.call(void 0, {description:"Lists all development branches of a Supabase project. This will return branch details including status which you can use to check when operations like merge/rebase/reset complete.",parameters:_zod.z.object({project_id:_zod.z.string()}),execute:async({project_id:e})=>{let t=await n.GET("/v1/projects/{ref}/branches",{params:{path:{ref:e}}});return t.response.status===422?[]:(c(t,"Failed to list branches"),t.data)}}),delete_branch:_mcputils.tool.call(void 0, {description:"Deletes a development branch.",parameters:_zod.z.object({branch_id:_zod.z.string()}),execute:async({branch_id:e})=>{let t=await n.DELETE("/v1/branches/{branch_id}",{params:{path:{branch_id:e}}});return c(t,"Failed to delete branch"),t.data}}),merge_branch:_mcputils.tool.call(void 0, {description:"Merges migrations and edge functions from a development branch to production.",parameters:_zod.z.object({branch_id:_zod.z.string()}),execute:async({branch_id:e})=>{let t=await n.POST("/v1/branches/{branch_id}/merge",{params:{path:{branch_id:e}},body:{}});return c(t,"Failed to merge branch"),t.data}}),reset_branch:_mcputils.tool.call(void 0, {description:"Resets migrations of a development branch. Any untracked data or schema changes will be lost.",parameters:_zod.z.object({branch_id:_zod.z.string(),migration_version:_zod.z.string().optional().describe("Reset your development branch to a specific migration version.")}),execute:async({branch_id:e,migration_version:t})=>{let o=await n.POST("/v1/branches/{branch_id}/reset",{params:{path:{branch_id:e}},body:{migration_version:t}});return c(o,"Failed to reset branch"),o.data}}),rebase_branch:_mcputils.tool.call(void 0, {description:"Rebases a development branch on production. This will effectively run any newer migrations from production onto this branch to help handle migration drift.",parameters:_zod.z.object({branch_id:_zod.z.string()}),execute:async({branch_id:e})=>{let t=await n.POST("/v1/branches/{branch_id}/push",{params:{path:{branch_id:e}},body:{}});return c(t,"Failed to rebase branch"),t.data}})}})}exports.a = x; exports.b = mt;
|
|
295
|
-
//# sourceMappingURL=chunk-M3JU5DW7.cjs.map
|