@candlerip/shared3 0.0.101 → 0.0.103

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/_devops/npm/npm-update-packages.sh +1 -1
  2. package/package.json +16 -1
  3. package/src/_devops/get-project-config/domains/args/index.d.ts +5 -0
  4. package/src/_devops/get-project-config/domains/args/index.js +1 -0
  5. package/src/_devops/get-project-config/domains/index.d.ts +1 -0
  6. package/src/_devops/get-project-config/domains/index.js +1 -0
  7. package/src/_devops/get-project-config/index.d.ts +2 -0
  8. package/src/_devops/get-project-config/index.js +18 -0
  9. package/src/aws/account-id/config.d.ts +1 -0
  10. package/src/aws/account-id/config.js +1 -0
  11. package/src/aws/account-id/index.d.ts +1 -0
  12. package/src/aws/account-id/index.js +1 -0
  13. package/src/aws/app-config/get-app-config/index.d.ts +1 -0
  14. package/src/aws/app-config/get-app-config/index.js +1 -0
  15. package/src/aws/app-config/get-app-config/util.d.ts +10 -0
  16. package/src/aws/app-config/get-app-config/util.js +79 -0
  17. package/src/aws/app-config/index.d.ts +1 -0
  18. package/src/aws/app-config/index.js +1 -0
  19. package/src/aws/cdk/attach-policy/index.d.ts +1 -0
  20. package/src/aws/cdk/attach-policy/index.js +1 -0
  21. package/src/aws/cdk/attach-policy/type.d.ts +24 -0
  22. package/src/aws/cdk/attach-policy/type.js +1 -0
  23. package/src/aws/cdk/attach-policy/util.d.ts +2 -0
  24. package/src/aws/cdk/attach-policy/util.js +33 -0
  25. package/src/aws/cdk/compose-cdk-stack/index.d.ts +1 -0
  26. package/src/aws/cdk/compose-cdk-stack/index.js +1 -0
  27. package/src/aws/cdk/compose-cdk-stack/type.d.ts +2 -0
  28. package/src/aws/cdk/compose-cdk-stack/type.js +1 -0
  29. package/src/aws/cdk/compose-cdk-stack/util.d.ts +2 -0
  30. package/src/aws/cdk/compose-cdk-stack/util.js +2 -0
  31. package/src/aws/cdk/index.d.ts +2 -0
  32. package/src/aws/cdk/index.js +2 -0
  33. package/src/aws/index.d.ts +7 -0
  34. package/src/aws/index.js +7 -0
  35. package/src/aws/lambda/index.d.ts +2 -0
  36. package/src/aws/lambda/index.js +2 -0
  37. package/src/aws/lambda/lambda-arn/compose-lambda-arn/index.d.ts +1 -0
  38. package/src/aws/lambda/lambda-arn/compose-lambda-arn/index.js +1 -0
  39. package/src/aws/lambda/lambda-arn/compose-lambda-arn/type.d.ts +2 -0
  40. package/src/aws/lambda/lambda-arn/compose-lambda-arn/type.js +1 -0
  41. package/src/aws/lambda/lambda-arn/compose-lambda-arn/util.d.ts +2 -0
  42. package/src/aws/lambda/lambda-arn/compose-lambda-arn/util.js +2 -0
  43. package/src/aws/lambda/lambda-arn/config.d.ts +1 -0
  44. package/src/aws/lambda/lambda-arn/config.js +3 -0
  45. package/src/aws/lambda/lambda-arn/index.d.ts +2 -0
  46. package/src/aws/lambda/lambda-arn/index.js +2 -0
  47. package/src/aws/lambda/lambda-name/config.d.ts +1 -0
  48. package/src/aws/lambda/lambda-name/config.js +1 -0
  49. package/src/aws/lambda/lambda-name/index.d.ts +2 -0
  50. package/src/aws/lambda/lambda-name/index.js +2 -0
  51. package/src/aws/lambda/lambda-name/type.d.ts +2 -0
  52. package/src/aws/lambda/lambda-name/type.js +1 -0
  53. package/src/aws/region/config.d.ts +1 -0
  54. package/src/aws/region/config.js +1 -0
  55. package/src/aws/region/default.d.ts +2 -0
  56. package/src/aws/region/default.js +1 -0
  57. package/src/aws/region/index.d.ts +3 -0
  58. package/src/aws/region/index.js +3 -0
  59. package/src/aws/region/type.d.ts +2 -0
  60. package/src/aws/region/type.js +1 -0
  61. package/src/aws/s3/index.d.ts +1 -0
  62. package/src/aws/s3/index.js +1 -0
  63. package/src/aws/s3/s3-arn/compose-s3-arn/index.d.ts +1 -0
  64. package/src/aws/s3/s3-arn/compose-s3-arn/index.js +1 -0
  65. package/src/aws/s3/s3-arn/compose-s3-arn/type.d.ts +1 -0
  66. package/src/aws/s3/s3-arn/compose-s3-arn/type.js +1 -0
  67. package/src/aws/s3/s3-arn/compose-s3-arn/util.d.ts +2 -0
  68. package/src/aws/s3/s3-arn/compose-s3-arn/util.js +2 -0
  69. package/src/aws/s3/s3-arn/config.d.ts +1 -0
  70. package/src/aws/s3/s3-arn/config.js +1 -0
  71. package/src/aws/s3/s3-arn/index.d.ts +2 -0
  72. package/src/aws/s3/s3-arn/index.js +2 -0
  73. package/src/aws/sqs/index.d.ts +2 -0
  74. package/src/aws/sqs/index.js +2 -0
  75. package/src/aws/sqs/queue-arn/compose-queue-arn/index.d.ts +1 -0
  76. package/src/aws/sqs/queue-arn/compose-queue-arn/index.js +1 -0
  77. package/src/aws/sqs/queue-arn/compose-queue-arn/type.d.ts +2 -0
  78. package/src/aws/sqs/queue-arn/compose-queue-arn/type.js +1 -0
  79. package/src/aws/sqs/queue-arn/compose-queue-arn/util.d.ts +2 -0
  80. package/src/aws/sqs/queue-arn/compose-queue-arn/util.js +2 -0
  81. package/src/aws/sqs/queue-arn/config.d.ts +1 -0
  82. package/src/aws/sqs/queue-arn/config.js +3 -0
  83. package/src/aws/sqs/queue-arn/index.d.ts +2 -0
  84. package/src/aws/sqs/queue-arn/index.js +2 -0
  85. package/src/aws/sqs/queue-name/cache/config.d.ts +1 -0
  86. package/src/aws/sqs/queue-name/cache/config.js +1 -0
  87. package/src/aws/sqs/queue-name/cache/index.d.ts +2 -0
  88. package/src/aws/sqs/queue-name/cache/index.js +2 -0
  89. package/src/aws/sqs/queue-name/cache/type.d.ts +2 -0
  90. package/src/aws/sqs/queue-name/cache/type.js +1 -0
  91. package/src/aws/sqs/queue-name/index.d.ts +3 -0
  92. package/src/aws/sqs/queue-name/index.js +3 -0
  93. package/src/aws/sqs/queue-name/logger/config.d.ts +1 -0
  94. package/src/aws/sqs/queue-name/logger/config.js +1 -0
  95. package/src/aws/sqs/queue-name/logger/index.d.ts +2 -0
  96. package/src/aws/sqs/queue-name/logger/index.js +2 -0
  97. package/src/aws/sqs/queue-name/logger/type.d.ts +2 -0
  98. package/src/aws/sqs/queue-name/logger/type.js +1 -0
  99. package/src/aws/sqs/queue-name/queue-name/config.d.ts +1 -0
  100. package/src/aws/sqs/queue-name/queue-name/config.js +3 -0
  101. package/src/aws/sqs/queue-name/queue-name/index.d.ts +2 -0
  102. package/src/aws/sqs/queue-name/queue-name/index.js +2 -0
  103. package/src/aws/sqs/queue-name/queue-name/type.d.ts +2 -0
  104. package/src/aws/sqs/queue-name/queue-name/type.js +1 -0
  105. package/src/backend/cache/cache/index.d.ts +2 -0
  106. package/src/backend/cache/cache/index.js +2 -0
  107. package/src/backend/cache/cache/singleton.d.ts +23 -0
  108. package/src/backend/cache/cache/singleton.js +104 -0
  109. package/src/backend/cache/cache/type.d.ts +5 -0
  110. package/src/backend/cache/cache/type.js +1 -0
  111. package/src/backend/cache/cache-key/config.d.ts +1 -0
  112. package/src/backend/cache/cache-key/config.js +18 -0
  113. package/src/backend/cache/cache-key/index.d.ts +3 -0
  114. package/src/backend/cache/cache-key/index.js +3 -0
  115. package/src/backend/cache/cache-key/type-guard.d.ts +2 -0
  116. package/src/backend/cache/cache-key/type-guard.js +4 -0
  117. package/src/backend/cache/cache-key/type.d.ts +2 -0
  118. package/src/backend/cache/cache-key/type.js +1 -0
  119. package/src/backend/cache/index.d.ts +2 -0
  120. package/src/backend/cache/index.js +2 -0
  121. package/src/backend/database/connect-database/index.d.ts +1 -0
  122. package/src/backend/database/connect-database/index.js +1 -0
  123. package/src/backend/database/connect-database/type.d.ts +1 -0
  124. package/src/backend/database/connect-database/type.js +1 -0
  125. package/src/backend/database/connect-database/util.d.ts +2 -0
  126. package/src/backend/database/connect-database/util.js +12 -0
  127. package/src/backend/database/model/translation/index.d.ts +2 -0
  128. package/src/backend/database/model/translation/index.js +2 -0
  129. package/src/backend/database/model/translation/type.d.ts +7 -0
  130. package/src/backend/database/model/translation/type.js +1 -0
  131. package/src/backend/database/model/translation/util.d.ts +7 -0
  132. package/src/backend/database/model/translation/util.js +7 -0
  133. package/src/backend/database/mutation/translation/get-translations/index.d.ts +1 -0
  134. package/src/backend/database/mutation/translation/get-translations/index.js +1 -0
  135. package/src/backend/database/mutation/translation/get-translations/type.d.ts +8 -0
  136. package/src/backend/database/mutation/translation/get-translations/type.js +1 -0
  137. package/src/backend/database/mutation/translation/get-translations/util.d.ts +2 -0
  138. package/src/backend/database/mutation/translation/get-translations/util.js +30 -0
  139. package/src/backend/database/mutation/translation/get-translations-as-dictionary/index.d.ts +1 -0
  140. package/src/backend/database/mutation/translation/get-translations-as-dictionary/index.js +1 -0
  141. package/src/backend/database/mutation/translation/get-translations-as-dictionary/util.d.ts +7 -0
  142. package/src/backend/database/mutation/translation/get-translations-as-dictionary/util.js +51 -0
  143. package/src/backend/database/mutation/translation/index.d.ts +2 -0
  144. package/src/backend/database/mutation/translation/index.js +2 -0
  145. package/src/backend/dictionary/compose-dictionary/index.d.ts +1 -0
  146. package/src/backend/dictionary/compose-dictionary/index.js +1 -0
  147. package/src/backend/dictionary/compose-dictionary/type.d.ts +10 -0
  148. package/src/backend/dictionary/compose-dictionary/type.js +1 -0
  149. package/src/backend/dictionary/compose-dictionary/util.d.ts +2 -0
  150. package/src/backend/dictionary/compose-dictionary/util.js +10 -0
  151. package/src/backend/dictionary/get-excluded-translation-ids/index.d.ts +1 -0
  152. package/src/backend/dictionary/get-excluded-translation-ids/index.js +1 -0
  153. package/src/backend/dictionary/get-excluded-translation-ids/type.d.ts +5 -0
  154. package/src/backend/dictionary/get-excluded-translation-ids/type.js +1 -0
  155. package/src/backend/dictionary/get-excluded-translation-ids/util.d.ts +2 -0
  156. package/src/backend/dictionary/get-excluded-translation-ids/util.js +10 -0
  157. package/src/backend/dictionary/index.d.ts +2 -0
  158. package/src/backend/dictionary/index.js +2 -0
  159. package/src/backend/express/index.d.ts +1 -0
  160. package/src/backend/express/index.js +1 -0
  161. package/src/backend/express/start-express-app/index.d.ts +1 -0
  162. package/src/backend/express/start-express-app/index.js +1 -0
  163. package/src/backend/express/start-express-app/type.d.ts +2 -0
  164. package/src/backend/express/start-express-app/type.js +1 -0
  165. package/src/backend/express/start-express-app/util.d.ts +2 -0
  166. package/src/backend/express/start-express-app/util.js +8 -0
  167. package/src/backend/message-broker/index.d.ts +4 -0
  168. package/src/backend/message-broker/index.js +4 -0
  169. package/src/backend/message-broker/log-custom-error/index.d.ts +1 -0
  170. package/src/backend/message-broker/log-custom-error/index.js +1 -0
  171. package/src/backend/message-broker/log-custom-error/type.d.ts +2 -0
  172. package/src/backend/message-broker/log-custom-error/type.js +1 -0
  173. package/src/backend/message-broker/log-custom-error/util.d.ts +2 -0
  174. package/src/backend/message-broker/log-custom-error/util.js +2 -0
  175. package/src/backend/message-broker/message-broker/config.d.ts +4 -0
  176. package/src/backend/message-broker/message-broker/config.js +4 -0
  177. package/src/backend/message-broker/message-broker/index.d.ts +3 -0
  178. package/src/backend/message-broker/message-broker/index.js +3 -0
  179. package/src/backend/message-broker/message-broker/singleton.d.ts +7 -0
  180. package/src/backend/message-broker/message-broker/singleton.js +70 -0
  181. package/src/backend/message-broker/message-broker/type.d.ts +12 -0
  182. package/src/backend/message-broker/message-broker/type.js +1 -0
  183. package/src/backend/message-broker/message-broker-queue-name/index.d.ts +1 -0
  184. package/src/backend/message-broker/message-broker-queue-name/index.js +1 -0
  185. package/src/backend/message-broker/message-broker-queue-name/type.d.ts +2 -0
  186. package/src/backend/message-broker/message-broker-queue-name/type.js +1 -0
  187. package/src/backend/message-broker/message-broker-refresh-cache/index.d.ts +2 -0
  188. package/src/backend/message-broker/message-broker-refresh-cache/index.js +2 -0
  189. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.d.ts +1 -0
  190. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/index.js +1 -0
  191. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.d.ts +2 -0
  192. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/type.js +1 -0
  193. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.d.ts +2 -0
  194. package/src/backend/message-broker/message-broker-refresh-cache/refresh-cache/util.js +6 -0
  195. package/src/backend/message-broker/message-broker-refresh-cache/type.d.ts +4 -0
  196. package/src/backend/message-broker/message-broker-refresh-cache/type.js +1 -0
