@camstack/system 1.2.458 → 1.2.459
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/{agent-https-DOELEug8.js → agent-https-Dnr_nIVx.js} +3 -723
- package/dist/{agent-https-CQA3W-3e.mjs → agent-https-Iw3RSQup.mjs} +4 -616
- 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/alerts.addon.js +5 -7
- package/dist/builtins/alerts/alerts.addon.mjs +5 -7
- package/dist/builtins/alerts/record-kinds.d.ts +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +242 -4
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +240 -2
- package/dist/builtins/calendars/calendars.addon.js +2 -10
- package/dist/builtins/calendars/calendars.addon.mjs +2 -3
- package/dist/builtins/calendars/record-kinds.d.ts +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- 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/core-blocks.addon.js +4 -6
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -6
- package/dist/builtins/device-history/device-history.addon.js +1 -1
- package/dist/builtins/device-history/device-history.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +2 -4
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -4
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +41 -43
- package/dist/builtins/keychain/index.mjs +41 -43
- 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/local-auth.addon.js +24 -40
- package/dist/builtins/local-auth/local-auth.addon.mjs +24 -40
- 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/native-metrics/node-metrics-history-recorder.d.ts +1 -2
- 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/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/file-host-protocol.d.ts +0 -15
- 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/owned-sqlite-file.d.ts +0 -44
- package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +0 -2
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +0 -21
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +3 -20
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +4 -18
- package/dist/builtins/sqlite-storage/records/records-sql.d.ts +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +0 -17
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +21 -196
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +21 -196
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +6 -14
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +7 -9
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +7 -9
- package/dist/builtins/system-config/system-config.addon.js +667 -40
- package/dist/builtins/system-config/system-config.addon.mjs +625 -15
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-BVguN7VV.mjs → composition-sources-DNRZWR1j.mjs} +1 -1
- package/dist/{composition-sources-DURQNDJ4.js → composition-sources-b0e_2I-D.js} +1 -1
- package/dist/{constants-Njka8Cv6.js → constants-6OeJiZgi.js} +1 -1
- package/dist/{constants-FGjnsE2x.mjs → constants-BnkOdj9Q.mjs} +1 -1
- package/dist/{device-ca-lEaAQ9Xi.mjs → device-ca-Bnkw8GyU.mjs} +1 -1
- package/dist/{device-ca-BrVK_5s3.js → device-ca-CPTDs--d.js} +1 -1
- package/dist/{dist-BZQjLPiz.js → dist-Bn-RNanh.js} +29 -130
- package/dist/{dist-B_GRPhnY.mjs → dist-Wy8cTxg6.mjs} +30 -113
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-Bg2HfTwP.mjs → hub-mdns-ciao-CJu0nhla.mjs} +2 -2
- package/dist/{hub-mdns-ciao-nce3TXs_.js → hub-mdns-ciao-CTBTlia4.js} +2 -2
- package/dist/index.js +27 -30
- package/dist/index.mjs +11 -14
- package/dist/{restore-archive-C7kLDI_0.mjs → restore-archive-CmP-iiG9.mjs} +84 -331
- package/dist/{restore-archive-FyfZ8YMC.js → restore-archive-DM1OBYq4.js} +89 -342
- package/dist/{wal-maintenance-DfSIOj24.js → wal-maintenance-DUHEp_09.js} +0 -0
- package/dist/{wal-maintenance-Duejh7Lx.mjs → wal-maintenance-NKbwWovZ.mjs} +0 -0
- package/package.json +1 -1
- package/dist/builtins/records/legacy-table-row-count.d.ts +0 -5
- package/dist/builtins/records/phase6-declare-gate.d.ts +0 -28
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +0 -5
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +0 -6
- package/dist/phase6-declare-gate-Dag1_WR2.js +0 -98
- package/dist/phase6-declare-gate-Lb-mrVvz.mjs +0 -93
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as require_read_all_rows } from "./read-all-rows-TaPqdWNF.mjs";
|
|
1
|
+
import { Gi as defineRecordKinds, N as DataStoreDatabaseSchema, S as DATABASE_SNAPSHOT_SUFFIX } from "./dist-Wy8cTxg6.mjs";
|
|
3
2
|
import { z } from "zod";
|
|
4
3
|
import { createCipheriv, createDecipheriv, createHash, createPrivateKey, createPublicKey, diffieHellman, generateKeyPairSync, hkdfSync, randomBytes } from "node:crypto";
|
|
5
4
|
import { Buffer as Buffer$1 } from "buffer";
|
|
@@ -21,6 +20,88 @@ import $r, { EventEmitter as EventEmitter$1 } from "events";
|
|
|
21
20
|
import * as zlib from "node:zlib";
|
|
22
21
|
import { pipeline } from "node:stream/promises";
|
|
23
22
|
import no from "node:assert";
|
|
23
|
+
var BackupScheduleBodySchema = z.object({
|
|
24
|
+
label: z.string(),
|
|
25
|
+
cron: z.string(),
|
|
26
|
+
enabled: z.boolean(),
|
|
27
|
+
locationIds: z.array(z.string()).readonly(),
|
|
28
|
+
retentionCount: z.number(),
|
|
29
|
+
dataSources: z.array(z.string()).readonly().optional(),
|
|
30
|
+
databases: z.array(DataStoreDatabaseSchema).readonly().optional(),
|
|
31
|
+
lastAttemptAt: z.number().optional(),
|
|
32
|
+
lastSuccessAt: z.number().optional(),
|
|
33
|
+
lastError: z.string().optional()
|
|
34
|
+
});
|
|
35
|
+
var BackupDestinationPolicyBodySchema = z.object({
|
|
36
|
+
enabled: z.boolean(),
|
|
37
|
+
retentionCount: z.number(),
|
|
38
|
+
label: z.string().optional(),
|
|
39
|
+
lastAttemptAt: z.number().optional(),
|
|
40
|
+
lastError: z.string().optional()
|
|
41
|
+
});
|
|
42
|
+
var BackupEncryptionKeyBodySchema = z.object({
|
|
43
|
+
keyId: z.string(),
|
|
44
|
+
publicKey: z.string(),
|
|
45
|
+
createdAt: z.number(),
|
|
46
|
+
retiredAt: z.number().nullable()
|
|
47
|
+
});
|
|
48
|
+
var BackupSeedMarkerBodySchema = z.object({ seededAt: z.number() });
|
|
49
|
+
var _backupOrchestratorRecordKinds = defineRecordKinds({
|
|
50
|
+
schedules: {
|
|
51
|
+
schema: BackupScheduleBodySchema,
|
|
52
|
+
class: "config",
|
|
53
|
+
writeTrigger: "operator upsert/delete; orchestrator stamps lastAttempt/success/error",
|
|
54
|
+
device: "none",
|
|
55
|
+
at: "none",
|
|
56
|
+
indexes: [{
|
|
57
|
+
name: "enabled",
|
|
58
|
+
fields: ["enabled"]
|
|
59
|
+
}],
|
|
60
|
+
retention: { none: "operator delete only" },
|
|
61
|
+
entry: {
|
|
62
|
+
title: "Backup schedules",
|
|
63
|
+
nameField: "label"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"destination-policies": {
|
|
67
|
+
schema: BackupDestinationPolicyBodySchema,
|
|
68
|
+
class: "config",
|
|
69
|
+
writeTrigger: "ensureDefault, operator upsert, recordAttempt after each archive write",
|
|
70
|
+
device: "none",
|
|
71
|
+
at: "none",
|
|
72
|
+
retention: { none: "row outlives location; ensureDefault recreates" }
|
|
73
|
+
},
|
|
74
|
+
"encryption-keys": {
|
|
75
|
+
schema: BackupEncryptionKeyBodySchema,
|
|
76
|
+
class: "config",
|
|
77
|
+
writeTrigger: "setupEncryption activate; disableEncryption retires active row",
|
|
78
|
+
device: "none",
|
|
79
|
+
at: "none",
|
|
80
|
+
retention: { none: "retired keys kept for archive decryption hints" }
|
|
81
|
+
},
|
|
82
|
+
"seed-markers": {
|
|
83
|
+
schema: BackupSeedMarkerBodySchema,
|
|
84
|
+
class: "config",
|
|
85
|
+
writeTrigger: "mark() once per seed id after seed landed",
|
|
86
|
+
device: "none",
|
|
87
|
+
at: "none",
|
|
88
|
+
retention: { none: "one row per seed id ever" }
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
var backupOrchestratorRecordKinds = _backupOrchestratorRecordKinds;
|
|
92
|
+
var backupSchedulesRecordKind = _backupOrchestratorRecordKinds.schedules;
|
|
93
|
+
var backupDestinationPoliciesRecordKind = _backupOrchestratorRecordKinds["destination-policies"];
|
|
94
|
+
var backupEncryptionKeysRecordKind = _backupOrchestratorRecordKinds["encryption-keys"];
|
|
95
|
+
var backupSeedMarkersRecordKind = _backupOrchestratorRecordKinds["seed-markers"];
|
|
96
|
+
function backupRecordStoresOf(records) {
|
|
97
|
+
return {
|
|
98
|
+
schedules: records.kind(backupSchedulesRecordKind),
|
|
99
|
+
destinationPolicies: records.kind(backupDestinationPoliciesRecordKind),
|
|
100
|
+
encryptionKeys: records.kind(backupEncryptionKeysRecordKind),
|
|
101
|
+
seedMarkers: records.kind(backupSeedMarkersRecordKind)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
24
105
|
//#region src/builtins/system-backup/backup-encryption.ts
|
|
25
106
|
/**
|
|
26
107
|
* Backup archive encryption — public key, streaming, chunked AEAD (D-backup
|
|
@@ -385,334 +466,6 @@ async function decryptBackupFile(input, output, secretKey) {
|
|
|
385
466
|
}
|
|
386
467
|
}
|
|
387
468
|
//#endregion
|
|
388
|
-
//#region src/builtins/backup-orchestrator/encryption-key-store.ts
|
|
389
|
-
var import_read_all_rows = require_read_all_rows();
|
|
390
|
-
/**
|
|
391
|
-
* @durable class=config owner=backup-orchestrator
|
|
392
|
-
* write="`setupEncryption` inserts one row per generated key and retires the
|
|
393
|
-
* previous active row; `disableEncryption` retires the active row"
|
|
394
|
-
* retention="none — one small row per key ever generated; a retired row
|
|
395
|
-
* names the key older archives need"
|
|
396
|
-
*/
|
|
397
|
-
var BACKUP_ENCRYPTION_KEYS_COLLECTION = "backup_encryption_keys";
|
|
398
|
-
var COLUMNS$1 = [
|
|
399
|
-
{
|
|
400
|
-
name: "key_id",
|
|
401
|
-
type: "TEXT",
|
|
402
|
-
primaryKey: true
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
name: "public_key",
|
|
406
|
-
type: "TEXT",
|
|
407
|
-
notNull: true
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
name: "created_at",
|
|
411
|
-
type: "INTEGER",
|
|
412
|
-
notNull: true
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
name: "retired_at",
|
|
416
|
-
type: "INTEGER"
|
|
417
|
-
}
|
|
418
|
-
];
|
|
419
|
-
var BackupEncryptionKeyStore = class {
|
|
420
|
-
store;
|
|
421
|
-
now;
|
|
422
|
-
declared = false;
|
|
423
|
-
keysKind;
|
|
424
|
-
constructor(store, now = Date.now, keysKind = null) {
|
|
425
|
-
this.store = store;
|
|
426
|
-
this.now = now;
|
|
427
|
-
this.keysKind = keysKind;
|
|
428
|
-
}
|
|
429
|
-
async ensureDeclared() {
|
|
430
|
-
if (this.keysKind !== null) return;
|
|
431
|
-
if (this.declared) return;
|
|
432
|
-
await this.store.declareCollection({
|
|
433
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
434
|
-
columns: COLUMNS$1
|
|
435
|
-
});
|
|
436
|
-
this.declared = true;
|
|
437
|
-
}
|
|
438
|
-
/** Every key, newest first. */
|
|
439
|
-
async list() {
|
|
440
|
-
await this.ensureDeclared();
|
|
441
|
-
const kind = this.keysKind;
|
|
442
|
-
if (kind !== null) {
|
|
443
|
-
const rows = await (0, import_read_all_rows.readAllRows)(kind);
|
|
444
|
-
rows.sort((a, b) => b.data.createdAt - a.data.createdAt);
|
|
445
|
-
const out = [];
|
|
446
|
-
for (const row of rows) {
|
|
447
|
-
const record = bodyToRecord(row.id, row.data);
|
|
448
|
-
if (record !== null) out.push(record);
|
|
449
|
-
}
|
|
450
|
-
return out;
|
|
451
|
-
}
|
|
452
|
-
const rows = await this.store.query({
|
|
453
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
454
|
-
filter: { orderBy: {
|
|
455
|
-
field: "created_at",
|
|
456
|
-
direction: "desc"
|
|
457
|
-
} }
|
|
458
|
-
});
|
|
459
|
-
const out = [];
|
|
460
|
-
for (const row of rows) {
|
|
461
|
-
const record = toRecord(row.data);
|
|
462
|
-
if (record !== null) out.push(record);
|
|
463
|
-
}
|
|
464
|
-
return out;
|
|
465
|
-
}
|
|
466
|
-
/** The key new archives are encrypted to; `null` = encryption off. */
|
|
467
|
-
async active() {
|
|
468
|
-
return (await this.list()).find((k) => k.retiredAt === null) ?? null;
|
|
469
|
-
}
|
|
470
|
-
/** Make `publicKey` the active key; the previous one is retired, kept listed. */
|
|
471
|
-
async activate(input) {
|
|
472
|
-
const parsed = parseBackupPublicKey(input.publicKey);
|
|
473
|
-
const t = this.now();
|
|
474
|
-
await this.retireActive(t);
|
|
475
|
-
const record = {
|
|
476
|
-
keyId: parsed.keyId,
|
|
477
|
-
publicKey: input.publicKey.trim(),
|
|
478
|
-
createdAt: t,
|
|
479
|
-
retiredAt: null
|
|
480
|
-
};
|
|
481
|
-
await this.write(record);
|
|
482
|
-
return record;
|
|
483
|
-
}
|
|
484
|
-
/** Encryption off: the active key is retired. Archives already made keep needing it. */
|
|
485
|
-
async disable() {
|
|
486
|
-
await this.retireActive(this.now());
|
|
487
|
-
}
|
|
488
|
-
async retireActive(at) {
|
|
489
|
-
for (const key of await this.list()) if (key.retiredAt === null) await this.write({
|
|
490
|
-
...key,
|
|
491
|
-
retiredAt: at
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
async write(record) {
|
|
495
|
-
await this.ensureDeclared();
|
|
496
|
-
const kind = this.keysKind;
|
|
497
|
-
if (kind !== null) {
|
|
498
|
-
const body = {
|
|
499
|
-
keyId: record.keyId,
|
|
500
|
-
publicKey: record.publicKey,
|
|
501
|
-
createdAt: record.createdAt,
|
|
502
|
-
retiredAt: record.retiredAt
|
|
503
|
-
};
|
|
504
|
-
const data = backupOrchestratorRecordKinds["encryption-keys"].schema.parse(body);
|
|
505
|
-
await kind.put({
|
|
506
|
-
id: record.keyId,
|
|
507
|
-
data
|
|
508
|
-
});
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
await this.store.deleteWhere({
|
|
512
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
513
|
-
filter: { where: { key_id: record.keyId } }
|
|
514
|
-
});
|
|
515
|
-
await this.store.insert({
|
|
516
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
517
|
-
record: {
|
|
518
|
-
id: record.keyId,
|
|
519
|
-
data: {
|
|
520
|
-
key_id: record.keyId,
|
|
521
|
-
public_key: record.publicKey,
|
|
522
|
-
created_at: record.createdAt,
|
|
523
|
-
retired_at: record.retiredAt
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
function bodyToRecord(keyId, body) {
|
|
530
|
-
if (!keyId) return null;
|
|
531
|
-
return {
|
|
532
|
-
keyId: body.keyId,
|
|
533
|
-
publicKey: body.publicKey,
|
|
534
|
-
createdAt: body.createdAt,
|
|
535
|
-
retiredAt: body.retiredAt
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
|
-
function toRecord(row) {
|
|
539
|
-
const keyId = row["key_id"];
|
|
540
|
-
const publicKey = row["public_key"];
|
|
541
|
-
const createdAt = row["created_at"];
|
|
542
|
-
if (typeof keyId !== "string" || typeof publicKey !== "string") return null;
|
|
543
|
-
const retired = row["retired_at"];
|
|
544
|
-
return {
|
|
545
|
-
keyId,
|
|
546
|
-
publicKey,
|
|
547
|
-
createdAt: typeof createdAt === "number" ? createdAt : Number(createdAt ?? 0),
|
|
548
|
-
retiredAt: typeof retired === "number" ? retired : null
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
//#endregion
|
|
552
|
-
//#region src/builtins/backup-orchestrator/seed-marker-store.ts
|
|
553
|
-
/**
|
|
554
|
-
* @durable class=config owner=backup-orchestrator
|
|
555
|
-
* write="the orchestrator inserts one row per seed id the first time that
|
|
556
|
-
* seed is created (or found already created); never updated"
|
|
557
|
-
* retention="none — one tiny row per seed ever made; deleting it lets the
|
|
558
|
-
* seed be re-created once more on the next boot"
|
|
559
|
-
*/
|
|
560
|
-
var BACKUP_SEED_MARKERS_COLLECTION = "backup_seed_markers";
|
|
561
|
-
var COLUMNS = [{
|
|
562
|
-
name: "seed_id",
|
|
563
|
-
type: "TEXT",
|
|
564
|
-
primaryKey: true
|
|
565
|
-
}, {
|
|
566
|
-
name: "seeded_at",
|
|
567
|
-
type: "INTEGER",
|
|
568
|
-
notNull: true
|
|
569
|
-
}];
|
|
570
|
-
var BackupSeedMarkerStore = class {
|
|
571
|
-
store;
|
|
572
|
-
now;
|
|
573
|
-
declared = false;
|
|
574
|
-
markersKind;
|
|
575
|
-
constructor(store, now = Date.now, markersKind = null) {
|
|
576
|
-
this.store = store;
|
|
577
|
-
this.now = now;
|
|
578
|
-
this.markersKind = markersKind;
|
|
579
|
-
}
|
|
580
|
-
async ensureDeclared() {
|
|
581
|
-
if (this.markersKind !== null) return;
|
|
582
|
-
if (this.declared) return;
|
|
583
|
-
await this.store.declareCollection({
|
|
584
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
585
|
-
columns: COLUMNS
|
|
586
|
-
});
|
|
587
|
-
this.declared = true;
|
|
588
|
-
}
|
|
589
|
-
async has(seedId) {
|
|
590
|
-
await this.ensureDeclared();
|
|
591
|
-
const kind = this.markersKind;
|
|
592
|
-
if (kind !== null) return await kind.get(seedId) !== null;
|
|
593
|
-
return (await this.store.query({
|
|
594
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
595
|
-
filter: {
|
|
596
|
-
where: { seed_id: seedId },
|
|
597
|
-
limit: 1
|
|
598
|
-
}
|
|
599
|
-
})).length > 0;
|
|
600
|
-
}
|
|
601
|
-
async mark(seedId) {
|
|
602
|
-
await this.ensureDeclared();
|
|
603
|
-
if (await this.has(seedId)) return;
|
|
604
|
-
const kind = this.markersKind;
|
|
605
|
-
if (kind !== null) {
|
|
606
|
-
const body = { seededAt: this.now() };
|
|
607
|
-
const data = backupOrchestratorRecordKinds["seed-markers"].schema.parse(body);
|
|
608
|
-
await kind.put({
|
|
609
|
-
id: seedId,
|
|
610
|
-
data
|
|
611
|
-
});
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
await this.store.insert({
|
|
615
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
616
|
-
record: {
|
|
617
|
-
id: seedId,
|
|
618
|
-
data: {
|
|
619
|
-
seed_id: seedId,
|
|
620
|
-
seeded_at: this.now()
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
//#endregion
|
|
627
|
-
//#region src/builtins/backup-orchestrator/record-kinds.ts
|
|
628
|
-
var BACKUP_SCHEDULES_LEGACY = "backup_schedules";
|
|
629
|
-
var BACKUP_DESTINATION_POLICIES_LEGACY = "backup_destination_policies";
|
|
630
|
-
var BackupScheduleBodySchema = z.object({
|
|
631
|
-
label: z.string(),
|
|
632
|
-
cron: z.string(),
|
|
633
|
-
enabled: z.boolean(),
|
|
634
|
-
locationIds: z.array(z.string()).readonly(),
|
|
635
|
-
retentionCount: z.number(),
|
|
636
|
-
dataSources: z.array(z.string()).readonly().optional(),
|
|
637
|
-
databases: z.array(DataStoreDatabaseSchema).readonly().optional(),
|
|
638
|
-
lastAttemptAt: z.number().optional(),
|
|
639
|
-
lastSuccessAt: z.number().optional(),
|
|
640
|
-
lastError: z.string().optional()
|
|
641
|
-
});
|
|
642
|
-
var BackupDestinationPolicyBodySchema = z.object({
|
|
643
|
-
enabled: z.boolean(),
|
|
644
|
-
retentionCount: z.number(),
|
|
645
|
-
label: z.string().optional(),
|
|
646
|
-
lastAttemptAt: z.number().optional(),
|
|
647
|
-
lastError: z.string().optional()
|
|
648
|
-
});
|
|
649
|
-
var BackupEncryptionKeyBodySchema = z.object({
|
|
650
|
-
keyId: z.string(),
|
|
651
|
-
publicKey: z.string(),
|
|
652
|
-
createdAt: z.number(),
|
|
653
|
-
retiredAt: z.number().nullable()
|
|
654
|
-
});
|
|
655
|
-
var BackupSeedMarkerBodySchema = z.object({ seededAt: z.number() });
|
|
656
|
-
var _backupOrchestratorRecordKinds = defineRecordKinds({
|
|
657
|
-
schedules: {
|
|
658
|
-
schema: BackupScheduleBodySchema,
|
|
659
|
-
class: "config",
|
|
660
|
-
writeTrigger: "operator upsert/delete; orchestrator stamps lastAttempt/success/error",
|
|
661
|
-
device: "none",
|
|
662
|
-
at: "none",
|
|
663
|
-
indexes: [{
|
|
664
|
-
name: "enabled",
|
|
665
|
-
fields: ["enabled"]
|
|
666
|
-
}],
|
|
667
|
-
retention: { none: "operator delete only" },
|
|
668
|
-
adoptsFrom: BACKUP_SCHEDULES_LEGACY,
|
|
669
|
-
entry: {
|
|
670
|
-
title: "Backup schedules",
|
|
671
|
-
nameField: "label"
|
|
672
|
-
}
|
|
673
|
-
},
|
|
674
|
-
"destination-policies": {
|
|
675
|
-
schema: BackupDestinationPolicyBodySchema,
|
|
676
|
-
class: "config",
|
|
677
|
-
writeTrigger: "ensureDefault, operator upsert, recordAttempt after each archive write",
|
|
678
|
-
device: "none",
|
|
679
|
-
at: "none",
|
|
680
|
-
retention: { none: "row outlives location; ensureDefault recreates" },
|
|
681
|
-
adoptsFrom: BACKUP_DESTINATION_POLICIES_LEGACY
|
|
682
|
-
},
|
|
683
|
-
"encryption-keys": {
|
|
684
|
-
schema: BackupEncryptionKeyBodySchema,
|
|
685
|
-
class: "config",
|
|
686
|
-
writeTrigger: "setupEncryption activate; disableEncryption retires active row",
|
|
687
|
-
device: "none",
|
|
688
|
-
at: "none",
|
|
689
|
-
retention: { none: "retired keys kept for archive decryption hints" },
|
|
690
|
-
adoptsFrom: BACKUP_ENCRYPTION_KEYS_COLLECTION
|
|
691
|
-
},
|
|
692
|
-
"seed-markers": {
|
|
693
|
-
schema: BackupSeedMarkerBodySchema,
|
|
694
|
-
class: "config",
|
|
695
|
-
writeTrigger: "mark() once per seed id after seed landed",
|
|
696
|
-
device: "none",
|
|
697
|
-
at: "none",
|
|
698
|
-
retention: { none: "one row per seed id ever" },
|
|
699
|
-
adoptsFrom: BACKUP_SEED_MARKERS_COLLECTION
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
var backupOrchestratorRecordKinds = _backupOrchestratorRecordKinds;
|
|
703
|
-
var backupSchedulesRecordKind = _backupOrchestratorRecordKinds.schedules;
|
|
704
|
-
var backupDestinationPoliciesRecordKind = _backupOrchestratorRecordKinds["destination-policies"];
|
|
705
|
-
var backupEncryptionKeysRecordKind = _backupOrchestratorRecordKinds["encryption-keys"];
|
|
706
|
-
var backupSeedMarkersRecordKind = _backupOrchestratorRecordKinds["seed-markers"];
|
|
707
|
-
function backupRecordStoresOf(records) {
|
|
708
|
-
return {
|
|
709
|
-
schedules: records.kind(backupSchedulesRecordKind),
|
|
710
|
-
destinationPolicies: records.kind(backupDestinationPoliciesRecordKind),
|
|
711
|
-
encryptionKeys: records.kind(backupEncryptionKeysRecordKind),
|
|
712
|
-
seedMarkers: records.kind(backupSeedMarkersRecordKind)
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
//#endregion
|
|
716
469
|
//#region node_modules/tar/dist/esm/index.min.js
|
|
717
470
|
var Mr = Object.defineProperty;
|
|
718
471
|
var Br = (s, t) => {
|
|
@@ -4457,4 +4210,4 @@ async function prepareRestoreArchive(input) {
|
|
|
4457
4210
|
}
|
|
4458
4211
|
}
|
|
4459
4212
|
//#endregion
|
|
4460
|
-
export {
|
|
4213
|
+
export { backupRecordStoresOf as _, BackupSnapshotRefusedError as a, BackupDecryptError as c, ENCRYPTED_BACKUP_SUFFIX as d, generateBackupKeyPair as f, backupOrchestratorRecordKinds as g, readBackupEncryptionHeader as h, BackupCancelledError as i, BackupKeyFormatError as l, parseBackupSecretKey as m, precheckRestoreKey as n, DEFAULT_BACKUP_DATABASES as o, parseBackupPublicKey as p, prepareRestoreArchive as r, SystemBackupService as s, BackupKeyRequiredError as t, BackupKeyMismatchError as u };
|