@archiva/archiva-nextjs 0.2.8 → 0.2.81

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.
@@ -118,34 +118,13 @@ var CloudCogIcon = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime2.js
118
118
  }
119
119
  );
120
120
  function eventToTimelineItem(event, getActorAvatar) {
121
- const actorId = event.actorId;
122
- const actorType = event.actorType || "user";
123
- let actorIdPart = actorId || "";
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) {
130
- if (actorId.includes(":")) {
131
- const [type, ...rest] = actorId.split(":");
132
- const idPart = rest.join(":");
133
- if (type === "service" || type === "system") {
134
- actorDisplay = `${type.charAt(0).toUpperCase() + type.slice(1)} ${idPart.charAt(0).toUpperCase() + idPart.slice(1)}`;
135
- } else {
136
- actorDisplay = idPart.charAt(0).toUpperCase() + idPart.slice(1);
137
- }
138
- } else {
139
- actorDisplay = actorId.charAt(0).toUpperCase() + actorId.slice(1);
140
- }
141
- }
142
- if (!actorDisplay) {
143
- actorDisplay = "Unknown Actor";
144
- }
145
- const userName = actorDisplay;
146
- const userHandle = actorIdPart || "unknown";
147
- const initials = userHandle.charAt(0).toUpperCase();
148
- const actorAvatarOrIcon = actorId && getActorAvatar ? getActorAvatar(actorId) : void 0;
121
+ const action = event.action.charAt(0).toUpperCase() + event.action.slice(1);
122
+ const description = action;
123
+ const actorId = event.actorId || "unknown";
124
+ const userName = actorId.includes(":") ? actorId.split(":")[1] || actorId : actorId;
125
+ const userHandle = userName;
126
+ const initials = userName.charAt(0).toUpperCase();
127
+ const actorAvatarOrIcon = getActorAvatar ? getActorAvatar(actorId) : void 0;
149
128
  let actorAvatar = void 0;
150
129
  let actorIcon = void 0;
