mobx-tanstack-query-api 0.0.19 → 0.0.20
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/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/query-core';
|
|
2
2
|
import { MobxMutation, MobxMutationConfig } from 'mobx-tanstack-query';
|
|
3
|
-
import { AllPropertiesOptional, AnyObject } from 'yummies/utils/types';
|
|
3
|
+
import { AllPropertiesOptional, AnyObject, Unpromise } from 'yummies/utils/types';
|
|
4
4
|
import { AnyEndpoint, InferEndpointError, InferEndpointInput, InferEndpointResponse } from './endpoint.types.js';
|
|
5
5
|
export type EndpointMutationInput<TBaseInput extends AnyObject, TMutationMeta extends AnyObject | void = void> = TBaseInput & (TMutationMeta extends void ? {} : AllPropertiesOptional<TMutationMeta> extends true ? {
|
|
6
6
|
meta?: TMutationMeta;
|
|
7
7
|
} : {
|
|
8
8
|
meta: TMutationMeta;
|
|
9
9
|
});
|
|
10
|
-
export interface EndpointMutationOptions<TEndpoint extends AnyEndpoint, TMutationMeta extends AnyObject | void = void> extends Omit<MobxMutationConfig<InferEndpointResponse<TEndpoint
|
|
10
|
+
export interface EndpointMutationOptions<TEndpoint extends AnyEndpoint, TMutationMeta extends AnyObject | void = void> extends Omit<MobxMutationConfig<Unpromise<InferEndpointResponse<TEndpoint>>, EndpointMutationInput<InferEndpointInput<TEndpoint>, TMutationMeta>, InferEndpointError<TEndpoint>>, 'queryClient' | 'mutationFn'> {
|
|
11
11
|
}
|
|
12
|
-
export declare class EndpointMutation<TEndpoint extends AnyEndpoint, TMutationMeta extends AnyObject | void = void> extends MobxMutation<InferEndpointResponse<TEndpoint
|
|
12
|
+
export declare class EndpointMutation<TEndpoint extends AnyEndpoint, TMutationMeta extends AnyObject | void = void> extends MobxMutation<Unpromise<InferEndpointResponse<TEndpoint>>, EndpointMutationInput<InferEndpointInput<TEndpoint>, TMutationMeta>> {
|
|
13
13
|
private endpoint;
|
|
14
14
|
constructor(endpoint: TEndpoint, queryClient: QueryClient, options: EndpointMutationOptions<TEndpoint, TMutationMeta>);
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-mutation.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"endpoint-mutation.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,SAAS,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,qBAAqB,CAC/B,UAAU,SAAS,SAAS,EAC5B,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,IAC3C,UAAU,GACZ,CAAC,aAAa,SAAS,IAAI,GAEvB,EAAE,GACF,qBAAqB,CAAC,aAAa,CAAC,SAAS,IAAI,GAC/C;IAAE,IAAI,CAAC,EAAE,aAAa,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AAEjC,MAAM,WAAW,uBAAuB,CACtC,SAAS,SAAS,WAAW,EAC7B,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,CAC7C,SAAQ,IAAI,CACV,kBAAkB,CAChB,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAC3C,qBAAqB,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,EACnE,kBAAkB,CAAC,SAAS,CAAC,CAC9B,EACD,aAAa,GAAG,YAAY,CAC7B;CAAG;AAEN,qBAAa,gBAAgB,CAC3B,SAAS,SAAS,WAAW,EAC7B,aAAa,SAAS,SAAS,GAAG,IAAI,GAAG,IAAI,CAC7C,SAAQ,YAAY,CACpB,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAC3C,qBAAqB,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,CACpE;IAEG,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,SAAS,EAC3B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,uBAAuB,CAAC,SAAS,EAAE,aAAa,CAAC;CAe7D"}
|
|
@@ -7,8 +7,9 @@ export class EndpointMutation extends MobxMutation {
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
8
|
// @ts-expect-error
|
|
9
9
|
queryClient,
|
|
10
|
-
mutationFn: (input) => {
|
|
11
|
-
|
|
10
|
+
mutationFn: async (input) => {
|
|
11
|
+
const response = (await endpoint.request(...endpoint.getParamsFromInput(input)));
|
|
12
|
+
return response;
|
|
12
13
|
},
|
|
13
14
|
});
|
|
14
15
|
this.endpoint = endpoint;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { QueryClient, QueryFunctionContext } from '@tanstack/query-core';
|
|
2
2
|
import { MobxQuery, MobxQueryConfig, MobxQueryDynamicOptions } from 'mobx-tanstack-query';
|
|
3
|
-
import { MaybeFalsy } from 'yummies/utils/types';
|
|
3
|
+
import { MaybeFalsy, Unpromise } from 'yummies/utils/types';
|
|
4
4
|
import { AnyEndpoint, InferEndpointError, InferEndpointInput, InferEndpointResponse } from './endpoint.types.js';
|
|
5
|
-
export interface EndpointQueryOptions<TEndpoint extends AnyEndpoint> extends Omit<MobxQueryConfig<InferEndpointResponse<TEndpoint
|
|
5
|
+
export interface EndpointQueryOptions<TEndpoint extends AnyEndpoint> extends Omit<MobxQueryConfig<Unpromise<InferEndpointResponse<TEndpoint>>, InferEndpointError<TEndpoint>>, 'options' | 'queryFn' | 'queryClient'> {
|
|
6
6
|
input: () => MaybeFalsy<InferEndpointInput<TEndpoint>>;
|
|
7
7
|
}
|
|
8
|
-
export declare class EndpointQuery<TEndpoint extends AnyEndpoint> extends MobxQuery<InferEndpointResponse<TEndpoint
|
|
8
|
+
export declare class EndpointQuery<TEndpoint extends AnyEndpoint> extends MobxQuery<Unpromise<InferEndpointResponse<TEndpoint>>, InferEndpointError<TEndpoint>> {
|
|
9
9
|
private endpoint;
|
|
10
10
|
constructor(endpoint: TEndpoint, queryClient: QueryClient, { input: getInput, ...queryOptions }: EndpointQueryOptions<TEndpoint>);
|
|
11
|
-
setInput(input: MaybeFalsy<InferEndpointInput<TEndpoint>>): Promise<InferEndpointResponse<TEndpoint
|
|
12
|
-
protected buildOptionsFromInput(input: MaybeFalsy<InferEndpointInput<TEndpoint>>): MobxQueryDynamicOptions<InferEndpointResponse<TEndpoint
|
|
11
|
+
setInput(input: MaybeFalsy<InferEndpointInput<TEndpoint>>): Promise<Unpromise<InferEndpointResponse<TEndpoint>>>;
|
|
12
|
+
protected buildOptionsFromInput(input: MaybeFalsy<InferEndpointInput<TEndpoint>>): MobxQueryDynamicOptions<Unpromise<InferEndpointResponse<TEndpoint>>, InferEndpointError<TEndpoint>>;
|
|
13
13
|
protected buildParamsFromContext(ctx: QueryFunctionContext<any, any>): any;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=endpoint-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-query.d.ts","sourceRoot":"","sources":["../../src/runtime/endpoint-query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EACL,SAAS,EACT,eAA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