mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: rename services
This commit is contained in:
parent
cf70da71c9
commit
bf1223e07d
@ -3,7 +3,7 @@ import Controller from '../controller';
|
|||||||
import { IUnleashConfig } from '../../types/option';
|
import { IUnleashConfig } from '../../types/option';
|
||||||
import { IUnleashServices } from '../../types/services';
|
import { IUnleashServices } from '../../types/services';
|
||||||
import { Logger } from '../../logger';
|
import { Logger } from '../../logger';
|
||||||
import ClientMetricsServiceV2 from '../../services/client-metrics/client-metrics-service-v2';
|
import ClientMetricsServiceV2 from '../../services/client-metrics/metrics-service-v2';
|
||||||
|
|
||||||
class ClientMetricsController extends Controller {
|
class ClientMetricsController extends Controller {
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
|
@ -4,7 +4,7 @@ import { UPDATE_APPLICATION } from '../../types/permissions';
|
|||||||
import { IUnleashConfig } from '../../types/option';
|
import { IUnleashConfig } from '../../types/option';
|
||||||
import { IUnleashServices } from '../../types/services';
|
import { IUnleashServices } from '../../types/services';
|
||||||
import { Logger } from '../../logger';
|
import { Logger } from '../../logger';
|
||||||
import ClientInstanceService from '../../services/client-metrics/client-instance-service';
|
import ClientInstanceService from '../../services/client-metrics/instance-service';
|
||||||
|
|
||||||
class MetricsController extends Controller {
|
class MetricsController extends Controller {
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
|
@ -2,7 +2,7 @@ import supertest from 'supertest';
|
|||||||
import createStores from '../../../test/fixtures/store';
|
import createStores from '../../../test/fixtures/store';
|
||||||
import getApp from '../../app';
|
import getApp from '../../app';
|
||||||
import { createTestConfig } from '../../../test/config/test-config';
|
import { createTestConfig } from '../../../test/config/test-config';
|
||||||
import { clientMetricsSchema } from '../../services/client-metrics/client-metrics-schema';
|
import { clientMetricsSchema } from '../../services/client-metrics/schema';
|
||||||
import { createServices } from '../../services';
|
import { createServices } from '../../services';
|
||||||
import { IUnleashStores } from '../../types';
|
import { IUnleashStores } from '../../types';
|
||||||
import { IUnleashOptions } from '../../server-impl';
|
import { IUnleashOptions } from '../../server-impl';
|
||||||
|
@ -2,12 +2,12 @@ import { Response } from 'express';
|
|||||||
import Controller from '../controller';
|
import Controller from '../controller';
|
||||||
import { IUnleashServices } from '../../types';
|
import { IUnleashServices } from '../../types';
|
||||||
import { IUnleashConfig } from '../../types/option';
|
import { IUnleashConfig } from '../../types/option';
|
||||||
import ClientInstanceService from '../../services/client-metrics/client-instance-service';
|
import ClientInstanceService from '../../services/client-metrics/instance-service';
|
||||||
import { Logger } from '../../logger';
|
import { Logger } from '../../logger';
|
||||||
import { IAuthRequest } from '../unleash-types';
|
import { IAuthRequest } from '../unleash-types';
|
||||||
import ApiUser from '../../types/api-user';
|
import ApiUser from '../../types/api-user';
|
||||||
import { ALL } from '../../types/models/api-token';
|
import { ALL } from '../../types/models/api-token';
|
||||||
import ClientMetricsServiceV2 from '../../services/client-metrics/client-metrics-service-v2';
|
import ClientMetricsServiceV2 from '../../services/client-metrics/metrics-service-v2';
|
||||||
import { User } from '../../server-impl';
|
import { User } from '../../server-impl';
|
||||||
import { IClientApp } from '../../types/model';
|
import { IClientApp } from '../../types/model';
|
||||||
import { NONE } from '../../types/permissions';
|
import { NONE } from '../../types/permissions';
|
||||||
|
@ -3,7 +3,7 @@ import Controller from '../controller';
|
|||||||
import { IUnleashServices } from '../../types';
|
import { IUnleashServices } from '../../types';
|
||||||
import { IUnleashConfig } from '../../types/option';
|
import { IUnleashConfig } from '../../types/option';
|
||||||
import { Logger } from '../../logger';
|
import { Logger } from '../../logger';
|
||||||
import ClientInstanceService from '../../services/client-metrics/client-instance-service';
|
import ClientInstanceService from '../../services/client-metrics/instance-service';
|
||||||
import { IAuthRequest, User } from '../../server-impl';
|
import { IAuthRequest, User } from '../../server-impl';
|
||||||
import { IClientApp } from '../../types/model';
|
import { IClientApp } from '../../types/model';
|
||||||
import ApiUser from '../../types/api-user';
|
import ApiUser from '../../types/api-user';
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import joi from 'joi';
|
|
||||||
|
|
||||||
const countSchema = joi
|
|
||||||
.object()
|
|
||||||
.options({ stripUnknown: true })
|
|
||||||
.keys({
|
|
||||||
yes: joi.number().min(0).empty('').default(0),
|
|
||||||
no: joi.number().min(0).empty('').default(0),
|
|
||||||
variants: joi.object().pattern(joi.string(), joi.number().min(0)),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const clientMetricsSchema = joi
|
|
||||||
.object()
|
|
||||||
.options({ stripUnknown: true })
|
|
||||||
.keys({
|
|
||||||
environment: joi.string().optional(),
|
|
||||||
appName: joi.string().required(),
|
|
||||||
instanceId: joi.string().required(),
|
|
||||||
bucket: joi
|
|
||||||
.object()
|
|
||||||
.required()
|
|
||||||
.keys({
|
|
||||||
start: joi.date().required(),
|
|
||||||
stop: joi.date().required(),
|
|
||||||
toggles: joi.object().pattern(/.*/, countSchema),
|
|
||||||
}),
|
|
||||||
});
|
|
@ -1,4 +1,4 @@
|
|||||||
import ClientInstanceService from './client-instance-service';
|
import ClientInstanceService from './instance-service';
|
||||||
import getLogger from '../../../test/fixtures/no-logger';
|
import getLogger from '../../../test/fixtures/no-logger';
|
||||||
import { IClientApp } from '../../types/model';
|
import { IClientApp } from '../../types/model';
|
||||||
import { secondsToMilliseconds } from 'date-fns';
|
import { secondsToMilliseconds } from 'date-fns';
|
@ -1,4 +1,4 @@
|
|||||||
import { applicationSchema } from './metrics-schema';
|
import { applicationSchema } from './schema';
|
||||||
import { APPLICATION_CREATED } from '../../types/events';
|
import { APPLICATION_CREATED } from '../../types/events';
|
||||||
import { IApplication } from './models';
|
import { IApplication } from './models';
|
||||||
import { IUnleashStores } from '../../types/stores';
|
import { IUnleashStores } from '../../types/stores';
|
||||||
@ -13,11 +13,11 @@ import { IStrategyStore } from '../../types/stores/strategy-store';
|
|||||||
import { IClientInstanceStore } from '../../types/stores/client-instance-store';
|
import { IClientInstanceStore } from '../../types/stores/client-instance-store';
|
||||||
import { IApplicationQuery } from '../../types/query';
|
import { IApplicationQuery } from '../../types/query';
|
||||||
import { IClientApp } from '../../types/model';
|
import { IClientApp } from '../../types/model';
|
||||||
import { clientRegisterSchema } from './register-schema';
|
import { clientRegisterSchema } from './schema';
|
||||||
|
|
||||||
import { minutesToMilliseconds, secondsToMilliseconds } from 'date-fns';
|
import { minutesToMilliseconds, secondsToMilliseconds } from 'date-fns';
|
||||||
import { IClientMetricsStoreV2 } from '../../types/stores/client-metrics-store-v2';
|
import { IClientMetricsStoreV2 } from '../../types/stores/client-metrics-store-v2';
|
||||||
import { clientMetricsSchema } from './client-metrics-schema';
|
import { clientMetricsSchema } from './schema';
|
||||||
|
|
||||||
export default class ClientInstanceService {
|
export default class ClientInstanceService {
|
||||||
apps = {};
|
apps = {};
|
@ -1,18 +0,0 @@
|
|||||||
import joi from 'joi';
|
|
||||||
|
|
||||||
export const applicationSchema = joi
|
|
||||||
.object()
|
|
||||||
.options({ stripUnknown: false })
|
|
||||||
.keys({
|
|
||||||
appName: joi.string().required(),
|
|
||||||
sdkVersion: joi.string().optional(),
|
|
||||||
strategies: joi
|
|
||||||
.array()
|
|
||||||
.optional()
|
|
||||||
.items(joi.string(), joi.any().strip()),
|
|
||||||
description: joi.string().allow('').optional(),
|
|
||||||
url: joi.string().allow('').optional(),
|
|
||||||
color: joi.string().allow('').optional(),
|
|
||||||
icon: joi.string().allow('').optional(),
|
|
||||||
announced: joi.boolean().optional().default(false),
|
|
||||||
});
|
|
@ -7,7 +7,7 @@ import {
|
|||||||
IClientMetricsEnv,
|
IClientMetricsEnv,
|
||||||
IClientMetricsStoreV2,
|
IClientMetricsStoreV2,
|
||||||
} from '../../types/stores/client-metrics-store-v2';
|
} from '../../types/stores/client-metrics-store-v2';
|
||||||
import { clientMetricsSchema } from './client-metrics-schema';
|
import { clientMetricsSchema } from './schema';
|
||||||
import { hoursToMilliseconds, minutesToMilliseconds } from 'date-fns';
|
import { hoursToMilliseconds, minutesToMilliseconds } from 'date-fns';
|
||||||
import { IFeatureToggleStore } from '../../types/stores/feature-toggle-store';
|
import { IFeatureToggleStore } from '../../types/stores/feature-toggle-store';
|
||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
@ -1,17 +0,0 @@
|
|||||||
import joi from 'joi';
|
|
||||||
|
|
||||||
export const clientRegisterSchema = joi
|
|
||||||
.object()
|
|
||||||
.options({ stripUnknown: true })
|
|
||||||
.keys({
|
|
||||||
appName: joi.string().required(),
|
|
||||||
instanceId: joi.string().required(),
|
|
||||||
sdkVersion: joi.string().optional(),
|
|
||||||
strategies: joi
|
|
||||||
.array()
|
|
||||||
.required()
|
|
||||||
.items(joi.string(), joi.any().strip()),
|
|
||||||
started: joi.date().required(),
|
|
||||||
interval: joi.number().required(),
|
|
||||||
environment: joi.string().optional(),
|
|
||||||
});
|
|
60
src/lib/services/client-metrics/schema.ts
Normal file
60
src/lib/services/client-metrics/schema.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import joi from 'joi';
|
||||||
|
|
||||||
|
const countSchema = joi
|
||||||
|
.object()
|
||||||
|
.options({ stripUnknown: true })
|
||||||
|
.keys({
|
||||||
|
yes: joi.number().min(0).empty('').default(0),
|
||||||
|
no: joi.number().min(0).empty('').default(0),
|
||||||
|
variants: joi.object().pattern(joi.string(), joi.number().min(0)),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const clientMetricsSchema = joi
|
||||||
|
.object()
|
||||||
|
.options({ stripUnknown: true })
|
||||||
|
.keys({
|
||||||
|
environment: joi.string().optional(),
|
||||||
|
appName: joi.string().required(),
|
||||||
|
instanceId: joi.string().required(),
|
||||||
|
bucket: joi
|
||||||
|
.object()
|
||||||
|
.required()
|
||||||
|
.keys({
|
||||||
|
start: joi.date().required(),
|
||||||
|
stop: joi.date().required(),
|
||||||
|
toggles: joi.object().pattern(/.*/, countSchema),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const applicationSchema = joi
|
||||||
|
.object()
|
||||||
|
.options({ stripUnknown: false })
|
||||||
|
.keys({
|
||||||
|
appName: joi.string().required(),
|
||||||
|
sdkVersion: joi.string().optional(),
|
||||||
|
strategies: joi
|
||||||
|
.array()
|
||||||
|
.optional()
|
||||||
|
.items(joi.string(), joi.any().strip()),
|
||||||
|
description: joi.string().allow('').optional(),
|
||||||
|
url: joi.string().allow('').optional(),
|
||||||
|
color: joi.string().allow('').optional(),
|
||||||
|
icon: joi.string().allow('').optional(),
|
||||||
|
announced: joi.boolean().optional().default(false),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const clientRegisterSchema = joi
|
||||||
|
.object()
|
||||||
|
.options({ stripUnknown: true })
|
||||||
|
.keys({
|
||||||
|
appName: joi.string().required(),
|
||||||
|
instanceId: joi.string().required(),
|
||||||
|
sdkVersion: joi.string().optional(),
|
||||||
|
strategies: joi
|
||||||
|
.array()
|
||||||
|
.required()
|
||||||
|
.items(joi.string(), joi.any().strip()),
|
||||||
|
started: joi.date().required(),
|
||||||
|
interval: joi.number().required(),
|
||||||
|
environment: joi.string().optional(),
|
||||||
|
});
|
@ -7,8 +7,8 @@ import HealthService from './health-service';
|
|||||||
|
|
||||||
import ProjectService from './project-service';
|
import ProjectService from './project-service';
|
||||||
import StateService from './state-service';
|
import StateService from './state-service';
|
||||||
import ClientInstanceService from './client-metrics/client-instance-service';
|
import ClientInstanceService from './client-metrics/instance-service';
|
||||||
import ClientMetricsServiceV2 from './client-metrics/client-metrics-service-v2';
|
import ClientMetricsServiceV2 from './client-metrics/metrics-service-v2';
|
||||||
import TagTypeService from './tag-type-service';
|
import TagTypeService from './tag-type-service';
|
||||||
import TagService from './tag-service';
|
import TagService from './tag-service';
|
||||||
import StrategyService from './strategy-service';
|
import StrategyService from './strategy-service';
|
||||||
|
@ -5,7 +5,7 @@ import StateService from '../services/state-service';
|
|||||||
import StrategyService from '../services/strategy-service';
|
import StrategyService from '../services/strategy-service';
|
||||||
import TagTypeService from '../services/tag-type-service';
|
import TagTypeService from '../services/tag-type-service';
|
||||||
import TagService from '../services/tag-service';
|
import TagService from '../services/tag-service';
|
||||||
import ClientInstanceService from '../services/client-metrics/client-instance-service';
|
import ClientInstanceService from '../services/client-metrics/instance-service';
|
||||||
import ContextService from '../services/context-service';
|
import ContextService from '../services/context-service';
|
||||||
import VersionService from '../services/version-service';
|
import VersionService from '../services/version-service';
|
||||||
import { ApiTokenService } from '../services/api-token-service';
|
import { ApiTokenService } from '../services/api-token-service';
|
||||||
@ -22,7 +22,7 @@ import FeatureToggleService from '../services/feature-toggle-service';
|
|||||||
import EnvironmentService from '../services/environment-service';
|
import EnvironmentService from '../services/environment-service';
|
||||||
import FeatureTagService from '../services/feature-tag-service';
|
import FeatureTagService from '../services/feature-tag-service';
|
||||||
import ProjectHealthService from '../services/project-health-service';
|
import ProjectHealthService from '../services/project-health-service';
|
||||||
import ClientMetricsServiceV2 from '../services/client-metrics/client-metrics-service-v2';
|
import ClientMetricsServiceV2 from '../services/client-metrics/metrics-service-v2';
|
||||||
import UserSplashService from '../services/user-splash-service';
|
import UserSplashService from '../services/user-splash-service';
|
||||||
|
|
||||||
export interface IUnleashServices {
|
export interface IUnleashServices {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import ClientInstanceService from '../../../lib/services/client-metrics/client-instance-service';
|
import ClientInstanceService from '../../../lib/services/client-metrics/instance-service';
|
||||||
import { IClientApp } from '../../../lib/types/model';
|
import { IClientApp } from '../../../lib/types/model';
|
||||||
import { secondsToMilliseconds } from 'date-fns';
|
import { secondsToMilliseconds } from 'date-fns';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user