Skip to content

Commit 1a29f25

Browse files
committed
Adding the enableWebhooks endpoint
1 parent baf19a1 commit 1a29f25

File tree

3 files changed

+72
-31
lines changed

3 files changed

+72
-31
lines changed

.changeset/wise-rocks-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"supabase-management-js": patch
3+
---
4+
5+
Adding enableWebhooks endpoint

src/api/v1.d.ts

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ export interface paths {
121121
/** Updates project's postgrest config */
122122
patch: operations["updatePostgRESTConfig"];
123123
};
124-
"/v1/projects/{ref}/database/query": {
125-
/** Run sql query */
126-
post: operations["runQuery"];
127-
};
128124
"/v1/projects/{ref}/secrets": {
129125
/**
130126
* List all secrets
@@ -207,6 +203,14 @@ export interface paths {
207203
/** Updates a project's auth config */
208204
patch: operations["updateV1AuthConfig"];
209205
};
206+
"/v1/projects/{ref}/database/query": {
207+
/** Run sql query */
208+
post: operations["v1RunQuery"];
209+
};
210+
"/v1/projects/{ref}/database/webhooks/enable": {
211+
/** Enables Database Webhooks on the project */
212+
post: operations["v1EnableDatabaseWebhooks"];
213+
};
210214
"/v1/projects/{ref}/functions": {
211215
/**
212216
* List all functions
@@ -449,9 +453,6 @@ export interface components {
449453
db_schema: string;
450454
db_extra_search_path: string;
451455
};
452-
RunQueryBody: {
453-
query: string;
454-
};
455456
SecretResponse: {
456457
name: string;
457458
value: string;
@@ -604,6 +605,9 @@ export interface components {
604605
smtp_sender_name?: string;
605606
rate_limit_email_sent?: number;
606607
};
608+
RunQueryBody: {
609+
query: string;
610+
};
607611
CreateFunctionBody: {
608612
slug: string;
609613
name: string;
@@ -1337,30 +1341,6 @@ export interface operations {
13371341
500: never;
13381342
};
13391343
};
1340-
/** Run sql query */
1341-
runQuery: {
1342-
parameters: {
1343-
path: {
1344-
/** @description Project ref */
1345-
ref: string;
1346-
};
1347-
};
1348-
requestBody: {
1349-
content: {
1350-
"application/json": components["schemas"]["RunQueryBody"];
1351-
};
1352-
};
1353-
responses: {
1354-
201: {
1355-
content: {
1356-
"application/json": Record<string, never>;
1357-
};
1358-
};
1359-
403: never;
1360-
/** @description Failed to run sql query */
1361-
500: never;
1362-
};
1363-
};
13641344
/**
13651345
* List all secrets
13661346
* @description Returns all secrets you've previously added to the specified project.
@@ -1799,6 +1779,45 @@ export interface operations {
17991779
500: never;
18001780
};
18011781
};
1782+
/** Run sql query */
1783+
v1RunQuery: {
1784+
parameters: {
1785+
path: {
1786+
/** @description Project ref */
1787+
ref: string;
1788+
};
1789+
};
1790+
requestBody: {
1791+
content: {
1792+
"application/json": components["schemas"]["RunQueryBody"];
1793+
};
1794+
};
1795+
responses: {
1796+
201: {
1797+
content: {
1798+
"application/json": Record<string, never>;
1799+
};
1800+
};
1801+
403: never;
1802+
/** @description Failed to run sql query */
1803+
500: never;
1804+
};
1805+
};
1806+
/** Enables Database Webhooks on the project */
1807+
v1EnableDatabaseWebhooks: {
1808+
parameters: {
1809+
path: {
1810+
/** @description Project ref */
1811+
ref: string;
1812+
};
1813+
};
1814+
responses: {
1815+
201: never;
1816+
403: never;
1817+
/** @description Failed to enable Database Webhooks on the project */
1818+
500: never;
1819+
};
1820+
};
18021821
/**
18031822
* List all functions
18041823
* @description Returns all functions you've previously added to the specified project.

src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,23 @@ export class SupabaseManagementAPI {
713713
return data;
714714
}
715715

716+
async enableWebhooks(ref: string) {
717+
const { data, response } = await this.client.post(
718+
"/v1/projects/{ref}/database/webhooks/enable",
719+
{
720+
params: {
721+
path: {
722+
ref,
723+
},
724+
},
725+
}
726+
);
727+
728+
if (response.status !== 201) {
729+
throw await this.#createResponseError(response, "enable webhooks");
730+
}
731+
}
732+
716733
/**
717734
* List all secrets
718735
* @description Returns all secrets you've previously added to the specified project.

0 commit comments

Comments
 (0)