chatbot-nc 2.0.80 → 2.0.83

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/dist/esm/aws/services/AESEncryptionUsingKMS.js +11 -20
  2. package/dist/esm/aws/services/AESEncryptionUsingKMS.js.map +1 -1
  3. package/dist/esm/aws/services/AWSChimeMeeting.js +15 -24
  4. package/dist/esm/aws/services/AWSChimeMeeting.js.map +1 -1
  5. package/dist/esm/aws/services/AWSCodepipeline.js +21 -34
  6. package/dist/esm/aws/services/AWSCodepipeline.js.map +1 -1
  7. package/dist/esm/aws/services/AWSComprehend.js +3 -12
  8. package/dist/esm/aws/services/AWSComprehend.js.map +1 -1
  9. package/dist/esm/aws/services/AWSConnect.js +135 -146
  10. package/dist/esm/aws/services/AWSConnect.js.map +1 -1
  11. package/dist/esm/aws/services/AWSConnectCases.js +12 -21
  12. package/dist/esm/aws/services/AWSConnectCases.js.map +1 -1
  13. package/dist/esm/aws/services/AWSConnectParticipant.js +12 -21
  14. package/dist/esm/aws/services/AWSConnectParticipant.js.map +1 -1
  15. package/dist/esm/aws/services/AWSCustomerProfiles.js +6 -15
  16. package/dist/esm/aws/services/AWSCustomerProfiles.js.map +1 -1
  17. package/dist/esm/aws/services/AWSDynamoDb.js +9 -18
  18. package/dist/esm/aws/services/AWSDynamoDb.js.map +1 -1
  19. package/dist/esm/aws/services/AWSGateway.js +6 -15
  20. package/dist/esm/aws/services/AWSGateway.js.map +1 -1
  21. package/dist/esm/aws/services/AWSGatewayManagement.js +6 -15
  22. package/dist/esm/aws/services/AWSGatewayManagement.js.map +1 -1
  23. package/dist/esm/aws/services/AWSLambda.js +4 -13
  24. package/dist/esm/aws/services/AWSLambda.js.map +1 -1
  25. package/dist/esm/aws/services/AWSLexModel.js +63 -72
  26. package/dist/esm/aws/services/AWSLexModel.js.map +1 -1
  27. package/dist/esm/aws/services/AWSLexRuntime.js +6 -15
  28. package/dist/esm/aws/services/AWSLexRuntime.js.map +1 -1
  29. package/dist/esm/aws/services/AWSPinpoint.js +9 -18
  30. package/dist/esm/aws/services/AWSPinpoint.js.map +1 -1
  31. package/dist/esm/aws/services/AWSPinpointSMSVoice.js +18 -27
  32. package/dist/esm/aws/services/AWSPinpointSMSVoice.js.map +1 -1
  33. package/dist/esm/aws/services/AWSQConnect.js +18 -27
  34. package/dist/esm/aws/services/AWSQConnect.js.map +1 -1
  35. package/dist/esm/aws/services/AWSS3.js +28 -37
  36. package/dist/esm/aws/services/AWSS3.js.map +1 -1
  37. package/dist/esm/aws/services/AWSSES.js +4 -13
  38. package/dist/esm/aws/services/AWSSES.js.map +1 -1
  39. package/dist/esm/aws/services/AWSSNS.js +11 -20
  40. package/dist/esm/aws/services/AWSSNS.js.map +1 -1
  41. package/dist/esm/aws/services/AWSSSM.js +3 -12
  42. package/dist/esm/aws/services/AWSSSM.js.map +1 -1
  43. package/dist/esm/aws/services/AWSSTS.js +3 -12
  44. package/dist/esm/aws/services/AWSSTS.js.map +1 -1
  45. package/dist/esm/aws/services/AWSTranslate.js +3 -12
  46. package/dist/esm/aws/services/AWSTranslate.js.map +1 -1
  47. package/dist/esm/communication/communicationService.js +29 -38
  48. package/dist/esm/communication/communicationService.js.map +1 -1
  49. package/dist/esm/communication/index.js +125 -148
  50. package/dist/esm/communication/index.js.map +1 -1
  51. package/dist/esm/enum/index.d.ts +4 -1
  52. package/dist/esm/enum/index.js +3 -0
  53. package/dist/esm/enum/index.js.map +1 -1
  54. package/dist/esm/hashing/idObfuscation.js +29 -43
  55. package/dist/esm/hashing/idObfuscation.js.map +1 -1
  56. package/dist/esm/hashing/index.js +141 -168
  57. package/dist/esm/hashing/index.js.map +1 -1
  58. package/dist/esm/repository/dynamodb.js +369 -398
  59. package/dist/esm/repository/dynamodb.js.map +1 -1
  60. package/dist/esm/shortner/index.js +20 -31
  61. package/dist/esm/shortner/index.js.map +1 -1
  62. package/dist/esm/utils/common.js +2 -11
  63. package/dist/esm/utils/common.js.map +1 -1
  64. package/dist/esm/utils/intent.js +24 -33
  65. package/dist/esm/utils/intent.js.map +1 -1
  66. package/dist/esm/webbookEvent/index.js +105 -128
  67. package/dist/esm/webbookEvent/index.js.map +1 -1
  68. package/package.json +4 -5
  69. package/dist/cjs/aws/index.d.ts +0 -178
  70. package/dist/cjs/aws/index.js +0 -52
  71. package/dist/cjs/aws/index.js.map +0 -1
  72. package/dist/cjs/aws/services/AESEncryptionUsingKMS.d.ts +0 -4
  73. package/dist/cjs/aws/services/AESEncryptionUsingKMS.js +0 -110
  74. package/dist/cjs/aws/services/AESEncryptionUsingKMS.js.map +0 -1
  75. package/dist/cjs/aws/services/AWSChimeMeeting.d.ts +0 -8
  76. package/dist/cjs/aws/services/AWSChimeMeeting.js +0 -108
  77. package/dist/cjs/aws/services/AWSChimeMeeting.js.map +0 -1
  78. package/dist/cjs/aws/services/AWSCodepipeline.d.ts +0 -16
  79. package/dist/cjs/aws/services/AWSCodepipeline.js +0 -56
  80. package/dist/cjs/aws/services/AWSCodepipeline.js.map +0 -1
  81. package/dist/cjs/aws/services/AWSComprehend.d.ts +0 -3
  82. package/dist/cjs/aws/services/AWSComprehend.js +0 -39
  83. package/dist/cjs/aws/services/AWSComprehend.js.map +0 -1
  84. package/dist/cjs/aws/services/AWSConnect.d.ts +0 -296
  85. package/dist/cjs/aws/services/AWSConnect.js +0 -876
  86. package/dist/cjs/aws/services/AWSConnect.js.map +0 -1
  87. package/dist/cjs/aws/services/AWSConnectCases.d.ts +0 -7
  88. package/dist/cjs/aws/services/AWSConnectCases.js +0 -90
  89. package/dist/cjs/aws/services/AWSConnectCases.js.map +0 -1
  90. package/dist/cjs/aws/services/AWSConnectParticipant.d.ts +0 -7
  91. package/dist/cjs/aws/services/AWSConnectParticipant.js +0 -96
  92. package/dist/cjs/aws/services/AWSConnectParticipant.js.map +0 -1
  93. package/dist/cjs/aws/services/AWSCustomerProfiles.d.ts +0 -5
  94. package/dist/cjs/aws/services/AWSCustomerProfiles.js +0 -54
  95. package/dist/cjs/aws/services/AWSCustomerProfiles.js.map +0 -1
  96. package/dist/cjs/aws/services/AWSDynamoDb.d.ts +0 -6
  97. package/dist/cjs/aws/services/AWSDynamoDb.js +0 -86
  98. package/dist/cjs/aws/services/AWSDynamoDb.js.map +0 -1
  99. package/dist/cjs/aws/services/AWSGateway.d.ts +0 -5
  100. package/dist/cjs/aws/services/AWSGateway.js +0 -54
  101. package/dist/cjs/aws/services/AWSGateway.js.map +0 -1
  102. package/dist/cjs/aws/services/AWSGatewayManagement.d.ts +0 -5
  103. package/dist/cjs/aws/services/AWSGatewayManagement.js +0 -58
  104. package/dist/cjs/aws/services/AWSGatewayManagement.js.map +0 -1
  105. package/dist/cjs/aws/services/AWSLambda.d.ts +0 -3
  106. package/dist/cjs/aws/services/AWSLambda.js +0 -34
  107. package/dist/cjs/aws/services/AWSLambda.js.map +0 -1
  108. package/dist/cjs/aws/services/AWSLexModel.d.ts +0 -24
  109. package/dist/cjs/aws/services/AWSLexModel.js +0 -396
  110. package/dist/cjs/aws/services/AWSLexModel.js.map +0 -1
  111. package/dist/cjs/aws/services/AWSLexRuntime.d.ts +0 -5
  112. package/dist/cjs/aws/services/AWSLexRuntime.js +0 -56
  113. package/dist/cjs/aws/services/AWSLexRuntime.js.map +0 -1
  114. package/dist/cjs/aws/services/AWSPinpoint.d.ts +0 -6
  115. package/dist/cjs/aws/services/AWSPinpoint.js +0 -74
  116. package/dist/cjs/aws/services/AWSPinpoint.js.map +0 -1
  117. package/dist/cjs/aws/services/AWSPinpointSMSVoice.d.ts +0 -9
  118. package/dist/cjs/aws/services/AWSPinpointSMSVoice.js +0 -120
  119. package/dist/cjs/aws/services/AWSPinpointSMSVoice.js.map +0 -1
  120. package/dist/cjs/aws/services/AWSQConnect.d.ts +0 -9
  121. package/dist/cjs/aws/services/AWSQConnect.js +0 -127
  122. package/dist/cjs/aws/services/AWSQConnect.js.map +0 -1
  123. package/dist/cjs/aws/services/AWSS3.d.ts +0 -11
  124. package/dist/cjs/aws/services/AWSS3.js +0 -195
  125. package/dist/cjs/aws/services/AWSS3.js.map +0 -1
  126. package/dist/cjs/aws/services/AWSSES.d.ts +0 -4
  127. package/dist/cjs/aws/services/AWSSES.js +0 -32
  128. package/dist/cjs/aws/services/AWSSES.js.map +0 -1
  129. package/dist/cjs/aws/services/AWSSNS.d.ts +0 -12
  130. package/dist/cjs/aws/services/AWSSNS.js +0 -82
  131. package/dist/cjs/aws/services/AWSSNS.js.map +0 -1
  132. package/dist/cjs/aws/services/AWSSSM.d.ts +0 -3
  133. package/dist/cjs/aws/services/AWSSSM.js +0 -53
  134. package/dist/cjs/aws/services/AWSSSM.js.map +0 -1
  135. package/dist/cjs/aws/services/AWSSTS.d.ts +0 -4
  136. package/dist/cjs/aws/services/AWSSTS.js +0 -37
  137. package/dist/cjs/aws/services/AWSSTS.js.map +0 -1
  138. package/dist/cjs/aws/services/AWSTranslate.d.ts +0 -4
  139. package/dist/cjs/aws/services/AWSTranslate.js +0 -36
  140. package/dist/cjs/aws/services/AWSTranslate.js.map +0 -1
  141. package/dist/cjs/communication/communicationService.d.ts +0 -20
  142. package/dist/cjs/communication/communicationService.js +0 -292
  143. package/dist/cjs/communication/communicationService.js.map +0 -1
  144. package/dist/cjs/communication/index.d.ts +0 -49
  145. package/dist/cjs/communication/index.js +0 -242
  146. package/dist/cjs/communication/index.js.map +0 -1
  147. package/dist/cjs/config/SSMParameters.d.ts +0 -26
  148. package/dist/cjs/config/SSMParameters.js +0 -34
  149. package/dist/cjs/config/SSMParameters.js.map +0 -1
  150. package/dist/cjs/enum/index.d.ts +0 -233
  151. package/dist/cjs/enum/index.js +0 -286
  152. package/dist/cjs/enum/index.js.map +0 -1
  153. package/dist/cjs/hashing/idObfuscation.d.ts +0 -20
  154. package/dist/cjs/hashing/idObfuscation.js +0 -70
  155. package/dist/cjs/hashing/idObfuscation.js.map +0 -1
  156. package/dist/cjs/hashing/index.d.ts +0 -33
  157. package/dist/cjs/hashing/index.js +0 -219
  158. package/dist/cjs/hashing/index.js.map +0 -1
  159. package/dist/cjs/index.d.ts +0 -12
  160. package/dist/cjs/index.js +0 -52
  161. package/dist/cjs/index.js.map +0 -1
  162. package/dist/cjs/logger/index.d.ts +0 -3
  163. package/dist/cjs/logger/index.js +0 -70
  164. package/dist/cjs/logger/index.js.map +0 -1
  165. package/dist/cjs/logger/loggerTransports.d.ts +0 -11
  166. package/dist/cjs/logger/loggerTransports.js +0 -72
  167. package/dist/cjs/logger/loggerTransports.js.map +0 -1
  168. package/dist/cjs/repository/dynamodb.d.ts +0 -121
  169. package/dist/cjs/repository/dynamodb.js +0 -725
  170. package/dist/cjs/repository/dynamodb.js.map +0 -1
  171. package/dist/cjs/shortner/index.d.ts +0 -4
  172. package/dist/cjs/shortner/index.js +0 -45
  173. package/dist/cjs/shortner/index.js.map +0 -1
  174. package/dist/cjs/utils/common.d.ts +0 -7
  175. package/dist/cjs/utils/common.js +0 -208
  176. package/dist/cjs/utils/common.js.map +0 -1
  177. package/dist/cjs/utils/date-format.d.ts +0 -16
  178. package/dist/cjs/utils/date-format.js +0 -282
  179. package/dist/cjs/utils/date-format.js.map +0 -1
  180. package/dist/cjs/utils/index.d.ts +0 -37
  181. package/dist/cjs/utils/index.js +0 -12
  182. package/dist/cjs/utils/index.js.map +0 -1
  183. package/dist/cjs/utils/intent.d.ts +0 -12
  184. package/dist/cjs/utils/intent.js +0 -214
  185. package/dist/cjs/utils/intent.js.map +0 -1
  186. package/dist/cjs/webbookEvent/index.d.ts +0 -22
  187. package/dist/cjs/webbookEvent/index.js +0 -174
  188. package/dist/cjs/webbookEvent/index.js.map +0 -1
