@trpc-panel/core 1.0.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.
Files changed (60) hide show
  1. package/README.md +173 -0
  2. package/lib/index.js +431 -0
  3. package/lib/index.mjs +427 -0
  4. package/lib/react-app/bundle.js +291 -0
  5. package/lib/react-app/bundle.js.map +1 -0
  6. package/lib/react-app/index.css +1076 -0
  7. package/lib/react-app/index.html +16 -0
  8. package/lib/src/index.d.ts +3 -0
  9. package/lib/src/meta.d.ts +9 -0
  10. package/lib/src/parse/__tests__/parseProcedure.test.d.ts +1 -0
  11. package/lib/src/parse/__tests__/parseRouter.test.d.ts +1 -0
  12. package/lib/src/parse/__tests__/utils/router.d.ts +159 -0
  13. package/lib/src/parse/__tests__/utils/schemas.d.ts +7 -0
  14. package/lib/src/parse/input-mappers/__tests__/zod/array.test.d.ts +1 -0
  15. package/lib/src/parse/input-mappers/__tests__/zod/bigint.test.d.ts +1 -0
  16. package/lib/src/parse/input-mappers/__tests__/zod/boolean.test.d.ts +1 -0
  17. package/lib/src/parse/input-mappers/__tests__/zod/branded.test.d.ts +1 -0
  18. package/lib/src/parse/input-mappers/__tests__/zod/default.test.d.ts +1 -0
  19. package/lib/src/parse/input-mappers/__tests__/zod/discriminatedUnion.test.d.ts +1 -0
  20. package/lib/src/parse/input-mappers/__tests__/zod/effects.test.d.ts +1 -0
  21. package/lib/src/parse/input-mappers/__tests__/zod/enum.test.d.ts +1 -0
  22. package/lib/src/parse/input-mappers/__tests__/zod/literal.test.d.ts +1 -0
  23. package/lib/src/parse/input-mappers/__tests__/zod/null.test.d.ts +1 -0
  24. package/lib/src/parse/input-mappers/__tests__/zod/nullable.test.d.ts +1 -0
  25. package/lib/src/parse/input-mappers/__tests__/zod/number.test.d.ts +1 -0
  26. package/lib/src/parse/input-mappers/__tests__/zod/object.test.d.ts +1 -0
  27. package/lib/src/parse/input-mappers/__tests__/zod/optional.test.d.ts +1 -0
  28. package/lib/src/parse/input-mappers/__tests__/zod/promise.test.d.ts +1 -0
  29. package/lib/src/parse/input-mappers/__tests__/zod/string.test.d.ts +1 -0
  30. package/lib/src/parse/input-mappers/__tests__/zod/undefined.test.d.ts +1 -0
  31. package/lib/src/parse/input-mappers/__tests__/zod/void.test.d.ts +1 -0
  32. package/lib/src/parse/input-mappers/defaultReferences.d.ts +2 -0
  33. package/lib/src/parse/input-mappers/zod/parsers/parseZodArrayDef.d.ts +3 -0
  34. package/lib/src/parse/input-mappers/zod/parsers/parseZodBigIntDef.d.ts +3 -0
  35. package/lib/src/parse/input-mappers/zod/parsers/parseZodBooleanFieldDef.d.ts +3 -0
  36. package/lib/src/parse/input-mappers/zod/parsers/parseZodBrandedDef.d.ts +3 -0
  37. package/lib/src/parse/input-mappers/zod/parsers/parseZodDefaultDef.d.ts +3 -0
  38. package/lib/src/parse/input-mappers/zod/parsers/parseZodDiscriminatedUnionDef.d.ts +16 -0
  39. package/lib/src/parse/input-mappers/zod/parsers/parseZodEffectsDef.d.ts +3 -0
  40. package/lib/src/parse/input-mappers/zod/parsers/parseZodEnumDef.d.ts +3 -0
  41. package/lib/src/parse/input-mappers/zod/parsers/parseZodLiteralDef.d.ts +3 -0
  42. package/lib/src/parse/input-mappers/zod/parsers/parseZodNullDef.d.ts +3 -0
  43. package/lib/src/parse/input-mappers/zod/parsers/parseZodNullableDef.d.ts +3 -0
  44. package/lib/src/parse/input-mappers/zod/parsers/parseZodNumberDef.d.ts +3 -0
  45. package/lib/src/parse/input-mappers/zod/parsers/parseZodObjectDef.d.ts +3 -0
  46. package/lib/src/parse/input-mappers/zod/parsers/parseZodOptionalDef.d.ts +3 -0
  47. package/lib/src/parse/input-mappers/zod/parsers/parseZodPromiseDef.d.ts +3 -0
  48. package/lib/src/parse/input-mappers/zod/parsers/parseZodStringDef.d.ts +3 -0
  49. package/lib/src/parse/input-mappers/zod/parsers/parseZodUndefinedDef.d.ts +3 -0
  50. package/lib/src/parse/input-mappers/zod/parsers/parseZodVoidDef.d.ts +3 -0
  51. package/lib/src/parse/input-mappers/zod/selector.d.ts +3 -0
  52. package/lib/src/parse/input-mappers/zod/zod-types.d.ts +4 -0
  53. package/lib/src/parse/parseErrorLogs.d.ts +1 -0
  54. package/lib/src/parse/parseNodeTypes.d.ts +61 -0
  55. package/lib/src/parse/parseProcedure.d.ts +18 -0
  56. package/lib/src/parse/parseRouter.d.ts +21 -0
  57. package/lib/src/parse/routerType.d.ts +486 -0
  58. package/lib/src/parse/utils.d.ts +2 -0
  59. package/lib/src/render.d.ts +7 -0
  60. package/package.json +100 -0
