@happyvertical/smrt-assets 0.60.9 → 0.60.11

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.
@@ -0,0 +1,14 @@
1
+ /** Identify the portable locator namespace without accepting the key yet. */
2
+ export declare function isLocalAssetLocator(value: string): boolean;
3
+ /** Encode a validated raw key as a persisted local asset locator. */
4
+ export declare function makeLocalAssetLocator(key: string): string;
5
+ /** Decode a portable locator to a validated key relative to the asset root. */
6
+ export declare function localAssetKey(locator: string): string;
7
+ export declare function requireLocalAssetRoot(root: string): string;
8
+ export declare function keyFromLegacyFileLocator(root: string, locator: string): string;
9
+ /**
10
+ * Refuse links and non-files beneath the trusted configured root. This
11
+ * inspection assumes the host prevents untrusted concurrent filesystem edits.
12
+ */
13
+ export declare function checkLocalAssetPath(root: string, key: string): Promise<void>;
14
+ //# sourceMappingURL=local-asset-locator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-asset-locator.d.ts","sourceRoot":"","sources":["../src/local-asset-locator.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,qEAAqE;AACrE,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOrD;AAkBD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW1D;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,CA4BR;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAkBf"}
@@ -0,0 +1,2 @@
1
+ export { isLocalAssetLocator, localAssetKey, makeLocalAssetLocator, } from './local-asset-locator.js';
2
+ //# sourceMappingURL=locator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locator.d.ts","sourceRoot":"","sources":["../src/locator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { a as makeLocalAssetLocator, i as localAssetKey, n as isLocalAssetLocator } from "./chunks/local-asset-locator-v4zTxVgM.js";
2
+ export { isLocalAssetLocator, localAssetKey, makeLocalAssetLocator };
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-assets",
5
- "packageVersion": "0.60.9",
5
+ "packageVersion": "0.60.11",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-assets:AssetAssociation": {
8
8
  "name": "assetassociation",
@@ -133,8 +133,14 @@
133
133
  ],
134
134
  "schema": {
135
135
  "tableName": "asset_associations",
136
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_associations\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"meta_type\" TEXT NOT NULL,\n \"meta_id\" TEXT NOT NULL,\n \"role\" TEXT NOT NULL,\n \"sort_order\" INTEGER DEFAULT 0,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL\n);",
136
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_associations\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"meta_type\" TEXT NOT NULL,\n \"meta_id\" TEXT NOT NULL,\n \"role\" TEXT NOT NULL,\n \"sort_order\" INTEGER DEFAULT 0,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL\n);",
137
137
  "columns": {
138
+ "_sync_origin_device_id": {
139
+ "type": "TEXT"
140
+ },
141
+ "_sync_revision": {
142
+ "type": "INTEGER"
143
+ },
138
144
  "id": {
139
145
  "type": "UUID",
140
146
  "primaryKey": true,
@@ -233,7 +239,7 @@
233
239
  ]
234
240
  }
235
241
  ],
236
- "version": "faa13cea"
242
+ "version": "04bd57bd"
237
243
  },
238
244
  "importPath": "@happyvertical/smrt-assets"
239
245
  },
@@ -405,8 +411,14 @@
405
411
  ],
406
412
  "schema": {
407
413
  "tableName": "asset_associations",
408
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_associations\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"meta_type\" TEXT NOT NULL,\n \"meta_id\" TEXT NOT NULL,\n \"role\" TEXT NOT NULL,\n \"sort_order\" INTEGER DEFAULT 0,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL\n);",
414
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_associations\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"meta_type\" TEXT NOT NULL,\n \"meta_id\" TEXT NOT NULL,\n \"role\" TEXT NOT NULL,\n \"sort_order\" INTEGER DEFAULT 0,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL\n);",
409
415
  "columns": {
416
+ "_sync_origin_device_id": {
417
+ "type": "TEXT"
418
+ },
419
+ "_sync_revision": {
420
+ "type": "INTEGER"
421
+ },
410
422
  "id": {
411
423
  "type": "UUID",
412
424
  "primaryKey": true,
@@ -505,7 +517,7 @@
505
517
  ]
506
518
  }
507
519
  ],
508
- "version": "faa13cea"
520
+ "version": "04bd57bd"
509
521
  },
510
522
  "importPath": "@happyvertical/smrt-assets"
511
523
  },
@@ -608,8 +620,14 @@
608
620
  "displayLabelField": "name",
609
621
  "schema": {
610
622
  "tableName": "asset_metafields",
611
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_metafields\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"validation\" TEXT\n);",
623
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_metafields\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"validation\" TEXT\n);",
612
624
  "columns": {
625
+ "_sync_origin_device_id": {
626
+ "type": "TEXT"
627
+ },
628
+ "_sync_revision": {
629
+ "type": "INTEGER"
630
+ },
613
631
  "id": {
614
632
  "type": "UUID",
615
633
  "primaryKey": true,
@@ -675,7 +693,7 @@
675
693
  ]
676
694
  }
677
695
  ],
678
- "version": "7393718c"
696
+ "version": "47eef3ef"
679
697
  },
680
698
  "importPath": "@happyvertical/smrt-assets"
681
699
  },
@@ -758,8 +776,14 @@
758
776
  ],
759
777
  "schema": {
760
778
  "tableName": "asset_metafields",
761
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_metafields\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"validation\" TEXT\n);",
779
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_metafields\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"validation\" TEXT\n);",
762
780
  "columns": {
781
+ "_sync_origin_device_id": {
782
+ "type": "TEXT"
783
+ },
784
+ "_sync_revision": {
785
+ "type": "INTEGER"
786
+ },
763
787
  "id": {
764
788
  "type": "UUID",
765
789
  "primaryKey": true,
@@ -825,7 +849,7 @@
825
849
  ]
826
850
  }
827
851
  ],
828
- "version": "7393718c"
852
+ "version": "47eef3ef"
829
853
  },
830
854
  "importPath": "@happyvertical/smrt-assets"
831
855
  },
@@ -906,8 +930,14 @@
906
930
  "displayLabelField": "name",
907
931
  "schema": {
908
932
  "tableName": "asset_statuses",
909
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_statuses\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
933
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_statuses\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
910
934
  "columns": {
935
+ "_sync_origin_device_id": {
936
+ "type": "TEXT"
937
+ },
938
+ "_sync_revision": {
939
+ "type": "INTEGER"
940
+ },
911
941
  "id": {
912
942
  "type": "UUID",
913
943
  "primaryKey": true,
@@ -973,7 +1003,7 @@
973
1003
  ]
974
1004
  }
975
1005
  ],
976
- "version": "8251a52f"
1006
+ "version": "f51692bf"
977
1007
  },
978
1008
  "importPath": "@happyvertical/smrt-assets"
979
1009
  },
@@ -1048,8 +1078,14 @@
1048
1078
  ],
