@substrat-run/kernel 0.139.0 → 0.141.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-log-ddl.d.ts +21 -0
- package/dist/admin-log-ddl.d.ts.map +1 -0
- package/dist/admin-log-ddl.js +32 -0
- package/dist/admin-log-ddl.js.map +1 -0
- package/dist/attachment-extractor.d.ts +12 -1
- package/dist/attachment-extractor.d.ts.map +1 -1
- package/dist/attachment-extractor.js +10 -5
- package/dist/attachment-extractor.js.map +1 -1
- package/dist/audit-outcome.d.ts +149 -0
- package/dist/audit-outcome.d.ts.map +1 -0
- package/dist/audit-outcome.js +233 -0
- package/dist/audit-outcome.js.map +1 -0
- package/dist/capability.d.ts +5 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +17 -8
- package/dist/capability.js.map +1 -1
- package/dist/connect-links.d.ts +91 -0
- package/dist/connect-links.d.ts.map +1 -0
- package/dist/connect-links.js +189 -0
- package/dist/connect-links.js.map +1 -0
- package/dist/connect-state.d.ts +12 -3
- package/dist/connect-state.d.ts.map +1 -1
- package/dist/connect-state.js +8 -3
- package/dist/connect-state.js.map +1 -1
- package/dist/derived-object.d.ts +14 -0
- package/dist/derived-object.d.ts.map +1 -0
- package/dist/derived-object.js +2 -0
- package/dist/derived-object.js.map +1 -0
- package/dist/derived-objects.d.ts +108 -0
- package/dist/derived-objects.d.ts.map +1 -0
- package/dist/derived-objects.js +199 -0
- package/dist/derived-objects.js.map +1 -0
- package/dist/email-intent.d.ts +56 -0
- package/dist/email-intent.d.ts.map +1 -0
- package/dist/email-intent.js +71 -0
- package/dist/email-intent.js.map +1 -0
- package/dist/entity-edges.d.ts +6 -1
- package/dist/entity-edges.d.ts.map +1 -1
- package/dist/entity-edges.js +13 -0
- package/dist/entity-edges.js.map +1 -1
- package/dist/entity-grant-shape.d.ts +94 -0
- package/dist/entity-grant-shape.d.ts.map +1 -0
- package/dist/entity-grant-shape.js +329 -0
- package/dist/entity-grant-shape.js.map +1 -0
- package/dist/entity-grant.d.ts +45 -0
- package/dist/entity-grant.d.ts.map +1 -0
- package/dist/entity-grant.js +71 -0
- package/dist/entity-grant.js.map +1 -0
- package/dist/entity-state-reads.d.ts +4 -7
- package/dist/entity-state-reads.d.ts.map +1 -1
- package/dist/entity-state-reads.js +13 -57
- package/dist/entity-state-reads.js.map +1 -1
- package/dist/entity-state.d.ts +37 -10
- package/dist/entity-state.d.ts.map +1 -1
- package/dist/entity-state.js +80 -69
- package/dist/entity-state.js.map +1 -1
- package/dist/entity-trash.d.ts +245 -0
- package/dist/entity-trash.d.ts.map +1 -0
- package/dist/entity-trash.js +380 -0
- package/dist/entity-trash.js.map +1 -0
- package/dist/grant-scoped-read.d.ts +41 -0
- package/dist/grant-scoped-read.d.ts.map +1 -0
- package/dist/grant-scoped-read.js +100 -0
- package/dist/grant-scoped-read.js.map +1 -0
- package/dist/index.d.ts +35 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/kernel-outbox.d.ts +14 -0
- package/dist/kernel-outbox.d.ts.map +1 -0
- package/dist/kernel-outbox.js +37 -0
- package/dist/kernel-outbox.js.map +1 -0
- package/dist/list-index.d.ts +11 -2
- package/dist/list-index.d.ts.map +1 -1
- package/dist/list-index.js +29 -21
- package/dist/list-index.js.map +1 -1
- package/dist/mail-sender.d.ts +78 -0
- package/dist/mail-sender.d.ts.map +1 -0
- package/dist/mail-sender.js +2 -0
- package/dist/mail-sender.js.map +1 -0
- package/dist/membership-executor.d.ts +0 -52
- package/dist/membership-executor.d.ts.map +1 -1
- package/dist/membership-executor.js +19 -59
- package/dist/membership-executor.js.map +1 -1
- package/dist/migration-digest.d.ts +161 -0
- package/dist/migration-digest.d.ts.map +1 -0
- package/dist/migration-digest.js +237 -0
- package/dist/migration-digest.js.map +1 -0
- package/dist/module-erasure.d.ts +156 -0
- package/dist/module-erasure.d.ts.map +1 -0
- package/dist/module-erasure.js +440 -0
- package/dist/module-erasure.js.map +1 -0
- package/dist/peer.d.ts +9 -1
- package/dist/peer.d.ts.map +1 -1
- package/dist/peer.js +29 -0
- package/dist/peer.js.map +1 -1
- package/dist/permission-checker.d.ts +6 -0
- package/dist/permission-checker.d.ts.map +1 -1
- package/dist/permission-checker.js.map +1 -1
- package/dist/permission-eval.d.ts +10 -1
- package/dist/permission-eval.d.ts.map +1 -1
- package/dist/permission-eval.js +51 -2
- package/dist/permission-eval.js.map +1 -1
- package/dist/platform-sweep.d.ts +1 -1
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +5 -0
- package/dist/platform-sweep.js.map +1 -1
- package/dist/scope-copy-ledger.d.ts +79 -0
- package/dist/scope-copy-ledger.d.ts.map +1 -0
- package/dist/scope-copy-ledger.js +82 -0
- package/dist/scope-copy-ledger.js.map +1 -0
- package/dist/scope-host.d.ts +402 -25
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js +74 -5
- package/dist/scope-host.js.map +1 -1
- package/dist/search-index.d.ts +8 -0
- package/dist/search-index.d.ts.map +1 -1
- package/dist/search-index.js +51 -21
- package/dist/search-index.js.map +1 -1
- package/dist/spine-guard.d.ts +7 -0
- package/dist/spine-guard.d.ts.map +1 -1
- package/dist/spine-guard.js +54 -6
- package/dist/spine-guard.js.map +1 -1
- package/dist/spine-restore.d.ts.map +1 -1
- package/dist/spine-restore.js +5 -0
- package/dist/spine-restore.js.map +1 -1
- package/dist/sql-statements.d.ts +71 -0
- package/dist/sql-statements.d.ts.map +1 -0
- package/dist/sql-statements.js +191 -0
- package/dist/sql-statements.js.map +1 -0
- package/dist/subject-redaction.d.ts +9 -1
- package/dist/subject-redaction.d.ts.map +1 -1
- package/dist/subject-redaction.js.map +1 -1
- package/dist/system-switch-record.d.ts +3 -0
- package/dist/system-switch-record.d.ts.map +1 -1
- package/dist/system-switch-record.js +2 -0
- package/dist/system-switch-record.js.map +1 -1
- package/dist/table-ownership.d.ts +103 -0
- package/dist/table-ownership.d.ts.map +1 -0
- package/dist/table-ownership.js +285 -0
- package/dist/table-ownership.js.map +1 -0
- package/dist/timeline.d.ts +4 -4
- package/dist/timeline.js +4 -4
- package/dist/visible-continuation.d.ts +38 -0
- package/dist/visible-continuation.d.ts.map +1 -0
- package/dist/visible-continuation.js +162 -0
- package/dist/visible-continuation.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ScopeCopyMoveConfirmation, ScopeScriptCopy } from './scope-host.js';
|
|
2
|
+
/**
|
|
3
|
+
* The directory's copy ledger (#1722), in the one SQL grammar both adapters run: the pure
|
|
4
|
+
* adapter's directory and the control-plane Durable Object build the same `scope_script_copies`
|
|
5
|
+
* table (`lint:spine-ddl` holds them to it), so the statements that lease, confirm and claim
|
|
6
|
+
* its entries live here rather than being spelled twice.
|
|
7
|
+
*
|
|
8
|
+
* A pending entry belongs to the move that recorded it until its lease runs out. Two things
|
|
9
|
+
* read that lease, and they are what make crash recovery safe against a move that is merely
|
|
10
|
+
* slow rather than dead:
|
|
11
|
+
*
|
|
12
|
+
* - The bind that routes the scope onto the move's destination (`COPY_MOVE_LIVE_PREDICATE`)
|
|
13
|
+
* lands only while every entry of the move is pending, unclaimed and inside its lease, and
|
|
14
|
+
* settles them in the same write (`COPY_MOVE_CONFIRM_SQL`).
|
|
15
|
+
* - A sweep claims only an entry whose lease has run out (`COPY_EXPIRED_SQL` then
|
|
16
|
+
* `COPY_CLAIM_SQL`), which no bind can confirm any more.
|
|
17
|
+
*
|
|
18
|
+
* So exactly one of them acts on a move: the bind before the lease ends, or the sweep after.
|
|
19
|
+
*/
|
|
20
|
+
/** Appended to a conditional bind's `UPDATE scopes … WHERE`. Params: `copyMoveLiveParams`. */
|
|
21
|
+
export declare const COPY_MOVE_LIVE_PREDICATE = "\n AND EXISTS (SELECT 1 FROM scope_script_copies AS move\n WHERE move.tenant_id = scopes.tenant_id AND move.scope_id = scopes.scope_id AND move.move_id = ?)\n AND NOT EXISTS (SELECT 1 FROM scope_script_copies AS move\n WHERE move.tenant_id = scopes.tenant_id AND move.scope_id = scopes.scope_id AND move.move_id = ?\n AND (move.state <> 'pending' OR move.lease_owner IS NOT NULL\n OR move.lease_until IS NULL OR move.lease_until <= ?))";
|
|
22
|
+
export declare const copyMoveLiveParams: (confirm: ScopeCopyMoveConfirmation, now: string) => string[];
|
|
23
|
+
/**
|
|
24
|
+
* Run in the bind's own transaction once its row update landed: the destination is now the
|
|
25
|
+
* route, and the source becomes the state the confirmation names, with the marker its export
|
|
26
|
+
* read. An adopt or rebind names `eligible`, so the sweep wipes the old copy under its fence
|
|
27
|
+
* (the old copy is no backout; rollback is a snapshot taken first). A carry names `retained`
|
|
28
|
+
* and promotes the source itself once it has ruled out an overtaken destination. A source on a
|
|
29
|
+
* deployment that cannot fence a wipe stays `retained`. Params: `copyMoveConfirmParams`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const COPY_MOVE_CONFIRM_SQL = "\n UPDATE scope_script_copies SET\n state = CASE role WHEN 'destination' THEN 'done' ELSE ? END,\n load_stamp = CASE role WHEN 'destination' THEN load_stamp ELSE ? END,\n revision = CASE role WHEN 'destination' THEN revision ELSE ? END,\n last_attempt_at = ?\n WHERE tenant_id = ? AND scope_id = ? AND move_id = ? AND state = 'pending'";
|
|
32
|
+
export declare const copyMoveConfirmParams: (confirm: ScopeCopyMoveConfirmation, tenantId: string, scopeId: string, now: string) => (string | null)[];
|
|
33
|
+
/** Pending entries whose lease ran out before `?` (or that never had one), oldest first, `LIMIT ?`. */
|
|
34
|
+
export declare const COPY_EXPIRED_SQL = "\n SELECT tenant_id, scope_id, script_ref, move_id FROM scope_script_copies\n WHERE state = 'pending' AND (lease_until IS NULL OR lease_until <= ?)\n ORDER BY lease_until, tenant_id, scope_id, script_ref, move_id LIMIT ?";
|
|
35
|
+
/** Claim one expired entry, re-checked in the write. Params: owner, leaseUntil, the key, now. */
|
|
36
|
+
export declare const COPY_CLAIM_SQL = "\n UPDATE scope_script_copies SET lease_owner = ?, lease_until = ?\n WHERE tenant_id = ? AND scope_id = ? AND script_ref = ? AND move_id = ?\n AND state = 'pending' AND (lease_until IS NULL OR lease_until <= ?)";
|
|
37
|
+
/**
|
|
38
|
+
* The fence a copy move's restore carries into the destination's own store (#1722). The vertical
|
|
39
|
+
* that holds the destination has no reach to the directory, so the move's lease travels with
|
|
40
|
+
* the restore instead: the store refuses the load, inside the load's own transaction, once
|
|
41
|
+
* `notAfter` has passed, and writes nothing.
|
|
42
|
+
*
|
|
43
|
+
* `notAfter` sits a margin inside the move's lease (`copyRestoreFence`), and everything that could
|
|
44
|
+
* make a late restore wrong waits for that lease to end first. A sweep claims an entry only once
|
|
45
|
+
* its lease has run out. A reap claims the scope, and an erasure finalizes, only while no entry
|
|
46
|
+
* of any move is pending, so for an unconfirmed move only after that sweep. A restore that is
|
|
47
|
+
* not refused therefore committed before any of them, and one that would land after any of them
|
|
48
|
+
* is refused. The margin absorbs clock skew between the directory and the destination, and
|
|
49
|
+
* `moveId` and `erasureEpoch` name the move and the erasure state it was issued under.
|
|
50
|
+
*/
|
|
51
|
+
export interface CopyRestoreFence {
|
|
52
|
+
moveId: string;
|
|
53
|
+
notAfter: string;
|
|
54
|
+
erasureEpoch: number;
|
|
55
|
+
}
|
|
56
|
+
/** How far inside the lease a restore must commit: five minutes, or a quarter of a short lease. */
|
|
57
|
+
export declare const copyRestoreFenceMarginMs: (leaseMs: number) => number;
|
|
58
|
+
/** The fence for a move whose entries were recorded no earlier than `recordedAt` (epoch ms). */
|
|
59
|
+
export declare const copyRestoreFence: (moveId: string, recordedAt: number, leaseMs: number, erasureEpoch: number) => CopyRestoreFence;
|
|
60
|
+
/** Whether a restore carrying `fence` may no longer land at `now` (epoch ms). */
|
|
61
|
+
export declare const copyRestoreFenceLapsed: (fence: CopyRestoreFence, now: number) => boolean;
|
|
62
|
+
/** The refusal a lapsed fence answers with, the same words on every host. */
|
|
63
|
+
export declare const COPY_RESTORE_FENCE_LAPSED = "the copy move's lease ran out before its restore; nothing was loaded (#1722)";
|
|
64
|
+
/** A ledger row as both adapters read it. */
|
|
65
|
+
export interface ScopeScriptCopyRow {
|
|
66
|
+
tenant_id: string;
|
|
67
|
+
scope_id: string;
|
|
68
|
+
script_ref: string;
|
|
69
|
+
move_id: string;
|
|
70
|
+
state: string;
|
|
71
|
+
load_stamp: string | null;
|
|
72
|
+
revision: string | null;
|
|
73
|
+
role: string | null;
|
|
74
|
+
lease_until: string | null;
|
|
75
|
+
}
|
|
76
|
+
/** The columns `ScopeScriptCopyRow` names, for a read that does not take `SELECT *`. */
|
|
77
|
+
export declare const SCOPE_SCRIPT_COPY_COLUMNS = "tenant_id, scope_id, script_ref, move_id, state, load_stamp, revision, role, lease_until";
|
|
78
|
+
export declare const scopeScriptCopyOf: (r: ScopeScriptCopyRow) => ScopeScriptCopy;
|
|
79
|
+
//# sourceMappingURL=scope-copy-ledger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-copy-ledger.d.ts","sourceRoot":"","sources":["../src/scope-copy-ledger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElF;;;;;;;;;;;;;;;;;GAiBG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,wBAAwB,4cAM0B,CAAC;AAEhE,eAAO,MAAM,kBAAkB,YAAa,yBAAyB,OAAO,MAAM,KAAG,MAAM,EACpD,CAAC;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,kWAM2C,CAAC;AAE9E,eAAO,MAAM,qBAAqB,YACvB,yBAAyB,YAAY,MAAM,WAAW,MAAM,OAAO,MAAM,KACjF,CAAC,MAAM,GAAG,IAAI,CAAC,EAGjB,CAAC;AAEF,uGAAuG;AACvG,eAAO,MAAM,gBAAgB,oOAG4C,CAAC;AAE1E,iGAAiG;AACjG,eAAO,MAAM,cAAc,4NAG6C,CAAC;AAEzE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,YAAa,MAAM,KAAG,MAAuD,CAAC;AAEnH,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,WACnB,MAAM,cAAc,MAAM,WAAW,MAAM,gBAAgB,MAAM,KACxE,gBAID,CAAC;AAEH,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,UAAW,gBAAgB,OAAO,MAAM,KAAG,OAA2C,CAAC;AAE1H,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB,iFAAiF,CAAC;AAExH,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,wFAAwF;AACxF,eAAO,MAAM,yBAAyB,6FACsD,CAAC;AAE7F,eAAO,MAAM,iBAAiB,MAAO,kBAAkB,KAAG,eAUxD,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directory's copy ledger (#1722), in the one SQL grammar both adapters run: the pure
|
|
3
|
+
* adapter's directory and the control-plane Durable Object build the same `scope_script_copies`
|
|
4
|
+
* table (`lint:spine-ddl` holds them to it), so the statements that lease, confirm and claim
|
|
5
|
+
* its entries live here rather than being spelled twice.
|
|
6
|
+
*
|
|
7
|
+
* A pending entry belongs to the move that recorded it until its lease runs out. Two things
|
|
8
|
+
* read that lease, and they are what make crash recovery safe against a move that is merely
|
|
9
|
+
* slow rather than dead:
|
|
10
|
+
*
|
|
11
|
+
* - The bind that routes the scope onto the move's destination (`COPY_MOVE_LIVE_PREDICATE`)
|
|
12
|
+
* lands only while every entry of the move is pending, unclaimed and inside its lease, and
|
|
13
|
+
* settles them in the same write (`COPY_MOVE_CONFIRM_SQL`).
|
|
14
|
+
* - A sweep claims only an entry whose lease has run out (`COPY_EXPIRED_SQL` then
|
|
15
|
+
* `COPY_CLAIM_SQL`), which no bind can confirm any more.
|
|
16
|
+
*
|
|
17
|
+
* So exactly one of them acts on a move: the bind before the lease ends, or the sweep after.
|
|
18
|
+
*/
|
|
19
|
+
/** Appended to a conditional bind's `UPDATE scopes … WHERE`. Params: `copyMoveLiveParams`. */
|
|
20
|
+
export const COPY_MOVE_LIVE_PREDICATE = `
|
|
21
|
+
AND EXISTS (SELECT 1 FROM scope_script_copies AS move
|
|
22
|
+
WHERE move.tenant_id = scopes.tenant_id AND move.scope_id = scopes.scope_id AND move.move_id = ?)
|
|
23
|
+
AND NOT EXISTS (SELECT 1 FROM scope_script_copies AS move
|
|
24
|
+
WHERE move.tenant_id = scopes.tenant_id AND move.scope_id = scopes.scope_id AND move.move_id = ?
|
|
25
|
+
AND (move.state <> 'pending' OR move.lease_owner IS NOT NULL
|
|
26
|
+
OR move.lease_until IS NULL OR move.lease_until <= ?))`;
|
|
27
|
+
export const copyMoveLiveParams = (confirm, now) => [confirm.moveId, confirm.moveId, now];
|
|
28
|
+
/**
|
|
29
|
+
* Run in the bind's own transaction once its row update landed: the destination is now the
|
|
30
|
+
* route, and the source becomes the state the confirmation names, with the marker its export
|
|
31
|
+
* read. An adopt or rebind names `eligible`, so the sweep wipes the old copy under its fence
|
|
32
|
+
* (the old copy is no backout; rollback is a snapshot taken first). A carry names `retained`
|
|
33
|
+
* and promotes the source itself once it has ruled out an overtaken destination. A source on a
|
|
34
|
+
* deployment that cannot fence a wipe stays `retained`. Params: `copyMoveConfirmParams`.
|
|
35
|
+
*/
|
|
36
|
+
export const COPY_MOVE_CONFIRM_SQL = `
|
|
37
|
+
UPDATE scope_script_copies SET
|
|
38
|
+
state = CASE role WHEN 'destination' THEN 'done' ELSE ? END,
|
|
39
|
+
load_stamp = CASE role WHEN 'destination' THEN load_stamp ELSE ? END,
|
|
40
|
+
revision = CASE role WHEN 'destination' THEN revision ELSE ? END,
|
|
41
|
+
last_attempt_at = ?
|
|
42
|
+
WHERE tenant_id = ? AND scope_id = ? AND move_id = ? AND state = 'pending'`;
|
|
43
|
+
export const copyMoveConfirmParams = (confirm, tenantId, scopeId, now) => [
|
|
44
|
+
confirm.source, confirm.sourceMarker?.loadStamp ?? null, confirm.sourceMarker?.revision ?? null,
|
|
45
|
+
now, tenantId, scopeId, confirm.moveId,
|
|
46
|
+
];
|
|
47
|
+
/** Pending entries whose lease ran out before `?` (or that never had one), oldest first, `LIMIT ?`. */
|
|
48
|
+
export const COPY_EXPIRED_SQL = `
|
|
49
|
+
SELECT tenant_id, scope_id, script_ref, move_id FROM scope_script_copies
|
|
50
|
+
WHERE state = 'pending' AND (lease_until IS NULL OR lease_until <= ?)
|
|
51
|
+
ORDER BY lease_until, tenant_id, scope_id, script_ref, move_id LIMIT ?`;
|
|
52
|
+
/** Claim one expired entry, re-checked in the write. Params: owner, leaseUntil, the key, now. */
|
|
53
|
+
export const COPY_CLAIM_SQL = `
|
|
54
|
+
UPDATE scope_script_copies SET lease_owner = ?, lease_until = ?
|
|
55
|
+
WHERE tenant_id = ? AND scope_id = ? AND script_ref = ? AND move_id = ?
|
|
56
|
+
AND state = 'pending' AND (lease_until IS NULL OR lease_until <= ?)`;
|
|
57
|
+
/** How far inside the lease a restore must commit: five minutes, or a quarter of a short lease. */
|
|
58
|
+
export const copyRestoreFenceMarginMs = (leaseMs) => Math.min(5 * 60_000, Math.floor(leaseMs / 4));
|
|
59
|
+
/** The fence for a move whose entries were recorded no earlier than `recordedAt` (epoch ms). */
|
|
60
|
+
export const copyRestoreFence = (moveId, recordedAt, leaseMs, erasureEpoch) => ({
|
|
61
|
+
moveId,
|
|
62
|
+
notAfter: new Date(recordedAt + leaseMs - copyRestoreFenceMarginMs(leaseMs)).toISOString(),
|
|
63
|
+
erasureEpoch,
|
|
64
|
+
});
|
|
65
|
+
/** Whether a restore carrying `fence` may no longer land at `now` (epoch ms). */
|
|
66
|
+
export const copyRestoreFenceLapsed = (fence, now) => now > Date.parse(fence.notAfter);
|
|
67
|
+
/** The refusal a lapsed fence answers with, the same words on every host. */
|
|
68
|
+
export const COPY_RESTORE_FENCE_LAPSED = "the copy move's lease ran out before its restore; nothing was loaded (#1722)";
|
|
69
|
+
/** The columns `ScopeScriptCopyRow` names, for a read that does not take `SELECT *`. */
|
|
70
|
+
export const SCOPE_SCRIPT_COPY_COLUMNS = 'tenant_id, scope_id, script_ref, move_id, state, load_stamp, revision, role, lease_until';
|
|
71
|
+
export const scopeScriptCopyOf = (r) => ({
|
|
72
|
+
tenantId: r.tenant_id,
|
|
73
|
+
scopeId: r.scope_id,
|
|
74
|
+
scriptRef: r.script_ref,
|
|
75
|
+
moveId: r.move_id,
|
|
76
|
+
state: r.state,
|
|
77
|
+
loadStamp: r.load_stamp,
|
|
78
|
+
revision: r.revision,
|
|
79
|
+
role: r.role === 'source' || r.role === 'destination' ? r.role : null,
|
|
80
|
+
leaseUntil: r.lease_until,
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=scope-copy-ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-copy-ledger.js","sourceRoot":"","sources":["../src/scope-copy-ledger.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8FAA8F;AAC9F,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;+DAMuB,CAAC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAkC,EAAE,GAAW,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