@ai-matrx/records 0.48.0 → 0.49.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.
@@ -2100,6 +2100,11 @@ declare const STORE_DOORS: readonly [{
2100
2100
  readonly args: "p_organization_id uuid, p_table_id uuid, p_record_ids uuid[], p_by_id boolean DEFAULT false";
2101
2101
  readonly returns: "TABLE(id uuid, document jsonb, level permission_level)";
2102
2102
  readonly security: "definer";
2103
+ }, {
2104
+ readonly name: "read_records_matching";
2105
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_filter jsonb DEFAULT '{}'::jsonb, p_by_id boolean DEFAULT false, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0";
2106
+ readonly returns: "TABLE(id uuid, document jsonb, level permission_level)";
2107
+ readonly security: "definer";
2103
2108
  }, {
2104
2109
  readonly name: "realtime_topic_admits";
2105
2110
  readonly args: "p_topic text";
@@ -2100,6 +2100,11 @@ declare const STORE_DOORS: readonly [{
2100
2100
  readonly args: "p_organization_id uuid, p_table_id uuid, p_record_ids uuid[], p_by_id boolean DEFAULT false";
2101
2101
  readonly returns: "TABLE(id uuid, document jsonb, level permission_level)";
2102
2102
  readonly security: "definer";
2103
+ }, {
2104
+ readonly name: "read_records_matching";
2105
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_filter jsonb DEFAULT '{}'::jsonb, p_by_id boolean DEFAULT false, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0";
2106
+ readonly returns: "TABLE(id uuid, document jsonb, level permission_level)";
2107
+ readonly security: "definer";
2103
2108
  }, {
2104
2109
  readonly name: "realtime_topic_admits";
2105
2110
  readonly args: "p_topic text";
package/dist/index.cjs CHANGED
@@ -90,7 +90,8 @@ __export(src_exports, {
90
90
  portalPath: () => portalPath,
91
91
  publicFormPath: () => publicFormPath,
92
92
  rememberedOpCount: () => rememberedOpCount,
93
- scopeChip: () => scopeChip
93
+ scopeChip: () => scopeChip,
94
+ stableFilterKey: () => stableFilterKey
94
95
  });
95
96
  module.exports = __toCommonJS(src_exports);
96
97
 
@@ -448,6 +449,20 @@ function portalPath(slug) {
448
449
  function measureKey(measure) {
449
450
  return measure.op === "count" ? "count" : `${measure.op}_${measure.key ?? ""}`;
450
451
  }
452
+ function stableFilterKey(filter) {
453
+ if (!filter) return "{}";
454
+ const keys = Object.keys(filter).sort();
455
+ if (keys.length === 0) return "{}";
456
+ const parts = keys.map((key) => {
457
+ const value = filter[key];
458
+ if (value !== null && typeof value === "object") {
459
+ const window2 = value;
460
+ return `${JSON.stringify(key)}:{"from":${JSON.stringify(window2.from ?? null)},"to":${JSON.stringify(window2.to ?? null)}}`;
461
+ }
462
+ return `${JSON.stringify(key)}:${JSON.stringify(value ?? null)}`;
463
+ });
464
+ return `{${parts.join(",")}}`;
465
+ }
451
466
 
452
467
  // src/capture-queue.ts
453
468
  var DB_NAME = "matrx-capture";
@@ -1222,6 +1237,7 @@ var STORE_DOORS = [
1222
1237
  { name: "read_record", args: "p_organization_id uuid, p_record_id uuid, p_by_id boolean DEFAULT false", returns: "jsonb", security: "definer" },
1223
1238
  { name: "read_records", args: "p_organization_id uuid, p_table_id uuid, p_by_id boolean DEFAULT false, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0", returns: "TABLE(id uuid, document jsonb, level permission_level)", security: "definer" },
1224
1239
  { name: "read_records_by_ids", args: "p_organization_id uuid, p_table_id uuid, p_record_ids uuid[], p_by_id boolean DEFAULT false", returns: "TABLE(id uuid, document jsonb, level permission_level)", security: "definer" },
1240
+ { name: "read_records_matching", args: "p_organization_id uuid, p_table_id uuid, p_filter jsonb DEFAULT '{}'::jsonb, p_by_id boolean DEFAULT false, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0", returns: "TABLE(id uuid, document jsonb, level permission_level)", security: "definer" },
1225
1241
  { name: "realtime_topic_admits", args: "p_topic text", returns: "boolean", security: "definer" },
1226
1242
  { name: "record_aggregate", args: "p_organization_id uuid, p_table_id uuid, p_group_by jsonb DEFAULT '[]'::jsonb, p_measures jsonb DEFAULT '[]'::jsonb, p_bucket jsonb DEFAULT NULL::jsonb, p_filter jsonb DEFAULT '{}'::jsonb, p_limit integer DEFAULT 200, p_required text DEFAULT 'viewer'::text", returns: "TABLE(groups jsonb, measures jsonb, row_count bigint)", security: "definer" },
1227
1243
  { name: "record_applicability", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(rule_id uuid, rule_name text, rule_version integer, applies boolean, answer jsonb)", security: "invoker" },