Skip to content

Commit 3f89144

Browse files
authored
Merge pull request #20 from code-store-platform/feat/add-custom-request
Add custom request function to ArcAPI
2 parents 6313012 + 8c9303b commit 3f89144

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @code.store/arcxp-sdk-ts
22

3+
## 4.48.0
4+
5+
### Minor Changes
6+
7+
- Add custom request function to ArcAPI
8+
39
## 4.47.2
410

511
### Patch Changes

package.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code.store/arcxp-sdk-ts",
3-
"version": "4.47.2",
3+
"version": "4.48.0",
44
"description": "A strongly typed set of ArcXP API's and utilities reduce the amount of work required to develop with ArcXP, starting with reducing the boilerplate code you have to write.",
55
"type": "commonjs",
66
"main": "./dist/index.js",
@@ -13,9 +13,7 @@
1313
"url": "https://github.com/code-store-platform/arcxp-sdk-ts"
1414
},
1515
"homepage": "https://github.com/code-store-platform/arcxp-sdk-ts",
16-
"files": [
17-
"dist"
18-
],
16+
"files": ["dist"],
1917
"scripts": {
2018
"build": "tsc",
2119
"format": "npx @biomejs/biome format --write .",
@@ -27,11 +25,7 @@
2725
"cs": "npx changeset && npx changeset version",
2826
"swaggerToTypes": "npx swagger-typescript-api -p ./tmp/swagger.json -o ./tmp -n swaggerTypes.ts"
2927
},
30-
"keywords": [
31-
"ArcXP",
32-
"SDK",
33-
"Code.Store"
34-
],
28+
"keywords": ["ArcXP", "SDK", "Code.Store"],
3529
"author": "code.store",
3630
"license": "MIT",
3731
"dependencies": {

src/api/custom/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
2+
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api';
3+
4+
export interface RequestConfig extends AxiosRequestConfig {}
5+
6+
export class Custom extends ArcAbstractAPI {
7+
constructor(options: ArcAPIOptions) {
8+
super({ ...options, apiPath: '' });
9+
}
10+
11+
public async request<T = unknown>(
12+
endpoint: `/${string}`,
13+
config: AxiosRequestConfig = {}
14+
): Promise<AxiosResponse<T>> {
15+
const response: AxiosResponse<T> = await this.client.request<T>({
16+
url: endpoint,
17+
...config,
18+
});
19+
20+
return response;
21+
}
22+
}

src/api/draft/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AStory } from '../../types/story';
1+
import type { AStory } from '../../types/story';
22
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api';
33
import type {
44
Circulations,

src/api/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ArcAPIOptions } from './abstract-api';
22
import { ArcAuthor } from './author';
33
import { ArcContent } from './content';
44
import { ArcContentOps } from './content-ops';
5+
import { Custom } from './custom';
56
import { ArcDraft } from './draft';
67
import { GlobalSettings } from './global-settings';
78
import { ArcIdentity } from './identity';
@@ -33,6 +34,7 @@ export const ArcAPI = (options: ArcAPIOptions) => {
3334
GlobalSettings: new GlobalSettings(options),
3435
Tags: new ArcTags(options),
3536
ContentOps: new ArcContentOps(options),
37+
Custom: new Custom(options),
3638
};
3739

3840
return {

0 commit comments

Comments
 (0)