1049
1079
  "schema": {
1050
1080
  "tableName": "asset_statuses",
1051
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_statuses\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
1081
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_statuses\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
1052
1082
  "columns": {
1083
+ "_sync_origin_device_id": {
1084
+ "type": "TEXT"
1085
+ },
1086
+ "_sync_revision": {
1087
+ "type": "INTEGER"
1088
+ },
1053
1089
  "id": {
1054
1090
  "type": "UUID",
1055
1091
  "primaryKey": true,
@@ -1115,7 +1151,7 @@
1115
1151
  ]
1116
1152
  }
1117
1153
  ],
1118
- "version": "8251a52f"
1154
+ "version": "f51692bf"
1119
1155
  },
1120
1156
  "importPath": "@happyvertical/smrt-assets"
1121
1157
  },
@@ -1194,8 +1230,14 @@
1194
1230
  ],
1195
1231
  "schema": {
1196
1232
  "tableName": "asset_tags",
1197
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_tags\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL,\n \"tag_id\" UUID NOT NULL\n);",
1233
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_tags\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL,\n \"tag_id\" UUID NOT NULL\n);",
1198
1234
  "columns": {
1235
+ "_sync_origin_device_id": {
1236
+ "type": "TEXT"
1237
+ },
1238
+ "_sync_revision": {
1239
+ "type": "INTEGER"
1240
+ },
1199
1241
  "id": {
1200
1242
  "type": "UUID",
1201
1243
  "primaryKey": true,
@@ -1276,7 +1318,7 @@
1276
1318
  ]
1277
1319
  }
1278
1320
  ],
1279
- "version": "e60d24f5"
1321
+ "version": "5473d500"
1280
1322
  },
1281
1323
  "importPath": "@happyvertical/smrt-assets"
1282
1324
  },
@@ -1420,8 +1462,14 @@
1420
1462
  ],
1421
1463
  "schema": {
1422
1464
  "tableName": "asset_tags",
1423
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_tags\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL,\n \"tag_id\" UUID NOT NULL\n);",
1465
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_tags\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"asset_id\" UUID NOT NULL,\n \"tag_id\" UUID NOT NULL\n);",
1424
1466
  "columns": {
1467
+ "_sync_origin_device_id": {
1468
+ "type": "TEXT"
1469
+ },
1470
+ "_sync_revision": {
1471
+ "type": "INTEGER"
1472
+ },
1425
1473
  "id": {
1426
1474
  "type": "UUID",
1427
1475
  "primaryKey": true,
@@ -1502,7 +1550,7 @@
1502
1550
  ]
1503
1551
  }
1504
1552
  ],
1505
- "version": "e60d24f5"
1553
+ "version": "5473d500"
1506
1554
  },
1507
1555
  "importPath": "@happyvertical/smrt-assets"
1508
1556
  },
@@ -1583,8 +1631,14 @@
1583
1631
  "displayLabelField": "name",
1584
1632
  "schema": {
1585
1633
  "tableName": "asset_types",
1586
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_types\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
1634
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_types\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
1587
1635
  "columns": {
1636
+ "_sync_origin_device_id": {
1637
+ "type": "TEXT"
1638
+ },
1639
+ "_sync_revision": {
1640
+ "type": "INTEGER"
1641
+ },
1588
1642
  "id": {
1589
1643
  "type": "UUID",
1590
1644
  "primaryKey": true,
@@ -1650,7 +1704,7 @@
1650
1704
  ]
1651
1705
  }
1652
1706
  ],
1653
- "version": "a9c93be2"
1707
+ "version": "e63d2a86"
1654
1708
  },
1655
1709
  "importPath": "@happyvertical/smrt-assets"
1656
1710
  },
@@ -1725,8 +1779,14 @@
1725
1779
  ],
1726
1780
  "schema": {
1727
1781
  "tableName": "asset_types",
1728
- "ddl": "CREATE TABLE IF NOT EXISTS \"asset_types\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
1782
+ "ddl": "CREATE TABLE IF NOT EXISTS \"asset_types\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"name\" TEXT,\n \"description\" TEXT\n);",
1729
1783
  "columns": {
1784
+ "_sync_origin_device_id": {
1785
+ "type": "TEXT"
1786
+ },
1787
+ "_sync_revision": {
1788
+ "type": "INTEGER"
1789
+ },
1730
1790
  "id": {
1731
1791
  "type": "UUID",
1732
1792
  "primaryKey": true,
@@ -1792,7 +1852,7 @@
1792
1852
  ]
1793
1853
  }
1794
1854
  ],
1795
- "version": "a9c93be2"
1855
+ "version": "e63d2a86"
1796
1856
  },
1797
1857
  "importPath": "@happyvertical/smrt-assets"
1798
1858
  },
@@ -2216,8 +2276,14 @@
2216
2276
  ],
2217
2277
  "schema": {
2218
2278
  "tableName": "assets",
2219
- "ddl": "CREATE TABLE IF NOT EXISTS \"assets\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"access_mode\" TEXT DEFAULT 'public',\n \"name\" TEXT,\n \"source_uri\" TEXT,\n \"mime_type\" TEXT,\n \"description\" TEXT,\n \"metadata\" TEXT,\n \"version\" INTEGER DEFAULT 1,\n \"primary_version_id\" UUID,\n \"type_slug\" TEXT,\n \"status_slug\" TEXT,\n \"owner_profile_id\" UUID,\n \"source_asset_id\" UUID,\n \"folder_id\" UUID,\n \"source_type\" TEXT,\n \"external_id\" TEXT,\n \"external_refs\" TEXT\n);",
2279
+ "ddl": "CREATE TABLE IF NOT EXISTS \"assets\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"access_mode\" TEXT DEFAULT 'public',\n \"name\" TEXT,\n \"source_uri\" TEXT,\n \"mime_type\" TEXT,\n \"description\" TEXT,\n \"metadata\" TEXT,\n \"version\" INTEGER DEFAULT 1,\n \"primary_version_id\" UUID,\n \"type_slug\" TEXT,\n \"status_slug\" TEXT,\n \"owner_profile_id\" UUID,\n \"source_asset_id\" UUID,\n \"folder_id\" UUID,\n \"source_type\" TEXT,\n \"external_id\" TEXT,\n \"external_refs\" TEXT\n);",
2220
2280
  "columns": {
2281
+ "_sync_origin_device_id": {
2282
+ "type": "TEXT"
2283
+ },
2284
+ "_sync_revision": {
2285
+ "type": "INTEGER"
2286
+ },
2221
2287
  "id": {
2222
2288
  "type": "UUID",
2223
2289
  "primaryKey": true,
@@ -2395,7 +2461,7 @@
2395
2461
  ]
2396
2462
  }
2397
2463
  ],
2398
- "version": "0e75029e"
2464
+ "version": "fd4b4eae"
2399
2465
  },
2400
2466
  "importPath": "@happyvertical/smrt-assets"
2401
2467
  },
@@ -2735,8 +2801,14 @@
2735
2801
  ],
