@cubejs-backend/schema-compiler 1.8.17 → 1.8.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/adapter/BaseQuery.d.ts.map +1 -1
- package/dist/src/adapter/BaseQuery.js +5 -1
- package/dist/src/adapter/BaseQuery.js.map +1 -1
- package/dist/src/adapter/BigqueryQuery.d.ts +2 -1
- package/dist/src/adapter/BigqueryQuery.d.ts.map +1 -1
- package/dist/src/adapter/BigqueryQuery.js +19 -4
- package/dist/src/adapter/BigqueryQuery.js.map +1 -1
- package/dist/src/adapter/ClickHouseQuery.d.ts.map +1 -1
- package/dist/src/adapter/ClickHouseQuery.js +7 -13
- package/dist/src/adapter/ClickHouseQuery.js.map +1 -1
- package/dist/src/adapter/CubeStoreQuery.js +1 -1
- package/dist/src/adapter/CubeStoreQuery.js.map +1 -1
- package/dist/src/adapter/HiveQuery.js +1 -1
- package/dist/src/adapter/HiveQuery.js.map +1 -1
- package/dist/src/adapter/MssqlQuery.d.ts +1 -0
- package/dist/src/adapter/MssqlQuery.d.ts.map +1 -1
- package/dist/src/adapter/MssqlQuery.js +11 -3
- package/dist/src/adapter/MssqlQuery.js.map +1 -1
- package/dist/src/adapter/MysqlQuery.js +2 -2
- package/dist/src/adapter/MysqlQuery.js.map +1 -1
- package/dist/src/compiler/CubeSymbols.d.ts +1 -0
- package/dist/src/compiler/CubeSymbols.d.ts.map +1 -1
- package/dist/src/compiler/CubeSymbols.js +1 -0
- package/dist/src/compiler/CubeSymbols.js.map +1 -1
- package/dist/src/compiler/CubeToMetaTransformer.d.ts +2 -0
- package/dist/src/compiler/CubeToMetaTransformer.d.ts.map +1 -1
- package/dist/src/compiler/CubeToMetaTransformer.js +1 -0
- package/dist/src/compiler/CubeToMetaTransformer.js.map +1 -1
- package/dist/src/compiler/CubeValidator.d.ts +1 -0
- package/dist/src/compiler/CubeValidator.d.ts.map +1 -1
- package/dist/src/compiler/CubeValidator.js +397 -374
- package/dist/src/compiler/CubeValidator.js.map +1 -1
- package/dist/src/compiler/JoinGraph.d.ts.map +1 -1
- package/dist/src/compiler/JoinGraph.js +3 -1
- package/dist/src/compiler/JoinGraph.js.map +1 -1
- package/dist/src/compiler/index.d.ts +1 -0
- package/dist/src/compiler/index.d.ts.map +1 -1
- package/dist/src/compiler/index.js +3 -1
- package/dist/src/compiler/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CubeValidator = exports.nonStringFields = void 0;
|
|
7
7
|
exports.functionFieldsPatterns = functionFieldsPatterns;
|
|
8
|
+
exports.describeModelSchemas = describeModelSchemas;
|
|
8
9
|
const crypto_1 = __importDefault(require("crypto"));
|
|
9
10
|
const joi_1 = __importDefault(require("joi"));
|
|
10
11
|
const lru_cache_1 = require("lru-cache");
|
|
@@ -105,8 +106,8 @@ const GranularityOffset = joi_1.default.string().pattern(/^-?(\d+\s+)(second|min
|
|
|
105
106
|
const formatAlternatives = [
|
|
106
107
|
joi_1.default.string().valid('imageUrl', 'link', 'currency', 'percent', 'number', 'id'),
|
|
107
108
|
joi_1.default.object().keys({
|
|
108
|
-
type: joi_1.default.string().valid('link'),
|
|
109
|
-
label: joi_1.default.string().required()
|
|
109
|
+
type: joi_1.default.string().valid('link').description('Format kind: link renders the value as a link titled with label'),
|
|
110
|
+
label: joi_1.default.string().required().description('Display label for the link')
|
|
110
111
|
})
|
|
111
112
|
];
|
|
112
113
|
const formatSchema = joi_1.default.alternatives(formatAlternatives);
|
|
@@ -269,23 +270,23 @@ const currencySchema = joi_1.default.string().custom((value, helper) => {
|
|
|
269
270
|
});
|
|
270
271
|
});
|
|
271
272
|
const MaskSchema = joi_1.default.alternatives([
|
|
272
|
-
joi_1.default.object().keys({ sql: joi_1.default.func().required() }),
|
|
273
|
+
joi_1.default.object().keys({ sql: joi_1.default.func().required().description('SQL expression for the masked value. For a measure, use an aggregate expression.') }),
|
|
273
274
|
joi_1.default.number(),
|
|
274
275
|
joi_1.default.boolean().strict(),
|
|
275
276
|
joi_1.default.string(),
|
|
276
277
|
]);
|
|
277
278
|
const LinkItemSchema = joi_1.default.object().keys({
|
|
278
|
-
name: identifier.required(),
|
|
279
|
-
label: joi_1.default.string().required(),
|
|
280
|
-
url: joi_1.default.func(),
|
|
281
|
-
dashboard: joi_1.default.string(),
|
|
282
|
-
icon: joi_1.default.string(),
|
|
283
|
-
target: joi_1.default.string().valid('blank', 'self'),
|
|
284
|
-
primary: joi_1.default.boolean().strict(),
|
|
279
|
+
name: identifier.required().description('Unique link identifier within the dimension'),
|
|
280
|
+
label: joi_1.default.string().required().description('Label shown to viewers'),
|
|
281
|
+
url: joi_1.default.func().description('SQL expression building the external URL (e.g. a member reference like {full_name})'),
|
|
282
|
+
dashboard: joi_1.default.string().description('Slug of the target dashboard for in-app drill-in'),
|
|
283
|
+
icon: joi_1.default.string().description('Tabler icon name shown for the link'),
|
|
284
|
+
target: joi_1.default.string().valid('blank', 'self').description('Where the link opens'),
|
|
285
|
+
primary: joi_1.default.boolean().strict().description('Render as the cell text itself (at most one per dimension)'),
|
|
285
286
|
params: joi_1.default.array().items(joi_1.default.object().keys({
|
|
286
|
-
key: joi_1.default.string().required(),
|
|
287
|
-
value: joi_1.default.func().required(),
|
|
288
|
-
})),
|
|
287
|
+
key: joi_1.default.string().required().description('Name of the query parameter'),
|
|
288
|
+
value: joi_1.default.func().required().description('SQL expression for the query parameter value'),
|
|
289
|
+
})).description('Query parameters appended to the link URL; values are SQL expressions'),
|
|
289
290
|
}).oxor('url', 'dashboard');
|
|
290
291
|
const LinksSchema = joi_1.default.array().items(LinkItemSchema).custom((value, helpers) => {
|
|
291
292
|
const names = value.map((link) => (typeof link.name === 'function' ? link.name() : link.name));
|
|
@@ -302,59 +303,61 @@ const LinksSchema = joi_1.default.array().items(LinkItemSchema).custom((value, h
|
|
|
302
303
|
}
|
|
303
304
|
return value;
|
|
304
305
|
});
|
|
306
|
+
// `CubeToMetaTransformer` reads `visible` and `shown` only when `public` is missing.
|
|
307
|
+
const sameAsPublicDescription = 'Same as public; prefer public';
|
|
305
308
|
const BaseDimensionWithoutSubQuery = {
|
|
306
|
-
aliases: joi_1.default.array().items(joi_1.default.string()),
|
|
307
|
-
type: joi_1.default.any().valid('string', 'number', 'boolean', 'time', 'geo').required(),
|
|
308
|
-
fieldType: joi_1.default.any().valid('string'),
|
|
309
|
-
valuesAsSegments: joi_1.default.boolean().strict(),
|
|
310
|
-
primaryKey: joi_1.default.boolean().strict(),
|
|
311
|
-
shown: joi_1.default.boolean().strict(),
|
|
312
|
-
public: joi_1.default.boolean().strict(),
|
|
313
|
-
title: joi_1.default.string(),
|
|
314
|
-
description: joi_1.default.string(),
|
|
315
|
-
suggestFilterValues: joi_1.default.boolean().strict(),
|
|
316
|
-
enableSuggestions: joi_1.default.boolean().strict(),
|
|
317
|
-
links: LinksSchema,
|
|
318
|
-
mask: MaskSchema,
|
|
309
|
+
aliases: joi_1.default.array().items(joi_1.default.string()).description('Other names for this dimension'),
|
|
310
|
+
type: joi_1.default.any().valid('string', 'number', 'boolean', 'time', 'geo').required().description('Type of the dimension'),
|
|
311
|
+
fieldType: joi_1.default.any().valid('string').meta({ hidden: true }),
|
|
312
|
+
valuesAsSegments: joi_1.default.boolean().strict().meta({ hidden: true }),
|
|
313
|
+
primaryKey: joi_1.default.boolean().strict().description('Whether this dimension uniquely identifies a row. Cube uses it to avoid counting measures twice across joins, and hides it unless public is set'),
|
|
314
|
+
shown: joi_1.default.boolean().strict().description(sameAsPublicDescription),
|
|
315
|
+
public: joi_1.default.boolean().strict().description('Whether this dimension is publicly accessible'),
|
|
316
|
+
title: joi_1.default.string().description('Display title for the dimension'),
|
|
317
|
+
description: joi_1.default.string().description('Description of what this dimension represents'),
|
|
318
|
+
suggestFilterValues: joi_1.default.boolean().strict().description("Whether tools suggest this dimension's values when filtering by it"),
|
|
319
|
+
enableSuggestions: joi_1.default.boolean().strict().description('Accepted for compatibility; Core does not read it. Use suggest_filter_values'),
|
|
320
|
+
links: LinksSchema.description("Links rendered on this dimension's cells in supporting tools (e.g. dashboard tables). Each link opens an external url (a SQL expression) or drills into a dashboard referenced by its slug."),
|
|
321
|
+
mask: MaskSchema.description(`Value returned instead of the dimension's value when an access policy masks it: a static number, boolean or string, or an object with a SQL expression. In YAML a string mask is read as a Python expression, so quote a literal twice: "'***'"`),
|
|
319
322
|
format: joi_1.default.when('type', {
|
|
320
323
|
switch: [
|
|
321
324
|
{ is: 'time', then: timeFormatSchema },
|
|
322
325
|
{ is: 'number', then: dimensionNumericFormatSchema },
|
|
323
326
|
],
|
|
324
327
|
otherwise: formatSchema
|
|
325
|
-
}),
|
|
328
|
+
}).description('How the dimension is displayed. String dimensions take imageUrl, link, currency, percent, number, id or a link object (type: link, label); number and time dimensions also take format strings. See https://docs.cube.dev/reference/data-modeling/dimensions#format'),
|
|
326
329
|
currency: joi_1.default.when('type', {
|
|
327
330
|
is: 'number',
|
|
328
331
|
then: currencySchema,
|
|
329
332
|
otherwise: joi_1.default.any().custom((_value, helper) => helper.message({
|
|
330
333
|
custom: '"currency" property can only be used with dimensions of type "number"'
|
|
331
334
|
}))
|
|
332
|
-
}),
|
|
333
|
-
meta: joi_1.default.any(),
|
|
334
|
-
order: joi_1.default.string().valid('asc', 'desc'),
|
|
335
|
-
key: joi_1.default.func(),
|
|
336
|
-
keyReference: joi_1.default.string(),
|
|
335
|
+
}).description('ISO 4217 currency code (e.g. USD, EUR, GBP) for number-type dimensions. Use with format: currency or currency_N. Case-insensitive. See https://docs.cube.dev/reference/data-modeling/dimensions#currency'),
|
|
336
|
+
meta: joi_1.default.any().description('Additional metadata for the dimension'),
|
|
337
|
+
order: joi_1.default.string().valid('asc', 'desc').description('Default sort order for this dimension. See https://docs.cube.dev/reference/data-modeling/dimensions#order'),
|
|
338
|
+
key: joi_1.default.func().description("Dimension that holds this dimension's key, such as an id for a name. Tools group and filter by the key"),
|
|
339
|
+
keyReference: joi_1.default.string().meta({ hidden: true }),
|
|
337
340
|
values: joi_1.default.when('type', {
|
|
338
341
|
is: 'switch',
|
|
339
342
|
then: joi_1.default.array().items(joi_1.default.string()),
|
|
340
343
|
otherwise: joi_1.default.forbidden()
|
|
341
|
-
}),
|
|
344
|
+
}).meta({ hidden: true }),
|
|
342
345
|
granularities: joi_1.default.when('type', {
|
|
343
346
|
is: 'time',
|
|
344
347
|
then: joi_1.default.object().pattern(identifierRegex, joi_1.default.alternatives([
|
|
345
348
|
joi_1.default.object().keys({
|
|
346
|
-
title: joi_1.default.string(),
|
|
347
|
-
interval: GranularityInterval.required(),
|
|
349
|
+
title: joi_1.default.string().description('Human-friendly description of the granularity'),
|
|
350
|
+
interval: GranularityInterval.required().description("Duration of the time interval (e.g., '1 week', '15 minutes', '1 year', '1 quarter')"),
|
|
348
351
|
origin: joi_1.default.string().required().custom((value, helpers) => {
|
|
349
352
|
const date = new Date(value);
|
|
350
353
|
if (Number.isNaN(date.getTime())) {
|
|
351
354
|
return helpers.message({ custom: 'Origin should be valid date-only form: YYYY[-MM[-DD]] or date-time form: YYYY-MM-DD[T]HH:mm[:ss[.sss[Z]]]' });
|
|
352
355
|
}
|
|
353
356
|
return value;
|
|
354
|
-
}),
|
|
357
|
+
}).description("Align intervals with a specific date (e.g., '2025-04-01')"),
|
|
355
358
|
}),
|
|
356
359
|
joi_1.default.object().keys({
|
|
357
|
-
title: joi_1.default.string(),
|
|
360
|
+
title: joi_1.default.string().description('Human-friendly description of the granularity'),
|
|
358
361
|
interval: GranularityInterval.required().custom((value, helper) => {
|
|
359
362
|
const intParsed = value.split(' ');
|
|
360
363
|
const msg = { custom: 'Arbitrary intervals cannot be used without origin point specified' };
|
|
@@ -383,48 +386,50 @@ const BaseDimensionWithoutSubQuery = {
|
|
|
383
386
|
};
|
|
384
387
|
const isValid = Object.keys(validIntervals).some(key => unit.includes(key) && validIntervals[key]());
|
|
385
388
|
return isValid ? value : helper.message(msg);
|
|
386
|
-
}),
|
|
387
|
-
offset: GranularityOffset.optional(),
|
|
389
|
+
}).description("Duration of the time interval (e.g., '1 week', '15 minutes', '1 year', '1 quarter')"),
|
|
390
|
+
offset: GranularityOffset.optional().description("Shift the time interval forward or backward (e.g., '-1 day', '1 month')"),
|
|
388
391
|
}),
|
|
389
392
|
joi_1.default.object().keys({
|
|
390
|
-
title: joi_1.default.string(),
|
|
391
|
-
sql: joi_1.default.func().required()
|
|
393
|
+
title: joi_1.default.string().description('Human-friendly description of the granularity'),
|
|
394
|
+
sql: joi_1.default.func().required().description('SQL expression that overrides a built-in granularity (e.g., month, quarter) in a calendar cube. Use interval instead to define a custom granularity.')
|
|
392
395
|
})
|
|
393
396
|
])).optional(),
|
|
394
397
|
otherwise: joi_1.default.forbidden()
|
|
395
|
-
})
|
|
398
|
+
}).description('Custom time granularities for time dimensions (e.g., fiscal year, custom week)')
|
|
396
399
|
};
|
|
397
400
|
const BaseDimension = {
|
|
398
|
-
subQuery: joi_1.default.boolean().strict(),
|
|
399
|
-
propagateFiltersToSubQuery: joi_1.default.boolean().strict(),
|
|
401
|
+
subQuery: joi_1.default.boolean().strict().description("Whether the dimension's sql references measures of another cube, which Cube computes in a subquery joined to this cube"),
|
|
402
|
+
propagateFiltersToSubQuery: joi_1.default.boolean().strict().description("Whether the query's filters are also applied inside that subquery"),
|
|
400
403
|
...BaseDimensionWithoutSubQuery
|
|
401
404
|
};
|
|
405
|
+
const rollingWindowTypeDescription = 'Type of rolling window: fixed (the default) spans trailing and leading; year_to_date, ' +
|
|
406
|
+
'quarter_to_date and month_to_date run from the start of the period; to_date runs from the start of the granularity period';
|
|
402
407
|
const FixedRollingWindow = {
|
|
403
|
-
type: joi_1.default.string().valid('fixed'),
|
|
404
|
-
trailing: timeInterval,
|
|
405
|
-
leading: timeInterval,
|
|
406
|
-
offset: joi_1.default.any().valid('start', 'end')
|
|
408
|
+
type: joi_1.default.string().valid('fixed').description(rollingWindowTypeDescription),
|
|
409
|
+
trailing: timeInterval.description("Trailing time interval for the rolling window (e.g., '3 months')"),
|
|
410
|
+
leading: timeInterval.description('Leading time interval for the rolling window'),
|
|
411
|
+
offset: joi_1.default.any().valid('start', 'end').description('Point of each period that trailing and leading are measured from: start, or end (the default)')
|
|
407
412
|
};
|
|
408
413
|
const GranularitySchema = joi_1.default.string().required(); // To support custom granularities
|
|
409
414
|
const YearToDate = {
|
|
410
|
-
type: joi_1.default.string().valid('year_to_date'),
|
|
415
|
+
type: joi_1.default.string().valid('year_to_date').description(rollingWindowTypeDescription),
|
|
411
416
|
};
|
|
412
417
|
const QuarterToDate = {
|
|
413
|
-
type: joi_1.default.string().valid('quarter_to_date'),
|
|
418
|
+
type: joi_1.default.string().valid('quarter_to_date').description(rollingWindowTypeDescription),
|
|
414
419
|
};
|
|
415
420
|
const MonthToDate = {
|
|
416
|
-
type: joi_1.default.string().valid('month_to_date'),
|
|
421
|
+
type: joi_1.default.string().valid('month_to_date').description(rollingWindowTypeDescription),
|
|
417
422
|
};
|
|
418
423
|
const ToDate = {
|
|
419
|
-
type: joi_1.default.string().valid('to_date'),
|
|
420
|
-
granularity: GranularitySchema,
|
|
424
|
+
type: joi_1.default.string().valid('to_date').description(rollingWindowTypeDescription),
|
|
425
|
+
granularity: GranularitySchema.description("Time granularity for period-to-date calculations (e.g., 'year' for YTD, 'quarter' for QTD)"),
|
|
421
426
|
};
|
|
422
427
|
const forbiddenCurrencyNonNumericMeasure = (value) => joi_1.default.forbidden().messages({
|
|
423
428
|
'any.unknown': `"currency" property can only be used with numeric measures, actual type: ${value}`,
|
|
424
429
|
});
|
|
425
430
|
const BaseMeasure = {
|
|
426
|
-
aliases: joi_1.default.array().items(joi_1.default.string()),
|
|
427
|
-
format: measureFormatSchema,
|
|
431
|
+
aliases: joi_1.default.array().items(joi_1.default.string()).description('Other names for this measure'),
|
|
432
|
+
format: measureFormatSchema.description('How the measure is displayed. Use a named format (number, id, percent, currency, abbr, accounting) with optional _N suffix (N=0–6) for decimal precision on supported formats, or any valid d3-format specifier (e.g. $,.2f, .0%). See https://docs.cube.dev/reference/data-modeling/measures#format'),
|
|
428
433
|
currency: joi_1.default.when('type', {
|
|
429
434
|
switch: [
|
|
430
435
|
{ is: 'string', then: forbiddenCurrencyNonNumericMeasure('string') },
|
|
@@ -432,19 +437,19 @@ const BaseMeasure = {
|
|
|
432
437
|
{ is: 'time', then: forbiddenCurrencyNonNumericMeasure('time') },
|
|
433
438
|
],
|
|
434
439
|
otherwise: currencySchema,
|
|
435
|
-
}),
|
|
436
|
-
public: joi_1.default.boolean().strict(),
|
|
440
|
+
}).description('ISO 4217 currency code (e.g. USD, EUR, GBP) for this measure. Use with format: currency or currency_N. Case-insensitive. See https://docs.cube.dev/reference/data-modeling/measures#currency'),
|
|
441
|
+
public: joi_1.default.boolean().strict().description('Whether this measure is publicly accessible'),
|
|
437
442
|
// TODO: Deprecate and remove, please use public
|
|
438
|
-
visible: joi_1.default.boolean().strict(),
|
|
443
|
+
visible: joi_1.default.boolean().strict().description(sameAsPublicDescription),
|
|
439
444
|
// TODO: Deprecate and remove, please use public
|
|
440
|
-
shown: joi_1.default.boolean().strict(),
|
|
441
|
-
cumulative: joi_1.default.boolean().strict(),
|
|
442
|
-
mask: MaskSchema,
|
|
445
|
+
shown: joi_1.default.boolean().strict().description(sameAsPublicDescription),
|
|
446
|
+
cumulative: joi_1.default.boolean().strict().description('Marks the measure as cumulative in the metadata. Measures with rolling_window are cumulative already'),
|
|
447
|
+
mask: MaskSchema.description(`Value returned instead of the measure's value when an access policy masks it: a static number, boolean or string, or an object with an aggregate SQL expression. Defaults to NULL. In YAML a string mask is read as a Python expression, so quote a literal twice: "'***'"`),
|
|
443
448
|
filters: joi_1.default.array().items(joi_1.default.object().keys({
|
|
444
|
-
sql: joi_1.default.func().required()
|
|
445
|
-
})),
|
|
446
|
-
title: joi_1.default.string(),
|
|
447
|
-
description: joi_1.default.string(),
|
|
449
|
+
sql: joi_1.default.func().required().description('SQL condition rows must match to be aggregated')
|
|
450
|
+
})).description('Filters applied to the rows the measure aggregates. Each filter is a SQL condition'),
|
|
451
|
+
title: joi_1.default.string().description('Display title for the measure'),
|
|
452
|
+
description: joi_1.default.string().description('Description of what this measure represents'),
|
|
448
453
|
rollingWindow: joi_1.default.alternatives().conditional(joi_1.default.ref('.type'), [
|
|
449
454
|
{ is: 'year_to_date', then: YearToDate },
|
|
450
455
|
{ is: 'quarter_to_date', then: QuarterToDate },
|
|
@@ -454,81 +459,88 @@ const BaseMeasure = {
|
|
|
454
459
|
then: FixedRollingWindow,
|
|
455
460
|
otherwise: FixedRollingWindow
|
|
456
461
|
}
|
|
457
|
-
]),
|
|
458
|
-
drillMemberReferences: joi_1.default.func(),
|
|
459
|
-
drillMembers: joi_1.default.func(),
|
|
462
|
+
]).description('Rolling window for a cumulative measure: the time range around each date that the measure aggregates'),
|
|
463
|
+
drillMemberReferences: joi_1.default.func().meta({ hidden: true }),
|
|
464
|
+
drillMembers: joi_1.default.func().description("Members listed when drilling down into this measure's value"),
|
|
460
465
|
drillFilters: joi_1.default.array().items(joi_1.default.object().keys({
|
|
461
|
-
sql: joi_1.default.func().required()
|
|
462
|
-
})),
|
|
463
|
-
meta: joi_1.default.any()
|
|
466
|
+
sql: joi_1.default.func().required().description('SQL condition for the drill-down rows')
|
|
467
|
+
})).description('Filters applied when drilling down into this measure'),
|
|
468
|
+
meta: joi_1.default.any().description('Additional metadata for the measure')
|
|
464
469
|
};
|
|
470
|
+
const filterValuesDescription = 'Values to compare with; required for all operators except set and notSet';
|
|
471
|
+
const refreshKeySqlEveryDescription = "How often the sql check runs (e.g., '1 hour'); defaults to 10 seconds";
|
|
465
472
|
const PreAggregationRefreshKeySchema = condition((s) => defined(s.sql), joi_1.default.object().keys({
|
|
466
|
-
sql: joi_1.default.func().required(),
|
|
473
|
+
sql: joi_1.default.func().required().description('SQL query to determine if refresh is needed'),
|
|
467
474
|
// We don't support timezone for this, because it's useless
|
|
468
475
|
// We cannot support cron interval
|
|
469
|
-
every: everyInterval,
|
|
476
|
+
every: everyInterval.description(refreshKeySqlEveryDescription),
|
|
470
477
|
}), condition((s) => defined(s.every), joi_1.default.object().keys({
|
|
471
|
-
every: joi_1.default.alternatives().try(everyInterval, everyCronInterval),
|
|
472
|
-
timezone: everyCronTimeZone,
|
|
473
|
-
incremental: joi_1.default.boolean().strict(),
|
|
474
|
-
updateWindow: everyInterval
|
|
478
|
+
every: joi_1.default.alternatives().try(everyInterval, everyCronInterval).description("Refresh interval (e.g., '1 hour', '1 day')"),
|
|
479
|
+
timezone: everyCronTimeZone.description('Timezone for refresh scheduling'),
|
|
480
|
+
incremental: joi_1.default.boolean().strict().description('Whether to keep rebuilding only the partitions that end within update_window of now, leaving older ones as built. Partitioned pre-aggregations only'),
|
|
481
|
+
updateWindow: everyInterval.description('Time window for incremental updates')
|
|
475
482
|
}), requireOneOf('sql', 'every')));
|
|
483
|
+
const partitionGranularityDescription = 'Time period each partition of the pre-aggregation covers, by its time dimension';
|
|
484
|
+
const uniqueKeyColumnsDescription = 'Columns that uniquely identify a row of the Cube Store table';
|
|
485
|
+
const allowNonStrictDateRangeMatchDescription = "Whether a query whose date range doesn't align with the granularity can use this pre-aggregation; defaults to true unless CUBEJS_PRE_AGGREGATIONS_ALLOW_NON_STRICT_DATE_RANGE_MATCH is false";
|
|
486
|
+
const preAggregationTypeDescription = 'Type of pre-aggregation: rollup (the default), original_sql, rollup_join or rollup_lambda';
|
|
487
|
+
const rollupJoinScheduledRefreshDescription = 'Only false: a rollup_join is ephemeral, so set freshness on the rollups it references';
|
|
476
488
|
const BasePreAggregationWithoutPartitionGranularity = {
|
|
477
|
-
refreshKey: PreAggregationRefreshKeySchema,
|
|
478
|
-
sqlAlias: joi_1.default.string().optional(),
|
|
479
|
-
useOriginalSqlPreAggregations: joi_1.default.boolean().strict(),
|
|
480
|
-
external: joi_1.default.boolean().strict(),
|
|
481
|
-
scheduledRefresh: joi_1.default.boolean().strict(),
|
|
489
|
+
refreshKey: PreAggregationRefreshKeySchema.description('When the pre-aggregation is refreshed: on a schedule (every) or when a SQL result changes (sql)'),
|
|
490
|
+
sqlAlias: joi_1.default.string().optional().description("Short alias for the pre-aggregation's table name, for databases that truncate long names"),
|
|
491
|
+
useOriginalSqlPreAggregations: joi_1.default.boolean().strict().description("Whether this rollup is built from the cube's original_sql pre-aggregation instead of re-running the cube's SQL"),
|
|
492
|
+
external: joi_1.default.boolean().strict().description('Whether to store the pre-aggregation in Cube Store instead of the source database; defaults to true for rollup and rollup_join unless CUBEJS_EXTERNAL_DEFAULT is false, and to false for original_sql'),
|
|
493
|
+
scheduledRefresh: joi_1.default.boolean().strict().description('Whether to refresh this pre-aggregation on schedule'),
|
|
482
494
|
indexes: joi_1.default.object().pattern(identifierRegex, joi_1.default.alternatives().try(joi_1.default.object().keys({
|
|
483
|
-
sql: joi_1.default.func().required()
|
|
495
|
+
sql: joi_1.default.func().required().description('SQL expression for the index')
|
|
484
496
|
}), joi_1.default.object().keys({
|
|
485
|
-
columns: joi_1.default.func().required(),
|
|
486
|
-
type: joi_1.default.any().valid('regular', 'aggregate'),
|
|
487
|
-
}))),
|
|
497
|
+
columns: joi_1.default.func().required().description('Members whose columns the index covers'),
|
|
498
|
+
type: joi_1.default.any().valid('regular', 'aggregate').description('Index type: regular, or aggregate for an aggregating index'),
|
|
499
|
+
}))).description("Indexes of the pre-aggregation's table in Cube Store, by name. An index lists columns, or is a SQL expression"),
|
|
488
500
|
// refreshRange was deprecated
|
|
489
|
-
refreshRangeStart: {
|
|
501
|
+
refreshRangeStart: joi_1.default.object().keys({
|
|
490
502
|
sql: joi_1.default.func().required()
|
|
491
|
-
},
|
|
492
|
-
refreshRangeEnd: {
|
|
503
|
+
}).meta({ hidden: true }),
|
|
504
|
+
refreshRangeEnd: joi_1.default.object().keys({
|
|
493
505
|
sql: joi_1.default.func().required()
|
|
494
|
-
},
|
|
506
|
+
}).meta({ hidden: true }),
|
|
495
507
|
// new api
|
|
496
|
-
buildRangeStart: {
|
|
497
|
-
sql: joi_1.default.func().required()
|
|
498
|
-
},
|
|
499
|
-
buildRangeEnd: {
|
|
500
|
-
sql: joi_1.default.func().required()
|
|
501
|
-
},
|
|
502
|
-
readOnly: joi_1.default.boolean().strict(),
|
|
503
|
-
streamOffset: joi_1.default.any().valid('earliest', 'latest'),
|
|
508
|
+
buildRangeStart: joi_1.default.object().keys({
|
|
509
|
+
sql: joi_1.default.func().required().description('SQL query returning the start of the build range')
|
|
510
|
+
}).description('SQL query returning the first timestamp of the range the pre-aggregation is built for. Takes effect only with partition_granularity'),
|
|
511
|
+
buildRangeEnd: joi_1.default.object().keys({
|
|
512
|
+
sql: joi_1.default.func().required().description('SQL query returning the end of the build range')
|
|
513
|
+
}).description('SQL query returning the last timestamp of the range the pre-aggregation is built for. Takes effect only with partition_granularity'),
|
|
514
|
+
readOnly: joi_1.default.boolean().strict().description('Whether to build a pre-aggregation stored in Cube Store by reading the query result, without creating tables in the source database'),
|
|
515
|
+
streamOffset: joi_1.default.any().valid('earliest', 'latest').description("Controls where Cube Store starts consuming from in the Kafka topic. 'latest' consumes only new messages; 'earliest' replays from the beginning."),
|
|
504
516
|
outputColumnTypes: joi_1.default.array().items(joi_1.default.object().keys({
|
|
505
|
-
member: joi_1.default.func().required(),
|
|
506
|
-
type: joi_1.default.string().required()
|
|
507
|
-
})),
|
|
517
|
+
member: joi_1.default.func().required().description('Reference to a dimension or measure included in the pre-aggregation'),
|
|
518
|
+
type: joi_1.default.string().required().description('Cube Store column type for this member')
|
|
519
|
+
})).description('Declares the output column types for the Cube Store table in streaming pre-aggregations (Kafka streams mode).'),
|
|
508
520
|
};
|
|
509
521
|
const BasePreAggregation = {
|
|
510
522
|
...BasePreAggregationWithoutPartitionGranularity,
|
|
511
|
-
partitionGranularity: joi_1.default.any().valid('hour', 'day', 'week', 'month', 'quarter', 'year'),
|
|
523
|
+
partitionGranularity: joi_1.default.any().valid('hour', 'day', 'week', 'month', 'quarter', 'year').description(partitionGranularityDescription),
|
|
512
524
|
};
|
|
513
525
|
const AutoRollupSchema = inherit(BasePreAggregation, {
|
|
514
|
-
type: joi_1.default.any().valid('autoRollup').required(),
|
|
515
|
-
maxPreAggregations: joi_1.default.number(),
|
|
526
|
+
type: joi_1.default.any().valid('autoRollup').required().description(preAggregationTypeDescription),
|
|
527
|
+
maxPreAggregations: joi_1.default.number().description('Maximum number of pre-aggregations an auto rollup creates'),
|
|
516
528
|
});
|
|
517
529
|
const OriginalSqlSchema = condition((s) => defined(s.partitionGranularity) || defined(s.timeDimension) || defined(s.timeDimensionReference), condition((s) => defined(s.timeDimensionReference), inherit(BasePreAggregation, {
|
|
518
|
-
type: joi_1.default.any().valid('originalSql').required(),
|
|
519
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
520
|
-
partitionGranularity: BasePreAggregation.partitionGranularity.required(),
|
|
521
|
-
timeDimensionReference: joi_1.default.func().required(),
|
|
522
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
530
|
+
type: joi_1.default.any().valid('originalSql').required().description(preAggregationTypeDescription),
|
|
531
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
532
|
+
partitionGranularity: BasePreAggregation.partitionGranularity.required().description(partitionGranularityDescription),
|
|
533
|
+
timeDimensionReference: joi_1.default.func().required().meta({ hidden: true }),
|
|
534
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
523
535
|
}), inherit(BasePreAggregation, {
|
|
524
|
-
type: joi_1.default.any().valid('originalSql').required(),
|
|
525
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
526
|
-
partitionGranularity: BasePreAggregation.partitionGranularity.required(),
|
|
527
|
-
timeDimension: joi_1.default.func().required(),
|
|
528
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
536
|
+
type: joi_1.default.any().valid('originalSql').required().description(preAggregationTypeDescription),
|
|
537
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
538
|
+
partitionGranularity: BasePreAggregation.partitionGranularity.required().description(partitionGranularityDescription),
|
|
539
|
+
timeDimension: joi_1.default.func().required().description('Time dimension reference for the pre-aggregation'),
|
|
540
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
529
541
|
})), inherit(BasePreAggregationWithoutPartitionGranularity, {
|
|
530
|
-
type: joi_1.default.any().valid('originalSql').required(),
|
|
531
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string())
|
|
542
|
+
type: joi_1.default.any().valid('originalSql').required().description(preAggregationTypeDescription),
|
|
543
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription)
|
|
532
544
|
}));
|
|
533
545
|
const ReferencesFields = ['timeDimensionReference', 'rollupReferences', 'measureReferences', 'dimensionReferences', 'segmentReferences'];
|
|
534
546
|
const NonReferencesFields = ['timeDimension', 'timeDimensions', 'rollups', 'measures', 'dimensions', 'segments'];
|
|
@@ -539,108 +551,108 @@ function errorOnMixing(schema) {
|
|
|
539
551
|
return condition((s) => hasAnyField(ReferencesFields, s) && hasAnyField(NonReferencesFields, s), joi_1.default.any().forbidden().error(new Error(`[${ReferencesFields.join(', ')}] are deprecated, please, use [${NonReferencesFields.join(', ')}] instead`)), schema);
|
|
540
552
|
}
|
|
541
553
|
const RollUpJoinSchema = condition((s) => defined(s.granularity) || defined(s.timeDimension) || defined(s.timeDimensionReference), condition((s) => defined(s.rollupReferences) || defined(s.timeDimensionReference), inherit(BasePreAggregation, {
|
|
542
|
-
type: joi_1.default.any().valid('rollupJoin').required(),
|
|
543
|
-
scheduledRefresh: joi_1.default.boolean().valid(false),
|
|
544
|
-
granularity: GranularitySchema,
|
|
545
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
546
|
-
timeDimensionReference: joi_1.default.func().required(),
|
|
547
|
-
rollupReferences: joi_1.default.func().required(),
|
|
548
|
-
measureReferences: joi_1.default.func(),
|
|
549
|
-
dimensionReferences: joi_1.default.func(),
|
|
550
|
-
segmentReferences: joi_1.default.func(),
|
|
554
|
+
type: joi_1.default.any().valid('rollupJoin').required().description(preAggregationTypeDescription),
|
|
555
|
+
scheduledRefresh: joi_1.default.boolean().valid(false).description(rollupJoinScheduledRefreshDescription),
|
|
556
|
+
granularity: GranularitySchema.description('Time granularity for rollup pre-aggregations'),
|
|
557
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
558
|
+
timeDimensionReference: joi_1.default.func().required().meta({ hidden: true }),
|
|
559
|
+
rollupReferences: joi_1.default.func().required().meta({ hidden: true }),
|
|
560
|
+
measureReferences: joi_1.default.func().meta({ hidden: true }),
|
|
561
|
+
dimensionReferences: joi_1.default.func().meta({ hidden: true }),
|
|
562
|
+
segmentReferences: joi_1.default.func().meta({ hidden: true }),
|
|
551
563
|
}),
|
|
552
564
|
// RollupJoin without references
|
|
553
565
|
inherit(BasePreAggregation, {
|
|
554
|
-
type: joi_1.default.any().valid('rollupJoin').required(),
|
|
555
|
-
scheduledRefresh: joi_1.default.boolean().valid(false),
|
|
556
|
-
granularity: GranularitySchema,
|
|
557
|
-
timeDimension: joi_1.default.func().required(),
|
|
558
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
559
|
-
rollups: joi_1.default.func().required(),
|
|
560
|
-
measures: joi_1.default.func(),
|
|
561
|
-
dimensions: joi_1.default.func(),
|
|
562
|
-
segments: joi_1.default.func(),
|
|
566
|
+
type: joi_1.default.any().valid('rollupJoin').required().description(preAggregationTypeDescription),
|
|
567
|
+
scheduledRefresh: joi_1.default.boolean().valid(false).description(rollupJoinScheduledRefreshDescription),
|
|
568
|
+
granularity: GranularitySchema.description('Time granularity for rollup pre-aggregations'),
|
|
569
|
+
timeDimension: joi_1.default.func().required().description('Time dimension reference for the pre-aggregation'),
|
|
570
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
571
|
+
rollups: joi_1.default.func().required().description('Rollup pre-aggregations to combine: joined for rollup_join, unioned for rollup_lambda'),
|
|
572
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
573
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
574
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
563
575
|
})), condition((s) => defined(s.rollupReferences), inherit(BasePreAggregation, {
|
|
564
|
-
type: joi_1.default.any().valid('rollupJoin').required(),
|
|
565
|
-
scheduledRefresh: joi_1.default.boolean().valid(false),
|
|
566
|
-
rollupReferences: joi_1.default.func().required(),
|
|
567
|
-
measureReferences: joi_1.default.func(),
|
|
568
|
-
dimensionReferences: joi_1.default.func(),
|
|
569
|
-
segmentReferences: joi_1.default.func(),
|
|
576
|
+
type: joi_1.default.any().valid('rollupJoin').required().description(preAggregationTypeDescription),
|
|
577
|
+
scheduledRefresh: joi_1.default.boolean().valid(false).description(rollupJoinScheduledRefreshDescription),
|
|
578
|
+
rollupReferences: joi_1.default.func().required().meta({ hidden: true }),
|
|
579
|
+
measureReferences: joi_1.default.func().meta({ hidden: true }),
|
|
580
|
+
dimensionReferences: joi_1.default.func().meta({ hidden: true }),
|
|
581
|
+
segmentReferences: joi_1.default.func().meta({ hidden: true }),
|
|
570
582
|
}),
|
|
571
583
|
// RollupJoin without references
|
|
572
584
|
condition((s) => defined(s.rollups), inherit(BasePreAggregation, {
|
|
573
|
-
type: joi_1.default.any().valid('rollupJoin').required(),
|
|
574
|
-
scheduledRefresh: joi_1.default.boolean().valid(false),
|
|
575
|
-
rollups: joi_1.default.func().required(),
|
|
576
|
-
measures: joi_1.default.func(),
|
|
577
|
-
dimensions: joi_1.default.func(),
|
|
578
|
-
segments: joi_1.default.func(),
|
|
585
|
+
type: joi_1.default.any().valid('rollupJoin').required().description(preAggregationTypeDescription),
|
|
586
|
+
scheduledRefresh: joi_1.default.boolean().valid(false).description(rollupJoinScheduledRefreshDescription),
|
|
587
|
+
rollups: joi_1.default.func().required().description('Rollup pre-aggregations to combine: joined for rollup_join, unioned for rollup_lambda'),
|
|
588
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
589
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
590
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
579
591
|
}), requireOneOf('granularity', 'rollups', 'timeDimension'))));
|
|
580
592
|
const RollupLambdaSchema = condition((s) => defined(s.granularity) || defined(s.timeDimension), {
|
|
581
|
-
type: joi_1.default.any().valid('rollupLambda').required(),
|
|
582
|
-
granularity: GranularitySchema,
|
|
583
|
-
timeDimension: joi_1.default.func().required(),
|
|
584
|
-
rollups: joi_1.default.func().required(),
|
|
585
|
-
measures: joi_1.default.func(),
|
|
586
|
-
dimensions: joi_1.default.func(),
|
|
587
|
-
segments: joi_1.default.func(),
|
|
588
|
-
unionWithSourceData: joi_1.default.boolean().strict(),
|
|
593
|
+
type: joi_1.default.any().valid('rollupLambda').required().description(preAggregationTypeDescription),
|
|
594
|
+
granularity: GranularitySchema.description('Time granularity for rollup pre-aggregations'),
|
|
595
|
+
timeDimension: joi_1.default.func().required().description('Time dimension reference for the pre-aggregation'),
|
|
596
|
+
rollups: joi_1.default.func().required().description('Rollup pre-aggregations to combine: joined for rollup_join, unioned for rollup_lambda'),
|
|
597
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
598
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
599
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
600
|
+
unionWithSourceData: joi_1.default.boolean().strict().description("Whether to add data newer than the last partition, read from the data source, to the pre-aggregation's results"),
|
|
589
601
|
}, {
|
|
590
|
-
type: joi_1.default.any().valid('rollupLambda').required(),
|
|
591
|
-
rollups: joi_1.default.func().required(),
|
|
592
|
-
measures: joi_1.default.func(),
|
|
593
|
-
dimensions: joi_1.default.func(),
|
|
594
|
-
segments: joi_1.default.func(),
|
|
595
|
-
unionWithSourceData: joi_1.default.boolean().strict(),
|
|
602
|
+
type: joi_1.default.any().valid('rollupLambda').required().description(preAggregationTypeDescription),
|
|
603
|
+
rollups: joi_1.default.func().required().description('Rollup pre-aggregations to combine: joined for rollup_join, unioned for rollup_lambda'),
|
|
604
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
605
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
606
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
607
|
+
unionWithSourceData: joi_1.default.boolean().strict().description("Whether to add data newer than the last partition, read from the data source, to the pre-aggregation's results"),
|
|
596
608
|
});
|
|
597
609
|
const RollUpSchema = condition((s) => defined(s.granularity) || defined(s.timeDimension) || defined(s.timeDimensions) || defined(s.timeDimensionReference), condition((s) => defined(s.timeDimensionReference), inherit(BasePreAggregation, {
|
|
598
|
-
type: joi_1.default.any().valid('rollup').required(),
|
|
599
|
-
timeDimensionReference: joi_1.default.func().required(),
|
|
600
|
-
granularity: GranularitySchema,
|
|
601
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
602
|
-
measureReferences: joi_1.default.func(),
|
|
603
|
-
dimensionReferences: joi_1.default.func(),
|
|
604
|
-
segmentReferences: joi_1.default.func(),
|
|
605
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
610
|
+
type: joi_1.default.any().valid('rollup').required().description(preAggregationTypeDescription),
|
|
611
|
+
timeDimensionReference: joi_1.default.func().required().meta({ hidden: true }),
|
|
612
|
+
granularity: GranularitySchema.description('Time granularity for rollup pre-aggregations'),
|
|
613
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
614
|
+
measureReferences: joi_1.default.func().meta({ hidden: true }),
|
|
615
|
+
dimensionReferences: joi_1.default.func().meta({ hidden: true }),
|
|
616
|
+
segmentReferences: joi_1.default.func().meta({ hidden: true }),
|
|
617
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
606
618
|
}), condition((s) => defined(s.timeDimension),
|
|
607
619
|
// Rollup without References postfix
|
|
608
620
|
inherit(BasePreAggregation, {
|
|
609
|
-
type: joi_1.default.any().valid('rollup').required(),
|
|
610
|
-
timeDimension: joi_1.default.func().required(),
|
|
611
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
612
|
-
granularity: GranularitySchema,
|
|
613
|
-
measures: joi_1.default.func(),
|
|
614
|
-
dimensions: joi_1.default.func(),
|
|
615
|
-
segments: joi_1.default.func(),
|
|
616
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
621
|
+
type: joi_1.default.any().valid('rollup').required().description(preAggregationTypeDescription),
|
|
622
|
+
timeDimension: joi_1.default.func().required().description('Time dimension reference for the pre-aggregation'),
|
|
623
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
624
|
+
granularity: GranularitySchema.description('Time granularity for rollup pre-aggregations'),
|
|
625
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
626
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
627
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
628
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
617
629
|
}),
|
|
618
630
|
// Rollup with multiple time dimensions
|
|
619
631
|
inherit(BasePreAggregation, {
|
|
620
|
-
type: joi_1.default.any().valid('rollup').required(),
|
|
632
|
+
type: joi_1.default.any().valid('rollup').required().description(preAggregationTypeDescription),
|
|
621
633
|
timeDimensions: joi_1.default.array().items(joi_1.default.object().keys({
|
|
622
|
-
dimension: joi_1.default.func(),
|
|
623
|
-
granularity: GranularitySchema,
|
|
624
|
-
})),
|
|
625
|
-
allowNonStrictDateRangeMatch: joi_1.default.bool(),
|
|
626
|
-
measures: joi_1.default.func(),
|
|
627
|
-
dimensions: joi_1.default.func(),
|
|
628
|
-
segments: joi_1.default.func(),
|
|
629
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
634
|
+
dimension: joi_1.default.func().description('Time dimension reference'),
|
|
635
|
+
granularity: GranularitySchema.description('Granularity of this time dimension'),
|
|
636
|
+
})).description('Time dimensions of the pre-aggregation, each with its own granularity. For rollup pre-aggregations only'),
|
|
637
|
+
allowNonStrictDateRangeMatch: joi_1.default.bool().description(allowNonStrictDateRangeMatchDescription),
|
|
638
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
639
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
640
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
641
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
630
642
|
}))), joi_1.default.alternatives().try(inherit(BasePreAggregation, {
|
|
631
|
-
type: joi_1.default.any().valid('rollup').required(),
|
|
632
|
-
measureReferences: joi_1.default.func(),
|
|
633
|
-
dimensionReferences: joi_1.default.func(),
|
|
634
|
-
segmentReferences: joi_1.default.func(),
|
|
635
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
643
|
+
type: joi_1.default.any().valid('rollup').required().description(preAggregationTypeDescription),
|
|
644
|
+
measureReferences: joi_1.default.func().meta({ hidden: true }),
|
|
645
|
+
dimensionReferences: joi_1.default.func().meta({ hidden: true }),
|
|
646
|
+
segmentReferences: joi_1.default.func().meta({ hidden: true }),
|
|
647
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
636
648
|
}),
|
|
637
649
|
// Rollup without References postfix
|
|
638
650
|
inherit(BasePreAggregation, {
|
|
639
|
-
type: joi_1.default.any().valid('rollup').required(),
|
|
640
|
-
measures: joi_1.default.func(),
|
|
641
|
-
dimensions: joi_1.default.func(),
|
|
642
|
-
segments: joi_1.default.func(),
|
|
643
|
-
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()),
|
|
651
|
+
type: joi_1.default.any().valid('rollup').required().description(preAggregationTypeDescription),
|
|
652
|
+
measures: joi_1.default.func().description('Measures to include in the pre-aggregation'),
|
|
653
|
+
dimensions: joi_1.default.func().description('Dimensions to include in the pre-aggregation'),
|
|
654
|
+
segments: joi_1.default.func().description('Segments to include in the pre-aggregation'),
|
|
655
|
+
uniqueKeyColumns: joi_1.default.array().items(joi_1.default.string()).description(uniqueKeyColumnsDescription),
|
|
644
656
|
})));
|
|
645
657
|
const PreAggregationsAlternatives = joi_1.default.object().pattern(identifierRegex, errorOnMixing(joi_1.default.alternatives().conditional(joi_1.default.ref('.type'), [
|
|
646
658
|
{ is: 'autoRollup', then: AutoRollupSchema },
|
|
@@ -650,34 +662,34 @@ const PreAggregationsAlternatives = joi_1.default.object().pattern(identifierReg
|
|
|
650
662
|
{ is: 'rollup',
|
|
651
663
|
then: RollUpSchema,
|
|
652
664
|
otherwise: joi_1.default.object().keys({
|
|
653
|
-
type: joi_1.default.string().valid('autoRollup', 'originalSql', 'rollupJoin', 'rollup').required()
|
|
665
|
+
type: joi_1.default.string().valid('autoRollup', 'originalSql', 'rollupJoin', 'rollup').required().description(preAggregationTypeDescription)
|
|
654
666
|
})
|
|
655
667
|
}
|
|
656
668
|
])));
|
|
657
669
|
const CubeRefreshKeySchema = condition((s) => defined(s.every), condition((s) => defined(s.sql), joi_1.default.object().keys({
|
|
658
|
-
sql: joi_1.default.func().required(),
|
|
670
|
+
sql: joi_1.default.func().required().description('SQL query to determine if refresh is needed'),
|
|
659
671
|
// We don't support timezone for this, because it's useless
|
|
660
672
|
// We cannot support cron interval
|
|
661
|
-
every: everyInterval,
|
|
673
|
+
every: everyInterval.description(refreshKeySqlEveryDescription),
|
|
662
674
|
}), joi_1.default.object().keys({
|
|
663
|
-
every: joi_1.default.alternatives().try(everyInterval, everyCronInterval).required(),
|
|
664
|
-
timezone: everyCronTimeZone,
|
|
675
|
+
every: joi_1.default.alternatives().try(everyInterval, everyCronInterval).required().description("Refresh interval (e.g., '1 hour', '1 day')"),
|
|
676
|
+
timezone: everyCronTimeZone.description('Timezone for refresh scheduling'),
|
|
665
677
|
})), condition((s) => defined(s.immutable), joi_1.default.object().keys({
|
|
666
|
-
immutable: joi_1.default.boolean().strict().required()
|
|
678
|
+
immutable: joi_1.default.boolean().strict().required().description('Has no effect: the cache refreshes on the default schedule. Use every or sql instead')
|
|
667
679
|
}), requireOneOf('every', 'sql', 'immutable')));
|
|
668
680
|
const measureType = joi_1.default.string().valid('number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox');
|
|
669
681
|
const measureTypeWithCount = joi_1.default.string().valid('count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox');
|
|
670
682
|
const multiStageMeasureType = joi_1.default.string().valid('count', 'number', 'string', 'boolean', 'time', 'sum', 'avg', 'min', 'max', 'countDistinct', 'countDistinctApprox', 'numberAgg', 'rank');
|
|
671
683
|
const timeShiftItemRequired = joi_1.default.object({
|
|
672
|
-
timeDimension: joi_1.default.func().required(),
|
|
673
|
-
interval: regexTimeInterval.required(),
|
|
674
|
-
type: joi_1.default.string().valid('next', 'prior').required(),
|
|
684
|
+
timeDimension: joi_1.default.func().required().description('The time dimension to apply the shift to. Optional with a single entry; Cube then infers it'),
|
|
685
|
+
interval: regexTimeInterval.required().description("The time interval to shift by (e.g., '1 year', '3 months', '1 week')"),
|
|
686
|
+
type: joi_1.default.string().valid('next', 'prior').required().description("Direction of time shift: 'prior' for past periods, 'next' for future periods"),
|
|
675
687
|
});
|
|
676
688
|
const timeShiftItemOptional = joi_1.default.object({
|
|
677
|
-
timeDimension: joi_1.default.func(), // not required
|
|
678
|
-
interval: regexTimeInterval,
|
|
679
|
-
name: identifier,
|
|
680
|
-
type: joi_1.default.string().valid('next', 'prior'),
|
|
689
|
+
timeDimension: joi_1.default.func().description('The time dimension to apply the shift to. Optional with a single entry; Cube then infers it'), // not required
|
|
690
|
+
interval: regexTimeInterval.description("The time interval to shift by (e.g., '1 year', '3 months', '1 week')"),
|
|
691
|
+
name: identifier.description("Name of a time shift declared on a calendar cube time dimension (e.g., 'prior_fiscal_year')"),
|
|
692
|
+
type: joi_1.default.string().valid('next', 'prior').description("Direction of time shift: 'prior' for past periods, 'next' for future periods"),
|
|
681
693
|
})
|
|
682
694
|
.xor('name', 'interval')
|
|
683
695
|
.and('interval', 'type');
|
|
@@ -689,121 +701,123 @@ const timeShiftItemOptional = joi_1.default.object({
|
|
|
689
701
|
// fail at runtime. Use the existing `accessPolicy.rowLevel.filters` if you
|
|
690
702
|
// need dynamic predicates resolved against the security context.
|
|
691
703
|
const MultiStageIncludeMemberFilterSchema = joi_1.default.object().keys({
|
|
692
|
-
member: joi_1.default.string().required(),
|
|
693
|
-
operator: joi_1.default.any().valid('equals', 'notEquals', 'contains', 'notContains', 'startsWith', 'notStartsWith', 'endsWith', 'notEndsWith', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'set', 'notSet', 'inDateRange', 'notInDateRange', 'onTheDate', 'beforeDate', 'beforeOrOnDate', 'afterDate', 'afterOrOnDate', 'measureFilter').required(),
|
|
704
|
+
member: joi_1.default.string().required().description('Member the filter applies to'),
|
|
705
|
+
operator: joi_1.default.any().valid('equals', 'notEquals', 'contains', 'notContains', 'startsWith', 'notStartsWith', 'endsWith', 'notEndsWith', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'set', 'notSet', 'inDateRange', 'notInDateRange', 'onTheDate', 'beforeDate', 'beforeOrOnDate', 'afterDate', 'afterOrOnDate', 'measureFilter').required().description('Filter operator, as in a query filter'),
|
|
694
706
|
values: joi_1.default.when('operator', {
|
|
695
707
|
is: joi_1.default.valid('set', 'notSet'),
|
|
696
708
|
then: joi_1.default.array().optional(),
|
|
697
709
|
otherwise: joi_1.default.array().required()
|
|
698
|
-
})
|
|
710
|
+
}).description(filterValuesDescription)
|
|
699
711
|
});
|
|
700
712
|
const MultiStageIncludeConditionSchema = joi_1.default.object().keys({
|
|
701
|
-
or: joi_1.default.array().items(MultiStageIncludeMemberFilterSchema, joi_1.default.link('...').description('Multi-stage include condition')),
|
|
702
|
-
and: joi_1.default.array().items(MultiStageIncludeMemberFilterSchema, joi_1.default.link('...').description('Multi-stage include condition')),
|
|
713
|
+
or: joi_1.default.array().items(MultiStageIncludeMemberFilterSchema, joi_1.default.link('...').description('Multi-stage include condition')).description('Predicates of which at least one must match'),
|
|
714
|
+
and: joi_1.default.array().items(MultiStageIncludeMemberFilterSchema, joi_1.default.link('...').description('Multi-stage include condition')).description('Predicates that must all match'),
|
|
703
715
|
}).xor('or', 'and');
|
|
704
716
|
const MultiStageFilter = joi_1.default.object().keys({
|
|
705
|
-
mode: joi_1.default.string().valid('relative', 'fixed'),
|
|
706
|
-
exclude: joi_1.default.func(),
|
|
707
|
-
keepOnly: joi_1.default.func(),
|
|
708
|
-
include: joi_1.default.array().items(MultiStageIncludeMemberFilterSchema, MultiStageIncludeConditionSchema),
|
|
717
|
+
mode: joi_1.default.string().valid('relative', 'fixed').description('How the override composes along a multi-stage chain: relative (default) or fixed'),
|
|
718
|
+
exclude: joi_1.default.func().description('Members whose query filters are dropped at the inner stage'),
|
|
719
|
+
keepOnly: joi_1.default.func().description('Members whose query filters are kept; all other inherited filters are dropped'),
|
|
720
|
+
include: joi_1.default.array().items(MultiStageIncludeMemberFilterSchema, MultiStageIncludeConditionSchema).description('Additional filters applied at the inner stage regardless of the query'),
|
|
709
721
|
}).nand('exclude', 'keepOnly');
|
|
710
722
|
const MultiStageGrain = joi_1.default.object().keys({
|
|
711
|
-
exclude: joi_1.default.func(),
|
|
712
|
-
keepOnly: joi_1.default.func(),
|
|
713
|
-
include: joi_1.default.func(),
|
|
723
|
+
exclude: joi_1.default.func().description("Group the inner stage by the query's dimensions minus these dimensions. Use for ranking within groups."),
|
|
724
|
+
keepOnly: joi_1.default.func().description("Group the inner stage by only these dimensions, ignoring the query's dimensions. Use for fixed-grain calculations such as percent of total."),
|
|
725
|
+
include: joi_1.default.func().description("Group the inner stage by the query's dimensions plus these dimensions. Use for nested aggregates (an aggregate of an aggregate)."),
|
|
714
726
|
}).nand('exclude', 'keepOnly');
|
|
715
727
|
const CaseSchema = joi_1.default.object().keys({
|
|
716
728
|
when: joi_1.default.array().items(joi_1.default.object().keys({
|
|
717
|
-
sql: joi_1.default.func().required(),
|
|
729
|
+
sql: joi_1.default.func().required().description("SQL condition; the first one that is true selects this entry's label"),
|
|
718
730
|
label: joi_1.default.alternatives([
|
|
719
731
|
joi_1.default.string(),
|
|
720
732
|
joi_1.default.object().keys({
|
|
721
|
-
sql: joi_1.default.func().required()
|
|
733
|
+
sql: joi_1.default.func().required().description('SQL expression for the label')
|
|
722
734
|
})
|
|
723
|
-
])
|
|
724
|
-
})),
|
|
735
|
+
]).description('Value to return when the condition matches: a string, or an object with a SQL expression')
|
|
736
|
+
})).description('Array of condition/value pairs'),
|
|
725
737
|
else: joi_1.default.object().keys({
|
|
726
738
|
label: joi_1.default.alternatives([
|
|
727
739
|
joi_1.default.string(),
|
|
728
740
|
joi_1.default.object().keys({
|
|
729
|
-
sql: joi_1.default.func().required()
|
|
741
|
+
sql: joi_1.default.func().required().description('SQL expression for the label')
|
|
730
742
|
})
|
|
731
|
-
])
|
|
732
|
-
})
|
|
743
|
+
]).description('Value to return when no condition matches: a string, or an object with a SQL expression')
|
|
744
|
+
}).description('Default value when no conditions match')
|
|
733
745
|
}).required();
|
|
734
746
|
const SwitchCaseSchema = joi_1.default.object().keys({
|
|
735
|
-
switch: joi_1.default.func().required(),
|
|
747
|
+
switch: joi_1.default.func().required().description('Dimension reference to evaluate for the switch condition'),
|
|
736
748
|
when: joi_1.default.array().items(joi_1.default.object().keys({
|
|
737
|
-
value: joi_1.default.string().required(),
|
|
738
|
-
sql: joi_1.default.func().required()
|
|
739
|
-
})),
|
|
749
|
+
value: joi_1.default.string().required().description('Value to match against the switch dimension'),
|
|
750
|
+
sql: joi_1.default.func().required().description('SQL expression returned when the switch dimension equals value')
|
|
751
|
+
})).description('Values of the switch dimension, each with the SQL expression it selects'),
|
|
740
752
|
else: joi_1.default.object().keys({
|
|
741
|
-
sql: joi_1.default.func().required()
|
|
742
|
-
})
|
|
753
|
+
sql: joi_1.default.func().required().description('SQL expression returned when the switch dimension matches no value')
|
|
754
|
+
}).description('Used when the switch dimension matches none of the when values')
|
|
743
755
|
}).required();
|
|
744
756
|
const CaseVariants = joi_1.default.alternatives().try(CaseSchema, SwitchCaseSchema);
|
|
745
757
|
const MeasuresSchema = joi_1.default.object().pattern(identifierRegex, joi_1.default.alternatives().conditional(joi_1.default.ref('.multiStage'), [
|
|
746
758
|
{
|
|
747
759
|
is: true,
|
|
748
760
|
then: inherit(BaseMeasure, {
|
|
749
|
-
multiStage: joi_1.default.boolean().strict(),
|
|
750
|
-
type: multiStageMeasureType.required(),
|
|
751
|
-
sql: joi_1.default.func(), // TODO .required(),
|
|
752
|
-
case: CaseVariants,
|
|
753
|
-
groupBy: joi_1.default.func(),
|
|
754
|
-
reduceBy: joi_1.default.func(),
|
|
755
|
-
addGroupBy: joi_1.default.func(),
|
|
756
|
-
filter: MultiStageFilter,
|
|
757
|
-
grain: MultiStageGrain,
|
|
761
|
+
multiStage: joi_1.default.boolean().strict().description('Enable multi-stage calculations for this measure. Required for time_shift, group_by, reduce_by, and rank type measures.'),
|
|
762
|
+
type: multiStageMeasureType.required().description('Type of the measure'),
|
|
763
|
+
sql: joi_1.default.func().description('SQL expression for the measure'), // TODO .required(),
|
|
764
|
+
case: CaseVariants.description("Conditional values: when/else pairs, or a switch on a dimension's values"),
|
|
765
|
+
groupBy: joi_1.default.func().description('Dimensions to group by for fixed dimension calculations (e.g., calculate revenue per country regardless of other groupings)'),
|
|
766
|
+
reduceBy: joi_1.default.func().description('Dimensions to reduce by for ranking calculations. The rank will be computed within each unique combination of non-reduced dimensions.'),
|
|
767
|
+
addGroupBy: joi_1.default.func().description('Additional dimensions to include in the inner aggregation stage while preserving query dimensions. Used for nested aggregate calculations in multi-stage measures.'),
|
|
768
|
+
filter: MultiStageFilter.description('Overrides the filters the inner aggregation stage of a multi-stage measure inherits from the query: exclude drops, keep_only keeps only, include adds. exclude and keep_only are mutually exclusive'),
|
|
769
|
+
grain: MultiStageGrain.description("Grain of a multi-stage measure's inner aggregation stage. Supersedes group_by (keep_only), reduce_by (exclude) and add_group_by (include). keep_only and exclude are mutually exclusive"),
|
|
758
770
|
timeShift: joi_1.default.alternatives().conditional(joi_1.default.array().length(1), {
|
|
759
771
|
then: joi_1.default.array().items(timeShiftItemOptional),
|
|
760
772
|
otherwise: joi_1.default.array().items(timeShiftItemRequired)
|
|
761
|
-
}),
|
|
773
|
+
}).description('Time shift configurations for period-over-period comparisons (e.g., compare to prior year). A single entry may reference a shift declared on a calendar cube time dimension by name; two or more entries must each spell out time_dimension, interval and type.'),
|
|
762
774
|
// TODO validate for order window functions
|
|
763
775
|
orderBy: joi_1.default.array().items(joi_1.default.object().keys({
|
|
764
|
-
sql: joi_1.default.func().required(),
|
|
765
|
-
dir: joi_1.default.string().valid('asc', 'desc')
|
|
766
|
-
})),
|
|
776
|
+
sql: joi_1.default.func().required().description("SQL expression or measure reference to order by (e.g., '{revenue}')"),
|
|
777
|
+
dir: joi_1.default.string().valid('asc', 'desc').description("Sort direction: 'asc' for ascending, 'desc' for descending")
|
|
778
|
+
})).description('Order by configurations for ranking measures. Determines the sort order for rank calculation.'),
|
|
767
779
|
})
|
|
768
780
|
}
|
|
769
781
|
]).conditional(joi_1.default.ref('.type'), [
|
|
770
782
|
{
|
|
771
783
|
is: 'count',
|
|
772
784
|
then: inherit(BaseMeasure, {
|
|
773
|
-
type: joi_1.default.any().valid('count').required(),
|
|
774
|
-
sql: joi_1.default.func(),
|
|
785
|
+
type: joi_1.default.any().valid('count').required().description('Type of the measure'),
|
|
786
|
+
sql: joi_1.default.func().description('SQL expression for the measure'),
|
|
775
787
|
})
|
|
776
788
|
},
|
|
777
789
|
{
|
|
778
790
|
is: measureType,
|
|
779
791
|
then: inherit(BaseMeasure, {
|
|
780
|
-
sql: joi_1.default.func().required(),
|
|
781
|
-
type: measureType.required()
|
|
792
|
+
sql: joi_1.default.func().required().description('SQL expression for the measure'),
|
|
793
|
+
type: measureType.required().description('Type of the measure')
|
|
782
794
|
}),
|
|
783
795
|
otherwise: joi_1.default.object().keys({
|
|
784
|
-
type: measureTypeWithCount.required()
|
|
796
|
+
type: measureTypeWithCount.required().description('Type of the measure')
|
|
785
797
|
})
|
|
786
798
|
}
|
|
787
799
|
]));
|
|
788
800
|
const CalendarTimeShiftItem = joi_1.default.alternatives().try(joi_1.default.object({
|
|
789
|
-
name: identifier.required(),
|
|
790
|
-
interval: regexTimeInterval.required(),
|
|
791
|
-
type: joi_1.default.string().valid('next', 'prior').required(),
|
|
801
|
+
name: identifier.required().description("Name identifier for this time shift (e.g., 'month_ago', 'year_ago')"),
|
|
802
|
+
interval: regexTimeInterval.required().description("The time interval to shift by (e.g., '1 month', '1 year')"),
|
|
803
|
+
type: joi_1.default.string().valid('next', 'prior').required().description("Direction of time shift: 'prior' for past periods, 'next' for future periods"),
|
|
792
804
|
sql: joi_1.default.forbidden()
|
|
793
805
|
}), joi_1.default.object({
|
|
794
|
-
name: identifier.required(),
|
|
795
|
-
sql: joi_1.default.func().required(),
|
|
806
|
+
name: identifier.required().description("Name identifier for this time shift (e.g., 'month_ago', 'year_ago')"),
|
|
807
|
+
sql: joi_1.default.func().required().description("Custom SQL expression to override default interval behavior (e.g., '{CUBE}.month_ago')"),
|
|
796
808
|
interval: joi_1.default.forbidden(),
|
|
797
809
|
type: joi_1.default.forbidden()
|
|
798
810
|
}), joi_1.default.object({
|
|
799
|
-
interval: regexTimeInterval.required(),
|
|
800
|
-
type: joi_1.default.string().valid('next', 'prior').required(),
|
|
801
|
-
sql: joi_1.default.func().required(),
|
|
811
|
+
interval: regexTimeInterval.required().description("The time interval to shift by (e.g., '1 month', '1 year')"),
|
|
812
|
+
type: joi_1.default.string().valid('next', 'prior').required().description("Direction of time shift: 'prior' for past periods, 'next' for future periods"),
|
|
813
|
+
sql: joi_1.default.func().required().description("Custom SQL expression to override default interval behavior (e.g., '{CUBE}.month_ago')"),
|
|
802
814
|
name: joi_1.default.forbidden()
|
|
803
815
|
}));
|
|
804
816
|
const SwitchDimension = joi_1.default.object({
|
|
805
|
-
type: joi_1.default.string().valid('switch').required(),
|
|
806
|
-
values: joi_1.default.array().items(joi_1.default.string()).min(1)
|
|
817
|
+
type: joi_1.default.string().valid('switch').required().description('Type of the dimension'),
|
|
818
|
+
values: joi_1.default.array().items(joi_1.default.string()).min(1)
|
|
819
|
+
.required()
|
|
820
|
+
.description("Predefined set of allowed values for switch dimensions. Required when type is 'switch'.")
|
|
807
821
|
});
|
|
808
822
|
const DimensionsSchema = joi_1.default.object().pattern(identifierRegex, joi_1.default.alternatives().conditional(joi_1.default.ref('.type'), {
|
|
809
823
|
is: 'switch',
|
|
@@ -811,65 +825,65 @@ const DimensionsSchema = joi_1.default.object().pattern(identifierRegex, joi_1.d
|
|
|
811
825
|
// Alternatives are tried in order and each miss builds a full error report, so the plain `sql`
|
|
812
826
|
// dimension, which most dimensions are, goes first. Order does not change what passes.
|
|
813
827
|
otherwise: joi_1.default.alternatives().try(inherit(BaseDimension, {
|
|
814
|
-
sql: joi_1.default.func().required(),
|
|
828
|
+
sql: joi_1.default.func().required().description('SQL expression for the dimension'),
|
|
815
829
|
}), inherit(BaseDimensionWithoutSubQuery, {
|
|
816
|
-
case: CaseVariants.required(),
|
|
817
|
-
multiStage: joi_1.default.boolean().strict(),
|
|
830
|
+
case: CaseVariants.required().description('Case statement for conditional dimension values'),
|
|
831
|
+
multiStage: joi_1.default.boolean().strict().description('Whether the dimension is computed in a multi-stage calculation'),
|
|
818
832
|
}), inherit(BaseDimensionWithoutSubQuery, {
|
|
819
833
|
latitude: joi_1.default.object().keys({
|
|
820
|
-
sql: joi_1.default.func().required()
|
|
821
|
-
}).required(),
|
|
834
|
+
sql: joi_1.default.func().required().description('SQL expression for the coordinate')
|
|
835
|
+
}).required().description('Latitude of a geo dimension. Use together with longitude instead of sql.'),
|
|
822
836
|
longitude: joi_1.default.object().keys({
|
|
823
|
-
sql: joi_1.default.func().required()
|
|
824
|
-
}).required()
|
|
837
|
+
sql: joi_1.default.func().required().description('SQL expression for the coordinate')
|
|
838
|
+
}).required().description('Longitude of a geo dimension. Use together with latitude instead of sql.')
|
|
825
839
|
}), inherit(BaseDimension, {
|
|
826
|
-
multiStage: joi_1.default.boolean().valid(true),
|
|
827
|
-
sql: joi_1.default.func().required(),
|
|
828
|
-
addGroupBy: joi_1.default.func(),
|
|
829
|
-
filter: MultiStageFilter,
|
|
840
|
+
multiStage: joi_1.default.boolean().valid(true).description('Whether the dimension is computed in a multi-stage calculation. Required for add_group_by and filter'),
|
|
841
|
+
sql: joi_1.default.func().required().description('SQL expression for the dimension'),
|
|
842
|
+
addGroupBy: joi_1.default.func().description('Dimensions to add to the inner aggregation stage of this multi-stage dimension'),
|
|
843
|
+
filter: MultiStageFilter.description('Overrides the filters the inner aggregation stage of this multi-stage dimension inherits from the query: exclude drops, keep_only keeps only, include adds'),
|
|
830
844
|
}),
|
|
831
845
|
// TODO should be valid only for calendar cubes, but this requires significant refactoring
|
|
832
846
|
// of all schemas. Left for the future when we'll switch to zod.
|
|
833
847
|
inherit(BaseDimensionWithoutSubQuery, {
|
|
834
|
-
type: joi_1.default.any().valid('time').required(),
|
|
835
|
-
sql: joi_1.default.func().required(),
|
|
836
|
-
timeShift: joi_1.default.array().items(CalendarTimeShiftItem),
|
|
848
|
+
type: joi_1.default.any().valid('time').required().description('Type of the dimension'),
|
|
849
|
+
sql: joi_1.default.func().required().description('SQL expression for the dimension'),
|
|
850
|
+
timeShift: joi_1.default.array().items(CalendarTimeShiftItem).description('Time shift configurations for calendar cube time dimensions (e.g., month_ago, year_ago)'),
|
|
837
851
|
}))
|
|
838
852
|
}));
|
|
839
853
|
const SegmentsSchema = joi_1.default.object().pattern(identifierRegex, joi_1.default.object().keys({
|
|
840
|
-
aliases: joi_1.default.array().items(joi_1.default.string()),
|
|
841
|
-
sql: joi_1.default.func().required(),
|
|
842
|
-
title: joi_1.default.string(),
|
|
843
|
-
description: joi_1.default.string(),
|
|
844
|
-
meta: joi_1.default.any(),
|
|
845
|
-
shown: joi_1.default.boolean().strict(),
|
|
846
|
-
public: joi_1.default.boolean().strict(),
|
|
854
|
+
aliases: joi_1.default.array().items(joi_1.default.string()).description('Other names for this segment'),
|
|
855
|
+
sql: joi_1.default.func().required().description('SQL expression for the segment filter'),
|
|
856
|
+
title: joi_1.default.string().description('Display title for the segment'),
|
|
857
|
+
description: joi_1.default.string().description('Description of what this segment represents'),
|
|
858
|
+
meta: joi_1.default.any().description('Additional metadata for the segment'),
|
|
859
|
+
shown: joi_1.default.boolean().strict().description(sameAsPublicDescription),
|
|
860
|
+
public: joi_1.default.boolean().strict().description('Whether this segment is publicly accessible'),
|
|
847
861
|
}));
|
|
848
862
|
const PolicyFilterSchema = joi_1.default.object().keys({
|
|
849
|
-
member: joi_1.default.func().required(),
|
|
850
|
-
memberReference: joi_1.default.string(),
|
|
851
|
-
operator: joi_1.default.any().valid('equals', 'notEquals', 'contains', 'notContains', 'startsWith', 'notStartsWith', 'endsWith', 'notEndsWith', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'set', 'notSet', 'inDateRange', 'notInDateRange', 'onTheDate', 'beforeDate', 'beforeOrOnDate', 'afterDate', 'afterOrOnDate', 'measureFilter').required(),
|
|
863
|
+
member: joi_1.default.func().required().description('Reference to the dimension or measure to filter on'),
|
|
864
|
+
memberReference: joi_1.default.string().meta({ hidden: true }),
|
|
865
|
+
operator: joi_1.default.any().valid('equals', 'notEquals', 'contains', 'notContains', 'startsWith', 'notStartsWith', 'endsWith', 'notEndsWith', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'set', 'notSet', 'inDateRange', 'notInDateRange', 'onTheDate', 'beforeDate', 'beforeOrOnDate', 'afterDate', 'afterOrOnDate', 'measureFilter').required().description('Filter operator'),
|
|
852
866
|
values: joi_1.default.when('operator', {
|
|
853
867
|
is: joi_1.default.valid('set', 'notSet'),
|
|
854
868
|
then: joi_1.default.func().optional(),
|
|
855
869
|
otherwise: joi_1.default.func().required()
|
|
856
|
-
})
|
|
870
|
+
}).description(`${filterValuesDescription}. Can use the security context with { securityContext.property } syntax`)
|
|
857
871
|
});
|
|
858
872
|
const PolicyFilterConditionSchema = joi_1.default.object().keys({
|
|
859
|
-
or: joi_1.default.array().items(PolicyFilterSchema, joi_1.default.link('...').description('Filter Condition schema')),
|
|
860
|
-
and: joi_1.default.array().items(PolicyFilterSchema, joi_1.default.link('...').description('Filter Condition schema')),
|
|
873
|
+
or: joi_1.default.array().items(PolicyFilterSchema, joi_1.default.link('...').description('Filter Condition schema')).description('Filters of which at least one must match'),
|
|
874
|
+
and: joi_1.default.array().items(PolicyFilterSchema, joi_1.default.link('...').description('Filter Condition schema')).description('Filters that must all match'),
|
|
861
875
|
}).xor('or', 'and');
|
|
862
876
|
const MemberLevelPolicySchema = joi_1.default.object().keys({
|
|
863
877
|
includes: joi_1.default.alternatives([
|
|
864
878
|
joi_1.default.string().valid('*'),
|
|
865
879
|
joi_1.default.array().items(joi_1.default.string())
|
|
866
|
-
]),
|
|
880
|
+
]).description('Members to include in access'),
|
|
867
881
|
excludes: joi_1.default.alternatives([
|
|
868
882
|
joi_1.default.string().valid('*'),
|
|
869
883
|
joi_1.default.array().items(joi_1.default.string().required())
|
|
870
|
-
]),
|
|
871
|
-
includesMembers: joi_1.default.array().items(joi_1.default.string().required()),
|
|
872
|
-
excludesMembers: joi_1.default.array().items(joi_1.default.string().required()),
|
|
884
|
+
]).description('Members to exclude from access'),
|
|
885
|
+
includesMembers: joi_1.default.array().items(joi_1.default.string().required()).meta({ hidden: true }),
|
|
886
|
+
excludesMembers: joi_1.default.array().items(joi_1.default.string().required()).meta({ hidden: true }),
|
|
873
887
|
})
|
|
874
888
|
// `includes` defaults to '*' in CubeEvaluator.prepareAccessPolicy, so an empty
|
|
875
889
|
// memberLevel grants every member — the opposite of how it reads.
|
|
@@ -881,27 +895,27 @@ const MemberMaskingPolicySchema = joi_1.default.object().keys({
|
|
|
881
895
|
includes: joi_1.default.alternatives([
|
|
882
896
|
joi_1.default.string().valid('*'),
|
|
883
897
|
joi_1.default.array().items(joi_1.default.string())
|
|
884
|
-
]),
|
|
898
|
+
]).description("Members to mask, or '*' for all members"),
|
|
885
899
|
excludes: joi_1.default.alternatives([
|
|
886
900
|
joi_1.default.string().valid('*'),
|
|
887
901
|
joi_1.default.array().items(joi_1.default.string().required())
|
|
888
|
-
]),
|
|
889
|
-
includesMembers: joi_1.default.array().items(joi_1.default.string().required()),
|
|
890
|
-
excludesMembers: joi_1.default.array().items(joi_1.default.string().required()),
|
|
902
|
+
]).description('Members not to mask'),
|
|
903
|
+
includesMembers: joi_1.default.array().items(joi_1.default.string().required()).meta({ hidden: true }),
|
|
904
|
+
excludesMembers: joi_1.default.array().items(joi_1.default.string().required()).meta({ hidden: true }),
|
|
891
905
|
});
|
|
892
906
|
const RowLevelPolicySchema = joi_1.default.object().keys({
|
|
893
|
-
filters: joi_1.default.array().items(PolicyFilterSchema, PolicyFilterConditionSchema),
|
|
894
|
-
allowAll: joi_1.default.boolean().valid(true).strict(),
|
|
907
|
+
filters: joi_1.default.array().items(PolicyFilterSchema, PolicyFilterConditionSchema).description('Filters to apply for row-level security'),
|
|
908
|
+
allowAll: joi_1.default.boolean().valid(true).strict().description("Grant access to all rows. Mutually exclusive with 'filters'"),
|
|
895
909
|
}).xor('filters', 'allowAll');
|
|
896
910
|
const GroupPolicySchema = joi_1.default.object().keys({
|
|
897
|
-
group: joi_1.default.string(),
|
|
898
|
-
groups: joi_1.default.array().items(joi_1.default.string()),
|
|
899
|
-
memberLevel: MemberLevelPolicySchema,
|
|
900
|
-
memberMasking: MemberMaskingPolicySchema,
|
|
901
|
-
rowLevel: RowLevelPolicySchema,
|
|
911
|
+
group: joi_1.default.string().description("The user group this policy applies to. Use '*' to match all users"),
|
|
912
|
+
groups: joi_1.default.array().items(joi_1.default.string()).description('The user groups this policy applies to. An array of group names.'),
|
|
913
|
+
memberLevel: MemberLevelPolicySchema.description('Members the policy grants access to'),
|
|
914
|
+
memberMasking: MemberMaskingPolicySchema.description('Member-level data masking configuration for sensitive fields'),
|
|
915
|
+
rowLevel: RowLevelPolicySchema.description('Rows the policy grants access to'),
|
|
902
916
|
conditions: joi_1.default.array().items(joi_1.default.object().keys({
|
|
903
|
-
if: joi_1.default.func().required(),
|
|
904
|
-
})),
|
|
917
|
+
if: joi_1.default.func().required().description('Expression evaluated with the security context, returning true or false'),
|
|
918
|
+
})).description('Conditions that must all be true for this policy to take effect'),
|
|
905
919
|
})
|
|
906
920
|
.nand('group', 'groups') // Cannot have both group and groups
|
|
907
921
|
.or('group', 'groups') // Must have at least one
|
|
@@ -913,64 +927,64 @@ const GroupPolicySchema = joi_1.default.object().keys({
|
|
|
913
927
|
* and update CubePropContextTranspiler.transpiledFieldsPatterns
|
|
914
928
|
**************************** */
|
|
915
929
|
const hierarchySchema = joi_1.default.object().pattern(identifierRegex, joi_1.default.object().keys({
|
|
916
|
-
title: joi_1.default.string(),
|
|
917
|
-
public: joi_1.default.boolean().strict(),
|
|
918
|
-
levels: joi_1.default.func()
|
|
930
|
+
title: joi_1.default.string().description('Human-readable display title for the hierarchy'),
|
|
931
|
+
public: joi_1.default.boolean().strict().description('Whether this hierarchy is publicly accessible'),
|
|
932
|
+
levels: joi_1.default.func().description("Dimension names in hierarchical order (can include joined dimensions like 'orders.status')")
|
|
919
933
|
}));
|
|
920
934
|
const baseSchema = {
|
|
921
|
-
name: identifier,
|
|
922
|
-
refreshKey: CubeRefreshKeySchema,
|
|
923
|
-
fileName: joi_1.default.string().required(),
|
|
924
|
-
extends: joi_1.default.func(),
|
|
925
|
-
allDefinitions: joi_1.default.func(), // Helpers function for extending
|
|
926
|
-
rawFolders: joi_1.default.func(), // Helpers function for extending
|
|
927
|
-
rawCubes: joi_1.default.func(), // Helpers function for extending
|
|
928
|
-
title: joi_1.default.string(),
|
|
929
|
-
sqlAlias: joi_1.default.string(),
|
|
930
|
-
dataSource: joi_1.default.string(),
|
|
931
|
-
description: joi_1.default.string(),
|
|
932
|
-
rewriteQueries: joi_1.default.boolean().strict(),
|
|
933
|
-
shown: joi_1.default.boolean().strict(),
|
|
934
|
-
public: joi_1.default.boolean().strict(),
|
|
935
|
-
meta: joi_1.default.any(),
|
|
935
|
+
name: identifier.description('Unique name of the cube or view'),
|
|
936
|
+
refreshKey: CubeRefreshKeySchema.description('When the cache of the cube or view is refreshed: on a schedule (every) or when a SQL result changes (sql)'),
|
|
937
|
+
fileName: joi_1.default.string().required().meta({ setByCompiler: true }),
|
|
938
|
+
extends: joi_1.default.func().description('Name of the cube or view this one extends'),
|
|
939
|
+
allDefinitions: joi_1.default.func().meta({ setByCompiler: true }), // Helpers function for extending
|
|
940
|
+
rawFolders: joi_1.default.func().meta({ setByCompiler: true }), // Helpers function for extending
|
|
941
|
+
rawCubes: joi_1.default.func().meta({ setByCompiler: true }), // Helpers function for extending
|
|
942
|
+
title: joi_1.default.string().description('Display title'),
|
|
943
|
+
sqlAlias: joi_1.default.string().description('Short alias used in generated SQL, for databases that truncate long names'),
|
|
944
|
+
dataSource: joi_1.default.string().description('Name of the data source to read from'),
|
|
945
|
+
description: joi_1.default.string().description('Description of what this cube or view represents'),
|
|
946
|
+
rewriteQueries: joi_1.default.boolean().strict().description('Whether a cube sql of the form SELECT * FROM table WHERE … is inlined: Cube queries the table directly and moves the conditions into the generated query'),
|
|
947
|
+
shown: joi_1.default.boolean().strict().description(sameAsPublicDescription),
|
|
948
|
+
public: joi_1.default.boolean().strict().description('Whether this cube or view is publicly accessible'),
|
|
949
|
+
meta: joi_1.default.any().description('Additional custom metadata'),
|
|
936
950
|
joins: joi_1.default.alternatives([
|
|
937
951
|
joi_1.default.object().pattern(identifierRegex, joi_1.default.object().keys({
|
|
938
|
-
sql: joi_1.default.func().required(),
|
|
939
|
-
relationship: joi_1.default.any().valid('belongsTo', 'belongs_to', 'many_to_one', 'manyToOne', 'hasMany', 'has_many', 'one_to_many', 'oneToMany', 'hasOne', 'has_one', 'one_to_one', 'oneToOne').required()
|
|
952
|
+
sql: joi_1.default.func().required().description('SQL join condition'),
|
|
953
|
+
relationship: joi_1.default.any().valid('belongsTo', 'belongs_to', 'many_to_one', 'manyToOne', 'hasMany', 'has_many', 'one_to_many', 'oneToMany', 'hasOne', 'has_one', 'one_to_one', 'oneToOne').required().description('Type of join relationship: one_to_one, one_to_many or many_to_one. The older names has_one, has_many and belongs_to also work')
|
|
940
954
|
})),
|
|
941
955
|
joi_1.default.array().items(joi_1.default.object().keys({
|
|
942
|
-
name: identifier.required(),
|
|
943
|
-
alias: identifier,
|
|
944
|
-
sql: joi_1.default.func().required(),
|
|
945
|
-
relationship: joi_1.default.any().valid('belongsTo', 'belongs_to', 'many_to_one', 'manyToOne', 'hasMany', 'has_many', 'one_to_many', 'oneToMany', 'hasOne', 'has_one', 'one_to_one', 'oneToOne').required()
|
|
956
|
+
name: identifier.required().description('Name of the cube to join'),
|
|
957
|
+
alias: identifier.description('Own name for this join, so the same cube can be joined more than once on different columns'),
|
|
958
|
+
sql: joi_1.default.func().required().description('SQL join condition'),
|
|
959
|
+
relationship: joi_1.default.any().valid('belongsTo', 'belongs_to', 'many_to_one', 'manyToOne', 'hasMany', 'has_many', 'one_to_many', 'oneToMany', 'hasOne', 'has_one', 'one_to_one', 'oneToOne').required().description('Type of join relationship: one_to_one, one_to_many or many_to_one. The older names has_one, has_many and belongs_to also work')
|
|
946
960
|
}))
|
|
947
|
-
]),
|
|
948
|
-
measures: MeasuresSchema,
|
|
949
|
-
dimensions: DimensionsSchema,
|
|
950
|
-
segments: SegmentsSchema,
|
|
951
|
-
preAggregations: PreAggregationsAlternatives,
|
|
952
|
-
accessPolicy: joi_1.default.array().items(GroupPolicySchema.required()),
|
|
953
|
-
hierarchies: hierarchySchema,
|
|
961
|
+
]).description('Joins to other cubes'),
|
|
962
|
+
measures: MeasuresSchema.description('Measure definitions'),
|
|
963
|
+
dimensions: DimensionsSchema.description('Dimension definitions'),
|
|
964
|
+
segments: SegmentsSchema.description('Segment definitions'),
|
|
965
|
+
preAggregations: PreAggregationsAlternatives.description('Pre-aggregation definitions for performance optimization'),
|
|
966
|
+
accessPolicy: joi_1.default.array().items(GroupPolicySchema.required()).description('Access policies that control who sees which members and rows'),
|
|
967
|
+
hierarchies: hierarchySchema.description('Hierarchies for drill-down functionality'),
|
|
954
968
|
};
|
|
955
969
|
const cubeSchema = inherit(baseSchema, {
|
|
956
|
-
sql: joi_1.default.func(),
|
|
957
|
-
sqlTable: joi_1.default.func(),
|
|
958
|
-
calendar: joi_1.default.boolean().strict(),
|
|
970
|
+
sql: joi_1.default.func().description('SQL query whose result is the table the cube queries; use instead of sql_table'),
|
|
971
|
+
sqlTable: joi_1.default.func().description('Database table name for the cube'),
|
|
972
|
+
calendar: joi_1.default.boolean().strict().description('Designates this cube as a calendar cube, enabling custom time shifts and granularities for fiscal calendars and other non-standard time calculations.'),
|
|
959
973
|
}).xor('sql', 'sqlTable').messages({
|
|
960
974
|
'object.xor': 'You must use either sql or sqlTable within a model, but not both'
|
|
961
975
|
});
|
|
962
976
|
const folderSchema = joi_1.default.object().keys({
|
|
963
|
-
name: joi_1.default.string().required(),
|
|
977
|
+
name: joi_1.default.string().required().description('Name of the folder'),
|
|
964
978
|
includes: joi_1.default.alternatives([
|
|
965
979
|
joi_1.default.string().valid('*'),
|
|
966
980
|
joi_1.default.array().items(joi_1.default.alternatives([
|
|
967
981
|
joi_1.default.string().required(),
|
|
968
982
|
joi_1.default.object().keys({
|
|
969
|
-
joinPath: joi_1.default.func().required(),
|
|
983
|
+
joinPath: joi_1.default.func().required().description('Join path of a cube in the view; the folder includes the members the view takes from it'),
|
|
970
984
|
}),
|
|
971
985
|
joi_1.default.link('#folderSchema'), // Can contain nested folders
|
|
972
986
|
])),
|
|
973
|
-
]).required(),
|
|
987
|
+
]).required().description('Members to include in this folder (can be member names or nested folders)'),
|
|
974
988
|
}).id('folderSchema');
|
|
975
989
|
// A view group's `includes`: a function, or an array of view references
|
|
976
990
|
// (string/function) and nested view group definitions (resolved via the shared
|
|
@@ -989,21 +1003,21 @@ const viewGroupIncludesSchema = joi_1.default.alternatives([
|
|
|
989
1003
|
// is meaningless here, so neither is accepted. Enforcing this at validation
|
|
990
1004
|
// time prevents nested groups from being silently dropped by the evaluator.
|
|
991
1005
|
const nestedViewGroupSchema = joi_1.default.object().keys({
|
|
992
|
-
name: joi_1.default.string().required(),
|
|
993
|
-
title: joi_1.default.string(),
|
|
994
|
-
description: joi_1.default.string(),
|
|
995
|
-
includes: viewGroupIncludesSchema.required(),
|
|
1006
|
+
name: joi_1.default.string().required().description('Name of the nested view group'),
|
|
1007
|
+
title: joi_1.default.string().description('Display title for the view group'),
|
|
1008
|
+
description: joi_1.default.string().description('Description of what this view group represents'),
|
|
1009
|
+
includes: viewGroupIncludesSchema.required().description('Views and nested view groups in this group'),
|
|
996
1010
|
})
|
|
997
1011
|
.id('nestedViewGroupSchema');
|
|
998
1012
|
const viewGroupSchema = joi_1.default.object().keys({
|
|
999
|
-
name: joi_1.default.string().required(),
|
|
1000
|
-
title: joi_1.default.string(),
|
|
1001
|
-
description: joi_1.default.string(),
|
|
1013
|
+
name: joi_1.default.string().required().description('Unique name of the view group'),
|
|
1014
|
+
title: joi_1.default.string().description('Display title for the view group'),
|
|
1015
|
+
description: joi_1.default.string().description('Description of what this view group represents'),
|
|
1002
1016
|
// Legacy way of including views into a group, kept for backward compatibility.
|
|
1003
|
-
views: joi_1.default.alternatives([joi_1.default.array().items(joi_1.default.string().required()), joi_1.default.func()]),
|
|
1017
|
+
views: joi_1.default.alternatives([joi_1.default.array().items(joi_1.default.string().required()), joi_1.default.func()]).description('Names of the views in this group. Older spelling of includes'),
|
|
1004
1018
|
// Preferred way of including views (and nested view groups) into a group.
|
|
1005
|
-
includes: viewGroupIncludesSchema,
|
|
1006
|
-
fileName: joi_1.default.string(),
|
|
1019
|
+
includes: viewGroupIncludesSchema.description('Views to include in this group (can be view names or nested view groups)'),
|
|
1020
|
+
fileName: joi_1.default.string().meta({ setByCompiler: true }),
|
|
1007
1021
|
})
|
|
1008
1022
|
.oxor('views', 'includes')
|
|
1009
1023
|
.messages({
|
|
@@ -1013,44 +1027,44 @@ const viewGroupSchema = joi_1.default.object().keys({
|
|
|
1013
1027
|
.shared(nestedViewGroupSchema)
|
|
1014
1028
|
.id('viewGroupSchema');
|
|
1015
1029
|
const ViewDefaultFilterSchema = joi_1.default.object().keys({
|
|
1016
|
-
member: joi_1.default.func().required(),
|
|
1017
|
-
operator: joi_1.default.any().valid('equals', 'notEquals', 'contains', 'notContains', 'startsWith', 'notStartsWith', 'endsWith', 'notEndsWith', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'set', 'notSet', 'inDateRange', 'notInDateRange', 'onTheDate', 'beforeDate', 'beforeOrOnDate', 'afterDate', 'afterOrOnDate').required(),
|
|
1030
|
+
member: joi_1.default.func().required().description('Name of the dimension to filter on; must be exposed by the view'),
|
|
1031
|
+
operator: joi_1.default.any().valid('equals', 'notEquals', 'contains', 'notContains', 'startsWith', 'notStartsWith', 'endsWith', 'notEndsWith', 'in', 'notIn', 'gt', 'gte', 'lt', 'lte', 'set', 'notSet', 'inDateRange', 'notInDateRange', 'onTheDate', 'beforeDate', 'beforeOrOnDate', 'afterDate', 'afterOrOnDate').required().description('Filter operator'),
|
|
1018
1032
|
values: joi_1.default.when('operator', {
|
|
1019
1033
|
is: joi_1.default.valid('set', 'notSet'),
|
|
1020
1034
|
then: joi_1.default.func().optional(),
|
|
1021
1035
|
otherwise: joi_1.default.func().required()
|
|
1022
|
-
}),
|
|
1023
|
-
unless: joi_1.default.func(),
|
|
1036
|
+
}).description(filterValuesDescription),
|
|
1037
|
+
unless: joi_1.default.func().description('Members that, when referenced in a query, release this default filter'),
|
|
1024
1038
|
});
|
|
1025
1039
|
const viewSchema = inherit(baseSchema, {
|
|
1026
|
-
isView: joi_1.default.boolean().strict(),
|
|
1027
|
-
viewGroup: joi_1.default.alternatives([joi_1.default.string(), joi_1.default.func()]),
|
|
1028
|
-
viewGroups: joi_1.default.alternatives([joi_1.default.array().items(joi_1.default.string().required()), joi_1.default.func()]),
|
|
1040
|
+
isView: joi_1.default.boolean().strict().meta({ setByCompiler: true }),
|
|
1041
|
+
viewGroup: joi_1.default.alternatives([joi_1.default.string(), joi_1.default.func()]).description('Name of the view group this view belongs to'),
|
|
1042
|
+
viewGroups: joi_1.default.alternatives([joi_1.default.array().items(joi_1.default.string().required()), joi_1.default.func()]).description('Names of the view groups this view belongs to'),
|
|
1029
1043
|
cubes: joi_1.default.array().items(joi_1.default.object().keys({
|
|
1030
|
-
joinPath: joi_1.default.func().required(),
|
|
1031
|
-
prefix: joi_1.default.boolean(),
|
|
1032
|
-
split: joi_1.default.boolean(),
|
|
1033
|
-
alias: joi_1.default.string(),
|
|
1044
|
+
joinPath: joi_1.default.func().required().description("The path to the cube, including any joins. Use cube name for direct access (e.g., 'Events') or dot notation for joined cubes (e.g., 'Events.Users')"),
|
|
1045
|
+
prefix: joi_1.default.boolean().description('Whether to prefix the included members with the cube name'),
|
|
1046
|
+
split: joi_1.default.boolean().description("Whether to expose this cube's members in a separate view named <view>_<cube>"),
|
|
1047
|
+
alias: joi_1.default.string().description("Name of the cube in this view: the prefix of its members when prefix is true, and the end of a split view's name. Defaults to the last part of join_path"),
|
|
1034
1048
|
includes: joi_1.default.alternatives([
|
|
1035
1049
|
joi_1.default.string().valid('*'),
|
|
1036
1050
|
joi_1.default.array().items(joi_1.default.alternatives([
|
|
1037
1051
|
joi_1.default.string().required(),
|
|
1038
1052
|
joi_1.default.object().keys({
|
|
1039
|
-
name: identifier.required(),
|
|
1040
|
-
alias: identifier,
|
|
1041
|
-
title: joi_1.default.string(),
|
|
1042
|
-
description: joi_1.default.string(),
|
|
1043
|
-
format: formatSchema,
|
|
1044
|
-
meta: joi_1.default.any(),
|
|
1053
|
+
name: identifier.required().description('Name of the member to include'),
|
|
1054
|
+
alias: identifier.description('Name the member gets in the view'),
|
|
1055
|
+
title: joi_1.default.string().description('Override the display title of the included member'),
|
|
1056
|
+
description: joi_1.default.string().description('Override the description of the included member'),
|
|
1057
|
+
format: formatSchema.description('Override the display format of the included member'),
|
|
1058
|
+
meta: joi_1.default.any().description('Override the metadata of the included member as a whole'),
|
|
1045
1059
|
})
|
|
1046
1060
|
]))
|
|
1047
|
-
]).required(),
|
|
1048
|
-
excludes: joi_1.default.array().items(joi_1.default.string().required()),
|
|
1061
|
+
]).required().description("Specify which members to include from the cube. Use '*' for all members, or an array of member names/objects with aliases"),
|
|
1062
|
+
excludes: joi_1.default.array().items(joi_1.default.string().required()).description('Members to exclude from the cube'),
|
|
1049
1063
|
}).oxor('split', 'prefix').messages({
|
|
1050
1064
|
'object.oxor': 'Using split together with prefix is not supported'
|
|
1051
|
-
})),
|
|
1052
|
-
folders: joi_1.default.array().items(folderSchema),
|
|
1053
|
-
defaultFilters: joi_1.default.array().items(ViewDefaultFilterSchema),
|
|
1065
|
+
})).description('List of cubes to include in the view'),
|
|
1066
|
+
folders: joi_1.default.array().items(folderSchema).description('Folders for organizing view members into logical groups'),
|
|
1067
|
+
defaultFilters: joi_1.default.array().items(ViewDefaultFilterSchema).description('Default filters applied to every query against the view'),
|
|
1054
1068
|
});
|
|
1055
1069
|
function formatErrorMessageFromDetails(explain, d) {
|
|
1056
1070
|
if (d?.context?.details) {
|
|
@@ -1105,6 +1119,15 @@ function functionFieldsPatterns() {
|
|
|
1105
1119
|
collectFunctionFieldsPatterns(functionPatterns, '', { ...cubeSchema, ...viewSchema });
|
|
1106
1120
|
return Array.from(functionPatterns);
|
|
1107
1121
|
}
|
|
1122
|
+
// Joi's own description of the model schemas, for generating the model-language manifest.
|
|
1123
|
+
// The JSON round trip drops the functions `.custom()` keeps in its args, leaving plain data.
|
|
1124
|
+
function describeModelSchemas() {
|
|
1125
|
+
return JSON.parse(JSON.stringify({
|
|
1126
|
+
cube: cubeSchema.describe(),
|
|
1127
|
+
view: viewSchema.describe(),
|
|
1128
|
+
viewGroup: viewGroupSchema.describe(),
|
|
1129
|
+
}));
|
|
1130
|
+
}
|
|
1108
1131
|
// Model objects come from the VM context, whose Object.prototype isn't this realm's, so the
|
|
1109
1132
|
// prototype walk stops at whichever realm's Object.prototype it reaches
|
|
1110
1133
|
const isRootPrototype = (o) => Object.getPrototypeOf(o) === null && Object.prototype.hasOwnProperty.call(o, 'hasOwnProperty');
|