@@ -0,0 +1,16 @@
1
+ <!doctype html>
2
+ <html class="h-full" lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>tRPC.panel()</title>
7
+ {{css}}
8
+ </head>
9
+ <body class="h-full">
10
+ <noscript>
11
+ You need to enable JavaScript to run this app.
12
+ </noscript>
13
+ <div class="flex flex-1 w-full h-full" id="root"></div>
14
+ {{js}}
15
+ </body>
16
+ </html>
@@ -0,0 +1,3 @@
1
+ export { renderTrpcPanel as renderTrpcPanel } from "./render";
2
+ export type { TRPCPanelMeta } from "./meta";
3
+ export { parseRouterWithOptions } from "./parse/parseRouter";
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export declare const TRPCPanelMetaSchema: z.ZodObject<{
3
+ description: z.ZodOptional<z.ZodString>;
4
+ }, "strip", z.ZodTypeAny, {
5
+ description?: string | undefined;
6
+ }, {
7
+ description?: string | undefined;
8
+ }>;
9
+ export type TRPCPanelMeta = z.infer<typeof TRPCPanelMetaSchema>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,159 @@
1
+ import { ObjectNode } from "@src/parse/parseNodeTypes";
2
+ import { z } from "zod";
3
+ import { ParsedProcedure } from "@src/parse/parseProcedure";
4
+ export declare const testTrpcInstance: import("@trpc/server").TRPCRootObject<object, {
5
+ description?: string | undefined;
6
+ }, {}, {
7
+ ctx: object;
8
+ meta: {
9
+ description?: string | undefined;
10
+ };
11
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
12
+ transformer: false;
13
+ }>;
14
+ export declare const parseTestRouterInputSchema: z.ZodObject<{
15
+ id: z.ZodString;
16
+ age: z.ZodNumber;
17
+ expectedAgeOfDeath: z.ZodOptional<z.ZodNumber>;
18
+ object: z.ZodObject<{
19
+ nestedId: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ nestedId: string;
22
+ }, {
23
+ nestedId: string;
24
+ }>;
25
+ du: z.ZodDiscriminatedUnion<"d", [z.ZodObject<{
26
+ d: z.ZodLiteral<"one">;
27
+ oneProps: z.ZodString;
28
+ }, "strip", z.ZodTypeAny, {
29
+ d: "one";
30
+ oneProps: string;
31
+ }, {
32
+ d: "one";
33
+ oneProps: string;
34
+ }>, z.ZodObject<{
35
+ d: z.ZodLiteral<"two">;
36
+ }, "strip", z.ZodTypeAny, {
37
+ d: "two";
38
+ }, {
39
+ d: "two";
40
+ }>]>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ object: {
43
+ nestedId: string;
44
+ };
45
+ id: string;
46
+ age: number;
47
+ du: {
48
+ d: "one";
49
+ oneProps: string;
50
+ } | {
51
+ d: "two";
52
+ };
53
+ expectedAgeOfDeath?: number | undefined;
54
+ }, {
55
+ object: {
56
+ nestedId: string;
57
+ };
58
+ id: string;
59
+ age: number;
60
+ du: {
61
+ d: "one";
62
+ oneProps: string;
63
+ } | {
64
+ d: "two";
65
+ };
66
+ expectedAgeOfDeath?: number | undefined;
67
+ }>;
68
+ export declare const expectedTestRouterInputParsedNode: ObjectNode;
69
+ export declare const testQueryExpectedParseResult: ParsedProcedure;
70
+ export declare const testMutationExpectedParseResult: ParsedProcedure;
71
+ export declare const testQuery: import("@trpc/server").TRPCQueryProcedure<{
72
+ input: {
73
+ object: {
74
+ nestedId: string;
75
+ };
76
+ id: string;
77
+ age: number;
78
+ du: {
79
+ d: "one";
80
+ oneProps: string;
81
+ } | {
82
+ d: "two";
83
+ };
84
+ expectedAgeOfDeath?: number | undefined;
85
+ };
86
+ output: string;
87
+ meta: {
88
+ description?: string | undefined;
89
+ };
90
+ }>;
91
+ export declare const testMutation: import("@trpc/server").TRPCMutationProcedure<{
92
+ input: {
93
+ object: {
94
+ nestedId: string;
95
+ };
96
+ id: string;
97
+ age: number;
98
+ du: {
99
+ d: "one";
100
+ oneProps: string;
101
+ } | {
102
+ d: "two";
103
+ };
104
+ expectedAgeOfDeath?: number | undefined;
105
+ };
106
+ output: string;
107
+ meta: {
108
+ description?: string | undefined;
109
+ };
110
+ }>;
111
+ export declare const parseTestRouter: import("@trpc/server").TRPCBuiltRouter<{
112
+ ctx: object;
113
+ meta: {
114
+ description?: string | undefined;
115
+ };
116
+ errorShape: import("@trpc/server").TRPCDefaultErrorShape;
117
+ transformer: false;
118
+ }, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
119
+ testQuery: import("@trpc/server").TRPCQueryProcedure<{
120
+ input: {
121
+ object: {
122
+ nestedId: string;
123
+ };
124
+ id: string;
125
+ age: number;
126
+ du: {
127
+ d: "one";
128
+ oneProps: string;
129
+ } | {
130
+ d: "two";
131
+ };
132
+ expectedAgeOfDeath?: number | undefined;
133
+ };
134
+ output: string;
135
+ meta: {
136
+ description?: string | undefined;
137
+ };
138
+ }>;
139
+ testMutation: import("@trpc/server").TRPCMutationProcedure<{
140
+ input: {
141
+ object: {
142
+ nestedId: string;
143
+ };
144
+ id: string;
145
+ age: number;
146
+ du: {
147
+ d: "one";
148
+ oneProps: string;
149
+ } | {
150
+ d: "two";
151
+ };
152
+ expectedAgeOfDeath?: number | undefined;
153
+ };
154
+ output: string;
155
+ meta: {
156
+ description?: string | undefined;
157
+ };
158
+ }>;
159
+ }>>;
@@ -0,0 +1,7 @@
1
+ import { ParsedInputNode } from "@src/parse/parseNodeTypes";
2
+ import { ZodSchema } from "zod";
3
+ export declare const testEnumValues: readonly ["a", "b", "c"];
4
+ export declare const testSchemas: {
5
+ schema: ZodSchema;
6
+ parsed: ParsedInputNode;
7
+ }[];
@@ -0,0 +1,2 @@
1
+ import { ParseReferences } from "@src/parse/parseNodeTypes";
2
+ export declare function defaultReferences(): ParseReferences;
@@ -0,0 +1,3 @@
1
+ import { ZodArrayDef } from "zod";
2
+ import { ArrayNode, ParseFunction } from "../../../parseNodeTypes";
3
+ export declare const parseZodArrayDef: ParseFunction<ZodArrayDef, ArrayNode>;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodBigIntDef } from "zod";
3
+ export declare function parseZodBigIntDef(def: ZodBigIntDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { ZodBooleanDef } from "zod";
2
+ import { BooleanNode, ParseFunction } from "../../../parseNodeTypes";
3
+ export declare const parseZodBooleanFieldDef: ParseFunction<ZodBooleanDef, BooleanNode>;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { AnyZodObject, ZodBrandedDef } from "zod";
3
+ export declare function parseZodBrandedDef(def: ZodBrandedDef<AnyZodObject>, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodDefaultDef } from "zod";
3
+ export declare function parseZodDefaultDef(def: ZodDefaultDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,16 @@
1
+ import { AnyZodObject } from "zod";
2
+ import { DiscriminatedUnionNode, ParseFunction } from "../../../parseNodeTypes";
3
+ type OptionsMap = Map<string, AnyZodObject>;
4
+ type ZodDiscriminatedUnionThreePointTwenty = {
5
+ optionsMap: OptionsMap;
6
+ discriminator: string;
7
+ description?: string;
8
+ };
9
+ type ZodDiscriminatedUnionPreThreePointTwenty = {
10
+ options: OptionsMap;
11
+ discriminator: string;
12
+ description?: string;
13
+ };
14
+ export type ZodDiscriminatedUnionDefUnversioned = ZodDiscriminatedUnionPreThreePointTwenty | ZodDiscriminatedUnionThreePointTwenty;
15
+ export declare const parseZodDiscriminatedUnionDef: ParseFunction<ZodDiscriminatedUnionDefUnversioned, DiscriminatedUnionNode>;
16
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodEffectsDef } from "zod";
3
+ export declare function parseZodEffectsDef(def: ZodEffectsDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { ZodEnumDef } from "zod";
2
+ import { EnumNode, ParseFunction } from "../../../parseNodeTypes";
3
+ export declare const parseZodEnumDef: ParseFunction<ZodEnumDef, EnumNode>;
@@ -0,0 +1,3 @@
1
+ import { ZodLiteralDef } from "zod";
2
+ import { LiteralNode, ParseFunction } from "../../../parseNodeTypes";
3
+ export declare const parseZodLiteralDef: ParseFunction<ZodLiteralDef, LiteralNode>;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodNullDef } from "zod";
3
+ export declare function parseZodNullDef(def: ZodNullDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodNullableDef } from "zod";
3
+ export declare function parseZodNullableDef(def: ZodNullableDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { NumberNode, ParseFunction } from "../../../parseNodeTypes";
2
+ import { ZodNumberDef } from "zod";
3
+ export declare const parseZodNumberDef: ParseFunction<ZodNumberDef, NumberNode>;
@@ -0,0 +1,3 @@
1
+ import { ZodObjectDef } from "zod";
2
+ import { ObjectNode, ParseFunction, UnsupportedNode } from "../../../parseNodeTypes";
3
+ export declare const parseZodObjectDef: ParseFunction<ZodObjectDef, ObjectNode | UnsupportedNode>;
@@ -0,0 +1,3 @@
1
+ import { ZodOptionalDef } from "zod";
2
+ import { ParsedInputNode, ParseFunction } from "../../../parseNodeTypes";
3
+ export declare const parseZodOptionalDef: ParseFunction<ZodOptionalDef, ParsedInputNode>;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodPromiseDef } from "zod";
3
+ export declare function parseZodPromiseDef(def: ZodPromiseDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { ParseFunction, StringNode } from "../../../parseNodeTypes";
2
+ import { ZodStringDef } from "zod";
3
+ export declare const parseZodStringDef: ParseFunction<ZodStringDef, StringNode>;
@@ -0,0 +1,3 @@
1
+ import { ParsedInputNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodUndefinedDef } from "zod";
3
+ export declare function parseZodUndefinedDef(def: ZodUndefinedDef, refs: ParseReferences): ParsedInputNode;
@@ -0,0 +1,3 @@
1
+ import { LiteralNode, ParseReferences } from "@src/parse/parseNodeTypes";
2
+ import { ZodVoidDef } from "zod";
3
+ export declare function parseZodVoidDef(_: ZodVoidDef, refs: ParseReferences): LiteralNode;
@@ -0,0 +1,3 @@
1
+ import { ParserSelectorFunction } from "../../parseNodeTypes";
2
+ import { ZodDefWithType } from "./zod-types";
3
+ export declare const zodSelectorFunction: ParserSelectorFunction<ZodDefWithType>;
@@ -0,0 +1,4 @@
1
+ import { ZodFirstPartyTypeKind, ZodTypeDef } from "zod";
2
+ export type ZodDefWithType = ZodTypeDef & {
3
+ typeName: ZodFirstPartyTypeKind;
4
+ };
@@ -0,0 +1 @@
1
+ export declare function logParseError(procedurePath: string, error: string): void;
@@ -0,0 +1,61 @@
1
+ import { ZodTypeDef } from "zod";
2
+ import { ZodDiscriminatedUnionDefUnversioned } from "./input-mappers/zod/parsers/parseZodDiscriminatedUnionDef";
3
+ import { TrpcPanelExtraOptions } from "./parseRouter";
4
+ export type SharedInputNodeProperties = {
5
+ path: (string | number)[];
6
+ optional?: true;
7
+ };
8
+ type InputNodeTypes = ZodTypeDef | ZodDiscriminatedUnionDefUnversioned;
9
+ export type ArrayNode = {
10
+ type: "array";
11
+ childType: ParsedInputNode;
12
+ } & SharedInputNodeProperties;
13
+ export type ObjectNode = {
14
+ type: "object";
15
+ children: {
16
+ [name: string]: ParsedInputNode;
17
+ };
18
+ } & SharedInputNodeProperties;
19
+ export type EnumNode = {
20
+ type: "enum";
21
+ enumValues: string[];
22
+ } & SharedInputNodeProperties;
23
+ export type DiscriminatedUnionNode = {
24
+ type: "discriminated-union";
25
+ discriminatedUnionValues: string[];
26
+ discriminatedUnionChildrenMap: {
27
+ [value: string]: ObjectNode;
28
+ };
29
+ discriminatorName: string;
30
+ } & SharedInputNodeProperties;
31
+ export type LiteralNode = {
32
+ type: "literal";
33
+ value: string | boolean | number | bigint | null | undefined;
34
+ } & SharedInputNodeProperties;
35
+ export type StringNode = {
36
+ type: "string";
37
+ } & SharedInputNodeProperties;
38
+ export type NumberNode = {
39
+ type: "number";
40
+ } & SharedInputNodeProperties;
41
+ export type BooleanNode = {
42
+ type: "boolean";
43
+ } & SharedInputNodeProperties;
44
+ export type UnsupportedNode = {
45
+ type: "unsupported";
46
+ } & SharedInputNodeProperties;
47
+ export type ParsedInputNode = ArrayNode | ObjectNode | EnumNode | DiscriminatedUnionNode | LiteralNode | StringNode | NumberNode | BooleanNode | UnsupportedNode;
48
+ export type AddDataFunctions = {
49
+ addDescriptionIfExists: (def: {
50
+ description?: string;
51
+ }, refs: ParseReferences) => void;
52
+ };
53
+ export type ParseReferences = {
54
+ path: string[];
55
+ optional?: true;
56
+ options: TrpcPanelExtraOptions;
57
+ addDataFunctions: AddDataFunctions;
58
+ };
59
+ export type ParseFunction<InputNodeType extends InputNodeTypes, ParsedNodeType extends ParsedInputNode> = (def: InputNodeType, references: ParseReferences) => ParsedNodeType;
60
+ export type ParserSelectorFunction<InputNodeType extends InputNodeTypes> = (inputNode: InputNodeType, references: ParseReferences) => ParsedInputNode;
61
+ export {};
@@ -0,0 +1,18 @@
1
+ import { Procedure } from "./routerType";
2
+ import { JSON7SchemaType, ProcedureType, TrpcPanelExtraOptions } from "./parseRouter";
3
+ import { ParsedInputNode } from "@src/parse/parseNodeTypes";
4
+ export type ProcedureExtraData = {
5
+ parameterDescriptions: {
6
+ [path: string]: string;
7
+ };
8
+ description?: string;
9
+ };
10
+ export type ParsedProcedure = {
11
+ inputSchema: JSON7SchemaType;
12
+ node: ParsedInputNode;
13
+ nodeType: "procedure";
14
+ procedureType: ProcedureType;
15
+ pathFromRootRouter: string[];
16
+ extraData: ProcedureExtraData;
17
+ };
18
+ export declare function parseProcedure(procedure: Procedure, path: string[], options: TrpcPanelExtraOptions): ParsedProcedure | null;
@@ -0,0 +1,21 @@
1
+ import { AnyRouter as TRPCRouter } from "@trpc/server";
2
+ import { zodToJsonSchema } from "zod-to-json-schema";
3
+ import { ParsedProcedure } from "./parseProcedure";
4
+ export type JSON7SchemaType = ReturnType<typeof zodToJsonSchema>;
5
+ export type ProcedureType = "query" | "mutation" | "subscription";
6
+ export type ParsedRouterChildren = {
7
+ [key: string]: ParsedRouter | ParsedProcedure;
8
+ };
9
+ export type ParsedRouter = {
10
+ children: ParsedRouterChildren;
11
+ path: string[];
12
+ nodeType: "router";
13
+ };
14
+ export type ParseRouterRefs = {
15
+ path: string[];
16
+ };
17
+ export type TrpcPanelExtraOptions = {
18
+ logFailedProcedureParse?: boolean;
19
+ transformer?: "superjson";
20
+ };
21
+ export declare function parseRouterWithOptions(router: TRPCRouter, parseRouterOptions: TrpcPanelExtraOptions): ParsedRouter;