@rushdb/javascript-sdk 2.10.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/dist/api/api.d.ts +71 -14
- package/dist/api/index.d.ts +1 -1
- package/dist/api/types.d.ts +126 -10
- package/dist/direct/capabilities.d.ts +27 -0
- package/dist/direct/engine.d.ts +45 -0
- package/dist/direct/router.d.ts +20 -0
- package/dist/direct/schema.d.ts +48 -0
- package/dist/index.cjs +27 -3
- package/dist/index.mjs +27 -3
- package/dist/index.node.d.ts +3 -2
- package/dist/index.node.mjs +27 -0
- package/dist/index.worker.d.ts +3 -2
- package/dist/sdk/errors.d.ts +27 -0
- package/dist/sdk/record.d.ts +23 -3
- package/dist/sdk/types.d.ts +16 -2
- package/dist/types/query.d.ts +2 -3
- package/package.json +30 -6
package/dist/sdk/record.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtractAggregateFields, FlattenTypes, InferSchemaTypesRead, InferSchemaTypesWrite, MaybeArray, OptionalKeysRead, PropertyDraft, RequiredKeysRead, Schema, SearchQuery } from '../types/index.js';
|
|
2
|
+
import type { TextSearchReport, VectorSearchReport } from '../api/types.js';
|
|
2
3
|
import type { Transaction } from './transaction.js';
|
|
3
4
|
/**
|
|
4
5
|
* Internal properties that are present on all database records.
|
|
@@ -93,6 +94,12 @@ export type DBRecordCreationOptions = {
|
|
|
93
94
|
relationshipType?: string;
|
|
94
95
|
mergeStrategy?: 'append' | 'rewrite';
|
|
95
96
|
mergeBy?: string[];
|
|
97
|
+
/**
|
|
98
|
+
* Shorthand for `mergeBy: []` + `mergeStrategy: 'append'`: match existing
|
|
99
|
+
* records on all incoming keys and merge (upsert) instead of creating
|
|
100
|
+
* duplicates on re-import.
|
|
101
|
+
*/
|
|
102
|
+
merge?: boolean;
|
|
96
103
|
};
|
|
97
104
|
export declare class DBRecordInstance<S extends Schema = Schema, Q extends SearchQuery<S> = SearchQuery<S>> {
|
|
98
105
|
data: DBRecordInferred<S, Q>;
|
|
@@ -133,6 +140,13 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
|
|
|
133
140
|
* @throws Error if the ID is missing or invalid
|
|
134
141
|
*/
|
|
135
142
|
get timestamp(): number;
|
|
143
|
+
/**
|
|
144
|
+
* The similarity score from the most recent vector search.
|
|
145
|
+
* Only present on records returned by `records.vectorSearch()`.
|
|
146
|
+
* Returns `undefined` for records from regular `find`/`search` queries.
|
|
147
|
+
* Equivalent to `data.__score`.
|
|
148
|
+
*/
|
|
149
|
+
get score(): number | undefined;
|
|
136
150
|
/**
|
|
137
151
|
* Deletes this record from the database.
|
|
138
152
|
*
|
|
@@ -140,7 +154,7 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
|
|
|
140
154
|
* @returns Promise resolving to the result of the delete operation
|
|
141
155
|
* @throws Error if the record data is undefined
|
|
142
156
|
*/
|
|
143
|
-
delete(transaction?: Transaction | string): Promise<import("../
|
|
157
|
+
delete(transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
|
|
144
158
|
message: string;
|
|
145
159
|
}>>;
|
|
146
160
|
/**
|
|
@@ -171,7 +185,7 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
|
|
|
171
185
|
* @returns Promise resolving to the result of the attach operation
|
|
172
186
|
* @throws Error if the record data is undefined
|
|
173
187
|
*/
|
|
174
|
-
attach(target: RelationTarget, options?: RelationOptions, transaction?: Transaction | string): Promise<import("../
|
|
188
|
+
attach(target: RelationTarget, options?: RelationOptions, transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
|
|
175
189
|
message: string;
|
|
176
190
|
}>>;
|
|
177
191
|
/**
|
|
@@ -183,7 +197,7 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
|
|
|
183
197
|
* @returns Promise resolving to the result of the detach operation
|
|
184
198
|
* @throws Error if the record data is undefined
|
|
185
199
|
*/
|
|
186
|
-
detach(target: RelationTarget, options?: RelationDetachOptions, transaction?: Transaction | string): Promise<import("../
|
|
200
|
+
detach(target: RelationTarget, options?: RelationDetachOptions, transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
|
|
187
201
|
message: string;
|
|
188
202
|
}>>;
|
|
189
203
|
}
|
|
@@ -203,6 +217,12 @@ export declare class DBRecordsArrayInstance<S extends Schema = Schema, Q extends
|
|
|
203
217
|
searchQuery?: SearchQuery<S>;
|
|
204
218
|
/** Warnings returned by AI-assisted query generation, when applicable. */
|
|
205
219
|
warnings?: string[];
|
|
220
|
+
/** For a vector search: how the engine ran it. */
|
|
221
|
+
vectorSearch?: VectorSearchReport;
|
|
222
|
+
/** For a keyword or hybrid search: how the engine ran its keyword leg. */
|
|
223
|
+
textSearch?: TextSearchReport;
|
|
224
|
+
/** For a hybrid search: how its legs were combined. */
|
|
225
|
+
fusion?: 'rrf' | 'dbsf';
|
|
206
226
|
/**
|
|
207
227
|
* Creates a new DBRecordsArrayInstance.
|
|
208
228
|
* Typically, you don't create these directly but receive them from query results.
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export type State = {
|
|
|
10
10
|
debug: boolean;
|
|
11
11
|
timeout: number;
|
|
12
12
|
token?: string;
|
|
13
|
+
direct?: boolean;
|
|
14
|
+
engineUrl?: string;
|
|
13
15
|
initialized: boolean;
|
|
14
16
|
serverSettings?: {
|
|
15
17
|
selfHosted: boolean;
|
|
16
|
-
customDB?: boolean;
|
|
17
|
-
managedDB?: boolean;
|
|
18
18
|
};
|
|
19
19
|
} & Partial<ApiConnectionConfig>;
|
|
20
20
|
export type Logger = (payload: any) => void;
|
|
@@ -22,6 +22,20 @@ export type SDKConfig = {
|
|
|
22
22
|
httpClient?: HttpClientInterface;
|
|
23
23
|
timeout?: number;
|
|
24
24
|
logger?: Logger;
|
|
25
|
+
/**
|
|
26
|
+
* Direct mode: talk to a standalone RushDB engine (`rushdbd`) instead of
|
|
27
|
+
* RushDB Cloud. Requires `engineUrl`; the token is the engine token. The
|
|
28
|
+
* methods listed in `CLOUD_ONLY_METHODS` throw `CloudOnlyError`, and no
|
|
29
|
+
* request is ever sent to RushDB Cloud.
|
|
30
|
+
*/
|
|
31
|
+
direct?: boolean;
|
|
32
|
+
/** Standalone engine base URL when `direct` is enabled (e.g. `http://127.0.0.1:3000`). */
|
|
33
|
+
engineUrl?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Tenant on a multitenant engine (`rushdbd --multitenant`), sent as
|
|
36
|
+
* `X-RushDB-Tenant`. Omit for a single-tenant engine.
|
|
37
|
+
*/
|
|
38
|
+
scope?: string;
|
|
25
39
|
options?: {
|
|
26
40
|
/**
|
|
27
41
|
* @description
|
package/dist/types/query.d.ts
CHANGED
|
@@ -5,9 +5,8 @@ import type { AnyObject, MaybeArray, RequireAtLeastOne } from './utils.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Variable-length traversal depth for `$relation.hops` and `$cycle.hops`.
|
|
7
7
|
* A number matches exactly that many hops; `{ min?, max? }` matches a range
|
|
8
|
-
* (`min` defaults to 1, or 2 for `$cycle`). Omitting `max`
|
|
9
|
-
*
|
|
10
|
-
* projects with a custom Neo4j instance.
|
|
8
|
+
* (`min` defaults to 1, or 2 for `$cycle`). Omitting `max` means up to 10
|
|
9
|
+
* hops (the engine default); RushDB Cloud also caps `max` per deployment.
|
|
11
10
|
*/
|
|
12
11
|
export type TraversalHops = number | {
|
|
13
12
|
min?: number;
|
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"rush-db"
|
|
39
39
|
],
|
|
40
40
|
"license": "Apache-2.0",
|
|
41
|
-
"version": "
|
|
41
|
+
"version": "3.0.0",
|
|
42
42
|
"type": "module",
|
|
43
43
|
"files": [
|
|
44
44
|
"dist"
|
|
@@ -47,18 +47,40 @@
|
|
|
47
47
|
"module": "./dist/index.mjs",
|
|
48
48
|
"types": "./dist/index.worker.d.ts",
|
|
49
49
|
"devDependencies": {
|
|
50
|
+
"@changesets/cli": "^2.27.10",
|
|
51
|
+
"@types/node": "^20.17.23",
|
|
50
52
|
"dotenv": "^16.0.3",
|
|
53
|
+
"esbuild": "0.21.5",
|
|
51
54
|
"typedoc": "^0.28.19",
|
|
52
|
-
"typedoc-plugin-markdown": "^4.12.0"
|
|
55
|
+
"typedoc-plugin-markdown": "^4.12.0",
|
|
56
|
+
"typescript": "5.7.2",
|
|
57
|
+
"vitest": "^1.6.1"
|
|
53
58
|
},
|
|
54
59
|
"sideEffects": false,
|
|
55
60
|
"publishConfig": {
|
|
56
61
|
"access": "public"
|
|
57
62
|
},
|
|
58
|
-
"bugs": "https://github.com/rush-db/
|
|
63
|
+
"bugs": "https://github.com/rush-db/javascript-sdk/issues",
|
|
59
64
|
"repository": {
|
|
60
|
-
"type": "
|
|
61
|
-
"url": "https://github.com/rush-db/
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "git+https://github.com/rush-db/javascript-sdk.git"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/rush-db/javascript-sdk#readme",
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=18.0.0",
|
|
71
|
+
"pnpm": ">=10.0.0"
|
|
72
|
+
},
|
|
73
|
+
"exports": {
|
|
74
|
+
".": {
|
|
75
|
+
"types": "./dist/index.node.d.ts",
|
|
76
|
+
"node": {
|
|
77
|
+
"import": "./dist/index.node.mjs",
|
|
78
|
+
"require": "./dist/index.cjs"
|
|
79
|
+
},
|
|
80
|
+
"import": "./dist/index.mjs",
|
|
81
|
+
"require": "./dist/index.cjs"
|
|
82
|
+
},
|
|
83
|
+
"./package.json": "./package.json"
|
|
62
84
|
},
|
|
63
85
|
"scripts": {
|
|
64
86
|
"build": "pnpm clean && pnpm build:package && pnpm build:types",
|
|
@@ -69,6 +91,8 @@
|
|
|
69
91
|
"clean": "rm -rf ./dist ./node_modules/.cache ./coverage ./esm ./cjs ./types",
|
|
70
92
|
"flush": "rm -rf node_modules",
|
|
71
93
|
"lint:circularDeps": "madge --circular ./src/*",
|
|
72
|
-
"lint:circularDepsWithImage": "madge --image graph.svg --circular ./src/*"
|
|
94
|
+
"lint:circularDepsWithImage": "madge --image graph.svg --circular ./src/*",
|
|
95
|
+
"test": "vitest run",
|
|
96
|
+
"release": "pnpm build && changeset publish"
|
|
73
97
|
}
|
|
74
98
|
}
|