From 6efa9cad176cce8afa45b257e8d7266a51e73517 Mon Sep 17 00:00:00 2001 From: Sam Blacklock Date: Thu, 12 Mar 2026 11:43:19 +0000 Subject: [PATCH] feat: add support for getting via slug in custom APIs --- src/endpoints/custom-apis.js | 27 +++++++++++++++++++++++++++ src/types/custom-apis.ts | 22 ++++++++++++++++++++++ src/types/extensions.d.ts | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/endpoints/custom-apis.js b/src/endpoints/custom-apis.js index 07c857b..f238f64 100644 --- a/src/endpoints/custom-apis.js +++ b/src/endpoints/custom-apis.js @@ -111,6 +111,33 @@ class CustomApisEndpoint extends CRUDExtend { 'DELETE' ) } + + GetEntriesBySlug(slug) { + const { limit, offset, sort, filter } = this + return this.request.send( + buildURL(`extensions/${slug}`, { limit, offset, sort, filter }), + 'GET', + undefined, + undefined, + this + ) + } + + GetEntryBySlug(slug, entryId) { + return this.request.send(`extensions/${slug}/${entryId}`, 'GET') + } + + CreateEntryBySlug(slug, body) { + return this.request.send(`extensions/${slug}`, 'POST', body) + } + + UpdateEntryBySlug(slug, entryId, body) { + return this.request.send(`extensions/${slug}/${entryId}`, 'PUT', body) + } + + DeleteEntryBySlug(slug, entryId) { + return this.request.send(`extensions/${slug}/${entryId}`, 'DELETE') + } } export default CustomApisEndpoint diff --git a/src/types/custom-apis.ts b/src/types/custom-apis.ts index e74d9ce..2a7174d 100644 --- a/src/types/custom-apis.ts +++ b/src/types/custom-apis.ts @@ -196,4 +196,26 @@ export interface CustomApisEndpoint { ): Promise DeleteEntry(customApiId: string, customApiEntryId: string): Promise + + GetEntriesBySlug(slug: string): Promise + + GetEntryBySlug(slug: string, entryId: string): Promise + + CreateEntryBySlug( + slug: string, + body: RequestBody + ): Promise + + UpdateEntryBySlug( + slug: string, + entryId: string, + body: RequestBody + ): Promise + + DeleteEntryBySlug(slug: string, entryId: string): Promise + + Filter(filter: any): CustomApisEndpoint + Limit(value: number): CustomApisEndpoint + Offset(value: number): CustomApisEndpoint + Sort(value: string): CustomApisEndpoint } diff --git a/src/types/extensions.d.ts b/src/types/extensions.d.ts index 995746c..bf42613 100644 --- a/src/types/extensions.d.ts +++ b/src/types/extensions.d.ts @@ -1 +1 @@ -export type Extensions = Record> \ No newline at end of file +export type Extensions = Record>