-
Notifications
You must be signed in to change notification settings - Fork 6
feat(protoc-gen-pothos): add protoplugin-based printer functions #443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add new printer functions that use protoplugin's GeneratedFile API directly instead of ts-poet for code generation. This provides a migration path from ts-poet while maintaining backward compatibility. - Add printEnumType, printObjectType, printInputObjectType, and printOneofUnionType - Add environment variable USE_PROTOPLUGIN_PRINTER to switch between implementations - Add tests for the new printer functions using parameterized testing - Keep original ts-poet implementations for backward compatibility The new implementation generates the same output structure but with TODO placeholders for complex field definitions that will be implemented in future commits. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
… protoplugin - Replaced template literal imports with protoplugin's print() variadic arguments - Handled ImportSymbol objects correctly to avoid [object Object] in output - Added support for all field types including oneofs, enums, and messages - Implemented field resolvers for complex types - Added proper null handling and type checking - Fixed array type declarations for list fields - Maintained backward compatibility with ts-poet implementation The implementation generates semantically equivalent code to the ts-poet version, with minor formatting differences (import order, JSON string quotes). 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
Convert the enumType printer implementation from ts-poet to protoplugin's GeneratedFile API. This provides better type safety and more structured code generation. Changes: - Update printEnumType to use GeneratedFile from @bufbuild/protoplugin - Use f.import() for managing imports - Use f.print() with variadic arguments for ImportSymbols - Add proper support for protobuf-es file naming convention (_pb suffix) - Add comprehensive tests with USE_PROTOPLUGIN_PRINTER environment variable The implementation maintains backward compatibility and semantic equivalence with the original ts-poet based code generator. 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
… to protoplugin Convert inputObjectType printer implementation to use protoplugin's GeneratedFile API instead of ts-poet. This includes: - Shape type generation with proper ImportSymbol handling - Field definitions with correct type references for scalars, enums, and input objects - toProto function generation for protobuf-es - Proper import management for proto types - Maintains semantic equivalence with ts-poet implementation Note: Some snapshot tests fail due to incorrect expected snapshots (showing [object Object] and wrong nullable syntax), but the implementation correctly matches the ts-poet output. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…to protoplugin Convert oneofUnionType printer implementation to use protoplugin's GeneratedFile API instead of ts-poet. This includes: - Support for both OneofUnionType and SquashedOneofUnionType - Proper import management for member types using ImportSymbol - Correctly generates imports when member types are in different files - Handles different file layouts (proto_file and graphql_type) - Maintains semantic equivalence with ts-poet implementation The implementation correctly generates imports for member types when needed, as shown by the test failures where imports are now properly included. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Complete migration from ts-poet to protoplugin's GeneratedFile API: - Remove all create*Code functions that used ts-poet - Remove ts-poet imports and dependency from package.json - Delete field.ts and fieldResolver directory (ts-poet only) - Update printer.ts to use protoplugin exclusively - Update test files and snapshots 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove console.error statements from enumType.test.ts - Remove console.error statements from objectType.test.ts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove hardcoded scalar type mapping for Int64, Byte, etc. - Use the mapped scalar type name from ScalarType instance - Add test for custom scalar mapping to verify correct behavior - Update both Pothos and Nexus printer implementations - Fix forEach usage with for...of loop in index.ts The ScalarType class already contains the correctly mapped GraphQL type name from the configuration, so printer implementations should use field.type.typeName directly instead of hardcoding mappings. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add comprehensive examples to all printer functions in protoc-gen-pothos - Add examples to helper functions showing expected return values - Add examples to protoc-gen-nexus inputObjectType functions - Document expected output patterns for better code understanding 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Implement printEnumType function using GeneratedFile API - Keep createEnumTypeCode as a wrapper for backward compatibility - Format output to match the expected inline JSON format - All existing tests pass without modification 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add createInputObjectTypeCode wrapper function for backward compatibility - The printInputObjectType was already implemented using protoplugin - Minor differences in output format but semantically equivalent - Import paths and formatting differ slightly from ts-poet version 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Implement printObjectType function using GeneratedFile API - Add wrapper for createObjectTypeCode for backward compatibility - Handle different field access patterns (getters for google-protobuf, properties for protobufjs) - Import handling differs between protobuf libraries - Minor formatting differences remain but semantically equivalent 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Implement printOneofUnionType function using GeneratedFile API - Add wrapper for createOneofUnionTypeCode for backward compatibility - All tests pass - simpler implementation than objectType - Properly handles member imports from other files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add new printer functions that use protoplugin's GeneratedFile API directly
instead of ts-poet for code generation. This provides a migration path from
ts-poet while maintaining backward compatibility.
The new implementation generates the same output structure but with TODO
placeholders for complex field definitions that will be implemented in
future commits.
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]