@littlebigbrain/client 0.14.0 → 0.15.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.
@@ -7,8 +7,13 @@ export interface CallOptions {
7
7
  maxRetries?: number;
8
8
  /** Override the client's deadline-based retry budget (ms) for this request. */
9
9
  retryBudgetMs?: number;
10
- /** Override retry safety classification. Read-only POST namespaces set this automatically. */
11
- retry?: boolean;
10
+ /**
11
+ * Override retry safety classification. Read-only POST namespaces set this
12
+ * automatically. `true` retries a `429`, a `5xx` and a network failure;
13
+ * `"rate_limited"` retries only a retryable `429`, which the server returns
14
+ * before it runs the request.
15
+ */
16
+ retry?: boolean | "rate_limited";
12
17
  /** Abort the request and suppress any further retries. */
13
18
  signal?: AbortSignal;
14
19
  /** Additional request headers. Values override SDK defaults intentionally. */
@@ -50,6 +55,16 @@ export type Query = Record<string, QueryValue>;
50
55
  export declare function sleep(ms: number): Promise<void>;
51
56
  export declare function retryableStatus(status: number): boolean;
52
57
  export declare function retryAllowed(method: string, idempotencyKey?: string): boolean;
58
+ /**
59
+ * Whether a request's retry classification covers a network failure.
60
+ * `"rate_limited"` does not: the request may have run on the server.
61
+ */
62
+ export declare function retriesNetworkFailure(retry: boolean | "rate_limited"): boolean;
63
+ /**
64
+ * Whether a request's retry classification covers a retryable status.
65
+ * `"rate_limited"` covers only `429`.
66
+ */
67
+ export declare function retriesStatus(retry: boolean | "rate_limited", status: number): boolean;
53
68
  /** Parse a Retry-After delta-seconds or HTTP-date value, capped at one minute. */
54
69
  export declare function parseRetryAfterMs(value: string | null | undefined, nowMs?: number): number | undefined;
55
70
  /**
package/dist/transport.js CHANGED
@@ -69,6 +69,20 @@ export function retryAllowed(method, idempotencyKey) {
69
69
  upper === "OPTIONS" ||
70
70
  idempotencyKey !== undefined);
71
71
  }
72
+ /**
73
+ * Whether a request's retry classification covers a network failure.
74
+ * `"rate_limited"` does not: the request may have run on the server.
75
+ */
76
+ export function retriesNetworkFailure(retry) {
77
+ return retry === true;
78
+ }
79
+ /**
80
+ * Whether a request's retry classification covers a retryable status.
81
+ * `"rate_limited"` covers only `429`.
82
+ */
83
+ export function retriesStatus(retry, status) {
84
+ return retry === "rate_limited" ? status === 429 : retry;
85
+ }
72
86
  const MAX_RETRY_AFTER_MS = 60_000;
73
87
  /** Parse a Retry-After delta-seconds or HTTP-date value, capped at one minute. */
74
88
  export function parseRetryAfterMs(value, nowMs = Date.now()) {
package/dist/types.d.ts CHANGED
@@ -138,12 +138,19 @@ export interface SparqlResultsJson {
138
138
  boolean?: boolean;
139
139
  }
140
140
  /** Parsed SPARQL results: the head vars, the ASK boolean (or null), the raw
141
- * typed bindings, and the bindings flattened to `{ variable: lexicalValue }`. */
141
+ * typed bindings, the bindings flattened to `{ variable: lexicalValue }`, and
142
+ * the served snapshot (or null). */
142
143
  export interface SparqlResults {
143
144
  vars: string[];
144
145
  boolean: boolean | null;
145
146
  bindings: Record<string, SparqlTerm>[];
146
147
  rows: Record<string, string>[];
148
+ /**
149
+ * The snapshot the rows were read from, for an eventual or pinned
150
+ * (`as_of_commit_seq`) read: `served_at_seq` is that commit. `null` for a
151
+ * plain strong read.
152
+ */
153
+ snapshot: Schemas["SnapshotView"] | null;
147
154
  }
148
155
  /**
149
156
  * Parse a {@link Schemas.SparqlTextResponse} (whose `results` field carries the
package/dist/types.js CHANGED
@@ -7,12 +7,13 @@
7
7
  export function parseSparqlResults(response) {
8
8
  const doc = JSON.parse(response.results);
9
9
  const vars = doc.head?.vars ?? [];
10
+ const snapshot = response.snapshot ?? null;
10
11
  if (typeof doc.boolean === "boolean") {
11
- return { vars, boolean: doc.boolean, bindings: [], rows: [] };
12
+ return { vars, boolean: doc.boolean, bindings: [], rows: [], snapshot };
12
13
  }
13
14
  const bindings = doc.results?.bindings ?? [];
14
15
  const rows = bindings.map((binding) => Object.fromEntries(Object.entries(binding).map(([name, term]) => [name, term.value])));
15
- return { vars, boolean: null, bindings, rows };
16
+ return { vars, boolean: null, bindings, rows, snapshot };
16
17
  }
17
18
  export function firstPatternVariable(patterns) {
18
19
  for (const pattern of patterns) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlebigbrain/client",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "TypeScript client for little big brain: search, graph queries, and data import",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {