@tanstack/db 0.0.14 → 0.0.15
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/cjs/collection.cjs +117 -104
- package/dist/cjs/collection.cjs.map +1 -1
- package/dist/cjs/collection.d.cts +18 -21
- package/dist/cjs/index.cjs +35 -13
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +0 -1
- package/dist/cjs/query/builder/functions.cjs +107 -0
- package/dist/cjs/query/builder/functions.cjs.map +1 -0
- package/dist/cjs/query/builder/functions.d.cts +38 -0
- package/dist/cjs/query/builder/index.cjs +499 -0
- package/dist/cjs/query/builder/index.cjs.map +1 -0
- package/dist/cjs/query/builder/index.d.cts +324 -0
- package/dist/cjs/query/builder/ref-proxy.cjs +96 -0
- package/dist/cjs/query/builder/ref-proxy.cjs.map +1 -0
- package/dist/cjs/query/builder/ref-proxy.d.cts +28 -0
- package/dist/cjs/query/builder/types.d.cts +80 -0
- package/dist/cjs/query/compiler/evaluators.cjs +261 -0
- package/dist/cjs/query/compiler/evaluators.cjs.map +1 -0
- package/dist/cjs/query/compiler/evaluators.d.cts +11 -0
- package/dist/cjs/query/compiler/group-by.cjs +271 -0
- package/dist/cjs/query/compiler/group-by.cjs.map +1 -0
- package/dist/cjs/query/compiler/group-by.d.cts +7 -0
- package/dist/cjs/query/compiler/index.cjs +181 -0
- package/dist/cjs/query/compiler/index.cjs.map +1 -0
- package/dist/cjs/query/compiler/index.d.cts +15 -0
- package/dist/cjs/query/compiler/joins.cjs +116 -0
- package/dist/cjs/query/compiler/joins.cjs.map +1 -0
- package/dist/cjs/query/compiler/joins.d.cts +11 -0
- package/dist/cjs/query/compiler/order-by.cjs +89 -0
- package/dist/cjs/query/compiler/order-by.cjs.map +1 -0
- package/dist/cjs/query/compiler/order-by.d.cts +9 -0
- package/dist/cjs/query/compiler/select.cjs +57 -0
- package/dist/cjs/query/compiler/select.cjs.map +1 -0
- package/dist/cjs/query/compiler/select.d.cts +15 -0
- package/dist/cjs/query/index.d.cts +6 -5
- package/dist/cjs/query/ir.cjs +57 -0
- package/dist/cjs/query/ir.cjs.map +1 -0
- package/dist/cjs/query/ir.d.cts +81 -0
- package/dist/cjs/query/live-query-collection.cjs +224 -0
- package/dist/cjs/query/live-query-collection.cjs.map +1 -0
- package/dist/cjs/query/live-query-collection.d.cts +124 -0
- package/dist/cjs/transactions.cjs +20 -13
- package/dist/cjs/transactions.cjs.map +1 -1
- package/dist/cjs/transactions.d.cts +10 -1
- package/dist/cjs/types.d.cts +13 -0
- package/dist/esm/collection.d.ts +18 -21
- package/dist/esm/collection.js +118 -105
- package/dist/esm/collection.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +34 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/query/builder/functions.d.ts +38 -0
- package/dist/esm/query/builder/functions.js +107 -0
- package/dist/esm/query/builder/functions.js.map +1 -0
- package/dist/esm/query/builder/index.d.ts +324 -0
- package/dist/esm/query/builder/index.js +499 -0
- package/dist/esm/query/builder/index.js.map +1 -0
- package/dist/esm/query/builder/ref-proxy.d.ts +28 -0
- package/dist/esm/query/builder/ref-proxy.js +96 -0
- package/dist/esm/query/builder/ref-proxy.js.map +1 -0
- package/dist/esm/query/builder/types.d.ts +80 -0
- package/dist/esm/query/compiler/evaluators.d.ts +11 -0
- package/dist/esm/query/compiler/evaluators.js +261 -0
- package/dist/esm/query/compiler/evaluators.js.map +1 -0
- package/dist/esm/query/compiler/group-by.d.ts +7 -0
- package/dist/esm/query/compiler/group-by.js +271 -0
- package/dist/esm/query/compiler/group-by.js.map +1 -0
- package/dist/esm/query/compiler/index.d.ts +15 -0
- package/dist/esm/query/compiler/index.js +181 -0
- package/dist/esm/query/compiler/index.js.map +1 -0
- package/dist/esm/query/compiler/joins.d.ts +11 -0
- package/dist/esm/query/compiler/joins.js +116 -0
- package/dist/esm/query/compiler/joins.js.map +1 -0
- package/dist/esm/query/compiler/order-by.d.ts +9 -0
- package/dist/esm/query/compiler/order-by.js +89 -0
- package/dist/esm/query/compiler/order-by.js.map +1 -0
- package/dist/esm/query/compiler/select.d.ts +15 -0
- package/dist/esm/query/compiler/select.js +57 -0
- package/dist/esm/query/compiler/select.js.map +1 -0
- package/dist/esm/query/index.d.ts +6 -5
- package/dist/esm/query/ir.d.ts +81 -0
- package/dist/esm/query/ir.js +57 -0
- package/dist/esm/query/ir.js.map +1 -0
- package/dist/esm/query/live-query-collection.d.ts +124 -0
- package/dist/esm/query/live-query-collection.js +224 -0
- package/dist/esm/query/live-query-collection.js.map +1 -0
- package/dist/esm/transactions.d.ts +10 -1
- package/dist/esm/transactions.js +20 -13
- package/dist/esm/transactions.js.map +1 -1
- package/dist/esm/types.d.ts +13 -0
- package/package.json +3 -4
- package/src/collection.ts +152 -129
- package/src/index.ts +0 -1
- package/src/query/builder/functions.ts +267 -0
- package/src/query/builder/index.ts +648 -0
- package/src/query/builder/ref-proxy.ts +156 -0
- package/src/query/builder/types.ts +278 -0
- package/src/query/compiler/evaluators.ts +315 -0
- package/src/query/compiler/group-by.ts +428 -0
- package/src/query/compiler/index.ts +276 -0
- package/src/query/compiler/joins.ts +228 -0
- package/src/query/compiler/order-by.ts +139 -0
- package/src/query/compiler/select.ts +173 -0
- package/src/query/index.ts +64 -5
- package/src/query/ir.ts +128 -0
- package/src/query/live-query-collection.ts +509 -0
- package/src/transactions.ts +27 -16
- package/src/types.ts +15 -0
- package/dist/cjs/query/compiled-query.cjs +0 -160
- package/dist/cjs/query/compiled-query.cjs.map +0 -1
- package/dist/cjs/query/compiled-query.d.cts +0 -20
- package/dist/cjs/query/evaluators.cjs +0 -161
- package/dist/cjs/query/evaluators.cjs.map +0 -1
- package/dist/cjs/query/evaluators.d.cts +0 -14
- package/dist/cjs/query/extractors.cjs +0 -122
- package/dist/cjs/query/extractors.cjs.map +0 -1
- package/dist/cjs/query/extractors.d.cts +0 -22
- package/dist/cjs/query/functions.cjs +0 -152
- package/dist/cjs/query/functions.cjs.map +0 -1
- package/dist/cjs/query/functions.d.cts +0 -21
- package/dist/cjs/query/group-by.cjs +0 -88
- package/dist/cjs/query/group-by.cjs.map +0 -1
- package/dist/cjs/query/group-by.d.cts +0 -40
- package/dist/cjs/query/joins.cjs +0 -141
- package/dist/cjs/query/joins.cjs.map +0 -1
- package/dist/cjs/query/joins.d.cts +0 -14
- package/dist/cjs/query/order-by.cjs +0 -185
- package/dist/cjs/query/order-by.cjs.map +0 -1
- package/dist/cjs/query/order-by.d.cts +0 -3
- package/dist/cjs/query/pipeline-compiler.cjs +0 -89
- package/dist/cjs/query/pipeline-compiler.cjs.map +0 -1
- package/dist/cjs/query/pipeline-compiler.d.cts +0 -10
- package/dist/cjs/query/query-builder.cjs +0 -307
- package/dist/cjs/query/query-builder.cjs.map +0 -1
- package/dist/cjs/query/query-builder.d.cts +0 -225
- package/dist/cjs/query/schema.d.cts +0 -100
- package/dist/cjs/query/select.cjs +0 -130
- package/dist/cjs/query/select.cjs.map +0 -1
- package/dist/cjs/query/select.d.cts +0 -3
- package/dist/cjs/query/types.d.cts +0 -189
- package/dist/cjs/query/utils.cjs +0 -154
- package/dist/cjs/query/utils.cjs.map +0 -1
- package/dist/cjs/query/utils.d.cts +0 -37
- package/dist/cjs/utils.cjs +0 -17
- package/dist/cjs/utils.cjs.map +0 -1
- package/dist/cjs/utils.d.cts +0 -3
- package/dist/esm/query/compiled-query.d.ts +0 -20
- package/dist/esm/query/compiled-query.js +0 -160
- package/dist/esm/query/compiled-query.js.map +0 -1
- package/dist/esm/query/evaluators.d.ts +0 -14
- package/dist/esm/query/evaluators.js +0 -161
- package/dist/esm/query/evaluators.js.map +0 -1
- package/dist/esm/query/extractors.d.ts +0 -22
- package/dist/esm/query/extractors.js +0 -122
- package/dist/esm/query/extractors.js.map +0 -1
- package/dist/esm/query/functions.d.ts +0 -21
- package/dist/esm/query/functions.js +0 -152
- package/dist/esm/query/functions.js.map +0 -1
- package/dist/esm/query/group-by.d.ts +0 -40
- package/dist/esm/query/group-by.js +0 -88
- package/dist/esm/query/group-by.js.map +0 -1
- package/dist/esm/query/joins.d.ts +0 -14
- package/dist/esm/query/joins.js +0 -141
- package/dist/esm/query/joins.js.map +0 -1
- package/dist/esm/query/order-by.d.ts +0 -3
- package/dist/esm/query/order-by.js +0 -185
- package/dist/esm/query/order-by.js.map +0 -1
- package/dist/esm/query/pipeline-compiler.d.ts +0 -10
- package/dist/esm/query/pipeline-compiler.js +0 -89
- package/dist/esm/query/pipeline-compiler.js.map +0 -1
- package/dist/esm/query/query-builder.d.ts +0 -225
- package/dist/esm/query/query-builder.js +0 -307
- package/dist/esm/query/query-builder.js.map +0 -1
- package/dist/esm/query/schema.d.ts +0 -100
- package/dist/esm/query/select.d.ts +0 -3
- package/dist/esm/query/select.js +0 -130
- package/dist/esm/query/select.js.map +0 -1
- package/dist/esm/query/types.d.ts +0 -189
- package/dist/esm/query/utils.d.ts +0 -37
- package/dist/esm/query/utils.js +0 -154
- package/dist/esm/query/utils.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -3
- package/dist/esm/utils.js +0 -17
- package/dist/esm/utils.js.map +0 -1
- package/src/query/compiled-query.ts +0 -234
- package/src/query/evaluators.ts +0 -250
- package/src/query/extractors.ts +0 -214
- package/src/query/functions.ts +0 -297
- package/src/query/group-by.ts +0 -139
- package/src/query/joins.ts +0 -260
- package/src/query/order-by.ts +0 -264
- package/src/query/pipeline-compiler.ts +0 -149
- package/src/query/query-builder.ts +0 -902
- package/src/query/schema.ts +0 -268
- package/src/query/select.ts +0 -208
- package/src/query/types.ts +0 -418
- package/src/query/utils.ts +0 -245
- package/src/utils.ts +0 -15
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { ConditionOperand, ExplicitLiteral, FunctionCall, LiteralValue, Select } from './schema.js';
|
|
2
|
-
export type Input = Record<string, unknown>;
|
|
3
|
-
export type Schema = Record<string, Input>;
|
|
4
|
-
export type Context<TBaseSchema extends Schema = Schema, TSchema extends Schema = Schema> = {
|
|
5
|
-
baseSchema: TBaseSchema;
|
|
6
|
-
schema: TSchema;
|
|
7
|
-
default?: keyof TSchema;
|
|
8
|
-
result?: Record<string, unknown>;
|
|
9
|
-
hasJoin?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type Flatten<T> = {
|
|
12
|
-
[K in keyof T]: T[K];
|
|
13
|
-
} & {};
|
|
14
|
-
type UniqueSecondLevelKeys<T> = {
|
|
15
|
-
[K in keyof T]: Exclude<keyof T[K], {
|
|
16
|
-
[P in Exclude<keyof T, K>]: keyof T[P];
|
|
17
|
-
}[Exclude<keyof T, K>]>;
|
|
18
|
-
}[keyof T];
|
|
19
|
-
type InputNames<TSchema extends Schema> = RemoveIndexSignature<{
|
|
20
|
-
[I in keyof TSchema]: I;
|
|
21
|
-
}>[keyof RemoveIndexSignature<{
|
|
22
|
-
[I in keyof TSchema]: I;
|
|
23
|
-
}>];
|
|
24
|
-
type UniquePropertyNames<TSchema extends Schema> = UniqueSecondLevelKeys<RemoveIndexSignature<TSchema>>;
|
|
25
|
-
export type RemoveIndexSignature<T> = {
|
|
26
|
-
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
27
|
-
};
|
|
28
|
-
type QualifiedReferencesOfSchemaString<TSchema extends Schema> = RemoveIndexSignature<{
|
|
29
|
-
[I in keyof TSchema]: {
|
|
30
|
-
[P in keyof RemoveIndexSignature<TSchema[I]>]: `@${string & I}.${string & P}`;
|
|
31
|
-
}[keyof RemoveIndexSignature<TSchema[I]>];
|
|
32
|
-
}>;
|
|
33
|
-
type QualifiedReferenceString<TContext extends Context<Schema>> = QualifiedReferencesOfSchemaString<TContext[`schema`]>[keyof QualifiedReferencesOfSchemaString<TContext[`schema`]>];
|
|
34
|
-
type QualifiedReferencesOfSchemaObject<TSchema extends Schema> = RemoveIndexSignature<{
|
|
35
|
-
[I in keyof TSchema]: {
|
|
36
|
-
[P in keyof RemoveIndexSignature<TSchema[I]>]: {
|
|
37
|
-
col: `${string & I}.${string & P}`;
|
|
38
|
-
};
|
|
39
|
-
}[keyof RemoveIndexSignature<TSchema[I]>];
|
|
40
|
-
}>;
|
|
41
|
-
type QualifiedReferenceObject<TContext extends Context<Schema>> = QualifiedReferencesOfSchemaObject<TContext[`schema`]>[keyof QualifiedReferencesOfSchemaObject<TContext[`schema`]>];
|
|
42
|
-
type QualifiedReference<TContext extends Context<Schema>> = QualifiedReferenceString<TContext> | QualifiedReferenceObject<TContext>;
|
|
43
|
-
type DefaultReferencesOfSchemaString<TSchema extends Schema, TDefault extends keyof TSchema> = RemoveIndexSignature<{
|
|
44
|
-
[P in keyof TSchema[TDefault]]: `@${string & P}`;
|
|
45
|
-
}>;
|
|
46
|
-
type DefaultReferenceString<TContext extends Context<Schema>> = TContext[`default`] extends undefined ? never : DefaultReferencesOfSchemaString<TContext[`schema`], Exclude<TContext[`default`], undefined>>[keyof DefaultReferencesOfSchemaString<TContext[`schema`], Exclude<TContext[`default`], undefined>>];
|
|
47
|
-
type DefaultReferencesOfSchemaObject<TSchema extends Schema, TDefault extends keyof TSchema> = RemoveIndexSignature<{
|
|
48
|
-
[P in keyof TSchema[TDefault]]: {
|
|
49
|
-
col: `${string & P}`;
|
|
50
|
-
};
|
|
51
|
-
}>;
|
|
52
|
-
type DefaultReferenceObject<TContext extends Context<Schema>> = TContext[`default`] extends undefined ? never : DefaultReferencesOfSchemaObject<TContext[`schema`], Exclude<TContext[`default`], undefined>>[keyof DefaultReferencesOfSchemaObject<TContext[`schema`], Exclude<TContext[`default`], undefined>>];
|
|
53
|
-
type DefaultReference<TContext extends Context<Schema>> = DefaultReferenceString<TContext> | DefaultReferenceObject<TContext>;
|
|
54
|
-
type UniqueReferencesOfSchemaString<TSchema extends Schema> = RemoveIndexSignature<{
|
|
55
|
-
[I in keyof TSchema]: {
|
|
56
|
-
[P in keyof TSchema[I]]: P extends UniquePropertyNames<TSchema> ? `@${string & P}` : never;
|
|
57
|
-
}[keyof TSchema[I]];
|
|
58
|
-
}>;
|
|
59
|
-
type UniqueReferenceString<TContext extends Context<Schema>> = UniqueReferencesOfSchemaString<TContext[`schema`]>[keyof UniqueReferencesOfSchemaString<TContext[`schema`]>];
|
|
60
|
-
type UniqueReferencesOfSchemaObject<TSchema extends Schema> = RemoveIndexSignature<{
|
|
61
|
-
[I in keyof TSchema]: {
|
|
62
|
-
[P in keyof TSchema[I]]: P extends UniquePropertyNames<TSchema> ? {
|
|
63
|
-
col: `${string & P}`;
|
|
64
|
-
} : never;
|
|
65
|
-
}[keyof TSchema[I]];
|
|
66
|
-
}>;
|
|
67
|
-
type UniqueReferenceObject<TContext extends Context<Schema>> = UniqueReferencesOfSchemaObject<TContext[`schema`]>[keyof UniqueReferencesOfSchemaObject<TContext[`schema`]>];
|
|
68
|
-
type UniqueReference<TContext extends Context<Schema>> = UniqueReferenceString<TContext> | UniqueReferenceObject<TContext>;
|
|
69
|
-
type InputWildcardString<TContext extends Context<Schema>> = Flatten<{
|
|
70
|
-
[I in InputNames<TContext[`schema`]>]: `@${I}.*`;
|
|
71
|
-
}[InputNames<TContext[`schema`]>]>;
|
|
72
|
-
type InputWildcardObject<TContext extends Context<Schema>> = Flatten<{
|
|
73
|
-
[I in InputNames<TContext[`schema`]>]: {
|
|
74
|
-
col: `${I}.*`;
|
|
75
|
-
};
|
|
76
|
-
}[InputNames<TContext[`schema`]>]>;
|
|
77
|
-
type InputWildcard<TContext extends Context<Schema>> = InputWildcardString<TContext> | InputWildcardObject<TContext>;
|
|
78
|
-
type AllWildcardString = `@*`;
|
|
79
|
-
type AllWildcardObject = {
|
|
80
|
-
col: `*`;
|
|
81
|
-
};
|
|
82
|
-
type AllWildcard = AllWildcardString | AllWildcardObject;
|
|
83
|
-
export type PropertyReferenceString<TContext extends Context<Schema>> = DefaultReferenceString<TContext> | QualifiedReferenceString<TContext> | UniqueReferenceString<TContext>;
|
|
84
|
-
export type WildcardReferenceString<TContext extends Context<Schema>> = InputWildcardString<TContext> | AllWildcardString;
|
|
85
|
-
export type PropertyReferenceObject<TContext extends Context<Schema>> = DefaultReferenceObject<TContext> | QualifiedReferenceObject<TContext> | UniqueReferenceObject<TContext>;
|
|
86
|
-
export type WildcardReferenceObject<TContext extends Context<Schema>> = InputWildcardObject<TContext> | AllWildcardObject;
|
|
87
|
-
export type PropertyReference<TContext extends Context<Schema>> = DefaultReference<TContext> | QualifiedReference<TContext> | UniqueReference<TContext>;
|
|
88
|
-
export type WildcardReference<TContext extends Context<Schema>> = InputWildcard<TContext> | AllWildcard;
|
|
89
|
-
type InputWithProperty<TSchema extends Schema, TProperty extends string> = {
|
|
90
|
-
[I in keyof RemoveIndexSignature<TSchema>]: TProperty extends keyof TSchema[I] ? I : never;
|
|
91
|
-
}[keyof RemoveIndexSignature<TSchema>];
|
|
92
|
-
export type TypeFromPropertyReference<TContext extends Context<Schema>, TReference extends PropertyReference<TContext>> = TReference extends `@${infer InputName}.${infer PropName}` | {
|
|
93
|
-
col: `${infer InputName}.${infer PropName}`;
|
|
94
|
-
} ? InputName extends keyof TContext[`schema`] ? PropName extends keyof TContext[`schema`][InputName] ? TContext[`schema`][InputName][PropName] : never : never : TReference extends `@${infer PropName}` | {
|
|
95
|
-
col: `${infer PropName}`;
|
|
96
|
-
} ? PropName extends keyof TContext[`schema`][Exclude<TContext[`default`], undefined>] ? TContext[`schema`][Exclude<TContext[`default`], undefined>][PropName] : TContext[`schema`][InputWithProperty<TContext[`schema`], PropName>][PropName] : never;
|
|
97
|
-
/**
|
|
98
|
-
* Return the key that would be used in the result of the query for a given property
|
|
99
|
-
* reference.
|
|
100
|
-
* - `@id` -> `id`
|
|
101
|
-
* - `@employees.id` -> `id`
|
|
102
|
-
* - `{ col: 'id' }` -> `id`
|
|
103
|
-
* - `{ col: 'employees.id' }` -> `id`
|
|
104
|
-
*/
|
|
105
|
-
export type ResultKeyFromPropertyReference<TContext extends Context<Schema>, TReference extends PropertyReference<TContext>> = TReference extends `@${infer _InputName}.${infer PropName}` ? PropName : TReference extends {
|
|
106
|
-
col: `${infer _InputName}.${infer PropName}`;
|
|
107
|
-
} ? PropName : TReference extends `@${infer PropName}` ? PropName : TReference extends {
|
|
108
|
-
col: `${infer PropName}`;
|
|
109
|
-
} ? PropName : never;
|
|
110
|
-
export type InputReference<TContext extends Context<Schema>> = {
|
|
111
|
-
[I in InputNames<TContext[`schema`]>]: I;
|
|
112
|
-
}[InputNames<TContext[`schema`]>];
|
|
113
|
-
export type RenameInput<TSchema extends Schema, TInput extends keyof TSchema, TNewName extends string> = Flatten<{
|
|
114
|
-
[K in Exclude<keyof TSchema, TInput>]: TSchema[K];
|
|
115
|
-
} & {
|
|
116
|
-
[P in TNewName]: TSchema[TInput];
|
|
117
|
-
}>;
|
|
118
|
-
export type MaybeRenameInput<TSchema extends Schema, TInput extends keyof TSchema, TNewName extends string | undefined> = TNewName extends undefined ? TSchema : RenameInput<TSchema, TInput, Exclude<TNewName, undefined>>;
|
|
119
|
-
/**
|
|
120
|
-
* Helper type to combine result types from each select item in a tuple
|
|
121
|
-
*/
|
|
122
|
-
export type InferResultTypeFromSelectTuple<TContext extends Context<Schema>, TSelects extends ReadonlyArray<Select<TContext>>> = UnionToIntersection<{
|
|
123
|
-
[K in keyof TSelects]: TSelects[K] extends Select<TContext> ? InferResultType<TContext, TSelects[K]> : never;
|
|
124
|
-
}[number]>;
|
|
125
|
-
/**
|
|
126
|
-
* Convert a union type to an intersection type
|
|
127
|
-
*/
|
|
128
|
-
type UnionToIntersection<TUnion> = (TUnion extends any ? (x: TUnion) => void : never) extends (x: infer I) => void ? I : never;
|
|
129
|
-
/**
|
|
130
|
-
* Infers the result type from a single select item
|
|
131
|
-
*/
|
|
132
|
-
type InferResultType<TContext extends Context<Schema>, TSelect extends Select<TContext>> = TSelect extends PropertyReferenceString<TContext> ? {
|
|
133
|
-
[K in ResultKeyFromPropertyReference<TContext, TSelect>]: TypeFromPropertyReference<TContext, TSelect>;
|
|
134
|
-
} : TSelect extends WildcardReferenceString<TContext> ? TSelect extends `@*` ? InferAllColumnsType<TContext> : TSelect extends `@${infer TableName}.*` ? TableName extends keyof TContext[`schema`] ? InferTableColumnsType<TContext, TableName> : {} : {} : TSelect extends {
|
|
135
|
-
[alias: string]: PropertyReference<TContext> | FunctionCall<TContext>;
|
|
136
|
-
} ? {
|
|
137
|
-
[K in keyof TSelect]: TSelect[K] extends PropertyReference<TContext> ? TypeFromPropertyReference<TContext, TSelect[K]> : TSelect[K] extends FunctionCall<TContext> ? InferFunctionCallResultType<TContext, TSelect[K]> : never;
|
|
138
|
-
} : {};
|
|
139
|
-
/**
|
|
140
|
-
* Infers the result type for all columns from all tables
|
|
141
|
-
*/
|
|
142
|
-
type InferAllColumnsType<TContext extends Context<Schema>> = {
|
|
143
|
-
[K in keyof TContext[`schema`]]: {
|
|
144
|
-
[P in keyof TContext[`schema`][K]]: TContext[`schema`][K][P];
|
|
145
|
-
};
|
|
146
|
-
}[keyof TContext[`schema`]];
|
|
147
|
-
/**
|
|
148
|
-
* Infers the result type for all columns from a specific table
|
|
149
|
-
*/
|
|
150
|
-
type InferTableColumnsType<TContext extends Context<Schema>, TTable extends keyof TContext[`schema`]> = {
|
|
151
|
-
[P in keyof TContext[`schema`][TTable]]: TContext[`schema`][TTable][P];
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Infers the result type for a function call
|
|
155
|
-
*/
|
|
156
|
-
type InferFunctionCallResultType<TContext extends Context<Schema>, TFunctionCall extends FunctionCall<TContext>> = TFunctionCall extends {
|
|
157
|
-
SUM: any;
|
|
158
|
-
} ? number : TFunctionCall extends {
|
|
159
|
-
COUNT: any;
|
|
160
|
-
} ? number : TFunctionCall extends {
|
|
161
|
-
AVG: any;
|
|
162
|
-
} ? number : TFunctionCall extends {
|
|
163
|
-
MIN: any;
|
|
164
|
-
} ? InferOperandType<TContext, TFunctionCall[`MIN`]> : TFunctionCall extends {
|
|
165
|
-
MAX: any;
|
|
166
|
-
} ? InferOperandType<TContext, TFunctionCall[`MAX`]> : TFunctionCall extends {
|
|
167
|
-
DATE: any;
|
|
168
|
-
} ? string : TFunctionCall extends {
|
|
169
|
-
JSON_EXTRACT: any;
|
|
170
|
-
} ? unknown : TFunctionCall extends {
|
|
171
|
-
JSON_EXTRACT_PATH: any;
|
|
172
|
-
} ? unknown : TFunctionCall extends {
|
|
173
|
-
UPPER: any;
|
|
174
|
-
} ? string : TFunctionCall extends {
|
|
175
|
-
LOWER: any;
|
|
176
|
-
} ? string : TFunctionCall extends {
|
|
177
|
-
COALESCE: any;
|
|
178
|
-
} ? InferOperandType<TContext, TFunctionCall[`COALESCE`]> : TFunctionCall extends {
|
|
179
|
-
CONCAT: any;
|
|
180
|
-
} ? string : TFunctionCall extends {
|
|
181
|
-
LENGTH: any;
|
|
182
|
-
} ? number : TFunctionCall extends {
|
|
183
|
-
ORDER_INDEX: any;
|
|
184
|
-
} ? number : unknown;
|
|
185
|
-
/**
|
|
186
|
-
* Infers the type of an operand
|
|
187
|
-
*/
|
|
188
|
-
type InferOperandType<TContext extends Context<Schema>, TOperand extends ConditionOperand<TContext>> = TOperand extends PropertyReference<TContext> ? TypeFromPropertyReference<TContext, TOperand> : TOperand extends LiteralValue ? TOperand : TOperand extends ExplicitLiteral ? TOperand[`value`] : TOperand extends FunctionCall<TContext> ? InferFunctionCallResultType<TContext, TOperand> : TOperand extends Array<ConditionOperand<TContext>> ? InferOperandType<TContext, TOperand[number]> : unknown;
|
|
189
|
-
export {};
|
package/dist/cjs/query/utils.cjs
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function isAggregateFunctionCall(obj) {
|
|
4
|
-
if (!obj || typeof obj !== `object`) return false;
|
|
5
|
-
const aggregateFunctions = [
|
|
6
|
-
`SUM`,
|
|
7
|
-
`COUNT`,
|
|
8
|
-
`AVG`,
|
|
9
|
-
`MIN`,
|
|
10
|
-
`MAX`,
|
|
11
|
-
`MEDIAN`,
|
|
12
|
-
`MODE`
|
|
13
|
-
];
|
|
14
|
-
const keys = Object.keys(obj);
|
|
15
|
-
return keys.length === 1 && aggregateFunctions.includes(keys[0]);
|
|
16
|
-
}
|
|
17
|
-
function isOrderIndexFunctionCall(obj) {
|
|
18
|
-
if (!obj || typeof obj !== `object`) return false;
|
|
19
|
-
const keys = Object.keys(obj);
|
|
20
|
-
return keys.length === 1 && keys[0] === `ORDER_INDEX`;
|
|
21
|
-
}
|
|
22
|
-
function isComparable(value) {
|
|
23
|
-
return typeof value === `number` || typeof value === `string` || typeof value === `boolean` || value instanceof Date;
|
|
24
|
-
}
|
|
25
|
-
function compareValues(left, right, operator) {
|
|
26
|
-
if (!isComparable(left) || !isComparable(right)) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Cannot compare non-comparable values: ${typeof left} and ${typeof right}`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
if (typeof left !== typeof right && (typeof left === `string` || typeof left === `number`) && (typeof right === `string` || typeof right === `number`)) {
|
|
32
|
-
const leftStr = String(left);
|
|
33
|
-
const rightStr = String(right);
|
|
34
|
-
switch (operator) {
|
|
35
|
-
case `<`:
|
|
36
|
-
return leftStr < rightStr;
|
|
37
|
-
case `<=`:
|
|
38
|
-
return leftStr <= rightStr;
|
|
39
|
-
case `>`:
|
|
40
|
-
return leftStr > rightStr;
|
|
41
|
-
case `>=`:
|
|
42
|
-
return leftStr >= rightStr;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (left instanceof Date && right instanceof Date) {
|
|
46
|
-
const leftTime = left.getTime();
|
|
47
|
-
const rightTime = right.getTime();
|
|
48
|
-
switch (operator) {
|
|
49
|
-
case `<`:
|
|
50
|
-
return leftTime < rightTime;
|
|
51
|
-
case `<=`:
|
|
52
|
-
return leftTime <= rightTime;
|
|
53
|
-
case `>`:
|
|
54
|
-
return leftTime > rightTime;
|
|
55
|
-
case `>=`:
|
|
56
|
-
return leftTime >= rightTime;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (typeof left === typeof right) {
|
|
60
|
-
switch (operator) {
|
|
61
|
-
case `<`:
|
|
62
|
-
return left < right;
|
|
63
|
-
case `<=`:
|
|
64
|
-
return left <= right;
|
|
65
|
-
case `>`:
|
|
66
|
-
return left > right;
|
|
67
|
-
case `>=`:
|
|
68
|
-
return left >= right;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
throw new Error(
|
|
72
|
-
`Cannot compare incompatible types: ${typeof left} and ${typeof right}`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
function convertLikeToRegex(pattern) {
|
|
76
|
-
let finalPattern = ``;
|
|
77
|
-
let i = 0;
|
|
78
|
-
while (i < pattern.length) {
|
|
79
|
-
const char = pattern[i];
|
|
80
|
-
if (char === `\\` && i + 1 < pattern.length) {
|
|
81
|
-
finalPattern += pattern[i + 1];
|
|
82
|
-
i += 2;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
switch (char) {
|
|
86
|
-
case `%`:
|
|
87
|
-
finalPattern += `.*`;
|
|
88
|
-
break;
|
|
89
|
-
case `_`:
|
|
90
|
-
finalPattern += `.`;
|
|
91
|
-
break;
|
|
92
|
-
// Handle regex special characters
|
|
93
|
-
case `.`:
|
|
94
|
-
case `^`:
|
|
95
|
-
case `$`:
|
|
96
|
-
case `*`:
|
|
97
|
-
case `+`:
|
|
98
|
-
case `?`:
|
|
99
|
-
case `(`:
|
|
100
|
-
case `)`:
|
|
101
|
-
case `[`:
|
|
102
|
-
case `]`:
|
|
103
|
-
case `{`:
|
|
104
|
-
case `}`:
|
|
105
|
-
case `|`:
|
|
106
|
-
case `/`:
|
|
107
|
-
finalPattern += `\\` + char;
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
finalPattern += char;
|
|
111
|
-
}
|
|
112
|
-
i++;
|
|
113
|
-
}
|
|
114
|
-
return finalPattern;
|
|
115
|
-
}
|
|
116
|
-
function isValueInArray(value, array, caseInsensitive = false) {
|
|
117
|
-
if (array.includes(value)) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
if (value === null || value === void 0) {
|
|
121
|
-
return array.some((item) => item === null || item === void 0);
|
|
122
|
-
}
|
|
123
|
-
if (typeof value === `number` || typeof value === `string`) {
|
|
124
|
-
return array.some((item) => {
|
|
125
|
-
if (typeof item === typeof value) {
|
|
126
|
-
if (typeof value === `string` && caseInsensitive) {
|
|
127
|
-
return value.toLowerCase() === item.toLowerCase();
|
|
128
|
-
}
|
|
129
|
-
return item === value;
|
|
130
|
-
}
|
|
131
|
-
if ((typeof item === `number` || typeof item === `string`) && (typeof value === `number` || typeof value === `string`)) {
|
|
132
|
-
return String(item) === String(value);
|
|
133
|
-
}
|
|
134
|
-
return false;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
if (typeof value === `object`) {
|
|
138
|
-
const valueStr = JSON.stringify(value);
|
|
139
|
-
return array.some((item) => {
|
|
140
|
-
if (typeof item === `object` && item !== null) {
|
|
141
|
-
return JSON.stringify(item) === valueStr;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
exports.compareValues = compareValues;
|
|
149
|
-
exports.convertLikeToRegex = convertLikeToRegex;
|
|
150
|
-
exports.isAggregateFunctionCall = isAggregateFunctionCall;
|
|
151
|
-
exports.isComparable = isComparable;
|
|
152
|
-
exports.isOrderIndexFunctionCall = isOrderIndexFunctionCall;
|
|
153
|
-
exports.isValueInArray = isValueInArray;
|
|
154
|
-
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../../src/query/utils.ts"],"sourcesContent":["/**\n * Helper function to determine if an object is a function call with an aggregate function\n */\nexport function isAggregateFunctionCall(obj: any): boolean {\n if (!obj || typeof obj !== `object`) return false\n\n const aggregateFunctions = [\n `SUM`,\n `COUNT`,\n `AVG`,\n `MIN`,\n `MAX`,\n `MEDIAN`,\n `MODE`,\n ]\n const keys = Object.keys(obj)\n\n return keys.length === 1 && aggregateFunctions.includes(keys[0]!)\n}\n\n/**\n * Helper function to determine if an object is an ORDER_INDEX function call\n */\nexport function isOrderIndexFunctionCall(obj: any): boolean {\n if (!obj || typeof obj !== `object`) return false\n\n const keys = Object.keys(obj)\n return keys.length === 1 && keys[0] === `ORDER_INDEX`\n}\n\n/**\n * Type guard to check if a value is comparable (can be used with <, >, <=, >= operators)\n * @param value The value to check\n * @returns True if the value is comparable\n */\nexport function isComparable(\n value: unknown\n): value is number | string | Date | boolean {\n return (\n typeof value === `number` ||\n typeof value === `string` ||\n typeof value === `boolean` ||\n value instanceof Date\n )\n}\n\n/**\n * Performs a comparison between two values, ensuring they are of compatible types\n * @param left The left operand\n * @param right The right operand\n * @param operator The comparison operator\n * @returns The result of the comparison\n * @throws Error if the values are not comparable\n */\nexport function compareValues(\n left: unknown,\n right: unknown,\n operator: `<` | `<=` | `>` | `>=`\n): boolean {\n // First check if both values are comparable\n if (!isComparable(left) || !isComparable(right)) {\n throw new Error(\n `Cannot compare non-comparable values: ${typeof left} and ${typeof right}`\n )\n }\n\n // If they're different types but both are strings or numbers, convert to strings\n if (\n typeof left !== typeof right &&\n (typeof left === `string` || typeof left === `number`) &&\n (typeof right === `string` || typeof right === `number`)\n ) {\n // Convert to strings for comparison (follows JavaScript's coercion rules)\n const leftStr = String(left)\n const rightStr = String(right)\n\n switch (operator) {\n case `<`:\n return leftStr < rightStr\n case `<=`:\n return leftStr <= rightStr\n case `>`:\n return leftStr > rightStr\n case `>=`:\n return leftStr >= rightStr\n }\n }\n\n // For Date objects, convert to timestamps\n if (left instanceof Date && right instanceof Date) {\n const leftTime = left.getTime()\n const rightTime = right.getTime()\n\n switch (operator) {\n case `<`:\n return leftTime < rightTime\n case `<=`:\n return leftTime <= rightTime\n case `>`:\n return leftTime > rightTime\n case `>=`:\n return leftTime >= rightTime\n }\n }\n\n // For other cases where types match\n if (typeof left === typeof right) {\n switch (operator) {\n case `<`:\n return left < right\n case `<=`:\n return left <= right\n case `>`:\n return left > right\n case `>=`:\n return left >= right\n }\n }\n\n // If we get here, it means the values are technically comparable but not compatible\n throw new Error(\n `Cannot compare incompatible types: ${typeof left} and ${typeof right}`\n )\n}\n\n/**\n * Converts a SQL LIKE pattern to a JavaScript regex pattern\n * @param pattern The SQL LIKE pattern to convert\n * @returns A regex-compatible pattern string\n */\nexport function convertLikeToRegex(pattern: string): string {\n let finalPattern = ``\n let i = 0\n\n while (i < pattern.length) {\n const char = pattern[i]\n\n // Handle escape character\n if (char === `\\\\` && i + 1 < pattern.length) {\n // Add the next character as a literal (escaped)\n finalPattern += pattern[i + 1]\n i += 2 // Skip both the escape and the escaped character\n continue\n }\n\n // Handle SQL LIKE special characters\n switch (char) {\n case `%`:\n // % matches any sequence of characters (including empty)\n finalPattern += `.*`\n break\n case `_`:\n // _ matches any single character\n finalPattern += `.`\n break\n // Handle regex special characters\n case `.`:\n case `^`:\n case `$`:\n case `*`:\n case `+`:\n case `?`:\n case `(`:\n case `)`:\n case `[`:\n case `]`:\n case `{`:\n case `}`:\n case `|`:\n case `/`:\n // Escape regex special characters\n finalPattern += `\\\\` + char\n break\n default:\n // Regular character, just add it\n finalPattern += char\n }\n\n i++\n }\n\n return finalPattern\n}\n\n/**\n * Helper function to check if a value is in an array, with special handling for various types\n * @param value The value to check for\n * @param array The array to search in\n * @param caseInsensitive Optional flag to enable case-insensitive matching for strings (default: false)\n * @returns True if the value is found in the array\n */\nexport function isValueInArray(\n value: unknown,\n array: Array<unknown>,\n caseInsensitive: boolean = false\n): boolean {\n // Direct inclusion check first (fastest path)\n if (array.includes(value)) {\n return true\n }\n\n // Handle null/undefined\n if (value === null || value === undefined) {\n return array.some((item) => item === null || item === undefined)\n }\n\n // Handle numbers and strings with type coercion\n if (typeof value === `number` || typeof value === `string`) {\n return array.some((item) => {\n // Same type, direct comparison\n if (typeof item === typeof value) {\n if (typeof value === `string` && caseInsensitive) {\n // Case-insensitive comparison for strings (only if explicitly enabled)\n return value.toLowerCase() === (item as string).toLowerCase()\n }\n return item === value\n }\n\n // Different types, try coercion for number/string\n if (\n (typeof item === `number` || typeof item === `string`) &&\n (typeof value === `number` || typeof value === `string`)\n ) {\n // Convert both to strings for comparison\n return String(item) === String(value)\n }\n\n return false\n })\n }\n\n // Handle objects/arrays by comparing stringified versions\n if (typeof value === `object`) {\n const valueStr = JSON.stringify(value)\n return array.some((item) => {\n if (typeof item === `object` && item !== null) {\n return JSON.stringify(item) === valueStr\n }\n return false\n })\n }\n\n // Fallback\n return false\n}\n"],"names":[],"mappings":";;AAGO,SAAS,wBAAwB,KAAmB;AACzD,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAiB,QAAA;AAE5C,QAAM,qBAAqB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACM,QAAA,OAAO,OAAO,KAAK,GAAG;AAE5B,SAAO,KAAK,WAAW,KAAK,mBAAmB,SAAS,KAAK,CAAC,CAAE;AAClE;AAKO,SAAS,yBAAyB,KAAmB;AAC1D,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAiB,QAAA;AAEtC,QAAA,OAAO,OAAO,KAAK,GAAG;AAC5B,SAAO,KAAK,WAAW,KAAK,KAAK,CAAC,MAAM;AAC1C;AAOO,SAAS,aACd,OAC2C;AAEzC,SAAA,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,aACjB,iBAAiB;AAErB;AAUgB,SAAA,cACd,MACA,OACA,UACS;AAET,MAAI,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,KAAK,GAAG;AAC/C,UAAM,IAAI;AAAA,MACR,yCAAyC,OAAO,IAAI,QAAQ,OAAO,KAAK;AAAA,IAC1E;AAAA,EAAA;AAIF,MACE,OAAO,SAAS,OAAO,UACtB,OAAO,SAAS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II,SAAA;AACT;;;;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper function to determine if an object is a function call with an aggregate function
|
|
3
|
-
*/
|
|
4
|
-
export declare function isAggregateFunctionCall(obj: any): boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Helper function to determine if an object is an ORDER_INDEX function call
|
|
7
|
-
*/
|
|
8
|
-
export declare function isOrderIndexFunctionCall(obj: any): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Type guard to check if a value is comparable (can be used with <, >, <=, >= operators)
|
|
11
|
-
* @param value The value to check
|
|
12
|
-
* @returns True if the value is comparable
|
|
13
|
-
*/
|
|
14
|
-
export declare function isComparable(value: unknown): value is number | string | Date | boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Performs a comparison between two values, ensuring they are of compatible types
|
|
17
|
-
* @param left The left operand
|
|
18
|
-
* @param right The right operand
|
|
19
|
-
* @param operator The comparison operator
|
|
20
|
-
* @returns The result of the comparison
|
|
21
|
-
* @throws Error if the values are not comparable
|
|
22
|
-
*/
|
|
23
|
-
export declare function compareValues(left: unknown, right: unknown, operator: `<` | `<=` | `>` | `>=`): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Converts a SQL LIKE pattern to a JavaScript regex pattern
|
|
26
|
-
* @param pattern The SQL LIKE pattern to convert
|
|
27
|
-
* @returns A regex-compatible pattern string
|
|
28
|
-
*/
|
|
29
|
-
export declare function convertLikeToRegex(pattern: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Helper function to check if a value is in an array, with special handling for various types
|
|
32
|
-
* @param value The value to check for
|
|
33
|
-
* @param array The array to search in
|
|
34
|
-
* @param caseInsensitive Optional flag to enable case-insensitive matching for strings (default: false)
|
|
35
|
-
* @returns True if the value is found in the array
|
|
36
|
-
*/
|
|
37
|
-
export declare function isValueInArray(value: unknown, array: Array<unknown>, caseInsensitive?: boolean): boolean;
|
package/dist/cjs/utils.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function getLockedObjects() {
|
|
4
|
-
return /* @__PURE__ */ new Set();
|
|
5
|
-
}
|
|
6
|
-
let globalVersion = 0;
|
|
7
|
-
function getGlobalVersion() {
|
|
8
|
-
return globalVersion;
|
|
9
|
-
}
|
|
10
|
-
function advanceGlobalVersion() {
|
|
11
|
-
console.log(`==== advancing global version`, globalVersion + 1);
|
|
12
|
-
return globalVersion++;
|
|
13
|
-
}
|
|
14
|
-
exports.advanceGlobalVersion = advanceGlobalVersion;
|
|
15
|
-
exports.getGlobalVersion = getGlobalVersion;
|
|
16
|
-
exports.getLockedObjects = getLockedObjects;
|
|
17
|
-
//# sourceMappingURL=utils.cjs.map
|
package/dist/cjs/utils.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["export function getLockedObjects(): Set<string> {\n // Stub implementation that returns an empty Set\n return new Set()\n}\n\nlet globalVersion = 0\n\nexport function getGlobalVersion(): number {\n return globalVersion\n}\n\nexport function advanceGlobalVersion(): number {\n console.log(`==== advancing global version`, globalVersion + 1)\n return globalVersion++\n}\n"],"names":[],"mappings":";;AAAO,SAAS,mBAAgC;AAE9C,6BAAW,IAAI;AACjB;AAEA,IAAI,gBAAgB;AAEb,SAAS,mBAA2B;AAClC,SAAA;AACT;AAEO,SAAS,uBAA+B;AACrC,UAAA,IAAI,iCAAiC,gBAAgB,CAAC;AACvD,SAAA;AACT;;;;"}
|
package/dist/cjs/utils.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Collection } from '../collection.js';
|
|
2
|
-
import { QueryBuilder } from './query-builder.js';
|
|
3
|
-
import { Context, Schema } from './types.js';
|
|
4
|
-
export declare function compileQuery<TContext extends Context<Schema>>(queryBuilder: QueryBuilder<TContext>): CompiledQuery<((TContext["result"] extends object ? TContext["result"] : TContext["hasJoin"] extends true ? TContext["schema"] : TContext["default"] extends keyof TContext["schema"] ? TContext["schema"][TContext["default"]] : never) extends infer T ? { [K in keyof T]: (TContext["result"] extends object ? TContext["result"] : TContext["hasJoin"] extends true ? TContext["schema"] : TContext["default"] extends keyof TContext["schema"] ? TContext["schema"][TContext["default"]] : never)[K]; } : never) & {
|
|
5
|
-
_key?: string | number;
|
|
6
|
-
}>;
|
|
7
|
-
export declare class CompiledQuery<TResults extends object = Record<string, unknown>> {
|
|
8
|
-
private graph;
|
|
9
|
-
private inputs;
|
|
10
|
-
private inputCollections;
|
|
11
|
-
private resultCollection;
|
|
12
|
-
state: `compiled` | `running` | `stopped`;
|
|
13
|
-
private unsubscribeCallbacks;
|
|
14
|
-
constructor(queryBuilder: QueryBuilder<Context<Schema>>);
|
|
15
|
-
get results(): Collection<TResults, string | number, {}>;
|
|
16
|
-
private sendChangesToInput;
|
|
17
|
-
private runGraph;
|
|
18
|
-
start(): () => void;
|
|
19
|
-
stop(): void;
|
|
20
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { D2, MultiSet, output } from "@electric-sql/d2mini";
|
|
2
|
-
import { createCollection } from "../collection.js";
|
|
3
|
-
import { compileQueryPipeline } from "./pipeline-compiler.js";
|
|
4
|
-
function compileQuery(queryBuilder) {
|
|
5
|
-
return new CompiledQuery(queryBuilder);
|
|
6
|
-
}
|
|
7
|
-
class CompiledQuery {
|
|
8
|
-
constructor(queryBuilder) {
|
|
9
|
-
this.state = `compiled`;
|
|
10
|
-
this.unsubscribeCallbacks = [];
|
|
11
|
-
const query = queryBuilder._query;
|
|
12
|
-
const collections = query.collections;
|
|
13
|
-
if (!collections) {
|
|
14
|
-
throw new Error(`No collections provided`);
|
|
15
|
-
}
|
|
16
|
-
this.inputCollections = collections;
|
|
17
|
-
const graph = new D2();
|
|
18
|
-
const inputs = Object.fromEntries(
|
|
19
|
-
Object.entries(collections).map(([key]) => [key, graph.newInput()])
|
|
20
|
-
);
|
|
21
|
-
const sync = ({
|
|
22
|
-
begin,
|
|
23
|
-
write,
|
|
24
|
-
commit,
|
|
25
|
-
collection
|
|
26
|
-
}) => {
|
|
27
|
-
compileQueryPipeline(
|
|
28
|
-
query,
|
|
29
|
-
inputs
|
|
30
|
-
).pipe(
|
|
31
|
-
output((data) => {
|
|
32
|
-
begin();
|
|
33
|
-
data.getInner().reduce((acc, [[key, value], multiplicity]) => {
|
|
34
|
-
const changes = acc.get(key) || {
|
|
35
|
-
deletes: 0,
|
|
36
|
-
inserts: 0,
|
|
37
|
-
value
|
|
38
|
-
};
|
|
39
|
-
if (multiplicity < 0) {
|
|
40
|
-
changes.deletes += Math.abs(multiplicity);
|
|
41
|
-
} else if (multiplicity > 0) {
|
|
42
|
-
changes.inserts += multiplicity;
|
|
43
|
-
changes.value = value;
|
|
44
|
-
}
|
|
45
|
-
acc.set(key, changes);
|
|
46
|
-
return acc;
|
|
47
|
-
}, /* @__PURE__ */ new Map()).forEach((changes, rawKey) => {
|
|
48
|
-
const { deletes, inserts, value } = changes;
|
|
49
|
-
const valueWithKey = { ...value, _key: rawKey };
|
|
50
|
-
if (inserts && deletes === 0) {
|
|
51
|
-
write({
|
|
52
|
-
value: valueWithKey,
|
|
53
|
-
type: `insert`
|
|
54
|
-
});
|
|
55
|
-
} else if (
|
|
56
|
-
// Insert & update(s) (updates are a delete & insert)
|
|
57
|
-
inserts > deletes || // Just update(s) but the item is already in the collection (so
|
|
58
|
-
// was inserted previously).
|
|
59
|
-
inserts === deletes && collection.has(valueWithKey._key)
|
|
60
|
-
) {
|
|
61
|
-
write({
|
|
62
|
-
value: valueWithKey,
|
|
63
|
-
type: `update`
|
|
64
|
-
});
|
|
65
|
-
} else if (deletes > 0) {
|
|
66
|
-
write({
|
|
67
|
-
value: valueWithKey,
|
|
68
|
-
type: `delete`
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
throw new Error(
|
|
72
|
-
`This should never happen ${JSON.stringify(changes)}`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
commit();
|
|
77
|
-
})
|
|
78
|
-
);
|
|
79
|
-
graph.finalize();
|
|
80
|
-
};
|
|
81
|
-
this.graph = graph;
|
|
82
|
-
this.inputs = inputs;
|
|
83
|
-
const compare = query.orderBy ? (val1, val2) => {
|
|
84
|
-
const x = val1;
|
|
85
|
-
const y = val2;
|
|
86
|
-
if (x._orderByIndex < y._orderByIndex) {
|
|
87
|
-
return -1;
|
|
88
|
-
} else if (x._orderByIndex > y._orderByIndex) {
|
|
89
|
-
return 1;
|
|
90
|
-
} else {
|
|
91
|
-
return 0;
|
|
92
|
-
}
|
|
93
|
-
} : void 0;
|
|
94
|
-
this.resultCollection = createCollection({
|
|
95
|
-
getKey: (val) => {
|
|
96
|
-
return val._key;
|
|
97
|
-
},
|
|
98
|
-
gcTime: 0,
|
|
99
|
-
startSync: true,
|
|
100
|
-
compare,
|
|
101
|
-
sync: {
|
|
102
|
-
sync
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
get results() {
|
|
107
|
-
return this.resultCollection;
|
|
108
|
-
}
|
|
109
|
-
sendChangesToInput(inputKey, changes, getKey) {
|
|
110
|
-
const input = this.inputs[inputKey];
|
|
111
|
-
const multiSetArray = [];
|
|
112
|
-
for (const change of changes) {
|
|
113
|
-
const key = getKey(change.value);
|
|
114
|
-
if (change.type === `insert`) {
|
|
115
|
-
multiSetArray.push([[key, change.value], 1]);
|
|
116
|
-
} else if (change.type === `update`) {
|
|
117
|
-
multiSetArray.push([[key, change.previousValue], -1]);
|
|
118
|
-
multiSetArray.push([[key, change.value], 1]);
|
|
119
|
-
} else {
|
|
120
|
-
multiSetArray.push([[key, change.value], -1]);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
input.sendData(new MultiSet(multiSetArray));
|
|
124
|
-
}
|
|
125
|
-
runGraph() {
|
|
126
|
-
this.graph.run();
|
|
127
|
-
}
|
|
128
|
-
start() {
|
|
129
|
-
if (this.state === `running`) {
|
|
130
|
-
throw new Error(`Query is already running`);
|
|
131
|
-
} else if (this.state === `stopped`) {
|
|
132
|
-
throw new Error(`Query is stopped`);
|
|
133
|
-
}
|
|
134
|
-
Object.entries(this.inputCollections).forEach(([key, collection]) => {
|
|
135
|
-
const unsubscribe = collection.subscribeChanges(
|
|
136
|
-
(changes) => {
|
|
137
|
-
this.sendChangesToInput(key, changes, collection.config.getKey);
|
|
138
|
-
this.runGraph();
|
|
139
|
-
},
|
|
140
|
-
{ includeInitialState: true }
|
|
141
|
-
);
|
|
142
|
-
this.unsubscribeCallbacks.push(unsubscribe);
|
|
143
|
-
});
|
|
144
|
-
this.runGraph();
|
|
145
|
-
this.state = `running`;
|
|
146
|
-
return () => {
|
|
147
|
-
this.stop();
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
stop() {
|
|
151
|
-
this.unsubscribeCallbacks.forEach((unsubscribe) => unsubscribe());
|
|
152
|
-
this.unsubscribeCallbacks = [];
|
|
153
|
-
this.state = `stopped`;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
export {
|
|
157
|
-
CompiledQuery,
|
|
158
|
-
compileQuery
|
|
159
|
-
};
|
|
160
|
-
//# sourceMappingURL=compiled-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compiled-query.js","sources":["../../../src/query/compiled-query.ts"],"sourcesContent":["import { D2, MultiSet, output } from \"@electric-sql/d2mini\"\nimport { createCollection } from \"../collection.js\"\nimport { compileQueryPipeline } from \"./pipeline-compiler.js\"\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\"\nimport type { Collection } from \"../collection.js\"\nimport type { ChangeMessage, ResolveType, SyncConfig } from \"../types.js\"\nimport type {\n IStreamBuilder,\n MultiSetArray,\n RootStreamBuilder,\n} from \"@electric-sql/d2mini\"\nimport type { QueryBuilder, ResultsFromContext } from \"./query-builder.js\"\nimport type { Context, Schema } from \"./types.js\"\n\nexport function compileQuery<TContext extends Context<Schema>>(\n queryBuilder: QueryBuilder<TContext>\n) {\n return new CompiledQuery<\n ResultsFromContext<TContext> & { _key?: string | number }\n >(queryBuilder)\n}\n\nexport class CompiledQuery<TResults extends object = Record<string, unknown>> {\n private graph: D2\n private inputs: Record<string, RootStreamBuilder<any>>\n private inputCollections: Record<string, Collection<any>>\n private resultCollection: Collection<TResults>\n public state: `compiled` | `running` | `stopped` = `compiled`\n private unsubscribeCallbacks: Array<() => void> = []\n\n constructor(queryBuilder: QueryBuilder<Context<Schema>>) {\n const query = queryBuilder._query\n const collections = query.collections\n\n if (!collections) {\n throw new Error(`No collections provided`)\n }\n\n this.inputCollections = collections\n\n const graph = new D2()\n const inputs = Object.fromEntries(\n Object.entries(collections).map(([key]) => [key, graph.newInput<any>()])\n )\n\n // Use TResults directly to ensure type compatibility\n const sync: SyncConfig<TResults>[`sync`] = ({\n begin,\n write,\n commit,\n collection,\n }) => {\n compileQueryPipeline<IStreamBuilder<[unknown, TResults]>>(\n query,\n inputs\n ).pipe(\n output((data) => {\n begin()\n data\n .getInner()\n .reduce((acc, [[key, value], multiplicity]) => {\n const changes = acc.get(key) || {\n deletes: 0,\n inserts: 0,\n value,\n }\n if (multiplicity < 0) {\n changes.deletes += Math.abs(multiplicity)\n } else if (multiplicity > 0) {\n changes.inserts += multiplicity\n changes.value = value\n }\n acc.set(key, changes)\n return acc\n }, new Map<unknown, { deletes: number; inserts: number; value: TResults }>())\n .forEach((changes, rawKey) => {\n const { deletes, inserts, value } = changes\n const valueWithKey = { ...value, _key: rawKey }\n\n // Simple singular insert.\n if (inserts && deletes === 0) {\n write({\n value: valueWithKey,\n type: `insert`,\n })\n } else if (\n // Insert & update(s) (updates are a delete & insert)\n inserts > deletes ||\n // Just update(s) but the item is already in the collection (so\n // was inserted previously).\n (inserts === deletes &&\n collection.has(valueWithKey._key as string | number))\n ) {\n write({\n value: valueWithKey,\n type: `update`,\n })\n // Only delete is left as an option\n } else if (deletes > 0) {\n write({\n value: valueWithKey,\n type: `delete`,\n })\n } else {\n throw new Error(\n `This should never happen ${JSON.stringify(changes)}`\n )\n }\n })\n commit()\n })\n )\n graph.finalize()\n }\n\n this.graph = graph\n this.inputs = inputs\n\n const compare = query.orderBy\n ? (\n val1: ResolveType<\n TResults,\n StandardSchemaV1,\n Record<string, unknown>\n >,\n val2: ResolveType<TResults, StandardSchemaV1, Record<string, unknown>>\n ): number => {\n // The query builder always adds an _orderByIndex property if the results are ordered\n const x = val1 as TResults & { _orderByIndex: number }\n const y = val2 as TResults & { _orderByIndex: number }\n if (x._orderByIndex < y._orderByIndex) {\n return -1\n } else if (x._orderByIndex > y._orderByIndex) {\n return 1\n } else {\n return 0\n }\n }\n : undefined\n\n this.resultCollection = createCollection<TResults>({\n getKey: (val: unknown) => {\n return (val as any)._key\n },\n gcTime: 0,\n startSync: true,\n compare,\n sync: {\n sync: sync as unknown as (params: {\n collection: Collection<\n ResolveType<TResults, never, Record<string, unknown>>,\n string | number,\n {}\n >\n begin: () => void\n write: (\n message: Omit<\n ChangeMessage<\n ResolveType<TResults, never, Record<string, unknown>>,\n string | number\n >,\n `key`\n >\n ) => void\n commit: () => void\n }) => void,\n },\n }) as unknown as Collection<TResults, string | number, {}>\n }\n\n get results() {\n return this.resultCollection\n }\n\n private sendChangesToInput(\n inputKey: string,\n changes: Array<ChangeMessage>,\n getKey: (item: ChangeMessage[`value`]) => any\n ) {\n const input = this.inputs[inputKey]!\n const multiSetArray: MultiSetArray<unknown> = []\n for (const change of changes) {\n const key = getKey(change.value)\n if (change.type === `insert`) {\n multiSetArray.push([[key, change.value], 1])\n } else if (change.type === `update`) {\n multiSetArray.push([[key, change.previousValue], -1])\n multiSetArray.push([[key, change.value], 1])\n } else {\n // change.type === `delete`\n multiSetArray.push([[key, change.value], -1])\n }\n }\n input.sendData(new MultiSet(multiSetArray))\n }\n\n private runGraph() {\n this.graph.run()\n }\n\n start() {\n if (this.state === `running`) {\n throw new Error(`Query is already running`)\n } else if (this.state === `stopped`) {\n throw new Error(`Query is stopped`)\n }\n\n // Subscribe to changes\n Object.entries(this.inputCollections).forEach(([key, collection]) => {\n const unsubscribe = collection.subscribeChanges(\n (changes) => {\n this.sendChangesToInput(key, changes, collection.config.getKey)\n this.runGraph()\n },\n { includeInitialState: true }\n )\n\n this.unsubscribeCallbacks.push(unsubscribe)\n })\n\n this.runGraph()\n\n this.state = `running`\n return () => {\n this.stop()\n }\n }\n\n stop() {\n this.unsubscribeCallbacks.forEach((unsubscribe) => unsubscribe())\n this.unsubscribeCallbacks = []\n this.state = `stopped`\n }\n}\n"],"names":[],"mappings":";;;AAcO,SAAS,aACd,cACA;AACO,SAAA,IAAI,cAET,YAAY;AAChB;AAEO,MAAM,cAAiE;AAAA,EAQ5E,YAAY,cAA6C;AAHzD,SAAO,QAA4C;AACnD,SAAQ,uBAA0C,CAAC;AAGjD,UAAM,QAAQ,aAAa;AAC3B,UAAM,cAAc,MAAM;AAE1B,QAAI,CAAC,aAAa;AACV,YAAA,IAAI,MAAM,yBAAyB;AAAA,IAAA;AAG3C,SAAK,mBAAmB;AAElB,UAAA,QAAQ,IAAI,GAAG;AACrB,UAAM,SAAS,OAAO;AAAA,MACpB,OAAO,QAAQ,WAAW,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,MAAM,SAAA,CAAe,CAAC;AAAA,IACzE;AAGA,UAAM,OAAqC,CAAC;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,MACI;AACJ;AAAA,QACE;AAAA,QACA;AAAA,MAAA,EACA;AAAA,QACA,OAAO,CAAC,SAAS;AACT,gBAAA;AAEH,eAAA,WACA,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,GAAG,YAAY,MAAM;AAC7C,kBAAM,UAAU,IAAI,IAAI,GAAG,KAAK;AAAA,cAC9B,SAAS;AAAA,cACT,SAAS;AAAA,cACT;AAAA,YACF;AACA,gBAAI,eAAe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E,qBAAqB,KAAK;AAAA,MAC9B;AAEK,WAAA,qBAAqB,KAAK,WAAW;AAAA,IAAA,CAC3C;AAED,SAAK,SAAS;AAEd,SAAK,QAAQ;AACb,WAAO,MAAM;AACX,WAAK,KAAK;AAAA,IACZ;AAAA,EAAA;AAAA,EAGF,OAAO;AACL,SAAK,qBAAqB,QAAQ,CAAC,gBAAgB,aAAa;AAChE,SAAK,uBAAuB,CAAC;AAC7B,SAAK,QAAQ;AAAA,EAAA;AAEjB;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Comparator, Condition, ConditionOperand, Where } from './schema.js';
|
|
2
|
-
import { NamespacedRow } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Evaluates a Where clause (which is always an array of conditions and/or callbacks) against a nested row structure
|
|
5
|
-
*/
|
|
6
|
-
export declare function evaluateWhereOnNamespacedRow(namespacedRow: NamespacedRow, where: Where, mainTableAlias?: string, joinedTableAlias?: string): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Evaluates a condition against a nested row structure
|
|
9
|
-
*/
|
|
10
|
-
export declare function evaluateConditionOnNamespacedRow(namespacedRow: NamespacedRow, condition: Condition, mainTableAlias?: string, joinedTableAlias?: string): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Evaluates a simple condition against a nested row structure
|
|
13
|
-
*/
|
|
14
|
-
export declare function evaluateSimpleConditionOnNamespacedRow(namespacedRow: Record<string, unknown>, left: ConditionOperand, comparator: Comparator, right: ConditionOperand, mainTableAlias?: string, joinedTableAlias?: string): boolean;
|