|
| 1 | +import { authFirst } from "./util"; |
| 2 | + |
| 3 | +export const org = { |
| 4 | + getAll: authFirst, |
| 5 | + create: authFirst, |
| 6 | + get: authFirst, |
| 7 | + set: authFirst, |
| 8 | + addAdmin: authFirst, |
| 9 | + addUser: authFirst, |
| 10 | + createUser: authFirst, |
| 11 | + createToken: authFirst, |
| 12 | + expireToken: authFirst, |
| 13 | + getUsers: authFirst, |
| 14 | + message: authFirst, |
| 15 | + removeUser: authFirst, |
| 16 | + removeAdmin: authFirst, |
| 17 | +}; |
| 18 | + |
| 19 | +export interface Org { |
| 20 | + // get every organization that the given account is a member or admin of. If account_id is a site |
| 21 | + // admin, this gets all organizations, and status will usually be 'none' in that case. |
| 22 | + getAll: (opts: { account_id?: string }) => Promise< |
| 23 | + { |
| 24 | + name: string; |
| 25 | + title?: string; |
| 26 | + admin_account_ids?: string[]; |
| 27 | + }[] |
| 28 | + >; |
| 29 | + |
| 30 | + // create a new organization with the given unique name (at most 39 characters); only admins |
| 31 | + // can create an organization. Returns uuid of organization. The name CANNOT BE CHANGED, |
| 32 | + // because it is what is used elsewhere to link to the org. |
| 33 | + create: (opts: { account_id?: string; name: string }) => Promise<string>; |
| 34 | + |
| 35 | + // get properties of an existing organization |
| 36 | + get: (opts: { account_id?: string; name: string }) => Promise<{ |
| 37 | + name: string; |
| 38 | + title?: string; |
| 39 | + description?: string; |
| 40 | + link?: string; |
| 41 | + email_address?: string; |
| 42 | + admin_account_ids?: string[]; |
| 43 | + }>; |
| 44 | + |
| 45 | + // change properties of an existing organization |
| 46 | + set: (opts: { |
| 47 | + account_id?: string; |
| 48 | + name: string; |
| 49 | + title?: string; |
| 50 | + description?: string; |
| 51 | + link?: string; |
| 52 | + email_address?: string; |
| 53 | + }) => Promise<void>; |
| 54 | + |
| 55 | + addAdmin: (opts: { |
| 56 | + account_id?: string; |
| 57 | + name: string; |
| 58 | + // user = account_id or email address |
| 59 | + user: string; |
| 60 | + }) => Promise<void>; |
| 61 | + |
| 62 | + addUser: (opts: { |
| 63 | + account_id?: string; |
| 64 | + name: string; |
| 65 | + // user = account_id or email address |
| 66 | + user: string; |
| 67 | + }) => Promise<void>; |
| 68 | + |
| 69 | + createUser: (opts: { |
| 70 | + account_id?: string; |
| 71 | + name: string; |
| 72 | + email: string; |
| 73 | + firstName: string; |
| 74 | + lastName: string; |
| 75 | + password: string; |
| 76 | + }) => Promise<string>; |
| 77 | + |
| 78 | + removeUser: (opts: { |
| 79 | + account_id?: string; |
| 80 | + name: string; |
| 81 | + // user = account_id or email address |
| 82 | + user: string; |
| 83 | + }) => Promise<void>; |
| 84 | + |
| 85 | + removeAdmin: (opts: { |
| 86 | + account_id?: string; |
| 87 | + name: string; |
| 88 | + // user = account_id or email address |
| 89 | + user: string; |
| 90 | + }) => Promise<void>; |
| 91 | + |
| 92 | + createToken: (opts: { |
| 93 | + account_id?: string; |
| 94 | + // user = account_id or email address |
| 95 | + user: string; |
| 96 | + }) => Promise<{ token: string; url: string }>; |
| 97 | + |
| 98 | + expireToken: (opts: { account_id?: string; token: string }) => Promise<void>; |
| 99 | + |
| 100 | + getUsers: (opts: { account_id?: string; name: string }) => Promise< |
| 101 | + { |
| 102 | + first_name: string; |
| 103 | + last_name: string; |
| 104 | + account_id: string; |
| 105 | + email_address: string; |
| 106 | + }[] |
| 107 | + >; |
| 108 | + |
| 109 | + message: (opts: { |
| 110 | + account_id?: string; |
| 111 | + name: string; |
| 112 | + subject: string; |
| 113 | + body: string; |
| 114 | + }) => Promise<void>; |
| 115 | +} |
0 commit comments