@headless-lms/adapter-db 0.3.0 → 0.4.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.
Files changed (73) hide show
  1. package/dist/index.d.ts +6 -1
  2. package/dist/index.js +6 -1
  3. package/dist/repositories/admin.js +1 -1
  4. package/dist/repositories/assets.d.ts +1 -2
  5. package/dist/repositories/assets.js +0 -4
  6. package/dist/repositories/assets.js.map +1 -1
  7. package/dist/repositories/automations.d.ts +0 -1
  8. package/dist/repositories/automations.js +1 -17
  9. package/dist/repositories/automations.js.map +1 -1
  10. package/dist/repositories/chats.d.ts +4 -4
  11. package/dist/repositories/chats.js +33 -18
  12. package/dist/repositories/chats.js.map +1 -1
  13. package/dist/repositories/content.d.ts +3 -3
  14. package/dist/repositories/content.js +35 -12
  15. package/dist/repositories/content.js.map +1 -1
  16. package/dist/repositories/devices.d.ts +17 -0
  17. package/dist/repositories/devices.js +75 -0
  18. package/dist/repositories/devices.js.map +1 -0
  19. package/dist/repositories/digest-runs.d.ts +14 -0
  20. package/dist/repositories/digest-runs.js +39 -0
  21. package/dist/repositories/digest-runs.js.map +1 -0
  22. package/dist/repositories/discussion.d.ts +6 -1
  23. package/dist/repositories/discussion.js +9 -4
  24. package/dist/repositories/discussion.js.map +1 -1
  25. package/dist/repositories/entitlements.d.ts +3 -1
  26. package/dist/repositories/entitlements.js +12 -6
  27. package/dist/repositories/entitlements.js.map +1 -1
  28. package/dist/repositories/inserted-row.d.ts +5 -0
  29. package/dist/repositories/inserted-row.js +7 -0
  30. package/dist/repositories/inserted-row.js.map +1 -0
  31. package/dist/repositories/mentions.d.ts +17 -0
  32. package/dist/repositories/mentions.js +55 -0
  33. package/dist/repositories/mentions.js.map +1 -0
  34. package/dist/repositories/notification-settings.d.ts +19 -0
  35. package/dist/repositories/notification-settings.js +67 -0
  36. package/dist/repositories/notification-settings.js.map +1 -0
  37. package/dist/repositories/notifications.d.ts +23 -16
  38. package/dist/repositories/notifications.js +152 -44
  39. package/dist/repositories/notifications.js.map +1 -1
  40. package/dist/repositories/organizations.d.ts +1 -0
  41. package/dist/repositories/organizations.js +4 -1
  42. package/dist/repositories/organizations.js.map +1 -1
  43. package/dist/repositories/posts.d.ts +4 -8
  44. package/dist/repositories/posts.js +25 -28
  45. package/dist/repositories/posts.js.map +1 -1
  46. package/dist/repositories/subscriptions.d.ts +18 -0
  47. package/dist/repositories/subscriptions.js +72 -0
  48. package/dist/repositories/subscriptions.js.map +1 -0
  49. package/dist/schema/automations.d.ts +524 -19
  50. package/dist/schema/automations.js +73 -7
  51. package/dist/schema/automations.js.map +1 -1
  52. package/dist/schema/discussion.d.ts +277 -127
  53. package/dist/schema/discussion.js +59 -24
  54. package/dist/schema/discussion.js.map +1 -1
  55. package/dist/schema/identity.d.ts +109 -109
  56. package/dist/schema/identity.js +28 -70
  57. package/dist/schema/identity.js.map +1 -1
  58. package/dist/schema/index.d.ts +5 -5
  59. package/dist/schema/index.js +10 -6
  60. package/drizzle/0011_digest_runs.sql +8 -0
  61. package/drizzle/0012_subscriptions.sql +16 -0
  62. package/drizzle/0013_mentions.sql +10 -0
  63. package/drizzle/0014_notification_settings_devices.sql +36 -0
  64. package/drizzle/0015_automations_drop_source.sql +2 -0
  65. package/drizzle/0016_notifications_automations.sql +48 -0
  66. package/drizzle/meta/0011_snapshot.json +8868 -0
  67. package/drizzle/meta/0012_snapshot.json +8873 -0
  68. package/drizzle/meta/0013_snapshot.json +8943 -0
  69. package/drizzle/meta/0014_snapshot.json +9305 -0
  70. package/drizzle/meta/0015_snapshot.json +9270 -0
  71. package/drizzle/meta/0016_snapshot.json +9230 -0
  72. package/drizzle/meta/_journal.json +42 -0
  73. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"automations.js","names":[],"sources":["../../src/schema/automations.ts"],"sourcesContent":["// automations tables — org-scoped automation definitions and their run\n// history. `automations.actions` and `automation_runs.action_results` are\n// ordered jsonb blobs (contract types owned by @headless-lms/core/types); a run's\n// `event` is the triggering DomainEvent snapshot, stored verbatim.\nimport {\n pgTable,\n text,\n boolean,\n jsonb,\n timestamp,\n primaryKey,\n index,\n uniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport { sql } from \"drizzle-orm\";\nimport { genId } from \"@headless-lms/core/shared/id\";\nimport { organizations } from \"./organizations.js\";\nimport type {\n Automation,\n AutomationAction,\n AutomationActionResult,\n AutomationRun,\n} from \"@headless-lms/core/schemas\";\nimport type { DomainEvent } from \"@headless-lms/core/shared/ports\";\nimport type { Expect, NoDrift } from \"./drift.js\";\n\nexport const automations = pgTable(\n \"automations\",\n {\n orgId: text(\"org_id\")\n .notNull()\n .references(() => organizations.id),\n id: text(\"id\")\n .notNull()\n .$defaultFn(() => genId(\"automation\")),\n name: text(\"name\").notNull(),\n kind: text(\"kind\", { enum: [\"workflow\", \"webhook\"] })\n .notNull()\n .default(\"workflow\"),\n description: text(\"description\"),\n triggers: text(\"triggers\").array().notNull(),\n actions: jsonb(\"actions\").$type<AutomationAction[]>().notNull(),\n enabled: boolean(\"enabled\").notNull().default(true),\n filter: jsonb(\"filter\").$type<Automation[\"filter\"]>(),\n source: text(\"source\", { enum: [\"system\", \"user\"] })\n .notNull()\n .default(\"user\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (t) => ({\n pk: primaryKey({ columns: [t.orgId, t.id] }),\n triggersIdx: index(\"automations_triggers_idx\").using(\"gin\", t.triggers),\n systemSeedIdx: uniqueIndex(\"automations_system_seed_idx\")\n .on(t.orgId, t.name, sql`coalesce(${t.filter}->>'communityId', '')`)\n .where(sql`${t.source} = 'system'`),\n }),\n);\n\nexport const automationRuns = pgTable(\n \"automation_runs\",\n {\n orgId: text(\"org_id\")\n .notNull()\n .references(() => organizations.id),\n id: text(\"id\")\n .notNull()\n .$defaultFn(() => genId(\"automationRun\")),\n automationId: text(\"automation_id\").notNull(),\n trigger: text(\"trigger\").notNull(),\n // At-least-once dedupe key for the triggering event; DB-internal, not part of the domain `AutomationRun` type.\n eventId: text(\"event_id\").notNull(),\n event: jsonb(\"event\").$type<DomainEvent>().notNull(),\n status: text(\"status\", { enum: [\"running\", \"completed\", \"failed\"] }).notNull(),\n actionResults: jsonb(\"action_results\").$type<AutomationActionResult[]>().notNull().default([]),\n startedAt: timestamp(\"started_at\", { withTimezone: true }).notNull(),\n finishedAt: timestamp(\"finished_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (t) => ({\n pk: primaryKey({ columns: [t.orgId, t.id] }),\n automationIdx: index(\"automation_runs_org_automation_idx\").on(t.orgId, t.automationId),\n eventDedupeIdx: uniqueIndex(\"automation_runs_org_automation_event_idx\").on(\n t.orgId,\n t.automationId,\n t.eventId,\n ),\n }),\n);\n\ntype _AutomationsDrift = Expect<NoDrift<typeof automations.$inferSelect, Automation>>;\ntype _AutomationRunsDrift = Expect<NoDrift<typeof automationRuns.$inferSelect, AutomationRun>>;\n"],"mappings":";;;;;AA0BA,MAAa,cAAc,QACzB,eACA;CACE,OAAO,KAAK,QAAQ,CAAC,CAClB,QAAQ,CAAC,CACT,iBAAiB,cAAc,EAAE;CACpC,IAAI,KAAK,IAAI,CAAC,CACX,QAAQ,CAAC,CACT,iBAAiB,MAAM,YAAY,CAAC;CACvC,MAAM,KAAK,MAAM,CAAC,CAAC,QAAQ;CAC3B,MAAM,KAAK,QAAQ,EAAE,MAAM,CAAC,YAAY,SAAS,EAAE,CAAC,CAAC,CAClD,QAAQ,CAAC,CACT,QAAQ,UAAU;CACrB,aAAa,KAAK,aAAa;CAC/B,UAAU,KAAK,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ;CAC3C,SAAS,MAAM,SA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AAQ,EAAE,CAAC,CAAC,CAAC,QAAQ;CAC7E,eAAe,MAAM,gBAAgB,CAAC,CAAC,MAAgC,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC7F,WAAW,UAAU,cAAc,EAAE,cAAc,KAAK,CAAC,CAAC,CAAC,QAAQ;CACnE,YAAY,UAAU,eAAe,EAAE,cAAc,KAAK,CAAC;CAC3D,WAAW,UAAU,cAAc,EAAE,cAAc,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW;CAChF,WAAW,UAAU,cAAc,EAAE,cAAc,KAAK,CAAC,CAAC,CACvD,QAAQ,CAAC,CACT,WAAW,CAAC,CACZ,gCAAgB,IAAI,KAAK,CAAC;AAC/B,IACC,OAAO;CACN,IAAI,WAAW,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;CAC3C,eAAe,MAAM,oCAAoC,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY;CACrF,gBAAgB,YAAY,0CAA0C,CAAC,CAAC,GACtE,EAAE,OACF,EAAE,cACF,EAAE,OACJ;AACF,EACF"}
