this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

some prep-work for lexicon update

why e796c34d dc8f3031

+35 -6
+8 -1
cmd/gosky/main.go
··· 427 427 return fmt.Errorf("must specify rkey of post to delete") 428 428 } 429 429 430 - return atpc.RepoDeleteRecord(context.TODO(), atpc.C.Auth.Did, "app.bsky.feed.post", rkey) 430 + schema := "app.bsky.feed.post" 431 + if strings.Contains(rkey, "/") { 432 + parts := strings.Split(rkey, "/") 433 + schema = parts[0] 434 + rkey = parts[1] 435 + } 436 + 437 + return atpc.RepoDeleteRecord(context.TODO(), atpc.C.Auth.Did, schema, rkey) 431 438 }, 432 439 } 433 440
+27 -5
lex/gen.go
··· 131 131 return &s, nil 132 132 } 133 133 134 - func GenCodeForSchema(pkg string, prefix string, fname string, reqcode bool, s *Schema) error { 134 + func BuildExtDefMap(ss []*Schema) map[string]*ExtDef { 135 + out := make(map[string]*ExtDef) 136 + for _, s := range ss { 137 + for k, d := range s.Defs { 138 + out[s.ID+"#"+k] = &ExtDef{ 139 + Type: d, 140 + } 141 + } 142 + } 143 + return out 144 + } 145 + 146 + type ExtDef struct { 147 + Type TypeSchema 148 + } 149 + 150 + func GenCodeForSchema(pkg string, prefix string, fname string, reqcode bool, s *Schema, defmap map[string]*ExtDef) error { 135 151 buf := new(bytes.Buffer) 136 152 137 153 s.prefix = prefix ··· 457 473 params = append(params, k) 458 474 paramtypes = append(paramtypes, k+" string") 459 475 fmt.Fprintf(w, "%s := c.QueryParam(\"%s\")\n", k, k) 460 - case "number": 476 + case "integer": 461 477 params = append(params, k) 462 478 paramtypes = append(paramtypes, k+" int") 463 479 fmt.Fprintf(w, ` ··· 466 482 return err 467 483 } 468 484 `, k, k) 485 + case "number": 486 + return fmt.Errorf("non-integer numbers currently unsupported") 469 487 default: 470 488 return fmt.Errorf("unsupported handler parameter type: %s", t.Type) 471 489 } ··· 511 529 case "string": 512 530 return "string", nil 513 531 case "number": 532 + return "float64", nil 533 + case "integer": 514 534 return "int64", nil 515 535 case "boolean": 516 536 return "bool", nil ··· 578 598 // TODO: deal with max length 579 599 fmt.Fprintf(w, "type %s string\n", name) 580 600 case "number": 601 + fmt.Fprintf(w, "type %s float64\n", name) 602 + case "integer": 581 603 fmt.Fprintf(w, "type %s int64\n", name) 582 604 case "boolean": 583 605 fmt.Fprintf(w, "type %s bool\n", name) ··· 645 667 646 668 func (s *Schema) writeTypeMethods(name string, t TypeSchema, w io.Writer) error { 647 669 switch t.Type { 648 - case "string", "number", "array", "boolean": 670 + case "string", "number", "array", "boolean", "integer": 649 671 return nil 650 672 case "object": 651 673 if err := s.writeJsonMarshalerObject(name, t, w); err != nil { ··· 757 779 func (s *Schema) getTypeConstValueForType(t TypeSchema) (string, []string, error) { 758 780 parts := strings.Split(t.Ref, "/") 759 781 if len(parts) == 3 && parts[0] == "#" && parts[1] == "defs" { 760 - defs, ok := s.Defs[parts[2]] 782 + def, ok := s.Defs[parts[2]] 761 783 if !ok { 762 784 return "", nil, fmt.Errorf("bad reference %q", parts[2]) 763 785 } 764 786 765 - typ, ok := defs.Properties["type"] 787 + typ, ok := def.Properties["type"] 766 788 if !ok { 767 789 return "", nil, fmt.Errorf("referenced enum value %q does not have type property", parts[2]) 768 790 }