@shotleybuilder/gridlite-adapter-tanstack-db 0.5.0 → 0.6.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/adapter.d.ts +69 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +271 -0
- package/dist/adapter.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/live.d.ts +33 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +85 -0
- package/dist/live.js.map +1 -0
- package/dist/operator-map.d.ts +20 -0
- package/dist/operator-map.d.ts.map +1 -0
- package/dist/operator-map.js +85 -0
- package/dist/operator-map.js.map +1 -0
- package/dist/query-translator.d.ts +35 -0
- package/dist/query-translator.d.ts.map +1 -0
- package/dist/query-translator.js +156 -0
- package/dist/query-translator.js.map +1 -0
- package/dist/schema.d.ts +37 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +74 -0
- package/dist/schema.js.map +1 -0
- package/dist/storage.d.ts +51 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +167 -0
- package/dist/storage.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapter.ts — TanStackDBAdapter
|
|
3
|
+
*
|
|
4
|
+
* Implements the QueryAdapter interface using TanStack DB collections
|
|
5
|
+
* and query builder. Translates structured descriptors into TanStack DB
|
|
6
|
+
* query builder chains.
|
|
7
|
+
*/
|
|
8
|
+
import type { Collection } from "@tanstack/db";
|
|
9
|
+
import type { QueryAdapter, LiveQueryHandle, ColumnStateEntry, QueryDescriptor, CountDescriptor, GroupSummaryDescriptor, GroupCountDescriptor, GroupDetailDescriptor } from "@shotleybuilder/svelte-gridlite-kit/adapter";
|
|
10
|
+
import type { ColumnMetadata, ViewPreset } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
11
|
+
import { type StorageProvider } from "./storage.js";
|
|
12
|
+
type AnyCollection = Collection<any, any, any, any, any>;
|
|
13
|
+
export interface TanStackDBAdapterOptions {
|
|
14
|
+
/** TanStack DB Collection to query against */
|
|
15
|
+
collection: AnyCollection;
|
|
16
|
+
/** Explicit column metadata (required unless schema is provided) */
|
|
17
|
+
columns?: ColumnMetadata[];
|
|
18
|
+
/** Zod schema for automatic column derivation (alternative to columns) */
|
|
19
|
+
schema?: {
|
|
20
|
+
shape: Record<string, any>;
|
|
21
|
+
};
|
|
22
|
+
/** State persistence provider (defaults to InMemoryStorage) */
|
|
23
|
+
storage?: StorageProvider;
|
|
24
|
+
}
|
|
25
|
+
export declare class TanStackDBAdapter implements QueryAdapter {
|
|
26
|
+
private collection;
|
|
27
|
+
private columns;
|
|
28
|
+
private allowedColumns;
|
|
29
|
+
private storage;
|
|
30
|
+
private schemaOption?;
|
|
31
|
+
private columnsOption?;
|
|
32
|
+
private initialized;
|
|
33
|
+
constructor(options: TanStackDBAdapterOptions);
|
|
34
|
+
init(): Promise<void>;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
introspect(): Promise<ColumnMetadata[]>;
|
|
37
|
+
getAllowedColumns(): string[];
|
|
38
|
+
private getSearchColumns;
|
|
39
|
+
private getDefaultSortColumn;
|
|
40
|
+
private buildQueryFn;
|
|
41
|
+
createLiveQuery(query: QueryDescriptor): LiveQueryHandle;
|
|
42
|
+
executeCount(query: CountDescriptor): Promise<number>;
|
|
43
|
+
executeGroupSummary(query: GroupSummaryDescriptor): Promise<{
|
|
44
|
+
rows: Record<string, unknown>[];
|
|
45
|
+
}>;
|
|
46
|
+
executeGroupCount(query: GroupCountDescriptor): Promise<number>;
|
|
47
|
+
executeGroupDetail(query: GroupDetailDescriptor): Promise<{
|
|
48
|
+
rows: Record<string, unknown>[];
|
|
49
|
+
}>;
|
|
50
|
+
getDistinctValues(column: string): Promise<string[]>;
|
|
51
|
+
getNumericRange(column: string): Promise<{
|
|
52
|
+
min: number;
|
|
53
|
+
max: number;
|
|
54
|
+
} | null>;
|
|
55
|
+
loadColumnState(gridId: string, viewId?: string): Promise<ColumnStateEntry[]>;
|
|
56
|
+
saveColumnState(gridId: string, columns: ColumnStateEntry[], viewId?: string): Promise<void>;
|
|
57
|
+
saveView(gridId: string, view: ViewPreset): Promise<void>;
|
|
58
|
+
loadView(viewId: string): Promise<ViewPreset | null>;
|
|
59
|
+
loadViews(gridId: string): Promise<ViewPreset[]>;
|
|
60
|
+
deleteView(viewId: string): Promise<void>;
|
|
61
|
+
loadDefaultView(gridId: string): Promise<ViewPreset | null>;
|
|
62
|
+
setDefaultView(gridId: string, viewId: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Factory function for creating a TanStack DB adapter.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createTanStackDBAdapter(options: TanStackDBAdapterOptions): QueryAdapter;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACX,MAAM,2CAA2C,CAAC;AAUnD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAGrE,KAAK,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC,8CAA8C;IAC9C,UAAU,EAAE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CAAC;IA+BzC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBpD,eAAe,CACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IA8BzC,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAIxB,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EAAE,EAC3B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAIV,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAIpD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIhD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAI3D,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,GAChC,YAAY,CAEd"}
|
package/dist/adapter.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapter.ts — TanStackDBAdapter
|
|
3
|
+
*
|
|
4
|
+
* Implements the QueryAdapter interface using TanStack DB collections
|
|
5
|
+
* and query builder. Translates structured descriptors into TanStack DB
|
|
6
|
+
* query builder chains.
|
|
7
|
+
*/
|
|
8
|
+
import { createLiveQueryCollection, eq, isNull, count, sum, avg, min, max, } from "@tanstack/db";
|
|
9
|
+
import { applyFilters, applyGlobalSearch, applySorting, applyPagination, applyJsonbFilters, } from "./query-translator.js";
|
|
10
|
+
import { createLiveQueryHandle } from "./live.js";
|
|
11
|
+
import { deriveColumnsFromZodSchema } from "./schema.js";
|
|
12
|
+
import { InMemoryStorage } from "./storage.js";
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const AGG_FNS = {
|
|
15
|
+
count,
|
|
16
|
+
sum,
|
|
17
|
+
avg,
|
|
18
|
+
min,
|
|
19
|
+
max,
|
|
20
|
+
};
|
|
21
|
+
export class TanStackDBAdapter {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.columns = [];
|
|
24
|
+
this.allowedColumns = [];
|
|
25
|
+
this.initialized = false;
|
|
26
|
+
if (!options.collection) {
|
|
27
|
+
throw new Error("TanStackDBAdapter requires a collection");
|
|
28
|
+
}
|
|
29
|
+
if (!options.columns && !options.schema) {
|
|
30
|
+
throw new Error("TanStackDBAdapter requires either columns or schema");
|
|
31
|
+
}
|
|
32
|
+
this.collection = options.collection;
|
|
33
|
+
this.columnsOption = options.columns;
|
|
34
|
+
this.schemaOption = options.schema;
|
|
35
|
+
this.storage = options.storage ?? new InMemoryStorage();
|
|
36
|
+
}
|
|
37
|
+
// ─── Lifecycle ────────────────────────────────────────────────────────────
|
|
38
|
+
async init() {
|
|
39
|
+
// Derive columns
|
|
40
|
+
if (this.columnsOption) {
|
|
41
|
+
this.columns = this.columnsOption;
|
|
42
|
+
}
|
|
43
|
+
else if (this.schemaOption) {
|
|
44
|
+
this.columns = deriveColumnsFromZodSchema(this.schemaOption);
|
|
45
|
+
}
|
|
46
|
+
this.allowedColumns = this.columns.map((c) => c.name);
|
|
47
|
+
this.initialized = true;
|
|
48
|
+
}
|
|
49
|
+
destroy() {
|
|
50
|
+
// Nothing to clean up at adapter level;
|
|
51
|
+
// individual live query handles clean up via their own destroy()
|
|
52
|
+
}
|
|
53
|
+
// ─── Schema ───────────────────────────────────────────────────────────────
|
|
54
|
+
async introspect() {
|
|
55
|
+
return this.columns;
|
|
56
|
+
}
|
|
57
|
+
getAllowedColumns() {
|
|
58
|
+
return this.allowedColumns;
|
|
59
|
+
}
|
|
60
|
+
// ─── Query helpers ────────────────────────────────────────────────────────
|
|
61
|
+
getSearchColumns(searchColumns) {
|
|
62
|
+
if (searchColumns && searchColumns.length > 0)
|
|
63
|
+
return searchColumns;
|
|
64
|
+
// Default to all text columns
|
|
65
|
+
return this.columns.filter((c) => c.dataType === "text").map((c) => c.name);
|
|
66
|
+
}
|
|
67
|
+
getDefaultSortColumn() {
|
|
68
|
+
return this.allowedColumns[0];
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
buildQueryFn(query) {
|
|
72
|
+
const searchColumns = this.getSearchColumns(query.searchColumns);
|
|
73
|
+
const defaultSortCol = this.getDefaultSortColumn();
|
|
74
|
+
const hasSorting = (query.sorting?.length ?? 0) > 0;
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
return (q) => {
|
|
77
|
+
let chain = q.from({ source: this.collection });
|
|
78
|
+
chain = applyFilters(chain, query.filters, query.filterLogic);
|
|
79
|
+
chain = applyJsonbFilters(chain, query.filters);
|
|
80
|
+
chain = applyGlobalSearch(chain, query.globalSearch, searchColumns);
|
|
81
|
+
chain = applySorting(chain, query.sorting);
|
|
82
|
+
chain = applyPagination(chain, query.page, query.pageSize, hasSorting, defaultSortCol);
|
|
83
|
+
return chain;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// ─── Query Execution ──────────────────────────────────────────────────────
|
|
87
|
+
createLiveQuery(query) {
|
|
88
|
+
return createLiveQueryHandle({
|
|
89
|
+
sourceCollection: this.collection,
|
|
90
|
+
columns: this.columns,
|
|
91
|
+
buildQueryFn: (desc) => this.buildQueryFn(desc),
|
|
92
|
+
initialQuery: query,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async executeCount(query) {
|
|
96
|
+
const searchColumns = this.getSearchColumns(query.searchColumns);
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
const queryFn = (q) => {
|
|
99
|
+
let chain = q.from({ source: this.collection });
|
|
100
|
+
chain = applyFilters(chain, query.filters, query.filterLogic);
|
|
101
|
+
chain = applyJsonbFilters(chain, query.filters);
|
|
102
|
+
chain = applyGlobalSearch(chain, query.globalSearch, searchColumns);
|
|
103
|
+
return chain;
|
|
104
|
+
};
|
|
105
|
+
const result = createLiveQueryCollection(queryFn);
|
|
106
|
+
const rows = await result.toArrayWhenReady();
|
|
107
|
+
return rows.length;
|
|
108
|
+
}
|
|
109
|
+
async executeGroupSummary(query) {
|
|
110
|
+
const searchColumns = this.getSearchColumns(query.searchColumns);
|
|
111
|
+
const defaultSortCol = this.getDefaultSortColumn();
|
|
112
|
+
const hasSorting = (query.sorting?.length ?? 0) > 0;
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
const queryFn = (q) => {
|
|
115
|
+
let chain = q.from({ source: this.collection });
|
|
116
|
+
chain = applyFilters(chain, query.filters, query.filterLogic);
|
|
117
|
+
chain = applyJsonbFilters(chain, query.filters);
|
|
118
|
+
chain = applyGlobalSearch(chain, query.globalSearch, searchColumns);
|
|
119
|
+
// Group by
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
+
chain = chain.groupBy((ctx) => query.grouping.map((g) => ctx.source[g.column]));
|
|
122
|
+
// Select: group columns + _count + aggregations
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
+
chain = chain.select((ctx) => {
|
|
125
|
+
const selected = {};
|
|
126
|
+
for (const g of query.grouping) {
|
|
127
|
+
selected[g.column] = ctx.source[g.column];
|
|
128
|
+
}
|
|
129
|
+
selected._count = count(ctx.source[this.allowedColumns[0]]);
|
|
130
|
+
for (const g of query.grouping) {
|
|
131
|
+
for (const agg of g.aggregations ?? []) {
|
|
132
|
+
if (!agg.column)
|
|
133
|
+
continue;
|
|
134
|
+
const alias = agg.alias ?? `${agg.function}_${agg.column}`;
|
|
135
|
+
const fn = AGG_FNS[agg.function];
|
|
136
|
+
if (fn) {
|
|
137
|
+
selected[alias] = fn(ctx.source[agg.column]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return selected;
|
|
142
|
+
});
|
|
143
|
+
chain = applySorting(chain, query.sorting);
|
|
144
|
+
chain = applyPagination(chain, query.page, query.pageSize, hasSorting, defaultSortCol);
|
|
145
|
+
return chain;
|
|
146
|
+
};
|
|
147
|
+
const result = createLiveQueryCollection(queryFn);
|
|
148
|
+
const rows = await result.toArrayWhenReady();
|
|
149
|
+
return { rows: rows };
|
|
150
|
+
}
|
|
151
|
+
async executeGroupCount(query) {
|
|
152
|
+
const searchColumns = this.getSearchColumns(query.searchColumns);
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
|
+
const queryFn = (q) => {
|
|
155
|
+
let chain = q.from({ source: this.collection });
|
|
156
|
+
chain = applyFilters(chain, query.filters, query.filterLogic);
|
|
157
|
+
chain = applyJsonbFilters(chain, query.filters);
|
|
158
|
+
chain = applyGlobalSearch(chain, query.globalSearch, searchColumns);
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
|
+
chain = chain.groupBy((ctx) => query.grouping.map((g) => ctx.source[g.column]));
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
|
+
chain = chain.select((ctx) => {
|
|
163
|
+
const selected = {};
|
|
164
|
+
for (const g of query.grouping) {
|
|
165
|
+
selected[g.column] = ctx.source[g.column];
|
|
166
|
+
}
|
|
167
|
+
return selected;
|
|
168
|
+
});
|
|
169
|
+
return chain;
|
|
170
|
+
};
|
|
171
|
+
const result = createLiveQueryCollection(queryFn);
|
|
172
|
+
const rows = await result.toArrayWhenReady();
|
|
173
|
+
return rows.length;
|
|
174
|
+
}
|
|
175
|
+
async executeGroupDetail(query) {
|
|
176
|
+
const searchColumns = this.getSearchColumns(query.searchColumns);
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
|
+
const queryFn = (q) => {
|
|
179
|
+
let chain = q.from({ source: this.collection });
|
|
180
|
+
chain = applyFilters(chain, query.filters, query.filterLogic);
|
|
181
|
+
chain = applyJsonbFilters(chain, query.filters);
|
|
182
|
+
chain = applyGlobalSearch(chain, query.globalSearch, searchColumns);
|
|
183
|
+
// Add group value constraints
|
|
184
|
+
for (const gv of query.groupValues) {
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
186
|
+
chain = chain.where((ctx) => gv.value === null
|
|
187
|
+
? isNull(ctx.source[gv.column])
|
|
188
|
+
: eq(ctx.source[gv.column], gv.value));
|
|
189
|
+
}
|
|
190
|
+
chain = applySorting(chain, query.sorting);
|
|
191
|
+
return chain;
|
|
192
|
+
};
|
|
193
|
+
const result = createLiveQueryCollection(queryFn);
|
|
194
|
+
const rows = await result.toArrayWhenReady();
|
|
195
|
+
return { rows: rows };
|
|
196
|
+
}
|
|
197
|
+
// ─── Filter Suggestions ───────────────────────────────────────────────────
|
|
198
|
+
async getDistinctValues(column) {
|
|
199
|
+
if (!this.allowedColumns.includes(column)) {
|
|
200
|
+
throw new Error(`Column "${column}" is not in the allowed columns list`);
|
|
201
|
+
}
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
203
|
+
const queryFn = (q) => q
|
|
204
|
+
.from({ source: this.collection })
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
+
.select((ctx) => ({ val: ctx.source[column] }))
|
|
207
|
+
.distinct();
|
|
208
|
+
const result = createLiveQueryCollection(queryFn);
|
|
209
|
+
const rows = (await result.toArrayWhenReady());
|
|
210
|
+
return rows
|
|
211
|
+
.map((r) => r.val)
|
|
212
|
+
.filter((v) => v != null)
|
|
213
|
+
.map(String)
|
|
214
|
+
.sort()
|
|
215
|
+
.slice(0, 200);
|
|
216
|
+
}
|
|
217
|
+
async getNumericRange(column) {
|
|
218
|
+
if (!this.allowedColumns.includes(column)) {
|
|
219
|
+
throw new Error(`Column "${column}" is not in the allowed columns list`);
|
|
220
|
+
}
|
|
221
|
+
const colMeta = this.columns.find((c) => c.name === column);
|
|
222
|
+
if (colMeta?.dataType !== "number")
|
|
223
|
+
return null;
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
+
const queryFn = (q) => q
|
|
226
|
+
.from({ source: this.collection })
|
|
227
|
+
.groupBy(() => [])
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
.select((ctx) => ({
|
|
230
|
+
min_val: min(ctx.source[column]),
|
|
231
|
+
max_val: max(ctx.source[column]),
|
|
232
|
+
}));
|
|
233
|
+
const result = createLiveQueryCollection(queryFn);
|
|
234
|
+
const rows = (await result.toArrayWhenReady());
|
|
235
|
+
if (rows.length === 0)
|
|
236
|
+
return null;
|
|
237
|
+
return { min: Number(rows[0].min_val), max: Number(rows[0].max_val) };
|
|
238
|
+
}
|
|
239
|
+
// ─── State Persistence (delegated to StorageProvider) ─────────────────────
|
|
240
|
+
async loadColumnState(gridId, viewId) {
|
|
241
|
+
return this.storage.loadColumnState(gridId, viewId);
|
|
242
|
+
}
|
|
243
|
+
async saveColumnState(gridId, columns, viewId) {
|
|
244
|
+
await this.storage.saveColumnState(gridId, columns, viewId);
|
|
245
|
+
}
|
|
246
|
+
async saveView(gridId, view) {
|
|
247
|
+
await this.storage.saveView(gridId, view);
|
|
248
|
+
}
|
|
249
|
+
async loadView(viewId) {
|
|
250
|
+
return this.storage.loadView(viewId);
|
|
251
|
+
}
|
|
252
|
+
async loadViews(gridId) {
|
|
253
|
+
return this.storage.loadViews(gridId);
|
|
254
|
+
}
|
|
255
|
+
async deleteView(viewId) {
|
|
256
|
+
await this.storage.deleteView(viewId);
|
|
257
|
+
}
|
|
258
|
+
async loadDefaultView(gridId) {
|
|
259
|
+
return this.storage.loadDefaultView(gridId);
|
|
260
|
+
}
|
|
261
|
+
async setDefaultView(gridId, viewId) {
|
|
262
|
+
await this.storage.setDefaultView(gridId, viewId);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Factory function for creating a TanStack DB adapter.
|
|
267
|
+
*/
|
|
268
|
+
export function createTanStackDBAdapter(options) {
|
|
269
|
+
return new TanStackDBAdapter(options);
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,yBAAyB,EACzB,EAAE,EACF,MAAM,EACN,KAAK,EACL,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,GACJ,MAAM,cAAc,CAAC;AAgBtB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAwB,MAAM,cAAc,CAAC;AAiBrE,8DAA8D;AAC9D,MAAM,OAAO,GAAsC;IACjD,KAAK;IACL,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACJ,CAAC;AAEF,MAAM,OAAO,iBAAiB;IAU5B,YAAY,OAAiC;QARrC,YAAO,GAAqB,EAAE,CAAC;QAC/B,mBAAc,GAAa,EAAE,CAAC;QAK9B,gBAAW,GAAG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AAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAc;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAAc;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,MAAc;QACjD,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAiC;IAEjC,OAAO,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createTanStackDBAdapter, TanStackDBAdapter } from './adapter.js';
|
|
2
|
+
export type { TanStackDBAdapterOptions } from './adapter.js';
|
|
3
|
+
export { InMemoryStorage, LocalStorageProvider } from './storage.js';
|
|
4
|
+
export type { StorageProvider } from './storage.js';
|
|
5
|
+
export { deriveColumnsFromZodSchema } from './schema.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1E,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Public API for @shotleybuilder/gridlite-adapter-tanstack-db
|
|
2
|
+
export { createTanStackDBAdapter, TanStackDBAdapter } from './adapter.js';
|
|
3
|
+
export { InMemoryStorage, LocalStorageProvider } from './storage.js';
|
|
4
|
+
export { deriveColumnsFromZodSchema } from './schema.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/live.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* live.ts — Bridges TanStack DB live query collections to GridLite's
|
|
3
|
+
* LiveQueryHandle / LiveQueryState contract.
|
|
4
|
+
*
|
|
5
|
+
* Uses createLiveQueryCollection (framework-agnostic, no Svelte context needed)
|
|
6
|
+
* and subscribeChanges() for reactivity.
|
|
7
|
+
*/
|
|
8
|
+
import type { Collection } from "@tanstack/db";
|
|
9
|
+
import type { LiveQueryHandle, QueryDescriptor } from "@shotleybuilder/svelte-gridlite-kit/adapter";
|
|
10
|
+
import type { ColumnMetadata } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
11
|
+
type QueryBuilderFn = (q: any) => any;
|
|
12
|
+
export interface LiveQueryConfig {
|
|
13
|
+
/** Source collection to query against */
|
|
14
|
+
sourceCollection: Collection;
|
|
15
|
+
/** Column metadata for synthesizing fields */
|
|
16
|
+
columns: ColumnMetadata[];
|
|
17
|
+
/** Function that builds a query chain from a descriptor */
|
|
18
|
+
buildQueryFn: (descriptor: QueryDescriptor) => QueryBuilderFn;
|
|
19
|
+
/** Initial query descriptor */
|
|
20
|
+
initialQuery: QueryDescriptor;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Wait for a collection to reach 'ready' status.
|
|
24
|
+
* Uses toArrayWhenReady() which triggers preload() internally,
|
|
25
|
+
* ensuring the D2 pipeline starts even without subscribers.
|
|
26
|
+
*/
|
|
27
|
+
export declare function waitForReady(collection: Collection): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Create a LiveQueryHandle that wraps a TanStack DB live query collection.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createLiveQueryHandle(config: LiveQueryConfig): LiveQueryHandle;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,eAAe,EAEf,eAAe,EAChB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAGhF,KAAK,cAAc,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,yCAAyC;IACzC,gBAAgB,EAAE,UAAU,CAAC;IAC7B,8CAA8C;IAC9C,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,2DAA2D;IAC3D,YAAY,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,cAAc,CAAC;IAC9D,+BAA+B;IAC/B,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAKlE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,GACtB,eAAe,CAoEjB"}
|
package/dist/live.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* live.ts — Bridges TanStack DB live query collections to GridLite's
|
|
3
|
+
* LiveQueryHandle / LiveQueryState contract.
|
|
4
|
+
*
|
|
5
|
+
* Uses createLiveQueryCollection (framework-agnostic, no Svelte context needed)
|
|
6
|
+
* and subscribeChanges() for reactivity.
|
|
7
|
+
*/
|
|
8
|
+
import { createLiveQueryCollection } from "@tanstack/db";
|
|
9
|
+
/**
|
|
10
|
+
* Wait for a collection to reach 'ready' status.
|
|
11
|
+
* Uses toArrayWhenReady() which triggers preload() internally,
|
|
12
|
+
* ensuring the D2 pipeline starts even without subscribers.
|
|
13
|
+
*/
|
|
14
|
+
export function waitForReady(collection) {
|
|
15
|
+
if (collection.status === "ready") {
|
|
16
|
+
return Promise.resolve();
|
|
17
|
+
}
|
|
18
|
+
return collection.toArrayWhenReady().then(() => { });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a LiveQueryHandle that wraps a TanStack DB live query collection.
|
|
22
|
+
*/
|
|
23
|
+
export function createLiveQueryHandle(config) {
|
|
24
|
+
const { sourceCollection, columns, buildQueryFn } = config;
|
|
25
|
+
let currentQuery = config.initialQuery;
|
|
26
|
+
let destroyed = false;
|
|
27
|
+
const subscribers = new Set();
|
|
28
|
+
const fields = columns.map((c) => ({ name: c.name, dataTypeID: 0 }));
|
|
29
|
+
// Create the initial live query collection
|
|
30
|
+
let liveCollection = createLiveQueryCollection(buildQueryFn(currentQuery));
|
|
31
|
+
let subscription = subscribeTo(liveCollection);
|
|
32
|
+
function buildState(coll) {
|
|
33
|
+
const isReady = coll.status === "ready";
|
|
34
|
+
return {
|
|
35
|
+
rows: isReady
|
|
36
|
+
? coll.toArray
|
|
37
|
+
: [],
|
|
38
|
+
fields,
|
|
39
|
+
loading: !isReady,
|
|
40
|
+
error: coll.status === "error" ? new Error("Collection error") : null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function notify(coll) {
|
|
44
|
+
if (destroyed)
|
|
45
|
+
return;
|
|
46
|
+
const state = buildState(coll);
|
|
47
|
+
for (const cb of subscribers) {
|
|
48
|
+
cb(state);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function subscribeTo(coll) {
|
|
52
|
+
return coll.subscribeChanges(() => notify(coll), {
|
|
53
|
+
includeInitialState: true,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
subscribe(callback) {
|
|
58
|
+
subscribers.add(callback);
|
|
59
|
+
// Immediate delivery per Svelte store contract
|
|
60
|
+
callback(buildState(liveCollection));
|
|
61
|
+
return () => {
|
|
62
|
+
subscribers.delete(callback);
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
async refresh() {
|
|
66
|
+
notify(liveCollection);
|
|
67
|
+
},
|
|
68
|
+
async update(newQuery) {
|
|
69
|
+
if (destroyed)
|
|
70
|
+
return;
|
|
71
|
+
currentQuery = newQuery;
|
|
72
|
+
// Tear down old subscription
|
|
73
|
+
subscription.unsubscribe();
|
|
74
|
+
// Create new live query collection
|
|
75
|
+
liveCollection = createLiveQueryCollection(buildQueryFn(currentQuery));
|
|
76
|
+
subscription = subscribeTo(liveCollection);
|
|
77
|
+
},
|
|
78
|
+
async destroy() {
|
|
79
|
+
destroyed = true;
|
|
80
|
+
subscription.unsubscribe();
|
|
81
|
+
subscribers.clear();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=live.js.map
|
package/dist/live.js.map
ADDED
|
@@ -0,0 +1 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AW,EAAE,CAAC;YAC3B,WAAW,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* operator-map.ts — Maps GridLite FilterOperator → TanStack DB expressions.
|
|
3
|
+
*
|
|
4
|
+
* Each mapping function takes a field reference (from the query builder's
|
|
5
|
+
* context proxy) and a condition value, returning a TanStack DB expression.
|
|
6
|
+
*/
|
|
7
|
+
import type { FilterCondition } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
8
|
+
type FieldRef = any;
|
|
9
|
+
type Expression = any;
|
|
10
|
+
/**
|
|
11
|
+
* Translate a single FilterCondition into a TanStack DB expression.
|
|
12
|
+
*
|
|
13
|
+
* @param fieldRef - The field reference from the query builder context (e.g. source.name)
|
|
14
|
+
* @param condition - The GridLite filter condition
|
|
15
|
+
* @param getFieldRef - Optional function to resolve a column name to a field ref (for valueColumn)
|
|
16
|
+
* @returns A TanStack DB expression, or null if the condition cannot be translated
|
|
17
|
+
*/
|
|
18
|
+
export declare function translateCondition(fieldRef: FieldRef, condition: FilterCondition, getFieldRef?: (column: string) => FieldRef): Expression | null;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=operator-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-map.d.ts","sourceRoot":"","sources":["../src/operator-map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAGjF,KAAK,QAAQ,GAAG,GAAG,CAAC;AAEpB,KAAK,UAAU,GAAG,GAAG,CAAC;AAEtB;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,eAAe,EAC1B,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,QAAQ,GACzC,UAAU,GAAG,IAAI,CAiDnB"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* operator-map.ts — Maps GridLite FilterOperator → TanStack DB expressions.
|
|
3
|
+
*
|
|
4
|
+
* Each mapping function takes a field reference (from the query builder's
|
|
5
|
+
* context proxy) and a condition value, returning a TanStack DB expression.
|
|
6
|
+
*/
|
|
7
|
+
import { eq, gt, gte, lt, lte, ilike, isNull, and, or, not, } from "@tanstack/db";
|
|
8
|
+
/**
|
|
9
|
+
* Translate a single FilterCondition into a TanStack DB expression.
|
|
10
|
+
*
|
|
11
|
+
* @param fieldRef - The field reference from the query builder context (e.g. source.name)
|
|
12
|
+
* @param condition - The GridLite filter condition
|
|
13
|
+
* @param getFieldRef - Optional function to resolve a column name to a field ref (for valueColumn)
|
|
14
|
+
* @returns A TanStack DB expression, or null if the condition cannot be translated
|
|
15
|
+
*/
|
|
16
|
+
export function translateCondition(fieldRef, condition, getFieldRef) {
|
|
17
|
+
const { operator, value } = condition;
|
|
18
|
+
// Column-to-column comparison
|
|
19
|
+
if (condition.valueColumn && getFieldRef) {
|
|
20
|
+
if (condition.intervalOffset) {
|
|
21
|
+
throw new Error(`TanStack DB adapter does not support interval offsets. ` +
|
|
22
|
+
`Pre-compute date offsets in your collection data instead.`);
|
|
23
|
+
}
|
|
24
|
+
const rhsRef = getFieldRef(condition.valueColumn);
|
|
25
|
+
return translateComparison(operator, fieldRef, rhsRef);
|
|
26
|
+
}
|
|
27
|
+
switch (operator) {
|
|
28
|
+
case "equals":
|
|
29
|
+
return eq(fieldRef, value);
|
|
30
|
+
case "not_equals":
|
|
31
|
+
return not(eq(fieldRef, value));
|
|
32
|
+
case "contains":
|
|
33
|
+
return ilike(fieldRef, `%${value}%`);
|
|
34
|
+
case "not_contains":
|
|
35
|
+
return not(ilike(fieldRef, `%${value}%`));
|
|
36
|
+
case "starts_with":
|
|
37
|
+
return ilike(fieldRef, `${value}%`);
|
|
38
|
+
case "ends_with":
|
|
39
|
+
return ilike(fieldRef, `%${value}`);
|
|
40
|
+
case "greater_than":
|
|
41
|
+
case "is_after":
|
|
42
|
+
return gt(fieldRef, value);
|
|
43
|
+
case "less_than":
|
|
44
|
+
case "is_before":
|
|
45
|
+
return lt(fieldRef, value);
|
|
46
|
+
case "greater_or_equal":
|
|
47
|
+
return gte(fieldRef, value);
|
|
48
|
+
case "less_or_equal":
|
|
49
|
+
return lte(fieldRef, value);
|
|
50
|
+
case "is_empty":
|
|
51
|
+
return or(isNull(fieldRef), eq(fieldRef, ""));
|
|
52
|
+
case "is_not_empty":
|
|
53
|
+
return and(not(isNull(fieldRef)), not(eq(fieldRef, "")));
|
|
54
|
+
case "jsonb_has_key":
|
|
55
|
+
case "jsonb_not_has_key":
|
|
56
|
+
// These require fn.where() functional fallback — handled at the translator level
|
|
57
|
+
return null;
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Translate a comparison operator for column-to-column comparisons.
|
|
64
|
+
*/
|
|
65
|
+
function translateComparison(operator, lhs, rhs) {
|
|
66
|
+
switch (operator) {
|
|
67
|
+
case "equals":
|
|
68
|
+
return eq(lhs, rhs);
|
|
69
|
+
case "not_equals":
|
|
70
|
+
return not(eq(lhs, rhs));
|
|
71
|
+
case "greater_than":
|
|
72
|
+
case "is_after":
|
|
73
|
+
return gt(lhs, rhs);
|
|
74
|
+
case "less_than":
|
|
75
|
+
case "is_before":
|
|
76
|
+
return lt(lhs, rhs);
|
|
77
|
+
case "greater_or_equal":
|
|
78
|
+
return gte(lhs, rhs);
|
|
79
|
+
case "less_or_equal":
|
|
80
|
+
return lte(lhs, rhs);
|
|
81
|
+
default:
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=operator-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-map.js","sourceRoot":"","sources":["../src/operator-map.ts"],"names":[],"mappings":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C,GAAG,EAAE,GAAG,CAAC,CAAC;QACvB,KAAK,eAAe;YAClB,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACvB;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* query-translator.ts — Translates GridLite descriptors into TanStack DB query builder chains.
|
|
3
|
+
*
|
|
4
|
+
* Four pure functions that chain onto a BaseQueryBuilder:
|
|
5
|
+
* applyFilters — recursive FilterNode → and/or tree
|
|
6
|
+
* applyGlobalSearch — OR of ilike across columns
|
|
7
|
+
* applySorting — .orderBy() chain
|
|
8
|
+
* applyPagination — .limit().offset() (requires orderBy)
|
|
9
|
+
*/
|
|
10
|
+
import type { FilterNode, FilterLogic, SortConfig } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
11
|
+
type QueryChain = any;
|
|
12
|
+
/**
|
|
13
|
+
* Apply filter nodes to a query chain.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyFilters(chain: QueryChain, filters?: FilterNode[], filterLogic?: FilterLogic): QueryChain;
|
|
16
|
+
/**
|
|
17
|
+
* Apply global search (OR of ilike across columns).
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyGlobalSearch(chain: QueryChain, searchTerm?: string, searchColumns?: string[]): QueryChain;
|
|
20
|
+
/**
|
|
21
|
+
* Apply sorting to a query chain.
|
|
22
|
+
*/
|
|
23
|
+
export declare function applySorting(chain: QueryChain, sorting?: SortConfig[]): QueryChain;
|
|
24
|
+
/**
|
|
25
|
+
* Apply pagination (limit/offset) to a query chain.
|
|
26
|
+
* TanStack DB requires orderBy for limit/offset.
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyPagination(chain: QueryChain, page?: number, pageSize?: number, hasOrdering?: boolean, defaultSortColumn?: string): QueryChain;
|
|
29
|
+
/**
|
|
30
|
+
* Apply JSONB functional fallback filters via fn.where().
|
|
31
|
+
* These cannot be expressed in the D2 expression tree.
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyJsonbFilters(chain: QueryChain, filters?: FilterNode[]): QueryChain;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=query-translator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-translator.d.ts","sourceRoot":"","sources":["../src/query-translator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACX,MAAM,2CAA2C,CAAC;AAKnD,KAAK,UAAU,GAAG,GAAG,CAAC;AAItB;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,UAAU,EAAE,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,UAAU,CAkBZ;AAuCD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,UAAU,CAaZ;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,UAAU,EAAE,GACrB,UAAU,CAUZ;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,UAAU,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,OAAO,EACrB,iBAAiB,CAAC,EAAE,MAAM,GACzB,UAAU,CAcZ;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,UAAU,EAAE,GACrB,UAAU,CAoBZ"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* query-translator.ts — Translates GridLite descriptors into TanStack DB query builder chains.
|
|
3
|
+
*
|
|
4
|
+
* Four pure functions that chain onto a BaseQueryBuilder:
|
|
5
|
+
* applyFilters — recursive FilterNode → and/or tree
|
|
6
|
+
* applyGlobalSearch — OR of ilike across columns
|
|
7
|
+
* applySorting — .orderBy() chain
|
|
8
|
+
* applyPagination — .limit().offset() (requires orderBy)
|
|
9
|
+
*/
|
|
10
|
+
import { and, or, ilike, eq } from "@tanstack/db";
|
|
11
|
+
import { isFilterGroup } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
12
|
+
import { translateCondition } from "./operator-map.js";
|
|
13
|
+
/**
|
|
14
|
+
* Apply filter nodes to a query chain.
|
|
15
|
+
*/
|
|
16
|
+
export function applyFilters(chain, filters, filterLogic) {
|
|
17
|
+
if (!filters || filters.length === 0)
|
|
18
|
+
return chain;
|
|
19
|
+
const logic = filterLogic ?? "and";
|
|
20
|
+
return chain.where((ctx) => {
|
|
21
|
+
const source = ctx.source;
|
|
22
|
+
const expressions = filters
|
|
23
|
+
.map((node) => translateNode(node, source))
|
|
24
|
+
.filter((e) => e != null);
|
|
25
|
+
if (expressions.length === 0)
|
|
26
|
+
return eq(1, 1); // no-op true
|
|
27
|
+
if (expressions.length === 1)
|
|
28
|
+
return expressions[0];
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
return logic === "or"
|
|
31
|
+
? or(...expressions)
|
|
32
|
+
: and(...expressions);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Recursively translate a FilterNode into a TanStack DB expression.
|
|
37
|
+
*/
|
|
38
|
+
function translateNode(node, source) {
|
|
39
|
+
if (isFilterGroup(node)) {
|
|
40
|
+
const childExprs = node.children
|
|
41
|
+
.map((child) => translateNode(child, source))
|
|
42
|
+
.filter((e) => e != null);
|
|
43
|
+
if (childExprs.length === 0)
|
|
44
|
+
return null;
|
|
45
|
+
if (childExprs.length === 1)
|
|
46
|
+
return childExprs[0];
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
return node.logic === "or"
|
|
49
|
+
? or(...childExprs)
|
|
50
|
+
: and(...childExprs);
|
|
51
|
+
}
|
|
52
|
+
// Leaf condition
|
|
53
|
+
if (!node.field)
|
|
54
|
+
return null;
|
|
55
|
+
// JSONB operators need fn.where() fallback — skip in expression tree
|
|
56
|
+
if (node.operator === "jsonb_has_key" ||
|
|
57
|
+
node.operator === "jsonb_not_has_key") {
|
|
58
|
+
// Cannot express in D2 expression tree; handled separately
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const fieldRef = source[node.field];
|
|
62
|
+
return translateCondition(fieldRef, node, (colName) => source[colName]);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Apply global search (OR of ilike across columns).
|
|
66
|
+
*/
|
|
67
|
+
export function applyGlobalSearch(chain, searchTerm, searchColumns) {
|
|
68
|
+
if (!searchTerm || !searchColumns || searchColumns.length === 0)
|
|
69
|
+
return chain;
|
|
70
|
+
const pattern = `%${searchTerm}%`;
|
|
71
|
+
return chain.where((ctx) => {
|
|
72
|
+
const source = ctx.source;
|
|
73
|
+
const expressions = searchColumns.map((col) => ilike(source[col], pattern));
|
|
74
|
+
if (expressions.length === 0)
|
|
75
|
+
return eq(1, 1);
|
|
76
|
+
if (expressions.length === 1)
|
|
77
|
+
return expressions[0];
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
return or(...expressions);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Apply sorting to a query chain.
|
|
84
|
+
*/
|
|
85
|
+
export function applySorting(chain, sorting) {
|
|
86
|
+
if (!sorting || sorting.length === 0)
|
|
87
|
+
return chain;
|
|
88
|
+
for (const sort of sorting) {
|
|
89
|
+
chain = chain.orderBy((ctx) => ctx.source[sort.column], sort.direction === "desc" ? "desc" : "asc");
|
|
90
|
+
}
|
|
91
|
+
return chain;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Apply pagination (limit/offset) to a query chain.
|
|
95
|
+
* TanStack DB requires orderBy for limit/offset.
|
|
96
|
+
*/
|
|
97
|
+
export function applyPagination(chain, page, pageSize, hasOrdering, defaultSortColumn) {
|
|
98
|
+
if (page == null || pageSize == null)
|
|
99
|
+
return chain;
|
|
100
|
+
// TanStack DB requires orderBy for limit/offset
|
|
101
|
+
if (!hasOrdering && defaultSortColumn) {
|
|
102
|
+
chain = chain.orderBy((ctx) => ctx.source[defaultSortColumn]);
|
|
103
|
+
}
|
|
104
|
+
const offset = page * pageSize;
|
|
105
|
+
chain = chain.limit(pageSize);
|
|
106
|
+
if (offset > 0) {
|
|
107
|
+
chain = chain.offset(offset);
|
|
108
|
+
}
|
|
109
|
+
return chain;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Apply JSONB functional fallback filters via fn.where().
|
|
113
|
+
* These cannot be expressed in the D2 expression tree.
|
|
114
|
+
*/
|
|
115
|
+
export function applyJsonbFilters(chain, filters) {
|
|
116
|
+
if (!filters)
|
|
117
|
+
return chain;
|
|
118
|
+
const jsonbConditions = collectJsonbConditions(filters);
|
|
119
|
+
for (const cond of jsonbConditions) {
|
|
120
|
+
if (cond.operator === "jsonb_has_key") {
|
|
121
|
+
chain = chain.fn.where((row) => {
|
|
122
|
+
const obj = row.source[cond.field];
|
|
123
|
+
if (obj == null || typeof obj !== "object")
|
|
124
|
+
return false;
|
|
125
|
+
return String(cond.value) in obj;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else if (cond.operator === "jsonb_not_has_key") {
|
|
129
|
+
chain = chain.fn.where((row) => {
|
|
130
|
+
const obj = row.source[cond.field];
|
|
131
|
+
if (obj == null || typeof obj !== "object")
|
|
132
|
+
return true;
|
|
133
|
+
return !(String(cond.value) in obj);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return chain;
|
|
138
|
+
}
|
|
139
|
+
function collectJsonbConditions(nodes) {
|
|
140
|
+
const result = [];
|
|
141
|
+
for (const node of nodes) {
|
|
142
|
+
if (isFilterGroup(node)) {
|
|
143
|
+
result.push(...collectJsonbConditions(node.children));
|
|
144
|
+
}
|
|
145
|
+
else if (node.operator === "jsonb_has_key" ||
|
|
146
|
+
node.operator === "jsonb_not_has_key") {
|
|
147
|
+
result.push({
|
|
148
|
+
field: node.field,
|
|
149
|
+
operator: node.operator,
|
|
150
|
+
value: node.value,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=query-translator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-translator.js","sourceRoot":"","sources":["../src/query-translator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAe,EAAE,EAAE,MAAM,cAAc,CAAC;AAM/D,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAOvD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAiB,EACjB,OAAsB,EACtB,WAAyB;IAEzB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,MAAM,KAAK,GAAG,WAAW,IAAI,KAAK,CAAC;IAEnC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,GAAiB,EAAE,EAAE;QACvC,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QAC1B,MAAM,WAAW,GAAG,OAAO;aACxB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;aAC1C,MAAM,CAAC,CAAC,CAAC,EAA8B,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QAExD,IAAI,WAAW,CAAC,M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ACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schema.ts — Derive ColumnMetadata from Zod schemas or explicit column lists.
|
|
3
|
+
*
|
|
4
|
+
* Since TanStack DB collections don't have information_schema like Postgres,
|
|
5
|
+
* consumers must provide either explicit ColumnMetadata[] or a Zod schema
|
|
6
|
+
* from which we can derive column metadata at runtime.
|
|
7
|
+
*/
|
|
8
|
+
import type { ColumnMetadata } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
9
|
+
type ZodShape = Record<string, {
|
|
10
|
+
_def: {
|
|
11
|
+
typeName: string;
|
|
12
|
+
innerType?: {
|
|
13
|
+
_def: {
|
|
14
|
+
typeName: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
interface ZodObjectLike {
|
|
20
|
+
shape: ZodShape;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Derive ColumnMetadata[] from a Zod object schema.
|
|
24
|
+
*
|
|
25
|
+
* Maps Zod types to GridLite data types:
|
|
26
|
+
* ZodString → 'text'
|
|
27
|
+
* ZodNumber → 'number'
|
|
28
|
+
* ZodBoolean → 'boolean'
|
|
29
|
+
* ZodDate → 'date'
|
|
30
|
+
* ZodObject → 'json'
|
|
31
|
+
* ZodArray → 'json'
|
|
32
|
+
* ZodEnum → 'text'
|
|
33
|
+
* (other) → 'text'
|
|
34
|
+
*/
|
|
35
|
+
export declare function deriveColumnsFromZodSchema(schema: ZodObjectLike): ColumnMetadata[];
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,2CAA2C,CAAC;AAInD,KAAK,QAAQ,GAAG,MAAM,CACpB,MAAM,EACN;IAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE;gBAAE,QAAQ,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,CAC3E,CAAC;AAEF,UAAU,aAAa;IACrB,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,GACpB,cAAc,EAAE,CAgBlB"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schema.ts — Derive ColumnMetadata from Zod schemas or explicit column lists.
|
|
3
|
+
*
|
|
4
|
+
* Since TanStack DB collections don't have information_schema like Postgres,
|
|
5
|
+
* consumers must provide either explicit ColumnMetadata[] or a Zod schema
|
|
6
|
+
* from which we can derive column metadata at runtime.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Derive ColumnMetadata[] from a Zod object schema.
|
|
10
|
+
*
|
|
11
|
+
* Maps Zod types to GridLite data types:
|
|
12
|
+
* ZodString → 'text'
|
|
13
|
+
* ZodNumber → 'number'
|
|
14
|
+
* ZodBoolean → 'boolean'
|
|
15
|
+
* ZodDate → 'date'
|
|
16
|
+
* ZodObject → 'json'
|
|
17
|
+
* ZodArray → 'json'
|
|
18
|
+
* ZodEnum → 'text'
|
|
19
|
+
* (other) → 'text'
|
|
20
|
+
*/
|
|
21
|
+
export function deriveColumnsFromZodSchema(schema) {
|
|
22
|
+
const shape = schema.shape;
|
|
23
|
+
const columns = [];
|
|
24
|
+
for (const [name, field] of Object.entries(shape)) {
|
|
25
|
+
const { dataType, nullable } = resolveZodType(field._def);
|
|
26
|
+
columns.push({
|
|
27
|
+
name,
|
|
28
|
+
dataType,
|
|
29
|
+
postgresType: "unknown",
|
|
30
|
+
nullable,
|
|
31
|
+
hasDefault: false,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return columns;
|
|
35
|
+
}
|
|
36
|
+
function resolveZodType(def) {
|
|
37
|
+
const typeName = def.typeName;
|
|
38
|
+
// Unwrap optional/nullable wrappers
|
|
39
|
+
if (typeName === "ZodOptional" || typeName === "ZodNullable") {
|
|
40
|
+
if (def.innerType) {
|
|
41
|
+
const inner = resolveZodType(def.innerType._def);
|
|
42
|
+
return { ...inner, nullable: true };
|
|
43
|
+
}
|
|
44
|
+
return { dataType: "text", nullable: true };
|
|
45
|
+
}
|
|
46
|
+
// Unwrap default
|
|
47
|
+
if (typeName === "ZodDefault") {
|
|
48
|
+
if (def.innerType) {
|
|
49
|
+
return resolveZodType(def.innerType._def);
|
|
50
|
+
}
|
|
51
|
+
return { dataType: "text", nullable: false };
|
|
52
|
+
}
|
|
53
|
+
switch (typeName) {
|
|
54
|
+
case "ZodString":
|
|
55
|
+
return { dataType: "text", nullable: false };
|
|
56
|
+
case "ZodNumber":
|
|
57
|
+
case "ZodBigInt":
|
|
58
|
+
return { dataType: "number", nullable: false };
|
|
59
|
+
case "ZodBoolean":
|
|
60
|
+
return { dataType: "boolean", nullable: false };
|
|
61
|
+
case "ZodDate":
|
|
62
|
+
return { dataType: "date", nullable: false };
|
|
63
|
+
case "ZodObject":
|
|
64
|
+
case "ZodArray":
|
|
65
|
+
case "ZodRecord":
|
|
66
|
+
return { dataType: "json", nullable: false };
|
|
67
|
+
case "ZodEnum":
|
|
68
|
+
case "ZodNativeEnum":
|
|
69
|
+
return { dataType: "text", nullable: false };
|
|
70
|
+
default:
|
|
71
|
+
return { dataType: "text", nullable: false };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;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AE,CAAC;IAC/C,CAAC;IAED,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC/C,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACjD,KAAK,YAAY;YACf,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAClD,KAAK,SAAS;YACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC/C,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC/C,KAAK,SAAS,CAAC;QACf,KAAK,eAAe;YAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC/C;YACE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ColumnStateEntry } from "@shotleybuilder/svelte-gridlite-kit/adapter";
|
|
2
|
+
import type { ViewPreset } from "@shotleybuilder/svelte-gridlite-kit/types";
|
|
3
|
+
/**
|
|
4
|
+
* StorageProvider — pluggable persistence for view/column state.
|
|
5
|
+
*
|
|
6
|
+
* TanStack DB has no SQL backend, so we abstract state persistence
|
|
7
|
+
* behind this interface. Two built-in implementations:
|
|
8
|
+
* - InMemoryStorage (default, ephemeral)
|
|
9
|
+
* - LocalStorageProvider (persists to window.localStorage)
|
|
10
|
+
*/
|
|
11
|
+
export interface StorageProvider {
|
|
12
|
+
loadColumnState(gridId: string, viewId?: string): Promise<ColumnStateEntry[]>;
|
|
13
|
+
saveColumnState(gridId: string, columns: ColumnStateEntry[], viewId?: string): Promise<void>;
|
|
14
|
+
saveView(gridId: string, view: ViewPreset): Promise<void>;
|
|
15
|
+
loadView(viewId: string): Promise<ViewPreset | null>;
|
|
16
|
+
loadViews(gridId: string): Promise<ViewPreset[]>;
|
|
17
|
+
deleteView(viewId: string): Promise<void>;
|
|
18
|
+
loadDefaultView(gridId: string): Promise<ViewPreset | null>;
|
|
19
|
+
setDefaultView(gridId: string, viewId: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare class InMemoryStorage implements StorageProvider {
|
|
22
|
+
private columnState;
|
|
23
|
+
private views;
|
|
24
|
+
private viewsByGrid;
|
|
25
|
+
private defaults;
|
|
26
|
+
private colKey;
|
|
27
|
+
loadColumnState(gridId: string, viewId?: string): Promise<ColumnStateEntry[]>;
|
|
28
|
+
saveColumnState(gridId: string, columns: ColumnStateEntry[], viewId?: string): Promise<void>;
|
|
29
|
+
saveView(gridId: string, view: ViewPreset): Promise<void>;
|
|
30
|
+
loadView(viewId: string): Promise<ViewPreset | null>;
|
|
31
|
+
loadViews(gridId: string): Promise<ViewPreset[]>;
|
|
32
|
+
deleteView(viewId: string): Promise<void>;
|
|
33
|
+
loadDefaultView(gridId: string): Promise<ViewPreset | null>;
|
|
34
|
+
setDefaultView(gridId: string, viewId: string): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export declare class LocalStorageProvider implements StorageProvider {
|
|
37
|
+
private prefix;
|
|
38
|
+
constructor(prefix?: string);
|
|
39
|
+
private key;
|
|
40
|
+
private getJSON;
|
|
41
|
+
private setJSON;
|
|
42
|
+
loadColumnState(gridId: string, viewId?: string): Promise<ColumnStateEntry[]>;
|
|
43
|
+
saveColumnState(gridId: string, columns: ColumnStateEntry[], viewId?: string): Promise<void>;
|
|
44
|
+
saveView(gridId: string, view: ViewPreset): Promise<void>;
|
|
45
|
+
loadView(viewId: string): Promise<ViewPreset | null>;
|
|
46
|
+
loadViews(gridId: string): Promise<ViewPreset[]>;
|
|
47
|
+
deleteView(viewId: string): Promise<void>;
|
|
48
|
+
loadDefaultView(gridId: string): Promise<ViewPreset | null>;
|
|
49
|
+
setDefaultView(gridId: string, viewId: string): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AAE5E;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC9E,eAAe,CACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EAAE,EAC3B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACrD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACjD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC5D,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,O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,MAAM,EACd,OAAO,EAAE,gBAAgB,EAAE,EAC3B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAOV,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAIpD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAUhD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BzC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAM3D,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpE"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// ─── InMemoryStorage ──────────────────────────────────────────────────────────
|
|
2
|
+
export class InMemoryStorage {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.columnState = new Map();
|
|
5
|
+
this.views = new Map();
|
|
6
|
+
this.viewsByGrid = new Map();
|
|
7
|
+
this.defaults = new Map();
|
|
8
|
+
}
|
|
9
|
+
colKey(gridId, viewId) {
|
|
10
|
+
return viewId ? `${gridId}::${viewId}` : gridId;
|
|
11
|
+
}
|
|
12
|
+
async loadColumnState(gridId, viewId) {
|
|
13
|
+
return this.columnState.get(this.colKey(gridId, viewId)) ?? [];
|
|
14
|
+
}
|
|
15
|
+
async saveColumnState(gridId, columns, viewId) {
|
|
16
|
+
this.columnState.set(this.colKey(gridId, viewId), columns);
|
|
17
|
+
}
|
|
18
|
+
async saveView(gridId, view) {
|
|
19
|
+
this.views.set(view.id, view);
|
|
20
|
+
const set = this.viewsByGrid.get(gridId) ?? new Set();
|
|
21
|
+
set.add(view.id);
|
|
22
|
+
this.viewsByGrid.set(gridId, set);
|
|
23
|
+
}
|
|
24
|
+
async loadView(viewId) {
|
|
25
|
+
return this.views.get(viewId) ?? null;
|
|
26
|
+
}
|
|
27
|
+
async loadViews(gridId) {
|
|
28
|
+
const ids = this.viewsByGrid.get(gridId);
|
|
29
|
+
if (!ids)
|
|
30
|
+
return [];
|
|
31
|
+
const views = [];
|
|
32
|
+
for (const id of ids) {
|
|
33
|
+
const v = this.views.get(id);
|
|
34
|
+
if (v)
|
|
35
|
+
views.push(v);
|
|
36
|
+
}
|
|
37
|
+
return views.sort((a, b) => a.name.localeCompare(b.name));
|
|
38
|
+
}
|
|
39
|
+
async deleteView(viewId) {
|
|
40
|
+
const view = this.views.get(viewId);
|
|
41
|
+
this.views.delete(viewId);
|
|
42
|
+
// Remove from grid index
|
|
43
|
+
for (const [, set] of this.viewsByGrid) {
|
|
44
|
+
set.delete(viewId);
|
|
45
|
+
}
|
|
46
|
+
// Remove associated column state
|
|
47
|
+
if (view) {
|
|
48
|
+
// Delete view-scoped column state for all grids
|
|
49
|
+
for (const key of this.columnState.keys()) {
|
|
50
|
+
if (key.endsWith(`::${viewId}`)) {
|
|
51
|
+
this.columnState.delete(key);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.columnState.delete(viewId);
|
|
56
|
+
// Remove default if this was the default
|
|
57
|
+
for (const [gridId, defaultId] of this.defaults) {
|
|
58
|
+
if (defaultId === viewId)
|
|
59
|
+
this.defaults.delete(gridId);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async loadDefaultView(gridId) {
|
|
63
|
+
const viewId = this.defaults.get(gridId);
|
|
64
|
+
if (!viewId)
|
|
65
|
+
return null;
|
|
66
|
+
return this.views.get(viewId) ?? null;
|
|
67
|
+
}
|
|
68
|
+
async setDefaultView(gridId, viewId) {
|
|
69
|
+
this.defaults.set(gridId, viewId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// ─── LocalStorageProvider ─────────────────────────────────────────────────────
|
|
73
|
+
export class LocalStorageProvider {
|
|
74
|
+
constructor(prefix = "gridlite") {
|
|
75
|
+
this.prefix = prefix;
|
|
76
|
+
}
|
|
77
|
+
key(...parts) {
|
|
78
|
+
return [this.prefix, ...parts].join(":");
|
|
79
|
+
}
|
|
80
|
+
getJSON(key) {
|
|
81
|
+
try {
|
|
82
|
+
const raw = localStorage.getItem(key);
|
|
83
|
+
return raw ? JSON.parse(raw) : null;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
setJSON(key, value) {
|
|
90
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
91
|
+
}
|
|
92
|
+
async loadColumnState(gridId, viewId) {
|
|
93
|
+
const k = viewId
|
|
94
|
+
? this.key("colstate", gridId, viewId)
|
|
95
|
+
: this.key("colstate", gridId);
|
|
96
|
+
return this.getJSON(k) ?? [];
|
|
97
|
+
}
|
|
98
|
+
async saveColumnState(gridId, columns, viewId) {
|
|
99
|
+
const k = viewId
|
|
100
|
+
? this.key("colstate", gridId, viewId)
|
|
101
|
+
: this.key("colstate", gridId);
|
|
102
|
+
this.setJSON(k, columns);
|
|
103
|
+
}
|
|
104
|
+
async saveView(gridId, view) {
|
|
105
|
+
this.setJSON(this.key("view", view.id), view);
|
|
106
|
+
// Track view IDs per grid
|
|
107
|
+
const indexKey = this.key("viewindex", gridId);
|
|
108
|
+
const ids = this.getJSON(indexKey) ?? [];
|
|
109
|
+
if (!ids.includes(view.id)) {
|
|
110
|
+
ids.push(view.id);
|
|
111
|
+
this.setJSON(indexKey, ids);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async loadView(viewId) {
|
|
115
|
+
return this.getJSON(this.key("view", viewId));
|
|
116
|
+
}
|
|
117
|
+
async loadViews(gridId) {
|
|
118
|
+
const ids = this.getJSON(this.key("viewindex", gridId)) ?? [];
|
|
119
|
+
const views = [];
|
|
120
|
+
for (const id of ids) {
|
|
121
|
+
const v = this.getJSON(this.key("view", id));
|
|
122
|
+
if (v)
|
|
123
|
+
views.push(v);
|
|
124
|
+
}
|
|
125
|
+
return views.sort((a, b) => a.name.localeCompare(b.name));
|
|
126
|
+
}
|
|
127
|
+
async deleteView(viewId) {
|
|
128
|
+
localStorage.removeItem(this.key("view", viewId));
|
|
129
|
+
// Remove from all grid indexes
|
|
130
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
131
|
+
const k = localStorage.key(i);
|
|
132
|
+
if (k?.startsWith(this.key("viewindex"))) {
|
|
133
|
+
const ids = this.getJSON(k) ?? [];
|
|
134
|
+
const filtered = ids.filter((id) => id !== viewId);
|
|
135
|
+
if (filtered.length !== ids.length) {
|
|
136
|
+
this.setJSON(k, filtered);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Remove associated column state keys
|
|
141
|
+
for (let i = localStorage.length - 1; i >= 0; i--) {
|
|
142
|
+
const k = localStorage.key(i);
|
|
143
|
+
if (k?.startsWith(this.key("colstate")) && k.endsWith(viewId)) {
|
|
144
|
+
localStorage.removeItem(k);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Remove default if this was the default
|
|
148
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
149
|
+
const k = localStorage.key(i);
|
|
150
|
+
if (k?.startsWith(this.key("default"))) {
|
|
151
|
+
const val = localStorage.getItem(k);
|
|
152
|
+
if (val === viewId)
|
|
153
|
+
localStorage.removeItem(k);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async loadDefaultView(gridId) {
|
|
158
|
+
const viewId = localStorage.getItem(this.key("default", gridId));
|
|
159
|
+
if (!viewId)
|
|
160
|
+
return null;
|
|
161
|
+
return this.getJSON(this.key("view", viewId));
|
|
162
|
+
}
|
|
163
|
+
async setDefaultView(gridId, viewId) {
|
|
164
|
+
localStorage.setItem(this.key("default", gridId), viewId);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AA0BA,iFAAiF;AAEjF,MAAM,OAAO,eAAe;IAA5B;QACU,gBAAW,GAAG,IAAI,GAAG,EAA8B,CAAC;QACpD,UAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;QACtC,gBAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC7C,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IA2E/C,CAAC;IAzES,MAAM,CAAC,MAAc,EAAE,MAAe;QAC5C,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,MAAc,EACd,MAAe;QAEf,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,MAAc,EACd,OAA2B,EAC3B,MAAe;QAEf,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,IAAgB;QAC7C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;QACtD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,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AY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACpC,IAAI,GAAG,KAAK,MAAM;oBAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAAc;QAClC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,CAAa,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,MAAc;QACjD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shotleybuilder/gridlite-adapter-tanstack-db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "TanStack DB adapter for svelte-gridlite-kit",
|
|
5
5
|
"author": "Sertantai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@tanstack/db": ">=0.5.0",
|
|
27
|
-
"@shotleybuilder/svelte-gridlite-kit": "0.5.
|
|
27
|
+
"@shotleybuilder/svelte-gridlite-kit": "^0.5.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@tanstack/db": "^0.6.0",
|
|
31
31
|
"typescript": "^5.0.0",
|
|
32
32
|
"vitest": "^2.0.0",
|
|
33
33
|
"zod": "^3.23.0",
|
|
34
|
-
"@shotleybuilder/svelte-gridlite-kit": "0.5.
|
|
34
|
+
"@shotleybuilder/svelte-gridlite-kit": "^0.5.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc",
|