2736
2802
  "schema": {
2737
2803
  "tableName": "assets",
2738
- "ddl": "CREATE TABLE IF NOT EXISTS \"assets\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"access_mode\" TEXT DEFAULT 'public',\n \"name\" TEXT,\n \"source_uri\" TEXT,\n \"mime_type\" TEXT,\n \"description\" TEXT,\n \"metadata\" TEXT,\n \"version\" INTEGER DEFAULT 1,\n \"primary_version_id\" UUID,\n \"type_slug\" TEXT,\n \"status_slug\" TEXT,\n \"owner_profile_id\" UUID,\n \"source_asset_id\" UUID,\n \"folder_id\" UUID,\n \"source_type\" TEXT,\n \"external_id\" TEXT,\n \"external_refs\" TEXT\n);",
2804
+ "ddl": "CREATE TABLE IF NOT EXISTS \"assets\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"_meta_type\" TEXT NOT NULL,\n \"_meta_data\" JSON,\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"access_mode\" TEXT DEFAULT 'public',\n \"name\" TEXT,\n \"source_uri\" TEXT,\n \"mime_type\" TEXT,\n \"description\" TEXT,\n \"metadata\" TEXT,\n \"version\" INTEGER DEFAULT 1,\n \"primary_version_id\" UUID,\n \"type_slug\" TEXT,\n \"status_slug\" TEXT,\n \"owner_profile_id\" UUID,\n \"source_asset_id\" UUID,\n \"folder_id\" UUID,\n \"source_type\" TEXT,\n \"external_id\" TEXT,\n \"external_refs\" TEXT\n);",
2739
2805
  "columns": {
2806
+ "_sync_origin_device_id": {
2807
+ "type": "TEXT"
2808
+ },
2809
+ "_sync_revision": {
2810
+ "type": "INTEGER"
2811
+ },
2740
2812
  "id": {
2741
2813
  "type": "UUID",
2742
2814
  "primaryKey": true,
@@ -2914,7 +2986,7 @@
2914
2986
  ]
2915
2987
  }
2916
2988
  ],
2917
- "version": "0e75029e"
2989
+ "version": "fd4b4eae"
2918
2990
  },
2919
2991
  "importPath": "@happyvertical/smrt-assets"
2920
2992
  },
@@ -3103,8 +3175,14 @@
3103
3175
  "displayLabelField": "name",
3104
3176
  "schema": {
3105
3177
  "tableName": "folders",
3106
- "ddl": "CREATE TABLE IF NOT EXISTS \"folders\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"name\" TEXT,\n \"description\" TEXT,\n \"owner_profile_id\" UUID\n);",
3178
+ "ddl": "CREATE TABLE IF NOT EXISTS \"folders\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"name\" TEXT,\n \"description\" TEXT,\n \"owner_profile_id\" UUID\n);",
3107
3179
  "columns": {
3180
+ "_sync_origin_device_id": {
3181
+ "type": "TEXT"
3182
+ },
3183
+ "_sync_revision": {
3184
+ "type": "INTEGER"
3185
+ },
3108
3186
  "id": {
3109
3187
  "type": "UUID",
3110
3188
  "primaryKey": true,
@@ -3196,7 +3274,7 @@
3196
3274
  ]
3197
3275
  }
3198
3276
  ],
3199
- "version": "1d0b1fcb"
3277
+ "version": "fee9a679"
3200
3278
  },
3201
3279
  "importPath": "@happyvertical/smrt-assets"
3202
3280
  },
@@ -3314,8 +3392,14 @@
3314
3392
  ],
3315
3393
  "schema": {
3316
3394
  "tableName": "folders",
3317
- "ddl": "CREATE TABLE IF NOT EXISTS \"folders\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"name\" TEXT,\n \"description\" TEXT,\n \"owner_profile_id\" UUID\n);",
3395
+ "ddl": "CREATE TABLE IF NOT EXISTS \"folders\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"parent_id\" UUID,\n \"tenant_id\" UUID,\n \"name\" TEXT,\n \"description\" TEXT,\n \"owner_profile_id\" UUID\n);",
3318
3396
  "columns": {
3397
+ "_sync_origin_device_id": {
3398
+ "type": "TEXT"
3399
+ },
3400
+ "_sync_revision": {
3401
+ "type": "INTEGER"
3402
+ },
3319
3403
  "id": {
3320
3404
  "type": "UUID",
3321
3405
  "primaryKey": true,
@@ -3407,7 +3491,7 @@
3407
3491
  ]
3408
3492
  }
3409
3493
  ],
3410
- "version": "1d0b1fcb"
3494
+ "version": "fee9a679"
3411
3495
  },
3412
3496
  "importPath": "@happyvertical/smrt-assets"
3413
3497
  }
@@ -3,18 +3,20 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-assets",
6
- "packageVersion": "0.60.9",
6
+ "packageVersion": "0.60.11",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "73ed3f0d5bde0e0dd64f9b92d43fb2dddc2745c974914dd9c0ea8d57b51ccca4",
11
- "packageJson": "9881e16b9fd57b88da88c1c88db18eb698e8e10c3d952881cc396f7536086ee3",
12
- "agents": "5e66d98d4e6806b15e8ceddefc00266547374b02d02bab81d72c14f5304403f7",
10
+ "manifest": "8123cd92f9bfcd34b5db9850a1f501cfede0dccbe92b9930e352812fb9a75462",
11
+ "packageJson": "972f4d64de29038ee8ef35a088a232a621ccf958bc76d29707a1e70a8ab938a3",
12
+ "agents": "57d57d3eff49cb185e2a8cadf8b14b06d26a4a7750862a41a09e5000dc9570b6",
13
+ "moduleDoc:README.md": "565639275a9f6b74d64d9043dc1ec642339446cbeaf0ebc3f0239da7dc5e7222",
13
14
  "moduleDoc:agents/private-assets.md": "e1a4ab4be7048f29d9e5b0d37d298f13e5a88ae9d988ef3a7cad728e03fb5797"
14
15
  },
15
16
  "exports": [
16
17
  ".",
17
18
  "./filesystem",
19
+ "./locator",
18
20
  "./manifest",
19
21
  "./manifest.json",
20
22
  "./playground",
@@ -3721,8 +3723,13 @@
3721
3723
  "polymorphicAssociations": 1,
3722
3724
  "uuidColumns": 40
3723
3725
  },
