@deliverart/sdk-js-core 0.1.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,44 +1,27 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-core",
3
3
  "description": "Core SDK for DeliverArt, providing essential functionalities and utilities.",
4
- "version": "0.1.4",
4
+ "version": "1.1.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "tsup": {
9
+ "tsconfig": "./tsconfig.json"
10
+ },
8
11
  "exports": {
9
12
  ".": {
10
13
  "import": "./dist/index.js",
11
14
  "require": "./dist/index.cjs"
12
15
  }
13
16
  },
14
- "dependencies": {
15
- "axios": "1.9.0",
16
- "zod": "3.25.67"
17
- },
18
- "devDependencies": {
19
- "@changesets/cli": "^2.29.4",
20
- "@eslint/js": "9.28.0",
21
- "@types/node": "22.15.30",
22
- "@typescript-eslint/eslint-plugin": "8.33.1",
23
- "@typescript-eslint/parser": "8.33.1",
24
- "eslint": "9.28.0",
25
- "eslint-config-prettier": "10.1.5",
26
- "eslint-plugin-simple-import-sort": "12.1.1",
27
- "prettier": "3.5.3",
28
- "tsup": "8.5.0",
29
- "typescript": "5.8.3"
30
- },
17
+ "files": [
18
+ "dist"
19
+ ],
31
20
  "publishConfig": {
32
21
  "access": "public"
33
22
  },
34
23
  "scripts": {
35
24
  "build": "tsup src/index.ts --dts --format esm,cjs",
36
- "dev": "tsup src/index.ts --dts --watch",
37
- "lint": "eslint .",
38
- "lint:fix": "eslint . --fix",
39
- "prettier": "prettier --check .",
40
- "prettier:fix": "prettier --write .",
41
- "version": "@changesets/cli version",
42
- "release": "@changesets/cli publish"
25
+ "dev": "tsup src/index.ts --dts --watch"
43
26
  }
44
27
  }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
