fauna-api 1.0.682 → 1.0.692

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/src/authentification.d.ts +34 -0
  2. package/dist/src/authentification.js +135 -0
  3. package/dist/src/calendar.d.ts +5 -2
  4. package/dist/src/calendar.js +5 -2
  5. package/dist/src/cicada/contacts.d.ts +19 -25
  6. package/dist/src/cicada/contacts.js +17 -5
  7. package/dist/src/cicada/inboxes.d.ts +16 -0
  8. package/dist/src/cicada/inboxes.js +10 -0
  9. package/dist/src/extensions/web/session.d.ts +1 -3
  10. package/dist/src/extensions/web/session.js +0 -1
  11. package/dist/src/groups.d.ts +167 -20
  12. package/dist/src/groups.js +287 -31
  13. package/dist/src/marmot/web.d.ts +27 -9
  14. package/dist/src/marmot/web.js +118 -79
  15. package/dist/src/parrot/room.d.ts +6 -2
  16. package/dist/src/parrot/room.js +11 -0
  17. package/dist/src/parrot/share.d.ts +4 -1
  18. package/dist/src/parrot/share.js +4 -2
  19. package/dist/src/rooms.d.ts +37 -11
  20. package/dist/src/rooms.js +46 -14
  21. package/dist/src/shared/server.d.ts +23 -0
  22. package/dist/src/shared/server.js +41 -0
  23. package/dist/src/ui/authentification.d.ts +6 -2
  24. package/dist/src/ui/authentification.js +36 -10
  25. package/dist/src/ui/browser.js +1 -1
  26. package/dist/src/ui/chat.js +8 -6
  27. package/dist/src/ui/chatSequence.d.ts +3 -2
  28. package/dist/src/ui/chatSequence.js +7 -2
  29. package/dist/src/ui/drive.js +1 -1
  30. package/dist/src/ui/index.d.ts +2 -0
  31. package/dist/src/ui/index.js +2 -0
  32. package/dist/src/ui/integrations.js +74 -0
  33. package/dist/src/ui/maps.d.ts +1 -1
  34. package/dist/src/ui/maps.js +3 -1
  35. package/dist/src/ui/markdown.d.ts +5 -0
  36. package/dist/src/ui/markdown.js +33 -0
  37. package/dist/src/ui/toast.d.ts +2 -2
  38. package/dist/src/ui/toast.js +5 -5
  39. package/dist/src/ui/ui.css +137 -0
  40. package/dist/src/webhooks.d.ts +2 -0
  41. package/package.json +2 -2
