@orpc/vue-colada 0.46.0 → 0.48.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 +3 -1
- package/dist/index.d.mts +21 -24
- package/dist/index.d.ts +21 -24
- package/dist/index.mjs +14 -31
- 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.
|
@@ -55,6 +55,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
56
56
|
- [@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
57
|
- [@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
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
59
|
+
- [@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
60
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
59
61
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
60
62
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
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,43 +13,40 @@ 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 Error> = (undefined extends TInput ? {
|
21
|
-
input?:
|
17
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, 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 Error> = UseQueryOptions<TOutput, TError>;
|
24
|
+
context: MaybeRefOrGetter<TClientContext>;
|
25
|
+
}) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
|
26
|
+
type QueryOptions<TOutput, TError extends Error, TInitialData extends TOutput | undefined> = UseQueryOptions<TOutput, TError, TInitialData>;
|
30
27
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = (Record<never, never> extends TClientContext ? {
|
31
|
-
context?:
|
28
|
+
context?: MaybeRefOrGetter<TClientContext>;
|
32
29
|
} : {
|
33
|
-
context:
|
30
|
+
context: MaybeRefOrGetter<TClientContext>;
|
34
31
|
}) & SetOptional<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>;
|
35
32
|
type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = UseMutationOptions<TOutput, TInput, TError, TMutationContext>;
|
36
33
|
|
37
34
|
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
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 {
|
40
|
+
path: string[];
|
41
|
+
}
|
42
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
43
43
|
|
44
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> : {
|
45
45
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
46
46
|
} & GeneralUtils<unknown>;
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
52
|
-
|
53
|
-
declare const createORPCVueColadaUtils: typeof createRouterUtils;
|
47
|
+
interface CreateRouterUtilsOptions {
|
48
|
+
path?: string[];
|
49
|
+
}
|
50
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
54
51
|
|
55
|
-
export { type BuildKeyOptions, 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,43 +13,40 @@ 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 Error> = (undefined extends TInput ? {
|
21
|
-
input?:
|
17
|
+
type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, 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 Error> = UseQueryOptions<TOutput, TError>;
|
24
|
+
context: MaybeRefOrGetter<TClientContext>;
|
25
|
+
}) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
|
26
|
+
type QueryOptions<TOutput, TError extends Error, TInitialData extends TOutput | undefined> = UseQueryOptions<TOutput, TError, TInitialData>;
|
30
27
|
type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = (Record<never, never> extends TClientContext ? {
|
31
|
-
context?:
|
28
|
+
context?: MaybeRefOrGetter<TClientContext>;
|
32
29
|
} : {
|
33
|
-
context:
|
30
|
+
context: MaybeRefOrGetter<TClientContext>;
|
34
31
|
}) & SetOptional<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>;
|
35
32
|
type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = UseMutationOptions<TOutput, TInput, TError, TMutationContext>;
|
36
33
|
|
37
34
|
interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
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 {
|
40
|
+
path: string[];
|
41
|
+
}
|
42
|
+
declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, options: CreateProcedureUtilsOptions): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
|
43
43
|
|
44
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> : {
|
45
45
|
[K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
|
46
46
|
} & GeneralUtils<unknown>;
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
|
52
|
-
|
53
|
-
declare const createORPCVueColadaUtils: typeof createRouterUtils;
|
47
|
+
interface CreateRouterUtilsOptions {
|
48
|
+
path?: string[];
|
49
|
+
}
|
50
|
+
declare function createRouterUtils<T extends NestedClient<any>>(client: T, options?: CreateRouterUtilsOptions): RouterUtils<T>;
|
54
51
|
|
55
|
-
export { type BuildKeyOptions, 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,45 +21,30 @@ function createGeneralUtils(path) {
|
|
21
21
|
};
|
22
22
|
}
|
23
23
|
|
24
|
-
function
|
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
|
-
function createProcedureUtils(client, path) {
|
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(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
|
-
key: (input) => buildKey(path, { input }),
|
53
|
-
mutation: (input) => client(input, { context:
|
36
|
+
key: (input) => buildKey(options.path, { input }),
|
37
|
+
mutation: (input) => client(input, { context: toValue(context) }),
|
54
38
|
...rest
|
55
39
|
};
|
56
40
|
}
|
57
41
|
};
|
58
42
|
}
|
59
43
|
|
60
|
-
function createRouterUtils(client,
|
44
|
+
function createRouterUtils(client, options = {}) {
|
45
|
+
const path = options.path ?? [];
|
61
46
|
const generalUtils = createGeneralUtils(path);
|
62
|
-
const procedureUtils = createProcedureUtils(client, path);
|
47
|
+
const procedureUtils = createProcedureUtils(client, { path });
|
63
48
|
const recursive = new Proxy({
|
64
49
|
...generalUtils,
|
65
50
|
...procedureUtils
|
@@ -69,7 +54,7 @@ function createRouterUtils(client, path = []) {
|
|
69
54
|
if (typeof prop !== "string") {
|
70
55
|
return value;
|
71
56
|
}
|
72
|
-
const nextUtils = createRouterUtils(client[prop], [...path, prop]);
|
57
|
+
const nextUtils = createRouterUtils(client[prop], { ...options, path: [...path, prop] });
|
73
58
|
if (typeof value !== "function") {
|
74
59
|
return nextUtils;
|
75
60
|
}
|
@@ -83,6 +68,4 @@ function createRouterUtils(client, path = []) {
|
|
83
68
|
return recursive;
|
84
69
|
}
|
85
70
|
|
86
|
-
|
87
|
-
|
88
|
-
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.
|
4
|
+
"version": "0.48.0",
|
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.
|
36
|
-
"@orpc/shared": "0.
|
35
|
+
"@orpc/client": "0.48.0",
|
36
|
+
"@orpc/shared": "0.48.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"pinia": "^2.3.0"
|