@ray-db/core 0.1.7 → 0.2.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.
package/README.md CHANGED
@@ -16,16 +16,55 @@ yarn add @ray-db/core
16
16
 
17
17
  This package ships prebuilt binaries for major platforms. If a prebuild isn't available for your target, you'll need a Rust toolchain to build from source.
18
18
 
19
- ## Quickstart (graph basics)
19
+ ## Quickstart (fluent API)
20
+
21
+ The fluent API provides a high-level, type-safe interface for schema-driven workflows:
22
+
23
+ ```ts
24
+ import { ray, node, edge, prop, optional } from '@ray-db/core'
25
+
26
+ // Define your schema
27
+ const User = node('user', {
28
+ key: (id: string) => `user:${id}`,
29
+ props: {
30
+ name: prop.string('name'),
31
+ email: prop.string('email'),
32
+ age: optional(prop.int('age')),
33
+ },
34
+ })
35
+
36
+ const Knows = edge('knows', {
37
+ since: prop.int('since'),
38
+ })
39
+
40
+ // Open database (async)
41
+ const db = await ray('./social.raydb', {
42
+ nodes: [User],
43
+ edges: [Knows],
44
+ })
45
+
46
+ // Insert nodes
47
+ const alice = db.insert(User).values({ key: 'alice', name: 'Alice', email: 'alice@example.com' }).returning()
48
+ const bob = db.insert(User).values({ key: 'bob', name: 'Bob', email: 'bob@example.com' }).returning()
49
+
50
+ // Create edges
51
+ db.link(alice, Knows, bob, { since: 2024 })
52
+
53
+ // Traverse
54
+ const friends = db.from(alice).out(Knows).toArray()
55
+
56
+ // Pathfinding
57
+ const path = db.shortestPath(alice).via(Knows).to(bob).dijkstra()
58
+
59
+ db.close()
60
+ ```
61
+
62
+ ## Quickstart (low-level API)
63
+
64
+ For direct control, use the low-level `Database` class:
20
65
 
