Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
feat: convert v3beta1 to TypeScript (#389)
Browse files Browse the repository at this point in the history
* feat: convert v3beta1 to TypeScript

* fix: gts fix

* fix: no npx
  • Loading branch information
alexander-fenster committed Nov 22, 2019
1 parent da755f3 commit 0a88c63
Show file tree
Hide file tree
Showing 22 changed files with 1,672 additions and 2,861 deletions.
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@
"scripts": {
"docs": "jsdoc -c .jsdoc.js",
"predocs": "npm run compile",
"lint": "npm run check && eslint '**/*.js'",
"lint": "gts check && eslint '**/*.js'",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"system-test": "mocha build/system-test --timeout 600000",
"test": "c8 mocha build/test",
"check": "gts check",
"clean": "gts clean",
"compile": "tsc -p . && npm run copy-js",
"copy-js": "cp -r src/v3beta1 build/src/ && cp -r protos build/ && cp test/*.js build/test",
"compile": "tsc -p . && cp -r protos build/",
"fix": "gts fix && eslint --fix '**/*.js'",
"prepare": "npm run compile",
"pretest": "npm run compile",
Expand All @@ -50,7 +47,7 @@
"@google-cloud/promisify": "^1.0.0",
"arrify": "^2.0.0",
"extend": "^3.0.2",
"google-gax": "^1.7.5",
"google-gax": "^1.11.1",
"is": "^3.2.1",
"is-html": "^2.0.0",
"protobufjs": "^6.8.8"
Expand Down
68 changes: 68 additions & 0 deletions protos/google/cloud/common_resources.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This file contains stub messages for common resources in GCP.
// It is not intended to be directly generated, and is instead used by
// other tooling to be able to match common resource patterns.
syntax = "proto3";

package google.cloud;

import "google/api/resource.proto";


message Project {
option (google.api.resource) = {
type: "cloudresourcemanager.googleapis.com/Project"
pattern: "projects/{project}"
};

string name = 1;
}

message Organization {
option (google.api.resource) = {
type: "cloudresourcemanager.googleapis.com/Organization"
pattern: "organizations/{organization}"
};

string name = 1;
}

message Folder {
option (google.api.resource) = {
type: "cloudresourcemanager.googleapis.com/Folder"
pattern: "folders/{folder}"
};

string name = 1;
}

message BillingAccount {
option (google.api.resource) = {
type: "cloudbilling.googleapis.com/BillingAccount"
pattern: "billingAccounts/{billing_account}"
};

string name = 1;
}

message Location {
option (google.api.resource) = {
type: "locations.googleapis.com/Location"
pattern: "projects/{project}/locations/{location}"
};

string name = 1;
}
30 changes: 30 additions & 0 deletions protos/protos.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as Long from "long";
import * as $protobuf from "protobufjs";
/** Namespace google. */
export namespace google {
Expand Down Expand Up @@ -6774,6 +6789,12 @@ export namespace google {

/** ResourceDescriptor history */
history?: (google.api.ResourceDescriptor.History|null);

/** ResourceDescriptor plural */
plural?: (string|null);

/** ResourceDescriptor singular */
singular?: (string|null);
}

/** Represents a ResourceDescriptor. */
Expand All @@ -6797,6 +6818,12 @@ export namespace google {
/** ResourceDescriptor history. */
public history: google.api.ResourceDescriptor.History;

/** ResourceDescriptor plural. */
public plural: string;

/** ResourceDescriptor singular. */
public singular: string;

/**
* Creates a new ResourceDescriptor instance using the specified properties.
* @param [properties] Properties to set
Expand Down Expand Up @@ -8533,6 +8560,9 @@ export namespace google {

/** FileOptions uninterpretedOption */
uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null);

/** FileOptions .google.api.resourceDefinition */
".google.api.resourceDefinition"?: (google.api.IResourceDescriptor[]|null);
}

/** Represents a FileOptions. */
Expand Down
104 changes: 103 additions & 1 deletion protos/protos.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */

Expand Down Expand Up @@ -16442,6 +16456,8 @@
* @property {Array.<string>|null} [pattern] ResourceDescriptor pattern
* @property {string|null} [nameField] ResourceDescriptor nameField
* @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history
* @property {string|null} [plural] ResourceDescriptor plural
* @property {string|null} [singular] ResourceDescriptor singular
*/

/**
Expand Down Expand Up @@ -16492,6 +16508,22 @@
*/
ResourceDescriptor.prototype.history = 0;

/**
* ResourceDescriptor plural.
* @member {string} plural
* @memberof google.api.ResourceDescriptor
* @instance
*/
ResourceDescriptor.prototype.plural = "";

/**
* ResourceDescriptor singular.
* @member {string} singular
* @memberof google.api.ResourceDescriptor
* @instance
*/
ResourceDescriptor.prototype.singular = "";

/**
* Creates a new ResourceDescriptor instance using the specified properties.
* @function create
Expand Down Expand Up @@ -16525,6 +16557,10 @@
writer.uint32(/* id 3, wireType 2 =*/26).string(message.nameField);
if (message.history != null && message.hasOwnProperty("history"))
writer.uint32(/* id 4, wireType 0 =*/32).int32(message.history);
if (message.plural != null && message.hasOwnProperty("plural"))
writer.uint32(/* id 5, wireType 2 =*/42).string(message.plural);
if (message.singular != null && message.hasOwnProperty("singular"))
writer.uint32(/* id 6, wireType 2 =*/50).string(message.singular);
return writer;
};

