@archiva/archiva-nextjs 0.2.6 → 0.2.7
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-BJ8aJsbs.d.mts +139 -0
- package/dist/index-BJ8aJsbs.d.ts +139 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react/client.js +30 -27
- package/dist/react/client.mjs +30 -27
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
|
|
3
|
+
type EventChange = {
|
|
4
|
+
op: "set" | "unset" | "add" | "remove" | "replace" | string;
|
|
5
|
+
path: string;
|
|
6
|
+
before?: unknown;
|
|
7
|
+
after?: unknown;
|
|
8
|
+
};
|
|
9
|
+
type CreateEventInput = {
|
|
10
|
+
action: string;
|
|
11
|
+
entityType: string;
|
|
12
|
+
entityId: string;
|
|
13
|
+
actorType?: string;
|
|
14
|
+
actorId?: string;
|
|
15
|
+
actorDisplay?: string;
|
|
16
|
+
occurredAt?: string;
|
|
17
|
+
source?: string;
|
|
18
|
+
context?: Record<string, unknown>;
|
|
19
|
+
changes?: EventChange[];
|
|
20
|
+
};
|
|
21
|
+
type CreateEventOptions = {
|
|
22
|
+
idempotencyKey?: string;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
};
|
|
25
|
+
type AuditEventListItem = {
|
|
26
|
+
id: string;
|
|
27
|
+
receivedAt: string;
|
|
28
|
+
action: string;
|
|
29
|
+
entityType: string;
|
|
30
|
+
entityId: string;
|
|
31
|
+
actorId: string | null;
|
|
32
|
+
actorType?: 'user' | 'service' | 'system';
|
|
33
|
+
actorDisplay?: string | null;
|
|
34
|
+
source: string | null;
|
|
35
|
+
};
|
|
36
|
+
type PageResult<T> = {
|
|
37
|
+
items: T[];
|
|
38
|
+
nextCursor?: string;
|
|
39
|
+
};
|
|
40
|
+
type LoadEventsParams = {
|
|
41
|
+
entityId?: string;
|
|
42
|
+
actorId?: string;
|
|
43
|
+
entityType?: string;
|
|
44
|
+
actorType?: 'user' | 'service' | 'system';
|
|
45
|
+
limit?: number;
|
|
46
|
+
cursor?: string;
|
|
47
|
+
};
|
|
48
|
+
declare class ArchivaError extends Error {
|
|
49
|
+
statusCode: number;
|
|
50
|
+
code: "UNAUTHORIZED" | "FORBIDDEN" | "PAYLOAD_TOO_LARGE" | "RATE_LIMITED" | "IDEMPOTENCY_CONFLICT" | "HTTP_ERROR";
|
|
51
|
+
retryAfterSeconds?: number;
|
|
52
|
+
details?: unknown;
|
|
53
|
+
constructor(params: {
|
|
54
|
+
statusCode: number;
|
|
55
|
+
code: "UNAUTHORIZED" | "FORBIDDEN" | "PAYLOAD_TOO_LARGE" | "RATE_LIMITED" | "IDEMPOTENCY_CONFLICT" | "HTTP_ERROR";
|
|
56
|
+
message: string;
|
|
57
|
+
retryAfterSeconds?: number;
|
|
58
|
+
details?: unknown;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Server action to load audit events
|
|
64
|
+
*
|
|
65
|
+
* @param params - Query parameters for filtering events
|
|
66
|
+
* @param apiKey - Optional API key (otherwise uses ARCHIVA_SECRET_KEY env var)
|
|
67
|
+
* @returns Paginated list of audit events
|
|
68
|
+
*/
|
|
69
|
+
declare function loadEvents(params: LoadEventsParams, apiKey?: string): Promise<PageResult<AuditEventListItem>>;
|
|
70
|
+
/**
|
|
71
|
+
* Server action to create a single audit event
|
|
72
|
+
*
|
|
73
|
+
* @param event - Event data to create
|
|
74
|
+
* @param options - Optional idempotency and request ID options
|
|
75
|
+
* @param apiKey - Optional API key (otherwise uses ARCHIVA_SECRET_KEY env var)
|
|
76
|
+
* @returns Created event ID and replay status
|
|
77
|
+
*/
|
|
78
|
+
declare function createEvent(event: CreateEventInput, options?: CreateEventOptions, apiKey?: string): Promise<{
|
|
79
|
+
eventId: string;
|
|
80
|
+
replayed: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Server action to create multiple audit events (bulk)
|
|
84
|
+
*
|
|
85
|
+
* @param events - Array of events to create
|
|
86
|
+
* @param options - Optional idempotency and request ID options
|
|
87
|
+
* @param apiKey - Optional API key (otherwise uses ARCHIVA_SECRET_KEY env var)
|
|
88
|
+
* @returns Array of created event IDs
|
|
89
|
+
*/
|
|
90
|
+
declare function createEvents(events: CreateEventInput[], options?: CreateEventOptions, apiKey?: string): Promise<{
|
|
91
|
+
eventIds: string[];
|
|
92
|
+
}>;
|
|
93
|
+
|
|
94
|
+
interface FrontendTokenResponse {
|
|
95
|
+
token: string;
|
|
96
|
+
expiresAt: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fetches a frontend token from the Archiva API
|
|
100
|
+
*
|
|
101
|
+
* @param projectId - Optional project ID for scoping
|
|
102
|
+
* @param apiBaseUrl - Archiva API base URL (defaults to https://api.archiva.app)
|
|
103
|
+
* @returns Frontend token response
|
|
104
|
+
*/
|
|
105
|
+
declare function createFrontendTokenGET(projectId?: string, apiBaseUrl?: string): Promise<FrontendTokenResponse>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Next.js route handler for GET /api/archiva/frontend-token
|
|
109
|
+
*
|
|
110
|
+
* This handler can be used in the host app's route file:
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* // app/api/archiva/frontend-token/route.ts
|
|
114
|
+
* export { GET } from '@archiva/archiva-nextjs/server';
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* Or with custom configuration:
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { createFrontendTokenRoute } from '@archiva/archiva-nextjs/server';
|
|
121
|
+
*
|
|
122
|
+
* export const GET = createFrontendTokenRoute({
|
|
123
|
+
* apiBaseUrl: process.env.ARCHIVA_API_URL,
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare function createFrontendTokenRoute(options?: {
|
|
128
|
+
apiBaseUrl?: string;
|
|
129
|
+
}): (request: NextRequest) => Promise<NextResponse<FrontendTokenResponse> | NextResponse<{
|
|
130
|
+
error: string;
|
|
131
|
+
}>>;
|
|
132
|
+
/**
|
|
133
|
+
* Default GET handler (for direct export)
|
|
134
|
+
*/
|
|
135
|
+
declare function GET(request: NextRequest): Promise<NextResponse<FrontendTokenResponse> | NextResponse<{
|
|
136
|
+
error: string;
|
|
137
|
+
}>>;
|
|
138
|
+
|
|
139
|
+
export { ArchivaError as A, type CreateEventInput as C, type EventChange as E, type FrontendTokenResponse as F, GET as G, type LoadEventsParams as L, type PageResult as P, createEvents as a, createFrontendTokenGET as b, createEvent as c, createFrontendTokenRoute as d, type CreateEventOptions as e, type AuditEventListItem as f, loadEvents as l };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
|
|
3
|
+
type EventChange = {
|
|
4
|
+
op: "set" | "unset" | "add" | "remove" | "replace" | string;
|
|
5
|
+
path: string;
|
|
6
|
+
before?: unknown;
|
|
7
|
+
after?: unknown;
|
|
8
|
+
};
|
|
9
|
+
type CreateEventInput = {
|
|
10
|
+
action: string;
|
|
11
|
+
entityType: string;
|
|
12
|
+
entityId: string;
|
|
13
|
+
actorType?: string;
|
|
14
|
+
actorId?: string;
|
|
15
|
+
actorDisplay?: string;
|
|
16
|
+
occurredAt?: string;
|
|
17
|
+
source?: string;
|
|
18
|
+
context?: Record<string, unknown>;
|
|
19
|
+
changes?: EventChange[];
|
|
20
|
+
};
|
|
21
|
+
type CreateEventOptions = {
|
|
22
|
+
idempotencyKey?: string;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
};
|
|
25
|
+
type AuditEventListItem = {
|
|
26
|
+
id: string;
|
|
27
|
+
receivedAt: string;
|
|
28
|
+
action: string;
|
|
29
|
+
entityType: string;
|
|
30
|
+
entityId: string;
|
|
31
|
+
actorId: string | null;
|
|
32
|
+
actorType?: 'user' | 'service' | 'system';
|
|
33
|
+
actorDisplay?: string | null;
|
|
34
|
+
source: string | null;
|
|
35
|
+
};
|
|
36
|
+
type PageResult<T> = {
|
|
37
|
+
items: T[];
|
|
38
|
+
nextCursor?: string;
|
|
39
|
+
};
|
|
40
|
+
type LoadEventsParams = {
|
|
41
|
+
entityId?: string;
|
|
42
|
+
actorId?: string;
|
|
43
|
+
entityType?: string;
|
|
44
|
+
actorType?: 'user' | 'service' | 'system';
|
|
45
|
+
limit?: number;
|
|
46
|
+
cursor?: string;
|
|
47
|
+
};
|
|
48
|
+
declare class ArchivaError extends Error {
|
|
49
|
+
statusCode: number;
|
|
50
|
+
code: "UNAUTHORIZED" | "FORBIDDEN" | "PAYLOAD_TOO_LARGE" | "RATE_LIMITED" | "IDEMPOTENCY_CONFLICT" | "HTTP_ERROR";
|
|
51
|
+
retryAfterSeconds?: number;
|
|
52
|
+
details?: unknown;
|
|
53
|
+
constructor(params: {
|
|
54
|
+
statusCode: number;
|
|
55
|
+
code: "UNAUTHORIZED" | "FORBIDDEN" | "PAYLOAD_TOO_LARGE" | "RATE_LIMITED" | "IDEMPOTENCY_CONFLICT" | "HTTP_ERROR";
|
|
56
|
+
message: string;
|
|
57
|
+
retryAfterSeconds?: number;
|
|
58
|
+
details?: unknown;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Server action to load audit events
|
|
64
|
+
*
|
|
65
|
+
* @param params - Query parameters for filtering events
|
|
66
|
+
* @param apiKey - Optional API key (otherwise uses ARCHIVA_SECRET_KEY env var)
|
|
67
|
+
* @returns Paginated list of audit events
|
|
68
|
+
*/
|
|
69
|
+
declare function loadEvents(params: LoadEventsParams, apiKey?: string): Promise<PageResult<AuditEventListItem>>;
|
|
70
|
+
/**
|
|
71
|
+
* Server action to create a single audit event
|
|
72
|
+
*
|
|
73
|
+
* @param event - Event data to create
|
|
74
|
+
* @param options - Optional idempotency and request ID options
|
|
75
|
+
* @param apiKey - Optional API key (otherwise uses ARCHIVA_SECRET_KEY env var)
|
|
76
|
+
* @returns Created event ID and replay status
|
|
77
|
+
*/
|
|
78
|
+
declare function createEvent(event: CreateEventInput, options?: CreateEventOptions, apiKey?: string): Promise<{
|
|
79
|
+
eventId: string;
|
|
80
|
+
replayed: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Server action to create multiple audit events (bulk)
|
|
84
|
+
*
|
|
85
|
+
* @param events - Array of events to create
|
|
86
|
+
* @param options - Optional idempotency and request ID options
|
|
87
|
+
* @param apiKey - Optional API key (otherwise uses ARCHIVA_SECRET_KEY env var)
|
|
88
|
+
* @returns Array of created event IDs
|
|
89
|
+
*/
|
|
90
|
+
declare function createEvents(events: CreateEventInput[], options?: CreateEventOptions, apiKey?: string): Promise<{
|
|
91
|
+
eventIds: string[];
|
|
92
|
+
}>;
|
|
93
|
+
|
|
94
|
+
interface FrontendTokenResponse {
|
|
95
|
+
token: string;
|
|
96
|
+
expiresAt: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Fetches a frontend token from the Archiva API
|
|
100
|
+
*
|
|
101
|
+
* @param projectId - Optional project ID for scoping
|
|
102
|
+
* @param apiBaseUrl - Archiva API base URL (defaults to https://api.archiva.app)
|
|
103
|
+
* @returns Frontend token response
|
|
104
|
+
*/
|
|
105
|
+
declare function createFrontendTokenGET(projectId?: string, apiBaseUrl?: string): Promise<FrontendTokenResponse>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Next.js route handler for GET /api/archiva/frontend-token
|
|
109
|
+
*
|
|
110
|
+
* This handler can be used in the host app's route file:
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* // app/api/archiva/frontend-token/route.ts
|
|
114
|
+
* export { GET } from '@archiva/archiva-nextjs/server';
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* Or with custom configuration:
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { createFrontendTokenRoute } from '@archiva/archiva-nextjs/server';
|
|
121
|
+
*
|
|
122
|
+
* export const GET = createFrontendTokenRoute({
|
|
123
|
+
* apiBaseUrl: process.env.ARCHIVA_API_URL,
|
|
124
|
+
* });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
declare function createFrontendTokenRoute(options?: {
|
|
128
|
+
apiBaseUrl?: string;
|
|
129
|
+
}): (request: NextRequest) => Promise<NextResponse<FrontendTokenResponse> | NextResponse<{
|
|
130
|
+
error: string;
|
|
131
|
+
}>>;
|
|
132
|
+
/**
|
|
133
|
+
* Default GET handler (for direct export)
|
|
134
|
+
*/
|
|
135
|
+
declare function GET(request: NextRequest): Promise<NextResponse<FrontendTokenResponse> | NextResponse<{
|
|
136
|
+
error: string;
|
|
137
|
+
}>>;
|
|
138
|
+
|
|
139
|
+
export { ArchivaError as A, type CreateEventInput as C, type EventChange as E, type FrontendTokenResponse as F, GET as G, type LoadEventsParams as L, type PageResult as P, createEvents as a, createFrontendTokenGET as b, createEvent as c, createFrontendTokenRoute as d, type CreateEventOptions as e, type AuditEventListItem as f, loadEvents as l };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ArchivaProvider, ArchivaProviderProps } from './react/index.mjs';
|
|
2
|
-
export { A as ArchivaError, f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, E as EventChange, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from './index-
|
|
2
|
+
export { A as ArchivaError, f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, E as EventChange, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from './index-BJ8aJsbs.mjs';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'next/server';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ArchivaProvider, ArchivaProviderProps } from './react/index.js';
|
|
2
|
-
export { A as ArchivaError, f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, E as EventChange, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from './index-
|
|
2
|
+
export { A as ArchivaError, f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, E as EventChange, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from './index-BJ8aJsbs.js';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'next/server';
|
package/dist/react/client.js
CHANGED
|
@@ -119,30 +119,32 @@ var CloudCogIcon = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime2.js
|
|
|
119
119
|
);
|
|
120
120
|
function eventToTimelineItem(event, getActorAvatar) {
|
|
121
121
|
const actorId = event.actorId;
|
|
122
|
-
|
|
122
|
+
const actorType = event.actorType || "user";
|
|
123
123
|
let actorIdPart = actorId || "";
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
if (actorId && actorId.includes(":")) {
|
|
125
|
+
const [, ...rest] = actorId.split(":");
|
|
126
|
+
actorIdPart = rest.join(":") || actorId;
|
|
127
|
+
}
|
|
128
|
+
let actorDisplay = event.actorDisplay || null;
|
|
129
|
+
if (!actorDisplay && actorId) {
|
|
126
130
|
if (actorId.includes(":")) {
|
|
127
131
|
const [type, ...rest] = actorId.split(":");
|
|
128
|
-
|
|
129
|
-
actorIdPart = rest.join(":");
|
|
132
|
+
const idPart = rest.join(":");
|
|
130
133
|
if (type === "service" || type === "system") {
|
|
131
|
-
actorDisplay = `${type.charAt(0).toUpperCase() + type.slice(1)} ${
|
|
134
|
+
actorDisplay = `${type.charAt(0).toUpperCase() + type.slice(1)} ${idPart.charAt(0).toUpperCase() + idPart.slice(1)}`;
|
|
132
135
|
} else {
|
|
133
|
-
actorDisplay =
|
|
136
|
+
actorDisplay = idPart.charAt(0).toUpperCase() + idPart.slice(1);
|
|
134
137
|
}
|
|
135
138
|
} else {
|
|
136
|
-
actorIdPart = actorId;
|
|
137
139
|
actorDisplay = actorId.charAt(0).toUpperCase() + actorId.slice(1);
|
|
138
140
|
}
|
|
139
|
-
}
|
|
141
|
+
}
|
|
142
|
+
if (!actorDisplay) {
|
|
140
143
|
actorDisplay = "Unknown Actor";
|
|
141
|
-
actorIdPart = "unknown";
|
|
142
144
|
}
|
|
143
145
|
const userName = actorDisplay;
|
|
144
|
-
const userHandle = actorIdPart;
|
|
145
|
-
const initials =
|
|
146
|
+
const userHandle = actorIdPart || "unknown";
|
|
147
|
+
const initials = userHandle.charAt(0).toUpperCase();
|
|
146
148
|
const actorAvatarOrIcon = actorId && getActorAvatar ? getActorAvatar(actorId) : void 0;
|
|
147
149
|
let actorAvatar = void 0;
|
|
148
150
|
let actorIcon = void 0;
|
|
@@ -189,6 +191,9 @@ async function fetchEventsWithRetry(apiBaseUrl, getToken, forceRefreshToken, par
|
|
|
189
191
|
if (params.entityType) {
|
|
190
192
|
url.searchParams.set("entityType", params.entityType);
|
|
191
193
|
}
|
|
194
|
+
if (params.actorType) {
|
|
195
|
+
url.searchParams.set("actorType", params.actorType);
|
|
196
|
+
}
|
|
192
197
|
if (params.limit) {
|
|
193
198
|
url.searchParams.set("limit", String(params.limit));
|
|
194
199
|
}
|
|
@@ -318,22 +323,18 @@ function SimpleAvatar({
|
|
|
318
323
|
}
|
|
319
324
|
);
|
|
320
325
|
}
|
|
321
|
-
function getActorType(actorId) {
|
|
322
|
-
if (!actorId) return "user";
|
|
323
|
-
if (actorId.includes(":")) {
|
|
324
|
-
const [type] = actorId.split(":");
|
|
325
|
-
if (type === "service" || type === "system") {
|
|
326
|
-
return type;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
return "user";
|
|
330
|
-
}
|
|
331
326
|
function applyClientSideFilters(events, searchQuery, showSystemAndServices) {
|
|
332
327
|
let filtered = events;
|
|
333
328
|
if (!showSystemAndServices) {
|
|
334
329
|
filtered = filtered.filter((event) => {
|
|
335
|
-
|
|
336
|
-
|
|
330
|
+
if (event.actorType) {
|
|
331
|
+
return event.actorType === "user";
|
|
332
|
+
}
|
|
333
|
+
if (event.actorId && event.actorId.includes(":")) {
|
|
334
|
+
const [type] = event.actorId.split(":");
|
|
335
|
+
return type !== "service" && type !== "system";
|
|
336
|
+
}
|
|
337
|
+
return true;
|
|
337
338
|
});
|
|
338
339
|
}
|
|
339
340
|
if (!searchQuery.trim()) {
|
|
@@ -341,7 +342,7 @@ function applyClientSideFilters(events, searchQuery, showSystemAndServices) {
|
|
|
341
342
|
}
|
|
342
343
|
const query = searchQuery.toLowerCase();
|
|
343
344
|
return filtered.filter((event) => {
|
|
344
|
-
return event.action.toLowerCase().includes(query) || event.entityType.toLowerCase().includes(query) || event.entityId.toLowerCase().includes(query) || event.actorId && event.actorId.toLowerCase().includes(query) || event.source && event.source.toLowerCase().includes(query);
|
|
345
|
+
return event.action.toLowerCase().includes(query) || event.entityType.toLowerCase().includes(query) || event.entityId.toLowerCase().includes(query) || event.actorId && event.actorId.toLowerCase().includes(query) || event.source && event.source.toLowerCase().includes(query) || event.actorDisplay && event.actorDisplay.toLowerCase().includes(query);
|
|
345
346
|
});
|
|
346
347
|
}
|
|
347
348
|
function Timeline({
|
|
@@ -372,6 +373,8 @@ function Timeline({
|
|
|
372
373
|
entityId,
|
|
373
374
|
actorId,
|
|
374
375
|
entityType,
|
|
376
|
+
// Filter by actorType on API side
|
|
377
|
+
actorType: showSystemAndServices ? void 0 : "user",
|
|
375
378
|
limit: initialLimit,
|
|
376
379
|
cursor: options?.reset ? void 0 : options?.currentCursor ?? cursor
|
|
377
380
|
};
|
|
@@ -390,13 +393,13 @@ function Timeline({
|
|
|
390
393
|
setLoading(false);
|
|
391
394
|
}
|
|
392
395
|
},
|
|
393
|
-
[entityId, actorId, entityType, initialLimit, apiBaseUrl, getToken, forceRefreshToken, cursor]
|
|
396
|
+
[entityId, actorId, entityType, initialLimit, apiBaseUrl, getToken, forceRefreshToken, cursor, showSystemAndServices]
|
|
394
397
|
);
|
|
395
398
|
React2.useEffect(() => {
|
|
396
399
|
setCursor(void 0);
|
|
397
400
|
setAllEvents([]);
|
|
398
401
|
void load({ reset: true });
|
|
399
|
-
}, [entityId, actorId, entityType]);
|
|
402
|
+
}, [entityId, actorId, entityType, showSystemAndServices]);
|
|
400
403
|
const filteredEvents = React2.useMemo(() => {
|
|
401
404
|
return applyClientSideFilters(allEvents, searchQuery, showSystemAndServices);
|
|
402
405
|
}, [allEvents, searchQuery, showSystemAndServices]);
|
package/dist/react/client.mjs
CHANGED
|
@@ -74,30 +74,32 @@ var CloudCogIcon = ({ className }) => /* @__PURE__ */ jsxs(
|
|
|
74
74
|
);
|
|
75
75
|
function eventToTimelineItem(event, getActorAvatar) {
|
|
76
76
|
const actorId = event.actorId;
|
|
77
|
-
|
|
77
|
+
const actorType = event.actorType || "user";
|
|
78
78
|
let actorIdPart = actorId || "";
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
if (actorId && actorId.includes(":")) {
|
|
80
|
+
const [, ...rest] = actorId.split(":");
|
|
81
|
+
actorIdPart = rest.join(":") || actorId;
|
|
82
|
+
}
|
|
83
|
+
let actorDisplay = event.actorDisplay || null;
|
|
84
|
+
if (!actorDisplay && actorId) {
|
|
81
85
|
if (actorId.includes(":")) {
|
|
82
86
|
const [type, ...rest] = actorId.split(":");
|
|
83
|
-
|
|
84
|
-
actorIdPart = rest.join(":");
|
|
87
|
+
const idPart = rest.join(":");
|
|
85
88
|
if (type === "service" || type === "system") {
|
|
86
|
-
actorDisplay = `${type.charAt(0).toUpperCase() + type.slice(1)} ${
|
|
89
|
+
actorDisplay = `${type.charAt(0).toUpperCase() + type.slice(1)} ${idPart.charAt(0).toUpperCase() + idPart.slice(1)}`;
|
|
87
90
|
} else {
|
|
88
|
-
actorDisplay =
|
|
91
|
+
actorDisplay = idPart.charAt(0).toUpperCase() + idPart.slice(1);
|
|
89
92
|
}
|
|
90
93
|
} else {
|
|
91
|
-
actorIdPart = actorId;
|
|
92
94
|
actorDisplay = actorId.charAt(0).toUpperCase() + actorId.slice(1);
|
|
93
95
|
}
|
|
94
|
-
}
|
|
96
|
+
}
|
|
97
|
+
if (!actorDisplay) {
|
|
95
98
|
actorDisplay = "Unknown Actor";
|
|
96
|
-
actorIdPart = "unknown";
|
|
97
99
|
}
|
|
98
100
|
const userName = actorDisplay;
|
|
99
|
-
const userHandle = actorIdPart;
|
|
100
|
-
const initials =
|
|
101
|
+
const userHandle = actorIdPart || "unknown";
|
|
102
|
+
const initials = userHandle.charAt(0).toUpperCase();
|
|
101
103
|
const actorAvatarOrIcon = actorId && getActorAvatar ? getActorAvatar(actorId) : void 0;
|
|
102
104
|
let actorAvatar = void 0;
|
|
103
105
|
let actorIcon = void 0;
|
|
@@ -144,6 +146,9 @@ async function fetchEventsWithRetry(apiBaseUrl, getToken, forceRefreshToken, par
|
|
|
144
146
|
if (params.entityType) {
|
|
145
147
|
url.searchParams.set("entityType", params.entityType);
|
|
146
148
|
}
|
|
149
|
+
if (params.actorType) {
|
|
150
|
+
url.searchParams.set("actorType", params.actorType);
|
|
151
|
+
}
|
|
147
152
|
if (params.limit) {
|
|
148
153
|
url.searchParams.set("limit", String(params.limit));
|
|
149
154
|
}
|
|
@@ -273,22 +278,18 @@ function SimpleAvatar({
|
|
|
273
278
|
}
|
|
274
279
|
);
|
|
275
280
|
}
|
|
276
|
-
function getActorType(actorId) {
|
|
277
|
-
if (!actorId) return "user";
|
|
278
|
-
if (actorId.includes(":")) {
|
|
279
|
-
const [type] = actorId.split(":");
|
|
280
|
-
if (type === "service" || type === "system") {
|
|
281
|
-
return type;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return "user";
|
|
285
|
-
}
|
|
286
281
|
function applyClientSideFilters(events, searchQuery, showSystemAndServices) {
|
|
287
282
|
let filtered = events;
|
|
288
283
|
if (!showSystemAndServices) {
|
|
289
284
|
filtered = filtered.filter((event) => {
|
|
290
|
-
|
|
291
|
-
|
|
285
|
+
if (event.actorType) {
|
|
286
|
+
return event.actorType === "user";
|
|
287
|
+
}
|
|
288
|
+
if (event.actorId && event.actorId.includes(":")) {
|
|
289
|
+
const [type] = event.actorId.split(":");
|
|
290
|
+
return type !== "service" && type !== "system";
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
292
293
|
});
|
|
293
294
|
}
|
|
294
295
|
if (!searchQuery.trim()) {
|
|
@@ -296,7 +297,7 @@ function applyClientSideFilters(events, searchQuery, showSystemAndServices) {
|
|
|
296
297
|
}
|
|
297
298
|
const query = searchQuery.toLowerCase();
|
|
298
299
|
return filtered.filter((event) => {
|
|
299
|
-
return event.action.toLowerCase().includes(query) || event.entityType.toLowerCase().includes(query) || event.entityId.toLowerCase().includes(query) || event.actorId && event.actorId.toLowerCase().includes(query) || event.source && event.source.toLowerCase().includes(query);
|
|
300
|
+
return event.action.toLowerCase().includes(query) || event.entityType.toLowerCase().includes(query) || event.entityId.toLowerCase().includes(query) || event.actorId && event.actorId.toLowerCase().includes(query) || event.source && event.source.toLowerCase().includes(query) || event.actorDisplay && event.actorDisplay.toLowerCase().includes(query);
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
303
|
function Timeline({
|
|
@@ -327,6 +328,8 @@ function Timeline({
|
|
|
327
328
|
entityId,
|
|
328
329
|
actorId,
|
|
329
330
|
entityType,
|
|
331
|
+
// Filter by actorType on API side
|
|
332
|
+
actorType: showSystemAndServices ? void 0 : "user",
|
|
330
333
|
limit: initialLimit,
|
|
331
334
|
cursor: options?.reset ? void 0 : options?.currentCursor ?? cursor
|
|
332
335
|
};
|
|
@@ -345,13 +348,13 @@ function Timeline({
|
|
|
345
348
|
setLoading(false);
|
|
346
349
|
}
|
|
347
350
|
},
|
|
348
|
-
[entityId, actorId, entityType, initialLimit, apiBaseUrl, getToken, forceRefreshToken, cursor]
|
|
351
|
+
[entityId, actorId, entityType, initialLimit, apiBaseUrl, getToken, forceRefreshToken, cursor, showSystemAndServices]
|
|
349
352
|
);
|
|
350
353
|
React.useEffect(() => {
|
|
351
354
|
setCursor(void 0);
|
|
352
355
|
setAllEvents([]);
|
|
353
356
|
void load({ reset: true });
|
|
354
|
-
}, [entityId, actorId, entityType]);
|
|
357
|
+
}, [entityId, actorId, entityType, showSystemAndServices]);
|
|
355
358
|
const filteredEvents = React.useMemo(() => {
|
|
356
359
|
return applyClientSideFilters(allEvents, searchQuery, showSystemAndServices);
|
|
357
360
|
}, [allEvents, searchQuery, showSystemAndServices]);
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from '../index-
|
|
1
|
+
export { f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from '../index-BJ8aJsbs.mjs';
|
|
2
2
|
import 'next/server';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from '../index-
|
|
1
|
+
export { f as AuditEventListItem, C as CreateEventInput, e as CreateEventOptions, F as FrontendTokenResponse, G as GET, L as LoadEventsParams, P as PageResult, c as createEvent, a as createEvents, b as createFrontendTokenGET, d as createFrontendTokenRoute, l as loadEvents } from '../index-BJ8aJsbs.js';
|
|
2
2
|
import 'next/server';
|