3724
- "agentDoc": "# @happyvertical/smrt-assets\n\nProvider-agnostic asset management with versioning, type classification, and generic/provenance associations.\n\n## Models\n\n- **Asset** (STI base): versioning via `primaryVersionId` chain + `version` number. `ownerProfileId`, `typeSlug`, `statusSlug`, `mimeType`, `sourceUri`. Derivation chain via `sourceAssetId` (R3-D — was `parentId` before the rename; column `source_asset_id`).\n- **AssetType** / **AssetStatus**: lookup tables for classification and lifecycle.\n- **AssetMetafield**: custom metadata field definitions with JSON validation rules.\n- **Folder**: hierarchical container for assets. Own `SmrtHierarchical` model with its own `folders` table (R3-D — was an STI subclass of Asset before). `Asset.folderId` points to the folder.\n- **AssetAssociation**: generic/provenance polymorphic join — `assetId` + `metaType` + `metaId` + `role` + `sortOrder`. Use it when a relationship is not owned by a base/domain model join table like `content_assets`, `profile_assets`, `event_assets`, `place_assets`, or `product_assets`.\n\n## Key Patterns\n\n- **Versioning**: `createNewVersion()` increments version, chains via `primaryVersionId`. `findVersions()` to retrieve history.\n- **Tag integration**: `addTag()`/`removeTag()` use raw `db.upsert()` on `asset_tags` join table (not a SMRT model).\n- **AssetStore**: abstraction for provider-agnostic file I/O (S3, local, etc.).\n `planFile(asset, opts)` resolves a recoverable URI before bytes are written;\n persist it before `preserveFile(asset, bytes, opts)`. Preservation adopts equal\n existing bytes and rejects changed bytes, changed resolver targets and read\n failures other than not-found. The caller owns receipt fencing/serialization.\n `removeFile(asset)` removes only bytes for recovery cleanup, including an\n already-pruned owner record; `remove(asset)` also deletes the owner record.\n- **Ownership rule**: base/domain-owned asset relationships should live on noun join tables such as `content_assets`, `profile_assets`, `event_assets`, `place_assets`, and `product_assets`; keep `AssetAssociation` for generic/provenance links like image derivation.\n\n## Runtime surface\n\nApps and agents should depend on the public **asset runtime** rather than hand-wiring a collection + store per-package (#1128).\n\n- `createAssetRuntime({ db, storage })` → `AssetRuntime` bundling `AssetCollection`, `AssetAssociationCollection`, and an initialized `AssetStore`.\n- `AssetRuntime.storeSourceAsset(name, data, opts)` — create a new source asset (record + bytes).\n- `AssetRuntime.storeDerivedAsset(source, name, data, opts)` — create a derivative with `sourceAssetId` set and (by default) a provenance `AssetAssociation` under a chosen role.\n- `AssetRuntime.linkDerivation(source, derivative, { role })` — record provenance without touching bytes.\n- `AssetRuntime.setExtractionStatus(asset, status, { error?, extractedAt? })` — write canonical extraction metadata into the asset's description JSON sidecar. Non-destructive: if `description` is free-form prose or non-object JSON, the original value is preserved under the reserved `text` key instead of being overwritten. Existing JSON objects are merged into.\n\n- `AssetRuntime.getPrivateAssetMetadata({ tenantId, actorUserId, assetId })` → `PrivateAssetMetadata | null` — authorized, tenant-scoped display metadata read of one PRIVATE asset so hosts never read `assets` rows. Trusted server capability (host authorizes first); requires an ambient tenant actor matching `tenantId`/`actorUserId` exactly (throws otherwise, including empty ids). Result is an allowlist (`id, tenantId, name, mimeType, version, typeSlug, statusSlug, createdAt, updatedAt`); never owner, `sourceUri`, description/metadata sidecars. There is no size field on `Asset`. Missing, public and other-tenant assets all return `null`. Internally resolves the owner from the tenant-scoped private row, then reads through the guarded collection inside a one-id `withPrivateAssetAccess` that closes on return; inside an existing scope it can only narrow (throws `cannot widen` otherwise).\n\nAgents that need asset I/O should accept an `AssetRuntimeLike` in their options rather than asking callers to pass a store + collection separately.\n\n## Serving contract\n\n- `serveAsset({ runtime, asset, tenantId?, disposition?, canAccess?, headers?, remoteMode? })` → standard Web `Response`.\n - `404` when the id doesn't resolve; `403` when the tenant mismatches or `canAccess` denies; `302` when `remoteMode: 'redirect'` and the asset's `sourceUri` is `http(s)`; `502` when `remoteMode: 'proxy'` and the origin fetch fails; `500` on store read errors or unexpected failures; `200` otherwise with `Content-Type`, `Content-Length`, and `Content-Disposition` set.\n - Assets whose `sourceUri` is `http(s)` are supported via `remoteMode`: `'proxy'` (default, fetch and return bytes), `'redirect'` (302 to the origin), or `'error'` (treat as misconfiguration). Pass `fetchImpl` to swap the fetch client.\n - `Content-Disposition` uses an ASCII-safe quoted `filename` fallback and retains the Unicode download name in UTF-8 `filename*` ([RFC 6266](https://www.rfc-editor.org/rfc/rfc6266#section-4.3), [RFC 8187](https://www.rfc-editor.org/rfc/rfc8187#section-3.2.1)). Both names strip C0/DEL/C1 controls and replace `\"` / `\\` / `/` to prevent header injection; isolated UTF-16 surrogates become U+FFFD before encoding, while valid pairs are preserved.\n - The 500 body is a generic `'Internal error serving asset'`; the underlying error is logged via `console.error` so operators can debug without leaking paths/bucket names to clients.\n - Works in SvelteKit `+server.ts` endpoints, Hono, and any runtime with a global `Response` (Node 18+). Pass `responseCtor` for older runtimes.\n- `resolveAssetForServing(options)` → `{ asset, data, contentType, filename, size }` when callers want to render their own framework response. Throws `AssetServeError(status)` on the same failure modes.\n\n## Source/derived vocabulary\n\nThe following roles are exported as `ASSET_ROLES` and should be preferred over ad-hoc strings when apps want cross-package tooling (serving, UI pickers) to agree on meaning:\n\n| Role | Use |\n|------|-----|\n| `source_document` | original upstream document (agenda PDF, minutes) |\n| `document_image` | page/extracted image derived from a source document |\n| `thumbnail` | preview rendition of another asset |\n| `proof` | non-canonical evidence asset backing a fact |\n| `derivation_source` | \"came from\" link on generated media |\n| `attachment` | generic owner-join link |\n| `hero` | primary/featured asset on an owner |\n\nCanonical metadata keys are exported as `ASSET_METADATA_KEYS`: `extractionStatus`, `extractionError`, `extractedAt`, `sourceUrl`, `sourceHash`, `pageNumber`. Extraction status values live in `ASSET_EXTRACTION_STATUS` (`pending | running | succeeded | failed`).\n\n## UI Registry\n\nThe `./ui` subpath exports `ASSETS_MODULE_META` and `ASSETS_UI_SLOTS` so registry-driven hosts (smrt-chat, dynamic admin shells) can discover the package's Svelte components without a hard import.\n\n```ts\nimport { ASSETS_MODULE_META, ASSETS_UI_SLOTS } from '@happyvertical/smrt-assets/ui';\nimport '@happyvertical/smrt-assets/svelte'; // side-effect: ModuleUIRegistry.register(...)\nimport { ModuleUIRegistry } from '@happyvertical/smrt-ui/registry';\n\nconst AssetManager = ModuleUIRegistry.get('@happyvertical/smrt-assets', 'asset-manager');\n```\n\nRegistered slots: `asset-manager` (admin), `asset-grid` / `asset-list` (list), `asset-detail` (detail), `asset-toolbar` / `asset-action-bar` (action), `asset-create-modal` (form). Slot IDs are stable contracts — host apps reference them by string.\n\n## Gotchas\n\n- **Files SDK is a lazy boundary (#1979)**: `AssetStore` loads `@happyvertical/files` through `src/files-runtime.ts` (bundler-invisible), because smrt-assets is reachable from provider-neutral consumer graphs via profiles. Node/tsx/vite-dev runtimes resolve it on first file operation; fully-bundled deployments import `@happyvertical/smrt-assets/filesystem` at startup. Never import the files SDK statically from modules reachable from `src/index.ts`.\n- **Version history manual**: `findVersions()` chaining required — no ORM shortcut\n- **Tag management uses raw SQL**: `asset_tags` is a join table, not an SMRT model\n- **Folder tree traversal**: via `SmrtHierarchical` (`getParent`/`getChildren`/`getAncestors`/`getDescendants`/`getHierarchy`/`moveTo`); `FolderCollection.getTree(rootId?)` and `getPath(folderId)` wrap these for convenience\n- **AssetAssociation polymorphic FK**: requires manual `metaType` string matching\n- **Optional tenancy**: assets can be global (tenantId=null) or tenant-scoped\n\n## Private records\n\n`Asset.accessMode` and the mandatory owning interceptor protect private records\nacross generated and parent STI surfaces. Use the exact actor/owner/ID capability\nonly after host authorization; see [private assets](agents/private-assets.md).\nFor display metadata (name, mime type, version) use `AssetRuntime.getPrivateAssetMetadata`\ninstead of reading raw `assets` rows to discover the owner.\n",
3726
+ "agentDoc": "# @happyvertical/smrt-assets\n\nProvider-agnostic asset management with versioning, type classification, and generic/provenance associations.\n\n## Models\n\n- **Asset** (STI base): versioning via `primaryVersionId` chain + `version` number. `ownerProfileId`, `typeSlug`, `statusSlug`, `mimeType`, `sourceUri`. Derivation chain via `sourceAssetId` (R3-D — was `parentId` before the rename; column `source_asset_id`).\n- **AssetType** / **AssetStatus**: lookup tables for classification and lifecycle.\n- **AssetMetafield**: custom metadata field definitions with JSON validation rules.\n- **Folder**: hierarchical container for assets. Own `SmrtHierarchical` model with its own `folders` table (R3-D — was an STI subclass of Asset before). `Asset.folderId` points to the folder.\n- **AssetAssociation**: generic/provenance polymorphic join — `assetId` + `metaType` + `metaId` + `role` + `sortOrder`. Use it when a relationship is not owned by a base/domain model join table like `content_assets`, `profile_assets`, `event_assets`, `place_assets`, or `product_assets`.\n\n## Key Patterns\n\n- **Versioning**: `createNewVersion()` increments version, chains via `primaryVersionId`. `findVersions()` to retrieve history.\n- **Tag integration**: `addTag()`/`removeTag()` use raw `db.upsert()` on `asset_tags` join table (not a SMRT model).\n- **AssetStore**: abstraction for provider-agnostic file I/O (S3, local, etc.).\n `planFile(asset, opts)` resolves a recoverable URI before bytes are written;\n persist it before `preserveFile(asset, bytes, opts)`. Preservation adopts equal\n existing bytes and rejects changed bytes, changed resolver targets and read\n failures other than not-found. The caller owns receipt fencing/serialization.\n `removeFile(asset)` removes only bytes for recovery cleanup, including an\n already-pruned owner record; `remove(asset)` also deletes the owner record.\n Opt into `asset-local:<key>` writes with\n `{ type: 'local', basePath: absoluteRoot, locatorMode: 'relative' }`.\n Keep the root app-owned; portable paths must resolve beneath it without links.\n See [portable local storage](README.md#portable-local-storage) for adoption and\n the legacy locator boundary.\n- **Ownership rule**: base/domain-owned asset relationships should live on noun join tables such as `content_assets`, `profile_assets`, `event_assets`, `place_assets`, and `product_assets`; keep `AssetAssociation` for generic/provenance links like image derivation.\n\n## Runtime surface\n\nApps and agents should depend on the public **asset runtime** rather than hand-wiring a collection + store per-package (#1128).\n\n- `createAssetRuntime({ db, storage })` → `AssetRuntime` bundling `AssetCollection`, `AssetAssociationCollection`, and an initialized `AssetStore`.\n- `AssetRuntime.storeSourceAsset(name, data, opts)` — create a new source asset (record + bytes).\n- `AssetRuntime.storeDerivedAsset(source, name, data, opts)` — create a derivative with `sourceAssetId` set and (by default) a provenance `AssetAssociation` under a chosen role.\n- `AssetRuntime.linkDerivation(source, derivative, { role })` — record provenance without touching bytes.\n- `AssetRuntime.setExtractionStatus(asset, status, { error?, extractedAt? })` — write canonical extraction metadata into the asset's description JSON sidecar. Non-destructive: if `description` is free-form prose or non-object JSON, the original value is preserved under the reserved `text` key instead of being overwritten. Existing JSON objects are merged into.\n\n- `AssetRuntime.getPrivateAssetMetadata({ tenantId, actorUserId, assetId })` → `PrivateAssetMetadata | null` — authorized, tenant-scoped display metadata read of one PRIVATE asset so hosts never read `assets` rows. Trusted server capability (host authorizes first); requires an ambient tenant actor matching `tenantId`/`actorUserId` exactly (throws otherwise, including empty ids). Result is an allowlist (`id, tenantId, name, mimeType, version, typeSlug, statusSlug, createdAt, updatedAt`); never owner, `sourceUri`, description/metadata sidecars. There is no size field on `Asset`. Missing, public and other-tenant assets all return `null`. Internally resolves the owner from the tenant-scoped private row, then reads through the guarded collection inside a one-id `withPrivateAssetAccess` that closes on return; inside an existing scope it can only narrow (throws `cannot widen` otherwise).\n\nAgents that need asset I/O should accept an `AssetRuntimeLike` in their options rather than asking callers to pass a store + collection separately.\n\n## Serving contract\n\n- `serveAsset({ runtime, asset, tenantId?, disposition?, canAccess?, headers?, remoteMode? })` → standard Web `Response`.\n - `404` when the id doesn't resolve; `403` when the tenant mismatches or `canAccess` denies; `302` when `remoteMode: 'redirect'` and the asset's `sourceUri` is `http(s)`; `502` when `remoteMode: 'proxy'` and the origin fetch fails; `500` on store read errors or unexpected failures; `200` otherwise with `Content-Type`, `Content-Length`, and `Content-Disposition` set.\n - Assets whose `sourceUri` is `http(s)` are supported via `remoteMode`: `'proxy'` (default, fetch and return bytes), `'redirect'` (302 to the origin), or `'error'` (treat as misconfiguration). Pass `fetchImpl` to swap the fetch client.\n - `Content-Disposition` uses an ASCII-safe quoted `filename` fallback and retains the Unicode download name in UTF-8 `filename*` ([RFC 6266](https://www.rfc-editor.org/rfc/rfc6266#section-4.3), [RFC 8187](https://www.rfc-editor.org/rfc/rfc8187#section-3.2.1)). Both names strip C0/DEL/C1 controls and replace `\"` / `\\` / `/` to prevent header injection; isolated UTF-16 surrogates become U+FFFD before encoding, while valid pairs are preserved.\n - The 500 body is a generic `'Internal error serving asset'`; the underlying error is logged via `console.error` so operators can debug without leaking paths/bucket names to clients.\n - Works in SvelteKit `+server.ts` endpoints, Hono, and any runtime with a global `Response` (Node 18+). Pass `responseCtor` for older runtimes.\n- `resolveAssetForServing(options)` → `{ asset, data, contentType, filename, size }` when callers want to render their own framework response. Throws `AssetServeError(status)` on the same failure modes.\n\n## Source/derived vocabulary\n\nThe following roles are exported as `ASSET_ROLES` and should be preferred over ad-hoc strings when apps want cross-package tooling (serving, UI pickers) to agree on meaning:\n\n| Role | Use |\n|------|-----|\n| `source_document` | original upstream document (agenda PDF, minutes) |\n| `document_image` | page/extracted image derived from a source document |\n| `thumbnail` | preview rendition of another asset |\n| `proof` | non-canonical evidence asset backing a fact |\n| `derivation_source` | \"came from\" link on generated media |\n| `attachment` | generic owner-join link |\n| `hero` | primary/featured asset on an owner |\n\nCanonical metadata keys are exported as `ASSET_METADATA_KEYS`: `extractionStatus`, `extractionError`, `extractedAt`, `sourceUrl`, `sourceHash`, `pageNumber`. Extraction status values live in `ASSET_EXTRACTION_STATUS` (`pending | running | succeeded | failed`).\n\n## UI Registry\n\nThe `./ui` subpath exports `ASSETS_MODULE_META` and `ASSETS_UI_SLOTS` so registry-driven hosts (smrt-chat, dynamic admin shells) can discover the package's Svelte components without a hard import.\n\n```ts\nimport { ASSETS_MODULE_META, ASSETS_UI_SLOTS } from '@happyvertical/smrt-assets/ui';\nimport '@happyvertical/smrt-assets/svelte'; // side-effect: ModuleUIRegistry.register(...)\nimport { ModuleUIRegistry } from '@happyvertical/smrt-ui/registry';\n\nconst AssetManager = ModuleUIRegistry.get('@happyvertical/smrt-assets', 'asset-manager');\n```\n\nRegistered slots: `asset-manager` (admin), `asset-grid` / `asset-list` (list), `asset-detail` (detail), `asset-toolbar` / `asset-action-bar` (action), `asset-create-modal` (form). Slot IDs are stable contracts — host apps reference them by string.\n\n## Gotchas\n\n- **Files SDK is a lazy boundary (#1979)**: `AssetStore` loads `@happyvertical/files` through `src/files-runtime.ts` (bundler-invisible), because smrt-assets is reachable from provider-neutral consumer graphs via profiles. Node/tsx/vite-dev runtimes resolve it on first file operation; fully-bundled deployments import `@happyvertical/smrt-assets/filesystem` at startup. Never import the files SDK statically from modules reachable from `src/index.ts`.\n- **Version history manual**: `findVersions()` chaining required — no ORM shortcut\n- **Tag management uses raw SQL**: `asset_tags` is a join table, not an SMRT model\n- **Folder tree traversal**: via `SmrtHierarchical` (`getParent`/`getChildren`/`getAncestors`/`getDescendants`/`getHierarchy`/`moveTo`); `FolderCollection.getTree(rootId?)` and `getPath(folderId)` wrap these for convenience\n- **AssetAssociation polymorphic FK**: requires manual `metaType` string matching\n- **Optional tenancy**: assets can be global (tenantId=null) or tenant-scoped\n\n## Private records\n\n`Asset.accessMode` and the mandatory owning interceptor protect private records\nacross generated and parent STI surfaces. Use the exact actor/owner/ID capability\nonly after host authorization; see [private assets](agents/private-assets.md).\nFor display metadata (name, mime type, version) use `AssetRuntime.getPrivateAssetMetadata`\ninstead of reading raw `assets` rows to discover the owner.\n",
3725
3727
  "moduleDocs": [
3728
+ {
3729
+ "path": "README.md",
3730
+ "module": "README",
3731
+ "content": "# @happyvertical/smrt-assets\n\nProvider-agnostic asset management with versioning, type classification, metadata fields, and generic/provenance associations.\n\n`AssetAssociation` is the generic exception path for linking assets to arbitrary\nobjects when there is not a model-owned noun join table. Base/domain-owned\nrelationships should use dedicated joins such as `content_assets`,\n`profile_assets`, `event_assets`, `place_assets`, and `product_assets`.\n\n## Feature recipes\n\n`assets.library` provides the model-backed file and media library: assets,\nfolders, classifications, statuses, and metadata definitions.\n`assets.attachments` adds record attachment provenance and requires the library.\nThey share the **Files and media** catalog card and the **Assets** navigation\nsection, and both embed user-facing help in the generated manifest. The recipes\npublish browser-safe mock fixture exports from `@happyvertical/smrt-assets/playground`.\n`AssetManager` needs host persistence callbacks and `AttachmentPanel` needs\nrecord-scoped authorized attachments, so neither is declared as a standalone\nplacement. Storage providers remain application-owned, so the recipes declare\nno provider.\n\nThe package playground is a Mock preview. Its asset grid uses in-memory props\nand data-URI thumbnails, and its attachment panel demonstrates supplied native\nform data only. It never performs a real network upload or creates public\nstorage URLs.\n\n## Installation\n\n```bash\npnpm add @happyvertical/smrt-assets\n```\n\n## Usage\n\n```typescript\nimport {\n Asset, AssetCollection,\n AssetType, AssetStatus, AssetMetafield,\n AssetAssociation, AssetAssociationCollection,\n Folder, FolderCollection,\n AssetStore,\n} from '@happyvertical/smrt-assets';\n\n// Create lookup records\nconst imageType = new AssetType({ slug: 'image', name: 'Image' });\nawait imageType.save();\n\nconst published = new AssetStatus({ slug: 'published', name: 'Published' });\nawait published.save();\n\n// Create an asset\nconst photo = new Asset({\n name: 'Product Photo',\n slug: 'product-photo-001',\n sourceUri: 's3://bucket/products/photo-001.jpg',\n mimeType: 'image/jpeg',\n typeSlug: 'image',\n statusSlug: 'published',\n version: 1,\n});\nawait photo.save();\n\n// Versioning -- chain via primaryVersionId, increment version number\nconst v2 = new Asset({\n ...photo, slug: 'product-photo-002', version: 2, primaryVersionId: photo.id,\n sourceUri: 's3://bucket/products/photo-002.jpg',\n});\nawait v2.save();\n\n// Derivatives via sourceAssetId (renamed from `parentId` in R3-D)\nconst thumb = new Asset({\n name: 'Thumbnail', slug: 'product-photo-001-thumb', sourceAssetId: photo.id,\n sourceUri: 's3://bucket/products/photo-001-thumb.jpg',\n mimeType: 'image/jpeg', typeSlug: 'image', statusSlug: 'published',\n});\nawait thumb.save();\n\n// Generic/provenance association -- link asset to an arbitrary object\nconst assoc = new AssetAssociation({\n assetId: photo.id,\n metaType: 'Image',\n metaId: 'derived-image-123',\n role: 'derivation-source',\n sortOrder: 0,\n});\nawait assoc.save();\n\n// Base/domain-owned asset relationships should use dedicated noun joins instead:\n// content_assets, profile_assets, event_assets, place_assets, product_assets\n\n// Folder organization (its own SmrtHierarchical model, `folders` table)\nconst folder = new Folder({ name: 'Product Images', slug: 'product-images' });\nawait folder.save();\n// Move an asset into a folder\nphoto.folderId = folder.id;\nawait photo.save();\n\n// AssetStore -- provider-agnostic file I/O + record creation\nconst store = await new AssetStore(assetRoot, collection).initialize();\nawait store.store('screenshot', buffer, { mimeType: 'image/png' });\n```\n\n## Portable local storage\n\nFor a new desktop installation, pass the same portable storage configuration\nto each asset runtime, worker, and service that handles its managed files:\n\n```ts\nconst assets = await createAssetRuntime({\n db,\n storage: { type: 'local', basePath: assetRoot, locatorMode: 'relative' },\n});\n```\n\nUse an absolute, app-owned `assetRoot`. The store persists\n`asset-local:<key>`, for example `asset-local:document/17f6.txt`.\nThe key is a raw, slash-separated path under the configured root and\ncontains no URL escaping. Use ASCII letters, digits, underscores, and\nhyphens in type slugs and IDs. The store rejects traversal, absolute keys,\nWindows device names, links at or below the root, and non-regular files. Keep\nthe root and its contents under app control; the filesystem checks assume\nno concurrent changes by an untrusted local process.\n\nWhen copying an installation, copy the database and the asset directory\ntogether, keep each file's path within the directory, and set `basePath`\nto the copied directory. Read, preserve, and remove assets through the\nruntime. A storage resolver may choose a path for a portable write, but\nlater reads and deletes must use the stored key in the built-in local\nfilesystem for that runtime.\n\nThe option changes new writes only. Existing local options and S3\nlocators keep their formats. A built-in local store can read portable\nlocators whether or not it opts in to writing them. In portable mode,\nan existing `file://` locator can still be read or removed when it\nidentifies a valid key inside the configured root; changing the root\ndoes not relocate such records. Start with fresh desktop data or handle\nexisting absolute locators before moving an installation.\n\n## API\n\n### Models (SmrtObject)\n\n| Export | Description |\n|--------|------------|\n| `Asset` | Core asset with versioning (`primaryVersionId`, `version`), derivation chain (`sourceAssetId`), `sourceUri`, `mimeType`, `typeSlug`, `statusSlug`, `ownerProfileId` |\n| `AssetAssociation` | Generic/provenance polymorphic join: `assetId` + `metaType` + `metaId` + `role` + `sortOrder`; not for base/domain-owned joins that already have noun tables |\n| `AssetType` | Lookup table for asset type classification |\n| `AssetStatus` | Lookup table for lifecycle status |\n| `AssetMetafield` | Custom metadata field definitions with JSON validation rules |\n| `Folder` | Hierarchical container for assets; own `folders` table extending `SmrtHierarchical` |\n\n### Collections (SmrtCollection)\n\n| Export | Description |\n|--------|------------|\n| `AssetCollection` | Collection for Asset |\n| `AssetAssociationCollection` | Collection for AssetAssociation |\n| `AssetTypeCollection` | Collection for AssetType |\n| `AssetStatusCollection` | Collection for AssetStatus |\n| `AssetMetafieldCollection` | Collection for AssetMetafield |\n| `FolderCollection` | Collection for Folder |\n\n### Utilities\n\n| Export | Description |\n|--------|------------|\n| `AssetStore` | Provider-agnostic file I/O that writes buffers to storage and creates Asset records |\n\n### Types\n\n| Export | Description |\n|--------|------------|\n| `AssetOptions` | Options for `Asset` constructor |\n| `AssetAssociationOptions` | Options for `AssetAssociation` constructor |\n| `AssetTypeOptions` | Options for `AssetType` constructor |\n| `AssetStatusOptions` | Options for `AssetStatus` constructor |\n| `AssetMetafieldOptions` | Options for `AssetMetafield` constructor |\n| `FolderOptions` | Options for `Folder` constructor |\n| `StoreOptions` | Options for `AssetStore.store()` |\n| `ProviderOptions` | Provider configuration for `AssetStore` |\n\n## Dependencies\n\n| Package | Purpose |\n|---------|---------|\n| `@happyvertical/smrt-core` | ORM base (SmrtObject, SmrtCollection) |\n| `@happyvertical/smrt-tags` | Tag integration (`addTag`/`removeTag` on assets) |\n| `@happyvertical/smrt-tenancy` | Optional tenant scoping |\n| `@happyvertical/files` | Provider-agnostic filesystem for AssetStore |\n\n## Native private attachments\n\n`AttachmentPanel`, `AttachmentList` and `AttachmentUpload` compose authorized\nprivate links, caller-supplied version history, and native multipart uploads.\nThey preserve request identity and failed-action metadata without deriving\npublic storage URLs. See [the attachment contract](agents/attachments.md) for\npublic types, native payloads, recovery, and server responsibilities.\n\nPass `onremove(attachment)` and/or `removeAction` (native POST of the\nattachment id) to add a confirmed per-attachment Remove button; see\n\"Removing attachments\" in the contract.\n\n### Polymorphic junction collection types\n\n`AssetAssociationCollection` extends `SmrtJunctionBase`, sharing `byRight`,\nordering, positioning, and registration guards with ordinary junctions. Its\n`byLeft`, `attach`, `detach`, and `setLinks` methods still require both `metaType`\nand `metaId`; they do not implement the single-owner `SmrtJunction` contract.\nUse `instanceof SmrtJunctionBase` when recognizing either kind of junction.\nAsset associations no longer satisfy `instanceof SmrtJunction`.\n\nAfter building the workspace, `node scripts/verify-packed-junction-types.mjs`\nchecks actual core/assets tarballs in the standard Bundler mode with\n`skipLibCheck: false`, inherited result types, and negative owner-argument tests.\nFull NodeNext declaration portability is tracked separately in #3524.\n\nThe consumer fixture installs declared dependencies in a temporary directory\nwith no ancestor `node_modules`; it never links producer dependencies. It retains\nthe project’s public registry routing without copying credentials. Set\n`SMRT_PACKED_EVIDENCE_DIR` to retain tarballs and the consumer lockfile. For an\nexplicitly separate upstream-candidate proof, `SMRT_PACKED_OVERRIDES` may name\na JSON file of pnpm overrides; such a proof does not establish that the normal\npublished dependency graph passes.\n"
3732
+ },
3726
3733
  {
3727
3734
  "path": "agents/private-assets.md",
3728
3735
  "module": "private-assets",
@@ -0,0 +1,110 @@
1
+ ---
2
+ type: "Component"
3
+ title: "@happyvertical/smrt-assets"
4
+ description: "Asset management system with versioning, metadata, and AI-powered operations for SMRT framework"
5
+ status: "stable"
6
+ generated:
7
+ by: "smrt/scripts/generate-knowledge-okf.ts"
8
+ at: "2026-11-06T01:23:41Z"
9
+ audience: "internal"
10
+ evidence_level: "source-inspected"
11
+ source_revision: "sha256:73bdc0cbe39f1720505c0abd7438920e0e7d167f84e8ca629c3cb40127d8027c"
12
+ sources:
13
+ - id: "manifest"
14
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/assets/package.json"
15
+ title: "@happyvertical/smrt-assets package manifest"
16
+ - id: "agents"
17
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/assets/AGENTS.md"
18
+ title: "@happyvertical/smrt-assets packages/assets/AGENTS.md"
19
+ - id: "agents-2"
20
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/assets/README.md"
21
+ title: "@happyvertical/smrt-assets packages/assets/README.md"
22
+ - id: "agents-3"
23
+ resource: "https://github.com/happyvertical/smrt/blob/main/packages/assets/agents/private-assets.md"
24
+ title: "@happyvertical/smrt-assets packages/assets/agents/private-assets.md"
25
+ ---
26
+
27
+ # @happyvertical/smrt-assets
28
+
29
+ ## Package
30
+
31
+ - Directory: `packages/assets`
32
+ - Private: no
33
+ - Object source: `domain-artifact`
34
+ - Evidence level: `source-inspected`
35
+
36
+ ## Documentation
37
+
38
+ - `packages/assets/AGENTS.md`
39
+ - `packages/assets/README.md`
40
+ - `packages/assets/agents/private-assets.md`
41
+
42
+ ## Framework dependencies
43
+
44
+ - [smrt-core](/components/smrt-core.md)
45
+ - [smrt-playground](/components/smrt-playground.md)
46
+ - [smrt-tags](/components/smrt-tags.md)
47
+ - [smrt-tenancy](/components/smrt-tenancy.md)
48
+ - [smrt-types](/components/smrt-types.md)
49
+ - [smrt-ui](/components/smrt-ui.md)
50
+ - [smrt-vitest](/components/smrt-vitest.md)
51
+
52
+ ## SDK dependencies
53
+
54
+ - `@happyvertical/ai`
55
+ - `@happyvertical/files`
56
+ - `@happyvertical/logger`
57
+ - `@happyvertical/sql`
58
+ - `@happyvertical/utils`
59
+
60
+ ## Exports
61
+
62
+ - `.`
63
+ - `./filesystem`
64
+ - `./locator`
65
+ - `./manifest`
66
+ - `./manifest.json`
67
+ - `./playground`
68
+ - `./svelte`
69
+ - `./ui`
70
+ - `./workbench`
71
+
72
+ ## Models
73
+
74
+ - `Asset` (collection `assets`, extends `SmrtObject`, STI table)
75
+ - `AssetAssociation` (collection `assetassociations`, extends `SmrtPolymorphicAssociation`)
76
+ - `AssetAssociationCollection` (collection `assetassociations`, extends `SmrtJunctionBase`)
77
+ - `AssetCollection` (collection `assets`, extends `SmrtCollection`)
78
+ - `AssetMetafield` (collection `assetmetafields`, extends `SmrtObject`, STI table)
79
+ - `AssetMetafieldCollection` (collection `assetmetafields`, extends `SmrtCollection`)
80
+ - `AssetStatus` (collection `assetstatuses`, extends `SmrtObject`, STI table)
81
+ - `AssetStatusCollection` (collection `assetstatuses`, extends `SmrtCollection`)
82
+ - `AssetTag` (collection `assettags`, extends `SmrtObject`)
83
+ - `AssetTagCollection` (collection `assettags`, extends `SmrtJunction`)
84
+ - `AssetType` (collection `assettypes`, extends `SmrtObject`, STI table)
85
+ - `AssetTypeCollection` (collection `assettypes`, extends `SmrtCollection`)
86
+ - `Folder` (collection `folders`, extends `SmrtHierarchical`)
87
+ - `FolderCollection` (collection `folders`, extends `SmrtCollection`)
88
+
89
+ ## MCP tools
90
+
91
+ - `asset_create`: create on `@happyvertical/smrt-assets:Asset`
92
+ - `asset_get`: get on `@happyvertical/smrt-assets:Asset`
93
+ - `asset_list`: list on `@happyvertical/smrt-assets:Asset`
94
+ - `asset_update`: update on `@happyvertical/smrt-assets:Asset`
95
+ - `assetassociation_create`: create on `@happyvertical/smrt-assets:AssetAssociation`
96
+ - `assetassociation_get`: get on `@happyvertical/smrt-assets:AssetAssociation`
97
+ - `assetassociation_list`: list on `@happyvertical/smrt-assets:AssetAssociation`
98
+ - `assetmetafield_create`: create on `@happyvertical/smrt-assets:AssetMetafield`
99
+ - `assetmetafield_get`: get on `@happyvertical/smrt-assets:AssetMetafield`
100
+ - `assetmetafield_list`: list on `@happyvertical/smrt-assets:AssetMetafield`
101
+ - `assetstatus_create`: create on `@happyvertical/smrt-assets:AssetStatus`
102
+ - `assetstatus_get`: get on `@happyvertical/smrt-assets:AssetStatus`
103
+ - `assetstatus_list`: list on `@happyvertical/smrt-assets:AssetStatus`
104
+ - `assettype_create`: create on `@happyvertical/smrt-assets:AssetType`
105
+ - `assettype_get`: get on `@happyvertical/smrt-assets:AssetType`
106
+ - `assettype_list`: list on `@happyvertical/smrt-assets:AssetType`
107
+ - `folder_create`: create on `@happyvertical/smrt-assets:Folder`
108
+ - `folder_get`: get on `@happyvertical/smrt-assets:Folder`
109
+ - `folder_list`: list on `@happyvertical/smrt-assets:Folder`
110
+ - `folder_update`: update on `@happyvertical/smrt-assets:Folder`