@diia-inhouse/db 4.12.0 → 10.8.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/LICENCE.md +59 -59
- package/dist/cli/cleanupExpiredData.js +104 -0
- package/dist/cli/cleanupExpiredData.js.map +1 -0
- package/dist/cli/index.js +105 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/runMigration.js +73 -0
- package/dist/cli/runMigration.js.map +1 -0
- package/dist/cli/syncIndexes.js +45 -0
- package/dist/cli/syncIndexes.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/database.js +3 -0
- package/dist/interfaces/database.js.map +1 -0
- package/dist/interfaces/errors.js +5 -1
- package/dist/interfaces/errors.js.map +1 -1
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/metrics.js +20 -0
- package/dist/interfaces/metrics.js.map +1 -0
- package/dist/interfaces/models/counter.js +3 -0
- package/dist/interfaces/models/counter.js.map +1 -0
- package/dist/interfaces/models/index.js +19 -0
- package/dist/interfaces/models/index.js.map +1 -0
- package/dist/mongo.js +18 -3
- package/dist/mongo.js.map +1 -1
- package/dist/postgres.js +19 -0
- package/dist/postgres.js.map +1 -0
- package/dist/postgresUtils.js +20 -0
- package/dist/postgresUtils.js.map +1 -0
- package/dist/schemas/counter.js +14 -0
- package/dist/schemas/counter.js.map +1 -0
- package/dist/{models → schemas}/encryptedStorage.js +4 -2
- package/dist/schemas/encryptedStorage.js.map +1 -0
- package/dist/schemas/index.js +20 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/statusHistoryItem.js +12 -0
- package/dist/schemas/statusHistoryItem.js.map +1 -0
- package/dist/services/counter.js +72 -0
- package/dist/services/counter.js.map +1 -0
- package/dist/services/database.js +123 -55
- package/dist/services/database.js.map +1 -1
- package/dist/services/encryptedStorage.js +136 -15
- package/dist/services/encryptedStorage.js.map +1 -1
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/postgresDatabase.js +25 -0
- package/dist/services/postgresDatabase.js.map +1 -0
- package/dist/tables/counter.js +12 -0
- package/dist/tables/counter.js.map +1 -0
- package/dist/tables/encryptedStorage.js +14 -0
- package/dist/tables/encryptedStorage.js.map +1 -0
- package/dist/tables/index.js +19 -0
- package/dist/tables/index.js.map +1 -0
- package/dist/types/cli/cleanupExpiredData.d.ts +11 -0
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/cli/runMigration.d.ts +11 -0
- package/dist/types/cli/syncIndexes.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interfaces/database.d.ts +8 -0
- package/dist/types/interfaces/dbConfig.d.ts +8 -29
- package/dist/types/interfaces/errors.d.ts +5 -1
- package/dist/types/interfaces/index.d.ts +3 -25
- package/dist/types/interfaces/metrics.d.ts +20 -0
- package/dist/types/interfaces/migrateMongoConfig.d.ts +0 -24
- package/dist/types/interfaces/models/counter.d.ts +5 -0
- package/dist/types/interfaces/models/encryptedStorage.d.ts +1 -27
- package/dist/types/interfaces/models/index.d.ts +2 -0
- package/dist/types/postgres.d.ts +2 -0
- package/dist/types/postgresUtils.d.ts +26 -0
- package/dist/types/schemas/counter.d.ts +12 -0
- package/dist/types/schemas/encryptedStorage.d.ts +12 -0
- package/dist/types/schemas/index.d.ts +3 -0
- package/dist/types/schemas/statusHistoryItem.d.ts +3 -0
- package/dist/types/services/counter.d.ts +15 -0
- package/dist/types/services/database.d.ts +33 -33
- package/dist/types/services/encryptedStorage.d.ts +60 -34
- package/dist/types/services/index.d.ts +2 -0
- package/dist/types/services/postgresDatabase.d.ts +8 -0
- package/dist/types/tables/counter.d.ts +94 -0
- package/dist/types/tables/encryptedStorage.d.ts +111 -0
- package/dist/types/tables/index.d.ts +2 -0
- package/package.json +62 -60
- package/dist/models/encryptedStorage.js.map +0 -1
- package/dist/types/models/encryptedStorage.d.ts +0 -30
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
import { Counter } from '../interfaces/models/counter';
|
|
3
|
+
declare const counterSchema: Schema<Counter, import("mongoose").Model<Counter, any, any, any, import("mongoose").Document<unknown, any, Counter, any, {}> & Counter & {
|
|
4
|
+
_id: import("mongoose").Types.ObjectId;
|
|
5
|
+
} & {
|
|
6
|
+
__v: number;
|
|
7
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, Counter, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<Counter>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<Counter> & {
|
|
8
|
+
_id: import("mongoose").Types.ObjectId;
|
|
9
|
+
} & {
|
|
10
|
+
__v: number;
|
|
11
|
+
}>;
|
|
12
|
+
export { counterSchema };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
import { EncryptedStorage } from '../interfaces/models/encryptedStorage';
|
|
3
|
+
declare const encryptedStorageSchema: Schema<EncryptedStorage, import("mongoose").Model<EncryptedStorage, any, any, any, import("mongoose").Document<unknown, any, EncryptedStorage, any, {}> & EncryptedStorage & {
|
|
4
|
+
_id: import("mongoose").Types.ObjectId;
|
|
5
|
+
} & {
|
|
6
|
+
__v: number;
|
|
7
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, EncryptedStorage, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<EncryptedStorage>, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").FlatRecord<EncryptedStorage> & {
|
|
8
|
+
_id: import("mongoose").Types.ObjectId;
|
|
9
|
+
} & {
|
|
10
|
+
__v: number;
|
|
11
|
+
}>;
|
|
12
|
+
export { encryptedStorageSchema };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { DatabaseAdapterType, PostgresDatabase } from '../interfaces';
|
|
3
|
+
import { Counter } from '../interfaces/models/counter';
|
|
4
|
+
export declare class CounterService {
|
|
5
|
+
private readonly databaseAdapter;
|
|
6
|
+
private readonly counterModel;
|
|
7
|
+
private readonly postgresDatabase;
|
|
8
|
+
private readonly getNextValueStrategy;
|
|
9
|
+
private readonly getNextDailyValueStrategy;
|
|
10
|
+
constructor(databaseAdapter: DatabaseAdapterType, counterModel?: Model<Counter> | null, postgresDatabase?: PostgresDatabase | null);
|
|
11
|
+
getNextValue(code: string): Promise<number>;
|
|
12
|
+
getNextDailyValue(code: string): Promise<number>;
|
|
13
|
+
private getModel;
|
|
14
|
+
private getPostgresDatabase;
|
|
15
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
-
/// <reference types="mongoose/types/session" />
|
|
20
|
-
/// <reference types="mongoose/types/types" />
|
|
21
|
-
/// <reference types="mongoose/types/utility" />
|
|
22
|
-
/// <reference types="mongoose/types/validation" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { ClientSession } from 'mongoose';
|
|
1
|
+
import mongoose, { ClientSession } from 'mongoose';
|
|
2
|
+
import { Histogram, Observer } from '@diia-inhouse/diia-metrics';
|
|
26
3
|
import { EnvService } from '@diia-inhouse/env';
|
|
27
|
-
import { HealthCheckResult, Logger, OnHealthCheck, OnInit } from '@diia-inhouse/types';
|
|
28
|
-
import { AppDb, AppDbConfig, DbType, MongoDbStatus } from '../interfaces';
|
|
29
|
-
export declare class DatabaseService implements OnInit, OnHealthCheck {
|
|
4
|
+
import { HealthCheckResult, Logger, OnDestroy, OnHealthCheck, OnInit } from '@diia-inhouse/types';
|
|
5
|
+
import { AppDb, AppDbConfig, DatabaseAdapterType, DbType, MongoDbStatus, MongodbOperationsLabelsMap } from '../interfaces';
|
|
6
|
+
export declare class DatabaseService implements OnInit, OnHealthCheck, OnDestroy {
|
|
7
|
+
private readonly databaseAdapter;
|
|
30
8
|
private readonly dbConfigs;
|
|
31
9
|
private readonly envService;
|
|
32
10
|
private readonly logger;
|
|
33
|
-
private readonly dbStateCodeToName;
|
|
34
11
|
readonly defaultModelsDir = "models";
|
|
35
12
|
db: Partial<Record<DbType, AppDb>>;
|
|
36
|
-
|
|
13
|
+
dbOperationsHistogram?: Histogram<MongodbOperationsLabelsMap>;
|
|
14
|
+
dbOplogObserver?: Observer<object>;
|
|
15
|
+
observerInterval: NodeJS.Timeout | undefined;
|
|
16
|
+
private dbOplog;
|
|
17
|
+
private readonly isMonitoringEnabled;
|
|
18
|
+
private readonly dbStateCodeToName;
|
|
19
|
+
/**
|
|
20
|
+
* https://www.mongodb.com/docs/manual/core/transactions/#read-concern-write-concern-read-preference
|
|
21
|
+
*/
|
|
22
|
+
private readonly defaultTransactionOptions;
|
|
23
|
+
constructor(databaseAdapter: DatabaseAdapterType, dbConfigs: Partial<Record<DbType, AppDbConfig>>, envService: EnvService, logger: Logger);
|
|
37
24
|
onInit(): Promise<void>;
|
|
25
|
+
onDestroy(): Promise<void>;
|
|
38
26
|
onHealthCheck(): Promise<HealthCheckResult<MongoDbStatus>>;
|
|
39
27
|
createDbConnection(type: DbType, config: AppDbConfig): Promise<AppDb | undefined>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Begins a new MongoDB transaction by starting a session and transaction
|
|
30
|
+
*
|
|
31
|
+
* @param options - Optional transaction options to override the default transaction settings
|
|
32
|
+
* @returns A ClientSession with an active transaction
|
|
33
|
+
* @throws {DatabaseError} If the database connection is undefined or transaction fails to start
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* - Uses the main database connection to start the session
|
|
37
|
+
* - Applies default transaction options (readPreference: primary)
|
|
38
|
+
* - Will abort transaction and end session if any errors occur during setup
|
|
39
|
+
*/
|
|
40
|
+
beginTransaction(options?: mongoose.mongo.TransactionOptions): Promise<ClientSession>;
|
|
41
|
+
private connectMonitor;
|
|
42
|
+
private oplogObserver;
|
|
43
43
|
}
|
|
@@ -1,43 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="mongoose/types/callback" />
|
|
3
|
-
/// <reference types="mongoose/types/collection" />
|
|
4
|
-
/// <reference types="mongoose/types/connection" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor" />
|
|
6
|
-
/// <reference types="mongoose/types/document" />
|
|
7
|
-
/// <reference types="mongoose/types/error" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes" />
|
|
12
|
-
/// <reference types="mongoose/types/models" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
-
/// <reference types="mongoose/types/populate" />
|
|
16
|
-
/// <reference types="mongoose/types/query" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
-
/// <reference types="mongoose/types/session" />
|
|
20
|
-
/// <reference types="mongoose/types/types" />
|
|
21
|
-
/// <reference types="mongoose/types/utility" />
|
|
22
|
-
/// <reference types="mongoose/types/validation" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
-
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { QueryOptions, Types } from 'mongoose';
|
|
1
|
+
import { Model, QueryOptions } from 'mongoose';
|
|
26
2
|
import { AuthService } from '@diia-inhouse/crypto';
|
|
27
3
|
import { EnvService } from '@diia-inhouse/env';
|
|
28
4
|
import { Logger } from '@diia-inhouse/types';
|
|
5
|
+
import { DatabaseAdapterType, PostgresDatabase } from '../interfaces';
|
|
6
|
+
import { EncryptedStorage } from '../interfaces/models/encryptedStorage';
|
|
7
|
+
/**
|
|
8
|
+
* EncryptedStorageService provides CRUD operations for managing encrypted storage entries
|
|
9
|
+
* in both Postgres and MongoDB databases. The service abstracts database implementation details
|
|
10
|
+
* using a strategy pattern depending on the configured database adapter type.
|
|
11
|
+
*
|
|
12
|
+
* Suitable for storing and managing sensitive data in an encrypted manner with specific expiration time.
|
|
13
|
+
*
|
|
14
|
+
* This service should be wrapped in a repository.
|
|
15
|
+
*
|
|
16
|
+
* Register this service in the DI container with the following (MongoDB) configuration (AuthService is located in @diia-inhouse/crypto):
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // src/deps.ts
|
|
19
|
+
* encryptedStorage: asClass(EncryptedStorageService, { injector: () => ({ encryptedStorageModel }) }).singleton(),
|
|
20
|
+
* auth: asClass(AuthService, { injector: () => ({ authConfig: config.auth }) }).singleton()
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // src/config.ts
|
|
25
|
+
* auth: {
|
|
26
|
+
* jwk: await envService.getSecret('JWE_SECRET_DATA_JWK'),
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // src/models/encryptedStorage.ts
|
|
32
|
+
* import { EncryptedStorage, Model, encryptedStorageSchema, model, models } from '@diia-inhouse/db'
|
|
33
|
+
*
|
|
34
|
+
* export default (models.EncryptedStorage as Model<EncryptedStorage>) || model('EncryptedStorage', encryptedStorageSchema)
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Use the following command to generate a JWE secret data JWK:
|
|
38
|
+
* node -e "const crypto = require('crypto'); const { privateKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048 }); const jwk = privateKey.export({ format: 'jwk' }); jwk.use = 'enc'; console.log(JSON.stringify(jwk));"
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // .env.example
|
|
41
|
+
* JWE_SECRET_DATA_JWK={your-jwk-here}
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
29
44
|
export declare class EncryptedStorageService {
|
|
30
45
|
private readonly logger;
|
|
31
46
|
private readonly auth;
|
|
32
47
|
private readonly envService;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
private readonly databaseAdapter;
|
|
49
|
+
private readonly encryptedStorageModel;
|
|
50
|
+
private readonly postgresDatabase;
|
|
51
|
+
private readonly saveEntityStrategy;
|
|
52
|
+
private readonly updateEntityStrategy;
|
|
53
|
+
private readonly findEntityStrategy;
|
|
54
|
+
private readonly deleteManyStrategy;
|
|
55
|
+
private readonly removeEntityStrategy;
|
|
56
|
+
private readonly findExpirationStrategy;
|
|
57
|
+
constructor(logger: Logger, auth: AuthService, envService: EnvService, databaseAdapter: DatabaseAdapterType, encryptedStorageModel?: Model<EncryptedStorage> | null, postgresDatabase?: PostgresDatabase | null);
|
|
58
|
+
save<T>(data: T, expiration: number): Promise<string>;
|
|
59
|
+
get<T>(id: string, options?: QueryOptions): Promise<T>;
|
|
60
|
+
getSafe<T>(id: string, options?: QueryOptions): Promise<T | undefined>;
|
|
61
|
+
update<T>(id: string, data: T): Promise<void>;
|
|
62
|
+
remove(id: string): Promise<void>;
|
|
63
|
+
deleteMany(ids: string[]): Promise<void>;
|
|
64
|
+
setExpiration(id: string, expiration: number, options?: QueryOptions): Promise<void>;
|
|
65
|
+
getExpiration(id: string): Promise<Date>;
|
|
42
66
|
private getStorageItemById;
|
|
67
|
+
private getModel;
|
|
68
|
+
private getPostgresDatabase;
|
|
43
69
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OnInit } from '@diia-inhouse/types';
|
|
2
|
+
import { DatabaseAdapterType, PostgresDatabase } from '../interfaces';
|
|
3
|
+
export declare class PostgresDatabaseService implements OnInit {
|
|
4
|
+
private readonly databaseAdapter;
|
|
5
|
+
private readonly postgresDatabase;
|
|
6
|
+
constructor(databaseAdapter: DatabaseAdapterType, postgresDatabase: PostgresDatabase);
|
|
7
|
+
onInit(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const counter: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "counter";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "counter";
|
|
8
|
+
dataType: "date";
|
|
9
|
+
columnType: "PgTimestamp";
|
|
10
|
+
data: Date;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "updated_at";
|
|
24
|
+
tableName: "counter";
|
|
25
|
+
dataType: "date";
|
|
26
|
+
columnType: "PgTimestamp";
|
|
27
|
+
data: Date;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: true;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
code: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "code";
|
|
41
|
+
tableName: "counter";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgVarchar";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {
|
|
56
|
+
length: undefined;
|
|
57
|
+
}>;
|
|
58
|
+
value: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
+
name: "value";
|
|
60
|
+
tableName: "counter";
|
|
61
|
+
dataType: "number";
|
|
62
|
+
columnType: "PgInteger";
|
|
63
|
+
data: number;
|
|
64
|
+
driverParam: string | number;
|
|
65
|
+
notNull: true;
|
|
66
|
+
hasDefault: false;
|
|
67
|
+
isPrimaryKey: false;
|
|
68
|
+
isAutoincrement: false;
|
|
69
|
+
hasRuntimeDefault: false;
|
|
70
|
+
enumValues: undefined;
|
|
71
|
+
baseColumn: never;
|
|
72
|
+
identity: undefined;
|
|
73
|
+
generated: undefined;
|
|
74
|
+
}, {}, {}>;
|
|
75
|
+
date: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
+
name: "date";
|
|
77
|
+
tableName: "counter";
|
|
78
|
+
dataType: "date";
|
|
79
|
+
columnType: "PgTimestamp";
|
|
80
|
+
data: Date;
|
|
81
|
+
driverParam: string;
|
|
82
|
+
notNull: true;
|
|
83
|
+
hasDefault: false;
|
|
84
|
+
isPrimaryKey: false;
|
|
85
|
+
isAutoincrement: false;
|
|
86
|
+
hasRuntimeDefault: false;
|
|
87
|
+
enumValues: undefined;
|
|
88
|
+
baseColumn: never;
|
|
89
|
+
identity: undefined;
|
|
90
|
+
generated: undefined;
|
|
91
|
+
}, {}, {}>;
|
|
92
|
+
};
|
|
93
|
+
dialect: "pg";
|
|
94
|
+
}>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export declare const encryptedStorage: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "encrypted_storage";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "created_at";
|
|
7
|
+
tableName: "encrypted_storage";
|
|
8
|
+
dataType: "date";
|
|
9
|
+
columnType: "PgTimestamp";
|
|
10
|
+
data: Date;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: false;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "updated_at";
|
|
24
|
+
tableName: "encrypted_storage";
|
|
25
|
+
dataType: "date";
|
|
26
|
+
columnType: "PgTimestamp";
|
|
27
|
+
data: Date;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: true;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "id";
|
|
41
|
+
tableName: "encrypted_storage";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgUUID";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: true;
|
|
48
|
+
isPrimaryKey: true;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: undefined;
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
data: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "data";
|
|
58
|
+
tableName: "encrypted_storage";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgText";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
expiresAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "expires_at";
|
|
75
|
+
tableName: "encrypted_storage";
|
|
76
|
+
dataType: "custom";
|
|
77
|
+
columnType: "PgCustomColumn";
|
|
78
|
+
data: Date;
|
|
79
|
+
driverParam: string;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: undefined;
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {
|
|
90
|
+
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
91
|
+
}>;
|
|
92
|
+
source: import("drizzle-orm/pg-core").PgColumn<{
|
|
93
|
+
name: "source";
|
|
94
|
+
tableName: "encrypted_storage";
|
|
95
|
+
dataType: "json";
|
|
96
|
+
columnType: "PgJsonb";
|
|
97
|
+
data: unknown;
|
|
98
|
+
driverParam: unknown;
|
|
99
|
+
notNull: false;
|
|
100
|
+
hasDefault: false;
|
|
101
|
+
isPrimaryKey: false;
|
|
102
|
+
isAutoincrement: false;
|
|
103
|
+
hasRuntimeDefault: false;
|
|
104
|
+
enumValues: undefined;
|
|
105
|
+
baseColumn: never;
|
|
106
|
+
identity: undefined;
|
|
107
|
+
generated: undefined;
|
|
108
|
+
}, {}, {}>;
|
|
109
|
+
};
|
|
110
|
+
dialect: "pg";
|
|
111
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/db",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.8.0",
|
|
4
4
|
"description": "Package with database connection",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -11,89 +11,91 @@
|
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
14
|
+
"node": ">=22"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"diia-db": "dist/cli/index.js"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"require": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./postgres": {
|
|
26
|
+
"types": "./dist/types/postgres.d.ts",
|
|
27
|
+
"import": "./dist/postgres.js",
|
|
28
|
+
"require": "./dist/postgres.js"
|
|
29
|
+
}
|
|
15
30
|
},
|
|
16
31
|
"scripts": {
|
|
17
32
|
"prebuild": "rimraf dist",
|
|
18
33
|
"build": "tsc",
|
|
19
34
|
"semantic-release": "semantic-release",
|
|
20
|
-
"
|
|
21
|
-
"lint": "eslint
|
|
22
|
-
"
|
|
23
|
-
"test": "
|
|
24
|
-
"test:coverage": "jest --coverage",
|
|
25
|
-
"test:unit": "npm run test --selectProjects unit --",
|
|
26
|
-
"test:integration": "npm run test --selectProjects integration --",
|
|
35
|
+
"lint": "eslint . && prettier --check .",
|
|
36
|
+
"lint-fix": "eslint . --fix && prettier --write .",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest watch",
|
|
27
39
|
"prepare": "npm run build",
|
|
28
40
|
"find-circulars": "madge --circular --extensions ts ./",
|
|
29
41
|
"lint:lockfile": "lockfile-lint --path package-lock.json --allowed-hosts registry.npmjs.org --validate-https"
|
|
30
42
|
},
|
|
31
43
|
"dependencies": {
|
|
32
|
-
"@diia-inhouse/crypto": "1.
|
|
33
|
-
"@diia-inhouse/diia-logger": "3.
|
|
34
|
-
"@diia-inhouse/
|
|
35
|
-
"@diia-inhouse/
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
44
|
+
"@diia-inhouse/crypto": "1.20.0",
|
|
45
|
+
"@diia-inhouse/diia-logger": "3.16.0",
|
|
46
|
+
"@diia-inhouse/diia-metrics": "6.4.0",
|
|
47
|
+
"@diia-inhouse/utils": "5.3.0",
|
|
48
|
+
"@diia-inhouse/validators": "1.28.0",
|
|
49
|
+
"@types/migrate-mongo": "10.0.6",
|
|
50
|
+
"bson": "6.10.4",
|
|
51
|
+
"drizzle-orm": "0.45.1",
|
|
52
|
+
"lodash": "4.17.23",
|
|
53
|
+
"luxon": "3.7.2",
|
|
54
|
+
"migrate-mongo": "12.1.3",
|
|
55
|
+
"mongoose": "8.23.0",
|
|
56
|
+
"pg": "8.19.0",
|
|
57
|
+
"recursive-readdir": "2.2.3",
|
|
58
|
+
"ts-node": "10.9.2",
|
|
59
|
+
"yargs": "17.7.2"
|
|
42
60
|
},
|
|
43
61
|
"peerDependencies": {
|
|
44
|
-
"@diia-inhouse/env": ">=
|
|
62
|
+
"@diia-inhouse/env": ">=2.0.0",
|
|
45
63
|
"@diia-inhouse/errors": ">=1.6.1",
|
|
46
64
|
"@diia-inhouse/types": ">=6.30.0"
|
|
47
65
|
},
|
|
48
66
|
"devDependencies": {
|
|
49
|
-
"@diia-inhouse/configs": "1.
|
|
50
|
-
"@diia-inhouse/env": "
|
|
51
|
-
"@diia-inhouse/errors": "1.
|
|
52
|
-
"@diia-inhouse/eslint-config": "
|
|
53
|
-
"@diia-inhouse/eslint-plugin": "1.
|
|
54
|
-
"@diia-inhouse/test": "
|
|
55
|
-
"@diia-inhouse/types": "
|
|
56
|
-
"@types/lodash": "4.17.
|
|
57
|
-
"@types/node": "
|
|
67
|
+
"@diia-inhouse/configs": "6.1.1",
|
|
68
|
+
"@diia-inhouse/env": "2.8.1",
|
|
69
|
+
"@diia-inhouse/errors": "1.17.0",
|
|
70
|
+
"@diia-inhouse/eslint-config": "8.3.0",
|
|
71
|
+
"@diia-inhouse/eslint-plugin": "1.9.5",
|
|
72
|
+
"@diia-inhouse/test": "7.2.0",
|
|
73
|
+
"@diia-inhouse/types": "11.3.0",
|
|
74
|
+
"@types/lodash": "4.17.24",
|
|
75
|
+
"@types/node": "25.3.3",
|
|
76
|
+
"@types/pg": "8.18.0",
|
|
58
77
|
"@types/recursive-readdir": "2.2.4",
|
|
78
|
+
"@types/yargs": "17.0.35",
|
|
79
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
80
|
+
"@vitest/ui": "4.0.18",
|
|
59
81
|
"dotenv-flow": "4.1.0",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"lockfile-lint": "4.
|
|
63
|
-
"madge": "
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"preset": "@diia-inhouse/configs/dist/jest"
|
|
82
|
+
"drizzle-kit": "0.31.9",
|
|
83
|
+
"eslint": "9.39.3",
|
|
84
|
+
"lockfile-lint": "4.14.1",
|
|
85
|
+
"madge": "8.0.0",
|
|
86
|
+
"rimraf": "6.1.3",
|
|
87
|
+
"semantic-release": "24.2.9",
|
|
88
|
+
"typescript": "5.9.3",
|
|
89
|
+
"vite-tsconfig-paths": "6.1.1",
|
|
90
|
+
"vitest": "4.0.18",
|
|
91
|
+
"vitest-mock-extended": "3.1.0"
|
|
71
92
|
},
|
|
72
93
|
"release": {
|
|
73
|
-
"extends": "@diia-inhouse/configs/dist/semantic-release/package"
|
|
74
|
-
"branches": [
|
|
75
|
-
"main"
|
|
76
|
-
]
|
|
94
|
+
"extends": "@diia-inhouse/configs/dist/semantic-release/package"
|
|
77
95
|
},
|
|
78
96
|
"commitlint": {
|
|
79
97
|
"extends": "@diia-inhouse/configs/dist/commitlint"
|
|
80
98
|
},
|
|
81
|
-
"eslintConfig": {
|
|
82
|
-
"extends": "@diia-inhouse/eslint-config",
|
|
83
|
-
"overrides": [
|
|
84
|
-
{
|
|
85
|
-
"files": [
|
|
86
|
-
"*.ts"
|
|
87
|
-
],
|
|
88
|
-
"parserOptions": {
|
|
89
|
-
"project": [
|
|
90
|
-
"./tsconfig.json",
|
|
91
|
-
"./tests/tsconfig.json"
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
99
|
"prettier": "@diia-inhouse/eslint-config/prettier",
|
|
98
100
|
"madge": {
|
|
99
101
|
"tsConfig": "./tsconfig.json"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encryptedStorage.js","sourceRoot":"","sources":["../../src/models/encryptedStorage.ts"],"names":[],"mappings":";;AAAA,uCAAuD;AAMvD,MAAM,sBAAsB,GAAG,IAAI,iBAAM,CACrC;IACI,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IACzC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;CACvB,EACD;IACI,UAAU,EAAE,IAAI;CACnB,CACJ,CAAA;AAED,sBAAsB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,kBAAkB,2BAAe,EAAE,CAAC,CAAA;AAErF,kBAAwC,iBAAM,CAAC,gBAAgB,IAAI,IAAA,gBAAK,EAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAA"}
|