Skip to content

Commit df6160c

Browse files
authored
feat(schema-compiler): Support public/shown for segments (#6491)
1 parent d3b8ed7 commit df6160c

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeValidator.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ const MeasuresSchema = Joi.object().pattern(identifierRegex, Joi.alternatives().
449449
]
450450
));
451451

452+
const SegmentsSchema = Joi.object().pattern(identifierRegex, Joi.object().keys({
453+
aliases: Joi.array().items(Joi.string()),
454+
sql: Joi.func().required(),
455+
title: Joi.string(),
456+
description: Joi.string(),
457+
meta: Joi.any(),
458+
shown: Joi.boolean().strict(),
459+
public: Joi.boolean().strict(),
460+
}));
461+
452462
/* *****************************
453463
* ATTENTION:
454464
* In case of adding/removing/changing any Joi.func() field that needs to be transpiled,
@@ -512,13 +522,7 @@ const baseSchema = {
512522
sql: Joi.func().required()
513523
})
514524
)),
515-
segments: Joi.object().pattern(identifierRegex, Joi.object().keys({
516-
aliases: Joi.array().items(Joi.string()),
517-
sql: Joi.func().required(),
518-
title: Joi.string(),
519-
description: Joi.string(),
520-
meta: Joi.any()
521-
})),
525+
segments: SegmentsSchema,
522526
preAggregations: PreAggregationsAlternatives,
523527
};
524528

packages/cubejs-schema-compiler/test/unit/cube-validator.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ describe('Cube Validation', () => {
4848
primaryKey: true
4949
},
5050
},
51+
segments: {
52+
firstSegment: {
53+
public: false,
54+
sql: () => 'test',
55+
},
56+
secondSegment: {
57+
shown: false,
58+
sql: () => 'test',
59+
}
60+
},
5161
fileName: 'fileName',
5262
};
5363

0 commit comments

Comments
 (0)