@murumets-ee/entity 0.9.0 → 0.10.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/dist/index.d.mts CHANGED
@@ -404,10 +404,22 @@ declare const behavior: {
404
404
  interface CountCacheLike {
405
405
  get(key: string): number | undefined;
406
406
  set(key: string, count: number): void;
407
+ /**
408
+ * Cache-or-compute with single-flight semantics.
409
+ *
410
+ * If the entry is cached and unexpired, returns it immediately (no promise
411
+ * allocation in the hot path). Otherwise, if a refresh is already in flight
412
+ * for the same key, returns that in-flight promise instead of starting a
413
+ * second one — preventing the thundering-herd burst of identical
414
+ * `count(*)` queries when N concurrent requests cross the TTL boundary
415
+ * together.
416
+ */
417
+ getOrCompute(key: string, compute: () => Promise<number>): Promise<number> | number;
407
418
  invalidate(prefix: string): void;
408
419
  }
409
420
  declare class CountCache implements CountCacheLike {
410
421
  private cache;
422
+ private inflight;
411
423
  private ttlMs;
412
424
  constructor(ttlMs?: number);
413
425
  /**
@@ -419,10 +431,23 @@ declare class CountCache implements CountCacheLike {
419
431
  */
420
432
  set(key: string, count: number): void;
421
433
  /**
422
- * Invalidate all cache entries whose key starts with the given prefix.
423
- * Typically called with the entity name after mutations (create/update/delete).
434
+ * Cache-or-compute with single-flight semantics. See `CountCacheLike` doc.
435
+ *
436
+ * Cache hits return synchronously (the call site keeps the await but no
437
+ * actual microtask is scheduled). Cache misses register an in-flight
438
+ * promise so concurrent callers share one DB round-trip; the promise is
439
+ * removed once it resolves (or rejects) so the next miss can refresh.
440
+ * On rejection, nothing is cached — the next caller retries.
424
441
  */
425
- invalidate(prefix: string): void;
442
+ getOrCompute(key: string, compute: () => Promise<number>): Promise<number> | number;
443
+ /**
444
+ * Invalidate all cache entries for a given entity name.
445
+ * Matches the exact entity name OR any key where the entity is followed
446
+ * by one of the cache-key separators (`:` for WHERE, `@` for scope).
447
+ * Avoids accidental cross-entity invalidation (e.g. invalidating 'user'
448
+ * must not clear 'users:where=...' entries).
449
+ */
450
+ invalidate(entityName: string): void;
426
451
  /**
427
452
  * Remove all expired entries. Useful for periodic cleanup in long-running processes.
428
453
  */
@@ -584,42 +609,6 @@ declare function defineEntity<F extends Record<string, FieldConfig>, const B ext
584
609
  id: IdField;
585
610
  } & ExtractBehaviorFields<B> & F>;
586
611
  //#endregion
587
- //#region src/shared/entity-data-ops.d.ts
588
- /**
589
- * Security context resolved per-request. Provided by the consumer
590
- * (e.g., via React.cache() in Next.js, or runAsCli for CLI).
591
- * The entity package has zero knowledge of how this is resolved.
592
- */
593
- interface SecurityContext {
594
- user: {
595
- id: string;
596
- groups: string[];
597
- name?: string;
598
- email?: string;
599
- };
600
- checker: (role: string, resource: string, action: string) => boolean;
601
- scope?: {
602
- type: string;
603
- id: string;
604
- };
605
- }
606
- /**
607
- * Function that resolves the current request's security context.
608
- * Injected at construction time — the entity package never imports
609
- * @murumets-ee/core or any framework-specific code.
610
- *
611
- * Returns undefined only when intentionally skipping enforcement
612
- * (should not happen in production — throw ForbiddenError instead).
613
- */
614
- type ContextResolver = () => SecurityContext | undefined | Promise<SecurityContext | undefined>;
615
- /**
616
- * Thrown when a user lacks permission for an entity operation.
617
- * Consumers (api-handler) catch this and return HTTP 403.
618
- */
619
- declare class ForbiddenError extends Error {
620
- constructor(message: string);
621
- }
622
- //#endregion
623
612
  //#region src/refs/find-usages.d.ts
624
613
  interface EntityUsage {
625
614
  sourceEntity: string;
@@ -856,8 +845,18 @@ declare function needsLocaleStatus(entity: Entity): boolean;
856
845
  * Check if an entity is publishable (has publishable() behavior).
857
846
  */
858
847
  declare function isPublishable(entity: Entity): boolean;
859
- /** Per-locale publish status table for publishable + translatable entities. */
860
- declare function generateLocaleStatusSchema(entity: Entity, parent: PgTable): _$drizzle_orm_pg_core0.PgTableWithColumns<{
848
+ /**
849
+ * Check if an entity has blocks fields with translatable block content (non-localized mode).
850
+ */
851
+ declare function hasTranslatableBlocks(entity: Entity): boolean;
852
+ /**
853
+ * Generate layout translation table for non-localized blocks with translatable fields.
854
+ *
855
+ * `layoutParent` is optional — when provided, emits a `.references()` FK
856
+ * pointing at the corresponding `{entity}_layout` table (for migration
857
+ * generation).
858
+ */
859
+ declare function generateLayoutTranslationSchema(entity: Entity, layoutParent?: PgTable): _$drizzle_orm_pg_core0.PgTableWithColumns<{
861
860
  name: string;
862
861
  schema: undefined;
863
862
  columns: {
@@ -878,8 +877,8 @@ declare function generateLocaleStatusSchema(entity: Entity, parent: PgTable): _$
878
877
  identity: undefined;
879
878
  generated: undefined;
880
879
  }, {}, {}>;
881
- entityId: _$drizzle_orm_pg_core0.PgColumn<{
882
- name: "entity_id";
880
+ layoutId: _$drizzle_orm_pg_core0.PgColumn<{
881
+ name: "layout_id";
883
882
  tableName: string;
884
883
  dataType: "string";
885
884
  columnType: "PgUUID";
@@ -914,625 +913,8 @@ declare function generateLocaleStatusSchema(entity: Entity, parent: PgTable): _$
914
913
  }, {}, {
915
914
  length: 10;
916
915
  }>;
917
- status: _$drizzle_orm_pg_core0.PgColumn<{
918
- name: "status";
919
- tableName: string;
920
- dataType: "string";
921
- columnType: "PgVarchar";
922
- data: string;
923
- driverParam: string;
924
- notNull: true;
925
- hasDefault: true;
926
- isPrimaryKey: false;
927
- isAutoincrement: false;
928
- hasRuntimeDefault: false;
929
- enumValues: [string, ...string[]];
930
- baseColumn: never;
931
- identity: undefined;
932
- generated: undefined;
933
- }, {}, {
934
- length: 20;
935
- }>;
936
- publishedAt: _$drizzle_orm_pg_core0.PgColumn<{
937
- name: "published_at";
938
- tableName: string;
939
- dataType: "date";
940
- columnType: "PgTimestamp";
941
- data: Date;
942
- driverParam: string;
943
- notNull: false;
944
- hasDefault: false;
945
- isPrimaryKey: false;
946
- isAutoincrement: false;
947
- hasRuntimeDefault: false;
948
- enumValues: undefined;
949
- baseColumn: never;
950
- identity: undefined;
951
- generated: undefined;
952
- }, {}, {}>;
953
- };
954
- dialect: "pg";
955
- }>;
956
- /** Drafts overlay table for publishable entities. */
957
- declare function generateDraftsSchema(entity: Entity, parent: PgTable): _$drizzle_orm_pg_core0.PgTableWithColumns<{
958
- name: string;
959
- schema: undefined;
960
- columns: {
961
- id: _$drizzle_orm_pg_core0.PgColumn<{
962
- name: "id";
963
- tableName: string;
964
- dataType: "string";
965
- columnType: "PgUUID";
966
- data: string;
967
- driverParam: string;
968
- notNull: true;
969
- hasDefault: true;
970
- isPrimaryKey: true;
971
- isAutoincrement: false;
972
- hasRuntimeDefault: false;
973
- enumValues: undefined;
974
- baseColumn: never;
975
- identity: undefined;
976
- generated: undefined;
977
- }, {}, {}>;
978
- entityId: _$drizzle_orm_pg_core0.PgColumn<{
979
- name: "entity_id";
980
- tableName: string;
981
- dataType: "string";
982
- columnType: "PgUUID";
983
- data: string;
984
- driverParam: string;
985
- notNull: true;
986
- hasDefault: false;
987
- isPrimaryKey: false;
988
- isAutoincrement: false;
989
- hasRuntimeDefault: false;
990
- enumValues: undefined;
991
- baseColumn: never;
992
- identity: undefined;
993
- generated: undefined;
994
- }, {}, {}>;
995
- locale: _$drizzle_orm_pg_core0.PgColumn<{
996
- name: "locale";
997
- tableName: string;
998
- dataType: "string";
999
- columnType: "PgVarchar";
1000
- data: string;
1001
- driverParam: string;
1002
- notNull: true;
1003
- hasDefault: true;
1004
- isPrimaryKey: false;
1005
- isAutoincrement: false;
1006
- hasRuntimeDefault: false;
1007
- enumValues: [string, ...string[]];
1008
- baseColumn: never;
1009
- identity: undefined;
1010
- generated: undefined;
1011
- }, {}, {
1012
- length: 10;
1013
- }>;
1014
- data: _$drizzle_orm_pg_core0.PgColumn<{
1015
- name: "data";
1016
- tableName: string;
1017
- dataType: "json";
1018
- columnType: "PgJsonb";
1019
- data: unknown;
1020
- driverParam: unknown;
1021
- notNull: true;
1022
- hasDefault: false;
1023
- isPrimaryKey: false;
1024
- isAutoincrement: false;
1025
- hasRuntimeDefault: false;
1026
- enumValues: undefined;
1027
- baseColumn: never;
1028
- identity: undefined;
1029
- generated: undefined;
1030
- }, {}, {}>;
1031
- createdBy: _$drizzle_orm_pg_core0.PgColumn<{
1032
- name: "created_by";
1033
- tableName: string;
1034
- dataType: "string";
1035
- columnType: "PgVarchar";
1036
- data: string;
1037
- driverParam: string;
1038
- notNull: true;
1039
- hasDefault: false;
1040
- isPrimaryKey: false;
1041
- isAutoincrement: false;
1042
- hasRuntimeDefault: false;
1043
- enumValues: [string, ...string[]];
1044
- baseColumn: never;
1045
- identity: undefined;
1046
- generated: undefined;
1047
- }, {}, {
1048
- length: 255;
1049
- }>;
1050
- createdByName: _$drizzle_orm_pg_core0.PgColumn<{
1051
- name: "created_by_name";
1052
- tableName: string;
1053
- dataType: "string";
1054
- columnType: "PgVarchar";
1055
- data: string;
1056
- driverParam: string;
1057
- notNull: false;
1058
- hasDefault: false;
1059
- isPrimaryKey: false;
1060
- isAutoincrement: false;
1061
- hasRuntimeDefault: false;
1062
- enumValues: [string, ...string[]];
1063
- baseColumn: never;
1064
- identity: undefined;
1065
- generated: undefined;
1066
- }, {}, {
1067
- length: 255;
1068
- }>;
1069
- createdAt: _$drizzle_orm_pg_core0.PgColumn<{
1070
- name: "created_at";
1071
- tableName: string;
1072
- dataType: "date";
1073
- columnType: "PgTimestamp";
1074
- data: Date;
1075
- driverParam: string;
1076
- notNull: true;
1077
- hasDefault: true;
1078
- isPrimaryKey: false;
1079
- isAutoincrement: false;
1080
- hasRuntimeDefault: false;
1081
- enumValues: undefined;
1082
- baseColumn: never;
1083
- identity: undefined;
1084
- generated: undefined;
1085
- }, {}, {}>;
1086
- updatedAt: _$drizzle_orm_pg_core0.PgColumn<{
1087
- name: "updated_at";
1088
- tableName: string;
1089
- dataType: "date";
1090
- columnType: "PgTimestamp";
1091
- data: Date;
1092
- driverParam: string;
1093
- notNull: true;
1094
- hasDefault: true;
1095
- isPrimaryKey: false;
1096
- isAutoincrement: false;
1097
- hasRuntimeDefault: false;
1098
- enumValues: undefined;
1099
- baseColumn: never;
1100
- identity: undefined;
1101
- generated: undefined;
1102
- }, {}, {}>;
1103
- };
1104
- dialect: "pg";
1105
- }>;
1106
- /** Versions history table for versionable entities. */
1107
- declare function generateVersionsSchema(entity: Entity, parent: PgTable): _$drizzle_orm_pg_core0.PgTableWithColumns<{
1108
- name: string;
1109
- schema: undefined;
1110
- columns: {
1111
- id: _$drizzle_orm_pg_core0.PgColumn<{
1112
- name: "id";
1113
- tableName: string;
1114
- dataType: "string";
1115
- columnType: "PgUUID";
1116
- data: string;
1117
- driverParam: string;
1118
- notNull: true;
1119
- hasDefault: true;
1120
- isPrimaryKey: true;
1121
- isAutoincrement: false;
1122
- hasRuntimeDefault: false;
1123
- enumValues: undefined;
1124
- baseColumn: never;
1125
- identity: undefined;
1126
- generated: undefined;
1127
- }, {}, {}>;
1128
- entityId: _$drizzle_orm_pg_core0.PgColumn<{
1129
- name: "entity_id";
1130
- tableName: string;
1131
- dataType: "string";
1132
- columnType: "PgUUID";
1133
- data: string;
1134
- driverParam: string;
1135
- notNull: true;
1136
- hasDefault: false;
1137
- isPrimaryKey: false;
1138
- isAutoincrement: false;
1139
- hasRuntimeDefault: false;
1140
- enumValues: undefined;
1141
- baseColumn: never;
1142
- identity: undefined;
1143
- generated: undefined;
1144
- }, {}, {}>;
1145
- version: _$drizzle_orm_pg_core0.PgColumn<{
1146
- name: "version";
1147
- tableName: string;
1148
- dataType: "number";
1149
- columnType: "PgInteger";
1150
- data: number;
1151
- driverParam: string | number;
1152
- notNull: true;
1153
- hasDefault: false;
1154
- isPrimaryKey: false;
1155
- isAutoincrement: false;
1156
- hasRuntimeDefault: false;
1157
- enumValues: undefined;
1158
- baseColumn: never;
1159
- identity: undefined;
1160
- generated: undefined;
1161
- }, {}, {}>;
1162
- locale: _$drizzle_orm_pg_core0.PgColumn<{
1163
- name: "locale";
1164
- tableName: string;
1165
- dataType: "string";
1166
- columnType: "PgVarchar";
1167
- data: string;
1168
- driverParam: string;
1169
- notNull: true;
1170
- hasDefault: true;
1171
- isPrimaryKey: false;
1172
- isAutoincrement: false;
1173
- hasRuntimeDefault: false;
1174
- enumValues: [string, ...string[]];
1175
- baseColumn: never;
1176
- identity: undefined;
1177
- generated: undefined;
1178
- }, {}, {
1179
- length: 10;
1180
- }>;
1181
- data: _$drizzle_orm_pg_core0.PgColumn<{
1182
- name: "data";
1183
- tableName: string;
1184
- dataType: "json";
1185
- columnType: "PgJsonb";
1186
- data: unknown;
1187
- driverParam: unknown;
1188
- notNull: true;
1189
- hasDefault: false;
1190
- isPrimaryKey: false;
1191
- isAutoincrement: false;
1192
- hasRuntimeDefault: false;
1193
- enumValues: undefined;
1194
- baseColumn: never;
1195
- identity: undefined;
1196
- generated: undefined;
1197
- }, {}, {}>;
1198
- delta: _$drizzle_orm_pg_core0.PgColumn<{
1199
- name: "delta";
1200
- tableName: string;
1201
- dataType: "json";
1202
- columnType: "PgJsonb";
1203
- data: unknown;
1204
- driverParam: unknown;
1205
- notNull: false;
1206
- hasDefault: false;
1207
- isPrimaryKey: false;
1208
- isAutoincrement: false;
1209
- hasRuntimeDefault: false;
1210
- enumValues: undefined;
1211
- baseColumn: never;
1212
- identity: undefined;
1213
- generated: undefined;
1214
- }, {}, {}>;
1215
- status: _$drizzle_orm_pg_core0.PgColumn<{
1216
- name: "status";
1217
- tableName: string;
1218
- dataType: "string";
1219
- columnType: "PgVarchar";
1220
- data: string;
1221
- driverParam: string;
1222
- notNull: false;
1223
- hasDefault: false;
1224
- isPrimaryKey: false;
1225
- isAutoincrement: false;
1226
- hasRuntimeDefault: false;
1227
- enumValues: [string, ...string[]];
1228
- baseColumn: never;
1229
- identity: undefined;
1230
- generated: undefined;
1231
- }, {}, {
1232
- length: 20;
1233
- }>;
1234
- createdBy: _$drizzle_orm_pg_core0.PgColumn<{
1235
- name: "created_by";
1236
- tableName: string;
1237
- dataType: "string";
1238
- columnType: "PgVarchar";
1239
- data: string;
1240
- driverParam: string;
1241
- notNull: false;
1242
- hasDefault: false;
1243
- isPrimaryKey: false;
1244
- isAutoincrement: false;
1245
- hasRuntimeDefault: false;
1246
- enumValues: [string, ...string[]];
1247
- baseColumn: never;
1248
- identity: undefined;
1249
- generated: undefined;
1250
- }, {}, {
1251
- length: 255;
1252
- }>;
1253
- createdByName: _$drizzle_orm_pg_core0.PgColumn<{
1254
- name: "created_by_name";
1255
- tableName: string;
1256
- dataType: "string";
1257
- columnType: "PgVarchar";
1258
- data: string;
1259
- driverParam: string;
1260
- notNull: false;
1261
- hasDefault: false;
1262
- isPrimaryKey: false;
1263
- isAutoincrement: false;
1264
- hasRuntimeDefault: false;
1265
- enumValues: [string, ...string[]];
1266
- baseColumn: never;
1267
- identity: undefined;
1268
- generated: undefined;
1269
- }, {}, {
1270
- length: 255;
1271
- }>;
1272
- createdAt: _$drizzle_orm_pg_core0.PgColumn<{
1273
- name: "created_at";
1274
- tableName: string;
1275
- dataType: "date";
1276
- columnType: "PgTimestamp";
1277
- data: Date;
1278
- driverParam: string;
1279
- notNull: true;
1280
- hasDefault: true;
1281
- isPrimaryKey: false;
1282
- isAutoincrement: false;
1283
- hasRuntimeDefault: false;
1284
- enumValues: undefined;
1285
- baseColumn: never;
1286
- identity: undefined;
1287
- generated: undefined;
1288
- }, {}, {}>;
1289
- isAutosave: _$drizzle_orm_pg_core0.PgColumn<{
1290
- name: "is_autosave";
1291
- tableName: string;
1292
- dataType: "boolean";
1293
- columnType: "PgBoolean";
1294
- data: boolean;
1295
- driverParam: boolean;
1296
- notNull: true;
1297
- hasDefault: true;
1298
- isPrimaryKey: false;
1299
- isAutoincrement: false;
1300
- hasRuntimeDefault: false;
1301
- enumValues: undefined;
1302
- baseColumn: never;
1303
- identity: undefined;
1304
- generated: undefined;
1305
- }, {}, {}>;
1306
- };
1307
- dialect: "pg";
1308
- }>;
1309
- /**
1310
- * Shared content locks table — one per project, independent of any entity.
1311
- * Included exactly once in `buildRuntimeSchema()` when any entity is publishable.
1312
- */
1313
- declare function generateContentLocksSchema(): _$drizzle_orm_pg_core0.PgTableWithColumns<{
1314
- name: "toolkit_content_locks";
1315
- schema: undefined;
1316
- columns: {
1317
- id: _$drizzle_orm_pg_core0.PgColumn<{
1318
- name: "id";
1319
- tableName: "toolkit_content_locks";
1320
- dataType: "string";
1321
- columnType: "PgUUID";
1322
- data: string;
1323
- driverParam: string;
1324
- notNull: true;
1325
- hasDefault: true;
1326
- isPrimaryKey: true;
1327
- isAutoincrement: false;
1328
- hasRuntimeDefault: false;
1329
- enumValues: undefined;
1330
- baseColumn: never;
1331
- identity: undefined;
1332
- generated: undefined;
1333
- }, {}, {}>;
1334
- entityType: _$drizzle_orm_pg_core0.PgColumn<{
1335
- name: "entity_type";
1336
- tableName: "toolkit_content_locks";
1337
- dataType: "string";
1338
- columnType: "PgVarchar";
1339
- data: string;
1340
- driverParam: string;
1341
- notNull: true;
1342
- hasDefault: false;
1343
- isPrimaryKey: false;
1344
- isAutoincrement: false;
1345
- hasRuntimeDefault: false;
1346
- enumValues: [string, ...string[]];
1347
- baseColumn: never;
1348
- identity: undefined;
1349
- generated: undefined;
1350
- }, {}, {
1351
- length: 100;
1352
- }>;
1353
- entityId: _$drizzle_orm_pg_core0.PgColumn<{
1354
- name: "entity_id";
1355
- tableName: "toolkit_content_locks";
1356
- dataType: "string";
1357
- columnType: "PgVarchar";
1358
- data: string;
1359
- driverParam: string;
1360
- notNull: true;
1361
- hasDefault: false;
1362
- isPrimaryKey: false;
1363
- isAutoincrement: false;
1364
- hasRuntimeDefault: false;
1365
- enumValues: [string, ...string[]];
1366
- baseColumn: never;
1367
- identity: undefined;
1368
- generated: undefined;
1369
- }, {}, {
1370
- length: 255;
1371
- }>;
1372
- locale: _$drizzle_orm_pg_core0.PgColumn<{
1373
- name: "locale";
1374
- tableName: "toolkit_content_locks";
1375
- dataType: "string";
1376
- columnType: "PgVarchar";
1377
- data: string;
1378
- driverParam: string;
1379
- notNull: true;
1380
- hasDefault: true;
1381
- isPrimaryKey: false;
1382
- isAutoincrement: false;
1383
- hasRuntimeDefault: false;
1384
- enumValues: [string, ...string[]];
1385
- baseColumn: never;
1386
- identity: undefined;
1387
- generated: undefined;
1388
- }, {}, {
1389
- length: 10;
1390
- }>;
1391
- lockedBy: _$drizzle_orm_pg_core0.PgColumn<{
1392
- name: "locked_by";
1393
- tableName: "toolkit_content_locks";
1394
- dataType: "string";
1395
- columnType: "PgVarchar";
1396
- data: string;
1397
- driverParam: string;
1398
- notNull: true;
1399
- hasDefault: false;
1400
- isPrimaryKey: false;
1401
- isAutoincrement: false;
1402
- hasRuntimeDefault: false;
1403
- enumValues: [string, ...string[]];
1404
- baseColumn: never;
1405
- identity: undefined;
1406
- generated: undefined;
1407
- }, {}, {
1408
- length: 255;
1409
- }>;
1410
- lockedByName: _$drizzle_orm_pg_core0.PgColumn<{
1411
- name: "locked_by_name";
1412
- tableName: "toolkit_content_locks";
1413
- dataType: "string";
1414
- columnType: "PgVarchar";
1415
- data: string;
1416
- driverParam: string;
1417
- notNull: false;
1418
- hasDefault: false;
1419
- isPrimaryKey: false;
1420
- isAutoincrement: false;
1421
- hasRuntimeDefault: false;
1422
- enumValues: [string, ...string[]];
1423
- baseColumn: never;
1424
- identity: undefined;
1425
- generated: undefined;
1426
- }, {}, {
1427
- length: 255;
1428
- }>;
1429
- lockedAt: _$drizzle_orm_pg_core0.PgColumn<{
1430
- name: "locked_at";
1431
- tableName: "toolkit_content_locks";
1432
- dataType: "date";
1433
- columnType: "PgTimestamp";
1434
- data: Date;
1435
- driverParam: string;
1436
- notNull: true;
1437
- hasDefault: true;
1438
- isPrimaryKey: false;
1439
- isAutoincrement: false;
1440
- hasRuntimeDefault: false;
1441
- enumValues: undefined;
1442
- baseColumn: never;
1443
- identity: undefined;
1444
- generated: undefined;
1445
- }, {}, {}>;
1446
- expiresAt: _$drizzle_orm_pg_core0.PgColumn<{
1447
- name: "expires_at";
1448
- tableName: "toolkit_content_locks";
1449
- dataType: "date";
1450
- columnType: "PgTimestamp";
1451
- data: Date;
1452
- driverParam: string;
1453
- notNull: true;
1454
- hasDefault: false;
1455
- isPrimaryKey: false;
1456
- isAutoincrement: false;
1457
- hasRuntimeDefault: false;
1458
- enumValues: undefined;
1459
- baseColumn: never;
1460
- identity: undefined;
1461
- generated: undefined;
1462
- }, {}, {}>;
1463
- };
1464
- dialect: "pg";
1465
- }>;
1466
- /**
1467
- * Check if an entity has blocks fields with translatable block content (non-localized mode).
1468
- */
1469
- declare function hasTranslatableBlocks(entity: Entity): boolean;
1470
- /**
1471
- * Generate layout translation table for non-localized blocks with translatable fields.
1472
- *
1473
- * `layoutParent` is optional — when provided, emits a `.references()` FK
1474
- * pointing at the corresponding `{entity}_layout` table (for migration
1475
- * generation).
1476
- */
1477
- declare function generateLayoutTranslationSchema(entity: Entity, layoutParent?: PgTable): _$drizzle_orm_pg_core0.PgTableWithColumns<{
1478
- name: string;
1479
- schema: undefined;
1480
- columns: {
1481
- id: _$drizzle_orm_pg_core0.PgColumn<{
1482
- name: "id";
1483
- tableName: string;
1484
- dataType: "string";
1485
- columnType: "PgUUID";
1486
- data: string;
1487
- driverParam: string;
1488
- notNull: true;
1489
- hasDefault: true;
1490
- isPrimaryKey: true;
1491
- isAutoincrement: false;
1492
- hasRuntimeDefault: false;
1493
- enumValues: undefined;
1494
- baseColumn: never;
1495
- identity: undefined;
1496
- generated: undefined;
1497
- }, {}, {}>;
1498
- layoutId: _$drizzle_orm_pg_core0.PgColumn<{
1499
- name: "layout_id";
1500
- tableName: string;
1501
- dataType: "string";
1502
- columnType: "PgUUID";
1503
- data: string;
1504
- driverParam: string;
1505
- notNull: true;
1506
- hasDefault: false;
1507
- isPrimaryKey: false;
1508
- isAutoincrement: false;
1509
- hasRuntimeDefault: false;
1510
- enumValues: undefined;
1511
- baseColumn: never;
1512
- identity: undefined;
1513
- generated: undefined;
1514
- }, {}, {}>;
1515
- locale: _$drizzle_orm_pg_core0.PgColumn<{
1516
- name: "locale";
1517
- tableName: string;
1518
- dataType: "string";
1519
- columnType: "PgVarchar";
1520
- data: string;
1521
- driverParam: string;
1522
- notNull: true;
1523
- hasDefault: false;
1524
- isPrimaryKey: false;
1525
- isAutoincrement: false;
1526
- hasRuntimeDefault: false;
1527
- enumValues: [string, ...string[]];
1528
- baseColumn: never;
1529
- identity: undefined;
1530
- generated: undefined;
1531
- }, {}, {
1532
- length: 10;
1533
- }>;
1534
- fields: _$drizzle_orm_pg_core0.PgColumn<{
1535
- name: "fields";
916
+ fields: _$drizzle_orm_pg_core0.PgColumn<{
917
+ name: "fields";
1536
918
  tableName: string;
1537
919
  dataType: "json";
1538
920
  columnType: "PgJsonb";
@@ -1567,5 +949,41 @@ declare function generateLayoutTranslationSchema(entity: Entity, layoutParent?:
1567
949
  */
1568
950
  declare function buildEntitySchemaMap(entities: Entity[]): Record<string, PgTable>;
1569
951
  //#endregion
1570
- export { type AuditableFields, type Behavior, type BehaviorContext, type BlockDefinitionRef, type BlocksField, type BooleanField, type ContextResolver, CountCache, type CountCacheLike, type CursorInput, type DateField, type Entity, type EntityAdminConfig, type EntityDefinition, type EntityInput, type EntityUsage, type FieldConfig, type FieldToTS, ForbiddenError, type IdField, type InferEntity, type InferEntityDTO, type JsonField, type JsonValue, type MediaField, type NumberField, type PublishableFields, type ReferenceField, ReferencedEntityError, type RichTextField, type SecurityContext, type SelectField, type SlugField, type TextField, auditable, behavior, buildCursorCondition, buildEntitySchemaMap, decodeCursor, defineEntity, encodeCursor, estimateRowCount, field, generateContentLocksSchema, generateDraftsSchema, generateLayoutSchema, generateLayoutTranslationSchema, generateLocaleStatusSchema, generateSchema, generateTranslationSchema, generateVersionsSchema, hasBlocksFields, hasTranslatableBlocks, hierarchical, isPublishable, isVersionable, needsLocaleStatus, publishable, revisionable, sluggable, slugify, timestamped };
952
+ //#region src/shared/entity-data-ops.d.ts
953
+ /**
954
+ * Security context resolved per-request. Provided by the consumer
955
+ * (e.g., via React.cache() in Next.js, or runAsCli for CLI).
956
+ * The entity package has zero knowledge of how this is resolved.
957
+ */
958
+ interface SecurityContext {
959
+ user: {
960
+ id: string;
961
+ groups: string[];
962
+ name?: string;
963
+ email?: string;
964
+ };
965
+ checker: (role: string, resource: string, action: string) => boolean;
966
+ scope?: {
967
+ type: string;
968
+ id: string;
969
+ };
970
+ }
971
+ /**
972
+ * Function that resolves the current request's security context.
973
+ * Injected at construction time — the entity package never imports
974
+ * @murumets-ee/core or any framework-specific code.
975
+ *
976
+ * Returns undefined only when intentionally skipping enforcement
977
+ * (should not happen in production — throw ForbiddenError instead).
978
+ */
979
+ type ContextResolver = () => SecurityContext | undefined | Promise<SecurityContext | undefined>;
980
+ /**
981
+ * Thrown when a user lacks permission for an entity operation.
982
+ * Consumers (api-handler) catch this and return HTTP 403.
983
+ */
984
+ declare class ForbiddenError extends Error {
985
+ constructor(message: string);
986
+ }
987
+ //#endregion
988
+ export { type AuditableFields, type Behavior, type BehaviorContext, type BlockDefinitionRef, type BlocksField, type BooleanField, type ContextResolver, CountCache, type CountCacheLike, type CursorInput, type DateField, type Entity, type EntityAdminConfig, type EntityDefinition, type EntityInput, type EntityUsage, type FieldConfig, type FieldToTS, ForbiddenError, type IdField, type InferEntity, type InferEntityDTO, type JsonField, type JsonValue, type MediaField, type NumberField, type PublishableFields, type ReferenceField, ReferencedEntityError, type RichTextField, type SecurityContext, type SelectField, type SlugField, type TextField, auditable, behavior, buildCursorCondition, buildEntitySchemaMap, decodeCursor, defineEntity, encodeCursor, estimateRowCount, field, generateLayoutSchema, generateLayoutTranslationSchema, generateSchema, generateTranslationSchema, hasBlocksFields, hasTranslatableBlocks, hierarchical, isPublishable, isVersionable, needsLocaleStatus, publishable, revisionable, sluggable, slugify, timestamped };
1571
989
  //# sourceMappingURL=index.d.mts.map