mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
Export tag types (#3026)
Adds a simple functionality to export also tag types.
This commit is contained in:
parent
a91089d904
commit
daa4041d03
@ -98,6 +98,7 @@ test('exportResultSchema', () => {
|
||||
},
|
||||
],
|
||||
segments: [],
|
||||
tagTypes: [{ name: 'simple', description: 'test' }],
|
||||
};
|
||||
|
||||
expect(
|
||||
|
@ -11,12 +11,13 @@ import { variantSchema } from './variant-schema';
|
||||
import { overrideSchema } from './override-schema';
|
||||
import { variantsSchema } from './variants-schema';
|
||||
import { constraintSchema } from './constraint-schema';
|
||||
import { tagTypeSchema } from './tag-type-schema';
|
||||
|
||||
export const exportResultSchema = {
|
||||
$id: '#/components/schemas/exportResultSchema',
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['features', 'featureStrategies'],
|
||||
required: ['features', 'featureStrategies', 'tagTypes'],
|
||||
properties: {
|
||||
features: {
|
||||
type: 'array',
|
||||
@ -54,6 +55,12 @@ export const exportResultSchema = {
|
||||
$ref: '#/components/schemas/segmentSchema',
|
||||
},
|
||||
},
|
||||
tagTypes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
$ref: '#/components/schemas/tagTypeSchema',
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
schemas: {
|
||||
@ -69,6 +76,7 @@ export const exportResultSchema = {
|
||||
constraintSchema,
|
||||
parametersSchema,
|
||||
legalValueSchema,
|
||||
tagTypeSchema,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
@ -88,6 +88,7 @@ export default class ExportImportService {
|
||||
contextFields,
|
||||
featureTags,
|
||||
segments,
|
||||
tagTypes,
|
||||
] = await Promise.all([
|
||||
this.toggleStore.getAllByNames(query.features),
|
||||
await this.featureEnvironmentStore.getAllByFeatures(
|
||||
@ -102,6 +103,7 @@ export default class ExportImportService {
|
||||
this.contextFieldStore.getAll(),
|
||||
this.featureTagStore.getAllByFeatures(query.features),
|
||||
this.segmentStore.getAll(),
|
||||
this.tagTypeStore.getAll(),
|
||||
]);
|
||||
this.addSegmentsToStrategies(featureStrategies, strategySegments);
|
||||
const filteredContextFields = contextFields.filter((field) =>
|
||||
@ -116,6 +118,9 @@ export default class ExportImportService {
|
||||
strategy.segments.includes(segment.id),
|
||||
),
|
||||
);
|
||||
const filteredTagTypes = tagTypes.filter((tagType) =>
|
||||
featureTags.map((tag) => tag.tagType).includes(tagType.name),
|
||||
);
|
||||
const result = {
|
||||
features: features.map((item) => {
|
||||
const { createdAt, archivedAt, lastSeenAt, ...rest } = item;
|
||||
@ -148,6 +153,7 @@ export default class ExportImportService {
|
||||
const { createdAt, createdBy, ...rest } = item;
|
||||
return rest;
|
||||
}),
|
||||
tagTypes: filteredTagTypes,
|
||||
};
|
||||
await this.eventStore.store({
|
||||
type: FEATURES_EXPORTED,
|
||||
|
@ -1096,10 +1096,17 @@ exports[`should serve the OpenAPI spec 1`] = `
|
||||
},
|
||||
"type": "array",
|
||||
},
|
||||
"tagTypes": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/tagTypeSchema",
|
||||
},
|
||||
"type": "array",
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"features",
|
||||
"featureStrategies",
|
||||
"tagTypes",
|
||||
],
|
||||
"type": "object",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user