├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── _sqlc.json ├── buf.gen.yaml ├── buf.work.yaml ├── cmd └── sqlc-gen-ts-d1 │ └── main.go ├── codegen └── plugin │ ├── codegen.pb.go │ └── codegen_vtproto.pb.go ├── go.mod ├── go.sum ├── protos └── plugin │ └── codegen.proto ├── query.sql ├── schema.sql ├── sqlc.json └── src └── gen └── sqlc ├── models.ts └── querier.ts /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | node_modules 3 | package.json 4 | package-lock.json 5 | tsconfig.json 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2023 Yonashiro Nao 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: generate 2 | generate: sqlc.json 3 | sqlc generate 4 | 5 | .PHONY: release 6 | release: dist/sqlc-gen-ts-d1.wasm dist/sqlc-gen-ts-d1.wasm.sha256 7 | gh release delete -y --cleanup-tag v0.0.0-a 8 | gh release create v0.0.0-a dist/sqlc-gen-ts-d1.wasm dist/sqlc-gen-ts-d1.wasm.sha256 9 | 10 | sqlc.json: bin/sqlc-gen-ts-d1.wasm.sha256 _sqlc.json 11 | cat _sqlc.json | WASM_SHA256=$$(cat $<) envsubst > $@ 12 | 13 | bin/sqlc-gen-ts-d1.wasm.sha256: bin/sqlc-gen-ts-d1.wasm 14 | openssl sha256 $< | awk '{print $$2}' > $@ 15 | 16 | bin/sqlc-gen-ts-d1.wasm: cmd/sqlc-gen-ts-d1/main.go 17 | mkdir -p bin && GOROOT=$$(go env GOROOT) tinygo build -o $@ -gc=leaking -scheduler=none -target=wasi -no-debug -ldflags="-X main.version=v0.0.0-a" $< 18 | 19 | dist/sqlc-gen-ts-d1.wasm.sha256: dist/sqlc-gen-ts-d1.wasm 20 | openssl sha256 $< | awk '{print $$2}' > $@ 21 | 22 | dist/sqlc-gen-ts-d1.wasm: cmd/sqlc-gen-ts-d1/main.go 23 | mkdir -p dist && GOROOT=$$(go env GOROOT) tinygo build -o $@ -gc=leaking -scheduler=none -target=wasi -no-debug -ldflags="-X main.version=v0.0.0-a -X main.revision=$$(git rev-parse HEAD)" $< 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sqlc-gen-ts-d1 2 | 3 | https://github.com/voluntas/sqlc-gen-ts-d1-spec 4 | 5 | を元に作られたプロトタイプです。 6 | 7 | ## 使用方法 8 | 9 | sqlc v1.19.0 以上で動作します。 10 | 11 | sqlc.json の plugins 以下に ts-d1 を追加してください。 12 | 13 | v0.0.0-a リリースは main branch に合わせて再生成されているので sha256 を再取得しないと期待通りの動作をしないかもしれません 14 | ```bash 15 | cat < = {\n") 70 | querier.WriteString(" then(onFulfilled?: (value: T) => void, onRejected?: (reason?: any) => void): void;\n") 71 | querier.WriteString(" batch(): D1PreparedStatement;\n") 72 | querier.WriteString("}\n") 73 | 74 | requireModels := map[string]bool{} 75 | requireExpandedParams := false 76 | 77 | for _, q := range request.GetQueries() { 78 | queryText := q.GetText() 79 | // sqlc.embed はカラムを x.a, x.b, x.c のような形で展開する 80 | // 複数の sqlc.embed が展開された結果、重複した名前のカラムの情報が得られない処理系がある 81 | // そのため x.a AS x_a, x.b AS x_b, x.c AS x_c のようにクエリを書き換えることで問題を回避する 82 | // カラムを一つずつ書き換えた場合は前方一致や後方一致を考慮する必要があるのでまとめて書き換えを行う 83 | for _, c := range q.GetColumns() { 84 | et := c.GetEmbedTable() 85 | if et.GetName() == "" { 86 | continue 87 | } 88 | var news, olds []string 89 | for _, ec := range tableMap.findTable(et).GetColumns() { 90 | from := et.GetName() + "." + ec.GetName() 91 | to := from + " AS " + naming.toEmbedColumnName(et, ec) 92 | olds = append(olds, from) 93 | news = append(news, to) 94 | } 95 | queryText = strings.Replace(queryText, strings.Join(olds, ", "), strings.Join(news, ", "), 1) 96 | } 97 | 98 | query := "-- name: " + q.GetName() + " " + q.GetCmd() + "\n" + queryText 99 | fmt.Fprintf(querier, "const %s = `%s`;\n", naming.toConstQueryName(q), query) 100 | 101 | querier.WriteByte('\n') 102 | 103 | // パラメータが0個の場合は引数から削除するので型を生成しない 104 | if len(q.GetParams()) > 0 { 105 | fmt.Fprintf(querier, "export type %s = {\n", naming.toParamsTypeName(q)) 106 | for _, p := range q.GetParams() { 107 | c := p.GetColumn() 108 | paramName := naming.toPropertyName(c) 109 | tsType := tsTypeMap.toTsType(c) 110 | // パラメータは sqlc.narg を使った場合のみ nullable 111 | if c.GetNotNull() { 112 | // パラメータに対応するカラムがわかっていて、スキーマ上で nullable であればパラメータを nullable とする 113 | if tc := tableMap.findColumn(c); tc != nil && !tc.GetNotNull() { 114 | tsType += " | null" 115 | } 116 | } 117 | fmt.Fprintf(querier, " %s: %s;\n", paramName, tsType) 118 | } 119 | querier.WriteString("};\n") 120 | 121 | querier.WriteByte('\n') 122 | } 123 | 124 | needRawType := false 125 | // :exec はレスポンスが返ってこないので型を生成しない 126 | if q.GetCmd() != ":exec" { 127 | fmt.Fprintf(querier, "export type %s = {\n", naming.toQueryRowTypeName(q)) 128 | for _, c := range q.GetColumns() { 129 | colName := c.GetName() 130 | propName := naming.toPropertyName(c) 131 | 132 | // カラム名(snake)とプロパティ名(camel)が異なる場合 133 | // 生成コードの内部で変換する必要があるのでクエリの内部結果型が必要になる 134 | if colName != propName { 135 | needRawType = true 136 | } 137 | 138 | tsType := "" 139 | 140 | // sqlc.embed が使われている場合 141 | // 生成コードの内部で変換する必要があるのでクエリの内部結果型が必要になる 142 | if et := c.GetEmbedTable(); et.GetName() != "" { 143 | needRawType = true 144 | tsType = naming.toModelTypeName(et) 145 | // models.ts から import が必要になる 146 | requireModels[tsType] = true 147 | } else { 148 | tsType = tsTypeMap.toTsType(c) 149 | } 150 | fmt.Fprintf(querier, " %s: %s;\n", propName, tsType) 151 | } 152 | querier.WriteString("};\n") 153 | 154 | querier.WriteByte('\n') 155 | } 156 | 157 | // 內部結果型が必要な場合のみ生成する 158 | if needRawType { 159 | fmt.Fprintf(querier, "type %s = {\n", naming.toRawQueryRowTypeName(q)) 160 | for _, c := range q.GetColumns() { 161 | // sqlc.embed の場合、スキーマからカラムの情報を取得し展開する 162 | if et := c.GetEmbedTable(); et.GetName() != "" { 163 | for _, ec := range tableMap.findTable(et).GetColumns() { 164 | colName := naming.toEmbedColumnName(et, ec) 165 | tsType := tsTypeMap.toTsType(ec) 166 | fmt.Fprintf(querier, " %s: %s;\n", colName, tsType) 167 | } 168 | } else { 169 | colName := c.GetName() 170 | tsType := tsTypeMap.toTsType(c) 171 | fmt.Fprintf(querier, " %s: %s;\n", colName, tsType) 172 | } 173 | } 174 | querier.WriteString("};\n") 175 | 176 | querier.WriteByte('\n') 177 | } 178 | 179 | rowType := naming.toQueryRowTypeName(q) 180 | // retType は関数の戻り値の型 181 | var retType string 182 | // resultType は SQLite からの戻り値の型 183 | var resultType string 184 | 185 | if cmd := q.GetCmd(); cmd == ":one" { 186 | retType = rowType + " | null" 187 | resultType = retType 188 | if needRawType { 189 | resultType = naming.toRawQueryRowTypeName(q) + " | null" 190 | } 191 | } else if cmd == ":exec" { 192 | retType = "D1Result" 193 | } else { 194 | retType = "D1Result<" + rowType + ">" 195 | resultType = rowType 196 | if needRawType { 197 | resultType = naming.toRawQueryRowTypeName(q) 198 | } 199 | } 200 | 201 | fmt.Fprintf(querier, "export function %s(\n", naming.toFunctionName(q)) 202 | fmt.Fprintf(querier, " d1: D1Database") 203 | // パラメータがないときは引数を追加しない 204 | if len(q.GetParams()) > 0 { 205 | querier.WriteString(",\n") 206 | fmt.Fprintf(querier, " args: %s", naming.toParamsTypeName(q)) 207 | } 208 | querier.WriteString("\n") 209 | fmt.Fprintf(querier, "): Query<%s> {\n", retType) 210 | 211 | var queryVar string 212 | var bindArgs string 213 | if hasSqlcSlice(q) { 214 | // SQLite はパラメータに配列を指定できないため、sqlc.slice では実行時にクエリを書き換える必要がある 215 | // sqlc はパラメータに自動採番する都合で sqlc.slice のパラメータは登場順で番号がつく 216 | // しかし ? には番号がついてない文字列が出力される (sqlc-dev/sqlc/pull/2274) 217 | // 動的にパラメータの数が変動するが既存のパラメータの番号は書き換えたくないので1個目の要素はそのまま渡して動的なパラメータは末尾に追加する 218 | // 例: 219 | // クエリ: 220 | // SELECT * FROM foo WHERE a = @a AND id IN (sqlc.slice(ids)) AND b = @b 221 | // コンパイル済み: 222 | // SELECT id, a, b FROM foo WHERE a = ?1 AND id IN (/*SLICE:ids*/?) AND b = ?3 223 | // 実行時(idsが長さ3の場合): 224 | // SELECT id, a, b FROM foo WHERE a = ?1 AND id IN (?2, ?4, ?5) AND b = ?3 225 | fmt.Fprintf(querier, " let query = %s;\n", naming.toConstQueryName(q)) 226 | fmt.Fprintf(querier, " const params: any[] = [%s];\n", buildBindArgs(q)) 227 | for _, p := range q.GetParams() { 228 | c := p.GetColumn() 229 | if !c.GetIsSqlcSlice() { 230 | continue 231 | } 232 | n := p.GetNumber() 233 | propName := naming.toPropertyName(c) 234 | // sqlc.slice は (/*SLICE:foo*/?) という形式でクエリが書き出される (sqlc-dev/sqlc/pull/2274) 235 | // (?1, ?2, ?3) のような形で書き換える 236 | fmt.Fprintf(querier, " query = query.replace(\"(/*SLICE:%s*/?)\", expandedParam(%d, args.%s.length, params.length));\n", c.Name, n, propName) 237 | // 1番目の要素は宣言時に params に含まれているのでそれ以降を push する 238 | fmt.Fprintf(querier, " params.push(...args.%s.slice(1));\n", propName) 239 | } 240 | queryVar = "query" 241 | bindArgs = "...params" 242 | requireExpandedParams = true 243 | } else { 244 | queryVar = naming.toConstQueryName(q) 245 | bindArgs = buildBindArgs(q) 246 | } 247 | 248 | fmt.Fprintf(querier, " const ps = d1\n") 249 | fmt.Fprintf(querier, " .prepare(%s)", queryVar) 250 | if len(q.GetParams()) > 0 { 251 | querier.WriteString("\n") 252 | fmt.Fprintf(querier, " .bind(%s)", bindArgs) 253 | } 254 | querier.WriteString(";\n") 255 | 256 | fmt.Fprintf(querier, " return {\n") 257 | fmt.Fprintf(querier, " then(onFulfilled?: (value: %s) => void, onRejected?: (reason?: any) => void) {\n", retType) 258 | 259 | switch q.GetCmd() { 260 | case ":one": 261 | fmt.Fprintf(querier, " ps.first<%s>()\n", resultType) 262 | case ":many": 263 | fmt.Fprintf(querier, " ps.all<%s>()\n", resultType) 264 | case ":exec": 265 | fmt.Fprintf(querier, " ps.run()\n") 266 | } 267 | 268 | // 內部結果型を使っている場合は結果型に変換する処理を生成する 269 | if needRawType { 270 | if q.GetCmd() == ":one" { 271 | fmt.Fprintf(querier, " .then((raw: %s) => raw ? {\n", resultType) 272 | writeFromRawMapping(querier, " ", tableMap, q) 273 | fmt.Fprintf(querier, " } : null)\n") 274 | } else { 275 | fmt.Fprintf(querier, " .then((r: D1Result<%s>) => { return {\n", resultType) 276 | fmt.Fprintf(querier, " ...r,\n") 277 | if workersTypesV3 { 278 | fmt.Fprintf(querier, " results: r.results ? r.results.map((raw: %s) => { return {\n", resultType) 279 | writeFromRawMapping(querier, " ", tableMap, q) 280 | fmt.Fprintf(querier, " }}) : undefined,\n") 281 | } else { 282 | fmt.Fprintf(querier, " results: r.results.map((raw: %s) => { return {\n", resultType) 283 | writeFromRawMapping(querier, " ", tableMap, q) 284 | fmt.Fprintf(querier, " }}),\n") 285 | } 286 | fmt.Fprintf(querier, " }})\n") 287 | } 288 | } 289 | fmt.Fprintf(querier, " .then(onFulfilled).catch(onRejected);\n") 290 | fmt.Fprintf(querier, " },\n") 291 | fmt.Fprintf(querier, " batch() { return ps; },\n") 292 | fmt.Fprintf(querier, " }\n") 293 | querier.WriteString("}\n") 294 | 295 | querier.WriteByte('\n') 296 | } 297 | 298 | if requireExpandedParams { 299 | // sqlc.slice は実行時にクエリ書き換えが必要でその際に使う関数 300 | querier.WriteString(`function expandedParam(n: number, len: number, last: number): string { 301 | const params: number[] = [n]; 302 | for (let i = 1; i < len; i++) { 303 | params.push(last + i); 304 | } 305 | return "(" + params.map((x: number) => "?" + x).join(", ") + ")"; 306 | } 307 | `) 308 | } 309 | 310 | if len(requireModels) > 0 { 311 | var models []string 312 | for k := range requireModels { 313 | models = append(models, k) 314 | } 315 | sort.Strings(models) 316 | fmt.Fprintf(header, "import { %s } from \"./models\"\n", strings.Join(models, ", ")) 317 | } 318 | if header.Len() > 0 { 319 | header.WriteString("\n") 320 | } 321 | files = append(files, &plugin.File{Name: "querier.ts", Contents: append(header.Bytes(), querier.Bytes()...)}) 322 | } 323 | 324 | return &plugin.CodeGenResponse{ 325 | Files: files, 326 | }, nil 327 | } 328 | 329 | // TableMap はスキーマのテーブルの情報を検索可能なマップ 330 | type TableMap struct { 331 | m map[string]*tableMapEntry 332 | } 333 | 334 | func (m *TableMap) findColumn(c *plugin.Column) *plugin.Column { 335 | t := c.GetTable() 336 | if t == nil { 337 | return nil 338 | } 339 | table := m.m[t.GetName()] 340 | if table == nil { 341 | return nil 342 | } 343 | return table.m[c.GetName()] 344 | } 345 | 346 | func (m *TableMap) findTable(table *plugin.Identifier) *plugin.Table { 347 | t := m.m[table.GetName()] 348 | if t == nil { 349 | return nil 350 | } 351 | return t.t 352 | } 353 | 354 | type tableMapEntry struct { 355 | t *plugin.Table 356 | m map[string]*plugin.Column 357 | } 358 | 359 | func buildTableMap(catalog *plugin.Catalog) TableMap { 360 | tm := TableMap{ 361 | m: map[string]*tableMapEntry{}, 362 | } 363 | for _, schema := range catalog.GetSchemas() { 364 | for _, table := range schema.GetTables() { 365 | e := tableMapEntry{ 366 | t: table, 367 | m: map[string]*plugin.Column{}, 368 | } 369 | for _, column := range table.GetColumns() { 370 | e.m[column.GetName()] = column 371 | } 372 | tm.m[table.GetRel().GetName()] = &e 373 | } 374 | } 375 | return tm 376 | } 377 | 378 | // parseOption はクオートされたカンマ区切りの`key=value`形式かjsonのオブジェクト形式の入力を受け取りマップとして返す 379 | // 例: `"foo1=bar,foo2=buz"` => map[string]string{"foo1": "bar", "foo2": "buz"} 380 | // 例: `{"foo1":"bar","foo2":"buz"}` => map[string]string{"foo1": "bar", "foo2": "buz"} 381 | func parseOption(opt []byte) (map[string]string, error) { 382 | m := map[string]string{} 383 | if len(opt) == 0 { 384 | return m, nil 385 | } 386 | 387 | if bytes.HasPrefix(opt, []byte("{")) { 388 | if err := json.Unmarshal(opt, &m); err != nil { 389 | return nil, fmt.Errorf("unmarshal: %w", err) 390 | } 391 | return m, nil 392 | } 393 | 394 | s, _ := strconv.Unquote(string(opt)) 395 | for _, kv := range strings.Split(s, ",") { 396 | k, v, _ := strings.Cut(kv, "=") 397 | m[k] = v 398 | } 399 | return m, nil 400 | } 401 | 402 | type TsTypeMap struct { 403 | m map[string]string 404 | } 405 | 406 | func (t *TsTypeMap) toTsType(col *plugin.Column) string { 407 | dbType := col.GetType().GetName() 408 | tsType, ok := t.m[strings.ToUpper(dbType)] 409 | if !ok { 410 | tsType = "number | string" 411 | } 412 | if col.GetIsSqlcSlice() { 413 | tsType += "[]" 414 | } 415 | if !col.GetNotNull() { 416 | tsType += " | null" 417 | } 418 | return tsType 419 | } 420 | 421 | func buildTsTypeMap(settings *plugin.Settings) *TsTypeMap { 422 | // https://developers.cloudflare.com/d1/platform/client-api/#type-conversion 423 | m := map[string]string{ 424 | "NULL": "null", 425 | "REAL": "number", 426 | "INTEGER": "number", 427 | "TEXT": "string", 428 | "DATETIME": "string", 429 | "JSON": "string", 430 | "BLOB": "ArrayBuffer", 431 | } 432 | for _, o := range settings.GetOverrides() { 433 | m[strings.ToUpper(o.GetDbType())] = o.GetCodeType() 434 | } 435 | return &TsTypeMap{m: m} 436 | } 437 | 438 | func toUpperCamel(snake string) string { 439 | var b strings.Builder 440 | for _, t := range strings.Split(snake, "_") { 441 | if t != "" { 442 | b.WriteString(strings.ToUpper(t[:1]) + t[1:]) 443 | } 444 | } 445 | return b.String() 446 | } 447 | 448 | func toLowerCamel(snake string) string { 449 | s := toUpperCamel(snake) 450 | return strings.ToLower(s[:1]) + s[1:] 451 | } 452 | 453 | type Naming struct{} 454 | 455 | // toModelTypeName は models.ts に出力されるモデルの型名を返す 456 | func (Naming) toModelTypeName(table *plugin.Identifier) string { 457 | return toUpperCamel(table.GetName()) 458 | } 459 | 460 | // toPropertyName は TypeScript のプロパティの名前を返す 461 | func (Naming) toPropertyName(col *plugin.Column) string { 462 | return toLowerCamel(col.GetName()) 463 | } 464 | 465 | // toConstQueryName はクエリ文字列の定数の名前を返す 466 | func (Naming) toConstQueryName(q *plugin.Query) string { 467 | return toLowerCamel(q.GetName()) + "Query" 468 | } 469 | 470 | // toParamsTypeName はクエリのパラメータ型の名前を返す 471 | func (Naming) toParamsTypeName(q *plugin.Query) string { 472 | return q.GetName() + "Params" 473 | } 474 | 475 | // toQueryRowTypeName はクエリの結果型の名前を返す 476 | func (Naming) toQueryRowTypeName(q *plugin.Query) string { 477 | return q.GetName() + "Row" 478 | } 479 | 480 | // toRawQueryRowTypeName はクエリの内部結果型の名前を返す 481 | func (Naming) toRawQueryRowTypeName(q *plugin.Query) string { 482 | return "Raw" + q.GetName() + "Row" 483 | } 484 | 485 | // toEmbedColumnName は sqlc.embed が使われたときのカラム名を返す 486 | func (Naming) toEmbedColumnName(e *plugin.Identifier, c *plugin.Column) string { 487 | // MEMO: "_" 1つだと最悪他のカラム名と衝突してしまいそう 488 | return e.GetName() + "_" + c.GetName() 489 | } 490 | 491 | // toFunctionName はクエリ関数の関数名を返す 492 | func (Naming) toFunctionName(q *plugin.Query) string { 493 | return toLowerCamel(q.GetName()) 494 | } 495 | 496 | var naming Naming 497 | 498 | func hasSqlcSlice(q *plugin.Query) bool { 499 | for _, p := range q.GetParams() { 500 | if p.GetColumn().GetIsSqlcSlice() { 501 | return true 502 | } 503 | } 504 | return false 505 | } 506 | 507 | func buildBindArgs(q *plugin.Query) string { 508 | var args strings.Builder 509 | for i, p := range q.GetParams() { 510 | if i > 0 { 511 | args.WriteString(", ") 512 | } 513 | args.WriteString("args." + naming.toPropertyName(p.GetColumn())) 514 | if p.GetColumn().GetIsSqlcSlice() { 515 | args.WriteString("[0]") 516 | } 517 | } 518 | return args.String() 519 | } 520 | 521 | func writeFromRawMapping(w *bytes.Buffer, indent string, tableMap TableMap, q *plugin.Query) { 522 | for _, c := range q.GetColumns() { 523 | propName := naming.toPropertyName(c) 524 | // sqlc.embed の場合はモデル型に変換する 525 | if et := c.GetEmbedTable(); et.GetName() != "" { 526 | fmt.Fprintf(w, "%s// sqlc.embed(%s)\n", indent, propName) 527 | fmt.Fprintf(w, "%s%s: {\n", indent, propName) 528 | for _, ec := range tableMap.findTable(et).GetColumns() { 529 | from := naming.toEmbedColumnName(et, ec) 530 | to := naming.toPropertyName(ec) 531 | fmt.Fprintf(w, "%s %s: raw.%s,\n", indent, to, from) 532 | } 533 | fmt.Fprintf(w, "%s},\n", indent) 534 | } else { 535 | from := c.GetName() 536 | fmt.Fprintf(w, "%s%s: raw.%s,\n", indent, propName, from) 537 | } 538 | } 539 | } 540 | 541 | type Handler func(*plugin.CodeGenRequest) (*plugin.CodeGenResponse, error) 542 | 543 | func run(h Handler) error { 544 | var req plugin.CodeGenRequest 545 | reqBlob, err := io.ReadAll(os.Stdin) 546 | if err != nil { 547 | return err 548 | } 549 | if err := req.UnmarshalVT(reqBlob); err != nil { 550 | return err 551 | } 552 | resp, err := h(&req) 553 | if err != nil { 554 | return err 555 | } 556 | respBlob, err := resp.MarshalVT() 557 | if err != nil { 558 | return err 559 | } 560 | w := bufio.NewWriter(os.Stdout) 561 | if _, err := w.Write(respBlob); err != nil { 562 | return err 563 | } 564 | if err := w.Flush(); err != nil { 565 | return err 566 | } 567 | return nil 568 | } 569 | 570 | var version string 571 | var revision string 572 | 573 | func appendMeta(b *bytes.Buffer, req *plugin.CodeGenRequest) { 574 | v := "v0.0.0-a" 575 | if version != "" { 576 | v = version 577 | } 578 | r := "HEAD" 579 | if revision != "" { 580 | r = revision 581 | } 582 | sha256 := req.GetSettings().GetCodegen().GetWasm().GetSha256() 583 | if sha256 != "" { 584 | r = sha256 585 | } 586 | b.WriteString("// Code generated by sqlc-gen-ts-d1. DO NOT EDIT.\n") 587 | b.WriteString("// versions:\n") 588 | fmt.Fprintf(b, "// sqlc %s\n", req.SqlcVersion) 589 | fmt.Fprintf(b, "// sqlc-gen-ts-d1 %s@%s\n", v, r) 590 | b.WriteString("\n") 591 | } 592 | 593 | func main() { 594 | if err := run(handler); err != nil { 595 | fmt.Fprintf(os.Stderr, "error generating output: %s", err) 596 | os.Exit(2) 597 | } 598 | } 599 | -------------------------------------------------------------------------------- /codegen/plugin/codegen.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.30.0 4 | // protoc (unknown) 5 | // source: plugin/codegen.proto 6 | 7 | package plugin 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | sync "sync" 13 | ) 14 | 15 | const ( 16 | // Verify that this generated code is sufficiently up-to-date. 17 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 18 | // Verify that runtime/protoimpl is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 20 | ) 21 | 22 | type File struct { 23 | state protoimpl.MessageState 24 | sizeCache protoimpl.SizeCache 25 | unknownFields protoimpl.UnknownFields 26 | 27 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 28 | Contents []byte `protobuf:"bytes,2,opt,name=contents,proto3" json:"contents,omitempty"` 29 | } 30 | 31 | func (x *File) Reset() { 32 | *x = File{} 33 | if protoimpl.UnsafeEnabled { 34 | mi := &file_plugin_codegen_proto_msgTypes[0] 35 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 36 | ms.StoreMessageInfo(mi) 37 | } 38 | } 39 | 40 | func (x *File) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*File) ProtoMessage() {} 45 | 46 | func (x *File) ProtoReflect() protoreflect.Message { 47 | mi := &file_plugin_codegen_proto_msgTypes[0] 48 | if protoimpl.UnsafeEnabled && x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use File.ProtoReflect.Descriptor instead. 59 | func (*File) Descriptor() ([]byte, []int) { 60 | return file_plugin_codegen_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *File) GetName() string { 64 | if x != nil { 65 | return x.Name 66 | } 67 | return "" 68 | } 69 | 70 | func (x *File) GetContents() []byte { 71 | if x != nil { 72 | return x.Contents 73 | } 74 | return nil 75 | } 76 | 77 | type Override struct { 78 | state protoimpl.MessageState 79 | sizeCache protoimpl.SizeCache 80 | unknownFields protoimpl.UnknownFields 81 | 82 | // name of the type to use, e.g. `github.com/segmentio/ksuid.KSUID` or `mymodule.Type` 83 | CodeType string `protobuf:"bytes,1,opt,name=code_type,proto3" json:"code_type,omitempty"` 84 | // name of the type to use, e.g. `text` 85 | DbType string `protobuf:"bytes,3,opt,name=db_type,proto3" json:"db_type,omitempty"` 86 | // True if the override should apply to a nullable database type 87 | Nullable bool `protobuf:"varint,5,opt,name=nullable,proto3" json:"nullable,omitempty"` 88 | // fully qualified name of the column, e.g. `accounts.id` 89 | Column string `protobuf:"bytes,6,opt,name=column,proto3" json:"column,omitempty"` 90 | Table *Identifier `protobuf:"bytes,7,opt,name=table,proto3" json:"table,omitempty"` 91 | ColumnName string `protobuf:"bytes,8,opt,name=column_name,proto3" json:"column_name,omitempty"` 92 | GoType *ParsedGoType `protobuf:"bytes,10,opt,name=go_type,json=goType,proto3" json:"go_type,omitempty"` 93 | // True if the override should apply to a unsigned database type 94 | Unsigned bool `protobuf:"varint,11,opt,name=unsigned,proto3" json:"unsigned,omitempty"` 95 | } 96 | 97 | func (x *Override) Reset() { 98 | *x = Override{} 99 | if protoimpl.UnsafeEnabled { 100 | mi := &file_plugin_codegen_proto_msgTypes[1] 101 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 102 | ms.StoreMessageInfo(mi) 103 | } 104 | } 105 | 106 | func (x *Override) String() string { 107 | return protoimpl.X.MessageStringOf(x) 108 | } 109 | 110 | func (*Override) ProtoMessage() {} 111 | 112 | func (x *Override) ProtoReflect() protoreflect.Message { 113 | mi := &file_plugin_codegen_proto_msgTypes[1] 114 | if protoimpl.UnsafeEnabled && x != nil { 115 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 116 | if ms.LoadMessageInfo() == nil { 117 | ms.StoreMessageInfo(mi) 118 | } 119 | return ms 120 | } 121 | return mi.MessageOf(x) 122 | } 123 | 124 | // Deprecated: Use Override.ProtoReflect.Descriptor instead. 125 | func (*Override) Descriptor() ([]byte, []int) { 126 | return file_plugin_codegen_proto_rawDescGZIP(), []int{1} 127 | } 128 | 129 | func (x *Override) GetCodeType() string { 130 | if x != nil { 131 | return x.CodeType 132 | } 133 | return "" 134 | } 135 | 136 | func (x *Override) GetDbType() string { 137 | if x != nil { 138 | return x.DbType 139 | } 140 | return "" 141 | } 142 | 143 | func (x *Override) GetNullable() bool { 144 | if x != nil { 145 | return x.Nullable 146 | } 147 | return false 148 | } 149 | 150 | func (x *Override) GetColumn() string { 151 | if x != nil { 152 | return x.Column 153 | } 154 | return "" 155 | } 156 | 157 | func (x *Override) GetTable() *Identifier { 158 | if x != nil { 159 | return x.Table 160 | } 161 | return nil 162 | } 163 | 164 | func (x *Override) GetColumnName() string { 165 | if x != nil { 166 | return x.ColumnName 167 | } 168 | return "" 169 | } 170 | 171 | func (x *Override) GetGoType() *ParsedGoType { 172 | if x != nil { 173 | return x.GoType 174 | } 175 | return nil 176 | } 177 | 178 | func (x *Override) GetUnsigned() bool { 179 | if x != nil { 180 | return x.Unsigned 181 | } 182 | return false 183 | } 184 | 185 | type ParsedGoType struct { 186 | state protoimpl.MessageState 187 | sizeCache protoimpl.SizeCache 188 | unknownFields protoimpl.UnknownFields 189 | 190 | ImportPath string `protobuf:"bytes,1,opt,name=import_path,json=importPath,proto3" json:"import_path,omitempty"` 191 | Package string `protobuf:"bytes,2,opt,name=package,proto3" json:"package,omitempty"` 192 | TypeName string `protobuf:"bytes,3,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` 193 | BasicType bool `protobuf:"varint,4,opt,name=basic_type,json=basicType,proto3" json:"basic_type,omitempty"` 194 | StructTags map[string]string `protobuf:"bytes,5,rep,name=struct_tags,json=structTags,proto3" json:"struct_tags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 195 | } 196 | 197 | func (x *ParsedGoType) Reset() { 198 | *x = ParsedGoType{} 199 | if protoimpl.UnsafeEnabled { 200 | mi := &file_plugin_codegen_proto_msgTypes[2] 201 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 202 | ms.StoreMessageInfo(mi) 203 | } 204 | } 205 | 206 | func (x *ParsedGoType) String() string { 207 | return protoimpl.X.MessageStringOf(x) 208 | } 209 | 210 | func (*ParsedGoType) ProtoMessage() {} 211 | 212 | func (x *ParsedGoType) ProtoReflect() protoreflect.Message { 213 | mi := &file_plugin_codegen_proto_msgTypes[2] 214 | if protoimpl.UnsafeEnabled && x != nil { 215 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 216 | if ms.LoadMessageInfo() == nil { 217 | ms.StoreMessageInfo(mi) 218 | } 219 | return ms 220 | } 221 | return mi.MessageOf(x) 222 | } 223 | 224 | // Deprecated: Use ParsedGoType.ProtoReflect.Descriptor instead. 225 | func (*ParsedGoType) Descriptor() ([]byte, []int) { 226 | return file_plugin_codegen_proto_rawDescGZIP(), []int{2} 227 | } 228 | 229 | func (x *ParsedGoType) GetImportPath() string { 230 | if x != nil { 231 | return x.ImportPath 232 | } 233 | return "" 234 | } 235 | 236 | func (x *ParsedGoType) GetPackage() string { 237 | if x != nil { 238 | return x.Package 239 | } 240 | return "" 241 | } 242 | 243 | func (x *ParsedGoType) GetTypeName() string { 244 | if x != nil { 245 | return x.TypeName 246 | } 247 | return "" 248 | } 249 | 250 | func (x *ParsedGoType) GetBasicType() bool { 251 | if x != nil { 252 | return x.BasicType 253 | } 254 | return false 255 | } 256 | 257 | func (x *ParsedGoType) GetStructTags() map[string]string { 258 | if x != nil { 259 | return x.StructTags 260 | } 261 | return nil 262 | } 263 | 264 | type Settings struct { 265 | state protoimpl.MessageState 266 | sizeCache protoimpl.SizeCache 267 | unknownFields protoimpl.UnknownFields 268 | 269 | Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` 270 | Engine string `protobuf:"bytes,2,opt,name=engine,proto3" json:"engine,omitempty"` 271 | Schema []string `protobuf:"bytes,3,rep,name=schema,proto3" json:"schema,omitempty"` 272 | Queries []string `protobuf:"bytes,4,rep,name=queries,proto3" json:"queries,omitempty"` 273 | Rename map[string]string `protobuf:"bytes,5,rep,name=rename,proto3" json:"rename,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 274 | Overrides []*Override `protobuf:"bytes,6,rep,name=overrides,proto3" json:"overrides,omitempty"` 275 | Codegen *Codegen `protobuf:"bytes,12,opt,name=codegen,proto3" json:"codegen,omitempty"` 276 | } 277 | 278 | func (x *Settings) Reset() { 279 | *x = Settings{} 280 | if protoimpl.UnsafeEnabled { 281 | mi := &file_plugin_codegen_proto_msgTypes[3] 282 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 283 | ms.StoreMessageInfo(mi) 284 | } 285 | } 286 | 287 | func (x *Settings) String() string { 288 | return protoimpl.X.MessageStringOf(x) 289 | } 290 | 291 | func (*Settings) ProtoMessage() {} 292 | 293 | func (x *Settings) ProtoReflect() protoreflect.Message { 294 | mi := &file_plugin_codegen_proto_msgTypes[3] 295 | if protoimpl.UnsafeEnabled && x != nil { 296 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 297 | if ms.LoadMessageInfo() == nil { 298 | ms.StoreMessageInfo(mi) 299 | } 300 | return ms 301 | } 302 | return mi.MessageOf(x) 303 | } 304 | 305 | // Deprecated: Use Settings.ProtoReflect.Descriptor instead. 306 | func (*Settings) Descriptor() ([]byte, []int) { 307 | return file_plugin_codegen_proto_rawDescGZIP(), []int{3} 308 | } 309 | 310 | func (x *Settings) GetVersion() string { 311 | if x != nil { 312 | return x.Version 313 | } 314 | return "" 315 | } 316 | 317 | func (x *Settings) GetEngine() string { 318 | if x != nil { 319 | return x.Engine 320 | } 321 | return "" 322 | } 323 | 324 | func (x *Settings) GetSchema() []string { 325 | if x != nil { 326 | return x.Schema 327 | } 328 | return nil 329 | } 330 | 331 | func (x *Settings) GetQueries() []string { 332 | if x != nil { 333 | return x.Queries 334 | } 335 | return nil 336 | } 337 | 338 | func (x *Settings) GetRename() map[string]string { 339 | if x != nil { 340 | return x.Rename 341 | } 342 | return nil 343 | } 344 | 345 | func (x *Settings) GetOverrides() []*Override { 346 | if x != nil { 347 | return x.Overrides 348 | } 349 | return nil 350 | } 351 | 352 | func (x *Settings) GetCodegen() *Codegen { 353 | if x != nil { 354 | return x.Codegen 355 | } 356 | return nil 357 | } 358 | 359 | type Codegen struct { 360 | state protoimpl.MessageState 361 | sizeCache protoimpl.SizeCache 362 | unknownFields protoimpl.UnknownFields 363 | 364 | Out string `protobuf:"bytes,1,opt,name=out,proto3" json:"out,omitempty"` 365 | Plugin string `protobuf:"bytes,2,opt,name=plugin,proto3" json:"plugin,omitempty"` 366 | Options []byte `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` 367 | Env []string `protobuf:"bytes,4,rep,name=env,proto3" json:"env,omitempty"` 368 | Process *Codegen_Process `protobuf:"bytes,5,opt,name=process,proto3" json:"process,omitempty"` 369 | Wasm *Codegen_WASM `protobuf:"bytes,6,opt,name=wasm,proto3" json:"wasm,omitempty"` 370 | } 371 | 372 | func (x *Codegen) Reset() { 373 | *x = Codegen{} 374 | if protoimpl.UnsafeEnabled { 375 | mi := &file_plugin_codegen_proto_msgTypes[4] 376 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 377 | ms.StoreMessageInfo(mi) 378 | } 379 | } 380 | 381 | func (x *Codegen) String() string { 382 | return protoimpl.X.MessageStringOf(x) 383 | } 384 | 385 | func (*Codegen) ProtoMessage() {} 386 | 387 | func (x *Codegen) ProtoReflect() protoreflect.Message { 388 | mi := &file_plugin_codegen_proto_msgTypes[4] 389 | if protoimpl.UnsafeEnabled && x != nil { 390 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 391 | if ms.LoadMessageInfo() == nil { 392 | ms.StoreMessageInfo(mi) 393 | } 394 | return ms 395 | } 396 | return mi.MessageOf(x) 397 | } 398 | 399 | // Deprecated: Use Codegen.ProtoReflect.Descriptor instead. 400 | func (*Codegen) Descriptor() ([]byte, []int) { 401 | return file_plugin_codegen_proto_rawDescGZIP(), []int{4} 402 | } 403 | 404 | func (x *Codegen) GetOut() string { 405 | if x != nil { 406 | return x.Out 407 | } 408 | return "" 409 | } 410 | 411 | func (x *Codegen) GetPlugin() string { 412 | if x != nil { 413 | return x.Plugin 414 | } 415 | return "" 416 | } 417 | 418 | func (x *Codegen) GetOptions() []byte { 419 | if x != nil { 420 | return x.Options 421 | } 422 | return nil 423 | } 424 | 425 | func (x *Codegen) GetEnv() []string { 426 | if x != nil { 427 | return x.Env 428 | } 429 | return nil 430 | } 431 | 432 | func (x *Codegen) GetProcess() *Codegen_Process { 433 | if x != nil { 434 | return x.Process 435 | } 436 | return nil 437 | } 438 | 439 | func (x *Codegen) GetWasm() *Codegen_WASM { 440 | if x != nil { 441 | return x.Wasm 442 | } 443 | return nil 444 | } 445 | 446 | type Catalog struct { 447 | state protoimpl.MessageState 448 | sizeCache protoimpl.SizeCache 449 | unknownFields protoimpl.UnknownFields 450 | 451 | Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` 452 | DefaultSchema string `protobuf:"bytes,2,opt,name=default_schema,json=defaultSchema,proto3" json:"default_schema,omitempty"` 453 | Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` 454 | Schemas []*Schema `protobuf:"bytes,4,rep,name=schemas,proto3" json:"schemas,omitempty"` 455 | } 456 | 457 | func (x *Catalog) Reset() { 458 | *x = Catalog{} 459 | if protoimpl.UnsafeEnabled { 460 | mi := &file_plugin_codegen_proto_msgTypes[5] 461 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 462 | ms.StoreMessageInfo(mi) 463 | } 464 | } 465 | 466 | func (x *Catalog) String() string { 467 | return protoimpl.X.MessageStringOf(x) 468 | } 469 | 470 | func (*Catalog) ProtoMessage() {} 471 | 472 | func (x *Catalog) ProtoReflect() protoreflect.Message { 473 | mi := &file_plugin_codegen_proto_msgTypes[5] 474 | if protoimpl.UnsafeEnabled && x != nil { 475 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 476 | if ms.LoadMessageInfo() == nil { 477 | ms.StoreMessageInfo(mi) 478 | } 479 | return ms 480 | } 481 | return mi.MessageOf(x) 482 | } 483 | 484 | // Deprecated: Use Catalog.ProtoReflect.Descriptor instead. 485 | func (*Catalog) Descriptor() ([]byte, []int) { 486 | return file_plugin_codegen_proto_rawDescGZIP(), []int{5} 487 | } 488 | 489 | func (x *Catalog) GetComment() string { 490 | if x != nil { 491 | return x.Comment 492 | } 493 | return "" 494 | } 495 | 496 | func (x *Catalog) GetDefaultSchema() string { 497 | if x != nil { 498 | return x.DefaultSchema 499 | } 500 | return "" 501 | } 502 | 503 | func (x *Catalog) GetName() string { 504 | if x != nil { 505 | return x.Name 506 | } 507 | return "" 508 | } 509 | 510 | func (x *Catalog) GetSchemas() []*Schema { 511 | if x != nil { 512 | return x.Schemas 513 | } 514 | return nil 515 | } 516 | 517 | type Schema struct { 518 | state protoimpl.MessageState 519 | sizeCache protoimpl.SizeCache 520 | unknownFields protoimpl.UnknownFields 521 | 522 | Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` 523 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 524 | Tables []*Table `protobuf:"bytes,3,rep,name=tables,proto3" json:"tables,omitempty"` 525 | Enums []*Enum `protobuf:"bytes,4,rep,name=enums,proto3" json:"enums,omitempty"` 526 | CompositeTypes []*CompositeType `protobuf:"bytes,5,rep,name=composite_types,json=compositeTypes,proto3" json:"composite_types,omitempty"` 527 | } 528 | 529 | func (x *Schema) Reset() { 530 | *x = Schema{} 531 | if protoimpl.UnsafeEnabled { 532 | mi := &file_plugin_codegen_proto_msgTypes[6] 533 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 534 | ms.StoreMessageInfo(mi) 535 | } 536 | } 537 | 538 | func (x *Schema) String() string { 539 | return protoimpl.X.MessageStringOf(x) 540 | } 541 | 542 | func (*Schema) ProtoMessage() {} 543 | 544 | func (x *Schema) ProtoReflect() protoreflect.Message { 545 | mi := &file_plugin_codegen_proto_msgTypes[6] 546 | if protoimpl.UnsafeEnabled && x != nil { 547 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 548 | if ms.LoadMessageInfo() == nil { 549 | ms.StoreMessageInfo(mi) 550 | } 551 | return ms 552 | } 553 | return mi.MessageOf(x) 554 | } 555 | 556 | // Deprecated: Use Schema.ProtoReflect.Descriptor instead. 557 | func (*Schema) Descriptor() ([]byte, []int) { 558 | return file_plugin_codegen_proto_rawDescGZIP(), []int{6} 559 | } 560 | 561 | func (x *Schema) GetComment() string { 562 | if x != nil { 563 | return x.Comment 564 | } 565 | return "" 566 | } 567 | 568 | func (x *Schema) GetName() string { 569 | if x != nil { 570 | return x.Name 571 | } 572 | return "" 573 | } 574 | 575 | func (x *Schema) GetTables() []*Table { 576 | if x != nil { 577 | return x.Tables 578 | } 579 | return nil 580 | } 581 | 582 | func (x *Schema) GetEnums() []*Enum { 583 | if x != nil { 584 | return x.Enums 585 | } 586 | return nil 587 | } 588 | 589 | func (x *Schema) GetCompositeTypes() []*CompositeType { 590 | if x != nil { 591 | return x.CompositeTypes 592 | } 593 | return nil 594 | } 595 | 596 | type CompositeType struct { 597 | state protoimpl.MessageState 598 | sizeCache protoimpl.SizeCache 599 | unknownFields protoimpl.UnknownFields 600 | 601 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 602 | Comment string `protobuf:"bytes,2,opt,name=comment,proto3" json:"comment,omitempty"` 603 | } 604 | 605 | func (x *CompositeType) Reset() { 606 | *x = CompositeType{} 607 | if protoimpl.UnsafeEnabled { 608 | mi := &file_plugin_codegen_proto_msgTypes[7] 609 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 610 | ms.StoreMessageInfo(mi) 611 | } 612 | } 613 | 614 | func (x *CompositeType) String() string { 615 | return protoimpl.X.MessageStringOf(x) 616 | } 617 | 618 | func (*CompositeType) ProtoMessage() {} 619 | 620 | func (x *CompositeType) ProtoReflect() protoreflect.Message { 621 | mi := &file_plugin_codegen_proto_msgTypes[7] 622 | if protoimpl.UnsafeEnabled && x != nil { 623 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 624 | if ms.LoadMessageInfo() == nil { 625 | ms.StoreMessageInfo(mi) 626 | } 627 | return ms 628 | } 629 | return mi.MessageOf(x) 630 | } 631 | 632 | // Deprecated: Use CompositeType.ProtoReflect.Descriptor instead. 633 | func (*CompositeType) Descriptor() ([]byte, []int) { 634 | return file_plugin_codegen_proto_rawDescGZIP(), []int{7} 635 | } 636 | 637 | func (x *CompositeType) GetName() string { 638 | if x != nil { 639 | return x.Name 640 | } 641 | return "" 642 | } 643 | 644 | func (x *CompositeType) GetComment() string { 645 | if x != nil { 646 | return x.Comment 647 | } 648 | return "" 649 | } 650 | 651 | type Enum struct { 652 | state protoimpl.MessageState 653 | sizeCache protoimpl.SizeCache 654 | unknownFields protoimpl.UnknownFields 655 | 656 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 657 | Vals []string `protobuf:"bytes,2,rep,name=vals,proto3" json:"vals,omitempty"` 658 | Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` 659 | } 660 | 661 | func (x *Enum) Reset() { 662 | *x = Enum{} 663 | if protoimpl.UnsafeEnabled { 664 | mi := &file_plugin_codegen_proto_msgTypes[8] 665 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 666 | ms.StoreMessageInfo(mi) 667 | } 668 | } 669 | 670 | func (x *Enum) String() string { 671 | return protoimpl.X.MessageStringOf(x) 672 | } 673 | 674 | func (*Enum) ProtoMessage() {} 675 | 676 | func (x *Enum) ProtoReflect() protoreflect.Message { 677 | mi := &file_plugin_codegen_proto_msgTypes[8] 678 | if protoimpl.UnsafeEnabled && x != nil { 679 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 680 | if ms.LoadMessageInfo() == nil { 681 | ms.StoreMessageInfo(mi) 682 | } 683 | return ms 684 | } 685 | return mi.MessageOf(x) 686 | } 687 | 688 | // Deprecated: Use Enum.ProtoReflect.Descriptor instead. 689 | func (*Enum) Descriptor() ([]byte, []int) { 690 | return file_plugin_codegen_proto_rawDescGZIP(), []int{8} 691 | } 692 | 693 | func (x *Enum) GetName() string { 694 | if x != nil { 695 | return x.Name 696 | } 697 | return "" 698 | } 699 | 700 | func (x *Enum) GetVals() []string { 701 | if x != nil { 702 | return x.Vals 703 | } 704 | return nil 705 | } 706 | 707 | func (x *Enum) GetComment() string { 708 | if x != nil { 709 | return x.Comment 710 | } 711 | return "" 712 | } 713 | 714 | type Table struct { 715 | state protoimpl.MessageState 716 | sizeCache protoimpl.SizeCache 717 | unknownFields protoimpl.UnknownFields 718 | 719 | Rel *Identifier `protobuf:"bytes,1,opt,name=rel,proto3" json:"rel,omitempty"` 720 | Columns []*Column `protobuf:"bytes,2,rep,name=columns,proto3" json:"columns,omitempty"` 721 | Comment string `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` 722 | } 723 | 724 | func (x *Table) Reset() { 725 | *x = Table{} 726 | if protoimpl.UnsafeEnabled { 727 | mi := &file_plugin_codegen_proto_msgTypes[9] 728 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 729 | ms.StoreMessageInfo(mi) 730 | } 731 | } 732 | 733 | func (x *Table) String() string { 734 | return protoimpl.X.MessageStringOf(x) 735 | } 736 | 737 | func (*Table) ProtoMessage() {} 738 | 739 | func (x *Table) ProtoReflect() protoreflect.Message { 740 | mi := &file_plugin_codegen_proto_msgTypes[9] 741 | if protoimpl.UnsafeEnabled && x != nil { 742 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 743 | if ms.LoadMessageInfo() == nil { 744 | ms.StoreMessageInfo(mi) 745 | } 746 | return ms 747 | } 748 | return mi.MessageOf(x) 749 | } 750 | 751 | // Deprecated: Use Table.ProtoReflect.Descriptor instead. 752 | func (*Table) Descriptor() ([]byte, []int) { 753 | return file_plugin_codegen_proto_rawDescGZIP(), []int{9} 754 | } 755 | 756 | func (x *Table) GetRel() *Identifier { 757 | if x != nil { 758 | return x.Rel 759 | } 760 | return nil 761 | } 762 | 763 | func (x *Table) GetColumns() []*Column { 764 | if x != nil { 765 | return x.Columns 766 | } 767 | return nil 768 | } 769 | 770 | func (x *Table) GetComment() string { 771 | if x != nil { 772 | return x.Comment 773 | } 774 | return "" 775 | } 776 | 777 | type Identifier struct { 778 | state protoimpl.MessageState 779 | sizeCache protoimpl.SizeCache 780 | unknownFields protoimpl.UnknownFields 781 | 782 | Catalog string `protobuf:"bytes,1,opt,name=catalog,proto3" json:"catalog,omitempty"` 783 | Schema string `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` 784 | Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` 785 | } 786 | 787 | func (x *Identifier) Reset() { 788 | *x = Identifier{} 789 | if protoimpl.UnsafeEnabled { 790 | mi := &file_plugin_codegen_proto_msgTypes[10] 791 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 792 | ms.StoreMessageInfo(mi) 793 | } 794 | } 795 | 796 | func (x *Identifier) String() string { 797 | return protoimpl.X.MessageStringOf(x) 798 | } 799 | 800 | func (*Identifier) ProtoMessage() {} 801 | 802 | func (x *Identifier) ProtoReflect() protoreflect.Message { 803 | mi := &file_plugin_codegen_proto_msgTypes[10] 804 | if protoimpl.UnsafeEnabled && x != nil { 805 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 806 | if ms.LoadMessageInfo() == nil { 807 | ms.StoreMessageInfo(mi) 808 | } 809 | return ms 810 | } 811 | return mi.MessageOf(x) 812 | } 813 | 814 | // Deprecated: Use Identifier.ProtoReflect.Descriptor instead. 815 | func (*Identifier) Descriptor() ([]byte, []int) { 816 | return file_plugin_codegen_proto_rawDescGZIP(), []int{10} 817 | } 818 | 819 | func (x *Identifier) GetCatalog() string { 820 | if x != nil { 821 | return x.Catalog 822 | } 823 | return "" 824 | } 825 | 826 | func (x *Identifier) GetSchema() string { 827 | if x != nil { 828 | return x.Schema 829 | } 830 | return "" 831 | } 832 | 833 | func (x *Identifier) GetName() string { 834 | if x != nil { 835 | return x.Name 836 | } 837 | return "" 838 | } 839 | 840 | type Column struct { 841 | state protoimpl.MessageState 842 | sizeCache protoimpl.SizeCache 843 | unknownFields protoimpl.UnknownFields 844 | 845 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 846 | NotNull bool `protobuf:"varint,3,opt,name=not_null,json=notNull,proto3" json:"not_null,omitempty"` 847 | IsArray bool `protobuf:"varint,4,opt,name=is_array,json=isArray,proto3" json:"is_array,omitempty"` 848 | Comment string `protobuf:"bytes,5,opt,name=comment,proto3" json:"comment,omitempty"` 849 | Length int32 `protobuf:"varint,6,opt,name=length,proto3" json:"length,omitempty"` 850 | IsNamedParam bool `protobuf:"varint,7,opt,name=is_named_param,json=isNamedParam,proto3" json:"is_named_param,omitempty"` 851 | IsFuncCall bool `protobuf:"varint,8,opt,name=is_func_call,json=isFuncCall,proto3" json:"is_func_call,omitempty"` 852 | // XXX: Figure out what PostgreSQL calls `foo.id` 853 | Scope string `protobuf:"bytes,9,opt,name=scope,proto3" json:"scope,omitempty"` 854 | Table *Identifier `protobuf:"bytes,10,opt,name=table,proto3" json:"table,omitempty"` 855 | TableAlias string `protobuf:"bytes,11,opt,name=table_alias,json=tableAlias,proto3" json:"table_alias,omitempty"` 856 | Type *Identifier `protobuf:"bytes,12,opt,name=type,proto3" json:"type,omitempty"` 857 | IsSqlcSlice bool `protobuf:"varint,13,opt,name=is_sqlc_slice,json=isSqlcSlice,proto3" json:"is_sqlc_slice,omitempty"` 858 | EmbedTable *Identifier `protobuf:"bytes,14,opt,name=embed_table,json=embedTable,proto3" json:"embed_table,omitempty"` 859 | OriginalName string `protobuf:"bytes,15,opt,name=original_name,json=originalName,proto3" json:"original_name,omitempty"` 860 | Unsigned bool `protobuf:"varint,16,opt,name=unsigned,proto3" json:"unsigned,omitempty"` 861 | ArrayDims int32 `protobuf:"varint,17,opt,name=array_dims,json=arrayDims,proto3" json:"array_dims,omitempty"` 862 | } 863 | 864 | func (x *Column) Reset() { 865 | *x = Column{} 866 | if protoimpl.UnsafeEnabled { 867 | mi := &file_plugin_codegen_proto_msgTypes[11] 868 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 869 | ms.StoreMessageInfo(mi) 870 | } 871 | } 872 | 873 | func (x *Column) String() string { 874 | return protoimpl.X.MessageStringOf(x) 875 | } 876 | 877 | func (*Column) ProtoMessage() {} 878 | 879 | func (x *Column) ProtoReflect() protoreflect.Message { 880 | mi := &file_plugin_codegen_proto_msgTypes[11] 881 | if protoimpl.UnsafeEnabled && x != nil { 882 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 883 | if ms.LoadMessageInfo() == nil { 884 | ms.StoreMessageInfo(mi) 885 | } 886 | return ms 887 | } 888 | return mi.MessageOf(x) 889 | } 890 | 891 | // Deprecated: Use Column.ProtoReflect.Descriptor instead. 892 | func (*Column) Descriptor() ([]byte, []int) { 893 | return file_plugin_codegen_proto_rawDescGZIP(), []int{11} 894 | } 895 | 896 | func (x *Column) GetName() string { 897 | if x != nil { 898 | return x.Name 899 | } 900 | return "" 901 | } 902 | 903 | func (x *Column) GetNotNull() bool { 904 | if x != nil { 905 | return x.NotNull 906 | } 907 | return false 908 | } 909 | 910 | func (x *Column) GetIsArray() bool { 911 | if x != nil { 912 | return x.IsArray 913 | } 914 | return false 915 | } 916 | 917 | func (x *Column) GetComment() string { 918 | if x != nil { 919 | return x.Comment 920 | } 921 | return "" 922 | } 923 | 924 | func (x *Column) GetLength() int32 { 925 | if x != nil { 926 | return x.Length 927 | } 928 | return 0 929 | } 930 | 931 | func (x *Column) GetIsNamedParam() bool { 932 | if x != nil { 933 | return x.IsNamedParam 934 | } 935 | return false 936 | } 937 | 938 | func (x *Column) GetIsFuncCall() bool { 939 | if x != nil { 940 | return x.IsFuncCall 941 | } 942 | return false 943 | } 944 | 945 | func (x *Column) GetScope() string { 946 | if x != nil { 947 | return x.Scope 948 | } 949 | return "" 950 | } 951 | 952 | func (x *Column) GetTable() *Identifier { 953 | if x != nil { 954 | return x.Table 955 | } 956 | return nil 957 | } 958 | 959 | func (x *Column) GetTableAlias() string { 960 | if x != nil { 961 | return x.TableAlias 962 | } 963 | return "" 964 | } 965 | 966 | func (x *Column) GetType() *Identifier { 967 | if x != nil { 968 | return x.Type 969 | } 970 | return nil 971 | } 972 | 973 | func (x *Column) GetIsSqlcSlice() bool { 974 | if x != nil { 975 | return x.IsSqlcSlice 976 | } 977 | return false 978 | } 979 | 980 | func (x *Column) GetEmbedTable() *Identifier { 981 | if x != nil { 982 | return x.EmbedTable 983 | } 984 | return nil 985 | } 986 | 987 | func (x *Column) GetOriginalName() string { 988 | if x != nil { 989 | return x.OriginalName 990 | } 991 | return "" 992 | } 993 | 994 | func (x *Column) GetUnsigned() bool { 995 | if x != nil { 996 | return x.Unsigned 997 | } 998 | return false 999 | } 1000 | 1001 | func (x *Column) GetArrayDims() int32 { 1002 | if x != nil { 1003 | return x.ArrayDims 1004 | } 1005 | return 0 1006 | } 1007 | 1008 | type Query struct { 1009 | state protoimpl.MessageState 1010 | sizeCache protoimpl.SizeCache 1011 | unknownFields protoimpl.UnknownFields 1012 | 1013 | Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` 1014 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 1015 | Cmd string `protobuf:"bytes,3,opt,name=cmd,proto3" json:"cmd,omitempty"` 1016 | Columns []*Column `protobuf:"bytes,4,rep,name=columns,proto3" json:"columns,omitempty"` 1017 | Params []*Parameter `protobuf:"bytes,5,rep,name=params,json=parameters,proto3" json:"params,omitempty"` 1018 | Comments []string `protobuf:"bytes,6,rep,name=comments,proto3" json:"comments,omitempty"` 1019 | Filename string `protobuf:"bytes,7,opt,name=filename,proto3" json:"filename,omitempty"` 1020 | InsertIntoTable *Identifier `protobuf:"bytes,8,opt,name=insert_into_table,proto3" json:"insert_into_table,omitempty"` 1021 | } 1022 | 1023 | func (x *Query) Reset() { 1024 | *x = Query{} 1025 | if protoimpl.UnsafeEnabled { 1026 | mi := &file_plugin_codegen_proto_msgTypes[12] 1027 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1028 | ms.StoreMessageInfo(mi) 1029 | } 1030 | } 1031 | 1032 | func (x *Query) String() string { 1033 | return protoimpl.X.MessageStringOf(x) 1034 | } 1035 | 1036 | func (*Query) ProtoMessage() {} 1037 | 1038 | func (x *Query) ProtoReflect() protoreflect.Message { 1039 | mi := &file_plugin_codegen_proto_msgTypes[12] 1040 | if protoimpl.UnsafeEnabled && x != nil { 1041 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1042 | if ms.LoadMessageInfo() == nil { 1043 | ms.StoreMessageInfo(mi) 1044 | } 1045 | return ms 1046 | } 1047 | return mi.MessageOf(x) 1048 | } 1049 | 1050 | // Deprecated: Use Query.ProtoReflect.Descriptor instead. 1051 | func (*Query) Descriptor() ([]byte, []int) { 1052 | return file_plugin_codegen_proto_rawDescGZIP(), []int{12} 1053 | } 1054 | 1055 | func (x *Query) GetText() string { 1056 | if x != nil { 1057 | return x.Text 1058 | } 1059 | return "" 1060 | } 1061 | 1062 | func (x *Query) GetName() string { 1063 | if x != nil { 1064 | return x.Name 1065 | } 1066 | return "" 1067 | } 1068 | 1069 | func (x *Query) GetCmd() string { 1070 | if x != nil { 1071 | return x.Cmd 1072 | } 1073 | return "" 1074 | } 1075 | 1076 | func (x *Query) GetColumns() []*Column { 1077 | if x != nil { 1078 | return x.Columns 1079 | } 1080 | return nil 1081 | } 1082 | 1083 | func (x *Query) GetParams() []*Parameter { 1084 | if x != nil { 1085 | return x.Params 1086 | } 1087 | return nil 1088 | } 1089 | 1090 | func (x *Query) GetComments() []string { 1091 | if x != nil { 1092 | return x.Comments 1093 | } 1094 | return nil 1095 | } 1096 | 1097 | func (x *Query) GetFilename() string { 1098 | if x != nil { 1099 | return x.Filename 1100 | } 1101 | return "" 1102 | } 1103 | 1104 | func (x *Query) GetInsertIntoTable() *Identifier { 1105 | if x != nil { 1106 | return x.InsertIntoTable 1107 | } 1108 | return nil 1109 | } 1110 | 1111 | type Parameter struct { 1112 | state protoimpl.MessageState 1113 | sizeCache protoimpl.SizeCache 1114 | unknownFields protoimpl.UnknownFields 1115 | 1116 | Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` 1117 | Column *Column `protobuf:"bytes,2,opt,name=column,proto3" json:"column,omitempty"` 1118 | } 1119 | 1120 | func (x *Parameter) Reset() { 1121 | *x = Parameter{} 1122 | if protoimpl.UnsafeEnabled { 1123 | mi := &file_plugin_codegen_proto_msgTypes[13] 1124 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1125 | ms.StoreMessageInfo(mi) 1126 | } 1127 | } 1128 | 1129 | func (x *Parameter) String() string { 1130 | return protoimpl.X.MessageStringOf(x) 1131 | } 1132 | 1133 | func (*Parameter) ProtoMessage() {} 1134 | 1135 | func (x *Parameter) ProtoReflect() protoreflect.Message { 1136 | mi := &file_plugin_codegen_proto_msgTypes[13] 1137 | if protoimpl.UnsafeEnabled && x != nil { 1138 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1139 | if ms.LoadMessageInfo() == nil { 1140 | ms.StoreMessageInfo(mi) 1141 | } 1142 | return ms 1143 | } 1144 | return mi.MessageOf(x) 1145 | } 1146 | 1147 | // Deprecated: Use Parameter.ProtoReflect.Descriptor instead. 1148 | func (*Parameter) Descriptor() ([]byte, []int) { 1149 | return file_plugin_codegen_proto_rawDescGZIP(), []int{13} 1150 | } 1151 | 1152 | func (x *Parameter) GetNumber() int32 { 1153 | if x != nil { 1154 | return x.Number 1155 | } 1156 | return 0 1157 | } 1158 | 1159 | func (x *Parameter) GetColumn() *Column { 1160 | if x != nil { 1161 | return x.Column 1162 | } 1163 | return nil 1164 | } 1165 | 1166 | type CodeGenRequest struct { 1167 | state protoimpl.MessageState 1168 | sizeCache protoimpl.SizeCache 1169 | unknownFields protoimpl.UnknownFields 1170 | 1171 | Settings *Settings `protobuf:"bytes,1,opt,name=settings,proto3" json:"settings,omitempty"` 1172 | Catalog *Catalog `protobuf:"bytes,2,opt,name=catalog,proto3" json:"catalog,omitempty"` 1173 | Queries []*Query `protobuf:"bytes,3,rep,name=queries,proto3" json:"queries,omitempty"` 1174 | SqlcVersion string `protobuf:"bytes,4,opt,name=sqlc_version,proto3" json:"sqlc_version,omitempty"` 1175 | PluginOptions []byte `protobuf:"bytes,5,opt,name=plugin_options,proto3" json:"plugin_options,omitempty"` 1176 | } 1177 | 1178 | func (x *CodeGenRequest) Reset() { 1179 | *x = CodeGenRequest{} 1180 | if protoimpl.UnsafeEnabled { 1181 | mi := &file_plugin_codegen_proto_msgTypes[14] 1182 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1183 | ms.StoreMessageInfo(mi) 1184 | } 1185 | } 1186 | 1187 | func (x *CodeGenRequest) String() string { 1188 | return protoimpl.X.MessageStringOf(x) 1189 | } 1190 | 1191 | func (*CodeGenRequest) ProtoMessage() {} 1192 | 1193 | func (x *CodeGenRequest) ProtoReflect() protoreflect.Message { 1194 | mi := &file_plugin_codegen_proto_msgTypes[14] 1195 | if protoimpl.UnsafeEnabled && x != nil { 1196 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1197 | if ms.LoadMessageInfo() == nil { 1198 | ms.StoreMessageInfo(mi) 1199 | } 1200 | return ms 1201 | } 1202 | return mi.MessageOf(x) 1203 | } 1204 | 1205 | // Deprecated: Use CodeGenRequest.ProtoReflect.Descriptor instead. 1206 | func (*CodeGenRequest) Descriptor() ([]byte, []int) { 1207 | return file_plugin_codegen_proto_rawDescGZIP(), []int{14} 1208 | } 1209 | 1210 | func (x *CodeGenRequest) GetSettings() *Settings { 1211 | if x != nil { 1212 | return x.Settings 1213 | } 1214 | return nil 1215 | } 1216 | 1217 | func (x *CodeGenRequest) GetCatalog() *Catalog { 1218 | if x != nil { 1219 | return x.Catalog 1220 | } 1221 | return nil 1222 | } 1223 | 1224 | func (x *CodeGenRequest) GetQueries() []*Query { 1225 | if x != nil { 1226 | return x.Queries 1227 | } 1228 | return nil 1229 | } 1230 | 1231 | func (x *CodeGenRequest) GetSqlcVersion() string { 1232 | if x != nil { 1233 | return x.SqlcVersion 1234 | } 1235 | return "" 1236 | } 1237 | 1238 | func (x *CodeGenRequest) GetPluginOptions() []byte { 1239 | if x != nil { 1240 | return x.PluginOptions 1241 | } 1242 | return nil 1243 | } 1244 | 1245 | type CodeGenResponse struct { 1246 | state protoimpl.MessageState 1247 | sizeCache protoimpl.SizeCache 1248 | unknownFields protoimpl.UnknownFields 1249 | 1250 | Files []*File `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"` 1251 | } 1252 | 1253 | func (x *CodeGenResponse) Reset() { 1254 | *x = CodeGenResponse{} 1255 | if protoimpl.UnsafeEnabled { 1256 | mi := &file_plugin_codegen_proto_msgTypes[15] 1257 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1258 | ms.StoreMessageInfo(mi) 1259 | } 1260 | } 1261 | 1262 | func (x *CodeGenResponse) String() string { 1263 | return protoimpl.X.MessageStringOf(x) 1264 | } 1265 | 1266 | func (*CodeGenResponse) ProtoMessage() {} 1267 | 1268 | func (x *CodeGenResponse) ProtoReflect() protoreflect.Message { 1269 | mi := &file_plugin_codegen_proto_msgTypes[15] 1270 | if protoimpl.UnsafeEnabled && x != nil { 1271 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1272 | if ms.LoadMessageInfo() == nil { 1273 | ms.StoreMessageInfo(mi) 1274 | } 1275 | return ms 1276 | } 1277 | return mi.MessageOf(x) 1278 | } 1279 | 1280 | // Deprecated: Use CodeGenResponse.ProtoReflect.Descriptor instead. 1281 | func (*CodeGenResponse) Descriptor() ([]byte, []int) { 1282 | return file_plugin_codegen_proto_rawDescGZIP(), []int{15} 1283 | } 1284 | 1285 | func (x *CodeGenResponse) GetFiles() []*File { 1286 | if x != nil { 1287 | return x.Files 1288 | } 1289 | return nil 1290 | } 1291 | 1292 | type Codegen_Process struct { 1293 | state protoimpl.MessageState 1294 | sizeCache protoimpl.SizeCache 1295 | unknownFields protoimpl.UnknownFields 1296 | 1297 | Cmd string `protobuf:"bytes,1,opt,name=cmd,proto3" json:"cmd,omitempty"` 1298 | } 1299 | 1300 | func (x *Codegen_Process) Reset() { 1301 | *x = Codegen_Process{} 1302 | if protoimpl.UnsafeEnabled { 1303 | mi := &file_plugin_codegen_proto_msgTypes[18] 1304 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1305 | ms.StoreMessageInfo(mi) 1306 | } 1307 | } 1308 | 1309 | func (x *Codegen_Process) String() string { 1310 | return protoimpl.X.MessageStringOf(x) 1311 | } 1312 | 1313 | func (*Codegen_Process) ProtoMessage() {} 1314 | 1315 | func (x *Codegen_Process) ProtoReflect() protoreflect.Message { 1316 | mi := &file_plugin_codegen_proto_msgTypes[18] 1317 | if protoimpl.UnsafeEnabled && x != nil { 1318 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1319 | if ms.LoadMessageInfo() == nil { 1320 | ms.StoreMessageInfo(mi) 1321 | } 1322 | return ms 1323 | } 1324 | return mi.MessageOf(x) 1325 | } 1326 | 1327 | // Deprecated: Use Codegen_Process.ProtoReflect.Descriptor instead. 1328 | func (*Codegen_Process) Descriptor() ([]byte, []int) { 1329 | return file_plugin_codegen_proto_rawDescGZIP(), []int{4, 0} 1330 | } 1331 | 1332 | func (x *Codegen_Process) GetCmd() string { 1333 | if x != nil { 1334 | return x.Cmd 1335 | } 1336 | return "" 1337 | } 1338 | 1339 | type Codegen_WASM struct { 1340 | state protoimpl.MessageState 1341 | sizeCache protoimpl.SizeCache 1342 | unknownFields protoimpl.UnknownFields 1343 | 1344 | Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` 1345 | Sha256 string `protobuf:"bytes,2,opt,name=sha256,proto3" json:"sha256,omitempty"` 1346 | } 1347 | 1348 | func (x *Codegen_WASM) Reset() { 1349 | *x = Codegen_WASM{} 1350 | if protoimpl.UnsafeEnabled { 1351 | mi := &file_plugin_codegen_proto_msgTypes[19] 1352 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1353 | ms.StoreMessageInfo(mi) 1354 | } 1355 | } 1356 | 1357 | func (x *Codegen_WASM) String() string { 1358 | return protoimpl.X.MessageStringOf(x) 1359 | } 1360 | 1361 | func (*Codegen_WASM) ProtoMessage() {} 1362 | 1363 | func (x *Codegen_WASM) ProtoReflect() protoreflect.Message { 1364 | mi := &file_plugin_codegen_proto_msgTypes[19] 1365 | if protoimpl.UnsafeEnabled && x != nil { 1366 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 1367 | if ms.LoadMessageInfo() == nil { 1368 | ms.StoreMessageInfo(mi) 1369 | } 1370 | return ms 1371 | } 1372 | return mi.MessageOf(x) 1373 | } 1374 | 1375 | // Deprecated: Use Codegen_WASM.ProtoReflect.Descriptor instead. 1376 | func (*Codegen_WASM) Descriptor() ([]byte, []int) { 1377 | return file_plugin_codegen_proto_rawDescGZIP(), []int{4, 1} 1378 | } 1379 | 1380 | func (x *Codegen_WASM) GetUrl() string { 1381 | if x != nil { 1382 | return x.Url 1383 | } 1384 | return "" 1385 | } 1386 | 1387 | func (x *Codegen_WASM) GetSha256() string { 1388 | if x != nil { 1389 | return x.Sha256 1390 | } 1391 | return "" 1392 | } 1393 | 1394 | var File_plugin_codegen_proto protoreflect.FileDescriptor 1395 | 1396 | var file_plugin_codegen_proto_rawDesc = []byte{ 1397 | 0x0a, 0x14, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 1398 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x36, 1399 | 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 1400 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 1401 | 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6f, 1402 | 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x93, 0x02, 0x0a, 0x08, 0x4f, 0x76, 0x65, 0x72, 0x72, 1403 | 0x69, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 1404 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 1405 | 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 1406 | 0x28, 0x09, 0x52, 0x07, 0x64, 0x62, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 1407 | 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6e, 1408 | 0x75, 0x6c, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 1409 | 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 1410 | 0x28, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 1411 | 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 1412 | 0x65, 0x72, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6c, 1413 | 0x75, 0x6d, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 1414 | 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x67, 1415 | 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 1416 | 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x64, 0x47, 0x6f, 0x54, 0x79, 1417 | 0x70, 0x65, 0x52, 0x06, 0x67, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 1418 | 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x75, 0x6e, 1419 | 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x22, 0x8b, 0x02, 0x0a, 1420 | 0x0c, 0x50, 0x61, 0x72, 0x73, 0x65, 0x64, 0x47, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 1421 | 0x0b, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 1422 | 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 1423 | 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 1424 | 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 1425 | 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 1426 | 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x61, 0x73, 0x69, 0x63, 0x5f, 0x74, 1427 | 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x61, 0x73, 0x69, 0x63, 1428 | 0x54, 0x79, 0x70, 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x74, 1429 | 0x61, 0x67, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x70, 0x6c, 0x75, 0x67, 1430 | 0x69, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x64, 0x47, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x2e, 1431 | 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 1432 | 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x54, 0x61, 0x67, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x53, 1433 | 0x74, 0x72, 0x75, 0x63, 0x74, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 1434 | 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 1435 | 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 1436 | 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xd2, 0x02, 0x0a, 0x08, 0x53, 1437 | 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 1438 | 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 1439 | 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 1440 | 0x09, 0x52, 0x06, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 1441 | 0x65, 0x6d, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 1442 | 0x61, 0x12, 0x18, 0x0a, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 1443 | 0x28, 0x09, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x06, 0x72, 1444 | 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x6c, 1445 | 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x2e, 0x52, 0x65, 1446 | 0x6e, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x6e, 0x61, 0x6d, 1447 | 0x65, 0x12, 0x2e, 0x0a, 0x09, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x73, 0x18, 0x06, 1448 | 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x4f, 0x76, 1449 | 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x09, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 1450 | 0x73, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x01, 1451 | 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 1452 | 0x67, 0x65, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x1a, 0x39, 0x0a, 0x0b, 1453 | 0x52, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 1454 | 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 1455 | 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 1456 | 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 1457 | 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x0c, 0x22, 1458 | 0x8b, 0x02, 0x0a, 0x07, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6f, 1459 | 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 1460 | 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 1461 | 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 1462 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 1463 | 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x65, 0x6e, 1464 | 0x76, 0x12, 0x31, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 1465 | 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 1466 | 0x67, 0x65, 0x6e, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x52, 0x07, 0x70, 0x72, 0x6f, 1467 | 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x18, 0x06, 0x20, 0x01, 1468 | 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x64, 0x65, 1469 | 0x67, 0x65, 0x6e, 0x2e, 0x57, 0x41, 0x53, 0x4d, 0x52, 0x04, 0x77, 0x61, 0x73, 0x6d, 0x1a, 0x1b, 1470 | 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 1471 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 0x64, 0x1a, 0x30, 0x0a, 0x04, 0x57, 1472 | 0x41, 0x53, 0x4d, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 1473 | 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 1474 | 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x22, 0x88, 0x01, 1475 | 0x0a, 0x07, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 1476 | 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 1477 | 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 1478 | 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 1479 | 0x61, 0x75, 0x6c, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 1480 | 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 1481 | 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 1482 | 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 1483 | 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x68, 1484 | 0x65, 0x6d, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 1485 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 1486 | 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 1487 | 0x65, 0x12, 0x25, 0x0a, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 1488 | 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 1489 | 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x6e, 0x75, 0x6d, 1490 | 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 1491 | 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x12, 0x3e, 0x0a, 0x0f, 1492 | 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 1493 | 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 1494 | 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0e, 0x63, 0x6f, 1495 | 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x3d, 0x0a, 0x0d, 1496 | 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 1497 | 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 1498 | 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 1499 | 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x48, 0x0a, 0x04, 0x45, 1500 | 0x6e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 1501 | 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 1502 | 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 1503 | 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 1504 | 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x71, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x24, 1505 | 0x0a, 0x03, 0x72, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 1506 | 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 1507 | 0x03, 0x72, 0x65, 0x6c, 0x12, 0x28, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 1508 | 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 1509 | 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x18, 1510 | 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 1511 | 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x52, 0x0a, 0x0a, 0x49, 0x64, 0x65, 0x6e, 1512 | 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 1513 | 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 1514 | 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 1515 | 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 1516 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8e, 0x04, 0x0a, 1517 | 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 1518 | 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 1519 | 0x6f, 0x74, 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 1520 | 0x6f, 0x74, 0x4e, 0x75, 0x6c, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x72, 0x72, 1521 | 0x61, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x72, 0x72, 0x61, 1522 | 0x79, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 1523 | 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6c, 1524 | 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 1525 | 0x67, 0x74, 0x68, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x73, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x64, 0x5f, 1526 | 0x70, 0x61, 0x72, 0x61, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x69, 0x73, 0x4e, 1527 | 0x61, 0x6d, 0x65, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x20, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 1528 | 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 1529 | 0x0a, 0x69, 0x73, 0x46, 0x75, 0x6e, 0x63, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x73, 1530 | 0x63, 0x6f, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 1531 | 0x65, 0x12, 0x28, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 1532 | 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 1533 | 0x66, 0x69, 0x65, 0x72, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 1534 | 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 1535 | 0x52, 0x0a, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x26, 0x0a, 0x04, 1536 | 0x74, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x75, 1537 | 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x04, 1538 | 0x74, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x69, 0x73, 0x5f, 0x73, 0x71, 0x6c, 0x63, 0x5f, 1539 | 0x73, 0x6c, 0x69, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x53, 1540 | 0x71, 0x6c, 0x63, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x12, 0x33, 0x0a, 0x0b, 0x65, 0x6d, 0x62, 0x65, 1541 | 0x64, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 1542 | 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 1543 | 0x72, 0x52, 0x0a, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x23, 0x0a, 1544 | 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0f, 1545 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 1546 | 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, 0x10, 1547 | 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x75, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, 0x1d, 1548 | 0x0a, 0x0a, 0x61, 0x72, 0x72, 0x61, 0x79, 0x5f, 0x64, 0x69, 0x6d, 0x73, 0x18, 0x11, 0x20, 0x01, 1549 | 0x28, 0x05, 0x52, 0x09, 0x61, 0x72, 0x72, 0x61, 0x79, 0x44, 0x69, 0x6d, 0x73, 0x22, 0x94, 0x02, 1550 | 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 1551 | 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 1552 | 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 1553 | 0x10, 0x0a, 0x03, 0x63, 0x6d, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x6d, 1554 | 0x64, 0x12, 0x28, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 1555 | 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 1556 | 0x6d, 0x6e, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x70, 1557 | 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x6c, 1558 | 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x0a, 1559 | 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 1560 | 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 1561 | 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 1562 | 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 1563 | 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x11, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 1564 | 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 1565 | 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 1566 | 0x72, 0x52, 0x11, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x6f, 0x5f, 0x74, 1567 | 0x61, 0x62, 0x6c, 0x65, 0x22, 0x4b, 0x0a, 0x09, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 1568 | 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 1569 | 0x05, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 1570 | 0x75, 0x6d, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x6c, 0x75, 0x67, 1571 | 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 1572 | 0x6e, 0x22, 0xde, 0x01, 0x0a, 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x52, 0x65, 0x71, 1573 | 0x75, 0x65, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 1574 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 1575 | 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 1576 | 0x67, 0x73, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x18, 0x02, 0x20, 1577 | 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x43, 0x61, 0x74, 1578 | 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x07, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x27, 0x0a, 1579 | 0x07, 0x71, 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 1580 | 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x07, 0x71, 1581 | 0x75, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x71, 0x6c, 0x63, 0x5f, 0x76, 1582 | 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x71, 1583 | 0x6c, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x6c, 1584 | 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 1585 | 0x28, 0x0c, 0x52, 0x0e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 1586 | 0x6e, 0x73, 0x22, 0x35, 0x0a, 0x0f, 0x43, 0x6f, 0x64, 0x65, 0x47, 0x65, 0x6e, 0x52, 0x65, 0x73, 1587 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 1588 | 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x46, 0x69, 1589 | 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x42, 0x8c, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 1590 | 0x6d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x42, 0x0c, 0x43, 0x6f, 0x64, 0x65, 0x67, 0x65, 1591 | 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 1592 | 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x72, 0x69, 0x73, 0x61, 0x6e, 0x6f, 0x2f, 0x73, 0x71, 0x6c, 1593 | 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 1594 | 0x2d, 0x64, 0x31, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 1595 | 0x69, 0x6e, 0xa2, 0x02, 0x03, 0x50, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 1596 | 0x6e, 0xca, 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0xe2, 0x02, 0x12, 0x50, 0x6c, 0x75, 1597 | 0x67, 0x69, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 1598 | 0x02, 0x06, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 1599 | } 1600 | 1601 | var ( 1602 | file_plugin_codegen_proto_rawDescOnce sync.Once 1603 | file_plugin_codegen_proto_rawDescData = file_plugin_codegen_proto_rawDesc 1604 | ) 1605 | 1606 | func file_plugin_codegen_proto_rawDescGZIP() []byte { 1607 | file_plugin_codegen_proto_rawDescOnce.Do(func() { 1608 | file_plugin_codegen_proto_rawDescData = protoimpl.X.CompressGZIP(file_plugin_codegen_proto_rawDescData) 1609 | }) 1610 | return file_plugin_codegen_proto_rawDescData 1611 | } 1612 | 1613 | var file_plugin_codegen_proto_msgTypes = make([]protoimpl.MessageInfo, 20) 1614 | var file_plugin_codegen_proto_goTypes = []interface{}{ 1615 | (*File)(nil), // 0: plugin.File 1616 | (*Override)(nil), // 1: plugin.Override 1617 | (*ParsedGoType)(nil), // 2: plugin.ParsedGoType 1618 | (*Settings)(nil), // 3: plugin.Settings 1619 | (*Codegen)(nil), // 4: plugin.Codegen 1620 | (*Catalog)(nil), // 5: plugin.Catalog 1621 | (*Schema)(nil), // 6: plugin.Schema 1622 | (*CompositeType)(nil), // 7: plugin.CompositeType 1623 | (*Enum)(nil), // 8: plugin.Enum 1624 | (*Table)(nil), // 9: plugin.Table 1625 | (*Identifier)(nil), // 10: plugin.Identifier 1626 | (*Column)(nil), // 11: plugin.Column 1627 | (*Query)(nil), // 12: plugin.Query 1628 | (*Parameter)(nil), // 13: plugin.Parameter 1629 | (*CodeGenRequest)(nil), // 14: plugin.CodeGenRequest 1630 | (*CodeGenResponse)(nil), // 15: plugin.CodeGenResponse 1631 | nil, // 16: plugin.ParsedGoType.StructTagsEntry 1632 | nil, // 17: plugin.Settings.RenameEntry 1633 | (*Codegen_Process)(nil), // 18: plugin.Codegen.Process 1634 | (*Codegen_WASM)(nil), // 19: plugin.Codegen.WASM 1635 | } 1636 | var file_plugin_codegen_proto_depIdxs = []int32{ 1637 | 10, // 0: plugin.Override.table:type_name -> plugin.Identifier 1638 | 2, // 1: plugin.Override.go_type:type_name -> plugin.ParsedGoType 1639 | 16, // 2: plugin.ParsedGoType.struct_tags:type_name -> plugin.ParsedGoType.StructTagsEntry 1640 | 17, // 3: plugin.Settings.rename:type_name -> plugin.Settings.RenameEntry 1641 | 1, // 4: plugin.Settings.overrides:type_name -> plugin.Override 1642 | 4, // 5: plugin.Settings.codegen:type_name -> plugin.Codegen 1643 | 18, // 6: plugin.Codegen.process:type_name -> plugin.Codegen.Process 1644 | 19, // 7: plugin.Codegen.wasm:type_name -> plugin.Codegen.WASM 1645 | 6, // 8: plugin.Catalog.schemas:type_name -> plugin.Schema 1646 | 9, // 9: plugin.Schema.tables:type_name -> plugin.Table 1647 | 8, // 10: plugin.Schema.enums:type_name -> plugin.Enum 1648 | 7, // 11: plugin.Schema.composite_types:type_name -> plugin.CompositeType 1649 | 10, // 12: plugin.Table.rel:type_name -> plugin.Identifier 1650 | 11, // 13: plugin.Table.columns:type_name -> plugin.Column 1651 | 10, // 14: plugin.Column.table:type_name -> plugin.Identifier 1652 | 10, // 15: plugin.Column.type:type_name -> plugin.Identifier 1653 | 10, // 16: plugin.Column.embed_table:type_name -> plugin.Identifier 1654 | 11, // 17: plugin.Query.columns:type_name -> plugin.Column 1655 | 13, // 18: plugin.Query.params:type_name -> plugin.Parameter 1656 | 10, // 19: plugin.Query.insert_into_table:type_name -> plugin.Identifier 1657 | 11, // 20: plugin.Parameter.column:type_name -> plugin.Column 1658 | 3, // 21: plugin.CodeGenRequest.settings:type_name -> plugin.Settings 1659 | 5, // 22: plugin.CodeGenRequest.catalog:type_name -> plugin.Catalog 1660 | 12, // 23: plugin.CodeGenRequest.queries:type_name -> plugin.Query 1661 | 0, // 24: plugin.CodeGenResponse.files:type_name -> plugin.File 1662 | 25, // [25:25] is the sub-list for method output_type 1663 | 25, // [25:25] is the sub-list for method input_type 1664 | 25, // [25:25] is the sub-list for extension type_name 1665 | 25, // [25:25] is the sub-list for extension extendee 1666 | 0, // [0:25] is the sub-list for field type_name 1667 | } 1668 | 1669 | func init() { file_plugin_codegen_proto_init() } 1670 | func file_plugin_codegen_proto_init() { 1671 | if File_plugin_codegen_proto != nil { 1672 | return 1673 | } 1674 | if !protoimpl.UnsafeEnabled { 1675 | file_plugin_codegen_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 1676 | switch v := v.(*File); i { 1677 | case 0: 1678 | return &v.state 1679 | case 1: 1680 | return &v.sizeCache 1681 | case 2: 1682 | return &v.unknownFields 1683 | default: 1684 | return nil 1685 | } 1686 | } 1687 | file_plugin_codegen_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 1688 | switch v := v.(*Override); i { 1689 | case 0: 1690 | return &v.state 1691 | case 1: 1692 | return &v.sizeCache 1693 | case 2: 1694 | return &v.unknownFields 1695 | default: 1696 | return nil 1697 | } 1698 | } 1699 | file_plugin_codegen_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 1700 | switch v := v.(*ParsedGoType); i { 1701 | case 0: 1702 | return &v.state 1703 | case 1: 1704 | return &v.sizeCache 1705 | case 2: 1706 | return &v.unknownFields 1707 | default: 1708 | return nil 1709 | } 1710 | } 1711 | file_plugin_codegen_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 1712 | switch v := v.(*Settings); i { 1713 | case 0: 1714 | return &v.state 1715 | case 1: 1716 | return &v.sizeCache 1717 | case 2: 1718 | return &v.unknownFields 1719 | default: 1720 | return nil 1721 | } 1722 | } 1723 | file_plugin_codegen_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 1724 | switch v := v.(*Codegen); i { 1725 | case 0: 1726 | return &v.state 1727 | case 1: 1728 | return &v.sizeCache 1729 | case 2: 1730 | return &v.unknownFields 1731 | default: 1732 | return nil 1733 | } 1734 | } 1735 | file_plugin_codegen_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 1736 | switch v := v.(*Catalog); i { 1737 | case 0: 1738 | return &v.state 1739 | case 1: 1740 | return &v.sizeCache 1741 | case 2: 1742 | return &v.unknownFields 1743 | default: 1744 | return nil 1745 | } 1746 | } 1747 | file_plugin_codegen_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 1748 | switch v := v.(*Schema); i { 1749 | case 0: 1750 | return &v.state 1751 | case 1: 1752 | return &v.sizeCache 1753 | case 2: 1754 | return &v.unknownFields 1755 | default: 1756 | return nil 1757 | } 1758 | } 1759 | file_plugin_codegen_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { 1760 | switch v := v.(*CompositeType); i { 1761 | case 0: 1762 | return &v.state 1763 | case 1: 1764 | return &v.sizeCache 1765 | case 2: 1766 | return &v.unknownFields 1767 | default: 1768 | return nil 1769 | } 1770 | } 1771 | file_plugin_codegen_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { 1772 | switch v := v.(*Enum); i { 1773 | case 0: 1774 | return &v.state 1775 | case 1: 1776 | return &v.sizeCache 1777 | case 2: 1778 | return &v.unknownFields 1779 | default: 1780 | return nil 1781 | } 1782 | } 1783 | file_plugin_codegen_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { 1784 | switch v := v.(*Table); i { 1785 | case 0: 1786 | return &v.state 1787 | case 1: 1788 | return &v.sizeCache 1789 | case 2: 1790 | return &v.unknownFields 1791 | default: 1792 | return nil 1793 | } 1794 | } 1795 | file_plugin_codegen_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { 1796 | switch v := v.(*Identifier); i { 1797 | case 0: 1798 | return &v.state 1799 | case 1: 1800 | return &v.sizeCache 1801 | case 2: 1802 | return &v.unknownFields 1803 | default: 1804 | return nil 1805 | } 1806 | } 1807 | file_plugin_codegen_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { 1808 | switch v := v.(*Column); i { 1809 | case 0: 1810 | return &v.state 1811 | case 1: 1812 | return &v.sizeCache 1813 | case 2: 1814 | return &v.unknownFields 1815 | default: 1816 | return nil 1817 | } 1818 | } 1819 | file_plugin_codegen_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { 1820 | switch v := v.(*Query); i { 1821 | case 0: 1822 | return &v.state 1823 | case 1: 1824 | return &v.sizeCache 1825 | case 2: 1826 | return &v.unknownFields 1827 | default: 1828 | return nil 1829 | } 1830 | } 1831 | file_plugin_codegen_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { 1832 | switch v := v.(*Parameter); i { 1833 | case 0: 1834 | return &v.state 1835 | case 1: 1836 | return &v.sizeCache 1837 | case 2: 1838 | return &v.unknownFields 1839 | default: 1840 | return nil 1841 | } 1842 | } 1843 | file_plugin_codegen_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { 1844 | switch v := v.(*CodeGenRequest); i { 1845 | case 0: 1846 | return &v.state 1847 | case 1: 1848 | return &v.sizeCache 1849 | case 2: 1850 | return &v.unknownFields 1851 | default: 1852 | return nil 1853 | } 1854 | } 1855 | file_plugin_codegen_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { 1856 | switch v := v.(*CodeGenResponse); i { 1857 | case 0: 1858 | return &v.state 1859 | case 1: 1860 | return &v.sizeCache 1861 | case 2: 1862 | return &v.unknownFields 1863 | default: 1864 | return nil 1865 | } 1866 | } 1867 | file_plugin_codegen_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { 1868 | switch v := v.(*Codegen_Process); i { 1869 | case 0: 1870 | return &v.state 1871 | case 1: 1872 | return &v.sizeCache 1873 | case 2: 1874 | return &v.unknownFields 1875 | default: 1876 | return nil 1877 | } 1878 | } 1879 | file_plugin_codegen_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { 1880 | switch v := v.(*Codegen_WASM); i { 1881 | case 0: 1882 | return &v.state 1883 | case 1: 1884 | return &v.sizeCache 1885 | case 2: 1886 | return &v.unknownFields 1887 | default: 1888 | return nil 1889 | } 1890 | } 1891 | } 1892 | type x struct{} 1893 | out := protoimpl.TypeBuilder{ 1894 | File: protoimpl.DescBuilder{ 1895 | GoPackagePath: "github.com/orisano/sqlc-gen-ts-d1/codegen/plugin", 1896 | RawDescriptor: file_plugin_codegen_proto_rawDesc, 1897 | NumEnums: 0, 1898 | NumMessages: 20, 1899 | NumExtensions: 0, 1900 | NumServices: 0, 1901 | }, 1902 | GoTypes: file_plugin_codegen_proto_goTypes, 1903 | DependencyIndexes: file_plugin_codegen_proto_depIdxs, 1904 | MessageInfos: file_plugin_codegen_proto_msgTypes, 1905 | }.Build() 1906 | File_plugin_codegen_proto = out.File 1907 | file_plugin_codegen_proto_rawDesc = nil 1908 | file_plugin_codegen_proto_goTypes = nil 1909 | file_plugin_codegen_proto_depIdxs = nil 1910 | } 1911 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/orisano/sqlc-gen-ts-d1 2 | 3 | go 1.20 4 | 5 | require google.golang.org/protobuf v1.34.2 6 | 7 | require github.com/google/go-cmp v0.5.9 // indirect 8 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= 2 | github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 3 | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= 4 | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 5 | -------------------------------------------------------------------------------- /protos/plugin/codegen.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package plugin; 4 | 5 | option go_package = "github.com/orisano/sqlc-gen-typescript-d1/codegen/plugin"; 6 | 7 | message File { 8 | string name = 1 [json_name = "name"]; 9 | bytes contents = 2 [json_name = "contents"]; 10 | } 11 | 12 | message Override { 13 | // PythonType message was field 9 14 | reserved 9; 15 | 16 | // name of the type to use, e.g. `github.com/segmentio/ksuid.KSUID` or `mymodule.Type` 17 | string code_type = 1 [json_name = "code_type"]; 18 | 19 | // name of the type to use, e.g. `text` 20 | string db_type = 3 [json_name = "db_type"]; 21 | 22 | // True if the override should apply to a nullable database type 23 | bool nullable = 5 [json_name = "nullable"]; 24 | 25 | // fully qualified name of the column, e.g. `accounts.id` 26 | string column = 6 [json_name = "column"]; 27 | 28 | Identifier table = 7 [json_name = "table"]; 29 | 30 | string column_name = 8 [json_name = "column_name"]; 31 | 32 | ParsedGoType go_type = 10; 33 | 34 | // True if the override should apply to a unsigned database type 35 | bool unsigned = 11 [json_name = "unsigned"]; 36 | } 37 | 38 | message ParsedGoType { 39 | string import_path = 1; 40 | string package = 2; 41 | string type_name = 3; 42 | bool basic_type = 4; 43 | map struct_tags = 5; 44 | } 45 | 46 | message Settings { 47 | // PythonCode message was field 8 48 | // KotlinCode message was field 9 49 | // GoCode message was field 10; 50 | // JSONCode message was field 11; 51 | reserved 8, 9, 10, 11; 52 | 53 | string version = 1 [json_name = "version"]; 54 | string engine = 2 [json_name = "engine"]; 55 | repeated string schema = 3 [json_name = "schema"]; 56 | repeated string queries = 4 [json_name = "queries"]; 57 | map rename = 5 [json_name = "rename"]; 58 | repeated Override overrides = 6 [json_name = "overrides"]; 59 | Codegen codegen = 12 [json_name = "codegen"]; 60 | } 61 | 62 | message Codegen { 63 | message Process { 64 | string cmd = 1; 65 | } 66 | message WASM { 67 | string url = 1; 68 | string sha256 = 2; 69 | } 70 | string out = 1 [json_name = "out"]; 71 | string plugin = 2 [json_name = "plugin"]; 72 | bytes options = 3 [json_name = "options"]; 73 | repeated string env = 4 [json_name = "env"]; 74 | Process process = 5 [json_name = "process"]; 75 | WASM wasm = 6 [json_name = "wasm"]; 76 | } 77 | 78 | message Catalog { 79 | string comment = 1; 80 | string default_schema = 2; 81 | string name = 3; 82 | repeated Schema schemas = 4; 83 | } 84 | 85 | message Schema { 86 | string comment = 1; 87 | string name = 2; 88 | repeated Table tables = 3; 89 | repeated Enum enums = 4; 90 | repeated CompositeType composite_types = 5; 91 | } 92 | 93 | message CompositeType { 94 | string name = 1; 95 | string comment = 2; 96 | } 97 | 98 | message Enum { 99 | string name = 1; 100 | repeated string vals = 2; 101 | string comment = 3; 102 | } 103 | 104 | message Table { 105 | Identifier rel = 1; 106 | repeated Column columns = 2; 107 | string comment = 3; 108 | } 109 | 110 | message Identifier { 111 | string catalog = 1; 112 | string schema = 2; 113 | string name = 3; 114 | } 115 | 116 | message Column { 117 | string name = 1; 118 | bool not_null = 3; 119 | bool is_array = 4; 120 | string comment = 5; 121 | int32 length = 6; 122 | bool is_named_param = 7; 123 | bool is_func_call = 8; 124 | 125 | // XXX: Figure out what PostgreSQL calls `foo.id` 126 | string scope = 9; 127 | Identifier table = 10; 128 | string table_alias = 11; 129 | Identifier type = 12; 130 | bool is_sqlc_slice = 13; 131 | Identifier embed_table = 14; 132 | string original_name = 15; 133 | bool unsigned = 16; 134 | int32 array_dims = 17; 135 | } 136 | 137 | message Query { 138 | string text = 1 [json_name = "text"]; 139 | string name = 2 [json_name = "name"]; 140 | string cmd = 3 [json_name = "cmd"]; 141 | repeated Column columns = 4 [json_name = "columns"]; 142 | repeated Parameter params = 5 [json_name = "parameters"]; 143 | repeated string comments = 6 [json_name = "comments"]; 144 | string filename = 7 [json_name = "filename"]; 145 | Identifier insert_into_table = 8 [json_name = "insert_into_table"]; 146 | } 147 | 148 | message Parameter { 149 | int32 number = 1 [json_name = "number"]; 150 | Column column = 2 [json_name = "column"]; 151 | } 152 | 153 | message CodeGenRequest { 154 | Settings settings = 1 [json_name = "settings"]; 155 | Catalog catalog = 2 [json_name = "catalog"]; 156 | repeated Query queries = 3 [json_name = "queries"]; 157 | string sqlc_version = 4 [json_name = "sqlc_version"]; 158 | bytes plugin_options = 5 [json_name = "plugin_options"]; 159 | } 160 | 161 | message CodeGenResponse { 162 | repeated File files = 1 [json_name = "files"]; 163 | } 164 | -------------------------------------------------------------------------------- /query.sql: -------------------------------------------------------------------------------- 1 | -- name: GetAccount :one 2 | SELECT * FROM account WHERE id = @account_id; 3 | 4 | -- name: ListAccounts :many 5 | SELECT sqlc.embed(account) FROM account; 6 | 7 | -- name: CreateAccount :exec 8 | INSERT INTO account (id, display_name, email) 9 | VALUES (@id, @display_name, @email); 10 | 11 | -- name: UpdateAccountDisplayName :one 12 | UPDATE account 13 | SET display_name = @display_name 14 | WHERE id = @id 15 | RETURNING *; 16 | 17 | -- name: GetAccounts :many 18 | SELECT * FROM account WHERE id IN (sqlc.slice(ids)); 19 | 20 | -- name: GetConnectionId :one 21 | SELECT CAST(json_extract('{"connection_id":"foo"}', '$.connection_id') AS TEXT) AS connection_id; 22 | -------------------------------------------------------------------------------- /schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE account ( 2 | pk INTEGER PRIMARY KEY AUTOINCREMENT, 3 | id TEXT UNIQUE NOT NULL, 4 | display_name TEXT NOT NULL, 5 | email TEXT 6 | ); 7 | -------------------------------------------------------------------------------- /sqlc.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2", 3 | "plugins": [ 4 | { 5 | "name": "ts-d1", 6 | "wasm": { 7 | "url": "file://bin/sqlc-gen-ts-d1.wasm", 8 | "sha256": "169773bef3730638dff80a5736aa9ed510a77fa820d9e43eab692bfd794a73e1" 9 | } 10 | } 11 | ], 12 | "sql": [ 13 | { 14 | "schema": "schema.sql", 15 | "queries": "query.sql", 16 | "engine": "sqlite", 17 | "codegen": [ 18 | { 19 | "out": "src/gen/sqlc", 20 | "plugin": "ts-d1", 21 | "options": { 22 | "workers-types": "experimental" 23 | } 24 | } 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /src/gen/sqlc/models.ts: -------------------------------------------------------------------------------- 1 | // Code generated by sqlc-gen-ts-d1. DO NOT EDIT. 2 | // versions: 3 | // sqlc v1.25.0 4 | // sqlc-gen-ts-d1 v0.0.0-a@169773bef3730638dff80a5736aa9ed510a77fa820d9e43eab692bfd794a73e1 5 | 6 | export type Account = { 7 | pk: number; 8 | id: string; 9 | displayName: string; 10 | email: string | null; 11 | }; 12 | 13 | -------------------------------------------------------------------------------- /src/gen/sqlc/querier.ts: -------------------------------------------------------------------------------- 1 | // Code generated by sqlc-gen-ts-d1. DO NOT EDIT. 2 | // versions: 3 | // sqlc v1.25.0 4 | // sqlc-gen-ts-d1 v0.0.0-a@169773bef3730638dff80a5736aa9ed510a77fa820d9e43eab692bfd794a73e1 5 | 6 | import { D1Database, D1PreparedStatement, D1Result } from "@cloudflare/workers-types/experimental" 7 | import { Account } from "./models" 8 | 9 | type Query = { 10 | then(onFulfilled?: (value: T) => void, onRejected?: (reason?: any) => void): void; 11 | batch(): D1PreparedStatement; 12 | } 13 | const getAccountQuery = `-- name: GetAccount :one 14 | SELECT pk, id, display_name, email FROM account WHERE id = ?1`; 15 | 16 | export type GetAccountParams = { 17 | accountId: string; 18 | }; 19 | 20 | export type GetAccountRow = { 21 | pk: number; 22 | id: string; 23 | displayName: string; 24 | email: string | null; 25 | }; 26 | 27 | type RawGetAccountRow = { 28 | pk: number; 29 | id: string; 30 | display_name: string; 31 | email: string | null; 32 | }; 33 | 34 | export function getAccount( 35 | d1: D1Database, 36 | args: GetAccountParams 37 | ): Query { 38 | const ps = d1 39 | .prepare(getAccountQuery) 40 | .bind(args.accountId); 41 | return { 42 | then(onFulfilled?: (value: GetAccountRow | null) => void, onRejected?: (reason?: any) => void) { 43 | ps.first() 44 | .then((raw: RawGetAccountRow | null) => raw ? { 45 | pk: raw.pk, 46 | id: raw.id, 47 | displayName: raw.display_name, 48 | email: raw.email, 49 | } : null) 50 | .then(onFulfilled).catch(onRejected); 51 | }, 52 | batch() { return ps; }, 53 | } 54 | } 55 | 56 | const listAccountsQuery = `-- name: ListAccounts :many 57 | SELECT account.pk AS account_pk, account.id AS account_id, account.display_name AS account_display_name, account.email AS account_email FROM account`; 58 | 59 | export type ListAccountsRow = { 60 | account: Account; 61 | }; 62 | 63 | type RawListAccountsRow = { 64 | account_pk: number; 65 | account_id: string; 66 | account_display_name: string; 67 | account_email: string | null; 68 | }; 69 | 70 | export function listAccounts( 71 | d1: D1Database 72 | ): Query> { 73 | const ps = d1 74 | .prepare(listAccountsQuery); 75 | return { 76 | then(onFulfilled?: (value: D1Result) => void, onRejected?: (reason?: any) => void) { 77 | ps.all() 78 | .then((r: D1Result) => { return { 79 | ...r, 80 | results: r.results.map((raw: RawListAccountsRow) => { return { 81 | // sqlc.embed(account) 82 | account: { 83 | pk: raw.account_pk, 84 | id: raw.account_id, 85 | displayName: raw.account_display_name, 86 | email: raw.account_email, 87 | }, 88 | }}), 89 | }}) 90 | .then(onFulfilled).catch(onRejected); 91 | }, 92 | batch() { return ps; }, 93 | } 94 | } 95 | 96 | const createAccountQuery = `-- name: CreateAccount :exec 97 | INSERT INTO account (id, display_name, email) 98 | VALUES (?1, ?2, ?3)`; 99 | 100 | export type CreateAccountParams = { 101 | id: string; 102 | displayName: string; 103 | email: string | null; 104 | }; 105 | 106 | export function createAccount( 107 | d1: D1Database, 108 | args: CreateAccountParams 109 | ): Query { 110 | const ps = d1 111 | .prepare(createAccountQuery) 112 | .bind(args.id, args.displayName, args.email); 113 | return { 114 | then(onFulfilled?: (value: D1Result) => void, onRejected?: (reason?: any) => void) { 115 | ps.run() 116 | .then(onFulfilled).catch(onRejected); 117 | }, 118 | batch() { return ps; }, 119 | } 120 | } 121 | 122 | const updateAccountDisplayNameQuery = `-- name: UpdateAccountDisplayName :one 123 | UPDATE account 124 | SET display_name = ?1 125 | WHERE id = ?2 126 | RETURNING pk, id, display_name, email`; 127 | 128 | export type UpdateAccountDisplayNameParams = { 129 | displayName: string; 130 | id: string; 131 | }; 132 | 133 | export type UpdateAccountDisplayNameRow = { 134 | pk: number; 135 | id: string; 136 | displayName: string; 137 | email: string | null; 138 | }; 139 | 140 | type RawUpdateAccountDisplayNameRow = { 141 | pk: number; 142 | id: string; 143 | display_name: string; 144 | email: string | null; 145 | }; 146 | 147 | export function updateAccountDisplayName( 148 | d1: D1Database, 149 | args: UpdateAccountDisplayNameParams 150 | ): Query { 151 | const ps = d1 152 | .prepare(updateAccountDisplayNameQuery) 153 | .bind(args.displayName, args.id); 154 | return { 155 | then(onFulfilled?: (value: UpdateAccountDisplayNameRow | null) => void, onRejected?: (reason?: any) => void) { 156 | ps.first() 157 | .then((raw: RawUpdateAccountDisplayNameRow | null) => raw ? { 158 | pk: raw.pk, 159 | id: raw.id, 160 | displayName: raw.display_name, 161 | email: raw.email, 162 | } : null) 163 | .then(onFulfilled).catch(onRejected); 164 | }, 165 | batch() { return ps; }, 166 | } 167 | } 168 | 169 | const getAccountsQuery = `-- name: GetAccounts :many 170 | SELECT pk, id, display_name, email FROM account WHERE id IN (/*SLICE:ids*/?)`; 171 | 172 | export type GetAccountsParams = { 173 | ids: string[]; 174 | }; 175 | 176 | export type GetAccountsRow = { 177 | pk: number; 178 | id: string; 179 | displayName: string; 180 | email: string | null; 181 | }; 182 | 183 | type RawGetAccountsRow = { 184 | pk: number; 185 | id: string; 186 | display_name: string; 187 | email: string | null; 188 | }; 189 | 190 | export function getAccounts( 191 | d1: D1Database, 192 | args: GetAccountsParams 193 | ): Query> { 194 | let query = getAccountsQuery; 195 | const params: any[] = [args.ids[0]]; 196 | query = query.replace("(/*SLICE:ids*/?)", expandedParam(1, args.ids.length, params.length)); 197 | params.push(...args.ids.slice(1)); 198 | const ps = d1 199 | .prepare(query) 200 | .bind(...params); 201 | return { 202 | then(onFulfilled?: (value: D1Result) => void, onRejected?: (reason?: any) => void) { 203 | ps.all() 204 | .then((r: D1Result) => { return { 205 | ...r, 206 | results: r.results.map((raw: RawGetAccountsRow) => { return { 207 | pk: raw.pk, 208 | id: raw.id, 209 | displayName: raw.display_name, 210 | email: raw.email, 211 | }}), 212 | }}) 213 | .then(onFulfilled).catch(onRejected); 214 | }, 215 | batch() { return ps; }, 216 | } 217 | } 218 | 219 | const getConnectionIdQuery = `-- name: GetConnectionId :one 220 | SELECT CAST(json_extract('{"connection_id":"foo"}', '$.connection_id') AS TEXT) AS connection_id`; 221 | 222 | export type GetConnectionIdRow = { 223 | connectionId: string; 224 | }; 225 | 226 | type RawGetConnectionIdRow = { 227 | connection_id: string; 228 | }; 229 | 230 | export function getConnectionId( 231 | d1: D1Database 232 | ): Query { 233 | const ps = d1 234 | .prepare(getConnectionIdQuery); 235 | return { 236 | then(onFulfilled?: (value: GetConnectionIdRow | null) => void, onRejected?: (reason?: any) => void) { 237 | ps.first() 238 | .then((raw: RawGetConnectionIdRow | null) => raw ? { 239 | connectionId: raw.connection_id, 240 | } : null) 241 | .then(onFulfilled).catch(onRejected); 242 | }, 243 | batch() { return ps; }, 244 | } 245 | } 246 | 247 | function expandedParam(n: number, len: number, last: number): string { 248 | const params: number[] = [n]; 249 | for (let i = 1; i < len; i++) { 250 | params.push(last + i); 251 | } 252 | return "(" + params.map((x: number) => "?" + x).join(", ") + ")"; 253 | } 254 | --------------------------------------------------------------------------------