xmemory 3.14.0 → 3.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.
package/README.md CHANGED
@@ -578,22 +578,34 @@ if (review.status === "evolution_in_progress") {
578
578
  console.log(item.item_fingerprint, item.rationale, item.op);
579
579
  }
580
580
 
581
- // 2. Decide — accept / reject / defer per item, in one batch.
582
- const decisions: DecisionInput[] = proposal.items.map((item) => ({
583
- item_fingerprint: item.item_fingerprint,
584
- decision: "accept",
585
- }));
586
- const decided = await inst.decideSuggestions(proposal.proposal_version, decisions);
587
-
588
- // 3. Apply — commit accepted decisions as one migration.
589
- const applied = await inst.applyPendingDecisions(decided.next_proposal_version);
590
- console.log(applied.status, applied.summary); // e.g. "ok" "added 1 field"
581
+ // 2. Decide — accept / reject / defer per item, in one batch. Leave out
582
+ // items flagged apply_blocked: accepting one fails the whole apply.
583
+ const decisions: DecisionInput[] = proposal.items
584
+ .filter((item) => !item.apply_blocked)
585
+ .map((item) => ({
586
+ item_fingerprint: item.item_fingerprint,
587
+ decision: "accept",
588
+ }));
589
+ if (decisions.length > 0) {
590
+ const decided = await inst.decideSuggestions(proposal.proposal_version, decisions);
591
+
592
+ // 3. Apply — commit accepted decisions as one migration.
593
+ const applied = await inst.applyPendingDecisions(decided.next_proposal_version);
594
+ console.log(applied.status, applied.summary); // e.g. "ok" "added 1 field"
595
+ }
591
596
  }
