Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Proto columns #1991

Merged
merged 19 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"ycsb": "node ./benchmark/ycsb.js run -P ./benchmark/workloada -p table=usertable -p cloudspanner.instance=ycsb-instance -p operationcount=100 -p cloudspanner.database=ycsb",
"fix": "gts fix",
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build",
"compile": "tsc -p . && cp -r protos build && cp -r test/data build/test",
"prepare": "npm run compile-protos && npm run compile",
"pretest": "npm run compile",
"presystem-test": "npm run compile",
Expand Down
7 changes: 5 additions & 2 deletions samples/database-get-ddl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function main(instanceId, databaseId, projectId) {

async function getDatabaseDdl() {
// Get the schema definition of the database.
const [ddlStatements] = await databaseAdminClient.getDatabaseDdl({
const [getDatabaseDdlResponse] = await databaseAdminClient.getDatabaseDdl({
database: databaseAdminClient.databasePath(
projectId,
instanceId,
Expand All @@ -55,7 +55,10 @@ function main(instanceId, databaseId, projectId) {
databaseId
)}:`
);
ddlStatements.statements.forEach(element => {
console.log(
harshachinta marked this conversation as resolved.
Show resolved Hide resolved
`Proto Descriptors: ${getDatabaseDdlResponse.protoDescriptors}`
);
getDatabaseDdlResponse.statements.forEach(element => {
console.log(element);
});
}
Expand Down
3 changes: 2 additions & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"@google-cloud/kms": "^4.0.0",
"@google-cloud/precise-date": "^4.0.0",
"@google-cloud/spanner": "^7.7.0",
"yargs": "^17.0.0"
"yargs": "^17.0.0",
"protobufjs": "^7.0.0"
},
"devDependencies": {
"chai": "^4.2.0",
Expand Down
Binary file added samples/resource/descriptors.pb
Binary file not shown.
163 changes: 163 additions & 0 deletions samples/resource/singer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
// Copyright 2024 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 $protobuf from 'protobufjs';
import Long = require('long');
/** Namespace spanner. */
export namespace spanner {
/** Namespace examples. */
namespace examples {
/** Namespace music. */
namespace music {
/** Properties of a SingerInfo. */
interface ISingerInfo {
/** SingerInfo singerId */
singerId?: number | Long | null;

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

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

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

/** Represents a SingerInfo. */
class SingerInfo implements ISingerInfo {

Check warning on line 39 in samples/resource/singer.d.ts

View workflow job for this annotation

GitHub Actions / lint

'SingerInfo' is defined but never used
/**
* Constructs a new SingerInfo.
* @param [properties] Properties to set
*/
constructor(properties?: spanner.examples.music.ISingerInfo);

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

/** SingerInfo birthDate. */
public birthDate: string;

/** SingerInfo nationality. */
public nationality: string;

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

/**
* Creates a new SingerInfo instance using the specified properties.
* @param [properties] Properties to set
* @returns SingerInfo instance
*/
public static create(
properties?: spanner.examples.music.ISingerInfo
): spanner.examples.music.SingerInfo;

/**
* Encodes the specified SingerInfo message. Does not implicitly {@link spanner.examples.music.SingerInfo.verify|verify} messages.
* @param message SingerInfo message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encode(
message: spanner.examples.music.ISingerInfo,
writer?: $protobuf.Writer
): $protobuf.Writer;

/**
* Encodes the specified SingerInfo message, length delimited. Does not implicitly {@link spanner.examples.music.SingerInfo.verify|verify} messages.
* @param message SingerInfo message or plain object to encode
* @param [writer] Writer to encode to
* @returns Writer
*/
public static encodeDelimited(
message: spanner.examples.music.ISingerInfo,
writer?: $protobuf.Writer
): $protobuf.Writer;

/**
* Decodes a SingerInfo message from the specified reader or buffer.
* @param reader Reader or buffer to decode from
* @param [length] Message length if known beforehand
* @returns SingerInfo
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decode(
reader: $protobuf.Reader | Uint8Array,
length?: number
): spanner.examples.music.SingerInfo;

/**
* Decodes a SingerInfo message from the specified reader or buffer, length delimited.
* @param reader Reader or buffer to decode from
* @returns SingerInfo
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
public static decodeDelimited(
reader: $protobuf.Reader | Uint8Array
): spanner.examples.music.SingerInfo;

/**
* Verifies a SingerInfo message.
* @param message Plain object to verify
* @returns `null` if valid, otherwise the reason why it is not
*/
public static verify(message: {[k: string]: any}): string | null;

Check warning on line 118 in samples/resource/singer.d.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Creates a SingerInfo message from a plain object. Also converts values to their respective internal types.
* @param object Plain object
* @returns SingerInfo
*/
public static fromObject(object: {
[k: string]: any;

Check warning on line 126 in samples/resource/singer.d.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}): spanner.examples.music.SingerInfo;

/**
* Creates a plain object from a SingerInfo message. Also converts values to other types if specified.
* @param message SingerInfo
* @param [options] Conversion options
* @returns Plain object
*/
public static toObject(
message: spanner.examples.music.SingerInfo,
options?: $protobuf.IConversionOptions
): {[k: string]: any};

Check warning on line 138 in samples/resource/singer.d.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Converts this SingerInfo to JSON.
* @returns JSON object
*/
public toJSON(): {[k: string]: any};

Check warning on line 144 in samples/resource/singer.d.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Gets the default type url for SingerInfo
* @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns The default type url
*/
public static getTypeUrl(typeUrlPrefix?: string): string;
}

/** Genre enum. */
enum Genre {

Check warning on line 155 in samples/resource/singer.d.ts

View workflow job for this annotation

GitHub Actions / lint

'Genre' is defined but never used
POP = 0,
JAZZ = 1,
FOLK = 2,
ROCK = 3,
}
}
}
}
Loading
Loading