21
66
  ```ts
22
- import {
23
- Database,
24
- JsTraversalDirection,
25
- PropType,
26
- pathConfig,
27
- traversalStep,
28
- } from '@ray-db/core'
67
+ import { Database, JsTraversalDirection, PropType, pathConfig, traversalStep } from '@ray-db/core'
29
68
 
30
69
  const db = Database.open('example.raydb', { createIfMissing: true })
31
70
 
@@ -52,10 +91,7 @@ const oneHop = db.traverseSingle([alice], JsTraversalDirection.Out, knows)
52
91
  console.log(oneHop)
53
92
 
54
93
  // Multi-hop traversal
55
- const steps = [
56
- traversalStep(JsTraversalDirection.Out, knows),
57
- traversalStep(JsTraversalDirection.Out, knows),
58
- ]
94
+ const steps = [traversalStep(JsTraversalDirection.Out, knows), traversalStep(JsTraversalDirection.Out, knows)]
59
95
  const twoHop = db.traverse([alice], steps)
60
96
  console.log(twoHop)
61
97
 
@@ -111,3 +147,4 @@ https://ray-kwaf.vercel.app/docs
111
147
  ## License
112
148
 
113
149
  MIT
150
+ # trigger
@@ -0,0 +1,96 @@
1
+ /**
2
+ * RayDB - A fast, lightweight, embedded graph database for Node.js
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * import { ray, defineNode, defineEdge, prop, optional } from '@ray-db/core'
7
+ *
8
+ * // Define schema
9
+ * const User = defineNode('user', {
10
+ * key: (id: string) => `user:${id}`,
11
+ * props: {
12
+ * name: prop.string('name'),
13
+ * email: prop.string('email'),
14
+ * },
15
+ * })
16
+ *
17
+ * const knows = defineEdge('knows', {
18
+ * since: prop.int('since'),
19
+ * })
20
+ *
21
+ * // Open database
22
+ * const db = await ray('./my.raydb', {
23
+ * nodes: [User],
24
+ * edges: [knows],
25
+ * })
26
+ *
27
+ * // Insert nodes
28
+ * const alice = db.insert('user').values('alice', { name: 'Alice' }).returning()
29
+ *
30
+ * // Close when done
31
+ * db.close()
32
+ * ```
33
+ *
34
+ * @packageDocumentation
35
+ */
36
+ export { node, edge, prop, optional, withDefault, defineNode, defineEdge } from './schema';
37
+ export type { PropType, PropSpec, KeySpec, NodeSpec, NodeConfig, EdgeSpec } from './schema';
38
+ import { Ray as NativeRay } from '../index';
39
+ import type { NodeSpec, EdgeSpec } from './schema';
40
+ export { Ray } from '../index';
41
+ export { Database, VectorIndex, RayInsertBuilder, RayInsertExecutorSingle, RayInsertExecutorMany, RayUpdateBuilder, RayUpdateEdgeBuilder, RayTraversal, RayPath, } from '../index';
42
+ export { JsTraversalDirection as TraversalDirection, JsDistanceMetric as DistanceMetric, JsAggregation as Aggregation, JsSyncMode as SyncMode, JsCompressionType as CompressionType, PropType as PropValueType, } from '../index';
43
+ export { openDatabase, createBackup, restoreBackup, getBackupInfo, createOfflineBackup, collectMetrics, healthCheck, createVectorIndex, bruteForceSearch, pathConfig, traversalStep, version, } from '../index';
44
+ export type { DbStats, CheckResult, OpenOptions, ExportOptions, ExportResult, ImportOptions, ImportResult, BackupOptions, BackupResult, RestoreOptions, OfflineBackupOptions, StreamOptions, PaginationOptions, NodePage, EdgePage, NodeWithProps, EdgeWithProps, DatabaseMetrics, DataMetrics, CacheMetrics, CacheLayerMetrics, MemoryMetrics, MvccMetrics, MvccStats, HealthCheckResult, HealthCheckEntry, JsTraverseOptions as TraverseOptions, JsTraversalStep as TraversalStep, JsTraversalResult as TraversalResult, JsPathConfig as PathConfig, JsPathResult as PathResult, JsPathEdge as PathEdge, VectorIndexOptions, VectorIndexStats, VectorSearchHit, SimilarOptions, JsIvfConfig as IvfConfig, JsIvfStats as IvfStats, JsPqConfig as PqConfig, JsSearchOptions as SearchOptions, JsSearchResult as SearchResult, JsBruteForceResult as BruteForceResult, CompressionOptions, SingleFileOptimizeOptions, VacuumOptions, JsCacheStats as CacheStats, JsEdge as Edge, JsFullEdge as FullEdge, JsNodeProp as NodeProp, JsPropValue as PropValue, JsEdgeInput as EdgeInput, } from '../index';
45
+ /** Options for opening a Ray database */
46
+ export interface RayOptions {
47
+ /** Node type definitions */
48
+ nodes: NodeSpec[];
49
+ /** Edge type definitions */
50
+ edges: EdgeSpec[];
51
+ /** Open in read-only mode (default: false) */
52
+ readOnly?: boolean;
53
+ /** Create database if it doesn't exist (default: true) */
54
+ createIfMissing?: boolean;
55
+ /** Acquire file lock (default: true) */
56
+ lockFile?: boolean;
57
+ }
58
+ /**
59
+ * Open a Ray database asynchronously.
60
+ *
61
+ * This is the recommended way to open a database as it doesn't block
62
+ * the Node.js event loop during file I/O.
63
+ *
64
+ * @param path - Path to the database file
65
+ * @param options - Database options including schema
66
+ * @returns Promise resolving to a Ray database instance
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const db = await ray('./my.raydb', {
71
+ * nodes: [User, Post],
72
+ * edges: [follows, authored],
73
+ * })
74
+ * ```
75
+ */
76
+ export declare function ray(path: string, options: RayOptions): Promise<NativeRay>;
77
+ /**
78
+ * Open a Ray database synchronously.
79
+ *
80
+ * Use this when you need synchronous initialization (e.g., at module load time).
81
+ * For most cases, prefer the async `ray()` function.
82
+ *
83
+ * @param path - Path to the database file
84
+ * @param options - Database options including schema
85
+ * @returns A Ray database instance
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const db = raySync('./my.raydb', {
90
+ * nodes: [User],
91
+ * edges: [knows],
92
+ * })
93
+ * ```
94
+ */
95
+ export declare function raySync(path: string, options: RayOptions): NativeRay;
96
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAMH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC1F,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAO3F,OAAO,EAA8C,GAAG,IAAI,SAAS,EAAE,MAAM,UAAU,CAAA;AAIvF,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAY,MAAM,UAAU,CAAA;AAO5D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG9B,OAAO,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB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,IAAI,QAAQ,EACtB,UAAU,IAAI,QAAQ,EACtB,WAAW,IAAI,SAAS,EACxB,WAAW,IAAI,SAAS,GACzB,MAAM,UAAU,CAAA;AAMjB,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,4BAA4B;IAC5B,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AA6DD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAI/E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,CAGpE"}
package/dist/index.js ADDED
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ /**
3
+ * RayDB - A fast, lightweight, embedded graph database for Node.js
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import { ray, defineNode, defineEdge, prop, optional } from '@ray-db/core'
8
+ *
9
+ * // Define schema
10
+ * const User = defineNode('user', {
11
+ * key: (id: string) => `user:${id}`,
12
+ * props: {
13
+ * name: prop.string('name'),
14
+ * email: prop.string('email'),
15
+ * },
16
+ * })
17
+ *
18
+ * const knows = defineEdge('knows', {
19
+ * since: prop.int('since'),
20
+ * })
21
+ *
22
+ * // Open database
23
+ * const db = await ray('./my.raydb', {
24
+ * nodes: [User],
25
+ * edges: [knows],
26
+ * })
27
+ *
28
+ * // Insert nodes
29
+ * const alice = db.insert('user').values('alice', { name: 'Alice' }).returning()
30
+ *
31
+ * // Close when done
32
+ * db.close()
33
+ * ```
34
+ *
35
+ * @packageDocumentation
36
+ */
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.version = exports.traversalStep = exports.pathConfig = exports.bruteForceSearch = exports.createVectorIndex = exports.healthCheck = exports.collectMetrics = exports.createOfflineBackup = exports.getBackupInfo = exports.restoreBackup = exports.createBackup = exports.openDatabase = exports.PropValueType = exports.CompressionType = exports.SyncMode = exports.Aggregation = exports.DistanceMetric = exports.TraversalDirection = exports.RayPath = exports.RayTraversal = exports.RayUpdateEdgeBuilder = exports.RayUpdateBuilder = exports.RayInsertExecutorMany = exports.RayInsertExecutorSingle = exports.RayInsertBuilder = exports.VectorIndex = exports.Database = exports.Ray = exports.defineEdge = exports.defineNode = exports.withDefault = exports.optional = exports.prop = exports.edge = exports.node = void 0;
39
+ exports.ray = ray;
40
+ exports.raySync = raySync;
41
+ // =============================================================================
42
+ // Schema Builders (clean API)
43
+ // =============================================================================
44
+ var schema_1 = require("./schema");
45
+ Object.defineProperty(exports, "node", { enumerable: true, get: function () { return schema_1.node; } });
46
+ Object.defineProperty(exports, "edge", { enumerable: true, get: function () { return schema_1.edge; } });
47
+ Object.defineProperty(exports, "prop", { enumerable: true, get: function () { return schema_1.prop; } });
48
+ Object.defineProperty(exports, "optional", { enumerable: true, get: function () { return schema_1.optional; } });
49
+ Object.defineProperty(exports, "withDefault", { enumerable: true, get: function () { return schema_1.withDefault; } });
50
+ Object.defineProperty(exports, "defineNode", { enumerable: true, get: function () { return schema_1.defineNode; } });
51
+ Object.defineProperty(exports, "defineEdge", { enumerable: true, get: function () { return schema_1.defineEdge; } });
52
+ // =============================================================================
53
+ // Native Bindings
54
+ // =============================================================================
55
+ // Import native bindings
56
+ const index_1 = require("../index");
57
+ // =============================================================================
58
+ // Clean Type Aliases (no Js prefix)
59
+ // =============================================================================
60
+ // Re-export Ray class
61
+ var index_2 = require("../index");
62
+ Object.defineProperty(exports, "Ray", { enumerable: true, get: function () { return index_2.Ray; } });
63
+ // Re-export other classes with clean names
64
+ var index_3 = require("../index");
65
+ Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return index_3.Database; } });
66
+ Object.defineProperty(exports, "VectorIndex", { enumerable: true, get: function () { return index_3.VectorIndex; } });
67
+ Object.defineProperty(exports, "RayInsertBuilder", { enumerable: true, get: function () { return index_3.RayInsertBuilder; } });
68
+ Object.defineProperty(exports, "RayInsertExecutorSingle", { enumerable: true, get: function () { return index_3.RayInsertExecutorSingle; } });
69
+ Object.defineProperty(exports, "RayInsertExecutorMany", { enumerable: true, get: function () { return index_3.RayInsertExecutorMany; } });
70
+ Object.defineProperty(exports, "RayUpdateBuilder", { enumerable: true, get: function () { return index_3.RayUpdateBuilder; } });
71
+ Object.defineProperty(exports, "RayUpdateEdgeBuilder", { enumerable: true, get: function () { return index_3.RayUpdateEdgeBuilder; } });
72
+ Object.defineProperty(exports, "RayTraversal", { enumerable: true, get: function () { return index_3.RayTraversal; } });
73
+ Object.defineProperty(exports, "RayPath", { enumerable: true, get: function () { return index_3.RayPath; } });
74
+ // Re-export enums with clean names
75
+ var index_4 = require("../index");
76
+ Object.defineProperty(exports, "TraversalDirection", { enumerable: true, get: function () { return index_4.JsTraversalDirection; } });
77
+ Object.defineProperty(exports, "DistanceMetric", { enumerable: true, get: function () { return index_4.JsDistanceMetric; } });
78
+ Object.defineProperty(exports, "Aggregation", { enumerable: true, get: function () { return index_4.JsAggregation; } });
79
+ Object.defineProperty(exports, "SyncMode", { enumerable: true, get: function () { return index_4.JsSyncMode; } });
80
+ Object.defineProperty(exports, "CompressionType", { enumerable: true, get: function () { return index_4.JsCompressionType; } });
81
+ Object.defineProperty(exports, "PropValueType", { enumerable: true, get: function () { return index_4.PropType; } });
82
+ // Re-export utility functions
83
+ var index_5 = require("../index");
84
+ Object.defineProperty(exports, "openDatabase", { enumerable: true, get: function () { return index_5.openDatabase; } });
85
+ Object.defineProperty(exports, "createBackup", { enumerable: true, get: function () { return index_5.createBackup; } });
86
+ Object.defineProperty(exports, "restoreBackup", { enumerable: true, get: function () { return index_5.restoreBackup; } });
87
+ Object.defineProperty(exports, "getBackupInfo", { enumerable: true, get: function () { return index_5.getBackupInfo; } });
88
+ Object.defineProperty(exports, "createOfflineBackup", { enumerable: true, get: function () { return index_5.createOfflineBackup; } });
89
+ Object.defineProperty(exports, "collectMetrics", { enumerable: true, get: function () { return index_5.collectMetrics; } });
90
+ Object.defineProperty(exports, "healthCheck", { enumerable: true, get: function () { return index_5.healthCheck; } });
91
+ Object.defineProperty(exports, "createVectorIndex", { enumerable: true, get: function () { return index_5.createVectorIndex; } });
92
+ Object.defineProperty(exports, "bruteForceSearch", { enumerable: true, get: function () { return index_5.bruteForceSearch; } });
93
+ Object.defineProperty(exports, "pathConfig", { enumerable: true, get: function () { return index_5.pathConfig; } });
94
+ Object.defineProperty(exports, "traversalStep", { enumerable: true, get: function () { return index_5.traversalStep; } });
95
+ Object.defineProperty(exports, "version", { enumerable: true, get: function () { return index_5.version; } });
96
+ // =============================================================================
97
+ // Type Conversion Helpers
98
+ // =============================================================================
99
+ function propSpecToNative(spec) {
100
+ return {
101
+ type: spec.type,
102
+ optional: spec.optional,
103
+ default: spec.default,
104
+ };
105
+ }
106
+ function nodeSpecToNative(spec) {
107
+ let props;
108
+ if (spec.props) {
109
+ props = {};
110
+ for (const [k, v] of Object.entries(spec.props)) {
111
+ props[k] = propSpecToNative(v);
112
+ }
113
+ }
114
+ return {
115
+ name: spec.name,
116
+ key: spec.key,
117
+ props,
118
+ };
119
+ }
120
+ function edgeSpecToNative(spec) {
121
+ let props;
122
+ if (spec.props) {
123
+ props = {};
124
+ for (const [k, v] of Object.entries(spec.props)) {
125
+ props[k] = propSpecToNative(v);
126
+ }
127
+ }
128
+ return {
129
+ name: spec.name,
130
+ props,
131
+ };
132
+ }
133
+ function optionsToNative(options) {
134
+ return {
135
+ nodes: options.nodes.map(nodeSpecToNative),
136
+ edges: options.edges.map(edgeSpecToNative),
137
+ readOnly: options.readOnly,
138
+ createIfMissing: options.createIfMissing,
139
+ lockFile: options.lockFile,
140
+ };
141
+ }
142
+ // =============================================================================
143
+ // Main Entry Points
144
+ // =============================================================================
145
+ /**
146
+ * Open a Ray database asynchronously.
147
+ *
148
+ * This is the recommended way to open a database as it doesn't block
149
+ * the Node.js event loop during file I/O.
150
+ *
151
+ * @param path - Path to the database file
152
+ * @param options - Database options including schema
153
+ * @returns Promise resolving to a Ray database instance
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const db = await ray('./my.raydb', {
158
+ * nodes: [User, Post],
159
+ * edges: [follows, authored],
160
+ * })
161
+ * ```
162
+ */
163
+ async function ray(path, options) {
164
+ const nativeOptions = optionsToNative(options);
165
+ // Cast through unknown because NAPI-RS generates Promise<unknown> for async tasks
166
+ return (await (0, index_1.ray)(path, nativeOptions));
167
+ }
168
+ /**
169
+ * Open a Ray database synchronously.
170
+ *
171
+ * Use this when you need synchronous initialization (e.g., at module load time).
172
+ * For most cases, prefer the async `ray()` function.
173
+ *
174
+ * @param path - Path to the database file
175
+ * @param options - Database options including schema
176
+ * @returns A Ray database instance
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * const db = raySync('./my.raydb', {
181
+ * nodes: [User],
182
+ * edges: [knows],
183
+ * })
184
+ * ```
185
+ */
186
+ function raySync(path, options) {
187
+ const nativeOptions = optionsToNative(options);
188
+ return (0, index_1.raySync)(path, nativeOptions);
189
+ }
190
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;AAmOH,kBAIC;AAoBD,0BAGC;AA5PD,gFAAgF;AAChF,8BAA8B;AAC9B,gFAAgF;AAEhF,mCAA0F;AAAjF,8FAAA,IAAI,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,qGAAA,WAAW,OAAA;AA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AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,GAAG,CAAC,IAAY,EAAE,OAAmB;IACzD,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAC9C,kFAAkF;IAClF,OAAO,CAAC,MAAM,IAAA,WAAS,EAAC,IAAI,EAAE,aAAa,CAAC,CAAc,CAAA;AAC5D,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,OAAO,CAAC,IAAY,EAAE,OAAmB;IACvD,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAC9C,OAAO,IAAA,eAAa,EAAC,IAAI,EAAE,aAAa,CAAC,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Schema Definition API for RayDB
3
+ *
4
+ * Provides type-safe schema builders for defining graph nodes and edges.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { node, edge, prop, optional } from '@ray-db/core'
9
+ *
10
+ * const User = node('user', {
11
+ * key: (id: string) => `user:${id}`,
12
+ * props: {
13
+ * name: prop.string('name'),
14
+ * email: prop.string('email'),
15
+ * age: optional(prop.int('age')),
16
+ * },
17
+ * })
18
+ *
19
+ * const knows = edge('knows', {
20
+ * since: prop.int('since'),
21
+ * })
22
+ * ```
23
+ */
24
+ /** Property type identifiers */
25
+ export type PropType = 'string' | 'int' | 'float' | 'bool' | 'vector' | 'any';
26
+ /** Property specification */
27
+ export interface PropSpec {
28
+ /** Property type */
29
+ type: PropType;
30
+ /** Whether this property is optional */
31
+ optional?: boolean;
32
+ /** Default value for this property */
33
+ default?: unknown;
34
+ }
35
+ /**
36
+ * Property type builders.
37
+ *
38
+ * Use these to define typed properties on nodes and edges.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const name = prop.string('name') // required string
43
+ * const age = optional(prop.int('age')) // optional int
44
+ * const score = prop.float('score') // required float
45
+ * const active = prop.bool('active') // required bool
46
+ * const embedding = prop.vector('embedding', 1536) // vector with dimensions
47
+ * ```
48
+ */
49
+ export declare const prop: {
50
+ /**
51
+ * String property.
52
+ * Stored as UTF-8 strings.
53
+ */
54
+ string: (_name: string) => PropSpec;
55
+ /**
56
+ * Integer property.
57
+ * Stored as 64-bit signed integers.
58
+ */
59
+ int: (_name: string) => PropSpec;
60
+ /**
61
+ * Float property.
62
+ * Stored as 64-bit IEEE 754 floats.
63
+ */
64
+ float: (_name: string) => PropSpec;
65
+ /**
66
+ * Boolean property.
67
+ */
68
+ bool: (_name: string) => PropSpec;
69
+ /**
70
+ * Vector property for embeddings.
71
+ * Stored as Float32 arrays.
72
+ *
73
+ * @param _name - Property name
74
+ * @param _dimensions - Vector dimensions (for documentation/validation)
75
+ */
76
+ vector: (_name: string, _dimensions?: number) => PropSpec;
77
+ /**
78
+ * Any property (schema-less).
79
+ * Accepts any value type.
80
+ */
81
+ any: (_name: string) => PropSpec;
82
+ };
83
+ /**
84
+ * Mark a property as optional.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const age = optional(prop.int('age'))
89
+ * ```
90
+ */
91
+ export declare function optional<T extends PropSpec>(spec: T): T;
92
+ /**
93
+ * Set a default value for a property.
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const status = withDefault(prop.string('status'), 'active')
98
+ * ```
99
+ */
100
+ export declare function withDefault<T extends PropSpec>(spec: T, value: unknown): T;
101
+ /** Key generation strategy */
102
+ export interface KeySpec {
103
+ /** Key generation kind */
104
+ kind: 'prefix' | 'template' | 'parts';
105
+ /** Key prefix (for all kinds) */
106
+ prefix?: string;
107
+ /** Template string with {field} placeholders (for 'template' kind) */
108
+ template?: string;
109
+ /** Field names to concatenate (for 'parts' kind) */
110
+ fields?: string[];
111
+ /** Separator between parts (for 'parts' kind, default ':') */
112
+ separator?: string;
113
+ }
114
+ /** Node type specification */
115
+ export interface NodeSpec {
116
+ /** Node type name (must be unique per database) */
117
+ name: string;
118
+ /** Key generation specification */
119
+ key?: KeySpec;
120
+ /** Property definitions */
121
+ props?: Record<string, PropSpec>;
122
+ }
123
+ /** Configuration for node() */
124
+ export interface NodeConfig<K extends string = string> {
125
+ /**
126
+ * Key generator function or key specification.
127
+ *
128
+ * If a function is provided, it will be analyzed to extract the key prefix.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // Function form - prefix is extracted automatically
133
+ * key: (id: string) => `user:${id}`
134
+ *
135
+ * // Object form - explicit specification
136
+ * key: { kind: 'prefix', prefix: 'user:' }
137
+ * key: { kind: 'template', template: 'user:{org}:{id}' }
138
+ * key: { kind: 'parts', fields: ['org', 'id'], separator: ':' }
139
+ * ```
140
+ */
141
+ key?: ((arg: K) => string) | KeySpec;
142
+ /** Property definitions */
143
+ props?: Record<string, PropSpec>;
144
+ }
145
+ /**
146
+ * Define a node type with properties.
147
+ *
148
+ * Creates a node definition that can be used for all node operations
149
+ * (insert, update, delete, query).
150
+ *
151
+ * @param name - The node type name (must be unique)
152
+ * @param config - Node configuration with key function and properties
153
+ * @returns A NodeSpec that can be passed to ray()
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const User = node('user', {
158
+ * key: (id: string) => `user:${id}`,
159
+ * props: {
160
+ * name: prop.string('name'),
161
+ * email: prop.string('email'),
162
+ * age: optional(prop.int('age')),
163
+ * },
164
+ * })
165
+ *
166
+ * // With template key
167
+ * const OrgUser = node('org_user', {
168
+ * key: { kind: 'template', template: 'org:{org}:user:{id}' },
169
+ * props: {
170
+ * name: prop.string('name'),
171
+ * },
172
+ * })
173
+ * ```
174
+ */
175
+ export declare function node<K extends string = string>(name: string, config?: NodeConfig<K>): NodeSpec;
176
+ /** Edge type specification */
177
+ export interface EdgeSpec {
178
+ /** Edge type name (must be unique per database) */
179
+ name: string;
180
+ /** Property definitions */
181
+ props?: Record<string, PropSpec>;
182
+ }
183
+ /**
184
+ * Define an edge type with optional properties.
185
+ *
186
+ * Creates an edge definition that can be used for all edge operations
187
+ * (link, unlink, query). Edges are directional and can have properties.
188
+ *
189
+ * @param name - The edge type name (must be unique)
190
+ * @param props - Optional property definitions
191
+ * @returns An EdgeSpec that can be passed to ray()
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * // Edge with properties
196
+ * const knows = edge('knows', {
197
+ * since: prop.int('since'),
198
+ * weight: optional(prop.float('weight')),
199
+ * })
200
+ *
201
+ * // Edge without properties
202
+ * const follows = edge('follows')
203
+ * ```
204
+ */
205
+ export declare function edge(name: string, props?: Record<string, PropSpec>): EdgeSpec;
206
+ /** @deprecated Use `node()` instead */
207
+ export declare const defineNode: typeof node;
208
+ /** @deprecated Use `edge()` instead */
209
+ export declare const defineEdge: typeof edge;
210
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../ts/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,gCAAgC;AAChC,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;AAE7E,6BAA6B;AAC7B,MAAM,WAAW,QAAQ;IACvB,oBAAoB;IACpB,IAAI,EAAE,QAAQ,CAAA;IACd,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAMD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,IAAI;IACf;;;OAGG;oBACa,MAAM,KAAG,QAAQ;IAEjC;;;OAGG;iBACU,MAAM,KAAG,QAAQ;IAE9B;;;OAGG;mBACY,MAAM,KAAG,QAAQ;IAEhC;;OAEG;kBACW,MAAM,KAAG,QAAQ;IAE/B;;;;;;OAMG;oBACa,MAAM,gBAAgB,MAAM,KAAG,QAAQ;IAEvD;;;OAGG;iBACU,MAAM,KAAG,QAAQ;CAC/B,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS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AM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAE7E;AAMD,uCAAuC;AACvC,eAAO,MAAM,UAAU,aAAO,CAAA;AAE9B,uCAAuC;AACvC,eAAO,MAAM,UAAU,aAAO,CAAA"}
package/dist/schema.js ADDED
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /**
3
+ * Schema Definition API for RayDB
4
+ *
5
+ * Provides type-safe schema builders for defining graph nodes and edges.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { node, edge, prop, optional } from '@ray-db/core'
10
+ *
11
+ * const User = node('user', {
12
+ * key: (id: string) => `user:${id}`,
13
+ * props: {
14
+ * name: prop.string('name'),
15
+ * email: prop.string('email'),
16
+ * age: optional(prop.int('age')),
17
+ * },
18
+ * })
19
+ *
20
+ * const knows = edge('knows', {
21
+ * since: prop.int('since'),
22
+ * })
23
+ * ```
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.defineEdge = exports.defineNode = exports.prop = void 0;
27
+ exports.optional = optional;
28
+ exports.withDefault = withDefault;
29
+ exports.node = node;
30
+ exports.edge = edge;
31
+ // =============================================================================
32
+ // Property Builders
33
+ // =============================================================================
34
+ /**
35
+ * Property type builders.
36
+ *
37
+ * Use these to define typed properties on nodes and edges.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const name = prop.string('name') // required string
42
+ * const age = optional(prop.int('age')) // optional int
43
+ * const score = prop.float('score') // required float
44
+ * const active = prop.bool('active') // required bool
45
+ * const embedding = prop.vector('embedding', 1536) // vector with dimensions
46
+ * ```
47
+ */
48
+ exports.prop = {
49
+ /**
50
+ * String property.
51
+ * Stored as UTF-8 strings.
52
+ */
53
+ string: (_name) => ({ type: 'string' }),
54
+ /**
55
+ * Integer property.
56
+ * Stored as 64-bit signed integers.
57
+ */
58
+ int: (_name) => ({ type: 'int' }),
59
+ /**
60
+ * Float property.
61
+ * Stored as 64-bit IEEE 754 floats.
62
+ */
63
+ float: (_name) => ({ type: 'float' }),
64
+ /**
65
+ * Boolean property.
66
+ */
67
+ bool: (_name) => ({ type: 'bool' }),
68
+ /**
69
+ * Vector property for embeddings.
70
+ * Stored as Float32 arrays.
71
+ *
72
+ * @param _name - Property name
73
+ * @param _dimensions - Vector dimensions (for documentation/validation)
74
+ */
75
+ vector: (_name, _dimensions) => ({ type: 'vector' }),
76
+ /**
77
+ * Any property (schema-less).
78
+ * Accepts any value type.
79
+ */
80
+ any: (_name) => ({ type: 'any' }),
81
+ };
82
+ /**
83
+ * Mark a property as optional.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const age = optional(prop.int('age'))
88
+ * ```
89
+ */
90
+ function optional(spec) {
91
+ return { ...spec, optional: true };
92
+ }
93
+ /**
94
+ * Set a default value for a property.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const status = withDefault(prop.string('status'), 'active')
99
+ * ```
100
+ */
101
+ function withDefault(spec, value) {
102
+ return { ...spec, default: value };
103
+ }
104
+ /**
105
+ * Define a node type with properties.
106
+ *
107
+ * Creates a node definition that can be used for all node operations
108
+ * (insert, update, delete, query).
109
+ *
110
+ * @param name - The node type name (must be unique)
111
+ * @param config - Node configuration with key function and properties
112
+ * @returns A NodeSpec that can be passed to ray()
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const User = node('user', {
117
+ * key: (id: string) => `user:${id}`,
118
+ * props: {
119
+ * name: prop.string('name'),
120
+ * email: prop.string('email'),
121
+ * age: optional(prop.int('age')),
122
+ * },
123
+ * })
124
+ *
125
+ * // With template key
126
+ * const OrgUser = node('org_user', {
127
+ * key: { kind: 'template', template: 'org:{org}:user:{id}' },
128
+ * props: {
129
+ * name: prop.string('name'),
130
+ * },
131
+ * })
132
+ * ```
133
+ */
134
+ function node(name, config) {
135
+ if (!config) {
136
+ return { name };
137
+ }
138
+ let keySpec;
139
+ if (typeof config.key === 'function') {
140
+ // Extract prefix from key function by calling it with a test value
141
+ const testKey = config.key('__test__');
142
+ const testIdx = testKey.indexOf('__test__');
143
+ if (testIdx !== -1) {
144
+ const prefix = testKey.slice(0, testIdx);
145
+ keySpec = { kind: 'prefix', prefix };
146
+ }
147
+ else {
148
+ // Couldn't extract prefix, use default
149
+ keySpec = { kind: 'prefix', prefix: `${name}:` };
150
+ }
151
+ }
152
+ else if (config.key) {
153
+ keySpec = config.key;
154
+ }
155
+ return {
156
+ name,
157
+ key: keySpec,
158
+ props: config.props,
159
+ };
160
+ }
161
+ /**
162
+ * Define an edge type with optional properties.
163
+ *
164
+ * Creates an edge definition that can be used for all edge operations
165
+ * (link, unlink, query). Edges are directional and can have properties.
166
+ *
167
+ * @param name - The edge type name (must be unique)
168
+ * @param props - Optional property definitions
169
+ * @returns An EdgeSpec that can be passed to ray()
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * // Edge with properties
174
+ * const knows = edge('knows', {
175
+ * since: prop.int('since'),
176
+ * weight: optional(prop.float('weight')),
177
+ * })
178
+ *
179
+ * // Edge without properties
180
+ * const follows = edge('follows')
181
+ * ```
182
+ */
183
+ function edge(name, props) {
184
+ return { name, props };
185
+ }
186
+ // =============================================================================
187
+ // Aliases for backwards compatibility
188
+ // =============================================================================
189
+ /** @deprecated Use `node()` instead */
190
+ exports.defineNode = node;
191
+ /** @deprecated Use `edge()` instead */
192
+ exports.defineEdge = edge;
193
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../ts/schema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAqFH,4BAE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ACjB,CAAC;IAED,IAAI,OAA4B,CAAA;IAEhC,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QACrC,mEAAmE;QACnE,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,UAAe,CAAC,CAAA;QAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAC3C,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC;YACnB,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;YACxC,OAAO,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;QACtC,CAAC;aAAM,CAAC;YACN,uCAAuC;YACvC,OAAO,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,EAAE,CAAA;QAClD,CAAC;IACH,CAAC;SAAM,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACtB,OAAO,GAAG,MAAM,CAAC,GAAG,CAAA;IACtB,CAAC;IAED,OAAO;QACL,IAAI;QACJ,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAA;AACH,CAAC;AAcD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,IAAI,CAAC,IAAY,EAAE,KAAgC;IACjE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AACxB,CAAC;AAED,gFAAgF;AAChF,sCAAsC;AACtC,gFAAgF;AAEhF,uCAAuC;AAC1B,QAAA,UAAU,GAAG,IAAI,CAAA;AAE9B,uCAAuC;AAC1B,QAAA,UAAU,GAAG,IAAI,CAAA"}
package/index.d.ts CHANGED
@@ -1284,8 +1284,14 @@ export declare const enum PropValueTag {
1284
1284
  VectorF32 = 5
1285
1285
  }
