chatbot-nc 2.0.83 → 2.0.84

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 (187) hide show
  1. package/dist/cjs/aws/index.d.ts +179 -0
  2. package/dist/cjs/aws/index.js +52 -0
  3. package/dist/cjs/aws/index.js.map +1 -0
  4. package/dist/cjs/aws/services/AESEncryptionUsingKMS.d.ts +4 -0
  5. package/dist/cjs/aws/services/AESEncryptionUsingKMS.js +101 -0
  6. package/dist/cjs/aws/services/AESEncryptionUsingKMS.js.map +1 -0
  7. package/dist/cjs/aws/services/AWSChimeMeeting.d.ts +8 -0
  8. package/dist/cjs/aws/services/AWSChimeMeeting.js +99 -0
  9. package/dist/cjs/aws/services/AWSChimeMeeting.js.map +1 -0
  10. package/dist/cjs/aws/services/AWSCodepipeline.d.ts +16 -0
  11. package/dist/cjs/aws/services/AWSCodepipeline.js +43 -0
  12. package/dist/cjs/aws/services/AWSCodepipeline.js.map +1 -0
  13. package/dist/cjs/aws/services/AWSComprehend.d.ts +3 -0
  14. package/dist/cjs/aws/services/AWSComprehend.js +30 -0
  15. package/dist/cjs/aws/services/AWSComprehend.js.map +1 -0
  16. package/dist/cjs/aws/services/AWSConnect.d.ts +296 -0
  17. package/dist/cjs/aws/services/AWSConnect.js +865 -0
  18. package/dist/cjs/aws/services/AWSConnect.js.map +1 -0
  19. package/dist/cjs/aws/services/AWSConnectCases.d.ts +7 -0
  20. package/dist/cjs/aws/services/AWSConnectCases.js +81 -0
  21. package/dist/cjs/aws/services/AWSConnectCases.js.map +1 -0
  22. package/dist/cjs/aws/services/AWSConnectParticipant.d.ts +7 -0
  23. package/dist/cjs/aws/services/AWSConnectParticipant.js +87 -0
  24. package/dist/cjs/aws/services/AWSConnectParticipant.js.map +1 -0
  25. package/dist/cjs/aws/services/AWSCustomerProfiles.d.ts +5 -0
  26. package/dist/cjs/aws/services/AWSCustomerProfiles.js +45 -0
  27. package/dist/cjs/aws/services/AWSCustomerProfiles.js.map +1 -0
  28. package/dist/cjs/aws/services/AWSDynamoDb.d.ts +6 -0
  29. package/dist/cjs/aws/services/AWSDynamoDb.js +77 -0
  30. package/dist/cjs/aws/services/AWSDynamoDb.js.map +1 -0
  31. package/dist/cjs/aws/services/AWSGateway.d.ts +5 -0
  32. package/dist/cjs/aws/services/AWSGateway.js +45 -0
  33. package/dist/cjs/aws/services/AWSGateway.js.map +1 -0
  34. package/dist/cjs/aws/services/AWSGatewayManagement.d.ts +5 -0
  35. package/dist/cjs/aws/services/AWSGatewayManagement.js +49 -0
  36. package/dist/cjs/aws/services/AWSGatewayManagement.js.map +1 -0
  37. package/dist/cjs/aws/services/AWSLambda.d.ts +3 -0
  38. package/dist/cjs/aws/services/AWSLambda.js +25 -0
  39. package/dist/cjs/aws/services/AWSLambda.js.map +1 -0
  40. package/dist/cjs/aws/services/AWSLexModel.d.ts +24 -0
  41. package/dist/cjs/aws/services/AWSLexModel.js +387 -0
  42. package/dist/cjs/aws/services/AWSLexModel.js.map +1 -0
  43. package/dist/cjs/aws/services/AWSLexRuntime.d.ts +5 -0
  44. package/dist/cjs/aws/services/AWSLexRuntime.js +47 -0
  45. package/dist/cjs/aws/services/AWSLexRuntime.js.map +1 -0
  46. package/dist/cjs/aws/services/AWSPinpoint.d.ts +6 -0
  47. package/dist/cjs/aws/services/AWSPinpoint.js +65 -0
  48. package/dist/cjs/aws/services/AWSPinpoint.js.map +1 -0
  49. package/dist/cjs/aws/services/AWSPinpointSMSVoice.d.ts +9 -0
  50. package/dist/cjs/aws/services/AWSPinpointSMSVoice.js +111 -0
  51. package/dist/cjs/aws/services/AWSPinpointSMSVoice.js.map +1 -0
  52. package/dist/cjs/aws/services/AWSQConnect.d.ts +9 -0
  53. package/dist/cjs/aws/services/AWSQConnect.js +118 -0
  54. package/dist/cjs/aws/services/AWSQConnect.js.map +1 -0
  55. package/dist/cjs/aws/services/AWSS3.d.ts +11 -0
  56. package/dist/cjs/aws/services/AWSS3.js +186 -0
  57. package/dist/cjs/aws/services/AWSS3.js.map +1 -0
  58. package/dist/cjs/aws/services/AWSSES.d.ts +4 -0
  59. package/dist/cjs/aws/services/AWSSES.js +23 -0
  60. package/dist/cjs/aws/services/AWSSES.js.map +1 -0
  61. package/dist/cjs/aws/services/AWSSNS.d.ts +12 -0
  62. package/dist/cjs/aws/services/AWSSNS.js +73 -0
  63. package/dist/cjs/aws/services/AWSSNS.js.map +1 -0
  64. package/dist/cjs/aws/services/AWSSSM.d.ts +4 -0
  65. package/dist/cjs/aws/services/AWSSSM.js +82 -0
  66. package/dist/cjs/aws/services/AWSSSM.js.map +1 -0
  67. package/dist/cjs/aws/services/AWSSTS.d.ts +4 -0
  68. package/dist/cjs/aws/services/AWSSTS.js +28 -0
  69. package/dist/cjs/aws/services/AWSSTS.js.map +1 -0
  70. package/dist/cjs/aws/services/AWSTranslate.d.ts +4 -0
  71. package/dist/cjs/aws/services/AWSTranslate.js +27 -0
  72. package/dist/cjs/aws/services/AWSTranslate.js.map +1 -0
  73. package/dist/cjs/communication/communicationService.d.ts +20 -0
  74. package/dist/cjs/communication/communicationService.js +283 -0
  75. package/dist/cjs/communication/communicationService.js.map +1 -0
  76. package/dist/cjs/communication/index.d.ts +49 -0
  77. package/dist/cjs/communication/index.js +219 -0
  78. package/dist/cjs/communication/index.js.map +1 -0
  79. package/dist/cjs/config/SSMParameters.d.ts +26 -0
  80. package/dist/cjs/config/SSMParameters.js +34 -0
  81. package/dist/cjs/config/SSMParameters.js.map +1 -0
  82. package/dist/cjs/enum/index.d.ts +236 -0
  83. package/dist/cjs/enum/index.js +289 -0
  84. package/dist/cjs/enum/index.js.map +1 -0
  85. package/dist/cjs/hashing/idObfuscation.d.ts +20 -0
  86. package/dist/cjs/hashing/idObfuscation.js +56 -0
  87. package/dist/cjs/hashing/idObfuscation.js.map +1 -0
  88. package/dist/cjs/hashing/index.d.ts +33 -0
  89. package/dist/cjs/hashing/index.js +192 -0
  90. package/dist/cjs/hashing/index.js.map +1 -0
  91. package/dist/cjs/index.d.ts +12 -0
  92. package/dist/cjs/index.js +52 -0
  93. package/dist/cjs/index.js.map +1 -0
  94. package/dist/cjs/logger/index.d.ts +3 -0
  95. package/dist/cjs/logger/index.js +70 -0
  96. package/dist/cjs/logger/index.js.map +1 -0
  97. package/dist/cjs/logger/loggerTransports.d.ts +11 -0
  98. package/dist/cjs/logger/loggerTransports.js +72 -0
  99. package/dist/cjs/logger/loggerTransports.js.map +1 -0
  100. package/dist/cjs/repository/dynamodb.d.ts +121 -0
  101. package/dist/cjs/repository/dynamodb.js +696 -0
  102. package/dist/cjs/repository/dynamodb.js.map +1 -0
  103. package/dist/cjs/shortner/index.d.ts +4 -0
  104. package/dist/cjs/shortner/index.js +34 -0
  105. package/dist/cjs/shortner/index.js.map +1 -0
  106. package/dist/cjs/utils/common.d.ts +7 -0
  107. package/dist/cjs/utils/common.js +199 -0
  108. package/dist/cjs/utils/common.js.map +1 -0
  109. package/dist/cjs/utils/date-format.d.ts +16 -0
  110. package/dist/cjs/utils/date-format.js +282 -0
  111. package/dist/cjs/utils/date-format.js.map +1 -0
  112. package/dist/cjs/utils/index.d.ts +37 -0
  113. package/dist/cjs/utils/index.js +12 -0
  114. package/dist/cjs/utils/index.js.map +1 -0
  115. package/dist/cjs/utils/intent.d.ts +12 -0
  116. package/dist/cjs/utils/intent.js +205 -0
  117. package/dist/cjs/utils/intent.js.map +1 -0
  118. package/dist/cjs/webbookEvent/index.d.ts +22 -0
  119. package/dist/cjs/webbookEvent/index.js +151 -0
  120. package/dist/cjs/webbookEvent/index.js.map +1 -0
  121. package/dist/esm/aws/index.d.ts +1 -0
  122. package/dist/esm/aws/services/AESEncryptionUsingKMS.js +20 -11
  123. package/dist/esm/aws/services/AESEncryptionUsingKMS.js.map +1 -1
  124. package/dist/esm/aws/services/AWSChimeMeeting.js +24 -15
  125. package/dist/esm/aws/services/AWSChimeMeeting.js.map +1 -1
  126. package/dist/esm/aws/services/AWSCodepipeline.js +34 -21
  127. package/dist/esm/aws/services/AWSCodepipeline.js.map +1 -1
  128. package/dist/esm/aws/services/AWSComprehend.js +12 -3
  129. package/dist/esm/aws/services/AWSComprehend.js.map +1 -1
  130. package/dist/esm/aws/services/AWSConnect.js +144 -135
  131. package/dist/esm/aws/services/AWSConnect.js.map +1 -1
  132. package/dist/esm/aws/services/AWSConnectCases.js +21 -12
  133. package/dist/esm/aws/services/AWSConnectCases.js.map +1 -1
  134. package/dist/esm/aws/services/AWSConnectParticipant.js +21 -12
  135. package/dist/esm/aws/services/AWSConnectParticipant.js.map +1 -1
  136. package/dist/esm/aws/services/AWSCustomerProfiles.js +15 -6
  137. package/dist/esm/aws/services/AWSCustomerProfiles.js.map +1 -1
  138. package/dist/esm/aws/services/AWSDynamoDb.js +18 -9
  139. package/dist/esm/aws/services/AWSDynamoDb.js.map +1 -1
  140. package/dist/esm/aws/services/AWSGateway.js +15 -6
  141. package/dist/esm/aws/services/AWSGateway.js.map +1 -1
  142. package/dist/esm/aws/services/AWSGatewayManagement.js +15 -6
  143. package/dist/esm/aws/services/AWSGatewayManagement.js.map +1 -1
  144. package/dist/esm/aws/services/AWSLambda.js +13 -4
  145. package/dist/esm/aws/services/AWSLambda.js.map +1 -1
  146. package/dist/esm/aws/services/AWSLexModel.js +72 -63
  147. package/dist/esm/aws/services/AWSLexModel.js.map +1 -1
  148. package/dist/esm/aws/services/AWSLexRuntime.js +15 -6
  149. package/dist/esm/aws/services/AWSLexRuntime.js.map +1 -1
  150. package/dist/esm/aws/services/AWSPinpoint.js +18 -9
  151. package/dist/esm/aws/services/AWSPinpoint.js.map +1 -1
  152. package/dist/esm/aws/services/AWSPinpointSMSVoice.js +27 -18
  153. package/dist/esm/aws/services/AWSPinpointSMSVoice.js.map +1 -1
  154. package/dist/esm/aws/services/AWSQConnect.js +27 -18
  155. package/dist/esm/aws/services/AWSQConnect.js.map +1 -1
  156. package/dist/esm/aws/services/AWSS3.js +37 -28
  157. package/dist/esm/aws/services/AWSS3.js.map +1 -1
  158. package/dist/esm/aws/services/AWSSES.js +13 -4
  159. package/dist/esm/aws/services/AWSSES.js.map +1 -1
  160. package/dist/esm/aws/services/AWSSNS.js +20 -11
  161. package/dist/esm/aws/services/AWSSNS.js.map +1 -1
  162. package/dist/esm/aws/services/AWSSSM.d.ts +1 -0
  163. package/dist/esm/aws/services/AWSSSM.js +50 -3
  164. package/dist/esm/aws/services/AWSSSM.js.map +1 -1
  165. package/dist/esm/aws/services/AWSSTS.js +12 -3
  166. package/dist/esm/aws/services/AWSSTS.js.map +1 -1
  167. package/dist/esm/aws/services/AWSTranslate.js +12 -3
  168. package/dist/esm/aws/services/AWSTranslate.js.map +1 -1
  169. package/dist/esm/communication/communicationService.js +38 -29
  170. package/dist/esm/communication/communicationService.js.map +1 -1
  171. package/dist/esm/communication/index.js +148 -125
  172. package/dist/esm/communication/index.js.map +1 -1
  173. package/dist/esm/hashing/idObfuscation.js +43 -28
  174. package/dist/esm/hashing/idObfuscation.js.map +1 -1
  175. package/dist/esm/hashing/index.js +168 -141
  176. package/dist/esm/hashing/index.js.map +1 -1
  177. package/dist/esm/repository/dynamodb.js +398 -369
  178. package/dist/esm/repository/dynamodb.js.map +1 -1
  179. package/dist/esm/shortner/index.js +31 -20
  180. package/dist/esm/shortner/index.js.map +1 -1
  181. package/dist/esm/utils/common.js +11 -2
  182. package/dist/esm/utils/common.js.map +1 -1
  183. package/dist/esm/utils/intent.js +33 -24
  184. package/dist/esm/utils/intent.js.map +1 -1
  185. package/dist/esm/webbookEvent/index.js +128 -105
  186. package/dist/esm/webbookEvent/index.js.map +1 -1
  187. package/package.json +5 -4
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; // ES Modules import
2
11
  import { DynamoDBDocumentClient, ScanCommand, QueryCommand, PutCommand, UpdateCommand, DeleteCommand, GetCommand, BatchWriteCommand } from "@aws-sdk/lib-dynamodb";
