@mywebapi.com/sdk 0.1.1 → 0.2.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.
- package/README.md +64 -32
- package/dist/auth.d.ts +13 -3
- package/dist/browser/index.js +3675 -0
- package/dist/client.d.ts +2 -0
- package/dist/deadline.d.ts +1 -0
- package/dist/environments.d.ts +3 -0
- package/dist/errors.d.ts +1 -0
- package/dist/mutator.context.d.ts +14 -4
- package/dist/mutator.d.ts +6 -0
- package/dist/node/index.js +3670 -0
- package/dist/signalr.d.ts +4 -0
- package/package.json +28 -25
- package/dist/index.js +0 -6357
package/dist/client.d.ts
CHANGED
|
@@ -83,6 +83,8 @@ export interface CPluginWebApiClientOptions {
|
|
|
83
83
|
fetch?: typeof fetch;
|
|
84
84
|
/** Override individual retry-policy fields. */
|
|
85
85
|
retry?: Partial<RetryPolicy>;
|
|
86
|
+
/** Per-request deadline in milliseconds. Defaults to 30 seconds. */
|
|
87
|
+
timeoutMs?: number;
|
|
86
88
|
}
|
|
87
89
|
/** Combine environment selector with client credentials. */
|
|
88
90
|
export type CPluginWebApiClientInit = EnvironmentSelector & CPluginWebApiClientOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withDeadline<T>(timeoutMs: number, caller: AbortSignal | null | undefined, operation: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
package/dist/environments.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type EnvironmentName = 'prod' | 'staging' | 'custom';
|
|
|
2
2
|
export interface ResolvedEnvironment {
|
|
3
3
|
apiBaseUrl: string;
|
|
4
4
|
authority: string;
|
|
5
|
+
allowInsecureLoopback?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export type EnvironmentSelector = {
|
|
7
8
|
env: 'prod' | 'staging';
|
|
@@ -9,5 +10,7 @@ export type EnvironmentSelector = {
|
|
|
9
10
|
env: 'custom';
|
|
10
11
|
apiBaseUrl: string;
|
|
11
12
|
authority: string;
|
|
13
|
+
allowInsecureLoopback?: boolean;
|
|
12
14
|
};
|
|
15
|
+
export declare function validateServiceUrl(raw: string, name: string, allowInsecureLoopback?: boolean): string;
|
|
13
16
|
export declare function resolveEnvironment(sel: EnvironmentSelector): ResolvedEnvironment;
|
package/dist/errors.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface ApiEnvelope<T> {
|
|
|
17
17
|
error?: ApiErrorBody | null;
|
|
18
18
|
meta?: ApiMeta | null;
|
|
19
19
|
}
|
|
20
|
+
export declare function codeForHttpStatus(status: number): Exclude<WebApiErrorCode, 'Ok'>;
|
|
20
21
|
export declare class ApiError extends Error {
|
|
21
22
|
readonly code: WebApiErrorCode;
|
|
22
23
|
readonly description: string | undefined;
|
|
@@ -6,8 +6,18 @@ export interface RequestContext {
|
|
|
6
6
|
tokenProvider: TokenProvider;
|
|
7
7
|
fetchImpl: typeof fetch;
|
|
8
8
|
retryPolicy: RetryPolicy;
|
|
9
|
-
|
|
9
|
+
timeoutMs: number;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
export declare
|
|
13
|
-
export
|
|
11
|
+
/** Private symbol copied through generated object spreads. */
|
|
12
|
+
export declare const requestContext: unique symbol;
|
|
13
|
+
export type RequestInitWithContext = RequestInit & {
|
|
14
|
+
[requestContext]?: RequestContext;
|
|
15
|
+
};
|
|
16
|
+
export declare function contextFromOptions(options: RequestInit): RequestContext;
|
|
17
|
+
/** Attach a client context without exposing it in serialized request options. */
|
|
18
|
+
export declare function withRequestContext(options: RequestInit | undefined, ctx: RequestContext): RequestInitWithContext;
|
|
19
|
+
/** Metadata carried on array payloads returned by customFetch for paged(). */
|
|
20
|
+
export declare const responseMeta: unique symbol;
|
|
21
|
+
export type ResponseWithMeta<T> = T & {
|
|
22
|
+
[responseMeta]?: ApiMeta | null;
|
|
23
|
+
};
|
package/dist/mutator.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import { type ApiMeta } from './errors';
|
|
2
|
+
import { type RequestContext } from './mutator.context';
|
|
1
3
|
export type UnwrapEnvelope<T> = T extends {
|
|
2
4
|
data?: infer D;
|
|
3
5
|
} ? NonNullable<D> : T;
|
|
6
|
+
type ResponseConsumer<T> = (response: Response, signal: AbortSignal) => Promise<T>;
|
|
7
|
+
export declare function authenticatedFetch<T>(ctx: RequestContext, url: string, options: RequestInit, consume: ResponseConsumer<T>): Promise<T>;
|
|
4
8
|
export declare function customFetch<T>(url: string, options: RequestInit): Promise<T>;
|
|
9
|
+
export declare function pagingFromResult<T>(items: T): ApiMeta | null;
|
|
10
|
+
export {};
|