@btravstack/pothos 0.49.0 → 0.50.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 +3 -1
- package/dist/index.d.mts +2 -11
- package/dist/index.mjs +1 -13
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -23,9 +23,11 @@ contract-first services. The default export is the plugin, listed after
|
|
|
23
23
|
contract half on its own.
|
|
24
24
|
|
|
25
25
|
Every dependency is a peer: Pothos plugins and `graphql` each need one copy.
|
|
26
|
+
Install `@btravstack/contract` alongside them; `contractInput` reuses its
|
|
27
|
+
`/orpc` input-schema accessor.
|
|
26
28
|
|
|
27
29
|
```sh
|
|
28
|
-
pnpm add @btravstack/pothos @pothos/core @pothos/plugin-errors @pothos/plugin-relay \
|
|
30
|
+
pnpm add @btravstack/pothos @btravstack/contract @pothos/core @pothos/plugin-errors @pothos/plugin-relay \
|
|
29
31
|
@unthrown/pothos@^0.1.2 graphql unthrown zod \
|
|
30
32
|
@orpc/client@2.0.0-beta.44 @orpc/contract@2.0.0-beta.44
|
|
31
33
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { AsyncResult } from "unthrown";
|
|
|
3
3
|
import { GraphQLFieldResolver } from "graphql";
|
|
4
4
|
import { ResultConnectionOptions } from "@unthrown/pothos/relay";
|
|
5
5
|
import { CaseOf, Caseable, Refusals, ResultFieldOptions } from "@unthrown/pothos";
|
|
6
|
+
import { contractInputSchema as contractInput } from "@btravstack/contract/orpc";
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
import { AnySchema, ErrorMap, ProcedureContract } from "@orpc/contract";
|
|
8
9
|
import { ConnectionShapeForType, DefaultConnectionArguments } from "@pothos/plugin-relay";
|
|
@@ -20,16 +21,6 @@ declare global {
|
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region src/contract.d.ts
|
|
23
|
-
/**
|
|
24
|
-
* The one Zod schema a procedure's contract declares for its input, typed as
|
|
25
|
-
* declared — to derive a GraphQL argument's shape from it (`.shape`, a
|
|
26
|
-
* `z.preprocess` around it) when the schema is built.
|
|
27
|
-
*
|
|
28
|
-
* A procedure whose contract holds anything but exactly one Zod input schema
|
|
29
|
-
* is a mistake in the schema's source, not a request's: it throws, once, as
|
|
30
|
-
* the schema is built.
|
|
31
|
-
*/
|
|
32
|
-
export declare const contractInput: <Input extends z.ZodType, Output extends AnySchema, Errors extends ErrorMap>(procedure: ProcedureContract<Input, Output, Errors>) => Input;
|
|
33
24
|
declare const InvalidInput_base: import("unthrown").TaggedErrorConstructor<"InvalidInput">;
|
|
34
25
|
/**
|
|
35
26
|
* An input the procedure's contract refuses, caught before the procedure is
|
|
@@ -165,4 +156,4 @@ export declare const procedureErrors: (registry: Readonly<Record<string, ErrorCl
|
|
|
165
156
|
readonly types: (new (...args: never[]) => Error)[];
|
|
166
157
|
};
|
|
167
158
|
//#endregion
|
|
168
|
-
export { type ProcedureConnectionOptions, type ProcedureFieldOptions, pluginName as default };
|
|
159
|
+
export { type ProcedureConnectionOptions, type ProcedureFieldOptions, contractInput, pluginName as default };
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { GraphQLError } from "graphql";
|
|
|
4
4
|
import { ORPCError } from "@orpc/client";
|
|
5
5
|
import "@unthrown/pothos/relay";
|
|
6
6
|
import { outcomeOf } from "@unthrown/pothos";
|
|
7
|
+
import { contractInputSchema as contractInput } from "@btravstack/contract/orpc";
|
|
7
8
|
import { z } from "zod";
|
|
8
9
|
//#region src/access-refusal.ts
|
|
9
10
|
const accessMarker = Symbol("AccessRefusal");
|
|
@@ -21,19 +22,6 @@ const accessRefusal = (cause) => {
|
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region src/contract.ts
|
|
23
24
|
/**
|
|
24
|
-
* The one Zod schema a procedure's contract declares for its input, typed as
|
|
25
|
-
* declared — to derive a GraphQL argument's shape from it (`.shape`, a
|
|
26
|
-
* `z.preprocess` around it) when the schema is built.
|
|
27
|
-
*
|
|
28
|
-
* A procedure whose contract holds anything but exactly one Zod input schema
|
|
29
|
-
* is a mistake in the schema's source, not a request's: it throws, once, as
|
|
30
|
-
* the schema is built.
|
|
31
|
-
*/
|
|
32
|
-
const contractInput = (procedure) => {
|
|
33
|
-
const [schema] = z.tuple([z.custom((value) => value instanceof z.ZodType)]).parse(procedure["~orpc"].inputSchemas);
|
|
34
|
-
return schema;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
25
|
* An input the procedure's contract refuses, caught before the procedure is
|
|
38
26
|
* called: each of the contract's issues, with its message and path.
|
|
39
27
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btravstack/pothos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Pothos fields that call oRPC procedures, each declared error answered as a typed GraphQL refusal",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@btravstack/contract": "0.50.0",
|
|
43
44
|
"@btravstack/tsconfig": "0.4.0",
|
|
44
45
|
"@orpc/client": "2.0.0-beta.44",
|
|
45
46
|
"@orpc/contract": "2.0.0-beta.44",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"zod": "4.6.7"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
65
|
+
"@btravstack/contract": "^0.50.0",
|
|
64
66
|
"@orpc/client": "^2.0.0-beta.28",
|
|
65
67
|
"@orpc/contract": "^2.0.0-beta.28",
|
|
66
68
|
"@pothos/core": "^4.15.0",
|