🎯 MapView v2.0 - Global Deployment Ready

 MAJOR FEATURES:
• Auto-zoom intelligence với smart bounds fitting
• Enhanced 3D GPS markers với pulsing effects
• Professional route display với 6-layer rendering
• Status-based parking icons với availability indicators
• Production-ready build optimizations

🗺️ AUTO-ZOOM FEATURES:
• Smart bounds fitting cho GPS + selected parking
• Adaptive padding (50px) cho visual balance
• Max zoom control (level 16) để tránh quá gần
• Dynamic centering khi không có selection

🎨 ENHANCED VISUALS:
• 3D GPS marker với multi-layer pulse effects
• Advanced parking icons với status colors
• Selection highlighting với animation
• Dimming system cho non-selected items

🛣️ ROUTE SYSTEM:
• OpenRouteService API integration
• Multi-layer route rendering (glow, shadow, main, animated)
• Real-time distance & duration calculation
• Visual route info trong popup

📱 PRODUCTION READY:
• SSR safe với dynamic imports
• Build errors resolved
• Global deployment via Vercel
• Optimized performance

🌍 DEPLOYMENT:
• Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app
• Bundle size: 22.8 kB optimized
• Global CDN distribution
• HTTPS enabled

💾 VERSION CONTROL:
• MapView-v2.0.tsx backup created
• MAPVIEW_VERSIONS.md documentation
• Full version history tracking
This commit is contained in:
2025-07-20 19:52:16 +07:00
parent 3203463a6a
commit c65cc97a33
64624 changed files with 7199453 additions and 6462 deletions

119
backend/node_modules/@redis/search/README.md generated vendored Normal file
View File

