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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -1
  3. package/package.json +16 -10
  4. package/lib/dslgen/index.d.ts +0 -2
  5. package/lib/dslgen/index.d.ts.map +0 -1
  6. package/lib/dslgen/index.js +0 -17
  7. package/lib/dslgen/printers/enumType.d.ts +0 -16
  8. package/lib/dslgen/printers/enumType.d.ts.map +0 -1
  9. package/lib/dslgen/printers/enumType.js +0 -40
  10. package/lib/dslgen/printers/field.d.ts +0 -41
  11. package/lib/dslgen/printers/field.d.ts.map +0 -1
  12. package/lib/dslgen/printers/field.js +0 -99
  13. package/lib/dslgen/printers/fieldResolver/enumFieldResolver.d.ts +0 -20
  14. package/lib/dslgen/printers/fieldResolver/enumFieldResolver.d.ts.map +0 -1
  15. package/lib/dslgen/printers/fieldResolver/enumFieldResolver.js +0 -61
  16. package/lib/dslgen/printers/fieldResolver/nonNullResolver.d.ts +0 -3
  17. package/lib/dslgen/printers/fieldResolver/nonNullResolver.d.ts.map +0 -1
  18. package/lib/dslgen/printers/fieldResolver/nonNullResolver.js +0 -10
  19. package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts +0 -14
  20. package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts.map +0 -1
  21. package/lib/dslgen/printers/fieldResolver/oneofUnionResolver.js +0 -45
  22. package/lib/dslgen/printers/index.d.ts +0 -5
  23. package/lib/dslgen/printers/index.d.ts.map +0 -1
  24. package/lib/dslgen/printers/index.js +0 -28
  25. package/lib/dslgen/printers/inputObjectType.d.ts +0 -19
  26. package/lib/dslgen/printers/inputObjectType.d.ts.map +0 -1
  27. package/lib/dslgen/printers/inputObjectType.js +0 -59
  28. package/lib/dslgen/printers/objectType.d.ts +0 -15
  29. package/lib/dslgen/printers/objectType.d.ts.map +0 -1
  30. package/lib/dslgen/printers/objectType.js +0 -50
  31. package/lib/dslgen/printers/oneofUnionType.d.ts +0 -14
  32. package/lib/dslgen/printers/oneofUnionType.d.ts.map +0 -1
  33. package/lib/dslgen/printers/oneofUnionType.js +0 -27
  34. package/lib/dslgen/printers/util.d.ts +0 -12
  35. package/lib/dslgen/printers/util.d.ts.map +0 -1
  36. package/lib/dslgen/printers/util.js +0 -69
  37. package/lib/printer.d.ts +0 -11
  38. package/lib/printer.d.ts.map +0 -1
  39. package/lib/printer.js +0 -34
  40. package/lib/process.d.ts +0 -2
  41. package/lib/process.d.ts.map +0 -1
  42. package/lib/process.js +0 -6
  43. package/lib/protoc-gen-pothos.d.ts +0 -2
  44. package/lib/protoc-gen-pothos.d.ts.map +0 -1
  45. package/lib/protoc-gen-pothos.js +0 -5
  46. package/module/dslgen/index.d.ts +0 -2
  47. package/module/dslgen/index.d.ts.map +0 -1
  48. package/module/dslgen/index.js +0 -1
  49. package/module/dslgen/printers/enumType.d.ts +0 -16
  50. package/module/dslgen/printers/enumType.d.ts.map +0 -1
  51. package/module/dslgen/printers/enumType.js +0 -36
  52. package/module/dslgen/printers/field.d.ts +0 -41
  53. package/module/dslgen/printers/field.d.ts.map +0 -1
  54. package/module/dslgen/printers/field.js +0 -94
  55. package/module/dslgen/printers/fieldResolver/enumFieldResolver.d.ts +0 -20
  56. package/module/dslgen/printers/fieldResolver/enumFieldResolver.d.ts.map +0 -1
  57. package/module/dslgen/printers/fieldResolver/enumFieldResolver.js +0 -57
  58. package/module/dslgen/printers/fieldResolver/nonNullResolver.d.ts +0 -3
  59. package/module/dslgen/printers/fieldResolver/nonNullResolver.d.ts.map +0 -1
  60. package/module/dslgen/printers/fieldResolver/nonNullResolver.js +0 -6
  61. package/module/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts +0 -14
  62. package/module/dslgen/printers/fieldResolver/oneofUnionResolver.d.ts.map +0 -1
  63. package/module/dslgen/printers/fieldResolver/oneofUnionResolver.js +0 -41
  64. package/module/dslgen/printers/index.d.ts +0 -5
  65. package/module/dslgen/printers/index.d.ts.map +0 -1
  66. package/module/dslgen/printers/index.js +0 -24
  67. package/module/dslgen/printers/inputObjectType.d.ts +0 -19
  68. package/module/dslgen/printers/inputObjectType.d.ts.map +0 -1
  69. package/module/dslgen/printers/inputObjectType.js +0 -55
  70. package/module/dslgen/printers/objectType.d.ts +0 -15
  71. package/module/dslgen/printers/objectType.d.ts.map +0 -1
  72. package/module/dslgen/printers/objectType.js +0 -46
  73. package/module/dslgen/printers/oneofUnionType.d.ts +0 -14
  74. package/module/dslgen/printers/oneofUnionType.d.ts.map +0 -1
  75. package/module/dslgen/printers/oneofUnionType.js +0 -23
  76. package/module/dslgen/printers/util.d.ts +0 -12
  77. package/module/dslgen/printers/util.d.ts.map +0 -1
  78. package/module/dslgen/printers/util.js +0 -37
  79. package/module/printer.d.ts +0 -11
  80. package/module/printer.d.ts.map +0 -1
  81. package/module/printer.js +0 -30
  82. package/module/process.d.ts +0 -2
  83. package/module/process.d.ts.map +0 -1
  84. package/module/process.js +0 -3
  85. package/module/protoc-gen-pothos.d.ts +0 -2
  86. package/module/protoc-gen-pothos.d.ts.map +0 -1
  87. package/module/protoc-gen-pothos.js +0 -3
