simplesvelte 2.2.7 → 2.2.9

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.
@@ -224,10 +224,24 @@ type PrismaFilter<T> = T extends string ? T | {
224
224
  };
225
225
  /**
226
226
  * Transform return type that constrains field names to TRecord keys
227
- * and provides proper typing for Prisma filter operators based on field types
227
+ * and provides proper typing for Prisma filter operators based on field types.
228
+ * Supports OR and AND operators for complex queries.
228
229
  */
229
230
  type TransformResult<TRecord> = {
230
231
  [K in keyof TRecord]?: PrismaFilter<TRecord[K]>;
232
+ } & {
233
+ /** OR operator - at least one condition must match */
234
+ OR?: Array<{
235
+ [K in keyof TRecord]?: PrismaFilter<TRecord[K]>;
236
+ }>;
237
+ /** AND operator - all conditions must match */
238
+ AND?: Array<{
239
+ [K in keyof TRecord]?: PrismaFilter<TRecord[K]>;
240
+ }>;
241
+ /** NOT operator - inverts the condition */
242
+ NOT?: {
243
+ [K in keyof TRecord]?: PrismaFilter<TRecord[K]>;
244
+ };
231
245
  };
232
246
  /**
233
247
  * Parsed query parameters from AG Grid request
@@ -278,7 +292,7 @@ type AGGridQueryParams = {
278
292
  * }
279
293
  * ```
280
294
  *
281
- * @example Full Name (Multi-field)
295
+ * @example Full Name (Multi-field with OR)
282
296
  * ```typescript
283
297
  * {
284
298
  * columnId: 'fullName',
@@ -286,8 +300,10 @@ type AGGridQueryParams = {
286
300
  * transform: (name) => {
287
301
  * const [first, last] = name.split(' ')
288
302
  * return {
289
- * firstName: { contains: first, mode: 'insensitive' },
290
- * lastName: { contains: last, mode: 'insensitive' }
303
+ * OR: [
304
+ * { firstName: { contains: first, mode: 'insensitive' } },
305
+ * { lastName: { contains: last || first, mode: 'insensitive' } }
306
+ * ]
291
307
  * }
292
308
  * }
293
309
  * }
@@ -299,8 +299,21 @@ function applyNumberFilter(where, field, filter) {
299
299
  */
300
300
  function applyDateFilter(where, field, filter) {
301
301
  const type = filter.type;
302
- const dateFrom = filter.dateFrom;
303
- const dateTo = filter.dateTo;
302
+ let dateFrom = filter.dateFrom;
303
+ let dateTo = filter.dateTo;
304
+ // Convert date strings to ISO-8601 DateTime format for Prisma
305
+ if (dateFrom && typeof dateFrom === 'string') {
306
+ // If it's just a date (YYYY-MM-DD), convert to start of day in ISO format
307
+ if (/^\d{4}-\d{2}-\d{2}$/.test(dateFrom)) {
308
+ dateFrom = new Date(dateFrom + 'T00:00:00.000Z').toISOString();
309
+ }
310
+ }
311
+ if (dateTo && typeof dateTo === 'string') {
312
+ // If it's just a date (YYYY-MM-DD), convert to end of day in ISO format
313
+ if (/^\d{4}-\d{2}-\d{2}$/.test(dateTo)) {
314
+ dateTo = new Date(dateTo + 'T23:59:59.999Z').toISOString();
315
+ }
316
+ }
304
317
  switch (type) {
305
318
  case 'equals':
306
319
  where[field] = dateFrom;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplesvelte",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
4
4
  "scripts": {
5
5
  "dev": "bun vite dev",
6
6
  "build": "bun vite build && bun run prepack",