Use RSVP #15
|
|
@ -0,0 +1,105 @@
|
|||
package lishwist // import "lishwist/core"
|
||||
|
||||
|
||||
VARIABLES
|
||||
|
||||
var ErrorUsernameTaken = errors.New("Username is taken")
|
||||
|
||||
FUNCTIONS
|
||||
|
||||
func Init(dataSourceName string) error
|
||||
func PrintTables(d *sql.DB)
|
||||
func PrintViews(d *sql.DB)
|
||||
|
||||
TYPES
|
||||
|
||||
type Admin struct {
|
||||
// Has unexported fields.
|
||||
}
|
||||
|
||||
func (a *Admin) AddUserToGroup(userId, groupId string) error
|
||||
|
||||
func (a *Admin) CreateGroup(name string, reference string) (*Group, error)
|
||||
|
||||
func (*Admin) GetUser(id string) (*User, error)
|
||||
|
||||
func (a *Admin) ListGroups() ([]Group, error)
|
||||
|
||||
func (*Admin) ListUsers() ([]User, error)
|
||||
|
||||
func (a *Admin) RemoveUserFromGroup(userId, groupId string) error
|
||||
|
||||
func (u *Admin) UserSetLive(userReference string, setting bool) error
|
||||
|
||||
type ErrorInvalidCredentials error
|
||||
|
||||
type Group struct {
|
||||
Id string
|
||||
Name string
|
||||
Reference string
|
||||
Members []User
|
||||
}
|
||||
|
||||
func GetGroupByReference(reference string) (*Group, error)
|
||||
|
||||
func (g *Group) MemberIndex(userId string) int
|
||||
|
||||
type Session struct {
|
||||
User
|
||||
}
|
||||
|
||||
func Login(username, password string) (*Session, error)
|
||||
|
||||
func SessionFromUsername(username string) (*Session, error)
|
||||
|
||||
func (s *Session) Admin() *Admin
|
||||
|
||||
func (s *Session) ClaimWishes(claims, unclaims []string) error
|
||||
|
||||
func (s *Session) CompleteWishes(claims []string) error
|
||||
|
||||
func (s *Session) GetGroupByReference(reference string) (*Group, error)
|
||||
|
||||
func (u *Session) GetGroups() ([]Group, error)
|
||||
|
||||
func (s *Session) GetOthersWishes(userReference string) ([]Wish, error)
|
||||
|
||||
func (s *Session) GetWishes() ([]Wish, error)
|
||||
|
||||
func (s *Session) MakeWish(name string) error
|
||||
|
||||
func (s *Session) RecindWishesForUser(ids ...string) error
|
||||
|
||||
func (s *Session) RevokeWishes(ids ...string) error
|
||||
|
||||
func (u *Session) SuggestWishForUser(otherUserReference string, wishName string) error
|
||||
|
||||
type User struct {
|
||||
Id string
|
||||
NormalName string
|
||||
Name string
|
||||
Reference string
|
||||
IsAdmin bool
|
||||
IsLive bool
|
||||
}
|
||||
|
||||
func GetUserByReference(reference string) (*User, error)
|
||||
|
||||
func Register(username, newPassword string) (*User, error)
|
||||
|
||||
func (u *User) GetTodo() ([]Wish, error)
|
||||
|
||||
func (u *User) WishCount() (int, error)
|
||||
|
||||
type Wish struct {
|
||||
Id string
|
||||
Name string
|
||||
ClaimantId string `json:",omitempty"`
|
||||
ClaimantName string `json:",omitempty"`
|
||||
Sent bool
|
||||
RecipientId string `json:",omitempty"`
|
||||
RecipientName string `json:",omitempty"`
|
||||
RecipientRef string `json:",omitempty"`
|
||||
CreatorId string `json:",omitempty"`
|
||||
CreatorName string `json:",omitempty"`
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
git diff --exit-code $1 api.snap.txt $(find . -name '*_test.go' -type f)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
go doc -all | ./scripts/strip_godoc_comments
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import fileinput
|
||||
from collections import deque
|
||||
from typing import Iterator
|
||||
from typing import TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def window(it: Iterator[T], size: int = 2) -> Iterator[list[T]]:
|
||||
if size < 2:
|
||||
raise ValueError("Window size must be at least 2")
|
||||
|
||||
window: deque[T] = deque(maxlen=size)
|
||||
|
||||
for _ in range(size):
|
||||
try:
|
||||
window.append(next(it))
|
||||
except StopIteration:
|
||||
return
|
||||
|
||||
yield list(window)
|
||||
|
||||
for item in it:
|
||||
window.append(item)
|
||||
yield list(window)
|
||||
|
||||
|
||||
struct = False
|
||||
func = False
|
||||
for line, next_line in window(fileinput.input()):
|
||||
line = line.removesuffix("\n")
|
||||
|
||||
if line.startswith("type ") and line.endswith(" struct {"):
|
||||
struct = True
|
||||
elif struct and line.endswith("}"):
|
||||
struct = False
|
||||
elif line.startswith("func"):
|
||||
func = True
|
||||
elif next_line[:4].strip() != "":
|
||||
func = False
|
||||
|
||||
if struct:
|
||||
if (
|
||||
line != ""
|
||||
and not line.lstrip().startswith("//")
|
||||
or "Has unexported fields" in line
|
||||
):
|
||||
print(line)
|
||||
elif func:
|
||||
if line != "" and not line.startswith(" "):
|
||||
print(line)
|
||||
else:
|
||||
print(line)
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd core/
|
||||
|
||||
APISNAP=api.snap.txt
|
||||
|
||||
./scripts/api_snapshot > $APISNAP
|
||||
git diff --quiet $APISNAP
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "There are unstaged changes to $APISNAP"
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Reference in New Issue