wizard-ql 2.0.0 → 2.0.1
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/index.d.ts +1 -1
- package/dist/parse.d.ts +2 -1
- package/dist/spec.d.ts +10 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type Operation, type ComparisonOperation, type JunctionOperation, type Expression, type Condition, type UncheckedCondition, type Group, type Primitive, type TypeRecord, type Token, type ComparisonTypeToTSType, OPERATION_PURPOSE_DICTIONARY, COMPARISON_TYPE_DICTIONARY, OPERATION_ALIAS_DICTIONARY } from './spec';
|
|
1
|
+
export { type Operation, type ComparisonOperation, type JunctionOperation, type Expression, type UncheckedExpression, type Condition, type UncheckedCondition, type Group, type Primitive, type TypeRecord, type Token, type ComparisonTypeToTSType, OPERATION_PURPOSE_DICTIONARY, COMPARISON_TYPE_DICTIONARY, OPERATION_ALIAS_DICTIONARY } from './spec';
|
|
2
2
|
export { type ExpressionConstraints, QUOTE_EDGE_REGEX, parse, tokenize } from './parse';
|
|
3
3
|
export { executeAsKnex } from './execute';
|
|
4
4
|
export { type AggregationValue, summarize } from './summarize';
|
package/dist/parse.d.ts
CHANGED
|
@@ -51,4 +51,5 @@ export interface ExpressionConstraints<T extends TypeRecord, V extends boolean>
|
|
|
51
51
|
* @returns The object representation
|
|
52
52
|
* @throws {ParseError | ConstraintError}
|
|
53
53
|
*/
|
|
54
|
-
export declare function parse<const T extends TypeRecord
|
|
54
|
+
export declare function parse<const T extends TypeRecord = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type
|
|
55
|
+
const V extends boolean = false>(expression: string | string[] | Token[], constraints?: ExpressionConstraints<T, V>): Expression<ConvertTypeRecord<T>, V> | null;
|
package/dist/spec.d.ts
CHANGED
|
@@ -106,14 +106,14 @@ export type FieldTypeToTSType<T extends FieldType> = {
|
|
|
106
106
|
export type Primitive = FieldTypeToTSType<FieldType>;
|
|
107
107
|
/** Convert input type record to language server type record */
|
|
108
108
|
export type ConvertTypeRecord<T extends TypeRecord> = {
|
|
109
|
-
[K in keyof T]:
|
|
109
|
+
[K in keyof T]: T[K] extends FieldType[] ? FieldTypeToTSType<T[K][number]> : T[K] extends FieldType ? FieldTypeToTSType<T[K]> : Primitive;
|
|
110
110
|
};
|
|
111
111
|
export declare const TYPE_PRIORITY: ["boolean", "date", "number", "string"];
|
|
112
112
|
/**
|
|
113
113
|
* A group of conditions joined by a junction operator
|
|
114
114
|
* @template R A record mapping field names to values
|
|
115
115
|
*/
|
|
116
|
-
export interface Group<R extends Record<string,
|
|
116
|
+
export interface Group<R extends Record<string, unknown> = Record<string, Primitive>, V extends boolean = false> {
|
|
117
117
|
type: 'group';
|
|
118
118
|
/** The junction operator */
|
|
119
119
|
operation: JunctionOperation;
|
|
@@ -125,14 +125,14 @@ export interface Group<R extends Record<string, Primitive> = Record<string, Prim
|
|
|
125
125
|
* @template R A record mapping field names to values
|
|
126
126
|
* @template F The name of the field being queried
|
|
127
127
|
*/
|
|
128
|
-
export interface Condition<R extends Record<string,
|
|
128
|
+
export interface Condition<R extends Record<string, unknown>, F extends keyof R, O extends ComparisonOperation> {
|
|
129
129
|
type: 'condition';
|
|
130
130
|
/** The operation */
|
|
131
131
|
operation: O;
|
|
132
132
|
/** The name of the field */
|
|
133
133
|
field: F;
|
|
134
134
|
/** The value being checked */
|
|
135
|
-
value: typeof COMPARISON_TYPE_DICTIONARY[O] extends 'array' ? Array<R[F]> : R[F]
|
|
135
|
+
value: typeof COMPARISON_TYPE_DICTIONARY[O] extends 'array' ? Array<R[F]> : Extract<ComparisonTypeToTSType<O>, R[F]>;
|
|
136
136
|
/** Was this condition validated by the constraints or is its type unknown? */
|
|
137
137
|
validated: true;
|
|
138
138
|
}
|
|
@@ -146,7 +146,7 @@ export interface UncheckedCondition<O extends ComparisonOperation = ComparisonOp
|
|
|
146
146
|
/** The name of the field */
|
|
147
147
|
field: string;
|
|
148
148
|
/** The value being checked */
|
|
149
|
-
value: ComparisonTypeToTSType<O>;
|
|
149
|
+
value: Exclude<ComparisonTypeToTSType<O>, Date>;
|
|
150
150
|
/** Was this condition validated by the constraints or is its type unknown? */
|
|
151
151
|
validated: false;
|
|
152
152
|
}
|
|
@@ -160,7 +160,7 @@ type ReverseAggregate<T extends Record<any, any>> = {
|
|
|
160
160
|
};
|
|
161
161
|
type ReverseAggregatedTypes = ReverseAggregate<typeof COMPARISON_TYPE_DICTIONARY>;
|
|
162
162
|
/** Create a union of conditions; an intersection of the operation type validation and constraint type validation */
|
|
163
|
-
export type CheckedConditionSpread<R extends Record<string,
|
|
163
|
+
export type CheckedConditionSpread<R extends Record<string, unknown>> = {
|
|
164
164
|
[K in keyof R]: {
|
|
165
165
|
[O in keyof ReverseAggregatedTypes]: Condition<R, K, ReverseAggregatedTypes[O]>;
|
|
166
166
|
}[keyof ReverseAggregatedTypes];
|
|
@@ -169,5 +169,8 @@ export type CheckedConditionSpread<R extends Record<string, Primitive>> = {
|
|
|
169
169
|
export type UncheckedConditionSpread = {
|
|
170
170
|
[O in keyof ReverseAggregatedTypes]: UncheckedCondition<ReverseAggregatedTypes[O]>;
|
|
171
171
|
}[keyof ReverseAggregatedTypes];
|
|
172
|
-
export type Expression<R extends Record<string,
|
|
172
|
+
export type Expression<R extends Record<string, unknown> = Record<string, Primitive>, V extends boolean = false> = Group<R, V> | (V extends true ? CheckedConditionSpread<R> : CheckedConditionSpread<R> | UncheckedConditionSpread);
|
|
173
|
+
export type UncheckedExpression = (Omit<Group, 'constituents'> & {
|
|
174
|
+
constituents: UncheckedExpression[];
|
|
175
|
+
}) | UncheckedConditionSpread;
|
|
173
176
|
export {};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
},
|
|
7
7
|
"homepage": "https://github.com/guidance-analytics/wizard-ql",
|
|
8
8
|
"description": "WizardQL is a natural-language-like query language for constructing data queries for resources that meet conditions.",
|
|
9
|
-
"version": "2.0.
|
|
9
|
+
"version": "2.0.1",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "git+https://github.com/guidance-analytics/wizard-ql.git"
|