protoc-gen-pothos 0.3.0 → 0.3.1

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 (71) hide show
  1. package/lib/dslgen/index.d.ts +2 -0
  2. package/lib/dslgen/index.d.ts.map +1 -0
  3. package/lib/dslgen/printers/enumType.d.ts +16 -0
  4. package/lib/dslgen/printers/enumType.d.ts.map +1 -0
  5. package/lib/dslgen/printers/field.d.ts +41 -0
  6. package/lib/dslgen/printers/field.d.ts.map +1 -0
  7. package/lib/dslgen/printers/field.js +8 -3
  8. package/lib/dslgen/printers/fieldResolver/enumFieldResolver.d.ts +20 -0
  9. package/lib/dslgen/printers/fieldResolver/enumFieldResolver.d.ts.map +1 -0
  10. package/lib/dslgen/printers/fieldResolver/nonNullResolver.d.ts +3 -0
  11. package/lib/dslgen/printers/fieldResolver/nonNullResolver.d.ts.map +1 -0
  12. package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts +14 -0
  13. package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts.map +1 -0
  14. package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.js +6 -2
  15. package/lib/dslgen/printers/index.d.ts +5 -0
  16. package/lib/dslgen/printers/index.d.ts.map +1 -0
  17. package/lib/dslgen/printers/index.js +2 -1
  18. package/lib/dslgen/printers/inputObjectType.d.ts +19 -0
  19. package/lib/dslgen/printers/inputObjectType.d.ts.map +1 -0
  20. package/lib/dslgen/printers/inputObjectType.js +3 -1
  21. package/lib/dslgen/printers/objectType.d.ts +15 -0
  22. package/lib/dslgen/printers/objectType.d.ts.map +1 -0
  23. package/lib/dslgen/printers/oneofUnionType.d.ts +14 -0
  24. package/lib/dslgen/printers/oneofUnionType.d.ts.map +1 -0
  25. package/lib/dslgen/printers/util.d.ts +12 -0
  26. package/lib/dslgen/printers/util.d.ts.map +1 -0
  27. package/lib/dslgen/printers/util.js +1 -1
  28. package/lib/printer.d.ts +11 -0
  29. package/lib/printer.d.ts.map +1 -0
  30. package/lib/process.d.ts +2 -0
  31. package/lib/process.d.ts.map +1 -0
  32. package/lib/protoc-gen-pothos.d.ts +2 -0
  33. package/lib/protoc-gen-pothos.d.ts.map +1 -0
  34. package/module/dslgen/index.d.ts +2 -0
  35. package/module/dslgen/index.d.ts.map +1 -0
  36. package/module/dslgen/printers/enumType.d.ts +16 -0
  37. package/module/dslgen/printers/enumType.d.ts.map +1 -0
  38. package/module/dslgen/printers/enumType.js +1 -1
  39. package/module/dslgen/printers/field.d.ts +41 -0
  40. package/module/dslgen/printers/field.d.ts.map +1 -0
  41. package/module/dslgen/printers/field.js +8 -3
  42. package/module/dslgen/printers/fieldResolver/enumFieldResolver.d.ts +20 -0
  43. package/module/dslgen/printers/fieldResolver/enumFieldResolver.d.ts.map +1 -0
  44. package/module/dslgen/printers/fieldResolver/enumFieldResolver.js +1 -1
  45. package/module/dslgen/printers/fieldResolver/nonNullResolver.d.ts +3 -0
  46. package/module/dslgen/printers/fieldResolver/nonNullResolver.d.ts.map +1 -0
  47. package/module/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts +14 -0
  48. package/module/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts.map +1 -0
  49. package/module/dslgen/printers/fieldResolver/oneofUnionResolver.js +7 -3
  50. package/module/dslgen/printers/index.d.ts +5 -0
  51. package/module/dslgen/printers/index.d.ts.map +1 -0
  52. package/module/dslgen/printers/index.js +2 -1
  53. package/module/dslgen/printers/inputObjectType.d.ts +19 -0
  54. package/module/dslgen/printers/inputObjectType.d.ts.map +1 -0
  55. package/module/dslgen/printers/inputObjectType.js +5 -3
  56. package/module/dslgen/printers/objectType.d.ts +15 -0
  57. package/module/dslgen/printers/objectType.d.ts.map +1 -0
  58. package/module/dslgen/printers/objectType.js +1 -1
  59. package/module/dslgen/printers/oneofUnionType.d.ts +14 -0
  60. package/module/dslgen/printers/oneofUnionType.d.ts.map +1 -0
  61. package/module/dslgen/printers/util.d.ts +12 -0
  62. package/module/dslgen/printers/util.d.ts.map +1 -0
  63. package/module/dslgen/printers/util.js +1 -1
  64. package/module/printer.d.ts +11 -0
  65. package/module/printer.d.ts.map +1 -0
  66. package/module/process.d.ts +2 -0
  67. package/module/process.d.ts.map +1 -0
  68. package/module/protoc-gen-pothos.d.ts +2 -0
  69. package/module/protoc-gen-pothos.d.ts.map +1 -0
  70. package/package.json +6 -11
  71. package/CHANGELOG.md +0 -99