3
12
  const awsRegion = process.env.AWS_DEFAULT_REGION || 'us-east-1';
@@ -18,49 +27,53 @@ export default class BaseDynamoDBRepository {
18
27
  * Add item in DynamoDB table
19
28
  * @param {object} item // Object containing add for target item
20
29
  */
21
- async add(item) {
22
- try {
23
- item = this.parseDate(item);
24
- var params = {
25
- TableName: this.TABLE_NAME,
26
- Item: Object.assign({}, item)
27
- };
28
- if (!("createdAt" in params.Item))
29
- params.Item.createdAt = Number(Date.now());
30
- if (!("updatedAt" in params.Item))
31
- params.Item.updatedAt = Number(Date.now());
32
- const response = await this.documentClient.send(new PutCommand(params));
33
- console.log('dbItem');
34
- return response;
35
- }
36
- catch (error) {
37
- this.handleError(error);
38
- // // throw new DatabaseException( error.code );
39
- }
30
+ add(item) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ try {
33
+ item = this.parseDate(item);
34
+ var params = {
35
+ TableName: this.TABLE_NAME,
36
+ Item: Object.assign({}, item)
37
+ };
38
+ if (!("createdAt" in params.Item))
39
+ params.Item.createdAt = Number(Date.now());
40
+ if (!("updatedAt" in params.Item))
41
+ params.Item.updatedAt = Number(Date.now());
42
+ const response = yield this.documentClient.send(new PutCommand(params));
43
+ console.log('dbItem');
44
+ return response;
45
+ }
46
+ catch (error) {
47
+ this.handleError(error);
48
+ // // throw new DatabaseException( error.code );
49
+ }
50
+ });
40
51
  }