592
597
  ```
593
598
 
594
599
  When `status === "evolution_in_progress"`, back off for `retry_after_seconds`
595
600
  and retry instead of blocking.
596
601
 
602
+ An item with `apply_blocked: true` cannot be applied as proposed — for example
603
+ a field that another item in the same proposal already adds as part of a new
604
+ object — and its `rationale` says why. Accepting it fails the whole apply, so a
605
+ bulk accept should skip it; the remaining items apply together. When every item
606
+ is flagged there is nothing to accept: skip the decide call, which refuses an
607
+ empty batch with `invalid_decision_input`.
608
+
597
609
  ### Direct migration flow (enhance → dry-run → update)
598
610
 
599
611
  Drive a migration yourself — ask the server to *enhance* the current schema,
@@ -267,11 +267,19 @@ class XmemoryClient {
267
267
  : raw.slice(0, 200));
268
268
  throw new types_js_1.XmemoryAPIError(`HTTP ${res.status}: ${msg}`, res.status, structured.code, structured.details, parseRetryAfter(res));
269
269
  }
270
+ // The schema-evolution endpoints answer an error as a bare
271
+ // `{status: "error", error_type, ...}` payload. A long-running call answers
272
+ // 200 before it finishes, so that payload can arrive on a 2xx response; it
273
+ // is thrown here with its code and details, exactly as on a non-2xx one.
274
+ if (own(payload, "status") === "error" && typeof own(payload, "error_type") === "string") {
275
+ const structured = extractStructuredError(payload);
276
+ throw new types_js_1.XmemoryAPIError(`HTTP ${res.status}: ${structured.message ?? structured.code}`, res.status, structured.code, structured.details, parseRetryAfter(res));
277
+ }
270
278
  const response = payload;
271
279
  const responseErrors = ownArray(response, "errors");
272
280
  if (responseErrors.length > 0) {
273
281
  const first = responseErrors[0];
274
- throw new types_js_1.XmemoryAPIError(`API error: ${first.message} (${first.code})`, res.status, first.code);
282
+ throw new types_js_1.XmemoryAPIError(`API error: ${first.message} (${first.code})`, res.status, first.code, first.details ?? null, parseRetryAfter(res));
275
283
  }
276
284
  return response;
277
285
  }
@@ -712,6 +712,15 @@ export interface ProposalItem {
712
712
  readonly depends_on: string[];
713
713
  readonly current_decision: string | null;
714
714
  readonly rationale: string;
715
+ /**
716
+ * `true` when the change cannot be applied as proposed — for example a field
717
+ * that another item in the same proposal already adds as part of a new
718
+ * object. Accepting it fails the whole apply, and `rationale` says why, so
719
+ * leave it out of a bulk accept: the items not flagged apply together. The
720
+ * server re-derives the flag on every review. Absent on a server that
721
+ * predates it; treat that as not flagged.
722
+ */
723
+ readonly apply_blocked?: boolean;
715
724
  }
716
725
  export interface ConsolidatedProposal {
717
726
  readonly instance_id: string;
@@ -950,6 +959,7 @@ export interface ApiError {
950
959
  readonly message: string;
951
960
  readonly field?: string;
952
961
  readonly resource_id?: string;
962
+ readonly details?: Record<string, unknown> | null;
953
963
  }
954
964
  export interface RawApiResponse {
955
965
  readonly ids?: string[];
@@ -1,2 +1,2 @@
1
1
  /** Package version. Kept in sync with `package.json` — a test asserts they match. */
2
- export declare const VERSION = "3.14.0";
2
+ export declare const VERSION = "3.15.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  /** Package version. Kept in sync with `package.json` — a test asserts they match. */
5
- exports.VERSION = "3.14.0";
5
+ exports.VERSION = "3.15.0";
@@ -261,11 +261,19 @@ export class XmemoryClient {
261
261
  : raw.slice(0, 200));
262
262
  throw new XmemoryAPIError(`HTTP ${res.status}: ${msg}`, res.status, structured.code, structured.details, parseRetryAfter(res));
263
263
  }
264
+ // The schema-evolution endpoints answer an error as a bare
265
+ // `{status: "error", error_type, ...}` payload. A long-running call answers
266
+ // 200 before it finishes, so that payload can arrive on a 2xx response; it
267
+ // is thrown here with its code and details, exactly as on a non-2xx one.
268
+ if (own(payload, "status") === "error" && typeof own(payload, "error_type") === "string") {
269
+ const structured = extractStructuredError(payload);
270
+ throw new XmemoryAPIError(`HTTP ${res.status}: ${structured.message ?? structured.code}`, res.status, structured.code, structured.details, parseRetryAfter(res));
271
+ }
264
272
  const response = payload;
265
273
  const responseErrors = ownArray(response, "errors");
266
274
  if (responseErrors.length > 0) {
267
275
  const first = responseErrors[0];
268
- throw new XmemoryAPIError(`API error: ${first.message} (${first.code})`, res.status, first.code);
276
+ throw new XmemoryAPIError(`API error: ${first.message} (${first.code})`, res.status, first.code, first.details ?? null, parseRetryAfter(res));
269
277
  }
270
278
  return response;
271
279
  }
@@ -712,6 +712,15 @@ export interface ProposalItem {
712
712
  readonly depends_on: string[];
713
713
  readonly current_decision: string | null;
714
714
  readonly rationale: string;
715
+ /**
716
+ * `true` when the change cannot be applied as proposed — for example a field
717
+ * that another item in the same proposal already adds as part of a new
718
+ * object. Accepting it fails the whole apply, and `rationale` says why, so
719
+ * leave it out of a bulk accept: the items not flagged apply together. The
720
+ * server re-derives the flag on every review. Absent on a server that
721
+ * predates it; treat that as not flagged.
722
+ */
723
+ readonly apply_blocked?: boolean;
715
724
  }
716
725
  export interface ConsolidatedProposal {
717
726
  readonly instance_id: string;
@@ -950,6 +959,7 @@ export interface ApiError {
950
959
  readonly message: string;
951
960
  readonly field?: string;
952
961
  readonly resource_id?: string;
962
+ readonly details?: Record<string, unknown> | null;
953
963
  }
954
964
  export interface RawApiResponse {
955
965
  readonly ids?: string[];
@@ -1,2 +1,2 @@
1
1
  /** Package version. Kept in sync with `package.json` — a test asserts they match. */
2
- export declare const VERSION = "3.14.0";
2
+ export declare const VERSION = "3.15.0";
@@ -1,2 +1,2 @@
1
1
  /** Package version. Kept in sync with `package.json` — a test asserts they match. */
2
- export const VERSION = "3.14.0";
2
+ export const VERSION = "3.15.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmemory",
3
- "version": "3.14.0",
3
+ "version": "3.15.0",
4
4
  "description": "xmemory",
5
5
  "keywords": [
6
6
  "xmemory"