simplesvelte 2.2.11 → 2.2.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplesvelte",
3
- "version": "2.2.11",
3
+ "version": "2.2.13",
4
4
  "scripts": {
5
5
  "dev": "bun vite dev",
6
6
  "build": "bun vite build && bun run prepack",
package/dist/ag-grid.d.ts DELETED
@@ -1,551 +0,0 @@
1
- /**
2
- * AG Grid Server-Side Row Model (SSRM) - Server-Side Implementation API
3
- *
4
- * This module provides a clean, strongly-typed interface for implementing
5
- * AG Grid's Server-Side Row Model on the backend with any data source.
6
- *
7
- * @example Server-Side Usage (SvelteKit Remote Function)
8
- * ```typescript
9
- * import { createAGGridQuery, agGridRequestSchema } from './ag-grid'
10
- * import { query } from '$app/server'
11
- *
12
- * export const getUsersPaginated = query(agGridRequestSchema, async (request) => {
13
- * return await createAGGridQuery({
14
- * async fetch(params) {
15
- * // Your data fetching logic
16
- * const users = await DB.user.findMany({
17
- * where: params.where,
18
- * orderBy: params.orderBy,
19
- * skip: params.skip,
20
- * take: params.take,
21
- * })
22
- * return users
23
- * },
24
- * async count(params) {
25
- * return await DB.user.count({ where: params.where })
26
- * }
27
- * })(request)
28
- * })
29
- * ```
30
- */
31
- import type { IServerSideDatasource } from 'ag-grid-enterprise';
32
- import { z } from 'zod';
33
- /**
34
- * Column configuration from AG Grid
35
- */
36
- export interface AGGridColumn {
37
- id: string;
38
- displayName: string;
39
- field?: string;
40
- aggFunc?: string;
41
- }
42
- /**
43
- * Sort configuration
44
- */
45
- export interface AGGridSort {
46
- colId: string;
47
- sort: 'asc' | 'desc';
48
- }
49
- /**
50
- * Filter model from AG Grid
51
- * This is a simplified type - actual filters can be more complex
52
- */
53
- export type AGGridFilterModel = Record<string, unknown>;
54
- /**
55
- * Request parameters sent from AG Grid to the data fetcher
56
- */
57
- export interface AGGridRequest {
58
- /** Starting row index (0-based) */
59
- startRow?: number;
60
- /** Ending row index (exclusive) */
61
- endRow?: number;
62
- /** Current filter configuration */
63
- filterModel?: AGGridFilterModel;
64
- /** Current sort configuration */
65
- sortModel: AGGridSort[];
66
- /** Columns being used for row grouping */
67
- rowGroupCols: AGGridColumn[];
68
- /** Current group keys for drill-down */
69
- groupKeys: string[];
70
- /** Columns with aggregation functions */
71
- valueCols: AGGridColumn[];
72
- /** Columns being pivoted */
73
- pivotCols: AGGridColumn[];
74
- /** Whether pivot mode is enabled */
75
- pivotMode: boolean;
76
- }
77
- /**
78
- * Response from the data fetcher back to AG Grid
79
- */
80
- export interface AGGridResponse<TData = unknown> {
81
- /** The row data for this request */
82
- rows: TData[];
83
- /**
84
- * Total number of rows available (for pagination)
85
- * - For leaf-level data: total count matching the filter
86
- * - For group rows: number of groups at this level
87
- * - If undefined, AG Grid assumes all rows have been loaded
88
- */
89
- lastRow?: number;
90
- /** Optional metadata for group levels */
91
- groupLevelInfo?: unknown;
92
- /** Pivot result fields (for pivot mode) */
93
- pivotResultFields?: string[];
94
- }
95
- /**
96
- * Data fetcher function type
97
- * Implement this to connect AG Grid to your backend
98
- */
99
- export type AGGridDataFetcher<TData = unknown> = (request: AGGridRequest) => Promise<AGGridResponse<TData>>;
100
- /**
101
- * Options for datasource creation
102
- */
103
- export interface AGGridDatasourceOptions {
104
- /** Called when a request fails */
105
- onError?: (error: unknown) => void;
106
- /** Called before each request is made */
107
- onBeforeRequest?: (request: AGGridRequest) => void;
108
- /** Called after each successful response */
109
- onAfterResponse?: (response: AGGridResponse) => void;
110
- /** Enable debug logging */
111
- debug?: boolean;
112
- }
113
- /**
114
- * Zod schema for AG Grid column configuration
115
- */
116
- export declare const agGridColumnSchema: z.ZodObject<{
117
- id: z.ZodString;
118
- displayName: z.ZodString;
119
- field: z.ZodOptional<z.ZodString>;
120
- aggFunc: z.ZodOptional<z.ZodString>;
121
- }, "strip", z.ZodTypeAny, {
122
- id: string;
123
- displayName: string;
124
- field?: string | undefined;
125
- aggFunc?: string | undefined;
126
- }, {
127
- id: string;
128
- displayName: string;
129
- field?: string | undefined;
130
- aggFunc?: string | undefined;
131
- }>;
132
- /**
133
- * Zod schema for AG Grid sort configuration
134
- */
135
- export declare const agGridSortSchema: z.ZodObject<{
136
- colId: z.ZodString;
137
- sort: z.ZodEnum<["asc", "desc"]>;
138
- }, "strip", z.ZodTypeAny, {
139
- sort: "asc" | "desc";
140
- colId: string;
141
- }, {
142
- sort: "asc" | "desc";
143
- colId: string;
144
- }>;
145
- /**
146
- * Zod schema for AG Grid request
147
- * Use this in your remote function schema: query(agGridRequestSchema, async (request) => ...)
148
- */
149
- export declare const agGridRequestSchema: z.ZodObject<{
150
- startRow: z.ZodOptional<z.ZodNumber>;
151
- endRow: z.ZodOptional<z.ZodNumber>;
152
- filterModel: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
153
- sortModel: z.ZodArray<z.ZodObject<{
154
- colId: z.ZodString;
155
- sort: z.ZodEnum<["asc", "desc"]>;
156
- }, "strip", z.ZodTypeAny, {
157
- sort: "asc" | "desc";
158
- colId: string;
159
- }, {
160
- sort: "asc" | "desc";
161
- colId: string;
162
- }>, "many">;
163
- rowGroupCols: z.ZodArray<z.ZodObject<{
164
- id: z.ZodString;
165
- displayName: z.ZodString;
166
- field: z.ZodOptional<z.ZodString>;
167
- aggFunc: z.ZodOptional<z.ZodString>;
168
- }, "strip", z.ZodTypeAny, {
169
- id: string;
170
- displayName: string;
171
- field?: string | undefined;
172
- aggFunc?: string | undefined;
173
- }, {
174
- id: string;
175
- displayName: string;
176
- field?: string | undefined;
177
- aggFunc?: string | undefined;
178
- }>, "many">;
179
- groupKeys: z.ZodArray<z.ZodString, "many">;
180
- valueCols: z.ZodArray<z.ZodObject<{
181
- id: z.ZodString;
182
- displayName: z.ZodString;
183
- field: z.ZodOptional<z.ZodString>;
184
- aggFunc: z.ZodOptional<z.ZodString>;
185
- }, "strip", z.ZodTypeAny, {
186
- id: string;
187
- displayName: string;
188
- field?: string | undefined;
189
- aggFunc?: string | undefined;
190
- }, {
191
- id: string;
192
- displayName: string;
193
- field?: string | undefined;
194
- aggFunc?: string | undefined;
195
- }>, "many">;
196
- pivotCols: z.ZodArray<z.ZodObject<{
197
- id: z.ZodString;
198
- displayName: z.ZodString;
199
- field: z.ZodOptional<z.ZodString>;
200
- aggFunc: z.ZodOptional<z.ZodString>;
201
- }, "strip", z.ZodTypeAny, {
202
- id: string;
203
- displayName: string;
204
- field?: string | undefined;
205
- aggFunc?: string | undefined;
206
- }, {
207
- id: string;
208
- displayName: string;
209
- field?: string | undefined;
210
- aggFunc?: string | undefined;
211
- }>, "many">;
212
- pivotMode: z.ZodBoolean;
213
- }, "strip", z.ZodTypeAny, {
214
- pivotMode: boolean;
215
- sortModel: {
216
- sort: "asc" | "desc";
217
- colId: string;
218
- }[];
219
- rowGroupCols: {
220
- id: string;
221
- displayName: string;
222
- field?: string | undefined;
223
- aggFunc?: string | undefined;
224
- }[];
225
- groupKeys: string[];
226
- valueCols: {
227
- id: string;
228
- displayName: string;
229
- field?: string | undefined;
230
- aggFunc?: string | undefined;
231
- }[];
232
- pivotCols: {
233
- id: string;
234
- displayName: string;
235
- field?: string | undefined;
236
- aggFunc?: string | undefined;
237
- }[];
238
- startRow?: number | undefined;
239
- endRow?: number | undefined;
240
- filterModel?: Record<string, unknown> | undefined;
241
- }, {
242
- pivotMode: boolean;
243
- sortModel: {
244
- sort: "asc" | "desc";
245
- colId: string;
246
- }[];
247
- rowGroupCols: {
248
- id: string;
249
- displayName: string;
250
- field?: string | undefined;
251
- aggFunc?: string | undefined;
252
- }[];
253
- groupKeys: string[];
254
- valueCols: {
255
- id: string;
256
- displayName: string;
257
- field?: string | undefined;
258
- aggFunc?: string | undefined;
259
- }[];
260
- pivotCols: {
261
- id: string;
262
- displayName: string;
263
- field?: string | undefined;
264
- aggFunc?: string | undefined;
265
- }[];
266
- startRow?: number | undefined;
267
- endRow?: number | undefined;
268
- filterModel?: Record<string, unknown> | undefined;
269
- }>;
270
- /**
271
- * Parsed query parameters from AG Grid request
272
- * This is what you'll use to query your database
273
- */
274
- export interface AGGridQueryParams<TWhereInput = Record<string, unknown>> {
275
- /** WHERE clause for filtering */
276
- where: TWhereInput;
277
- /** ORDER BY clause for sorting (use Record<string, unknown>[] for Prisma compatibility) */
278
- orderBy: Record<string, unknown>[];
279
- /** Number of rows to skip (for pagination) */
280
- skip: number;
281
- /** Number of rows to take (for pagination) */
282
- take: number;
283
- /** Current grouping level (for row grouping) */
284
- groupLevel: number;
285
- /** Group keys for drill-down */
286
- groupKeys: string[];
287
- /** Column being grouped at current level */
288
- groupColumn?: AGGridColumn;
289
- /** Whether this is a group request or leaf data request */
290
- isGroupRequest: boolean;
291
- }
292
- /**
293
- * Configuration for a computed/virtual field
294
- *
295
- * Use this ONLY for truly computed/calculated values, not for simple nested relations.
296
- *
297
- * For nested relations (e.g., showing 'location.name'), use dot notation directly in
298
- * your column definitions instead:
299
- * { field: 'location.name', headerName: 'Location' }
300
- *
301
- * computedFields are for complex calculations like:
302
- * - Week ending dates calculated from another date field
303
- * - Full names concatenated from firstName + lastName
304
- * - Custom aggregations or transformations
305
- */
306
- export interface ComputedField<TRecord = unknown, TWhereInput = Record<string, unknown>> {
307
- /** Column ID in AG Grid */
308
- columnId: string;
309
- /**
310
- * Database field to use for sorting/filtering (for simple nested fields)
311
- * Only use this with computedFields if you need a custom field name.
312
- * Otherwise, use dot notation directly in column definitions.
313
- */
314
- dbField?: string;
315
- /**
316
- * Custom function to compute the value for display
317
- * Required for complex calculations.
318
- */
319
- valueGetter?: (record: TRecord) => unknown;
320
- /**
321
- * Custom filter handler
322
- * Required for complex computed fields that need custom filter logic.
323
- */
324
- filterHandler?: (filterValue: unknown, where: TWhereInput) => void;
325
- /**
326
- * Custom group filter handler
327
- * Required for complex computed fields that need custom grouping logic.
328
- */
329
- groupHandler?: (groupKey: string, where: TWhereInput) => void;
330
- }
331
- /**
332
- * Configuration for AG Grid query builder
333
- */
334
- export interface AGGridQueryConfig<TRecord = unknown, TWhereInput = Record<string, unknown>> {
335
- /** Function to fetch data rows */
336
- fetch: (params: AGGridQueryParams<TWhereInput>) => Promise<TRecord[]>;
337
- /** Function to count total rows */
338
- count: (params: AGGridQueryParams<TWhereInput>) => Promise<number>;
339
- /** Optional: Computed/virtual fields configuration */
340
- computedFields?: ComputedField<TRecord, TWhereInput>[];
341
- /** Optional: Default sort when no sort specified */
342
- defaultSort?: Record<string, 'asc' | 'desc'>;
343
- /** Optional: Transform where clause before query */
344
- transformWhere?: (where: TWhereInput, request: AGGridRequest) => TWhereInput;
345
- }
346
- /**
347
- * Creates an AG Grid query handler for server-side data fetching
348
- *
349
- * This is the main server-side API. Use this in your remote functions or API endpoints
350
- * to handle AG Grid requests with any database/data source.
351
- *
352
- * @param config - Configuration for data fetching and field mappings
353
- * @returns Function that processes AG Grid requests and returns responses
354
- *
355
- * @example Basic Prisma Usage
356
- * ```typescript
357
- * export const getUsersPaginated = query(agGridRequestSchema, async (request) => {
358
- * return await createAGGridQuery({
359
- * async fetch(params) {
360
- * return await DB.user.findMany({
361
- * where: params.where,
362
- * orderBy: params.orderBy,
363
- * skip: params.skip,
364
- * take: params.take,
365
- * })
366
- * },
367
- * async count(params) {
368
- * return await DB.user.count({ where: params.where })
369
- * },
370
- * defaultSort: { createdAt: 'desc' }
371
- * })(request)
372
- * })
373
- * ```
374
- *
375
- * @example With Nested Relations (Use Dot Notation)
376
- * ```typescript
377
- * // Server-side - just include the relation
378
- * return await createAGGridQuery({
379
- * async fetch(params) {
380
- * return await DB.intervention.findMany({
381
- * where: params.where,
382
- * orderBy: params.orderBy,
383
- * skip: params.skip,
384
- * take: params.take,
385
- * include: { location: true }
386
- * })
387
- * },
388
- * async count(params) {
389
- * return await DB.intervention.count({ where: params.where })
390
- * }
391
- * })(request)
392
- *
393
- * // Client-side - use dot notation in column definitions
394
- * const columnDefs = [
395
- * { field: 'id' },
396
- * { field: 'location.name', headerName: 'Location', filter: 'agTextColumnFilter' },
397
- * ]
398
- * // That's it! Auto-handles display, filtering, sorting, and grouping
399
- * ```
400
- *
401
- * @example With Computed Fields (Complex Calculations)
402
- * ```typescript
403
- * return await createAGGridQuery({
404
- * async fetch(params) {
405
- * return await DB.intervention.findMany({
406
- * where: params.where,
407
- * orderBy: params.orderBy,
408
- * skip: params.skip,
409
- * take: params.take,
410
- * })
411
- * },
412
- * async count(params) {
413
- * return await DB.intervention.count({ where: params.where })
414
- * },
415
- * computedFields: [
416
- * {
417
- * // Complex computed field - provide custom handlers
418
- * columnId: 'weekEnding',
419
- * valueGetter: (record) => calculateWeekEnding(record.date),
420
- * filterHandler: (filterValue, where) => {
421
- * // Custom filter logic for week ending
422
- * }
423
- * }
424
- * ]
425
- * })(request)
426
- * ```
427
- */
428
- export declare function createAGGridQuery<TRecord = unknown, TWhereInput = Record<string, unknown>>(config: AGGridQueryConfig<TRecord, TWhereInput>): (request: AGGridRequest) => Promise<AGGridResponse<TRecord>>;
429
- /**
430
- * Creates an AG Grid server-side datasource from a data fetcher function
431
- *
432
- * This is the main entry point for implementing SSRM. Simply provide a function
433
- * that fetches data based on AG Grid's request, and this handles all the
434
- * AG Grid datasource protocol.
435
- *
436
- * @param fetcher - Function that fetches data based on AG Grid's request
437
- * @param options - Optional configuration for error handling and logging
438
- * @returns IServerSideDatasource compatible with AG Grid
439
- *
440
- * @example
441
- * ```typescript
442
- * const datasource = createAGGridDatasource(async (request) => {
443
- * const { startRow, endRow, filterModel, sortModel } = request
444
- *
445
- * // Your data fetching logic here
446
- * const data = await fetchFromAPI({
447
- * offset: startRow,
448
- * limit: endRow - startRow,
449
- * filters: filterModel,
450
- * sorts: sortModel
451
- * })
452
- *
453
- * return {
454
- * rows: data.items,
455
- * lastRow: data.total
456
- * }
457
- * })
458
- * ```
459
- */
460
- export declare function createAGGridDatasource<TData = unknown>(fetcher: AGGridDataFetcher<TData>, options?: AGGridDatasourceOptions): IServerSideDatasource<TData>;
461
- /**
462
- * Checks if the current request is for leaf-level data (not groups)
463
- *
464
- * @param request - AG Grid request
465
- * @returns true if requesting leaf data, false if requesting groups
466
- */
467
- export declare function isLeafDataRequest(request: AGGridRequest): boolean;
468
- /**
469
- * Gets the current grouping level (0-based)
470
- *
471
- * @param request - AG Grid request
472
- * @returns Current group level, or -1 if not grouping
473
- */
474
- export declare function getCurrentGroupLevel(request: AGGridRequest): number;
475
- /**
476
- * Gets the column being grouped at the current level
477
- *
478
- * @param request - AG Grid request
479
- * @returns Column configuration for current group level, or undefined
480
- */
481
- export declare function getCurrentGroupColumn(request: AGGridRequest): AGGridColumn | undefined;
482
- /**
483
- * Default column definition for SSRM grids
484
- */
485
- export declare const defaultSSRMColDef: import('ag-grid-community').ColDef;
486
- /**
487
- * Default grid options for SSRM
488
- */
489
- export declare const defaultSSRMGridOptions: Partial<import('ag-grid-community').GridOptions>;
490
- /**
491
- * Predefined filter configurations for common column types
492
- */
493
- export declare const filterConfigs: {
494
- /** Text column with text filter */
495
- readonly text: {
496
- readonly filter: "agTextColumnFilter";
497
- readonly filterParams: {
498
- readonly buttons: readonly ["clear"];
499
- readonly suppressAndOrCondition: true;
500
- };
501
- };
502
- /** Number column with number filter */
503
- readonly number: {
504
- readonly filter: "agNumberColumnFilter";
505
- readonly filterParams: {
506
- readonly buttons: readonly ["clear"];
507
- readonly suppressAndOrCondition: true;
508
- };
509
- };
510
- /** Date column with date filter */
511
- readonly date: {
512
- readonly filter: "agDateColumnFilter";
513
- readonly filterParams: {
514
- readonly buttons: readonly ["clear"];
515
- readonly suppressAndOrCondition: true;
516
- };
517
- };
518
- /** Date range filter (for start dates) */
519
- readonly startDate: {
520
- readonly filter: "agDateColumnFilter";
521
- readonly filterParams: {
522
- readonly buttons: readonly ["clear"];
523
- readonly suppressAndOrCondition: true;
524
- readonly filterOptions: readonly ["greaterThan", "inRange"];
525
- };
526
- };
527
- /** Date range filter (for end dates) */
528
- readonly endDate: {
529
- readonly filter: "agDateColumnFilter";
530
- readonly filterParams: {
531
- readonly buttons: readonly ["clear"];
532
- readonly suppressAndOrCondition: true;
533
- readonly filterOptions: readonly ["lessThan", "inRange"];
534
- };
535
- };
536
- /** Set filter (for categories) */
537
- readonly set: {
538
- readonly filter: "agSetColumnFilter";
539
- readonly filterParams: {
540
- readonly buttons: readonly ["clear"];
541
- };
542
- };
543
- /** Boolean filter (Yes/No) */
544
- readonly boolean: {
545
- readonly filter: "agSetColumnFilter";
546
- readonly filterParams: {
547
- readonly values: readonly ["Yes", "No"];
548
- readonly buttons: readonly ["clear"];
549
- };
550
- };
551
- };