41
52
  /**
42
53
  * Update item in DynamoDB table
43
54
  * @param {object} key // Object containing target item key(s)
44
55
  * @param {object} item // Object containing updates for target item
45
56
  */
46
- async update(key, item) {
47
- try {
48
- const itemKeys = Object.keys(item).filter(k => k !== key);
49
- const params = {
50
- TableName: this.TABLE_NAME,
51
- UpdateExpression: `SET ${itemKeys.map((k, index) => `#field${index} = :value${index}`).join(', ')}`,
52
- ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
53
- ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] })), {}),
54
- Key: {
55
- [key]: item[key]
56
- },
57
- ReturnValues: 'ALL_NEW'
58
- };
59
- return await this.documentClient.send(new UpdateCommand(params));
60
- }
61
- catch (error) {
62
- this.handleError(error);
63
- }
57
+ update(key, item) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ try {
60
+ const itemKeys = Object.keys(item).filter(k => k !== key);
61
+ const params = {
62
+ TableName: this.TABLE_NAME,
63
+ UpdateExpression: `SET ${itemKeys.map((k, index) => `#field${index} = :value${index}`).join(', ')}`,
64
+ ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
65
+ ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] })), {}),
66
+ Key: {
67
+ [key]: item[key]
68
+ },
69
+ ReturnValues: 'ALL_NEW'
70
+ };
71
+ return yield this.documentClient.send(new UpdateCommand(params));
72
+ }
73
+ catch (error) {
74
+ this.handleError(error);
75
+ }
76
+ });
64
77
  }
65
78
  /**
66
79
  * Update item in DynamoDB table
@@ -68,27 +81,29 @@ export default class BaseDynamoDBRepository {
68
81
  * @param {object} item // Object containing updates for target item
69
82
  * @returns
70
83
  */
