@coasys/ad4m 0.13.0-test-4 → 0.13.0-test-5

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.
@@ -18,6 +18,7 @@ import { RuntimeClient } from './runtime/RuntimeClient';
18
18
  import { ExpressionClient } from './expression/ExpressionClient';
19
19
  import { AIClient } from './ai/AIClient';
20
20
  import { ApiClient } from './apiClient';
21
+ import { Ad4mModel } from './model/Ad4mModel';
21
22
  /**
22
23
  * Client for the Ad4m interface wrapping WebSocket RPC calls
23
24
  * for convenient use in user facing code.
@@ -52,6 +53,15 @@ export class Ad4mClient {
52
53
  __classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setNeighbourhoodClient(__classPrivateFieldGet(this, _Ad4mClient_neighbourhoodClient, "f"));
53
54
  __classPrivateFieldGet(this, _Ad4mClient_perspectiveClient, "f").setAIClient(__classPrivateFieldGet(this, _Ad4mClient_aiClient, "f"));
54
55
  __classPrivateFieldSet(this, _Ad4mClient_runtimeClient, new RuntimeClient(baseUrl, token, subscribe, __classPrivateFieldGet(this, _Ad4mClient_apiClient, "f")), "f");
56
+ // Register with AD4M DevTools if the bridge is installed (e.g. browser extension)
57
+ try {
58
+ const dt = globalThis.__AD4M_DEVTOOLS__;
59
+ if (dt) {
60
+ dt._client = this;
61
+ dt._Ad4mModel = Ad4mModel;
62
+ }
63
+ }
64
+ catch { }
55
65
  }
56
66
  get agent() {
57
67
  return __classPrivateFieldGet(this, _Ad4mClient_agentClient, "f");
@@ -474,10 +474,10 @@ export declare class Ad4mModel {
474
474
  /**
475
475
  * Evaluate SPARQL getters for a batch of instances on demand.
476
476
  *
477
- * Use after a shallow collection query (the default) to resolve
478
- * getter-backed properties for visible items only. This avoids the
479
- * O(N × getters) cost of evaluating every getter on every instance in
480
- * a large collection query.
477
+ * Since deepQuery defaults to true, property getters are evaluated
478
+ * automatically during collection queries. Use this method when
479
+ * deepQuery was explicitly set to false and you want to lazily
480
+ * resolve getter-backed properties for a subset of instances.
481
481
  *
482
482
  * @param instances - Array of model instances to evaluate getters on
483
483
  * @param perspective - The perspective to query against
@@ -486,8 +486,8 @@ export declare class Ad4mModel {
486
486
  *
487
487
  * @example
488
488
  * ```typescript
489
- * const messages = await Message.findAll(perspective, { parent: channel, limit: 30 });
490
- * // messages[i].replyingTo is undefined (getter skipped by default)
489
+ * const messages = await Message.query(perspective).deepQuery(false).limit(30).get();
490
+ * // messages[i].replyingTo is undefined (getter skipped)
491
491
  *
492
492
  * // Evaluate getters for the visible subset
493
493
  * await Message.evaluateGetters(messages.slice(0, 10), perspective, ['replyingTo']);
@@ -766,5 +766,18 @@ export declare class Ad4mModel {
766
766
  * @param name - Class name to assign (e.g. "Channel")
767
767
  * @returns Generated Ad4mModel subclass, ready for querying
768
768
  */
769
- static fromSHACL(shape: SHACLShape, name: string): typeof Ad4mModel;
769
+ /**
770
+ * Synthesise an `Ad4mModel` subclass from a SHACL shape.
771
+ *
772
+ * @param shape - The SHACL shape to synthesise from.
773
+ * @param name - The model name (e.g. "Channel").
774
+ * @param classResolver - Optional thunk factory. When provided, any collection
775
+ * property that carries a `sh:class` URI will have its `target` wired up lazily:
776
+ * `target: () => classResolver(localName)`. Because `target` is only called at
777
+ * query time (inside `enrichShapeForIncludes` / `jsonToModelInstance`), the
778
+ * resolver just needs to return the correct class by the time a query runs —
779
+ * making it safe to pass a closure over a registry object that is still being
780
+ * populated (e.g. the `result` record inside `getModelClasses`).
781
+ */
782
+ static fromSHACL(shape: SHACLShape, name: string, classResolver?: (localName: string) => typeof Ad4mModel | undefined): typeof Ad4mModel;
770
783
  }
