@rushdb/javascript-sdk 2.11.0 → 3.0.1

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.
@@ -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>;
@@ -147,7 +154,7 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
147
154
  * @returns Promise resolving to the result of the delete operation
148
155
  * @throws Error if the record data is undefined
149
156
  */
150
- delete(transaction?: Transaction | string): Promise<import("../index.node.js").ApiResponse<{
157
+ delete(transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
151
158
  message: string;
152
159
  }>>;
153
160
  /**
@@ -178,7 +185,7 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
178
185
  * @returns Promise resolving to the result of the attach operation
179
186
  * @throws Error if the record data is undefined
180
187
  */
181
- attach(target: RelationTarget, options?: RelationOptions, transaction?: Transaction | string): Promise<import("../index.node.js").ApiResponse<{
188
+ attach(target: RelationTarget, options?: RelationOptions, transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
182
189
  message: string;
183
190
  }>>;
184
191
  /**
@@ -190,7 +197,7 @@ export declare class DBRecordInstance<S extends Schema = Schema, Q extends Searc
190
197
  * @returns Promise resolving to the result of the detach operation
191
198
  * @throws Error if the record data is undefined
192
199
  */
193
- detach(target: RelationTarget, options?: RelationDetachOptions, transaction?: Transaction | string): Promise<import("../index.node.js").ApiResponse<{
200
+ detach(target: RelationTarget, options?: RelationDetachOptions, transaction?: Transaction | string): Promise<import("../api/types.js").ApiResponse<{
194
201
  message: string;
195
202
  }>>;
196
203
  }
@@ -210,6 +217,12 @@ export declare class DBRecordsArrayInstance<S extends Schema = Schema, Q extends
210
217
  searchQuery?: SearchQuery<S>;
211
218
  /** Warnings returned by AI-assisted query generation, when applicable. */
212
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';
213
226
  /**
214
227
  * Creates a new DBRecordsArrayInstance.
215
228
  * Typically, you don't create these directly but receive them from query results.
@@ -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 (`rushdb`) 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 (`rushdb serve --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
@@ -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` requests
9
- * unbounded traversal, which is only allowed on self-hosted deployments and
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": "2.11.0",
41
+ "version": "3.0.1",
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/rushdb/issues",
63
+ "bugs": "https://github.com/rush-db/javascript-sdk/issues",
59
64
  "repository": {
60
- "type": "https",
61
- "url": "https://github.com/rush-db/rushdb"
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
  }