2022-04-25 14:17:59 +02:00
|
|
|
import { Request, Response } from 'express';
|
2021-04-22 10:07:10 +02:00
|
|
|
import { IUnleashConfig } from '../../types/option';
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
import { IUnleashServices } from '../../types';
|
2023-10-20 13:17:41 +02:00
|
|
|
import Controller from '../../routes/controller';
|
2021-09-14 19:58:48 +02:00
|
|
|
import { extractUsername } from '../../util/extract-user';
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
import { DELETE_FEATURE, NONE, UPDATE_FEATURE } from '../../types/permissions';
|
2023-10-20 13:17:41 +02:00
|
|
|
import FeatureToggleService from './feature-toggle-service';
|
|
|
|
import { IAuthRequest } from '../../routes/unleash-types';
|
2022-06-08 08:01:14 +02:00
|
|
|
import {
|
|
|
|
featuresSchema,
|
|
|
|
FeaturesSchema,
|
|
|
|
} from '../../openapi/spec/features-schema';
|
|
|
|
import { serializeDates } from '../../types/serialize-dates';
|
|
|
|
import { OpenApiService } from '../../services/openapi-service';
|
2022-07-01 08:06:33 +02:00
|
|
|
import { createResponseSchema } from '../../openapi/util/create-response-schema';
|
2023-06-30 14:22:08 +02:00
|
|
|
import {
|
|
|
|
emptyResponse,
|
|
|
|
getStandardResponses,
|
|
|
|
} from '../../openapi/util/standard-responses';
|
2023-10-13 09:38:18 +02:00
|
|
|
import { TransactionCreator, UnleashTransaction } from '../../db/transaction';
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2021-04-22 10:07:10 +02:00
|
|
|
export default class ArchiveController extends Controller {
|
2021-11-12 13:15:51 +01:00
|
|
|
private featureService: FeatureToggleService;
|
2023-10-13 09:38:18 +02:00
|
|
|
private transactionalFeatureToggleService: (
|
|
|
|
db: UnleashTransaction,
|
|
|
|
) => FeatureToggleService;
|
|
|
|
private readonly startTransaction: TransactionCreator<UnleashTransaction>;
|
2022-06-08 08:01:14 +02:00
|
|
|
private openApiService: OpenApiService;
|
|
|
|
|
2021-04-22 10:07:10 +02:00
|
|
|
constructor(
|
|
|
|
config: IUnleashConfig,
|
|
|
|
{
|
2023-10-13 09:38:18 +02:00
|
|
|
transactionalFeatureToggleService,
|
2021-07-07 10:46:50 +02:00
|
|
|
featureToggleServiceV2,
|
2022-04-25 14:17:59 +02:00
|
|
|
openApiService,
|
2023-10-13 09:38:18 +02:00
|
|
|
}: Pick<
|
|
|
|
IUnleashServices,
|
|
|
|
| 'transactionalFeatureToggleService'
|
|
|
|
| 'featureToggleServiceV2'
|
|
|
|
| 'openApiService'
|
|
|
|
>,
|
|
|
|
startTransaction: TransactionCreator<UnleashTransaction>,
|
2021-04-22 10:07:10 +02:00
|
|
|
) {
|
2018-12-19 14:50:01 +01:00
|
|
|
super(config);
|
2021-07-07 10:46:50 +02:00
|
|
|
this.featureService = featureToggleServiceV2;
|
2022-06-08 08:01:14 +02:00
|
|
|
this.openApiService = openApiService;
|
2023-10-13 09:38:18 +02:00
|
|
|
this.transactionalFeatureToggleService =
|
|
|
|
transactionalFeatureToggleService;
|
|
|
|
this.startTransaction = startTransaction;
|
2018-11-30 08:24:22 +01:00
|
|
|
|
2022-04-25 14:17:59 +02:00
|
|
|
this.route({
|
|
|
|
method: 'get',
|
|
|
|
path: '/features',
|
|
|
|
handler: this.getArchivedFeatures,
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
permission: NONE,
|
2022-04-25 14:17:59 +02:00
|
|
|
middleware: [
|
|
|
|
openApiService.validPath({
|
2022-08-12 11:37:57 +02:00
|
|
|
tags: ['Archive'],
|
2023-08-01 15:58:15 +02:00
|
|
|
summary: 'Get archived features',
|
|
|
|
description:
|
|
|
|
'Retrieve a list of all [archived feature toggles](https://docs.getunleash.io/reference/archived-toggles).',
|
2022-06-08 15:31:34 +02:00
|
|
|
operationId: 'getArchivedFeatures',
|
2023-06-30 14:22:08 +02:00
|
|
|
responses: {
|
|
|
|
200: createResponseSchema('featuresSchema'),
|
|
|
|
...getStandardResponses(401, 403),
|
|
|
|
},
|
|
|
|
|
2022-04-25 14:17:59 +02:00
|
|
|
deprecated: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2022-05-04 08:45:29 +02:00
|
|
|
this.route({
|
|
|
|
method: 'get',
|
|
|
|
path: '/features/:projectId',
|
|
|
|
handler: this.getArchivedFeaturesByProjectId,
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
permission: NONE,
|
2022-05-04 08:45:29 +02:00
|
|
|
middleware: [
|
|
|
|
openApiService.validPath({
|
2022-08-12 11:37:57 +02:00
|
|
|
tags: ['Archive'],
|
2022-06-08 15:31:34 +02:00
|
|
|
operationId: 'getArchivedFeaturesByProjectId',
|
2023-08-01 15:58:15 +02:00
|
|
|
summary: 'Get archived features in project',
|
|
|
|
description:
|
|
|
|
'Retrieves a list of archived features that belong to the provided project.',
|
2023-06-30 14:22:08 +02:00
|
|
|
responses: {
|
|
|
|
200: createResponseSchema('featuresSchema'),
|
|
|
|
...getStandardResponses(401, 403),
|
|
|
|
},
|
|
|
|
|
2022-05-04 08:45:29 +02:00
|
|
|
deprecated: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2022-06-08 15:31:34 +02:00
|
|
|
this.route({
|
|
|
|
method: 'delete',
|
|
|
|
path: '/:featureName',
|
|
|
|
acceptAnyContentType: true,
|
|
|
|
handler: this.deleteFeature,
|
|
|
|
permission: DELETE_FEATURE,
|
|
|
|
middleware: [
|
|
|
|
openApiService.validPath({
|
2022-08-12 11:37:57 +02:00
|
|
|
tags: ['Archive'],
|
2023-06-30 14:22:08 +02:00
|
|
|
description:
|
|
|
|
'This endpoint archives the specified feature.',
|
|
|
|
summary: 'Archives a feature',
|
2022-06-08 15:31:34 +02:00
|
|
|
operationId: 'deleteFeature',
|
2023-06-30 14:22:08 +02:00
|
|
|
responses: {
|
|
|
|
200: emptyResponse,
|
|
|
|
...getStandardResponses(401, 403),
|
|
|
|
},
|
2022-06-08 15:31:34 +02:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
this.route({
|
|
|
|
method: 'post',
|
|
|
|
path: '/revive/:featureName',
|
|
|
|
acceptAnyContentType: true,
|
|
|
|
handler: this.reviveFeature,
|
|
|
|
permission: UPDATE_FEATURE,
|
|
|
|
middleware: [
|
|
|
|
openApiService.validPath({
|
2022-08-12 11:37:57 +02:00
|
|
|
tags: ['Archive'],
|
2023-06-30 14:22:08 +02:00
|
|
|
description:
|
|
|
|
'This endpoint revives the specified feature from archive.',
|
|
|
|
summary: 'Revives a feature',
|
2022-06-08 15:31:34 +02:00
|
|
|
operationId: 'reviveFeature',
|
2023-06-30 14:22:08 +02:00
|
|
|
responses: {
|
|
|
|
200: emptyResponse,
|
|
|
|
...getStandardResponses(400, 401, 403),
|
|
|
|
},
|
2022-06-08 15:31:34 +02:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
2017-06-28 10:20:22 +02:00
|
|
|
}
|
|
|
|
|
2022-04-25 14:17:59 +02:00
|
|
|
async getArchivedFeatures(
|
2023-09-18 10:06:26 +02:00
|
|
|
req: IAuthRequest,
|
2022-04-25 14:17:59 +02:00
|
|
|
res: Response<FeaturesSchema>,
|
|
|
|
): Promise<void> {
|
2023-09-18 10:06:26 +02:00
|
|
|
const { user } = req;
|
2023-10-20 13:17:41 +02:00
|
|
|
const features = await this.featureService.getAllArchivedFeatures(
|
2021-08-13 10:36:19 +02:00
|
|
|
true,
|
2023-09-18 10:06:26 +02:00
|
|
|
user.id,
|
2021-08-13 10:36:19 +02:00
|
|
|
);
|
2022-06-08 08:01:14 +02:00
|
|
|
this.openApiService.respondWithValidation(
|
|
|
|
200,
|
|
|
|
res,
|
|
|
|
featuresSchema.$id,
|
|
|
|
{ version: 2, features: serializeDates(features) },
|
|
|
|
);
|
2018-11-30 08:24:22 +01:00
|
|
|
}
|
2017-06-28 10:20:22 +02:00
|
|
|
|
2022-05-04 08:45:29 +02:00
|
|
|
async getArchivedFeaturesByProjectId(
|
|
|
|
req: Request<{ projectId: string }, any, any, any>,
|
|
|
|
res: Response<FeaturesSchema>,
|
|
|
|
): Promise<void> {
|
|
|
|
const { projectId } = req.params;
|
|
|
|
const features =
|
2023-10-20 13:17:41 +02:00
|
|
|
await this.featureService.getArchivedFeaturesByProjectId(
|
2022-05-04 08:45:29 +02:00
|
|
|
true,
|
|
|
|
projectId,
|
|
|
|
);
|
2022-06-08 08:01:14 +02:00
|
|
|
this.openApiService.respondWithValidation(
|
|
|
|
200,
|
|
|
|
res,
|
|
|
|
featuresSchema.$id,
|
|
|
|
{ version: 2, features: serializeDates(features) },
|
|
|
|
);
|
2022-05-04 08:45:29 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 14:11:56 +02:00
|
|
|
async deleteFeature(
|
2022-06-08 15:31:34 +02:00
|
|
|
req: IAuthRequest<{ featureName: string }>,
|
2022-06-10 10:04:56 +02:00
|
|
|
res: Response<void>,
|
2021-05-06 14:11:56 +02:00
|
|
|
): Promise<void> {
|
|
|
|
const { featureName } = req.params;
|
2021-09-14 19:58:48 +02:00
|
|
|
const user = extractUsername(req);
|
2021-08-13 10:36:19 +02:00
|
|
|
await this.featureService.deleteFeature(featureName, user);
|
|
|
|
res.status(200).end();
|
2021-05-06 14:11:56 +02:00
|
|
|
}
|
|
|
|
|
2022-06-08 15:31:34 +02:00
|
|
|
async reviveFeature(
|
|
|
|
req: IAuthRequest<{ featureName: string }>,
|
2022-06-10 10:04:56 +02:00
|
|
|
res: Response<void>,
|
2022-06-08 15:31:34 +02:00
|
|
|
): Promise<void> {
|
2021-09-14 19:58:48 +02:00
|
|
|
const userName = extractUsername(req);
|
2021-04-23 13:29:24 +02:00
|
|
|
const { featureName } = req.params;
|
2023-10-13 09:38:18 +02:00
|
|
|
|
|
|
|
await this.startTransaction(async (tx) =>
|
|
|
|
this.transactionalFeatureToggleService(tx).reviveFeature(
|
|
|
|
featureName,
|
|
|
|
userName,
|
|
|
|
),
|
|
|
|
);
|
2021-08-13 10:36:19 +02:00
|
|
|
res.status(200).end();
|
2018-11-30 08:24:22 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-25 18:34:23 +02:00
|
|
|
|
2018-11-30 08:24:22 +01:00
|
|
|
module.exports = ArchiveController;
|