@orpc/vue-colada 0.0.0-next.c0afbea → 0.0.0-next.c0dd7cd

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 CHANGED
@@ -60,6 +60,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
60
60
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
61
61
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
62
62
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
63
+ - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
64
+ - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
63
65
 
64
66
  ## `@orpc/vue-colada`
65
67
 
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 { AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
- import { MaybeRef } from 'vue';
3
+ import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
+ import { MaybeRefOrGetter } from 'vue';
5
5
 
6
6
  interface BuildKeyOptions<TInput> {
7
7
  input?: TInput;
@@ -13,24 +13,21 @@ 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
17
  type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TInitialData extends TOutput | undefined> = (undefined extends TInput ? {
21
- input?: MaybeRefDeep<TInput>;
18
+ input?: MaybeRefOrGetter<TInput>;
22
19
  } : {
23
- input: MaybeRefDeep<TInput>;
20
+ input: MaybeRefOrGetter<TInput>;
24
21
  }) & (Record<never, never> extends TClientContext ? {
25
- context?: MaybeRefDeep<TClientContext>;
22
+ context?: MaybeRefOrGetter<TClientContext>;
26
23
  } : {
27
- context: MaybeRefDeep<TClientContext>;
24
+ context: MaybeRefOrGetter<TClientContext>;
28
25
  }) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
29
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?: MaybeRefDeep<TClientContext>;
28
+ context?: MaybeRefOrGetter<TClientContext>;
32
29
  } : {
33
- context: MaybeRefDeep<TClientContext>;
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
 
@@ -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 MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createRouterUtils as 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 { AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
- import { MaybeRef } from 'vue';
3
+ import { SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
+ import { MaybeRefOrGetter } from 'vue';
5
5
 
6
6
  interface BuildKeyOptions<TInput> {
7
7
  input?: TInput;
@@ -13,24 +13,21 @@ 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
17
  type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TInitialData extends TOutput | undefined> = (undefined extends TInput ? {
21
- input?: MaybeRefDeep<TInput>;
18
+ input?: MaybeRefOrGetter<TInput>;
22
19
  } : {
23
- input: MaybeRefDeep<TInput>;
20
+ input: MaybeRefOrGetter<TInput>;
24
21
  }) & (Record<never, never> extends TClientContext ? {
25
- context?: MaybeRefDeep<TClientContext>;
22
+ context?: MaybeRefOrGetter<TClientContext>;
26
23
  } : {
27
- context: MaybeRefDeep<TClientContext>;
24
+ context: MaybeRefOrGetter<TClientContext>;
28
25
  }) & SetOptional<QueryOptions<TOutput, TError, TInitialData>, 'key' | 'query'>;
29
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?: MaybeRefDeep<TClientContext>;
28
+ context?: MaybeRefOrGetter<TClientContext>;
32
29
  } : {
33
- context: MaybeRefDeep<TClientContext>;
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
 
@@ -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 MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createRouterUtils as 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 { RPCJsonSerializer } from '@orpc/client/standard';
2
- import { stringifyJSON, isObject } from '@orpc/shared';
3
- import { isRef, computed } from 'vue';
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 RPCJsonSerializer().serialize(options.input);
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: unrefDeep(input) })),
46
- query: ({ signal }) => client(unrefDeep(input), { signal, context: unrefDeep(context) }),
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: unrefDeep(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.c0afbea",
4
+ "version": "0.0.0-next.c0dd7cd",
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.c0afbea",
36
- "@orpc/shared": "0.0.0-next.c0afbea"
35
+ "@orpc/shared": "0.0.0-next.c0dd7cd",
36
+ "@orpc/client": "0.0.0-next.c0dd7cd"
37
37
  },
38
38
  "devDependencies": {
39
39
  "pinia": "^2.3.0"