@kitedb/core 0.2.6 → 0.2.8

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/dist/schema.d.ts CHANGED
@@ -24,9 +24,9 @@
24
24
  /** Property type identifiers */
25
25
  export type PropType = 'string' | 'int' | 'float' | 'bool' | 'vector' | 'any';
26
26
  /** Property specification */
27
- export interface PropSpec {
27
+ export interface PropSpec<T extends PropType = PropType> {
28
28
  /** Property type */
29
- type: PropType;
29
+ type: T;
30
30
  /** Whether this property is optional */
31
31
  optional?: boolean;
32
32
  /** Default value for this property */
@@ -51,21 +51,21 @@ export declare const prop: {
51
51
  * String property.
52
52
  * Stored as UTF-8 strings.
53
53
  */
54
- string: (_name: string) => PropSpec;
54
+ string: (_name: string) => PropSpec<"string">;
55
55
  /**
56
56
  * Integer property.
57
57
  * Stored as 64-bit signed integers.
58
58
  */
59
- int: (_name: string) => PropSpec;
59
+ int: (_name: string) => PropSpec<"int">;
60
60
  /**
61
61
  * Float property.
62
62
  * Stored as 64-bit IEEE 754 floats.
63
63
  */
64
- float: (_name: string) => PropSpec;
64
+ float: (_name: string) => PropSpec<"float">;
65
65
  /**
66
66
  * Boolean property.
67
67
  */
68
- bool: (_name: string) => PropSpec;
68
+ bool: (_name: string) => PropSpec<"bool">;
69
69
  /**
70
70
  * Vector property for embeddings.
71
71
  * Stored as Float32 arrays.
@@ -73,12 +73,12 @@ export declare const prop: {
73
73
  * @param _name - Property name
74
74
  * @param _dimensions - Vector dimensions (for documentation/validation)
75
75
  */
76
- vector: (_name: string, _dimensions?: number) => PropSpec;
76
+ vector: (_name: string, _dimensions?: number) => PropSpec<"vector">;
77
77
  /**
78
78
  * Any property (schema-less).
79
79
  * Accepts any value type.
80
80
  */
81
- any: (_name: string) => PropSpec;
81
+ any: (_name: string) => PropSpec<"any">;
82
82
  };
83
83
  /**
84
84
  * Mark a property as optional.
@@ -88,7 +88,9 @@ export declare const prop: {
88
88
  * const age = optional(prop.int('age'))
89
89
  * ```
90
90
  */
91
- export declare function optional<T extends PropSpec>(spec: T): T;
91
+ export declare function optional<T extends PropSpec>(spec: T): T & {
92
+ optional: true;
93
+ };
92
94
  /**
93
95
  * Set a default value for a property.
94
96
  *
@@ -112,16 +114,16 @@ export interface KeySpec {
112
114
  separator?: string;
113
115
  }
114
116
  /** Node type specification */
115
- export interface NodeSpec {
117
+ export interface NodeSpec<P extends Record<string, PropSpec> | undefined = Record<string, PropSpec> | undefined> {
116
118
  /** Node type name (must be unique per database) */
117
119
  name: string;
118
120
  /** Key generation specification */
119
121
  key?: KeySpec;
120
122
  /** Property definitions */
121
- props?: Record<string, PropSpec>;
123
+ props?: P;
122
124
  }
123
125
  /** Configuration for node() */
124
- export interface NodeConfig<K extends string = string> {
126
+ export interface NodeConfig<K extends string = string, P extends Record<string, PropSpec> | undefined = Record<string, PropSpec> | undefined> {
125
127
  /**
126
128
  * Key generator function or key specification.
127
129
  *
@@ -140,7 +142,7 @@ export interface NodeConfig<K extends string = string> {
140
142
  */
141
143
  key?: ((arg: K) => string) | KeySpec;
142
144
  /** Property definitions */
143
- props?: Record<string, PropSpec>;
145
+ props?: P;
144
146
  }
145
147
  /**
146
148
  * Define a node type with properties.
@@ -150,7 +152,7 @@ export interface NodeConfig<K extends string = string> {
150
152
  *
151
153
  * @param name - The node type name (must be unique)
152
154
  * @param config - Node configuration with key function and properties
153
- * @returns A NodeSpec that can be passed to ray()
155
+ * @returns A NodeSpec that can be passed to kite()
154
156
  *
155
157
  * @example
156
158
  * ```typescript
@@ -172,13 +174,13 @@ export interface NodeConfig<K extends string = string> {
172
174
  * })
173
175
  * ```
174
176
  */
175
- export declare function node<K extends string = string>(name: string, config?: NodeConfig<K>): NodeSpec;
177
+ export declare function node<K extends string = string, P extends Record<string, PropSpec> | undefined = Record<string, PropSpec> | undefined>(name: string, config?: NodeConfig<K, P>): NodeSpec<P>;
176
178
  /** Edge type specification */
177
- export interface EdgeSpec {
179
+ export interface EdgeSpec<P extends Record<string, PropSpec> | undefined = Record<string, PropSpec> | undefined> {
178
180
  /** Edge type name (must be unique per database) */
179
181
  name: string;
180
182
  /** Property definitions */
181
- props?: Record<string, PropSpec>;
183
+ props?: P;
182
184
  }
183
185
  /**
184
186
  * Define an edge type with optional properties.
@@ -188,7 +190,7 @@ export interface EdgeSpec {
188
190
  *
189
191
  * @param name - The edge type name (must be unique)
190
192
  * @param props - Optional property definitions
191
- * @returns An EdgeSpec that can be passed to ray()
193
+ * @returns An EdgeSpec that can be passed to kite()
192
194
  *
193
195
  * @example
194
196
  * ```typescript
@@ -202,9 +204,35 @@ export interface EdgeSpec {
202
204
  * const follows = edge('follows')
203
205
  * ```
204
206
  */
205
- export declare function edge(name: string, props?: Record<string, PropSpec>): EdgeSpec;
207
+ export declare function edge<P extends Record<string, PropSpec> | undefined = Record<string, PropSpec> | undefined>(name: string, props?: P): EdgeSpec<P>;
206
208
  /** @deprecated Use `node()` instead */
207
209
  export declare const defineNode: typeof node;
208
210
  /** @deprecated Use `edge()` instead */
209
211
  export declare const defineEdge: typeof edge;
212
+ type PropValue<S extends PropSpec> = S['type'] extends 'string' ? string : S['type'] extends 'int' ? number : S['type'] extends 'float' ? number : S['type'] extends 'bool' ? boolean : S['type'] extends 'vector' ? Array<number> : unknown;
213
+ type OptionalKeys<P extends Record<string, PropSpec>> = {
214
+ [K in keyof P]: P[K] extends {
215
+ optional: true;
216
+ } ? K : never;
217
+ }[keyof P];
218
+ type RequiredKeys<P extends Record<string, PropSpec>> = Exclude<keyof P, OptionalKeys<P>>;
219
+ type PropsFromSpec<P extends Record<string, PropSpec> | undefined> = P extends Record<string, PropSpec> ? {
220
+ [K in RequiredKeys<P>]: PropValue<P[K]>;
221
+ } & {
222
+ [K in OptionalKeys<P>]?: PropValue<P[K]>;
223
+ } : Record<string, never>;
224
+ export type NodeRef<N extends NodeSpec = NodeSpec> = {
225
+ id: number;
226
+ key: string;
227
+ type: N['name'];
228
+ };
229
+ export type InferNodeInsert<N extends NodeSpec> = {
230
+ key: string;
231
+ } & PropsFromSpec<N['props']>;
232
+ export type InferNodeUpsert<N extends NodeSpec> = {
233
+ key: string;
234
+ } & Partial<PropsFromSpec<N['props']>>;
235
+ export type InferNode<N extends NodeSpec> = NodeRef<N> & PropsFromSpec<N['props']>;
236
+ export type InferEdgeProps<E extends EdgeSpec> = PropsFromSpec<E['props']>;
237
+ export {};
210
238
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +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,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAEvD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE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,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,IAAI;IAChD,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAEtC,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;AAElF,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,QAAQ,IAAI,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA"}
package/dist/schema.js CHANGED
@@ -109,7 +109,7 @@ function withDefault(spec, value) {
109
109
  *
110
110
  * @param name - The node type name (must be unique)
111
111
  * @param config - Node configuration with key function and properties
112
- * @returns A NodeSpec that can be passed to ray()
112
+ * @returns A NodeSpec that can be passed to kite()
113
113
  *
114
114
  * @example
115
115
  * ```typescript
@@ -166,7 +166,7 @@ function node(name, config) {
166
166
  *
167
167
  * @param name - The edge type name (must be unique)
168
168
  * @param props - Optional property definitions
169
- * @returns An EdgeSpec that can be passed to ray()
169
+ * @returns An EdgeSpec that can be passed to kite()
170
170
  *
171
171
  * @example
172
172
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../ts/schema.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAqFH,4BAEC;AAUD,kCAEC;AAuFD,oBA2BC;AAoCD,oBAEC;AAxOD,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;;;;;;;;;;;;GAaG;AACU,QAAA,IAAI,GAAG;IAClB;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAa,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEzD;;;OAGG;IACH,GAAG,EAAE,CAAC,KAAa,EAAY,EAAE,CAAC,CAAC,EAAE,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AAC,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;AAgBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,IAAI,CAElB,IAAY,EAAE,KAAS;IACvB,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
@@ -22,6 +22,10 @@ export declare class Database {
22
22
  hasTransaction(): boolean
23
23
  /** Create a new node */
24
24
  createNode(key?: string | undefined | null): number
25
+ /** Upsert a node by key (create if missing, update props) */
26
+ upsertNode(key: string, props: Array<JsNodeProp>): number
27
+ /** Upsert a node by ID (create if missing, update props) */
28
+ upsertNodeById(nodeId: number, props: Array<JsNodeProp>): number
25
29
  /** Delete a node */
26
30
  deleteNode(nodeId: number): void
27
31
  /** Check if a node exists */
@@ -38,6 +42,12 @@ export declare class Database {
38
42
  addEdge(src: number, etype: number, dst: number): void
39
43
  /** Add an edge by type name */
40
44
  addEdgeByName(src: number, etypeName: string, dst: number): void
45
+ /**
46
+ * Upsert an edge (create if missing, update props)
47
+ *
48
+ * Returns true if the edge was created.
49
+ */
50
+ upsertEdge(src: number, etype: number, dst: number, props: Array<JsNodeProp>): boolean
41
51
  /** Delete an edge */
42
52
  deleteEdge(src: number, etype: number, dst: number): void
43
53
  /** Check if an edge exists */
@@ -512,11 +522,11 @@ export declare class JsIvfPqIndex {
512
522
  }
513
523
 
514
524
  /**
515
- * High-level Ray database handle for Node.js/Bun.
525
+ * High-level Kite database handle for Node.js/Bun.
516
526
  *
517
527
  * # Thread Safety and Concurrent Access
518
528
  *
519
- * Ray uses an internal RwLock to support concurrent operations:
529
+ * Kite uses an internal RwLock to support concurrent operations:
520
530
  *
521
531
  * - **Read operations** (get, exists, neighbors, traversals) use a shared read lock,
522
532
  * allowing multiple concurrent reads without blocking each other.
@@ -541,9 +551,9 @@ export declare class JsIvfPqIndex {
541
551
  * await db.insert("User").key("david").set("name", "David").execute();
542
552
  * ```
543
553
  */
544
- export declare class Ray {
545
- /** Open a Ray database */
546
- static open(path: string, options: JsRayOptions): Ray
554
+ export declare class Kite {
555
+ /** Open a Kite database */
556
+ static open(path: string, options: JsKiteOptions): Kite
547
557
  /** Close the database */
548
558
  close(): void
549
559
  /** Get a node by key (returns node object with props) */
@@ -563,11 +573,15 @@ export declare class Ray {
563
573
  /** Delete a node by key */
564
574
  deleteByKey(nodeType: string, key: unknown): boolean
565
575
  /** Create an insert builder */
566
- insert(nodeType: string): RayInsertBuilder
576
+ insert(nodeType: string): KiteInsertBuilder
577
+ /** Create an upsert builder */
578
+ upsert(nodeType: string): KiteUpsertBuilder
567
579
  /** Create an update builder by node ID */
568
- updateById(nodeId: number): RayUpdateBuilder
580
+ updateById(nodeId: number): KiteUpdateBuilder
581
+ /** Create an upsert builder by node ID */
582
+ upsertById(nodeType: string, nodeId: number): KiteUpsertByIdBuilder
569
583
  /** Create an update builder by key */
570
- updateByKey(nodeType: string, key: unknown): RayUpdateBuilder
584
+ updateByKey(nodeType: string, key: unknown): KiteUpdateBuilder
571
585
  /** Link two nodes */
572
586
  link(src: number, edgeType: string, dst: number, props?: object | undefined | null): void
573
587
  /** Unlink two nodes */
@@ -583,7 +597,9 @@ export declare class Ray {
583
597
  /** Delete an edge property */
584
598
  delEdgeProp(src: number, edgeType: string, dst: number, propName: string): void
585
599
  /** Update edge properties with a builder */
586
- updateEdge(src: number, edgeType: string, dst: number): RayUpdateEdgeBuilder
600
+ updateEdge(src: number, edgeType: string, dst: number): KiteUpdateEdgeBuilder
601
+ /** Upsert edge properties with a builder */
602
+ upsertEdge(src: number, edgeType: string, dst: number): KiteUpsertEdgeBuilder
587
603
  /** List all nodes of a type (returns array of node objects) */
588
604
  all(nodeType: string): Array<object>
589
605
  /** Count nodes (optionally by type) */
@@ -606,40 +622,48 @@ export declare class Ray {
606
622
  describe(): string
607
623
  /** Check database integrity */
608
624
  check(): CheckResult
625
+ /** Begin a transaction */
626
+ begin(readOnly?: boolean | undefined | null): number
627
+ /** Commit the current transaction */
628
+ commit(): void
629
+ /** Rollback the current transaction */
630
+ rollback(): void
631
+ /** Check if there's an active transaction */
632
+ hasTransaction(): boolean
609
633
  /** Execute a batch of operations atomically */
610
634
  batch(ops: Array<object>): Array<object>
611
635
  /** Begin a traversal from a node ID */
612
- from(nodeId: number): RayTraversal
636
+ from(nodeId: number): KiteTraversal
613
637
  /** Begin a traversal from multiple nodes */
614
- fromNodes(nodeIds: Array<number>): RayTraversal
638
+ fromNodes(nodeIds: Array<number>): KiteTraversal
615
639
  /** Begin a path finding query */
616
- path(source: number, target: number): RayPath
640
+ path(source: number, target: number): KitePath
617
641
  /** Begin a path finding query to multiple targets */
618
- pathToAny(source: number, targets: Array<number>): RayPath
642
+ pathToAny(source: number, targets: Array<number>): KitePath
619
643
  }
620
644
 
621
- export declare class RayInsertBuilder {
645
+ export declare class KiteInsertBuilder {
622
646
  /** Specify values for a single insert */
623
- values(key: unknown, props?: object | undefined | null): RayInsertExecutorSingle
647
+ values(key: unknown, props?: object | undefined | null): KiteInsertExecutorSingle
624
648
  /** Specify values for multiple inserts */
625
- valuesMany(entries: Array<unknown>): RayInsertExecutorMany
649
+ valuesMany(entries: Array<unknown>): KiteInsertExecutorMany
626
650
  }
627
651
 
628
- export declare class RayInsertExecutorMany {
652
+ export declare class KiteInsertExecutorMany {
629
653
  /** Execute the inserts without returning */
630
654
  execute(): void
631
655
  /** Execute the inserts and return nodes */
632
656
  returning(): Array<object>
633
657
  }
634
658
 
635
- export declare class RayInsertExecutorSingle {
659
+ export declare class KiteInsertExecutorSingle {
636
660
  /** Execute the insert without returning */
637
661
  execute(): void
638
662
  /** Execute the insert and return the node */
639
663
  returning(): object
640
664
  }
641
665
 
642
- export declare class RayPath {
666
+ export declare class KitePath {
643
667
  via(edgeType: string): void
644
668
  maxDepth(depth: number): void
645
669
  direction(direction: string): void
@@ -649,21 +673,21 @@ export declare class RayPath {
649
673
  findKShortest(k: number): Array<JsPathResult>
650
674
  }
651
675
 
652
- export declare class RayTraversal {
653
- whereEdge(func: unknown): void
654
- whereNode(func: unknown): void
655
- out(edgeType?: string | undefined | null): void
656
- in(edgeType?: string | undefined | null): void
657
- both(edgeType?: string | undefined | null): void
658
- traverse(edgeType: string | undefined | null, options: JsTraverseOptions): void
659
- take(limit: number): void
660
- select(props: Array<string>): void
676
+ export declare class KiteTraversal {
677
+ whereEdge(func: unknown): KiteTraversal
678
+ whereNode(func: unknown): KiteTraversal
679
+ out(edgeType?: string | undefined | null): KiteTraversal
680
+ in(edgeType?: string | undefined | null): KiteTraversal
681
+ both(edgeType?: string | undefined | null): KiteTraversal
682
+ traverse(edgeType: string | undefined | null, options: JsTraverseOptions): KiteTraversal
683
+ take(limit: number): KiteTraversal
684
+ select(props: Array<string>): KiteTraversal
661
685
  nodes(): Array<number>
662
686
  edges(): Array<JsFullEdge>
663
687
  count(): number
664
688
  }
665
689
 
666
- export declare class RayUpdateBuilder {
690
+ export declare class KiteUpdateBuilder {
667
691
  /** Set a node property */
668
692
  set(propName: string, value: unknown): void
669
693
  /** Remove a node property */
@@ -674,7 +698,7 @@ export declare class RayUpdateBuilder {
674
698
  execute(): void
675
699
  }
676
700
 
677
- export declare class RayUpdateEdgeBuilder {
701
+ export declare class KiteUpdateEdgeBuilder {
678
702
  /** Set an edge property */
679
703
  set(propName: string, value: unknown): void
680
704
  /** Remove an edge property */
@@ -685,6 +709,49 @@ export declare class RayUpdateEdgeBuilder {
685
709
  execute(): void
686
710
  }
687
711
 
712
+ export declare class KiteUpsertBuilder {
713
+ /** Specify values for a single upsert */
714
+ values(key: unknown, props?: object | undefined | null): KiteUpsertExecutorSingle
715
+ /** Specify values for multiple upserts */
716
+ valuesMany(entries: Array<unknown>): KiteUpsertExecutorMany
717
+ }
718
+
719
+ export declare class KiteUpsertByIdBuilder {
720
+ /** Set a node property */
721
+ set(propName: string, value: unknown): void
722
+ /** Remove a node property */
723
+ unset(propName: string): void
724
+ /** Set multiple properties at once */
725
+ setAll(props: object): void
726
+ /** Execute the upsert */
727
+ execute(): void
728
+ }
729
+
730
+ export declare class KiteUpsertEdgeBuilder {
731
+ /** Set an edge property */
732
+ set(propName: string, value: unknown): void
733
+ /** Remove an edge property */
734
+ unset(propName: string): void
735
+ /** Set multiple edge properties at once */
736
+ setAll(props: object): void
737
+ /** Execute the upsert */
738
+ execute(): void
739
+ }
740
+
741
+ export declare class KiteUpsertExecutorMany {
742
+ /** Execute the upserts without returning */
743
+ execute(): void
744
+ /** Execute the upserts and return nodes */
745
+ returning(): Array<object>
746
+ }
747
+
748
+ export declare class KiteUpsertExecutorSingle {
749
+ /** Execute the upsert without returning */
750
+ execute(): void
751
+ /** Execute the upsert and return the node */
752
+ returning(): object
753
+ }
754
+
688
755
  /** High-level vector index for similarity search */
689
756
  export declare class VectorIndex {
690
757
  /** Create a new vector index */
@@ -999,6 +1066,14 @@ export interface JsKeySpec {
999
1066
  separator?: string
1000
1067
  }
1001
1068
 
1069
+ export interface JsKiteOptions {
1070
+ nodes: Array<JsNodeSpec>
1071
+ edges: Array<JsEdgeSpec>
1072
+ readOnly?: boolean
1073
+ createIfMissing?: boolean
1074
+ lockFile?: boolean
1075
+ }
1076
+
1002
1077
  /** Node property key-value pair for JS */
1003
1078
  export interface JsNodeProp {
1004
1079
  keyId: number
@@ -1089,14 +1164,6 @@ export interface JsPropValue {
1089
1164
  vectorValue?: Array<number>
1090
1165
  }
1091
1166
 
1092
- export interface JsRayOptions {
1093
- nodes: Array<JsNodeSpec>
1094
- edges: Array<JsEdgeSpec>
1095
- readOnly?: boolean
1096
- createIfMissing?: boolean
1097
- lockFile?: boolean
1098
- }
1099
-
1100
1167
  /** Options for vector search */
1101
1168
  export interface JsSearchOptions {
1102
1169
  /** Number of clusters to probe (overrides index default) */
@@ -1176,6 +1243,15 @@ export interface JsTraverseOptions {
1176
1243
  unique?: boolean
1177
1244
  }
1178
1245
 
1246
+ /**
1247
+ * Kite entrypoint - async version (recommended)
1248
+ * Opens the database on a background thread to avoid blocking the event loop
1249
+ */
1250
+ export declare function kite(path: string, options: JsKiteOptions): Promise<unknown>
1251
+
1252
+ /** Kite entrypoint - sync version */
1253
+ export declare function kiteSync(path: string, options: JsKiteOptions): Kite
1254
+
1179
1255
  /** Memory metrics */
1180
1256
  export interface MemoryMetrics {
1181
1257
  deltaEstimateBytes: number
@@ -1314,15 +1390,6 @@ export declare const enum PropValueTag {
1314
1390
  VectorF32 = 5
1315
1391
  }
1316
1392
 
1317
- /**
1318
- * Ray entrypoint - async version (recommended)
1319
- * Opens the database on a background thread to avoid blocking the event loop
1320
- */
1321
- export declare function ray(path: string, options: JsRayOptions): Promise<unknown>
1322
-
1323
- /** Ray entrypoint - sync version (for backwards compatibility) */
1324
- export declare function raySync(path: string, options: JsRayOptions): Ray
1325
-
1326
1393
  /** Restore a backup into a target path */
1327
1394
  export declare function restoreBackup(backupPath: string, restorePath: string, options?: RestoreOptions | undefined | null): string
1328
1395