@camstack/system 1.2.444 → 1.2.446
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon-runner.js +40 -31
- package/dist/addon-runner.mjs +41 -32
- package/dist/{agent-https-DlpTMDqA.js → agent-https-5DYAOJMO.js} +810 -12
- package/dist/{agent-https-U0d4uvn2.mjs → agent-https-BWUEf6ev.mjs} +697 -13
- package/dist/auth/admin-token-manager.d.ts +9 -3
- package/dist/auth/api-key-manager.d.ts +9 -3
- package/dist/auth/auth-audit-log.d.ts +9 -3
- package/dist/auth/device-credential-manager.d.ts +5 -1
- package/dist/auth/external-identity-manager.d.ts +8 -21
- package/dist/auth/login-session-manager.d.ts +11 -3
- package/dist/auth/scoped-token-manager.d.ts +8 -52
- package/dist/auth/totp-manager.d.ts +11 -3
- package/dist/auth/user-manager.d.ts +10 -17
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alert-store.d.ts +32 -0
- package/dist/builtins/alerts/alerts.addon.d.ts +9 -2
- package/dist/builtins/alerts/alerts.addon.js +373 -154
- package/dist/builtins/alerts/alerts.addon.mjs +372 -154
- package/dist/builtins/alerts/critical-push.d.ts +4 -0
- package/dist/builtins/alerts/emit-alert-policy.d.ts +28 -0
- package/dist/builtins/alerts/record-kinds.d.ts +15 -0
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +1 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +134 -193
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +134 -193
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/record-kinds.d.ts +58 -0
- package/dist/builtins/backup-orchestrator/schedule-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +4 -2
- package/dist/builtins/calendars/calendar-prefs-store.d.ts +13 -5
- package/dist/builtins/calendars/calendars.addon.d.ts +2 -2
- package/dist/builtins/calendars/calendars.addon.js +67 -64
- package/dist/builtins/calendars/calendars.addon.mjs +59 -64
- package/dist/builtins/calendars/record-kinds.d.ts +18 -0
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/cluster-agent/record-kinds.d.ts +36 -0
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/block-settings-store.d.ts +8 -4
- package/dist/builtins/core-blocks/core-block-store.d.ts +8 -16
- package/dist/builtins/core-blocks/core-blocks.addon.js +85 -112
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +86 -113
- package/dist/builtins/core-blocks/index.mjs +1 -1
- package/dist/builtins/core-blocks/record-kinds.d.ts +26 -0
- package/dist/builtins/device-manager/device-manager.addon.js +111 -187
- package/dist/builtins/device-manager/device-manager.addon.mjs +110 -187
- package/dist/builtins/device-manager/device-tombstone-store.d.ts +9 -48
- package/dist/builtins/device-manager/record-kinds.d.ts +14 -0
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +152 -22
- package/dist/builtins/keychain/index.mjs +152 -22
- package/dist/builtins/keychain/keychain-service.d.ts +3 -2
- package/dist/builtins/keychain/keychain-store.d.ts +13 -2
- package/dist/builtins/keychain/record-kinds.d.ts +16 -0
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/auth-schema.d.ts +3 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2903 -2123
- package/dist/builtins/local-auth/local-auth.addon.mjs +2904 -2124
- package/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -48
- package/dist/builtins/local-auth/record-kinds.d.ts +141 -0
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/record-entries/index.js +1 -1
- package/dist/builtins/record-entries/index.mjs +1 -1
- package/dist/builtins/records/legacy-table-row-count.d.ts +5 -0
- package/dist/builtins/records/phase6-declare-gate.d.ts +28 -0
- package/dist/builtins/records-isolated.d.ts +10 -0
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +30 -0
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +10 -16
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +6 -0
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +4 -0
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +5 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +17 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +111 -3
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +111 -3
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +9 -1
- package/dist/builtins/storage-orchestrator/drain-state-store.d.ts +5 -2
- package/dist/builtins/storage-orchestrator/location-store.d.ts +7 -2
- package/dist/builtins/storage-orchestrator/record-kinds.d.ts +38 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +196 -5
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +195 -6
- package/dist/builtins/system-config/record-kinds.d.ts +32 -0
- package/dist/builtins/system-config/system-config.addon.js +53 -618
- package/dist/builtins/system-config/system-config.addon.mjs +29 -577
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-C3rKncIF.mjs → composition-sources-BmC5jAUv.mjs} +1 -1
- package/dist/{composition-sources-NAPZddic.js → composition-sources-BwIIltnZ.js} +1 -1
- package/dist/{constants-BKX2QnIg.mjs → constants-6XHGmEUF.mjs} +1 -1
- package/dist/{constants-BXiNEIeV.js → constants-DA_tjzIk.js} +1 -1
- package/dist/{device-ca-jxjSL8Ov.mjs → device-ca-Bh_ClxMO.mjs} +1 -1
- package/dist/{device-ca-DT9X2S6d.js → device-ca-CnbrgfmW.js} +1 -1
- package/dist/{dist-D1vECb_6.js → dist-BkNfEJKa.js} +521 -64
- package/dist/{dist-DERK-gP5.mjs → dist-CkZIrsAP.mjs} +462 -65
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-CRaC97V0.mjs → hub-mdns-ciao-CoyIUWHC.mjs} +2 -2
- package/dist/{hub-mdns-ciao-Cah9GCIg.js → hub-mdns-ciao-m5LIr4oA.js} +2 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3095 -2821
- package/dist/index.mjs +3067 -2810
- package/dist/kernel/index.d.ts +2 -0
- package/dist/kernel/moleculer/event-bus.d.ts +3 -1
- package/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +5 -1
- package/dist/kernel/moleculer/remote-logger.d.ts +2 -2
- package/dist/kernel/transport/cap-route-resolver.d.ts +9 -38
- package/dist/phase6-declare-gate-BDWZuB2n.mjs +93 -0
- package/dist/phase6-declare-gate-Bl7KocEs.js +98 -0
- package/dist/read-all-rows-CVoO1ONM.js +29 -0
- package/dist/read-all-rows-TaPqdWNF.mjs +25 -0
- package/dist/records/read-all-rows.d.ts +6 -0
- package/dist/{restore-archive-Dy-qKTdF.js → restore-archive-B57xI5Ue.js} +353 -5
- package/dist/{restore-archive-daKyE24F.mjs → restore-archive-CMr4V7Fi.mjs} +339 -9
- package/dist/tls/agent-https-names.d.ts +9 -13
- package/dist/{wal-maintenance-zRc24mOC.mjs → wal-maintenance-Bqm4zrNA.mjs} +0 -0
- package/dist/{wal-maintenance-dAv4IdzC.js → wal-maintenance-CuG1DUca.js} +0 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Hi as nodePin, Rr as BaseAddon, Tn as mayWriteToLocation, ia as toNodeId, la as EventCategory, mt as backupCapability, ur as storageOccupancyCapability } from "../../dist-CkZIrsAP.mjs";
|
|
2
|
+
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
|
+
import { _ as parseBackupSecretKey, a as BackupSnapshotRefusedError, c as backupOrchestratorRecordKinds, d as BackupEncryptionKeyStore, g as generateBackupKeyPair, h as ENCRYPTED_BACKUP_SUFFIX, i as BackupCancelledError, l as backupRecordStoresOf, n as precheckRestoreKey, o as DEFAULT_BACKUP_DATABASES, p as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, u as BackupSeedMarkerStore } from "../../restore-archive-CMr4V7Fi.mjs";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import * as fsp from "node:fs/promises";
|
|
5
6
|
import * as path$1 from "node:path";
|
|
@@ -76,66 +77,6 @@ async function seedWeeklySchedule(store, markers) {
|
|
|
76
77
|
return seed;
|
|
77
78
|
}
|
|
78
79
|
//#endregion
|
|
79
|
-
//#region src/builtins/backup-orchestrator/seed-marker-store.ts
|
|
80
|
-
/**
|
|
81
|
-
* @durable class=config owner=backup-orchestrator
|
|
82
|
-
* write="the orchestrator inserts one row per seed id the first time that
|
|
83
|
-
* seed is created (or found already created); never updated"
|
|
84
|
-
* retention="none — one tiny row per seed ever made; deleting it lets the
|
|
85
|
-
* seed be re-created once more on the next boot"
|
|
86
|
-
*/
|
|
87
|
-
var BACKUP_SEED_MARKERS_COLLECTION = "backup_seed_markers";
|
|
88
|
-
var COLUMNS$1 = [{
|
|
89
|
-
name: "seed_id",
|
|
90
|
-
type: "TEXT",
|
|
91
|
-
primaryKey: true
|
|
92
|
-
}, {
|
|
93
|
-
name: "seeded_at",
|
|
94
|
-
type: "INTEGER",
|
|
95
|
-
notNull: true
|
|
96
|
-
}];
|
|
97
|
-
var BackupSeedMarkerStore = class {
|
|
98
|
-
store;
|
|
99
|
-
now;
|
|
100
|
-
declared = false;
|
|
101
|
-
constructor(store, now = Date.now) {
|
|
102
|
-
this.store = store;
|
|
103
|
-
this.now = now;
|
|
104
|
-
}
|
|
105
|
-
async ensureDeclared() {
|
|
106
|
-
if (this.declared) return;
|
|
107
|
-
await this.store.declareCollection({
|
|
108
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
109
|
-
columns: COLUMNS$1
|
|
110
|
-
});
|
|
111
|
-
this.declared = true;
|
|
112
|
-
}
|
|
113
|
-
async has(seedId) {
|
|
114
|
-
await this.ensureDeclared();
|
|
115
|
-
return (await this.store.query({
|
|
116
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
117
|
-
filter: {
|
|
118
|
-
where: { seed_id: seedId },
|
|
119
|
-
limit: 1
|
|
120
|
-
}
|
|
121
|
-
})).length > 0;
|
|
122
|
-
}
|
|
123
|
-
async mark(seedId) {
|
|
124
|
-
await this.ensureDeclared();
|
|
125
|
-
if (await this.has(seedId)) return;
|
|
126
|
-
await this.store.insert({
|
|
127
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
128
|
-
record: {
|
|
129
|
-
id: seedId,
|
|
130
|
-
data: {
|
|
131
|
-
seed_id: seedId,
|
|
132
|
-
seeded_at: this.now()
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
//#endregion
|
|
139
80
|
//#region ../../node_modules/croner/dist/croner.js
|
|
140
81
|
function T(s) {
|
|
141
82
|
return Date.UTC(s.y, s.m - 1, s.d, s.h, s.i, s.s);
|
|
@@ -930,6 +871,7 @@ function previewNextRuns(cron, count, after) {
|
|
|
930
871
|
}
|
|
931
872
|
//#endregion
|
|
932
873
|
//#region src/builtins/backup-orchestrator/destination-policy.ts
|
|
874
|
+
var import_read_all_rows = require_read_all_rows();
|
|
933
875
|
/**
|
|
934
876
|
* @durable class=config owner=backup-orchestrator
|
|
935
877
|
* write="`ensureDefault` auto-creates one row the first time a `backups` storage
|
|
@@ -984,8 +926,10 @@ var BACKUP_DESTINATION_POLICIES_COLUMNS = [
|
|
|
984
926
|
var BackupDestinationPolicyService = class {
|
|
985
927
|
store;
|
|
986
928
|
declared = false;
|
|
987
|
-
|
|
929
|
+
policiesKind;
|
|
930
|
+
constructor(store, policiesKind = null) {
|
|
988
931
|
this.store = store;
|
|
932
|
+
this.policiesKind = policiesKind;
|
|
989
933
|
}
|
|
990
934
|
/**
|
|
991
935
|
* Lazy `declareCollection` — called from every read/write path.
|
|
@@ -997,6 +941,7 @@ var BackupDestinationPolicyService = class {
|
|
|
997
941
|
await this.ensureDeclared();
|
|
998
942
|
}
|
|
999
943
|
async ensureDeclared() {
|
|
944
|
+
if (this.policiesKind !== null) return;
|
|
1000
945
|
if (this.declared) return;
|
|
1001
946
|
await this.store.declareCollection({
|
|
1002
947
|
collection: BACKUP_DESTINATION_POLICIES,
|
|
@@ -1006,6 +951,17 @@ var BackupDestinationPolicyService = class {
|
|
|
1006
951
|
}
|
|
1007
952
|
async list() {
|
|
1008
953
|
await this.ensureDeclared();
|
|
954
|
+
const kind = this.policiesKind;
|
|
955
|
+
if (kind !== null) {
|
|
956
|
+
const rows = await (0, import_read_all_rows.readAllRows)(kind);
|
|
957
|
+
rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
958
|
+
const out = [];
|
|
959
|
+
for (const row of rows) {
|
|
960
|
+
const mapped = bodyToPolicy(row.id, row.data);
|
|
961
|
+
if (mapped) out.push(mapped);
|
|
962
|
+
}
|
|
963
|
+
return out;
|
|
964
|
+
}
|
|
1009
965
|
const rows = await this.store.query({
|
|
1010
966
|
collection: BACKUP_DESTINATION_POLICIES,
|
|
1011
967
|
filter: { orderBy: {
|
|
@@ -1022,6 +978,11 @@ var BackupDestinationPolicyService = class {
|
|
|
1022
978
|
}
|
|
1023
979
|
async get(locationId) {
|
|
1024
980
|
await this.ensureDeclared();
|
|
981
|
+
const kind = this.policiesKind;
|
|
982
|
+
if (kind !== null) {
|
|
983
|
+
const row = await kind.get(locationId);
|
|
984
|
+
return row === null ? null : bodyToPolicy(locationId, row.data);
|
|
985
|
+
}
|
|
1025
986
|
const rows = await this.store.query({
|
|
1026
987
|
collection: BACKUP_DESTINATION_POLICIES,
|
|
1027
988
|
filter: {
|
|
@@ -1037,6 +998,16 @@ var BackupDestinationPolicyService = class {
|
|
|
1037
998
|
*/
|
|
1038
999
|
async upsert(p) {
|
|
1039
1000
|
await this.ensureDeclared();
|
|
1001
|
+
const kind = this.policiesKind;
|
|
1002
|
+
if (kind !== null) {
|
|
1003
|
+
const body = policyToBody(p);
|
|
1004
|
+
const data = backupOrchestratorRecordKinds["destination-policies"].schema.parse(body);
|
|
1005
|
+
await kind.put({
|
|
1006
|
+
id: p.locationId,
|
|
1007
|
+
data
|
|
1008
|
+
});
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1040
1011
|
await this.store.deleteWhere({
|
|
1041
1012
|
collection: BACKUP_DESTINATION_POLICIES,
|
|
1042
1013
|
filter: { where: { location_id: p.locationId } }
|
|
@@ -1051,6 +1022,11 @@ var BackupDestinationPolicyService = class {
|
|
|
1051
1022
|
}
|
|
1052
1023
|
async delete(locationId) {
|
|
1053
1024
|
await this.ensureDeclared();
|
|
1025
|
+
const kind = this.policiesKind;
|
|
1026
|
+
if (kind !== null) {
|
|
1027
|
+
await kind.delete(locationId);
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1054
1030
|
await this.store.deleteWhere({
|
|
1055
1031
|
collection: BACKUP_DESTINATION_POLICIES,
|
|
1056
1032
|
filter: { where: { location_id: locationId } }
|
|
@@ -1102,6 +1078,26 @@ var BackupDestinationPolicyService = class {
|
|
|
1102
1078
|
});
|
|
1103
1079
|
}
|
|
1104
1080
|
};
|
|
1081
|
+
function policyToBody(p) {
|
|
1082
|
+
return {
|
|
1083
|
+
enabled: p.enabled,
|
|
1084
|
+
retentionCount: p.retentionCount,
|
|
1085
|
+
...p.label !== void 0 ? { label: p.label } : {},
|
|
1086
|
+
...p.lastAttemptAt !== void 0 ? { lastAttemptAt: p.lastAttemptAt } : {},
|
|
1087
|
+
...p.lastError !== void 0 ? { lastError: p.lastError } : {}
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
function bodyToPolicy(locationId, body) {
|
|
1091
|
+
if (!locationId) return null;
|
|
1092
|
+
return {
|
|
1093
|
+
locationId,
|
|
1094
|
+
enabled: body.enabled,
|
|
1095
|
+
retentionCount: body.retentionCount,
|
|
1096
|
+
...body.label !== void 0 ? { label: body.label } : {},
|
|
1097
|
+
...body.lastAttemptAt !== void 0 ? { lastAttemptAt: body.lastAttemptAt } : {},
|
|
1098
|
+
...body.lastError !== void 0 ? { lastError: body.lastError } : {}
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1105
1101
|
function mapPolicyToRow(p) {
|
|
1106
1102
|
return {
|
|
1107
1103
|
location_id: p.locationId,
|
|
@@ -1205,131 +1201,6 @@ async function downloadArchiveToCache(input) {
|
|
|
1205
1201
|
}
|
|
1206
1202
|
}
|
|
1207
1203
|
//#endregion
|
|
1208
|
-
//#region src/builtins/backup-orchestrator/encryption-key-store.ts
|
|
1209
|
-
/**
|
|
1210
|
-
* @durable class=config owner=backup-orchestrator
|
|
1211
|
-
* write="`setupEncryption` inserts one row per generated key and retires the
|
|
1212
|
-
* previous active row; `disableEncryption` retires the active row"
|
|
1213
|
-
* retention="none — one small row per key ever generated; a retired row
|
|
1214
|
-
* names the key older archives need"
|
|
1215
|
-
*/
|
|
1216
|
-
var BACKUP_ENCRYPTION_KEYS_COLLECTION = "backup_encryption_keys";
|
|
1217
|
-
var COLUMNS = [
|
|
1218
|
-
{
|
|
1219
|
-
name: "key_id",
|
|
1220
|
-
type: "TEXT",
|
|
1221
|
-
primaryKey: true
|
|
1222
|
-
},
|
|
1223
|
-
{
|
|
1224
|
-
name: "public_key",
|
|
1225
|
-
type: "TEXT",
|
|
1226
|
-
notNull: true
|
|
1227
|
-
},
|
|
1228
|
-
{
|
|
1229
|
-
name: "created_at",
|
|
1230
|
-
type: "INTEGER",
|
|
1231
|
-
notNull: true
|
|
1232
|
-
},
|
|
1233
|
-
{
|
|
1234
|
-
name: "retired_at",
|
|
1235
|
-
type: "INTEGER"
|
|
1236
|
-
}
|
|
1237
|
-
];
|
|
1238
|
-
var BackupEncryptionKeyStore = class {
|
|
1239
|
-
store;
|
|
1240
|
-
now;
|
|
1241
|
-
declared = false;
|
|
1242
|
-
constructor(store, now = Date.now) {
|
|
1243
|
-
this.store = store;
|
|
1244
|
-
this.now = now;
|
|
1245
|
-
}
|
|
1246
|
-
async ensureDeclared() {
|
|
1247
|
-
if (this.declared) return;
|
|
1248
|
-
await this.store.declareCollection({
|
|
1249
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1250
|
-
columns: COLUMNS
|
|
1251
|
-
});
|
|
1252
|
-
this.declared = true;
|
|
1253
|
-
}
|
|
1254
|
-
/** Every key, newest first. */
|
|
1255
|
-
async list() {
|
|
1256
|
-
await this.ensureDeclared();
|
|
1257
|
-
const rows = await this.store.query({
|
|
1258
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1259
|
-
filter: { orderBy: {
|
|
1260
|
-
field: "created_at",
|
|
1261
|
-
direction: "desc"
|
|
1262
|
-
} }
|
|
1263
|
-
});
|
|
1264
|
-
const out = [];
|
|
1265
|
-
for (const row of rows) {
|
|
1266
|
-
const record = toRecord(row.data);
|
|
1267
|
-
if (record !== null) out.push(record);
|
|
1268
|
-
}
|
|
1269
|
-
return out;
|
|
1270
|
-
}
|
|
1271
|
-
/** The key new archives are encrypted to; `null` = encryption off. */
|
|
1272
|
-
async active() {
|
|
1273
|
-
return (await this.list()).find((k) => k.retiredAt === null) ?? null;
|
|
1274
|
-
}
|
|
1275
|
-
/** Make `publicKey` the active key; the previous one is retired, kept listed. */
|
|
1276
|
-
async activate(input) {
|
|
1277
|
-
const parsed = parseBackupPublicKey(input.publicKey);
|
|
1278
|
-
const t = this.now();
|
|
1279
|
-
await this.retireActive(t);
|
|
1280
|
-
const record = {
|
|
1281
|
-
keyId: parsed.keyId,
|
|
1282
|
-
publicKey: input.publicKey.trim(),
|
|
1283
|
-
createdAt: t,
|
|
1284
|
-
retiredAt: null
|
|
1285
|
-
};
|
|
1286
|
-
await this.write(record);
|
|
1287
|
-
return record;
|
|
1288
|
-
}
|
|
1289
|
-
/** Encryption off: the active key is retired. Archives already made keep needing it. */
|
|
1290
|
-
async disable() {
|
|
1291
|
-
await this.retireActive(this.now());
|
|
1292
|
-
}
|
|
1293
|
-
async retireActive(at) {
|
|
1294
|
-
for (const key of await this.list()) if (key.retiredAt === null) await this.write({
|
|
1295
|
-
...key,
|
|
1296
|
-
retiredAt: at
|
|
1297
|
-
});
|
|
1298
|
-
}
|
|
1299
|
-
async write(record) {
|
|
1300
|
-
await this.ensureDeclared();
|
|
1301
|
-
await this.store.deleteWhere({
|
|
1302
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1303
|
-
filter: { where: { key_id: record.keyId } }
|
|
1304
|
-
});
|
|
1305
|
-
await this.store.insert({
|
|
1306
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
1307
|
-
record: {
|
|
1308
|
-
id: record.keyId,
|
|
1309
|
-
data: {
|
|
1310
|
-
key_id: record.keyId,
|
|
1311
|
-
public_key: record.publicKey,
|
|
1312
|
-
created_at: record.createdAt,
|
|
1313
|
-
retired_at: record.retiredAt
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
function toRecord(row) {
|
|
1320
|
-
const keyId = row["key_id"];
|
|
1321
|
-
const publicKey = row["public_key"];
|
|
1322
|
-
const createdAt = row["created_at"];
|
|
1323
|
-
if (typeof keyId !== "string" || typeof publicKey !== "string") return null;
|
|
1324
|
-
const retired = row["retired_at"];
|
|
1325
|
-
return {
|
|
1326
|
-
keyId,
|
|
1327
|
-
publicKey,
|
|
1328
|
-
createdAt: typeof createdAt === "number" ? createdAt : Number(createdAt ?? 0),
|
|
1329
|
-
retiredAt: typeof retired === "number" ? retired : null
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
//#endregion
|
|
1333
1204
|
//#region src/builtins/backup-orchestrator/manifest-store.ts
|
|
1334
1205
|
/** File path (relative to the location root) where the index lives. */
|
|
1335
1206
|
var MANIFESTS_FILENAME = "manifests.json";
|
|
@@ -1865,13 +1736,16 @@ var BACKUP_SCHEDULES_COLUMNS = [
|
|
|
1865
1736
|
var BackupScheduleService = class {
|
|
1866
1737
|
store;
|
|
1867
1738
|
declared = false;
|
|
1868
|
-
|
|
1739
|
+
schedulesKind;
|
|
1740
|
+
constructor(store, schedulesKind = null) {
|
|
1869
1741
|
this.store = store;
|
|
1742
|
+
this.schedulesKind = schedulesKind;
|
|
1870
1743
|
}
|
|
1871
1744
|
async initialize() {
|
|
1872
1745
|
await this.ensureDeclared();
|
|
1873
1746
|
}
|
|
1874
1747
|
async ensureDeclared() {
|
|
1748
|
+
if (this.schedulesKind !== null) return;
|
|
1875
1749
|
if (this.declared) return;
|
|
1876
1750
|
await this.store.declareCollection({
|
|
1877
1751
|
collection: BACKUP_SCHEDULES,
|
|
@@ -1881,6 +1755,17 @@ var BackupScheduleService = class {
|
|
|
1881
1755
|
}
|
|
1882
1756
|
async list() {
|
|
1883
1757
|
await this.ensureDeclared();
|
|
1758
|
+
const kind = this.schedulesKind;
|
|
1759
|
+
if (kind !== null) {
|
|
1760
|
+
const rows = await (0, import_read_all_rows.readAllRows)(kind);
|
|
1761
|
+
rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
1762
|
+
const out = [];
|
|
1763
|
+
for (const row of rows) {
|
|
1764
|
+
const mapped = bodyToSchedule(row.id, row.data);
|
|
1765
|
+
if (mapped) out.push(mapped);
|
|
1766
|
+
}
|
|
1767
|
+
return out;
|
|
1768
|
+
}
|
|
1884
1769
|
const rows = await this.store.query({
|
|
1885
1770
|
collection: BACKUP_SCHEDULES,
|
|
1886
1771
|
filter: { orderBy: {
|
|
@@ -1897,6 +1782,11 @@ var BackupScheduleService = class {
|
|
|
1897
1782
|
}
|
|
1898
1783
|
async get(id) {
|
|
1899
1784
|
await this.ensureDeclared();
|
|
1785
|
+
const kind = this.schedulesKind;
|
|
1786
|
+
if (kind !== null) {
|
|
1787
|
+
const row = await kind.get(id);
|
|
1788
|
+
return row === null ? null : bodyToSchedule(id, row.data);
|
|
1789
|
+
}
|
|
1900
1790
|
const rows = await this.store.query({
|
|
1901
1791
|
collection: BACKUP_SCHEDULES,
|
|
1902
1792
|
filter: {
|
|
@@ -1909,6 +1799,16 @@ var BackupScheduleService = class {
|
|
|
1909
1799
|
/** Replace-or-insert (delete + insert — mirrors the policy store). */
|
|
1910
1800
|
async upsert(s) {
|
|
1911
1801
|
await this.ensureDeclared();
|
|
1802
|
+
const kind = this.schedulesKind;
|
|
1803
|
+
if (kind !== null) {
|
|
1804
|
+
const body = scheduleToBody(s);
|
|
1805
|
+
const data = backupOrchestratorRecordKinds.schedules.schema.parse(body);
|
|
1806
|
+
await kind.put({
|
|
1807
|
+
id: s.id,
|
|
1808
|
+
data
|
|
1809
|
+
});
|
|
1810
|
+
return;
|
|
1811
|
+
}
|
|
1912
1812
|
await this.store.deleteWhere({
|
|
1913
1813
|
collection: BACKUP_SCHEDULES,
|
|
1914
1814
|
filter: { where: { id: s.id } }
|
|
@@ -1923,12 +1823,47 @@ var BackupScheduleService = class {
|
|
|
1923
1823
|
}
|
|
1924
1824
|
async delete(id) {
|
|
1925
1825
|
await this.ensureDeclared();
|
|
1826
|
+
const kind = this.schedulesKind;
|
|
1827
|
+
if (kind !== null) {
|
|
1828
|
+
await kind.delete(id);
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1926
1831
|
await this.store.deleteWhere({
|
|
1927
1832
|
collection: BACKUP_SCHEDULES,
|
|
1928
1833
|
filter: { where: { id } }
|
|
1929
1834
|
});
|
|
1930
1835
|
}
|
|
1931
1836
|
};
|
|
1837
|
+
function scheduleToBody(s) {
|
|
1838
|
+
return {
|
|
1839
|
+
label: s.label,
|
|
1840
|
+
cron: s.cron,
|
|
1841
|
+
enabled: s.enabled,
|
|
1842
|
+
locationIds: [...s.locationIds],
|
|
1843
|
+
retentionCount: s.retentionCount,
|
|
1844
|
+
...s.dataSources !== void 0 ? { dataSources: [...s.dataSources] } : {},
|
|
1845
|
+
...s.databases !== void 0 ? { databases: [...s.databases] } : {},
|
|
1846
|
+
...s.lastAttemptAt !== void 0 ? { lastAttemptAt: s.lastAttemptAt } : {},
|
|
1847
|
+
...s.lastSuccessAt !== void 0 ? { lastSuccessAt: s.lastSuccessAt } : {},
|
|
1848
|
+
...s.lastError !== void 0 ? { lastError: s.lastError } : {}
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
function bodyToSchedule(id, body) {
|
|
1852
|
+
if (!id) return null;
|
|
1853
|
+
return {
|
|
1854
|
+
id,
|
|
1855
|
+
label: body.label,
|
|
1856
|
+
cron: body.cron,
|
|
1857
|
+
enabled: body.enabled,
|
|
1858
|
+
locationIds: [...body.locationIds],
|
|
1859
|
+
retentionCount: body.retentionCount,
|
|
1860
|
+
...body.dataSources !== void 0 ? { dataSources: [...body.dataSources] } : {},
|
|
1861
|
+
...body.databases !== void 0 && body.databases.length > 0 ? { databases: [...body.databases] } : {},
|
|
1862
|
+
...body.lastAttemptAt !== void 0 ? { lastAttemptAt: body.lastAttemptAt } : {},
|
|
1863
|
+
...body.lastSuccessAt !== void 0 ? { lastSuccessAt: body.lastSuccessAt } : {},
|
|
1864
|
+
...body.lastError !== void 0 ? { lastError: body.lastError } : {}
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1932
1867
|
function mapScheduleToRow(s) {
|
|
1933
1868
|
return {
|
|
1934
1869
|
id: s.id,
|
|
@@ -2183,6 +2118,7 @@ var UPLOAD_CHUNK_BYTES = 8 * 1024 * 1024;
|
|
|
2183
2118
|
var ORCHESTRATOR_ADDON_ID = "backup-orchestrator";
|
|
2184
2119
|
var BackupOrchestratorAddon = class extends BaseAddon {
|
|
2185
2120
|
systemBackup = null;
|
|
2121
|
+
backupRecords = null;
|
|
2186
2122
|
policies = null;
|
|
2187
2123
|
schedules = null;
|
|
2188
2124
|
/** Backup encryption keys — PUBLIC keys only (see encryption-key-store.ts). */
|
|
@@ -2224,6 +2160,11 @@ var BackupOrchestratorAddon = class extends BaseAddon {
|
|
|
2224
2160
|
super({});
|
|
2225
2161
|
}
|
|
2226
2162
|
async onInitialize() {
|
|
2163
|
+
const records = this.ctx.records;
|
|
2164
|
+
if (records !== void 0) {
|
|
2165
|
+
await records.declare(backupOrchestratorRecordKinds);
|
|
2166
|
+
this.backupRecords = backupRecordStoresOf(records);
|
|
2167
|
+
}
|
|
2227
2168
|
this.dataDir = this.ctx.nodeDataDir;
|
|
2228
2169
|
this.stagingDir = resolveStagingDir(this.ctx.nodeDataDir);
|
|
2229
2170
|
this.systemBackup = new SystemBackupService(this.dataDir, this.ctx.logger);
|
|
@@ -2245,7 +2186,7 @@ var BackupOrchestratorAddon = class extends BaseAddon {
|
|
|
2245
2186
|
}
|
|
2246
2187
|
await this.seedWeekly();
|
|
2247
2188
|
const settingsStore = this.ctx.kernel.capabilityRegistry?.getSingleton("settings-store");
|
|
2248
|
-
this.encryptionKeys = settingsStore ? new BackupEncryptionKeyStore(settingsStore) : null;
|
|
2189
|
+
this.encryptionKeys = settingsStore ? new BackupEncryptionKeyStore(settingsStore, Date.now, this.backupRecords?.encryptionKeys ?? null) : null;
|
|
2249
2190
|
const provider = {
|
|
2250
2191
|
listDestinations: () => this.listDestinations(),
|
|
2251
2192
|
list: () => this.aggregatedList(),
|
|
@@ -3248,7 +3189,7 @@ var BackupOrchestratorAddon = class extends BaseAddon {
|
|
|
3248
3189
|
try {
|
|
3249
3190
|
const store = this.ctx.kernel.capabilityRegistry?.getSingleton("settings-store");
|
|
3250
3191
|
if (!store) return;
|
|
3251
|
-
const seed = await seedWeeklySchedule(this.schedules, new BackupSeedMarkerStore(store));
|
|
3192
|
+
const seed = await seedWeeklySchedule(this.schedules, new BackupSeedMarkerStore(store, Date.now, this.backupRecords?.seedMarkers ?? null));
|
|
3252
3193
|
if (seed === null) return;
|
|
3253
3194
|
this.ctx.logger.info("backup: seeded the weekly events & history schedule", { meta: {
|
|
3254
3195
|
scheduleId: seed.id,
|
|
@@ -3405,7 +3346,7 @@ var BackupOrchestratorAddon = class extends BaseAddon {
|
|
|
3405
3346
|
this.ctx.logger.warn("backup-orchestrator: no settings-store provider — backup schedules will not persist");
|
|
3406
3347
|
return null;
|
|
3407
3348
|
}
|
|
3408
|
-
return new BackupScheduleService(store);
|
|
3349
|
+
return new BackupScheduleService(store, this.backupRecords?.schedules ?? null);
|
|
3409
3350
|
}
|
|
3410
3351
|
resolvePolicyService() {
|
|
3411
3352
|
const reg = this.ctx.kernel.capabilityRegistry;
|
|
@@ -3415,7 +3356,7 @@ var BackupOrchestratorAddon = class extends BaseAddon {
|
|
|
3415
3356
|
this.ctx.logger.warn("backup-orchestrator: no settings-store provider — destination policies will not persist");
|
|
3416
3357
|
return null;
|
|
3417
3358
|
}
|
|
3418
|
-
return new BackupDestinationPolicyService(store);
|
|
3359
|
+
return new BackupDestinationPolicyService(store, this.backupRecords?.destinationPolicies ?? null);
|
|
3419
3360
|
}
|
|
3420
3361
|
/**
|
|
3421
3362
|
* Narrow `ctx.api.storage` to the subset the manifest helpers need.
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* the `settings-store` collection surface. Callers obtain the provider via
|
|
16
16
|
* `kernel.capabilityRegistry.getSingleton<ISettingsStoreProvider>('settings-store')`.
|
|
17
17
|
*/
|
|
18
|
-
import type { CollectionColumn, ISettingsStoreProvider } from "@camstack/types";
|
|
18
|
+
import type { CollectionColumn, ISettingsStoreProvider, RecordKindHandle } from "@camstack/types";
|
|
19
|
+
import { type BackupDestinationPolicyBody } from "./record-kinds.js";
|
|
19
20
|
/**
|
|
20
21
|
* Per-`backups`-location policy. `locationId` is the foreign-key into
|
|
21
22
|
* the storage orchestrator's `storage_locations` table.
|
|
@@ -54,7 +55,8 @@ export declare const BACKUP_DESTINATION_POLICIES_COLUMNS: readonly CollectionCol
|
|
|
54
55
|
export declare class BackupDestinationPolicyService {
|
|
55
56
|
private readonly store;
|
|
56
57
|
private declared;
|
|
57
|
-
|
|
58
|
+
private readonly policiesKind;
|
|
59
|
+
constructor(store: ISettingsStoreProvider, policiesKind?: RecordKindHandle<BackupDestinationPolicyBody> | null);
|
|
58
60
|
/**
|
|
59
61
|
* Lazy `declareCollection` — called from every read/write path.
|
|
60
62
|
* `declareCollection` is idempotent, so repeated calls collapse to a no-op
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* A read that fails THROWS: a backup run must never take "could not read the
|
|
10
10
|
* setting" for "encryption is off" and ship a plain archive.
|
|
11
11
|
*/
|
|
12
|
-
import type { ISettingsStoreProvider } from "@camstack/types";
|
|
12
|
+
import type { ISettingsStoreProvider, RecordKindHandle } from "@camstack/types";
|
|
13
|
+
import { type BackupEncryptionKeyBody } from "./record-kinds.js";
|
|
13
14
|
/**
|
|
14
15
|
* @durable class=config owner=backup-orchestrator
|
|
15
16
|
* write="`setupEncryption` inserts one row per generated key and retires the
|
|
@@ -29,7 +30,8 @@ export declare class BackupEncryptionKeyStore {
|
|
|
29
30
|
private readonly store;
|
|
30
31
|
private readonly now;
|
|
31
32
|
private declared;
|
|
32
|
-
|
|
33
|
+
private readonly keysKind;
|
|
34
|
+
constructor(store: Store, now?: () => number, keysKind?: RecordKindHandle<BackupEncryptionKeyBody> | null);
|
|
33
35
|
private ensureDeclared;
|
|
34
36
|
/** Every key, newest first. */
|
|
35
37
|
list(): Promise<readonly BackupEncryptionKeyRecord[]>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record kinds owned by backup-orchestrator (phase 4 — hub-main).
|
|
3
|
+
*/
|
|
4
|
+
import type { RecordKindHandle, RecordsAccess } from "@camstack/types";
|
|
5
|
+
import { DataStoreDatabaseSchema, type DefinedRecordKind } from "@camstack/types";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
export declare const BACKUP_SCHEDULES_LEGACY = "backup_schedules";
|
|
8
|
+
export declare const BACKUP_DESTINATION_POLICIES_LEGACY = "backup_destination_policies";
|
|
9
|
+
export type BackupScheduleBody = {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly cron: string;
|
|
12
|
+
readonly enabled: boolean;
|
|
13
|
+
readonly locationIds: readonly string[];
|
|
14
|
+
readonly retentionCount: number;
|
|
15
|
+
readonly dataSources?: readonly string[];
|
|
16
|
+
readonly databases?: readonly z.infer<typeof DataStoreDatabaseSchema>[];
|
|
17
|
+
readonly lastAttemptAt?: number;
|
|
18
|
+
readonly lastSuccessAt?: number;
|
|
19
|
+
readonly lastError?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const BackupScheduleBodySchema: z.ZodType<BackupScheduleBody>;
|
|
22
|
+
export type BackupDestinationPolicyBody = {
|
|
23
|
+
readonly enabled: boolean;
|
|
24
|
+
readonly retentionCount: number;
|
|
25
|
+
readonly label?: string;
|
|
26
|
+
readonly lastAttemptAt?: number;
|
|
27
|
+
readonly lastError?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const BackupDestinationPolicyBodySchema: z.ZodType<BackupDestinationPolicyBody>;
|
|
30
|
+
export type BackupEncryptionKeyBody = {
|
|
31
|
+
readonly keyId: string;
|
|
32
|
+
readonly publicKey: string;
|
|
33
|
+
readonly createdAt: number;
|
|
34
|
+
readonly retiredAt: number | null;
|
|
35
|
+
};
|
|
36
|
+
export declare const BackupEncryptionKeyBodySchema: z.ZodType<BackupEncryptionKeyBody>;
|
|
37
|
+
export type BackupSeedMarkerBody = {
|
|
38
|
+
readonly seededAt: number;
|
|
39
|
+
};
|
|
40
|
+
export declare const BackupSeedMarkerBodySchema: z.ZodType<BackupSeedMarkerBody>;
|
|
41
|
+
export type BackupOrchestratorRecordKindsMap = {
|
|
42
|
+
readonly schedules: DefinedRecordKind<z.ZodType<BackupScheduleBody>>;
|
|
43
|
+
readonly "destination-policies": DefinedRecordKind<z.ZodType<BackupDestinationPolicyBody>>;
|
|
44
|
+
readonly "encryption-keys": DefinedRecordKind<z.ZodType<BackupEncryptionKeyBody>>;
|
|
45
|
+
readonly "seed-markers": DefinedRecordKind<z.ZodType<BackupSeedMarkerBody>>;
|
|
46
|
+
};
|
|
47
|
+
export declare const backupOrchestratorRecordKinds: BackupOrchestratorRecordKindsMap;
|
|
48
|
+
export declare const backupSchedulesRecordKind: DefinedRecordKind<z.ZodType<BackupScheduleBody>>;
|
|
49
|
+
export declare const backupDestinationPoliciesRecordKind: DefinedRecordKind<z.ZodType<BackupDestinationPolicyBody>>;
|
|
50
|
+
export declare const backupEncryptionKeysRecordKind: DefinedRecordKind<z.ZodType<BackupEncryptionKeyBody>>;
|
|
51
|
+
export declare const backupSeedMarkersRecordKind: DefinedRecordKind<z.ZodType<BackupSeedMarkerBody>>;
|
|
52
|
+
export interface BackupRecordStores {
|
|
53
|
+
readonly schedules: RecordKindHandle<BackupScheduleBody>;
|
|
54
|
+
readonly destinationPolicies: RecordKindHandle<BackupDestinationPolicyBody>;
|
|
55
|
+
readonly encryptionKeys: RecordKindHandle<BackupEncryptionKeyBody>;
|
|
56
|
+
readonly seedMarkers: RecordKindHandle<BackupSeedMarkerBody>;
|
|
57
|
+
}
|
|
58
|
+
export declare function backupRecordStoresOf(records: Pick<RecordsAccess, "kind">): BackupRecordStores;
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* the surface serialises and parses them, so this file passes and
|
|
15
15
|
* receives real arrays.
|
|
16
16
|
*/
|
|
17
|
-
import type { CollectionColumn, DataStoreDatabase, ISettingsStoreProvider } from "@camstack/types";
|
|
17
|
+
import type { CollectionColumn, DataStoreDatabase, ISettingsStoreProvider, RecordKindHandle } from "@camstack/types";
|
|
18
|
+
import { type BackupScheduleBody } from "./record-kinds.js";
|
|
18
19
|
/**
|
|
19
20
|
* A backup schedule row.
|
|
20
21
|
*
|
|
@@ -54,7 +55,8 @@ export declare const BACKUP_SCHEDULES_COLUMNS: readonly CollectionColumn[];
|
|
|
54
55
|
export declare class BackupScheduleService {
|
|
55
56
|
private readonly store;
|
|
56
57
|
private declared;
|
|
57
|
-
|
|
58
|
+
private readonly schedulesKind;
|
|
59
|
+
constructor(store: ISettingsStoreProvider, schedulesKind?: RecordKindHandle<BackupScheduleBody> | null);
|
|
58
60
|
initialize(): Promise<void>;
|
|
59
61
|
private ensureDeclared;
|
|
60
62
|
list(): Promise<readonly BackupSchedule[]>;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* AFTER the seeded row landed. A read that fails THROWS: "could not read the
|
|
8
8
|
* marker" must never look like "never seeded".
|
|
9
9
|
*/
|
|
10
|
-
import type { ISettingsStoreProvider } from "@camstack/types";
|
|
10
|
+
import type { ISettingsStoreProvider, RecordKindHandle } from "@camstack/types";
|
|
11
|
+
import { type BackupSeedMarkerBody } from "./record-kinds.js";
|
|
11
12
|
/**
|
|
12
13
|
* @durable class=config owner=backup-orchestrator
|
|
13
14
|
* write="the orchestrator inserts one row per seed id the first time that
|
|
@@ -26,7 +27,8 @@ export declare class BackupSeedMarkerStore implements SeedMarkers {
|
|
|
26
27
|
private readonly store;
|
|
27
28
|
private readonly now;
|
|
28
29
|
private declared;
|
|
29
|
-
|
|
30
|
+
private readonly markersKind;
|
|
31
|
+
constructor(store: Store, now?: () => number, markersKind?: RecordKindHandle<BackupSeedMarkerBody> | null);
|
|
30
32
|
private ensureDeclared;
|
|
31
33
|
has(seedId: string): Promise<boolean>;
|
|
32
34
|
mark(seedId: string): Promise<void>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-user calendar UI preferences (colour override + visibility).
|
|
3
3
|
*
|
|
4
|
-
* One row per `userId`. The calendars builtin owns
|
|
4
|
+
* One row per `userId`. The calendars builtin owns read/write via records;
|
|
5
5
|
* the browser never talks to `settingsStore` directly.
|
|
6
6
|
*/
|
|
7
|
-
import { type CalendarPreferences, type
|
|
7
|
+
import { type CalendarPreferences, type RecordKindHandle, type RecordsAccess } from "@camstack/types";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { CalendarUserPrefsBodySchema } from "./record-kinds.js";
|
|
8
10
|
/**
|
|
9
11
|
* @durable class=config owner=calendars
|
|
10
12
|
* write="`setCalendarPreference` upserts the caller's row"
|
|
@@ -13,9 +15,14 @@ import { type CalendarPreferences, type SettingsStoreClient } from "@camstack/ty
|
|
|
13
15
|
* colour/hide choices."
|
|
14
16
|
*/
|
|
15
17
|
export declare const CALENDARS_USER_PREFS_COLLECTION = "calendars:user-prefs";
|
|
16
|
-
|
|
17
|
-
export declare
|
|
18
|
-
|
|
18
|
+
type PrefsBody = z.infer<typeof CalendarUserPrefsBodySchema>;
|
|
19
|
+
export declare class CalendarPrefsStore {
|
|
20
|
+
private readonly kind;
|
|
21
|
+
constructor(kind: RecordKindHandle<PrefsBody>);
|
|
22
|
+
static of(records: Pick<RecordsAccess, "kind">): CalendarPrefsStore;
|
|
23
|
+
load(userId: string): Promise<CalendarPreferences>;
|
|
24
|
+
save(userId: string, prefs: CalendarPreferences, nowMs: number): Promise<void>;
|
|
25
|
+
}
|
|
19
26
|
/**
|
|
20
27
|
* Patch one calendar's preference entry. `color: null` clears the override;
|
|
21
28
|
* omitting a field leaves it unchanged. An entry that becomes empty is dropped.
|
|
@@ -24,3 +31,4 @@ export declare function patchCalendarPreference(current: CalendarPreferences, ca
|
|
|
24
31
|
readonly visible?: boolean;
|
|
25
32
|
readonly color?: string | null;
|
|
26
33
|
}): CalendarPreferences;
|
|
34
|
+
export {};
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import { BaseAddon, type ProviderRegistration } from "@camstack/types";
|
|
7
7
|
export declare class CalendarsAddon extends BaseAddon {
|
|
8
8
|
readonly id = "calendars";
|
|
9
|
-
private
|
|
9
|
+
private prefsStore;
|
|
10
10
|
constructor();
|
|
11
11
|
protected onInitialize(): Promise<ProviderRegistration[]>;
|
|
12
|
-
private
|
|
12
|
+
private prefs;
|
|
13
13
|
private sources;
|
|
14
14
|
private listCalendars;
|
|
15
15
|
private listEvents;
|