1
+ {"version":3,"file":"automations.js","names":[],"sources":["../../src/schema/automations.ts"],"sourcesContent":["// automations tables — org-scoped automation definitions and their run\n// history. `automations.actions` and `automation_runs.action_results` are\n// ordered jsonb blobs (contract types owned by @headless-lms/core/types); a run's\n// `event` is the triggering DomainEvent snapshot, stored verbatim.\nimport {\n pgTable,\n text,\n boolean,\n jsonb,\n timestamp,\n primaryKey,\n foreignKey,\n index,\n uniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport { desc, sql } from \"drizzle-orm\";\nimport { genId } from \"@headless-lms/core/shared/id\";\nimport { organizations, orgUsers } from \"./organizations.js\";\nimport { communities, spaces } from \"./content.js\";\nimport type {\n Automation,\n AutomationAction,\n AutomationActionResult,\n AutomationRun,\n} from \"@headless-lms/core/schemas\";\nimport type { DomainEvent, JsonValue } from \"@headless-lms/core/shared/ports\";\nimport type { Reason } from \"@headless-lms/core/types\";\nimport type { Expect, NoDrift } from \"./drift.js\";\n\nexport const automations = pgTable(\n \"automations\",\n {\n orgId: text(\"org_id\")\n .notNull()\n .references(() => organizations.id),\n id: text(\"id\")\n .notNull()\n .$defaultFn(() => genId(\"automation\")),\n name: text(\"name\").notNull(),\n kind: text(\"kind\", { enum: [\"workflow\", \"webhook\"] })\n .notNull()\n .default(\"workflow\"),\n description: text(\"description\"),\n triggers: text(\"triggers\").array().notNull(),\n actions: jsonb(\"actions\").$type<AutomationAction[]>().notNull(),\n enabled: boolean(\"enabled\").notNull().default(true),\n filter: jsonb(\"filter\").$type<Automation[\"filter\"]>(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (t) => ({\n pk: primaryKey({ columns: [t.orgId, t.id] }),\n triggersIdx: index(\"automations_triggers_idx\").using(\"gin\", t.triggers),\n }),\n);\n\nexport const automationRuns = pgTable(\n \"automation_runs\",\n {\n orgId: text(\"org_id\")\n .notNull()\n .references(() => organizations.id),\n id: text(\"id\")\n .notNull()\n .$defaultFn(() => genId(\"automationRun\")),\n automationId: text(\"automation_id\").notNull(),\n trigger: text(\"trigger\").notNull(),\n // At-least-once dedupe key for the triggering event; DB-internal, not part of the domain `AutomationRun` type.\n eventId: text(\"event_id\").notNull(),\n event: jsonb(\"event\").$type<DomainEvent>().notNull(),\n status: text(\"status\", { enum: [\"running\", \"completed\", \"failed\"] }).notNull(),\n actionResults: jsonb(\"action_results\").$type<AutomationActionResult[]>().notNull().default([]),\n startedAt: timestamp(\"started_at\", { withTimezone: true }).notNull(),\n finishedAt: timestamp(\"finished_at\", { withTimezone: true }),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n updatedAt: timestamp(\"updated_at\", { withTimezone: true })\n .notNull()\n .defaultNow()\n .$onUpdate(() => new Date()),\n },\n (t) => ({\n pk: primaryKey({ columns: [t.orgId, t.id] }),\n automationIdx: index(\"automation_runs_org_automation_idx\").on(t.orgId, t.automationId),\n eventDedupeIdx: uniqueIndex(\"automation_runs_org_automation_event_idx\").on(\n t.orgId,\n t.automationId,\n t.eventId,\n ),\n }),\n);\n\nexport const notifications = pgTable(\n \"notifications\",\n {\n orgId: text(\"org_id\").notNull(),\n id: text(\"id\")\n .notNull()\n .$defaultFn(() => genId(\"notification\")),\n userId: text(\"user_id\").notNull(),\n sourceEventId: text(\"source_event_id\"),\n type: text(\"type\").notNull(),\n scope: text(\"scope\", { enum: [\"org\", \"community\", \"space\", \"chat\"] }).notNull(),\n reasons: text(\"reasons\").array().$type<Reason[]>().notNull(),\n matchedReason: text(\"matched_reason\").$type<Reason>().notNull(),\n category: text(\"category\").notNull(),\n communityId: text(\"community_id\"),\n spaceId: text(\"space_id\"),\n actorOrgUserId: text(\"actor_org_user_id\"),\n subjectType: text(\"subject_type\"),\n subjectId: text(\"subject_id\"),\n parentType: text(\"parent_type\"),\n parentId: text(\"parent_id\"),\n display: jsonb(\"display\").$type<Record<string, JsonValue>>().notNull(),\n inApp: boolean(\"in_app\").notNull(),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n readAt: timestamp(\"read_at\", { withTimezone: true }),\n },\n (t) => ({\n pk: primaryKey({ columns: [t.orgId, t.id] }),\n userFk: foreignKey({\n columns: [t.orgId, t.userId],\n foreignColumns: [orgUsers.orgId, orgUsers.userId],\n }).onDelete(\"cascade\"),\n communityFk: foreignKey({\n columns: [t.orgId, t.communityId],\n foreignColumns: [communities.orgId, communities.id],\n }).onDelete(\"cascade\"),\n spaceFk: foreignKey({\n columns: [t.orgId, t.spaceId],\n foreignColumns: [spaces.orgId, spaces.id],\n }).onDelete(\"cascade\"),\n sourceIdx: uniqueIndex(\"notifications_source_event_idx\")\n .on(t.orgId, t.sourceEventId, t.userId, sql`coalesce(${t.communityId}, '')`)\n .where(sql`${t.sourceEventId} is not null`),\n listIdx: index(\"notifications_list_idx\")\n .on(t.orgId, t.userId, desc(t.createdAt), desc(t.id))\n .where(sql`${t.inApp}`),\n communityIdx: index(\"notifications_community_idx\").on(t.orgId, t.userId, t.communityId),\n categoryIdx: index(\"notifications_category_idx\").on(t.orgId, t.userId, t.category),\n reasonsIdx: index(\"notifications_reasons_idx\").using(\"gin\", t.reasons),\n }),\n);\n\nexport const notificationDeliveries = pgTable(\n \"notification_deliveries\",\n {\n orgId: text(\"org_id\").notNull(),\n id: text(\"id\")\n .notNull()\n .$defaultFn(() => genId(\"notificationDelivery\")),\n notificationId: text(\"notification_id\").notNull(),\n channel: text(\"channel\").notNull(),\n status: text(\"status\", { enum: [\"pending\", \"sent\", \"failed\"] })\n .notNull()\n .default(\"pending\"),\n lastError: text(\"last_error\"),\n createdAt: timestamp(\"created_at\", { withTimezone: true }).notNull().defaultNow(),\n sentAt: timestamp(\"sent_at\", { withTimezone: true }),\n },\n (t) => ({\n pk: primaryKey({ columns: [t.orgId, t.id] }),\n notificationFk: foreignKey({\n columns: [t.orgId, t.notificationId],\n foreignColumns: [notifications.orgId, notifications.id],\n }).onDelete(\"cascade\"),\n channelIdx: uniqueIndex(\"notification_deliveries_channel_idx\").on(\n t.orgId,\n t.notificationId,\n t.channel,\n ),\n }),\n);\n\ntype _AutomationsDrift = Expect<NoDrift<typeof automations.$inferSelect, Automation>>;\ntype _AutomationRunsDrift = Expect<NoDrift<typeof automationRuns.$inferSelect, AutomationRun>>;\n"],"mappings":";;;;;;AA6BA,MAAa,cAAc,QACzB,eACA;CACE,OAAO,KAAK,QAAQ,CAAC,CAClB,QAAQ,CAAC,CACT,iBAAiB,cAAc,EAAE;CACpC,IAAI,KAAK,IAAI,CAAC,CACX,QAAQ,CAAC,CACT,iBAAiB,MAAM,YAAY,CAAC;CACvC,MAAM,KAAK,MAAM,CAAC,CAAC,QAAQ;CAC3B,MAAM,KAAK,QAAQ,EAAE,MAAM,CA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AM,6BAA6B,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW;CACtF,aAAa,MAAM,4BAA4B,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;CACjF,YAAY,MAAM,2BAA2B,CAAC,CAAC,MAAM,OAAO,EAAE,OAAO;AACvE,EACF;AAEA,MAAa,yBAAyB,QACpC,2BACA;CACE,OAAO,KAAK,QAAQ,CAAC,CAAC,QAAQ;CAC9B,IAAI,KAAK,IAAI,CAAC,CACX,QAAQ,CAAC,CACT,iBAAiB,MAAM,sBAAsB,CAAC;CACjD,gBAAgB,KAAK,iBAAiB,CAAC,CAAC,QAAQ;CAChD,SAAS,KAAK,SAAS,CAAC,CAAC,QAAQ;CACjC,QAAQ,KAAK,UAAU,EAAE,MAAM;EAAC;EAAW;EAAQ;CAAQ,EAAE,CAAC,CAAC,CAC5D,QAAQ,CAAC,CACT,QAAQ,SAAS;CACpB,WAAW,KAAK,YAAY;CAC5B,WAAW,UAAU,cAAc,EAAE,cAAc,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW;CAChF,QAAQ,UAAU,WAAW,EAAE,cAAc,KAAK,CAAC;AACrD,IACC,OAAO;CACN,IAAI,WAAW,EAAE,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;CAC3C,gBAAgB,WAAW;EACzB,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc;EACnC,gBAAgB,CAAC,cAAc,OAAO,cAAc,EAAE;CACxD,CAAC,CAAC,CAAC,SAAS,SAAS;CACrB,YAAY,YAAY,qCAAqC,CAAC,CAAC,GAC7D,EAAE,OACF,EAAE,gBACF,EAAE,OACJ;AACF,EACF"}
@@ -440,98 +440,6 @@ declare const postReactions: import("drizzle-orm/pg-core").PgTableWithColumns<{
440
440
  };