71
- async updateByMutiple(keys, item) {
72
- try {
73
- // const itemKeys = Object.keys(item).filter(k => !key.includes(k));
74
- const itemKeys = Object.keys(item).filter(k => !keys.includes(k));
75
- const keyItem = Object.keys(item).filter(k => keys.includes(k));
76
- const params = {
77
- TableName: this.TABLE_NAME,
78
- UpdateExpression: `SET ${itemKeys.map((k, index) => `#field${index} = :value${index}`).join(', ')}`,
79
- ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
80
- ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] })), {}),
81
- Key: keyItem.reduce((obj, key) => {
82
- obj[key] = item[key];
83
- return obj;
84
- }, {}),
85
- ReturnValues: 'ALL_NEW'
86
- };
87
- return await this.documentClient.send(new UpdateCommand(params));
88
- }
89
- catch (error) {
90
- this.handleError(error);
91
- }
84
+ updateByMutiple(keys, item) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ try {
87
+ // const itemKeys = Object.keys(item).filter(k => !key.includes(k));
88
+ const itemKeys = Object.keys(item).filter(k => !keys.includes(k));
89
+ const keyItem = Object.keys(item).filter(k => keys.includes(k));
90
+ const params = {
91
+ TableName: this.TABLE_NAME,
92
+ UpdateExpression: `SET ${itemKeys.map((k, index) => `#field${index} = :value${index}`).join(', ')}`,
93
+ ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
94
+ ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] })), {}),
95
+ Key: keyItem.reduce((obj, key) => {
96
+ obj[key] = item[key];
97
+ return obj;
98
+ }, {}),
99
+ ReturnValues: 'ALL_NEW'
100
+ };
101
+ return yield this.documentClient.send(new UpdateCommand(params));
102
+ }
103
+ catch (error) {
104
+ this.handleError(error);
105
+ }
106
+ });
92
107
  }
93
108
  /**
94
109
  *
@@ -128,27 +143,29 @@ export default class BaseDynamoDBRepository {
128
143
  * @param {object} id // Object containing target item key(s)
129
144
  * @param {object} version // Object containing updates for target item
130
145
  */
131
- async getById(key) {
132
- console.info("Dynamo db Repository: getById Start");
133
- var params = {
134
- TableName: this.TABLE_NAME,
135
- Key: key
136
- };
137
- try {
138
- console.info("Dynamo db Repository: getById End");
139
- const command = new GetCommand(params);
140
- const response = await this.documentClient.send(command);
141
- if (response && response.Item) {
142
- return this.unparseDate(response.Item);
146
+ getById(key) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ console.info("Dynamo db Repository: getById Start");
149
+ var params = {
150
+ TableName: this.TABLE_NAME,
151
+ Key: key
152
+ };
153
+ try {
154
+ console.info("Dynamo db Repository: getById End");
155
+ const command = new GetCommand(params);
156
+ const response = yield this.documentClient.send(command);
157
+ if (response && response.Item) {
158
+ return this.unparseDate(response.Item);
159
+ }
160
+ return null;
143
161
  }
144
- return null;
145
- }
146
- catch (error) {
147
- console.error(`error occured while getting custom order log by primary keys - customOrderLog - ${error}`);
148
- console.error("Dynamo db Repository: Error: ");
149
- this.handleError(error);
150
- // throw new DatabaseException( error.code );
151
- }
162
+ catch (error) {
163
+ console.error(`error occured while getting custom order log by primary keys - customOrderLog - ${error}`);
164
+ console.error("Dynamo db Repository: Error: ");
165
+ this.handleError(error);
166
+ // throw new DatabaseException( error.code );
167
+ }
168
+ });
152
169
  }
153
170
  /**
154
171
  * Get item in DynamoDB table
@@ -166,198 +183,202 @@ export default class BaseDynamoDBRepository {
166
183
  * Get items in DynamoDB table
167
184
  * @param {object} item // Object containing target item key(s)
168
185
  */
