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

fix: Generate JavaScript Code from plugin-pb #66

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions protos/plugin/v3/plugin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ service Plugin {
rpc Write(stream Write.Request) returns (Write.Response);
// Transform resources.
rpc Transform(stream Transform.Request) returns (stream Transform.Response);
// Transform schemas.
rpc TransformSchema(stream TransformSchema.Request) returns (stream TransformSchema.Response);
// Send signal to flush and close open connections
rpc Close(Close.Request) returns (Close.Response);
// Validate and test the connections used by the plugin
Expand Down Expand Up @@ -203,6 +205,17 @@ message Transform {
}
}

message TransformSchema {
message Request {
// marshalled arrow.Schema
bytes schema = 1;
}
message Response {
// marshalled arrow.Schema
bytes schema = 1;
}
}

message Close {
message Request {}
message Response {}
Expand Down
189 changes: 189 additions & 0 deletions protos/plugin/v3/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2890,6 +2890,182 @@ export namespace cloudquery.plugin.v3 {
}
}
}
export class TransformSchema extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") { }
}
static fromObject(data: {}): TransformSchema {
const message = new TransformSchema({});
return message;
}
toObject() {
const data: {} = {};
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TransformSchema {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TransformSchema();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): TransformSchema {
return TransformSchema.deserialize(bytes);
}
}
export namespace TransformSchema {
export class Request extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
schema?: Uint8Array;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("schema" in data && data.schema != undefined) {
this.schema = data.schema;
}
}
}
get schema() {
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
}
set schema(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
schema?: Uint8Array;
}): Request {
const message = new Request({});
if (data.schema != null) {
message.schema = data.schema;
}
return message;
}
toObject() {
const data: {
schema?: Uint8Array;
} = {};
if (this.schema != null) {
data.schema = this.schema;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.schema.length)
writer.writeBytes(1, this.schema);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Request {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Request();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.schema = reader.readBytes();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Request {
return Request.deserialize(bytes);
}
}
export class Response extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
schema?: Uint8Array;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("schema" in data && data.schema != undefined) {
this.schema = data.schema;
}
}
}
get schema() {
return pb_1.Message.getFieldWithDefault(this, 1, new Uint8Array(0)) as Uint8Array;
}
set schema(value: Uint8Array) {
pb_1.Message.setField(this, 1, value);
}
static fromObject(data: {
schema?: Uint8Array;
}): Response {
const message = new Response({});
if (data.schema != null) {
message.schema = data.schema;
}
return message;
}
toObject() {
const data: {
schema?: Uint8Array;
} = {};
if (this.schema != null) {
data.schema = this.schema;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.schema.length)
writer.writeBytes(1, this.schema);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Response {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Response();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.schema = reader.readBytes();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): Response {
return Response.deserialize(bytes);
}
}
}
export class Close extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {}) {
Expand Down Expand Up @@ -3341,6 +3517,15 @@ export namespace cloudquery.plugin.v3 {
responseSerialize: (message: Transform.Response) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => Transform.Response.deserialize(new Uint8Array(bytes))
},
TransformSchema: {
path: "/cloudquery.plugin.v3.Plugin/TransformSchema",
requestStream: true,
responseStream: true,
requestSerialize: (message: TransformSchema.Request) => Buffer.from(message.serialize()),
requestDeserialize: (bytes: Buffer) => TransformSchema.Request.deserialize(new Uint8Array(bytes)),
responseSerialize: (message: TransformSchema.Response) => Buffer.from(message.serialize()),
responseDeserialize: (bytes: Buffer) => TransformSchema.Response.deserialize(new Uint8Array(bytes))
},
Close: {
path: "/cloudquery.plugin.v3.Plugin/Close",
requestStream: false,
Expand Down Expand Up @@ -3370,6 +3555,7 @@ export namespace cloudquery.plugin.v3 {
abstract Read(call: grpc_1.ServerWritableStream<Read.Request, Read.Response>): void;
abstract Write(call: grpc_1.ServerReadableStream<Write.Request, Write.Response>, callback: grpc_1.sendUnaryData<Write.Response>): void;
abstract Transform(call: grpc_1.ServerDuplexStream<Transform.Request, Transform.Response>): void;
abstract TransformSchema(call: grpc_1.ServerDuplexStream<TransformSchema.Request, TransformSchema.Response>): void;
abstract Close(call: grpc_1.ServerUnaryCall<Close.Request, Close.Response>, callback: grpc_1.sendUnaryData<Close.Response>): void;
abstract TestConnection(call: grpc_1.ServerUnaryCall<TestConnection.Request, TestConnection.Response>, callback: grpc_1.sendUnaryData<TestConnection.Response>): void;
}
Expand Down Expand Up @@ -3404,6 +3590,9 @@ export namespace cloudquery.plugin.v3 {
Transform: GrpcChunkServiceInterface<Transform.Request, Transform.Response> = (metadata?: grpc_1.Metadata | grpc_1.CallOptions, options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream<Transform.Request, Transform.Response> => {
return super.Transform(metadata, options);
};
TransformSchema: GrpcChunkServiceInterface<TransformSchema.Request, TransformSchema.Response> = (metadata?: grpc_1.Metadata | grpc_1.CallOptions, options?: grpc_1.CallOptions): grpc_1.ClientDuplexStream<TransformSchema.Request, TransformSchema.Response> => {
return super.TransformSchema(metadata, options);
};
Close: GrpcUnaryServiceInterface<Close.Request, Close.Response> = (message: Close.Request, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Close.Response>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Close.Response>, callback?: grpc_1.requestCallback<Close.Response>): grpc_1.ClientUnaryCall => {
return super.Close(message, metadata, options, callback);
};
Expand Down