@antfly/embedded 0.3.0-rc.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -3
- package/dist/{chunk-4KIXT2VQ.js → chunk-MUBX3DSJ.js} +7 -1
- package/dist/{database-BT18eJuO.d.cts → database-DAUsGvzu.d.cts} +48 -2
- package/dist/{database-BT18eJuO.d.ts → database-DAUsGvzu.d.ts} +48 -2
- package/dist/index.cjs +170 -19
- package/dist/index.d.cts +42 -14
- package/dist/index.d.ts +42 -14
- package/dist/index.js +163 -19
- package/dist/kysely.cjs +28 -10
- package/dist/kysely.d.cts +1 -1
- package/dist/kysely.d.ts +1 -1
- package/dist/kysely.js +22 -10
- package/package.json +5 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CheckReport, S as StableSnapshotReport, R as RestoreOptions, N as NativeLibrary, I as InferenceOptions, J as JsonInput, P as PullProgress, D as Database, U as Uint64Like } from './database-
|
|
2
|
-
export { a as Capabilities, b as CompactReport, G as GraphDirection, c as InferenceMode, d as InferenceStatus, L as LibraryNotFoundError, e as LibrarySource, f as MIN_THREAD_STACK_SIZE, M as MemoryAdmissionStats, O as OpenMode,
|
|
1
|
+
import { C as CheckReport, S as StableSnapshotReport, R as RestoreOptions, N as NativeLibrary, I as InferenceOptions, J as JsonInput, P as PullProgress, D as Database, U as Uint64Like } from './database-DAUsGvzu.cjs';
|
|
2
|
+
export { a as Capabilities, b as CompactReport, G as GraphDirection, c as InferenceMode, d as InferenceStatus, L as LibraryNotFoundError, e as LibrarySource, f as LiveByteAccounting, g as LiveByteCategory, h as MIN_THREAD_STACK_SIZE, M as MemoryAdmissionStats, O as OpenMode, i as OpenOptions, j as OutcomeReceiptStatus, k as PendingWorkStatus, l as Profile, m as ReplayGeneratedEnrichmentsResult, n as ResolvedLibrary, o as SUPPORTED_ABI_VERSION, p as Status, q as Storage, r as StorageStatus, T as THREADING_SERIALIZED, s as TTLCleanupOptions, t as TxnStatus, u as UnsupportedPlatformError, V as VacuumReport, W as WriteIntent, v as create, w as createHosted, x as createWithOptions, y as embeddedPlatformPackageName, z as open, A as openHosted, B as openReadonly, E as openStatusOnly, F as openWithOptions, H as platformLibraryFileName, K as resolveLibrary } from './database-DAUsGvzu.cjs';
|
|
3
3
|
import 'koffi';
|
|
4
4
|
|
|
5
5
|
/** Thrown by validateAbi() when the loaded libantfly does not match the header this binding was written against. */
|
|
@@ -43,8 +43,9 @@ declare enum ErrorCode {
|
|
|
43
43
|
TxnNotFound = 5,
|
|
44
44
|
Busy = 6,
|
|
45
45
|
/**
|
|
46
|
-
* The operation
|
|
47
|
-
* not be confirmed
|
|
46
|
+
* The operation may have taken effect: it was published but crash
|
|
47
|
+
* durability could not be confirmed, or a failure left it unknown whether
|
|
48
|
+
* it applied. Inspect the affected data; do not retry automatically.
|
|
48
49
|
*/
|
|
49
50
|
OutcomeUnknown = 7,
|
|
50
51
|
/**
|
|
@@ -53,8 +54,9 @@ declare enum ErrorCode {
|
|
|
53
54
|
*/
|
|
54
55
|
Unsupported = 8,
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* Derived work stalled or failed. A batch may already have committed its
|
|
58
|
+
* primary write: inspect the error detail and pending-work diagnostics.
|
|
59
|
+
* Do not replay a batch reported as committed.
|
|
58
60
|
*/
|
|
59
61
|
Stalled = 9,
|
|
60
62
|
/**
|
|
@@ -105,7 +107,13 @@ declare class BusyError extends AntflyError {
|
|
|
105
107
|
constructor(message?: string);
|
|
106
108
|
}
|
|
107
109
|
declare class OutcomeUnknownError extends AntflyError {
|
|
108
|
-
|
|
110
|
+
/**
|
|
111
|
+
* The receipt the database issued for an autocommit SQL write that ended
|
|
112
|
+
* with an unknown outcome, if any. Resolve it later with
|
|
113
|
+
* `Database.outcomeReceiptStatus()`.
|
|
114
|
+
*/
|
|
115
|
+
readonly outcomeReceipt?: string;
|
|
116
|
+
constructor(message?: string, outcomeReceipt?: string);
|
|
109
117
|
}
|
|
110
118
|
declare class UnsupportedError extends AntflyError {
|
|
111
119
|
constructor(message?: string);
|
|
@@ -154,6 +162,22 @@ declare function decodeArtifactIdRaw(artifactIdBase64: string): Promise<Buffer>;
|
|
|
154
162
|
/** Typed form of decodeArtifactIdRaw. */
|
|
155
163
|
declare function decodeArtifactId(artifactIdBase64: string): Promise<unknown>;
|
|
156
164
|
|
|
165
|
+
interface GraphDiagnostic {
|
|
166
|
+
code: string;
|
|
167
|
+
message: string;
|
|
168
|
+
span?: {
|
|
169
|
+
start: number;
|
|
170
|
+
end: number;
|
|
171
|
+
};
|
|
172
|
+
write_outcome?: "not_started" | "aborted" | "committed" | "unknown";
|
|
173
|
+
transaction_id?: string;
|
|
174
|
+
}
|
|
175
|
+
declare class GraphError extends Error {
|
|
176
|
+
readonly diagnostic: GraphDiagnostic;
|
|
177
|
+
readonly nativeCode: number;
|
|
178
|
+
constructor(diagnostic: GraphDiagnostic, nativeCode: number);
|
|
179
|
+
}
|
|
180
|
+
|
|
157
181
|
/**
|
|
158
182
|
* Return false from a pull() onProgress or generateStream() onChunk
|
|
159
183
|
* callback to cancel; anything else (including void/undefined) continues.
|
|
@@ -161,8 +185,8 @@ declare function decodeArtifactId(artifactIdBase64: string): Promise<unknown>;
|
|
|
161
185
|
type CallbackResult = boolean | void;
|
|
162
186
|
/**
|
|
163
187
|
* An embedded Antfly inference runtime handle: no database, just model
|
|
164
|
-
* inference (embed, rerank, chunk, generate, rewrite, decide, extract, read
|
|
165
|
-
*
|
|
188
|
+
* inference (embed, rerank, chunk, generate, rewrite, decide, extract, and read
|
|
189
|
+
* for documents/images/audio) via the libantfly antfly_inference_* C ABI. Models load on
|
|
166
190
|
* first use and stay cached until close().
|
|
167
191
|
*
|
|
168
192
|
* Every JSON call except pull() and generateStream() is async (runs on
|
|
@@ -238,11 +262,9 @@ declare class Inference implements AsyncDisposable {
|
|
|
238
262
|
decide(request: JsonInput): Promise<unknown>;
|
|
239
263
|
extractRaw(request: JsonInput): Promise<Buffer>;
|
|
240
264
|
extract(request: JsonInput): Promise<unknown>;
|
|
241
|
-
/**
|
|
265
|
+
/** Read images, documents, or audio. */
|
|
242
266
|
readRaw(request: JsonInput): Promise<Buffer>;
|
|
243
267
|
read(request: JsonInput): Promise<unknown>;
|
|
244
|
-
transcribeRaw(request: JsonInput): Promise<Buffer>;
|
|
245
|
-
transcribe(request: JsonInput): Promise<unknown>;
|
|
246
268
|
/** The installed models, as returned by GET /ai/v1/models. */
|
|
247
269
|
listModelsRaw(): Promise<Buffer>;
|
|
248
270
|
listModels(): Promise<unknown>;
|
|
@@ -290,12 +312,18 @@ interface SqlDiagnostic {
|
|
|
290
312
|
declare class SqlError extends Error {
|
|
291
313
|
readonly diagnostic: SqlDiagnostic;
|
|
292
314
|
readonly transactionId?: string | undefined;
|
|
315
|
+
readonly outcomeReceipt?: string | undefined;
|
|
293
316
|
readonly sqlstate: string;
|
|
294
|
-
|
|
317
|
+
/**
|
|
318
|
+
* @param outcomeReceipt Set when an autocommit write ended with an unknown
|
|
319
|
+
* outcome; resolve it later with `Database.outcomeReceiptStatus()`.
|
|
320
|
+
*/
|
|
321
|
+
constructor(diagnostic: SqlDiagnostic, transactionId?: string | undefined, outcomeReceipt?: string | undefined);
|
|
295
322
|
}
|
|
296
323
|
interface SqlColumn {
|
|
297
324
|
name: string;
|
|
298
325
|
type: string;
|
|
326
|
+
element_type?: string;
|
|
299
327
|
}
|
|
300
328
|
interface SqlResult<Row = Record<string, unknown>> {
|
|
301
329
|
columns: readonly SqlColumn[];
|
|
@@ -322,4 +350,4 @@ declare class Connection {
|
|
|
322
350
|
close(): Promise<void>;
|
|
323
351
|
}
|
|
324
352
|
|
|
325
|
-
export { AbiMismatchError, AntflyError, BusyError, CancelledError, CheckReport, Connection, Database, ErrorCode, Inference, InferenceOptions, IntentConflictError, InternalError, InvalidArgumentError, JsonInput, NotFoundError, OutcomeUnknownError, PullProgress, RestoreOptions, type SqlColumn, SqlError, type SqlResult, StableSnapshotReport, StalledError, TxnNotFoundError, Uint64Like, UnsupportedError, VersionConflictError, abiVersion, checkFile, checkFileRaw, copyStableSnapshotFile, copyStableSnapshotFileRaw, decodeArtifactId, decodeArtifactIdRaw, errorCodeDescription, errorCodeName, restore, restoreFile, threadingMode, validateAbi, validateInferenceAbi };
|
|
353
|
+
export { AbiMismatchError, AntflyError, BusyError, CancelledError, CheckReport, Connection, Database, ErrorCode, type GraphDiagnostic, GraphError, Inference, InferenceOptions, IntentConflictError, InternalError, InvalidArgumentError, JsonInput, NotFoundError, OutcomeUnknownError, PullProgress, RestoreOptions, type SqlColumn, SqlError, type SqlResult, StableSnapshotReport, StalledError, TxnNotFoundError, Uint64Like, UnsupportedError, VersionConflictError, abiVersion, checkFile, checkFileRaw, copyStableSnapshotFile, copyStableSnapshotFileRaw, decodeArtifactId, decodeArtifactIdRaw, errorCodeDescription, errorCodeName, restore, restoreFile, threadingMode, validateAbi, validateInferenceAbi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CheckReport, S as StableSnapshotReport, R as RestoreOptions, N as NativeLibrary, I as InferenceOptions, J as JsonInput, P as PullProgress, D as Database, U as Uint64Like } from './database-
|
|
2
|
-
export { a as Capabilities, b as CompactReport, G as GraphDirection, c as InferenceMode, d as InferenceStatus, L as LibraryNotFoundError, e as LibrarySource, f as MIN_THREAD_STACK_SIZE, M as MemoryAdmissionStats, O as OpenMode,
|
|
1
|
+
import { C as CheckReport, S as StableSnapshotReport, R as RestoreOptions, N as NativeLibrary, I as InferenceOptions, J as JsonInput, P as PullProgress, D as Database, U as Uint64Like } from './database-DAUsGvzu.js';
|
|
2
|
+
export { a as Capabilities, b as CompactReport, G as GraphDirection, c as InferenceMode, d as InferenceStatus, L as LibraryNotFoundError, e as LibrarySource, f as LiveByteAccounting, g as LiveByteCategory, h as MIN_THREAD_STACK_SIZE, M as MemoryAdmissionStats, O as OpenMode, i as OpenOptions, j as OutcomeReceiptStatus, k as PendingWorkStatus, l as Profile, m as ReplayGeneratedEnrichmentsResult, n as ResolvedLibrary, o as SUPPORTED_ABI_VERSION, p as Status, q as Storage, r as StorageStatus, T as THREADING_SERIALIZED, s as TTLCleanupOptions, t as TxnStatus, u as UnsupportedPlatformError, V as VacuumReport, W as WriteIntent, v as create, w as createHosted, x as createWithOptions, y as embeddedPlatformPackageName, z as open, A as openHosted, B as openReadonly, E as openStatusOnly, F as openWithOptions, H as platformLibraryFileName, K as resolveLibrary } from './database-DAUsGvzu.js';
|
|
3
3
|
import 'koffi';
|
|
4
4
|
|
|
5
5
|
/** Thrown by validateAbi() when the loaded libantfly does not match the header this binding was written against. */
|
|
@@ -43,8 +43,9 @@ declare enum ErrorCode {
|
|
|
43
43
|
TxnNotFound = 5,
|
|
44
44
|
Busy = 6,
|
|
45
45
|
/**
|
|
46
|
-
* The operation
|
|
47
|
-
* not be confirmed
|
|
46
|
+
* The operation may have taken effect: it was published but crash
|
|
47
|
+
* durability could not be confirmed, or a failure left it unknown whether
|
|
48
|
+
* it applied. Inspect the affected data; do not retry automatically.
|
|
48
49
|
*/
|
|
49
50
|
OutcomeUnknown = 7,
|
|
50
51
|
/**
|
|
@@ -53,8 +54,9 @@ declare enum ErrorCode {
|
|
|
53
54
|
*/
|
|
54
55
|
Unsupported = 8,
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* Derived work stalled or failed. A batch may already have committed its
|
|
58
|
+
* primary write: inspect the error detail and pending-work diagnostics.
|
|
59
|
+
* Do not replay a batch reported as committed.
|
|
58
60
|
*/
|
|
59
61
|
Stalled = 9,
|
|
60
62
|
/**
|
|
@@ -105,7 +107,13 @@ declare class BusyError extends AntflyError {
|
|
|
105
107
|
constructor(message?: string);
|
|
106
108
|
}
|
|
107
109
|
declare class OutcomeUnknownError extends AntflyError {
|
|
108
|
-
|
|
110
|
+
/**
|
|
111
|
+
* The receipt the database issued for an autocommit SQL write that ended
|
|
112
|
+
* with an unknown outcome, if any. Resolve it later with
|
|
113
|
+
* `Database.outcomeReceiptStatus()`.
|
|
114
|
+
*/
|
|
115
|
+
readonly outcomeReceipt?: string;
|
|
116
|
+
constructor(message?: string, outcomeReceipt?: string);
|
|
109
117
|
}
|
|
110
118
|
declare class UnsupportedError extends AntflyError {
|
|
111
119
|
constructor(message?: string);
|
|
@@ -154,6 +162,22 @@ declare function decodeArtifactIdRaw(artifactIdBase64: string): Promise<Buffer>;
|
|
|
154
162
|
/** Typed form of decodeArtifactIdRaw. */
|
|
155
163
|
declare function decodeArtifactId(artifactIdBase64: string): Promise<unknown>;
|
|
156
164
|
|
|
165
|
+
interface GraphDiagnostic {
|
|
166
|
+
code: string;
|
|
167
|
+
message: string;
|
|
168
|
+
span?: {
|
|
169
|
+
start: number;
|
|
170
|
+
end: number;
|
|
171
|
+
};
|
|
172
|
+
write_outcome?: "not_started" | "aborted" | "committed" | "unknown";
|
|
173
|
+
transaction_id?: string;
|
|
174
|
+
}
|
|
175
|
+
declare class GraphError extends Error {
|
|
176
|
+
readonly diagnostic: GraphDiagnostic;
|
|
177
|
+
readonly nativeCode: number;
|
|
178
|
+
constructor(diagnostic: GraphDiagnostic, nativeCode: number);
|
|
179
|
+
}
|
|
180
|
+
|
|
157
181
|
/**
|
|
158
182
|
* Return false from a pull() onProgress or generateStream() onChunk
|
|
159
183
|
* callback to cancel; anything else (including void/undefined) continues.
|
|
@@ -161,8 +185,8 @@ declare function decodeArtifactId(artifactIdBase64: string): Promise<unknown>;
|
|
|
161
185
|
type CallbackResult = boolean | void;
|
|
162
186
|
/**
|
|
163
187
|
* An embedded Antfly inference runtime handle: no database, just model
|
|
164
|
-
* inference (embed, rerank, chunk, generate, rewrite, decide, extract, read
|
|
165
|
-
*
|
|
188
|
+
* inference (embed, rerank, chunk, generate, rewrite, decide, extract, and read
|
|
189
|
+
* for documents/images/audio) via the libantfly antfly_inference_* C ABI. Models load on
|
|
166
190
|
* first use and stay cached until close().
|
|
167
191
|
*
|
|
168
192
|
* Every JSON call except pull() and generateStream() is async (runs on
|
|
@@ -238,11 +262,9 @@ declare class Inference implements AsyncDisposable {
|
|
|
238
262
|
decide(request: JsonInput): Promise<unknown>;
|
|
239
263
|
extractRaw(request: JsonInput): Promise<Buffer>;
|
|
240
264
|
extract(request: JsonInput): Promise<unknown>;
|
|
241
|
-
/**
|
|
265
|
+
/** Read images, documents, or audio. */
|
|
242
266
|
readRaw(request: JsonInput): Promise<Buffer>;
|
|
243
267
|
read(request: JsonInput): Promise<unknown>;
|
|
244
|
-
transcribeRaw(request: JsonInput): Promise<Buffer>;
|
|
245
|
-
transcribe(request: JsonInput): Promise<unknown>;
|
|
246
268
|
/** The installed models, as returned by GET /ai/v1/models. */
|
|
247
269
|
listModelsRaw(): Promise<Buffer>;
|
|
248
270
|
listModels(): Promise<unknown>;
|
|
@@ -290,12 +312,18 @@ interface SqlDiagnostic {
|
|
|
290
312
|
declare class SqlError extends Error {
|
|
291
313
|
readonly diagnostic: SqlDiagnostic;
|
|
292
314
|
readonly transactionId?: string | undefined;
|
|
315
|
+
readonly outcomeReceipt?: string | undefined;
|
|
293
316
|
readonly sqlstate: string;
|
|
294
|
-
|
|
317
|
+
/**
|
|
318
|
+
* @param outcomeReceipt Set when an autocommit write ended with an unknown
|
|
319
|
+
* outcome; resolve it later with `Database.outcomeReceiptStatus()`.
|
|
320
|
+
*/
|
|
321
|
+
constructor(diagnostic: SqlDiagnostic, transactionId?: string | undefined, outcomeReceipt?: string | undefined);
|
|
295
322
|
}
|
|
296
323
|
interface SqlColumn {
|
|
297
324
|
name: string;
|
|
298
325
|
type: string;
|
|
326
|
+
element_type?: string;
|
|
299
327
|
}
|
|
300
328
|
interface SqlResult<Row = Record<string, unknown>> {
|
|
301
329
|
columns: readonly SqlColumn[];
|
|
@@ -322,4 +350,4 @@ declare class Connection {
|
|
|
322
350
|
close(): Promise<void>;
|
|
323
351
|
}
|
|
324
352
|
|
|
325
|
-
export { AbiMismatchError, AntflyError, BusyError, CancelledError, CheckReport, Connection, Database, ErrorCode, Inference, InferenceOptions, IntentConflictError, InternalError, InvalidArgumentError, JsonInput, NotFoundError, OutcomeUnknownError, PullProgress, RestoreOptions, type SqlColumn, SqlError, type SqlResult, StableSnapshotReport, StalledError, TxnNotFoundError, Uint64Like, UnsupportedError, VersionConflictError, abiVersion, checkFile, checkFileRaw, copyStableSnapshotFile, copyStableSnapshotFileRaw, decodeArtifactId, decodeArtifactIdRaw, errorCodeDescription, errorCodeName, restore, restoreFile, threadingMode, validateAbi, validateInferenceAbi };
|
|
353
|
+
export { AbiMismatchError, AntflyError, BusyError, CancelledError, CheckReport, Connection, Database, ErrorCode, type GraphDiagnostic, GraphError, Inference, InferenceOptions, IntentConflictError, InternalError, InvalidArgumentError, JsonInput, NotFoundError, OutcomeUnknownError, PullProgress, RestoreOptions, type SqlColumn, SqlError, type SqlResult, StableSnapshotReport, StalledError, TxnNotFoundError, Uint64Like, UnsupportedError, VersionConflictError, abiVersion, checkFile, checkFileRaw, copyStableSnapshotFile, copyStableSnapshotFileRaw, decodeArtifactId, decodeArtifactIdRaw, errorCodeDescription, errorCodeName, restore, restoreFile, threadingMode, validateAbi, validateInferenceAbi };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Connection,
|
|
3
3
|
SqlError,
|
|
4
4
|
__filename
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-MUBX3DSJ.js";
|
|
6
6
|
|
|
7
7
|
// src/abi.ts
|
|
8
8
|
import koffi2 from "koffi";
|
|
@@ -154,7 +154,7 @@ var ERROR_CODE_DESCRIPTIONS = {
|
|
|
154
154
|
[4 /* IntentConflict */]: "a transaction intent conflicts with the requested operation",
|
|
155
155
|
[5 /* TxnNotFound */]: "the requested transaction was not found",
|
|
156
156
|
[6 /* Busy */]: "the requested resource is temporarily busy or changed during streaming; stabilize it and retry",
|
|
157
|
-
[7 /* OutcomeUnknown */]: "the operation
|
|
157
|
+
[7 /* OutcomeUnknown */]: "the operation may have taken effect, but whether it applied or became durable could not be confirmed; inspect the affected data and do not retry automatically",
|
|
158
158
|
[8 /* Unsupported */]: "the operation requires a capability that is not supported by this platform or filesystem",
|
|
159
159
|
[9 /* Stalled */]: "derived work stalled or failed; inspect pending-work diagnostics and repair or reopen the database",
|
|
160
160
|
[10 /* Cancelled */]: "the caller cancelled the operation",
|
|
@@ -228,9 +228,16 @@ var BusyError = class extends AntflyError {
|
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
230
|
var OutcomeUnknownError = class extends AntflyError {
|
|
231
|
-
|
|
231
|
+
/**
|
|
232
|
+
* The receipt the database issued for an autocommit SQL write that ended
|
|
233
|
+
* with an unknown outcome, if any. Resolve it later with
|
|
234
|
+
* `Database.outcomeReceiptStatus()`.
|
|
235
|
+
*/
|
|
236
|
+
outcomeReceipt;
|
|
237
|
+
constructor(message, outcomeReceipt) {
|
|
232
238
|
super(7 /* OutcomeUnknown */, message);
|
|
233
239
|
this.name = "OutcomeUnknownError";
|
|
240
|
+
if (outcomeReceipt !== void 0) this.outcomeReceipt = outcomeReceipt;
|
|
234
241
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
235
242
|
}
|
|
236
243
|
};
|
|
@@ -468,6 +475,31 @@ function buildNative() {
|
|
|
468
475
|
configureKoffiStacks();
|
|
469
476
|
const handle = koffi.load(resolved.path);
|
|
470
477
|
const f = handle.func.bind(handle);
|
|
478
|
+
let dbGraphCatalogJson;
|
|
479
|
+
let dbCypherJson;
|
|
480
|
+
let dbGraphWriteStatusJson;
|
|
481
|
+
try {
|
|
482
|
+
dbGraphCatalogJson = f("antfly_db_graph_catalog_json", "uint32_t", [
|
|
483
|
+
PAntflyDb,
|
|
484
|
+
AntflySlice,
|
|
485
|
+
PAntflyBufferOut
|
|
486
|
+
]);
|
|
487
|
+
dbCypherJson = f("antfly_db_cypher_json", "uint32_t", [
|
|
488
|
+
PAntflyDb,
|
|
489
|
+
AntflySlice,
|
|
490
|
+
AntflySlice,
|
|
491
|
+
PAntflyBufferOut
|
|
492
|
+
]);
|
|
493
|
+
dbGraphWriteStatusJson = f("antfly_db_graph_write_status_json", "uint32_t", [
|
|
494
|
+
PAntflyDb,
|
|
495
|
+
AntflySlice,
|
|
496
|
+
PAntflyBufferOut
|
|
497
|
+
]);
|
|
498
|
+
} catch {
|
|
499
|
+
dbGraphCatalogJson = void 0;
|
|
500
|
+
dbCypherJson = void 0;
|
|
501
|
+
dbGraphWriteStatusJson = void 0;
|
|
502
|
+
}
|
|
471
503
|
return {
|
|
472
504
|
handle,
|
|
473
505
|
resolved,
|
|
@@ -492,6 +524,9 @@ function buildNative() {
|
|
|
492
524
|
dbClose: f("antfly_db_close", "void", [PAntflyDb]),
|
|
493
525
|
bufferFree: f("antfly_buffer_free", "void", [koffi.pointer(AntflyBuffer)]),
|
|
494
526
|
dbSqlJson: f("antfly_db_sql_json", "uint32_t", [PAntflyDb, AntflySlice, PAntflyBufferOut]),
|
|
527
|
+
dbGraphCatalogJson,
|
|
528
|
+
dbCypherJson,
|
|
529
|
+
dbGraphWriteStatusJson,
|
|
495
530
|
dbOpenTable: f("antfly_db_open_table", "uint32_t", [PAntflyDb, AntflySlice, PAntflyDbOut]),
|
|
496
531
|
dbCreateTableJson: f("antfly_db_create_table_json", "uint32_t", [
|
|
497
532
|
PAntflyDb,
|
|
@@ -574,7 +609,33 @@ function buildNative() {
|
|
|
574
609
|
"uint64_t",
|
|
575
610
|
"uint8_t"
|
|
576
611
|
]),
|
|
612
|
+
dbBatchWithReceipt: f("antfly_db_batch_with_receipt", "uint32_t", [
|
|
613
|
+
PAntflyDb,
|
|
614
|
+
PAntflyWriteIntentArray,
|
|
615
|
+
"size_t",
|
|
616
|
+
PAntflyVersionPredicateArray,
|
|
617
|
+
"size_t",
|
|
618
|
+
"uint64_t",
|
|
619
|
+
"uint8_t",
|
|
620
|
+
PAntflyBufferOut
|
|
621
|
+
]),
|
|
577
622
|
dbBatchJson: f("antfly_db_batch_json", "uint32_t", [PAntflyDb, AntflySlice, PAntflyBufferOut]),
|
|
623
|
+
dbBatchJsonWithReceipt: f("antfly_db_batch_json_with_receipt", "uint32_t", [
|
|
624
|
+
PAntflyDb,
|
|
625
|
+
AntflySlice,
|
|
626
|
+
PAntflyBufferOut,
|
|
627
|
+
PAntflyBufferOut
|
|
628
|
+
]),
|
|
629
|
+
lastErrorOutcomeReceipt: f("antfly_last_error_outcome_receipt", "uint32_t", [PAntflyBufferOut]),
|
|
630
|
+
dbOutcomeReceiptStatus: f("antfly_db_outcome_receipt_status", "uint32_t", [
|
|
631
|
+
PAntflyDb,
|
|
632
|
+
AntflySlice,
|
|
633
|
+
PUint8Out
|
|
634
|
+
]),
|
|
635
|
+
dbOutcomeReceiptForget: f("antfly_db_outcome_receipt_forget", "uint32_t", [
|
|
636
|
+
PAntflyDb,
|
|
637
|
+
AntflySlice
|
|
638
|
+
]),
|
|
578
639
|
dbBeginTransactionWithId: f("antfly_db_begin_transaction_with_id", "uint32_t", [
|
|
579
640
|
PAntflyDb,
|
|
580
641
|
"const uint8_t *",
|
|
@@ -854,11 +915,6 @@ function buildNative() {
|
|
|
854
915
|
AntflySlice,
|
|
855
916
|
PAntflyBufferOut
|
|
856
917
|
]),
|
|
857
|
-
inferenceTranscribeJson: f("antfly_inference_transcribe_json", "uint32_t", [
|
|
858
|
-
PAntflyInference,
|
|
859
|
-
AntflySlice,
|
|
860
|
-
PAntflyBufferOut
|
|
861
|
-
]),
|
|
862
918
|
inferenceListModelsJson: f("antfly_inference_list_models_json", "uint32_t", [
|
|
863
919
|
PAntflyInference,
|
|
864
920
|
PAntflyBufferOut
|
|
@@ -917,6 +973,18 @@ function validateInferenceAbi() {
|
|
|
917
973
|
import * as fsp from "fs/promises";
|
|
918
974
|
import { basename, dirname as dirname2, join as join2 } from "path";
|
|
919
975
|
|
|
976
|
+
// src/graph-types.ts
|
|
977
|
+
var GraphError = class extends Error {
|
|
978
|
+
constructor(diagnostic, nativeCode) {
|
|
979
|
+
super(diagnostic.message);
|
|
980
|
+
this.diagnostic = diagnostic;
|
|
981
|
+
this.nativeCode = nativeCode;
|
|
982
|
+
this.name = "GraphError";
|
|
983
|
+
}
|
|
984
|
+
diagnostic;
|
|
985
|
+
nativeCode;
|
|
986
|
+
};
|
|
987
|
+
|
|
920
988
|
// src/marshal.ts
|
|
921
989
|
import { promisify } from "util";
|
|
922
990
|
import koffi3 from "koffi";
|
|
@@ -1030,6 +1098,8 @@ function parseMemoryJson(buf) {
|
|
|
1030
1098
|
}
|
|
1031
1099
|
|
|
1032
1100
|
// src/database.ts
|
|
1101
|
+
var OUTCOME_RECEIPT_APPLIED = 1;
|
|
1102
|
+
var OUTCOME_RECEIPT_NOT_APPLIED = 2;
|
|
1033
1103
|
var OPEN_FLAG_NO_SYNC = 1 << 0;
|
|
1034
1104
|
var OPEN_FLAG_TTL_CLEANUP = 1 << 1;
|
|
1035
1105
|
var OPEN_FLAG_REMOTE_PROVIDER_CONFIGURED = 1 << 2;
|
|
@@ -1137,7 +1207,12 @@ var Database = class _Database {
|
|
|
1137
1207
|
const code = await callAsync(fn, handle, ...args, out);
|
|
1138
1208
|
const body = takeBuffer(this.#native, out);
|
|
1139
1209
|
const value = body.length ? JSON.parse(body.toString("utf8")) : void 0;
|
|
1140
|
-
if (code && value?.error)
|
|
1210
|
+
if (code && value?.error) {
|
|
1211
|
+
throw new SqlError(value.error, value.transaction_id, value.outcome_receipt);
|
|
1212
|
+
}
|
|
1213
|
+
if (code === 7 /* OutcomeUnknown */ && typeof value?.outcome_receipt === "string") {
|
|
1214
|
+
throw new OutcomeUnknownError(void 0, value.outcome_receipt);
|
|
1215
|
+
}
|
|
1141
1216
|
checkCode(code);
|
|
1142
1217
|
return value;
|
|
1143
1218
|
});
|
|
@@ -1145,6 +1220,31 @@ var Database = class _Database {
|
|
|
1145
1220
|
sqlJson(request) {
|
|
1146
1221
|
return this.#invokeSql(this.#native.dbSqlJson, jsonSlice(request));
|
|
1147
1222
|
}
|
|
1223
|
+
// biome-ignore lint/suspicious/noExplicitAny: native signatures vary
|
|
1224
|
+
#invokeGraph(fn, ...args) {
|
|
1225
|
+
if (!fn)
|
|
1226
|
+
return Promise.reject(
|
|
1227
|
+
new UnsupportedError("This native library does not expose Cypher graphs")
|
|
1228
|
+
);
|
|
1229
|
+
return this.#run(async (handle) => {
|
|
1230
|
+
const out = newBufferOut();
|
|
1231
|
+
const code = await callAsync(fn, handle, ...args, out);
|
|
1232
|
+
const body = takeBuffer(this.#native, out);
|
|
1233
|
+
const value = body.length ? JSON.parse(body.toString("utf8")) : void 0;
|
|
1234
|
+
if (code && value?.code) throw new GraphError(value, code);
|
|
1235
|
+
checkCode(code);
|
|
1236
|
+
return value;
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
graphCatalogJson(request) {
|
|
1240
|
+
return this.#invokeGraph(this.#native.dbGraphCatalogJson, jsonSlice(request));
|
|
1241
|
+
}
|
|
1242
|
+
cypherJson(graph, request) {
|
|
1243
|
+
return this.#invokeGraph(this.#native.dbCypherJson, stringSlice(graph), jsonSlice(request));
|
|
1244
|
+
}
|
|
1245
|
+
graphWriteStatus(transactionId) {
|
|
1246
|
+
return this.#invokeGraph(this.#native.dbGraphWriteStatusJson, stringSlice(transactionId));
|
|
1247
|
+
}
|
|
1148
1248
|
createTable(name, schema) {
|
|
1149
1249
|
return this.#invokeCode(this.#native.dbCreateTableJson, stringSlice(name), jsonSlice(schema));
|
|
1150
1250
|
}
|
|
@@ -1288,21 +1388,44 @@ var Database = class _Database {
|
|
|
1288
1388
|
batch(writes, timestampNs) {
|
|
1289
1389
|
return this.#run(async (handle) => {
|
|
1290
1390
|
const cWrites = writes.length ? writes.map(toNativeWriteIntent) : null;
|
|
1391
|
+
const receiptOut = newBufferOut();
|
|
1291
1392
|
const code = await callAsync(
|
|
1292
|
-
this.#native.
|
|
1393
|
+
this.#native.dbBatchWithReceipt,
|
|
1293
1394
|
handle,
|
|
1294
1395
|
cWrites,
|
|
1295
1396
|
writes.length,
|
|
1296
1397
|
null,
|
|
1297
1398
|
0,
|
|
1298
1399
|
timestampNs,
|
|
1299
|
-
0
|
|
1400
|
+
0,
|
|
1401
|
+
receiptOut
|
|
1300
1402
|
);
|
|
1403
|
+
const receipt = takeBuffer(this.#native, receiptOut);
|
|
1404
|
+
if (code === 7 /* OutcomeUnknown */ && receipt.length) {
|
|
1405
|
+
throw new OutcomeUnknownError(void 0, receipt.toString("utf8"));
|
|
1406
|
+
}
|
|
1301
1407
|
checkCode(code);
|
|
1302
1408
|
});
|
|
1303
1409
|
}
|
|
1304
1410
|
batchJsonRaw(request) {
|
|
1305
|
-
return this.#
|
|
1411
|
+
return this.#run(async (handle) => {
|
|
1412
|
+
const out = newBufferOut();
|
|
1413
|
+
const receiptOut = newBufferOut();
|
|
1414
|
+
const code = await callAsync(
|
|
1415
|
+
this.#native.dbBatchJsonWithReceipt,
|
|
1416
|
+
handle,
|
|
1417
|
+
jsonSlice(request),
|
|
1418
|
+
out,
|
|
1419
|
+
receiptOut
|
|
1420
|
+
);
|
|
1421
|
+
const receipt = takeBuffer(this.#native, receiptOut);
|
|
1422
|
+
if (code === 7 /* OutcomeUnknown */ && receipt.length) {
|
|
1423
|
+
takeBuffer(this.#native, out);
|
|
1424
|
+
throw new OutcomeUnknownError(void 0, receipt.toString("utf8"));
|
|
1425
|
+
}
|
|
1426
|
+
checkCode(code);
|
|
1427
|
+
return takeBuffer(this.#native, out);
|
|
1428
|
+
});
|
|
1306
1429
|
}
|
|
1307
1430
|
async batchJson(request) {
|
|
1308
1431
|
return parseJson(await this.batchJsonRaw(request));
|
|
@@ -1629,6 +1752,32 @@ var Database = class _Database {
|
|
|
1629
1752
|
return out[0];
|
|
1630
1753
|
});
|
|
1631
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Resolves an outcome receipt (`SqlError.outcomeReceipt` or
|
|
1757
|
+
* `OutcomeUnknownError.outcomeReceipt`) on any handle for the same
|
|
1758
|
+
* database. Rejects with `StalledError` while the uncertain commit is not
|
|
1759
|
+
* reconciled yet: retry on a Lite database; for a directory database,
|
|
1760
|
+
* close the issuing handle and reopen first.
|
|
1761
|
+
*/
|
|
1762
|
+
outcomeReceiptStatus(receipt) {
|
|
1763
|
+
return this.#run(async (handle) => {
|
|
1764
|
+
const out = [0];
|
|
1765
|
+
const code = await callAsync(
|
|
1766
|
+
this.#native.dbOutcomeReceiptStatus,
|
|
1767
|
+
handle,
|
|
1768
|
+
stringSlice(receipt),
|
|
1769
|
+
out
|
|
1770
|
+
);
|
|
1771
|
+
checkCode(code);
|
|
1772
|
+
if (out[0] === OUTCOME_RECEIPT_APPLIED) return "applied";
|
|
1773
|
+
if (out[0] === OUTCOME_RECEIPT_NOT_APPLIED) return "not_applied";
|
|
1774
|
+
throw new InternalError(`unexpected outcome receipt status ${out[0]}`);
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
/** Removes a resolved receipt's durable marker; afterwards it cannot be resolved. */
|
|
1778
|
+
forgetOutcomeReceipt(receipt) {
|
|
1779
|
+
return this.#invokeCode(this.#native.dbOutcomeReceiptForget, stringSlice(receipt));
|
|
1780
|
+
}
|
|
1632
1781
|
commitVersion(txnId) {
|
|
1633
1782
|
return this.#run(async (handle) => {
|
|
1634
1783
|
const id = txnIdBytes(txnId);
|
|
@@ -2061,19 +2210,13 @@ var Inference = class _Inference {
|
|
|
2061
2210
|
async extract(request) {
|
|
2062
2211
|
return parseJson(await this.extractRaw(request));
|
|
2063
2212
|
}
|
|
2064
|
-
/**
|
|
2213
|
+
/** Read images, documents, or audio. */
|
|
2065
2214
|
readRaw(request) {
|
|
2066
2215
|
return this.#invokeJson(this.#native.inferenceReadJson, request);
|
|
2067
2216
|
}
|
|
2068
2217
|
async read(request) {
|
|
2069
2218
|
return parseJson(await this.readRaw(request));
|
|
2070
2219
|
}
|
|
2071
|
-
transcribeRaw(request) {
|
|
2072
|
-
return this.#invokeJson(this.#native.inferenceTranscribeJson, request);
|
|
2073
|
-
}
|
|
2074
|
-
async transcribe(request) {
|
|
2075
|
-
return parseJson(await this.transcribeRaw(request));
|
|
2076
|
-
}
|
|
2077
2220
|
/** The installed models, as returned by GET /ai/v1/models. */
|
|
2078
2221
|
listModelsRaw() {
|
|
2079
2222
|
return this.#run(async (handle) => {
|
|
@@ -2204,6 +2347,7 @@ export {
|
|
|
2204
2347
|
Database,
|
|
2205
2348
|
ErrorCode,
|
|
2206
2349
|
GraphDirection,
|
|
2350
|
+
GraphError,
|
|
2207
2351
|
Inference,
|
|
2208
2352
|
InferenceMode,
|
|
2209
2353
|
IntentConflictError,
|
package/dist/kysely.cjs
CHANGED
|
@@ -24,18 +24,25 @@ __export(kysely_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(kysely_exports);
|
|
26
26
|
var import_kysely = require("kysely");
|
|
27
|
+
var import_migration = require("kysely/migration");
|
|
27
28
|
|
|
28
29
|
// src/sql-types.ts
|
|
29
30
|
var SqlError = class extends Error {
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @param outcomeReceipt Set when an autocommit write ended with an unknown
|
|
33
|
+
* outcome; resolve it later with `Database.outcomeReceiptStatus()`.
|
|
34
|
+
*/
|
|
35
|
+
constructor(diagnostic, transactionId, outcomeReceipt) {
|
|
31
36
|
super(`${diagnostic.code}: ${diagnostic.message}`);
|
|
32
37
|
this.diagnostic = diagnostic;
|
|
33
38
|
this.transactionId = transactionId;
|
|
39
|
+
this.outcomeReceipt = outcomeReceipt;
|
|
34
40
|
this.name = "SqlError";
|
|
35
41
|
this.sqlstate = diagnostic.code;
|
|
36
42
|
}
|
|
37
43
|
diagnostic;
|
|
38
44
|
transactionId;
|
|
45
|
+
outcomeReceipt;
|
|
39
46
|
sqlstate;
|
|
40
47
|
};
|
|
41
48
|
|
|
@@ -307,7 +314,7 @@ var AntflyDialect = class {
|
|
|
307
314
|
},
|
|
308
315
|
async getTables(options) {
|
|
309
316
|
const names = (await database.listTables()).filter(
|
|
310
|
-
(name) => name !== "default" && (options?.withInternalKyselyTables ||
|
|
317
|
+
(name) => name !== "default" && (options?.withInternalKyselyTables || name !== import_migration.DEFAULT_MIGRATION_TABLE && name !== import_migration.DEFAULT_MIGRATION_LOCK_TABLE)
|
|
311
318
|
);
|
|
312
319
|
return Promise.all(
|
|
313
320
|
names.map(async (name) => {
|
|
@@ -322,19 +329,30 @@ var AntflyDialect = class {
|
|
|
322
329
|
} finally {
|
|
323
330
|
await handle.close();
|
|
324
331
|
}
|
|
325
|
-
const
|
|
332
|
+
const documents = Object.values(schema.document_schemas ?? {}).map(
|
|
333
|
+
(document) => document.schema
|
|
334
|
+
);
|
|
326
335
|
return {
|
|
327
336
|
name,
|
|
328
337
|
schema: "public",
|
|
329
338
|
isView: false,
|
|
330
339
|
isForeign: false,
|
|
331
|
-
columns: described.columns.map((column) =>
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
340
|
+
columns: described.columns.map((column) => {
|
|
341
|
+
return {
|
|
342
|
+
name: column.name,
|
|
343
|
+
// The embedded decoder returns every integer width as bigint.
|
|
344
|
+
// Exact NUMERIC uses decimal text; other structured values
|
|
345
|
+
// retain conservative metadata for schema generation.
|
|
346
|
+
dataType: column.element_type === "numeric" && column.type !== "array" ? "numeric" : column.type,
|
|
347
|
+
isNullable: column.name !== "_id" && (documents.length === 0 || documents.some((document) => {
|
|
348
|
+
const property = document?.properties?.[column.name];
|
|
349
|
+
return !property || !document?.required?.includes(column.name) || property.nullable === true || property.type === "null" || Array.isArray(property.type) && property.type.includes("null");
|
|
350
|
+
})),
|
|
351
|
+
isAutoIncrementing: false,
|
|
352
|
+
hasDefaultValue: schema.column_defaults?.some((entry) => entry.column === column.name) ?? false,
|
|
353
|
+
isGeneratedAlways: schema.generated_columns?.some((entry) => entry.column === column.name) ?? false
|
|
354
|
+
};
|
|
355
|
+
})
|
|
338
356
|
};
|
|
339
357
|
})
|
|
340
358
|
);
|
package/dist/kysely.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialect, Driver, PostgresQueryCompiler, PostgresAdapter, Kysely, MigrationLockOptions, DatabaseIntrospector } from 'kysely';
|
|
2
|
-
import { D as Database } from './database-
|
|
2
|
+
import { D as Database } from './database-DAUsGvzu.cjs';
|
|
3
3
|
import 'koffi';
|
|
4
4
|
|
|
5
5
|
declare class AntflyAdapter extends PostgresAdapter {
|
package/dist/kysely.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialect, Driver, PostgresQueryCompiler, PostgresAdapter, Kysely, MigrationLockOptions, DatabaseIntrospector } from 'kysely';
|
|
2
|
-
import { D as Database } from './database-
|
|
2
|
+
import { D as Database } from './database-DAUsGvzu.js';
|
|
3
3
|
import 'koffi';
|
|
4
4
|
|
|
5
5
|
declare class AntflyAdapter extends PostgresAdapter {
|