diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3d824fd --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +/src/gen/plugin/codegen_pb.ts linguist-generated=true diff --git a/Makefile b/Makefile index 728685e..5bbe894 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ out.js: src/app.ts $(wildcard src/drivers/*.ts) src/gen/plugin/codegen_pb.ts nod npx esbuild --bundle src/app.ts --tree-shaking=true --format=esm --target=es2020 --outfile=out.js src/gen/plugin/codegen_pb.ts: buf.gen.yaml - buf generate --template buf.gen.yaml buf.build/sqlc/sqlc --path plugin/ + npx @bufbuild/buf generate --template buf.gen.yaml buf.build/sqlc/sqlc --path plugin/ node_modules: package.json package-lock.json npm install diff --git a/buf.gen.yaml b/buf.gen.yaml index 3da6894..3c30aba 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,5 +1,5 @@ version: v1 plugins: - - plugin: buf.build/bufbuild/es:v1.4.2 + - plugin: buf.build/bufbuild/es:v2.11.0 opt: target=ts out: src/gen \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ad8b872..a1e27cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.7", "license": "ISC", "dependencies": { - "@bufbuild/protobuf": "^1.4.2", + "@bufbuild/protobuf": "^2.11.0", "javy": "^0.1.2", "pg": "^8.11.3" }, @@ -19,9 +19,10 @@ } }, "node_modules/@bufbuild/protobuf": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.4.2.tgz", - "integrity": "sha512-JyEH8Z+OD5Sc2opSg86qMHn1EM1Sa+zj/Tc0ovxdwk56ByVNONJSabuCUbLQp+eKN3rWNfrho0X+3SEqEPXIow==" + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-2.11.0.tgz", + "integrity": "sha512-sBXGT13cpmPR5BMgHE6UEEfEaShh5Ror6rfN3yEK5si7QVrtZg8LEPQb0VVhiLRUslD2yLnXtnRzG035J/mZXQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)" }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.3", diff --git a/package.json b/package.json index 6fe3168..197e731 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@bufbuild/protobuf": "^1.4.2", + "@bufbuild/protobuf": "^2.11.0", "javy": "^0.1.2", "pg": "^8.11.3" } diff --git a/src/app.ts b/src/app.ts index e3a077c..4279d16 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,12 +18,16 @@ import { factory, } from "typescript"; +import { create, fromBinary, toBinary } from "@bufbuild/protobuf"; import { GenerateRequest, + GenerateRequestSchema, GenerateResponse, + GenerateResponseSchema, Parameter, Column, File, + FileSchema, Query, } from "./gen/plugin/codegen_pb"; @@ -200,7 +204,7 @@ ${query.text}` } if (nodes) { files.push( - new File({ + create(FileSchema, { name: `${filename.replace(".", "_")}.ts`, contents: new TextEncoder().encode(printNode(nodes)), }) @@ -209,7 +213,7 @@ ${query.text}` } } - return new GenerateResponse({ + return create(GenerateResponseSchema, { files: files, }); } @@ -217,7 +221,7 @@ ${query.text}` // Read input from stdin function readInput(): GenerateRequest { const buffer = readFileSync(STDIO.Stdin); - return GenerateRequest.fromBinary(buffer); + return fromBinary(GenerateRequestSchema, buffer); } function queryDecl(name: string, sql: string) { @@ -299,7 +303,6 @@ function printNode(nodes: Node[]): string { // Write output to stdout function writeOutput(output: GenerateResponse) { - const encodedOutput = output.toBinary(); - const buffer = new Uint8Array(encodedOutput); + const buffer = toBinary(GenerateResponseSchema, output); writeFileSync(STDIO.Stdout, buffer); } diff --git a/src/gen/plugin/codegen_pb.ts b/src/gen/plugin/codegen_pb.ts index c82b4cf..17e5af0 100644 --- a/src/gen/plugin/codegen_pb.ts +++ b/src/gen/plugin/codegen_pb.ts @@ -1,138 +1,99 @@ -// @generated by protoc-gen-es v1.4.2 with parameter "target=ts" +// @generated by protoc-gen-es v2.11.0 with parameter "target=ts" // @generated from file plugin/codegen.proto (package plugin, syntax proto3) /* eslint-disable */ -// @ts-nocheck -import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; -import { Message, proto3 } from "@bufbuild/protobuf"; +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv2"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file plugin/codegen.proto. + */ +export const file_plugin_codegen: GenFile = /*@__PURE__*/ + fileDesc("ChRwbHVnaW4vY29kZWdlbi5wcm90bxIGcGx1Z2luIiYKBEZpbGUSDAoEbmFtZRgBIAEoCRIQCghjb250ZW50cxgCIAEoDCKMAQoIU2V0dGluZ3MSDwoHdmVyc2lvbhgBIAEoCRIOCgZlbmdpbmUYAiABKAkSDgoGc2NoZW1hGAMgAygJEg8KB3F1ZXJpZXMYBCADKAkSIAoHY29kZWdlbhgMIAEoCzIPLnBsdWdpbi5Db2RlZ2VuSgQIBRAGSgQICBAJSgQICRAKSgQIChALSgQICxAMIs8BCgdDb2RlZ2VuEgsKA291dBgBIAEoCRIOCgZwbHVnaW4YAiABKAkSDwoHb3B0aW9ucxgDIAEoDBILCgNlbnYYBCADKAkSKAoHcHJvY2VzcxgFIAEoCzIXLnBsdWdpbi5Db2RlZ2VuLlByb2Nlc3MSIgoEd2FzbRgGIAEoCzIULnBsdWdpbi5Db2RlZ2VuLldBU00aFgoHUHJvY2VzcxILCgNjbWQYASABKAkaIwoEV0FTTRILCgN1cmwYASABKAkSDgoGc2hhMjU2GAIgASgJImEKB0NhdGFsb2cSDwoHY29tbWVudBgBIAEoCRIWCg5kZWZhdWx0X3NjaGVtYRgCIAEoCRIMCgRuYW1lGAMgASgJEh8KB3NjaGVtYXMYBCADKAsyDi5wbHVnaW4uU2NoZW1hIpMBCgZTY2hlbWESDwoHY29tbWVudBgBIAEoCRIMCgRuYW1lGAIgASgJEh0KBnRhYmxlcxgDIAMoCzINLnBsdWdpbi5UYWJsZRIbCgVlbnVtcxgEIAMoCzIMLnBsdWdpbi5FbnVtEi4KD2NvbXBvc2l0ZV90eXBlcxgFIAMoCzIVLnBsdWdpbi5Db21wb3NpdGVUeXBlIi4KDUNvbXBvc2l0ZVR5cGUSDAoEbmFtZRgBIAEoCRIPCgdjb21tZW50GAIgASgJIjMKBEVudW0SDAoEbmFtZRgBIAEoCRIMCgR2YWxzGAIgAygJEg8KB2NvbW1lbnQYAyABKAkiWgoFVGFibGUSHwoDcmVsGAEgASgLMhIucGx1Z2luLklkZW50aWZpZXISHwoHY29sdW1ucxgCIAMoCzIOLnBsdWdpbi5Db2x1bW4SDwoHY29tbWVudBgDIAEoCSI7CgpJZGVudGlmaWVyEg8KB2NhdGFsb2cYASABKAkSDgoGc2NoZW1hGAIgASgJEgwKBG5hbWUYAyABKAki7wIKBkNvbHVtbhIMCgRuYW1lGAEgASgJEhAKCG5vdF9udWxsGAMgASgIEhAKCGlzX2FycmF5GAQgASgIEg8KB2NvbW1lbnQYBSABKAkSDgoGbGVuZ3RoGAYgASgFEhYKDmlzX25hbWVkX3BhcmFtGAcgASgIEhQKDGlzX2Z1bmNfY2FsbBgIIAEoCBINCgVzY29wZRgJIAEoCRIhCgV0YWJsZRgKIAEoCzISLnBsdWdpbi5JZGVudGlmaWVyEhMKC3RhYmxlX2FsaWFzGAsgASgJEiAKBHR5cGUYDCABKAsyEi5wbHVnaW4uSWRlbnRpZmllchIVCg1pc19zcWxjX3NsaWNlGA0gASgIEicKC2VtYmVkX3RhYmxlGA4gASgLMhIucGx1Z2luLklkZW50aWZpZXISFQoNb3JpZ2luYWxfbmFtZRgPIAEoCRIQCgh1bnNpZ25lZBgQIAEoCBISCgphcnJheV9kaW1zGBEgASgFIuYBCgVRdWVyeRIMCgR0ZXh0GAEgASgJEgwKBG5hbWUYAiABKAkSCwoDY21kGAMgASgJEh8KB2NvbHVtbnMYBCADKAsyDi5wbHVnaW4uQ29sdW1uEi0KBnBhcmFtcxgFIAMoCzIRLnBsdWdpbi5QYXJhbWV0ZXJSCnBhcmFtZXRlcnMSEAoIY29tbWVudHMYBiADKAkSEAoIZmlsZW5hbWUYByABKAkSQAoRaW5zZXJ0X2ludG9fdGFibGUYCCABKAsyEi5wbHVnaW4uSWRlbnRpZmllclIRaW5zZXJ0X2ludG9fdGFibGUiOwoJUGFyYW1ldGVyEg4KBm51bWJlchgBIAEoBRIeCgZjb2x1bW4YAiABKAsyDi5wbHVnaW4uQ29sdW1uIusBCg9HZW5lcmF0ZVJlcXVlc3QSIgoIc2V0dGluZ3MYASABKAsyEC5wbHVnaW4uU2V0dGluZ3MSIAoHY2F0YWxvZxgCIAEoCzIPLnBsdWdpbi5DYXRhbG9nEh4KB3F1ZXJpZXMYAyADKAsyDS5wbHVnaW4uUXVlcnkSIgoMc3FsY192ZXJzaW9uGAQgASgJUgxzcWxjX3ZlcnNpb24SJgoOcGx1Z2luX29wdGlvbnMYBSABKAxSDnBsdWdpbl9vcHRpb25zEiYKDmdsb2JhbF9vcHRpb25zGAYgASgMUg5nbG9iYWxfb3B0aW9ucyIvChBHZW5lcmF0ZVJlc3BvbnNlEhsKBWZpbGVzGAEgAygLMgwucGx1Z2luLkZpbGUyTwoOQ29kZWdlblNlcnZpY2USPQoIR2VuZXJhdGUSFy5wbHVnaW4uR2VuZXJhdGVSZXF1ZXN0GhgucGx1Z2luLkdlbmVyYXRlUmVzcG9uc2VCKlooZ2l0aHViLmNvbS9zcWxjLWRldi9zcWxjL2ludGVybmFsL3BsdWdpbmIGcHJvdG8z"); /** * @generated from message plugin.File */ -export class File extends Message { +export type File = Message<"plugin.File"> & { /** * @generated from field: string name = 1; */ - name = ""; + name: string; /** * @generated from field: bytes contents = 2; */ - contents = new Uint8Array(0); - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.File"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "contents", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): File { - return new File().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): File { - return new File().fromJson(jsonValue, options); - } + contents: Uint8Array; +}; - static fromJsonString(jsonString: string, options?: Partial): File { - return new File().fromJsonString(jsonString, options); - } - - static equals(a: File | PlainMessage | undefined, b: File | PlainMessage | undefined): boolean { - return proto3.util.equals(File, a, b); - } -} +/** + * Describes the message plugin.File. + * Use `create(FileSchema)` to create a new message. + */ +export const FileSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 0); /** * @generated from message plugin.Settings */ -export class Settings extends Message { +export type Settings = Message<"plugin.Settings"> & { /** * @generated from field: string version = 1; */ - version = ""; + version: string; /** * @generated from field: string engine = 2; */ - engine = ""; + engine: string; /** * @generated from field: repeated string schema = 3; */ - schema: string[] = []; + schema: string[]; /** * @generated from field: repeated string queries = 4; */ - queries: string[] = []; + queries: string[]; /** * @generated from field: plugin.Codegen codegen = 12; */ codegen?: Codegen; +}; - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Settings"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "version", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "engine", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "schema", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 4, name: "queries", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 12, name: "codegen", kind: "message", T: Codegen }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Settings { - return new Settings().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Settings { - return new Settings().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Settings { - return new Settings().fromJsonString(jsonString, options); - } - - static equals(a: Settings | PlainMessage | undefined, b: Settings | PlainMessage | undefined): boolean { - return proto3.util.equals(Settings, a, b); - } -} +/** + * Describes the message plugin.Settings. + * Use `create(SettingsSchema)` to create a new message. + */ +export const SettingsSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 1); /** * @generated from message plugin.Codegen */ -export class Codegen extends Message { +export type Codegen = Message<"plugin.Codegen"> & { /** * @generated from field: string out = 1; */ - out = ""; + out: string; /** * @generated from field: string plugin = 2; */ - plugin = ""; + plugin: string; /** * @generated from field: bytes options = 3; */ - options = new Uint8Array(0); + options: Uint8Array; /** * @generated from field: repeated string env = 4; */ - env: string[] = []; + env: string[]; /** * @generated from field: plugin.Codegen.Process process = 5; @@ -143,332 +104,176 @@ export class Codegen extends Message { * @generated from field: plugin.Codegen.WASM wasm = 6; */ wasm?: Codegen_WASM; +}; - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Codegen"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "out", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "plugin", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "options", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - { no: 4, name: "env", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 5, name: "process", kind: "message", T: Codegen_Process }, - { no: 6, name: "wasm", kind: "message", T: Codegen_WASM }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Codegen { - return new Codegen().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Codegen { - return new Codegen().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Codegen { - return new Codegen().fromJsonString(jsonString, options); - } - - static equals(a: Codegen | PlainMessage | undefined, b: Codegen | PlainMessage | undefined): boolean { - return proto3.util.equals(Codegen, a, b); - } -} +/** + * Describes the message plugin.Codegen. + * Use `create(CodegenSchema)` to create a new message. + */ +export const CodegenSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 2); /** * @generated from message plugin.Codegen.Process */ -export class Codegen_Process extends Message { +export type Codegen_Process = Message<"plugin.Codegen.Process"> & { /** * @generated from field: string cmd = 1; */ - cmd = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Codegen.Process"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "cmd", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Codegen_Process { - return new Codegen_Process().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Codegen_Process { - return new Codegen_Process().fromJson(jsonValue, options); - } + cmd: string; +}; - static fromJsonString(jsonString: string, options?: Partial): Codegen_Process { - return new Codegen_Process().fromJsonString(jsonString, options); - } - - static equals(a: Codegen_Process | PlainMessage | undefined, b: Codegen_Process | PlainMessage | undefined): boolean { - return proto3.util.equals(Codegen_Process, a, b); - } -} +/** + * Describes the message plugin.Codegen.Process. + * Use `create(Codegen_ProcessSchema)` to create a new message. + */ +export const Codegen_ProcessSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 2, 0); /** * @generated from message plugin.Codegen.WASM */ -export class Codegen_WASM extends Message { +export type Codegen_WASM = Message<"plugin.Codegen.WASM"> & { /** * @generated from field: string url = 1; */ - url = ""; + url: string; /** * @generated from field: string sha256 = 2; */ - sha256 = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Codegen.WASM"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "url", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "sha256", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Codegen_WASM { - return new Codegen_WASM().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Codegen_WASM { - return new Codegen_WASM().fromJson(jsonValue, options); - } + sha256: string; +}; - static fromJsonString(jsonString: string, options?: Partial): Codegen_WASM { - return new Codegen_WASM().fromJsonString(jsonString, options); - } - - static equals(a: Codegen_WASM | PlainMessage | undefined, b: Codegen_WASM | PlainMessage | undefined): boolean { - return proto3.util.equals(Codegen_WASM, a, b); - } -} +/** + * Describes the message plugin.Codegen.WASM. + * Use `create(Codegen_WASMSchema)` to create a new message. + */ +export const Codegen_WASMSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 2, 1); /** * @generated from message plugin.Catalog */ -export class Catalog extends Message { +export type Catalog = Message<"plugin.Catalog"> & { /** * @generated from field: string comment = 1; */ - comment = ""; + comment: string; /** * @generated from field: string default_schema = 2; */ - defaultSchema = ""; + defaultSchema: string; /** * @generated from field: string name = 3; */ - name = ""; + name: string; /** * @generated from field: repeated plugin.Schema schemas = 4; */ - schemas: Schema[] = []; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Catalog"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "comment", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "default_schema", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 4, name: "schemas", kind: "message", T: Schema, repeated: true }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Catalog { - return new Catalog().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Catalog { - return new Catalog().fromJson(jsonValue, options); - } + schemas: Schema[]; +}; - static fromJsonString(jsonString: string, options?: Partial): Catalog { - return new Catalog().fromJsonString(jsonString, options); - } - - static equals(a: Catalog | PlainMessage | undefined, b: Catalog | PlainMessage | undefined): boolean { - return proto3.util.equals(Catalog, a, b); - } -} +/** + * Describes the message plugin.Catalog. + * Use `create(CatalogSchema)` to create a new message. + */ +export const CatalogSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 3); /** * @generated from message plugin.Schema */ -export class Schema extends Message { +export type Schema = Message<"plugin.Schema"> & { /** * @generated from field: string comment = 1; */ - comment = ""; + comment: string; /** * @generated from field: string name = 2; */ - name = ""; + name: string; /** * @generated from field: repeated plugin.Table tables = 3; */ - tables: Table[] = []; + tables: Table[]; /** * @generated from field: repeated plugin.Enum enums = 4; */ - enums: Enum[] = []; + enums: Enum[]; /** * @generated from field: repeated plugin.CompositeType composite_types = 5; */ - compositeTypes: CompositeType[] = []; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Schema"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "comment", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "tables", kind: "message", T: Table, repeated: true }, - { no: 4, name: "enums", kind: "message", T: Enum, repeated: true }, - { no: 5, name: "composite_types", kind: "message", T: CompositeType, repeated: true }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Schema { - return new Schema().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Schema { - return new Schema().fromJson(jsonValue, options); - } + compositeTypes: CompositeType[]; +}; - static fromJsonString(jsonString: string, options?: Partial): Schema { - return new Schema().fromJsonString(jsonString, options); - } - - static equals(a: Schema | PlainMessage | undefined, b: Schema | PlainMessage | undefined): boolean { - return proto3.util.equals(Schema, a, b); - } -} +/** + * Describes the message plugin.Schema. + * Use `create(SchemaSchema)` to create a new message. + */ +export const SchemaSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 4); /** * @generated from message plugin.CompositeType */ -export class CompositeType extends Message { +export type CompositeType = Message<"plugin.CompositeType"> & { /** * @generated from field: string name = 1; */ - name = ""; + name: string; /** * @generated from field: string comment = 2; */ - comment = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.CompositeType"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "comment", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): CompositeType { - return new CompositeType().fromBinary(bytes, options); - } + comment: string; +}; - static fromJson(jsonValue: JsonValue, options?: Partial): CompositeType { - return new CompositeType().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): CompositeType { - return new CompositeType().fromJsonString(jsonString, options); - } - - static equals(a: CompositeType | PlainMessage | undefined, b: CompositeType | PlainMessage | undefined): boolean { - return proto3.util.equals(CompositeType, a, b); - } -} +/** + * Describes the message plugin.CompositeType. + * Use `create(CompositeTypeSchema)` to create a new message. + */ +export const CompositeTypeSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 5); /** * @generated from message plugin.Enum */ -export class Enum extends Message { +export type Enum = Message<"plugin.Enum"> & { /** * @generated from field: string name = 1; */ - name = ""; + name: string; /** * @generated from field: repeated string vals = 2; */ - vals: string[] = []; + vals: string[]; /** * @generated from field: string comment = 3; */ - comment = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Enum"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "vals", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 3, name: "comment", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Enum { - return new Enum().fromBinary(bytes, options); - } + comment: string; +}; - static fromJson(jsonValue: JsonValue, options?: Partial): Enum { - return new Enum().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Enum { - return new Enum().fromJsonString(jsonString, options); - } - - static equals(a: Enum | PlainMessage | undefined, b: Enum | PlainMessage | undefined): boolean { - return proto3.util.equals(Enum, a, b); - } -} +/** + * Describes the message plugin.Enum. + * Use `create(EnumSchema)` to create a new message. + */ +export const EnumSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 6); /** * @generated from message plugin.Table */ -export class Table extends Message { +export type Table = Message<"plugin.Table"> & { /** * @generated from field: plugin.Identifier rel = 1; */ @@ -477,137 +282,93 @@ export class Table extends Message
{ /** * @generated from field: repeated plugin.Column columns = 2; */ - columns: Column[] = []; + columns: Column[]; /** * @generated from field: string comment = 3; */ - comment = ""; - - constructor(data?: PartialMessage
) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Table"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "rel", kind: "message", T: Identifier }, - { no: 2, name: "columns", kind: "message", T: Column, repeated: true }, - { no: 3, name: "comment", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Table { - return new Table().fromBinary(bytes, options); - } + comment: string; +}; - static fromJson(jsonValue: JsonValue, options?: Partial): Table { - return new Table().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Table { - return new Table().fromJsonString(jsonString, options); - } - - static equals(a: Table | PlainMessage
| undefined, b: Table | PlainMessage
| undefined): boolean { - return proto3.util.equals(Table, a, b); - } -} +/** + * Describes the message plugin.Table. + * Use `create(TableSchema)` to create a new message. + */ +export const TableSchema: GenMessage
= /*@__PURE__*/ + messageDesc(file_plugin_codegen, 7); /** * @generated from message plugin.Identifier */ -export class Identifier extends Message { +export type Identifier = Message<"plugin.Identifier"> & { /** * @generated from field: string catalog = 1; */ - catalog = ""; + catalog: string; /** * @generated from field: string schema = 2; */ - schema = ""; + schema: string; /** * @generated from field: string name = 3; */ - name = ""; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Identifier"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "catalog", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "schema", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Identifier { - return new Identifier().fromBinary(bytes, options); - } + name: string; +}; - static fromJson(jsonValue: JsonValue, options?: Partial): Identifier { - return new Identifier().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Identifier { - return new Identifier().fromJsonString(jsonString, options); - } - - static equals(a: Identifier | PlainMessage | undefined, b: Identifier | PlainMessage | undefined): boolean { - return proto3.util.equals(Identifier, a, b); - } -} +/** + * Describes the message plugin.Identifier. + * Use `create(IdentifierSchema)` to create a new message. + */ +export const IdentifierSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 8); /** * @generated from message plugin.Column */ -export class Column extends Message { +export type Column = Message<"plugin.Column"> & { /** * @generated from field: string name = 1; */ - name = ""; + name: string; /** * @generated from field: bool not_null = 3; */ - notNull = false; + notNull: boolean; /** * @generated from field: bool is_array = 4; */ - isArray = false; + isArray: boolean; /** * @generated from field: string comment = 5; */ - comment = ""; + comment: string; /** * @generated from field: int32 length = 6; */ - length = 0; + length: number; /** * @generated from field: bool is_named_param = 7; */ - isNamedParam = false; + isNamedParam: boolean; /** * @generated from field: bool is_func_call = 8; */ - isFuncCall = false; + isFuncCall: boolean; /** * XXX: Figure out what PostgreSQL calls `foo.id` * * @generated from field: string scope = 9; */ - scope = ""; + scope: string; /** * @generated from field: plugin.Identifier table = 10; @@ -617,7 +378,7 @@ export class Column extends Message { /** * @generated from field: string table_alias = 11; */ - tableAlias = ""; + tableAlias: string; /** * @generated from field: plugin.Identifier type = 12; @@ -627,7 +388,7 @@ export class Column extends Message { /** * @generated from field: bool is_sqlc_slice = 13; */ - isSqlcSlice = false; + isSqlcSlice: boolean; /** * @generated from field: plugin.Identifier embed_table = 14; @@ -637,187 +398,104 @@ export class Column extends Message { /** * @generated from field: string original_name = 15; */ - originalName = ""; + originalName: string; /** * @generated from field: bool unsigned = 16; */ - unsigned = false; + unsigned: boolean; /** * @generated from field: int32 array_dims = 17; */ - arrayDims = 0; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Column"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "not_null", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 4, name: "is_array", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 5, name: "comment", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 6, name: "length", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 7, name: "is_named_param", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 8, name: "is_func_call", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 9, name: "scope", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 10, name: "table", kind: "message", T: Identifier }, - { no: 11, name: "table_alias", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 12, name: "type", kind: "message", T: Identifier }, - { no: 13, name: "is_sqlc_slice", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 14, name: "embed_table", kind: "message", T: Identifier }, - { no: 15, name: "original_name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 16, name: "unsigned", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, - { no: 17, name: "array_dims", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Column { - return new Column().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Column { - return new Column().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Column { - return new Column().fromJsonString(jsonString, options); - } - - static equals(a: Column | PlainMessage | undefined, b: Column | PlainMessage | undefined): boolean { - return proto3.util.equals(Column, a, b); - } -} + arrayDims: number; +}; + +/** + * Describes the message plugin.Column. + * Use `create(ColumnSchema)` to create a new message. + */ +export const ColumnSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 9); /** * @generated from message plugin.Query */ -export class Query extends Message { +export type Query = Message<"plugin.Query"> & { /** * @generated from field: string text = 1; */ - text = ""; + text: string; /** * @generated from field: string name = 2; */ - name = ""; + name: string; /** * @generated from field: string cmd = 3; */ - cmd = ""; + cmd: string; /** * @generated from field: repeated plugin.Column columns = 4; */ - columns: Column[] = []; + columns: Column[]; /** * @generated from field: repeated plugin.Parameter params = 5 [json_name = "parameters"]; */ - params: Parameter[] = []; + params: Parameter[]; /** * @generated from field: repeated string comments = 6; */ - comments: string[] = []; + comments: string[]; /** * @generated from field: string filename = 7; */ - filename = ""; + filename: string; /** * @generated from field: plugin.Identifier insert_into_table = 8 [json_name = "insert_into_table"]; */ insertIntoTable?: Identifier; +}; - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Query"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "text", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 2, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 3, name: "cmd", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 4, name: "columns", kind: "message", T: Column, repeated: true }, - { no: 5, name: "params", jsonName: "parameters", kind: "message", T: Parameter, repeated: true }, - { no: 6, name: "comments", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, - { no: 7, name: "filename", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 8, name: "insert_into_table", jsonName: "insert_into_table", kind: "message", T: Identifier }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Query { - return new Query().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Query { - return new Query().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Query { - return new Query().fromJsonString(jsonString, options); - } - - static equals(a: Query | PlainMessage | undefined, b: Query | PlainMessage | undefined): boolean { - return proto3.util.equals(Query, a, b); - } -} +/** + * Describes the message plugin.Query. + * Use `create(QuerySchema)` to create a new message. + */ +export const QuerySchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 10); /** * @generated from message plugin.Parameter */ -export class Parameter extends Message { +export type Parameter = Message<"plugin.Parameter"> & { /** * @generated from field: int32 number = 1; */ - number = 0; + number: number; /** * @generated from field: plugin.Column column = 2; */ column?: Column; +}; - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.Parameter"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "number", kind: "scalar", T: 5 /* ScalarType.INT32 */ }, - { no: 2, name: "column", kind: "message", T: Column }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): Parameter { - return new Parameter().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): Parameter { - return new Parameter().fromJson(jsonValue, options); - } - - static fromJsonString(jsonString: string, options?: Partial): Parameter { - return new Parameter().fromJsonString(jsonString, options); - } - - static equals(a: Parameter | PlainMessage | undefined, b: Parameter | PlainMessage | undefined): boolean { - return proto3.util.equals(Parameter, a, b); - } -} +/** + * Describes the message plugin.Parameter. + * Use `create(ParameterSchema)` to create a new message. + */ +export const ParameterSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 11); /** * @generated from message plugin.GenerateRequest */ -export class GenerateRequest extends Message { +export type GenerateRequest = Message<"plugin.GenerateRequest"> & { /** * @generated from field: plugin.Settings settings = 1; */ @@ -831,90 +509,60 @@ export class GenerateRequest extends Message { /** * @generated from field: repeated plugin.Query queries = 3; */ - queries: Query[] = []; + queries: Query[]; /** * @generated from field: string sqlc_version = 4 [json_name = "sqlc_version"]; */ - sqlcVersion = ""; + sqlcVersion: string; /** * @generated from field: bytes plugin_options = 5 [json_name = "plugin_options"]; */ - pluginOptions = new Uint8Array(0); + pluginOptions: Uint8Array; /** * @generated from field: bytes global_options = 6 [json_name = "global_options"]; */ - globalOptions = new Uint8Array(0); - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.GenerateRequest"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "settings", kind: "message", T: Settings }, - { no: 2, name: "catalog", kind: "message", T: Catalog }, - { no: 3, name: "queries", kind: "message", T: Query, repeated: true }, - { no: 4, name: "sqlc_version", jsonName: "sqlc_version", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - { no: 5, name: "plugin_options", jsonName: "plugin_options", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - { no: 6, name: "global_options", jsonName: "global_options", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): GenerateRequest { - return new GenerateRequest().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): GenerateRequest { - return new GenerateRequest().fromJson(jsonValue, options); - } + globalOptions: Uint8Array; +}; - static fromJsonString(jsonString: string, options?: Partial): GenerateRequest { - return new GenerateRequest().fromJsonString(jsonString, options); - } - - static equals(a: GenerateRequest | PlainMessage | undefined, b: GenerateRequest | PlainMessage | undefined): boolean { - return proto3.util.equals(GenerateRequest, a, b); - } -} +/** + * Describes the message plugin.GenerateRequest. + * Use `create(GenerateRequestSchema)` to create a new message. + */ +export const GenerateRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 12); /** * @generated from message plugin.GenerateResponse */ -export class GenerateResponse extends Message { +export type GenerateResponse = Message<"plugin.GenerateResponse"> & { /** * @generated from field: repeated plugin.File files = 1; */ - files: File[] = []; - - constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); - } - - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "plugin.GenerateResponse"; - static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "files", kind: "message", T: File, repeated: true }, - ]); - - static fromBinary(bytes: Uint8Array, options?: Partial): GenerateResponse { - return new GenerateResponse().fromBinary(bytes, options); - } - - static fromJson(jsonValue: JsonValue, options?: Partial): GenerateResponse { - return new GenerateResponse().fromJson(jsonValue, options); - } + files: File[]; +}; - static fromJsonString(jsonString: string, options?: Partial): GenerateResponse { - return new GenerateResponse().fromJsonString(jsonString, options); - } +/** + * Describes the message plugin.GenerateResponse. + * Use `create(GenerateResponseSchema)` to create a new message. + */ +export const GenerateResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_plugin_codegen, 13); - static equals(a: GenerateResponse | PlainMessage | undefined, b: GenerateResponse | PlainMessage | undefined): boolean { - return proto3.util.equals(GenerateResponse, a, b); - } -} +/** + * @generated from service plugin.CodegenService + */ +export const CodegenService: GenService<{ + /** + * @generated from rpc plugin.CodegenService.Generate + */ + generate: { + methodKind: "unary"; + input: typeof GenerateRequestSchema; + output: typeof GenerateResponseSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_plugin_codegen, 0);