1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: drop full- for import/validate (#3168)

This commit is contained in:
Mateusz Kwasniewski 2023-02-21 10:15:57 +01:00 committed by GitHub
parent 4b21175c80
commit 3800877be1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 146 additions and 142 deletions

View File

@ -14,7 +14,7 @@ export const useImportApi = () => {
const { trackEvent } = usePlausibleTracker();
const createImport = async (payload: ImportQuerySchema) => {
const path = `api/admin/features-batch/full-import`;
const path = `api/admin/features-batch/import`;
const req = createRequest(path, {
method: 'POST',
body: JSON.stringify(payload),

View File

@ -19,7 +19,7 @@ export const useValidateImportApi = () => {
const validateImport = async (
payload: ImportQuerySchema
): Promise<IValidationSchema> => {
const path = `api/admin/features-batch/full-validate`;
const path = `api/admin/features-batch/validate`;
const req = createRequest(path, {
method: 'POST',
body: JSON.stringify(payload),

View File

@ -36,7 +36,7 @@ import { FavoriteProjectsStore } from './favorite-projects-store';
import { AccountStore } from './account-store';
import ProjectStatsStore from './project-stats-store';
import { Db } from './db';
import { ImportTogglesStore } from '../export-import-toggles/import-toggles-store';
import { ImportTogglesStore } from '../features/export-import-toggles/import-toggles-store';
export const createStores = (
config: IUnleashConfig,

View File

@ -1,17 +1,17 @@
import { Db, IUnleashConfig } from 'lib/server-impl';
import EventStore from '../db/event-store';
import GroupStore from '../db/group-store';
import { AccountStore } from '../db/account-store';
import RoleStore from '../db/role-store';
import EnvironmentStore from '../db/environment-store';
import { AccessStore } from '../db/access-store';
import { AccessService, GroupService } from '../services';
import FakeEventStore from '../../test/fixtures/fake-event-store';
import FakeGroupStore from '../../test/fixtures/fake-group-store';
import { FakeAccountStore } from '../../test/fixtures/fake-account-store';
import FakeRoleStore from '../../test/fixtures/fake-role-store';
import FakeEnvironmentStore from '../../test/fixtures/fake-environment-store';
import FakeAccessStore from '../../test/fixtures/fake-access-store';
import EventStore from '../../db/event-store';
import GroupStore from '../../db/group-store';
import { AccountStore } from '../../db/account-store';
import RoleStore from '../../db/role-store';
import EnvironmentStore from '../../db/environment-store';
import { AccessStore } from '../../db/access-store';
import { AccessService, GroupService } from '../../services';
import FakeGroupStore from '../../../test/fixtures/fake-group-store';
import FakeEventStore from '../../../test/fixtures/fake-event-store';
import { FakeAccountStore } from '../../../test/fixtures/fake-account-store';
import FakeRoleStore from '../../../test/fixtures/fake-role-store';
import FakeEnvironmentStore from '../../../test/fixtures/fake-environment-store';
import FakeAccessStore from '../../../test/fixtures/fake-access-store';
export const createAccessService = (
db: Db,

View File

@ -1,40 +1,43 @@
import { Db } from '../db/db';
import { IUnleashConfig } from '../types';
import { Db } from '../../db/db';
import { IUnleashConfig } from '../../types';
import ExportImportService from './export-import-service';
import { ImportTogglesStore } from './import-toggles-store';
import FeatureToggleStore from '../db/feature-toggle-store';
import TagStore from '../db/tag-store';
import TagTypeStore from '../db/tag-type-store';
import ProjectStore from '../db/project-store';
import FeatureTagStore from '../db/feature-tag-store';
import StrategyStore from '../db/strategy-store';
import ContextFieldStore from '../db/context-field-store';
import EventStore from '../db/event-store';
import FeatureStrategiesStore from '../db/feature-strategy-store';
import FeatureToggleStore from '../../db/feature-toggle-store';
import TagStore from '../../db/tag-store';
import TagTypeStore from '../../db/tag-type-store';
import ProjectStore from '../../db/project-store';
import FeatureTagStore from '../../db/feature-tag-store';
import StrategyStore from '../../db/strategy-store';
import ContextFieldStore from '../../db/context-field-store';
import EventStore from '../../db/event-store';
import FeatureStrategiesStore from '../../db/feature-strategy-store';
import {
ContextService,
FeatureTagService,
StrategyService,
TagTypeService,
} from '../services';
import { createAccessService, createFakeAccessService } from '../access';
} from '../../services';
import {
createAccessService,
createFakeAccessService,
} from '../access/createAccessService';
import {
createFakeFeatureToggleService,
createFeatureToggleService,
} from '../feature-toggle';
import SegmentStore from '../db/segment-store';
import { FeatureEnvironmentStore } from '../db/feature-environment-store';
import FakeFeatureToggleStore from '../../test/fixtures/fake-feature-toggle-store';
import FakeTagStore from '../../test/fixtures/fake-tag-store';
import FakeTagTypeStore from '../../test/fixtures/fake-tag-type-store';
import FakeSegmentStore from '../../test/fixtures/fake-segment-store';
import FakeProjectStore from '../../test/fixtures/fake-project-store';
import FakeFeatureTagStore from '../../test/fixtures/fake-feature-tag-store';
import FakeContextFieldStore from '../../test/fixtures/fake-context-field-store';
import FakeEventStore from '../../test/fixtures/fake-event-store';
import FakeFeatureStrategiesStore from '../../test/fixtures/fake-feature-strategies-store';
import FakeFeatureEnvironmentStore from '../../test/fixtures/fake-feature-environment-store';
import FakeStrategiesStore from '../../test/fixtures/fake-strategies-store';
} from '../feature-toggle/createFeatureToggleService';
import SegmentStore from '../../db/segment-store';
import { FeatureEnvironmentStore } from '../../db/feature-environment-store';
import FakeFeatureToggleStore from '../../../test/fixtures/fake-feature-toggle-store';
import FakeTagStore from '../../../test/fixtures/fake-tag-store';
import FakeTagTypeStore from '../../../test/fixtures/fake-tag-type-store';
import FakeSegmentStore from '../../../test/fixtures/fake-segment-store';
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
import FakeContextFieldStore from '../../../test/fixtures/fake-context-field-store';
import FakeEventStore from '../../../test/fixtures/fake-event-store';
import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store';
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
import FakeStrategiesStore from '../../../test/fixtures/fake-strategies-store';
export const createFakeExportImportTogglesService = (
config: IUnleashConfig,

View File

@ -1,16 +1,16 @@
import { Response } from 'express';
import { Knex } from 'knex';
import Controller from '../routes/controller';
import { Logger } from '../logger';
import Controller from '../../routes/controller';
import { Logger } from '../../logger';
import ExportImportService from './export-import-service';
import { OpenApiService } from '../services';
import { TransactionCreator, UnleashTransaction } from '../db/transaction';
import { OpenApiService } from '../../services';
import { TransactionCreator, UnleashTransaction } from '../../db/transaction';
import {
IUnleashConfig,
IUnleashServices,
NONE,
serializeDates,
} from '../types';
} from '../../types';
import {
createRequestSchema,
createResponseSchema,
@ -19,10 +19,10 @@ import {
exportResultSchema,
ImportTogglesSchema,
importTogglesValidateSchema,
} from '../openapi';
import { IAuthRequest } from '../routes/unleash-types';
import { extractUsername } from '../util';
import { InvalidOperationError } from '../error';
} from '../../openapi';
import { IAuthRequest } from '../../routes/unleash-types';
import { extractUsername } from '../../util';
import { InvalidOperationError } from '../../error';
class ExportImportController extends Controller {
private logger: Logger;
@ -76,7 +76,7 @@ class ExportImportController extends Controller {
});
this.route({
method: 'post',
path: '/full-validate',
path: '/validate',
permission: NONE,
handler: this.validateImport,
middleware: [
@ -97,7 +97,7 @@ class ExportImportController extends Controller {
});
this.route({
method: 'post',
path: '/full-import',
path: '/import',
permission: NONE,
handler: this.importData,
middleware: [

View File

@ -1,9 +1,9 @@
import {
IUnleashTest,
setupAppWithAuth,
} from '../../test/e2e/helpers/test-helper';
import dbInit, { ITestDb } from '../../test/e2e/helpers/database-init';
import getLogger from '../../test/fixtures/no-logger';
} from '../../../test/e2e/helpers/test-helper';
import dbInit, { ITestDb } from '../../../test/e2e/helpers/database-init';
import getLogger from '../../../test/fixtures/no-logger';
import {
DEFAULT_PROJECT,
IContextFieldStore,
@ -13,11 +13,11 @@ import {
IProjectStore,
IUnleashStores,
RoleName,
} from '../types';
import { ImportTogglesSchema, VariantsSchema } from '../openapi';
import { IContextFieldDto } from '../types/stores/context-field-store';
import { AccessService } from '../services';
import { DEFAULT_ENV } from '../util';
} from '../../types';
import { ImportTogglesSchema, VariantsSchema } from '../../openapi';
import { IContextFieldDto } from '../../types/stores/context-field-store';
import { AccessService } from '../../services';
import { DEFAULT_ENV } from '../../util';
let app: IUnleashTest;
let db: ITestDb;
@ -35,7 +35,7 @@ const adminUserName = 'admin-user';
const validateImport = (importPayload: ImportTogglesSchema, status = 200) =>
app.request
.post('/api/admin/features-batch/full-validate')
.post('/api/admin/features-batch/validate')
.send(importPayload)
.set('Content-Type', 'application/json')
.expect(status);

View File

@ -1,37 +1,37 @@
import { IUnleashConfig } from '../types/option';
import { IUnleashConfig } from '../../types/option';
import {
FeatureToggleDTO,
IFeatureStrategy,
IFeatureStrategySegment,
IVariant,
} from '../types/model';
import { Logger } from '../logger';
import { IFeatureTagStore } from '../types/stores/feature-tag-store';
import { ITagTypeStore } from '../types/stores/tag-type-store';
import { IEventStore } from '../types/stores/event-store';
import { IStrategy } from '../types/stores/strategy-store';
import { IFeatureToggleStore } from '../types/stores/feature-toggle-store';
import { IFeatureStrategiesStore } from '../types/stores/feature-strategies-store';
import { IFeatureEnvironmentStore } from '../types/stores/feature-environment-store';
import { IContextFieldStore, IUnleashStores } from '../types/stores';
import { ISegmentStore } from '../types/stores/segment-store';
import { ExportQuerySchema } from '../openapi/spec/export-query-schema';
} from '../../types/model';
import { Logger } from '../../logger';
import { IFeatureTagStore } from '../../types/stores/feature-tag-store';
import { ITagTypeStore } from '../../types/stores/tag-type-store';
import { IEventStore } from '../../types/stores/event-store';
import { IStrategy } from '../../types/stores/strategy-store';
import { IFeatureToggleStore } from '../../types/stores/feature-toggle-store';
import { IFeatureStrategiesStore } from '../../types/stores/feature-strategies-store';
import { IFeatureEnvironmentStore } from '../../types/stores/feature-environment-store';
import { IContextFieldStore, IUnleashStores } from '../../types/stores';
import { ISegmentStore } from '../../types/stores/segment-store';
import { ExportQuerySchema } from '../../openapi/spec/export-query-schema';
import {
FEATURES_EXPORTED,
FEATURES_IMPORTED,
IFlagResolver,
IUnleashServices,
WithRequired,
} from '../types';
} from '../../types';
import {
ExportResultSchema,
FeatureStrategySchema,
ImportTogglesValidateSchema,
} from '../openapi';
import { ImportTogglesSchema } from '../openapi/spec/import-toggles-schema';
import User from '../types/user';
import { BadDataError } from '../error';
import { extractUsernameFromUser } from '../util';
} from '../../openapi';
import { ImportTogglesSchema } from '../../openapi/spec/import-toggles-schema';
import User from '../../types/user';
import { BadDataError } from '../../error';
import { extractUsernameFromUser } from '../../util';
import {
AccessService,
ContextService,
@ -39,7 +39,7 @@ import {
FeatureToggleService,
StrategyService,
TagTypeService,
} from '../services';
} from '../../services';
import { isValidField } from './import-context-validation';
import { IImportTogglesStore } from './import-toggles-store-type';
import { ImportPermissionsService } from './import-permissions-service';

View File

@ -1,9 +1,9 @@
import {
IUnleashTest,
setupAppWithCustomConfig,
} from '../../test/e2e/helpers/test-helper';
import dbInit, { ITestDb } from '../../test/e2e/helpers/database-init';
import getLogger from '../../test/fixtures/no-logger';
} from '../../../test/e2e/helpers/test-helper';
import dbInit, { ITestDb } from '../../../test/e2e/helpers/database-init';
import getLogger from '../../../test/fixtures/no-logger';
import {
DEFAULT_PROJECT,
FeatureToggleDTO,
@ -15,15 +15,15 @@ import {
ISegment,
IStrategyConfig,
IVariant,
} from '../types';
import { DEFAULT_ENV } from '../util';
} from '../../types';
import { DEFAULT_ENV } from '../../util';
import {
ContextFieldSchema,
ImportTogglesSchema,
VariantsSchema,
} from '../openapi';
import User from '../types/user';
import { IContextFieldDto } from '../types/stores/context-field-store';
} from '../../openapi';
import User from '../../types/user';
import { IContextFieldDto } from '../../types/stores/context-field-store';
let app: IUnleashTest;
let db: ITestDb;
@ -422,7 +422,7 @@ const importToggles = (
expect: (response) => void = () => {},
) =>
app.request
.post('/api/admin/features-batch/full-import')
.post('/api/admin/features-batch/import')
.send(importPayload)
.set('Content-Type', 'application/json')
.expect(status)
@ -543,7 +543,7 @@ const getTags = (feature: string) =>
const validateImport = (importPayload: ImportTogglesSchema, status = 200) =>
app.request
.post('/api/admin/features-batch/full-validate')
.post('/api/admin/features-batch/validate')
.send(importPayload)
.set('Content-Type', 'application/json')
.expect(status);

View File

@ -1,4 +1,4 @@
import { IContextFieldDto } from '../types/stores/context-field-store';
import { IContextFieldDto } from '../../types/stores/context-field-store';
export const isValidField = (
importedField: IContextFieldDto,

View File

@ -1,8 +1,8 @@
import { IImportTogglesStore } from './import-toggles-store-type';
import { AccessService, ContextService, TagTypeService } from '../services';
import { ContextFieldSchema, ImportTogglesSchema } from '../openapi';
import { ITagType } from '../types/stores/tag-type-store';
import User from '../types/user';
import { AccessService, ContextService, TagTypeService } from '../../services';
import { ContextFieldSchema, ImportTogglesSchema } from '../../openapi';
import { ITagType } from '../../types/stores/tag-type-store';
import User from '../../types/user';
import {
CREATE_CONTEXT_FIELD,
CREATE_FEATURE,
@ -11,8 +11,8 @@ import {
UPDATE_FEATURE,
UPDATE_FEATURE_ENVIRONMENT_VARIANTS,
UPDATE_TAG_TYPE,
} from '../types';
import { InvalidOperationError } from '../error';
} from '../../types';
import { InvalidOperationError } from '../../error';
type Mode = 'regular' | 'change_request';

View File

@ -1,8 +1,8 @@
import {
FeatureStrategySchema,
ImportTogglesValidateItemSchema,
} from '../openapi';
import { IContextFieldDto } from '../types/stores/context-field-store';
} from '../../openapi';
import { IContextFieldDto } from '../../types/stores/context-field-store';
export class ImportValidationMessages {
static compilePermissionErrors(

View File

@ -3,37 +3,37 @@ import {
FeatureToggleService,
GroupService,
SegmentService,
} from '../services';
import EventStore from '../db/event-store';
import FeatureStrategiesStore from '../db/feature-strategy-store';
import FeatureToggleStore from '../db/feature-toggle-store';
import FeatureToggleClientStore from '../db/feature-toggle-client-store';
import ProjectStore from '../db/project-store';
import FeatureTagStore from '../db/feature-tag-store';
import { FeatureEnvironmentStore } from '../db/feature-environment-store';
import SegmentStore from '../db/segment-store';
import ContextFieldStore from '../db/context-field-store';
import GroupStore from '../db/group-store';
import { AccountStore } from '../db/account-store';
import { AccessStore } from '../db/access-store';
import RoleStore from '../db/role-store';
import EnvironmentStore from '../db/environment-store';
import { Db } from '../db/db';
import { IUnleashConfig } from '../types';
import FakeEventStore from '../../test/fixtures/fake-event-store';
import FakeFeatureStrategiesStore from '../../test/fixtures/fake-feature-strategies-store';
import FakeFeatureToggleStore from '../../test/fixtures/fake-feature-toggle-store';
import FakeFeatureToggleClientStore from '../../test/fixtures/fake-feature-toggle-client-store';
import FakeProjectStore from '../../test/fixtures/fake-project-store';
import FakeFeatureTagStore from '../../test/fixtures/fake-feature-tag-store';
import FakeFeatureEnvironmentStore from '../../test/fixtures/fake-feature-environment-store';
import FakeSegmentStore from '../../test/fixtures/fake-segment-store';
import FakeContextFieldStore from '../../test/fixtures/fake-context-field-store';
import FakeGroupStore from '../../test/fixtures/fake-group-store';
import { FakeAccountStore } from '../../test/fixtures/fake-account-store';
import FakeAccessStore from '../../test/fixtures/fake-access-store';
import FakeRoleStore from '../../test/fixtures/fake-role-store';
import FakeEnvironmentStore from '../../test/fixtures/fake-environment-store';
} from '../../services';
import EventStore from '../../db/event-store';
import FeatureStrategiesStore from '../../db/feature-strategy-store';
import FeatureToggleStore from '../../db/feature-toggle-store';
import FeatureToggleClientStore from '../../db/feature-toggle-client-store';
import ProjectStore from '../../db/project-store';
import FeatureTagStore from '../../db/feature-tag-store';
import { FeatureEnvironmentStore } from '../../db/feature-environment-store';
import SegmentStore from '../../db/segment-store';
import ContextFieldStore from '../../db/context-field-store';
import GroupStore from '../../db/group-store';
import { AccountStore } from '../../db/account-store';
import { AccessStore } from '../../db/access-store';
import RoleStore from '../../db/role-store';
import EnvironmentStore from '../../db/environment-store';
import { Db } from '../../db/db';
import { IUnleashConfig } from '../../types';
import FakeEventStore from '../../../test/fixtures/fake-event-store';
import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store';
import FakeFeatureToggleStore from '../../../test/fixtures/fake-feature-toggle-store';
import FakeFeatureToggleClientStore from '../../../test/fixtures/fake-feature-toggle-client-store';
import FakeProjectStore from '../../../test/fixtures/fake-project-store';
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store';
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store';
import FakeSegmentStore from '../../../test/fixtures/fake-segment-store';
import FakeContextFieldStore from '../../../test/fixtures/fake-context-field-store';
import FakeGroupStore from '../../../test/fixtures/fake-group-store';
import { FakeAccountStore } from '../../../test/fixtures/fake-account-store';
import FakeAccessStore from '../../../test/fixtures/fake-access-store';
import FakeRoleStore from '../../../test/fixtures/fake-role-store';
import FakeEnvironmentStore from '../../../test/fixtures/fake-environment-store';
export const createFeatureToggleService = (
db: Db,

View File

@ -0,0 +1,3 @@
export * from './access/createAccessService';
export * from './export-import-toggles/createExportImportService';
export * from './feature-toggle/createFeatureToggleService';

View File

@ -13,6 +13,4 @@ export * from './services';
export * from './types';
export * from './util';
export * from './error';
export * from './access';
export * from './export-import-toggles';
export * from './feature-toggle';
export * from './features';

View File

@ -30,7 +30,7 @@ import FavoritesController from './favorites';
import MaintenanceController from './maintenance';
import { createKnexTransactionStarter } from '../../db/transaction';
import { Db } from '../../db/db';
import ExportImportController from '../../export-import-toggles/export-import-controller';
import ExportImportController from '../../features/export-import-toggles/export-import-controller';
class AdminApi extends Controller {
constructor(config: IUnleashConfig, services: IUnleashServices, db: Db) {

View File

@ -46,7 +46,7 @@ import { Knex } from 'knex';
import {
createExportImportTogglesService,
createFakeExportImportTogglesService,
} from '../export-import-toggles';
} from '../features/export-import-toggles/createExportImportService';
import { Db } from '../db/db';
// TODO: will be moved to scheduler feature directory

View File

@ -37,10 +37,10 @@ import { LastSeenService } from '../services/client-metrics/last-seen-service';
import { InstanceStatsService } from '../services/instance-stats-service';
import { FavoritesService } from '../services/favorites-service';
import MaintenanceService from '../services/maintenance-service';
import ExportImportService from '../export-import-toggles/export-import-service';
import { AccountService } from '../services/account-service';
import { SchedulerService } from '../services/scheduler-service';
import { Knex } from 'knex';
import ExportImportService from '../features/export-import-toggles/export-import-service';
export interface IUnleashServices {
accessService: AccessService;

View File

@ -32,7 +32,7 @@ import { IFavoriteFeaturesStore } from './stores/favorite-features';
import { IFavoriteProjectsStore } from './stores/favorite-projects';
import { IAccountStore } from './stores/account-store';
import { IProjectStatsStore } from './stores/project-stats-store-type';
import { IImportTogglesStore } from '../export-import-toggles/import-toggles-store-type';
import { IImportTogglesStore } from '../features/export-import-toggles/import-toggles-store-type';
export interface IUnleashStores {
accessStore: IAccessStore;

View File

@ -5129,7 +5129,7 @@ If the provided project does not exist, the list of events will be empty.",
],
},
},
"/api/admin/features-batch/full-import": {
"/api/admin/features-batch/import": {
"post": {
"description": "Unleash toggles exported from a different instance can be imported into a new project and environment",
"operationId": "importToggles",
@ -5155,7 +5155,7 @@ If the provided project does not exist, the list of events will be empty.",
],
},
},
"/api/admin/features-batch/full-validate": {
"/api/admin/features-batch/validate": {
"post": {
"description": "Unleash toggles exported from a different instance can be imported into a new project and environment",
"operationId": "validateImport",