@coasys/ad4m 0.11.2-dev.4 → 0.11.2-dev.6

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.
@@ -373,9 +373,9 @@ export class Ad4mModel {
373
373
  writable: options.writable || false,
374
374
  ...(options.initial !== undefined && { initial: options.initial }),
375
375
  ...(options.resolveLanguage !== undefined && { resolveLanguage: options.resolveLanguage }),
376
+ ...(options.prologGetter !== undefined && { prologGetter: options.prologGetter }),
376
377
  ...(options.getter !== undefined && { getter: options.getter }),
377
- ...(options.surrealGetter !== undefined && { surrealGetter: options.surrealGetter }),
378
- ...(options.setter !== undefined && { setter: options.setter }),
378
+ ...(options.prologSetter !== undefined && { prologSetter: options.prologSetter }),
379
379
  ...(options.local !== undefined && { local: options.local }),
380
380
  ...(options.transform !== undefined && { transform: options.transform }),
381
381
  ...(options.flag !== undefined && { flag: options.flag })
@@ -391,7 +391,7 @@ export class Ad4mModel {
391
391
  predicate: options.through || "",
392
392
  ...(options.where !== undefined && { where: options.where }),
393
393
  ...(options.local !== undefined && { local: options.local }),
394
- ...(options.surrealGetter !== undefined && { surrealGetter: options.surrealGetter })
394
+ ...(options.getter !== undefined && { getter: options.getter })
395
395
  };
396
396
  }
397
397
  // Fallback: If both structures are empty but a JSON schema is attached, derive from it
@@ -502,9 +502,9 @@ export class Ad4mModel {
502
502
  if (metadata.writable === false) {
503
503
  throw new Error(`Property "${key}" is read-only and cannot be written`);
504
504
  }
505
- if (metadata.setter) {
506
- // Custom setter - throw error for now (Phase 2)
507
- throw new Error(`Custom setter for property "${key}" not yet supported without Prolog. ` +
505
+ if (metadata.prologSetter) {
506
+ // Custom Prolog setter - throw error for now (Phase 2)
507
+ throw new Error(`Custom Prolog setter for property "${key}" not yet supported without Prolog. ` +
508
508
  `Use standard @Property decorator or enable Prolog for custom setters.`);
509
509
  }
510
510
  if (!metadata.through) {
@@ -589,8 +589,26 @@ export class Ad4mModel {
589
589
  }
590
590
  return [name, finalValue];
591
591
  })));
592
+ // Filter out properties that are read-only (getters without setters)
593
+ const writableProps = Object.fromEntries(Object.entries(propsObject).filter(([key]) => {
594
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(instance), key);
595
+ if (!descriptor) {
596
+ // No descriptor means it's a regular property on the instance, allow it
597
+ return true;
598
+ }
599
+ // Check if it's an accessor descriptor (has get/set) vs data descriptor (has value/writable)
600
+ const isAccessor = descriptor.get !== undefined || descriptor.set !== undefined;
601
+ if (isAccessor) {
602
+ // Accessor descriptor: only allow if it has a setter
603
+ return descriptor.set !== undefined;
604
+ }
605
+ else {
606
+ // Data descriptor: only allow if writable is not explicitly false
607
+ return descriptor.writable !== false;
608
+ }
609
+ }));
592
610
  // Assign properties to instance
593
- Object.assign(instance, propsObject);
611
+ Object.assign(instance, writableProps);
594
612
  }
