@gmx-io/sdk 2.0.0 → 2.1.1

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.
@@ -0,0 +1,9 @@
1
+ import { IHttp } from "./types";
2
+ type PinKeys = (string | undefined)[];
3
+ export declare function postJsonPinning<TResult>(api: IHttp, path: string, body: unknown, keysOf: (result: TResult) => PinKeys, opts?: {
4
+ transform?: (result: any) => TResult;
5
+ }): Promise<TResult>;
6
+ export declare function postJsonPinned<TResult>(api: IHttp, keys: PinKeys, path: string, body: unknown, opts?: {
7
+ transform?: (result: any) => TResult;
8
+ }): Promise<TResult>;
9
+ export {};
@@ -1,4 +1,4 @@
1
- import { IHttp } from "./types";
1
+ import { IHttp, ServedResult } from "./types";
2
2
  export declare class HttpError extends Error {
3
3
  /** HTTP status code */
4
4
  statusCode: number;
@@ -21,4 +21,7 @@ export declare class HttpClient implements IHttp {
21
21
  postJson<TResult>(path: string, body: unknown, opts?: {
22
22
  transform?: (result: any) => TResult;
23
23
  }): Promise<TResult>;
24
+ postJsonWith<TResult>(path: string, body: unknown, opts?: {
25
+ transform?: (result: any) => TResult;
26
+ }): Promise<ServedResult<TResult>>;
24
27
  }
@@ -1,4 +1,4 @@
1
- import { IHttp } from "./types";
1
+ import { IHttp, ServedResult } from "./types";
2
2
  export declare class HttpClientWithFallback implements IHttp {
3
3
  private clients;
4
4
  private primaryIndex;
@@ -12,6 +12,9 @@ export declare class HttpClientWithFallback implements IHttp {
12
12
  postJson<TResult>(path: string, body: unknown, opts?: {
13
13
  transform?: (result: any) => TResult;
14
14
  }): Promise<TResult>;
15
+ postJsonWith<TResult>(path: string, body: unknown, opts?: {
16
+ transform?: (result: any) => TResult;
17
+ }): Promise<ServedResult<TResult>>;
15
18
  private withFallback;
16
19
  private getClientOrder;
17
20
  private recordFailure;
@@ -1,3 +1,7 @@
1
+ export type ServedResult<TResult> = {
2
+ result: TResult;
3
+ client: IHttp;
4
+ };
1
5
  export type IHttp = {
2
6
  url: string;
3
7
  fetchJson: <TResult>(path: string, opts?: {
@@ -7,4 +11,7 @@ export type IHttp = {
7
11
  postJson: <TResult>(path: string, body: unknown, opts?: {
8
12
  transform?: (result: any) => TResult;
9
13
  }) => Promise<TResult>;
14
+ postJsonWith?: <TResult>(path: string, body: unknown, opts?: {
15
+ transform?: (result: any) => TResult;
16
+ }) => Promise<ServedResult<TResult>>;
10
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",