xmemory 3.20.0 → 3.21.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
@@ -247,8 +247,9 @@ if (status.write_status === "completed") {
247
247
 
248
248
  A finished write carries `changes`, the async path's only view of what the write
249
249
  did — and where a [scoped write](#scoped-writes) in `"drop"` mode reports what it
250
- left out, and a [field merge](#mergeable-text-fields) what it chose between. A
251
- status for a write that has not finished carries none, so the field is optional.
250
+ left out, a [field merge](#mergeable-text-fields) what it chose between, and a
251
+ [delete](#records-a-delete-left-without-a-link) the records it left without a link.
252
+ A status for a write that has not finished carries none, so the field is optional.
252
253
 
253
254
  ### Write ordering
254
255
 
@@ -334,6 +335,33 @@ The key is omitted when there is no such entry. An absent key does not prove the
334
335
  texts agreed: a merge that failed, fell back to appending, or left the stored
335
336
  text unchanged reports none.
336
337
 
338
+ ### Records a delete left without a link
339
+
340
+ Deleting a record never deletes the records linked to it. The relation's
341
+ `on_delete` removes or clears each link, and the write lists those links under
342
+ `changes.deleted.relations`; a link the same write also states may be reported
343
+ under `relationship_outcomes` as well, or instead. A record whose last link of a
344
+ relation was the deleted one is listed in `changes.orphaned_records`
345
+ (`OrphanedRecord`), so you can decide whether it still belongs. `relation` is
346
+ the relation's class name: an XMD relation `works_at` comes back as `WorksAt`:
347
+
348
+ ```typescript
349
+ const result = await inst.write("Remove the Harbour Wall project.");
350
+ for (const r of result.changes.orphaned_records ?? []) {
351
+ console.log(r.object_type_name, r.folded ? `${r.count} more` : r.identity, "has no", r.relation, "link left");
352
+ }
353
+ ```
354
+
355
+ The key is omitted when there is no such record and by a server from before this
356
+ report, so a missing key means none reported. It means nothing at all when
357
+ `relationship_outcomes` reports the write's summary unavailable (an entry with
358
+ `status: "unavailable"`). A record the write deleted, or that still has a link
359
+ of that relation when the write completes, is not listed. Past 100 entries of
360
+ one type and relation, the rest arrive as one entry marked `folded: true`, with
361
+ an empty `identity` and their `count`. `deleted.relations` folds a delete's
362
+ links past 100 of one relation into one entry with that relation's `name`, empty
363
+ `endpoints` and `fields`, `folded: true` and their `count`.
364
+
337
365
  ### `inst.read(query, options?)` → `ReadResult`
338
366
 
339
367
  Query the instance.
@@ -10,7 +10,7 @@ export { AgentSurface, BindingTier, FragmentMerge, SetupFormat, StepKind } from
10
10
  export type { AgentSetupResult, AgentSetupStep, AgentSetupSurface, AgentSurfaceValue, FragmentMergeValue, ProjectFragment, ProjectSetup, SetupFormatValue, StepKindValue, BindingTierValue, SchemaTypeValue, ExtractionLogic, ReadMode, RelatedTypesMode, RelationCardinality, WriteQueueStatus, FieldType, OnDelete, CastStrategy, DecisionKind, MigrationSource, } from "./types.js";
11
11
  export type { ScopeObject, ReadScope, WriteScope, RelationsScope, WriteScopeMode } from "./types.js";
12
12
  export type { XmemoryClientOptions, RequestOptions, ReadOptions, WriteOptions, ExtractOptions, CreateInstanceOptions, GenerateSchemaOptions, UpdateInstanceMetadataOptions, PatchInstanceMetadataOptions, UpdateInstanceSchemaOptions, DryRunMigrationOptions, ListMigrationsOptions, GetMigrationOptions, SuggestionRequestOptions, } from "./types.js";
13
- export type { ClusterInfo, InstanceInfo, InstanceSchemaInfo, ReadResult, TaggedReaderResult, RelatedTypes, RelatedTypesTouched, RelatedTypesLink, RelatedTypesObjectType, RelatedTypesRelation, WriteResult, WriteChanges, SkippedOutOfScope, FieldMergeContradiction, AsyncWriteResult, WriteStatusResult, ExtractResult, GenerateSchemaResult, ToolDescription, ToolParameterDescription, RawDescribeResult, } from "./types.js";
13
+ export type { ClusterInfo, InstanceInfo, InstanceSchemaInfo, ReadResult, TaggedReaderResult, RelatedTypes, RelatedTypesTouched, RelatedTypesLink, RelatedTypesObjectType, RelatedTypesRelation, WriteResult, WriteChanges, SkippedOutOfScope, FieldMergeContradiction, OrphanedRecord, AsyncWriteResult, WriteStatusResult, ExtractResult, GenerateSchemaResult, ToolDescription, ToolParameterDescription, RawDescribeResult, } from "./types.js";
14
14
  export type { WriteMutation, ObjectMutationBody, ObjectCreatePayload, ObjectUpdatePayload, ObjectDeletePayload, RelationMutationBody, RelationCreatePayload, RelationUpdatePayload, RelationDeletePayload, RelationEndpoint, } from "./types.js";
15
15
  export type { MigrationPlan, MigrationOp, FieldSpec, AddObject, RemoveObject, RenameObject, ChangeObject, AddField, RemoveField, RenameField, ChangeField, AddRelation, RemoveRelation, RenameRelation, ChangeRelation, DefaultValue, EnumValues, } from "./types.js";
16
16
  export type { EnhanceSchemaResult, PlanSummary, DryRunResult, MigrationRecord, ListMigrationsResult, GetMigrationResult, ConsolidatedProposal, ProposalItem, ReviewSuggestionsResult, DecisionInput, RecordedDecision, DependencyWarning, DecideSuggestionsResult, ApplyPendingDecisionsResult, } from "./types.js";
@@ -488,20 +488,64 @@ export interface FieldMergeContradiction {
488
488
  */
489
489
  readonly kept: "stored" | "new" | (string & {});
490
490
  }
491
+ /**
492
+ * A stored record a delete in the write left with no link of a relation it had
493
+ * one of: the deleted record was its last link of that relation.
494
+ *
495
+ * Deleting a record never deletes the records linked to it. Its links are
496
+ * removed or cleared, as the relation's `on_delete` says, and listed under
497
+ * `deleted.relations`; a link the same write also states may be reported under
498
+ * `relationship_outcomes` as well, or instead. A record left without any link
499
+ * of a relation is listed here, so the caller can decide whether it still
500
+ * belongs.
501
+ */
502
+ export interface OrphanedRecord {
503
+ /** The object type of the record left without a link. */
504
+ readonly object_type_name: string;
505
+ /**
506
+ * The record as the write's other entries name it: by the write's own
507
+ * identifier when the write names it, otherwise by its primary key, rendered
508
+ * `field='value'` (a composite key's parts comma-separated). Empty for a type
509
+ * without a key, for a key missing a part, and on a folded entry.
510
+ */
511
+ readonly identity: string;
512
+ /**
513
+ * The relation the record no longer has a link of, by its class name: an XMD
514
+ * relation `works_at` comes back as `WorksAt`.
515
+ */
516
+ readonly relation: string;
517
+ /** On a folded entry, how many records it stands for. */
518
+ readonly count?: number;
519
+ /**
520
+ * `true` on an entry that stands for the records past the first 100 of one
521
+ * type and relation, with an empty `identity` and their `count`.
522
+ */
523
+ readonly folded?: boolean;
524
+ }
491
525
  /**
492
526
  * What a write did, grouped into `created` / `updated` / `deleted`, plus what a
493
- * `"drop"`-mode scope left out and the contradictions a field merge resolved.
527
+ * `"drop"`-mode scope left out, the contradictions a field merge resolved and
528
+ * the records a delete left without a link.
494
529
  *
495
530
  * The three groups stay `unknown`: their shape is the server's to evolve and
496
531
  * this client has never modelled it. `skipped_out_of_scope` is typed because it
497
532
  * is the one part a caller has to branch on — a `"drop"`-mode write succeeds
498
533
  * whether or not it skipped anything, so this list is the only report that some
499
534
  * of what the text said was not applied. `merge_contradictions` is typed because
500
- * it is the only report of what a merge chose between.
535
+ * it is the only report of what a merge chose between, and `orphaned_records`
536
+ * because it is the only report of a record a delete left without a link.
501
537
  */
502
538
  export interface WriteChanges {
503
539
  readonly created: unknown;
504
540
  readonly updated: unknown;
541
+ /**
542
+ * What the write deleted, as `{ objects, relations }`. A record delete's
543
+ * links, removed or cleared as the relation's `on_delete` says, are listed
544
+ * under `relations`; a link the same write also states may be reported
545
+ * under `relationship_outcomes` as well, or instead. Past 100 links of one
546
+ * relation, the rest arrive as one entry with that relation's `name`, empty
547
+ * `endpoints` and `fields`, `folded: true` and their `count`.
548
+ */
505
549
  readonly deleted: unknown;
506
550
  /**
507
551
  * Omitted by the server when nothing was skipped — which is every write that
@@ -520,6 +564,18 @@ export interface WriteChanges {
520
564
  * appended, or left the stored text unchanged reports none.
521
565
  */
522
566
  readonly merge_contradictions?: readonly FieldMergeContradiction[];
567
+ /**
568
+ * The stored records a delete in this write left with no link of a relation
569
+ * they had one of. Advisory: delete or relink such a record if it no longer
570
+ * belongs. A record the write deleted, or that still has a link of that
571
+ * relation when the write completes, is not listed. Omitted by the server
572
+ * when there is none, and by a server that predates the report, so
573
+ * `undefined` and `[]` both mean "none reported" — and nothing at all when
574
+ * `relationship_outcomes` reports the write's summary unavailable (an entry
575
+ * with `status: "unavailable"`). Past 100 entries of one type and relation,
576
+ * the rest arrive folded into one entry (see {@link OrphanedRecord.folded}).
577
+ */
578
+ readonly orphaned_records?: readonly OrphanedRecord[];
523
579
  }
524
580
  export interface WriteResult {
525
581
  readonly write_id: string;
@@ -528,8 +584,9 @@ export interface WriteResult {
528
584
  readonly console_url: string | null;
529
585
  /**
530
586
  * What the write did, grouped into `created` / `updated` / `deleted`; for a
531
- * scoped write in `"drop"` mode, what it skipped instead of applying; and
532
- * what a field merge chose between (`merge_contradictions`).
587
+ * scoped write in `"drop"` mode, what it skipped instead of applying; what a
588
+ * field merge chose between (`merge_contradictions`); and the records a delete
589
+ * left without a link (`orphaned_records`).
533
590
  */
534
591
  readonly changes: WriteChanges;
535
592
  }
@@ -551,8 +608,8 @@ export interface WriteStatusResult {
551
608
  * What the finished write did, in the same shape {@link WriteResult.changes}
552
609
  * carries — and the async caller's only view of it, since `writeAsync`
553
610
  * returns before the write has done anything. It is therefore where a
554
- * `"drop"`-mode scope reports what it skipped, and a field merge what it chose
555
- * between.
611
+ * `"drop"`-mode scope reports what it skipped, a field merge what it chose
612
+ * between, and a delete the records it left without a link.
556
613
  *
557
614
  * Optional because a status is not always about a finished write: a queued,
558
615
  * in-progress, failed or unknown `write_id` carries none. Read it once
@@ -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.20.0";
2
+ export declare const VERSION = "3.21.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.20.0";
5
+ exports.VERSION = "3.21.0";
@@ -10,7 +10,7 @@ export { AgentSurface, BindingTier, FragmentMerge, SetupFormat, StepKind } from
10
10
  export type { AgentSetupResult, AgentSetupStep, AgentSetupSurface, AgentSurfaceValue, FragmentMergeValue, ProjectFragment, ProjectSetup, SetupFormatValue, StepKindValue, BindingTierValue, SchemaTypeValue, ExtractionLogic, ReadMode, RelatedTypesMode, RelationCardinality, WriteQueueStatus, FieldType, OnDelete, CastStrategy, DecisionKind, MigrationSource, } from "./types.js";
11
11
  export type { ScopeObject, ReadScope, WriteScope, RelationsScope, WriteScopeMode } from "./types.js";
12
12
  export type { XmemoryClientOptions, RequestOptions, ReadOptions, WriteOptions, ExtractOptions, CreateInstanceOptions, GenerateSchemaOptions, UpdateInstanceMetadataOptions, PatchInstanceMetadataOptions, UpdateInstanceSchemaOptions, DryRunMigrationOptions, ListMigrationsOptions, GetMigrationOptions, SuggestionRequestOptions, } from "./types.js";
13
- export type { ClusterInfo, InstanceInfo, InstanceSchemaInfo, ReadResult, TaggedReaderResult, RelatedTypes, RelatedTypesTouched, RelatedTypesLink, RelatedTypesObjectType, RelatedTypesRelation, WriteResult, WriteChanges, SkippedOutOfScope, FieldMergeContradiction, AsyncWriteResult, WriteStatusResult, ExtractResult, GenerateSchemaResult, ToolDescription, ToolParameterDescription, RawDescribeResult, } from "./types.js";
13
+ export type { ClusterInfo, InstanceInfo, InstanceSchemaInfo, ReadResult, TaggedReaderResult, RelatedTypes, RelatedTypesTouched, RelatedTypesLink, RelatedTypesObjectType, RelatedTypesRelation, WriteResult, WriteChanges, SkippedOutOfScope, FieldMergeContradiction, OrphanedRecord, AsyncWriteResult, WriteStatusResult, ExtractResult, GenerateSchemaResult, ToolDescription, ToolParameterDescription, RawDescribeResult, } from "./types.js";
14
14
  export type { WriteMutation, ObjectMutationBody, ObjectCreatePayload, ObjectUpdatePayload, ObjectDeletePayload, RelationMutationBody, RelationCreatePayload, RelationUpdatePayload, RelationDeletePayload, RelationEndpoint, } from "./types.js";
15
15
  export type { MigrationPlan, MigrationOp, FieldSpec, AddObject, RemoveObject, RenameObject, ChangeObject, AddField, RemoveField, RenameField, ChangeField, AddRelation, RemoveRelation, RenameRelation, ChangeRelation, DefaultValue, EnumValues, } from "./types.js";
16
16
  export type { EnhanceSchemaResult, PlanSummary, DryRunResult, MigrationRecord, ListMigrationsResult, GetMigrationResult, ConsolidatedProposal, ProposalItem, ReviewSuggestionsResult, DecisionInput, RecordedDecision, DependencyWarning, DecideSuggestionsResult, ApplyPendingDecisionsResult, } from "./types.js";
@@ -488,20 +488,64 @@ export interface FieldMergeContradiction {
488
488
  */
489
489
  readonly kept: "stored" | "new" | (string & {});
490
490
  }
491
+ /**
492
+ * A stored record a delete in the write left with no link of a relation it had
493
+ * one of: the deleted record was its last link of that relation.
494
+ *
495
+ * Deleting a record never deletes the records linked to it. Its links are
496
+ * removed or cleared, as the relation's `on_delete` says, and listed under
497
+ * `deleted.relations`; a link the same write also states may be reported under
498
+ * `relationship_outcomes` as well, or instead. A record left without any link
499
+ * of a relation is listed here, so the caller can decide whether it still
500
+ * belongs.
501
+ */
502
+ export interface OrphanedRecord {
503
+ /** The object type of the record left without a link. */
504
+ readonly object_type_name: string;
505
+ /**
506
+ * The record as the write's other entries name it: by the write's own
507
+ * identifier when the write names it, otherwise by its primary key, rendered
508
+ * `field='value'` (a composite key's parts comma-separated). Empty for a type
509
+ * without a key, for a key missing a part, and on a folded entry.
510
+ */
511
+ readonly identity: string;
512
+ /**
513
+ * The relation the record no longer has a link of, by its class name: an XMD
514
+ * relation `works_at` comes back as `WorksAt`.
515
+ */
516
+ readonly relation: string;
517
+ /** On a folded entry, how many records it stands for. */
518
+ readonly count?: number;
519
+ /**
520
+ * `true` on an entry that stands for the records past the first 100 of one
521
+ * type and relation, with an empty `identity` and their `count`.
522
+ */
523
+ readonly folded?: boolean;
524
+ }
491
525
  /**
492
526
  * What a write did, grouped into `created` / `updated` / `deleted`, plus what a
493
- * `"drop"`-mode scope left out and the contradictions a field merge resolved.
527
+ * `"drop"`-mode scope left out, the contradictions a field merge resolved and
528
+ * the records a delete left without a link.
494
529
  *
495
530
  * The three groups stay `unknown`: their shape is the server's to evolve and
496
531
  * this client has never modelled it. `skipped_out_of_scope` is typed because it
497
532
  * is the one part a caller has to branch on — a `"drop"`-mode write succeeds
498
533
  * whether or not it skipped anything, so this list is the only report that some
499
534
  * of what the text said was not applied. `merge_contradictions` is typed because
500
- * it is the only report of what a merge chose between.
535
+ * it is the only report of what a merge chose between, and `orphaned_records`
536
+ * because it is the only report of a record a delete left without a link.
501
537
  */
502
538
  export interface WriteChanges {
503
539
  readonly created: unknown;
504
540
  readonly updated: unknown;
541
+ /**
542
+ * What the write deleted, as `{ objects, relations }`. A record delete's
543
+ * links, removed or cleared as the relation's `on_delete` says, are listed
544
+ * under `relations`; a link the same write also states may be reported
545
+ * under `relationship_outcomes` as well, or instead. Past 100 links of one
546
+ * relation, the rest arrive as one entry with that relation's `name`, empty
547
+ * `endpoints` and `fields`, `folded: true` and their `count`.
548
+ */
505
549
  readonly deleted: unknown;
506
550
  /**
507
551
  * Omitted by the server when nothing was skipped — which is every write that
@@ -520,6 +564,18 @@ export interface WriteChanges {
520
564
  * appended, or left the stored text unchanged reports none.
521
565
  */
522
566
  readonly merge_contradictions?: readonly FieldMergeContradiction[];
567
+ /**
568
+ * The stored records a delete in this write left with no link of a relation
569
+ * they had one of. Advisory: delete or relink such a record if it no longer
570
+ * belongs. A record the write deleted, or that still has a link of that
571
+ * relation when the write completes, is not listed. Omitted by the server
572
+ * when there is none, and by a server that predates the report, so
573
+ * `undefined` and `[]` both mean "none reported" — and nothing at all when
574
+ * `relationship_outcomes` reports the write's summary unavailable (an entry
575
+ * with `status: "unavailable"`). Past 100 entries of one type and relation,
576
+ * the rest arrive folded into one entry (see {@link OrphanedRecord.folded}).
577
+ */
578
+ readonly orphaned_records?: readonly OrphanedRecord[];
523
579
  }
524
580
  export interface WriteResult {
525
581
  readonly write_id: string;
@@ -528,8 +584,9 @@ export interface WriteResult {
528
584
  readonly console_url: string | null;
529
585
  /**
530
586
  * What the write did, grouped into `created` / `updated` / `deleted`; for a
531
- * scoped write in `"drop"` mode, what it skipped instead of applying; and
532
- * what a field merge chose between (`merge_contradictions`).
587
+ * scoped write in `"drop"` mode, what it skipped instead of applying; what a
588
+ * field merge chose between (`merge_contradictions`); and the records a delete
589
+ * left without a link (`orphaned_records`).
533
590
  */
534
591
  readonly changes: WriteChanges;
535
592
  }
@@ -551,8 +608,8 @@ export interface WriteStatusResult {
551
608
  * What the finished write did, in the same shape {@link WriteResult.changes}
552
609
  * carries — and the async caller's only view of it, since `writeAsync`
553
610
  * returns before the write has done anything. It is therefore where a
554
- * `"drop"`-mode scope reports what it skipped, and a field merge what it chose
555
- * between.
611
+ * `"drop"`-mode scope reports what it skipped, a field merge what it chose
612
+ * between, and a delete the records it left without a link.
556
613
  *
557
614
  * Optional because a status is not always about a finished write: a queued,
558
615
  * in-progress, failed or unknown `write_id` carries none. Read it once
@@ -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.20.0";
2
+ export declare const VERSION = "3.21.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.20.0";
2
+ export const VERSION = "3.21.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmemory",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "xmemory",
5
5
  "keywords": [
6
6
  "xmemory"
@@ -40,8 +40,8 @@
40
40
  "build:clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
41
41
  "build:esm": "tsc -p tsconfig.esm.json && node -e \"require('fs').writeFileSync('dist/esm/package.json','{\\\"type\\\":\\\"module\\\"}')\"",
42
42
  "build:cjs": "tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json','{\\\"type\\\":\\\"commonjs\\\"}')\"",
43
- "test": "tsc --noEmit && node --import tsx test.ts",
44
- "test:types": "tsc --noEmit",
43
+ "test": "tsc --noEmit && tsc -p tsconfig.test.json && node --import tsx test.ts",
44
+ "test:types": "tsc --noEmit && tsc -p tsconfig.test.json",
45
45
  "prepublishOnly": "npm run build"
46
46
  },
47
47
  "devDependencies": {