@orpc/vue-colada 0.0.0-next.9adcd05 → 0.0.0-next.9b13466
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 +14 -1
- package/dist/index.d.mts +17 -22
- package/dist/index.d.ts +17 -22
- package/dist/index.mjs +8 -26
- package/package.json +3 -3
package/README.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
@@ -53,11 +53,16 @@ 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).
|
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
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
58
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
59
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
60
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/).
|
61
66
|
|
62
67
|
## `@orpc/vue-colada`
|
63
68
|
|
@@ -92,6 +97,14 @@ export function Setup() {
|
|
92
97
|
}
|
93
98
|
```
|
94
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
|
+
|
95
108
|
## License
|
96
109
|
|
97
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,36 +13,33 @@ 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 extends
|
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:
|
28
|
-
}) & SetOptional<
|
29
|
-
type QueryOptions<TOutput, TError extends
|
30
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
31
|
-
context?:
|
24
|
+
context: MaybeRefOrGetter<TClientContext>;
|
25
|
+
}) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
|
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
|
-
queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
|
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>;
|
41
38
|
}
|
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,6 +49,4 @@ interface CreateRouterUtilsOptions {
|
|
52
49
|
}
|
53
50
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
|
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,36 +13,33 @@ 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 extends
|
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:
|
28
|
-
}) & SetOptional<
|
29
|
-
type QueryOptions<TOutput, TError extends
|
30
|
-
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError
|
31
|
-
context?:
|
24
|
+
context: MaybeRefOrGetter<TClientContext>;
|
25
|
+
}) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
|
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
|
-
queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
|
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>;
|
41
38
|
}
|
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,6 +49,4 @@ interface CreateRouterUtilsOptions {
|
|
52
49
|
}
|
53
50
|
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
export { type BuildKeyOptions, type CreateProcedureUtilsOptions, type CreateRouterUtilsOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
|
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
|
}
|
@@ -84,6 +68,4 @@ function createRouterUtils(client, options = {}) {
|
|
84
68
|
return recursive;
|
85
69
|
}
|
86
70
|
|
87
|
-
|
88
|
-
|
89
|
-
export { buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
|
71
|
+
export { buildKey, createGeneralUtils, createRouterUtils as createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
|
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.9b13466",
|
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.9b13466",
|
36
|
+
"@orpc/shared": "0.0.0-next.9b13466"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"pinia": "^2.3.0"
|