@duraxis/core 0.3.0 → 0.5.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/CHANGELOG.md +26 -0
- package/README.md +10 -0
- package/dist/commit/commit-coordinator.d.ts +3 -1
- package/dist/config.d.ts +72 -0
- package/dist/database/duraxis-database.d.ts +39 -5
- package/dist/gc/garbage-collector.d.ts +5 -1
- package/dist/gc/reachability-scanner.d.ts +7 -2
- package/dist/gc/storage-coordination.d.ts +10 -0
- package/dist/index.cjs +1573 -321
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1561 -323
- package/dist/index.js.map +1 -1
- package/dist/indexes/bptree/bptree-node-cache.d.ts +7 -2
- package/dist/indexes/secondary/secondary-index-manager.d.ts +2 -1
- package/dist/query/context/query-context.d.ts +26 -9
- package/dist/query/executor/query-executor.d.ts +3 -0
- package/dist/query/model/cursor.d.ts +7 -2
- package/dist/query/planner/rule-based-planner.d.ts +4 -1
- package/dist/query/validation/query-validator.d.ts +5 -1
- package/dist/relations/foreign-key-manager.d.ts +1 -1
- package/dist/resources/operation-owner.d.ts +25 -0
- package/dist/resources/prepared-writes.d.ts +11 -0
- package/dist/resources/resource-manager.d.ts +64 -0
- package/dist/transactions/transaction.d.ts +35 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @duraxis/core changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6377fde: Add framework-independent configuration and owned database/ORM factories, bounded decorated-entity discovery, and shared NestJS/CLI schema resolution. Initialize projects with one source-root configuration and direct AST-guided AppModule integration. Support static inspection/mutation, centralized named connections, registry-free generators and source/compiled deployments without runtime CLI dependencies. Use shared typed configuration across runtime and CLI, standard Nest feature modules, and authenticated encrypted cursors. Document storage, migration, discovery and lifecycle contracts.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [6377fde]
|
|
12
|
+
- @duraxis/storage@0.2.1
|
|
13
|
+
|
|
14
|
+
## 0.4.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- a4bed1c: Harden bounded production pilots with hierarchical resource admission, query and transaction deadlines, tracked pending I/O, bounded materialization, weighted caches, incremental listings and journal replay, and verified single-owner garbage collection.
|
|
19
|
+
|
|
20
|
+
Breaking pre-1.0 changes: Core requires bounded-read adapter capabilities; resource limits now reject oversized work; destructive S3 GC fails closed; encrypted expiring v3 cursors replace signed database cursors. Restart pagination and provision stable encryption keys. Tenant context checks strengthen application isolation but do not authorize raw storage access.
|
|
21
|
+
|
|
22
|
+
Add conservative commit reconciliation and bounded atomic idempotency receipts without callback retries. Preserve manifest CAS, physical persistence formats and migration checksum identities. See docs/PRODUCTION-HARDENING.md for defaults, deployment constraints, receipt retention and remaining index/FK accounting limitations.
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [a4bed1c]
|
|
27
|
+
- @duraxis/storage@0.2.0
|
|
28
|
+
|
|
3
29
|
## 0.3.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -73,3 +73,13 @@ upgrade Core before adopting migrations and do not downgrade migrated databases.
|
|
|
73
73
|
Affected-schema validation stages final records in memory. Streaming reads do not
|
|
74
74
|
bound transaction memory, and schema-mutated index queries may scan and sort.
|
|
75
75
|
For versioned evolution use [`@duraxis/migrations`](../migrations/README.md).
|
|
76
|
+
|
|
77
|
+
## Production resource and lifecycle limits
|
|
78
|
+
|
|
79
|
+
See the [production hardening guide](../../docs/PRODUCTION-HARDENING.md) for bounded defaults, cancellation, verified maintenance, tenant trust boundaries, encrypted cursors, upgrade instructions and remaining pilot limitations. Core rejects storage adapters without bounded-read capability; destructive shared-storage garbage collection is unsupported.
|
|
80
|
+
|
|
81
|
+
## CLI project setup
|
|
82
|
+
|
|
83
|
+
Run `npx --package @duraxis/cli@latest duraxis init` to generate one source-root configuration. NestJS AppModule integration is automatic; standalone applications call the public runtime factories. See the [shared configuration API and examples](../../docs/CLI-SETUP.md) and [setup guide](../../docs/CLI-SETUP.md).
|
|
84
|
+
|
|
85
|
+
`defineDuraxisConfig`, `selectDuraxisConnection`, `normalizeDuraxisConnection`, `duraxisDriverContext` and `createDatabase` are framework-independent exports. Configuration accepts a driver/driver factory or a centralized named `connections` map. Core does not import ORM, NestJS or CLI. `createDatabase` owns factory-created drivers and closes them on initialization failure and default shutdown; supplied instances remain externally owned unless requested.
|
|
@@ -4,9 +4,11 @@ import { StorageKeyManager } from "../security/storage-key-manager.js";
|
|
|
4
4
|
export declare class CommitCoordinator {
|
|
5
5
|
private readonly storage;
|
|
6
6
|
private readonly keys;
|
|
7
|
+
private readonly coordinationStorage;
|
|
7
8
|
private readonly primary;
|
|
8
9
|
private readonly secondary;
|
|
9
10
|
private readonly foreignKeys;
|
|
10
|
-
constructor(storage: StorageDriver, keys?: StorageKeyManager);
|
|
11
|
+
constructor(storage: StorageDriver, keys?: StorageKeyManager, coordinationStorage?: StorageDriver);
|
|
11
12
|
commit(transaction: Transaction): Promise<void>;
|
|
13
|
+
private publish;
|
|
12
14
|
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { StorageDriver } from "@duraxis/storage";
|
|
2
|
+
import { DuraxisDatabase, type DuraxisDatabaseOptions } from "./database/duraxis-database.js";
|
|
3
|
+
export type ConfigEntity = new (...args: never[]) => object;
|
|
4
|
+
export interface EntityDiscoveryOptions {
|
|
5
|
+
readonly directories?: readonly string[];
|
|
6
|
+
readonly allowEmpty?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DuraxisDriverContext {
|
|
9
|
+
readonly root: string;
|
|
10
|
+
readonly directory: string;
|
|
11
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
12
|
+
readonly resolvePath: (path: string) => string;
|
|
13
|
+
}
|
|
14
|
+
export interface DuraxisConnectionOptions {
|
|
15
|
+
readonly name?: string;
|
|
16
|
+
readonly driver: StorageDriver | ((context: DuraxisDriverContext) => StorageDriver | Promise<StorageDriver>);
|
|
17
|
+
readonly location?: string | URL;
|
|
18
|
+
readonly baseDirectory?: string;
|
|
19
|
+
readonly database?: Omit<DuraxisDatabaseOptions, "storage">;
|
|
20
|
+
readonly cursorKeyEnv?: string;
|
|
21
|
+
readonly closeStorage?: boolean;
|
|
22
|
+
readonly entities?: readonly ConfigEntity[] | (() => readonly ConfigEntity[] | Promise<readonly ConfigEntity[]>);
|
|
23
|
+
readonly autoLoadEntities?: boolean | EntityDiscoveryOptions;
|
|
24
|
+
readonly schema?: {
|
|
25
|
+
readonly mode: "create" | "validate" | "validate-managed";
|
|
26
|
+
};
|
|
27
|
+
readonly migrations?: boolean | {
|
|
28
|
+
readonly directory?: string;
|
|
29
|
+
readonly snapshots?: string;
|
|
30
|
+
readonly format?: "ts" | "js" | "mts" | "mjs";
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface DuraxisConnectionsOptions {
|
|
34
|
+
readonly defaultConnection?: string;
|
|
35
|
+
readonly connections: Readonly<Record<string, DuraxisConnectionOptions>>;
|
|
36
|
+
}
|
|
37
|
+
export type DuraxisConfiguration = DuraxisConnectionOptions | DuraxisConnectionsOptions;
|
|
38
|
+
export declare function isDuraxisConfiguration(value: unknown): value is DuraxisConfiguration;
|
|
39
|
+
export declare function defineDuraxisConfig<const T extends DuraxisConfiguration>(config: T): T;
|
|
40
|
+
export declare function validateConnectionName(name: string): string;
|
|
41
|
+
export declare function selectDuraxisConnection(config: DuraxisConfiguration, name?: string): DuraxisConnectionOptions;
|
|
42
|
+
export declare function duraxisDriverContext(options: DuraxisConnectionOptions): DuraxisDriverContext;
|
|
43
|
+
export declare function normalizeDuraxisConnection(options: DuraxisConnectionOptions): {
|
|
44
|
+
name?: string;
|
|
45
|
+
driver: StorageDriver | ((context: DuraxisDriverContext) => StorageDriver | Promise<StorageDriver>);
|
|
46
|
+
location?: string | URL;
|
|
47
|
+
baseDirectory?: string;
|
|
48
|
+
cursorKeyEnv?: string;
|
|
49
|
+
closeStorage?: boolean;
|
|
50
|
+
entities?: readonly ConfigEntity[] | (() => readonly ConfigEntity[] | Promise<readonly ConfigEntity[]>);
|
|
51
|
+
autoLoadEntities?: boolean | EntityDiscoveryOptions;
|
|
52
|
+
context: DuraxisDriverContext;
|
|
53
|
+
database: {
|
|
54
|
+
cursorSigningKey?: Uint8Array;
|
|
55
|
+
resources?: Partial<import("./index.js").ResourceLimits>;
|
|
56
|
+
cursorEncryption?: import("./index.js").CursorKeyring;
|
|
57
|
+
accessScope?: {
|
|
58
|
+
readonly tenant: string;
|
|
59
|
+
readonly currentTenant: () => string | undefined;
|
|
60
|
+
};
|
|
61
|
+
namespace?: string | undefined;
|
|
62
|
+
};
|
|
63
|
+
schema: {
|
|
64
|
+
readonly mode: "create" | "validate" | "validate-managed";
|
|
65
|
+
};
|
|
66
|
+
migrations: {
|
|
67
|
+
directory: string;
|
|
68
|
+
snapshots: string;
|
|
69
|
+
format: "js" | "mjs" | "mts" | "ts";
|
|
70
|
+
} | undefined;
|
|
71
|
+
};
|
|
72
|
+
export declare function createDatabase(config: DuraxisConfiguration, name?: string): Promise<DuraxisDatabase>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CursorKeyring } from "../query/model/cursor.js";
|
|
2
|
+
import { type ResourceLimits, type ResourceScope } from "../resources/resource-manager.js";
|
|
1
3
|
import type { StorageDriver } from "@duraxis/storage";
|
|
2
4
|
import { Transaction } from "../transactions/transaction.js";
|
|
3
5
|
import type { SnapshotReader } from "../snapshots/snapshot-reader.js";
|
|
@@ -12,6 +14,12 @@ export interface DuraxisDatabaseOptions {
|
|
|
12
14
|
readonly storage: StorageDriver;
|
|
13
15
|
readonly namespace?: string;
|
|
14
16
|
readonly cursorSigningKey?: Uint8Array;
|
|
17
|
+
readonly resources?: Partial<ResourceLimits>;
|
|
18
|
+
readonly cursorEncryption?: CursorKeyring;
|
|
19
|
+
readonly accessScope?: {
|
|
20
|
+
readonly tenant: string;
|
|
21
|
+
readonly currentTenant: () => string | undefined;
|
|
22
|
+
};
|
|
15
23
|
}
|
|
16
24
|
export interface CollectionRow {
|
|
17
25
|
readonly id: string;
|
|
@@ -27,25 +35,45 @@ export interface DuraxisMetrics {
|
|
|
27
35
|
readonly queryDurationMs: number;
|
|
28
36
|
readonly garbageCollections: number;
|
|
29
37
|
readonly garbageCollectionDurationMs: number;
|
|
38
|
+
readonly resources: ReturnType<ResourceScope["metrics"]>;
|
|
30
39
|
readonly storage?: ReturnType<NonNullable<StorageDriver["getMetrics"]>>;
|
|
31
40
|
}
|
|
32
41
|
export declare class DuraxisDatabase {
|
|
42
|
+
readonly resourceLimits: Readonly<ResourceLimits>;
|
|
43
|
+
readonly resources: ResourceScope;
|
|
44
|
+
private readonly cursorEncryption?;
|
|
45
|
+
private readonly accessScope?;
|
|
33
46
|
private readonly storage;
|
|
34
47
|
private readonly keys;
|
|
35
|
-
private readonly coordinator;
|
|
36
|
-
private readonly recovery;
|
|
37
|
-
private readonly primary;
|
|
38
|
-
private readonly secondary;
|
|
39
48
|
private readonly cursorSigningKey;
|
|
40
49
|
private readonly planner;
|
|
41
50
|
private readonly planCompiler;
|
|
42
51
|
private readonly metrics;
|
|
43
52
|
private readonly active;
|
|
53
|
+
private readonly owners;
|
|
54
|
+
private readonly operations;
|
|
55
|
+
private closePromise?;
|
|
56
|
+
private readonly cleanupFailures;
|
|
57
|
+
private readonly outcomes;
|
|
58
|
+
private readonly drainWaiters;
|
|
44
59
|
private maintenance;
|
|
45
60
|
private pendingSnapshotAcquisitions;
|
|
46
61
|
private closed;
|
|
47
62
|
constructor(options: DuraxisDatabaseOptions);
|
|
63
|
+
get namespace(): string;
|
|
64
|
+
static forTenant(options: Omit<DuraxisDatabaseOptions, "namespace" | "accessScope"> & {
|
|
65
|
+
readonly tenant: string;
|
|
66
|
+
readonly currentTenant: () => string | undefined;
|
|
67
|
+
}): DuraxisDatabase;
|
|
68
|
+
private assertAccess;
|
|
48
69
|
transaction<T>(callback: (tx: Transaction) => Promise<T> | T): Promise<T>;
|
|
70
|
+
private rememberOutcome;
|
|
71
|
+
resolveCommitOutcome(id: string): Promise<"COMMITTED" | "NOT_COMMITTED" | "UNKNOWN">;
|
|
72
|
+
transactionOnce<T>(operationId: string, callback: (tx: Transaction) => Promise<T> | T): Promise<{
|
|
73
|
+
readonly applied: boolean;
|
|
74
|
+
readonly transactionId: string;
|
|
75
|
+
readonly result?: T;
|
|
76
|
+
}>;
|
|
49
77
|
snapshot<T>(callback: (reader: SnapshotReader) => Promise<T> | T): Promise<T>;
|
|
50
78
|
defineCollection(schema: CollectionDefinition): Promise<void>;
|
|
51
79
|
defineCollections(schemas: readonly CollectionDefinition[]): Promise<void>;
|
|
@@ -57,6 +85,10 @@ export declare class DuraxisDatabase {
|
|
|
57
85
|
queryPage(query: LogicalQuery, options?: QueryExecutorOptions): Promise<QueryPage>;
|
|
58
86
|
queryPage(query: LogicalQuery, source: QueryOperator, options?: QueryExecutorOptions): Promise<QueryPage>;
|
|
59
87
|
queryAll(query: LogicalQuery, options?: QueryExecutorOptions): Promise<readonly QueryRow[]>;
|
|
88
|
+
createMaterializationBudget<T>(): {
|
|
89
|
+
add(value: T): void;
|
|
90
|
+
close(): void;
|
|
91
|
+
};
|
|
60
92
|
explain(query: LogicalQuery): Promise<ExplainResult>;
|
|
61
93
|
executePlan(query: LogicalQuery, plan: PhysicalPlan, options?: QueryExecutorOptions): AsyncIterable<QueryRow>;
|
|
62
94
|
getDocument(collection: string, id: string): Promise<DocumentRecord | null>;
|
|
@@ -64,7 +96,6 @@ export declare class DuraxisDatabase {
|
|
|
64
96
|
scanCollection(collection: string, limit?: number): Promise<CollectionRow[]>;
|
|
65
97
|
getCommitStatus(transactionId: string): Promise<import("../recovery/recovery-manager.js").CommitStatus>;
|
|
66
98
|
verifyHistory(): Promise<number>;
|
|
67
|
-
/** Starts a new verifiable commit-history chain without changing data roots. */
|
|
68
99
|
checkpointHistory(): Promise<string>;
|
|
69
100
|
verifyIntegrity(): Promise<{
|
|
70
101
|
objects: number;
|
|
@@ -73,6 +104,8 @@ export declare class DuraxisDatabase {
|
|
|
73
104
|
commits: number;
|
|
74
105
|
}>;
|
|
75
106
|
collectGarbage(storage: StorageDriver, options?: GarbageCollectionOptions): Promise<GarbageCollectionReport>;
|
|
107
|
+
private finishSnapshot;
|
|
108
|
+
private queryContext;
|
|
76
109
|
private releaseSnapshot;
|
|
77
110
|
private queryOptions;
|
|
78
111
|
private bindSignal;
|
|
@@ -81,6 +114,7 @@ export declare class DuraxisDatabase {
|
|
|
81
114
|
getMetrics(): DuraxisMetrics;
|
|
82
115
|
close(options?: {
|
|
83
116
|
readonly closeStorage?: boolean;
|
|
117
|
+
readonly timeoutMs?: number;
|
|
84
118
|
}): Promise<void>;
|
|
85
119
|
private createSnapshot;
|
|
86
120
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResourceScope } from "../resources/resource-manager.js";
|
|
1
2
|
import type { StorageDriver } from "@duraxis/storage";
|
|
2
3
|
import { type Snapshot } from "../commit/manifest.js";
|
|
3
4
|
import { StorageKeyManager } from "../security/storage-key-manager.js";
|
|
@@ -9,6 +10,8 @@ export interface GarbageCollectionOptions {
|
|
|
9
10
|
readonly batchSize?: number;
|
|
10
11
|
readonly signal?: AbortSignal;
|
|
11
12
|
readonly continueOnError?: boolean;
|
|
13
|
+
readonly maxMarkBytes?: number;
|
|
14
|
+
readonly maxReferences?: number;
|
|
12
15
|
}
|
|
13
16
|
export interface GarbageCollectionReport {
|
|
14
17
|
readonly scanned: number;
|
|
@@ -26,6 +29,7 @@ export declare class GarbageCollector {
|
|
|
26
29
|
private readonly keys;
|
|
27
30
|
private readonly activeSnapshots;
|
|
28
31
|
private readonly scanner;
|
|
29
|
-
|
|
32
|
+
private readonly resourceParent;
|
|
33
|
+
constructor(storage: StorageDriver, keys: StorageKeyManager, activeSnapshots: () => readonly Snapshot[], scanner?: ReachabilityScanner, resourceParent?: ResourceScope);
|
|
30
34
|
collect(options?: GarbageCollectionOptions): Promise<GarbageCollectionReport>;
|
|
31
35
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { StorageDriver } from "@duraxis/storage";
|
|
2
2
|
import type { Snapshot } from "../commit/manifest.js";
|
|
3
3
|
import { StorageKeyManager } from "../security/storage-key-manager.js";
|
|
4
|
+
export interface ReachabilityOptions {
|
|
5
|
+
readonly maxReferences?: number;
|
|
6
|
+
readonly maxBytes?: number;
|
|
7
|
+
readonly signal?: AbortSignal;
|
|
8
|
+
}
|
|
4
9
|
export interface ReachabilityScanner {
|
|
5
|
-
scan(snapshot: Snapshot): Promise<ReadonlySet<string>>;
|
|
10
|
+
scan(snapshot: Snapshot, options?: ReachabilityOptions): Promise<ReadonlySet<string>>;
|
|
6
11
|
}
|
|
7
12
|
export declare class ManifestReachabilityScanner implements ReachabilityScanner {
|
|
8
13
|
private readonly keys;
|
|
9
14
|
private readonly nodes;
|
|
10
15
|
private readonly primary;
|
|
11
16
|
constructor(keys: StorageKeyManager, storage: StorageDriver);
|
|
12
|
-
scan(snapshot: Snapshot): Promise<ReadonlySet<string>>;
|
|
17
|
+
scan(snapshot: Snapshot, options?: ReachabilityOptions): Promise<ReadonlySet<string>>;
|
|
13
18
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StorageDriver } from "@duraxis/storage";
|
|
2
|
+
import type { Snapshot } from "../commit/manifest.js";
|
|
3
|
+
interface Coordination {
|
|
4
|
+
active: number;
|
|
5
|
+
maintenance: boolean;
|
|
6
|
+
snapshots: Set<Snapshot>;
|
|
7
|
+
}
|
|
8
|
+
export declare function storageCoordination(storage: StorageDriver): Coordination;
|
|
9
|
+
export declare function coordinateCommit<T>(storage: StorageDriver, maximum: number, action: () => Promise<T>): Promise<T>;
|
|
10
|
+
export {};
|