protoc-gen-pothos 0.3.2 → 0.3.3
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/LICENSE +21 -0
- package/README.md +50 -1
- package/package.json +16 -10
- package/lib/dslgen/index.d.ts +0 -2
- package/lib/dslgen/index.d.ts.map +0 -1
- package/lib/dslgen/index.js +0 -17
- package/lib/dslgen/printers/enumType.d.ts +0 -16
- package/lib/dslgen/printers/enumType.d.ts.map +0 -1
- package/lib/dslgen/printers/enumType.js +0 -40
- package/lib/dslgen/printers/field.d.ts +0 -41
- package/lib/dslgen/printers/field.d.ts.map +0 -1
- package/lib/dslgen/printers/field.js +0 -99
- package/lib/dslgen/printers/fieldResolver/enumFieldResolver.d.ts +0 -20
- package/lib/dslgen/printers/fieldResolver/enumFieldResolver.d.ts.map +0 -1
- package/lib/dslgen/printers/fieldResolver/enumFieldResolver.js +0 -61
- package/lib/dslgen/printers/fieldResolver/nonNullResolver.d.ts +0 -3
- package/lib/dslgen/printers/fieldResolver/nonNullResolver.d.ts.map +0 -1
- package/lib/dslgen/printers/fieldResolver/nonNullResolver.js +0 -10
- package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts +0 -14
- package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts.map +0 -1
- package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.js +0 -45
- package/lib/dslgen/printers/index.d.ts +0 -5
- package/lib/dslgen/printers/index.d.ts.map +0 -1
- package/lib/dslgen/printers/index.js +0 -28
- package/lib/dslgen/printers/inputObjectType.d.ts +0 -19
- package/lib/dslgen/printers/inputObjectType.d.ts.map +0 -1
- package/lib/dslgen/printers/inputObjectType.js +0 -59
- package/lib/dslgen/printers/objectType.d.ts +0 -15
- package/lib/dslgen/printers/objectType.d.ts.map +0 -1
- package/lib/dslgen/printers/objectType.js +0 -50
- package/lib/dslgen/printers/oneofUnionType.d.ts +0 -14
- package/lib/dslgen/printers/oneofUnionType.d.ts.map +0 -1
- package/lib/dslgen/printers/oneofUnionType.js +0 -27
- package/lib/dslgen/printers/util.d.ts +0 -12
- package/lib/dslgen/printers/util.d.ts.map +0 -1
- package/lib/dslgen/printers/util.js +0 -69
- package/lib/printer.d.ts +0 -11
- package/lib/printer.d.ts.map +0 -1
- package/lib/printer.js +0 -34
- package/lib/process.d.ts +0 -2
- package/lib/process.d.ts.map +0 -1
- package/lib/process.js +0 -6
- package/lib/protoc-gen-pothos.d.ts +0 -2
- package/lib/protoc-gen-pothos.d.ts.map +0 -1
- package/lib/protoc-gen-pothos.js +0 -5
- package/module/dslgen/index.d.ts +0 -2
- package/module/dslgen/index.d.ts.map +0 -1
- package/module/dslgen/index.js +0 -1
- package/module/dslgen/printers/enumType.d.ts +0 -16
- package/module/dslgen/printers/enumType.d.ts.map +0 -1
- package/module/dslgen/printers/enumType.js +0 -36
- package/module/dslgen/printers/field.d.ts +0 -41
- package/module/dslgen/printers/field.d.ts.map +0 -1
- package/module/dslgen/printers/field.js +0 -94
- package/module/dslgen/printers/fieldResolver/enumFieldResolver.d.ts +0 -20
- package/module/dslgen/printers/fieldResolver/enumFieldResolver.d.ts.map +0 -1
- package/module/dslgen/printers/fieldResolver/enumFieldResolver.js +0 -57
- package/module/dslgen/printers/fieldResolver/nonNullResolver.d.ts +0 -3
- package/module/dslgen/printers/fieldResolver/nonNullResolver.d.ts.map +0 -1
- package/module/dslgen/printers/fieldResolver/nonNullResolver.js +0 -6
- package/module/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts +0 -14
- package/module/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts.map +0 -1
- package/module/dslgen/printers/fieldResolver/oneofUnionResolver.js +0 -41
- package/module/dslgen/printers/index.d.ts +0 -5
- package/module/dslgen/printers/index.d.ts.map +0 -1
- package/module/dslgen/printers/index.js +0 -24
- package/module/dslgen/printers/inputObjectType.d.ts +0 -19
- package/module/dslgen/printers/inputObjectType.d.ts.map +0 -1
- package/module/dslgen/printers/inputObjectType.js +0 -55
- package/module/dslgen/printers/objectType.d.ts +0 -15
- package/module/dslgen/printers/objectType.d.ts.map +0 -1
- package/module/dslgen/printers/objectType.js +0 -46
- package/module/dslgen/printers/oneofUnionType.d.ts +0 -14
- package/module/dslgen/printers/oneofUnionType.d.ts.map +0 -1
- package/module/dslgen/printers/oneofUnionType.js +0 -23
- package/module/dslgen/printers/util.d.ts +0 -12
- package/module/dslgen/printers/util.d.ts.map +0 -1
- package/module/dslgen/printers/util.js +0 -37
- package/module/printer.d.ts +0 -11
- package/module/printer.d.ts.map +0 -1
- package/module/printer.js +0 -30
- package/module/process.d.ts +0 -2
- package/module/process.d.ts.map +0 -1
- package/module/process.js +0 -3
- package/module/protoc-gen-pothos.d.ts +0 -2
- package/module/protoc-gen-pothos.d.ts.map +0 -1
- package/module/protoc-gen-pothos.js +0 -3
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ObjectField, ObjectOneofField, } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { code, joinCode } from "ts-poet";
|
|
3
|
-
/**
|
|
4
|
-
* @example nullable
|
|
5
|
-
* ```ts
|
|
6
|
-
* const value = source.v1 ?? source.v2 ?? source.v3;
|
|
7
|
-
* if (value != null) {
|
|
8
|
-
* throw new Error("...");
|
|
9
|
-
* }
|
|
10
|
-
* return value
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export function createOneofUnionResolverCode(sourceExpr, field) {
|
|
14
|
-
const createBlockStmtCode = (sourceExpr, { nullable }) => {
|
|
15
|
-
const createFieldExpr = (memberField) => {
|
|
16
|
-
if (field instanceof ObjectOneofField) {
|
|
17
|
-
return code `${sourceExpr}.${memberField.proto.jsonName}`;
|
|
18
|
-
}
|
|
19
|
-
return code `${sourceExpr}?.${memberField.proto.jsonName}`;
|
|
20
|
-
};
|
|
21
|
-
return code `
|
|
22
|
-
const value = ${joinCode(field.type.fields.map(createFieldExpr), {
|
|
23
|
-
on: "??",
|
|
24
|
-
})};
|
|
25
|
-
if (value == null) {
|
|
26
|
-
${nullable
|
|
27
|
-
? "return null"
|
|
28
|
-
: `throw new Error("${field.name} should not be null")`};
|
|
29
|
-
}
|
|
30
|
-
return value;
|
|
31
|
-
`;
|
|
32
|
-
};
|
|
33
|
-
if (field instanceof ObjectField && field.isList()) {
|
|
34
|
-
return code `
|
|
35
|
-
return ${sourceExpr}.map(item => {
|
|
36
|
-
${createBlockStmtCode(code `item`, { nullable: false })}
|
|
37
|
-
})
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
return createBlockStmtCode(sourceExpr, { nullable: field.isNullable() });
|
|
41
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EnumType, InputObjectType, ObjectType, OneofUnionType, SquashedOneofUnionType } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { Code } from "ts-poet";
|
|
3
|
-
import { PothosPrinterOptions } from "./util";
|
|
4
|
-
export declare function createTypeDslCodes(types: (ObjectType | InputObjectType | EnumType | OneofUnionType | SquashedOneofUnionType)[], opts: PothosPrinterOptions): Code[];
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,UAAU,EACV,cAAc,EACd,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAM/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE9C,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,CACH,UAAU,GACV,eAAe,GACf,QAAQ,GACR,cAAc,GACd,sBAAsB,CACzB,EAAE,EACH,IAAI,EAAE,oBAAoB,GACzB,IAAI,EAAE,CAqBR"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { EnumType, InputObjectType, ObjectType, OneofUnionType, SquashedOneofUnionType, } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { createEnumTypeCode } from "./enumType";
|
|
3
|
-
import { createInputObjectTypeCode } from "./inputObjectType";
|
|
4
|
-
import { createObjectTypeCode } from "./objectType";
|
|
5
|
-
import { createOneofUnionTypeCode } from "./oneofUnionType";
|
|
6
|
-
export function createTypeDslCodes(types, opts) {
|
|
7
|
-
return types.flatMap((type) => {
|
|
8
|
-
if (type instanceof ObjectType) {
|
|
9
|
-
return createObjectTypeCode(type, opts);
|
|
10
|
-
}
|
|
11
|
-
if (type instanceof InputObjectType) {
|
|
12
|
-
return createInputObjectTypeCode(type, opts);
|
|
13
|
-
}
|
|
14
|
-
if (type instanceof EnumType) {
|
|
15
|
-
return [createEnumTypeCode(type, opts)];
|
|
16
|
-
}
|
|
17
|
-
if (type instanceof OneofUnionType ||
|
|
18
|
-
type instanceof SquashedOneofUnionType) {
|
|
19
|
-
return [createOneofUnionTypeCode(type, opts)];
|
|
20
|
-
}
|
|
21
|
-
const _exhaustiveCheck = type;
|
|
22
|
-
throw "unreachable";
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { InputObjectType } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { Code } from "ts-poet";
|
|
3
|
-
import { PothosPrinterOptions } from "./util";
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* export type HelloInput$Shape = {
|
|
8
|
-
* // ...
|
|
9
|
-
* }
|
|
10
|
-
* export const HelloInput$Ref: pothos.InputObjectRef<Hello$SHape> = builder.inputRef("HelloInput").implement({
|
|
11
|
-
* description: "...",
|
|
12
|
-
* fields: (t) => ({
|
|
13
|
-
* // ...
|
|
14
|
-
* }),
|
|
15
|
-
* })
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function createInputObjectTypeCode(type: InputObjectType, opts: PothosPrinterOptions): Code;
|
|
19
|
-
//# sourceMappingURL=inputObjectType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inputObjectType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/inputObjectType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkC,MAAM,SAAS,CAAC;AAG/D,OAAO,EAGL,oBAAoB,EAGrB,MAAM,QAAQ,CAAC;AAEhB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAkDN"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { compact, InputObjectType, protobufGraphQLExtensions, protoType, } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { code, imp, joinCode, literalOf } from "ts-poet";
|
|
3
|
-
import { createFieldRefCode, createNoopFieldRefCode } from "./field";
|
|
4
|
-
import { fieldTypeShape, pothosBuilder, pothosRef, shapeType, } from "./util";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* export type HelloInput$Shape = {
|
|
9
|
-
* // ...
|
|
10
|
-
* }
|
|
11
|
-
* export const HelloInput$Ref: pothos.InputObjectRef<Hello$SHape> = builder.inputRef("HelloInput").implement({
|
|
12
|
-
* description: "...",
|
|
13
|
-
* fields: (t) => ({
|
|
14
|
-
* // ...
|
|
15
|
-
* }),
|
|
16
|
-
* })
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export function createInputObjectTypeCode(type, opts) {
|
|
20
|
-
const shapeTypeCode = code `
|
|
21
|
-
export type ${shapeType(type)} = {
|
|
22
|
-
${joinCode(type.fields.map((f) => {
|
|
23
|
-
let typeNode;
|
|
24
|
-
if (f.type instanceof InputObjectType) {
|
|
25
|
-
// @ts-expect-error f should be inferred as InputObjectField<InputObjectType>
|
|
26
|
-
typeNode = code `${fieldTypeShape(f, opts)}`;
|
|
27
|
-
if (f.isList())
|
|
28
|
-
typeNode = code `Array<${typeNode}>`;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
typeNode = code `${protoType(type.proto, opts)}[${literalOf(f.proto.jsonName)}]`;
|
|
32
|
-
}
|
|
33
|
-
return f.isNullable()
|
|
34
|
-
? code `${f.name}?: ${typeNode} | null,`
|
|
35
|
-
: code `${f.name}: ${typeNode},`;
|
|
36
|
-
}))}
|
|
37
|
-
};
|
|
38
|
-
`;
|
|
39
|
-
const refCode = code `
|
|
40
|
-
export const ${pothosRef(type)}: ${imp("InputObjectRef@@pothos/core")}<${shapeType(type)}> =
|
|
41
|
-
${pothosBuilder(type, opts)}.inputRef<${shapeType(type)}>(${literalOf(type.typeName)}).implement(
|
|
42
|
-
${literalOf(compact({
|
|
43
|
-
description: type.description,
|
|
44
|
-
fields: code `t => ({${type.fields.length > 0
|
|
45
|
-
? type.fields.map((f) => code `${f.name}: ${createFieldRefCode(f, opts)},`)
|
|
46
|
-
: code `_: ${createNoopFieldRefCode({ input: true })}`}})`,
|
|
47
|
-
extensions: protobufGraphQLExtensions(type),
|
|
48
|
-
}))}
|
|
49
|
-
);
|
|
50
|
-
`;
|
|
51
|
-
return code `
|
|
52
|
-
${shapeTypeCode}
|
|
53
|
-
${refCode}
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ObjectType } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { Code } from "ts-poet";
|
|
3
|
-
import { PothosPrinterOptions } from "./util";
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* export const Hello$Ref = builder.objectRef<_$hello$hello_pb.Hello>("Hello")
|
|
8
|
-
* builder.objectType(Hello$Ref, {
|
|
9
|
-
* name: "Hello",
|
|
10
|
-
* // ...
|
|
11
|
-
* })
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare function createObjectTypeCode(type: ObjectType, opts: PothosPrinterOptions): Code;
|
|
15
|
-
//# sourceMappingURL=objectType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objectType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/objectType.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAGX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAC;AAG1D,OAAO,EAAiB,oBAAoB,EAAa,MAAM,QAAQ,CAAC;AAExE;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAoDN"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { compact, InterfaceType, protobufGraphQLExtensions, protoType, } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { code, joinCode, literalOf } from "ts-poet";
|
|
3
|
-
import { createFieldRefCode, createNoopFieldRefCode } from "./field";
|
|
4
|
-
import { pothosBuilder, pothosRef } from "./util";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* export const Hello$Ref = builder.objectRef<_$hello$hello_pb.Hello>("Hello")
|
|
9
|
-
* builder.objectType(Hello$Ref, {
|
|
10
|
-
* name: "Hello",
|
|
11
|
-
* // ...
|
|
12
|
-
* })
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export function createObjectTypeCode(type, opts) {
|
|
16
|
-
const isInterface = type instanceof InterfaceType;
|
|
17
|
-
const typeOpts = {
|
|
18
|
-
name: type.typeName,
|
|
19
|
-
fields: code `t => ({${type.fields.length > 0
|
|
20
|
-
? joinCode(type.fields.map((f) => code `${f.name}: ${createFieldRefCode(f, opts)},`))
|
|
21
|
-
: code `_: ${createNoopFieldRefCode({ input: false })}`}})`,
|
|
22
|
-
description: type.description,
|
|
23
|
-
isTypeOf: isInterface
|
|
24
|
-
? undefined
|
|
25
|
-
: code `
|
|
26
|
-
(source) => {
|
|
27
|
-
return (source as ${protoType(type.proto, opts)} | { $type: string & {} }).$type
|
|
28
|
-
=== ${literalOf(type.proto.fullName.toString())};
|
|
29
|
-
}
|
|
30
|
-
`,
|
|
31
|
-
extensions: protobufGraphQLExtensions(type),
|
|
32
|
-
};
|
|
33
|
-
const buildRefFunc = code `${pothosBuilder(type, opts)}.${isInterface ? "interface" : "object"}Ref`;
|
|
34
|
-
const buildTypeFunc = code `${pothosBuilder(type, opts)}.${isInterface ? "interface" : "object"}Type`;
|
|
35
|
-
const refFuncTypeArg = isInterface
|
|
36
|
-
? code `
|
|
37
|
-
Pick<
|
|
38
|
-
${protoType(type.proto, opts)},
|
|
39
|
-
${joinCode(type.fields.map((f) => code `${literalOf(f.proto.jsonName)}`), { on: "|" })}
|
|
40
|
-
>`
|
|
41
|
-
: protoType(type.proto, opts);
|
|
42
|
-
return code `
|
|
43
|
-
export const ${pothosRef(type)} = ${buildRefFunc}<${refFuncTypeArg}>(${literalOf(type.typeName)});
|
|
44
|
-
${buildTypeFunc}(${pothosRef(type)}, ${literalOf(compact(typeOpts))});
|
|
45
|
-
`;
|
|
46
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { OneofUnionType, SquashedOneofUnionType } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { Code } from "ts-poet";
|
|
3
|
-
import { PothosPrinterOptions } from "./util";
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* export cosnt Oneof = builder.unionType("Oneof", {
|
|
8
|
-
* types: [...],
|
|
9
|
-
* // ...
|
|
10
|
-
* })
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare function createOneofUnionTypeCode(type: OneofUnionType | SquashedOneofUnionType, opts: PothosPrinterOptions): Code;
|
|
14
|
-
//# sourceMappingURL=oneofUnionType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oneofUnionType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/oneofUnionType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAEd,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAQ,IAAI,EAAa,MAAM,SAAS,CAAC;AAEhD,OAAO,EAAiB,oBAAoB,EAAa,MAAM,QAAQ,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,cAAc,GAAG,sBAAsB,EAC7C,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAYN"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { compact, protobufGraphQLExtensions, } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { code, literalOf } from "ts-poet";
|
|
3
|
-
import { pothosBuilder, pothosRef } from "./util";
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* export cosnt Oneof = builder.unionType("Oneof", {
|
|
8
|
-
* types: [...],
|
|
9
|
-
* // ...
|
|
10
|
-
* })
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export function createOneofUnionTypeCode(type, opts) {
|
|
14
|
-
const typeOpts = {
|
|
15
|
-
types: type.fields.map((f) => pothosRef(f.type)),
|
|
16
|
-
description: type.description,
|
|
17
|
-
extensions: protobufGraphQLExtensions(type),
|
|
18
|
-
};
|
|
19
|
-
return code `
|
|
20
|
-
export const ${pothosRef(type)} =
|
|
21
|
-
${pothosBuilder(type, opts)}.unionType(${literalOf(type.typeName)}, ${literalOf(compact(typeOpts))});
|
|
22
|
-
`;
|
|
23
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EnumType, InputObjectField, InputObjectType, InterfaceType, ObjectField, ObjectOneofField, ObjectType, OneofUnionType, PrinterOptions, SquashedOneofUnionType } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { Code } from "ts-poet";
|
|
3
|
-
export type PothosPrinterOptions = Extract<PrinterOptions, {
|
|
4
|
-
dsl: "pothos";
|
|
5
|
-
}>;
|
|
6
|
-
export declare function pothosRef(type: ObjectType | InputObjectType | EnumType | OneofUnionType | SquashedOneofUnionType | InterfaceType): Code;
|
|
7
|
-
export declare function shapeType(type: InputObjectType): Code;
|
|
8
|
-
export declare function shapeTypeName(type: InputObjectType): string;
|
|
9
|
-
export declare function fieldTypeRef(field: ObjectField<ObjectType | EnumType | InterfaceType | SquashedOneofUnionType> | InputObjectField<InputObjectType | EnumType> | ObjectOneofField, opts: PothosPrinterOptions): Code;
|
|
10
|
-
export declare function fieldTypeShape(field: InputObjectField<InputObjectType>, opts: PothosPrinterOptions): Code;
|
|
11
|
-
export declare function pothosBuilder(type: ObjectType | InputObjectType | EnumType | OneofUnionType | SquashedOneofUnionType, opts: Pick<PothosPrinterOptions, "dsl" | "pothos" | "fileLayout" | "filenameSuffix">): Code;
|
|
12
|
-
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/util.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EAGR,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,cAAc,EACd,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAQ,IAAI,EAAO,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,GAAG,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAE9E,wBAAgB,SAAS,CACvB,IAAI,EACA,UAAU,GACV,eAAe,GACf,QAAQ,GACR,cAAc,GACd,sBAAsB,GACtB,aAAa,GAChB,IAAI,CAEN;AAcD,wBAAgB,SAAS,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAErD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE3D;AAED,wBAAgB,YAAY,CAC1B,KAAK,EACD,WAAW,CACT,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,sBAAsB,CAC/D,GACD,gBAAgB,CAAC,eAAe,GAAG,QAAQ,CAAC,GAC5C,gBAAgB,EACpB,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAON;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,gBAAgB,CAAC,eAAe,CAAC,EACxC,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAON;AAED,wBAAgB,aAAa,CAC3B,IAAI,EACA,UAAU,GACV,eAAe,GACf,QAAQ,GACR,cAAc,GACd,sBAAsB,EAC1B,IAAI,EAAE,IAAI,CACR,oBAAoB,EACpB,KAAK,GAAG,QAAQ,GAAG,YAAY,GAAG,gBAAgB,CACnD,GACA,IAAI,CAKN"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import { filename, generatedGraphQLTypeImportPath, } from "@proto-graphql/codegen-core";
|
|
3
|
-
import { code, imp } from "ts-poet";
|
|
4
|
-
export function pothosRef(type) {
|
|
5
|
-
return code `${pothosRefName(type)}`;
|
|
6
|
-
}
|
|
7
|
-
function pothosRefName(type) {
|
|
8
|
-
return `${type.typeName}$Ref`;
|
|
9
|
-
}
|
|
10
|
-
export function shapeType(type) {
|
|
11
|
-
return code `${shapeTypeName(type)}`;
|
|
12
|
-
}
|
|
13
|
-
export function shapeTypeName(type) {
|
|
14
|
-
return `${type.typeName}$Shape`;
|
|
15
|
-
}
|
|
16
|
-
export function fieldTypeRef(field, opts) {
|
|
17
|
-
const importPath = generatedGraphQLTypeImportPath(field, opts);
|
|
18
|
-
if (importPath == null)
|
|
19
|
-
return pothosRef(field.type);
|
|
20
|
-
const imported = imp(`IMPORTED_PLACEHOLDER@${importPath}`);
|
|
21
|
-
imported.symbol = pothosRefName(field.type); // NOTE: Workaround for ts-poet not recognizing "$" as an identifier
|
|
22
|
-
return code `${imported}`;
|
|
23
|
-
}
|
|
24
|
-
export function fieldTypeShape(field, opts) {
|
|
25
|
-
const importPath = generatedGraphQLTypeImportPath(field, opts);
|
|
26
|
-
if (importPath == null)
|
|
27
|
-
return shapeType(field.type);
|
|
28
|
-
const imported = imp(`IMPORTED_PLACEHOLDER@${importPath}`);
|
|
29
|
-
imported.symbol = shapeTypeName(field.type); // NOTE: Workaround for ts-poet not recognizing "$" as an identifier
|
|
30
|
-
return code `${imported}`;
|
|
31
|
-
}
|
|
32
|
-
export function pothosBuilder(type, opts) {
|
|
33
|
-
const importPath = opts.pothos.builderPath.startsWith(".")
|
|
34
|
-
? path.relative(path.dirname(filename(type, opts)), opts.pothos.builderPath)
|
|
35
|
-
: opts.pothos.builderPath;
|
|
36
|
-
return code `${imp(`builder@${importPath}`)}`;
|
|
37
|
-
}
|
package/module/printer.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TypeOptions } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { ProtoFile, ProtoRegistry } from "@proto-graphql/proto-descriptors";
|
|
3
|
-
import { PothosPrinterOptions } from "./dslgen/printers/util";
|
|
4
|
-
export declare function generateFiles(registry: ProtoRegistry, file: ProtoFile, opts: {
|
|
5
|
-
type: TypeOptions;
|
|
6
|
-
printer: PothosPrinterOptions;
|
|
7
|
-
}): {
|
|
8
|
-
filename: string;
|
|
9
|
-
content: string;
|
|
10
|
-
}[];
|
|
11
|
-
//# sourceMappingURL=printer.d.ts.map
|
package/module/printer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAI5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,GACzD;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAkCzC"}
|
package/module/printer.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { collectTypesFromFile, filename, filenameFromProtoFile, printCodes, } from "@proto-graphql/codegen-core";
|
|
2
|
-
import { createTypeDslCodes } from "./dslgen";
|
|
3
|
-
export function generateFiles(registry, file, opts) {
|
|
4
|
-
opts.printer.protobuf = "ts-proto"; // default
|
|
5
|
-
const types = collectTypesFromFile(file, opts.type, registry);
|
|
6
|
-
switch (opts.printer.fileLayout) {
|
|
7
|
-
case "proto_file": {
|
|
8
|
-
return [
|
|
9
|
-
{
|
|
10
|
-
filename: filenameFromProtoFile(file, opts.printer),
|
|
11
|
-
content: printCodes(createCodes(types, opts.printer), "protoc-gen-pothos", file),
|
|
12
|
-
},
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
case "graphql_type": {
|
|
16
|
-
return types.map((t) => ({
|
|
17
|
-
filename: filename(t, opts.printer),
|
|
18
|
-
content: printCodes(createCodes([t], opts.printer), "protoc-gen-pothos", file),
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
/* istanbul ignore next */
|
|
22
|
-
default: {
|
|
23
|
-
const _exhaustiveCheck = opts.printer.fileLayout;
|
|
24
|
-
throw "unreachable";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function createCodes(types, opts) {
|
|
29
|
-
return [...createTypeDslCodes(types, opts)];
|
|
30
|
-
}
|
package/module/process.d.ts
DELETED
package/module/process.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,gLAAoD,CAAC"}
|
package/module/process.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protoc-gen-pothos.d.ts","sourceRoot":"","sources":["../src/protoc-gen-pothos.ts"],"names":[],"mappings":""}
|