169
- async query(item, condition, indexName, projectionExpression, limit, scanIndexForward = true, exclusiveStartKey) {
170
- console.info("Dynamo db Repository: query Start");
171
- try {
172
- const itemKeys = Object.keys(item);
173
- // let Key, Filter;
174
- // if (!indexName) {
175
- // Key = `${itemKeys.map((k, index) => {
176
- // if (this.PRIMARY_KEY.length === 0 || this.PRIMARY_KEY.includes(k))
177
- // if (!this.isComparator(condition![index] || '='))
178
- // return `${condition![index]}(#field${index} ,:value${index})`
179
- // else
180
- // return `#field${index} ${condition![index] || '='} :value${index}`
181
- // }).filter(a => a).join(' and ')}`;
182
- // Filter = `${itemKeys.map((k, index) => {
183
- // if (!this.PRIMARY_KEY.includes(k))
184
- // if (!this.isComparator(condition![index] || '='))
185
- // if(condition![index].toUpperCase() == 'IN')
186
- // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
187
- // else
188
- // return `${condition![index]}(#field${index} ,:value${index})`
189
- // else
190
- // return `#field${index} ${condition![index] || '='} :value${index}`
191
- // }).filter(a => a).join(' and ')}`;
192
- // }
193
- // else {
194
- // Key = `${itemKeys.map((k, index) => {
195
- // if (indexName.split('-').includes(k)) {
196
- // if (!this.isComparator(condition![index] || '='))
197
- // return `${condition![index]}(#field${index} ,:value${index})`
198
- // else
199
- // return `#field${index} ${condition![index] || '='} :value${index}`
200
- // }
201
- // }).filter(a => a).join(' and ')}`;
202
- // Filter = `${itemKeys.map((k, index) => {
203
- // if (!indexName.split('-').includes(k)) {
204
- // if (!this.isComparator(condition![index] || '='))
205
- // if(condition![index].toUpperCase() == 'IN')
206
- // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
207
- // else
208
- // return `${condition![index]}(#field${index} ,:value${index})`
209
- // else
210
- // return `#field${index} ${condition![index] || '='} :value${index}`
211
- // }
212
- // }).filter(a => a).join(' and ')}`;
213
- // }
214
- let [Key, Filter] = await this.getKeyAndFilter(item, condition, indexName);
215
- let params = {
216
- TableName: this.TABLE_NAME,
217
- ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
218
- ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => {
219
- if (Array.isArray(item[k])) {
220
- let data = this.getArrayValue(item[k], index);
221
- return Object.assign(Object.assign({}, accumulator), data);
222
- }
223
- else
224
- return Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] });
225
- }, {}),
226
- KeyConditionExpression: Key,
227
- ScanIndexForward: scanIndexForward
228
- };
229
- if (exclusiveStartKey)
230
- params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
231
- if (indexName)
232
- params = Object.assign(params, { IndexName: indexName });
233
- if (projectionExpression)
234
- params = Object.assign(params, { ProjectionExpression: projectionExpression });
235
- if (Filter)
236
- params = Object.assign(params, { FilterExpression: Filter });
237
- // if (limit)
238
- // params = Object.assign(params, { Limit:limit});
239
- let response, acc = [];
240
- do {
241
- response = await this.documentClient.send(new QueryCommand(params));
242
- console.info("Repository: query End");
243
- params.ExclusiveStartKey = response.LastEvaluatedKey;
244
- console.log("Last Evaluated Key");
245
- if (limit) {
246
- if (response && response.Items) {
247
- if (response.Items.length <= limit - acc.length)
248
- acc = [...acc, ...response.Items];
186
+ query(item, condition, indexName, projectionExpression, limit, scanIndexForward = true, exclusiveStartKey) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ console.info("Dynamo db Repository: query Start");
189
+ try {
190
+ const itemKeys = Object.keys(item);
191
+ // let Key, Filter;
192
+ // if (!indexName) {
193
+ // Key = `${itemKeys.map((k, index) => {
194
+ // if (this.PRIMARY_KEY.length === 0 || this.PRIMARY_KEY.includes(k))
195
+ // if (!this.isComparator(condition![index] || '='))
196
+ // return `${condition![index]}(#field${index} ,:value${index})`
197
+ // else
198
+ // return `#field${index} ${condition![index] || '='} :value${index}`
199
+ // }).filter(a => a).join(' and ')}`;
200
+ // Filter = `${itemKeys.map((k, index) => {
201
+ // if (!this.PRIMARY_KEY.includes(k))
202
+ // if (!this.isComparator(condition![index] || '='))
203
+ // if(condition![index].toUpperCase() == 'IN')
204
+ // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
205
+ // else
206
+ // return `${condition![index]}(#field${index} ,:value${index})`
207
+ // else
208
+ // return `#field${index} ${condition![index] || '='} :value${index}`
209
+ // }).filter(a => a).join(' and ')}`;
210
+ // }
211
+ // else {
212
+ // Key = `${itemKeys.map((k, index) => {
213
+ // if (indexName.split('-').includes(k)) {
214
+ // if (!this.isComparator(condition![index] || '='))
215
+ // return `${condition![index]}(#field${index} ,:value${index})`
216
+ // else
217
+ // return `#field${index} ${condition![index] || '='} :value${index}`
218
+ // }
219
+ // }).filter(a => a).join(' and ')}`;
220
+ // Filter = `${itemKeys.map((k, index) => {
221
+ // if (!indexName.split('-').includes(k)) {
222
+ // if (!this.isComparator(condition![index] || '='))
223
+ // if(condition![index].toUpperCase() == 'IN')
224
+ // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
225
+ // else
226
+ // return `${condition![index]}(#field${index} ,:value${index})`
227
+ // else
228
+ // return `#field${index} ${condition![index] || '='} :value${index}`
229
+ // }
230
+ // }).filter(a => a).join(' and ')}`;
231
+ // }
232
+ let [Key, Filter] = yield this.getKeyAndFilter(item, condition, indexName);
233
+ let params = {
234
+ TableName: this.TABLE_NAME,
235
+ ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
236
+ ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => {
237
+ if (Array.isArray(item[k])) {
238
+ let data = this.getArrayValue(item[k], index);
239
+ return Object.assign(Object.assign({}, accumulator), data);
240
+ }
249
241
  else
250
- acc = [...acc, ...response.Items.slice(0, limit - acc.length)];
242
+ return Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] });
243
+ }, {}),
244
+ KeyConditionExpression: Key,
245
+ ScanIndexForward: scanIndexForward
246
+ };
247
+ if (exclusiveStartKey)
248
+ params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
249
+ if (indexName)
250
+ params = Object.assign(params, { IndexName: indexName });
251
+ if (projectionExpression)
252
+ params = Object.assign(params, { ProjectionExpression: projectionExpression });
253
+ if (Filter)
254
+ params = Object.assign(params, { FilterExpression: Filter });
255
+ // if (limit)
256
+ // params = Object.assign(params, { Limit:limit});
257
+ let response, acc = [];
258
+ do {
259
+ response = yield this.documentClient.send(new QueryCommand(params));
260
+ console.info("Repository: query End");
261
+ params.ExclusiveStartKey = response.LastEvaluatedKey;
262
+ console.log("Last Evaluated Key");
263
+ if (limit) {
264
+ if (response && response.Items) {
265
+ if (response.Items.length <= limit - acc.length)
266
+ acc = [...acc, ...response.Items];
267
+ else
268
+ acc = [...acc, ...response.Items.slice(0, limit - acc.length)];
269
+ }
251
270
  }
252
- }
253
- else if (response && response.Items)
254
- acc = [...acc, ...response.Items];
255
- } while (response && response.Items && response.LastEvaluatedKey && (!limit || acc.length < limit));
256
- if (acc.length > 0)
257
- return this.unparseDate(acc);
258
- else
259
- return null;
260
- }
261
- catch (error) {
262
- this.handleError(error);
263
- }
271
+ else if (response && response.Items)
272
+ acc = [...acc, ...response.Items];
273
+ } while (response && response.Items && response.LastEvaluatedKey && (!limit || acc.length < limit));
274
+ if (acc.length > 0)
275
+ return this.unparseDate(acc);
276
+ else
277
+ return null;
278
+ }
279
+ catch (error) {
280
+ this.handleError(error);
281
+ }
282
+ });
264
283
  }
265
284
  /**
266
285
  * Get items in DynamoDB table with Pagination
267
286
  * @param {object} item // Object containing target item key(s)
268
287
  */
