@coffre/db 0.14.4 → 0.15.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 +2 -1
- package/dist/change-records-_fKvahvs.js +55 -0
- package/dist/connect.d.ts +22 -10
- package/dist/connect.js +74 -12
- package/dist/database-CVteLhp1.d.ts +410 -0
- package/dist/{database-BadNeeN-.js → database-D55ENPX-.js} +46 -25
- package/dist/dialect.d.ts +4 -3
- package/dist/dialect.js +14 -5
- package/dist/grants.d.ts +4 -4
- package/dist/grants.js +4 -4
- package/dist/hyperdrive.d.ts +48 -23
- package/dist/hyperdrive.js +168 -91
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/log-DaD7fyUq.d.ts +722 -0
- package/dist/log.d.ts +2 -596
- package/dist/log.js +224 -10
- package/dist/migrate.d.ts +43 -3
- package/dist/migrate.js +149 -29
- package/dist/migrations/postgres/0021_prune_vault_releases.sql +19 -0
- package/dist/migrations/postgres/0022_log_015.sql +672 -0
- package/dist/migrations/postgres/0023_change_path.sql +153 -0
- package/dist/migrations/postgres/0024_use_015.sql +556 -0
- package/dist/migrations/postgres/0025_app_change.sql +221 -0
- package/dist/migrations/postgres/0026_issue_lock.sql +106 -0
- package/dist/migrations/postgres/0027_retention.sql +118 -0
- package/dist/migrations/postgres/0028_use_stalls.sql +594 -0
- package/dist/migrations/postgres/0029_use_objects.sql +887 -0
- package/dist/migrations/postgres/0030_unarchive_restores.sql +259 -0
- package/dist/migrations/postgres/0031_app_read.sql +65 -0
- package/dist/migrations/postgres/0032_secrets_live_index.sql +4 -0
- package/dist/migrations/postgres/0033_use_generations.sql +582 -0
- package/dist/migrations/postgres/0034_vault_credentials.sql +153 -0
- package/dist/migrations/postgres/0035_first_days.sql +3 -0
- package/dist/migrations/postgres/0036_vault_issues.sql +91 -0
- package/dist/migrations/postgres/0037_vault_bindings.sql +271 -0
- package/dist/migrations/postgres/0040_binding_origin.sql +159 -0
- package/dist/migrations/postgres/0041_cutover.sql +132 -0
- package/dist/migrations/postgres/0042_sign_in_index.sql +7 -0
- package/dist/migrations/postgres/0043_issue_revoke_index.sql +4 -0
- package/dist/migrations/postgres/0044_use_by_name.sql +705 -0
- package/dist/migrations/postgres/0045_decide_first.sql +878 -0
- package/dist/migrations/postgres/0046_way_in_uses.sql +1149 -0
- package/dist/migrations/postgres/0047_cutover_finish.sql +268 -0
- package/dist/migrations/postgres/0048_use_batch.sql +59 -0
- package/dist/migrations/postgres/0049_reads.sql +171 -0
- package/dist/migrations/postgres/meta/0021_snapshot.json +3334 -0
- package/dist/migrations/postgres/meta/0022_snapshot.json +3831 -0
- package/dist/migrations/postgres/meta/0023_snapshot.json +3831 -0
- package/dist/migrations/postgres/meta/0024_snapshot.json +3831 -0
- package/dist/migrations/postgres/meta/0025_snapshot.json +3831 -0
- package/dist/migrations/postgres/meta/0026_snapshot.json +3831 -0
- package/dist/migrations/postgres/meta/0027_snapshot.json +3853 -0
- package/dist/migrations/postgres/meta/0028_snapshot.json +3853 -0
- package/dist/migrations/postgres/meta/0029_snapshot.json +3859 -0
- package/dist/migrations/postgres/meta/0030_snapshot.json +3859 -0
- package/dist/migrations/postgres/meta/0031_snapshot.json +3859 -0
- package/dist/migrations/postgres/meta/0032_snapshot.json +3875 -0
- package/dist/migrations/postgres/meta/0033_snapshot.json +3875 -0
- package/dist/migrations/postgres/meta/0034_snapshot.json +3875 -0
- package/dist/migrations/postgres/meta/0035_snapshot.json +3875 -0
- package/dist/migrations/postgres/meta/0036_snapshot.json +3875 -0
- package/dist/migrations/postgres/meta/0037_snapshot.json +3875 -0
- package/dist/migrations/postgres/meta/0038_snapshot.json +3881 -0
- package/dist/migrations/postgres/meta/0039_snapshot.json +3881 -0
- package/dist/migrations/postgres/meta/0040_snapshot.json +3931 -0
- package/dist/migrations/postgres/meta/0041_snapshot.json +3981 -0
- package/dist/migrations/postgres/meta/0042_snapshot.json +3981 -0
- package/dist/migrations/postgres/meta/0043_snapshot.json +3981 -0
- package/dist/migrations/postgres/meta/0044_snapshot.json +3991 -0
- package/dist/migrations/postgres/meta/0045_snapshot.json +3997 -0
- package/dist/migrations/postgres/meta/0046_snapshot.json +3997 -0
- package/dist/migrations/postgres/meta/0047_snapshot.json +4234 -0
- package/dist/migrations/postgres/meta/_journal.json +189 -0
- package/dist/migrations/sqlite/0018_log_015.sql +84 -0
- package/dist/migrations/sqlite/0019_retention.sql +2 -0
- package/dist/migrations/sqlite/0020_ended_references.sql +1 -0
- package/dist/migrations/sqlite/0021_secrets_live_index.sql +1 -0
- package/dist/migrations/sqlite/0022_binding_origin.sql +1 -0
- package/dist/migrations/sqlite/0023_sign_in_index.sql +2 -0
- package/dist/migrations/sqlite/0024_issue_revoke_index.sql +2 -0
- package/dist/migrations/sqlite/0025_way_in_uses.sql +42 -0
- package/dist/migrations/sqlite/0026_cutover_finish.sql +11 -0
- package/dist/migrations/sqlite/0027_reads.sql +38 -0
- package/dist/migrations/sqlite/meta/0018_snapshot.json +3529 -0
- package/dist/migrations/sqlite/meta/0019_snapshot.json +3538 -0
- package/dist/migrations/sqlite/meta/0020_snapshot.json +3545 -0
- package/dist/migrations/sqlite/meta/0021_snapshot.json +3553 -0
- package/dist/migrations/sqlite/meta/0022_snapshot.json +3560 -0
- package/dist/migrations/sqlite/meta/0023_snapshot.json +3579 -0
- package/dist/migrations/sqlite/meta/0024_snapshot.json +3598 -0
- package/dist/migrations/sqlite/meta/0025_snapshot.json +3609 -0
- package/dist/migrations/sqlite/meta/0026_snapshot.json +3616 -0
- package/dist/migrations/sqlite/meta/0027_snapshot.json +3834 -0
- package/dist/migrations/sqlite/meta/_journal.json +70 -0
- package/dist/platform-Y3gICK6n.d.ts +58 -0
- package/dist/portable.d.ts +2 -2
- package/dist/postgres-BI3xTnyw.js +1718 -0
- package/dist/postgres-platform-node.d.ts +14 -0
- package/dist/postgres-platform-node.js +21 -0
- package/dist/postgres-platform-workerd.d.ts +61 -0
- package/dist/postgres-platform-workerd.js +163 -0
- package/dist/{schema-z8GcN_Xu.d.ts → schema-DgoPqqsI.d.ts} +1329 -9
- package/dist/schema-sqlite.d.ts +1308 -8
- package/dist/schema-sqlite.js +156 -20
- package/dist/schema-version.d.ts +1 -1
- package/dist/schema-version.js +261 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +229 -22
- package/package.json +13 -5
- package/src/active-subject.ts +9 -0
- package/src/change-records.ts +38 -0
- package/src/connect.ts +67 -13
- package/src/database.ts +67 -51
- package/src/dialect.ts +17 -8
- package/src/grants.ts +3 -3
- package/src/hyperdrive.ts +181 -104
- package/src/log.ts +244 -11
- package/src/migrate.ts +157 -30
- package/src/migrations/postgres/0021_prune_vault_releases.sql +19 -0
- package/src/migrations/postgres/0022_log_015.sql +672 -0
- package/src/migrations/postgres/0023_change_path.sql +153 -0
- package/src/migrations/postgres/0024_use_015.sql +556 -0
- package/src/migrations/postgres/0025_app_change.sql +221 -0
- package/src/migrations/postgres/0026_issue_lock.sql +106 -0
- package/src/migrations/postgres/0027_retention.sql +118 -0
- package/src/migrations/postgres/0028_use_stalls.sql +594 -0
- package/src/migrations/postgres/0029_use_objects.sql +887 -0
- package/src/migrations/postgres/0030_unarchive_restores.sql +259 -0
- package/src/migrations/postgres/0031_app_read.sql +65 -0
- package/src/migrations/postgres/0032_secrets_live_index.sql +4 -0
- package/src/migrations/postgres/0033_use_generations.sql +582 -0
- package/src/migrations/postgres/0034_vault_credentials.sql +153 -0
- package/src/migrations/postgres/0035_first_days.sql +3 -0
- package/src/migrations/postgres/0036_vault_issues.sql +91 -0
- package/src/migrations/postgres/0037_vault_bindings.sql +271 -0
- package/src/migrations/postgres/0040_binding_origin.sql +159 -0
- package/src/migrations/postgres/0041_cutover.sql +132 -0
- package/src/migrations/postgres/0042_sign_in_index.sql +7 -0
- package/src/migrations/postgres/0043_issue_revoke_index.sql +4 -0
- package/src/migrations/postgres/0044_use_by_name.sql +705 -0
- package/src/migrations/postgres/0045_decide_first.sql +878 -0
- package/src/migrations/postgres/0046_way_in_uses.sql +1149 -0
- package/src/migrations/postgres/0047_cutover_finish.sql +268 -0
- package/src/migrations/postgres/0048_use_batch.sql +59 -0
- package/src/migrations/postgres/0049_reads.sql +171 -0
- package/src/migrations/postgres/meta/0021_snapshot.json +3334 -0
- package/src/migrations/postgres/meta/0022_snapshot.json +3831 -0
- package/src/migrations/postgres/meta/0023_snapshot.json +3831 -0
- package/src/migrations/postgres/meta/0024_snapshot.json +3831 -0
- package/src/migrations/postgres/meta/0025_snapshot.json +3831 -0
- package/src/migrations/postgres/meta/0026_snapshot.json +3831 -0
- package/src/migrations/postgres/meta/0027_snapshot.json +3853 -0
- package/src/migrations/postgres/meta/0028_snapshot.json +3853 -0
- package/src/migrations/postgres/meta/0029_snapshot.json +3859 -0
- package/src/migrations/postgres/meta/0030_snapshot.json +3859 -0
- package/src/migrations/postgres/meta/0031_snapshot.json +3859 -0
- package/src/migrations/postgres/meta/0032_snapshot.json +3875 -0
- package/src/migrations/postgres/meta/0033_snapshot.json +3875 -0
- package/src/migrations/postgres/meta/0034_snapshot.json +3875 -0
- package/src/migrations/postgres/meta/0035_snapshot.json +3875 -0
- package/src/migrations/postgres/meta/0036_snapshot.json +3875 -0
- package/src/migrations/postgres/meta/0037_snapshot.json +3875 -0
- package/src/migrations/postgres/meta/0038_snapshot.json +3881 -0
- package/src/migrations/postgres/meta/0039_snapshot.json +3881 -0
- package/src/migrations/postgres/meta/0040_snapshot.json +3931 -0
- package/src/migrations/postgres/meta/0041_snapshot.json +3981 -0
- package/src/migrations/postgres/meta/0042_snapshot.json +3981 -0
- package/src/migrations/postgres/meta/0043_snapshot.json +3981 -0
- package/src/migrations/postgres/meta/0044_snapshot.json +3991 -0
- package/src/migrations/postgres/meta/0045_snapshot.json +3997 -0
- package/src/migrations/postgres/meta/0046_snapshot.json +3997 -0
- package/src/migrations/postgres/meta/0047_snapshot.json +4234 -0
- package/src/migrations/postgres/meta/_journal.json +189 -0
- package/src/migrations/sqlite/0018_log_015.sql +84 -0
- package/src/migrations/sqlite/0019_retention.sql +2 -0
- package/src/migrations/sqlite/0020_ended_references.sql +1 -0
- package/src/migrations/sqlite/0021_secrets_live_index.sql +1 -0
- package/src/migrations/sqlite/0022_binding_origin.sql +1 -0
- package/src/migrations/sqlite/0023_sign_in_index.sql +2 -0
- package/src/migrations/sqlite/0024_issue_revoke_index.sql +2 -0
- package/src/migrations/sqlite/0025_way_in_uses.sql +42 -0
- package/src/migrations/sqlite/0026_cutover_finish.sql +11 -0
- package/src/migrations/sqlite/0027_reads.sql +38 -0
- package/src/migrations/sqlite/meta/0018_snapshot.json +3529 -0
- package/src/migrations/sqlite/meta/0019_snapshot.json +3538 -0
- package/src/migrations/sqlite/meta/0020_snapshot.json +3545 -0
- package/src/migrations/sqlite/meta/0021_snapshot.json +3553 -0
- package/src/migrations/sqlite/meta/0022_snapshot.json +3560 -0
- package/src/migrations/sqlite/meta/0023_snapshot.json +3579 -0
- package/src/migrations/sqlite/meta/0024_snapshot.json +3598 -0
- package/src/migrations/sqlite/meta/0025_snapshot.json +3609 -0
- package/src/migrations/sqlite/meta/0026_snapshot.json +3616 -0
- package/src/migrations/sqlite/meta/0027_snapshot.json +3834 -0
- package/src/migrations/sqlite/meta/_journal.json +70 -0
- package/src/postgres-js/README.md +183 -0
- package/src/postgres-js/UNLICENSE +24 -0
- package/src/postgres-js/bytes.ts +89 -0
- package/src/postgres-js/connection.ts +882 -0
- package/src/postgres-js/errors.ts +84 -0
- package/src/postgres-js/index.ts +516 -0
- package/src/postgres-js/platform.node.ts +29 -0
- package/src/postgres-js/platform.ts +60 -0
- package/src/postgres-js/platform.workerd.ts +225 -0
- package/src/postgres-js/query.ts +123 -0
- package/src/postgres-js/queue.ts +42 -0
- package/src/postgres-js/result.ts +46 -0
- package/src/postgres-js/types.ts +52 -0
- package/src/postgres.ts +375 -26
- package/src/schema-version.ts +2 -2
- package/src/schema.sqlite.ts +200 -9
- package/src/schema.ts +294 -8
- package/src/verify-runtime.ts +18 -29
- package/LICENSE +0 -21
- package/dist/database-CFhTnnzM.d.ts +0 -73
- package/dist/postgres-Bmar8y0q.js +0 -29
- package/dist/relations-BfR3JjT1.js +0 -38
- package/src/relations.ts +0 -40
package/dist/log.d.ts
CHANGED
|
@@ -1,596 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
3
|
-
import { LogKey, StoredEntry } from "@coffre/core/audit";
|
|
4
|
-
//#region src/log.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Appending to the audit log, the one table both the app and the vault
|
|
7
|
-
* write, each under its own key (@coffre/core/audit says what an entry's MAC
|
|
8
|
-
* and hash cover).
|
|
9
|
-
*
|
|
10
|
-
* Every append locks the log's head first, `audit_chain_head`, so entries
|
|
11
|
-
* from any process take their numbers in one order. It then reads the
|
|
12
|
-
* database clock, after the lock, and the log's last entry, which the head
|
|
13
|
-
* must name: a head that does not was moved, or entries were deleted behind
|
|
14
|
-
* it, and the append refuses. The same statement says whether the log has
|
|
15
|
-
* moved on from the key it appends under (`KeyRetired`).
|
|
16
|
-
*
|
|
17
|
-
* This is deliberately not a queue and not best-effort: the entries go in
|
|
18
|
-
* the caller's transaction, so if the append fails, what it records does
|
|
19
|
-
* not happen either.
|
|
20
|
-
*/
|
|
21
|
-
/** An entry to append: what it says. The append numbers, dates, signs and chains it. */
|
|
22
|
-
export type NewEntry = {
|
|
23
|
-
actor: string;
|
|
24
|
-
action: string;
|
|
25
|
-
decision: 'allow' | 'deny';
|
|
26
|
-
code?: string | null;
|
|
27
|
-
subjectPrincipal?: string | null;
|
|
28
|
-
projectId?: string | null;
|
|
29
|
-
environmentId?: string | null;
|
|
30
|
-
secretId?: string | null;
|
|
31
|
-
secretVersionId?: string | null;
|
|
32
|
-
operationId?: string | null;
|
|
33
|
-
requestId?: string | null;
|
|
34
|
-
sourceIp?: string | null;
|
|
35
|
-
relatedSeq?: bigint | null;
|
|
36
|
-
/** JSON text. */
|
|
37
|
-
metadata?: string;
|
|
38
|
-
};
|
|
39
|
-
export type Appended = {
|
|
40
|
-
/** The first entry's number, and the next number after the last. */
|
|
41
|
-
seqStart: bigint;
|
|
42
|
-
nextSeq: bigint;
|
|
43
|
-
headHash: Buffer;
|
|
44
|
-
/** Milliseconds since the epoch, the database's, shared by the batch. */
|
|
45
|
-
occurredAt: number;
|
|
46
|
-
};
|
|
47
|
-
/** The log's head does not name its last entry: something moved it, or cut the log behind it. */
|
|
48
|
-
export declare class LogHeadMismatch extends Error {
|
|
49
|
-
constructor(message: string);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* The log's head is behind one this process wrote: the database was rolled
|
|
53
|
-
* back, or entries were cut off its end. That cannot be told from a restore,
|
|
54
|
-
* so the append refuses and someone has to look.
|
|
55
|
-
*/
|
|
56
|
-
export declare class LogRewound extends Error {
|
|
57
|
-
constructor(message: string);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* An append under a key the log has moved on from: an entry of its
|
|
61
|
-
* author's, `key.reseal` or `key.rotate`, names it as the key it moves
|
|
62
|
-
* from (`MOVES_FROM`), and a key moved from writes no more.
|
|
63
|
-
*/
|
|
64
|
-
export declare class KeyRetired extends Error {
|
|
65
|
-
constructor(message: string);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* The actions by which an author moves to a new key, each under the new one
|
|
69
|
-
* and naming the key it moves from as its subject: from the first, that key
|
|
70
|
-
* writes no more (`KeyRetired`). The app's key rotation writes them
|
|
71
|
-
* (packages/server/src/key-rotation.ts).
|
|
72
|
-
*/
|
|
73
|
-
export declare const MOVES_FROM: readonly ["key.reseal", "key.rotate"];
|
|
74
|
-
/**
|
|
75
|
-
* Forget every head written so far. For tests that empty the database
|
|
76
|
-
* between cases, which is exactly what the check above refuses.
|
|
77
|
-
*/
|
|
78
|
-
export declare function forgetLogHeads(): void;
|
|
79
|
-
/**
|
|
80
|
-
* Lock the log's head, and read it. A transaction that appends takes this
|
|
81
|
-
* before any other row, so the lock order is the same everywhere; taking it
|
|
82
|
-
* again in the same transaction is free.
|
|
83
|
-
*/
|
|
84
|
-
export declare function lockLogHead(tx: Transaction): Promise<{
|
|
85
|
-
nextSeq: bigint;
|
|
86
|
-
headHash: Buffer;
|
|
87
|
-
}>;
|
|
88
|
-
/**
|
|
89
|
-
* Lock the log's head if no one holds it, without waiting: whether it is
|
|
90
|
-
* held now. For work any caller may do, of which one at a time is enough,
|
|
91
|
-
* which a request that finds the head taken leaves to the one that has it.
|
|
92
|
-
* SQLite's transactions hold the whole file, so the head is always free.
|
|
93
|
-
*/
|
|
94
|
-
export declare function lockLogHeadIfFree(tx: Transaction): Promise<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Append `entries` under `key`. `check`, when given, runs once the head is
|
|
97
|
-
* locked and before anything is written: a writer's own condition on the
|
|
98
|
-
* log as it stands, which no other append can change until this one
|
|
99
|
-
* commits. It throws to refuse.
|
|
100
|
-
*/
|
|
101
|
-
export declare function appendEntries(tx: Transaction, key: LogKey, entries: readonly NewEntry[], check?: (tx: Transaction) => Promise<void>,
|
|
102
|
-
/**
|
|
103
|
-
* The head as a statement of the caller's locked it, with the log's last
|
|
104
|
-
* entry and the clock as that statement read them once it held the lock:
|
|
105
|
-
* nothing to read again.
|
|
106
|
-
*/
|
|
107
|
-
locked?: HeldHead): Promise<Appended>;
|
|
108
|
-
/** A head locked by a statement of the caller's, and what it read under the lock (`appendEntries`). */
|
|
109
|
-
export type HeldHead = {
|
|
110
|
-
head: {
|
|
111
|
-
nextSeq: bigint;
|
|
112
|
-
headHash: Buffer;
|
|
113
|
-
};
|
|
114
|
-
last: {
|
|
115
|
-
seq: bigint;
|
|
116
|
-
hash: Buffer;
|
|
117
|
-
} | null;
|
|
118
|
-
at: number;
|
|
119
|
-
};
|
|
120
|
-
/** An entry's columns, as the chain's codec reads them (`StoredEntry`). */
|
|
121
|
-
export declare function entryColumns(db: Queryable): {
|
|
122
|
-
seq: import("drizzle-orm/pg-core").PgColumn<{
|
|
123
|
-
name: "seq";
|
|
124
|
-
tableName: "audit_log";
|
|
125
|
-
dataType: "bigint";
|
|
126
|
-
columnType: "PgBigInt64";
|
|
127
|
-
data: bigint;
|
|
128
|
-
driverParam: string;
|
|
129
|
-
notNull: true;
|
|
130
|
-
hasDefault: false;
|
|
131
|
-
isPrimaryKey: true;
|
|
132
|
-
isAutoincrement: false;
|
|
133
|
-
hasRuntimeDefault: false;
|
|
134
|
-
enumValues: undefined;
|
|
135
|
-
baseColumn: never;
|
|
136
|
-
identity: undefined;
|
|
137
|
-
generated: undefined;
|
|
138
|
-
}, {}, {}>;
|
|
139
|
-
author: import("drizzle-orm/pg-core").PgColumn<{
|
|
140
|
-
name: "author";
|
|
141
|
-
tableName: "audit_log";
|
|
142
|
-
dataType: "string";
|
|
143
|
-
columnType: "PgText";
|
|
144
|
-
data: string;
|
|
145
|
-
driverParam: string;
|
|
146
|
-
notNull: true;
|
|
147
|
-
hasDefault: false;
|
|
148
|
-
isPrimaryKey: false;
|
|
149
|
-
isAutoincrement: false;
|
|
150
|
-
hasRuntimeDefault: false;
|
|
151
|
-
enumValues: [string, ...string[]];
|
|
152
|
-
baseColumn: never;
|
|
153
|
-
identity: undefined;
|
|
154
|
-
generated: undefined;
|
|
155
|
-
}, {}, {}>;
|
|
156
|
-
keyId: import("drizzle-orm/pg-core").PgColumn<{
|
|
157
|
-
name: "key_id";
|
|
158
|
-
tableName: "audit_log";
|
|
159
|
-
dataType: "string";
|
|
160
|
-
columnType: "PgText";
|
|
161
|
-
data: string;
|
|
162
|
-
driverParam: string;
|
|
163
|
-
notNull: true;
|
|
164
|
-
hasDefault: false;
|
|
165
|
-
isPrimaryKey: false;
|
|
166
|
-
isAutoincrement: false;
|
|
167
|
-
hasRuntimeDefault: false;
|
|
168
|
-
enumValues: [string, ...string[]];
|
|
169
|
-
baseColumn: never;
|
|
170
|
-
identity: undefined;
|
|
171
|
-
generated: undefined;
|
|
172
|
-
}, {}, {}>;
|
|
173
|
-
occurredAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
174
|
-
name: "occurred_at";
|
|
175
|
-
tableName: "audit_log";
|
|
176
|
-
dataType: "number";
|
|
177
|
-
columnType: "PgBigInt53";
|
|
178
|
-
data: number;
|
|
179
|
-
driverParam: string | number;
|
|
180
|
-
notNull: true;
|
|
181
|
-
hasDefault: false;
|
|
182
|
-
isPrimaryKey: false;
|
|
183
|
-
isAutoincrement: false;
|
|
184
|
-
hasRuntimeDefault: false;
|
|
185
|
-
enumValues: undefined;
|
|
186
|
-
baseColumn: never;
|
|
187
|
-
identity: undefined;
|
|
188
|
-
generated: undefined;
|
|
189
|
-
}, {}, {}>;
|
|
190
|
-
actor: import("drizzle-orm/pg-core").PgColumn<{
|
|
191
|
-
name: "actor";
|
|
192
|
-
tableName: "audit_log";
|
|
193
|
-
dataType: "string";
|
|
194
|
-
columnType: "PgText";
|
|
195
|
-
data: string;
|
|
196
|
-
driverParam: string;
|
|
197
|
-
notNull: true;
|
|
198
|
-
hasDefault: false;
|
|
199
|
-
isPrimaryKey: false;
|
|
200
|
-
isAutoincrement: false;
|
|
201
|
-
hasRuntimeDefault: false;
|
|
202
|
-
enumValues: [string, ...string[]];
|
|
203
|
-
baseColumn: never;
|
|
204
|
-
identity: undefined;
|
|
205
|
-
generated: undefined;
|
|
206
|
-
}, {}, {}>;
|
|
207
|
-
action: import("drizzle-orm/pg-core").PgColumn<{
|
|
208
|
-
name: "action";
|
|
209
|
-
tableName: "audit_log";
|
|
210
|
-
dataType: "string";
|
|
211
|
-
columnType: "PgText";
|
|
212
|
-
data: string;
|
|
213
|
-
driverParam: string;
|
|
214
|
-
notNull: true;
|
|
215
|
-
hasDefault: false;
|
|
216
|
-
isPrimaryKey: false;
|
|
217
|
-
isAutoincrement: false;
|
|
218
|
-
hasRuntimeDefault: false;
|
|
219
|
-
enumValues: [string, ...string[]];
|
|
220
|
-
baseColumn: never;
|
|
221
|
-
identity: undefined;
|
|
222
|
-
generated: undefined;
|
|
223
|
-
}, {}, {}>;
|
|
224
|
-
decision: import("drizzle-orm/pg-core").PgColumn<{
|
|
225
|
-
name: "decision";
|
|
226
|
-
tableName: "audit_log";
|
|
227
|
-
dataType: "string";
|
|
228
|
-
columnType: "PgText";
|
|
229
|
-
data: string;
|
|
230
|
-
driverParam: string;
|
|
231
|
-
notNull: true;
|
|
232
|
-
hasDefault: false;
|
|
233
|
-
isPrimaryKey: false;
|
|
234
|
-
isAutoincrement: false;
|
|
235
|
-
hasRuntimeDefault: false;
|
|
236
|
-
enumValues: [string, ...string[]];
|
|
237
|
-
baseColumn: never;
|
|
238
|
-
identity: undefined;
|
|
239
|
-
generated: undefined;
|
|
240
|
-
}, {}, {}>;
|
|
241
|
-
code: import("drizzle-orm/pg-core").PgColumn<{
|
|
242
|
-
name: "code";
|
|
243
|
-
tableName: "audit_log";
|
|
244
|
-
dataType: "string";
|
|
245
|
-
columnType: "PgText";
|
|
246
|
-
data: string;
|
|
247
|
-
driverParam: string;
|
|
248
|
-
notNull: false;
|
|
249
|
-
hasDefault: false;
|
|
250
|
-
isPrimaryKey: false;
|
|
251
|
-
isAutoincrement: false;
|
|
252
|
-
hasRuntimeDefault: false;
|
|
253
|
-
enumValues: [string, ...string[]];
|
|
254
|
-
baseColumn: never;
|
|
255
|
-
identity: undefined;
|
|
256
|
-
generated: undefined;
|
|
257
|
-
}, {}, {}>;
|
|
258
|
-
subjectPrincipal: import("drizzle-orm/pg-core").PgColumn<{
|
|
259
|
-
name: "subject_principal";
|
|
260
|
-
tableName: "audit_log";
|
|
261
|
-
dataType: "string";
|
|
262
|
-
columnType: "PgText";
|
|
263
|
-
data: string;
|
|
264
|
-
driverParam: string;
|
|
265
|
-
notNull: false;
|
|
266
|
-
hasDefault: false;
|
|
267
|
-
isPrimaryKey: false;
|
|
268
|
-
isAutoincrement: false;
|
|
269
|
-
hasRuntimeDefault: false;
|
|
270
|
-
enumValues: [string, ...string[]];
|
|
271
|
-
baseColumn: never;
|
|
272
|
-
identity: undefined;
|
|
273
|
-
generated: undefined;
|
|
274
|
-
}, {}, {}>;
|
|
275
|
-
projectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
276
|
-
name: "project_id";
|
|
277
|
-
tableName: "audit_log";
|
|
278
|
-
dataType: "string";
|
|
279
|
-
columnType: "PgUUID";
|
|
280
|
-
data: string;
|
|
281
|
-
driverParam: string;
|
|
282
|
-
notNull: false;
|
|
283
|
-
hasDefault: false;
|
|
284
|
-
isPrimaryKey: false;
|
|
285
|
-
isAutoincrement: false;
|
|
286
|
-
hasRuntimeDefault: false;
|
|
287
|
-
enumValues: undefined;
|
|
288
|
-
baseColumn: never;
|
|
289
|
-
identity: undefined;
|
|
290
|
-
generated: undefined;
|
|
291
|
-
}, {}, {}>;
|
|
292
|
-
environmentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
293
|
-
name: "environment_id";
|
|
294
|
-
tableName: "audit_log";
|
|
295
|
-
dataType: "string";
|
|
296
|
-
columnType: "PgUUID";
|
|
297
|
-
data: string;
|
|
298
|
-
driverParam: string;
|
|
299
|
-
notNull: false;
|
|
300
|
-
hasDefault: false;
|
|
301
|
-
isPrimaryKey: false;
|
|
302
|
-
isAutoincrement: false;
|
|
303
|
-
hasRuntimeDefault: false;
|
|
304
|
-
enumValues: undefined;
|
|
305
|
-
baseColumn: never;
|
|
306
|
-
identity: undefined;
|
|
307
|
-
generated: undefined;
|
|
308
|
-
}, {}, {}>;
|
|
309
|
-
secretId: import("drizzle-orm/pg-core").PgColumn<{
|
|
310
|
-
name: "secret_id";
|
|
311
|
-
tableName: "audit_log";
|
|
312
|
-
dataType: "string";
|
|
313
|
-
columnType: "PgUUID";
|
|
314
|
-
data: string;
|
|
315
|
-
driverParam: string;
|
|
316
|
-
notNull: false;
|
|
317
|
-
hasDefault: false;
|
|
318
|
-
isPrimaryKey: false;
|
|
319
|
-
isAutoincrement: false;
|
|
320
|
-
hasRuntimeDefault: false;
|
|
321
|
-
enumValues: undefined;
|
|
322
|
-
baseColumn: never;
|
|
323
|
-
identity: undefined;
|
|
324
|
-
generated: undefined;
|
|
325
|
-
}, {}, {}>;
|
|
326
|
-
secretVersionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
327
|
-
name: "secret_version_id";
|
|
328
|
-
tableName: "audit_log";
|
|
329
|
-
dataType: "string";
|
|
330
|
-
columnType: "PgUUID";
|
|
331
|
-
data: string;
|
|
332
|
-
driverParam: string;
|
|
333
|
-
notNull: false;
|
|
334
|
-
hasDefault: false;
|
|
335
|
-
isPrimaryKey: false;
|
|
336
|
-
isAutoincrement: false;
|
|
337
|
-
hasRuntimeDefault: false;
|
|
338
|
-
enumValues: undefined;
|
|
339
|
-
baseColumn: never;
|
|
340
|
-
identity: undefined;
|
|
341
|
-
generated: undefined;
|
|
342
|
-
}, {}, {}>;
|
|
343
|
-
operationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
344
|
-
name: "operation_id";
|
|
345
|
-
tableName: "audit_log";
|
|
346
|
-
dataType: "string";
|
|
347
|
-
columnType: "PgUUID";
|
|
348
|
-
data: string;
|
|
349
|
-
driverParam: string;
|
|
350
|
-
notNull: false;
|
|
351
|
-
hasDefault: false;
|
|
352
|
-
isPrimaryKey: false;
|
|
353
|
-
isAutoincrement: false;
|
|
354
|
-
hasRuntimeDefault: false;
|
|
355
|
-
enumValues: undefined;
|
|
356
|
-
baseColumn: never;
|
|
357
|
-
identity: undefined;
|
|
358
|
-
generated: undefined;
|
|
359
|
-
}, {}, {}>;
|
|
360
|
-
requestId: import("drizzle-orm/pg-core").PgColumn<{
|
|
361
|
-
name: "request_id";
|
|
362
|
-
tableName: "audit_log";
|
|
363
|
-
dataType: "string";
|
|
364
|
-
columnType: "PgText";
|
|
365
|
-
data: string;
|
|
366
|
-
driverParam: string;
|
|
367
|
-
notNull: false;
|
|
368
|
-
hasDefault: false;
|
|
369
|
-
isPrimaryKey: false;
|
|
370
|
-
isAutoincrement: false;
|
|
371
|
-
hasRuntimeDefault: false;
|
|
372
|
-
enumValues: [string, ...string[]];
|
|
373
|
-
baseColumn: never;
|
|
374
|
-
identity: undefined;
|
|
375
|
-
generated: undefined;
|
|
376
|
-
}, {}, {}>;
|
|
377
|
-
sourceIp: import("drizzle-orm/pg-core").PgColumn<{
|
|
378
|
-
name: "source_ip";
|
|
379
|
-
tableName: "audit_log";
|
|
380
|
-
dataType: "string";
|
|
381
|
-
columnType: "PgText";
|
|
382
|
-
data: string;
|
|
383
|
-
driverParam: string;
|
|
384
|
-
notNull: false;
|
|
385
|
-
hasDefault: false;
|
|
386
|
-
isPrimaryKey: false;
|
|
387
|
-
isAutoincrement: false;
|
|
388
|
-
hasRuntimeDefault: false;
|
|
389
|
-
enumValues: [string, ...string[]];
|
|
390
|
-
baseColumn: never;
|
|
391
|
-
identity: undefined;
|
|
392
|
-
generated: undefined;
|
|
393
|
-
}, {}, {}>;
|
|
394
|
-
relatedSeq: import("drizzle-orm/pg-core").PgColumn<{
|
|
395
|
-
name: "related_seq";
|
|
396
|
-
tableName: "audit_log";
|
|
397
|
-
dataType: "bigint";
|
|
398
|
-
columnType: "PgBigInt64";
|
|
399
|
-
data: bigint;
|
|
400
|
-
driverParam: string;
|
|
401
|
-
notNull: false;
|
|
402
|
-
hasDefault: false;
|
|
403
|
-
isPrimaryKey: false;
|
|
404
|
-
isAutoincrement: false;
|
|
405
|
-
hasRuntimeDefault: false;
|
|
406
|
-
enumValues: undefined;
|
|
407
|
-
baseColumn: never;
|
|
408
|
-
identity: undefined;
|
|
409
|
-
generated: undefined;
|
|
410
|
-
}, {}, {}>;
|
|
411
|
-
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
412
|
-
name: "metadata";
|
|
413
|
-
tableName: "audit_log";
|
|
414
|
-
dataType: "string";
|
|
415
|
-
columnType: "PgText";
|
|
416
|
-
data: string;
|
|
417
|
-
driverParam: string;
|
|
418
|
-
notNull: true;
|
|
419
|
-
hasDefault: true;
|
|
420
|
-
isPrimaryKey: false;
|
|
421
|
-
isAutoincrement: false;
|
|
422
|
-
hasRuntimeDefault: false;
|
|
423
|
-
enumValues: [string, ...string[]];
|
|
424
|
-
baseColumn: never;
|
|
425
|
-
identity: undefined;
|
|
426
|
-
generated: undefined;
|
|
427
|
-
}, {}, {}>;
|
|
428
|
-
prevHash: import("drizzle-orm/pg-core").PgColumn<{
|
|
429
|
-
name: "prev_hash";
|
|
430
|
-
tableName: "audit_log";
|
|
431
|
-
dataType: "custom";
|
|
432
|
-
columnType: "PgCustomColumn";
|
|
433
|
-
data: Buffer<ArrayBufferLike>;
|
|
434
|
-
driverParam: unknown;
|
|
435
|
-
notNull: true;
|
|
436
|
-
hasDefault: false;
|
|
437
|
-
isPrimaryKey: false;
|
|
438
|
-
isAutoincrement: false;
|
|
439
|
-
hasRuntimeDefault: false;
|
|
440
|
-
enumValues: undefined;
|
|
441
|
-
baseColumn: never;
|
|
442
|
-
identity: undefined;
|
|
443
|
-
generated: undefined;
|
|
444
|
-
}, {}, {
|
|
445
|
-
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
446
|
-
}>;
|
|
447
|
-
mac: import("drizzle-orm/pg-core").PgColumn<{
|
|
448
|
-
name: "mac";
|
|
449
|
-
tableName: "audit_log";
|
|
450
|
-
dataType: "custom";
|
|
451
|
-
columnType: "PgCustomColumn";
|
|
452
|
-
data: Buffer<ArrayBufferLike>;
|
|
453
|
-
driverParam: unknown;
|
|
454
|
-
notNull: true;
|
|
455
|
-
hasDefault: false;
|
|
456
|
-
isPrimaryKey: false;
|
|
457
|
-
isAutoincrement: false;
|
|
458
|
-
hasRuntimeDefault: false;
|
|
459
|
-
enumValues: undefined;
|
|
460
|
-
baseColumn: never;
|
|
461
|
-
identity: undefined;
|
|
462
|
-
generated: undefined;
|
|
463
|
-
}, {}, {
|
|
464
|
-
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
465
|
-
}>;
|
|
466
|
-
hash: import("drizzle-orm/pg-core").PgColumn<{
|
|
467
|
-
name: "hash";
|
|
468
|
-
tableName: "audit_log";
|
|
469
|
-
dataType: "custom";
|
|
470
|
-
columnType: "PgCustomColumn";
|
|
471
|
-
data: Buffer<ArrayBufferLike>;
|
|
472
|
-
driverParam: unknown;
|
|
473
|
-
notNull: true;
|
|
474
|
-
hasDefault: false;
|
|
475
|
-
isPrimaryKey: false;
|
|
476
|
-
isAutoincrement: false;
|
|
477
|
-
hasRuntimeDefault: false;
|
|
478
|
-
enumValues: undefined;
|
|
479
|
-
baseColumn: never;
|
|
480
|
-
identity: undefined;
|
|
481
|
-
generated: undefined;
|
|
482
|
-
}, {}, {
|
|
483
|
-
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
484
|
-
}>;
|
|
485
|
-
};
|
|
486
|
-
/**
|
|
487
|
-
* Metadata a reader of many entries holds at once, at most: an entry about
|
|
488
|
-
* a read of several secrets lists them, a thousand some 150 kilobytes, so a
|
|
489
|
-
* count of entries alone does not bound a batch's or a page's memory within
|
|
490
|
-
* a Worker's 128 megabytes.
|
|
491
|
-
*/
|
|
492
|
-
export declare const BATCH_BYTES: number;
|
|
493
|
-
/**
|
|
494
|
-
* Of the entries `where` matches, in `order` of seq, the first `limit` or
|
|
495
|
-
* fewer that hold no more than `BATCH_BYTES` of metadata between them, but
|
|
496
|
-
* always the first: the seqs they run from and to, and whether the bytes
|
|
497
|
-
* cut the run short of `limit`. Null when none matches. A reader asks this
|
|
498
|
-
* first, then reads `where` between the two.
|
|
499
|
-
*/
|
|
500
|
-
export declare function withinBytes(db: Queryable, where: SQL | undefined, limit: number, order?: 'asc' | 'desc'): Promise<{
|
|
501
|
-
from: bigint;
|
|
502
|
-
to: bigint;
|
|
503
|
-
cut: boolean;
|
|
504
|
-
count: number;
|
|
505
|
-
} | null>;
|
|
506
|
-
/**
|
|
507
|
-
* The first entry missing from the log up to `seq`, and the one found in
|
|
508
|
-
* its place, or null when every one is there. Seqs are the primary key, so
|
|
509
|
-
* a stretch is whole exactly when its count is its length: one pass over
|
|
510
|
-
* the key's index, never the entries. Only a log with a gap pays for more,
|
|
511
|
-
* a count per halving to find where.
|
|
512
|
-
*
|
|
513
|
-
* entries 0..9, 4 cut: { expected: 4n, found: 5n }
|
|
514
|
-
*/
|
|
515
|
-
export declare function missingEntry(db: Queryable, seq: bigint): Promise<{
|
|
516
|
-
expected: bigint;
|
|
517
|
-
found: bigint | null;
|
|
518
|
-
} | null>;
|
|
519
|
-
/**
|
|
520
|
-
* How a reader tells the vault's own entries from those forged in its name:
|
|
521
|
-
* by their MAC, which only the vault holds the key to check. Each it finds
|
|
522
|
-
* forged goes to `forged`.
|
|
523
|
-
*/
|
|
524
|
-
export type Authenticity = {
|
|
525
|
-
authentic: (entry: StoredEntry) => boolean;
|
|
526
|
-
forged: (entry: StoredEntry) => void;
|
|
527
|
-
};
|
|
528
|
-
/** Up to `limit` of the entries in the vault's name, allowed, of one `action`, before `before` (the newest when undefined), newest first. */
|
|
529
|
-
export declare function newestVaultEntries(db: Queryable, action: string, limit: number, before?: bigint): Promise<StoredEntry[]>;
|
|
530
|
-
/**
|
|
531
|
-
* The number of the newest entry in the vault's name, allowed, of one
|
|
532
|
-
* `action`, or null for none: whether one was appended since, and nothing
|
|
533
|
-
* of what it says, so its MAC is not checked. One indexed read.
|
|
534
|
-
*/
|
|
535
|
-
export declare function newestVaultSeq(db: Queryable, action: string): Promise<bigint | null>;
|
|
536
|
-
/**
|
|
537
|
-
* `newestVaultSeq`'s query, to run or to read inside another, as a
|
|
538
|
-
* credential's read takes the newest `policy.change` with it: one rule for
|
|
539
|
-
* what the newest is, wherever it is read.
|
|
540
|
-
*/
|
|
541
|
-
export declare function newestSeqQuery(db: Queryable, action: string | Placeholder): Omit<import("drizzle-orm/pg-core").PgSelectBase<"audit_log", {
|
|
542
|
-
seq: import("drizzle-orm/pg-core").PgColumn<{
|
|
543
|
-
name: "seq";
|
|
544
|
-
tableName: "audit_log";
|
|
545
|
-
dataType: "bigint";
|
|
546
|
-
columnType: "PgBigInt64";
|
|
547
|
-
data: bigint;
|
|
548
|
-
driverParam: string;
|
|
549
|
-
notNull: true;
|
|
550
|
-
hasDefault: false;
|
|
551
|
-
isPrimaryKey: true;
|
|
552
|
-
isAutoincrement: false;
|
|
553
|
-
hasRuntimeDefault: false;
|
|
554
|
-
enumValues: undefined;
|
|
555
|
-
baseColumn: never;
|
|
556
|
-
identity: undefined;
|
|
557
|
-
generated: undefined;
|
|
558
|
-
}, {}, {}>;
|
|
559
|
-
}, "partial", Record<"audit_log", "not-null">, false, "where" | "orderBy" | "limit", {
|
|
560
|
-
seq: bigint;
|
|
561
|
-
}[], {
|
|
562
|
-
seq: import("drizzle-orm/pg-core").PgColumn<{
|
|
563
|
-
name: "seq";
|
|
564
|
-
tableName: "audit_log";
|
|
565
|
-
dataType: "bigint";
|
|
566
|
-
columnType: "PgBigInt64";
|
|
567
|
-
data: bigint;
|
|
568
|
-
driverParam: string;
|
|
569
|
-
notNull: true;
|
|
570
|
-
hasDefault: false;
|
|
571
|
-
isPrimaryKey: true;
|
|
572
|
-
isAutoincrement: false;
|
|
573
|
-
hasRuntimeDefault: false;
|
|
574
|
-
enumValues: undefined;
|
|
575
|
-
baseColumn: never;
|
|
576
|
-
identity: undefined;
|
|
577
|
-
generated: undefined;
|
|
578
|
-
}, {}, {}>;
|
|
579
|
-
}>, "where" | "orderBy" | "limit">;
|
|
580
|
-
/** How many entries in its name the vault reads back, a page at a time, for its own newest of a kind (`newestAuthentic`). */
|
|
581
|
-
export declare const LOOK_BACK: {
|
|
582
|
-
page: number;
|
|
583
|
-
pages: number;
|
|
584
|
-
};
|
|
585
|
-
/** What `newestAuthentic` finds: the entry, or why there is none. */
|
|
586
|
-
export type Newest = StoredEntry | 'none' | 'forged' | 'unreached';
|
|
587
|
-
/**
|
|
588
|
-
* The newest of the entries `page` reads, newest first and before a seq,
|
|
589
|
-
* that `check` finds authentic: the newest alone first, which it is unless
|
|
590
|
-
* entries were forged in the vault's name since, then back a page at a
|
|
591
|
-
* time. 'none' when there are none at all, 'forged' when every one is in
|
|
592
|
-
* the vault's name but not its own, and 'unreached' once it has read
|
|
593
|
-
* LOOK_BACK such entries (1024), whether or not more are left.
|
|
594
|
-
*/
|
|
595
|
-
export declare function newestAuthentic(page: (limit: number, before: bigint | undefined) => Promise<StoredEntry[]>, check: Authenticity): Promise<Newest>;
|
|
596
|
-
//#endregion
|
|
1
|
+
import { A as ChangeRecord, C as logObject, D as newestVaultEntries, E as newestSeqQuery, M as recorded, O as newestVaultSeq, S as lockLogHeadQueued, T as newestAuthentic, _ as holdFence, a as HeldHead, b as lockLogHead, c as LogHeadMismatch, d as NewEntry, f as Newest, g as forgetLogHeads, h as entryColumns, i as HeadBusy, j as RECORDS, k as withinBytes, l as LogRewound, m as appendEntries, n as Authenticity, o as KeyRetired, p as appChanges, r as BATCH_BYTES, s as LOOK_BACK, t as Appended, u as MOVES_FROM, v as holdIssues, w as missingEntry, x as lockLogHeadIfFree, y as isStaleChange } from "./log-DaD7fyUq.js";
|
|
2
|
+
export { Appended, Authenticity, BATCH_BYTES, type ChangeRecord, HeadBusy, HeldHead, KeyRetired, LOOK_BACK, LogHeadMismatch, LogRewound, MOVES_FROM, NewEntry, Newest, RECORDS, appChanges, appendEntries, entryColumns, forgetLogHeads, holdFence, holdIssues, isStaleChange, lockLogHead, lockLogHeadIfFree, lockLogHeadQueued, logObject, missingEntry, newestAuthentic, newestSeqQuery, newestVaultEntries, newestVaultSeq, recorded, withinBytes };
|