@trpc-panel/core 1.0.0 → 1.0.2
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 +4 -4
- package/lib/index.js +9 -1
- package/lib/index.mjs +9 -1
- package/lib/src/parse/routerType.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,13 +25,13 @@ Check out our [test app](https://app.trpcpanel.io)
|
|
|
25
25
|
Install with your preferred package manager:
|
|
26
26
|
|
|
27
27
|
```sh
|
|
28
|
-
|
|
28
|
+
npm install @trpc-panel/core
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
render your panel and return it from your backend (express example):
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
|
-
import { renderTrpcPanel } from "trpc-panel";
|
|
34
|
+
import { renderTrpcPanel } from "@trpc-panel/core";
|
|
35
35
|
// ...
|
|
36
36
|
app.use("/panel", (_, res) => {
|
|
37
37
|
return res.send(
|
|
@@ -48,7 +48,7 @@ In Nextjs you'd want to create an api route somewhere like `src/pages/api/panel.
|
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
51
|
-
import { renderTrpcPanel } from "trpc-panel";
|
|
51
|
+
import { renderTrpcPanel } from "@trpc-panel/core";
|
|
52
52
|
import { appRouter } from "../../server/api/root";
|
|
53
53
|
|
|
54
54
|
export default async function handler(_: NextApiRequest, res: NextApiResponse) {
|
|
@@ -77,7 +77,7 @@ Documentation is opt-in, meaning you only need to set it up if you want to use i
|
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
79
|
import { initTRPC } from "@trpc/server";
|
|
80
|
-
import { TRPCPanelMeta } from "trpc-panel";
|
|
80
|
+
import { TRPCPanelMeta } from "@trpc-panel/core";
|
|
81
81
|
|
|
82
82
|
const t = initTRPC.meta<TRPCPanelMeta>().create();
|
|
83
83
|
```
|
package/lib/index.js
CHANGED
|
@@ -64,7 +64,15 @@ const RouterSchema = zod.z.object({
|
|
|
64
64
|
_def: RouterDefSchema,
|
|
65
65
|
});
|
|
66
66
|
function isRouter(obj) {
|
|
67
|
-
|
|
67
|
+
if (RouterSchema.safeParse(obj).success)
|
|
68
|
+
return true;
|
|
69
|
+
if (typeof obj === "object" &&
|
|
70
|
+
obj !== null &&
|
|
71
|
+
!isProcedure(obj) &&
|
|
72
|
+
!Array.isArray(obj)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
68
76
|
}
|
|
69
77
|
zod.z.object({
|
|
70
78
|
_def: ProcedureDefSchema,
|
package/lib/index.mjs
CHANGED
|
@@ -61,7 +61,15 @@ const RouterSchema = z.object({
|
|
|
61
61
|
_def: RouterDefSchema,
|
|
62
62
|
});
|
|
63
63
|
function isRouter(obj) {
|
|
64
|
-
|
|
64
|
+
if (RouterSchema.safeParse(obj).success)
|
|
65
|
+
return true;
|
|
66
|
+
if (typeof obj === "object" &&
|
|
67
|
+
obj !== null &&
|
|
68
|
+
!isProcedure(obj) &&
|
|
69
|
+
!Array.isArray(obj)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
65
73
|
}
|
|
66
74
|
z.object({
|
|
67
75
|
_def: ProcedureDefSchema,
|