1286
1286
 
1287
- /** Ray entrypoint (TS parity) */
1288
- export declare function ray(path: string, options: JsRayOptions): Ray
1287
+ /**
1288
+ * Ray entrypoint - async version (recommended)
1289
+ * Opens the database on a background thread to avoid blocking the event loop
1290
+ */
1291
+ export declare function ray(path: string, options: JsRayOptions): Promise<unknown>
1292
+
1293
+ /** Ray entrypoint - sync version (for backwards compatibility) */
1294
+ export declare function raySync(path: string, options: JsRayOptions): Ray
1289
1295
 
1290
1296
  /** Restore a backup into a target path */
1291
1297
  export declare function restoreBackup(backupPath: string, restorePath: string, options?: RestoreOptions | undefined | null): string
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@ray-db/core-android-arm64')
79
79
  const bindingPackageVersion = require('@ray-db/core-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@ray-db/core-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@ray-db/core-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@ray-db/core-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@ray-db/core-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@ray-db/core-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@ray-db/core-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@ray-db/core-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@ray-db/core-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@ray-db/core-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@ray-db/core-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@ray-db/core-darwin-universal')
184
184
  const bindingPackageVersion = require('@ray-db/core-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@ray-db/core-darwin-x64')
200
200
  const bindingPackageVersion = require('@ray-db/core-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@ray-db/core-darwin-arm64')
