@aeolus-fleet/core 0.30.0 → 0.31.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/adapters/prisma/generated/browser.d.ts +18 -1
- package/dist/adapters/prisma/generated/client.d.ts +18 -1
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +30 -0
- package/dist/adapters/prisma/generated/enums.d.ts +6 -0
- package/dist/adapters/prisma/generated/enums.js +6 -1
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +33 -0
- package/dist/adapters/prisma/generated/internal/class.js +4 -4
- package/dist/adapters/prisma/generated/internal/class.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.d.ts +271 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +34 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +37 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +34 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/Delivery.d.ts +1 -10
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +1179 -114
- package/dist/adapters/prisma/generated/models/Meeting.d.ts +2520 -0
- package/dist/adapters/prisma/generated/models/Meeting.js +2 -0
- package/dist/adapters/prisma/generated/models/Meeting.js.map +1 -0
- package/dist/adapters/prisma/generated/models/MeetingMicRequest.d.ts +1398 -0
- package/dist/adapters/prisma/generated/models/MeetingMicRequest.js +2 -0
- package/dist/adapters/prisma/generated/models/MeetingMicRequest.js.map +1 -0
- package/dist/adapters/prisma/generated/models/MeetingParticipant.d.ts +1630 -0
- package/dist/adapters/prisma/generated/models/MeetingParticipant.js +2 -0
- package/dist/adapters/prisma/generated/models/MeetingParticipant.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Message.d.ts +274 -1
- package/dist/adapters/prisma/generated/models/Ship.d.ts +1765 -68
- package/dist/adapters/prisma/generated/models.d.ts +3 -0
- package/dist/adapters/prisma/history.js +5 -3
- package/dist/adapters/prisma/history.js.map +1 -1
- package/dist/adapters/prisma/meetings.d.ts +4 -0
- package/dist/adapters/prisma/meetings.js +103 -0
- package/dist/adapters/prisma/meetings.js.map +1 -0
- package/dist/adapters/prisma/messaging.js +1 -0
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/prisma/registry.js +7 -0
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.js +5 -1
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/prisma/unit-of-work.d.ts +2 -1
- package/dist/adapters/prisma/unit-of-work.js +2 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- package/dist/adapters/trpc/console.d.ts +1 -1
- package/dist/adapters/trpc/context.d.ts +10 -0
- package/dist/adapters/trpc/fleet.d.ts +26 -14
- package/dist/adapters/trpc/router.d.ts +214 -15
- package/dist/adapters/trpc/ship-protocol.js +2 -1
- package/dist/adapters/trpc/ship-protocol.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +209 -0
- package/dist/adapters/trpc/ship.js +220 -2
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/trpc.js +19 -0
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.js +3 -1
- package/dist/app.js.map +1 -1
- package/dist/domain/messaging/add-to-meeting.d.ts +41 -0
- package/dist/domain/messaging/add-to-meeting.js +76 -0
- package/dist/domain/messaging/add-to-meeting.js.map +1 -0
- package/dist/domain/messaging/answer.d.ts +2 -1
- package/dist/domain/messaging/answer.js +3 -2
- package/dist/domain/messaging/answer.js.map +1 -1
- package/dist/domain/messaging/change-meeting.d.ts +32 -0
- package/dist/domain/messaging/change-meeting.js +35 -0
- package/dist/domain/messaging/change-meeting.js.map +1 -0
- package/dist/domain/messaging/change-mic.d.ts +30 -0
- package/dist/domain/messaging/change-mic.js +27 -0
- package/dist/domain/messaging/change-mic.js.map +1 -0
- package/dist/domain/messaging/dismiss-delivery.js +2 -1
- package/dist/domain/messaging/dismiss-delivery.js.map +1 -1
- package/dist/domain/messaging/meeting-life.d.ts +76 -0
- package/dist/domain/messaging/meeting-life.js +136 -0
- package/dist/domain/messaging/meeting-life.js.map +1 -0
- package/dist/domain/messaging/meeting-notice.d.ts +58 -0
- package/dist/domain/messaging/meeting-notice.js +87 -0
- package/dist/domain/messaging/meeting-notice.js.map +1 -0
- package/dist/domain/messaging/meeting.d.ts +103 -0
- package/dist/domain/messaging/meeting.js +106 -0
- package/dist/domain/messaging/meeting.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +29 -4
- package/dist/domain/messaging/message.js +84 -9
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/mic.d.ts +64 -0
- package/dist/domain/messaging/mic.js +130 -0
- package/dist/domain/messaging/mic.js.map +1 -0
- package/dist/domain/messaging/open-meeting.d.ts +61 -0
- package/dist/domain/messaging/open-meeting.js +98 -0
- package/dist/domain/messaging/open-meeting.js.map +1 -0
- package/dist/domain/messaging/ports.d.ts +45 -1
- package/dist/domain/messaging/public.d.ts +3 -0
- package/dist/domain/messaging/public.js +1 -0
- package/dist/domain/messaging/public.js.map +1 -1
- package/dist/domain/messaging/read-meeting.d.ts +67 -0
- package/dist/domain/messaging/read-meeting.js +61 -0
- package/dist/domain/messaging/read-meeting.js.map +1 -0
- package/dist/domain/messaging/receive-deliveries.d.ts +3 -1
- package/dist/domain/messaging/receive-deliveries.js +1 -0
- package/dist/domain/messaging/receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/resend-delivery.js +4 -3
- package/dist/domain/messaging/resend-delivery.js.map +1 -1
- package/dist/domain/messaging/retired-participant.d.ts +36 -0
- package/dist/domain/messaging/retired-participant.js +38 -0
- package/dist/domain/messaging/retired-participant.js.map +1 -0
- package/dist/domain/messaging/send-message.d.ts +8 -2
- package/dist/domain/messaging/send-message.js +72 -1
- package/dist/domain/messaging/send-message.js.map +1 -1
- package/dist/domain/messaging/send-request.js +2 -0
- package/dist/domain/messaging/send-request.js.map +1 -1
- package/dist/domain/registry/ports.d.ts +2 -0
- package/dist/domain/registry/public.d.ts +2 -1
- package/dist/domain/registry/public.js +2 -1
- package/dist/domain/registry/public.js.map +1 -1
- package/dist/domain/registry/read-built-in-rules.d.ts +2 -1
- package/dist/domain/registry/read-built-in-rules.js +3 -1
- package/dist/domain/registry/read-built-in-rules.js.map +1 -1
- package/dist/domain/registry/resolve-invitees.d.ts +27 -0
- package/dist/domain/registry/resolve-invitees.js +27 -0
- package/dist/domain/registry/resolve-invitees.js.map +1 -0
- package/dist/domain/registry/resolve-selector.d.ts +2 -2
- package/dist/domain/registry/resolve-selector.js.map +1 -1
- package/dist/domain/registry/retire-ship.d.ts +8 -3
- package/dist/domain/registry/retire-ship.js +10 -1
- package/dist/domain/registry/retire-ship.js.map +1 -1
- package/dist/domain/shared/close-health-snapshots.d.ts +5 -2
- package/dist/domain/shared/close-health-snapshots.js +12 -6
- package/dist/domain/shared/close-health-snapshots.js.map +1 -1
- package/dist/domain/shared/errors.d.ts +1 -1
- package/dist/domain/shared/errors.js.map +1 -1
- package/dist/domain/shared/history.d.ts +10 -2
- package/dist/domain/shared/history.js +17 -2
- package/dist/domain/shared/history.js.map +1 -1
- package/dist/domain/shared/selector.d.ts +17 -9
- package/dist/wiring.d.ts +10 -0
- package/dist/wiring.js +11 -1
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261024160000_meetings/migration.sql +86 -0
- package/src/adapters/prisma/migrations/20261024160100_meetings_open_scope/migration.sql +64 -0
- package/src/adapters/prisma/migrations/20261024160200_meetings_mic/migration.sql +35 -0
- package/src/adapters/prisma/migrations/20261024160300_meetings_life/migration.sql +6 -0
- package/src/adapters/prisma/schema.prisma +205 -106
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { refuse } from '../shared/errors.js';
|
|
2
|
+
import { shipActor } from '../shared/events.js';
|
|
3
|
+
import { ok } from '../shared/result.js';
|
|
4
|
+
import { checkPresent, isPresent } from './meeting.js';
|
|
5
|
+
import { offTheMic } from './mic.js';
|
|
6
|
+
const ENDED = 'it no longer changes';
|
|
7
|
+
/**
|
|
8
|
+
* Changes the meeting for the ship `by`. A rejoin takes a ship that left,
|
|
9
|
+
* whose right stands; every other change takes a present participant of the
|
|
10
|
+
* open meeting. The owner's reach for a rejoin is the caller's to check.
|
|
11
|
+
*/
|
|
12
|
+
export function changeMeeting(meeting, input) {
|
|
13
|
+
const { meetingId, by, change, at } = input;
|
|
14
|
+
if (change.kind === 'rejoin') {
|
|
15
|
+
return rejoined(meeting, { meetingId, by, at });
|
|
16
|
+
}
|
|
17
|
+
const present = checkPresent(meeting, { meetingId, shipId: by, ended: ENDED });
|
|
18
|
+
if (!present.isOk) {
|
|
19
|
+
return present;
|
|
20
|
+
}
|
|
21
|
+
const open = present.value;
|
|
22
|
+
const actor = shipActor(by);
|
|
23
|
+
switch (change.kind) {
|
|
24
|
+
case 'leave':
|
|
25
|
+
return byOwnerNever(open, by) ?? ok(gone(open, { shipId: by, actor, at, type: 'ParticipantLeft', isRevoked: false }));
|
|
26
|
+
case 'revoke':
|
|
27
|
+
return (onlyByOwner(open, by) ??
|
|
28
|
+
byOwnerNever(open, change.shipId) ??
|
|
29
|
+
presentOnly(open, change.shipId) ??
|
|
30
|
+
ok(gone(open, { shipId: change.shipId, actor, at, type: 'ParticipantRevoked', isRevoked: true })));
|
|
31
|
+
case 'transfer':
|
|
32
|
+
return onlyByOwner(open, by) ?? presentOnly(open, change.shipId) ?? ok(roleChanged(open, { role: 'owner', shipId: change.shipId, actor, at }));
|
|
33
|
+
case 'nameModerator':
|
|
34
|
+
return onlyByOwner(open, by) ?? presentOnly(open, change.shipId) ?? ok(roleChanged(open, { role: 'moderator', shipId: change.shipId, actor, at }));
|
|
35
|
+
case 'end':
|
|
36
|
+
if (by !== open.ownerShipId && by !== open.moderatorShipId) {
|
|
37
|
+
return refuse('NOT_OWNER_OR_MODERATOR', `Only the owner or the moderator of meeting ${open.id} ends it`);
|
|
38
|
+
}
|
|
39
|
+
return ok(ended(open, { by, actor, at }));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The ships added to the meeting by its owner (M5, M13): each ship not
|
|
44
|
+
* present joins now, after those there, its right given back if the owner had
|
|
45
|
+
* revoked it. A ship present already stays as it is. The owner's reach of each
|
|
46
|
+
* added ship is the caller's to check.
|
|
47
|
+
*/
|
|
48
|
+
export function addToMeeting(meeting, input) {
|
|
49
|
+
const { by, at } = input;
|
|
50
|
+
const present = checkPresent(meeting, { meetingId: input.meetingId, shipId: by, ended: ENDED });
|
|
51
|
+
if (!present.isOk) {
|
|
52
|
+
return present;
|
|
53
|
+
}
|
|
54
|
+
const open = present.value;
|
|
55
|
+
const notOwner = onlyByOwner(open, by);
|
|
56
|
+
if (notOwner) {
|
|
57
|
+
return notOwner;
|
|
58
|
+
}
|
|
59
|
+
const added = [...new Set(input.shipIds)].filter((shipId) => !isPresent(open, shipId));
|
|
60
|
+
const joined = (shipId) => ({ shipId, joinedAt: at, leftAt: null, isRevoked: false });
|
|
61
|
+
const participants = [...open.participants.filter(({ shipId }) => !added.includes(shipId)), ...added.map(joined)];
|
|
62
|
+
return ok({
|
|
63
|
+
meeting: { ...open, participants },
|
|
64
|
+
events: added.map((shipId) => ({ fleetId: open.fleetId, type: 'ParticipantAdded', occurredAt: at, actor: shipActor(by), shipId, details: { meetingId: open.id } })),
|
|
65
|
+
added,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The meeting once the ship retired (M15, M17), caused by `actor`: a retired
|
|
70
|
+
* owner ends it; a retired participant leaves it, its moderatorship going to
|
|
71
|
+
* the owner. Undefined when the ship is not present in an open meeting.
|
|
72
|
+
*/
|
|
73
|
+
export function withRetiredShip(meeting, input) {
|
|
74
|
+
const { shipId, actor, at } = input;
|
|
75
|
+
if (meeting.endedAt !== null || !isPresent(meeting, shipId)) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if (shipId === meeting.ownerShipId) {
|
|
79
|
+
return ended(meeting, { by: shipId, actor, at });
|
|
80
|
+
}
|
|
81
|
+
return gone(meeting, { shipId, actor, at, type: 'ParticipantLeft', isRevoked: false });
|
|
82
|
+
}
|
|
83
|
+
function rejoined(meeting, input) {
|
|
84
|
+
const { by, at } = input;
|
|
85
|
+
const left = checkPresent(meeting, { meetingId: input.meetingId, shipId: by, ended: ENDED });
|
|
86
|
+
if (left.isOk) {
|
|
87
|
+
return refuse('ALREADY_PRESENT', `You take part in meeting ${input.meetingId} already`);
|
|
88
|
+
}
|
|
89
|
+
if (left.error.kind !== 'PARTICIPANT_LEFT' || meeting === undefined) {
|
|
90
|
+
return left;
|
|
91
|
+
}
|
|
92
|
+
const participants = meeting.participants.map((participant) => (participant.shipId === by ? { ...participant, joinedAt: at, leftAt: null } : participant));
|
|
93
|
+
return ok({ meeting: { ...meeting, participants }, events: [lifeEvent(meeting, { type: 'ParticipantRejoined', shipId: by, actor: shipActor(by), at })], micGivenTo: null, hasEnded: false });
|
|
94
|
+
}
|
|
95
|
+
/** The ship out of the meeting, left or revoked: off the mic, its moderatorship to the owner. */
|
|
96
|
+
function gone(meeting, input) {
|
|
97
|
+
const { shipId, actor, at } = input;
|
|
98
|
+
const participants = meeting.participants.map((participant) => (participant.shipId === shipId ? { ...participant, leftAt: at, isRevoked: input.isRevoked } : participant));
|
|
99
|
+
const events = [lifeEvent(meeting, { type: input.type, shipId, actor, at })];
|
|
100
|
+
let changed = { ...meeting, participants };
|
|
101
|
+
if (shipId === meeting.moderatorShipId) {
|
|
102
|
+
changed = { ...changed, moderatorShipId: meeting.ownerShipId };
|
|
103
|
+
events.push(lifeEvent(meeting, { type: 'ModeratorNamed', shipId: meeting.ownerShipId, actor, at }));
|
|
104
|
+
}
|
|
105
|
+
const offMic = offTheMic(changed, { shipId, actor, at });
|
|
106
|
+
return { meeting: offMic.meeting, events: [...events, ...offMic.events], micGivenTo: offMic.givenTo, hasEnded: false };
|
|
107
|
+
}
|
|
108
|
+
/** The owner or the moderator handed to another present participant; a new moderator goes off the mic, as it needs none. */
|
|
109
|
+
function roleChanged(meeting, input) {
|
|
110
|
+
const { role, shipId, actor, at } = input;
|
|
111
|
+
if ((role === 'owner' ? meeting.ownerShipId : meeting.moderatorShipId) === shipId) {
|
|
112
|
+
return { meeting, events: [], micGivenTo: null, hasEnded: false };
|
|
113
|
+
}
|
|
114
|
+
if (role === 'owner') {
|
|
115
|
+
return { meeting: { ...meeting, ownerShipId: shipId }, events: [lifeEvent(meeting, { type: 'OwnershipTransferred', shipId, actor, at })], micGivenTo: null, hasEnded: false };
|
|
116
|
+
}
|
|
117
|
+
const named = lifeEvent(meeting, { type: 'ModeratorNamed', shipId, actor, at });
|
|
118
|
+
const offMic = offTheMic({ ...meeting, moderatorShipId: shipId }, { shipId, actor, at });
|
|
119
|
+
return { meeting: offMic.meeting, events: [named, ...offMic.events], micGivenTo: offMic.givenTo, hasEnded: false };
|
|
120
|
+
}
|
|
121
|
+
function ended(meeting, input) {
|
|
122
|
+
return { meeting: { ...meeting, endedAt: input.at }, events: [lifeEvent(meeting, { type: 'MeetingEnded', shipId: input.by, actor: input.actor, at: input.at })], micGivenTo: null, hasEnded: true };
|
|
123
|
+
}
|
|
124
|
+
function lifeEvent(meeting, input) {
|
|
125
|
+
return { fleetId: meeting.fleetId, type: input.type, occurredAt: input.at, actor: input.actor, shipId: input.shipId, details: { meetingId: meeting.id } };
|
|
126
|
+
}
|
|
127
|
+
function onlyByOwner(meeting, by) {
|
|
128
|
+
return by === meeting.ownerShipId ? undefined : refuse('NOT_OWNER', `Only the owner of meeting ${meeting.id} adds and revokes ships, transfers it and names its moderator`);
|
|
129
|
+
}
|
|
130
|
+
function byOwnerNever(meeting, shipId) {
|
|
131
|
+
return shipId === meeting.ownerShipId ? refuse('OWNER_CANNOT_LEAVE', `You own meeting ${meeting.id}: transfer it to another participant first`) : undefined;
|
|
132
|
+
}
|
|
133
|
+
function presentOnly(meeting, shipId) {
|
|
134
|
+
return isPresent(meeting, shipId) ? undefined : refuse('PARTICIPANT_NOT_FOUND', `Ship ${shipId} is not one of the participants of meeting ${meeting.id}`);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=meeting-life.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meeting-life.js","sourceRoot":"","sources":["../../../src/domain/messaging/meeting-life.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAA6B,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAwD,MAAM,cAAc,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAiCrC,MAAM,KAAK,GAAG,sBAAsB,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAA4B,EAAE,KAA4E;IACtI,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAC5C,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/E,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,OAAO,OAAO,CAAC;IACjB,CAAC;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M,8CAA8C,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5J,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type AccountId, type IdGenerator, type MeetingAdded, type ShipId, type ShipKind } from '@aeolus-fleet/common';
|
|
2
|
+
import { type EventLog } from '../shared/events.js';
|
|
3
|
+
import type { Notifier } from '../shared/notifier.js';
|
|
4
|
+
import { type Result } from '../shared/result.js';
|
|
5
|
+
import type { ShipRepository } from '../registry/public.js';
|
|
6
|
+
import { type Meeting } from './meeting.js';
|
|
7
|
+
import { type AcceptRefusal } from './message.js';
|
|
8
|
+
import type { DeliveryRepository, MessageRepository, RequestHasher } from './ports.js';
|
|
9
|
+
export interface MeetingNoticeTx {
|
|
10
|
+
messages: Pick<MessageRepository, 'create'>;
|
|
11
|
+
deliveries: Pick<DeliveryRepository, 'create'>;
|
|
12
|
+
events: EventLog;
|
|
13
|
+
notifier: Notifier;
|
|
14
|
+
}
|
|
15
|
+
/** A notice to one participant: from which ship, of which content type, with what payload. */
|
|
16
|
+
export interface MeetingNotice {
|
|
17
|
+
meeting: Meeting;
|
|
18
|
+
senderShipId: ShipId;
|
|
19
|
+
senderKind?: ShipKind;
|
|
20
|
+
signedInAccountId?: AccountId;
|
|
21
|
+
shipId: ShipId;
|
|
22
|
+
contentType: string;
|
|
23
|
+
payload: string;
|
|
24
|
+
model: string | undefined;
|
|
25
|
+
at: Date;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A notice that tells one participant what changed in its meeting (decision
|
|
29
|
+
* 0061, M11): a message from the ship that caused it to that ship, the
|
|
30
|
+
* meeting on its envelope, with its pending delivery, MessageAccepted and the
|
|
31
|
+
* notice that wakes it. No reach check: inside the meeting every participant
|
|
32
|
+
* reaches every other.
|
|
33
|
+
*/
|
|
34
|
+
export declare function tellParticipant(deps: {
|
|
35
|
+
tx: MeetingNoticeTx;
|
|
36
|
+
ids: IdGenerator;
|
|
37
|
+
hasher: RequestHasher;
|
|
38
|
+
}, notice: MeetingNotice): Promise<Result<undefined, AcceptRefusal>>;
|
|
39
|
+
/** The added notice's payload: the meeting, its title, its owner, its moderator and its present participants, by id and name. */
|
|
40
|
+
export declare function addedNoticeOf(tx: {
|
|
41
|
+
ships: Pick<ShipRepository, 'find'>;
|
|
42
|
+
}, meeting: Meeting): Promise<MeetingAdded>;
|
|
43
|
+
/**
|
|
44
|
+
* The notices a change of the meeting owes (M11): to the ship that got the
|
|
45
|
+
* mic by it, from the moderator; and once it ended, to every other present
|
|
46
|
+
* participant, from the ship that ended it. Neither states a model: the change
|
|
47
|
+
* may be another ship's, as a release under first in line or a retire.
|
|
48
|
+
*/
|
|
49
|
+
export declare function tellOfChange(deps: {
|
|
50
|
+
tx: MeetingNoticeTx;
|
|
51
|
+
ids: IdGenerator;
|
|
52
|
+
hasher: RequestHasher;
|
|
53
|
+
}, change: {
|
|
54
|
+
meeting: Meeting;
|
|
55
|
+
micGivenTo: ShipId | null;
|
|
56
|
+
endedBy: ShipId | null;
|
|
57
|
+
at: Date;
|
|
58
|
+
}): Promise<Result<undefined, AcceptRefusal>>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { MEETING_ENDED_CONTENT_TYPE, MEETING_MIC_CONTENT_TYPE } from '@aeolus-fleet/common';
|
|
2
|
+
import { recordEvent } from '../shared/events.js';
|
|
3
|
+
import { ok } from '../shared/result.js';
|
|
4
|
+
import { participantsBut } from './meeting.js';
|
|
5
|
+
import { acceptMessage } from './message.js';
|
|
6
|
+
import { sendRequestText } from './send-request.js';
|
|
7
|
+
/**
|
|
8
|
+
* A notice that tells one participant what changed in its meeting (decision
|
|
9
|
+
* 0061, M11): a message from the ship that caused it to that ship, the
|
|
10
|
+
* meeting on its envelope, with its pending delivery, MessageAccepted and the
|
|
11
|
+
* notice that wakes it. No reach check: inside the meeting every participant
|
|
12
|
+
* reaches every other.
|
|
13
|
+
*/
|
|
14
|
+
export async function tellParticipant(deps, notice) {
|
|
15
|
+
const { tx, ids, hasher } = deps;
|
|
16
|
+
const { meeting, shipId, payload, contentType, at } = notice;
|
|
17
|
+
const recipient = { kind: 'ship', shipId };
|
|
18
|
+
const messageId = ids('message');
|
|
19
|
+
const accepted = acceptMessage({ recipient, repliedTo: undefined }, {
|
|
20
|
+
messageId,
|
|
21
|
+
deliveryId: ids('delivery'),
|
|
22
|
+
fleetId: meeting.fleetId,
|
|
23
|
+
senderShipId: notice.senderShipId,
|
|
24
|
+
payload,
|
|
25
|
+
contentType,
|
|
26
|
+
model: notice.model,
|
|
27
|
+
...(notice.senderKind === undefined ? {} : { senderKind: notice.senderKind }),
|
|
28
|
+
// The fleet's own key for the notice, as a ping's is: one per message, never the caller's.
|
|
29
|
+
idempotencyKey: `meeting-notice-${messageId}`,
|
|
30
|
+
requestHash: hasher.hash(sendRequestText({ selector: recipient, payload, contentType, inReplyTo: undefined, isForced: false })),
|
|
31
|
+
inReplyTo: undefined,
|
|
32
|
+
isForced: false,
|
|
33
|
+
meetingId: meeting.id,
|
|
34
|
+
...(notice.signedInAccountId === undefined ? {} : { signedInAccountId: notice.signedInAccountId }),
|
|
35
|
+
at,
|
|
36
|
+
});
|
|
37
|
+
if (!accepted.isOk) {
|
|
38
|
+
return accepted;
|
|
39
|
+
}
|
|
40
|
+
const { message, delivery, events } = accepted.value;
|
|
41
|
+
await tx.messages.create(message);
|
|
42
|
+
await tx.deliveries.create(delivery);
|
|
43
|
+
for (const event of events) {
|
|
44
|
+
await recordEvent({ events: tx.events, ids }, event);
|
|
45
|
+
}
|
|
46
|
+
await tx.notifier.deliveryPending({ fleetId: meeting.fleetId, deliveryId: delivery.id, recipient: delivery.recipient });
|
|
47
|
+
return ok(undefined);
|
|
48
|
+
}
|
|
49
|
+
/** The added notice's payload: the meeting, its title, its owner, its moderator and its present participants, by id and name. */
|
|
50
|
+
export async function addedNoticeOf(tx, meeting) {
|
|
51
|
+
const names = new Map();
|
|
52
|
+
const present = meeting.participants.filter(({ leftAt }) => leftAt === null);
|
|
53
|
+
for (const { shipId } of present) {
|
|
54
|
+
const ship = await tx.ships.find(meeting.fleetId, shipId);
|
|
55
|
+
names.set(shipId, ship?.name ?? shipId);
|
|
56
|
+
}
|
|
57
|
+
const party = (id) => ({ id, name: names.get(id) ?? id });
|
|
58
|
+
return { meetingId: meeting.id, title: meeting.title, owner: party(meeting.ownerShipId), moderator: party(meeting.moderatorShipId), participants: present.map(({ shipId }) => party(shipId)) };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The notices a change of the meeting owes (M11): to the ship that got the
|
|
62
|
+
* mic by it, from the moderator; and once it ended, to every other present
|
|
63
|
+
* participant, from the ship that ended it. Neither states a model: the change
|
|
64
|
+
* may be another ship's, as a release under first in line or a retire.
|
|
65
|
+
*/
|
|
66
|
+
export async function tellOfChange(deps, change) {
|
|
67
|
+
const { meeting, at } = change;
|
|
68
|
+
const notices = [];
|
|
69
|
+
if (change.micGivenTo !== null) {
|
|
70
|
+
const payload = { meetingId: meeting.id };
|
|
71
|
+
notices.push({ meeting, senderShipId: meeting.moderatorShipId, shipId: change.micGivenTo, contentType: MEETING_MIC_CONTENT_TYPE, payload: JSON.stringify(payload), model: undefined, at });
|
|
72
|
+
}
|
|
73
|
+
if (change.endedBy !== null) {
|
|
74
|
+
const payload = { meetingId: meeting.id };
|
|
75
|
+
for (const shipId of participantsBut(meeting, change.endedBy)) {
|
|
76
|
+
notices.push({ meeting, senderShipId: change.endedBy, shipId, contentType: MEETING_ENDED_CONTENT_TYPE, payload: JSON.stringify(payload), model: undefined, at });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const notice of notices) {
|
|
80
|
+
const told = await tellParticipant(deps, notice);
|
|
81
|
+
if (!told.isOk) {
|
|
82
|
+
return told;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return ok(undefined);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=meeting-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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D,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,wBAAwB,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7L,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAiB,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;QACxD,KAAK,MAAM,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,0BAA0B,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;QACnK,CAAC;IACH,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { FleetId, MeetingId, MessageId, MicPattern, ShipId } from '@aeolus-fleet/common';
|
|
2
|
+
import { type DomainError } from '../shared/errors.js';
|
|
3
|
+
import { type NewEvent } from '../shared/events.js';
|
|
4
|
+
import { type Result } from '../shared/result.js';
|
|
5
|
+
import type { MicRequest } from './mic.js';
|
|
6
|
+
/**
|
|
7
|
+
* One moderated conversation of ships (decision 0061): what a participant
|
|
8
|
+
* contributes reaches every other participant. It has one owner and one
|
|
9
|
+
* moderator, both participants, the ship that opened it at first.
|
|
10
|
+
*/
|
|
11
|
+
export interface Meeting {
|
|
12
|
+
id: MeetingId;
|
|
13
|
+
fleetId: FleetId;
|
|
14
|
+
/** A short name a person reads when auditing later; none when it was opened without one. */
|
|
15
|
+
title: string | null;
|
|
16
|
+
ownerShipId: ShipId;
|
|
17
|
+
moderatorShipId: ShipId;
|
|
18
|
+
/** The ship that opened it, whose idempotency key it was opened with. */
|
|
19
|
+
openedByShipId: ShipId;
|
|
20
|
+
idempotencyKey: string;
|
|
21
|
+
/** The hash of the request it was opened with: what a repeat of its key must match. */
|
|
22
|
+
requestHash: string;
|
|
23
|
+
/** Every ship in it, each once, the opener first, then in the order they joined. */
|
|
24
|
+
participants: Participant[];
|
|
25
|
+
openedAt: Date;
|
|
26
|
+
/** When it ended; none while it is open. */
|
|
27
|
+
endedAt: Date | null;
|
|
28
|
+
/** The participant that holds the mic, which may contribute beside the moderator; none while the mic is free (M7). */
|
|
29
|
+
micHolderShipId: ShipId | null;
|
|
30
|
+
/** How a free mic passes (M9). */
|
|
31
|
+
micPattern: MicPattern;
|
|
32
|
+
/** The ships waiting for the mic, oldest first, each once (M8). */
|
|
33
|
+
micRequests: MicRequest[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A ship in a meeting, never a type, and when it last joined. It is present
|
|
37
|
+
* until it leaves; a ship that left keeps its right to rejoin unless the owner
|
|
38
|
+
* revoked it (M13).
|
|
39
|
+
*/
|
|
40
|
+
export interface Participant {
|
|
41
|
+
shipId: ShipId;
|
|
42
|
+
joinedAt: Date;
|
|
43
|
+
/** When it left or was revoked; none while it is present. */
|
|
44
|
+
leftAt: Date | null;
|
|
45
|
+
/** Whether the owner revoked its right: it rejoins only when the owner adds it again. */
|
|
46
|
+
isRevoked: boolean;
|
|
47
|
+
}
|
|
48
|
+
export type PresenceRefusal = DomainError<'MEETING_NOT_FOUND' | 'MEETING_ENDED' | 'PARTICIPANT_REVOKED' | 'PARTICIPANT_LEFT'>;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the ship is present in the meeting, open still. A meeting that does
|
|
51
|
+
* not exist and one the ship never took part in are one refusal, so a
|
|
52
|
+
* stranger learns nothing of it; then an ended meeting, said in `ended`; then
|
|
53
|
+
* a ship whose right was revoked, and one that left.
|
|
54
|
+
*/
|
|
55
|
+
export declare function checkPresent(meeting: Meeting | undefined, input: {
|
|
56
|
+
meetingId: MeetingId;
|
|
57
|
+
shipId: ShipId;
|
|
58
|
+
ended: string;
|
|
59
|
+
}): Result<Meeting, PresenceRefusal>;
|
|
60
|
+
/** Whether the ship is in the meeting now. */
|
|
61
|
+
export declare function isPresent(meeting: Meeting, shipId: ShipId): boolean;
|
|
62
|
+
export type OpenMeetingRefusal = DomainError<'MEETING_WITHOUT_INVITEES'>;
|
|
63
|
+
/**
|
|
64
|
+
* Opens a meeting of the opener and the ships it invited, resolved and each
|
|
65
|
+
* reached by the opener already: the opener owns and moderates it. Each ship
|
|
66
|
+
* joins once, the opener first; a meeting of the opener alone is refused.
|
|
67
|
+
* MeetingOpened, then ParticipantAdded for each participant, caused by the
|
|
68
|
+
* opener.
|
|
69
|
+
*/
|
|
70
|
+
export declare function openMeeting(input: {
|
|
71
|
+
meetingId: MeetingId;
|
|
72
|
+
fleetId: FleetId;
|
|
73
|
+
title: string | null;
|
|
74
|
+
openerShipId: ShipId;
|
|
75
|
+
invitedShipIds: readonly ShipId[];
|
|
76
|
+
idempotencyKey: string;
|
|
77
|
+
requestHash: string;
|
|
78
|
+
at: Date;
|
|
79
|
+
}): Result<{
|
|
80
|
+
meeting: Meeting;
|
|
81
|
+
events: NewEvent[];
|
|
82
|
+
}, OpenMeetingRefusal>;
|
|
83
|
+
/**
|
|
84
|
+
* An open with a key its opener used before: the same request is a repeat
|
|
85
|
+
* and gets the original meeting; another request with that key is refused.
|
|
86
|
+
*/
|
|
87
|
+
export declare function repeatOfOpen(original: Meeting, requestHash: string): Result<MeetingId, DomainError<'IDEMPOTENCY_KEY_REUSED'>>;
|
|
88
|
+
export type ContributionRefusal = PresenceRefusal | DomainError<'CONTRIBUTION_REPLIES' | 'CONTRIBUTION_FORCED' | 'MIC_NOT_HELD'>;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the ship may contribute to the meeting (decision 0061), and if so
|
|
91
|
+
* the participants its contribution goes to: every present one but itself.
|
|
92
|
+
* The ship is present in the open meeting (`checkPresent`); a contribution
|
|
93
|
+
* replies to no message (M18) and is never forced; and only the moderator
|
|
94
|
+
* and the mic's holder contribute (M7).
|
|
95
|
+
*/
|
|
96
|
+
export declare function checkContribution(meeting: Meeting | undefined, contribution: {
|
|
97
|
+
meetingId: MeetingId;
|
|
98
|
+
senderShipId: ShipId;
|
|
99
|
+
inReplyTo: MessageId | undefined;
|
|
100
|
+
isForced: boolean;
|
|
101
|
+
}): Result<ShipId[], ContributionRefusal>;
|
|
102
|
+
/** The present participants but the one given, in the meeting's order. */
|
|
103
|
+
export declare function participantsBut(meeting: Meeting, shipId: ShipId): ShipId[];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { refuse } from '../shared/errors.js';
|
|
2
|
+
import { shipActor } from '../shared/events.js';
|
|
3
|
+
import { ok } from '../shared/result.js';
|
|
4
|
+
/**
|
|
5
|
+
* Whether the ship is present in the meeting, open still. A meeting that does
|
|
6
|
+
* not exist and one the ship never took part in are one refusal, so a
|
|
7
|
+
* stranger learns nothing of it; then an ended meeting, said in `ended`; then
|
|
8
|
+
* a ship whose right was revoked, and one that left.
|
|
9
|
+
*/
|
|
10
|
+
export function checkPresent(meeting, input) {
|
|
11
|
+
const { meetingId, shipId } = input;
|
|
12
|
+
const participant = meeting?.participants.find((held) => held.shipId === shipId);
|
|
13
|
+
if (meeting === undefined || participant === undefined) {
|
|
14
|
+
return refuse('MEETING_NOT_FOUND', `Meeting ${meetingId} does not exist or you are not one of its participants`);
|
|
15
|
+
}
|
|
16
|
+
if (meeting.endedAt !== null) {
|
|
17
|
+
return refuse('MEETING_ENDED', `Meeting ${meetingId} ended: ${input.ended}`);
|
|
18
|
+
}
|
|
19
|
+
if (participant.isRevoked) {
|
|
20
|
+
return refuse('PARTICIPANT_REVOKED', `The owner of meeting ${meetingId} revoked your right to it: only the owner adds you again`);
|
|
21
|
+
}
|
|
22
|
+
if (participant.leftAt !== null) {
|
|
23
|
+
return refuse('PARTICIPANT_LEFT', `You left meeting ${meetingId}: rejoin it first`);
|
|
24
|
+
}
|
|
25
|
+
return ok(meeting);
|
|
26
|
+
}
|
|
27
|
+
/** Whether the ship is in the meeting now. */
|
|
28
|
+
export function isPresent(meeting, shipId) {
|
|
29
|
+
return meeting.participants.some((participant) => participant.shipId === shipId && participant.leftAt === null);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Opens a meeting of the opener and the ships it invited, resolved and each
|
|
33
|
+
* reached by the opener already: the opener owns and moderates it. Each ship
|
|
34
|
+
* joins once, the opener first; a meeting of the opener alone is refused.
|
|
35
|
+
* MeetingOpened, then ParticipantAdded for each participant, caused by the
|
|
36
|
+
* opener.
|
|
37
|
+
*/
|
|
38
|
+
export function openMeeting(input) {
|
|
39
|
+
const { meetingId, fleetId, openerShipId, at } = input;
|
|
40
|
+
const shipIds = [...new Set([openerShipId, ...input.invitedShipIds])];
|
|
41
|
+
if (shipIds.length === 1) {
|
|
42
|
+
return refuse('MEETING_WITHOUT_INVITEES', 'A meeting needs at least one ship besides its opener: invite ships by id, by name or by label');
|
|
43
|
+
}
|
|
44
|
+
const meeting = {
|
|
45
|
+
id: meetingId,
|
|
46
|
+
fleetId,
|
|
47
|
+
title: input.title,
|
|
48
|
+
ownerShipId: openerShipId,
|
|
49
|
+
moderatorShipId: openerShipId,
|
|
50
|
+
openedByShipId: openerShipId,
|
|
51
|
+
idempotencyKey: input.idempotencyKey,
|
|
52
|
+
requestHash: input.requestHash,
|
|
53
|
+
participants: shipIds.map((shipId) => ({ shipId, joinedAt: at, leftAt: null, isRevoked: false })),
|
|
54
|
+
openedAt: at,
|
|
55
|
+
endedAt: null,
|
|
56
|
+
micHolderShipId: null,
|
|
57
|
+
micPattern: 'moderator',
|
|
58
|
+
micRequests: [],
|
|
59
|
+
};
|
|
60
|
+
const actor = shipActor(openerShipId);
|
|
61
|
+
return ok({
|
|
62
|
+
meeting,
|
|
63
|
+
events: [
|
|
64
|
+
{ fleetId, type: 'MeetingOpened', occurredAt: at, actor, shipId: openerShipId, details: { meetingId, participants: shipIds.length } },
|
|
65
|
+
...shipIds.map((shipId) => ({ fleetId, type: 'ParticipantAdded', occurredAt: at, actor, shipId, details: { meetingId } })),
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* An open with a key its opener used before: the same request is a repeat
|
|
71
|
+
* and gets the original meeting; another request with that key is refused.
|
|
72
|
+
*/
|
|
73
|
+
export function repeatOfOpen(original, requestHash) {
|
|
74
|
+
return original.requestHash === requestHash
|
|
75
|
+
? ok(original.id)
|
|
76
|
+
: refuse('IDEMPOTENCY_KEY_REUSED', 'This idempotency key was already used for another meeting: open a new meeting with a new key');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether the ship may contribute to the meeting (decision 0061), and if so
|
|
80
|
+
* the participants its contribution goes to: every present one but itself.
|
|
81
|
+
* The ship is present in the open meeting (`checkPresent`); a contribution
|
|
82
|
+
* replies to no message (M18) and is never forced; and only the moderator
|
|
83
|
+
* and the mic's holder contribute (M7).
|
|
84
|
+
*/
|
|
85
|
+
export function checkContribution(meeting, contribution) {
|
|
86
|
+
const { meetingId, senderShipId } = contribution;
|
|
87
|
+
const present = checkPresent(meeting, { meetingId, shipId: senderShipId, ended: 'it takes no more contributions' });
|
|
88
|
+
if (!present.isOk) {
|
|
89
|
+
return present;
|
|
90
|
+
}
|
|
91
|
+
if (contribution.inReplyTo !== undefined) {
|
|
92
|
+
return refuse('CONTRIBUTION_REPLIES', 'A contribution replies to no message: send it to the meeting without inReplyTo');
|
|
93
|
+
}
|
|
94
|
+
if (contribution.isForced) {
|
|
95
|
+
return refuse('CONTRIBUTION_FORCED', 'A contribution is never forced: send it to the meeting without isForced');
|
|
96
|
+
}
|
|
97
|
+
if (senderShipId !== present.value.moderatorShipId && senderShipId !== present.value.micHolderShipId) {
|
|
98
|
+
return refuse('MIC_NOT_HELD', `You do not hold the mic of meeting ${meetingId}: request the mic, and contribute once it is given to you`);
|
|
99
|
+
}
|
|
100
|
+
return ok(participantsBut(present.value, senderShipId));
|
|
101
|
+
}
|
|
102
|
+
/** The present participants but the one given, in the meeting's order. */
|
|
103
|
+
export function participantsBut(meeting, shipId) {
|
|
104
|
+
return meeting.participants.filter((participant) => participant.shipId !== shipId && participant.leftAt === null).map((participant) => participant.shipId);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=meeting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meeting.js","sourceRoot":"","sources":["../../../src/domain/messaging/meeting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAiDtD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAA4B,EAAE,KAA8D;IACvH,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,WAAW,GAAG,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IACjF,IAAI,OAAO,KAAK,SAAS,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,mBAAmB,EAAE,WAAW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ryId, type DeliveryState, type FleetId, type LeaseId, type MessageId, type ShipId, type ShipKind } from '@aeolus-fleet/common';
|
|
1
|
+
import { type AccountId, type DeliveryId, type DeliveryState, type FleetId, type LeaseId, type MeetingId, type MessageId, type ShipId, type ShipKind } from '@aeolus-fleet/common';
|
|
2
2
|
import { type DomainError } from '../shared/errors.js';
|
|
3
3
|
import { type Actor, type NewEvent } from '../shared/events.js';
|
|
4
4
|
import { type Result } from '../shared/result.js';
|
|
5
|
-
import type { Recipient } from '../shared/selector.js';
|
|
5
|
+
import type { Addressee, Recipient } from '../shared/selector.js';
|
|
6
6
|
/**
|
|
7
7
|
* An immutable envelope plus an opaque payload, sent by one ship to a
|
|
8
8
|
* selector (docs/blueprint.md, "Message"). Accepted only once its selector
|
|
@@ -13,8 +13,8 @@ export interface Message {
|
|
|
13
13
|
fleetId: FleetId;
|
|
14
14
|
/** The calling ship: every sender is a ship, `argo` included. */
|
|
15
15
|
senderShipId: ShipId;
|
|
16
|
-
/** The selector as resolved at send time: a ship's id, never its name, or a
|
|
17
|
-
selector:
|
|
16
|
+
/** The selector as resolved at send time: a ship's id, never its name, a type, or a meeting (decision 0061). */
|
|
17
|
+
selector: Addressee;
|
|
18
18
|
payload: string;
|
|
19
19
|
/** A media type, exactly as the sender gave it. */
|
|
20
20
|
contentType: string;
|
|
@@ -28,6 +28,8 @@ export interface Message {
|
|
|
28
28
|
inReplyToMessageId: MessageId | null;
|
|
29
29
|
/** The message this one resends: an undeliverable one the operator sent again. */
|
|
30
30
|
resendOfMessageId: MessageId | null;
|
|
31
|
+
/** The meeting it was contributed to, or tells of as the notice that added its recipient (decision 0061). */
|
|
32
|
+
meetingId: MeetingId | null;
|
|
31
33
|
createdAt: Date;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
@@ -99,8 +101,12 @@ export interface MessageToAccept {
|
|
|
99
101
|
actor?: Actor;
|
|
100
102
|
/** The account signed in to the console as argo when argo sends or resends it (decision 0054). */
|
|
101
103
|
signedInAccountId?: AccountId;
|
|
104
|
+
/** The meeting it tells of, for the notice that adds its recipient to one (decision 0061). */
|
|
105
|
+
meetingId?: MeetingId;
|
|
102
106
|
at: Date;
|
|
103
107
|
}
|
|
108
|
+
/** Who the delivery of the message went to: its message's recipient, or for a contribution to a meeting the participant it is for (decision 0061). */
|
|
109
|
+
export declare function deliveredTo(message: Pick<Message, 'selector'>, delivery: Pick<Delivery, 'recipient'>): Recipient;
|
|
104
110
|
export type RepeatRefusal = DomainError<'IDEMPOTENCY_KEY_REUSED'>;
|
|
105
111
|
/**
|
|
106
112
|
* A send with a key its sender used before. The same request is a repeat, a
|
|
@@ -130,3 +136,22 @@ export declare function acceptMessage(fleet: {
|
|
|
130
136
|
delivery: Delivery;
|
|
131
137
|
events: NewEvent[];
|
|
132
138
|
}, AcceptRefusal>;
|
|
139
|
+
/** What a participant contributes to a meeting, its payload and key already checked, with one delivery id per participant it goes to. */
|
|
140
|
+
export type ContributionToAccept = Omit<MessageToAccept, 'deliveryId' | 'inReplyTo' | 'isForced' | 'resendOf' | 'meetingId'> & {
|
|
141
|
+
meetingId: MeetingId;
|
|
142
|
+
deliveries: readonly {
|
|
143
|
+
deliveryId: DeliveryId;
|
|
144
|
+
shipId: ShipId;
|
|
145
|
+
}[];
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Accepts a contribution to a meeting (decision 0061): one message to the
|
|
149
|
+
* meeting, carrying it on its envelope, and one pending delivery per other
|
|
150
|
+
* participant, each with its own MessageAccepted naming that participant and
|
|
151
|
+
* the meeting, caused by the sender. The model rule is a send's.
|
|
152
|
+
*/
|
|
153
|
+
export declare function acceptContribution(send: ContributionToAccept): Result<{
|
|
154
|
+
message: Message;
|
|
155
|
+
deliveries: Delivery[];
|
|
156
|
+
events: NewEvent[];
|
|
157
|
+
}, AcceptRefusal>;
|