@moonbase.sh/storefront-api 0.2.36 → 0.2.39

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/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z, ZodTypeAny } from 'zod';
2
2
 
3
3
  declare const addressSchema: z.ZodObject<{
4
4
  countryCode: z.ZodString;
@@ -216,17 +216,22 @@ declare class TokenStore {
216
216
  }
217
217
 
218
218
  type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
219
- interface Response {
220
- data: unknown;
221
- headers: Headers;
219
+ interface Response<T> {
220
+ data: T;
221
+ headers: Record<string, string>;
222
222
  status: number;
223
223
  }
224
+ interface FetchOptions {
225
+ method?: HttpMethods;
226
+ body?: any;
227
+ contentType?: string;
228
+ }
224
229
  declare class MoonbaseApi {
225
230
  baseUrl: string;
226
231
  private tokenStore;
227
232
  constructor(baseUrl: string, tokenStore: TokenStore);
228
- authenticatedFetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
229
- fetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
233
+ authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
234
+ fetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
230
235
  }
231
236
 
232
237
  declare const activationRequestSchema: z.ZodObject<{
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z, ZodTypeAny } from 'zod';
2
2
 
3
3
  declare const addressSchema: z.ZodObject<{
4
4
  countryCode: z.ZodString;
@@ -216,17 +216,22 @@ declare class TokenStore {
216
216
  }
217
217
 
218
218
  type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
219
- interface Response {
220
- data: unknown;
221
- headers: Headers;
219
+ interface Response<T> {
220
+ data: T;
221
+ headers: Record<string, string>;
222
222
  status: number;
223
223
  }
224
+ interface FetchOptions {
225
+ method?: HttpMethods;
226
+ body?: any;
227
+ contentType?: string;
228
+ }
224
229
  declare class MoonbaseApi {
225
230
  baseUrl: string;
226
231
  private tokenStore;
227
232
  constructor(baseUrl: string, tokenStore: TokenStore);
228
- authenticatedFetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
229
- fetch(path: string, method?: HttpMethods, body?: any, contentType?: string): Promise<Response>;
233
+ authenticatedFetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
234
+ fetch<T extends ZodTypeAny>(path: string, schema: T, options?: FetchOptions): Promise<Response<z.infer<T>>>;
230
235
  }
231
236
 
232
237
  declare const activationRequestSchema: z.ZodObject<{