441
441
  dialect: "pg";
442
442
  }>;
443
- declare const postFollows: import("drizzle-orm/pg-core").PgTableWithColumns<{
444
- name: "post_follows";
445
- schema: undefined;
446
- columns: {
447
- orgId: import("drizzle-orm/pg-core").PgColumn<{
448
- name: "org_id";
449
- tableName: "post_follows";
450
- dataType: "string";
451
- columnType: "PgText";
452
- data: string;
453
- driverParam: string;
454
- notNull: true;
455
- hasDefault: false;
456
- isPrimaryKey: false;
457
- isAutoincrement: false;
458
- hasRuntimeDefault: false;
459
- enumValues: [string, ...string[]];
460
- baseColumn: never;
461
- identity: undefined;
462
- generated: undefined;
463
- }, {}, {}>;
464
- postId: import("drizzle-orm/pg-core").PgColumn<{
465
- name: "post_id";
466
- tableName: "post_follows";
467
- dataType: "string";
468
- columnType: "PgText";
469
- data: string;
470
- driverParam: string;
471
- notNull: true;
472
- hasDefault: false;
473
- isPrimaryKey: false;
474
- isAutoincrement: false;
475
- hasRuntimeDefault: false;
476
- enumValues: [string, ...string[]];
477
- baseColumn: never;
478
- identity: undefined;
479
- generated: undefined;
480
- }, {}, {}>;
481
- orgUserId: import("drizzle-orm/pg-core").PgColumn<{
482
- name: "org_user_id";
483
- tableName: "post_follows";
484
- dataType: "string";
485
- columnType: "PgText";
486
- data: string;
487
- driverParam: string;
488
- notNull: true;
489
- hasDefault: false;
490
- isPrimaryKey: false;
491
- isAutoincrement: false;
492
- hasRuntimeDefault: false;
493
- enumValues: [string, ...string[]];
494
- baseColumn: never;
495
- identity: undefined;
496
- generated: undefined;
497
- }, {}, {}>;
498
- createdAt: import("drizzle-orm/pg-core").PgColumn<{
499
- name: "created_at";
500
- tableName: "post_follows";
501
- dataType: "date";
502
- columnType: "PgTimestamp";
503
- data: Date;
504
- driverParam: string;
505
- notNull: true;
506
- hasDefault: true;
507
- isPrimaryKey: false;
508
- isAutoincrement: false;
509
- hasRuntimeDefault: false;
510
- enumValues: undefined;
511
- baseColumn: never;
512
- identity: undefined;
513
- generated: undefined;
514
- }, {}, {}>;
515
- updatedAt: import("drizzle-orm/pg-core").PgColumn<{
516
- name: "updated_at";
517
- tableName: "post_follows";
518
- dataType: "date";
519
- columnType: "PgTimestamp";
520
- data: Date;
521
- driverParam: string;
522
- notNull: true;
523
- hasDefault: true;
524
- isPrimaryKey: false;
525
- isAutoincrement: false;
526
- hasRuntimeDefault: false;
527
- enumValues: undefined;
528
- baseColumn: never;
529
- identity: undefined;
530
- generated: undefined;
531
- }, {}, {}>;
532
- };
533
- dialect: "pg";
534
- }>;
535
443
  declare const postBookmarks: import("drizzle-orm/pg-core").PgTableWithColumns<{
536
444
  name: "post_bookmarks";
537
445
  schema: undefined;
@@ -1598,40 +1506,6 @@ declare const chatUsers: import("drizzle-orm/pg-core").PgTableWithColumns<{
1598
1506
  identity: undefined;
1599
1507
  generated: undefined;
1600
1508
  }, {}, {}>;
1601
- muted: import("drizzle-orm/pg-core").PgColumn<{
1602
- name: "muted";
1603
- tableName: "chat_users";
1604
- dataType: "boolean";
1605
- columnType: "PgBoolean";
1606
- data: boolean;
1607
- driverParam: boolean;
1608
- notNull: true;
1609
- hasDefault: true;
1610
- isPrimaryKey: false;
1611
- isAutoincrement: false;
1612
- hasRuntimeDefault: false;
1613
- enumValues: undefined;
1614
- baseColumn: never;
1615
- identity: undefined;
1616
- generated: undefined;
1617
- }, {}, {}>;
1618
- mutedUntil: import("drizzle-orm/pg-core").PgColumn<{
1619
- name: "muted_until";
1620
- tableName: "chat_users";
1621
- dataType: "date";
1622
- columnType: "PgTimestamp";
1623
- data: Date;
1624
- driverParam: string;
1625
- notNull: false;
1626
- hasDefault: false;
1627
- isPrimaryKey: false;
1628
- isAutoincrement: false;
1629
- hasRuntimeDefault: false;
1630
- enumValues: undefined;
1631
- baseColumn: never;
1632
- identity: undefined;
1633
- generated: undefined;
1634
- }, {}, {}>;
1635
1509
  createdAt: import("drizzle-orm/pg-core").PgColumn<{
1636
1510
  name: "created_at";
1637
1511
  tableName: "chat_users";
@@ -2418,6 +2292,282 @@ declare const blockedUsers: import("drizzle-orm/pg-core").PgTableWithColumns<{
2418
2292
  };
2419
2293
  dialect: "pg";
2420
2294
  }>;
2295
+ declare const digestRuns: import("drizzle-orm/pg-core").PgTableWithColumns<{
2296
+ name: "digest_runs";
2297
+ schema: undefined;
2298
+ columns: {
2299
+ orgId: import("drizzle-orm/pg-core").PgColumn<{
2300
+ name: "org_id";
2301
+ tableName: "digest_runs";
2302
+ dataType: "string";
2303
+ columnType: "PgText";
2304
+ data: string;
2305
+ driverParam: string;
2306
+ notNull: true;
2307
+ hasDefault: false;
2308
+ isPrimaryKey: false;
2309
+ isAutoincrement: false;
2310
+ hasRuntimeDefault: false;
2311
+ enumValues: [string, ...string[]];
2312
+ baseColumn: never;
2313
+ identity: undefined;
2314
+ generated: undefined;
2315
+ }, {}, {}>;
2316
+ communityId: import("drizzle-orm/pg-core").PgColumn<{
2317
+ name: "community_id";
2318
+ tableName: "digest_runs";
2319
+ dataType: "string";
2320
+ columnType: "PgText";
2321
+ data: string;
2322
+ driverParam: string;
2323
+ notNull: true;
2324
+ hasDefault: false;
2325
+ isPrimaryKey: false;
2326
+ isAutoincrement: false;
2327
+ hasRuntimeDefault: false;
2328
+ enumValues: [string, ...string[]];
2329
+ baseColumn: never;
2330
+ identity: undefined;
2331
+ generated: undefined;
2332
+ }, {}, {}>;
2333
+ lastDueAt: import("drizzle-orm/pg-core").PgColumn<{
2334
+ name: "last_due_at";
2335
+ tableName: "digest_runs";
2336
+ dataType: "date";
2337
+ columnType: "PgTimestamp";
2338
+ data: Date;
2339
+ driverParam: string;
2340
+ notNull: true;
2341
+ hasDefault: false;
2342
+ isPrimaryKey: false;
2343
+ isAutoincrement: false;
2344
+ hasRuntimeDefault: false;
2345
+ enumValues: undefined;
2346
+ baseColumn: never;
2347
+ identity: undefined;
2348
+ generated: undefined;
2349
+ }, {}, {}>;
2350
+ };
2351
+ dialect: "pg";
2352
+ }>;
2353
+ declare const subscriptions: import("drizzle-orm/pg-core").PgTableWithColumns<{
2354
+ name: "subscriptions";
2355
+ schema: undefined;
2356
+ columns: {
2357
+ orgId: import("drizzle-orm/pg-core").PgColumn<{
2358
+ name: "org_id";
2359
+ tableName: "subscriptions";
2360
+ dataType: "string";
2361
+ columnType: "PgText";
2362
+ data: string;
2363
+ driverParam: string;
2364
+ notNull: true;
2365
+ hasDefault: false;
2366
+ isPrimaryKey: false;
2367
+ isAutoincrement: false;
2368
+ hasRuntimeDefault: false;
2369
+ enumValues: [string, ...string[]];
2370
+ baseColumn: never;
2371
+ identity: undefined;
2372
+ generated: undefined;
2373
+ }, {}, {}>;
2374
+ orgUserId: import("drizzle-orm/pg-core").PgColumn<{
2375
+ name: "org_user_id";
2376
+ tableName: "subscriptions";
2377
+ dataType: "string";
2378
+ columnType: "PgText";
2379
+ data: string;
2380
+ driverParam: string;
2381
+ notNull: true;
2382
+ hasDefault: false;
2383
+ isPrimaryKey: false;
2384
+ isAutoincrement: false;
2385
+ hasRuntimeDefault: false;
2386
+ enumValues: [string, ...string[]];
2387
+ baseColumn: never;
2388
+ identity: undefined;
2389
+ generated: undefined;
2390
+ }, {}, {}>;
2391
+ itemType: import("drizzle-orm/pg-core").PgColumn<{
2392
+ name: "item_type";
2393
+ tableName: "subscriptions";
2394
+ dataType: "string";
2395
+ columnType: "PgText";
2396
+ data: "space" | "post" | "chat";
2397
+ driverParam: string;
2398
+ notNull: true;
2399
+ hasDefault: false;
2400
+ isPrimaryKey: false;
2401
+ isAutoincrement: false;
2402
+ hasRuntimeDefault: false;
2403
+ enumValues: ["post", "space", "chat"];
2404
+ baseColumn: never;
2405
+ identity: undefined;
2406
+ generated: undefined;
2407
+ }, {}, {}>;
2408
+ itemId: import("drizzle-orm/pg-core").PgColumn<{
2409
+ name: "item_id";
2410
+ tableName: "subscriptions";
2411
+ dataType: "string";
2412
+ columnType: "PgText";
2413
+ data: string;
2414
+ driverParam: string;
2415
+ notNull: true;
2416
+ hasDefault: false;
2417
+ isPrimaryKey: false;
2418
+ isAutoincrement: false;
2419
+ hasRuntimeDefault: false;
2420
+ enumValues: [string, ...string[]];
2421
+ baseColumn: never;
2422
+ identity: undefined;
2423
+ generated: undefined;
2424
+ }, {}, {}>;
2425
+ state: import("drizzle-orm/pg-core").PgColumn<{
2426
+ name: "state";
2427
+ tableName: "subscriptions";
2428
+ dataType: "string";
2429
+ columnType: "PgText";
2430
+ data: "following" | "muted";
2431
+ driverParam: string;
2432
+ notNull: true;
2433
+ hasDefault: false;
2434
+ isPrimaryKey: false;
2435
+ isAutoincrement: false;
2436
+ hasRuntimeDefault: false;
2437
+ enumValues: ["following", "muted"];
2438
+ baseColumn: never;
2439
+ identity: undefined;
2440
+ generated: undefined;
2441
+ }, {}, {}>;
2442
+ mutedUntil: import("drizzle-orm/pg-core").PgColumn<{
2443
+ name: "muted_until";
2444
+ tableName: "subscriptions";
2445
+ dataType: "date";
2446
+ columnType: "PgTimestamp";
2447
+ data: Date;
2448
+ driverParam: string;
2449
+ notNull: false;
2450
+ hasDefault: false;
2451
+ isPrimaryKey: false;
2452
+ isAutoincrement: false;
2453
+ hasRuntimeDefault: false;
2454
+ enumValues: undefined;
2455
+ baseColumn: never;
2456
+ identity: undefined;
2457
+ generated: undefined;
2458
+ }, {}, {}>;
2459
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
2460
+ name: "created_at";
2461
+ tableName: "subscriptions";
2462
+ dataType: "date";
2463
+ columnType: "PgTimestamp";
2464
+ data: Date;
2465
+ driverParam: string;
2466
+ notNull: true;
2467
+ hasDefault: true;
2468
+ isPrimaryKey: false;
2469
+ isAutoincrement: false;
2470
+ hasRuntimeDefault: false;
2471
+ enumValues: undefined;
2472
+ baseColumn: never;
2473
+ identity: undefined;
2474
+ generated: undefined;
2475
+ }, {}, {}>;
2476
+ };
2477
+ dialect: "pg";
2478
+ }>;
2479
+ declare const mentions: import("drizzle-orm/pg-core").PgTableWithColumns<{
2480
+ name: "mentions";
2481
+ schema: undefined;
2482
+ columns: {
2483
+ orgId: import("drizzle-orm/pg-core").PgColumn<{
2484
+ name: "org_id";
2485
+ tableName: "mentions";
2486
+ dataType: "string";
2487
+ columnType: "PgText";
2488
+ data: string;
2489
+ driverParam: string;
2490
+ notNull: true;
2491
+ hasDefault: false;
2492
+ isPrimaryKey: false;
2493
+ isAutoincrement: false;
2494
+ hasRuntimeDefault: false;
2495
+ enumValues: [string, ...string[]];
2496
+ baseColumn: never;
2497
+ identity: undefined;
2498
+ generated: undefined;
2499
+ }, {}, {}>;
2500
+ itemType: import("drizzle-orm/pg-core").PgColumn<{
2501
+ name: "item_type";
2502
+ tableName: "mentions";
2503
+ dataType: "string";
2504
+ columnType: "PgText";
2505
+ data: "comment" | "post" | "message";
2506
+ driverParam: string;
2507
+ notNull: true;
2508
+ hasDefault: false;
2509
+ isPrimaryKey: false;
2510
+ isAutoincrement: false;
2511
+ hasRuntimeDefault: false;
2512
+ enumValues: ["post", "comment", "message"];
2513
+ baseColumn: never;
2514
+ identity: undefined;
2515
+ generated: undefined;
2516
+ }, {}, {}>;
2517
+ itemId: import("drizzle-orm/pg-core").PgColumn<{
2518
+ name: "item_id";
2519
+ tableName: "mentions";
2520
+ dataType: "string";
2521
+ columnType: "PgText";
2522
+ data: string;
2523
+ driverParam: string;
2524
+ notNull: true;
2525
+ hasDefault: false;
2526
+ isPrimaryKey: false;
2527
+ isAutoincrement: false;
2528
+ hasRuntimeDefault: false;
2529
+ enumValues: [string, ...string[]];
2530
+ baseColumn: never;
2531
+ identity: undefined;
2532
+ generated: undefined;
2533
+ }, {}, {}>;
2534
+ orgUserId: import("drizzle-orm/pg-core").PgColumn<{
2535
+ name: "org_user_id";
2536
+ tableName: "mentions";
2537
+ dataType: "string";
2538
+ columnType: "PgText";
2539
+ data: string;
2540
+ driverParam: string;
2541
+ notNull: true;
2542
+ hasDefault: false;
2543
+ isPrimaryKey: false;
2544
+ isAutoincrement: false;
2545
+ hasRuntimeDefault: false;
2546
+ enumValues: [string, ...string[]];
2547
+ baseColumn: never;
2548
+ identity: undefined;
2549
+ generated: undefined;
2550
+ }, {}, {}>;
2551
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
2552
+ name: "created_at";
2553
+ tableName: "mentions";
2554
+ dataType: "date";
2555
+ columnType: "PgTimestamp";
2556
+ data: Date;
2557
+ driverParam: string;
2558
+ notNull: true;
2559
+ hasDefault: true;
2560
+ isPrimaryKey: false;
2561
+ isAutoincrement: false;
2562
+ hasRuntimeDefault: false;
2563
+ enumValues: undefined;
2564
+ baseColumn: never;
2565
+ identity: undefined;
2566
+ generated: undefined;
2567
+ }, {}, {}>;
2568
+ };
2569
+ dialect: "pg";
2570
+ }>;
2421
2571
  //#endregion