269
- async queryWithPagination(item, condition, indexName, projectionExpression, limit = 1000, scanIndexForward = true, exclusiveStartKey) {
270
- console.info("Dynamo db Repository: query Start");
271
- try {
272
- const itemKeys = Object.keys(item);
273
- // let Key, Filter;
274
- // if (!indexName) {
275
- // Key = `${itemKeys.map((k, index) => {
276
- // if (this.PRIMARY_KEY.length === 0 || this.PRIMARY_KEY.includes(k))
277
- // if (!this.isComparator(condition![index] || '='))
278
- // return `${condition![index]}(#field${index} ,:value${index})`
279
- // else
280
- // return `#field${index} ${condition![index] || '='} :value${index}`
281
- // }).filter(a => a).join(' and ')}`;
282
- // Filter = `${itemKeys.map((k, index) => {
283
- // if (!this.PRIMARY_KEY.includes(k))
284
- // if (!this.isComparator(condition![index] || '='))
285
- // if(condition![index].toUpperCase() == 'IN')
286
- // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
287
- // else
288
- // return `${condition![index]}(#field${index} ,:value${index})`
289
- // else
290
- // return `#field${index} ${condition![index] || '='} :value${index}`
291
- // }).filter(a => a).join(' and ')}`;
292
- // }
293
- // else {
294
- // Key = `${itemKeys.map((k, index) => {
295
- // if (indexName.split('-').includes(k)) {
296
- // if (!this.isComparator(condition![index] || '='))
297
- // return `${condition![index]}(#field${index} ,:value${index})`
298
- // else
299
- // return `#field${index} ${condition![index] || '='} :value${index}`
300
- // }
301
- // }).filter(a => a).join(' and ')}`;
302
- // Filter = `${itemKeys.map((k, index) => {
303
- // if (!indexName.split('-').includes(k)) {
304
- // if (!this.isComparator(condition![index] || '='))
305
- // if(condition![index].toUpperCase() == 'IN')
306
- // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
307
- // else
308
- // return `${condition![index]}(#field${index} ,:value${index})`
309
- // else
310
- // return `#field${index} ${condition![index] || '='} :value${index}`
311
- // }
312
- // }).filter(a => a).join(' and ')}`;
313
- // }
314
- let [Key, Filter] = await this.getKeyAndFilter(item, condition, indexName);
315
- let params = {
316
- TableName: this.TABLE_NAME,
317
- ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
318
- ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => {
319
- if (Array.isArray(item[k])) {
320
- let data = this.getArrayValue(item[k], index);
321
- return Object.assign(Object.assign({}, accumulator), data);
322
- }
323
- else
324
- return Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] });
325
- }, {}),
326
- KeyConditionExpression: Key,
327
- ScanIndexForward: scanIndexForward
328
- };
329
- if (exclusiveStartKey)
330
- params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
331
- if (indexName)
332
- params = Object.assign(params, { IndexName: indexName });
333
- if (projectionExpression)
334
- params = Object.assign(params, { ProjectionExpression: projectionExpression });
335
- if (Filter)
336
- params = Object.assign(params, { FilterExpression: Filter });
337
- if (limit)
338
- params = Object.assign(params, { Limit: limit });
339
- let response, acc = { exclusiveStartKey: "", data: [] };
340
- do {
341
- response = await this.documentClient.send(new QueryCommand(params));
342
- console.info("Repository: query End");
343
- params.ExclusiveStartKey = response.LastEvaluatedKey;
344
- console.log("Last Evaluated Key");
345
- acc.exclusiveStartKey = response.LastEvaluatedKey;
346
- if (response && response.Items)
347
- acc.data = [...acc.data, ...response.Items];
288
+ queryWithPagination(item, condition, indexName, projectionExpression, limit = 1000, scanIndexForward = true, exclusiveStartKey) {
289
+ return __awaiter(this, void 0, void 0, function* () {
290
+ console.info("Dynamo db Repository: query Start");
291
+ try {
292
+ const itemKeys = Object.keys(item);
293
+ // let Key, Filter;
294
+ // if (!indexName) {
295
+ // Key = `${itemKeys.map((k, index) => {
296
+ // if (this.PRIMARY_KEY.length === 0 || this.PRIMARY_KEY.includes(k))
297
+ // if (!this.isComparator(condition![index] || '='))
298
+ // return `${condition![index]}(#field${index} ,:value${index})`
299
+ // else
300
+ // return `#field${index} ${condition![index] || '='} :value${index}`
301
+ // }).filter(a => a).join(' and ')}`;
302
+ // Filter = `${itemKeys.map((k, index) => {
303
+ // if (!this.PRIMARY_KEY.includes(k))
304
+ // if (!this.isComparator(condition![index] || '='))
305
+ // if(condition![index].toUpperCase() == 'IN')
306
+ // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
307
+ // else
308
+ // return `${condition![index]}(#field${index} ,:value${index})`
309
+ // else
310
+ // return `#field${index} ${condition![index] || '='} :value${index}`
311
+ // }).filter(a => a).join(' and ')}`;
312
+ // }
313
+ // else {
314
+ // Key = `${itemKeys.map((k, index) => {
315
+ // if (indexName.split('-').includes(k)) {
316
+ // if (!this.isComparator(condition![index] || '='))
317
+ // return `${condition![index]}(#field${index} ,:value${index})`
318
+ // else
319
+ // return `#field${index} ${condition![index] || '='} :value${index}`
320
+ // }
321
+ // }).filter(a => a).join(' and ')}`;
322
+ // Filter = `${itemKeys.map((k, index) => {
323
+ // if (!indexName.split('-').includes(k)) {
324
+ // if (!this.isComparator(condition![index] || '='))
325
+ // if(condition![index].toUpperCase() == 'IN')
326
+ // return `#field${index} ${condition![index]}(${Object.keys(this.getArrayValue(item[k],index)).toString()})`
327
+ // else
328
+ // return `${condition![index]}(#field${index} ,:value${index})`
329
+ // else
330
+ // return `#field${index} ${condition![index] || '='} :value${index}`
331
+ // }
332
+ // }).filter(a => a).join(' and ')}`;
333
+ // }
334
+ let [Key, Filter] = yield this.getKeyAndFilter(item, condition, indexName);
335
+ let params = {
336
+ TableName: this.TABLE_NAME,
337
+ ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
338
+ ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => {
339
+ if (Array.isArray(item[k])) {
340
+ let data = this.getArrayValue(item[k], index);
341
+ return Object.assign(Object.assign({}, accumulator), data);
342
+ }
343
+ else
344
+ return Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] });
345
+ }, {}),
346
+ KeyConditionExpression: Key,
347
+ ScanIndexForward: scanIndexForward
348
+ };
349
+ if (exclusiveStartKey)
350
+ params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
351
+ if (indexName)
352
+ params = Object.assign(params, { IndexName: indexName });
353
+ if (projectionExpression)
354
+ params = Object.assign(params, { ProjectionExpression: projectionExpression });
355
+ if (Filter)
356
+ params = Object.assign(params, { FilterExpression: Filter });
348
357
  if (limit)
349
- params.Limit = limit - acc.data.length;
350
- } while (response && response.Items && response.LastEvaluatedKey && acc.data.length < limit);
351
- if (acc.data.length > 0) {
352
- acc.data = this.unparseDate(acc.data);
353
- return acc;
358
+ params = Object.assign(params, { Limit: limit });
359
+ let response, acc = { exclusiveStartKey: "", data: [] };
360
+ do {
361
+ response = yield this.documentClient.send(new QueryCommand(params));
362
+ console.info("Repository: query End");
363
+ params.ExclusiveStartKey = response.LastEvaluatedKey;
364
+ console.log("Last Evaluated Key");
365
+ acc.exclusiveStartKey = response.LastEvaluatedKey;
366
+ if (response && response.Items)
367
+ acc.data = [...acc.data, ...response.Items];
368
+ if (limit)
369
+ params.Limit = limit - acc.data.length;
370
+ } while (response && response.Items && response.LastEvaluatedKey && acc.data.length < limit);
371
+ if (acc.data.length > 0) {
372
+ acc.data = this.unparseDate(acc.data);
373
+ return acc;
374
+ }
375
+ else
376
+ return null;
354
377
  }