@@ -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,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createObjectTypeCode = void 0;
4
- const codegen_core_1 = require("@proto-graphql/codegen-core");
5
- const ts_poet_1 = require("ts-poet");
6
- const field_1 = require("./field");
7
- const util_1 = require("./util");
8
- /**
9
- * @example
10
- * ```ts
11
- * export const Hello$Ref = builder.objectRef<_$hello$hello_pb.Hello>("Hello")
12
- * builder.objectType(Hello$Ref, {
13
- * name: "Hello",
14
- * // ...
15
- * })
16
- * ```
17
- */
18
- function createObjectTypeCode(type, opts) {
19
- const isInterface = type instanceof codegen_core_1.InterfaceType;
20
- const typeOpts = {
21
- name: type.typeName,
22
- fields: (0, ts_poet_1.code) `t => ({${type.fields.length > 0
23
- ? (0, ts_poet_1.joinCode)(type.fields.map((f) => (0, ts_poet_1.code) `${f.name}: ${(0, field_1.createFieldRefCode)(f, opts)},`))
24
- : (0, ts_poet_1.code) `_: ${(0, field_1.createNoopFieldRefCode)({ input: false })}`}})`,
25
- description: type.description,
26
- isTypeOf: isInterface
27
- ? undefined
28
- : (0, ts_poet_1.code) `
29
- (source) => {
30
- return (source as ${(0, codegen_core_1.protoType)(type.proto, opts)} | { $type: string & {} }).$type
31
- === ${(0, ts_poet_1.literalOf)(type.proto.fullName.toString())};
32
- }
33
- `,
34
- extensions: (0, codegen_core_1.protobufGraphQLExtensions)(type),
35
- };
36
- const buildRefFunc = (0, ts_poet_1.code) `${(0, util_1.pothosBuilder)(type, opts)}.${isInterface ? "interface" : "object"}Ref`;
37
- const buildTypeFunc = (0, ts_poet_1.code) `${(0, util_1.pothosBuilder)(type, opts)}.${isInterface ? "interface" : "object"}Type`;
38
- const refFuncTypeArg = isInterface
39
- ? (0, ts_poet_1.code) `
40
- Pick<
41
- ${(0, codegen_core_1.protoType)(type.proto, opts)},
42
- ${(0, ts_poet_1.joinCode)(type.fields.map((f) => (0, ts_poet_1.code) `${(0, ts_poet_1.literalOf)(f.proto.jsonName)}`), { on: "|" })}
43
- >`
44
- : (0, codegen_core_1.protoType)(type.proto, opts);
45
- return (0, ts_poet_1.code) `
46
- export const ${(0, util_1.pothosRef)(type)} = ${buildRefFunc}<${refFuncTypeArg}>(${(0, ts_poet_1.literalOf)(type.typeName)});
47
- ${buildTypeFunc}(${(0, util_1.pothosRef)(type)}, ${(0, ts_poet_1.literalOf)((0, codegen_core_1.compact)(typeOpts))});
48
- `;
49
- }
50
- exports.createObjectTypeCode = createObjectTypeCode;
@@ -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,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createOneofUnionTypeCode = void 0;
4
- const codegen_core_1 = require("@proto-graphql/codegen-core");
5
- const ts_poet_1 = require("ts-poet");
6
- const util_1 = require("./util");
7
- /**
8
- * @example
9
- * ```ts
10
- * export cosnt Oneof = builder.unionType("Oneof", {
11
- * types: [...],
12
- * // ...
13
- * })
14
- * ```
15
- */
16
- function createOneofUnionTypeCode(type, opts) {
17
- const typeOpts = {
18
- types: type.fields.map((f) => (0, util_1.pothosRef)(f.type)),
19
- description: type.description,
20
- extensions: (0, codegen_core_1.protobufGraphQLExtensions)(type),
21
- };
22
- return (0, ts_poet_1.code) `
23
- export const ${(0, util_1.pothosRef)(type)} =
24
- ${(0, util_1.pothosBuilder)(type, opts)}.unionType(${(0, ts_poet_1.literalOf)(type.typeName)}, ${(0, ts_poet_1.literalOf)((0, codegen_core_1.compact)(typeOpts))});
25
- `;
26
- }
27
- exports.createOneofUnionTypeCode = createOneofUnionTypeCode;
@@ -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,69 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.pothosBuilder = exports.fieldTypeShape = exports.fieldTypeRef = exports.shapeTypeName = exports.shapeType = exports.pothosRef = void 0;
27
- const path = __importStar(require("path"));
28
- const codegen_core_1 = require("@proto-graphql/codegen-core");
29
- const ts_poet_1 = require("ts-poet");
30
- function pothosRef(type) {
31
- return (0, ts_poet_1.code) `${pothosRefName(type)}`;
32
- }
33
- exports.pothosRef = pothosRef;
34
- function pothosRefName(type) {
35
- return `${type.typeName}$Ref`;
36
- }
37
- function shapeType(type) {
38
- return (0, ts_poet_1.code) `${shapeTypeName(type)}`;
39
- }
40
- exports.shapeType = shapeType;
41
- function shapeTypeName(type) {
42
- return `${type.typeName}$Shape`;
43
- }
44
- exports.shapeTypeName = shapeTypeName;
45
- function fieldTypeRef(field, opts) {
46
- const importPath = (0, codegen_core_1.generatedGraphQLTypeImportPath)(field, opts);
47
- if (importPath == null)
48
- return pothosRef(field.type);
49
- const imported = (0, ts_poet_1.imp)(`IMPORTED_PLACEHOLDER@${importPath}`);
50
- imported.symbol = pothosRefName(field.type); // NOTE: Workaround for ts-poet not recognizing "$" as an identifier
51
- return (0, ts_poet_1.code) `${imported}`;
52
- }
53
- exports.fieldTypeRef = fieldTypeRef;
54
- function fieldTypeShape(field, opts) {
55
- const importPath = (0, codegen_core_1.generatedGraphQLTypeImportPath)(field, opts);
56
- if (importPath == null)
57
- return shapeType(field.type);
58
- const imported = (0, ts_poet_1.imp)(`IMPORTED_PLACEHOLDER@${importPath}`);
59
- imported.symbol = shapeTypeName(field.type); // NOTE: Workaround for ts-poet not recognizing "$" as an identifier
60
- return (0, ts_poet_1.code) `${imported}`;
61
- }
62
- exports.fieldTypeShape = fieldTypeShape;
63
- function pothosBuilder(type, opts) {
64
- const importPath = opts.pothos.builderPath.startsWith(".")
65
- ? path.relative(path.dirname((0, codegen_core_1.filename)(type, opts)), opts.pothos.builderPath)
66
- : opts.pothos.builderPath;
67
- return (0, ts_poet_1.code) `${(0, ts_poet_1.imp)(`builder@${importPath}`)}`;
68
- }
69
- exports.pothosBuilder = pothosBuilder;
package/lib/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
@@ -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/lib/printer.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateFiles = void 0;
4
- const codegen_core_1 = require("@proto-graphql/codegen-core");
5
- const dslgen_1 = require("./dslgen");
6
- function generateFiles(registry, file, opts) {
7
- opts.printer.protobuf = "ts-proto"; // default
8
- const types = (0, codegen_core_1.collectTypesFromFile)(file, opts.type, registry);
9
- switch (opts.printer.fileLayout) {
10
- case "proto_file": {
11
- return [
12
- {
13
- filename: (0, codegen_core_1.filenameFromProtoFile)(file, opts.printer),
14
- content: (0, codegen_core_1.printCodes)(createCodes(types, opts.printer), "protoc-gen-pothos", file),
15
- },
16
- ];
17
- }
18
- case "graphql_type": {
19
- return types.map((t) => ({
20
- filename: (0, codegen_core_1.filename)(t, opts.printer),
21
- content: (0, codegen_core_1.printCodes)(createCodes([t], opts.printer), "protoc-gen-pothos", file),
22
- }));
23
- }
24
- /* istanbul ignore next */
25
- default: {
26
- const _exhaustiveCheck = opts.printer.fileLayout;
27
- throw "unreachable";
28
- }
29
- }
30
- }
31
- exports.generateFiles = generateFiles;
32
- function createCodes(types, opts) {
33
- return [...(0, dslgen_1.createTypeDslCodes)(types, opts)];
34
- }
package/lib/process.d.ts DELETED
@@ -1,2 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,gLAAoD,CAAC"}
package/lib/process.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processRequest = void 0;
4
- const protoc_plugin_helpers_1 = require("@proto-graphql/protoc-plugin-helpers");
5
- const printer_1 = require("./printer");
6
- exports.processRequest = (0, protoc_plugin_helpers_1.createProcessor)({ generateFiles: printer_1.generateFiles, dsl: "pothos" });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=protoc-gen-pothos.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protoc-gen-pothos.d.ts","sourceRoot":"","sources":["../src/protoc-gen-pothos.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const protoc_plugin_helpers_1 = require("@proto-graphql/protoc-plugin-helpers");
4
- const process_1 = require("./process");
5
- (0, protoc_plugin_helpers_1.withCodeGeneratorRequest)(process_1.processRequest);
@@ -1,2 +0,0 @@
1
- export * from "./printers";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dslgen/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./printers";
@@ -1,16 +0,0 @@
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
@@ -1 +0,0 @@
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,36 +0,0 @@
1
- import { compact, protobufGraphQLExtensions, } from "@proto-graphql/codegen-core";
2
- import { code, joinCode, literalOf } from "ts-poet";
3
- import { pothosBuilder, pothosRef } 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 function createEnumTypeCode(type, opts) {
16
- const typeOpts = {
17
- description: type.description,
18
- values: code `{${joinCode(type.values
19
- .filter((v) => !v.isIgnored() && !v.isUnespecified())
20
- .map((ev) => code `${ev.name}: ${literalOf(compact({
21
- description: ev.description,
22
- deprecationReason: ev.deprecationReason,
23
- value: ev.number,
24
- extensions: {
25
- protobufEnumValue: {
26
- name: ev.proto.name,
27
- },
28
- },
29
- }))},`))}} as const`,
30
- extensions: protobufGraphQLExtensions(type),
31
- };
32
- return code `
33
- export const ${pothosRef(type)} =
34
- ${pothosBuilder(type, opts)}.enumType(${literalOf(type.typeName)}, ${literalOf(compact(typeOpts))});
35
- `;
36
- }
@@ -1,41 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,94 +0,0 @@
1
- import { compact, createGetFieldValueCode, EnumType, InputObjectField, ObjectField, ObjectOneofField, ObjectType, protobufGraphQLExtensions, ScalarType, SquashedOneofUnionType, } from "@proto-graphql/codegen-core";
2
- import { code, literalOf } from "ts-poet";
3
- import { createEnumResolverCode } from "./fieldResolver/enumFieldResolver";
4
- import { createNonNullResolverCode } from "./fieldResolver/nonNullResolver";
5
- import { createOneofUnionResolverCode } from "./fieldResolver/oneofUnionResolver";
6
- import { fieldTypeRef } from "./util";
7
- /**
8
- * @example
9
- * ```ts
10
- * t.expose("name", {
11
- * type: "Boolean",
12
- * nullable: true,
13
- * description: "...",
14
- * })
15
- * ```
16
- * ```ts
17
- * t.field({
18
- * type: "Boolean",
19
- * nullable: true,
20
- * description: "...",
21
- * resolve() {
22
- * return true
23
- * }
24
- * })
25
- * ```
26
- */
27
- export function createFieldRefCode(field, opts) {
28
- const isInput = field instanceof InputObjectField;
29
- const baseType = field.type instanceof ScalarType
30
- ? literalOf(field.type.typeName)
31
- : fieldTypeRef(field, opts);
32
- const sourceExpr = code `source`;
33
- let resolverCode;
34
- if (!isInput) {
35
- if (field instanceof ObjectOneofField) {
36
- resolverCode = createOneofUnionResolverCode(sourceExpr, field);
37
- }
38
- else {
39
- const valueExpr = createGetFieldValueCode(sourceExpr, field.proto, opts);
40
- const nullableInProto = field.type instanceof ObjectType ||
41
- (field.type instanceof ScalarType &&
42
- !field.type.isPrimitive() &&
43
- !field.type.isWrapperType());
44
- if (nullableInProto && !field.isNullable()) {
45
- resolverCode = createNonNullResolverCode(valueExpr);
46
- }
47
- if (field.type instanceof EnumType && field instanceof ObjectField) {
48
- resolverCode = createEnumResolverCode(valueExpr, field, opts);
49
- }
50
- if (field.type instanceof SquashedOneofUnionType &&
51
- field instanceof ObjectField) {
52
- resolverCode = createOneofUnionResolverCode(valueExpr, field);
53
- }
54
- }
55
- }
56
- const nullableValue = isInput !== field.isNullable(); /* Logical XOR */
57
- const fieldOpts = {
58
- type: field.isList() ? code `[${baseType}]` : baseType,
59
- [isInput ? "required" : "nullable"]: field.isList()
60
- ? { list: nullableValue, items: isInput /* always non-null */ }
61
- : nullableValue,
62
- description: field.description,
63
- deprecationReason: field.deprecationReason,
64
- resolve: resolverCode ? code `${sourceExpr} => {${resolverCode}}` : null,
65
- extensions: protobufGraphQLExtensions(field),
66
- };
67
- const shouldUseFieldFunc = isInput || resolverCode != null;
68
- return shouldUseFieldFunc
69
- ? code `t.field(${literalOf(compact(fieldOpts))})`
70
- : code `t.expose(${literalOf(field.proto.jsonName)}, ${literalOf(compact(fieldOpts))})`;
71
- }
72
- /**
73
- * @example
74
- * ```ts
75
- * t.field( {
76
- * type: "Boolean",
77
- * nullable: true,
78
- * description: "noop field",
79
- * resolve() {
80
- * return true
81
- * }
82
- * })
83
- * ```
84
- */
85
- export function createNoopFieldRefCode(opts) {
86
- return code `
87
- t.field({
88
- type: "Boolean",
89
- ${opts.input ? "required: false" : "nullable: true"},
90
- description: "noop field",
91
- ${opts.input ? "" : "resolve: () => true,"}
92
- })
93
- `;
94
- }
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
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,57 +0,0 @@
1
- import { protoType, } 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 function createEnumResolverCode(valueExpr, field, opts) {
20
- const createBlockStmtCodes = (valueExpr) => {
21
- const chunks = [];
22
- if (field.type.unspecifiedValue != null) {
23
- const escapeCode = field.isNullable() && !field.isList()
24
- ? code `return null;`
25
- : code `throw new Error("${field.name} is required field. But got unspecified.");`;
26
- chunks.push(code `
27
- if (${valueExpr} === ${protoType(field.type.proto, opts)}.${field.type.unspecifiedValue.proto.name}) {
28
- ${escapeCode}
29
- }
30
- `);
31
- }
32
- for (const ev of field.type.valuesWithIgnored) {
33
- if (!ev.isIgnored())
34
- continue;
35
- chunks.push(code `
36
- if (${valueExpr} === ${protoType(field.type.proto, opts)}.${ev.proto.name}) {
37
- throw new Error("${ev.name} is ignored in GraphQL schema");
38
- }
39
- `);
40
- }
41
- return chunks;
42
- };
43
- if (field.isList()) {
44
- const stmts = createBlockStmtCodes(code `item`);
45
- if (stmts.length === 0) {
46
- return code `return ${valueExpr}`;
47
- }
48
- return code `return ${valueExpr}.map(item => {
49
- ${stmts}
50
- return item;
51
- })`;
52
- }
53
- return code `
54
- ${createBlockStmtCodes(valueExpr)}
55
- return ${valueExpr};
56
- `;
57
- }
@@ -1,3 +0,0 @@
1
- import { Code } from "ts-poet";
2
- export declare function createNonNullResolverCode(valueExpr: Code): Code;
3
- //# sourceMappingURL=nonNullResolver.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
1
- import { code } from "ts-poet";
2
- export function createNonNullResolverCode(valueExpr) {
3
- return code `
4
- return ${valueExpr}!;
5
- `;
6
- }
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}