@datafn/server 0.1.1 → 0.1.3
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 +20 -0
- package/dist/index.cjs +1113 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -5
- package/dist/index.d.ts +268 -5
- package/dist/index.js +1064 -79
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DatafnPlugin, DatafnSchema as DatafnSchema$1 } from '@datafn/core';
|
|
1
|
+
import { DatafnRouteScope, DatafnPlugin, DatafnRequestAction, DatafnSchema as DatafnSchema$1, NamespaceStorageOperation, NamespaceStorageLogicalRole, NamespaceStorageOwnership, DATAFN_NAMESPACE_STORAGE_MANIFEST_VERSION, DATAFN_NAMESPACE_STORAGE_SCHEMA_VERSION } from '@datafn/core';
|
|
2
|
+
export { DATAFN_REQUEST_ACTIONS, DATAFN_REQUEST_PROTOCOL_VERSION, DATAFN_REQUEST_PROTOCOL_VERSIONS, DATAFN_STRUCTURAL_SELECTOR_POSITIONS, DatafnRequestAction, DatafnRequestProtocolVersion, DatafnResourceSelector, ParsedDatafnMutation, ParsedDatafnQuery, ParsedDatafnRequest, ParsedDatafnTransactStep, StructuralResourceSelection, collectStructuralResourceSelectors, extractStructuralResourceSelectors, isDatafnRequestAction, parseDatafnRequest } from '@datafn/core';
|
|
2
3
|
import { ObservationEvent, ObservabilityInput, ObservabilityConfigInput } from '@superfunctions/observability';
|
|
3
4
|
import { DatafnSchema, DatafnPlugin as DatafnPlugin$1 } from '@datafn/core/types';
|
|
4
5
|
import { Route, Router } from '@superfunctions/http';
|
|
@@ -68,6 +69,98 @@ interface DatafnLogger {
|
|
|
68
69
|
debug(message: string, context?: Record<string, unknown>): void;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
interface DatafnRouteIdentity {
|
|
73
|
+
/** Opaque authenticated subject; never derived from routing headers. */
|
|
74
|
+
subject: string;
|
|
75
|
+
namespace: string;
|
|
76
|
+
sessionBinding?: string;
|
|
77
|
+
/** Optional upstream session deadline bounds the grant. */
|
|
78
|
+
expiresAt?: number;
|
|
79
|
+
}
|
|
80
|
+
interface DatafnRouteTicketClaims {
|
|
81
|
+
version: 1;
|
|
82
|
+
issuer: string;
|
|
83
|
+
audience: string;
|
|
84
|
+
subject: string;
|
|
85
|
+
namespace: string;
|
|
86
|
+
regionId: string;
|
|
87
|
+
epoch: number;
|
|
88
|
+
scopes: DatafnRouteScope[];
|
|
89
|
+
issuedAt: number;
|
|
90
|
+
notBefore: number;
|
|
91
|
+
expiresAt: number;
|
|
92
|
+
ticketId: string;
|
|
93
|
+
sessionBinding?: string;
|
|
94
|
+
}
|
|
95
|
+
interface DatafnRouteTicketSigner {
|
|
96
|
+
sign(claims: DatafnRouteTicketClaims): Promise<string> | string;
|
|
97
|
+
}
|
|
98
|
+
interface DatafnRouteTicketVerifier {
|
|
99
|
+
verify(ticket: string): Promise<DatafnRouteTicketClaims> | DatafnRouteTicketClaims;
|
|
100
|
+
}
|
|
101
|
+
interface DatafnRouteTicketEvent {
|
|
102
|
+
type: "issued" | "accepted" | "rejected" | "renewal_failed";
|
|
103
|
+
code?: string;
|
|
104
|
+
}
|
|
105
|
+
declare function routeTicketError(code: "DATAFN_ROUTE_TICKET_INVALID" | "DATAFN_ROUTE_TICKET_EXPIRED" | "DATAFN_ROUTE_TICKET_REVOKED" | "DATAFN_ROUTE_FORBIDDEN" | "DATAFN_ROUTE_RATE_LIMITED"): DatafnRoutingError;
|
|
106
|
+
/** Separate signing domain and key ring from DATA-1 internal request assertions. */
|
|
107
|
+
declare function createDatafnHmacRouteTickets(input: {
|
|
108
|
+
activeKeyId: string;
|
|
109
|
+
/** At least 32 bytes of cryptographically random key material per key. */
|
|
110
|
+
keys: Record<string, string | Uint8Array>;
|
|
111
|
+
}): DatafnRouteTicketSigner & DatafnRouteTicketVerifier;
|
|
112
|
+
interface DatafnRegionalEndpoint {
|
|
113
|
+
httpUrl: string;
|
|
114
|
+
wsUrl?: string;
|
|
115
|
+
/** Unique audience per environment/cell endpoint. */
|
|
116
|
+
audience: string;
|
|
117
|
+
}
|
|
118
|
+
interface DatafnRouteBootstrapConfig {
|
|
119
|
+
directory: DatafnPlacementDirectoryAdapter;
|
|
120
|
+
authenticate(request: Request): Promise<DatafnRouteIdentity> | DatafnRouteIdentity;
|
|
121
|
+
resolveEndpoint(placement: DatafnNamespacePlacement): Promise<DatafnRegionalEndpoint> | DatafnRegionalEndpoint;
|
|
122
|
+
/** Application-owned authorization selects operations; never accept requested scopes verbatim. */
|
|
123
|
+
authorize(identity: DatafnRouteIdentity): Promise<readonly DatafnRouteScope[]> | readonly DatafnRouteScope[];
|
|
124
|
+
signer: DatafnRouteTicketSigner;
|
|
125
|
+
issuer: string;
|
|
126
|
+
ttlMs?: number;
|
|
127
|
+
now?: () => number;
|
|
128
|
+
onEvent?(event: DatafnRouteTicketEvent): void;
|
|
129
|
+
}
|
|
130
|
+
/** Mount at one canonical, authenticated POST endpoint. Request body/region headers are ignored. */
|
|
131
|
+
declare function createDatafnRouteBootstrap(config: DatafnRouteBootstrapConfig): (request: Request) => Promise<Response>;
|
|
132
|
+
interface DatafnRegionalTicketRuntime {
|
|
133
|
+
/** Browser HTTP/WS origins. An Origin header is rejected unless explicitly allowed. */
|
|
134
|
+
allowedOrigins?: readonly string[];
|
|
135
|
+
verifier: DatafnRouteTicketVerifier;
|
|
136
|
+
issuer: string;
|
|
137
|
+
audience: string;
|
|
138
|
+
/** Validates application credentials separately from the route grant. Also used on WS handshakes. */
|
|
139
|
+
authenticate(request: Request): Promise<DatafnRouteIdentity> | DatafnRouteIdentity;
|
|
140
|
+
/** Checks ticket/session revocation on each HTTP request and WS admission. False rejects. */
|
|
141
|
+
isActive?(claims: DatafnRouteTicketClaims): Promise<boolean> | boolean;
|
|
142
|
+
/** Optional provider-neutral limiter before plugin authorization/execution. */
|
|
143
|
+
allowRequest?(claims: DatafnRouteTicketClaims): Promise<boolean> | boolean;
|
|
144
|
+
now?: () => number;
|
|
145
|
+
/** Future issuance/not-before tolerance only. Expiry is never extended. Default 5 seconds. */
|
|
146
|
+
clockSkewMs?: number;
|
|
147
|
+
onEvent?(event: DatafnRouteTicketEvent): void;
|
|
148
|
+
}
|
|
149
|
+
/** The adapter must negotiate only datafn-sync-v1, never echo the ticket subprotocol. */
|
|
150
|
+
declare function readDatafnRouteTicket(request: Request, websocket?: boolean): string | undefined;
|
|
151
|
+
declare function validateDatafnRouteTicket(input: {
|
|
152
|
+
request: Request;
|
|
153
|
+
namespace: string;
|
|
154
|
+
regionId: string;
|
|
155
|
+
scope: DatafnRouteScope;
|
|
156
|
+
runtime: DatafnRegionalTicketRuntime;
|
|
157
|
+
}): Promise<DatafnRouteTicketClaims>;
|
|
158
|
+
/** Wrap regional HTTP ingress, including preflight. No credentials/cookies or wildcard origins. */
|
|
159
|
+
declare function withDatafnRegionalCors(handler: (request: Request) => Promise<Response>, options: {
|
|
160
|
+
origins: readonly string[];
|
|
161
|
+
headers?: readonly string[];
|
|
162
|
+
}): (request: Request) => Promise<Response>;
|
|
163
|
+
|
|
71
164
|
type DatafnPlacementState = "active" | "moving" | "tombstoned";
|
|
72
165
|
interface DatafnNamespacePlacement {
|
|
73
166
|
namespace: string;
|
|
@@ -158,6 +251,8 @@ interface DatafnRoutingEvent {
|
|
|
158
251
|
}
|
|
159
252
|
interface DatafnPlacementRuntimeConfig {
|
|
160
253
|
directory: DatafnPlacementDirectoryAdapter;
|
|
254
|
+
/** Opt-in public ingress: requires a route ticket or a valid internal assertion. */
|
|
255
|
+
routeTickets?: DatafnRegionalTicketRuntime;
|
|
161
256
|
requireRoutingAssertion?: boolean;
|
|
162
257
|
assertionVerifier?: DatafnRoutingAssertionVerifier;
|
|
163
258
|
replayStore?: DatafnRoutingReplayStore;
|
|
@@ -171,7 +266,7 @@ interface DatafnPlacementRuntimeConfig {
|
|
|
171
266
|
declare const DATAFN_ROUTING_ASSERTION_HEADER = "x-datafn-routing-assertion";
|
|
172
267
|
declare const DATAFN_ROUTING_INTERNAL_HEADERS: readonly ["x-datafn-routing-assertion", "x-datafn-routing-namespace", "x-datafn-routing-region", "x-datafn-routing-epoch"];
|
|
173
268
|
declare class DatafnRoutingError extends Error {
|
|
174
|
-
readonly code: "DATAFN_PLACEMENT_NOT_FOUND" | "DATAFN_PLACEMENT_UNAVAILABLE" | "DATAFN_REGION_MISMATCH" | "DATAFN_NAMESPACE_MOVING" | "DATAFN_CELL_UNAVAILABLE" | "DATAFN_ROUTING_ASSERTION_INVALID" | "DATAFN_ROUTING_RETRY_EXHAUSTED" | "DATAFN_PAYLOAD_TOO_LARGE";
|
|
269
|
+
readonly code: "DATAFN_ROUTE_TICKET_INVALID" | "DATAFN_ROUTE_TICKET_EXPIRED" | "DATAFN_ROUTE_TICKET_REVOKED" | "DATAFN_ROUTE_FORBIDDEN" | "DATAFN_ROUTE_RATE_LIMITED" | "DATAFN_PLACEMENT_NOT_FOUND" | "DATAFN_PLACEMENT_UNAVAILABLE" | "DATAFN_REGION_MISMATCH" | "DATAFN_NAMESPACE_MOVING" | "DATAFN_CELL_UNAVAILABLE" | "DATAFN_ROUTING_ASSERTION_INVALID" | "DATAFN_ROUTING_RETRY_EXHAUSTED" | "DATAFN_PAYLOAD_TOO_LARGE";
|
|
175
270
|
readonly status: number;
|
|
176
271
|
readonly retryable: boolean;
|
|
177
272
|
readonly executionStarted: boolean;
|
|
@@ -208,12 +303,15 @@ declare function claimDatafnNamespacePlacement(input: {
|
|
|
208
303
|
interface DatafnPlacementValidationResult {
|
|
209
304
|
placement: DatafnNamespacePlacement;
|
|
210
305
|
assertion?: DatafnRoutingAssertionClaims;
|
|
306
|
+
ticket?: DatafnRouteTicketClaims;
|
|
211
307
|
}
|
|
212
308
|
declare function validateDatafnPlacement(input: {
|
|
213
309
|
namespace: string;
|
|
214
310
|
regionId: string;
|
|
215
311
|
runtime: DatafnPlacementRuntimeConfig;
|
|
216
312
|
request?: Request;
|
|
313
|
+
/** Server-selected operation; custom routes default to the custom scope. */
|
|
314
|
+
scope?: DatafnRouteScope;
|
|
217
315
|
/** Trusted in-process execution has no externally supplied assertion. */
|
|
218
316
|
trustedInternal?: boolean;
|
|
219
317
|
}): Promise<DatafnPlacementValidationResult>;
|
|
@@ -393,7 +491,7 @@ interface ExecutionTimingEvent {
|
|
|
393
491
|
}
|
|
394
492
|
|
|
395
493
|
type DataFnEventType = 'datafn.authorization.denied' | 'datafn.payload.rejected' | 'datafn.rate_limited' | 'datafn.request.failed' | 'datafn.retention.pruned' | 'datafn.retention.prune_failed';
|
|
396
|
-
type DataFnAction =
|
|
494
|
+
type DataFnAction = DatafnRequestAction;
|
|
397
495
|
interface DataFnRequestEventMetadata extends Record<string, unknown> {
|
|
398
496
|
action?: DataFnAction;
|
|
399
497
|
path?: string;
|
|
@@ -599,6 +697,12 @@ interface WebSocketClient {
|
|
|
599
697
|
*/
|
|
600
698
|
interface WsAuthContext {
|
|
601
699
|
namespace: string;
|
|
700
|
+
/** Set only by the validated regional handshake. */
|
|
701
|
+
routeTicket?: {
|
|
702
|
+
id: string;
|
|
703
|
+
expiresAt: number;
|
|
704
|
+
now?: () => number;
|
|
705
|
+
};
|
|
602
706
|
/** Optional actor identity for principal-targeted invalidation. */
|
|
603
707
|
actorId?: string;
|
|
604
708
|
/** Optional resolved principal IDs for principal-targeted invalidation. */
|
|
@@ -824,7 +928,9 @@ interface DatafnServerConfig<TContext = any> {
|
|
|
824
928
|
/** Public-link plugin instance used to register share-link routes and resolve link principals. */
|
|
825
929
|
publicLinks?: DatafnPublicLinksPlugin;
|
|
826
930
|
/** Authorizes each DataFn action after context creation and before route execution. */
|
|
827
|
-
authorize?: (ctx: TContext
|
|
931
|
+
authorize?: (ctx: TContext & {
|
|
932
|
+
parsedBody?: unknown;
|
|
933
|
+
}, action: "status" | "query" | "mutation" | "transact" | "seed" | "clone" | "pull" | "push" | "reconcile" | "search", payload: unknown) => Promise<boolean> | boolean;
|
|
828
934
|
/** Static context or request-scoped context factory passed to authorization, namespace resolution, route handlers, and hooks. */
|
|
829
935
|
context?: TContext | ((request: Request) => Promise<TContext> | TContext);
|
|
830
936
|
/** Request, query, mutation, and validation limits enforced by DataFn routes. */
|
|
@@ -943,6 +1049,8 @@ interface DatafnServer<TContext = any> {
|
|
|
943
1049
|
addRoutedClient(client: WebSocketClient, authContext: WsAuthContext, handshakeRequest?: Request): Promise<boolean>;
|
|
944
1050
|
/** Closes stale sessions so clients reconnect through the canonical gateway. */
|
|
945
1051
|
fenceNamespace(namespace: string, minimumEpoch?: number): number;
|
|
1052
|
+
/** Immediately revoke an admitted route ticket across this process. */
|
|
1053
|
+
revokeRouteTicket(ticketId: string): number;
|
|
946
1054
|
removeClient(client: WebSocketClient): void;
|
|
947
1055
|
handleMessage(client: WebSocketClient, data: string): void;
|
|
948
1056
|
/** REL-007: Called by WS transport on native pong frame receipt. */
|
|
@@ -997,6 +1105,105 @@ interface DatafnApp {
|
|
|
997
1105
|
*/
|
|
998
1106
|
declare function datafn(config: DatafnAppConfig): DatafnApp;
|
|
999
1107
|
|
|
1108
|
+
/**
|
|
1109
|
+
* Adapter-resolved namespace storage plan.
|
|
1110
|
+
*
|
|
1111
|
+
* The logical contract lives in `@datafn/core`. This module binds that
|
|
1112
|
+
* contract to the installed PostgreSQL schema and fails closed when the
|
|
1113
|
+
* catalog contains unknown DataFn-owned namespace storage.
|
|
1114
|
+
*/
|
|
1115
|
+
|
|
1116
|
+
declare const POSTGRES_NAMESPACE_STORAGE_CATALOG_SQL: string;
|
|
1117
|
+
type DatafnNamespaceStorageErrorCode = "DATAFN_NAMESPACE_STORAGE_UNSUPPORTED" | "DATAFN_NAMESPACE_STORAGE_VERSION_MISMATCH" | "DATAFN_NAMESPACE_STORAGE_INCOMPLETE" | "DATAFN_NAMESPACE_STORAGE_UNKNOWN" | "DATAFN_NAMESPACE_STORAGE_INVALID";
|
|
1118
|
+
declare class DatafnNamespaceStorageError extends Error {
|
|
1119
|
+
readonly code: DatafnNamespaceStorageErrorCode;
|
|
1120
|
+
readonly details?: unknown;
|
|
1121
|
+
constructor(input: {
|
|
1122
|
+
code: DatafnNamespaceStorageErrorCode;
|
|
1123
|
+
message: string;
|
|
1124
|
+
details?: unknown;
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
interface NamespaceStorageCatalogRelation {
|
|
1128
|
+
readonly name: string;
|
|
1129
|
+
readonly columns: readonly string[];
|
|
1130
|
+
/** Valid, non-partial indexes, with expression and INCLUDE columns excluded. */
|
|
1131
|
+
readonly indexes?: readonly {
|
|
1132
|
+
columns: readonly string[];
|
|
1133
|
+
unique: boolean;
|
|
1134
|
+
primary?: boolean;
|
|
1135
|
+
}[];
|
|
1136
|
+
}
|
|
1137
|
+
interface NamespaceStorageCatalog {
|
|
1138
|
+
readonly dialect: "postgres";
|
|
1139
|
+
readonly relations: readonly NamespaceStorageCatalogRelation[];
|
|
1140
|
+
}
|
|
1141
|
+
interface NamespaceStorageEntry {
|
|
1142
|
+
readonly logicalRole: NamespaceStorageLogicalRole | "application";
|
|
1143
|
+
readonly ownership: NamespaceStorageOwnership;
|
|
1144
|
+
readonly relation: string;
|
|
1145
|
+
readonly quotedRelation: string;
|
|
1146
|
+
readonly namespaceColumn: string;
|
|
1147
|
+
readonly quotedNamespaceColumn: string;
|
|
1148
|
+
readonly operations: readonly NamespaceStorageOperation[];
|
|
1149
|
+
readonly copyOrder: number;
|
|
1150
|
+
readonly present: boolean;
|
|
1151
|
+
}
|
|
1152
|
+
interface NamespaceStoragePlan {
|
|
1153
|
+
readonly manifestVersion: typeof DATAFN_NAMESPACE_STORAGE_MANIFEST_VERSION;
|
|
1154
|
+
readonly schemaVersion: typeof DATAFN_NAMESPACE_STORAGE_SCHEMA_VERSION;
|
|
1155
|
+
readonly dialect: "postgres";
|
|
1156
|
+
readonly entries: readonly NamespaceStorageEntry[];
|
|
1157
|
+
}
|
|
1158
|
+
interface ApplicationNamespaceStorageEntry {
|
|
1159
|
+
readonly relation: string;
|
|
1160
|
+
readonly namespaceColumn: string;
|
|
1161
|
+
readonly operations?: readonly NamespaceStorageOperation[];
|
|
1162
|
+
readonly copyOrder?: number;
|
|
1163
|
+
}
|
|
1164
|
+
declare function quotePostgresIdentifier(identifier: string): string;
|
|
1165
|
+
declare function namespacedInternalTableRoles(): Readonly<Record<string, NamespaceStorageLogicalRole>>;
|
|
1166
|
+
declare function resolveNamespaceStoragePlan(input: {
|
|
1167
|
+
schema: DatafnSchema$1;
|
|
1168
|
+
catalog: NamespaceStorageCatalog;
|
|
1169
|
+
manifestVersion?: string;
|
|
1170
|
+
schemaVersion?: string;
|
|
1171
|
+
}): NamespaceStoragePlan;
|
|
1172
|
+
declare function selectNamespaceStorageEntries(plan: NamespaceStoragePlan, operation: NamespaceStorageOperation): readonly NamespaceStorageEntry[];
|
|
1173
|
+
declare function composeNamespaceStoragePlan(plan: NamespaceStoragePlan, applicationEntries: readonly ApplicationNamespaceStorageEntry[]): NamespaceStoragePlan;
|
|
1174
|
+
declare const POSTGRES_NAMESPACE_STORAGE_INDEX_SQL: string;
|
|
1175
|
+
type PostgresNamespaceStorageQuery = (sql: string) => Promise<readonly {
|
|
1176
|
+
table_name: string;
|
|
1177
|
+
column_name?: string;
|
|
1178
|
+
index_columns?: readonly string[];
|
|
1179
|
+
index_unique?: boolean;
|
|
1180
|
+
index_primary?: boolean;
|
|
1181
|
+
}[]>;
|
|
1182
|
+
declare function inspectPostgresNamespaceStorage(query: PostgresNamespaceStorageQuery): Promise<NamespaceStorageCatalog>;
|
|
1183
|
+
declare function assertInternalNamespaceStorageMetadataComplete(): void;
|
|
1184
|
+
declare function drainNamespaceStorage(input: {
|
|
1185
|
+
adapter: Adapter;
|
|
1186
|
+
plan: NamespaceStoragePlan;
|
|
1187
|
+
namespace: string;
|
|
1188
|
+
runtime: DatafnMultiRegionRuntimeConfig;
|
|
1189
|
+
logger?: DatafnLogger;
|
|
1190
|
+
}): Promise<{
|
|
1191
|
+
processed: number;
|
|
1192
|
+
pending: number;
|
|
1193
|
+
}>;
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Drain every permission-directory outbox row for one namespace.
|
|
1197
|
+
* Used by tenant move/backup tooling after writes are fenced.
|
|
1198
|
+
*/
|
|
1199
|
+
declare function drainNamespacePermissionDirectoryOutbox(db: Adapter, namespace: string, runtime: DatafnMultiRegionRuntimeConfig, logger?: DatafnLogger, options?: {
|
|
1200
|
+
limit?: number;
|
|
1201
|
+
maxRounds?: number;
|
|
1202
|
+
}): Promise<{
|
|
1203
|
+
processed: number;
|
|
1204
|
+
pending: number;
|
|
1205
|
+
}>;
|
|
1206
|
+
|
|
1000
1207
|
/**
|
|
1001
1208
|
* GET /datafn/status endpoint
|
|
1002
1209
|
* Returns server metadata, capabilities, limits, and schema hash
|
|
@@ -1014,4 +1221,60 @@ interface StatusResult {
|
|
|
1014
1221
|
serverTimeMs: number;
|
|
1015
1222
|
}
|
|
1016
1223
|
|
|
1017
|
-
|
|
1224
|
+
/** Resumable position within a namespace sweep. */
|
|
1225
|
+
interface AncestorInactiveCursor {
|
|
1226
|
+
resource: string;
|
|
1227
|
+
afterId: string | null;
|
|
1228
|
+
}
|
|
1229
|
+
interface RecomputeAncestorInactiveOptions {
|
|
1230
|
+
namespace: string;
|
|
1231
|
+
batchSize?: number;
|
|
1232
|
+
/** Maximum ancestor nodes visited per row; exceeding the bound fails explicitly. */
|
|
1233
|
+
maxGraphNodes?: number;
|
|
1234
|
+
cursor?: AncestorInactiveCursor | null;
|
|
1235
|
+
dryRun?: boolean;
|
|
1236
|
+
logger?: DatafnLogger;
|
|
1237
|
+
}
|
|
1238
|
+
interface RecomputeAncestorInactiveResult {
|
|
1239
|
+
scanned: number;
|
|
1240
|
+
updated: number;
|
|
1241
|
+
/** Mismatches not written because their compare-and-set lost a race. */
|
|
1242
|
+
skipped: number;
|
|
1243
|
+
/** Null once every dependent resource in the namespace has been visited. */
|
|
1244
|
+
nextCursor: AncestorInactiveCursor | null;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Ordered list of resources that own the runtime-maintained
|
|
1248
|
+
* `isAncestorInactive` field for `schema`.
|
|
1249
|
+
*/
|
|
1250
|
+
declare function ancestorInactiveResources(schema: DatafnSchema$1): string[];
|
|
1251
|
+
/**
|
|
1252
|
+
* Recomputes `isAncestorInactive` for one batch of records in `namespace`,
|
|
1253
|
+
* resolving each record against the current state of its parents. Rows are
|
|
1254
|
+
* visited in ascending id order per resource so the sweep is deterministic and
|
|
1255
|
+
* resumable via `nextCursor`. Ancestor flags are derived from primary state,
|
|
1256
|
+
* with bounded traversal and explicit cycle/malformed-link errors. Quiesce
|
|
1257
|
+
* ancestor/link mutations during repair; compare-and-set guards only the
|
|
1258
|
+
* derived value on each row, not an atomic snapshot of the entire graph.
|
|
1259
|
+
*/
|
|
1260
|
+
declare function recomputeAncestorInactive(adapter: Adapter, schema: DatafnSchema$1, options: RecomputeAncestorInactiveOptions): Promise<RecomputeAncestorInactiveResult>;
|
|
1261
|
+
interface RecomputeAncestorInactiveAllResult {
|
|
1262
|
+
scanned: number;
|
|
1263
|
+
updated: number;
|
|
1264
|
+
/** Mismatches not written because their compare-and-set lost a race. */
|
|
1265
|
+
skipped: number;
|
|
1266
|
+
sweeps: number;
|
|
1267
|
+
/** False when `maxSweeps` was reached while the last sweep changed or skipped rows. */
|
|
1268
|
+
converged: boolean;
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Runs full namespace sweeps of {@link recomputeAncestorInactive} until a
|
|
1272
|
+
* sweep produces no updates or skipped writes, verifying the prior sweep.
|
|
1273
|
+
* Bounded by `maxSweeps`; check `converged`
|
|
1274
|
+
* and rerun if it is false. Dry runs perform a single sweep.
|
|
1275
|
+
*/
|
|
1276
|
+
declare function recomputeAncestorInactiveAll(adapter: Adapter, schema: DatafnSchema$1, options: Omit<RecomputeAncestorInactiveOptions, "cursor"> & {
|
|
1277
|
+
maxSweeps?: number;
|
|
1278
|
+
}): Promise<RecomputeAncestorInactiveAllResult>;
|
|
1279
|
+
|
|
1280
|
+
export { type AncestorInactiveCursor, type ApplicationNamespaceStorageEntry, AtomicSequenceStore, ChainedSequenceStore, type CreateDatafnPublicLinkInput, type CrossResourceSearchParams, DATAFN_MULTI_REGION_CAPABILITY, DATAFN_ROUTING_ASSERTION_HEADER, DATAFN_ROUTING_INTERNAL_HEADERS, type DataFnAction, type DataFnAuthorizationDeniedEvent, type DataFnAuthorizationDeniedMetadata, type DataFnEvent, type DataFnEventMap, type DataFnEventType, type DataFnPayloadRejectedEvent, type DataFnPayloadRejectedMetadata, type DataFnRateLimitedEvent, type DataFnRateLimitedMetadata, type DataFnRequestEventMetadata, type DataFnRequestFailedEvent, type DataFnRequestFailedMetadata, type DataFnRetentionPruneFailedEvent, type DataFnRetentionPruneFailedMetadata, type DataFnRetentionPrunedEvent, type DataFnRetentionPrunedMetadata, DatabaseSequenceStore, type DatafnApp, type DatafnAppConfig, type DatafnAppServerConfig, type DatafnComposableRoute, type DatafnExecutor, type DatafnExecutorAction, DatafnExecutorError, type DatafnGatewayCellRegistry, type DatafnGatewayDispatcher, type DatafnGatewayRouter, type DatafnGatewayRouterConfig, type DatafnMultiRegionDirectory, type DatafnMultiRegionPluginConfig, type DatafnMultiRegionRuntimeConfig, type DatafnNamespaceMigrationContext, type DatafnNamespaceMigrationHooks, type DatafnNamespaceMigrationState, type DatafnNamespacePlacement, DatafnNamespaceStorageError, type DatafnNamespaceStorageErrorCode, type DatafnPermissionDirectoryGrant, type DatafnPlacementDirectoryAdapter, type DatafnPlacementRuntimeConfig, type DatafnPlacementState, type DatafnPluginAuthorizationInput, type DatafnPluginAuthorizationResult, type DatafnPluginRoutePlacement, type DatafnPluginRoutePlacementResult, type DatafnPublicLinkAuthorizationInput, type DatafnPublicLinkGrant, DatafnPublicLinkInputError, type DatafnPublicLinkPrincipal, type DatafnPublicLinkRecord, type DatafnPublicLinkShareLevel, type DatafnPublicLinkShareScope, type DatafnPublicLinksPlugin, type DatafnPublicLinksPluginConfig, type DatafnRegionalEndpoint, type DatafnRegionalTicketRuntime, type DatafnRouteBootstrapConfig, type DatafnRouteHeaderEntries, type DatafnRouteHeaderInput, type DatafnRouteHeaders, type DatafnRouteHookInput, type DatafnRouteHooks, type DatafnRouteIdentity, type DatafnRouteResponseHook, type DatafnRouteTicketClaims, type DatafnRouteTicketEvent, type DatafnRouteTicketSigner, type DatafnRouteTicketVerifier, type DatafnRoutingAssertionClaims, type DatafnRoutingAssertionSigner, type DatafnRoutingAssertionVerifier, DatafnRoutingError, type DatafnRoutingEvent, type DatafnRoutingEventType, type DatafnRoutingReplayStore, type DatafnServer, type DatafnServerConfig, type NamespaceStorageCatalog, type NamespaceStorageCatalogRelation, type NamespaceStorageEntry, type NamespaceStoragePlan, POSTGRES_NAMESPACE_STORAGE_CATALOG_SQL, POSTGRES_NAMESPACE_STORAGE_INDEX_SQL, type PostgresNamespaceStorageQuery, type RateLimitConfig, type RecomputeAncestorInactiveAllResult, type RecomputeAncestorInactiveOptions, type RecomputeAncestorInactiveResult, type SearchProvider, type SearchResult, type SearchResultItem, type SequenceStore, type SequenceStorePolicy, type StatusResult, ancestorInactiveResources, assertInternalNamespaceStorageMetadataComplete, claimDatafnNamespacePlacement, composeNamespaceStoragePlan, createConditionalKvDatafnPlacementDirectory, createDatafnGatewayRouter, createDatafnHmacRouteTickets, createDatafnHmacRoutingAssertions, createDatafnMultiRegionPlugin, createDatafnPublicLinksPlugin, createDatafnRouteBootstrap, createDatafnServer, createMemoryDatafnPlacementDirectory, createMemoryDatafnRoutingReplayStore, createSequenceStore, datafn, datafnMultiRegionPlugin, drainNamespacePermissionDirectoryOutbox, drainNamespaceStorage, inspectPostgresNamespaceStorage, migrateDatafnNamespace, namespacedInternalTableRoles, quotePostgresIdentifier, readDatafnPublicLinkToken, readDatafnRouteTicket, recomputeAncestorInactive, recomputeAncestorInactiveAll, resolveDatafnPublicLink, resolveNamespaceStoragePlan, routeTicketError, selectNamespaceStorageEntries, validateDatafnPlacement, validateDatafnRouteTicket, validateDatafnRoutingBodyLimit, withDatafnPublicLinksSchema, withDatafnRegionalCors, withDatafnRoutingAssertion };
|