@jarenjs/linq 0.67.0 → 0.72.2

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,481 @@
1
+ // Derived from chart-definition.schema.json by scripts/generate-chart-pen.js.
2
+ /**
3
+ * createStreamAdapter mapping: how reader events accumulate into this chart's data
4
+ */
5
+ export interface StreamSpec {
6
+ recordPath?: Array<string | number>;
7
+ recordBoundary?: "path" | "document";
8
+ xField?: string;
9
+ yField?: string;
10
+ seriesField?: string;
11
+ /**
12
+ * Schema constraints this type cannot express: type="integer", minimum=1
13
+ */
14
+ maxPoints?: number;
15
+ [key: string]: unknown;
16
+ }
17
+
18
+
19
+ export interface Slice {
20
+ label: string;
21
+ /**
22
+ * Schema constraints this type cannot express: minimum=0
23
+ */
24
+ value: number;
25
+ [key: string]: unknown;
26
+ }
27
+
28
+
29
+ export type Tone = "win" | "loss" | null;
30
+
31
+ export interface BarSeries {
32
+ name: string;
33
+ values: Array<number | null>;
34
+ tone?: Tone;
35
+ tones?: Array<Tone>;
36
+ [key: string]: unknown;
37
+ }
38
+
39
+
40
+ export interface Point {
41
+ x: number;
42
+ y: number;
43
+ tone?: Tone;
44
+ [key: string]: unknown;
45
+ }
46
+
47
+
48
+ export interface LineSeries {
49
+ name: string;
50
+ points: Array<Point>;
51
+ [key: string]: unknown;
52
+ }
53
+
54
+
55
+ export interface Candle {
56
+ t: number;
57
+ open: number;
58
+ high: number;
59
+ low: number;
60
+ close: number;
61
+ [key: string]: unknown;
62
+ }
63
+
64
+
65
+ /**
66
+ * a named series of index-aligned values (radar axes / streamgraph samples)
67
+ */
68
+ export interface ValueSeries {
69
+ name: string;
70
+ values: Array<number | null>;
71
+ [key: string]: unknown;
72
+ }
73
+
74
+
75
+ /**
76
+ * one boxplot category: raw samples in `values`, or a precomputed five-number summary
77
+ */
78
+ export type Box = ({ values: unknown; [key: string]: unknown; } | Array<unknown> | string | number | boolean | null | { min: unknown; q1: unknown; med: unknown; q3: unknown; max: unknown; [key: string]: unknown; }) & { label: string; values?: Array<number | null>; min?: number; q1?: number; med?: number; q3?: number; max?: number; outliers?: Array<number>; [key: string]: unknown; };
79
+
80
+ export interface TreemapItem {
81
+ label: string;
82
+ /**
83
+ * Schema constraints this type cannot express: exclusiveMinimum=0
84
+ */
85
+ value: number;
86
+ [key: string]: unknown;
87
+ }
88
+
89
+
90
+ /**
91
+ * one hierarchy level: the group's value is its children's sum
92
+ */
93
+ export interface TreemapGroup {
94
+ label: string;
95
+ /**
96
+ * Schema constraints this type cannot express: minItems=1
97
+ */
98
+ children: Array<TreemapItem>;
99
+ [key: string]: unknown;
100
+ }
101
+
102
+
103
+ /**
104
+ * a flow from source to target; endpoints are node names or node indexes
105
+ */
106
+ export interface SankeyLink {
107
+ /**
108
+ * Schema constraints this type cannot express: type="integer"
109
+ */
110
+ source: string | number;
111
+ /**
112
+ * Schema constraints this type cannot express: type="integer"
113
+ */
114
+ target: string | number;
115
+ /**
116
+ * Schema constraints this type cannot express: exclusiveMinimum=0
117
+ */
118
+ value: number;
119
+ [key: string]: unknown;
120
+ }
121
+
122
+
123
+ /**
124
+ * Schema constraints this type cannot express: minimum=-180, maximum=180
125
+ */
126
+ export type MapPointAtItem1 = number;
127
+
128
+ /**
129
+ * Schema constraints this type cannot express: minimum=-90, maximum=90
130
+ */
131
+ export type MapPointAtItem2 = number;
132
+
133
+ /**
134
+ * a place marker: the convenience path for a caller holding positions rather than GeoJSON
135
+ */
136
+ export interface MapPoint {
137
+ /**
138
+ * a GeoJSON position: [longitude, latitude]
139
+ * Schema constraints this type cannot express: minItems=2, maxItems=3
140
+ */
141
+ at: [MapPointAtItem1, MapPointAtItem2, ...Array<number>];
142
+ label?: string;
143
+ value?: number;
144
+ [key: string]: unknown;
145
+ }
146
+
147
+
148
+ export interface SamplingPolicyAnyOf3 {
149
+ method?: "lttb" | "minmax";
150
+ /**
151
+ * the most points one series may draw; an explicit target makes the rendered line independent of any layout
152
+ * Schema constraints this type cannot express: type="integer", minimum=2
153
+ */
154
+ target?: number;
155
+ /**
156
+ * the width the derived target assumes, in CSS pixels (default 560)
157
+ * Schema constraints this type cannot express: exclusiveMinimum=0
158
+ */
159
+ width?: number;
160
+ /**
161
+ * Schema constraints this type cannot express: exclusiveMinimum=0
162
+ */
163
+ pixelRatio?: number;
164
+ [key: string]: unknown;
165
+ }
166
+
167
+
168
+ /**
169
+ * how many of a line's points are drawn: false never samples, a method name or object samples whatever the count, and an omitted member samples a TIME line above 2000 points through @jarenjs/core/series. Distinct from stream.maxPoints, which decides what exists rather than what is drawn.
170
+ */
171
+ export type SamplingPolicy = false | "lttb" | "minmax" | SamplingPolicyAnyOf3;
172
+
173
+ /**
174
+ * the month, weekday and meridiem names a time-axis pattern with a name token reads (compileDateLocale(pack).names from @jarenjs/locales); a name token with no record is a compile error, never an English fallback
175
+ */
176
+ export interface DateNames {
177
+ /**
178
+ * Schema constraints this type cannot express: minItems=12, maxItems=12
179
+ */
180
+ months?: Array<string>;
181
+ /**
182
+ * Schema constraints this type cannot express: minItems=12, maxItems=12
183
+ */
184
+ monthsShort?: Array<string>;
185
+ /**
186
+ * Schema constraints this type cannot express: minItems=7, maxItems=7
187
+ */
188
+ weekdays?: Array<string>;
189
+ /**
190
+ * Schema constraints this type cannot express: minItems=7, maxItems=7
191
+ */
192
+ weekdaysShort?: Array<string>;
193
+ /**
194
+ * Schema constraints this type cannot express: minItems=2, maxItems=2
195
+ */
196
+ meridiem?: Array<string>;
197
+ [key: string]: unknown;
198
+ }
199
+
200
+
201
+ /**
202
+ * LDML label patterns for a time axis, keyed by the granularity of the tick step; an omitted member keeps its numeric default (HH:mm:ss, HH:mm, yyyy-MM-dd, yyyy-MM, yyyy)
203
+ */
204
+ export interface TimeFormats {
205
+ second?: string;
206
+ minute?: string;
207
+ day?: string;
208
+ month?: string;
209
+ year?: string;
210
+ [key: string]: unknown;
211
+ }
212
+
213
+
214
+ export interface DomainPolicyX {
215
+ /**
216
+ * Schema constraints this type cannot express: exclusiveMinimum=0
217
+ */
218
+ window: number;
219
+ /**
220
+ * Schema constraints this type cannot express: exclusiveMinimum=0
221
+ */
222
+ slide?: number;
223
+ [key: string]: unknown;
224
+ }
225
+
226
+
227
+ /**
228
+ * domain-stability policy: a quantized sliding x window and/or pinned or step-quantized y bounds, so most streaming ticks keep the scales still
229
+ */
230
+ export interface DomainPolicy {
231
+ x?: DomainPolicyX;
232
+ y?: "step" | { min?: number; max?: number; [key: string]: unknown; };
233
+ [key: string]: unknown;
234
+ }
235
+
236
+
237
+ export interface PieChart {
238
+ type: "pie";
239
+ title?: string | null;
240
+ stream?: StreamSpec;
241
+ /**
242
+ * true for the default hole fraction, or the hole radius as a fraction of the outer radius
243
+ * Schema constraints this type cannot express: exclusiveMinimum=0, exclusiveMaximum=1
244
+ */
245
+ donut?: boolean | number;
246
+ slices?: Array<Slice>;
247
+ }
248
+
249
+
250
+ export interface BarChart {
251
+ type: "bar";
252
+ title?: string | null;
253
+ stream?: StreamSpec;
254
+ stacked?: boolean;
255
+ log?: boolean;
256
+ orient?: "v" | "h";
257
+ catLabel?: string | null;
258
+ valLabel?: string | null;
259
+ categories?: Array<string>;
260
+ series?: Array<BarSeries>;
261
+ }
262
+
263
+
264
+ export interface LineChart {
265
+ type: "line";
266
+ title?: string | null;
267
+ stream?: StreamSpec;
268
+ x?: "linear" | "time";
269
+ log?: boolean;
270
+ markers?: boolean;
271
+ xLabel?: string | null;
272
+ yLabel?: string | null;
273
+ domain?: DomainPolicy;
274
+ sampling?: SamplingPolicy;
275
+ dateNames?: DateNames;
276
+ timeFormats?: TimeFormats;
277
+ series?: Array<LineSeries>;
278
+ }
279
+
280
+
281
+ export interface ScatterChart {
282
+ type: "scatter";
283
+ title?: string | null;
284
+ stream?: StreamSpec;
285
+ xLog?: boolean;
286
+ yLog?: boolean;
287
+ refY?: number;
288
+ refLabel?: string | null;
289
+ xLabel?: string | null;
290
+ yLabel?: string | null;
291
+ points?: Array<Point>;
292
+ }
293
+
294
+
295
+ export interface CandlestickChart {
296
+ type: "candlestick";
297
+ title?: string | null;
298
+ stream?: StreamSpec;
299
+ xLabel?: string | null;
300
+ yLabel?: string | null;
301
+ domain?: DomainPolicy;
302
+ dateNames?: DateNames;
303
+ timeFormats?: TimeFormats;
304
+ candles?: Array<Candle>;
305
+ }
306
+
307
+
308
+ export interface RadarChart {
309
+ type: "radar";
310
+ title?: string | null;
311
+ stream?: StreamSpec;
312
+ /**
313
+ * Schema constraints this type cannot express: exclusiveMinimum=0
314
+ */
315
+ max?: number;
316
+ axes?: Array<string>;
317
+ series?: Array<ValueSeries>;
318
+ }
319
+
320
+
321
+ export interface GaugeChart {
322
+ type: "gauge";
323
+ title?: string | null;
324
+ stream?: StreamSpec;
325
+ value?: number;
326
+ min?: number;
327
+ max?: number;
328
+ unit?: string | null;
329
+ tone?: Tone;
330
+ }
331
+
332
+
333
+ export interface BoxplotChart {
334
+ type: "boxplot";
335
+ title?: string | null;
336
+ stream?: StreamSpec;
337
+ catLabel?: string | null;
338
+ valLabel?: string | null;
339
+ boxes?: Array<Box>;
340
+ }
341
+
342
+
343
+ export interface HeatmapChart {
344
+ type: "heatmap";
345
+ title?: string | null;
346
+ stream?: StreamSpec;
347
+ log?: boolean;
348
+ xLabel?: string | null;
349
+ yLabel?: string | null;
350
+ xLabels?: Array<string>;
351
+ yLabels?: Array<string>;
352
+ /**
353
+ * values[yi][xi], row-major from the top row; null marks a missing cell
354
+ */
355
+ values?: Array<Array<number | null>>;
356
+ }
357
+
358
+
359
+ export interface TreemapChart {
360
+ type: "treemap";
361
+ title?: string | null;
362
+ stream?: StreamSpec;
363
+ /**
364
+ * Schema constraints this type cannot express: exclusiveMinimum=0
365
+ */
366
+ aspect?: number;
367
+ /**
368
+ * leaves, or one level of groups; a chart with any group treats a bare leaf as a group of one
369
+ */
370
+ items?: Array<TreemapItem | TreemapGroup>;
371
+ }
372
+
373
+
374
+ export interface StreamgraphChart {
375
+ type: "streamgraph";
376
+ title?: string | null;
377
+ stream?: StreamSpec;
378
+ xLabel?: string | null;
379
+ xs?: Array<number>;
380
+ series?: Array<ValueSeries>;
381
+ }
382
+
383
+
384
+ export interface SankeyChart {
385
+ type: "sankey";
386
+ title?: string | null;
387
+ stream?: StreamSpec;
388
+ nodes?: Array<string | { name: string; [key: string]: unknown; }>;
389
+ links?: Array<SankeyLink>;
390
+ }
391
+
392
+
393
+ export interface MapChart {
394
+ type: "map";
395
+ title?: string | null;
396
+ stream?: StreamSpec;
397
+ /**
398
+ * feature property to shade by; absent leaves the map unshaded
399
+ */
400
+ value?: string;
401
+ /**
402
+ * feature property to name features by (default 'name')
403
+ */
404
+ label?: string;
405
+ log?: boolean;
406
+ /**
407
+ * Schema constraints this type cannot express: exclusiveMinimum=0
408
+ */
409
+ aspect?: number;
410
+ /**
411
+ * Douglas-Peucker tolerance as a fraction of the frame's width, or false to keep every vertex
412
+ * Schema constraints this type cannot express: minimum=0
413
+ */
414
+ simplify?: number | boolean;
415
+ /**
416
+ * GeoJSON: a FeatureCollection, or an array of Features or geometries
417
+ */
418
+ features?: { [key: string]: unknown; } | Array<unknown>;
419
+ points?: Array<MapPoint>;
420
+ }
421
+
422
+
423
+ export type ChartDefinition = PieChart | BarChart | LineChart | ScatterChart | CandlestickChart | RadarChart | GaugeChart | BoxplotChart | HeatmapChart | TreemapChart | StreamgraphChart | SankeyChart | MapChart;
424
+
425
+
426
+ export interface ChartDefinitions {
427
+ pie: PieChart;
428
+ bar: BarChart;
429
+ line: LineChart;
430
+ scatter: ScatterChart;
431
+ candlestick: CandlestickChart;
432
+ radar: RadarChart;
433
+ gauge: GaugeChart;
434
+ boxplot: BoxplotChart;
435
+ heatmap: HeatmapChart;
436
+ treemap: TreemapChart;
437
+ streamgraph: StreamgraphChart;
438
+ sankey: SankeyChart;
439
+ map: MapChart;
440
+ }
441
+ export type ChartKind = keyof ChartDefinitions;
442
+ type Immutable<T> = T extends object ? { readonly [K in keyof T]: Immutable<T[K]> } : T;
443
+ export type ChartOptions<K extends ChartKind> = Omit<Immutable<ChartDefinitions[K]>, 'type'>;
444
+ export type ChartPen<K extends ChartKind> = ChartBuilder<K> & {
445
+ readonly [P in keyof ChartOptions<K>]-?: (value: Exclude<ChartOptions<K>[P], undefined>) => ChartPen<K>;
446
+ };
447
+ /** The kind controls the available fluent members and their value types. */
448
+ export class ChartBuilder<K extends ChartKind = ChartKind> {
449
+ protected constructor();
450
+ readonly schema: Immutable<ChartDefinitions[K]>;
451
+ toJSON(): Immutable<ChartDefinitions[K]>;
452
+ options(value: ChartOptions<K>): ChartPen<K>;
453
+ }
454
+ /** A raw public chart definition; extensions remain JSON and engine-validated. */
455
+ export function from<K extends ChartKind>(document: ChartDefinitions[K]): ChartPen<K>;
456
+ /** A pie chart definition. */
457
+ export function pie(options?: ChartOptions<'pie'>): ChartPen<'pie'>;
458
+ /** A bar chart definition. */
459
+ export function bar(options?: ChartOptions<'bar'>): ChartPen<'bar'>;
460
+ /** A line chart definition. */
461
+ export function line(options?: ChartOptions<'line'>): ChartPen<'line'>;
462
+ /** A scatter chart definition. */
463
+ export function scatter(options?: ChartOptions<'scatter'>): ChartPen<'scatter'>;
464
+ /** A candlestick chart definition. */
465
+ export function candlestick(options?: ChartOptions<'candlestick'>): ChartPen<'candlestick'>;
466
+ /** A radar chart definition. */
467
+ export function radar(options?: ChartOptions<'radar'>): ChartPen<'radar'>;
468
+ /** A gauge chart definition. */
469
+ export function gauge(options?: ChartOptions<'gauge'>): ChartPen<'gauge'>;
470
+ /** A boxplot chart definition. */
471
+ export function boxplot(options?: ChartOptions<'boxplot'>): ChartPen<'boxplot'>;
472
+ /** A heatmap chart definition. */
473
+ export function heatmap(options?: ChartOptions<'heatmap'>): ChartPen<'heatmap'>;
474
+ /** A treemap chart definition. */
475
+ export function treemap(options?: ChartOptions<'treemap'>): ChartPen<'treemap'>;
476
+ /** A streamgraph chart definition. */
477
+ export function streamgraph(options?: ChartOptions<'streamgraph'>): ChartPen<'streamgraph'>;
478
+ /** A sankey chart definition. */
479
+ export function sankey(options?: ChartOptions<'sankey'>): ChartPen<'sankey'>;
480
+ /** A map chart definition. */
481
+ export function map(options?: ChartOptions<'map'>): ChartPen<'map'>;
@@ -0,0 +1,45 @@
1
+ import type { ExprBase, UnknownExpr } from './index.js';
2
+ import type { Json, JsonSchema } from './schema.js';
3
+
4
+ export type Match = string | { readonly path?: string; readonly schema?: JsonSchema };
5
+ export type Output = 'text' | 'xml';
6
+ export type Segment = string | Readonly<Record<string, Json>> | readonly Segment[];
7
+ export interface RuleDocument {
8
+ readonly match?: Match;
9
+ readonly mode?: string;
10
+ readonly priority?: number;
11
+ readonly body: readonly Segment[];
12
+ }
13
+ export type TemplateDocument = readonly RuleDocument[] | {
14
+ readonly $jtlt: '0.1';
15
+ readonly output?: Output;
16
+ readonly rules: readonly RuleDocument[];
17
+ };
18
+ export type QueryInput<N extends string = never> = Json | ((value: UnknownExpr, externals: Readonly<Record<N | 'root' | 'path', UnknownExpr>>) => ExprBase<unknown> | Json);
19
+ export interface QueryOptions<N extends string> { readonly externals?: readonly N[] }
20
+ export function text(value: string): string;
21
+ export function query<N extends string = never>(value: QueryInput<N>, options?: QueryOptions<N>): string | Readonly<Record<string, Json>>;
22
+ export function raw<N extends string = never>(value: QueryInput<N>, options?: QueryOptions<N>): { readonly $raw: Json };
23
+ export function json<N extends string = never>(value: QueryInput<N>, options?: QueryOptions<N>): { readonly $json: Json };
24
+ export function apply<N extends string = never>(value: QueryInput<N>, mode?: string, options?: QueryOptions<N>): { readonly $apply: Json };
25
+ export class RuleBuilder {
26
+ protected constructor();
27
+ readonly schema: RuleDocument;
28
+ toJSON(): RuleDocument;
29
+ body(value: readonly Segment[]): RuleBuilder;
30
+ match(value: Match): RuleBuilder;
31
+ mode(value: string): RuleBuilder;
32
+ priority(value: number): RuleBuilder;
33
+ }
34
+ export function rule(body?: readonly Segment[], options?: Omit<RuleDocument, 'body'>): RuleBuilder;
35
+ export class TemplateBuilder {
36
+ protected constructor();
37
+ readonly schema: TemplateDocument;
38
+ toJSON(): TemplateDocument;
39
+ rules(values: readonly (RuleBuilder | RuleDocument)[]): TemplateBuilder;
40
+ rule(value: RuleBuilder | RuleDocument): TemplateBuilder;
41
+ output(value: Output): TemplateBuilder;
42
+ }
43
+ export function stylesheet(rules?: readonly (RuleBuilder | RuleDocument)[], options?: { readonly output?: Output }): TemplateBuilder;
44
+ export function bare(rules?: readonly (RuleBuilder | RuleDocument)[]): TemplateBuilder;
45
+ export function from(document: TemplateDocument): TemplateBuilder;
@@ -0,0 +1,96 @@
1
+ // Derived from the English catalogs by scripts/generate-message-pen.js.
2
+ export interface CatalogIds {
3
+ validate: "type" | "required" | "minimum" | "maximum" | "exclusiveMinimum" | "exclusiveMaximum" | "multipleOf" | "minLength" | "maxLength" | "pattern" | "additionalProperties" | "minProperties" | "maxProperties" | "minItems" | "maxItems" | "uniqueItems" | "contains" | "items" | "allOf" | "anyOf" | "oneOf" | "not" | "format" | "if" | "then" | "else" | "false schema" | "$query" | "JQ2001" | "JQ2003";
4
+ forms: "form/required" | "form/type" | "form/const" | "form/enum" | "form/minLength" | "form/maxLength" | "form/pattern" | "form/format" | "form/minimum" | "form/maximum" | "form/exclusiveMinimum" | "form/exclusiveMaximum" | "form/multipleOf" | "form/minItems" | "form/maxItems" | "form/uniqueItems" | "form/minProperties" | "form/maxProperties" | "x-form/assert" | "form/addItem" | "form/removeItem";
5
+ contract: "contract/not-found" | "contract/method-not-allowed" | "contract/body-too-large" | "contract/unsupported-media" | "contract/malformed-json" | "contract/invalid-input" | "contract/idempotency-key-required" | "contract/handler-failed" | "contract/idempotency-conflict" | "contract/invalid-output" | "contract/malformed-path" | "contract/malformed-query" | "contract/not-implemented" | "contract/precondition-failed" | "contract/invalid-header" | "contract/handler-error" | "contract/client-invalid-input" | "contract/network" | "contract/cancelled" | "contract/invalid-response" | "contract/key-storage-failed" | "contract/undeclared-response" | "contract/not-a-contract" | "contract/incompatible" | "contract/host-failed" | "contract/local-handler-failed" | "contract/unknown-operation" | "contract/port-timeout" | "contract/malformed-frame" | "contract/channel-closed" | "contract/not-a-stream" | "contract/invalid-snapshot" | "contract/seq-regression" | "contract/stream-error" | "contract/heartbeat-missed" | "contract/slow-consumer" | "contract/reconnect-exhausted";
6
+ }
7
+ export interface MessageParameters {
8
+ "type": "type" | "types";
9
+ "required": "missingProperty";
10
+ "minimum": "comparison" | "limit";
11
+ "maximum": "comparison" | "limit";
12
+ "exclusiveMinimum": "comparison" | "limit";
13
+ "exclusiveMaximum": "comparison" | "limit";
14
+ "multipleOf": "multipleOf";
15
+ "minLength": "limit";
16
+ "maxLength": "limit";
17
+ "pattern": "pattern";
18
+ "additionalProperties": "additionalProperty";
19
+ "minProperties": "limit";
20
+ "maxProperties": "limit";
21
+ "minItems": "limit";
22
+ "maxItems": "limit";
23
+ "uniqueItems": never;
24
+ "contains": never;
25
+ "items": never;
26
+ "allOf": never;
27
+ "anyOf": never;
28
+ "oneOf": never;
29
+ "not": never;
30
+ "format": "format";
31
+ "if": never;
32
+ "then": never;
33
+ "else": never;
34
+ "false schema": never;
35
+ "$query": "code" | "docPath";
36
+ "JQ2001": "code" | "docPath";
37
+ "JQ2003": "code" | "docPath";
38
+ "form/required": never;
39
+ "form/type": "type";
40
+ "form/const": "constValue";
41
+ "form/enum": "enumValues";
42
+ "form/minLength": "len" | "limit";
43
+ "form/maxLength": "len" | "limit";
44
+ "form/pattern": "pattern";
45
+ "form/format": "format";
46
+ "form/minimum": "limit";
47
+ "form/maximum": "limit";
48
+ "form/exclusiveMinimum": "limit";
49
+ "form/exclusiveMaximum": "limit";
50
+ "form/multipleOf": "multipleOf";
51
+ "form/minItems": "limit";
52
+ "form/maxItems": "limit";
53
+ "form/uniqueItems": never;
54
+ "form/minProperties": "limit";
55
+ "form/maxProperties": "limit";
56
+ "x-form/assert": never;
57
+ "form/addItem": never;
58
+ "form/removeItem": never;
59
+ "contract/not-found": never;
60
+ "contract/method-not-allowed": "allow";
61
+ "contract/body-too-large": "limit" | "op";
62
+ "contract/unsupported-media": "media" | "op";
63
+ "contract/malformed-json": "op";
64
+ "contract/invalid-input": "op";
65
+ "contract/idempotency-key-required": "op";
66
+ "contract/handler-failed": "op";
67
+ "contract/idempotency-conflict": "kind" | "op";
68
+ "contract/invalid-output": "op";
69
+ "contract/malformed-path": never;
70
+ "contract/malformed-query": never;
71
+ "contract/not-implemented": "op";
72
+ "contract/precondition-failed": "op";
73
+ "contract/invalid-header": "header" | "op";
74
+ "contract/handler-error": "code" | "op";
75
+ "contract/client-invalid-input": "op";
76
+ "contract/network": "name" | "op";
77
+ "contract/cancelled": "op";
78
+ "contract/invalid-response": "op";
79
+ "contract/key-storage-failed": "op";
80
+ "contract/undeclared-response": "op" | "status";
81
+ "contract/not-a-contract": "id";
82
+ "contract/incompatible": "client" | "id" | "server";
83
+ "contract/host-failed": "op";
84
+ "contract/local-handler-failed": "op";
85
+ "contract/unknown-operation": never;
86
+ "contract/port-timeout": "ms" | "op";
87
+ "contract/malformed-frame": "op";
88
+ "contract/channel-closed": "op";
89
+ "contract/not-a-stream": "op";
90
+ "contract/invalid-snapshot": "op";
91
+ "contract/seq-regression": "op";
92
+ "contract/stream-error": "code" | "op";
93
+ "contract/heartbeat-missed": "ms" | "op";
94
+ "contract/slow-consumer": "op";
95
+ "contract/reconnect-exhausted": "attempts" | "lastCode" | "op";
96
+ }
@@ -0,0 +1,32 @@
1
+ import type { Json } from './schema.js';
2
+ import type { CatalogIds, MessageParameters } from './message-vocabulary.js';
3
+ export type { CatalogIds, MessageParameters } from './message-vocabulary.js';
4
+ export type CatalogSource = keyof CatalogIds | 'all';
5
+ export type Msgid<S extends CatalogSource = 'all'> = S extends keyof CatalogIds ? CatalogIds[S] : keyof MessageParameters;
6
+ export type CatalogDocument<I extends string = Msgid> = Readonly<Record<I, string>>;
7
+ type Present<D> = string extends keyof D ? never : {
8
+ [K in keyof D]-?: {} extends Pick<D, K> ? never : K
9
+ }[keyof D] & string;
10
+ // A union-valued id adds one unknown member, not every member of that union.
11
+ type SingleId<I, Whole = I> = I extends unknown ? [Whole] extends [I] ? I : never : never;
12
+ export const CATALOGS: { readonly [S in keyof CatalogIds]: { readonly [I in CatalogIds[S]]: readonly (I extends keyof MessageParameters ? MessageParameters[I] : never)[] } };
13
+ export class CatalogBuilder<S extends CatalogSource = 'all', P extends string = never> {
14
+ protected constructor();
15
+ readonly __source: S;
16
+ readonly __present: P;
17
+ entry<I extends Msgid<S>>(id: I, template: string): CatalogBuilder<S, P | SingleId<I>>;
18
+ entries<const D extends Partial<Record<Msgid<S>, string>>>(values: D & Record<Exclude<keyof D, Msgid<S>>, never>): CatalogBuilder<S, P | Present<D>>;
19
+ partial(): CatalogDocument<P>;
20
+ complete(this: Exclude<Msgid<S>, P> extends never ? CatalogBuilder<S, P> : never): CatalogDocument<Msgid<S>>;
21
+ toJSON(this: Exclude<Msgid<S>, P> extends never ? CatalogBuilder<S, P> : never): CatalogDocument<Msgid<S>>;
22
+ }
23
+ export function catalog<S extends CatalogSource = 'all'>(source?: S, locale?: string): CatalogBuilder<S>;
24
+ /** Raw drafts remain subject to runtime key/placeholder checks at either exit. */
25
+ export function from<const D extends Record<string, string>, S extends CatalogSource = 'all'>(document: D, options?: { readonly source?: S; readonly locale?: string }): CatalogBuilder<S, Present<D>>;
26
+ export function inline(template: string): string;
27
+ export interface MessageSpec<I extends Msgid = Msgid> {
28
+ readonly $msgid: I;
29
+ readonly message?: string;
30
+ readonly params?: [MessageParameters[I]] extends [never] ? Readonly<Record<string, never>> : Readonly<Partial<Record<MessageParameters[I], Json>>>;
31
+ }
32
+ export function message<I extends Msgid>(id: I, options?: Omit<MessageSpec<I>, '$msgid'>): MessageSpec<I>;