- "changelog": "@changesets/cli/changelog",
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "restricted",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
11
- }
@@ -1,47 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- permissions:
9
- contents: write
10
-
11
- jobs:
12
- release:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
-
17
- - uses: pnpm/action-setup@v2
18
- with:
19
- version: 8
20
-
21
- - uses: actions/setup-node@v4
22
- with:
23
- node-version: '20'
24
- registry-url: 'https://registry.npmjs.org'
25
- always-auth: true
26
- env:
27
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28
-
29
- - name: Install deps
30
- run: pnpm install
31
-
32
- - name: Build
33
- run: pnpm build
34
-
35
- - name: Create version and changelog
36
- run: pnpx @changesets/cli version
37
-
38
- - name: Publish to NPM
39
- run: pnpx @changesets/cli publish
40
- env:
41
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42
-
43
- - name: Push updated versions and changelogs
44
- uses: EndBug/add-and-commit@v9
45
- with:
46
- message: 'chore(release): version bump'
47
- add: '.'
package/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "semi": false,
3
- "singleQuote": true,
4
- "printWidth": 100,
5
- "trailingComma": "all",
6
- "arrowParens": "avoid"
7
- }
package/CHANGELOG.md DELETED
@@ -1,67 +0,0 @@
1
- # @deliverart/sdk-js-core
2
-
3
- ## 0.1.4
4
-
5
- ### Patch Changes
6
-
7
- - 60fba1c: ignore lock
8
-
9
- ## 0.1.3
10
-
11
- ### Patch Changes
12
-
13
- - e177edc: Expose rawResponse
14
-
15
- ## 0.1.2
16
-
17
- ### Patch Changes
18
-
19
- - b204aab: Add parseResponse method
20
-
21
- ## 0.1.1
22
-
23
- ### Patch Changes
24
-
25
- - 20b57df: Expose errors
26
-
27
- ## 0.1.0
28
-
29
- ### Minor Changes
30
-
31
- - dd33eb4: Implement Request Response call
32
-
33
- ## 0.0.7
34
-
35
- ### Patch Changes
36
-
37
- - c36723b: Extends ApiExtension with void type
38
-
39
- ## 0.0.6
40
-
41
- ### Patch Changes
42
-
43
- - 14cc1fd: restructure ApiClient to use factory function and improve type definitions
44
-
45
- ## 0.0.5
46
-
47
- ### Patch Changes
48
-
49
- - 077e5f6: make use() generically typed with proper plugin propagation
50
-
51
- ## 0.0.4
52
-
53
- ### Patch Changes
54
-
55
- - b5f002a: fix: update package name
56
-
57
- ## 0.0.3
58
-
59
- ### Patch Changes
60
-
61
- - e7475f6: fix: remove changeset default files
62
-
63
- ## 0.0.2
64
-
65
- ### Patch Changes
66
-
67
- - 0f3205e: fix: trigger deploy
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # api-v2-sdk-js-core
2
-
3
- Core SDK for API2 server interface
package/dist/index.cjs DELETED
@@ -1,136 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- AbstractApiRequest: () => AbstractApiRequest,
34
- InputValidationError: () => InputValidationError,
35
- OutputValidationError: () => OutputValidationError,
36
- createApiClient: () => createApiClient
37
- });
38
- module.exports = __toCommonJS(index_exports);
39
-
40
- // src/ApiClient.ts
41
- var import_axios = __toESM(require("axios"), 1);
42
-
43
- // src/errors.ts
44
- var InputValidationError = class extends Error {
45
- // eslint-disable-next-line no-unused-vars
46
- constructor(issues) {
47
- super("Invalid input");
48
- this.issues = issues;
49
- this.name = "InputValidationError";
50
- }
51
- };
52
- var OutputValidationError = class extends Error {
53
- // eslint-disable-next-line no-unused-vars
54
- constructor(issues) {
55
- super("Invalid response");
56
- this.issues = issues;
57
- this.name = "OutputValidationError";
58
- }
59
- };
60
-
61
- // src/ApiClient.ts
62
- var AbstractApiRequest = class {
63
- constructor(input, options) {
64
- this.input = input;
65
- this.options = options;
66
- }
67
- validateInput() {
68
- const result = this.inputSchema.safeParse(this.input);
69
- if (!result.success) {
70
- throw new InputValidationError(result.error.issues);
71
- }
72
- return result.data;
73
- }
74
- validateQuery() {
75
- if (!this.querySchema || !this.options?.query) return void 0;
76
- const result = this.querySchema.safeParse(this.options.query);
77
- if (!result.success) {
78
- throw new InputValidationError(result.error.issues);
79
- }
80
- return result.data;
81
- }
82
- validateHeaders() {
83
- if (!this.headersSchema || !this.options?.headers) return void 0;
84
- const result = this.headersSchema.safeParse(this.options.headers);
85
- if (!result.success) {
86
- throw new InputValidationError(result.error.issues);
87
- }
88
- return result.data;
89
- }
90
- validateOutput(data) {
91
- const result = this.outputSchema.safeParse(data);
92
- if (!result.success) {
93
- throw new OutputValidationError(result.error.issues);
94
- }
95
- return result.data;
96
- }
97
- parseResponse(data, rawResponse) {
98
- void rawResponse;
99
- return this.validateOutput(data);
100
- }
101
- };
102
- function createApiClient(config) {
103
- const http = import_axios.default.create({ baseURL: config.baseUrl });
104
- const base = {
105
- http,
106
- async call(request) {
107
- const input = request.validateInput();
108
- const query = request.validateQuery();
109
- const headers = request.validateHeaders();
110
- const res = await http.request({
111
- url: request.getPath(),
112
- method: request.method,
113
- headers: {
114
- "Content-Type": request.contentType,
115
- Accept: request.accept,
116
- ...headers ?? {}
117
- },
118
- params: query,
119
- data: request.method !== "GET" ? input : void 0
120
- });
121
- return request.parseResponse(res.data, res);
122
- },
123
- addPlugin(plugin) {
124
- const extension = plugin.setup(this);
125
- return { ...this, ...extension };
126
- }
127
- };
128
- return base;
129
- }
130
- // Annotate the CommonJS export names for ESM import in node:
131
- 0 && (module.exports = {
132
- AbstractApiRequest,
133
- InputValidationError,
134
- OutputValidationError,
135
- createApiClient
136
- });
package/dist/index.d.cts DELETED
@@ -1,52 +0,0 @@
1
- import { AxiosResponse, AxiosInstance } from 'axios';
2
- import { ZodSchema, ZodIssue } from 'zod';
3
-
4
- type ApiExtension = Record<string, unknown>;
5
- interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
6
- setup: (client: ApiClient<Record<string, unknown>>) => T;
7
- }
8
-
9
- declare abstract class AbstractApiRequest<Input, Output, Query = unknown, Headers = unknown> {
10
- readonly input: Input;
11
- readonly options?: {
12
- query?: Query;
13
- headers?: Headers;
14
- } | undefined;
15
- abstract readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
16
- abstract readonly contentType: 'application/json' | 'multipart/form-data' | 'application/merge-patch+json';
17
- abstract readonly accept: 'application/json';
18
- abstract readonly inputSchema: ZodSchema<Input>;
19
- abstract readonly outputSchema: ZodSchema<Output>;
20
- abstract readonly querySchema?: ZodSchema<Query>;
21
- abstract readonly headersSchema?: ZodSchema<Headers>;
22
- protected constructor(input: Input, options?: {
23
- query?: Query;
24
- headers?: Headers;
25
- } | undefined);
26
- abstract getPath(): string;
27
- validateInput(): Input;
28
- validateQuery(): Query | undefined;
29
- validateHeaders(): Headers | undefined;
30
- validateOutput(data: unknown): Output;
31
- parseResponse(data: unknown, rawResponse?: AxiosResponse): Output;
32
- }
33
- interface ApiClientBase {
34
- http: AxiosInstance;
35
- addPlugin: <T extends ApiExtension>(plugin: ApiClientPlugin<T>) => ApiClient<T>;
36
- call<I, O, Q, H>(request: AbstractApiRequest<I, O, Q, H>): Promise<O>;
37
- }
38
- declare function createApiClient<Extensions extends ApiExtension = NonNullable<unknown>>(config: {
39
- baseUrl: string;
40
- }): ApiClient<Extensions>;
41
- type ApiClient<Extensions extends ApiExtension = NonNullable<unknown>> = ApiClientBase & Extensions;
42
-
43
- declare class InputValidationError extends Error {
44
- readonly issues: ZodIssue[];
45
- constructor(issues: ZodIssue[]);
46
- }
47
- declare class OutputValidationError extends Error {
48
- readonly issues: ZodIssue[];
49
- constructor(issues: ZodIssue[]);
50
- }
51
-
52
- export { AbstractApiRequest, type ApiClient, type ApiClientPlugin, type ApiExtension, InputValidationError, OutputValidationError, createApiClient };
package/dist/index.d.ts DELETED
@@ -1,52 +0,0 @@
1
- import { AxiosResponse, AxiosInstance } from 'axios';
2
- import { ZodSchema, ZodIssue } from 'zod';
3
-
4
- type ApiExtension = Record<string, unknown>;
5
- interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
6
- setup: (client: ApiClient<Record<string, unknown>>) => T;
7
- }
8
-
9
- declare abstract class AbstractApiRequest<Input, Output, Query = unknown, Headers = unknown> {
10
- readonly input: Input;
11
- readonly options?: {
12
- query?: Query;
13
- headers?: Headers;
14
- } | undefined;
15
- abstract readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
16
- abstract readonly contentType: 'application/json' | 'multipart/form-data' | 'application/merge-patch+json';
17
- abstract readonly accept: 'application/json';
18
- abstract readonly inputSchema: ZodSchema<Input>;
19
- abstract readonly outputSchema: ZodSchema<Output>;
20
- abstract readonly querySchema?: ZodSchema<Query>;
21
- abstract readonly headersSchema?: ZodSchema<Headers>;
22
- protected constructor(input: Input, options?: {
23
- query?: Query;
24
- headers?: Headers;
25
- } | undefined);
26
- abstract getPath(): string;
27
- validateInput(): Input;
28
- validateQuery(): Query | undefined;
29
- validateHeaders(): Headers | undefined;
30
- validateOutput(data: unknown): Output;
31
- parseResponse(data: unknown, rawResponse?: AxiosResponse): Output;
32
- }
33
- interface ApiClientBase {
34
- http: AxiosInstance;
35
- addPlugin: <T extends ApiExtension>(plugin: ApiClientPlugin<T>) => ApiClient<T>;
36
- call<I, O, Q, H>(request: AbstractApiRequest<I, O, Q, H>): Promise<O>;
37
- }
38
- declare function createApiClient<Extensions extends ApiExtension = NonNullable<unknown>>(config: {
39
- baseUrl: string;
40
- }): ApiClient<Extensions>;
41
- type ApiClient<Extensions extends ApiExtension = NonNullable<unknown>> = ApiClientBase & Extensions;
42
-
43
- declare class InputValidationError extends Error {
44
- readonly issues: ZodIssue[];
45
- constructor(issues: ZodIssue[]);
46
- }
47
- declare class OutputValidationError extends Error {
48
- readonly issues: ZodIssue[];
49
- constructor(issues: ZodIssue[]);
50
- }
51
-
52
- export { AbstractApiRequest, type ApiClient, type ApiClientPlugin, type ApiExtension, InputValidationError, OutputValidationError, createApiClient };
package/dist/index.js DELETED
@@ -1,96 +0,0 @@
1
- // src/ApiClient.ts
2
- import axios from "axios";
3
-
4
- // src/errors.ts
5
- var InputValidationError = class extends Error {
6
- // eslint-disable-next-line no-unused-vars
7
- constructor(issues) {
8
- super("Invalid input");
9
- this.issues = issues;
10
- this.name = "InputValidationError";
11
- }
12
- };
13
- var OutputValidationError = class extends Error {
14
- // eslint-disable-next-line no-unused-vars
15
- constructor(issues) {
16
- super("Invalid response");
17
- this.issues = issues;
18
- this.name = "OutputValidationError";
19
- }
20
- };
21
-
22
- // src/ApiClient.ts
23
- var AbstractApiRequest = class {
24
- constructor(input, options) {
25
- this.input = input;
26
- this.options = options;
27
- }
28
- validateInput() {
29
- const result = this.inputSchema.safeParse(this.input);
30
- if (!result.success) {
31
- throw new InputValidationError(result.error.issues);
32
- }
33
- return result.data;
34
- }
35
- validateQuery() {
36
- if (!this.querySchema || !this.options?.query) return void 0;
37
- const result = this.querySchema.safeParse(this.options.query);
38
- if (!result.success) {
39
- throw new InputValidationError(result.error.issues);
40
- }
41
- return result.data;
42
- }
43
- validateHeaders() {
44
- if (!this.headersSchema || !this.options?.headers) return void 0;
45
- const result = this.headersSchema.safeParse(this.options.headers);
46
- if (!result.success) {
47
- throw new InputValidationError(result.error.issues);
48
- }
49
- return result.data;
50
- }
51
- validateOutput(data) {
52
- const result = this.outputSchema.safeParse(data);
53
- if (!result.success) {
54
- throw new OutputValidationError(result.error.issues);
55
- }
56
- return result.data;
57
- }
58
- parseResponse(data, rawResponse) {
59
- void rawResponse;
60
- return this.validateOutput(data);
61
- }
62
- };
63
- function createApiClient(config) {
64
- const http = axios.create({ baseURL: config.baseUrl });
65
- const base = {
66
- http,
67
- async call(request) {
68
- const input = request.validateInput();
69
- const query = request.validateQuery();
70
- const headers = request.validateHeaders();
71
- const res = await http.request({
72
- url: request.getPath(),
73
- method: request.method,
74
- headers: {
75
- "Content-Type": request.contentType,
76
- Accept: request.accept,
77
- ...headers ?? {}
78
- },
79
- params: query,
80
- data: request.method !== "GET" ? input : void 0
81
- });
82
- return request.parseResponse(res.data, res);
83
- },
84
- addPlugin(plugin) {
85
- const extension = plugin.setup(this);
86
- return { ...this, ...extension };
87
- }
88
- };
89
- return base;
90
- }
91
- export {
92
- AbstractApiRequest,
93
- InputValidationError,
94
- OutputValidationError,
95
- createApiClient
96
- };
package/eslint.config.js DELETED
@@ -1,37 +0,0 @@
1
- /* eslint-disable */
2
- // eslint.config.js per @typescript-eslint v8
3
- import js from '@eslint/js'
4
- import prettier from 'eslint-config-prettier'
5
- import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
6
- import tsPlugin from '@typescript-eslint/eslint-plugin'
7
- import tsParser from '@typescript-eslint/parser'
8
-
9
- export default [
10
- js.configs.recommended,
11
- {
12
- files: ['**/*.ts'],
13
- languageOptions: {
14
- parser: tsParser,
15
- globals: {
16
- process: 'readonly',
17
- },
18
- parserOptions: {
19
- project: ['./tsconfig.json'],
20
- tsconfigRootDir: process.cwd(),
21
- sourceType: 'module',
22
- },
23
- },
24
- plugins: {
25
- '@typescript-eslint': tsPlugin,
26
- 'simple-import-sort': simpleImportSortPlugin,
27
- },
28
- rules: {
29
- 'simple-import-sort/imports': 'error',
30
- 'simple-import-sort/exports': 'error',
31
- '@typescript-eslint/no-unused-vars': 'warn',
32
- },
33
- },
34
- prettier,
35
- ]
36
-
37
- export const ignores = ['dist', 'node_modules']
package/src/ApiClient.ts DELETED
@@ -1,119 +0,0 @@
1
- import axios, { AxiosInstance, AxiosResponse } from 'axios'
2
- import { ZodSchema } from 'zod'
3
-
4
- import { InputValidationError, OutputValidationError } from './errors'
5
- import type { ApiClientPlugin, ApiExtension } from './types'
6
-
7
- export abstract class AbstractApiRequest<Input, Output, Query = unknown, Headers = unknown> {
8
- abstract readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE'
9
- abstract readonly contentType:
10
- | 'application/json'
11
- | 'multipart/form-data'
12
- | 'application/merge-patch+json'
13
- abstract readonly accept: 'application/json'
14
- abstract readonly inputSchema: ZodSchema<Input>
15
- abstract readonly outputSchema: ZodSchema<Output>
16
- abstract readonly querySchema?: ZodSchema<Query>
17
- abstract readonly headersSchema?: ZodSchema<Headers>
18
-
19
- protected constructor(
20
- // eslint-disable-next-line no-unused-vars
21
- public readonly input: Input,
22
- // eslint-disable-next-line no-unused-vars
23
- public readonly options?: {
24
- query?: Query
25
- headers?: Headers
26
- },
27
- ) {}
28
-
29
- abstract getPath(): string
30
-
31
- validateInput(): Input {
32
- const result = this.inputSchema.safeParse(this.input)
33
- if (!result.success) {
34
- throw new InputValidationError(result.error.issues)
35
- }
36
- return result.data
37
- }
38
-
39
- validateQuery(): Query | undefined {
40
- if (!this.querySchema || !this.options?.query) return undefined
41
-
42
- const result = this.querySchema.safeParse(this.options.query)
43
- if (!result.success) {
44
- throw new InputValidationError(result.error.issues)
45
- }
46
- return result.data
47
- }
48
-
49
- validateHeaders(): Headers | undefined {
50
- if (!this.headersSchema || !this.options?.headers) return undefined
51
-
52
- const result = this.headersSchema.safeParse(this.options.headers)
53
- if (!result.success) {
54
- throw new InputValidationError(result.error.issues)
55
- }
56
- return result.data
57
- }
58
-
59
- validateOutput(data: unknown): Output {
60
- const result = this.outputSchema.safeParse(data)
61
- if (!result.success) {
62
- throw new OutputValidationError(result.error.issues)
63
- }
64
- return result.data
65
- }
66
-
67
- parseResponse(data: unknown, rawResponse?: AxiosResponse): Output {
68
- void rawResponse
69
- return this.validateOutput(data)
70
- }
71
- }
72
-
73
- interface ApiClientBase {
74
- http: AxiosInstance
75
- // eslint-disable-next-line no-unused-vars
76
- addPlugin: <T extends ApiExtension>(plugin: ApiClientPlugin<T>) => ApiClient<T>
77
- // eslint-disable-next-line no-unused-vars
78
- call<I, O, Q, H>(request: AbstractApiRequest<I, O, Q, H>): Promise<O>
79
- }
80
-
81
- export function createApiClient<Extensions extends ApiExtension = NonNullable<unknown>>(config: {
82
- baseUrl: string
83
- }): ApiClient<Extensions> {
84
- const http = axios.create({ baseURL: config.baseUrl })
85
-
86
- const base: ApiClientBase = {
87
- http,
88
-
89
- async call<I, O, Q, H>(request: AbstractApiRequest<I, O, Q, H>): Promise<O> {
90
- const input = request.validateInput()
91
- const query = request.validateQuery()
92
- const headers = request.validateHeaders()
93
-
94
- const res = await http.request({
95
- url: request.getPath(),
96
- method: request.method,
97
- headers: {
98
- 'Content-Type': request.contentType,
99
- Accept: request.accept,
100
- ...(headers ?? {}),
101
- },
102
- params: query,
103
- data: request.method !== 'GET' ? input : undefined,
104
- })
105
-
106
- return request.parseResponse(res.data, res)
107
- },
108
-
109
- addPlugin<T extends ApiExtension>(plugin: ApiClientPlugin<T>) {
110
- const extension = plugin.setup(this as ApiClient<Extensions & T>)
111
- return { ...this, ...extension } as ApiClient<Extensions & T>
112
- },
113
- }
114
-
115
- return base as ApiClient<Extensions>
116
- }
117
-
118
- export type ApiClient<Extensions extends ApiExtension = NonNullable<unknown>> = ApiClientBase &
119
- Extensions
package/src/errors.ts DELETED
@@ -1,17 +0,0 @@
1
- import { ZodIssue } from 'zod'
2
-
3
- export class InputValidationError extends Error {
4
- // eslint-disable-next-line no-unused-vars
5
- constructor(public readonly issues: ZodIssue[]) {
6
- super('Invalid input')
7
- this.name = 'InputValidationError'
8
- }
9
- }
10
-
11
- export class OutputValidationError extends Error {
12
- // eslint-disable-next-line no-unused-vars
13
- constructor(public readonly issues: ZodIssue[]) {
14
- super('Invalid response')
15
- this.name = 'OutputValidationError'
16
- }
17
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './ApiClient'
2
- export * from './errors'
3
- export * from './types'
package/src/types.ts DELETED
@@ -1,8 +0,0 @@
1
- import { ApiClient } from './ApiClient'
2
-
3
- export type ApiExtension = Record<string, unknown>
4
-
5
- export interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
6
- // eslint-disable-next-line no-unused-vars
7
- setup: (client: ApiClient<Record<string, unknown>>) => T
8
- }
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Node",
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "outDir": "dist",
11
- "declaration": true,
12
- "declarationMap": true
13
- },
14
- "include": ["src"]
15
- }