@@ -1,12 +1,3 @@
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
- };
10
1
  import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; // ES Modules import
11
2
  import { DynamoDBDocumentClient, ScanCommand, QueryCommand, PutCommand, UpdateCommand, DeleteCommand, GetCommand, BatchWriteCommand } from "@aws-sdk/lib-dynamodb";
12
3
  const awsRegion = process.env.AWS_DEFAULT_REGION || 'us-east-1';
@@ -27,53 +18,49 @@ export default class BaseDynamoDBRepository {
27
18
  * Add item in DynamoDB table
28
19
  * @param {object} item // Object containing add for target item
29
20
  */
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
- });
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
+ }
51
40
  }
52
41
  /**
53
42
  * Update item in DynamoDB table
54
43
  * @param {object} key // Object containing target item key(s)
55
44
  * @param {object} item // Object containing updates for target item
56
45
  */
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
- });
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
+ }
77
64
  }
78
65
  /**
79
66
  * Update item in DynamoDB table
@@ -81,29 +68,27 @@ export default class BaseDynamoDBRepository {
81
68
  * @param {object} item // Object containing updates for target item
82
69
  * @returns
83
70
  */
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
- });
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
+ }
107
92
  }
108
93
  /**
109
94
  *
@@ -143,29 +128,27 @@ export default class BaseDynamoDBRepository {
143
128
  * @param {object} id // Object containing target item key(s)
144
129
  * @param {object} version // Object containing updates for target item
145
130
  */
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;
161
- }
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 );
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);
167
143
  }
