@littlebigbrain/client 0.6.1 → 0.7.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/dist/client.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { ImportLine, LbbClientOptions, LbbStackActivityResponse, LbbStackActivityWindow, ListResponse, RawLbbResponse, RdfExportOptions, RdfImportOptions, Schemas, SparqlResults } from "./types.js";
2
- import { type RequestOptions } from "./transport.js";
1
+ import type { ImportLine, LbbClientOptions, ListResponse, RawLbbResponse, RdfExportOptions, RdfImportOptions, Schemas, SparqlResults } from "./types.js";
2
+ import { type CallOptions, type RequestOptions } from "./transport.js";
3
3
  import { ContextNamespace, EntityNamespace, GraphNamespace, IndexNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace } from "./namespaces.js";
4
4
  export { parseSparqlResults } from "./types.js";
5
- export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, FetchLike, FlatProperties, ImportLine, LbbClientOptions, LbbRequestEvent, LbbResponseEvent, LbbRetryEvent, LbbErrorPayload, LbbStackActivityResponse, LbbStackActivityWindow, ListResponse, RawLbbResponse, RdfExportOptions, RdfImportOptions, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, AskRequest, AskResponse, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, SearchRequest, SearchResponse, SearchResult, Snapshot, } from "./types.js";
5
+ export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, FetchLike, FlatProperties, ImportLine, LbbClientOptions, LbbRequestEvent, LbbResponseEvent, LbbRetryEvent, LbbErrorPayload, ListResponse, RawLbbResponse, RdfExportOptions, RdfImportOptions, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, AskRequest, AskResponse, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, SearchRequest, SearchResponse, SearchResult, Snapshot, } from "./types.js";
6
6
  export { LbbError } from "./transport.js";
7
7
  export type { CallOptions, Query, QueryValue, RequestOptions, } from "./transport.js";
8
8
  export type { EntityListOptions, HybridSearchOptions } from "./namespaces.js";
@@ -115,6 +115,42 @@ export declare class LbbClient {
115
115
  }): Promise<Schemas["GraphRetractResponse"]>;
116
116
  /** Create the scoped graph/branch. Construct the client with the desired graph/branch first. */
117
117
  createGraph(): Promise<Schemas["CreateGraphResponse"]>;
118
+ /**
119
+ * Fork a whole graph into a brand-new destination graph in the same tenant.
120
+ * The copy runs as a durable background job (`confirm` is fixed to `dst`, which
121
+ * the route requires to authorize the fork); the destination must not already
122
+ * exist, so the create-only CAS on the server side makes the call safe to
123
+ * retry. The response only acknowledges the enqueue — poll the destination
124
+ * graph's metadata (see `response.poll`) to observe the fork completing: the
125
+ * destination becomes readable once its head is published.
126
+ */
127
+ forkGraph(opts: {
128
+ src: string;
129
+ dst: string;
130
+ }): Promise<Schemas["GraphForkResponse"]>;
131
+ /**
132
+ * Declarative full-state replace: reconcile the scoped graph so its current
133
+ * state matches exactly the NDJSON payload (same line grammar as
134
+ * {@link import} — triplets or `{type,name,properties}` entity records; pass an
135
+ * array, serialized here, or a pre-built NDJSON string). The whole
136
+ * reconciliation lands as one atomic cutover: payload records are upserted, and
137
+ * entities present at the pre-reload head but absent from the payload leave
138
+ * current state (retraction semantics — history is preserved, so an `as_of`
139
+ * read pinned before the cutover still sees the old state). `confirm` must
140
+ * equal the target graph id (reload is semi-destructive). `dryRun` previews the
141
+ * full delta with zero durable changes. The response carries
142
+ * `prior_commit_seq` / `prior_snapshot_token` as the rollback anchor — read
143
+ * them back with `?as_of_commit_seq=<prior_commit_seq>` to see the pre-reload
144
+ * state. An Idempotency-Key scopes the single cutover commit, so a retry
145
+ * replays rather than re-applying.
146
+ */
147
+ reload(lines: ImportLine[] | string, opts: {
148
+ confirm: string;
149
+ dryRun?: boolean;
150
+ strict?: boolean;
151
+ observedAt?: string;
152
+ idempotencyKey?: string;
153
+ }): Promise<Schemas["GraphReloadResponse"]>;
118
154
  /** Fork the scoped branch from an existing branch in the same graph. */
119
155
  createBranch(body: Schemas["GraphBranchCreateRequest"]): Promise<Schemas["GraphBranchCreateResponse"]>;
120
156
  /**
@@ -385,7 +421,14 @@ export declare class LbbClient {
385
421
  name?: string;
386
422
  relations?: string[];
387
423
  asOf?: string;
424
+ /** Require the bounded ranged-adjacency path; returns `index_busy` while unavailable. */
425
+ indexed?: boolean;
388
426
  }): Promise<Schemas["EntityNeighborhoodResponse"]>;