595
613
  async getData() {
596
614
  // Builds an object with the author, timestamp, all properties, & all collections on the Ad4mModel and saves it to the instance
@@ -616,10 +634,10 @@ export class Ad4mModel {
616
634
  let maxTimestamp = null;
617
635
  let latestAuthor = null;
618
636
  let originalAuthor = null;
619
- // Process properties (skip those with surrealGetter)
637
+ // Process properties (skip those with custom getter)
620
638
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
621
- if (propMeta.surrealGetter)
622
- continue; // Handle via surrealGetter evaluation
639
+ if (propMeta.getter)
640
+ continue; // Handle via custom getter evaluation
623
641
  const matching = links.filter((l) => l.predicate === propMeta.predicate);
624
642
  if (matching.length > 0) {
625
643
  // "Latest wins" semantics: select the last element since links are ordered ASC.
@@ -671,14 +689,44 @@ export class Ad4mModel {
671
689
  this[propName] = value;
672
690
  }
673
691
  }
674
- // Process collections (skip those with surrealGetter)
692
+ // Process collections (skip those with custom getter)
675
693
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
676
- if (collMeta.surrealGetter)
677
- continue; // Handle via surrealGetter evaluation
694
+ if (collMeta.getter)
695
+ continue; // Handle via custom getter evaluation
678
696
  const matching = links.filter((l) => l.predicate === collMeta.predicate);
679
697
  // Collections preserve chronological order: links are sorted ASC by timestamp,
680
698
  // so the collection reflects the order in which items were added (oldest to newest).
681
699
  let values = matching.map((l) => l.target);
700
+ // Apply where.condition filtering if present
701
+ if (collMeta.where?.condition && values.length > 0) {
702
+ try {
703
+ // Filter values by evaluating condition for each value
704
+ const filteredValues = [];
705
+ for (const value of values) {
706
+ let condition = collMeta.where.condition
707
+ .replace(/\$perspective/g, `'${__classPrivateFieldGet(this, _Ad4mModel_perspective, "f").uuid}'`)
708
+ .replace(/\$base/g, `'${__classPrivateFieldGet(this, _Ad4mModel_baseExpression, "f")}'`)
709
+ .replace(/Target/g, `'${value.replace(/'/g, "\\'")}'`);
710
+ // If condition starts with WHERE, wrap it in array length check pattern
711
+ // Using array::len() to properly count matching links
712
+ if (condition.trim().startsWith('WHERE')) {
713
+ condition = `array::len(SELECT * FROM link ${condition}) > 0`;
714
+ }
715
+ const filterQuery = `RETURN ${condition}`;
716
+ const result = await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").querySurrealDB(filterQuery);
717
+ // RETURN can return the value directly or in an array
718
+ const isTrue = result === true || (Array.isArray(result) && result.length > 0 && result[0] === true);
719
+ if (isTrue) {
720
+ filteredValues.push(value);
721
+ }
722
+ }
723
+ values = filteredValues;
724
+ }
725
+ catch (error) {
726
+ console.warn(`Failed to apply condition filter for ${collName}:`, error);
727
+ // Keep unfiltered values on error
728
+ }
729
+ }
682
730
  // Apply where.isInstance filtering if present
683
731
  if (collMeta.where?.isInstance && values.length > 0) {
684
732
  try {
@@ -708,7 +756,26 @@ export class Ad4mModel {
708
756
  }
709
757
  }
710
758
  // Evaluate SurrealQL getters
711
- await ctor.evaluateSurrealGettersForInstance(this, __classPrivateFieldGet(this, _Ad4mModel_perspective, "f"), metadata);
759
+ await ctor.evaluateCustomGettersForInstance(this, __classPrivateFieldGet(this, _Ad4mModel_perspective, "f"), metadata);
760
+ // Apply where.isInstance filtering to getter collections
761
+ // (non-getter collections were already filtered above)
762
+ for (const [collName, collMeta] of Object.entries(metadata.collections)) {
763
+ if (collMeta.getter && collMeta.where?.isInstance && this[collName]?.length > 0) {
764
+ try {
765
+ const className = typeof collMeta.where.isInstance === 'string'
766
+ ? collMeta.where.isInstance
767
+ : collMeta.where.isInstance.name;
768
+ const filterMetadata = await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").getSubjectClassMetadataFromSDNA(className);
769
+ if (filterMetadata) {
770
+ const filtered = await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").batchCheckSubjectInstances(this[collName], filterMetadata);
771
+ this[collName] = filtered;
772
+ }
773
+ }
774
+ catch (error) {
775
+ // Keep unfiltered values on error
776
+ }
777
+ }
778
+ }
712
779
  }
713
780
  catch (e) {
714
781
  console.error(`SurrealDB getData also failed for ${__classPrivateFieldGet(this, _Ad4mModel_baseExpression, "f")}:`, e);
@@ -741,14 +808,14 @@ export class Ad4mModel {
741
808
  * Evaluates custom SurrealQL getters for properties and collections on a specific instance.
742
809
  * @private
743
810
  */
744
- static async evaluateSurrealGettersForInstance(instance, perspective, metadata) {
811
+ static async evaluateCustomGettersForInstance(instance, perspective, metadata) {
745
812
  const safeBaseExpression = this.formatSurrealValue(instance.baseExpression);
746
- // Evaluate property surrealGetters
813
+ // Evaluate property getters
747
814
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
748
- if (propMeta.surrealGetter) {
815
+ if (propMeta.getter) {
749
816
  try {
750
817
  // Replace 'Base' placeholder with actual base expression
751
- const query = propMeta.surrealGetter.replace(/Base/g, safeBaseExpression);
818
+ const query = propMeta.getter.replace(/Base/g, safeBaseExpression);
752
819
  // Query from node table to have graph traversal context
753
820
  const result = await perspective.querySurrealDB(`SELECT (${query}) AS value FROM node WHERE uri = ${safeBaseExpression}`);
754
821
  if (result && result.length > 0 && result[0].value !== undefined && result[0].value !== null && result[0].value !== 'None' && result[0].value !== '') {
@@ -756,28 +823,28 @@ export class Ad4mModel {
756
823
  }
757
824
  }
758
825
  catch (error) {
759
- console.warn(`Failed to evaluate surrealGetter for ${propName}:`, error);
826
+ console.warn(`Failed to evaluate getter for ${propName}:`, error);
760
827
  }
761
828
  }
762
829
  }
763
- // Evaluate collection surrealGetters
830
+ // Evaluate collection getters
764
831
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
765
- if (collMeta.surrealGetter) {
832
+ if (collMeta.getter) {
766
833
  try {
767
834
  // Replace 'Base' placeholder with actual base expression
768
- const query = collMeta.surrealGetter.replace(/Base/g, safeBaseExpression);
835
+ const query = collMeta.getter.replace(/Base/g, safeBaseExpression);
769
836
  // Query from node table to have graph traversal context
770
837
  const result = await perspective.querySurrealDB(`SELECT (${query}) AS value FROM node WHERE uri = ${safeBaseExpression}`);
771
838
  if (result && result.length > 0 && result[0].value !== undefined && result[0].value !== null) {
772
839
  // Filter out 'None' from collection results
773
840
  const value = result[0].value;
774
841
  instance[collName] = Array.isArray(value)
775
- ? value.filter((v) => v && v !== '' && v !== 'None')
842
+ ? value.filter((v) => v !== undefined && v !== null && v !== '' && v !== 'None')
776
843
  : value;
777
844
  }
778
845
  }
779
846
  catch (error) {
780
- console.warn(`Failed to evaluate surrealGetter for ${collName}:`, error);
847
+ console.warn(`Failed to evaluate getter for ${collName}:`, error);
781
848
  }
782
849
  }
783
850
  }
@@ -1275,7 +1342,7 @@ WHERE ${whereConditions.join(' AND ')}
1275
1342
  });
1276
1343
  }
1277
1344
  // Collect values to assign to instance
1278
- const values = [...Properties, ...Collections, ["timestamp", Timestamp], ["author", Author]];
1345
+ const values = [...Properties, ...Collections, ["createdAt", Timestamp], ["author", Author]];
1279
1346
  await Ad4mModel.assignValuesToInstance(perspective, instance, values);
1280
1347
  return instance;
1281
1348
  }
@@ -1343,11 +1410,11 @@ WHERE ${whereConditions.join(' AND ')}
1343
1410
  latestAuthor = link.author;
1344
1411
  }
1345
1412
  }
1346
- // Find matching property (skip those with surrealGetter)
1413
+ // Find matching property (skip those with getter)
1347
1414
  let foundProperty = false;
1348
1415
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
1349
- if (propMeta.surrealGetter)
1350
- continue; // Handle via surrealGetter evaluation
1416
+ if (propMeta.getter)
1417
+ continue; // Handle via getter evaluation
1351
1418
  if (propMeta.predicate === predicate) {
1352
1419
  // For properties, take the first value (or we could use timestamp to get latest)
1353
1420
  // Note: Empty objects {} are truthy, so we need to check for them explicitly
@@ -1417,11 +1484,11 @@ WHERE ${whereConditions.join(' AND ')}
1417
1484
  break;
1418
1485
  }
1419
1486
  }