@@ -29,6 +29,19 @@ export type Profile = {
29
29
  export declare const Profile: {
30
30
  fromJSON(json: unknown): Profile | undefined;
31
31
  };
32
+ /** One place you're signed in. `id` names the session; it is not its token. */
33
+ export type Session = {
34
+ id: string;
35
+ /** The session this call came from. */
36
+ current: boolean;
37
+ /** The browser or client that signed in, as its User-Agent named it. */
38
+ agent: string;
39
+ created: Date;
40
+ expires: Date;
41
+ };
42
+ export declare const Session: {
43
+ fromJSON(json: any): Session;
44
+ };
32
45
  export declare function authorize(email: string, password: string): Promise<Token>;
33
46
  export declare function authorizeToken(token: Token): Promise<Credentials>;
34
47
  export declare function authorizeApiKey(apiKey: string): Promise<ApiKey>;
@@ -37,6 +50,27 @@ export declare function create(email: string, password: string, phone: string, d
37
50
  export declare function edit(credentials: Credentials, update: Partial<Pick<Credentials, 'displayName' | 'icon' | 'email' | 'phone'>>): Promise<boolean>;
38
51
  export declare function verify(channel: 'EMAIL' | 'PHONE', target: string, code: string): Promise<boolean>;
39
52
  export declare function sendVerification(credentials: Credentials, channel: 'EMAIL' | 'PHONE'): Promise<boolean>;
53
+ /** Emails a link and code for choosing a new password, when an account has that email. Answers the same either way. */
54
+ export declare function forgotPassword(email: string): Promise<boolean>;
55
+ /** A new password, with the code from a reset email. The email counts as verified, and every session ends. */
56
+ export declare function resetPassword(email: string, code: string, password: string): Promise<boolean>;
57
+ /** A new password, given the current one. Every other session ends; this one stays. */
58
+ export declare function changePassword(credentials: Credentials, current: string, password: string): Promise<boolean>;
59
+ /** Your live sessions, newest first. */
60
+ export declare function sessions(credentials: Credentials, query: {
61
+ cursor: number;
62
+ max: number;
63
+ }): Promise<Session[]>;
64
+ /** Ends one of your sessions. */
65
+ export declare function revokeSession(credentials: Credentials, session: Session): Promise<boolean>;
66
+ /** Ends the session `credentials` signed in with. */
67
+ export declare function signOut(credentials: Credentials): Promise<boolean>;
68
+ /** Ends every one of your sessions, this one too. */
69
+ export declare function signOutEverywhere(credentials: Credentials): Promise<boolean>;
70
+ /** A single use code that passes this session to another page or app for a minute, so the token never rides in a URL. */
71
+ export declare function handoff(credentials: Credentials): Promise<string>;
72
+ /** Uses up a handoff code for the session token it passes. */
73
+ export declare function redeemHandoff(code: string): Promise<Token>;
40
74
  export declare function allocateBalance(credentials: Credentials, target: ApiKey | Group, delta: number): Promise<true>;
41
75
  export declare function generateApiKey(credentials: Credentials): Promise<ApiKey>;
42
76
  export declare function removeApiKey(credentials: Credentials, apiKey: ApiKey): Promise<boolean>;
@@ -13,6 +13,17 @@ export const Profile = {
13
13
  };
14
14
  },
15
15
  };
16
+ export const Session = {
17
+ fromJSON(json) {
18
+ return {
19
+ id: String(json.id),
20
+ current: json.current === true,
21
+ agent: typeof json.agent === "string" ? json.agent : "",
22
+ created: new Date(json.created),
23
+ expires: new Date(json.expires),
24
+ };
25
+ },
26
+ };
16
27
  // Authorization
