Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: bundle size #21

Open
wants to merge 3 commits into
base: feat/bundle-check
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"npm": ">=6.0.0"
},
"dependencies": {
"debug": "4.4.0"
"debug": "4.4.0",
"react": "^19.0.0"
}
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { StrapiSDKValidator } from './validators';

import type { StrapiSDKConfig } from './sdk';

// @ts-ignore
export * as React from 'react';
export * from './errors';

/**
Expand Down
55 changes: 55 additions & 0 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,58 @@ export class StrapiSDK<const T_Config extends StrapiSDKConfig = StrapiSDKConfig>
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<string, any>): Promise<any> {
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}`);
}
}
}
Loading