168
- });
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
+ }
169
152
  }
170
153
  /**
171
154
  * Get item in DynamoDB table
@@ -183,202 +166,198 @@ export default class BaseDynamoDBRepository {
183
166
  * Get items in DynamoDB table
184
167
  * @param {object} item // Object containing target item key(s)
185
168
  */
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
- }
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];
241
249
  else
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
- }
250
+ acc = [...acc, ...response.Items.slice(0, limit - acc.length)];
270
251
  }
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
- });
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
+ }
283
264
  }
284
265
  /**
285
266
  * Get items in DynamoDB table with Pagination
286
267
  * @param {object} item // Object containing target item key(s)
287
268
  */
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 });
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];
357
348
  if (limit)
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;
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;
377
354
  }
378
- catch (error) {
379
- this.handleError(error);
380
- }
381
- });
355
+ else
356
+ return null;
357
+ }
358
+ catch (error) {
359
+ this.handleError(error);
360
+ }
382
361
  }
383
362
  /**
384
363
  * Get items in DynamoDB table
@@ -386,137 +365,129 @@ export default class BaseDynamoDBRepository {
386
365
  * @param {Array} condition // Array containing target item key(s) condition
387
366
  * @param {String} projectionExpression // if you want only selected filed should return
388
367
  */
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
- });
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
+ }
423
400
  }
424
401
  /**
425
402
  * Delete item in DynamoDB table
426
403
  * @param {object} key // Object containing target item key(s)
427
404
  */
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
- });
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
+ }
447
422
  }
448
423
  /**
449
424
  * Get All items in DynamoDB table
450
425
  */
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
- });
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
+ }
479
452
  }
480
453
  /**
481
454
  * Bulk Upload item in DynamoDB table
482
455
  * @param {object} item // Object containing add for target item
483
456
  */
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;
514
- }
515
- catch (error) {
516
- this.handleError(error);
517
- // // throw new DatabaseException( error.code );
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');
518
483
  }
519
- });
484
+ console.log("Upload Successfully");
485
+ return true;
486
+ }
487
+ catch (error) {
488
+ this.handleError(error);
489
+ // // throw new DatabaseException( error.code );
490
+ }
520
491
  }
521
492
  /**
522
493
  *