@upstash/redis 1.36.0-rc.3 → 1.36.0-rc.5

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.
@@ -356,7 +356,7 @@ type InferSchemaData<TSchema> = {
356
356
  [K in keyof TSchema]: TSchema[K] extends FieldType ? FieldValueType<TSchema[K]> : TSchema[K] extends DetailedField ? FieldValueType<ExtractFieldType<TSchema[K]>> : TSchema[K] extends NestedIndexSchema ? InferSchemaData<TSchema[K]> : never;
357
357
  };
358
358
  type QueryOptions<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
359
- filter: QueryFilter<TSchema>;
359
+ filter: RootQueryFilter<TSchema>;
360
360
  /** Maximum number of results to return */
361
361
  limit?: number;
362
362
  /** Number of results to skip */
@@ -421,7 +421,17 @@ type StringOperationMap<T extends string> = {
421
421
  distance?: number;
422
422
  transpositionCostOne?: boolean;
423
423
  };
424
- $phrase: T;
424
+ $phrase: T | {
425
+ value: T;
426
+ } | {
427
+ value: T;
428
+ slop: number;
429
+ prefix?: never;
430
+ } | {
431
+ value: T;
432
+ prefix: boolean;
433
+ slop?: never;
434
+ };
425
435
  $regex: T;
426
436
  };
427
437
  type NumberOperationMap<T extends number> = {
@@ -442,49 +452,151 @@ type DateOperationMap<T extends string | Date> = {
442
452
  $eq: T;
443
453
  $ne: T;
444
454
  $in: T[];
455
+ $gt: T;
456
+ $gte: T;
457
+ $lte: T;
458
+ $lt: T;
445
459
  };
446
460
  type StringOperations = {
447
461
  [K in keyof StringOperationMap<string>]: {
448
462
  [P in K]: StringOperationMap<string>[K];
463
+ } & {
464
+ $boost?: number;
449
465
  };
450
466
  }[keyof StringOperationMap<string>];
451
467
  type NumberOperations = {
452
468
  [K in keyof NumberOperationMap<number>]: {
453
469
  [P in K]: NumberOperationMap<number>[K];
470
+ } & {
471
+ $boost?: number;
454
472
  };
455
473
  }[keyof NumberOperationMap<number>];
456
474
  type BooleanOperations = {
457
475
  [K in keyof BooleanOperationMap<boolean>]: {
458
476
  [P in K]: BooleanOperationMap<boolean>[K];
477
+ } & {
478
+ $boost?: number;
459
479
  };
460
480
  }[keyof BooleanOperationMap<boolean>];
461
481
  type DateOperations = {
462
482
  [K in keyof DateOperationMap<string | Date>]: {
463
483
  [P in K]: DateOperationMap<string | Date>[K];
484
+ } & {
485
+ $boost?: number;
464
486
  };
465
487
  }[keyof DateOperationMap<string | Date>];
466
488
  type OperationsForFieldType<T extends FieldType> = T extends "TEXT" ? StringOperations : T extends "U64" | "I64" | "F64" ? NumberOperations : T extends "BOOL" ? BooleanOperations : T extends "DATE" ? DateOperations : never;
467
- type PathOperations<TSchema, TPath extends string> = GetFieldAtPath<TSchema, TPath> extends infer Field ? Field extends FieldType | DetailedField ? OperationsForFieldType<ExtractFieldType<Field>> : never : never;
489
+ type PathOperations<TSchema, TPath extends string> = GetFieldAtPath<TSchema, TPath> extends infer Field ? Field extends FieldType | DetailedField ? OperationsForFieldType<ExtractFieldType<Field>> | FieldValueType<ExtractFieldType<Field>> : never : never;
468
490
  type QueryLeaf<TSchema> = {
469
- [Path in SchemaPaths<TSchema>]: {
470
- [K in Path]: PathOperations<TSchema, Path>;
471
- };
472
- }[SchemaPaths<TSchema>];
473
- type QueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> = QueryLeaf<TSchema> | {
491
+ [K in SchemaPaths<TSchema>]?: PathOperations<TSchema, K>;
492
+ } & {
493
+ $and?: never;
494
+ $or?: never;
495
+ $must?: never;
496
+ $should?: never;
497
+ $mustNot?: never;
498
+ $boost?: never;
499
+ };
500
+ type BoolBase<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
501
+ [P in SchemaPaths<TSchema>]?: PathOperations<TSchema, P>;
502
+ };
503
+ type AndNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
504
+ $and: QueryFilter<TSchema>;
505
+ $boost?: number;
506
+ $or?: never;
507
+ $must?: never;
508
+ $should?: never;
509
+ $mustNot?: never;
510
+ };
511
+ type OrNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
512
+ $or: QueryFilter<TSchema>;
513
+ $boost?: number;
514
+ $and?: never;
515
+ $must?: never;
516
+ $should?: never;
517
+ $mustNot?: never;
518
+ };
519
+ type MustNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
474
520
  $must: QueryFilter<TSchema>;
