@littlebigbrain/client 0.8.0 → 0.8.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 +11 -5
- package/dist/client.d.ts +30 -175
- package/dist/client.js +36 -233
- package/dist/index.d.ts +1 -1
- package/dist/namespaces.d.ts +15 -84
- package/dist/namespaces.js +31 -190
- package/dist/schema.d.ts +973 -5668
- package/dist/types.d.ts +2 -17
- package/package.json +1 -1
package/dist/namespaces.js
CHANGED
|
@@ -28,7 +28,6 @@ export class GraphNamespace {
|
|
|
28
28
|
facts;
|
|
29
29
|
context;
|
|
30
30
|
entities;
|
|
31
|
-
indexes;
|
|
32
31
|
ontology;
|
|
33
32
|
query;
|
|
34
33
|
schema;
|
|
@@ -38,7 +37,6 @@ export class GraphNamespace {
|
|
|
38
37
|
this.facts = new FactsNamespace(client);
|
|
39
38
|
this.context = client.context;
|
|
40
39
|
this.entities = client.entities;
|
|
41
|
-
this.indexes = client.indexes;
|
|
42
40
|
this.ontology = client.ontology;
|
|
43
41
|
this.query = client.query;
|
|
44
42
|
this.schema = client.schema;
|
|
@@ -130,10 +128,6 @@ export class GraphNamespace {
|
|
|
130
128
|
body,
|
|
131
129
|
});
|
|
132
130
|
}
|
|
133
|
-
/** Export this graph's current snapshot as Turtle, N-Triples, TriG, or N-Quads. */
|
|
134
|
-
exportRdf(opts = {}) {
|
|
135
|
-
return this.client.exportRdf(opts);
|
|
136
|
-
}
|
|
137
131
|
}
|
|
138
132
|
export class FactsNamespace {
|
|
139
133
|
client;
|
|
@@ -149,7 +143,7 @@ export class FactsNamespace {
|
|
|
149
143
|
}
|
|
150
144
|
/** Bulk-load a dataset as NDJSON. See {@link LbbClient.import}. */
|
|
151
145
|
import(lines, opts = {}) {
|
|
152
|
-
const { batch, strict, observedAt,
|
|
146
|
+
const { batch, strict, observedAt, ...request } = opts;
|
|
153
147
|
const ndjson = typeof lines === "string"
|
|
154
148
|
? lines
|
|
155
149
|
: lines.map((line) => JSON.stringify(line)).join("\n");
|
|
@@ -158,7 +152,7 @@ export class FactsNamespace {
|
|
|
158
152
|
idempotencyKey: request.idempotencyKey ?? this.client.idempotencyKey("import"),
|
|
159
153
|
rawBody: ndjson,
|
|
160
154
|
contentType: "application/x-ndjson",
|
|
161
|
-
query: { batch, strict, observed_at: observedAt
|
|
155
|
+
query: { batch, strict, observed_at: observedAt },
|
|
162
156
|
});
|
|
163
157
|
}
|
|
164
158
|
/**
|
|
@@ -215,7 +209,6 @@ export class SearchNamespace {
|
|
|
215
209
|
query: {
|
|
216
210
|
query: input,
|
|
217
211
|
top_k: opts.topK,
|
|
218
|
-
source: opts.source,
|
|
219
212
|
consistency: opts.consistency ?? this.client.defaultConsistency,
|
|
220
213
|
min_indexed_seq: opts.minIndexedSeq,
|
|
221
214
|
lexical: opts.lexical,
|
|
@@ -223,8 +216,6 @@ export class SearchNamespace {
|
|
|
223
216
|
vector: opts.vector,
|
|
224
217
|
targets: opts.targets?.join(","),
|
|
225
218
|
profile: opts.profile,
|
|
226
|
-
as_of: opts.asOf,
|
|
227
|
-
as_of_commit_seq: opts.asOfCommitSeq,
|
|
228
219
|
log_impression: opts.logImpression,
|
|
229
220
|
},
|
|
230
221
|
});
|
|
@@ -263,101 +254,6 @@ export class SearchNamespace {
|
|
|
263
254
|
});
|
|
264
255
|
}
|
|
265
256
|
}
|
|
266
|
-
export class SchemaNamespace {
|
|
267
|
-
client;
|
|
268
|
-
constructor(client) {
|
|
269
|
-
this.client = client;
|
|
270
|
-
}
|
|
271
|
-
/** Active graph schema bundle: ontology plus activated SHACL shapes. */
|
|
272
|
-
view(opts = {}) {
|
|
273
|
-
const { audit, ...request } = opts;
|
|
274
|
-
return this.client.request("GET", "/v1/schema", {
|
|
275
|
-
...request,
|
|
276
|
-
query: { audit: audit || undefined },
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
/** Preview a proposed RDF/SHACL schema bundle and audit current data. */
|
|
280
|
-
preview(body, opts = {}) {
|
|
281
|
-
return this.client.request("POST", "/v1/schema/preview", {
|
|
282
|
-
...opts,
|
|
283
|
-
retry: opts.retry ?? true,
|
|
284
|
-
body,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
/** Activate a previewed SHACL schema bundle for this graph branch. */
|
|
288
|
-
publish(body, opts = {}) {
|
|
289
|
-
return this.client.request("POST", "/v1/schema/publish", { ...opts, body });
|
|
290
|
-
}
|
|
291
|
-
/** Audit current data against the active SHACL schema bundle. */
|
|
292
|
-
audit(opts = {}) {
|
|
293
|
-
return this.client.request("POST", "/v1/schema/audit", {
|
|
294
|
-
...opts,
|
|
295
|
-
retry: opts.retry ?? true,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
export class IndexNamespace {
|
|
300
|
-
client;
|
|
301
|
-
constructor(client) {
|
|
302
|
-
this.client = client;
|
|
303
|
-
}
|
|
304
|
-
run(opts = {}) {
|
|
305
|
-
const { wait, background: requestedBackground, body, ...request } = opts;
|
|
306
|
-
const background = requestedBackground ?? (wait === false ? true : undefined);
|
|
307
|
-
return this.client.request("POST", "/v1/index/run", {
|
|
308
|
-
...request,
|
|
309
|
-
query: { background },
|
|
310
|
-
body,
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
build(opts = {}) {
|
|
314
|
-
const { background, ...request } = opts;
|
|
315
|
-
return this.client.request("POST", "/v1/index/build", {
|
|
316
|
-
...request,
|
|
317
|
-
query: { background: background || undefined },
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
delta(opts = {}) {
|
|
321
|
-
return this.client.request("POST", "/v1/index/delta", opts);
|
|
322
|
-
}
|
|
323
|
-
submit(body = {}, opts) {
|
|
324
|
-
return this.client.request("POST", "/v1/index/jobs", { ...opts, body });
|
|
325
|
-
}
|
|
326
|
-
job(jobId, opts = {}) {
|
|
327
|
-
return this.client.request("GET", "/v1/index/jobs", {
|
|
328
|
-
...opts,
|
|
329
|
-
query: { job_id: jobId },
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
cancel(jobId, opts = {}) {
|
|
333
|
-
return this.client.request("DELETE", "/v1/index/jobs", {
|
|
334
|
-
...opts,
|
|
335
|
-
query: { job_id: jobId },
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
gc(opts = {}) {
|
|
339
|
-
const { keepRuns, dryRun, ...request } = opts;
|
|
340
|
-
return this.client.request("POST", "/v1/index/gc", {
|
|
341
|
-
...request,
|
|
342
|
-
query: { keep_runs: keepRuns, dry_run: dryRun },
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
submitGc(body = {}, opts) {
|
|
346
|
-
return this.client.request("POST", "/v1/index/gc-jobs", { ...opts, body });
|
|
347
|
-
}
|
|
348
|
-
gcJob(jobId, opts = {}) {
|
|
349
|
-
return this.client.request("GET", "/v1/index/gc-jobs", {
|
|
350
|
-
...opts,
|
|
351
|
-
query: { job_id: jobId },
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
cancelGc(jobId, opts = {}) {
|
|
355
|
-
return this.client.request("DELETE", "/v1/index/gc-jobs", {
|
|
356
|
-
...opts,
|
|
357
|
-
query: { job_id: jobId },
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
257
|
export class EntityNamespace {
|
|
362
258
|
client;
|
|
363
259
|
constructor(client) {
|
|
@@ -365,61 +261,12 @@ export class EntityNamespace {
|
|
|
365
261
|
}
|
|
366
262
|
/**
|
|
367
263
|
* Return the exact type cardinality and a bounded deterministic sample from
|
|
368
|
-
* the ranged adjacency
|
|
369
|
-
* falling back to an exhaustive
|
|
264
|
+
* the ranged adjacency family pinned by the published generation. A missing
|
|
265
|
+
* family fails closed rather than falling back to an exhaustive scan.
|
|
370
266
|
*/
|
|
371
267
|
sample(opts) {
|
|
372
268
|
return this.client.entityTypeSample(opts);
|
|
373
269
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Browse entities as the unified list envelope. Pass `fields` (names or `*`)
|
|
376
|
-
* to inline each row's typed attributes as native JSON (under `attributes`) —
|
|
377
|
-
* "list entities and their titles" in one call instead of a list plus N point
|
|
378
|
-
* lookups — or `ids`
|
|
379
|
-
* to fetch a specific set. Page with `cursor` from the previous `next_cursor`.
|
|
380
|
-
*/
|
|
381
|
-
list(opts = {}) {
|
|
382
|
-
const csv = (v) => Array.isArray(v) ? v.join(",") : v;
|
|
383
|
-
return this.client.request("GET", "/v1/graph/entities", {
|
|
384
|
-
...transportOptions(opts),
|
|
385
|
-
query: {
|
|
386
|
-
type: opts.type,
|
|
387
|
-
limit: opts.limit,
|
|
388
|
-
cursor: opts.cursor,
|
|
389
|
-
offset: opts.offset,
|
|
390
|
-
q: opts.query,
|
|
391
|
-
fields: csv(opts.fields),
|
|
392
|
-
ids: csv(opts.ids),
|
|
393
|
-
},
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
/** Yield list envelopes while following `next_cursor` until exhaustion. */
|
|
397
|
-
async *pages(opts = {}) {
|
|
398
|
-
let cursor = opts.cursor;
|
|
399
|
-
const seen = new Set();
|
|
400
|
-
do {
|
|
401
|
-
const page = await this.list({
|
|
402
|
-
...opts,
|
|
403
|
-
cursor,
|
|
404
|
-
offset: cursor === undefined ? opts.offset : undefined,
|
|
405
|
-
});
|
|
406
|
-
yield page;
|
|
407
|
-
if (!page.has_more || page.next_cursor === null)
|
|
408
|
-
return;
|
|
409
|
-
if (seen.has(page.next_cursor)) {
|
|
410
|
-
throw new Error(`entity pagination cursor repeated: ${page.next_cursor}`);
|
|
411
|
-
}
|
|
412
|
-
seen.add(page.next_cursor);
|
|
413
|
-
cursor = page.next_cursor;
|
|
414
|
-
} while (true);
|
|
415
|
-
}
|
|
416
|
-
/** Yield entities directly while following the server's stable cursor. */
|
|
417
|
-
async *iterate(opts = {}) {
|
|
418
|
-
for await (const page of this.pages(opts)) {
|
|
419
|
-
for (const entity of page.data)
|
|
420
|
-
yield entity;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
270
|
get(opts) {
|
|
424
271
|
return this.client.entityMetadata(opts);
|
|
425
272
|
}
|
|
@@ -444,8 +291,6 @@ export class EntityNamespace {
|
|
|
444
291
|
select: opts.select,
|
|
445
292
|
limit: opts.limit,
|
|
446
293
|
offset: opts.offset,
|
|
447
|
-
as_of_valid_time: opts.asOfValidTime,
|
|
448
|
-
as_of_commit_seq: opts.asOfCommitSeq,
|
|
449
294
|
order_by: opts.orderBy,
|
|
450
295
|
reason: opts.reason,
|
|
451
296
|
max_solutions: opts.maxSolutions,
|
|
@@ -454,19 +299,12 @@ export class EntityNamespace {
|
|
|
454
299
|
});
|
|
455
300
|
}
|
|
456
301
|
}
|
|
457
|
-
/** Grounding
|
|
302
|
+
/** Grounding operations over one pinned published vocabulary. */
|
|
458
303
|
export class ContextNamespace {
|
|
459
304
|
client;
|
|
460
305
|
constructor(client) {
|
|
461
306
|
this.client = client;
|
|
462
307
|
}
|
|
463
|
-
ask(body, opts = {}) {
|
|
464
|
-
return this.client.request("POST", "/v1/ask", {
|
|
465
|
-
...opts,
|
|
466
|
-
retry: opts.retry ?? true,
|
|
467
|
-
body,
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
308
|
suggest(body, opts = {}) {
|
|
471
309
|
return this.client.request("POST", "/v1/search/suggest", {
|
|
472
310
|
...opts,
|
|
@@ -496,6 +334,25 @@ export class ContextNamespace {
|
|
|
496
334
|
});
|
|
497
335
|
}
|
|
498
336
|
}
|
|
337
|
+
/** Active ontology/SHACL bundle metadata and atomic publication. */
|
|
338
|
+
export class SchemaNamespace {
|
|
339
|
+
client;
|
|
340
|
+
constructor(client) {
|
|
341
|
+
this.client = client;
|
|
342
|
+
}
|
|
343
|
+
/** Read active metadata without running request-time validation. */
|
|
344
|
+
view(opts = {}) {
|
|
345
|
+
return this.client.request("GET", "/v1/schema", opts);
|
|
346
|
+
}
|
|
347
|
+
/** Atomically publish a bundle; conformance is produced asynchronously. */
|
|
348
|
+
publish(body, opts = {}) {
|
|
349
|
+
return this.client.request("POST", "/v1/schema/publish", {
|
|
350
|
+
...opts,
|
|
351
|
+
idempotencyKey: opts.idempotencyKey ?? this.client.idempotencyKey("schema-publish"),
|
|
352
|
+
body,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
499
356
|
/** Ontology discovery and lifecycle operations. */
|
|
500
357
|
export class OntologyNamespace {
|
|
501
358
|
client;
|
|
@@ -510,7 +367,12 @@ export class OntologyNamespace {
|
|
|
510
367
|
});
|
|
511
368
|
}
|
|
512
369
|
conformance(opts = {}) {
|
|
513
|
-
return this.client.request("GET", "/v1/ontology/conformance",
|
|
370
|
+
return this.client.request("GET", "/v1/ontology/conformance", {
|
|
371
|
+
...opts,
|
|
372
|
+
query: {
|
|
373
|
+
consistency: opts.consistency ?? this.client.defaultConsistency,
|
|
374
|
+
},
|
|
375
|
+
});
|
|
514
376
|
}
|
|
515
377
|
search(body, opts = {}) {
|
|
516
378
|
return this.client.request("POST", "/v1/ontology/search", {
|
|
@@ -546,7 +408,7 @@ export class OntologyNamespace {
|
|
|
546
408
|
});
|
|
547
409
|
}
|
|
548
410
|
}
|
|
549
|
-
/** Structured, SPARQL-text,
|
|
411
|
+
/** Structured, SPARQL-text, and analytical query operations. */
|
|
550
412
|
export class QueryNamespace {
|
|
551
413
|
client;
|
|
552
414
|
constructor(client) {
|
|
@@ -590,25 +452,4 @@ export class QueryNamespace {
|
|
|
590
452
|
body,
|
|
591
453
|
});
|
|
592
454
|
}
|
|
593
|
-
shacl(body, opts = {}) {
|
|
594
|
-
return this.client.request("POST", "/v1/query/shacl", {
|
|
595
|
-
...opts,
|
|
596
|
-
retry: opts.retry ?? true,
|
|
597
|
-
body,
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
infer(body, opts = {}) {
|
|
601
|
-
return this.client.request("POST", "/v1/inference/run", {
|
|
602
|
-
...opts,
|
|
603
|
-
retry: opts.retry ?? true,
|
|
604
|
-
body,
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
premises(body, opts = {}) {
|
|
608
|
-
return this.client.request("POST", "/v1/inference/retrieval-premises", {
|
|
609
|
-
...opts,
|
|
610
|
-
retry: opts.retry ?? true,
|
|
611
|
-
body,
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
455
|
}
|