@point-hub/papi 0.6.6 → 0.7.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/lib/index.js +57403 -58077
- package/lib/src/app.d.ts.map +1 -1
- package/lib/src/base-usecase.d.ts.map +1 -1
- package/lib/src/console/commands/make-command/index.command.d.ts.map +1 -1
- package/lib/src/console/commands/make-middleware/index.command.d.ts.map +1 -1
- package/lib/src/console/index.d.ts.map +1 -1
- package/lib/src/database/mongodb/mongo-error-handler.d.ts +51 -0
- package/lib/src/database/mongodb/mongo-error-handler.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo-error-handler.spec.d.ts +2 -0
- package/lib/src/database/mongodb/mongo-error-handler.spec.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo-query-builder.utils.d.ts +483 -0
- package/lib/src/database/mongodb/mongo-query-builder.utils.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo-query-builder.utils.spec.d.ts +2 -0
- package/lib/src/database/mongodb/mongo-query-builder.utils.spec.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo-test.service.d.ts +109 -0
- package/lib/src/database/mongodb/mongo-test.service.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo-test.service.spec.d.ts +2 -0
- package/lib/src/database/mongodb/mongo-test.service.spec.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo.service.d.ts +264 -0
- package/lib/src/database/mongodb/mongo.service.d.ts.map +1 -0
- package/lib/src/database/mongodb/mongo.service.spec.d.ts +2 -0
- package/lib/src/database/mongodb/mongo.service.spec.d.ts.map +1 -0
- package/lib/src/index.d.ts +7 -33
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/interfaces/types.d.ts +14 -60
- package/lib/src/interfaces/types.d.ts.map +1 -1
- package/lib/src/server.d.ts.map +1 -1
- package/lib/stub/middleware/configurable.middleware.d.ts +3 -0
- package/lib/stub/middleware/configurable.middleware.d.ts.map +1 -0
- package/lib/stub/middleware/configurable.spec.d.ts +2 -0
- package/lib/stub/middleware/configurable.spec.d.ts.map +1 -0
- package/lib/stub/middleware/new.middleware.d.ts +3 -0
- package/lib/stub/middleware/new.middleware.d.ts.map +1 -0
- package/lib/stub/middleware/new.spec.d.ts +2 -0
- package/lib/stub/middleware/new.spec.d.ts.map +1 -0
- package/package.json +9 -9
- package/stub/middleware/configurable.middleware.ts +7 -0
- package/stub/middleware/configurable.spec.ts +13 -0
- package/stub/middleware/new.middleware.ts +5 -0
- package/stub/middleware/new.spec.ts +13 -0
- package/lib/src/database/connection.d.ts +0 -37
- package/lib/src/database/connection.d.ts.map +0 -1
- package/lib/src/database/mongodb/connection.d.ts +0 -43
- package/lib/src/database/mongodb/connection.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-compose.d.ts +0 -23
- package/lib/src/database/mongodb/mongodb-compose.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-compose.spec.d.ts +0 -2
- package/lib/src/database/mongodb/mongodb-compose.spec.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-error-handler.d.ts +0 -10
- package/lib/src/database/mongodb/mongodb-error-handler.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-helper.d.ts +0 -79
- package/lib/src/database/mongodb/mongodb-helper.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-helper.spec.d.ts +0 -2
- package/lib/src/database/mongodb/mongodb-helper.spec.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-query-filters.d.ts +0 -101
- package/lib/src/database/mongodb/mongodb-query-filters.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-query-filters.spec.d.ts +0 -2
- package/lib/src/database/mongodb/mongodb-query-filters.spec.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-querystring.d.ts +0 -93
- package/lib/src/database/mongodb/mongodb-querystring.d.ts.map +0 -1
- package/lib/src/database/mongodb/mongodb-querystring.spec.d.ts +0 -2
- package/lib/src/database/mongodb/mongodb-querystring.spec.d.ts.map +0 -1
- package/lib/src/middleware/mongodb-error-handler.middleware.d.ts +0 -3
- package/lib/src/middleware/mongodb-error-handler.middleware.d.ts.map +0 -1
- package/lib/src/test/utils.d.ts +0 -13
- package/lib/src/test/utils.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.middleware.d.ts","sourceRoot":"","sources":["../../../stub/middleware/new.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEzD,MAAM,CAAC,OAAO,WAAW,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,QAEvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new.spec.d.ts","sourceRoot":"","sources":["../../../stub/middleware/new.spec.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@point-hub/papi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Point API Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -33,23 +33,23 @@
|
|
|
33
33
|
"url": "https://github.com/point-hub/papi.git"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@eslint/eslintrc": "^3.3.
|
|
37
|
-
"@eslint/js": "^
|
|
36
|
+
"@eslint/eslintrc": "^3.3.7",
|
|
37
|
+
"@eslint/js": "^10.0.1",
|
|
38
38
|
"@types/compression": "^1.8.1",
|
|
39
39
|
"@types/cors": "^2.8.19",
|
|
40
40
|
"@types/express": "^5.0.6",
|
|
41
|
-
"@types/node": "^
|
|
41
|
+
"@types/node": "^26.6.6",
|
|
42
42
|
"@types/shelljs": "^0.10.0",
|
|
43
43
|
"@types/validatorjs": "^3.15.5",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
45
|
-
"@typescript-eslint/parser": "^8.
|
|
46
|
-
"bun-types": "^1.4.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
|
45
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
46
|
+
"bun-types": "^1.4.4",
|
|
47
47
|
"cross-env": "^10.1.0",
|
|
48
|
-
"eslint": "^10.
|
|
48
|
+
"eslint": "^10.14.0",
|
|
49
49
|
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
50
50
|
"jiti": "^2.7.0",
|
|
51
51
|
"shx": "^0.4.0",
|
|
52
|
-
"typescript": "
|
|
52
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@point-hub/express-cli": "^0.2.2",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect, it, jest } from 'bun:test'
|
|
2
|
+
import { NextFunction, Request, Response } from 'express'
|
|
3
|
+
|
|
4
|
+
import middleware from './configurable.middleware'
|
|
5
|
+
|
|
6
|
+
it('test middleware', () => {
|
|
7
|
+
const req = {} as Request
|
|
8
|
+
const res = {} as Response
|
|
9
|
+
const next: NextFunction = jest.fn()
|
|
10
|
+
middleware()(req, res, next)
|
|
11
|
+
|
|
12
|
+
expect(next).toHaveBeenCalled()
|
|
13
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect, it, jest } from 'bun:test'
|
|
2
|
+
import { NextFunction, Request, Response } from 'express'
|
|
3
|
+
|
|
4
|
+
import middleware from './new.middleware'
|
|
5
|
+
|
|
6
|
+
it('test middleware', () => {
|
|
7
|
+
const req = {} as Request
|
|
8
|
+
const res = {} as Response
|
|
9
|
+
const next: NextFunction = jest.fn()
|
|
10
|
+
middleware(req, res, next)
|
|
11
|
+
|
|
12
|
+
expect(next).toHaveBeenCalled()
|
|
13
|
+
})
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { IAggregateOutput, ICreateManyOutput, ICreateOutput, IDatabase, IDeleteManyOutput, IDeleteOutput, IDocument, IPipeline, IQuery, IRetrieveAllOutput, IRetrieveManyOutput, IUpdateManyOutput, IUpdateOutput } from '../index';
|
|
2
|
-
export declare class DatabaseConnection implements IDatabase {
|
|
3
|
-
adapter: IDatabase;
|
|
4
|
-
session: unknown;
|
|
5
|
-
constructor(adapter: IDatabase);
|
|
6
|
-
open(): Promise<void>;
|
|
7
|
-
close(): Promise<void>;
|
|
8
|
-
database(name: string): this;
|
|
9
|
-
collection(name: string): this;
|
|
10
|
-
listCollections(): Promise<{
|
|
11
|
-
name: string;
|
|
12
|
-
}[]>;
|
|
13
|
-
startSession(): import("mongodb").ClientSession;
|
|
14
|
-
endSession(): Promise<void>;
|
|
15
|
-
startTransaction(): void;
|
|
16
|
-
commitTransaction(): Promise<void>;
|
|
17
|
-
abortTransaction(): Promise<void>;
|
|
18
|
-
createIndex(name: string, spec: unknown, options?: unknown): Promise<void>;
|
|
19
|
-
createCollection(name: string, options?: unknown): Promise<void>;
|
|
20
|
-
dropCollection(name: string, options?: unknown): Promise<void>;
|
|
21
|
-
dropDatabase(options?: unknown): Promise<void>;
|
|
22
|
-
updateSchema(name: string, schema: unknown): Promise<void>;
|
|
23
|
-
command(document: IDocument, options?: unknown): Promise<IDocument>;
|
|
24
|
-
create(document: IDocument, options?: unknown): Promise<ICreateOutput>;
|
|
25
|
-
createMany(documents: IDocument[], options?: unknown): Promise<ICreateManyOutput>;
|
|
26
|
-
retrieveAll<TData>(query: IQuery, options?: unknown): Promise<IRetrieveAllOutput<TData>>;
|
|
27
|
-
retrieveMany<TData>(query: IQuery, options?: unknown): Promise<IRetrieveManyOutput<TData>>;
|
|
28
|
-
retrieve<TOutput extends object>(_id: string, options?: unknown): Promise<TOutput | null>;
|
|
29
|
-
update(filter: string | IDocument, document: IDocument, options?: unknown): Promise<IUpdateOutput>;
|
|
30
|
-
updateOne(filter: IDocument, document: IDocument, options?: unknown): Promise<IUpdateOutput>;
|
|
31
|
-
updateMany(filter: IDocument, document: IDocument, options?: unknown): Promise<IUpdateManyOutput>;
|
|
32
|
-
delete(_id: string, options?: unknown): Promise<IDeleteOutput>;
|
|
33
|
-
deleteMany(input: string[] | Record<string, unknown>, options?: unknown): Promise<IDeleteManyOutput>;
|
|
34
|
-
deleteAll(options?: unknown): Promise<IDeleteManyOutput>;
|
|
35
|
-
aggregate<TData>(pipeline: IPipeline[], query?: IQuery, options?: unknown): Promise<IAggregateOutput<TData>>;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/database/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,SAAS,EACT,MAAM,EACN,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACd,MAAM,UAAU,CAAA;AAEjB,qBAAa,kBAAmB,YAAW,SAAS;IAE/B,OAAO,EAAE,SAAS;IADrC,OAAO,EAAE,OAAO,CAAA;gBACG,OAAO,EAAE,SAAS;IACxB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAGrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAG5B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxB,eAAe,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAGpD,YAAY;IAGN,UAAU;IAGhB,gBAAgB;IAGV,iBAAiB;IAGjB,gBAAgB;IAGhB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO;IAG1D,gBAAgB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,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAGjG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAG9D,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAGpG,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAGxD,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;CAG1H"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ClientSession, Collection, CollectionOptions, CreateIndexesOptions, Db, DbOptions, IndexSpecification } from 'mongodb';
|
|
2
|
-
import { MongoClient } from 'mongodb';
|
|
3
|
-
import { IAggregateOutput, ICreateManyOutput, ICreateOutput, IDatabase, IDeleteManyOutput, IDeleteOutput, IDocument, IPipeline, IQuery, IRetrieveAllOutput, IRetrieveManyOutput, IUpdateManyOutput, IUpdateOutput } from '../../index';
|
|
4
|
-
export declare class MongoDBConnection implements IDatabase {
|
|
5
|
-
databaseName: string;
|
|
6
|
-
client: MongoClient;
|
|
7
|
-
_database: Db | undefined;
|
|
8
|
-
_collection: Collection | undefined;
|
|
9
|
-
session: ClientSession | undefined;
|
|
10
|
-
private isConnected;
|
|
11
|
-
constructor(connectionString: string, databaseName: string);
|
|
12
|
-
open(): Promise<void>;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
database(name: string, options?: DbOptions): this;
|
|
15
|
-
collection(name: string, options?: CollectionOptions): this;
|
|
16
|
-
listCollections(): Promise<{
|
|
17
|
-
name: string;
|
|
18
|
-
}[]>;
|
|
19
|
-
createIndex(name: string, spec: IndexSpecification, options: CreateIndexesOptions): Promise<void>;
|
|
20
|
-
updateSchema(name: string, schema: unknown): Promise<void>;
|
|
21
|
-
createCollection(name: string, options: any): Promise<void>;
|
|
22
|
-
dropCollection(name: string, options: any): Promise<void>;
|
|
23
|
-
dropDatabase(options: any): Promise<void>;
|
|
24
|
-
startSession(): ClientSession;
|
|
25
|
-
endSession(): Promise<void>;
|
|
26
|
-
startTransaction(): void;
|
|
27
|
-
commitTransaction(): Promise<void>;
|
|
28
|
-
abortTransaction(): Promise<void>;
|
|
29
|
-
command(command: IDocument, options?: unknown): Promise<IDocument>;
|
|
30
|
-
create(document: IDocument, options?: unknown): Promise<ICreateOutput>;
|
|
31
|
-
createMany(documents: IDocument[], options?: unknown): Promise<ICreateManyOutput>;
|
|
32
|
-
retrieveAll<TData>(query: IQuery, options?: any): Promise<IRetrieveAllOutput<TData>>;
|
|
33
|
-
retrieveMany<TData>(query: IQuery, options?: any): Promise<IRetrieveManyOutput<TData>>;
|
|
34
|
-
retrieve<TOutput extends object>(_id: string, options?: any): Promise<TOutput | null>;
|
|
35
|
-
update(filter: string | IDocument, document: IDocument, options?: any): Promise<IUpdateOutput>;
|
|
36
|
-
updateOne(filter: IDocument, document: IDocument, options?: any): Promise<IUpdateOutput>;
|
|
37
|
-
updateMany(filter: IDocument, document: IDocument, options?: any): Promise<IUpdateManyOutput>;
|
|
38
|
-
delete(_id: string, options?: any): Promise<IDeleteOutput>;
|
|
39
|
-
deleteMany(input: string[] | Record<string, any>, options?: any): Promise<IDeleteManyOutput>;
|
|
40
|
-
deleteAll(options?: any): Promise<IDeleteManyOutput>;
|
|
41
|
-
aggregate<TData>(pipeline: IPipeline[], query?: IQuery, options?: any): Promise<IAggregateOutput<TData>>;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|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AAG,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBxF,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoB7F,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC;IAiB1D,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6B5F,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYpD,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;CA2DtH"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type Primitive = string | number | boolean | null | undefined;
|
|
2
|
-
type Data = Primitive | DataObject | DataArray;
|
|
3
|
-
interface DataObject {
|
|
4
|
-
[key: string]: Data;
|
|
5
|
-
}
|
|
6
|
-
type DataArray = Array<Data>;
|
|
7
|
-
interface MongoUpdate {
|
|
8
|
-
$set?: Record<string, unknown>;
|
|
9
|
-
$unset?: Record<string, string>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Compose MongoDB update operators ($set and $unset) based on input data.
|
|
13
|
-
* Fields with empty string or null values will be added to $unset,
|
|
14
|
-
* all other fields will be added to $set.
|
|
15
|
-
* Supports nested objects and arrays.
|
|
16
|
-
*
|
|
17
|
-
* @param data - Input object to transform
|
|
18
|
-
* @param parentKey - Internal key path prefix for recursion
|
|
19
|
-
* @returns MongoDB update object with $set and/or $unset
|
|
20
|
-
*/
|
|
21
|
-
export declare function composeUpdate(data: DataObject, parentKey?: string): MongoUpdate;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=mongodb-compose.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-compose.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-compose.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAE7D,KAAK,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAC9C,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB;AACD,KAAK,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;AAE5B,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,SAAK,GAAG,WAAW,CAgC3E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-compose.spec.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-compose.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseError, type IError } from '@point-hub/express-error-handler';
|
|
2
|
-
import { MongoServerError } from 'mongodb';
|
|
3
|
-
export declare function handleSchemaValidation(err: MongoServerError, error: IError): void;
|
|
4
|
-
export declare function handleUniqueValidation(err: MongoServerError, error: IError): void;
|
|
5
|
-
export declare class MongoErrorHandler extends BaseError {
|
|
6
|
-
constructor(err: MongoServerError);
|
|
7
|
-
get isOperational(): boolean;
|
|
8
|
-
get name(): string;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=mongodb-error-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-error-handler.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-error-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAQ,KAAK,MAAM,EAAoB,MAAM,kCAAkC,CAAA;AACjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QAS1E;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QA4B1E;AAED,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,GAAG,EAAE,gBAAgB;IAYjC,IAAI,aAAa,YAEhB;IACD,IAAa,IAAI,WAEhB;CACF"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { CreateIndexesOptions, IndexSpecification, ObjectId } from 'mongodb';
|
|
2
|
-
import { IDatabase } from '../../index';
|
|
3
|
-
type ObjectIdToString<T> = T extends ObjectId ? string : T extends (infer U)[] ? ObjectIdToString<U>[] : T extends Date ? T : T extends object ? {
|
|
4
|
-
[K in keyof T]: ObjectIdToString<T[K]>;
|
|
5
|
-
} : T;
|
|
6
|
-
/**
|
|
7
|
-
* https://www.mongodb.com/docs/drivers/node/current/fundamentals/indexes/
|
|
8
|
-
* https://www.mongodb.com/docs/manual/reference/collation/
|
|
9
|
-
* https://www.mongodb.com/docs/manual/core/index-sparse/
|
|
10
|
-
* https://www.mongodb.com/docs/manual/core/index-partial/
|
|
11
|
-
*/
|
|
12
|
-
export declare class MongoDBHelper {
|
|
13
|
-
private db;
|
|
14
|
-
constructor(db: IDatabase);
|
|
15
|
-
/**
|
|
16
|
-
* Create unique column
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* create unique attribute "name"
|
|
20
|
-
* createUnique(collection, {
|
|
21
|
-
* name: -1,
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* create unique attribute for multiple column "first_name" and "last_name"
|
|
26
|
-
* createUnique(collection, {
|
|
27
|
-
* firstName: -1,
|
|
28
|
-
* lastName: -1,
|
|
29
|
-
* })
|
|
30
|
-
*/
|
|
31
|
-
createUnique(collection: string, properties: object): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Create unique if column is exists
|
|
34
|
-
*/
|
|
35
|
-
createUniqueIfNotNull(collection: string, properties: object): Promise<void>;
|
|
36
|
-
createIndex(collection: string, spec: IndexSpecification, options?: CreateIndexesOptions): Promise<void>;
|
|
37
|
-
isExists(name: string): Promise<boolean>;
|
|
38
|
-
static stringToObjectId(ids: string[]): ObjectId[];
|
|
39
|
-
static stringToObjectId<T>(input: T): T;
|
|
40
|
-
static expandDottedObject(obj: Record<string, unknown>): Record<string, unknown>;
|
|
41
|
-
static convertToObjectId(input: unknown): unknown;
|
|
42
|
-
/**
|
|
43
|
-
* Recursively converts all ObjectId instances within a structure to strings.
|
|
44
|
-
* @param value The input data structure.
|
|
45
|
-
* @returns The data structure with ObjectId instances converted to strings.
|
|
46
|
-
*/
|
|
47
|
-
static objectIdToString<T>(value: T): ObjectIdToString<T>;
|
|
48
|
-
/**
|
|
49
|
-
* Deeply cleans an object by removing properties that are:
|
|
50
|
-
* 1. Undefined
|
|
51
|
-
* 2. Null
|
|
52
|
-
* 3. Empty objects ({})
|
|
53
|
-
* 4. Empty arrays ([])
|
|
54
|
-
* * @param rawInput The input data object.
|
|
55
|
-
* @returns The deeply filtered object, or an empty object if all content was filtered.
|
|
56
|
-
*/
|
|
57
|
-
static buildPostData(rawInput: Record<string, any>): Record<string, any>;
|
|
58
|
-
/**
|
|
59
|
-
* Builds a clean array of documents for a MongoDB insertMany operation.
|
|
60
|
-
* It iterates over the array, applying deep filtering to each document.
|
|
61
|
-
* Documents that become empty after filtering are removed from the array.
|
|
62
|
-
*/
|
|
63
|
-
static buildPostManyData(rawInput: Array<Record<string, any>>): Array<Record<string, any>>;
|
|
64
|
-
/**
|
|
65
|
-
* Builds safe MongoDB $set and $unset operations for a PATCH request.
|
|
66
|
-
* It flattens nested objects into dot notation and handles explicit null values for $unset.
|
|
67
|
-
* Undefined values are ignored.
|
|
68
|
-
*/
|
|
69
|
-
static buildPatchData: (rawInput: Record<string, any>) => {
|
|
70
|
-
$set?: Record<string, any>;
|
|
71
|
-
$unset?: Record<string, true>;
|
|
72
|
-
$push?: Record<string, any>;
|
|
73
|
-
$pull?: Record<string, any>;
|
|
74
|
-
$inc?: Record<string, number>;
|
|
75
|
-
$addToSet?: Record<string, any>;
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export {};
|
|
79
|
-
//# sourceMappingURL=mongodb-helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-helper.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GACzC,MAAM,GACN,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACrB,gBAAgB,CAAC,CAAC,CAAC,EAAE,GACrB,CAAC,SAAS,IAAI,GACd,CAAC,GACD,CAAC,SAAS,MAAM,GAChB;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC1C,CAAC,CAAC;AAsEN;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,EAAE,CAAA;gBAEE,EAAE,EAAE,SAAS;IAIzB;;;;;;;;;;;;;;;OAeG;I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AE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC,CAyEA;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-helper.spec.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-helper.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds a case-insensitive regex filter to the filters array if a value is provided.
|
|
3
|
-
*
|
|
4
|
-
* @param filters - An array of MongoDB filter objects to be modified.
|
|
5
|
-
* @param field - The field name to apply the regex on.
|
|
6
|
-
* @param value - The string value to search for (optional). If empty or only whitespace, no filter is added.
|
|
7
|
-
*/
|
|
8
|
-
export declare const addRegexFilter: (filters: Record<string, unknown>[], field: string, value?: string) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Adds an exact-match filter to the filters array if a value is provided.
|
|
11
|
-
*
|
|
12
|
-
* @param filters - An array of MongoDB filter objects to be modified.
|
|
13
|
-
* @param field - The field name to match exactly.
|
|
14
|
-
* @param value - The exact value to match (optional). If empty or only whitespace, no filter is added.
|
|
15
|
-
*/
|
|
16
|
-
export declare const addExactFilter: (filters: Record<string, unknown>[], field: string, value?: string) => void;
|
|
17
|
-
/**
|
|
18
|
-
* Parses a boolean value from a string or boolean input.
|
|
19
|
-
*
|
|
20
|
-
* - Accepts `true` / `false` booleans directly
|
|
21
|
-
* - Converts string values `"true"` and `"false"` to booleans
|
|
22
|
-
* - Returns `undefined` for any other value
|
|
23
|
-
*
|
|
24
|
-
* @param value - A boolean or a string representation of a boolean.
|
|
25
|
-
* @returns `true`, `false`, or `undefined` if the value cannot be parsed.
|
|
26
|
-
*/
|
|
27
|
-
export declare const parseBoolean: (value?: string | boolean) => boolean | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Adds a boolean exact-match filter to the filters array.
|
|
30
|
-
*
|
|
31
|
-
* The filter is only added if the value can be successfully parsed
|
|
32
|
-
* into a boolean (`true` or `false`).
|
|
33
|
-
*
|
|
34
|
-
* @param filters - An array of MongoDB filter objects to be modified.
|
|
35
|
-
* @param field - The field name to match.
|
|
36
|
-
* @param value - A boolean or string (`"true"` / `"false"`) to match.
|
|
37
|
-
*/
|
|
38
|
-
export declare const addBooleanFilter: (filters: Record<string, unknown>[], field: string, value?: string | boolean) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Adds a MongoDB date range filter (`$gte` / `$lte`) to the filters array.
|
|
41
|
-
*
|
|
42
|
-
* The filter is only added if at least one of `value_from` or `value_to`
|
|
43
|
-
* is provided and non-empty.
|
|
44
|
-
*
|
|
45
|
-
* @param filters - An array of MongoDB filter objects to be modified.
|
|
46
|
-
* @param field - The date field name to apply the range filter on.
|
|
47
|
-
* @param value_from - The start date (inclusive) as a string.
|
|
48
|
-
* @param value_to - The end date (inclusive) as a string.
|
|
49
|
-
*/
|
|
50
|
-
export declare const addDateRangeFilter: (filters: Record<string, unknown>[], field: string, value_from?: string, value_to?: string) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Adds a numeric filter to the filters array based on comparison operators or a single value.
|
|
53
|
-
*
|
|
54
|
-
* Accepts expressions like `">10<20"`, `"<=15"`, `"=5"` or `"50"` (interpreted as equality).
|
|
55
|
-
*
|
|
56
|
-
* @param filters - An array of MongoDB filter objects to be modified.
|
|
57
|
-
* @param field - The field name to apply the numeric comparison on.
|
|
58
|
-
* @param value - A string representing the numeric comparison(s).
|
|
59
|
-
*/
|
|
60
|
-
export declare const addNumberFilter: (filters: Record<string, unknown>[], field: string, value?: string) => void;
|
|
61
|
-
/**
|
|
62
|
-
* Parses a string expression into MongoDB-style numeric comparison operators.
|
|
63
|
-
*
|
|
64
|
-
* Supported formats:
|
|
65
|
-
* - `"50"` → `{ eq: 50 }`
|
|
66
|
-
* - `">10"` → `{ gt: 10 }`
|
|
67
|
-
* - `"<=15"` → `{ lte: 15 }`
|
|
68
|
-
* - `">=5<20"` → `{ gte: 5, lt: 20 }`
|
|
69
|
-
*
|
|
70
|
-
* Constraints:
|
|
71
|
-
* - Only one lower-bound (`>` or `>=`) and one upper-bound (`<` or `<=`) operator are allowed.
|
|
72
|
-
* - Throws an API error for malformed or ambiguous expressions.
|
|
73
|
-
*
|
|
74
|
-
* @param expr - A string representing numeric comparisons.
|
|
75
|
-
* @returns An object with numeric comparison constraints.
|
|
76
|
-
*
|
|
77
|
-
* @throws Will throw an API error if the input format is invalid or has duplicate bounds.
|
|
78
|
-
*/
|
|
79
|
-
export declare const parseComparisons: (expr: string) => {
|
|
80
|
-
gt?: number;
|
|
81
|
-
gte?: number;
|
|
82
|
-
lt?: number;
|
|
83
|
-
lte?: number;
|
|
84
|
-
eq?: number;
|
|
85
|
-
};
|
|
86
|
-
declare const _default: {
|
|
87
|
-
parseComparisons: (expr: string) => {
|
|
88
|
-
gt?: number;
|
|
89
|
-
gte?: number;
|
|
90
|
-
lt?: number;
|
|
91
|
-
lte?: number;
|
|
92
|
-
eq?: number;
|
|
93
|
-
};
|
|
94
|
-
addBooleanFilter: (filters: Record<string, unknown>[], field: string, value?: string | boolean) => void;
|
|
95
|
-
addNumberFilter: (filters: Record<string, unknown>[], field: string, value?: string) => void;
|
|
96
|
-
addRegexFilter: (filters: Record<string, unknown>[], field: string, value?: string) => void;
|
|
97
|
-
addDateRangeFilter: (filters: Record<string, unknown>[], field: string, value_from?: string, value_to?: string) => void;
|
|
98
|
-
addExactFilter: (filters: Record<string, unknown>[], field: string, value?: string) => void;
|
|
99
|
-
};
|
|
100
|
-
export default _default;
|
|
101
|
-
//# sourceMappingURL=mongodb-query-filters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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,MAAM,KACX;QACD,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,EAAE,CAAC,EAAE,MAAM,CAAA;KACZ;gCAtFyC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,UAAU,MAAM,GAAG,OAAO;+BAuCnE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,UAAU,MAAM;8BA7FzD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,UAAU,MAAM;kCAuEpD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,eAAe,MAAM,aAAa,MAAM;8BA1DpF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,UAAU,MAAM;;AA+KhG,wBAOC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-query-filters.spec.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-query-filters.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { SortDirection } from 'mongodb';
|
|
2
|
-
interface IFieldsObject {
|
|
3
|
-
[key: string]: number;
|
|
4
|
-
}
|
|
5
|
-
interface ISortObject {
|
|
6
|
-
[key: string]: SortDirection;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Parse query string to number
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* page("10") // => 10
|
|
13
|
-
* page(10) // => 10
|
|
14
|
-
*/
|
|
15
|
-
export declare function page(page?: string | number): number;
|
|
16
|
-
/**
|
|
17
|
-
* Parse query string to number
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* limit("10") // => 10
|
|
21
|
-
* limit(10) // => 10
|
|
22
|
-
*/
|
|
23
|
-
export declare function limit(pageSize?: string | number): number;
|
|
24
|
-
/**
|
|
25
|
-
* Skip number of data from page
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* skip(1, 10) // => 0
|
|
29
|
-
* skip(2, 10) // => 10
|
|
30
|
-
* skip(3, 10) // => 20
|
|
31
|
-
*/
|
|
32
|
-
export declare function skip(currentPage: string | number, pageSize: string | number): number;
|
|
33
|
-
export declare function filter(filter: any): any;
|
|
34
|
-
/**
|
|
35
|
-
* Convert string param to mongodb field object
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* fields("name, address") // => { name: 1, address: 1 }
|
|
39
|
-
*/
|
|
40
|
-
export declare function fields(fields?: string, excludeFields?: string[]): IFieldsObject;
|
|
41
|
-
/**
|
|
42
|
-
* Convert string to array
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* convertStringToArray("name, address") // => ["name", "address"]
|
|
46
|
-
*/
|
|
47
|
-
export declare function convertStringToArray(fields: string): string[];
|
|
48
|
-
/**
|
|
49
|
-
* Convert array to mongodb field object
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* convertFieldObject(["name", "address"]) // => { name: 1, address: 1 }
|
|
53
|
-
* convertFieldObject(["name", "address"], -1) // => { name: -1, address: -1 }
|
|
54
|
-
*/
|
|
55
|
-
export declare function convertFieldObject(array: string[], value?: number): IFieldsObject;
|
|
56
|
-
/**
|
|
57
|
-
* Converts a flat array of string fields (with optional negative prefix for descending)
|
|
58
|
-
* into a single object suitable for MongoDB-style sorting.
|
|
59
|
-
*
|
|
60
|
-
* Example:
|
|
61
|
-
* ['-firstName', 'lastName', 'created_at']
|
|
62
|
-
* becomes
|
|
63
|
-
* { firstName: -1, lastName: 1, created_at: 1 }
|
|
64
|
-
*/
|
|
65
|
-
export declare function convertSortObject(input: string[]): Record<string, 1 | -1>;
|
|
66
|
-
/**
|
|
67
|
-
* Remove excluded fields
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ex: { password: 0 }
|
|
71
|
-
*/
|
|
72
|
-
export declare function filterExludeFields(obj: IFieldsObject, excludeFields: string[]): IFieldsObject;
|
|
73
|
-
/**
|
|
74
|
-
* Convert string param to mongodb sort object
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* sort("name, -createdAt") // => { name: 1, createdAt: -1 }
|
|
78
|
-
*/
|
|
79
|
-
export declare function sort(fields: string): ISortObject;
|
|
80
|
-
declare const _default: {
|
|
81
|
-
page: typeof page;
|
|
82
|
-
limit: typeof limit;
|
|
83
|
-
skip: typeof skip;
|
|
84
|
-
sort: typeof sort;
|
|
85
|
-
fields: typeof fields;
|
|
86
|
-
filter: typeof filter;
|
|
87
|
-
filterExludeFields: typeof filterExludeFields;
|
|
88
|
-
convertStringToArray: typeof convertStringToArray;
|
|
89
|
-
convertFieldObject: typeof convertFieldObject;
|
|
90
|
-
convertSortObject: typeof convertSortObject;
|
|
91
|
-
};
|
|
92
|
-
export default _default;
|
|
93
|
-
//# sourceMappingURL=mongodb-querystring.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-querystring.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-querystring.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,UAAU,aAAa;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAED,UAAU,WAAW;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,MAAM,GAAG,MAAU,GAAG,MAAM,CAMtD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,QAAQ,GAAE,MAAM,GAAG,MAAW,GAAG,MAAM,CAM5D;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEpF;AAGD,wBAAgB,MAAM,CAAC,MAAM,EAAE,GAAG,OAEjC;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,SAAK,EAAE,aAAa,GAAE,MAAM,EAAO,GAAG,aAAa,CAI/E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,SAAI,GAAG,aAAa,CAM5E;AACD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAkBzE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,aAAa,CAK7F;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAchD;;;;;;;;;;;;;AAED,wBAWC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-querystring.spec.d.ts","sourceRoot":"","sources":["../../../../src/database/mongodb/mongodb-querystring.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-error-handler.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/mongodb-error-handler.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIhD,MAAM,CAAC,OAAO,UAAU,6BAA6B,KAC3C,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,WAMhD"}
|
package/lib/src/test/utils.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { IDatabase, IQuery } from '../index';
|
|
2
|
-
import { ISchema } from '../index';
|
|
3
|
-
export declare class DatabaseTestUtil {
|
|
4
|
-
static dbConnection: IDatabase;
|
|
5
|
-
static open(uri: string, name?: string): Promise<void>;
|
|
6
|
-
static close(): Promise<void>;
|
|
7
|
-
static createCollections(listSchema: ISchema[][]): Promise<void>;
|
|
8
|
-
static dropAllCollections(): Promise<void>;
|
|
9
|
-
static reset(): Promise<void>;
|
|
10
|
-
static retrieve<TOutput extends object>(collection: string, _id: string): Promise<TOutput | null>;
|
|
11
|
-
static retrieveMany<TData>(collection: string, query?: IQuery): Promise<import("../index").IRetrieveManyOutput<TData>>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAElC,qBAAa,gBAAgB;IAC3B,OAAc,YAAY,EAAE,SAAS,CAAA;WAExB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAa;WAKnC,KAAK;WAIL,iBAAiB,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE;WAoCzC,kBAAkB;WASlB,KAAK;WAOL,QAAQ,CAAC,OAAO,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;WAIhE,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW;CAGxE"}
|