@@ -0,0 +1,2 @@
1
+ export * from "./printers";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dslgen/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { EnumType } from "@proto-graphql/codegen-core";
2
+ import { Code } from "ts-poet";
3
+ import { PothosPrinterOptions } from "./util";
4
+ /**
5
+ * @example
6
+ * ```ts
7
+ * export cosnt Hello$Ref = builder.enumType("Hello", {
8
+ * values: [
9
+ * // ...
10
+ * ],
11
+ * // ...
12
+ * })
13
+ * ```
14
+ */
15
+ export declare function createEnumTypeCode(type: EnumType, opts: PothosPrinterOptions): Code;
16
+ //# sourceMappingURL=enumType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/enumType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAET,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAQ,IAAI,EAAuB,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAiB,oBAAoB,EAAa,MAAM,QAAQ,CAAC;AAExE;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,oBAAoB,GACzB,IAAI,CA8BN"}
@@ -0,0 +1,41 @@
1
+ import { InputObjectField, ObjectField, ObjectOneofField } from "@proto-graphql/codegen-core";
2
+ import { Code } from "ts-poet";
3
+ import { PothosPrinterOptions } from "./util";
4
+ /**
5
+ * @example
6
+ * ```ts
7
+ * t.expose("name", {
8
+ * type: "Boolean",
9
+ * nullable: true,
10
+ * description: "...",
11
+ * })
12
+ * ```
13
+ * ```ts
14
+ * t.field({
15
+ * type: "Boolean",
16
+ * nullable: true,
17
+ * description: "...",
18
+ * resolve() {
19
+ * return true
20
+ * }
21
+ * })
22
+ * ```
23
+ */
24
+ export declare function createFieldRefCode(field: ObjectField<any> | ObjectOneofField | InputObjectField<any>, opts: PothosPrinterOptions): Code;
25
+ /**
26
+ * @example
27
+ * ```ts
28
+ * t.field( {
29
+ * type: "Boolean",
30
+ * nullable: true,
31
+ * description: "noop field",
32
+ * resolve() {
33
+ * return true
34
+ * }
35
+ * })
36
+ * ```
37
+ */
38
+ export declare function createNoopFieldRefCode(opts: {
39
+ input: boolean;
40
+ }): Code;
41
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAKjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAQ,IAAI,EAAa,MAAM,SAAS,CAAC;AAKhD,OAAO,EAAgB,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,EAClE,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAoDN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CASrE"}
@@ -29,7 +29,9 @@ const util_1 = require("./util");
29
29
  */
