@hypequery/protocol 0.25.0 → 0.26.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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Optional client-contract members a consumer opts into per discovery request.
3
+ *
4
+ * Validators released before a member existed reject it as an unknown field, so
5
+ * a producer emits it only to a consumer that names its feature in this request
6
+ * header. Tokens are comma-separated and case-insensitive; unknown tokens are
7
+ * ignored, and an oversized header names no features.
8
+ */
9
+ export declare const CLIENT_CONTRACT_FEATURES_HEADER = "x-hypequery-client-features";
10
+ /** Field annotations' synonyms, examples, format, unit and currency (RFC 0018, 2026-11-05). */
11
+ export declare const CLIENT_CONTRACT_FIELD_METADATA_FEATURE = "field-metadata";
12
+ /** Every feature this version understands, as one header value. */
13
+ export declare const CLIENT_CONTRACT_FEATURES = "field-metadata";
14
+ /** The feature tokens named by a features header value (`null`/`undefined` when absent). */
15
+ export declare function parseClientContractFeatures(value: string | null | undefined): ReadonlySet<string>;
16
+ /** Whether a features header value asks for field metadata. */
17
+ export declare function acceptsClientFieldMetadata(value: string | null | undefined): boolean;
18
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/client-contract/features.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAC7E,+FAA+F;AAC/F,eAAO,MAAM,sCAAsC,mBAAmB,CAAC;AACvE,mEAAmE;AACnE,eAAO,MAAM,wBAAwB,mBAAyC,CAAC;AAG/E,4FAA4F;AAC5F,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAGjG;AAED,+DAA+D;AAC/D,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEpF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Optional client-contract members a consumer opts into per discovery request.
3
+ *
4
+ * Validators released before a member existed reject it as an unknown field, so
5
+ * a producer emits it only to a consumer that names its feature in this request
6
+ * header. Tokens are comma-separated and case-insensitive; unknown tokens are
7
+ * ignored, and an oversized header names no features.
8
+ */
9
+ export const CLIENT_CONTRACT_FEATURES_HEADER = 'x-hypequery-client-features';
10
+ /** Field annotations' synonyms, examples, format, unit and currency (RFC 0018, 2026-11-05). */
11
+ export const CLIENT_CONTRACT_FIELD_METADATA_FEATURE = 'field-metadata';
12
+ /** Every feature this version understands, as one header value. */
13
+ export const CLIENT_CONTRACT_FEATURES = CLIENT_CONTRACT_FIELD_METADATA_FEATURE;
14
+ const MAX_FEATURES_HEADER_LENGTH = 256;
15
+ /** The feature tokens named by a features header value (`null`/`undefined` when absent). */
16
+ export function parseClientContractFeatures(value) {
17
+ if (typeof value !== 'string' || value.length > MAX_FEATURES_HEADER_LENGTH)
18
+ return new Set();
19
+ return new Set(value.split(',').map(token => token.replace(/^[ \t]+|[ \t]+$/g, '').toLowerCase()).filter(Boolean));
20
+ }
21
+ /** Whether a features header value asks for field metadata. */
22
+ export function acceptsClientFieldMetadata(value) {
23
+ return parseClientContractFeatures(value).has(CLIENT_CONTRACT_FIELD_METADATA_FEATURE);
24
+ }
@@ -0,0 +1,10 @@
1
+ import type { PreparedProtocolClientContract } from './types.js';
2
+ /**
3
+ * The same contract and view without field annotations' synonyms, examples,
4
+ * format, unit and currency, for a consumer that did not ask for field
5
+ * metadata. Field entries, `fields` and `annotations` left empty are omitted, so
6
+ * the result has one canonical encoding; every schemaHash is unchanged and the
7
+ * contentHash is recomputed.
8
+ */
9
+ export declare function withoutClientFieldMetadata(prepared: PreparedProtocolClientContract): PreparedProtocolClientContract;
10
+ //# sourceMappingURL=field-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-metadata.d.ts","sourceRoot":"","sources":["../../src/client-contract/field-metadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,8BAA8B,EAE/B,MAAM,YAAY,CAAC;AAsBpB;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,8BAA8B,GAAG,8BAA8B,CAQnH"}
@@ -0,0 +1,36 @@
1
+ import { prepareProtocolClientContract } from './validate.js';
2
+ function fieldText(field) {
3
+ const { label, description } = field;
4
+ if (label === undefined && description === undefined)
5
+ return undefined;
6
+ return { ...(label === undefined ? {} : { label }), ...(description === undefined ? {} : { description }) };
7
+ }
8
+ function textOnly(annotations) {
9
+ const fields = Object.fromEntries(Object.entries(annotations.fields ?? {}).flatMap(([key, field]) => {
10
+ const text = fieldText(field);
11
+ return text ? [[key, text]] : [];
12
+ }));
13
+ const { label, description } = annotations;
14
+ const result = {
15
+ ...(label === undefined ? {} : { label }),
16
+ ...(description === undefined ? {} : { description }),
17
+ ...(Object.keys(fields).length ? { fields } : {}),
18
+ };
19
+ return Object.keys(result).length ? result : undefined;
20
+ }
21
+ /**
22
+ * The same contract and view without field annotations' synonyms, examples,
23
+ * format, unit and currency, for a consumer that did not ask for field
24
+ * metadata. Field entries, `fields` and `annotations` left empty are omitted, so
25
+ * the result has one canonical encoding; every schemaHash is unchanged and the
26
+ * contentHash is recomputed.
27
+ */
28
+ export function withoutClientFieldMetadata(prepared) {
29
+ const { contract } = prepared;
30
+ const endpoints = contract.endpoints.map((endpoint) => {
31
+ const { schemaHash: _schemaHash, annotations, ...rest } = endpoint;
32
+ const text = annotations ? textOnly(annotations) : undefined;
33
+ return text ? { ...rest, annotations: text } : rest;
34
+ });
35
+ return prepareProtocolClientContract({ kind: contract.kind, version: contract.version, view: contract.view, endpoints });
36
+ }
@@ -1,8 +1,10 @@
1
1
  export { validateProtocolClientContract, prepareProtocolClientContract } from './validate.js';
