@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,138 @@
1
+ import { randomIdent } from '@famir/common';
2
+ import { CONFIG } from '@famir/config';
3
+ import { LOGGER } from '@famir/logger';
4
+ import { VALIDATOR } from '@famir/validator';
5
+ import { DATABASE_CONNECTOR, DATABASE_LOCK_TIMEOUT } from '../../database.js';
6
+ import { CampaignModel, FullCampaignModel } from '../../models/index.js';
7
+ import { RedisBaseRepository } from '../base/index.js';
8
+ import { CAMPAIGN_REPOSITORY } from './campaign.js';
9
+ import { campaignSchemas } from './campaign.schemas.js';
10
+ export class RedisCampaignRepository extends RedisBaseRepository {
11
+ static inject(container) {
12
+ container.registerSingleton(CAMPAIGN_REPOSITORY, (c) => new RedisCampaignRepository(c.resolve(VALIDATOR), c.resolve(CONFIG), c.resolve(LOGGER), c.resolve(DATABASE_CONNECTOR).connection()));
13
+ }
14
+ constructor(validator, config, logger, connection) {
15
+ super(validator, config, logger, connection, 'campaign');
16
+ this.validator.addSchemas(campaignSchemas);
17
+ this.logger.debug(`CampaignRepository initialized`);
18
+ }
19
+ async create(campaignId, mirrorDomain, description, cryptSecret, landingUpgradePath, sessionCookieName, sessionExpire, newSessionExpire, messageExpire) {
20
+ try {
21
+ const statusReply = await this.connection.campaign.create_campaign(this.options.prefix, campaignId, mirrorDomain, description, cryptSecret, landingUpgradePath, sessionCookieName, sessionExpire, newSessionExpire, messageExpire);
22
+ const mesg = this.handleStatusReply(statusReply);
23
+ this.logger.info(mesg, { campaign: { campaignId, mirrorDomain } });
24
+ }
25
+ catch (error) {
26
+ this.raiseError(error, 'create', { campaignId, mirrorDomain });
27
+ }
28
+ }
29
+ async read(campaignId) {
30
+ try {
31
+ const rawModel = await this.connection.campaign.read_campaign(this.options.prefix, campaignId);
32
+ return this.buildModel(rawModel);
33
+ }
34
+ catch (error) {
35
+ this.raiseError(error, 'read', { campaignId });
36
+ }
37
+ }
38
+ async readFull(campaignId) {
39
+ try {
40
+ const rawModel = await this.connection.campaign.read_full_campaign(this.options.prefix, campaignId);
41
+ return this.buildFullModel(rawModel);
42
+ }
43
+ catch (error) {
44
+ this.raiseError(error, 'readFull', { campaignId });
45
+ }
46
+ }
47
+ async lock(campaignId) {
48
+ const lockSecret = randomIdent();
49
+ try {
50
+ const statusReply = await this.connection.campaign.lock_campaign(this.options.prefix, campaignId, lockSecret, DATABASE_LOCK_TIMEOUT);
51
+ const mesg = this.handleStatusReply(statusReply);
52
+ this.logger.info(mesg, { campaign: { campaignId } });
53
+ return lockSecret;
54
+ }
55
+ catch (error) {
56
+ this.raiseError(error, 'lock', { campaignId });
57
+ }
58
+ }
59
+ async unlock(campaignId, lockSecret) {
60
+ try {
61
+ const statusReply = await this.connection.campaign.unlock_campaign(this.options.prefix, campaignId, lockSecret);
62
+ const mesg = this.handleStatusReply(statusReply);
63
+ this.logger.info(mesg, { campaign: { campaignId } });
64
+ }
65
+ catch (error) {
66
+ this.raiseError(error, 'unlock', { campaignId });
67
+ }
68
+ }
69
+ async update(campaignId, description, sessionExpire, newSessionExpire, messageExpire, lockSecret) {
70
+ try {
71
+ const statusReply = await this.connection.campaign.update_campaign(this.options.prefix, campaignId, description, sessionExpire, newSessionExpire, messageExpire, lockSecret);
72
+ const mesg = this.handleStatusReply(statusReply);
73
+ this.logger.info(mesg, { campaign: { campaignId } });
74
+ }
75
+ catch (error) {
76
+ this.raiseError(error, 'update', { campaignId });
77
+ }
78
+ }
79
+ async delete(campaignId, lockSecret) {
80
+ try {
81
+ const statusReply = await this.connection.campaign.delete_campaign(this.options.prefix, campaignId, lockSecret);
82
+ const mesg = this.handleStatusReply(statusReply);
83
+ this.logger.info(mesg, { campaign: { campaignId } });
84
+ }
85
+ catch (error) {
86
+ this.raiseError(error, 'delete', { campaignId });
87
+ }
88
+ }
89
+ async list() {
90
+ try {
91
+ const index = await this.connection.campaign.read_campaign_index(this.options.prefix);
92
+ this.validateArrayStringsReply(index);
93
+ const rawCollection = await Promise.all(index.map((campaignId) => this.connection.campaign.read_campaign(this.options.prefix, campaignId)));
94
+ return this.buildCollection(rawCollection);
95
+ }
96
+ catch (error) {
97
+ this.raiseError(error, 'list', null);
98
+ }
99
+ }
100
+ async listFull() {
101
+ try {
102
+ const index = await this.connection.campaign.read_campaign_index(this.options.prefix);
103
+ this.validateArrayStringsReply(index);
104
+ const rawCollection = await Promise.all(index.map((campaignId) => this.connection.campaign.read_full_campaign(this.options.prefix, campaignId)));
105
+ return this.buildFullCollection(rawCollection);
106
+ }
107
+ catch (error) {
108
+ this.raiseError(error, 'listFull', null);
109
+ }
110
+ }
111
+ buildModel(rawModel) {
112
+ if (rawModel === null) {
113
+ return null;
114
+ }
115
+ this.validateRawData('database-raw-campaign', rawModel);
116
+ return new CampaignModel(rawModel.campaign_id, rawModel.mirror_domain, !!rawModel.is_locked, rawModel.session_count, rawModel.message_count, new Date(rawModel.created_at));
117
+ }
118
+ buildFullModel(rawModel) {
119
+ if (rawModel === null) {
120
+ return null;
121
+ }
122
+ this.validateRawData('database-raw-full-campaign', rawModel);
123
+ return new FullCampaignModel(rawModel.campaign_id, rawModel.mirror_domain, rawModel.description, rawModel.crypt_secret, rawModel.landing_upgrade_path, rawModel.session_cookie_name, rawModel.session_expire, rawModel.new_session_expire, rawModel.message_expire, !!rawModel.is_locked, rawModel.proxy_count, rawModel.target_count, rawModel.redirector_count, rawModel.lure_count, rawModel.session_count, rawModel.message_count, new Date(rawModel.created_at));
124
+ }
125
+ buildCollection(rawCollection) {
126
+ this.validateArrayReply(rawCollection);
127
+ return rawCollection
128
+ .map((rawModel) => this.buildModel(rawModel))
129
+ .filter(CampaignModel.isNotNull);
130
+ }
131
+ buildFullCollection(rawCollection) {
132
+ this.validateArrayReply(rawCollection);
133
+ return rawCollection
134
+ .map((rawModel) => this.buildFullModel(rawModel))
135
+ .filter(CampaignModel.isNotNull);
136
+ }
137
+ }
138
+ //# sourceMappingURL=redis-campaign.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-campaign.repository.js","sourceRoot":"","sources":["../../../src/repositories/campaign/redis-campaign.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM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AAa,CAAC,CAAA;QAEtC,OAAO,aAAa;aACjB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aAC5C,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC;IAES,mBAAmB,CAAC,aAAsB;QAClD,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;QAEtC,OAAO,aAAa;aACjB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;aAChD,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;IACpC,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ export * from './base/index.js';
2
+ export * from './campaign/index.js';
3
+ export * from './lure/index.js';
4
+ export * from './message/index.js';
5
+ export * from './proxy/index.js';
6
+ export * from './redirector/index.js';
7
+ export * from './session/index.js';
8
+ export * from './target/index.js';
@@ -0,0 +1,9 @@
1
+ export * from './base/index.js';
2
+ export * from './campaign/index.js';
3
+ export * from './lure/index.js';
4
+ export * from './message/index.js';
5
+ export * from './proxy/index.js';
6
+ export * from './redirector/index.js';
7
+ export * from './session/index.js';
8
+ export * from './target/index.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './lure.js';
2
+ export * from './lure.schemas.js';
3
+ export * from './redis-lure.repository.js';
@@ -0,0 +1,4 @@
1
+ export * from './lure.js';
2
+ export * from './lure.schemas.js';
3
+ export * from './redis-lure.repository.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/lure/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { LureModel } from '../../models/index.js';
2
+ export declare const LURE_REPOSITORY: unique symbol;
3
+ export interface LureRepository {
4
+ create(campaignId: string, lureId: string, path: string, redirectorId: string, lockSecret: string): Promise<void>;
5
+ read(campaignId: string, lureId: string): Promise<LureModel | null>;
6
+ find(campaignId: string, path: string): Promise<LureModel | null>;
7
+ enable(campaignId: string, lureId: string, lockSecret: string): Promise<void>;
8
+ disable(campaignId: string, lureId: string, lockSecret: string): Promise<void>;
9
+ delete(campaignId: string, lureId: string, redirectorId: string, lockSecret: string): Promise<void>;
10
+ list(campaignId: string): Promise<LureModel[] | null>;
11
+ }
@@ -0,0 +1,49 @@
1
+ import { CommandParser } from '@redis/client';
2
+ export interface RawLure {
3
+ campaign_id: string;
4
+ lure_id: string;
5
+ path: string;
6
+ redirector_id: string;
7
+ is_enabled: number;
8
+ session_count: number;
9
+ created_at: number;
10
+ }
11
+ export declare const lureFunctions: {
12
+ readonly lure: {
13
+ readonly create_lure: {
14
+ readonly NUMBER_OF_KEYS: 6;
15
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lureId: string, path: string, redirectorId: string, lockSecret: string) => void;
16
+ readonly transformReply: () => unknown;
17
+ };
18
+ readonly read_lure: {
19
+ readonly NUMBER_OF_KEYS: 2;
20
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lureId: string) => void;
21
+ readonly transformReply: () => unknown;
22
+ };
23
+ readonly find_lure_id: {
24
+ readonly NUMBER_OF_KEYS: 2;
25
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, path: string) => void;
26
+ readonly transformReply: () => unknown;
27
+ };
28
+ readonly read_lure_index: {
29
+ readonly NUMBER_OF_KEYS: 2;
30
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string) => void;
31
+ readonly transformReply: () => unknown;
32
+ };
33
+ readonly enable_lure: {
34
+ readonly NUMBER_OF_KEYS: 3;
35
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lureId: string, lockSecret: string) => void;
36
+ readonly transformReply: () => unknown;
37
+ };
38
+ readonly disable_lure: {
39
+ readonly NUMBER_OF_KEYS: 3;
40
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lureId: string, lockSecret: string) => void;
41
+ readonly transformReply: () => unknown;
42
+ };
43
+ readonly delete_lure: {
44
+ readonly NUMBER_OF_KEYS: 6;
45
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, lureId: string, redirectorId: string, lockSecret: string) => void;
46
+ readonly transformReply: () => unknown;
47
+ };
48
+ };
49
+ };
@@ -0,0 +1,82 @@
1
+ import { campaignKey, campaignLockKey, lureIndexKey, lureKey, lurePathsKey, redirectorKey } from '../../database.keys.js';
2
+ export const lureFunctions = {
3
+ lure: {
4
+ create_lure: {
5
+ NUMBER_OF_KEYS: 6,
6
+ parseCommand(parser, prefix, campaignId, lureId, path, redirectorId, lockSecret) {
7
+ parser.pushKey(campaignKey(prefix, campaignId));
8
+ parser.pushKey(campaignLockKey(prefix, campaignId));
9
+ parser.pushKey(lureKey(prefix, campaignId, lureId));
10
+ parser.pushKey(lurePathsKey(prefix, campaignId));
11
+ parser.pushKey(lureIndexKey(prefix, campaignId));
12
+ parser.pushKey(redirectorKey(prefix, campaignId, redirectorId));
13
+ parser.push(campaignId);
14
+ parser.push(lureId);
15
+ parser.push(path);
16
+ parser.push(redirectorId);
17
+ parser.push(Date.now().toString());
18
+ parser.push(lockSecret);
19
+ },
20
+ transformReply: undefined
21
+ },
22
+ read_lure: {
23
+ NUMBER_OF_KEYS: 2,
24
+ parseCommand(parser, prefix, campaignId, lureId) {
25
+ parser.pushKey(campaignKey(prefix, campaignId));
26
+ parser.pushKey(lureKey(prefix, campaignId, lureId));
27
+ },
28
+ transformReply: undefined
29
+ },
30
+ find_lure_id: {
31
+ NUMBER_OF_KEYS: 2,
32
+ parseCommand(parser, prefix, campaignId, path) {
33
+ parser.pushKey(campaignKey(prefix, campaignId));
34
+ parser.pushKey(lurePathsKey(prefix, campaignId));
35
+ parser.push(path);
36
+ },
37
+ transformReply: undefined
38
+ },
39
+ read_lure_index: {
40
+ NUMBER_OF_KEYS: 2,
41
+ parseCommand(parser, prefix, campaignId) {
42
+ parser.pushKey(campaignKey(prefix, campaignId));
43
+ parser.pushKey(lureIndexKey(prefix, campaignId));
44
+ },
45
+ transformReply: undefined
46
+ },
47
+ enable_lure: {
48
+ NUMBER_OF_KEYS: 3,
49
+ parseCommand(parser, prefix, campaignId, lureId, lockSecret) {
50
+ parser.pushKey(campaignKey(prefix, campaignId));
51
+ parser.pushKey(campaignLockKey(prefix, campaignId));
52
+ parser.pushKey(lureKey(prefix, campaignId, lureId));
53
+ parser.push(lockSecret);
54
+ },
55
+ transformReply: undefined
56
+ },
57
+ disable_lure: {
58
+ NUMBER_OF_KEYS: 3,
59
+ parseCommand(parser, prefix, campaignId, lureId, lockSecret) {
60
+ parser.pushKey(campaignKey(prefix, campaignId));
61
+ parser.pushKey(campaignLockKey(prefix, campaignId));
62
+ parser.pushKey(lureKey(prefix, campaignId, lureId));
63
+ parser.push(lockSecret);
64
+ },
65
+ transformReply: undefined
66
+ },
67
+ delete_lure: {
68
+ NUMBER_OF_KEYS: 6,
69
+ parseCommand(parser, prefix, campaignId, lureId, redirectorId, lockSecret) {
70
+ parser.pushKey(campaignKey(prefix, campaignId));
71
+ parser.pushKey(campaignLockKey(prefix, campaignId));
72
+ parser.pushKey(lureKey(prefix, campaignId, lureId));
73
+ parser.pushKey(lurePathsKey(prefix, campaignId));
74
+ parser.pushKey(lureIndexKey(prefix, campaignId));
75
+ parser.pushKey(redirectorKey(prefix, campaignId, redirectorId));
76
+ parser.push(lockSecret);
77
+ },
78
+ transformReply: undefined
79
+ }
80
+ }
81
+ };
82
+ //# sourceMappingURL=lure.functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lure.functions.js","sourceRoot":"","sources":["../../../src/repositories/lure/lure.functions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,eAAe,EACf,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACd,MAAM,wBAAwB,CAAA;AAY/B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE;QACJ,WAAW,EAAE;YACX,cAAc,EAAE,CAAC;YAEjB,YAAY,CACV,MAAqB,EACrB,MAAc,EACd,UAAkB,EAClB,MAAc,EACd,IAAY,EACZ,YAAoB,EACpB,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,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAA;gBACnD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAChD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAChD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAA;gBAE/D,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACvB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACjB,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC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C,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAChD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;gBAChD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAA;gBAE/D,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACzB,CAAC;YAED,cAAc,EAAE,SAAqC;SACtD;KACF;CACO,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const LURE_REPOSITORY = Symbol('LureRepository');
2
+ //# sourceMappingURL=lure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lure.js","sourceRoot":"","sources":["../../../src/repositories/lure/lure.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { JSONSchemaType, ValidatorSchemas } from '@famir/validator';
2
+ export declare const lureSchemas: ValidatorSchemas;
3
+ export declare const lurePathSchema: JSONSchemaType<string>;
@@ -0,0 +1,45 @@
1
+ const rawLureSchema = {
2
+ type: 'object',
3
+ required: [
4
+ 'campaign_id',
5
+ 'lure_id',
6
+ 'path',
7
+ 'redirector_id',
8
+ 'is_enabled',
9
+ 'session_count',
10
+ 'created_at'
11
+ ],
12
+ properties: {
13
+ campaign_id: {
14
+ type: 'string'
15
+ },
16
+ lure_id: {
17
+ type: 'string'
18
+ },
19
+ path: {
20
+ type: 'string'
21
+ },
22
+ redirector_id: {
23
+ type: 'string'
24
+ },
25
+ is_enabled: {
26
+ type: 'integer'
27
+ },
28
+ session_count: {
29
+ type: 'integer'
30
+ },
31
+ created_at: {
32
+ type: 'integer'
33
+ }
34
+ },
35
+ additionalProperties: false
36
+ };
37
+ export const lureSchemas = {
38
+ 'database-raw-lure': rawLureSchema
39
+ };
40
+ export const lurePathSchema = {
41
+ type: 'string',
42
+ minLength: 1,
43
+ maxLength: 128
44
+ };
45
+ //# sourceMappingURL=lure.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lure.schemas.js","sourceRoot":"","sources":["../../../src/repositories/lure/lure.schemas.ts"],"names":[],"mappings":"AAGA,MAAM,aAAa,GAA4B;IAC7C,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE;QACR,aAAa;QACb,SAAS;QACT,MAAM;QACN,eAAe;QACf,YAAY;QACZ,eAAe;QACf,YAAY;KACb;IACD,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;SACf;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;SACf;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;QACD,aAAa,EAAE;YACb,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,WAAW,GAAqB;IAC3C,mBAAmB,EAAE,aAAa;CAC1B,CAAA;AAEV,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;CACN,CAAA"}
@@ -0,0 +1,21 @@
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 { LureModel } from '../../models/index.js';
7
+ import { RedisBaseRepository } from '../base/index.js';
8
+ import { LureRepository } from './lure.js';
9
+ export declare class RedisLureRepository extends RedisBaseRepository implements LureRepository {
10
+ static inject(container: DIContainer): void;
11
+ constructor(validator: Validator, config: Config<RedisDatabaseConfig>, logger: Logger, connection: RedisDatabaseConnection);
12
+ create(campaignId: string, lureId: string, path: string, redirectorId: string, lockSecret: string): Promise<void>;
13
+ read(campaignId: string, lureId: string): Promise<LureModel | null>;
14
+ find(campaignId: string, path: string): Promise<LureModel | null>;
15
+ enable(campaignId: string, lureId: string, lockSecret: string): Promise<void>;
16
+ disable(campaignId: string, lureId: string, lockSecret: string): Promise<void>;
17
+ delete(campaignId: string, lureId: string, redirectorId: string, lockSecret: string): Promise<void>;
18
+ list(campaignId: string): Promise<LureModel[] | null>;
19
+ protected buildModel(rawModel: unknown): LureModel | null;
20
+ protected buildCollection(rawCollection: unknown): LureModel[];
21
+ }
@@ -0,0 +1,107 @@
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 { LureModel } from '../../models/index.js';
6
+ import { RedisBaseRepository } from '../base/index.js';
7
+ import { LURE_REPOSITORY } from './lure.js';
8
+ import { lureSchemas } from './lure.schemas.js';
9
+ export class RedisLureRepository extends RedisBaseRepository {
10
+ static inject(container) {
11
+ container.registerSingleton(LURE_REPOSITORY, (c) => new RedisLureRepository(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, 'lure');
15
+ this.validator.addSchemas(lureSchemas);
16
+ this.logger.debug(`LureRepository initialized`);
17
+ }
18
+ async create(campaignId, lureId, path, redirectorId, lockSecret) {
19
+ try {
20
+ const statusReply = await this.connection.lure.create_lure(this.options.prefix, campaignId, lureId, path, redirectorId, lockSecret);
21
+ const mesg = this.handleStatusReply(statusReply);
22
+ this.logger.info(mesg, { lure: { campaignId, lureId, path, redirectorId } });
23
+ }
24
+ catch (error) {
25
+ this.raiseError(error, 'create', { campaignId, lureId, path, redirectorId });
26
+ }
27
+ }
28
+ async read(campaignId, lureId) {
29
+ try {
30
+ const rawModel = await this.connection.lure.read_lure(this.options.prefix, campaignId, lureId);
31
+ return this.buildModel(rawModel);
32
+ }
33
+ catch (error) {
34
+ this.raiseError(error, 'read', { campaignId, lureId });
35
+ }
36
+ }
37
+ async find(campaignId, path) {
38
+ try {
39
+ const lureId = await this.connection.lure.find_lure_id(this.options.prefix, campaignId, path);
40
+ if (lureId === null) {
41
+ return null;
42
+ }
43
+ this.validateStringReply(lureId);
44
+ const rawModel = await this.connection.lure.read_lure(this.options.prefix, campaignId, lureId);
45
+ return this.buildModel(rawModel);
46
+ }
47
+ catch (error) {
48
+ this.raiseError(error, 'find', { campaignId, path });
49
+ }
50
+ }
51
+ async enable(campaignId, lureId, lockSecret) {
52
+ try {
53
+ const statusReply = await this.connection.lure.enable_lure(this.options.prefix, campaignId, lureId, lockSecret);
54
+ const mesg = this.handleStatusReply(statusReply);
55
+ this.logger.info(mesg, { lure: { campaignId, lureId } });
56
+ }
57
+ catch (error) {
58
+ this.raiseError(error, 'enable', { campaignId, lureId });
59
+ }
60
+ }
61
+ async disable(campaignId, lureId, lockSecret) {
62
+ try {
63
+ const statusReply = await this.connection.lure.disable_lure(this.options.prefix, campaignId, lureId, lockSecret);
64
+ const mesg = this.handleStatusReply(statusReply);
65
+ this.logger.info(mesg, { lure: { campaignId, lureId } });
66
+ }
67
+ catch (error) {
68
+ this.raiseError(error, 'disable', { campaignId, lureId });
69
+ }
70
+ }
71
+ async delete(campaignId, lureId, redirectorId, lockSecret) {
72
+ try {
73
+ const statusReply = await this.connection.lure.delete_lure(this.options.prefix, campaignId, lureId, redirectorId, lockSecret);
74
+ const mesg = this.handleStatusReply(statusReply);
75
+ this.logger.info(mesg, { lure: { campaignId, lureId, redirectorId } });
76
+ }
77
+ catch (error) {
78
+ this.raiseError(error, 'delete', { campaignId, lureId, redirectorId });
79
+ }
80
+ }
81
+ async list(campaignId) {
82
+ try {
83
+ const index = await this.connection.lure.read_lure_index(this.options.prefix, campaignId);
84
+ if (index === null) {
85
+ return null;
86
+ }
87
+ this.validateArrayStringsReply(index);
88
+ const rawCollection = await Promise.all(index.map((lureId) => this.connection.lure.read_lure(this.options.prefix, campaignId, lureId)));
89
+ return this.buildCollection(rawCollection);
90
+ }
91
+ catch (error) {
92
+ this.raiseError(error, 'list', { campaignId });
93
+ }
94
+ }
95
+ buildModel(rawModel) {
96
+ if (rawModel === null) {
97
+ return null;
98
+ }
99
+ this.validateRawData('database-raw-lure', rawModel);
100
+ return new LureModel(rawModel.campaign_id, rawModel.lure_id, rawModel.path, rawModel.redirector_id, !!rawModel.is_enabled, rawModel.session_count, new Date(rawModel.created_at));
101
+ }
102
+ buildCollection(rawCollection) {
103
+ this.validateArrayReply(rawCollection);
104
+ return rawCollection.map((rawModel) => this.buildModel(rawModel)).filter(LureModel.isNotNull);
105
+ }
106
+ }
107
+ //# sourceMappingURL=redis-lure.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-lure.repository.js","sourceRoot":"","sources":["../../../src/repositories/lure/redis-lure.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAU,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAU,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAa,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EACL,kBAAkB,EAInB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,OAAO,mBAAoB,SAAQ,mBAAmB;IAC1D,MAAM,CAAC,MAAM,CAAC,SAAsB;QAClC,SAAS,CAAC,iBAAiB,CACzB,eAAe,E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pC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,IAAI,CAAC,eAAe,CAAU,mBAAmB,EAAE,QAAQ,CAAC,CAAA;QAE5D,OAAO,IAAI,SAAS,CAClB,QAAQ,CAAC,WAAW,EACpB,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,aAAa,EACtB,CAAC,CAAC,QAAQ,CAAC,UAAU,EACrB,QAAQ,CAAC,aAAa,EACtB,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC9B,CAAA;IACH,CAAC;IAES,eAAe,CAAC,aAAsB;QAC9C,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;QAEtC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;IAC/F,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export * from './message.js';
2
+ export * from './message.schemas.js';
3
+ export * from './redis-message.repository.js';
@@ -0,0 +1,4 @@
1
+ export * from './message.js';
2
+ export * from './message.schemas.js';
3
+ export * from './redis-message.repository.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/message/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { FullMessageModel, MessageBody, MessageConnection, MessageError, MessageHeaders, MessageKind, MessageMethod, MessagePayload } from '../../models/index.js';
2
+ export declare const MESSAGE_REPOSITORY: unique symbol;
3
+ export interface MessageRepository {
4
+ create(campaignId: string, messageId: string, proxyId: string, targetId: string, sessionId: string, kind: MessageKind, method: MessageMethod, 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>;
5
+ read(campaignId: string, messageId: string): Promise<FullMessageModel | null>;
6
+ }
@@ -0,0 +1,44 @@
1
+ import { CommandParser } from '@redis/client';
2
+ export interface RawMessage {
3
+ campaign_id: string;
4
+ message_id: string;
5
+ proxy_id: string;
6
+ target_id: string;
7
+ session_id: string;
8
+ kind: string;
9
+ method: string;
10
+ url: string;
11
+ status: number;
12
+ processor: string;
13
+ start_time: number;
14
+ finish_time: number;
15
+ created_at: number;
16
+ }
17
+ export interface RawFullMessage extends RawMessage {
18
+ request_headers: string;
19
+ request_body: string;
20
+ response_headers: string;
21
+ response_body: string;
22
+ connection: string;
23
+ payload: string;
24
+ errors: string;
25
+ }
26
+ export declare const messageFunctions: {
27
+ readonly message: {
28
+ readonly create_message: {
29
+ readonly NUMBER_OF_KEYS: 5;
30
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, messageId: string, proxyId: string, targetId: string, sessionId: string, kind: string, method: string, url: string, requestHeaders: string, requestBody: string, status: number, responseHeaders: string, responseBody: string, connection: string, payload: string, errors: string, processor: string, startTime: number, finishTime: number) => void;
31
+ readonly transformReply: () => unknown;
32
+ };
33
+ readonly read_message: {
34
+ readonly NUMBER_OF_KEYS: 2;
35
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, messageId: string) => void;
36
+ readonly transformReply: () => unknown;
37
+ };
38
+ readonly read_full_message: {
39
+ readonly NUMBER_OF_KEYS: 2;
40
+ readonly parseCommand: (parser: CommandParser, prefix: string, campaignId: string, messageId: string) => void;
41
+ readonly transformReply: () => unknown;
42
+ };
43
+ };
44
+ };