Skip to content

Commit

Permalink
chore(spanner): regenerate proto files (#2050)
Browse files Browse the repository at this point in the history
* chore(spanner): regenerate proto files

* chore(spanner): regenerate proto files

* feat(spanner): ignore lint on generated proto files

* chore(spanner): add README files

* chore(spanner): fix lint

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
harshachinta and gcf-owl-bot[bot] authored May 22, 2024
1 parent f31d7b2 commit 628f4b0
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 74 deletions.
8 changes: 8 additions & 0 deletions samples/resource/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#### To generate singer.js and singer.d.ts file from singer.proto
```shell
npm install -g protobufjs-cli
cd samples/resource
pbjs -t static-module -w commonjs -o singer.js singer.proto
pbts -o singer.d.ts singer.js
protoc --proto_path=. --include_imports --descriptor_set_out=descriptors.pb singer.proto
```
Binary file modified samples/resource/descriptors.pb
Binary file not shown.
20 changes: 16 additions & 4 deletions samples/resource/singer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,28 @@ export namespace examples {
constructor(properties?: examples.spanner.music.ISingerInfo);

/** SingerInfo singerId. */
public singerId: number | Long;
public singerId?: number | Long | null;

/** SingerInfo birthDate. */
public birthDate: string;
public birthDate?: string | null;

/** SingerInfo nationality. */
public nationality: string;
public nationality?: string | null;

/** SingerInfo genre. */
public genre: examples.spanner.music.Genre;
public genre?: examples.spanner.music.Genre | null;

/** SingerInfo _singerId. */
public _singerId?: 'singerId';

/** SingerInfo _birthDate. */
public _birthDate?: 'birthDate';

/** SingerInfo _nationality. */
public _nationality?: 'nationality';

/** SingerInfo _genre. */
public _genre?: 'genre';

/**
* Creates a new SingerInfo instance using the specified properties.
Expand Down
118 changes: 86 additions & 32 deletions samples/resource/singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,37 +81,82 @@ $root.examples = (function () {

/**
* SingerInfo singerId.
* @member {number|Long} singerId
* @member {number|Long|null|undefined} singerId
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
SingerInfo.prototype.singerId = $util.Long
? $util.Long.fromBits(0, 0, false)
: 0;
SingerInfo.prototype.singerId = null;

/**
* SingerInfo birthDate.
* @member {string} birthDate
* @member {string|null|undefined} birthDate
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
SingerInfo.prototype.birthDate = '';
SingerInfo.prototype.birthDate = null;

/**
* SingerInfo nationality.
* @member {string} nationality
* @member {string|null|undefined} nationality
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
SingerInfo.prototype.nationality = '';
SingerInfo.prototype.nationality = null;

/**
* SingerInfo genre.
* @member {examples.spanner.music.Genre} genre
* @member {examples.spanner.music.Genre|null|undefined} genre
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
SingerInfo.prototype.genre = 0;
SingerInfo.prototype.genre = null;

// OneOf field names bound to virtual getters and setters
var $oneOfFields;

/**
* SingerInfo _singerId.
* @member {"singerId"|undefined} _singerId
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
Object.defineProperty(SingerInfo.prototype, '_singerId', {
get: $util.oneOfGetter(($oneOfFields = ['singerId'])),
set: $util.oneOfSetter($oneOfFields),
});

/**
* SingerInfo _birthDate.
* @member {"birthDate"|undefined} _birthDate
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
Object.defineProperty(SingerInfo.prototype, '_birthDate', {
get: $util.oneOfGetter(($oneOfFields = ['birthDate'])),
set: $util.oneOfSetter($oneOfFields),
});

/**
* SingerInfo _nationality.
* @member {"nationality"|undefined} _nationality
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
Object.defineProperty(SingerInfo.prototype, '_nationality', {
get: $util.oneOfGetter(($oneOfFields = ['nationality'])),
set: $util.oneOfSetter($oneOfFields),
});

/**
* SingerInfo _genre.
* @member {"genre"|undefined} _genre
* @memberof examples.spanner.music.SingerInfo
* @instance
*/
Object.defineProperty(SingerInfo.prototype, '_genre', {
get: $util.oneOfGetter(($oneOfFields = ['genre'])),
set: $util.oneOfSetter($oneOfFields),
});

/**
* Creates a new SingerInfo instance using the specified properties.
Expand Down Expand Up @@ -242,7 +287,9 @@ $root.examples = (function () {
SingerInfo.verify = function verify(message) {
if (typeof message !== 'object' || message === null)
return 'object expected';
if (message.singerId !== null && message.hasOwnProperty('singerId'))
var properties = {};
if (message.singerId !== null && message.hasOwnProperty('singerId')) {
properties._singerId = 1;
if (
!$util.isInteger(message.singerId) &&
!(
Expand All @@ -252,16 +299,25 @@ $root.examples = (function () {
)
)
return 'singerId: integer|Long expected';
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
}
if (
message.birthDate !== null &&
message.hasOwnProperty('birthDate')
) {
properties._birthDate = 1;
if (!$util.isString(message.birthDate))
return 'birthDate: string expected';
}
if (
message.nationality !== null &&
message.hasOwnProperty('nationality')
)
) {
properties._nationality = 1;
if (!$util.isString(message.nationality))
return 'nationality: string expected';
if (message.genre !== null && message.hasOwnProperty('genre'))
}
if (message.genre !== null && message.hasOwnProperty('genre')) {
properties._genre = 1;
switch (message.genre) {
default:
return 'genre: enum value expected';
Expand All @@ -271,6 +327,7 @@ $root.examples = (function () {
case 3:
break;
}
}
return null;
};

Expand Down Expand Up @@ -343,21 +400,7 @@ $root.examples = (function () {
SingerInfo.toObject = function toObject(message, options) {
if (!options) options = {};
var object = {};
if (options.defaults) {
if ($util.Long) {
var long = new $util.Long(0, 0, false);
object.singerId =
options.longs === String
? long.toString()
: options.longs === Number
? long.toNumber()
: long;
} else object.singerId = options.longs === String ? '0' : 0;
object.birthDate = '';
object.nationality = '';
object.genre = options.enums === String ? 'POP' : 0;
}
if (message.singerId !== null && message.hasOwnProperty('singerId'))
if (message.singerId !== null && message.hasOwnProperty('singerId')) {
if (typeof message.singerId === 'number')
object.singerId =
options.longs === String
Expand All @@ -373,21 +416,32 @@ $root.examples = (function () {
message.singerId.high >>> 0
).toNumber()
: message.singerId;
if (message.birthDate !== null && message.hasOwnProperty('birthDate'))
if (options.oneofs) object._singerId = 'singerId';
}
if (
message.birthDate !== null &&
message.hasOwnProperty('birthDate')
) {
object.birthDate = message.birthDate;
if (options.oneofs) object._birthDate = 'birthDate';
}
if (
message.nationality !== null &&
message.hasOwnProperty('nationality')
)
) {
object.nationality = message.nationality;
if (message.genre !== null && message.hasOwnProperty('genre'))
if (options.oneofs) object._nationality = 'nationality';
}
if (message.genre !== null && message.hasOwnProperty('genre')) {
object.genre =
options.enums === String
? $root.examples.spanner.music.Genre[message.genre] ===
undefined
? message.genre
: $root.examples.spanner.music.Genre[message.genre]
: message.genre;
if (options.oneofs) object._genre = 'genre';
}
return object;
};

Expand Down
2 changes: 1 addition & 1 deletion samples/resource/singer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto2";
syntax = "proto3";

package examples.spanner.music;

Expand Down
8 changes: 8 additions & 0 deletions test/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#### To generate singer.js and singer.d.ts file from singer.proto
```shell
npm install -g protobufjs-cli
cd test/data
pbjs -t static-module -w commonjs -o singer.js singer.proto
pbts -o singer.d.ts singer.js
protoc --proto_path=. --include_imports --descriptor_set_out=descriptors.pb singer.proto
```
Binary file modified test/data/descriptors.pb
Binary file not shown.
20 changes: 16 additions & 4 deletions test/data/singer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,28 @@ export namespace examples {
constructor(properties?: examples.spanner.music.ISingerInfo);

/** SingerInfo singerId. */
public singerId: number | Long;
public singerId?: number | Long | null;

/** SingerInfo birthDate. */
public birthDate: string;
public birthDate?: string | null;

/** SingerInfo nationality. */
public nationality: string;
public nationality?: string | null;

/** SingerInfo genre. */
public genre: examples.spanner.music.Genre;
public genre?: examples.spanner.music.Genre | null;

/** SingerInfo _singerId. */
public _singerId?: 'singerId';

/** SingerInfo _birthDate. */
public _birthDate?: 'birthDate';

/** SingerInfo _nationality. */
public _nationality?: 'nationality';

/** SingerInfo _genre. */
public _genre?: 'genre';

/**
* Creates a new SingerInfo instance using the specified properties.
Expand Down
Loading

0 comments on commit 628f4b0

Please sign in to comment.