2
2
  export { ProtocolClientContractError, CLIENT_ERROR_MESSAGES } from './errors.js';
3
3
  export type { ProtocolClientContractErrorCode } from './errors.js';
4
- export type { ClientDimension, ClientMeasure, ClientFilter, ClientTime, ClientQueryLimits, ClientEndpointAnnotations, ClientFieldAnnotation, ClientDatasetEndpoint, ClientMetricEndpoint, ProtocolClientEndpoint, ProtocolClientContract, PreparedProtocolClientContract, ClientFieldType, ClientWireType, } from './types.js';
4
+ export type { ClientDimension, ClientMeasure, ClientFilter, ClientTime, ClientQueryLimits, ClientAnnotationText, ClientEndpointAnnotations, ClientFieldAnnotation, ClientDatasetEndpoint, ClientMetricEndpoint, ProtocolClientEndpoint, ProtocolClientContract, PreparedProtocolClientContract, ClientFieldType, ClientWireType, } from './types.js';
5
5
  export { validateProtocolClientQuery } from './query.js';
6
6
  export type { ClientQueryPlan } from './query.js';
7
7
  export { decodeProtocolClientContract } from './decode.js';
8
+ export { CLIENT_CONTRACT_FEATURES, CLIENT_CONTRACT_FEATURES_HEADER, CLIENT_CONTRACT_FIELD_METADATA_FEATURE, acceptsClientFieldMetadata, parseClientContractFeatures, } from './features.js';
9
+ export { withoutClientFieldMetadata } from './field-metadata.js';
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client-contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACnE,YAAY,EACV,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAC3E,yBAAyB,EAAE,qBAAqB,EAChD,qBAAqB,EAAE,oBAAoB,EAAE,sBAAsB,EACnE,sBAAsB,EAAE,8BAA8B,EAAE,eAAe,EAAE,cAAc,GACxF,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client-contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACnE,YAAY,EACV,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAC3E,oBAAoB,EAAE,yBAAyB,EAAE,qBAAqB,EACtE,qBAAqB,EAAE,oBAAoB,EAAE,sBAAsB,EACnE,sBAAsB,EAAE,8BAA8B,EAAE,eAAe,EAAE,cAAc,GACxF,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,sCAAsC,EACtC,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC"}
@@ -2,3 +2,5 @@ export { validateProtocolClientContract, prepareProtocolClientContract } from '.
2
2
  export { ProtocolClientContractError, CLIENT_ERROR_MESSAGES } from './errors.js';
3
3
  export { validateProtocolClientQuery } from './query.js';
4
4
  export { decodeProtocolClientContract } from './decode.js';
5
+ export { CLIENT_CONTRACT_FEATURES, CLIENT_CONTRACT_FEATURES_HEADER, CLIENT_CONTRACT_FIELD_METADATA_FEATURE, acceptsClientFieldMetadata, parseClientContractFeatures, } from './features.js';
6
+ export { withoutClientFieldMetadata } from './field-metadata.js';
@@ -5,6 +5,8 @@ export declare function filter(input: unknown, path: string): ClientFilter;
5
5
  export declare function fields<T>(input: unknown, path: string, validate: (v: unknown, p: string) => T): Record<string, T>;
