@digitaldefiance/node-express-suite 3.12.16 → 3.13.1
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/package.json +1 -1
- package/src/application-base.d.ts +50 -47
- package/src/application-base.d.ts.map +1 -1
- package/src/application-base.js +180 -229
- package/src/application-base.js.map +1 -1
- package/src/application.d.ts +2 -1
- package/src/application.d.ts.map +1 -1
- package/src/application.js +8 -4
- package/src/application.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +3 -1
- package/src/index.js.map +1 -1
- package/src/interfaces/document-store.d.ts +38 -0
- package/src/interfaces/document-store.d.ts.map +1 -0
- package/src/interfaces/document-store.js +8 -0
- package/src/interfaces/document-store.js.map +1 -0
- package/src/interfaces/failable-result.d.ts +1 -6
- package/src/interfaces/failable-result.d.ts.map +1 -1
- package/src/interfaces/failable-result.js +0 -5
- package/src/interfaces/failable-result.js.map +1 -1
- package/src/interfaces/index.d.ts +2 -0
- package/src/interfaces/index.d.ts.map +1 -1
- package/src/interfaces/index.js +2 -0
- package/src/interfaces/index.js.map +1 -1
- package/src/interfaces/storage/client-session.d.ts +22 -0
- package/src/interfaces/storage/client-session.d.ts.map +1 -0
- package/src/interfaces/storage/client-session.js +3 -0
- package/src/interfaces/storage/client-session.js.map +1 -0
- package/src/interfaces/storage/collection.d.ts +80 -0
- package/src/interfaces/storage/collection.d.ts.map +1 -0
- package/src/interfaces/storage/collection.js +3 -0
- package/src/interfaces/storage/collection.js.map +1 -0
- package/src/interfaces/storage/database-lifecycle-hooks.d.ts +43 -0
- package/src/interfaces/storage/database-lifecycle-hooks.d.ts.map +1 -0
- package/src/interfaces/storage/database-lifecycle-hooks.js +3 -0
- package/src/interfaces/storage/database-lifecycle-hooks.js.map +1 -0
- package/src/interfaces/storage/database.d.ts +30 -0
- package/src/interfaces/storage/database.d.ts.map +1 -0
- package/src/interfaces/storage/database.js +3 -0
- package/src/interfaces/storage/database.js.map +1 -0
- package/src/interfaces/storage/document-types.d.ts +413 -0
- package/src/interfaces/storage/document-types.d.ts.map +1 -0
- package/src/interfaces/storage/document-types.js +8 -0
- package/src/interfaces/storage/document-types.js.map +1 -0
- package/src/interfaces/storage/index.d.ts +6 -0
- package/src/interfaces/storage/index.d.ts.map +1 -0
- package/src/interfaces/storage/index.js +9 -0
- package/src/interfaces/storage/index.js.map +1 -0
- package/src/services/index.d.ts +4 -0
- package/src/services/index.d.ts.map +1 -1
- package/src/services/index.js +4 -0
- package/src/services/index.js.map +1 -1
- package/src/services/mongoose-collection.d.ts +52 -0
- package/src/services/mongoose-collection.d.ts.map +1 -0
- package/src/services/mongoose-collection.js +326 -0
- package/src/services/mongoose-collection.js.map +1 -0
- package/src/services/mongoose-database.d.ts +64 -0
- package/src/services/mongoose-database.d.ts.map +1 -0
- package/src/services/mongoose-database.js +121 -0
- package/src/services/mongoose-database.js.map +1 -0
- package/src/services/mongoose-document-store.d.ts +109 -0
- package/src/services/mongoose-document-store.d.ts.map +1 -0
- package/src/services/mongoose-document-store.js +264 -0
- package/src/services/mongoose-document-store.js.map +1 -0
- package/src/services/mongoose-session-adapter.d.ts +39 -0
- package/src/services/mongoose-session-adapter.d.ts.map +1 -0
- package/src/services/mongoose-session-adapter.js +63 -0
- package/src/services/mongoose-session-adapter.js.map +1 -0
- package/src/utils/default-mongo-uri-validator.d.ts +15 -0
- package/src/utils/default-mongo-uri-validator.d.ts.map +1 -0
- package/src/utils/default-mongo-uri-validator.js +46 -0
- package/src/utils/default-mongo-uri-validator.js.map +1 -0
- package/src/utils.d.ts +21 -2
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +124 -49
- package/src/utils.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Base application class with core functionality.
|
|
3
|
-
*
|
|
3
|
+
* Delegates database operations to an IDatabase instance (or legacy IDocumentStore).
|
|
4
4
|
* @module application-base
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import type { BsonDocument, ICollection, IDatabase, IDatabaseLifecycleHooks } from './interfaces/storage';
|
|
7
|
+
import { Model } from '@digitaldefiance/mongoose-types';
|
|
8
|
+
import mongoose from '@digitaldefiance/mongoose-types';
|
|
7
9
|
import { MongoMemoryReplSet } from 'mongodb-memory-server';
|
|
8
10
|
import { ServiceContainer } from './container';
|
|
9
11
|
import { IBaseDocument } from './documents/base';
|
|
10
12
|
import { Environment } from './environment';
|
|
11
13
|
import { IApplication } from './interfaces/application';
|
|
12
14
|
import { IConstants } from './interfaces/constants';
|
|
13
|
-
import {
|
|
15
|
+
import { IDocumentStore } from './interfaces/document-store';
|
|
14
16
|
import { PluginManager } from './plugins';
|
|
15
17
|
import { SchemaMap } from './types';
|
|
16
18
|
import type { PlatformID } from '@digitaldefiance/node-ecies-lib';
|
|
17
19
|
/**
|
|
18
|
-
* Base Application class with core functionality
|
|
20
|
+
* Base Application class with core functionality.
|
|
21
|
+
* Accepts an IDatabase (preferred) or legacy IDocumentStore for backward compatibility.
|
|
22
|
+
* When an IDatabase is provided, database lifecycle is managed through the IDatabase contract.
|
|
23
|
+
* When a legacy IDocumentStore is provided, it is used directly for backward compatibility.
|
|
19
24
|
*/
|
|
20
25
|
export declare class BaseApplication<TID extends PlatformID, TModelDocs extends Record<string, IBaseDocument<any, TID>>, TInitResults, TConstants extends IConstants = IConstants> implements IApplication<TID> {
|
|
21
26
|
/**
|
|
22
27
|
* Application environment
|
|
23
28
|
*/
|
|
24
29
|
private _environment;
|
|
25
|
-
/**
|
|
26
|
-
* In-memory MongoDB instance for development
|
|
27
|
-
*/
|
|
28
|
-
private _devDatabase?;
|
|
29
30
|
/**
|
|
30
31
|
* Constants for the application
|
|
31
32
|
*/
|
|
32
33
|
private _constants;
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* The IDatabase instance for storage-agnostic database operations.
|
|
36
|
+
* Set when an IDatabase is passed to the constructor.
|
|
35
37
|
*/
|
|
36
|
-
|
|
38
|
+
protected readonly _database: IDatabase | undefined;
|
|
37
39
|
/**
|
|
38
|
-
*
|
|
40
|
+
* The injected document store handling all database operations.
|
|
41
|
+
* Set when a legacy IDocumentStore is passed to the constructor.
|
|
42
|
+
* @deprecated Prefer _database (IDatabase) for new code.
|
|
39
43
|
*/
|
|
40
|
-
|
|
44
|
+
protected readonly _documentStore: IDocumentStore<TID, TModelDocs> | undefined;
|
|
41
45
|
/**
|
|
42
|
-
*
|
|
46
|
+
* Optional lifecycle hooks for database initialization on the IDatabase path.
|
|
43
47
|
*/
|
|
44
|
-
|
|
48
|
+
protected readonly _lifecycleHooks: IDatabaseLifecycleHooks<TInitResults> | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Whether setupDevStore was invoked during start() (for teardown on stop).
|
|
51
|
+
*/
|
|
52
|
+
protected _devStoreProvisioned: boolean;
|
|
45
53
|
/**
|
|
46
54
|
* Get the application environment
|
|
47
55
|
*/
|
|
@@ -56,13 +64,9 @@ export declare class BaseApplication<TID extends PlatformID, TModelDocs extends
|
|
|
56
64
|
*/
|
|
57
65
|
static get distDir(): string;
|
|
58
66
|
/**
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
protected _db?: typeof mongoose;
|
|
62
|
-
/**
|
|
63
|
-
* Schema map for all models
|
|
67
|
+
* Schema map for all models, delegated to the document store.
|
|
68
|
+
* Only available when a legacy IDocumentStore is used.
|
|
64
69
|
*/
|
|
65
|
-
protected _schemaMap: SchemaMap<TID, TModelDocs> | undefined;
|
|
66
70
|
get schemaMap(): SchemaMap<TID, TModelDocs>;
|
|
67
71
|
/**
|
|
68
72
|
* Flag indicating whether the application is ready to handle requests
|
|
@@ -77,51 +81,50 @@ export declare class BaseApplication<TID extends PlatformID, TModelDocs extends
|
|
|
77
81
|
*/
|
|
78
82
|
readonly plugins: PluginManager<TID>;
|
|
79
83
|
/**
|
|
80
|
-
* Get the connected MongoDB database instance
|
|
84
|
+
* Get the connected MongoDB database instance.
|
|
85
|
+
* @deprecated Use database (IDatabase) or documentStore instead for storage-agnostic access.
|
|
81
86
|
*/
|
|
82
87
|
get db(): typeof mongoose;
|
|
83
88
|
/**
|
|
84
|
-
* Get
|
|
85
|
-
*/
|
|
86
|
-
get ready(): boolean;
|
|
87
|
-
constructor(environment: Environment<TID>, schemaMapFactory: (connection: mongoose.Connection) => SchemaMap<TID, TModelDocs>, databaseInitFunction: (application: BaseApplication<TID, TModelDocs, TInitResults>) => Promise<IFailableResult<TInitResults>>, initResultHashFunction: (initResults: TInitResults) => string, constants?: TConstants);
|
|
88
|
-
/**
|
|
89
|
-
* Validate MongoDB URI to prevent SSRF attacks
|
|
89
|
+
* Get the IDatabase instance, if one was provided.
|
|
90
90
|
*/
|
|
91
|
-
|
|
91
|
+
get database(): IDatabase | undefined;
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* Get the injected document store.
|
|
94
|
+
* @deprecated Prefer database (IDatabase) for new code.
|
|
94
95
|
*/
|
|
95
|
-
|
|
96
|
+
get documentStore(): IDocumentStore<TID, TModelDocs> | undefined;
|
|
96
97
|
/**
|
|
97
|
-
*
|
|
98
|
+
* Get the in-memory MongoDB instance (if any), delegated to the document store.
|
|
99
|
+
* Only available when a legacy IDocumentStore is used.
|
|
98
100
|
*/
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Set up an in-memory MongoDB instance for development
|
|
102
|
-
* @returns The MongoDB connection URI
|
|
103
|
-
*/
|
|
104
|
-
protected setupDevDatabase(): Promise<string>;
|
|
105
|
-
/**
|
|
106
|
-
* Initialize the development database with default data
|
|
107
|
-
*/
|
|
108
|
-
protected initializeDevDatabase(): Promise<TInitResults>;
|
|
101
|
+
get devDatabase(): MongoMemoryReplSet | undefined;
|
|
109
102
|
/**
|
|
110
|
-
* Get the
|
|
103
|
+
* Get whether the application is ready to handle requests
|
|
111
104
|
*/
|
|
112
|
-
get
|
|
105
|
+
get ready(): boolean;
|
|
106
|
+
constructor(environment: Environment<TID>, databaseOrStore: IDatabase | IDocumentStore<TID, TModelDocs>, constants?: TConstants, lifecycleHooks?: IDatabaseLifecycleHooks<TInitResults>);
|
|
113
107
|
/**
|
|
114
|
-
* Start the application and connect to the database
|
|
108
|
+
* Start the application and connect to the database.
|
|
109
|
+
* Delegates connection to IDatabase or legacy IDocumentStore.
|
|
115
110
|
*/
|
|
116
111
|
start(mongoUri?: string, delayReady?: boolean): Promise<void>;
|
|
117
112
|
/**
|
|
118
|
-
* Stop the application
|
|
113
|
+
* Stop the application.
|
|
114
|
+
* Delegates disconnection to IDatabase or legacy IDocumentStore.
|
|
119
115
|
*/
|
|
120
116
|
stop(): Promise<void>;
|
|
121
117
|
/**
|
|
122
|
-
* Get a
|
|
118
|
+
* Get a collection by name via the IDatabase interface.
|
|
119
|
+
* @param name Name of the collection
|
|
120
|
+
* @returns ICollection<T> for the named collection
|
|
121
|
+
* @throws if no IDatabase was provided
|
|
122
|
+
*/
|
|
123
|
+
getCollection<T extends BsonDocument>(name: string): ICollection<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Get a model by name, delegated to the legacy document store.
|
|
126
|
+
* @deprecated Use getCollection<T>(name) with IDatabase instead.
|
|
123
127
|
* @param modelName Name of the model
|
|
124
|
-
* @returns
|
|
125
128
|
*/
|
|
126
129
|
getModel<T extends IBaseDocument<any, TID>>(modelName: string): Model<T>;
|
|
127
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-base.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application-base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"application-base.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-node-express-suite/src/application-base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,uBAAuB,EACxB,MAAM,sBAAs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