@orpc/react 0.0.0-next.571d5d7 → 0.0.0-next.5725903
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 +266 -0
- package/dist/hooks/index.d.mts +79 -0
- package/dist/hooks/index.d.ts +79 -0
- package/dist/hooks/index.mjs +91 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.mjs +57 -0
- package/package.json +22 -20
- package/dist/index.js +0 -674
- package/dist/src/general-hooks.d.ts +0 -24
- package/dist/src/general-utils.d.ts +0 -41
- package/dist/src/index.d.ts +0 -9
- package/dist/src/orpc-path.d.ts +0 -5
- package/dist/src/procedure-hooks.d.ts +0 -31
- package/dist/src/procedure-utils.d.ts +0 -35
- package/dist/src/react-context.d.ts +0 -13
- package/dist/src/react-hooks.d.ts +0 -22
- package/dist/src/react-utils.d.ts +0 -22
- package/dist/src/react.d.ts +0 -21
- package/dist/src/tanstack-key.d.ts +0 -15
- package/dist/src/tanstack-query.d.ts +0 -19
- package/dist/src/types.d.ts +0 -5
- package/dist/src/use-queries/builder.d.ts +0 -20
- package/dist/src/use-queries/builders.d.ts +0 -19
- package/dist/src/use-queries/hook.d.ts +0 -16
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ORPCError, createORPCErrorFromJson } from '@orpc/client';
|
|
2
|
+
import { StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
|
|
3
|
+
export { getIssueMessage, parseFormData } from '@orpc/openapi-client/standard';
|
|
4
|
+
import { createProcedureClient } from '@orpc/server';
|
|
5
|
+
import { onError, resolveMaybeOptionalOptions, toArray, onStart, onSuccess, onFinish } from '@orpc/shared';
|
|
6
|
+
|
|
7
|
+
const orpcErrorToNextHttpFallbackInterceptor = onError((error) => {
|
|
8
|
+
if (error instanceof ORPCError && [401, 403, 404].includes(error.status)) {
|
|
9
|
+
const nextError = createORPCErrorFromJson(error.toJSON());
|
|
10
|
+
nextError.cause = error;
|
|
11
|
+
nextError.digest = `NEXT_HTTP_ERROR_FALLBACK;${error.status}`;
|
|
12
|
+
throw nextError;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function createFormAction(lazyableProcedure, ...rest) {
|
|
16
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
17
|
+
const client = createProcedureClient(lazyableProcedure, {
|
|
18
|
+
...options,
|
|
19
|
+
interceptors: [orpcErrorToNextHttpFallbackInterceptor, ...toArray(options.interceptors)]
|
|
20
|
+
});
|
|
21
|
+
const bracketNotation = new StandardBracketNotationSerializer();
|
|
22
|
+
return async (form) => {
|
|
23
|
+
const input = bracketNotation.deserialize([...form]);
|
|
24
|
+
await client(input);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const onStartDeferred = (callback, ...rest) => {
|
|
29
|
+
return onStart((...args) => {
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
callback(...args);
|
|
32
|
+
}, 6);
|
|
33
|
+
}, ...rest);
|
|
34
|
+
};
|
|
35
|
+
const onSuccessDeferred = (callback, ...rest) => {
|
|
36
|
+
return onSuccess((...args) => {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
callback(...args);
|
|
39
|
+
}, 6);
|
|
40
|
+
}, ...rest);
|
|
41
|
+
};
|
|
42
|
+
const onErrorDeferred = (callback, ...rest) => {
|
|
43
|
+
return onError((...args) => {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
callback(...args);
|
|
46
|
+
}, 6);
|
|
47
|
+
}, ...rest);
|
|
48
|
+
};
|
|
49
|
+
const onFinishDeferred = (callback, ...rest) => {
|
|
50
|
+
return onFinish((...args) => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
callback(...args);
|
|
53
|
+
}, 6);
|
|
54
|
+
}, ...rest);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { createFormAction, onErrorDeferred, onFinishDeferred, onStartDeferred, onSuccessDeferred, orpcErrorToNextHttpFallbackInterceptor };
|
package/package.json
CHANGED
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.5725903",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://orpc.
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/middleapi/orpc.git",
|
|
10
10
|
"directory": "packages/react"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"orpc",
|
|
14
|
+
"react",
|
|
15
|
+
"nextjs"
|
|
15
16
|
],
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"import": "./dist/index.
|
|
20
|
-
"default": "./dist/index.
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"default": "./dist/index.mjs"
|
|
21
22
|
},
|
|
22
|
-
"
|
|
23
|
-
"types": "./dist/
|
|
23
|
+
"./hooks": {
|
|
24
|
+
"types": "./dist/hooks/index.d.mts",
|
|
25
|
+
"import": "./dist/hooks/index.mjs",
|
|
26
|
+
"default": "./dist/hooks/index.mjs"
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
29
|
"files": [
|
|
27
|
-
"!**/*.map",
|
|
28
|
-
"!**/*.tsbuildinfo",
|
|
29
30
|
"dist"
|
|
30
31
|
],
|
|
31
32
|
"peerDependencies": {
|
|
32
|
-
"
|
|
33
|
-
"react": ">=18.3.0",
|
|
34
|
-
"@orpc/client": "0.0.0-next.571d5d7",
|
|
35
|
-
"@orpc/server": "0.0.0-next.571d5d7",
|
|
36
|
-
"@orpc/contract": "0.0.0-next.571d5d7"
|
|
33
|
+
"react": ">=18.0.0"
|
|
37
34
|
},
|
|
38
35
|
"dependencies": {
|
|
39
|
-
"@orpc/
|
|
36
|
+
"@orpc/client": "0.0.0-next.5725903",
|
|
37
|
+
"@orpc/openapi-client": "0.0.0-next.5725903",
|
|
38
|
+
"@orpc/shared": "0.0.0-next.5725903",
|
|
39
|
+
"@orpc/server": "0.0.0-next.5725903",
|
|
40
|
+
"@orpc/contract": "0.0.0-next.5725903"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
+
"react": "^19.2.4",
|
|
44
|
+
"zod": "^4.3.6"
|
|
43
45
|
},
|
|
44
46
|
"scripts": {
|
|
45
|
-
"build": "
|
|
47
|
+
"build": "unbuild",
|
|
46
48
|
"build:watch": "pnpm run build --watch",
|
|
47
49
|
"type:check": "tsc -b"
|
|
48
50
|
}
|