6
6
  export declare function time(input: unknown, path: string): ClientTime | null;
7
7
  export declare function limits(input: unknown, path: string): ClientQueryLimits;
8
+ /** Field annotation members after label/description, in validation order. */
9
+ export declare const CLIENT_FIELD_METADATA_MEMBERS: readonly ["synonyms", "examples", "format", "unit", "currency"];
8
10
  /** Presentation text; references to dimension/measure keys are checked with the endpoint's. */
9
11
  export declare function annotations(input: unknown, path: string): ClientEndpointAnnotations;
10
12
  //# sourceMappingURL=nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/client-contract/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAyB,YAAY,EAAE,aAAa,EAC1G,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKpD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAYvE;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAKnE;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjE;AACD,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CASjH;AACD,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CASpE;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAUtE;AAQD,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,yBAAyB,CAiBnF"}
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/client-contract/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAyB,YAAY,EAAE,aAAa,EAC1G,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKpD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,eAAe,CAYvE;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAKnE;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAQjE;AACD,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CASjH;AACD,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CASpE;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAUtE;AACD,6EAA6E;AAC7E,eAAO,MAAM,6BAA6B,iEAAkE,CAAC;AAa7G,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,yBAAyB,CAiBnF"}
@@ -1,5 +1,5 @@
1
1
  import { clientError } from './errors.js';
2
- import { bool, choice, CLIENT_FIELD_TYPES, CLIENT_GRAINS, CLIENT_OPERATORS, integer, name, names, optionalShape, pointer, record, shape, text, timezone } from './primitives.js';
2
+ import { bool, choice, CLIENT_FIELD_TYPES, CLIENT_GRAINS, CLIENT_OPERATORS, currency, integer, name, names, optionalShape, pointer, record, shape, text, textList, timezone } from './primitives.js';
3
3
  export function dimension(input, path) {
4
4
  const value = shape(input, ['type', 'wireType', 'nullable', 'groupable', 'orderable'], path);
5
5
  const type = choice(value.type, CLIENT_FIELD_TYPES, pointer(path, 'type'));
@@ -66,6 +66,8 @@ export function limits(input, path) {
66
66
  }
67
67
  return result;
68
68
  }