216
216
  const bindingPackageVersion = require('@ray-db/core-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@ray-db/core-freebsd-x64')
236
236
  const bindingPackageVersion = require('@ray-db/core-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@ray-db/core-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@ray-db/core-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@ray-db/core-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@ray-db/core-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@ray-db/core-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@ray-db/core-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@ray-db/core-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@ray-db/core-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@ray-db/core-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@ray-db/core-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@ray-db/core-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@ray-db/core-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@ray-db/core-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@ray-db/core-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@ray-db/core-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@ray-db/core-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@ray-db/core-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@ray-db/core-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@ray-db/core-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@ray-db/core-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@ray-db/core-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@ray-db/core-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@ray-db/core-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@ray-db/core-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@ray-db/core-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@ray-db/core-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@ray-db/core-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@ray-db/core-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@ray-db/core-openharmony-x64')
494
494
  const bindingPackageVersion = require('@ray-db/core-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@ray-db/core-openharmony-arm')
510
510
  const bindingPackageVersion = require('@ray-db/core-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -607,6 +607,7 @@ module.exports.plus100 = nativeBinding.plus100
607
607
  module.exports.PropType = nativeBinding.PropType
608
608
  module.exports.PropValueTag = nativeBinding.PropValueTag
609
609
  module.exports.ray = nativeBinding.ray
610
+ module.exports.raySync = nativeBinding.raySync
610
611
  module.exports.restoreBackup = nativeBinding.restoreBackup
611
612
  module.exports.traversalStep = nativeBinding.traversalStep
612
613
  module.exports.version = nativeBinding.version
package/package.json CHANGED
@@ -1,10 +1,23 @@
1
1
  {
2
2
  "name": "@ray-db/core",
3
- "version": "0.1.7",
3
+ "version": "0.2.1",
4
4
  "description": "RayDB - A fast, lightweight, embedded graph database for Node.js",
5
5
  "author": "mask <mask@mask.dev>",
6
6
  "homepage": "https://github.com/maskdotdev/ray",
7
- "main": "index.js",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.js"
15
+ },
16
+ "./native": {
17
+ "types": "./index.d.ts",
18
+ "require": "./index.js"
19
+ }
20
+ },
8
21
  "repository": {
9
22
  "type": "git",
10
23
  "url": "https://github.com/maskdotdev/ray"
@@ -26,7 +39,8 @@
26
39
  "files": [
27
40
  "index.d.ts",
28
41
  "index.js",
29
- "browser.js"
42
+ "browser.js",
43
+ "dist"
30
44
  ],
31
45
  "napi": {
32
46
  "binaryName": "core",
@@ -47,8 +61,10 @@
47
61
  "scripts": {
48
62
  "artifacts": "napi artifacts",
49
63
  "bench": "node --import @oxc-node/core/register benchmark/bench.ts",
50
- "build": "napi build --platform --release",
51
- "build:debug": "napi build --platform",
64
+ "build": "napi build --platform --release && bun run build:ts",
65
+ "build:native": "napi build --platform --release",
66
+ "build:ts": "tsc -p ts/tsconfig.json",
67
+ "build:debug": "napi build --platform && bun run build:ts",
52
68
  "build:wasm": "napi build --target wasm32-wasip1-threads --release && node scripts/rename-wasm.mjs",
53
69
  "build:wasm:debug": "napi build --target wasm32-wasip1-threads && node scripts/rename-wasm.mjs",
54
70
  "format": "run-p format:prettier format:rs format:toml",
@@ -59,7 +75,7 @@
59
75
  "prepublishOnly": "napi prepublish -t npm",
60
76
  "test": "ava",
61
77
  "test:wasm": "node scripts/wasm-smoke.mjs",
62
- "preversion": "napi build --platform && git add .",
78
+ "preversion": "napi build --platform && bun run build:ts && git add .",
63
79
  "version": "napi version",
64
80
  "prepare": "husky"
65
81
  },
@@ -71,6 +87,7 @@
71
87
  "@emnapi/runtime": "^1.5.0",
72
88
  "@napi-rs/cli": "^3.2.0",
73
89
  "@oxc-node/core": "^0.0.35",
90
+ "@oxc-node/core-darwin-arm64": "0.0.35",
74
91
  "@taplo/cli": "^0.7.0",
75
92
  "@tybys/wasm-util": "^0.10.0",
76
93
  "ava": "^6.4.1",
@@ -95,6 +112,9 @@
95
112
  ]
96
113
  },
97
114
  "ava": {
115
+ "files": [
116
+ "__test__/**/*.spec.ts"
117
+ ],
98
118
  "extensions": {
99
119
  "ts": "module"
100
120
  },
@@ -115,11 +135,11 @@
115
135
  "singleQuote": true,
116
136
  "arrowParens": "always"
117
137
  },
118
- "packageManager": "yarn@4.12.0",
138
+ "packageManager": "bun@1.2.4",
119
139
  "optionalDependencies": {
120
- "@ray-db/core-win32-x64-msvc": "0.1.7",
121
- "@ray-db/core-darwin-x64": "0.1.7",
122
- "@ray-db/core-linux-x64-gnu": "0.1.7",
123
- "@ray-db/core-darwin-arm64": "0.1.7"
140
+ "@ray-db/core-win32-x64-msvc": "0.2.1",
141
+ "@ray-db/core-darwin-x64": "0.2.1",
142
+ "@ray-db/core-linux-x64-gnu": "0.2.1",
143
+ "@ray-db/core-darwin-arm64": "0.2.1"
124
144
  }
125
145
  }