@geekmidas/client 10.0.0-alpha.13 → 10.0.0-alpha.131
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 +40 -57
- package/dist/auth-fetcher.cjs +3 -1
- package/dist/auth-fetcher.cjs.map +1 -1
- package/dist/auth-fetcher.d.cts +2 -1
- package/dist/auth-fetcher.d.cts.map +1 -1
- package/dist/auth-fetcher.d.mts +2 -1
- package/dist/auth-fetcher.d.mts.map +1 -1
- package/dist/auth-fetcher.mjs +3 -1
- package/dist/auth-fetcher.mjs.map +1 -1
- package/dist/fetcher.cjs +6 -1
- package/dist/fetcher.cjs.map +1 -1
- package/dist/fetcher.d.cts +3 -1
- package/dist/fetcher.d.cts.map +1 -1
- package/dist/fetcher.d.mts +3 -1
- package/dist/fetcher.d.mts.map +1 -1
- package/dist/fetcher.mjs +6 -1
- package/dist/fetcher.mjs.map +1 -1
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/infer.d.cts +2 -2
- package/dist/infer.d.cts.map +1 -1
- package/dist/infer.d.mts +2 -2
- package/dist/infer.d.mts.map +1 -1
- package/dist/methods.cjs +21 -0
- package/dist/methods.cjs.map +1 -0
- package/dist/methods.d.cts +23 -0
- package/dist/methods.d.cts.map +1 -0
- package/dist/methods.d.mts +23 -0
- package/dist/methods.d.mts.map +1 -0
- package/dist/methods.mjs +19 -0
- package/dist/methods.mjs.map +1 -0
- package/dist/openapi-hooks.d.cts +2 -2
- package/dist/openapi-hooks.d.cts.map +1 -1
- package/dist/openapi-hooks.d.mts +2 -2
- package/dist/openapi-hooks.d.mts.map +1 -1
- package/dist/openapi-types.d.cts +3 -2
- package/dist/openapi-types.d.cts.map +1 -1
- package/dist/openapi-types.d.mts +3 -2
- package/dist/openapi-types.d.mts.map +1 -1
- package/dist/react-query.d.cts +2 -2
- package/dist/react-query.d.cts.map +1 -1
- package/dist/react-query.d.mts +2 -2
- package/dist/react-query.d.mts.map +1 -1
- package/dist/telemetry-g3BE86Wd.d.cts +68 -0
- package/dist/telemetry-g3BE86Wd.d.cts.map +1 -0
- package/dist/telemetry-g3BE86Wd.d.mts +68 -0
- package/dist/telemetry-g3BE86Wd.d.mts.map +1 -0
- package/dist/telemetry.cjs +128 -0
- package/dist/telemetry.cjs.map +1 -0
- package/dist/telemetry.d.cts +2 -0
- package/dist/telemetry.d.mts +2 -0
- package/dist/telemetry.mjs +125 -0
- package/dist/telemetry.mjs.map +1 -0
- package/dist/types.d.cts +21 -8
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +21 -8
- package/dist/types.d.mts.map +1 -1
- package/package.json +22 -9
- package/dist/openapi.cjs +0 -528
- package/dist/openapi.cjs.map +0 -1
- package/dist/openapi.d.cts +0 -494
- package/dist/openapi.d.cts.map +0 -1
- package/dist/openapi.d.mts +0 -494
- package/dist/openapi.d.mts.map +0 -1
- package/dist/openapi.mjs +0 -501
- package/dist/openapi.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { a as traceContextInjector, i as sampledAt, n as InvalidClientSampleRate, r as TraceContextInjector, t as ClientTelemetryOptions } from "./telemetry-g3BE86Wd.cjs";
|
|
1
2
|
import { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult } from "./types.cjs";
|
|
3
|
+
import { CALL_METHODS, CallMethod, MethodCall, MethodCalls, RoutesFor, methodCalls } from "./methods.cjs";
|
|
2
4
|
import { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher } from "./auth-fetcher.cjs";
|
|
3
5
|
import { FetchFn, TypedFetcher, createTypedFetcher } from "./fetcher.cjs";
|
|
4
6
|
import { InferOpenApi, InferOpenApiFromEndpoint } from "./infer.cjs";
|
|
5
|
-
export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetchFn, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, GetEndpointAuth, InferOpenApi, InferOpenApiFromEndpoint, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, PublicEndpoints, QueryEndpoint, RequestConfig, SecuritySchemeObject, TokenProvider, TypedApiFunction, TypedEndpoint, TypedFetcher, UsedSecuritySchemes, ValidEndpoint, WrappedApiFunction, WrappedResult, createAuthAwareFetcher, createTypedFetcher };
|
|
7
|
+
export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, CALL_METHODS, CallMethod, ClientTelemetryOptions, EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetchFn, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, GetEndpointAuth, InferOpenApi, InferOpenApiFromEndpoint, InvalidClientSampleRate, IsConfigRequired, MethodCall, MethodCalls, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, PublicEndpoints, QueryEndpoint, RequestConfig, RoutesFor, SecuritySchemeObject, TokenProvider, TraceContextInjector, TypedApiFunction, TypedEndpoint, TypedFetcher, UsedSecuritySchemes, ValidEndpoint, WrappedApiFunction, WrappedResult, createAuthAwareFetcher, createTypedFetcher, methodCalls, sampledAt, traceContextInjector };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { a as traceContextInjector, i as sampledAt, n as InvalidClientSampleRate, r as TraceContextInjector, t as ClientTelemetryOptions } from "./telemetry-g3BE86Wd.mjs";
|
|
1
2
|
import { EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint, WrappedApiFunction, WrappedResult } from "./types.mjs";
|
|
3
|
+
import { CALL_METHODS, CallMethod, MethodCall, MethodCalls, RoutesFor, methodCalls } from "./methods.mjs";
|
|
2
4
|
import { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, GetEndpointAuth, PublicEndpoints, SecuritySchemeObject, TokenProvider, UsedSecuritySchemes, createAuthAwareFetcher } from "./auth-fetcher.mjs";
|
|
3
5
|
import { FetchFn, TypedFetcher, createTypedFetcher } from "./fetcher.mjs";
|
|
4
6
|
import { InferOpenApi, InferOpenApiFromEndpoint } from "./infer.mjs";
|
|
5
|
-
export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetchFn, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, GetEndpointAuth, InferOpenApi, InferOpenApiFromEndpoint, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, PublicEndpoints, QueryEndpoint, RequestConfig, SecuritySchemeObject, TokenProvider, TypedApiFunction, TypedEndpoint, TypedFetcher, UsedSecuritySchemes, ValidEndpoint, WrappedApiFunction, WrappedResult, createAuthAwareFetcher, createTypedFetcher };
|
|
7
|
+
export { ApiKeyProvider, AuthFetcherOptions, AuthStrategy, AuthenticatedEndpoints, AwsSigner, CALL_METHODS, CallMethod, ClientTelemetryOptions, EndpointString, ErrorTransformer, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetchFn, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, GetEndpointAuth, InferOpenApi, InferOpenApiFromEndpoint, InvalidClientSampleRate, IsConfigRequired, MethodCall, MethodCalls, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, PublicEndpoints, QueryEndpoint, RequestConfig, RoutesFor, SecuritySchemeObject, TokenProvider, TraceContextInjector, TypedApiFunction, TypedEndpoint, TypedFetcher, UsedSecuritySchemes, ValidEndpoint, WrappedApiFunction, WrappedResult, createAuthAwareFetcher, createTypedFetcher, methodCalls, sampledAt, traceContextInjector };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CALL_METHODS, methodCalls } from "./methods.mjs";
|
|
2
|
+
import { InvalidClientSampleRate, sampledAt, traceContextInjector } from "./telemetry.mjs";
|
|
1
3
|
import { TypedFetcher, createTypedFetcher } from "./fetcher.mjs";
|
|
2
4
|
import { createAuthAwareFetcher } from "./auth-fetcher.mjs";
|
|
3
5
|
import "./infer.mjs";
|
|
4
6
|
import "./types.mjs";
|
|
5
|
-
export { TypedFetcher, createAuthAwareFetcher, createTypedFetcher };
|
|
7
|
+
export { CALL_METHODS, InvalidClientSampleRate, TypedFetcher, createAuthAwareFetcher, createTypedFetcher, methodCalls, sampledAt, traceContextInjector };
|
package/dist/infer.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
|
|
1
|
+
import { ConvertRouteParams, Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
|
|
2
2
|
import { HttpMethod } from "@geekmidas/constructs/types";
|
|
3
3
|
import { InferStandardSchema, InferStandardSchemaInput } from "@geekmidas/schema";
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -74,7 +74,7 @@ type InferOperation<TInput extends EndpointSchemas, TOutput extends StandardSche
|
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
76
|
export type InferOpenApiFromEndpoint<T> = T extends Endpoint<infer TRoute, infer TMethod, infer TInput, infer TOutput, any, any, any> ? {
|
|
77
|
-
paths: { [K in TRoute]: InferRouteParameters<TRoute
|
|
77
|
+
paths: { [K in ConvertRouteParams<TRoute>]: InferRouteParameters<ConvertRouteParams<TRoute>> & { [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput>; }; };
|
|
78
78
|
} : never;
|
|
79
79
|
/**
|
|
80
80
|
* Infers TypedFetcher-compatible paths structure from multiple endpoints
|
package/dist/infer.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infer.d.cts","names":[],"sources":["../src/infer.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"infer.d.cts","names":[],"sources":["../src/infer.ts"],"mappings":";;;;;;;;;KAgBK,gBAAgB,yBACpB,kCAAkC,eAAe,YAC3C,KAAK,oBAAmB,gBAAgB;;;;KAM1C,gBAAgB,UAAU,cAAc,UAAU;;;;KAKlD,qBAAqB,yBACzB,gBAAgB,gBAAgB;EAG7B;IACC,MAAM,gBAAgB;;;;;;KAOtB,yBAAyB,eAAe,mBAAmB;EAC/D,aAAa;;EAGX;IAMC,OAAO,yBAAyB;;;;;;KAQ/B,eACJ,eAAe,iBACf,gBAAgB,gCACb,yBAAyB;EAC5B,cAAc;IAAiB,YAAY;;IAExC;MAKC,oBAAoB,yBAAyB;;;EAIjD;IACC;MACC,SAAS,gBAAgB;QAEtB,oBAAoB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA+BlC,yBAAyB,KACpC,UAAU,eACH,cACA,eACA,cACA;EAUJ,UACE,KAAK,mBAAmB,UAAU,qBAClC,mBAAmB,cAElB,KAAK,gBAAgB,WAAW,eAAe,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA2ClD,aAAa,qCACxB,mCAAmC,gBAAgB,QAChD,yBAAyB;EAAiB,aAAa;IACtD;EACG,OAAO;IACT,aAAa;EAAgB,aAAa;;EACvC,OAAO,KAAK;;EACZ,OAAO;IACX,aAAa;EACZ"}
|
package/dist/infer.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
|
|
1
|
+
import { ConvertRouteParams, Endpoint, EndpointSchemas } from "@geekmidas/constructs/endpoints";
|
|
2
2
|
import { HttpMethod } from "@geekmidas/constructs/types";
|
|
3
3
|
import { InferStandardSchema, InferStandardSchemaInput } from "@geekmidas/schema";
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -74,7 +74,7 @@ type InferOperation<TInput extends EndpointSchemas, TOutput extends StandardSche
|
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
76
|
export type InferOpenApiFromEndpoint<T> = T extends Endpoint<infer TRoute, infer TMethod, infer TInput, infer TOutput, any, any, any> ? {
|
|
77
|
-
paths: { [K in TRoute]: InferRouteParameters<TRoute
|
|
77
|
+
paths: { [K in ConvertRouteParams<TRoute>]: InferRouteParameters<ConvertRouteParams<TRoute>> & { [M in LowercaseMethod<TMethod>]: InferOperation<TInput, TOutput>; }; };
|
|
78
78
|
} : never;
|
|
79
79
|
/**
|
|
80
80
|
* Infers TypedFetcher-compatible paths structure from multiple endpoints
|
package/dist/infer.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infer.d.mts","names":[],"sources":["../src/infer.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"infer.d.mts","names":[],"sources":["../src/infer.ts"],"mappings":";;;;;;;;;KAgBK,gBAAgB,yBACpB,kCAAkC,eAAe,YAC3C,KAAK,oBAAmB,gBAAgB;;;;KAM1C,gBAAgB,UAAU,cAAc,UAAU;;;;KAKlD,qBAAqB,yBACzB,gBAAgB,gBAAgB;EAG7B;IACC,MAAM,gBAAgB;;;;;;KAOtB,yBAAyB,eAAe,mBAAmB;EAC/D,aAAa;;EAGX;IAMC,OAAO,yBAAyB;;;;;;KAQ/B,eACJ,eAAe,iBACf,gBAAgB,gCACb,yBAAyB;EAC5B,cAAc;IAAiB,YAAY;;IAExC;MAKC,oBAAoB,yBAAyB;;;EAIjD;IACC;MACC,SAAS,gBAAgB;QAEtB,oBAAoB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA+BlC,yBAAyB,KACpC,UAAU,eACH,cACA,eACA,cACA;EAUJ,UACE,KAAK,mBAAmB,UAAU,qBAClC,mBAAmB,cAElB,KAAK,gBAAgB,WAAW,eAAe,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA2ClD,aAAa,qCACxB,mCAAmC,gBAAgB,QAChD,yBAAyB;EAAiB,aAAa;IACtD;EACG,OAAO;IACT,aAAa;EAAgB,aAAa;;EACvC,OAAO,KAAK;;EACZ,OAAO;IACX,aAAa;EACZ"}
|
package/dist/methods.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/methods.ts
|
|
3
|
+
/** The HTTP methods a client offers as calls: `api.get(…)`, `api.post(…)`. */
|
|
4
|
+
const CALL_METHODS = [
|
|
5
|
+
"get",
|
|
6
|
+
"post",
|
|
7
|
+
"put",
|
|
8
|
+
"patch",
|
|
9
|
+
"delete",
|
|
10
|
+
"options"
|
|
11
|
+
];
|
|
12
|
+
/** The method calls for a client, each delegating to `api('METHOD /route', …)`. */
|
|
13
|
+
function methodCalls(fn) {
|
|
14
|
+
const call = (method) => (route, config) => fn(`${method.toUpperCase()} ${route}`, config);
|
|
15
|
+
return Object.fromEntries(CALL_METHODS.map((method) => [method, call(method)]));
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.CALL_METHODS = CALL_METHODS;
|
|
19
|
+
exports.methodCalls = methodCalls;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=methods.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.cjs","names":[],"sources":["../src/methods.ts"],"sourcesContent":["import type {\n\tExtractEndpointResponse,\n\tExtractMethod,\n\tFilteredRequestConfig,\n\tIsConfigRequired,\n\tTypedApiFunction,\n\tTypedEndpoint,\n} from './types';\n\n/** The HTTP methods a client offers as calls: `api.get(…)`, `api.post(…)`. */\nexport const CALL_METHODS = [\n\t'get',\n\t'post',\n\t'put',\n\t'patch',\n\t'delete',\n\t'options',\n] as const;\n\nexport type CallMethod = (typeof CALL_METHODS)[number];\n\n/**\n * The routes that answer `M` — only routes with a `POST` appear in `api.post`,\n * so a route that exists under another method is a type error, not a 405.\n */\nexport type RoutesFor<Paths, M extends CallMethod> = {\n\t[R in keyof Paths]: M extends ExtractMethod<Paths, R> ? R : never;\n}[keyof Paths] &\n\tstring;\n\n/**\n * One method's call: `api.post('/users', { body })`.\n *\n * The second argument has only the keys the endpoint declares, and is required\n * exactly when something in it is — the same rule as `api('POST /users', …)`,\n * which this is sugar over.\n */\nexport type MethodCall<Paths, M extends CallMethod> = <\n\tR extends RoutesFor<Paths, M>,\n>(\n\troute: R,\n\t...args: `${Uppercase<M>} ${R}` extends TypedEndpoint<Paths>\n\t\t? IsConfigRequired<Paths, `${Uppercase<M>} ${R}`> extends true\n\t\t\t? [config: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>]\n\t\t\t: [config?: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>]\n\t\t: never\n) => Promise<ExtractEndpointResponse<Paths, `${Uppercase<M>} ${R}`>>;\n\nexport type MethodCalls<Paths> = {\n\t[M in CallMethod]: MethodCall<Paths, M>;\n};\n\n/** The method calls for a client, each delegating to `api('METHOD /route', …)`. */\nexport function methodCalls<Paths>(\n\tfn: TypedApiFunction<Paths>,\n): MethodCalls<Paths> {\n\tconst call =\n\t\t(method: CallMethod) =>\n\t\t(route: string, config?: unknown): Promise<unknown> =>\n\t\t\t(fn as (endpoint: string, config?: unknown) => Promise<unknown>)(\n\t\t\t\t`${method.toUpperCase()} ${route}`,\n\t\t\t\tconfig,\n\t\t\t);\n\n\treturn Object.fromEntries(\n\t\tCALL_METHODS.map((method) => [method, call(method)]),\n\t) as unknown as MethodCalls<Paths>;\n}\n"],"mappings":";;;AAUA,MAAa,eAAe;CAC3B;CACA;CACA;CACA;CACA;CACA;AACD;;AAoCA,SAAgB,YACf,IACqB;CACrB,MAAM,QACJ,YACA,OAAe,WACd,GACA,GAAG,OAAO,YAAY,EAAE,GAAG,SAC3B,MACD;CAEF,OAAO,OAAO,YACb,aAAa,KAAK,WAAW,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CACpD;AACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ExtractEndpointResponse, ExtractMethod, FilteredRequestConfig, IsConfigRequired, TypedApiFunction, TypedEndpoint } from "./types.cjs";
|
|
2
|
+
//#region src/methods.d.ts
|
|
3
|
+
/** The HTTP methods a client offers as calls: `api.get(…)`, `api.post(…)`. */
|
|
4
|
+
export declare const CALL_METHODS: readonly ['get', 'post', 'put', 'patch', 'delete', 'options'];
|
|
5
|
+
export type CallMethod = (typeof CALL_METHODS)[number];
|
|
6
|
+
/**
|
|
7
|
+
* The routes that answer `M` — only routes with a `POST` appear in `api.post`,
|
|
8
|
+
* so a route that exists under another method is a type error, not a 405.
|
|
9
|
+
*/
|
|
10
|
+
export type RoutesFor<Paths, M extends CallMethod> = { [R in keyof Paths]: M extends ExtractMethod<Paths, R> ? R : never; }[keyof Paths] & string;
|
|
11
|
+
/**
|
|
12
|
+
* One method's call: `api.post('/users', { body })`.
|
|
13
|
+
*
|
|
14
|
+
* The second argument has only the keys the endpoint declares, and is required
|
|
15
|
+
* exactly when something in it is — the same rule as `api('POST /users', …)`,
|
|
16
|
+
* which this is sugar over.
|
|
17
|
+
*/
|
|
18
|
+
export type MethodCall<Paths, M extends CallMethod> = <R extends RoutesFor<Paths, M>>(route: R, ...args: `${Uppercase<M>} ${R}` extends TypedEndpoint<Paths> ? IsConfigRequired<Paths, `${Uppercase<M>} ${R}`> extends true ? [config: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>] : [config?: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>] : never) => Promise<ExtractEndpointResponse<Paths, `${Uppercase<M>} ${R}`>>;
|
|
19
|
+
export type MethodCalls<Paths> = { [M in CallMethod]: MethodCall<Paths, M>; };
|
|
20
|
+
/** The method calls for a client, each delegating to `api('METHOD /route', …)`. */
|
|
21
|
+
export declare function methodCalls<Paths>(fn: TypedApiFunction<Paths>): MethodCalls<Paths>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=methods.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.d.cts","names":[],"sources":["../src/methods.ts"],"mappings":";;;qBAUa;YASD,qBAAqB;;;;;YAMrB,UAAU,OAAO,UAAU,iBACrC,WAAW,QAAQ,UAAU,cAAc,OAAO,KAAK,mBACjD;;;;;;;;YAUI,WAAW,OAAO,UAAU,eACvC,UAAU,UAAU,OAAO,IAE3B,OAAO,MACJ,SAAS,UAAU,MAAM,YAAY,cAAc,SACnD,iBAAiB,UAAU,UAAU,MAAM,qBACzC,QAAQ,sBAAsB,UAAU,UAAU,MAAM,SACxD,SAAS,sBAAsB,UAAU,UAAU,MAAM,kBAE1D,QAAQ,wBAAwB,UAAU,UAAU,MAAM;YAEnD,YAAY,YACtB,KAAK,aAAa,WAAW,OAAO;;wBAItB,YAAY,OAC3B,IAAI,iBAAiB,SACnB,YAAY"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ExtractEndpointResponse, ExtractMethod, FilteredRequestConfig, IsConfigRequired, TypedApiFunction, TypedEndpoint } from "./types.mjs";
|
|
2
|
+
//#region src/methods.d.ts
|
|
3
|
+
/** The HTTP methods a client offers as calls: `api.get(…)`, `api.post(…)`. */
|
|
4
|
+
export declare const CALL_METHODS: readonly ['get', 'post', 'put', 'patch', 'delete', 'options'];
|
|
5
|
+
export type CallMethod = (typeof CALL_METHODS)[number];
|
|
6
|
+
/**
|
|
7
|
+
* The routes that answer `M` — only routes with a `POST` appear in `api.post`,
|
|
8
|
+
* so a route that exists under another method is a type error, not a 405.
|
|
9
|
+
*/
|
|
10
|
+
export type RoutesFor<Paths, M extends CallMethod> = { [R in keyof Paths]: M extends ExtractMethod<Paths, R> ? R : never; }[keyof Paths] & string;
|
|
11
|
+
/**
|
|
12
|
+
* One method's call: `api.post('/users', { body })`.
|
|
13
|
+
*
|
|
14
|
+
* The second argument has only the keys the endpoint declares, and is required
|
|
15
|
+
* exactly when something in it is — the same rule as `api('POST /users', …)`,
|
|
16
|
+
* which this is sugar over.
|
|
17
|
+
*/
|
|
18
|
+
export type MethodCall<Paths, M extends CallMethod> = <R extends RoutesFor<Paths, M>>(route: R, ...args: `${Uppercase<M>} ${R}` extends TypedEndpoint<Paths> ? IsConfigRequired<Paths, `${Uppercase<M>} ${R}`> extends true ? [config: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>] : [config?: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>] : never) => Promise<ExtractEndpointResponse<Paths, `${Uppercase<M>} ${R}`>>;
|
|
19
|
+
export type MethodCalls<Paths> = { [M in CallMethod]: MethodCall<Paths, M>; };
|
|
20
|
+
/** The method calls for a client, each delegating to `api('METHOD /route', …)`. */
|
|
21
|
+
export declare function methodCalls<Paths>(fn: TypedApiFunction<Paths>): MethodCalls<Paths>;
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=methods.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.d.mts","names":[],"sources":["../src/methods.ts"],"mappings":";;;qBAUa;YASD,qBAAqB;;;;;YAMrB,UAAU,OAAO,UAAU,iBACrC,WAAW,QAAQ,UAAU,cAAc,OAAO,KAAK,mBACjD;;;;;;;;YAUI,WAAW,OAAO,UAAU,eACvC,UAAU,UAAU,OAAO,IAE3B,OAAO,MACJ,SAAS,UAAU,MAAM,YAAY,cAAc,SACnD,iBAAiB,UAAU,UAAU,MAAM,qBACzC,QAAQ,sBAAsB,UAAU,UAAU,MAAM,SACxD,SAAS,sBAAsB,UAAU,UAAU,MAAM,kBAE1D,QAAQ,wBAAwB,UAAU,UAAU,MAAM;YAEnD,YAAY,YACtB,KAAK,aAAa,WAAW,OAAO;;wBAItB,YAAY,OAC3B,IAAI,iBAAiB,SACnB,YAAY"}
|
package/dist/methods.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/methods.ts
|
|
2
|
+
/** The HTTP methods a client offers as calls: `api.get(…)`, `api.post(…)`. */
|
|
3
|
+
const CALL_METHODS = [
|
|
4
|
+
"get",
|
|
5
|
+
"post",
|
|
6
|
+
"put",
|
|
7
|
+
"patch",
|
|
8
|
+
"delete",
|
|
9
|
+
"options"
|
|
10
|
+
];
|
|
11
|
+
/** The method calls for a client, each delegating to `api('METHOD /route', …)`. */
|
|
12
|
+
function methodCalls(fn) {
|
|
13
|
+
const call = (method) => (route, config) => fn(`${method.toUpperCase()} ${route}`, config);
|
|
14
|
+
return Object.fromEntries(CALL_METHODS.map((method) => [method, call(method)]));
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CALL_METHODS, methodCalls };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=methods.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methods.mjs","names":[],"sources":["../src/methods.ts"],"sourcesContent":["import type {\n\tExtractEndpointResponse,\n\tExtractMethod,\n\tFilteredRequestConfig,\n\tIsConfigRequired,\n\tTypedApiFunction,\n\tTypedEndpoint,\n} from './types';\n\n/** The HTTP methods a client offers as calls: `api.get(…)`, `api.post(…)`. */\nexport const CALL_METHODS = [\n\t'get',\n\t'post',\n\t'put',\n\t'patch',\n\t'delete',\n\t'options',\n] as const;\n\nexport type CallMethod = (typeof CALL_METHODS)[number];\n\n/**\n * The routes that answer `M` — only routes with a `POST` appear in `api.post`,\n * so a route that exists under another method is a type error, not a 405.\n */\nexport type RoutesFor<Paths, M extends CallMethod> = {\n\t[R in keyof Paths]: M extends ExtractMethod<Paths, R> ? R : never;\n}[keyof Paths] &\n\tstring;\n\n/**\n * One method's call: `api.post('/users', { body })`.\n *\n * The second argument has only the keys the endpoint declares, and is required\n * exactly when something in it is — the same rule as `api('POST /users', …)`,\n * which this is sugar over.\n */\nexport type MethodCall<Paths, M extends CallMethod> = <\n\tR extends RoutesFor<Paths, M>,\n>(\n\troute: R,\n\t...args: `${Uppercase<M>} ${R}` extends TypedEndpoint<Paths>\n\t\t? IsConfigRequired<Paths, `${Uppercase<M>} ${R}`> extends true\n\t\t\t? [config: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>]\n\t\t\t: [config?: FilteredRequestConfig<Paths, `${Uppercase<M>} ${R}`>]\n\t\t: never\n) => Promise<ExtractEndpointResponse<Paths, `${Uppercase<M>} ${R}`>>;\n\nexport type MethodCalls<Paths> = {\n\t[M in CallMethod]: MethodCall<Paths, M>;\n};\n\n/** The method calls for a client, each delegating to `api('METHOD /route', …)`. */\nexport function methodCalls<Paths>(\n\tfn: TypedApiFunction<Paths>,\n): MethodCalls<Paths> {\n\tconst call =\n\t\t(method: CallMethod) =>\n\t\t(route: string, config?: unknown): Promise<unknown> =>\n\t\t\t(fn as (endpoint: string, config?: unknown) => Promise<unknown>)(\n\t\t\t\t`${method.toUpperCase()} ${route}`,\n\t\t\t\tconfig,\n\t\t\t);\n\n\treturn Object.fromEntries(\n\t\tCALL_METHODS.map((method) => [method, call(method)]),\n\t) as unknown as MethodCalls<Paths>;\n}\n"],"mappings":";;AAUA,MAAa,eAAe;CAC3B;CACA;CACA;CACA;CACA;CACA;AACD;;AAoCA,SAAgB,YACf,IACqB;CACrB,MAAM,QACJ,YACA,OAAe,WACd,GACA,GAAG,OAAO,YAAY,EAAE,GAAG,SAC3B,MACD;CAEF,OAAO,OAAO,YACb,aAAa,KAAK,WAAW,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CACpD;AACD"}
|
package/dist/openapi-hooks.d.cts
CHANGED
|
@@ -89,8 +89,8 @@ interface OperationRegistry {
|
|
|
89
89
|
export declare function createOpenAPIHooks<Paths>(options?: FetcherOptions & {
|
|
90
90
|
operations?: OperationRegistry;
|
|
91
91
|
}): {
|
|
92
|
-
useQuery: <OpId extends OperationsByMethod<Paths,
|
|
93
|
-
useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths,
|
|
92
|
+
useQuery: <OpId extends OperationsByMethod<Paths, 'get'>>(operationId: OpId, config?: RemoveNever<OperationParams<Paths, OpId>>, options?: Omit<UseQueryOptions<OperationResponse<Paths, OpId>, Error>, 'queryKey' | 'queryFn'>) => import("@tanstack/react-query").UseQueryResult<OperationResponse<Paths, OpId>, Error>;
|
|
93
|
+
useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths, 'get'>>>(operationId: OpId, options?: Omit<UseMutationOptions<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>>, 'mutationFn'>) => import("@tanstack/react-query").UseMutationResult<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>, unknown>;
|
|
94
94
|
};
|
|
95
95
|
//#endregion
|
|
96
96
|
//# sourceMappingURL=openapi-hooks.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-hooks.d.cts","names":[],"sources":["../src/openapi-hooks.ts"],"mappings":";;;KASK;KAGA,cAAc,YACjB,cAAc,WACb,gBAAgB,MAAM,QAAQ,cAAc,MAAM,MAAM;EACxD,mBAAmB;IAEjB;EAEC,aAAa;EACb,MAAM;EACN,QAAQ;EACR,MAAM,MAAM,MAAM;IACjB,cAAc,MAAM;MACnB;QAAc,YAAY;;QAExB;;2BAMD,MAAM,QAAQ,sBACf;KAGH,aAAa,YAChB,MAAM,cAAc,UAAU;EAC9B,mBAAmB;IAEjB,aACQ;KAIP,YAAY,eAAe,aAAa;KAGxC,mBAAmB,OAAO,eAAe,kBAC5C,KAAK,YAAY,SAAS,aAAa,OAAO;EAAa,QAAQ;IACjE,aAEF,YAAY;KAGT,gBACJ,OACA,aAAa,YAAY,UACtB,aAAa,OAAO;EACvB,YAAY,mBAAmB;EAC/B,YAAY;;EAGV,SAAS,MAAM;IAAgB;MAAc,YAAY;;MACtD,IACA;IAAe;MAAc,YAAY;;MACxC;EAEJ,QAAQ;IAAe;MAAe,cAAc;;MAAQ;EAC5D,OAAO;IACN;MAAe;QAAW,0BAA0B;;;MAElD,OACA;IACC;MACC;MACA;QAAW,0BAA0B;;;MAGtC;;KAMF,kBACJ,OACA,aAAa,YAAY,UACtB,aAAa,OAAO;EAAgB,YAAY;IACjD;EACA;IAAa;MAAO;QAAW,0BAA0B;;;;IAExD,IACA;EACC;IAAa;MAAO;QAAW,0BAA0B;;;;IAEzD,IACA;EAAe;IAAa;;;KAM5B,YAAY,KAAK,KACrB,MAEE,WAAW,IAAI,EAAE,2BAA2B,WACtC;UAIC;GACR;IACA;IACA;;;wBAIc,mBAAmB,OAClC,UAAS;EAAmB,aAAa;;
|
|
1
|
+
{"version":3,"file":"openapi-hooks.d.cts","names":[],"sources":["../src/openapi-hooks.ts"],"mappings":";;;KASK;KAGA,cAAc,YACjB,cAAc,WACb,gBAAgB,MAAM,QAAQ,cAAc,MAAM,MAAM;EACxD,mBAAmB;IAEjB;EAEC,aAAa;EACb,MAAM;E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openapi-hooks.d.mts
CHANGED
|
@@ -89,8 +89,8 @@ interface OperationRegistry {
|
|
|
89
89
|
export declare function createOpenAPIHooks<Paths>(options?: FetcherOptions & {
|
|
90
90
|
operations?: OperationRegistry;
|
|
91
91
|
}): {
|
|
92
|
-
useQuery: <OpId extends OperationsByMethod<Paths,
|
|
93
|
-
useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths,
|
|
92
|
+
useQuery: <OpId extends OperationsByMethod<Paths, 'get'>>(operationId: OpId, config?: RemoveNever<OperationParams<Paths, OpId>>, options?: Omit<UseQueryOptions<OperationResponse<Paths, OpId>, Error>, 'queryKey' | 'queryFn'>) => import("@tanstack/react-query").UseQueryResult<OperationResponse<Paths, OpId>, Error>;
|
|
93
|
+
useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths, 'get'>>>(operationId: OpId, options?: Omit<UseMutationOptions<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>>, 'mutationFn'>) => import("@tanstack/react-query").UseMutationResult<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>, unknown>;
|
|
94
94
|
};
|
|
95
95
|
//#endregion
|
|
96
96
|
//# sourceMappingURL=openapi-hooks.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-hooks.d.mts","names":[],"sources":["../src/openapi-hooks.ts"],"mappings":";;;KASK;KAGA,cAAc,YACjB,cAAc,WACb,gBAAgB,MAAM,QAAQ,cAAc,MAAM,MAAM;EACxD,mBAAmB;IAEjB;EAEC,aAAa;EACb,MAAM;EACN,QAAQ;EACR,MAAM,MAAM,MAAM;IACjB,cAAc,MAAM;MACnB;QAAc,YAAY;;QAExB;;2BAMD,MAAM,QAAQ,sBACf;KAGH,aAAa,YAChB,MAAM,cAAc,UAAU;EAC9B,mBAAmB;IAEjB,aACQ;KAIP,YAAY,eAAe,aAAa;KAGxC,mBAAmB,OAAO,eAAe,kBAC5C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V,SAAS,MAAM;IAAgB;MAAc,YAAY;;MACtD,IACA;IAAe;MAAc,YAAY;;MACxC;EAEJ,QAAQ;IAAe;MAAe,cAAc;;MAAQ;EAC5D,OAAO;IACN;MAAe;QAAW,0BAA0B;;;MAElD,OACA;IACC;MACC;MACA;QAAW,0BAA0B;;;MAGtC;;KAMF,kBACJ,OACA,aAAa,YAAY,UACtB,aAAa,OAAO;EAAgB,YAAY;IACjD;EACA;IAAa;MAAO;QAAW,0BAA0B;;;;IAExD,IACA;EACC;IAAa;MAAO;QAAW,0BAA0B;;;;IAEzD,IACA;EAAe;IAAa;;;KAM5B,YAAY,KAAK,KACrB,MAEE,WAAW,IAAI,EAAE,2BAA2B,WACtC;UAIC;GACR;IACA;IACA;;;wBAIc,mBAAmB,OAClC,UAAS;EAAmB,aAAa;;EAkBxC,WAAW,aAAa,mBAAmB,eAAa,aAC1C,MAAI,SACR,YAAY,gBAAgB,OAAO,QAAM,UACxC,KACT,gBAAgB,kBAAkB,OAAO,OAAO,oEAEhD,eAAA,kBAAA,OAAA,OAAA;EAeF,cACC,aAAa,QACZ,YAAY,QACZ,mBAAmB,gBACnB,aAEY,MAAI,UACP,KACT,mBACC,kBAAkB,OAAO,OACzB,OACA,YAAY,gBAAgB,OAAO,2DAGpC,kBAAA,kBAAA,OAAA,OAAA,OAAA,YAAA,gBAAA,OAAA"}
|
package/dist/openapi-types.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//#region src/openapi-types.d.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* A hand-written `paths` fixture in openapi-typescript's shape, for the
|
|
4
|
+
* client's own tests. Applications get theirs from `gkm build`, which writes
|
|
5
|
+
* a typed client per surface to the workspace root's `.gkm/client/<surface>.ts`.
|
|
5
6
|
*
|
|
6
7
|
* This is a placeholder file showing the expected structure.
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-types.d.cts","names":[],"sources":["../src/openapi-types.d.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"openapi-types.d.cts","names":[],"sources":["../src/openapi-types.d.ts"],"mappings":";;;;;;;;iBAQiB;EAChB;IACC;MACC;MACA;MACA;MACA;;IAED;MACC;MACA;QACC;QACA;QACA;UACC;;QAED;;MAED;MACA;;QAEC;UACC;aACE;;UAEF;YACC;cACC;cACA;cACA;cACA;gBACC;gBACA;;cAED;gBACC;gBACA;;cAED;gBACC;gBACA;;;cAGD;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;;;;;IAML;MACC;MACA;QACC;QACA;QACA;UACC;;QAED;;MAED;QACC;UACC;YACC;YACA;YACA;YACA;cACC;cACA;;YAED;cACC;cACA;;YAED;cACC;cACA;;;YAGD;;;;MAIH;;QAEC;UACC;aACE;;UAEF;YACC;cACC;cACA;cACA;cACA;gBACC;gBACA;;cAED;gBACC;gBACA;;cAED;gBACC;gBACA;;;cAGD;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;;;;;IAML;IACA;MACC;MACA;QACC;QACA;QACA;UACC;;QAED;;MAED;MACA;;QAEC;UACC;aACE;;UAEF;YACC;cACC;;cAEA;;;;;;IAML;IACA;IACA;IACA;;EAED;IACC;MACC;MACA;QACC;UACC;UACA;UACA;;;MAGF;QACC;UACC;YACC;cACC,OAAO;gBACN;gBACA;gBACA;;;;;;;IAON;MACC;MACA;QACC;UACC;YACC;YACA;;;;MAIH;QACC;UACC;YACC;cACC;cACA;cACA;;;;;;;EAON;IACC;MACC;QACC;;;IAGF;MACC;MACA;QACC;UACC;YACC;cACC;cACA;cACA;;;;;;IAML;MACC;MACA;QACC;UACC;YACC;YACA;;;;MAIH;QACC;UACC;YACC;cACC;cACA;cACA;;;;;;IAML;MACC;MACA;QACC;UACC;;;;;EAKJ;IACC;MACC;MACA;QACC;UACC;UACA;UACA;;;MAGF;QACC;UACC;YACC;cACC,OAAO;gBACN;gBACA;gBACA;gBACA;gBACA;;cAED;gBACC;gBACA;gBACA;;cAED;;;;;;;EAON;IACC;MACC;MACA;QACC;UACC;YACC;cACC;;;;QAIH;UACC;YACC;cACC;;;;;;;EAON;IACC;MACC;MACA;QACC;UACC;YACC;cACC;;;;;;;EAON;IACC;MACC;MACA;QACC;UACC;UACA;;;MAGF;QACC;UACC;YACC;cACC,OAAO;gBACN;gBACA;gBACA;;cAED;gBACC;gBACA;gBACA;gBACA;;;;;;;;EAQP;IACC;MACC;MACA;QACC;UACC;UACA;;;MAGF;QACC;UACC;YACC;cACC,UAAU;gBACT;gBACA;gBACA;;cAED;;;;;;;EAON;IACC;MACC;MACA;QACC;WACE;;;MAGH;QACC;UACC;YACC;cACC,aAAa;cACb,MAAM;gBACL;gBACA;;cAED;gBACC;gBACA;gBACA;gBACA;;;;;;;;;iBAUS;EAChB;IACC;MACC;MACA;MACA;;IAED;MACC;MACA;MACA;MACA;MACA"}
|
package/dist/openapi-types.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
//#region src/openapi-types.d.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* A hand-written `paths` fixture in openapi-typescript's shape, for the
|
|
4
|
+
* client's own tests. Applications get theirs from `gkm build`, which writes
|
|
5
|
+
* a typed client per surface to the workspace root's `.gkm/client/<surface>.ts`.
|
|
5
6
|
*
|
|
6
7
|
* This is a placeholder file showing the expected structure.
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-types.d.mts","names":[],"sources":["../src/openapi-types.d.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"openapi-types.d.mts","names":[],"sources":["../src/openapi-types.d.ts"],"mappings":";;;;;;;;iBAQiB;EAChB;IACC;MACC;MACA;MACA;MACA;;IAED;MACC;MACA;QACC;QACA;QACA;UACC;;QAED;;MAED;MACA;;QAEC;UACC;aACE;;UAEF;YACC;cACC;cACA;cACA;cACA;gBACC;gBACA;;cAED;gBACC;gBACA;;cAED;gBACC;gBACA;;;cAGD;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;;;;;IAML;MACC;MACA;QACC;QACA;QACA;UACC;;QAED;;MAED;QACC;UACC;YACC;YACA;YACA;YACA;cACC;cACA;;YAED;cACC;cACA;;YAED;cACC;cACA;;;YAGD;;;;MAIH;;QAEC;UACC;aACE;;UAEF;YACC;cACC;cACA;cACA;cACA;gBACC;gBACA;;cAED;gBACC;gBACA;;cAED;gBACC;gBACA;;;cAGD;;cAEA;;cAEA;;cAEA;;cAEA;;cAEA;;;;;;IAML;IACA;MACC;MACA;QACC;QACA;QACA;UACC;;QAED;;MAED;MACA;;QAEC;UACC;aACE;;UAEF;YACC;cACC;;cAEA;;;;;;IAML;IACA;IACA;IACA;;EAED;IACC;MACC;MACA;QACC;UACC;UACA;UACA;;;MAGF;QACC;UACC;YACC;cACC,OAAO;gBACN;gBACA;gBACA;;;;;;;IAON;MACC;MACA;QACC;UACC;YACC;YACA;;;;MAIH;QACC;UACC;YACC;cACC;cACA;cACA;;;;;;;EAON;IACC;MACC;QACC;;;IAGF;MACC;MACA;QACC;UACC;YACC;cACC;cACA;cACA;;;;;;IAML;MACC;MACA;QACC;UACC;YACC;YACA;;;;MAIH;QACC;UACC;YACC;cACC;cACA;cACA;;;;;;IAML;MACC;MACA;QACC;UACC;;;;;EAKJ;IACC;MACC;MACA;QACC;UACC;UACA;UACA;;;MAGF;QACC;UACC;YACC;cACC,OAAO;gBACN;gBACA;gBACA;gBACA;gBACA;;cAED;gBACC;gBACA;gBACA;;cAED;;;;;;;EAON;IACC;MACC;MACA;QACC;UACC;YACC;cACC;;;;QAIH;UACC;YACC;cACC;;;;;;;EAON;IACC;MACC;MACA;QACC;UACC;YACC;cACC;;;;;;;EAON;IACC;MACC;MACA;QACC;UACC;UACA;;;MAGF;QACC;UACC;YACC;cACC,OAAO;gBACN;gBACA;gBACA;;cAED;gBACC;gBACA;gBACA;gBACA;;;;;;;;EAQP;IACC;MACC;MACA;QACC;UACC;UACA;;;MAGF;QACC;UACC;YACC;cACC,UAAU;gBACT;gBACA;gBACA;;cAED;;;;;;;EAON;IACC;MACC;MACA;QACC;WACE;;;MAGH;QACC;UACC;YACC;cACC,aAAa;cACb,MAAM;gBACL;gBACA;;cAED;gBACC;gBACA;gBACA;gBACA;;;;;;;;;iBAUS;EAChB;IACC;MACC;MACA;MACA;;IAED;MACC;MACA;MACA;MACA;MACA"}
|
package/dist/react-query.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class TypedQueryClient<Paths> {
|
|
|
8
8
|
private fetcher;
|
|
9
9
|
private queryClient?;
|
|
10
10
|
constructor(options?: TypedQueryClientOptions);
|
|
11
|
-
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<
|
|
11
|
+
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
12
12
|
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
13
13
|
useInfiniteQuery<T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
14
14
|
pages: TPageData[];
|
|
@@ -45,7 +45,7 @@ export declare class TypedQueryClient<Paths> {
|
|
|
45
45
|
setQueryClient(queryClient: QueryClient): void;
|
|
46
46
|
}
|
|
47
47
|
export declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
48
|
-
export declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<
|
|
48
|
+
export declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
49
49
|
export declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
50
50
|
export declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
51
51
|
pages: TPageData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.d.cts","names":[],"sources":["../src/react-query.ts"],"mappings":";;;iBAwBiB,gCAAgC;EAChD,cAAc;;qBAGF,iBAAiB;UACrB;UACA;
|
|
1
|
+
{"version":3,"file":"react-query.d.cts","names":[],"sources":["../src/react-query.ts"],"mappings":";;;iBAwBiB,gCAAgC;EAChD,cAAc;;qBAGF,iBAAiB;UACrB;UACA;EAER,YAAY,UA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AC3C,sBAEA,QAAQ,iBAAiB,QACzB,UAAU,GACV,SAAS,KACR,wBACC,WACA;EACE,OAAO;EAAa,YAAY;cAElC;EAID,mBACC,UAAU,WACV,UAAU,aACV,eAAe,YACf,eAAe,iBACX;EACL,kBAAkB;GAEnB,SAAS,sBAAsB,OAAO,qCAAE;;;GAGxC;;;;wBAKe,0BAA0B,OACzC,QAAQ,iBAAiB;;;;EAQxB,oBAAoB,UAAU,cAAc,QAAM,UACvC,GAAC,SACF,sBAAsB,OAAO,OAAE;;;;EAYzC,4BAAoB"}
|
package/dist/react-query.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class TypedQueryClient<Paths> {
|
|
|
8
8
|
private fetcher;
|
|
9
9
|
private queryClient?;
|
|
10
10
|
constructor(options?: TypedQueryClientOptions);
|
|
11
|
-
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<
|
|
11
|
+
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
12
12
|
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
13
13
|
useInfiniteQuery<T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
14
14
|
pages: TPageData[];
|
|
@@ -45,7 +45,7 @@ export declare class TypedQueryClient<Paths> {
|
|
|
45
45
|
setQueryClient(queryClient: QueryClient): void;
|
|
46
46
|
}
|
|
47
47
|
export declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
48
|
-
export declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<
|
|
48
|
+
export declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<ExtractEndpointResponse<Paths, T>, Response>;
|
|
49
49
|
export declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): import("@tanstack/react-query").UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
50
50
|
export declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
51
51
|
pages: TPageData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-query.d.mts","names":[],"sources":["../src/react-query.ts"],"mappings":";;;iBAwBiB,gCAAgC;EAChD,cAAc;;qBAGF,iBAAiB;UACrB;UACA;
|
|
1
|
+
{"version":3,"file":"react-query.d.mts","names":[],"sources":["../src/react-query.ts"],"mappings":";;;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sBAAA,OAAA;wBAKc,sBACf,OACA,UAAU,cAAc,QACxB,YAAY,wBAAwB,OAAO,IAC3C,sBAEA,QAAQ,iBAAiB,QACzB,UAAU,GACV,SAAS,KACR,wBACC,WACA;EACE,OAAO;EAAa,YAAY;cAElC;EAID,mBACC,UAAU,WACV,UAAU,aACV,eAAe,YACf,eAAe,iBACX;EACL,kBAAkB;GAEnB,SAAS,sBAAsB,OAAO,qCAAE;;;GAGxC;;;;wBAKe,0BAA0B,OACzC,QAAQ,iBAAiB;;;;EAQxB,oBAAoB,UAAU,cAAc,QAAM,UACvC,GAAC,SACF,sBAAsB,OAAO,OAAE;;;;EAYzC,4BAAoB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/telemetry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* W3C trace context on the requests a client makes to its own API, so a user
|
|
4
|
+
* action in the browser and the API request it causes are one trace.
|
|
5
|
+
*
|
|
6
|
+
* Two levels, chosen per request:
|
|
7
|
+
*
|
|
8
|
+
* - **An OpenTelemetry context is active** — a browser SDK has a span open, or
|
|
9
|
+
* this runs on a server (a Next.js server component, an API calling another
|
|
10
|
+
* API) inside a request span. The globally registered propagator writes the
|
|
11
|
+
* headers, so the current span is the parent: `traceparent`, `tracestate`,
|
|
12
|
+
* and whatever else that propagator carries.
|
|
13
|
+
* - **Otherwise** (level 1): one trace id per page view — per page load in a
|
|
14
|
+
* browser, per client in Node — a fresh span id per request, and a sampled
|
|
15
|
+
* flag decided once per page view from {@link ClientTelemetryOptions.sampleRate}.
|
|
16
|
+
*
|
|
17
|
+
* Nothing is sent to any origin but the API's own: a trace id is an identifier,
|
|
18
|
+
* and a third party has no business correlating a user's requests by it. And
|
|
19
|
+
* nothing at all where a `fetch` instrumentation is listening (a server with
|
|
20
|
+
* OpenTelemetry's undici instrumentation): it writes the request's own
|
|
21
|
+
* context, and two `traceparent` headers would be read as none.
|
|
22
|
+
*
|
|
23
|
+
* `@opentelemetry/api` is not imported. Every copy of it — whichever version
|
|
24
|
+
* an app bundles — registers its globals on `globalThis` under
|
|
25
|
+
* `Symbol.for('opentelemetry.js.api.1')`, which is how two copies in one page
|
|
26
|
+
* already share a provider. Reading the propagator and context manager from
|
|
27
|
+
* there costs a browser bundle nothing when no SDK is loaded, and still finds
|
|
28
|
+
* the SDK when one is.
|
|
29
|
+
*/
|
|
30
|
+
/** Telemetry on a client: `true` for the defaults, or these options. */
|
|
31
|
+
interface ClientTelemetryOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The fraction of page views whose requests are sampled, from 0 to 1, when
|
|
34
|
+
* no OpenTelemetry context is active. Decided once per page view, so a
|
|
35
|
+
* page's requests are all kept or all dropped together.
|
|
36
|
+
*
|
|
37
|
+
* Use the stage's rate. The API caps an incoming sampled flag at its own
|
|
38
|
+
* rate anyway, and decides from the trace id the same way this does, so a
|
|
39
|
+
* page view sampled here at the API's rate is sampled there too.
|
|
40
|
+
* @default 1
|
|
41
|
+
*/
|
|
42
|
+
sampleRate?: number;
|
|
43
|
+
}
|
|
44
|
+
/** A `sampleRate` outside 0–1, which no sampler can honour. */
|
|
45
|
+
declare class InvalidClientSampleRate extends Error {
|
|
46
|
+
readonly sampleRate: number;
|
|
47
|
+
constructor(sampleRate: number);
|
|
48
|
+
}
|
|
49
|
+
/** Adds trace headers to a request to `url`, when it is the API's own. */
|
|
50
|
+
type TraceContextInjector = (url: string, headers: Record<string, string>) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a trace is sampled at `rate`, from its id.
|
|
53
|
+
*
|
|
54
|
+
* The same rule as OpenTelemetry's `TraceIdRatioBasedSampler`: the id's four
|
|
55
|
+
* 32-bit words XORed together, under `rate` of the 32-bit range. The trace id
|
|
56
|
+
* is random, so this samples `rate` of page views — and the API, applying the
|
|
57
|
+
* same rule to the same id at the same rate, keeps exactly the page views kept
|
|
58
|
+
* here rather than a random `rate` of them.
|
|
59
|
+
*/
|
|
60
|
+
declare function sampledAt(traceId: string, rate: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* An injector for a client whose API is at `baseURL`, or undefined when
|
|
63
|
+
* telemetry is off.
|
|
64
|
+
*/
|
|
65
|
+
declare function traceContextInjector(baseURL: string, telemetry: boolean | ClientTelemetryOptions | undefined): TraceContextInjector | undefined;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { traceContextInjector as a, sampledAt as i, InvalidClientSampleRate as n, TraceContextInjector as r, ClientTelemetryOptions as t };
|
|
68
|
+
//# sourceMappingURL=telemetry-g3BE86Wd.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-g3BE86Wd.d.cts","names":[],"sources":["../src/telemetry.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BiB;;;;;;;;;;;EAWhB;;;cAIY,gCAAgC;WACvB;EAArB,YAAqB;;;KASV,wBACX,aACA,SAAS;;;;;;;;;;iBAiEM,UAAU,iBAAiB;;;;;iBA6E3B,qBACf,iBACA,qBAAqB,qCACnB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/telemetry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* W3C trace context on the requests a client makes to its own API, so a user
|
|
4
|
+
* action in the browser and the API request it causes are one trace.
|
|
5
|
+
*
|
|
6
|
+
* Two levels, chosen per request:
|
|
7
|
+
*
|
|
8
|
+
* - **An OpenTelemetry context is active** — a browser SDK has a span open, or
|
|
9
|
+
* this runs on a server (a Next.js server component, an API calling another
|
|
10
|
+
* API) inside a request span. The globally registered propagator writes the
|
|
11
|
+
* headers, so the current span is the parent: `traceparent`, `tracestate`,
|
|
12
|
+
* and whatever else that propagator carries.
|
|
13
|
+
* - **Otherwise** (level 1): one trace id per page view — per page load in a
|
|
14
|
+
* browser, per client in Node — a fresh span id per request, and a sampled
|
|
15
|
+
* flag decided once per page view from {@link ClientTelemetryOptions.sampleRate}.
|
|
16
|
+
*
|
|
17
|
+
* Nothing is sent to any origin but the API's own: a trace id is an identifier,
|
|
18
|
+
* and a third party has no business correlating a user's requests by it. And
|
|
19
|
+
* nothing at all where a `fetch` instrumentation is listening (a server with
|
|
20
|
+
* OpenTelemetry's undici instrumentation): it writes the request's own
|
|
21
|
+
* context, and two `traceparent` headers would be read as none.
|
|
22
|
+
*
|
|
23
|
+
* `@opentelemetry/api` is not imported. Every copy of it — whichever version
|
|
24
|
+
* an app bundles — registers its globals on `globalThis` under
|
|
25
|
+
* `Symbol.for('opentelemetry.js.api.1')`, which is how two copies in one page
|
|
26
|
+
* already share a provider. Reading the propagator and context manager from
|
|
27
|
+
* there costs a browser bundle nothing when no SDK is loaded, and still finds
|
|
28
|
+
* the SDK when one is.
|
|
29
|
+
*/
|
|
30
|
+
/** Telemetry on a client: `true` for the defaults, or these options. */
|
|
31
|
+
interface ClientTelemetryOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The fraction of page views whose requests are sampled, from 0 to 1, when
|
|
34
|
+
* no OpenTelemetry context is active. Decided once per page view, so a
|
|
35
|
+
* page's requests are all kept or all dropped together.
|
|
36
|
+
*
|
|
37
|
+
* Use the stage's rate. The API caps an incoming sampled flag at its own
|
|
38
|
+
* rate anyway, and decides from the trace id the same way this does, so a
|
|
39
|
+
* page view sampled here at the API's rate is sampled there too.
|
|
40
|
+
* @default 1
|
|
41
|
+
*/
|
|
42
|
+
sampleRate?: number;
|
|
43
|
+
}
|
|
44
|
+
/** A `sampleRate` outside 0–1, which no sampler can honour. */
|
|
45
|
+
declare class InvalidClientSampleRate extends Error {
|
|
46
|
+
readonly sampleRate: number;
|
|
47
|
+
constructor(sampleRate: number);
|
|
48
|
+
}
|
|
49
|
+
/** Adds trace headers to a request to `url`, when it is the API's own. */
|
|
50
|
+
type TraceContextInjector = (url: string, headers: Record<string, string>) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a trace is sampled at `rate`, from its id.
|
|
53
|
+
*
|
|
54
|
+
* The same rule as OpenTelemetry's `TraceIdRatioBasedSampler`: the id's four
|
|
55
|
+
* 32-bit words XORed together, under `rate` of the 32-bit range. The trace id
|
|
56
|
+
* is random, so this samples `rate` of page views — and the API, applying the
|
|
57
|
+
* same rule to the same id at the same rate, keeps exactly the page views kept
|
|
58
|
+
* here rather than a random `rate` of them.
|
|
59
|
+
*/
|
|
60
|
+
declare function sampledAt(traceId: string, rate: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* An injector for a client whose API is at `baseURL`, or undefined when
|
|
63
|
+
* telemetry is off.
|
|
64
|
+
*/
|
|
65
|
+
declare function traceContextInjector(baseURL: string, telemetry: boolean | ClientTelemetryOptions | undefined): TraceContextInjector | undefined;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { traceContextInjector as a, sampledAt as i, InvalidClientSampleRate as n, TraceContextInjector as r, ClientTelemetryOptions as t };
|
|
68
|
+
//# sourceMappingURL=telemetry-g3BE86Wd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-g3BE86Wd.d.mts","names":[],"sources":["../src/telemetry.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BiB;;;;;;;;;;;EAWhB;;;cAIY,gCAAgC;WACvB;EAArB,YAAqB;;;KASV,wBACX,aACA,SAAS;;;;;;;;;;iBAiEM,UAAU,iBAAiB;;;;;iBA6E3B,qBACf,iBACA,qBAAqB,qCACnB"}
|