@ikonintegration/ikapi 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/BaseEvent/Launchable/ContainerExec.ts +6 -2
- package/src/Mailer/Mailer.ts +42 -52
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -28
- package/dist/index.js.map +0 -1
- package/dist/package-lock.json +0 -11901
- package/dist/package.json +0 -82
- package/dist/src/API/Request.d.ts +0 -125
- package/dist/src/API/Request.js +0 -185
- package/dist/src/API/Request.js.map +0 -1
- package/dist/src/API/Response.d.ts +0 -188
- package/dist/src/API/Response.js +0 -270
- package/dist/src/API/Response.js.map +0 -1
- package/dist/src/BaseEvent/DynamoTransaction.d.ts +0 -70
- package/dist/src/BaseEvent/DynamoTransaction.js +0 -104
- package/dist/src/BaseEvent/DynamoTransaction.js.map +0 -1
- package/dist/src/BaseEvent/EventProcessor.d.ts +0 -58
- package/dist/src/BaseEvent/EventProcessor.js +0 -101
- package/dist/src/BaseEvent/EventProcessor.js.map +0 -1
- package/dist/src/BaseEvent/Launchable/ContainerExec.d.ts +0 -42
- package/dist/src/BaseEvent/Launchable/ContainerExec.js +0 -102
- package/dist/src/BaseEvent/Launchable/ContainerExec.js.map +0 -1
- package/dist/src/BaseEvent/Launchable/index.d.ts +0 -34
- package/dist/src/BaseEvent/Launchable/index.js +0 -43
- package/dist/src/BaseEvent/Launchable/index.js.map +0 -1
- package/dist/src/BaseEvent/Launchable/types.d.ts +0 -10
- package/dist/src/BaseEvent/Launchable/types.js +0 -2
- package/dist/src/BaseEvent/Launchable/types.js.map +0 -1
- package/dist/src/BaseEvent/Process.d.ts +0 -50
- package/dist/src/BaseEvent/Process.js +0 -64
- package/dist/src/BaseEvent/Process.js.map +0 -1
- package/dist/src/BaseEvent/StepTransaction.d.ts +0 -23
- package/dist/src/BaseEvent/StepTransaction.js +0 -27
- package/dist/src/BaseEvent/StepTransaction.js.map +0 -1
- package/dist/src/BaseEvent/Transaction.d.ts +0 -149
- package/dist/src/BaseEvent/Transaction.js +0 -224
- package/dist/src/BaseEvent/Transaction.js.map +0 -1
- package/dist/src/Cache/Redis.d.ts +0 -29
- package/dist/src/Cache/Redis.js +0 -80
- package/dist/src/Cache/Redis.js.map +0 -1
- package/dist/src/Cache/types.d.ts +0 -31
- package/dist/src/Cache/types.js +0 -2
- package/dist/src/Cache/types.js.map +0 -1
- package/dist/src/Config/Configuration.d.ts +0 -123
- package/dist/src/Config/Configuration.js +0 -109
- package/dist/src/Config/Configuration.js.map +0 -1
- package/dist/src/Config/EnvironmentVar.d.ts +0 -74
- package/dist/src/Config/EnvironmentVar.js +0 -138
- package/dist/src/Config/EnvironmentVar.js.map +0 -1
- package/dist/src/Crypto/Crypto.d.ts +0 -45
- package/dist/src/Crypto/Crypto.js +0 -72
- package/dist/src/Crypto/Crypto.js.map +0 -1
- package/dist/src/Database/Database.d.ts +0 -21
- package/dist/src/Database/Database.js +0 -15
- package/dist/src/Database/Database.js.map +0 -1
- package/dist/src/Database/DatabaseManager.d.ts +0 -47
- package/dist/src/Database/DatabaseManager.js +0 -60
- package/dist/src/Database/DatabaseManager.js.map +0 -1
- package/dist/src/Database/DatabaseTransaction.d.ts +0 -101
- package/dist/src/Database/DatabaseTransaction.js +0 -126
- package/dist/src/Database/DatabaseTransaction.js.map +0 -1
- package/dist/src/Database/index.d.ts +0 -10
- package/dist/src/Database/index.js +0 -15
- package/dist/src/Database/index.js.map +0 -1
- package/dist/src/Database/integrations/dynamo/DynamoDatabase.d.ts +0 -35
- package/dist/src/Database/integrations/dynamo/DynamoDatabase.js +0 -59
- package/dist/src/Database/integrations/dynamo/DynamoDatabase.js.map +0 -1
- package/dist/src/Database/integrations/kysely/KyselyDatabase.d.ts +0 -66
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js +0 -86
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +0 -1
- package/dist/src/Database/integrations/kysely/KyselyTransaction.d.ts +0 -70
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js +0 -118
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +0 -1
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +0 -36
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +0 -54
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +0 -1
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +0 -63
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +0 -61
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +0 -1
- package/dist/src/Database/types.d.ts +0 -76
- package/dist/src/Database/types.js +0 -2
- package/dist/src/Database/types.js.map +0 -1
- package/dist/src/Globals.d.ts +0 -93
- package/dist/src/Globals.js +0 -99
- package/dist/src/Globals.js.map +0 -1
- package/dist/src/Logger/Logger.d.ts +0 -161
- package/dist/src/Logger/Logger.js +0 -299
- package/dist/src/Logger/Logger.js.map +0 -1
- package/dist/src/Mailer/Mailer.d.ts +0 -78
- package/dist/src/Mailer/Mailer.js +0 -182
- package/dist/src/Mailer/Mailer.js.map +0 -1
- package/dist/src/Publisher/Publisher.d.ts +0 -39
- package/dist/src/Publisher/Publisher.js +0 -77
- package/dist/src/Publisher/Publisher.js.map +0 -1
- package/dist/src/Server/RouteResolver.d.ts +0 -33
- package/dist/src/Server/RouteResolver.js +0 -100
- package/dist/src/Server/RouteResolver.js.map +0 -1
- package/dist/src/Server/Router.d.ts +0 -157
- package/dist/src/Server/Router.js +0 -32
- package/dist/src/Server/Router.js.map +0 -1
- package/dist/src/Server/lib/ContainerServer.d.ts +0 -42
- package/dist/src/Server/lib/ContainerServer.js +0 -66
- package/dist/src/Server/lib/ContainerServer.js.map +0 -1
- package/dist/src/Server/lib/Server.d.ts +0 -45
- package/dist/src/Server/lib/Server.js +0 -93
- package/dist/src/Server/lib/Server.js.map +0 -1
- package/dist/src/Server/lib/container/GenericHandler.d.ts +0 -9
- package/dist/src/Server/lib/container/GenericHandler.js +0 -82
- package/dist/src/Server/lib/container/GenericHandler.js.map +0 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +0 -52
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +0 -132
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +0 -1
- package/dist/src/Server/lib/container/HealthHandler.d.ts +0 -9
- package/dist/src/Server/lib/container/HealthHandler.js +0 -19
- package/dist/src/Server/lib/container/HealthHandler.js.map +0 -1
- package/dist/src/Server/lib/container/Proxy.d.ts +0 -67
- package/dist/src/Server/lib/container/Proxy.js +0 -143
- package/dist/src/Server/lib/container/Proxy.js.map +0 -1
- package/dist/src/Server/lib/container/Utils.d.ts +0 -14
- package/dist/src/Server/lib/container/Utils.js +0 -37
- package/dist/src/Server/lib/container/Utils.js.map +0 -1
- package/dist/src/Util/AsyncSingleton.d.ts +0 -31
- package/dist/src/Util/AsyncSingleton.js +0 -83
- package/dist/src/Util/AsyncSingleton.js.map +0 -1
- package/dist/src/Util/Utils.d.ts +0 -61
- package/dist/src/Util/Utils.js +0 -147
- package/dist/src/Util/Utils.js.map +0 -1
- package/dist/src/Validation/Validator.d.ts +0 -17
- package/dist/src/Validation/Validator.js +0 -39
- package/dist/src/Validation/Validator.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An enumeration representing different types of environments.
|
|
3
|
-
* @enum {number}
|
|
4
|
-
* @readonly
|
|
5
|
-
* @property {number} PlainRemote - Represents a plain remote environment.
|
|
6
|
-
* @property {number} SecureRemote - Represents a secure remote environment.
|
|
7
|
-
* @property {number} Local - Represents a local environment.
|
|
8
|
-
*/
|
|
9
|
-
export declare enum EnvironmentType {
|
|
10
|
-
PlainRemote = 0,
|
|
11
|
-
SecureRemote = 1,
|
|
12
|
-
Local = 2
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Represents an environment variable with methods to resolve its value based on the environment type.
|
|
16
|
-
* @template T - The type of the environment variable value.
|
|
17
|
-
*/
|
|
18
|
-
export default class EnvironmentVar<T> {
|
|
19
|
-
/**
|
|
20
|
-
* The name of the parameter.
|
|
21
|
-
*/
|
|
22
|
-
private readonly paramName;
|
|
23
|
-
/**
|
|
24
|
-
* The type of environment.
|
|
25
|
-
* @readonly
|
|
26
|
-
*/
|
|
27
|
-
private readonly type;
|
|
28
|
-
/**
|
|
29
|
-
* A boolean flag indicating whether the field is optional or not.
|
|
30
|
-
*/
|
|
31
|
-
private readonly optional;
|
|
32
|
-
/**
|
|
33
|
-
* The prefix used for parameters in the class.
|
|
34
|
-
* @type {string}
|
|
35
|
-
*/
|
|
36
|
-
private readonly paramPrefix;
|
|
37
|
-
/**
|
|
38
|
-
* Constructs a new instance of the EnvironmentVar class.
|
|
39
|
-
* @param {string} paramName - The name of the environment variable.
|
|
40
|
-
* @param {EnvironmentType} type - The type of the environment.
|
|
41
|
-
* @param {boolean} [optional] - Indicates whether the environment variable is optional.
|
|
42
|
-
* @param {string} [paramPrefix] - The prefix to be added to the environment variable name.
|
|
43
|
-
*/
|
|
44
|
-
constructor(paramName: string, type: EnvironmentType, optional: boolean | undefined, paramPrefix: string);
|
|
45
|
-
/**
|
|
46
|
-
* Resolves the value of the environment variable synchronously.
|
|
47
|
-
* @returns {T} - The resolved value of the environment variable.
|
|
48
|
-
* @throws {Error} - If the environment type is not 'Local'.
|
|
49
|
-
*/
|
|
50
|
-
syncResolve(): T;
|
|
51
|
-
/**
|
|
52
|
-
* Resolves the value based on the environment type.
|
|
53
|
-
* @returns {Promise<any>} - The resolved value.
|
|
54
|
-
*/
|
|
55
|
-
resolve(): Promise<T | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* Retrieves the value of a local environment variable.
|
|
58
|
-
* @returns {T} - The value of the local environment variable.
|
|
59
|
-
* @throws {Error} - If the local environment variable is not defined and is not optional.
|
|
60
|
-
*/
|
|
61
|
-
private getLocalValue;
|
|
62
|
-
/**
|
|
63
|
-
* Retrieves the plain value of a remote environment parameter.
|
|
64
|
-
* @returns {Promise<T>} - A promise that resolves to the plain value of the parameter.
|
|
65
|
-
* @throws {Error} - If the parameter cannot be retrieved and is not optional.
|
|
66
|
-
*/
|
|
67
|
-
private getPlainValue;
|
|
68
|
-
/**
|
|
69
|
-
* Retrieves a secure value from the secrets manager.
|
|
70
|
-
* @returns {Promise<T>} - A promise that resolves to the secure value.
|
|
71
|
-
* @throws {Error} - Throws an error if the secure value cannot be retrieved and is not optional.
|
|
72
|
-
*/
|
|
73
|
-
private getSecureValue;
|
|
74
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
|
|
11
|
-
import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm';
|
|
12
|
-
// Explicity setting VM level variables in order to persist
|
|
13
|
-
// client across different important and instances.
|
|
14
|
-
// eslint-disable-next-line no-var
|
|
15
|
-
/**
|
|
16
|
-
* Variables to hold instances of SSMClient and SecretsManagerClient, initialized as null.
|
|
17
|
-
* @type {SSMClient | null} ssmClient - Instance of SSMClient or null if not initialized.
|
|
18
|
-
* @type {SecretsManagerClient | null} secretsClient - Instance of SecretsManagerClient or null if not initialized.
|
|
19
|
-
*/
|
|
20
|
-
let ssmClient = null, secretsClient = null;
|
|
21
|
-
/**
|
|
22
|
-
* An enumeration representing different types of environments.
|
|
23
|
-
* @enum {number}
|
|
24
|
-
* @readonly
|
|
25
|
-
* @property {number} PlainRemote - Represents a plain remote environment.
|
|
26
|
-
* @property {number} SecureRemote - Represents a secure remote environment.
|
|
27
|
-
* @property {number} Local - Represents a local environment.
|
|
28
|
-
*/
|
|
29
|
-
export var EnvironmentType;
|
|
30
|
-
(function (EnvironmentType) {
|
|
31
|
-
EnvironmentType[EnvironmentType["PlainRemote"] = 0] = "PlainRemote";
|
|
32
|
-
EnvironmentType[EnvironmentType["SecureRemote"] = 1] = "SecureRemote";
|
|
33
|
-
EnvironmentType[EnvironmentType["Local"] = 2] = "Local";
|
|
34
|
-
})(EnvironmentType || (EnvironmentType = {}));
|
|
35
|
-
/**
|
|
36
|
-
* Represents an environment variable with methods to resolve its value based on the environment type.
|
|
37
|
-
* @template T - The type of the environment variable value.
|
|
38
|
-
*/
|
|
39
|
-
export default class EnvironmentVar {
|
|
40
|
-
/**
|
|
41
|
-
* Constructs a new instance of the EnvironmentVar class.
|
|
42
|
-
* @param {string} paramName - The name of the environment variable.
|
|
43
|
-
* @param {EnvironmentType} type - The type of the environment.
|
|
44
|
-
* @param {boolean} [optional] - Indicates whether the environment variable is optional.
|
|
45
|
-
* @param {string} [paramPrefix] - The prefix to be added to the environment variable name.
|
|
46
|
-
*/
|
|
47
|
-
constructor(paramName, type, optional = true, paramPrefix) {
|
|
48
|
-
this.paramName = paramName;
|
|
49
|
-
this.type = type;
|
|
50
|
-
this.optional = !!optional;
|
|
51
|
-
this.paramPrefix = paramPrefix;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Resolves the value of the environment variable synchronously.
|
|
55
|
-
* @returns {T} - The resolved value of the environment variable.
|
|
56
|
-
* @throws {Error} - If the environment type is not 'Local'.
|
|
57
|
-
*/
|
|
58
|
-
syncResolve() {
|
|
59
|
-
if (this.type == EnvironmentType.Local)
|
|
60
|
-
return this.getLocalValue();
|
|
61
|
-
else {
|
|
62
|
-
throw new Error("EnvironmentVar syncResolve method can only be called for environments of type 'Local'");
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Resolves the value based on the environment type.
|
|
67
|
-
* @returns {Promise<any>} - The resolved value.
|
|
68
|
-
*/
|
|
69
|
-
resolve() {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
if (this.type == EnvironmentType.Local)
|
|
72
|
-
return this.getLocalValue();
|
|
73
|
-
else if (this.type == EnvironmentType.SecureRemote)
|
|
74
|
-
return this.getSecureValue();
|
|
75
|
-
else
|
|
76
|
-
return this.getPlainValue();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Retrieves the value of a local environment variable.
|
|
81
|
-
* @returns {T} - The value of the local environment variable.
|
|
82
|
-
* @throws {Error} - If the local environment variable is not defined and is not optional.
|
|
83
|
-
*/
|
|
84
|
-
getLocalValue() {
|
|
85
|
-
const value = process.env[this.paramName];
|
|
86
|
-
if (!value && !this.optional) {
|
|
87
|
-
throw new Error(`Local environment ${this.paramName} is not defined, please reconfigure the application and redeploy!`);
|
|
88
|
-
}
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Retrieves the plain value of a remote environment parameter.
|
|
93
|
-
* @returns {Promise<T>} - A promise that resolves to the plain value of the parameter.
|
|
94
|
-
* @throws {Error} - If the parameter cannot be retrieved and is not optional.
|
|
95
|
-
*/
|
|
96
|
-
getPlainValue() {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
if (!ssmClient)
|
|
99
|
-
ssmClient = new SSMClient();
|
|
100
|
-
const pName = `${this.paramPrefix}${this.paramName}`;
|
|
101
|
-
try {
|
|
102
|
-
const data = yield ssmClient.send(new GetParameterCommand({ Name: pName }));
|
|
103
|
-
if (data.Parameter && data.Parameter.Value)
|
|
104
|
-
return data.Parameter.Value;
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
console.error(error);
|
|
108
|
-
}
|
|
109
|
-
if (!this.optional) {
|
|
110
|
-
throw new Error(`Unable to retrieve plain remote env value: ${pName}`);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Retrieves a secure value from the secrets manager.
|
|
116
|
-
* @returns {Promise<T>} - A promise that resolves to the secure value.
|
|
117
|
-
* @throws {Error} - Throws an error if the secure value cannot be retrieved and is not optional.
|
|
118
|
-
*/
|
|
119
|
-
getSecureValue() {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
if (!secretsClient)
|
|
122
|
-
secretsClient = new SecretsManagerClient();
|
|
123
|
-
const pName = `${this.paramPrefix}${this.paramName}`;
|
|
124
|
-
try {
|
|
125
|
-
const data = yield secretsClient.send(new GetSecretValueCommand({ SecretId: pName }));
|
|
126
|
-
if (data.SecretString)
|
|
127
|
-
return data.SecretString;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
console.error(error);
|
|
131
|
-
}
|
|
132
|
-
if (!this.optional) {
|
|
133
|
-
throw new Error(`Unable to retrieve secure remote env: ${pName}`);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=EnvironmentVar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EnvironmentVar.js","sourceRoot":"","sources":["../../../src/Config/EnvironmentVar.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { EncryptionAlgorithmSpec } from '@aws-sdk/client-kms';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
|
|
4
|
-
*/
|
|
5
|
-
export default class Crypto {
|
|
6
|
-
/**
|
|
7
|
-
* The KMSClient instance used for making requests to the Key Management Service (KMS).
|
|
8
|
-
*/
|
|
9
|
-
private readonly client;
|
|
10
|
-
/**
|
|
11
|
-
* The AWS region of the object. This property is readonly and cannot be modified once set.
|
|
12
|
-
*/
|
|
13
|
-
private readonly region;
|
|
14
|
-
/**
|
|
15
|
-
* The unique identifier for the KMS.
|
|
16
|
-
* @readonly
|
|
17
|
-
* @type {string}
|
|
18
|
-
*/
|
|
19
|
-
private readonly keyId;
|
|
20
|
-
/**
|
|
21
|
-
* Specifies the encryption algorithm used for encryption.
|
|
22
|
-
*/
|
|
23
|
-
private readonly encryptionAlgorithm;
|
|
24
|
-
/**
|
|
25
|
-
* Constructs a new instance of a KeyManager with the provided region, keyId, and optional encryption algorithm.
|
|
26
|
-
* @param {string} region - The region where the key is stored.
|
|
27
|
-
* @param {string} keyId - The ID of the key.
|
|
28
|
-
* @param {EncryptionAlgorithmSpec} [optEncryptionAlgorithm='RSAES_OAEP_SHA_256'] - The encryption algorithm to use (default is RSAES_OAEP_SHA_256).
|
|
29
|
-
* @returns None
|
|
30
|
-
*/
|
|
31
|
-
constructor(region: string, keyId: string, optEncryptionAlgorithm?: EncryptionAlgorithmSpec);
|
|
32
|
-
/**
|
|
33
|
-
* Encrypts the given data using RSAES_OAEP_SHA_256 encryption algorithm.
|
|
34
|
-
* @param {string | any} data - The data to be encrypted.
|
|
35
|
-
* @returns {Promise<string | null>} - A promise that resolves to the encrypted data as a hexadecimal string.
|
|
36
|
-
*/
|
|
37
|
-
encryptData(data: string | any): Promise<string | null>;
|
|
38
|
-
/**
|
|
39
|
-
* Decrypts the given data using the RSAES_OAEP_SHA_256 encryption algorithm.
|
|
40
|
-
* @param {string} data - The encrypted data to decrypt.
|
|
41
|
-
* @returns {Promise<string | null>} - A promise that resolves to the decrypted plaintext string.
|
|
42
|
-
* If decryption fails, null is returned.
|
|
43
|
-
*/
|
|
44
|
-
decryptData(data: string): Promise<string | null>;
|
|
45
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { KMSClient, EncryptCommand, DecryptCommand, } from '@aws-sdk/client-kms';
|
|
11
|
-
/**
|
|
12
|
-
* Represents a Crypto class that provides encryption and decryption functionality using AWS KMS.
|
|
13
|
-
*/
|
|
14
|
-
export default class Crypto {
|
|
15
|
-
/**
|
|
16
|
-
* Constructs a new instance of a KeyManager with the provided region, keyId, and optional encryption algorithm.
|
|
17
|
-
* @param {string} region - The region where the key is stored.
|
|
18
|
-
* @param {string} keyId - The ID of the key.
|
|
19
|
-
* @param {EncryptionAlgorithmSpec} [optEncryptionAlgorithm='RSAES_OAEP_SHA_256'] - The encryption algorithm to use (default is RSAES_OAEP_SHA_256).
|
|
20
|
-
* @returns None
|
|
21
|
-
*/
|
|
22
|
-
constructor(region, keyId, optEncryptionAlgorithm) {
|
|
23
|
-
this.region = region;
|
|
24
|
-
this.keyId = keyId;
|
|
25
|
-
this.encryptionAlgorithm = optEncryptionAlgorithm || 'RSAES_OAEP_SHA_256';
|
|
26
|
-
this.client = new KMSClient({ region: this.region });
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Encrypts the given data using RSAES_OAEP_SHA_256 encryption algorithm.
|
|
30
|
-
* @param {string | any} data - The data to be encrypted.
|
|
31
|
-
* @returns {Promise<string | null>} - A promise that resolves to the encrypted data as a hexadecimal string.
|
|
32
|
-
*/
|
|
33
|
-
encryptData(data) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
try {
|
|
36
|
-
const resp = yield this.client.send(new EncryptCommand({
|
|
37
|
-
KeyId: this.keyId,
|
|
38
|
-
EncryptionAlgorithm: this.encryptionAlgorithm,
|
|
39
|
-
Plaintext: new TextEncoder().encode(typeof data === 'string' ? data : JSON.stringify(data)),
|
|
40
|
-
}));
|
|
41
|
-
return Buffer.from(resp.CiphertextBlob, 'utf8').toString('hex');
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
console.error('Encryption failure', e);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Decrypts the given data using the RSAES_OAEP_SHA_256 encryption algorithm.
|
|
51
|
-
* @param {string} data - The encrypted data to decrypt.
|
|
52
|
-
* @returns {Promise<string | null>} - A promise that resolves to the decrypted plaintext string.
|
|
53
|
-
* If decryption fails, null is returned.
|
|
54
|
-
*/
|
|
55
|
-
decryptData(data) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
try {
|
|
58
|
-
const resp = yield this.client.send(new DecryptCommand({
|
|
59
|
-
KeyId: this.keyId,
|
|
60
|
-
CiphertextBlob: Buffer.from(data, 'hex'),
|
|
61
|
-
EncryptionAlgorithm: this.encryptionAlgorithm,
|
|
62
|
-
}));
|
|
63
|
-
return new TextDecoder().decode(resp.Plaintext);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
console.error('Decryption failure', e);
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=Crypto.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../../../src/Crypto/Crypto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,GAEf,MAAM,qBAAqB,CAAA;AAE5B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IAoBzB;;;;;;OAMG;IACH,YAAY,MAAc,EAAE,KAAa,EAAE,sBAAgD;QACzF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,mBAAmB,GAAG,sBAAsB,IAAI,oBAAoB,CAAA;QACzE,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACtD,CAAC;IAED;;;;OAIG;IACU,WAAW,CAAC,IAAkB;;YACzC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,IAAI,cAAc,CAAC;oBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;oBAC7C,SAAS,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CACjC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CACvD;iBACF,CAAC,CACH,CAAA;gBACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAqB,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YACxE,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;gBACtC,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACU,WAAW,CAAC,IAAY;;YACnC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACjC,IAAI,cAAc,CAAC;oBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;oBACxC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;iBAC9C,CAAC,CACH,CAAA;gBACD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACjD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAA;gBACtC,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;KAAA;CACF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DatabaseTransaction } from './DatabaseTransaction.js';
|
|
2
|
-
import { DbConfig } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Abstract class representing a Database with a generic type extending DatabaseTransaction.
|
|
5
|
-
* @template T - The type of DatabaseTransaction to be used.
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class Database<T extends DatabaseTransaction> {
|
|
8
|
-
readonly config: DbConfig<any>;
|
|
9
|
-
/**
|
|
10
|
-
* Constructor for a class that takes in a database configuration object.
|
|
11
|
-
* @param {DbConfig<any>} config - The database configuration object.
|
|
12
|
-
* @returns None
|
|
13
|
-
*/
|
|
14
|
-
protected constructor(config: DbConfig<any>);
|
|
15
|
-
/**
|
|
16
|
-
* Represents an abstract method for a transaction that returns a Promise of type T.
|
|
17
|
-
* This method needs to be implemented by subclasses.
|
|
18
|
-
* @returns A Promise that resolves to a value of type T.
|
|
19
|
-
*/
|
|
20
|
-
abstract transaction(): Promise<T>;
|
|
21
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abstract class representing a Database with a generic type extending DatabaseTransaction.
|
|
3
|
-
* @template T - The type of DatabaseTransaction to be used.
|
|
4
|
-
*/
|
|
5
|
-
export class Database {
|
|
6
|
-
/**
|
|
7
|
-
* Constructor for a class that takes in a database configuration object.
|
|
8
|
-
* @param {DbConfig<any>} config - The database configuration object.
|
|
9
|
-
* @returns None
|
|
10
|
-
*/
|
|
11
|
-
constructor(config) {
|
|
12
|
-
this.config = config;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=Database.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Database.js","sourceRoot":"","sources":["../../../src/Database/Database.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAgB,QAAQ;IAC5B;;;;OAIG;IACH,YAAsC,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;CAQhE"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { DynamoDatabase } from './integrations/dynamo/DynamoDatabase.js';
|
|
2
|
-
import { KyselyDatabase } from './integrations/kysely/KyselyDatabase.js';
|
|
3
|
-
import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase.js';
|
|
4
|
-
import type { DatabaseImplType, DatabaseType, DbConfig } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
* Object containing different database implementations.
|
|
7
|
-
* @type {Object}
|
|
8
|
-
* @property {PostgresDatabase} pg - Postgres database implementation
|
|
9
|
-
* @property {KyselyDatabase<any>} kysely - Kysely database implementation
|
|
10
|
-
*/
|
|
11
|
-
export declare const DATABASES: {
|
|
12
|
-
pg: typeof PostgresDatabase;
|
|
13
|
-
kysely: typeof KyselyDatabase;
|
|
14
|
-
dynamo: typeof DynamoDatabase;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Manages the creation and storage of database instances.
|
|
18
|
-
*/
|
|
19
|
-
export declare class DatabaseManager {
|
|
20
|
-
/**
|
|
21
|
-
* Singleton instance of the DatabaseManager class.
|
|
22
|
-
* This instance is used to interact with the database.
|
|
23
|
-
*/
|
|
24
|
-
static readonly INSTANCE: DatabaseManager;
|
|
25
|
-
/**
|
|
26
|
-
* A private property that holds a reference to the DATABASES constant.
|
|
27
|
-
* @type {typeof DATABASES}
|
|
28
|
-
*/
|
|
29
|
-
private databases;
|
|
30
|
-
/**
|
|
31
|
-
* An object that stores instances of DatabaseImplType objects with keys of type string.
|
|
32
|
-
* @type {Object.<string, DatabaseImplType<any, any>>}
|
|
33
|
-
*/
|
|
34
|
-
private instances;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a database instance based on the provided configuration.
|
|
37
|
-
* @param {DbConfig<S>} config - The configuration object for the database.
|
|
38
|
-
* @returns {DatabaseImplType<S, DBSchema>} An instance of the database based on the configuration.
|
|
39
|
-
*/
|
|
40
|
-
create<S extends DatabaseType, DBSchema>(config: DbConfig<S>): DatabaseImplType<S, DBSchema>;
|
|
41
|
-
/**
|
|
42
|
-
* Instantiates a database connection based on the provided configuration.
|
|
43
|
-
* @param {DbConfig<'pg'> | DbConfig<'kysely'>} config - The configuration object specifying the type of database.
|
|
44
|
-
* @returns {DatabaseImplType<S, DBSchema>} An instance of the specified database connection.
|
|
45
|
-
*/
|
|
46
|
-
private instantiateDb;
|
|
47
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import hash from 'object-hash';
|
|
2
|
-
import { DynamoDatabase } from './integrations/dynamo/DynamoDatabase.js';
|
|
3
|
-
import { KyselyDatabase } from './integrations/kysely/KyselyDatabase.js';
|
|
4
|
-
import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase.js';
|
|
5
|
-
/**
|
|
6
|
-
* Object containing different database implementations.
|
|
7
|
-
* @type {Object}
|
|
8
|
-
* @property {PostgresDatabase} pg - Postgres database implementation
|
|
9
|
-
* @property {KyselyDatabase<any>} kysely - Kysely database implementation
|
|
10
|
-
*/
|
|
11
|
-
export const DATABASES = {
|
|
12
|
-
pg: PostgresDatabase,
|
|
13
|
-
kysely: KyselyDatabase,
|
|
14
|
-
dynamo: DynamoDatabase,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Manages the creation and storage of database instances.
|
|
18
|
-
*/
|
|
19
|
-
export class DatabaseManager {
|
|
20
|
-
constructor() {
|
|
21
|
-
/**
|
|
22
|
-
* A private property that holds a reference to the DATABASES constant.
|
|
23
|
-
* @type {typeof DATABASES}
|
|
24
|
-
*/
|
|
25
|
-
this.databases = DATABASES;
|
|
26
|
-
/**
|
|
27
|
-
* An object that stores instances of DatabaseImplType objects with keys of type string.
|
|
28
|
-
* @type {Object.<string, DatabaseImplType<any, any>>}
|
|
29
|
-
*/
|
|
30
|
-
this.instances = {};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates a database instance based on the provided configuration.
|
|
34
|
-
* @param {DbConfig<S>} config - The configuration object for the database.
|
|
35
|
-
* @returns {DatabaseImplType<S, DBSchema>} An instance of the database based on the configuration.
|
|
36
|
-
*/
|
|
37
|
-
create(config) {
|
|
38
|
-
const configHash = hash(config);
|
|
39
|
-
if (this.instances[configHash]) {
|
|
40
|
-
return this.instances[configHash];
|
|
41
|
-
}
|
|
42
|
-
const instance = this.instantiateDb(config);
|
|
43
|
-
this.instances[configHash] = instance;
|
|
44
|
-
return instance;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Instantiates a database connection based on the provided configuration.
|
|
48
|
-
* @param {DbConfig<'pg'> | DbConfig<'kysely'>} config - The configuration object specifying the type of database.
|
|
49
|
-
* @returns {DatabaseImplType<S, DBSchema>} An instance of the specified database connection.
|
|
50
|
-
*/
|
|
51
|
-
instantiateDb(config) {
|
|
52
|
-
return new this.databases[config.type](config);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Singleton instance of the DatabaseManager class.
|
|
57
|
-
* This instance is used to interact with the database.
|
|
58
|
-
*/
|
|
59
|
-
DatabaseManager.INSTANCE = new DatabaseManager();
|
|
60
|
-
//# sourceMappingURL=DatabaseManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAA;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAA;AAG3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,gBAAgB;IACpB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,cAAc;CACvB,CAAA;AAED;;GAEG;AACH,MAAM,OAAO,eAAe;IAA5B;QAME;;;WAGG;QACK,cAAS,GAAqB,SAAS,CAAA;QAC/C;;;WAGG;QACK,cAAS,GAAgD,EAAE,CAAA;IA6BrE,CAAC;IA3BC;;;;OAIG;IACI,MAAM,CACX,MAAmB;QAEnB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAQ,CAAA;QAC1C,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAc,MAAa,CAAC,CAAA;QAC/D,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAA;QACrC,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;;;OAIG;IACK,aAAa,CACnB,MAAgE;QAEhE,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAa,CAAQ,CAAA;IAC9D,CAAC;;AA1CD;;;GAGG;AACoB,wBAAQ,GAAG,IAAI,eAAe,EAAE,AAAxB,CAAwB"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Database } from './Database.js';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract class representing a database transaction.
|
|
4
|
-
* Warning: These need to be arrow functions!
|
|
5
|
-
* @class DatabaseTransaction
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class DatabaseTransaction extends Function {
|
|
8
|
-
/**
|
|
9
|
-
* A boolean flag indicating whether a certain feature is open or closed.
|
|
10
|
-
* @type {boolean}
|
|
11
|
-
*/
|
|
12
|
-
protected _isOpen: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* A property representing a writer object.
|
|
15
|
-
* @type {any}
|
|
16
|
-
*/
|
|
17
|
-
readonly writer: any;
|
|
18
|
-
/**
|
|
19
|
-
* A property representing a reader object.
|
|
20
|
-
* @type {any}
|
|
21
|
-
*/
|
|
22
|
-
readonly reader: any;
|
|
23
|
-
/**
|
|
24
|
-
* A protected property representing a transaction.
|
|
25
|
-
* @type {any}
|
|
26
|
-
*/
|
|
27
|
-
protected transaction: any;
|
|
28
|
-
/**
|
|
29
|
-
* A protected property representing a database of type Database<any>.
|
|
30
|
-
* This property is accessible within the class and its subclasses.
|
|
31
|
-
*/
|
|
32
|
-
protected database: Database<any>;
|
|
33
|
-
/**
|
|
34
|
-
* Constructor for a class that interacts with a database using a writer and reader.
|
|
35
|
-
* @param {any} writer - The object responsible for writing to the database.
|
|
36
|
-
* @param {Database<any>} database - The database to interact with.
|
|
37
|
-
* @param {any} [reader] - The object responsible for reading from the database (optional).
|
|
38
|
-
* @returns None
|
|
39
|
-
*/
|
|
40
|
-
protected constructor(writer: any, database: Database<any>, reader?: any);
|
|
41
|
-
/**
|
|
42
|
-
* Creates a proxy instance for the given subclass of DatabaseTransaction.
|
|
43
|
-
* The proxy handles method binding and transaction execution based on the subclass state.
|
|
44
|
-
* @param {T} subclass - The subclass of DatabaseTransaction to proxy.
|
|
45
|
-
* @returns A proxied instance of the subclass with method binding and transaction execution logic.
|
|
46
|
-
*/
|
|
47
|
-
protected static proxyInstance<T extends DatabaseTransaction>(subclass: T): T;
|
|
48
|
-
/**
|
|
49
|
-
* Check if the object is open.
|
|
50
|
-
* @returns {boolean} - true if the object is open, false otherwise.
|
|
51
|
-
*/
|
|
52
|
-
isOpen: () => boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Begins a transaction asynchronously.
|
|
55
|
-
* @returns {Promise<void>} A Promise that resolves when the transaction has begun.
|
|
56
|
-
* @throws {Error} If the transaction is already open.
|
|
57
|
-
*/
|
|
58
|
-
begin: () => Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Asynchronously commits the transaction.
|
|
61
|
-
* If the transaction is already closed, an error is thrown.
|
|
62
|
-
* @returns Promise<void>
|
|
63
|
-
* @throws Error if the transaction is already closed
|
|
64
|
-
*/
|
|
65
|
-
commit: () => Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Rollback the transaction by reverting any changes made within the transaction.
|
|
68
|
-
* If the transaction is already closed, an error is thrown.
|
|
69
|
-
* @returns Promise<void>
|
|
70
|
-
* @throws Error if the transaction is already closed.
|
|
71
|
-
*/
|
|
72
|
-
rollback: () => Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Closes the success modal, committing or rolling back changes based on the autoCommit setting.
|
|
75
|
-
* If the modal is open and autoCommit is enabled, it will commit the changes.
|
|
76
|
-
* If autoCommit is disabled, it will rollback the changes.
|
|
77
|
-
* @returns {Promise<void>} A promise that resolves once the commit or rollback operation is completed.
|
|
78
|
-
*/
|
|
79
|
-
closeSuccess: () => Promise<void>;
|
|
80
|
-
/**
|
|
81
|
-
* Closes the failure by performing a rollback if the failure is currently open.
|
|
82
|
-
* @returns {Promise<void>} A promise that resolves once the rollback is completed.
|
|
83
|
-
*/
|
|
84
|
-
closeFailure: () => Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Abstract method that should be implemented by subclasses to perform a commit operation.
|
|
87
|
-
* @returns A Promise that resolves when the commit operation is completed.
|
|
88
|
-
*/
|
|
89
|
-
protected abstract doCommit: () => Promise<any>;
|
|
90
|
-
/**
|
|
91
|
-
* An abstract method that defines the rollback functionality.
|
|
92
|
-
* This method should be implemented by subclasses to perform the actual rollback operation.
|
|
93
|
-
* @returns A Promise that resolves when the rollback operation is completed.
|
|
94
|
-
*/
|
|
95
|
-
protected abstract doRollback: () => Promise<any>;
|
|
96
|
-
/**
|
|
97
|
-
* Abstract method that defines the beginning of an asynchronous operation.
|
|
98
|
-
* @returns A Promise that resolves when the operation begins.
|
|
99
|
-
*/
|
|
100
|
-
protected abstract doBegin: () => Promise<any>;
|
|
101
|
-
}
|