@tstdl/base 0.92.166 → 0.92.168
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/api/server/middlewares/content-type.middleware.js +1 -1
- package/application/application.d.ts +12 -18
- package/application/application.js +48 -69
- package/application/index.d.ts +1 -5
- package/application/index.js +1 -5
- package/application/providers.d.ts +10 -0
- package/application/providers.js +54 -0
- package/authentication/client/authentication.service.d.ts +1 -3
- package/authentication/client/authentication.service.js +4 -5
- package/browser/browser-context-controller.d.ts +2 -4
- package/browser/browser-context-controller.js +5 -6
- package/browser/browser-controller.d.ts +2 -4
- package/browser/browser-controller.js +3 -4
- package/browser/browser.service.d.ts +1 -3
- package/browser/browser.service.js +1 -2
- package/browser/page-controller.d.ts +2 -4
- package/browser/page-controller.js +7 -8
- package/browser/utils.js +3 -3
- package/cancellation/token.d.ts +104 -41
- package/cancellation/token.js +125 -54
- package/core.d.ts +1 -13
- package/core.js +1 -46
- package/disposable/disposable.d.ts +0 -8
- package/disposable/disposable.js +1 -3
- package/disposable/index.d.ts +0 -6
- package/disposable/index.js +0 -6
- package/disposable/using.d.ts +0 -1
- package/disposable/using.js +2 -3
- package/distributed-loop/distributed-loop.js +2 -2
- package/errors/utils.js +4 -1
- package/examples/api/authentication.js +11 -5
- package/examples/api/basic-overview.js +17 -12
- package/examples/api/custom-authentication.js +13 -7
- package/examples/api/streaming.js +15 -12
- package/examples/browser/basic.js +6 -3
- package/examples/document-management/main.js +6 -3
- package/examples/http/client.js +7 -3
- package/examples/mail/basic.js +9 -7
- package/examples/pdf/basic.js +8 -6
- package/examples/template/basic.js +7 -5
- package/http/client/http-client-request.d.ts +1 -2
- package/http/client/http-client-request.js +1 -2
- package/http/server/http-server.d.ts +1 -3
- package/http/server/http-server.js +0 -1
- package/http/server/node/node-http-server.d.ts +1 -2
- package/http/server/node/node-http-server.js +1 -2
- package/import.js +1 -1
- package/injector/injector.d.ts +1 -1
- package/injector/types.d.ts +3 -4
- package/lock/lock.d.ts +40 -21
- package/lock/lock.js +74 -1
- package/lock/postgres/drizzle/0000_busy_tattoo.sql +7 -0
- package/lock/postgres/drizzle/meta/0000_snapshot.json +65 -0
- package/lock/postgres/drizzle/meta/_journal.json +13 -0
- package/lock/postgres/drizzle.config.js +11 -0
- package/lock/postgres/index.d.ts +2 -0
- package/lock/postgres/index.js +2 -0
- package/lock/postgres/lock.d.ts +14 -0
- package/lock/postgres/lock.js +127 -0
- package/lock/postgres/models/index.d.ts +2 -0
- package/lock/postgres/models/index.js +2 -0
- package/lock/postgres/models/lock.model.d.ts +7 -0
- package/{examples/orm/user.model.js → lock/postgres/models/lock.model.js} +22 -30
- package/lock/postgres/models/schemas.d.ts +3 -0
- package/lock/postgres/models/schemas.js +4 -0
- package/lock/postgres/module.d.ts +6 -0
- package/lock/postgres/module.js +26 -0
- package/lock/postgres/provider.d.ts +6 -0
- package/lock/postgres/provider.js +29 -0
- package/lock/provider.d.ts +12 -2
- package/lock/provider.js +24 -1
- package/lock/web/web-lock.d.ts +4 -3
- package/lock/web/web-lock.js +49 -42
- package/lock/web/web-lock.provider.d.ts +0 -3
- package/lock/web/web-lock.provider.js +5 -22
- package/logger/formatter.d.ts +13 -0
- package/logger/formatter.js +3 -0
- package/logger/formatters/index.d.ts +2 -0
- package/logger/formatters/index.js +2 -0
- package/logger/formatters/json.d.ts +5 -0
- package/logger/formatters/json.js +33 -0
- package/logger/formatters/pretty-print.d.ts +5 -0
- package/logger/formatters/pretty-print.js +55 -0
- package/logger/index.d.ts +5 -2
- package/logger/index.js +5 -2
- package/logger/level.d.ts +10 -8
- package/logger/level.js +9 -9
- package/logger/logger.d.ts +21 -30
- package/logger/logger.js +98 -26
- package/logger/manager.d.ts +20 -0
- package/logger/manager.js +77 -0
- package/logger/tokens.d.ts +1 -1
- package/logger/tokens.js +1 -1
- package/logger/transport.d.ts +14 -0
- package/logger/transport.js +16 -0
- package/logger/transports/console.d.ts +14 -0
- package/logger/transports/console.js +36 -0
- package/logger/transports/index.d.ts +1 -0
- package/logger/transports/index.js +1 -0
- package/mail/clients/nodemailer.mail-client.d.ts +0 -1
- package/mail/clients/nodemailer.mail-client.js +9 -7
- package/message-bus/local/local-message-bus.js +2 -2
- package/message-bus/message-bus-base.d.ts +2 -3
- package/message-bus/message-bus-base.js +5 -6
- package/message-bus/message-bus.d.ts +1 -2
- package/message-bus/message-bus.js +1 -2
- package/module/index.d.ts +0 -2
- package/module/index.js +0 -2
- package/module/module.d.ts +17 -18
- package/module/module.js +47 -12
- package/module/modules/function.module.d.ts +6 -6
- package/module/modules/function.module.js +25 -9
- package/module/modules/web-server.module.d.ts +2 -10
- package/module/modules/web-server.module.js +3 -11
- package/openid-connect/index.d.ts +0 -2
- package/openid-connect/index.js +0 -2
- package/openid-connect/oidc-state.model.d.ts +4 -5
- package/openid-connect/oidc-state.model.js +51 -1
- package/openid-connect/oidc.service-model.d.ts +1 -1
- package/openid-connect/oidc.service.d.ts +2 -6
- package/openid-connect/oidc.service.js +24 -37
- package/orm/decorators.d.ts +10 -1
- package/orm/decorators.js +8 -0
- package/orm/server/repository.d.ts +3 -1
- package/orm/server/repository.js +32 -3
- package/package.json +17 -28
- package/pdf/pdf.service.js +9 -9
- package/pool/pool.d.ts +1 -3
- package/pool/pool.js +3 -4
- package/queue/postgres/job.model.d.ts +1 -2
- package/queue/postgres/job.model.js +1 -2
- package/queue/postgres/module.js +1 -1
- package/threading/thread-pool.d.ts +1 -3
- package/threading/thread-pool.js +7 -8
- package/utils/format-error.d.ts +7 -0
- package/utils/format-error.js +59 -17
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/object/dereference.d.ts +51 -19
- package/utils/object/dereference.js +52 -43
- package/utils/timing.js +2 -2
- package/utils/try-chain.d.ts +22 -0
- package/utils/try-chain.js +46 -0
- package/database/entity-repository.d.ts +0 -50
- package/database/entity-repository.js +0 -3
- package/database/entity.d.ts +0 -7
- package/database/entity.js +0 -1
- package/database/id.d.ts +0 -1
- package/database/id.js +0 -9
- package/database/index.d.ts +0 -11
- package/database/index.js +0 -11
- package/database/module.d.ts +0 -8
- package/database/module.js +0 -11
- package/database/mongo/classes.d.ts +0 -21
- package/database/mongo/classes.js +0 -26
- package/database/mongo/index.d.ts +0 -15
- package/database/mongo/index.js +0 -15
- package/database/mongo/model/document.d.ts +0 -29
- package/database/mongo/model/document.js +0 -63
- package/database/mongo/model/index.d.ts +0 -1
- package/database/mongo/model/index.js +0 -1
- package/database/mongo/module.d.ts +0 -8
- package/database/mongo/module.js +0 -68
- package/database/mongo/mongo-base.repository.d.ts +0 -103
- package/database/mongo/mongo-base.repository.js +0 -263
- package/database/mongo/mongo-bulk.d.ts +0 -35
- package/database/mongo/mongo-bulk.js +0 -90
- package/database/mongo/mongo-entity-repository.d.ts +0 -98
- package/database/mongo/mongo-entity-repository.js +0 -278
- package/database/mongo/operations.d.ts +0 -10
- package/database/mongo/operations.js +0 -54
- package/database/mongo/query-converter.d.ts +0 -6
- package/database/mongo/query-converter.js +0 -83
- package/database/mongo/simple-entity-repository.d.ts +0 -7
- package/database/mongo/simple-entity-repository.js +0 -6
- package/database/mongo/types.d.ts +0 -50
- package/database/mongo/types.js +0 -3
- package/database/query.d.ts +0 -121
- package/database/query.js +0 -7
- package/database/utils.d.ts +0 -2
- package/database/utils.js +0 -3
- package/disposable/async-disposer.d.ts +0 -35
- package/disposable/async-disposer.js +0 -125
- package/examples/orm/drizzle.config.js +0 -6
- package/examples/orm/schemas.d.ts +0 -3
- package/examples/orm/schemas.js +0 -4
- package/examples/orm/test.d.ts +0 -1
- package/examples/orm/test.js +0 -11
- package/examples/orm/user.model.d.ts +0 -13
- package/key-value-store/mongo/index.d.ts +0 -6
- package/key-value-store/mongo/index.js +0 -6
- package/key-value-store/mongo/module.d.ts +0 -8
- package/key-value-store/mongo/module.js +0 -18
- package/key-value-store/mongo/mongo-key-value-store.provider.d.ts +0 -8
- package/key-value-store/mongo/mongo-key-value-store.provider.js +0 -26
- package/key-value-store/mongo/mongo-key-value.model.d.ts +0 -7
- package/key-value-store/mongo/mongo-key-value.model.js +0 -1
- package/key-value-store/mongo/mongo-key-value.repository.d.ts +0 -10
- package/key-value-store/mongo/mongo-key-value.repository.js +0 -31
- package/key-value-store/mongo/mongo-key-value.store.d.ts +0 -15
- package/key-value-store/mongo/mongo-key-value.store.js +0 -82
- package/key-value-store/mongo/tokens.d.ts +0 -3
- package/key-value-store/mongo/tokens.js +0 -2
- package/lock/mongo/index.d.ts +0 -5
- package/lock/mongo/index.js +0 -5
- package/lock/mongo/lock.d.ts +0 -14
- package/lock/mongo/lock.js +0 -125
- package/lock/mongo/model.d.ts +0 -6
- package/lock/mongo/model.js +0 -1
- package/lock/mongo/module.d.ts +0 -12
- package/lock/mongo/module.js +0 -20
- package/lock/mongo/mongo-lock-repository.d.ts +0 -14
- package/lock/mongo/mongo-lock-repository.js +0 -67
- package/lock/mongo/provider.d.ts +0 -8
- package/lock/mongo/provider.js +0 -36
- package/logger/console/index.d.ts +0 -1
- package/logger/console/index.js +0 -1
- package/logger/console/logger.d.ts +0 -11
- package/logger/console/logger.js +0 -64
- package/logger/noop/index.d.ts +0 -1
- package/logger/noop/index.js +0 -1
- package/logger/noop/logger.d.ts +0 -9
- package/logger/noop/logger.js +0 -21
- package/migration/index.d.ts +0 -9
- package/migration/index.js +0 -9
- package/migration/migration-state-repository.d.ts +0 -4
- package/migration/migration-state-repository.js +0 -3
- package/migration/migration-state.d.ts +0 -6
- package/migration/migration-state.js +0 -1
- package/migration/migrator.d.ts +0 -23
- package/migration/migrator.js +0 -76
- package/migration/mongo/index.d.ts +0 -2
- package/migration/mongo/index.js +0 -2
- package/migration/mongo/migration-state-repository.d.ts +0 -11
- package/migration/mongo/migration-state-repository.js +0 -32
- package/migration/mongo/module.d.ts +0 -12
- package/migration/mongo/module.js +0 -17
- package/module/module-base.d.ts +0 -18
- package/module/module-base.js +0 -40
- package/module/module-metric-reporter.d.ts +0 -29
- package/module/module-metric-reporter.js +0 -62
- package/openid-connect/mongo-oidc-state.repository.d.ts +0 -21
- package/openid-connect/mongo-oidc-state.repository.js +0 -52
- package/openid-connect/oidc-state.repository.d.ts +0 -4
- package/openid-connect/oidc-state.repository.js +0 -3
- package/process-shutdown.d.ts +0 -9
- package/process-shutdown.js +0 -65
- package/queue/mongo/index.d.ts +0 -4
- package/queue/mongo/index.js +0 -4
- package/queue/mongo/job.d.ts +0 -12
- package/queue/mongo/job.js +0 -1
- package/queue/mongo/mongo-job.repository.d.ts +0 -13
- package/queue/mongo/mongo-job.repository.js +0 -54
- package/queue/mongo/queue.d.ts +0 -38
- package/queue/mongo/queue.js +0 -266
- package/queue/mongo/queue.provider.d.ts +0 -18
- package/queue/mongo/queue.provider.js +0 -38
- package/search-index/elastic/config.d.ts +0 -8
- package/search-index/elastic/config.js +0 -26
- package/search-index/elastic/index.d.ts +0 -8
- package/search-index/elastic/index.js +0 -8
- package/search-index/elastic/keyword-rewriter.d.ts +0 -8
- package/search-index/elastic/keyword-rewriter.js +0 -18
- package/search-index/elastic/model/elastic-query.d.ts +0 -16
- package/search-index/elastic/model/elastic-query.js +0 -1
- package/search-index/elastic/model/index-mapping.d.ts +0 -26
- package/search-index/elastic/model/index-mapping.js +0 -4
- package/search-index/elastic/model/index.d.ts +0 -3
- package/search-index/elastic/model/index.js +0 -3
- package/search-index/elastic/model/sort.d.ts +0 -8
- package/search-index/elastic/model/sort.js +0 -1
- package/search-index/elastic/module.d.ts +0 -10
- package/search-index/elastic/module.js +0 -49
- package/search-index/elastic/query-builder/boolean-query-builder.d.ts +0 -11
- package/search-index/elastic/query-builder/boolean-query-builder.js +0 -52
- package/search-index/elastic/query-builder/index.d.ts +0 -1
- package/search-index/elastic/query-builder/index.js +0 -1
- package/search-index/elastic/query-converter.d.ts +0 -9
- package/search-index/elastic/query-converter.js +0 -183
- package/search-index/elastic/search-index.d.ts +0 -30
- package/search-index/elastic/search-index.js +0 -144
- package/search-index/elastic/sort-converter.d.ts +0 -4
- package/search-index/elastic/sort-converter.js +0 -14
- package/search-index/elastic/types.d.ts +0 -5
- package/search-index/elastic/types.js +0 -1
- package/search-index/error.d.ts +0 -10
- package/search-index/error.js +0 -14
- package/search-index/index.d.ts +0 -3
- package/search-index/index.js +0 -3
- package/search-index/memory/index.d.ts +0 -1
- package/search-index/memory/index.js +0 -1
- package/search-index/memory/memory-search-index.d.ts +0 -19
- package/search-index/memory/memory-search-index.js +0 -144
- package/search-index/search-index.d.ts +0 -46
- package/search-index/search-index.js +0 -31
- package/search-index/search-result.d.ts +0 -12
- package/search-index/search-result.js +0 -1
- package/theme/adapters/css-adapter.d.ts +0 -5
- package/theme/adapters/css-adapter.js +0 -29
- package/theme/adapters/index.d.ts +0 -2
- package/theme/adapters/index.js +0 -2
- package/theme/adapters/tailwind-adapter.d.ts +0 -18
- package/theme/adapters/tailwind-adapter.js +0 -32
- package/theme/index.d.ts +0 -1
- package/theme/index.js +0 -1
- package/theme/theme-service.d.ts +0 -43
- package/theme/theme-service.js +0 -128
- /package/{examples/orm → lock/postgres}/drizzle.config.d.ts +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Entity } from '../../database/index.js';
|
|
2
|
-
import type { Paths, TypedOmit } from '../../types/index.js';
|
|
3
|
-
import type * as Mongo from 'mongodb';
|
|
4
|
-
import type { MongoDocument } from './model/document.js';
|
|
5
|
-
export type MongoConnection = {
|
|
6
|
-
url: string;
|
|
7
|
-
} & Mongo.MongoClientOptions;
|
|
8
|
-
export type MongoRepositoryConfig<T extends Entity, TDb extends Entity = T> = {
|
|
9
|
-
connection?: MongoConnection;
|
|
10
|
-
database?: string;
|
|
11
|
-
collection: string;
|
|
12
|
-
types?: {
|
|
13
|
-
entity: T;
|
|
14
|
-
database: TDb;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export type Filter<T extends Entity = Entity> = Mongo.Filter<MongoDocument<T>>;
|
|
18
|
-
export type UpdateFilter<T extends Entity = Entity> = Mongo.UpdateFilter<MongoDocument<T>>;
|
|
19
|
-
export type BulkOperation<T extends Entity = Entity> = InsertOneOperation<T> | ReplaceOneOperation<T> | UpdateOneOperation<T> | UpdateManyOperation<T> | DeleteOneOperation<T> | DeleteManyOperation<T>;
|
|
20
|
-
export type InsertOneOperation<T extends Entity = Entity> = {
|
|
21
|
-
insertOne: Mongo.InsertOneModel<MongoDocument<T>>;
|
|
22
|
-
};
|
|
23
|
-
export type ReplaceOneOperation<T extends Entity = Entity> = {
|
|
24
|
-
replaceOne: Mongo.ReplaceOneModel<MongoDocument<T>>;
|
|
25
|
-
};
|
|
26
|
-
export type UpdateOneOperation<T extends Entity = Entity> = {
|
|
27
|
-
updateOne: Mongo.UpdateOneModel<MongoDocument<T>>;
|
|
28
|
-
};
|
|
29
|
-
export type UpdateManyOperation<T extends Entity = Entity> = {
|
|
30
|
-
updateMany: Mongo.UpdateManyModel<MongoDocument<T>>;
|
|
31
|
-
};
|
|
32
|
-
export type DeleteOneOperation<T extends Entity = Entity> = {
|
|
33
|
-
deleteOne: Mongo.DeleteOneModel<MongoDocument<T>>;
|
|
34
|
-
};
|
|
35
|
-
export type DeleteManyOperation<T extends Entity = Entity> = {
|
|
36
|
-
deleteMany: Mongo.DeleteManyModel<MongoDocument<T>>;
|
|
37
|
-
};
|
|
38
|
-
export type SortObject<T extends Entity = Entity> = {
|
|
39
|
-
[P in keyof MongoDocument<T>]?: 1 | -1;
|
|
40
|
-
};
|
|
41
|
-
export type SortArrayItem<T extends Entity = Entity> = [keyof MongoDocument<T> & string, 1 | -1];
|
|
42
|
-
export type SortArray<T extends Entity = Entity> = SortArrayItem<T>[];
|
|
43
|
-
export type Sort<T extends Entity = Entity> = SortArray<T> | SortObject<T>;
|
|
44
|
-
export type TypedIndexDescription<T extends Entity = Entity> = Omit<Mongo.IndexDescription, 'key' | 'partialFilterExpression'> & {
|
|
45
|
-
key: {
|
|
46
|
-
[P in Paths<T>]?: Mongo.IndexDirection;
|
|
47
|
-
};
|
|
48
|
-
partialFilterExpression?: Filter<T>;
|
|
49
|
-
};
|
|
50
|
-
export declare function getMongoRepositoryConfig<T extends Entity, TDb extends Entity = T>(config: TypedOmit<MongoRepositoryConfig<T, TDb>, 'types'>): MongoRepositoryConfig<T, TDb>;
|
package/database/mongo/types.js
DELETED
package/database/query.d.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { Flatten, Record } from '../types/index.js';
|
|
2
|
-
import type { Geometry } from '../types/geo-json.js';
|
|
3
|
-
export type QueryOptions<T = any> = {
|
|
4
|
-
sort?: Sort<T>[];
|
|
5
|
-
skip?: number;
|
|
6
|
-
limit?: number;
|
|
7
|
-
};
|
|
8
|
-
export type LogicalQuery<T = any> = LogicalAndQuery<T> | LogicalOrQuery<T> | LogicalNorQuery<T>;
|
|
9
|
-
export type LogicalQueryTypes = keyof (LogicalAndQuery & LogicalOrQuery & LogicalNorQuery);
|
|
10
|
-
export declare const allLogicalQueryTypes: LogicalQueryTypes[];
|
|
11
|
-
export type ComparisonQueryBody<T = any> = {
|
|
12
|
-
[P in keyof T]?: ComparisonQueryOrValue<T[P]>;
|
|
13
|
-
} & Record<ComparisonQueryOrValue>;
|
|
14
|
-
export type ComparisonQueryOrValue<T = any> = ComparisonQuery<T> | T | Flatten<T>;
|
|
15
|
-
export type ComparisonQuery<T = any> = Partial<ComparisonNotQuery<T> & ComparisonEqualsQuery<T> & ComparisonNotEqualsQuery<T> & ComparisonExistsQuery & ComparisonItemQuery<T> & ComparisonInQuery<T> & ComparisonNotInQuery<T> & ComparisonAllQuery<T> & ComparisonGreaterThanQuery<T> & ComparisonGreaterThanOrEqualsQuery<T> & ComparisonLessThanQuery<T> & ComparisonLessThanOrEqualsQuery<T> & ComparisonRegexQuery & ComparisonTextQuery & ComparisonGeoShapeQuery & ComparisonGeoDistanceQuery>;
|
|
16
|
-
export type ComparisonQueryTypes = keyof ComparisonQuery;
|
|
17
|
-
export declare const allComparisonQueryTypes: ComparisonQueryTypes[];
|
|
18
|
-
export type SpecialQuery<T = any> = Partial<TextSpanQuery<T>>;
|
|
19
|
-
export type SpecialQueryTypes = keyof SpecialQuery;
|
|
20
|
-
export declare const allSpecialQueryTypes: SpecialQueryTypes[];
|
|
21
|
-
export type Query<T = any> = LogicalQuery<T> | (ComparisonQueryBody<T> & SpecialQuery<T>);
|
|
22
|
-
export type QueryTypes = LogicalQueryTypes | ComparisonQueryTypes | SpecialQueryTypes;
|
|
23
|
-
export declare const allQueryTypes: ("$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$all" | "$gt" | "$gte" | "$lt" | "$lte" | "$regex" | "$text" | "$geoShape" | "$geoDistance" | "$textSpan")[];
|
|
24
|
-
export type Order = 'asc' | 'desc';
|
|
25
|
-
export declare const allOrders: Order[];
|
|
26
|
-
export type Operator = 'and' | 'or';
|
|
27
|
-
export declare const allOperators: Operator[];
|
|
28
|
-
export type Sort<T = any> = {
|
|
29
|
-
field: Extract<keyof T, string> | '$score';
|
|
30
|
-
order?: Order;
|
|
31
|
-
};
|
|
32
|
-
export type LogicalAndQuery<T = any> = {
|
|
33
|
-
$and: Query<T>[];
|
|
34
|
-
};
|
|
35
|
-
export type LogicalOrQuery<T = any> = {
|
|
36
|
-
$or: Query<T>[];
|
|
37
|
-
};
|
|
38
|
-
export type LogicalNorQuery<T = any> = {
|
|
39
|
-
$nor: Query<T>[];
|
|
40
|
-
};
|
|
41
|
-
export type ComparisonValue<T> = T | Flatten<T>;
|
|
42
|
-
export type ComparisonValueWithRegex<T> = T extends string ? ComparisonValue<T | RegExp> : T extends string[] ? ComparisonValue<(Flatten<T> | RegExp)[]> : (T | Flatten<T>);
|
|
43
|
-
export type ComparisonNotQuery<T = any> = {
|
|
44
|
-
$not: ComparisonQuery<T>;
|
|
45
|
-
};
|
|
46
|
-
export type ComparisonEqualsQuery<T = any> = {
|
|
47
|
-
$eq: ComparisonValueWithRegex<T>;
|
|
48
|
-
};
|
|
49
|
-
export type ComparisonNotEqualsQuery<T = any> = {
|
|
50
|
-
$neq: ComparisonValueWithRegex<T>;
|
|
51
|
-
};
|
|
52
|
-
export type ComparisonExistsQuery = {
|
|
53
|
-
$exists: ComparisonValue<boolean>;
|
|
54
|
-
};
|
|
55
|
-
export type ComparisonItemQuery<T = any> = {
|
|
56
|
-
$item: T extends (infer U)[] ? U extends Record<any, any> ? Query<U> : ComparisonQuery<U> : never;
|
|
57
|
-
};
|
|
58
|
-
export type ComparisonInQuery<T = any> = {
|
|
59
|
-
$in: ComparisonValueWithRegex<T>[];
|
|
60
|
-
};
|
|
61
|
-
export type ComparisonNotInQuery<T = any> = {
|
|
62
|
-
$nin: ComparisonValueWithRegex<T>[];
|
|
63
|
-
};
|
|
64
|
-
export type ComparisonAllQuery<T = any> = {
|
|
65
|
-
$all: ComparisonValueWithRegex<T>[];
|
|
66
|
-
};
|
|
67
|
-
export type ComparisonGreaterThanQuery<T = any> = {
|
|
68
|
-
$gt: ComparisonValue<T>;
|
|
69
|
-
};
|
|
70
|
-
export type ComparisonGreaterThanOrEqualsQuery<T = any> = {
|
|
71
|
-
$gte: ComparisonValue<T>;
|
|
72
|
-
};
|
|
73
|
-
export type ComparisonLessThanQuery<T = any> = {
|
|
74
|
-
$lt: ComparisonValue<T>;
|
|
75
|
-
};
|
|
76
|
-
export type ComparisonLessThanOrEqualsQuery<T = any> = {
|
|
77
|
-
$lte: ComparisonValue<T>;
|
|
78
|
-
};
|
|
79
|
-
export type ComparisonRegexQuery = {
|
|
80
|
-
$regex: string | RegExp | {
|
|
81
|
-
pattern: string;
|
|
82
|
-
flags: string;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
export type ComparisonTextQuery = {
|
|
86
|
-
$text: string | {
|
|
87
|
-
text: string;
|
|
88
|
-
operator?: Operator;
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
export type GeoShapeRelation = 'intersects' | 'within' | 'disjoint' | 'contains';
|
|
92
|
-
export type ComparisonGeoShapeQuery = {
|
|
93
|
-
$geoShape: {
|
|
94
|
-
geometry: Geometry;
|
|
95
|
-
relation: GeoShapeRelation;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
export type ComparisonGeoDistanceQuery = {
|
|
99
|
-
$geoDistance: {
|
|
100
|
-
longitude: number;
|
|
101
|
-
latitude: number;
|
|
102
|
-
/**
|
|
103
|
-
* Maximum distance in meters
|
|
104
|
-
*/
|
|
105
|
-
maxDistance?: number;
|
|
106
|
-
/**
|
|
107
|
-
* Minimum distance in meters
|
|
108
|
-
*/
|
|
109
|
-
minDistance?: number;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
export type TextSpanQueryMode = 'best' | 'most' | 'cross';
|
|
113
|
-
export declare const allTextSpanQueryModes: TextSpanQueryMode[];
|
|
114
|
-
export type TextSpanQuery<T = any> = {
|
|
115
|
-
$textSpan: {
|
|
116
|
-
fields: (Extract<keyof T, string>)[];
|
|
117
|
-
text: string;
|
|
118
|
-
mode?: TextSpanQueryMode;
|
|
119
|
-
operator?: Operator;
|
|
120
|
-
};
|
|
121
|
-
};
|
package/database/query.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export const allLogicalQueryTypes = ['$and', '$or', '$nor'];
|
|
2
|
-
export const allComparisonQueryTypes = ['$all', '$not', '$eq', '$exists', '$gt', '$gte', '$in', '$item', '$lt', '$lte', '$neq', '$nin', '$regex', '$text', '$geoDistance', '$geoShape'];
|
|
3
|
-
export const allSpecialQueryTypes = ['$textSpan'];
|
|
4
|
-
export const allQueryTypes = [...allLogicalQueryTypes, ...allComparisonQueryTypes, ...allSpecialQueryTypes];
|
|
5
|
-
export const allOrders = ['asc', 'desc'];
|
|
6
|
-
export const allOperators = ['and', 'or'];
|
|
7
|
-
export const allTextSpanQueryModes = ['best', 'most', 'cross'];
|
package/database/utils.d.ts
DELETED
package/database/utils.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type CancellationSignal, CancellationToken } from '../cancellation/token.js';
|
|
2
|
-
import { type AsyncDisposable, type Disposable } from './disposable.js';
|
|
3
|
-
declare const deferrerToken: unique symbol;
|
|
4
|
-
export type AsyncDisposeTaskFunction = () => any;
|
|
5
|
-
export type AsyncDisposeHandler = AsyncDisposeTaskFunction | Disposable | AsyncDisposable;
|
|
6
|
-
export type AsyncDisposeTask = {
|
|
7
|
-
taskFunction: AsyncDisposeTaskFunction;
|
|
8
|
-
};
|
|
9
|
-
export type Deferrer = {
|
|
10
|
-
[deferrerToken]: CancellationToken;
|
|
11
|
-
yield(): void;
|
|
12
|
-
};
|
|
13
|
-
export declare class AsyncDisposer implements AsyncDisposable, AsyncDisposableStack {
|
|
14
|
-
#private;
|
|
15
|
-
get disposingSignal(): CancellationSignal;
|
|
16
|
-
get disposedSignal(): CancellationSignal;
|
|
17
|
-
get disposing(): boolean;
|
|
18
|
-
get disposed(): boolean;
|
|
19
|
-
readonly [Symbol.toStringTag] = "AsyncDisposable";
|
|
20
|
-
constructor();
|
|
21
|
-
use<T extends globalThis.AsyncDisposable | globalThis.Disposable | null | undefined>(value: T): T;
|
|
22
|
-
adopt<T>(value: T, onDisposeAsync: (value: T) => void | PromiseLike<void>): T;
|
|
23
|
-
move(): AsyncDisposableStack;
|
|
24
|
-
getDeferrer(): Deferrer;
|
|
25
|
-
defer<T>(func: () => Promise<T>): Promise<T>;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param fnOrDisposable
|
|
29
|
-
*/
|
|
30
|
-
add(fnOrDisposable: AsyncDisposeHandler): void;
|
|
31
|
-
disposeAsync(): Promise<void>;
|
|
32
|
-
dispose(): Promise<void>;
|
|
33
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { CancellationToken } from '../cancellation/token.js';
|
|
2
|
-
import { isDefined, isNullOrUndefined } from '../utils/type-guards.js';
|
|
3
|
-
import { MultiError } from '../errors/multi.error.js';
|
|
4
|
-
import { dispose, disposeAsync, isAsyncDisposable, isDisposable } from './disposable.js';
|
|
5
|
-
const deferrerToken = Symbol('DeferrerToken');
|
|
6
|
-
export class AsyncDisposer {
|
|
7
|
-
#disposingToken;
|
|
8
|
-
#disposedToken;
|
|
9
|
-
#deferrers;
|
|
10
|
-
#tasks;
|
|
11
|
-
get disposingSignal() {
|
|
12
|
-
return this.#disposingToken;
|
|
13
|
-
}
|
|
14
|
-
get disposedSignal() {
|
|
15
|
-
return this.#disposedToken;
|
|
16
|
-
}
|
|
17
|
-
get disposing() {
|
|
18
|
-
return this.#disposingToken.isSet;
|
|
19
|
-
}
|
|
20
|
-
get disposed() {
|
|
21
|
-
return this.#disposedToken.isSet;
|
|
22
|
-
}
|
|
23
|
-
[Symbol.toStringTag] = 'AsyncDisposable';
|
|
24
|
-
constructor() {
|
|
25
|
-
this.#deferrers = new Set();
|
|
26
|
-
this.#tasks = [];
|
|
27
|
-
this.#disposingToken = new CancellationToken();
|
|
28
|
-
this.#disposedToken = new CancellationToken();
|
|
29
|
-
}
|
|
30
|
-
use(value) {
|
|
31
|
-
if (isNullOrUndefined(value)) {
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
this.add(value);
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
adopt(value, onDisposeAsync) {
|
|
38
|
-
this.add(async () => onDisposeAsync(value));
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
move() {
|
|
42
|
-
const disposer = new AsyncDisposer();
|
|
43
|
-
disposer.#tasks = this.#tasks;
|
|
44
|
-
disposer.#deferrers = this.#deferrers;
|
|
45
|
-
this.#tasks = [];
|
|
46
|
-
this.#deferrers = new Set();
|
|
47
|
-
this.#disposingToken.set();
|
|
48
|
-
this.#disposedToken.set();
|
|
49
|
-
return disposer;
|
|
50
|
-
}
|
|
51
|
-
getDeferrer() {
|
|
52
|
-
const deferrer = {
|
|
53
|
-
[deferrerToken]: new CancellationToken(),
|
|
54
|
-
yield: () => {
|
|
55
|
-
deferrer[deferrerToken].set();
|
|
56
|
-
this.#deferrers.delete(deferrer);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
this.#deferrers.add(deferrer);
|
|
60
|
-
return deferrer;
|
|
61
|
-
}
|
|
62
|
-
async defer(func) {
|
|
63
|
-
const deferrer = this.getDeferrer();
|
|
64
|
-
try {
|
|
65
|
-
const result = await func();
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
deferrer.yield();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
*
|
|
74
|
-
* @param fnOrDisposable
|
|
75
|
-
*/
|
|
76
|
-
add(fnOrDisposable) {
|
|
77
|
-
const fn = isAsyncDisposable(fnOrDisposable)
|
|
78
|
-
? async () => fnOrDisposable[disposeAsync]()
|
|
79
|
-
: isDisposable(fnOrDisposable)
|
|
80
|
-
? () => fnOrDisposable[dispose]()
|
|
81
|
-
: fnOrDisposable;
|
|
82
|
-
this.#tasks.push({ taskFunction: fn });
|
|
83
|
-
}
|
|
84
|
-
async disposeAsync() {
|
|
85
|
-
await this.dispose();
|
|
86
|
-
}
|
|
87
|
-
async dispose() {
|
|
88
|
-
if (this.disposing) {
|
|
89
|
-
return this.#disposedToken.$set;
|
|
90
|
-
}
|
|
91
|
-
this.#disposingToken.set();
|
|
92
|
-
const errors = [];
|
|
93
|
-
for (const deferrer of this.#deferrers) {
|
|
94
|
-
try {
|
|
95
|
-
await deferrer[deferrerToken];
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
errors.push(error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
for (let i = this.#tasks.length - 1; i >= 0; i--) {
|
|
102
|
-
try {
|
|
103
|
-
const task = this.#tasks[i];
|
|
104
|
-
await task.taskFunction();
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
errors.push(error);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const error = (errors.length == 1)
|
|
111
|
-
? errors[0]
|
|
112
|
-
: (errors.length > 1)
|
|
113
|
-
? new MultiError(errors, 'dispose errors')
|
|
114
|
-
: undefined;
|
|
115
|
-
if (isDefined(error)) {
|
|
116
|
-
this.#disposedToken.error(error);
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
this.#disposedToken.set();
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
async [Symbol.asyncDispose]() {
|
|
123
|
-
return this.dispose();
|
|
124
|
-
}
|
|
125
|
-
}
|
package/examples/orm/schemas.js
DELETED
package/examples/orm/test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/examples/orm/test.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { eq } from 'drizzle-orm';
|
|
2
|
-
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
3
|
-
import { pgSchema, uuid } from 'drizzle-orm/pg-core';
|
|
4
|
-
import * as schema from './schemas.js';
|
|
5
|
-
const db = drizzle('', { schema });
|
|
6
|
-
const query = eq(schema.user, 1);
|
|
7
|
-
const x = pgSchema('').table('test', {
|
|
8
|
-
id: uuid().defaultRandom().primaryKey()
|
|
9
|
-
});
|
|
10
|
-
await db.insert(x).values({});
|
|
11
|
-
const user = await db.select().from(schema.user);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Entity, Integer } from '../../orm/index.js';
|
|
2
|
-
export declare enum Foo {
|
|
3
|
-
Bar = 0,
|
|
4
|
-
Baz = 1
|
|
5
|
-
}
|
|
6
|
-
export declare class User extends Entity {
|
|
7
|
-
static entityName: string;
|
|
8
|
-
name: string;
|
|
9
|
-
nickNames: string[];
|
|
10
|
-
age: Integer | null;
|
|
11
|
-
hasAge: boolean;
|
|
12
|
-
mail: string;
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { MongoRepositoryConfig } from '../../database/mongo/index.js';
|
|
2
|
-
import type { MongoKeyValue } from './mongo-key-value.model.js';
|
|
3
|
-
/**
|
|
4
|
-
* configure mongo queue module
|
|
5
|
-
* @param keyValueRepositoryConfig repository configuration for jobs
|
|
6
|
-
* @param register whether to register for {@link Queue} and {@link QueueProvider}
|
|
7
|
-
*/
|
|
8
|
-
export declare function configureMongoKeyValueStore(keyValueRepositoryConfig: MongoRepositoryConfig<MongoKeyValue>, register?: boolean): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Injector } from '../../injector/injector.js';
|
|
2
|
-
import { KeyValueStoreProvider } from '../key-value-store.provider.js';
|
|
3
|
-
import { KeyValueStore } from '../key-value.store.js';
|
|
4
|
-
import { MongoKeyValueStoreProvider } from './mongo-key-value-store.provider.js';
|
|
5
|
-
import { MongoKeyValueStore } from './mongo-key-value.store.js';
|
|
6
|
-
import { DEFAULT_KEY_VALUE_REPOSITORY_CONFIG } from './tokens.js';
|
|
7
|
-
/**
|
|
8
|
-
* configure mongo queue module
|
|
9
|
-
* @param keyValueRepositoryConfig repository configuration for jobs
|
|
10
|
-
* @param register whether to register for {@link Queue} and {@link QueueProvider}
|
|
11
|
-
*/
|
|
12
|
-
export function configureMongoKeyValueStore(keyValueRepositoryConfig, register = true) {
|
|
13
|
-
Injector.register(DEFAULT_KEY_VALUE_REPOSITORY_CONFIG, { useValue: keyValueRepositoryConfig });
|
|
14
|
-
if (register) {
|
|
15
|
-
Injector.registerSingleton(KeyValueStoreProvider, { useToken: MongoKeyValueStoreProvider });
|
|
16
|
-
Injector.registerSingleton(KeyValueStore, { useToken: MongoKeyValueStore });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { KeyValueStore, KeyValueStoreProvider } from '../../key-value-store/index.js';
|
|
2
|
-
import type { StringMap } from '../../types/index.js';
|
|
3
|
-
import { MongoKeyValueRepository } from './mongo-key-value.repository.js';
|
|
4
|
-
export declare class MongoKeyValueStoreProvider implements KeyValueStoreProvider {
|
|
5
|
-
private readonly keyValueRepository;
|
|
6
|
-
constructor(keyValueRepository: MongoKeyValueRepository);
|
|
7
|
-
get<KV extends StringMap>(module: string): KeyValueStore<KV>;
|
|
8
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { Singleton } from '../../injector/decorators.js';
|
|
11
|
-
import { MongoKeyValueRepository } from './mongo-key-value.repository.js';
|
|
12
|
-
import { MongoKeyValueStore } from './mongo-key-value.store.js';
|
|
13
|
-
let MongoKeyValueStoreProvider = class MongoKeyValueStoreProvider {
|
|
14
|
-
keyValueRepository;
|
|
15
|
-
constructor(keyValueRepository) {
|
|
16
|
-
this.keyValueRepository = keyValueRepository;
|
|
17
|
-
}
|
|
18
|
-
get(module) {
|
|
19
|
-
return new MongoKeyValueStore(this.keyValueRepository, module);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
MongoKeyValueStoreProvider = __decorate([
|
|
23
|
-
Singleton(),
|
|
24
|
-
__metadata("design:paramtypes", [MongoKeyValueRepository])
|
|
25
|
-
], MongoKeyValueStoreProvider);
|
|
26
|
-
export { MongoKeyValueStoreProvider };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CollectionArgument } from '../../database/mongo/index.js';
|
|
2
|
-
import { Collection, MongoEntityRepository } from '../../database/mongo/index.js';
|
|
3
|
-
import { resolveArgumentType } from '../../injector/index.js';
|
|
4
|
-
import type { Resolvable } from '../../injector/interfaces.js';
|
|
5
|
-
import { Logger } from '../../logger/index.js';
|
|
6
|
-
import type { MongoKeyValue } from './mongo-key-value.model.js';
|
|
7
|
-
export declare class MongoKeyValueRepository extends MongoEntityRepository<MongoKeyValue> implements Resolvable<CollectionArgument<MongoKeyValue>> {
|
|
8
|
-
readonly [resolveArgumentType]: CollectionArgument<MongoKeyValue, MongoKeyValue>;
|
|
9
|
-
constructor(collection: Collection<MongoKeyValue>, logger: Logger);
|
|
10
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
-
};
|
|
13
|
-
import { Collection, MongoEntityRepository, noopTransformer } from '../../database/mongo/index.js';
|
|
14
|
-
import { ForwardArg, ResolveArg, Singleton, resolveArgumentType } from '../../injector/index.js';
|
|
15
|
-
import { Logger } from '../../logger/index.js';
|
|
16
|
-
import { DEFAULT_KEY_VALUE_REPOSITORY_CONFIG } from './tokens.js';
|
|
17
|
-
const indexes = [
|
|
18
|
-
{ key: { module: 1, key: 1 }, unique: true }
|
|
19
|
-
];
|
|
20
|
-
let MongoKeyValueRepository = class MongoKeyValueRepository extends MongoEntityRepository {
|
|
21
|
-
constructor(collection, logger) {
|
|
22
|
-
super(collection, noopTransformer, { logger, indexes });
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
MongoKeyValueRepository = __decorate([
|
|
26
|
-
Singleton({ defaultArgumentProvider: (context) => context.resolve(DEFAULT_KEY_VALUE_REPOSITORY_CONFIG) }),
|
|
27
|
-
__param(0, ForwardArg()),
|
|
28
|
-
__param(1, ResolveArg('MongoKeyValueRepository')),
|
|
29
|
-
__metadata("design:paramtypes", [Collection, Logger])
|
|
30
|
-
], MongoKeyValueRepository);
|
|
31
|
-
export { MongoKeyValueRepository };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { KeyValueStore } from '../../key-value-store/index.js';
|
|
2
|
-
import type { StringMap } from '../../types/index.js';
|
|
3
|
-
import { MongoKeyValueRepository } from './mongo-key-value.repository.js';
|
|
4
|
-
export declare class MongoKeyValueStore<KV extends StringMap> extends KeyValueStore<KV> {
|
|
5
|
-
private readonly keyValueRepository;
|
|
6
|
-
constructor(keyValueRepository: MongoKeyValueRepository, module: string);
|
|
7
|
-
get<K extends keyof KV>(key: K): Promise<KV[K] | undefined>;
|
|
8
|
-
get<K extends keyof KV, D>(key: K, defaultValue: D): Promise<D | KV[K]>;
|
|
9
|
-
set<K extends keyof KV>(key: K, value: KV[K]): Promise<void>;
|
|
10
|
-
getOrSet<K extends keyof KV>(key: K, value: KV[K]): Promise<KV[K]>;
|
|
11
|
-
setMany(keyValues: Partial<KV>): Promise<void>;
|
|
12
|
-
delete(key: keyof KV): Promise<boolean>;
|
|
13
|
-
deleteMany(keys: (keyof KV)[]): Promise<void>;
|
|
14
|
-
clear(): Promise<void>;
|
|
15
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { getNewId } from '../../database/index.js';
|
|
11
|
-
import { Singleton } from '../../injector/index.js';
|
|
12
|
-
import { KeyValueStore } from '../../key-value-store/index.js';
|
|
13
|
-
import { currentTimestamp } from '../../utils/date-time.js';
|
|
14
|
-
import { objectEntries } from '../../utils/object/object.js';
|
|
15
|
-
import { assertString, isUndefined } from '../../utils/type-guards.js';
|
|
16
|
-
import { MongoKeyValueStoreProvider } from './mongo-key-value-store.provider.js';
|
|
17
|
-
import { MongoKeyValueRepository } from './mongo-key-value.repository.js';
|
|
18
|
-
let MongoKeyValueStore = class MongoKeyValueStore extends KeyValueStore {
|
|
19
|
-
keyValueRepository;
|
|
20
|
-
constructor(keyValueRepository, module) {
|
|
21
|
-
super(module);
|
|
22
|
-
this.keyValueRepository = keyValueRepository;
|
|
23
|
-
}
|
|
24
|
-
async get(key, defaultValue) {
|
|
25
|
-
const item = await this.keyValueRepository.baseRepository.tryLoadByFilter({ module: this.module, key: key });
|
|
26
|
-
if (isUndefined(item)) {
|
|
27
|
-
return defaultValue;
|
|
28
|
-
}
|
|
29
|
-
return item.value;
|
|
30
|
-
}
|
|
31
|
-
async set(key, value) {
|
|
32
|
-
const timestamp = currentTimestamp();
|
|
33
|
-
const update = {
|
|
34
|
-
$set: { value, updated: timestamp },
|
|
35
|
-
$setOnInsert: { _id: getNewId() },
|
|
36
|
-
};
|
|
37
|
-
await this.keyValueRepository.baseRepository.update({ module: this.module, key: key }, update, { upsert: true });
|
|
38
|
-
}
|
|
39
|
-
async getOrSet(key, value) {
|
|
40
|
-
await this.keyValueRepository.baseRepository.insertIfNotExistsByFilter({
|
|
41
|
-
module: this.module,
|
|
42
|
-
key: key,
|
|
43
|
-
value,
|
|
44
|
-
}, { id: getNewId(), module: this.module, key: key, value, updated: currentTimestamp() });
|
|
45
|
-
const result = await this.get(key);
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
async setMany(keyValues) {
|
|
49
|
-
const timestamp = currentTimestamp();
|
|
50
|
-
const bulk = this.keyValueRepository.baseRepository.bulk();
|
|
51
|
-
for (const [key, value] of objectEntries(keyValues)) {
|
|
52
|
-
const update = {
|
|
53
|
-
$set: { value, updated: timestamp },
|
|
54
|
-
$setOnInsert: { _id: getNewId() },
|
|
55
|
-
};
|
|
56
|
-
bulk.update({ module: this.module, key }, update, { upsert: true });
|
|
57
|
-
}
|
|
58
|
-
await bulk.execute();
|
|
59
|
-
}
|
|
60
|
-
async delete(key) {
|
|
61
|
-
return await this.keyValueRepository.deleteByFilter({ module: this.module, key: key });
|
|
62
|
-
}
|
|
63
|
-
async deleteMany(keys) {
|
|
64
|
-
await this.keyValueRepository.deleteManyByFilter({ module: this.module, key: { $in: keys } });
|
|
65
|
-
}
|
|
66
|
-
async clear() {
|
|
67
|
-
await this.keyValueRepository.deleteManyByFilter({ module: this.module });
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
MongoKeyValueStore = __decorate([
|
|
71
|
-
Singleton({
|
|
72
|
-
provider: {
|
|
73
|
-
useFactory: (argument, context) => {
|
|
74
|
-
const provider = context.resolve(MongoKeyValueStoreProvider);
|
|
75
|
-
assertString(argument, 'Missing or invalid argument (KV-Store module)');
|
|
76
|
-
return provider.get(argument);
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
__metadata("design:paramtypes", [MongoKeyValueRepository, String])
|
|
81
|
-
], MongoKeyValueStore);
|
|
82
|
-
export { MongoKeyValueStore };
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { MongoRepositoryConfig } from '../../database/mongo/types.js';
|
|
2
|
-
import type { MongoKeyValue } from './mongo-key-value.model.js';
|
|
3
|
-
export declare const DEFAULT_KEY_VALUE_REPOSITORY_CONFIG: import("../../injector/token.js").InjectionToken<MongoRepositoryConfig<MongoKeyValue>, never>;
|