@hypequery/protocol 0.11.0 → 0.12.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.
@@ -3,5 +3,5 @@ export { PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, encodeProtocolDeploymentContract,
3
3
  export type { PreparedProtocolDeploymentContract } from './codec.js';
4
4
  export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS } from './limits.js';
5
5
  export { validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './validate.js';
6
- export type { ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolNamedQueryContract, ProtocolRuntimeArtifact, } from './types.js';
6
+ export type { ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDefaults, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetFreshness, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolSemanticMetadata, ProtocolSemanticSensitivity, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolNamedQueryContract, ProtocolRuntimeArtifact, } 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,GAClC,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
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,GAClC,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,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,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/deployments/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEtF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,wBAAwB,CAQhF,CAAC;AAEH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,yBAA8B,GACtC,QAAQ,CAAC,wBAAwB,CAAC,CAcpC"}
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/deployments/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEtF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,wBAAwB,CAShF,CAAC;AAEH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,yBAA8B,GACtC,QAAQ,CAAC,wBAAwB,CAAC,CAcpC"}
@@ -3,6 +3,7 @@ export const DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS = Object.freeze({
3
3
  maxQueries: 1_000,
4
4
  maxArtifacts: 100,
5
5
  maxDatasetItems: 1_000,
6
+ maxSemanticMetadataItems: 100,
6
7
  maxTextBytes: 4_096,
7
8
  maxSourceBytes: 1_024,
8
9
  maxPathBytes: 2_048,
@@ -3,6 +3,23 @@ import type { ProtocolIdentifier, ProtocolQualifiedIdentifier } from '../identif
3
3
  import type { ProtocolQueryImplementation, ProtocolSqlExpression } from '../query-implementations/index.js';
4
4
  import type { ProtocolSchema } from '../schemas/index.js';
5
5
  export type ProtocolDatasetFieldType = 'string' | 'number' | 'boolean' | 'timestamp';
6
+ export type ProtocolSemanticSensitivity = 'public' | 'internal' | 'confidential' | 'restricted';
7
+ export interface ProtocolSemanticMetadata {
8
+ readonly examples?: readonly string[];
9
+ readonly synonyms?: readonly string[];
10
+ readonly format?: string;
11
+ readonly unit?: string;
12
+ readonly currency?: string;
13
+ readonly timezone?: string;
14
+ readonly sensitivity?: ProtocolSemanticSensitivity;
15
+ }
16
+ export interface ProtocolDatasetFreshness {
17
+ readonly maxAgeSeconds: number;
18
+ }
19
+ export interface ProtocolDatasetDefaults {
20
+ readonly dimensions?: readonly ProtocolIdentifier[];
21
+ readonly timeGrain?: ProtocolTimeGrain;
22
+ }
6
23
  export type ProtocolAccessPolicy = {
7
24
  readonly kind: 'public';
8
25
  } | {
@@ -34,7 +51,7 @@ export type ProtocolDatasetFieldSource = {
34
51
  readonly kind: 'column';
35
52
  readonly column: string;
36
53
  } | ProtocolSqlExpression;
37
- export interface ProtocolDatasetDimension {
54
+ export interface ProtocolDatasetDimension extends ProtocolSemanticMetadata {
38
55
  readonly name: ProtocolIdentifier;
39
56
  readonly type: ProtocolDatasetFieldType;
40
57
  readonly source: ProtocolDatasetFieldSource;
@@ -43,7 +60,7 @@ export interface ProtocolDatasetDimension {
43
60
  readonly label?: string;
44
61
  readonly description?: string;
45
62
  }
46
- export interface ProtocolDatasetMeasure {
63
+ export interface ProtocolDatasetMeasure extends ProtocolSemanticMetadata {
47
64
  readonly name: ProtocolIdentifier;
48
65
  readonly aggregation: 'sum' | 'count' | 'countDistinct' | 'avg' | 'min' | 'max' | 'argMax' | 'argMin' | 'percentile' | 'stddev' | 'variance';
49
66
  readonly field: ProtocolQualifiedIdentifier;
@@ -54,7 +71,7 @@ export interface ProtocolDatasetMeasure {
54
71
  readonly label?: string;
55
72
  readonly description?: string;
56
73
  }
57
- export interface ProtocolDatasetFilter {
74
+ export interface ProtocolDatasetFilter extends ProtocolSemanticMetadata {
58
75
  readonly name: ProtocolIdentifier;
59
76
  readonly field: ProtocolQualifiedIdentifier;
60
77
  readonly operators: readonly ('eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'notIn' | 'between' | 'like')[];
@@ -69,7 +86,7 @@ export interface ProtocolDatasetRelationship {
69
86
  readonly to: ProtocolQualifiedIdentifier;
70
87
  readonly queryable: boolean;
71
88
  }
72
- export interface ProtocolDatasetMetric {
89
+ export interface ProtocolDatasetMetric extends ProtocolSemanticMetadata {
73
90
  readonly name: ProtocolIdentifier;
74
91
  readonly kind: 'metric' | 'derived-metric' | 'grained-metric';
75
92
  readonly expression: ProtocolExpression;
@@ -87,9 +104,13 @@ export interface ProtocolDatasetLimits {
87
104
  readonly maxFilters?: number;
88
105
  readonly maxResultSize?: number;
89
106
  }
90
- export interface ProtocolDatasetContract {
107
+ export interface ProtocolDatasetContract extends ProtocolSemanticMetadata {
91
108
  readonly name: ProtocolIdentifier;
109
+ readonly description?: string;
92
110
  readonly source: string;
111
+ readonly freshness?: ProtocolDatasetFreshness;
112
+ readonly owner?: string;
113
+ readonly defaults?: ProtocolDatasetDefaults;
93
114
  readonly tenant: ProtocolDatasetTenantPolicy;
94
115
  readonly timeField?: ProtocolQualifiedIdentifier;
95
116
  readonly dimensions: readonly ProtocolDatasetDimension[];
@@ -129,6 +150,13 @@ export interface ProtocolDeploymentLimits {
129
150
  readonly maxQueries: number;
130
151
  readonly maxArtifacts: number;
131
152
  readonly maxDatasetItems: number;
153
+ /**
154
+ * Ceiling on each semantic-metadata collection (`examples`, `synonyms`, and
155
+ * `defaults.dimensions`). Deliberately tighter than `maxDatasetItems`: these
156
+ * are authoring aids, and the definition-time validator in
157
+ * `@hypequery/datasets` applies the same ceiling.
158
+ */
159
+ readonly maxSemanticMetadataItems: number;
132
160
  readonly maxTextBytes: number;
133
161
  readonly maxSourceBytes: number;
134
162
  readonly maxPathBytes: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/deployments/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAA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AA6B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/deployments/validate.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,uBAAuB,EASvB,0BAA0B,EAE1B,yBAAyB,EAK1B,MAAM,YAAY,CAAC;AAsfpB,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,uBAAuB,CAEzB;AAoKD,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,0BAA0B,CA2C5B"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/deployments/validate.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,uBAAuB,EASvB,0BAA0B,EAE1B,yBAAyB,EAK1B,MAAM,YAAY,CAAC;AA2lBpB,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,uBAAuB,CAEzB;AAkLD,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,yBAA8B,GACtC,0BAA0B,CA2C5B"}
@@ -14,6 +14,10 @@ const OPERATORS = new Set([
14
14
  'eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'in', 'notIn', 'between', 'like',
15
15
  ]);
16
16
  const GRAINS = new Set(['day', 'week', 'month', 'quarter', 'year']);
17
+ const SENSITIVITIES = new Set(['public', 'internal', 'confidential', 'restricted']);
18
+ const SEMANTIC_METADATA_FIELDS = [
19
+ 'examples', 'synonyms', 'format', 'unit', 'currency', 'timezone', 'sensitivity',
20
+ ];
17
21
  function requireRecord(input, path) {
18
22
  if (typeof input !== 'object' || input === null || Array.isArray(input)) {
19
23
  deploymentError('HQ_DEPLOYMENT_TYPE', path);
@@ -108,6 +112,30 @@ function uniqueStrings(input, path, maxItems, parse) {
108
112
  deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', path);
109
113
  return Object.freeze(result);
110
114
  }
115
+ function validateSemanticMetadata(value, result, path, limits) {
116
+ const parseText = (item, itemPath) => (boundedText(item, itemPath, limits.maxTextBytes));
117
+ for (const key of ['examples', 'synonyms']) {
118
+ if (value[key] !== undefined) {
119
+ result[key] = uniqueStrings(value[key], `${path}.${key}`, limits.maxSemanticMetadataItems, parseText);
120
+ }
121
+ }
122
+ for (const key of ['format', 'unit', 'timezone']) {
123
+ optionalText(value[key], key, result, path, limits);
124
+ }
125
+ if (value.currency !== undefined) {
126
+ const currency = boundedText(value.currency, `${path}.currency`, limits.maxTextBytes);
127
+ if (!/^[A-Z]{3}$/.test(currency)) {
128
+ deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.currency`);
129
+ }
130
+ result.currency = currency;
131
+ }
132
+ if (value.sensitivity !== undefined) {
133
+ if (typeof value.sensitivity !== 'string' || !SENSITIVITIES.has(value.sensitivity)) {
134
+ deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.sensitivity`);
135
+ }
136
+ result.sensitivity = value.sensitivity;
137
+ }
138
+ }
111
139
  function validateAccess(input, path, limits) {
112
140
  const value = requireRecord(input, path);
113
141
  if (value.kind === 'public') {
@@ -223,7 +251,7 @@ function validateFieldSource(input, path, limits) {
223
251
  }
224
252
  function validateDimension(input, path, limits) {
225
253
  const value = requireRecord(input, path);
226
- exactFields(value, ['name', 'type', 'source', 'filterable', 'groupable'], ['label', 'description'], path);
254
+ exactFields(value, ['name', 'type', 'source', 'filterable', 'groupable'], ['label', 'description', ...SEMANTIC_METADATA_FIELDS], path);
227
255
  if (!['string', 'number', 'boolean', 'timestamp'].includes(value.type)) {
228
256
  deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.type`);
229
257
  }
@@ -240,11 +268,12 @@ function validateDimension(input, path, limits) {
240
268
  };
241
269
  optionalText(value.label, 'label', result, path, limits);
242
270
  optionalText(value.description, 'description', result, path, limits);
271
+ validateSemanticMetadata(value, result, path, limits);
243
272
  return freezeRecord(result);
244
273
  }
245
274
  function validateMeasure(input, path, limits) {
246
275
  const value = requireRecord(input, path);
247
- exactFields(value, ['name', 'aggregation', 'field', 'filters'], ['argField', 'level', 'sql', 'label', 'description'], path);
276
+ exactFields(value, ['name', 'aggregation', 'field', 'filters'], ['argField', 'level', 'sql', 'label', 'description', ...SEMANTIC_METADATA_FIELDS], path);
248
277
  if (typeof value.aggregation !== 'string' || !AGGREGATIONS.has(value.aggregation)) {
249
278
  deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.aggregation`);
250
279
  }
@@ -275,11 +304,12 @@ function validateMeasure(input, path, limits) {
275
304
  result.sql = nested(() => validateProtocolSqlExpression(value.sql), `${path}.sql`);
276
305
  optionalText(value.label, 'label', result, path, limits);
277
306
  optionalText(value.description, 'description', result, path, limits);
307
+ validateSemanticMetadata(value, result, path, limits);
278
308
  return freezeRecord(result);
279
309
  }
280
310
  function validateFilter(input, path, limits) {
281
311
  const value = requireRecord(input, path);
282
- exactFields(value, ['name', 'field', 'operators'], ['label', 'description'], path);
312
+ exactFields(value, ['name', 'field', 'operators'], ['label', 'description', ...SEMANTIC_METADATA_FIELDS], path);
283
313
  const operators = uniqueStrings(value.operators, `${path}.operators`, limits.maxDatasetItems, (operator, operatorPath) => {
284
314
  if (typeof operator !== 'string' || !OPERATORS.has(operator)) {
285
315
  deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', operatorPath);
@@ -295,6 +325,7 @@ function validateFilter(input, path, limits) {
295
325
  };
296
326
  optionalText(value.label, 'label', result, path, limits);
297
327
  optionalText(value.description, 'description', result, path, limits);
328
+ validateSemanticMetadata(value, result, path, limits);
298
329
  return freezeRecord(result);
299
330
  }
300
331
  function validateRelationship(input, path) {
@@ -319,7 +350,7 @@ function validateRelationship(input, path) {
319
350
  }
320
351
  function validateMetric(input, path, limits) {
321
352
  const value = requireRecord(input, path);
322
- exactFields(value, ['name', 'kind', 'expression', 'dimensions', 'filters', 'grains', 'endpoint'], ['grain', 'label', 'description'], path);
353
+ exactFields(value, ['name', 'kind', 'expression', 'dimensions', 'filters', 'grains', 'endpoint'], ['grain', 'label', 'description', ...SEMANTIC_METADATA_FIELDS], path);
323
354
  if (!['metric', 'derived-metric', 'grained-metric'].includes(value.kind)) {
324
355
  deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.kind`);
325
356
  }
@@ -355,6 +386,7 @@ function validateMetric(input, path, limits) {
355
386
  result.grain = grain;
356
387
  optionalText(value.label, 'label', result, path, limits);
357
388
  optionalText(value.description, 'description', result, path, limits);
389
+ validateSemanticMetadata(value, result, path, limits);
358
390
  return freezeRecord(result);
359
391
  }
360
392
  function validateLimits(input, path) {
@@ -367,6 +399,31 @@ function validateLimits(input, path) {
367
399
  }
368
400
  return freezeRecord(result);
369
401
  }
402
+ function validateFreshness(input, path) {
403
+ const value = requireRecord(input, path);
404
+ exactFields(value, ['maxAgeSeconds'], [], path);
405
+ return freezeRecord({
406
+ maxAgeSeconds: positiveInteger(value.maxAgeSeconds, `${path}.maxAgeSeconds`),
407
+ });
408
+ }
409
+ function validateDefaults(input, path, limits) {
410
+ const value = requireRecord(input, path);
411
+ exactFields(value, [], ['dimensions', 'timeGrain'], path);
412
+ const result = {};
413
+ if (value.dimensions !== undefined) {
414
+ result.dimensions = uniqueStrings(value.dimensions, `${path}.dimensions`, limits.maxSemanticMetadataItems, (dimension, dimensionPath) => identifier(dimension, dimensionPath));
415
+ }
416
+ if (value.timeGrain !== undefined) {
417
+ if (typeof value.timeGrain !== 'string' || !GRAINS.has(value.timeGrain)) {
418
+ deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', `${path}.timeGrain`);
419
+ }
420
+ result.timeGrain = value.timeGrain;
421
+ }
422
+ if (Object.keys(result).length === 0) {
423
+ deploymentError('HQ_DEPLOYMENT_INVALID_VALUE', path);
424
+ }
425
+ return freezeRecord(result);
426
+ }
370
427
  function namedItems(input, path, maxItems, validate) {
371
428
  const items = requireArray(input, path, maxItems).map((value, index) => validate(value, `${path}[${index}]`));
372
429
  if (new Set(items.map(item => item.name)).size !== items.length) {
@@ -376,7 +433,11 @@ function namedItems(input, path, maxItems, validate) {
376
433
  }
377
434
  function validateDataset(input, path, limits) {
378
435
  const value = requireRecord(input, path);
379
- exactFields(value, ['name', 'source', 'tenant', 'dimensions', 'measures', 'filters', 'metrics', 'relationships'], ['timeField', 'limits', 'endpoint'], path);
436
+ exactFields(value, ['name', 'source', 'tenant', 'dimensions', 'measures', 'filters', 'metrics', 'relationships'], [
437
+ 'description', 'freshness', 'owner', 'defaults',
438
+ ...SEMANTIC_METADATA_FIELDS,
439
+ 'timeField', 'limits', 'endpoint',
440
+ ], path);
380
441
  const result = {
381
442
  name: identifier(value.name, `${path}.name`),
382
443
  source: boundedText(value.source, `${path}.source`, limits.maxSourceBytes),
@@ -389,6 +450,15 @@ function validateDataset(input, path, limits) {
389
450
  };
390
451
  if (value.timeField !== undefined)
391
452
  result.timeField = identifier(value.timeField, `${path}.timeField`, true);
453
+ optionalText(value.description, 'description', result, path, limits);
454
+ optionalText(value.owner, 'owner', result, path, limits);
455
+ validateSemanticMetadata(value, result, path, limits);
456
+ if (value.freshness !== undefined) {
457
+ result.freshness = validateFreshness(value.freshness, `${path}.freshness`);
458
+ }
459
+ if (value.defaults !== undefined) {
460
+ result.defaults = validateDefaults(value.defaults, `${path}.defaults`, limits);
461
+ }
392
462
  if (value.limits !== undefined)
393
463
  result.limits = validateLimits(value.limits, `${path}.limits`);
394
464
  if (value.endpoint !== undefined)
@@ -430,6 +500,12 @@ function validateArtifact(input, path) {
430
500
  function validateReferences(contract) {
431
501
  const datasets = new Map(contract.datasets.map(dataset => [dataset.name, dataset]));
432
502
  for (const [datasetIndex, dataset] of contract.datasets.entries()) {
503
+ if (dataset.defaults?.dimensions?.some(name => (!dataset.dimensions.some(dimension => dimension.name === name && dimension.groupable)))) {
504
+ deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `$.datasets[${datasetIndex}].defaults.dimensions`);
505
+ }
506
+ if (dataset.defaults?.timeGrain !== undefined && dataset.timeField === undefined) {
507
+ deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `$.datasets[${datasetIndex}].defaults.timeGrain`);
508
+ }
433
509
  for (const [relationshipIndex, relationship] of dataset.relationships.entries()) {
434
510
  if (!datasets.has(relationship.target)) {
435
511
  deploymentError('HQ_DEPLOYMENT_INVALID_REFERENCE', `$.datasets[${datasetIndex}].relationships[${relationshipIndex}].target`);
package/dist/index.d.ts CHANGED
@@ -11,11 +11,14 @@ export type { ProtocolIdentifier, ProtocolIdentifierErrorCode, ProtocolQualified
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
16
  export { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, PROTOCOL_DEPLOYMENT_BUNDLE_IDENTITY_DOMAIN, ProtocolDeploymentBundleError, encodeProtocolDeploymentBundleManifest, encodeProtocolDeploymentBundleManifestToString, hashProtocolDeploymentBundleManifest, prepareProtocolDeploymentBundleManifest, validateProtocolDeploymentBundleManifest, } from './bundles/index.js';
15
17
  export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS, PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, ProtocolDeploymentReleaseError, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './releases/index.js';
16
18
  export type { PreparedProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseErrorCode, ProtocolDeploymentReleaseLimits, ProtocolDeploymentReleaseOptions, ProtocolDeploymentReleaseTarget, } from './releases/index.js';
17
19
  export type { PreparedProtocolDeploymentBundleManifest, ProtocolDeploymentBundleArtifact, ProtocolDeploymentBundleDeployment, ProtocolDeploymentBundleErrorCode, ProtocolDeploymentBundleFile, ProtocolDeploymentBundleLimits, ProtocolDeploymentBundleManifest, ProtocolDeploymentBundleOptions, } from './bundles/index.js';
18
20
  export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './deployments/index.js';
19
- export type { PreparedProtocolDeploymentContract, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolNamedQueryContract, ProtocolRuntimeArtifact, } from './deployments/index.js';
21
+ export type { PreparedProtocolDeploymentContract, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDefaults, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetFreshness, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolSemanticMetadata, ProtocolSemanticSensitivity, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolNamedQueryContract, ProtocolRuntimeArtifact, } from './deployments/index.js';
20
22
  export type { ProtocolQueryImplementation, ProtocolQueryImplementationErrorCode, ProtocolQueryImplementationLimits, ProtocolQueryImplementationOptions, ProtocolSqlDialect, ProtocolSqlExpression, ProtocolSqlParameter, ProtocolSqlParameterSource, ProtocolSqlTenantPolicy, } from './query-implementations/index.js';
23
+ export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './invocations/failure-messages.js';
21
24
  //# sourceMappingURL=index.d.ts.map
@@ -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;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B,CAAC;AAEhC,YAAY,EACV,kCAAkC,EAClC,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GACxB,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"}
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,kC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EACrB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GACxB,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,6 +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
9
  export { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, PROTOCOL_DEPLOYMENT_BUNDLE_IDENTITY_DOMAIN, ProtocolDeploymentBundleError, encodeProtocolDeploymentBundleManifest, encodeProtocolDeploymentBundleManifestToString, hashProtocolDeploymentBundleManifest, prepareProtocolDeploymentBundleManifest, validateProtocolDeploymentBundleManifest, } from './bundles/index.js';
9
10
  export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS, PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, ProtocolDeploymentReleaseError, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './releases/index.js';
10
11
  export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './deployments/index.js';
12
+ export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './invocations/failure-messages.js';
@@ -0,0 +1,8 @@
1
+ import type { ProtocolSemanticInvocationErrorCode } from './types.js';
2
+ export declare class ProtocolSemanticInvocationError extends TypeError {
3
+ readonly code: ProtocolSemanticInvocationErrorCode;
4
+ readonly path: string;
5
+ constructor(code: ProtocolSemanticInvocationErrorCode, path?: string);
6
+ }
7
+ export declare function invocationError(code: ProtocolSemanticInvocationErrorCode, path?: string): never;
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/invocations/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAEtE,qBAAa,+BAAgC,SAAQ,SAAS;IAC5D,QAAQ,CAAC,IAAI,EAAE,mCAAmC,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,mCAAmC,EAAE,IAAI,SAAM;CAMlE;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,mCAAmC,EACzC,IAAI,SAAM,GACT,KAAK,CAEP"}
@@ -0,0 +1,13 @@
1
+ export class ProtocolSemanticInvocationError extends TypeError {
2
+ code;
3
+ path;
4
+ constructor(code, path = '$') {
5
+ super(`${code} at ${path}`);
6
+ this.name = 'ProtocolSemanticInvocationError';
7
+ this.code = code;
8
+ this.path = path;
9
+ }
10
+ }
11
+ export function invocationError(code, path = '$') {
12
+ throw new ProtocolSemanticInvocationError(code, path);
13
+ }
@@ -0,0 +1,4 @@
1
+ import type { ProtocolSemanticInvocationFailureCategory } from './types.js';
2
+ /** Fixed public messages; provider exceptions belong only in private logs. */
3
+ export declare const PROTOCOL_SEMANTIC_FAILURE_MESSAGES: Readonly<Record<ProtocolSemanticInvocationFailureCategory, string>>;
4
+ //# sourceMappingURL=failure-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure-messages.d.ts","sourceRoot":"","sources":["../../src/invocations/failure-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,YAAY,CAAC;AAE5E,8EAA8E;AAC9E,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,MAAM,CAAC,yCAAyC,EAAE,MAAM,CAAC,CAcjH,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** Fixed public messages; provider exceptions belong only in private logs. */
2
+ export const PROTOCOL_SEMANTIC_FAILURE_MESSAGES = Object.freeze({
3
+ "configuration-invalid": "The execution configuration is invalid.",
4
+ "not-found": "The requested target was not found.",
5
+ "unauthenticated": "Authentication is required.",
6
+ "forbidden": "Access is forbidden.",
7
+ "tenant-required": "A trusted tenant is required.",
8
+ "input-invalid": "The semantic query is invalid.",
9
+ "budget-exceeded": "The invocation budget was exceeded.",
10
+ "cancelled": "The invocation was cancelled.",
11
+ "stale-activation": "The pinned activation is no longer active.",
12
+ "unsupported-capability": "Portable execution cannot reproduce this target.",
13
+ "executor-unavailable": "The executor is unavailable.",
14
+ "executor-failed": "The executor failed.",
15
+ "output-invalid": "The executor returned an invalid result."
16
+ });
@@ -0,0 +1,6 @@
1
+ export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './failure-messages.js';
2
+ export { ProtocolSemanticInvocationError } from './errors.js';
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';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,GACzC,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,0BAA0B,EAC1B,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"}
@@ -0,0 +1,4 @@
1
+ export { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './failure-messages.js';
2
+ export { ProtocolSemanticInvocationError } from './errors.js';
3
+ export { DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS } from './limits.js';
4
+ export { validateProtocolSemanticInvocation, validateProtocolSemanticInvocationFailure, validateProtocolSemanticInvocationResult, } from './validate.js';
@@ -0,0 +1,4 @@
1
+ import type { ProtocolSemanticInvocationLimits, ProtocolSemanticInvocationOptions } from './types.js';
2
+ export declare const DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS: Readonly<ProtocolSemanticInvocationLimits>;
3
+ export declare function resolveSemanticInvocationLimits(options?: ProtocolSemanticInvocationOptions): Readonly<ProtocolSemanticInvocationLimits>;
4
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/invocations/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,2CAA2C,EACxD,QAAQ,CAAC,gCAAgC,CAQvC,CAAC;AAEH,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,iCAAsC,GAC9C,QAAQ,CAAC,gCAAgC,CAAC,CAe5C"}
@@ -0,0 +1,24 @@
1
+ export const DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS = Object.freeze({
2
+ maxTextBytes: 1_024,
3
+ maxMessageBytes: 1_024,
4
+ maxRows: 10_000,
5
+ maxColumnsPerRow: 256,
6
+ maxValueBytes: 65_536,
7
+ maxDeadlineMs: 3_600_000,
8
+ maxResponseBytes: 33_554_432,
9
+ });
10
+ export function resolveSemanticInvocationLimits(options = {}) {
11
+ const result = { ...DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS };
12
+ for (const key of Object.keys(result)) {
13
+ const value = options.limits?.[key];
14
+ if (value === undefined)
15
+ continue;
16
+ const maximum = DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS[key];
17
+ if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
18
+ throw new RangeError(`${key} must be a positive safe integer no greater than ${maximum} `
19
+ + '(the semantic invocation v1 maximum)');
20
+ }
21
+ result[key] = value;
22
+ }
23
+ return Object.freeze(result);
24
+ }
@@ -0,0 +1,111 @@
1
+ import type { ProtocolSemanticQuery } from '../expressions/index.js';
2
+ export interface ProtocolSemanticInvocationTarget {
3
+ readonly project: string;
4
+ readonly environment: string;
5
+ }
6
+ /**
7
+ * Caller-requested ceilings. A runtime applies the most restrictive of these,
8
+ * the endpoint policy, and its own defaults — a caller can tighten a budget but
9
+ * never widen one.
10
+ */
11
+ export interface ProtocolSemanticInvocationBudget {
12
+ readonly deadlineMs?: number;
13
+ readonly maxRows?: number;
14
+ readonly maxResponseBytes?: number;
15
+ }
16
+ /**
17
+ * One dataset or metric invocation against an activated deployment.
18
+ *
19
+ * Decision 0002 sketched the dataset/metric name beside the nested query, which
20
+ * would let the two disagree. It also permits normalizing to a single
21
+ * identifier location, so the names live only inside `operation`, whose own
22
+ * `kind` discriminates dataset from metric.
23
+ *
24
+ * There is deliberately no tenant field: a caller cannot supply or change a
25
+ * tenant, which is resolved by the provider callback inside trusted execution
26
+ * context.
27
+ */
28
+ export interface ProtocolSemanticInvocation {
29
+ readonly kind: 'hypequery-semantic-invocation';
30
+ readonly version: 1;
31
+ readonly target: ProtocolSemanticInvocationTarget;
32
+ /** Pins execution to one activation. Omit to accept whichever is active. */
33
+ readonly activationRevision?: string;
34
+ readonly operation: ProtocolSemanticQuery;
35
+ readonly budget?: ProtocolSemanticInvocationBudget;
36
+ /** External correlation only; never authoritative. */
37
+ readonly correlationId?: string;
38
+ }
39
+ /**
40
+ * A result cell. Portable execution returns scalars; anything richer would need
41
+ * the RFC 0001 tagged value model, which this envelope deliberately does not
42
+ * pull into result rows.
43
+ */
44
+ export type ProtocolSemanticInvocationValue = string | number | boolean | null;
45
+ export type ProtocolSemanticInvocationRow = Readonly<Record<string, ProtocolSemanticInvocationValue>>;
46
+ export interface ProtocolSemanticInvocationPagination {
47
+ readonly limit: number;
48
+ readonly offset: number;
49
+ readonly hasMore: boolean;
50
+ }
51
+ export interface ProtocolSemanticInvocationMeta {
52
+ readonly rowCount: number;
53
+ readonly pagination?: ProtocolSemanticInvocationPagination;
54
+ }
55
+ /**
56
+ * The successful result. Operational metadata (trace, timing, cache outcome)
57
+ * belongs in the transport's own metadata rather than beside the rows shown to
58
+ * a model, so it is not carried here.
59
+ */
60
+ export interface ProtocolSemanticInvocationResult {
61
+ readonly kind: 'hypequery-semantic-invocation-result';
62
+ readonly version: 1;
63
+ /** The activation that actually served the call, never the one requested. */
64
+ readonly activationRevision: string;
65
+ readonly data: readonly ProtocolSemanticInvocationRow[];
66
+ readonly meta: ProtocolSemanticInvocationMeta;
67
+ }
68
+ /** Provider-neutral failure categories from decision 0002, plus decision 0005. */
69
+ export type ProtocolSemanticInvocationFailureCategory = 'configuration-invalid' | 'not-found' | 'unauthenticated' | 'forbidden' | 'tenant-required' | 'input-invalid' | 'budget-exceeded' | 'cancelled' | 'stale-activation'
70
+ /** Portable execution cannot reproduce this target exactly. Decision 0005. */
71
+ | 'unsupported-capability' | 'executor-unavailable' | 'executor-failed' | 'output-invalid';
72
+ /**
73
+ * A failed invocation. Closed by construction: there is no field that accepts
74
+ * SQL, parameter values, tenant identifiers, physical source details, stack
75
+ * traces, or a provider exception.
76
+ */
77
+ export interface ProtocolSemanticInvocationFailure {
78
+ readonly kind: 'hypequery-semantic-invocation-failure';
79
+ readonly version: 1;
80
+ readonly category: ProtocolSemanticInvocationFailureCategory;
81
+ /** Stable machine-readable code, e.g. `HQ_SEMANTIC_TENANT_REQUIRED`. */
82
+ readonly code: string;
83
+ readonly message: string;
84
+ /** Bounded input path for a correctable failure, e.g. `$.operation.limit`. */
85
+ readonly path?: string;
86
+ readonly retryable: boolean;
87
+ /** The caller must re-read discovery before retrying. */
88
+ readonly relist: boolean;
89
+ readonly activationRevision?: string;
90
+ }
91
+ export interface ProtocolSemanticInvocationLimits {
92
+ readonly maxTextBytes: number;
93
+ readonly maxMessageBytes: number;
94
+ readonly maxRows: number;
95
+ readonly maxColumnsPerRow: number;
96
+ readonly maxValueBytes: number;
97
+ readonly maxDeadlineMs: number;
98
+ readonly maxResponseBytes: number;
99
+ }
100
+ /**
101
+ * Validation budgets for a semantic invocation.
102
+ *
103
+ * Each configured value must be a positive safe integer no greater than the
104
+ * corresponding value in `DEFAULT_PROTOCOL_SEMANTIC_INVOCATION_LIMITS`. These
105
+ * options may tighten the v1 conformance limits but cannot raise them.
106
+ */
107
+ export interface ProtocolSemanticInvocationOptions {
108
+ readonly limits?: Partial<ProtocolSemanticInvocationLimits>;
109
+ }
110
+ export type ProtocolSemanticInvocationErrorCode = 'HQ_INVOCATION_TYPE' | 'HQ_INVOCATION_UNKNOWN_FIELD' | 'HQ_INVOCATION_INVALID_VERSION' | 'HQ_INVOCATION_INVALID_VALUE' | 'HQ_INVOCATION_TOO_MANY_ITEMS' | 'HQ_INVOCATION_TOO_LARGE' | 'HQ_INVOCATION_UNSAFE_OBJECT';
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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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AC7D;AAED,MAAM,MAAM,mCAAmC,GAC3C,oBAAoB,GACpB,6BAA6B,GAC7B,+BAA+B,GAC/B,6BAA6B,GAC7B,8BAA8B,GAC9B,yBAAyB,GACzB,6BAA6B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ProtocolSemanticInvocation, ProtocolSemanticInvocationFailure, ProtocolSemanticInvocationOptions, ProtocolSemanticInvocationResult } from './types.js';
2
+ /** Validate one dataset or metric invocation request. */
3
+ export declare function validateProtocolSemanticInvocation(input: unknown, options?: ProtocolSemanticInvocationOptions): ProtocolSemanticInvocation;
4
+ /** Validate a successful invocation result before it is returned or cached. */
5
+ export declare function validateProtocolSemanticInvocationResult(input: unknown, options?: ProtocolSemanticInvocationOptions): ProtocolSemanticInvocationResult;
6
+ /** Validate a failed invocation before it crosses a trust boundary. */
7
+ export declare function validateProtocolSemanticInvocationFailure(input: unknown, options?: ProtocolSemanticInvocationOptions): ProtocolSemanticInvocationFailure;
8
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/invocations/validate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,0BAA0B,EAE1B,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,CAgC5B;AAyED,+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"}
@@ -0,0 +1,306 @@
1
+ import { ProtocolExpressionError, validateProtocolSemanticQuery } from '../expressions/index.js';
2
+ import { PROTOCOL_SEMANTIC_FAILURE_MESSAGES } from './failure-messages.js';
3
+ import { invocationError } from './errors.js';
4
+ import { resolveSemanticInvocationLimits } from './limits.js';
5
+ const HEX64_PATTERN = /^[0-9a-f]{64}$/;
6
+ const FAILURE_CATEGORIES = [
7
+ 'configuration-invalid',
8
+ 'not-found',
9
+ 'unauthenticated',
10
+ 'forbidden',
11
+ 'tenant-required',
12
+ 'input-invalid',
13
+ 'budget-exceeded',
14
+ 'cancelled',
15
+ 'stale-activation',
16
+ 'unsupported-capability',
17
+ 'executor-unavailable',
18
+ 'executor-failed',
19
+ 'output-invalid',
20
+ ];
21
+ const FAILURE_CODE_PATTERN = /^[A-Z][A-Z0-9_]*$/;
22
+ const textEncoder = new TextEncoder();
23
+ function requireRecord(input, path) {
24
+ if (typeof input !== 'object' || input === null || Array.isArray(input)) {
25
+ invocationError('HQ_INVOCATION_TYPE', path);
26
+ }
27
+ const prototype = Object.getPrototypeOf(input);
28
+ if (prototype !== Object.prototype && prototype !== null) {
29
+ invocationError('HQ_INVOCATION_UNSAFE_OBJECT', path);
30
+ }
31
+ if (Object.getOwnPropertySymbols(input).length > 0) {
32
+ invocationError('HQ_INVOCATION_UNSAFE_OBJECT', path);
33
+ }
34
+ for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(input))) {
35
+ if (!descriptor.enumerable || !('value' in descriptor)) {
36
+ invocationError('HQ_INVOCATION_UNSAFE_OBJECT', path);
37
+ }
38
+ }
39
+ return input;
40
+ }
41
+ function requireArray(input, path, maximum) {
42
+ if (!Array.isArray(input))
43
+ invocationError('HQ_INVOCATION_TYPE', path);
44
+ if (input.length > maximum)
45
+ invocationError('HQ_INVOCATION_TOO_MANY_ITEMS', path);
46
+ if (Object.getPrototypeOf(input) !== Array.prototype || Object.getOwnPropertySymbols(input).length > 0) {
47
+ invocationError('HQ_INVOCATION_UNSAFE_OBJECT', path);
48
+ }
49
+ const descriptors = Object.getOwnPropertyDescriptors(input);
50
+ if (Object.keys(descriptors).length !== input.length + 1) {
51
+ invocationError('HQ_INVOCATION_UNSAFE_OBJECT', path);
52
+ }
53
+ for (let index = 0; index < input.length; index++) {
54
+ const descriptor = descriptors[String(index)];
55
+ if (!descriptor || !descriptor.enumerable || !('value' in descriptor)) {
56
+ invocationError('HQ_INVOCATION_UNSAFE_OBJECT', path);
57
+ }
58
+ }
59
+ return input;
60
+ }
61
+ function exactFields(value, required, optional, path) {
62
+ const allowed = new Set([...required, ...optional]);
63
+ for (const key of Object.keys(value)) {
64
+ if (!allowed.has(key))
65
+ invocationError('HQ_INVOCATION_UNKNOWN_FIELD', `${path}.${key}`);
66
+ }
67
+ for (const key of required) {
68
+ if (!Object.hasOwn(value, key))
69
+ invocationError('HQ_INVOCATION_TYPE', `${path}.${key}`);
70
+ }
71
+ }
72
+ function freezeRecord(entries) {
73
+ return Object.freeze(Object.assign(Object.create(null), entries));
74
+ }
75
+ function hasControlCharacter(text) {
76
+ for (let index = 0; index < text.length; index += 1) {
77
+ const code = text.charCodeAt(index);
78
+ if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
79
+ return true;
80
+ }
81
+ return false;
82
+ }
83
+ function boundedText(value, path, maximum) {
84
+ if (typeof value !== 'string')
85
+ invocationError('HQ_INVOCATION_TYPE', path);
86
+ if (value.length > maximum || textEncoder.encode(value).byteLength > maximum) {
87
+ invocationError('HQ_INVOCATION_TOO_LARGE', path);
88
+ }
89
+ if (hasControlCharacter(value))
90
+ invocationError('HQ_INVOCATION_INVALID_VALUE', path);
91
+ return value;
92
+ }
93
+ function boundedInteger(value, path, maximum) {
94
+ if (typeof value !== 'number')
95
+ invocationError('HQ_INVOCATION_TYPE', path);
96
+ if (!Number.isSafeInteger(value) || value < 1) {
97
+ invocationError('HQ_INVOCATION_INVALID_VALUE', path);
98
+ }
99
+ if (value > maximum)
100
+ invocationError('HQ_INVOCATION_TOO_LARGE', path);
101
+ return value;
102
+ }
103
+ function nonNegativeInteger(value, path, maximum) {
104
+ if (typeof value !== 'number')
105
+ invocationError('HQ_INVOCATION_TYPE', path);
106
+ if (!Number.isSafeInteger(value) || value < 0) {
107
+ invocationError('HQ_INVOCATION_INVALID_VALUE', path);
108
+ }
109
+ if (value > maximum)
110
+ invocationError('HQ_INVOCATION_TOO_LARGE', path);
111
+ return value;
112
+ }
113
+ function requireBoolean(value, path) {
114
+ if (typeof value !== 'boolean')
115
+ invocationError('HQ_INVOCATION_TYPE', path);
116
+ return value;
117
+ }
118
+ function activationRevision(value, path) {
119
+ if (typeof value !== 'string')
120
+ invocationError('HQ_INVOCATION_TYPE', path);
121
+ if (!HEX64_PATTERN.test(value))
122
+ invocationError('HQ_INVOCATION_INVALID_VALUE', path);
123
+ return value;
124
+ }
125
+ function requireVersion(value, kind, path) {
126
+ if (value.kind !== kind) {
127
+ if (typeof value.kind !== 'string')
128
+ invocationError('HQ_INVOCATION_TYPE', `${path}.kind`);
129
+ invocationError('HQ_INVOCATION_INVALID_VALUE', `${path}.kind`);
130
+ }
131
+ if (value.version !== 1) {
132
+ if (typeof value.version !== 'number')
133
+ invocationError('HQ_INVOCATION_TYPE', `${path}.version`);
134
+ invocationError('HQ_INVOCATION_INVALID_VERSION', `${path}.version`);
135
+ }
136
+ }
137
+ function target(input, path, limits) {
138
+ const value = requireRecord(input, path);
139
+ exactFields(value, ['project', 'environment'], [], path);
140
+ const result = {};
141
+ for (const key of ['project', 'environment']) {
142
+ const text = boundedText(value[key], `${path}.${key}`, limits.maxTextBytes);
143
+ if (!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(text)) {
144
+ invocationError('HQ_INVOCATION_INVALID_VALUE', `${path}.${key}`);
145
+ }
146
+ result[key] = text;
147
+ }
148
+ return freezeRecord(result);
149
+ }
150
+ function budget(input, path, limits) {
151
+ const value = requireRecord(input, path);
152
+ exactFields(value, [], ['deadlineMs', 'maxRows', 'maxResponseBytes'], path);
153
+ const result = {};
154
+ if (value.deadlineMs !== undefined) {
155
+ result.deadlineMs = boundedInteger(value.deadlineMs, `${path}.deadlineMs`, limits.maxDeadlineMs);
156
+ }
157
+ if (value.maxRows !== undefined) {
158
+ result.maxRows = boundedInteger(value.maxRows, `${path}.maxRows`, limits.maxRows);
159
+ }
160
+ if (value.maxResponseBytes !== undefined) {
161
+ result.maxResponseBytes = boundedInteger(value.maxResponseBytes, `${path}.maxResponseBytes`, limits.maxResponseBytes);
162
+ }
163
+ // An empty budget is indistinguishable from omitting the field, and two
164
+ // encodings of the same request are not portable.
165
+ if (Object.keys(result).length === 0)
166
+ invocationError('HQ_INVOCATION_INVALID_VALUE', path);
167
+ return freezeRecord(result);
168
+ }
169
+ /** Validate one dataset or metric invocation request. */
170
+ export function validateProtocolSemanticInvocation(input, options = {}) {
171
+ const limits = resolveSemanticInvocationLimits(options);
172
+ const value = requireRecord(input, '$');
173
+ exactFields(value, ['kind', 'version', 'target', 'operation'], ['activationRevision', 'budget', 'correlationId'], '$');
174
+ requireVersion(value, 'hypequery-semantic-invocation', '$');
175
+ const result = {
176
+ kind: 'hypequery-semantic-invocation',
177
+ version: 1,
178
+ target: target(value.target, '$.target', limits),
179
+ operation: semanticQuery(value.operation, '$.operation'),
180
+ };
181
+ if (value.activationRevision !== undefined) {
182
+ result.activationRevision = activationRevision(value.activationRevision, '$.activationRevision');
183
+ }
184
+ if (value.budget !== undefined)
185
+ result.budget = budget(value.budget, '$.budget', limits);
186
+ if (value.correlationId !== undefined) {
187
+ result.correlationId = boundedText(value.correlationId, '$.correlationId', limits.maxTextBytes);
188
+ }
189
+ return freezeRecord(result);
190
+ }
191
+ function semanticQuery(input, path) {
192
+ try {
193
+ return validateProtocolSemanticQuery(input);
194
+ }
195
+ catch (error) {
196
+ if (error instanceof ProtocolExpressionError) {
197
+ invocationError('HQ_INVOCATION_INVALID_VALUE', path);
198
+ }
199
+ throw error;
200
+ }
201
+ }
202
+ function row(input, path, limits) {
203
+ const value = requireRecord(input, path);
204
+ const keys = Object.keys(value);
205
+ if (keys.length > limits.maxColumnsPerRow) {
206
+ invocationError('HQ_INVOCATION_TOO_MANY_ITEMS', path);
207
+ }
208
+ const result = {};
209
+ for (const key of keys) {
210
+ const cell = value[key];
211
+ const cellPath = `${path}.${key}`;
212
+ if (cell === null || typeof cell === 'boolean') {
213
+ result[key] = cell;
214
+ }
215
+ else if (typeof cell === 'number') {
216
+ // A non-finite number has no portable JSON encoding.
217
+ if (!Number.isFinite(cell))
218
+ invocationError('HQ_INVOCATION_INVALID_VALUE', cellPath);
219
+ result[key] = cell;
220
+ }
221
+ else if (typeof cell === 'string') {
222
+ if (textEncoder.encode(cell).byteLength > limits.maxValueBytes) {
223
+ invocationError('HQ_INVOCATION_TOO_LARGE', cellPath);
224
+ }
225
+ if (hasControlCharacter(cell))
226
+ invocationError('HQ_INVOCATION_INVALID_VALUE', cellPath);
227
+ result[key] = cell;
228
+ }
229
+ else {
230
+ invocationError('HQ_INVOCATION_TYPE', cellPath);
231
+ }
232
+ }
233
+ return freezeRecord(result);
234
+ }
235
+ function meta(input, path, limits, rowCount) {
236
+ const value = requireRecord(input, path);
237
+ exactFields(value, ['rowCount'], ['pagination'], path);
238
+ const declared = nonNegativeInteger(value.rowCount, `${path}.rowCount`, limits.maxRows);
239
+ // A rowCount that disagrees with the rows it describes is a broken result,
240
+ // not a hint — the caller would page or aggregate on a false total.
241
+ if (declared !== rowCount)
242
+ invocationError('HQ_INVOCATION_INVALID_VALUE', `${path}.rowCount`);
243
+ const result = { rowCount: declared };
244
+ if (value.pagination !== undefined) {
245
+ const paginationPath = `${path}.pagination`;
246
+ const pagination = requireRecord(value.pagination, paginationPath);
247
+ exactFields(pagination, ['limit', 'offset', 'hasMore'], [], paginationPath);
248
+ result.pagination = freezeRecord({
249
+ limit: boundedInteger(pagination.limit, `${paginationPath}.limit`, limits.maxRows),
250
+ offset: nonNegativeInteger(pagination.offset, `${paginationPath}.offset`, Number.MAX_SAFE_INTEGER),
251
+ hasMore: requireBoolean(pagination.hasMore, `${paginationPath}.hasMore`),
252
+ });
253
+ }
254
+ return freezeRecord(result);
255
+ }
256
+ /** Validate a successful invocation result before it is returned or cached. */
257
+ export function validateProtocolSemanticInvocationResult(input, options = {}) {
258
+ const limits = resolveSemanticInvocationLimits(options);
259
+ const value = requireRecord(input, '$');
260
+ exactFields(value, ['kind', 'version', 'activationRevision', 'data', 'meta'], [], '$');
261
+ requireVersion(value, 'hypequery-semantic-invocation-result', '$');
262
+ const rows = requireArray(value.data, '$.data', limits.maxRows);
263
+ const data = Object.freeze(rows.map((entry, index) => row(entry, `$.data[${index}]`, limits)));
264
+ return freezeRecord({
265
+ kind: 'hypequery-semantic-invocation-result',
266
+ version: 1,
267
+ activationRevision: activationRevision(value.activationRevision, '$.activationRevision'),
268
+ data,
269
+ meta: meta(value.meta, '$.meta', limits, data.length),
270
+ });
271
+ }
272
+ /** Validate a failed invocation before it crosses a trust boundary. */
273
+ export function validateProtocolSemanticInvocationFailure(input, options = {}) {
274
+ const limits = resolveSemanticInvocationLimits(options);
275
+ const value = requireRecord(input, '$');
276
+ exactFields(value, ['kind', 'version', 'category', 'code', 'message', 'retryable', 'relist'], ['path', 'activationRevision'], '$');
277
+ requireVersion(value, 'hypequery-semantic-invocation-failure', '$');
278
+ if (typeof value.category !== 'string')
279
+ invocationError('HQ_INVOCATION_TYPE', '$.category');
280
+ if (!FAILURE_CATEGORIES.includes(value.category)) {
281
+ invocationError('HQ_INVOCATION_INVALID_VALUE', '$.category');
282
+ }
283
+ const message = boundedText(value.message, '$.message', limits.maxMessageBytes);
284
+ if (message !== PROTOCOL_SEMANTIC_FAILURE_MESSAGES[value.category]) {
285
+ invocationError('HQ_INVOCATION_INVALID_VALUE', '$.message');
286
+ }
287
+ const code = boundedText(value.code, '$.code', limits.maxTextBytes);
288
+ if (!FAILURE_CODE_PATTERN.test(code))
289
+ invocationError('HQ_INVOCATION_INVALID_VALUE', '$.code');
290
+ const result = {
291
+ kind: 'hypequery-semantic-invocation-failure',
292
+ version: 1,
293
+ category: value.category,
294
+ code,
295
+ message,
296
+ retryable: requireBoolean(value.retryable, '$.retryable'),
297
+ relist: requireBoolean(value.relist, '$.relist'),
298
+ };
299
+ if (value.path !== undefined) {
300
+ result.path = boundedText(value.path, '$.path', limits.maxTextBytes);
301
+ }
302
+ if (value.activationRevision !== undefined) {
303
+ result.activationRevision = activationRevision(value.activationRevision, '$.activationRevision');
304
+ }
305
+ return freezeRecord(result);
306
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/protocol",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Portable analytics contracts and TypeScript reference implementation for Hypequery",
5
5
  "keywords": [
6
6
  "hypequery",
@@ -18,7 +18,8 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
21
+ "import": "./dist/index.js",
22
+ "default": "./dist/index.js"
22
23
  }
23
24
  },
24
25
  "files": [