427
+ /** Exact type cardinality plus a bounded deterministic sample from ranged adjacency. */
428
+ entityTypeSample(opts: {
429
+ type: string;
430
+ limit?: number;
431
+ } & CallOptions): Promise<Schemas["EntityTypeSampleResponse"]>;
389
432
  /** Stored entity object-ref status and index-coverage metadata (no
390
433
  * attributes — read those from `entityDetail`'s top-level `attributes`). */
391
434
  entityMetadata(opts: {
@@ -581,8 +624,12 @@ export declare class LbbClient {
581
624
  }): Promise<Schemas["WalCompactResponse"]>;
582
625
  /** Server, graph, and persisted-index status. */
583
626
  status(): Promise<unknown>;
584
- /** Graph footprint, WAL tail, and index coverage. */
585
- metadata(): Promise<Schemas["GraphMetadataResponse"]>;
627
+ /** Graph footprint, WAL tail, and index coverage. Exact object inventory is opt-in. */
628
+ metadata(opts?: {
629
+ includeObjects?: boolean;
630
+ includeIndexes?: boolean;
631
+ includeTemporalCoverage?: boolean;
632
+ }): Promise<Schemas["GraphMetadataResponse"]>;
586
633
  waitForIndexLineage(targetSeq: number, opts?: {
587
634
  timeoutMs?: number;
588
635
  pollIntervalMs?: number;
@@ -591,6 +638,4 @@ export declare class LbbClient {
591
638
  summary(): Promise<Schemas["GraphSummaryResponse"]>;
592
639
  /** List the graphs (and branches) under the scoped tenant. */
593
640
  listGraphs(): Promise<Schemas["GraphListResponse"]>;
594
- /** Activity for the stack selected by the bearer stack key or session. */
595
- stackActivity(window?: LbbStackActivityWindow): Promise<LbbStackActivityResponse>;
596
641
  }
package/dist/client.js CHANGED
@@ -400,6 +400,53 @@ export class LbbClient {
400
400
  createGraph() {
401
401
  return this.request("POST", "/v1/graph/create");
402
402
  }
403
+ /**
404
+ * Fork a whole graph into a brand-new destination graph in the same tenant.
405
+ * The copy runs as a durable background job (`confirm` is fixed to `dst`, which
406
+ * the route requires to authorize the fork); the destination must not already
407
+ * exist, so the create-only CAS on the server side makes the call safe to
408
+ * retry. The response only acknowledges the enqueue — poll the destination
409
+ * graph's metadata (see `response.poll`) to observe the fork completing: the
410
+ * destination becomes readable once its head is published.
411
+ */
412
+ forkGraph(opts) {
413
+ return this.request("POST", "/v1/graph/fork", {
414
+ query: { src: opts.src, dst: opts.dst, confirm: opts.dst },
415
+ retry: true,
416
+ });
417
+ }
418
+ /**
419
+ * Declarative full-state replace: reconcile the scoped graph so its current
420
+ * state matches exactly the NDJSON payload (same line grammar as
421
+ * {@link import} — triplets or `{type,name,properties}` entity records; pass an
422
+ * array, serialized here, or a pre-built NDJSON string). The whole
423
+ * reconciliation lands as one atomic cutover: payload records are upserted, and
424
+ * entities present at the pre-reload head but absent from the payload leave
425
+ * current state (retraction semantics — history is preserved, so an `as_of`
426
+ * read pinned before the cutover still sees the old state). `confirm` must
427
+ * equal the target graph id (reload is semi-destructive). `dryRun` previews the
428
+ * full delta with zero durable changes. The response carries
429
+ * `prior_commit_seq` / `prior_snapshot_token` as the rollback anchor — read
430
+ * them back with `?as_of_commit_seq=<prior_commit_seq>` to see the pre-reload
431
+ * state. An Idempotency-Key scopes the single cutover commit, so a retry
432
+ * replays rather than re-applying.
433
+ */
434
+ reload(lines, opts) {
435
+ const ndjson = typeof lines === "string"
436
+ ? lines
437
+ : lines.map((line) => JSON.stringify(line)).join("\n");
438
+ return this.request("POST", "/v1/graph/reload", {
439
+ rawBody: ndjson,
440
+ contentType: "application/x-ndjson",
441
+ query: {
442
+ confirm: opts.confirm,
443
+ dry_run: opts.dryRun,
444
+ strict: opts.strict,
445
+ observed_at: opts.observedAt,
446
+ },
447
+ idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("reload"),
448
+ });
449
+ }
403
450
  /** Fork the scoped branch from an existing branch in the same graph. */
404
451
  createBranch(body) {
405
452
  return this.request("POST", "/v1/graph/branch", { body });
@@ -783,9 +830,18 @@ export class LbbClient {
783
830
  name: opts.name,
784
831
  relations: opts.relations?.join(","),
785
832
  as_of: opts.asOf,
833
+ indexed: opts.indexed,
786
834
  },
787
835
  });
788
836
  }
837
+ /** Exact type cardinality plus a bounded deterministic sample from ranged adjacency. */
838
+ entityTypeSample(opts) {
839
+ const { type, limit, ...request } = opts;
840
+ return this.request("GET", "/v1/graph/entities/sample", {
841
+ ...request,
842
+ query: { type, limit },
843
+ });
844
+ }
789
845
  /** Stored entity object-ref status and index-coverage metadata (no
790
846
  * attributes — read those from `entityDetail`'s top-level `attributes`). */
791
847
  entityMetadata(opts) {
@@ -1078,9 +1134,15 @@ export class LbbClient {
1078
1134
  status() {
1079
1135
  return this.request("GET", "/v1/status");
1080
1136
  }
1081
- /** Graph footprint, WAL tail, and index coverage. */
1082
- metadata() {
1083
- return this.request("GET", "/v1/graph/metadata");
1137
+ /** Graph footprint, WAL tail, and index coverage. Exact object inventory is opt-in. */
1138
+ metadata(opts = {}) {
1139
+ return this.request("GET", "/v1/graph/metadata", {
1140
+ query: {
1141
+ include_objects: opts.includeObjects,
1142
+ include_indexes: opts.includeIndexes,
1143
+ include_temporal_coverage: opts.includeTemporalCoverage,
1144
+ },
1145
+ });
1084
1146
  }
1085
1147
  async waitForIndexLineage(targetSeq, opts = {}) {
1086
1148
  const deadline = Date.now() + (opts.timeoutMs ?? 30_000);
@@ -1121,9 +1183,4 @@ export class LbbClient {
1121
1183
  listGraphs() {
1122
1184
  return this.request("GET", "/v1/graphs");
1123
1185
  }
1124
- // --- stack activity ---
1125
- /** Activity for the stack selected by the bearer stack key or session. */
1126
- stackActivity(window = "24h") {
1127
- return this.request("GET", "/v1/stack/activity", { query: { window } });
1128
- }
1129
1186
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { LbbClient, LbbError, parseSparqlResults } from "./client.js";
2
- export type { LbbClientOptions, CallOptions, RequestOptions, EntityListOptions, HybridSearchOptions, LbbRequestEvent, LbbResponseEvent, LbbStackActivityResponse, LbbStackActivityWindow, FetchLike, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, AskRequest, AskResponse, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, SearchRequest, SearchResponse, SearchResult, Snapshot, } from "./client.js";
2
+ export type { LbbClientOptions, CallOptions, RequestOptions, EntityListOptions, HybridSearchOptions, LbbRequestEvent, LbbResponseEvent, FetchLike, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, AskRequest, AskResponse, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, SearchRequest, SearchResponse, SearchResult, Snapshot, } from "./client.js";
3
3
  export type { components, paths, operations } from "./schema.js";
@@ -143,6 +143,15 @@ export declare class IndexNamespace {
143
143
  export declare class EntityNamespace {
144
144
  private readonly client;
145
145
  constructor(client: LbbClient);
146
+ /**
147
+ * Return the exact type cardinality and a bounded deterministic sample from
148
+ * the ranged adjacency index. The server returns `index_busy` rather than
149
+ * falling back to an exhaustive snapshot scan when the index is unavailable.
150
+ */
151
+ sample(opts: {
152
+ type: string;
153
+ limit?: number;
154
+ } & CallOptions): Promise<Schemas["EntityTypeSampleResponse"]>;
146
155
  /**
147
156
  * Browse entities as the unified list envelope. Pass `fields` (names or `*`)
148
157
  * to inline each row's typed attributes as native JSON (under `attributes`) —
@@ -344,6 +344,14 @@ export class EntityNamespace {
344
344
  constructor(client) {
345
345
  this.client = client;
346
346
  }
347
+ /**
348
+ * Return the exact type cardinality and a bounded deterministic sample from
349
+ * the ranged adjacency index. The server returns `index_busy` rather than
350
+ * falling back to an exhaustive snapshot scan when the index is unavailable.
351
+ */
352
+ sample(opts) {
353
+ return this.client.entityTypeSample(opts);
354
+ }
347
355
  /**
348
356
  * Browse entities as the unified list envelope. Pass `fields` (names or `*`)
349
357
  * to inline each row's typed attributes as native JSON (under `attributes`) —