@aeolus-fleet/core 0.31.0 → 0.32.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 +1 -1
- package/dist/adapters/prisma/defined-scopes.d.ts +4 -0
- package/dist/adapters/prisma/defined-scopes.js +23 -0
- package/dist/adapters/prisma/defined-scopes.js.map +1 -0
- package/dist/adapters/prisma/delivery-notices.d.ts +3 -0
- package/dist/adapters/prisma/delivery-notices.js +7 -2
- package/dist/adapters/prisma/delivery-notices.js.map +1 -1
- package/dist/adapters/prisma/fleet-limit-settings.d.ts +6 -0
- package/dist/adapters/prisma/fleet-limit-settings.js +17 -0
- package/dist/adapters/prisma/fleet-limit-settings.js.map +1 -0
- package/dist/adapters/prisma/generated/browser.d.ts +17 -3
- package/dist/adapters/prisma/generated/client.d.ts +17 -3
- package/dist/adapters/prisma/generated/commonInputTypes.d.ts +196 -46
- package/dist/adapters/prisma/generated/enums.d.ts +32 -0
- package/dist/adapters/prisma/generated/enums.js +28 -1
- package/dist/adapters/prisma/generated/enums.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/class.d.ts +22 -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 +254 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js +62 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespace.js.map +1 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.d.ts +63 -0
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js +62 -1
- package/dist/adapters/prisma/generated/internal/prismaNamespaceBrowser.js.map +1 -1
- package/dist/adapters/prisma/generated/models/DefinedScope.d.ts +1110 -0
- package/dist/adapters/prisma/generated/models/DefinedScope.js +2 -0
- package/dist/adapters/prisma/generated/models/DefinedScope.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Fleet.d.ts +2128 -2
- package/dist/adapters/prisma/generated/models/InstallationSettings.d.ts +108 -4
- package/dist/adapters/prisma/generated/models/Message.d.ts +557 -516
- package/dist/adapters/prisma/generated/models/Schedule.d.ts +3925 -0
- package/dist/adapters/prisma/generated/models/Schedule.js +2 -0
- package/dist/adapters/prisma/generated/models/Schedule.js.map +1 -0
- package/dist/adapters/prisma/generated/models/Ship.d.ts +736 -3
- package/dist/adapters/prisma/generated/models.d.ts +2 -0
- package/dist/adapters/prisma/history-pruner.d.ts +3 -0
- package/dist/adapters/prisma/history-pruner.js +232 -0
- package/dist/adapters/prisma/history-pruner.js.map +1 -0
- package/dist/adapters/prisma/history.js +67 -14
- package/dist/adapters/prisma/history.js.map +1 -1
- package/dist/adapters/prisma/installation.js +27 -8
- package/dist/adapters/prisma/installation.js.map +1 -1
- package/dist/adapters/prisma/messaging.js +7 -3
- package/dist/adapters/prisma/messaging.js.map +1 -1
- package/dist/adapters/prisma/registry.js +28 -9
- package/dist/adapters/prisma/registry.js.map +1 -1
- package/dist/adapters/prisma/rows.js +10 -1
- package/dist/adapters/prisma/rows.js.map +1 -1
- package/dist/adapters/prisma/schedules.d.ts +12 -0
- package/dist/adapters/prisma/schedules.js +255 -0
- package/dist/adapters/prisma/schedules.js.map +1 -0
- package/dist/adapters/prisma/unit-of-work.d.ts +7 -2
- package/dist/adapters/prisma/unit-of-work.js +7 -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/console.js +3 -6
- package/dist/adapters/trpc/console.js.map +1 -1
- package/dist/adapters/trpc/context.d.ts +20 -0
- package/dist/adapters/trpc/fleet.d.ts +210 -8
- package/dist/adapters/trpc/fleet.js +111 -11
- package/dist/adapters/trpc/fleet.js.map +1 -1
- package/dist/adapters/trpc/installation.d.ts +139 -4
- package/dist/adapters/trpc/installation.js +4 -4
- package/dist/adapters/trpc/installation.js.map +1 -1
- package/dist/adapters/trpc/router.d.ts +508 -8
- package/dist/adapters/trpc/schedule-output.d.ts +74 -0
- package/dist/adapters/trpc/schedule-output.js +71 -0
- package/dist/adapters/trpc/schedule-output.js.map +1 -0
- package/dist/adapters/trpc/ship-contract.js +7 -0
- package/dist/adapters/trpc/ship-contract.js.map +1 -1
- package/dist/adapters/trpc/ship.d.ts +188 -3
- package/dist/adapters/trpc/ship.js +105 -11
- package/dist/adapters/trpc/ship.js.map +1 -1
- package/dist/adapters/trpc/starting-prompt-text.js +5 -5
- package/dist/adapters/trpc/starting-prompt-text.js.map +1 -1
- package/dist/adapters/trpc/trpc.d.ts +8 -0
- package/dist/adapters/trpc/trpc.js +19 -2
- package/dist/adapters/trpc/trpc.js.map +1 -1
- package/dist/app.d.ts +5 -3
- package/dist/app.js +30 -4
- package/dist/app.js.map +1 -1
- package/dist/domain/messaging/add-to-meeting.js +1 -1
- package/dist/domain/messaging/add-to-meeting.js.map +1 -1
- package/dist/domain/messaging/cancel-schedule.d.ts +35 -0
- package/dist/domain/messaging/cancel-schedule.js +45 -0
- package/dist/domain/messaging/cancel-schedule.js.map +1 -0
- package/dist/domain/messaging/check-reach-to-each.d.ts +25 -0
- package/dist/domain/messaging/check-reach-to-each.js +21 -0
- package/dist/domain/messaging/check-reach-to-each.js.map +1 -0
- package/dist/domain/messaging/cron.d.ts +46 -0
- package/dist/domain/messaging/cron.js +164 -0
- package/dist/domain/messaging/cron.js.map +1 -0
- package/dist/domain/messaging/daily-message-limit.d.ts +7 -5
- package/dist/domain/messaging/daily-message-limit.js +8 -7
- package/dist/domain/messaging/daily-message-limit.js.map +1 -1
- package/dist/domain/messaging/list-schedules.d.ts +38 -0
- package/dist/domain/messaging/list-schedules.js +33 -0
- package/dist/domain/messaging/list-schedules.js.map +1 -0
- package/dist/domain/messaging/message.d.ts +43 -4
- package/dist/domain/messaging/message.js +82 -4
- package/dist/domain/messaging/message.js.map +1 -1
- package/dist/domain/messaging/open-meeting.js +1 -1
- package/dist/domain/messaging/open-meeting.js.map +1 -1
- package/dist/domain/messaging/pause-schedule.d.ts +34 -0
- package/dist/domain/messaging/pause-schedule.js +44 -0
- package/dist/domain/messaging/pause-schedule.js.map +1 -0
- package/dist/domain/messaging/ports.d.ts +77 -3
- 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 -1
- package/dist/domain/messaging/push-receive-deliveries.js +5 -2
- package/dist/domain/messaging/push-receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/receive-deliveries.d.ts +4 -1
- package/dist/domain/messaging/receive-deliveries.js +2 -0
- package/dist/domain/messaging/receive-deliveries.js.map +1 -1
- package/dist/domain/messaging/resend-delivery.js +2 -2
- package/dist/domain/messaging/resend-delivery.js.map +1 -1
- package/dist/domain/messaging/resume-schedule.d.ts +34 -0
- package/dist/domain/messaging/resume-schedule.js +37 -0
- package/dist/domain/messaging/resume-schedule.js.map +1 -0
- package/dist/domain/messaging/retired-scheduler.d.ts +31 -0
- package/dist/domain/messaging/retired-scheduler.js +30 -0
- package/dist/domain/messaging/retired-scheduler.js.map +1 -0
- package/dist/domain/messaging/schedule-access.d.ts +20 -0
- package/dist/domain/messaging/schedule-access.js +21 -0
- package/dist/domain/messaging/schedule-access.js.map +1 -0
- package/dist/domain/messaging/schedule-limits.d.ts +25 -0
- package/dist/domain/messaging/schedule-limits.js +51 -0
- package/dist/domain/messaging/schedule-limits.js.map +1 -0
- package/dist/domain/messaging/schedule-message.d.ts +65 -0
- package/dist/domain/messaging/schedule-message.js +151 -0
- package/dist/domain/messaging/schedule-message.js.map +1 -0
- package/dist/domain/messaging/schedule.d.ts +238 -0
- package/dist/domain/messaging/schedule.js +316 -0
- package/dist/domain/messaging/schedule.js.map +1 -0
- package/dist/domain/messaging/send-due-schedules.d.ts +40 -0
- package/dist/domain/messaging/send-due-schedules.js +141 -0
- package/dist/domain/messaging/send-due-schedules.js.map +1 -0
- package/dist/domain/messaging/send-message.d.ts +10 -3
- package/dist/domain/messaging/send-message.js +78 -4
- package/dist/domain/messaging/send-message.js.map +1 -1
- package/dist/domain/messaging/send-request.d.ts +3 -2
- package/dist/domain/messaging/send-request.js +5 -2
- package/dist/domain/messaging/send-request.js.map +1 -1
- package/dist/domain/registry/applied-limits.d.ts +5 -7
- package/dist/domain/registry/applied-limits.js +5 -9
- package/dist/domain/registry/applied-limits.js.map +1 -1
- package/dist/domain/registry/check-manage.d.ts +23 -0
- package/dist/domain/registry/check-manage.js +19 -0
- package/dist/domain/registry/check-manage.js.map +1 -0
- package/dist/domain/registry/commission-ship.js +3 -3
- package/dist/domain/registry/commission-ship.js.map +1 -1
- package/dist/domain/registry/declare-scopes.d.ts +5 -3
- package/dist/domain/registry/declare-scopes.js +4 -2
- package/dist/domain/registry/declare-scopes.js.map +1 -1
- package/dist/domain/registry/define-scope.d.ts +33 -0
- package/dist/domain/registry/define-scope.js +30 -0
- package/dist/domain/registry/define-scope.js.map +1 -0
- package/dist/domain/registry/defined-scope.d.ts +68 -0
- package/dist/domain/registry/defined-scope.js +83 -0
- package/dist/domain/registry/defined-scope.js.map +1 -0
- package/dist/domain/registry/describe-scope.d.ts +31 -0
- package/dist/domain/registry/describe-scope.js +28 -0
- package/dist/domain/registry/describe-scope.js.map +1 -0
- package/dist/domain/registry/get-fleet-limits.d.ts +1 -1
- package/dist/domain/registry/get-fleet-limits.js +1 -1
- package/dist/domain/registry/get-fleet-limits.js.map +1 -1
- package/dist/domain/registry/grant-scopes.d.ts +4 -3
- package/dist/domain/registry/grant-scopes.js +4 -4
- package/dist/domain/registry/grant-scopes.js.map +1 -1
- package/dist/domain/registry/installation-fleet.d.ts +4 -1
- package/dist/domain/registry/installation-fleet.js +9 -2
- package/dist/domain/registry/installation-fleet.js.map +1 -1
- package/dist/domain/registry/label-value-texts.d.ts +16 -0
- package/dist/domain/registry/label-value-texts.js +15 -0
- package/dist/domain/registry/label-value-texts.js.map +1 -0
- package/dist/domain/registry/limits.d.ts +42 -7
- package/dist/domain/registry/limits.js +41 -6
- package/dist/domain/registry/limits.js.map +1 -1
- package/dist/domain/registry/list-scopes.d.ts +13 -6
- package/dist/domain/registry/list-scopes.js +15 -6
- package/dist/domain/registry/list-scopes.js.map +1 -1
- package/dist/domain/registry/named-namespaces.d.ts +18 -8
- package/dist/domain/registry/named-namespaces.js +11 -3
- package/dist/domain/registry/named-namespaces.js.map +1 -1
- package/dist/domain/registry/ports.d.ts +20 -0
- package/dist/domain/registry/public.d.ts +2 -0
- package/dist/domain/registry/public.js +2 -0
- package/dist/domain/registry/public.js.map +1 -1
- package/dist/domain/registry/remove-scope.d.ts +29 -0
- package/dist/domain/registry/remove-scope.js +32 -0
- package/dist/domain/registry/remove-scope.js.map +1 -0
- package/dist/domain/registry/resolve-label-selection.d.ts +20 -0
- package/dist/domain/registry/resolve-label-selection.js +26 -0
- package/dist/domain/registry/resolve-label-selection.js.map +1 -0
- package/dist/domain/registry/retire-ship.d.ts +5 -2
- package/dist/domain/registry/retire-ship.js +6 -1
- package/dist/domain/registry/retire-ship.js.map +1 -1
- package/dist/domain/registry/scope-grant.d.ts +6 -2
- package/dist/domain/registry/scope-grant.js +9 -5
- package/dist/domain/registry/scope-grant.js.map +1 -1
- package/dist/domain/registry/scope-namespace.d.ts +5 -1
- package/dist/domain/registry/scope-namespace.js +9 -2
- package/dist/domain/registry/scope-namespace.js.map +1 -1
- package/dist/domain/registry/set-fleet-limits.d.ts +8 -5
- package/dist/domain/registry/set-fleet-limits.js +38 -6
- package/dist/domain/registry/set-fleet-limits.js.map +1 -1
- package/dist/domain/registry/set-installation-settings.d.ts +4 -4
- package/dist/domain/registry/set-installation-settings.js +21 -15
- package/dist/domain/registry/set-installation-settings.js.map +1 -1
- package/dist/domain/registry/ship.d.ts +2 -0
- package/dist/domain/registry/ship.js +1 -1
- package/dist/domain/registry/ship.js.map +1 -1
- package/dist/domain/shared/delivery-way.d.ts +4 -0
- package/dist/domain/shared/delivery-way.js +5 -2
- package/dist/domain/shared/delivery-way.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-pruning.d.ts +130 -0
- package/dist/domain/shared/history-pruning.js +74 -0
- package/dist/domain/shared/history-pruning.js.map +1 -0
- package/dist/domain/shared/history.d.ts +33 -5
- package/dist/domain/shared/history.js +3 -1
- package/dist/domain/shared/history.js.map +1 -1
- package/dist/domain/shared/prune-history.d.ts +39 -0
- package/dist/domain/shared/prune-history.js +98 -0
- package/dist/domain/shared/prune-history.js.map +1 -0
- package/dist/domain/shared/read-fleet-limits.d.ts +14 -4
- package/dist/domain/shared/read-fleet-limits.js +8 -4
- package/dist/domain/shared/read-fleet-limits.js.map +1 -1
- package/dist/domain/shared/read-message-deliveries.d.ts +30 -0
- package/dist/domain/shared/read-message-deliveries.js +24 -0
- package/dist/domain/shared/read-message-deliveries.js.map +1 -0
- package/dist/domain/shared/read-message.d.ts +4 -1
- package/dist/domain/shared/read-message.js +3 -2
- package/dist/domain/shared/read-message.js.map +1 -1
- package/dist/domain/shared/read-sent-message.d.ts +21 -7
- package/dist/domain/shared/read-sent-message.js +19 -6
- package/dist/domain/shared/read-sent-message.js.map +1 -1
- package/dist/domain/shared/selector.d.ts +21 -8
- package/dist/schedule-timer.d.ts +22 -0
- package/dist/schedule-timer.js +78 -0
- package/dist/schedule-timer.js.map +1 -0
- package/dist/wiring.d.ts +26 -0
- package/dist/wiring.js +27 -1
- package/dist/wiring.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/prisma/migrations/20261025090000_scheduled_messages_envelope/migration.sql +5 -0
- package/src/adapters/prisma/migrations/20261025090100_schedules/migration.sql +109 -0
- package/src/adapters/prisma/migrations/20261025120000_repeating_schedules/migration.sql +40 -0
- package/src/adapters/prisma/migrations/20261025130000_schedule_limits/migration.sql +11 -0
- package/src/adapters/prisma/migrations/20261025140000_send_to_a_label/migration.sql +16 -0
- package/src/adapters/prisma/migrations/20261025150000_define_scope/migration.sql +64 -0
- package/src/adapters/prisma/migrations/20261025150100_defined_scopes/migration.sql +15 -0
- package/src/adapters/prisma/migrations/20261025160000_retention/migration.sql +7 -0
- package/src/adapters/prisma/migrations/20261025170000_message_deliveries_page/migration.sql +7 -0
- package/src/adapters/prisma/migrations/20261025180000_history_pruning/migration.sql +25 -0
- package/src/adapters/prisma/migrations/20261025190000_history_pruning_crew_events/migration.sql +2 -0
- package/src/adapters/prisma/migrations/20261025200000_schedule_to_a_label/migration.sql +12 -0
- package/src/adapters/prisma/schema.prisma +179 -26
|
@@ -4,11 +4,12 @@ import type { Clock } from '../shared/clock.js';
|
|
|
4
4
|
import { type EventLog } from '../shared/events.js';
|
|
5
5
|
import { type Result } from '../shared/result.js';
|
|
6
6
|
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
7
|
-
import type { ScopeNamespaceRepository, ShipRepository } from './ports.js';
|
|
7
|
+
import type { DefinedScopeRepository, ScopeNamespaceRepository, ShipRepository } from './ports.js';
|
|
8
8
|
import { type DeclaredScope, type DeclareScopesRefusal } from './scope-namespace.js';
|
|
9
9
|
export interface DeclareScopesTx {
|
|
10
10
|
ships: Pick<ShipRepository, 'find' | 'findForUpdate' | 'scopesHeldIn'>;
|
|
11
11
|
scopeNamespaces: Pick<ScopeNamespaceRepository, 'lockNamespace' | 'find' | 'findByDeclarer' | 'save'>;
|
|
12
|
+
definedScopes: Pick<DefinedScopeRepository, 'usesNamespace'>;
|
|
12
13
|
events: EventLog;
|
|
13
14
|
}
|
|
14
15
|
/** The namespace as declared, with its whole list of scopes. */
|
|
@@ -28,8 +29,9 @@ export type DeclareScopes = (caller: ShipCaller, input: {
|
|
|
28
29
|
* list of scopes, the first time or again (decision 0046). Its scope
|
|
29
30
|
* (scopes:declare) is checked before this runs. In one unit of work, holding
|
|
30
31
|
* the declaring ship, so one ship never takes two namespaces, then the
|
|
31
|
-
* namespace, so two ships
|
|
32
|
-
* waits: the namespace and
|
|
32
|
+
* namespace, so two ships, or a ship and the fleet defining a scope, never
|
|
33
|
+
* both find it free and a grant of its scopes waits: the namespace and
|
|
34
|
+
* ScopesDeclared.
|
|
33
35
|
*/
|
|
34
36
|
export declare function createDeclareScopes(deps: {
|
|
35
37
|
uow: UnitOfWork<DeclareScopesTx>;
|
|
@@ -6,8 +6,9 @@ import { declareScopes } from './scope-namespace.js';
|
|
|
6
6
|
* list of scopes, the first time or again (decision 0046). Its scope
|
|
7
7
|
* (scopes:declare) is checked before this runs. In one unit of work, holding
|
|
8
8
|
* the declaring ship, so one ship never takes two namespaces, then the
|
|
9
|
-
* namespace, so two ships
|
|
10
|
-
* waits: the namespace and
|
|
9
|
+
* namespace, so two ships, or a ship and the fleet defining a scope, never
|
|
10
|
+
* both find it free and a grant of its scopes waits: the namespace and
|
|
11
|
+
* ScopesDeclared.
|
|
11
12
|
*/
|
|
12
13
|
export function createDeclareScopes(deps) {
|
|
13
14
|
return (caller, input) => deps.uow.run(async (tx) => {
|
|
@@ -20,6 +21,7 @@ export function createDeclareScopes(deps) {
|
|
|
20
21
|
taken: taken && { namespace: taken, declarerName: declarer?.name ?? taken.declaredBy },
|
|
21
22
|
ofDeclarer: await tx.scopeNamespaces.findByDeclarer(fleetId, shipId),
|
|
22
23
|
held: taken === undefined ? [] : await tx.ships.scopesHeldIn(fleetId, input.namespace),
|
|
24
|
+
isUsedByFleet: await tx.definedScopes.usesNamespace(fleetId, input.namespace),
|
|
23
25
|
});
|
|
24
26
|
if (!declared.isOk) {
|
|
25
27
|
return declared;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declare-scopes.js","sourceRoot":"","sources":["../../../src/domain/registry/declare-scopes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAiD,MAAM,sBAAsB,CAAC;
|
|
1
|
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E,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,UAAU,EAAE;YACtF,UAAU,EAAE,MAAM,EAAE,CAAC,eAAe,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC;YACpE,IAAI,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;YACtF,aAAa,EAAE,MAAM,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;SAC9E,CACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,MAAM,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxD,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC1C,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IdGenerator } from '@aeolus-fleet/common';
|
|
2
|
+
import { type Caller } from '../shared/caller.js';
|
|
3
|
+
import type { Clock } from '../shared/clock.js';
|
|
4
|
+
import { type EventLog } from '../shared/events.js';
|
|
5
|
+
import { type Result } from '../shared/result.js';
|
|
6
|
+
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
7
|
+
import { type DefineScopeRefusal } from './defined-scope.js';
|
|
8
|
+
import type { DefinedScopeRepository, ScopeNamespaceRepository, ShipRepository } from './ports.js';
|
|
9
|
+
export interface DefineScopeTx {
|
|
10
|
+
ships: Pick<ShipRepository, 'find'>;
|
|
11
|
+
scopeNamespaces: Pick<ScopeNamespaceRepository, 'lockNamespace' | 'find'>;
|
|
12
|
+
definedScopes: Pick<DefinedScopeRepository, 'find' | 'save'>;
|
|
13
|
+
events: EventLog;
|
|
14
|
+
}
|
|
15
|
+
export type DefineScope = (caller: Caller, input: {
|
|
16
|
+
scope: string;
|
|
17
|
+
description: string;
|
|
18
|
+
}) => Promise<Result<{
|
|
19
|
+
scope: string;
|
|
20
|
+
description: string;
|
|
21
|
+
}, DefineScopeRefusal>>;
|
|
22
|
+
/**
|
|
23
|
+
* Use case: any actor defines a scope of the fleet's own (design
|
|
24
|
+
* gateway-scopes, 4.1). Its scope (scopes:define) is checked before this
|
|
25
|
+
* runs. In one unit of work, holding the scope's namespace, so a plugin
|
|
26
|
+
* declaring the same namespace waits and then finds it the fleet's: the
|
|
27
|
+
* scope and ScopeDefined.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createDefineScope(deps: {
|
|
30
|
+
uow: UnitOfWork<DefineScopeTx>;
|
|
31
|
+
clock: Clock;
|
|
32
|
+
ids: IdGenerator;
|
|
33
|
+
}): DefineScope;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { actorOf } from '../shared/caller.js';
|
|
2
|
+
import { recordEvent } from '../shared/events.js';
|
|
3
|
+
import { ok } from '../shared/result.js';
|
|
4
|
+
import { defineScope, namespaceOf } from './defined-scope.js';
|
|
5
|
+
/**
|
|
6
|
+
* Use case: any actor defines a scope of the fleet's own (design
|
|
7
|
+
* gateway-scopes, 4.1). Its scope (scopes:define) is checked before this
|
|
8
|
+
* runs. In one unit of work, holding the scope's namespace, so a plugin
|
|
9
|
+
* declaring the same namespace waits and then finds it the fleet's: the
|
|
10
|
+
* scope and ScopeDefined.
|
|
11
|
+
*/
|
|
12
|
+
export function createDefineScope(deps) {
|
|
13
|
+
return (caller, input) => deps.uow.run(async (tx) => {
|
|
14
|
+
const { fleetId } = caller;
|
|
15
|
+
const namespace = namespaceOf(input.scope);
|
|
16
|
+
await tx.scopeNamespaces.lockNamespace(fleetId, namespace);
|
|
17
|
+
const declared = await tx.scopeNamespaces.find(fleetId, namespace);
|
|
18
|
+
const declarer = declared && (await tx.ships.find(fleetId, declared.declaredBy));
|
|
19
|
+
const defined = defineScope({ fleetId, scope: input.scope, description: input.description, at: deps.clock.now(), actor: actorOf(caller) }, { declarerName: declared && (declarer?.name ?? declared.declaredBy), defined: await tx.definedScopes.find(fleetId, input.scope) });
|
|
20
|
+
if (!defined.isOk) {
|
|
21
|
+
return defined;
|
|
22
|
+
}
|
|
23
|
+
await tx.definedScopes.save(defined.value.defined);
|
|
24
|
+
for (const event of defined.value.events) {
|
|
25
|
+
await recordEvent({ events: tx.events, ids: deps.ids }, event);
|
|
26
|
+
}
|
|
27
|
+
return ok({ scope: defined.value.defined.scope, description: defined.value.defined.description });
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=define-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-scope.js","sourceRoot":"","sources":["../../../src/domain/registry/define-scope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAA2B,MAAM,oBAAoB,CAAC;AAYvF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAwE;IACxG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACvB,IAAI,CAAC,GAAG,CAAC,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,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACpG,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type FleetId, type ScopeName } from '@aeolus-fleet/common';
|
|
2
|
+
import { type DomainError } from '../shared/errors.js';
|
|
3
|
+
import type { Actor, NewEvent } from '../shared/events.js';
|
|
4
|
+
import { type Result } from '../shared/result.js';
|
|
5
|
+
/**
|
|
6
|
+
* One of the fleet's own scopes (design gateway-scopes, 4.1): named in the
|
|
7
|
+
* company's words, such as `crm:read-leads`, with a one-line description.
|
|
8
|
+
* Defined, described and removed by any actor holding scopes:define, and
|
|
9
|
+
* never retired with the one who defined it. Its namespace holds the fleet's
|
|
10
|
+
* scopes only, never a plugin's; the fleet has no cap on them.
|
|
11
|
+
*/
|
|
12
|
+
export interface DefinedScope {
|
|
13
|
+
fleetId: FleetId;
|
|
14
|
+
scope: ScopeName;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
export type DefineScopeRefusal = DomainError<'INVALID_SCOPE' | 'INVALID_SCOPE_DESCRIPTION' | 'CORE_NAMESPACE' | 'RESERVED_NAMESPACE' | 'NAMESPACE_TAKEN' | 'SCOPE_DEFINED'>;
|
|
18
|
+
/** The namespace of a scope: what comes before its colon, or the whole text when it has none. */
|
|
19
|
+
export declare function namespaceOf(scope: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* The fleet defines a scope of its own. Refused, each by name: a malformed
|
|
22
|
+
* scope or description, a core namespace, a namespace reserved for a plugin
|
|
23
|
+
* Aeolus knows, a namespace a plugin declared, and a scope the fleet has.
|
|
24
|
+
* Writes ScopeDefined.
|
|
25
|
+
*/
|
|
26
|
+
export declare function defineScope(input: {
|
|
27
|
+
fleetId: FleetId;
|
|
28
|
+
scope: string;
|
|
29
|
+
description: string;
|
|
30
|
+
at: Date;
|
|
31
|
+
actor: Actor;
|
|
32
|
+
}, fleet: {
|
|
33
|
+
/** The name of the ship that declared the scope's namespace as a plugin, if one did. */
|
|
34
|
+
declarerName: string | undefined;
|
|
35
|
+
/** The scope as the fleet has it, if it does. */
|
|
36
|
+
defined: DefinedScope | undefined;
|
|
37
|
+
}): Result<{
|
|
38
|
+
defined: DefinedScope;
|
|
39
|
+
events: NewEvent[];
|
|
40
|
+
}, DefineScopeRefusal>;
|
|
41
|
+
/**
|
|
42
|
+
* The fleet changes the description of one of its scopes; its name never
|
|
43
|
+
* changes, a new name is a new scope. Refused: a scope the fleet does not
|
|
44
|
+
* have and a malformed description. Writes ScopeDescribed when the
|
|
45
|
+
* description changes.
|
|
46
|
+
*/
|
|
47
|
+
export declare function describeScope(defined: DefinedScope | undefined, input: {
|
|
48
|
+
scope: string;
|
|
49
|
+
description: string;
|
|
50
|
+
at: Date;
|
|
51
|
+
actor: Actor;
|
|
52
|
+
}): Result<{
|
|
53
|
+
defined: DefinedScope;
|
|
54
|
+
events: NewEvent[];
|
|
55
|
+
}, DomainError<'SCOPE_NOT_DEFINED' | 'INVALID_SCOPE_DESCRIPTION'>>;
|
|
56
|
+
/**
|
|
57
|
+
* The fleet removes one of its scopes, refused while an active ship holds
|
|
58
|
+
* it (decision 0046), naming how many. Removing the last scope of a
|
|
59
|
+
* namespace frees it. Writes ScopeRemoved.
|
|
60
|
+
*/
|
|
61
|
+
export declare function removeScope(defined: DefinedScope | undefined, input: {
|
|
62
|
+
scope: string;
|
|
63
|
+
holders: number;
|
|
64
|
+
at: Date;
|
|
65
|
+
actor: Actor;
|
|
66
|
+
}): Result<{
|
|
67
|
+
events: NewEvent[];
|
|
68
|
+
}, DomainError<'SCOPE_NOT_DEFINED' | 'SCOPE_HELD'>>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isCoreNamespace, RESERVED_NAMESPACES, SCOPE_DESCRIPTION_MAX_LENGTH, SCOPE_NAME_PATTERN } from '@aeolus-fleet/common';
|
|
2
|
+
import { refuse } from '../shared/errors.js';
|
|
3
|
+
import { ok } from '../shared/result.js';
|
|
4
|
+
import { isScopeDescription } from './scope-namespace.js';
|
|
5
|
+
/** The namespace of a scope: what comes before its colon, or the whole text when it has none. */
|
|
6
|
+
export function namespaceOf(scope) {
|
|
7
|
+
const colon = scope.indexOf(':');
|
|
8
|
+
return colon === -1 ? scope : scope.slice(0, colon);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The fleet defines a scope of its own. Refused, each by name: a malformed
|
|
12
|
+
* scope or description, a core namespace, a namespace reserved for a plugin
|
|
13
|
+
* Aeolus knows, a namespace a plugin declared, and a scope the fleet has.
|
|
14
|
+
* Writes ScopeDefined.
|
|
15
|
+
*/
|
|
16
|
+
export function defineScope(input, fleet) {
|
|
17
|
+
const { fleetId, scope, description, at, actor } = input;
|
|
18
|
+
if (!SCOPE_NAME_PATTERN.test(scope)) {
|
|
19
|
+
return refuse('INVALID_SCOPE', `${scope} is no scope: <namespace>:<action>, each lowercase letters, digits and hyphens, starting with a letter, at most 32 characters`);
|
|
20
|
+
}
|
|
21
|
+
const namespace = namespaceOf(scope);
|
|
22
|
+
if (isCoreNamespace(namespace)) {
|
|
23
|
+
return refuse('CORE_NAMESPACE', `${namespace} is a core namespace: core alone defines its scopes`);
|
|
24
|
+
}
|
|
25
|
+
if (RESERVED_NAMESPACES.some((reserved) => reserved === namespace)) {
|
|
26
|
+
return refuse('RESERVED_NAMESPACE', `${namespace} is reserved for a plugin Aeolus knows: pick another namespace`);
|
|
27
|
+
}
|
|
28
|
+
if (!isScopeDescription(description)) {
|
|
29
|
+
return refuse('INVALID_SCOPE_DESCRIPTION', `The description of ${scope} is one line of 1 to ${String(SCOPE_DESCRIPTION_MAX_LENGTH)} characters`);
|
|
30
|
+
}
|
|
31
|
+
if (fleet.declarerName !== undefined) {
|
|
32
|
+
return refuse('NAMESPACE_TAKEN', `The namespace ${namespace} is taken, by ${fleet.declarerName}`);
|
|
33
|
+
}
|
|
34
|
+
if (fleet.defined !== undefined) {
|
|
35
|
+
return refuse('SCOPE_DEFINED', `The fleet has ${scope} already: change its description instead`);
|
|
36
|
+
}
|
|
37
|
+
return ok({
|
|
38
|
+
defined: { fleetId, scope, description },
|
|
39
|
+
events: [{ fleetId, type: 'ScopeDefined', occurredAt: at, actor, details: { scope, description } }],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The fleet changes the description of one of its scopes; its name never
|
|
44
|
+
* changes, a new name is a new scope. Refused: a scope the fleet does not
|
|
45
|
+
* have and a malformed description. Writes ScopeDescribed when the
|
|
46
|
+
* description changes.
|
|
47
|
+
*/
|
|
48
|
+
export function describeScope(defined, input) {
|
|
49
|
+
const { scope, description, at, actor } = input;
|
|
50
|
+
if (defined === undefined) {
|
|
51
|
+
return notDefined(scope);
|
|
52
|
+
}
|
|
53
|
+
if (!isScopeDescription(description)) {
|
|
54
|
+
return refuse('INVALID_SCOPE_DESCRIPTION', `The description of ${scope} is one line of 1 to ${String(SCOPE_DESCRIPTION_MAX_LENGTH)} characters`);
|
|
55
|
+
}
|
|
56
|
+
if (description === defined.description) {
|
|
57
|
+
return ok({ defined, events: [] });
|
|
58
|
+
}
|
|
59
|
+
return ok({
|
|
60
|
+
defined: { ...defined, description },
|
|
61
|
+
events: [{ fleetId: defined.fleetId, type: 'ScopeDescribed', occurredAt: at, actor, details: { scope, description } }],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The fleet removes one of its scopes, refused while an active ship holds
|
|
66
|
+
* it (decision 0046), naming how many. Removing the last scope of a
|
|
67
|
+
* namespace frees it. Writes ScopeRemoved.
|
|
68
|
+
*/
|
|
69
|
+
export function removeScope(defined, input) {
|
|
70
|
+
const { scope, holders, at, actor } = input;
|
|
71
|
+
if (defined === undefined) {
|
|
72
|
+
return notDefined(scope);
|
|
73
|
+
}
|
|
74
|
+
if (holders > 0) {
|
|
75
|
+
const who = holders === 1 ? '1 ship holds' : `${String(holders)} ships hold`;
|
|
76
|
+
return refuse('SCOPE_HELD', `${who} ${scope}: revoke it from ${holders === 1 ? 'it' : 'them'} first`);
|
|
77
|
+
}
|
|
78
|
+
return ok({ events: [{ fleetId: defined.fleetId, type: 'ScopeRemoved', occurredAt: at, actor, details: { scope } }] });
|
|
79
|
+
}
|
|
80
|
+
function notDefined(scope) {
|
|
81
|
+
return refuse('SCOPE_NOT_DEFINED', `The fleet has no scope ${scope}`);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=defined-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defined-scope.js","sourceRoot":"","sources":["../../../src/domain/registry/defined-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,kBAAkB,EAAgC,MAAM,sBAAsB,CAAC;AAE5J,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,EAAE,EAAyB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAiB1D,iGAAiG;AACjG,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,KAAuF,EACvF,KAKC;IAED,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EA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K,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC;QAC7E,OAAO,MAAM,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,KAAK,oBAAoB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AACzH,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,KAAK,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IdGenerator } from '@aeolus-fleet/common';
|
|
2
|
+
import { type Caller } from '../shared/caller.js';
|
|
3
|
+
import type { Clock } from '../shared/clock.js';
|
|
4
|
+
import type { DomainError } from '../shared/errors.js';
|
|
5
|
+
import { type EventLog } from '../shared/events.js';
|
|
6
|
+
import { type Result } from '../shared/result.js';
|
|
7
|
+
import type { UnitOfWork } from '../shared/unit-of-work.js';
|
|
8
|
+
import type { DefinedScopeRepository, ScopeNamespaceRepository } from './ports.js';
|
|
9
|
+
export interface DescribeScopeTx {
|
|
10
|
+
scopeNamespaces: Pick<ScopeNamespaceRepository, 'lockNamespace'>;
|
|
11
|
+
definedScopes: Pick<DefinedScopeRepository, 'find' | 'save'>;
|
|
12
|
+
events: EventLog;
|
|
13
|
+
}
|
|
14
|
+
export type DescribeScope = (caller: Caller, input: {
|
|
15
|
+
scope: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}) => Promise<Result<{
|
|
18
|
+
scope: string;
|
|
19
|
+
description: string;
|
|
20
|
+
}, DomainError<'SCOPE_NOT_DEFINED' | 'INVALID_SCOPE_DESCRIPTION'>>>;
|
|
21
|
+
/**
|
|
22
|
+
* Use case: any actor changes the description of one of the fleet's scopes
|
|
23
|
+
* (design gateway-scopes, 4.1). Its scope (scopes:define) is checked before
|
|
24
|
+
* this runs. In one unit of work, holding the scope's namespace, so a removal
|
|
25
|
+
* never finds it described back: the description and ScopeDescribed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createDescribeScope(deps: {
|
|
28
|
+
uow: UnitOfWork<DescribeScopeTx>;
|
|
29
|
+
clock: Clock;
|
|
30
|
+
ids: IdGenerator;
|
|
31
|
+
}): DescribeScope;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { actorOf } from '../shared/caller.js';
|
|
2
|
+
import { recordEvent } from '../shared/events.js';
|
|
3
|
+
import { ok } from '../shared/result.js';
|
|
4
|
+
import { describeScope, namespaceOf } from './defined-scope.js';
|
|
5
|
+
/**
|
|
6
|
+
* Use case: any actor changes the description of one of the fleet's scopes
|
|
7
|
+
* (design gateway-scopes, 4.1). Its scope (scopes:define) is checked before
|
|
8
|
+
* this runs. In one unit of work, holding the scope's namespace, so a removal
|
|
9
|
+
* never finds it described back: the description and ScopeDescribed.
|
|
10
|
+
*/
|
|
11
|
+
export function createDescribeScope(deps) {
|
|
12
|
+
return (caller, input) => deps.uow.run(async (tx) => {
|
|
13
|
+
const { fleetId } = caller;
|
|
14
|
+
await tx.scopeNamespaces.lockNamespace(fleetId, namespaceOf(input.scope));
|
|
15
|
+
const described = describeScope(await tx.definedScopes.find(fleetId, input.scope), { ...input, at: deps.clock.now(), actor: actorOf(caller) });
|
|
16
|
+
if (!described.isOk) {
|
|
17
|
+
return described;
|
|
18
|
+
}
|
|
19
|
+
if (described.value.events.length > 0) {
|
|
20
|
+
await tx.definedScopes.save(described.value.defined);
|
|
21
|
+
}
|
|
22
|
+
for (const event of described.value.events) {
|
|
23
|
+
await recordEvent({ events: tx.events, ids: deps.ids }, event);
|
|
24
|
+
}
|
|
25
|
+
return ok({ scope: described.value.defined.scope, description: described.value.defined.description });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=describe-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-scope.js","sourceRoot":"","sources":["../../../src/domain/registry/describe-scope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAchE;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA0E;IAC5G,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACvB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAA2H,EAAE;QACjJ,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAC3B,MAAM,EAAE,CAAC,eAAe,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/I,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACpB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3C,MAAM,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -11,7 +11,7 @@ export interface GetFleetLimitsTx {
|
|
|
11
11
|
export type GetFleetLimits = (input: {
|
|
12
12
|
fleetId: FleetId;
|
|
13
13
|
}) => Promise<Result<FleetLimits, DomainError<'FLEET_NOT_FOUND'>>>;
|
|
14
|
-
/** Use case: a fleet's ship and daily message limits, how each is set and the limit that
|
|
14
|
+
/** Use case: a fleet's ship and daily message limits and its retention, how each is set and the limit or days that apply. */
|
|
15
15
|
export declare function createGetFleetLimits(deps: {
|
|
16
16
|
uow: UnitOfWork<GetFleetLimitsTx>;
|
|
17
17
|
}): GetFleetLimits;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { refuse } from '../shared/errors.js';
|
|
2
2
|
import { ok } from '../shared/result.js';
|
|
3
3
|
import { fleetLimitsOf } from './limits.js';
|
|
4
|
-
/** Use case: a fleet's ship and daily message limits, how each is set and the limit that
|
|
4
|
+
/** Use case: a fleet's ship and daily message limits and its retention, how each is set and the limit or days that apply. */
|
|
5
5
|
export function createGetFleetLimits(deps) {
|
|
6
6
|
return ({ fleetId }) => deps.uow.run(async (tx) => {
|
|
7
7
|
const settings = await tx.fleets.limitSettings(fleetId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-fleet-limits.js","sourceRoot":"","sources":["../../../src/domain/registry/get-fleet-limits.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAU9D,
|
|
1
|
+
{"version":3,"file":"get-fleet-limits.js","sourceRoot":"","sources":["../../../src/domain/registry/get-fleet-limits.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAU9D,6HAA6H;AAC7H,MAAM,UAAU,oBAAoB,CAAC,IAA2C;IAC9E,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CACrB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAgE,EAAE;QACtF,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,MAAM,CAAC,iBAAiB,EAAE,mCAAmC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACtG,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -6,11 +6,12 @@ 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 CheckManageTx, type NotReachable } from './check-reach.js';
|
|
9
|
-
import type { ScopeNamespaceRepository, ShipRepository } from './ports.js';
|
|
9
|
+
import type { DefinedScopeRepository, ScopeNamespaceRepository, ShipRepository } from './ports.js';
|
|
10
10
|
import { type GrantScopesRefusal } from './scope-grant.js';
|
|
11
11
|
export interface GrantScopesTx extends Omit<CheckManageTx, 'ships'> {
|
|
12
12
|
ships: Pick<ShipRepository, 'find' | 'findForUpdate' | 'setScopes'>;
|
|
13
13
|
scopeNamespaces: Pick<ScopeNamespaceRepository, 'lockNamespace' | 'find'>;
|
|
14
|
+
definedScopes: Pick<DefinedScopeRepository, 'find'>;
|
|
14
15
|
events: EventLog;
|
|
15
16
|
}
|
|
16
17
|
export type GrantScopes = (caller: Caller, input: {
|
|
@@ -26,8 +27,8 @@ export type GrantScopesUseCaseRefusal = GrantScopesRefusal | NotReachable | Doma
|
|
|
26
27
|
* within its manage reach (decisions 0046, 0053), within what it may grant,
|
|
27
28
|
* read from the server or its checked token. A refused reach keeps its record.
|
|
28
29
|
* Its scope (scopes:grant) is checked before this runs. In one unit of work,
|
|
29
|
-
* holding the ship, then each
|
|
30
|
-
*
|
|
30
|
+
* holding the ship, then each namespace the scopes name, so a declaration
|
|
31
|
+
* that removes a scope, or a removal of one of the fleet's own, waits: the ship's scopes and
|
|
31
32
|
* ScopesChanged. The ship's crew holds them from its next call.
|
|
32
33
|
*/
|
|
33
34
|
export declare function createGrantScopes(deps: {
|
|
@@ -10,8 +10,8 @@ import { lockNamedNamespaces } from './named-namespaces.js';
|
|
|
10
10
|
* within its manage reach (decisions 0046, 0053), within what it may grant,
|
|
11
11
|
* read from the server or its checked token. A refused reach keeps its record.
|
|
12
12
|
* Its scope (scopes:grant) is checked before this runs. In one unit of work,
|
|
13
|
-
* holding the ship, then each
|
|
14
|
-
*
|
|
13
|
+
* holding the ship, then each namespace the scopes name, so a declaration
|
|
14
|
+
* that removes a scope, or a removal of one of the fleet's own, waits: the ship's scopes and
|
|
15
15
|
* ScopesChanged. The ship's crew holds them from its next call.
|
|
16
16
|
*/
|
|
17
17
|
export function createGrantScopes(deps) {
|
|
@@ -26,9 +26,9 @@ export function createGrantScopes(deps) {
|
|
|
26
26
|
if (!managed.isOk) {
|
|
27
27
|
return managed;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const named = await lockNamedNamespaces(tx, { fleetId, scopes: [...input.grant, ...input.revoke] });
|
|
30
30
|
const granter = { shipId: isShipCaller(caller) ? caller.shipId : null, isOperator: caller.kind === 'operator', scopes: caller.scopes };
|
|
31
|
-
const granted = grantScopes({ ship, granter, grant: input.grant, revoke: input.revoke, at, actor: actorOf(caller) },
|
|
31
|
+
const granted = grantScopes({ ship, granter, grant: input.grant, revoke: input.revoke, at, actor: actorOf(caller) }, named);
|
|
32
32
|
if (!granted.isOk) {
|
|
33
33
|
return granted;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant-scopes.js","sourceRoot":"","sources":["../../../src/domain/registry/grant-scopes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAe,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAoB,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAiB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAe,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAyC,MAAM,kBAAkB,CAAC;AAE3G,OAAO,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"grant-scopes.js","sourceRoot":"","sources":["../../../src/domain/registry/grant-scopes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAe,MAAM,qBAAqB,CA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,6 +1,6 @@
|
|
|
1
1
|
import type { FleetId } from '@aeolus-fleet/common';
|
|
2
2
|
import type { Health } from '../shared/health.js';
|
|
3
|
-
import { type FleetLimit, type InstallationSettings } from './limits.js';
|
|
3
|
+
import { type FleetLimit, type FleetRetention, type InstallationSettings } from './limits.js';
|
|
4
4
|
import type { FleetHealth, InstallationFleetFacts, InstallationFleetWindow } from './ports.js';
|
|
5
5
|
/** How far back an installation's fleet counts its messages, and over how many UTC days. */
|
|
6
6
|
export declare const MESSAGE_WINDOW_DAYS = 7;
|
|
@@ -27,6 +27,9 @@ export interface InstallationFleet {
|
|
|
27
27
|
limits: {
|
|
28
28
|
ships: FleetLimit;
|
|
29
29
|
dailyMessages: FleetLimit;
|
|
30
|
+
schedulesPerShip: FleetLimit;
|
|
31
|
+
minimumScheduleInterval: FleetLimit;
|
|
32
|
+
retention: FleetRetention;
|
|
30
33
|
};
|
|
31
34
|
/** Its 0041 figures, and where its deliveries are stuck (decision 0042). */
|
|
32
35
|
health: FleetHealth & Health;
|
|
@@ -16,7 +16,14 @@ export function messageWindow(now) {
|
|
|
16
16
|
export function installationFleet(facts, read) {
|
|
17
17
|
const { messagesSince, messagesPerUtcDay, limitSettings, health, ...rest } = facts;
|
|
18
18
|
const messagesPerDay = utcDays(read.now).map((date) => ({ date, count: messagesPerUtcDay.find((day) => day.date === date)?.count ?? 0 }));
|
|
19
|
-
const { ships, dailyMessages } = fleetLimitsOf({ fleetId: facts.fleetId, settings: limitSettings, installation: read.installation });
|
|
20
|
-
return {
|
|
19
|
+
const { ships, dailyMessages, schedulesPerShip, minimumScheduleInterval, retention } = fleetLimitsOf({ fleetId: facts.fleetId, settings: limitSettings, installation: read.installation });
|
|
20
|
+
return {
|
|
21
|
+
...rest,
|
|
22
|
+
health: { ...health, ...read.health },
|
|
23
|
+
messagesLast7Days: messagesSince,
|
|
24
|
+
messagesToday: messagesPerDay.at(-1)?.count ?? 0,
|
|
25
|
+
messagesPerDay,
|
|
26
|
+
limits: { ships, dailyMessages, schedulesPerShip, minimumScheduleInterval, retention },
|
|
27
|
+
};
|
|
21
28
|
}
|
|
22
29
|
//# sourceMappingURL=installation-fleet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation-fleet.js","sourceRoot":"","sources":["../../../src/domain/registry/installation-fleet.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"installation-fleet.js","sourceRoot":"","sources":["../../../src/domain/registry/installation-fleet.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAmE,MAAM,aAAa,CAAC;AAG7G,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAuB9D,gGAAgG;AAChG,SAAS,OAAO,CAAC,GAAS;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAClF,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,mBAAmB,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAClK,CAAC;AAED,uHAAuH;AACvH,MAAM,UAAU,aAAa,CAAC,GAAS;IACrC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG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@
|
|
|
1
|
+
import type { FleetId, LabelValueId } from '@aeolus-fleet/common';
|
|
2
|
+
import type { HistoryLabelValue } from '../shared/history.js';
|
|
3
|
+
import type { LabelRepository } from './ports.js';
|
|
4
|
+
/** The ports naming label values reads, inside the caller's unit of work. */
|
|
5
|
+
export interface LabelValueTextsTx {
|
|
6
|
+
labels: Pick<LabelRepository, 'listNamedBy'>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Each of these label values by its key and value texts, in the order given,
|
|
10
|
+
* each once, read in one query (decision 0065, R10). A value its label no
|
|
11
|
+
* longer has keeps its id, its texts null.
|
|
12
|
+
*/
|
|
13
|
+
export declare function labelValueTexts(tx: LabelValueTextsTx, input: {
|
|
14
|
+
fleetId: FleetId;
|
|
15
|
+
valueIds: readonly LabelValueId[];
|
|
16
|
+
}): Promise<HistoryLabelValue[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Each of these label values by its key and value texts, in the order given,
|
|
3
|
+
* each once, read in one query (decision 0065, R10). A value its label no
|
|
4
|
+
* longer has keeps its id, its texts null.
|
|
5
|
+
*/
|
|
6
|
+
export async function labelValueTexts(tx, input) {
|
|
7
|
+
const valueIds = [...new Set(input.valueIds)];
|
|
8
|
+
if (valueIds.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const labels = await tx.labels.listNamedBy(input.fleetId, { labelIds: [], valueIds });
|
|
12
|
+
const texts = new Map(labels.flatMap((label) => label.values.map((value) => [value.id, { key: label.key, value: value.value }])));
|
|
13
|
+
return valueIds.map((valueId) => ({ valueId, key: null, value: null, ...texts.get(valueId) }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=label-value-texts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label-value-texts.js","sourceRoot":"","sources":["../../../src/domain/registry/label-value-texts.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EAAqB,EAAE,KAA8D;IACzH,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAU,CAAC,CAAC,CAAC,CAAC;IAC3I,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -2,17 +2,24 @@ import type { FleetId } from '@aeolus-fleet/common';
|
|
|
2
2
|
import { type DomainError } from '../shared/errors.js';
|
|
3
3
|
import { type Result } from '../shared/result.js';
|
|
4
4
|
/**
|
|
5
|
-
* The installation's settings (docs/blueprint.md, "Installation"): the ship
|
|
6
|
-
*
|
|
7
|
-
* the number of fleets. Null is no limit
|
|
8
|
-
*
|
|
5
|
+
* The installation's settings (docs/blueprint.md, "Installation"): the ship,
|
|
6
|
+
* daily message and schedule limits and the retention a fleet follows unless
|
|
7
|
+
* set for it, and the cap on the number of fleets. Null is no limit, and for
|
|
8
|
+
* the retention kept for good. Aeolus sets none of its own: these are
|
|
9
|
+
* whoever runs the installation's (decisions 0016, 0066).
|
|
9
10
|
*/
|
|
10
11
|
export interface InstallationSettings {
|
|
11
12
|
defaultShipLimit: number | null;
|
|
12
13
|
defaultDailyMessageLimit: number | null;
|
|
14
|
+
/** The schedules a ship may hold active or paused (decision 0062, S12). */
|
|
15
|
+
defaultSchedulesPerShipLimit: number | null;
|
|
16
|
+
/** The shortest time between two send times of a repeating schedule, in seconds (decision 0062, S12). */
|
|
17
|
+
defaultMinimumScheduleInterval: number | null;
|
|
18
|
+
/** The days a fleet keeps its finished history (decision 0066). */
|
|
19
|
+
defaultRetentionDays: number | null;
|
|
13
20
|
fleetCap: number | null;
|
|
14
21
|
}
|
|
15
|
-
/** An installation that has set nothing: no limit anywhere, as a self-hosted server runs. */
|
|
22
|
+
/** An installation that has set nothing: no limit anywhere and everything kept, as a self-hosted server runs. */
|
|
16
23
|
export declare const NO_INSTALLATION_SETTINGS: InstallationSettings;
|
|
17
24
|
/** How one of a fleet's limits is set: it follows the installation default, or is set for the fleet to a number or to no limit. */
|
|
18
25
|
export type FleetLimitSetting = {
|
|
@@ -21,25 +28,53 @@ export type FleetLimitSetting = {
|
|
|
21
28
|
kind: 'fleet';
|
|
22
29
|
limit: number | null;
|
|
23
30
|
};
|
|
24
|
-
/** How a fleet's
|
|
31
|
+
/** How a fleet's retention is set: it follows the installation default, or is set for the fleet to a number of days or to none (kept for good). */
|
|
32
|
+
export type RetentionSetting = {
|
|
33
|
+
kind: 'default';
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'fleet';
|
|
36
|
+
days: number | null;
|
|
37
|
+
};
|
|
38
|
+
/** How a fleet's limits and its retention are set. */
|
|
25
39
|
export interface FleetLimitSettings {
|
|
26
40
|
ships: FleetLimitSetting;
|
|
27
41
|
dailyMessages: FleetLimitSetting;
|
|
42
|
+
schedulesPerShip: FleetLimitSetting;
|
|
43
|
+
minimumScheduleInterval: FleetLimitSetting;
|
|
44
|
+
retention: RetentionSetting;
|
|
28
45
|
}
|
|
29
|
-
/** A fleet that has set nothing for itself:
|
|
46
|
+
/** A fleet that has set nothing for itself: every limit and the retention follow the installation default. */
|
|
30
47
|
export declare const FOLLOWING_DEFAULTS: FleetLimitSettings;
|
|
31
48
|
/** One of a fleet's limits: how it is set, and the limit that applies (null: none). */
|
|
32
49
|
export interface FleetLimit {
|
|
33
50
|
setting: FleetLimitSetting;
|
|
34
51
|
applies: number | null;
|
|
35
52
|
}
|
|
53
|
+
/** A fleet's retention: how it is set, and the days that apply (null: kept for good). */
|
|
54
|
+
export interface FleetRetention {
|
|
55
|
+
setting: RetentionSetting;
|
|
56
|
+
applies: number | null;
|
|
57
|
+
}
|
|
36
58
|
export interface FleetLimits {
|
|
37
59
|
fleetId: FleetId;
|
|
38
60
|
ships: FleetLimit;
|
|
39
61
|
dailyMessages: FleetLimit;
|
|
62
|
+
schedulesPerShip: FleetLimit;
|
|
63
|
+
minimumScheduleInterval: FleetLimit;
|
|
64
|
+
retention: FleetRetention;
|
|
40
65
|
}
|
|
66
|
+
/** The limit that applies to the fleet now for each of its limits, and the retention in days; null where none applies. */
|
|
67
|
+
export type AppliedLimits = {
|
|
68
|
+
[Name in keyof FleetLimitSettings]: number | null;
|
|
69
|
+
};
|
|
70
|
+
/** The limits a fleet applies from how it set them and the installation's defaults. */
|
|
71
|
+
export declare function appliedLimitsOf(settings: FleetLimitSettings, installation: InstallationSettings): AppliedLimits;
|
|
41
72
|
/** A limit as configured: a whole number of at least 0, or null for no limit. */
|
|
42
73
|
export declare function limit(raw: number | null): Result<number | null, DomainError<'INVALID_LIMIT'>>;
|
|
74
|
+
/** A retention as configured: a whole number of days of at least 1, or null for kept for good; no other minimum or maximum (decision 0066). */
|
|
75
|
+
export declare function retentionDays(raw: number | null): Result<number | null, DomainError<'INVALID_RETENTION'>>;
|
|
76
|
+
/** The days a retention setting gives: its own when set for the fleet, else the installation default. */
|
|
77
|
+
export declare function appliedRetention(setting: RetentionSetting, defaultDays: number | null): number | null;
|
|
43
78
|
/** The limit a setting gives: its own when set for the fleet, else the installation default. */
|
|
44
79
|
export declare function appliedLimit(setting: FleetLimitSetting, defaultLimit: number | null): number | null;
|
|
45
80
|
/** A fleet's limits from how it set them and the installation's defaults. */
|