@@ -0,0 +1,70 @@
1
+ import amqp from 'amqplib';
2
+ import { consoleCustomError, customErrorWorker } from '../../../error/index.js';
3
+ export const MessageBrokerSingleton = (() => {
4
+ let _channel;
5
+ let _connection;
6
+ let _errorMessage = 'Initializing MessageBroker';
7
+ let _url;
8
+ let _customErrorWorker;
9
+ const checkErrorStatus = () => {
10
+ if (_errorMessage) {
11
+ return _customErrorWorker.composeCustomError(_errorMessage);
12
+ }
13
+ return;
14
+ };
15
+ const connect = async () => {
16
+ try {
17
+ _connection = await amqp.connect(_url);
18
+ _connection.on('error', (_err) => {
19
+ handleError(_err);
20
+ });
21
+ _channel = await _connection.createChannel();
22
+ _errorMessage = null;
23
+ }
24
+ catch (err) {
25
+ handleError(err);
26
+ }
27
+ };
28
+ const handleError = (err) => {
29
+ _customErrorWorker.addInfo({ err });
30
+ _errorMessage = 'Error connect Rabbitmq';
31
+ setTimeout(connect, 10000);
32
+ };
33
+ const init = (url) => {
34
+ _url = url;
35
+ _customErrorWorker = customErrorWorker({ url });
36
+ connect();
37
+ };
38
+ const listenQueue = async (queue, onMessage) => {
39
+ const resp = checkErrorStatus();
40
+ if (resp) {
41
+ consoleCustomError(resp.customError);
42
+ console.error('QUEUE:', queue);
43
+ setTimeout(() => listenQueue(queue, onMessage), 10000);
44
+ return;
45
+ }
46
+ await _channel.assertQueue(queue, { durable: true });
47
+ _channel.consume(queue, (msg) => {
48
+ if (msg) {
49
+ onMessage(JSON.parse(msg.content.toString()));
50
+ _channel.ack(msg);
51
+ }
52
+ });
53
+ };
54
+ const sendMessage = async (queueName, message) => {
55
+ const resp = checkErrorStatus();
56
+ if (resp) {
57
+ consoleCustomError(resp.customError);
58
+ console.error('QUEUE:', queueName);
59
+ console.error('MESSAGE:', message);
60
+ return;
61
+ }
62
+ await _channel.assertQueue(queueName, { durable: true });
63
+ _channel.sendToQueue(queueName, Buffer.from(JSON.stringify(message)));
64
+ };
65
+ return {
66
+ init,
67
+ listenQueue,
68
+ sendMessage,
69
+ };
70
+ })();
@@ -0,0 +1,12 @@
1
+ import { MessageBrokerRefreshCache } from '../message-broker-refresh-cache/index.js';
2
+ import { MessageBrokerQueueName } from '../message-broker-queue-name/index.js';
3
+ import { MESSAGE_BROKER_CONFIG } from './config.js';
4
+ import { CustomError } from '../../../error/index.js';
5
+ export type MessageBroker = {
6
+ [key in MessageBrokerQueueName]: TypeMap[(typeof MESSAGE_BROKER_CONFIG)[key]];
7
+ };
8
+ interface TypeMap {
9
+ 'MessageBrokerRefreshCache | null': MessageBrokerRefreshCache | null;
10
+ CustomError: CustomError;
11
+ }
12
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './type.js';
@@ -0,0 +1 @@
1
+ export * from './type.js';
@@ -0,0 +1,2 @@
1
+ import { MESSAGE_BROKER_CONFIG } from '../message-broker/config.js';
2
+ export type MessageBrokerQueueName = keyof typeof MESSAGE_BROKER_CONFIG;
@@ -0,0 +1,2 @@
1
+ export * from './type.js';
2
+ export * from './refresh-cache/index.js';
@@ -0,0 +1,2 @@
1
+ export * from './type.js';
2
+ export * from './refresh-cache/index.js';
@@ -0,0 +1,2 @@
1
+ import { CacheKey } from '../../../cache/index.js';
2
+ export type RefreshCache = (cacheKeys?: CacheKey[]) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import { RefreshCache } from './type.js';
2
+ export declare const refreshCache: RefreshCache;
@@ -0,0 +1,6 @@
1
+ import { MessageBrokerSingleton } from '../../message-broker/index.js';
2
+ export const refreshCache = (cacheKeys) => MessageBrokerSingleton.sendMessage('cache-service:refresh-cache', cacheKeys
3
+ ? {
4
+ cacheKeys,
5
+ }
6
+ : null);
@@ -0,0 +1,4 @@
1
+ import { CacheKey } from '../../cache/index.js';
2
+ export type MessageBrokerRefreshCache = {
3
+ cacheKeys: CacheKey[];
4
+ };