69
+ /** Field annotation members after label/description, in validation order. */
70
+ export const CLIENT_FIELD_METADATA_MEMBERS = ['synonyms', 'examples', 'format', 'unit', 'currency'];
69
71
  function annotation(input, path, keys) {
70
72
  const value = optionalShape(input, keys, path);
71
73
  const result = Object.create(null);
@@ -73,6 +75,16 @@ function annotation(input, path, keys) {
73
75
  result.label = text(value.label, pointer(path, 'label'));
74
76
  if (Object.hasOwn(value, 'description'))
75
77
  result.description = text(value.description, pointer(path, 'description'));
78
+ if (Object.hasOwn(value, 'synonyms'))
79
+ result.synonyms = textList(value.synonyms, pointer(path, 'synonyms'));
80
+ if (Object.hasOwn(value, 'examples'))
81
+ result.examples = textList(value.examples, pointer(path, 'examples'));
82
+ if (Object.hasOwn(value, 'format'))
83
+ result.format = text(value.format, pointer(path, 'format'));
84
+ if (Object.hasOwn(value, 'unit'))
85
+ result.unit = text(value.unit, pointer(path, 'unit'));
86
+ if (Object.hasOwn(value, 'currency'))
87
+ result.currency = currency(value.currency, pointer(path, 'currency'));
76
88
  return result;
77
89
  }
78
90
  /** Presentation text; references to dimension/measure keys are checked with the endpoint's. */
@@ -90,7 +102,7 @@ export function annotations(input, path) {
90
102
  const described = Object.create(null);
91
103
  for (const key of keys.sort()) {
92
104
  name(key, fieldsPath, true);
93
- described[key] = annotation(entries[key], pointer(fieldsPath, key), ['label', 'description']);
105
+ described[key] = annotation(entries[key], pointer(fieldsPath, key), ['label', 'description', ...CLIENT_FIELD_METADATA_MEMBERS]);
94
106
  }
95
107
  result.fields = described;
96
108
  }
@@ -15,5 +15,11 @@ export declare function names(input: unknown, path: string, allowed?: readonly s
15
15
  export declare function route(input: unknown, path: string): string;
16
16
  /** Deployment label/description rules: non-blank, control-free, at most 4096 UTF-8 bytes. */
17
17
  export declare function text(input: unknown, path: string): string;
18
+ /** At most this many synonyms or examples per field, the deployment contract's metadata ceiling. */
19
+ export declare const CLIENT_ANNOTATION_LIST_ITEMS = 100;
20
+ /** A non-empty, duplicate-free list of annotation text, in producer order. */
21
+ export declare function textList(input: unknown, path: string): string[];
22
+ /** An ISO 4217-shaped code: three uppercase ASCII letters. */
23
+ export declare function currency(input: unknown, path: string): string;
18
24
  export declare function timezone(input: unknown, path: string): string;
19
25
  //# sourceMappingURL=primitives.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/client-contract/primitives.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,eAAO,MAAM,kBAAkB,uDAAwD,CAAC;AACxF,eAAO,MAAM,aAAa,wEAAyE,CAAC;AACpG,eAAO,MAAM,gBAAgB,UAAmG,CAAC;AACjI,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAElE;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAGjE;AAMD,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAKjG;AACD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,E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AA4B,MAAM,CAAC;AAChD,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAO/D;AACD,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7D;AACD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7D"}
@@ -94,6 +94,27 @@ export function text(input, path) {
94
94
  clientError('HQ_CLIENT_SHAPE', path);
95
95
  return input;
96
96
  }
97
+ /** At most this many synonyms or examples per field, the deployment contract's metadata ceiling. */
98
+ export const CLIENT_ANNOTATION_LIST_ITEMS = 100;
99
+ /** A non-empty, duplicate-free list of annotation text, in producer order. */
100
+ export function textList(input, path) {
101
+ if (!Array.isArray(input))
102
+ clientError('HQ_CLIENT_SHAPE', path);
103
+ if (input.length > CLIENT_ANNOTATION_LIST_ITEMS)
104
+ clientError('HQ_CLIENT_LIMIT', path);
105
+ if (input.length === 0)
106
+ clientError('HQ_CLIENT_SHAPE', path);
107
+ const result = input.map((item, index) => text(item, pointer(path, index)));
108
+ if (new Set(result).size !== result.length)
109
+ clientError('HQ_CLIENT_DUPLICATE', path);
110
+ return result;
111
+ }
112
+ /** An ISO 4217-shaped code: three uppercase ASCII letters. */
113
+ export function currency(input, path) {
114
+ if (typeof input !== 'string' || !/^[A-Z]{3}$/.test(input))
115
+ clientError('HQ_CLIENT_SHAPE', path);
116
+ return input;
117
+ }
97
118
  export function timezone(input, path) {
98
119
  if (typeof input !== 'string' || !CLIENT_TIMEZONE_NAMES.has(input))
99
120
  clientError('HQ_CLIENT_SHAPE', path);
@@ -32,12 +32,26 @@ export interface ClientQueryLimits {
32
32
  readonly maxOrderBy: number;
33
33
  readonly maxFilterValues: number;
34
34
  }
35
- export interface ClientFieldAnnotation {
35
+ /** Label and description: the presentation text an endpoint group and each field may carry. */
36
+ export interface ClientAnnotationText {
36
37
  readonly label?: string;
37
38
  readonly description?: string;
38
39
  }
40
+ /**
41
+ * Field presentation metadata. Besides text, a field may carry the deployment
42
+ * contract's agent-facing vocabulary: synonyms and example values, a display
43
+ * format, a unit and an ISO 4217 currency code. Producers emit the vocabulary
44
+ * only to consumers that ask for it (`CLIENT_CONTRACT_FIELD_METADATA_FEATURE`).
45
+ */
46
+ export interface ClientFieldAnnotation extends ClientAnnotationText {
47
+ readonly synonyms?: readonly string[];
48
+ readonly examples?: readonly string[];
49
+ readonly format?: string;
50
+ readonly unit?: string;
51
+ readonly currency?: string;
52
+ }
39
53
  /** Presentation text only; excluded from schemaHash and never a capability. */
40
- export interface ClientEndpointAnnotations extends ClientFieldAnnotation {
54
+ export interface ClientEndpointAnnotations extends ClientAnnotationText {
41
55
  readonly fields?: Readonly<Record<string, ClientFieldAnnotation>>;
42
56
  }
43
57
  interface ClientEndpointBase {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client-contract/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAC5E,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAClF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AACD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IACxB,Q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,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,yBAAyB,CAAC;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AACD,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AACD,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AACD,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,GAAG,oBAAoB,CAAC;AAClF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,YAAY,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AACD,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/protocol",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Portable analytics contracts and TypeScript reference implementation for Hypequery",
5
5
  "keywords": [
6
6
  "hypequery",