@orpc/vue-colada 1.2.0 → 1.4.0
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 +2 -1
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.mjs +11 -10
- package/package.json +7 -5
package/README.md
CHANGED
@@ -49,6 +49,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
49
49
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
50
50
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
51
51
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
52
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
|
52
53
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
53
54
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
54
55
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
@@ -62,7 +63,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
62
63
|
|
63
64
|
## `@orpc/vue-colada`
|
64
65
|
|
65
|
-
Integration with [Pinia Colada](https://pinia-colada.esm.dev/). Read the [documentation](https://orpc.unnoq.com/docs/pinia-colada) for more information.
|
66
|
+
Integration with [Pinia Colada](https://pinia-colada.esm.dev/). Read the [documentation](https://orpc.unnoq.com/docs/integrations/pinia-colada) for more information.
|
66
67
|
|
67
68
|
```ts
|
68
69
|
export function Setup() {
|
package/dist/index.d.mts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
2
2
|
import { EntryKey, UseQueryOptions, UseMutationOptions, _EmptyObject } from '@pinia/colada';
|
3
|
-
import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { PartialDeep, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { MaybeRefOrGetter } from 'vue';
|
5
5
|
|
6
6
|
interface BuildKeyOptions<TInput> {
|
7
|
-
|
7
|
+
type?: 'query' | 'mutation';
|
8
|
+
input?: PartialDeep<TInput>;
|
8
9
|
}
|
9
10
|
declare function buildKey<TInput>(path: string[], options?: BuildKeyOptions<TInput>): EntryKey;
|
10
11
|
|
@@ -12,7 +13,7 @@ interface GeneralUtils<TInput> {
|
|
12
13
|
/**
|
13
14
|
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
14
15
|
*
|
15
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key Docs}
|
16
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key Docs}
|
16
17
|
*/
|
17
18
|
key(options?: BuildKeyOptions<TInput>): EntryKey;
|
18
19
|
}
|
@@ -40,21 +41,21 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
40
41
|
/**
|
41
42
|
* Calling corresponding procedure client
|
42
43
|
*
|
43
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure Client Docs}
|
44
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure Client Docs}
|
44
45
|
*/
|
45
46
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
46
47
|
/**
|
47
48
|
* Generate options used for useQuery/...
|
48
49
|
*
|
49
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#query-options-utility Pinia Colada Query Options Utility Docs}
|
50
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#query-options-utility Pinia Colada Query Options Utility Docs}
|
50
51
|
*/
|
51
|
-
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): QueryOptions<TOutput, TError, UInitialData
|
52
|
+
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): NoInfer<QueryOptions<TOutput, TError, UInitialData>>;
|
52
53
|
/**
|
53
54
|
* Generate options used for useMutation/...
|
54
55
|
*
|
55
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#mutation-options Pinia Colada Mutation Options Docs}
|
56
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#mutation-options Pinia Colada Mutation Options Docs}
|
56
57
|
*/
|
57
|
-
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext
|
58
|
+
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptions<TInput, TOutput, TError, UMutationContext>>;
|
58
59
|
}
|
59
60
|
interface CreateProcedureUtilsOptions {
|
60
61
|
path: string[];
|
@@ -71,7 +72,7 @@ interface CreateRouterUtilsOptions {
|
|
71
72
|
* Create a router utils from a client.
|
72
73
|
*
|
73
74
|
* @info Both client-side and server-side clients are supported.
|
74
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada Pinia Colada Docs}
|
75
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada Pinia Colada Docs}
|
75
76
|
*/
|
76
77
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
77
78
|
|
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import { ClientContext, Client, NestedClient } from '@orpc/client';
|
2
2
|
import { EntryKey, UseQueryOptions, UseMutationOptions, _EmptyObject } from '@pinia/colada';
|
3
|
-
import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { PartialDeep, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { MaybeRefOrGetter } from 'vue';
|
5
5
|
|
6
6
|
interface BuildKeyOptions<TInput> {
|
7
|
-
|
7
|
+
type?: 'query' | 'mutation';
|
8
|
+
input?: PartialDeep<TInput>;
|
8
9
|
}
|
9
10
|
declare function buildKey<TInput>(path: string[], options?: BuildKeyOptions<TInput>): EntryKey;
|
10
11
|
|
@@ -12,7 +13,7 @@ interface GeneralUtils<TInput> {
|
|
12
13
|
/**
|
13
14
|
* Generate a query/mutation key for checking status, invalidate, set, get, etc.
|
14
15
|
*
|
15
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key Docs}
|
16
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#query-mutation-key Pinia Colada Query/Mutation Key Docs}
|
16
17
|
*/
|
17
18
|
key(options?: BuildKeyOptions<TInput>): EntryKey;
|
18
19
|
}
|
@@ -40,21 +41,21 @@ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput,
|
|
40
41
|
/**
|
41
42
|
* Calling corresponding procedure client
|
42
43
|
*
|
43
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure Client Docs}
|
44
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#calling-procedure-clients Pinia Colada Calling Procedure Client Docs}
|
44
45
|
*/
|
45
46
|
call: Client<TClientContext, TInput, TOutput, TError>;
|
46
47
|
/**
|
47
48
|
* Generate options used for useQuery/...
|
48
49
|
*
|
49
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#query-options-utility Pinia Colada Query Options Utility Docs}
|
50
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#query-options-utility Pinia Colada Query Options Utility Docs}
|
50
51
|
*/
|
51
|
-
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): QueryOptions<TOutput, TError, UInitialData
|
52
|
+
queryOptions<UInitialData extends TOutput | undefined = TOutput | undefined>(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError, UInitialData>>): NoInfer<QueryOptions<TOutput, TError, UInitialData>>;
|
52
53
|
/**
|
53
54
|
* Generate options used for useMutation/...
|
54
55
|
*
|
55
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada#mutation-options Pinia Colada Mutation Options Docs}
|
56
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada#mutation-options Pinia Colada Mutation Options Docs}
|
56
57
|
*/
|
57
|
-
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext
|
58
|
+
mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): NoInfer<MutationOptions<TInput, TOutput, TError, UMutationContext>>;
|
58
59
|
}
|
59
60
|
interface CreateProcedureUtilsOptions {
|
60
61
|
path: string[];
|
@@ -71,7 +72,7 @@ interface CreateRouterUtilsOptions {
|
|
71
72
|
* Create a router utils from a client.
|
72
73
|
*
|
73
74
|
* @info Both client-side and server-side clients are supported.
|
74
|
-
* @see {@link https://orpc.unnoq.com/docs/pinia-colada Pinia Colada Docs}
|
75
|
+
* @see {@link https://orpc.unnoq.com/docs/integrations/pinia-colada Pinia Colada Docs}
|
75
76
|
*/
|
76
77
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
77
78
|
|
package/dist/index.mjs
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
import { StandardRPCJsonSerializer } from '@orpc/client/standard';
|
2
|
-
import { stringifyJSON } from '@orpc/shared';
|
3
2
|
import { toValue, computed } from 'vue';
|
4
3
|
|
5
|
-
function buildKey(path, options) {
|
6
|
-
|
7
|
-
|
8
|
-
}
|
9
|
-
const [json, meta] = new StandardRPCJsonSerializer().serialize(options.input);
|
4
|
+
function buildKey(path, options = {}) {
|
5
|
+
const [json] = new StandardRPCJsonSerializer().serialize(options.input);
|
6
|
+
const withInput = json !== void 0 ? { input: json } : {};
|
7
|
+
const withType = options.type !== void 0 ? { type: options.type } : {};
|
10
8
|
return [
|
11
|
-
|
12
|
-
{
|
9
|
+
path,
|
10
|
+
{
|
11
|
+
...withInput,
|
12
|
+
...withType
|
13
|
+
}
|
13
14
|
];
|
14
15
|
}
|
15
16
|
|
@@ -26,14 +27,14 @@ function createProcedureUtils(client, options) {
|
|
26
27
|
call: client,
|
27
28
|
queryOptions(...[{ input, context, ...rest } = {}]) {
|
28
29
|
return {
|
29
|
-
key: computed(() => buildKey(options.path, { input: toValue(input) })),
|
30
|
+
key: computed(() => buildKey(options.path, { type: "query", input: toValue(input) })),
|
30
31
|
query: ({ signal }) => client(toValue(input), { signal, context: toValue(context) }),
|
31
32
|
...rest
|
32
33
|
};
|
33
34
|
},
|
34
35
|
mutationOptions(...[{ context, ...rest } = {}]) {
|
35
36
|
return {
|
36
|
-
key: (input) => buildKey(options.path, { input }),
|
37
|
+
key: (input) => buildKey(options.path, { type: "mutation", input }),
|
37
38
|
mutation: (input) => client(input, { context: toValue(context) }),
|
38
39
|
...rest
|
39
40
|
};
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/vue-colada",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.4.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -28,15 +28,17 @@
|
|
28
28
|
"dist"
|
29
29
|
],
|
30
30
|
"peerDependencies": {
|
31
|
-
"@pinia/colada": ">=0.
|
31
|
+
"@pinia/colada": ">=0.16.0",
|
32
32
|
"vue": ">=3.3.0"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@orpc/client": "1.
|
36
|
-
"@orpc/shared": "1.
|
35
|
+
"@orpc/client": "1.4.0",
|
36
|
+
"@orpc/shared": "1.4.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"pinia": "^
|
39
|
+
"@pinia/colada": "^0.17.0",
|
40
|
+
"pinia": "^3.0.2",
|
41
|
+
"vue": "^3.5.16"
|
40
42
|
},
|
41
43
|
"scripts": {
|
42
44
|
"build": "unbuild",
|