2422
- export { blockedUsers, chatUsers, chats, commentFlags, commentReactions, comments, messageAttachments, messageFlags, messageReactions, messages, postBookmarks, postFlags, postFollows, postReactions, posts };
2572
+ export { blockedUsers, chatUsers, chats, commentFlags, commentReactions, comments, digestRuns, mentions, messageAttachments, messageFlags, messageReactions, messages, postBookmarks, postFlags, postReactions, posts, subscriptions };
2423
2573
  //# sourceMappingURL=discussion.d.ts.map
@@ -98,27 +98,6 @@ const postReactions = pgTable("post_reactions", {
98
98
  foreignColumns: [orgUsers.orgId, orgUsers.id]
99
99
  }).onDelete("cascade")
100
100
  }));
101
- const postFollows = pgTable("post_follows", {
102
- orgId: text("org_id").notNull().references(() => organizations.id),
103
- postId: text("post_id").notNull(),
104
- orgUserId: text("org_user_id").notNull(),
105
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
106
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
107
- }, (t) => ({
108
- pk: primaryKey({ columns: [
109
- t.orgId,
110
- t.postId,
111
- t.orgUserId
112
- ] }),
113
- postFk: foreignKey({
114
- columns: [t.orgId, t.postId],
115
- foreignColumns: [posts.orgId, posts.id]
116
- }).onDelete("cascade"),
117
- orgUserFk: foreignKey({
118
- columns: [t.orgId, t.orgUserId],
119
- foreignColumns: [orgUsers.orgId, orgUsers.id]
120
- }).onDelete("cascade")
121
- }));
122
101
  const postBookmarks = pgTable("post_bookmarks", {
123
102
  orgId: text("org_id").notNull().references(() => organizations.id),
124
103
  postId: text("post_id").notNull(),
@@ -305,8 +284,6 @@ const chatUsers = pgTable("chat_users", {
305
284
  joinedAt: timestamp("joined_at", { withTimezone: true }).notNull().defaultNow(),
306
285
  leftAt: timestamp("left_at", { withTimezone: true }),
307
286
  lastReadMessageId: text("last_read_message_id"),
308
- muted: boolean("muted").notNull().default(false),
309
- mutedUntil: timestamp("muted_until", { withTimezone: true }),
310
287
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
311
288
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
312
289
  }, (t) => ({
@@ -500,7 +477,65 @@ const blockedUsers = pgTable("blocked_users", {
500
477
  }).onDelete("cascade"),
501
478
  blockedIdx: index("blocked_users_blocked_idx").on(t.orgId, t.communityId, t.blockedOrgUserId)
502
479
  }));
480
+ const digestRuns = pgTable("digest_runs", {
481
+ orgId: text("org_id").notNull(),
482
+ communityId: text("community_id").notNull(),
483
+ lastDueAt: timestamp("last_due_at", { withTimezone: true }).notNull()
484
+ }, (t) => ({
485
+ pk: primaryKey({ columns: [t.orgId, t.communityId] }),
486
+ communityFk: foreignKey({
487
+ columns: [t.orgId, t.communityId],
488
+ foreignColumns: [communities.orgId, communities.id]
489
+ }).onDelete("cascade")
490
+ }));
491
+ const subscriptions = pgTable("subscriptions", {
492
+ orgId: text("org_id").notNull(),
493
+ orgUserId: text("org_user_id").notNull(),
494
+ itemType: text("item_type", { enum: [
495
+ "post",
496
+ "space",
497
+ "chat"
498
+ ] }).notNull(),
499
+ itemId: text("item_id").notNull(),
500
+ state: text("state", { enum: ["following", "muted"] }).notNull(),
501
+ mutedUntil: timestamp("muted_until", { withTimezone: true }),
502
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
503
+ }, (t) => ({
504
+ pk: primaryKey({ columns: [
505
+ t.orgId,
506
+ t.orgUserId,
507
+ t.itemType,
508
+ t.itemId
509
+ ] }),
510
+ orgUserFk: foreignKey({
511
+ columns: [t.orgId, t.orgUserId],
512
+ foreignColumns: [orgUsers.orgId, orgUsers.id]
513
+ }).onDelete("cascade"),
514
+ itemIdx: index("subscriptions_item_idx").on(t.orgId, t.itemType, t.itemId, t.state)
515
+ }));
516
+ const mentions = pgTable("mentions", {
517
+ orgId: text("org_id").notNull(),
518
+ itemType: text("item_type", { enum: [
519
+ "post",
520
+ "comment",
521
+ "message"
522
+ ] }).notNull(),
523
+ itemId: text("item_id").notNull(),
524
+ orgUserId: text("org_user_id").notNull(),
525
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
526
+ }, (t) => ({
527
+ pk: primaryKey({ columns: [
528
+ t.orgId,
529
+ t.itemType,
530
+ t.itemId,
531
+ t.orgUserId
532
+ ] }),
533
+ orgUserFk: foreignKey({
534
+ columns: [t.orgId, t.orgUserId],
535
+ foreignColumns: [orgUsers.orgId, orgUsers.id]
536
+ }).onDelete("cascade")
537
+ }));
503
538
  //#endregion
504
- export { blockedUsers, chatUsers, chats, commentFlags, commentReactions, comments, messageAttachments, messageFlags, messageReactions, messages, postBookmarks, postFlags, postFollows, postReactions, posts };
539
+ export { blockedUsers, chatUsers, chats, commentFlags, commentReactions, comments, digestRuns, mentions, messageAttachments, messageFlags, messageReactions, messages, postBookmarks, postFlags, postReactions, posts, subscriptions };
505
540
 
506
541
  //# sourceMappingURL=discussion.js.map