@openpeepshq/core 0.28.1 → 0.30.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/analytics/compile.js +15 -7
- package/dist/analytics/jamMetrics.d.ts +47 -0
- package/dist/analytics/jamMetrics.js +93 -0
- package/dist/analytics/pdfReport.js +40 -1
- package/dist/analytics/read.js +68 -5
- package/dist/analytics/report.d.ts +75 -0
- package/dist/analytics/report.js +1 -0
- package/dist/auditLog/finders.d.ts +27 -0
- package/dist/auditLog/finders.js +40 -0
- package/dist/auditLog/index.d.ts +3 -0
- package/dist/auditLog/index.js +3 -0
- package/dist/auditLog/mapping.d.ts +4 -0
- package/dist/auditLog/mapping.js +18 -0
- package/dist/auditLog/mutations.d.ts +42 -0
- package/dist/auditLog/mutations.js +43 -0
- package/dist/db/pg/map/registry.js +11 -1
- package/dist/db/pg/schema/analytics.d.ts +68 -0
- package/dist/db/pg/schema/analytics.js +10 -0
- package/dist/db/pg/schema/auditLogs.d.ts +183 -0
- package/dist/db/pg/schema/auditLogs.js +30 -0
- package/dist/db/pg/schema/documents.d.ts +17 -0
- package/dist/db/pg/schema/documents.js +10 -1
- package/dist/db/pg/schema/index.d.ts +263 -0
- package/dist/db/pg/schema/index.js +3 -0
- package/dist/db/pg/sql/0020_add_audit_logs.sql +16 -0
- package/dist/db/pg/sql/0021_jam_occurrence_recurrence_id.sql +10 -0
- package/dist/db/pg/sql/meta/0020_snapshot.json +4816 -0
- package/dist/db/pg/sql/meta/0021_snapshot.json +4718 -0
- package/dist/db/pg/sql/meta/0022_snapshot.json +182 -1
- package/dist/db/pg/sql/meta/_journal.json +15 -1
- package/dist/jams/export.d.ts +17 -4
- package/dist/jams/export.js +36 -6
- package/dist/jams/finders.js +5 -1
- package/dist/jams/index.js +3 -0
- package/dist/jams/livekit.d.ts +18 -3
- package/dist/jams/livekit.js +37 -5
- package/dist/jams/mapping.d.ts +0 -27
- package/dist/jams/mapping.js +0 -15
- package/dist/jams/token.js +14 -6
- package/dist/stats/finders.js +34 -7
- package/package.json +4 -4
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { auditLogs } from '../db/pg/schema/index.js';
|
|
3
|
+
import { allpeepDb } from '../db/index.js';
|
|
4
|
+
import { logger } from '../log/index.js';
|
|
5
|
+
const log = logger('auditLog');
|
|
6
|
+
/** Plain insert — throws on failure. */
|
|
7
|
+
export const createAuditEntry = async (data) => {
|
|
8
|
+
const { db } = await allpeepDb();
|
|
9
|
+
const [row] = await db
|
|
10
|
+
.insert(auditLogs)
|
|
11
|
+
.values({
|
|
12
|
+
id: randomUUID(),
|
|
13
|
+
actorProfileId: data.actorProfileId,
|
|
14
|
+
actorAccountId: data.actorAccountId ?? null,
|
|
15
|
+
actorIp: data.actorIp ?? null,
|
|
16
|
+
action: data.action,
|
|
17
|
+
targetType: data.targetType,
|
|
18
|
+
targetId: data.targetId ?? null,
|
|
19
|
+
targetLabel: data.targetLabel ?? null,
|
|
20
|
+
metadata: data.metadata ?? null,
|
|
21
|
+
})
|
|
22
|
+
.returning();
|
|
23
|
+
return row;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Fire-and-forget audit write: resolves the actor (profile + owning
|
|
27
|
+
* account), inserts one row and swallows its own errors. A failed audit
|
|
28
|
+
* write must never fail the admin action that triggered it — it is logged
|
|
29
|
+
* as a server error.
|
|
30
|
+
*/
|
|
31
|
+
export const recordAuditEntry = async (data, ctx) => {
|
|
32
|
+
try {
|
|
33
|
+
await createAuditEntry({
|
|
34
|
+
actorProfileId: data.actorProfileId ?? ctx.profile?.id ?? '',
|
|
35
|
+
actorAccountId: ctx.profile?.controllers?.[0]?.id ?? null,
|
|
36
|
+
actorIp: ctx.ip ?? null,
|
|
37
|
+
...data,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
log.error('audit entry write failed:', error);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -96,12 +96,15 @@ const hashtagsSplit = (data) => {
|
|
|
96
96
|
};
|
|
97
97
|
/** Older jam events stored jamId; the column is post_id. */
|
|
98
98
|
const jamEventsSplit = (data) => {
|
|
99
|
-
const { postId, jamId, ...rest } = data;
|
|
99
|
+
const { postId, jamId, recurrenceId, ...rest } = data;
|
|
100
100
|
const scalars = {};
|
|
101
101
|
const resolvedPostId = postId ?? jamId;
|
|
102
102
|
if (resolvedPostId !== undefined) {
|
|
103
103
|
scalars.postId = resolvedPostId;
|
|
104
104
|
}
|
|
105
|
+
if (recurrenceId !== undefined) {
|
|
106
|
+
scalars.recurrenceId = recurrenceId;
|
|
107
|
+
}
|
|
105
108
|
return { scalars, body: { ...rest } };
|
|
106
109
|
};
|
|
107
110
|
/** Legacy settings docs use profile id as document id, not profileId. */
|
|
@@ -472,6 +475,13 @@ export const rowToDocument = (collection, row, keepMetadata = false) => {
|
|
|
472
475
|
return rowToModel(row.id, {
|
|
473
476
|
jamId: row.postId,
|
|
474
477
|
...(row.body ?? {}),
|
|
478
|
+
// recurrence_id is the denormalized source of truth; a stale body
|
|
479
|
+
// value from a pre-migration write must not shadow it. The column is
|
|
480
|
+
// null for one-off jams, so only a real occurrence id overrides the
|
|
481
|
+
// body (an explicit null would fail the optional-string schema).
|
|
482
|
+
...(typeof row.recurrenceId === 'string'
|
|
483
|
+
? { recurrenceId: row.recurrenceId }
|
|
484
|
+
: {}),
|
|
475
485
|
}, timestamps);
|
|
476
486
|
case 'processingStats':
|
|
477
487
|
return rowToModel(row.id, {
|
|
@@ -241,6 +241,74 @@ export declare const analyticsDailyTotals: import("drizzle-orm/pg-core").PgTable
|
|
|
241
241
|
identity: undefined;
|
|
242
242
|
generated: undefined;
|
|
243
243
|
}, {}, {}>;
|
|
244
|
+
jamMinutes: import("drizzle-orm/pg-core").PgColumn<{
|
|
245
|
+
name: "jam_minutes";
|
|
246
|
+
tableName: "analytics_daily_totals";
|
|
247
|
+
dataType: "number";
|
|
248
|
+
columnType: "PgInteger";
|
|
249
|
+
data: number;
|
|
250
|
+
driverParam: string | number;
|
|
251
|
+
notNull: true;
|
|
252
|
+
hasDefault: true;
|
|
253
|
+
isPrimaryKey: false;
|
|
254
|
+
isAutoincrement: false;
|
|
255
|
+
hasRuntimeDefault: false;
|
|
256
|
+
enumValues: undefined;
|
|
257
|
+
baseColumn: never;
|
|
258
|
+
identity: undefined;
|
|
259
|
+
generated: undefined;
|
|
260
|
+
}, {}, {}>;
|
|
261
|
+
jamUniqueAttendees: import("drizzle-orm/pg-core").PgColumn<{
|
|
262
|
+
name: "jam_unique_attendees";
|
|
263
|
+
tableName: "analytics_daily_totals";
|
|
264
|
+
dataType: "number";
|
|
265
|
+
columnType: "PgInteger";
|
|
266
|
+
data: number;
|
|
267
|
+
driverParam: string | number;
|
|
268
|
+
notNull: true;
|
|
269
|
+
hasDefault: true;
|
|
270
|
+
isPrimaryKey: false;
|
|
271
|
+
isAutoincrement: false;
|
|
272
|
+
hasRuntimeDefault: false;
|
|
273
|
+
enumValues: undefined;
|
|
274
|
+
baseColumn: never;
|
|
275
|
+
identity: undefined;
|
|
276
|
+
generated: undefined;
|
|
277
|
+
}, {}, {}>;
|
|
278
|
+
jamPeakConcurrent: import("drizzle-orm/pg-core").PgColumn<{
|
|
279
|
+
name: "jam_peak_concurrent";
|
|
280
|
+
tableName: "analytics_daily_totals";
|
|
281
|
+
dataType: "number";
|
|
282
|
+
columnType: "PgInteger";
|
|
283
|
+
data: number;
|
|
284
|
+
driverParam: string | number;
|
|
285
|
+
notNull: true;
|
|
286
|
+
hasDefault: true;
|
|
287
|
+
isPrimaryKey: false;
|
|
288
|
+
isAutoincrement: false;
|
|
289
|
+
hasRuntimeDefault: false;
|
|
290
|
+
enumValues: undefined;
|
|
291
|
+
baseColumn: never;
|
|
292
|
+
identity: undefined;
|
|
293
|
+
generated: undefined;
|
|
294
|
+
}, {}, {}>;
|
|
295
|
+
jamRecordingsCompleted: import("drizzle-orm/pg-core").PgColumn<{
|
|
296
|
+
name: "jam_recordings_completed";
|
|
297
|
+
tableName: "analytics_daily_totals";
|
|
298
|
+
dataType: "number";
|
|
299
|
+
columnType: "PgInteger";
|
|
300
|
+
data: number;
|
|
301
|
+
driverParam: string | number;
|
|
302
|
+
notNull: true;
|
|
303
|
+
hasDefault: true;
|
|
304
|
+
isPrimaryKey: false;
|
|
305
|
+
isAutoincrement: false;
|
|
306
|
+
hasRuntimeDefault: false;
|
|
307
|
+
enumValues: undefined;
|
|
308
|
+
baseColumn: never;
|
|
309
|
+
identity: undefined;
|
|
310
|
+
generated: undefined;
|
|
311
|
+
}, {}, {}>;
|
|
244
312
|
compiledAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
245
313
|
name: "compiled_at";
|
|
246
314
|
tableName: "analytics_daily_totals";
|
|
@@ -17,6 +17,16 @@ export const analyticsDailyTotals = pgTable('analytics_daily_totals', {
|
|
|
17
17
|
viewEvents: integer('view_events').notNull().default(0),
|
|
18
18
|
jamSessions: integer('jam_sessions').notNull().default(0),
|
|
19
19
|
jamParticipants: integer('jam_participants').notNull().default(0),
|
|
20
|
+
/** Sum of per-occurrence (close − start) minutes, attributed to the start day. */
|
|
21
|
+
jamMinutes: integer('jam_minutes').notNull().default(0),
|
|
22
|
+
/** Distinct profiles with a persisted join event on the day. */
|
|
23
|
+
jamUniqueAttendees: integer('jam_unique_attendees').notNull().default(0),
|
|
24
|
+
/** Max overlap of the day's per-occurrence start…close intervals. */
|
|
25
|
+
jamPeakConcurrent: integer('jam_peak_concurrent').notNull().default(0),
|
|
26
|
+
/** jam_recordings edges reaching status 'completed' on the day. */
|
|
27
|
+
jamRecordingsCompleted: integer('jam_recordings_completed')
|
|
28
|
+
.notNull()
|
|
29
|
+
.default(0),
|
|
20
30
|
compiledAt: timestamp('compiled_at', { withTimezone: true, mode: 'string' })
|
|
21
31
|
.notNull()
|
|
22
32
|
.default(sql `now()`),
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable audit trail of admin actions (user-data and moderation).
|
|
3
|
+
* Rows are append-only: no `updated_at`/`deleted_at`, and there is no
|
|
4
|
+
* retention job — the log is kept indefinitely.
|
|
5
|
+
*/
|
|
6
|
+
export declare const auditLogs: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
7
|
+
name: "audit_logs";
|
|
8
|
+
schema: undefined;
|
|
9
|
+
columns: {
|
|
10
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
11
|
+
name: "id";
|
|
12
|
+
tableName: "audit_logs";
|
|
13
|
+
dataType: "string";
|
|
14
|
+
columnType: "PgUUID";
|
|
15
|
+
data: string;
|
|
16
|
+
driverParam: string;
|
|
17
|
+
notNull: true;
|
|
18
|
+
hasDefault: false;
|
|
19
|
+
isPrimaryKey: true;
|
|
20
|
+
isAutoincrement: false;
|
|
21
|
+
hasRuntimeDefault: false;
|
|
22
|
+
enumValues: undefined;
|
|
23
|
+
baseColumn: never;
|
|
24
|
+
identity: undefined;
|
|
25
|
+
generated: undefined;
|
|
26
|
+
}, {}, {}>;
|
|
27
|
+
actorProfileId: import("drizzle-orm/pg-core").PgColumn<{
|
|
28
|
+
name: "actor_profile_id";
|
|
29
|
+
tableName: "audit_logs";
|
|
30
|
+
dataType: "string";
|
|
31
|
+
columnType: "PgText";
|
|
32
|
+
data: string;
|
|
33
|
+
driverParam: string;
|
|
34
|
+
notNull: true;
|
|
35
|
+
hasDefault: false;
|
|
36
|
+
isPrimaryKey: false;
|
|
37
|
+
isAutoincrement: false;
|
|
38
|
+
hasRuntimeDefault: false;
|
|
39
|
+
enumValues: [string, ...string[]];
|
|
40
|
+
baseColumn: never;
|
|
41
|
+
identity: undefined;
|
|
42
|
+
generated: undefined;
|
|
43
|
+
}, {}, {}>;
|
|
44
|
+
actorAccountId: import("drizzle-orm/pg-core").PgColumn<{
|
|
45
|
+
name: "actor_account_id";
|
|
46
|
+
tableName: "audit_logs";
|
|
47
|
+
dataType: "string";
|
|
48
|
+
columnType: "PgText";
|
|
49
|
+
data: string;
|
|
50
|
+
driverParam: string;
|
|
51
|
+
notNull: false;
|
|
52
|
+
hasDefault: false;
|
|
53
|
+
isPrimaryKey: false;
|
|
54
|
+
isAutoincrement: false;
|
|
55
|
+
hasRuntimeDefault: false;
|
|
56
|
+
enumValues: [string, ...string[]];
|
|
57
|
+
baseColumn: never;
|
|
58
|
+
identity: undefined;
|
|
59
|
+
generated: undefined;
|
|
60
|
+
}, {}, {}>;
|
|
61
|
+
actorIp: import("drizzle-orm/pg-core").PgColumn<{
|
|
62
|
+
name: "actor_ip";
|
|
63
|
+
tableName: "audit_logs";
|
|
64
|
+
dataType: "string";
|
|
65
|
+
columnType: "PgText";
|
|
66
|
+
data: string;
|
|
67
|
+
driverParam: string;
|
|
68
|
+
notNull: false;
|
|
69
|
+
hasDefault: false;
|
|
70
|
+
isPrimaryKey: false;
|
|
71
|
+
isAutoincrement: false;
|
|
72
|
+
hasRuntimeDefault: false;
|
|
73
|
+
enumValues: [string, ...string[]];
|
|
74
|
+
baseColumn: never;
|
|
75
|
+
identity: undefined;
|
|
76
|
+
generated: undefined;
|
|
77
|
+
}, {}, {}>;
|
|
78
|
+
action: import("drizzle-orm/pg-core").PgColumn<{
|
|
79
|
+
name: "action";
|
|
80
|
+
tableName: "audit_logs";
|
|
81
|
+
dataType: "string";
|
|
82
|
+
columnType: "PgText";
|
|
83
|
+
data: string;
|
|
84
|
+
driverParam: string;
|
|
85
|
+
notNull: true;
|
|
86
|
+
hasDefault: false;
|
|
87
|
+
isPrimaryKey: false;
|
|
88
|
+
isAutoincrement: false;
|
|
89
|
+
hasRuntimeDefault: false;
|
|
90
|
+
enumValues: [string, ...string[]];
|
|
91
|
+
baseColumn: never;
|
|
92
|
+
identity: undefined;
|
|
93
|
+
generated: undefined;
|
|
94
|
+
}, {}, {}>;
|
|
95
|
+
targetType: import("drizzle-orm/pg-core").PgColumn<{
|
|
96
|
+
name: "target_type";
|
|
97
|
+
tableName: "audit_logs";
|
|
98
|
+
dataType: "string";
|
|
99
|
+
columnType: "PgText";
|
|
100
|
+
data: string;
|
|
101
|
+
driverParam: string;
|
|
102
|
+
notNull: true;
|
|
103
|
+
hasDefault: false;
|
|
104
|
+
isPrimaryKey: false;
|
|
105
|
+
isAutoincrement: false;
|
|
106
|
+
hasRuntimeDefault: false;
|
|
107
|
+
enumValues: [string, ...string[]];
|
|
108
|
+
baseColumn: never;
|
|
109
|
+
identity: undefined;
|
|
110
|
+
generated: undefined;
|
|
111
|
+
}, {}, {}>;
|
|
112
|
+
targetId: import("drizzle-orm/pg-core").PgColumn<{
|
|
113
|
+
name: "target_id";
|
|
114
|
+
tableName: "audit_logs";
|
|
115
|
+
dataType: "string";
|
|
116
|
+
columnType: "PgText";
|
|
117
|
+
data: string;
|
|
118
|
+
driverParam: string;
|
|
119
|
+
notNull: false;
|
|
120
|
+
hasDefault: false;
|
|
121
|
+
isPrimaryKey: false;
|
|
122
|
+
isAutoincrement: false;
|
|
123
|
+
hasRuntimeDefault: false;
|
|
124
|
+
enumValues: [string, ...string[]];
|
|
125
|
+
baseColumn: never;
|
|
126
|
+
identity: undefined;
|
|
127
|
+
generated: undefined;
|
|
128
|
+
}, {}, {}>;
|
|
129
|
+
targetLabel: import("drizzle-orm/pg-core").PgColumn<{
|
|
130
|
+
name: "target_label";
|
|
131
|
+
tableName: "audit_logs";
|
|
132
|
+
dataType: "string";
|
|
133
|
+
columnType: "PgText";
|
|
134
|
+
data: string;
|
|
135
|
+
driverParam: string;
|
|
136
|
+
notNull: false;
|
|
137
|
+
hasDefault: false;
|
|
138
|
+
isPrimaryKey: false;
|
|
139
|
+
isAutoincrement: false;
|
|
140
|
+
hasRuntimeDefault: false;
|
|
141
|
+
enumValues: [string, ...string[]];
|
|
142
|
+
baseColumn: never;
|
|
143
|
+
identity: undefined;
|
|
144
|
+
generated: undefined;
|
|
145
|
+
}, {}, {}>;
|
|
146
|
+
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
147
|
+
name: "metadata";
|
|
148
|
+
tableName: "audit_logs";
|
|
149
|
+
dataType: "json";
|
|
150
|
+
columnType: "PgJsonb";
|
|
151
|
+
data: unknown;
|
|
152
|
+
driverParam: unknown;
|
|
153
|
+
notNull: false;
|
|
154
|
+
hasDefault: false;
|
|
155
|
+
isPrimaryKey: false;
|
|
156
|
+
isAutoincrement: false;
|
|
157
|
+
hasRuntimeDefault: false;
|
|
158
|
+
enumValues: undefined;
|
|
159
|
+
baseColumn: never;
|
|
160
|
+
identity: undefined;
|
|
161
|
+
generated: undefined;
|
|
162
|
+
}, {}, {}>;
|
|
163
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
164
|
+
name: "created_at";
|
|
165
|
+
tableName: "audit_logs";
|
|
166
|
+
dataType: "string";
|
|
167
|
+
columnType: "PgTimestampString";
|
|
168
|
+
data: string;
|
|
169
|
+
driverParam: string;
|
|
170
|
+
notNull: true;
|
|
171
|
+
hasDefault: true;
|
|
172
|
+
isPrimaryKey: false;
|
|
173
|
+
isAutoincrement: false;
|
|
174
|
+
hasRuntimeDefault: false;
|
|
175
|
+
enumValues: undefined;
|
|
176
|
+
baseColumn: never;
|
|
177
|
+
identity: undefined;
|
|
178
|
+
generated: undefined;
|
|
179
|
+
}, {}, {}>;
|
|
180
|
+
};
|
|
181
|
+
dialect: "pg";
|
|
182
|
+
}>;
|
|
183
|
+
export type AuditLogRow = typeof auditLogs.$inferSelect;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { index, jsonb, pgTable, text, timestamp } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { idColumn } from './base.js';
|
|
4
|
+
/**
|
|
5
|
+
* Immutable audit trail of admin actions (user-data and moderation).
|
|
6
|
+
* Rows are append-only: no `updated_at`/`deleted_at`, and there is no
|
|
7
|
+
* retention job — the log is kept indefinitely.
|
|
8
|
+
*/
|
|
9
|
+
export const auditLogs = pgTable('audit_logs', {
|
|
10
|
+
id: idColumn(),
|
|
11
|
+
actorProfileId: text('actor_profile_id').notNull(),
|
|
12
|
+
actorAccountId: text('actor_account_id'),
|
|
13
|
+
// Stores the client-supplied `X-Forwarded-For` value at write time (see
|
|
14
|
+
// `clientIp`). It is not verified against the proxy and rows are
|
|
15
|
+
// immutable, so treat `actor_ip` as untrusted provenance — a client can
|
|
16
|
+
// set it arbitrarily before the TLS proxy.
|
|
17
|
+
actorIp: text('actor_ip'),
|
|
18
|
+
action: text('action').notNull(),
|
|
19
|
+
targetType: text('target_type').notNull(),
|
|
20
|
+
targetId: text('target_id'),
|
|
21
|
+
targetLabel: text('target_label'),
|
|
22
|
+
metadata: jsonb('metadata'),
|
|
23
|
+
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' })
|
|
24
|
+
.notNull()
|
|
25
|
+
.default(sql `now()`),
|
|
26
|
+
}, (table) => [
|
|
27
|
+
index('audit_logs_created_at_idx').on(table.createdAt.desc()),
|
|
28
|
+
index('audit_logs_actor_profile_idx').on(table.actorProfileId),
|
|
29
|
+
index('audit_logs_target_idx').on(table.targetType, table.targetId),
|
|
30
|
+
]);
|
|
@@ -1799,6 +1799,23 @@ export declare const jamEvents: import("drizzle-orm/pg-core").PgTableWithColumns
|
|
|
1799
1799
|
identity: undefined;
|
|
1800
1800
|
generated: undefined;
|
|
1801
1801
|
}, {}, {}>;
|
|
1802
|
+
recurrenceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
1803
|
+
name: "recurrence_id";
|
|
1804
|
+
tableName: "jam_events";
|
|
1805
|
+
dataType: "string";
|
|
1806
|
+
columnType: "PgText";
|
|
1807
|
+
data: string;
|
|
1808
|
+
driverParam: string;
|
|
1809
|
+
notNull: false;
|
|
1810
|
+
hasDefault: false;
|
|
1811
|
+
isPrimaryKey: false;
|
|
1812
|
+
isAutoincrement: false;
|
|
1813
|
+
hasRuntimeDefault: false;
|
|
1814
|
+
enumValues: [string, ...string[]];
|
|
1815
|
+
baseColumn: never;
|
|
1816
|
+
identity: undefined;
|
|
1817
|
+
generated: undefined;
|
|
1818
|
+
}, {}, {}>;
|
|
1802
1819
|
body: import("drizzle-orm/pg-core").PgColumn<{
|
|
1803
1820
|
name: "body";
|
|
1804
1821
|
tableName: "jam_events";
|
|
@@ -137,9 +137,18 @@ export const inviteLinks = pgTable('invite_links', {
|
|
|
137
137
|
export const jamEvents = pgTable('jam_events', {
|
|
138
138
|
id: idColumn(),
|
|
139
139
|
postId: text('post_id').notNull(),
|
|
140
|
+
/**
|
|
141
|
+
* ISO occurrence id for recurring jams (denormalized from
|
|
142
|
+
* `body->>'recurrenceId'`); null for one-off events. Lets session
|
|
143
|
+
* lifecycle and attendance roll up per occurrence without body scans.
|
|
144
|
+
*/
|
|
145
|
+
recurrenceId: text('recurrence_id'),
|
|
140
146
|
body: jsonb('body').notNull().default({}),
|
|
141
147
|
...modelTimestamps,
|
|
142
|
-
}, (t) => [
|
|
148
|
+
}, (t) => [
|
|
149
|
+
index('jam_events_post_idx').on(t.postId),
|
|
150
|
+
index('jam_events_post_recurrence_idx').on(t.postId, t.recurrenceId),
|
|
151
|
+
]);
|
|
143
152
|
export const mediaAttachments = pgTable('media_attachments', {
|
|
144
153
|
id: idColumn(),
|
|
145
154
|
body: jsonb('body').notNull().default({}),
|