1420
- // If not a property, check if it's a collection (skip those with surrealGetter)
1487
+ // If not a property, check if it's a collection (skip those with getter)
1421
1488
  if (!foundProperty) {
1422
1489
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
1423
- if (collMeta.surrealGetter)
1424
- continue; // Handle via surrealGetter evaluation
1490
+ if (collMeta.getter)
1491
+ continue; // Handle via getter evaluation
1425
1492
  if (collMeta.predicate === predicate) {
1426
1493
  // For collections, accumulate all values with their timestamps and indices for sorting
1427
1494
  if (!instance[collName]) {
@@ -1501,7 +1568,7 @@ WHERE ${whereConditions.join(' AND ')}
1501
1568
  // Replace collection with sorted values, filtering out empty strings and None
1502
1569
  instance[collName] = pairs
1503
1570
  .map(p => p.value)
1504
- .filter((v) => v && v !== '' && v !== 'None');
1571
+ .filter((v) => v !== undefined && v !== null && v !== '' && v !== 'None');
1505
1572
  // Clean up temporary arrays
1506
1573
  delete instance[timestampsKey];
1507
1574
  delete instance[indicesKey];
@@ -1511,8 +1578,9 @@ WHERE ${whereConditions.join(' AND ')}
1511
1578
  if (requestedProperties.length > 0 || requestedCollections.length > 0) {
1512
1579
  const requestedAttributes = [...requestedProperties, ...requestedCollections];
1513
1580
  Object.keys(instance).forEach((key) => {
1514
- // Keep only requested attributes, plus always keep timestamp and author
1515
- if (!requestedAttributes.includes(key) && key !== 'timestamp' && key !== 'author' && key !== 'baseExpression') {
1581
+ // Keep only requested attributes, plus always keep createdAt, updatedAt, author, and baseExpression
1582
+ // Note: timestamp is a getter alias for createdAt, so we preserve createdAt instead
1583
+ if (!requestedAttributes.includes(key) && key !== 'createdAt' && key !== 'updatedAt' && key !== 'author' && key !== 'baseExpression') {
1516
1584
  delete instance[key];
1517
1585
  }
1518
1586
  });
@@ -1523,12 +1591,13 @@ WHERE ${whereConditions.join(' AND ')}
1523
1591
  console.error(`Failed to process SurrealDB instance ${base}:`, error);
1524
1592
  }
1525
1593
  }
1526
- // Evaluate SurrealQL getters for all instances
1594
+ // Evaluate custom getters for all instances (single pass)
1595
+ // This populates collection values needed for where.isInstance filtering
1527
1596
  for (const instance of instances) {
1528
- await this.evaluateSurrealGettersForInstance(instance, perspective, metadata);
1597
+ await this.evaluateCustomGettersForInstance(instance, perspective, metadata);
1529
1598
  }
1530
1599
  // Filter collections by where.isInstance if specified
1531
- // Do this for all instances that have collections with filters
1600
+ // Do this after initial evaluation so collection values exist for filtering
1532
1601
  for (const instance of instances) {
1533
1602
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
1534
1603
  if (collMeta.where?.isInstance && instance[collName]?.length > 0) {
@@ -1545,6 +1614,7 @@ WHERE ${whereConditions.join(' AND ')}
1545
1614
  }
1546
1615
  // Check which subjects are instances of the target class
1547
1616
  const validSubjects = await perspective.batchCheckSubjectInstances(subjects, classMetadata);
1617
+ // Update the collection with filtered instances
1548
1618
  instance[collName] = validSubjects;
1549
1619
  }
1550
1620
  catch (error) {
@@ -1553,10 +1623,6 @@ WHERE ${whereConditions.join(' AND ')}
1553
1623
  }
1554
1624
  }
1555
1625
  }
1556
- // Evaluate SurrealQL getters for all instances
1557
- for (const instance of instances) {
1558
- await this.evaluateSurrealGettersForInstance(instance, perspective, metadata);
1559
- }
1560
1626
  // Filter by where conditions that couldn't be filtered in SQL
1561
1627
  // This includes:
1562
1628
  // - author/timestamp (computed from grouped links)
@@ -40,7 +40,7 @@ describe("Ad4mModel.getModelMetadata()", () => {
40
40
  __metadata("design:type", String)
41
41
  ], PropertyModel.prototype, "optional", void 0);
42
42
  __decorate([
43
- ReadOnly({ through: "test://readonly", getter: "custom_getter" }),
43
+ ReadOnly({ through: "test://readonly", prologGetter: "custom_getter" }),
44
44
  __metadata("design:type", String)
45
45
  ], PropertyModel.prototype, "readonly", void 0);
46
46
  __decorate([
@@ -64,7 +64,7 @@ describe("Ad4mModel.getModelMetadata()", () => {
64
64
  // Verify "readonly" property
65
65
  expect(metadata.properties.readonly.predicate).toBe("test://readonly");
66
66
  expect(metadata.properties.readonly.writable).toBe(false);
67
- expect(metadata.properties.readonly.getter).toBe("custom_getter");
67
+ expect(metadata.properties.readonly.prologGetter).toBe("custom_getter");
68
68
  // Verify "type" property (flag)
69
69
  expect(metadata.properties.type.predicate).toBe("test://type");
70
70
  expect(metadata.properties.type.flag).toBe(true);
@@ -144,8 +144,8 @@ describe("Ad4mModel.getModelMetadata()", () => {
144
144
  __decorate([
145
145
  Optional({
146
146
  through: "test://computed",
147
- getter: "triple(Base, 'test://value', V), Value is V * 2",
148
- setter: "Value is V / 2, Actions = [{action: 'setSingleTarget', source: 'this', predicate: 'test://value', target: Value}]"
147
+ prologGetter: "triple(Base, 'test://value', V), Value is V * 2",
148
+ prologSetter: "Value is V / 2, Actions = [{action: 'setSingleTarget', source: 'this', predicate: 'test://value', target: Value}]"
149
149
  }),
150
150
  __metadata("design:type", Number)
151
151
  ], CustomModel.prototype, "computed", void 0);
@@ -153,10 +153,10 @@ describe("Ad4mModel.getModelMetadata()", () => {
153
153
  ModelOptions({ name: "CustomModel" })
154
154
  ], CustomModel);
155
155
  const metadata = CustomModel.getModelMetadata();
156
- // Assert getter and setter contain the custom code
157
- expect(metadata.properties.computed.getter).toContain("triple(Base, 'test://value', V), Value is V * 2");
158
- expect(metadata.properties.computed.setter).toContain("Value is V / 2");
159
- expect(metadata.properties.computed.setter).toContain("setSingleTarget");
156
+ // Assert prologGetter and prologSetter contain the custom code
157
+ expect(metadata.properties.computed.prologGetter).toContain("triple(Base, 'test://value', V), Value is V * 2");
158
+ expect(metadata.properties.computed.prologSetter).toContain("Value is V / 2");
159
+ expect(metadata.properties.computed.prologSetter).toContain("setSingleTarget");
160
160
  });
161
161
  it("should handle collection with isInstance where clause", () => {
162
162
  let Comment = class Comment extends Ad4mModel {
@@ -210,7 +210,7 @@ describe("Ad4mModel.getModelMetadata()", () => {
210
210
  __metadata("design:type", String)
211
211
  ], Recipe.prototype, "description", void 0);
212
212
  __decorate([
213
- ReadOnly({ through: "recipe://rating", getter: "avg_rating(Base, Value)" }),
213
+ ReadOnly({ through: "recipe://rating", prologGetter: "avg_rating(Base, Value)" }),
214
214
  __metadata("design:type", Number)
215
215
  ], Recipe.prototype, "rating", void 0);
216
216
  __decorate([
@@ -241,7 +241,7 @@ describe("Ad4mModel.getModelMetadata()", () => {
241
241
  expect(metadata.properties.name.resolveLanguage).toBe("literal");
242
242
  expect(metadata.properties.description.predicate).toBe("recipe://description");
243
243
  expect(metadata.properties.rating.predicate).toBe("recipe://rating");
244
- expect(metadata.properties.rating.getter).toBe("avg_rating(Base, Value)");
244
+ expect(metadata.properties.rating.prologGetter).toBe("avg_rating(Base, Value)");
245
245
  expect(metadata.collections.ingredients.predicate).toBe("recipe://ingredient");
246
246
  expect(metadata.collections.steps.predicate).toBe("recipe://step");
247
247
  expect(metadata.collections.steps.local).toBe(true);
@@ -12,9 +12,9 @@ export interface InstanceQueryParams {
12
12
  */
13
13
  where?: object;
14
14
  /**
15
- * A string representing the condition clause of the query.
15
+ * A string representing the Prolog condition clause of the query.
16
16
  */
17
- condition?: string;
17
+ prologCondition?: string;
18
18
  }
19
19
  /**
20
20
  * Decorator for querying instances of a model class.
@@ -47,14 +47,14 @@ export interface InstanceQueryParams {
47
47
  * static async findByName(perspective: PerspectiveProxy): Promise<Recipe[]> { return [] }
48
48
  *
49
49
  * // Get highly rated recipes using a custom condition
50
- * @InstanceQuery({ condition: "triple(Instance, 'recipe://rating', Rating), Rating > 4" })
50
+ * @InstanceQuery({ prologCondition: "triple(Instance, 'recipe://rating', Rating), Rating > 4" })
51
51
  * static async topRated(perspective: PerspectiveProxy): Promise<Recipe[]> { return [] }
52
52
  * }
53
53
  * ```
54
54
  *
55
55
  * @param {Object} [options] - Query options
56
56
  * @param {object} [options.where] - Object with property-value pairs to match
57
- * @param {string} [options.condition] - Custom Prolog condition for more complex queries
57
+ * @param {string} [options.prologCondition] - Custom Prolog condition for more complex queries
58
58
  */
59
59
  export declare function InstanceQuery(options?: InstanceQueryParams): <T>(target: T, key: keyof T, descriptor: PropertyDescriptor) => void;
60
60
  export interface PropertyOptions {
@@ -79,19 +79,19 @@ export interface PropertyOptions {
79
79
  */
80
80
  resolveLanguage?: string;
81
81
  /**
82
- * Custom getter to get the value of the property in the prolog engine. If not provided, the default getter will be used.
82
+ * Custom Prolog getter to get the value of the property. If not provided, the default getter will be used.
83
83
  */
84
- getter?: string;
84
+ prologGetter?: string;
85
85
  /**
86
- * Custom setter to set the value of the property in the prolog engine. Only available if the property is writable.
86
+ * Custom Prolog setter to set the value of the property. Only available if the property is writable.
87
87
  */
88
- setter?: string;
88
+ prologSetter?: string;
89
89
  /**
90
90
  * Custom SurrealQL getter to resolve the property value. Use this for custom graph traversals.
91
91
  * The expression can reference 'Base' which will be replaced with the instance's base expression.
92
92
  * Example: "(<-link[WHERE predicate = 'flux://has_reply'].in.uri)[0]"
93
93
  */
94
- surrealGetter?: string;
94
+ getter?: string;
95
95
  /**
96
96
  * Indicates whether the property is stored locally in the perspective and not in the network. Useful for properties that are not meant to be shared with the network.
97
97
  */
@@ -178,8 +178,8 @@ export interface PropertyOptions {
178
178
  * @param {boolean} [opts.required] - Whether the property must have a value
179
179
  * @param {boolean} [opts.writable=true] - Whether the property can be modified
180
180
  * @param {string} [opts.resolveLanguage] - Language to use for value resolution (e.g. "literal")
181
- * @param {string} [opts.getter] - Custom Prolog code for getting the property value
182
- * @param {string} [opts.setter] - Custom Prolog code for setting the property value
181
+ * @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
182
+ * @param {string} [opts.prologSetter] - Custom Prolog code for setting the property value
183
183
  * @param {boolean} [opts.local] - Whether the property should only be stored locally
184
184
  */
185
185
  export declare function Optional(opts: PropertyOptions): <T>(target: T, key: keyof T) => void;
@@ -249,6 +249,7 @@ export interface FlagOptions {
249
249
  export declare function Flag(opts: FlagOptions): <T>(target: T, key: keyof T) => void;
250
250
  interface WhereOptions {
251
251
  isInstance?: any;
252
+ prologCondition?: string;
252
253
  condition?: string;
253
254
  }
254
255
  export interface CollectionOptions {
@@ -265,7 +266,7 @@ export interface CollectionOptions {
265
266
  * The expression can reference 'Base' which will be replaced with the instance's base expression.
266
267
  * Example: "(<-link[WHERE predicate = 'flux://has_reply'].in.uri)"
267
268
  */
268
- surrealGetter?: string;
269
+ getter?: string;
269
270
  /**
270
271
  * Indicates whether the property is stored locally in the perspective and not in the network. Useful for properties that are not meant to be shared with the network.
271
272
  */
@@ -307,13 +308,20 @@ export interface CollectionOptions {
307
308
  * })
308
309
  * comments: string[] = [];
309
310
  *
310
- * // Collection with custom filter condition
311
+ * // Collection with custom Prolog filter condition
311
312
  * @Collection({
312
313
  * through: "recipe://step",
313
- * where: { condition: `triple(Target, "step://order", Order), Order < 3` }
314
+ * where: { prologCondition: `triple(Target, "step://order", Order), Order < 3` }
314
315
  * })
315
316
  * firstSteps: string[] = [];
316
317
  *
318
+ * // Collection with custom SurrealDB filter condition
319
+ * @Collection({
320
+ * through: "recipe://entries",
321
+ * where: { condition: `WHERE in.uri = Target AND predicate = 'recipe://has_ingredient' AND out.uri = 'recipe://test')`
322
+ * })
323
+ * ingredients: string[] = [];
324
+ *
317
325
  * // Local-only collection not shared with network
318
326
  * @Collection({
319
327
  * through: "recipe://note",
@@ -333,7 +341,7 @@ export interface CollectionOptions {
333
341
  * @param {string} opts.through - The predicate URI for collection links
334
342
  * @param {WhereOptions} [opts.where] - Filter conditions for collection values
335
343
  * @param {any} [opts.where.isInstance] - Model class to filter instances by
336
- * @param {string} [opts.where.condition] - Custom Prolog condition for filtering
344
+ * @param {string} [opts.where.prologCondition] - Custom Prolog condition for filtering
337
345
  * @param {boolean} [opts.local] - Whether collection links are stored locally only
338
346
  */
339
347
  export declare function Collection(opts: CollectionOptions): <T>(target: T, key: keyof T) => void;
@@ -450,8 +458,8 @@ export declare function ModelOptions(opts: ModelOptionsOptions): (target: any) =
450
458
  * @param {string} opts.through - The predicate URI for the property
451
459
  * @param {string} [opts.initial] - Initial value (defaults to "literal://string:uninitialized")
452
460
  * @param {string} [opts.resolveLanguage] - Language to use for value resolution (e.g. "literal")
453
- * @param {string} [opts.getter] - Custom Prolog code for getting the property value
454
- * @param {string} [opts.setter] - Custom Prolog code for setting the property value
461
+ * @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
462
+ * @param {string} [opts.prologSetter] - Custom Prolog code for setting the property value
455
463
  * @param {boolean} [opts.local] - Whether the property should only be stored locally
456
464
  */
457
465
  export declare function Property(opts: PropertyOptions): <T>(target: T, key: keyof T) => void;
@@ -507,7 +515,7 @@ export declare function Property(opts: PropertyOptions): <T>(target: T, key: key
507
515
  * @param {string} opts.through - The predicate URI for the property
508
516
  * @param {string} [opts.initial] - Initial value (if property should have one)
509
517
  * @param {string} [opts.resolveLanguage] - Language to use for value resolution (e.g. "literal")
510
- * @param {string} [opts.getter] - Custom Prolog code for getting the property value
518
+ * @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
511
519
  * @param {boolean} [opts.local] - Whether the property should only be stored locally
512
520
  */
513
521
  export declare function ReadOnly(opts: PropertyOptions): <T>(target: T, key: keyof T) => void;