475
- } | {
521
+ $boost?: number;
522
+ $and?: never;
523
+ $or?: never;
524
+ $should?: never;
525
+ $mustNot?: never;
526
+ };
527
+ type ShouldNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
476
528
  $should: QueryFilter<TSchema>;
477
- } | {
478
- $not: QueryFilter<TSchema>;
479
- } | {
529
+ $boost?: number;
530
+ $and?: never;
531
+ $or?: never;
532
+ $must?: never;
533
+ $mustNot?: never;
534
+ };
535
+ type MustShouldNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
536
+ $must: QueryFilter<TSchema>;
537
+ $should: QueryFilter<TSchema>;
538
+ $and?: never;
539
+ $or?: never;
540
+ };
541
+ type NotNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
542
+ $mustNot: QueryFilter<TSchema>;
543
+ $boost?: number;
544
+ $and?: never;
545
+ $or?: never;
546
+ $must?: never;
547
+ $should?: never;
548
+ };
549
+ type AndNotNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
480
550
  $and: QueryFilter<TSchema>;
481
- } | {
551
+ $mustNot: QueryFilter<TSchema>;
552
+ $boost?: number;
553
+ $or?: never;
554
+ $must?: never;
555
+ $should?: never;
556
+ };
557
+ type OrNotNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
482
558
  $or: QueryFilter<TSchema>;
483
- } | {
484
- $boost: {
485
- query: QueryFilter<TSchema>;
486
- value: number;
487
- };
559
+ $mustNot: QueryFilter<TSchema>;
560
+ $boost?: number;
561
+ $and?: never;
562
+ $must?: never;
563
+ $should?: never;
564
+ };
565
+ type ShouldNotNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
566
+ $should: QueryFilter<TSchema>;
567
+ $mustNot: QueryFilter<TSchema>;
568
+ $boost?: number;
569
+ $and?: never;
570
+ $or?: never;
571
+ $must?: never;
572
+ };
573
+ type MustNotNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
574
+ $must: QueryFilter<TSchema>;
575
+ $mustNot: QueryFilter<TSchema>;
576
+ $boost?: number;
577
+ $and?: never;
578
+ $or?: never;
579
+ $should?: never;
580
+ };
581
+ type BoolNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TSchema> & {
582
+ $must: QueryFilter<TSchema>;
583
+ $should: QueryFilter<TSchema>;
584
+ $mustNot: QueryFilter<TSchema>;
585
+ $boost?: number;
586
+ $and?: never;
587
+ $or?: never;
588
+ };
589
+ type QueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> = QueryLeaf<TSchema> | AndNode<TSchema> | OrNode<TSchema> | MustNode<TSchema> | ShouldNode<TSchema> | MustShouldNode<TSchema> | NotNode<TSchema> | AndNotNode<TSchema> | OrNotNode<TSchema> | ShouldNotNode<TSchema> | MustNotNode<TSchema> | BoolNode<TSchema>;
590
+ type RootQueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> = QueryLeaf<TSchema> | AndNode<TSchema> | RootOrNode<TSchema> | MustNode<TSchema> | ShouldNode<TSchema> | MustShouldNode<TSchema> | AndNotNode<TSchema> | ShouldNotNode<TSchema> | MustNotNode<TSchema> | BoolNode<TSchema>;
591
+ type RootOrNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
592
+ [P in SchemaPaths<TSchema>]?: never;
593
+ } & {
594
+ $or: QueryFilter<TSchema>;
595
+ $boost?: number;
596
+ $and?: never;
597
+ $must?: never;
598
+ $should?: never;
599
+ $mustNot?: never;
488
600
  };
