@hw-agconnect/cloud-server 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +258 -0
  2. package/auth-service/agconnect-auth.json +7 -0
  3. package/auth-service/auth.d.ts +48 -0
  4. package/auth-service/auth.js +1 -0
  5. package/auth-service/backend/auth-backend.d.ts +11 -0
  6. package/auth-service/backend/auth-backend.js +1 -0
  7. package/auth-service/entity/auth-access-token-impl.d.ts +67 -0
  8. package/auth-service/entity/auth-access-token-impl.js +1 -0
  9. package/auth-service/entity/auth-access-token.d.ts +54 -0
  10. package/auth-service/entity/auth-access-token.js +1 -0
  11. package/auth-service/entity/provider.d.ts +17 -0
  12. package/auth-service/entity/provider.js +1 -0
  13. package/auth-service/entity/token-provider-info.d.ts +18 -0
  14. package/auth-service/entity/token-provider-info.js +1 -0
  15. package/auth-service/entity/user-import-export-result.d.ts +33 -0
  16. package/auth-service/entity/user-import-export-result.js +1 -0
  17. package/auth-service/error/agc-auth-error-message.d.ts +39 -0
  18. package/auth-service/error/agc-auth-error-message.js +1 -0
  19. package/auth-service/error/agc-auth-error.d.ts +7 -0
  20. package/auth-service/error/agc-auth-error.js +1 -0
  21. package/auth-service/index.d.ts +13 -0
  22. package/auth-service/index.js +1 -0
  23. package/auth-service/jwt/agc-auth-jwt.d.ts +17 -0
  24. package/auth-service/jwt/agc-auth-jwt.js +1 -0
  25. package/auth-service/jwt/agc-auth-jwttoken.d.ts +10 -0
  26. package/auth-service/jwt/agc-auth-jwttoken.js +1 -0
  27. package/auth-service/jwt/agc-auth-public-keys-manager.d.ts +4 -0
  28. package/auth-service/jwt/agc-auth-public-keys-manager.js +1 -0
  29. package/auth-service/jwt/agc-auth-rsa-verifier.d.ts +6 -0
  30. package/auth-service/jwt/agc-auth-rsa-verifier.js +1 -0
  31. package/auth-service/jwt/rsa-key-pair.d.ts +15 -0
  32. package/auth-service/jwt/rsa-key-pair.js +1 -0
  33. package/auth-service/params/fileParams.d.ts +6 -0
  34. package/auth-service/params/fileParams.js +1 -0
  35. package/auth-service/params/index.d.ts +7 -0
  36. package/auth-service/params/index.js +1 -0
  37. package/auth-service/params/signParams.d.ts +9 -0
  38. package/auth-service/params/signParams.js +1 -0
  39. package/auth-service/params/tokenParams.d.ts +7 -0
  40. package/auth-service/params/tokenParams.js +1 -0
  41. package/auth-service/params/uidParams.d.ts +6 -0
  42. package/auth-service/params/uidParams.js +1 -0
  43. package/auth-service/request/export-user-list-req.d.ts +13 -0
  44. package/auth-service/request/export-user-list-req.js +1 -0
  45. package/auth-service/request/export-user-req.d.ts +13 -0
  46. package/auth-service/request/export-user-req.js +1 -0
  47. package/auth-service/request/import-export-user-info.d.ts +40 -0
  48. package/auth-service/request/import-export-user-info.js +1 -0
  49. package/auth-service/request/import-user-req.d.ts +14 -0
  50. package/auth-service/request/import-user-req.js +1 -0
  51. package/auth-service/request/provider-info.d.ts +20 -0
  52. package/auth-service/request/provider-info.js +1 -0
  53. package/auth-service/request/public-key-req.d.ts +9 -0
  54. package/auth-service/request/public-key-req.js +1 -0
  55. package/auth-service/request/revoke-token-req.d.ts +13 -0
  56. package/auth-service/request/revoke-token-req.js +1 -0
  57. package/auth-service/request/verify-token-req.d.ts +13 -0
  58. package/auth-service/request/verify-token-req.js +1 -0
  59. package/auth-service/response/auth-operate-rsp.d.ts +7 -0
  60. package/auth-service/response/auth-operate-rsp.js +1 -0
  61. package/auth-service/response/export-user-list-rsp.d.ts +13 -0
  62. package/auth-service/response/export-user-list-rsp.js +1 -0
  63. package/auth-service/response/export-user-rsp.d.ts +14 -0
  64. package/auth-service/response/export-user-rsp.js +1 -0
  65. package/auth-service/response/import-success-user.d.ts +11 -0
  66. package/auth-service/response/import-success-user.js +1 -0
  67. package/auth-service/response/import-user-rsp.d.ts +11 -0
  68. package/auth-service/response/import-user-rsp.js +1 -0
  69. package/auth-service/response/publickey-rsp.d.ts +9 -0
  70. package/auth-service/response/publickey-rsp.js +1 -0
  71. package/auth-service/response/token-info.d.ts +11 -0
  72. package/auth-service/response/token-info.js +1 -0
  73. package/auth-service/response/verify-token-rsp.d.ts +14 -0
  74. package/auth-service/response/verify-token-rsp.js +1 -0
  75. package/auth-service/service/agc-auth.d.ts +4 -0
  76. package/auth-service/service/agc-auth.js +1 -0
  77. package/auth-service/service/impl/agc-auth-service-impl.d.ts +46 -0
  78. package/auth-service/service/impl/agc-auth-service-impl.js +1 -0
  79. package/auth-service/service/impl/agc-auth-service.d.ts +54 -0
  80. package/auth-service/service/impl/agc-auth-service.js +1 -0
  81. package/auth-service/utils/auth-service-api-util.d.ts +11 -0
  82. package/auth-service/utils/auth-service-api-util.js +1 -0
  83. package/auth-service/utils/key-header-util.d.ts +19 -0
  84. package/auth-service/utils/key-header-util.js +1 -0
  85. package/cloud.d.ts +24 -0
  86. package/cloud.js +1 -0
  87. package/common-server/agc-client/agc-client.d.ts +41 -0
  88. package/common-server/agc-client/agc-client.js +1 -0
  89. package/common-server/agconnect-common.json +29 -0
  90. package/common-server/config/cloud-gw-url-util.d.ts +7 -0
  91. package/common-server/config/cloud-gw-url-util.js +1 -0
  92. package/common-server/config/configService.d.ts +12 -0
  93. package/common-server/config/configService.js +1 -0
  94. package/common-server/credential-service/access-token.d.ts +11 -0
  95. package/common-server/credential-service/access-token.js +1 -0
  96. package/common-server/credential-service/clientid-credential.d.ts +27 -0
  97. package/common-server/credential-service/clientid-credential.js +1 -0
  98. package/common-server/credential-service/credential-parser.d.ts +23 -0
  99. package/common-server/credential-service/credential-parser.js +1 -0
  100. package/common-server/credential-service/credential-service.d.ts +41 -0
  101. package/common-server/credential-service/credential-service.js +1 -0
  102. package/common-server/credential-service/credential-type.d.ts +7 -0
  103. package/common-server/credential-service/credential-type.js +1 -0
  104. package/common-server/error/error-message.d.ts +30 -0
  105. package/common-server/error/error-message.js +1 -0
  106. package/common-server/error/error.d.ts +36 -0
  107. package/common-server/error/error.js +1 -0
  108. package/common-server/http-client/base-response.d.ts +11 -0
  109. package/common-server/http-client/base-response.js +1 -0
  110. package/common-server/http-client/common-headers.d.ts +37 -0
  111. package/common-server/http-client/common-headers.js +1 -0
  112. package/common-server/http-client/connect-ret.d.ts +12 -0
  113. package/common-server/http-client/connect-ret.js +1 -0
  114. package/common-server/http-client/http-client.d.ts +5 -0
  115. package/common-server/http-client/http-client.js +1 -0
  116. package/common-server/http-client/http-clinet-api.d.ts +66 -0
  117. package/common-server/http-client/http-clinet-api.js +1 -0
  118. package/common-server/http-client/request-constructor.d.ts +8 -0
  119. package/common-server/http-client/request-constructor.js +1 -0
  120. package/common-server/index.d.ts +19 -0
  121. package/common-server/index.js +1 -0
  122. package/common-server/service/agc-service.d.ts +14 -0
  123. package/common-server/service/agc-service.js +1 -0
  124. package/common-server/service/service-factory.d.ts +9 -0
  125. package/common-server/service/service-factory.js +1 -0
  126. package/common-server/utils/utils.d.ts +4 -0
  127. package/common-server/utils/utils.js +1 -0
  128. package/database-service/CloudDB.d.ts +13 -0
  129. package/database-service/CloudDB.js +1 -0
  130. package/database-service/CloudDBCollection.d.ts +108 -0
  131. package/database-service/CloudDBCollection.js +1 -0
  132. package/database-service/agconnect-database.json +4 -0
  133. package/database-service/communicator/https/HttpsCommunicator.d.ts +69 -0
  134. package/database-service/communicator/https/HttpsCommunicator.js +1 -0
  135. package/database-service/communicator/https/RequestHeader.d.ts +13 -0
  136. package/database-service/communicator/https/RequestHeader.js +1 -0
  137. package/database-service/exception/AGConnectCloudDBException.d.ts +10 -0
  138. package/database-service/exception/AGConnectCloudDBException.js +1 -0
  139. package/database-service/exception/CloudDBErrorCode.d.ts +672 -0
  140. package/database-service/exception/CloudDBErrorCode.js +1 -0
  141. package/database-service/exception/ErrorCodeMessage.d.ts +1 -0
  142. package/database-service/exception/ErrorCodeMessage.js +1 -0
  143. package/database-service/index.d.ts +14 -0
  144. package/database-service/index.js +1 -0
  145. package/database-service/model/DatabaseConfig.d.ts +7 -0
  146. package/database-service/model/DatabaseConfig.js +1 -0
  147. package/database-service/model/index.d.ts +4 -0
  148. package/database-service/model/index.js +1 -0
  149. package/database-service/query/CloudDBZoneConfig.d.ts +23 -0
  150. package/database-service/query/CloudDBZoneConfig.js +1 -0
  151. package/database-service/query/CloudDBZoneObjectOperator.d.ts +39 -0
  152. package/database-service/query/CloudDBZoneObjectOperator.js +1 -0
  153. package/database-service/query/CloudDBZoneObjectOperatorConstraint.d.ts +127 -0
  154. package/database-service/query/CloudDBZoneObjectOperatorConstraint.js +1 -0
  155. package/database-service/query/CloudDBZoneQuery.d.ts +188 -0
  156. package/database-service/query/CloudDBZoneQuery.js +1 -0
  157. package/database-service/query/CloudDBZoneSnapshot.d.ts +16 -0
  158. package/database-service/query/CloudDBZoneSnapshot.js +1 -0
  159. package/database-service/request/CloudDBZoneGenericObject.d.ts +58 -0
  160. package/database-service/request/CloudDBZoneGenericObject.js +1 -0
  161. package/database-service/services/AGConnectCloudDB.d.ts +63 -0
  162. package/database-service/services/AGConnectCloudDB.js +1 -0
  163. package/database-service/services/CloudDBService.d.ts +75 -0
  164. package/database-service/services/CloudDBService.js +1 -0
  165. package/database-service/services/CloudDBZone.d.ts +254 -0
  166. package/database-service/services/CloudDBZone.js +1 -0
  167. package/database-service/services/Transaction.d.ts +73 -0
  168. package/database-service/services/Transaction.js +1 -0
  169. package/database-service/utils/AggregareType.d.ts +10 -0
  170. package/database-service/utils/AggregareType.js +1 -0
  171. package/database-service/utils/CloudDBSdkUtils.d.ts +30 -0
  172. package/database-service/utils/CloudDBSdkUtils.js +1 -0
  173. package/database-service/utils/ConditionType.d.ts +26 -0
  174. package/database-service/utils/ConditionType.js +1 -0
  175. package/database-service/utils/ConditionValidate.d.ts +40 -0
  176. package/database-service/utils/ConditionValidate.js +1 -0
  177. package/database-service/utils/Constant.d.ts +9 -0
  178. package/database-service/utils/Constant.js +1 -0
  179. package/database-service/utils/DataModelHelper.d.ts +28 -0
  180. package/database-service/utils/DataModelHelper.js +1 -0
  181. package/database-service/utils/FieldType.d.ts +18 -0
  182. package/database-service/utils/FieldType.js +1 -0
  183. package/database-service/utils/SchemaUtils.d.ts +24 -0
  184. package/database-service/utils/SchemaUtils.js +1 -0
  185. package/database-service/utils/Utils.d.ts +134 -0
  186. package/database-service/utils/Utils.js +1 -0
  187. package/function-service/cloudFunction.d.ts +10 -0
  188. package/function-service/cloudFunction.js +1 -0
  189. package/function-service/exception/AGCFunctionException.d.ts +7 -0
  190. package/function-service/exception/AGCFunctionException.js +1 -0
  191. package/function-service/exception/FunctionErrorCode.d.ts +26 -0
  192. package/function-service/exception/FunctionErrorCode.js +1 -0
  193. package/function-service/index.d.ts +8 -0
  194. package/function-service/index.js +1 -0
  195. package/function-service/params/functionParams.d.ts +9 -0
  196. package/function-service/params/functionParams.js +1 -0
  197. package/function-service/params/index.d.ts +4 -0
  198. package/function-service/params/index.js +1 -0
  199. package/function-service/server/AGCFunction.d.ts +20 -0
  200. package/function-service/server/AGCFunction.js +1 -0
  201. package/function-service/server/FunctionCallable.d.ts +40 -0
  202. package/function-service/server/FunctionCallable.js +1 -0
  203. package/function-service/server/FunctionResult.d.ts +8 -0
  204. package/function-service/server/FunctionResult.js +1 -0
  205. package/function-service/server/request/RequestHeaders.d.ts +10 -0
  206. package/function-service/server/request/RequestHeaders.js +1 -0
  207. package/function-service/util/HashUtil.d.ts +10 -0
  208. package/function-service/util/HashUtil.js +1 -0
  209. package/index.d.ts +7 -0
  210. package/index.js +1 -0
  211. package/package.json +58 -0
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { AGCClient } from '../../common-server';
5
+ import { CloudDBZoneConfig } from '../query/CloudDBZoneConfig';
6
+ import { CloudDBService } from './CloudDBService';
7
+ import { CloudDBZone } from './CloudDBZone';
8
+ /**
9
+ * AGConnectCloudDB interface.
10
+ */
11
+ export declare class AGConnectCloudDB extends CloudDBService {
12
+ private static agconnectMultiCloudDB;
13
+ private readonly USER_KEY;
14
+ private readonly UID_MAX_SIZE;
15
+ private readonly RETENTION_PERIOD_URL;
16
+ private constructor();
17
+ /**
18
+ * If the AGConnectCloudDB has not been instantiated,
19
+ * the singleton AGConnectCloudDB will be instantiated with AgcClient.
20
+ *
21
+ * @param agcClient client from Agc.
22
+ * @throws AGConnectCloudDBException if agcClient is null.
23
+ */
24
+ static initialize(agcClient: AGCClient): void;
25
+ /**
26
+ * The AGConnectCloudDB is returned if it has been instantiated, else will throw an exception.
27
+ *
28
+ * @returns The singleton AGConnectCloudDB.
29
+ * @throws AGConnectCloudDBException if AGConnectCloudDB has not been instantiated.
30
+ */
31
+ static getInstance(agcClient: AGCClient): AGConnectCloudDB;
32
+ /**
33
+ * open a CloudDBZone - create it if non existing, return its info if already exists.
34
+ *
35
+ * @param zoneConfig the CloudDBZoneConfig which contains the cloudDBZoneName.
36
+ * @returns CloudDBZone.
37
+ * @throws AGConnectCloudDBException if config is null.
38
+ */
39
+ openCloudDBZone(zoneConfig: CloudDBZoneConfig): CloudDBZone;
40
+ /**
41
+ * developers use this API to delete userKey according to userId.
42
+ *
43
+ * @param uid the userId that userKey belongs to.
44
+ * @returns promise with number.
45
+ * @throws AGConnectCloudDBException if uid is invalid.
46
+ */
47
+ executeDeleteUserKey(uid: string): Promise<number>;
48
+ /**
49
+ * the async interface of query the data retention period
50
+ *
51
+ * @return CompletableFuture with Integer
52
+ * @throws AGConnectCloudDBException if execute with exception
53
+ */
54
+ queryDeletedDataRetentionPeriod(): Promise<number>;
55
+ /**
56
+ * the async interface of update the data retention period
57
+ *
58
+ * @param days the data retention period, the range must be 0 to 60 days
59
+ * @return CompletableFuture with Integer
60
+ * @throws AGConnectCloudDBException if execute with exception
61
+ */
62
+ updateDeletedDataRetentionPeriod(days: number): Promise<number>;
63
+ }
@@ -0,0 +1 @@
1
+ "use strict";var __extends=this&&this.__extends||function(){var o=function(e,n){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,e){o.__proto__=e}||function(o,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n])},o(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function t(){this.constructor=e}o(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.AGConnectCloudDB=void 0;var CloudDBErrorCode_1=require("../exception/CloudDBErrorCode"),CloudDBService_1=require("./CloudDBService"),AGConnectCloudDBException_1=require("../exception/AGConnectCloudDBException"),CloudDBZone_1=require("./CloudDBZone"),AGConnectCloudDB=function(o){function e(e){var n=o.call(this,e)||this;return n.USER_KEY="v3/userKey",n.UID_MAX_SIZE=100,n.RETENTION_PERIOD_URL="v1/retentionPeriod",n}return __extends(e,o),e.initialize=function(o){if(!o)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);var n=o.getCredential().getRegion();e.agconnectMultiCloudDB.get(n)||this.agconnectMultiCloudDB.set(n,new e(o))},e.getInstance=function(o){if(0===e.agconnectMultiCloudDB.size)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGCONNECT_CLOUDDB_NOT_INITIALIZE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGCONNECT_CLOUDDB_NOT_INITIALIZE);var n=e.agconnectMultiCloudDB.get(o.getCredential().getRegion());if(!n)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGCONNECT_CLOUDDB_NOT_INITIALIZE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGCONNECT_CLOUDDB_NOT_INITIALIZE);return n},e.prototype.openCloudDBZone=function(o){if(!o)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);return this.setTraceId(o.getTraceId()),new CloudDBZone_1.CloudDBZone(this.agcClient,o)},e.prototype.executeDeleteUserKey=function(o){if(!o||o.length>this.UID_MAX_SIZE)return console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.USERID_IS_INVALID).message),Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.USERID_IS_INVALID));var e=this.URL_PREFIX+this.USER_KEY,n={userId:o};return this.objectDeleteResponse(e,n)},e.prototype.queryDeletedDataRetentionPeriod=function(){var o=this.URL_PREFIX+this.RETENTION_PERIOD_URL;return this.objectGetResponse(o,this.KEY_RETENTION_DAYS)},e.prototype.updateDeletedDataRetentionPeriod=function(o){if(o<0||o>this.MAX_RETENTION_DAYS)throw new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID);var e=this.URL_PREFIX+this.RETENTION_PERIOD_URL,n={retentionDays:o};return this.objectPutResponse(e,n)},e.agconnectMultiCloudDB=new Map,e}(CloudDBService_1.CloudDBService);exports.AGConnectCloudDB=AGConnectCloudDB;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { AGCClient } from "../../common-server";
5
+ import { HttpsCommunicator } from "../communicator/https/HttpsCommunicator";
6
+ /**
7
+ * The base class of cloudDB service.
8
+ */
9
+ export declare class CloudDBService {
10
+ protected readonly URL_PREFIX = "api/clouddb/clouddbservice/";
11
+ protected agcClient: AGCClient;
12
+ protected requestSender: HttpsCommunicator;
13
+ protected traceId: string | undefined;
14
+ protected readonly MAX_RETENTION_DAYS = 60;
15
+ protected readonly KEY_RETENTION_DAYS = "retentionDays";
16
+ /**
17
+ * Constructor of CloudDB Service.
18
+ *
19
+ * @param agcClient client from Agc.
20
+ * @throws AGConnectCloudDBException if agcClient is null.
21
+ */
22
+ protected constructor(agcClient: AGCClient);
23
+ /**
24
+ * set the trace id
25
+ *
26
+ * @param traceId the trace id
27
+ */
28
+ protected setTraceId(traceId: string | undefined): void;
29
+ /**
30
+ * general the request id and trace id
31
+ *
32
+ * @return the object with request and trace id
33
+ */
34
+ protected generalRequestId(): any;
35
+ /**
36
+ * This method is used to send Put request and parse the response.
37
+ *
38
+ * @param requestUrl the request url.
39
+ * @param responseKey the response data key.
40
+ * @returns the number of recprds that being put.
41
+ * @throws AGConnectCloudDBException if response is invalid.
42
+ */
43
+ protected objectGetResponse(requestUrl: string, responseKey: string): Promise<number>;
44
+ /**
45
+ * This method is used to send Put request and parse the response.
46
+ *
47
+ * @param requestUrl the request url.
48
+ * @param data the data need to send.
49
+ * @returns the number of recprds that being put.
50
+ * @throws AGConnectCloudDBException if response is invalid.
51
+ */
52
+ protected objectPutResponse(requestUrl: string, data: any): Promise<number>;
53
+ private resendGetRequest;
54
+ private resendPutRequest;
55
+ /**
56
+ * This method is used to send Delete request and parse the response.
57
+ *
58
+ * @param requestUrl the request url.
59
+ * @param data the data need to send.
60
+ * @returns the number of recprds that being deleted.
61
+ * @throws AGConnectCloudDBException if response is invalid.
62
+ */
63
+ protected objectDeleteResponse(requestUrl: string, data: any): Promise<number>;
64
+ private resendDeleteRequest;
65
+ /**
66
+ * This method is used to check whether the response body is valid.
67
+ *
68
+ * @param resp response body
69
+ */
70
+ protected checkResponseBody(resp: any): void;
71
+ /**
72
+ * This method is used to check whether the error response is valid.
73
+ */
74
+ protected isErrResponseNotValid(err: any): boolean;
75
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CloudDBService=void 0;var CloudDBErrorCode_1=require("../exception/CloudDBErrorCode"),AGConnectCloudDBException_1=require("../exception/AGConnectCloudDBException"),ErrorCodeMessage_1=require("../exception/ErrorCodeMessage"),HttpsCommunicator_1=require("../communicator/https/HttpsCommunicator"),Utils_1=require("../utils/Utils"),CloudDBService=function(){function e(e){if(this.URL_PREFIX="api/clouddb/clouddbservice/",this.MAX_RETENTION_DAYS=60,this.KEY_RETENTION_DAYS="retentionDays",!e)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);this.agcClient=e,this.requestSender=new HttpsCommunicator_1.HttpsCommunicator(this.agcClient)}return e.prototype.setTraceId=function(e){this.traceId=e},e.prototype.generalRequestId=function(){return{requestId:Utils_1.Utils.getRequestId(),traceId:this.traceId?this.traceId:Utils_1.Utils.getRequestId()}},e.prototype.objectGetResponse=function(e,t){var o=this;return new Promise((function(n,r){var s=o.generalRequestId();o.requestSender.sendGetRequest(e,s).then((function(e){o.checkResponseBody(e),n(e.data[t])})).catch((function(){o.resendGetRequest(n,r,e,s,t)}))}))},e.prototype.objectPutResponse=function(e,t){var o=this;return new Promise((function(n,r){var s=o.generalRequestId();o.requestSender.sendPutRequest(e,s,t).then((function(e){o.checkResponseBody(e),n(e.data[o.KEY_RETENTION_DAYS])})).catch((function(){o.resendPutRequest(n,r,e,s,t)}))}))},e.prototype.resendGetRequest=function(e,t,o,n,r){var s=this;this.requestSender.sendGetRequest(o,n,!0).then((function(t){s.checkResponseBody(t),e(t.data[r])})).catch((function(e){console.warn("Get catch error, requestId:"+n.traceId),s.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},e.prototype.resendPutRequest=function(e,t,o,n,r){var s=this;this.requestSender.sendPutRequest(o,n,r,!0).then((function(t){s.checkResponseBody(t),e(t.data[s.KEY_RETENTION_DAYS])})).catch((function(e){console.warn("Put catch error, requestId:"+n.traceId),s.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},e.prototype.objectDeleteResponse=function(e,t){var o=this;return new Promise((function(n,r){var s=o.generalRequestId();o.requestSender.sendDeleteRequest(e,s,t).then((function(e){o.checkResponseBody(e),n(e.data.delNumber)})).catch((function(){o.resendDeleteRequest(n,r,e,s,t)}))}))},e.prototype.resendDeleteRequest=function(e,t,o,n,r){var s=this;this.requestSender.sendDeleteRequest(o,n,r,!0).then((function(t){s.checkResponseBody(t),e(t.data.delNumber)})).catch((function(e){console.warn("Delete catch error, requestId:"+n.traceId),s.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},e.prototype.checkResponseBody=function(e){if(200===e.status&&!e.data)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID)},e.prototype.isErrResponseNotValid=function(e){return null==e.response||null==e.response.data||null==e.response.data.errorCodeV2||!(0,ErrorCodeMessage_1.getErrorMessage)(e.response.data.errorCodeV2)||(console.warn("Get cloud error code =>",e.response.data.errorCodeV2),!1)},e}();exports.CloudDBService=CloudDBService;
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { CloudDBZoneQuery } from '../query/CloudDBZoneQuery';
5
+ import { CloudDBZoneSnapshot } from '../query/CloudDBZoneSnapshot';
6
+ import { TransactionFunction } from './Transaction';
7
+ import { AGCClient } from '../../common-server';
8
+ import { CloudDBService } from './CloudDBService';
9
+ import { CloudDBZoneConfig } from '../query/CloudDBZoneConfig';
10
+ import { CloudDBZoneObjectOperator } from '../query/CloudDBZoneObjectOperator';
11
+ import { CloudDBZoneObjectOperatorConstraint } from '../query/CloudDBZoneObjectOperatorConstraint';
12
+ export declare class ServerStatus {
13
+ serverTimestamp: number;
14
+ }
15
+ export declare const enum RequestOperationType {
16
+ UPSERT = "UPSERT",
17
+ INSERT = "INSERT",
18
+ DELETE = "DELETE",
19
+ RECYCLEBIN_DELETE = "RECYCLEBIN_DELETE",
20
+ RECOVERY = "RECOVERY",
21
+ BATCH_UPSERT = "BATCH_UPSERT",
22
+ BATCH_DELETE = "BATCH_DELETE",
23
+ QUERY_DELETED_DATA_RETENTION_PERIOD = "QUERY_DELETED_DATA_RETENTION_PERIOD",
24
+ DELETED_DATA_RETENTION_PERIOD = "DELETED_DATA_RETENTION_PERIOD"
25
+ }
26
+ export declare const enum AggregateResponseKey {
27
+ AVG = "average",
28
+ SUM = "sum",
29
+ MAX = "maximum",
30
+ MIN = "minimum",
31
+ COUNT = "count"
32
+ }
33
+ /**
34
+ * CloudDBZone object interface.
35
+ */
36
+ export declare class CloudDBZone extends CloudDBService {
37
+ private readonly cloudDBZoneConfig;
38
+ private readonly QUERIES_URL;
39
+ private readonly TRANSACTION_QUERIES_URL;
40
+ private readonly DATA_URL;
41
+ private readonly ALL_DATA_URL;
42
+ private readonly TRANSACTION_URL;
43
+ private readonly KEY_ORDERBY_FIELD_NAME;
44
+ private readonly KEY_ORDERBY_DIRECTION;
45
+ private readonly UPDATE_URL;
46
+ private readonly RECOVERY_DATA_URL;
47
+ private readonly BATCH_UPDATE_DELETE_URL;
48
+ private readonly SYNC_BATCH_UPDATE_DELETE_URL;
49
+ private readonly PROCESS_PERCENTAGE;
50
+ private readonly SERVER_STATUS_URL;
51
+ private readonly KEY_SERVER_STATUS;
52
+ private static readonly KEY_DATA;
53
+ constructor(agcClient: AGCClient, cloudDBZoneConfig: CloudDBZoneConfig);
54
+ /**
55
+ * This method is used to get config of current CloudDBZone.
56
+ *
57
+ * @returns config of current CloudDBZone.
58
+ */
59
+ getCloudBDZoneConfig(): CloudDBZoneConfig;
60
+ executeTransactionQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, isQueryDelete: boolean): Promise<any>;
61
+ private resendTransactionQuery;
62
+ /**
63
+ * developers use this API to insert/update specific records in a table.
64
+ *
65
+ * @param objectList single object/object list need to be inserted/updated to database.
66
+ * @returns promise with number.
67
+ */
68
+ executeUpsert<T>(objectList: T[] | T): Promise<number>;
69
+ /**
70
+ * developers use this API to insert specific records in a table.
71
+ *
72
+ * @param objectList single object/object list need to be inserted to database.
73
+ * @returns promise with number.
74
+ */
75
+ executeInsert<T>(objectList: T[] | T): Promise<number>;
76
+ /**
77
+ * developers use this API to recovery specific records in a table.
78
+ *
79
+ * @param objectList single object/object list need to be recovery to database.
80
+ * @returns promise with number.
81
+ */
82
+ executeRecovery<T>(objectList: T[] | T): Promise<number>;
83
+ /**
84
+ * developers use this API to increase field value or update specific fields in a table.
85
+ *
86
+ * @param operator single operator need to be updated to database.
87
+ * @param constraint the constraint conditions of updated object.
88
+ * @returns promise with number.
89
+ * @throws AGConnectCloudDBException when error occur.
90
+ */
91
+ executeUpdate<T>(operator: CloudDBZoneObjectOperator, constraint?: CloudDBZoneObjectOperatorConstraint<T>): Promise<number>;
92
+ private getUpdateData;
93
+ private getBatchDeleteData;
94
+ /**
95
+ * developers use this API to increase field value or update specific fields with the required conditions in a table.
96
+ *
97
+ * @param operator single operator need to be updated to database.
98
+ * @param constraint the constraint conditions of updated object.
99
+ * @returns promise with number.
100
+ * @throws AGConnectCloudDBException when error occur.
101
+ */
102
+ executeBatchUpdate<T>(operator: CloudDBZoneObjectOperator, constraint?: CloudDBZoneObjectOperatorConstraint<T>): Promise<number>;
103
+ /**
104
+ * developers use this API to increase field value or update specific fields with the required conditions in a table.
105
+ *
106
+ * @param operator single operator need to be updated to database.
107
+ * @param constraint the constraint conditions of updated object.
108
+ * @returns promise with number.
109
+ * @throws AGConnectCloudDBException when error occur.
110
+ */
111
+ executeBatchUpdateByCondition<T>(operator: CloudDBZoneObjectOperator, constraint?: CloudDBZoneObjectOperatorConstraint<T>): Promise<number>;
112
+ /**
113
+ * developers use this API to batch delete data with the required conditions in a table.
114
+ *
115
+ * @param constraint the constraint conditions of deleted object.
116
+ * @returns promise with number.
117
+ * @throws AGConnectCloudDBException when error occur.
118
+ */
119
+ executeBatchDelete<T>(constraint: CloudDBZoneObjectOperatorConstraint<T>): Promise<number>;
120
+ /**
121
+ * developers use this API to batch delete data with the required conditions in a table.
122
+ *
123
+ * @param constraint the constraint conditions of deleted object.
124
+ * @returns promise with number.
125
+ * @throws AGConnectCloudDBException when error occur.
126
+ */
127
+ executeBatchDeleteByCondition<T>(constraint: CloudDBZoneObjectOperatorConstraint<T>): Promise<number>;
128
+ private sendBatchRequest;
129
+ private checkBatchResult;
130
+ private resendUpsertRequest;
131
+ private resendUpdateRequest;
132
+ private resendBatchRequest;
133
+ private static checkInputData;
134
+ /**
135
+ * developers use this API to delete specific records in a table.
136
+ *
137
+ * @param objectList single object/object list need to be deleted from database.
138
+ * @returns promise with number.
139
+ */
140
+ executeDelete<T>(objectList: T[] | T): Promise<number>;
141
+ /**
142
+ * developers use this API to delete specific records in a recycle bin table.
143
+ *
144
+ * @param objectList single object/object list need to be deleted from database.
145
+ * @returns promise with number.
146
+ */
147
+ executeRecycleBinDelete<T>(objectList: T[] | T): Promise<number>;
148
+ /**
149
+ * developers use this API to delete all records in a table.
150
+ *
151
+ * @param clazz the object or object type name needs to be deleted from database.
152
+ * @returns promise with number.
153
+ */
154
+ executeDeleteAll<T>(clazz: (new () => T) | string): Promise<number>;
155
+ /**
156
+ * developers use this API to select a table by a cloudDBZoneQuery.
157
+ *
158
+ * @param cloudDBZoneQuery cloudDBZoneQuery user construct using api, such as where, equalTo...
159
+ * @returns promise with object list queried from table.
160
+ */
161
+ executeQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>): Promise<CloudDBZoneSnapshot<T>>;
162
+ /**
163
+ * developers use this API to select recycle bin table by a cloudDBZoneQuery.
164
+ *
165
+ * @param cloudDBZoneQuery cloudDBZoneQuery user construct using api, such as where, equalTo...
166
+ * @param begin the start of data from recycle bin delete time
167
+ * @param end the end of data from recycle bin delete time
168
+ * @returns promise with object list queried from recycle bin table.
169
+ */
170
+ executeRecycleBinQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, begin?: Date | null, end?: Date | null): Promise<CloudDBZoneSnapshot<T>>;
171
+ /**
172
+ * developers use this API to get an average result from CloudDBZone by a cloudDBZoneQuery.
173
+ *
174
+ * @param cloudDBZoneQuery user construct a cloudDBZoneQuery using api, such as where, equalTo...
175
+ * @param fieldName user choose one field to query.
176
+ * @returns promise with number.
177
+ */
178
+ executeAverageQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, fieldName: string): Promise<number>;
179
+ /**
180
+ * developers use this API to get a sum result from CloudDBZone by a cloudDBZoneQuery.
181
+ *
182
+ * @param cloudDBZoneQuery user construct a cloudDBZoneQuery using api, such as where, equalTo...
183
+ * @param fieldName user choose one field to query.
184
+ * @returns promise with number.
185
+ */
186
+ executeSumQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, fieldName: string): Promise<number>;
187
+ /**
188
+ * developers use this API to get a maximum result from CloudDBZone by a cloudDBZoneQuery.
189
+ *
190
+ * @param cloudDBZoneQuery user construct a cloudDBZoneQuery using api, such as where, equalTo...
191
+ * @param fieldName user choose one field to query.
192
+ * @returns promise with number.
193
+ */
194
+ executeMaximumQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, fieldName: string): Promise<number>;
195
+ /**
196
+ * developers use this API to get minimum result from CloudDBZone by a cloudDBZoneQuery.
197
+ *
198
+ * @param cloudDBZoneQuery user construct a cloudDBZoneQuery using api, such as where, equalTo...
199
+ * @param fieldName user choose one field to query.
200
+ * @returns promise with number.
201
+ */
202
+ executeMinimalQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, fieldName: string): Promise<number>;
203
+ /**
204
+ * developers use this API to get count result from CloudDBZone by a cloudDBZoneQuery.
205
+ *
206
+ * @param cloudDBZoneQuery user construct a cloudDBZoneQuery using api, such as where, equalTo...
207
+ * @param fieldName user choose our field to query.
208
+ * @returns promise with number.
209
+ */
210
+ executeCountQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>, fieldName: string): Promise<number>;
211
+ /**
212
+ * developers use this API to execute a transaction in cloud size.
213
+ *
214
+ * @param transactionFunction the transactionFunction.
215
+ * @returns promise with boolean.
216
+ */
217
+ runTransaction(transactionFunction: TransactionFunction): Promise<boolean>;
218
+ executeServerStatusQuery<T>(): Promise<ServerStatus>;
219
+ private resendExecuteServerStatusQuery;
220
+ private getCloudDBZoneResult;
221
+ private static verifyTransaction;
222
+ private getTransactionResult;
223
+ private resendGetTransactionResult;
224
+ private verifyPaginationQuery;
225
+ private checkPrimaryKeyValues;
226
+ private checkPaginationQueryConditions;
227
+ private checkPaginationEqualTo;
228
+ private static checkPaginationOrderBy;
229
+ private getIndexByQueryCondition;
230
+ private static checkAggregateQueryInput;
231
+ private static responseCheck;
232
+ private static aggregateResponseCheck;
233
+ private getAllOrderBys;
234
+ private isPaginationQuery;
235
+ private objectListTransform;
236
+ private aggregateQueryResponse;
237
+ private resendAggregateQuery;
238
+ private formAggregateQueryData;
239
+ private checkOperator;
240
+ private static getPrimaryKeys;
241
+ private static checkConstraint;
242
+ private static checkConstraintOnly;
243
+ private handleIncrementData;
244
+ private formData;
245
+ /**
246
+ * developers use this API to select a table by a cloudDBZoneQuery.
247
+ *
248
+ * @param cloudDBZoneQuery cloudDBZoneQuery user construct using api, such as where, equalTo...
249
+ * @returns promise with object list queried from table.
250
+ */
251
+ private executeQueryInternal;
252
+ private executeDeleteInternal;
253
+ private checkGenericObjectPaginationEqualTo;
254
+ }
@@ -0,0 +1 @@
1
+ "use strict";var __extends=this&&this.__extends||function(){var e=function(o,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&(e[t]=o[t])},e(o,t)};return function(o,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=o}e(o,t),o.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}(),__awaiter=this&&this.__awaiter||function(e,o,t,n){return new(t||(t=Promise))((function(r,i){function c(e){try{d(n.next(e))}catch(e){i(e)}}function u(e){try{d(n.throw(e))}catch(e){i(e)}}function d(e){var o;e.done?r(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(c,u)}d((n=n.apply(e,o||[])).next())}))},__generator=this&&this.__generator||function(e,o){var t,n,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(d){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(c=0)),c;)try{if(t=1,n&&(r=2&u[0]?n.return:u[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,u[1])).done)return r;switch(n=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return c.label++,{value:u[1],done:!1};case 5:c.label++,n=u[1],u=[0];continue;case 7:u=c.ops.pop(),c.trys.pop();continue;default:if(!(r=c.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){c=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){c.label=u[1];break}if(6===u[0]&&c.label<r[1]){c.label=r[1],r=u;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(u);break}r[2]&&c.ops.pop(),c.trys.pop();continue}u=o.call(e,c)}catch(e){u=[6,e],n=0}finally{t=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,d])}}},__values=this&&this.__values||function(e){var o="function"==typeof Symbol&&Symbol.iterator,t=o&&e[o],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")},__read=this&&this.__read||function(e,o){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,r,i=t.call(e),c=[];try{for(;(void 0===o||o-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(r)throw r.error}}return c};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CloudDBZone=exports.ServerStatus=void 0;var CloudDBZoneQuery_1=require("../query/CloudDBZoneQuery"),CloudDBZoneSnapshot_1=require("../query/CloudDBZoneSnapshot"),Transaction_1=require("./Transaction"),Utils_1=require("../utils/Utils"),AGConnectCloudDBException_1=require("../exception/AGConnectCloudDBException"),CloudDBErrorCode_1=require("../exception/CloudDBErrorCode"),FieldType_1=require("../utils/FieldType"),Constant_1=require("../utils/Constant"),CloudDBService_1=require("./CloudDBService"),DataModelHelper_1=require("../utils/DataModelHelper"),ConditionValidate_1=require("../utils/ConditionValidate"),ErrorCodeMessage_1=require("../exception/ErrorCodeMessage"),CloudDBZoneGenericObject_1=require("../request/CloudDBZoneGenericObject"),MAX_OBJECT_LIST_NUM=1e3,MAX_OBJECTS_CAPACITY=20971520,MAX_FAILED_COUNT=5,HTTP_STATUS_OK=200,ServerStatus=function(){};exports.ServerStatus=ServerStatus;var RequestOperationTypeMap=new Map([["UPSERT",{operationType:0,resKey:"upsertNumber"}],["INSERT",{operationType:1,resKey:"insertNumber"}],["DELETE",{operationType:2,resKey:"delNumber"}],["RECYCLEBIN_DELETE",{operationType:3,resKey:"delNumber"}],["RECOVERY",{operationType:4,resKey:"recoveryNumber"}]]),CloudDBZone=function(e){function o(o,t){var n=e.call(this,o)||this;if(n.QUERIES_URL="v4/objects/queries",n.TRANSACTION_QUERIES_URL="v4/syncObjects/queries",n.DATA_URL="v3/syncObjects",n.ALL_DATA_URL="v3/syncAllObjects",n.TRANSACTION_URL="v3/transaction",n.KEY_ORDERBY_FIELD_NAME="orderByFieldName",n.KEY_ORDERBY_DIRECTION="orderByDirection",n.UPDATE_URL="v4/object",n.RECOVERY_DATA_URL="v1/objectsRecovery",n.BATCH_UPDATE_DELETE_URL="v4/objects",n.SYNC_BATCH_UPDATE_DELETE_URL="v1/objects/changeByCondition",n.PROCESS_PERCENTAGE="v1/processPercentage",n.SERVER_STATUS_URL="v1/serverStatus",n.KEY_SERVER_STATUS="timestamp",!t||!t.getCloudDBZoneName())throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);return n.setTraceId(t.getTraceId()),n.cloudDBZoneConfig=t,n}return __extends(o,e),o.prototype.getCloudBDZoneConfig=function(){return this.cloudDBZoneConfig},o.prototype.executeTransactionQuery=function(e,t){return __awaiter(this,void 0,void 0,(function(){var n,r,i,c=this;return __generator(this,(function(u){return n=e.clazzInstance,this.verifyPaginationQuery(e,n),r=this.URL_PREFIX+this.TRANSACTION_QUERIES_URL,i={objectTypeName:e.getObjectTypeName(),cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),isQueryDelete:t,queryConditions:n instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?Utils_1.Utils.serializeGenericObjQuery(e.getQueryConditions()):Utils_1.Utils.serializeQueryConditions(e.getQueryConditions(),n.getFieldTypeMap())},[2,new Promise((function(e,t){var n=c.generalRequestId();c.requestSender.sendPostRequest(r,n,i).then((function(t){c.checkResponseBody(t),e(t[o.KEY_DATA][o.KEY_DATA])})).catch((function(){c.resendTransactionQuery(e,t,r,n,i)}))}))]}))}))},o.prototype.resendTransactionQuery=function(e,t,n,r,i){var c=this;this.requestSender.sendPostRequest(n,r,i,!0).then((function(t){c.checkResponseBody(t),e(t[o.KEY_DATA][o.KEY_DATA])})).catch((function(e){console.warn("Query catch error, requestId:"+r.traceId),c.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},o.prototype.executeUpsert=function(e){return this.handleIncrementData(e,"UPSERT")},o.prototype.executeInsert=function(e){return this.handleIncrementData(e,"INSERT")},o.prototype.executeRecovery=function(e){return this.handleIncrementData(e,"RECOVERY")},o.prototype.executeUpdate=function(e,t){var n=this;if(0===e.getUpdateMap().size&&0===e.getIncrementMap().size)return console.log("The updated and incremental field size is 0, no need to update."),Promise.resolve(0);var r=this.URL_PREFIX+this.UPDATE_URL;return this.checkOperator(e),o.checkConstraint(e.getObject(),t),new Promise((function(i,c){var u=n.generalRequestId(),d=n.getUpdateData(e,t);n.requestSender.sendPutRequest(r,u,d).then((function(e){n.checkResponseBody(e),i(e[o.KEY_DATA].affectNum)})).catch((function(){n.resendUpdateRequest(i,c,r,u,d)}))}))},o.prototype.getUpdateData=function(e,t,n){var r=n?{cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),objectTypeName:e.getObjectTypeName()}:{cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),objectTypeName:e.getObjectTypeName(),primaryKey:o.getPrimaryKeys(e.getObject())};return e.getIncrementMap()&&0!=e.getIncrementMap().size&&(r.increment=Utils_1.Utils.serializeMapObject(e.getObject(),e.getIncrementMap())),e.getUpdateMap()&&0!=e.getUpdateMap().size&&(r.update=Utils_1.Utils.serializeMapObject(e.getObject(),e.getUpdateMap())),t&&(r.conditions=e.getObject()instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?Utils_1.Utils.serializeGenericObjQuery(t.getConditions()):Utils_1.Utils.serializeQueryConditions(t.getConditions(),e.getObject().getFieldTypeMap())),n&&!t&&(r.conditions=[]),r},o.prototype.getBatchDeleteData=function(e){var o={cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),objectTypeName:e.getObjectTypeName()};return e&&(o.conditions=e.getSerializeQueryCondition()),o},o.prototype.executeBatchUpdate=function(e,t){var n=this;return 0===e.getUpdateMap().size&&0===e.getIncrementMap().size?(console.log("The updated and incremental field size is 0, no need to update."),Promise.resolve(0)):(this.checkOperator(e,!0),o.checkConstraint(e.getObject(),t),new Promise((function(o,r){var i=n.generalRequestId(),c=n.getUpdateData(e,t,!0);n.sendBatchRequest(i,c,"BATCH_UPSERT").then((function(e){n.checkBatchResult(o,r,e,"BATCH_UPSERT",i)})).catch((function(){n.resendBatchRequest(o,r,i,c,"BATCH_UPSERT")}))})))},o.prototype.executeBatchUpdateByCondition=function(e,t){var n=this;return 0===e.getUpdateMap().size&&0===e.getIncrementMap().size?(console.log("The updated and incremental field size is 0, no need to update."),Promise.resolve(0)):(this.checkOperator(e,!0),o.checkConstraint(e.getObject(),t),new Promise((function(r,i){var c=n.generalRequestId(),u=n.getUpdateData(e,t,!0),d=n.URL_PREFIX+n.SYNC_BATCH_UPDATE_DELETE_URL;n.requestSender.sendPostRequest(d,c,u).then((function(e){n.checkResponseBody(e),r(e[o.KEY_DATA].affectNum)})).catch((function(e){i(e)}))})))},o.prototype.executeBatchDelete=function(e){var t=this;return o.checkConstraintOnly(e),new Promise((function(o,n){var r=t.generalRequestId(),i=t.getBatchDeleteData(e);t.sendBatchRequest(r,i,"BATCH_DELETE").then((function(e){t.checkBatchResult(o,n,e,"BATCH_DELETE",r)})).catch((function(){t.resendBatchRequest(o,n,r,i,"BATCH_DELETE")}))}))},o.prototype.executeBatchDeleteByCondition=function(e){var t=this;return o.checkConstraintOnly(e),new Promise((function(n,r){var i=t.generalRequestId(),c=t.getBatchDeleteData(e),u=t.URL_PREFIX+t.SYNC_BATCH_UPDATE_DELETE_URL;t.requestSender.sendDeleteRequest(u,i,c).then((function(e){t.checkResponseBody(e),n(e[o.KEY_DATA].affectNum)})).catch((function(e){r(e)}))}))},o.prototype.sendBatchRequest=function(e,o,t,n){return __awaiter(this,void 0,void 0,(function(){var r,i,c,u;return __generator(this,(function(d){switch(d.label){case 0:return r=this.URL_PREFIX+this.BATCH_UPDATE_DELETE_URL,"BATCH_UPSERT"!==t?[3,2]:[4,this.requestSender.sendPostRequest(r,e,o,n)];case 1:return i=d.sent(),[3,4];case 2:return[4,this.requestSender.sendDeleteRequest(r,e,o,n)];case 3:i=d.sent(),d.label=4;case 4:if(this.checkResponseBody(i),!(c=i.data.processId))throw new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.SYSTEM_ERROR);return u=this.URL_PREFIX+this.PROCESS_PERCENTAGE,[4,this.requestSender.sendProcessRequest(u,e,{processId:c},n)];case 5:return[2,d.sent()]}}))}))},o.prototype.checkBatchResult=function(e,t,n,r,i){this.checkResponseBody(n),n.status===HTTP_STATUS_OK&&1===n.data.processPercentage&&n.data.affectNum>=0?e(n[o.KEY_DATA].affectNum):(console.warn("".concat(r," catch error, requestId:")+i.traceId),n.status===HTTP_STATUS_OK?n.data.finished?n.data.finished&&n.data.errorCodeV2?t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(n.data.errorCodeV2))):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID)):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PROCESS_REQUEST_TIMEOUT)):t(n))},o.prototype.resendUpsertRequest=function(e,t,n,r,i,c){var u=this;this.requestSender.sendPostRequest(n,r,i,!0).then((function(t){u.checkResponseBody(t),e(t[o.KEY_DATA][RequestOperationTypeMap.get(c).resKey])})).catch((function(e){console.warn("".concat(c," catch error, requestId:")+r.traceId),u.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},o.prototype.resendUpdateRequest=function(e,t,n,r,i){var c=this;this.requestSender.sendPutRequest(n,r,i,!0).then((function(t){c.checkResponseBody(t),e(t[o.KEY_DATA].affectNum)})).catch((function(e){console.warn("Update catch error, requestId:"+r.traceId),c.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},o.prototype.resendBatchRequest=function(e,o,t,n,r){var i=this;this.sendBatchRequest(t,n,r).then((function(n){i.checkBatchResult(e,o,n,r,t)})).catch((function(e){console.warn("".concat(r," catch error, requestId:")+t.traceId),i.isErrResponseNotValid(e)?o(e):o(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},o.checkInputData=function(e){if(e.length>MAX_OBJECT_LIST_NUM)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW);Utils_1.Utils.checkSchemaAndDataSize(e)},o.prototype.executeDelete=function(e){return this.executeDeleteInternal(e,!1)},o.prototype.executeRecycleBinDelete=function(e){return this.executeDeleteInternal(e,!0)},o.prototype.executeDeleteAll=function(e){if(!e)return console.warn("the class is null"),Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL));var o;typeof e===Constant_1.VerifyKey.String?(Utils_1.Utils.checkObjectTypeName(e),o=e):(Utils_1.Utils.clazzCheck(e),o=(new e).getClassName());var t=this.URL_PREFIX+this.ALL_DATA_URL,n={objectTypeName:o,cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName()};return this.objectDeleteResponse(t,n)},o.prototype.executeQuery=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,this.executeQueryInternal(e,!1)]}))}))},o.prototype.executeRecycleBinQuery=function(e,o,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){if(!o&&!t)return[2,this.executeQueryInternal(e,!0)];if(!o||!t||o.getTime()>t.getTime())throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID);return[2,this.executeQueryInternal(e,!0,o,t)]}))}))},o.prototype.executeAverageQuery=function(e,o){var t=this.formAggregateQueryData(e,o,"Average"),n="average("+o+")";return this.aggregateQueryResponse(t,n)},o.prototype.executeSumQuery=function(e,o){var t=this.formAggregateQueryData(e,o,"Sum"),n="sum("+o+")";return this.aggregateQueryResponse(t,n)},o.prototype.executeMaximumQuery=function(e,o){var t=this.formAggregateQueryData(e,o,"Max"),n="maximum("+o+")";return this.aggregateQueryResponse(t,n)},o.prototype.executeMinimalQuery=function(e,o){var t=this.formAggregateQueryData(e,o,"Min"),n="minimum("+o+")";return this.aggregateQueryResponse(t,n)},o.prototype.executeCountQuery=function(e,o){var t=this.formAggregateQueryData(e,o,"Count"),n="count("+o+")";return this.aggregateQueryResponse(t,n)},o.prototype.runTransaction=function(e){return e?this.getCloudDBZoneResult(e):(console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL)))},o.prototype.executeServerStatusQuery=function(){var e=this,t=this.URL_PREFIX+this.SERVER_STATUS_URL;return new Promise((function(n,r){var i=e.generalRequestId();e.requestSender.sendGetRequest(t,i).then((function(t){n({serverTimestamp:Number(t[o.KEY_DATA][e.KEY_SERVER_STATUS])})})).catch((function(){e.resendExecuteServerStatusQuery(n,r,t,i)}))}))},o.prototype.resendExecuteServerStatusQuery=function(e,t,n,r){var i=this;this.requestSender.sendGetRequest(n,r).then((function(t){e({serverTimestamp:t[o.KEY_DATA][i.KEY_SERVER_STATUS]})})).catch((function(e){console.warn("Query ServerStatus catch error, requestId:"+r.traceId),i.isErrResponseNotValid(e)?t(e):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2)))}))},o.prototype.getCloudDBZoneResult=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,r;return __generator(this,(function(i){switch(i.label){case 0:t=new Transaction_1.Transaction(this),n=!1,r=0,i.label=1;case 1:if(n||!(r<MAX_FAILED_COUNT))return[3,7];i.label=2;case 2:return i.trys.push([2,,5,6]),typeof e.apply!=Constant_1.VerifyKey.Function?(console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.CLASS_INVALID).message),[2,Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.CLASS_INVALID))]):[4,e.apply(t)];case 3:return(n=i.sent())?(t.sortVerifyObjectsList(),o.verifyTransaction(t),[4,this.getTransactionResult(t)]):(console.warn("user function return false, transaction failed."),[2,!1]);case 4:return n=i.sent(),r++,[3,6];case 5:return t.release(),[7];case 6:return[3,1];case 7:return[2,n]}}))}))},o.verifyTransaction=function(e){var o,t,n=0;try{for(var r=__values(e.transactionList),i=r.next();!i.done;i=r.next()){var c=i.value;if((c.operationType===Transaction_1.OperationType.UPSERT||c.operationType===Transaction_1.OperationType.DELETE)&&(n+=c.objects.length)>MAX_OBJECT_LIST_NUM)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW)}}catch(e){o={error:e}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}if(e.needVerifyObjectsList.length>MAX_OBJECT_LIST_NUM)throw console.warn("Too many query results in the transaction."),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW)},o.prototype.getTransactionResult=function(e){return __awaiter(this,void 0,void 0,(function(){var o,t,n=this;return __generator(this,(function(r){return e.isTransactionEmpty()?(console.warn("nothing need to execute in this transaction, transaction succeed."),[2,Promise.resolve(!0)]):(o=this.URL_PREFIX+this.TRANSACTION_URL,t={cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),needVerifyObjectsList:e.needVerifyObjectsList,transactionList:e.transactionList},JSON.stringify(t).length>MAX_OBJECTS_CAPACITY?(console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW).message),[2,Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW))]):[2,new Promise((function(e,r){var i=n.generalRequestId();n.requestSender.sendPostRequest(o,i,t).then((function(o){o.status===HTTP_STATUS_OK&&e(!0)})).catch((function(){n.resendGetTransactionResult(e,r,o,i,t)}))}))])}))}))},o.prototype.resendGetTransactionResult=function(e,o,t,n,r){var i=this;this.requestSender.sendPostRequest(t,n,r,!0).then((function(o){o.status===HTTP_STATUS_OK&&e(!0)})).catch((function(t){if(console.warn("Transaction catch error, requestId:"+n.traceId),i.isErrResponseNotValid(t))o(t);else{var r=String(t.response.data.errorCodeV2);console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(r).message),r!=CloudDBErrorCode_1.CloudDBErrorCode.PARAMETER_INVALID?e(!1):o(new AGConnectCloudDBException_1.AGConnectCloudDBException(r))}}))},o.prototype.verifyPaginationQuery=function(e,o){var t=this.isPaginationQuery(e.getQueryConditions());if(t){var n=this.getAllOrderBys(e.getQueryConditions()),r=n.get(this.KEY_ORDERBY_FIELD_NAME),i=n.get(this.KEY_ORDERBY_DIRECTION);if(i.includes("asc")&&i.includes("desc"))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ORDER_BY_ONLY_SUPPORT_ONE_DIRECTION).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ORDER_BY_ONLY_SUPPORT_ONE_DIRECTION);if(r.size!==i.length)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATION_ORDER_BY_HAS_DUPLICATE_FIELD).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATION_ORDER_BY_HAS_DUPLICATE_FIELD);this.checkPaginationQueryConditions(e,t,r,o),e.conditionValidate.isGenericObj||this.checkPrimaryKeyValues(e,t)}},o.prototype.checkPrimaryKeyValues=function(e,o){var t,n,r=e.clazzInstance.getPrimaryKeyList();try{for(var i=__values(r),c=i.next();!c.done;c=i.next()){var u=c.value;if(Utils_1.Utils.isNullOrUndefined(o[u]))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PRIMARY_KEY_VALUE_REQUIRED).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PRIMARY_KEY_VALUE_REQUIRED)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},o.prototype.checkPaginationQueryConditions=function(e,t,n,r){var i=this,c=!1;e.getQueryConditions().forEach((function(u){var d=u.conditionType;if(Utils_1.Utils.isAggregateType(d))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_NOT_SUPPORT_AGGREGATE)),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_NOT_SUPPORT_AGGREGATE);if("OrderBy"!==d&&"EqualTo"!==d&&"Limit"!==d&&!Utils_1.Utils.isPaginationType(d))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_QUERY_INPUT_IS_ONLY_SUPPORTED).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_QUERY_INPUT_IS_ONLY_SUPPORTED);if("EqualTo"===d){if(c)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.EQUAL_TO_NOT_BEFORE_ORDER_BY).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.EQUAL_TO_NOT_BEFORE_ORDER_BY);i.checkPaginationEqualTo(u,t,n)}"OrderBy"===d&&(c=!0,e.conditionValidate.isGenericObj||o.checkPaginationOrderBy(u,r))}))},o.prototype.checkPaginationEqualTo=function(e,o,t){if(o instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject)this.checkGenericObjectPaginationEqualTo(e,o,t);else{var n=e.fieldName,r=o.getFieldTypeMap();if(o.getPrimaryKeyList().includes(n))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_NOT_SUPPORT_PRIMARY_KEY).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_NOT_SUPPORT_PRIMARY_KEY);if(t.has(n))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_FIELD_IS_SAME_WITH_ORDER_BY).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_FIELD_IS_SAME_WITH_ORDER_BY);if(r.get(n)===FieldType_1.FieldType.Text)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_NOT_SUPPORT_TEXT).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_NOT_SUPPORT_TEXT)}},o.checkPaginationOrderBy=function(e,o){var t=e.fieldName,n=o.getFieldTypeMap().get(t);if(n===FieldType_1.FieldType.ByteArray||n===FieldType_1.FieldType.Text||n===FieldType_1.FieldType.Boolean)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_ORDER_BY_NOT_SUPPORT_TYPE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_ORDER_BY_NOT_SUPPORT_TYPE)},o.prototype.getIndexByQueryCondition=function(e,o){var t=[];return e.forEach((function(e){var o=e.conditionType;if("OrderBy"===o||"EqualTo"===o){var n=e.fieldName;n&&t.push(n)}})),o.forEach((function(e){t.includes(e)||t.push(e)})),t},o.checkAggregateQueryInput=function(e,o,t,n){if(!o)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_FIELD_NAME_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_FIELD_NAME_IS_NULL);if(Utils_1.Utils.checkFieldName(o),!n){var r=e.getFieldTypeMap();if(!r.has(o))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_ENTITY_DO_NOT_HAVE_FIELD).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_ENTITY_DO_NOT_HAVE_FIELD);if(e.getEncryptedFieldList().includes(o)&&"Count"!=t)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ENCRYPTED_FIELD_NOT_SUPPORT_QUERY).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ENCRYPTED_FIELD_NOT_SUPPORT_QUERY);var i=r.get(o);if("Count"!==t&&!Utils_1.Utils.isNumericField(i))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_FIELD_TYPE_IS_NOT_NUMERIC).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_FIELD_TYPE_IS_NOT_NUMERIC)}},o.responseCheck=function(e){if(!e||!e.status)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID);if(!(e.status!==HTTP_STATUS_OK||e[o.KEY_DATA]&&e[o.KEY_DATA][o.KEY_DATA]))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID)},o.aggregateResponseCheck=function(e){if(o.responseCheck(e),!e[o.KEY_DATA][o.KEY_DATA][0])throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.RESPONSE_IS_INVALID)},o.prototype.getAllOrderBys=function(e){var o=this,t=new Map;return t.set(this.KEY_ORDERBY_FIELD_NAME,new Set),t.set(this.KEY_ORDERBY_DIRECTION,[]),e.forEach((function(e){"OrderBy"===e.conditionType&&(t.get(o.KEY_ORDERBY_FIELD_NAME).add(e.fieldName),t.get(o.KEY_ORDERBY_DIRECTION).push(e.value))})),t},o.prototype.isPaginationQuery=function(e){var o=void 0;return e.forEach((function(e){if(Utils_1.Utils.isPaginationType(e.conditionType)){if(o)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_QUERY_INPUT_IS_MORE_THAN_ONE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_QUERY_INPUT_IS_MORE_THAN_ONE);o=e.value}})),o},o.prototype.objectListTransform=function(e){if(!e){var t=new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);throw console.warn(t.message),t}var n;n=Utils_1.Utils.isArray(e)?e:[e];for(var r=0;r<n.length;r++)if(null==n[r])throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);return o.checkInputData(n),n},o.prototype.aggregateQueryResponse=function(e,t){var n=this,r=this.URL_PREFIX+this.QUERIES_URL;return new Promise((function(i,c){var u=n.generalRequestId();n.requestSender.sendPostRequest(r,u,e).then((function(e){o.aggregateResponseCheck(e),i(e[o.KEY_DATA][o.KEY_DATA][0][t])})).catch((function(){n.resendAggregateQuery(i,c,r,u,e,t)}))}))},o.prototype.resendAggregateQuery=function(e,t,n,r,i,c){var u=this;this.requestSender.sendPostRequest(n,r,i,!0).then((function(t){o.aggregateResponseCheck(t),e(t[o.KEY_DATA][o.KEY_DATA][0][c])})).catch((function(e){var o,n,i,c;if(console.warn("Query catch error, requestId:"+r.traceId),u.isErrResponseNotValid(e))t(e);else{var d=null===(n=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===n?void 0:n.errorCodeV2;d!=CloudDBErrorCode_1.CloudDBErrorCode.NOT_SUPPORT_QUERY_DATA_TYPE&&d!=CloudDBErrorCode_1.CloudDBErrorCode.ERROR_CODE_PAGINATION_QUERY_FAILED_FOR_NO_INDEX?t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2))):t(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2),null===(c=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===c?void 0:c.info))}}))},o.prototype.formAggregateQueryData=function(e,t,n){if(!e)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_CLOUDDB_ZONE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.AGGREGATE_QUERY_CLOUDDB_ZONE_IS_NULL);if(!(e instanceof CloudDBZoneQuery_1.CloudDBZoneQuery)||typeof e.getClazz()!==Constant_1.VerifyKey.Function)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID);var r=e.getObjectTypeName(),i=e.clazzInstance;o.checkAggregateQueryInput(i,t,n,e.conditionValidate.isGenericObj);var c=e.getQueryConditions();c.push({fieldName:t,conditionType:n});var u=e.conditionValidate.isGenericObj?Utils_1.Utils.serializeGenericObjQuery(c):Utils_1.Utils.serializeQueryConditions(c,i.getFieldTypeMap());return{objectTypeName:r,cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),queryConditions:u}},o.prototype.checkOperator=function(e,o){var t,n,r,i,c=e.getObject();o||DataModelHelper_1.DataModelHelper.checkPrimaryKeys(c);var u=e.getIncrementMap(),d=e.getUpdateMap(),a=new Set;try{for(var s=__values(u.entries()),C=s.next();!C.done;C=s.next()){var l=__read(C.value,2),E=l[0],_=l[1];a.add(E),DataModelHelper_1.DataModelHelper.checkOperatorField(E,_,c,!0,!!o)}}catch(e){t={error:e}}finally{try{C&&!C.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}try{for(var D=__values(d.entries()),p=D.next();!p.done;p=D.next()){var A=__read(p.value,2);E=A[0],_=A[1];a.add(E),DataModelHelper_1.DataModelHelper.checkOperatorField(E,_,c,!1,!!o)}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=D.return)&&i.call(D)}finally{if(r)throw r.error}}if(a.size<u.size+d.size)throw console.warn((0,ErrorCodeMessage_1.getErrorMessage)(CloudDBErrorCode_1.CloudDBErrorCode.DUPLICATE_FIELD)),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DUPLICATE_FIELD)},o.getPrimaryKeys=function(e){var o,t,n={},r=e instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?e.primaryKeys:e.getPrimaryKeyList();try{for(var i=__values(r),c=i.next();!c.done;c=i.next()){var u=c.value;n[u]=e instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?e.getFieldValue(u):e[u]}}catch(e){o={error:e}}finally{try{c&&!c.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return n},o.checkConstraint=function(e,o){if(o){if(!(e instanceof o.getClazz()))throw console.warn((0,ErrorCodeMessage_1.getErrorMessage)(CloudDBErrorCode_1.CloudDBErrorCode.OPERATOR_MISMATCH_CONSTRAINT)),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.OPERATOR_MISMATCH_CONSTRAINT);this.checkConstraintOnly(o)}},o.checkConstraintOnly=function(e){var o,t;if(!e)throw console.warn((0,ErrorCodeMessage_1.getErrorMessage)(CloudDBErrorCode_1.CloudDBErrorCode.OPERATOR_MISMATCH_CONSTRAINT)),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.OPERATOR_MISMATCH_CONSTRAINT);ConditionValidate_1.ConditionValidate.checkConditionLen(e.getConditions());var n=new ConditionValidate_1.ConditionValidate(e.getClazz(),e.clazzInstance);try{for(var r=__values(e.getConditions()),i=r.next();!i.done;i=r.next()){var c=i.value;n.checkCondition(c)}}catch(e){o={error:e}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(o)throw o.error}}},o.prototype.handleIncrementData=function(e,t){var n,r,i=this;try{if(0===(n=this.objectListTransform(e)).length)return console.log("ObjectList is empty when execute ".concat(t,".")),Promise.resolve(0);r=this.formData(n,t)}catch(e){return Promise.reject(e)}var c="RECOVERY"==t?this.RECOVERY_DATA_URL:this.DATA_URL,u=this.URL_PREFIX+c;return new Promise((function(e,n){var c=i.generalRequestId();i.requestSender.sendPostRequest(u,c,r).then((function(n){i.checkResponseBody(n),e(n[o.KEY_DATA][RequestOperationTypeMap.get(t).resKey])})).catch((function(){i.resendUpsertRequest(e,n,u,c,r,t)}))}))},o.prototype.formData=function(e,o,t){var n;n=e[0]instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?e[0].getObjectTypeName():e[0].constructor.name;var r={cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),objectTypeName:n,objects:Utils_1.Utils.serializeObjects(e)};switch(o){case"UPSERT":case"INSERT":r.operationType=RequestOperationTypeMap.get(o).operationType;break;case"RECYCLEBIN_DELETE":r.isDeleteDisused=t}if(JSON.stringify(r).length>MAX_OBJECTS_CAPACITY)throw console.warn("upsert data size is more than 20MB"),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.DATA_SIZE_IS_OVERFLOW);return r},o.prototype.executeQueryInternal=function(e,t,n,r){return __awaiter(this,void 0,void 0,(function(){var i,c,u,d,a,s,C=this;return __generator(this,(function(l){return e?e instanceof CloudDBZoneQuery_1.CloudDBZoneQuery&&typeof e.getClazz()===Constant_1.VerifyKey.Function?(i=e.clazzInstance,this.verifyPaginationQuery(e,i),c=this.URL_PREFIX+this.QUERIES_URL,u=e.conditionValidate.fieldTypeMap,d=e.getQueryConditions(),a=e.conditionValidate.isGenericObj?Utils_1.Utils.serializeGenericObjQuery(d,n,r):Utils_1.Utils.serializeQueryConditions(d,i.getFieldTypeMap(),n,r),s={objectTypeName:e.getObjectTypeName(),cloudDBZoneName:this.cloudDBZoneConfig.getCloudDBZoneName(),isQueryDelete:t,queryConditions:a},[2,new Promise((function(t,n){var r=C.generalRequestId();C.requestSender.sendPostRequest(c,r,s).then((function(n){o.responseCheck(n);var r=Utils_1.Utils.deserializeObjects(n[o.KEY_DATA][o.KEY_DATA],u,e.getClazz(),e.getObjectTypeName()),i=new CloudDBZoneSnapshot_1.CloudDBZoneSnapshot(r);t(i)})).catch((function(){C.requestSender.sendPostRequest(c,r,s,!0).then((function(n){o.responseCheck(n);var r=Utils_1.Utils.deserializeObjects(n[o.KEY_DATA][o.KEY_DATA],u,e.getClazz(),e.getObjectTypeName()),i=new CloudDBZoneSnapshot_1.CloudDBZoneSnapshot(r);t(i)})).catch((function(e){var o,t;if(console.warn("Query catch error, requestId:"+r.traceId),C.isErrResponseNotValid(e))n(e);else{var i=String(e.response.data.errorCodeV2);i!==CloudDBErrorCode_1.CloudDBErrorCode.NOT_SUPPORT_QUERY_DATA_TYPE&&i!==CloudDBErrorCode_1.CloudDBErrorCode.ERROR_CODE_PAGINATION_QUERY_FAILED_FOR_NO_INDEX?n(new AGConnectCloudDBException_1.AGConnectCloudDBException(i)):n(new AGConnectCloudDBException_1.AGConnectCloudDBException(String(e.response.data.errorCodeV2),null===(t=null===(o=null==e?void 0:e.response)||void 0===o?void 0:o.data)||void 0===t?void 0:t.info))}}))}))}))]):(console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID).message),[2,Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID))]):(console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.QUERY_CONDITION_IS_NULL).message),[2,Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.QUERY_CONDITION_IS_NULL))])}))}))},o.prototype.executeDeleteInternal=function(e,o){var t,n;try{if(0===(t=this.objectListTransform(e)).length)return console.log("ObjectList is empty when execute Delete."),Promise.resolve(0);var r=o?"RECYCLEBIN_DELETE":"DELETE";n=this.formData(t,r,o)}catch(e){return Promise.reject(e)}var i=this.URL_PREFIX+this.DATA_URL;return this.objectDeleteResponse(i,n)},o.prototype.checkGenericObjectPaginationEqualTo=function(e,o,t){var n=e.fieldName;if(o.primaryKeys.has(n))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_NOT_SUPPORT_PRIMARY_KEY).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_NOT_SUPPORT_PRIMARY_KEY);if(t.has(n))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_FIELD_IS_SAME_WITH_ORDER_BY).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PAGINATE_EQUAL_TO_FIELD_IS_SAME_WITH_ORDER_BY)},o.KEY_DATA="data",o}(CloudDBService_1.CloudDBService);exports.CloudDBZone=CloudDBZone;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ import { CloudDBZoneQuery } from '../query/CloudDBZoneQuery';
5
+ import { CloudDBZone } from './CloudDBZone';
6
+ export type Operation = {
7
+ operationType: OperationType;
8
+ objectTypeName: string;
9
+ objects: unknown[];
10
+ };
11
+ export type verifyObject = {
12
+ objectTypeName: string;
13
+ objects: unknown[];
14
+ };
15
+ export type verifyMapObject = {
16
+ objectTypeName: string;
17
+ clazz: any;
18
+ objects: unknown[];
19
+ };
20
+ /**
21
+ * Transaction is a class that describe a transaction supplied to user, there are executeQuery,
22
+ * executeUpsert, executeDelete operation in transaction; all operation called in a transaction object.
23
+ */
24
+ export declare class Transaction {
25
+ needVerifyObjectsList: any[];
26
+ transactionList: Operation[];
27
+ private cloudDBZone;
28
+ private needVerifyObjectMap;
29
+ private needVerifyDataNum;
30
+ private queryDataLength;
31
+ constructor(cloudDBZone: CloudDBZone);
32
+ /**
33
+ * developers use this API to select a table by a naturalStoreQuery in a transaction.
34
+ *
35
+ * @param cloudDBZoneQuery user construct a naturalStoreQuery using api. such as where, equalTo...
36
+ * @returns list of T.
37
+ */
38
+ executeQuery<T>(cloudDBZoneQuery: CloudDBZoneQuery<T>): Promise<T[]>;
39
+ private checkQueryData;
40
+ private static getVersionData;
41
+ /**
42
+ * developers use this API to upsert specific records in a table.
43
+ *
44
+ * @param objectList object list need to be deleted from database.
45
+ * @returns promise with Transaction itself.
46
+ */
47
+ executeUpsert<T>(objectList: T[]): Transaction;
48
+ /**
49
+ * developers use this API to delete specific records in a table.
50
+ *
51
+ * @param objectList object list need to be deleted from database.
52
+ * @returns promise with Transaction itself.
53
+ */
54
+ executeDelete<T>(objectList: T[]): Transaction;
55
+ private static checkInputData;
56
+ formTransactionData(objectList: any[], operationType: OperationType): Operation;
57
+ release(): void;
58
+ isTransactionEmpty(): boolean;
59
+ sortVerifyObjectsList(): void;
60
+ }
61
+ export declare enum OperationType {
62
+ UPSERT = "Upsert",
63
+ DELETE = "Delete"
64
+ }
65
+ export interface TransactionFunction {
66
+ /**
67
+ * apply implemented by user
68
+ *
69
+ * @param transaction enter transaction
70
+ * @returns boolean value
71
+ */
72
+ apply(transaction: Transaction): Promise<boolean>;
73
+ }
@@ -0,0 +1 @@
1
+ "use strict";var __assign=this&&this.__assign||function(){return __assign=Object.assign||function(e){for(var o,t=1,r=arguments.length;t<r;t++)for(var n in o=arguments[t])Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n]);return e},__assign.apply(this,arguments)},__awaiter=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function c(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var o;e.done?n(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(a,c)}l((r=r.apply(e,o||[])).next())}))},__generator=this&&this.__generator||function(e,o){var t,r,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(l){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(t=1,r&&(n=2&c[0]?r.return:c[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,c[1])).done)return n;switch(r=0,n&&(c=[2&c[0],n.value]),c[0]){case 0:case 1:n=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!n||c[1]>n[0]&&c[1]<n[3])){a.label=c[1];break}if(6===c[0]&&a.label<n[1]){a.label=n[1],n=c;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(c);break}n[2]&&a.ops.pop(),a.trys.pop();continue}c=o.call(e,a)}catch(e){c=[6,e],r=0}finally{t=n=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,l])}}},__read=this&&this.__read||function(e,o){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,n,i=t.call(e),a=[];try{for(;(void 0===o||o-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(n)throw n.error}}return a},__spreadArray=this&&this.__spreadArray||function(e,o,t){if(t||2===arguments.length)for(var r,n=0,i=o.length;n<i;n++)!r&&n in o||(r||(r=Array.prototype.slice.call(o,0,n)),r[n]=o[n]);return e.concat(r||Array.prototype.slice.call(o))},__values=this&&this.__values||function(e){var o="function"==typeof Symbol&&Symbol.iterator,t=o&&e[o],r=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(o?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperationType=exports.Transaction=void 0;var OperationType,AGConnectCloudDBException_1=require("../exception/AGConnectCloudDBException"),Utils_1=require("../utils/Utils"),CloudDBZoneQuery_1=require("../query/CloudDBZoneQuery"),CloudDBErrorCode_1=require("../exception/CloudDBErrorCode"),CloudDBZoneGenericObject_1=require("../request/CloudDBZoneGenericObject"),Constant_1=require("../utils/Constant"),MAX_QUERY_OBJECT_NUM=1e3,MAX_QUERY_OBJECT_LIST_CAPACITY=20971520,KEY_NATURALBASE_VSERSION="naturalbase_version",Transaction=function(){function e(e){this.needVerifyObjectsList=[],this.transactionList=[],this.needVerifyObjectMap=new Map,this.needVerifyDataNum=0,this.queryDataLength=0,this.cloudDBZone=e}return e.prototype.executeQuery=function(o){return __awaiter(this,void 0,void 0,(function(){var t,r,n,i,a,c,l,u,s;return __generator(this,(function(C){switch(C.label){case 0:if(!o)return console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.QUERY_CONDITION_IS_NULL).message),[2,Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.QUERY_CONDITION_IS_NULL))];if(!(o instanceof CloudDBZoneQuery_1.CloudDBZoneQuery)||typeof o.getClazz()!==Constant_1.VerifyKey.Function)return console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID).message),[2,Promise.reject(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.INPUT_PARAMETER_INVALID))];if(this.transactionList.length>0)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_CODE_TRANSACTION_SEQUENCE_INCORRECT).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_CODE_TRANSACTION_SEQUENCE_INCORRECT);return[4,this.cloudDBZone.executeTransactionQuery(o,!1)];case 1:return t=C.sent(),this.checkQueryData(t),r=o.getClazz(),n=o.clazzInstance,i=__spreadArray([],__read(t),!1).map((function(e){return __assign({},e)})),(a=o.conditionValidate.isGenericObj)?t.forEach((function(e){delete e[KEY_NATURALBASE_VSERSION]})):i=e.getVersionData(t,n.getPrimaryKeyList()),this.needVerifyObjectMap.has(o.getObjectTypeName())?(c=this.needVerifyObjectMap.get(o.getObjectTypeName()).objects.concat(i),this.needVerifyObjectMap.get(o.getObjectTypeName()).objects=c):(l={objectTypeName:o.getObjectTypeName(),clazz:n,objects:i},this.needVerifyObjectMap.set(o.getObjectTypeName(),l)),u=a?o.conditionValidate.fieldTypeMap:n.getFieldTypeMap(),s=Utils_1.Utils.deserializeObjects(t,u,r,o.getObjectTypeName()),[2,Promise.resolve(s)]}}))}))},e.prototype.checkQueryData=function(e){if(!e)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.FAIL_TO_PARSE_QUERY_DATA).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.FAIL_TO_PARSE_QUERY_DATA);if(e.length>MAX_QUERY_OBJECT_NUM)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_QUERY_DATA_COUNT_TOO_LARGE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_QUERY_DATA_COUNT_TOO_LARGE);if(this.needVerifyDataNum+=e.length,this.needVerifyDataNum>MAX_QUERY_OBJECT_NUM)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_QUERY_DATA_COUNT_TOO_LARGE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_QUERY_DATA_COUNT_TOO_LARGE);if(this.queryDataLength+=JSON.stringify(e).length,this.queryDataLength>MAX_QUERY_OBJECT_LIST_CAPACITY)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_QUERY_DATA_SIZE_TOO_LARGE).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.ERROR_QUERY_DATA_SIZE_TOO_LARGE)},e.getVersionData=function(e,o){var t,r,n,i,a=[];try{for(var c=__values(e),l=c.next();!l.done;l=c.next()){var u=l.value,s={};try{for(var C=(n=void 0,__values(o)),d=C.next();!d.done;d=C.next()){var _=d.value,E=u[_];if(null===E)throw console.warn("the primaryKey data is null"),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PARAMETER_INVALID);s[_]=E}}catch(e){n={error:e}}finally{try{d&&!d.done&&(i=C.return)&&i.call(C)}finally{if(n)throw n.error}}var p=u[KEY_NATURALBASE_VSERSION];if(!p)throw console.warn("the version data is null"),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PARAMETER_INVALID);s[KEY_NATURALBASE_VSERSION]=p,a.push(s)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return a},e.prototype.executeUpsert=function(o){return e.checkInputData(o),0===o.length||(Utils_1.Utils.checkSchemaAndDataSize(o),this.transactionList.push(this.formTransactionData(o,OperationType.UPSERT))),this},e.prototype.executeDelete=function(o){return e.checkInputData(o),0===o.length||(Utils_1.Utils.checkSchemaAndDataSize(o),this.transactionList.push(this.formTransactionData(o,OperationType.DELETE))),this},e.checkInputData=function(e){if(!e)throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);if(!Utils_1.Utils.isArray(e))throw console.warn(new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PARAMETER_INVALID).message),new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.PARAMETER_INVALID);for(var o=0;o<e.length;o++)if(null==e[o]){var t=new AGConnectCloudDBException_1.AGConnectCloudDBException(CloudDBErrorCode_1.CloudDBErrorCode.VALUE_IS_NULL);throw console.warn(t.message),t}},e.prototype.formTransactionData=function(e,o){return{operationType:o,objectTypeName:e[0]instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?e[0].getObjectTypeName():e[0].getClassName(),objects:Utils_1.Utils.serializeObjects(e)}},e.prototype.release=function(){this.needVerifyObjectsList=[],this.transactionList=[],this.needVerifyObjectMap=new Map,this.needVerifyDataNum=0,this.queryDataLength=0},e.prototype.isTransactionEmpty=function(){var e,o,t=!0;try{for(var r=__values(this.transactionList),n=r.next();!n.done;n=r.next()){if(n.value.objects.length>0){t=!1;break}}}catch(o){e={error:o}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(e)throw e.error}}return t},e.prototype.sortVerifyObjectsList=function(){var e,o,t=Array.from(this.needVerifyObjectMap.values());t.sort((function(e,o){return e.objectTypeName.localeCompare(o.objectTypeName)})),t.forEach((function(e){var o=e.clazz instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?[]:e.clazz.getPrimaryKeyList(),t=e.clazz instanceof CloudDBZoneGenericObject_1.CloudDBZoneGenericObject?new Map:e.clazz.getFieldTypeMap();e.objects.sort((function(e,r){var n,i;try{for(var a=__values(o),c=a.next();!c.done;c=a.next()){var l=c.value,u=t.get(l),s=Utils_1.Utils.primaryKeyCompareTo(e[l],r[l],u);if(0!=s)return s}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return 0}))}));try{for(var r=__values(t),n=r.next();!n.done;n=r.next()){var i=n.value;this.needVerifyObjectsList.push({objectTypeName:i.objectTypeName,objects:i.objects})}}catch(o){e={error:o}}finally{try{n&&!n.done&&(o=r.return)&&o.call(r)}finally{if(e)throw e.error}}},e}();exports.Transaction=Transaction,function(e){e.UPSERT="Upsert",e.DELETE="Delete"}(OperationType=exports.OperationType||(exports.OperationType={}));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ export declare const enum AggregateType {
5
+ AVG = "Average",
6
+ SUM = "Sum",
7
+ MAX = "Max",
8
+ MIN = "Min",
9
+ COUNT = "Count"
10
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023 All rights reserved.
3
+ */
4
+ /**
5
+ * CloudDBSdkUtils provides methods to get information from config file.
6
+ */
7
+ export declare class CloudDBSdkUtils {
8
+ private static readonly SERVICE_NAME;
9
+ /**
10
+ * This method is used to get cloud gate way url from config file.
11
+ *
12
+ * @param region the region of the gate way.
13
+ * @param useBackup Indicates whether to switch the standby gateway address.
14
+ * @returns the url of the cloud gate way.
15
+ */
16
+ static getCloudGwUrl(region?: string | undefined, useBackup?: boolean | undefined): string;
17
+ private static getService;
18
+ /**
19
+ * This method is used to get sdk name from config file.
20
+ *
21
+ * @returns the name of sdk
22
+ */
23
+ static getCloudDBSdkName(): string;
24
+ /**
25
+ * This method is used to get sdk version from config file.
26
+ *
27
+ * @returns the version of sdk
28
+ */
29
+ static getCloudDBSdkVersion(): string;
30
+ }
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CloudDBSdkUtils=void 0;var common_server_1=require("../../common-server"),path_1=__importDefault(require("path")),CONFIG_PATH=path_1.default.join(__dirname,"../agconnect-database.json"),CloudDBSdkUtils=function(){function e(){}return e.getCloudGwUrl=function(e,t){return common_server_1.CloudGwUrlUtil.getCloudgwUrlByRegion(e,t)},e.getService=function(){return common_server_1.ConfigService.initialLoadServiceConfig(this.SERVICE_NAME,CONFIG_PATH),common_server_1.ConfigService.getService(this.SERVICE_NAME)},e.getCloudDBSdkName=function(){return this.getService().getConfigValue("sdk_name")},e.getCloudDBSdkVersion=function(){return this.getService().getConfigValue("sdk_version")},e.SERVICE_NAME="CloudDB",e}();exports.CloudDBSdkUtils=CloudDBSdkUtils;