From 05d7eeb23665b244a4f36fe97b4c92c0c777e507 Mon Sep 17 00:00:00 2001 From: Convly Date: Mon, 23 Dec 2024 15:05:08 +0100 Subject: [PATCH 1/2] feat(sdk): add GenericManager for reusable operations --- src/sdk.ts | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/sdk.ts b/src/sdk.ts index 813be6e..4da9f7b 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -268,3 +268,58 @@ export class StrapiSDK return new SingleTypeManager(resource, this._httpClient); } } + +/** + * A manager class to handle generic operations within the SDK. + * + * This class provides utility functions or shared logic that can be reused across different components. + * + * @example + * ```typescript + * const genericManager = new GenericManager(); + * genericManager.performOperation(); + * ``` + */ +export class GenericManager { + private readonly _httpClient: HttpClient; + + /** + * Initializes the `GenericManager` with the HTTP client for making requests. + * + * @param httpClient - The HTTP client instance to use for requests. + */ + constructor(httpClient: HttpClient) { + this._httpClient = httpClient; + } + + /** + * Performs a generic operation using the provided endpoint and payload. + * + * This method demonstrates how shared logic can be implemented. + * + * @param endpoint - The specific endpoint to interact with. + * @param payload - The data to send with the request. + * + * @returns A promise resolving to the server's response. + * + * @example + * ```typescript + * const response = await genericManager.performOperation('/custom-endpoint', { key: 'value' }); + * console.log(response); + * ``` + */ + async performOperation(endpoint: string, payload: Record): Promise { + try { + const response = await this._httpClient.fetch(endpoint, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(payload), + }); + return response.json(); + } catch (error) { + throw new Error(`Failed to perform operation on ${endpoint}: ${error}`); + } + } +} From 47747867d6987e32c4c27256bf3ae46d1821f43d Mon Sep 17 00:00:00 2001 From: Convly Date: Mon, 23 Dec 2024 15:09:35 +0100 Subject: [PATCH 2/2] feat(dependencies): add react 19.0.0 to dependencies --- .github/actions/setup/action.yml | 18 +++++++++--------- package.json | 3 ++- pnpm-lock.yaml | 9 +++++++++ src/index.ts | 2 ++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index ba43332..19bdfd5 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,20 +1,20 @@ -name: "Setup" -description: "Install Node.js and pnpm and set up caching" +name: 'Setup' +description: 'Install Node.js and pnpm and set up caching' inputs: node-version: - description: "Version of Node.js to use" + description: 'Version of Node.js to use' required: false - default: "22" + default: '22' pnpm-version: - description: "Version of pnpm to install" + description: 'Version of pnpm to install' required: false - default: "9.1.0" + default: '9.1.0' env: - description: "Build Environment" + description: 'Build Environment' required: false - default: "production" + default: 'production' runs: - using: "composite" + using: 'composite' steps: - uses: pnpm/action-setup@v4 name: Install pnpm diff --git a/package.json b/package.json index 45e5c17..8b64004 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "npm": ">=6.0.0" }, "dependencies": { - "debug": "4.4.0" + "debug": "4.4.0", + "react": "^19.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a850a9..ed98ff5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: debug: specifier: 4.4.0 version: 4.4.0 + react: + specifier: ^19.0.0 + version: 19.0.0 devDependencies: '@commitlint/cli': specifier: 19.6.0 @@ -2623,6 +2626,10 @@ packages: react-is@18.3.1: resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} + react@19.0.0: + resolution: {integrity: sha512-V8AVnmPIICiWpGfm6GLzCR/W5FXLchHop40W4nXBmdlEceh16rCN8O8LNWm5bh5XUX91fh7KpA+W0TgMKmgTpQ==} + engines: {node: '>=0.10.0'} + reflect.getprototypeof@1.0.9: resolution: {integrity: sha512-r0Ay04Snci87djAsI4U+WNRcSw5S4pOH7qFjd/veA5gC7TbqESR3tcj28ia95L/fYUDw11JKP7uqUKUAfVvV5Q==} engines: {node: '>= 0.4'} @@ -6291,6 +6298,8 @@ snapshots: react-is@18.3.1: {} + react@19.0.0: {} + reflect.getprototypeof@1.0.9: dependencies: call-bind: 1.0.8 diff --git a/src/index.ts b/src/index.ts index a8b8a5d..1769fc9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,8 @@ import { StrapiSDKValidator } from './validators'; import type { StrapiSDKConfig } from './sdk'; +// @ts-ignore +export * as React from 'react'; export * from './errors'; /**