@@ -8,7 +8,7 @@ import { resolveParentPredicate } from "./query-common";
8
8
  import { isArrayType, determinePredicate, determineNamespace, buildModelFromJSONSchema } from "./json-schema";
9
9
  import { buildSPARQLQuery } from "./query-sparql";
10
10
  import { ModelQueryBuilder } from "./ModelQueryBuilder";
11
- import { normalizeValue, evaluateCustomGettersForInstance, } from "./hydration";
11
+ import { normalizeValue, } from "./hydration";
12
12
  // ---------------------------------------------------------------------------
13
13
  // Helpers for Rust-side include resolution
14
14
  // ---------------------------------------------------------------------------
@@ -647,6 +647,7 @@ export class Ad4mModel {
647
647
  const query = {
648
648
  where: { id: this._baseExpression },
649
649
  limit: 1,
650
+ deepQuery: true, // Single-instance get() always evaluates property getters
650
651
  };
651
652
  if (opts?.properties)
652
653
  query.properties = opts.properties;
@@ -755,6 +756,7 @@ export class Ad4mModel {
755
756
  queryInput.limit = query.limit;
756
757
  if (query.count !== undefined)
757
758
  queryInput.count = query.count;
759
+ queryInput.deepQuery = query.deepQuery ?? true;
758
760
  if (query.include) {
759
761
  const allRelMeta = getRelationsMetadata(this);
760
762
  enrichShapeForIncludes(metadata, query.include, allRelMeta);
@@ -772,10 +774,10 @@ export class Ad4mModel {
772
774
  try {
773
775
  const TargetClass = meta.target();
774
776
  const filter = buildConformanceFilter(meta.predicate, TargetClass);
775
- // Only compile where clauses to SPARQL when the target properties
776
- // are stored as plain IRIs (not signed expressions). Properties
777
- // without resolveLanguage or with resolveLanguage='literal' store
778
- // values as signed JSON envelopes, so SPARQL exact-match fails.
777
+ // Compile where clauses to SPARQL when all target properties use
778
+ // literal encoding (literal:string:X etc.) which is SPARQL-matchable.
779
+ // Properties with a non-literal resolveLanguage store expression hashes
780
+ // that can't be matched by value in SPARQL.
779
781
  let whereConditions = [];
780
782
  if (rel.where) {
781
783
  try {
@@ -786,15 +788,12 @@ export class Ad4mModel {
786
788
  if (['id', 'author', 'timestamp'].includes(propName))
787
789
  continue;
788
790
  const propMeta = targetMetadata.properties[propName];
789
- if (propMeta && (!propMeta.resolveLanguage || propMeta.resolveLanguage === 'literal')) {
791
+ if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal') {
790
792
  allSparqlFilterable = false;
791
793
  break;
792
794
  }
793
795
  }
794
796
  }
795
- else {
796
- allSparqlFilterable = false;
797
- }
798
797
  if (allSparqlFilterable) {
799
798
  whereConditions = compileWhereClause(rel.where, targetMetadata);
800
799
  }
@@ -914,6 +913,7 @@ export class Ad4mModel {
914
913
  queryInput.limit = query.limit;
915
914
  if (query.count !== undefined)
916
915
  queryInput.count = query.count;
916
+ queryInput.deepQuery = query.deepQuery ?? true;
917
917
  // Enrich relation metadata with target class shapes for Rust-side
918
918
  // include resolution. This eliminates per-relation GraphQL round-trips
919
919
  // by letting the Rust endpoint resolve includes in-process.
@@ -943,10 +943,10 @@ export class Ad4mModel {
943
943
  try {
944
944
  const TargetClass = meta.target();
945
945
  const filter = buildConformanceFilter(meta.predicate, TargetClass);
946
- // Only compile where clauses to SPARQL when the target properties
947
- // are stored as plain IRIs (not signed expressions). Properties
948
- // without resolveLanguage or with resolveLanguage='literal' store
949
- // values as signed JSON envelopes, so SPARQL exact-match fails.
946
+ // Compile where clauses to SPARQL when all target properties use
947
+ // literal encoding (literal:string:X etc.) which is SPARQL-matchable.
948
+ // Properties with a non-literal resolveLanguage store expression hashes
949
+ // that can't be matched by value in SPARQL.
950
950
  let whereConditions = [];
951
951
  if (rel.where) {
952
952
  try {
@@ -957,15 +957,12 @@ export class Ad4mModel {
957
957
  if (['id', 'author', 'timestamp'].includes(propName))
958
958
  continue;
959
959
  const propMeta = targetMetadata.properties[propName];
960
- if (propMeta && (!propMeta.resolveLanguage || propMeta.resolveLanguage === 'literal')) {
960
+ if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal') {
961
961
  allSparqlFilterable = false;
962
962
  break;
963
963
  }
964
964
  }
965
965
  }
966
- else {
967
- allSparqlFilterable = false;
968
- }
969
966
  if (allSparqlFilterable) {
970
967
  whereConditions = compileWhereClause(rel.where, targetMetadata);
971
968
  }
@@ -996,6 +993,13 @@ export class Ad4mModel {
996
993
  // the TS decorators are the definitive source of truth.
997
994
  const shapeJson = JSON.stringify(metadata);
998
995
  const queryJson = JSON.stringify(queryInput);
996
+ // TEMP DEBUG: Log getters with where-clause filters to diagnose CI failure
997
+ for (const [relName, relMeta] of Object.entries(metadata.relations)) {
998
+ const rel = relMeta;
999
+ if (rel.where) {
1000
+ console.log(`[MODEL_QUERY_DEBUG] relation="${relName}" getter=${rel.getter ?? 'NONE'} where=${JSON.stringify(rel.where)}`);
1001
+ }
1002
+ }
999
1003
  const result = await perspective.modelQuery(className, queryJson, shapeJson);
1000
1004
  // Convert JSON instances to model class instances, recursively constructing
1001
1005
  // class instances for any included relations resolved by Rust.
@@ -1032,40 +1036,6 @@ export class Ad4mModel {
1032
1036
  }
1033
1037
  }));
1034
1038
  }
1035
- // Relation conformance getters are evaluated Rust-side via evaluate_getters()
1036
- // in model_query.rs. However, for relations with non-SPARQL-filterable where
1037
- // clauses (e.g. properties stored as signed expressions), we still need
1038
- // TS-side evaluation as a fallback. Running evaluateCustomGettersForInstance
1039
- // with skipPropertyGetters ensures conformance + JS post-filtering for
1040
- // where clauses that couldn't be compiled to SPARQL.
1041
- const includedRelNames = queryInput.include ? new Set(Object.keys(queryInput.include)) : new Set();
1042
- for (const inst of instances) {
1043
- // Save included relation values that came from Rust hydration
1044
- const savedIncluded = {};
1045
- for (const relName of includedRelNames) {
1046
- if (inst[relName] !== undefined) {
1047
- savedIncluded[relName] = inst[relName];
1048
- }
1049
- }
1050
- await evaluateCustomGettersForInstance(inst, perspective, metadata, {
1051
- skipPropertyGetters: true,
1052
- });
1053
- // Restore hydrated include objects that were overwritten by conformance getters
1054
- for (const [relName, value] of Object.entries(savedIncluded)) {
1055
- inst[relName] = value;
1056
- }
1057
- // Fix cardinality for non-included HasOne/BelongsToOne relations:
1058
- // The conformance getter always produces arrays; unwrap to scalar.
1059
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
1060
- if (includedRelNames.has(relName))
1061
- continue;
1062
- const kind = relMeta.kind;
1063
- if ((kind === 'hasOne' || kind === 'belongsToOne') && Array.isArray(inst[relName])) {
1064
- const arr = inst[relName];
1065
- inst[relName] = arr.length > 0 ? arr[0] : null;
1066
- }
1067
- }
1068
- }
1069
1039
  // Take snapshots for dirty tracking
1070
1040
  const snapshotRelations = queryInput.include;
1071
1041
  for (const inst of instances) {
@@ -1493,10 +1463,10 @@ export class Ad4mModel {
1493
1463
  /**
1494
1464
  * Evaluate SPARQL getters for a batch of instances on demand.
1495
1465
  *
1496
- * Use after a shallow collection query (the default) to resolve
1497
- * getter-backed properties for visible items only. This avoids the
1498
- * O(N × getters) cost of evaluating every getter on every instance in
1499
- * a large collection query.
1466
+ * Since deepQuery defaults to true, property getters are evaluated
1467
+ * automatically during collection queries. Use this method when
1468
+ * deepQuery was explicitly set to false and you want to lazily
1469
+ * resolve getter-backed properties for a subset of instances.
1500
1470
  *
1501
1471
  * @param instances - Array of model instances to evaluate getters on
1502
1472
  * @param perspective - The perspective to query against
@@ -1505,8 +1475,8 @@ export class Ad4mModel {
1505
1475
  *
1506
1476
  * @example
1507
1477
  * ```typescript
1508
- * const messages = await Message.findAll(perspective, { parent: channel, limit: 30 });
1509
- * // messages[i].replyingTo is undefined (getter skipped by default)
1478
+ * const messages = await Message.query(perspective).deepQuery(false).limit(30).get();
1479
+ * // messages[i].replyingTo is undefined (getter skipped)
1510
1480
  *
1511
1481
  * // Evaluate getters for the visible subset
1512
1482
  * await Message.evaluateGetters(messages.slice(0, 10), perspective, ['replyingTo']);
@@ -1517,10 +1487,28 @@ export class Ad4mModel {
1517
1487
  if (instances.length === 0)
1518
1488
  return;
1519
1489
  const metadata = this.getModelMetadata();
1520
- const opts = propertyNames && propertyNames.length > 0
1521
- ? { requestedProperties: propertyNames }
1522
- : undefined;
1523
- // Determine which property names will actually be evaluated
1490
+ // Pre-compute conformance getters so the shape sent to Rust includes them
1491
+ const allRelMeta = getRelationsMetadata(this);
1492
+ for (const [relName, relMeta] of Object.entries(metadata.relations)) {
1493
+ const rel = relMeta;
1494
+ if (rel.getter || rel.direction === 'reverse' || rel.filter === false)
1495
+ continue;
1496
+ const meta = allRelMeta[relName];
1497
+ if (!meta?.target)
1498
+ continue;
1499
+ try {
1500
+ const TargetClass = meta.target();
1501
+ const filter = buildConformanceFilter(meta.predicate, TargetClass);
1502
+ if (filter)
1503
+ rel.getter = filter.getter;
1504
+ }
1505
+ catch (_) { /* target class may not be available */ }
1506
+ }
1507
+ const shapeJson = JSON.stringify(metadata);
1508
+ const instanceIds = instances.map(inst => inst.id || inst._baseExpression);
1509
+ // Single RPC call evaluates all getters in-process on the executor
1510
+ const result = await perspective.evaluateGetters(metadata.className, instanceIds, shapeJson, propertyNames);
1511
+ // Determine which property names were evaluated for snapshot sync
1524
1512
  const evaluatedPropertyNames = [];
1525
1513
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
1526
1514
  if (propMeta.getter) {
@@ -1529,13 +1517,24 @@ export class Ad4mModel {
1529
1517
  }
1530
1518
  }
1531
1519
  }
1520
+ // Also include relation getters
1521
+ for (const [relName, relMeta] of Object.entries(metadata.relations)) {
1522
+ if (relMeta.getter) {
1523
+ if (!propertyNames || propertyNames.length === 0 || propertyNames.includes(relName)) {
1524
+ evaluatedPropertyNames.push(relName);
1525
+ }
1526
+ }
1527
+ }
1528
+ // Apply results to instances and sync snapshots
1532
1529
  for (const instance of instances) {
1533
- await evaluateCustomGettersForInstance(instance, perspective, metadata, opts);
1534
- // Sync snapshot so isDirty() doesn't flag getter-only changes.
1535
- // evaluateGetters() mutates instances in place, but their snapshots
1536
- // were already taken during hydration. Without this sync, the computed
1537
- // getter values would make isDirty() return true and save() would try
1538
- // to write read-only computed properties.
1530
+ const id = instance.id || instance._baseExpression;
1531
+ const props = result[id];
1532
+ if (props) {
1533
+ for (const [key, value] of Object.entries(props)) {
1534
+ instance[key] = value;
1535
+ }
1536
+ }
1537
+ // Sync snapshot so isDirty() doesn't flag getter-only changes
1539
1538
  const modelInstance = instance;
1540
1539
  if (modelInstance._snapshot) {
1541
1540
  for (const propName of evaluatedPropertyNames) {
@@ -1936,7 +1935,20 @@ export class Ad4mModel {
1936
1935
  * @param name - Class name to assign (e.g. "Channel")
1937
1936
  * @returns Generated Ad4mModel subclass, ready for querying
1938
1937
  */
1939
- static fromSHACL(shape, name) {
1938
+ /**
1939
+ * Synthesise an `Ad4mModel` subclass from a SHACL shape.
1940
+ *
1941
+ * @param shape - The SHACL shape to synthesise from.
1942
+ * @param name - The model name (e.g. "Channel").
1943
+ * @param classResolver - Optional thunk factory. When provided, any collection
1944
+ * property that carries a `sh:class` URI will have its `target` wired up lazily:
1945
+ * `target: () => classResolver(localName)`. Because `target` is only called at
1946
+ * query time (inside `enrichShapeForIncludes` / `jsonToModelInstance`), the
1947
+ * resolver just needs to return the correct class by the time a query runs —
1948
+ * making it safe to pass a closure over a registry object that is still being
1949
+ * populated (e.g. the `result` record inside `getModelClasses`).
1950
+ */
1951
+ static fromSHACL(shape, name, classResolver) {
1940
1952
  const DynamicModelClass = class extends this {
1941
1953
  };
1942
1954
  DynamicModelClass.className = name;
@@ -1975,9 +1987,19 @@ export class Ad4mModel {
1975
1987
  continue;
1976
1988
  const isCollection = prop.maxCount === undefined || prop.maxCount > 1;
1977
1989
  if (isCollection) {
1990
+ // Derive a lazy `target` thunk when a sh:class URI is present and a
1991
+ // classResolver was supplied. The thunk is evaluated at query time so
1992
+ // it is safe even if the target class hasn't been registered yet.
1993
+ let targetThunk;
1994
+ if (prop.class && classResolver) {
1995
+ const sep = Math.max(prop.class.lastIndexOf('#'), prop.class.lastIndexOf('/'));
1996
+ const localName = sep >= 0 ? prop.class.slice(sep + 1) : prop.class;
1997
+ targetThunk = () => classResolver(localName);
1998
+ }
1978
1999
  setRelationRegistryEntry(DynamicModelClass, prop.name, {
1979
2000
  predicate: prop.path,
1980
2001
  kind: 'hasMany',
2002
+ ...(targetThunk !== undefined && { target: targetThunk }),
1981
2003
  ...(prop.local !== undefined && { local: prop.local }),
1982
2004
  ...(prop.getter !== undefined && { getter: prop.getter }),
1983
2005
  });
@@ -158,24 +158,24 @@ export declare class ModelQueryBuilder<T extends Ad4mModel> {
158
158
  */
159
159
  properties(properties: string[]): ModelQueryBuilder<T>;
160
160
  /**
161
- * Opts in to evaluating SPARQL property getters during collection hydration.
161
+ * Controls whether SPARQL property getters are evaluated during hydration.
162
162
  *
163
- * By default, collection queries skip getter evaluation for performance.
164
- * Call `.deepQuery()` when you need getter-backed properties in the result set.
163
+ * By default, collection queries evaluate property getters (deepQuery=true).
164
+ * Call `.deepQuery(false)` to skip getter evaluation for performance.
165
165
  *
166
+ * @param enabled - Whether to evaluate property getters (default: true)
166
167
  * @returns The query builder for chaining
167
168
  *
168
169
  * @example
169
170
  * ```typescript
170
171
  * const messages = await Message.query(perspective)
171
172
  * .parent(channel)
172
- * .deepQuery()
173
+ * .deepQuery(false) // skip property getters for performance
173
174
  * .limit(30)
174
175
  * .get();
175
- * // messages[i].replyingTo is populated
176
176
  * ```
177
177
  */
178
- deepQuery(): ModelQueryBuilder<T>;
178
+ deepQuery(enabled?: boolean): ModelQueryBuilder<T>;
179
179
  /**
180
180
  * Specifies which relations to eager-load (hydrate into model instances).
181
181
  *
@@ -201,25 +201,25 @@ export class ModelQueryBuilder {
201
201
  return this;
202
202
  }
203
203
  /**
204
- * Opts in to evaluating SPARQL property getters during collection hydration.
204
+ * Controls whether SPARQL property getters are evaluated during hydration.
205
205
  *
206
- * By default, collection queries skip getter evaluation for performance.
207
- * Call `.deepQuery()` when you need getter-backed properties in the result set.
206
+ * By default, collection queries evaluate property getters (deepQuery=true).
207
+ * Call `.deepQuery(false)` to skip getter evaluation for performance.
208
208
  *
209
+ * @param enabled - Whether to evaluate property getters (default: true)
209
210
  * @returns The query builder for chaining
210
211
  *
211
212
  * @example
212
213
  * ```typescript
213
214
  * const messages = await Message.query(perspective)
214
215
  * .parent(channel)
215
- * .deepQuery()
216
+ * .deepQuery(false) // skip property getters for performance
216
217
  * .limit(30)
217
218
  * .get();
218
- * // messages[i].replyingTo is populated
219
219
  * ```
220
220
  */
221
- deepQuery() {
222
- this.queryParams.deepQuery = true;
221
+ deepQuery(enabled = true) {
222
+ this.queryParams.deepQuery = enabled;
223
223
  return this;
224
224
  }
225
225
  /**
@@ -381,9 +381,15 @@ export class ModelQueryBuilder {
381
381
  console.error('Model subscription update parse error:', e);
382
382
  }
383
383
  });
384
- // Set up keepalive
384
+ // Set up keepalive with failure tracking
385
+ let keepaliveFailures = 0;
385
386
  const keepaliveTimer = setInterval(() => {
386
- this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).catch(() => { });
387
+ this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
388
+ keepaliveFailures = 0;
389
+ }).catch((e) => {
390
+ keepaliveFailures++;
391
+ console.warn(`Model subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
392
+ });
387
393
  }, 30000);
388
394
  // Store dispose function
389
395
  this.currentSubscription = {
@@ -478,8 +484,14 @@ export class ModelQueryBuilder {
478
484
  console.error('Count subscription update parse error:', e);
479
485
  }
480
486
  });
487
+ let keepaliveFailures = 0;
481
488
  const keepaliveTimer = setInterval(() => {
482
- this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).catch(() => { });
489
+ this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
490
+ keepaliveFailures = 0;
491
+ }).catch((e) => {
492
+ keepaliveFailures++;
493
+ console.warn(`Count subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
494
+ });
483
495
  }, 30000);
484
496
  this.currentSubscription = {
485
497
  dispose: () => {
@@ -582,8 +594,14 @@ export class ModelQueryBuilder {
582
594
  return;
583
595
  processResults().catch(e => console.error('Paginate subscription error:', e));
584
596
  });
597
+ let keepaliveFailures = 0;
585
598
  const keepaliveTimer = setInterval(() => {
586
- this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).catch(() => { });
599
+ this.perspective.client.keepAliveQuery(this.perspective.uuid, subscriptionId).then(() => {
600
+ keepaliveFailures = 0;
601
+ }).catch((e) => {
602
+ keepaliveFailures++;
603
+ console.warn(`Paginate subscription keepalive failed (attempt ${keepaliveFailures}) for ${subscriptionId}:`, e);
604
+ });
587
605
  }, 30000);
588
606
  this.currentSubscription = {
589
607
  dispose: () => {
@@ -1,50 +1,13 @@
1
1
  /**
2
2
  * hydration.ts — Instance hydration helpers extracted from Ad4mModel.
3
3
  *
4
- * After the Rust model_query pipeline migration (Phases 1-13), most hydration
5
- * logic moved to Rust. This file retains:
4
+ * After the Rust model_query pipeline migration, most hydration logic moved
5
+ * to Rust. This file retains:
6
6
  * - normalizeValue() — snapshot dirty-tracking
7
- * - matchesCondition() — JS-side post-filter (used by evaluateCustomGettersForInstance)
8
- * - evaluateCustomGettersForInstance() — lazy getter evaluation (Ad4mModel.evaluateGetters)
9
- * - buildConformanceGetter() — conformance SPARQL generation for relation getters
10
7
  */
11
- import type { PerspectiveProxy } from "../perspectives/PerspectiveProxy";
12
- import type { ModelMetadata, WhereCondition } from "./types";
13
8
  /**
14
9
  * Normalize a value for snapshot storage.
15
10
  * Arrays of model instances are reduced to their `.id` strings so that
16
11
  * dirty-tracking compares stable identifiers instead of object references.
17
12
  */
18
13
  export declare function normalizeValue(value: any): any;
19
- /**
20
- * Checks if a value matches a where-condition (for post-query filtering).
21
- */
22
- export declare function matchesCondition(value: any, condition: WhereCondition): boolean;
23
- /**
24
- * Builds a SPARQL conformance getter for a relation whose `target` model
25
- * is known but no explicit `getter` string was supplied.
26
- *
27
- * The generated getter traverses outgoing links matching the relation's
28
- * predicate and then filters the target nodes to only those that conform to
29
- * the target model's shape (required properties / flags).
30
- *
31
- * Delegates to the shared `buildConformanceFilter()` utility in decorators.ts
32
- * so the same logic is used at shape-definition time and at query time.
33
- *
34
- * @param relationPredicate - The relation's predicate URI (e.g. "flux://entry_type")
35
- * @param targetClass - The target model class (result of calling the `target()` thunk)
36
- * @returns A SPARQL expression string, or `undefined` if no conformance
37
- * conditions could be derived from the target model.
38
- */
39
- export declare function buildConformanceGetter(relationPredicate: string, targetClass: any): string | undefined;
40
- /**
41
- * Evaluates custom SurrealQL getters for properties and relations on a specific instance.
42
- *
43
- * For relations that declare a `target` but no explicit `getter`, a conformance
44
- * getter is auto-generated from the target model's metadata (unless `filter: false`).
45
- */
46
- export declare function evaluateCustomGettersForInstance(instance: any, perspective: PerspectiveProxy, metadata: ModelMetadata, options?: {
47
- requestedProperties?: string[];
48
- include?: Record<string, any>;
49
- skipPropertyGetters?: boolean;
50
- }): Promise<void>;