fauna-api 1.0.686 → 1.0.693
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.
- package/dist/src/authentification.d.ts +34 -0
- package/dist/src/authentification.js +135 -0
- package/dist/src/calendar.d.ts +5 -2
- package/dist/src/calendar.js +5 -2
- package/dist/src/cicada/inboxes.d.ts +7 -1
- package/dist/src/cicada/inboxes.js +2 -0
- package/dist/src/cicada/phone.d.ts +45 -0
- package/dist/src/cicada/phone.js +46 -0
- package/dist/src/extensions/web/session.d.ts +1 -3
- package/dist/src/extensions/web/session.js +0 -1
- package/dist/src/groups.d.ts +167 -20
- package/dist/src/groups.js +287 -31
- package/dist/src/marmot/web.d.ts +27 -9
- package/dist/src/marmot/web.js +118 -79
- package/dist/src/parrot/room.d.ts +6 -2
- package/dist/src/parrot/room.js +11 -0
- package/dist/src/parrot/share.d.ts +4 -1
- package/dist/src/parrot/share.js +4 -2
- package/dist/src/rooms.d.ts +37 -11
- package/dist/src/rooms.js +46 -14
- package/dist/src/shared/server.d.ts +23 -0
- package/dist/src/shared/server.js +41 -0
- package/dist/src/ui/authentification.d.ts +6 -2
- package/dist/src/ui/authentification.js +36 -10
- package/dist/src/ui/browser.js +1 -1
- package/dist/src/ui/chat.js +8 -6
- package/dist/src/ui/chatSequence.d.ts +3 -2
- package/dist/src/ui/chatSequence.js +7 -2
- package/dist/src/ui/drive.js +1 -1
- package/dist/src/ui/index.d.ts +2 -0
- package/dist/src/ui/index.js +2 -0
- package/dist/src/ui/maps.d.ts +1 -1
- package/dist/src/ui/maps.js +3 -1
- package/dist/src/ui/markdown.d.ts +5 -0
- package/dist/src/ui/markdown.js +33 -0
- package/dist/src/ui/toast.d.ts +2 -2
- package/dist/src/ui/toast.js +5 -5
- package/dist/src/webhooks.d.ts +2 -0
- 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))
|
package/dist/src/calendar.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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.
|
|
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>;
|
package/dist/src/calendar.js
CHANGED
|
@@ -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
|
-
/**
|
|
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.
|
|
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,7 +1,7 @@
|
|
|
1
1
|
import { Cicada } from "./index.js";
|
|
2
2
|
import { Platform } from "../integrations.js";
|
|
3
3
|
import { Credentials, ApiKey } from "../authentification.js";
|
|
4
|
-
import type { Text } from "../parrot/generative.js";
|
|
4
|
+
import type { Text, Voice } from "../parrot/generative.js";
|
|
5
5
|
export type InboxGroup = {
|
|
6
6
|
id: string;
|
|
7
7
|
name: string;
|
|
@@ -30,8 +30,12 @@ export declare function assign(authorization: Credentials | ApiKey, inboxId: str
|
|
|
30
30
|
}): Promise<void>;
|
|
31
31
|
export declare function listAccounts(authorization: Credentials | ApiKey, inboxId: string): Promise<InboxAccount[]>;
|
|
32
32
|
/** `dailyLimit` and `spentToday` are dollars per UTC day; at the limit the agent pauses until midnight UTC. */
|
|
33
|
+
/** `reasoning` is one of the text model's catalog tiers, empty for its default; `voiceModel`
|
|
34
|
+
* is the realtime voice the agent talks with on calls, empty for the catalog's first. */
|
|
33
35
|
export type AgentSettings = {
|
|
34
36
|
model: Text;
|
|
37
|
+
reasoning: string;
|
|
38
|
+
voiceModel: Voice | '';
|
|
35
39
|
instructions: string;
|
|
36
40
|
dailyLimit: number;
|
|
37
41
|
spentToday: number;
|
|
@@ -44,6 +48,8 @@ export declare function getAgent(authorization: Credentials | ApiKey, inbox: str
|
|
|
44
48
|
/** Turns the agent on (it answers messages sent from now on) or updates it. */
|
|
45
49
|
export declare function setAgent(authorization: Credentials | ApiKey, inbox: string, settings: {
|
|
46
50
|
model: Text;
|
|
51
|
+
reasoning?: string;
|
|
52
|
+
voiceModel?: Voice;
|
|
47
53
|
instructions: string;
|
|
48
54
|
dailyLimit: number;
|
|
49
55
|
}): Promise<AgentSettings>;
|
|
@@ -61,6 +61,8 @@ export const AgentSettings = {
|
|
|
61
61
|
fromJSON(json) {
|
|
62
62
|
return {
|
|
63
63
|
model: json.model,
|
|
64
|
+
reasoning: String(json.reasoning ?? ''),
|
|
65
|
+
voiceModel: String(json.voiceModel ?? ''),
|
|
64
66
|
instructions: String(json.instructions ?? ''),
|
|
65
67
|
dailyLimit: Number(json.dailyLimit ?? 0),
|
|
66
68
|
spentToday: Number(json.spentToday ?? 0),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Cicada } from "./index.js";
|
|
1
2
|
import { Credentials, ApiKey } from "../authentification.js";
|
|
2
3
|
import WebSocket from "isomorphic-ws";
|
|
3
4
|
export type CallEnd = {
|
|
@@ -46,3 +47,47 @@ export declare function listen(authorization: Credentials | ApiKey, inbox: strin
|
|
|
46
47
|
}>;
|
|
47
48
|
/** Calls `to` from one of the inbox's phone lines: `from`, or its first line. */
|
|
48
49
|
export declare function call(authorization: Credentials | ApiKey, inbox: string, to: string, from?: string): Promise<PhoneCall>;
|
|
50
|
+
/** Where in a recording something was said, in milliseconds from its start. */
|
|
51
|
+
export type CallSpan = {
|
|
52
|
+
startMs: number;
|
|
53
|
+
endMs: number;
|
|
54
|
+
};
|
|
55
|
+
/** One side speaking in a recorded call, each word timed. `You` is the inbox's side on a
|
|
56
|
+
* call a person took or placed; `Agent` is the inbox's agent. */
|
|
57
|
+
export type CallSegment = CallSpan & {
|
|
58
|
+
speaker: 'Them' | 'You' | 'Agent';
|
|
59
|
+
text: string;
|
|
60
|
+
words: CallSpan[];
|
|
61
|
+
};
|
|
62
|
+
/** A call on one of the inbox's lines, with its recording's timed transcript. */
|
|
63
|
+
export type CallRecord = {
|
|
64
|
+
id: string;
|
|
65
|
+
direction: 'IN' | 'OUT';
|
|
66
|
+
/** The other party, E.164. */
|
|
67
|
+
peer: string;
|
|
68
|
+
/** The inbox's line, E.164. */
|
|
69
|
+
line: string;
|
|
70
|
+
status: string;
|
|
71
|
+
startedAt: Date;
|
|
72
|
+
/** Seconds it was connected. */
|
|
73
|
+
duration: number;
|
|
74
|
+
/** The inbox's agent took or placed it. */
|
|
75
|
+
agent: boolean;
|
|
76
|
+
/** A message left on the line, or a call that reached their voicemail. */
|
|
77
|
+
voicemail: boolean;
|
|
78
|
+
/** Its audio can be fetched with recording(). */
|
|
79
|
+
recorded: boolean;
|
|
80
|
+
segments: CallSegment[];
|
|
81
|
+
};
|
|
82
|
+
export declare const CallRecord: {
|
|
83
|
+
fromJSON(json: any): CallRecord;
|
|
84
|
+
};
|
|
85
|
+
/** The inbox's calls, newest first. `voicemails` keeps only voicemails; `query` matches what was said, the number, or the contact's name. */
|
|
86
|
+
export declare function history(authorization: Credentials | ApiKey, inbox: string, opts?: {
|
|
87
|
+
voicemails?: boolean;
|
|
88
|
+
query?: string;
|
|
89
|
+
cursor?: number;
|
|
90
|
+
max?: number;
|
|
91
|
+
}): Promise<CallRecord[]>;
|
|
92
|
+
/** A recorded call's audio, MP3. */
|
|
93
|
+
export declare function recording(authorization: Credentials | ApiKey, call: string): Promise<Blob>;
|
package/dist/src/cicada/phone.js
CHANGED
|
@@ -304,3 +304,49 @@ export async function listen(authorization, inbox, onIncoming) {
|
|
|
304
304
|
export async function call(authorization, inbox, to, from) {
|
|
305
305
|
return openCall(authorization, { event: 'dial', inbox, to, ...(from ? { from } : {}) });
|
|
306
306
|
}
|
|
307
|
+
export const CallRecord = {
|
|
308
|
+
fromJSON(json) {
|
|
309
|
+
return {
|
|
310
|
+
id: String(json.id),
|
|
311
|
+
direction: json.direction === 'in' ? 'IN' : 'OUT',
|
|
312
|
+
peer: String(json.peer ?? ''),
|
|
313
|
+
line: String(json.line ?? ''),
|
|
314
|
+
status: String(json.status ?? ''),
|
|
315
|
+
startedAt: new Date(json.startedAt),
|
|
316
|
+
duration: Number(json.duration ?? 0),
|
|
317
|
+
agent: Boolean(json.agent),
|
|
318
|
+
voicemail: Boolean(json.voicemail),
|
|
319
|
+
recorded: Boolean(json.recorded),
|
|
320
|
+
segments: Array.isArray(json.segments) ? json.segments : [],
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
/** The inbox's calls, newest first. `voicemails` keeps only voicemails; `query` matches what was said, the number, or the contact's name. */
|
|
325
|
+
export async function history(authorization, inbox, opts = {}) {
|
|
326
|
+
const response = await fetch(`${Cicada.getURL()}/cicada/phone/history`, {
|
|
327
|
+
method: 'POST',
|
|
328
|
+
headers: {
|
|
329
|
+
'Content-Type': 'application/json',
|
|
330
|
+
Authorization: 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
331
|
+
},
|
|
332
|
+
body: JSON.stringify({ inbox, ...opts }),
|
|
333
|
+
});
|
|
334
|
+
if (!response.ok)
|
|
335
|
+
throw new Error(await response.text());
|
|
336
|
+
const json = await response.json();
|
|
337
|
+
return (Array.isArray(json) ? json : []).map(CallRecord.fromJSON);
|
|
338
|
+
}
|
|
339
|
+
/** A recorded call's audio, MP3. */
|
|
340
|
+
export async function recording(authorization, call) {
|
|
341
|
+
const response = await fetch(`${Cicada.getURL()}/cicada/phone/recording`, {
|
|
342
|
+
method: 'POST',
|
|
343
|
+
headers: {
|
|
344
|
+
'Content-Type': 'application/json',
|
|
345
|
+
Authorization: 'email' in authorization ? `Token ${authorization.token}` : `ApiKey ${authorization.id}`,
|
|
346
|
+
},
|
|
347
|
+
body: JSON.stringify({ call }),
|
|
348
|
+
});
|
|
349
|
+
if (!response.ok)
|
|
350
|
+
throw new Error(await response.text());
|
|
351
|
+
return await response.blob();
|
|
352
|
+
}
|
|
@@ -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) {
|
package/dist/src/groups.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
|
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
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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;
|