1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef CLOUD_DATA_JS_CLOUD_UTILS_H 16 #define CLOUD_DATA_JS_CLOUD_UTILS_H 17 18 #include "js_utils.h" 19 #include "cloud_types.h" 20 #include "common_types.h" 21 #include "rdb_predicates.h" 22 #include "result_set.h" 23 #include "js_config.h" 24 25 namespace OHOS::AppDataMgrJsKit { 26 namespace JSUtils { 27 using Participant = OHOS::CloudData::Participant; 28 using Privilege = OHOS::CloudData::Privilege; 29 using RdbPredicates = OHOS::NativeRdb::RdbPredicates; 30 using ResultSet = OHOS::NativeRdb::ResultSet; 31 using ExtraData = OHOS::CloudData::JsConfig::ExtraData; 32 using StatisticInfo = OHOS::CloudData::StatisticInfo; 33 using Asset = OHOS::CommonType::AssetValue; 34 using CloudSyncInfo = OHOS::CloudData::CloudSyncInfo; 35 36 template<> 37 int32_t Convert2Value(napi_env env, napi_value input, ExtraData &output); 38 39 template<> 40 int32_t Convert2Value(napi_env env, napi_value input, Participant &output); 41 42 template<> 43 int32_t Convert2Value(napi_env env, napi_value input, Privilege &output); 44 45 template<> 46 int32_t Convert2Value(napi_env env, napi_value input, std::shared_ptr<RdbPredicates> &output); 47 48 template<> 49 int32_t Convert2Value(napi_env env, napi_value input, Asset &output); 50 51 template<> 52 napi_value Convert2JSValue(napi_env env, const Participant &value); 53 54 template<> 55 napi_value Convert2JSValue(napi_env env, const Privilege &value); 56 57 template<> 58 napi_value Convert2JSValue(napi_env env, const std::shared_ptr<ResultSet> &value); 59 60 template<> 61 napi_value Convert2JSValue(napi_env env, const std::pair<int32_t, std::string> &value); 62 63 template<> 64 napi_value Convert2JSValue(napi_env env, const StatisticInfo &value); 65 66 template<> 67 napi_value Convert2JSValue(napi_env env, const CloudSyncInfo &value); 68 }; // namespace JSUtils 69 } // namespace OHOS::AppDataMgrJsKit 70 #endif // CLOUD_DATA_JS_CLOUD_UTILS_H