UNPKG

@foxpage/foxpage-manager

Version:

foxpage resource manager

54 lines (53 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MockManagerImpl = void 0; const data_service_1 = require("../data-service"); /** * mock manager * * @export * @class MockManager */ class MockManagerImpl { constructor(app) { this.appId = app.appId; } /** * get mock from local first, not exist will fetch from server * * @param {string} mockId * @return {*} {(Promise<Mock | undefined>)} */ async getMock(mockId) { const result = (await this.getMocks([mockId]))[0]; return result === null || result === void 0 ? void 0 : result.content; } /** * get mocks * * @param {string[]} mockIds * @return {*} {Promise<Mock[]>} */ async getMocks(mockIds) { return await data_service_1.foxpageDataService.fetchMocks(this.appId, { mockIds }); } /** * get mock from local first, not exist will fetch from server * * @param {string} mockId * @return {*} {(Promise<Mock | undefined>)} */ async getDraftMock(mockId) { const result = (await this.getDraftMocks([mockId]))[0]; return result === null || result === void 0 ? void 0 : result.content; } /** * get draft mocks * @param mockIds * @returns */ async getDraftMocks(mockIds) { return await data_service_1.foxpageDataService.fetchDraftMocks(this.appId, { mockIds }); } } exports.MockManagerImpl = MockManagerImpl;