@jarenjs/linq 0.67.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -2
- package/docs/AI-PEN.md +98 -0
- package/docs/APP-PEN.md +3 -3
- package/docs/CHARTS-PEN.md +94 -0
- package/docs/CONTRACT-PEN.md +4 -4
- package/docs/DB-CLIENT.md +3 -3
- package/docs/FORMS-PEN.md +2 -2
- package/docs/JTLT-PEN.md +83 -0
- package/docs/LINQ-FORMAT.md +170 -42
- package/docs/MESSAGES-PEN.md +105 -0
- package/docs/MIGRATION-PEN.md +1 -1
- package/docs/MODEL-PEN.md +3 -3
- package/docs/PROJECT-PEN.md +75 -0
- package/docs/QUERY-PEN.md +4 -4
- package/docs/SCHEMA-PEN.md +70 -83
- package/package.json +27 -7
- package/src/ai/index.js +76 -0
- package/src/authored.js +38 -0
- package/src/charts/index.js +131 -0
- package/src/charts/vocabulary.js +119 -0
- package/src/jtlt/index.js +97 -0
- package/src/messages/index.js +96 -0
- package/src/messages/vocabulary.js +259 -0
- package/src/project/index.js +54 -0
- package/src/schema/builders.js +100 -9
- package/src/schema/emit.js +29 -13
- package/types/ai.d.ts +56 -0
- package/types/charts.d.ts +438 -0
- package/types/jtlt.d.ts +45 -0
- package/types/message-vocabulary.d.ts +96 -0
- package/types/messages.d.ts +32 -0
- package/types/project.d.ts +45 -0
- package/types/schema.d.ts +54 -0
package/src/schema/emit.js
CHANGED
|
@@ -118,7 +118,10 @@ export function reachesNormalizer(builder, seen = new Set()) {
|
|
|
118
118
|
for (const [key] of st.annotations) {
|
|
119
119
|
if (NORMALIZER_KEYS.includes(key)) return true;
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
const keywordChildren = (value) => isSchemaBuilder(value) ? reachesNormalizer(value, seen)
|
|
122
|
+
: value !== null && typeof value === 'object' && Object.values(value).some(keywordChildren);
|
|
123
|
+
return Object.values(st.keywords).some(keywordChildren)
|
|
124
|
+
|| children(st).some((child) => reachesNormalizer(child, seen));
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
/** Every builder one state holds directly (lazy thunks resolved). */
|
|
@@ -215,6 +218,12 @@ function emitNode(builder, ctx, at) {
|
|
|
215
218
|
const st = builder.state;
|
|
216
219
|
let node = emitCore(builder, st, ctx, at);
|
|
217
220
|
if (st.nullable) node = nullableOf(node, st);
|
|
221
|
+
for (const key of Object.keys(st.keywords)) {
|
|
222
|
+
const value = st.keywords[key];
|
|
223
|
+
setObjectMember(node, key, emitKeyword(value, ctx, `${at}/${token(key)}`, key));
|
|
224
|
+
}
|
|
225
|
+
if (st.nullable && TYPED[st.kind] !== undefined && Array.isArray(node.enum)
|
|
226
|
+
&& !node.enum.includes(null)) node.enum = [...node.enum, null];
|
|
218
227
|
if (st.checks.length > 0) {
|
|
219
228
|
node.$query = st.checks.length === 1 ? st.checks[0] : { $and: st.checks };
|
|
220
229
|
}
|
|
@@ -222,6 +231,19 @@ function emitNode(builder, ctx, at) {
|
|
|
222
231
|
return node;
|
|
223
232
|
}
|
|
224
233
|
|
|
234
|
+
/** Emit schema-valued keywords in the root's shared definition context. */
|
|
235
|
+
function emitKeyword(value, ctx, at, keyword) {
|
|
236
|
+
if (isSchemaBuilder(value)) {
|
|
237
|
+
if (['not', 'unevaluatedProperties', 'unevaluatedItems', 'dependentSchemas', 'dependencies', 'contentSchema'].includes(keyword))
|
|
238
|
+
refuseNormalizerUnder(value, keyword, at);
|
|
239
|
+
return emitNode(value, ctx, at);
|
|
240
|
+
}
|
|
241
|
+
if (Array.isArray(value)) return value.map((v, i) => emitKeyword(v, ctx, `${at}/${i}`, keyword));
|
|
242
|
+
if (value !== null && typeof value === 'object')
|
|
243
|
+
return Object.fromEntries(Object.keys(value).map((k) => [k, emitKeyword(value[k], ctx, `${at}/${token(k)}`, keyword)]));
|
|
244
|
+
return value;
|
|
245
|
+
}
|
|
246
|
+
|
|
225
247
|
/** Fold `null` into a typed node; wrap an untyped one in `anyOf`. */
|
|
226
248
|
function nullableOf(node, st) {
|
|
227
249
|
if (TYPED[st.kind] !== undefined) {
|
|
@@ -238,12 +260,6 @@ function nullableOf(node, st) {
|
|
|
238
260
|
return { anyOf: [node, { type: 'null' }] };
|
|
239
261
|
}
|
|
240
262
|
|
|
241
|
-
/** The constraint keywords a builder collected, in the order set. */
|
|
242
|
-
function withKeywords(node, st) {
|
|
243
|
-
for (const key of Object.keys(st.keywords)) node[key] = st.keywords[key];
|
|
244
|
-
return node;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
263
|
/**
|
|
248
264
|
* The kind-specific core of a node: `type` and the structural
|
|
249
265
|
* keywords, with the collected constraints after them.
|
|
@@ -256,7 +272,7 @@ function withKeywords(node, st) {
|
|
|
256
272
|
function emitCore(builder, st, ctx, at) {
|
|
257
273
|
switch (st.kind) {
|
|
258
274
|
case 'string': case 'number': case 'integer': case 'boolean': case 'null':
|
|
259
|
-
return
|
|
275
|
+
return { type: st.kind };
|
|
260
276
|
case 'literal':
|
|
261
277
|
return { const: st.value };
|
|
262
278
|
case 'enum':
|
|
@@ -293,20 +309,20 @@ function emitCore(builder, st, ctx, at) {
|
|
|
293
309
|
node.propertyNames = emitNode(st.names, ctx, `${at}/propertyNames`);
|
|
294
310
|
}
|
|
295
311
|
if (st.dependent !== null) node.dependentRequired = cloneJson(st.dependent);
|
|
296
|
-
return
|
|
312
|
+
return node;
|
|
297
313
|
}
|
|
298
314
|
case 'record':
|
|
299
|
-
return
|
|
315
|
+
return {
|
|
300
316
|
type: 'object',
|
|
301
317
|
additionalProperties: emitNode(st.values, ctx, `${at}/additionalProperties`),
|
|
302
|
-
}
|
|
318
|
+
};
|
|
303
319
|
case 'array': {
|
|
304
320
|
const node = { type: 'array', items: emitNode(st.items, ctx, `${at}/items`) };
|
|
305
321
|
if (st.contains !== null) {
|
|
306
322
|
refuseNormalizerUnder(st.contains, 'contains()', `${at}/contains`);
|
|
307
323
|
node.contains = emitNode(st.contains, ctx, `${at}/contains`);
|
|
308
324
|
}
|
|
309
|
-
return
|
|
325
|
+
return node;
|
|
310
326
|
}
|
|
311
327
|
case 'tuple': {
|
|
312
328
|
const node = {
|
|
@@ -315,7 +331,7 @@ function emitCore(builder, st, ctx, at) {
|
|
|
315
331
|
};
|
|
316
332
|
if (st.rest !== null) node.items = emitNode(st.rest, ctx, `${at}/items`);
|
|
317
333
|
node.minItems = st.items.length;
|
|
318
|
-
return
|
|
334
|
+
return node;
|
|
319
335
|
}
|
|
320
336
|
case 'union': case 'discriminated': {
|
|
321
337
|
const keyword = st.kind === 'union' ? 'anyOf' : 'oneOf';
|
package/types/ai.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Json } from './schema.js';
|
|
2
|
+
import type { ExprBase, UnknownExpr } from './index.js';
|
|
3
|
+
export type Query = Json | ((value: UnknownExpr) => ExprBase<unknown> | Json);
|
|
4
|
+
export interface ChunkOptions { readonly strategy?: 'size' | 'line' | 'separator'; readonly size?: number }
|
|
5
|
+
export interface GrepOptions { readonly pattern: string; readonly flags?: 'i' | 'm' | 'im' | ''; readonly limit?: number }
|
|
6
|
+
export interface AnswerOptions { readonly chars?: number }
|
|
7
|
+
export interface ReduceOptions { readonly outputSchema?: Json }
|
|
8
|
+
export interface StepOptions {
|
|
9
|
+
chunk: ChunkOptions; grep: GrepOptions; select: { readonly query: Json };
|
|
10
|
+
stat: {}; peek: {}; map: { readonly prompt: string }; reduce: { readonly query: Json } & ReduceOptions; answer: AnswerOptions;
|
|
11
|
+
}
|
|
12
|
+
export type Operation = keyof StepOptions;
|
|
13
|
+
export type Step<K extends Operation, F extends string = string, N extends string = string> = {
|
|
14
|
+
readonly op: K; readonly from: F;
|
|
15
|
+
} & (K extends 'answer' ? {} : { readonly as: N }) & StepOptions[K];
|
|
16
|
+
export type StepDocument = { [K in Operation]: Step<K> }[Operation];
|
|
17
|
+
export interface ProgramDocument { readonly steps: readonly StepDocument[] }
|
|
18
|
+
export function chunk<const F extends string, const N extends string>(from: F, as: N, options?: ChunkOptions): Step<'chunk', F, N>;
|
|
19
|
+
export function grep<const F extends string, const N extends string>(from: F, as: N, options: GrepOptions): Step<'grep', F, N>;
|
|
20
|
+
export function select<const F extends string, const N extends string>(from: F, as: N, query: Query): Step<'select', F, N>;
|
|
21
|
+
export function stat<const F extends string, const N extends string>(from: F, as: N): Step<'stat', F, N>;
|
|
22
|
+
export function peek<const F extends string, const N extends string>(from: F, as: N): Step<'peek', F, N>;
|
|
23
|
+
export function map<const F extends string, const N extends string>(from: F, as: N, prompt: string): Step<'map', F, N>;
|
|
24
|
+
export function reduce<const F extends string, const N extends string>(from: F, as: N, query: Query, options?: ReduceOptions): Step<'reduce', F, N>;
|
|
25
|
+
export function answer<const F extends string>(from: F, options?: AnswerOptions): Step<'answer', F>;
|
|
26
|
+
|
|
27
|
+
type Kind = Exclude<Operation, 'answer'> | 'slot';
|
|
28
|
+
type Bindings = Record<string, Kind>;
|
|
29
|
+
type Names<B, K extends Kind = Kind> = { [N in keyof B]: B[N] extends K ? N : never }[keyof B] & string;
|
|
30
|
+
type Single<B> = Names<B, Exclude<Kind, 'chunk' | 'map'>>;
|
|
31
|
+
type Fresh<B, N extends string> = N extends keyof B ? B[N] extends 'slot' ? N : never : N;
|
|
32
|
+
type Add<B, N extends string, K extends Kind> = Omit<B, N> & Record<N, K>;
|
|
33
|
+
type InputFor<B, K extends Operation> = K extends 'reduce' ? Names<B, 'map'> : K extends 'select' | 'answer' ? Single<B> : Names<B>;
|
|
34
|
+
type StepKeys<K extends Operation> = 'op' | 'from' | (K extends 'answer' ? never : 'as') | keyof StepOptions[K];
|
|
35
|
+
type CheckStep<B, T extends StepDocument> = Exclude<keyof T, StepKeys<T['op']>> extends never ? T['from'] extends InputFor<B, T['op']>
|
|
36
|
+
? T extends { readonly as: infer N extends string } ? N extends Fresh<B, N> ? unknown : never : unknown : never : never;
|
|
37
|
+
type AfterStep<B, T extends StepDocument> = T extends { readonly as: infer N extends string; readonly op: infer K extends Kind } ? Add<B, N, K> : B;
|
|
38
|
+
export class ProgramBuilder<B extends Bindings = {}, Done extends boolean = false> {
|
|
39
|
+
protected constructor();
|
|
40
|
+
readonly __bindings: B;
|
|
41
|
+
readonly __done: Done;
|
|
42
|
+
readonly schema: ProgramDocument;
|
|
43
|
+
toJSON(): ProgramDocument;
|
|
44
|
+
step<const T extends StepDocument>(this: ProgramBuilder<B, false>, step: T & CheckStep<B, T>): ProgramBuilder<AfterStep<B, T>, T['op'] extends 'answer' ? true : false>;
|
|
45
|
+
chunk<N extends string>(this: ProgramBuilder<B, false>, from: Names<B>, as: Fresh<B, N>, options?: ChunkOptions): ProgramBuilder<Add<B, N, 'chunk'>>;
|
|
46
|
+
grep<N extends string>(this: ProgramBuilder<B, false>, from: Names<B>, as: Fresh<B, N>, options: GrepOptions): ProgramBuilder<Add<B, N, 'grep'>>;
|
|
47
|
+
select<N extends string>(this: ProgramBuilder<B, false>, from: Single<B>, as: Fresh<B, N>, query: Query): ProgramBuilder<Add<B, N, 'select'>>;
|
|
48
|
+
stat<N extends string>(this: ProgramBuilder<B, false>, from: Names<B>, as: Fresh<B, N>): ProgramBuilder<Add<B, N, 'stat'>>;
|
|
49
|
+
peek<N extends string>(this: ProgramBuilder<B, false>, from: Names<B>, as: Fresh<B, N>): ProgramBuilder<Add<B, N, 'peek'>>;
|
|
50
|
+
map<N extends string>(this: ProgramBuilder<B, false>, from: Names<B>, as: Fresh<B, N>, prompt: string): ProgramBuilder<Add<B, N, 'map'>>;
|
|
51
|
+
reduce<N extends string>(this: ProgramBuilder<B, false>, from: Names<B, 'map'>, as: Fresh<B, N>, query: Query, options?: ReduceOptions): ProgramBuilder<Add<B, N, 'reduce'>>;
|
|
52
|
+
answer(this: ProgramBuilder<B, false>, from: Single<B>, options?: AnswerOptions): ProgramBuilder<B, true>;
|
|
53
|
+
}
|
|
54
|
+
export function program<const S extends readonly string[] = []>(slots?: S): ProgramBuilder<Record<S[number], 'slot'>>;
|
|
55
|
+
/** Raw documents make no binding-order or terminal-state inference. */
|
|
56
|
+
export function from(document: ProgramDocument): ProgramBuilder<Record<string, Kind>, boolean>;
|
|
@@ -0,0 +1,438 @@
|
|
|
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 = 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
|
+
* a place marker: the convenience path for a caller holding positions rather than GeoJSON
|
|
125
|
+
*/
|
|
126
|
+
export interface MapPoint {
|
|
127
|
+
/**
|
|
128
|
+
* a GeoJSON position: [longitude, latitude]
|
|
129
|
+
* Schema constraints this type cannot express: minItems=2, maxItems=3
|
|
130
|
+
*/
|
|
131
|
+
at: [number, number, ...Array<number>];
|
|
132
|
+
label?: string;
|
|
133
|
+
value?: number;
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 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.
|
|
140
|
+
*/
|
|
141
|
+
export type SamplingPolicy = false | "lttb" | "minmax" | { method?: "lttb" | "minmax"; target?: number; width?: number; pixelRatio?: number; [key: string]: unknown; };
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 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
|
|
145
|
+
*/
|
|
146
|
+
export interface DateNames {
|
|
147
|
+
/**
|
|
148
|
+
* Schema constraints this type cannot express: minItems=12, maxItems=12
|
|
149
|
+
*/
|
|
150
|
+
months?: Array<string>;
|
|
151
|
+
/**
|
|
152
|
+
* Schema constraints this type cannot express: minItems=12, maxItems=12
|
|
153
|
+
*/
|
|
154
|
+
monthsShort?: Array<string>;
|
|
155
|
+
/**
|
|
156
|
+
* Schema constraints this type cannot express: minItems=7, maxItems=7
|
|
157
|
+
*/
|
|
158
|
+
weekdays?: Array<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Schema constraints this type cannot express: minItems=7, maxItems=7
|
|
161
|
+
*/
|
|
162
|
+
weekdaysShort?: Array<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Schema constraints this type cannot express: minItems=2, maxItems=2
|
|
165
|
+
*/
|
|
166
|
+
meridiem?: Array<string>;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 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)
|
|
173
|
+
*/
|
|
174
|
+
export interface TimeFormats {
|
|
175
|
+
second?: string;
|
|
176
|
+
minute?: string;
|
|
177
|
+
day?: string;
|
|
178
|
+
month?: string;
|
|
179
|
+
year?: string;
|
|
180
|
+
[key: string]: unknown;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* domain-stability policy: a quantized sliding x window and/or pinned or step-quantized y bounds, so most streaming ticks keep the scales still
|
|
186
|
+
*/
|
|
187
|
+
export interface DomainPolicy {
|
|
188
|
+
x?: { window: number; slide?: number; [key: string]: unknown; };
|
|
189
|
+
y?: "step" | { min?: number; max?: number; [key: string]: unknown; };
|
|
190
|
+
[key: string]: unknown;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
export interface PieChart {
|
|
195
|
+
type: "pie";
|
|
196
|
+
title?: string | null;
|
|
197
|
+
stream?: StreamSpec;
|
|
198
|
+
/**
|
|
199
|
+
* true for the default hole fraction, or the hole radius as a fraction of the outer radius
|
|
200
|
+
* Schema constraints this type cannot express: exclusiveMinimum=0, exclusiveMaximum=1
|
|
201
|
+
*/
|
|
202
|
+
donut?: boolean | number;
|
|
203
|
+
slices?: Array<Slice>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
export interface BarChart {
|
|
208
|
+
type: "bar";
|
|
209
|
+
title?: string | null;
|
|
210
|
+
stream?: StreamSpec;
|
|
211
|
+
stacked?: boolean;
|
|
212
|
+
log?: boolean;
|
|
213
|
+
orient?: "v" | "h";
|
|
214
|
+
catLabel?: string | null;
|
|
215
|
+
valLabel?: string | null;
|
|
216
|
+
categories?: Array<string>;
|
|
217
|
+
series?: Array<BarSeries>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
export interface LineChart {
|
|
222
|
+
type: "line";
|
|
223
|
+
title?: string | null;
|
|
224
|
+
stream?: StreamSpec;
|
|
225
|
+
x?: "linear" | "time";
|
|
226
|
+
log?: boolean;
|
|
227
|
+
markers?: boolean;
|
|
228
|
+
xLabel?: string | null;
|
|
229
|
+
yLabel?: string | null;
|
|
230
|
+
domain?: DomainPolicy;
|
|
231
|
+
sampling?: SamplingPolicy;
|
|
232
|
+
dateNames?: DateNames;
|
|
233
|
+
timeFormats?: TimeFormats;
|
|
234
|
+
series?: Array<LineSeries>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
export interface ScatterChart {
|
|
239
|
+
type: "scatter";
|
|
240
|
+
title?: string | null;
|
|
241
|
+
stream?: StreamSpec;
|
|
242
|
+
xLog?: boolean;
|
|
243
|
+
yLog?: boolean;
|
|
244
|
+
refY?: number;
|
|
245
|
+
refLabel?: string | null;
|
|
246
|
+
xLabel?: string | null;
|
|
247
|
+
yLabel?: string | null;
|
|
248
|
+
points?: Array<Point>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
export interface CandlestickChart {
|
|
253
|
+
type: "candlestick";
|
|
254
|
+
title?: string | null;
|
|
255
|
+
stream?: StreamSpec;
|
|
256
|
+
xLabel?: string | null;
|
|
257
|
+
yLabel?: string | null;
|
|
258
|
+
domain?: DomainPolicy;
|
|
259
|
+
dateNames?: DateNames;
|
|
260
|
+
timeFormats?: TimeFormats;
|
|
261
|
+
candles?: Array<Candle>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
export interface RadarChart {
|
|
266
|
+
type: "radar";
|
|
267
|
+
title?: string | null;
|
|
268
|
+
stream?: StreamSpec;
|
|
269
|
+
/**
|
|
270
|
+
* Schema constraints this type cannot express: exclusiveMinimum=0
|
|
271
|
+
*/
|
|
272
|
+
max?: number;
|
|
273
|
+
axes?: Array<string>;
|
|
274
|
+
series?: Array<ValueSeries>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
export interface GaugeChart {
|
|
279
|
+
type: "gauge";
|
|
280
|
+
title?: string | null;
|
|
281
|
+
stream?: StreamSpec;
|
|
282
|
+
value?: number;
|
|
283
|
+
min?: number;
|
|
284
|
+
max?: number;
|
|
285
|
+
unit?: string | null;
|
|
286
|
+
tone?: Tone;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
export interface BoxplotChart {
|
|
291
|
+
type: "boxplot";
|
|
292
|
+
title?: string | null;
|
|
293
|
+
stream?: StreamSpec;
|
|
294
|
+
catLabel?: string | null;
|
|
295
|
+
valLabel?: string | null;
|
|
296
|
+
boxes?: Array<Box>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
export interface HeatmapChart {
|
|
301
|
+
type: "heatmap";
|
|
302
|
+
title?: string | null;
|
|
303
|
+
stream?: StreamSpec;
|
|
304
|
+
log?: boolean;
|
|
305
|
+
xLabel?: string | null;
|
|
306
|
+
yLabel?: string | null;
|
|
307
|
+
xLabels?: Array<string>;
|
|
308
|
+
yLabels?: Array<string>;
|
|
309
|
+
/**
|
|
310
|
+
* values[yi][xi], row-major from the top row; null marks a missing cell
|
|
311
|
+
*/
|
|
312
|
+
values?: Array<Array<number | null>>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
export interface TreemapChart {
|
|
317
|
+
type: "treemap";
|
|
318
|
+
title?: string | null;
|
|
319
|
+
stream?: StreamSpec;
|
|
320
|
+
/**
|
|
321
|
+
* Schema constraints this type cannot express: exclusiveMinimum=0
|
|
322
|
+
*/
|
|
323
|
+
aspect?: number;
|
|
324
|
+
/**
|
|
325
|
+
* leaves, or one level of groups; a chart with any group treats a bare leaf as a group of one
|
|
326
|
+
*/
|
|
327
|
+
items?: Array<TreemapItem | TreemapGroup>;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
export interface StreamgraphChart {
|
|
332
|
+
type: "streamgraph";
|
|
333
|
+
title?: string | null;
|
|
334
|
+
stream?: StreamSpec;
|
|
335
|
+
xLabel?: string | null;
|
|
336
|
+
xs?: Array<number>;
|
|
337
|
+
series?: Array<ValueSeries>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
export interface SankeyChart {
|
|
342
|
+
type: "sankey";
|
|
343
|
+
title?: string | null;
|
|
344
|
+
stream?: StreamSpec;
|
|
345
|
+
nodes?: Array<string | { name: string; [key: string]: unknown; }>;
|
|
346
|
+
links?: Array<SankeyLink>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
export interface MapChart {
|
|
351
|
+
type: "map";
|
|
352
|
+
title?: string | null;
|
|
353
|
+
stream?: StreamSpec;
|
|
354
|
+
/**
|
|
355
|
+
* feature property to shade by; absent leaves the map unshaded
|
|
356
|
+
*/
|
|
357
|
+
value?: string;
|
|
358
|
+
/**
|
|
359
|
+
* feature property to name features by (default 'name')
|
|
360
|
+
*/
|
|
361
|
+
label?: string;
|
|
362
|
+
log?: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Schema constraints this type cannot express: exclusiveMinimum=0
|
|
365
|
+
*/
|
|
366
|
+
aspect?: number;
|
|
367
|
+
/**
|
|
368
|
+
* Douglas-Peucker tolerance as a fraction of the frame's width, or false to keep every vertex
|
|
369
|
+
* Schema constraints this type cannot express: minimum=0
|
|
370
|
+
*/
|
|
371
|
+
simplify?: number | boolean;
|
|
372
|
+
/**
|
|
373
|
+
* GeoJSON: a FeatureCollection, or an array of Features or geometries
|
|
374
|
+
*/
|
|
375
|
+
features?: { [key: string]: unknown; } | Array<unknown>;
|
|
376
|
+
points?: Array<MapPoint>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
export type ChartDefinition = PieChart | BarChart | LineChart | ScatterChart | CandlestickChart | RadarChart | GaugeChart | BoxplotChart | HeatmapChart | TreemapChart | StreamgraphChart | SankeyChart | MapChart;
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
export interface ChartDefinitions {
|
|
384
|
+
pie: PieChart;
|
|
385
|
+
bar: BarChart;
|
|
386
|
+
line: LineChart;
|
|
387
|
+
scatter: ScatterChart;
|
|
388
|
+
candlestick: CandlestickChart;
|
|
389
|
+
radar: RadarChart;
|
|
390
|
+
gauge: GaugeChart;
|
|
391
|
+
boxplot: BoxplotChart;
|
|
392
|
+
heatmap: HeatmapChart;
|
|
393
|
+
treemap: TreemapChart;
|
|
394
|
+
streamgraph: StreamgraphChart;
|
|
395
|
+
sankey: SankeyChart;
|
|
396
|
+
map: MapChart;
|
|
397
|
+
}
|
|
398
|
+
export type ChartKind = keyof ChartDefinitions;
|
|
399
|
+
type Immutable<T> = T extends object ? { readonly [K in keyof T]: Immutable<T[K]> } : T;
|
|
400
|
+
export type ChartOptions<K extends ChartKind> = Omit<Immutable<ChartDefinitions[K]>, 'type'>;
|
|
401
|
+
export type ChartPen<K extends ChartKind> = ChartBuilder<K> & {
|
|
402
|
+
readonly [P in keyof ChartOptions<K>]-?: (value: Exclude<ChartOptions<K>[P], undefined>) => ChartPen<K>;
|
|
403
|
+
};
|
|
404
|
+
/** The kind controls the available fluent members and their value types. */
|
|
405
|
+
export class ChartBuilder<K extends ChartKind = ChartKind> {
|
|
406
|
+
protected constructor();
|
|
407
|
+
readonly schema: Immutable<ChartDefinitions[K]>;
|
|
408
|
+
toJSON(): Immutable<ChartDefinitions[K]>;
|
|
409
|
+
options(value: ChartOptions<K>): ChartPen<K>;
|
|
410
|
+
}
|
|
411
|
+
/** A raw public chart definition; extensions remain JSON and engine-validated. */
|
|
412
|
+
export function from<K extends ChartKind>(document: ChartDefinitions[K]): ChartPen<K>;
|
|
413
|
+
/** A pie chart definition. */
|
|
414
|
+
export function pie(options?: ChartOptions<'pie'>): ChartPen<'pie'>;
|
|
415
|
+
/** A bar chart definition. */
|
|
416
|
+
export function bar(options?: ChartOptions<'bar'>): ChartPen<'bar'>;
|
|
417
|
+
/** A line chart definition. */
|
|
418
|
+
export function line(options?: ChartOptions<'line'>): ChartPen<'line'>;
|
|
419
|
+
/** A scatter chart definition. */
|
|
420
|
+
export function scatter(options?: ChartOptions<'scatter'>): ChartPen<'scatter'>;
|
|
421
|
+
/** A candlestick chart definition. */
|
|
422
|
+
export function candlestick(options?: ChartOptions<'candlestick'>): ChartPen<'candlestick'>;
|
|
423
|
+
/** A radar chart definition. */
|
|
424
|
+
export function radar(options?: ChartOptions<'radar'>): ChartPen<'radar'>;
|
|
425
|
+
/** A gauge chart definition. */
|
|
426
|
+
export function gauge(options?: ChartOptions<'gauge'>): ChartPen<'gauge'>;
|
|
427
|
+
/** A boxplot chart definition. */
|
|
428
|
+
export function boxplot(options?: ChartOptions<'boxplot'>): ChartPen<'boxplot'>;
|
|
429
|
+
/** A heatmap chart definition. */
|
|
430
|
+
export function heatmap(options?: ChartOptions<'heatmap'>): ChartPen<'heatmap'>;
|
|
431
|
+
/** A treemap chart definition. */
|
|
432
|
+
export function treemap(options?: ChartOptions<'treemap'>): ChartPen<'treemap'>;
|
|
433
|
+
/** A streamgraph chart definition. */
|
|
434
|
+
export function streamgraph(options?: ChartOptions<'streamgraph'>): ChartPen<'streamgraph'>;
|
|
435
|
+
/** A sankey chart definition. */
|
|
436
|
+
export function sankey(options?: ChartOptions<'sankey'>): ChartPen<'sankey'>;
|
|
437
|
+
/** A map chart definition. */
|
|
438
|
+
export function map(options?: ChartOptions<'map'>): ChartPen<'map'>;
|
package/types/jtlt.d.ts
ADDED
|
@@ -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;
|