falkordb 6.9.2 → 6.9.3

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.
Files changed (46) hide show
  1. package/README.md +56 -1
  2. package/dist/index.d.ts +6 -1
  3. package/dist/index.js +11 -1
  4. package/dist/src/clients/client.d.ts +23 -5
  5. package/dist/src/clients/client.js +7 -0
  6. package/dist/src/clients/cluster.d.ts +16 -6
  7. package/dist/src/clients/cluster.js +41 -16
  8. package/dist/src/clients/nullClient.d.ts +4 -3
  9. package/dist/src/clients/nullClient.js +5 -2
  10. package/dist/src/clients/single.d.ts +6 -5
  11. package/dist/src/clients/single.js +17 -8
  12. package/dist/src/commands/CONSTRAINT_CREATE.js +3 -1
  13. package/dist/src/commands/CONSTRAINT_DROP.js +3 -1
  14. package/dist/src/commands/COPY.js +3 -1
  15. package/dist/src/commands/EXPLAIN.d.ts +3 -2
  16. package/dist/src/commands/EXPLAIN.js +5 -4
  17. package/dist/src/commands/MEMORY_USAGE.js +7 -4
  18. package/dist/src/commands/PROFILE.d.ts +4 -3
  19. package/dist/src/commands/PROFILE.js +7 -5
  20. package/dist/src/commands/QUERY.js +7 -2
  21. package/dist/src/commands/RO_QUERY.js +5 -1
  22. package/dist/src/commands/SLOWLOG.d.ts +1 -1
  23. package/dist/src/commands/SLOWLOG.js +3 -1
  24. package/dist/src/commands/SLOWLOG_RESET.d.ts +5 -0
  25. package/dist/src/commands/SLOWLOG_RESET.js +19 -0
  26. package/dist/src/commands/index.d.ts +10 -1
  27. package/dist/src/commands/index.js +60 -12
  28. package/dist/src/entities.d.ts +19 -0
  29. package/dist/src/entities.js +121 -0
  30. package/dist/src/execution-plan.d.ts +45 -0
  31. package/dist/src/execution-plan.js +121 -0
  32. package/dist/src/falkordb.js +31 -4
  33. package/dist/src/graph.d.ts +95 -18
  34. package/dist/src/graph.js +321 -75
  35. package/dist/src/query-statistics.d.ts +6 -0
  36. package/dist/src/query-statistics.js +66 -0
  37. package/dist/src/types/falkordb-options.d.ts +8 -0
  38. package/dist/src/types/graph-value.d.ts +11 -5
  39. package/dist/src/types/index.d.ts +2 -0
  40. package/dist/src/types/index.js +2 -0
  41. package/dist/src/types/procedures.d.ts +47 -0
  42. package/dist/src/types/procedures.js +2 -0
  43. package/dist/src/types/query-options.d.ts +6 -1
  44. package/dist/src/types/query-statistics.d.ts +20 -0
  45. package/dist/src/types/query-statistics.js +2 -0
  46. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
1
  import { RedisArgument } from "@redis/client";
2
2
  import { Client } from "./clients/client";
3
3
  import { ConstraintType, EntityType } from "./enums";
4
- import type { GraphReply, MemoryUsageOptions, QueryOptions, QueryReply } from "./types";
4
+ import { ExecutionPlan } from "./execution-plan";
5
+ import type { CallProcedureOptions, ConstraintInfo, GraphReply, IndexInfo, MemoryUsageOptions, PlanOptions, QueryOptions, QueryParam, VectorIndexOptions } from "./types";
5
6
  export { ConstraintType, EntityType };
6
7
  export type { GraphReply };
7
8
  /**
@@ -16,10 +17,14 @@ export interface GraphSchemaState {
16
17
  export interface GraphCacheOptions {
17
18
  schema?: GraphSchemaState;
18
19
  onDelete?: (graph: Graph) => void;
20
+ selectGraph?: (name: string) => Graph;
21
+ integers?: "number" | "bigint";
19
22
  }
20
23
  export default class Graph {
21
24
  #private;
22
25
  constructor(client: Client, name: string, cache?: GraphCacheOptions);
26
+ /** The graph's name (its Redis key) */
27
+ get name(): string;
23
28
  query<T>(query: RedisArgument, options?: QueryOptions): Promise<GraphReply<T>>;