355
- else
356
- return null;
357
- }
358
- catch (error) {
359
- this.handleError(error);
360
- }
378
+ catch (error) {
379
+ this.handleError(error);
380
+ }
381
+ });
361
382
  }
362
383
  /**
363
384
  * Get items in DynamoDB table
@@ -365,129 +386,137 @@ export default class BaseDynamoDBRepository {
365
386
  * @param {Array} condition // Array containing target item key(s) condition
366
387
  * @param {String} projectionExpression // if you want only selected filed should return
367
388
  */
368
- async scan(item, condition, projectionExpression, exclusiveStartKey) {
369
- console.info("Dynamo db Repository: query Start");
370
- try {
371
- const itemKeys = Object.keys(item);
372
- const Key = `${itemKeys.map((k, index) => `#field${index} ${condition[index]} :value${index}`).join(' and ')}`;
373
- let params = {
374
- TableName: this.TABLE_NAME,
375
- ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
376
- ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] })), {}),
377
- FilterExpression: Key
378
- };
379
- if (projectionExpression)
380
- params = Object.assign(params, { ProjectionExpression: projectionExpression });
381
- if (exclusiveStartKey)
382
- params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
383
- let response, acc = [];
384
- do {
385
- response = await this.documentClient.send(new ScanCommand(params));
386
- console.info("Repository: query End");
387
- params.ExclusiveStartKey = response.LastEvaluatedKey;
388
- console.log("Last Evaluated Key");
389
- if (response && response.Items)
390
- acc = [...acc, ...response.Items];
391
- } while (response && response.Items && response.LastEvaluatedKey);
392
- if (acc.length > 0)
393
- return this.unparseDate(acc);
394
- else
395
- return null;
396
- }
397
- catch (error) {
398
- this.handleError(error);
399
- }
389
+ scan(item, condition, projectionExpression, exclusiveStartKey) {
390
+ return __awaiter(this, void 0, void 0, function* () {
391
+ console.info("Dynamo db Repository: query Start");
392
+ try {
393
+ const itemKeys = Object.keys(item);
394
+ const Key = `${itemKeys.map((k, index) => `#field${index} ${condition[index]} :value${index}`).join(' and ')}`;
395
+ let params = {
396
+ TableName: this.TABLE_NAME,
397
+ ExpressionAttributeNames: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`#field${index}`]: k })), {}),
398
+ ExpressionAttributeValues: itemKeys.reduce((accumulator, k, index) => (Object.assign(Object.assign({}, accumulator), { [`:value${index}`]: item[k] })), {}),
399
+ FilterExpression: Key
400
+ };
401
+ if (projectionExpression)
402
+ params = Object.assign(params, { ProjectionExpression: projectionExpression });
403
+ if (exclusiveStartKey)
404
+ params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
405
+ let response, acc = [];
406
+ do {
407
+ response = yield this.documentClient.send(new ScanCommand(params));
408
+ console.info("Repository: query End");
409
+ params.ExclusiveStartKey = response.LastEvaluatedKey;
410
+ console.log("Last Evaluated Key");
411
+ if (response && response.Items)
412
+ acc = [...acc, ...response.Items];
413
+ } while (response && response.Items && response.LastEvaluatedKey);
414
+ if (acc.length > 0)
415
+ return this.unparseDate(acc);
416
+ else
417
+ return null;
418
+ }
419
+ catch (error) {
420
+ this.handleError(error);
421
+ }
422
+ });
400
423
  }
401
424
  /**
402
425
  * Delete item in DynamoDB table
403
426
  * @param {object} key // Object containing target item key(s)
404
427
  */
