@openpeepshq/common 0.30.0 → 0.32.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/lib/adminSections.d.ts +4 -0
- package/dist/lib/adminSections.js +5 -0
- package/dist/types/analytics.d.ts +75 -0
- package/dist/types/analytics.js +16 -0
- package/dist/types/auditLog.d.ts +33 -0
- package/dist/types/auditLog.js +32 -0
- package/dist/types/capabilities.d.ts +2 -2
- package/dist/types/capabilities.js +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/notifications.d.ts +1 -0
- package/dist/types/roleDefaults.js +17 -0
- package/package.json +1 -1
- package/src/lib/adminSections.ts +5 -0
- package/src/types/analytics.ts +16 -0
- package/src/types/auditLog.ts +41 -0
- package/src/types/capabilities.ts +2 -0
- package/src/types/index.ts +1 -0
- package/src/types/roleDefaults.ts +26 -0
|
@@ -52,6 +52,10 @@ export declare const adminSections: readonly [{
|
|
|
52
52
|
readonly key: "database";
|
|
53
53
|
readonly path: "/admin/db";
|
|
54
54
|
readonly capabilities: readonly ["core-db-access"];
|
|
55
|
+
}, {
|
|
56
|
+
readonly key: "auditLog";
|
|
57
|
+
readonly path: "/admin/audit-log";
|
|
58
|
+
readonly capabilities: readonly ["core-auditLog-read"];
|
|
55
59
|
}];
|
|
56
60
|
export type AdminSectionKey = (typeof adminSections)[number]['key'];
|
|
57
61
|
export type AdminSection = (typeof adminSections)[number];
|
|
@@ -65,6 +65,11 @@ export const adminSections = [
|
|
|
65
65
|
path: '/admin/db',
|
|
66
66
|
capabilities: ['core-db-access'],
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
key: 'auditLog',
|
|
70
|
+
path: '/admin/audit-log',
|
|
71
|
+
capabilities: ['core-auditLog-read'],
|
|
72
|
+
},
|
|
68
73
|
];
|
|
69
74
|
export const canAccessAdminSection = (roles, section) => checkRoleCapabilities(roles ?? [], [...section.capabilities]).success;
|
|
70
75
|
export const getVisibleAdminSections = (roles) => adminSections.filter((section) => canAccessAdminSection(roles, section));
|
|
@@ -258,6 +258,66 @@ export declare const analyticsOverviewSchema: z.ZodObject<{
|
|
|
258
258
|
value: z.ZodNumber;
|
|
259
259
|
}, z.core.$strip>>>;
|
|
260
260
|
}, z.core.$strip>;
|
|
261
|
+
jamSessions: z.ZodObject<{
|
|
262
|
+
key: z.ZodString;
|
|
263
|
+
value: z.ZodNumber;
|
|
264
|
+
previousValue: z.ZodNumber;
|
|
265
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
266
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
267
|
+
day: z.ZodString;
|
|
268
|
+
value: z.ZodNumber;
|
|
269
|
+
}, z.core.$strip>>>;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
jamParticipants: z.ZodObject<{
|
|
272
|
+
key: z.ZodString;
|
|
273
|
+
value: z.ZodNumber;
|
|
274
|
+
previousValue: z.ZodNumber;
|
|
275
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
276
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
277
|
+
day: z.ZodString;
|
|
278
|
+
value: z.ZodNumber;
|
|
279
|
+
}, z.core.$strip>>>;
|
|
280
|
+
}, z.core.$strip>;
|
|
281
|
+
jamMinutes: z.ZodObject<{
|
|
282
|
+
key: z.ZodString;
|
|
283
|
+
value: z.ZodNumber;
|
|
284
|
+
previousValue: z.ZodNumber;
|
|
285
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
286
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
287
|
+
day: z.ZodString;
|
|
288
|
+
value: z.ZodNumber;
|
|
289
|
+
}, z.core.$strip>>>;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
jamUniqueAttendees: z.ZodObject<{
|
|
292
|
+
key: z.ZodString;
|
|
293
|
+
value: z.ZodNumber;
|
|
294
|
+
previousValue: z.ZodNumber;
|
|
295
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
296
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
297
|
+
day: z.ZodString;
|
|
298
|
+
value: z.ZodNumber;
|
|
299
|
+
}, z.core.$strip>>>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
jamPeakConcurrent: z.ZodObject<{
|
|
302
|
+
key: z.ZodString;
|
|
303
|
+
value: z.ZodNumber;
|
|
304
|
+
previousValue: z.ZodNumber;
|
|
305
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
306
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
307
|
+
day: z.ZodString;
|
|
308
|
+
value: z.ZodNumber;
|
|
309
|
+
}, z.core.$strip>>>;
|
|
310
|
+
}, z.core.$strip>;
|
|
311
|
+
jamRecordings: z.ZodObject<{
|
|
312
|
+
key: z.ZodString;
|
|
313
|
+
value: z.ZodNumber;
|
|
314
|
+
previousValue: z.ZodNumber;
|
|
315
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
316
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
317
|
+
day: z.ZodString;
|
|
318
|
+
value: z.ZodNumber;
|
|
319
|
+
}, z.core.$strip>>>;
|
|
320
|
+
}, z.core.$strip>;
|
|
261
321
|
}, z.core.$strip>;
|
|
262
322
|
postsOverTime: z.ZodArray<z.ZodObject<{
|
|
263
323
|
day: z.ZodString;
|
|
@@ -285,6 +345,11 @@ export declare const analyticsOverviewSchema: z.ZodObject<{
|
|
|
285
345
|
label: z.ZodString;
|
|
286
346
|
value: z.ZodNumber;
|
|
287
347
|
}, z.core.$strip>>;
|
|
348
|
+
jamsOverTime: z.ZodArray<z.ZodObject<{
|
|
349
|
+
day: z.ZodString;
|
|
350
|
+
label: z.ZodString;
|
|
351
|
+
value: z.ZodNumber;
|
|
352
|
+
}, z.core.$strip>>;
|
|
288
353
|
topMembers: z.ZodArray<z.ZodObject<{
|
|
289
354
|
profileId: z.ZodString;
|
|
290
355
|
handle: z.ZodString;
|
|
@@ -401,6 +466,16 @@ export declare const analyticsGrowthSchema: z.ZodObject<{
|
|
|
401
466
|
value: z.ZodNumber;
|
|
402
467
|
}, z.core.$strip>>>;
|
|
403
468
|
}, z.core.$strip>;
|
|
469
|
+
jamMinutes: z.ZodObject<{
|
|
470
|
+
key: z.ZodString;
|
|
471
|
+
value: z.ZodNumber;
|
|
472
|
+
previousValue: z.ZodNumber;
|
|
473
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
474
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
475
|
+
day: z.ZodString;
|
|
476
|
+
value: z.ZodNumber;
|
|
477
|
+
}, z.core.$strip>>>;
|
|
478
|
+
}, z.core.$strip>;
|
|
404
479
|
}, z.core.$strip>;
|
|
405
480
|
signupsByDay: z.ZodArray<z.ZodObject<{
|
|
406
481
|
day: z.ZodString;
|
package/dist/types/analytics.js
CHANGED
|
@@ -142,10 +142,24 @@ export const analyticsOverviewSchema = z.object({
|
|
|
142
142
|
unverifiedMembers: analyticsMetricCardSchema,
|
|
143
143
|
activeMembers: analyticsMetricCardSchema,
|
|
144
144
|
totalGroups: analyticsMetricCardSchema,
|
|
145
|
+
/** Distinct (jam, occurrence) sessions started in the range. */
|
|
146
|
+
jamSessions: analyticsMetricCardSchema,
|
|
147
|
+
/** Distinct (member, jam) pairings from attended joins in the range. */
|
|
148
|
+
jamParticipants: analyticsMetricCardSchema,
|
|
149
|
+
/** Total minutes of jam sessions that started in the range. */
|
|
150
|
+
jamMinutes: analyticsMetricCardSchema,
|
|
151
|
+
/** Distinct members who joined at least one jam in the range. */
|
|
152
|
+
jamUniqueAttendees: analyticsMetricCardSchema,
|
|
153
|
+
/** Highest number of concurrent jam sessions overlapping in the range. */
|
|
154
|
+
jamPeakConcurrent: analyticsMetricCardSchema,
|
|
155
|
+
/** Jam recordings that reached "completed" in the range. */
|
|
156
|
+
jamRecordings: analyticsMetricCardSchema,
|
|
145
157
|
}),
|
|
146
158
|
postsOverTime: analyticsStackedPointSchema.array(),
|
|
147
159
|
postTypes: analyticsPostTypeCountSchema.array(),
|
|
148
160
|
activeUsersSeries: analyticsBucketedPointSchema.array(),
|
|
161
|
+
/** Jam sessions over time, bucketed like activeUsersSeries. */
|
|
162
|
+
jamsOverTime: analyticsBucketedPointSchema.array(),
|
|
149
163
|
topMembers: analyticsMemberRowSchema.array(),
|
|
150
164
|
topPosts: analyticsPostRowSchema.array(),
|
|
151
165
|
/** @deprecated kept for report/CSV compatibility */
|
|
@@ -163,6 +177,8 @@ export const analyticsGrowthSchema = z.object({
|
|
|
163
177
|
dau: analyticsMetricCardSchema,
|
|
164
178
|
mau: analyticsMetricCardSchema,
|
|
165
179
|
dauMau: analyticsMetricCardSchema,
|
|
180
|
+
/** Total minutes of jam sessions that started in the range. */
|
|
181
|
+
jamMinutes: analyticsMetricCardSchema,
|
|
166
182
|
}),
|
|
167
183
|
/** New-member counts for every day in the selected range. */
|
|
168
184
|
signupsByDay: analyticsDayHeatmapCellSchema.array(),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const auditLogEntrySchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
actorProfileId: z.ZodString;
|
|
5
|
+
actorAccountId: z.ZodNullable<z.ZodString>;
|
|
6
|
+
actorIp: z.ZodNullable<z.ZodString>;
|
|
7
|
+
action: z.ZodString;
|
|
8
|
+
targetType: z.ZodString;
|
|
9
|
+
targetId: z.ZodNullable<z.ZodString>;
|
|
10
|
+
targetLabel: z.ZodNullable<z.ZodString>;
|
|
11
|
+
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
12
|
+
createdAt: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type AuditLogEntry = z.infer<typeof auditLogEntrySchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Keyset cursor: the `created_at`/`id` of the last row of the previous page.
|
|
17
|
+
* Both parts are required together so a row that ties on `created_at` with the
|
|
18
|
+
* boundary row is not skipped when paging ("older" = strictly below the pair).
|
|
19
|
+
*/
|
|
20
|
+
export declare const auditLogCursorSchema: z.ZodObject<{
|
|
21
|
+
before: z.ZodString;
|
|
22
|
+
beforeId: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type AuditLogCursor = z.infer<typeof auditLogCursorSchema>;
|
|
25
|
+
export declare const auditLogListQuerySchema: z.ZodObject<{
|
|
26
|
+
before: z.ZodOptional<z.ZodString>;
|
|
27
|
+
beforeId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
29
|
+
actor: z.ZodOptional<z.ZodString>;
|
|
30
|
+
targetType: z.ZodOptional<z.ZodString>;
|
|
31
|
+
targetId: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type AuditLogListQuery = z.infer<typeof auditLogListQuerySchema>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const auditLogEntrySchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
actorProfileId: z.string(),
|
|
5
|
+
actorAccountId: z.string().nullable(),
|
|
6
|
+
actorIp: z.string().nullable(),
|
|
7
|
+
action: z.string(),
|
|
8
|
+
targetType: z.string(),
|
|
9
|
+
targetId: z.string().nullable(),
|
|
10
|
+
targetLabel: z.string().nullable(),
|
|
11
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
12
|
+
createdAt: z.string().datetime(),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Keyset cursor: the `created_at`/`id` of the last row of the previous page.
|
|
16
|
+
* Both parts are required together so a row that ties on `created_at` with the
|
|
17
|
+
* boundary row is not skipped when paging ("older" = strictly below the pair).
|
|
18
|
+
*/
|
|
19
|
+
export const auditLogCursorSchema = z.object({
|
|
20
|
+
before: z.string().datetime(),
|
|
21
|
+
beforeId: z.string().uuid(),
|
|
22
|
+
});
|
|
23
|
+
export const auditLogListQuerySchema = z.object({
|
|
24
|
+
/** Only entries older than this `created_at`. Pair with `beforeId`. */
|
|
25
|
+
before: z.string().datetime().optional(),
|
|
26
|
+
/** The `id` paired with `before`; rows with the same `created_at` but a lower `id` are the ones returned. */
|
|
27
|
+
beforeId: z.string().uuid().optional(),
|
|
28
|
+
limit: z.coerce.number().int().min(1).max(1000).optional(),
|
|
29
|
+
actor: z.string().optional(),
|
|
30
|
+
targetType: z.string().optional(),
|
|
31
|
+
targetId: z.string().optional(),
|
|
32
|
+
});
|
|
@@ -27,14 +27,14 @@ export type GroupCapability = (typeof groupCapabilities)[number];
|
|
|
27
27
|
export type ProfileCapability = (typeof profileCapabilities)[number];
|
|
28
28
|
export type ReportCapability = (typeof reportCapabilities)[number];
|
|
29
29
|
export type AccessTokenCapability = (typeof accessTokenCapabilities)[number];
|
|
30
|
-
export declare const roleCapabilities: readonly ["core-local", "core-accounts-read", "core-accounts-create", "core-accounts-update", "core-accounts-delete", "core-reports-create", "core-reports-update", "core-groups-create", "core-groups-read", "core-groups-delete", "core-groups-addMember", "core-groups-removeMember", "core-groups-changeMemberRole", "core-posts-create-note-local", "core-posts-create-note-public", "core-posts-create-note-direct", "core-posts-create-note-private", "core-posts-create-event-local", "core-posts-create-event-public", "core-posts-create-event-direct", "core-posts-create-event-private", "core-posts-create-poll-local", "core-posts-create-poll-public", "core-posts-create-poll-direct", "core-posts-create-poll-private", "core-posts-create-article-local", "core-posts-create-article-public", "core-posts-create-article-direct", "core-posts-create-article-private", "core-posts-create-resource-local", "core-posts-create-resource-public", "core-posts-create-resource-direct", "core-posts-create-resource-private", "core-posts-read-local", "core-posts-announce", "core-posts-delete", "core-profiles-read", "core-profiles-roles-update", "core-profiles-delete", "core-profiles-suspend", "core-profiles-update", "core-profiles-impersonate", "core-analytics-read", "core-config-update", "core-config-read", "core-federation-manage", "core-customization-read", "core-customization-update", "core-capabilities-read", "core-capabilities-update", "core-backups-create", "core-backups-read", "core-backups-download", "core-backups-restore", "core-db-access", "core-i18n-update", "core-logs-read", "core-roles-read", "core-roles-update", "core-maintenance-restart", "core-media-read", "core-media-delete", "core-inviteLinks-create", "core-inviteLinks-read", "core-inviteLinks-update", "core-inviteLinks-delete", "core-serviceTokens-create", "core-serviceTokens-read", "core-serviceTokens-update", "core-serviceTokens-delete", "core-plugins-manage"];
|
|
30
|
+
export declare const roleCapabilities: readonly ["core-local", "core-accounts-read", "core-accounts-create", "core-accounts-update", "core-accounts-delete", "core-reports-create", "core-reports-update", "core-groups-create", "core-groups-read", "core-groups-delete", "core-groups-addMember", "core-groups-removeMember", "core-groups-changeMemberRole", "core-posts-create-note-local", "core-posts-create-note-public", "core-posts-create-note-direct", "core-posts-create-note-private", "core-posts-create-event-local", "core-posts-create-event-public", "core-posts-create-event-direct", "core-posts-create-event-private", "core-posts-create-poll-local", "core-posts-create-poll-public", "core-posts-create-poll-direct", "core-posts-create-poll-private", "core-posts-create-article-local", "core-posts-create-article-public", "core-posts-create-article-direct", "core-posts-create-article-private", "core-posts-create-resource-local", "core-posts-create-resource-public", "core-posts-create-resource-direct", "core-posts-create-resource-private", "core-posts-read-local", "core-posts-announce", "core-posts-delete", "core-profiles-read", "core-profiles-roles-update", "core-profiles-delete", "core-profiles-suspend", "core-profiles-update", "core-profiles-impersonate", "core-analytics-read", "core-config-update", "core-config-read", "core-federation-manage", "core-customization-read", "core-customization-update", "core-capabilities-read", "core-capabilities-update", "core-backups-create", "core-backups-read", "core-backups-download", "core-backups-restore", "core-db-access", "core-i18n-update", "core-logs-read", "core-auditLog-read", "core-roles-read", "core-roles-update", "core-maintenance-restart", "core-media-read", "core-media-delete", "core-inviteLinks-create", "core-inviteLinks-read", "core-inviteLinks-update", "core-inviteLinks-delete", "core-serviceTokens-create", "core-serviceTokens-read", "core-serviceTokens-update", "core-serviceTokens-delete", "core-plugins-manage"];
|
|
31
31
|
export type RoleCapability = (typeof roleCapabilities)[number];
|
|
32
32
|
/**
|
|
33
33
|
* Capability keys an instance admin can toggle for each role (leaves) plus the
|
|
34
34
|
* wildcard allow-all keys an editor exposes. `*` covers capabilities that do not
|
|
35
35
|
* fall under a `core-<domain>-*` category (e.g. `core-local`).
|
|
36
36
|
*/
|
|
37
|
-
export declare const roleCapabilityEditorKeys: readonly ["core-local", "core-accounts-read", "core-accounts-create", "core-accounts-update", "core-accounts-delete", "core-reports-create", "core-reports-update", "core-groups-create", "core-groups-read", "core-groups-delete", "core-groups-addMember", "core-groups-removeMember", "core-groups-changeMemberRole", "core-posts-create-note-local", "core-posts-create-note-public", "core-posts-create-note-direct", "core-posts-create-note-private", "core-posts-create-event-local", "core-posts-create-event-public", "core-posts-create-event-direct", "core-posts-create-event-private", "core-posts-create-poll-local", "core-posts-create-poll-public", "core-posts-create-poll-direct", "core-posts-create-poll-private", "core-posts-create-article-local", "core-posts-create-article-public", "core-posts-create-article-direct", "core-posts-create-article-private", "core-posts-create-resource-local", "core-posts-create-resource-public", "core-posts-create-resource-direct", "core-posts-create-resource-private", "core-posts-read-local", "core-posts-announce", "core-posts-delete", "core-profiles-read", "core-profiles-roles-update", "core-profiles-delete", "core-profiles-suspend", "core-profiles-update", "core-profiles-impersonate", "core-analytics-read", "core-config-update", "core-config-read", "core-federation-manage", "core-customization-read", "core-customization-update", "core-capabilities-read", "core-capabilities-update", "core-backups-create", "core-backups-read", "core-backups-download", "core-backups-restore", "core-db-access", "core-i18n-update", "core-logs-read", "core-roles-read", "core-roles-update", "core-maintenance-restart", "core-media-read", "core-media-delete", "core-inviteLinks-create", "core-inviteLinks-read", "core-inviteLinks-update", "core-inviteLinks-delete", "core-serviceTokens-create", "core-serviceTokens-read", "core-serviceTokens-update", "core-serviceTokens-delete", "core-plugins-manage", "*", "core-accounts-*", "core-analytics-*", "core-backups-*", "core-capabilities-*", "core-config-*", "core-customization-*", "core-db-*", "core-federation-*", "core-groups-*", "core-i18n-*", "core-inviteLinks-*", "core-logs-*", "core-maintenance-*", "core-media-*", "core-plugins-*", "core-profiles-*", "core-posts-create-*", "core-posts-*", "core-reports-*", "core-roles-*", "core-serviceTokens-*"];
|
|
37
|
+
export declare const roleCapabilityEditorKeys: readonly ["core-local", "core-accounts-read", "core-accounts-create", "core-accounts-update", "core-accounts-delete", "core-reports-create", "core-reports-update", "core-groups-create", "core-groups-read", "core-groups-delete", "core-groups-addMember", "core-groups-removeMember", "core-groups-changeMemberRole", "core-posts-create-note-local", "core-posts-create-note-public", "core-posts-create-note-direct", "core-posts-create-note-private", "core-posts-create-event-local", "core-posts-create-event-public", "core-posts-create-event-direct", "core-posts-create-event-private", "core-posts-create-poll-local", "core-posts-create-poll-public", "core-posts-create-poll-direct", "core-posts-create-poll-private", "core-posts-create-article-local", "core-posts-create-article-public", "core-posts-create-article-direct", "core-posts-create-article-private", "core-posts-create-resource-local", "core-posts-create-resource-public", "core-posts-create-resource-direct", "core-posts-create-resource-private", "core-posts-read-local", "core-posts-announce", "core-posts-delete", "core-profiles-read", "core-profiles-roles-update", "core-profiles-delete", "core-profiles-suspend", "core-profiles-update", "core-profiles-impersonate", "core-analytics-read", "core-config-update", "core-config-read", "core-federation-manage", "core-customization-read", "core-customization-update", "core-capabilities-read", "core-capabilities-update", "core-backups-create", "core-backups-read", "core-backups-download", "core-backups-restore", "core-db-access", "core-i18n-update", "core-logs-read", "core-auditLog-read", "core-roles-read", "core-roles-update", "core-maintenance-restart", "core-media-read", "core-media-delete", "core-inviteLinks-create", "core-inviteLinks-read", "core-inviteLinks-update", "core-inviteLinks-delete", "core-serviceTokens-create", "core-serviceTokens-read", "core-serviceTokens-update", "core-serviceTokens-delete", "core-plugins-manage", "*", "core-accounts-*", "core-analytics-*", "core-auditLog-*", "core-backups-*", "core-capabilities-*", "core-config-*", "core-customization-*", "core-db-*", "core-federation-*", "core-groups-*", "core-i18n-*", "core-inviteLinks-*", "core-logs-*", "core-maintenance-*", "core-media-*", "core-plugins-*", "core-profiles-*", "core-posts-create-*", "core-posts-*", "core-reports-*", "core-roles-*", "core-serviceTokens-*"];
|
|
38
38
|
/** Capability keys an admin can toggle per relationship for posts. */
|
|
39
39
|
export declare const postCapabilityEditorKeys: readonly ["core-posts-read", "core-posts-update", "core-posts-delete", "core-posts-vote", "core-posts-react", "core-posts-rsvp", "core-posts-reply", "core-posts-jam-moderate", "core-posts-jam-speak", "core-posts-jam-read", "core-posts-*"];
|
|
40
40
|
/** Capability keys an admin can toggle per relationship for profiles. */
|
|
@@ -179,6 +179,7 @@ export const roleCapabilities = [
|
|
|
179
179
|
'core-db-access',
|
|
180
180
|
'core-i18n-update',
|
|
181
181
|
'core-logs-read',
|
|
182
|
+
'core-auditLog-read',
|
|
182
183
|
'core-roles-read',
|
|
183
184
|
'core-roles-update',
|
|
184
185
|
'core-maintenance-restart',
|
|
@@ -204,6 +205,7 @@ export const roleCapabilityEditorKeys = [
|
|
|
204
205
|
'*',
|
|
205
206
|
'core-accounts-*',
|
|
206
207
|
'core-analytics-*',
|
|
208
|
+
'core-auditLog-*',
|
|
207
209
|
'core-backups-*',
|
|
208
210
|
'core-capabilities-*',
|
|
209
211
|
'core-config-*',
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -162,6 +162,7 @@ export declare const notificationTypeSchema: z.ZodObject<{
|
|
|
162
162
|
"core-db-access": "core-db-access";
|
|
163
163
|
"core-i18n-update": "core-i18n-update";
|
|
164
164
|
"core-logs-read": "core-logs-read";
|
|
165
|
+
"core-auditLog-read": "core-auditLog-read";
|
|
165
166
|
"core-roles-read": "core-roles-read";
|
|
166
167
|
"core-roles-update": "core-roles-update";
|
|
167
168
|
"core-maintenance-restart": "core-maintenance-restart";
|
|
@@ -113,6 +113,15 @@ const adminCanManageFederation = (roles) => roles.map((role) => role.key === 'ad
|
|
|
113
113
|
},
|
|
114
114
|
}
|
|
115
115
|
: role);
|
|
116
|
+
const adminCanReadAuditLog = (roles) => roles.map((role) => role.key === 'admin'
|
|
117
|
+
? {
|
|
118
|
+
...role,
|
|
119
|
+
capabilities: {
|
|
120
|
+
add: [...(role.capabilities?.add ?? []), 'core-auditLog-read'],
|
|
121
|
+
remove: [...(role.capabilities?.remove ?? [])],
|
|
122
|
+
},
|
|
123
|
+
}
|
|
124
|
+
: role);
|
|
116
125
|
export const roleDefaultsHistory = [
|
|
117
126
|
{
|
|
118
127
|
version: '2026-10-06',
|
|
@@ -126,6 +135,14 @@ export const roleDefaultsHistory = [
|
|
|
126
135
|
version: '2026-11-26',
|
|
127
136
|
roles: versionedRoles('2026-11-26', adminCanManageFederation(adminCanManageMedia(builtinRoles))),
|
|
128
137
|
},
|
|
138
|
+
{
|
|
139
|
+
// Appended (never edited in place): a stored role anchored at
|
|
140
|
+
// '2026-11-26' rebases against this entry's baseline, which is
|
|
141
|
+
// what makes `rebaseRoleToCurrentDefaults` grant `core-auditLog-read`
|
|
142
|
+
// to customized admin roles.
|
|
143
|
+
version: '2026-11-27',
|
|
144
|
+
roles: versionedRoles('2026-11-27', adminCanReadAuditLog(adminCanManageFederation(adminCanManageMedia(builtinRoles)))),
|
|
145
|
+
},
|
|
129
146
|
];
|
|
130
147
|
/** The current (last) version — the one in use. */
|
|
131
148
|
export const currentRoleDefaults = roleDefaultsHistory[roleDefaultsHistory.length - 1];
|
package/package.json
CHANGED
package/src/lib/adminSections.ts
CHANGED
|
@@ -67,6 +67,11 @@ export const adminSections = [
|
|
|
67
67
|
path: '/admin/db',
|
|
68
68
|
capabilities: ['core-db-access'],
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
key: 'auditLog',
|
|
72
|
+
path: '/admin/audit-log',
|
|
73
|
+
capabilities: ['core-auditLog-read'],
|
|
74
|
+
},
|
|
70
75
|
] as const;
|
|
71
76
|
|
|
72
77
|
export type AdminSectionKey = (typeof adminSections)[number]['key'];
|
package/src/types/analytics.ts
CHANGED
|
@@ -189,10 +189,24 @@ export const analyticsOverviewSchema = z.object({
|
|
|
189
189
|
unverifiedMembers: analyticsMetricCardSchema,
|
|
190
190
|
activeMembers: analyticsMetricCardSchema,
|
|
191
191
|
totalGroups: analyticsMetricCardSchema,
|
|
192
|
+
/** Distinct (jam, occurrence) sessions started in the range. */
|
|
193
|
+
jamSessions: analyticsMetricCardSchema,
|
|
194
|
+
/** Distinct (member, jam) pairings from attended joins in the range. */
|
|
195
|
+
jamParticipants: analyticsMetricCardSchema,
|
|
196
|
+
/** Total minutes of jam sessions that started in the range. */
|
|
197
|
+
jamMinutes: analyticsMetricCardSchema,
|
|
198
|
+
/** Distinct members who joined at least one jam in the range. */
|
|
199
|
+
jamUniqueAttendees: analyticsMetricCardSchema,
|
|
200
|
+
/** Highest number of concurrent jam sessions overlapping in the range. */
|
|
201
|
+
jamPeakConcurrent: analyticsMetricCardSchema,
|
|
202
|
+
/** Jam recordings that reached "completed" in the range. */
|
|
203
|
+
jamRecordings: analyticsMetricCardSchema,
|
|
192
204
|
}),
|
|
193
205
|
postsOverTime: analyticsStackedPointSchema.array(),
|
|
194
206
|
postTypes: analyticsPostTypeCountSchema.array(),
|
|
195
207
|
activeUsersSeries: analyticsBucketedPointSchema.array(),
|
|
208
|
+
/** Jam sessions over time, bucketed like activeUsersSeries. */
|
|
209
|
+
jamsOverTime: analyticsBucketedPointSchema.array(),
|
|
196
210
|
topMembers: analyticsMemberRowSchema.array(),
|
|
197
211
|
topPosts: analyticsPostRowSchema.array(),
|
|
198
212
|
/** @deprecated kept for report/CSV compatibility */
|
|
@@ -212,6 +226,8 @@ export const analyticsGrowthSchema = z.object({
|
|
|
212
226
|
dau: analyticsMetricCardSchema,
|
|
213
227
|
mau: analyticsMetricCardSchema,
|
|
214
228
|
dauMau: analyticsMetricCardSchema,
|
|
229
|
+
/** Total minutes of jam sessions that started in the range. */
|
|
230
|
+
jamMinutes: analyticsMetricCardSchema,
|
|
215
231
|
}),
|
|
216
232
|
/** New-member counts for every day in the selected range. */
|
|
217
233
|
signupsByDay: analyticsDayHeatmapCellSchema.array(),
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const auditLogEntrySchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
actorProfileId: z.string(),
|
|
6
|
+
actorAccountId: z.string().nullable(),
|
|
7
|
+
actorIp: z.string().nullable(),
|
|
8
|
+
action: z.string(),
|
|
9
|
+
targetType: z.string(),
|
|
10
|
+
targetId: z.string().nullable(),
|
|
11
|
+
targetLabel: z.string().nullable(),
|
|
12
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
13
|
+
createdAt: z.string().datetime(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export type AuditLogEntry = z.infer<typeof auditLogEntrySchema>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Keyset cursor: the `created_at`/`id` of the last row of the previous page.
|
|
20
|
+
* Both parts are required together so a row that ties on `created_at` with the
|
|
21
|
+
* boundary row is not skipped when paging ("older" = strictly below the pair).
|
|
22
|
+
*/
|
|
23
|
+
export const auditLogCursorSchema = z.object({
|
|
24
|
+
before: z.string().datetime(),
|
|
25
|
+
beforeId: z.string().uuid(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type AuditLogCursor = z.infer<typeof auditLogCursorSchema>;
|
|
29
|
+
|
|
30
|
+
export const auditLogListQuerySchema = z.object({
|
|
31
|
+
/** Only entries older than this `created_at`. Pair with `beforeId`. */
|
|
32
|
+
before: z.string().datetime().optional(),
|
|
33
|
+
/** The `id` paired with `before`; rows with the same `created_at` but a lower `id` are the ones returned. */
|
|
34
|
+
beforeId: z.string().uuid().optional(),
|
|
35
|
+
limit: z.coerce.number().int().min(1).max(1000).optional(),
|
|
36
|
+
actor: z.string().optional(),
|
|
37
|
+
targetType: z.string().optional(),
|
|
38
|
+
targetId: z.string().optional(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export type AuditLogListQuery = z.infer<typeof auditLogListQuerySchema>;
|
|
@@ -214,6 +214,7 @@ export const roleCapabilities = [
|
|
|
214
214
|
'core-db-access',
|
|
215
215
|
'core-i18n-update',
|
|
216
216
|
'core-logs-read',
|
|
217
|
+
'core-auditLog-read',
|
|
217
218
|
'core-roles-read',
|
|
218
219
|
'core-roles-update',
|
|
219
220
|
'core-maintenance-restart',
|
|
@@ -242,6 +243,7 @@ export const roleCapabilityEditorKeys = [
|
|
|
242
243
|
'*',
|
|
243
244
|
'core-accounts-*',
|
|
244
245
|
'core-analytics-*',
|
|
246
|
+
'core-auditLog-*',
|
|
245
247
|
'core-backups-*',
|
|
246
248
|
'core-capabilities-*',
|
|
247
249
|
'core-config-*',
|
package/src/types/index.ts
CHANGED
|
@@ -139,6 +139,19 @@ const adminCanManageFederation = (roles: RoleData[]): RoleData[] =>
|
|
|
139
139
|
: role,
|
|
140
140
|
);
|
|
141
141
|
|
|
142
|
+
const adminCanReadAuditLog = (roles: RoleData[]): RoleData[] =>
|
|
143
|
+
roles.map((role) =>
|
|
144
|
+
role.key === 'admin'
|
|
145
|
+
? {
|
|
146
|
+
...role,
|
|
147
|
+
capabilities: {
|
|
148
|
+
add: [...(role.capabilities?.add ?? []), 'core-auditLog-read'],
|
|
149
|
+
remove: [...(role.capabilities?.remove ?? [])],
|
|
150
|
+
},
|
|
151
|
+
}
|
|
152
|
+
: role,
|
|
153
|
+
);
|
|
154
|
+
|
|
142
155
|
export const roleDefaultsHistory: RoleDefaultsVersion[] = [
|
|
143
156
|
{
|
|
144
157
|
version: '2026-10-06',
|
|
@@ -155,6 +168,19 @@ export const roleDefaultsHistory: RoleDefaultsVersion[] = [
|
|
|
155
168
|
adminCanManageFederation(adminCanManageMedia(builtinRoles)),
|
|
156
169
|
),
|
|
157
170
|
},
|
|
171
|
+
{
|
|
172
|
+
// Appended (never edited in place): a stored role anchored at
|
|
173
|
+
// '2026-11-26' rebases against this entry's baseline, which is
|
|
174
|
+
// what makes `rebaseRoleToCurrentDefaults` grant `core-auditLog-read`
|
|
175
|
+
// to customized admin roles.
|
|
176
|
+
version: '2026-11-27',
|
|
177
|
+
roles: versionedRoles(
|
|
178
|
+
'2026-11-27',
|
|
179
|
+
adminCanReadAuditLog(
|
|
180
|
+
adminCanManageFederation(adminCanManageMedia(builtinRoles)),
|
|
181
|
+
),
|
|
182
|
+
),
|
|
183
|
+
},
|
|
158
184
|
];
|
|
159
185
|
|
|
160
186
|
/** The current (last) version — the one in use. */
|