@diia-inhouse/db 12.3.23 → 12.4.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/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { EncryptedStorage } from "./interfaces/models/encryptedStorage.js";
|
|
|
11
11
|
import { models, mongoose } from "./interfaces/index.js";
|
|
12
12
|
import { DatabaseService } from "./services/database.js";
|
|
13
13
|
import { PostgresDatabaseService } from "./services/postgresDatabase.js";
|
|
14
|
-
import { EncryptedStorageService } from "./services/encryptedStorage.js";
|
|
14
|
+
import { EncryptedStorageService, JweEncrypter, buildEncryptedStorageEntry } from "./services/encryptedStorage.js";
|
|
15
15
|
import { CounterService } from "./services/counter.js";
|
|
16
16
|
import { MongoHelper } from "./mongo.js";
|
|
17
17
|
import { counterSchema } from "./schemas/counter.js";
|
|
@@ -22,7 +22,7 @@ export * from "mongoose";
|
|
|
22
22
|
|
|
23
23
|
//#region src/index.d.ts
|
|
24
24
|
declare namespace index_d_exports {
|
|
25
|
-
export { AppDb, AppDbConfig, Counter, CounterService, DatabaseAdapter, DatabaseAdapterType, DatabaseService, DbConnectionStatus, DbOpLog, DbOpLogEntry, DbStatusByType, DbType, DerivedRepository, EncryptedStorage, EncryptedStorageService, MigrateMongoConfig, MongoDBErrorCode, MongoDbStatus, MongoHelper, MongodbOperationResult, MongodbOperationsLabelsMap, PostgresDatabase, PostgresDatabaseService, PostgresDbConfig, PostgresErrorCode, ReplicaSetNodeConfig, counter, counterSchema, createStatusHistoryItemSchema, encryptedStorage, encryptedStorageSchema, expiringTimestamp, models, mongodbOperationsAllowedFields, mongodbOperationsDefaultBuckets, mongoose, timestamps };
|
|
25
|
+
export { AppDb, AppDbConfig, Counter, CounterService, DatabaseAdapter, DatabaseAdapterType, DatabaseService, DbConnectionStatus, DbOpLog, DbOpLogEntry, DbStatusByType, DbType, DerivedRepository, EncryptedStorage, EncryptedStorageService, JweEncrypter, MigrateMongoConfig, MongoDBErrorCode, MongoDbStatus, MongoHelper, MongodbOperationResult, MongodbOperationsLabelsMap, PostgresDatabase, PostgresDatabaseService, PostgresDbConfig, PostgresErrorCode, ReplicaSetNodeConfig, buildEncryptedStorageEntry, counter, counterSchema, createStatusHistoryItemSchema, encryptedStorage, encryptedStorageSchema, expiringTimestamp, models, mongodbOperationsAllowedFields, mongodbOperationsDefaultBuckets, mongoose, timestamps };
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
-
export { AppDb, AppDbConfig, Counter, CounterService, DatabaseAdapter, DatabaseAdapterType, DatabaseService, DbConnectionStatus, DbOpLog, DbOpLogEntry, DbStatusByType, DbType, DerivedRepository, EncryptedStorage, EncryptedStorageService, MigrateMongoConfig, MongoDBErrorCode, MongoDbStatus, MongoHelper, MongodbOperationResult, MongodbOperationsLabelsMap, PostgresDatabase, PostgresDatabaseService, PostgresDbConfig, PostgresErrorCode, ReplicaSetNodeConfig, counter, counterSchema, createStatusHistoryItemSchema, encryptedStorage, encryptedStorageSchema, expiringTimestamp, models, mongodbOperationsAllowedFields, mongodbOperationsDefaultBuckets, mongoose, timestamps };
|
|
28
|
+
export { AppDb, AppDbConfig, Counter, CounterService, DatabaseAdapter, DatabaseAdapterType, DatabaseService, DbConnectionStatus, DbOpLog, DbOpLogEntry, DbStatusByType, DbType, DerivedRepository, EncryptedStorage, EncryptedStorageService, JweEncrypter, MigrateMongoConfig, MongoDBErrorCode, MongoDbStatus, MongoHelper, MongodbOperationResult, MongodbOperationsLabelsMap, PostgresDatabase, PostgresDatabaseService, PostgresDbConfig, PostgresErrorCode, ReplicaSetNodeConfig, buildEncryptedStorageEntry, counter, counterSchema, createStatusHistoryItemSchema, encryptedStorage, encryptedStorageSchema, expiringTimestamp, models, mongodbOperationsAllowedFields, mongodbOperationsDefaultBuckets, mongoose, timestamps };
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { DatabaseService } from "./services/database.js";
|
|
|
8
8
|
import { PostgresDatabaseService } from "./services/postgresDatabase.js";
|
|
9
9
|
import { expiringTimestamp, timestamps } from "./postgresUtils.js";
|
|
10
10
|
import { encryptedStorage } from "./tables/encryptedStorage.js";
|
|
11
|
-
import { EncryptedStorageService } from "./services/encryptedStorage.js";
|
|
11
|
+
import { EncryptedStorageService, buildEncryptedStorageEntry } from "./services/encryptedStorage.js";
|
|
12
12
|
import { counter } from "./tables/counter.js";
|
|
13
13
|
import { CounterService } from "./services/counter.js";
|
|
14
14
|
import "./services/index.js";
|
|
@@ -20,4 +20,4 @@ import "./schemas/index.js";
|
|
|
20
20
|
import "./postgres.js";
|
|
21
21
|
export * from "mongoose";
|
|
22
22
|
//#endregion
|
|
23
|
-
export { CounterService, DatabaseService, DbConnectionStatus, DbType, EncryptedStorageService, MongoDBErrorCode, MongoHelper, MongodbOperationResult, PostgresDatabaseService, PostgresErrorCode, counter, counterSchema, createStatusHistoryItemSchema, encryptedStorage, encryptedStorageSchema, expiringTimestamp, models, mongodbOperationsAllowedFields, mongodbOperationsDefaultBuckets, mongoose, timestamps };
|
|
23
|
+
export { CounterService, DatabaseService, DbConnectionStatus, DbType, EncryptedStorageService, MongoDBErrorCode, MongoHelper, MongodbOperationResult, PostgresDatabaseService, PostgresErrorCode, buildEncryptedStorageEntry, counter, counterSchema, createStatusHistoryItemSchema, encryptedStorage, encryptedStorageSchema, expiringTimestamp, models, mongodbOperationsAllowedFields, mongodbOperationsDefaultBuckets, mongoose, timestamps };
|
|
@@ -6,6 +6,8 @@ import { EnvService } from "@diia-inhouse/env";
|
|
|
6
6
|
import { AuthService } from "@diia-inhouse/crypto";
|
|
7
7
|
|
|
8
8
|
//#region src/services/encryptedStorage.d.ts
|
|
9
|
+
type JweEncrypter = Pick<AuthService, "encryptJWE">;
|
|
10
|
+
declare function buildEncryptedStorageEntry(auth: JweEncrypter, data: unknown, expiration: number, withSource: boolean): Promise<EncryptedStorage>;
|
|
9
11
|
/**
|
|
10
12
|
* EncryptedStorageService provides CRUD operations for managing encrypted storage entries
|
|
11
13
|
* in both Postgres and MongoDB databases. The service abstracts database implementation details
|
|
@@ -70,4 +72,4 @@ declare class EncryptedStorageService {
|
|
|
70
72
|
private getPostgresDatabase;
|
|
71
73
|
}
|
|
72
74
|
//#endregion
|
|
73
|
-
export { EncryptedStorageService };
|
|
75
|
+
export { EncryptedStorageService, JweEncrypter, buildEncryptedStorageEntry };
|
|
@@ -3,6 +3,14 @@ import { NotFoundError } from "@diia-inhouse/errors";
|
|
|
3
3
|
import { eq, inArray } from "drizzle-orm";
|
|
4
4
|
import { utils } from "@diia-inhouse/utils";
|
|
5
5
|
//#region src/services/encryptedStorage.ts
|
|
6
|
+
async function buildEncryptedStorageEntry(auth, data, expiration, withSource) {
|
|
7
|
+
const storageItem = {
|
|
8
|
+
data: await auth.encryptJWE(utils.encodeObjectToBase64(data)),
|
|
9
|
+
expiresAt: new Date(Date.now() + expiration)
|
|
10
|
+
};
|
|
11
|
+
if (withSource) storageItem.source = data;
|
|
12
|
+
return storageItem;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* EncryptedStorageService provides CRUD operations for managing encrypted storage entries
|
|
8
16
|
* in both Postgres and MongoDB databases. The service abstracts database implementation details
|
|
@@ -104,11 +112,7 @@ var EncryptedStorageService = class {
|
|
|
104
112
|
this.postgresDatabase = postgresDatabase;
|
|
105
113
|
}
|
|
106
114
|
async save(data, expiration) {
|
|
107
|
-
const storageItem =
|
|
108
|
-
data: await this.auth.encryptJWE(utils.encodeObjectToBase64(data)),
|
|
109
|
-
expiresAt: new Date(Date.now() + expiration)
|
|
110
|
-
};
|
|
111
|
-
if (!this.envService.isProd()) storageItem.source = data;
|
|
115
|
+
const storageItem = await buildEncryptedStorageEntry(this.auth, data, expiration, !this.envService.isProd());
|
|
112
116
|
return await this.saveEntityStrategy[this.databaseAdapter](storageItem);
|
|
113
117
|
}
|
|
114
118
|
async get(id, options = {}) {
|
|
@@ -176,4 +180,4 @@ var EncryptedStorageService = class {
|
|
|
176
180
|
}
|
|
177
181
|
};
|
|
178
182
|
//#endregion
|
|
179
|
-
export { EncryptedStorageService };
|
|
183
|
+
export { EncryptedStorageService, buildEncryptedStorageEntry };
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DatabaseService } from "./database.js";
|
|
2
2
|
import { PostgresDatabaseService } from "./postgresDatabase.js";
|
|
3
|
-
import { EncryptedStorageService } from "./encryptedStorage.js";
|
|
3
|
+
import { EncryptedStorageService, JweEncrypter, buildEncryptedStorageEntry } from "./encryptedStorage.js";
|
|
4
4
|
import { CounterService } from "./counter.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/db",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Package with database connection",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"lint:lockfile": "lockfile-lint --path package-lock.json --allowed-hosts registry.npmjs.org --validate-https"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@diia-inhouse/crypto": "2.1.
|
|
44
|
-
"@diia-inhouse/diia-logger": "4.4.
|
|
45
|
-
"@diia-inhouse/diia-metrics": "7.1.
|
|
46
|
-
"@diia-inhouse/utils": "6.0.
|
|
47
|
-
"@diia-inhouse/validators": "2.2.
|
|
43
|
+
"@diia-inhouse/crypto": "2.1.5",
|
|
44
|
+
"@diia-inhouse/diia-logger": "4.4.41",
|
|
45
|
+
"@diia-inhouse/diia-metrics": "7.1.77",
|
|
46
|
+
"@diia-inhouse/utils": "6.0.75",
|
|
47
|
+
"@diia-inhouse/validators": "2.2.57",
|
|
48
48
|
"@types/migrate-mongo": "10.0.6",
|
|
49
49
|
"bson": "7.2.0",
|
|
50
50
|
"drizzle-orm": "0.45.2",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@diia-inhouse/configs": "7.0.1",
|
|
66
|
-
"@diia-inhouse/env": "3.3.
|
|
67
|
-
"@diia-inhouse/errors": "2.2.
|
|
66
|
+
"@diia-inhouse/env": "3.3.44",
|
|
67
|
+
"@diia-inhouse/errors": "2.2.16",
|
|
68
68
|
"@diia-inhouse/oxc-config": "2.1.1",
|
|
69
|
-
"@diia-inhouse/test": "8.2
|
|
69
|
+
"@diia-inhouse/test": "8.3.2",
|
|
70
70
|
"@diia-inhouse/types": "14.2.3",
|
|
71
71
|
"@types/lodash": "4.17.24",
|
|
72
72
|
"@types/node": "25.6.2",
|