@orpc/vue-colada 0.0.0-next.c0afbea → 0.0.0-next.c0ca4c7
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 +11 -0
- package/dist/index.d.mts +15 -18
- package/dist/index.d.ts +15 -18
- package/dist/index.mjs +7 -23
- package/package.json +3 -3
package/README.md
CHANGED
@@ -53,6 +53,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
56
57
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
57
58
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
58
59
|
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
@@ -60,6 +61,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
60
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
61
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
62
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
63
66
|
|
64
67
|
## `@orpc/vue-colada`
|
65
68
|
|
@@ -94,6 +97,14 @@ export function Setup() {
|
|
94
97
|
}
|
95
98
|
```
|
96
99
|
|
100
|
+
## Sponsors
|
101
|
+
|
102
|
+
<p align="center">
|
103
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
104
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
105
|
+
</a>
|
106
|
+
</p>
|
107
|
+
|
97
108
|
## License
|
98
109
|
|
99
110
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
2
2
|
import { EntryKey, UseQueryOptions, UseMutationOptions, _EmptyObject } from '@pinia/colada';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { MaybeRefOrGetter } from 'vue';
|
5
5
|
|
6
6
|
interface BuildKeyOptions<TInput> {
|
7
7
|
input?: TInput;
|
@@ -13,28 +13,25 @@ interface GeneralUtils<TInput> {
|
|
13
13
|
}
|
14
14
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
15
15
|
|
16
|
-
type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
17
|
-
[K in keyof T]: MaybeRefDeep<T[K]>;
|
18
|
-
} : T>;
|
19
16
|
type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
|
20
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
21
|
-
input?:
|
17
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TInitialData extends TOutput | undefined> = (undefined extends TInput ? {
|
18
|
+
input?: MaybeRefOrGetter<TInput>;
|
22
19
|
} : {
|
23
|
-
input:
|
20
|
+
input: MaybeRefOrGetter<TInput>;
|
24
21
|
}) & (Record<never, never> extends TClientContext ? {
|
25
|
-
context?:
|
22
|
+
context?: MaybeRefOrGetter<TClientContext>;
|
26
23
|
} : {
|
27
|
-
context:
|
24
|
+
context: MaybeRefOrGetter<TClientContext>;
|
28
25
|
}) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
|
29
|
-
type QueryOptions<TOutput, TError
|
30
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
31
|
-
context?:
|
26
|
+
type QueryOptions<TOutput, TError, TInitialData extends TOutput | undefined> = UseQueryOptions<TOutput, TError, TInitialData>;
|
27
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext extends Record<any, any>> = (Record<never, never> extends TClientContext ? {
|
28
|
+
context?: MaybeRefOrGetter<TClientContext>;
|
32
29
|
} : {
|
33
|
-
context:
|
30
|
+
context: MaybeRefOrGetter<TClientContext>;
|
34
31
|
}) & SetOptional<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>;
|
35
|
-
type MutationOptions<TInput, TOutput, TError
|
32
|
+
type MutationOptions<TInput, TOutput, TError, TMutationContext extends Record<any, any>> = UseMutationOptions<TOutput, TInput, TError, TMutationContext>;
|
36
33
|
|
37
|
-
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
34
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
38
35
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
39
36
|
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): QueryOptions<TOutput, TError, UInitialData>;
|
40
37
|
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
@@ -42,7 +39,7 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
42
39
|
interface CreateProcedureUtilsOptions {
|
43
40
|
path: string[];
|
44
41
|
}
|
45
|
-
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
42
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
46
43
|
|
47
44
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
48
45
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
@@ -52,4 +49,4 @@ interface CreateRouterUtilsOptions {
|
|
52
49
|
}
|
53
50
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
54
51
|
|
55
|
-
export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type
|
52
|
+
export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createRouterUtils as createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
|
package/dist/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
2
2
|
import { EntryKey, UseQueryOptions, UseMutationOptions, _EmptyObject } from '@pinia/colada';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import { MaybeRefOrGetter } from 'vue';
|
5
5
|
|
6
6
|
interface BuildKeyOptions<TInput> {
|
7
7
|
input?: TInput;
|
@@ -13,28 +13,25 @@ interface GeneralUtils<TInput> {
|
|
13
13
|
}
|
14
14
|
declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
|
15
15
|
|
16
|
-
type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
|
17
|
-
[K in keyof T]: MaybeRefDeep<T[K]>;
|
18
|
-
} : T>;
|
19
16
|
type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
|
20
|
-
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
21
|
-
input?:
|
17
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TInitialData extends TOutput | undefined> = (undefined extends TInput ? {
|
18
|
+
input?: MaybeRefOrGetter<TInput>;
|
22
19
|
} : {
|
23
|
-
input:
|
20
|
+
input: MaybeRefOrGetter<TInput>;
|
24
21
|
}) & (Record<never, never> extends TClientContext ? {
|
25
|
-
context?:
|
22
|
+
context?: MaybeRefOrGetter<TClientContext>;
|
26
23
|
} : {
|
27
|
-
context:
|
24
|
+
context: MaybeRefOrGetter<TClientContext>;
|
28
25
|
}) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
|
29
|
-
type QueryOptions<TOutput, TError
|
30
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
31
|
-
context?:
|
26
|
+
type QueryOptions<TOutput, TError, TInitialData extends TOutput | undefined> = UseQueryOptions<TOutput, TError, TInitialData>;
|
27
|
+
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError, TMutationContext extends Record<any, any>> = (Record<never, never> extends TClientContext ? {
|
28
|
+
context?: MaybeRefOrGetter<TClientContext>;
|
32
29
|
} : {
|
33
|
-
context:
|
30
|
+
context: MaybeRefOrGetter<TClientContext>;
|
34
31
|
}) & SetOptional<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>;
|
35
|
-
type MutationOptions<TInput, TOutput, TError
|
32
|
+
type MutationOptions<TInput, TOutput, TError, TMutationContext extends Record<any, any>> = UseMutationOptions<TOutput, TInput, TError, TMutationContext>;
|
36
33
|
|
37
|
-
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
34
|
+
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
38
35
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
39
36
|
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): QueryOptions<TOutput, TError, UInitialData>;
|
40
37
|
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
|
@@ -42,7 +39,7 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
42
39
|
interface CreateProcedureUtilsOptions {
|
43
40
|
path: string[];
|
44
41
|
}
|
45
|
-
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError
|
42
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
46
43
|
|
47
44
|
type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
|
48
45
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
@@ -52,4 +49,4 @@ interface CreateRouterUtilsOptions {
|
|
52
49
|
}
|
53
50
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
54
51
|
|
55
|
-
export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type
|
52
|
+
export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createRouterUtils as createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
|
package/dist/index.mjs
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { stringifyJSON
|
3
|
-
import {
|
1
|
+
import { StandardRPCJsonSerializer } from '@orpc/client/standard';
|
2
|
+
import { stringifyJSON } from '@orpc/shared';
|
3
|
+
import { toValue, computed } from 'vue';
|
4
4
|
|
5
5
|
function buildKey(path, options) {
|
6
6
|
if (options?.input === void 0) {
|
7
7
|
return path;
|
8
8
|
}
|
9
|
-
const [json, meta] = new
|
9
|
+
const [json, meta] = new StandardRPCJsonSerializer().serialize(options.input);
|
10
10
|
return [
|
11
11
|
...path,
|
12
12
|
{ input: stringifyJSON({ json, meta }) }
|
@@ -21,36 +21,20 @@ function createGeneralUtils(path) {
|
|
21
21
|
};
|
22
22
|
}
|
23
23
|
|
24
|
-
function unrefDeep(value) {
|
25
|
-
if (isRef(value)) {
|
26
|
-
return unrefDeep(value.value);
|
27
|
-
}
|
28
|
-
if (Array.isArray(value)) {
|
29
|
-
return value.map(unrefDeep);
|
30
|
-
}
|
31
|
-
if (isObject(value)) {
|
32
|
-
return Object.keys(value).reduce((acc, key) => {
|
33
|
-
acc[key] = unrefDeep(value[key]);
|
34
|
-
return acc;
|
35
|
-
}, {});
|
36
|
-
}
|
37
|
-
return value;
|
38
|
-
}
|
39
|
-
|
40
24
|
function createProcedureUtils(client, options) {
|
41
25
|
return {
|
42
26
|
call: client,
|
43
27
|
queryOptions(...[{ input, context, ...rest } = {}]) {
|
44
28
|
return {
|
45
|
-
key: computed(() => buildKey(options.path, { input:
|
46
|
-
query: ({ signal }) => client(
|
29
|
+
key: computed(() => buildKey(options.path, { input: toValue(input) })),
|
30
|
+
query: ({ signal }) => client(toValue(input), { signal, context: toValue(context) }),
|
47
31
|
...rest
|
48
32
|
};
|
49
33
|
},
|
50
34
|
mutationOptions(...[{ context, ...rest } = {}]) {
|
51
35
|
return {
|
52
36
|
key: (input) => buildKey(options.path, { input }),
|
53
|
-
mutation: (input) => client(input, { context:
|
37
|
+
mutation: (input) => client(input, { context: toValue(context) }),
|
54
38
|
...rest
|
55
39
|
};
|
56
40
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/vue-colada",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.c0ca4c7",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -32,8 +32,8 @@
|
|
32
32
|
"vue": ">=3.3.0"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@orpc/client": "0.0.0-next.
|
36
|
-
"@orpc/shared": "0.0.0-next.
|
35
|
+
"@orpc/client": "0.0.0-next.c0ca4c7",
|
36
|
+
"@orpc/shared": "0.0.0-next.c0ca4c7"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"pinia": "^2.3.0"
|