Skip to content

Commit

Permalink
V2: Mark all exports from codegenv1 private (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Apr 23, 2024
1 parent 42087dc commit f4bb5e1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/protobuf/src/codegenv1/restore-json-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import type { DescriptorProto } from "../wkt/gen/google/protobuf/descriptor_pb.j
import { protoCamelCase } from "../reflect/names.js";
import { unsafeIsSetExplicit } from "../reflect/unsafe.js";

/**
* @private
*/
export function restoreJsonNames(message: DescriptorProto) {
for (const f of message.field) {
if (!unsafeIsSetExplicit(f, "jsonName")) {
Expand Down
9 changes: 9 additions & 0 deletions packages/protobuf/src/codegenv1/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @private
*/
export const packageName = "@bufbuild/protobuf";

/**
* @private
*/
export const wktPublicImportPaths: Readonly<Record<string, string>> = {
"google/protobuf/compiler/plugin.proto": packageName + "/wkt",
"google/protobuf/any.proto": packageName + "/wkt",
Expand All @@ -29,6 +35,9 @@ export const wktPublicImportPaths: Readonly<Record<string, string>> = {
"google/protobuf/wrappers.proto": packageName + "/wkt",
};

/**
* @private
*/
// prettier-ignore
export const symbols = {
isMessage: {typeOnly: false, bootstrapWktFrom: "../../is-message.js", from: packageName },
Expand Down
40 changes: 40 additions & 0 deletions packages/protobuf/src/codegenv1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,61 @@ import type {
DescService,
} from "../desc-types.js";

/**
* Describes a protobuf source file.
*
* @private
*/
export type GenDescFile = DescFile;

/**
* Describes a message declaration in a protobuf source file.
*
* This type is identical to DescMessage, but carries additional type
* information.
*
* @private
*/
export type GenDescMessage<RuntimeShape extends Message> = DescMessage &
brand<RuntimeShape>;

/**
* Describes an enumeration in a protobuf source file.
*
* This type is identical to DescEnum, but carries additional type
* information.
*
* @private
*/
export type GenDescEnum<RuntimeShape> = DescEnum & brand<RuntimeShape>;

/**
* Describes an extension in a protobuf source file.
*
* This type is identical to DescExtension, but carries additional type
* information.
*
* @private
*/
export type GenDescExtension<
Extendee extends Message = Message,
RuntimeShape = unknown,
> = DescExtension & brand<Extendee, RuntimeShape>;

/**
* Describes a service declaration in a protobuf source file.
*
* This type is identical to DescService, but carries additional type
* information.
*
* @private
*/
export type GenDescService<RuntimeShape extends GenDescServiceShape> =
DescService & brand<RuntimeShape>;

/**
* @private
*/
export type GenDescServiceShape = {
[localName: string]: {
kind: "unary" | "server_streaming" | "client_streaming" | "bidi_streaming";
Expand Down

0 comments on commit f4bb5e1

Please sign in to comment.