@cronvello/shop-sdk 0.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.
@@ -0,0 +1,78 @@
1
+ import { M6 as apiRoutes } from './index-CIpUb0vL.js';
2
+
3
+ type ShopRouteKey = keyof typeof apiRoutes;
4
+ type ShopRoute<K extends ShopRouteKey> = (typeof apiRoutes)[K];
5
+ type ShopRouteMethod<K extends ShopRouteKey> = ShopRoute<K>["method"];
6
+ type ShopRouteAuth<K extends ShopRouteKey> = ShopRoute<K>["auth"];
7
+ type ShopRouteParams<K extends ShopRouteKey> = ShopRoute<K>["types"]["params"];
8
+ type ShopRouteQuery<K extends ShopRouteKey> = ShopRoute<K>["types"]["query"];
9
+ type ShopRouteBody<K extends ShopRouteKey> = ShopRoute<K>["types"]["body"];
10
+ type ShopRouteResponse<K extends ShopRouteKey> = ShopRoute<K>["types"]["response"];
11
+ type ShopRouteResponseData<K extends ShopRouteKey> = ShopRoute<K>["types"]["responseData"];
12
+ type IsEmptyObject<T> = T extends object ? (keyof T extends never ? true : false) : false;
13
+ type InputField<Name extends string, T> = [T] extends [undefined] ? {
14
+ [K in Name]?: never;
15
+ } : IsEmptyObject<T> extends true ? {
16
+ [K in Name]?: T;
17
+ } : {
18
+ [K in Name]: T;
19
+ };
20
+ type ShopRouteInput<K extends ShopRouteKey> = InputField<"params", ShopRouteParams<K>> & InputField<"query", ShopRouteQuery<K>> & InputField<"body", ShopRouteBody<K>>;
21
+ type ShopAuthType = (typeof apiRoutes)[ShopRouteKey]["auth"]["type"];
22
+ type ShopRequestContext = {
23
+ routeKey: ShopRouteKey;
24
+ method: string;
25
+ path: string;
26
+ authType: ShopAuthType;
27
+ };
28
+ type MaybePromise<T> = T | Promise<T>;
29
+ type HeaderProvider = (context: ShopRequestContext) => MaybePromise<HeadersInit | undefined>;
30
+ type BaseUrlProvider = string | (() => MaybePromise<string>);
31
+ type ShopClientOptions = {
32
+ baseUrl?: BaseUrlProvider;
33
+ fetch?: typeof globalThis.fetch;
34
+ headers?: HeadersInit | HeaderProvider;
35
+ timeoutMs?: number;
36
+ retries?: number;
37
+ retryDelayMs?: number;
38
+ };
39
+ type ShopRequestOptions = {
40
+ headers?: HeadersInit;
41
+ signal?: AbortSignal;
42
+ timeoutMs?: number;
43
+ retries?: number;
44
+ retryUnsafe?: boolean;
45
+ };
46
+ interface ShopClient {
47
+ readonly baseUrl: BaseUrlProvider;
48
+ request<K extends ShopRouteKey>(routeKey: K, input: ShopRouteInput<K>, options?: ShopRequestOptions): Promise<ShopRouteResponseData<K>>;
49
+ requestText<K extends ShopRouteKey>(routeKey: K, input: ShopRouteInput<K>, options?: ShopRequestOptions): Promise<string>;
50
+ requestRaw<K extends ShopRouteKey>(routeKey: K, input: ShopRouteInput<K>, options?: ShopRequestOptions): Promise<Response>;
51
+ }
52
+
53
+ /** Stable production endpoint used when no override or resolver is supplied. */
54
+ declare const SHOP_API_URL = "https://node-shop-production-86b7.up.railway.app";
55
+
56
+ type ShopErrorDetails = {
57
+ status: number;
58
+ method: string;
59
+ path: string;
60
+ routeKey: string;
61
+ requestId?: string;
62
+ responseBody?: unknown;
63
+ cause?: unknown;
64
+ };
65
+ declare class ShopApiError extends Error {
66
+ readonly status: number;
67
+ readonly method: string;
68
+ readonly path: string;
69
+ readonly routeKey: string;
70
+ readonly requestId?: string;
71
+ readonly responseBody?: unknown;
72
+ constructor(message: string, details: ShopErrorDetails);
73
+ }
74
+ declare class ShopConfigurationError extends Error {
75
+ constructor(message: string);
76
+ }
77
+
78
+ export { type BaseUrlProvider as B, type HeaderProvider as H, type MaybePromise as M, type ShopClientOptions as S, type ShopClient as a, SHOP_API_URL as b, ShopApiError as c, type ShopAuthType as d, ShopConfigurationError as e, type ShopRequestContext as f, type ShopRequestOptions as g, type ShopRoute as h, type ShopRouteAuth as i, type ShopRouteBody as j, type ShopRouteInput as k, type ShopRouteKey as l, type ShopRouteMethod as m, type ShopRouteParams as n, type ShopRouteQuery as o, type ShopRouteResponse as p, type ShopRouteResponseData as q };
@@ -0,0 +1,78 @@
1
+ import { M6 as apiRoutes } from './index-CIpUb0vL.cjs';
2
+
3
+ type ShopRouteKey = keyof typeof apiRoutes;
4
+ type ShopRoute<K extends ShopRouteKey> = (typeof apiRoutes)[K];
5
+ type ShopRouteMethod<K extends ShopRouteKey> = ShopRoute<K>["method"];
6
+ type ShopRouteAuth<K extends ShopRouteKey> = ShopRoute<K>["auth"];
7
+ type ShopRouteParams<K extends ShopRouteKey> = ShopRoute<K>["types"]["params"];
8
+ type ShopRouteQuery<K extends ShopRouteKey> = ShopRoute<K>["types"]["query"];
9
+ type ShopRouteBody<K extends ShopRouteKey> = ShopRoute<K>["types"]["body"];
10
+ type ShopRouteResponse<K extends ShopRouteKey> = ShopRoute<K>["types"]["response"];
11
+ type ShopRouteResponseData<K extends ShopRouteKey> = ShopRoute<K>["types"]["responseData"];
12
+ type IsEmptyObject<T> = T extends object ? (keyof T extends never ? true : false) : false;
13
+ type InputField<Name extends string, T> = [T] extends [undefined] ? {
14
+ [K in Name]?: never;
15
+ } : IsEmptyObject<T> extends true ? {
16
+ [K in Name]?: T;
17
+ } : {
18
+ [K in Name]: T;
19
+ };
20
+ type ShopRouteInput<K extends ShopRouteKey> = InputField<"params", ShopRouteParams<K>> & InputField<"query", ShopRouteQuery<K>> & InputField<"body", ShopRouteBody<K>>;
21
+ type ShopAuthType = (typeof apiRoutes)[ShopRouteKey]["auth"]["type"];
22
+ type ShopRequestContext = {
23
+ routeKey: ShopRouteKey;
24
+ method: string;
25
+ path: string;
26
+ authType: ShopAuthType;
27
+ };
28
+ type MaybePromise<T> = T | Promise<T>;
29
+ type HeaderProvider = (context: ShopRequestContext) => MaybePromise<HeadersInit | undefined>;
30
+ type BaseUrlProvider = string | (() => MaybePromise<string>);
31
+ type ShopClientOptions = {
32
+ baseUrl?: BaseUrlProvider;
33
+ fetch?: typeof globalThis.fetch;
34
+ headers?: HeadersInit | HeaderProvider;
35
+ timeoutMs?: number;
36
+ retries?: number;
37
+ retryDelayMs?: number;
38
+ };
39
+ type ShopRequestOptions = {
40
+ headers?: HeadersInit;
41
+ signal?: AbortSignal;
42
+ timeoutMs?: number;
43
+ retries?: number;
44
+ retryUnsafe?: boolean;
45
+ };
46
+ interface ShopClient {
47
+ readonly baseUrl: BaseUrlProvider;
48
+ request<K extends ShopRouteKey>(routeKey: K, input: ShopRouteInput<K>, options?: ShopRequestOptions): Promise<ShopRouteResponseData<K>>;
49
+ requestText<K extends ShopRouteKey>(routeKey: K, input: ShopRouteInput<K>, options?: ShopRequestOptions): Promise<string>;
50
+ requestRaw<K extends ShopRouteKey>(routeKey: K, input: ShopRouteInput<K>, options?: ShopRequestOptions): Promise<Response>;
51
+ }
52
+
53
+ /** Stable production endpoint used when no override or resolver is supplied. */
54
+ declare const SHOP_API_URL = "https://node-shop-production-86b7.up.railway.app";
55
+
56
+ type ShopErrorDetails = {
57
+ status: number;
58
+ method: string;
59
+ path: string;
60
+ routeKey: string;
61
+ requestId?: string;
62
+ responseBody?: unknown;
63
+ cause?: unknown;
64
+ };
65
+ declare class ShopApiError extends Error {
66
+ readonly status: number;
67
+ readonly method: string;
68
+ readonly path: string;
69
+ readonly routeKey: string;
70
+ readonly requestId?: string;
71
+ readonly responseBody?: unknown;
72
+ constructor(message: string, details: ShopErrorDetails);
73
+ }
74
+ declare class ShopConfigurationError extends Error {
75
+ constructor(message: string);
76
+ }
77
+
78
+ export { type BaseUrlProvider as B, type HeaderProvider as H, type MaybePromise as M, type ShopClientOptions as S, type ShopClient as a, SHOP_API_URL as b, ShopApiError as c, type ShopAuthType as d, ShopConfigurationError as e, type ShopRequestContext as f, type ShopRequestOptions as g, type ShopRoute as h, type ShopRouteAuth as i, type ShopRouteBody as j, type ShopRouteInput as k, type ShopRouteKey as l, type ShopRouteMethod as m, type ShopRouteParams as n, type ShopRouteQuery as o, type ShopRouteResponse as p, type ShopRouteResponseData as q };