@elaraai/east 1.0.83 → 1.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/analyze.d.ts.map +1 -1
- package/dist/src/analyze.js +48 -0
- package/dist/src/analyze.js.map +1 -1
- package/dist/src/ast_to_ir.coerce_to.spec.js +4 -4
- package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -1
- package/dist/src/ast_to_ir.d.ts +6 -1
- package/dist/src/ast_to_ir.d.ts.map +1 -1
- package/dist/src/ast_to_ir.js +20 -7
- package/dist/src/ast_to_ir.js.map +1 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +52 -0
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/codegen/canonical.d.ts +37 -0
- package/dist/src/codegen/canonical.d.ts.map +1 -0
- package/dist/src/codegen/canonical.js +208 -0
- package/dist/src/codegen/canonical.js.map +1 -0
- package/dist/src/codegen/codegen.spec.js +132 -201
- package/dist/src/codegen/codegen.spec.js.map +1 -1
- package/dist/src/codegen/printer.d.ts.map +1 -1
- package/dist/src/codegen/printer.js +142 -24
- package/dist/src/codegen/printer.js.map +1 -1
- package/dist/src/codegen/spellings.d.ts +4 -1
- package/dist/src/codegen/spellings.d.ts.map +1 -1
- package/dist/src/codegen/spellings.js +5 -1
- package/dist/src/codegen/spellings.js.map +1 -1
- package/dist/src/compile/builtins/index.d.ts.map +1 -1
- package/dist/src/compile/builtins/index.js +2 -0
- package/dist/src/compile/builtins/index.js.map +1 -1
- package/dist/src/compile/builtins/primitives.d.ts.map +1 -1
- package/dist/src/compile/builtins/primitives.js +2 -1
- package/dist/src/compile/builtins/primitives.js.map +1 -1
- package/dist/src/compile/builtins/query.d.ts +10 -0
- package/dist/src/compile/builtins/query.d.ts.map +1 -0
- package/dist/src/compile/builtins/query.js +5 -0
- package/dist/src/compile/builtins/query.js.map +1 -0
- package/dist/src/expr/block.d.ts.map +1 -1
- package/dist/src/expr/block.js +2 -1
- package/dist/src/expr/block.js.map +1 -1
- package/dist/src/expr/index.d.ts +75 -47
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +31 -0
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/libs/datetime.d.ts +20 -20
- package/dist/src/expr/libs/datetime.d.ts.map +1 -1
- package/dist/src/expr/libs/datetime.js +208 -167
- package/dist/src/expr/libs/datetime.js.map +1 -1
- package/dist/src/expr/libs/float.d.ts +15 -15
- package/dist/src/expr/libs/float.d.ts.map +1 -1
- package/dist/src/expr/libs/float.js +298 -267
- package/dist/src/expr/libs/float.js.map +1 -1
- package/dist/src/expr/libs/integer.d.ts +12 -12
- package/dist/src/expr/libs/integer.d.ts.map +1 -1
- package/dist/src/expr/libs/integer.js +219 -194
- package/dist/src/expr/libs/integer.js.map +1 -1
- package/dist/src/expr/libs/lazy.d.ts +28 -0
- package/dist/src/expr/libs/lazy.d.ts.map +1 -0
- package/dist/src/expr/libs/lazy.js +55 -0
- package/dist/src/expr/libs/lazy.js.map +1 -0
- package/dist/src/expr/libs/lazy.spec.d.ts +6 -0
- package/dist/src/expr/libs/lazy.spec.d.ts.map +1 -0
- package/dist/src/expr/libs/lazy.spec.js +102 -0
- package/dist/src/expr/libs/lazy.spec.js.map +1 -0
- package/dist/src/expr/query.d.ts +60 -0
- package/dist/src/expr/query.d.ts.map +1 -0
- package/dist/src/expr/query.js +84 -0
- package/dist/src/expr/query.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +4 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +9 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/location.d.ts +22 -0
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +31 -0
- package/dist/src/location.js.map +1 -1
- package/dist/src/naming.d.ts +12 -7
- package/dist/src/naming.d.ts.map +1 -1
- package/dist/src/naming.js +30 -13
- package/dist/src/naming.js.map +1 -1
- package/dist/src/naming.spec.js +49 -0
- package/dist/src/naming.spec.js.map +1 -1
- package/dist/src/portable.spec.d.ts +6 -0
- package/dist/src/portable.spec.d.ts.map +1 -0
- package/dist/src/portable.spec.js +181 -0
- package/dist/src/portable.spec.js.map +1 -0
- package/dist/src/query/evaluate.d.ts +98 -0
- package/dist/src/query/evaluate.d.ts.map +1 -0
- package/dist/src/query/evaluate.js +193 -0
- package/dist/src/query/evaluate.js.map +1 -0
- package/dist/src/query/index.d.ts +17 -0
- package/dist/src/query/index.d.ts.map +1 -0
- package/dist/src/query/index.js +17 -0
- package/dist/src/query/index.js.map +1 -0
- package/dist/src/query/jq/catalog.d.ts +174 -0
- package/dist/src/query/jq/catalog.d.ts.map +1 -0
- package/dist/src/query/jq/catalog.js +1740 -0
- package/dist/src/query/jq/catalog.js.map +1 -0
- package/dist/src/query/jq/check.d.ts +210 -0
- package/dist/src/query/jq/check.d.ts.map +1 -0
- package/dist/src/query/jq/check.js +2261 -0
- package/dist/src/query/jq/check.js.map +1 -0
- package/dist/src/query/jq/complete.d.ts +89 -0
- package/dist/src/query/jq/complete.d.ts.map +1 -0
- package/dist/src/query/jq/complete.js +320 -0
- package/dist/src/query/jq/complete.js.map +1 -0
- package/dist/src/query/jq/describe.d.ts +53 -0
- package/dist/src/query/jq/describe.d.ts.map +1 -0
- package/dist/src/query/jq/describe.js +149 -0
- package/dist/src/query/jq/describe.js.map +1 -0
- package/dist/src/query/jq/lex.d.ts +118 -0
- package/dist/src/query/jq/lex.d.ts.map +1 -0
- package/dist/src/query/jq/lex.js +371 -0
- package/dist/src/query/jq/lex.js.map +1 -0
- package/dist/src/query/jq/literals.d.ts +49 -0
- package/dist/src/query/jq/literals.d.ts.map +1 -0
- package/dist/src/query/jq/literals.js +78 -0
- package/dist/src/query/jq/literals.js.map +1 -0
- package/dist/src/query/jq/messages.d.ts +126 -0
- package/dist/src/query/jq/messages.d.ts.map +1 -0
- package/dist/src/query/jq/messages.js +172 -0
- package/dist/src/query/jq/messages.js.map +1 -0
- package/dist/src/query/jq/parse.d.ts +70 -0
- package/dist/src/query/jq/parse.d.ts.map +1 -0
- package/dist/src/query/jq/parse.js +1013 -0
- package/dist/src/query/jq/parse.js.map +1 -0
- package/dist/src/query/jq/print.d.ts +59 -0
- package/dist/src/query/jq/print.d.ts.map +1 -0
- package/dist/src/query/jq/print.js +587 -0
- package/dist/src/query/jq/print.js.map +1 -0
- package/dist/src/query/jq/shapes.d.ts +345 -0
- package/dist/src/query/jq/shapes.d.ts.map +1 -0
- package/dist/src/query/jq/shapes.js +584 -0
- package/dist/src/query/jq/shapes.js.map +1 -0
- package/dist/src/query/jq/spans.d.ts +133 -0
- package/dist/src/query/jq/spans.d.ts.map +1 -0
- package/dist/src/query/jq/spans.js +195 -0
- package/dist/src/query/jq/spans.js.map +1 -0
- package/dist/src/query/jq/split.d.ts +334 -0
- package/dist/src/query/jq/split.d.ts.map +1 -0
- package/dist/src/query/jq/split.js +2108 -0
- package/dist/src/query/jq/split.js.map +1 -0
- package/dist/src/query/jq/strftime.d.ts +20 -0
- package/dist/src/query/jq/strftime.d.ts.map +1 -0
- package/dist/src/query/jq/strftime.js +65 -0
- package/dist/src/query/jq/strftime.js.map +1 -0
- package/dist/src/query/jq/summary.d.ts +139 -0
- package/dist/src/query/jq/summary.d.ts.map +1 -0
- package/dist/src/query/jq/summary.js +222 -0
- package/dist/src/query/jq/summary.js.map +1 -0
- package/dist/src/query/jq/translate-builtins.d.ts +21 -0
- package/dist/src/query/jq/translate-builtins.d.ts.map +1 -0
- package/dist/src/query/jq/translate-builtins.js +1873 -0
- package/dist/src/query/jq/translate-builtins.js.map +1 -0
- package/dist/src/query/jq/translate.d.ts +627 -0
- package/dist/src/query/jq/translate.d.ts.map +1 -0
- package/dist/src/query/jq/translate.js +3364 -0
- package/dist/src/query/jq/translate.js.map +1 -0
- package/dist/src/query/types.d.ts +505 -0
- package/dist/src/query/types.d.ts.map +1 -0
- package/dist/src/query/types.js +231 -0
- package/dist/src/query/types.js.map +1 -0
- package/dist/src/runner_exec.d.ts +134 -0
- package/dist/src/runner_exec.d.ts.map +1 -0
- package/dist/src/runner_exec.js +371 -0
- package/dist/src/runner_exec.js.map +1 -0
- package/dist/src/runner_exec.spec.d.ts +6 -0
- package/dist/src/runner_exec.spec.d.ts.map +1 -0
- package/dist/src/runner_exec.spec.js +198 -0
- package/dist/src/runner_exec.spec.js.map +1 -0
- package/dist/src/runner_io.d.ts +370 -0
- package/dist/src/runner_io.d.ts.map +1 -0
- package/dist/src/runner_io.js +563 -0
- package/dist/src/runner_io.js.map +1 -0
- package/dist/src/runner_io.spec.d.ts +6 -0
- package/dist/src/runner_io.spec.d.ts.map +1 -0
- package/dist/src/runner_io.spec.js +224 -0
- package/dist/src/runner_io.spec.js.map +1 -0
- package/dist/src/runner_merge.d.ts +95 -0
- package/dist/src/runner_merge.d.ts.map +1 -0
- package/dist/src/runner_merge.js +238 -0
- package/dist/src/runner_merge.js.map +1 -0
- package/dist/src/runner_protocol.d.ts +60 -6
- package/dist/src/runner_protocol.d.ts.map +1 -1
- package/dist/src/runner_protocol.js +48 -6
- package/dist/src/runner_protocol.js.map +1 -1
- package/dist/src/serialization/beast2/index.d.ts +2 -2
- package/dist/src/serialization/beast2/index.d.ts.map +1 -1
- package/dist/src/serialization/beast2/index.js +1 -1
- package/dist/src/serialization/beast2/index.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.d.ts +10 -6
- package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.js +10 -6
- package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
- package/dist/src/serialization/beast2/v5/frames.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/frames.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/frames.spec.js +42 -0
- package/dist/src/serialization/beast2/v5/frames.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/index.spec.js +108 -0
- package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.d.ts +74 -7
- package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.js +129 -27
- package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
- package/dist/src/serialization/beast2/v5/lazy.spec.js +251 -16
- package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.d.ts +139 -23
- package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/stream.js +196 -44
- package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
- package/dist/src/serialization/beast2/v5/type-section.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/type-section.js +25 -12
- package/dist/src/serialization/beast2/v5/type-section.js.map +1 -1
- package/dist/src/serialization/beast2/v5/type-section.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/type-section.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/type-section.spec.js +41 -0
- package/dist/src/serialization/beast2/v5/type-section.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/weight.d.ts +36 -0
- package/dist/src/serialization/beast2/v5/weight.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/weight.js +238 -0
- package/dist/src/serialization/beast2/v5/weight.js.map +1 -0
- package/dist/src/serialization/crc32.d.ts +38 -0
- package/dist/src/serialization/crc32.d.ts.map +1 -0
- package/dist/src/serialization/crc32.js +70 -0
- package/dist/src/serialization/crc32.js.map +1 -0
- package/dist/src/serialization/crc32.spec.d.ts +6 -0
- package/dist/src/serialization/crc32.spec.d.ts.map +1 -0
- package/dist/src/serialization/crc32.spec.js +92 -0
- package/dist/src/serialization/crc32.spec.js.map +1 -0
- package/dist/src/serialization/east-inferred.spec.js +4 -0
- package/dist/src/serialization/east-inferred.spec.js.map +1 -1
- package/dist/src/serialization/east.d.ts.map +1 -1
- package/dist/src/serialization/east.js +134 -110
- package/dist/src/serialization/east.js.map +1 -1
- package/dist/src/serialization/east.spec.js +185 -4
- package/dist/src/serialization/east.spec.js.map +1 -1
- package/dist/src/serialization/east_text.d.ts +25 -0
- package/dist/src/serialization/east_text.d.ts.map +1 -0
- package/dist/src/serialization/east_text.js +29 -0
- package/dist/src/serialization/east_text.js.map +1 -0
- package/dist/src/serialization/index.d.ts +1 -1
- package/dist/src/serialization/index.d.ts.map +1 -1
- package/dist/src/serialization/index.js +1 -1
- package/dist/src/serialization/index.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +7 -6
- package/dist/src/types.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
import { type EastType } from "../../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* How many outputs a filter gives: at least `lo`, at most `hi`, where a `hi`
|
|
8
|
+
* of 2 stands for any number more than one.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export interface Mult {
|
|
13
|
+
/** 1 when the filter always gives at least one output. */
|
|
14
|
+
readonly lo: 0 | 1;
|
|
15
|
+
/** 0 for none, 1 for at most one, 2 for any number. */
|
|
16
|
+
readonly hi: 0 | 1 | 2;
|
|
17
|
+
}
|
|
18
|
+
/** Exactly one output. @internal */
|
|
19
|
+
export declare const ONE: Mult;
|
|
20
|
+
/** None or one output. @internal */
|
|
21
|
+
export declare const MAYBE: Mult;
|
|
22
|
+
/** No output: `empty`, `error`, `break`. @internal */
|
|
23
|
+
export declare const ZERO: Mult;
|
|
24
|
+
/** Any number of outputs. @internal */
|
|
25
|
+
export declare const MANY: Mult;
|
|
26
|
+
/** At least one output, possibly more. @internal */
|
|
27
|
+
export declare const SOME: Mult;
|
|
28
|
+
/**
|
|
29
|
+
* The multiplicity of `a | b`: each output of `a` feeds `b`.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Not `then`: a module that exports a `then` is a thenable, and a promise
|
|
33
|
+
* resolved with its namespace calls that `then` and waits on it forever — as
|
|
34
|
+
* vitest's module runner resolves every module it loads.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export declare function piped(a: Mult, b: Mult): Mult;
|
|
39
|
+
/**
|
|
40
|
+
* The multiplicity of `a, b`: the outputs of `a`, then those of `b`.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export declare function also(a: Mult, b: Mult): Mult;
|
|
45
|
+
/**
|
|
46
|
+
* The multiplicity of a choice between two filters: `if`, `//`, `try`.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function either(a: Mult, b: Mult): Mult;
|
|
51
|
+
/**
|
|
52
|
+
* The multiplicity a checked query records.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export declare function wireMultiplicity(m: Mult): "one" | "maybe" | "many";
|
|
57
|
+
/**
|
|
58
|
+
* What narrowing has proved about a value, following its type's structure.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* - `cases` — a variant holds one of these cases; `payload` is what is known
|
|
62
|
+
* about the payload when there is only one.
|
|
63
|
+
* - `fields` — facts about some fields of a struct.
|
|
64
|
+
* - `elements` — facts about every element of an array, set or vector.
|
|
65
|
+
* - `values` — facts about every value of a dict.
|
|
66
|
+
* - `present` — an option holds a value.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export type Facts = {
|
|
71
|
+
readonly kind: "cases";
|
|
72
|
+
readonly cases: ReadonlySet<string>;
|
|
73
|
+
readonly payload: Facts | undefined;
|
|
74
|
+
} | {
|
|
75
|
+
readonly kind: "fields";
|
|
76
|
+
readonly fields: ReadonlyMap<string, Facts>;
|
|
77
|
+
} | {
|
|
78
|
+
readonly kind: "elements";
|
|
79
|
+
readonly element: Facts;
|
|
80
|
+
} | {
|
|
81
|
+
readonly kind: "values";
|
|
82
|
+
readonly value: Facts;
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: "present";
|
|
85
|
+
readonly payload: Facts | undefined;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* An output of an East type, with what narrowing has proved about it.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
export interface TypeShape {
|
|
93
|
+
readonly kind: "type";
|
|
94
|
+
readonly type: EastType;
|
|
95
|
+
readonly facts: Facts | undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* One member of a union: an output of one of several types, and the variant
|
|
99
|
+
* case it was read from when it is a payload.
|
|
100
|
+
*
|
|
101
|
+
* @internal
|
|
102
|
+
*/
|
|
103
|
+
export interface Member {
|
|
104
|
+
readonly shape: TypeShape;
|
|
105
|
+
readonly case: string | undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The outputs of a filter as the checker knows them.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* - `type` — every output has this East type.
|
|
112
|
+
* - `union` — outputs have different types, one member per type (`..`, `.[]`
|
|
113
|
+
* over a struct, the payload of an un-narrowed variant). A union must unify
|
|
114
|
+
* into one type before it is collected or output.
|
|
115
|
+
* - `error` — a diagnostic was reported here; everything built on it is
|
|
116
|
+
* unchecked, so one mistake reports one problem.
|
|
117
|
+
*
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
export type Shape = TypeShape | {
|
|
121
|
+
readonly kind: "union";
|
|
122
|
+
readonly members: readonly Member[];
|
|
123
|
+
} | {
|
|
124
|
+
readonly kind: "error";
|
|
125
|
+
};
|
|
126
|
+
/** The shape after a reported problem. @internal */
|
|
127
|
+
export declare const ERROR: Shape;
|
|
128
|
+
/**
|
|
129
|
+
* The shape of outputs of one type.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function typed(type: EastType, facts?: Facts): TypeShape;
|
|
134
|
+
/**
|
|
135
|
+
* A union of members, flattened, with members of the same type and case
|
|
136
|
+
* merged; a single member is its own shape.
|
|
137
|
+
*
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
export declare function union(members: readonly Member[]): Shape;
|
|
141
|
+
/**
|
|
142
|
+
* The members of a shape: one for a `type` shape.
|
|
143
|
+
*
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
export declare function membersOf(shape: Shape): readonly Member[];
|
|
147
|
+
/**
|
|
148
|
+
* A type with its recursive wrapper and references read through: what a
|
|
149
|
+
* value of it is made of.
|
|
150
|
+
*
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
export declare function unwrap(type: EastType): EastType;
|
|
154
|
+
/**
|
|
155
|
+
* The payload of an option that jq sees as `null` or the value: East JSON's
|
|
156
|
+
* flat options (`jsonFlatOptionPayload`).
|
|
157
|
+
*
|
|
158
|
+
* @param type - a type
|
|
159
|
+
* @returns the `some` payload's type, or `undefined` when the type is not a
|
|
160
|
+
* flat option (jq then sees it as `{type, value}`)
|
|
161
|
+
*
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
export declare function nullablePayload(type: EastType): EastType | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Whether jq sees values of a type as `null`: Null, or a flat option.
|
|
167
|
+
*
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
export declare function canBeNull(type: EastType): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* The type jq's `T` or `null` becomes: `Option<T>`, or `T` itself when it can
|
|
173
|
+
* already be `null`.
|
|
174
|
+
*
|
|
175
|
+
* @returns the type, or `undefined` when no type holds both: `T` is an option
|
|
176
|
+
* jq sees as `{type, value}`, and wrapping it again would too
|
|
177
|
+
*
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
export declare function orNull(type: EastType): EastType | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* The one type two outputs can share, as jq's typed outputs unify.
|
|
183
|
+
*
|
|
184
|
+
* @param a - one output's type
|
|
185
|
+
* @param b - another's
|
|
186
|
+
* @returns their common type, or `undefined` when they have none
|
|
187
|
+
*
|
|
188
|
+
* @remarks
|
|
189
|
+
* - Equal types unify to themselves, and `Never` (no value) to the other.
|
|
190
|
+
* - A reference is read through, as jq sees its value: `Ref<T>` and `U`
|
|
191
|
+
* unify as `T` and `U` do.
|
|
192
|
+
* - A recursive type and its node unify to the recursive type; another
|
|
193
|
+
* recursive type only with `null`, or an option of it.
|
|
194
|
+
* - Integer and Float unify to Float.
|
|
195
|
+
* - `null` and `T` unify to `Option<T>`; `Option<T>` and `U` to
|
|
196
|
+
* `Option<T ⊔ U>`.
|
|
197
|
+
* - Arrays, sets, dicts and vectors unify element-wise; `Array<Never>` (an
|
|
198
|
+
* empty `[]`) takes the other's element type.
|
|
199
|
+
* - Structs with the same field names unify field by field, in the first's
|
|
200
|
+
* field order; `Struct{}` (an empty `{}`) unifies with any dict.
|
|
201
|
+
* - Variants unify case by case, taking every case of both.
|
|
202
|
+
*
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
export declare function unify(a: EastType, b: EastType): EastType | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* The types `..` and `recurse` give on values of some types: each type, then
|
|
208
|
+
* the types of the values inside it, depth first, each once. Inside a value
|
|
209
|
+
* are an option's value, the elements of an array, set or vector, a matrix's
|
|
210
|
+
* rows, a dict's values, a struct's fields, and a variant's case name and
|
|
211
|
+
* payloads (jq's `{type, value}`).
|
|
212
|
+
*
|
|
213
|
+
* @param types - the input's types
|
|
214
|
+
* @returns the types, in the order the walk first meets them
|
|
215
|
+
*
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
export declare function descendTypes(types: readonly EastType[]): EastType[];
|
|
219
|
+
/**
|
|
220
|
+
* The one type a shape's outputs share.
|
|
221
|
+
*
|
|
222
|
+
* @param shape - a shape
|
|
223
|
+
* @returns the type, `Never` for no outputs, or `undefined` when the members
|
|
224
|
+
* have no common type (or the shape is an error)
|
|
225
|
+
*
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
export declare function unifyShape(shape: Shape): EastType | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Prints a type for a diagnostic, as jq's users read one: `Integer`,
|
|
231
|
+
* `Option<Float>`, `Array<String>`, `Dict<String, Float>`,
|
|
232
|
+
* `Struct{id: Integer, total: Float}`, `Variant{cancelled, pending, shipped}`.
|
|
233
|
+
*
|
|
234
|
+
* @param type - the type
|
|
235
|
+
* @param depth - how many levels of structs to spell out
|
|
236
|
+
* @returns its text
|
|
237
|
+
*
|
|
238
|
+
* @remarks
|
|
239
|
+
* A struct deeper than `depth` prints as `Struct{…}`, and one with more than
|
|
240
|
+
* six fields lists six and `…`. A recursive type prints its node, and a
|
|
241
|
+
* reference back into it as `…`.
|
|
242
|
+
*
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
export declare function describeType(type: EastType, depth?: number): string;
|
|
246
|
+
/**
|
|
247
|
+
* What a condition proves when it is true: that a variant at a field path
|
|
248
|
+
* from `.` holds one of some cases (`.status.type == "shipped"`), or that
|
|
249
|
+
* the value at the path has one of some jq types (`type == "number"`).
|
|
250
|
+
*
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
export type Proof = {
|
|
254
|
+
readonly kind: "case";
|
|
255
|
+
readonly path: readonly string[];
|
|
256
|
+
readonly cases: readonly string[];
|
|
257
|
+
} | {
|
|
258
|
+
readonly kind: "type";
|
|
259
|
+
readonly path: readonly string[];
|
|
260
|
+
readonly types: readonly string[];
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* The names jq's `type` gives, and East's additions for its own types.
|
|
264
|
+
*
|
|
265
|
+
* @internal
|
|
266
|
+
*/
|
|
267
|
+
export declare const JQ_TYPE_NAMES: readonly string[];
|
|
268
|
+
/**
|
|
269
|
+
* The names `type` can give for values of a type: an option's `null` and its
|
|
270
|
+
* payload's.
|
|
271
|
+
*
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
274
|
+
export declare function jqTypeNames(type: EastType): string[];
|
|
275
|
+
/**
|
|
276
|
+
* Narrows a shape to the outputs whose jq type is one of some names: what
|
|
277
|
+
* `select(type == "object")` keeps.
|
|
278
|
+
*
|
|
279
|
+
* @internal
|
|
280
|
+
*/
|
|
281
|
+
export declare function narrowTypes(shape: Shape, types: readonly string[]): Shape;
|
|
282
|
+
/**
|
|
283
|
+
* What the checker knows about a filter's outputs.
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* - `shape` and `mult` — the outputs' types and how many there are.
|
|
287
|
+
* - `access` — the field names from the filter's input to its output, when
|
|
288
|
+
* the filter only reads fields (`.a.b`, `.a | .b`).
|
|
289
|
+
* - `caseOf` — the output is `.P.type` of a variant at path `P`, with the cases
|
|
290
|
+
* it can hold.
|
|
291
|
+
* - `proves` — what the output being true proves about the input.
|
|
292
|
+
* - `partial` — the output is an option only because some cases of a variant
|
|
293
|
+
* lack the field read, so narrowing would make it exact: the case that has
|
|
294
|
+
* it, the field, and the path of the node that read it.
|
|
295
|
+
* - `stream` — the output is an element of the stream the `[]` at this path
|
|
296
|
+
* makes.
|
|
297
|
+
* - `typeOf` — the output is the jq type name of the value at this field
|
|
298
|
+
* path from the input.
|
|
299
|
+
*
|
|
300
|
+
* @internal
|
|
301
|
+
*/
|
|
302
|
+
export interface Result {
|
|
303
|
+
readonly shape: Shape;
|
|
304
|
+
readonly mult: Mult;
|
|
305
|
+
readonly access?: readonly string[] | undefined;
|
|
306
|
+
readonly caseOf?: {
|
|
307
|
+
readonly path: readonly string[];
|
|
308
|
+
readonly variant: EastType;
|
|
309
|
+
readonly cases: readonly string[];
|
|
310
|
+
} | undefined;
|
|
311
|
+
readonly proves?: readonly Proof[] | undefined;
|
|
312
|
+
readonly partial?: {
|
|
313
|
+
readonly caseName: string;
|
|
314
|
+
readonly leaf: string;
|
|
315
|
+
readonly at: string;
|
|
316
|
+
} | undefined;
|
|
317
|
+
readonly stream?: string | undefined;
|
|
318
|
+
readonly typeOf?: readonly string[] | undefined;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Narrows a shape: the variant at `path` holds only `cases`.
|
|
322
|
+
*
|
|
323
|
+
* @param shape - the shape of `.`
|
|
324
|
+
* @param path - the field names from `.` to the variant
|
|
325
|
+
* @param cases - the cases it holds
|
|
326
|
+
* @returns the shape with the fact added, or the shape unchanged when the
|
|
327
|
+
* path does not lead to a variant
|
|
328
|
+
*
|
|
329
|
+
* @internal
|
|
330
|
+
*/
|
|
331
|
+
export declare function refine(shape: Shape, path: readonly string[], cases: readonly string[]): Shape;
|
|
332
|
+
/**
|
|
333
|
+
* The cases a variant can hold, given what is known about it.
|
|
334
|
+
*
|
|
335
|
+
* @internal
|
|
336
|
+
*/
|
|
337
|
+
export declare function casesOf(type: EastType, facts: Facts | undefined): string[];
|
|
338
|
+
/**
|
|
339
|
+
* Whether values of a type can be sorted and compared by East's total order:
|
|
340
|
+
* every data type (no functions).
|
|
341
|
+
*
|
|
342
|
+
* @internal
|
|
343
|
+
*/
|
|
344
|
+
export declare function isOrdered(type: EastType): boolean;
|
|
345
|
+
//# sourceMappingURL=shapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapes.d.ts","sourceRoot":"","sources":["../../../../src/query/jq/shapes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EAEQ,KAAK,QAAQ,EAC3B,MAAM,g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