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