24
29
  roQuery<T>(query: RedisArgument, options?: QueryOptions): Promise<GraphReply<T>>;
25
30
  delete(): Promise<void>;
@@ -31,26 +36,98 @@ export default class Graph {
31
36
  * on the next query, so this is rarely needed.
32
37
  */
33
38
  clearMetadataCache(): void;
34
- explain(query: string): Promise<any>;
35
- profile(query: string): Promise<any>;
39
+ /**
40
+ * Returns the query's execution plan as an operation tree, without running
41
+ * the query. The lines the server returned are kept in `steps`.
42
+ */
43
+ explain(query: string, options?: PlanOptions): Promise<ExecutionPlan>;
44
+ /**
45
+ * Runs the query and returns its execution plan as an operation tree, each
46
+ * operation annotated with its `recordsProduced` and `executionTime`. The
47
+ * lines the server returned are kept in `steps`.
48
+ */
49
+ profile(query: string, options?: PlanOptions): Promise<ExecutionPlan>;
36
50
  memoryUsage(options?: MemoryUsageOptions): Promise<import("./types").MemoryUsageReply>;
37
51
  slowLog(): Promise<import("./types").SlowLogReply>;
52
+ /** Clears the graph's slow log (`GRAPH.SLOWLOG <graph> RESET`) */
53
+ slowLogReset(): Promise<void>;
54
+ /**
55
+ * Calls a procedure, e.g. `callProcedure('db.idx.fulltext.queryNodes', ['Movie', 'Jungle'])`.
56
+ * The arguments are sent as query parameters, so they need no escaping.
57
+ * Runs as a read-only query unless `readOnly` is `false`.
58
+ */
59
+ callProcedure<T>(procedure: string, args?: QueryParam[], options?: CallProcedureOptions): Promise<GraphReply<T>>;
60
+ /** Lists the graph's indexes (`CALL db.indexes()`) */
61
+ listIndices(): Promise<IndexInfo[]>;
62
+ /** Lists the graph's constraints and their status (`CALL db.constraints()`) */
63
+ listConstraints(): Promise<ConstraintInfo[]>;
64
+ /**
65
+ * Creates a constraint (`GRAPH.CONSTRAINT CREATE`).
66
+ *
67
+ * A unique constraint requires a range index on each of its properties, so
68
+ * for `ConstraintType.UNIQUE` this first creates that index on every
69
+ * property that is not indexed yet (an existing index is reused). Mandatory
70
+ * constraints need no index and create none.
71
+ *
72
+ * The constraint is enforced asynchronously: the server accepts it before
73
+ * checking the existing data, so poll `listConstraints()` until its status
74
+ * is `OPERATIONAL` (or `FAILED` if existing entities violate it).
75
+ */
38
76
  constraintCreate(constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
39
77
  constraintDrop(constraintType: ConstraintType, entityType: EntityType, label: string, ...properties: string[]): Promise<void>;
40
- copy(destGraph: string): Promise<any>;
41
- createTypedIndex(idxType: string, entityType: "NODE" | "EDGE", label: string, properties: string[], options?: Record<string, string | number | boolean>): Promise<QueryReply>;
42
- createNodeRangeIndex(label: string, ...properties: string[]): Promise<QueryReply>;
43
- createNodeFulltextIndex(label: string, ...properties: string[]): Promise<QueryReply>;
44
- createNodeVectorIndex(label: string, dim?: number, similarityFunction?: string, ...properties: string[]): Promise<QueryReply>;
45
- createEdgeRangeIndex(label: string, ...properties: string[]): Promise<QueryReply>;
46
- createEdgeFulltextIndex(label: string, ...properties: string[]): Promise<QueryReply>;
47
- createEdgeVectorIndex(label: string, dim?: number, similarityFunction?: string, ...properties: string[]): Promise<QueryReply>;
48
- dropTypedIndex(idxType: string, entityType: "NODE" | "EDGE", label: string, attribute: string): Promise<QueryReply>;
49
- dropNodeRangeIndex(label: string, attribute: string): Promise<QueryReply>;
50
- dropNodeFulltextIndex(label: string, attribute: string): Promise<QueryReply>;
51
- dropNodeVectorIndex(label: string, attribute: string): Promise<QueryReply>;
52
- dropEdgeRangeIndex(label: string, attribute: string): Promise<QueryReply>;
53
- dropEdgeFulltextIndex(label: string, attribute: string): Promise<QueryReply>;
54
- dropEdgeVectorIndex(label: string, attribute: string): Promise<QueryReply>;
78
+ /**
79
+ * Creates a unique constraint on nodes, together with the range index it
80
+ * requires on each property. Enforced asynchronously, see `constraintCreate`.
81
+ */
82
+ createNodeUniqueConstraint(label: string, ...properties: string[]): Promise<void>;
83
+ /**
84
+ * Creates a unique constraint on relationships, together with the range
85
+ * index it requires on each property. Enforced asynchronously, see
86
+ * `constraintCreate`.
87
+ */
88
+ createEdgeUniqueConstraint(relation: string, ...properties: string[]): Promise<void>;
89
+ /**
90
+ * Creates a mandatory constraint on nodes. Enforced asynchronously, see
91
+ * `constraintCreate`.
92
+ */
93
+ createNodeMandatoryConstraint(label: string, ...properties: string[]): Promise<void>;
94
+ /**
95
+ * Creates a mandatory constraint on relationships. Enforced asynchronously,
96
+ * see `constraintCreate`.
97
+ */
98
+ createEdgeMandatoryConstraint(relation: string, ...properties: string[]): Promise<void>;
99
+ /** Drops a unique constraint on nodes; its supporting range index is kept */
100
+ dropNodeUniqueConstraint(label: string, ...properties: string[]): Promise<void>;
101
+ /** Drops a unique constraint on relationships; its supporting range index is kept */
102
+ dropEdgeUniqueConstraint(relation: string, ...properties: string[]): Promise<void>;
103
+ dropNodeMandatoryConstraint(label: string, ...properties: string[]): Promise<void>;
104
+ dropEdgeMandatoryConstraint(relation: string, ...properties: string[]): Promise<void>;
105
+ /**
106
+ * Copies the graph to `destGraph` (`GRAPH.COPY`) and returns the copy: for
107
+ * a graph from `selectGraph`, the instance `selectGraph(destGraph)` returns.
108
+ */
109
+ copy(destGraph: string): Promise<Graph>;
110
+ createTypedIndex(idxType: string, entityType: "NODE" | "EDGE", label: string, properties: string[], options?: Record<string, string | number | boolean>): Promise<GraphReply<never>>;
111
+ createNodeRangeIndex(label: string, ...properties: string[]): Promise<GraphReply<never>>;
112
+ createNodeFulltextIndex(label: string, ...properties: string[]): Promise<GraphReply<never>>;
113
+ /**
114
+ * Creates a vector index, e.g.
115
+ * `createNodeVectorIndex(label, { dimension: 768, similarityFunction: 'cosine' }, 'embedding')`.
116
+ */
117
+ createNodeVectorIndex(label: string, options: VectorIndexOptions, ...properties: string[]): Promise<GraphReply<never>>;
118
+ createEdgeRangeIndex(label: string, ...properties: string[]): Promise<GraphReply<never>>;
119
+ createEdgeFulltextIndex(label: string, ...properties: string[]): Promise<GraphReply<never>>;
120
+ /**
121
+ * Creates a vector index, e.g.
122
+ * `createEdgeVectorIndex(label, { dimension: 768, similarityFunction: 'cosine' }, 'embedding')`.
123
+ */
124
+ createEdgeVectorIndex(label: string, options: VectorIndexOptions, ...properties: string[]): Promise<GraphReply<never>>;
125
+ dropTypedIndex(idxType: string, entityType: "NODE" | "EDGE", label: string, attribute: string): Promise<GraphReply<never>>;
126
+ dropNodeRangeIndex(label: string, attribute: string): Promise<GraphReply<never>>;
127
+ dropNodeFulltextIndex(label: string, attribute: string): Promise<GraphReply<never>>;
128
+ dropNodeVectorIndex(label: string, attribute: string): Promise<GraphReply<never>>;
129
+ dropEdgeRangeIndex(label: string, attribute: string): Promise<GraphReply<never>>;
130
+ dropEdgeFulltextIndex(label: string, attribute: string): Promise<GraphReply<never>>;
131
+ dropEdgeVectorIndex(label: string, attribute: string): Promise<GraphReply<never>>;
55
132
  }
56
133
  export { Graph };