405
- async delete(key) {
406
- console.info("Dynamo db Repository: delete Start");
407
- var params = {
408
- TableName: this.TABLE_NAME,
409
- Key: key
410
- };
411
- try {
412
- const command = new DeleteCommand(params);
413
- const data = await this.documentClient.send(command);
414
- console.info("Dynamo db Repository: delete End");
415
- }
416
- catch (error) {
417
- console.error(`error occured while deleting custom order log by primary keys - customOrderLog - ${error}`);
418
- console.error("Dynamo db Repository: Error: ");
419
- this.handleError(error);
420
- // throw new DatabaseException( error.code );
421
- }
428
+ delete(key) {
429
+ return __awaiter(this, void 0, void 0, function* () {
430
+ console.info("Dynamo db Repository: delete Start");
431
+ var params = {
432
+ TableName: this.TABLE_NAME,
433
+ Key: key
434
+ };
435
+ try {
436
+ const command = new DeleteCommand(params);
437
+ const data = yield this.documentClient.send(command);
438
+ console.info("Dynamo db Repository: delete End");
439
+ }
440
+ catch (error) {
441
+ console.error(`error occured while deleting custom order log by primary keys - customOrderLog - ${error}`);
442
+ console.error("Dynamo db Repository: Error: ");
443
+ this.handleError(error);
444
+ // throw new DatabaseException( error.code );
445
+ }
446
+ });
422
447
  }
423
448
  /**
424
449
  * Get All items in DynamoDB table
425
450
  */
426
- async getAll(exclusiveStartKey) {
427
- var params = {
428
- TableName: this.TABLE_NAME
429
- };
430
- try {
431
- console.info("Dynamo Repository: getAll Start");
432
- if (exclusiveStartKey)
433
- params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
434
- let response, acc = [];
435
- do {
436
- response = await this.documentClient.send(new ScanCommand(params));
437
- console.info("Repository: query End");
438
- params.ExclusiveStartKey = response.LastEvaluatedKey;
439
- console.log("Last Evaluated Key");
440
- if (response && response.Items)
441
- acc = [...acc, ...response.Items];
442
- } while (response && response.Items && response.LastEvaluatedKey);
443
- console.info("Dynamo db Repository: getAll End");
444
- return this.unparseDate(acc);
445
- }
446
- catch (error) {
447
- console.error(`error occured while get all custom order log by primary keys - customOrderLog - ${error}`);
448
- console.error("Dynamo db Repository: Error: ");
449
- this.handleError(error);
450
- // throw new DatabaseException( error.code );
451
- }
451
+ getAll(exclusiveStartKey) {
452
+ return __awaiter(this, void 0, void 0, function* () {
453
+ var params = {
454
+ TableName: this.TABLE_NAME
455
+ };
456
+ try {
457
+ console.info("Dynamo Repository: getAll Start");
458
+ if (exclusiveStartKey)
459
+ params = Object.assign(params, { ExclusiveStartKey: exclusiveStartKey });
460
+ let response, acc = [];
461
+ do {
462
+ response = yield this.documentClient.send(new ScanCommand(params));
463
+ console.info("Repository: query End");
464
+ params.ExclusiveStartKey = response.LastEvaluatedKey;
465
+ console.log("Last Evaluated Key");
466
+ if (response && response.Items)
467
+ acc = [...acc, ...response.Items];
468
+ } while (response && response.Items && response.LastEvaluatedKey);
469
+ console.info("Dynamo db Repository: getAll End");
470
+ return this.unparseDate(acc);
471
+ }
472
+ catch (error) {
473
+ console.error(`error occured while get all custom order log by primary keys - customOrderLog - ${error}`);
474
+ console.error("Dynamo db Repository: Error: ");
475
+ this.handleError(error);
476
+ // throw new DatabaseException( error.code );
477
+ }
478
+ });
452
479
  }
453
480
  /**
454
481
  * Bulk Upload item in DynamoDB table
455
482
  * @param {object} item // Object containing add for target item
456
483
  */
457
- async bulkUpload(items) {
458
- try {
459
- let insertItem = await Promise.all(items.map(async (item) => {
460
- item = this.parseDate(item);
461
- return item;
462
- // return {PutRequest:{Item:item}};
463
- }));
464
- // chunkArray is a local convenience function. It takes an array and returns
465
- // a generator function. The generator function yields every N items.
466
- const itemChunks = [...Array(Math.ceil(insertItem.length / 25))].map(_ => insertItem.splice(0, 25));
467
- // For every chunk of 25 items, make one BatchWrite request.
468
- for (const chunk of itemChunks) {
469
- const putRequests = chunk.map((data) => ({
470
- PutRequest: {
471
- Item: data,
472
- },
473
- }));
474
- const command = new BatchWriteCommand({
475
- RequestItems: {
476
- // An existing table is required. A composite key of 'title' and 'year' is recommended
477
- // to account for duplicate titles.
478
- [this.TABLE_NAME]: putRequests
479
- }
480
- });
481
- const response = await this.documentClient.send(command);
482
- console.log('dbItem');
484
+ bulkUpload(items) {
485
+ return __awaiter(this, void 0, void 0, function* () {
486
+ try {
487
+ let insertItem = yield Promise.all(items.map((item) => __awaiter(this, void 0, void 0, function* () {
488
+ item = this.parseDate(item);
489
+ return item;
490
+ // return {PutRequest:{Item:item}};
491
+ })));
492
+ // chunkArray is a local convenience function. It takes an array and returns
493
+ // a generator function. The generator function yields every N items.
494
+ const itemChunks = [...Array(Math.ceil(insertItem.length / 25))].map(_ => insertItem.splice(0, 25));
495
+ // For every chunk of 25 items, make one BatchWrite request.
496
+ for (const chunk of itemChunks) {
497
+ const putRequests = chunk.map((data) => ({
498
+ PutRequest: {
499
+ Item: data,
500
+ },
501
+ }));
502
+ const command = new BatchWriteCommand({
503
+ RequestItems: {
504
+ // An existing table is required. A composite key of 'title' and 'year' is recommended
505
+ // to account for duplicate titles.
506
+ [this.TABLE_NAME]: putRequests
507
+ }
508
+ });
509
+ const response = yield this.documentClient.send(command);
510
+ console.log('dbItem');
511
+ }
512
+ console.log("Upload Successfully");
513
+ return true;
483
514
  }
484
- console.log("Upload Successfully");
485
- return true;
486
- }
487
- catch (error) {
488
- this.handleError(error);
489
- // // throw new DatabaseException( error.code );
490
- }
515
+ catch (error) {
516
+ this.handleError(error);
517
+ // // throw new DatabaseException( error.code );
518
+ }
519
+ });
491
520
  }
492
521
  /**
493
522
  *