Refactor api-binder as a directory

The role of the api-binder module is to be the intermediary
between the cloud API and the device-state. For this reason it makes sense to
isolate target state retrieval and current state reporting into this
module. This change just moves current state reporting to the directory.
This commit is contained in:
Felipe Lalanne 2021-09-06 19:47:05 +00:00
parent 97f3b2a51e
commit 25e9ab4786
3 changed files with 16 additions and 19 deletions

View File

@ -6,34 +6,31 @@ import * as t from 'io-ts';
import * as _ from 'lodash';
import { PinejsClientRequest } from 'pinejs-client-request';
import * as url from 'url';
import * as deviceRegister from './lib/register-device';
import * as deviceRegister from '../lib/register-device';
import * as config from './config';
import * as deviceConfig from './device-config';
import * as eventTracker from './event-tracker';
import { loadBackupFromMigration } from './lib/migration';
import * as config from '../config';
import * as deviceConfig from '../device-config';
import * as eventTracker from '../event-tracker';
import { loadBackupFromMigration } from '../lib/migration';
import {
ContractValidationError,
ContractViolationError,
InternalInconsistencyError,
TargetStateError,
} from './lib/errors';
import * as request from './lib/request';
} from '../lib/errors';
import * as request from '../lib/request';
import log from './lib/supervisor-console';
import log from '../lib/supervisor-console';
import * as deviceState from './device-state';
import * as globalEventBus from './event-bus';
import * as TargetState from './device-state/target-state';
import * as logger from './logger';
import * as deviceState from '../device-state';
import * as globalEventBus from '../event-bus';
import * as TargetState from '../device-state/target-state';
import * as logger from '../logger';
import * as apiHelper from './lib/api-helper';
import { Device } from './lib/api-helper';
import {
startReporting,
stateReportErrors,
} from './device-state/current-state';
import * as apiHelper from '../lib/api-helper';
import { Device } from '../lib/api-helper';
import { startReporting, stateReportErrors } from './report';
interface DevicePinInfo {
app: number;

View File

@ -405,7 +405,7 @@ describe('ApiBinder', () => {
});
it('fails when stateReportHealthy is false', async () => {
const currentState = await import('../src/device-state/current-state');
const currentState = await import('../src/api-binder/report');
configStub.resolves({
unmanaged: false,