1
0
mirror of https://github.com/Unleash/unleash.git synced 2026-01-05 20:06:22 +01:00

feat: export project specific context fields

This commit is contained in:
kwasniew 2025-12-17 10:22:20 +01:00
parent 81d898c067
commit 7a25d724be
No known key found for this signature in database
GPG Key ID: 43A7CBC24C119560
3 changed files with 20 additions and 4 deletions

View File

@ -340,7 +340,10 @@ export class ContextController extends Controller {
const result = await this.transactionalContextService.transactional(
(service) =>
service.createContextField(
{ ...value, project: req.params.projectId },
{
...value,
project: req.params.projectId || value.project,
},
req.audit,
),
);

View File

@ -170,6 +170,7 @@ beforeAll(async () => {
experimental: {
flags: {
featureLinks: true,
projectContextFields: true,
},
},
},
@ -201,8 +202,8 @@ afterAll(async () => {
await db.destroy();
});
describe('import-export for project-specific segments', () => {
test('exports features with project-specific-segments', async () => {
describe('import-export for project specific segments', () => {
test('exports features with project specific segments and context fields', async () => {
const segmentName = 'my-segment';
const project = 'with-segments';
await createProjects([project]);
@ -211,6 +212,10 @@ describe('import-export for project-specific segments', () => {
project,
constraints: [],
});
await app.createContextField({
name: 'projectAppName',
project,
});
const strategy = {
name: 'default',
parameters: {
@ -219,7 +224,7 @@ describe('import-export for project-specific segments', () => {
},
constraints: [
{
contextName: 'appName',
contextName: 'projectAppName',
values: ['test'],
operator: 'IN' as const,
},
@ -265,6 +270,7 @@ describe('import-export for project-specific segments', () => {
name: segmentName,
},
],
contextFields: [{ name: 'projectAppName', project }],
});
});
});

View File

@ -63,6 +63,13 @@ export const contextFieldSchema = {
$ref: '#/components/schemas/legalValueSchema',
},
},
project: {
description:
'The project this context field belongs to (if it is project-specific)',
type: 'string',
nullable: true,
example: 'my-project',
},
},
components: {
schemas: {