30
30
  function createFieldRefCode(field, opts) {
31
31
  const isInput = field instanceof codegen_core_1.InputObjectField;
32
- const baseType = field.type instanceof codegen_core_1.ScalarType ? (0, ts_poet_1.literalOf)(field.type.typeName) : (0, util_1.fieldTypeRef)(field, opts);
32
+ const baseType = field.type instanceof codegen_core_1.ScalarType
33
+ ? (0, ts_poet_1.literalOf)(field.type.typeName)
34
+ : (0, util_1.fieldTypeRef)(field, opts);
33
35
  const sourceExpr = (0, ts_poet_1.code) `source`;
34
36
  let resolverCode;
35
37
  if (!isInput) {
@@ -39,14 +41,17 @@ function createFieldRefCode(field, opts) {
39
41
  else {
40
42
  const valueExpr = (0, codegen_core_1.createGetFieldValueCode)(sourceExpr, field.proto, opts);
41
43
  const nullableInProto = field.type instanceof codegen_core_1.ObjectType ||
42
- (field.type instanceof codegen_core_1.ScalarType && !field.type.isPrimitive() && !field.type.isWrapperType());
44
+ (field.type instanceof codegen_core_1.ScalarType &&
45
+ !field.type.isPrimitive() &&
46
+ !field.type.isWrapperType());
43
47
  if (nullableInProto && !field.isNullable()) {
44
48
  resolverCode = (0, nonNullResolver_1.createNonNullResolverCode)(valueExpr);
45
49
  }
46
50
  if (field.type instanceof codegen_core_1.EnumType && field instanceof codegen_core_1.ObjectField) {
47
51
  resolverCode = (0, enumFieldResolver_1.createEnumResolverCode)(valueExpr, field, opts);
48
52
  }
49
- if (field.type instanceof codegen_core_1.SquashedOneofUnionType && field instanceof codegen_core_1.ObjectField) {
53
+ if (field.type instanceof codegen_core_1.SquashedOneofUnionType &&
54
+ field instanceof codegen_core_1.ObjectField) {
50
55
  resolverCode = (0, oneofUnionResolver_1.createOneofUnionResolverCode)(valueExpr, field);
51
56
  }
52
57
  }
@@ -0,0 +1,20 @@
1
+ import { EnumType, ObjectField, PrinterOptions } from "@proto-graphql/codegen-core";
2
+ import { Code } from "ts-poet";
3
+ /**
4
+ * @example nullable
5
+ * ```ts
6
+ * if (!root.myEnum || root.myEnum === _$enums.myEnum.MY_ENUM_UNSPECIFIED) {
7
+ * return null
8
+ * }
9
+ * return root.myEnum
10
+ * ```
11
+ * @example notNull
12
+ * ```ts
13
+ * if (!root.myEnum || root.myEnum === _$enums.myEnum.MY_ENUM_UNSPECIFIED) {
14
+ * throw new Error("Message.field is required field. but got null or unspecified.")
15
+ * }
16
+ * return root.myEnum
17
+ * ```
18
+ */
19
+ export declare function createEnumResolverCode(valueExpr: Code, field: ObjectField<EnumType>, opts: PrinterOptions): Code;
20
+ //# sourceMappingURL=enumFieldResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumFieldResolver.d.ts","sourceRoot":"","sources":["../../../../src/dslgen/printers/fieldResolver/enumFieldResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,cAAc,EAEf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAQ,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,EAC5B,IAAI,EAAE,cAAc,GACnB,IAAI,CA8CN"}
@@ -0,0 +1,3 @@
1
+ import { Code } from "ts-poet";
2
+ export declare function createNonNullResolverCode(valueExpr: Code): Code;
3
+ //# sourceMappingURL=nonNullResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nonNullResolver.d.ts","sourceRoot":"","sources":["../../../../src/dslgen/printers/fieldResolver/nonNullResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,MAAM,SAAS,CAAC;AAErC,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAI/D"}
@@ -0,0 +1,14 @@
1
+ import { ObjectField, ObjectOneofField, SquashedOneofUnionType } from "@proto-graphql/codegen-core";
2
+ import { Code } 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 declare function createOneofUnionResolverCode(sourceExpr: Code, field: ObjectOneofField | ObjectField<SquashedOneofUnionType>): Code;
14
+ //# sourceMappingURL=oneofUnionResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneofUnionResolver.d.ts","sourceRoot":"","sources":["../../../../src/dslgen/printers/fieldResolver/oneofUnionResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkB,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,IAAI,EAChB,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAAC,sBAAsB,CAAC,GAC5D,IAAI,CAoCN"}
@@ -22,9 +22,13 @@ function createOneofUnionResolverCode(sourceExpr, field) {
22
22
  return (0, ts_poet_1.code) `${sourceExpr}?.${memberField.proto.jsonName}`;
23
23
  };
24
24
  return (0, ts_poet_1.code) `
25
- const value = ${(0, ts_poet_1.joinCode)(field.type.fields.map(createFieldExpr), { on: "??" })};
25
+ const value = ${(0, ts_poet_1.joinCode)(field.type.fields.map(createFieldExpr), {
26
+ on: "??",
27
+ })};
26
28
  if (value == null) {
27
- ${nullable ? "return null" : `throw new Error("${field.name} should not be null")`};
29
+ ${nullable
30
+ ? "return null"
31
+ : `throw new Error("${field.name} should not be null")`};
28
32
  }
29
33
  return value;
30
34
  `;
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
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"}
@@ -17,7 +17,8 @@ function createTypeDslCodes(types, opts) {
17
17
  if (type instanceof codegen_core_1.EnumType) {
18
18
  return [(0, enumType_1.createEnumTypeCode)(type, opts)];
19
19
  }
20
- if (type instanceof codegen_core_1.OneofUnionType || type instanceof codegen_core_1.SquashedOneofUnionType) {
20
+ if (type instanceof codegen_core_1.OneofUnionType ||
21
+ type instanceof codegen_core_1.SquashedOneofUnionType) {
21
22
  return [(0, oneofUnionType_1.createOneofUnionTypeCode)(type, opts)];
22
23
  }
23
24
  const _exhaustiveCheck = type;
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -33,7 +33,9 @@ function createInputObjectTypeCode(type, opts) {
33
33
  else {
34
34
  typeNode = (0, ts_poet_1.code) `${(0, codegen_core_1.protoType)(type.proto, opts)}[${(0, ts_poet_1.literalOf)(f.proto.jsonName)}]`;
35
35
  }
36
- return f.isNullable() ? (0, ts_poet_1.code) `${f.name}?: ${typeNode} | null,` : (0, ts_poet_1.code) `${f.name}: ${typeNode},`;
36
+ return f.isNullable()
37
+ ? (0, ts_poet_1.code) `${f.name}?: ${typeNode} | null,`
38
+ : (0, ts_poet_1.code) `${f.name}: ${typeNode},`;
37
39
  }))}
38
40
  };
39
41
  `;
@@ -0,0 +1,15 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.pothosBuilder = exports.fieldTypeShape = exports.fieldTypeRef = exports.shapeTypeName = exports.shapeType = exports.pothosRef = void 0;
27
- const codegen_core_1 = require("@proto-graphql/codegen-core");
28
27
  const path = __importStar(require("path"));
28
+ const codegen_core_1 = require("@proto-graphql/codegen-core");
29
29
  const ts_poet_1 = require("ts-poet");
30
30
  function pothosRef(type) {
31
31
  return (0, ts_poet_1.code) `${pothosRefName(type)}`;
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export declare const processRequest: (req: import("google-protobuf/google/protobuf/compiler/plugin_pb").CodeGeneratorRequest) => import("google-protobuf/google/protobuf/compiler/plugin_pb").CodeGeneratorResponse;
2
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,gLAAoD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=protoc-gen-pothos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protoc-gen-pothos.d.ts","sourceRoot":"","sources":["../src/protoc-gen-pothos.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "./printers";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dslgen/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { EnumType } from "@proto-graphql/codegen-core";
2
+ import { Code } from "ts-poet";
3
+ import { PothosPrinterOptions } from "./util";
4
+ /**
5
+ * @example
6
+ * ```ts
7
+ * export cosnt Hello$Ref = builder.enumType("Hello", {
8
+ * values: [
9
+ * // ...
10
+ * ],
11
+ * // ...
12
+ * })
13
+ * ```
14
+ */
15
+ export declare function createEnumTypeCode(type: EnumType, opts: PothosPrinterOptions): Code;
16
+ //# sourceMappingURL=enumType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumType.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/enumType.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAET,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAQ,IAAI,EAAuB,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAiB,oBAAoB,EAAa,MAAM,QAAQ,CAAC;AAExE;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,oBAAoB,GACzB,IAAI,CA8BN"}
@@ -1,4 +1,4 @@
1
- import { compact, protobufGraphQLExtensions } from "@proto-graphql/codegen-core";
1
+ import { compact, protobufGraphQLExtensions, } from "@proto-graphql/codegen-core";
2
2
  import { code, joinCode, literalOf } from "ts-poet";
3
3
  import { pothosBuilder, pothosRef } from "./util";
4
4
  /**
@@ -0,0 +1,41 @@
1
+ import { InputObjectField, ObjectField, ObjectOneofField } from "@proto-graphql/codegen-core";
2
+ import { Code } from "ts-poet";
3
+ import { PothosPrinterOptions } from "./util";
4
+ /**
5
+ * @example
6
+ * ```ts
7
+ * t.expose("name", {
8
+ * type: "Boolean",
9
+ * nullable: true,
10
+ * description: "...",
11
+ * })
12
+ * ```
13
+ * ```ts
14
+ * t.field({
15
+ * type: "Boolean",
16
+ * nullable: true,
17
+ * description: "...",
18
+ * resolve() {
19
+ * return true
20
+ * }
21
+ * })
22
+ * ```
23
+ */
24
+ export declare function createFieldRefCode(field: ObjectField<any> | ObjectOneofField | InputObjectField<any>, opts: PothosPrinterOptions): Code;
25
+ /**
26
+ * @example
27
+ * ```ts
28
+ * t.field( {
29
+ * type: "Boolean",
30
+ * nullable: true,
31
+ * description: "noop field",
32
+ * resolve() {
33
+ * return true
34
+ * }
35
+ * })
36
+ * ```
37
+ */
38
+ export declare function createNoopFieldRefCode(opts: {
39
+ input: boolean;
40
+ }): Code;
41
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/dslgen/printers/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAKjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAQ,IAAI,EAAa,MAAM,SAAS,CAAC;AAKhD,OAAO,EAAgB,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,EAClE,IAAI,EAAE,oBAAoB,GACzB,IAAI,CAoDN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CASrE"}
@@ -26,7 +26,9 @@ import { fieldTypeRef } from "./util";
26
26
  */
27
27
  export function createFieldRefCode(field, opts) {
28
28
  const isInput = field instanceof InputObjectField;
29
- const baseType = field.type instanceof ScalarType ? literalOf(field.type.typeName) : fieldTypeRef(field, opts);
29
+ const baseType = field.type instanceof ScalarType
30
+ ? literalOf(field.type.typeName)
31
+ : fieldTypeRef(field, opts);
30
32
  const sourceExpr = code `source`;
31
33
  let resolverCode;
32
34
  if (!isInput) {
@@ -36,14 +38,17 @@ export function createFieldRefCode(field, opts) {
36
38
  else {
37
39
  const valueExpr = createGetFieldValueCode(sourceExpr, field.proto, opts);
38
40
  const nullableInProto = field.type instanceof ObjectType ||
39
- (field.type instanceof ScalarType && !field.type.isPrimitive() && !field.type.isWrapperType());
41
+ (field.type instanceof ScalarType &&
42
+ !field.type.isPrimitive() &&
43
+ !field.type.isWrapperType());
40
44
  if (nullableInProto && !field.isNullable()) {
41
45
  resolverCode = createNonNullResolverCode(valueExpr);
42
46
  }
43
47
  if (field.type instanceof EnumType && field instanceof ObjectField) {
44
48
  resolverCode = createEnumResolverCode(valueExpr, field, opts);
45
49
  }
46
- if (field.type instanceof SquashedOneofUnionType && field instanceof ObjectField) {
50
+ if (field.type instanceof SquashedOneofUnionType &&
51
+ field instanceof ObjectField) {
47
52
  resolverCode = createOneofUnionResolverCode(valueExpr, field);
48
53
  }
49
54
  }
@@ -0,0 +1,20 @@
1
+ import { EnumType, ObjectField, PrinterOptions } from "@proto-graphql/codegen-core";
2
+ import { Code } from "ts-poet";
3
+ /**
4
+ * @example nullable
5
+ * ```ts
6
+ * if (!root.myEnum || root.myEnum === _$enums.myEnum.MY_ENUM_UNSPECIFIED) {
7
+ * return null
8
+ * }
9
+ * return root.myEnum
10
+ * ```
11
+ * @example notNull
12
+ * ```ts
13
+ * if (!root.myEnum || root.myEnum === _$enums.myEnum.MY_ENUM_UNSPECIFIED) {
14
+ * throw new Error("Message.field is required field. but got null or unspecified.")
15
+ * }
16
+ * return root.myEnum
17
+ * ```
18
+ */
19
+ export declare function createEnumResolverCode(valueExpr: Code, field: ObjectField<EnumType>, opts: PrinterOptions): Code;
20
+ //# sourceMappingURL=enumFieldResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enumFieldResolver.d.ts","sourceRoot":"","sources":["../../../../src/dslgen/printers/fieldResolver/enumFieldResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,cAAc,EAEf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAQ,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,EAC5B,IAAI,EAAE,cAAc,GACnB,IAAI,CA8CN"}
@@ -1,4 +1,4 @@
1
- import { protoType } from "@proto-graphql/codegen-core";
1
+ import { protoType, } from "@proto-graphql/codegen-core";
2
2
  import { code } from "ts-poet";
3
3
  /**
4
4
  * @example nullable
@@ -0,0 +1,3 @@
1
+ import { Code } from "ts-poet";
2
+ export declare function createNonNullResolverCode(valueExpr: Code): Code;
3
+ //# sourceMappingURL=nonNullResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nonNullResolver.d.ts","sourceRoot":"","sources":["../../../../src/dslgen/printers/fieldResolver/nonNullResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAE,MAAM,SAAS,CAAC;AAErC,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,CAI/D"}
@@ -0,0 +1,14 @@
1
+ import { ObjectField, ObjectOneofField, SquashedOneofUnionType } from "@proto-graphql/codegen-core";
2
+ import { Code } 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 declare function createOneofUnionResolverCode(sourceExpr: Code, field: ObjectOneofField | ObjectField<SquashedOneofUnionType>): Code;
14
+ //# sourceMappingURL=oneofUnionResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneofUnionResolver.d.ts","sourceRoot":"","sources":["../../../../src/dslgen/printers/fieldResolver/oneofUnionResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,IAAI,EAAkB,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,IAAI,EAChB,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAAC,sBAAsB,CAAC,GAC5D,IAAI,CAoCN"}
@@ -1,4 +1,4 @@
1
- import { ObjectField, ObjectOneofField } from "@proto-graphql/codegen-core";
1
+ import { ObjectField, ObjectOneofField, } from "@proto-graphql/codegen-core";
2
2
  import { code, joinCode } from "ts-poet";
3
3
  /**
4
4
  * @example nullable
@@ -19,9 +19,13 @@ export function createOneofUnionResolverCode(sourceExpr, field) {
19
19
  return code `${sourceExpr}?.${memberField.proto.jsonName}`;
20
20
  };
21
21
  return code `
22
- const value = ${joinCode(field.type.fields.map(createFieldExpr), { on: "??" })};
22
+ const value = ${joinCode(field.type.fields.map(createFieldExpr), {
23
+ on: "??",
24
+ })};
23
25
  if (value == null) {
24
- ${nullable ? "return null" : `throw new Error("${field.name} should not be null")`};
26
+ ${nullable
27
+ ? "return null"
28
+ : `throw new Error("${field.name} should not be null")`};
25
29
  }
26
30
  return value;
27
31
  `;
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
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"}
@@ -14,7 +14,8 @@ export function createTypeDslCodes(types, opts) {
14
14
  if (type instanceof EnumType) {
15
15
  return [createEnumTypeCode(type, opts)];
16
16
  }
17
- if (type instanceof OneofUnionType || type instanceof SquashedOneofUnionType) {
17
+ if (type instanceof OneofUnionType ||
18
+ type instanceof SquashedOneofUnionType) {
18
19
  return [createOneofUnionTypeCode(type, opts)];
19
20
  }
20
21
  const _exhaustiveCheck = type;
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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,7 +1,7 @@
1
- import { compact, InputObjectType, protobufGraphQLExtensions, protoType } from "@proto-graphql/codegen-core";
1
+ import { compact, InputObjectType, protobufGraphQLExtensions, protoType, } from "@proto-graphql/codegen-core";
2
2
  import { code, imp, joinCode, literalOf } from "ts-poet";
3
3
  import { createFieldRefCode, createNoopFieldRefCode } from "./field";
4
- import { fieldTypeShape, pothosBuilder, pothosRef, shapeType } from "./util";
4
+ import { fieldTypeShape, pothosBuilder, pothosRef, shapeType, } from "./util";
5
5
  /**
6
6
  * @example
7
7
  * ```ts
@@ -30,7 +30,9 @@ export function createInputObjectTypeCode(type, opts) {
30
30
  else {
31
31
  typeNode = code `${protoType(type.proto, opts)}[${literalOf(f.proto.jsonName)}]`;
32
32
  }
33
- return f.isNullable() ? code `${f.name}?: ${typeNode} | null,` : code `${f.name}: ${typeNode},`;
33
+ return f.isNullable()
34
+ ? code `${f.name}?: ${typeNode} | null,`
35
+ : code `${f.name}: ${typeNode},`;
34
36
  }))}
