@famir/database 0.0.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/README.md +4 -0
- package/dist/database.d.ts +27 -0
- package/dist/database.error.d.ts +9 -0
- package/dist/database.error.js +13 -0
- package/dist/database.error.js.map +1 -0
- package/dist/database.functions.d.ts +242 -0
- package/dist/database.functions.js +17 -0
- package/dist/database.functions.js.map +1 -0
- package/dist/database.js +5 -0
- package/dist/database.js.map +1 -0
- package/dist/database.keys.d.ts +21 -0
- package/dist/database.keys.js +67 -0
- package/dist/database.keys.js.map +1 -0
- package/dist/database.schemas.d.ts +3 -0
- package/dist/database.schemas.js +12 -0
- package/dist/database.schemas.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/models/campaign/campaign.d.ts +24 -0
- package/dist/models/campaign/campaign.js +47 -0
- package/dist/models/campaign/campaign.js.map +1 -0
- package/dist/models/campaign/index.d.ts +1 -0
- package/dist/models/campaign/index.js +2 -0
- package/dist/models/campaign/index.js.map +1 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/index.js +8 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/lure/index.d.ts +1 -0
- package/dist/models/lure/index.js +2 -0
- package/dist/models/lure/index.js.map +1 -0
- package/dist/models/lure/lure.d.ts +17 -0
- package/dist/models/lure/lure.js +25 -0
- package/dist/models/lure/lure.js.map +1 -0
- package/dist/models/message/index.d.ts +1 -0
- package/dist/models/message/index.js +2 -0
- package/dist/models/message/index.js.map +1 -0
- package/dist/models/message/message.d.ts +38 -0
- package/dist/models/message/message.js +58 -0
- package/dist/models/message/message.js.map +1 -0
- package/dist/models/proxy/index.d.ts +1 -0
- package/dist/models/proxy/index.js +2 -0
- package/dist/models/proxy/index.js.map +1 -0
- package/dist/models/proxy/proxy.d.ts +16 -0
- package/dist/models/proxy/proxy.js +23 -0
- package/dist/models/proxy/proxy.js.map +1 -0
- package/dist/models/redirector/index.d.ts +1 -0
- package/dist/models/redirector/index.js +2 -0
- package/dist/models/redirector/index.js.map +1 -0
- package/dist/models/redirector/redirector.d.ts +12 -0
- package/dist/models/redirector/redirector.js +23 -0
- package/dist/models/redirector/redirector.js.map +1 -0
- package/dist/models/session/index.d.ts +1 -0
- package/dist/models/session/index.js +2 -0
- package/dist/models/session/index.js.map +1 -0
- package/dist/models/session/session.d.ts +13 -0
- package/dist/models/session/session.js +27 -0
- package/dist/models/session/session.js.map +1 -0
- package/dist/models/target/index.d.ts +1 -0
- package/dist/models/target/index.js +2 -0
- package/dist/models/target/index.js.map +1 -0
- package/dist/models/target/target.d.ts +51 -0
- package/dist/models/target/target.js +110 -0
- package/dist/models/target/target.js.map +1 -0
- package/dist/redis-database-connector.d.ts +15 -0
- package/dist/redis-database-connector.js +47 -0
- package/dist/redis-database-connector.js.map +1 -0
- package/dist/redis-database-manager.d.ts +11 -0
- package/dist/redis-database-manager.js +27 -0
- package/dist/redis-database-manager.js.map +1 -0
- package/dist/redis-functions.d.ts +1 -0
- package/dist/redis-functions.js +1396 -0
- package/dist/redis-functions.js.map +1 -0
- package/dist/repositories/base/index.d.ts +1 -0
- package/dist/repositories/base/index.js +2 -0
- package/dist/repositories/base/index.js.map +1 -0
- package/dist/repositories/base/redis-base.repository.d.ts +23 -0
- package/dist/repositories/base/redis-base.repository.js +140 -0
- package/dist/repositories/base/redis-base.repository.js.map +1 -0
- package/dist/repositories/campaign/campaign.d.ts +13 -0
- package/dist/repositories/campaign/campaign.functions.d.ts +66 -0
- package/dist/repositories/campaign/campaign.functions.js +111 -0
- package/dist/repositories/campaign/campaign.functions.js.map +1 -0
- package/dist/repositories/campaign/campaign.js +2 -0
- package/dist/repositories/campaign/campaign.js.map +1 -0
- package/dist/repositories/campaign/campaign.schemas.d.ts +9 -0
- package/dist/repositories/campaign/campaign.schemas.js +148 -0
- package/dist/repositories/campaign/campaign.schemas.js.map +1 -0
- package/dist/repositories/campaign/index.d.ts +3 -0
- package/dist/repositories/campaign/index.js +4 -0
- package/dist/repositories/campaign/index.js.map +1 -0
- package/dist/repositories/campaign/redis-campaign.repository.d.ts +25 -0
- package/dist/repositories/campaign/redis-campaign.repository.js +138 -0
- package/dist/repositories/campaign/redis-campaign.repository.js.map +1 -0
- package/dist/repositories/index.d.ts +8 -0
- package/dist/repositories/index.js +9 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/lure/index.d.ts +3 -0
- package/dist/repositories/lure/index.js +4 -0
- package/dist/repositories/lure/index.js.map +1 -0
- package/dist/repositories/lure/lure.d.ts +11 -0
- package/dist/repositories/lure/lure.functions.d.ts +49 -0
- package/dist/repositories/lure/lure.functions.js +82 -0
- package/dist/repositories/lure/lure.functions.js.map +1 -0
- package/dist/repositories/lure/lure.js +2 -0
- package/dist/repositories/lure/lure.js.map +1 -0
- package/dist/repositories/lure/lure.schemas.d.ts +3 -0
- package/dist/repositories/lure/lure.schemas.js +45 -0
- package/dist/repositories/lure/lure.schemas.js.map +1 -0
- package/dist/repositories/lure/redis-lure.repository.d.ts +21 -0
- package/dist/repositories/lure/redis-lure.repository.js +107 -0
- package/dist/repositories/lure/redis-lure.repository.js.map +1 -0
- package/dist/repositories/message/index.d.ts +3 -0
- package/dist/repositories/message/index.js +4 -0
- package/dist/repositories/message/index.js.map +1 -0
- package/dist/repositories/message/message.d.ts +6 -0
- package/dist/repositories/message/message.functions.d.ts +44 -0
- package/dist/repositories/message/message.functions.js +53 -0
- package/dist/repositories/message/message.functions.js.map +1 -0
- package/dist/repositories/message/message.js +2 -0
- package/dist/repositories/message/message.js.map +1 -0
- package/dist/repositories/message/message.schemas.d.ts +2 -0
- package/dist/repositories/message/message.schemas.js +206 -0
- package/dist/repositories/message/message.schemas.js.map +1 -0
- package/dist/repositories/message/redis-message.repository.d.ts +20 -0
- package/dist/repositories/message/redis-message.repository.js +72 -0
- package/dist/repositories/message/redis-message.repository.js.map +1 -0
- package/dist/repositories/proxy/index.d.ts +3 -0
- package/dist/repositories/proxy/index.js +4 -0
- package/dist/repositories/proxy/index.js.map +1 -0
- package/dist/repositories/proxy/proxy.d.ts +10 -0
- package/dist/repositories/proxy/proxy.functions.d.ts +43 -0
- package/dist/repositories/proxy/proxy.functions.js +72 -0
- package/dist/repositories/proxy/proxy.functions.js.map +1 -0
- package/dist/repositories/proxy/proxy.js +2 -0
- package/dist/repositories/proxy/proxy.js.map +1 -0
- package/dist/repositories/proxy/proxy.schemas.d.ts +3 -0
- package/dist/repositories/proxy/proxy.schemas.js +34 -0
- package/dist/repositories/proxy/proxy.schemas.js.map +1 -0
- package/dist/repositories/proxy/redis-proxy.repository.d.ts +20 -0
- package/dist/repositories/proxy/redis-proxy.repository.js +93 -0
- package/dist/repositories/proxy/redis-proxy.repository.js.map +1 -0
- package/dist/repositories/redirector/index.d.ts +3 -0
- package/dist/repositories/redirector/index.js +4 -0
- package/dist/repositories/redirector/index.js.map +1 -0
- package/dist/repositories/redirector/redirector.d.ts +11 -0
- package/dist/repositories/redirector/redirector.functions.d.ts +44 -0
- package/dist/repositories/redirector/redirector.functions.js +70 -0
- package/dist/repositories/redirector/redirector.functions.js.map +1 -0
- package/dist/repositories/redirector/redirector.js +2 -0
- package/dist/repositories/redirector/redirector.js.map +1 -0
- package/dist/repositories/redirector/redirector.schemas.d.ts +3 -0
- package/dist/repositories/redirector/redirector.schemas.js +51 -0
- package/dist/repositories/redirector/redirector.schemas.js.map +1 -0
- package/dist/repositories/redirector/redis-redirector.repository.d.ts +23 -0
- package/dist/repositories/redirector/redis-redirector.repository.js +121 -0
- package/dist/repositories/redirector/redis-redirector.repository.js.map +1 -0
- package/dist/repositories/session/index.d.ts +3 -0
- package/dist/repositories/session/index.js +4 -0
- package/dist/repositories/session/index.js.map +1 -0
- package/dist/repositories/session/redis-session.repository.d.ts +18 -0
- package/dist/repositories/session/redis-session.repository.js +85 -0
- package/dist/repositories/session/redis-session.repository.js.map +1 -0
- package/dist/repositories/session/session.d.ts +8 -0
- package/dist/repositories/session/session.functions.d.ts +35 -0
- package/dist/repositories/session/session.functions.js +47 -0
- package/dist/repositories/session/session.functions.js.map +1 -0
- package/dist/repositories/session/session.js +2 -0
- package/dist/repositories/session/session.js.map +1 -0
- package/dist/repositories/session/session.schemas.d.ts +2 -0
- package/dist/repositories/session/session.schemas.js +44 -0
- package/dist/repositories/session/session.schemas.js.map +1 -0
- package/dist/repositories/target/index.d.ts +3 -0
- package/dist/repositories/target/index.js +4 -0
- package/dist/repositories/target/index.js.map +1 -0
- package/dist/repositories/target/redis-target.repository.d.ts +30 -0
- package/dist/repositories/target/redis-target.repository.js +198 -0
- package/dist/repositories/target/redis-target.repository.js.map +1 -0
- package/dist/repositories/target/target.d.ts +17 -0
- package/dist/repositories/target/target.functions.d.ts +89 -0
- package/dist/repositories/target/target.functions.js +184 -0
- package/dist/repositories/target/target.functions.js.map +1 -0
- package/dist/repositories/target/target.js +2 -0
- package/dist/repositories/target/target.js.map +1 -0
- package/dist/repositories/target/target.schemas.d.ts +13 -0
- package/dist/repositories/target/target.schemas.js +241 -0
- package/dist/repositories/target/target.schemas.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-functions.js","sourceRoot":"","sources":["../src/redis-functions.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAa;IAChC,gBAAgB;IAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiOmB;IAEnB,aAAa;IACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEA2HmE;IAEnE,eAAe;IACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yDA6GuD;CACxD,CAAA;AAED,MAAM,UAAU,kBAAkB;IAChC,MAAM,OAAO,GAAuB,EAAE,CAAA;IAEtC,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,eAAe,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;QACjC,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;QAErC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAA;YACnD,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './redis-base.repository.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/base/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Config } from '@famir/config';
|
|
2
|
+
import { Logger } from '@famir/logger';
|
|
3
|
+
import { Validator } from '@famir/validator';
|
|
4
|
+
import { RedisDatabaseConfig, RedisDatabaseConnection, RedisDatabaseRepositoryOptions } from '../../database.js';
|
|
5
|
+
export declare abstract class RedisBaseRepository {
|
|
6
|
+
protected readonly validator: Validator;
|
|
7
|
+
protected readonly logger: Logger;
|
|
8
|
+
protected readonly connection: RedisDatabaseConnection;
|
|
9
|
+
protected readonly repositoryName: string;
|
|
10
|
+
protected readonly options: RedisDatabaseRepositoryOptions;
|
|
11
|
+
constructor(validator: Validator, config: Config<RedisDatabaseConfig>, logger: Logger, connection: RedisDatabaseConnection, repositoryName: string);
|
|
12
|
+
protected validateStringReply(value: unknown): asserts value is string;
|
|
13
|
+
protected validateArrayReply(value: unknown): asserts value is unknown[];
|
|
14
|
+
protected validateArrayStringsReply(value: unknown): asserts value is string[];
|
|
15
|
+
protected handleStatusReply(value: unknown): string;
|
|
16
|
+
protected validateRawData<T>(schema: string, value: unknown): asserts value is T;
|
|
17
|
+
protected decodeJson(value: string): unknown;
|
|
18
|
+
protected encodeJson(value: object): string;
|
|
19
|
+
protected decodeBase64(value: string): Buffer;
|
|
20
|
+
protected encodeBase64(value: Buffer): string;
|
|
21
|
+
protected raiseError(error: unknown, method: string, data: unknown): never;
|
|
22
|
+
private buildOptions;
|
|
23
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { arrayIncludes } from '@famir/common';
|
|
2
|
+
import { DatabaseError } from '../../database.error.js';
|
|
3
|
+
import { DATABASE_STATUS_CODES } from '../../database.js';
|
|
4
|
+
export class RedisBaseRepository {
|
|
5
|
+
validator;
|
|
6
|
+
logger;
|
|
7
|
+
connection;
|
|
8
|
+
repositoryName;
|
|
9
|
+
options;
|
|
10
|
+
constructor(validator, config, logger, connection, repositoryName) {
|
|
11
|
+
this.validator = validator;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
this.connection = connection;
|
|
14
|
+
this.repositoryName = repositoryName;
|
|
15
|
+
this.options = this.buildOptions(config.data);
|
|
16
|
+
}
|
|
17
|
+
validateStringReply(value) {
|
|
18
|
+
if (!(value != null && typeof value === 'string' && value)) {
|
|
19
|
+
throw new DatabaseError(`StringReply validate failed`, {
|
|
20
|
+
code: 'INTERNAL_ERROR'
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
validateArrayReply(value) {
|
|
25
|
+
if (!(value != null && Array.isArray(value))) {
|
|
26
|
+
throw new DatabaseError(`ArrayReply validate failed`, {
|
|
27
|
+
code: 'INTERNAL_ERROR'
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
validateArrayStringsReply(value) {
|
|
32
|
+
const isValid = value != null &&
|
|
33
|
+
Array.isArray(value) &&
|
|
34
|
+
value.every((item) => item != null && typeof item === 'string' && item);
|
|
35
|
+
if (!isValid) {
|
|
36
|
+
throw new DatabaseError(`ArrayStringsReply validate failed`, {
|
|
37
|
+
code: 'INTERNAL_ERROR'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
handleStatusReply(value) {
|
|
42
|
+
if (!(value != null && typeof value === 'string' && value)) {
|
|
43
|
+
throw new DatabaseError(`StatusReply validate failed`, {
|
|
44
|
+
code: 'INTERNAL_ERROR'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const [code, message] = value.split(/\s+(.*)/, 2);
|
|
48
|
+
if (!(code && message && arrayIncludes(DATABASE_STATUS_CODES, code))) {
|
|
49
|
+
throw new DatabaseError(`StatusReply parse failed`, {
|
|
50
|
+
code: 'INTERNAL_ERROR'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (code !== 'OK') {
|
|
54
|
+
throw new DatabaseError(message, {
|
|
55
|
+
code
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return message;
|
|
59
|
+
}
|
|
60
|
+
validateRawData(schema, value) {
|
|
61
|
+
try {
|
|
62
|
+
this.validator.assertSchema(schema, value);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new DatabaseError(`RawData validate failed`, {
|
|
66
|
+
cause: error,
|
|
67
|
+
code: 'INTERNAL_ERROR'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
decodeJson(value) {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(value);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw new DatabaseError(`JSON decode failed`, {
|
|
77
|
+
cause: error,
|
|
78
|
+
code: 'INTERNAL_ERROR'
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
encodeJson(value) {
|
|
83
|
+
try {
|
|
84
|
+
return JSON.stringify(value);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new DatabaseError(`JSON encode failed`, {
|
|
88
|
+
cause: error,
|
|
89
|
+
code: 'INTERNAL_ERROR'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
decodeBase64(value) {
|
|
94
|
+
try {
|
|
95
|
+
return Buffer.from(value, 'base64');
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw new DatabaseError(`Base64 decode failed`, {
|
|
99
|
+
cause: error,
|
|
100
|
+
code: 'INTERNAL_ERROR'
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
encodeBase64(value) {
|
|
105
|
+
try {
|
|
106
|
+
return value.toString('base64');
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw new DatabaseError(`Base64 encode failed`, {
|
|
110
|
+
cause: error,
|
|
111
|
+
code: 'INTERNAL_ERROR'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
raiseError(error, method, data) {
|
|
116
|
+
if (error instanceof DatabaseError) {
|
|
117
|
+
error.context['repository'] = this.repositoryName;
|
|
118
|
+
error.context['method'] = method;
|
|
119
|
+
error.context['data'] = data;
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new DatabaseError(`Service internal error`, {
|
|
124
|
+
cause: error,
|
|
125
|
+
context: {
|
|
126
|
+
repository: this.repositoryName,
|
|
127
|
+
method,
|
|
128
|
+
data
|
|
129
|
+
},
|
|
130
|
+
code: 'INTERNAL_ERROR'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
buildOptions(config) {
|
|
135
|
+
return {
|
|
136
|
+
prefix: config.DATABASE_PREFIX
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=redis-base.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-base.repository.js","sourceRoot":"","sources":["../../../src/repositories/base/redis-base.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAI7C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EACL,qBAAqB,EAItB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,OAAgB,mBAAmB;IAIlB;IAEA;IACA;IACA;IAPF,OAAO,CAAgC;IAE1D,YACqB,SAAoB,EACvC,MAAmC,EAChB,MAAc,EACd,UAAmC,EACnC,cAAsB;QAJtB,cAAS,GAAT,SAAS,CAAW;QAEpB,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAyB;QACnC,mBAAc,GAAd,cAAc,CAAQ;QAEzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IAES,mBAAmB,CAAC,KAAc;QAC1C,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC;YAC3D,MAAM,IAAI,aAAa,CAAC,6BAA6B,EAAE;gBACrD,IAAI,EAAE,gBAAgB;aACvB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAES,kBAAkB,CAAC,KAAc;QACzC,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CA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AAQ,CAAC,CAAA;QACjC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,aAAa,CAAC,sBAAsB,EAAE;gBAC9C,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,gBAAgB;aACvB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAES,UAAU,CAAC,KAAc,EAAE,MAAc,EAAE,IAAa;QAChE,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;YACnC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,cAAc,CAAA;YACjD,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAA;YAChC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;YAE5B,MAAM,KAAK,CAAA;QACb,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,aAAa,CAAC,wBAAwB,EAAE;gBAChD,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE;oBACP,UAAU,EAAE,IAAI,CAAC,cAAc;oBAC/B,MAAM;oBACN,IAAI;iBACL;gBACD,IAAI,EAAE,gBAAgB;aACvB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,MAA2B;QAC9C,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,eAAe;SAC/B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CampaignModel, FullCampaignModel } from '../../models/index.js';
|
|
2
|
+
export declare const CAMPAIGN_REPOSITORY: unique symbol;
|
|
3
|
+
export interface CampaignRepository {
|
|
4
|
+
create(campaignId: string, mirrorDomain: string, description: string, cryptSecret: string, landingUpgradePath: string, sessionCookieName: string, sessionExpire: number, newSessionExpire: number, messageExpire: number): Promise<void>;
|
|
5
|
+
read(campaignId: string): Promise<CampaignModel | null>;
|
|
6
|
+
readFull(campaignId: string): Promise<FullCampaignModel | null>;
|
|
7
|
+
lock(campaignId: string): Promise<string>;
|
|
8
|
+
unlock(campaignId: string, lockSecret: string): Promise<void>;
|
|
9
|
+
update(campaignId: string, description: string | null | undefined, sessionExpire: number | null | undefined, newSessionExpire: number | null | undefined, messageExpire: number | null | undefined, lockSecret: string): Promise<void>;
|
|
10
|
+
delete(campaignId: string, lockSecret: string): Promise<void>;
|
|
11
|
+
list(): Promise<CampaignModel[]>;
|
|
12
|
+
listFull(): Promise<CampaignModel[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CommandParser } from '@redis/client';
|
|
2
|
+
export interface RawCampaign {
|
|
3
|
+
campaign_id: string;
|
|
4
|
+
mirror_domain: string;
|
|
5
|
+
is_locked: number;
|
|
6
|
+
session_count: number;
|
|
7
|
+
message_count: number;
|
|
8
|
+
created_at: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RawFullCampaign extends RawCampaign {
|
|
11
|
+
description: string;
|
|
12
|
+
crypt_secret: string;
|
|
13
|
+
landing_upgrade_path: string;
|
|
14
|
+
session_cookie_name: string;
|
|
15
|
+
session_expire: number;
|
|
16
|
+
new_session_expire: number;
|
|
17
|
+
message_expire: number;
|
|
18
|
+
proxy_count: number;
|
|
19
|
+
target_count: number;
|
|
20
|
+
redirector_count: number;
|
|
21
|
+
lure_count: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const campaignFunctions: {
|
|
24
|
+
readonly campaign: {
|
|
25
|
+
readonly create_campaign: {
|
|
26
|
+
readonly NUMBER_OF_KEYS: 3;
|
|
27
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, mirrorDomain: string, description: string, cryptSecret: string, landingUpgradePath: string, sessionCookieName: string, sessionExpire: number, newSessionExpire: number, messageExpire: number) => void;
|
|
28
|
+
readonly transformReply: () => unknown;
|
|
29
|
+
};
|
|
30
|
+
readonly read_campaign: {
|
|
31
|
+
readonly NUMBER_OF_KEYS: 2;
|
|
32
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string) => void;
|
|
33
|
+
readonly transformReply: () => unknown;
|
|
34
|
+
};
|
|
35
|
+
readonly read_full_campaign: {
|
|
36
|
+
readonly NUMBER_OF_KEYS: 6;
|
|
37
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string) => void;
|
|
38
|
+
readonly transformReply: () => unknown;
|
|
39
|
+
};
|
|
40
|
+
readonly read_campaign_index: {
|
|
41
|
+
readonly NUMBER_OF_KEYS: 1;
|
|
42
|
+
readonly parseCommand: (parser: CommandParser, prefix: string) => void;
|
|
43
|
+
readonly transformReply: () => unknown;
|
|
44
|
+
};
|
|
45
|
+
readonly lock_campaign: {
|
|
46
|
+
readonly NUMBER_OF_KEYS: 2;
|
|
47
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lockSecret: string, lockTimeout: number) => void;
|
|
48
|
+
readonly transformReply: () => unknown;
|
|
49
|
+
};
|
|
50
|
+
readonly unlock_campaign: {
|
|
51
|
+
readonly NUMBER_OF_KEYS: 2;
|
|
52
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lockSecret: string) => void;
|
|
53
|
+
readonly transformReply: () => unknown;
|
|
54
|
+
};
|
|
55
|
+
readonly update_campaign: {
|
|
56
|
+
readonly NUMBER_OF_KEYS: 2;
|
|
57
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, description: string | null | undefined, sessionExpire: number | null | undefined, newSessionExpire: number | null | undefined, messageExpire: number | null | undefined, lockSecret: string) => void;
|
|
58
|
+
readonly transformReply: () => unknown;
|
|
59
|
+
};
|
|
60
|
+
readonly delete_campaign: {
|
|
61
|
+
readonly NUMBER_OF_KEYS: 8;
|
|
62
|
+
readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lockSecret: string) => void;
|
|
63
|
+
readonly transformReply: () => unknown;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { campaignIndexKey, campaignKey, campaignLockKey, campaignUniqueMirrorDomainKey, lureIndexKey, proxyIndexKey, redirectorIndexKey, targetIndexKey } from '../../database.keys.js';
|
|
2
|
+
export const campaignFunctions = {
|
|
3
|
+
campaign: {
|
|
4
|
+
create_campaign: {
|
|
5
|
+
NUMBER_OF_KEYS: 3,
|
|
6
|
+
parseCommand(parser, prefix, campaignId, mirrorDomain, description, cryptSecret, landingUpgradePath, sessionCookieName, sessionExpire, newSessionExpire, messageExpire) {
|
|
7
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
8
|
+
parser.pushKey(campaignUniqueMirrorDomainKey(prefix));
|
|
9
|
+
parser.pushKey(campaignIndexKey(prefix));
|
|
10
|
+
parser.push(campaignId);
|
|
11
|
+
parser.push(mirrorDomain);
|
|
12
|
+
parser.push(description);
|
|
13
|
+
parser.push(cryptSecret);
|
|
14
|
+
parser.push(landingUpgradePath);
|
|
15
|
+
parser.push(sessionCookieName);
|
|
16
|
+
parser.push(sessionExpire.toString());
|
|
17
|
+
parser.push(newSessionExpire.toString());
|
|
18
|
+
parser.push(messageExpire.toString());
|
|
19
|
+
parser.push(Date.now().toString());
|
|
20
|
+
},
|
|
21
|
+
transformReply: undefined
|
|
22
|
+
},
|
|
23
|
+
read_campaign: {
|
|
24
|
+
NUMBER_OF_KEYS: 2,
|
|
25
|
+
parseCommand(parser, prefix, campaignId) {
|
|
26
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
27
|
+
parser.pushKey(campaignLockKey(prefix, campaignId));
|
|
28
|
+
},
|
|
29
|
+
transformReply: undefined
|
|
30
|
+
},
|
|
31
|
+
read_full_campaign: {
|
|
32
|
+
NUMBER_OF_KEYS: 6,
|
|
33
|
+
parseCommand(parser, prefix, campaignId) {
|
|
34
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
35
|
+
parser.pushKey(campaignLockKey(prefix, campaignId));
|
|
36
|
+
parser.pushKey(proxyIndexKey(prefix, campaignId));
|
|
37
|
+
parser.pushKey(targetIndexKey(prefix, campaignId));
|
|
38
|
+
parser.pushKey(redirectorIndexKey(prefix, campaignId));
|
|
39
|
+
parser.pushKey(lureIndexKey(prefix, campaignId));
|
|
40
|
+
},
|
|
41
|
+
transformReply: undefined
|
|
42
|
+
},
|
|
43
|
+
read_campaign_index: {
|
|
44
|
+
NUMBER_OF_KEYS: 1,
|
|
45
|
+
parseCommand(parser, prefix) {
|
|
46
|
+
parser.pushKey(campaignIndexKey(prefix));
|
|
47
|
+
},
|
|
48
|
+
transformReply: undefined
|
|
49
|
+
},
|
|
50
|
+
lock_campaign: {
|
|
51
|
+
NUMBER_OF_KEYS: 2,
|
|
52
|
+
parseCommand(parser, prefix, campaignId, lockSecret, lockTimeout) {
|
|
53
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
54
|
+
parser.pushKey(campaignLockKey(prefix, campaignId));
|
|
55
|
+
parser.push(lockSecret);
|
|
56
|
+
parser.push(lockTimeout.toString());
|
|
57
|
+
},
|
|
58
|
+
transformReply: undefined
|
|
59
|
+
},
|
|
60
|
+
unlock_campaign: {
|
|
61
|
+
NUMBER_OF_KEYS: 2,
|
|
62
|
+
parseCommand(parser, prefix, campaignId, lockSecret) {
|
|
63
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
64
|
+
parser.pushKey(campaignLockKey(prefix, campaignId));
|
|
65
|
+
parser.push(lockSecret);
|
|
66
|
+
},
|
|
67
|
+
transformReply: undefined
|
|
68
|
+
},
|
|
69
|
+
update_campaign: {
|
|
70
|
+
NUMBER_OF_KEYS: 2,
|
|
71
|
+
parseCommand(parser, prefix, campaignId, description, sessionExpire, newSessionExpire, messageExpire, lockSecret) {
|
|
72
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
73
|
+
parser.pushKey(campaignLockKey(prefix, campaignId));
|
|
74
|
+
if (description != null) {
|
|
75
|
+
parser.push('description');
|
|
76
|
+
parser.push(description);
|
|
77
|
+
}
|
|
78
|
+
if (sessionExpire != null) {
|
|
79
|
+
parser.push('session_expire');
|
|
80
|
+
parser.push(sessionExpire.toString());
|
|
81
|
+
}
|
|
82
|
+
if (newSessionExpire != null) {
|
|
83
|
+
parser.push('new_session_expire');
|
|
84
|
+
parser.push(newSessionExpire.toString());
|
|
85
|
+
}
|
|
86
|
+
if (messageExpire != null) {
|
|
87
|
+
parser.push('message_expire');
|
|
88
|
+
parser.push(messageExpire.toString());
|
|
89
|
+
}
|
|
90
|
+
parser.push(lockSecret);
|
|
91
|
+
},
|
|
92
|
+
transformReply: undefined
|
|
93
|
+
},
|
|
94
|
+
delete_campaign: {
|
|
95
|
+
NUMBER_OF_KEYS: 8,
|
|
96
|
+
parseCommand(parser, prefix, campaignId, lockSecret) {
|
|
97
|
+
parser.pushKey(campaignKey(prefix, campaignId));
|
|
98
|
+
parser.pushKey(campaignLockKey(prefix, campaignId));
|
|
99
|
+
parser.pushKey(campaignUniqueMirrorDomainKey(prefix));
|
|
100
|
+
parser.pushKey(campaignIndexKey(prefix));
|
|
101
|
+
parser.pushKey(proxyIndexKey(prefix, campaignId));
|
|
102
|
+
parser.pushKey(targetIndexKey(prefix, campaignId));
|
|
103
|
+
parser.pushKey(redirectorIndexKey(prefix, campaignId));
|
|
104
|
+
parser.pushKey(lureIndexKey(prefix, campaignId));
|
|
105
|
+
parser.push(lockSecret);
|
|
106
|
+
},
|
|
107
|
+
transformReply: undefined
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=campaign.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign.functions.js","sourceRoot":"","sources":["../../../src/repositories/campaign/campaign.functions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,6BAA6B,EAC7B,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAyB/B,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,QAAQ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@
|
|
|
1
|
+
{"version":3,"file":"campaign.js","sourceRoot":"","sources":["../../../src/repositories/campaign/campaign.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { JSONSchemaType, ValidatorSchemas } from '@famir/validator';
|
|
2
|
+
export declare const campaignSchemas: ValidatorSchemas;
|
|
3
|
+
export declare const campaignMirrorDomainSchema: JSONSchemaType<string>;
|
|
4
|
+
export declare const campaignDescriptionSchema: JSONSchemaType<string>;
|
|
5
|
+
export declare const campaignLandingUpgradePathSchema: JSONSchemaType<string>;
|
|
6
|
+
export declare const campaignSessionCookieNameSchema: JSONSchemaType<string>;
|
|
7
|
+
export declare const campaignSessionExpireSchema: JSONSchemaType<number>;
|
|
8
|
+
export declare const campaignNewSessionExpireSchema: JSONSchemaType<number>;
|
|
9
|
+
export declare const campaignMessageExpireSchema: JSONSchemaType<number>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const rawCampaignSchema = {
|
|
2
|
+
type: 'object',
|
|
3
|
+
required: [
|
|
4
|
+
'campaign_id',
|
|
5
|
+
'mirror_domain',
|
|
6
|
+
'is_locked',
|
|
7
|
+
'session_count',
|
|
8
|
+
'message_count',
|
|
9
|
+
'created_at'
|
|
10
|
+
],
|
|
11
|
+
properties: {
|
|
12
|
+
campaign_id: {
|
|
13
|
+
type: 'string'
|
|
14
|
+
},
|
|
15
|
+
mirror_domain: {
|
|
16
|
+
type: 'string'
|
|
17
|
+
},
|
|
18
|
+
is_locked: {
|
|
19
|
+
type: 'integer'
|
|
20
|
+
},
|
|
21
|
+
session_count: {
|
|
22
|
+
type: 'integer'
|
|
23
|
+
},
|
|
24
|
+
message_count: {
|
|
25
|
+
type: 'integer'
|
|
26
|
+
},
|
|
27
|
+
created_at: {
|
|
28
|
+
type: 'integer'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
additionalProperties: false
|
|
32
|
+
};
|
|
33
|
+
const rawFullCampaignSchema = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
required: [
|
|
36
|
+
'campaign_id',
|
|
37
|
+
'mirror_domain',
|
|
38
|
+
'description',
|
|
39
|
+
'crypt_secret',
|
|
40
|
+
'landing_upgrade_path',
|
|
41
|
+
'session_cookie_name',
|
|
42
|
+
'session_expire',
|
|
43
|
+
'new_session_expire',
|
|
44
|
+
'message_expire',
|
|
45
|
+
'is_locked',
|
|
46
|
+
'proxy_count',
|
|
47
|
+
'target_count',
|
|
48
|
+
'redirector_count',
|
|
49
|
+
'lure_count',
|
|
50
|
+
'session_count',
|
|
51
|
+
'message_count',
|
|
52
|
+
'created_at'
|
|
53
|
+
],
|
|
54
|
+
properties: {
|
|
55
|
+
campaign_id: {
|
|
56
|
+
type: 'string'
|
|
57
|
+
},
|
|
58
|
+
mirror_domain: {
|
|
59
|
+
type: 'string'
|
|
60
|
+
},
|
|
61
|
+
description: {
|
|
62
|
+
type: 'string'
|
|
63
|
+
},
|
|
64
|
+
crypt_secret: {
|
|
65
|
+
type: 'string'
|
|
66
|
+
},
|
|
67
|
+
landing_upgrade_path: {
|
|
68
|
+
type: 'string'
|
|
69
|
+
},
|
|
70
|
+
session_cookie_name: {
|
|
71
|
+
type: 'string'
|
|
72
|
+
},
|
|
73
|
+
session_expire: {
|
|
74
|
+
type: 'integer'
|
|
75
|
+
},
|
|
76
|
+
new_session_expire: {
|
|
77
|
+
type: 'integer'
|
|
78
|
+
},
|
|
79
|
+
message_expire: {
|
|
80
|
+
type: 'integer'
|
|
81
|
+
},
|
|
82
|
+
is_locked: {
|
|
83
|
+
type: 'integer'
|
|
84
|
+
},
|
|
85
|
+
proxy_count: {
|
|
86
|
+
type: 'integer'
|
|
87
|
+
},
|
|
88
|
+
target_count: {
|
|
89
|
+
type: 'integer'
|
|
90
|
+
},
|
|
91
|
+
redirector_count: {
|
|
92
|
+
type: 'integer'
|
|
93
|
+
},
|
|
94
|
+
lure_count: {
|
|
95
|
+
type: 'integer'
|
|
96
|
+
},
|
|
97
|
+
session_count: {
|
|
98
|
+
type: 'integer'
|
|
99
|
+
},
|
|
100
|
+
message_count: {
|
|
101
|
+
type: 'integer'
|
|
102
|
+
},
|
|
103
|
+
created_at: {
|
|
104
|
+
type: 'integer'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
additionalProperties: false
|
|
108
|
+
};
|
|
109
|
+
export const campaignSchemas = {
|
|
110
|
+
'database-raw-campaign': rawCampaignSchema,
|
|
111
|
+
'database-raw-full-campaign': rawFullCampaignSchema
|
|
112
|
+
};
|
|
113
|
+
export const campaignMirrorDomainSchema = {
|
|
114
|
+
type: 'string',
|
|
115
|
+
minLength: 1,
|
|
116
|
+
maxLength: 256
|
|
117
|
+
};
|
|
118
|
+
export const campaignDescriptionSchema = {
|
|
119
|
+
type: 'string',
|
|
120
|
+
minLength: 0,
|
|
121
|
+
maxLength: 1024
|
|
122
|
+
};
|
|
123
|
+
export const campaignLandingUpgradePathSchema = {
|
|
124
|
+
type: 'string',
|
|
125
|
+
minLength: 3,
|
|
126
|
+
maxLength: 64
|
|
127
|
+
};
|
|
128
|
+
export const campaignSessionCookieNameSchema = {
|
|
129
|
+
type: 'string',
|
|
130
|
+
minLength: 3,
|
|
131
|
+
maxLength: 64
|
|
132
|
+
};
|
|
133
|
+
export const campaignSessionExpireSchema = {
|
|
134
|
+
type: 'integer',
|
|
135
|
+
minimum: 3600 * 1000,
|
|
136
|
+
maximum: 365 * 24 * 3600 * 1000
|
|
137
|
+
};
|
|
138
|
+
export const campaignNewSessionExpireSchema = {
|
|
139
|
+
type: 'integer',
|
|
140
|
+
minimum: 1000,
|
|
141
|
+
maximum: 900 * 1000
|
|
142
|
+
};
|
|
143
|
+
export const campaignMessageExpireSchema = {
|
|
144
|
+
type: 'integer',
|
|
145
|
+
minimum: 60 * 1000,
|
|
146
|
+
maximum: 24 * 3600 * 1000
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=campaign.schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign.schemas.js","sourceRoot":"","sources":["../../../src/repositories/campaign/campaign.schemas.ts"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GAAgC;IACrD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR,aAAa;QACb,eAAe;QACf,WAAW;QACX,eAAe;QACf,eAAe;QACf,YAAY;KACb;IACD,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;SACf;QACD,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;SAChB;QACD,aAAa,EAAE;YACb,IAAI,EAAE,SAAS;SAChB;QACD,aAAa,EAAE;YACb,IAAI,EAAE,SAAS;SAChB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,SAAS;SAChB;KACF;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAA;AAEV,MAAM,qBAAqB,GAAoC;IAC7D,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR,aAAa;QACb,eAAe;QACf,aAAa;QACb,cAAc;QACd,sBAAsB;QACtB,qBAAqB;QACrB,gBAAgB;QAChB,oBAAoB;QACpB,gBAAgB;QAChB,WAAW;QACX,aAAa;QACb,cAAc;QACd,kBAAkB;QAClB,YAAY;QACZ,eAAe;QACf,eAAe;QACf,YAAY;KACb;IACD,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;SACf;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;SACf;QACD,oBAAoB,EAAE;YACpB,IAAI,EAAE,QAAQ;SACf;QACD,mBAAmB,EAAE;YACnB,IAAI,EAAE,QAAQ;SACf;QACD,cAAc,EAAE;YACd,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;IACpB,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI;CACvB,CAAA;AAEV,MAAM,CAAC,MAAM,8BAA8B,GAA2B;IACpE,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,GAAG,GAAG,IAAI;CACX,CAAA;AAEV,MAAM,CAAC,MAAM,2BAA2B,GAA2B;IACjE,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,EAAE,GAAG,IAAI;IAClB,OAAO,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/campaign/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DIContainer } from '@famir/common';
|
|
2
|
+
import { Config } from '@famir/config';
|
|
3
|
+
import { Logger } from '@famir/logger';
|
|
4
|
+
import { Validator } from '@famir/validator';
|
|
5
|
+
import { RedisDatabaseConfig, RedisDatabaseConnection } from '../../database.js';
|
|
6
|
+
import { CampaignModel, FullCampaignModel } from '../../models/index.js';
|
|
7
|
+
import { RedisBaseRepository } from '../base/index.js';
|
|
8
|
+
import { CampaignRepository } from './campaign.js';
|
|
9
|
+
export declare class RedisCampaignRepository extends RedisBaseRepository implements CampaignRepository {
|
|
10
|
+
static inject(container: DIContainer): void;
|
|
11
|
+
constructor(validator: Validator, config: Config<RedisDatabaseConfig>, logger: Logger, connection: RedisDatabaseConnection);
|
|
12
|
+
create(campaignId: string, mirrorDomain: string, description: string, cryptSecret: string, landingUpgradePath: string, sessionCookieName: string, sessionExpire: number, newSessionExpire: number, messageExpire: number): Promise<void>;
|
|
13
|
+
read(campaignId: string): Promise<CampaignModel | null>;
|
|
14
|
+
readFull(campaignId: string): Promise<FullCampaignModel | null>;
|
|
15
|
+
lock(campaignId: string): Promise<string>;
|
|
16
|
+
unlock(campaignId: string, lockSecret: string): Promise<void>;
|
|
17
|
+
update(campaignId: string, description: string | null | undefined, sessionExpire: number | null | undefined, newSessionExpire: number | null | undefined, messageExpire: number | null | undefined, lockSecret: string): Promise<void>;
|
|
18
|
+
delete(campaignId: string, lockSecret: string): Promise<void>;
|
|
19
|
+
list(): Promise<CampaignModel[]>;
|
|
20
|
+
listFull(): Promise<FullCampaignModel[]>;
|
|
21
|
+
protected buildModel(rawModel: unknown): CampaignModel | null;
|
|
22
|
+
protected buildFullModel(rawModel: unknown): FullCampaignModel | null;
|
|
23
|
+
protected buildCollection(rawCollection: unknown): CampaignModel[];
|
|
24
|
+
protected buildFullCollection(rawCollection: unknown): FullCampaignModel[];
|
|
25
|
+
}
|