489
601
  type DescribeFieldInfo = {
490
602
  type: FieldType;
@@ -494,7 +606,7 @@ type DescribeFieldInfo = {
494
606
  };
495
607
  type IndexDescription<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
496
608
  name: string;
497
- dataType: "hash" | "string";
609
+ dataType: "hash" | "string" | "json";
498
610
  prefixes: string[];
499
611
  language?: Language;
500
612
  schema: Record<SchemaPaths<TSchema>, DescribeFieldInfo>;
@@ -509,12 +621,17 @@ type createIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
509
621
  } & ({
510
622
  dataType: "string";
511
623
  schema: TSchema extends NestedIndexSchema ? TSchema : never;
624
+ } | {
625
+ dataType: "json";
626
+ schema: TSchema extends NestedIndexSchema ? TSchema : never;
512
627
  } | {
513
628
  dataType: "hash";
514
629
  schema: TSchema extends FlatIndexSchema ? TSchema : never;
515
630
  });
516
- type SearchIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = Pick<createIndexProps<TSchema>, "name" | "client"> & {
517
- schema?: createIndexProps<TSchema>["schema"];
631
+ type SearchIndexProps<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
632
+ name: string;
633
+ client: Requester;
634
+ schema?: TSchema;
518
635
  };
519
636
  declare class SearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema> {
520
637
  readonly name: SearchIndexProps<TSchema>["name"];
@@ -523,16 +640,17 @@ declare class SearchIndex<TSchema extends NestedIndexSchema | FlatIndexSchema> {
523
640
  constructor({ name, schema, client }: SearchIndexProps<TSchema>);
524
641
  waitIndexing(): Promise<string>;
525
642
  describe(): Promise<IndexDescription<TSchema>>;
526
- query<TOptions extends QueryOptions<TSchema>>(options: TOptions): Promise<QueryResult<TSchema, TOptions>[]>;
643
+ query(options: QueryOptions<TSchema>): Promise<QueryResult<TSchema, QueryOptions<TSchema>>[]>;
527
644
  count({ filter }: {
528
- filter: QueryFilter<TSchema>;
645
+ filter: RootQueryFilter<TSchema>;
529
646
  }): Promise<{
530
647
  count: number;
531
648
  }>;
532
649
  drop(): Promise<string>;
533
650
  }
534
- declare function createIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(props: createIndexProps<TSchema>): Promise<SearchIndex<TSchema>>;
535
- declare function index<TSchema extends NestedIndexSchema | FlatIndexSchema>(client: Requester, name: SearchIndexProps<TSchema>["name"], schema?: SearchIndexProps<TSchema>["schema"]): SearchIndex<TSchema>;
651
+ declare function createIndex<TSchema extends NestedIndexSchema | FlatIndexSchema>(props: createIndexProps<TSchema>): Promise<SearchIndex<(TSchema extends NestedIndexSchema ? TSchema : never) | (TSchema extends NestedIndexSchema ? TSchema : never) | (TSchema extends FlatIndexSchema ? TSchema : never)>>;
652
+ declare function index<TSchema extends NestedIndexSchema | FlatIndexSchema>(client: Requester, name: string, schema: TSchema): SearchIndex<TSchema>;
653
+ declare function index(client: Requester, name: string): SearchIndex<any>;
536
654
 
537
655
  /**
538
656
  * @see https://redis.io/commands/append
@@ -3372,7 +3490,7 @@ declare class Redis {
3372
3490
  readonly?: TReadonly;
3373
3491
  }): TReadonly extends true ? ScriptRO<TResult> : Script<TResult>;
3374
3492
  get search(): {
3375
- createIndex: <TSchema extends NestedIndexSchema | FlatIndexSchema>(props: Omit<createIndexProps<TSchema>, "client">) => Promise<SearchIndex<TSchema>>;
3493
+ createIndex: <TSchema extends NestedIndexSchema | FlatIndexSchema>(props: Omit<createIndexProps<TSchema>, "client">) => Promise<SearchIndex<(TSchema extends NestedIndexSchema ? TSchema : never) | (TSchema extends NestedIndexSchema ? TSchema : never) | (TSchema extends FlatIndexSchema ? TSchema : never)>>;
3376
3494
  index: <TSchema extends NestedIndexSchema | FlatIndexSchema>(name: string, schema?: TSchema extends NestedIndexSchema ? TSchema : never) => SearchIndex<TSchema>;
3377
3495
  };
3378
3496
  /**