35
37
  };
36
38
  `;
@@ -0,0 +1,15 @@
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
@@ -0,0 +1 @@
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,4 +1,4 @@
1
- import { compact, InterfaceType, protobufGraphQLExtensions, protoType } from "@proto-graphql/codegen-core";
1
+ import { compact, InterfaceType, protobufGraphQLExtensions, protoType, } from "@proto-graphql/codegen-core";
2
2
  import { code, joinCode, literalOf } from "ts-poet";
3
3
  import { createFieldRefCode, createNoopFieldRefCode } from "./field";
4
4
  import { pothosBuilder, pothosRef } from "./util";
@@ -0,0 +1,14 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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,5 +1,5 @@
1
- import { filename, generatedGraphQLTypeImportPath, } from "@proto-graphql/codegen-core";
2
1
  import * as path from "path";
2
+ import { filename, generatedGraphQLTypeImportPath, } from "@proto-graphql/codegen-core";
3
3
  import { code, imp } from "ts-poet";
4
4
  export function pothosRef(type) {
5
5
  return code `${pothosRefName(type)}`;
@@ -0,0 +1,11 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export declare const processRequest: (req: import("google-protobuf/google/protobuf/compiler/plugin_pb").CodeGeneratorRequest) => import("google-protobuf/google/protobuf/compiler/plugin_pb").CodeGeneratorResponse;
2
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,gLAAoD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=protoc-gen-pothos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protoc-gen-pothos.d.ts","sourceRoot":"","sources":["../src/protoc-gen-pothos.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protoc-gen-pothos",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Generate DSL for Pothos GraphQL from Protocol Buffers IDL",
5
5
  "keywords": [
6
6
  "graphql",
@@ -23,19 +23,14 @@
23
23
  "node": ">= 14.0.0"
24
24
  },
25
25
  "dependencies": {
26
- "@proto-graphql/codegen-core": "^0.3.0",
26
+ "@proto-graphql/codegen-core": "^0.3.1",
27
27
  "@proto-graphql/proto-descriptors": "^0.3.0",
28
28
  "@proto-graphql/protoc-plugin-helpers": "^0.2.2",
29
- "google-protobuf": "^3.20.1",
29
+ "google-protobuf": "^3.21.2",
30
30
  "ts-poet": "^6.3.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@pothos/core": "^3.22.7",
34
- "@testapis/ts-proto": "^0.5.1",
35
- "@testapis/ts-proto-with-forcelong-long": "^0.6.0",
36
- "@testapis/ts-proto-with-forcelong-number": "^0.6.0",
37
- "@types/glob": "^8.0.0",
38
- "glob": "^8.0.1"
33
+ "@types/google-protobuf": "^3.15.6"
39
34
  },
40
35
  "files": [
41
36
  "bin/",
@@ -44,8 +39,8 @@
44
39
  "module/"
45
40
  ],
46
41
  "scripts": {
47
- "build": "tsc --build . && tsc --build tsconfig.module.json",
48
- "clean": "rimraf lib/ module/ && tsc --build . --clean && tsc --build tsconfig.module.json --clean",
42
+ "build": "tsc --build tsconfig.cjs.json && tsc --build tsconfig.module.json",
43
+ "clean": "rimraf lib/ module/ && tsc --build tsconfig.cjs.json --clean && tsc --build tsconfig.module.json --clean",
49
44
  "test": "jest --coverage"
50
45
  }
51
46
  }
package/CHANGELOG.md DELETED
@@ -1,99 +0,0 @@
1
- # protoc-gen-pothos
2
-
3
- ## 0.3.0
4
-
5
- ### Minor Changes
6
-
7
- - [#239](https://github.com/proto-graphql/proto-graphql-js/pull/239) [`f072608`](https://github.com/proto-graphql/proto-graphql-js/commit/f0726082c9ad728ff5ad648e79ab7862f85a1a97) Thanks [@izumin5210](https://github.com/izumin5210)! - rewrite protoc-gen-pothos printer with ts-poet
8
-
9
- ### Patch Changes
10
-
11
- - [#243](https://github.com/proto-graphql/proto-graphql-js/pull/243) [`3aa729a`](https://github.com/proto-graphql/proto-graphql-js/commit/3aa729a62a36aa782e8c2153bb3b789e9551ae00) Thanks [@izumin5210](https://github.com/izumin5210)! - remove unused code from codegen-core
12
-
13
- - [#241](https://github.com/proto-graphql/proto-graphql-js/pull/241) [`cef3d3e`](https://github.com/proto-graphql/proto-graphql-js/commit/cef3d3e512e616f98869c12060d592c3ff887aa9) Thanks [@izumin5210](https://github.com/izumin5210)! - rewrite protoc-gen-nexus printer with ts-poet
14
-
15
- - Updated dependencies [[`3aa729a`](https://github.com/proto-graphql/proto-graphql-js/commit/3aa729a62a36aa782e8c2153bb3b789e9551ae00), [`cef3d3e`](https://github.com/proto-graphql/proto-graphql-js/commit/cef3d3e512e616f98869c12060d592c3ff887aa9), [`f072608`](https://github.com/proto-graphql/proto-graphql-js/commit/f0726082c9ad728ff5ad648e79ab7862f85a1a97)]:
16
- - @proto-graphql/codegen-core@0.3.0
17
- - @proto-graphql/protoc-plugin-helpers@0.2.2
18
- - @proto-graphql/proto-descriptors@0.3.0
19
-
20
- ## 0.2.3
21
-
22
- ### Patch Changes
23
-
24
- - [#237](https://github.com/proto-graphql/proto-graphql-js/pull/237) [`b9945c8`](https://github.com/proto-graphql/proto-graphql-js/commit/b9945c827e737bda8b85621966a90a2e7e5cdf41) Thanks [@izumin5210](https://github.com/izumin5210)! - tweak input type definition for avoiding type error
25
-
26
- - Updated dependencies [[`b9945c8`](https://github.com/proto-graphql/proto-graphql-js/commit/b9945c827e737bda8b85621966a90a2e7e5cdf41)]:
27
- - @proto-graphql/codegen-core@0.2.3
28
-
29
- ## 0.2.2
30
-
31
- ### Patch Changes
32
-
33
- - [#234](https://github.com/proto-graphql/proto-graphql-js/pull/234) [`a2a3e60`](https://github.com/proto-graphql/proto-graphql-js/commit/a2a3e60789f75c31c600333afd830a02ac0cccf8) Thanks [@izumin5210](https://github.com/izumin5210)! - support `ProtoScalar` in `ProtoField.type`
34
-
35
- - [#236](https://github.com/proto-graphql/proto-graphql-js/pull/236) [`3410d43`](https://github.com/proto-graphql/proto-graphql-js/commit/3410d43a7d29d04e1ed52576ac8a28e9b43cb452) Thanks [@izumin5210](https://github.com/izumin5210)! - add `typeFullName` to extensions in GraphQLField
36
-
37
- - Updated dependencies [[`a2a3e60`](https://github.com/proto-graphql/proto-graphql-js/commit/a2a3e60789f75c31c600333afd830a02ac0cccf8)]:
38
- - @proto-graphql/codegen-core@0.2.2
39
- - @proto-graphql/proto-descriptors@0.2.0
40
- - @proto-graphql/protoc-plugin-helpers@0.2.1
41
-
42
- ## 0.2.1
43
-
44
- ### Patch Changes
45
-
46
- - [#231](https://github.com/proto-graphql/proto-graphql-js/pull/231) [`2ff07a6`](https://github.com/proto-graphql/proto-graphql-js/commit/2ff07a64212a62010330803d05c2f8f7f37f29b4) Thanks [@izumin5210](https://github.com/izumin5210)! - add oroginal protobuf type info to extensions
47
-
48
- - [#228](https://github.com/proto-graphql/proto-graphql-js/pull/228) [`c7db053`](https://github.com/proto-graphql/proto-graphql-js/commit/c7db0531f3790dbf61d740440eda841459cb3f6b) Thanks [@izumin5210](https://github.com/izumin5210)! - Support PothosShemaBuilder in external modules
49
-
50
- - [#216](https://github.com/proto-graphql/proto-graphql-js/pull/216) [`831f8e7`](https://github.com/proto-graphql/proto-graphql-js/commit/831f8e70ff45d3503413441f568c2c901ae6f552) Thanks [@izumin5210](https://github.com/izumin5210)! - new E2E testing
51
-
52
- - Updated dependencies [[`c7db053`](https://github.com/proto-graphql/proto-graphql-js/commit/c7db0531f3790dbf61d740440eda841459cb3f6b)]:
53
- - @proto-graphql/codegen-core@0.2.1
54
-
55
- ## 0.2.0
56
-
57
- ### Minor Changes
58
-
59
- - [#224](https://github.com/proto-graphql/proto-graphql-js/pull/224) [`6c25f40`](https://github.com/proto-graphql/proto-graphql-js/commit/6c25f4035f1b788a63bf005dbc52ca5d0bd5f2a2) Thanks [@izumin5210](https://github.com/izumin5210)! - support `long_number` param for mapping 64bit numbers to GraphQL Int
60
-
61
- ### Patch Changes
62
-
63
- - Updated dependencies [[`6c25f40`](https://github.com/proto-graphql/proto-graphql-js/commit/6c25f4035f1b788a63bf005dbc52ca5d0bd5f2a2)]:
64
- - @proto-graphql/codegen-core@0.2.0
65
- - @proto-graphql/protoc-plugin-helpers@0.2.0
66
-
67
- ## 0.1.2
68
-
69
- ### Patch Changes
70
-
71
- - [#217](https://github.com/proto-graphql/proto-graphql-js/pull/217) [`5e2e85b`](https://github.com/proto-graphql/proto-graphql-js/commit/5e2e85baf6e0e21960104d3db30a4e21e04e1627) Thanks [@izumin5210](https://github.com/izumin5210)! - add `eslint-disable` directive to generated files
72
-
73
- - [#218](https://github.com/proto-graphql/proto-graphql-js/pull/218) [`c1246c3`](https://github.com/proto-graphql/proto-graphql-js/commit/c1246c3a349f11e3b2bbfd6198c1a06b37270ece) Thanks [@izumin5210](https://github.com/izumin5210)! - fix non-null custom scalar field resolver
74
-
75
- - Updated dependencies [[`c1246c3`](https://github.com/proto-graphql/proto-graphql-js/commit/c1246c3a349f11e3b2bbfd6198c1a06b37270ece)]:
76
- - @proto-graphql/codegen-core@0.1.2
77
-
78
- ## 0.1.1
79
-
80
- ### Patch Changes
81
-
82
- - [#212](https://github.com/proto-graphql/proto-graphql-js/pull/212) [`ba647eb`](https://github.com/proto-graphql/proto-graphql-js/commit/ba647eb584850fee9c632a76cc1c028ce8ccd725) Thanks [@izumin5210](https://github.com/izumin5210)! - refactor dependencies
83
-
84
- - Updated dependencies [[`ba647eb`](https://github.com/proto-graphql/proto-graphql-js/commit/ba647eb584850fee9c632a76cc1c028ce8ccd725), [`c5b988a`](https://github.com/proto-graphql/proto-graphql-js/commit/c5b988a4a1eac5d56d29572b593ae7643e23bd88)]:
85
- - @proto-graphql/codegen-core@0.1.1
86
- - @proto-graphql/protoc-plugin-helpers@0.1.1
87
-
88
- ## 0.1.0
89
-
90
- ### Minor Changes
91
-
92
- - [#200](https://github.com/proto-graphql/proto-graphql-js/pull/200) [`515eabd`](https://github.com/proto-graphql/proto-graphql-js/commit/515eabd2f39baa0a99ae057b1b30a4ccc4149f66) Thanks [@izumin5210](https://github.com/izumin5210)! - support Pothos GraphQL
93
-
94
- ### Patch Changes
95
-
96
- - Updated dependencies [[`515eabd`](https://github.com/proto-graphql/proto-graphql-js/commit/515eabd2f39baa0a99ae057b1b30a4ccc4149f66)]:
97
- - @proto-graphql/codegen-core@0.1.0
98
- - @proto-graphql/proto-descriptors@0.1.0
99
- - @proto-graphql/protoc-plugin-helpers@0.1.0