From aa015f00d1e20f019dcfeedd470db6cbe84f11ca Mon Sep 17 00:00:00 2001 From: higan Date: Fri, 10 Mar 2023 21:24:28 +0800 Subject: [PATCH] :sparkles: Change enum impl --- examples/example-simple/package.json | 14 +- lerna.json | 2 +- package.json | 1 + packages/sisyphus-cli/package.json | 10 +- packages/sisyphus-cli/src/index.ts | 2 +- packages/sisyphus-cli/src/root.ts | 2 +- packages/sisyphus-compiler/package.json | 4 +- packages/sisyphus-compiler/src/aip/state.ts | 1 - packages/sisyphus-compiler/src/core/enum.ts | 6 +- packages/sisyphus-compiler/src/core/field.ts | 12 +- packages/sisyphus-compiler/src/descriptor.ts | 30 ++--- .../src/google/protobuf/descriptor.ts | 82 ++++++------ .../sisyphus-compiler/src/import-manager.ts | 2 +- packages/sisyphus-compiler/src/index.ts | 2 +- .../sisyphus-compiler/src/protobuf/enum.ts | 3 + .../sisyphus-compiler/src/protobuf/file.ts | 6 +- .../sisyphus-compiler/src/protobuf/message.ts | 45 ++++--- .../sisyphus-compiler/src/wellknown/core.ts | 92 ++++++++------ .../sisyphus-compiler/src/wellknown/proto.ts | 95 ++++++++------ packages/sisyphus-google-aip/package.json | 10 +- .../src/google/longrunning/operations.aip.ts | 22 +--- packages/sisyphus-google-proto/package.json | 10 +- .../src/google/api/annotations.proto.ts | 2 +- .../src/google/api/auth.proto.ts | 9 +- .../src/google/api/log.proto.ts | 2 +- .../src/google/api/metric.proto.ts | 5 +- .../google/api/monitored_resource.proto.ts | 10 +- .../src/google/api/service.proto.ts | 12 +- .../src/google/api/system_parameter.proto.ts | 6 +- .../src/google/cloud/audit/audit_log.proto.ts | 13 +- .../src/google/geo/type/viewport.proto.ts | 2 +- .../google/longrunning/operations.proto.ts | 13 +- .../src/google/rpc/error_details.proto.ts | 13 +- packages/sisyphus-google/package.json | 6 +- .../src/google/api/annotations.ts | 2 +- .../sisyphus-google/src/google/api/backend.ts | 24 ++-- .../src/google/api/config_change.ts | 10 +- .../src/google/api/consumer.ts | 12 +- .../src/google/api/error_reason.ts | 120 +++++++++--------- .../src/google/api/field_behavior.ts | 22 ++-- .../sisyphus-google/src/google/api/label.ts | 8 +- .../src/google/api/launch_stage.ts | 16 +-- .../sisyphus-google/src/google/api/metric.ts | 72 +++++------ .../src/google/api/monitored_resource.ts | 10 +- .../src/google/api/resource.ts | 18 +-- .../sisyphus-google/src/google/api/service.ts | 16 +-- .../src/google/cloud/audit/audit_log.ts | 4 +- .../src/google/cloud/extended_operations.ts | 12 +- .../src/google/logging/type/log_severity.ts | 18 +-- .../src/google/longrunning/operations.ts | 2 +- .../sisyphus-google/src/google/rpc/code.ts | 80 ++++++------ .../src/google/type/calendar_period.ts | 16 +-- .../src/google/type/dayofweek.ts | 16 +-- .../sisyphus-google/src/google/type/month.ts | 26 ++-- packages/sisyphus-protoc/package.json | 2 +- packages/sisyphus-protoc/src/protoc.ts | 11 +- packages/sisyphus-protoc/src/util.ts | 7 + packages/sisyphus-runtime-proto/package.json | 7 +- packages/sisyphus-runtime-proto/src/README.md | 33 ----- .../src/google/protobuf/descriptor.proto.ts | 29 ++++- packages/sisyphus-runtime/package.json | 5 +- packages/sisyphus-runtime/src/enum.ts | 12 ++ .../src/google/protobuf/api.ts | 4 +- .../src/google/protobuf/descriptor.ts | 80 ++++++------ .../src/google/protobuf/type.ts | 58 ++++----- packages/sisyphus-runtime/src/index.ts | 1 + packages/sisyphus-transport-aip/package.json | 6 +- 67 files changed, 699 insertions(+), 606 deletions(-) delete mode 100644 packages/sisyphus-runtime-proto/src/README.md create mode 100644 packages/sisyphus-runtime/src/enum.ts diff --git a/examples/example-simple/package.json b/examples/example-simple/package.json index fc1475a..b2a846e 100644 --- a/examples/example-simple/package.json +++ b/examples/example-simple/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/example-simple", - "version": "2.0.8", + "version": "2.1.0", "description": "Example project using sisyphus.js", "main": "dist/index.js", "scripts": { @@ -26,14 +26,14 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "devDependencies": { - "@sisyphus.js/cli": "^2.0.8", - "@sisyphus.js/google.proto": "^2.0.8", - "@sisyphus.js/runtime.proto": "^2.0.8" + "@sisyphus.js/cli": "^2.1.0", + "@sisyphus.js/google.proto": "^2.1.0", + "@sisyphus.js/runtime.proto": "^2.1.0" }, "dependencies": { - "@sisyphus.js/google": "^2.0.8", - "@sisyphus.js/runtime": "^2.0.8", - "@sisyphus.js/transport-aip": "^2.0.8" + "@sisyphus.js/google": "^2.1.0", + "@sisyphus.js/runtime": "^2.1.0", + "@sisyphus.js/transport-aip": "^2.1.0" }, "directories": { "proto": "proto" diff --git a/lerna.json b/lerna.json index 6b854e6..484b2c2 100644 --- a/lerna.json +++ b/lerna.json @@ -3,5 +3,5 @@ "packages/*", "examples/*" ], - "version": "2.0.8" + "version": "2.1.0" } diff --git a/package.json b/package.json index 21789a5..09f727e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ }, "scripts": { "clean": "lerna run clean", + "bootstrap": "lerna bootstrap --hoist", "build": "lerna bootstrap --hoist && lerna run clean && lerna run build", "publish": "lerna publish from-package --yes --no-verify-access", "watch": "lerna run --stream --no-sort --concurrency 9999 watch", diff --git a/packages/sisyphus-cli/package.json b/packages/sisyphus-cli/package.json index 23fdbac..bc33464 100644 --- a/packages/sisyphus-cli/package.json +++ b/packages/sisyphus-cli/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/cli", - "version": "2.0.8", + "version": "2.1.0", "description": "Protoc cli for sisyphus project on js platform", "bin": { "sisygen": "lib/index.js" @@ -30,10 +30,10 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "dependencies": { - "@sisyphus.js/compiler": "^2.0.8", - "@sisyphus.js/protoc": "^2.0.8", - "@sisyphus.js/runtime": "^2.0.8", - "@sisyphus.js/runtime.proto": "^2.0.8", + "@sisyphus.js/compiler": "^2.1.0", + "@sisyphus.js/protoc": "^2.1.0", + "@sisyphus.js/runtime": "^2.1.0", + "@sisyphus.js/runtime.proto": "^2.1.0", "commander": "^10.0.0", "npmlog": "^7.0.1" } diff --git a/packages/sisyphus-cli/src/index.ts b/packages/sisyphus-cli/src/index.ts index c77af97..f354e16 100644 --- a/packages/sisyphus-cli/src/index.ts +++ b/packages/sisyphus-cli/src/index.ts @@ -124,7 +124,7 @@ export async function main(args: string[]): Promise { advance({ kind: 'files', parent: undefined, - descriptor: new FileDescSet(fileDescSet), + descriptor: new FileDescSet(fileDescSet), target: files, src: targetProtos, lib: generatedModules diff --git a/packages/sisyphus-cli/src/root.ts b/packages/sisyphus-cli/src/root.ts index 0134e05..66ccec6 100644 --- a/packages/sisyphus-cli/src/root.ts +++ b/packages/sisyphus-cli/src/root.ts @@ -35,7 +35,7 @@ async function discoverGeneratedModuleInPackage(packageInfo: PackageJson, dir: s for (let file of sisyphusDist.generatedFiles) { const moduleName = tsModuleName(file) if (moduleName == undefined) return - generatedModules['/' + moduleName] = path.join(packageInfo.name, packageInfo.directories?.lib ?? 'lib', moduleName) + generatedModules['/' + moduleName] = path.posix.join(packageInfo.name, packageInfo.directories?.lib ?? 'lib', moduleName) } return packageInfo diff --git a/packages/sisyphus-compiler/package.json b/packages/sisyphus-compiler/package.json index a237dce..35655bb 100644 --- a/packages/sisyphus-compiler/package.json +++ b/packages/sisyphus-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/compiler", - "version": "2.0.8", + "version": "2.1.0", "description": "Precompiled google common protos by sisyphus protobuf compiler", "main": "lib/index.js", "sisyphus": { @@ -35,6 +35,6 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "dependencies": { - "@sisyphus.js/protoc": "^2.0.8" + "@sisyphus.js/protoc": "^2.1.0" } } diff --git a/packages/sisyphus-compiler/src/aip/state.ts b/packages/sisyphus-compiler/src/aip/state.ts index 8f0d3f9..a116cc9 100644 --- a/packages/sisyphus-compiler/src/aip/state.ts +++ b/packages/sisyphus-compiler/src/aip/state.ts @@ -1,5 +1,4 @@ import {CodeBuilder} from '../code-builder' -import {FileGeneratingState} from '../core/state' import {FileDescriptor, MethodDescriptor, ServiceDescriptor} from '../descriptor' import {GeneratingState} from '../generator' import {FilesGeneratingState} from '../state' diff --git a/packages/sisyphus-compiler/src/core/enum.ts b/packages/sisyphus-compiler/src/core/enum.ts index 3dd65be..cf85d04 100644 --- a/packages/sisyphus-compiler/src/core/enum.ts +++ b/packages/sisyphus-compiler/src/core/enum.ts @@ -2,7 +2,7 @@ import {EnumGeneratingState, EnumValueGeneratingState} from './state' generate('enum', it => { const builder = it.target - it.generatedElements ++ + it.generatedElements++ builder.normalize().lineComment(...it.descriptor.comments()) builder.normalize().document(it.descriptor.document()) @@ -25,11 +25,11 @@ generate('enum', it => { generate('enumValue', it => { const builder = it.target - it.generatedElements ++ + it.generatedElements++ builder.normalize().lineComment(...it.descriptor.comments()) builder.normalize().document(it.descriptor.document()) - builder.append(`${it.descriptor.simpleName()} = '${it.descriptor.name()}',`) + builder.append(`${it.descriptor.name()} = ${it.descriptor.number()},`) builder.trailingComment(it.descriptor.trailingComment()) builder.ln() }) \ No newline at end of file diff --git a/packages/sisyphus-compiler/src/core/field.ts b/packages/sisyphus-compiler/src/core/field.ts index 84f6762..229af0d 100644 --- a/packages/sisyphus-compiler/src/core/field.ts +++ b/packages/sisyphus-compiler/src/core/field.ts @@ -1,9 +1,9 @@ import {CodeBuilder} from '../code-builder' -import {ExtensionDescriptor, FieldDescriptor, MessageDescriptor} from '../descriptor' +import {EnumDescriptor, ExtensionDescriptor, FieldDescriptor, MessageDescriptor} from '../descriptor' import {ExtensionGeneratingState, FieldGeneratingState, OneofGeneratingState} from './state' generate('field', it => { - it.generatedElements ++ + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -35,7 +35,7 @@ generate('oneof', it => { }) generate('extension', it => { - it.generatedElements ++ + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -76,7 +76,7 @@ function type(builder: CodeBuilder, field: FieldDescriptor | ExtensionDescriptor break // case 'TYPE_GROUP': case 'TYPE_MESSAGE': - case 'TYPE_ENUM': + case 'TYPE_ENUM': { const wellknown = wellknownType(builder, field.descriptor.typeName ?? '', protobuf) if (wellknown !== null) { return wellknown @@ -87,7 +87,11 @@ function type(builder: CodeBuilder, field: FieldDescriptor | ExtensionDescriptor return mapType(builder, target) const importName = builder.importManager.import(lib, target.importName()) result = target.fullImportName(importName) + if (target instanceof EnumDescriptor) { + result = `${result} | (keyof typeof ${result})` + } break + } default: throw new Error(`Unsupported field type '${field.descriptor.type}'`) } diff --git a/packages/sisyphus-compiler/src/descriptor.ts b/packages/sisyphus-compiler/src/descriptor.ts index abc0db5..393326f 100644 --- a/packages/sisyphus-compiler/src/descriptor.ts +++ b/packages/sisyphus-compiler/src/descriptor.ts @@ -705,24 +705,24 @@ function arrayEquals(a: any[], b: any[]): boolean { } function fieldPacked(syntax: string | undefined, descriptor: Google.FieldDescriptorProto) { - if (descriptor.label != Google.FieldDescriptorProto.Label.REPEATED) return undefined + if (descriptor.label != 'LABEL_REPEATED') return undefined let defaultPacked = false if (syntax == 'proto3') { switch (descriptor.type) { - case Google.FieldDescriptorProto.Type.BOOL: - case Google.FieldDescriptorProto.Type.UINT32: - case Google.FieldDescriptorProto.Type.UINT64: - case Google.FieldDescriptorProto.Type.INT32: - case Google.FieldDescriptorProto.Type.INT64: - case Google.FieldDescriptorProto.Type.SINT32: - case Google.FieldDescriptorProto.Type.SINT64: - case Google.FieldDescriptorProto.Type.DOUBLE: - case Google.FieldDescriptorProto.Type.FLOAT: - case Google.FieldDescriptorProto.Type.FIXED32: - case Google.FieldDescriptorProto.Type.FIXED64: - case Google.FieldDescriptorProto.Type.SFIXED32: - case Google.FieldDescriptorProto.Type.SFIXED64: - case Google.FieldDescriptorProto.Type.ENUM: + case 'TYPE_BOOL': + case 'TYPE_UINT32': + case 'TYPE_UINT64': + case 'TYPE_INT32': + case 'TYPE_INT64': + case 'TYPE_SINT32': + case 'TYPE_SINT64': + case 'TYPE_DOUBLE': + case 'TYPE_FLOAT': + case 'TYPE_FIXED32': + case 'TYPE_FIXED64': + case 'TYPE_SFIXED32': + case 'TYPE_SFIXED64': + case 'TYPE_ENUM': defaultPacked = true break } diff --git a/packages/sisyphus-compiler/src/google/protobuf/descriptor.ts b/packages/sisyphus-compiler/src/google/protobuf/descriptor.ts index 1f9a8d3..67562f5 100644 --- a/packages/sisyphus-compiler/src/google/protobuf/descriptor.ts +++ b/packages/sisyphus-compiler/src/google/protobuf/descriptor.ts @@ -133,13 +133,13 @@ export interface FieldDescriptorProto { number?: number - label?: FieldDescriptorProto.Label + label?: FieldDescriptorProto.Label | (keyof typeof FieldDescriptorProto.Label) /** * If type_name is set, this need not be set. If both this and type_name * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. */ - type?: FieldDescriptorProto.Type + type?: FieldDescriptorProto.Type | (keyof typeof FieldDescriptorProto.Type) /** * For message and enum types, this is the name of the type. If the name @@ -214,31 +214,31 @@ export namespace FieldDescriptorProto { * 0 is reserved for errors. * Order is weird for historical reasons. */ - DOUBLE = 'TYPE_DOUBLE', + TYPE_DOUBLE = 1, - FLOAT = 'TYPE_FLOAT', + TYPE_FLOAT = 2, /** * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if * negative values are likely. */ - INT64 = 'TYPE_INT64', + TYPE_INT64 = 3, - UINT64 = 'TYPE_UINT64', + TYPE_UINT64 = 4, /** * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if * negative values are likely. */ - INT32 = 'TYPE_INT32', + TYPE_INT32 = 5, - FIXED64 = 'TYPE_FIXED64', + TYPE_FIXED64 = 6, - FIXED32 = 'TYPE_FIXED32', + TYPE_FIXED32 = 7, - BOOL = 'TYPE_BOOL', + TYPE_BOOL = 8, - STRING = 'TYPE_STRING', + TYPE_STRING = 9, /** * Tag-delimited aggregate. @@ -246,24 +246,24 @@ export namespace FieldDescriptorProto { * implementations should still be able to parse the group wire format and * treat group fields as unknown fields. */ - GROUP = 'TYPE_GROUP', + TYPE_GROUP = 10, - MESSAGE = 'TYPE_MESSAGE', // Length-delimited aggregate. + TYPE_MESSAGE = 11, // Length-delimited aggregate. /** New in version 2. */ - BYTES = 'TYPE_BYTES', + TYPE_BYTES = 12, - UINT32 = 'TYPE_UINT32', + TYPE_UINT32 = 13, - ENUM = 'TYPE_ENUM', + TYPE_ENUM = 14, - SFIXED32 = 'TYPE_SFIXED32', + TYPE_SFIXED32 = 15, - SFIXED64 = 'TYPE_SFIXED64', + TYPE_SFIXED64 = 16, - SINT32 = 'TYPE_SINT32', // Uses ZigZag encoding. + TYPE_SINT32 = 17, // Uses ZigZag encoding. - SINT64 = 'TYPE_SINT64', // Uses ZigZag encoding. + TYPE_SINT64 = 18, // Uses ZigZag encoding. } export namespace Type { @@ -272,11 +272,11 @@ export namespace FieldDescriptorProto { export enum Label { /** 0 is reserved for errors */ - OPTIONAL = 'LABEL_OPTIONAL', + LABEL_OPTIONAL = 1, - REQUIRED = 'LABEL_REQUIRED', + LABEL_REQUIRED = 2, - REPEATED = 'LABEL_REPEATED', + LABEL_REPEATED = 3, } export namespace Label { @@ -396,7 +396,7 @@ export namespace MethodDescriptorProto { // Each of the definitions above may have "options" attached. These are // just annotations which may cause code to be generated slightly differently // or may contain hints for code that manipulates protocol messages. -// +// // Clients may define custom options as extensions of the *Options messages. // These extensions may not yet be known at parsing time, so the parser cannot // store the values in them. Instead it stores them in a field in the *Options @@ -404,7 +404,7 @@ export namespace MethodDescriptorProto { // across all *Options messages. We then use this field to populate the // extensions when we build a descriptor, at which point all protos have been // parsed and so all extensions are known. -// +// // Extension numbers for custom options may be chosen as follows: // * For options which will only be used within a single application or // organization, or for experimental options, use field numbers 50000 @@ -463,7 +463,7 @@ export interface FileOptions { */ javaStringCheckUtf8?: boolean - optimizeFor?: FileOptions.OptimizeMode + optimizeFor?: FileOptions.OptimizeMode | (keyof typeof FileOptions.OptimizeMode) /** * Sets the Go package where structs generated from this .proto will be @@ -564,12 +564,12 @@ export namespace FileOptions { /** Generated classes can be optimized for speed or code size. */ export enum OptimizeMode { - SPEED = 'SPEED', // Generate complete code for parsing, serialization, + SPEED = 1, // Generate complete code for parsing, serialization, /** etc. */ - CODE_SIZE = 'CODE_SIZE', // Use ReflectionOps to implement these methods. + CODE_SIZE = 2, // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 'LITE_RUNTIME', // Generate code using MessageLite and the lite runtime. + LITE_RUNTIME = 3, // Generate code using MessageLite and the lite runtime. } export namespace OptimizeMode { @@ -655,7 +655,7 @@ export interface FieldOptions { * options below. This option is not yet implemented in the open source * release -- sorry, we'll try to include it in a future version! */ - ctype?: FieldOptions.CType + ctype?: FieldOptions.CType | (keyof typeof FieldOptions.CType) /** * The packed option can be enabled for repeated primitive fields to enable @@ -679,7 +679,7 @@ export interface FieldOptions { * This option is an enum to permit additional types to be added, e.g. * goog.math.Integer. */ - jstype?: FieldOptions.JSType + jstype?: FieldOptions.JSType | (keyof typeof FieldOptions.JSType) /** * Should this field be parsed lazily? Lazy applies only to message-type @@ -746,11 +746,11 @@ export namespace FieldOptions { export enum CType { /** Default mode. */ - STRING = 'STRING', + STRING = 0, - CORD = 'CORD', + CORD = 1, - STRING_PIECE = 'STRING_PIECE', + STRING_PIECE = 2, } export namespace CType { @@ -759,13 +759,13 @@ export namespace FieldOptions { export enum JSType { /** Use the default type. */ - NORMAL = 'JS_NORMAL', + JS_NORMAL = 0, /** Use JavaScript strings. */ - STRING = 'JS_STRING', + JS_STRING = 1, /** Use JavaScript numbers. */ - NUMBER = 'JS_NUMBER', + JS_NUMBER = 2, } export namespace JSType { @@ -858,7 +858,7 @@ export interface MethodOptions { */ deprecated?: boolean - idempotencyLevel?: MethodOptions.IdempotencyLevel + idempotencyLevel?: MethodOptions.IdempotencyLevel | (keyof typeof MethodOptions.IdempotencyLevel) /** The parser stores options it doesn't recognize here. See above. */ uninterpretedOption?: UninterpretedOption[] @@ -873,11 +873,11 @@ export namespace MethodOptions { * methods, and PUT verb for idempotent methods instead of the default POST. */ export enum IdempotencyLevel { - IDEMPOTENCY_UNKNOWN = 'IDEMPOTENCY_UNKNOWN', + IDEMPOTENCY_UNKNOWN = 0, - NO_SIDE_EFFECTS = 'NO_SIDE_EFFECTS', // implies idempotent + NO_SIDE_EFFECTS = 1, // implies idempotent - IDEMPOTENT = 'IDEMPOTENT', // idempotent, but may have side effects + IDEMPOTENT = 2, // idempotent, but may have side effects } export namespace IdempotencyLevel { diff --git a/packages/sisyphus-compiler/src/import-manager.ts b/packages/sisyphus-compiler/src/import-manager.ts index 778b613..44f17d2 100644 --- a/packages/sisyphus-compiler/src/import-manager.ts +++ b/packages/sisyphus-compiler/src/import-manager.ts @@ -93,7 +93,7 @@ export class SimpleImportManager implements ImportManager { private importPath(lib: string): string { if (lib.startsWith('/')) { - lib = path.relative(path.dirname(this._current), lib) + lib = path.posix.relative(path.posix.dirname(this._current), lib) if (!lib.startsWith('.')) { lib = './' + lib } diff --git a/packages/sisyphus-compiler/src/index.ts b/packages/sisyphus-compiler/src/index.ts index fb87ca0..7eb9c0e 100644 --- a/packages/sisyphus-compiler/src/index.ts +++ b/packages/sisyphus-compiler/src/index.ts @@ -25,7 +25,7 @@ global.advance = function >(ini if (generator.kind !== state.kind) continue generator.generate(state) if (!state.continue) { - return state.generatedElements + break } } diff --git a/packages/sisyphus-compiler/src/protobuf/enum.ts b/packages/sisyphus-compiler/src/protobuf/enum.ts index e86b20b..3a2a3b3 100644 --- a/packages/sisyphus-compiler/src/protobuf/enum.ts +++ b/packages/sisyphus-compiler/src/protobuf/enum.ts @@ -6,6 +6,7 @@ import { generate('enum:proto', it => { const builder = it.target + it.generatedElements++ builder.normalize().beginBlock(`namespace ${it.descriptor.enumName()}`) @@ -16,6 +17,7 @@ generate('enum:proto', it => { generate('enum:proto:impl', it => { const builder = it.target + it.generatedElements++ let importName = builder.importManager.import(`/${it.descriptor.file().tsModulePath()}`, it.descriptor.importName()) builder.normalize().beginBlock(`${it.descriptor.fullImportName(importName)}.descriptor =`) @@ -40,6 +42,7 @@ generate('enum:proto:impl', it => { generate('enumValue:proto:descriptor', it => { const builder = it.target + it.generatedElements++ builder.normalize().appendLn(`${it.descriptor.number()}: '${it.descriptor.name()}',`) builder.normalize().appendLn(`${it.descriptor.name()}: ${it.descriptor.number()},`) diff --git a/packages/sisyphus-compiler/src/protobuf/file.ts b/packages/sisyphus-compiler/src/protobuf/file.ts index 05d89e5..27f1e1e 100644 --- a/packages/sisyphus-compiler/src/protobuf/file.ts +++ b/packages/sisyphus-compiler/src/protobuf/file.ts @@ -22,14 +22,10 @@ generate('files', it => { }) if (elements > 0) { it.target.push({ - name: file.tsFile('aip'), + name: file.tsFile('proto'), content: builder.build() }) } - it.target.push({ - name: file.tsFile('proto'), - content: builder.build() - }) } }) diff --git a/packages/sisyphus-compiler/src/protobuf/message.ts b/packages/sisyphus-compiler/src/protobuf/message.ts index 08e3462..a27c9bf 100644 --- a/packages/sisyphus-compiler/src/protobuf/message.ts +++ b/packages/sisyphus-compiler/src/protobuf/message.ts @@ -1,7 +1,6 @@ import util from 'util' import {CodeBuilder} from '../code-builder' import {ExtensionDescriptor, FieldDescriptor, MessageDescriptor} from '../descriptor' -import {FieldDescriptorProto} from '../google/protobuf/descriptor' import { ExtensionProtobufGeneratingState, FieldProtobufDescriptorGeneratingState, @@ -12,6 +11,7 @@ import { generate('message:proto', it => { if (it.descriptor.mapEntry()) return const builder = it.target + it.generatedElements++ builder.beginBlock(`namespace ${it.descriptor.interfaceName()}`) @@ -37,6 +37,8 @@ generate('message:proto', it => { generate('message:proto:impl', it => { if (it.descriptor.mapEntry()) return + it.generatedElements++ + const builder = it.target let importName = builder.importManager.import(`/${it.descriptor.file().tsModulePath()}`, it.descriptor.importName()) builder.normalize().beginBlock(`${it.descriptor.fullImportName(importName)}.descriptor = protobufDefinition({`) @@ -99,7 +101,7 @@ generate('message:proto:impl', it => { generate('field:proto:descriptor', it => { const builder = it.target -// fields: [{kind: 'message', name: 'values', num: 1, type: () => Value.descriptor, repeat: true}] + it.generatedElements++ const kind = fieldKind(it.descriptor) builder.append(`{kind: '${kind}', name: '${it.descriptor.name()}', num: ${it.descriptor.descriptor.number}, `) @@ -138,6 +140,7 @@ generate('field:proto:descriptor', it => generate('extension:proto', it => { const builder = it.target + it.generatedElements++ builder.importManager.import('@sisyphus.js/runtime.proto') @@ -153,14 +156,14 @@ generate('extension:proto', it => { function fieldKind(desc: FieldDescriptor | ExtensionDescriptor): string { switch (desc.descriptor.type) { - case FieldDescriptorProto.Type.MESSAGE: + case 'TYPE_MESSAGE': const type = desc.root().lookup(desc.descriptor.typeName ?? '') if (type instanceof MessageDescriptor && type.mapEntry()) { return 'map' } else { return 'message' } - case FieldDescriptorProto.Type.ENUM: + case 'TYPE_ENUM': return 'enum' default: return 'scalar' @@ -169,38 +172,38 @@ function fieldKind(desc: FieldDescriptor | ExtensionDescriptor): string { function type(builder: CodeBuilder, field: FieldDescriptor | ExtensionDescriptor): string { switch (field.descriptor.type) { - case FieldDescriptorProto.Type.DOUBLE: + case 'TYPE_DOUBLE': return `1 /* DOUBLE */` - case FieldDescriptorProto.Type.FLOAT: + case 'TYPE_FLOAT': return `2 /* FLOAT */` - case FieldDescriptorProto.Type.INT32: + case 'TYPE_INT32': return `5 /* INT32 */` - case FieldDescriptorProto.Type.SINT32: + case 'TYPE_SINT32': return `17 /* SINT32 */` - case FieldDescriptorProto.Type.UINT32: + case 'TYPE_UINT32': return `13 /* UINT32 */` - case FieldDescriptorProto.Type.FIXED32: + case 'TYPE_FIXED32': return `7 /* FIXED32 */` - case FieldDescriptorProto.Type.SFIXED32: + case 'TYPE_SFIXED32': return `15 /* SFIXED32 */` - case FieldDescriptorProto.Type.INT64: + case 'TYPE_INT64': return `3 /* INT64 */` - case FieldDescriptorProto.Type.UINT64: + case 'TYPE_UINT64': return `4 /* UINT64 */` - case FieldDescriptorProto.Type.SINT64: + case 'TYPE_SINT64': return `18 /* SINT64 */` - case FieldDescriptorProto.Type.FIXED64: + case 'TYPE_FIXED64': return `6 /* FIXED64 */` - case FieldDescriptorProto.Type.SFIXED64: + case 'TYPE_SFIXED64': return `16 /* SFIXED64 */` - case FieldDescriptorProto.Type.BOOL: + case 'TYPE_BOOL': return `8 /* BOOL */` - case FieldDescriptorProto.Type.BYTES: + case 'TYPE_BYTES': return `12 /* BYTES */` - case FieldDescriptorProto.Type.STRING: + case 'TYPE_STRING': return `9 /* STRING */` - case FieldDescriptorProto.Type.MESSAGE: - case FieldDescriptorProto.Type.ENUM: + case 'TYPE_MESSAGE': + case 'TYPE_ENUM': const [lib, target] = field.file().import(field.descriptor.typeName ?? '', 'proto') const importName = builder.importManager.import(lib, target.importName()) diff --git a/packages/sisyphus-compiler/src/wellknown/core.ts b/packages/sisyphus-compiler/src/wellknown/core.ts index d6dcb0f..7e100e6 100644 --- a/packages/sisyphus-compiler/src/wellknown/core.ts +++ b/packages/sisyphus-compiler/src/wellknown/core.ts @@ -21,12 +21,11 @@ generate>('file:header', it => { } return [lib, name] } - - return true }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Any') return false + if (it.descriptor.fullname() != 'google.protobuf.Any') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -38,11 +37,12 @@ generate('message', it => { builder.beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Duration') return false + if (it.descriptor.fullname() != 'google.protobuf.Duration') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -53,11 +53,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Empty') return false + if (it.descriptor.fullname() != 'google.protobuf.Empty') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -67,11 +68,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.FieldMask') return false + if (it.descriptor.fullname() != 'google.protobuf.FieldMask') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -82,11 +84,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Struct') return false + if (it.descriptor.fullname() != 'google.protobuf.Struct') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -96,11 +99,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Value') return false + if (it.descriptor.fullname() != 'google.protobuf.Value') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -110,11 +114,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.ListValue') return false + if (it.descriptor.fullname() != 'google.protobuf.ListValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -124,11 +129,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('enum', it => { - if (it.descriptor.fullname() != 'google.protobuf.NullValue') return false + if (it.descriptor.fullname() != 'google.protobuf.NullValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -138,12 +144,13 @@ generate('enum', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.enumName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Timestamp') return false + if (it.descriptor.fullname() != 'google.protobuf.Timestamp') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -153,11 +160,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.DoubleValue') return false + if (it.descriptor.fullname() != 'google.protobuf.DoubleValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -167,11 +175,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.FloatValue') return false + if (it.descriptor.fullname() != 'google.protobuf.FloatValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -181,11 +190,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Int64Value') return false + if (it.descriptor.fullname() != 'google.protobuf.Int64Value') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -196,11 +206,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.UInt64Value') return false + if (it.descriptor.fullname() != 'google.protobuf.UInt64Value') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -211,11 +222,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.Int32Value') return false + if (it.descriptor.fullname() != 'google.protobuf.Int32Value') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -225,11 +237,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.UInt32Value') return false + if (it.descriptor.fullname() != 'google.protobuf.UInt32Value') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -239,11 +252,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.BoolValue') return false + if (it.descriptor.fullname() != 'google.protobuf.BoolValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -253,11 +267,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.StringValue') return false + if (it.descriptor.fullname() != 'google.protobuf.StringValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -267,11 +282,12 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) generate('message', it => { - if (it.descriptor.fullname() != 'google.protobuf.BytesValue') return false + if (it.descriptor.fullname() != 'google.protobuf.BytesValue') return + it.generatedElements++ const builder = it.target builder.normalize().lineComment(...it.descriptor.comments()) @@ -281,5 +297,5 @@ generate('message', it => { builder.normalize().beginBlock(`export namespace ${it.descriptor.interfaceName()}`) builder.normalize().appendLn(`export const name = '${it.descriptor.fullname()}'`) builder.endBlock() - return true + it.continue = false }) \ No newline at end of file diff --git a/packages/sisyphus-compiler/src/wellknown/proto.ts b/packages/sisyphus-compiler/src/wellknown/proto.ts index 3407156..6668985 100644 --- a/packages/sisyphus-compiler/src/wellknown/proto.ts +++ b/packages/sisyphus-compiler/src/wellknown/proto.ts @@ -41,190 +41,207 @@ generate>('file:header', it => { return [lib, name] } - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Any') return false + if (it.descriptor.fullname() != 'google.protobuf.Any') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'any', 'write') importFromWellknown(builder, 'any', 'read') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Duration') return false + if (it.descriptor.fullname() != 'google.protobuf.Duration') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'duration', 'write') importFromWellknown(builder, 'duration', 'read') importFromWellknown(builder, 'duration', 'box') importFromWellknown(builder, 'duration', 'unbox') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Empty') return false + if (it.descriptor.fullname() != 'google.protobuf.Empty') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'empty', 'write') importFromWellknown(builder, 'empty', 'read') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.FieldMask') return false + if (it.descriptor.fullname() != 'google.protobuf.FieldMask') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'field-mask', 'write') importFromWellknown(builder, 'field-mask', 'read') importFromWellknown(builder, 'field-mask', 'box') importFromWellknown(builder, 'field-mask', 'unbox') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Struct') return false + if (it.descriptor.fullname() != 'google.protobuf.Struct') return + it.generatedElements++ const builder = it.target.normalize() - importFromWellknown(builder, 'struct', 'write','writeStruct') + importFromWellknown(builder, 'struct', 'write', 'writeStruct') importFromWellknown(builder, 'struct', 'read', 'readStruct') - importFromWellknown(builder, 'struct', 'box','boxStruct') + importFromWellknown(builder, 'struct', 'box', 'boxStruct') importFromWellknown(builder, 'struct', 'unbox', 'unboxStruct') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Value') return false + if (it.descriptor.fullname() != 'google.protobuf.Value') return + it.generatedElements++ const builder = it.target.normalize() - importFromWellknown(builder, 'struct', 'write','writeValue') + importFromWellknown(builder, 'struct', 'write', 'writeValue') importFromWellknown(builder, 'struct', 'read', 'readValue') - importFromWellknown(builder, 'struct', 'box','boxValue') + importFromWellknown(builder, 'struct', 'box', 'boxValue') importFromWellknown(builder, 'struct', 'unbox', 'unboxValue') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.ListValue') return false + if (it.descriptor.fullname() != 'google.protobuf.ListValue') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'struct', 'write', 'writeListValue') importFromWellknown(builder, 'struct', 'read', 'readListValue') importFromWellknown(builder, 'struct', 'box', 'boxListValue') importFromWellknown(builder, 'struct', 'unbox', 'unboxListValue') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Timestamp') return false + if (it.descriptor.fullname() != 'google.protobuf.Timestamp') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'timestamp', 'write') importFromWellknown(builder, 'timestamp', 'read') importFromWellknown(builder, 'timestamp', 'box') importFromWellknown(builder, 'timestamp', 'unbox') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.DoubleValue') return false + if (it.descriptor.fullname() != 'google.protobuf.DoubleValue') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeDoubleValue') importFromWellknown(builder, 'wrappers', 'read', 'readDoubleValue') importFromWellknown(builder, 'wrappers', 'box', 'boxDoubleValue') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxDoubleValue') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.FloatValue') return false + if (it.descriptor.fullname() != 'google.protobuf.FloatValue') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeFloatValue') importFromWellknown(builder, 'wrappers', 'read', 'readFloatValue') importFromWellknown(builder, 'wrappers', 'box', 'boxFloatValue') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxFloatValue') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Int32Value') return false + if (it.descriptor.fullname() != 'google.protobuf.Int32Value') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeInt32Value') importFromWellknown(builder, 'wrappers', 'read', 'readInt32Value') importFromWellknown(builder, 'wrappers', 'box', 'boxInt32Value') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxInt32Value') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.UInt32Value') return false + if (it.descriptor.fullname() != 'google.protobuf.UInt32Value') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeUInt32Value') importFromWellknown(builder, 'wrappers', 'read', 'readUInt32Value') importFromWellknown(builder, 'wrappers', 'box', 'boxUInt32Value') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxUInt32Value') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.Int64Value') return false + if (it.descriptor.fullname() != 'google.protobuf.Int64Value') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeInt64Value') importFromWellknown(builder, 'wrappers', 'read', 'readInt64Value') importFromWellknown(builder, 'wrappers', 'box', 'boxInt64Value') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxInt64Value') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.UInt64Value') return false + if (it.descriptor.fullname() != 'google.protobuf.UInt64Value') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeUInt64Value') importFromWellknown(builder, 'wrappers', 'read', 'readUInt64Value') importFromWellknown(builder, 'wrappers', 'box', 'boxUInt64Value') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxUInt64Value') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.BoolValue') return false + if (it.descriptor.fullname() != 'google.protobuf.BoolValue') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeBoolValue') importFromWellknown(builder, 'wrappers', 'read', 'readBoolValue') importFromWellknown(builder, 'wrappers', 'box', 'boxBoolValue') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxBoolValue') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.StringValue') return false + if (it.descriptor.fullname() != 'google.protobuf.StringValue') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeStringValue') importFromWellknown(builder, 'wrappers', 'read', 'readStringValue') importFromWellknown(builder, 'wrappers', 'box', 'boxStringValue') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxStringValue') builder.ln() - return true + it.continue = false }) generate('message:proto:desc', it => { - if (it.descriptor.fullname() != 'google.protobuf.BytesValue') return false + if (it.descriptor.fullname() != 'google.protobuf.BytesValue') return + it.generatedElements++ const builder = it.target.normalize() importFromWellknown(builder, 'wrappers', 'write', 'writeBytesValue') importFromWellknown(builder, 'wrappers', 'read', 'readBytesValue') importFromWellknown(builder, 'wrappers', 'box', 'boxBytesValue') importFromWellknown(builder, 'wrappers', 'unbox', 'unboxBytesValue') builder.ln() - return true + it.continue = false }) function importFromWellknown(builder: CodeBuilder, module: string, name: string, impl?: string) { diff --git a/packages/sisyphus-google-aip/package.json b/packages/sisyphus-google-aip/package.json index 17a1bad..3632305 100644 --- a/packages/sisyphus-google-aip/package.json +++ b/packages/sisyphus-google-aip/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/google.aip", - "version": "2.0.8", + "version": "2.1.0", "description": "Precompiled google common aip clients by sisyphus protobuf compiler", "scripts": { "clean": "tsc --build --clean", @@ -33,12 +33,12 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "devDependencies": { - "@sisyphus.js/cli": "^2.0.8", - "@sisyphus.js/google.proto": "^2.0.8" + "@sisyphus.js/cli": "^2.1.0", + "@sisyphus.js/google.proto": "^2.1.0" }, "dependencies": { - "@sisyphus.js/google": "^2.0.8", - "@sisyphus.js/transport-aip": "^2.0.8" + "@sisyphus.js/google": "^2.1.0", + "@sisyphus.js/transport-aip": "^2.1.0" }, "directories": { "lib": "lib" diff --git a/packages/sisyphus-google-aip/src/google/longrunning/operations.aip.ts b/packages/sisyphus-google-aip/src/google/longrunning/operations.aip.ts index 6037c1c..2234821 100644 --- a/packages/sisyphus-google-aip/src/google/longrunning/operations.aip.ts +++ b/packages/sisyphus-google-aip/src/google/longrunning/operations.aip.ts @@ -1,5 +1,5 @@ import {Operations} from '@sisyphus.js/google/lib/google/longrunning/operations' -import {Rpc, ServiceDescriptor, aipClient} from '@sisyphus.js/transport-aip' +import {aipClient, Rpc, ServiceDescriptor} from '@sisyphus.js/transport-aip' declare module '@sisyphus.js/google/lib/google/longrunning/operations' { namespace Operations { @@ -19,40 +19,28 @@ Operations.aipDescriptor = { name: 'ListOperations', i: '.google.longrunning.ListOperationsRequest', o: '.google.longrunning.ListOperationsResponse', - options: { - http: {get: '/v1/{name=operations}'}, - methodSignature: ['name,filter'] - } + options: {} }, getOperation: { name: 'GetOperation', i: '.google.longrunning.GetOperationRequest', o: '.google.longrunning.Operation', - options: { - http: {get: '/v1/{name=operations/**}'}, - methodSignature: ['name'] - } + options: {} }, deleteOperation: { name: 'DeleteOperation', i: '.google.longrunning.DeleteOperationRequest', o: '.google.protobuf.Empty', - options: { - http: {delete: '/v1/{name=operations/**}'}, - methodSignature: ['name'] - } + options: {} }, cancelOperation: { name: 'CancelOperation', i: '.google.longrunning.CancelOperationRequest', o: '.google.protobuf.Empty', - options: { - http: {post: '/v1/{name=operations/**}:cancel', body: '*'}, - methodSignature: ['name'] - } + options: {} }, waitOperation: { diff --git a/packages/sisyphus-google-proto/package.json b/packages/sisyphus-google-proto/package.json index 9eb1ece..422de3d 100644 --- a/packages/sisyphus-google-proto/package.json +++ b/packages/sisyphus-google-proto/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/google.proto", - "version": "2.0.8", + "version": "2.1.0", "description": "Precompiled google common protos with full protobuf by sisyphus protobuf compiler", "main": "lib/index.js", "scripts": { @@ -34,12 +34,12 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "devDependencies": { - "@sisyphus.js/cli": "^2.0.8" + "@sisyphus.js/cli": "^2.1.0" }, "dependencies": { - "@sisyphus.js/google": "^2.0.8", - "@sisyphus.js/runtime": "^2.0.8", - "@sisyphus.js/runtime.proto": "^2.0.8" + "@sisyphus.js/google": "^2.1.0", + "@sisyphus.js/runtime": "^2.1.0", + "@sisyphus.js/runtime.proto": "^2.1.0" }, "directories": { "lib": "lib" diff --git a/packages/sisyphus-google-proto/src/google/api/annotations.proto.ts b/packages/sisyphus-google-proto/src/google/api/annotations.proto.ts index a25dd79..ce62def 100644 --- a/packages/sisyphus-google-proto/src/google/api/annotations.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/annotations.proto.ts @@ -1,6 +1,6 @@ -import {HttpRule} from './http.proto' import '@sisyphus.js/google/lib/google/api/annotations' import '@sisyphus.js/runtime.proto' +import {HttpRule} from './http.proto' declare module '@sisyphus.js/google/lib/google/api/annotations' { } diff --git a/packages/sisyphus-google-proto/src/google/api/auth.proto.ts b/packages/sisyphus-google-proto/src/google/api/auth.proto.ts index acf3be8..cef0b3d 100644 --- a/packages/sisyphus-google-proto/src/google/api/auth.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/auth.proto.ts @@ -1,4 +1,11 @@ -import {AuthProvider, AuthRequirement, Authentication, AuthenticationRule, JwtLocation, OAuthRequirements} from '@sisyphus.js/google/lib/google/api/auth' +import { + Authentication, + AuthenticationRule, + AuthProvider, + AuthRequirement, + JwtLocation, + OAuthRequirements +} from '@sisyphus.js/google/lib/google/api/auth' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' diff --git a/packages/sisyphus-google-proto/src/google/api/log.proto.ts b/packages/sisyphus-google-proto/src/google/api/log.proto.ts index 87608f7..655b7c8 100644 --- a/packages/sisyphus-google-proto/src/google/api/log.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/log.proto.ts @@ -1,7 +1,7 @@ -import {LabelDescriptor} from './label.proto' import {LogDescriptor} from '@sisyphus.js/google/lib/google/api/log' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' +import {LabelDescriptor} from './label.proto' declare module '@sisyphus.js/google/lib/google/api/log' { namespace LogDescriptor { diff --git a/packages/sisyphus-google-proto/src/google/api/metric.proto.ts b/packages/sisyphus-google-proto/src/google/api/metric.proto.ts index e86a1b6..c00dbf9 100644 --- a/packages/sisyphus-google-proto/src/google/api/metric.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/metric.proto.ts @@ -1,9 +1,9 @@ -import {LabelDescriptor} from './label.proto' -import {LaunchStage} from './launch_stage.proto' import {Metric, MetricDescriptor} from '@sisyphus.js/google/lib/google/api/metric' import {EnumDescriptor, MessageDescriptor} from '@sisyphus.js/runtime.proto' import {Duration} from '@sisyphus.js/runtime.proto/lib/google/protobuf/duration.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' +import {LabelDescriptor} from './label.proto' +import {LaunchStage} from './launch_stage.proto' declare module '@sisyphus.js/google/lib/google/api/metric' { namespace MetricDescriptor { @@ -12,6 +12,7 @@ declare module '@sisyphus.js/google/lib/google/api/metric' { function binaryify(v: MetricDescriptor): Uint8Array function parse(buffer: Uint8Array): MetricDescriptor + namespace MetricDescriptorMetadata { let descriptor: MessageDescriptor diff --git a/packages/sisyphus-google-proto/src/google/api/monitored_resource.proto.ts b/packages/sisyphus-google-proto/src/google/api/monitored_resource.proto.ts index 9e11fa3..cf1b922 100644 --- a/packages/sisyphus-google-proto/src/google/api/monitored_resource.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/monitored_resource.proto.ts @@ -1,9 +1,13 @@ -import {LabelDescriptor} from './label.proto' -import {LaunchStage} from './launch_stage.proto' -import {MonitoredResource, MonitoredResourceDescriptor, MonitoredResourceMetadata} from '@sisyphus.js/google/lib/google/api/monitored_resource' +import { + MonitoredResource, + MonitoredResourceDescriptor, + MonitoredResourceMetadata +} from '@sisyphus.js/google/lib/google/api/monitored_resource' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {Struct} from '@sisyphus.js/runtime.proto/lib/google/protobuf/struct.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' +import {LabelDescriptor} from './label.proto' +import {LaunchStage} from './launch_stage.proto' declare module '@sisyphus.js/google/lib/google/api/monitored_resource' { namespace MonitoredResourceDescriptor { diff --git a/packages/sisyphus-google-proto/src/google/api/service.proto.ts b/packages/sisyphus-google-proto/src/google/api/service.proto.ts index 2e1d137..60d9fd4 100644 --- a/packages/sisyphus-google-proto/src/google/api/service.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/service.proto.ts @@ -1,3 +1,9 @@ +import {Service} from '@sisyphus.js/google/lib/google/api/service' +import {MessageDescriptor} from '@sisyphus.js/runtime.proto' +import {Api} from '@sisyphus.js/runtime.proto/lib/google/protobuf/api.proto' +import {Enum, Type} from '@sisyphus.js/runtime.proto/lib/google/protobuf/type.proto' +import {UInt32Value} from '@sisyphus.js/runtime.proto/lib/google/protobuf/wrappers.proto' +import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' import {Authentication} from './auth.proto' import {Backend} from './backend.proto' import {Billing} from './billing.proto' @@ -15,12 +21,6 @@ import {Quota} from './quota.proto' import {SourceInfo} from './source_info.proto' import {SystemParameters} from './system_parameter.proto' import {Usage} from './usage.proto' -import {Service} from '@sisyphus.js/google/lib/google/api/service' -import {MessageDescriptor} from '@sisyphus.js/runtime.proto' -import {Api} from '@sisyphus.js/runtime.proto/lib/google/protobuf/api.proto' -import {Enum, Type} from '@sisyphus.js/runtime.proto/lib/google/protobuf/type.proto' -import {UInt32Value} from '@sisyphus.js/runtime.proto/lib/google/protobuf/wrappers.proto' -import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' declare module '@sisyphus.js/google/lib/google/api/service' { namespace Service { diff --git a/packages/sisyphus-google-proto/src/google/api/system_parameter.proto.ts b/packages/sisyphus-google-proto/src/google/api/system_parameter.proto.ts index 2ff104a..8afdc89 100644 --- a/packages/sisyphus-google-proto/src/google/api/system_parameter.proto.ts +++ b/packages/sisyphus-google-proto/src/google/api/system_parameter.proto.ts @@ -1,4 +1,8 @@ -import {SystemParameter, SystemParameterRule, SystemParameters} from '@sisyphus.js/google/lib/google/api/system_parameter' +import { + SystemParameter, + SystemParameterRule, + SystemParameters +} from '@sisyphus.js/google/lib/google/api/system_parameter' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' diff --git a/packages/sisyphus-google-proto/src/google/cloud/audit/audit_log.proto.ts b/packages/sisyphus-google-proto/src/google/cloud/audit/audit_log.proto.ts index 7596119..e0d7e77 100644 --- a/packages/sisyphus-google-proto/src/google/cloud/audit/audit_log.proto.ts +++ b/packages/sisyphus-google-proto/src/google/cloud/audit/audit_log.proto.ts @@ -1,10 +1,17 @@ -import {AttributeContext} from '../../rpc/context/attribute_context.proto' -import {Status} from '../../rpc/status.proto' -import {AuditLog, AuthenticationInfo, AuthorizationInfo, RequestMetadata, ResourceLocation, ServiceAccountDelegationInfo} from '@sisyphus.js/google/lib/google/cloud/audit/audit_log' +import { + AuditLog, + AuthenticationInfo, + AuthorizationInfo, + RequestMetadata, + ResourceLocation, + ServiceAccountDelegationInfo +} from '@sisyphus.js/google/lib/google/cloud/audit/audit_log' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {Any} from '@sisyphus.js/runtime.proto/lib/google/protobuf/any.proto' import {Struct} from '@sisyphus.js/runtime.proto/lib/google/protobuf/struct.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' +import {AttributeContext} from '../../rpc/context/attribute_context.proto' +import {Status} from '../../rpc/status.proto' declare module '@sisyphus.js/google/lib/google/cloud/audit/audit_log' { namespace AuditLog { diff --git a/packages/sisyphus-google-proto/src/google/geo/type/viewport.proto.ts b/packages/sisyphus-google-proto/src/google/geo/type/viewport.proto.ts index 92d405a..b305b0d 100644 --- a/packages/sisyphus-google-proto/src/google/geo/type/viewport.proto.ts +++ b/packages/sisyphus-google-proto/src/google/geo/type/viewport.proto.ts @@ -1,7 +1,7 @@ -import {LatLng} from '../../type/latlng.proto' import {Viewport} from '@sisyphus.js/google/lib/google/geo/type/viewport' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' +import {LatLng} from '../../type/latlng.proto' declare module '@sisyphus.js/google/lib/google/geo/type/viewport' { namespace Viewport { diff --git a/packages/sisyphus-google-proto/src/google/longrunning/operations.proto.ts b/packages/sisyphus-google-proto/src/google/longrunning/operations.proto.ts index babc744..a85f5a6 100644 --- a/packages/sisyphus-google-proto/src/google/longrunning/operations.proto.ts +++ b/packages/sisyphus-google-proto/src/google/longrunning/operations.proto.ts @@ -1,9 +1,18 @@ -import {Status} from '../rpc/status.proto' -import {CancelOperationRequest, DeleteOperationRequest, GetOperationRequest, ListOperationsRequest, ListOperationsResponse, Operation, OperationInfo, WaitOperationRequest} from '@sisyphus.js/google/lib/google/longrunning/operations' +import { + CancelOperationRequest, + DeleteOperationRequest, + GetOperationRequest, + ListOperationsRequest, + ListOperationsResponse, + Operation, + OperationInfo, + WaitOperationRequest +} from '@sisyphus.js/google/lib/google/longrunning/operations' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {Any} from '@sisyphus.js/runtime.proto/lib/google/protobuf/any.proto' import {Duration} from '@sisyphus.js/runtime.proto/lib/google/protobuf/duration.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' +import {Status} from '../rpc/status.proto' declare module '@sisyphus.js/google/lib/google/longrunning/operations' { namespace Operation { diff --git a/packages/sisyphus-google-proto/src/google/rpc/error_details.proto.ts b/packages/sisyphus-google-proto/src/google/rpc/error_details.proto.ts index a221cae..529ec40 100644 --- a/packages/sisyphus-google-proto/src/google/rpc/error_details.proto.ts +++ b/packages/sisyphus-google-proto/src/google/rpc/error_details.proto.ts @@ -1,4 +1,15 @@ -import {BadRequest, DebugInfo, ErrorInfo, Help, LocalizedMessage, PreconditionFailure, QuotaFailure, RequestInfo, ResourceInfo, RetryInfo} from '@sisyphus.js/google/lib/google/rpc/error_details' +import { + BadRequest, + DebugInfo, + ErrorInfo, + Help, + LocalizedMessage, + PreconditionFailure, + QuotaFailure, + RequestInfo, + ResourceInfo, + RetryInfo +} from '@sisyphus.js/google/lib/google/rpc/error_details' import {MessageDescriptor} from '@sisyphus.js/runtime.proto' import {Duration} from '@sisyphus.js/runtime.proto/lib/google/protobuf/duration.proto' import {binaryifyFun, parseFun} from '@sisyphus.js/runtime.proto/lib/message' diff --git a/packages/sisyphus-google/package.json b/packages/sisyphus-google/package.json index 61f85aa..2956a95 100644 --- a/packages/sisyphus-google/package.json +++ b/packages/sisyphus-google/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/google", - "version": "2.0.8", + "version": "2.1.0", "description": "Precompiled google common protos by sisyphus protobuf compiler", "scripts": { "clean": "tsc --build --clean", @@ -34,10 +34,10 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "devDependencies": { - "@sisyphus.js/cli": "^2.0.8" + "@sisyphus.js/cli": "^2.1.0" }, "dependencies": { - "@sisyphus.js/runtime": "^2.0.8" + "@sisyphus.js/runtime": "^2.1.0" }, "directories": { "lib": "lib", diff --git a/packages/sisyphus-google/src/google/api/annotations.ts b/packages/sisyphus-google/src/google/api/annotations.ts index adc02e2..b68675c 100644 --- a/packages/sisyphus-google/src/google/api/annotations.ts +++ b/packages/sisyphus-google/src/google/api/annotations.ts @@ -1,5 +1,5 @@ -import {HttpRule} from './http' import '@sisyphus.js/runtime/lib/google/protobuf/descriptor' +import {HttpRule} from './http' declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { interface MethodOptions { diff --git a/packages/sisyphus-google/src/google/api/backend.ts b/packages/sisyphus-google/src/google/api/backend.ts index 357beb0..1c01990 100644 --- a/packages/sisyphus-google/src/google/api/backend.ts +++ b/packages/sisyphus-google/src/google/api/backend.ts @@ -63,7 +63,7 @@ export interface BackendRule { */ operationDeadline?: number - pathTranslation?: BackendRule.PathTranslation + pathTranslation?: BackendRule.PathTranslation | (keyof typeof BackendRule.PathTranslation) /** * The JWT audience is used when generating a JWT ID token for the backend. @@ -119,7 +119,7 @@ export namespace BackendRule { * unspecified. */ export enum PathTranslation { - UNSPECIFIED = 'PATH_TRANSLATION_UNSPECIFIED', + PATH_TRANSLATION_UNSPECIFIED = 0, /** * Use the backend address as-is, with no modification to the path. If the @@ -127,7 +127,7 @@ export namespace BackendRule { * appended to the query string. If a query string parameter and a URL * pattern variable have the same name, this may result in duplicate keys in * the query string. - * + * * # Examples * * Given the following operation config: @@ -137,39 +137,39 @@ export namespace BackendRule { * * Requests to the following request paths will call the backend at the * translated path: - * + * * Request path: /api/company/widgetworks/user/johndoe * Translated: * https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe - * + * * Request path: /api/company/widgetworks/user/johndoe?timezone=EST * Translated: * https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe */ - CONSTANT_ADDRESS = 'CONSTANT_ADDRESS', + CONSTANT_ADDRESS = 1, /** * The request path will be appended to the backend address. - * + * * # Examples - * + * * Given the following operation config: - * + * * Method path: /api/company/{cid}/user/{uid} * Backend address: https://example.appspot.com * * Requests to the following request paths will call the backend at the * translated path: - * + * * Request path: /api/company/widgetworks/user/johndoe * Translated: * https://example.appspot.com/api/company/widgetworks/user/johndoe - * + * * Request path: /api/company/widgetworks/user/johndoe?timezone=EST * Translated: * https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST */ - APPEND_PATH_TO_ADDRESS = 'APPEND_PATH_TO_ADDRESS', + APPEND_PATH_TO_ADDRESS = 2, } export namespace PathTranslation { diff --git a/packages/sisyphus-google/src/google/api/config_change.ts b/packages/sisyphus-google/src/google/api/config_change.ts index 00c54fb..c2e7aaa 100644 --- a/packages/sisyphus-google/src/google/api/config_change.ts +++ b/packages/sisyphus-google/src/google/api/config_change.ts @@ -33,7 +33,7 @@ export interface ConfigChange { newValue?: string /** The type for this change, either ADDED, REMOVED, or MODIFIED. */ - changeType?: ChangeType + changeType?: ChangeType | (keyof typeof ChangeType) /** * Collection of advice provided for this change, useful for determining the @@ -68,25 +68,25 @@ export namespace Advice { */ export enum ChangeType { /** No value was provided. */ - UNSPECIFIED = 'CHANGE_TYPE_UNSPECIFIED', + CHANGE_TYPE_UNSPECIFIED = 0, /** * The changed object exists in the 'new' service configuration, but not * in the 'old' service configuration. */ - ADDED = 'ADDED', + ADDED = 1, /** * The changed object exists in the 'old' service configuration, but not * in the 'new' service configuration. */ - REMOVED = 'REMOVED', + REMOVED = 2, /** * The changed object exists in both service configurations, but its value * is different. */ - MODIFIED = 'MODIFIED', + MODIFIED = 3, } export namespace ChangeType { diff --git a/packages/sisyphus-google/src/google/api/consumer.ts b/packages/sisyphus-google/src/google/api/consumer.ts index 101bcce..dd5425a 100644 --- a/packages/sisyphus-google/src/google/api/consumer.ts +++ b/packages/sisyphus-google/src/google/api/consumer.ts @@ -42,7 +42,7 @@ export interface Property { name?: string /** The type of this property. */ - type?: Property.PropertyType + type?: Property.PropertyType | (keyof typeof Property.PropertyType) /** The description of the property */ description?: string @@ -54,19 +54,19 @@ export namespace Property { /** Supported data type of the property values */ export enum PropertyType { /** The type is unspecified, and will result in an error. */ - UNSPECIFIED = 'UNSPECIFIED', + UNSPECIFIED = 0, /** The type is `int64`. */ - INT64 = 'INT64', + INT64 = 1, /** The type is `bool`. */ - BOOL = 'BOOL', + BOOL = 2, /** The type is `string`. */ - STRING = 'STRING', + STRING = 3, /** The type is 'double'. */ - DOUBLE = 'DOUBLE', + DOUBLE = 4, } export namespace PropertyType { diff --git a/packages/sisyphus-google/src/google/api/error_reason.ts b/packages/sisyphus-google/src/google/api/error_reason.ts index b0b812e..6cff6d7 100644 --- a/packages/sisyphus-google/src/google/api/error_reason.ts +++ b/packages/sisyphus-google/src/google/api/error_reason.ts @@ -12,14 +12,14 @@ */ export enum ErrorReason { /** Do not use this default value. */ - UNSPECIFIED = 'ERROR_REASON_UNSPECIFIED', + ERROR_REASON_UNSPECIFIED = 0, /** * The request is calling a disabled service for a consumer. - * + * * Example of an ErrorInfo when the consumer "projects/123" contacting * "pubsub.googleapis.com" service which is disabled: - * + * * { "reason": "SERVICE_DISABLED", * "domain": "googleapis.com", * "metadata": { @@ -27,19 +27,19 @@ export enum ErrorReason { * "service": "pubsub.googleapis.com" * } * } - * + * * This response indicates the "pubsub.googleapis.com" has been disabled in * "projects/123". */ - SERVICE_DISABLED = 'SERVICE_DISABLED', + SERVICE_DISABLED = 1, /** * The request whose associated billing account is disabled. - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to contact * "pubsub.googleapis.com" service because the associated billing account is * disabled: - * + * * { "reason": "BILLING_DISABLED", * "domain": "googleapis.com", * "metadata": { @@ -47,19 +47,19 @@ export enum ErrorReason { * "service": "pubsub.googleapis.com" * } * } - * + * * This response indicates the billing account associated has been disabled. */ - BILLING_DISABLED = 'BILLING_DISABLED', + BILLING_DISABLED = 2, /** * The request is denied because the provided [API * key](https://cloud.google.com/docs/authentication/api-keys) is invalid. It * may be in a bad format, cannot be found, or has been expired). - * + * * Example of an ErrorInfo when the request is contacting * "storage.googleapis.com" service with an invalid API key: - * + * * { "reason": "API_KEY_INVALID", * "domain": "googleapis.com", * "metadata": { @@ -67,16 +67,16 @@ export enum ErrorReason { * } * } */ - API_KEY_INVALID = 'API_KEY_INVALID', + API_KEY_INVALID = 3, /** * The request is denied because it violates [API key API * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_api_restrictions). - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to call the * "storage.googleapis.com" service because this service is restricted in the * API key: - * + * * { "reason": "API_KEY_SERVICE_BLOCKED", * "domain": "googleapis.com", * "metadata": { @@ -85,16 +85,16 @@ export enum ErrorReason { * } * } */ - API_KEY_SERVICE_BLOCKED = 'API_KEY_SERVICE_BLOCKED', + API_KEY_SERVICE_BLOCKED = 4, /** * The request is denied because it violates [API key HTTP * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_http_restrictions). - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to call * "storage.googleapis.com" service because the http referrer of the request * violates API key HTTP restrictions: - * + * * { "reason": "API_KEY_HTTP_REFERRER_BLOCKED", * "domain": "googleapis.com", * "metadata": { @@ -103,16 +103,16 @@ export enum ErrorReason { * } * } */ - API_KEY_HTTP_REFERRER_BLOCKED = 'API_KEY_HTTP_REFERRER_BLOCKED', + API_KEY_HTTP_REFERRER_BLOCKED = 7, /** * The request is denied because it violates [API key IP address * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions). - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to call * "storage.googleapis.com" service because the caller IP of the request * violates API key IP address restrictions: - * + * * { "reason": "API_KEY_IP_ADDRESS_BLOCKED", * "domain": "googleapis.com", * "metadata": { @@ -121,16 +121,16 @@ export enum ErrorReason { * } * } */ - API_KEY_IP_ADDRESS_BLOCKED = 'API_KEY_IP_ADDRESS_BLOCKED', + API_KEY_IP_ADDRESS_BLOCKED = 8, /** * The request is denied because it violates [API key Android application * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions). - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to call * "storage.googleapis.com" service because the request from the Android apps * violates the API key Android application restrictions: - * + * * { "reason": "API_KEY_ANDROID_APP_BLOCKED", * "domain": "googleapis.com", * "metadata": { @@ -139,16 +139,16 @@ export enum ErrorReason { * } * } */ - API_KEY_ANDROID_APP_BLOCKED = 'API_KEY_ANDROID_APP_BLOCKED', + API_KEY_ANDROID_APP_BLOCKED = 9, /** * The request is denied because it violates [API key iOS application * restrictions](https://cloud.google.com/docs/authentication/api-keys#adding_application_restrictions). - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to call * "storage.googleapis.com" service because the request from the iOS apps * violates the API key iOS application restrictions: - * + * * { "reason": "API_KEY_IOS_APP_BLOCKED", * "domain": "googleapis.com", * "metadata": { @@ -157,12 +157,12 @@ export enum ErrorReason { * } * } */ - API_KEY_IOS_APP_BLOCKED = 'API_KEY_IOS_APP_BLOCKED', + API_KEY_IOS_APP_BLOCKED = 13, /** * The request is denied because there is not enough rate quota for the * consumer. - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to contact * "pubsub.googleapis.com" service because consumer's rate quota usage has * reached the maximum value set for the quota limit @@ -183,7 +183,7 @@ export enum ErrorReason { * the service "dataflow.googleapis.com" and hits the organization quota * limit "DefaultRequestsPerMinutePerOrganization" on the metric * "dataflow.googleapis.com/default_requests". - * + * * { "reason": "RATE_LIMIT_EXCEEDED", * "domain": "googleapis.com", * "metadata": { @@ -194,12 +194,12 @@ export enum ErrorReason { * } * } */ - RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED', + RATE_LIMIT_EXCEEDED = 5, /** * The request is denied because there is not enough resource quota for the * consumer. - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to contact * "compute.googleapis.com" service because consumer's resource quota usage * has reached the maximum value set for the quota limit "VMsPerProject" @@ -219,7 +219,7 @@ export enum ErrorReason { * quota on the service "dataflow.googleapis.com" and hits the organization * quota limit "jobs-per-organization" on the metric * "dataflow.googleapis.com/job_count". - * + * * { "reason": "RESOURCE_QUOTA_EXCEEDED", * "domain": "googleapis.com", * "metadata": { @@ -230,13 +230,13 @@ export enum ErrorReason { * } * } */ - RESOURCE_QUOTA_EXCEEDED = 'RESOURCE_QUOTA_EXCEEDED', + RESOURCE_QUOTA_EXCEEDED = 6, /** * The request whose associated billing account address is in a tax restricted * location, violates the local tax restrictions when creating resources in * the restricted region. - * + * * Example of an ErrorInfo when creating the Cloud Storage Bucket in the * container "projects/123" under a tax restricted region * "locations/asia-northeast3": @@ -249,21 +249,21 @@ export enum ErrorReason { * "location": "locations/asia-northeast3" * } * } - * + * * This response indicates creating the Cloud Storage Bucket in * "locations/asia-northeast3" violates the location tax restriction. */ - LOCATION_TAX_POLICY_VIOLATED = 'LOCATION_TAX_POLICY_VIOLATED', + LOCATION_TAX_POLICY_VIOLATED = 10, /** * The request is denied because the caller does not have required permission * on the user project "projects/123" or the user project is invalid. For more * information, check the [userProject System * Parameters](https://cloud.google.com/apis/docs/system-parameters). - * + * * Example of an ErrorInfo when the caller is calling Cloud Storage service * with insufficient permissions on the user project: - * + * * { "reason": "USER_PROJECT_DENIED", * "domain": "googleapis.com", * "metadata": { @@ -272,17 +272,17 @@ export enum ErrorReason { * } * } */ - USER_PROJECT_DENIED = 'USER_PROJECT_DENIED', + USER_PROJECT_DENIED = 11, /** * The request is denied because the consumer "projects/123" is suspended due * to Terms of Service(Tos) violations. Check [Project suspension * guidelines](https://cloud.google.com/resource-manager/docs/project-suspension-guidelines) * for more information. - * + * * Example of an ErrorInfo when calling Cloud Storage service with the * suspended consumer "projects/123": - * + * * { "reason": "CONSUMER_SUSPENDED", * "domain": "googleapis.com", * "metadata": { @@ -291,15 +291,15 @@ export enum ErrorReason { * } * } */ - CONSUMER_SUSPENDED = 'CONSUMER_SUSPENDED', + CONSUMER_SUSPENDED = 12, /** * The request is denied because the associated consumer is invalid. It may be * in a bad format, cannot be found, or have been deleted. - * + * * Example of an ErrorInfo when calling Cloud Storage service with the * invalid consumer "projects/123": - * + * * { "reason": "CONSUMER_INVALID", * "domain": "googleapis.com", * "metadata": { @@ -308,7 +308,7 @@ export enum ErrorReason { * } * } */ - CONSUMER_INVALID = 'CONSUMER_INVALID', + CONSUMER_INVALID = 14, /** * The request is denied because it violates [VPC Service @@ -317,11 +317,11 @@ export enum ErrorReason { * to search the audit log for a request rejected by VPC Service Controls. For * more information, please refer [VPC Service Controls * Troubleshooting](https://cloud.google.com/vpc-service-controls/docs/troubleshooting#unique-id) - * + * * Example of an ErrorInfo when the consumer "projects/123" fails to call * Cloud Storage service because the request is prohibited by the VPC Service * Controls. - * + * * { "reason": "SECURITY_POLICY_VIOLATED", * "domain": "googleapis.com", * "metadata": { @@ -331,14 +331,14 @@ export enum ErrorReason { * } * } */ - SECURITY_POLICY_VIOLATED = 'SECURITY_POLICY_VIOLATED', + SECURITY_POLICY_VIOLATED = 15, /** * The request is denied because the provided access token has expired. - * + * * Example of an ErrorInfo when the request is calling Cloud Storage service * with an expired access token: - * + * * { "reason": "ACCESS_TOKEN_EXPIRED", * "domain": "googleapis.com", * "metadata": { @@ -347,7 +347,7 @@ export enum ErrorReason { * } * } */ - ACCESS_TOKEN_EXPIRED = 'ACCESS_TOKEN_EXPIRED', + ACCESS_TOKEN_EXPIRED = 16, /** * The request is denied because the provided access token doesn't have at @@ -356,10 +356,10 @@ export enum ErrorReason { * APIs](https://developers.google.com/identity/protocols/oauth2/scopes) for * the list of the OAuth 2.0 scopes that you might need to request to access * the API. - * + * * Example of an ErrorInfo when the request is calling Cloud Storage service * with an access token that is missing required scopes: - * + * * { "reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT", * "domain": "googleapis.com", * "metadata": { @@ -368,13 +368,13 @@ export enum ErrorReason { * } * } */ - ACCESS_TOKEN_SCOPE_INSUFFICIENT = 'ACCESS_TOKEN_SCOPE_INSUFFICIENT', + ACCESS_TOKEN_SCOPE_INSUFFICIENT = 17, /** * The request is denied because the account associated with the provided * access token is in an invalid state, such as disabled or deleted. * For more information, see https://cloud.google.com/docs/authentication. - * + * * Warning: For privacy reasons, the server may not be able to disclose the * email address for some accounts. The client MUST NOT depend on the * availability of the `email` attribute. @@ -382,7 +382,7 @@ export enum ErrorReason { * Example of an ErrorInfo when the request is to the Cloud Storage API with * an access token that is associated with a disabled or deleted [service * account](http://cloud/iam/docs/service-accounts): - * + * * { "reason": "ACCOUNT_STATE_INVALID", * "domain": "googleapis.com", * "metadata": { @@ -392,15 +392,15 @@ export enum ErrorReason { * } * } */ - ACCOUNT_STATE_INVALID = 'ACCOUNT_STATE_INVALID', + ACCOUNT_STATE_INVALID = 18, /** * The request is denied because the type of the provided access token is not * supported by the API being called. - * + * * Example of an ErrorInfo when the request is to the Cloud Storage API with * an unsupported token type. - * + * * { "reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED", * "domain": "googleapis.com", * "metadata": { @@ -409,7 +409,7 @@ export enum ErrorReason { * } * } */ - ACCESS_TOKEN_TYPE_UNSUPPORTED = 'ACCESS_TOKEN_TYPE_UNSUPPORTED', + ACCESS_TOKEN_TYPE_UNSUPPORTED = 19, } export namespace ErrorReason { diff --git a/packages/sisyphus-google/src/google/api/field_behavior.ts b/packages/sisyphus-google/src/google/api/field_behavior.ts index d76a7ff..9f744f0 100644 --- a/packages/sisyphus-google/src/google/api/field_behavior.ts +++ b/packages/sisyphus-google/src/google/api/field_behavior.ts @@ -10,21 +10,21 @@ import '@sisyphus.js/runtime/lib/google/protobuf/descriptor' */ export enum FieldBehavior { /** Conventional default for enums. Do not use this. */ - UNSPECIFIED = 'FIELD_BEHAVIOR_UNSPECIFIED', + FIELD_BEHAVIOR_UNSPECIFIED = 0, /** * Specifically denotes a field as optional. * While all fields in protocol buffers are optional, this may be specified * for emphasis if appropriate. */ - OPTIONAL = 'OPTIONAL', + OPTIONAL = 1, /** * Denotes a field as required. * This indicates that the field **must** be provided as part of the request, * and failure to do so will cause an error (usually `INVALID_ARGUMENT`). */ - REQUIRED = 'REQUIRED', + REQUIRED = 2, /** * Denotes a field as output only. @@ -32,21 +32,21 @@ export enum FieldBehavior { * field in a request does nothing (the server *must* ignore it and * *must not* throw an error as a result of the field's presence). */ - OUTPUT_ONLY = 'OUTPUT_ONLY', + OUTPUT_ONLY = 3, /** * Denotes a field as input only. * This indicates that the field is provided in requests, and the * corresponding field is not included in output. */ - INPUT_ONLY = 'INPUT_ONLY', + INPUT_ONLY = 4, /** * Denotes a field as immutable. * This indicates that the field may be set once in a request to create a * resource, but may not be changed thereafter. */ - IMMUTABLE = 'IMMUTABLE', + IMMUTABLE = 5, /** * Denotes that a (repeated) field is an unordered list. @@ -54,7 +54,7 @@ export enum FieldBehavior { * in any arbitrary order, rather than the order the user originally * provided. Additionally, the list's order may or may not be stable. */ - UNORDERED_LIST = 'UNORDERED_LIST', + UNORDERED_LIST = 6, /** * Denotes that this field returns a non-empty default value if not set. @@ -62,7 +62,7 @@ export enum FieldBehavior { * a non-empty value will be returned. The user will not be aware of what * non-empty value to expect. */ - NON_EMPTY_DEFAULT = 'NON_EMPTY_DEFAULT', + NON_EMPTY_DEFAULT = 7, } export namespace FieldBehavior { @@ -74,9 +74,9 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { /** * A designation of a specific field behavior (required, output only, etc.) * in protobuf messages. - * + * * Examples: - * + * * string name = 1 [(google.api.field_behavior) = REQUIRED]; * State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; * google.protobuf.Duration ttl = 1 @@ -85,6 +85,6 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { * [(google.api.field_behavior) = OUTPUT_ONLY, * (google.api.field_behavior) = IMMUTABLE]; */ - fieldBehavior: FieldBehavior[] + fieldBehavior: FieldBehavior | (keyof typeof FieldBehavior)[] } } diff --git a/packages/sisyphus-google/src/google/api/label.ts b/packages/sisyphus-google/src/google/api/label.ts index eb06c71..2468180 100644 --- a/packages/sisyphus-google/src/google/api/label.ts +++ b/packages/sisyphus-google/src/google/api/label.ts @@ -4,7 +4,7 @@ export interface LabelDescriptor { key?: string /** The type of data that can be assigned to the label. */ - valueType?: LabelDescriptor.ValueType + valueType?: LabelDescriptor.ValueType | (keyof typeof LabelDescriptor.ValueType) /** A human-readable description for the label. */ description?: string @@ -16,13 +16,13 @@ export namespace LabelDescriptor { /** Value types that can be used as label values. */ export enum ValueType { /** A variable-length string. This is the default. */ - STRING = 'STRING', + STRING = 0, /** Boolean; true or false. */ - BOOL = 'BOOL', + BOOL = 1, /** A 64-bit signed integer. */ - INT64 = 'INT64', + INT64 = 2, } export namespace ValueType { diff --git a/packages/sisyphus-google/src/google/api/launch_stage.ts b/packages/sisyphus-google/src/google/api/launch_stage.ts index 03267a9..770d83e 100644 --- a/packages/sisyphus-google/src/google/api/launch_stage.ts +++ b/packages/sisyphus-google/src/google/api/launch_stage.ts @@ -4,13 +4,13 @@ */ export enum LaunchStage { /** Do not use this default value. */ - UNSPECIFIED = 'LAUNCH_STAGE_UNSPECIFIED', + LAUNCH_STAGE_UNSPECIFIED = 0, /** The feature is not yet implemented. Users can not use it. */ - UNIMPLEMENTED = 'UNIMPLEMENTED', + UNIMPLEMENTED = 6, /** Prelaunch features are hidden from users and are only visible internally. */ - PRELAUNCH = 'PRELAUNCH', + PRELAUNCH = 7, /** * Early Access features are limited to a closed group of testers. To use @@ -19,7 +19,7 @@ export enum LaunchStage { * be unstable, changed in backward-incompatible ways, and are not * guaranteed to be released. */ - EARLY_ACCESS = 'EARLY_ACCESS', + EARLY_ACCESS = 1, /** * Alpha is a limited availability test for releases before they are cleared @@ -32,7 +32,7 @@ export enum LaunchStage { * test environments or for limited-use tests -- just like they would in * normal production cases. */ - ALPHA = 'ALPHA', + ALPHA = 2, /** * Beta is the point at which we are ready to open a release for any @@ -41,13 +41,13 @@ export enum LaunchStage { * may have some open outstanding issues. Beta releases are suitable for * limited production use cases. */ - BETA = 'BETA', + BETA = 3, /** * GA features are open to all developers and are considered stable and * fully qualified for production use. */ - GA = 'GA', + GA = 4, /** * Deprecated features are scheduled to be shut down and removed. For more @@ -56,7 +56,7 @@ export enum LaunchStage { * and the [Google Cloud Platform Subject to the Deprecation * Policy](https://cloud.google.com/terms/deprecation) documentation. */ - DEPRECATED = 'DEPRECATED', + DEPRECATED = 5, } export namespace LaunchStage { diff --git a/packages/sisyphus-google/src/google/api/metric.ts b/packages/sisyphus-google/src/google/api/metric.ts index 018ea7f..ff0ea83 100644 --- a/packages/sisyphus-google/src/google/api/metric.ts +++ b/packages/sisyphus-google/src/google/api/metric.ts @@ -1,6 +1,6 @@ +import {Duration} from '@sisyphus.js/runtime/lib/google/protobuf/duration' import {LabelDescriptor} from './label' import {LaunchStage} from './launch_stage' -import {Duration} from '@sisyphus.js/runtime/lib/google/protobuf/duration' /** * Defines a metric type and its schema. Once a metric descriptor is created, @@ -16,7 +16,7 @@ export interface MetricDescriptor { * URL-encoded. All user-defined metric types have the DNS name * `custom.googleapis.com` or `external.googleapis.com`. Metric types should * use a natural hierarchical grouping. For example: - * + * * "custom.googleapis.com/invoice/paid/amount" * "external.googleapis.com/prometheus/up" * "appengine.googleapis.com/http/server/response_latencies" @@ -37,40 +37,40 @@ export interface MetricDescriptor { * Whether the metric records instantaneous values, changes to a value, etc. * Some combinations of `metric_kind` and `value_type` might not be supported. */ - metricKind?: MetricDescriptor.MetricKind + metricKind?: MetricDescriptor.MetricKind | (keyof typeof MetricDescriptor.MetricKind) /** * Whether the measurement is an integer, a floating-point number, etc. * Some combinations of `metric_kind` and `value_type` might not be supported. */ - valueType?: MetricDescriptor.ValueType + valueType?: MetricDescriptor.ValueType | (keyof typeof MetricDescriptor.ValueType) /** * The units in which the metric value is reported. It is only applicable * if the `value_type` is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The `unit` * defines the representation of the stored metric values. - * + * * Different systems might scale the values to be more easily displayed (so a * value of `0.02kBy` _might_ be displayed as `20By`, and a value of * `3523kBy` _might_ be displayed as `3.5MBy`). However, if the `unit` is * `kBy`, then the value of the metric is always in thousands of bytes, no * matter how it might be displayed. - * + * * If you want a custom metric to record the exact number of CPU-seconds used * by a job, you can create an `INT64 CUMULATIVE` metric whose `unit` is * `s{CPU}` (or equivalently `1s{CPU}` or just `s`). If the job uses 12,005 * CPU-seconds, then the value is written as `12005`. - * + * * Alternatively, if you want a custom metric to record data in a more * granular way, you can create a `DOUBLE CUMULATIVE` metric whose `unit` is * `ks{CPU}`, and then write the value `12.005` (which is `12005/1000`), * or use `Kis{CPU}` and write `11.723` (which is `12005/1024`). - * + * * The supported units are a subset of [The Unified Code for Units of * Measure](https://unitsofmeasure.org/ucum.html) standard: - * + * * **Basic units (UNIT)** - * + * * * `bit` bit * * `By` byte * * `s` second @@ -78,9 +78,9 @@ export interface MetricDescriptor { * * `h` hour * * `d` day * * `1` dimensionless - * + * * **Prefixes (PREFIX)** - * + * * * `k` kilo (10^3) * * `M` mega (10^6) * * `G` giga (10^9) @@ -89,7 +89,7 @@ export interface MetricDescriptor { * * `E` exa (10^18) * * `Z` zetta (10^21) * * `Y` yotta (10^24) - * + * * * `m` milli (10^-3) * * `u` micro (10^-6) * * `n` nano (10^-9) @@ -98,37 +98,37 @@ export interface MetricDescriptor { * * `a` atto (10^-18) * * `z` zepto (10^-21) * * `y` yocto (10^-24) - * + * * * `Ki` kibi (2^10) * * `Mi` mebi (2^20) * * `Gi` gibi (2^30) * * `Ti` tebi (2^40) * * `Pi` pebi (2^50) - * + * * **Grammar** - * + * * The grammar also includes these connectors: - * + * * * `/` division or ratio (as an infix operator). For examples, * `kBy/{email}` or `MiBy/10ms` (although you should almost never * have `/s` in a metric `unit`; rates should always be computed at * query time from the underlying cumulative or delta value). * * `.` multiplication or composition (as an infix operator). For * examples, `GBy.d` or `k{watt}.h`. - * + * * The grammar for a unit is as follows: - * + * * Expression = Component { "." Component } { "/" Component } ; - * + * * Component = ( [ PREFIX ] UNIT | "%" ) [ Annotation ] * | Annotation * | "1" * ; - * + * * Annotation = "{" NAME "}" ; - * + * * Notes: - * + * * * `Annotation` is just a comment if it follows a `UNIT`. If the annotation * is used alone, then the unit is equivalent to `1`. For examples, * `{request}/s == 1/s`, `By{transmitted}/s == By/s`. @@ -166,7 +166,7 @@ export interface MetricDescriptor { metadata?: MetricDescriptor.MetricDescriptorMetadata /** Optional. The launch stage of the metric definition. */ - launchStage?: LaunchStage + launchStage?: LaunchStage | (keyof typeof LaunchStage) /** * Read-only. If present, then a [time @@ -184,7 +184,7 @@ export namespace MetricDescriptor { /** Additional annotations that can be used to guide the usage of a metric. */ export interface MetricDescriptorMetadata { /** Deprecated. Must use the [MetricDescriptor.launch_stage][google.api.MetricDescriptor.launch_stage] instead. */ - launchStage?: LaunchStage + launchStage?: LaunchStage | (keyof typeof LaunchStage) /** * The sampling period of metric data points. For metrics which are written @@ -213,13 +213,13 @@ export namespace MetricDescriptor { */ export enum MetricKind { /** Do not use this default value. */ - UNSPECIFIED = 'METRIC_KIND_UNSPECIFIED', + METRIC_KIND_UNSPECIFIED = 0, /** An instantaneous measurement of a value. */ - GAUGE = 'GAUGE', + GAUGE = 1, /** The change in a value during a time interval. */ - DELTA = 'DELTA', + DELTA = 2, /** * A value accumulated over a time interval. Cumulative @@ -228,7 +228,7 @@ export namespace MetricDescriptor { * value to zero and sets a new start time for the following * points. */ - CUMULATIVE = 'CUMULATIVE', + CUMULATIVE = 3, } export namespace MetricKind { @@ -238,31 +238,31 @@ export namespace MetricDescriptor { /** The value type of a metric. */ export enum ValueType { /** Do not use this default value. */ - UNSPECIFIED = 'VALUE_TYPE_UNSPECIFIED', + VALUE_TYPE_UNSPECIFIED = 0, /** * The value is a boolean. * This value type can be used only if the metric kind is `GAUGE`. */ - BOOL = 'BOOL', + BOOL = 1, /** The value is a signed 64-bit integer. */ - INT64 = 'INT64', + INT64 = 2, /** The value is a double precision floating point number. */ - DOUBLE = 'DOUBLE', + DOUBLE = 3, /** * The value is a text string. * This value type can be used only if the metric kind is `GAUGE`. */ - STRING = 'STRING', + STRING = 4, /** The value is a [`Distribution`][google.api.Distribution]. */ - DISTRIBUTION = 'DISTRIBUTION', + DISTRIBUTION = 5, /** The value is money. */ - MONEY = 'MONEY', + MONEY = 6, } export namespace ValueType { diff --git a/packages/sisyphus-google/src/google/api/monitored_resource.ts b/packages/sisyphus-google/src/google/api/monitored_resource.ts index f4b398b..3e561a1 100644 --- a/packages/sisyphus-google/src/google/api/monitored_resource.ts +++ b/packages/sisyphus-google/src/google/api/monitored_resource.ts @@ -1,6 +1,6 @@ +import {Struct} from '@sisyphus.js/runtime/lib/google/protobuf/struct' import {LabelDescriptor} from './label' import {LaunchStage} from './launch_stage' -import {Struct} from '@sisyphus.js/runtime/lib/google/protobuf/struct' /** * An object that describes the schema of a [MonitoredResource][google.api.MonitoredResource] object using a @@ -8,7 +8,7 @@ import {Struct} from '@sisyphus.js/runtime/lib/google/protobuf/struct' * descriptor for Google Compute Engine VM instances has a type of * `"gce_instance"` and specifies the use of the labels `"instance_id"` and * `"zone"` to identify particular VM instances. - * + * * Different APIs can support different monitored resource types. APIs generally * provide a `list` method that returns the monitored resource descriptors used * by the API. @@ -52,7 +52,7 @@ export interface MonitoredResourceDescriptor { labels?: LabelDescriptor[] /** Optional. The launch stage of the monitored resource definition. */ - launchStage?: LaunchStage + launchStage?: LaunchStage | (keyof typeof LaunchStage) } export namespace MonitoredResourceDescriptor { @@ -69,7 +69,7 @@ export namespace MonitoredResourceDescriptor { * Engine VM instance could be represented by the following object, because the * [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for `"gce_instance"` has labels * `"instance_id"` and `"zone"`: - * + * * { "type": "gce_instance", * "labels": { "instance_id": "12345678901234", * "zone": "us-central1-a" }} @@ -110,7 +110,7 @@ export interface MonitoredResourceMetadata { * "security_group", "name", etc. * System label values can be only strings, Boolean values, or a list of * strings. For example: - * + * * { "name": "my-test-instance", * "security_group": ["a", "b", "c"], * "spot_instance": false } diff --git a/packages/sisyphus-google/src/google/api/resource.ts b/packages/sisyphus-google/src/google/api/resource.ts index b8a0ae1..b7da0e3 100644 --- a/packages/sisyphus-google/src/google/api/resource.ts +++ b/packages/sisyphus-google/src/google/api/resource.ts @@ -110,7 +110,7 @@ export interface ResourceDescriptor { * }; * } */ - history?: ResourceDescriptor.History + history?: ResourceDescriptor.History | (keyof typeof ResourceDescriptor.History) /** * The plural name used in the resource name and permission names, such as @@ -136,7 +136,7 @@ export interface ResourceDescriptor { * These indicate that a resource is expected to conform to a given * style. See the specific style flags for additional information. */ - style?: ResourceDescriptor.Style[] + style?: ResourceDescriptor.Style | (keyof typeof ResourceDescriptor.Style)[] } export namespace ResourceDescriptor { @@ -148,20 +148,20 @@ export namespace ResourceDescriptor { */ export enum History { /** The "unset" value. */ - UNSPECIFIED = 'HISTORY_UNSPECIFIED', + HISTORY_UNSPECIFIED = 0, /** * The resource originally had one pattern and launched as such, and * additional patterns were added later. */ - ORIGINALLY_SINGLE_PATTERN = 'ORIGINALLY_SINGLE_PATTERN', + ORIGINALLY_SINGLE_PATTERN = 1, /** * The resource has one pattern, but the API owner expects to add more * later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents * that from being necessary once there are multiple patterns.) */ - FUTURE_MULTI_PATTERN = 'FUTURE_MULTI_PATTERN', + FUTURE_MULTI_PATTERN = 2, } export namespace History { @@ -171,19 +171,19 @@ export namespace ResourceDescriptor { /** A flag representing a specific style that a resource claims to conform to. */ export enum Style { /** The unspecified value. Do not use. */ - UNSPECIFIED = 'STYLE_UNSPECIFIED', + STYLE_UNSPECIFIED = 0, /** * This resource is intended to be "declarative-friendly". - * + * * Declarative-friendly resources must be more strictly consistent, and * setting this to true communicates to tools that this resource should * adhere to declarative-friendly expectations. - * + * * Note: This is used by the API linter (linter.aip.dev) to enable * additional checks. */ - DECLARATIVE_FRIENDLY = 'DECLARATIVE_FRIENDLY', + DECLARATIVE_FRIENDLY = 1, } export namespace Style { diff --git a/packages/sisyphus-google/src/google/api/service.ts b/packages/sisyphus-google/src/google/api/service.ts index 43cc608..eafcc58 100644 --- a/packages/sisyphus-google/src/google/api/service.ts +++ b/packages/sisyphus-google/src/google/api/service.ts @@ -1,3 +1,6 @@ +import {Api} from '@sisyphus.js/runtime/lib/google/protobuf/api' +import {Enum, Type} from '@sisyphus.js/runtime/lib/google/protobuf/type' +import {UInt32Value} from '@sisyphus.js/runtime/lib/google/protobuf/wrappers' import {Authentication} from './auth' import {Backend} from './backend' import {Billing} from './billing' @@ -15,9 +18,6 @@ import {Quota} from './quota' import {SourceInfo} from './source_info' import {SystemParameters} from './system_parameter' import {Usage} from './usage' -import {Api} from '@sisyphus.js/runtime/lib/google/protobuf/api' -import {Enum, Type} from '@sisyphus.js/runtime/lib/google/protobuf/type' -import {UInt32Value} from '@sisyphus.js/runtime/lib/google/protobuf/wrappers' /** * `Service` is the root object of Google service configuration schema. It @@ -25,9 +25,9 @@ import {UInt32Value} from '@sisyphus.js/runtime/lib/google/protobuf/wrappers' * title, and delegates other aspects to sub-sections. Each sub-section is * either a proto message or a repeated proto message that configures a * specific aspect, such as auth. See each proto message definition for details. - * + * * Example: - * + * * type: google.api.Service * name: calendar.googleapis.com * title: Google Calendar API @@ -81,7 +81,7 @@ export interface Service { * automatically included. Messages which are not referenced but * shall be included, such as types used by the `google.protobuf.Any` type, * should be listed here by name. Example: - * + * * types: * - name: google.protobuf.Int32 */ @@ -92,7 +92,7 @@ export interface Service { * referenced directly or indirectly by the `apis` are automatically * included. Enums which are not referenced but shall be included * should be listed here by name. Example: - * + * * enums: * - name: google.someapi.v1.SomeEnum */ @@ -158,7 +158,7 @@ export interface Service { /** * Obsolete. Do not use. - * + * * This field has no semantic meaning. The service config compiler always * sets this field to `3`. */ diff --git a/packages/sisyphus-google/src/google/cloud/audit/audit_log.ts b/packages/sisyphus-google/src/google/cloud/audit/audit_log.ts index 2d85c40..3f920cf 100644 --- a/packages/sisyphus-google/src/google/cloud/audit/audit_log.ts +++ b/packages/sisyphus-google/src/google/cloud/audit/audit_log.ts @@ -1,8 +1,8 @@ -import {AttributeContext} from '../../rpc/context/attribute_context' -import {Status} from '../../rpc/status' import {long} from '@sisyphus.js/runtime' import {Any} from '@sisyphus.js/runtime/lib/google/protobuf/any' import {Struct} from '@sisyphus.js/runtime/lib/google/protobuf/struct' +import {AttributeContext} from '../../rpc/context/attribute_context' +import {Status} from '../../rpc/status' /** Common audit log format for Google Cloud Platform API operations. */ export interface AuditLog { diff --git a/packages/sisyphus-google/src/google/cloud/extended_operations.ts b/packages/sisyphus-google/src/google/cloud/extended_operations.ts index def154f..5ba2456 100644 --- a/packages/sisyphus-google/src/google/cloud/extended_operations.ts +++ b/packages/sisyphus-google/src/google/cloud/extended_operations.ts @@ -8,13 +8,13 @@ import '@sisyphus.js/runtime/lib/google/protobuf/descriptor' */ export enum OperationResponseMapping { /** Do not use. */ - UNDEFINED = 'UNDEFINED', + UNDEFINED = 0, /** * A field in an API-specific (custom) Operation object which carries the same * meaning as google.longrunning.Operation.name. */ - NAME = 'NAME', + NAME = 1, /** * A field in an API-specific (custom) Operation object which carries the same @@ -24,19 +24,19 @@ export enum OperationResponseMapping { * boolean, then it should follow the same semantics as Operation.done. * Otherwise, a non-empty value should be treated as `Operation.done == true`. */ - STATUS = 'STATUS', + STATUS = 2, /** * A field in an API-specific (custom) Operation object which carries the same * meaning as google.longrunning.Operation.error.code. */ - ERROR_CODE = 'ERROR_CODE', + ERROR_CODE = 3, /** * A field in an API-specific (custom) Operation object which carries the same * meaning as google.longrunning.Operation.error.message. */ - ERROR_MESSAGE = 'ERROR_MESSAGE', + ERROR_MESSAGE = 4, } export namespace OperationResponseMapping { @@ -50,7 +50,7 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { * their standard counterparts in google.longrunning.Operation. See * OperationResponseMapping enum definition. */ - operationField: OperationResponseMapping + operationField: OperationResponseMapping | (keyof typeof OperationResponseMapping) /** * A field annotation that maps fields in the initial request message diff --git a/packages/sisyphus-google/src/google/logging/type/log_severity.ts b/packages/sisyphus-google/src/google/logging/type/log_severity.ts index 91f6b87..78badf4 100644 --- a/packages/sisyphus-google/src/google/logging/type/log_severity.ts +++ b/packages/sisyphus-google/src/google/logging/type/log_severity.ts @@ -17,34 +17,34 @@ */ export enum LogSeverity { /** (0) The log entry has no assigned severity level. */ - DEFAULT = 'DEFAULT', + DEFAULT = 0, /** (100) Debug or trace information. */ - DEBUG = 'DEBUG', + DEBUG = 100, /** (200) Routine information, such as ongoing status or performance. */ - INFO = 'INFO', + INFO = 200, /** * (300) Normal but significant events, such as start up, shut down, or * a configuration change. */ - NOTICE = 'NOTICE', + NOTICE = 300, /** (400) Warning events might cause problems. */ - WARNING = 'WARNING', + WARNING = 400, /** (500) Error events are likely to cause problems. */ - ERROR = 'ERROR', + ERROR = 500, /** (600) Critical events cause more severe problems or outages. */ - CRITICAL = 'CRITICAL', + CRITICAL = 600, /** (700) A person must take an action immediately. */ - ALERT = 'ALERT', + ALERT = 700, /** (800) One or more systems are unusable. */ - EMERGENCY = 'EMERGENCY', + EMERGENCY = 800, } export namespace LogSeverity { diff --git a/packages/sisyphus-google/src/google/longrunning/operations.ts b/packages/sisyphus-google/src/google/longrunning/operations.ts index 61b9ddf..cc260b8 100644 --- a/packages/sisyphus-google/src/google/longrunning/operations.ts +++ b/packages/sisyphus-google/src/google/longrunning/operations.ts @@ -1,8 +1,8 @@ -import {Status} from '../rpc/status' import {Any} from '@sisyphus.js/runtime/lib/google/protobuf/any' import '@sisyphus.js/runtime/lib/google/protobuf/descriptor' import {Duration} from '@sisyphus.js/runtime/lib/google/protobuf/duration' import {Empty} from '@sisyphus.js/runtime/lib/google/protobuf/empty' +import {Status} from '../rpc/status' /** * Manages long-running operations with an API service. diff --git a/packages/sisyphus-google/src/google/rpc/code.ts b/packages/sisyphus-google/src/google/rpc/code.ts index 96ea74c..4429a64 100644 --- a/packages/sisyphus-google/src/google/rpc/code.ts +++ b/packages/sisyphus-google/src/google/rpc/code.ts @@ -10,17 +10,17 @@ export enum Code { /** * Not an error; returned on success - * + * * HTTP Mapping: 200 OK */ - OK = 'OK', + OK = 0, /** * The operation was cancelled, typically by the caller. - * + * * HTTP Mapping: 499 Client Closed Request */ - CANCELLED = 'CANCELLED', + CANCELLED = 1, /** * Unknown error. For example, this error may be returned when @@ -28,20 +28,20 @@ export enum Code { * an error space that is not known in this address space. Also * errors raised by APIs that do not return enough error information * may be converted to this error. - * + * * HTTP Mapping: 500 Internal Server Error */ - UNKNOWN = 'UNKNOWN', + UNKNOWN = 2, /** * The client specified an invalid argument. Note that this differs * from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments * that are problematic regardless of the state of the system * (e.g., a malformed file name). - * + * * HTTP Mapping: 400 Bad Request */ - INVALID_ARGUMENT = 'INVALID_ARGUMENT', + INVALID_ARGUMENT = 3, /** * The deadline expired before the operation could complete. For operations @@ -49,31 +49,31 @@ export enum Code { * even if the operation has completed successfully. For example, a * successful response from a server could have been delayed long * enough for the deadline to expire. - * + * * HTTP Mapping: 504 Gateway Timeout */ - DEADLINE_EXCEEDED = 'DEADLINE_EXCEEDED', + DEADLINE_EXCEEDED = 4, /** * Some requested entity (e.g., file or directory) was not found. - * + * * Note to server developers: if a request is denied for an entire class * of users, such as gradual feature rollout or undocumented whitelist, * `NOT_FOUND` may be used. If a request is denied for some users within * a class of users, such as user-based access control, `PERMISSION_DENIED` * must be used. - * + * * HTTP Mapping: 404 Not Found */ - NOT_FOUND = 'NOT_FOUND', + NOT_FOUND = 5, /** * The entity that a client attempted to create (e.g., file or directory) * already exists. - * + * * HTTP Mapping: 409 Conflict */ - ALREADY_EXISTS = 'ALREADY_EXISTS', + ALREADY_EXISTS = 6, /** * The caller does not have permission to execute the specified @@ -84,33 +84,33 @@ export enum Code { * instead for those errors). This error code does not imply the * request is valid or the requested entity exists or satisfies * other pre-conditions. - * + * * HTTP Mapping: 403 Forbidden */ - PERMISSION_DENIED = 'PERMISSION_DENIED', + PERMISSION_DENIED = 7, /** * The request does not have valid authentication credentials for the * operation. - * + * * HTTP Mapping: 401 Unauthorized */ - UNAUTHENTICATED = 'UNAUTHENTICATED', + UNAUTHENTICATED = 16, /** * Some resource has been exhausted, perhaps a per-user quota, or * perhaps the entire file system is out of space. - * + * * HTTP Mapping: 429 Too Many Requests */ - RESOURCE_EXHAUSTED = 'RESOURCE_EXHAUSTED', + RESOURCE_EXHAUSTED = 8, /** * The operation was rejected because the system is not in a state * required for the operation's execution. For example, the directory * to be deleted is non-empty, an rmdir operation is applied to * a non-directory, etc. - * + * * Service implementors can use the following guidelines to decide * between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: * (a) Use `UNAVAILABLE` if the client can retry just the failing call. @@ -122,79 +122,79 @@ export enum Code { * fails because the directory is non-empty, `FAILED_PRECONDITION` * should be returned since the client should not retry unless * the files are deleted from the directory. - * + * * HTTP Mapping: 400 Bad Request */ - FAILED_PRECONDITION = 'FAILED_PRECONDITION', + FAILED_PRECONDITION = 9, /** * The operation was aborted, typically due to a concurrency issue such as * a sequencer check failure or transaction abort. - * + * * See the guidelines above for deciding between `FAILED_PRECONDITION`, * `ABORTED`, and `UNAVAILABLE`. - * + * * HTTP Mapping: 409 Conflict */ - ABORTED = 'ABORTED', + ABORTED = 10, /** * The operation was attempted past the valid range. E.g., seeking or * reading past end-of-file. - * + * * Unlike `INVALID_ARGUMENT`, this error indicates a problem that may * be fixed if the system state changes. For example, a 32-bit file * system will generate `INVALID_ARGUMENT` if asked to read at an * offset that is not in the range [0,2^32-1], but it will generate * `OUT_OF_RANGE` if asked to read from an offset past the current * file size. - * + * * There is a fair bit of overlap between `FAILED_PRECONDITION` and * `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific * error) when it applies so that callers who are iterating through * a space can easily look for an `OUT_OF_RANGE` error to detect when * they are done. - * + * * HTTP Mapping: 400 Bad Request */ - OUT_OF_RANGE = 'OUT_OF_RANGE', + OUT_OF_RANGE = 11, /** * The operation is not implemented or is not supported/enabled in this * service. - * + * * HTTP Mapping: 501 Not Implemented */ - UNIMPLEMENTED = 'UNIMPLEMENTED', + UNIMPLEMENTED = 12, /** * Internal errors. This means that some invariants expected by the * underlying system have been broken. This error code is reserved * for serious errors. - * + * * HTTP Mapping: 500 Internal Server Error */ - INTERNAL = 'INTERNAL', + INTERNAL = 13, /** * The service is currently unavailable. This is most likely a * transient condition, which can be corrected by retrying with * a backoff. Note that it is not always safe to retry * non-idempotent operations. - * + * * See the guidelines above for deciding between `FAILED_PRECONDITION`, * `ABORTED`, and `UNAVAILABLE`. - * + * * HTTP Mapping: 503 Service Unavailable */ - UNAVAILABLE = 'UNAVAILABLE', + UNAVAILABLE = 14, /** * Unrecoverable data loss or corruption. - * + * * HTTP Mapping: 500 Internal Server Error */ - DATA_LOSS = 'DATA_LOSS', + DATA_LOSS = 15, } export namespace Code { diff --git a/packages/sisyphus-google/src/google/type/calendar_period.ts b/packages/sisyphus-google/src/google/type/calendar_period.ts index cf7a818..ce25d2c 100644 --- a/packages/sisyphus-google/src/google/type/calendar_period.ts +++ b/packages/sisyphus-google/src/google/type/calendar_period.ts @@ -5,38 +5,38 @@ */ export enum CalendarPeriod { /** Undefined period, raises an error. */ - UNSPECIFIED = 'CALENDAR_PERIOD_UNSPECIFIED', + CALENDAR_PERIOD_UNSPECIFIED = 0, /** A day. */ - DAY = 'DAY', + DAY = 1, /** * A week. Weeks begin on Monday, following * [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date). */ - WEEK = 'WEEK', + WEEK = 2, /** * A fortnight. The first calendar fortnight of the year begins at the start * of week 1 according to * [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date). */ - FORTNIGHT = 'FORTNIGHT', + FORTNIGHT = 3, /** A month. */ - MONTH = 'MONTH', + MONTH = 4, /** * A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each * year. */ - QUARTER = 'QUARTER', + QUARTER = 5, /** A half-year. Half-years start on dates 1-Jan and 1-Jul. */ - HALF = 'HALF', + HALF = 6, /** A year. */ - YEAR = 'YEAR', + YEAR = 7, } export namespace CalendarPeriod { diff --git a/packages/sisyphus-google/src/google/type/dayofweek.ts b/packages/sisyphus-google/src/google/type/dayofweek.ts index 70b4ebf..fe315e9 100644 --- a/packages/sisyphus-google/src/google/type/dayofweek.ts +++ b/packages/sisyphus-google/src/google/type/dayofweek.ts @@ -1,28 +1,28 @@ /** Represents a day of the week. */ export enum DayOfWeek { /** The day of the week is unspecified. */ - UNSPECIFIED = 'DAY_OF_WEEK_UNSPECIFIED', + DAY_OF_WEEK_UNSPECIFIED = 0, /** Monday */ - MONDAY = 'MONDAY', + MONDAY = 1, /** Tuesday */ - TUESDAY = 'TUESDAY', + TUESDAY = 2, /** Wednesday */ - WEDNESDAY = 'WEDNESDAY', + WEDNESDAY = 3, /** Thursday */ - THURSDAY = 'THURSDAY', + THURSDAY = 4, /** Friday */ - FRIDAY = 'FRIDAY', + FRIDAY = 5, /** Saturday */ - SATURDAY = 'SATURDAY', + SATURDAY = 6, /** Sunday */ - SUNDAY = 'SUNDAY', + SUNDAY = 7, } export namespace DayOfWeek { diff --git a/packages/sisyphus-google/src/google/type/month.ts b/packages/sisyphus-google/src/google/type/month.ts index 74542c3..cbf7885 100644 --- a/packages/sisyphus-google/src/google/type/month.ts +++ b/packages/sisyphus-google/src/google/type/month.ts @@ -1,43 +1,43 @@ /** Represents a month in the Gregorian calendar. */ export enum Month { /** The unspecified month. */ - UNSPECIFIED = 'MONTH_UNSPECIFIED', + MONTH_UNSPECIFIED = 0, /** The month of January. */ - JANUARY = 'JANUARY', + JANUARY = 1, /** The month of February. */ - FEBRUARY = 'FEBRUARY', + FEBRUARY = 2, /** The month of March. */ - MARCH = 'MARCH', + MARCH = 3, /** The month of April. */ - APRIL = 'APRIL', + APRIL = 4, /** The month of May. */ - MAY = 'MAY', + MAY = 5, /** The month of June. */ - JUNE = 'JUNE', + JUNE = 6, /** The month of July. */ - JULY = 'JULY', + JULY = 7, /** The month of August. */ - AUGUST = 'AUGUST', + AUGUST = 8, /** The month of September. */ - SEPTEMBER = 'SEPTEMBER', + SEPTEMBER = 9, /** The month of October. */ - OCTOBER = 'OCTOBER', + OCTOBER = 10, /** The month of November. */ - NOVEMBER = 'NOVEMBER', + NOVEMBER = 11, /** The month of December. */ - DECEMBER = 'DECEMBER', + DECEMBER = 12, } export namespace Month { diff --git a/packages/sisyphus-protoc/package.json b/packages/sisyphus-protoc/package.json index cc36845..cfac8ed 100644 --- a/packages/sisyphus-protoc/package.json +++ b/packages/sisyphus-protoc/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/protoc", - "version": "2.0.8", + "version": "2.1.0", "description": "Install protoc for current platform.", "main": "lib/index.js", "bin": { diff --git a/packages/sisyphus-protoc/src/protoc.ts b/packages/sisyphus-protoc/src/protoc.ts index 6862ba5..8774f63 100644 --- a/packages/sisyphus-protoc/src/protoc.ts +++ b/packages/sisyphus-protoc/src/protoc.ts @@ -5,7 +5,14 @@ import fs from 'fs/promises' import log from 'npmlog' import * as os from 'os' import path from 'path' -import {download, generateReleaseName, getProtobufVersionConfig, getRedirectLocation, installedDirectory} from './util' +import { + download, + generateProtocName, + generateReleaseName, + getProtobufVersionConfig, + getRedirectLocation, + installedDirectory +} from './util' export default async function protoc(...args: string[]): Promise { const version = await getProtobufVersionConfig(process.cwd()) @@ -32,7 +39,7 @@ async function ensureProtoc(version: string | undefined | null): Promise const releaseName = generateReleaseName(os.platform(), os.arch(), version) const releasePath = path.join(installedDirectory, releaseName) - const protocPath = path.join(releasePath, 'bin', 'protoc') + const protocPath = path.join(releasePath, 'bin', generateProtocName(os.platform())) try { await fs.access(protocPath, constants.X_OK) diff --git a/packages/sisyphus-protoc/src/util.ts b/packages/sisyphus-protoc/src/util.ts index 9eae871..c0581ba 100644 --- a/packages/sisyphus-protoc/src/util.ts +++ b/packages/sisyphus-protoc/src/util.ts @@ -40,6 +40,13 @@ export function generateReleaseName(platform: NodeJS.Platform, arch: string, ver return `protoc-${version}-${build}` } +export function generateProtocName(platform: NodeJS.Platform): string { + if (platform === 'win32') { + return 'protoc.exe' + } + return 'protoc' +} + function downloadRedirected(uri: string, redirects: string[] = []): Promise { const url = new URL(uri) diff --git a/packages/sisyphus-runtime-proto/package.json b/packages/sisyphus-runtime-proto/package.json index 9f8de65..3191250 100644 --- a/packages/sisyphus-runtime-proto/package.json +++ b/packages/sisyphus-runtime-proto/package.json @@ -1,13 +1,14 @@ { "name": "@sisyphus.js/runtime.proto", - "version": "2.0.8", + "version": "2.1.0", "description": "Protobuf full runtime for sisyphus project on js platform, support protobuf binary format.", "main": "lib/index.js", "scripts": { "clean": "tsc --build --clean", "build": "tsc", "watch": "tsc -w", - "test": "mocha" + "test": "mocha", + "protoc": "sisygen -O ./src" }, "files": [ "lib", @@ -34,7 +35,7 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "dependencies": { - "@sisyphus.js/runtime": "^2.0.8" + "@sisyphus.js/runtime": "^2.1.0" }, "directories": { "lib": "lib" diff --git a/packages/sisyphus-runtime-proto/src/README.md b/packages/sisyphus-runtime-proto/src/README.md deleted file mode 100644 index 07f61ff..0000000 --- a/packages/sisyphus-runtime-proto/src/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# @sisyphus.js NPM 包 - -- [@sisyphus.js/runtime](./sisyphus-runtime) - - sisyphus.js 核心运行时,用于仅支持 Json 接口访问的代码生成,包含预编译的 well-known protos 与一些基础类型定义。 - [![](https://img.shields.io/npm/v/@sisyphus.js/runtime)](https://www.npmjs.com/package/@sisyphus.js/runtime) - -- [@sisyphus.js/runtime.proto](./sisyphus-runtime-proto) - - sisyphus.js 完整 Protobuf 运行时,用于反序列化/序列化 Protobuf 二进制格式。 - [![](https://img.shields.io/npm/v/@sisyphus.js/runtime.proto)](https://www.npmjs.com/package/@sisyphus.js/runtime.proto) - -- [@sisyphus.js/google](./sisyphus-google) - - 预编译的由 google 定义的特殊 protos,仅包含 Json 接口,定义了 Http/gRPC 转码标准。 - [![](https://img.shields.io/npm/v/@sisyphus.js/google)](https://www.npmjs.com/package/@sisyphus.js/google) - -- [@sisyphus.js/google.proto](./sisyphus-google-proto) - - 预编译的由 google 定义的特殊 protos,包含二进制序列化/反序列化支持。 - [![](https://img.shields.io/npm/v/@sisyphus.js/google.proto)](https://www.npmjs.com/package/@sisyphus.js/google.proto) - -- [@sisyphus.js/google.aip](./sisyphus-google-aip) - - 预编译的由 google 定义的特殊 protos 的 AIP 标准客户端,目前只包含 long running operation 客户端。 - [![](https://img.shields.io/npm/v/@sisyphus.js/google.aip)](https://www.npmjs.com/package/@sisyphus.js/google.aip) - -- [@sisyphus.js/protoc](./sisyphus-protoc) - - 为当前的运行环境自动下载 protoc release,并且提供了 npm script 快速访问 protoc 命令的方式。 - [![](https://img.shields.io/npm/v/@sisyphus.js/protoc)](https://www.npmjs.com/package/@sisyphus.js/protoc) - -- [@sisyphus.js/compiler](./sisyphus-compiler) - - sisyphus.js 基础编译器插件,包含 core, proto, aip 三个子插件。 - [![](https://img.shields.io/npm/v/@sisyphus.js/compiler)](https://www.npmjs.com/package/@sisyphus.js/compiler) - -- [@sisyphus.js/cli](./sisyphus-cli) - - sisyphus.js 命令行界面,提供 sisygen 命令来快速生成 protobuf 代码。 - [![](https://img.shields.io/npm/v/@sisyphus.js/cli)](https://www.npmjs.com/package/@sisyphus.js/cli) diff --git a/packages/sisyphus-runtime-proto/src/google/protobuf/descriptor.proto.ts b/packages/sisyphus-runtime-proto/src/google/protobuf/descriptor.proto.ts index 00b0c47..bf0c138 100644 --- a/packages/sisyphus-runtime-proto/src/google/protobuf/descriptor.proto.ts +++ b/packages/sisyphus-runtime-proto/src/google/protobuf/descriptor.proto.ts @@ -1,6 +1,28 @@ +import { + DescriptorProto, + EnumDescriptorProto, + EnumOptions, + EnumValueDescriptorProto, + EnumValueOptions, + ExtensionRangeOptions, + FieldDescriptorProto, + FieldOptions, + FileDescriptorProto, + FileDescriptorSet, + FileOptions, + GeneratedCodeInfo, + MessageOptions, + MethodDescriptorProto, + MethodOptions, + OneofDescriptorProto, + OneofOptions, + ServiceDescriptorProto, + ServiceOptions, + SourceCodeInfo, + UninterpretedOption +} from '@sisyphus.js/runtime/lib/google/protobuf/descriptor' import {binaryifyFun, parseFun} from '../../message' import {EnumDescriptor, MessageDescriptor} from '../../reflection' -import {DescriptorProto, EnumDescriptorProto, EnumOptions, EnumValueDescriptorProto, EnumValueOptions, ExtensionRangeOptions, FieldDescriptorProto, FieldOptions, FileDescriptorProto, FileDescriptorSet, FileOptions, GeneratedCodeInfo, MessageOptions, MethodDescriptorProto, MethodOptions, OneofDescriptorProto, OneofOptions, ServiceDescriptorProto, ServiceOptions, SourceCodeInfo, UninterpretedOption} from '@sisyphus.js/runtime/lib/google/protobuf/descriptor' declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { namespace FileDescriptorSet { @@ -25,6 +47,7 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { function binaryify(v: DescriptorProto): Uint8Array function parse(buffer: Uint8Array): DescriptorProto + namespace ExtensionRange { let descriptor: MessageDescriptor @@ -80,6 +103,7 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { function binaryify(v: EnumDescriptorProto): Uint8Array function parse(buffer: Uint8Array): EnumDescriptorProto + namespace EnumReservedRange { let descriptor: MessageDescriptor @@ -199,6 +223,7 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { function binaryify(v: UninterpretedOption): Uint8Array function parse(buffer: Uint8Array): UninterpretedOption + namespace NamePart { let descriptor: MessageDescriptor @@ -214,6 +239,7 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { function binaryify(v: SourceCodeInfo): Uint8Array function parse(buffer: Uint8Array): SourceCodeInfo + namespace Location { let descriptor: MessageDescriptor @@ -229,6 +255,7 @@ declare module '@sisyphus.js/runtime/lib/google/protobuf/descriptor' { function binaryify(v: GeneratedCodeInfo): Uint8Array function parse(buffer: Uint8Array): GeneratedCodeInfo + namespace Annotation { let descriptor: MessageDescriptor diff --git a/packages/sisyphus-runtime/package.json b/packages/sisyphus-runtime/package.json index effd865..edeaaf6 100644 --- a/packages/sisyphus-runtime/package.json +++ b/packages/sisyphus-runtime/package.json @@ -1,13 +1,14 @@ { "name": "@sisyphus.js/runtime", - "version": "2.0.8", + "version": "2.1.0", "description": "Protobuf lite runtime for sisyphus project on js platform, only support JSON format.", "main": "lib/index.js", "scripts": { "clean": "tsc --build --clean", "build": "tsc", "watch": "tsc -w", - "test": "mocha" + "test": "mocha", + "protoc": "sisygen -O ./src" }, "files": [ "lib", diff --git a/packages/sisyphus-runtime/src/enum.ts b/packages/sisyphus-runtime/src/enum.ts new file mode 100644 index 0000000..752cd72 --- /dev/null +++ b/packages/sisyphus-runtime/src/enum.ts @@ -0,0 +1,12 @@ +export function enumValue(value: number | string, enumType: any): number { + if (typeof value === 'string') value = enumType[value] ?? 0 + if (typeof value !== 'number') throw new Error(`'${value}' must be a enum(number or string).`) + return value +} + +export function enumValueName(value: number | string, enumType: any): string { + if (typeof value === 'number') { + return enumType[value] + } + return enumType[value] ?? value +} diff --git a/packages/sisyphus-runtime/src/google/protobuf/api.ts b/packages/sisyphus-runtime/src/google/protobuf/api.ts index 0eb799a..487f222 100644 --- a/packages/sisyphus-runtime/src/google/protobuf/api.ts +++ b/packages/sisyphus-runtime/src/google/protobuf/api.ts @@ -58,7 +58,7 @@ export interface Api { mixins?: Mixin[] /** The source syntax of the service. */ - syntax?: Syntax + syntax?: Syntax | (keyof typeof Syntax) } export namespace Api { @@ -86,7 +86,7 @@ export interface Method { options?: Option[] /** The source syntax of this method. */ - syntax?: Syntax + syntax?: Syntax | (keyof typeof Syntax) } export namespace Method { diff --git a/packages/sisyphus-runtime/src/google/protobuf/descriptor.ts b/packages/sisyphus-runtime/src/google/protobuf/descriptor.ts index cc27d1c..eda0073 100644 --- a/packages/sisyphus-runtime/src/google/protobuf/descriptor.ts +++ b/packages/sisyphus-runtime/src/google/protobuf/descriptor.ts @@ -133,13 +133,13 @@ export interface FieldDescriptorProto { number?: number - label?: FieldDescriptorProto.Label + label?: FieldDescriptorProto.Label | (keyof typeof FieldDescriptorProto.Label) /** * If type_name is set, this need not be set. If both this and type_name * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. */ - type?: FieldDescriptorProto.Type + type?: FieldDescriptorProto.Type | (keyof typeof FieldDescriptorProto.Type) /** * For message and enum types, this is the name of the type. If the name @@ -214,31 +214,31 @@ export namespace FieldDescriptorProto { * 0 is reserved for errors. * Order is weird for historical reasons. */ - DOUBLE = 'TYPE_DOUBLE', + TYPE_DOUBLE = 1, - FLOAT = 'TYPE_FLOAT', + TYPE_FLOAT = 2, /** * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if * negative values are likely. */ - INT64 = 'TYPE_INT64', + TYPE_INT64 = 3, - UINT64 = 'TYPE_UINT64', + TYPE_UINT64 = 4, /** * Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if * negative values are likely. */ - INT32 = 'TYPE_INT32', + TYPE_INT32 = 5, - FIXED64 = 'TYPE_FIXED64', + TYPE_FIXED64 = 6, - FIXED32 = 'TYPE_FIXED32', + TYPE_FIXED32 = 7, - BOOL = 'TYPE_BOOL', + TYPE_BOOL = 8, - STRING = 'TYPE_STRING', + TYPE_STRING = 9, /** * Tag-delimited aggregate. @@ -246,24 +246,24 @@ export namespace FieldDescriptorProto { * implementations should still be able to parse the group wire format and * treat group fields as unknown fields. */ - GROUP = 'TYPE_GROUP', + TYPE_GROUP = 10, - MESSAGE = 'TYPE_MESSAGE', // Length-delimited aggregate. + TYPE_MESSAGE = 11, // Length-delimited aggregate. /** New in version 2. */ - BYTES = 'TYPE_BYTES', + TYPE_BYTES = 12, - UINT32 = 'TYPE_UINT32', + TYPE_UINT32 = 13, - ENUM = 'TYPE_ENUM', + TYPE_ENUM = 14, - SFIXED32 = 'TYPE_SFIXED32', + TYPE_SFIXED32 = 15, - SFIXED64 = 'TYPE_SFIXED64', + TYPE_SFIXED64 = 16, - SINT32 = 'TYPE_SINT32', // Uses ZigZag encoding. + TYPE_SINT32 = 17, // Uses ZigZag encoding. - SINT64 = 'TYPE_SINT64', // Uses ZigZag encoding. + TYPE_SINT64 = 18, // Uses ZigZag encoding. } export namespace Type { @@ -272,11 +272,11 @@ export namespace FieldDescriptorProto { export enum Label { /** 0 is reserved for errors */ - OPTIONAL = 'LABEL_OPTIONAL', + LABEL_OPTIONAL = 1, - REQUIRED = 'LABEL_REQUIRED', + LABEL_REQUIRED = 2, - REPEATED = 'LABEL_REPEATED', + LABEL_REPEATED = 3, } export namespace Label { @@ -463,7 +463,7 @@ export interface FileOptions { */ javaStringCheckUtf8?: boolean - optimizeFor?: FileOptions.OptimizeMode + optimizeFor?: FileOptions.OptimizeMode | (keyof typeof FileOptions.OptimizeMode) /** * Sets the Go package where structs generated from this .proto will be @@ -564,12 +564,12 @@ export namespace FileOptions { /** Generated classes can be optimized for speed or code size. */ export enum OptimizeMode { - SPEED = 'SPEED', // Generate complete code for parsing, serialization, + SPEED = 1, // Generate complete code for parsing, serialization, /** etc. */ - CODE_SIZE = 'CODE_SIZE', // Use ReflectionOps to implement these methods. + CODE_SIZE = 2, // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 'LITE_RUNTIME', // Generate code using MessageLite and the lite runtime. + LITE_RUNTIME = 3, // Generate code using MessageLite and the lite runtime. } export namespace OptimizeMode { @@ -655,7 +655,7 @@ export interface FieldOptions { * options below. This option is not yet implemented in the open source * release -- sorry, we'll try to include it in a future version! */ - ctype?: FieldOptions.CType + ctype?: FieldOptions.CType | (keyof typeof FieldOptions.CType) /** * The packed option can be enabled for repeated primitive fields to enable @@ -675,11 +675,11 @@ export interface FieldOptions { * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to * use the JavaScript "number" type. The behavior of the default option * JS_NORMAL is implementation dependent. - * + * * This option is an enum to permit additional types to be added, e.g. * goog.math.Integer. */ - jstype?: FieldOptions.JSType + jstype?: FieldOptions.JSType | (keyof typeof FieldOptions.JSType) /** * Should this field be parsed lazily? Lazy applies only to message-type @@ -746,11 +746,11 @@ export namespace FieldOptions { export enum CType { /** Default mode. */ - STRING = 'STRING', + STRING = 0, - CORD = 'CORD', + CORD = 1, - STRING_PIECE = 'STRING_PIECE', + STRING_PIECE = 2, } export namespace CType { @@ -759,13 +759,13 @@ export namespace FieldOptions { export enum JSType { /** Use the default type. */ - JS_NORMAL = 'JS_NORMAL', + JS_NORMAL = 0, /** Use JavaScript strings. */ - JS_STRING = 'JS_STRING', + JS_STRING = 1, /** Use JavaScript numbers. */ - JS_NUMBER = 'JS_NUMBER', + JS_NUMBER = 2, } export namespace JSType { @@ -858,7 +858,7 @@ export interface MethodOptions { */ deprecated?: boolean - idempotencyLevel?: MethodOptions.IdempotencyLevel + idempotencyLevel?: MethodOptions.IdempotencyLevel | (keyof typeof MethodOptions.IdempotencyLevel) /** The parser stores options it doesn't recognize here. See above. */ uninterpretedOption?: UninterpretedOption[] @@ -873,11 +873,11 @@ export namespace MethodOptions { * methods, and PUT verb for idempotent methods instead of the default POST. */ export enum IdempotencyLevel { - IDEMPOTENCY_UNKNOWN = 'IDEMPOTENCY_UNKNOWN', + IDEMPOTENCY_UNKNOWN = 0, - NO_SIDE_EFFECTS = 'NO_SIDE_EFFECTS', // implies idempotent + NO_SIDE_EFFECTS = 1, // implies idempotent - IDEMPOTENT = 'IDEMPOTENT', // idempotent, but may have side effects + IDEMPOTENT = 2, // idempotent, but may have side effects } export namespace IdempotencyLevel { diff --git a/packages/sisyphus-runtime/src/google/protobuf/type.ts b/packages/sisyphus-runtime/src/google/protobuf/type.ts index e0cda8e..10091ef 100644 --- a/packages/sisyphus-runtime/src/google/protobuf/type.ts +++ b/packages/sisyphus-runtime/src/google/protobuf/type.ts @@ -19,7 +19,7 @@ export interface Type { sourceContext?: SourceContext /** The source syntax. */ - syntax?: Syntax + syntax?: Syntax | (keyof typeof Syntax) } export namespace Type { @@ -29,10 +29,10 @@ export namespace Type { /** A single field of a message type. */ export interface Field { /** The field type. */ - kind?: Field.Kind + kind?: Field.Kind | (keyof typeof Field.Kind) /** The field cardinality. */ - cardinality?: Field.Cardinality + cardinality?: Field.Cardinality | (keyof typeof Field.Cardinality) /** The field number. */ number?: number @@ -71,61 +71,61 @@ export namespace Field { /** Basic field types. */ export enum Kind { /** Field type unknown. */ - TYPE_UNKNOWN = 'TYPE_UNKNOWN', + TYPE_UNKNOWN = 0, /** Field type double. */ - TYPE_DOUBLE = 'TYPE_DOUBLE', + TYPE_DOUBLE = 1, /** Field type float. */ - TYPE_FLOAT = 'TYPE_FLOAT', + TYPE_FLOAT = 2, /** Field type int64. */ - TYPE_INT64 = 'TYPE_INT64', + TYPE_INT64 = 3, /** Field type uint64. */ - TYPE_UINT64 = 'TYPE_UINT64', + TYPE_UINT64 = 4, /** Field type int32. */ - TYPE_INT32 = 'TYPE_INT32', + TYPE_INT32 = 5, /** Field type fixed64. */ - TYPE_FIXED64 = 'TYPE_FIXED64', + TYPE_FIXED64 = 6, /** Field type fixed32. */ - TYPE_FIXED32 = 'TYPE_FIXED32', + TYPE_FIXED32 = 7, /** Field type bool. */ - TYPE_BOOL = 'TYPE_BOOL', + TYPE_BOOL = 8, /** Field type string. */ - TYPE_STRING = 'TYPE_STRING', + TYPE_STRING = 9, /** Field type group. Proto2 syntax only, and deprecated. */ - TYPE_GROUP = 'TYPE_GROUP', + TYPE_GROUP = 10, /** Field type message. */ - TYPE_MESSAGE = 'TYPE_MESSAGE', + TYPE_MESSAGE = 11, /** Field type bytes. */ - TYPE_BYTES = 'TYPE_BYTES', + TYPE_BYTES = 12, /** Field type uint32. */ - TYPE_UINT32 = 'TYPE_UINT32', + TYPE_UINT32 = 13, /** Field type enum. */ - TYPE_ENUM = 'TYPE_ENUM', + TYPE_ENUM = 14, /** Field type sfixed32. */ - TYPE_SFIXED32 = 'TYPE_SFIXED32', + TYPE_SFIXED32 = 15, /** Field type sfixed64. */ - TYPE_SFIXED64 = 'TYPE_SFIXED64', + TYPE_SFIXED64 = 16, /** Field type sint32. */ - TYPE_SINT32 = 'TYPE_SINT32', + TYPE_SINT32 = 17, /** Field type sint64. */ - TYPE_SINT64 = 'TYPE_SINT64', + TYPE_SINT64 = 18, } export namespace Kind { @@ -135,16 +135,16 @@ export namespace Field { /** Whether a field is optional, required, or repeated. */ export enum Cardinality { /** For fields with unknown cardinality. */ - UNKNOWN = 'CARDINALITY_UNKNOWN', + CARDINALITY_UNKNOWN = 0, /** For optional fields. */ - OPTIONAL = 'CARDINALITY_OPTIONAL', + CARDINALITY_OPTIONAL = 1, /** For required fields. Proto2 syntax only. */ - REQUIRED = 'CARDINALITY_REQUIRED', + CARDINALITY_REQUIRED = 2, /** For repeated fields. */ - REPEATED = 'CARDINALITY_REPEATED', + CARDINALITY_REPEATED = 3, } export namespace Cardinality { @@ -167,7 +167,7 @@ export interface Enum { sourceContext?: SourceContext /** The source syntax. */ - syntax?: Syntax + syntax?: Syntax | (keyof typeof Syntax) } export namespace Enum { @@ -219,10 +219,10 @@ export namespace Option { /** The syntax in which a protocol buffer element is defined. */ export enum Syntax { /** Syntax `proto2`. */ - PROTO2 = 'SYNTAX_PROTO2', + SYNTAX_PROTO2 = 0, /** Syntax `proto3`. */ - PROTO3 = 'SYNTAX_PROTO3', + SYNTAX_PROTO3 = 1, } export namespace Syntax { diff --git a/packages/sisyphus-runtime/src/index.ts b/packages/sisyphus-runtime/src/index.ts index 598f2e8..b2c6bc4 100644 --- a/packages/sisyphus-runtime/src/index.ts +++ b/packages/sisyphus-runtime/src/index.ts @@ -10,6 +10,7 @@ export * from './timestamp' export * from './google/protobuf/type' export * from './google/protobuf/wrappers' +export * from './enum' export * from './base64' export * from './int64' export * from './long' diff --git a/packages/sisyphus-transport-aip/package.json b/packages/sisyphus-transport-aip/package.json index b0f6372..2512cdc 100644 --- a/packages/sisyphus-transport-aip/package.json +++ b/packages/sisyphus-transport-aip/package.json @@ -1,6 +1,6 @@ { "name": "@sisyphus.js/transport-aip", - "version": "2.0.8", + "version": "2.1.0", "description": "gRPC transport based on AIP spec(gRPC to HTTP/Json Transcoding).", "main": "lib/index.js", "scripts": { @@ -32,8 +32,8 @@ }, "homepage": "https://github.com/ButterCam/sisyphus-js#readme", "dependencies": { - "@sisyphus.js/google": "^2.0.8", - "@sisyphus.js/runtime": "^2.0.8" + "@sisyphus.js/google": "^2.1.0", + "@sisyphus.js/runtime": "^2.1.0" }, "directories": { "lib": "lib",