151
130
  if (typeof actorAvatarOrIcon === "string") {
@@ -153,7 +132,8 @@ function eventToTimelineItem(event, getActorAvatar) {
153
132
  } else if (actorAvatarOrIcon) {
154
133
  actorIcon = actorAvatarOrIcon;
155
134
  }
156
- if (!actorAvatar && !actorIcon && actorId) {
135
+ const actorType = event.actorType ?? "user";
136
+ if (!actorAvatar && !actorIcon) {
157
137
  if (actorType === "user") {
158
138
  actorAvatar = "https://www.gravatar.com/avatar?d=mp";
159
139
  } else if (actorType === "system") {
@@ -162,21 +142,30 @@ function eventToTimelineItem(event, getActorAvatar) {
162
142
  actorIcon = CloudCogIcon;
163
143
  }
164
144
  }
165
- const action = event.action.charAt(0).toUpperCase() + event.action.slice(1);
166
145
  return {
167
146
  id: event.id,
168
147
  title: "",
169
- // Not used in activity layout
170
- description: action,
171
- timestamp: event.receivedAt,
172
- userName,
148
+ // Required by TimelineItem type, but not used in activity layout - matches ActivityLog.tsx line 352
149
+ userName: userName.charAt(0).toUpperCase() + userName.slice(1),
150
+ // Matches ActivityLog.tsx line 353
151
+ actorDisplay: event.actorDisplay ?? void 0,
152
+ // Matches ActivityLog.tsx line 354
173
153
  userHandle,
174
- actorDisplay,
154
+ // Matches ActivityLog.tsx line 355
155
+ description,
156
+ // Matches ActivityLog.tsx line 356
175
157
  entityType: event.entityType.toLowerCase(),
158
+ // Matches ActivityLog.tsx line 357
159
+ timestamp: new Date(event.receivedAt),
160
+ // Matches ActivityLog.tsx line 358 - ensure it's a Date object
176
161
  avatar: actorAvatar,
162
+ // Matches ActivityLog.tsx line 359
177
163
  icon: actorIcon,
164
+ // Matches ActivityLog.tsx line 360
178
165
  avatarFallback: initials,
166
+ // Matches ActivityLog.tsx line 361
179
167
  statusIndicator: false,
168
+ // Can be set to true for recent items - matches ActivityLog.tsx line 362
180
169
  data: event
181
170
  };
182
171
  }
@@ -221,8 +210,25 @@ async function fetchEventsWithRetry(apiBaseUrl, getToken, forceRefreshToken, par
221
210
  if (!payload || typeof payload !== "object" || !Array.isArray(payload.items)) {
222
211
  throw new Error("Invalid response format");
223
212
  }
213
+ const items = payload.items.map((item) => {
214
+ if (typeof item !== "object" || item === null) {
215
+ throw new Error("Invalid item format in response");
216
+ }
217
+ const event = item;
218
+ return {
219
+ id: String(event.id ?? ""),
220
+ receivedAt: String(event.receivedAt ?? ""),
221
+ action: String(event.action ?? ""),
222
+ entityType: String(event.entityType ?? ""),
223
+ entityId: String(event.entityId ?? ""),
224
+ actorId: event.actorId !== null && event.actorId !== void 0 ? String(event.actorId) : null,
225
+ actorType: event.actorType && (event.actorType === "user" || event.actorType === "service" || event.actorType === "system") ? event.actorType : void 0,
226
+ actorDisplay: event.actorDisplay !== null && event.actorDisplay !== void 0 ? String(event.actorDisplay) : void 0,
227
+ source: event.source !== null && event.source !== void 0 ? String(event.source) : null
228
+ };
229
+ });
224
230
  return {
225
- items: payload.items,
231
+ items,
226
232
  nextCursor: typeof payload.nextCursor === "string" ? payload.nextCursor : void 0
227
233
  };
228
234
  }
@@ -73,34 +73,13 @@ var CloudCogIcon = ({ className }) => /* @__PURE__ */ jsxs(
73
73
  }
74
74
  );
75
75
  function eventToTimelineItem(event, getActorAvatar) {
76
- const actorId = event.actorId;
77
- const actorType = event.actorType || "user";
78
- let actorIdPart = actorId || "";
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) {
85
- if (actorId.includes(":")) {
86
- const [type, ...rest] = actorId.split(":");
87
- const idPart = rest.join(":");
88
- if (type === "service" || type === "system") {
89
- actorDisplay = `${type.charAt(0).toUpperCase() + type.slice(1)} ${idPart.charAt(0).toUpperCase() + idPart.slice(1)}`;
90
- } else {
91
- actorDisplay = idPart.charAt(0).toUpperCase() + idPart.slice(1);
92
- }
93
- } else {
94
- actorDisplay = actorId.charAt(0).toUpperCase() + actorId.slice(1);
95
- }
96
- }
97
- if (!actorDisplay) {
98
- actorDisplay = "Unknown Actor";
99
- }
100
- const userName = actorDisplay;
101
- const userHandle = actorIdPart || "unknown";
102
- const initials = userHandle.charAt(0).toUpperCase();
103
- const actorAvatarOrIcon = actorId && getActorAvatar ? getActorAvatar(actorId) : void 0;
76
+ const action = event.action.charAt(0).toUpperCase() + event.action.slice(1);
77
+ const description = action;
78
+ const actorId = event.actorId || "unknown";
79
+ const userName = actorId.includes(":") ? actorId.split(":")[1] || actorId : actorId;
80
+ const userHandle = userName;
81
+ const initials = userName.charAt(0).toUpperCase();
82
+ const actorAvatarOrIcon = getActorAvatar ? getActorAvatar(actorId) : void 0;
104
83
  let actorAvatar = void 0;
105
84
  let actorIcon = void 0;
106
85
  if (typeof actorAvatarOrIcon === "string") {
@@ -108,7 +87,8 @@ function eventToTimelineItem(event, getActorAvatar) {
108
87
  } else if (actorAvatarOrIcon) {
109
88
  actorIcon = actorAvatarOrIcon;
110
89
  }
111
- if (!actorAvatar && !actorIcon && actorId) {
90
+ const actorType = event.actorType ?? "user";
91
+ if (!actorAvatar && !actorIcon) {
112
92
  if (actorType === "user") {
113
93
  actorAvatar = "https://www.gravatar.com/avatar?d=mp";
114
94
  } else if (actorType === "system") {
@@ -117,21 +97,30 @@ function eventToTimelineItem(event, getActorAvatar) {
117
97
  actorIcon = CloudCogIcon;
118
98
  }
119
99
  }
120
- const action = event.action.charAt(0).toUpperCase() + event.action.slice(1);
121
100
  return {
122
101
  id: event.id,
123
102
  title: "",
124
- // Not used in activity layout
125
- description: action,
126
- timestamp: event.receivedAt,
127
- userName,
103
+ // Required by TimelineItem type, but not used in activity layout - matches ActivityLog.tsx line 352
104
+ userName: userName.charAt(0).toUpperCase() + userName.slice(1),
105
+ // Matches ActivityLog.tsx line 353
106
+ actorDisplay: event.actorDisplay ?? void 0,
107
+ // Matches ActivityLog.tsx line 354
128
108
  userHandle,
129
- actorDisplay,
109
+ // Matches ActivityLog.tsx line 355
110
+ description,
111
+ // Matches ActivityLog.tsx line 356
130
112
  entityType: event.entityType.toLowerCase(),
113
+ // Matches ActivityLog.tsx line 357
114
+ timestamp: new Date(event.receivedAt),
115
+ // Matches ActivityLog.tsx line 358 - ensure it's a Date object
131
116
  avatar: actorAvatar,
117
+ // Matches ActivityLog.tsx line 359
132
118
  icon: actorIcon,
119
+ // Matches ActivityLog.tsx line 360
133
120
  avatarFallback: initials,
121
+ // Matches ActivityLog.tsx line 361
134
122
  statusIndicator: false,
123
+ // Can be set to true for recent items - matches ActivityLog.tsx line 362
135
124
  data: event
136
125
  };
137
126
  }
@@ -176,8 +165,25 @@ async function fetchEventsWithRetry(apiBaseUrl, getToken, forceRefreshToken, par
176
165
  if (!payload || typeof payload !== "object" || !Array.isArray(payload.items)) {
177
166
  throw new Error("Invalid response format");
178
167
  }
168
+ const items = payload.items.map((item) => {
169
+ if (typeof item !== "object" || item === null) {
170
+ throw new Error("Invalid item format in response");
171
+ }
172
+ const event = item;
173
+ return {
174
+ id: String(event.id ?? ""),
175
+ receivedAt: String(event.receivedAt ?? ""),
176
+ action: String(event.action ?? ""),
177
+ entityType: String(event.entityType ?? ""),
178
+ entityId: String(event.entityId ?? ""),
179
+ actorId: event.actorId !== null && event.actorId !== void 0 ? String(event.actorId) : null,
180
+ actorType: event.actorType && (event.actorType === "user" || event.actorType === "service" || event.actorType === "system") ? event.actorType : void 0,
181
+ actorDisplay: event.actorDisplay !== null && event.actorDisplay !== void 0 ? String(event.actorDisplay) : void 0,
182
+ source: event.source !== null && event.source !== void 0 ? String(event.source) : null
183
+ };
184
+ });
179
185
  return {
180
- items: payload.items,
186
+ items,
181
187
  nextCursor: typeof payload.nextCursor === "string" ? payload.nextCursor : void 0
182
188
  };
183
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archiva/archiva-nextjs",
3
- "version": "0.2.08",
3
+ "version": "0.2.081",
4
4
  "description": "Archiva Next.js SDK - Server Actions and Timeline Component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -30,6 +30,7 @@
30
30
  "files": ["dist"],
31
31
  "scripts": {
32
32
  "build": "tsup src/index.tsx src/react/index.ts src/react/client.ts src/server/index.ts --format esm,cjs --dts",
33
+ "dev": "tsup src/index.tsx src/react/index.ts src/react/client.ts src/server/index.ts --format esm,cjs --dts --watch",
33
34
  "test": "vitest run --config vitest.config.ts"
34
35
  },
35
36
  "peerDependencies": {