@open-commune/core 0.2.15 → 0.2.16

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
@@ -3,8 +3,8 @@ import * as _trpc_server from '@trpc/server';
3
3
  import { z } from 'zod';
4
4
  import * as drizzle_orm_bun_sqlite from 'drizzle-orm/bun-sqlite';
5
5
  import { Database } from 'bun:sqlite';
6
- import { s as schema, U as User, S as Session, I as Invitation, A as ApiToken, O as Organization, N as NewOrganization, a as OrganizationInitDto, b as OrganizationUpdateDto, c as NewMedia, M as Media, d as MediaFinalizeDto, e as MediaUpdateDto, C as CollectionDefinition, f as NewCollectionDefinition, E as Entry, g as NewEntry, D as DefinitionCreateDto, h as DefinitionUpdateDto, i as EntrySearchHit, j as EntryCreateDto, k as EntryUpdateDto, l as ErrorType } from './shared/core.ZROqCA7w.mjs';
7
- export { m as AcceptInvitationDto, n as Address, o as ApiTokenCreateDto, p as ERROR_TYPES, q as InviteDto, L as LoginDto, r as MediaRequestUploadDto, t as NewUser, P as PublicUser, R as RequestPasswordResetDto, u as UpdateOwnProfileDto, v as UserUpdateDto, w as acceptInvitationDto, x as addressSchema, y as apiTokenCreateDto, z as apiTokens, B as collectionDefinitions, F as definitionCreateDto, G as definitionDto, H as definitionUpdateDto, J as entries, K as entryCreateDto, Q as entryDto, T as entrySearchHitDto, V as entryUpdateDto, W as invitations, X as inviteDto, Y as isErrorType, Z as loginDto, _ as media, $ as mediaFinalizeDto, a0 as mediaRequestUploadDto, a1 as mediaUpdateDto, a2 as organization, a3 as organizationInitDto, a4 as organizationUpdateDto, a5 as requestPasswordResetDto, a6 as sessions, a7 as toPublicUser, a8 as updateOwnProfileDto, a9 as userUpdateDto, aa as users } from './shared/core.ZROqCA7w.mjs';
6
+ import { s as schema, U as User, S as Session, I as Invitation, A as ApiToken, O as Organization, N as NewOrganization, a as OrganizationInitDto, b as OrganizationUpdateDto, c as NewMedia, M as Media, d as MediaFinalizeDto, e as MediaUpdateDto, C as CollectionDefinition, f as NewCollectionDefinition, E as Entry, g as NewEntry, D as DefinitionCreateDto, h as DefinitionUpdateDto, i as EntrySearchHit, j as EntryCreateDto, k as EntryUpdateDto, l as AudienceAsk, m as AudiencePanelData, n as ErrorType } from './shared/core.7Us3D2yq.mjs';
7
+ export { o as AUDIENCE_PERIODS, p as AcceptInvitationDto, q as Address, r as ApiTokenCreateDto, t as AudienceQuery, u as AudienceSummary, v as ERROR_TYPES, w as InviteDto, L as LoginDto, x as MediaRequestUploadDto, y as NewUser, P as PublicUser, R as RequestPasswordResetDto, z as UpdateOwnProfileDto, B as UserUpdateDto, F as acceptInvitationDto, G as addressSchema, H as apiTokenCreateDto, J as apiTokens, K as audienceAskDto, Q as audienceQuerySchema, T as audienceSummarySchema, V as collectionDefinitions, W as definitionCreateDto, X as definitionDto, Y as definitionUpdateDto, Z as entries, _ as entryCreateDto, $ as entryDto, a0 as entrySearchHitDto, a1 as entryUpdateDto, a2 as invitations, a3 as inviteDto, a4 as isErrorType, a5 as loginDto, a6 as media, a7 as mediaFinalizeDto, a8 as mediaRequestUploadDto, a9 as mediaUpdateDto, aa as organization, ab as organizationInitDto, ac as organizationUpdateDto, ad as requestPasswordResetDto, ae as sessions, af as toPublicUser, ag as updateOwnProfileDto, ah as userUpdateDto, ai as users } from './shared/core.7Us3D2yq.mjs';
8
8
  export { FIELD_TYPES, FieldType, PUBLICATION_STATUSES, PublicationStatus } from './domains/collections/constants.mjs';
9
9
  export { FIELD_VALUE_SCHEMAS, FieldDefinition, buildDataSchema, fieldDefinitionSchema } from './domains/collections/utils.mjs';
10
10
  import 'drizzle-orm/sqlite-core';
@@ -21,6 +21,9 @@ declare const envSchema: z.ZodObject<{
21
21
  COMMUN_EMAIL_WEBHOOK_TOKEN: z.ZodOptional<z.ZodString>;
22
22
  COMMUN_ADMIN_URL: z.ZodOptional<z.ZodString>;
23
23
  COMMUN_JWT_SECRET: z.ZodString;
24
+ OPEN_COMMUNE_AUDIENCE_URL: z.ZodOptional<z.ZodURL>;
25
+ OPEN_COMMUNE_AUDIENCE_TOKEN: z.ZodOptional<z.ZodString>;
26
+ OPEN_COMMUNE_AUDIENCE_VIEWERS: z.ZodOptional<z.ZodString>;
24
27
  }, z.core.$strip>;
