@comapeo/core 2.3.2 → 3.0.0

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/errors.d.ts CHANGED
@@ -6,4 +6,20 @@ export function nullIfNotFound(err: unknown): null;
6
6
  export class NotFoundError extends Error {
7
7
  constructor(message?: string);
8
8
  }
9
+ export class AlreadyJoinedError extends Error {
10
+ /** @param {string} [message] */
11
+ constructor(message?: string | undefined);
12
+ }
13
+ export class InviteSendError extends Error {
14
+ /** @param {string} [message] */
15
+ constructor(message?: string | undefined);
16
+ }
17
+ export class InviteAbortedError extends Error {
18
+ /** @param {string} [message] */
19
+ constructor(message?: string | undefined);
20
+ }
21
+ export class TimeoutError extends Error {
22
+ /** @param {string} [message] */
23
+ constructor(message?: string | undefined);
24
+ }
9
25
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH,oCAHW,OAAO,GACL,IAAI,CAKhB;AAbD;IACE,8BAEC;CACF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAuCA;;;GAGG;AACH,oCAHW,OAAO,GACL,IAAI,CAKhB;AA9CD;IACE,8BAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF"}
@@ -0,0 +1,112 @@
1
+ /** @import { MapBuffers } from '../types.js' */
2
+ /**
3
+ * @import {
4
+ * Invite as InviteRpcMessage,
5
+ * InviteCancel,
6
+ * ProjectJoinDetails
7
+ * } from '../generated/rpc.js'
8
+ */
9
+ /**
10
+ * @internal
11
+ * @typedef {InviteRpcMessage & { receivedAt: number }} InviteInternal
12
+ */
13
+ /** @typedef {ExtractStateString<import('xstate').StateValueFrom<typeof inviteStateMachine>>} InviteState */
14
+ /** @typedef {import('type-fest').Simplify<MapBuffers<InviteInternal> & { invitorDeviceId: string } & ({ state: Exclude<InviteState, 'error'> } | { state: 'error', error: Error })>} Invite */
15
+ /**
16
+ * @typedef {import('xstate').ActorRefFrom<typeof inviteStateMachine>} invite.actor
17
+ */
18
+ /**
19
+ * @typedef {Object} InviteApiEvents
20
+ * @property {(invite: Invite) => void} invite-received
21
+ * @property {(invite: Invite) => void} invite-updated
22
+ */
23
+ /**
24
+ * @typedef {(projectDetails: Pick<ProjectJoinDetails, 'projectKey' | 'encryptionKeys'> & { projectName: string }) => Promise<string>} AddProjectQuery
25
+ */
26
+ /**
27
+ * @extends {TypedEmitter<InviteApiEvents>}
28
+ */
29
+ export class InviteApi extends TypedEmitter<InviteApiEvents> {
30
+ /**
31
+ * @param {Object} options
32
+ * @param {import('../local-peers.js').LocalPeers} options.rpc
33
+ * @param {object} options.queries
34
+ * @param {(projectInviteId: Readonly<Buffer>) => undefined | { projectPublicId: string }} options.queries.getProjectByInviteId
35
+ * @param {AddProjectQuery} options.queries.addProject
36
+ * @param {Logger} [options.logger]
37
+ */
38
+ constructor({ rpc, queries, logger }: {
39
+ rpc: import("../local-peers.js").LocalPeers;
40
+ queries: {
41
+ getProjectByInviteId: (projectInviteId: Readonly<Buffer>) => undefined | {
42
+ projectPublicId: string;
43
+ };
44
+ addProject: AddProjectQuery;
45
+ };
46
+ logger?: Logger | undefined;
47
+ });
48
+ rpc: import("../local-peers.js").LocalPeers;
49
+ /**
50
+ * Get all invites (in all)
51
+ *
52
+ * @returns {Array<Invite>}
53
+ */
54
+ getMany(): Array<Invite>;
55
+ /**
56
+ * Get an invite by inviteId
57
+ *
58
+ * @param {string} inviteIdString
59
+ * @returns {Invite}
60
+ */
61
+ getById(inviteIdString: string): Invite;
62
+ /**
63
+ * Attempt to accept the invite.
64
+ *
65
+ * This can fail if the invitor has canceled the invite or if you cannot
66
+ * connect to the invitor's device.
67
+ *
68
+ * If the invite is accepted and you had other invites to the same project,
69
+ * those invites are removed, and the invitors are told that you're already
70
+ * part of this project.
71
+ *
72
+ * @param {Pick<Invite, 'inviteId'>} invite
73
+ * @returns {Promise<string>}
74
+ */
75
+ accept({ inviteId: inviteIdString }: Pick<Invite, "inviteId">): Promise<string>;
76
+ /**
77
+ * @param {Pick<Invite, 'inviteId'>} invite
78
+ * @returns {void}
79
+ */
80
+ reject({ inviteId: inviteIdString }: Pick<Invite, "inviteId">): void;
81
+ #private;
82
+ }
83
+ export type ExtractStateString<T extends import("xstate").StateValue> = T extends string ? T : T extends import("xstate").StateValueMap ? keyof T : never;
84
+ export type InviteInternal = InviteRpcMessage & {
85
+ receivedAt: number;
86
+ };
87
+ export type InviteState = ExtractStateString<import("xstate").StateValueFrom<typeof inviteStateMachine>>;
88
+ export type Invite = import("type-fest").Simplify<MapBuffers<InviteInternal> & {
89
+ invitorDeviceId: string;
90
+ } & ({
91
+ state: Exclude<InviteState, "error">;
92
+ } | {
93
+ state: "error";
94
+ error: Error;
95
+ })>;
96
+ export namespace invite {
97
+ type actor = import("xstate").ActorRefFrom<typeof inviteStateMachine>;
98
+ }
99
+ export type InviteApiEvents = {
100
+ "invite-received": (invite: Invite) => void;
101
+ "invite-updated": (invite: Invite) => void;
102
+ };
103
+ export type AddProjectQuery = (projectDetails: Pick<ProjectJoinDetails, "projectKey" | "encryptionKeys"> & {
104
+ projectName: string;
105
+ }) => Promise<string>;
106
+ import { TypedEmitter } from 'tiny-typed-emitter';
107
+ import { Logger } from '../logger.js';
108
+ import type { Invite as InviteRpcMessage } from '../generated/rpc.js';
109
+ import { inviteStateMachine } from './invite-state-machine.js';
110
+ import type { MapBuffers } from '../types.js';
111
+ import type { ProjectJoinDetails } from '../generated/rpc.js';
112
+ //# sourceMappingURL=invite-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invite-api.d.ts","sourceRoot":"","sources":["../../src/invite/invite-api.js"],"names":[],"mapp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AK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;;iBAGvK,OAAO,QAAQ,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC;;;uBAKvD,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI;sBACxB,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI;;8BAIzB,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY,GAAG,gBAAgB,CAAC,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC;6BA/CxG,oBAAoB;uBAK1B,cAAc;gDAe3B,qBAAqB;mCAbI,2BAA2B;gCAO9B,aAAa;wCAMnC,qBAAqB"}
@@ -0,0 +1,510 @@
1
+ /** @import { StringToTaggedUnion } from '../types.js' */
2
+ /** @import { ProjectJoinDetails } from '../generated/rpc.js' */
3
+ /**
4
+ * @internal
5
+ * @typedef {object} Context
6
+ * @property {null | Error} error
7
+ * @property {null | string} projectPublicId
8
+ */
9
+ /**
10
+ * @typedef {object} MachineSetupTypes
11
+ * @property {Context} context
12
+ * @property {{ projectPublicId: string | null }} output
13
+ * @property {StringToTaggedUnion<'ACCEPT_INVITE' | 'CANCEL_INVITE' | 'REJECT_INVITE' | 'ALREADY_IN_PROJECT' | 'ADDED_PROJECT' | 'PEER_DISCONNECTED'> | ({ type: 'RECEIVE_PROJECT_DETAILS' } & ProjectJoinDetails)} events
14
+ */
15
+ export const inviteStateMachine: import("xstate").StateMachine<Context, {
16
+ type: "ACCEPT_INVITE";
17
+ } | {
18
+ type: "CANCEL_INVITE";
19
+ } | {
20
+ type: "REJECT_INVITE";
21
+ } | {
22
+ type: "ALREADY_IN_PROJECT";
23
+ } | {
24
+ type: "ADDED_PROJECT";
25
+ } | {
26
+ type: "PEER_DISCONNECTED";
27
+ } | ({
28
+ type: "RECEIVE_PROJECT_DETAILS";
29
+ } & ProjectJoinDetails), {
30
+ [x: string]: import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<void, {
31
+ decision: InviteResponse_Decision;
32
+ }, import("xstate").EventObject>> | import("xstate").ActorRefFromLogic<import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>> | undefined;
33
+ }, import("xstate").Values<{
34
+ sendInviteResponse: {
35
+ src: "sendInviteResponse";
36
+ logic: import("xstate").PromiseActorLogic<void, {
37
+ decision: InviteResponse_Decision;
38
+ }, import("xstate").EventObject>;
39
+ id: string | undefined;
40
+ };
41
+ addProject: {
42
+ src: "addProject";
43
+ logic: import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>;
44
+ id: string | undefined;
45
+ };
46
+ }>, never, {
47
+ type: "isNotAlreadyJoiningOrInProject";
48
+ params: unknown;
49
+ }, "receiveTimeout" | "addProjectTimeout", "error" | "rejected" | "pending" | "canceled" | "respondedAlready" | "joined" | {
50
+ responding: "default" | "accept" | "reject" | "already";
51
+ } | {
52
+ joining: "awaitingDetails" | "addingProject";
53
+ }, string, import("xstate").NonReducibleUnknown, {
54
+ projectPublicId: string | null;
55
+ }, import("xstate").EventObject, import("xstate").MetaObject, {
56
+ readonly id: "invite";
57
+ readonly context: {
58
+ readonly error: null;
59
+ readonly projectPublicId: null;
60
+ };
61
+ readonly initial: "pending";
62
+ readonly states: {
63
+ readonly pending: {
64
+ readonly description: "Pending invite awaiting response";
65
+ readonly on: {
66
+ readonly CANCEL_INVITE: {
67
+ readonly target: "canceled";
68
+ };
69
+ readonly ACCEPT_INVITE: readonly [{
70
+ readonly target: "responding.accept";
71
+ readonly guard: {
72
+ readonly type: "isNotAlreadyJoiningOrInProject";
73
+ };
74
+ }, {
75
+ readonly actions: import("xstate").ActionFunction<Context, {
76
+ type: "ACCEPT_INVITE";
77
+ }, {
78
+ type: "ACCEPT_INVITE";
79
+ } | {
80
+ type: "CANCEL_INVITE";
81
+ } | {
82
+ type: "REJECT_INVITE";
83
+ } | {
84
+ type: "ALREADY_IN_PROJECT";
85
+ } | {
86
+ type: "ADDED_PROJECT";
87
+ } | {
88
+ type: "PEER_DISCONNECTED";
89
+ } | ({
90
+ type: "RECEIVE_PROJECT_DETAILS";
91
+ } & ProjectJoinDetails), undefined, never, never, never, "receiveTimeout" | "addProjectTimeout", never>;
92
+ }];
93
+ readonly ALREADY_IN_PROJECT: {
94
+ readonly target: "responding.already";
95
+ };
96
+ readonly REJECT_INVITE: {
97
+ readonly target: "responding.reject";
98
+ };
99
+ };
100
+ };
101
+ readonly responding: {
102
+ readonly description: "Responding to invite";
103
+ readonly initial: "default";
104
+ readonly on: {
105
+ readonly CANCEL_INVITE: {
106
+ readonly target: "#invite.canceled";
107
+ };
108
+ };
109
+ readonly states: {
110
+ readonly default: {
111
+ readonly always: {
112
+ readonly target: "#invite.error";
113
+ readonly actions: import("xstate").ActionFunction<Context, {
114
+ type: "ACCEPT_INVITE";
115
+ } | {
116
+ type: "CANCEL_INVITE";
117
+ } | {
118
+ type: "REJECT_INVITE";
119
+ } | {
120
+ type: "ALREADY_IN_PROJECT";
121
+ } | {
122
+ type: "ADDED_PROJECT";
123
+ } | {
124
+ type: "PEER_DISCONNECTED";
125
+ } | ({
126
+ type: "RECEIVE_PROJECT_DETAILS";
127
+ } & ProjectJoinDetails), {
128
+ type: "ACCEPT_INVITE";
129
+ } | {
130
+ type: "CANCEL_INVITE";
131
+ } | {
132
+ type: "REJECT_INVITE";
133
+ } | {
134
+ type: "ALREADY_IN_PROJECT";
135
+ } | {
136
+ type: "ADDED_PROJECT";
137
+ } | {
138
+ type: "PEER_DISCONNECTED";
139
+ } | ({
140
+ type: "RECEIVE_PROJECT_DETAILS";
141
+ } & ProjectJoinDetails), undefined, import("xstate").Values<{
142
+ sendInviteResponse: {
143
+ src: "sendInviteResponse";
144
+ logic: import("xstate").PromiseActorLogic<void, {
145
+ decision: InviteResponse_Decision;
146
+ }, import("xstate").EventObject>;
147
+ id: string | undefined;
148
+ };
149
+ addProject: {
150
+ src: "addProject";
151
+ logic: import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>;
152
+ id: string | undefined;
153
+ };
154
+ }>, never, never, never, never>;
155
+ };
156
+ };
157
+ readonly accept: {
158
+ readonly description: "Sending accept response";
159
+ readonly invoke: {
160
+ readonly src: "sendInviteResponse";
161
+ readonly input: {
162
+ readonly decision: "ACCEPT";
163
+ };
164
+ readonly onDone: "#invite.joining";
165
+ readonly onError: "#invite.error";
166
+ };
167
+ readonly on: {
168
+ readonly RECEIVE_PROJECT_DETAILS: {
169
+ readonly target: "#invite.joining.addingProject";
170
+ };
171
+ };
172
+ };
173
+ readonly reject: {
174
+ readonly description: "Sending reject response";
175
+ readonly invoke: {
176
+ readonly src: "sendInviteResponse";
177
+ readonly input: {
178
+ readonly decision: "REJECT";
179
+ };
180
+ readonly onDone: "#invite.rejected";
181
+ readonly onError: "#invite.error";
182
+ };
183
+ };
184
+ readonly already: {
185
+ readonly description: "Sending already response";
186
+ readonly invoke: {
187
+ readonly src: "sendInviteResponse";
188
+ readonly input: {
189
+ readonly decision: "ALREADY";
190
+ };
191
+ readonly onDone: "#invite.respondedAlready";
192
+ readonly onError: "#invite.error";
193
+ };
194
+ };
195
+ };
196
+ };
197
+ readonly joining: {
198
+ readonly initial: "awaitingDetails";
199
+ readonly description: "Joining project from invite";
200
+ readonly states: {
201
+ readonly awaitingDetails: {
202
+ readonly description: "Waiting for project details";
203
+ readonly on: {
204
+ readonly RECEIVE_PROJECT_DETAILS: {
205
+ readonly target: "addingProject";
206
+ };
207
+ readonly CANCEL_INVITE: {
208
+ readonly target: "#invite.canceled";
209
+ };
210
+ };
211
+ readonly after: {
212
+ readonly receiveTimeout: {
213
+ readonly target: "#invite.error";
214
+ readonly actions: import("xstate").ActionFunction<Context, {
215
+ type: "ACCEPT_INVITE";
216
+ } | {
217
+ type: "CANCEL_INVITE";
218
+ } | {
219
+ type: "REJECT_INVITE";
220
+ } | {
221
+ type: "ALREADY_IN_PROJECT";
222
+ } | {
223
+ type: "ADDED_PROJECT";
224
+ } | {
225
+ type: "PEER_DISCONNECTED";
226
+ } | ({
227
+ type: "RECEIVE_PROJECT_DETAILS";
228
+ } & ProjectJoinDetails), {
229
+ type: "ACCEPT_INVITE";
230
+ } | {
231
+ type: "CANCEL_INVITE";
232
+ } | {
233
+ type: "REJECT_INVITE";
234
+ } | {
235
+ type: "ALREADY_IN_PROJECT";
236
+ } | {
237
+ type: "ADDED_PROJECT";
238
+ } | {
239
+ type: "PEER_DISCONNECTED";
240
+ } | ({
241
+ type: "RECEIVE_PROJECT_DETAILS";
242
+ } & ProjectJoinDetails), undefined, import("xstate").Values<{
243
+ sendInviteResponse: {
244
+ src: "sendInviteResponse";
245
+ logic: import("xstate").PromiseActorLogic<void, {
246
+ decision: InviteResponse_Decision;
247
+ }, import("xstate").EventObject>;
248
+ id: string | undefined;
249
+ };
250
+ addProject: {
251
+ src: "addProject";
252
+ logic: import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>;
253
+ id: string | undefined;
254
+ };
255
+ }>, never, never, never, never>;
256
+ };
257
+ };
258
+ };
259
+ readonly addingProject: {
260
+ readonly description: "Adding project from invite";
261
+ readonly invoke: {
262
+ readonly src: "addProject";
263
+ readonly input: ({ event }: {
264
+ context: Context;
265
+ event: {
266
+ type: "ACCEPT_INVITE";
267
+ } | {
268
+ type: "CANCEL_INVITE";
269
+ } | {
270
+ type: "REJECT_INVITE";
271
+ } | {
272
+ type: "ALREADY_IN_PROJECT";
273
+ } | {
274
+ type: "ADDED_PROJECT";
275
+ } | {
276
+ type: "PEER_DISCONNECTED";
277
+ } | ({
278
+ type: "RECEIVE_PROJECT_DETAILS";
279
+ } & ProjectJoinDetails);
280
+ self: import("xstate").ActorRef<import("xstate").MachineSnapshot<Context, {
281
+ type: "ACCEPT_INVITE";
282
+ } | {
283
+ type: "CANCEL_INVITE";
284
+ } | {
285
+ type: "REJECT_INVITE";
286
+ } | {
287
+ type: "ALREADY_IN_PROJECT";
288
+ } | {
289
+ type: "ADDED_PROJECT";
290
+ } | {
291
+ type: "PEER_DISCONNECTED";
292
+ } | ({
293
+ type: "RECEIVE_PROJECT_DETAILS";
294
+ } & ProjectJoinDetails), Record<string, import("xstate").AnyActorRef>, import("xstate").StateValue, string, unknown, any, any>, {
295
+ type: "ACCEPT_INVITE";
296
+ } | {
297
+ type: "CANCEL_INVITE";
298
+ } | {
299
+ type: "REJECT_INVITE";
300
+ } | {
301
+ type: "ALREADY_IN_PROJECT";
302
+ } | {
303
+ type: "ADDED_PROJECT";
304
+ } | {
305
+ type: "PEER_DISCONNECTED";
306
+ } | ({
307
+ type: "RECEIVE_PROJECT_DETAILS";
308
+ } & ProjectJoinDetails), import("xstate").AnyEventObject>;
309
+ }) => Omit<{
310
+ type: "RECEIVE_PROJECT_DETAILS";
311
+ } & ProjectJoinDetails, "type">;
312
+ readonly onDone: {
313
+ readonly target: "#invite.joined";
314
+ readonly actions: import("xstate").ActionFunction<Context, import("xstate").DoneActorEvent<string, string>, {
315
+ type: "ACCEPT_INVITE";
316
+ } | {
317
+ type: "CANCEL_INVITE";
318
+ } | {
319
+ type: "REJECT_INVITE";
320
+ } | {
321
+ type: "ALREADY_IN_PROJECT";
322
+ } | {
323
+ type: "ADDED_PROJECT";
324
+ } | {
325
+ type: "PEER_DISCONNECTED";
326
+ } | ({
327
+ type: "RECEIVE_PROJECT_DETAILS";
328
+ } & ProjectJoinDetails), undefined, import("xstate").Values<{
329
+ sendInviteResponse: {
330
+ src: "sendInviteResponse";
331
+ logic: import("xstate").PromiseActorLogic<void, {
332
+ decision: InviteResponse_Decision;
333
+ }, import("xstate").EventObject>;
334
+ id: string | undefined;
335
+ };
336
+ addProject: {
337
+ src: "addProject";
338
+ logic: import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>;
339
+ id: string | undefined;
340
+ };
341
+ }>, never, never, never, never>;
342
+ };
343
+ readonly onError: "#invite.error";
344
+ };
345
+ readonly after: {
346
+ readonly addProjectTimeout: {
347
+ readonly target: "#invite.error";
348
+ readonly actions: import("xstate").ActionFunction<Context, {
349
+ type: "ACCEPT_INVITE";
350
+ } | {
351
+ type: "CANCEL_INVITE";
352
+ } | {
353
+ type: "REJECT_INVITE";
354
+ } | {
355
+ type: "ALREADY_IN_PROJECT";
356
+ } | {
357
+ type: "ADDED_PROJECT";
358
+ } | {
359
+ type: "PEER_DISCONNECTED";
360
+ } | ({
361
+ type: "RECEIVE_PROJECT_DETAILS";
362
+ } & ProjectJoinDetails), {
363
+ type: "ACCEPT_INVITE";
364
+ } | {
365
+ type: "CANCEL_INVITE";
366
+ } | {
367
+ type: "REJECT_INVITE";
368
+ } | {
369
+ type: "ALREADY_IN_PROJECT";
370
+ } | {
371
+ type: "ADDED_PROJECT";
372
+ } | {
373
+ type: "PEER_DISCONNECTED";
374
+ } | ({
375
+ type: "RECEIVE_PROJECT_DETAILS";
376
+ } & ProjectJoinDetails), undefined, import("xstate").Values<{
377
+ sendInviteResponse: {
378
+ src: "sendInviteResponse";
379
+ logic: import("xstate").PromiseActorLogic<void, {
380
+ decision: InviteResponse_Decision;
381
+ }, import("xstate").EventObject>;
382
+ id: string | undefined;
383
+ };
384
+ addProject: {
385
+ src: "addProject";
386
+ logic: import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>;
387
+ id: string | undefined;
388
+ };
389
+ }>, never, never, never, never>;
390
+ };
391
+ };
392
+ };
393
+ };
394
+ };
395
+ readonly canceled: {
396
+ readonly description: "The invite has been canceled";
397
+ readonly type: "final";
398
+ };
399
+ readonly rejected: {
400
+ readonly description: "Rejected invite";
401
+ readonly type: "final";
402
+ };
403
+ readonly respondedAlready: {
404
+ readonly description: "Responded that already in project";
405
+ readonly type: "final";
406
+ };
407
+ readonly joined: {
408
+ readonly description: "Successfully joined project";
409
+ readonly type: "final";
410
+ };
411
+ readonly error: {
412
+ readonly entry: import("xstate").ActionFunction<Context, {
413
+ type: "ACCEPT_INVITE";
414
+ } | {
415
+ type: "CANCEL_INVITE";
416
+ } | {
417
+ type: "REJECT_INVITE";
418
+ } | {
419
+ type: "ALREADY_IN_PROJECT";
420
+ } | {
421
+ type: "ADDED_PROJECT";
422
+ } | {
423
+ type: "PEER_DISCONNECTED";
424
+ } | ({
425
+ type: "RECEIVE_PROJECT_DETAILS";
426
+ } & ProjectJoinDetails), {
427
+ type: "ACCEPT_INVITE";
428
+ } | {
429
+ type: "CANCEL_INVITE";
430
+ } | {
431
+ type: "REJECT_INVITE";
432
+ } | {
433
+ type: "ALREADY_IN_PROJECT";
434
+ } | {
435
+ type: "ADDED_PROJECT";
436
+ } | {
437
+ type: "PEER_DISCONNECTED";
438
+ } | ({
439
+ type: "RECEIVE_PROJECT_DETAILS";
440
+ } & ProjectJoinDetails), undefined, import("xstate").Values<{
441
+ sendInviteResponse: {
442
+ src: "sendInviteResponse";
443
+ logic: import("xstate").PromiseActorLogic<void, {
444
+ decision: InviteResponse_Decision;
445
+ }, import("xstate").EventObject>;
446
+ id: string | undefined;
447
+ };
448
+ addProject: {
449
+ src: "addProject";
450
+ logic: import("xstate").PromiseActorLogic<string, ProjectJoinDetails, import("xstate").EventObject>;
451
+ id: string | undefined;
452
+ };
453
+ }>, never, never, never, never>;
454
+ readonly type: "final";
455
+ readonly description: "Error joining project";
456
+ };
457
+ };
458
+ readonly output: ({ context }: {
459
+ context: Context;
460
+ event: import("xstate").DoneStateEvent<unknown>;
461
+ self: import("xstate").ActorRef<import("xstate").MachineSnapshot<Context, {
462
+ type: "ACCEPT_INVITE";
463
+ } | {
464
+ type: "CANCEL_INVITE";
465
+ } | {
466
+ type: "REJECT_INVITE";
467
+ } | {
468
+ type: "ALREADY_IN_PROJECT";
469
+ } | {
470
+ type: "ADDED_PROJECT";
471
+ } | {
472
+ type: "PEER_DISCONNECTED";
473
+ } | ({
474
+ type: "RECEIVE_PROJECT_DETAILS";
475
+ } & ProjectJoinDetails), Record<string, import("xstate").AnyActorRef>, import("xstate").StateValue, string, unknown, any, any>, {
476
+ type: "ACCEPT_INVITE";
477
+ } | {
478
+ type: "CANCEL_INVITE";
479
+ } | {
480
+ type: "REJECT_INVITE";
481
+ } | {
482
+ type: "ALREADY_IN_PROJECT";
483
+ } | {
484
+ type: "ADDED_PROJECT";
485
+ } | {
486
+ type: "PEER_DISCONNECTED";
487
+ } | ({
488
+ type: "RECEIVE_PROJECT_DETAILS";
489
+ } & ProjectJoinDetails), import("xstate").AnyEventObject>;
490
+ }) => {
491
+ projectPublicId: string | null;
492
+ };
493
+ }>;
494
+ export type Context = {
495
+ error: null | Error;
496
+ projectPublicId: null | string;
497
+ };
498
+ export type MachineSetupTypes = {
499
+ context: Context;
500
+ output: {
501
+ projectPublicId: string | null;
502
+ };
503
+ events: StringToTaggedUnion<"ACCEPT_INVITE" | "CANCEL_INVITE" | "REJECT_INVITE" | "ALREADY_IN_PROJECT" | "ADDED_PROJECT" | "PEER_DISCONNECTED"> | ({
504
+ type: "RECEIVE_PROJECT_DETAILS";
505
+ } & ProjectJoinDetails);
506
+ };
507
+ import type { ProjectJoinDetails } from '../generated/rpc.js';
508
+ import { InviteResponse_Decision } from '../generated/rpc.js';
509
+ import type { StringToTaggedUnion } from '../types.js';
510
+ //# sourceMappingURL=invite-state-machine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invite-state-machine.d.ts","sourceRoot":"","sources":["../../src/invite/invite-state-machine.js"],"names":[],"mappings":"AASA,yDAAyD;AACzD,gEAAgE;AAChE;;;;;GAKG;AACH;;;;;GAKG;AAEH;;;;;;;;;;;;;UAHiK,yBAAyB;;;kBAQpJ,uBAAuB;;;;;;sBAAvB,uBAAuB;;;;;;;;;;;;;;;;;qBAT5B,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BACmH,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAAzB,yBAAyB;;;;;;;;;;;;;;kCAAzB,yBAAyB;;;;;8CAQpJ,uBA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