@trpc/client 10.27.3 → 10.28.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/dist/TRPCClientError.d.ts +25 -25
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/createTRPCClient.d.ts +19 -19
- package/dist/createTRPCClientProxy.d.ts +38 -38
- package/dist/createTRPCClientProxy.d.ts.map +1 -1
- package/dist/createTRPCUntypedClient.d.ts +4 -4
- package/dist/getFetch.d.ts +2 -2
- package/dist/{httpUtils-1a07b2e6.js → httpUtils-00c8b54e.js} +125 -125
- package/dist/index.d.ts +6 -6
- package/dist/internals/TRPCUntypedClient.d.ts +61 -61
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/internals/dataLoader.d.ts +17 -17
- package/dist/internals/dataLoader.d.ts.map +1 -1
- package/dist/internals/getAbortController.d.ts +3 -3
- package/dist/internals/retryDelay.d.ts +1 -1
- package/dist/internals/types.d.ts +75 -102
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/links/dedupeLink.d.ts +3 -3
- package/dist/links/httpBatchLink.d.ts +15 -15
- package/dist/links/httpFormDataLink.d.ts +1 -1
- package/dist/links/httpLink.d.ts +16 -16
- package/dist/links/index.d.ts +7 -7
- package/dist/links/internals/createChain.d.ts +7 -7
- package/dist/links/internals/httpUtils.d.ts +59 -59
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/isObject.d.ts +1 -1
- package/dist/links/loggerLink.d.ts +39 -39
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/retryLink.d.ts +5 -5
- package/dist/links/splitLink.d.ts +13 -13
- package/dist/links/types.d.ts +69 -69
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink.d.ts +28 -28
- package/dist/links/wsLink.d.ts.map +1 -1
- package/dist/links/wsLink.js +9 -17
- package/dist/links/wsLink.mjs +9 -17
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/transformResult.d.ts +33 -33
- package/dist/{splitLink-aebd28df.js → splitLink-0df96fdc.js} +34 -34
- package/dist/{transformResult-fc4863b8.js → transformResult-ae8e970c.js} +80 -80
- package/package.json +11 -7
- package/src/internals/types.ts +0 -39
- package/src/links/wsLink.ts +10 -24
- package/src/internals/types.test.ts +0 -66
- package/src/links/dedupeLink.test.ts +0 -128
- package/src/links/internals/createChain.test.ts +0 -117
- package/src/links/splitLink.test.ts +0 -55
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { AnyProcedure, AnyRouter, DefaultErrorShape, Maybe, inferRouterError } from '@trpc/server';
|
|
2
|
-
import { TRPCErrorResponse, TRPCErrorShape } from '@trpc/server/rpc';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
|
6
|
-
readonly message: string;
|
|
7
|
-
readonly shape: Maybe<TShape>;
|
|
8
|
-
readonly data: Maybe<TShape['data']>;
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
export declare class TRPCClientError<TRouterOrProcedure extends ErrorInferrable> extends Error implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>> {
|
|
12
|
-
readonly cause: Error | undefined;
|
|
13
|
-
readonly shape: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
|
14
|
-
readonly data: Maybe<inferErrorShape<TRouterOrProcedure>['data']>;
|
|
15
|
-
readonly meta: Record<string, unknown> | undefined;
|
|
16
|
-
constructor(message: string, opts?: {
|
|
17
|
-
result?: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
|
18
|
-
cause?: Error;
|
|
19
|
-
meta?: Record<string, unknown>;
|
|
20
|
-
});
|
|
21
|
-
static from<TRouterOrProcedure extends ErrorInferrable>(cause: Error | TRPCErrorResponse<any>, opts?: {
|
|
22
|
-
meta?: Record<string, unknown>;
|
|
23
|
-
}): TRPCClientError<TRouterOrProcedure>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
1
|
+
import { AnyProcedure, AnyRouter, DefaultErrorShape, Maybe, inferRouterError } from '@trpc/server';
|
|
2
|
+
import { TRPCErrorResponse, TRPCErrorShape } from '@trpc/server/rpc';
|
|
3
|
+
type ErrorInferrable = AnyRouter | AnyProcedure | TRPCErrorShape<number>;
|
|
4
|
+
type inferErrorShape<TInferrable extends ErrorInferrable> = TInferrable extends AnyRouter ? inferRouterError<TInferrable> : TInferrable extends AnyProcedure ? TInferrable['_def']['_config']['$types']['errorShape'] : TInferrable;
|
|
5
|
+
export interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly shape: Maybe<TShape>;
|
|
8
|
+
readonly data: Maybe<TShape['data']>;
|
|
9
|
+
}
|
|
10
|
+
export type TRPCClientErrorLike<TRouterOrProcedure extends ErrorInferrable> = TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>>;
|
|
11
|
+
export declare class TRPCClientError<TRouterOrProcedure extends ErrorInferrable> extends Error implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>> {
|
|
12
|
+
readonly cause: Error | undefined;
|
|
13
|
+
readonly shape: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
|
14
|
+
readonly data: Maybe<inferErrorShape<TRouterOrProcedure>['data']>;
|
|
15
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
16
|
+
constructor(message: string, opts?: {
|
|
17
|
+
result?: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
|
18
|
+
cause?: Error;
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
|
+
});
|
|
21
|
+
static from<TRouterOrProcedure extends ErrorInferrable>(cause: Error | TRPCErrorResponse<any>, opts?: {
|
|
22
|
+
meta?: Record<string, unknown>;
|
|
23
|
+
}): TRPCClientError<TRouterOrProcedure>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
26
|
//# sourceMappingURL=TRPCClientError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,
|
|
1
|
+
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAErE,KAAK,eAAe,GAAG,SAAS,GAAG,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAEzE,KAAK,eAAe,CAAC,WAAW,SAAS,eAAe,IACtD,WAAW,SAAS,SAAS,GACzB,gBAAgB,CAAC,WAAW,CAAC,GAC7B,WAAW,SAAS,YAAY,GAChC,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,GACtD,WAAW,CAAC;AAElB,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,iBAAiB;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;CACtC;AACD,MAAM,MAAM,mBAAmB,CAAC,kBAAkB,SAAS,eAAe,IACxE,mBAAmB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAE3D,qBAAa,eAAe,CAAC,kBAAkB,SAAS,eAAe,CACrE,SAAQ,KACR,YAAW,mBAAmB,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAEnE,SAAgB,KAAK,oBAAC;IACtB,SAAgB,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAClE,SAAgB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,SAAgB,IAAI,sCAAC;gBAGnB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpD,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC;WAkBW,IAAI,CAAC,kBAAkB,SAAS,eAAe,EAC3D,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,EACrC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAO,GAC5C,eAAe,CAAC,kBAAkB,CAAC;CAqBvC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { AnyRouter, inferProcedureInput, inferProcedureOutput, inferSubscriptionOutput } from '@trpc/server';
|
|
2
|
-
import { Unsubscribable } from '@trpc/server/observable';
|
|
3
|
-
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
4
|
-
import { TRPCClientError } from './TRPCClientError';
|
|
5
|
-
import { CreateTRPCClientOptions, TRPCRequestOptions, TRPCSubscriptionObserver } from './internals/TRPCUntypedClient';
|
|
6
|
-
import { TRPCClientRuntime } from './links';
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
export interface TRPCClient<TRouter extends AnyRouter> {
|
|
11
|
-
readonly runtime: TRPCClientRuntime;
|
|
12
|
-
query<TQueries extends TRouter['_def']['queries'], TPath extends string & keyof TQueries, TInput extends inferProcedureInput<TQueries[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferProcedureOutput<TQueries[TPath]>>;
|
|
13
|
-
mutation<TMutations extends TRouter['_def']['mutations'], TPath extends string & keyof TMutations, TInput extends inferProcedureInput<TMutations[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferTransformedProcedureOutput<TMutations[TPath]>>;
|
|
14
|
-
subscription<TSubscriptions extends TRouter['_def']['subscriptions'], TPath extends string & keyof TSubscriptions, TOutput extends inferSubscriptionOutput<TRouter, TPath>, TInput extends inferProcedureInput<TSubscriptions[TPath]>>(path: TPath, input: TInput, opts: TRPCRequestOptions & Partial<TRPCSubscriptionObserver<TOutput, TRPCClientError<TRouter>>>): Unsubscribable;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated use `createTRPCProxyClient` instead
|
|
18
|
-
*/
|
|
19
|
-
export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
|
|
1
|
+
import type { AnyRouter, inferProcedureInput, inferProcedureOutput, inferSubscriptionOutput } from '@trpc/server';
|
|
2
|
+
import { Unsubscribable } from '@trpc/server/observable';
|
|
3
|
+
import { inferTransformedProcedureOutput } from '@trpc/server/shared';
|
|
4
|
+
import { TRPCClientError } from './TRPCClientError';
|
|
5
|
+
import { CreateTRPCClientOptions, TRPCRequestOptions, TRPCSubscriptionObserver } from './internals/TRPCUntypedClient';
|
|
6
|
+
import { TRPCClientRuntime } from './links';
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
export interface TRPCClient<TRouter extends AnyRouter> {
|
|
11
|
+
readonly runtime: TRPCClientRuntime;
|
|
12
|
+
query<TQueries extends TRouter['_def']['queries'], TPath extends string & keyof TQueries, TInput extends inferProcedureInput<TQueries[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferProcedureOutput<TQueries[TPath]>>;
|
|
13
|
+
mutation<TMutations extends TRouter['_def']['mutations'], TPath extends string & keyof TMutations, TInput extends inferProcedureInput<TMutations[TPath]>>(path: TPath, input?: TInput, opts?: TRPCRequestOptions): Promise<inferTransformedProcedureOutput<TMutations[TPath]>>;
|
|
14
|
+
subscription<TSubscriptions extends TRouter['_def']['subscriptions'], TPath extends string & keyof TSubscriptions, TOutput extends inferSubscriptionOutput<TRouter, TPath>, TInput extends inferProcedureInput<TSubscriptions[TPath]>>(path: TPath, input: TInput, opts: TRPCRequestOptions & Partial<TRPCSubscriptionObserver<TOutput, TRPCClientError<TRouter>>>): Unsubscribable;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use `createTRPCProxyClient` instead
|
|
18
|
+
*/
|
|
19
|
+
export declare function createTRPCClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCClient<TRouter>;
|
|
20
20
|
//# sourceMappingURL=createTRPCClient.d.ts.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, IntersectionError, ProcedureArgs, ProcedureRouterRecord, ProcedureType } from '@trpc/server';
|
|
2
|
-
import type { Unsubscribable } from '@trpc/server/observable';
|
|
3
|
-
import { inferTransformedProcedureOutput, inferTransformedSubscriptionOutput } from '@trpc/server/shared';
|
|
4
|
-
import { TRPCClientError } from './TRPCClientError';
|
|
5
|
-
import { TRPCClient } from './createTRPCClient';
|
|
6
|
-
import { CreateTRPCClientOptions } from './createTRPCUntypedClient';
|
|
7
|
-
import { TRPCSubscriptionObserver, UntypedClientProperties } from './internals/TRPCUntypedClient';
|
|
8
|
-
/** @public */
|
|
9
|
-
export
|
|
10
|
-
/** @internal */
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
input: ProcedureArgs<TProcedure['_def']>[0],
|
|
14
|
-
opts: ProcedureArgs<TProcedure['_def']>[1] & Partial<TRPCSubscriptionObserver<inferTransformedSubscriptionOutput<TProcedure>, TRPCClientError<TProcedure>>>
|
|
15
|
-
]) => Unsubscribable;
|
|
16
|
-
|
|
17
|
-
query: Resolver<TProcedure>;
|
|
18
|
-
} : TProcedure extends AnyMutationProcedure ? {
|
|
19
|
-
mutate: Resolver<TProcedure>;
|
|
20
|
-
} : TProcedure extends AnySubscriptionProcedure ? {
|
|
21
|
-
subscribe: SubscriptionResolver<TProcedure>;
|
|
22
|
-
} : never;
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey]> : never;
|
|
28
|
-
};
|
|
29
|
-
/** @internal */
|
|
30
|
-
export declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
|
|
31
|
-
export
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated use `createTRPCProxyClient` instead
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCClient<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
37
|
-
export declare function createTRPCProxyClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
38
|
-
export {};
|
|
1
|
+
import type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnyRouter, AnySubscriptionProcedure, IntersectionError, ProcedureArgs, ProcedureRouterRecord, ProcedureType } from '@trpc/server';
|
|
2
|
+
import type { Unsubscribable } from '@trpc/server/observable';
|
|
3
|
+
import { inferTransformedProcedureOutput, inferTransformedSubscriptionOutput } from '@trpc/server/shared';
|
|
4
|
+
import { TRPCClientError } from './TRPCClientError';
|
|
5
|
+
import { TRPCClient } from './createTRPCClient';
|
|
6
|
+
import { CreateTRPCClientOptions } from './createTRPCUntypedClient';
|
|
7
|
+
import { TRPCSubscriptionObserver, UntypedClientProperties } from './internals/TRPCUntypedClient';
|
|
8
|
+
/** @public */
|
|
9
|
+
export type inferRouterProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record']>;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export type Resolver<TProcedure extends AnyProcedure> = (...args: ProcedureArgs<TProcedure['_def']>) => Promise<inferTransformedProcedureOutput<TProcedure>>;
|
|
12
|
+
type SubscriptionResolver<TProcedure extends AnyProcedure> = (...args: [
|
|
13
|
+
input: ProcedureArgs<TProcedure['_def']>[0],
|
|
14
|
+
opts: ProcedureArgs<TProcedure['_def']>[1] & Partial<TRPCSubscriptionObserver<inferTransformedSubscriptionOutput<TProcedure>, TRPCClientError<TProcedure>>>
|
|
15
|
+
]) => Unsubscribable;
|
|
16
|
+
type DecorateProcedure<TProcedure extends AnyProcedure> = TProcedure extends AnyQueryProcedure ? {
|
|
17
|
+
query: Resolver<TProcedure>;
|
|
18
|
+
} : TProcedure extends AnyMutationProcedure ? {
|
|
19
|
+
mutate: Resolver<TProcedure>;
|
|
20
|
+
} : TProcedure extends AnySubscriptionProcedure ? {
|
|
21
|
+
subscribe: SubscriptionResolver<TProcedure>;
|
|
22
|
+
} : never;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
|
|
27
|
+
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey]> : never;
|
|
28
|
+
};
|
|
29
|
+
/** @internal */
|
|
30
|
+
export declare const clientCallTypeToProcedureType: (clientCallType: string) => ProcedureType;
|
|
31
|
+
export type CreateTRPCProxyClient<TRouter extends AnyRouter> = DecoratedProcedureRecord<TRouter['_def']['record']> extends infer TProcedureRecord ? UntypedClientProperties & keyof TProcedureRecord extends never ? TProcedureRecord : IntersectionError<UntypedClientProperties & keyof TProcedureRecord> : never;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated use `createTRPCProxyClient` instead
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function createTRPCClientProxy<TRouter extends AnyRouter>(client: TRPCClient<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
37
|
+
export declare function createTRPCProxyClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): CreateTRPCProxyClient<TRouter>;
|
|
38
|
+
export {};
|
|
39
39
|
//# sourceMappingURL=createTRPCClientProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTRPCClientProxy.d.ts","sourceRoot":"","sources":["../src/createTRPCClientProxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAGL,+BAA+B,EAC/B,kCAAkC,EACnC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EACL,wBAAwB,EAExB,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AAEvC,cAAc;AACd,
|
|
1
|
+
{"version":3,"file":"createTRPCClientProxy.d.ts","sourceRoot":"","sources":["../src/createTRPCClientProxy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,Y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
-
import { CreateTRPCClientOptions, TRPCUntypedClient } from './internals/TRPCUntypedClient';
|
|
3
|
-
export declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<AnyRouter>;
|
|
4
|
-
export type { CreateTRPCClientOptions, TRPCRequestOptions, TRPCUntypedClient, } from './internals/TRPCUntypedClient';
|
|
1
|
+
import { AnyRouter } from '@trpc/server';
|
|
2
|
+
import { CreateTRPCClientOptions, TRPCUntypedClient } from './internals/TRPCUntypedClient';
|
|
3
|
+
export declare function createTRPCUntypedClient<TRouter extends AnyRouter>(opts: CreateTRPCClientOptions<TRouter>): TRPCUntypedClient<AnyRouter>;
|
|
4
|
+
export type { CreateTRPCClientOptions, TRPCRequestOptions, TRPCUntypedClient, } from './internals/TRPCUntypedClient';
|
|
5
5
|
//# sourceMappingURL=createTRPCUntypedClient.d.ts.map
|
package/dist/getFetch.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FetchEsque, NativeFetchEsque } from './internals/types';
|
|
2
|
-
export declare function getFetch(customFetchImpl?: FetchEsque | NativeFetchEsque): FetchEsque;
|
|
1
|
+
import { FetchEsque, NativeFetchEsque } from './internals/types';
|
|
2
|
+
export declare function getFetch(customFetchImpl?: FetchEsque | NativeFetchEsque): FetchEsque;
|
|
3
3
|
//# sourceMappingURL=getFetch.d.ts.map
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
const isFunction = (fn) => typeof fn === 'function';
|
|
2
|
-
function _bind(fn, thisArg) {
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
4
|
-
return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
|
|
5
|
-
}
|
|
6
|
-
function getFetch(customFetchImpl) {
|
|
7
|
-
if (customFetchImpl) {
|
|
8
|
-
return customFetchImpl;
|
|
9
|
-
}
|
|
10
|
-
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
11
|
-
return _bind(window.fetch, window);
|
|
12
|
-
}
|
|
13
|
-
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
14
|
-
return _bind(globalThis.fetch, globalThis);
|
|
15
|
-
}
|
|
16
|
-
throw new Error('No fetch implementation found');
|
|
1
|
+
const isFunction = (fn) => typeof fn === 'function';
|
|
2
|
+
function _bind(fn, thisArg) {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
4
|
+
return isFunction(fn.bind) ? fn.bind(thisArg) : fn;
|
|
5
|
+
}
|
|
6
|
+
function getFetch(customFetchImpl) {
|
|
7
|
+
if (customFetchImpl) {
|
|
8
|
+
return customFetchImpl;
|
|
9
|
+
}
|
|
10
|
+
if (typeof window !== 'undefined' && isFunction(window.fetch)) {
|
|
11
|
+
return _bind(window.fetch, window);
|
|
12
|
+
}
|
|
13
|
+
if (typeof globalThis !== 'undefined' && isFunction(globalThis.fetch)) {
|
|
14
|
+
return _bind(globalThis.fetch, globalThis);
|
|
15
|
+
}
|
|
16
|
+
throw new Error('No fetch implementation found');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function getAbortController(customAbortControllerImpl) {
|
|
20
|
-
if (customAbortControllerImpl) {
|
|
21
|
-
return customAbortControllerImpl;
|
|
22
|
-
}
|
|
23
|
-
if (typeof window !== 'undefined' && window.AbortController) {
|
|
24
|
-
return window.AbortController;
|
|
25
|
-
}
|
|
26
|
-
if (typeof globalThis !== 'undefined' && globalThis.AbortController) {
|
|
27
|
-
return globalThis.AbortController;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
19
|
+
function getAbortController(customAbortControllerImpl) {
|
|
20
|
+
if (customAbortControllerImpl) {
|
|
21
|
+
return customAbortControllerImpl;
|
|
22
|
+
}
|
|
23
|
+
if (typeof window !== 'undefined' && window.AbortController) {
|
|
24
|
+
return window.AbortController;
|
|
25
|
+
}
|
|
26
|
+
if (typeof globalThis !== 'undefined' && globalThis.AbortController) {
|
|
27
|
+
return globalThis.AbortController;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function resolveHTTPLinkOptions(opts) {
|
|
33
|
-
return {
|
|
34
|
-
url: opts.url,
|
|
35
|
-
fetch: getFetch(opts.fetch),
|
|
36
|
-
AbortController: getAbortController(opts.AbortController),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// https://github.com/trpc/trpc/pull/669
|
|
40
|
-
function arrayToDict(array) {
|
|
41
|
-
const dict = {};
|
|
42
|
-
for (let index = 0; index < array.length; index++) {
|
|
43
|
-
const element = array[index];
|
|
44
|
-
dict[index] = element;
|
|
45
|
-
}
|
|
46
|
-
return dict;
|
|
47
|
-
}
|
|
48
|
-
const METHOD = {
|
|
49
|
-
query: 'GET',
|
|
50
|
-
mutation: 'POST',
|
|
51
|
-
};
|
|
52
|
-
function getInput(opts) {
|
|
53
|
-
return 'input' in opts
|
|
54
|
-
? opts.runtime.transformer.serialize(opts.input)
|
|
55
|
-
: arrayToDict(opts.inputs.map((_input) => opts.runtime.transformer.serialize(_input)));
|
|
56
|
-
}
|
|
57
|
-
const getUrl = (opts) => {
|
|
58
|
-
let url = opts.url + '/' + opts.path;
|
|
59
|
-
const queryParts = [];
|
|
60
|
-
if ('inputs' in opts) {
|
|
61
|
-
queryParts.push('batch=1');
|
|
62
|
-
}
|
|
63
|
-
if (opts.type === 'query') {
|
|
64
|
-
const input = getInput(opts);
|
|
65
|
-
if (input !== undefined) {
|
|
66
|
-
queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (queryParts.length) {
|
|
70
|
-
url += '?' + queryParts.join('&');
|
|
71
|
-
}
|
|
72
|
-
return url;
|
|
73
|
-
};
|
|
74
|
-
const getBody = (opts) => {
|
|
75
|
-
if (opts.type === 'query') {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const input = getInput(opts);
|
|
79
|
-
return input !== undefined ? JSON.stringify(input) : undefined;
|
|
80
|
-
};
|
|
81
|
-
const jsonHttpRequester = (opts) => {
|
|
82
|
-
return httpRequest({
|
|
83
|
-
...opts,
|
|
84
|
-
contentTypeHeader: 'application/json',
|
|
85
|
-
getUrl,
|
|
86
|
-
getBody,
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
function httpRequest(opts) {
|
|
90
|
-
const { type } = opts;
|
|
91
|
-
const ac = opts.AbortController ? new opts.AbortController() : null;
|
|
92
|
-
const promise = new Promise((resolve, reject) => {
|
|
93
|
-
const url = opts.getUrl(opts);
|
|
94
|
-
const body = opts.getBody(opts);
|
|
95
|
-
const meta = {};
|
|
96
|
-
Promise.resolve(opts.headers())
|
|
97
|
-
.then((headers) => {
|
|
98
|
-
/* istanbul ignore if -- @preserve */
|
|
99
|
-
if (type === 'subscription') {
|
|
100
|
-
throw new Error('Subscriptions should use wsLink');
|
|
101
|
-
}
|
|
102
|
-
return opts.fetch(url, {
|
|
103
|
-
method: METHOD[type],
|
|
104
|
-
signal: ac?.signal,
|
|
105
|
-
body: body,
|
|
106
|
-
headers: {
|
|
107
|
-
...(opts.contentTypeHeader
|
|
108
|
-
? { 'content-type': opts.contentTypeHeader }
|
|
109
|
-
: {}),
|
|
110
|
-
...headers,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
})
|
|
114
|
-
.then((_res) => {
|
|
115
|
-
meta.response = _res;
|
|
116
|
-
return _res.json();
|
|
117
|
-
})
|
|
118
|
-
.then((json) => {
|
|
119
|
-
resolve({
|
|
120
|
-
json: json,
|
|
121
|
-
meta,
|
|
122
|
-
});
|
|
123
|
-
})
|
|
124
|
-
.catch(reject);
|
|
125
|
-
});
|
|
126
|
-
const cancel = () => {
|
|
127
|
-
ac?.abort();
|
|
128
|
-
};
|
|
129
|
-
return { promise, cancel };
|
|
32
|
+
function resolveHTTPLinkOptions(opts) {
|
|
33
|
+
return {
|
|
34
|
+
url: opts.url,
|
|
35
|
+
fetch: getFetch(opts.fetch),
|
|
36
|
+
AbortController: getAbortController(opts.AbortController),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// https://github.com/trpc/trpc/pull/669
|
|
40
|
+
function arrayToDict(array) {
|
|
41
|
+
const dict = {};
|
|
42
|
+
for (let index = 0; index < array.length; index++) {
|
|
43
|
+
const element = array[index];
|
|
44
|
+
dict[index] = element;
|
|
45
|
+
}
|
|
46
|
+
return dict;
|
|
47
|
+
}
|
|
48
|
+
const METHOD = {
|
|
49
|
+
query: 'GET',
|
|
50
|
+
mutation: 'POST',
|
|
51
|
+
};
|
|
52
|
+
function getInput(opts) {
|
|
53
|
+
return 'input' in opts
|
|
54
|
+
? opts.runtime.transformer.serialize(opts.input)
|
|
55
|
+
: arrayToDict(opts.inputs.map((_input) => opts.runtime.transformer.serialize(_input)));
|
|
56
|
+
}
|
|
57
|
+
const getUrl = (opts) => {
|
|
58
|
+
let url = opts.url + '/' + opts.path;
|
|
59
|
+
const queryParts = [];
|
|
60
|
+
if ('inputs' in opts) {
|
|
61
|
+
queryParts.push('batch=1');
|
|
62
|
+
}
|
|
63
|
+
if (opts.type === 'query') {
|
|
64
|
+
const input = getInput(opts);
|
|
65
|
+
if (input !== undefined) {
|
|
66
|
+
queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (queryParts.length) {
|
|
70
|
+
url += '?' + queryParts.join('&');
|
|
71
|
+
}
|
|
72
|
+
return url;
|
|
73
|
+
};
|
|
74
|
+
const getBody = (opts) => {
|
|
75
|
+
if (opts.type === 'query') {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
const input = getInput(opts);
|
|
79
|
+
return input !== undefined ? JSON.stringify(input) : undefined;
|
|
80
|
+
};
|
|
81
|
+
const jsonHttpRequester = (opts) => {
|
|
82
|
+
return httpRequest({
|
|
83
|
+
...opts,
|
|
84
|
+
contentTypeHeader: 'application/json',
|
|
85
|
+
getUrl,
|
|
86
|
+
getBody,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
function httpRequest(opts) {
|
|
90
|
+
const { type } = opts;
|
|
91
|
+
const ac = opts.AbortController ? new opts.AbortController() : null;
|
|
92
|
+
const promise = new Promise((resolve, reject) => {
|
|
93
|
+
const url = opts.getUrl(opts);
|
|
94
|
+
const body = opts.getBody(opts);
|
|
95
|
+
const meta = {};
|
|
96
|
+
Promise.resolve(opts.headers())
|
|
97
|
+
.then((headers) => {
|
|
98
|
+
/* istanbul ignore if -- @preserve */
|
|
99
|
+
if (type === 'subscription') {
|
|
100
|
+
throw new Error('Subscriptions should use wsLink');
|
|
101
|
+
}
|
|
102
|
+
return opts.fetch(url, {
|
|
103
|
+
method: METHOD[type],
|
|
104
|
+
signal: ac?.signal,
|
|
105
|
+
body: body,
|
|
106
|
+
headers: {
|
|
107
|
+
...(opts.contentTypeHeader
|
|
108
|
+
? { 'content-type': opts.contentTypeHeader }
|
|
109
|
+
: {}),
|
|
110
|
+
...headers,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
})
|
|
114
|
+
.then((_res) => {
|
|
115
|
+
meta.response = _res;
|
|
116
|
+
return _res.json();
|
|
117
|
+
})
|
|
118
|
+
.then((json) => {
|
|
119
|
+
resolve({
|
|
120
|
+
json: json,
|
|
121
|
+
meta,
|
|
122
|
+
});
|
|
123
|
+
})
|
|
124
|
+
.catch(reject);
|
|
125
|
+
});
|
|
126
|
+
const cancel = () => {
|
|
127
|
+
ac?.abort();
|
|
128
|
+
};
|
|
129
|
+
return { promise, cancel };
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
export { getUrl as a, getFetch as g, httpRequest as h, jsonHttpRequester as j, resolveHTTPLinkOptions as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './createTRPCUntypedClient';
|
|
2
|
-
export * from './createTRPCClient';
|
|
3
|
-
export * from './createTRPCClientProxy';
|
|
4
|
-
export * from './getFetch';
|
|
5
|
-
export * from './TRPCClientError';
|
|
6
|
-
export * from './links';
|
|
1
|
+
export * from './createTRPCUntypedClient';
|
|
2
|
+
export * from './createTRPCClient';
|
|
3
|
+
export * from './createTRPCClientProxy';
|
|
4
|
+
export * from './getFetch';
|
|
5
|
+
export * from './TRPCClientError';
|
|
6
|
+
export * from './links';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { AnyRouter, ClientDataTransformerOptions, CombinedDataTransformer, DataTransformerOptions, DefaultDataTransformer } from '@trpc/server';
|
|
2
|
-
import { Unsubscribable } from '@trpc/server/observable';
|
|
3
|
-
import { TRPCClientError } from '../TRPCClientError';
|
|
4
|
-
import { OperationContext, TRPCClientRuntime, TRPCLink } from '../links/types';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Data transformer
|
|
8
|
-
*
|
|
9
|
-
* You must use the same transformer on the backend and frontend
|
|
10
|
-
* @link https://trpc.io/docs/data-transformers
|
|
11
|
-
**/
|
|
12
|
-
transformer?: 'You must set a transformer on the backend router';
|
|
13
|
-
} : TRouter['_def']['_config']['transformer'] extends DataTransformerOptions ? {
|
|
14
|
-
/**
|
|
15
|
-
* Data transformer
|
|
16
|
-
*
|
|
17
|
-
* You must use the same transformer on the backend and frontend
|
|
18
|
-
* @link https://trpc.io/docs/data-transformers
|
|
19
|
-
**/
|
|
20
|
-
transformer: TRouter['_def']['_config']['transformer'] extends CombinedDataTransformer ? DataTransformerOptions : TRouter['_def']['_config']['transformer'];
|
|
21
|
-
} : {
|
|
22
|
-
/**
|
|
23
|
-
* Data transformer
|
|
24
|
-
*
|
|
25
|
-
* You must use the same transformer on the backend and frontend
|
|
26
|
-
* @link https://trpc.io/docs/data-transformers
|
|
27
|
-
**/
|
|
28
|
-
transformer?: /** @deprecated **/ ClientDataTransformerOptions | CombinedDataTransformer;
|
|
29
|
-
};
|
|
30
|
-
export interface TRPCRequestOptions {
|
|
31
|
-
/**
|
|
32
|
-
* Pass additional context to links
|
|
33
|
-
*/
|
|
34
|
-
context?: OperationContext;
|
|
35
|
-
signal?: AbortSignal;
|
|
36
|
-
}
|
|
37
|
-
export interface TRPCSubscriptionObserver<TValue, TError> {
|
|
38
|
-
onStarted: () => void;
|
|
39
|
-
onData: (value: TValue) => void;
|
|
40
|
-
onError: (err: TError) => void;
|
|
41
|
-
onStopped: () => void;
|
|
42
|
-
onComplete: () => void;
|
|
43
|
-
}
|
|
44
|
-
/** @internal */
|
|
45
|
-
export
|
|
46
|
-
links: TRPCLink<TRouter>[];
|
|
47
|
-
};
|
|
48
|
-
/** @internal */
|
|
49
|
-
export
|
|
50
|
-
export declare class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
51
|
-
private readonly links;
|
|
52
|
-
readonly runtime: TRPCClientRuntime;
|
|
53
|
-
private requestId;
|
|
54
|
-
constructor(opts: CreateTRPCClientOptions<TRouter>);
|
|
55
|
-
private $request;
|
|
56
|
-
private requestAsPromise;
|
|
57
|
-
query(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
58
|
-
mutation(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
59
|
-
subscription(path: string, input: unknown, opts: TRPCRequestOptions & Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>>): Unsubscribable;
|
|
60
|
-
}
|
|
61
|
-
export {};
|
|
1
|
+
import { AnyRouter, ClientDataTransformerOptions, CombinedDataTransformer, DataTransformerOptions, DefaultDataTransformer } from '@trpc/server';
|
|
2
|
+
import { Unsubscribable } from '@trpc/server/observable';
|
|
3
|
+
import { TRPCClientError } from '../TRPCClientError';
|
|
4
|
+
import { OperationContext, TRPCClientRuntime, TRPCLink } from '../links/types';
|
|
5
|
+
type CreateTRPCClientBaseOptions<TRouter extends AnyRouter> = TRouter['_def']['_config']['transformer'] extends DefaultDataTransformer ? {
|
|
6
|
+
/**
|
|
7
|
+
* Data transformer
|
|
8
|
+
*
|
|
9
|
+
* You must use the same transformer on the backend and frontend
|
|
10
|
+
* @link https://trpc.io/docs/data-transformers
|
|
11
|
+
**/
|
|
12
|
+
transformer?: 'You must set a transformer on the backend router';
|
|
13
|
+
} : TRouter['_def']['_config']['transformer'] extends DataTransformerOptions ? {
|
|
14
|
+
/**
|
|
15
|
+
* Data transformer
|
|
16
|
+
*
|
|
17
|
+
* You must use the same transformer on the backend and frontend
|
|
18
|
+
* @link https://trpc.io/docs/data-transformers
|
|
19
|
+
**/
|
|
20
|
+
transformer: TRouter['_def']['_config']['transformer'] extends CombinedDataTransformer ? DataTransformerOptions : TRouter['_def']['_config']['transformer'];
|
|
21
|
+
} : {
|
|
22
|
+
/**
|
|
23
|
+
* Data transformer
|
|
24
|
+
*
|
|
25
|
+
* You must use the same transformer on the backend and frontend
|
|
26
|
+
* @link https://trpc.io/docs/data-transformers
|
|
27
|
+
**/
|
|
28
|
+
transformer?: /** @deprecated **/ ClientDataTransformerOptions | CombinedDataTransformer;
|
|
29
|
+
};
|
|
30
|
+
export interface TRPCRequestOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Pass additional context to links
|
|
33
|
+
*/
|
|
34
|
+
context?: OperationContext;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
}
|
|
37
|
+
export interface TRPCSubscriptionObserver<TValue, TError> {
|
|
38
|
+
onStarted: () => void;
|
|
39
|
+
onData: (value: TValue) => void;
|
|
40
|
+
onError: (err: TError) => void;
|
|
41
|
+
onStopped: () => void;
|
|
42
|
+
onComplete: () => void;
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
export type CreateTRPCClientOptions<TRouter extends AnyRouter> = CreateTRPCClientBaseOptions<TRouter> & {
|
|
46
|
+
links: TRPCLink<TRouter>[];
|
|
47
|
+
};
|
|
48
|
+
/** @internal */
|
|
49
|
+
export type UntypedClientProperties = 'links' | 'runtime' | 'requestId' | '$request' | 'requestAsPromise' | 'query' | 'mutation' | 'subscription';
|
|
50
|
+
export declare class TRPCUntypedClient<TRouter extends AnyRouter> {
|
|
51
|
+
private readonly links;
|
|
52
|
+
readonly runtime: TRPCClientRuntime;
|
|
53
|
+
private requestId;
|
|
54
|
+
constructor(opts: CreateTRPCClientOptions<TRouter>);
|
|
55
|
+
private $request;
|
|
56
|
+
private requestAsPromise;
|
|
57
|
+
query(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
58
|
+
mutation(path: string, input?: unknown, opts?: TRPCRequestOptions): Promise<unknown>;
|
|
59
|
+
subscription(path: string, input: unknown, opts: TRPCRequestOptions & Partial<TRPCSubscriptionObserver<unknown, TRPCClientError<AnyRouter>>>): Unsubscribable;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
62
|
//# sourceMappingURL=TRPCUntypedClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EAIf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,gBAAgB,EAEhB,iBAAiB,EACjB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAExB,
|
|
1
|
+
{"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAC5B,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EAIf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,C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