Notably, this gets us `@actions/github` 6.0.1, which is necessary for `github.context.runAttempt` (so I have also updated `package.json` accordingly). On that note... great job following semver, GitHub! Between this and the non-breaking major version change on `@actions/cache`, I'm starting to feel like nobody on the Actions team understands how software versioning works.
112 lines
4.4 KiB
TypeScript
112 lines
4.4 KiB
TypeScript
import { DescEnum, DescMessage, DescService, FileRegistry } from "@bufbuild/protobuf";
|
|
import * as rt from "@protobuf-ts/runtime";
|
|
import * as rpc from "@protobuf-ts/runtime-rpc";
|
|
/**
|
|
* The protobuf-ts plugin generates code for message types from descriptor
|
|
* protos. This class also creates message types from descriptor protos, but
|
|
* but instead of generating code, it creates the type in-memory.
|
|
*
|
|
* This means that it is possible, for example, to read a message from binary
|
|
* data without any generated code.
|
|
*
|
|
* The protobuf-ts plugin uses the interpreter to read custom options at
|
|
* compile time and convert them to JSON.
|
|
*
|
|
* Since the interpreter creates fully functional message types including
|
|
* reflection information, the protobuf-ts plugin uses the interpreter as
|
|
* single source of truth for generating message interfaces and reflection
|
|
* information.
|
|
*/
|
|
export declare class Interpreter {
|
|
private readonly registry;
|
|
private readonly options;
|
|
private readonly serviceTypes;
|
|
private readonly messageTypes;
|
|
private readonly enumInfos;
|
|
constructor(registry: FileRegistry, options: {
|
|
normalLongType: rt.LongType;
|
|
oneofKindDiscriminator: string;
|
|
synthesizeEnumZeroValue: string | false;
|
|
forceExcludeAllOptions: boolean;
|
|
keepEnumPrefix: boolean;
|
|
useProtoFieldName: boolean;
|
|
});
|
|
/**
|
|
* Returns a map of custom options for the provided descriptor.
|
|
* The map is an object indexed by the extension field name.
|
|
* The value of the extension field is provided in JSON format.
|
|
*
|
|
* This works by:
|
|
* - searching for option extensions for the given descriptor proto
|
|
* in the registry.
|
|
* - for example, providing a google.protobuf.FieldDescriptorProto
|
|
* searches for all extensions on google.protobuf.FieldOption.
|
|
* - extensions are just fields, so we build a synthetic message
|
|
* type with all the (extension) fields.
|
|
* - the field names are created by DescriptorRegistry.getExtensionName(),
|
|
* which produces for example "spec.option_name", where "spec" is
|
|
* the package and "option_name" is the field name.
|
|
* - then we concatenate all unknown field data of the option and
|
|
* read the data with our synthetic message type
|
|
* - the read message is then simply converted to JSON
|
|
*
|
|
* The optional "optionBlacklist" will exclude matching options.
|
|
* The blacklist can contain exact extension names, or use the wildcard
|
|
* character `*` to match a namespace or even all options.
|
|
*
|
|
* Note that options on options (google.protobuf.*Options) are not
|
|
* supported.
|
|
*/
|
|
private readOptions;
|
|
/**
|
|
* Get a runtime type for the given message type name or message descriptor.
|
|
* Creates the type if not created previously.
|
|
*
|
|
* Honors our file option "ts.exclude_options".
|
|
*/
|
|
getMessageType(descriptorOrTypeName: string | DescMessage): rt.IMessageType<rt.UnknownMessage>;
|
|
/**
|
|
* Get a runtime type for the given service type name or service descriptor.
|
|
* Creates the type if not created previously.
|
|
*
|
|
* Honors our file option "ts.exclude_options".
|
|
*/
|
|
getServiceType(descriptorOrTypeName: string | DescService): rpc.ServiceType;
|
|
/**
|
|
* Get runtime information for an enum.
|
|
* Creates the info if not created previously.
|
|
*/
|
|
getEnumInfo(descriptorOrTypeName: string | DescEnum): rt.EnumInfo;
|
|
private static createTypescriptNameForMethod;
|
|
private buildServiceType;
|
|
private buildMethodInfo;
|
|
/**
|
|
* Create a name for a field or a oneof.
|
|
* - use lowerCamelCase unless useProtoFieldName option is enabled
|
|
* - escape reserved object property names by
|
|
* adding '$' at the end
|
|
* - don't have to escape reserved keywords
|
|
*/
|
|
private createTypescriptNameForField;
|
|
private buildFieldInfos;
|
|
private buildFieldInfo;
|
|
private buildEnumInfo;
|
|
private findEnumSharedPrefix;
|
|
private getL;
|
|
private isLong;
|
|
/**
|
|
* Is this a 64 bit integral or fixed type?
|
|
*/
|
|
static isLongValueType(type: rt.ScalarType): boolean;
|
|
}
|
|
/**
|
|
* Builds a typescript enum lookup object,
|
|
* compatible with enums generated by @protobuf-ts/plugin.
|
|
*/
|
|
export declare class RuntimeEnumBuilder {
|
|
private readonly values;
|
|
add(name: string, number: number): void;
|
|
isValid(): boolean;
|
|
build(): rt.EnumInfo[1];
|
|
}
|