diff --git a/scripts/terra/config/c_to_ts_config.ts b/scripts/terra/config/c_to_ts_config.ts new file mode 100644 index 0000000..2937edb --- /dev/null +++ b/scripts/terra/config/c_to_ts_config.ts @@ -0,0 +1,85 @@ +import { SimpleType, SimpleTypeKind } from '@agoraio-extensions/cxx-parser'; +import { + UpdateNodeConfig, + updateSimpleTypeName, +} from '@agoraio-extensions/terra_shared_configs'; + +module.exports = { + '^Optional<(.*)>': '$1', + '^(.*)::(.*)': '$2', + '^AString$': 'string', + '^user_id_t$': 'string', + '^view_t$': 'any', + '^view_t\\*$': 'any[]', + '^uid_t$': 'number', + '^const uid_t\\*$': 'number[]', + '^track_id_t$': 'number', + '^video_track_id_t$': 'number', + '^conn_id_t$': 'number', + '^char$': 'number', + '^unsigned int$': 'number', + '^size_t$': 'number', + '^unsigned short$': 'number', + '^unsigned char$': 'number', + '^float$': 'number', + '^double$': 'number', + '^int(.*)_t$': 'number', + '^uint(.*)_t$': 'number', + '^long$': 'number', + '^long long$': 'number', + '^int$': 'number', + '^bool$': 'boolean', + '^intptr_t$': 'number', + '^uintptr_t$': 'number', + '^const char \\*$': 'string', + '^IMetadata': 'RtmMetadata', + 'customHook': (node: SimpleType, configs: UpdateNodeConfig) => { + let type = node.name; + if (!type) { + type = node.source; + } + switch (node.asSimpleType().kind) { + case SimpleTypeKind.value_t: + type = updateSimpleTypeName(type, configs); + break; + case SimpleTypeKind.pointer_t: + if (type == 'char') { + if (node.source.endsWith('**')) { + type = 'string[]'; + } else { + type = 'string'; + } + } else if (type == 'uint8_t' || type == 'unsigned char') { + type = 'Uint8Array'; + } else if (type == 'void') { + type = 'any'; + } else { + type = updateSimpleTypeName(type, configs); + } + break; + case SimpleTypeKind.reference_t: + type = updateSimpleTypeName(type, configs); + break; + case SimpleTypeKind.array_t: + if (type == 'char') { + if (node.source.endsWith('**')) { + type = 'string[]'; + } else { + type = 'string'; + } + } else if (type == 'void') { + type = 'Uint8Array'; + } else { + type = updateSimpleTypeName(type, configs) + '[]'; + } + break; + case SimpleTypeKind.template_t: + type = updateSimpleTypeName(node.template_arguments[0]!, configs); + break; + default: + type = updateSimpleTypeName(type, configs); + break; + } + return type; + }, +}; diff --git a/scripts/terra/config/filter_file_list.json b/scripts/terra/config/filter_file_list.json deleted file mode 100644 index 596c1be..0000000 --- a/scripts/terra/config/filter_file_list.json +++ /dev/null @@ -1 +0,0 @@ -["AgoraOptional.h", "AgoraRefPtr.h", "IAgoraParameter.h"] diff --git a/scripts/terra/config/fixed_return_type_list.ts b/scripts/terra/config/fixed_return_type_list.ts new file mode 100644 index 0000000..1e61e44 --- /dev/null +++ b/scripts/terra/config/fixed_return_type_list.ts @@ -0,0 +1,11 @@ +import { SimpleTypeKind } from '@agoraio-extensions/cxx-parser'; + +module.exports = { + 'agora::rtm::IStreamChannel.getSubscribedUserList': { + name: 'agora::rtm::UserList', + source: 'agora::rtm::UserList*', + kind: SimpleTypeKind.array_t, + is_const: false, + is_builtin_type: true, + }, +}; diff --git a/scripts/terra/config/impl_configs.yaml b/scripts/terra/config/impl_config.yaml similarity index 63% rename from scripts/terra/config/impl_configs.yaml rename to scripts/terra/config/impl_config.yaml index 019dfd0..20d5085 100644 --- a/scripts/terra/config/impl_configs.yaml +++ b/scripts/terra/config/impl_config.yaml @@ -1,5 +1,4 @@ parsers: - # CXXParser should always put first - name: CXXParser package: '@agoraio-extensions/cxx-parser' args: @@ -9,6 +8,7 @@ parsers: include: - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' exclude: + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' - name: AddNodeParser @@ -22,27 +22,40 @@ parsers: - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/custom_headers/*.h' exclude: + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' + - name: RemoveNodeParser + package: '@agoraio-extensions/terra_shared_configs' + args: + ignoreDefaultConfig: true + configFilePath: ./remove_node_list.ts - name: PointerToArrayParser package: '@agoraio-extensions/terra_shared_configs' args: - configJsonFilePath: ./pointer_to_array.json - - name: OrderNodeParser + ignoreDefaultConfig: true + configFilePath: ./pointer_to_array.ts + - name: UpdateSimpleTypeParser + package: '@agoraio-extensions/terra_shared_configs' + args: + ignoreDefaultConfig: true + configFilePath: ./rename_member_function_param_type_list.ts + - name: ReturnTypeParser package: '@agoraio-extensions/terra_shared_configs' + args: + convertReturnToVoid: false + ignoreDefaultConfig: true + configFilePath: ./fixed_return_type_list.ts - name: FixEnumConstantParser package: '@agoraio-extensions/terra_shared_configs' - - name: UpdateSimpleTypeParser + - name: OrderNodeParser package: '@agoraio-extensions/terra_shared_configs' - args: - configJsonFilePath: ./param_type_list.json - - name: RemoveNodeParser + - name: UpdateSimpleTypeParser package: '@agoraio-extensions/terra_shared_configs' args: - configJsonFilePath: ./remove_node_list.json - -# defines_macros: -# - __IRIS_WEB__ + parserDefaultValue: true + ignoreDefaultConfig: true + configFilePath: ./c_to_ts_config.ts renderers: - path: ../impl.ts diff --git a/scripts/terra/config/impl_special_return_list.json b/scripts/terra/config/impl_special_return_list.json deleted file mode 100644 index 8a1d208..0000000 --- a/scripts/terra/config/impl_special_return_list.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "agora::rtm::IRtmPresence.whoNow": "requestId", - "agora::rtm::IRtmPresence.whereNow": "requestId", - "agora::rtm::IRtmPresence.setState": "requestId", - "agora::rtm::IRtmPresence.removeState": "requestId", - "agora::rtm::IRtmPresence.getState": "requestId", - "agora::rtm::IRtmPresence.getOnlineUsers": "requestId", - "agora::rtm::IRtmPresence.getUserChannels": "requestId", - "agora::rtm::IRtmLock.setLock": "requestId", - "agora::rtm::IRtmLock.getLocks": "requestId", - "agora::rtm::IRtmLock.removeLock": "requestId", - "agora::rtm::IRtmLock.acquireLock": "requestId", - "agora::rtm::IRtmLock.releaseLock": "requestId", - "agora::rtm::IRtmLock.revokeLock": "requestId", - "agora::rtm::IRtmStorage.setChannelMetadata": "requestId", - "agora::rtm::IRtmStorage.updateChannelMetadata": "requestId", - "agora::rtm::IRtmStorage.removeChannelMetadata": "requestId", - "agora::rtm::IRtmStorage.getChannelMetadata": "requestId", - "agora::rtm::IRtmStorage.setUserMetadata": "requestId", - "agora::rtm::IRtmStorage.updateUserMetadata": "requestId", - "agora::rtm::IRtmStorage.removeUserMetadata": "requestId", - "agora::rtm::IRtmStorage.getUserMetadata": "requestId", - "agora::rtm::IRtmStorage.subscribeUserMetadata": "requestId", - "agora::rtm::IStreamChannel.join": "requestId", - "agora::rtm::IStreamChannel.leave": "requestId", - "agora::rtm::IStreamChannel.joinTopic": "requestId", - "agora::rtm::IStreamChannel.leaveTopic": "requestId", - "agora::rtm::IRtmClient.publish": "requestId", - "agora::rtm::ext::IRtmClient.publishWithBuffer": "requestId", - "agora::rtm::IRtmClient.subscribe": "requestId" -} diff --git a/scripts/terra/config/param_optional_list.json b/scripts/terra/config/param_optional_list.json deleted file mode 100644 index 9381ddc..0000000 --- a/scripts/terra/config/param_optional_list.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - "agora::rtm::IRtmClient.publish.requestId", - "agora::rtm::IRtmClient.subscribe.requestId", - "agora::rtm::ext::IRtmClient.publishWithBuffer.requestId", - "agora::rtm::IRtmLock.setLock.requestId", - "agora::rtm::IRtmLock.getLocks.requestId", - "agora::rtm::IRtmLock.removeLock.requestId", - "agora::rtm::IRtmLock.acquireLock.requestId", - "agora::rtm::IRtmLock.releaseLock.requestId", - "agora::rtm::IRtmLock.revokeLock.requestId", - "agora::rtm::IRtmPresence.whoNow.requestId", - "agora::rtm::IRtmPresence.whereNow.requestId", - "agora::rtm::IRtmPresence.setState.requestId", - "agora::rtm::IRtmPresence.removeState.requestId", - "agora::rtm::IRtmPresence.getState.requestId", - "agora::rtm::IRtmPresence.getOnlineUsers.requestId", - "agora::rtm::IRtmPresence.getUserChannels.requestId", - "agora::rtm::IChannel.updateAttributes.requestId", - "agora::rtm::IChannel.deleteAttributes.requestId", - "agora::rtm::IRtmStorage.setChannelMetadata.requestId", - "agora::rtm::IRtmStorage.updateChannelMetadata.requestId", - "agora::rtm::IRtmStorage.removeChannelMetadata.requestId", - "agora::rtm::IRtmStorage.getChannelMetadata.requestId", - "agora::rtm::IRtmStorage.setUserMetadata.requestId", - "agora::rtm::IRtmStorage.updateUserMetadata.requestId", - "agora::rtm::IRtmStorage.removeUserMetadata.requestId", - "agora::rtm::IRtmStorage.getUserMetadata.requestId", - "agora::rtm::IRtmStorage.subscribeUserMetadata.requestId", - "agora::rtm::IStreamChannel.join.requestId", - "agora::rtm::IStreamChannel.leave.requestId", - "agora::rtm::IStreamChannel.joinTopic.requestId", - "agora::rtm::IStreamChannel.leaveTopic.requestId", - "agora::rtm::IStreamChannel.subscribeTopic.requestId", - "agora::rtm::IStreamChannel.subscribeTopic.options", - "agora::rtm::IStreamChannel.unsubscribeTopic.options" -] diff --git a/scripts/terra/config/param_type_list.json b/scripts/terra/config/param_type_list.json deleted file mode 100644 index 31656a2..0000000 --- a/scripts/terra/config/param_type_list.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "agora::rtm::IChannelMember\\*": "IChannelMember", - "^Optional<(.*)>": "$1", - "^util::(.*)": "$1", - "^agora::(.*)": "$1", - "^rtm::(.*)": "$1", - "^agora::rtm::(.*)": "$1", - "^agora_refptr": "$1", - "^agora::util::(.*)": "$1", - "^(.*)::(.*)": "$2", - "^(.*)const&": "$1", - "^(.*)&": "$1", - "^(.*)\\[(.*)\\]": "$1", - - "^char const\\*$": "string", - "^char\\*$": "string", - "^char\\**$": "string[]", - "^char const\\**$": "string[]", - "^unsigned char const\\*$": "Uint8Array", - "^unsigned char const\\**$": "Uint8Array[]", - "^uint(.*)_t const\\*$": "Uint8Array", - "^uint(.*)_t const$": "number", - "^int(.*)_t const$": "number", - "^size_t const$": "number", - - "^size_t\\*$": "number", - "^size_t$": "number", - "^char$": "string", - "^int$": "number", - "^uint(.*)_t$": "number", - "^int(.*)_t$": "number", - "^bool$": "boolean", - "^long long$": "number", - "^ulong$": "number", - "^long$": "number", - - "^(.*)const\\*$": "$1[]", - "^(.*)\\*$": "$1[]", - "^IMetadata": "RtmMetadata" -} diff --git a/scripts/terra/config/pointer_to_array.json b/scripts/terra/config/pointer_to_array.json deleted file mode 100644 index 5e52259..0000000 --- a/scripts/terra/config/pointer_to_array.json +++ /dev/null @@ -1 +0,0 @@ -["^(.*)(List|s)$"] diff --git a/scripts/terra/config/pointer_to_array.ts b/scripts/terra/config/pointer_to_array.ts new file mode 100644 index 0000000..b9a9828 --- /dev/null +++ b/scripts/terra/config/pointer_to_array.ts @@ -0,0 +1,10 @@ +module.exports = [ + 'agora::rtm::IRtmPresence.setState.items', + 'agora::rtm::IRtmEventHandler.onWhereNowResult.channels', + 'agora::rtm::IRtmEventHandler.onGetUserChannelsResult.channels', + 'agora::rtm::IChannelEventHandler.onMembersGotten.members', + 'agora::rtm::IStreamChannel.unsubscribeTopic.options', + 'agora::rtm::IChannelEventHandler.onAttributesUpdated.attributes', + 'agora::rtm::IChannelEventHandler.onAttributesDeleted.attributes', + 'agora::rtm::IChannelEventHandler.updateAttributes.attributes', +]; diff --git a/scripts/terra/config/remove_node_list.json b/scripts/terra/config/remove_node_list.json deleted file mode 100644 index 8fb24cc..0000000 --- a/scripts/terra/config/remove_node_list.json +++ /dev/null @@ -1,9 +0,0 @@ -[ - "operator==", - "operator!=", - "operator=", - "operator>", - "operator<", - "Optional", - "agora::rtm::IMetadata" -] diff --git a/scripts/terra/config/remove_node_list.ts b/scripts/terra/config/remove_node_list.ts new file mode 100644 index 0000000..3e397fe --- /dev/null +++ b/scripts/terra/config/remove_node_list.ts @@ -0,0 +1,4 @@ +module.exports = [ + 'agora::rtm::IMetadata', + 'agora::rtm::IStreamChannel.getSubscribedUserList.users', +]; diff --git a/scripts/terra/config/rename_member_function_param_type_list.ts b/scripts/terra/config/rename_member_function_param_type_list.ts new file mode 100644 index 0000000..f053ebf --- /dev/null +++ b/scripts/terra/config/rename_member_function_param_type_list.ts @@ -0,0 +1 @@ +module.exports = {}; diff --git a/scripts/terra/config/types_configs.yaml b/scripts/terra/config/types_config.yaml similarity index 60% rename from scripts/terra/config/types_configs.yaml rename to scripts/terra/config/types_config.yaml index 80b8498..2360a52 100644 --- a/scripts/terra/config/types_configs.yaml +++ b/scripts/terra/config/types_config.yaml @@ -1,5 +1,4 @@ parsers: - # CXXParser should always put first - name: CXXParser package: '@agoraio-extensions/cxx-parser' args: @@ -9,6 +8,7 @@ parsers: include: - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' exclude: + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' - name: AddNodeParser @@ -22,27 +22,44 @@ parsers: - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/*.h' - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/custom_headers/*.h' exclude: + - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraRtmService.h' - '@agoraio-extensions/terra_shared_configs:headers/rtm_2.1.7/include/IAgoraService.h' + - name: RemoveNodeParser + package: '@agoraio-extensions/terra_shared_configs' + args: + ignoreDefaultConfig: true + configFilePath: ./remove_node_list.ts - name: PointerToArrayParser package: '@agoraio-extensions/terra_shared_configs' args: - configJsonFilePath: ./pointer_to_array.json - - name: OrderNodeParser + ignoreDefaultConfig: true + configFilePath: ./pointer_to_array.ts + - name: UpdateSimpleTypeParser + package: '@agoraio-extensions/terra_shared_configs' + args: + ignoreDefaultConfig: true + configFilePath: ./rename_member_function_param_type_list.ts + - name: ReturnTypeParser package: '@agoraio-extensions/terra_shared_configs' + args: + convertReturnToVoid: false + ignoreDefaultConfig: true + configFilePath: ./fixed_return_type_list.ts - name: FixEnumConstantParser package: '@agoraio-extensions/terra_shared_configs' + - name: OrderNodeParser + package: '@agoraio-extensions/terra_shared_configs' - name: UpdateSimpleTypeParser package: '@agoraio-extensions/terra_shared_configs' args: - configJsonFilePath: ./param_type_list.json - - name: RemoveNodeParser + parserDefaultValue: true + ignoreDefaultConfig: true + configFilePath: ./c_to_ts_config.ts + - name: TsCommentParser package: '@agoraio-extensions/terra_shared_configs' args: - configJsonFilePath: ./remove_node_list.json - -# defines_macros: -# - __IRIS_WEB__ + language: 'ts' renderers: - path: ../index.ts diff --git a/scripts/terra/generate-code.sh b/scripts/terra/generate-code.sh new file mode 100644 index 0000000..0277905 --- /dev/null +++ b/scripts/terra/generate-code.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e +set -x + +MY_PATH=$(realpath $(dirname "$0")) +PROJECT_ROOT=$(realpath ${MY_PATH}/../..) + +npm exec terra -- run \ + --config ${PROJECT_ROOT}/scripts/terra/config/types_config.yaml \ + --output-dir=${PROJECT_ROOT}/src + +npm exec terra -- run \ + --config ${PROJECT_ROOT}/scripts/terra/config/impl_config.yaml \ + --output-dir=${PROJECT_ROOT}/src + +cd ${PROJECT_ROOT} + +yarn exec eslint --fix --ext .ts ./src diff --git a/scripts/terra/generate-prepare.sh b/scripts/terra/generate-prepare.sh new file mode 100644 index 0000000..0171900 --- /dev/null +++ b/scripts/terra/generate-prepare.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e +set -x + +# treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it. +touch yarn.lock +rm -rf node_modules +rm -rf .terra +yarn install +rm yarn.lock diff --git a/scripts/terra/impl.ts b/scripts/terra/impl.ts index 4a6e22f..e380b92 100644 --- a/scripts/terra/impl.ts +++ b/scripts/terra/impl.ts @@ -4,7 +4,7 @@ import { CXXFile, CXXTYPE, CXXTerraNode, - SimpleTypeKind, + Variable, } from '@agoraio-extensions/cxx-parser'; import { ParseResult, TerraContext } from '@agoraio-extensions/terra-core'; @@ -12,16 +12,17 @@ import { ParseResult, TerraContext } from '@agoraio-extensions/terra-core'; import { renderWithConfiguration } from '@agoraio-extensions/terra_shared_configs'; import { - appendNumberToDuplicateMemberFunction, - filterFile, + deepClone, + findClazz, + findEnumz, + findStruct, isMatch, + upperFirstWord, } from './utils'; -const implSpecialReturnList = require('./config/impl_special_return_list.json'); -const paramOptionalList = require('./config/param_optional_list.json'); - interface CXXFileUserData { fileName: string; + renderFileEnd: boolean; } interface TerraNodeUserData { @@ -33,97 +34,173 @@ interface TerraNodeUserData { prefix_name: string; } +interface VariableUserData { + name: string; +} + interface ClazzMethodUserData { + output: string; + input: string; + input_map: Variable[]; + input_map_fixed: Variable[]; + output_map: Variable[]; hasParameters: boolean; bindingFunctionName?: string; - bindingIrisKey?: string; - returnParamName?: string; + renderApiType?: string; + returnParam?: string; } export function impl(parseResult: ParseResult) { + let preParseResult = deepClone(parseResult, ['parent', 'outVariable']); let cxxfiles = parseResult.nodes as CXXFile[]; - //移除不需要的文件 - let view = filterFile(cxxfiles).map((cxxfile: CXXFile) => { - const cxxUserData: CXXFileUserData = { - fileName: path.basename( - cxxfile.file_path, - path.extname(cxxfile.file_path) - ), - }; - cxxfile.user_data = cxxUserData; - - let nodes = cxxfile.nodes.filter((node: CXXTerraNode) => { - return node.__TYPE === CXXTYPE.Clazz; - }); + //only render file which has clazz + let view = cxxfiles + .filter((cxxfile) => { + return ( + cxxfile.nodes.filter((node) => { + return node.__TYPE === CXXTYPE.Clazz; + }).length > 0 + ); + }) + .map((cxxfile: CXXFile) => { + const cxxUserData: CXXFileUserData = { + renderFileEnd: false, + fileName: path.basename( + cxxfile.file_path, + path.extname(cxxfile.file_path) + ), + }; - cxxfile.nodes = nodes.map((node: CXXTerraNode) => { - if (node.name === 'IStreamChannelImpl') { - // debugger; - } + let nodes = cxxfile.nodes.filter((node: CXXTerraNode) => { + return node.__TYPE === CXXTYPE.Clazz; + }); - //重载函数重命名, 自动末尾+数字 - //['joinChannel', 'joinChannel'] => ['joinChannel', 'joinChannel2'] - node.asClazz().methods = appendNumberToDuplicateMemberFunction( - node.asClazz().methods - ); - node.asClazz().methods.map((method) => { - const clazzMethodUserData: ClazzMethodUserData = { - hasParameters: method.parameters.length > 0, - bindingFunctionName: `getApiTypeFrom${ - method.name.charAt(0).toUpperCase() + method.name.slice(1) - }`, - returnParamName: - method.parameters.filter((param) => { - return param.name === implSpecialReturnList[method.fullName]; - }).length > 0 - ? implSpecialReturnList[method.fullName] - : 'result', - bindingIrisKey: `${node.asClazz().name.slice(1)}_${method.name}`, - }; - method.user_data = clazzMethodUserData; - method.asMemberFunction().parameters.map((param) => { - const clazzMethodParametersUserData = { - isOptional: paramOptionalList.includes(param.fullName), + cxxfile.nodes = nodes.map((node: CXXTerraNode) => { + node.asClazz().methods.map((method) => { + let output_params: string[] = []; + let input_params: string[] = []; + const clazzMethodUserData: ClazzMethodUserData = { + output: '', + input: '', + input_map: [], + input_map_fixed: [], + output_map: [], + hasParameters: true, + bindingFunctionName: `getApiTypeFrom${upperFirstWord(method.name)}`, + returnParam: '', + renderApiType: `${node.asClazz().name.slice(1)}_${method.name}`, }; - if (param.type.kind === SimpleTypeKind.pointer_t) { - param.type.source = param.type.source.replace('[]', ''); + // method.return_type.name = convertToCamelCase(method.return_type.name); + method.asMemberFunction().parameters.map((param) => { + let variableUserData: VariableUserData = { + name: param.name, + }; + let typeName = param.type.name; + let default_value = param.default_value; + param.user_data = variableUserData; + if (param.is_output) { + output_params.push(`${variableUserData.name}: ${typeName}`); + clazzMethodUserData.output_map.push(param); + } else { + let member = `${variableUserData.name}: ${typeName}`; + if (param.default_value) { + if ( + param.default_value == '__null' || + param.default_value == 'nullptr' + ) { + member = `${variableUserData.name}?: ${typeName}`; + } else if (param.type.is_builtin_type) { + member += ` = ${default_value}`; + } else { + let flag = false; + if (findStruct(param.type.name, preParseResult).length > 0) { + flag = true; + member += ` = new ${default_value}`; + } + if (findEnumz(param.type.name, preParseResult).length > 0) { + flag = true; + member += ` =${typeName}.${default_value}`; + } + if (!flag) { + member += ` = ${default_value}`; + } + } + } + input_params.push(member); + clazzMethodUserData.input_map.push(param); + if ( + typeName !== 'Uint8Array' && + findClazz(param.type.name, preParseResult).length <= 0 + ) { + clazzMethodUserData.input_map_fixed.push(param); + } + } + }); + if (output_params.length > 0) { + if ( + method.asMemberFunction().return_type.name !== 'void' && + method.asMemberFunction().return_type.name !== 'number' + ) { + output_params.push(`result: ${method.return_type.name},`); + } } - param.user_data = clazzMethodParametersUserData; + clazzMethodUserData.input = input_params.join(','); + if (output_params.length > 1) { + clazzMethodUserData.output = `{${output_params.join(',')}}`; + } else if (output_params.length == 1) { + clazzMethodUserData.output = output_params[0]?.split(': ')[1]!; + } else { + clazzMethodUserData.output = `${method.return_type.name}`; + } + clazzMethodUserData.hasParameters = + clazzMethodUserData.input_map.length > 0; + if ( + clazzMethodUserData.output_map.length > 0 || + method.return_type.name !== 'void' + ) { + clazzMethodUserData.returnParam = `const jsonResults = `; + } + clazzMethodUserData.returnParam += + 'callIrisApi.call(this, apiType, jsonParams);\n'; + clazzMethodUserData.output_map.map((output) => { + clazzMethodUserData.returnParam += ` const ${output.name} = jsonResults.${output.name};\n`; + }); + if (clazzMethodUserData.output_map.length === 0) { + if (method.return_type.name !== 'void') { + clazzMethodUserData.returnParam += ` return jsonResults.result;\n`; + } + } else { + if (clazzMethodUserData.output_map.length === 1) { + clazzMethodUserData.returnParam += ` return ${clazzMethodUserData.output_map[0]?.name}\n`; + } else { + clazzMethodUserData.returnParam += ` return {\n`; + clazzMethodUserData.output_map.map((output) => { + clazzMethodUserData.returnParam += `${output.name},\n`; + }); + clazzMethodUserData.returnParam += `}\n`; + } + } + method.user_data = clazzMethodUserData; }); - if (method.return_type.kind === SimpleTypeKind.pointer_t) { - method.return_type.source = method.return_type.source.replace( - '[]', - '' - ); + + const terraNodeUserData: TerraNodeUserData = { + isStruct: node.__TYPE === CXXTYPE.Struct, + isEnumz: node.__TYPE === CXXTYPE.Enumz, + isClazz: node.__TYPE === CXXTYPE.Clazz, + prefix_name: node.name.replace(new RegExp('^I(.*)'), '$1'), + hasBaseClazzs: node.asClazz().base_clazzs.length > 0, + isCallback: isMatch(node.name, 'isCallback'), + }; + node.user_data = terraNodeUserData; + if (!cxxUserData.renderFileEnd && !terraNodeUserData.isCallback) { + cxxUserData.renderFileEnd = true; } + return node; }); - const terraNodeUserData: TerraNodeUserData = { - isStruct: node.__TYPE === CXXTYPE.Struct, - isEnumz: node.__TYPE === CXXTYPE.Enumz, - isClazz: node.__TYPE === CXXTYPE.Clazz, - prefix_name: node.name.replace(new RegExp('^I(.*)'), '$1'), - hasBaseClazzs: node.asClazz().base_clazzs.length > 0, - isCallback: isMatch(node.name, 'isCallback'), - }; - node.user_data = terraNodeUserData; - - return node; + cxxfile.user_data = cxxUserData; + return cxxfile; }); - return cxxfile; - }); - //移除不含有Clazz,Enumz,Struct的文件 - view = view.filter((cxxfile) => { - return ( - cxxfile.nodes.filter((node) => { - return ( - node.__TYPE === CXXTYPE.Clazz || - node.__TYPE === CXXTYPE.Enumz || - node.__TYPE === CXXTYPE.Struct - ); - }).length > 0 - ); - }); return view; } diff --git a/scripts/terra/index.ts b/scripts/terra/index.ts index 981ea0c..53da549 100644 --- a/scripts/terra/index.ts +++ b/scripts/terra/index.ts @@ -1,11 +1,6 @@ import * as path from 'path'; -import { - CXXFile, - CXXTYPE, - CXXTerraNode, - SimpleTypeKind, -} from '@agoraio-extensions/cxx-parser'; +import { CXXFile, CXXTYPE, CXXTerraNode } from '@agoraio-extensions/cxx-parser'; import { ParseResult, RenderResult, @@ -14,14 +9,7 @@ import { import { renderWithConfiguration } from '@agoraio-extensions/terra_shared_configs'; -import { - appendNumberToDuplicateMemberFunction, - filterFile, - getDefaultValue, - isMatch, -} from './utils'; - -const paramOptionalList = require('./config/param_optional_list.json'); +import { getDefaultValue, isMatch } from './utils'; interface CXXFileUserData { fileName: string; @@ -32,24 +20,14 @@ interface TerraNodeUserData { isEnumz: boolean; isClazz: boolean; isCallback: boolean; - hasComment: boolean; - comment: string; } interface ClazzMethodUserData { - hasComment: boolean; - comment: string; -} - -interface EnumMethodUserData { - hasComment: boolean; - comment: string; + output: string; + input: string; } interface StructMemberVariableUserData { - hasComment: boolean; - comment: string; - hasDefaultValue: boolean; defaultValue: any; } @@ -59,8 +37,7 @@ export default function ( parseResult: ParseResult ): RenderResult[] { let cxxfiles = parseResult.nodes as CXXFile[]; - //移除不需要的文件 - let view = filterFile(cxxfiles).map((cxxfile: CXXFile) => { + let view = cxxfiles.map((cxxfile: CXXFile) => { const cxxUserData: CXXFileUserData = { fileName: path.basename( cxxfile.file_path, @@ -70,78 +47,63 @@ export default function ( cxxfile.user_data = cxxUserData; cxxfile.nodes = cxxfile.nodes.map((node: CXXTerraNode) => { - let isCallback = isMatch(node.name, 'isCallback'); - - if (node.name === 'StorageEvent') { + if (node.name === 'IRtmPresence') { // debugger; } - + let isCallback = isMatch(node.name, 'isCallback'); if (node.__TYPE === CXXTYPE.Clazz) { - //重载函数重命名, 自动末尾+数字 - //['joinChannel', 'joinChannel'] => ['joinChannel', 'joinChannel2'] - node.asClazz().methods = appendNumberToDuplicateMemberFunction( - node.asClazz().methods - ); node.asClazz().methods.map((method) => { const clazzMethodUserData: ClazzMethodUserData = { - hasComment: method.comment !== '', - comment: method.comment - .replace(/^\n/, '* ') - .replace(/\n$/, '') - .replace(/\n/g, '\n* '), + output: '', + input: '', }; - method.user_data = clazzMethodUserData; + let output_params: string[] = []; + let input_params: string[] = []; method.asMemberFunction().parameters.map((param) => { - const clazzMethodParametersUserData = { - isOptional: paramOptionalList.includes(param.fullName), - }; - if (param.type.kind === SimpleTypeKind.pointer_t) { - param.type.source = param.type.source.replace('[]', ''); + if (param.is_output) { + input_params.push(`${param.name}?: ${param.type.name}`); + output_params.push(`${param.name}: ${param.type.name}`); + } else { + if (param.default_value) { + input_params.push(`${param.name}?: ${param.type.name}`); + } else { + input_params.push(`${param.name}: ${param.type.name}`); + } } - param.user_data = clazzMethodParametersUserData; }); - if (method.return_type.kind === SimpleTypeKind.pointer_t) { - method.return_type.source = method.return_type.source.replace( - '[]', - '' - ); + if (output_params.length > 0) { + if ( + method.asMemberFunction().return_type.name !== 'void' && + method.asMemberFunction().return_type.name !== 'number' + ) { + output_params.push(`result: ${method.return_type.name},`); + } + } + clazzMethodUserData.input = input_params.join(','); + if (output_params.length > 1) { + clazzMethodUserData.output = `{${output_params.join(',')}}`; + } else if (output_params.length == 1) { + clazzMethodUserData.output = output_params[0]?.split(': ')[1]!; + } else { + clazzMethodUserData.output = `${method.return_type.name}`; } + method.user_data = clazzMethodUserData; }); } if (node.__TYPE === CXXTYPE.Enumz) { - // debugger; node.asEnumz().enum_constants.map((enum_constant) => { - const clazzMethodUserData: EnumMethodUserData = { - hasComment: enum_constant.comment !== '', - comment: enum_constant.comment - .replace(/^\n/, '* ') - .replace(/\n$/, '') - .replace(/\n/g, '\n* '), - }; - enum_constant.user_data = clazzMethodUserData; + enum_constant.name = + enum_constant.name.charAt(0).toUpperCase() + + enum_constant.name.slice(1); }); } if (node.__TYPE === CXXTYPE.Struct) { node.asStruct().member_variables.map((member_variable) => { const structMemberVariableUserData: StructMemberVariableUserData = { - hasComment: member_variable.comment !== '', - comment: member_variable.comment - .replace(/^\n/, '* ') - .replace(/\n$/, '') - .replace(/\n/g, '\n* '), - hasDefaultValue: - getDefaultValue(node.asStruct(), member_variable).length > 0, defaultValue: getDefaultValue(node.asStruct(), member_variable), }; - member_variable.type.source = member_variable.type.source.replace( - '[]', - '' - ); - if (member_variable.type.kind === SimpleTypeKind.array_t) { - member_variable.type.source += '[]'; - } member_variable.user_data = structMemberVariableUserData; }); } @@ -151,11 +113,6 @@ export default function ( isEnumz: node.__TYPE === CXXTYPE.Enumz, isClazz: node.__TYPE === CXXTYPE.Clazz, isCallback: isCallback, - hasComment: node.comment !== '', - comment: node.comment - .replace(/^\n/, '* ') - .replace(/\n$/, '') - .replace(/\n/g, '\n* '), }; node.user_data = terraNodeUserData; @@ -164,7 +121,7 @@ export default function ( return cxxfile; }); - //移除不含有Clazz,Enumz,Struct的文件 + //remove Clazz/Enumz/Struct doesn't exist file view = view.filter((cxxfile) => { return ( cxxfile.nodes.filter((node) => { @@ -180,13 +137,13 @@ export default function ( fileNameTemplatePath: path.join( __dirname, 'templates', - 'types', + 'type', 'file_name.mustache' ), fileContentTemplatePath: path.join( __dirname, 'templates', - 'types', + 'type', 'file_content.mustache' ), view, diff --git a/scripts/terra/package.json b/scripts/terra/package.json index e9339ba..ff9d4af 100644 --- a/scripts/terra/package.json +++ b/scripts/terra/package.json @@ -1,16 +1,15 @@ { - "name": "terra-generate", + "name": "terra", "version": "1.0.0", - "description": "generate code by terra", - "license": "MIT", - "engines": { - "node": ">=18" - }, + "description": "", + "main": "index.js", "scripts": { - "build": "terra", - "terra": "yarn terra-types && yarn terra-impl", - "terra-types": "sh terra-types.sh", - "terra-impl": "sh terra-impl.sh" + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT", + "devDependencies": { + "@types/node": "^20.6.0" }, "dependencies": { "@agoraio-extensions/cxx-parser": "git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=cxx-parser", @@ -21,7 +20,7 @@ "@types/node": "^18.17.9", "js-yaml": "^4.1.0", "ts-node": "^10.9.1", - "typescript": "5.1.6" + "typescript": "^5.1.6" }, "packageManager": "yarn@4.0.1" } diff --git a/scripts/terra/templates/impl/file_content.mustache b/scripts/terra/templates/impl/file_content.mustache index 4abd191..4635e66 100644 --- a/scripts/terra/templates/impl/file_content.mustache +++ b/scripts/terra/templates/impl/file_content.mustache @@ -1,5 +1,3 @@ -/// Generated by terra, DO NOT MODIFY BY HAND. - {{#nodes}} {{#user_data.isCallback}} export function process{{name}}(handler: {{name}}, @@ -19,35 +17,32 @@ export function process{{name}}(handler: {{name}}, {{/user_data.isCallback}} {{^user_data.isCallback}} // @ts-ignore -export class {{name}}Impl implements {{name}}{ +export class {{name}}Impl {{#base_clazzs}}extends {{.}}Impl{{/base_clazzs}} implements {{name}}{ {{#methods}} {{name}}( - {{#parameters}} - {{name}}{{#user_data.isOptional}}?{{/user_data.isOptional}}: {{type.source}}, - {{/parameters}} - ): {{return_type.source}} { - const apiType = this.{{user_data.bindingFunctionName}}(); + {{{user_data.input}}} + ): {{user_data.output}} { + const apiType = this.{{user_data.bindingFunctionName}}({{#user_data.input_map}}{{user_data.name}},{{/user_data.input_map}}); const jsonParams = { - {{#parameters}} - {{name}}: {{name}}, - {{/parameters}} + {{#user_data.input_map}} + {{name}}: {{user_data.name}}, + {{/user_data.input_map}} {{#user_data.hasParameters}} toJSON: () => { return { - {{#parameters}} - {{name}}: {{name}}, - {{/parameters}} + {{#user_data.input_map_fixed}} + {{name}}: {{user_data.name}}, + {{/user_data.input_map_fixed}} }; }, {{/user_data.hasParameters}} }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.{{user_data.returnParamName}}; + {{{user_data.returnParam}}} } - protected {{user_data.bindingFunctionName}}(): string { - return '{{user_data.bindingIrisKey}}'; + protected {{user_data.bindingFunctionName}}({{{user_data.input}}}): string { + return '{{user_data.renderApiType}}'; } {{/methods}} @@ -55,3 +50,6 @@ export class {{name}}Impl implements {{name}}{ {{/user_data.isCallback}} {{/nodes}} +{{#user_data.renderFileEnd}} +import { callIrisApi } from '../internal/IrisRtmEngine'; +{{/user_data.renderFileEnd}} diff --git a/scripts/terra/templates/impl/file_name.mustache b/scripts/terra/templates/impl/file_name.mustache index a70e184..8bf4bf7 100644 --- a/scripts/terra/templates/impl/file_name.mustache +++ b/scripts/terra/templates/impl/file_name.mustache @@ -1 +1 @@ -{{&user_data.fileName}}Impl.ts \ No newline at end of file +impl/{{&user_data.fileName}}Impl.ts \ No newline at end of file diff --git a/scripts/terra/templates/type/clazz.mustache b/scripts/terra/templates/type/clazz.mustache new file mode 100644 index 0000000..a2236c2 --- /dev/null +++ b/scripts/terra/templates/type/clazz.mustache @@ -0,0 +1,29 @@ + +{{#user_data.isCallback}} + +{{#comment}} +{{{comment}}} +{{/comment}} +export interface {{name}} {{#base_clazzs}}extends {{.}}{{/base_clazzs}}{ +{{#methods}} + {{#comment}} + {{{comment}}} + {{/comment}} + {{name}}?({{#parameters}}{{name}}: {{{type.name}}},{{/parameters}}): {{#return_type}}{{{name}}}{{/return_type}}; +{{/methods}} +} +{{/user_data.isCallback}} +{{^user_data.isCallback}} + +{{#comment}} +{{{comment}}} +{{/comment}} +export abstract class {{name}} {{#base_clazzs}}extends {{.}}{{/base_clazzs}}{ +{{#methods}} + {{#comment}} + {{{comment}}} + {{/comment}} + abstract {{name}}({{user_data.input}}): {{{user_data.output}}}; +{{/methods}} +} +{{/user_data.isCallback}} diff --git a/scripts/terra/templates/type/enum.mustache b/scripts/terra/templates/type/enum.mustache new file mode 100644 index 0000000..3dd63d6 --- /dev/null +++ b/scripts/terra/templates/type/enum.mustache @@ -0,0 +1,14 @@ + +{{#name}} +{{#comment}} +{{{comment}}} +{{/comment}} +export enum {{name}} { +{{#enum_constants}} + {{#comment}} + {{{comment}}} + {{/comment}} + {{name}} = {{{value}}}, +{{/enum_constants}} +} +{{/name}} diff --git a/scripts/terra/templates/types/file_content.mustache b/scripts/terra/templates/type/file_content.mustache similarity index 100% rename from scripts/terra/templates/types/file_content.mustache rename to scripts/terra/templates/type/file_content.mustache diff --git a/scripts/terra/templates/types/file_name.mustache b/scripts/terra/templates/type/file_name.mustache similarity index 100% rename from scripts/terra/templates/types/file_name.mustache rename to scripts/terra/templates/type/file_name.mustache diff --git a/scripts/terra/templates/type/struct.mustache b/scripts/terra/templates/type/struct.mustache new file mode 100644 index 0000000..128f4e0 --- /dev/null +++ b/scripts/terra/templates/type/struct.mustache @@ -0,0 +1,19 @@ + +{{#comment}} +{{{comment}}} +{{/comment}} +export class {{name}} { +{{#member_variables}} + {{#comment}} + {{{comment}}} + {{/comment}} + {{name}}?: {{#type}}{{name}}{{/type}}{{{user_data.defaultValue}}}; +{{/member_variables}} + constructor(props?: Partial<{ + {{#member_variables}} + {{name}}?: {{#type}}{{name}}{{/type}}; +{{/member_variables}} + }>) { + Object.assign(this, props); + } +} diff --git a/scripts/terra/templates/types/clazz.mustache b/scripts/terra/templates/types/clazz.mustache deleted file mode 100644 index 0edb2bc..0000000 --- a/scripts/terra/templates/types/clazz.mustache +++ /dev/null @@ -1,37 +0,0 @@ - -{{#user_data.isCallback}} - -{{#user_data.hasComment}} -/** -{{{user_data.comment}}} -*/ -{{/user_data.hasComment}} -export interface {{name}} {{#base_clazzs}}extends {{.}}{{/base_clazzs}}{ -{{#methods}} - {{#user_data.hasComment}} - /** - {{{user_data.comment}}} - */ - {{/user_data.hasComment}} - {{name}}?({{#parameters}}{{name}}: {{type.source}},{{/parameters}}): {{#return_type}}{{source}}{{/return_type}}; -{{/methods}} -} -{{/user_data.isCallback}} -{{^user_data.isCallback}} - -{{#user_data.hasComment}} -/** -{{{user_data.comment}}} -*/ -{{/user_data.hasComment}} -export abstract class {{name}}{ -{{#methods}} - {{#user_data.hasComment}} - /** - {{{user_data.comment}}} - */ - {{/user_data.hasComment}} - abstract {{name}}({{#parameters}}{{name}}{{#user_data.isOptional}}?{{/user_data.isOptional}}: {{type.source}},{{/parameters}}): {{return_type.source}}; -{{/methods}} -} -{{/user_data.isCallback}} diff --git a/scripts/terra/templates/types/enum.mustache b/scripts/terra/templates/types/enum.mustache deleted file mode 100644 index 4bef91a..0000000 --- a/scripts/terra/templates/types/enum.mustache +++ /dev/null @@ -1,16 +0,0 @@ - -{{#user_data.hasComment}} -/** -{{{user_data.comment}}} -*/ -{{/user_data.hasComment}} -export enum {{name}} { -{{#enum_constants}} - {{#user_data.hasComment}} - /** - {{{user_data.comment}}} - */ - {{/user_data.hasComment}} - {{name}} = {{value}}, -{{/enum_constants}} -} diff --git a/scripts/terra/templates/types/struct.mustache b/scripts/terra/templates/types/struct.mustache deleted file mode 100644 index 7d65e6e..0000000 --- a/scripts/terra/templates/types/struct.mustache +++ /dev/null @@ -1,23 +0,0 @@ - -{{#user_data.hasComment}} -/** -{{{user_data.comment}}} -*/ -{{/user_data.hasComment}} -export class {{name}} { -{{#member_variables}} - {{#user_data.hasComment}} - /** - {{{user_data.comment}}} - */ - {{/user_data.hasComment}} - {{name}}?: {{#type}}{{source}}{{/type}}{{{user_data.defaultValue}}}; -{{/member_variables}} - constructor(props?: Partial<{ - {{#member_variables}} - {{name}}?: {{#type}}{{source}}{{/type}}; -{{/member_variables}} - }>) { - Object.assign(this, props); - } -} diff --git a/scripts/terra/terra-impl.sh b/scripts/terra/terra-impl.sh deleted file mode 100644 index d5766df..0000000 --- a/scripts/terra/terra-impl.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e -set -x - -MY_PATH=$(realpath $(dirname "$0")) -OUTPUT_DIR=$(realpath ${MY_PATH}/../../src/impl) - -find ${OUTPUT_DIR} -type f -delete - -npm run build -- run \ - --config ${MY_PATH}/config/impl_configs.yaml \ - --output-dir=${OUTPUT_DIR} \ - -cd ${OUTPUT_DIR}/../.. - -yarn exec eslint --fix --ext .ts ./src/impl diff --git a/scripts/terra/terra-types.sh b/scripts/terra/terra-types.sh deleted file mode 100644 index 51645be..0000000 --- a/scripts/terra/terra-types.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e -set -x - -MY_PATH=$(realpath $(dirname "$0")) -OUTPUT_DIR=$(realpath ${MY_PATH}/../../src) - -find ${OUTPUT_DIR} -maxdepth 1 -type f ! -path "*/index.ts" -delete - -npm run build -- run \ - --config ${MY_PATH}/config/types_configs.yaml \ - --output-dir=${OUTPUT_DIR} \ - -cd ${OUTPUT_DIR}/.. - -yarn exec eslint --fix --ext .ts ./src diff --git a/scripts/terra/utils.ts b/scripts/terra/utils.ts index b41e934..9041489 100644 --- a/scripts/terra/utils.ts +++ b/scripts/terra/utils.ts @@ -1,28 +1,20 @@ import { CXXFile, + CXXTYPE, + Clazz, + Enumz, MemberFunction, MemberVariable, Struct, } from '@agoraio-extensions/cxx-parser'; - -const path = require('path'); +import { ParseResult } from '@agoraio-extensions/terra-core'; let regMap: any = { isCallback: '.*(Observer|Handler|Callback|Receiver|Sink).*', }; -const filterFileList = require('./config/filter_file_list.json'); const specialConstructList = require('./config/special_construct_list.json'); -export function filterFile(cxxfiles: CXXFile[]): CXXFile[] { - return cxxfiles.filter((file) => { - const fileName = path.basename(file.file_path); - return !filterFileList.some((filter: string) => - new RegExp(filter, 'g').test(fileName) - ); - }); -} - export function isMatch(str: string, type: string): boolean { let result = false; if (regMap[type]) { @@ -73,3 +65,57 @@ export function getDefaultValue(node: Struct, member_variable: MemberVariable) { }); return default_value; } + +export function lowerFirstWord(str: string) { + return str.charAt(0).toLowerCase() + str.slice(1); +} + +export function upperFirstWord(str: string) { + return str.charAt(0).toUpperCase() + str.slice(1); +} + +export function deepClone(obj: any, skipKeys?: string[]) { + if (obj === null || typeof obj !== 'object') { + return obj; + } + + let clone = Array.isArray(obj) ? [] : {}; + + for (let key in obj) { + if (skipKeys?.includes(key)) { + continue; + } + if (obj.hasOwnProperty(key)) { + (clone as any)[key] = deepClone(obj[key], skipKeys); + } + } + + return clone; +} + +export function findClazz(value: string, parseResult: ParseResult) { + return ( + parseResult?.nodes.flatMap((f) => { + let file = f as CXXFile; + return file.nodes.filter((node) => node.__TYPE === CXXTYPE.Clazz); + }) as Clazz[] + ).filter((clazz: Clazz) => clazz.name === value); +} + +export function findEnumz(value: string, parseResult: ParseResult) { + return ( + parseResult?.nodes.flatMap((f) => { + let file = f as CXXFile; + return file.nodes.filter((node) => node.__TYPE === CXXTYPE.Enumz); + }) as Enumz[] + ).filter((enumz: Enumz) => enumz.name === value); +} + +export function findStruct(value: string, parseResult: ParseResult) { + return ( + parseResult?.nodes.flatMap((f) => { + let file = f as CXXFile; + return file.nodes.filter((node) => node.__TYPE === CXXTYPE.Struct); + }) as Struct[] + ).filter((struct: Struct) => struct.name === value); +} diff --git a/scripts/terra/yarn.lock b/scripts/terra/yarn.lock deleted file mode 100644 index 8df7197..0000000 --- a/scripts/terra/yarn.lock +++ /dev/null @@ -1,611 +0,0 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 8 - cacheKey: 10c0 - -"@agoraio-extensions/cxx-parser@git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=cxx-parser": - version: 0.1.9 - resolution: "@agoraio-extensions/cxx-parser@git@github.com:AgoraIO-Extensions/terra.git#workspace=cxx-parser&commit=e4bda11c11ab121349d023e2c2e289a83dc93c9f" - dependencies: - glob: "npm:^10.3.4" - yaml: "npm:^2.1.3" - peerDependencies: - "@agoraio-extensions/terra-core": "*" - checksum: 672fa66d635d8383c8607db88f6ed4ddeba26754a3e6eafd04f704da3c7b13a6b74c6eadd1880ab9a2ce66fdd9fe219e8f9aa4c214d9a74d759c158519a784bd - languageName: node - linkType: hard - -"@agoraio-extensions/terra-core@git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=terra-core": - version: 0.1.5 - resolution: "@agoraio-extensions/terra-core@git@github.com:AgoraIO-Extensions/terra.git#workspace=terra-core&commit=e4bda11c11ab121349d023e2c2e289a83dc93c9f" - checksum: d7113225ab004b2ff09de3c3718262925dc335f5ffb8ac2800bb96bfb2ad67a307063a425bd14654356d804586a785efe3856462e1087472463eb233a6793e44 - languageName: node - linkType: hard - -"@agoraio-extensions/terra@git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=terra": - version: 0.1.5 - resolution: "@agoraio-extensions/terra@git@github.com:AgoraIO-Extensions/terra.git#workspace=terra&commit=e4bda11c11ab121349d023e2c2e289a83dc93c9f" - dependencies: - commander: "npm:^9.4.1" - mustache: "npm:^4.2.0" - yaml: "npm:^2.1.3" - peerDependencies: - "@agoraio-extensions/terra-core": "*" - bin: - terra: ./bin/terra - checksum: f86bfecb341fec2016aa0f2b7f65f4fce8f0e5eeb481929cd7d99088e13bc2443ea24f8445982d56ea24cad253cfd83e81d0f98e5ffd5d3a757367905d1d2cf9 - languageName: node - linkType: hard - -"@agoraio-extensions/terra_shared_configs@git@github.com:AgoraIO-Extensions/terra_shared_configs.git#head=main": - version: 1.0.2 - resolution: "@agoraio-extensions/terra_shared_configs@git@github.com:AgoraIO-Extensions/terra_shared_configs.git#commit=9894630aa136e1b8047b6ee22252256112b0150f" - dependencies: - "@agoraio-extensions/cxx-parser": "git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=cxx-parser" - "@agoraio-extensions/terra-core": "git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=terra-core" - mustache: "npm:^4.2.0" - checksum: 591e192201af03742684b151271c914949f6d7617aadbdc2e8bf823fd005ca37190ab10cfdc4d22c8a055c10ca8b7237b9e78d8106bc9621a09c1c63022d0e52 - languageName: node - linkType: hard - -"@cspotcode/source-map-support@npm:^0.8.0": - version: 0.8.1 - resolution: "@cspotcode/source-map-support@npm:0.8.1" - dependencies: - "@jridgewell/trace-mapping": "npm:0.3.9" - checksum: 05c5368c13b662ee4c122c7bfbe5dc0b613416672a829f3e78bc49a357a197e0218d6e74e7c66cfcd04e15a179acab080bd3c69658c9fbefd0e1ccd950a07fc6 - languageName: node - linkType: hard - -"@isaacs/cliui@npm:^8.0.2": - version: 8.0.2 - resolution: "@isaacs/cliui@npm:8.0.2" - dependencies: - string-width: "npm:^5.1.2" - string-width-cjs: "npm:string-width@^4.2.0" - strip-ansi: "npm:^7.0.1" - strip-ansi-cjs: "npm:strip-ansi@^6.0.1" - wrap-ansi: "npm:^8.1.0" - wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" - checksum: b1bf42535d49f11dc137f18d5e4e63a28c5569de438a221c369483731e9dac9fb797af554e8bf02b6192d1e5eba6e6402cf93900c3d0ac86391d00d04876789e - languageName: node - linkType: hard - -"@jridgewell/resolve-uri@npm:^3.0.3": - version: 3.1.1 - resolution: "@jridgewell/resolve-uri@npm:3.1.1" - checksum: 0dbc9e29bc640bbbdc5b9876d2859c69042bfcf1423c1e6421bcca53e826660bff4e41c7d4bcb8dbea696404231a6f902f76ba41835d049e20f2dd6cffb713bf - languageName: node - linkType: hard - -"@jridgewell/sourcemap-codec@npm:^1.4.10": - version: 1.4.15 - resolution: "@jridgewell/sourcemap-codec@npm:1.4.15" - checksum: 0c6b5ae663087558039052a626d2d7ed5208da36cfd707dcc5cea4a07cfc918248403dcb5989a8f7afaf245ce0573b7cc6fd94c4a30453bd10e44d9363940ba5 - languageName: node - linkType: hard - -"@jridgewell/trace-mapping@npm:0.3.9": - version: 0.3.9 - resolution: "@jridgewell/trace-mapping@npm:0.3.9" - dependencies: - "@jridgewell/resolve-uri": "npm:^3.0.3" - "@jridgewell/sourcemap-codec": "npm:^1.4.10" - checksum: fa425b606d7c7ee5bfa6a31a7b050dd5814b4082f318e0e4190f991902181b4330f43f4805db1dd4f2433fd0ed9cc7a7b9c2683f1deeab1df1b0a98b1e24055b - languageName: node - linkType: hard - -"@pkgjs/parseargs@npm:^0.11.0": - version: 0.11.0 - resolution: "@pkgjs/parseargs@npm:0.11.0" - checksum: 5bd7576bb1b38a47a7fc7b51ac9f38748e772beebc56200450c4a817d712232b8f1d3ef70532c80840243c657d491cf6a6be1e3a214cff907645819fdc34aadd - languageName: node - linkType: hard - -"@tsconfig/node10@npm:^1.0.7": - version: 1.0.9 - resolution: "@tsconfig/node10@npm:1.0.9" - checksum: c176a2c1e1b16be120c328300ea910df15fb9a5277010116d26818272341a11483c5a80059389d04edacf6fd2d03d4687ad3660870fdd1cc0b7109e160adb220 - languageName: node - linkType: hard - -"@tsconfig/node12@npm:^1.0.7": - version: 1.0.11 - resolution: "@tsconfig/node12@npm:1.0.11" - checksum: dddca2b553e2bee1308a056705103fc8304e42bb2d2cbd797b84403a223b25c78f2c683ec3e24a095e82cd435387c877239bffcb15a590ba817cd3f6b9a99fd9 - languageName: node - linkType: hard - -"@tsconfig/node14@npm:^1.0.0": - version: 1.0.3 - resolution: "@tsconfig/node14@npm:1.0.3" - checksum: 67c1316d065fdaa32525bc9449ff82c197c4c19092b9663b23213c8cbbf8d88b6ed6a17898e0cbc2711950fbfaf40388938c1c748a2ee89f7234fc9e7fe2bf44 - languageName: node - linkType: hard - -"@tsconfig/node16@npm:^1.0.2": - version: 1.0.4 - resolution: "@tsconfig/node16@npm:1.0.4" - checksum: 05f8f2734e266fb1839eb1d57290df1664fe2aa3b0fdd685a9035806daa635f7519bf6d5d9b33f6e69dd545b8c46bd6e2b5c79acb2b1f146e885f7f11a42a5bb - languageName: node - linkType: hard - -"@types/js-yaml@npm:^4.0.8": - version: 4.0.9 - resolution: "@types/js-yaml@npm:4.0.9" - checksum: 24de857aa8d61526bbfbbaa383aa538283ad17363fcd5bb5148e2c7f604547db36646440e739d78241ed008702a8920665d1add5618687b6743858fae00da211 - languageName: node - linkType: hard - -"@types/node@npm:^18.17.9": - version: 18.18.13 - resolution: "@types/node@npm:18.18.13" - dependencies: - undici-types: "npm:~5.26.4" - checksum: 5f1840f26b4c00e6b4945be678644a46e6689ef10d9d7795d587b76059045b99a14ca6075264296e6e91d73e098fe83df9580881278d9a6ce394b368d9c76700 - languageName: node - linkType: hard - -"acorn-walk@npm:^8.1.1": - version: 8.3.0 - resolution: "acorn-walk@npm:8.3.0" - checksum: 24346e595f507b6e704a60d35f3c5e1aa9891d4fb6a3fc3d856503ab718cc26cabb5e3e1ff0ff8da6ec03d60a8226ebdb602805a94f970e7f797ea3b8b09437f - languageName: node - linkType: hard - -"acorn@npm:^8.4.1": - version: 8.11.2 - resolution: "acorn@npm:8.11.2" - bin: - acorn: bin/acorn - checksum: a3ed76c761b75ec54b1ec3068fb7f113a182e95aea7f322f65098c2958d232e3d211cb6dac35ff9c647024b63714bc528a26d54a925d1fef2c25585b4c8e4017 - languageName: node - linkType: hard - -"ansi-regex@npm:^5.0.1": - version: 5.0.1 - resolution: "ansi-regex@npm:5.0.1" - checksum: 9a64bb8627b434ba9327b60c027742e5d17ac69277960d041898596271d992d4d52ba7267a63ca10232e29f6107fc8a835f6ce8d719b88c5f8493f8254813737 - languageName: node - linkType: hard - -"ansi-regex@npm:^6.0.1": - version: 6.0.1 - resolution: "ansi-regex@npm:6.0.1" - checksum: cbe16dbd2c6b2735d1df7976a7070dd277326434f0212f43abf6d87674095d247968209babdaad31bb00882fa68807256ba9be340eec2f1004de14ca75f52a08 - languageName: node - linkType: hard - -"ansi-styles@npm:^4.0.0": - version: 4.3.0 - resolution: "ansi-styles@npm:4.3.0" - dependencies: - color-convert: "npm:^2.0.1" - checksum: 895a23929da416f2bd3de7e9cb4eabd340949328ab85ddd6e484a637d8f6820d485f53933446f5291c3b760cbc488beb8e88573dd0f9c7daf83dccc8fe81b041 - languageName: node - linkType: hard - -"ansi-styles@npm:^6.1.0": - version: 6.2.1 - resolution: "ansi-styles@npm:6.2.1" - checksum: 5d1ec38c123984bcedd996eac680d548f31828bd679a66db2bdf11844634dde55fec3efa9c6bb1d89056a5e79c1ac540c4c784d592ea1d25028a92227d2f2d5c - languageName: node - linkType: hard - -"arg@npm:^4.1.0": - version: 4.1.3 - resolution: "arg@npm:4.1.3" - checksum: 070ff801a9d236a6caa647507bdcc7034530604844d64408149a26b9e87c2f97650055c0f049abd1efc024b334635c01f29e0b632b371ac3f26130f4cf65997a - languageName: node - linkType: hard - -"argparse@npm:^2.0.1": - version: 2.0.1 - resolution: "argparse@npm:2.0.1" - checksum: c5640c2d89045371c7cedd6a70212a04e360fd34d6edeae32f6952c63949e3525ea77dbec0289d8213a99bbaeab5abfa860b5c12cf88a2e6cf8106e90dd27a7e - languageName: node - linkType: hard - -"balanced-match@npm:^1.0.0": - version: 1.0.2 - resolution: "balanced-match@npm:1.0.2" - checksum: 9308baf0a7e4838a82bbfd11e01b1cb0f0cf2893bc1676c27c2a8c0e70cbae1c59120c3268517a8ae7fb6376b4639ef81ca22582611dbee4ed28df945134aaee - languageName: node - linkType: hard - -"brace-expansion@npm:^2.0.1": - version: 2.0.1 - resolution: "brace-expansion@npm:2.0.1" - dependencies: - balanced-match: "npm:^1.0.0" - checksum: b358f2fe060e2d7a87aa015979ecea07f3c37d4018f8d6deb5bd4c229ad3a0384fe6029bb76cd8be63c81e516ee52d1a0673edbe2023d53a5191732ae3c3e49f - languageName: node - linkType: hard - -"color-convert@npm:^2.0.1": - version: 2.0.1 - resolution: "color-convert@npm:2.0.1" - dependencies: - color-name: "npm:~1.1.4" - checksum: 37e1150172f2e311fe1b2df62c6293a342ee7380da7b9cfdba67ea539909afbd74da27033208d01d6d5cfc65ee7868a22e18d7e7648e004425441c0f8a15a7d7 - languageName: node - linkType: hard - -"color-name@npm:~1.1.4": - version: 1.1.4 - resolution: "color-name@npm:1.1.4" - checksum: a1a3f914156960902f46f7f56bc62effc6c94e84b2cae157a526b1c1f74b677a47ec602bf68a61abfa2b42d15b7c5651c6dbe72a43af720bc588dff885b10f95 - languageName: node - linkType: hard - -"commander@npm:^9.4.1": - version: 9.5.0 - resolution: "commander@npm:9.5.0" - checksum: 5f7784fbda2aaec39e89eb46f06a999e00224b3763dc65976e05929ec486e174fe9aac2655f03ba6a5e83875bd173be5283dc19309b7c65954701c02025b3c1d - languageName: node - linkType: hard - -"create-require@npm:^1.1.0": - version: 1.1.1 - resolution: "create-require@npm:1.1.1" - checksum: 157cbc59b2430ae9a90034a5f3a1b398b6738bf510f713edc4d4e45e169bc514d3d99dd34d8d01ca7ae7830b5b8b537e46ae8f3c8f932371b0875c0151d7ec91 - languageName: node - linkType: hard - -"cross-spawn@npm:^7.0.0": - version: 7.0.3 - resolution: "cross-spawn@npm:7.0.3" - dependencies: - path-key: "npm:^3.1.0" - shebang-command: "npm:^2.0.0" - which: "npm:^2.0.1" - checksum: 5738c312387081c98d69c98e105b6327b069197f864a60593245d64c8089c8a0a744e16349281210d56835bb9274130d825a78b2ad6853ca13cfbeffc0c31750 - languageName: node - linkType: hard - -"diff@npm:^4.0.1": - version: 4.0.2 - resolution: "diff@npm:4.0.2" - checksum: 81b91f9d39c4eaca068eb0c1eb0e4afbdc5bb2941d197f513dd596b820b956fef43485876226d65d497bebc15666aa2aa82c679e84f65d5f2bfbf14ee46e32c1 - languageName: node - linkType: hard - -"eastasianwidth@npm:^0.2.0": - version: 0.2.0 - resolution: "eastasianwidth@npm:0.2.0" - checksum: 26f364ebcdb6395f95124fda411f63137a4bfb5d3a06453f7f23dfe52502905bd84e0488172e0f9ec295fdc45f05c23d5d91baf16bd26f0fe9acd777a188dc39 - languageName: node - linkType: hard - -"emoji-regex@npm:^8.0.0": - version: 8.0.0 - resolution: "emoji-regex@npm:8.0.0" - checksum: b6053ad39951c4cf338f9092d7bfba448cdfd46fe6a2a034700b149ac9ffbc137e361cbd3c442297f86bed2e5f7576c1b54cc0a6bf8ef5106cc62f496af35010 - languageName: node - linkType: hard - -"emoji-regex@npm:^9.2.2": - version: 9.2.2 - resolution: "emoji-regex@npm:9.2.2" - checksum: af014e759a72064cf66e6e694a7fc6b0ed3d8db680427b021a89727689671cefe9d04151b2cad51dbaf85d5ba790d061cd167f1cf32eb7b281f6368b3c181639 - languageName: node - linkType: hard - -"foreground-child@npm:^3.1.0": - version: 3.1.1 - resolution: "foreground-child@npm:3.1.1" - dependencies: - cross-spawn: "npm:^7.0.0" - signal-exit: "npm:^4.0.1" - checksum: 9700a0285628abaeb37007c9a4d92bd49f67210f09067638774338e146c8e9c825c5c877f072b2f75f41dc6a2d0be8664f79ffc03f6576649f54a84fb9b47de0 - languageName: node - linkType: hard - -"glob@npm:^10.3.4": - version: 10.3.10 - resolution: "glob@npm:10.3.10" - dependencies: - foreground-child: "npm:^3.1.0" - jackspeak: "npm:^2.3.5" - minimatch: "npm:^9.0.1" - minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0" - path-scurry: "npm:^1.10.1" - bin: - glob: dist/esm/bin.mjs - checksum: 13d8a1feb7eac7945f8c8480e11cd4a44b24d26503d99a8d8ac8d5aefbf3e9802a2b6087318a829fad04cb4e829f25c5f4f1110c68966c498720dd261c7e344d - languageName: node - linkType: hard - -"is-fullwidth-code-point@npm:^3.0.0": - version: 3.0.0 - resolution: "is-fullwidth-code-point@npm:3.0.0" - checksum: bb11d825e049f38e04c06373a8d72782eee0205bda9d908cc550ccb3c59b99d750ff9537982e01733c1c94a58e35400661f57042158ff5e8f3e90cf936daf0fc - languageName: node - linkType: hard - -"isexe@npm:^2.0.0": - version: 2.0.0 - resolution: "isexe@npm:2.0.0" - checksum: 228cfa503fadc2c31596ab06ed6aa82c9976eec2bfd83397e7eaf06d0ccf42cd1dfd6743bf9aeb01aebd4156d009994c5f76ea898d2832c1fe342da923ca457d - languageName: node - linkType: hard - -"jackspeak@npm:^2.3.5": - version: 2.3.6 - resolution: "jackspeak@npm:2.3.6" - dependencies: - "@isaacs/cliui": "npm:^8.0.2" - "@pkgjs/parseargs": "npm:^0.11.0" - dependenciesMeta: - "@pkgjs/parseargs": - optional: true - checksum: f01d8f972d894cd7638bc338e9ef5ddb86f7b208ce177a36d718eac96ec86638a6efa17d0221b10073e64b45edc2ce15340db9380b1f5d5c5d000cbc517dc111 - languageName: node - linkType: hard - -"js-yaml@npm:^4.1.0": - version: 4.1.0 - resolution: "js-yaml@npm:4.1.0" - dependencies: - argparse: "npm:^2.0.1" - bin: - js-yaml: bin/js-yaml.js - checksum: 184a24b4eaacfce40ad9074c64fd42ac83cf74d8c8cd137718d456ced75051229e5061b8633c3366b8aada17945a7a356b337828c19da92b51ae62126575018f - languageName: node - linkType: hard - -"lru-cache@npm:^9.1.1 || ^10.0.0": - version: 10.1.0 - resolution: "lru-cache@npm:10.1.0" - checksum: 778bc8b2626daccd75f24c4b4d10632496e21ba064b126f526c626fbdbc5b28c472013fccd45d7646b9e1ef052444824854aed617b59cd570d01a8b7d651fc1e - languageName: node - linkType: hard - -"make-error@npm:^1.1.1": - version: 1.3.6 - resolution: "make-error@npm:1.3.6" - checksum: 171e458d86854c6b3fc46610cfacf0b45149ba043782558c6875d9f42f222124384ad0b468c92e996d815a8a2003817a710c0a160e49c1c394626f76fa45396f - languageName: node - linkType: hard - -"minimatch@npm:^9.0.1": - version: 9.0.3 - resolution: "minimatch@npm:9.0.3" - dependencies: - brace-expansion: "npm:^2.0.1" - checksum: 85f407dcd38ac3e180f425e86553911d101455ca3ad5544d6a7cec16286657e4f8a9aa6695803025c55e31e35a91a2252b5dc8e7d527211278b8b65b4dbd5eac - languageName: node - linkType: hard - -"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": - version: 7.0.4 - resolution: "minipass@npm:7.0.4" - checksum: 6c7370a6dfd257bf18222da581ba89a5eaedca10e158781232a8b5542a90547540b4b9b7e7f490e4cda43acfbd12e086f0453728ecf8c19e0ef6921bc5958ac5 - languageName: node - linkType: hard - -"mustache@npm:^4.2.0": - version: 4.2.0 - resolution: "mustache@npm:4.2.0" - bin: - mustache: bin/mustache - checksum: 1f8197e8a19e63645a786581d58c41df7853da26702dbc005193e2437c98ca49b255345c173d50c08fe4b4dbb363e53cb655ecc570791f8deb09887248dd34a2 - languageName: node - linkType: hard - -"path-key@npm:^3.1.0": - version: 3.1.1 - resolution: "path-key@npm:3.1.1" - checksum: 748c43efd5a569c039d7a00a03b58eecd1d75f3999f5a28303d75f521288df4823bc057d8784eb72358b2895a05f29a070bc9f1f17d28226cc4e62494cc58c4c - languageName: node - linkType: hard - -"path-scurry@npm:^1.10.1": - version: 1.10.1 - resolution: "path-scurry@npm:1.10.1" - dependencies: - lru-cache: "npm:^9.1.1 || ^10.0.0" - minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0" - checksum: e5dc78a7348d25eec61ab166317e9e9c7b46818aa2c2b9006c507a6ff48c672d011292d9662527213e558f5652ce0afcc788663a061d8b59ab495681840c0c1e - languageName: node - linkType: hard - -"shebang-command@npm:^2.0.0": - version: 2.0.0 - resolution: "shebang-command@npm:2.0.0" - dependencies: - shebang-regex: "npm:^3.0.0" - checksum: a41692e7d89a553ef21d324a5cceb5f686d1f3c040759c50aab69688634688c5c327f26f3ecf7001ebfd78c01f3c7c0a11a7c8bfd0a8bc9f6240d4f40b224e4e - languageName: node - linkType: hard - -"shebang-regex@npm:^3.0.0": - version: 3.0.0 - resolution: "shebang-regex@npm:3.0.0" - checksum: 1dbed0726dd0e1152a92696c76c7f06084eb32a90f0528d11acd764043aacf76994b2fb30aa1291a21bd019d6699164d048286309a278855ee7bec06cf6fb690 - languageName: node - linkType: hard - -"signal-exit@npm:^4.0.1": - version: 4.1.0 - resolution: "signal-exit@npm:4.1.0" - checksum: 41602dce540e46d599edba9d9860193398d135f7ff72cab629db5171516cfae628d21e7bfccde1bbfdf11c48726bc2a6d1a8fb8701125852fbfda7cf19c6aa83 - languageName: node - linkType: hard - -"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^4.1.0": - version: 4.2.3 - resolution: "string-width@npm:4.2.3" - dependencies: - emoji-regex: "npm:^8.0.0" - is-fullwidth-code-point: "npm:^3.0.0" - strip-ansi: "npm:^6.0.1" - checksum: 1e525e92e5eae0afd7454086eed9c818ee84374bb80328fc41217ae72ff5f065ef1c9d7f72da41de40c75fa8bb3dee63d92373fd492c84260a552c636392a47b - languageName: node - linkType: hard - -"string-width@npm:^5.0.1, string-width@npm:^5.1.2": - version: 5.1.2 - resolution: "string-width@npm:5.1.2" - dependencies: - eastasianwidth: "npm:^0.2.0" - emoji-regex: "npm:^9.2.2" - strip-ansi: "npm:^7.0.1" - checksum: ab9c4264443d35b8b923cbdd513a089a60de339216d3b0ed3be3ba57d6880e1a192b70ae17225f764d7adbf5994e9bb8df253a944736c15a0240eff553c678ca - languageName: node - linkType: hard - -"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": - version: 6.0.1 - resolution: "strip-ansi@npm:6.0.1" - dependencies: - ansi-regex: "npm:^5.0.1" - checksum: 1ae5f212a126fe5b167707f716942490e3933085a5ff6c008ab97ab2f272c8025d3aa218b7bd6ab25729ca20cc81cddb252102f8751e13482a5199e873680952 - languageName: node - linkType: hard - -"strip-ansi@npm:^7.0.1": - version: 7.1.0 - resolution: "strip-ansi@npm:7.1.0" - dependencies: - ansi-regex: "npm:^6.0.1" - checksum: a198c3762e8832505328cbf9e8c8381de14a4fa50a4f9b2160138158ea88c0f5549fb50cb13c651c3088f47e63a108b34622ec18c0499b6c8c3a5ddf6b305ac4 - languageName: node - linkType: hard - -"terra-generate@workspace:.": - version: 0.0.0-use.local - resolution: "terra-generate@workspace:." - dependencies: - "@agoraio-extensions/cxx-parser": "git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=cxx-parser" - "@agoraio-extensions/terra": "git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=terra" - "@agoraio-extensions/terra-core": "git@github.com:AgoraIO-Extensions/terra.git#head=main&workspace=terra-core" - "@agoraio-extensions/terra_shared_configs": "git@github.com:AgoraIO-Extensions/terra_shared_configs.git#head=main" - "@types/js-yaml": "npm:^4.0.8" - "@types/node": "npm:^18.17.9" - js-yaml: "npm:^4.1.0" - ts-node: "npm:^10.9.1" - typescript: "npm:5.1.6" - languageName: unknown - linkType: soft - -"ts-node@npm:^10.9.1": - version: 10.9.1 - resolution: "ts-node@npm:10.9.1" - dependencies: - "@cspotcode/source-map-support": "npm:^0.8.0" - "@tsconfig/node10": "npm:^1.0.7" - "@tsconfig/node12": "npm:^1.0.7" - "@tsconfig/node14": "npm:^1.0.0" - "@tsconfig/node16": "npm:^1.0.2" - acorn: "npm:^8.4.1" - acorn-walk: "npm:^8.1.1" - arg: "npm:^4.1.0" - create-require: "npm:^1.1.0" - diff: "npm:^4.0.1" - make-error: "npm:^1.1.1" - v8-compile-cache-lib: "npm:^3.0.1" - yn: "npm:3.1.1" - peerDependencies: - "@swc/core": ">=1.2.50" - "@swc/wasm": ">=1.2.50" - "@types/node": "*" - typescript: ">=2.7" - peerDependenciesMeta: - "@swc/core": - optional: true - "@swc/wasm": - optional: true - bin: - ts-node: dist/bin.js - ts-node-cwd: dist/bin-cwd.js - ts-node-esm: dist/bin-esm.js - ts-node-script: dist/bin-script.js - ts-node-transpile-only: dist/bin-transpile.js - ts-script: dist/bin-script-deprecated.js - checksum: 95187932fb83f3901e22546bd2feeac7d2feb4f412f42ac3a595f049a23e8dcf70516dffb51866391228ea2dbcfaea039e250fb2bb334d48a86ab2b6aea0ae2d - languageName: node - linkType: hard - -"typescript@npm:5.1.6": - version: 5.1.6 - resolution: "typescript@npm:5.1.6" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 45ac28e2df8365fd28dac42f5d62edfe69a7203d5ec646732cadc04065331f34f9078f81f150fde42ed9754eed6fa3b06a8f3523c40b821e557b727f1992e025 - languageName: node - linkType: hard - -"typescript@patch:typescript@npm%3A5.1.6#optional!builtin": - version: 5.1.6 - resolution: "typescript@patch:typescript@npm%3A5.1.6#optional!builtin::version=5.1.6&hash=5da071" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: c2bded58ab897a8341fdbb0c1d92ea2362f498cfffebdc8a529d03e15ea2454142dfbf122dabbd9a5cb79b7123790d27def16e11844887d20636226773ed329a - languageName: node - linkType: hard - -"undici-types@npm:~5.26.4": - version: 5.26.5 - resolution: "undici-types@npm:5.26.5" - checksum: bb673d7876c2d411b6eb6c560e0c571eef4a01c1c19925175d16e3a30c4c428181fb8d7ae802a261f283e4166a0ac435e2f505743aa9e45d893f9a3df017b501 - languageName: node - linkType: hard - -"v8-compile-cache-lib@npm:^3.0.1": - version: 3.0.1 - resolution: "v8-compile-cache-lib@npm:3.0.1" - checksum: bdc36fb8095d3b41df197f5fb6f11e3a26adf4059df3213e3baa93810d8f0cc76f9a74aaefc18b73e91fe7e19154ed6f134eda6fded2e0f1c8d2272ed2d2d391 - languageName: node - linkType: hard - -"which@npm:^2.0.1": - version: 2.0.2 - resolution: "which@npm:2.0.2" - dependencies: - isexe: "npm:^2.0.0" - bin: - node-which: ./bin/node-which - checksum: 66522872a768b60c2a65a57e8ad184e5372f5b6a9ca6d5f033d4b0dc98aff63995655a7503b9c0a2598936f532120e81dd8cc155e2e92ed662a2b9377cc4374f - languageName: node - linkType: hard - -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": - version: 7.0.0 - resolution: "wrap-ansi@npm:7.0.0" - dependencies: - ansi-styles: "npm:^4.0.0" - string-width: "npm:^4.1.0" - strip-ansi: "npm:^6.0.0" - checksum: d15fc12c11e4cbc4044a552129ebc75ee3f57aa9c1958373a4db0292d72282f54373b536103987a4a7594db1ef6a4f10acf92978f79b98c49306a4b58c77d4da - languageName: node - linkType: hard - -"wrap-ansi@npm:^8.1.0": - version: 8.1.0 - resolution: "wrap-ansi@npm:8.1.0" - dependencies: - ansi-styles: "npm:^6.1.0" - string-width: "npm:^5.0.1" - strip-ansi: "npm:^7.0.1" - checksum: 138ff58a41d2f877eae87e3282c0630fc2789012fc1af4d6bd626eeb9a2f9a65ca92005e6e69a75c7b85a68479fe7443c7dbe1eb8fbaa681a4491364b7c55c60 - languageName: node - linkType: hard - -"yaml@npm:^2.1.3": - version: 2.3.4 - resolution: "yaml@npm:2.3.4" - checksum: cf03b68f8fef5e8516b0f0b54edaf2459f1648317fc6210391cf606d247e678b449382f4bd01f77392538429e306c7cba8ff46ff6b37cac4de9a76aff33bd9e1 - languageName: node - linkType: hard - -"yn@npm:3.1.1": - version: 3.1.1 - resolution: "yn@npm:3.1.1" - checksum: 0732468dd7622ed8a274f640f191f3eaf1f39d5349a1b72836df484998d7d9807fbea094e2f5486d6b0cd2414aad5775972df0e68f8604db89a239f0f4bf7443 - languageName: node - linkType: hard diff --git a/src/IAgoraRtmClient.ts b/src/IAgoraRtmClient.ts index b849252..0ed0e90 100644 --- a/src/IAgoraRtmClient.ts +++ b/src/IAgoraRtmClient.ts @@ -61,7 +61,7 @@ export class RtmConfig { * - For Windows, it is the window handle of app. Once set, this parameter enables you to plug * or unplug the video devices while they are powered. */ - context?: void; + context?: any; /** * Whether to use String user IDs, if you are using RTC products with Int user IDs, * set this value as 'false'. Otherwise errors might occur. @@ -89,7 +89,7 @@ export class RtmConfig { userId?: string; areaCode?: RTM_AREA_CODE; presenceTimeout?: number; - context?: void; + context?: any; useStringUserId?: boolean; eventHandler?: IRtmEventHandler; logConfig?: RtmLogConfig; diff --git a/src/IAgoraRtmService.ts b/src/IAgoraRtmService.ts deleted file mode 100644 index c77fed6..0000000 --- a/src/IAgoraRtmService.ts +++ /dev/null @@ -1,673 +0,0 @@ -/// Generated by terra, DO NOT MODIFY BY HAND. - -export enum PEER_MESSAGE_STATE { - PEER_MESSAGE_INIT = 0, - PEER_MESSAGE_FAILURE = 1, - PEER_MESSAGE_PEER_UNREACHABLE = 2, - PEER_MESSAGE_RECEIVED_BY_PEER = 3, - PEER_MESSAGE_SENT_TIMEOUT = 4, -} - -/** - * The login error code. - */ -export enum LOGIN_ERR_CODE { - /** - * 0: Login succeeds. No error occurs. - */ - LOGIN_ERR_OK = 0, - /** - * 1: Login fails for reasons unknown. - */ - LOGIN_ERR_UNKNOWN = 1, - /** - * 2: The server rejects the login, either because the user has already logged in, or because - * the RTM service is not initialized. - */ - LOGIN_ERR_REJECTED = 2, - /** - * 3: Invalid login arguments. - */ - LOGIN_ERR_INVALID_ARGUMENT = 3, - /** - * 4: The App ID is invalid. - */ - LOGIN_ERR_INVALID_APP_ID = 4, - /** - * 5: The token is invalid. - */ - LOGIN_ERR_INVALID_TOKEN = 5, - /** - * 6: The login is rejected because the token has expired. - */ - LOGIN_ERR_TOKEN_EXPIRED = 6, - /** - * 7: Authentication of the RTMP token fails. - */ - LOGIN_ERR_NOT_AUTHORIZED = 7, - /** - * 8: The login times out. The current timeout is set as six seconds. - */ - LOGIN_ERR_TIMEOUT = 8, -} - -/** - * The logout error code. - */ -export enum LOGOUT_ERR_CODE { - /** - * 0: Logout succeeds. No error occurs. - */ - LOGOUT_ERR_OK = 0, - /** - * 1: Logout fails. - */ - LOGOUT_ERR_REJECTED = 1, -} - -/** - * The connection state. - */ -export enum CONNECTION_STATE { - /** - * 1: The SDK has logged in the RTM service. - */ - CONNECTION_STATE_CONNECTED = 1, - /** - * 2: The initial state. The SDK is disconnected from the RTM service. - */ - CONNECTION_STATE_DISCONNECTED = 2, - /** - * 3: The SDK gives up logging in the RTM service, mainly because another instance has logged in the RTM - * service with the same user ID. - * - * Call the logout() method before calling login to log in the RTM service again. - */ - CONNECTION_STATE_ABORTED = 3, -} - -/** - * The state of the channel message. - */ -export enum CHANNEL_MESSAGE_STATE { - /** - * 1: The channel message is received by the server. - */ - CHANNEL_MESSAGE_RECEIVED_BY_SERVER = 1, - /** - * 3: The SDK has not received a response from the server in five seconds. The current timeout is set as - * five seconds. - */ - CHANNEL_MESSAGE_SENT_TIMEOUT = 3, -} - -/** - * The join channel error. - */ -export enum JOIN_CHANNEL_ERR { - /** - * 0: The method call succeeds, or the user joins the channel successfully. - */ - JOIN_CHANNEL_ERR_OK = 0, - /** - * 1: Common failure. The user fails to join the channel. - */ - JOIN_CHANNEL_ERR_FAILURE = 1, - /** - * 2: **RESERVED FOR FUTURE USE** - */ - JOIN_CHANNEL_ERR_REJECTED = 2, - /** - * 3: The user fails to join the channel because the argument is invalid. - */ - JOIN_CHANNEL_ERR_INVALID_ARGUMENT = 3, - /** - * 4: A timeout occurs when joining the channel. The current timeout is set as five seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state. - */ - JOIN_CHANNEL_TIMEOUT = 4, - /** - * 5: The number of the RTM channels you are in exceeds the limit of 20. - */ - JOIN_CHANNEL_ERR_EXCEED_LIMIT = 5, - /** - * 6: The user is joining or has joined the channel. - */ - JOIN_CHANNEL_ERR_ALREADY_JOINED = 6, - /** - * 7: The method call frequency exceeds 50 queries every three seconds. - */ - JOIN_CHANNEL_ERR_TOO_OFTEN = 7, - /** - * 8: The frequency of joining the same channel exceeds two times every five seconds. - */ - JOIN_CHANNEL_ERR_JOIN_SAME_CHANNEL_TOO_OFTEN = 8, - /** - * 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. - */ - JOIN_CHANNEL_ERR_NOT_INITIALIZED = 101, - /** - * 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before joining the channel. - */ - JOIN_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102, -} - -/** - * @brief Error codes related to leaving a channel. - */ -export enum LEAVE_CHANNEL_ERR { - /** - * 0: The method call succeeds, or the user leaves the channel successfully. - */ - LEAVE_CHANNEL_ERR_OK = 0, - /** - * 1: Common failure. The user fails to leave the channel. - */ - LEAVE_CHANNEL_ERR_FAILURE = 1, - /** - * 2: **RESERVED FOR FUTURE USE** - */ - LEAVE_CHANNEL_ERR_REJECTED = 2, - /** - * 3: The user is not in the channel. - */ - LEAVE_CHANNEL_ERR_NOT_IN_CHANNEL = 3, - /** - * 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. - */ - LEAVE_CHANNEL_ERR_NOT_INITIALIZED = 101, - /** - * 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before calling the \ref agora::rtm::IChannel::leave "leave" method. - */ - LEAVE_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102, -} - -/** - * The reason for a user to leave the channel. - */ -export enum LEAVE_CHANNEL_REASON { - /** - * 1: The user quits the channel. - */ - LEAVE_CHANNEL_REASON_QUIT = 1, - /** - * 2: The user is kicked off the channel. - */ - LEAVE_CHANNEL_REASON_KICKED = 2, -} - -/** - * @brief Error codes related to sending a channel message. - */ -export enum CHANNEL_MESSAGE_ERR_CODE { - /** - * 0: The method call succeeds, or the server receives the channel message. - */ - CHANNEL_MESSAGE_ERR_OK = 0, - /** - * 1: Common failure. The user fails to send the channel message. - */ - CHANNEL_MESSAGE_ERR_FAILURE = 1, - /** - * 2: The SDK does not receive a response from the server in 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state. - */ - CHANNEL_MESSAGE_ERR_SENT_TIMEOUT = 2, - /** - * 3: The method call frequency exceeds the limit of (RTM SDK for Windows C++) 180 calls every three seconds or (RTM SDK for Linux C++) 1500 calls every three seconds, with channel and peer messages taken together.. - */ - CHANNEL_MESSAGE_ERR_TOO_OFTEN = 3, - /** - * 4: The message is null or exceeds 32 KB in length. - */ - CHANNEL_MESSAGE_ERR_INVALID_MESSAGE = 4, - /** - * 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. - */ - CHANNEL_MESSAGE_ERR_NOT_INITIALIZED = 101, - /** - * 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before sending out a channel message. - */ - CHANNEL_MESSAGE_ERR_USER_NOT_LOGGED_IN = 102, -} - -/** - * The response code. - */ -export enum RESPONSE_CODE { - /** - * 1: The response - */ - RESPONSE_CODE_SUCCESS = 1, - RESPONSE_CODE_FAILURE = 2, -} - -/** - * The message type. - */ -export enum MESSAGE_TYPE { - /** - * 0: The message type is undefined. - */ - MESSAGE_TYPE_UNDEFINED = 0, - /** - * 1: A text message. - */ - MESSAGE_TYPE_TEXT = 1, - /** - * 2: A raw message in binary, for example, audio data, or video data. - */ - MESSAGE_TYPE_BINARY = 2, - /** - * 4: A converge message. - */ - MESSAGE_TYPE_CONVERGE = 4, -} - -/** - * The IMessage class. - */ -export abstract class IMessage { - /** - * Gets the ID of the message. - * @return The ID of the current IMessage instance. - */ - abstract getMessageId(): number; - /** - * Gets the message type. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract getMessageType(): number; - /** - * Sets the content of the text message, or the text description of the raw message. - * @param str The content of the text message, or the text description of the raw message. The maximum length - * is 32 KB. - */ - abstract setText(str: string): void; - /** - * Gets the content of the text messsage, or the text description of the raw message. - * @return - * - The content of the text message or the text description of the raw message. - */ - abstract getText(): string; - /** - * Get pointer of custom raw message - * @return - * - The content of binary raw message - */ - abstract getRawMessageData(): Uint8Array; - /** - * Get length of custom raw message - * @return - * - The length of binary raw message in bytes - */ - abstract getRawMessageLength(): number; - /** - * Set message type - */ - abstract setMessageType(type: number): void; - /** - * Set raw binary message - */ - abstract setRawMessage(data: Uint8Array, length: number): void; - /** - * Releases the IMessage instance. - */ - abstract release(): void; -} - -/** - * The IChannelMember class. - */ -export abstract class IChannelMember { - /** - * Gets the ID of the channel member. - * @return The ID of the channel member. - */ - abstract getMemberId(): string; - /** - * Gets the ID of the channel. - * @return The ID of the channel. - */ - abstract getChannelId(): string; - /** - * Releases the IChannelMember class. - */ - abstract release(): void; -} - -/** - * The IChannelAttributes class. - */ -export abstract class IChannelAttributes { - /** - * Adds an attribute to a specified channel. - * - * @param key The pointer to the attribute key. - * @param value The pointer to the attribute value. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract addAttribute(key: string, value: string): number; - /** - * Removes an attribute from the channel. - * @param key The pointer to the attribute key. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract removeAttribute(key: string): number; - /** - * Gets the size of the attributes. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract getAttributesSize(): number; - /** - * Gets the channel attributes. - * @param size The size of the channel attributes. - * @param key The pointer to the key of each channel attribute. - * @param value The pointer to the value of each channel attribute. - */ - abstract getAttributes(size: number, key: string, value: string): void; - /** - * Gets the value of a channel attribute using the attribute key. - * @param key The pointer to the key of the channel attribute that you want to get. - */ - abstract getAttributeValue(key: string): string; - /** - * Releases the IChannelAttributes instance. - * @param - * - 0: Success. - * - < 0: Failure. - */ - abstract release(): number; -} - -/** - * The IChannelEventHandler class. - */ -export interface IChannelEventHandler { - /** - * Occurs when the local user successfully joins a channel. - */ - onJoinSuccess?(): void; - /** - * Occurs when the local user fails to join a channel. - * @param errorCode The error code: #JOIN_CHANNEL_ERR. - */ - onJoinFailure?(errorCode: JOIN_CHANNEL_ERR): void; - /** - * Occurs when the local user leaves a channel. - * @param errorCode The error code. See #LEAVE_CHANNEL_ERR. - */ - onLeave?(errorCode: LEAVE_CHANNEL_ERR): void; - /** - * Occurs when the local user receives a channel message. - * @param message The pointer to the messsage: IMessage. - */ - onMessageReceived?(userId: string, message: IMessage): void; - /** - * Reports the state of the message sent by the local user. - * @param messageId ID of the message. - * @param state The state of the message: #CHANNEL_MESSAGE_STATE. - */ - onSendMessageState?(messageId: number, state: CHANNEL_MESSAGE_STATE): void; - /** - * Returns the result of the \ref agora::rtm::IChannel::sendMessage "sendMessage" method call. - * - * @param messageId The ID of the sent channel message. - * @param state The error codes. See #CHANNEL_MESSAGE_ERR_CODE. - */ - onSendMessageResult?( - messageId: number, - state: CHANNEL_MESSAGE_ERR_CODE - ): void; - /** - * Occurs when another member joins the channel. - * @param member The pointer to the member who joins the channel: IChannelMember. - */ - onMemberJoined?(member: IChannelMember): void; - /** - * Occurs when the other member leaves the channel. - * @param member The pointer to the member who leaves the channel: IChannelMember. - */ - onMemberLeft?(member: IChannelMember): void; - /** - * Reports all the members in the channel. - * @param members The pointer to each member in the channel: IChannelMember. - * @param userCount The number of users in the channel. - */ - onMembersGotten?(members: IChannelMember[], userCount: number): void; - /** - * Occurs when the channel attributes are updated. - * @param attributes The pointer to the current channel attributes: IChannelAttributes. - */ - onAttributesUpdated?(attributes: IChannelAttributes[]): void; - /** - * Occurs when the local user calls updateAttributes(). - * @param requestId ID of the current attribute update request. - * @param resCode The response code: #RESPONSE_CODE. - */ - onUpdateAttributesResponse?(requestId: number, resCode: RESPONSE_CODE): void; - /** - * Occurs when the channel attributes are deleted. - * @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes. - */ - onAttributesDeleted?(attributes: IChannelAttributes[]): void; - /** - * Occurs when the local user calls deleteAttributes(). - * @param requestId ID of the current attribute delete request. - * @param resCode The response code: #RESPONSE_CODE. - */ - onDeleteAttributesResponse?(requestId: number, resCode: RESPONSE_CODE): void; -} - -/** - * The IChannel class. - */ -export abstract class IChannel { - /** - * Sets an event handler for IChannel. - * @param eventHandler The pointer to the event handler of IChannel: IChannelEventHandler. - */ - abstract setEventHandler(eventHandler: IChannelEventHandler): void; - /** - * Joins the current channel. - * - * A successful method call triggers either onJoinSuccess() or onJoinFailure() on the local client, to report - * the state of joining the channel. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract join(): number; - /** - * Leaves the current channel. - * - * After the local user successfully leaves the channel, the SDK triggers the onLeave() on the local client. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract leave(): number; - /** - * Sends a channel message. - * - * After you successfully send a channel message, all members in the channel receive the message in the - * onMessageReceived() callback. - * @param message The pointer to the channel message that you want to send: IMessage. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract sendMessage(message: IMessage): number; - /** - * Updates the channel attributes. - * - * A successful method call triggers the onUpdateAttributesResponse() callback on the local client. - * @param attributes The pointer to the channel attributes that you want to update: IChannelAttributes. - * @param requestId ID of the current update request. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract updateAttributes( - attributes: IChannelAttributes[], - requestId?: number - ): number; - /** - * Removes the channel attributes. - * - * A successful method call triggers the onDeleteAttributesResponse() callback on the local client. - * @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes. - * @param requestId ID of the current delete request. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract deleteAttributes( - attributes: IChannelAttributes[], - requestId?: number - ): number; - /** - * Gets the current request ID. - * @return - * - The pointer to the request ID, if the method call succeeds. - * - An empty pointer NULL, if the method call fails. - */ - abstract getId(): string; - /** - * Releases the IChannel instance. - * - * This is a synchronous method call, which means that the SDK reports the result of this method call - * after the IChannel instance is successfully released. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract release(): number; -} - -/** - * The IRtmServiceEventHandler class. - */ -export interface IRtmServiceEventHandler { - /** - * Occurs when the user successfully logs in the RTM service. - */ - onLoginSuccess?(): void; - /** - * Occurs when the user fails to log in the RTM service. - * @param errorCode The reason for the login failure: #LOGIN_ERR_CODE. - */ - onLoginFailure?(errorCode: LOGIN_ERR_CODE): void; - /** - * Occurs when the user successfully logs out of the RTM service. - */ - onLogout?(): void; - /** - * Occurs when the connection state of the local user has changed. - * @param state The current connection state: #CONNECTION_STATE. - */ - onConnectionStateChanged?(state: CONNECTION_STATE): void; - /** - * Reports the state of sending a message. - * @param messageId ID of the message. - * @param state The current state of the message: #PEER_MESSAGE_STATE. - */ - onSendMessageState?(messageId: number, state: PEER_MESSAGE_STATE): void; - /** - * Occurs when the local user receives a message from a remote user. - * @param peerId ID of the remote user that sends the message. - * @param message The pointer to the message: IMessage. - */ - onMessageReceivedFromPeer?(peerId: string, message: IMessage): void; -} - -/** - * The IRtmService class. - */ -export abstract class IRtmService { - /** - * Creates and gets an IRtmService instance. - * @param appId The pointer to the app ID. - * @param eventHandler The pointer to the IRtmServiceEventHandler object. - * @param eventSpace The connection specific ID, used during report to argus. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract initialize( - appId: string, - eventHandler: IRtmServiceEventHandler - ): number; - /** - * Releases the IRtmServiceEventHandler object. - * @param eventHandler The pointer to the IRtmServiceEventHandler object. - */ - abstract unregisterObserver(eventHandler: IRtmServiceEventHandler): void; - /** - * Releases the IRtmService instance. - * @param sync Determines whether to report the result of this method call synchronously. - * - true: Report the result of this method call after the IRtmService instance is released. - * - false: (Default) Report the result of this method call immediately, even when the IRtmService is not - * released. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract release(sync: boolean): number; - /** - * Logs in the RTM service. - * - * @note - * - If you login with the same user ID from a different instance, your previous login will be kicked. - * - The call frequency limit of this method is 2 queries per second. - * @param token The token used to log in the RTM service. - * @param userId ID of the user logging in the RTM service. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract login(token: string, userId: string): number; - /** - * Logs out of the RTM service. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract logout(): number; - /** - * Sends a peer message to a specified remote user. - * - * @param peerId The pointer to the ID of the remote user. - * @param message The pointer to message: IMessage. - * @return - * - 0: Success. - * - < 0: Failure. - */ - abstract sendMessageToPeer(peerId: string, message: IMessage): number; - /** - * Creates an RTM channel. - * - * @param channelId The unique channel name for an RTM session. Supported character scopes are: - * - All lowercase English letters: a to z. - * - All uppercase English letters: A to Z. - * - All numeric characters: 0 to 9. - * - The space character. - * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", - * ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", "," - * - * @param eventHandler The pointer to IChannelEventHandler. - * @return - * - The pointer to an IChannel instance, if the method call succeeds. - * - An empty pointer NULL, if the method call fails. - */ - abstract createChannel( - channelId: string, - eventHandler: IChannelEventHandler - ): IChannel; -} diff --git a/src/IAgoraRtmStorage.ts b/src/IAgoraRtmStorage.ts index a9d4037..a0570f2 100644 --- a/src/IAgoraRtmStorage.ts +++ b/src/IAgoraRtmStorage.ts @@ -60,9 +60,9 @@ export class MetadataItem { export abstract class IRtmStorage { /** - Creates the metadata object and returns the pointer. +Creates the metadata object and returns the pointer. * @return Pointer of the metadata object. - */ +*/ abstract createMetadata(): RtmMetadata; /** * Set the metadata of a specified channel. diff --git a/src/IAgoraStreamChannel.ts b/src/IAgoraStreamChannel.ts index 91d72c8..ceb7b28 100644 --- a/src/IAgoraStreamChannel.ts +++ b/src/IAgoraStreamChannel.ts @@ -214,7 +214,7 @@ export abstract class IStreamChannel { */ abstract subscribeTopic( topic: string, - options?: TopicOptions, + options: TopicOptions, requestId?: number ): number; /** @@ -225,7 +225,7 @@ export abstract class IStreamChannel { * - 0: Success. * - < 0: Failure. */ - abstract unsubscribeTopic(topic: string, options?: TopicOptions): number; + abstract unsubscribeTopic(topic: string, options: TopicOptions): number; /** * Get subscribed user list * @@ -235,7 +235,7 @@ export abstract class IStreamChannel { * - 0: Success. * - < 0: Failure. */ - abstract getSubscribedUserList(topic: string, users: UserList[]): number; + abstract getSubscribedUserList(topic: string): UserList[]; /** * Release the stream channel instance. * diff --git a/src/impl/IAgoraRtmClientImpl.ts b/src/impl/IAgoraRtmClientImpl.ts index 006d262..e549494 100644 --- a/src/impl/IAgoraRtmClientImpl.ts +++ b/src/impl/IAgoraRtmClientImpl.ts @@ -4,9 +4,6 @@ import { IRtmLock } from '../IAgoraRtmLock'; import { IRtmPresence } from '../IAgoraRtmPresence'; import { IRtmStorage } from '../IAgoraRtmStorage'; import { IStreamChannel } from '../IAgoraStreamChannel'; -import { callIrisApi } from '../index'; - -/// Generated by terra, DO NOT MODIFY BY HAND. export function processIRtmEventHandler( handler: IRtmEventHandler, @@ -357,7 +354,7 @@ export function processIRtmEventHandler( // @ts-ignore export class IRtmClientImpl implements IRtmClient { initialize(config: RtmConfig): number { - const apiType = this.getApiTypeFromInitialize(); + const apiType = this.getApiTypeFromInitialize(config); const jsonParams = { config: config, toJSON: () => { @@ -370,7 +367,7 @@ export class IRtmClientImpl implements IRtmClient { return jsonResults.result; } - protected getApiTypeFromInitialize(): string { + protected getApiTypeFromInitialize(config: RtmConfig): string { return 'RtmClient_initialize'; } @@ -386,7 +383,7 @@ export class IRtmClientImpl implements IRtmClient { } login(token: string): number { - const apiType = this.getApiTypeFromLogin(); + const apiType = this.getApiTypeFromLogin(token); const jsonParams = { token: token, toJSON: () => { @@ -399,7 +396,7 @@ export class IRtmClientImpl implements IRtmClient { return jsonResults.result; } - protected getApiTypeFromLogin(): string { + protected getApiTypeFromLogin(token: string): string { return 'RtmClient_login'; } @@ -448,7 +445,7 @@ export class IRtmClientImpl implements IRtmClient { } renewToken(token: string): number { - const apiType = this.getApiTypeFromRenewToken(); + const apiType = this.getApiTypeFromRenewToken(token); const jsonParams = { token: token, toJSON: () => { @@ -461,7 +458,7 @@ export class IRtmClientImpl implements IRtmClient { return jsonResults.result; } - protected getApiTypeFromRenewToken(): string { + protected getApiTypeFromRenewToken(token: string): string { return 'RtmClient_renewToken'; } @@ -469,62 +466,68 @@ export class IRtmClientImpl implements IRtmClient { channelName: string, message: string, length: number, - option: PublishOptions, - requestId?: number + option: PublishOptions ): number { - const apiType = this.getApiTypeFromPublish(); + const apiType = this.getApiTypeFromPublish( + channelName, + message, + length, + option + ); const jsonParams = { channelName: channelName, message: message, length: length, option: option, - requestId: requestId, toJSON: () => { return { channelName: channelName, message: message, length: length, option: option, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromPublish(): string { + protected getApiTypeFromPublish( + channelName: string, + message: string, + length: number, + option: PublishOptions + ): string { return 'RtmClient_publish'; } - subscribe( - channelName: string, - options: SubscribeOptions, - requestId?: number - ): number { - const apiType = this.getApiTypeFromSubscribe(); + subscribe(channelName: string, options: SubscribeOptions): number { + const apiType = this.getApiTypeFromSubscribe(channelName, options); const jsonParams = { channelName: channelName, options: options, - requestId: requestId, toJSON: () => { return { channelName: channelName, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSubscribe(): string { + protected getApiTypeFromSubscribe( + channelName: string, + options: SubscribeOptions + ): string { return 'RtmClient_subscribe'; } unsubscribe(channelName: string): number { - const apiType = this.getApiTypeFromUnsubscribe(); + const apiType = this.getApiTypeFromUnsubscribe(channelName); const jsonParams = { channelName: channelName, toJSON: () => { @@ -537,12 +540,12 @@ export class IRtmClientImpl implements IRtmClient { return jsonResults.result; } - protected getApiTypeFromUnsubscribe(): string { + protected getApiTypeFromUnsubscribe(channelName: string): string { return 'RtmClient_unsubscribe'; } createStreamChannel(channelName: string): IStreamChannel { - const apiType = this.getApiTypeFromCreateStreamChannel(); + const apiType = this.getApiTypeFromCreateStreamChannel(channelName); const jsonParams = { channelName: channelName, toJSON: () => { @@ -555,12 +558,12 @@ export class IRtmClientImpl implements IRtmClient { return jsonResults.result; } - protected getApiTypeFromCreateStreamChannel(): string { + protected getApiTypeFromCreateStreamChannel(channelName: string): string { return 'RtmClient_createStreamChannel'; } setParameters(parameters: string): number { - const apiType = this.getApiTypeFromSetParameters(); + const apiType = this.getApiTypeFromSetParameters(parameters); const jsonParams = { parameters: parameters, toJSON: () => { @@ -573,7 +576,7 @@ export class IRtmClientImpl implements IRtmClient { return jsonResults.result; } - protected getApiTypeFromSetParameters(): string { + protected getApiTypeFromSetParameters(parameters: string): string { return 'RtmClient_setParameters'; } @@ -581,31 +584,40 @@ export class IRtmClientImpl implements IRtmClient { channelName: string, message: Uint8Array, length: number, - option: PublishOptions, - requestId?: number + option: PublishOptions ): number { - const apiType = this.getApiTypeFromPublishWithBuffer(); + const apiType = this.getApiTypeFromPublishWithBuffer( + channelName, + message, + length, + option + ); const jsonParams = { channelName: channelName, message: message, length: length, option: option, - requestId: requestId, toJSON: () => { return { channelName: channelName, - message: message, length: length, option: option, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromPublishWithBuffer(): string { + protected getApiTypeFromPublishWithBuffer( + channelName: string, + message: Uint8Array, + length: number, + option: PublishOptions + ): string { return 'RtmClient_publishWithBuffer'; } } + +import { callIrisApi } from '../internal/IrisRtmEngine'; diff --git a/src/impl/IAgoraRtmLockImpl.ts b/src/impl/IAgoraRtmLockImpl.ts index 909aaee..641b9d3 100644 --- a/src/impl/IAgoraRtmLockImpl.ts +++ b/src/impl/IAgoraRtmLockImpl.ts @@ -1,8 +1,5 @@ import { RTM_CHANNEL_TYPE } from '../AgoraRtmBase'; import { IRtmLock } from '../IAgoraRtmLock'; -import { callIrisApi } from '../index'; - -/// Generated by terra, DO NOT MODIFY BY HAND. // @ts-ignore export class IRtmLockImpl implements IRtmLock { @@ -10,86 +7,98 @@ export class IRtmLockImpl implements IRtmLock { channelName: string, channelType: RTM_CHANNEL_TYPE, lockName: string, - ttl: number, - requestId?: number + ttl: number ): number { - const apiType = this.getApiTypeFromSetLock(); + const apiType = this.getApiTypeFromSetLock( + channelName, + channelType, + lockName, + ttl + ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, ttl: ttl, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, ttl: ttl, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSetLock(): string { + protected getApiTypeFromSetLock( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + lockName: string, + ttl: number + ): string { return 'RtmLock_setLock'; } - getLocks( - channelName: string, - channelType: RTM_CHANNEL_TYPE, - requestId?: number - ): number { - const apiType = this.getApiTypeFromGetLocks(); + getLocks(channelName: string, channelType: RTM_CHANNEL_TYPE): number { + const apiType = this.getApiTypeFromGetLocks(channelName, channelType); const jsonParams = { channelName: channelName, channelType: channelType, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromGetLocks(): string { + protected getApiTypeFromGetLocks( + channelName: string, + channelType: RTM_CHANNEL_TYPE + ): string { return 'RtmLock_getLocks'; } removeLock( channelName: string, channelType: RTM_CHANNEL_TYPE, - lockName: string, - requestId?: number + lockName: string ): number { - const apiType = this.getApiTypeFromRemoveLock(); + const apiType = this.getApiTypeFromRemoveLock( + channelName, + channelType, + lockName + ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromRemoveLock(): string { + protected getApiTypeFromRemoveLock( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + lockName: string + ): string { return 'RtmLock_removeLock'; } @@ -97,60 +106,74 @@ export class IRtmLockImpl implements IRtmLock { channelName: string, channelType: RTM_CHANNEL_TYPE, lockName: string, - retry: boolean, - requestId?: number + retry: boolean ): number { - const apiType = this.getApiTypeFromAcquireLock(); + const apiType = this.getApiTypeFromAcquireLock( + channelName, + channelType, + lockName, + retry + ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, retry: retry, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, retry: retry, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromAcquireLock(): string { + protected getApiTypeFromAcquireLock( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + lockName: string, + retry: boolean + ): string { return 'RtmLock_acquireLock'; } releaseLock( channelName: string, channelType: RTM_CHANNEL_TYPE, - lockName: string, - requestId?: number + lockName: string ): number { - const apiType = this.getApiTypeFromReleaseLock(); + const apiType = this.getApiTypeFromReleaseLock( + channelName, + channelType, + lockName + ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromReleaseLock(): string { + protected getApiTypeFromReleaseLock( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + lockName: string + ): string { return 'RtmLock_releaseLock'; } @@ -158,31 +181,41 @@ export class IRtmLockImpl implements IRtmLock { channelName: string, channelType: RTM_CHANNEL_TYPE, lockName: string, - owner: string, - requestId?: number + owner: string ): number { - const apiType = this.getApiTypeFromRevokeLock(); + const apiType = this.getApiTypeFromRevokeLock( + channelName, + channelType, + lockName, + owner + ); const jsonParams = { channelName: channelName, channelType: channelType, lockName: lockName, owner: owner, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, lockName: lockName, owner: owner, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromRevokeLock(): string { + protected getApiTypeFromRevokeLock( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + lockName: string, + owner: string + ): string { return 'RtmLock_revokeLock'; } } + +import { callIrisApi } from '../internal/IrisRtmEngine'; diff --git a/src/impl/IAgoraRtmPresenceImpl.ts b/src/impl/IAgoraRtmPresenceImpl.ts index 4c68f46..5f352d7 100644 --- a/src/impl/IAgoraRtmPresenceImpl.ts +++ b/src/impl/IAgoraRtmPresenceImpl.ts @@ -5,58 +5,60 @@ import { StateItem, } from '../AgoraRtmBase'; import { IRtmPresence } from '../IAgoraRtmPresence'; -import { callIrisApi } from '../index'; - -/// Generated by terra, DO NOT MODIFY BY HAND. // @ts-ignore export class IRtmPresenceImpl implements IRtmPresence { whoNow( channelName: string, channelType: RTM_CHANNEL_TYPE, - options: PresenceOptions, - requestId?: number + options: PresenceOptions ): number { - const apiType = this.getApiTypeFromWhoNow(); + const apiType = this.getApiTypeFromWhoNow( + channelName, + channelType, + options + ); const jsonParams = { channelName: channelName, channelType: channelType, options: options, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromWhoNow(): string { + protected getApiTypeFromWhoNow( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + options: PresenceOptions + ): string { return 'RtmPresence_whoNow'; } - whereNow(userId: string, requestId?: number): number { - const apiType = this.getApiTypeFromWhereNow(); + whereNow(userId: string): number { + const apiType = this.getApiTypeFromWhereNow(userId); const jsonParams = { userId: userId, - requestId: requestId, toJSON: () => { return { userId: userId, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromWhereNow(): string { + protected getApiTypeFromWhereNow(userId: string): string { return 'RtmPresence_whereNow'; } @@ -64,31 +66,39 @@ export class IRtmPresenceImpl implements IRtmPresence { channelName: string, channelType: RTM_CHANNEL_TYPE, items: StateItem[], - count: number, - requestId?: number + count: number ): number { - const apiType = this.getApiTypeFromSetState(); + const apiType = this.getApiTypeFromSetState( + channelName, + channelType, + items, + count + ); const jsonParams = { channelName: channelName, channelType: channelType, items: items, count: count, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, items: items, count: count, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSetState(): string { + protected getApiTypeFromSetState( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + items: StateItem[], + count: number + ): string { return 'RtmPresence_setState'; } @@ -96,109 +106,130 @@ export class IRtmPresenceImpl implements IRtmPresence { channelName: string, channelType: RTM_CHANNEL_TYPE, keys: string[], - count: number, - requestId?: number + count: number ): number { - const apiType = this.getApiTypeFromRemoveState(); + const apiType = this.getApiTypeFromRemoveState( + channelName, + channelType, + keys, + count + ); const jsonParams = { channelName: channelName, channelType: channelType, keys: keys, count: count, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, keys: keys, count: count, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromRemoveState(): string { + protected getApiTypeFromRemoveState( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + keys: string[], + count: number + ): string { return 'RtmPresence_removeState'; } getState( channelName: string, channelType: RTM_CHANNEL_TYPE, - userId: string, - requestId?: number + userId: string ): number { - const apiType = this.getApiTypeFromGetState(); + const apiType = this.getApiTypeFromGetState( + channelName, + channelType, + userId + ); const jsonParams = { channelName: channelName, channelType: channelType, userId: userId, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, userId: userId, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromGetState(): string { + protected getApiTypeFromGetState( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + userId: string + ): string { return 'RtmPresence_getState'; } getOnlineUsers( channelName: string, channelType: RTM_CHANNEL_TYPE, - options: GetOnlineUsersOptions, - requestId?: number + options: GetOnlineUsersOptions ): number { - const apiType = this.getApiTypeFromGetOnlineUsers(); + const apiType = this.getApiTypeFromGetOnlineUsers( + channelName, + channelType, + options + ); const jsonParams = { channelName: channelName, channelType: channelType, options: options, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromGetOnlineUsers(): string { + protected getApiTypeFromGetOnlineUsers( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + options: GetOnlineUsersOptions + ): string { return 'RtmPresence_getOnlineUsers'; } - getUserChannels(userId: string, requestId?: number): number { - const apiType = this.getApiTypeFromGetUserChannels(); + getUserChannels(userId: string): number { + const apiType = this.getApiTypeFromGetUserChannels(userId); const jsonParams = { userId: userId, - requestId: requestId, toJSON: () => { return { userId: userId, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromGetUserChannels(): string { + protected getApiTypeFromGetUserChannels(userId: string): string { return 'RtmPresence_getUserChannels'; } } + +import { callIrisApi } from '../internal/IrisRtmEngine'; diff --git a/src/impl/IAgoraRtmServiceImpl.ts b/src/impl/IAgoraRtmServiceImpl.ts deleted file mode 100644 index f58676b..0000000 --- a/src/impl/IAgoraRtmServiceImpl.ts +++ /dev/null @@ -1,660 +0,0 @@ -import { - IChannel, - IChannelAttributes, - IChannelEventHandler, - IChannelMember, - IMessage, - IRtmService, - IRtmServiceEventHandler, -} from '../IAgoraRtmService'; -import { callIrisApi } from '../index'; - -/// Generated by terra, DO NOT MODIFY BY HAND. - -// @ts-ignore -export class IMessageImpl implements IMessage { - getMessageId(): number { - const apiType = this.getApiTypeFromGetMessageId(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetMessageId(): string { - return 'Message_getMessageId'; - } - - getMessageType(): number { - const apiType = this.getApiTypeFromGetMessageType(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetMessageType(): string { - return 'Message_getMessageType'; - } - - setText(str: string): void { - const apiType = this.getApiTypeFromSetText(); - const jsonParams = { - str: str, - toJSON: () => { - return { - str: str, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromSetText(): string { - return 'Message_setText'; - } - - getText(): string { - const apiType = this.getApiTypeFromGetText(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetText(): string { - return 'Message_getText'; - } - - getRawMessageData(): Uint8Array { - const apiType = this.getApiTypeFromGetRawMessageData(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetRawMessageData(): string { - return 'Message_getRawMessageData'; - } - - getRawMessageLength(): number { - const apiType = this.getApiTypeFromGetRawMessageLength(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetRawMessageLength(): string { - return 'Message_getRawMessageLength'; - } - - setMessageType(type: number): void { - const apiType = this.getApiTypeFromSetMessageType(); - const jsonParams = { - type: type, - toJSON: () => { - return { - type: type, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromSetMessageType(): string { - return 'Message_setMessageType'; - } - - setRawMessage(data: Uint8Array, length: number): void { - const apiType = this.getApiTypeFromSetRawMessage(); - const jsonParams = { - data: data, - length: length, - toJSON: () => { - return { - data: data, - length: length, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromSetRawMessage(): string { - return 'Message_setRawMessage'; - } - - release(): void { - const apiType = this.getApiTypeFromRelease(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromRelease(): string { - return 'Message_release'; - } -} - -// @ts-ignore -export class IChannelMemberImpl implements IChannelMember { - getMemberId(): string { - const apiType = this.getApiTypeFromGetMemberId(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetMemberId(): string { - return 'ChannelMember_getMemberId'; - } - - getChannelId(): string { - const apiType = this.getApiTypeFromGetChannelId(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetChannelId(): string { - return 'ChannelMember_getChannelId'; - } - - release(): void { - const apiType = this.getApiTypeFromRelease(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromRelease(): string { - return 'ChannelMember_release'; - } -} - -// @ts-ignore -export class IChannelAttributesImpl implements IChannelAttributes { - addAttribute(key: string, value: string): number { - const apiType = this.getApiTypeFromAddAttribute(); - const jsonParams = { - key: key, - value: value, - toJSON: () => { - return { - key: key, - value: value, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromAddAttribute(): string { - return 'ChannelAttributes_addAttribute'; - } - - removeAttribute(key: string): number { - const apiType = this.getApiTypeFromRemoveAttribute(); - const jsonParams = { - key: key, - toJSON: () => { - return { - key: key, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromRemoveAttribute(): string { - return 'ChannelAttributes_removeAttribute'; - } - - getAttributesSize(): number { - const apiType = this.getApiTypeFromGetAttributesSize(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetAttributesSize(): string { - return 'ChannelAttributes_getAttributesSize'; - } - - getAttributes(size: number, key: string, value: string): void { - const apiType = this.getApiTypeFromGetAttributes(); - const jsonParams = { - size: size, - key: key, - value: value, - toJSON: () => { - return { - size: size, - key: key, - value: value, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetAttributes(): string { - return 'ChannelAttributes_getAttributes'; - } - - getAttributeValue(key: string): string { - const apiType = this.getApiTypeFromGetAttributeValue(); - const jsonParams = { - key: key, - toJSON: () => { - return { - key: key, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetAttributeValue(): string { - return 'ChannelAttributes_getAttributeValue'; - } - - release(): number { - const apiType = this.getApiTypeFromRelease(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromRelease(): string { - return 'ChannelAttributes_release'; - } -} - -export function processIChannelEventHandler( - handler: IChannelEventHandler, - event: string, - jsonParams: any -) { - switch (event) { - case 'onJoinSuccess': - if (handler.onJoinSuccess !== undefined) { - handler.onJoinSuccess(); - } - break; - case 'onJoinFailure': - if (handler.onJoinFailure !== undefined) { - handler.onJoinFailure(jsonParams.errorCode); - } - break; - case 'onLeave': - if (handler.onLeave !== undefined) { - handler.onLeave(jsonParams.errorCode); - } - break; - case 'onMessageReceived': - if (handler.onMessageReceived !== undefined) { - handler.onMessageReceived(jsonParams.userId, jsonParams.message); - } - break; - case 'onSendMessageState': - if (handler.onSendMessageState !== undefined) { - handler.onSendMessageState(jsonParams.messageId, jsonParams.state); - } - break; - case 'onSendMessageResult': - if (handler.onSendMessageResult !== undefined) { - handler.onSendMessageResult(jsonParams.messageId, jsonParams.state); - } - break; - case 'onMemberJoined': - if (handler.onMemberJoined !== undefined) { - handler.onMemberJoined(jsonParams.member); - } - break; - case 'onMemberLeft': - if (handler.onMemberLeft !== undefined) { - handler.onMemberLeft(jsonParams.member); - } - break; - case 'onMembersGotten': - if (handler.onMembersGotten !== undefined) { - handler.onMembersGotten(jsonParams.members, jsonParams.userCount); - } - break; - case 'onAttributesUpdated': - if (handler.onAttributesUpdated !== undefined) { - handler.onAttributesUpdated(jsonParams.attributes); - } - break; - case 'onUpdateAttributesResponse': - if (handler.onUpdateAttributesResponse !== undefined) { - handler.onUpdateAttributesResponse( - jsonParams.requestId, - jsonParams.resCode - ); - } - break; - case 'onAttributesDeleted': - if (handler.onAttributesDeleted !== undefined) { - handler.onAttributesDeleted(jsonParams.attributes); - } - break; - case 'onDeleteAttributesResponse': - if (handler.onDeleteAttributesResponse !== undefined) { - handler.onDeleteAttributesResponse( - jsonParams.requestId, - jsonParams.resCode - ); - } - break; - } -} - -// @ts-ignore -export class IChannelImpl implements IChannel { - setEventHandler(eventHandler: IChannelEventHandler): void { - const apiType = this.getApiTypeFromSetEventHandler(); - const jsonParams = { - eventHandler: eventHandler, - toJSON: () => { - return { - eventHandler: eventHandler, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromSetEventHandler(): string { - return 'Channel_setEventHandler'; - } - - join(): number { - const apiType = this.getApiTypeFromJoin(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromJoin(): string { - return 'Channel_join'; - } - - leave(): number { - const apiType = this.getApiTypeFromLeave(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromLeave(): string { - return 'Channel_leave'; - } - - sendMessage(message: IMessage): number { - const apiType = this.getApiTypeFromSendMessage(); - const jsonParams = { - message: message, - toJSON: () => { - return { - message: message, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromSendMessage(): string { - return 'Channel_sendMessage'; - } - - updateAttributes( - attributes: IChannelAttributes[], - requestId?: number - ): number { - const apiType = this.getApiTypeFromUpdateAttributes(); - const jsonParams = { - attributes: attributes, - requestId: requestId, - toJSON: () => { - return { - attributes: attributes, - requestId: requestId, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromUpdateAttributes(): string { - return 'Channel_updateAttributes'; - } - - deleteAttributes( - attributes: IChannelAttributes[], - requestId?: number - ): number { - const apiType = this.getApiTypeFromDeleteAttributes(); - const jsonParams = { - attributes: attributes, - requestId: requestId, - toJSON: () => { - return { - attributes: attributes, - requestId: requestId, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromDeleteAttributes(): string { - return 'Channel_deleteAttributes'; - } - - getId(): string { - const apiType = this.getApiTypeFromGetId(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromGetId(): string { - return 'Channel_getId'; - } - - release(): number { - const apiType = this.getApiTypeFromRelease(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromRelease(): string { - return 'Channel_release'; - } -} - -export function processIRtmServiceEventHandler( - handler: IRtmServiceEventHandler, - event: string, - jsonParams: any -) { - switch (event) { - case 'onLoginSuccess': - if (handler.onLoginSuccess !== undefined) { - handler.onLoginSuccess(); - } - break; - case 'onLoginFailure': - if (handler.onLoginFailure !== undefined) { - handler.onLoginFailure(jsonParams.errorCode); - } - break; - case 'onLogout': - if (handler.onLogout !== undefined) { - handler.onLogout(); - } - break; - case 'onConnectionStateChanged': - if (handler.onConnectionStateChanged !== undefined) { - handler.onConnectionStateChanged(jsonParams.state); - } - break; - case 'onSendMessageState': - if (handler.onSendMessageState !== undefined) { - handler.onSendMessageState(jsonParams.messageId, jsonParams.state); - } - break; - case 'onMessageReceivedFromPeer': - if (handler.onMessageReceivedFromPeer !== undefined) { - handler.onMessageReceivedFromPeer( - jsonParams.peerId, - jsonParams.message - ); - } - break; - } -} - -// @ts-ignore -export class IRtmServiceImpl implements IRtmService { - initialize(appId: string, eventHandler: IRtmServiceEventHandler): number { - const apiType = this.getApiTypeFromInitialize(); - const jsonParams = { - appId: appId, - eventHandler: eventHandler, - toJSON: () => { - return { - appId: appId, - eventHandler: eventHandler, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromInitialize(): string { - return 'RtmService_initialize'; - } - - unregisterObserver(eventHandler: IRtmServiceEventHandler): void { - const apiType = this.getApiTypeFromUnregisterObserver(); - const jsonParams = { - eventHandler: eventHandler, - toJSON: () => { - return { - eventHandler: eventHandler, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromUnregisterObserver(): string { - return 'RtmService_unregisterObserver'; - } - - release(sync: boolean): number { - const apiType = this.getApiTypeFromRelease(); - const jsonParams = { - sync: sync, - toJSON: () => { - return { - sync: sync, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromRelease(): string { - return 'RtmService_release'; - } - - login(token: string, userId: string): number { - const apiType = this.getApiTypeFromLogin(); - const jsonParams = { - token: token, - userId: userId, - toJSON: () => { - return { - token: token, - userId: userId, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromLogin(): string { - return 'RtmService_login'; - } - - logout(): number { - const apiType = this.getApiTypeFromLogout(); - const jsonParams = {}; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromLogout(): string { - return 'RtmService_logout'; - } - - sendMessageToPeer(peerId: string, message: IMessage): number { - const apiType = this.getApiTypeFromSendMessageToPeer(); - const jsonParams = { - peerId: peerId, - message: message, - toJSON: () => { - return { - peerId: peerId, - message: message, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromSendMessageToPeer(): string { - return 'RtmService_sendMessageToPeer'; - } - - createChannel( - channelId: string, - eventHandler: IChannelEventHandler - ): IChannel { - const apiType = this.getApiTypeFromCreateChannel(); - const jsonParams = { - channelId: channelId, - eventHandler: eventHandler, - toJSON: () => { - return { - channelId: channelId, - eventHandler: eventHandler, - }; - }, - }; - const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; - } - - protected getApiTypeFromCreateChannel(): string { - return 'RtmService_createChannel'; - } -} diff --git a/src/impl/IAgoraRtmStorageImpl.ts b/src/impl/IAgoraRtmStorageImpl.ts index 2bc53c9..6835f83 100644 --- a/src/impl/IAgoraRtmStorageImpl.ts +++ b/src/impl/IAgoraRtmStorageImpl.ts @@ -1,8 +1,5 @@ import { RTM_CHANNEL_TYPE } from '../AgoraRtmBase'; import { IRtmStorage, MetadataOptions, RtmMetadata } from '../IAgoraRtmStorage'; -import { callIrisApi } from '../index'; - -/// Generated by terra, DO NOT MODIFY BY HAND. // @ts-ignore export class IRtmStorageImpl implements IRtmStorage { @@ -22,17 +19,21 @@ export class IRtmStorageImpl implements IRtmStorage { channelType: RTM_CHANNEL_TYPE, data: RtmMetadata, options: MetadataOptions, - lockName: string, - requestId?: number + lockName: string ): number { - const apiType = this.getApiTypeFromSetChannelMetadata(); + const apiType = this.getApiTypeFromSetChannelMetadata( + channelName, + channelType, + data, + options, + lockName + ); const jsonParams = { channelName: channelName, channelType: channelType, data: data, options: options, lockName: lockName, - requestId: requestId, toJSON: () => { return { channelName: channelName, @@ -40,15 +41,21 @@ export class IRtmStorageImpl implements IRtmStorage { data: data, options: options, lockName: lockName, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSetChannelMetadata(): string { + protected getApiTypeFromSetChannelMetadata( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + data: RtmMetadata, + options: MetadataOptions, + lockName: string + ): string { return 'RtmStorage_setChannelMetadata'; } @@ -57,17 +64,21 @@ export class IRtmStorageImpl implements IRtmStorage { channelType: RTM_CHANNEL_TYPE, data: RtmMetadata, options: MetadataOptions, - lockName: string, - requestId?: number + lockName: string ): number { - const apiType = this.getApiTypeFromUpdateChannelMetadata(); + const apiType = this.getApiTypeFromUpdateChannelMetadata( + channelName, + channelType, + data, + options, + lockName + ); const jsonParams = { channelName: channelName, channelType: channelType, data: data, options: options, lockName: lockName, - requestId: requestId, toJSON: () => { return { channelName: channelName, @@ -75,15 +86,21 @@ export class IRtmStorageImpl implements IRtmStorage { data: data, options: options, lockName: lockName, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromUpdateChannelMetadata(): string { + protected getApiTypeFromUpdateChannelMetadata( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + data: RtmMetadata, + options: MetadataOptions, + lockName: string + ): string { return 'RtmStorage_updateChannelMetadata'; } @@ -92,17 +109,21 @@ export class IRtmStorageImpl implements IRtmStorage { channelType: RTM_CHANNEL_TYPE, data: RtmMetadata, options: MetadataOptions, - lockName: string, - requestId?: number + lockName: string ): number { - const apiType = this.getApiTypeFromRemoveChannelMetadata(); + const apiType = this.getApiTypeFromRemoveChannelMetadata( + channelName, + channelType, + data, + options, + lockName + ); const jsonParams = { channelName: channelName, channelType: channelType, data: data, options: options, lockName: lockName, - requestId: requestId, toJSON: () => { return { channelName: channelName, @@ -110,173 +131,195 @@ export class IRtmStorageImpl implements IRtmStorage { data: data, options: options, lockName: lockName, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromRemoveChannelMetadata(): string { + protected getApiTypeFromRemoveChannelMetadata( + channelName: string, + channelType: RTM_CHANNEL_TYPE, + data: RtmMetadata, + options: MetadataOptions, + lockName: string + ): string { return 'RtmStorage_removeChannelMetadata'; } getChannelMetadata( channelName: string, - channelType: RTM_CHANNEL_TYPE, - requestId?: number + channelType: RTM_CHANNEL_TYPE ): number { - const apiType = this.getApiTypeFromGetChannelMetadata(); + const apiType = this.getApiTypeFromGetChannelMetadata( + channelName, + channelType + ); const jsonParams = { channelName: channelName, channelType: channelType, - requestId: requestId, toJSON: () => { return { channelName: channelName, channelType: channelType, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromGetChannelMetadata(): string { + protected getApiTypeFromGetChannelMetadata( + channelName: string, + channelType: RTM_CHANNEL_TYPE + ): string { return 'RtmStorage_getChannelMetadata'; } setUserMetadata( userId: string, data: RtmMetadata, - options: MetadataOptions, - requestId?: number + options: MetadataOptions ): number { - const apiType = this.getApiTypeFromSetUserMetadata(); + const apiType = this.getApiTypeFromSetUserMetadata(userId, data, options); const jsonParams = { userId: userId, data: data, options: options, - requestId: requestId, toJSON: () => { return { userId: userId, data: data, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSetUserMetadata(): string { + protected getApiTypeFromSetUserMetadata( + userId: string, + data: RtmMetadata, + options: MetadataOptions + ): string { return 'RtmStorage_setUserMetadata'; } updateUserMetadata( userId: string, data: RtmMetadata, - options: MetadataOptions, - requestId?: number + options: MetadataOptions ): number { - const apiType = this.getApiTypeFromUpdateUserMetadata(); + const apiType = this.getApiTypeFromUpdateUserMetadata( + userId, + data, + options + ); const jsonParams = { userId: userId, data: data, options: options, - requestId: requestId, toJSON: () => { return { userId: userId, data: data, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromUpdateUserMetadata(): string { + protected getApiTypeFromUpdateUserMetadata( + userId: string, + data: RtmMetadata, + options: MetadataOptions + ): string { return 'RtmStorage_updateUserMetadata'; } removeUserMetadata( userId: string, data: RtmMetadata, - options: MetadataOptions, - requestId?: number + options: MetadataOptions ): number { - const apiType = this.getApiTypeFromRemoveUserMetadata(); + const apiType = this.getApiTypeFromRemoveUserMetadata( + userId, + data, + options + ); const jsonParams = { userId: userId, data: data, options: options, - requestId: requestId, toJSON: () => { return { userId: userId, data: data, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromRemoveUserMetadata(): string { + protected getApiTypeFromRemoveUserMetadata( + userId: string, + data: RtmMetadata, + options: MetadataOptions + ): string { return 'RtmStorage_removeUserMetadata'; } - getUserMetadata(userId: string, requestId?: number): number { - const apiType = this.getApiTypeFromGetUserMetadata(); + getUserMetadata(userId: string): number { + const apiType = this.getApiTypeFromGetUserMetadata(userId); const jsonParams = { userId: userId, - requestId: requestId, toJSON: () => { return { userId: userId, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromGetUserMetadata(): string { + protected getApiTypeFromGetUserMetadata(userId: string): string { return 'RtmStorage_getUserMetadata'; } - subscribeUserMetadata(userId: string, requestId?: number): number { - const apiType = this.getApiTypeFromSubscribeUserMetadata(); + subscribeUserMetadata(userId: string): number { + const apiType = this.getApiTypeFromSubscribeUserMetadata(userId); const jsonParams = { userId: userId, - requestId: requestId, toJSON: () => { return { userId: userId, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSubscribeUserMetadata(): string { + protected getApiTypeFromSubscribeUserMetadata(userId: string): string { return 'RtmStorage_subscribeUserMetadata'; } unsubscribeUserMetadata(userId: string): number { - const apiType = this.getApiTypeFromUnsubscribeUserMetadata(); + const apiType = this.getApiTypeFromUnsubscribeUserMetadata(userId); const jsonParams = { userId: userId, toJSON: () => { @@ -289,7 +332,9 @@ export class IRtmStorageImpl implements IRtmStorage { return jsonResults.result; } - protected getApiTypeFromUnsubscribeUserMetadata(): string { + protected getApiTypeFromUnsubscribeUserMetadata(userId: string): string { return 'RtmStorage_unsubscribeUserMetadata'; } } + +import { callIrisApi } from '../internal/IrisRtmEngine'; diff --git a/src/impl/IAgoraStreamChannelImpl.ts b/src/impl/IAgoraStreamChannelImpl.ts index 9ea103e..9e2086a 100644 --- a/src/impl/IAgoraStreamChannelImpl.ts +++ b/src/impl/IAgoraStreamChannelImpl.ts @@ -5,34 +5,30 @@ import { JoinTopicOptions, TopicOptions, } from '../IAgoraStreamChannel'; -import { callIrisApi } from '../index'; - -/// Generated by terra, DO NOT MODIFY BY HAND. // @ts-ignore export class IStreamChannelImpl implements IStreamChannel { - join(options: JoinChannelOptions, requestId?: number): number { - const apiType = this.getApiTypeFromJoin(); + join(options: JoinChannelOptions): number { + const apiType = this.getApiTypeFromJoin(options); const jsonParams = { options: options, - requestId: requestId, toJSON: () => { return { options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromJoin(): string { + protected getApiTypeFromJoin(options: JoinChannelOptions): string { return 'StreamChannel_join'; } renewToken(token: string): number { - const apiType = this.getApiTypeFromRenewToken(); + const apiType = this.getApiTypeFromRenewToken(token); const jsonParams = { token: token, toJSON: () => { @@ -45,22 +41,16 @@ export class IStreamChannelImpl implements IStreamChannel { return jsonResults.result; } - protected getApiTypeFromRenewToken(): string { + protected getApiTypeFromRenewToken(token: string): string { return 'StreamChannel_renewToken'; } - leave(requestId?: number): number { + leave(): number { const apiType = this.getApiTypeFromLeave(); - const jsonParams = { - requestId: requestId, - toJSON: () => { - return { - requestId: requestId, - }; - }, - }; + const jsonParams = {}; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } protected getApiTypeFromLeave(): string { @@ -78,29 +68,27 @@ export class IStreamChannelImpl implements IStreamChannel { return 'StreamChannel_getChannelName'; } - joinTopic( - topic: string, - options: JoinTopicOptions, - requestId?: number - ): number { - const apiType = this.getApiTypeFromJoinTopic(); + joinTopic(topic: string, options: JoinTopicOptions): number { + const apiType = this.getApiTypeFromJoinTopic(topic, options); const jsonParams = { topic: topic, options: options, - requestId: requestId, toJSON: () => { return { topic: topic, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromJoinTopic(): string { + protected getApiTypeFromJoinTopic( + topic: string, + options: JoinTopicOptions + ): string { return 'StreamChannel_joinTopic'; } @@ -110,7 +98,12 @@ export class IStreamChannelImpl implements IStreamChannel { length: number, option: PublishOptions ): number { - const apiType = this.getApiTypeFromPublishTopicMessage(); + const apiType = this.getApiTypeFromPublishTopicMessage( + topic, + message, + length, + option + ); const jsonParams = { topic: topic, message: message, @@ -129,58 +122,60 @@ export class IStreamChannelImpl implements IStreamChannel { return jsonResults.result; } - protected getApiTypeFromPublishTopicMessage(): string { + protected getApiTypeFromPublishTopicMessage( + topic: string, + message: string, + length: number, + option: PublishOptions + ): string { return 'StreamChannel_publishTopicMessage'; } - leaveTopic(topic: string, requestId?: number): number { - const apiType = this.getApiTypeFromLeaveTopic(); + leaveTopic(topic: string): number { + const apiType = this.getApiTypeFromLeaveTopic(topic); const jsonParams = { topic: topic, - requestId: requestId, toJSON: () => { return { topic: topic, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.requestId; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromLeaveTopic(): string { + protected getApiTypeFromLeaveTopic(topic: string): string { return 'StreamChannel_leaveTopic'; } - subscribeTopic( - topic: string, - options?: TopicOptions, - requestId?: number - ): number { - const apiType = this.getApiTypeFromSubscribeTopic(); + subscribeTopic(topic: string, options: TopicOptions): number { + const apiType = this.getApiTypeFromSubscribeTopic(topic, options); const jsonParams = { topic: topic, options: options, - requestId: requestId, toJSON: () => { return { topic: topic, options: options, - requestId: requestId, }; }, }; const jsonResults = callIrisApi.call(this, apiType, jsonParams); - return jsonResults.result; + const requestId = jsonResults.requestId; + return requestId; } - protected getApiTypeFromSubscribeTopic(): string { + protected getApiTypeFromSubscribeTopic( + topic: string, + options: TopicOptions + ): string { return 'StreamChannel_subscribeTopic'; } - unsubscribeTopic(topic: string, options?: TopicOptions): number { - const apiType = this.getApiTypeFromUnsubscribeTopic(); + unsubscribeTopic(topic: string, options: TopicOptions): number { + const apiType = this.getApiTypeFromUnsubscribeTopic(topic, options); const jsonParams = { topic: topic, options: options, @@ -195,19 +190,20 @@ export class IStreamChannelImpl implements IStreamChannel { return jsonResults.result; } - protected getApiTypeFromUnsubscribeTopic(): string { + protected getApiTypeFromUnsubscribeTopic( + topic: string, + options: TopicOptions + ): string { return 'StreamChannel_unsubscribeTopic'; } - getSubscribedUserList(topic: string, users: UserList[]): number { - const apiType = this.getApiTypeFromGetSubscribedUserList(); + getSubscribedUserList(topic: string): UserList[] { + const apiType = this.getApiTypeFromGetSubscribedUserList(topic); const jsonParams = { topic: topic, - users: users, toJSON: () => { return { topic: topic, - users: users, }; }, }; @@ -215,7 +211,7 @@ export class IStreamChannelImpl implements IStreamChannel { return jsonResults.result; } - protected getApiTypeFromGetSubscribedUserList(): string { + protected getApiTypeFromGetSubscribedUserList(topic: string): string { return 'StreamChannel_getSubscribedUserList'; } @@ -236,7 +232,12 @@ export class IStreamChannelImpl implements IStreamChannel { length: number, option: PublishOptions ): number { - const apiType = this.getApiTypeFromPublishTopicMessageWithBuffer(); + const apiType = this.getApiTypeFromPublishTopicMessageWithBuffer( + topic, + message, + length, + option + ); const jsonParams = { topic: topic, message: message, @@ -245,7 +246,6 @@ export class IStreamChannelImpl implements IStreamChannel { toJSON: () => { return { topic: topic, - message: message, length: length, option: option, }; @@ -255,7 +255,14 @@ export class IStreamChannelImpl implements IStreamChannel { return jsonResults.result; } - protected getApiTypeFromPublishTopicMessageWithBuffer(): string { + protected getApiTypeFromPublishTopicMessageWithBuffer( + topic: string, + message: Uint8Array, + length: number, + option: PublishOptions + ): string { return 'StreamChannel_publishTopicMessageWithBuffer'; } } + +import { callIrisApi } from '../internal/IrisRtmEngine';