17
28
  export async function authorize(email, password) {
18
29
  const response = await fetch(`${Fauna.getURL()}/authentification/authorize`, {
@@ -108,6 +119,130 @@ export async function sendVerification(credentials, channel) {
108
119
  }
109
120
  return response.ok;
110
121
  }
122
+ // Passwords and sessions
123
+ /** Emails a link and code for choosing a new password, when an account has that email. Answers the same either way. */
124
+ export async function forgotPassword(email) {
125
+ const response = await fetch(`${Fauna.getURL()}/authentification/password/forgot`, {
126
+ method: "POST",
127
+ headers: {
128
+ "Content-Type": "application/json"
129
+ },
130
+ body: JSON.stringify({ email })
131
+ });
132
+ if (!response.ok) {
133
+ throw new Error(await response.text());
134
+ }
135
+ return response.ok;
136
+ }
137
+ /** A new password, with the code from a reset email. The email counts as verified, and every session ends. */
138
+ export async function resetPassword(email, code, password) {
139
+ const response = await fetch(`${Fauna.getURL()}/authentification/password/reset`, {
140
+ method: "POST",
141
+ headers: {
142
+ "Content-Type": "application/json"
143
+ },
144
+ body: JSON.stringify({ email, code, password })
145
+ });
146
+ if (!response.ok) {
147
+ throw new Error(await response.text());
148
+ }
149
+ return response.ok;
150
+ }
151
+ /** A new password, given the current one. Every other session ends; this one stays. */
152
+ export async function changePassword(credentials, current, password) {
153
+ const response = await fetch(`${Fauna.getURL()}/authentification/password`, {
154
+ method: "POST",
155
+ headers: {
156
+ "Content-Type": "application/json",
157
+ "Authorization": `Token ${credentials.token}`
158
+ },
159
+ body: JSON.stringify({ current, password })
160
+ });
161
+ if (!response.ok) {
162
+ throw new Error(await response.text());
163
+ }
164
+ return response.ok;
165
+ }
166
+ /** Your live sessions, newest first. */
167
+ export async function sessions(credentials, query) {
168
+ const params = new URLSearchParams({ cursor: String(query.cursor), max: String(query.max) });
169
+ const response = await fetch(`${Fauna.getURL()}/authentification/sessions?${params}`, {
170
+ method: "GET",
171
+ headers: {
172
+ "Authorization": `Token ${credentials.token}`
173
+ }
174
+ });
175
+ if (!response.ok) {
176
+ throw new Error(await response.text());
177
+ }
178
+ return (await response.json()).map((row) => Session.fromJSON(row));
179
+ }
180
+ /** Ends one of your sessions. */
181
+ export async function revokeSession(credentials, session) {
182
+ const response = await fetch(`${Fauna.getURL()}/authentification/sessions/${encodeURIComponent(session.id)}`, {
183
+ method: "DELETE",
184
+ headers: {
185
+ "Authorization": `Token ${credentials.token}`
186
+ }
187
+ });
188
+ if (!response.ok) {
189
+ throw new Error(await response.text());
190
+ }
191
+ return response.ok;
192
+ }
193
+ /** Ends the session `credentials` signed in with. */
194
+ export async function signOut(credentials) {
195
+ const response = await fetch(`${Fauna.getURL()}/authentification/sign-out`, {
196
+ method: "POST",
197
+ headers: {
198
+ "Authorization": `Token ${credentials.token}`
199
+ }
200
+ });
201
+ if (!response.ok) {
202
+ throw new Error(await response.text());
203
+ }
204
+ return response.ok;
205
+ }
206
+ /** Ends every one of your sessions, this one too. */
207
+ export async function signOutEverywhere(credentials) {
208
+ const response = await fetch(`${Fauna.getURL()}/authentification/sessions`, {
209
+ method: "DELETE",
210
+ headers: {
211
+ "Authorization": `Token ${credentials.token}`
212
+ }
213
+ });
214
+ if (!response.ok) {
215
+ throw new Error(await response.text());
216
+ }
217
+ return response.ok;
218
+ }
219
+ /** A single use code that passes this session to another page or app for a minute, so the token never rides in a URL. */
220
+ export async function handoff(credentials) {
221
+ const response = await fetch(`${Fauna.getURL()}/authentification/handoff`, {
222
+ method: "POST",
223
+ headers: {
224
+ "Authorization": `Token ${credentials.token}`
225
+ }
226
+ });
227
+ if (!response.ok) {
228
+ throw new Error(await response.text());
229
+ }
230
+ return String((await response.json()).code);
231
+ }
232
+ /** Uses up a handoff code for the session token it passes. */
233
+ export async function redeemHandoff(code) {
234
+ const response = await fetch(`${Fauna.getURL()}/authentification/handoff/redeem`, {
235
+ method: "POST",
236
+ headers: {
237
+ "Content-Type": "application/json"
238
+ },
239
+ body: JSON.stringify({ code })
240
+ });
241
+ if (!response.ok) {
242
+ throw new Error(await response.text());
243
+ }
244
+ return await response.text();
245
+ }
111
246
  export async function allocateBalance(credentials, target, delta) {
112
247
  const deltaMicros = Math.round(delta * 1000000);
113
248
  if (!Number.isSafeInteger(deltaMicros))
@@ -77,7 +77,10 @@ export declare function update(authorization: Credentials | ApiKey, id: string,
77
77
  export declare function remove(authorization: Credentials | ApiKey, id: string): Promise<void>;
78
78
  /** Answer an event you're invited to: `yes`, `no` or `maybe`. */
79
79
  export declare function respond(authorization: Credentials | ApiKey, id: string, answer: Answer): Promise<Event>;
80
- /** The secret .ics link for your calendar, or `group`'s, for Google, Apple or Outlook to subscribe to. */
80
+ /** Your own secret .ics link for your calendar, or `group`'s, for Google, Apple or
81
+ * Outlook to subscribe to. Each person has their own link, and a group's stops
82
+ * working when you leave the group. */
81
83
  export declare function feed(authorization: Credentials | ApiKey, group?: Group): Promise<string>;
82
- /** A new .ics link for your calendar, or `group`'s. The old one stops working. */
84
+ /** A new .ics link of your own for your calendar, or `group`'s. Your old one stops
85
+ * working; nobody else's changes. */
83
86
  export declare function resetFeed(credentials: Credentials, group?: Group): Promise<string>;
@@ -105,7 +105,9 @@ export async function respond(authorization, id, answer) {
105
105
  throw new Error(await response.text());
106
106
  return Event.fromJSON(await response.json());
107
107
  }
108
- /** The secret .ics link for your calendar, or `group`'s, for Google, Apple or Outlook to subscribe to. */
108
+ /** Your own secret .ics link for your calendar, or `group`'s, for Google, Apple or
109
+ * Outlook to subscribe to. Each person has their own link, and a group's stops
110
+ * working when you leave the group. */
109
111
  export async function feed(authorization, group) {
110
112
  const response = await fetch(`${Fauna.getURL()}/calendar/feed`, {
111
113
  method: "GET",
@@ -118,7 +120,8 @@ export async function feed(authorization, group) {
118
120
  throw new Error(await response.text());
119
121
  return (await response.json()).url;
120
122
  }
121
- /** A new .ics link for your calendar, or `group`'s. The old one stops working. */
123
+ /** A new .ics link of your own for your calendar, or `group`'s. Your old one stops
124
+ * working; nobody else's changes. */
122
125
  export async function resetFeed(credentials, group) {
123
126
  const response = await fetch(`${Fauna.getURL()}/calendar/feed/reset`, {
124
127
  method: "POST",
@@ -1,31 +1,25 @@
1
- import { Platform } from "../integrations.js";
2
- import { Profile, Credentials, ApiKey } from "../authentification.js";
3
- export type Discord = {
4
- displayName: string;
5
- handle: string;
6
- userId?: string;
7
- };
8
- export type Slack = {
9
- displayName: string;
10
- email: string;
11
- headline: string;
12
- };
13
- export type Email = {
14
- email: string;
1
+ import { Credentials, ApiKey } from "../authentification.js";
2
+ export type AddressKind = 'email' | 'phone' | 'discord';
3
+ export type Address = {
4
+ kind: AddressKind;
5
+ /** Lowercase email, E.164 phone (+12395551234), or Discord handle without @. */
6
+ value: string;
15
7
  };
16
- export type SMS = {
17
- phone: string;
18
- };
19
- export type Identity = Discord | Slack | Email | SMS;
20
8
  export type Contact = {
21
- profile: Profile;
9
+ id: string;
10
+ displayName: string;
11
+ addresses: Address[];
12
+ /** One of its emails belongs to a Fauna account: the verified badge. */
22
13
  registered: boolean;
23
- platforms: Identity[];
14
+ /** That Fauna account's picture. */
15
+ icon?: string;
24
16
  };
17
+ /** Every contact, sorted by display name. */
25
18
  export declare function list(authorization: Credentials | ApiKey): Promise<Contact[]>;
26
- export declare function create(authorization: Credentials | ApiKey, params: {
27
- email: string;
28
- displayName?: string;
29
- platform: Platform;
30
- identity?: string;
19
+ /** Creates a contact, or with `id` renames one and replaces its addresses. */
20
+ export declare function save(authorization: Credentials | ApiKey, contact: {
21
+ id?: string;
22
+ displayName: string;
23
+ addresses: Address[];
31
24
  }): Promise<Contact>;
25
+ export declare function remove(authorization: Credentials | ApiKey, id: string): Promise<void>;
@@ -1,4 +1,5 @@
1
1
  import { Cicada } from "./index.js";
2
+ /** Every contact, sorted by display name. */
2
3
  export async function list(authorization) {
3
4
  const response = await fetch(`${Cicada.getURL()}/cicada/contacts`, {
4
5
  method: "POST",
@@ -11,18 +12,29 @@ export async function list(authorization) {
11
12
  throw new Error(await response.text());
12
13
  return await response.json();
13
14
  }
14
- // Promote an anonymous sender into a contact. Email is mandatory; passing the
15
- // platform + raw identity (phone / handle / email) binds existing messages to it.
16
- export async function create(authorization, params) {
17
- const response = await fetch(`${Cicada.getURL()}/cicada/contacts/create`, {
15
+ /** Creates a contact, or with `id` renames one and replaces its addresses. */
16
+ export async function save(authorization, contact) {
17
+ const response = await fetch(`${Cicada.getURL()}/cicada/contacts/save`, {
18
18
  method: "POST",
19
19
  headers: {
20
20
  "Content-Type": "application/json",
21
21
  "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
22
22
  },
23
- body: JSON.stringify(params)
23
+ body: JSON.stringify(contact)
24
24
  });
25
25
  if (!response.ok)
26
26
  throw new Error(await response.text());
27
27
  return await response.json();
28
28
  }
29
+ export async function remove(authorization, id) {
30
+ const response = await fetch(`${Cicada.getURL()}/cicada/contacts/delete`, {
31
+ method: "POST",
32
+ headers: {
33
+ "Content-Type": "application/json",
34
+ "Authorization": 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`
35
+ },
36
+ body: JSON.stringify({ id })
37
+ });
38
+ if (!response.ok)
39
+ throw new Error(await response.text());
40
+ }
@@ -12,6 +12,8 @@ export type Inbox = {
12
12
  name: string;
13
13
  createdAt: Date;
14
14
  group?: InboxGroup;
15
+ /** An agent is on for this inbox. */
16
+ agent?: boolean;
15
17
  };
16
18
  export type InboxAccount = {
17
19
  platform: Platform;
@@ -46,3 +48,17 @@ export declare function setAgent(authorization: Credentials | ApiKey, inbox: str
46
48
  dailyLimit: number;
47
49
  }): Promise<AgentSettings>;
48
50
  export declare function clearAgent(authorization: Credentials | ApiKey, inbox: string): Promise<void>;
51
+ /**
52
+ * Has the inbox's agent phone `to` from one of the inbox's lines (`from`, or its first)
53
+ * and follow `directions`. Returns once the call is placed; the transcript lands on the
54
+ * thread with that number. Owners only; counts toward the agent's daily limit.
55
+ */
56
+ export declare function agentCall(authorization: Credentials, inbox: string, call: {
57
+ to: string;
58
+ directions: string;
59
+ from?: string;
60
+ }): Promise<{
61
+ calling: string;
62
+ from: string;
63
+ callId: string;
64
+ }>;
@@ -25,6 +25,7 @@ function wrapInbox(raw) {
25
25
  name: raw.name,
26
26
  createdAt: new Date(raw.createdAt),
27
27
  ...(group ? { group } : {}),
28
+ ...(raw.agent ? { agent: true } : {}),
28
29
  };
29
30
  }
30
31
  export async function list(authorization) {
@@ -80,3 +81,12 @@ export async function setAgent(authorization, inbox, settings) {
80
81
  export async function clearAgent(authorization, inbox) {
81
82
  await post(authorization, '/cicada/inboxes/agent/clear', { inbox });
82
83
  }
84
+ /**
85
+ * Has the inbox's agent phone `to` from one of the inbox's lines (`from`, or its first)
86
+ * and follow `directions`. Returns once the call is placed; the transcript lands on the
87
+ * thread with that number. Owners only; counts toward the agent's daily limit.
88
+ */
89
+ export async function agentCall(authorization, inbox, call) {
90
+ const response = await post(authorization, '/cicada/inboxes/agent/call', { inbox, ...call });
91
+ return await response.json();
92
+ }
@@ -103,6 +103,4 @@ export declare function invite(authorization: Credentials | ApiKey, email: strin
103
103
  accessCode: string;
104
104
  } | {
105
105
  reference: string;
106
- }): Promise<{
107
- status: "added" | "invited";
108
- }>;
106
+ }): Promise<void>;
@@ -318,7 +318,6 @@ export async function invite(authorization, email, joinUrl, scope) {
318
318
  });
319
319
  if (!response.ok)
320
320
  throw new Error(await response.text());
321
- return await response.json();
322
321
  }
323
322
  // ── Bootstrap helpers ────────────────────────────────────────────────────────
324
323
  async function publishPageBootstrap(web, authorization, root, onProgress, targetOverride) {
@@ -1,60 +1,207 @@
1
+ import { Fauna } from "../index.js";
1
2
  import { ApiKey, Credentials, Profile } from "./authentification.js";
2
3
  import { ChatSummary } from "./parrot/chat.js";
4
+ /** A group named inside another record. */
5
+ export type GroupRef = {
6
+ id: string;
7
+ name: string;
8
+ icon?: string;
9
+ };
10
+ export declare const GroupRef: {
11
+ fromJSON(json: any): GroupRef;
12
+ };
13
+ /** One way someone is in a group. `through` is the group's own id when they are
14
+ * directly in it, else the nested group they come in through. */
15
+ export type GroupMember = {
16
+ email: string;
17
+ displayName?: string;
18
+ icon?: string;
19
+ through: string;
20
+ };
21
+ export declare const GroupMember: {
22
+ fromJSON(json: any): GroupMember;
23
+ };
24
+ /** A group as someone in it sees it. A group holds people and other groups:
25
+ * everyone in a nested group is in this one too, never the other way. */
3
26
  export type Group = {
4
27
  id: string;
5
28
  name: string;
6
29
  icon?: string;
7
30
  balance: number;
8
- members: Profile[];
9
31
  createdAt: Date;
32
+ /** Emails of its admins, who are always directly in it: they change the group, who is in it and how people and groups join. */
33
+ admins: string[];
34
+ /** Emails of the people directly in it, admins included. */
35
+ people: string[];
36
+ /** The groups nested directly inside it. */
37
+ groups: GroupRef[];
38
+ /** Everyone in it, once per way in: the people directly in it first, then everyone who comes in through each nested group. */
39
+ members: GroupMember[];
40
+ /** How you are in it: its own id when you are directly in it, else the nested group you come in through. */
41
+ through: string;
10
42
  };
11
- /** A group as someone outside it sees it: no balance, no member list. */
43
+ export declare const Group: {
44
+ fromJSON(json: any): Group;
45
+ };
46
+ /** A join link, as the group's admins see it. People join with it, and admins of
47
+ * other groups put their group inside this one with it. */
48
+ export type JoinLink = {
49
+ code: string;
50
+ /** How many people or groups joined with it. */
51
+ uses: number;
52
+ /** How many it lets in before it is used up; absent when any number can join until it expires. */
53
+ maxUses?: number;
54
+ expires: Date;
55
+ };
56
+ export declare const JoinLink: {
57
+ fromJSON(json: any): JoinLink;
58
+ };
59
+ /** A group as anyone signed in may see it: no balance, no member list.
60
+ * `memberCount` counts everyone in it, directly or through a nested group. */
12
61
  export type GroupSummary = {
13
62
  id: string;
14
63
  name: string;
15
64
  icon?: string;
16
65
  memberCount: number;
17
66
  };
18
- /** A person found by `query`, with the groups they belong to. */
67
+ export declare const GroupSummary: {
68
+ fromJSON(json: any): GroupSummary;
69
+ };
70
+ /** A group a person found by `query` is in, and how: `through` is the group's own
71
+ * id when they are directly in it, else the nested group they come in through. */
72
+ export type MatchedGroup = {
73
+ id: string;
74
+ name: string;
75
+ icon?: string;
76
+ memberCount: number;
77
+ through: string;
78
+ };
79
+ export declare const MatchedGroup: {
80
+ fromJSON(json: any): MatchedGroup;
81
+ };
82
+ /** A person found by `query`, with every group they are in. */
19
83
  export type GroupMatch = {
20
84
  profile: Profile;
21
- groups: GroupSummary[];
85
+ groups: MatchedGroup[];
86
+ };
87
+ export declare const GroupMatch: {
88
+ fromJSON(json: any): GroupMatch;
89
+ };
90
+ /** Which side sent a nesting: `parent` invited the child, whose admins accept;
91
+ * `child` asked to go inside the parent, whose admins approve. */
92
+ export type NestSide = 'parent' | 'child';
93
+ /** A group invited inside another, or asking to go inside one, waiting for the other side's admins. */
94
+ export type GroupNest = {
95
+ token: string;
96
+ parent: GroupRef;
97
+ child: GroupRef;
98
+ from: NestSide;
99
+ /** Email of the admin who sent it. */
100
+ by?: string;
101
+ expires: Date;
102
+ };
103
+ export declare const GroupNest: {
104
+ fromJSON(json: any): GroupNest;
22
105
  };
106
+ /** What `inviteGroup` and `requestGroup` did: nested at once when you administer
107
+ * both groups, else waiting on the other side with `token`. */
108
+ export type NestOffer = {
109
+ nested: true;
110
+ } | {
111
+ nested: false;
112
+ token: string;
113
+ };
114
+ export declare const NestOffer: {
115
+ fromJSON(json: any): NestOffer;
116
+ };
117
+ /** Start a group. You are its first admin. Needs a subscription. */
23
118
  export declare function create(credentials: Credentials, name: string): Promise<Group>;
119
+ /** Every group you are in, directly or through a nested group, oldest first.
120
+ * Each says how you are in it (`through`). */
24
121
  export declare function list(authorization: Credentials | ApiKey): Promise<Group[]>;
25
- /** People matching a partial email or name, best first, each with their groups.
26
- * Only people in at least one group come back. */
122
+ /** People matching a partial email or name, best first, each with every group
123
+ * they are in and how. Only people in at least one group come back. */
27
124
  export declare function query(authorization: Credentials | ApiKey, profile: Partial<Profile>): Promise<GroupMatch[]>;
28
125
  /** Name, icon and member count of groups by id, including groups you are not in.
29
126
  * Unknown ids are left out. */
30
127
  export declare function summaries(authorization: Credentials | ApiKey, ids: string[]): Promise<GroupSummary[]>;
128
+ /** A group you are in, directly or through a nested group. */
31
129
  export declare function get(authorization: Credentials | ApiKey, id: string): Promise<Group>;
130
+ /** Change the group's name or icon. Admins only. */
32
131
  export declare function edit(credentials: Credentials, id: string, update: Partial<Group>): Promise<Group>;
33
- /** Add a user to a group by email. Resolves `{ status: 'added' }` if they were
34
- * added directly (they have a Fauna account), or `{ status: 'invited', token }`
35
- * if a pending invite was stored instead (no Fauna account for that email yet).
36
- * Fauna emails the invite unless `notify` is false, so an app can send its own
37
- * email carrying the token. */
132
+ /** Delete a group with its chats, files, calendar, rooms, webhooks and
133
+ * partnerships. It leaves every group it was in; the groups inside it stay.
134
+ * Its direct admins may, and so may anyone holding `fauna/groups:delete:global`. */
135
+ export declare function remove(credentials: Credentials, id: string): Promise<void>;
136
+ /** Invite an email to a group. Admins only. Nobody joins until they accept the
137
+ * invite with its token (`acceptInvite`), whether or not the email already has
138
+ * a Fauna account, and the answer is the same either way. Fauna emails the
139
+ * invite unless `notify` is false, so an app can send its own email carrying
140
+ * the token. Resolves to the token. */
38
141
  export declare function invite(credentials: Credentials, id: string, email: string, options?: {
39
142
  notify?: boolean;
40
- }): Promise<{
41
- status: 'added';
42
- } | {
43
- status: 'invited';
44
- token: string;
45
- }>;
46
- /** Join the group an email invite points at, using the token from the invite. */
143
+ }): Promise<string>;
144
+ /** Join the group an email invite points at, using the token from the invite.
145
+ * `alreadyMember` says you were directly in it already. */
47
146
  export declare function acceptInvite(credentials: Credentials, token: string): Promise<{
48
147
  group: Group;
49
148
  alreadyMember: boolean;
50
149
  }>;
51
- export declare function generateLink(credentials: Credentials, id: string): Promise<string>;
52
- export declare function join(credentials: Credentials, code: string): Promise<{
150
+ /** A join code good for seven days. Admins only. People join with it, and admins
151
+ * of other groups put their group inside this one with it. `maxUses` caps how
152
+ * many it lets in; without it, any number can join until it expires. */
153
+ export declare function generateLink(credentials: Credentials, id: string, options?: {
154
+ maxUses?: number;
155
+ }): Promise<string>;
156
+ /** The group's join links that still work, newest first. Admins only. */
157
+ export declare function links(credentials: Credentials, id: string): Promise<JoinLink[]>;
158
+ /** A join link stops working. Admins only. */
159
+ export declare function revokeLink(credentials: Credentials, id: string, code: string): Promise<void>;
160
+ /** Join a group with a join code. With `group`, a group you administer goes
161
+ * inside it instead, and you are in it through that group. `alreadyMember` says
162
+ * you (or `group`) were in it already. */
163
+ export declare function join(credentials: Credentials, code: string, group?: string): Promise<{
53
164
  group: Group;
54
165
  alreadyMember: boolean;
55
166
  }>;
167
+ /** Leave a group you are directly in. The last admin can't while anyone else is
168
+ * in it, directly or through a nested group: make someone else an admin, or
169
+ * delete the group. When nobody else is in it, leaving deletes it. */
56
170
  export declare function leave(credentials: Credentials, id: string): Promise<void>;
171
+ /** Remove a person who is directly in the group. Admins only. */
57
172
  export declare function kick(credentials: Credentials, id: string, email: string): Promise<void>;
173
+ /** Make a person who is directly in the group an admin. Admins only. Someone in
174
+ * it only through a nested group is invited directly first. */
175
+ export declare function promote(credentials: Credentials, id: string, email: string): Promise<Group>;
176
+ /** Make an admin a member again. Admins only; a group keeps at least one admin. */
177
+ export declare function demote(credentials: Credentials, id: string, email: string): Promise<Group>;
178
+ /** Invite group `child` inside group `id`; the child's admins accept with the
179
+ * token (`acceptNest`). Admins of `id` only. Nests at once when you administer
180
+ * both. Unless `notify` is false, the child's admins hear about it in their
181
+ * Fauna inbox. Nesting is at most 5 groups deep and never makes a loop. */
182
+ export declare function inviteGroup(credentials: Credentials, id: string, child: string, options?: {
183
+ notify?: boolean;
184
+ }): Promise<NestOffer>;
185
+ /** Ask to put group `id` inside group `parent`; the parent's admins approve with
186
+ * the token (`acceptNest`). Admins of `id` only. Nests at once when you
187
+ * administer both. Unless `notify` is false, the parent's admins hear about it
188
+ * in their Fauna inbox. */
189
+ export declare function requestGroup(credentials: Credentials, id: string, parent: string, options?: {
190
+ notify?: boolean;
191
+ }): Promise<NestOffer>;
192
+ /** The invites and requests waiting on or from a group, newest first. Admins only. */
193
+ export declare function nests(credentials: Credentials, id: string, query: {
194
+ cursor: number;
195
+ max: number;
196
+ }): Promise<GroupNest[]>;
197
+ /** Accept an invite into a group, or approve a request to join one, by its
198
+ * token. An admin of the side it waits on only. Resolves to the parent group. */
199
+ export declare function acceptNest(credentials: Credentials, token: string): Promise<Group>;
200
+ /** Drop a waiting invite or request by its token. An admin of either group. */
201
+ export declare function revokeNest(credentials: Credentials, token: string): Promise<void>;
202
+ /** Take group `child` out of group `id`. An admin of either group. Everyone who
203
+ * was in `id` only through it loses it. */
204
+ export declare function unnest(credentials: Credentials, id: string, child: string): Promise<void>;
58
205
  /** Two groups with people only chats between them. `group` is the one of yours it was listed for. */
59
206
  export type Partnership = {
60
207
  id: string;