@tanstack/db 0.1.11 → 0.2.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/dist/cjs/errors.cjs +18 -6
- package/dist/cjs/errors.cjs.map +1 -1
- package/dist/cjs/errors.d.cts +9 -3
- package/dist/cjs/index.cjs +3 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/query/builder/functions.cjs +4 -1
- package/dist/cjs/query/builder/functions.cjs.map +1 -1
- package/dist/cjs/query/builder/functions.d.cts +38 -21
- package/dist/cjs/query/builder/index.cjs +25 -16
- package/dist/cjs/query/builder/index.cjs.map +1 -1
- package/dist/cjs/query/builder/index.d.cts +8 -8
- package/dist/cjs/query/builder/ref-proxy.cjs +12 -8
- package/dist/cjs/query/builder/ref-proxy.cjs.map +1 -1
- package/dist/cjs/query/builder/ref-proxy.d.cts +2 -1
- package/dist/cjs/query/builder/types.d.cts +493 -28
- package/dist/cjs/query/compiler/evaluators.cjs +29 -0
- package/dist/cjs/query/compiler/evaluators.cjs.map +1 -1
- package/dist/cjs/query/compiler/group-by.cjs +4 -2
- package/dist/cjs/query/compiler/group-by.cjs.map +1 -1
- package/dist/cjs/query/compiler/index.cjs +13 -4
- package/dist/cjs/query/compiler/index.cjs.map +1 -1
- package/dist/cjs/query/compiler/joins.cjs +70 -61
- package/dist/cjs/query/compiler/joins.cjs.map +1 -1
- package/dist/cjs/query/compiler/select.cjs +131 -42
- package/dist/cjs/query/compiler/select.cjs.map +1 -1
- package/dist/cjs/query/compiler/select.d.cts +1 -5
- package/dist/cjs/query/ir.cjs +4 -0
- package/dist/cjs/query/ir.cjs.map +1 -1
- package/dist/cjs/query/ir.d.cts +6 -1
- package/dist/cjs/query/optimizer.cjs +61 -20
- package/dist/cjs/query/optimizer.cjs.map +1 -1
- package/dist/esm/errors.d.ts +9 -3
- package/dist/esm/errors.js +18 -6
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/query/builder/functions.d.ts +38 -21
- package/dist/esm/query/builder/functions.js +4 -1
- package/dist/esm/query/builder/functions.js.map +1 -1
- package/dist/esm/query/builder/index.d.ts +8 -8
- package/dist/esm/query/builder/index.js +27 -18
- package/dist/esm/query/builder/index.js.map +1 -1
- package/dist/esm/query/builder/ref-proxy.d.ts +2 -1
- package/dist/esm/query/builder/ref-proxy.js +12 -8
- package/dist/esm/query/builder/ref-proxy.js.map +1 -1
- package/dist/esm/query/builder/types.d.ts +493 -28
- package/dist/esm/query/compiler/evaluators.js +29 -0
- package/dist/esm/query/compiler/evaluators.js.map +1 -1
- package/dist/esm/query/compiler/group-by.js +4 -2
- package/dist/esm/query/compiler/group-by.js.map +1 -1
- package/dist/esm/query/compiler/index.js +15 -6
- package/dist/esm/query/compiler/index.js.map +1 -1
- package/dist/esm/query/compiler/joins.js +71 -62
- package/dist/esm/query/compiler/joins.js.map +1 -1
- package/dist/esm/query/compiler/select.d.ts +1 -5
- package/dist/esm/query/compiler/select.js +131 -42
- package/dist/esm/query/compiler/select.js.map +1 -1
- package/dist/esm/query/ir.d.ts +6 -1
- package/dist/esm/query/ir.js +4 -0
- package/dist/esm/query/ir.js.map +1 -1
- package/dist/esm/query/optimizer.js +62 -21
- package/dist/esm/query/optimizer.js.map +1 -1
- package/package.json +2 -2
- package/src/errors.ts +17 -10
- package/src/query/builder/functions.ts +176 -108
- package/src/query/builder/index.ts +68 -48
- package/src/query/builder/ref-proxy.ts +14 -20
- package/src/query/builder/types.ts +622 -110
- package/src/query/compiler/evaluators.ts +30 -0
- package/src/query/compiler/group-by.ts +6 -1
- package/src/query/compiler/index.ts +23 -6
- package/src/query/compiler/joins.ts +132 -104
- package/src/query/compiler/select.ts +206 -113
- package/src/query/ir.ts +14 -1
- package/src/query/optimizer.ts +131 -59
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderByDirection, QueryIR } from '../ir.js';
|
|
2
|
-
import { Context, GroupByCallback, JoinOnCallback,
|
|
2
|
+
import { Context, GroupByCallback, JoinOnCallback, MergeContextForJoinCallback, MergeContextWithJoinType, OrderByCallback, OrderByOptions, RefsForContext, ResultTypeFromSelect, SchemaFromSource, SelectObject, Source, WhereCallback, WithResult } from './types.js';
|
|
3
3
|
export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
4
4
|
private readonly query;
|
|
5
5
|
constructor(query?: Partial<QueryIR>);
|
|
@@ -59,7 +59,7 @@ export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
|
59
59
|
* .from({ activeUsers })
|
|
60
60
|
* .join({ p: postsCollection }, ({u, p}) => eq(u.id, p.userId))
|
|
61
61
|
*/
|
|
62
|
-
join<TSource extends Source, TJoinType extends `inner` | `left` | `right` | `full` = `left`>(source: TSource, onCallback: JoinOnCallback<
|
|
62
|
+
join<TSource extends Source, TJoinType extends `inner` | `left` | `right` | `full` = `left`>(source: TSource, onCallback: JoinOnCallback<MergeContextForJoinCallback<TContext, SchemaFromSource<TSource>>>, type?: TJoinType): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, TJoinType>>;
|
|
63
63
|
/**
|
|
64
64
|
* Perform a LEFT JOIN with another table or subquery
|
|
65
65
|
*
|
|
@@ -75,7 +75,7 @@ export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
|
75
75
|
* .leftJoin({ posts: postsCollection }, ({users, posts}) => eq(users.id, posts.userId))
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
|
-
leftJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<
|
|
78
|
+
leftJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<MergeContextForJoinCallback<TContext, SchemaFromSource<TSource>>>): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, `left`>>;
|
|
79
79
|
/**
|
|
80
80
|
* Perform a RIGHT JOIN with another table or subquery
|
|
81
81
|
*
|
|
@@ -91,7 +91,7 @@ export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
|
91
91
|
* .rightJoin({ posts: postsCollection }, ({users, posts}) => eq(users.id, posts.userId))
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
|
-
rightJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<
|
|
94
|
+
rightJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<MergeContextForJoinCallback<TContext, SchemaFromSource<TSource>>>): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, `right`>>;
|
|
95
95
|
/**
|
|
96
96
|
* Perform an INNER JOIN with another table or subquery
|
|
97
97
|
*
|
|
@@ -107,7 +107,7 @@ export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
|
107
107
|
* .innerJoin({ posts: postsCollection }, ({users, posts}) => eq(users.id, posts.userId))
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
|
-
innerJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<
|
|
110
|
+
innerJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<MergeContextForJoinCallback<TContext, SchemaFromSource<TSource>>>): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, `inner`>>;
|
|
111
111
|
/**
|
|
112
112
|
* Perform a FULL JOIN with another table or subquery
|
|
113
113
|
*
|
|
@@ -123,7 +123,7 @@ export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
|
123
123
|
* .fullJoin({ posts: postsCollection }, ({users, posts}) => eq(users.id, posts.userId))
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
|
-
fullJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<
|
|
126
|
+
fullJoin<TSource extends Source>(source: TSource, onCallback: JoinOnCallback<MergeContextForJoinCallback<TContext, SchemaFromSource<TSource>>>): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, `full`>>;
|
|
127
127
|
/**
|
|
128
128
|
* Filter rows based on a condition
|
|
129
129
|
*
|
|
@@ -216,7 +216,7 @@ export declare class BaseQueryBuilder<TContext extends Context = Context> {
|
|
|
216
216
|
* }))
|
|
217
217
|
* ```
|
|
218
218
|
*/
|
|
219
|
-
select<TSelectObject extends SelectObject>(callback: (refs:
|
|
219
|
+
select<TSelectObject extends SelectObject>(callback: (refs: RefsForContext<TContext>) => TSelectObject): QueryBuilder<WithResult<TContext, ResultTypeFromSelect<TSelectObject>>>;
|
|
220
220
|
/**
|
|
221
221
|
* Sort the query results by one or more columns
|
|
222
222
|
*
|
|
@@ -400,4 +400,4 @@ export type InitialQueryBuilderConstructor = new () => InitialQueryBuilder;
|
|
|
400
400
|
export type QueryBuilder<TContext extends Context> = Omit<BaseQueryBuilder<TContext>, `from` | `_getQuery`>;
|
|
401
401
|
export declare const Query: InitialQueryBuilderConstructor;
|
|
402
402
|
export type ExtractContext<T> = T extends BaseQueryBuilder<infer TContext> ? TContext : T extends QueryBuilder<infer TContext> ? TContext : never;
|
|
403
|
-
export type { Context, Source, GetResult } from './types.js';
|
|
403
|
+
export type { Context, Source, GetResult, RefLeaf as Ref } from './types.js';
|
|
@@ -39,7 +39,7 @@ function createSingleRowRefProxy() {
|
|
|
39
39
|
}
|
|
40
40
|
function createRefProxy(aliases) {
|
|
41
41
|
const cache = /* @__PURE__ */ new Map();
|
|
42
|
-
|
|
42
|
+
let accessId = 0;
|
|
43
43
|
function createProxy(path) {
|
|
44
44
|
const pathKey = path.join(`.`);
|
|
45
45
|
if (cache.has(pathKey)) {
|
|
@@ -60,9 +60,14 @@ function createRefProxy(aliases) {
|
|
|
60
60
|
return Reflect.has(target, prop);
|
|
61
61
|
},
|
|
62
62
|
ownKeys(target) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const id = ++accessId;
|
|
64
|
+
const sentinelKey = `__SPREAD_SENTINEL__${path.join(`.`)}__${id}`;
|
|
65
|
+
if (!Object.prototype.hasOwnProperty.call(target, sentinelKey)) {
|
|
66
|
+
Object.defineProperty(target, sentinelKey, {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
value: true
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
return Reflect.ownKeys(target);
|
|
68
73
|
},
|
|
@@ -81,7 +86,6 @@ function createRefProxy(aliases) {
|
|
|
81
86
|
if (prop === `__refProxy`) return true;
|
|
82
87
|
if (prop === `__path`) return [];
|
|
83
88
|
if (prop === `__type`) return void 0;
|
|
84
|
-
if (prop === `__spreadSentinels`) return spreadSentinels;
|
|
85
89
|
if (typeof prop === `symbol`) return Reflect.get(target, prop, receiver);
|
|
86
90
|
const propStr = String(prop);
|
|
87
91
|
if (aliases.includes(propStr)) {
|
|
@@ -90,16 +94,16 @@ function createRefProxy(aliases) {
|
|
|
90
94
|
return void 0;
|
|
91
95
|
},
|
|
92
96
|
has(target, prop) {
|
|
93
|
-
if (prop === `__refProxy` || prop === `__path` || prop === `__type`
|
|
97
|
+
if (prop === `__refProxy` || prop === `__path` || prop === `__type`)
|
|
94
98
|
return true;
|
|
95
99
|
if (typeof prop === `string` && aliases.includes(prop)) return true;
|
|
96
100
|
return Reflect.has(target, prop);
|
|
97
101
|
},
|
|
98
102
|
ownKeys(_target) {
|
|
99
|
-
return [...aliases, `__refProxy`, `__path`, `__type
|
|
103
|
+
return [...aliases, `__refProxy`, `__path`, `__type`];
|
|
100
104
|
},
|
|
101
105
|
getOwnPropertyDescriptor(target, prop) {
|
|
102
|
-
if (prop === `__refProxy` || prop === `__path` || prop === `__type`
|
|
106
|
+
if (prop === `__refProxy` || prop === `__path` || prop === `__type`) {
|
|
103
107
|
return { enumerable: false, configurable: true };
|
|
104
108
|
}
|
|
105
109
|
if (typeof prop === `string` && aliases.includes(prop)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-proxy.cjs","sources":["../../../../src/query/builder/ref-proxy.ts"],"sourcesContent":["import { PropRef, Value } from \"../ir.js\"\nimport type { BasicExpression } from \"../ir.js\"\n\nexport interface RefProxy<T = any> {\n /** @internal */\n readonly __refProxy: true\n /** @internal */\n readonly __path: Array<string>\n /** @internal */\n readonly __type: T\n}\n\n/**\n * Type for creating a RefProxy for a single row/type without namespacing\n * Used in collection indexes and where clauses\n */\nexport type SingleRowRefProxy<T> =\n T extends Record<string, any>\n ? {\n [K in keyof T]: T[K] extends Record<string, any>\n ? SingleRowRefProxy<T[K]> & RefProxy<T[K]>\n :
|
|
1
|
+
{"version":3,"file":"ref-proxy.cjs","sources":["../../../../src/query/builder/ref-proxy.ts"],"sourcesContent":["import { PropRef, Value } from \"../ir.js\"\nimport type { BasicExpression } from \"../ir.js\"\nimport type { RefLeaf } from \"./types.js\"\n\nexport interface RefProxy<T = any> {\n /** @internal */\n readonly __refProxy: true\n /** @internal */\n readonly __path: Array<string>\n /** @internal */\n readonly __type: T\n}\n\n/**\n * Type for creating a RefProxy for a single row/type without namespacing\n * Used in collection indexes and where clauses\n */\nexport type SingleRowRefProxy<T> =\n T extends Record<string, any>\n ? {\n [K in keyof T]: T[K] extends Record<string, any>\n ? SingleRowRefProxy<T[K]> & RefProxy<T[K]>\n : RefLeaf<T[K]>\n } & RefProxy<T>\n : RefProxy<T>\n\n/**\n * Creates a proxy object that records property access paths for a single row\n * Used in collection indexes and where clauses\n */\nexport function createSingleRowRefProxy<\n T extends Record<string, any>,\n>(): SingleRowRefProxy<T> {\n const cache = new Map<string, any>()\n\n function createProxy(path: Array<string>): any {\n const pathKey = path.join(`.`)\n if (cache.has(pathKey)) {\n return cache.get(pathKey)\n }\n\n const proxy = new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === `__refProxy`) return true\n if (prop === `__path`) return path\n if (prop === `__type`) return undefined // Type is only for TypeScript inference\n if (typeof prop === `symbol`) return Reflect.get(target, prop, receiver)\n\n const newPath = [...path, String(prop)]\n return createProxy(newPath)\n },\n\n has(target, prop) {\n if (prop === `__refProxy` || prop === `__path` || prop === `__type`)\n return true\n return Reflect.has(target, prop)\n },\n\n ownKeys(target) {\n return Reflect.ownKeys(target)\n },\n\n getOwnPropertyDescriptor(target, prop) {\n if (prop === `__refProxy` || prop === `__path` || prop === `__type`) {\n return { enumerable: false, configurable: true }\n }\n return Reflect.getOwnPropertyDescriptor(target, prop)\n },\n })\n\n cache.set(pathKey, proxy)\n return proxy\n }\n\n // Return the root proxy that starts with an empty path\n return createProxy([]) as SingleRowRefProxy<T>\n}\n\n/**\n * Creates a proxy object that records property access paths\n * Used in callbacks like where, select, etc. to create type-safe references\n */\nexport function createRefProxy<T extends Record<string, any>>(\n aliases: Array<string>\n): RefProxy<T> & T {\n const cache = new Map<string, any>()\n let accessId = 0 // Monotonic counter to record evaluation order\n\n function createProxy(path: Array<string>): any {\n const pathKey = path.join(`.`)\n if (cache.has(pathKey)) {\n return cache.get(pathKey)\n }\n\n const proxy = new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === `__refProxy`) return true\n if (prop === `__path`) return path\n if (prop === `__type`) return undefined // Type is only for TypeScript inference\n if (typeof prop === `symbol`) return Reflect.get(target, prop, receiver)\n\n const newPath = [...path, String(prop)]\n return createProxy(newPath)\n },\n\n has(target, prop) {\n if (prop === `__refProxy` || prop === `__path` || prop === `__type`)\n return true\n return Reflect.has(target, prop)\n },\n\n ownKeys(target) {\n const id = ++accessId\n const sentinelKey = `__SPREAD_SENTINEL__${path.join(`.`)}__${id}`\n if (!Object.prototype.hasOwnProperty.call(target, sentinelKey)) {\n Object.defineProperty(target, sentinelKey, {\n enumerable: true,\n configurable: true,\n value: true,\n })\n }\n return Reflect.ownKeys(target)\n },\n\n getOwnPropertyDescriptor(target, prop) {\n if (prop === `__refProxy` || prop === `__path` || prop === `__type`) {\n return { enumerable: false, configurable: true }\n }\n return Reflect.getOwnPropertyDescriptor(target, prop)\n },\n })\n\n cache.set(pathKey, proxy)\n return proxy\n }\n\n // Create the root proxy with all aliases as top-level properties\n const rootProxy = new Proxy({} as any, {\n get(target, prop, receiver) {\n if (prop === `__refProxy`) return true\n if (prop === `__path`) return []\n if (prop === `__type`) return undefined // Type is only for TypeScript inference\n if (typeof prop === `symbol`) return Reflect.get(target, prop, receiver)\n\n const propStr = String(prop)\n if (aliases.includes(propStr)) {\n return createProxy([propStr])\n }\n\n return undefined\n },\n\n has(target, prop) {\n if (prop === `__refProxy` || prop === `__path` || prop === `__type`)\n return true\n if (typeof prop === `string` && aliases.includes(prop)) return true\n return Reflect.has(target, prop)\n },\n\n ownKeys(_target) {\n return [...aliases, `__refProxy`, `__path`, `__type`]\n },\n\n getOwnPropertyDescriptor(target, prop) {\n if (prop === `__refProxy` || prop === `__path` || prop === `__type`) {\n return { enumerable: false, configurable: true }\n }\n if (typeof prop === `string` && aliases.includes(prop)) {\n return { enumerable: true, configurable: true }\n }\n return undefined\n },\n })\n\n return rootProxy\n}\n\n/**\n * Converts a value to an Expression\n * If it's a RefProxy, creates a Ref, otherwise creates a Value\n */\nexport function toExpression<T = any>(value: T): BasicExpression<T>\nexport function toExpression(value: RefProxy<any>): BasicExpression<any>\nexport function toExpression(value: any): BasicExpression<any> {\n if (isRefProxy(value)) {\n return new PropRef(value.__path)\n }\n // If it's already an Expression (Func, Ref, Value) or Agg, return it directly\n if (\n value &&\n typeof value === `object` &&\n `type` in value &&\n (value.type === `func` ||\n value.type === `ref` ||\n value.type === `val` ||\n value.type === `agg`)\n ) {\n return value\n }\n return new Value(value)\n}\n\n/**\n * Type guard to check if a value is a RefProxy\n */\nexport function isRefProxy(value: any): value is RefProxy {\n return value && typeof value === `object` && value.__refProxy === true\n}\n\n/**\n * Helper to create a Value expression from a literal\n */\nexport function val<T>(value: T): BasicExpression<T> {\n return new Value(value)\n}\n"],"names":["PropRef","Value"],"mappings":";;;AA8BO,SAAS,0BAEU;AACxB,QAAM,4BAAY,IAAA;AAElB,WAAS,YAAY,MAA0B;AAC7C,UAAM,UAAU,KAAK,KAAK,GAAG;AAC7B,QAAI,MAAM,IAAI,OAAO,GAAG;AACtB,aAAO,MAAM,IAAI,OAAO;AAAA,IAC1B;AAEA,UAAM,QAAQ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O;AAAA,IACT;AAAA,IAEA,IAAI,QAAQ,MAAM;AAChB,UAAI,SAAS,gBAAgB,SAAS,YAAY,SAAS;AACzD,eAAO;AACT,UAAI,OAAO,SAAS,YAAY,QAAQ,SAAS,IAAI,EAAG,QAAO;AAC/D,aAAO,QAAQ,IAAI,QAAQ,IAAI;AAAA,IACjC;AAAA,IAEA,QAAQ,SAAS;AACf,aAAO,CAAC,GAAG,SAAS,cAAc,UAAU,QAAQ;AAAA,IACtD;AAAA,IAEA,yBAAyB,QAAQ,MAAM;AACrC,UAAI,SAAS,gBAAgB,SAAS,YAAY,SAAS,UAAU;AACnE,eAAO,EAAE,YAAY,OAAO,cAAc,KAAA;AAAA,MAC5C;AACA,UAAI,OAAO,SAAS,YAAY,QAAQ,SAAS,IAAI,GAAG;AACtD,eAAO,EAAE,YAAY,MAAM,cAAc,KAAA;AAAA,MAC3C;AACA,aAAO;AAAA,IACT;AAAA,EAAA,CACD;AAED,SAAO;AACT;AAQO,SAAS,aAAa,OAAkC;AAC7D,MAAI,WAAW,KAAK,GAAG;AACrB,WAAO,IAAIA,GAAAA,QAAQ,MAAM,MAAM;AAAA,EACjC;AAEA,MACE,SACA,OAAO,UAAU,YACjB,UAAU,UACT,MAAM,SAAS,UACd,MAAM,SAAS,SACf,MAAM,SAAS,SACf,MAAM,SAAS,QACjB;AACA,WAAO;AAAA,EACT;AACA,SAAO,IAAIC,GAAAA,MAAM,KAAK;AACxB;AAKO,SAAS,WAAW,OAA+B;AACxD,SAAO,SAAS,OAAO,UAAU,YAAY,MAAM,eAAe;AACpE;;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BasicExpression } from '../ir.js';
|
|
2
|
+
import { RefLeaf } from './types.js';
|
|
2
3
|
export interface RefProxy<T = any> {
|
|
3
4
|
/** @internal */
|
|
4
5
|
readonly __refProxy: true;
|
|
@@ -12,7 +13,7 @@ export interface RefProxy<T = any> {
|
|
|
12
13
|
* Used in collection indexes and where clauses
|
|
13
14
|
*/
|
|
14
15
|
export type SingleRowRefProxy<T> = T extends Record<string, any> ? {
|
|
15
|
-
[K in keyof T]: T[K] extends Record<string, any> ? SingleRowRefProxy<T[K]> & RefProxy<T[K]> :
|
|
16
|
+
[K in keyof T]: T[K] extends Record<string, any> ? SingleRowRefProxy<T[K]> & RefProxy<T[K]> : RefLeaf<T[K]>;
|
|
16
17
|
} & RefProxy<T> : RefProxy<T>;
|
|
17
18
|
/**
|
|
18
19
|
* Creates a proxy object that records property access paths for a single row
|