25
28
  type CoreEnv = z.infer<typeof envSchema>;
26
29
  /**
@@ -293,13 +296,13 @@ declare class UsersService {
293
296
  verifyApiToken(token: string): Promise<boolean>;
294
297
  revokeApiToken(id: string): Promise<void>;
295
298
  listApiTokens(): Promise<Pick<{
296
- id: string;
297
299
  name: string;
300
+ id: string;
298
301
  createdAt: string;
299
302
  revokedAt: string | null;
300
303
  tokenHash: string;
301
304
  lastUsedAt: string | null;
302
- }, "id" | "name" | "createdAt" | "revokedAt" | "lastUsedAt">[]>;
305
+ }, "name" | "id" | "createdAt" | "revokedAt" | "lastUsedAt">[]>;
303
306
  }
304
307
 
305
308
  /**
@@ -406,6 +409,21 @@ declare class DefinitionRepository {
406
409
  delete(id: string): Promise<CollectionDefinition | undefined>;
407
410
  }
408
411
 
412
+ /** A period, its bounds ISO 8601 dates at the precision asked: `2026`, `2026-11`, `2026-11-13`. */
413
+ type EntryPeriod = {
414
+ gte?: string;
415
+ lte?: string;
416
+ };
417
+ /** How a listing may be narrowed. Every filter is optional, and they combine. */
418
+ type EntryNarrowing = {
419
+ /** One collection; every collection of the site when omitted. */
420
+ collectionId?: string;
421
+ status?: Entry['status'][];
422
+ search?: string;
423
+ date?: EntryPeriod;
424
+ references?: string[];
425
+ };
426
+ type EntryOrder = 'recent' | 'oldest' | 'title' | 'date_asc' | 'date_desc';
409
427
  /**
410
428
  * Database access for collection entries. Methods are async by contract, even
411
429
  * though bun:sqlite executes synchronously.
@@ -420,6 +438,24 @@ declare class EntryRepository {
420
438
  * entries would not fit in it anyway.
421
439
  */
422
440
  private narrowing;
441
+ /**
442
+ * The dates of an entry, as spans: an object of its fields that holds dates
443
+ * (a session, with its start and its end) is one span from the first to the
444
+ * last; a date on its own, at the top or in a list, is a span of one day.
445
+ * Read from any field, whatever its name, as the theme reads them.
446
+ */
447
+ private spans;
448
+ /**
449
+ * A span is within the period when it overlaps it, each bound compared at
450
+ * its own precision: `2026-11` keeps a session from 30/10 to 02/11.
451
+ */
452
+ private within;
453
+ /**
454
+ * The day an entry is sorted by: its first date within the period, or its
455
+ * last for a reverse order — so that « the last council » is the latest one
456
+ * held, and an entry with no date comes after every dated one.
457
+ */
458
+ private dateKey;
423
459
  /**
424
460
  * Text match on the title and the data. One LIKE is enough at a commune's
425
461
  * scale, and it leaves the title index usable.
@@ -436,18 +472,17 @@ declare class EntryRepository {
436
472
  limit: number;
437
473
  }): Promise<Entry[]>;
438
474
  /** The total a paginated listing is a window onto. Counted in SQL. */
