@aerokit/sdk 14.48.0 → 14.50.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerokit/sdk",
3
- "version": "14.48.0",
3
+ "version": "14.50.0",
4
4
  "description": "Unified TypeScript SDK for modern cloud platforms.",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
@@ -51,9 +51,41 @@ export function sampleRecord(entity) {
51
51
  for (const set of entity.exactlyOne ?? []) {
52
52
  for (const name of set.slice(1)) delete record[name];
53
53
  }
54
+ // a compare check relates two of the record's own fields, and the sample values above are
55
+ // per-type constants - so two dates come out EQUAL and a strict comparison (gt/lt/ne) would be
56
+ // rejected with 400. Derive the left operand from the right, by the smallest step that satisfies
57
+ // the declared operator (equality satisfies ge/le/eq).
58
+ for (const check of entity.compare ?? []) {
59
+ if (!(check.field in record) || record[check.than] == null) continue;
60
+ const type = (entity.fields ?? []).find((f) => f.name === check.field)?.type;
61
+ record[check.field] = shifted(record[check.than], type, STEPS[check.op] ?? 0);
62
+ }
54
63
  return record;
55
64
  }
56
65
 
66
+ // How far the left operand of a compare check has to move off the right one to satisfy it.
67
+ const STEPS = { ge: 0, le: 0, eq: 0, gt: 1, ne: 1, lt: -1 };
68
+
69
+ // One step of the value's own unit: a day for a date, an hour for a timestamp, one for a number.
70
+ function shifted(value, type, step) {
71
+ if (step === 0) return value;
72
+ switch (type) {
73
+ case 'date': {
74
+ const at = new Date(value + 'T00:00:00Z');
75
+ at.setUTCDate(at.getUTCDate() + step);
76
+ return at.toISOString().slice(0, 10);
77
+ }
78
+ case 'timestamp':
79
+ case 'datetime': {
80
+ const at = new Date(value);
81
+ at.setUTCHours(at.getUTCHours() + step);
82
+ return at.toISOString().replace(/\.\d{3}Z$/, 'Z');
83
+ }
84
+ default:
85
+ return value + step;
86
+ }
87
+ }
88
+
57
89
  // The searchable "handle" field: the first long string field shown in the list. Its
58
90
  // value identifies the record in the table across the create/edit/delete flow.
59
91
  // Null when the entity has no such field (all-numeric/date entities) - flows degrade: