@littlebigbrain/client 0.7.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 +58 -186
- package/dist/client.js +113 -253
- package/dist/index.d.ts +1 -1
- package/dist/namespaces.d.ts +24 -89
- package/dist/namespaces.js +69 -196
- package/dist/schema.d.ts +1000 -5675
- package/dist/types.d.ts +28 -17
- package/package.json +1 -1
package/dist/namespaces.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import type { LbbClient } from "./client.js";
|
|
2
2
|
import type { CallOptions } from "./transport.js";
|
|
3
|
-
import { type EntityAttributeFilterOptions, type ImportLine, type
|
|
3
|
+
import { type EntityAttributeFilterOptions, type ImportLine, type ReadConsistencyOptions, type RdfImportOptions, type Schemas } from "./types.js";
|
|
4
4
|
export interface HybridSearchOptions extends CallOptions {
|
|
5
5
|
topK?: number;
|
|
6
|
-
source?: string;
|
|
7
6
|
consistency?: string;
|
|
7
|
+
/** A5 read-your-writes floor (`min_indexed_seq`): the committed sequence a
|
|
8
|
+
* write returned; under eventual, an uncovered floor yields a retryable
|
|
9
|
+
* `read_your_writes_pending` 429. */
|
|
10
|
+
minIndexedSeq?: number;
|
|
8
11
|
lexical?: boolean;
|
|
9
12
|
bm25?: boolean;
|
|
10
13
|
vector?: boolean;
|
|
11
14
|
targets?: string[];
|
|
12
15
|
profile?: string;
|
|
13
|
-
/** Valid-time cursor (RFC 3339): results reflect facts true at this instant. */
|
|
14
|
-
asOf?: string;
|
|
15
|
-
/** Snapshot pin: results reproduce the graph as of this commit sequence. */
|
|
16
|
-
asOfCommitSeq?: number;
|
|
17
16
|
/** Opt-in impression logging for later relevance feedback. */
|
|
18
17
|
logImpression?: boolean;
|
|
19
18
|
}
|
|
@@ -22,7 +21,6 @@ export declare class GraphNamespace {
|
|
|
22
21
|
readonly facts: FactsNamespace;
|
|
23
22
|
readonly context: ContextNamespace;
|
|
24
23
|
readonly entities: EntityNamespace;
|
|
25
|
-
readonly indexes: IndexNamespace;
|
|
26
24
|
readonly ontology: OntologyNamespace;
|
|
27
25
|
readonly query: QueryNamespace;
|
|
28
26
|
readonly schema: SchemaNamespace;
|
|
@@ -64,8 +62,6 @@ export declare class GraphNamespace {
|
|
|
64
62
|
}): Promise<Schemas["ManagedEmbeddingPromoteResponse"]>;
|
|
65
63
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
66
64
|
retract(body: Schemas["GraphRetractRequest"], opts?: CallOptions): Promise<Schemas["GraphRetractResponse"]>;
|
|
67
|
-
/** Export this graph's current snapshot as Turtle, N-Triples, TriG, or N-Quads. */
|
|
68
|
-
exportRdf(opts?: RdfExportOptions): Promise<string>;
|
|
69
65
|
}
|
|
70
66
|
export declare class FactsNamespace {
|
|
71
67
|
private readonly client;
|
|
@@ -76,7 +72,6 @@ export declare class FactsNamespace {
|
|
|
76
72
|
batch?: number;
|
|
77
73
|
strict?: boolean;
|
|
78
74
|
observedAt?: string;
|
|
79
|
-
index?: boolean;
|
|
80
75
|
idempotencyKey?: string;
|
|
81
76
|
}): Promise<Schemas["GraphImportResponse"]>;
|
|
82
77
|
/**
|
|
@@ -96,74 +91,21 @@ export declare class SearchNamespace {
|
|
|
96
91
|
feedback(body: Schemas["SearchFeedbackRequest"], opts?: CallOptions): Promise<Schemas["SearchFeedbackResponse"]>;
|
|
97
92
|
feedbackExport(opts?: CallOptions): Promise<Schemas["SearchFeedbackExportResponse"]>;
|
|
98
93
|
feedbackSummary(opts?: CallOptions): Promise<Schemas["SearchFeedbackSummaryResponse"]>;
|
|
99
|
-
fullText(body: Schemas["FullTextSearchRequest"], opts?: CallOptions): Promise<Schemas["FullTextSearchResponse"]>;
|
|
100
|
-
vector(body: Schemas["EmbeddingSearchRequest"], opts?: CallOptions): Promise<Schemas["EmbeddingSearchResponse"]>;
|
|
101
|
-
}
|
|
102
|
-
export declare class SchemaNamespace {
|
|
103
|
-
private readonly client;
|
|
104
|
-
constructor(client: LbbClient);
|
|
105
|
-
/** Active graph schema bundle: ontology plus activated SHACL shapes. */
|
|
106
|
-
view(opts?: {
|
|
107
|
-
audit?: boolean;
|
|
108
|
-
} & CallOptions): Promise<Schemas["SchemaBundleView"]>;
|
|
109
|
-
/** Preview a proposed RDF/SHACL schema bundle and audit current data. */
|
|
110
|
-
preview(body: Schemas["SchemaPreviewRequest"], opts?: CallOptions): Promise<Schemas["SchemaPreviewResponse"]>;
|
|
111
|
-
/** Activate a previewed SHACL schema bundle for this graph branch. */
|
|
112
|
-
publish(body: Schemas["SchemaPublishRequest"], opts?: CallOptions): Promise<Schemas["SchemaPublishResponse"]>;
|
|
113
|
-
/** Audit current data against the active SHACL schema bundle. */
|
|
114
|
-
audit(opts?: CallOptions): Promise<Schemas["SchemaAuditReport"]>;
|
|
115
|
-
}
|
|
116
|
-
export declare class IndexNamespace {
|
|
117
|
-
private readonly client;
|
|
118
|
-
constructor(client: LbbClient);
|
|
119
|
-
run(opts?: {
|
|
120
|
-
wait?: boolean;
|
|
121
|
-
background?: boolean;
|
|
122
|
-
body?: unknown;
|
|
123
|
-
} & CallOptions): Promise<unknown>;
|
|
124
|
-
build(opts?: {
|
|
125
|
-
background?: boolean;
|
|
126
|
-
} & CallOptions): Promise<unknown>;
|
|
127
|
-
delta(opts?: CallOptions): Promise<Schemas["IndexDeltaResponse"]>;
|
|
128
|
-
submit(body: Partial<Schemas["IndexBuildOptions"]> | undefined, opts: CallOptions & {
|
|
129
|
-
idempotencyKey: string;
|
|
130
|
-
}): Promise<Schemas["SearchIndexJobStatusResponse"]>;
|
|
131
|
-
job(jobId: string, opts?: CallOptions): Promise<Schemas["SearchIndexJobStatusResponse"]>;
|
|
132
|
-
cancel(jobId: string, opts?: CallOptions): Promise<Schemas["SearchIndexJobStatusResponse"]>;
|
|
133
|
-
gc(opts?: {
|
|
134
|
-
keepRuns?: number;
|
|
135
|
-
dryRun?: boolean;
|
|
136
|
-
} & CallOptions): Promise<Schemas["IndexGcResponse"]>;
|
|
137
|
-
submitGc(body: Schemas["IndexGcRequest"] | undefined, opts: CallOptions & {
|
|
138
|
-
idempotencyKey: string;
|
|
139
|
-
}): Promise<Schemas["IndexGcJobStatusResponse"]>;
|
|
140
|
-
gcJob(jobId: string, opts?: CallOptions): Promise<Schemas["IndexGcJobStatusResponse"]>;
|
|
141
|
-
cancelGc(jobId: string, opts?: CallOptions): Promise<Schemas["IndexGcJobStatusResponse"]>;
|
|
94
|
+
fullText(body: Schemas["FullTextSearchRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["FullTextSearchResponse"]>;
|
|
95
|
+
vector(body: Schemas["EmbeddingSearchRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["EmbeddingSearchResponse"]>;
|
|
142
96
|
}
|
|
143
97
|
export declare class EntityNamespace {
|
|
144
98
|
private readonly client;
|
|
145
99
|
constructor(client: LbbClient);
|
|
146
100
|
/**
|
|
147
101
|
* Return the exact type cardinality and a bounded deterministic sample from
|
|
148
|
-
* the ranged adjacency
|
|
149
|
-
* falling back to an exhaustive
|
|
102
|
+
* the ranged adjacency family pinned by the published generation. A missing
|
|
103
|
+
* family fails closed rather than falling back to an exhaustive scan.
|
|
150
104
|
*/
|
|
151
105
|
sample(opts: {
|
|
152
106
|
type: string;
|
|
153
107
|
limit?: number;
|
|
154
108
|
} & CallOptions): Promise<Schemas["EntityTypeSampleResponse"]>;
|
|
155
|
-
/**
|
|
156
|
-
* Browse entities as the unified list envelope. Pass `fields` (names or `*`)
|
|
157
|
-
* to inline each row's typed attributes as native JSON (under `attributes`) —
|
|
158
|
-
* "list entities and their titles" in one call instead of a list plus N point
|
|
159
|
-
* lookups — or `ids`
|
|
160
|
-
* to fetch a specific set. Page with `cursor` from the previous `next_cursor`.
|
|
161
|
-
*/
|
|
162
|
-
list(opts?: EntityListOptions): Promise<ListResponse<Schemas["EntityExplorerRow"]>>;
|
|
163
|
-
/** Yield list envelopes while following `next_cursor` until exhaustion. */
|
|
164
|
-
pages(opts?: EntityListOptions): AsyncGenerator<ListResponse<Schemas["EntityExplorerRow"]>>;
|
|
165
|
-
/** Yield entities directly while following the server's stable cursor. */
|
|
166
|
-
iterate(opts?: EntityListOptions): AsyncGenerator<Schemas["EntityExplorerRow"]>;
|
|
167
109
|
get(opts: {
|
|
168
110
|
id?: string;
|
|
169
111
|
type?: string;
|
|
@@ -183,23 +125,10 @@ export declare class EntityNamespace {
|
|
|
183
125
|
*/
|
|
184
126
|
filterByAttributes(opts: EntityAttributeFilterOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
185
127
|
}
|
|
186
|
-
|
|
187
|
-
type?: string;
|
|
188
|
-
limit?: number;
|
|
189
|
-
cursor?: string | number;
|
|
190
|
-
/** @deprecated Legacy alias for `cursor`. */
|
|
191
|
-
offset?: number;
|
|
192
|
-
query?: string;
|
|
193
|
-
/** Property names to inline per row (or `"*"` / `["*"]` for all). */
|
|
194
|
-
fields?: string | string[];
|
|
195
|
-
/** Specific entity ids to fetch in one call (bulk lookup). */
|
|
196
|
-
ids?: string | string[];
|
|
197
|
-
}
|
|
198
|
-
/** Grounding and answer operations over the graph's real vocabulary. */
|
|
128
|
+
/** Grounding operations over one pinned published vocabulary. */
|
|
199
129
|
export declare class ContextNamespace {
|
|
200
130
|
private readonly client;
|
|
201
131
|
constructor(client: LbbClient);
|
|
202
|
-
ask(body: Schemas["AskRequest"], opts?: CallOptions): Promise<Schemas["AskResponse"]>;
|
|
203
132
|
suggest(body: Schemas["SearchSuggestRequest"], opts?: CallOptions): Promise<Schemas["SearchSuggestResponse"]>;
|
|
204
133
|
resolve(body: Schemas["ResolveTermRequest"], opts?: CallOptions): Promise<Schemas["ResolveTermResponse"]>;
|
|
205
134
|
decode(body: Schemas["DecodeRequest"], opts?: CallOptions): Promise<Schemas["DecodeResponse"]>;
|
|
@@ -207,6 +136,15 @@ export declare class ContextNamespace {
|
|
|
207
136
|
sample?: number;
|
|
208
137
|
} & CallOptions): Promise<Schemas["GroundabilityReport"]>;
|
|
209
138
|
}
|
|
139
|
+
/** Active ontology/SHACL bundle metadata and atomic publication. */
|
|
140
|
+
export declare class SchemaNamespace {
|
|
141
|
+
private readonly client;
|
|
142
|
+
constructor(client: LbbClient);
|
|
143
|
+
/** Read active metadata without running request-time validation. */
|
|
144
|
+
view(opts?: CallOptions): Promise<Schemas["SchemaBundleView"]>;
|
|
145
|
+
/** Atomically publish a bundle; conformance is produced asynchronously. */
|
|
146
|
+
publish(body: Schemas["SchemaPublishRequest"], opts?: CallOptions): Promise<Schemas["SchemaPublishResponse"]>;
|
|
147
|
+
}
|
|
210
148
|
/** Ontology discovery and lifecycle operations. */
|
|
211
149
|
export declare class OntologyNamespace {
|
|
212
150
|
private readonly client;
|
|
@@ -214,22 +152,19 @@ export declare class OntologyNamespace {
|
|
|
214
152
|
view(options?: {
|
|
215
153
|
counts?: boolean;
|
|
216
154
|
} & CallOptions): Promise<Schemas["OntologyView"]>;
|
|
217
|
-
conformance(opts?: CallOptions): Promise<Schemas["SchemaAuditReport"]>;
|
|
155
|
+
conformance(opts?: CallOptions & Pick<ReadConsistencyOptions, "consistency">): Promise<Schemas["SchemaAuditReport"]>;
|
|
218
156
|
search(body: Schemas["OntologySearchRequest"], opts?: CallOptions): Promise<Schemas["OntologySearchResponse"]>;
|
|
219
157
|
resolve(body: Schemas["OntologyResolveRequest"], opts?: CallOptions): Promise<Schemas["OntologyResolveResponse"]>;
|
|
220
158
|
define(body: Schemas["OntologyDefineRequest"], opts?: CallOptions): Promise<Schemas["OntologyDefineResponse"]>;
|
|
221
159
|
evolve(body: Schemas["OntologyEvolveRequest"], opts?: CallOptions): Promise<Schemas["OntologyEvolveResponse"]>;
|
|
222
160
|
induce(body: Schemas["OntologyInduceRequest"], opts?: CallOptions): Promise<Schemas["OntologyInduceResponse"]>;
|
|
223
161
|
}
|
|
224
|
-
/** Structured, SPARQL-text,
|
|
162
|
+
/** Structured, SPARQL-text, and analytical query operations. */
|
|
225
163
|
export declare class QueryNamespace {
|
|
226
164
|
private readonly client;
|
|
227
165
|
constructor(client: LbbClient);
|
|
228
|
-
structured(body: Schemas["SparqlSelectRequest"], opts?: CallOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
229
|
-
sparql(body: Schemas["SparqlTextRequest"], opts?: CallOptions): Promise<import("./types.js").SparqlResults>;
|
|
230
|
-
sparqlRaw(body: Schemas["SparqlTextRequest"], opts?: CallOptions): Promise<Schemas["SparqlTextResponse"]>;
|
|
166
|
+
structured(body: Schemas["SparqlSelectRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
167
|
+
sparql(body: Schemas["SparqlTextRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<import("./types.js").SparqlResults>;
|
|
168
|
+
sparqlRaw(body: Schemas["SparqlTextRequest"], opts?: CallOptions & ReadConsistencyOptions): Promise<Schemas["SparqlTextResponse"]>;
|
|
231
169
|
analytics(body: Schemas["AnalyticQueryRequest"], opts?: CallOptions): Promise<Schemas["AnalyticQueryResponse"]>;
|
|
232
|
-
shacl(body: Schemas["ShaclQueryRequest"], opts?: CallOptions): Promise<Schemas["ShaclQueryResponse"]>;
|
|
233
|
-
infer(body: Schemas["InferenceRunRequest"], opts?: CallOptions): Promise<Schemas["InferenceRunResponse"]>;
|
|
234
|
-
premises(body: Schemas["RetrievalPremiseRequest"], opts?: CallOptions): Promise<Schemas["RetrievalPremiseResponse"]>;
|
|
235
170
|
}
|
package/dist/namespaces.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { attributeFilter, firstPatternVariable, parseSparqlResults, } from "./types.js";
|
|
2
|
+
/** A5: fold read-consistency options into a request body's `consistency` /
|
|
3
|
+
* `min_indexed_seq` fields; a per-call value wins over the client default. */
|
|
4
|
+
function withReadConsistency(client, body, opts) {
|
|
5
|
+
const consistency = opts.consistency ?? client.defaultConsistency;
|
|
6
|
+
const merged = { ...body };
|
|
7
|
+
if (consistency !== undefined && merged.consistency === undefined) {
|
|
8
|
+
merged.consistency = consistency;
|
|
9
|
+
}
|
|
10
|
+
if (opts.minIndexedSeq !== undefined &&
|
|
11
|
+
merged.min_indexed_seq === undefined) {
|
|
12
|
+
merged.min_indexed_seq = opts.minIndexedSeq;
|
|
13
|
+
}
|
|
14
|
+
return merged;
|
|
15
|
+
}
|
|
2
16
|
function transportOptions(options) {
|
|
3
17
|
return {
|
|
4
18
|
idempotencyKey: options.idempotencyKey,
|
|
@@ -14,7 +28,6 @@ export class GraphNamespace {
|
|
|
14
28
|
facts;
|
|
15
29
|
context;
|
|
16
30
|
entities;
|
|
17
|
-
indexes;
|
|
18
31
|
ontology;
|
|
19
32
|
query;
|
|
20
33
|
schema;
|
|
@@ -24,7 +37,6 @@ export class GraphNamespace {
|
|
|
24
37
|
this.facts = new FactsNamespace(client);
|
|
25
38
|
this.context = client.context;
|
|
26
39
|
this.entities = client.entities;
|
|
27
|
-
this.indexes = client.indexes;
|
|
28
40
|
this.ontology = client.ontology;
|
|
29
41
|
this.query = client.query;
|
|
30
42
|
this.schema = client.schema;
|
|
@@ -116,10 +128,6 @@ export class GraphNamespace {
|
|
|
116
128
|
body,
|
|
117
129
|
});
|
|
118
130
|
}
|
|
119
|
-
/** Export this graph's current snapshot as Turtle, N-Triples, TriG, or N-Quads. */
|
|
120
|
-
exportRdf(opts = {}) {
|
|
121
|
-
return this.client.exportRdf(opts);
|
|
122
|
-
}
|
|
123
131
|
}
|
|
124
132
|
export class FactsNamespace {
|
|
125
133
|
client;
|
|
@@ -135,7 +143,7 @@ export class FactsNamespace {
|
|
|
135
143
|
}
|
|
136
144
|
/** Bulk-load a dataset as NDJSON. See {@link LbbClient.import}. */
|
|
137
145
|
import(lines, opts = {}) {
|
|
138
|
-
const { batch, strict, observedAt,
|
|
146
|
+
const { batch, strict, observedAt, ...request } = opts;
|
|
139
147
|
const ndjson = typeof lines === "string"
|
|
140
148
|
? lines
|
|
141
149
|
: lines.map((line) => JSON.stringify(line)).join("\n");
|
|
@@ -144,7 +152,7 @@ export class FactsNamespace {
|
|
|
144
152
|
idempotencyKey: request.idempotencyKey ?? this.client.idempotencyKey("import"),
|
|
145
153
|
rawBody: ndjson,
|
|
146
154
|
contentType: "application/x-ndjson",
|
|
147
|
-
query: { batch, strict, observed_at: observedAt
|
|
155
|
+
query: { batch, strict, observed_at: observedAt },
|
|
148
156
|
});
|
|
149
157
|
}
|
|
150
158
|
/**
|
|
@@ -186,10 +194,14 @@ export class SearchNamespace {
|
|
|
186
194
|
}
|
|
187
195
|
hybrid(input, opts = {}) {
|
|
188
196
|
if (typeof input !== "string") {
|
|
197
|
+
const search = withReadConsistency(this.client, input.search ?? {}, {
|
|
198
|
+
consistency: opts.consistency,
|
|
199
|
+
minIndexedSeq: opts.minIndexedSeq,
|
|
200
|
+
});
|
|
189
201
|
return this.client.request("POST", "/v1/graph/search", {
|
|
190
202
|
...transportOptions(opts),
|
|
191
203
|
retry: opts.retry ?? true,
|
|
192
|
-
body: input,
|
|
204
|
+
body: { ...input, search },
|
|
193
205
|
});
|
|
194
206
|
}
|
|
195
207
|
return this.client.request("GET", "/v1/search", {
|
|
@@ -197,15 +209,13 @@ export class SearchNamespace {
|
|
|
197
209
|
query: {
|
|
198
210
|
query: input,
|
|
199
211
|
top_k: opts.topK,
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
consistency: opts.consistency ?? this.client.defaultConsistency,
|
|
213
|
+
min_indexed_seq: opts.minIndexedSeq,
|
|
202
214
|
lexical: opts.lexical,
|
|
203
215
|
bm25: opts.bm25,
|
|
204
216
|
vector: opts.vector,
|
|
205
217
|
targets: opts.targets?.join(","),
|
|
206
218
|
profile: opts.profile,
|
|
207
|
-
as_of: opts.asOf,
|
|
208
|
-
as_of_commit_seq: opts.asOfCommitSeq,
|
|
209
219
|
log_impression: opts.logImpression,
|
|
210
220
|
},
|
|
211
221
|
});
|
|
@@ -233,109 +243,14 @@ export class SearchNamespace {
|
|
|
233
243
|
return this.client.request("POST", "/v1/search/full-text", {
|
|
234
244
|
...opts,
|
|
235
245
|
retry: opts.retry ?? true,
|
|
236
|
-
body,
|
|
246
|
+
body: withReadConsistency(this.client, body, opts),
|
|
237
247
|
});
|
|
238
248
|
}
|
|
239
249
|
vector(body, opts = {}) {
|
|
240
250
|
return this.client.request("POST", "/v1/search/embedding", {
|
|
241
251
|
...opts,
|
|
242
252
|
retry: opts.retry ?? true,
|
|
243
|
-
body,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
export class SchemaNamespace {
|
|
248
|
-
client;
|
|
249
|
-
constructor(client) {
|
|
250
|
-
this.client = client;
|
|
251
|
-
}
|
|
252
|
-
/** Active graph schema bundle: ontology plus activated SHACL shapes. */
|
|
253
|
-
view(opts = {}) {
|
|
254
|
-
const { audit, ...request } = opts;
|
|
255
|
-
return this.client.request("GET", "/v1/schema", {
|
|
256
|
-
...request,
|
|
257
|
-
query: { audit: audit || undefined },
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
/** Preview a proposed RDF/SHACL schema bundle and audit current data. */
|
|
261
|
-
preview(body, opts = {}) {
|
|
262
|
-
return this.client.request("POST", "/v1/schema/preview", {
|
|
263
|
-
...opts,
|
|
264
|
-
retry: opts.retry ?? true,
|
|
265
|
-
body,
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
/** Activate a previewed SHACL schema bundle for this graph branch. */
|
|
269
|
-
publish(body, opts = {}) {
|
|
270
|
-
return this.client.request("POST", "/v1/schema/publish", { ...opts, body });
|
|
271
|
-
}
|
|
272
|
-
/** Audit current data against the active SHACL schema bundle. */
|
|
273
|
-
audit(opts = {}) {
|
|
274
|
-
return this.client.request("POST", "/v1/schema/audit", {
|
|
275
|
-
...opts,
|
|
276
|
-
retry: opts.retry ?? true,
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
export class IndexNamespace {
|
|
281
|
-
client;
|
|
282
|
-
constructor(client) {
|
|
283
|
-
this.client = client;
|
|
284
|
-
}
|
|
285
|
-
run(opts = {}) {
|
|
286
|
-
const { wait, background: requestedBackground, body, ...request } = opts;
|
|
287
|
-
const background = requestedBackground ?? (wait === false ? true : undefined);
|
|
288
|
-
return this.client.request("POST", "/v1/index/run", {
|
|
289
|
-
...request,
|
|
290
|
-
query: { background },
|
|
291
|
-
body,
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
build(opts = {}) {
|
|
295
|
-
const { background, ...request } = opts;
|
|
296
|
-
return this.client.request("POST", "/v1/index/build", {
|
|
297
|
-
...request,
|
|
298
|
-
query: { background: background || undefined },
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
delta(opts = {}) {
|
|
302
|
-
return this.client.request("POST", "/v1/index/delta", opts);
|
|
303
|
-
}
|
|
304
|
-
submit(body = {}, opts) {
|
|
305
|
-
return this.client.request("POST", "/v1/index/jobs", { ...opts, body });
|
|
306
|
-
}
|
|
307
|
-
job(jobId, opts = {}) {
|
|
308
|
-
return this.client.request("GET", "/v1/index/jobs", {
|
|
309
|
-
...opts,
|
|
310
|
-
query: { job_id: jobId },
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
cancel(jobId, opts = {}) {
|
|
314
|
-
return this.client.request("DELETE", "/v1/index/jobs", {
|
|
315
|
-
...opts,
|
|
316
|
-
query: { job_id: jobId },
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
gc(opts = {}) {
|
|
320
|
-
const { keepRuns, dryRun, ...request } = opts;
|
|
321
|
-
return this.client.request("POST", "/v1/index/gc", {
|
|
322
|
-
...request,
|
|
323
|
-
query: { keep_runs: keepRuns, dry_run: dryRun },
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
submitGc(body = {}, opts) {
|
|
327
|
-
return this.client.request("POST", "/v1/index/gc-jobs", { ...opts, body });
|
|
328
|
-
}
|
|
329
|
-
gcJob(jobId, opts = {}) {
|
|
330
|
-
return this.client.request("GET", "/v1/index/gc-jobs", {
|
|
331
|
-
...opts,
|
|
332
|
-
query: { job_id: jobId },
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
cancelGc(jobId, opts = {}) {
|
|
336
|
-
return this.client.request("DELETE", "/v1/index/gc-jobs", {
|
|
337
|
-
...opts,
|
|
338
|
-
query: { job_id: jobId },
|
|
253
|
+
body: withReadConsistency(this.client, body, opts),
|
|
339
254
|
});
|
|
340
255
|
}
|
|
341
256
|
}
|
|
@@ -346,61 +261,12 @@ export class EntityNamespace {
|
|
|
346
261
|
}
|
|
347
262
|
/**
|
|
348
263
|
* Return the exact type cardinality and a bounded deterministic sample from
|
|
349
|
-
* the ranged adjacency
|
|
350
|
-
* 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.
|
|
351
266
|
*/
|
|
352
267
|
sample(opts) {
|
|
353
268
|
return this.client.entityTypeSample(opts);
|
|
354
269
|
}
|
|
355
|
-
/**
|
|
356
|
-
* Browse entities as the unified list envelope. Pass `fields` (names or `*`)
|
|
357
|
-
* to inline each row's typed attributes as native JSON (under `attributes`) —
|
|
358
|
-
* "list entities and their titles" in one call instead of a list plus N point
|
|
359
|
-
* lookups — or `ids`
|
|
360
|
-
* to fetch a specific set. Page with `cursor` from the previous `next_cursor`.
|
|
361
|
-
*/
|
|
362
|
-
list(opts = {}) {
|
|
363
|
-
const csv = (v) => Array.isArray(v) ? v.join(",") : v;
|
|
364
|
-
return this.client.request("GET", "/v1/graph/entities", {
|
|
365
|
-
...transportOptions(opts),
|
|
366
|
-
query: {
|
|
367
|
-
type: opts.type,
|
|
368
|
-
limit: opts.limit,
|
|
369
|
-
cursor: opts.cursor,
|
|
370
|
-
offset: opts.offset,
|
|
371
|
-
q: opts.query,
|
|
372
|
-
fields: csv(opts.fields),
|
|
373
|
-
ids: csv(opts.ids),
|
|
374
|
-
},
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
/** Yield list envelopes while following `next_cursor` until exhaustion. */
|
|
378
|
-
async *pages(opts = {}) {
|
|
379
|
-
let cursor = opts.cursor;
|
|
380
|
-
const seen = new Set();
|
|
381
|
-
do {
|
|
382
|
-
const page = await this.list({
|
|
383
|
-
...opts,
|
|
384
|
-
cursor,
|
|
385
|
-
offset: cursor === undefined ? opts.offset : undefined,
|
|
386
|
-
});
|
|
387
|
-
yield page;
|
|
388
|
-
if (!page.has_more || page.next_cursor === null)
|
|
389
|
-
return;
|
|
390
|
-
if (seen.has(page.next_cursor)) {
|
|
391
|
-
throw new Error(`entity pagination cursor repeated: ${page.next_cursor}`);
|
|
392
|
-
}
|
|
393
|
-
seen.add(page.next_cursor);
|
|
394
|
-
cursor = page.next_cursor;
|
|
395
|
-
} while (true);
|
|
396
|
-
}
|
|
397
|
-
/** Yield entities directly while following the server's stable cursor. */
|
|
398
|
-
async *iterate(opts = {}) {
|
|
399
|
-
for await (const page of this.pages(opts)) {
|
|
400
|
-
for (const entity of page.data)
|
|
401
|
-
yield entity;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
270
|
get(opts) {
|
|
405
271
|
return this.client.entityMetadata(opts);
|
|
406
272
|
}
|
|
@@ -425,8 +291,6 @@ export class EntityNamespace {
|
|
|
425
291
|
select: opts.select,
|
|
426
292
|
limit: opts.limit,
|
|
427
293
|
offset: opts.offset,
|
|
428
|
-
as_of_valid_time: opts.asOfValidTime,
|
|
429
|
-
as_of_commit_seq: opts.asOfCommitSeq,
|
|
430
294
|
order_by: opts.orderBy,
|
|
431
295
|
reason: opts.reason,
|
|
432
296
|
max_solutions: opts.maxSolutions,
|
|
@@ -435,19 +299,12 @@ export class EntityNamespace {
|
|
|
435
299
|
});
|
|
436
300
|
}
|
|
437
301
|
}
|
|
438
|
-
/** Grounding
|
|
302
|
+
/** Grounding operations over one pinned published vocabulary. */
|
|
439
303
|
export class ContextNamespace {
|
|
440
304
|
client;
|
|
441
305
|
constructor(client) {
|
|
442
306
|
this.client = client;
|
|
443
307
|
}
|
|
444
|
-
ask(body, opts = {}) {
|
|
445
|
-
return this.client.request("POST", "/v1/ask", {
|
|
446
|
-
...opts,
|
|
447
|
-
retry: opts.retry ?? true,
|
|
448
|
-
body,
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
308
|
suggest(body, opts = {}) {
|
|
452
309
|
return this.client.request("POST", "/v1/search/suggest", {
|
|
453
310
|
...opts,
|
|
@@ -477,6 +334,25 @@ export class ContextNamespace {
|
|
|
477
334
|
});
|
|
478
335
|
}
|
|
479
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
|
+
}
|
|
480
356
|
/** Ontology discovery and lifecycle operations. */
|
|
481
357
|
export class OntologyNamespace {
|
|
482
358
|
client;
|
|
@@ -491,7 +367,12 @@ export class OntologyNamespace {
|
|
|
491
367
|
});
|
|
492
368
|
}
|
|
493
369
|
conformance(opts = {}) {
|
|
494
|
-
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
|
+
});
|
|
495
376
|
}
|
|
496
377
|
search(body, opts = {}) {
|
|
497
378
|
return this.client.request("POST", "/v1/ontology/search", {
|
|
@@ -527,7 +408,7 @@ export class OntologyNamespace {
|
|
|
527
408
|
});
|
|
528
409
|
}
|
|
529
410
|
}
|
|
530
|
-
/** Structured, SPARQL-text,
|
|
411
|
+
/** Structured, SPARQL-text, and analytical query operations. */
|
|
531
412
|
export class QueryNamespace {
|
|
532
413
|
client;
|
|
533
414
|
constructor(client) {
|
|
@@ -537,11 +418,20 @@ export class QueryNamespace {
|
|
|
537
418
|
return this.client.request("POST", "/v1/query/sparql", {
|
|
538
419
|
...opts,
|
|
539
420
|
retry: opts.retry ?? true,
|
|
540
|
-
body,
|
|
421
|
+
body: withReadConsistency(this.client, body, opts),
|
|
541
422
|
});
|
|
542
423
|
}
|
|
543
424
|
async sparql(body, opts = {}) {
|
|
544
|
-
|
|
425
|
+
// The text dialect carries consistency/floor on the URL, not the body.
|
|
426
|
+
const response = await this.client.request("POST", "/v1/query/sparql-text", {
|
|
427
|
+
...opts,
|
|
428
|
+
retry: opts.retry ?? true,
|
|
429
|
+
body,
|
|
430
|
+
query: {
|
|
431
|
+
consistency: opts.consistency ?? this.client.defaultConsistency,
|
|
432
|
+
min_indexed_seq: opts.minIndexedSeq,
|
|
433
|
+
},
|
|
434
|
+
});
|
|
545
435
|
return parseSparqlResults(response);
|
|
546
436
|
}
|
|
547
437
|
sparqlRaw(body, opts = {}) {
|
|
@@ -549,6 +439,10 @@ export class QueryNamespace {
|
|
|
549
439
|
...opts,
|
|
550
440
|
retry: opts.retry ?? true,
|
|
551
441
|
body,
|
|
442
|
+
query: {
|
|
443
|
+
consistency: opts.consistency ?? this.client.defaultConsistency,
|
|
444
|
+
min_indexed_seq: opts.minIndexedSeq,
|
|
445
|
+
},
|
|
552
446
|
});
|
|
553
447
|
}
|
|
554
448
|
analytics(body, opts = {}) {
|
|
@@ -558,25 +452,4 @@ export class QueryNamespace {
|
|
|
558
452
|
body,
|
|
559
453
|
});
|
|
560
454
|
}
|
|
561
|
-
shacl(body, opts = {}) {
|
|
562
|
-
return this.client.request("POST", "/v1/query/shacl", {
|
|
563
|
-
...opts,
|
|
564
|
-
retry: opts.retry ?? true,
|
|
565
|
-
body,
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
infer(body, opts = {}) {
|
|
569
|
-
return this.client.request("POST", "/v1/inference/run", {
|
|
570
|
-
...opts,
|
|
571
|
-
retry: opts.retry ?? true,
|
|
572
|
-
body,
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
premises(body, opts = {}) {
|
|
576
|
-
return this.client.request("POST", "/v1/inference/retrieval-premises", {
|
|
577
|
-
...opts,
|
|
578
|
-
retry: opts.retry ?? true,
|
|
579
|
-
body,
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
455
|
}
|