439
- countMatching(options: {
440
- collectionId: string;
441
- status?: Entry['status'][];
442
- search?: string;
443
- }): Promise<number>;
444
- /** Admin listing: most recently updated first by default, paginated. */
445
- listPaginated(collectionId: string, options: {
475
+ countMatching(options: EntryNarrowing): Promise<number>;
476
+ /** The entries last touched, whatever their collection: what a home shows. */
477
+ listRecent(limit: number): Promise<Entry[]>;
478
+ /**
479
+ * Admin listing: most recently updated first by default, paginated. With a
480
+ * period and no order, the entries come by date, the earliest first.
481
+ */
482
+ listPaginated(options: EntryNarrowing & {
446
483
  skip: number;
447
484
  limit: number;
448
- status?: Entry['status'][];
449
- search?: string;
450
- order?: 'recent' | 'oldest' | 'title';
485
+ order?: EntryOrder;
451
486
  }): Promise<Entry[]>;
452
487
  listPublished(collectionId: string): Promise<Entry[]>;
453
488
  findBySlug(collectionId: string, slug: string): Promise<Entry | undefined>;
@@ -477,18 +512,22 @@ declare class CollectionsService {
477
512
  listEntries(collectionIdOrSlug: string): Promise<Entry[]>;
478
513
  getEntry(id: string): Promise<Entry>;
479
514
  /** Paginated admin listing, most recently updated first. */
480
- listEntriesPaginated(collectionIdOrSlug: string, options?: {
515
+ /**
516
+ * A page of entries, from one collection or, without one, from every
517
+ * collection of the site — narrowed by status, text, period and the entries
518
+ * they reference.
519
+ */
520
+ listEntriesPaginated(collectionIdOrSlug: string | undefined, options?: Omit<EntryNarrowing, 'collectionId'> & {
481
521
  skip?: number;
482
522
  limit?: number;
483
- status?: Entry['status'][];
484
- search?: string;
485
- order?: 'recent' | 'oldest' | 'title';
523
+ order?: EntryOrder;
486
524
  }): Promise<Entry[]>;
525
+ /** A collection's id from its id or its slug; none, for the whole site. */
526
+ private collectionIdOf;
527
+ /** The entries last touched across every collection, most recent first. */
528
+ listRecentEntries(limit?: number): Promise<Entry[]>;
487
529
  /** The total a listing is a window onto, under the same narrowing. */
488
- countEntries(collectionIdOrSlug: string, options?: {
489
- status?: Entry['status'][];
490
- search?: string;
491
- }): Promise<number>;
530
+ countEntries(collectionIdOrSlug: string | undefined, options?: Omit<EntryNarrowing, 'collectionId'>): Promise<number>;
492
531
  /**
493
532
  * Text search across collections, or within the ones named (by id or slug).
494
533
  * Each hit carries the slug of its collection.
@@ -514,6 +553,40 @@ declare class CollectionsService {
514
553
  private linkRelations;
515
554
  }
516
555
 
556
+ /**
557
+ * The audience panels' data: the site's, a collection's or an entry's, asked
558
+ * of the configured source (`OPEN_COMMUNE_AUDIENCE_URL`) and its most read
559
+ * pages named after the instance's own entries.
560
+ *
561
+ * The core measures nothing and holds no provider's key: a source is whatever
562
+ * answers the contract of `@open-commune/core/dtos` — the cloud's measurement
563
+ * service, or a converter in front of Matomo or Plausible.
564
+ */
565
+ declare class AudienceService {
566
+ private readonly collections;
567
+ private readonly config;
568
+ private readonly cache;
569
+ private names;
570
+ private readonly viewers;
571
+ constructor(collections: CollectionsService, config: {
572
+ url?: string;
573
+ token?: string;
574
+ /** Who sees the panels while they are previewed, comma-separated; unset, every user. */
575
+ viewers?: string;
576
+ fetchImpl?: typeof fetch;
577
+ });
578
+ summary(ask: AudienceAsk, viewer: string): Promise<AudiencePanelData>;
579
+ /** The source's answer, or `null`: any failure only hides the panel. */
580
+ private ask;
581
+ private entrySlug;
582
+ /**
583
+ * Published entries by slug and collections by slug, to name the most read
584
+ * pages. A path is matched by its last segment, which every theme, old or
585
+ * new, ends an entry's URL with.
586
+ */
587
+ private knownNames;
588
+ }
589
+
517
590
  /** The domain services — the ONLY surface transport layers (tRPC, REST) talk to. */
518
591
  interface CoreServices {
519
592
  health: HealthService;
@@ -521,6 +594,7 @@ interface CoreServices {
521
594
  organization: OrganizationService;
522
595
  media: MediaService;
523
596
  collections: CollectionsService;
597
+ audience: AudienceService;
524
598
  }
525
599
  /** The fully-wired dependency graph returned by `createCore({ env })`. */
526
600
  interface Core {
@@ -537,6 +611,39 @@ interface CoreContext {
537
611
  requestMeta?: SessionMeta;
538
612
  }
539
613
 
614
+ declare const router: _trpc_server.TRPCRouterBuilder<{
615
+ ctx: CoreContext;
616
+ meta: object;
617
+ errorShape: {
618
+ data: {
619
+ type?: ErrorType | undefined;
620
+ code: _trpc_server.TRPC_ERROR_CODE_KEY;
621
+ httpStatus: number;
622
+ path?: string;
623
+ stack?: string;
624
+ };
625
+ message: string;
626
+ code: _trpc_server.TRPC_ERROR_CODE_NUMBER;
627
+ };
628
+ transformer: false;
629
+ }>;
630
+ declare const mergeRouters: <TRouters extends _trpc_server.AnyRouter[]>(...routerList: TRouters) => _trpc_server.TRPCMergeRouters<TRouters>;
631
+ declare const publicProcedure: _trpc_server.TRPCProcedureBuilder<CoreContext, object, object, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, false>;
632
+ declare const middleware: <$ContextOverrides>(fn: _trpc_server.TRPCMiddlewareFunction<CoreContext, object, object, $ContextOverrides, unknown>) => _trpc_server.TRPCMiddlewareBuilder<CoreContext, object, $ContextOverrides, unknown>;
633
+ declare const procedure: _trpc_server.TRPCProcedureBuilder<CoreContext, object, {}, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, false>;
634
+ /** Requires an authenticated session, whatever the role. */
635
+ declare const protectedProcedure: _trpc_server.TRPCProcedureBuilder<CoreContext, object, {
636
+ services: CoreServices;
637
+ session: AuthSession;
638
+ requestMeta: SessionMeta | undefined;
639
+ }, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, false>;
640
+ /** Requires an authenticated admin. */
641
+ declare const adminProcedure: _trpc_server.TRPCProcedureBuilder<CoreContext, object, {
642
+ services: CoreServices;
643
+ session: AuthSession;
644
+ requestMeta: SessionMeta | undefined;
645
+ }, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, _trpc_server.TRPCUnsetMarker, false>;
646
+
540
647
  /**
541
648
  * Typed domain errors. Each domain exports its own catalogue
542
649
  * (`domains/<domain>/errors.ts`); the tRPC layer only forwards them —
@@ -611,14 +718,10 @@ declare const organizationRouter: _trpc_server.TRPCBuiltRouter<{
611
718
  input: void;
612
719
  output: {
613
720
  type: "commune" | "intercommunality" | "syndicate" | "other";
614
- id: number;
615
721
  name: string;
722
+ id: number;
616
723
  slug: string;
617
724
  description: string | null;
618
- updatedBy: string | null;
619
- legacyExtra: Record<string, unknown> | null;
620
- createdAt: string;
621
- updatedAt: string;
622
725
  address: {
623
726
  street?: string | undefined;
624
727
  postalCode?: string | undefined;
@@ -626,6 +729,10 @@ declare const organizationRouter: _trpc_server.TRPCBuiltRouter<{
626
729
  } | null;
627
730
  deployment: Record<string, unknown> | null;
628
731
  settings: Record<string, unknown> | null;
732
+ updatedBy: string | null;
733
+ legacyExtra: Record<string, unknown> | null;
734
+ createdAt: string;
735
+ updatedAt: string;
629
736
  } | null;
630
737
  meta: object;
631
738
  }>;
@@ -645,14 +752,10 @@ declare const organizationRouter: _trpc_server.TRPCBuiltRouter<{
645
752
  };
646
753
  output: {
647
754
  type: "commune" | "intercommunality" | "syndicate" | "other";
648
- id: number;
649
755
  name: string;
756
+ id: number;
650
757
  slug: string;
651
758
  description: string | null;
652
- updatedBy: string | null;
653
- legacyExtra: Record<string, unknown> | null;
654
- createdAt: string;
655
- updatedAt: string;
656
759
  address: {
657
760
  street?: string | undefined;
658
761
  postalCode?: string | undefined;
@@ -660,6 +763,10 @@ declare const organizationRouter: _trpc_server.TRPCBuiltRouter<{
660
763
  } | null;
661
764
  deployment: Record<string, unknown> | null;
662
765
  settings: Record<string, unknown> | null;
766
+ updatedBy: string | null;
767
+ legacyExtra: Record<string, unknown> | null;
768
+ createdAt: string;
769
+ updatedAt: string;
663
770
  };
664
771
  meta: object;
665
772
  }>;
@@ -679,14 +786,10 @@ declare const organizationRouter: _trpc_server.TRPCBuiltRouter<{
679
786
  };
680
787
  output: {
681
788
  type: "commune" | "intercommunality" | "syndicate" | "other";
682
- id: number;
683
789
  name: string;
790
+ id: number;
684
791
  slug: string;
685
792
  description: string | null;
686
- updatedBy: string | null;
687
- legacyExtra: Record<string, unknown> | null;
688
- createdAt: string;
689
- updatedAt: string;
690
793
  address: {
691
794
  street?: string | undefined;
692
795
  postalCode?: string | undefined;
@@ -694,6 +797,10 @@ declare const organizationRouter: _trpc_server.TRPCBuiltRouter<{
694
797
  } | null;
695
798
  deployment: Record<string, unknown> | null;
696
799
  settings: Record<string, unknown> | null;
800
+ updatedBy: string | null;
801
+ legacyExtra: Record<string, unknown> | null;
802
+ createdAt: string;
803
+ updatedAt: string;
697
804
  };
698
805
  meta: object;
699
806
  }>;
@@ -1024,13 +1131,13 @@ declare const apiTokensRouter: _trpc_server.TRPCBuiltRouter<{
1024
1131
  list: _trpc_server.TRPCQueryProcedure<{
1025
1132
  input: void;
1026
1133
  output: Pick<{
1027
- id: string;
1028
1134
  name: string;
1135
+ id: string;
1029
1136
  createdAt: string;
1030
1137
  revokedAt: string | null;
1031
1138
  tokenHash: string;
1032
1139
  lastUsedAt: string | null;
1033
- }, "id" | "name" | "createdAt" | "revokedAt" | "lastUsedAt">[];
1140
+ }, "name" | "id" | "createdAt" | "revokedAt" | "lastUsedAt">[];
1034
1141
  meta: object;
1035
1142
  }>;
1036
1143
  /** The plaintext token is returned ONCE — only its hash is stored. */
@@ -1257,38 +1364,38 @@ declare const mediaRouter: _trpc_server.TRPCBuiltRouter<{
1257
1364
  metaData?: Record<string, unknown> | undefined;
1258
1365
  };
1259
1366
  output: {
1367
+ filename: string;
1260
1368
  id: string;
1261
- createdBy: string | null;
1262
1369
  updatedBy: string | null;
1263
1370
  legacyExtra: Record<string, unknown> | null;
1264
1371
  createdAt: string;
1265
1372
  updatedAt: string;
1266
- filename: string;
1267
1373
  mime: string;
1268
- metaData: Record<string, unknown> | null;
1269
- alt: string | null;
1270
1374
  size: number;
1375
+ alt: string | null;
1271
1376
  caption: string | null;
1272
1377
  objects: Record<string, unknown>;
1378
+ metaData: Record<string, unknown> | null;
1379
+ createdBy: string | null;
1273
1380
  };
1274
1381
  meta: object;
1275
1382
  }>;
1276
1383
  list: _trpc_server.TRPCQueryProcedure<{
1277
1384
  input: void;
1278
1385
  output: ({
1386
+ filename: string;
1279
1387
  id: string;
1280
- createdBy: string | null;
1281
1388
  updatedBy: string | null;
1282
1389
  legacyExtra: Record<string, unknown> | null;
1283
1390
  createdAt: string;
1284
1391
  updatedAt: string;
1285
- filename: string;
1286
1392
  mime: string;
1287
- metaData: Record<string, unknown> | null;
1288
- alt: string | null;
1289
1393
  size: number;
1394
+ alt: string | null;
1290
1395
  caption: string | null;
1291
1396
  objects: Record<string, unknown>;
1397
+ metaData: Record<string, unknown> | null;
1398
+ createdBy: string | null;
1292
1399
  } & {
1293
1400
  objects: Record<string, string>;
1294
1401
  })[];
@@ -1299,19 +1406,19 @@ declare const mediaRouter: _trpc_server.TRPCBuiltRouter<{
1299
1406
  id: string;
1300
1407
  };
1301
1408
  output: {
1409
+ filename: string;
1302
1410
  id: string;
1303
- createdBy: string | null;
1304
1411
  updatedBy: string | null;
1305
1412
  legacyExtra: Record<string, unknown> | null;
1306
1413
  createdAt: string;
1307
1414
  updatedAt: string;
1308
- filename: string;
1309
1415
  mime: string;
1310
- metaData: Record<string, unknown> | null;
1311
- alt: string | null;
1312
1416
  size: number;
1417
+ alt: string | null;
1313
1418
  caption: string | null;
1314
1419
  objects: Record<string, unknown>;
1420
+ metaData: Record<string, unknown> | null;
1421
+ createdBy: string | null;
1315
1422
  } & {
1316
1423
  objects: Record<string, string>;
1317
1424
  };
@@ -1327,19 +1434,19 @@ declare const mediaRouter: _trpc_server.TRPCBuiltRouter<{
1327
1434
  };
1328
1435
  };
1329
1436
  output: {
1437
+ filename: string;
1330
1438
  id: string;
1331
- createdBy: string | null;
1332
1439
  updatedBy: string | null;
1333
1440
  legacyExtra: Record<string, unknown> | null;
1334
1441
  createdAt: string;
1335
1442
  updatedAt: string;
1336
- filename: string;
1337
1443
  mime: string;
1338
- metaData: Record<string, unknown> | null;
1339
- alt: string | null;
1340
1444
  size: number;
1445
+ alt: string | null;
1341
1446
  caption: string | null;
1342
1447
  objects: Record<string, unknown>;
1448
+ metaData: Record<string, unknown> | null;
1449
+ createdBy: string | null;
1343
1450
  };
1344
1451
  meta: object;
1345
1452
  }>;
@@ -1422,14 +1529,19 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1422
1529
  list: _trpc_server.TRPCQueryProcedure<{
1423
1530
  input: void;
1424
1531
  output: {
1425
- id: string;
1426
1532
  name: string;
1533
+ id: string;
1427
1534
  slug: string;
1428
1535
  description: string | null;
1536
+ updatedBy: string | null;
1537
+ legacyExtra: Record<string, unknown> | null;
1538
+ createdAt: string;
1539
+ updatedAt: string;
1540
+ createdBy: string | null;
1429
1541
  fields: {
1430
1542
  name: string;
1431
1543
  label: string;
1432
- type: "number" | "boolean" | "json" | "date" | "text" | "rich-text" | "media" | "relation" | "select" | "steps";
1544
+ type: "number" | "boolean" | "text" | "rich-text" | "date" | "media" | "relation" | "select" | "steps" | "json";
1433
1545
  required: boolean;
1434
1546
  hidden: boolean;
1435
1547
  options?: string[] | undefined;
@@ -1438,11 +1550,6 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1438
1550
  editor: Record<string, unknown> | null;
1439
1551
  display: Record<string, unknown> | null;
1440
1552
  headings: Record<string, unknown> | null;
1441
- createdBy: string | null;
1442
- updatedBy: string | null;
1443
- legacyExtra: Record<string, unknown> | null;
1444
- createdAt: string;
1445
- updatedAt: string;
1446
1553
  }[];
1447
1554
  meta: object;
1448
1555
  }>;
@@ -1482,7 +1589,7 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1482
1589
  fields: {
1483
1590
  name: string;
1484
1591
  label: string;
1485
- type: "number" | "boolean" | "json" | "date" | "text" | "rich-text" | "media" | "relation" | "select" | "steps";
1592
+ type: "number" | "boolean" | "text" | "rich-text" | "date" | "media" | "relation" | "select" | "steps" | "json";
1486
1593
  required?: boolean | undefined;
1487
1594
  hidden?: boolean | undefined;
1488
1595
  options?: string[] | undefined;
@@ -1495,14 +1602,19 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1495
1602
  slug?: string | undefined;
1496
1603
  };
1497
1604
  output: {
1498
- id: string;
1499
1605
  name: string;
1606
+ id: string;
1500
1607
  slug: string;
1501
1608
  description: string | null;
1609
+ updatedBy: string | null;
1610
+ legacyExtra: Record<string, unknown> | null;
1611
+ createdAt: string;
1612
+ updatedAt: string;
1613
+ createdBy: string | null;
1502
1614
  fields: {
1503
1615
  name: string;
1504
1616
  label: string;
1505
- type: "number" | "boolean" | "json" | "date" | "text" | "rich-text" | "media" | "relation" | "select" | "steps";
1617
+ type: "number" | "boolean" | "text" | "rich-text" | "date" | "media" | "relation" | "select" | "steps" | "json";
1506
1618
  required: boolean;
1507
1619
  hidden: boolean;
1508
1620
  options?: string[] | undefined;
@@ -1511,11 +1623,6 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1511
1623
  editor: Record<string, unknown> | null;
1512
1624
  display: Record<string, unknown> | null;
1513
1625
  headings: Record<string, unknown> | null;
1514
- createdBy: string | null;
1515
- updatedBy: string | null;
1516
- legacyExtra: Record<string, unknown> | null;
1517
- createdAt: string;
1518
- updatedAt: string;
1519
1626
  };
1520
1627
  meta: object;
1521
1628
  }>;
@@ -1532,7 +1639,7 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1532
1639
  fields?: {
1533
1640
  name: string;
1534
1641
  label: string;
1535
- type: "number" | "boolean" | "json" | "date" | "text" | "rich-text" | "media" | "relation" | "select" | "steps";
1642
+ type: "number" | "boolean" | "text" | "rich-text" | "date" | "media" | "relation" | "select" | "steps" | "json";
1536
1643
  required?: boolean | undefined;
1537
1644
  hidden?: boolean | undefined;
1538
1645
  options?: string[] | undefined;
@@ -1541,14 +1648,19 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1541
1648
  };
1542
1649
  };
1543
1650
  output: {
1544
- id: string;
1545
1651
  name: string;
1652
+ id: string;
1546
1653
  slug: string;
1547
1654
  description: string | null;
1655
+ updatedBy: string | null;
1656
+ legacyExtra: Record<string, unknown> | null;
1657
+ createdAt: string;
1658
+ updatedAt: string;
1659
+ createdBy: string | null;
1548
1660
  fields: {
1549
1661
  name: string;
1550
1662
  label: string;
1551
- type: "number" | "boolean" | "json" | "date" | "text" | "rich-text" | "media" | "relation" | "select" | "steps";
1663
+ type: "number" | "boolean" | "text" | "rich-text" | "date" | "media" | "relation" | "select" | "steps" | "json";
1552
1664
  required: boolean;
1553
1665
  hidden: boolean;
1554
1666
  options?: string[] | undefined;
@@ -1557,11 +1669,6 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1557
1669
  editor: Record<string, unknown> | null;
1558
1670
  display: Record<string, unknown> | null;
1559
1671
  headings: Record<string, unknown> | null;
1560
- createdBy: string | null;
1561
- updatedBy: string | null;
1562
- legacyExtra: Record<string, unknown> | null;
1563
- createdAt: string;
1564
- updatedAt: string;
1565
1672
  };
1566
1673
  meta: object;
1567
1674
  }>;
@@ -1640,12 +1747,17 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1640
1747
  /** Narrowing is optional: a caller that ignores it keeps the old behaviour. */
1641
1748
  list: _trpc_server.TRPCQueryProcedure<{
1642
1749
  input: {
1643
- collectionId: string;
1644
- status?: ("draft" | "waiting" | "ready" | "scheduled" | "published")[] | undefined;
1645
- search?: string | undefined;
1646
- order?: "title" | "recent" | "oldest" | undefined;
1750
+ order?: "title" | "recent" | "oldest" | "date_asc" | "date_desc" | undefined;
1647
1751
  skip?: number | undefined;
1648
1752
  limit?: number | undefined;
1753
+ collectionId?: string | undefined;
1754
+ status?: ("draft" | "waiting" | "ready" | "scheduled" | "published")[] | undefined;
1755
+ search?: string | undefined;
1756
+ date?: {
1757
+ gte?: string | undefined;
1758
+ lte?: string | undefined;
1759
+ } | undefined;
1760
+ references?: string[] | undefined;
1649
1761
  };
1650
1762
  output: {
1651
1763
  id: string;
@@ -1664,12 +1776,39 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1664
1776
  }[];
1665
1777
  meta: object;
1666
1778
  }>;
1779
+ /** What was last touched, across collections: the admin's home reads it. */
1780
+ recent: _trpc_server.TRPCQueryProcedure<{
1781
+ input: {
1782
+ limit?: number | undefined;
1783
+ } | undefined;
1784
+ output: {
1785
+ id: string;
1786
+ collectionId: string;
1787
+ title: string;
1788
+ slug: string;
1789
+ data: Record<string, unknown>;
1790
+ related: string[] | null;
1791
+ createdBy: string | null;
1792
+ updatedBy: string | null;
1793
+ status: "draft" | "waiting" | "ready" | "scheduled" | "published";
1794
+ publishedAt: string | null;
1795
+ legacyExtra: drizzle_zod.Json;
1796
+ createdAt: string;
1797
+ updatedAt: string;
1798
+ }[];
1799
+ meta: object;
1800
+ }>;
1667
1801
  /** The total a listing is a window onto, under the same narrowing. */
1668
1802
  count: _trpc_server.TRPCQueryProcedure<{
1669
1803
  input: {
1670
- collectionId: string;
1804
+ collectionId?: string | undefined;
1671
1805
  status?: ("draft" | "waiting" | "ready" | "scheduled" | "published")[] | undefined;
1672
1806
  search?: string | undefined;
1807
+ date?: {
1808
+ gte?: string | undefined;
1809
+ lte?: string | undefined;
1810
+ } | undefined;
1811
+ references?: string[] | undefined;
1673
1812
  };
1674
1813
  output: number;
1675
1814
  meta: object;
@@ -1689,13 +1828,13 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1689
1828
  id: string;
1690
1829
  data: Record<string, unknown>;
1691
1830
  slug: string;
1692
- createdBy: string | null;
1693
1831
  updatedBy: string | null;
1694
1832
  legacyExtra: Record<string, unknown> | null;
1695
1833
  createdAt: string;
1696
1834
  updatedAt: string;
1697
- title: string;
1835
+ createdBy: string | null;
1698
1836
  collectionId: string;
1837
+ title: string;
1699
1838
  related: string[] | null;
1700
1839
  status: "draft" | "waiting" | "ready" | "scheduled" | "published";
1701
1840
  publishedAt: string | null;
@@ -1718,13 +1857,13 @@ declare const collectionsRouter: _trpc_server.TRPCBuiltRouter<{
1718
1857
  id: string;
1719
1858
  data: Record<string, unknown>;
1720
1859
  slug: string;
1721
- createdBy: string | null;
1722
1860
  updatedBy: string | null;
1723
1861
  legacyExtra: Record<string, unknown> | null;
1724
1862
  createdAt: string;
1725
1863
  updatedAt: string;
1726
- title: string;
1864
+ createdBy: string | null;
1727
1865
  collectionId: string;
1866
+ title: string;
1728
1867
  related: string[] | null;
1729
1868
  status: "draft" | "waiting" | "ready" | "scheduled" | "published";
1730
1869
  publishedAt: string | null;
@@ -1808,6 +1947,55 @@ declare const DuplicateSlugError: {
1808
1947
  stackTraceLimit: number;
1809
1948
  };
1810
1949
 
1950
+ declare const audienceRouter: _trpc_server.TRPCBuiltRouter<{
1951
+ ctx: CoreContext;
1952
+ meta: object;
1953
+ errorShape: {
1954
+ data: {
1955
+ type?: ErrorType | undefined;
1956
+ code: _trpc_server.TRPC_ERROR_CODE_KEY;
1957
+ httpStatus: number;
1958
+ path?: string;
1959
+ stack?: string;
1960
+ };
1961
+ message: string;
1962
+ code: _trpc_server.TRPC_ERROR_CODE_NUMBER;
1963
+ };
1964
+ transformer: false;
1965
+ }, _trpc_server.TRPCDecorateCreateRouterOptions<{
1966
+ summary: _trpc_server.TRPCQueryProcedure<{
1967
+ input: {
1968
+ period: unknown;
1969
+ collection?: string | undefined;
1970
+ entry?: string | undefined;
1971
+ };
1972
+ output: AudiencePanelData;
1973
+ meta: object;
1974
+ }>;
1975
+ }>>;
1976
+
1977
+ /**
1978
+ * No audience to show: no source is configured, this user is not among its
1979
+ * viewers, the entry is unknown, or the source did not answer. The panels
1980
+ * render nothing; they never tell which.
1981
+ */
1982
+ declare const AudienceUnavailableError: {
1983
+ new (message?: string): {
1984
+ readonly type: ErrorType;
1985
+ readonly trpcCode: TrpcErrorCode;
1986
+ name: string;
1987
+ message: string;
1988
+ stack?: string;
1989
+ cause?: unknown;
1990
+ };
1991
+ isError(error: unknown): error is Error;
1992
+ isError(value: unknown): value is Error;
1993
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1994
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
1995
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
1996
+ stackTraceLimit: number;
1997
+ };
1998
+
1811
1999
  declare function createCore({ env }?: {
1812
2000
  env?: CoreEnv;
1813
2001
  }): Core;
@@ -2666,12 +2854,17 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
2666
2854
  }>;
2667
2855
  list: _trpc_server.TRPCQueryProcedure<{
2668
2856
  input: {
2669
- collectionId: string;
2670
- status?: ("draft" | "waiting" | "ready" | "scheduled" | "published")[] | undefined;
2671
- search?: string | undefined;
2672
- order?: "title" | "recent" | "oldest" | undefined;
2857
+ order?: "title" | "recent" | "oldest" | "date_asc" | "date_desc" | undefined;
2673
2858
  skip?: number | undefined;
2674
2859
  limit?: number | undefined;
2860
+ collectionId?: string | undefined;
2861
+ status?: ("draft" | "waiting" | "ready" | "scheduled" | "published")[] | undefined;
2862
+ search?: string | undefined;
2863
+ date?: {
2864
+ gte?: string | undefined;
2865
+ lte?: string | undefined;
2866
+ } | undefined;
2867
+ references?: string[] | undefined;
2675
2868
  };
2676
2869
  output: {
2677
2870
  id: string;
@@ -2690,11 +2883,37 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
2690
2883
  }[];
2691
2884
  meta: object;
2692
2885
  }>;
2693
- count: _trpc_server.TRPCQueryProcedure<{
2886
+ recent: _trpc_server.TRPCQueryProcedure<{
2694
2887
  input: {
2888
+ limit?: number | undefined;
2889
+ } | undefined;
2890
+ output: {
2891
+ id: string;
2695
2892
  collectionId: string;
2893
+ title: string;
2894
+ slug: string;
2895
+ data: Record<string, unknown>;
2896
+ related: string[] | null;
2897
+ createdBy: string | null;
2898
+ updatedBy: string | null;
2899
+ status: "draft" | "waiting" | "ready" | "scheduled" | "published";
2900
+ publishedAt: string | null;
2901
+ legacyExtra: drizzle_zod.Json;
2902
+ createdAt: string;
2903
+ updatedAt: string;
2904
+ }[];
2905
+ meta: object;
2906
+ }>;
2907
+ count: _trpc_server.TRPCQueryProcedure<{
2908
+ input: {
2909
+ collectionId?: string | undefined;
2696
2910
  status?: ("draft" | "waiting" | "ready" | "scheduled" | "published")[] | undefined;
2697
2911
  search?: string | undefined;
2912
+ date?: {
2913
+ gte?: string | undefined;
2914
+ lte?: string | undefined;
2915
+ } | undefined;
2916
+ references?: string[] | undefined;
2698
2917
  };
2699
2918
  output: number;
2700
2919
  meta: object;
@@ -2767,8 +2986,34 @@ declare const appRouter: _trpc_server.TRPCBuiltRouter<{
2767
2986
  }>;
2768
2987
  }>>;
2769
2988
  }>>;
2989
+ audience: _trpc_server.TRPCBuiltRouter<{
2990
+ ctx: CoreContext;
2991
+ meta: object;
2992
+ errorShape: {
2993
+ data: {
2994
+ type?: ErrorType | undefined;
2995
+ code: _trpc_server.TRPC_ERROR_CODE_KEY;
2996
+ httpStatus: number;
2997
+ path?: string;
2998
+ stack?: string;
2999
+ };
3000
+ message: string;
3001
+ code: _trpc_server.TRPC_ERROR_CODE_NUMBER;
3002
+ };
3003
+ transformer: false;
3004
+ }, _trpc_server.TRPCDecorateCreateRouterOptions<{
3005
+ summary: _trpc_server.TRPCQueryProcedure<{
3006
+ input: {
3007
+ period: unknown;
3008
+ collection?: string | undefined;
3009
+ entry?: string | undefined;
3010
+ };
3011
+ output: AudiencePanelData;
3012
+ meta: object;
3013
+ }>;
3014
+ }>>;
2770
3015
  }>>;
2771
3016
  type AppRouter = typeof appRouter;
2772
3017
 
2773
- export { ALLOWED_MIME, ApiToken, CannotRemoveSelfError, CollectionDefinition, CollectionNotFoundError, CollectionsService, DefinitionCreateDto, DefinitionRepository, DefinitionUpdateDto, DeployFailedError, DeployHookMissingError, DomainError, DuplicateSlugError, EmailService, Entry, EntryCreateDto, EntryNotFoundError, EntryRepository, EntrySearchHit, EntryUpdateDto, ErrorType, HealthService, InvalidEntryDataError, Invitation, InvitationInvalidError, Media, MediaFinalizeDto, MediaNotFoundError, MediaRepository, MediaService, MediaUpdateDto, NewCollectionDefinition, NewEntry, NewMedia, NewOrganization, Organization, OrganizationAlreadyInitializedError, OrganizationInitDto, OrganizationNotInitializedError, OrganizationRepository, OrganizationService, OrganizationUpdateDto, S3Storage, Session, SessionNotFoundError, TooManyAttemptsError, UnsupportedMimeError, UploadIncompleteError, User, UserNotFoundError, UsersRepository, UsersService, apiTokensRouter, appRouter, authRouter, collectionsRouter, connectDb, createCore, createStorage, createTypedError, invitationsRouter, isUniqueViolation, mediaRouter, organizationRouter, parseEnv, usersRouter };
3018
+ export { ALLOWED_MIME, ApiToken, AudienceAsk, AudiencePanelData, AudienceService, AudienceUnavailableError, CannotRemoveSelfError, CollectionDefinition, CollectionNotFoundError, CollectionsService, DefinitionCreateDto, DefinitionRepository, DefinitionUpdateDto, DeployFailedError, DeployHookMissingError, DomainError, DuplicateSlugError, EmailService, Entry, EntryCreateDto, EntryNotFoundError, EntryRepository, EntrySearchHit, EntryUpdateDto, ErrorType, HealthService, InvalidEntryDataError, Invitation, InvitationInvalidError, Media, MediaFinalizeDto, MediaNotFoundError, MediaRepository, MediaService, MediaUpdateDto, NewCollectionDefinition, NewEntry, NewMedia, NewOrganization, Organization, OrganizationAlreadyInitializedError, OrganizationInitDto, OrganizationNotInitializedError, OrganizationRepository, OrganizationService, OrganizationUpdateDto, S3Storage, Session, SessionNotFoundError, TooManyAttemptsError, UnsupportedMimeError, UploadIncompleteError, User, UserNotFoundError, UsersRepository, UsersService, adminProcedure, apiTokensRouter, appRouter, audienceRouter, authRouter, collectionsRouter, connectDb, createCore, createStorage, createTypedError, invitationsRouter, isUniqueViolation, mediaRouter, mergeRouters, middleware, organizationRouter, parseEnv, procedure, protectedProcedure, publicProcedure, router, usersRouter };
2774
3019
  export type { AppRouter, AuthSession, Core, CoreContext, CoreEnv, CoreServices, EmailEvent, HealthStatus, S3Config, StorageDriver, StoreDb, TrpcErrorCode };