UNPKG

youzanyun-devtool-worker

Version:

102 lines (101 loc) 4.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const spring4js_nodejs_1 = require("spring4js-nodejs"); let CustomApiService = class CustomApiService { constructor() { } async start() { } async checkUserAuth(params) { const resData = await this.requestService.get('https://diy.youzanyun.com/api/custom/devtool/app/auth', { params, }, { projectName: params.appName }); return resData; } async saveCustomContent(data) { const projectName = data.appName; const request = JSON.stringify(data); const result = await this.requestService.dubboCallWithAuthV2("com.youzan.baymax.api.FrontPagePushRecordService", "saveFrontPagePushRecord", [request], { projectName, }); if (+result.code === 0 || +result.code === 200) { return result.data || {}; } else { throw new Error('网络错误'); } } async saveCustomContentAndCreateImpl(data) { let resData = await this.requestService.post('https://diy.youzanyun.com/api/custom/devtool/pc/save-create-impl', data, {}, { projectName: data.appName }); if (+resData.code !== 200 && +resData.code !== 0) { throw new Error(resData.message); } return resData.data; } async getRemoteToolConfig() { let resData = await this.requestService.get('https://diy.youzanyun.com/api/mall-cloud/dev-tool/config/get', {}); if (+resData.code !== 200 && +resData.code !== 0) { throw new Error(resData.message); } return resData.data; } async getRemoteWscTemplateConfig() { let resData = await this.requestService.get('https://diy.youzanyun.com/api/mall-cloud/dev-tool/config/wscMpTplInfo', {}); if (+resData.code !== 200 && +resData.code !== 0) { throw new Error(resData.message); } return resData.data; } async getRemoteRetailTemplateConfig() { let resData = await this.requestService.get('https://diy.youzanyun.com/api/mall-cloud/dev-tool/config/retailMpTplInfo', {}); if (+resData.code !== 200 && +resData.code !== 0) { throw new Error(resData.message); } return resData.data; } async getExtImplAndRule(projectId, branchTag) { const { appId } = await this.projectService.getCompletedProjectById(projectId); let res = await this.requestService.dubboCallWithAuthV2("com.youzan.cloud.darwin.api.service.local.LocalExtRuleService", "queryExtImplAndRuleByAppId", [appId, branchTag], { projectId }); if (+res.code !== 200 && +res.code !== 0) { throw new Error(res.message); } return res; } async findByAppName(projectId) { const { appName } = await this.projectService.getCompletedProjectById(projectId); let res = await this.requestService.dubboCallWithAuthV2("com.youzan.baymax.api.ImplementedPageService", "findByAppName", [appName, 'dev'], { projectName: appName }); if (+res.code !== 200 && +res.code !== 0) { throw new Error(res.message); } return res.data || []; } async getBrandIsvAppIdWhiteList() { let brandIsvAppId = []; try { const remoteToolConfig = await this.getRemoteToolConfig(); if (remoteToolConfig.templateVersion) { const { brandIsvAppId: isvAppId } = JSON.parse(remoteToolConfig.templateVersion); brandIsvAppId = (isvAppId || '').split(','); } } catch (error) { console.log(error); } return brandIsvAppId; } }; tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], CustomApiService.prototype, "requestService", void 0); tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], CustomApiService.prototype, "projectService", void 0); CustomApiService = tslib_1.__decorate([ (0, spring4js_nodejs_1.Service)() ], CustomApiService); exports.default = CustomApiService;