@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.
Files changed (188) hide show
  1. package/README.md +4 -0
  2. package/dist/database.d.ts +27 -0
  3. package/dist/database.error.d.ts +9 -0
  4. package/dist/database.error.js +13 -0
  5. package/dist/database.error.js.map +1 -0
  6. package/dist/database.functions.d.ts +242 -0
  7. package/dist/database.functions.js +17 -0
  8. package/dist/database.functions.js.map +1 -0
  9. package/dist/database.js +5 -0
  10. package/dist/database.js.map +1 -0
  11. package/dist/database.keys.d.ts +21 -0
  12. package/dist/database.keys.js +67 -0
  13. package/dist/database.keys.js.map +1 -0
  14. package/dist/database.schemas.d.ts +3 -0
  15. package/dist/database.schemas.js +12 -0
  16. package/dist/database.schemas.js.map +1 -0
  17. package/dist/index.d.ts +7 -0
  18. package/dist/index.js +8 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/models/campaign/campaign.d.ts +24 -0
  21. package/dist/models/campaign/campaign.js +47 -0
  22. package/dist/models/campaign/campaign.js.map +1 -0
  23. package/dist/models/campaign/index.d.ts +1 -0
  24. package/dist/models/campaign/index.js +2 -0
  25. package/dist/models/campaign/index.js.map +1 -0
  26. package/dist/models/index.d.ts +7 -0
  27. package/dist/models/index.js +8 -0
  28. package/dist/models/index.js.map +1 -0
  29. package/dist/models/lure/index.d.ts +1 -0
  30. package/dist/models/lure/index.js +2 -0
  31. package/dist/models/lure/index.js.map +1 -0
  32. package/dist/models/lure/lure.d.ts +17 -0
  33. package/dist/models/lure/lure.js +25 -0
  34. package/dist/models/lure/lure.js.map +1 -0
  35. package/dist/models/message/index.d.ts +1 -0
  36. package/dist/models/message/index.js +2 -0
  37. package/dist/models/message/index.js.map +1 -0
  38. package/dist/models/message/message.d.ts +38 -0
  39. package/dist/models/message/message.js +58 -0
  40. package/dist/models/message/message.js.map +1 -0
  41. package/dist/models/proxy/index.d.ts +1 -0
  42. package/dist/models/proxy/index.js +2 -0
  43. package/dist/models/proxy/index.js.map +1 -0
  44. package/dist/models/proxy/proxy.d.ts +16 -0
  45. package/dist/models/proxy/proxy.js +23 -0
  46. package/dist/models/proxy/proxy.js.map +1 -0
  47. package/dist/models/redirector/index.d.ts +1 -0
  48. package/dist/models/redirector/index.js +2 -0
  49. package/dist/models/redirector/index.js.map +1 -0
  50. package/dist/models/redirector/redirector.d.ts +12 -0
  51. package/dist/models/redirector/redirector.js +23 -0
  52. package/dist/models/redirector/redirector.js.map +1 -0
  53. package/dist/models/session/index.d.ts +1 -0
  54. package/dist/models/session/index.js +2 -0
  55. package/dist/models/session/index.js.map +1 -0
  56. package/dist/models/session/session.d.ts +13 -0
  57. package/dist/models/session/session.js +27 -0
  58. package/dist/models/session/session.js.map +1 -0
  59. package/dist/models/target/index.d.ts +1 -0
  60. package/dist/models/target/index.js +2 -0
  61. package/dist/models/target/index.js.map +1 -0
  62. package/dist/models/target/target.d.ts +51 -0
  63. package/dist/models/target/target.js +110 -0
  64. package/dist/models/target/target.js.map +1 -0
  65. package/dist/redis-database-connector.d.ts +15 -0
  66. package/dist/redis-database-connector.js +47 -0
  67. package/dist/redis-database-connector.js.map +1 -0
  68. package/dist/redis-database-manager.d.ts +11 -0
  69. package/dist/redis-database-manager.js +27 -0
  70. package/dist/redis-database-manager.js.map +1 -0
  71. package/dist/redis-functions.d.ts +1 -0
  72. package/dist/redis-functions.js +1396 -0
  73. package/dist/redis-functions.js.map +1 -0
  74. package/dist/repositories/base/index.d.ts +1 -0
  75. package/dist/repositories/base/index.js +2 -0
  76. package/dist/repositories/base/index.js.map +1 -0
  77. package/dist/repositories/base/redis-base.repository.d.ts +23 -0
  78. package/dist/repositories/base/redis-base.repository.js +140 -0
  79. package/dist/repositories/base/redis-base.repository.js.map +1 -0
  80. package/dist/repositories/campaign/campaign.d.ts +13 -0
  81. package/dist/repositories/campaign/campaign.functions.d.ts +66 -0
  82. package/dist/repositories/campaign/campaign.functions.js +111 -0
  83. package/dist/repositories/campaign/campaign.functions.js.map +1 -0
  84. package/dist/repositories/campaign/campaign.js +2 -0
  85. package/dist/repositories/campaign/campaign.js.map +1 -0
  86. package/dist/repositories/campaign/campaign.schemas.d.ts +9 -0
  87. package/dist/repositories/campaign/campaign.schemas.js +148 -0
  88. package/dist/repositories/campaign/campaign.schemas.js.map +1 -0
  89. package/dist/repositories/campaign/index.d.ts +3 -0
  90. package/dist/repositories/campaign/index.js +4 -0
  91. package/dist/repositories/campaign/index.js.map +1 -0
  92. package/dist/repositories/campaign/redis-campaign.repository.d.ts +25 -0
  93. package/dist/repositories/campaign/redis-campaign.repository.js +138 -0
  94. package/dist/repositories/campaign/redis-campaign.repository.js.map +1 -0
  95. package/dist/repositories/index.d.ts +8 -0
  96. package/dist/repositories/index.js +9 -0
  97. package/dist/repositories/index.js.map +1 -0
  98. package/dist/repositories/lure/index.d.ts +3 -0
  99. package/dist/repositories/lure/index.js +4 -0
  100. package/dist/repositories/lure/index.js.map +1 -0
  101. package/dist/repositories/lure/lure.d.ts +11 -0
  102. package/dist/repositories/lure/lure.functions.d.ts +49 -0
  103. package/dist/repositories/lure/lure.functions.js +82 -0
  104. package/dist/repositories/lure/lure.functions.js.map +1 -0
  105. package/dist/repositories/lure/lure.js +2 -0
  106. package/dist/repositories/lure/lure.js.map +1 -0
  107. package/dist/repositories/lure/lure.schemas.d.ts +3 -0
  108. package/dist/repositories/lure/lure.schemas.js +45 -0
  109. package/dist/repositories/lure/lure.schemas.js.map +1 -0
  110. package/dist/repositories/lure/redis-lure.repository.d.ts +21 -0
  111. package/dist/repositories/lure/redis-lure.repository.js +107 -0
  112. package/dist/repositories/lure/redis-lure.repository.js.map +1 -0
  113. package/dist/repositories/message/index.d.ts +3 -0
  114. package/dist/repositories/message/index.js +4 -0
  115. package/dist/repositories/message/index.js.map +1 -0
  116. package/dist/repositories/message/message.d.ts +6 -0
  117. package/dist/repositories/message/message.functions.d.ts +44 -0
  118. package/dist/repositories/message/message.functions.js +53 -0
  119. package/dist/repositories/message/message.functions.js.map +1 -0
  120. package/dist/repositories/message/message.js +2 -0
  121. package/dist/repositories/message/message.js.map +1 -0
  122. package/dist/repositories/message/message.schemas.d.ts +2 -0
  123. package/dist/repositories/message/message.schemas.js +206 -0
  124. package/dist/repositories/message/message.schemas.js.map +1 -0
  125. package/dist/repositories/message/redis-message.repository.d.ts +20 -0
  126. package/dist/repositories/message/redis-message.repository.js +72 -0
  127. package/dist/repositories/message/redis-message.repository.js.map +1 -0
  128. package/dist/repositories/proxy/index.d.ts +3 -0
  129. package/dist/repositories/proxy/index.js +4 -0
  130. package/dist/repositories/proxy/index.js.map +1 -0
  131. package/dist/repositories/proxy/proxy.d.ts +10 -0
  132. package/dist/repositories/proxy/proxy.functions.d.ts +43 -0
  133. package/dist/repositories/proxy/proxy.functions.js +72 -0
  134. package/dist/repositories/proxy/proxy.functions.js.map +1 -0
  135. package/dist/repositories/proxy/proxy.js +2 -0
  136. package/dist/repositories/proxy/proxy.js.map +1 -0
  137. package/dist/repositories/proxy/proxy.schemas.d.ts +3 -0
  138. package/dist/repositories/proxy/proxy.schemas.js +34 -0
  139. package/dist/repositories/proxy/proxy.schemas.js.map +1 -0
  140. package/dist/repositories/proxy/redis-proxy.repository.d.ts +20 -0
  141. package/dist/repositories/proxy/redis-proxy.repository.js +93 -0
  142. package/dist/repositories/proxy/redis-proxy.repository.js.map +1 -0
  143. package/dist/repositories/redirector/index.d.ts +3 -0
  144. package/dist/repositories/redirector/index.js +4 -0
  145. package/dist/repositories/redirector/index.js.map +1 -0
  146. package/dist/repositories/redirector/redirector.d.ts +11 -0
  147. package/dist/repositories/redirector/redirector.functions.d.ts +44 -0
  148. package/dist/repositories/redirector/redirector.functions.js +70 -0
  149. package/dist/repositories/redirector/redirector.functions.js.map +1 -0
  150. package/dist/repositories/redirector/redirector.js +2 -0
  151. package/dist/repositories/redirector/redirector.js.map +1 -0
  152. package/dist/repositories/redirector/redirector.schemas.d.ts +3 -0
  153. package/dist/repositories/redirector/redirector.schemas.js +51 -0
  154. package/dist/repositories/redirector/redirector.schemas.js.map +1 -0
  155. package/dist/repositories/redirector/redis-redirector.repository.d.ts +23 -0
  156. package/dist/repositories/redirector/redis-redirector.repository.js +121 -0
  157. package/dist/repositories/redirector/redis-redirector.repository.js.map +1 -0
  158. package/dist/repositories/session/index.d.ts +3 -0
  159. package/dist/repositories/session/index.js +4 -0
  160. package/dist/repositories/session/index.js.map +1 -0
  161. package/dist/repositories/session/redis-session.repository.d.ts +18 -0
  162. package/dist/repositories/session/redis-session.repository.js +85 -0
  163. package/dist/repositories/session/redis-session.repository.js.map +1 -0
  164. package/dist/repositories/session/session.d.ts +8 -0
  165. package/dist/repositories/session/session.functions.d.ts +35 -0
  166. package/dist/repositories/session/session.functions.js +47 -0
  167. package/dist/repositories/session/session.functions.js.map +1 -0
  168. package/dist/repositories/session/session.js +2 -0
  169. package/dist/repositories/session/session.js.map +1 -0
  170. package/dist/repositories/session/session.schemas.d.ts +2 -0
  171. package/dist/repositories/session/session.schemas.js +44 -0
  172. package/dist/repositories/session/session.schemas.js.map +1 -0
  173. package/dist/repositories/target/index.d.ts +3 -0
  174. package/dist/repositories/target/index.js +4 -0
  175. package/dist/repositories/target/index.js.map +1 -0
  176. package/dist/repositories/target/redis-target.repository.d.ts +30 -0
  177. package/dist/repositories/target/redis-target.repository.js +198 -0
  178. package/dist/repositories/target/redis-target.repository.js.map +1 -0
  179. package/dist/repositories/target/target.d.ts +17 -0
  180. package/dist/repositories/target/target.functions.d.ts +89 -0
  181. package/dist/repositories/target/target.functions.js +184 -0
  182. package/dist/repositories/target/target.functions.js.map +1 -0
  183. package/dist/repositories/target/target.js +2 -0
  184. package/dist/repositories/target/target.js.map +1 -0
  185. package/dist/repositories/target/target.schemas.d.ts +13 -0
  186. package/dist/repositories/target/target.schemas.js +241 -0
  187. package/dist/repositories/target/target.schemas.js.map +1 -0
  188. package/package.json +46 -0
