@orpc/vue-colada 0.43.0 → 0.45.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 />
2
+ <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
3
3
  </div>
4
4
 
5
5
  <h1></h1>
@@ -0,0 +1,55 @@
1
+ import { ClientContext, Client, NestedClient } from '@orpc/client';
2
+ import { EntryKey, UseQueryOptions, UseMutationOptions, _EmptyObject } from '@pinia/colada';
3
+ import { AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
+ import { MaybeRef } from 'vue';
5
+
6
+ interface BuildKeyOptions<TInput> {
7
+ input?: TInput;
8
+ }
9
+ declare function buildKey<TInput>(path: string[], options?: BuildKeyOptions<TInput>): EntryKey;
10
+
11
+ interface GeneralUtils<TInput> {
12
+ key(options?: BuildKeyOptions<TInput>): EntryKey;
13
+ }
14
+ declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
15
+
16
+ type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
17
+ [K in keyof T]: MaybeRefDeep<T[K]>;
18
+ } : T>;
19
+ type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
20
+ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (undefined extends TInput ? {
21
+ input?: MaybeRefDeep<TInput>;
22
+ } : {
23
+ input: MaybeRefDeep<TInput>;
24
+ }) & (Record<never, never> extends TClientContext ? {
25
+ context?: MaybeRefDeep<TClientContext>;
26
+ } : {
27
+ context: MaybeRefDeep<TClientContext>;
28
+ }) & SetOptional<UseQueryOptions<TOutput, TError>, 'key' | 'query'>;
29
+ type QueryOptions<TOutput, TError extends Error> = UseQueryOptions<TOutput, TError>;
30
+ type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = (Record<never, never> extends TClientContext ? {
31
+ context?: MaybeRefDeep<TClientContext>;
32
+ } : {
33
+ context: MaybeRefDeep<TClientContext>;
34
+ }) & SetOptional<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>;
35
+ type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = UseMutationOptions<TOutput, TInput, TError, TMutationContext>;
36
+
37
+ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
38
+ call: Client<TClientContext, TInput, TOutput, TError>;
39
+ queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
40
+ mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
41
+ }
42
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
43
+
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
+ [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
46
+ } & GeneralUtils<unknown>;
47
+ /**
48
+ * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
49
+ * @param path - The base path for query key, when it it will be prefix to all keys
50
+ */
51
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
52
+
53
+ declare const createORPCVueColadaUtils: typeof createRouterUtils;
54
+
55
+ export { type BuildKeyOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
@@ -0,0 +1,55 @@
1
+ import { ClientContext, Client, NestedClient } from '@orpc/client';
2
+ import { EntryKey, UseQueryOptions, UseMutationOptions, _EmptyObject } from '@pinia/colada';
3
+ import { AnyFunction, SetOptional, MaybeOptionalOptions } from '@orpc/shared';
4
+ import { MaybeRef } from 'vue';
5
+
6
+ interface BuildKeyOptions<TInput> {
7
+ input?: TInput;
8
+ }
9
+ declare function buildKey<TInput>(path: string[], options?: BuildKeyOptions<TInput>): EntryKey;
10
+
11
+ interface GeneralUtils<TInput> {
12
+ key(options?: BuildKeyOptions<TInput>): EntryKey;
13
+ }
14
+ declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
15
+
16
+ type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
17
+ [K in keyof T]: MaybeRefDeep<T[K]>;
18
+ } : T>;
19
+ type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
20
+ type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (undefined extends TInput ? {
21
+ input?: MaybeRefDeep<TInput>;
22
+ } : {
23
+ input: MaybeRefDeep<TInput>;
24
+ }) & (Record<never, never> extends TClientContext ? {
25
+ context?: MaybeRefDeep<TClientContext>;
26
+ } : {
27
+ context: MaybeRefDeep<TClientContext>;
28
+ }) & SetOptional<UseQueryOptions<TOutput, TError>, 'key' | 'query'>;
29
+ type QueryOptions<TOutput, TError extends Error> = UseQueryOptions<TOutput, TError>;
30
+ type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = (Record<never, never> extends TClientContext ? {
31
+ context?: MaybeRefDeep<TClientContext>;
32
+ } : {
33
+ context: MaybeRefDeep<TClientContext>;
34
+ }) & SetOptional<UseMutationOptions<TOutput, TInput, TError, TMutationContext>, 'mutation'>;
35
+ type MutationOptions<TInput, TOutput, TError extends Error, TMutationContext extends Record<any, any>> = UseMutationOptions<TOutput, TInput, TError, TMutationContext>;
36
+
37
+ interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
38
+ call: Client<TClientContext, TInput, TOutput, TError>;
39
+ queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
40
+ mutationOptions<UMutationContext extends Record<any, any> = _EmptyObject>(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError, UMutationContext>>): MutationOptions<TInput, TOutput, TError, UMutationContext>;
41
+ }
42
+ declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
43
+
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
+ [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
46
+ } & GeneralUtils<unknown>;
47
+ /**
48
+ * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
49
+ * @param path - The base path for query key, when it it will be prefix to all keys
50
+ */
51
+ declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
52
+
53
+ declare const createORPCVueColadaUtils: typeof createRouterUtils;
54
+
55
+ export { type BuildKeyOptions, type GeneralUtils, type MaybeRefDeep, type MutationOptions, type MutationOptionsIn, type ProcedureUtils, type QueryOptions, type QueryOptionsIn, type RouterUtils, type UseQueryFnContext, buildKey, createGeneralUtils, createORPCVueColadaUtils, createProcedureUtils, createRouterUtils };
@@ -1,5 +1,7 @@
1
- // src/key.ts
2
- import { RPCJsonSerializer } from "@orpc/client/rpc";
1
+ import { RPCJsonSerializer } from '@orpc/client/standard';
2
+ import { stringifyJSON, isObject } from '@orpc/shared';
3
+ import { isRef, computed } from 'vue';
4
+
3
5
  function buildKey(path, options) {
4
6
  if (options?.input === void 0) {
5
7
  return path;
@@ -7,11 +9,10 @@ function buildKey(path, options) {
7
9
  const [json, meta] = new RPCJsonSerializer().serialize(options.input);
8
10
  return [
9
11
  ...path,
10
- { input: JSON.stringify({ json, meta }) }
12
+ { input: stringifyJSON({ json, meta }) }
11
13
  ];
12
14
  }
13
15
 
14
- // src/general-utils.ts
15
16
  function createGeneralUtils(path) {
16
17
  return {
17
18
  key(options) {
@@ -20,12 +21,6 @@ function createGeneralUtils(path) {
20
21
  };
21
22
  }
22
23
 
23
- // src/procedure-utils.ts
24
- import { computed } from "vue";
25
-
26
- // src/utils.ts
27
- import { isObject } from "@orpc/shared";
28
- import { isRef } from "vue";
29
24
  function unrefDeep(value) {
30
25
  if (isRef(value)) {
31
26
  return unrefDeep(value.value);
@@ -42,7 +37,6 @@ function unrefDeep(value) {
42
37
  return value;
43
38
  }
44
39
 
45
- // src/procedure-utils.ts
46
40
  function createProcedureUtils(client, path) {
47
41
  return {
48
42
  call: client,
@@ -63,7 +57,6 @@ function createProcedureUtils(client, path) {
63
57
  };
64
58
  }
65
59
 
66
- // src/router-utils.ts
67
60
  function createRouterUtils(client, path = []) {
68
61
  const generalUtils = createGeneralUtils(path);
69
62
  const procedureUtils = createProcedureUtils(client, path);
@@ -90,13 +83,6 @@ function createRouterUtils(client, path = []) {
90
83
  return recursive;
91
84
  }
92
85
 
93
- // src/index.ts
94
- var createORPCVueColadaUtils = createRouterUtils;
95
- export {
96
- buildKey,
97
- createGeneralUtils,
98
- createORPCVueColadaUtils,
99
- createProcedureUtils,
100
- createRouterUtils
101
- };
102
- //# sourceMappingURL=index.js.map
86
+ const createORPCVueColadaUtils = createRouterUtils;
87
+
88
+ export { buildKey, createGeneralUtils, 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.43.0",
4
+ "version": "0.45.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -19,17 +19,12 @@
19
19
  ],
20
20
  "exports": {
21
21
  ".": {
22
- "types": "./dist/src/index.d.ts",
23
- "import": "./dist/index.js",
24
- "default": "./dist/index.js"
25
- },
26
- "./🔒/*": {
27
- "types": "./dist/src/*.d.ts"
22
+ "types": "./dist/index.d.mts",
23
+ "import": "./dist/index.mjs",
24
+ "default": "./dist/index.mjs"
28
25
  }
29
26
  },
30
27
  "files": [
31
- "!**/*.map",
32
- "!**/*.tsbuildinfo",
33
28
  "dist"
34
29
  ],
35
30
  "peerDependencies": {
@@ -37,14 +32,14 @@
37
32
  "vue": ">=3.3.0"
38
33
  },
39
34
  "dependencies": {
40
- "@orpc/shared": "0.43.0",
41
- "@orpc/client": "0.43.0"
35
+ "@orpc/client": "0.45.0",
36
+ "@orpc/shared": "0.45.0"
42
37
  },
43
38
  "devDependencies": {
44
39
  "pinia": "^2.3.0"
45
40
  },
46
41
  "scripts": {
47
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
42
+ "build": "unbuild",
48
43
  "build:watch": "pnpm run build --watch",
49
44
  "type:check": "tsc -b"
50
45
  }
@@ -1,7 +0,0 @@
1
- import type { EntryKey } from '@pinia/colada';
2
- import type { BuildKeyOptions } from './key';
3
- export interface GeneralUtils<TInput> {
4
- key(options?: BuildKeyOptions<TInput>): EntryKey;
5
- }
6
- export declare function createGeneralUtils<TInput>(path: string[]): GeneralUtils<TInput>;
7
- //# sourceMappingURL=general-utils.d.ts.map
@@ -1,8 +0,0 @@
1
- import { createRouterUtils } from './router-utils';
2
- export * from './general-utils';
3
- export * from './key';
4
- export * from './procedure-utils';
5
- export * from './router-utils';
6
- export * from './types';
7
- export declare const createORPCVueColadaUtils: typeof createRouterUtils;
8
- //# sourceMappingURL=index.d.ts.map
package/dist/src/key.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import type { EntryKey } from '@pinia/colada';
2
- export interface BuildKeyOptions<TInput> {
3
- input?: TInput;
4
- }
5
- export declare function buildKey<TInput>(path: string[], options?: BuildKeyOptions<TInput>): EntryKey;
6
- //# sourceMappingURL=key.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { Client, ClientContext } from '@orpc/client';
2
- import type { MaybeOptionalOptions } from '@orpc/shared';
3
- import type { MutationOptions, MutationOptionsIn, QueryOptions, QueryOptionsIn } from './types';
4
- export interface ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
5
- call: Client<TClientContext, TInput, TOutput, TError>;
6
- queryOptions(...rest: MaybeOptionalOptions<QueryOptionsIn<TClientContext, TInput, TOutput, TError>>): QueryOptions<TOutput, TError>;
7
- mutationOptions(...rest: MaybeOptionalOptions<MutationOptionsIn<TClientContext, TInput, TOutput, TError>>): MutationOptions<TInput, TOutput, TError>;
8
- }
9
- export declare function createProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError extends Error>(client: Client<TClientContext, TInput, TOutput, TError>, path: string[]): ProcedureUtils<TClientContext, TInput, TOutput, TError>;
10
- //# sourceMappingURL=procedure-utils.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { Client, NestedClient } from '@orpc/client';
2
- import { type GeneralUtils } from './general-utils';
3
- import { type ProcedureUtils } from './procedure-utils';
4
- export type RouterUtils<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ProcedureUtils<UClientContext, UInput, UOutput, UError> & GeneralUtils<UInput> : {
5
- [K in keyof T]: T[K] extends NestedClient<any> ? RouterUtils<T[K]> : never;
6
- } & GeneralUtils<unknown>;
7
- /**
8
- * @param client - Any kind of oRPC clients: `createRouterClient`, `createORPCClient`, ...
9
- * @param path - The base path for query key, when it it will be prefix to all keys
10
- */
11
- export declare function createRouterUtils<T extends NestedClient<any>>(client: T, path?: string[]): RouterUtils<T>;
12
- //# sourceMappingURL=router-utils.d.ts.map
@@ -1,25 +0,0 @@
1
- import type { ClientContext } from '@orpc/client';
2
- import type { AnyFunction, SetOptional } from '@orpc/shared';
3
- import type { UseMutationOptions, UseQueryOptions } from '@pinia/colada';
4
- import type { MaybeRef } from 'vue';
5
- export type MaybeRefDeep<T> = MaybeRef<T extends AnyFunction ? T : T extends object ? {
6
- [K in keyof T]: MaybeRefDeep<T[K]>;
7
- } : T>;
8
- export type UseQueryFnContext = Parameters<UseQueryOptions<any>['query']>[0];
9
- export type QueryOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (undefined extends TInput ? {
10
- input?: MaybeRefDeep<TInput>;
11
- } : {
12
- input: MaybeRefDeep<TInput>;
13
- }) & (Record<never, never> extends TClientContext ? {
14
- context?: MaybeRefDeep<TClientContext>;
15
- } : {
16
- context: MaybeRefDeep<TClientContext>;
17
- }) & SetOptional<UseQueryOptions<TOutput, TError>, 'key' | 'query'>;
18
- export type QueryOptions<TOutput, TError extends Error> = UseQueryOptions<TOutput, TError>;
19
- export type MutationOptionsIn<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> = (Record<never, never> extends TClientContext ? {
20
- context?: MaybeRefDeep<TClientContext>;
21
- } : {
22
- context: MaybeRefDeep<TClientContext>;
23
- }) & SetOptional<UseMutationOptions<TOutput, TInput, TError>, 'mutation'>;
24
- export type MutationOptions<TInput, TOutput, TError extends Error> = UseMutationOptions<TOutput, TInput, TError>;
25
- //# sourceMappingURL=types.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import { type AnyFunction } from '@orpc/shared';
3
- export type UnrefDeep<T> = T extends Ref<infer U> ? UnrefDeep<U> : T extends AnyFunction ? T : T extends object ? {
4
- [K in keyof T]: UnrefDeep<T[K]>;
5
- } : T;
6
- export declare function unrefDeep<T>(value: T): UnrefDeep<T>;
7
- //# sourceMappingURL=utils.d.ts.map