Expand Down Expand Up @@ -16573,6 +16609,12 @@
case 4:
message.history = reader.int32();
break;
case 5:
message.plural = reader.string();
break;
case 6:
message.singular = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -16630,6 +16672,12 @@
case 2:
break;
}
if (message.plural != null && message.hasOwnProperty("plural"))
if (!$util.isString(message.plural))
return "plural: string expected";
if (message.singular != null && message.hasOwnProperty("singular"))
if (!$util.isString(message.singular))
return "singular: string expected";
return null;
};

Expand Down Expand Up @@ -16670,6 +16718,10 @@
message.history = 2;
break;
}
if (object.plural != null)
message.plural = String(object.plural);
if (object.singular != null)
message.singular = String(object.singular);
return message;
};

Expand All @@ -16692,6 +16744,8 @@
object.type = "";
object.nameField = "";
object.history = options.enums === String ? "HISTORY_UNSPECIFIED" : 0;
object.plural = "";
object.singular = "";
}
if (message.type != null && message.hasOwnProperty("type"))
object.type = message.type;
Expand All @@ -16704,6 +16758,10 @@
object.nameField = message.nameField;
if (message.history != null && message.hasOwnProperty("history"))
object.history = options.enums === String ? $root.google.api.ResourceDescriptor.History[message.history] : message.history;
if (message.plural != null && message.hasOwnProperty("plural"))
object.plural = message.plural;
if (message.singular != null && message.hasOwnProperty("singular"))
object.singular = message.singular;
return object;
};

Expand Down Expand Up @@ -21118,6 +21176,7 @@
* @property {string|null} [phpMetadataNamespace] FileOptions phpMetadataNamespace
* @property {string|null} [rubyPackage] FileOptions rubyPackage
* @property {Array.<google.protobuf.IUninterpretedOption>|null} [uninterpretedOption] FileOptions uninterpretedOption
* @property {Array.<google.api.IResourceDescriptor>|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition
*/

/**
Expand All @@ -21130,6 +21189,7 @@
*/
function FileOptions(properties) {
this.uninterpretedOption = [];
this[".google.api.resourceDefinition"] = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
Expand Down Expand Up @@ -21304,6 +21364,14 @@
*/
FileOptions.prototype.uninterpretedOption = $util.emptyArray;

/**
* FileOptions .google.api.resourceDefinition.
* @member {Array.<google.api.IResourceDescriptor>} .google.api.resourceDefinition
* @memberof google.protobuf.FileOptions
* @instance
*/
FileOptions.prototype[".google.api.resourceDefinition"] = $util.emptyArray;

/**
* Creates a new FileOptions instance using the specified properties.
* @function create
Expand Down Expand Up @@ -21371,6 +21439,9 @@
if (message.uninterpretedOption != null && message.uninterpretedOption.length)
for (var i = 0; i < message.uninterpretedOption.length; ++i)
$root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim();
if (message[".google.api.resourceDefinition"] != null && message[".google.api.resourceDefinition"].length)
for (var i = 0; i < message[".google.api.resourceDefinition"].length; ++i)
$root.google.api.ResourceDescriptor.encode(message[".google.api.resourceDefinition"][i], writer.uint32(/* id 1053, wireType 2 =*/8426).fork()).ldelim();
return writer;
};

Expand Down Expand Up @@ -21470,6 +21541,11 @@
message.uninterpretedOption = [];
message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32()));
break;
case 1053:
if (!(message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length))
message[".google.api.resourceDefinition"] = [];
message[".google.api.resourceDefinition"].push($root.google.api.ResourceDescriptor.decode(reader, reader.uint32()));
break;
default:
reader.skipType(tag & 7);
break;
Expand Down Expand Up @@ -21580,6 +21656,15 @@
return "uninterpretedOption." + error;
}
}
if (message[".google.api.resourceDefinition"] != null && message.hasOwnProperty(".google.api.resourceDefinition")) {
if (!Array.isArray(message[".google.api.resourceDefinition"]))
return ".google.api.resourceDefinition: array expected";
for (var i = 0; i < message[".google.api.resourceDefinition"].length; ++i) {
var error = $root.google.api.ResourceDescriptor.verify(message[".google.api.resourceDefinition"][i]);
if (error)
return ".google.api.resourceDefinition." + error;
}
}
return null;
};

Expand Down Expand Up @@ -21657,6 +21742,16 @@
message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]);
}
}
if (object[".google.api.resourceDefinition"]) {
if (!Array.isArray(object[".google.api.resourceDefinition"]))
throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: array expected");
message[".google.api.resourceDefinition"] = [];
for (var i = 0; i < object[".google.api.resourceDefinition"].length; ++i) {
if (typeof object[".google.api.resourceDefinition"][i] !== "object")
throw TypeError(".google.protobuf.FileOptions..google.api.resourceDefinition: object expected");
message[".google.api.resourceDefinition"][i] = $root.google.api.ResourceDescriptor.fromObject(object[".google.api.resourceDefinition"][i]);
}
}
return message;
};

Expand All @@ -21673,8 +21768,10 @@
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
if (options.arrays || options.defaults) {
object.uninterpretedOption = [];
object[".google.api.resourceDefinition"] = [];
}
if (options.defaults) {
object.javaPackage = "";
object.javaOuterClassname = "";
Expand Down Expand Up @@ -21742,6 +21839,11 @@
for (var j = 0; j < message.uninterpretedOption.length; ++j)
object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options);
}
if (message[".google.api.resourceDefinition"] && message[".google.api.resourceDefinition"].length) {
object[".google.api.resourceDefinition"] = [];
for (var j = 0; j < message[".google.api.resourceDefinition"].length; ++j)
object[".google.api.resourceDefinition"][j] = $root.google.api.ResourceDescriptor.toObject(message[".google.api.resourceDefinition"][j], options);
}
return object;
};

Expand Down
Loading

0 comments on commit 0a88c63

Please sign in to comment.