@aeolus-fleet/core 0.39.1 → 0.41.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/README.md +7 -7
- package/dist/adapters/cli/fleet-init.d.ts +1 -1
- package/dist/adapters/cli/fleet-init.js +5 -3
- package/dist/adapters/cli/fleet-init.js.map +1 -1
- package/dist/adapters/cli/io.d.ts +5 -2
- package/dist/adapters/cli/io.js.map +1 -1
- package/dist/adapters/crypto/account-token-signatures.js +1 -1
- package/dist/adapters/crypto/account-token-signatures.js.map +1 -1
- package/dist/adapters/prisma/client.d.ts +8 -2
- package/dist/adapters/prisma/client.js +3 -3
- package/dist/adapters/prisma/client.js.map +1 -1
- package/dist/adapters/prisma/content-type-sql.d.ts +11 -0
- package/dist/adapters/prisma/content-type-sql.js +41 -0
- package/dist/adapters/prisma/content-type-sql.js.map +1 -0
- package/dist/adapters/prisma/delivery-notices.d.ts +2 -2
- package/dist/adapters/prisma/delivery-notices.js +2 -2
- package/dist/adapters/prisma/exchange-rollups.d.ts +3 -1
- package/dist/adapters/prisma/exchange-rollups.js +15 -9
- package/dist/adapters/prisma/exchange-rollups.js.map +1 -1
- package/dist/adapters/prisma/fill-message-question-ids.d.ts +7 -0
- package/dist/adapters/prisma/fill-message-question-ids.js +12 -0
- package/dist/adapters/prisma/fill-message-question-ids.js.map +1 -0
- package/dist/adapters/prisma/fleet-counter.js +1 -1
- package/dist/adapters/prisma/fleet-counter.js.map +1 -1
- package/dist/adapters/prisma/fleet-event-wakeups.d.ts +1 -7
- package/dist/adapters/prisma/fleet-event-wakeups.js +0 -19
- package/dist/adapters/prisma/fleet-event-wakeups.js.map +1 -1
- package/dist/adapters/prisma/fleet-removal.d.ts +17 -0
- package/dist/adapters/prisma/fleet-removal.js +109 -0
- package/dist/adapters/prisma/fleet-removal.js.map +1 -0
- package/dist/adapters/prisma/generated/browser.d.ts +6 -0
- package/dist/adapters/prisma/generated/client.d.ts +6 -0
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +0 -30
- package/dist/adapters/prisma/generated/enums.d.ts +1 -6
- package/dist/adapters/prisma/generated/enums.js +2 -6
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +11 -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 +89 -10
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +13 -2
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +13 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +13 -2
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/Exchange.d.ts +60 -1
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +700 -1
- package/dist/adapters/prisma/generated/models/Message.d.ts +174 -1
- package/dist/adapters/prisma/generated/models/MessageMetadataBackfill.d.ts +1132 -0
- package/dist/adapters/prisma/generated/models/MessageMetadataBackfill.js +2 -0
- package/dist/adapters/prisma/generated/models/MessageMetadataBackfill.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Operator.d.ts +1 -40
- package/dist/adapters/prisma/generated/models.d.ts +1 -0
- package/dist/adapters/prisma/health-bootstrap-index.d.ts +2 -0
- package/dist/adapters/prisma/health-bootstrap-index.js +15 -0
- package/dist/adapters/prisma/health-bootstrap-index.js.map +1 -0
- package/dist/adapters/prisma/health-snapshots.js +6 -3
- package/dist/adapters/prisma/health-snapshots.js.map +1 -1
- package/dist/adapters/prisma/history.d.ts +3 -1
- package/dist/adapters/prisma/history.js +22 -4
- package/dist/adapters/prisma/history.js.map +1 -1
- package/dist/adapters/prisma/identity.js +6 -9
- package/dist/adapters/prisma/identity.js.map +1 -1
- package/dist/adapters/prisma/index-after-start.d.ts +16 -0
- package/dist/adapters/prisma/index-after-start.js +78 -0
- package/dist/adapters/prisma/index-after-start.js.map +1 -0
- package/dist/adapters/prisma/installation.js +3 -3
- package/dist/adapters/prisma/installation.js.map +1 -1
- package/dist/adapters/prisma/message-metadata-fill.d.ts +40 -0
- package/dist/adapters/prisma/message-metadata-fill.js +122 -0
- package/dist/adapters/prisma/message-metadata-fill.js.map +1 -0
- package/dist/adapters/prisma/messaging.d.ts +17 -1
- package/dist/adapters/prisma/messaging.js +60 -2
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/prisma/page-with-messages.js +2 -0
- package/dist/adapters/prisma/page-with-messages.js.map +1 -1
- package/dist/adapters/prisma/receiver-wakeups.d.ts +11 -17
- package/dist/adapters/prisma/receiver-wakeups.js +0 -60
- package/dist/adapters/prisma/receiver-wakeups.js.map +1 -1
- package/dist/adapters/prisma/registry.js +19 -54
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.js +3 -3
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/prisma/sealings.js +23 -7
- package/dist/adapters/prisma/sealings.js.map +1 -1
- package/dist/adapters/prisma/unit-of-work.d.ts +4 -2
- package/dist/adapters/prisma/unit-of-work.js +4 -0
- package/dist/adapters/prisma/unit-of-work.js.map +1 -1
- package/dist/adapters/prisma/unseen-plain-messages.d.ts +3 -0
- package/dist/adapters/prisma/unseen-plain-messages.js +20 -0
- package/dist/adapters/prisma/unseen-plain-messages.js.map +1 -0
- package/dist/adapters/telemetry/calls.d.ts +0 -8
- package/dist/adapters/telemetry/calls.js +3 -39
- package/dist/adapters/telemetry/calls.js.map +1 -1
- package/dist/adapters/trpc/console.d.ts +5 -10
- package/dist/adapters/trpc/console.js +2 -10
- package/dist/adapters/trpc/console.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +0 -2
- package/dist/adapters/trpc/fleet.d.ts +12 -13
- package/dist/adapters/trpc/fleet.js +6 -5
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/installation.d.ts +12 -0
- package/dist/adapters/trpc/router.d.ts +36 -28
- package/dist/adapters/trpc/ship-protocol.js +1 -1
- package/dist/adapters/trpc/ship-protocol.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +15 -15
- package/dist/adapters/trpc/ship.js +15 -16
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/trpc.js +0 -2
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.d.ts +5 -3
- package/dist/app.js +79 -14
- package/dist/app.js.map +1 -1
- package/dist/domain/identity/authenticate-installation.d.ts +1 -1
- package/dist/domain/identity/authenticate-installation.js +2 -2
- package/dist/domain/identity/authenticate-installation.js.map +1 -1
- package/dist/domain/identity/notice.js +1 -0
- package/dist/domain/identity/notice.js.map +1 -1
- package/dist/domain/identity/operator-account.d.ts +1 -3
- package/dist/domain/identity/operator-account.js.map +1 -1
- package/dist/domain/identity/ports.d.ts +1 -6
- package/dist/domain/identity/read-account.d.ts +2 -3
- package/dist/domain/identity/read-account.js +1 -2
- package/dist/domain/identity/read-account.js.map +1 -1
- package/dist/domain/messaging/check-inbox.d.ts +6 -23
- package/dist/domain/messaging/check-inbox.js +14 -59
- package/dist/domain/messaging/check-inbox.js.map +1 -1
- package/dist/domain/messaging/exchange.d.ts +3 -1
- package/dist/domain/messaging/exchange.js +10 -6
- package/dist/domain/messaging/exchange.js.map +1 -1
- package/dist/domain/messaging/fill-message-metadata.d.ts +29 -0
- package/dist/domain/messaging/fill-message-metadata.js +54 -0
- package/dist/domain/messaging/fill-message-metadata.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +5 -1
- package/dist/domain/messaging/message.js +9 -3
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/ports.d.ts +63 -18
- package/dist/domain/messaging/public.d.ts +1 -0
- package/dist/domain/messaging/public.js +1 -0
- package/dist/domain/messaging/public.js.map +1 -1
- package/dist/domain/messaging/push-receive-deliveries.d.ts +4 -6
- package/dist/domain/messaging/push-receive-deliveries.js +5 -7
- package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/read-exchanges.d.ts +1 -0
- package/dist/domain/messaging/read-exchanges.js +2 -1
- package/dist/domain/messaging/read-exchanges.js.map +1 -1
- package/dist/domain/messaging/receive-deliveries.d.ts +4 -34
- package/dist/domain/messaging/receive-deliveries.js +4 -46
- package/dist/domain/messaging/receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/receive-reply.d.ts +5 -8
- package/dist/domain/messaging/receive-reply.js +10 -9
- package/dist/domain/messaging/receive-reply.js.map +1 -1
- package/dist/domain/messaging/retired-asker.d.ts +33 -0
- package/dist/domain/messaging/retired-asker.js +81 -0
- package/dist/domain/messaging/retired-asker.js.map +1 -0
- package/dist/domain/messaging/turn-on-sealing.js +1 -1
- package/dist/domain/messaging/turn-on-sealing.js.map +1 -1
- package/dist/domain/registry/check-reach.d.ts +1 -1
- package/dist/domain/registry/check-reach.js +2 -2
- package/dist/domain/registry/check-reach.js.map +1 -1
- package/dist/domain/registry/delete-fleet.d.ts +5 -3
- package/dist/domain/registry/delete-fleet.js +6 -4
- package/dist/domain/registry/delete-fleet.js.map +1 -1
- package/dist/domain/registry/expectations.js +1 -0
- package/dist/domain/registry/expectations.js.map +1 -1
- package/dist/domain/registry/found-fleet.js +1 -1
- package/dist/domain/registry/found-fleet.js.map +1 -1
- package/dist/domain/registry/network-settings.d.ts +5 -2
- package/dist/domain/registry/network-settings.js +2 -2
- package/dist/domain/registry/network-settings.js.map +1 -1
- package/dist/domain/registry/ports.d.ts +25 -8
- package/dist/domain/registry/public.d.ts +1 -1
- package/dist/domain/registry/read-reach.js +1 -1
- package/dist/domain/registry/read-reach.js.map +1 -1
- package/dist/domain/registry/remove-deleted-fleets.d.ts +30 -0
- package/dist/domain/registry/remove-deleted-fleets.js +54 -0
- package/dist/domain/registry/remove-deleted-fleets.js.map +1 -0
- package/dist/domain/registry/retire-ship.d.ts +6 -2
- package/dist/domain/registry/retire-ship.js +9 -1
- package/dist/domain/registry/retire-ship.js.map +1 -1
- package/dist/domain/registry/ship-order.js +1 -1
- package/dist/domain/registry/ship-order.js.map +1 -1
- package/dist/domain/registry/verified-facts.js +1 -0
- package/dist/domain/registry/verified-facts.js.map +1 -1
- package/dist/domain/shared/caller.js +1 -0
- package/dist/domain/shared/caller.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/events.d.ts +0 -13
- package/dist/domain/shared/follow-fleet.d.ts +9 -15
- package/dist/domain/shared/follow-fleet.js +16 -55
- package/dist/domain/shared/follow-fleet.js.map +1 -1
- package/dist/domain/shared/health-snapshot.js +7 -2
- package/dist/domain/shared/health-snapshot.js.map +1 -1
- package/dist/domain/shared/read-fleet-limits.d.ts +2 -2
- package/dist/domain/shared/read-fleet-limits.js +1 -1
- package/dist/domain/shared/read-sent-message.d.ts +7 -4
- package/dist/domain/shared/read-sent-message.js +6 -15
- package/dist/domain/shared/read-sent-message.js.map +1 -1
- package/dist/maintenance-pass.d.ts +1 -1
- package/dist/maintenance-pass.js +4 -1
- package/dist/maintenance-pass.js.map +1 -1
- package/dist/start.d.ts +1 -1
- package/dist/start.js +1 -1
- package/dist/testing/container-sweeper.d.ts +67 -0
- package/dist/testing/container-sweeper.js +147 -14
- package/dist/testing/container-sweeper.js.map +1 -1
- package/dist/testing/postgres-container.js +2 -2
- package/dist/testing/postgres-container.js.map +1 -1
- package/dist/testing/postgres-global-setup.d.ts +1 -1
- package/dist/testing/postgres-global-setup.js +3 -2
- package/dist/testing/postgres-global-setup.js.map +1 -1
- package/dist/wiring.d.ts +7 -12
- package/dist/wiring.js +6 -18
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261115090000_messages_asked_answered_question_id/migration.sql +20 -0
- package/src/adapters/prisma/migrations/20261115100000_unseen_plain_messages/migration.sql +3 -0
- package/src/adapters/prisma/migrations/20261115110000_theme_per_browser/migration.sql +4 -0
- package/src/adapters/prisma/migrations/20261115120000_fleet_deleted_at/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261115180000_trierarch_kind/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261115180100_trierarch_kind_backfill/migration.sql +38 -0
- package/src/adapters/prisma/schema.prisma +28 -14
- package/dist/domain/identity/set-theme.d.ts +0 -21
- package/dist/domain/identity/set-theme.js +0 -19
- package/dist/domain/identity/set-theme.js.map +0 -1
- package/dist/domain/messaging/inbox-wait.d.ts +0 -8
- package/dist/domain/messaging/inbox-wait.js +0 -19
- package/dist/domain/messaging/inbox-wait.js.map +0 -1
|
@@ -11,16 +11,18 @@ export declare function isInExchange(message: Pick<Message, 'meetingId' | 'conte
|
|
|
11
11
|
/** A delivery as its exchange counts it: its message and sender, the ship it reached, if any yet, and its state. */
|
|
12
12
|
export interface ExchangeSide {
|
|
13
13
|
messageId: MessageId;
|
|
14
|
+
contentType: string;
|
|
14
15
|
senderShipId: ShipId;
|
|
15
16
|
reachedShipId: ShipId | null;
|
|
16
17
|
state: DeliveryState;
|
|
17
18
|
}
|
|
18
|
-
/** What one delivery
|
|
19
|
+
/** What one delivery adds to the newest message and unacknowledged counts, including plain messages seen by ackUpTo. */
|
|
19
20
|
export interface ExchangeCount {
|
|
20
21
|
shipId: ShipId;
|
|
21
22
|
otherShipId: ShipId;
|
|
22
23
|
newestMessageId: MessageId;
|
|
23
24
|
unacknowledged: number;
|
|
25
|
+
unseenPlainMessages: number;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* What a delivery's change from `before` to `after` (none before when it is
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPingContentType } from '@aeolus-fleet/common';
|
|
1
|
+
import { isConventionContentType, isPingContentType } from '@aeolus-fleet/common';
|
|
2
2
|
/**
|
|
3
3
|
* An exchange (docs/design/exchange-read, E1): what one ship and one other
|
|
4
4
|
* ship said to each other, every message one of them sent that reached the
|
|
@@ -26,19 +26,23 @@ export function exchangeCountsOf(change) {
|
|
|
26
26
|
const add = (count) => {
|
|
27
27
|
const key = `${count.shipId} ${count.otherShipId}`;
|
|
28
28
|
const sum = counts.get(key);
|
|
29
|
-
counts.set(key, {
|
|
29
|
+
counts.set(key, {
|
|
30
|
+
...count,
|
|
31
|
+
unacknowledged: (sum?.unacknowledged ?? 0) + count.unacknowledged,
|
|
32
|
+
unseenPlainMessages: (sum?.unseenPlainMessages ?? 0) + count.unseenPlainMessages,
|
|
33
|
+
});
|
|
30
34
|
};
|
|
31
35
|
const isNewReach = after?.reachedShipId != null && after.reachedShipId !== before?.reachedShipId;
|
|
32
36
|
if (before?.reachedShipId != null && isUnacknowledged(before.state)) {
|
|
33
|
-
add({ shipId: before.reachedShipId, otherShipId: before.senderShipId, newestMessageId: before.messageId, unacknowledged: -1 });
|
|
37
|
+
add({ shipId: before.reachedShipId, otherShipId: before.senderShipId, newestMessageId: before.messageId, unacknowledged: -1, unseenPlainMessages: isConventionContentType(before.contentType) ? 0 : -1 });
|
|
34
38
|
}
|
|
35
39
|
if (after?.reachedShipId != null) {
|
|
36
40
|
const reached = { shipId: after.reachedShipId, otherShipId: after.senderShipId, newestMessageId: after.messageId };
|
|
37
|
-
add({ ...reached, unacknowledged: isUnacknowledged(after.state) ? 1 : 0 });
|
|
41
|
+
add({ ...reached, unacknowledged: isUnacknowledged(after.state) ? 1 : 0, unseenPlainMessages: isUnacknowledged(after.state) && !isConventionContentType(after.contentType) ? 1 : 0 });
|
|
38
42
|
if (isNewReach) {
|
|
39
|
-
add({ shipId: after.senderShipId, otherShipId: after.reachedShipId, newestMessageId: after.messageId, unacknowledged: 0 });
|
|
43
|
+
add({ shipId: after.senderShipId, otherShipId: after.reachedShipId, newestMessageId: after.messageId, unacknowledged: 0, unseenPlainMessages: 0 });
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
|
-
return [...counts.values()].filter((count) => count.unacknowledged !== 0 || isNewReach);
|
|
46
|
+
return [...counts.values()].filter((count) => count.unacknowledged !== 0 || count.unseenPlainMessages !== 0 || isNewReach);
|
|
43
47
|
}
|
|
44
48
|
//# sourceMappingURL=exchange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../../src/domain/messaging/exchange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmD,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../../src/domain/messaging/exchange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAmD,MAAM,sBAAsB,CAAC;AAInI;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAmD;IAC9E,OAAO,OAAO,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAC/E,CAAC;AAoBD,yFAAyF;AACzF,SAAS,gBAAgB,CAAC,KAAoB;IAC5C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,UAAU,IAAI,KAAK,KAAK,QAAQ,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAuD;IACtF,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,MAAM,GAAG,GAAG,CAAC,KAAoB,EAAE,EAAE;QACnC,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;YACd,GAAG,KAAK;YACR,cAAc,EAAE,CAAC,GAAG,EAAE,cAA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CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,CAAC,CAAC;QACrJ,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,KAAK,CAAC,IAAI,KAAK,CAAC,mBAAmB,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC;AAC7H,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FleetId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { FleetRepository } from '../registry/public.js';
|
|
3
|
+
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
4
|
+
import type { MessageMetadataFill, MetadataFillIndexes } from './ports.js';
|
|
5
|
+
/** How many messages, and how many exchanges, one batch visits at most: each batch stays one short transaction. */
|
|
6
|
+
export declare const METADATA_FILL_BATCH = 100;
|
|
7
|
+
export interface FillMessageMetadataTx {
|
|
8
|
+
messageMetadataFill: MessageMetadataFill;
|
|
9
|
+
}
|
|
10
|
+
/** One pass; `onFleetError` is told of a fleet whose batch threw, and the pass goes on with the next fleet. Resolves whether every fleet's fill is complete. */
|
|
11
|
+
export type FillMessageMetadata = (onFleetError?: (fleetId: FleetId, error: unknown) => void) => Promise<{
|
|
12
|
+
isComplete: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Use case: the fill after start of the question ids and unseen plain message
|
|
16
|
+
* counts the migrations only added (docs/architecture.md, Backfills), run by
|
|
17
|
+
* core while it serves, never through the API. The first pass builds the
|
|
18
|
+
* indexes the fill and the reads of its unfilled part use. Each pass then
|
|
19
|
+
* takes one batch of each fleet, one unit of work under the fleet's cursor:
|
|
20
|
+
* the next messages by id and the next exchanges by key, and the cursor with
|
|
21
|
+
* them, so a batch that fails rolls back whole and the next pass takes it
|
|
22
|
+
* again. A fleet is complete once both walks reached their end.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createFillMessageMetadata(deps: {
|
|
25
|
+
fleets: Pick<FleetRepository, 'list'>;
|
|
26
|
+
indexes: MetadataFillIndexes;
|
|
27
|
+
uow: UnitOfWork<FillMessageMetadataTx>;
|
|
28
|
+
batch?: number;
|
|
29
|
+
}): FillMessageMetadata;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ok } from '../shared/result.js';
|
|
2
|
+
/** How many messages, and how many exchanges, one batch visits at most: each batch stays one short transaction. */
|
|
3
|
+
export const METADATA_FILL_BATCH = 100;
|
|
4
|
+
/**
|
|
5
|
+
* Use case: the fill after start of the question ids and unseen plain message
|
|
6
|
+
* counts the migrations only added (docs/architecture.md, Backfills), run by
|
|
7
|
+
* core while it serves, never through the API. The first pass builds the
|
|
8
|
+
* indexes the fill and the reads of its unfilled part use. Each pass then
|
|
9
|
+
* takes one batch of each fleet, one unit of work under the fleet's cursor:
|
|
10
|
+
* the next messages by id and the next exchanges by key, and the cursor with
|
|
11
|
+
* them, so a batch that fails rolls back whole and the next pass takes it
|
|
12
|
+
* again. A fleet is complete once both walks reached their end.
|
|
13
|
+
*/
|
|
14
|
+
export function createFillMessageMetadata(deps) {
|
|
15
|
+
const limit = deps.batch ?? METADATA_FILL_BATCH;
|
|
16
|
+
let wasIndexBuildDone = false;
|
|
17
|
+
const fillBatch = (fleetId) => deps.uow.run(async (tx) => {
|
|
18
|
+
const fill = tx.messageMetadataFill;
|
|
19
|
+
const cursor = await fill.lockCursor(fleetId);
|
|
20
|
+
if (cursor.isComplete) {
|
|
21
|
+
return ok(true);
|
|
22
|
+
}
|
|
23
|
+
const messageIds = await fill.fillQuestionIds(fleetId, { after: cursor.afterMessageId, limit });
|
|
24
|
+
const exchanges = await fill.fillUnseenPlainMessages(fleetId, { after: cursor.afterExchange, limit });
|
|
25
|
+
const isComplete = messageIds.length < limit && exchanges.length < limit;
|
|
26
|
+
await fill.saveCursor(fleetId, {
|
|
27
|
+
afterMessageId: messageIds.at(-1) ?? cursor.afterMessageId,
|
|
28
|
+
afterExchange: exchanges.at(-1) ?? cursor.afterExchange,
|
|
29
|
+
isComplete,
|
|
30
|
+
});
|
|
31
|
+
return ok(isComplete);
|
|
32
|
+
});
|
|
33
|
+
return async (onFleetError) => {
|
|
34
|
+
if (!wasIndexBuildDone) {
|
|
35
|
+
if (!await deps.indexes.build()) {
|
|
36
|
+
return { isComplete: false };
|
|
37
|
+
}
|
|
38
|
+
wasIndexBuildDone = true;
|
|
39
|
+
}
|
|
40
|
+
let isComplete = true;
|
|
41
|
+
for (const fleet of await deps.fleets.list()) {
|
|
42
|
+
try {
|
|
43
|
+
const batch = await fillBatch(fleet.id);
|
|
44
|
+
isComplete = isComplete && batch.isOk && batch.value;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
isComplete = false;
|
|
48
|
+
onFleetError?.(fleet.id, error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { isComplete };
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=fill-message-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-message-metadata.js","sourceRoot":"","sources":["../../../src/domain/messaging/fill-message-metadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAIzC,mHAAmH;AACnH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AASvC;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAKzC;IACC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,mBAAmB,CAAC;IAChD,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE,CACrC,I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UAAU,GAAG,IAAI,CAAC;QACtB,KAAK,MAAM,KAAK,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACxC,UAAU,GAAG,UAAU,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,UAAU,GAAG,KAAK,CAAC;gBACnB,YAAY,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -28,6 +28,10 @@ export interface Message {
|
|
|
28
28
|
requestHash: string;
|
|
29
29
|
/** The uuid of the question a withdrawal or a replacement names, read at send (decision 0068, B18): metadata, so it is found in a sealed fleet too. */
|
|
30
30
|
questionId: string | null;
|
|
31
|
+
/** The uuid of the question a question or a replacement asks, read at send as {@link questionId} is: so its open questions are found in a sealed fleet too (#1632). */
|
|
32
|
+
askedQuestionId: string | null;
|
|
33
|
+
/** The uuid of the question an answer names, read at send as {@link questionId} is. */
|
|
34
|
+
answeredQuestionId: string | null;
|
|
31
35
|
/** The message of the same fleet this one replies to. */
|
|
32
36
|
inReplyToMessageId: MessageId | null;
|
|
33
37
|
/** The message this one resends: an undeliverable one the operator sent again. */
|
|
@@ -151,7 +155,7 @@ export type AcceptRefusal = DomainError<'IN_REPLY_TO_NOT_FOUND' | 'MODEL_REQUIRE
|
|
|
151
155
|
* its selector resolved to, and MessageAccepted, caused by the sender. A reply
|
|
152
156
|
* names a message of the same fleet: `repliedTo` is that message as the fleet
|
|
153
157
|
* holds it, if it does. Only an agent ship states the model its session
|
|
154
|
-
* runs (decisions 0018 and 0044); argo, a person, an app and a
|
|
158
|
+
* runs (decisions 0018 and 0044); argo, a person, an app, a plugin and a trierarch state none (decision 0050). A resend carries the
|
|
155
159
|
* original message's model as it was, so it is not asked again; a ping is the
|
|
156
160
|
* fleet's question, not a session's message, so it carries none. A type
|
|
157
161
|
* delivery the network rules limit to some ships of the type keeps them. A
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isPingContentType, withdrawalOf } from '@aeolus-fleet/common';
|
|
1
|
+
import { answeredQuestionIdOf, askedQuestionIdOf, isPingContentType, withdrawalOf } from '@aeolus-fleet/common';
|
|
2
2
|
import { refuse } from '../shared/errors.js';
|
|
3
3
|
import { shipActor } from '../shared/events.js';
|
|
4
4
|
import { ok } from '../shared/result.js';
|
|
@@ -36,7 +36,7 @@ export function repeatOf(original, repeat) {
|
|
|
36
36
|
* its selector resolved to, and MessageAccepted, caused by the sender. A reply
|
|
37
37
|
* names a message of the same fleet: `repliedTo` is that message as the fleet
|
|
38
38
|
* holds it, if it does. Only an agent ship states the model its session
|
|
39
|
-
* runs (decisions 0018 and 0044); argo, a person, an app and a
|
|
39
|
+
* runs (decisions 0018 and 0044); argo, a person, an app, a plugin and a trierarch state none (decision 0050). A resend carries the
|
|
40
40
|
* original message's model as it was, so it is not asked again; a ping is the
|
|
41
41
|
* fleet's question, not a session's message, so it carries none. A type
|
|
42
42
|
* delivery the network rules limit to some ships of the type keeps them. A
|
|
@@ -60,6 +60,8 @@ export function acceptMessage(fleet, send) {
|
|
|
60
60
|
selector: recipient,
|
|
61
61
|
payload: send.payload,
|
|
62
62
|
questionId: questionIdOf(send),
|
|
63
|
+
askedQuestionId: askedQuestionIdOf(send),
|
|
64
|
+
answeredQuestionId: answeredQuestionIdOf(send),
|
|
63
65
|
contentType: send.contentType,
|
|
64
66
|
model: send.model ?? null,
|
|
65
67
|
idempotencyKey: send.idempotencyKey,
|
|
@@ -121,7 +123,7 @@ export function checkModel(send) {
|
|
|
121
123
|
if (isStated && send.senderKind === 'operator' && send.model !== undefined) {
|
|
122
124
|
return refuse('MODEL_FROM_ARGO', 'argo states no model: send without one');
|
|
123
125
|
}
|
|
124
|
-
if (isStated && (send.senderKind === 'person' || send.senderKind === 'app' || send.senderKind === 'plugin') && send.model !== undefined) {
|
|
126
|
+
if (isStated && (send.senderKind === 'person' || send.senderKind === 'app' || send.senderKind === 'plugin' || send.senderKind === 'trierarch') && send.model !== undefined) {
|
|
125
127
|
return refuse('MODEL_FROM_PERSON_APP_OR_PLUGIN', `A ${send.senderKind} ship states no model: send without one`);
|
|
126
128
|
}
|
|
127
129
|
if (isStated && send.senderKind === 'agent' && send.model === undefined) {
|
|
@@ -148,6 +150,8 @@ export function acceptContribution(send) {
|
|
|
148
150
|
selector: { kind: 'meeting', meetingId },
|
|
149
151
|
payload: send.payload,
|
|
150
152
|
questionId: questionIdOf(send),
|
|
153
|
+
askedQuestionId: askedQuestionIdOf(send),
|
|
154
|
+
answeredQuestionId: answeredQuestionIdOf(send),
|
|
151
155
|
contentType: send.contentType,
|
|
152
156
|
model: send.model ?? null,
|
|
153
157
|
idempotencyKey: send.idempotencyKey,
|
|
@@ -212,6 +216,8 @@ export function acceptLabelMessage(repliedTo, send) {
|
|
|
212
216
|
selector,
|
|
213
217
|
payload: send.payload,
|
|
214
218
|
questionId: questionIdOf(send),
|
|
219
|
+
askedQuestionId: askedQuestionIdOf(send),
|
|
220
|
+
answeredQuestionId: answeredQuestionIdOf(send),
|
|
215
221
|
contentType: send.contentType,
|
|
216
222
|
model: send.model ?? null,
|
|
217
223
|
idempotencyKey: send.idempotencyKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/domain/messaging/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAmL,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/domain/messaging/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,i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CAAC,CACH,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC1K,OAAO,EAAE,CAAC;QACR,OAAO;QACP,UAAU;QACV,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAY,EAAE,CAAC,CAAC;YACjE,OAAO;YACP,IAAI,EAAE,iBAAiB;YACvB,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK;YAC1B,MAAM;YACN,SAAS;YACT,UAAU;YACV,OAAO,EAAE;gBACP,QAAQ,EAAE,OAAO;gBACjB,aAAa,EAAE,IAAI;gBACnB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;gBACzB,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;gBACtC,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;aAC3H;SACF,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -121,6 +121,12 @@ export interface ScheduleNotifier {
|
|
|
121
121
|
scheduleDue(notice: ScheduleNotice): Promise<void>;
|
|
122
122
|
}
|
|
123
123
|
/** Outbound port: messages, always within one fleet. Never changed once stored. */
|
|
124
|
+
/** A question a ship asked another ship that is still open: its message, the ship it asked and its uuid. */
|
|
125
|
+
export interface OpenQuestion {
|
|
126
|
+
messageId: MessageId;
|
|
127
|
+
askedShipId: ShipId;
|
|
128
|
+
questionId: string;
|
|
129
|
+
}
|
|
124
130
|
export interface MessageRepository {
|
|
125
131
|
create(message: Message): Promise<void>;
|
|
126
132
|
/**
|
|
@@ -133,6 +139,18 @@ export interface MessageRepository {
|
|
|
133
139
|
/** The message the sender stored with this key, if any. */
|
|
134
140
|
findByIdempotencyKey(key: SenderKey): Promise<Message | undefined>;
|
|
135
141
|
find(fleetId: FleetId, messageId: MessageId): Promise<Message | undefined>;
|
|
142
|
+
/**
|
|
143
|
+
* The questions the ship asked another ship that is not retired and that
|
|
144
|
+
* are still open (decision 0038): a question or a replacement not answered
|
|
145
|
+
* by the ship it asked with an answer naming it, nor withdrawn or replaced
|
|
146
|
+
* by the ship itself. By message id, from after the cursor, at most limit:
|
|
147
|
+
* what it withdraws when it retires (#1632).
|
|
148
|
+
*/
|
|
149
|
+
listOpenQuestionsOf(fleetId: FleetId, query: {
|
|
150
|
+
shipId: ShipId;
|
|
151
|
+
after?: MessageId;
|
|
152
|
+
limit: number;
|
|
153
|
+
}): Promise<OpenQuestion[]>;
|
|
136
154
|
/**
|
|
137
155
|
* Holds the fleet's daily message-count lock until the unit of work ends, so
|
|
138
156
|
* two sends at the daily limit never both see room for one more.
|
|
@@ -210,6 +228,7 @@ export interface ListedExchange {
|
|
|
210
228
|
};
|
|
211
229
|
newestMessage: Message;
|
|
212
230
|
unacknowledged: number;
|
|
231
|
+
unseenPlainMessages: number;
|
|
213
232
|
}
|
|
214
233
|
/**
|
|
215
234
|
* Outbound port: the rollup of the person ships' lists of exchanges
|
|
@@ -318,27 +337,12 @@ export interface DeliveryRepository {
|
|
|
318
337
|
deliveryId: DeliveryId;
|
|
319
338
|
}): Promise<void>;
|
|
320
339
|
}
|
|
321
|
-
/** Where a
|
|
340
|
+
/** Where a wake stream listens: its ship, and the queue of its type, in its fleet. */
|
|
322
341
|
export interface ReceiverAddress {
|
|
323
342
|
fleetId: FleetId;
|
|
324
343
|
shipId: ShipId;
|
|
325
344
|
type: string;
|
|
326
345
|
}
|
|
327
|
-
/**
|
|
328
|
-
* Outbound port: wakes a waiting receive when a delivery may be pending for its
|
|
329
|
-
* ship or its type. A wake-up is a hint to look again, never a delivery: the
|
|
330
|
-
* receive finds out in the database whether one is there for it.
|
|
331
|
-
*/
|
|
332
|
-
export interface ReceiverWakeups {
|
|
333
|
-
/** Starts watching. A wake-up that comes before the next wait is kept for it. */
|
|
334
|
-
watch(address: ReceiverAddress): ReceiverWatch;
|
|
335
|
-
}
|
|
336
|
-
export interface ReceiverWatch {
|
|
337
|
-
/** Settles when the receive is woken, or once `waitMs` has passed. */
|
|
338
|
-
next(waitMs: number): Promise<'woken' | 'timedOut'>;
|
|
339
|
-
/** Stops watching. */
|
|
340
|
-
stop(): void;
|
|
341
|
-
}
|
|
342
346
|
/**
|
|
343
347
|
* How a wake stream's wait ended: a notice of a delivery pending for its ship
|
|
344
348
|
* or its type, the listener listening again, its time passed (a keep-alive is
|
|
@@ -418,8 +422,8 @@ export interface FleetSealingRepository {
|
|
|
418
422
|
findForUpdate(fleetId: FleetId): Promise<FleetSealing | undefined>;
|
|
419
423
|
/** Whether the fleet stores a payload plain: a message's or a schedule's. */
|
|
420
424
|
storesPlainPayload(fleetId: FleetId): Promise<boolean>;
|
|
421
|
-
/** How many payloads
|
|
422
|
-
|
|
425
|
+
/** How many payloads a fleet not yet sealing has to seal: the messages it stored, pruned ones too, and its plain schedules. */
|
|
426
|
+
payloadsToSeal(fleetId: FleetId): Promise<number>;
|
|
423
427
|
/** Marks the fleet sealing or sealed under its company key, with its first data key, current. */
|
|
424
428
|
turnOn(sealing: FleetSealing, firstKey: StoredDataKey): Promise<void>;
|
|
425
429
|
/** The fleet's data keys, oldest first, each with when it was made and whether it is current: never a wrap. */
|
|
@@ -476,3 +480,44 @@ export interface FleetSealingRepository {
|
|
|
476
480
|
}[];
|
|
477
481
|
}): Promise<void>;
|
|
478
482
|
}
|
|
483
|
+
/** An exchange's key in its fleet: the person ship and the ship it exchanged with. */
|
|
484
|
+
export interface ExchangeKey {
|
|
485
|
+
shipId: ShipId;
|
|
486
|
+
otherShipId: ShipId;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Where a fleet's metadata fill stands (docs/architecture.md, Backfills): the
|
|
490
|
+
* last message it visited by id, the last exchange it visited by key, and
|
|
491
|
+
* whether both walks reached the end.
|
|
492
|
+
*/
|
|
493
|
+
export interface MetadataFillCursor {
|
|
494
|
+
afterMessageId: MessageId | null;
|
|
495
|
+
afterExchange: ExchangeKey | null;
|
|
496
|
+
isComplete: boolean;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Outbound port: the fill after start of what the question id and unseen
|
|
500
|
+
* plain message migrations left empty, always within one fleet. A message
|
|
501
|
+
* stored since then holds its question ids and an exchange made since then
|
|
502
|
+
* its count, so each walk ends.
|
|
503
|
+
*/
|
|
504
|
+
export interface MessageMetadataFill {
|
|
505
|
+
/** The fleet's cursor, held for update until the unit of work ends; a fleet never visited starts at the beginning. */
|
|
506
|
+
lockCursor(fleetId: FleetId): Promise<MetadataFillCursor>;
|
|
507
|
+
/** Fills the question ids of the next messages by id after `after`, at most limit; the ids it visited, in order. */
|
|
508
|
+
fillQuestionIds(fleetId: FleetId, query: {
|
|
509
|
+
after: MessageId | null;
|
|
510
|
+
limit: number;
|
|
511
|
+
}): Promise<MessageId[]>;
|
|
512
|
+
/** Counts the unseen plain messages of each of the next exchanges by key after `after` that holds none, at most limit; the keys it visited, in order. */
|
|
513
|
+
fillUnseenPlainMessages(fleetId: FleetId, query: {
|
|
514
|
+
after: ExchangeKey | null;
|
|
515
|
+
limit: number;
|
|
516
|
+
}): Promise<ExchangeKey[]>;
|
|
517
|
+
saveCursor(fleetId: FleetId, cursor: MetadataFillCursor): Promise<void>;
|
|
518
|
+
}
|
|
519
|
+
/** Outbound port: the indexes the fill and the reads of what it has not filled yet use, built while core serves, without holding writes. */
|
|
520
|
+
export interface MetadataFillIndexes {
|
|
521
|
+
/** Builds each one that is not there or not valid; false means a build stopped or another core holds it. */
|
|
522
|
+
build(): Promise<boolean>;
|
|
523
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { hasClockRunOut, NOT_CONFIRMED_MINUTES, type ClockedCrew, type OverdueClock, type WaitingState } from './overdue.js';
|
|
2
2
|
export { leaveMeetingsOnRetire, lockMeetingsOf, type RetiredParticipantTx } from './retired-participant.js';
|
|
3
|
+
export { withdrawQuestionsOnRetire, type RetiredAskerTx } from './retired-asker.js';
|
|
3
4
|
export { cancelSchedulesOnRetire, lockSchedulesOf, type RetiredSchedulerTx } from './retired-scheduler.js';
|
|
4
5
|
export type { FleetSealingRepository, RequestHasher } from './ports.js';
|
|
5
6
|
export type { CompanyKeyUnavailableReason } from './fleet-sealing.js';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// part of it; adapters import them from their own modules.
|
|
3
3
|
export { hasClockRunOut, NOT_CONFIRMED_MINUTES } from './overdue.js';
|
|
4
4
|
export { leaveMeetingsOnRetire, lockMeetingsOf } from './retired-participant.js';
|
|
5
|
+
export { withdrawQuestionsOnRetire } from './retired-asker.js';
|
|
5
6
|
export { cancelSchedulesOnRetire, lockSchedulesOf } from './retired-scheduler.js';
|
|
6
7
|
export { DATA_KEY_CACHE_MS, heldForList, heldForRead, listedUnsealed, plainForRead, withDataKeys, UNREADABLE_PAYLOAD, } from './data-keys.js';
|
|
7
8
|
export { isSealedPayload } from './sealed-payload.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/messaging/public.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2DAA2D;AAC3D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAA0D,MAAM,cAAc,CAAC;AAC7H,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAA6B,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAA2B,MAAM,wBAAwB,CAAC;AAI3G,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EAMZ,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAsB,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/domain/messaging/public.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,2DAA2D;AAC3D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAA0D,MAAM,cAAc,CAAC;AAC7H,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAA6B,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAE,yBAAyB,EAAuB,MAAM,oBAAoB,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAA2B,MAAM,wBAAwB,CAAC;AAI3G,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,YAAY,EAMZ,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAsB,MAAM,qBAAqB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { type EventLog } from '../shared/events.js';
|
|
|
6
6
|
import { type Result } from '../shared/result.js';
|
|
7
7
|
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
8
8
|
import { type PayloadSealing } from './data-keys.js';
|
|
9
|
-
import type { DeliveryRepository
|
|
9
|
+
import type { DeliveryRepository } from './ports.js';
|
|
10
10
|
import { type ReceivedDelivery, type ReceiveRefusal } from './receive-deliveries.js';
|
|
11
11
|
export interface PushReceiveDeliveriesTx extends HoldLeaseTx, FindSenderTx {
|
|
12
12
|
leases: Pick<LeaseRepository, 'findOpenByIdForShare' | 'markPushed' | 'findCrewed'>;
|
|
@@ -22,7 +22,7 @@ export interface PushReceivedDelivery extends ReceivedDelivery {
|
|
|
22
22
|
handOverNumber: number | null;
|
|
23
23
|
}
|
|
24
24
|
export interface DeliveriesPushReceived {
|
|
25
|
-
/** None when
|
|
25
|
+
/** None when nothing was there for the crew. */
|
|
26
26
|
deliveries: PushReceivedDelivery[];
|
|
27
27
|
}
|
|
28
28
|
export type PushReceiveDeliveries = (crew: Crew, input: {
|
|
@@ -48,7 +48,8 @@ export type PushReceiveDeliveries = (crew: Crew, input: {
|
|
|
48
48
|
* it ends, the lease is pushed: the agent's plain receive answers nothing.
|
|
49
49
|
* Its first push receive may state what wakes the ship, kept with the lease
|
|
50
50
|
* (interop 5.1).
|
|
51
|
-
* When nothing is there it
|
|
51
|
+
* When nothing is there it answers empty at once, as a receive does
|
|
52
|
+
* (decision 0072).
|
|
52
53
|
* In a sealed fleet it unseals as a receive does (decision 0068, B9): a key
|
|
53
54
|
* it cannot get refuses KEY_UNAVAILABLE and takes nothing.
|
|
54
55
|
*/
|
|
@@ -57,7 +58,4 @@ export declare function createPushReceiveDeliveries(deps: {
|
|
|
57
58
|
clock: Clock;
|
|
58
59
|
ids: IdGenerator;
|
|
59
60
|
sealing: PayloadSealing;
|
|
60
|
-
wakeups: ReceiverWakeups;
|
|
61
|
-
/** How long a push receive waits on an empty inbox; about 25 seconds unless a test says otherwise. */
|
|
62
|
-
waitMs?: number;
|
|
63
61
|
}): PushReceiveDeliveries;
|
|
@@ -3,7 +3,7 @@ import { recordEvent } from '../shared/events.js';
|
|
|
3
3
|
import { ok } from '../shared/result.js';
|
|
4
4
|
import { withDataKeys } from './data-keys.js';
|
|
5
5
|
import { pushReceiveDelivery } from './delivery.js';
|
|
6
|
-
import {
|
|
6
|
+
import { receivedDeliveryOf } from './receive-deliveries.js';
|
|
7
7
|
import { receiveMax } from './receive-max.js';
|
|
8
8
|
/**
|
|
9
9
|
* Takes up to `max` deliveries for the crew in one unit of work: marks its
|
|
@@ -66,21 +66,19 @@ async function pushReceiptForCrew(deps, receipt) {
|
|
|
66
66
|
* it ends, the lease is pushed: the agent's plain receive answers nothing.
|
|
67
67
|
* Its first push receive may state what wakes the ship, kept with the lease
|
|
68
68
|
* (interop 5.1).
|
|
69
|
-
* When nothing is there it
|
|
69
|
+
* When nothing is there it answers empty at once, as a receive does
|
|
70
|
+
* (decision 0072).
|
|
70
71
|
* In a sealed fleet it unseals as a receive does (decision 0068, B9): a key
|
|
71
72
|
* it cannot get refuses KEY_UNAVAILABLE and takes nothing.
|
|
72
73
|
*/
|
|
73
74
|
export function createPushReceiveDeliveries(deps) {
|
|
74
|
-
const waitMs = deps.waitMs ?? RECEIVE_WAIT_MS;
|
|
75
75
|
return async (crew, input) => {
|
|
76
76
|
const max = receiveMax(input.max);
|
|
77
77
|
if (!max.isOk) {
|
|
78
78
|
return max;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
look: () => withDataKeys({ sealing: deps.sealing, fleetId: crew.fleetId }, (keys) => deps.uow.run((tx) => pushReceiptForCrew({ tx, ids: deps.ids, at: deps.clock.now(), keys }, { crew, max: max.value, shouldSkipHanded: input.shouldSkipHanded ?? false, excluding: input.excluding ?? [], ...(input.waker === undefined ? {} : { waker: input.waker }) }))),
|
|
83
|
-
});
|
|
80
|
+
const received = await withDataKeys({ sealing: deps.sealing, fleetId: crew.fleetId }, (keys) => deps.uow.run((tx) => pushReceiptForCrew({ tx, ids: deps.ids, at: deps.clock.now(), keys }, { crew, max: max.value, shouldSkipHanded: input.shouldSkipHanded ?? false, excluding: input.excluding ?? [], ...(input.waker === undefined ? {} : { waker: input.waker }) })));
|
|
81
|
+
return received.isOk ? ok({ deliveries: received.value.deliveries }) : received;
|
|
84
82
|
};
|
|
85
83
|
}
|
|
86
84
|
//# sourceMappingURL=push-receive-deliveries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-receive-deliveries.js","sourceRoot":"","sources":["../../../src/domain/messaging/push-receive-deliveries.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,eAAe,EAA6F,MAAM,uBAAuB,CAAC;AAG9J,OAAO,E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C,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAC5K,CACF,CACF,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClF,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -20,7 +20,7 @@ export function createReadExchanges(deps) {
|
|
|
20
20
|
}
|
|
21
21
|
const page = await tx.exchanges.page({ fleetId: crew.fleetId, shipId: crew.shipId, cursor, limit });
|
|
22
22
|
const items = [];
|
|
23
|
-
for (const { otherShip, newestMessage: message, unacknowledged } of page.items) {
|
|
23
|
+
for (const { otherShip, newestMessage: message, unacknowledged, unseenPlainMessages } of page.items) {
|
|
24
24
|
const payload = listedUnsealed(keys, { row: { fleetId: message.fleetId, rowId: message.id }, payload: message.payload });
|
|
25
25
|
if (!payload.isOk) {
|
|
26
26
|
return payload;
|
|
@@ -31,6 +31,7 @@ export function createReadExchanges(deps) {
|
|
|
31
31
|
otherShipType: otherShip.type,
|
|
32
32
|
otherShipKind: otherShip.kind,
|
|
33
33
|
unacknowledged,
|
|
34
|
+
unseenPlainMessages,
|
|
34
35
|
newestMessage: { messageId: message.id, senderShipId: message.senderShipId, payload: payload.value, contentType: message.contentType, sentAt: message.createdAt },
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-exchanges.js","sourceRoot":"","sources":["../../../src/domain/messaging/read-exchanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAA8C,MAAM,sBAAsB,CAAC;AAE5G,OAAO,EAAE,SAAS,EAAqC,MAAM,uBAAuB,CAAC;AAIrF,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAgE,MAAM,gBAA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G,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YACzH,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBAClB,OAAO,OAAO,CAAC;YACjB,CAAC;YACD,KAAK,CAAC,IAAI,CAAC;gBACT,WAAW,EAAE,SAAS,CAAC,EAAE;gBACzB,aAAa,EAAE,SAAS,CAAC,IAAI;gBAC7B,aAAa,EAAE,SAAS,CAAC,IAAI;gBAC7B,aAAa,EAAE,SAAS,CAAC,IAAI;gBAC7B,cAAc;gBACd,mBAAmB;gBACnB,aAAa,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE;aAClK,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC,CACH,CAAC;AACN,CAAC"}
|
|
@@ -9,7 +9,7 @@ import type { Recipient } from '../shared/selector.js';
|
|
|
9
9
|
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
10
10
|
import { type DataKeysNeeded, type HeldDataKeys, type PayloadSealing } from './data-keys.js';
|
|
11
11
|
import type { Delivery, Message } from './message.js';
|
|
12
|
-
import type { DeliveryRepository
|
|
12
|
+
import type { DeliveryRepository } from './ports.js';
|
|
13
13
|
export interface ReceiveDeliveriesTx extends HoldLeaseTx, FindSenderTx {
|
|
14
14
|
leases: Pick<LeaseRepository, 'findOpenByIdForShare' | 'isPushed' | 'findCrewed'>;
|
|
15
15
|
ships: Pick<ShipRepository, 'find'>;
|
|
@@ -45,15 +45,13 @@ export interface ReceivedDelivery {
|
|
|
45
45
|
sendTime: Date | null;
|
|
46
46
|
}
|
|
47
47
|
export interface DeliveriesReceived {
|
|
48
|
-
/** None when
|
|
48
|
+
/** None when nothing was there for the crew. */
|
|
49
49
|
deliveries: ReceivedDelivery[];
|
|
50
50
|
}
|
|
51
51
|
export type ReceiveRefusal = DomainError<'INVALID_RECEIVE_MAX' | 'SHIP_NOT_FOUND' | 'KEY_UNAVAILABLE'> | LeaseEnded;
|
|
52
52
|
export type ReceiveDeliveries = (crew: Crew, input: {
|
|
53
53
|
max?: number;
|
|
54
54
|
}) => Promise<Result<DeliveriesReceived, ReceiveRefusal>>;
|
|
55
|
-
/** How long a receive waits for a delivery when none is there: about 25 seconds, then it returns empty. */
|
|
56
|
-
export declare const RECEIVE_WAIT_MS = 25000;
|
|
57
55
|
/**
|
|
58
56
|
* The delivery as its crew gets it: with its message, its payload unsealed
|
|
59
57
|
* in a sealed fleet (decision 0068, B9), and its sender by id and by the name,
|
|
@@ -105,40 +103,12 @@ export declare function claimForCrew(deps: ClaimDeps, claim: {
|
|
|
105
103
|
* does not give refuses KEY_UNAVAILABLE, nothing claimed and no attempt
|
|
106
104
|
* counted, and the deliveries wait pending.
|
|
107
105
|
*
|
|
108
|
-
* When nothing is there it
|
|
109
|
-
*
|
|
110
|
-
* starts watching before it looks a second time, so a delivery that commits
|
|
111
|
-
* between its first look and its watch is found by that second look. A
|
|
112
|
-
* wake-up that brings nothing for it, a type delivery another ship took,
|
|
113
|
-
* leaves it waiting for the rest of its time.
|
|
106
|
+
* When nothing is there it answers empty at once: no call waits (decision
|
|
107
|
+
* 0072); a crew is told to look by its wake stream.
|
|
114
108
|
*/
|
|
115
109
|
export declare function createReceiveDeliveries(deps: {
|
|
116
110
|
uow: UnitOfWork<ReceiveDeliveriesTx>;
|
|
117
111
|
clock: Clock;
|
|
118
112
|
ids: IdGenerator;
|
|
119
113
|
sealing: PayloadSealing;
|
|
120
|
-
wakeups: ReceiverWakeups;
|
|
121
|
-
/** How long a receive waits on an empty inbox; about 25 seconds unless a test says otherwise. */
|
|
122
|
-
waitMs?: number;
|
|
123
114
|
}): ReceiveDeliveries;
|
|
124
|
-
/**
|
|
125
|
-
* Looks for the crew's deliveries, one unit of work per `look`, and
|
|
126
|
-
* when there are none waits for a wake-up for its ship or its type, until
|
|
127
|
-
* `waitMs` has passed. It starts watching before it looks a second time, so a
|
|
128
|
-
* delivery that commits between its first look and its watch is found by that
|
|
129
|
-
* second look. A wake-up that brings nothing for it leaves it waiting for the
|
|
130
|
-
* rest of its time.
|
|
131
|
-
*/
|
|
132
|
-
export declare function waitForDeliveries<Found, Refusal>(deps: {
|
|
133
|
-
clock: Clock;
|
|
134
|
-
wakeups: ReceiverWakeups;
|
|
135
|
-
waitMs: number;
|
|
136
|
-
}, wait: {
|
|
137
|
-
crew: Crew;
|
|
138
|
-
look: () => Promise<Result<{
|
|
139
|
-
ship: Ship;
|
|
140
|
-
deliveries: Found[];
|
|
141
|
-
}, Refusal>>;
|
|
142
|
-
}): Promise<Result<{
|
|
143
|
-
deliveries: Found[];
|
|
144
|
-
}, Refusal>>;
|