@hypequery/protocol 0.14.0 → 0.16.0
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/deployments/codec.d.ts +8 -1
- package/dist/deployments/codec.d.ts.map +1 -1
- package/dist/deployments/codec.js +12 -4
- package/dist/deployments/index.d.ts +4 -4
- package/dist/deployments/index.d.ts.map +1 -1
- package/dist/deployments/index.js +2 -2
- package/dist/deployments/segments.d.ts +21 -0
- package/dist/deployments/segments.d.ts.map +1 -0
- package/dist/deployments/segments.js +57 -0
- package/dist/deployments/types.d.ts +71 -1
- package/dist/deployments/types.d.ts.map +1 -1
- package/dist/deployments/validate.d.ts +11 -1
- package/dist/deployments/validate.d.ts.map +1 -1
- package/dist/deployments/validate.js +205 -22
- package/dist/expressions/index.d.ts +1 -1
- package/dist/expressions/index.d.ts.map +1 -1
- package/dist/expressions/types.d.ts +29 -3
- package/dist/expressions/types.d.ts.map +1 -1
- package/dist/expressions/validate.d.ts.map +1 -1
- package/dist/expressions/validate.js +38 -9
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/invocations/index.d.ts +2 -2
- package/dist/invocations/index.d.ts.map +1 -1
- package/dist/invocations/index.js +1 -1
- package/dist/invocations/types.d.ts +8 -0
- package/dist/invocations/types.d.ts.map +1 -1
- package/dist/invocations/validate.d.ts +10 -1
- package/dist/invocations/validate.d.ts.map +1 -1
- package/dist/invocations/validate.js +32 -7
- package/dist/values/validate.d.ts.map +1 -1
- package/dist/values/validate.js +3 -1
- package/package.json +1 -1
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import type { ProtocolDeploymentContract, ProtocolDeploymentOptions } from './types.js';
|
|
1
|
+
import type { ProtocolDeploymentContract, ProtocolDeploymentContractV3, ProtocolDeploymentOptions } from './types.js';
|
|
2
2
|
export declare const PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN = "hypequery:deployment:v2\0";
|
|
3
|
+
/** Identity domain for deployment contract 3 (RFC 0015). */
|
|
4
|
+
export declare const PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN = "hypequery:deployment:v3\0";
|
|
3
5
|
export interface PreparedProtocolDeploymentContract {
|
|
4
6
|
readonly contract: ProtocolDeploymentContract;
|
|
5
7
|
readonly canonical: string;
|
|
6
8
|
readonly bytes: Uint8Array;
|
|
7
9
|
readonly identity: string;
|
|
8
10
|
}
|
|
11
|
+
export interface PreparedProtocolDeploymentContractV3 extends Omit<PreparedProtocolDeploymentContract, 'contract'> {
|
|
12
|
+
readonly contract: ProtocolDeploymentContractV3;
|
|
13
|
+
}
|
|
9
14
|
export declare function prepareProtocolDeploymentContract(input: unknown, options?: ProtocolDeploymentOptions): PreparedProtocolDeploymentContract;
|
|
15
|
+
/** Validates, canonically encodes, and identifies a deployment contract 3. */
|
|
16
|
+
export declare function prepareProtocolDeploymentContractV3(input: unknown, options?: ProtocolDeploymentOptions): PreparedProtocolDeploymentContractV3;
|
|
10
17
|
export declare function encodeProtocolDeploymentContract(input: unknown, options?: ProtocolDeploymentOptions): Uint8Array;
|
|
11
18
|
export declare function hashProtocolDeploymentContract(input: unknown, options?: ProtocolDeploymentOptions): string;
|
|
12
19
|
export declare function encodeProtocolDeploymentContractToString(input: unknown, options?: ProtocolDeploymentOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/deployments/codec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/deployments/codec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAKpB,eAAO,MAAM,mCAAmC,8BAA8B,CAAC;AAC/E,4DAA4D;AAC5D,eAAO,MAAM,sCAAsC,8BAA8B,CAAC;AAElF,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oCACf,SAAQ,IAAI,CAAC,kCAAkC,EAAE,UAAU,CAAC;IAC5D,QAAQ,CAAC,QAAQ,EAAE,4BAA4B,CAAC;CACjD;AAYD,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,kCAAkC,CAEpC;AAED,8EAA8E;AAC9E,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,oCAAoC,CAEtC;AAED,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,UAAU,CAEZ;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAER;AAED,wBAAgB,wCAAwC,CACtD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAER"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2';
|
|
2
2
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
3
|
import { serializeJcs } from '../values/jcs.js';
|
|
4
|
-
import { validateProtocolDeploymentContract } from './validate.js';
|
|
4
|
+
import { validateProtocolDeploymentContract, validateProtocolDeploymentContractV3 } from './validate.js';
|
|
5
5
|
const textEncoder = new TextEncoder();
|
|
6
6
|
export const PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN = 'hypequery:deployment:v2\0';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
/** Identity domain for deployment contract 3 (RFC 0015). */
|
|
8
|
+
export const PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN = 'hypequery:deployment:v3\0';
|
|
9
|
+
function identify(contract, domain) {
|
|
9
10
|
const canonical = serializeJcs(contract);
|
|
10
11
|
const bytes = textEncoder.encode(canonical);
|
|
11
12
|
const identity = bytesToHex(sha256.create()
|
|
12
|
-
.update(textEncoder.encode(
|
|
13
|
+
.update(textEncoder.encode(domain))
|
|
13
14
|
.update(bytes)
|
|
14
15
|
.digest());
|
|
15
16
|
return Object.freeze({ contract, canonical, bytes, identity });
|
|
16
17
|
}
|
|
18
|
+
export function prepareProtocolDeploymentContract(input, options = {}) {
|
|
19
|
+
return identify(validateProtocolDeploymentContract(input, options), PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN);
|
|
20
|
+
}
|
|
21
|
+
/** Validates, canonically encodes, and identifies a deployment contract 3. */
|
|
22
|
+
export function prepareProtocolDeploymentContractV3(input, options = {}) {
|
|
23
|
+
return identify(validateProtocolDeploymentContractV3(input, options), PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN);
|
|
24
|
+
}
|
|
17
25
|
export function encodeProtocolDeploymentContract(input, options = {}) {
|
|
18
26
|
return prepareProtocolDeploymentContract(input, options).bytes;
|
|
19
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ProtocolDeploymentError } from './errors.js';
|
|
2
|
-
export { PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, } from './codec.js';
|
|
3
|
-
export type { PreparedProtocolDeploymentContract } from './codec.js';
|
|
2
|
+
export { PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, prepareProtocolDeploymentContractV3, } from './codec.js';
|
|
3
|
+
export type { PreparedProtocolDeploymentContract, PreparedProtocolDeploymentContractV3, } from './codec.js';
|
|
4
4
|
export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS } from './limits.js';
|
|
5
|
-
export { validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './validate.js';
|
|
6
|
-
export type { ProtocolDatasetDerivedMeasure, ProtocolDeploymentDataset, ProtocolDeploymentMeasure, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDefaults, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetFreshness, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolSemanticMetadata, ProtocolSemanticSensitivity, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolMetricDerivation, ProtocolMetricInput, } from './types.js';
|
|
5
|
+
export { validateProtocolDatasetContract, validateProtocolDeploymentContract, validateProtocolDeploymentContractV3, } from './validate.js';
|
|
6
|
+
export type { ProtocolDatasetDerivedMeasure, ProtocolDeploymentDataset, ProtocolDeploymentMeasure, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDefaults, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetFreshness, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolSemanticMetadata, ProtocolSemanticSensitivity, ProtocolDeploymentContract, ProtocolDeploymentContractV3, ProtocolDeploymentDatasetV3, ProtocolDeploymentMeasureV3, ProtocolDatasetDerivedMeasureV3, ProtocolDatasetMeasureV3, ProtocolDatasetSegment, ProtocolDatasetShiftMeasure, ProtocolDatasetWindowMeasure, ProtocolTimeInterval, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolMetricDerivation, ProtocolMetricInput, } from './types.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deployments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,mCAAmC,EACnC,gCAAgC,EAChC,wCAAwC,EACxC,8BAA8B,EAC9B,iCAAiC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deployments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,mCAAmC,EACnC,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,EACxC,8BAA8B,EAC9B,iCAAiC,EACjC,mCAAmC,GACpC,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,oCAAoC,GACrC,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,6BAA6B,EAC7B,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ProtocolDeploymentError } from './errors.js';
|
|
2
|
-
export { PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, } from './codec.js';
|
|
2
|
+
export { PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, prepareProtocolDeploymentContractV3, } from './codec.js';
|
|
3
3
|
export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS } from './limits.js';
|
|
4
|
-
export { validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './validate.js';
|
|
4
|
+
export { validateProtocolDatasetContract, validateProtocolDeploymentContract, validateProtocolDeploymentContractV3, } from './validate.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract 3 segment rules (RFC 0015) that depend on the owning dataset:
|
|
3
|
+
* predicate shape, and which references a predicate may make.
|
|
4
|
+
*/
|
|
5
|
+
import type { ProtocolExpression } from '../expressions/index.js';
|
|
6
|
+
import type { ProtocolDatasetDimension, ProtocolDatasetTenantPolicy } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* True for a comparison between references and literals, or a logical tree
|
|
9
|
+
* whose leaves are all such comparisons. Aggregates, arithmetic, and calls are
|
|
10
|
+
* excluded: a segment selects rows by their own dimension values.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSegmentPredicate(expression: ProtocolExpression): boolean;
|
|
13
|
+
/** Every reference name in an expression, in document order. */
|
|
14
|
+
export declare function expressionReferences(expression: ProtocolExpression): string[];
|
|
15
|
+
/**
|
|
16
|
+
* True when a segment predicate may reference `name`. It must be one of the
|
|
17
|
+
* dataset's own dimensions: never relationship-qualified, and never the tenant
|
|
18
|
+
* field, which only trusted runtime context may constrain.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSegmentReference(name: string, dimensions: readonly ProtocolDatasetDimension[], tenant: ProtocolDatasetTenantPolicy): boolean;
|
|
21
|
+
//# sourceMappingURL=segments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../src/deployments/segments.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAExF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAQ1E;AAMD,gEAAgE;AAChE,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAmB7E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,wBAAwB,EAAE,EAC/C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAMT"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract 3 segment rules (RFC 0015) that depend on the owning dataset:
|
|
3
|
+
* predicate shape, and which references a predicate may make.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* True for a comparison between references and literals, or a logical tree
|
|
7
|
+
* whose leaves are all such comparisons. Aggregates, arithmetic, and calls are
|
|
8
|
+
* excluded: a segment selects rows by their own dimension values.
|
|
9
|
+
*/
|
|
10
|
+
export function isSegmentPredicate(expression) {
|
|
11
|
+
if (expression.kind === 'comparison') {
|
|
12
|
+
return isSegmentOperand(expression.left) && isSegmentOperand(expression.right);
|
|
13
|
+
}
|
|
14
|
+
if (expression.kind !== 'logical')
|
|
15
|
+
return false;
|
|
16
|
+
return expression.operator === 'not'
|
|
17
|
+
? isSegmentPredicate(expression.operand)
|
|
18
|
+
: expression.operands.every(isSegmentPredicate);
|
|
19
|
+
}
|
|
20
|
+
function isSegmentOperand(expression) {
|
|
21
|
+
return expression.kind === 'reference' || expression.kind === 'literal';
|
|
22
|
+
}
|
|
23
|
+
/** Every reference name in an expression, in document order. */
|
|
24
|
+
export function expressionReferences(expression) {
|
|
25
|
+
switch (expression.kind) {
|
|
26
|
+
case 'reference':
|
|
27
|
+
return [expression.name];
|
|
28
|
+
case 'literal':
|
|
29
|
+
return [];
|
|
30
|
+
case 'binary':
|
|
31
|
+
case 'comparison':
|
|
32
|
+
return [...expressionReferences(expression.left), ...expressionReferences(expression.right)];
|
|
33
|
+
case 'call':
|
|
34
|
+
return expression.args.flatMap(expressionReferences);
|
|
35
|
+
case 'logical':
|
|
36
|
+
return expression.operator === 'not'
|
|
37
|
+
? expressionReferences(expression.operand)
|
|
38
|
+
: expression.operands.flatMap(expressionReferences);
|
|
39
|
+
case 'aggregate':
|
|
40
|
+
// Not reachable for a predicate; listed so a caller cannot miss one.
|
|
41
|
+
return [expression.field];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* True when a segment predicate may reference `name`. It must be one of the
|
|
46
|
+
* dataset's own dimensions: never relationship-qualified, and never the tenant
|
|
47
|
+
* field, which only trusted runtime context may constrain.
|
|
48
|
+
*/
|
|
49
|
+
export function isSegmentReference(name, dimensions, tenant) {
|
|
50
|
+
const dimension = dimensions.find(item => item.name === name);
|
|
51
|
+
if (!dimension)
|
|
52
|
+
return false;
|
|
53
|
+
if (tenant.kind !== 'required')
|
|
54
|
+
return true;
|
|
55
|
+
const column = dimension.source.kind === 'column' ? dimension.source.column : undefined;
|
|
56
|
+
return dimension.name !== tenant.field && column !== tenant.field;
|
|
57
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProtocolExpression, ProtocolTimeGrain } from '../expressions/index.js';
|
|
1
|
+
import type { ProtocolExpression, ProtocolQueryTimeGrain, ProtocolTimeGrain } from '../expressions/index.js';
|
|
2
2
|
import type { ProtocolIdentifier, ProtocolQualifiedIdentifier } from '../identifiers/index.js';
|
|
3
3
|
import type { ProtocolSqlExpression } from '../query-implementations/index.js';
|
|
4
4
|
export type ProtocolDatasetFieldType = 'string' | 'number' | 'boolean' | 'timestamp';
|
|
@@ -174,6 +174,75 @@ export interface ProtocolDeploymentContract {
|
|
|
174
174
|
readonly queries?: never;
|
|
175
175
|
readonly artifacts?: never;
|
|
176
176
|
}
|
|
177
|
+
/** A named, author-defined predicate over a dataset's own dimensions (RFC 0015). */
|
|
178
|
+
export interface ProtocolDatasetSegment extends ProtocolSemanticMetadata {
|
|
179
|
+
readonly name: ProtocolIdentifier;
|
|
180
|
+
readonly predicate: ProtocolExpression;
|
|
181
|
+
readonly label?: string;
|
|
182
|
+
readonly description?: string;
|
|
183
|
+
}
|
|
184
|
+
/** A contract 3 base measure: adds `approxCountDistinct` and its `approximate` marker. */
|
|
185
|
+
export interface ProtocolDatasetMeasureV3 extends Omit<ProtocolDatasetMeasure, 'aggregation'> {
|
|
186
|
+
readonly aggregation: ProtocolDatasetMeasure['aggregation'] | 'approxCountDistinct';
|
|
187
|
+
/** Present, and `true`, exactly when the aggregation is approximate. */
|
|
188
|
+
readonly approximate?: true;
|
|
189
|
+
}
|
|
190
|
+
/** A contract 3 derived measure: approximate when any measure it uses is. */
|
|
191
|
+
export interface ProtocolDatasetDerivedMeasureV3 extends ProtocolDatasetDerivedMeasure {
|
|
192
|
+
readonly approximate?: true;
|
|
193
|
+
}
|
|
194
|
+
/** A whole number of time units, such as `{ amount: 7, unit: 'day' }`. */
|
|
195
|
+
export interface ProtocolTimeInterval {
|
|
196
|
+
readonly amount: number;
|
|
197
|
+
readonly unit: ProtocolQueryTimeGrain;
|
|
198
|
+
}
|
|
199
|
+
interface ProtocolTimeMeasureCommon extends ProtocolSemanticMetadata {
|
|
200
|
+
readonly name: ProtocolIdentifier;
|
|
201
|
+
/** The base measure of the same dataset this measure wraps. */
|
|
202
|
+
readonly measure: ProtocolIdentifier;
|
|
203
|
+
/** Signals that selecting this measure requires a grain and bounded time range. */
|
|
204
|
+
readonly requiresTimeRange: true;
|
|
205
|
+
/** Present, and `true`, exactly when the wrapped measure is approximate. */
|
|
206
|
+
readonly approximate?: true;
|
|
207
|
+
readonly label?: string;
|
|
208
|
+
readonly description?: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A rolling, to-date, or cumulative window over a base measure (RFC 0015).
|
|
212
|
+
* Exactly one of `trailing`, `toDate`, and `cumulative` is present.
|
|
213
|
+
*/
|
|
214
|
+
export interface ProtocolDatasetWindowMeasure extends ProtocolTimeMeasureCommon {
|
|
215
|
+
readonly kind: 'window';
|
|
216
|
+
readonly trailing?: ProtocolTimeInterval;
|
|
217
|
+
readonly toDate?: Exclude<ProtocolQueryTimeGrain, 'minute'>;
|
|
218
|
+
readonly cumulative?: true;
|
|
219
|
+
}
|
|
220
|
+
/** A base measure evaluated over the bucket shifted back by `interval` (RFC 0015). */
|
|
221
|
+
export interface ProtocolDatasetShiftMeasure extends ProtocolTimeMeasureCommon {
|
|
222
|
+
readonly kind: 'shift';
|
|
223
|
+
readonly interval: ProtocolTimeInterval;
|
|
224
|
+
}
|
|
225
|
+
export type ProtocolDeploymentMeasureV3 = ProtocolDatasetMeasureV3 | ProtocolDatasetDerivedMeasureV3 | ProtocolDatasetWindowMeasure | ProtocolDatasetShiftMeasure;
|
|
226
|
+
/**
|
|
227
|
+
* A contract 3 dataset. The filter allow-list is renamed `allowedFilters`, and
|
|
228
|
+
* datasets may carry `segments`.
|
|
229
|
+
*/
|
|
230
|
+
export interface ProtocolDeploymentDatasetV3 extends Omit<ProtocolDeploymentDataset, 'measures' | 'filters' | 'defaults'> {
|
|
231
|
+
readonly measures: readonly ProtocolDeploymentMeasureV3[];
|
|
232
|
+
readonly allowedFilters: readonly ProtocolDatasetFilter[];
|
|
233
|
+
readonly segments?: readonly ProtocolDatasetSegment[];
|
|
234
|
+
readonly defaults?: {
|
|
235
|
+
readonly dimensions?: readonly ProtocolIdentifier[];
|
|
236
|
+
readonly timeGrain?: ProtocolQueryTimeGrain;
|
|
237
|
+
};
|
|
238
|
+
readonly filters?: never;
|
|
239
|
+
}
|
|
240
|
+
/** Deployment contract 3 (RFC 0015). */
|
|
241
|
+
export interface ProtocolDeploymentContractV3 {
|
|
242
|
+
readonly kind: 'hypequery-deployment';
|
|
243
|
+
readonly version: 3;
|
|
244
|
+
readonly datasets: readonly ProtocolDeploymentDatasetV3[];
|
|
245
|
+
}
|
|
177
246
|
export interface ProtocolDeploymentLimits {
|
|
178
247
|
readonly maxDatasets: number;
|
|
179
248
|
readonly maxDatasetItems: number;
|
|
@@ -200,4 +269,5 @@ export interface ProtocolDeploymentOptions {
|
|
|
200
269
|
readonly limits?: Partial<ProtocolDeploymentLimits>;
|
|
201
270
|
}
|
|
202
271
|
export type ProtocolDeploymentErrorCode = 'HQ_DEPLOYMENT_TYPE' | 'HQ_DEPLOYMENT_UNKNOWN_FIELD' | 'HQ_DEPLOYMENT_INVALID_VERSION' | 'HQ_DEPLOYMENT_INVALID_IDENTIFIER' | 'HQ_DEPLOYMENT_INVALID_VALUE' | 'HQ_DEPLOYMENT_INVALID_REFERENCE' | 'HQ_DEPLOYMENT_TOO_MANY_ITEMS' | 'HQ_DEPLOYMENT_TOO_LARGE' | 'HQ_DEPLOYMENT_UNSAFE_OBJECT';
|
|
272
|
+
export {};
|
|
203
273
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/deployments/types.ts"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C,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACrD;AAED,MAAM,MAAM,2BAA2B,GACnC,oBAAoB,GACpB,6BAA6B,GAC7B,+BAA+B,GAC/B,kCAAkC,GAClC,6BAA6B,GAC7B,iCAAiC,GACjC,8BAA8B,GAC9B,yBAAyB,GACzB,6BAA6B,CAAC"}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import type { ProtocolDatasetContract, ProtocolDeploymentContract, ProtocolDeploymentOptions } from './types.js';
|
|
1
|
+
import type { ProtocolDatasetContract, ProtocolDeploymentContract, ProtocolDeploymentContractV3, ProtocolDeploymentOptions } from './types.js';
|
|
2
2
|
export declare function validateProtocolDatasetContract(input: unknown, options?: ProtocolDeploymentOptions): ProtocolDatasetContract;
|
|
3
3
|
/** Validate the deployment contract. Unsupported fields are forbidden, even when empty. */
|
|
4
4
|
export declare function validateProtocolDeploymentContract(input: unknown, options?: ProtocolDeploymentOptions): ProtocolDeploymentContract;
|
|
5
|
+
/**
|
|
6
|
+
* Validate a deployment contract 3 (RFC 0015). Contract 3 renames the dataset
|
|
7
|
+
* filter allow-list to `allowedFilters` and adds segments, `approxCountDistinct`,
|
|
8
|
+
* window and shift measures, and sub-day default grains.
|
|
9
|
+
*
|
|
10
|
+
* Under the lowest-version rule, a contract that uses none of those is only
|
|
11
|
+
* valid as contract 2. Rejecting it here keeps a deployment's identity a
|
|
12
|
+
* function of its content rather than of which producer emitted it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateProtocolDeploymentContractV3(input: unknown, options?: ProtocolDeploymentOptions): ProtocolDeploymentContractV3;
|
|
5
15
|
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/deployments/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/deployments/validate.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,0BAA0B,EAC1B,4BAA4B,EAe5B,yBAAyB,EAG1B,MAAM,YAAY,CAAC;AAw0BpB,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,uBAAuB,CAEzB;AAiQD,2FAA2F;AAC3F,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,0BAA0B,CAU5B;AAYD;;;;;;;;GAQG;AACH,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,4BAA4B,CAa9B"}
|
|
@@ -2,16 +2,23 @@ import { ProtocolExpressionError, validateProtocolExpression } from '../expressi
|
|
|
2
2
|
import { ProtocolIdentifierError, parseProtocolIdentifier, parseProtocolQualifiedIdentifier, } from '../identifiers/index.js';
|
|
3
3
|
import { validateProtocolSqlExpression } from '../sql-expressions/validate.js';
|
|
4
4
|
import { deploymentError } from './errors.js';
|
|
5
|
+
import { expressionReferences, isSegmentPredicate, isSegmentReference } from './segments.js';
|
|
5
6
|
import { resolveDeploymentLimits } from './limits.js';
|
|
6
7
|
const textEncoder = new TextEncoder();
|
|
7
8
|
const AGGREGATIONS = new Set([
|
|
8
9
|
'sum', 'count', 'countDistinct', 'avg', 'min', 'max',
|
|
9
10
|
'argMax', 'argMin', 'percentile', 'stddev', 'variance',
|
|
10
11
|
]);
|
|
12
|
+
const AGGREGATIONS_V3 = new Set([...AGGREGATIONS, 'approxCountDistinct']);
|
|
13
|
+
const APPROXIMATE_AGGREGATIONS = new Set(['approxCountDistinct']);
|
|
11
14
|
const OPERATORS = new Set([
|
|
12
15
|
'eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'in', 'notIn', 'between', 'like',
|
|
13
16
|
]);
|
|
14
17
|
const GRAINS = new Set(['day', 'week', 'month', 'quarter', 'year']);
|
|
18
|
+
const GRAINS_V3 = new Set(['minute', 'hour', ...GRAINS]);
|
|
19
|
+
const SUB_DAY_GRAINS = new Set(['minute', 'hour']);
|
|
20
|
+
/** Aggregations a `cumulative` window may wrap: a running total of bucket partials. */
|
|
21
|
+
const CUMULATIVE_AGGREGATIONS = new Set(['sum', 'count', 'min', 'max']);
|
|
15
22
|
const SENSITIVITIES = new Set(['public', 'internal', 'confidential', 'restricted']);
|
|
16
23
|
const SEMANTIC_METADATA_FIELDS = [
|
|
17
24
|
'examples', 'synonyms', 'format', 'unit', 'currency', 'timezone', 'sensitivity',
|
|
@@ -259,12 +266,24 @@ function validateDimension(input, path, limits) {
|
|
|
259
266
|
validateSemanticMetadata(value, result, path, limits);
|
|
260
267
|
return freezeRecord(result);
|
|
261
268
|
}
|
|
262
|
-
function validateMeasure(input, path, limits) {
|
|
269
|
+
function validateMeasure(input, path, limits, version = 2) {
|
|
263
270
|
const value = requireRecord(input, path);
|
|
264
|
-
exactFields(value, ['name', 'aggregation', 'field', 'filters'], [
|
|
265
|
-
|
|
271
|
+
exactFields(value, ['name', 'aggregation', 'field', 'filters'], [
|
|
272
|
+
'argField', 'level', 'sql', 'label', 'description', ...SEMANTIC_METADATA_FIELDS,
|
|
273
|
+
...(version === 3 ? ['approximate'] : []),
|
|
274
|
+
], path);
|
|
275
|
+
if (typeof value.aggregation !== 'string'
|
|
276
|
+
|| !(version === 3 ? AGGREGATIONS_V3 : AGGREGATIONS).has(value.aggregation)) {
|
|
266
277
|
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.aggregation`);
|
|
267
278
|
}
|
|
279
|
+
// The marker is not free: present, as `true`, exactly for an approximate aggregation.
|
|
280
|
+
const approximate = APPROXIMATE_AGGREGATIONS.has(value.aggregation);
|
|
281
|
+
if (value.approximate !== undefined && value.approximate !== true) {
|
|
282
|
+
deploymentError('HQ_DEPLOYMENT_TYPE', `${path}.approximate`);
|
|
283
|
+
}
|
|
284
|
+
if (approximate !== (value.approximate === true)) {
|
|
285
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.approximate`);
|
|
286
|
+
}
|
|
268
287
|
const needsArg = value.aggregation === 'argMax' || value.aggregation === 'argMin';
|
|
269
288
|
if (needsArg !== (value.argField !== undefined)) {
|
|
270
289
|
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.argField`);
|
|
@@ -282,8 +301,10 @@ function validateMeasure(input, path, limits) {
|
|
|
282
301
|
aggregation: value.aggregation,
|
|
283
302
|
field: identifier(value.field, `${path}.field`, true),
|
|
284
303
|
filters: Object.freeze(requireArray(value.filters, `${path}.filters`, limits.maxDatasetItems)
|
|
285
|
-
.map((filter, index) => nested(() => validateProtocolExpression(filter), `${path}.filters[${index}]`))),
|
|
304
|
+
.map((filter, index) => nested(() => validateProtocolExpression(filter, { extension: version === 3 ? 2 : 1 }), `${path}.filters[${index}]`))),
|
|
286
305
|
};
|
|
306
|
+
if (approximate)
|
|
307
|
+
result.approximate = true;
|
|
287
308
|
if (value.argField !== undefined)
|
|
288
309
|
result.argField = identifier(value.argField, `${path}.argField`, true);
|
|
289
310
|
if (value.level !== undefined)
|
|
@@ -545,7 +566,7 @@ function validateFreshness(input, path) {
|
|
|
545
566
|
maxAgeSeconds: positiveInteger(value.maxAgeSeconds, `${path}.maxAgeSeconds`),
|
|
546
567
|
});
|
|
547
568
|
}
|
|
548
|
-
function validateDefaults(input, path, limits) {
|
|
569
|
+
function validateDefaults(input, path, limits, version) {
|
|
549
570
|
const value = requireRecord(input, path);
|
|
550
571
|
exactFields(value, [], ['dimensions', 'timeGrain'], path);
|
|
551
572
|
const result = {};
|
|
@@ -553,7 +574,7 @@ function validateDefaults(input, path, limits) {
|
|
|
553
574
|
result.dimensions = uniqueStrings(value.dimensions, `${path}.dimensions`, limits.maxSemanticMetadataItems, (dimension, dimensionPath) => identifier(dimension, dimensionPath));
|
|
554
575
|
}
|
|
555
576
|
if (value.timeGrain !== undefined) {
|
|
556
|
-
if (typeof value.timeGrain !== 'string' || !GRAINS.has(value.timeGrain)) {
|
|
577
|
+
if (typeof value.timeGrain !== 'string' || !(version === 3 ? GRAINS_V3 : GRAINS).has(value.timeGrain)) {
|
|
557
578
|
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.timeGrain`);
|
|
558
579
|
}
|
|
559
580
|
result.timeGrain = value.timeGrain;
|
|
@@ -570,23 +591,46 @@ function namedItems(input, path, maxItems, validate) {
|
|
|
570
591
|
}
|
|
571
592
|
return Object.freeze(items);
|
|
572
593
|
}
|
|
573
|
-
function
|
|
594
|
+
function validateSegment(input, path, limits, dimensions, tenant) {
|
|
595
|
+
const value = requireRecord(input, path);
|
|
596
|
+
exactFields(value, ['name', 'predicate'], ['label', 'description', ...SEMANTIC_METADATA_FIELDS], path);
|
|
597
|
+
const name = identifier(value.name, `${path}.name`);
|
|
598
|
+
const predicate = nested(() => validateProtocolExpression(value.predicate, { extension: 2 }), `${path}.predicate`);
|
|
599
|
+
if (!isSegmentPredicate(predicate)
|
|
600
|
+
|| expressionReferences(predicate).some(reference => !isSegmentReference(reference, dimensions, tenant))) {
|
|
601
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.predicate`);
|
|
602
|
+
}
|
|
603
|
+
const result = { name, predicate };
|
|
604
|
+
optionalText(value.label, 'label', result, path, limits);
|
|
605
|
+
optionalText(value.description, 'description', result, path, limits);
|
|
606
|
+
validateSemanticMetadata(value, result, path, limits);
|
|
607
|
+
return freezeRecord(result);
|
|
608
|
+
}
|
|
609
|
+
function validateDataset(input, path, limits, measureIndices, version = 2) {
|
|
574
610
|
const value = requireRecord(input, path);
|
|
575
|
-
|
|
611
|
+
// Contract 3 renames the allow-list; the old name is then an unknown field.
|
|
612
|
+
const filtersKey = version === 3 ? 'allowedFilters' : 'filters';
|
|
613
|
+
exactFields(value, [
|
|
614
|
+
'name', 'source', 'tenant', 'dimensions', 'measures', filtersKey, 'metrics', 'relationships',
|
|
615
|
+
], [
|
|
576
616
|
'description', 'freshness', 'owner', 'defaults',
|
|
577
617
|
...SEMANTIC_METADATA_FIELDS,
|
|
578
618
|
'timeField', 'limits', 'endpoint',
|
|
619
|
+
...(version === 3 ? ['segments'] : []),
|
|
579
620
|
], path);
|
|
580
621
|
const result = {
|
|
581
622
|
name: identifier(value.name, `${path}.name`),
|
|
582
623
|
source: boundedText(value.source, `${path}.source`, limits.maxSourceBytes),
|
|
583
624
|
tenant: validateTenant(value.tenant, `${path}.tenant`, limits),
|
|
584
625
|
dimensions: namedItems(value.dimensions, `${path}.dimensions`, limits.maxDatasetItems, (item, itemPath) => validateDimension(item, itemPath, limits)),
|
|
585
|
-
measures: namedItems(value.measures, `${path}.measures`, limits.maxDatasetItems, (item, itemPath, index) => validateMeasure(item, measureIndices === undefined ? itemPath : `${path}.measures[${measureIndices[index]}]`, limits)),
|
|
586
|
-
|
|
626
|
+
measures: namedItems(value.measures, `${path}.measures`, limits.maxDatasetItems, (item, itemPath, index) => validateMeasure(item, measureIndices === undefined ? itemPath : `${path}.measures[${measureIndices[index]}]`, limits, version)),
|
|
627
|
+
[filtersKey]: namedItems(value[filtersKey], `${path}.${filtersKey}`, limits.maxDatasetItems, (item, itemPath) => validateFilter(item, itemPath, limits)),
|
|
587
628
|
metrics: namedItems(value.metrics, `${path}.metrics`, limits.maxDatasetItems, (item, itemPath) => validateMetric(item, itemPath, limits)),
|
|
588
629
|
relationships: namedItems(value.relationships, `${path}.relationships`, limits.maxDatasetItems, (item, itemPath) => validateRelationship(item, itemPath)),
|
|
589
630
|
};
|
|
631
|
+
if (version === 3 && value.segments !== undefined) {
|
|
632
|
+
result.segments = namedItems(value.segments, `${path}.segments`, limits.maxDatasetItems, (item, itemPath) => validateSegment(item, itemPath, limits, result.dimensions, result.tenant));
|
|
633
|
+
}
|
|
590
634
|
if (value.timeField !== undefined)
|
|
591
635
|
result.timeField = identifier(value.timeField, `${path}.timeField`, true);
|
|
592
636
|
optionalText(value.description, 'description', result, path, limits);
|
|
@@ -596,7 +640,7 @@ function validateDataset(input, path, limits, measureIndices) {
|
|
|
596
640
|
result.freshness = validateFreshness(value.freshness, `${path}.freshness`);
|
|
597
641
|
}
|
|
598
642
|
if (value.defaults !== undefined) {
|
|
599
|
-
result.defaults = validateDefaults(value.defaults, `${path}.defaults`, limits);
|
|
643
|
+
result.defaults = validateDefaults(value.defaults, `${path}.defaults`, limits, version);
|
|
600
644
|
}
|
|
601
645
|
if (value.limits !== undefined)
|
|
602
646
|
result.limits = validateLimits(value.limits, `${path}.limits`);
|
|
@@ -644,11 +688,15 @@ function formulaReferences(expression, names) {
|
|
|
644
688
|
return;
|
|
645
689
|
}
|
|
646
690
|
}
|
|
647
|
-
function validateDatasetDerivedMeasure(input, path, limits) {
|
|
691
|
+
function validateDatasetDerivedMeasure(input, path, limits, version) {
|
|
648
692
|
const value = requireRecord(input, path);
|
|
649
693
|
exactFields(value, ['kind', 'name', 'uses', 'expression'], [
|
|
650
694
|
'label', 'description', ...SEMANTIC_METADATA_FIELDS,
|
|
695
|
+
...(version === 3 ? ['approximate'] : []),
|
|
651
696
|
], path);
|
|
697
|
+
if (value.approximate !== undefined && value.approximate !== true) {
|
|
698
|
+
deploymentError('HQ_DEPLOYMENT_TYPE', `${path}.approximate`);
|
|
699
|
+
}
|
|
652
700
|
if (value.kind !== 'derived')
|
|
653
701
|
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.kind`);
|
|
654
702
|
const uses = requireArray(value.uses, `${path}.uses`, limits.maxDatasetItems)
|
|
@@ -680,40 +728,144 @@ function validateDatasetDerivedMeasure(input, path, limits) {
|
|
|
680
728
|
uses: Object.freeze(uses),
|
|
681
729
|
expression,
|
|
682
730
|
};
|
|
731
|
+
// Checked against the base measures by the dataset, once they are known.
|
|
732
|
+
if (value.approximate === true)
|
|
733
|
+
result.approximate = true;
|
|
683
734
|
optionalText(value.label, 'label', result, path, limits);
|
|
684
735
|
optionalText(value.description, 'description', result, path, limits);
|
|
685
736
|
validateSemanticMetadata(value, result, path, limits);
|
|
686
737
|
return freezeRecord(result);
|
|
687
738
|
}
|
|
688
|
-
function
|
|
739
|
+
function validateInterval(input, path) {
|
|
689
740
|
const value = requireRecord(input, path);
|
|
690
|
-
exactFields(value, ['
|
|
741
|
+
exactFields(value, ['amount', 'unit'], [], path);
|
|
742
|
+
const amount = positiveInteger(value.amount, `${path}.amount`);
|
|
743
|
+
if (typeof value.unit !== 'string' || !GRAINS_V3.has(value.unit)) {
|
|
744
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.unit`);
|
|
745
|
+
}
|
|
746
|
+
return freezeRecord({ amount, unit: value.unit });
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Validates the shape of a contract 3 `window` or `shift` measure. Rules that
|
|
750
|
+
* need the rest of the dataset (the wrapped base measure, the time field, and
|
|
751
|
+
* approximation) are checked by the dataset. Rules that need the query grain
|
|
752
|
+
* (whole-bucket intervals, the bucket bound) are enforced at query time.
|
|
753
|
+
*/
|
|
754
|
+
function validateTimeMeasure(value, path, limits) {
|
|
755
|
+
const window = value.kind === 'window';
|
|
756
|
+
exactFields(value, window
|
|
757
|
+
? ['kind', 'name', 'measure', 'requiresTimeRange']
|
|
758
|
+
: ['kind', 'name', 'measure', 'interval', 'requiresTimeRange'], [
|
|
759
|
+
...(window ? ['trailing', 'toDate', 'cumulative'] : []),
|
|
760
|
+
'approximate', 'label', 'description', ...SEMANTIC_METADATA_FIELDS,
|
|
761
|
+
], path);
|
|
762
|
+
if (value.approximate !== undefined && value.approximate !== true) {
|
|
763
|
+
deploymentError('HQ_DEPLOYMENT_TYPE', `${path}.approximate`);
|
|
764
|
+
}
|
|
765
|
+
if (value.requiresTimeRange !== true) {
|
|
766
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.requiresTimeRange`);
|
|
767
|
+
}
|
|
768
|
+
const result = {
|
|
769
|
+
kind: value.kind,
|
|
770
|
+
name: identifier(value.name, `${path}.name`),
|
|
771
|
+
measure: identifier(value.measure, `${path}.measure`),
|
|
772
|
+
requiresTimeRange: true,
|
|
773
|
+
};
|
|
774
|
+
if (window) {
|
|
775
|
+
const frames = ['trailing', 'toDate', 'cumulative'].filter(key => value[key] !== undefined);
|
|
776
|
+
if (frames.length !== 1)
|
|
777
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', path);
|
|
778
|
+
if (value.trailing !== undefined)
|
|
779
|
+
result.trailing = validateInterval(value.trailing, `${path}.trailing`);
|
|
780
|
+
if (value.toDate !== undefined) {
|
|
781
|
+
// A to-date period must be coarser than some bucket, so `minute` has none.
|
|
782
|
+
if (typeof value.toDate !== 'string' || !GRAINS_V3.has(value.toDate) || value.toDate === 'minute') {
|
|
783
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.toDate`);
|
|
784
|
+
}
|
|
785
|
+
result.toDate = value.toDate;
|
|
786
|
+
}
|
|
787
|
+
if (value.cumulative !== undefined) {
|
|
788
|
+
if (value.cumulative !== true)
|
|
789
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.cumulative`);
|
|
790
|
+
result.cumulative = true;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
result.interval = validateInterval(value.interval, `${path}.interval`);
|
|
795
|
+
}
|
|
796
|
+
if (value.approximate === true)
|
|
797
|
+
result.approximate = true;
|
|
798
|
+
optionalText(value.label, 'label', result, path, limits);
|
|
799
|
+
optionalText(value.description, 'description', result, path, limits);
|
|
800
|
+
validateSemanticMetadata(value, result, path, limits);
|
|
801
|
+
return freezeRecord(result);
|
|
802
|
+
}
|
|
803
|
+
function validateDeploymentDataset(input, path, limits, version = 2) {
|
|
804
|
+
const value = requireRecord(input, path);
|
|
805
|
+
exactFields(value, [
|
|
806
|
+
'name', 'source', 'tenant', 'dimensions', 'measures',
|
|
807
|
+
version === 3 ? 'allowedFilters' : 'filters', 'relationships',
|
|
808
|
+
], [
|
|
691
809
|
'description', 'freshness', 'owner', 'defaults',
|
|
692
810
|
...SEMANTIC_METADATA_FIELDS, 'timeField', 'limits', 'endpoint',
|
|
811
|
+
...(version === 3 ? ['segments'] : []),
|
|
693
812
|
], path);
|
|
694
813
|
const measures = requireArray(value.measures, `${path}.measures`, limits.maxDatasetItems)
|
|
695
814
|
.map((measure, index) => requireRecord(measure, `${path}.measures[${index}]`));
|
|
815
|
+
// Base measures are validated by the dataset; composite ones (derived, and in
|
|
816
|
+
// contract 3 window and shift) reference them and are validated here.
|
|
817
|
+
const isComposite = (measure) => measure.kind === 'derived'
|
|
818
|
+
|| (version === 3 && (measure.kind === 'window' || measure.kind === 'shift'));
|
|
696
819
|
// Preserve original indices when validating base measures separately.
|
|
697
|
-
const baseEntries = measures.flatMap((measure, index) => (measure
|
|
698
|
-
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
820
|
+
const baseEntries = measures.flatMap((measure, index) => (isComposite(measure) ? [] : [{ measure, index }]));
|
|
821
|
+
const validated = validateDataset({ ...value, measures: baseEntries.map(entry => entry.measure), metrics: [] }, path, limits, baseEntries.map(entry => entry.index), version);
|
|
822
|
+
const composite = measures.map((measure, index) => {
|
|
823
|
+
const measurePath = `${path}.measures[${index}]`;
|
|
824
|
+
if (measure.kind === 'derived') {
|
|
825
|
+
return validateDatasetDerivedMeasure(measure, measurePath, limits, version);
|
|
826
|
+
}
|
|
827
|
+
return isComposite(measure) ? validateTimeMeasure(measure, measurePath, limits) : undefined;
|
|
828
|
+
});
|
|
829
|
+
const derived = composite.map(item => (item?.kind === 'derived' ? item : undefined));
|
|
703
830
|
const baseByName = new Map(validated.measures.map(measure => [measure.name, measure]));
|
|
704
831
|
let baseIndex = 0;
|
|
705
|
-
const ordered = measures.map((_, index) => (
|
|
832
|
+
const ordered = measures.map((_, index) => (composite[index] ?? validated.measures[baseIndex++]));
|
|
706
833
|
if (new Set(ordered.map(measure => measure.name)).size !== measures.length) {
|
|
707
834
|
deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `${path}.measures`);
|
|
708
835
|
}
|
|
836
|
+
const isApproximate = (measure) => measure?.approximate === true;
|
|
837
|
+
// A time measure wraps exactly one base measure and needs the dataset's time axis.
|
|
838
|
+
const timeByName = new Map();
|
|
839
|
+
for (const [index, item] of composite.entries()) {
|
|
840
|
+
if (!item || item.kind === 'derived')
|
|
841
|
+
continue;
|
|
842
|
+
const timeMeasure = item;
|
|
843
|
+
const measurePath = `${path}.measures[${index}]`;
|
|
844
|
+
const wrapped = baseByName.get(timeMeasure.measure);
|
|
845
|
+
if (!wrapped)
|
|
846
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `${measurePath}.measure`);
|
|
847
|
+
if (validated.timeField === undefined)
|
|
848
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `${measurePath}.kind`);
|
|
849
|
+
if (timeMeasure.cumulative === true && !CUMULATIVE_AGGREGATIONS.has(wrapped.aggregation)) {
|
|
850
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${measurePath}.cumulative`);
|
|
851
|
+
}
|
|
852
|
+
if (isApproximate(wrapped) !== isApproximate(timeMeasure)) {
|
|
853
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${measurePath}.approximate`);
|
|
854
|
+
}
|
|
855
|
+
timeByName.set(timeMeasure.name, timeMeasure);
|
|
856
|
+
}
|
|
709
857
|
for (const [index, item] of derived.entries()) {
|
|
710
858
|
if (!item)
|
|
711
859
|
continue;
|
|
712
860
|
for (const [useIndex, use] of item.uses.entries()) {
|
|
713
|
-
if (!baseByName.has(use.measure)) {
|
|
861
|
+
if (!baseByName.has(use.measure) && !timeByName.has(use.measure)) {
|
|
714
862
|
deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `${path}.measures[${index}].uses[${useIndex}].measure`);
|
|
715
863
|
}
|
|
716
864
|
}
|
|
865
|
+
const approximate = item.uses.some(use => (isApproximate(baseByName.get(use.measure) ?? timeByName.get(use.measure))));
|
|
866
|
+
if (approximate !== isApproximate(item)) {
|
|
867
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.measures[${index}].approximate`);
|
|
868
|
+
}
|
|
717
869
|
}
|
|
718
870
|
const { metrics: _metrics, ...dataset } = validated;
|
|
719
871
|
return freezeRecord({ ...dataset, measures: Object.freeze(ordered) });
|
|
@@ -731,3 +883,34 @@ export function validateProtocolDeploymentContract(input, options = {}) {
|
|
|
731
883
|
validateDatasetReferences(datasets);
|
|
732
884
|
return freezeRecord({ kind: 'hypequery-deployment', version: 2, datasets });
|
|
733
885
|
}
|
|
886
|
+
/** True when a contract 3 dataset uses anything contract 2 cannot express. */
|
|
887
|
+
function usesContract3Feature(dataset) {
|
|
888
|
+
return (dataset.segments?.length ?? 0) > 0
|
|
889
|
+
|| dataset.measures.some(measure => (('aggregation' in measure && APPROXIMATE_AGGREGATIONS.has(measure.aggregation))
|
|
890
|
+
|| ('kind' in measure && (measure.kind === 'window' || measure.kind === 'shift'))))
|
|
891
|
+
|| (dataset.defaults?.timeGrain !== undefined && SUB_DAY_GRAINS.has(dataset.defaults.timeGrain));
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Validate a deployment contract 3 (RFC 0015). Contract 3 renames the dataset
|
|
895
|
+
* filter allow-list to `allowedFilters` and adds segments, `approxCountDistinct`,
|
|
896
|
+
* window and shift measures, and sub-day default grains.
|
|
897
|
+
*
|
|
898
|
+
* Under the lowest-version rule, a contract that uses none of those is only
|
|
899
|
+
* valid as contract 2. Rejecting it here keeps a deployment's identity a
|
|
900
|
+
* function of its content rather than of which producer emitted it.
|
|
901
|
+
*/
|
|
902
|
+
export function validateProtocolDeploymentContractV3(input, options = {}) {
|
|
903
|
+
const limits = resolveDeploymentLimits(options);
|
|
904
|
+
const value = requireRecord(input, '$');
|
|
905
|
+
exactFields(value, ['kind', 'version', 'datasets'], [], '$');
|
|
906
|
+
if (value.kind !== 'hypequery-deployment')
|
|
907
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', '$.kind');
|
|
908
|
+
if (value.version !== 3)
|
|
909
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VERSION', '$.version');
|
|
910
|
+
const datasets = namedItems(value.datasets, '$.datasets', limits.maxDatasets, (item, path) => validateDeploymentDataset(item, path, limits, 3));
|
|
911
|
+
validateDatasetReferences(datasets);
|
|
912
|
+
if (!datasets.some(usesContract3Feature)) {
|
|
913
|
+
deploymentError('HQ_DEPLOYMENT_INVALID_VERSION', '$.version');
|
|
914
|
+
}
|
|
915
|
+
return freezeRecord({ kind: 'hypequery-deployment', version: 3, datasets });
|
|
916
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ProtocolExpressionError } from './errors.js';
|
|
2
2
|
export { DEFAULT_PROTOCOL_EXPRESSION_LIMITS } from './limits.js';
|
|
3
3
|
export { validateProtocolExpression, validateProtocolSemanticQuery } from './validate.js';
|
|
4
|
-
export type { ProtocolAggregation, ProtocolBinaryOperator, ProtocolComparisonOperator, ProtocolDatasetQuery, ProtocolExpression, ProtocolExpressionErrorCode, ProtocolExpressionLimits, ProtocolExpressionOptions, ProtocolFunctionName, ProtocolMetricQuery, ProtocolOrderBy, ProtocolSemanticQuery, ProtocolTimeGrain, } from './types.js';
|
|
4
|
+
export type { ProtocolAggregation, ProtocolBinaryOperator, ProtocolComparisonOperator, ProtocolDatasetQuery, ProtocolExpression, ProtocolExpressionErrorCode, ProtocolExpressionExtension, ProtocolExpressionLimits, ProtocolExpressionOptions, ProtocolFunctionName, ProtocolMetricQuery, ProtocolOrderBy, ProtocolSemanticQuery, ProtocolQueryTimeGrain, ProtocolTimeGrain, } from './types.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expressions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,EAClB,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expressions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC1F,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,YAAY,CAAC"}
|
|
@@ -3,7 +3,12 @@ import type { CanonicalValue } from '../values/index.js';
|
|
|
3
3
|
export type ProtocolBinaryOperator = 'add' | 'subtract' | 'multiply' | 'divide';
|
|
4
4
|
export type ProtocolFunctionName = 'nullIfZero' | 'coalesce' | 'round' | 'floor' | 'ceil';
|
|
5
5
|
export type ProtocolComparisonOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'notIn' | 'between' | 'like';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Every aggregation any supported expression extension accepts.
|
|
8
|
+
* `approxCountDistinct` is extension 2 (RFC 0015); the validator rejects it
|
|
9
|
+
* under extension 1.
|
|
10
|
+
*/
|
|
11
|
+
export type ProtocolAggregation = 'sum' | 'count' | 'countDistinct' | 'avg' | 'min' | 'max' | 'argMax' | 'argMin' | 'percentile' | 'stddev' | 'variance' | 'approxCountDistinct';
|
|
7
12
|
export type ProtocolExpression = {
|
|
8
13
|
readonly kind: 'reference';
|
|
9
14
|
readonly name: ProtocolQualifiedIdentifier;
|
|
@@ -40,7 +45,16 @@ export type ProtocolExpression = {
|
|
|
40
45
|
readonly level?: number;
|
|
41
46
|
readonly filters?: readonly ProtocolExpression[];
|
|
42
47
|
};
|
|
48
|
+
/** Expression extension 1 grains, also the deployment contract 2 grain set. */
|
|
43
49
|
export type ProtocolTimeGrain = 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
50
|
+
/**
|
|
51
|
+
* Every grain a semantic query may carry under any supported extension.
|
|
52
|
+
* `minute` and `hour` are extension 2 (RFC 0015); the validator rejects them
|
|
53
|
+
* under extension 1.
|
|
54
|
+
*/
|
|
55
|
+
export type ProtocolQueryTimeGrain = 'minute' | 'hour' | ProtocolTimeGrain;
|
|
56
|
+
/** Expression extension versions this implementation validates. */
|
|
57
|
+
export type ProtocolExpressionExtension = 1 | 2;
|
|
44
58
|
export interface ProtocolOrderBy {
|
|
45
59
|
readonly field: ProtocolQualifiedIdentifier;
|
|
46
60
|
readonly direction: 'asc' | 'desc';
|
|
@@ -49,15 +63,21 @@ interface ProtocolQueryCommon {
|
|
|
49
63
|
readonly dataset: ProtocolIdentifier;
|
|
50
64
|
readonly dimensions?: readonly ProtocolQualifiedIdentifier[];
|
|
51
65
|
readonly filters?: readonly ProtocolExpression[];
|
|
66
|
+
/** Named segments, AND-combined with `filters`. Extension 2 only. */
|
|
67
|
+
readonly segments?: readonly ProtocolIdentifier[];
|
|
52
68
|
readonly orderBy?: readonly ProtocolOrderBy[];
|
|
53
69
|
readonly limit?: number;
|
|
54
70
|
readonly offset?: number;
|
|
55
|
-
readonly by?:
|
|
71
|
+
readonly by?: ProtocolQueryTimeGrain;
|
|
56
72
|
readonly includeMeta?: boolean;
|
|
57
73
|
}
|
|
58
74
|
export interface ProtocolDatasetQuery extends ProtocolQueryCommon {
|
|
59
75
|
readonly kind: 'dataset';
|
|
60
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Simple measure names. Extension 2 also accepts one-hop relationship
|
|
78
|
+
* measures such as `customer.customerCount`.
|
|
79
|
+
*/
|
|
80
|
+
readonly measures?: readonly ProtocolQualifiedIdentifier[];
|
|
61
81
|
}
|
|
62
82
|
export interface ProtocolMetricQuery extends ProtocolQueryCommon {
|
|
63
83
|
readonly kind: 'metric';
|
|
@@ -71,6 +91,12 @@ export interface ProtocolExpressionLimits {
|
|
|
71
91
|
}
|
|
72
92
|
export interface ProtocolExpressionOptions {
|
|
73
93
|
readonly limits?: Partial<ProtocolExpressionLimits>;
|
|
94
|
+
/**
|
|
95
|
+
* Expression extension to validate against. Defaults to 1. The containing
|
|
96
|
+
* artifact selects it (RFC 0015): deployment contract 3 and semantic
|
|
97
|
+
* invocation 2 use extension 2.
|
|
98
|
+
*/
|
|
99
|
+
readonly extension?: ProtocolExpressionExtension;
|
|
74
100
|
}
|
|
75
101
|
export type ProtocolExpressionErrorCode = 'HQ_EXPRESSION_TYPE' | 'HQ_EXPRESSION_UNKNOWN_FIELD' | 'HQ_EXPRESSION_UNKNOWN_KIND' | 'HQ_EXPRESSION_INVALID_IDENTIFIER' | 'HQ_EXPRESSION_INVALID_VALUE' | 'HQ_EXPRESSION_INVALID_OPERATOR' | 'HQ_EXPRESSION_INVALID_ARITY' | 'HQ_EXPRESSION_INVALID_AGGREGATION' | 'HQ_EXPRESSION_INVALID_QUERY' | 'HQ_EXPRESSION_TOO_DEEP' | 'HQ_EXPRESSION_TOO_MANY_NODES' | 'HQ_EXPRESSION_TOO_MANY_ITEMS' | 'HQ_EXPRESSION_UNSAFE_OBJECT';
|
|
76
102
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/expressions/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAC1F,MAAM,MAAM,0BAA0B,GAClC,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACrF,MAAM,MAAM,mBAAmB,GAC3B,KAAK,GAAG,OAAO,GAAG,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GACzD,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/expressions/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAC1F,MAAM,MAAM,0BAA0B,GAClC,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AACr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EAAE,CAAC,EAAE,sBAAsB,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,2BAA2B,EAAE,CAAC;CAC5D;AAED,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;CACrC;AAED,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;AAE/E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACpD;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,2BAA2B,CAAC;CAClD;AAED,MAAM,MAAM,2BAA2B,GACnC,oBAAoB,GACpB,6BAA6B,GAC7B,4BAA4B,GAC5B,kCAAkC,GAClC,6BAA6B,GAC7B,gCAAgC,GAChC,6BAA6B,GAC7B,mCAAmC,GACnC,6BAA6B,GAC7B,wBAAwB,GACxB,8BAA8B,GAC9B,8BAA8B,GAC9B,6BAA6B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/expressions/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,kBAAkB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/expressions/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,kBAAkB,EAGlB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAsQpB,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,kBAAkB,CAEpB;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,qBAAqB,CAwDvB"}
|
|
@@ -4,11 +4,15 @@ import { expressionError } from './errors.js';
|
|
|
4
4
|
import { resolveExpressionLimits } from './limits.js';
|
|
5
5
|
const BINARY = new Set(['add', 'subtract', 'multiply', 'divide']);
|
|
6
6
|
const COMPARISONS = new Set(['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'in', 'notIn', 'between', 'like']);
|
|
7
|
-
const
|
|
7
|
+
const AGGREGATIONS_V1 = new Set([
|
|
8
8
|
'sum', 'count', 'countDistinct', 'avg', 'min', 'max',
|
|
9
9
|
'argMax', 'argMin', 'percentile', 'stddev', 'variance',
|
|
10
10
|
]);
|
|
11
|
-
const
|
|
11
|
+
const AGGREGATIONS_V2 = new Set([
|
|
12
|
+
...AGGREGATIONS_V1, 'approxCountDistinct',
|
|
13
|
+
]);
|
|
14
|
+
const GRAINS_V1 = new Set(['day', 'week', 'month', 'quarter', 'year']);
|
|
15
|
+
const GRAINS_V2 = new Set(['minute', 'hour', ...GRAINS_V1]);
|
|
12
16
|
const CALL_ARITY = Object.freeze({
|
|
13
17
|
nullIfZero: [1, 1],
|
|
14
18
|
coalesce: [2, 2],
|
|
@@ -218,7 +222,8 @@ function validateComparisonOperands(operator, right, path) {
|
|
|
218
222
|
function validateAggregate(value, path, depth, state) {
|
|
219
223
|
exactFields(value, ['kind', 'aggregation', 'field'], ['argField', 'level', 'filters'], path);
|
|
220
224
|
const aggregation = stringValue(value.aggregation, `${path}.aggregation`);
|
|
221
|
-
|
|
225
|
+
const aggregations = state.extension === 2 ? AGGREGATIONS_V2 : AGGREGATIONS_V1;
|
|
226
|
+
if (!aggregations.has(aggregation))
|
|
222
227
|
expressionError('HQ_EXPRESSION_INVALID_AGGREGATION', `${path}.aggregation`);
|
|
223
228
|
const isArg = aggregation === 'argMax' || aggregation === 'argMin';
|
|
224
229
|
const isPercentile = aggregation === 'percentile';
|
|
@@ -244,7 +249,11 @@ function validateAggregate(value, path, depth, state) {
|
|
|
244
249
|
});
|
|
245
250
|
}
|
|
246
251
|
function newState(options) {
|
|
247
|
-
|
|
252
|
+
const extension = options.extension ?? 1;
|
|
253
|
+
if (extension !== 1 && extension !== 2) {
|
|
254
|
+
throw new RangeError('extension must be 1 or 2');
|
|
255
|
+
}
|
|
256
|
+
return { limits: resolveExpressionLimits(options), extension, active: new WeakSet(), nodes: 0 };
|
|
248
257
|
}
|
|
249
258
|
export function validateProtocolExpression(input, options = {}) {
|
|
250
259
|
return validateExpression(input, '$', 1, newState(options));
|
|
@@ -256,30 +265,38 @@ export function validateProtocolSemanticQuery(input, options = {}) {
|
|
|
256
265
|
try {
|
|
257
266
|
const kind = stringValue(value.kind, '$.kind');
|
|
258
267
|
const metric = kind === 'metric';
|
|
268
|
+
const v2 = state.extension === 2;
|
|
259
269
|
if (!metric && kind !== 'dataset')
|
|
260
270
|
expressionError('HQ_EXPRESSION_INVALID_QUERY', '$.kind');
|
|
261
|
-
exactFields(value, metric ? ['kind', 'dataset', 'metric'] : ['kind', 'dataset'],
|
|
262
|
-
|
|
263
|
-
: ['
|
|
271
|
+
exactFields(value, metric ? ['kind', 'dataset', 'metric'] : ['kind', 'dataset'], [
|
|
272
|
+
'dimensions',
|
|
273
|
+
...(metric ? [] : ['measures']),
|
|
274
|
+
'filters',
|
|
275
|
+
...(v2 ? ['segments'] : []),
|
|
276
|
+
'orderBy', 'limit', 'offset', 'by', 'includeMeta',
|
|
277
|
+
], '$');
|
|
264
278
|
const result = {
|
|
265
279
|
kind,
|
|
266
280
|
dataset: identifier(value.dataset, '$.dataset', false),
|
|
267
281
|
...(metric ? { metric: identifier(value.metric, '$.metric', false) } : {}),
|
|
268
282
|
};
|
|
269
283
|
copyIdentifierArray(value, result, 'dimensions', true, state);
|
|
284
|
+
// Extension 2 admits one-hop relationship measures (`customer.count`).
|
|
270
285
|
if (!metric)
|
|
271
|
-
copyIdentifierArray(value, result, 'measures',
|
|
286
|
+
copyIdentifierArray(value, result, 'measures', v2, state);
|
|
272
287
|
if (value.filters !== undefined) {
|
|
273
288
|
const filters = arrayValue(value.filters, '$.filters', state);
|
|
274
289
|
result.filters = Object.freeze(filters.map((filter, index) => validatePredicate(filter, `$.filters[${index}]`, 1, state, 'HQ_EXPRESSION_INVALID_QUERY')));
|
|
275
290
|
}
|
|
291
|
+
if (value.segments !== undefined)
|
|
292
|
+
result.segments = validateSegments(value.segments, state);
|
|
276
293
|
if (value.orderBy !== undefined)
|
|
277
294
|
result.orderBy = validateOrderBy(value.orderBy, state);
|
|
278
295
|
copyInteger(value, result, 'limit', 0);
|
|
279
296
|
copyInteger(value, result, 'offset', 0);
|
|
280
297
|
if (value.by !== undefined) {
|
|
281
298
|
const grain = stringValue(value.by, '$.by');
|
|
282
|
-
if (!
|
|
299
|
+
if (!(v2 ? GRAINS_V2 : GRAINS_V1).has(grain))
|
|
283
300
|
expressionError('HQ_EXPRESSION_INVALID_QUERY', '$.by');
|
|
284
301
|
result.by = grain;
|
|
285
302
|
}
|
|
@@ -336,3 +353,15 @@ function validateOrderBy(input, state) {
|
|
|
336
353
|
return freezeRecord({ field: identifier(value.field, `${path}.field`), direction });
|
|
337
354
|
}));
|
|
338
355
|
}
|
|
356
|
+
function validateSegments(input, state) {
|
|
357
|
+
const values = arrayValue(input, '$.segments', state);
|
|
358
|
+
const seen = new Set();
|
|
359
|
+
return Object.freeze(values.map((item, index) => {
|
|
360
|
+
const path = `$.segments[${index}]`;
|
|
361
|
+
const name = identifier(item, path, false);
|
|
362
|
+
if (seen.has(name))
|
|
363
|
+
expressionError('HQ_EXPRESSION_INVALID_QUERY', path);
|
|
364
|
+
seen.add(name);
|
|
365
|
+
return name;
|
|
366
|
+
}));
|
|
367
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,20 +5,20 @@ export { PROTOCOL_CACHE_KEY_LIMITS, ProtocolCacheKeyError, deriveProtocolCacheKe
|
|
|
5
5
|
export { DEFAULT_PROTOCOL_EXPRESSION_LIMITS, ProtocolExpressionError, validateProtocolExpression, validateProtocolSemanticQuery, } from './expressions/index.js';
|
|
6
6
|
export { DEFAULT_PROTOCOL_SCHEMA_LIMITS, DEFAULT_PROTOCOL_SCHEMA_VALUE_LIMITS, ProtocolSchemaError, ProtocolSchemaValueError, applyProtocolSchemaValue, createProtocolSchemaValueParser, resolveProtocolSchemaValueLimits, validateProtocolSchema, } from './schemas/index.js';
|
|
7
7
|
export type { ProtocolSchema, ProtocolSchemaErrorCode, ProtocolSchemaLimits, ProtocolSchemaOptions, ProtocolSchemaValueLimits, ProtocolSchemaValueOptions, ProtocolSchemaValueParser, } from './schemas/index.js';
|
|
8
|
-
export type { ProtocolAggregation, ProtocolBinaryOperator, ProtocolComparisonOperator, ProtocolDatasetQuery, ProtocolExpression, ProtocolExpressionErrorCode, ProtocolExpressionLimits, ProtocolExpressionOptions, ProtocolFunctionName, ProtocolMetricQuery, ProtocolOrderBy, ProtocolSemanticQuery, ProtocolTimeGrain, } from './expressions/index.js';
|
|
8
|
+
export type { ProtocolAggregation, ProtocolBinaryOperator, ProtocolComparisonOperator, ProtocolDatasetQuery, ProtocolExpression, ProtocolExpressionErrorCode, ProtocolExpressionExtension, ProtocolExpressionLimits, ProtocolExpressionOptions, ProtocolFunctionName, ProtocolMetricQuery, ProtocolOrderBy, ProtocolSemanticQuery, ProtocolQueryTimeGrain, ProtocolTimeGrain, } from './expressions/index.js';
|
|
9
9
|
export type { DeriveProtocolCacheKeyOptions, ProtocolCacheKeyErrorCode, ProtocolCacheKeyNamespace, } from './cache-keys/index.js';
|
|
10
10
|
export type { ProtocolIdentifier, ProtocolIdentifierErrorCode, ProtocolQualifiedIdentifier, } from './identifiers/index.js';
|
|
11
11
|
export { DEFAULT_PROTOCOL_QUERY_IMPLEMENTATION_LIMITS, ProtocolQueryImplementationError, validateProtocolQueryImplementation, validateProtocolSqlExpression, } from './query-implementations/index.js';
|
|
12
12
|
export { DEFAULT_PROTOCOL_QUERY_EVENT_LIMITS, ProtocolQueryDiagnosticsError, ProtocolQueryEventError, validateProtocolQueryDiagnostics, validateProtocolQueryEvent, } from './events/index.js';
|
|
13
13
|
export type { ProtocolQueryDiagnostics, ProtocolQueryDiagnosticsErrorCode, ProtocolQueryErrorCategory, ProtocolQueryEvent, ProtocolQueryEventErrorCode, ProtocolQueryEventLimits, ProtocolQueryEventOptions, ProtocolQueryEventOutcome, ProtocolQueryEventTarget, ProtocolQueryOperation, ProtocolQueryTerminalReason, } from './events/index.js';
|
|
14
|
-
export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS, ProtocolSemanticInvocationError, validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, } from './invocations/index.js';
|
|
15
|
-
export type { ProtocolSemanticInvocation, ProtocolSemanticInvocationBudget, ProtocolSemanticInvocationErrorCode, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationFailureCategory, ProtocolSemanticInvocationLimits, ProtocolSemanticInvocationMeta, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationPagination, ProtocolSemanticInvocationResult, ProtocolSemanticInvocationRow, ProtocolSemanticInvocationTarget, ProtocolSemanticInvocationValue, } from './invocations/index.js';
|
|
14
|
+
export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS, ProtocolSemanticInvocationError, validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, validateProtocolSemanticInvocationV2, } from './invocations/index.js';
|
|
15
|
+
export type { ProtocolSemanticInvocation, ProtocolSemanticInvocationV2, ProtocolSemanticInvocationBudget, ProtocolSemanticInvocationErrorCode, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationFailureCategory, ProtocolSemanticInvocationLimits, ProtocolSemanticInvocationMeta, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationPagination, ProtocolSemanticInvocationResult, ProtocolSemanticInvocationRow, ProtocolSemanticInvocationTarget, ProtocolSemanticInvocationValue, } from './invocations/index.js';
|
|
16
16
|
export { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, PROTOCOL_DEPLOYMENT_BUNDLE_IDENTITY_DOMAIN, ProtocolDeploymentBundleError, encodeProtocolDeploymentBundleManifest, encodeProtocolDeploymentBundleManifestToString, hashProtocolDeploymentBundleManifest, prepareProtocolDeploymentBundleManifest, validateProtocolDeploymentBundleManifest, } from './bundles/index.js';
|
|
17
17
|
export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS, PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, ProtocolDeploymentReleaseError, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './releases/index.js';
|
|
18
18
|
export type { PreparedProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseErrorCode, ProtocolDeploymentReleaseLimits, ProtocolDeploymentReleaseOptions, ProtocolDeploymentReleaseTarget, } from './releases/index.js';
|
|
19
19
|
export type { PreparedProtocolDeploymentBundleManifest, ProtocolDeploymentBundleArtifact, ProtocolDeploymentBundleDeployment, ProtocolDeploymentBundleErrorCode, ProtocolDeploymentBundleFile, ProtocolDeploymentBundleLimits, ProtocolDeploymentBundleManifest, ProtocolDeploymentBundleOptions, } from './bundles/index.js';
|
|
20
|
-
export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './deployments/index.js';
|
|
21
|
-
export type { ProtocolDatasetDerivedMeasure, ProtocolDeploymentDataset, ProtocolDeploymentMeasure, PreparedProtocolDeploymentContract, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDefaults, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetFreshness, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolSemanticMetadata, ProtocolSemanticSensitivity, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolMetricDerivation, ProtocolMetricInput, } from './deployments/index.js';
|
|
20
|
+
export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, prepareProtocolDeploymentContractV3, validateProtocolDatasetContract, validateProtocolDeploymentContract, validateProtocolDeploymentContractV3, } from './deployments/index.js';
|
|
21
|
+
export type { ProtocolDatasetDerivedMeasure, ProtocolDeploymentDataset, ProtocolDeploymentMeasure, PreparedProtocolDeploymentContract, PreparedProtocolDeploymentContractV3, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDefaults, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetFreshness, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolSemanticMetadata, ProtocolSemanticSensitivity, ProtocolDeploymentContract, ProtocolDeploymentContractV3, ProtocolDeploymentDatasetV3, ProtocolDeploymentMeasureV3, ProtocolDatasetDerivedMeasureV3, ProtocolDatasetMeasureV3, ProtocolDatasetSegment, ProtocolDatasetShiftMeasure, ProtocolDatasetWindowMeasure, ProtocolTimeInterval, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolMetricDerivation, ProtocolMetricInput, } from './deployments/index.js';
|
|
22
22
|
export type { ProtocolQueryImplementation, ProtocolQueryImplementationErrorCode, ProtocolQueryImplementationLimits, ProtocolQueryImplementationOptions, ProtocolSqlDialect, ProtocolSqlExpression, ProtocolSqlParameter, ProtocolSqlParameterSource, ProtocolSqlTenantPolicy, } from './query-implementations/index.js';
|
|
23
23
|
export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './invocations/failure-messages.js';
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,E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iC,EACjC,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,2CAA2C,EAC3C,+BAA+B,EAC/B,kCAAkC,EAClC,yCAAyC,EACzC,wCAAwC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,EACpB,6BAA6B,EAC7B,+BAA+B,EAC/B,uBAAuB,EACvB,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kCAAkC,EAClC,uBAAuB,EACvB,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,EACpC,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,cAAc,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0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EAClC,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ export { DEFAULT_PROTOCOL_EXPRESSION_LIMITS, ProtocolExpressionError, validatePr
|
|
|
5
5
|
export { DEFAULT_PROTOCOL_SCHEMA_LIMITS, DEFAULT_PROTOCOL_SCHEMA_VALUE_LIMITS, ProtocolSchemaError, ProtocolSchemaValueError, applyProtocolSchemaValue, createProtocolSchemaValueParser, resolveProtocolSchemaValueLimits, validateProtocolSchema, } from './schemas/index.js';
|
|
6
6
|
export { DEFAULT_PROTOCOL_QUERY_IMPLEMENTATION_LIMITS, ProtocolQueryImplementationError, validateProtocolQueryImplementation, validateProtocolSqlExpression, } from './query-implementations/index.js';
|
|
7
7
|
export { DEFAULT_PROTOCOL_QUERY_EVENT_LIMITS, ProtocolQueryDiagnosticsError, ProtocolQueryEventError, validateProtocolQueryDiagnostics, validateProtocolQueryEvent, } from './events/index.js';
|
|
8
|
-
export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS, ProtocolSemanticInvocationError, validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, } from './invocations/index.js';
|
|
8
|
+
export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS, ProtocolSemanticInvocationError, validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, validateProtocolSemanticInvocationV2, } from './invocations/index.js';
|
|
9
9
|
export { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, PROTOCOL_DEPLOYMENT_BUNDLE_IDENTITY_DOMAIN, ProtocolDeploymentBundleError, encodeProtocolDeploymentBundleManifest, encodeProtocolDeploymentBundleManifestToString, hashProtocolDeploymentBundleManifest, prepareProtocolDeploymentBundleManifest, validateProtocolDeploymentBundleManifest, } from './bundles/index.js';
|
|
10
10
|
export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS, PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, ProtocolDeploymentReleaseError, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './releases/index.js';
|
|
11
|
-
export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './deployments/index.js';
|
|
11
|
+
export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, PROTOCOL_DEPLOYMENT_V3_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, prepareProtocolDeploymentContractV3, validateProtocolDatasetContract, validateProtocolDeploymentContract, validateProtocolDeploymentContractV3, } from './deployments/index.js';
|
|
12
12
|
export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './invocations/failure-messages.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './failure-messages.js';
|
|
2
2
|
export { ProtocolSemanticInvocationError } from './errors.js';
|
|
3
3
|
export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS } from './limits.js';
|
|
4
|
-
export { validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, } from './validate.js';
|
|
5
|
-
export type { ProtocolSemanticInvocation, ProtocolSemanticInvocationBudget, ProtocolSemanticInvocationErrorCode, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationFailureCategory, ProtocolSemanticInvocationLimits, ProtocolSemanticInvocationMeta, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationPagination, ProtocolSemanticInvocationResult, ProtocolSemanticInvocationRow, ProtocolSemanticInvocationTarget, ProtocolSemanticInvocationValue, } from './types.js';
|
|
4
|
+
export { validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, validateProtocolSemanticInvocationV2, } from './validate.js';
|
|
5
|
+
export type { ProtocolSemanticInvocation, ProtocolSemanticInvocationV2, ProtocolSemanticInvocationBudget, ProtocolSemanticInvocationErrorCode, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationFailureCategory, ProtocolSemanticInvocationLimits, ProtocolSemanticInvocationMeta, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationPagination, ProtocolSemanticInvocationResult, ProtocolSemanticInvocationRow, ProtocolSemanticInvocationTarget, ProtocolSemanticInvocationValue, } from './types.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invocations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,2CAA2C,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,kCAAkC,EAClC,yCAAyC,EACzC,wCAAwC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invocations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,2CAA2C,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,kCAAkC,EAClC,yCAAyC,EACzC,wCAAwC,EACxC,oCAAoC,GACrC,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,gCAAgC,EAChC,mCAAmC,EACnC,iCAAiC,EACjC,yCAAyC,EACzC,gCAAgC,EAChC,8BAA8B,EAC9B,iCAAiC,EACjC,oCAAoC,EACpC,gCAAgC,EAChC,6BAA6B,EAC7B,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './failure-messages.js';
|
|
2
2
|
export { ProtocolSemanticInvocationError } from './errors.js';
|
|
3
3
|
export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS } from './limits.js';
|
|
4
|
-
export { validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, } from './validate.js';
|
|
4
|
+
export { validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, validateProtocolSemanticInvocationV2, } from './validate.js';
|
|
@@ -36,6 +36,14 @@ export interface ProtocolSemanticInvocation {
|
|
|
36
36
|
/** External correlation only; never authoritative. */
|
|
37
37
|
readonly correlationId?: string;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A semantic invocation 2 request (RFC 0015). Identical to version 1, except
|
|
41
|
+
* that `operation` is validated under expression extension 2, so it may name
|
|
42
|
+
* segments, sub-day grains, and relationship measures.
|
|
43
|
+
*/
|
|
44
|
+
export interface ProtocolSemanticInvocationV2 extends Omit<ProtocolSemanticInvocation, 'version'> {
|
|
45
|
+
readonly version: 2;
|
|
46
|
+
}
|
|
39
47
|
/**
|
|
40
48
|
* A result cell. Portable execution returns scalars; anything richer would need
|
|
41
49
|
* the RFC 0001 tagged value model, which this envelope deliberately does not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/invocations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAClD,4EAA4E;IAC5E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,gCAAgC,CAAC;IACnD,sDAAsD;IACtD,QA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QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,mCAAmC,GAC3C,oBAAoB,GACpB,6BAA6B,GAC7B,+BAA+B,GAC/B,6BAA6B,GAC7B,8BAA8B,GAC9B,yBAAyB,GACzB,6BAA6B,CAAC"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import type { ProtocolSemanticInvocation, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationResult } from './types.js';
|
|
1
|
+
import type { ProtocolSemanticInvocation, ProtocolSemanticInvocationV2, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationResult } from './types.js';
|
|
2
2
|
/** Validate one dataset or metric invocation request. */
|
|
3
3
|
export declare function validateProtocolSemanticInvocation(input: unknown, options?: ProtocolSemanticInvocationOptions): ProtocolSemanticInvocation;
|
|
4
|
+
/**
|
|
5
|
+
* Validate a semantic invocation 2 request (RFC 0015): identical to version 1
|
|
6
|
+
* except that `operation` is validated under expression extension 2.
|
|
7
|
+
*
|
|
8
|
+
* Under the lowest-version rule, a request whose operation uses no extension 2
|
|
9
|
+
* feature (a segment, a sub-day grain, or a relationship measure) must be sent
|
|
10
|
+
* as version 1, and is rejected here.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateProtocolSemanticInvocationV2(input: unknown, options?: ProtocolSemanticInvocationOptions): ProtocolSemanticInvocationV2;
|
|
4
13
|
/** Validate a successful invocation result before it is returned or cached. */
|
|
5
14
|
export declare function validateProtocolSemanticInvocationResult(input: unknown, options?: ProtocolSemanticInvocationOptions): ProtocolSemanticInvocationResult;
|
|
6
15
|
/** Validate a failed invocation before it crosses a trust boundary. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/invocations/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/invocations/validate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAE5B,iCAAiC,EAGjC,iCAAiC,EACjC,gCAAgC,EAGjC,MAAM,YAAY,CAAC;AA+KpB,yDAAyD;AACzD,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,iCAAsC,GAC9C,0BAA0B,CAE5B;AAED;;;;;;;GAOG;AACH,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,iCAAsC,GAC9C,4BAA4B,CAM9B;AAuHD,+EAA+E;AAC/E,wBAAgB,wCAAwC,CACtD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,iCAAsC,GAC9C,gCAAgC,CAiBlC;AAED,uEAAuE;AACvE,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,iCAAsC,GAC9C,iCAAiC,CAyCnC"}
|
|
@@ -122,13 +122,13 @@ function activationRevision(value, path) {
|
|
|
122
122
|
invocationError('HQ_INVOCATION_INVALID_VALUE', path);
|
|
123
123
|
return value;
|
|
124
124
|
}
|
|
125
|
-
function requireVersion(value, kind, path) {
|
|
125
|
+
function requireVersion(value, kind, path, version = 1) {
|
|
126
126
|
if (value.kind !== kind) {
|
|
127
127
|
if (typeof value.kind !== 'string')
|
|
128
128
|
invocationError('HQ_INVOCATION_TYPE', `${path}.kind`);
|
|
129
129
|
invocationError('HQ_INVOCATION_INVALID_VALUE', `${path}.kind`);
|
|
130
130
|
}
|
|
131
|
-
if (value.version !==
|
|
131
|
+
if (value.version !== version) {
|
|
132
132
|
if (typeof value.version !== 'number')
|
|
133
133
|
invocationError('HQ_INVOCATION_TYPE', `${path}.version`);
|
|
134
134
|
invocationError('HQ_INVOCATION_INVALID_VERSION', `${path}.version`);
|
|
@@ -168,15 +168,39 @@ function budget(input, path, limits) {
|
|
|
168
168
|
}
|
|
169
169
|
/** Validate one dataset or metric invocation request. */
|
|
170
170
|
export function validateProtocolSemanticInvocation(input, options = {}) {
|
|
171
|
+
return validateInvocation(input, options, 1);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Validate a semantic invocation 2 request (RFC 0015): identical to version 1
|
|
175
|
+
* except that `operation` is validated under expression extension 2.
|
|
176
|
+
*
|
|
177
|
+
* Under the lowest-version rule, a request whose operation uses no extension 2
|
|
178
|
+
* feature (a segment, a sub-day grain, or a relationship measure) must be sent
|
|
179
|
+
* as version 1, and is rejected here.
|
|
180
|
+
*/
|
|
181
|
+
export function validateProtocolSemanticInvocationV2(input, options = {}) {
|
|
182
|
+
const invocation = validateInvocation(input, options, 2);
|
|
183
|
+
if (!usesExtension2(invocation.operation)) {
|
|
184
|
+
invocationError('HQ_INVOCATION_INVALID_VERSION', '$.version');
|
|
185
|
+
}
|
|
186
|
+
return invocation;
|
|
187
|
+
}
|
|
188
|
+
function usesExtension2(operation) {
|
|
189
|
+
return (operation.segments?.length ?? 0) > 0
|
|
190
|
+
|| operation.by === 'minute'
|
|
191
|
+
|| operation.by === 'hour'
|
|
192
|
+
|| (operation.kind === 'dataset' && (operation.measures ?? []).some(measure => measure.includes('.')));
|
|
193
|
+
}
|
|
194
|
+
function validateInvocation(input, options, version) {
|
|
171
195
|
const limits = resolveSemanticInvocationLimits(options);
|
|
172
196
|
const value = requireRecord(input, '$');
|
|
173
197
|
exactFields(value, ['kind', 'version', 'target', 'operation'], ['activationRevision', 'budget', 'correlationId'], '$');
|
|
174
|
-
requireVersion(value, 'hypequery-semantic-invocation', '$');
|
|
198
|
+
requireVersion(value, 'hypequery-semantic-invocation', '$', version);
|
|
175
199
|
const result = {
|
|
176
200
|
kind: 'hypequery-semantic-invocation',
|
|
177
|
-
version
|
|
201
|
+
version,
|
|
178
202
|
target: target(value.target, '$.target', limits),
|
|
179
|
-
operation: semanticQuery(value.operation, '$.operation'),
|
|
203
|
+
operation: semanticQuery(value.operation, '$.operation', version),
|
|
180
204
|
};
|
|
181
205
|
if (value.activationRevision !== undefined) {
|
|
182
206
|
result.activationRevision = activationRevision(value.activationRevision, '$.activationRevision');
|
|
@@ -188,9 +212,10 @@ export function validateProtocolSemanticInvocation(input, options = {}) {
|
|
|
188
212
|
}
|
|
189
213
|
return freezeRecord(result);
|
|
190
214
|
}
|
|
191
|
-
function semanticQuery(input, path) {
|
|
215
|
+
function semanticQuery(input, path, version) {
|
|
192
216
|
try {
|
|
193
|
-
|
|
217
|
+
// Invocation 2 carries expression extension 2 (RFC 0015).
|
|
218
|
+
return validateProtocolSemanticQuery(input, { extension: version });
|
|
194
219
|
}
|
|
195
220
|
catch (error) {
|
|
196
221
|
if (error instanceof ProtocolExpressionError) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/values/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/values/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAuWpB,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAOhB;AAYD,kFAAkF;AAClF,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACtC,sBAAsB,CAAC,EAAE,MAAM,GAC9B,cAAc,CAGhB;AAED,6EAA6E;AAC7E,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACtC,sBAAsB,CAAC,EAAE,MAAM,GAC9B,cAAc,CAEhB"}
|
package/dist/values/validate.js
CHANGED
|
@@ -52,8 +52,10 @@ function validateUnicode(value, path, maxBytes) {
|
|
|
52
52
|
valueError('HQ_VALUE_CONTROL_CHARACTER', path);
|
|
53
53
|
}
|
|
54
54
|
if (code >= 0xd800 && code <= 0xdbff) {
|
|
55
|
+
// charCodeAt past the end is NaN, which fails every range comparison,
|
|
56
|
+
// so an unpaired high surrogate at the end must be rejected explicitly.
|
|
55
57
|
const low = value.charCodeAt(index + 1);
|
|
56
|
-
if (low
|
|
58
|
+
if (!(low >= 0xdc00 && low <= 0xdfff)) {
|
|
57
59
|
valueError('HQ_VALUE_INVALID_UNICODE', path);
|
|
58
60
|
}
|
|
59
61
|
index += 1;
|