@@ -0,0 +1,119 @@
# @redis/search
This package provides support for the [RediSearch](https://redisearch.io) module, which adds indexing and querying support for data stored in Redis Hashes or as JSON documents with the RedisJSON module. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the RediSearch commands.
To use these extra commands, your Redis server must have the RediSearch module installed. To index and query JSON documents, you'll also need to add the RedisJSON module.
## Usage
For complete examples, see [`search-hashes.js`](https://github.com/redis/node-redis/blob/master/examples/search-hashes.js) and [`search-json.js`](https://github.com/redis/node-redis/blob/master/examples/search-json.js) in the Node Redis examples folder.
### Indexing and Querying Data in Redis Hashes
#### Creating an Index
Before we can perform any searches, we need to tell RediSearch how to index our data, and which Redis keys to find that data in. The [FT.CREATE](https://redis.io/commands/ft.create) command creates a RediSearch index. Here's how to use it to create an index we'll call `idx:animals` where we want to index hashes containing `name`, `species` and `age` fields, and whose key names in Redis begin with the prefix `noderedis:animals`:
```javascript
await client.ft.create('idx:animals', {
name: {
type: SchemaFieldTypes.TEXT,
SORTABLE: true
},
species: SchemaFieldTypes.TAG,
age: SchemaFieldTypes.NUMERIC
}, {
ON: 'HASH',
PREFIX: 'noderedis:animals'
});
```
See the [`FT.CREATE` documentation](https://redis.io/commands/ft.create/#description) for information about the different field types and additional options.
#### Querying the Index
Once we've created an index, and added some data to Redis hashes whose keys begin with the prefix `noderedis:animals`, we can start writing some search queries. RediSearch supports a rich query syntax for full-text search, faceted search, aggregation and more. Check out the [`FT.SEARCH` documentation](https://redis.io/commands/ft.search) and the [query syntax reference](https://redis.io/docs/interact/search-and-query/query) for more information.
Let's write a query to find all the animals where the `species` field has the value `dog`:
```javascript
const results = await client.ft.search('idx:animals', '@species:{dog}');
```
`results` looks like this:
```javascript
{
total: 2,
documents: [
{
id: 'noderedis:animals:4',
value: {
name: 'Fido',
species: 'dog',
age: '7'
}
},
{
id: 'noderedis:animals:3',
value: {
name: 'Rover',
species: 'dog',
age: '9'
}
}
]
}
```
### Indexing and Querying Data with RedisJSON
RediSearch can also index and query JSON documents stored in Redis using the RedisJSON module. The approach is similar to that for indexing and searching data in hashes, but we can now use JSON Path like syntax and the data no longer has to be flat name/value pairs - it can contain nested objects and arrays.
#### Creating an Index
As before, we create an index with the `FT.CREATE` command, this time specifying we want to index JSON documents that look like this:
```javascript
{
name: 'Alice',
age: 32,
coins: 100
}
```
Each document represents a user in some system, and users have name, age and coins properties.
One way we might choose to index these documents is as follows:
```javascript
await client.ft.create('idx:users', {
'$.name': {
type: SchemaFieldTypes.TEXT,
SORTABLE: 'UNF'
},
'$.age': {
type: SchemaFieldTypes.NUMERIC,
AS: 'age'
},
'$.coins': {
type: SchemaFieldTypes.NUMERIC,
AS: 'coins'
}
}, {
ON: 'JSON',
PREFIX: 'noderedis:users'
});
```
Note that we're using JSON Path to specify where the fields to index are in our JSON documents, and the `AS` clause to define a name/alias for each field. We'll use these when writing queries.
#### Querying the Index
Now we have an index and some data stored as JSON documents in Redis (see the [JSON package documentation](https://github.com/redis/node-redis/tree/master/packages/json) for examples of how to store JSON), we can write some queries...
We'll use the [RediSearch query language](https://redis.io/docs/interact/search-and-query/query) and [`FT.SEARCH`](https://redis.io/commands/ft.search) command. Here's a query to find users under the age of 30:
```javascript
await client.ft.search('idx:users', '@age:[0 30]');
```

View File

@@ -0,0 +1,118 @@
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
import { Params, PropertyName, SortByProperty } from '.';
export declare enum AggregateSteps {
GROUPBY = "GROUPBY",
SORTBY = "SORTBY",
APPLY = "APPLY",
LIMIT = "LIMIT",
FILTER = "FILTER"
}
interface AggregateStep<T extends AggregateSteps> {
type: T;
}
export declare enum AggregateGroupByReducers {
COUNT = "COUNT",
COUNT_DISTINCT = "COUNT_DISTINCT",
COUNT_DISTINCTISH = "COUNT_DISTINCTISH",
SUM = "SUM",
MIN = "MIN",
MAX = "MAX",
AVG = "AVG",
STDDEV = "STDDEV",
QUANTILE = "QUANTILE",
TOLIST = "TOLIST",
TO_LIST = "TOLIST",
FIRST_VALUE = "FIRST_VALUE",
RANDOM_SAMPLE = "RANDOM_SAMPLE"
}
interface GroupByReducer<T extends AggregateGroupByReducers> {
type: T;
AS?: string;
}
type CountReducer = GroupByReducer<AggregateGroupByReducers.COUNT>;
interface CountDistinctReducer extends GroupByReducer<AggregateGroupByReducers.COUNT_DISTINCT> {
property: PropertyName;
}
interface CountDistinctishReducer extends GroupByReducer<AggregateGroupByReducers.COUNT_DISTINCTISH> {
property: PropertyName;
}
interface SumReducer extends GroupByReducer<AggregateGroupByReducers.SUM> {
property: PropertyName;
}
interface MinReducer extends GroupByReducer<AggregateGroupByReducers.MIN> {
property: PropertyName;
}
interface MaxReducer extends GroupByReducer<AggregateGroupByReducers.MAX> {
property: PropertyName;
}
interface AvgReducer extends GroupByReducer<AggregateGroupByReducers.AVG> {
property: PropertyName;
}
interface StdDevReducer extends GroupByReducer<AggregateGroupByReducers.STDDEV> {
property: PropertyName;
}
interface QuantileReducer extends GroupByReducer<AggregateGroupByReducers.QUANTILE> {
property: PropertyName;
quantile: number;
}
interface ToListReducer extends GroupByReducer<AggregateGroupByReducers.TOLIST> {
property: PropertyName;
}
interface FirstValueReducer extends GroupByReducer<AggregateGroupByReducers.FIRST_VALUE> {
property: PropertyName;
BY?: PropertyName | {
property: PropertyName;
direction?: 'ASC' | 'DESC';
};
}
interface RandomSampleReducer extends GroupByReducer<AggregateGroupByReducers.RANDOM_SAMPLE> {
property: PropertyName;
sampleSize: number;
}
type GroupByReducers = CountReducer | CountDistinctReducer | CountDistinctishReducer | SumReducer | MinReducer | MaxReducer | AvgReducer | StdDevReducer | QuantileReducer | ToListReducer | FirstValueReducer | RandomSampleReducer;
interface GroupByStep extends AggregateStep<AggregateSteps.GROUPBY> {
properties?: PropertyName | Array<PropertyName>;
REDUCE: GroupByReducers | Array<GroupByReducers>;
}
interface SortStep extends AggregateStep<AggregateSteps.SORTBY> {
BY: SortByProperty | Array<SortByProperty>;
MAX?: number;
}
interface ApplyStep extends AggregateStep<AggregateSteps.APPLY> {
expression: string;
AS: string;
}
interface LimitStep extends AggregateStep<AggregateSteps.LIMIT> {
from: number;
size: number;
}
interface FilterStep extends AggregateStep<AggregateSteps.FILTER> {
expression: string;
}
type LoadField = PropertyName | {
identifier: PropertyName;
AS?: string;
};
export interface AggregateOptions {
VERBATIM?: boolean;
ADDSCORES?: boolean;
LOAD?: LoadField | Array<LoadField>;
STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
PARAMS?: Params;
DIALECT?: number;
TIMEOUT?: number;
}
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string, options?: AggregateOptions): RedisCommandArguments;
export declare function pushAggregatehOptions(args: RedisCommandArguments, options?: AggregateOptions): RedisCommandArguments;
export type AggregateRawReply = [
total: number,
...results: Array<Array<RedisCommandArgument>>
];
export interface AggregateReply {
total: number;
results: Array<Record<string, RedisCommandArgument>>;
}
export declare function transformReply(rawReply: AggregateRawReply): AggregateReply;
export {};

View File

@@ -0,0 +1,170 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.pushAggregatehOptions = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = exports.AggregateGroupByReducers = exports.AggregateSteps = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
const _1 = require(".");
var AggregateSteps;
(function (AggregateSteps) {
AggregateSteps["GROUPBY"] = "GROUPBY";
AggregateSteps["SORTBY"] = "SORTBY";
AggregateSteps["APPLY"] = "APPLY";
AggregateSteps["LIMIT"] = "LIMIT";
AggregateSteps["FILTER"] = "FILTER";
})(AggregateSteps || (exports.AggregateSteps = AggregateSteps = {}));
var AggregateGroupByReducers;
(function (AggregateGroupByReducers) {
AggregateGroupByReducers["COUNT"] = "COUNT";
AggregateGroupByReducers["COUNT_DISTINCT"] = "COUNT_DISTINCT";
AggregateGroupByReducers["COUNT_DISTINCTISH"] = "COUNT_DISTINCTISH";
AggregateGroupByReducers["SUM"] = "SUM";
AggregateGroupByReducers["MIN"] = "MIN";
AggregateGroupByReducers["MAX"] = "MAX";
AggregateGroupByReducers["AVG"] = "AVG";
AggregateGroupByReducers["STDDEV"] = "STDDEV";
AggregateGroupByReducers["QUANTILE"] = "QUANTILE";
AggregateGroupByReducers["TOLIST"] = "TOLIST";
AggregateGroupByReducers["TO_LIST"] = "TOLIST";
AggregateGroupByReducers["FIRST_VALUE"] = "FIRST_VALUE";
AggregateGroupByReducers["RANDOM_SAMPLE"] = "RANDOM_SAMPLE";
})(AggregateGroupByReducers || (exports.AggregateGroupByReducers = AggregateGroupByReducers = {}));
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(index, query, options) {
return pushAggregatehOptions(['FT.AGGREGATE', index, query], options);
}
exports.transformArguments = transformArguments;
function pushAggregatehOptions(args, options) {
if (options?.VERBATIM) {
args.push('VERBATIM');
}
if (options?.ADDSCORES) {
args.push('ADDSCORES');
}
if (options?.LOAD) {
args.push('LOAD');
(0, _1.pushArgumentsWithLength)(args, () => {
if (Array.isArray(options.LOAD)) {
for (const load of options.LOAD) {
pushLoadField(args, load);
}
}
else {
pushLoadField(args, options.LOAD);
}
});
}
if (options?.STEPS) {
for (const step of options.STEPS) {
switch (step.type) {
case AggregateSteps.GROUPBY:
args.push('GROUPBY');
if (!step.properties) {
args.push('0');
}
else {
(0, generic_transformers_1.pushVerdictArgument)(args, step.properties);
}
if (Array.isArray(step.REDUCE)) {
for (const reducer of step.REDUCE) {
pushGroupByReducer(args, reducer);
}
}
else {
pushGroupByReducer(args, step.REDUCE);
}
break;
case AggregateSteps.SORTBY:
(0, _1.pushSortByArguments)(args, 'SORTBY', step.BY);
if (step.MAX) {
args.push('MAX', step.MAX.toString());
}
break;
case AggregateSteps.APPLY:
args.push('APPLY', step.expression, 'AS', step.AS);
break;
case AggregateSteps.LIMIT:
args.push('LIMIT', step.from.toString(), step.size.toString());
break;
case AggregateSteps.FILTER:
args.push('FILTER', step.expression);
break;
}
}
}
(0, _1.pushParamsArgs)(args, options?.PARAMS);
if (options?.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}
return args;
}
exports.pushAggregatehOptions = pushAggregatehOptions;
function pushLoadField(args, toLoad) {
if (typeof toLoad === 'string') {
args.push(toLoad);
}
else {
args.push(toLoad.identifier);
if (toLoad.AS) {
args.push('AS', toLoad.AS);
}
}
}
function pushGroupByReducer(args, reducer) {
args.push('REDUCE', reducer.type);
switch (reducer.type) {
case AggregateGroupByReducers.COUNT:
args.push('0');
break;
case AggregateGroupByReducers.COUNT_DISTINCT:
case AggregateGroupByReducers.COUNT_DISTINCTISH:
case AggregateGroupByReducers.SUM:
case AggregateGroupByReducers.MIN:
case AggregateGroupByReducers.MAX:
case AggregateGroupByReducers.AVG:
case AggregateGroupByReducers.STDDEV:
case AggregateGroupByReducers.TOLIST:
args.push('1', reducer.property);
break;
case AggregateGroupByReducers.QUANTILE:
args.push('2', reducer.property, reducer.quantile.toString());
break;
case AggregateGroupByReducers.FIRST_VALUE: {
(0, _1.pushArgumentsWithLength)(args, () => {
args.push(reducer.property);
if (reducer.BY) {
args.push('BY');
if (typeof reducer.BY === 'string') {
args.push(reducer.BY);
}
else {
args.push(reducer.BY.property);
if (reducer.BY.direction) {
args.push(reducer.BY.direction);
}
}
}
});
break;
}
case AggregateGroupByReducers.RANDOM_SAMPLE:
args.push('2', reducer.property, reducer.sampleSize.toString());
break;
}
if (reducer.AS) {
args.push('AS', reducer.AS);
}
}
function transformReply(rawReply) {
const results = [];
for (let i = 1; i < rawReply.length; i++) {
results.push((0, generic_transformers_1.transformTuplesReply)(rawReply[i]));
}
return {
total: rawReply[0],
results
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,14 @@
import { AggregateOptions, AggregateRawReply, AggregateReply } from './AGGREGATE';
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './AGGREGATE';
interface AggregateWithCursorOptions extends AggregateOptions {
COUNT?: number;
}
export declare function transformArguments(index: string, query: string, options?: AggregateWithCursorOptions): import("@redis/client/dist/lib/commands").RedisCommandArguments;
type AggregateWithCursorRawReply = [
result: AggregateRawReply,
cursor: number
];
interface AggregateWithCursorReply extends AggregateReply {
cursor: number;
}
export declare function transformReply(reply: AggregateWithCursorRawReply): AggregateWithCursorReply;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
const AGGREGATE_1 = require("./AGGREGATE");
var AGGREGATE_2 = require("./AGGREGATE");
Object.defineProperty(exports, "FIRST_KEY_INDEX", { enumerable: true, get: function () { return AGGREGATE_2.FIRST_KEY_INDEX; } });
Object.defineProperty(exports, "IS_READ_ONLY", { enumerable: true, get: function () { return AGGREGATE_2.IS_READ_ONLY; } });
function transformArguments(index, query, options) {
const args = (0, AGGREGATE_1.transformArguments)(index, query, options);
args.push('WITHCURSOR');
if (options?.COUNT) {
args.push('COUNT', options.COUNT.toString());
}
return args;
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
return {
...(0, AGGREGATE_1.transformReply)(reply[0]),
cursor: reply[1]
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(name: string, index: string): Array<string>;
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(name, index) {
return ['FT.ALIASADD', name, index];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(name: string, index: string): Array<string>;
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(name, index) {
return ['FT.ALIASDEL', name, index];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(name: string, index: string): Array<string>;
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(name, index) {
return ['FT.ALIASUPDATE', name, index];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RediSearchSchema } from '.';
export declare function transformArguments(index: string, schema: RediSearchSchema): Array<string>;
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const _1 = require(".");
function transformArguments(index, schema) {
const args = ['FT.ALTER', index, 'SCHEMA', 'ADD'];
(0, _1.pushSchema)(args, schema);
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,6 @@
export declare function transformArguments(option: string): string[];
interface ConfigGetReply {
[option: string]: string | null;
}
export declare function transformReply(rawReply: Array<[string, string | null]>): ConfigGetReply;
export {};

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
function transformArguments(option) {
return ['FT.CONFIG', 'GET', option];
}
exports.transformArguments = transformArguments;
function transformReply(rawReply) {
const transformedReply = Object.create(null);
for (const [key, value] of rawReply) {
transformedReply[key] = value;
}
return transformedReply;
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(option: string, value: string): Array<string>;
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(option, value) {
return ['FT.CONFIG', 'SET', option, value];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,21 @@
import { RedisSearchLanguages, PropertyName, RediSearchSchema } from '.';
interface CreateOptions {
ON?: 'HASH' | 'JSON';
PREFIX?: string | Array<string>;
FILTER?: string;
LANGUAGE?: RedisSearchLanguages;
LANGUAGE_FIELD?: PropertyName;
SCORE?: number;
SCORE_FIELD?: PropertyName;
MAXTEXTFIELDS?: true;
TEMPORARY?: number;
NOOFFSETS?: true;
NOHL?: true;
NOFIELDS?: true;
NOFREQS?: true;
SKIPINITIALSCAN?: true;
STOPWORDS?: string | Array<string>;
}
export declare function transformArguments(index: string, schema: RediSearchSchema, options?: CreateOptions): Array<string>;
export declare function transformReply(): 'OK';
export {};

View File

@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
const _1 = require(".");
function transformArguments(index, schema, options) {
const args = ['FT.CREATE', index];
if (options?.ON) {
args.push('ON', options.ON);
}
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'PREFIX', options?.PREFIX);
if (options?.FILTER) {
args.push('FILTER', options.FILTER);
}
if (options?.LANGUAGE) {
args.push('LANGUAGE', options.LANGUAGE);
}
if (options?.LANGUAGE_FIELD) {
args.push('LANGUAGE_FIELD', options.LANGUAGE_FIELD);
}
if (options?.SCORE) {
args.push('SCORE', options.SCORE.toString());
}
if (options?.SCORE_FIELD) {
args.push('SCORE_FIELD', options.SCORE_FIELD);
}
// if (options?.PAYLOAD_FIELD) {
// args.push('PAYLOAD_FIELD', options.PAYLOAD_FIELD);
// }
if (options?.MAXTEXTFIELDS) {
args.push('MAXTEXTFIELDS');
}
if (options?.TEMPORARY) {
args.push('TEMPORARY', options.TEMPORARY.toString());
}
if (options?.NOOFFSETS) {
args.push('NOOFFSETS');
}
if (options?.NOHL) {
args.push('NOHL');
}
if (options?.NOFIELDS) {
args.push('NOFIELDS');
}
if (options?.NOFREQS) {
args.push('NOFREQS');
}
if (options?.SKIPINITIALSCAN) {
args.push('SKIPINITIALSCAN');
}
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'STOPWORDS', options?.STOPWORDS);
args.push('SCHEMA');
(0, _1.pushSchema)(args, schema);
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument } from '@redis/client/dist/lib/commands';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(index: RedisCommandArgument, cursorId: number): RedisCommandArgument[];
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(index, cursorId) {
return [
'FT.CURSOR',
'DEL',
index,
cursorId.toString()
];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,8 @@
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
interface CursorReadOptions {
COUNT?: number;
}
export declare function transformArguments(index: RedisCommandArgument, cursor: number, options?: CursorReadOptions): RedisCommandArguments;
export { transformReply } from './AGGREGATE_WITHCURSOR';

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(index, cursor, options) {
const args = [
'FT.CURSOR',
'READ',
index,
cursor.toString()
];
if (options?.COUNT) {
args.push('COUNT', options.COUNT.toString());
}
return args;
}
exports.transformArguments = transformArguments;
var AGGREGATE_WITHCURSOR_1 = require("./AGGREGATE_WITHCURSOR");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return AGGREGATE_WITHCURSOR_1.transformReply; } });

View File

@@ -0,0 +1,3 @@
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
export declare function transformArguments(dictionary: string, term: string | Array<string>): RedisCommandArguments;
export declare function transformReply(): number;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
function transformArguments(dictionary, term) {
return (0, generic_transformers_1.pushVerdictArguments)(['FT.DICTADD', dictionary], term);
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
export declare function transformArguments(dictionary: string, term: string | Array<string>): RedisCommandArguments;
export declare function transformReply(): number;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
function transformArguments(dictionary, term) {
return (0, generic_transformers_1.pushVerdictArguments)(['FT.DICTDEL', dictionary], term);
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(dictionary: string): Array<string>;
export declare function transformReply(): Array<string>;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(dictionary) {
return ['FT.DICTDUMP', dictionary];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,6 @@
interface DropIndexOptions {
DD?: true;
}
export declare function transformArguments(index: string, options?: DropIndexOptions): Array<string>;
export declare function transformReply(): 'OK';
export {};

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(index, options) {
const args = ['FT.DROPINDEX', index];
if (options?.DD) {
args.push('DD');
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,9 @@
import { Params } from ".";
export declare const IS_READ_ONLY = true;
interface ExplainOptions {
PARAMS?: Params;
DIALECT?: number;
}
export declare function transformArguments(index: string, query: string, options?: ExplainOptions): Array<string>;
export declare function transformReply(): string;
export {};

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = void 0;
const _1 = require(".");
exports.IS_READ_ONLY = true;
function transformArguments(index, query, options) {
const args = ['FT.EXPLAIN', index, query];
(0, _1.pushParamsArgs)(args, options?.PARAMS);
if (options?.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string): Array<string>;
export declare function transformReply(): Array<string>;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = void 0;
exports.IS_READ_ONLY = true;
function transformArguments(index, query) {
return ['FT.EXPLAINCLI', index, query];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,120 @@
import { RedisCommandArgument } from '@redis/client/dist/lib/commands';
export declare function transformArguments(index: string): Array<string>;
type InfoRawReply = [
'index_name',
RedisCommandArgument,
'index_options',
Array<RedisCommandArgument>,
'index_definition',
Array<RedisCommandArgument>,
'attributes',
Array<Array<RedisCommandArgument>>,
'num_docs',
RedisCommandArgument,
'max_doc_id',
RedisCommandArgument,
'num_terms',
RedisCommandArgument,
'num_records',
RedisCommandArgument,
'inverted_sz_mb',
RedisCommandArgument,
'vector_index_sz_mb',
RedisCommandArgument,
'total_inverted_index_blocks',
RedisCommandArgument,
'offset_vectors_sz_mb',
RedisCommandArgument,
'doc_table_size_mb',
RedisCommandArgument,
'sortable_values_size_mb',
RedisCommandArgument,
'key_table_size_mb',
RedisCommandArgument,
'records_per_doc_avg',
RedisCommandArgument,
'bytes_per_record_avg',
RedisCommandArgument,
'offsets_per_term_avg',
RedisCommandArgument,
'offset_bits_per_record_avg',
RedisCommandArgument,
'hash_indexing_failures',
RedisCommandArgument,
'indexing',
RedisCommandArgument,
'percent_indexed',
RedisCommandArgument,
'gc_stats',
[
'bytes_collected',
RedisCommandArgument,
'total_ms_run',
RedisCommandArgument,
'total_cycles',
RedisCommandArgument,
'average_cycle_time_ms',
RedisCommandArgument,
'last_run_time_ms',
RedisCommandArgument,
'gc_numeric_trees_missed',
RedisCommandArgument,
'gc_blocks_denied',
RedisCommandArgument
],
'cursor_stats',
[
'global_idle',
number,
'global_total',
number,
'index_capacity',
number,
'index_total',
number
],
'stopwords_list'?,
Array<RedisCommandArgument>?
];
interface InfoReply {
indexName: RedisCommandArgument;
indexOptions: Array<RedisCommandArgument>;
indexDefinition: Record<string, RedisCommandArgument>;
attributes: Array<Record<string, RedisCommandArgument>>;
numDocs: RedisCommandArgument;
maxDocId: RedisCommandArgument;
numTerms: RedisCommandArgument;
numRecords: RedisCommandArgument;
invertedSzMb: RedisCommandArgument;
vectorIndexSzMb: RedisCommandArgument;
totalInvertedIndexBlocks: RedisCommandArgument;
offsetVectorsSzMb: RedisCommandArgument;
docTableSizeMb: RedisCommandArgument;
sortableValuesSizeMb: RedisCommandArgument;
keyTableSizeMb: RedisCommandArgument;
recordsPerDocAvg: RedisCommandArgument;
bytesPerRecordAvg: RedisCommandArgument;
offsetsPerTermAvg: RedisCommandArgument;
offsetBitsPerRecordAvg: RedisCommandArgument;
hashIndexingFailures: RedisCommandArgument;
indexing: RedisCommandArgument;
percentIndexed: RedisCommandArgument;
gcStats: {
bytesCollected: RedisCommandArgument;
totalMsRun: RedisCommandArgument;
totalCycles: RedisCommandArgument;
averageCycleTimeMs: RedisCommandArgument;
lastRunTimeMs: RedisCommandArgument;
gcNumericTreesMissed: RedisCommandArgument;
gcBlocksDenied: RedisCommandArgument;
};
cursorStats: {
globalIdle: number;
globalTotal: number;
indexCapacity: number;
idnexTotal: number;
};
stopWords: Array<RedisCommandArgument> | undefined;
}
export declare function transformReply(rawReply: InfoRawReply): InfoReply;
export {};

View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
function transformArguments(index) {
return ['FT.INFO', index];
}
exports.transformArguments = transformArguments;
function transformReply(rawReply) {
return {
indexName: rawReply[1],
indexOptions: rawReply[3],
indexDefinition: (0, generic_transformers_1.transformTuplesReply)(rawReply[5]),
attributes: rawReply[7].map(attribute => (0, generic_transformers_1.transformTuplesReply)(attribute)),
numDocs: rawReply[9],
maxDocId: rawReply[11],
numTerms: rawReply[13],
numRecords: rawReply[15],
invertedSzMb: rawReply[17],
vectorIndexSzMb: rawReply[19],
totalInvertedIndexBlocks: rawReply[21],
offsetVectorsSzMb: rawReply[23],
docTableSizeMb: rawReply[25],
sortableValuesSizeMb: rawReply[27],
keyTableSizeMb: rawReply[29],
recordsPerDocAvg: rawReply[31],
bytesPerRecordAvg: rawReply[33],
offsetsPerTermAvg: rawReply[35],
offsetBitsPerRecordAvg: rawReply[37],
hashIndexingFailures: rawReply[39],
indexing: rawReply[41],
percentIndexed: rawReply[43],
gcStats: {
bytesCollected: rawReply[45][1],
totalMsRun: rawReply[45][3],
totalCycles: rawReply[45][5],
averageCycleTimeMs: rawReply[45][7],
lastRunTimeMs: rawReply[45][9],
gcNumericTreesMissed: rawReply[45][11],
gcBlocksDenied: rawReply[45][13]
},
cursorStats: {
globalIdle: rawReply[47][1],
globalTotal: rawReply[47][3],
indexCapacity: rawReply[47][5],
idnexTotal: rawReply[47][7]
},
stopWords: rawReply[49]
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,7 @@
import { AggregateOptions, AggregateRawReply } from './AGGREGATE';
import { ProfileOptions, ProfileRawReply, ProfileReply } from '.';
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string, options?: ProfileOptions & AggregateOptions): Array<string>;
type ProfileAggeregateRawReply = ProfileRawReply<AggregateRawReply>;
export declare function transformReply(reply: ProfileAggeregateRawReply): ProfileReply;
export {};

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = void 0;
const AGGREGATE_1 = require("./AGGREGATE");
const _1 = require(".");
exports.IS_READ_ONLY = true;
function transformArguments(index, query, options) {
const args = ['FT.PROFILE', index, 'AGGREGATE'];
if (options?.LIMITED) {
args.push('LIMITED');
}
args.push('QUERY', query);
(0, AGGREGATE_1.pushAggregatehOptions)(args, options);
return args;
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
return {
results: (0, AGGREGATE_1.transformReply)(reply[0]),
profile: (0, _1.transformProfile)(reply[1])
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,8 @@
import { SearchOptions, SearchRawReply } from './SEARCH';
import { ProfileOptions, ProfileRawReply, ProfileReply } from '.';
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string, options?: ProfileOptions & SearchOptions): RedisCommandArguments;
type ProfileSearchRawReply = ProfileRawReply<SearchRawReply>;
export declare function transformReply(reply: ProfileSearchRawReply, withoutDocuments: boolean): ProfileReply;
export {};

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = void 0;
const SEARCH_1 = require("./SEARCH");
const _1 = require(".");
exports.IS_READ_ONLY = true;
function transformArguments(index, query, options) {
let args = ['FT.PROFILE', index, 'SEARCH'];
if (options?.LIMITED) {
args.push('LIMITED');
}
args.push('QUERY', query);
return (0, _1.pushSearchOptions)(args, options);
}
exports.transformArguments = transformArguments;
function transformReply(reply, withoutDocuments) {
return {
results: (0, SEARCH_1.transformReply)(reply[0], withoutDocuments),
profile: (0, _1.transformProfile)(reply[1])
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,41 @@
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
import { RedisSearchLanguages, Params, PropertyName, SortByProperty, SearchReply } from '.';
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export interface SearchOptions {
VERBATIM?: true;
NOSTOPWORDS?: true;
WITHSORTKEYS?: true;
INKEYS?: string | Array<string>;
INFIELDS?: string | Array<string>;
RETURN?: string | Array<string>;
SUMMARIZE?: true | {
FIELDS?: PropertyName | Array<PropertyName>;
FRAGS?: number;
LEN?: number;
SEPARATOR?: string;
};
HIGHLIGHT?: true | {
FIELDS?: PropertyName | Array<PropertyName>;
TAGS?: {
open: string;
close: string;
};
};
SLOP?: number;
INORDER?: true;
LANGUAGE?: RedisSearchLanguages;
EXPANDER?: string;
SCORER?: string;
SORTBY?: SortByProperty;
LIMIT?: {
from: number | string;
size: number | string;
};
PARAMS?: Params;
DIALECT?: number;
TIMEOUT?: number;
}
export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments;
export type SearchRawReply = Array<any>;
export declare function transformReply(reply: SearchRawReply, withoutDocuments: boolean): SearchReply;

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
const _1 = require(".");
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(index, query, options) {
return (0, _1.pushSearchOptions)(['FT.SEARCH', index, query], options);
}
exports.transformArguments = transformArguments;
function transformReply(reply, withoutDocuments) {
const documents = [];
let i = 1;
while (i < reply.length) {
documents.push({
id: reply[i++],
value: withoutDocuments ? Object.create(null) : documentValue(reply[i++])
});
}
return {
total: reply[0],
documents
};
}
exports.transformReply = transformReply;
function documentValue(tuples) {
const message = Object.create(null);
let i = 0;
while (i < tuples.length) {
const key = tuples[i++], value = tuples[i++];
if (key === '$') { // might be a JSON reply
try {
Object.assign(message, JSON.parse(value));
continue;
}
catch {
// set as a regular property if not a valid JSON
}
}
message[key] = value;
}
return message;
}

View File

@@ -0,0 +1,10 @@
import { RedisCommandArguments } from "@redis/client/dist/lib/commands";
import { SearchOptions, SearchRawReply } from "./SEARCH";
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments;
export interface SearchNoContentReply {
total: number;
documents: Array<string>;
}
export declare function transformReply(reply: SearchRawReply): SearchNoContentReply;

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
const _1 = require(".");
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(index, query, options) {
return (0, _1.pushSearchOptions)(['FT.SEARCH', index, query, 'NOCONTENT'], options);
}
exports.transformArguments = transformArguments;
;
function transformReply(reply) {
return {
total: reply[0],
documents: reply.slice(1)
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,24 @@
interface SpellCheckTerms {
mode: 'INCLUDE' | 'EXCLUDE';
dictionary: string;
}
interface SpellCheckOptions {
DISTANCE?: number;
TERMS?: SpellCheckTerms | Array<SpellCheckTerms>;
DIALECT?: number;
}
export declare function transformArguments(index: string, query: string, options?: SpellCheckOptions): Array<string>;
type SpellCheckRawReply = Array<[
_: string,
term: string,
suggestions: Array<[score: string, suggestion: string]>
]>;
type SpellCheckReply = Array<{
term: string;
suggestions: Array<{
score: number;
suggestion: string;
}>;
}>;
export declare function transformReply(rawReply: SpellCheckRawReply): SpellCheckReply;
export {};

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
function transformArguments(index, query, options) {
const args = ['FT.SPELLCHECK', index, query];
if (options?.DISTANCE) {
args.push('DISTANCE', options.DISTANCE.toString());
}
if (options?.TERMS) {
if (Array.isArray(options.TERMS)) {
for (const term of options.TERMS) {
pushTerms(args, term);
}
}
else {
pushTerms(args, options.TERMS);
}
}
if (options?.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
return args;
}
exports.transformArguments = transformArguments;
function pushTerms(args, { mode, dictionary }) {
args.push('TERMS', mode, dictionary);
}
function transformReply(rawReply) {
return rawReply.map(([, term, suggestions]) => ({
term,
suggestions: suggestions.map(([score, suggestion]) => ({
score: Number(score),
suggestion
}))
}));
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,7 @@
interface SugAddOptions {
INCR?: true;
PAYLOAD?: string;
}
export declare function transformArguments(key: string, string: string, score: number, options?: SugAddOptions): Array<string>;
export declare function transformReply(): number;
export {};

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(key, string, score, options) {
const args = ['FT.SUGADD', key, string, score.toString()];
if (options?.INCR) {
args.push('INCR');
}
if (options?.PAYLOAD) {
args.push('PAYLOAD', options.PAYLOAD);
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(key: string, string: string): Array<string>;
export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
function transformArguments(key, string) {
return ['FT.SUGDEL', key, string];
}
exports.transformArguments = transformArguments;
var generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return generic_transformers_1.transformBooleanReply; } });

View File

@@ -0,0 +1,7 @@
export declare const IS_READ_ONLY = true;
export interface SugGetOptions {
FUZZY?: true;
MAX?: number;
}
export declare function transformArguments(key: string, prefix: string, options?: SugGetOptions): Array<string>;
export declare function transformReply(): null | Array<string>;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = void 0;
exports.IS_READ_ONLY = true;
function transformArguments(key, prefix, options) {
const args = ['FT.SUGGET', key, prefix];
if (options?.FUZZY) {
args.push('FUZZY');
}
if (options?.MAX) {
args.push('MAX', options.MAX.toString());
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,8 @@
import { SugGetOptions } from './SUGGET';
export { IS_READ_ONLY } from './SUGGET';
export declare function transformArguments(key: string, prefix: string, options?: SugGetOptions): Array<string>;
export interface SuggestionWithPayload {
suggestion: string;
payload: string | null;
}
export declare function transformReply(rawReply: Array<string | null> | null): Array<SuggestionWithPayload> | null;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = void 0;
const SUGGET_1 = require("./SUGGET");
var SUGGET_2 = require("./SUGGET");
Object.defineProperty(exports, "IS_READ_ONLY", { enumerable: true, get: function () { return SUGGET_2.IS_READ_ONLY; } });
function transformArguments(key, prefix, options) {
return [
...(0, SUGGET_1.transformArguments)(key, prefix, options),
'WITHPAYLOADS'
];
}
exports.transformArguments = transformArguments;
function transformReply(rawReply) {
if (rawReply === null)
return null;
const transformedReply = [];
for (let i = 0; i < rawReply.length; i += 2) {
transformedReply.push({
suggestion: rawReply[i],
payload: rawReply[i + 1]
});
}
return transformedReply;
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,8 @@
import { SugGetOptions } from './SUGGET';
export { IS_READ_ONLY } from './SUGGET';
export declare function transformArguments(key: string, prefix: string, options?: SugGetOptions): Array<string>;
export interface SuggestionWithScores {
suggestion: string;
score: number;
}
export declare function transformReply(rawReply: Array<string> | null): Array<SuggestionWithScores> | null;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = void 0;
const SUGGET_1 = require("./SUGGET");
var SUGGET_2 = require("./SUGGET");
Object.defineProperty(exports, "IS_READ_ONLY", { enumerable: true, get: function () { return SUGGET_2.IS_READ_ONLY; } });
function transformArguments(key, prefix, options) {
return [
...(0, SUGGET_1.transformArguments)(key, prefix, options),
'WITHSCORES'
];
}
exports.transformArguments = transformArguments;
function transformReply(rawReply) {
if (rawReply === null)
return null;
const transformedReply = [];
for (let i = 0; i < rawReply.length; i += 2) {
transformedReply.push({
suggestion: rawReply[i],
score: Number(rawReply[i + 1])
});
}
return transformedReply;
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,7 @@
import { SugGetOptions } from './SUGGET';
import { SuggestionWithPayload } from './SUGGET_WITHPAYLOADS';
import { SuggestionWithScores } from './SUGGET_WITHSCORES';
export { IS_READ_ONLY } from './SUGGET';
export declare function transformArguments(key: string, prefix: string, options?: SugGetOptions): Array<string>;
type SuggestionWithScoresAndPayloads = SuggestionWithScores & SuggestionWithPayload;
export declare function transformReply(rawReply: Array<string | null> | null): Array<SuggestionWithScoresAndPayloads> | null;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = void 0;
const SUGGET_1 = require("./SUGGET");
var SUGGET_2 = require("./SUGGET");
Object.defineProperty(exports, "IS_READ_ONLY", { enumerable: true, get: function () { return SUGGET_2.IS_READ_ONLY; } });
function transformArguments(key, prefix, options) {
return [
...(0, SUGGET_1.transformArguments)(key, prefix, options),
'WITHSCORES',
'WITHPAYLOADS'
];
}
exports.transformArguments = transformArguments;
function transformReply(rawReply) {
if (rawReply === null)
return null;
const transformedReply = [];
for (let i = 0; i < rawReply.length; i += 3) {
transformedReply.push({
suggestion: rawReply[i],
score: Number(rawReply[i + 1]),
payload: rawReply[i + 2]
});
}
return transformedReply;
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,3 @@
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: string): Array<string>;
export declare function transformReply(): number;

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = void 0;
exports.IS_READ_ONLY = true;
function transformArguments(key) {
return ['FT.SUGLEN', key];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(index: string): Array<string>;
export declare function transformReply(): Array<string>;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(index) {
return ['FT.SYNDUMP', index];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,7 @@
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
interface SynUpdateOptions {
SKIPINITIALSCAN?: true;
}
export declare function transformArguments(index: string, groupId: string, terms: string | Array<string>, options?: SynUpdateOptions): RedisCommandArguments;
export declare function transformReply(): 'OK';
export {};

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
function transformArguments(index, groupId, terms, options) {
const args = ['FT.SYNUPDATE', index, groupId];
if (options?.SKIPINITIALSCAN) {
args.push('SKIPINITIALSCAN');
}
return (0, generic_transformers_1.pushVerdictArguments)(args, terms);
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(index: string, fieldName: string): Array<string>;
export declare function transformReply(): Array<string>;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments(index, fieldName) {
return ['FT.TAGVALS', index, fieldName];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,2 @@
export declare function transformArguments(): Array<string>;
export declare function transformReply(): Array<string>;

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = void 0;
function transformArguments() {
return ['FT._LIST'];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,267 @@
import * as _LIST from './_LIST';
import * as ALTER from './ALTER';
import * as AGGREGATE_WITHCURSOR from './AGGREGATE_WITHCURSOR';
import * as AGGREGATE from './AGGREGATE';
import * as ALIASADD from './ALIASADD';
import * as ALIASDEL from './ALIASDEL';
import * as ALIASUPDATE from './ALIASUPDATE';
import * as CONFIG_GET from './CONFIG_GET';
import * as CONFIG_SET from './CONFIG_SET';
import * as CREATE from './CREATE';
import * as CURSOR_DEL from './CURSOR_DEL';
import * as CURSOR_READ from './CURSOR_READ';
import * as DICTADD from './DICTADD';
import * as DICTDEL from './DICTDEL';
import * as DICTDUMP from './DICTDUMP';
import * as DROPINDEX from './DROPINDEX';
import * as EXPLAIN from './EXPLAIN';
import * as EXPLAINCLI from './EXPLAINCLI';
import * as INFO from './INFO';
import * as PROFILESEARCH from './PROFILE_SEARCH';
import * as PROFILEAGGREGATE from './PROFILE_AGGREGATE';
import * as SEARCH from './SEARCH';
import * as SEARCH_NOCONTENT from './SEARCH_NOCONTENT';
import * as SPELLCHECK from './SPELLCHECK';
import * as SUGADD from './SUGADD';
import * as SUGDEL from './SUGDEL';
import * as SUGGET_WITHPAYLOADS from './SUGGET_WITHPAYLOADS';
import * as SUGGET_WITHSCORES_WITHPAYLOADS from './SUGGET_WITHSCORES_WITHPAYLOADS';
import * as SUGGET_WITHSCORES from './SUGGET_WITHSCORES';
import * as SUGGET from './SUGGET';
import * as SUGLEN from './SUGLEN';
import * as SYNDUMP from './SYNDUMP';
import * as SYNUPDATE from './SYNUPDATE';
import * as TAGVALS from './TAGVALS';
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
import { SearchOptions } from './SEARCH';
declare const _default: {
_LIST: typeof _LIST;
_list: typeof _LIST;
ALTER: typeof ALTER;
alter: typeof ALTER;
AGGREGATE_WITHCURSOR: typeof AGGREGATE_WITHCURSOR;
aggregateWithCursor: typeof AGGREGATE_WITHCURSOR;
AGGREGATE: typeof AGGREGATE;
aggregate: typeof AGGREGATE;
ALIASADD: typeof ALIASADD;
aliasAdd: typeof ALIASADD;
ALIASDEL: typeof ALIASDEL;
aliasDel: typeof ALIASDEL;
ALIASUPDATE: typeof ALIASUPDATE;
aliasUpdate: typeof ALIASUPDATE;
CONFIG_GET: typeof CONFIG_GET;
configGet: typeof CONFIG_GET;
CONFIG_SET: typeof CONFIG_SET;
configSet: typeof CONFIG_SET;
CREATE: typeof CREATE;
create: typeof CREATE;
CURSOR_DEL: typeof CURSOR_DEL;
cursorDel: typeof CURSOR_DEL;
CURSOR_READ: typeof CURSOR_READ;
cursorRead: typeof CURSOR_READ;
DICTADD: typeof DICTADD;
dictAdd: typeof DICTADD;
DICTDEL: typeof DICTDEL;
dictDel: typeof DICTDEL;
DICTDUMP: typeof DICTDUMP;
dictDump: typeof DICTDUMP;
DROPINDEX: typeof DROPINDEX;
dropIndex: typeof DROPINDEX;
EXPLAIN: typeof EXPLAIN;
explain: typeof EXPLAIN;
EXPLAINCLI: typeof EXPLAINCLI;
explainCli: typeof EXPLAINCLI;
INFO: typeof INFO;
info: typeof INFO;
PROFILESEARCH: typeof PROFILESEARCH;
profileSearch: typeof PROFILESEARCH;
PROFILEAGGREGATE: typeof PROFILEAGGREGATE;
profileAggregate: typeof PROFILEAGGREGATE;
SEARCH: typeof SEARCH;
search: typeof SEARCH;
SEARCH_NOCONTENT: typeof SEARCH_NOCONTENT;
searchNoContent: typeof SEARCH_NOCONTENT;
SPELLCHECK: typeof SPELLCHECK;
spellCheck: typeof SPELLCHECK;
SUGADD: typeof SUGADD;
sugAdd: typeof SUGADD;
SUGDEL: typeof SUGDEL;
sugDel: typeof SUGDEL;
SUGGET_WITHPAYLOADS: typeof SUGGET_WITHPAYLOADS;
sugGetWithPayloads: typeof SUGGET_WITHPAYLOADS;
SUGGET_WITHSCORES_WITHPAYLOADS: typeof SUGGET_WITHSCORES_WITHPAYLOADS;
sugGetWithScoresWithPayloads: typeof SUGGET_WITHSCORES_WITHPAYLOADS;
SUGGET_WITHSCORES: typeof SUGGET_WITHSCORES;
sugGetWithScores: typeof SUGGET_WITHSCORES;
SUGGET: typeof SUGGET;
sugGet: typeof SUGGET;
SUGLEN: typeof SUGLEN;
sugLen: typeof SUGLEN;
SYNDUMP: typeof SYNDUMP;
synDump: typeof SYNDUMP;
SYNUPDATE: typeof SYNUPDATE;
synUpdate: typeof SYNUPDATE;
TAGVALS: typeof TAGVALS;
tagVals: typeof TAGVALS;
};
export default _default;
export declare enum RedisSearchLanguages {
ARABIC = "Arabic",
BASQUE = "Basque",
CATALANA = "Catalan",
DANISH = "Danish",
DUTCH = "Dutch",
ENGLISH = "English",
FINNISH = "Finnish",
FRENCH = "French",
GERMAN = "German",
GREEK = "Greek",
HUNGARIAN = "Hungarian",
INDONESAIN = "Indonesian",
IRISH = "Irish",
ITALIAN = "Italian",
LITHUANIAN = "Lithuanian",
NEPALI = "Nepali",
NORWEIGAN = "Norwegian",
PORTUGUESE = "Portuguese",
ROMANIAN = "Romanian",
RUSSIAN = "Russian",
SPANISH = "Spanish",
SWEDISH = "Swedish",
TAMIL = "Tamil",
TURKISH = "Turkish",
CHINESE = "Chinese"
}
export type PropertyName = `${'@' | '$.'}${string}`;
export type SortByProperty = string | {
BY: string;
DIRECTION?: 'ASC' | 'DESC';
};
export declare function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void;
export declare function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array<SortByProperty>): RedisCommandArguments;
export declare function pushArgumentsWithLength(args: RedisCommandArguments, fn: (args: RedisCommandArguments) => void): RedisCommandArguments;
export declare enum SchemaFieldTypes {
TEXT = "TEXT",
NUMERIC = "NUMERIC",
GEO = "GEO",
TAG = "TAG",
VECTOR = "VECTOR",
GEOSHAPE = "GEOSHAPE"
}
type CreateSchemaField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = T | ({
type: T;
AS?: string;
INDEXMISSING?: boolean;
} & E);
type CommonFieldArguments = {
SORTABLE?: boolean | 'UNF';
NOINDEX?: boolean;
};
type CreateSchemaCommonField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = CreateSchemaField<T, (CommonFieldArguments & E)>;
export declare enum SchemaTextFieldPhonetics {
DM_EN = "dm:en",
DM_FR = "dm:fr",
FM_PT = "dm:pt",
DM_ES = "dm:es"
}
type CreateSchemaTextField = CreateSchemaCommonField<SchemaFieldTypes.TEXT, {
NOSTEM?: true;
WEIGHT?: number;
PHONETIC?: SchemaTextFieldPhonetics;
WITHSUFFIXTRIE?: boolean;
INDEXEMPTY?: boolean;
}>;
type CreateSchemaNumericField = CreateSchemaCommonField<SchemaFieldTypes.NUMERIC>;
type CreateSchemaGeoField = CreateSchemaCommonField<SchemaFieldTypes.GEO>;
type CreateSchemaTagField = CreateSchemaCommonField<SchemaFieldTypes.TAG, {
SEPARATOR?: string;
CASESENSITIVE?: true;
WITHSUFFIXTRIE?: boolean;
INDEXEMPTY?: boolean;
}>;
export declare enum VectorAlgorithms {
FLAT = "FLAT",
HNSW = "HNSW"
}
type CreateSchemaVectorField<T extends VectorAlgorithms, A extends Record<string, unknown>> = CreateSchemaField<SchemaFieldTypes.VECTOR, {
ALGORITHM: T;
TYPE: string;
DIM: number;
DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
INITIAL_CAP?: number;
} & A>;
type CreateSchemaFlatVectorField = CreateSchemaVectorField<VectorAlgorithms.FLAT, {
BLOCK_SIZE?: number;
}>;
type CreateSchemaHNSWVectorField = CreateSchemaVectorField<VectorAlgorithms.HNSW, {
M?: number;
EF_CONSTRUCTION?: number;
EF_RUNTIME?: number;
}>;
export declare const SCHEMA_GEO_SHAPE_COORD_SYSTEM: {
readonly SPHERICAL: "SPHERICAL";
readonly FLAT: "FLAT";
};
export type SchemaGeoShapeFieldCoordSystem = typeof SCHEMA_GEO_SHAPE_COORD_SYSTEM[keyof typeof SCHEMA_GEO_SHAPE_COORD_SYSTEM];
type CreateSchemaGeoShapeField = CreateSchemaCommonField<SchemaFieldTypes.GEOSHAPE, {
COORD_SYSTEM?: SchemaGeoShapeFieldCoordSystem;
}>;
export interface RediSearchSchema {
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField | CreateSchemaFlatVectorField | CreateSchemaHNSWVectorField | CreateSchemaGeoShapeField;
}
export declare function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema): void;
export type Params = Record<string, RedisCommandArgument | number>;
export declare function pushParamsArgs(args: RedisCommandArguments, params?: Params): RedisCommandArguments;
export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments;
interface SearchDocumentValue {
[key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue;
}
export interface SearchReply {
total: number;
documents: Array<{
id: string;
value: SearchDocumentValue;
}>;
}
export interface ProfileOptions {
LIMITED?: true;
}
export type ProfileRawReply<T> = [
results: T,
profile: [
_: string,
TotalProfileTime: string,
_: string,
ParsingTime: string,
_: string,
PipelineCreationTime: string,
_: string,
IteratorsProfile: Array<any>
]
];
export interface ProfileReply {
results: SearchReply | AGGREGATE.AggregateReply;
profile: ProfileData;
}
interface ChildIterator {
type?: string;
counter?: number;
term?: string;
size?: number;
time?: string;
childIterators?: Array<ChildIterator>;
}
interface IteratorsProfile {
type?: string;
counter?: number;
queryType?: string;
time?: string;
childIterators?: Array<ChildIterator>;
}
interface ProfileData {
totalProfileTime: string;
parsingTime: string;
pipelineCreationTime: string;
iteratorsProfile: IteratorsProfile;
}
export declare function transformProfile(reply: Array<any>): ProfileData;

View File

@@ -0,0 +1,458 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformProfile = exports.pushSearchOptions = exports.pushParamsArgs = exports.pushSchema = exports.SCHEMA_GEO_SHAPE_COORD_SYSTEM = exports.VectorAlgorithms = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.pushArgumentsWithLength = exports.pushSortByArguments = exports.pushSortByProperty = exports.RedisSearchLanguages = void 0;
const _LIST = require("./_LIST");
const ALTER = require("./ALTER");
const AGGREGATE_WITHCURSOR = require("./AGGREGATE_WITHCURSOR");
const AGGREGATE = require("./AGGREGATE");
const ALIASADD = require("./ALIASADD");
const ALIASDEL = require("./ALIASDEL");
const ALIASUPDATE = require("./ALIASUPDATE");
const CONFIG_GET = require("./CONFIG_GET");
const CONFIG_SET = require("./CONFIG_SET");
const CREATE = require("./CREATE");
const CURSOR_DEL = require("./CURSOR_DEL");
const CURSOR_READ = require("./CURSOR_READ");
const DICTADD = require("./DICTADD");
const DICTDEL = require("./DICTDEL");
const DICTDUMP = require("./DICTDUMP");
const DROPINDEX = require("./DROPINDEX");
const EXPLAIN = require("./EXPLAIN");
const EXPLAINCLI = require("./EXPLAINCLI");
const INFO = require("./INFO");
const PROFILESEARCH = require("./PROFILE_SEARCH");
const PROFILEAGGREGATE = require("./PROFILE_AGGREGATE");
const SEARCH = require("./SEARCH");
const SEARCH_NOCONTENT = require("./SEARCH_NOCONTENT");
const SPELLCHECK = require("./SPELLCHECK");
const SUGADD = require("./SUGADD");
const SUGDEL = require("./SUGDEL");
const SUGGET_WITHPAYLOADS = require("./SUGGET_WITHPAYLOADS");
const SUGGET_WITHSCORES_WITHPAYLOADS = require("./SUGGET_WITHSCORES_WITHPAYLOADS");
const SUGGET_WITHSCORES = require("./SUGGET_WITHSCORES");
const SUGGET = require("./SUGGET");
const SUGLEN = require("./SUGLEN");
const SYNDUMP = require("./SYNDUMP");
const SYNUPDATE = require("./SYNUPDATE");
const TAGVALS = require("./TAGVALS");
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
exports.default = {
_LIST,
_list: _LIST,
ALTER,
alter: ALTER,
AGGREGATE_WITHCURSOR,
aggregateWithCursor: AGGREGATE_WITHCURSOR,
AGGREGATE,
aggregate: AGGREGATE,
ALIASADD,
aliasAdd: ALIASADD,
ALIASDEL,
aliasDel: ALIASDEL,
ALIASUPDATE,
aliasUpdate: ALIASUPDATE,
CONFIG_GET,
configGet: CONFIG_GET,
CONFIG_SET,
configSet: CONFIG_SET,
CREATE,
create: CREATE,
CURSOR_DEL,
cursorDel: CURSOR_DEL,
CURSOR_READ,
cursorRead: CURSOR_READ,
DICTADD,
dictAdd: DICTADD,
DICTDEL,
dictDel: DICTDEL,
DICTDUMP,
dictDump: DICTDUMP,
DROPINDEX,
dropIndex: DROPINDEX,
EXPLAIN,
explain: EXPLAIN,
EXPLAINCLI,
explainCli: EXPLAINCLI,
INFO,
info: INFO,
PROFILESEARCH,
profileSearch: PROFILESEARCH,
PROFILEAGGREGATE,
profileAggregate: PROFILEAGGREGATE,
SEARCH,
search: SEARCH,
SEARCH_NOCONTENT,
searchNoContent: SEARCH_NOCONTENT,
SPELLCHECK,
spellCheck: SPELLCHECK,
SUGADD,
sugAdd: SUGADD,
SUGDEL,
sugDel: SUGDEL,
SUGGET_WITHPAYLOADS,
sugGetWithPayloads: SUGGET_WITHPAYLOADS,
SUGGET_WITHSCORES_WITHPAYLOADS,
sugGetWithScoresWithPayloads: SUGGET_WITHSCORES_WITHPAYLOADS,
SUGGET_WITHSCORES,
sugGetWithScores: SUGGET_WITHSCORES,
SUGGET,
sugGet: SUGGET,
SUGLEN,
sugLen: SUGLEN,
SYNDUMP,
synDump: SYNDUMP,
SYNUPDATE,
synUpdate: SYNUPDATE,
TAGVALS,
tagVals: TAGVALS
};
var RedisSearchLanguages;
(function (RedisSearchLanguages) {
RedisSearchLanguages["ARABIC"] = "Arabic";
RedisSearchLanguages["BASQUE"] = "Basque";
RedisSearchLanguages["CATALANA"] = "Catalan";
RedisSearchLanguages["DANISH"] = "Danish";
RedisSearchLanguages["DUTCH"] = "Dutch";
RedisSearchLanguages["ENGLISH"] = "English";
RedisSearchLanguages["FINNISH"] = "Finnish";
RedisSearchLanguages["FRENCH"] = "French";
RedisSearchLanguages["GERMAN"] = "German";
RedisSearchLanguages["GREEK"] = "Greek";
RedisSearchLanguages["HUNGARIAN"] = "Hungarian";
RedisSearchLanguages["INDONESAIN"] = "Indonesian";
RedisSearchLanguages["IRISH"] = "Irish";
RedisSearchLanguages["ITALIAN"] = "Italian";
RedisSearchLanguages["LITHUANIAN"] = "Lithuanian";
RedisSearchLanguages["NEPALI"] = "Nepali";
RedisSearchLanguages["NORWEIGAN"] = "Norwegian";
RedisSearchLanguages["PORTUGUESE"] = "Portuguese";
RedisSearchLanguages["ROMANIAN"] = "Romanian";
RedisSearchLanguages["RUSSIAN"] = "Russian";
RedisSearchLanguages["SPANISH"] = "Spanish";
RedisSearchLanguages["SWEDISH"] = "Swedish";
RedisSearchLanguages["TAMIL"] = "Tamil";
RedisSearchLanguages["TURKISH"] = "Turkish";
RedisSearchLanguages["CHINESE"] = "Chinese";
})(RedisSearchLanguages || (exports.RedisSearchLanguages = RedisSearchLanguages = {}));
function pushSortByProperty(args, sortBy) {
if (typeof sortBy === 'string') {
args.push(sortBy);
}
else {
args.push(sortBy.BY);
if (sortBy.DIRECTION) {
args.push(sortBy.DIRECTION);
}
}
}
exports.pushSortByProperty = pushSortByProperty;
function pushSortByArguments(args, name, sortBy) {
const lengthBefore = args.push(name, '' // will be overwritten
);
if (Array.isArray(sortBy)) {
for (const field of sortBy) {
pushSortByProperty(args, field);
}
}
else {
pushSortByProperty(args, sortBy);
}
args[lengthBefore - 1] = (args.length - lengthBefore).toString();
return args;
}
exports.pushSortByArguments = pushSortByArguments;
function pushArgumentsWithLength(args, fn) {
const lengthIndex = args.push('') - 1;
fn(args);
args[lengthIndex] = (args.length - lengthIndex - 1).toString();
return args;
}
exports.pushArgumentsWithLength = pushArgumentsWithLength;
var SchemaFieldTypes;
(function (SchemaFieldTypes) {
SchemaFieldTypes["TEXT"] = "TEXT";
SchemaFieldTypes["NUMERIC"] = "NUMERIC";
SchemaFieldTypes["GEO"] = "GEO";
SchemaFieldTypes["TAG"] = "TAG";
SchemaFieldTypes["VECTOR"] = "VECTOR";
SchemaFieldTypes["GEOSHAPE"] = "GEOSHAPE";
})(SchemaFieldTypes || (exports.SchemaFieldTypes = SchemaFieldTypes = {}));
function pushCommonFieldArguments(args, fieldOptions) {
if (fieldOptions.SORTABLE) {
args.push('SORTABLE');
if (fieldOptions.SORTABLE === 'UNF') {
args.push('UNF');
}
}
if (fieldOptions.NOINDEX) {
args.push('NOINDEX');
}
}
var SchemaTextFieldPhonetics;
(function (SchemaTextFieldPhonetics) {
SchemaTextFieldPhonetics["DM_EN"] = "dm:en";
SchemaTextFieldPhonetics["DM_FR"] = "dm:fr";
SchemaTextFieldPhonetics["FM_PT"] = "dm:pt";
SchemaTextFieldPhonetics["DM_ES"] = "dm:es";
})(SchemaTextFieldPhonetics || (exports.SchemaTextFieldPhonetics = SchemaTextFieldPhonetics = {}));
var VectorAlgorithms;
(function (VectorAlgorithms) {
VectorAlgorithms["FLAT"] = "FLAT";
VectorAlgorithms["HNSW"] = "HNSW";
})(VectorAlgorithms || (exports.VectorAlgorithms = VectorAlgorithms = {}));
exports.SCHEMA_GEO_SHAPE_COORD_SYSTEM = {
SPHERICAL: 'SPHERICAL',
FLAT: 'FLAT'
};
function pushSchema(args, schema) {
for (const [field, fieldOptions] of Object.entries(schema)) {
args.push(field);
if (typeof fieldOptions === 'string') {
args.push(fieldOptions);
continue;
}
if (fieldOptions.AS) {
args.push('AS', fieldOptions.AS);
}
args.push(fieldOptions.type);
switch (fieldOptions.type) {
case SchemaFieldTypes.TEXT:
if (fieldOptions.NOSTEM) {
args.push('NOSTEM');
}
if (fieldOptions.WEIGHT) {
args.push('WEIGHT', fieldOptions.WEIGHT.toString());
}
if (fieldOptions.PHONETIC) {
args.push('PHONETIC', fieldOptions.PHONETIC);
}
if (fieldOptions.WITHSUFFIXTRIE) {
args.push('WITHSUFFIXTRIE');
}
pushCommonFieldArguments(args, fieldOptions);
if (fieldOptions.INDEXEMPTY) {
args.push('INDEXEMPTY');
}
break;
case SchemaFieldTypes.NUMERIC:
case SchemaFieldTypes.GEO:
pushCommonFieldArguments(args, fieldOptions);
break;
case SchemaFieldTypes.TAG:
if (fieldOptions.SEPARATOR) {
args.push('SEPARATOR', fieldOptions.SEPARATOR);
}
if (fieldOptions.CASESENSITIVE) {
args.push('CASESENSITIVE');
}
if (fieldOptions.WITHSUFFIXTRIE) {
args.push('WITHSUFFIXTRIE');
}
pushCommonFieldArguments(args, fieldOptions);
if (fieldOptions.INDEXEMPTY) {
args.push('INDEXEMPTY');
}
break;
case SchemaFieldTypes.VECTOR:
args.push(fieldOptions.ALGORITHM);
pushArgumentsWithLength(args, () => {
args.push('TYPE', fieldOptions.TYPE, 'DIM', fieldOptions.DIM.toString(), 'DISTANCE_METRIC', fieldOptions.DISTANCE_METRIC);
if (fieldOptions.INITIAL_CAP) {
args.push('INITIAL_CAP', fieldOptions.INITIAL_CAP.toString());
}
switch (fieldOptions.ALGORITHM) {
case VectorAlgorithms.FLAT:
if (fieldOptions.BLOCK_SIZE) {
args.push('BLOCK_SIZE', fieldOptions.BLOCK_SIZE.toString());
}
break;
case VectorAlgorithms.HNSW:
if (fieldOptions.M) {
args.push('M', fieldOptions.M.toString());
}
if (fieldOptions.EF_CONSTRUCTION) {
args.push('EF_CONSTRUCTION', fieldOptions.EF_CONSTRUCTION.toString());
}
if (fieldOptions.EF_RUNTIME) {
args.push('EF_RUNTIME', fieldOptions.EF_RUNTIME.toString());
}
break;
}
});
break;
case SchemaFieldTypes.GEOSHAPE:
if (fieldOptions.COORD_SYSTEM !== undefined) {
args.push('COORD_SYSTEM', fieldOptions.COORD_SYSTEM);
}
pushCommonFieldArguments(args, fieldOptions);
break;
}
if (fieldOptions.INDEXMISSING) {
args.push('INDEXMISSING');
}
}
}
exports.pushSchema = pushSchema;
function pushParamsArgs(args, params) {
if (params) {
const enrties = Object.entries(params);
args.push('PARAMS', (enrties.length * 2).toString());
for (const [key, value] of enrties) {
args.push(key, typeof value === 'number' ? value.toString() : value);
}
}
return args;
}
exports.pushParamsArgs = pushParamsArgs;
function pushSearchOptions(args, options) {
if (options?.VERBATIM) {
args.push('VERBATIM');
}
if (options?.NOSTOPWORDS) {
args.push('NOSTOPWORDS');
}
// if (options?.WITHSCORES) {
// args.push('WITHSCORES');
// }
// if (options?.WITHPAYLOADS) {
// args.push('WITHPAYLOADS');
// }
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INKEYS', options?.INKEYS);
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INFIELDS', options?.INFIELDS);
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'RETURN', options?.RETURN);
if (options?.SUMMARIZE) {
args.push('SUMMARIZE');
if (typeof options.SUMMARIZE === 'object') {
if (options.SUMMARIZE.FIELDS) {
args.push('FIELDS');
(0, generic_transformers_1.pushVerdictArgument)(args, options.SUMMARIZE.FIELDS);
}
if (options.SUMMARIZE.FRAGS) {
args.push('FRAGS', options.SUMMARIZE.FRAGS.toString());
}
if (options.SUMMARIZE.LEN) {
args.push('LEN', options.SUMMARIZE.LEN.toString());
}
if (options.SUMMARIZE.SEPARATOR) {
args.push('SEPARATOR', options.SUMMARIZE.SEPARATOR);
}
}
}
if (options?.HIGHLIGHT) {
args.push('HIGHLIGHT');
if (typeof options.HIGHLIGHT === 'object') {
if (options.HIGHLIGHT.FIELDS) {
args.push('FIELDS');
(0, generic_transformers_1.pushVerdictArgument)(args, options.HIGHLIGHT.FIELDS);
}
if (options.HIGHLIGHT.TAGS) {
args.push('TAGS', options.HIGHLIGHT.TAGS.open, options.HIGHLIGHT.TAGS.close);
}
}
}
if (options?.SLOP) {
args.push('SLOP', options.SLOP.toString());
}
if (options?.INORDER) {
args.push('INORDER');
}
if (options?.LANGUAGE) {
args.push('LANGUAGE', options.LANGUAGE);
}
if (options?.EXPANDER) {
args.push('EXPANDER', options.EXPANDER);
}
if (options?.SCORER) {
args.push('SCORER', options.SCORER);
}
// if (options?.EXPLAINSCORE) {
// args.push('EXPLAINSCORE');
// }
// if (options?.PAYLOAD) {
// args.push('PAYLOAD', options.PAYLOAD);
// }
if (options?.SORTBY) {
args.push('SORTBY');
pushSortByProperty(args, options.SORTBY);
}
// if (options?.MSORTBY) {
// pushSortByArguments(args, 'MSORTBY', options.MSORTBY);
// }
if (options?.LIMIT) {
args.push('LIMIT', options.LIMIT.from.toString(), options.LIMIT.size.toString());
}
if (options?.PARAMS) {
pushParamsArgs(args, options.PARAMS);
}
if (options?.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
if (options?.RETURN?.length === 0) {
args.preserve = true;
}
if (options?.TIMEOUT !== undefined) {
args.push('TIMEOUT', options.TIMEOUT.toString());
}
return args;
}
exports.pushSearchOptions = pushSearchOptions;
function transformProfile(reply) {
return {
totalProfileTime: reply[0][1],
parsingTime: reply[1][1],
pipelineCreationTime: reply[2][1],
iteratorsProfile: transformIterators(reply[3][1])
};
}
exports.transformProfile = transformProfile;
function transformIterators(IteratorsProfile) {
var res = {};
for (let i = 0; i < IteratorsProfile.length; i += 2) {
const value = IteratorsProfile[i + 1];
switch (IteratorsProfile[i]) {
case 'Type':
res.type = value;
break;
case 'Counter':
res.counter = value;
break;
case 'Time':
res.time = value;
break;
case 'Query type':
res.queryType = value;
break;
case 'Child iterators':
res.childIterators = value.map(transformChildIterators);
break;
}
}
return res;
}
function transformChildIterators(IteratorsProfile) {
var res = {};
for (let i = 1; i < IteratorsProfile.length; i += 2) {
const value = IteratorsProfile[i + 1];
switch (IteratorsProfile[i]) {
case 'Type':
res.type = value;
break;
case 'Counter':
res.counter = value;
break;
case 'Time':
res.time = value;
break;
case 'Size':
res.size = value;
break;
case 'Term':
res.term = value;
break;
case 'Child iterators':
res.childIterators = value.map(transformChildIterators);
break;
}
}
return res;
}

4
backend/node_modules/@redis/search/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export { default } from './commands';
export { RediSearchSchema, RedisSearchLanguages, SchemaFieldTypes, SchemaTextFieldPhonetics, SearchReply, VectorAlgorithms } from './commands';
export { AggregateGroupByReducers, AggregateSteps } from './commands/AGGREGATE';
export { SearchOptions } from './commands/SEARCH';

13
backend/node_modules/@redis/search/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregateSteps = exports.AggregateGroupByReducers = exports.VectorAlgorithms = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.RedisSearchLanguages = exports.default = void 0;
var commands_1 = require("./commands");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return commands_1.default; } });
var commands_2 = require("./commands");
Object.defineProperty(exports, "RedisSearchLanguages", { enumerable: true, get: function () { return commands_2.RedisSearchLanguages; } });
Object.defineProperty(exports, "SchemaFieldTypes", { enumerable: true, get: function () { return commands_2.SchemaFieldTypes; } });
Object.defineProperty(exports, "SchemaTextFieldPhonetics", { enumerable: true, get: function () { return commands_2.SchemaTextFieldPhonetics; } });
Object.defineProperty(exports, "VectorAlgorithms", { enumerable: true, get: function () { return commands_2.VectorAlgorithms; } });
var AGGREGATE_1 = require("./commands/AGGREGATE");
Object.defineProperty(exports, "AggregateGroupByReducers", { enumerable: true, get: function () { return AGGREGATE_1.AggregateGroupByReducers; } });
Object.defineProperty(exports, "AggregateSteps", { enumerable: true, get: function () { return AGGREGATE_1.AggregateSteps; } });

41
backend/node_modules/@redis/search/package.json generated vendored Normal file
View File

@@ -0,0 +1,41 @@
{
"name": "@redis/search",
"version": "1.2.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/"
],
"scripts": {
"test": "nyc -r text-summary -r lcov mocha -r source-map-support/register -r ts-node/register './lib/**/*.spec.ts'",
"build": "tsc",
"documentation": "typedoc"
},
"peerDependencies": {
"@redis/client": "^1.0.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@redis/test-utils": "*",
"@types/node": "^20.6.2",
"nyc": "^15.1.0",
"release-it": "^16.1.5",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
"typescript": "^5.2.2"
},
"repository": {
"type": "git",
"url": "git://github.com/redis/node-redis.git"
},
"bugs": {
"url": "https://github.com/redis/node-redis/issues"
},
"homepage": "https://github.com/redis/node-redis/tree/master/packages/search",
"keywords": [
"redis",
"RediSearch"
]
}