@@ -0,0 +1,53 @@
1
+ import { campaignKey, messageKey, proxyKey, sessionKey, targetKey } from '../../database.keys.js';
2
+ export const messageFunctions = {
3
+ message: {
4
+ create_message: {
5
+ NUMBER_OF_KEYS: 5,
6
+ parseCommand(parser, prefix, campaignId, messageId, proxyId, targetId, sessionId, kind, method, url, requestHeaders, requestBody, status, responseHeaders, responseBody, connection, payload, errors, processor, startTime, finishTime) {
7
+ parser.pushKey(campaignKey(prefix, campaignId));
8
+ parser.pushKey(messageKey(prefix, campaignId, messageId));
9
+ parser.pushKey(proxyKey(prefix, campaignId, proxyId));
10
+ parser.pushKey(targetKey(prefix, campaignId, targetId));
11
+ parser.pushKey(sessionKey(prefix, campaignId, sessionId));
12
+ parser.push(campaignId);
13
+ parser.push(messageId);
14
+ parser.push(proxyId);
15
+ parser.push(targetId);
16
+ parser.push(sessionId);
17
+ parser.push(kind);
18
+ parser.push(method);
19
+ parser.push(url);
20
+ parser.push(requestHeaders);
21
+ parser.push(requestBody);
22
+ parser.push(status.toString());
23
+ parser.push(responseHeaders);
24
+ parser.push(responseBody);
25
+ parser.push(connection);
26
+ parser.push(payload);
27
+ parser.push(errors);
28
+ parser.push(processor);
29
+ parser.push(startTime.toString());
30
+ parser.push(finishTime.toString());
31
+ parser.push(Date.now().toString());
32
+ },
33
+ transformReply: undefined
34
+ },
35
+ read_message: {
36
+ NUMBER_OF_KEYS: 2,
37
+ parseCommand(parser, prefix, campaignId, messageId) {
38
+ parser.pushKey(campaignKey(prefix, campaignId));
39
+ parser.pushKey(messageKey(prefix, campaignId, messageId));
40
+ },
41
+ transformReply: undefined
42
+ },
43
+ read_full_message: {
44
+ NUMBER_OF_KEYS: 2,
45
+ parseCommand(parser, prefix, campaignId, messageId) {
46
+ parser.pushKey(campaignKey(prefix, campaignId));
47
+ parser.pushKey(messageKey(prefix, campaignId, messageId));
48
+ },
49
+ transformReply: undefined
50
+ }
51
+ }
52
+ };
53
+ //# sourceMappingURL=message.functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.functions.js","sourceRoot":"","sources":["../../../src/repositories/message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,EAAE,MAAc,EAAE,UAAkB,EAAE,SAAiB;gBACvF,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAC/C,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAA;YAC3D,CAAC;YAED,cAAc,EAAE,SAAqC;SACtD;KACF;CACO,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const MESSAGE_REPOSITORY = Symbol('MessageRepository');
2
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/repositories/message/message.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { ValidatorSchemas } from '@famir/validator';
2
+ export declare const messageSchemas: ValidatorSchemas;
@@ -0,0 +1,206 @@
1
+ const rawMessageSchema = {
2
+ type: 'object',
3
+ required: [
4
+ 'campaign_id',
5
+ 'message_id',
6
+ 'proxy_id',
7
+ 'target_id',
8
+ 'session_id',
9
+ 'kind',
10
+ 'method',
11
+ 'url',
12
+ 'status',
13
+ 'processor',
14
+ 'start_time',
15
+ 'finish_time',
16
+ 'created_at'
17
+ ],
18
+ properties: {
19
+ campaign_id: {
20
+ type: 'string'
21
+ },
22
+ message_id: {
23
+ type: 'string'
24
+ },
25
+ proxy_id: {
26
+ type: 'string'
27
+ },
28
+ target_id: {
29
+ type: 'string'
30
+ },
31
+ session_id: {
32
+ type: 'string'
33
+ },
34
+ kind: {
35
+ type: 'string'
36
+ },
37
+ method: {
38
+ type: 'string'
39
+ },
40
+ url: {
41
+ type: 'string'
42
+ },
43
+ status: {
44
+ type: 'integer'
45
+ },
46
+ processor: {
47
+ type: 'string'
48
+ },
49
+ start_time: {
50
+ type: 'integer'
51
+ },
52
+ finish_time: {
53
+ type: 'integer'
54
+ },
55
+ created_at: {
56
+ type: 'integer'
57
+ }
58
+ },
59
+ additionalProperties: false
60
+ };
61
+ const rawFullMessageSchema = {
62
+ type: 'object',
63
+ required: [
64
+ 'campaign_id',
65
+ 'message_id',
66
+ 'proxy_id',
67
+ 'target_id',
68
+ 'session_id',
69
+ 'kind',
70
+ 'method',
71
+ 'url',
72
+ 'request_headers',
73
+ 'request_body',
74
+ 'status',
75
+ 'response_headers',
76
+ 'response_body',
77
+ 'connection',
78
+ 'payload',
79
+ 'errors',
80
+ 'processor',
81
+ 'start_time',
82
+ 'finish_time',
83
+ 'created_at'
84
+ ],
85
+ properties: {
86
+ campaign_id: {
87
+ type: 'string'
88
+ },
89
+ message_id: {
90
+ type: 'string'
91
+ },
92
+ proxy_id: {
93
+ type: 'string'
94
+ },
95
+ target_id: {
96
+ type: 'string'
97
+ },
98
+ session_id: {
99
+ type: 'string'
100
+ },
101
+ kind: {
102
+ type: 'string'
103
+ },
104
+ method: {
105
+ type: 'string'
106
+ },
107
+ url: {
108
+ type: 'string'
109
+ },
110
+ request_headers: {
111
+ type: 'string'
112
+ },
113
+ request_body: {
114
+ type: 'string'
115
+ },
116
+ status: {
117
+ type: 'integer'
118
+ },
119
+ response_headers: {
120
+ type: 'string'
121
+ },
122
+ response_body: {
123
+ type: 'string'
124
+ },
125
+ connection: {
126
+ type: 'string'
127
+ },
128
+ payload: {
129
+ type: 'string'
130
+ },
131
+ errors: {
132
+ type: 'string'
133
+ },
134
+ processor: {
135
+ type: 'string'
136
+ },
137
+ start_time: {
138
+ type: 'integer'
139
+ },
140
+ finish_time: {
141
+ type: 'integer'
142
+ },
143
+ created_at: {
144
+ type: 'integer'
145
+ }
146
+ },
147
+ additionalProperties: false
148
+ };
149
+ const messageHeaderSchema = {
150
+ type: ['string', 'array'],
151
+ oneOf: [
152
+ {
153
+ type: 'string'
154
+ },
155
+ {
156
+ type: 'array',
157
+ items: {
158
+ type: 'string'
159
+ }
160
+ }
161
+ ]
162
+ };
163
+ const messageHeadersSchema = {
164
+ type: 'object',
165
+ required: [],
166
+ additionalProperties: {
167
+ ...messageHeaderSchema,
168
+ nullable: true
169
+ }
170
+ };
171
+ const messageConnectionSchema = {
172
+ type: 'object',
173
+ additionalProperties: {
174
+ anyOf: [{ type: 'number' }, { type: 'string' }]
175
+ }
176
+ };
177
+ const messagePayloadSchema = {
178
+ type: 'object',
179
+ additionalProperties: true
180
+ };
181
+ const messageErrorSchema = {
182
+ type: 'array',
183
+ minItems: 1,
184
+ maxItems: 10,
185
+ items: [
186
+ {
187
+ type: 'object'
188
+ }
189
+ ],
190
+ additionalItems: {
191
+ type: 'string'
192
+ }
193
+ };
194
+ const messageErrorsSchema = {
195
+ type: 'array',
196
+ items: messageErrorSchema
197
+ };
198
+ export const messageSchemas = {
199
+ 'database-raw-message': rawMessageSchema,
200
+ 'database-raw-full-message': rawFullMessageSchema,
201
+ 'database-message-headers': messageHeadersSchema,
202
+ 'database-message-connection': messageConnectionSchema,
203
+ 'database-message-payload': messagePayloadSchema,
204
+ 'database-message-errors': messageErrorsSchema
205
+ };
206
+ //# sourceMappingURL=message.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.schemas.js","sourceRoot":"","sources":["../../../src/repositories/message/message.schemas.ts"],"names":[],"mappings":"AAUA,MAAM,gBAAgB,GAA+B;IACnD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR,aAAa;QACb,YAAY;QACZ,UAAU;QACV,WAAW;QACX,YAAY;QACZ,MAAM;QACN,QAAQ;QACR,KAAK;QACL,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,aAAa;QACb,YAAY;KACb;IACD,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;SACf;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;SACf;QACD,UAAU,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E,CAAC;IACX,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE;QACL;YACE,IAAI,EAAE,QAAQ;SACf;KACF;IACD,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;KACf;CACO,CAAA;AAEV,MAAM,mBAAmB,GAAmC;IAC1D,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,kBAAkB;CACjB,CAAA;AAEV,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,sBAAsB,EAAE,gBAAgB;IACxC,2BAA2B,EAAE,oBAAoB;IACjD,0BAA0B,EAAE,oBAAoB;IAChD,6BAA6B,EAAE,uBAAuB;IACtD,0BAA0B,EAAE,oBAAoB;IAChD,yBAAyB,EAAE,mBAAmB;CACtC,CAAA"}
@@ -0,0 +1,20 @@
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 { FullMessageModel, MessageBody, MessageConnection, MessageError, MessageHeaders, MessageModel, MessagePayload } from '../../models/index.js';
7
+ import { RedisBaseRepository } from '../base/index.js';
8
+ import { MessageRepository } from './message.js';
9
+ export declare class RedisMessageRepository extends RedisBaseRepository implements MessageRepository {
10
+ static inject(container: DIContainer): void;
11
+ constructor(validator: Validator, config: Config<RedisDatabaseConfig>, logger: Logger, connection: RedisDatabaseConnection);
12
+ create(campaignId: string, messageId: string, proxyId: string, targetId: string, sessionId: string, kind: string, method: string, url: string, requestHeaders: MessageHeaders, requestBody: MessageBody, status: number, responseHeaders: MessageHeaders, responseBody: MessageBody, connection: MessageConnection, payload: MessagePayload, errors: MessageError[], processor: string, startTime: number, finishTime: number): Promise<void>;
13
+ read(campaignId: string, messageId: string): Promise<FullMessageModel | null>;
14
+ protected buildModel(rawModel: unknown): MessageModel | null;
15
+ protected buildFullModel(rawModel: unknown): FullMessageModel | null;
16
+ protected parseHeaders(value: string): MessageHeaders;
17
+ protected parseConnection(value: string): MessageConnection;
18
+ protected parsePayload(value: string): MessagePayload;
19
+ protected parseErrors(value: string): MessageError[];
20
+ }
@@ -0,0 +1,72 @@
1
+ import { CONFIG } from '@famir/config';
2
+ import { LOGGER } from '@famir/logger';
3
+ import { VALIDATOR } from '@famir/validator';
4
+ import { DATABASE_CONNECTOR } from '../../database.js';
5
+ import { FullMessageModel, MessageModel } from '../../models/index.js';
6
+ import { RedisBaseRepository } from '../base/index.js';
7
+ import { MESSAGE_REPOSITORY } from './message.js';
8
+ import { messageSchemas } from './message.schemas.js';
9
+ export class RedisMessageRepository extends RedisBaseRepository {
10
+ static inject(container) {
11
+ container.registerSingleton(MESSAGE_REPOSITORY, (c) => new RedisMessageRepository(c.resolve(VALIDATOR), c.resolve(CONFIG), c.resolve(LOGGER), c.resolve(DATABASE_CONNECTOR).connection()));
12
+ }
13
+ constructor(validator, config, logger, connection) {
14
+ super(validator, config, logger, connection, 'message');
15
+ this.validator.addSchemas(messageSchemas);
16
+ this.logger.debug(`MessageRepository initialized`);
17
+ }
18
+ async create(campaignId, messageId, proxyId, targetId, sessionId, kind, method, url, requestHeaders, requestBody, status, responseHeaders, responseBody, connection, payload, errors, processor, startTime, finishTime) {
19
+ try {
20
+ const statusReply = await this.connection.message.create_message(this.options.prefix, campaignId, messageId, proxyId, targetId, sessionId, kind, method, url, this.encodeJson(requestHeaders), this.encodeBase64(requestBody), status, this.encodeJson(responseHeaders), this.encodeBase64(responseBody), this.encodeJson(connection), this.encodeJson(payload), this.encodeJson(errors), processor, startTime, finishTime);
21
+ const mesg = this.handleStatusReply(statusReply);
22
+ this.logger.info(mesg, { message: { campaignId, messageId, proxyId, targetId, sessionId } });
23
+ }
24
+ catch (error) {
25
+ this.raiseError(error, 'create', { campaignId, messageId, proxyId, targetId, sessionId });
26
+ }
27
+ }
28
+ async read(campaignId, messageId) {
29
+ try {
30
+ const rawModel = await this.connection.message.read_full_message(this.options.prefix, campaignId, messageId);
31
+ return this.buildFullModel(rawModel);
32
+ }
33
+ catch (error) {
34
+ this.raiseError(error, 'read', { campaignId, messageId });
35
+ }
36
+ }
37
+ buildModel(rawModel) {
38
+ if (rawModel === null) {
39
+ return null;
40
+ }
41
+ this.validateRawData('database-raw-message', rawModel);
42
+ return new MessageModel(rawModel.campaign_id, rawModel.message_id, rawModel.proxy_id, rawModel.target_id, rawModel.session_id, rawModel.kind, rawModel.method, rawModel.url, rawModel.status, rawModel.processor, rawModel.start_time, rawModel.finish_time, new Date(rawModel.created_at));
43
+ }
44
+ buildFullModel(rawModel) {
45
+ if (rawModel === null) {
46
+ return null;
47
+ }
48
+ this.validateRawData('database-raw-full-message', rawModel);
49
+ return new FullMessageModel(rawModel.campaign_id, rawModel.message_id, rawModel.proxy_id, rawModel.target_id, rawModel.session_id, rawModel.kind, rawModel.method, rawModel.url, this.parseHeaders(rawModel.request_headers), this.decodeBase64(rawModel.request_body), rawModel.status, this.parseHeaders(rawModel.response_headers), this.decodeBase64(rawModel.response_body), this.parseConnection(rawModel.connection), this.parsePayload(rawModel.payload), this.parseErrors(rawModel.errors), rawModel.processor, rawModel.start_time, rawModel.finish_time, new Date(rawModel.created_at));
50
+ }
51
+ parseHeaders(value) {
52
+ const data = this.decodeJson(value);
53
+ this.validateRawData('database-message-headers', data);
54
+ return data;
55
+ }
56
+ parseConnection(value) {
57
+ const data = this.decodeJson(value);
58
+ this.validateRawData('database-message-connection', data);
59
+ return data;
60
+ }
61
+ parsePayload(value) {
62
+ const data = this.decodeJson(value);
63
+ this.validateRawData('database-message-payload', data);
64
+ return data;
65
+ }
66
+ parseErrors(value) {
67
+ const data = this.decodeJson(value);
68
+ this.validateRawData('database-message-errors', data);
69
+ return data;
70
+ }
71
+ }
72
+ //# sourceMappingURL=redis-message.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-message.repository.js","sourceRoot":"","sources":["../../../src/repositories/message/redis-message.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAA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AAK,CAAC,CAAA;QAEnC,IAAI,CAAC,eAAe,CAAiB,yBAAyB,EAAE,IAAI,CAAC,CAAA;QAErE,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export * from './proxy.js';
2
+ export * from './proxy.schemas.js';
3
+ export * from './redis-proxy.repository.js';
@@ -0,0 +1,4 @@
1
+ export * from './proxy.js';
2
+ export * from './proxy.schemas.js';
3
+ export * from './redis-proxy.repository.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/proxy/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { ProxyModel } from '../../models/index.js';
2
+ export declare const PROXY_REPOSITORY: unique symbol;
3
+ export interface ProxyRepository {
4
+ create(campaignId: string, proxyId: string, url: string, lockSecret: string): Promise<void>;
5
+ read(campaignId: string, proxyId: string): Promise<ProxyModel | null>;
6
+ enable(campaignId: string, proxyId: string, lockSecret: string): Promise<void>;
7
+ disable(campaignId: string, proxyId: string, lockSecret: string): Promise<void>;
8
+ delete(campaignId: string, proxyId: string, lockSecret: string): Promise<void>;
9
+ list(campaignId: string): Promise<ProxyModel[] | null>;
10
+ }
@@ -0,0 +1,43 @@
1
+ import { CommandParser } from '@redis/client';
2
+ export interface RawProxy {
3
+ campaign_id: string;
4
+ proxy_id: string;
5
+ url: string;
6
+ is_enabled: number;
7
+ message_count: number;
8
+ created_at: number;
9
+ }
10
+ export declare const proxyFunctions: {
11
+ readonly proxy: {
12
+ readonly create_proxy: {
13
+ readonly NUMBER_OF_KEYS: 5;
14
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, proxyId: string, url: string, lockSecret: string) => void;
15
+ readonly transformReply: () => unknown;
16
+ };
17
+ readonly read_proxy: {
18
+ readonly NUMBER_OF_KEYS: 2;
19
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, proxyId: string) => void;
20
+ readonly transformReply: () => unknown;
21
+ };
22
+ readonly read_proxy_index: {
23
+ readonly NUMBER_OF_KEYS: 2;
24
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string) => void;
25
+ readonly transformReply: () => unknown;
26
+ };
27
+ readonly enable_proxy: {
28
+ readonly NUMBER_OF_KEYS: 4;
29
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, proxyId: string, lockSecret: string) => void;
30
+ readonly transformReply: () => unknown;
31
+ };
32
+ readonly disable_proxy: {
33
+ readonly NUMBER_OF_KEYS: 4;
34
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, proxyId: string, lockSecret: string) => void;
35
+ readonly transformReply: () => unknown;
36
+ };
37
+ readonly delete_proxy: {
38
+ readonly NUMBER_OF_KEYS: 5;
39
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, proxyId: string, lockSecret: string) => void;
40
+ readonly transformReply: () => unknown;
41
+ };
42
+ };
43
+ };
@@ -0,0 +1,72 @@
1
+ import { campaignKey, campaignLockKey, enabledProxyIndexKey, proxyIndexKey, proxyKey, proxyUniqueUrlKey } from '../../database.keys.js';
2
+ export const proxyFunctions = {
3
+ proxy: {
4
+ create_proxy: {
5
+ NUMBER_OF_KEYS: 5,
6
+ parseCommand(parser, prefix, campaignId, proxyId, url, lockSecret) {
7
+ parser.pushKey(campaignKey(prefix, campaignId));
8
+ parser.pushKey(campaignLockKey(prefix, campaignId));
9
+ parser.pushKey(proxyKey(prefix, campaignId, proxyId));
10
+ parser.pushKey(proxyUniqueUrlKey(prefix, campaignId));
11
+ parser.pushKey(proxyIndexKey(prefix, campaignId));
12
+ parser.push(campaignId);
13
+ parser.push(proxyId);
14
+ parser.push(url);
15
+ parser.push(Date.now().toString());
16
+ parser.push(lockSecret);
17
+ },
18
+ transformReply: undefined
19
+ },
20
+ read_proxy: {
21
+ NUMBER_OF_KEYS: 2,
22
+ parseCommand(parser, prefix, campaignId, proxyId) {
23
+ parser.pushKey(campaignKey(prefix, campaignId));
24
+ parser.pushKey(proxyKey(prefix, campaignId, proxyId));
25
+ },
26
+ transformReply: undefined
27
+ },
28
+ read_proxy_index: {
29
+ NUMBER_OF_KEYS: 2,
30
+ parseCommand(parser, prefix, campaignId) {
31
+ parser.pushKey(campaignKey(prefix, campaignId));
32
+ parser.pushKey(proxyIndexKey(prefix, campaignId));
33
+ },
34
+ transformReply: undefined
35
+ },
36
+ enable_proxy: {
37
+ NUMBER_OF_KEYS: 4,
38
+ parseCommand(parser, prefix, campaignId, proxyId, lockSecret) {
39
+ parser.pushKey(campaignKey(prefix, campaignId));
40
+ parser.pushKey(campaignLockKey(prefix, campaignId));
41
+ parser.pushKey(proxyKey(prefix, campaignId, proxyId));
42
+ parser.pushKey(enabledProxyIndexKey(prefix, campaignId));
43
+ parser.push(lockSecret);
44
+ },
45
+ transformReply: undefined
46
+ },
47
+ disable_proxy: {
48
+ NUMBER_OF_KEYS: 4,
49
+ parseCommand(parser, prefix, campaignId, proxyId, lockSecret) {
50
+ parser.pushKey(campaignKey(prefix, campaignId));
51
+ parser.pushKey(campaignLockKey(prefix, campaignId));
52
+ parser.pushKey(proxyKey(prefix, campaignId, proxyId));
53
+ parser.pushKey(enabledProxyIndexKey(prefix, campaignId));
54
+ parser.push(lockSecret);
55
+ },
56
+ transformReply: undefined
57
+ },
58
+ delete_proxy: {
59
+ NUMBER_OF_KEYS: 5,
60
+ parseCommand(parser, prefix, campaignId, proxyId, lockSecret) {
61
+ parser.pushKey(campaignKey(prefix, campaignId));
62
+ parser.pushKey(campaignLockKey(prefix, campaignId));
63
+ parser.pushKey(proxyKey(prefix, campaignId, proxyId));
64
+ parser.pushKey(proxyUniqueUrlKey(prefix, campaignId));
65
+ parser.pushKey(proxyIndexKey(prefix, campaignId));
66
+ parser.push(lockSecret);
67
+ },
68
+ transformReply: undefined
69
+ }
70
+ }
71
+ };
72
+ //# sourceMappingURL=proxy.functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.functions.js","sourceRoot":"","sources":["../../../src/repositories/proxy/proxy.functions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAW/B,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,KAAK,EAAE;QACL,YAAY,EAAE;YACZ,cAAc,EAAE,CAAC;YAEjB,YAAY,CACV,MAAqB,EACrB,MAAc,EACd,UAAkB,EAClB,OAAe,EACf,GAAW,EACX,UAAkB;gBAElB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAC/C,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBACnD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;gBACrD,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBACrD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAEjD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACvB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBACpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAChB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;gBAClC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACzB,CAAC;YAED,cAAc,EAAE,SAAqC;SACtD;QAED,UAAU,EAAE;YACV,cAAc,EAAE,CAAC;YAEjB,YAAY,CAAC,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AO,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAC/C,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBACnD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;gBACrD,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAExD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACzB,CAAC;YAED,cAAc,EAAE,SAAqC;SACtD;QAED,YAAY,EAAE;YACZ,cAAc,EAAE,CAAC;YAEjB,YAAY,CACV,MAAqB,EACrB,MAAc,EACd,UAAkB,EAClB,OAAe,EACf,UAAkB;gBAElB,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAC/C,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBACnD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;gBACrD,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBACrD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAEjD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACzB,CAAC;YAED,cAAc,EAAE,SAAqC;SACtD;KACF;CACO,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const PROXY_REPOSITORY = Symbol('ProxyRepository');
2
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/repositories/proxy/proxy.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { JSONSchemaType, ValidatorSchemas } from '@famir/validator';
2
+ export declare const proxySchemas: ValidatorSchemas;
3
+ export declare const proxyUrlSchema: JSONSchemaType<string>;
@@ -0,0 +1,34 @@
1
+ const rawProxySchema = {
2
+ type: 'object',
3
+ required: ['campaign_id', 'proxy_id', 'url', 'is_enabled', 'message_count', 'created_at'],
4
+ properties: {
5
+ campaign_id: {
6
+ type: 'string'
7
+ },
8
+ proxy_id: {
9
+ type: 'string'
10
+ },
11
+ url: {
12
+ type: 'string'
13
+ },
14
+ is_enabled: {
15
+ type: 'integer'
16
+ },
17
+ message_count: {
18
+ type: 'integer'
19
+ },
20
+ created_at: {
21
+ type: 'integer'
22
+ }
23
+ },
24
+ additionalProperties: false
25
+ };
26
+ export const proxySchemas = {
27
+ 'database-raw-proxy': rawProxySchema
28
+ };
29
+ export const proxyUrlSchema = {
30
+ type: 'string',
31
+ minLength: 1,
32
+ maxLength: 128
33
+ };
34
+ //# sourceMappingURL=proxy.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.schemas.js","sourceRoot":"","sources":["../../../src/repositories/proxy/proxy.schemas.ts"],"names":[],"mappings":"AAGA,MAAM,cAAc,GAA6B;IAC/C,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,CAAC;IACzF,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;SACf;QACD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;SACf;QACD,UAAU,EAAE;YACV,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,CAAC,MAAM,YAAY,GAAqB;IAC5C,oBAAoB,EAAE,cAAc;CAC5B,CAAA;AAEV,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;CACN,CAAA"}
@@ -0,0 +1,20 @@
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 { ProxyModel } from '../../models/index.js';
7
+ import { RedisBaseRepository } from '../base/index.js';
8
+ import { ProxyRepository } from './proxy.js';
9
+ export declare class RedisProxyRepository extends RedisBaseRepository implements ProxyRepository {
10
+ static inject(container: DIContainer): void;
11
+ constructor(validator: Validator, config: Config<RedisDatabaseConfig>, logger: Logger, connection: RedisDatabaseConnection);
12
+ create(campaignId: string, proxyId: string, url: string, lockSecret: string): Promise<void>;
13
+ read(campaignId: string, proxyId: string): Promise<ProxyModel | null>;
14
+ enable(campaignId: string, proxyId: string, lockSecret: string): Promise<void>;
15
+ disable(campaignId: string, proxyId: string, lockSecret: string): Promise<void>;
16
+ delete(campaignId: string, proxyId: string, lockSecret: string): Promise<void>;
17
+ list(campaignId: string): Promise<ProxyModel[] | null>;
18
+ protected buildModel(rawModel: unknown): ProxyModel | null;
19
+ protected buildCollection(rawCollection: unknown): ProxyModel[];
20
+ }