@brightchain/node-express-suite 0.25.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/MIGRATION.md +131 -0
- package/README.md +11 -0
- package/package.json +18 -0
- package/src/index.d.ts +46 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +73 -0
- package/src/index.js.map +1 -0
- package/src/lib/application.d.ts +35 -0
- package/src/lib/application.d.ts.map +1 -0
- package/src/lib/application.js +38 -0
- package/src/lib/application.js.map +1 -0
- package/src/lib/bright-db-model-registry.d.ts +56 -0
- package/src/lib/bright-db-model-registry.d.ts.map +1 -0
- package/src/lib/bright-db-model-registry.js +71 -0
- package/src/lib/bright-db-model-registry.js.map +1 -0
- package/src/lib/brightchain-lib.d.ts +7 -0
- package/src/lib/brightchain-lib.d.ts.map +1 -0
- package/src/lib/brightchain-lib.js +12 -0
- package/src/lib/brightchain-lib.js.map +1 -0
- package/src/lib/brightdb.d.ts +7 -0
- package/src/lib/brightdb.d.ts.map +1 -0
- package/src/lib/brightdb.js +11 -0
- package/src/lib/brightdb.js.map +1 -0
- package/src/lib/constants.d.ts +6 -0
- package/src/lib/constants.d.ts.map +1 -0
- package/src/lib/constants.js +12 -0
- package/src/lib/constants.js.map +1 -0
- package/src/lib/create-test-app.d.ts +22 -0
- package/src/lib/create-test-app.d.ts.map +1 -0
- package/src/lib/create-test-app.js +49 -0
- package/src/lib/create-test-app.js.map +1 -0
- package/src/lib/databaseInit.d.ts +53 -0
- package/src/lib/databaseInit.d.ts.map +1 -0
- package/src/lib/databaseInit.js +114 -0
- package/src/lib/databaseInit.js.map +1 -0
- package/src/lib/datastore/block-document-store-factory.d.ts +31 -0
- package/src/lib/datastore/block-document-store-factory.d.ts.map +1 -0
- package/src/lib/datastore/block-document-store-factory.js +35 -0
- package/src/lib/datastore/block-document-store-factory.js.map +1 -0
- package/src/lib/datastore/block-document-store.d.ts +201 -0
- package/src/lib/datastore/block-document-store.d.ts.map +1 -0
- package/src/lib/datastore/block-document-store.js +649 -0
- package/src/lib/datastore/block-document-store.js.map +1 -0
- package/src/lib/datastore/document-store.d.ts +83 -0
- package/src/lib/datastore/document-store.d.ts.map +1 -0
- package/src/lib/datastore/document-store.js +3 -0
- package/src/lib/datastore/document-store.js.map +1 -0
- package/src/lib/datastore/index.d.ts +6 -0
- package/src/lib/datastore/index.d.ts.map +1 -0
- package/src/lib/datastore/index.js +11 -0
- package/src/lib/datastore/index.js.map +1 -0
- package/src/lib/datastore/memory-document-store.d.ts +9 -0
- package/src/lib/datastore/memory-document-store.d.ts.map +1 -0
- package/src/lib/datastore/memory-document-store.js +218 -0
- package/src/lib/datastore/memory-document-store.js.map +1 -0
- package/src/lib/environment.d.ts +64 -0
- package/src/lib/environment.d.ts.map +1 -0
- package/src/lib/environment.js +165 -0
- package/src/lib/environment.js.map +1 -0
- package/src/lib/factories/blockStoreFactory.d.ts +10 -0
- package/src/lib/factories/blockStoreFactory.d.ts.map +1 -0
- package/src/lib/factories/blockStoreFactory.js +14 -0
- package/src/lib/factories/blockStoreFactory.js.map +1 -0
- package/src/lib/interfaces/bright-db-application.d.ts +34 -0
- package/src/lib/interfaces/bright-db-application.d.ts.map +1 -0
- package/src/lib/interfaces/bright-db-application.js +13 -0
- package/src/lib/interfaces/bright-db-application.js.map +1 -0
- package/src/lib/interfaces/environment.d.ts +34 -0
- package/src/lib/interfaces/environment.d.ts.map +1 -0
- package/src/lib/interfaces/environment.js +11 -0
- package/src/lib/interfaces/environment.js.map +1 -0
- package/src/lib/middleware/index.d.ts +2 -0
- package/src/lib/middleware/index.d.ts.map +1 -0
- package/src/lib/middleware/index.js +6 -0
- package/src/lib/middleware/index.js.map +1 -0
- package/src/lib/middleware/validateBody.d.ts +13 -0
- package/src/lib/middleware/validateBody.d.ts.map +1 -0
- package/src/lib/middleware/validateBody.js +35 -0
- package/src/lib/middleware/validateBody.js.map +1 -0
- package/src/lib/middlewares.d.ts +9 -0
- package/src/lib/middlewares.d.ts.map +1 -0
- package/src/lib/middlewares.js +21 -0
- package/src/lib/middlewares.js.map +1 -0
- package/src/lib/plugins/bright-db-database-plugin.d.ts +95 -0
- package/src/lib/plugins/bright-db-database-plugin.d.ts.map +1 -0
- package/src/lib/plugins/bright-db-database-plugin.js +143 -0
- package/src/lib/plugins/bright-db-database-plugin.js.map +1 -0
- package/src/lib/plugins/configure-bright-db-app.d.ts +25 -0
- package/src/lib/plugins/configure-bright-db-app.d.ts.map +1 -0
- package/src/lib/plugins/configure-bright-db-app.js +31 -0
- package/src/lib/plugins/configure-bright-db-app.js.map +1 -0
- package/src/lib/services/bright-db-authentication-provider.d.ts +31 -0
- package/src/lib/services/bright-db-authentication-provider.d.ts.map +1 -0
- package/src/lib/services/bright-db-authentication-provider.js +91 -0
- package/src/lib/services/bright-db-authentication-provider.js.map +1 -0
- package/src/lib/services/bright-db-base-service.d.ts +26 -0
- package/src/lib/services/bright-db-base-service.d.ts.map +1 -0
- package/src/lib/services/bright-db-base-service.js +30 -0
- package/src/lib/services/bright-db-base-service.js.map +1 -0
- package/src/lib/services/bright-db-collection.d.ts +50 -0
- package/src/lib/services/bright-db-collection.d.ts.map +1 -0
- package/src/lib/services/bright-db-collection.js +116 -0
- package/src/lib/services/bright-db-collection.js.map +1 -0
- package/src/lib/services/sessionAdapter.d.ts +62 -0
- package/src/lib/services/sessionAdapter.d.ts.map +1 -0
- package/src/lib/services/sessionAdapter.js +106 -0
- package/src/lib/services/sessionAdapter.js.map +1 -0
- package/src/lib/shared-types.d.ts +41 -0
- package/src/lib/shared-types.d.ts.map +1 -0
- package/src/lib/shared-types.js +3 -0
- package/src/lib/shared-types.js.map +1 -0
- package/src/lib/transactions/bright-db-transaction-manager.d.ts +46 -0
- package/src/lib/transactions/bright-db-transaction-manager.d.ts.map +1 -0
- package/src/lib/transactions/bright-db-transaction-manager.js +81 -0
- package/src/lib/transactions/bright-db-transaction-manager.js.map +1 -0
- package/src/lib/types/backend-id.d.ts +3 -0
- package/src/lib/types/backend-id.d.ts.map +1 -0
- package/src/lib/types/backend-id.js +3 -0
- package/src/lib/types/backend-id.js.map +1 -0
- package/src/lib/upstream.d.ts +8 -0
- package/src/lib/upstream.d.ts.map +1 -0
- package/src/lib/upstream.js +13 -0
- package/src/lib/upstream.js.map +1 -0
- package/src/lib/validation/userValidation.d.ts +44 -0
- package/src/lib/validation/userValidation.d.ts.map +1 -0
- package/src/lib/validation/userValidation.js +147 -0
- package/src/lib/validation/userValidation.js.map +1 -0
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# MERN → BERN Migration Guide
|
|
2
|
+
|
|
3
|
+
Migrate from `@digitaldefiance/node-express-suite` (Mongoose/MongoDB) to `@brightchain/node-express-suite` (BrightDB).
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
| Upstream (MERN) | Suite (BERN) |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `MongoBaseService` | `BrightDbBaseService` |
|
|
10
|
+
| `MongooseCollection` | `BrightDbCollection` |
|
|
11
|
+
| `MongooseDocumentStore` | `BlockDocumentStore` |
|
|
12
|
+
| `MongooseSessionAdapter` | `BrightChainSessionAdapter` |
|
|
13
|
+
| `MongoDatabasePlugin` | `BrightDbDatabasePlugin` |
|
|
14
|
+
| `MongoAuthenticationProvider` | `BrightDbAuthenticationProvider` |
|
|
15
|
+
| `ModelRegistry` | `BrightDbModelRegistry` |
|
|
16
|
+
| `TransactionManager` | `BrightDbTransactionManager` |
|
|
17
|
+
| `IMongoApplication` | `IBrightDbApplication` |
|
|
18
|
+
| `MongoApplicationConcrete` | `BrightDbApplication` |
|
|
19
|
+
| `BaseEnvironment` + `.mongo` | `BrightDbEnvironment` |
|
|
20
|
+
|
|
21
|
+
## Step-by-Step
|
|
22
|
+
|
|
23
|
+
### 1. Update dependencies
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"dependencies": {
|
|
28
|
+
- "@digitaldefiance/node-express-suite": "...",
|
|
29
|
+
+ "@brightchain/node-express-suite": "..."
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
+ "@brightchain/brightchain-lib": "...",
|
|
33
|
+
+ "@brightchain/db": "..."
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Replace imports
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// Before
|
|
42
|
+
import { MongoBaseService, MongoDatabasePlugin } from '@digitaldefiance/node-express-suite';
|
|
43
|
+
|
|
44
|
+
// After
|
|
45
|
+
import { BrightDbBaseService, BrightDbDatabasePlugin } from '@brightchain/node-express-suite';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Replace database plugin
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Before
|
|
52
|
+
const plugin = new MongoDatabasePlugin(environment);
|
|
53
|
+
await plugin.connect(mongoUri);
|
|
54
|
+
|
|
55
|
+
// After
|
|
56
|
+
const plugin = new BrightDbDatabasePlugin(environment);
|
|
57
|
+
await plugin.connect(); // No URI needed — uses blockstore config from environment
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 4. Replace services
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Before
|
|
64
|
+
class MyService extends MongoBaseService {
|
|
65
|
+
async getUsers() {
|
|
66
|
+
const model = this.application.getModel('users');
|
|
67
|
+
return model.find({}).exec();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// After
|
|
72
|
+
class MyService extends BrightDbBaseService {
|
|
73
|
+
async getUsers() {
|
|
74
|
+
const model = this.application.getModel('users');
|
|
75
|
+
return model.find({}).exec();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 5. Replace document store
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// Before
|
|
84
|
+
const store = new MongooseDocumentStore(connection);
|
|
85
|
+
const users = store.collection('users');
|
|
86
|
+
|
|
87
|
+
// After
|
|
88
|
+
const store = new BlockDocumentStore(blockStore);
|
|
89
|
+
const users = store.collection('users');
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 6. Replace transactions
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// Before
|
|
96
|
+
const txMgr = new TransactionManager(connection, true);
|
|
97
|
+
await txMgr.execute(async (session) => { ... });
|
|
98
|
+
|
|
99
|
+
// After
|
|
100
|
+
const txMgr = new BrightDbTransactionManager(db, true);
|
|
101
|
+
await txMgr.execute(async (session) => { ... });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 7. Update environment config
|
|
105
|
+
|
|
106
|
+
Remove MongoDB URI configuration, add BrightDB blockstore config:
|
|
107
|
+
|
|
108
|
+
```env
|
|
109
|
+
# Remove
|
|
110
|
+
# MONGO_URI=mongodb://localhost:27017/mydb
|
|
111
|
+
|
|
112
|
+
# Add
|
|
113
|
+
BRIGHTCHAIN_BLOCKSTORE_PATH=/data/blocks
|
|
114
|
+
BRIGHTCHAIN_BLOCKSIZE_BYTES=1024
|
|
115
|
+
BRIGHTCHAIN_BLOCKSTORE_TYPE=disk
|
|
116
|
+
USE_MEMORY_DOCSTORE=false
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Behavioral Differences
|
|
120
|
+
|
|
121
|
+
| Feature | Mongoose/MongoDB | BrightDB |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| Change streams | `collection.watch()` supported | `watch()` supported (in-memory listeners) |
|
|
124
|
+
| Transactions | Multi-document ACID via replica set | Session-based with journal replay |
|
|
125
|
+
| Estimated count | O(1) via collection metadata | Delegates to `countDocuments()` |
|
|
126
|
+
| Text search | Native `$text` operator | In-memory tokenization via text indexes |
|
|
127
|
+
| Aggregation | Full MongoDB aggregation pipeline | Subset: `$match`, `$group`, `$sort`, `$limit`, `$skip`, `$project`, `$unwind`, `$lookup`, `$count`, `$addFields`, `$facet` |
|
|
128
|
+
| Query operators | Full MongoDB query language | Core operators: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$regex`, `$exists`, `$and`, `$or`, `$not`, `$nor`, `$elemMatch` |
|
|
129
|
+
| Indexes | B-tree, compound, TTL, geospatial | In-memory indexes with TTL support |
|
|
130
|
+
| Storage | Disk-based with WiredTiger | Content-addressable block store |
|
|
131
|
+
| Schema validation | Mongoose schemas | `CollectionSchema` with field-level validation |
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# brightchain-node-express-suite
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build brightchain-node-express-suite` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test brightchain-node-express-suite` to execute the unit tests via [Jest](https://jestjs.io).
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brightchain/node-express-suite",
|
|
3
|
+
"version": "0.25.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@digitaldefiance/branded-interface": "^0.0.5",
|
|
13
|
+
"@digitaldefiance/node-ecies-lib": "^4.20.0",
|
|
14
|
+
"@digitaldefiance/node-express-suite": "^4.20.1",
|
|
15
|
+
"@brightchain/brightchain-lib": "^0.25.0",
|
|
16
|
+
"@brightchain/db": "^0.25.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brightchain/node-express-suite
|
|
3
|
+
*
|
|
4
|
+
* Generic BrightDB-backed Express infrastructure extracted from brightchain-api-lib.
|
|
5
|
+
* This library sits between @digitaldefiance/node-express-suite (upstream) and
|
|
6
|
+
* @brightchain/brightchain-api-lib (domain-specific).
|
|
7
|
+
*/
|
|
8
|
+
export type { GuidV4Buffer, SignatureBuffer, ClientSession, DefaultBackendIdType, IBlockStorageSchema, IBlockStorageModel, IBlockStorageSchemaEntry, SchemaMap, } from './lib/shared-types';
|
|
9
|
+
export type { DefaultBackendIdType as DefaultBackendIdType_ } from './lib/types/backend-id';
|
|
10
|
+
export type { CreateDocumentOptions, RetrieveDocumentOptions, } from './lib/datastore/block-document-store';
|
|
11
|
+
export { BlockDocumentStore, CollectionHeadRegistry } from './lib/datastore/block-document-store';
|
|
12
|
+
export * from './lib/datastore/block-document-store-factory';
|
|
13
|
+
export * from './lib/datastore/document-store';
|
|
14
|
+
export { MemoryDocumentStore } from './lib/datastore/memory-document-store';
|
|
15
|
+
export type { IValidationError, IValidationResult } from './lib/validation/userValidation';
|
|
16
|
+
export { validateRegistration, validateLogin, validatePasswordChange, validateRecovery, } from './lib/validation/userValidation';
|
|
17
|
+
export { validateBody } from './lib/middleware/validateBody';
|
|
18
|
+
export type { ISessionDocument } from './lib/services/sessionAdapter';
|
|
19
|
+
export { BrightChainSessionAdapter } from './lib/services/sessionAdapter';
|
|
20
|
+
export type { IDatabaseInitEnvironment, IGenericInitData } from './lib/databaseInit';
|
|
21
|
+
export { brightchainDatabaseInit } from './lib/databaseInit';
|
|
22
|
+
export { BlockStoreFactory } from './lib/factories/blockStoreFactory';
|
|
23
|
+
export { BrightDbEnvironment } from './lib/environment';
|
|
24
|
+
export type { IAzureEnvironmentConfig, IS3EnvironmentConfig } from './lib/interfaces/environment';
|
|
25
|
+
export { BrightDbDatabasePlugin } from './lib/plugins/bright-db-database-plugin';
|
|
26
|
+
export type { IBrightDbDatabasePluginOptions } from './lib/plugins/bright-db-database-plugin';
|
|
27
|
+
export { BrightDbApplication } from './lib/application';
|
|
28
|
+
export type { IBrightDbApplication } from './lib/interfaces/bright-db-application';
|
|
29
|
+
export { configureBrightDbApp } from './lib/plugins/configure-bright-db-app';
|
|
30
|
+
export type { ConfigureBrightDbAppResult } from './lib/plugins/configure-bright-db-app';
|
|
31
|
+
export { BrightDbAuthenticationProvider } from './lib/services/bright-db-authentication-provider';
|
|
32
|
+
export { BrightDbConstants } from './lib/constants';
|
|
33
|
+
export { BrightDbMiddlewares } from './lib/middlewares';
|
|
34
|
+
export * from './lib/upstream';
|
|
35
|
+
export * from './lib/brightdb';
|
|
36
|
+
export * from './lib/brightchain-lib';
|
|
37
|
+
export { createTestApp } from './lib/create-test-app';
|
|
38
|
+
export type { CreateTestAppResult } from './lib/create-test-app';
|
|
39
|
+
export { BrightDbCollection } from './lib/services/bright-db-collection';
|
|
40
|
+
export { BrightDbBaseService } from './lib/services/bright-db-base-service';
|
|
41
|
+
export { BrightDbModelRegistry } from './lib/bright-db-model-registry';
|
|
42
|
+
export type { BrightDbModelRegistration } from './lib/bright-db-model-registry';
|
|
43
|
+
export { BrightDbTransactionManager } from './lib/transactions/bright-db-transaction-manager';
|
|
44
|
+
export type { BrightDbTransactionOptions } from './lib/transactions/bright-db-transaction-manager';
|
|
45
|
+
export type { IBrightDbDocumentStore } from './lib/datastore/document-store';
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../brightchain-node-express-suite/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG5F,YAAY,EACV,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAClG,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAG5E,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAG1E,YAAY,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGlG,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,YAAY,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAG9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAGnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,YAAY,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAGxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kDAAkD,CAAC;AAGlG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,cAAc,gBAAgB,CAAC;AAG/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,YAAY,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAGnG,YAAY,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @brightchain/node-express-suite
|
|
4
|
+
*
|
|
5
|
+
* Generic BrightDB-backed Express infrastructure extracted from brightchain-api-lib.
|
|
6
|
+
* This library sits between @digitaldefiance/node-express-suite (upstream) and
|
|
7
|
+
* @brightchain/brightchain-api-lib (domain-specific).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BrightDbTransactionManager = exports.BrightDbModelRegistry = exports.BrightDbBaseService = exports.BrightDbCollection = exports.createTestApp = exports.BrightDbMiddlewares = exports.BrightDbConstants = exports.BrightDbAuthenticationProvider = exports.configureBrightDbApp = exports.BrightDbApplication = exports.BrightDbDatabasePlugin = exports.BrightDbEnvironment = exports.BlockStoreFactory = exports.brightchainDatabaseInit = exports.BrightChainSessionAdapter = exports.validateBody = exports.validateRecovery = exports.validatePasswordChange = exports.validateLogin = exports.validateRegistration = exports.MemoryDocumentStore = exports.CollectionHeadRegistry = exports.BlockDocumentStore = void 0;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
var block_document_store_1 = require("./lib/datastore/block-document-store");
|
|
13
|
+
Object.defineProperty(exports, "BlockDocumentStore", { enumerable: true, get: function () { return block_document_store_1.BlockDocumentStore; } });
|
|
14
|
+
Object.defineProperty(exports, "CollectionHeadRegistry", { enumerable: true, get: function () { return block_document_store_1.CollectionHeadRegistry; } });
|
|
15
|
+
tslib_1.__exportStar(require("./lib/datastore/block-document-store-factory"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./lib/datastore/document-store"), exports);
|
|
17
|
+
var memory_document_store_1 = require("./lib/datastore/memory-document-store");
|
|
18
|
+
Object.defineProperty(exports, "MemoryDocumentStore", { enumerable: true, get: function () { return memory_document_store_1.MemoryDocumentStore; } });
|
|
19
|
+
var userValidation_1 = require("./lib/validation/userValidation");
|
|
20
|
+
Object.defineProperty(exports, "validateRegistration", { enumerable: true, get: function () { return userValidation_1.validateRegistration; } });
|
|
21
|
+
Object.defineProperty(exports, "validateLogin", { enumerable: true, get: function () { return userValidation_1.validateLogin; } });
|
|
22
|
+
Object.defineProperty(exports, "validatePasswordChange", { enumerable: true, get: function () { return userValidation_1.validatePasswordChange; } });
|
|
23
|
+
Object.defineProperty(exports, "validateRecovery", { enumerable: true, get: function () { return userValidation_1.validateRecovery; } });
|
|
24
|
+
// Middleware
|
|
25
|
+
var validateBody_1 = require("./lib/middleware/validateBody");
|
|
26
|
+
Object.defineProperty(exports, "validateBody", { enumerable: true, get: function () { return validateBody_1.validateBody; } });
|
|
27
|
+
var sessionAdapter_1 = require("./lib/services/sessionAdapter");
|
|
28
|
+
Object.defineProperty(exports, "BrightChainSessionAdapter", { enumerable: true, get: function () { return sessionAdapter_1.BrightChainSessionAdapter; } });
|
|
29
|
+
var databaseInit_1 = require("./lib/databaseInit");
|
|
30
|
+
Object.defineProperty(exports, "brightchainDatabaseInit", { enumerable: true, get: function () { return databaseInit_1.brightchainDatabaseInit; } });
|
|
31
|
+
// Factories
|
|
32
|
+
var blockStoreFactory_1 = require("./lib/factories/blockStoreFactory");
|
|
33
|
+
Object.defineProperty(exports, "BlockStoreFactory", { enumerable: true, get: function () { return blockStoreFactory_1.BlockStoreFactory; } });
|
|
34
|
+
// Environment
|
|
35
|
+
var environment_1 = require("./lib/environment");
|
|
36
|
+
Object.defineProperty(exports, "BrightDbEnvironment", { enumerable: true, get: function () { return environment_1.BrightDbEnvironment; } });
|
|
37
|
+
// Plugins
|
|
38
|
+
var bright_db_database_plugin_1 = require("./lib/plugins/bright-db-database-plugin");
|
|
39
|
+
Object.defineProperty(exports, "BrightDbDatabasePlugin", { enumerable: true, get: function () { return bright_db_database_plugin_1.BrightDbDatabasePlugin; } });
|
|
40
|
+
// Application
|
|
41
|
+
var application_1 = require("./lib/application");
|
|
42
|
+
Object.defineProperty(exports, "BrightDbApplication", { enumerable: true, get: function () { return application_1.BrightDbApplication; } });
|
|
43
|
+
// Configure App Helper
|
|
44
|
+
var configure_bright_db_app_1 = require("./lib/plugins/configure-bright-db-app");
|
|
45
|
+
Object.defineProperty(exports, "configureBrightDbApp", { enumerable: true, get: function () { return configure_bright_db_app_1.configureBrightDbApp; } });
|
|
46
|
+
// Authentication Provider
|
|
47
|
+
var bright_db_authentication_provider_1 = require("./lib/services/bright-db-authentication-provider");
|
|
48
|
+
Object.defineProperty(exports, "BrightDbAuthenticationProvider", { enumerable: true, get: function () { return bright_db_authentication_provider_1.BrightDbAuthenticationProvider; } });
|
|
49
|
+
// Constants
|
|
50
|
+
var constants_1 = require("./lib/constants");
|
|
51
|
+
Object.defineProperty(exports, "BrightDbConstants", { enumerable: true, get: function () { return constants_1.BrightDbConstants; } });
|
|
52
|
+
// Middlewares
|
|
53
|
+
var middlewares_1 = require("./lib/middlewares");
|
|
54
|
+
Object.defineProperty(exports, "BrightDbMiddlewares", { enumerable: true, get: function () { return middlewares_1.BrightDbMiddlewares; } });
|
|
55
|
+
// Upstream re-exports
|
|
56
|
+
tslib_1.__exportStar(require("./lib/upstream"), exports);
|
|
57
|
+
// BrightDB re-exports
|
|
58
|
+
tslib_1.__exportStar(require("./lib/brightdb"), exports);
|
|
59
|
+
// BrightChain-lib re-exports
|
|
60
|
+
tslib_1.__exportStar(require("./lib/brightchain-lib"), exports);
|
|
61
|
+
// Test utilities
|
|
62
|
+
var create_test_app_1 = require("./lib/create-test-app");
|
|
63
|
+
Object.defineProperty(exports, "createTestApp", { enumerable: true, get: function () { return create_test_app_1.createTestApp; } });
|
|
64
|
+
// MERN→BERN Parity Classes
|
|
65
|
+
var bright_db_collection_1 = require("./lib/services/bright-db-collection");
|
|
66
|
+
Object.defineProperty(exports, "BrightDbCollection", { enumerable: true, get: function () { return bright_db_collection_1.BrightDbCollection; } });
|
|
67
|
+
var bright_db_base_service_1 = require("./lib/services/bright-db-base-service");
|
|
68
|
+
Object.defineProperty(exports, "BrightDbBaseService", { enumerable: true, get: function () { return bright_db_base_service_1.BrightDbBaseService; } });
|
|
69
|
+
var bright_db_model_registry_1 = require("./lib/bright-db-model-registry");
|
|
70
|
+
Object.defineProperty(exports, "BrightDbModelRegistry", { enumerable: true, get: function () { return bright_db_model_registry_1.BrightDbModelRegistry; } });
|
|
71
|
+
var bright_db_transaction_manager_1 = require("./lib/transactions/bright-db-transaction-manager");
|
|
72
|
+
Object.defineProperty(exports, "BrightDbTransactionManager", { enumerable: true, get: function () { return bright_db_transaction_manager_1.BrightDbTransactionManager; } });
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../brightchain-node-express-suite/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;AAsBH,6EAAkG;AAAzF,0HAAA,kBAAkB,OAAA;AAAE,8HAAA,sBAAsB,OAAA;AACnD,uFAA6D;AAC7D,yEAA+C;AAC/C,+EAA4E;AAAnE,4HAAA,mBAAmB,OAAA;AAI5B,kEAKyC;AAJvC,sHAAA,oBAAoB,OAAA;AACpB,+GAAA,aAAa,OAAA;AACb,wHAAA,sBAAsB,OAAA;AACtB,kHAAA,gBAAgB,OAAA;AAGlB,aAAa;AACb,8DAA6D;AAApD,4GAAA,YAAY,OAAA;AAIrB,gEAA0E;AAAjE,2HAAA,yBAAyB,OAAA;AAIlC,mDAA6D;AAApD,uHAAA,uBAAuB,OAAA;AAEhC,YAAY;AACZ,uEAAsE;AAA7D,sHAAA,iBAAiB,OAAA;AAE1B,cAAc;AACd,iDAAwD;AAA/C,kHAAA,mBAAmB,OAAA;AAG5B,UAAU;AACV,qFAAiF;AAAxE,mIAAA,sBAAsB,OAAA;AAG/B,cAAc;AACd,iDAAwD;AAA/C,kHAAA,mBAAmB,OAAA;AAG5B,uBAAuB;AACvB,iFAA6E;AAApE,+HAAA,oBAAoB,OAAA;AAG7B,0BAA0B;AAC1B,sGAAkG;AAAzF,mJAAA,8BAA8B,OAAA;AAEvC,YAAY;AACZ,6CAAoD;AAA3C,8GAAA,iBAAiB,OAAA;AAE1B,cAAc;AACd,iDAAwD;AAA/C,kHAAA,mBAAmB,OAAA;AAE5B,sBAAsB;AACtB,yDAA+B;AAE/B,sBAAsB;AACtB,yDAA+B;AAE/B,6BAA6B;AAC7B,gEAAsC;AAEtC,iBAAiB;AACjB,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AAGtB,2BAA2B;AAC3B,4EAAyE;AAAhE,0HAAA,kBAAkB,OAAA;AAC3B,gFAA4E;AAAnE,6HAAA,mBAAmB,OAAA;AAC5B,2EAAuE;AAA9D,iIAAA,qBAAqB,OAAA;AAE9B,kGAA8F;AAArF,2IAAA,0BAA0B,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview BrightDbApplication — generic BrightDB-backed application base class.
|
|
3
|
+
*
|
|
4
|
+
* Extends the upstream Application with:
|
|
5
|
+
* - HTTP server capture during start()
|
|
6
|
+
*
|
|
7
|
+
* Domain-specific service wiring stays in the consuming library's App subclass.
|
|
8
|
+
*
|
|
9
|
+
* @module application
|
|
10
|
+
*/
|
|
11
|
+
import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
12
|
+
import { Application as UpstreamApplication, AppRouter, type IConstants } from '@digitaldefiance/node-express-suite';
|
|
13
|
+
import type { Server } from 'http';
|
|
14
|
+
import type { BrightDbEnvironment } from './environment';
|
|
15
|
+
/**
|
|
16
|
+
* Generic BrightDB-backed application base class.
|
|
17
|
+
*
|
|
18
|
+
* Extends the upstream Application with:
|
|
19
|
+
* - HTTP server capture during start()
|
|
20
|
+
*
|
|
21
|
+
* Domain-specific service wiring stays in the consuming library's App subclass.
|
|
22
|
+
*/
|
|
23
|
+
export declare class BrightDbApplication<TID extends PlatformID, TEnvironment extends BrightDbEnvironment<TID> = BrightDbEnvironment<TID>, TConstants extends IConstants = IConstants, TAppRouter extends AppRouter<TID> = AppRouter<TID>> extends UpstreamApplication<TID, TEnvironment, TConstants, TAppRouter> {
|
|
24
|
+
/**
|
|
25
|
+
* Captured HTTP server reference.
|
|
26
|
+
* The upstream Application stores the server as a private field,
|
|
27
|
+
* so subclasses intercept expressApp.listen() to capture it here.
|
|
28
|
+
*/
|
|
29
|
+
protected _httpServer: Server | null;
|
|
30
|
+
/**
|
|
31
|
+
* Get the HTTP server instance (available after start()).
|
|
32
|
+
*/
|
|
33
|
+
get httpServer(): Server | null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/application.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,SAAS,EACT,KAAK,UAAU,EAChB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD;;;;;;;GAOG;AACH,qBAAa,mBAAmB,CAC9B,GAAG,SAAS,UAAU,EACtB,YAAY,SAAS,mBAAmB,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,EACxE,UAAU,SAAS,UAAU,GAAG,UAAU,EAC1C,UAAU,SAAS,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAClD,SAAQ,mBAAmB,CAAC,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,CAAC;IACtE;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE5C;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,GAAG,IAAI,CAErC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview BrightDbApplication — generic BrightDB-backed application base class.
|
|
4
|
+
*
|
|
5
|
+
* Extends the upstream Application with:
|
|
6
|
+
* - HTTP server capture during start()
|
|
7
|
+
*
|
|
8
|
+
* Domain-specific service wiring stays in the consuming library's App subclass.
|
|
9
|
+
*
|
|
10
|
+
* @module application
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.BrightDbApplication = void 0;
|
|
14
|
+
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
15
|
+
/**
|
|
16
|
+
* Generic BrightDB-backed application base class.
|
|
17
|
+
*
|
|
18
|
+
* Extends the upstream Application with:
|
|
19
|
+
* - HTTP server capture during start()
|
|
20
|
+
*
|
|
21
|
+
* Domain-specific service wiring stays in the consuming library's App subclass.
|
|
22
|
+
*/
|
|
23
|
+
class BrightDbApplication extends node_express_suite_1.Application {
|
|
24
|
+
/**
|
|
25
|
+
* Captured HTTP server reference.
|
|
26
|
+
* The upstream Application stores the server as a private field,
|
|
27
|
+
* so subclasses intercept expressApp.listen() to capture it here.
|
|
28
|
+
*/
|
|
29
|
+
_httpServer = null;
|
|
30
|
+
/**
|
|
31
|
+
* Get the HTTP server instance (available after start()).
|
|
32
|
+
*/
|
|
33
|
+
get httpServer() {
|
|
34
|
+
return this._httpServer;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BrightDbApplication = BrightDbApplication;
|
|
38
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/application.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAGH,4EAI6C;AAI7C;;;;;;;GAOG;AACH,MAAa,mBAKX,SAAQ,gCAA8D;IACtE;;;;OAIG;IACO,WAAW,GAAkB,IAAI,CAAC;IAE5C;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAnBD,kDAmBC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview BrightDB model registry — singleton for managing BrightDB
|
|
3
|
+
* collection registrations. Parallel to upstream's ModelRegistry.
|
|
4
|
+
*
|
|
5
|
+
* @module bright-db-model-registry
|
|
6
|
+
*/
|
|
7
|
+
import type { CollectionSchema } from '@digitaldefiance/suite-core-lib';
|
|
8
|
+
import type { BrightDbCollection } from './services/bright-db-collection';
|
|
9
|
+
/**
|
|
10
|
+
* Registration entry for a BrightDB collection.
|
|
11
|
+
*/
|
|
12
|
+
export interface BrightDbModelRegistration {
|
|
13
|
+
collectionName: string;
|
|
14
|
+
schema?: CollectionSchema;
|
|
15
|
+
collection: BrightDbCollection;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Singleton registry for BrightDB collections.
|
|
19
|
+
* Manages collection registration and retrieval across the application.
|
|
20
|
+
* Parallel to upstream's ModelRegistry for Mongoose models.
|
|
21
|
+
*/
|
|
22
|
+
export declare class BrightDbModelRegistry {
|
|
23
|
+
private static _instance;
|
|
24
|
+
private readonly _models;
|
|
25
|
+
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Gets the singleton instance of BrightDbModelRegistry.
|
|
28
|
+
*/
|
|
29
|
+
static get instance(): BrightDbModelRegistry;
|
|
30
|
+
/**
|
|
31
|
+
* Creates an isolated registry instance (useful for testing).
|
|
32
|
+
*/
|
|
33
|
+
static createIsolated(): BrightDbModelRegistry;
|
|
34
|
+
/**
|
|
35
|
+
* Registers a collection with the registry.
|
|
36
|
+
*/
|
|
37
|
+
register(registration: BrightDbModelRegistration): void;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves a collection registration by name.
|
|
40
|
+
* @throws {Error} If the collection is not registered.
|
|
41
|
+
*/
|
|
42
|
+
get(modelName: string): BrightDbModelRegistration;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a collection is registered.
|
|
45
|
+
*/
|
|
46
|
+
has(modelName: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Lists all registered collection names.
|
|
49
|
+
*/
|
|
50
|
+
list(): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Clears all registrations (useful for testing).
|
|
53
|
+
*/
|
|
54
|
+
clear(): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=bright-db-model-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bright-db-model-registry.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/bright-db-model-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC;CAChC;AAED;;;;GAIG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IAExE,OAAO;IAEP;;OAEG;IACH,MAAM,KAAK,QAAQ,IAAI,qBAAqB,CAK3C;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,IAAI,qBAAqB;IAI9C;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,yBAAyB,GAAG,IAAI;IAIvD;;;OAGG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,yBAAyB;IAUjD;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI/B;;OAEG;IACH,IAAI,IAAI,MAAM,EAAE;IAIhB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview BrightDB model registry — singleton for managing BrightDB
|
|
4
|
+
* collection registrations. Parallel to upstream's ModelRegistry.
|
|
5
|
+
*
|
|
6
|
+
* @module bright-db-model-registry
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BrightDbModelRegistry = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Singleton registry for BrightDB collections.
|
|
12
|
+
* Manages collection registration and retrieval across the application.
|
|
13
|
+
* Parallel to upstream's ModelRegistry for Mongoose models.
|
|
14
|
+
*/
|
|
15
|
+
class BrightDbModelRegistry {
|
|
16
|
+
static _instance;
|
|
17
|
+
_models = new Map();
|
|
18
|
+
constructor() { }
|
|
19
|
+
/**
|
|
20
|
+
* Gets the singleton instance of BrightDbModelRegistry.
|
|
21
|
+
*/
|
|
22
|
+
static get instance() {
|
|
23
|
+
if (!BrightDbModelRegistry._instance) {
|
|
24
|
+
BrightDbModelRegistry._instance = new BrightDbModelRegistry();
|
|
25
|
+
}
|
|
26
|
+
return BrightDbModelRegistry._instance;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an isolated registry instance (useful for testing).
|
|
30
|
+
*/
|
|
31
|
+
static createIsolated() {
|
|
32
|
+
return new BrightDbModelRegistry();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Registers a collection with the registry.
|
|
36
|
+
*/
|
|
37
|
+
register(registration) {
|
|
38
|
+
this._models.set(registration.collectionName, registration);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves a collection registration by name.
|
|
42
|
+
* @throws {Error} If the collection is not registered.
|
|
43
|
+
*/
|
|
44
|
+
get(modelName) {
|
|
45
|
+
const reg = this._models.get(modelName);
|
|
46
|
+
if (!reg) {
|
|
47
|
+
throw new Error(`Model '${modelName}' is not registered in BrightDbModelRegistry.`);
|
|
48
|
+
}
|
|
49
|
+
return reg;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if a collection is registered.
|
|
53
|
+
*/
|
|
54
|
+
has(modelName) {
|
|
55
|
+
return this._models.has(modelName);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Lists all registered collection names.
|
|
59
|
+
*/
|
|
60
|
+
list() {
|
|
61
|
+
return Array.from(this._models.keys());
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Clears all registrations (useful for testing).
|
|
65
|
+
*/
|
|
66
|
+
clear() {
|
|
67
|
+
this._models.clear();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.BrightDbModelRegistry = BrightDbModelRegistry;
|
|
71
|
+
//# sourceMappingURL=bright-db-model-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bright-db-model-registry.js","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/bright-db-model-registry.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAcH;;;;GAIG;AACH,MAAa,qBAAqB;IACxB,MAAM,CAAC,SAAS,CAAwB;IAC/B,OAAO,GAAG,IAAI,GAAG,EAAqC,CAAC;IAExE,gBAAuB,CAAC;IAExB;;OAEG;IACH,MAAM,KAAK,QAAQ;QACjB,IAAI,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC;YACrC,qBAAqB,CAAC,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAChE,CAAC;QACD,OAAO,qBAAqB,CAAC,SAAS,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,qBAAqB,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,YAAuC;QAC9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,SAAiB;QACnB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CACb,UAAU,SAAS,+CAA+C,CACnE,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,SAAiB;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AAhED,sDAgEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports from @brightchain/brightchain-lib.
|
|
3
|
+
* Only generic infrastructure symbols — NO domain-specific modules.
|
|
4
|
+
*/
|
|
5
|
+
export { BlockSize, BlockStoreType, validBlockSizes, } from '@brightchain/brightchain-lib';
|
|
6
|
+
export type { IBlockStore, IInitResult, } from '@brightchain/brightchain-lib';
|
|
7
|
+
//# sourceMappingURL=brightchain-lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brightchain-lib.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/brightchain-lib.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,SAAS,EACT,cAAc,EACd,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EACV,WAAW,EACX,WAAW,GACZ,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validBlockSizes = exports.BlockStoreType = exports.BlockSize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Re-exports from @brightchain/brightchain-lib.
|
|
6
|
+
* Only generic infrastructure symbols — NO domain-specific modules.
|
|
7
|
+
*/
|
|
8
|
+
var brightchain_lib_1 = require("@brightchain/brightchain-lib");
|
|
9
|
+
Object.defineProperty(exports, "BlockSize", { enumerable: true, get: function () { return brightchain_lib_1.BlockSize; } });
|
|
10
|
+
Object.defineProperty(exports, "BlockStoreType", { enumerable: true, get: function () { return brightchain_lib_1.BlockStoreType; } });
|
|
11
|
+
Object.defineProperty(exports, "validBlockSizes", { enumerable: true, get: function () { return brightchain_lib_1.validBlockSizes; } });
|
|
12
|
+
//# sourceMappingURL=brightchain-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brightchain-lib.js","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/brightchain-lib.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,gEAIsC;AAHpC,4GAAA,SAAS,OAAA;AACT,iHAAA,cAAc,OAAA;AACd,kHAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports from @brightchain/db.
|
|
3
|
+
* Consumers can import these through @brightchain/node-express-suite.
|
|
4
|
+
*/
|
|
5
|
+
export { BrightDb, Collection } from '@brightchain/db';
|
|
6
|
+
export type { BsonDocument } from '@brightchain/db';
|
|
7
|
+
//# sourceMappingURL=brightdb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brightdb.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/brightdb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Collection = exports.BrightDb = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Re-exports from @brightchain/db.
|
|
6
|
+
* Consumers can import these through @brightchain/node-express-suite.
|
|
7
|
+
*/
|
|
8
|
+
var db_1 = require("@brightchain/db");
|
|
9
|
+
Object.defineProperty(exports, "BrightDb", { enumerable: true, get: function () { return db_1.BrightDb; } });
|
|
10
|
+
Object.defineProperty(exports, "Collection", { enumerable: true, get: function () { return db_1.Collection; } });
|
|
11
|
+
//# sourceMappingURL=brightdb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brightdb.js","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/brightdb.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,sCAAuD;AAA9C,8FAAA,QAAQ,OAAA;AAAE,gGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic BrightDB constants using createExpressConstants with minimal defaults.
|
|
3
|
+
* Domain-specific constants (site name, tagline, etc.) are set by consuming libraries.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BrightDbConstants: import("@digitaldefiance/node-express-suite").IConstants;
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/constants.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,0DAE5B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrightDbConstants = void 0;
|
|
4
|
+
const node_express_suite_1 = require("@digitaldefiance/node-express-suite");
|
|
5
|
+
/**
|
|
6
|
+
* Generic BrightDB constants using createExpressConstants with minimal defaults.
|
|
7
|
+
* Domain-specific constants (site name, tagline, etc.) are set by consuming libraries.
|
|
8
|
+
*/
|
|
9
|
+
exports.BrightDbConstants = (0, node_express_suite_1.createExpressConstants)('localhost', 'localhost', {
|
|
10
|
+
Site: 'BrightDB',
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/constants.ts"],"names":[],"mappings":";;;AAAA,4EAA6E;AAE7E;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,2CAAsB,EAAC,WAAW,EAAE,WAAW,EAAE;IAChF,IAAI,EAAE,UAAU;CACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Test utility for creating an in-memory BrightDB plugin instance.
|
|
3
|
+
*
|
|
4
|
+
* Useful for integration tests that need a connected BrightDB instance
|
|
5
|
+
* without requiring a real block store on disk.
|
|
6
|
+
*
|
|
7
|
+
* @module create-test-app
|
|
8
|
+
*/
|
|
9
|
+
import { BrightDbDatabasePlugin } from './plugins/bright-db-database-plugin';
|
|
10
|
+
import { BrightDbEnvironment } from './environment';
|
|
11
|
+
import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
12
|
+
export interface CreateTestAppResult<TID extends PlatformID> {
|
|
13
|
+
plugin: BrightDbDatabasePlugin<TID>;
|
|
14
|
+
environment: BrightDbEnvironment<TID>;
|
|
15
|
+
teardown: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a test-friendly BrightDB plugin with in-memory configuration.
|
|
19
|
+
* Useful for integration tests that need a connected BrightDB instance.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createTestApp<TID extends PlatformID>(envOverrides?: Record<string, string>): Promise<CreateTestAppResult<TID>>;
|
|
22
|
+
//# sourceMappingURL=create-test-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-test-app.d.ts","sourceRoot":"","sources":["../../../../brightchain-node-express-suite/src/lib/create-test-app.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,WAAW,mBAAmB,CAAC,GAAG,SAAS,UAAU;IACzD,MAAM,EAAE,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACpC,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,GAAG,SAAS,UAAU,EACxD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAmCnC"}
|