@alliance-droid/status-feedback-system 0.1.0 → 0.2.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 (54) hide show
  1. package/dist/api.d.ts +94 -0
  2. package/dist/api.js +100 -0
  3. package/dist/components/FeedbackBoard.svelte +842 -0
  4. package/dist/components/FeedbackBoard.svelte.d.ts +19 -0
  5. package/dist/components/FeedbackButton.svelte +3 -3
  6. package/dist/components/FeedbackButton.svelte.d.ts +1 -1
  7. package/dist/components/FeedbackForm.svelte +3 -3
  8. package/dist/components/FeedbackForm.svelte.d.ts +1 -1
  9. package/dist/components/StatusBanner.svelte +36 -3
  10. package/dist/components/StatusBanner.svelte.d.ts +7 -1
  11. package/dist/components/StatusPage.svelte +150 -83
  12. package/dist/components/StatusPage.svelte.d.ts +10 -3
  13. package/dist/index.d.ts +7 -9
  14. package/dist/index.js +6 -8
  15. package/dist/types.d.ts +13 -6
  16. package/package.json +2 -13
  17. package/dist/components/admin/AdminDashboard.svelte +0 -274
  18. package/dist/components/admin/AdminDashboard.svelte.d.ts +0 -9
  19. package/dist/components/admin/ApiKeyManager.svelte +0 -68
  20. package/dist/components/admin/ApiKeyManager.svelte.d.ts +0 -7
  21. package/dist/components/admin/FeedbackList.svelte +0 -160
  22. package/dist/components/admin/FeedbackList.svelte.d.ts +0 -17
  23. package/dist/components/admin/IncidentForm.svelte +0 -135
  24. package/dist/components/admin/IncidentForm.svelte.d.ts +0 -14
  25. package/dist/components/admin/IncidentManager.svelte +0 -153
  26. package/dist/components/admin/IncidentManager.svelte.d.ts +0 -13
  27. package/dist/components/admin/ProjectForm.svelte +0 -106
  28. package/dist/components/admin/ProjectForm.svelte.d.ts +0 -13
  29. package/dist/components/admin/ProjectList.svelte +0 -57
  30. package/dist/components/admin/ProjectList.svelte.d.ts +0 -10
  31. package/dist/components/admin/StatusControl.svelte +0 -62
  32. package/dist/components/admin/StatusControl.svelte.d.ts +0 -8
  33. package/dist/components/admin/SystemManager.svelte +0 -119
  34. package/dist/components/admin/SystemManager.svelte.d.ts +0 -13
  35. package/dist/components/admin/index.d.ts +0 -9
  36. package/dist/components/admin/index.js +0 -9
  37. package/dist/server/db.d.ts +0 -17
  38. package/dist/server/db.js +0 -68
  39. package/dist/server/feedback.d.ts +0 -27
  40. package/dist/server/feedback.js +0 -124
  41. package/dist/server/handlers.d.ts +0 -41
  42. package/dist/server/handlers.js +0 -251
  43. package/dist/server/incidents.d.ts +0 -27
  44. package/dist/server/incidents.js +0 -180
  45. package/dist/server/index.d.ts +0 -101
  46. package/dist/server/index.js +0 -71
  47. package/dist/server/projects.d.ts +0 -45
  48. package/dist/server/projects.js +0 -156
  49. package/dist/server/schema.d.ts +0 -9
  50. package/dist/server/schema.js +0 -94
  51. package/dist/server/systems.d.ts +0 -20
  52. package/dist/server/systems.js +0 -146
  53. package/dist/server/types.d.ts +0 -4
  54. package/dist/server/types.js +0 -4
package/dist/api.d.ts ADDED
@@ -0,0 +1,94 @@
1
+ /**
2
+ * API client for communicating with the status-feedback-admin backend.
3
+ *
4
+ * Usage:
5
+ * import { createStatusClient } from '@alliance-droid/status-feedback-system';
6
+ *
7
+ * const client = createStatusClient({
8
+ * apiUrl: 'https://status-admin.yourcompany.com',
9
+ * apiKey: 'sf_abc123...',
10
+ * });
11
+ *
12
+ * const { systems, incidents } = await client.getStatus();
13
+ */
14
+ import type { System, Incident, StatusHistoryEntry, Feedback, FeedbackResponse } from './types.js';
15
+ export interface StatusClientConfig {
16
+ /** Base URL of the status-feedback-admin app */
17
+ apiUrl: string;
18
+ /** API key for the project (sf_ prefixed) */
19
+ apiKey: string;
20
+ /** Optional custom fetch function (for SSR) */
21
+ fetch?: typeof globalThis.fetch;
22
+ }
23
+ export interface StatusData {
24
+ systems: System[];
25
+ overallStatus: string;
26
+ }
27
+ export interface IncidentData {
28
+ incidents: Incident[];
29
+ }
30
+ export interface UptimeData {
31
+ history: Record<string, StatusHistoryEntry[]>;
32
+ }
33
+ export interface BoardCategory {
34
+ name: string;
35
+ count: number;
36
+ }
37
+ export interface BoardItem {
38
+ id: string;
39
+ title: string | null;
40
+ category: string | null;
41
+ message: string;
42
+ status: string;
43
+ votes: number;
44
+ adminResponse: string | null;
45
+ responseCount: number;
46
+ createdAt: number;
47
+ }
48
+ export interface BoardData {
49
+ items: BoardItem[];
50
+ total: number;
51
+ categories: BoardCategory[];
52
+ }
53
+ export interface StatusClient {
54
+ /** Get current system statuses */
55
+ getStatus(): Promise<StatusData>;
56
+ /** Get incidents (active + recent resolved) */
57
+ getIncidents(options?: {
58
+ limit?: number;
59
+ includeResolved?: boolean;
60
+ }): Promise<IncidentData>;
61
+ /** Get uptime history for all systems (90 days) */
62
+ getUptime(options?: {
63
+ days?: number;
64
+ }): Promise<UptimeData>;
65
+ /** Submit user feedback */
66
+ submitFeedback(data: {
67
+ message: string;
68
+ title?: string;
69
+ category?: string;
70
+ email?: string;
71
+ pageUrl?: string;
72
+ metadata?: Record<string, unknown>;
73
+ }): Promise<Feedback>;
74
+ /** Get public feedback board */
75
+ getBoard(options?: {
76
+ category?: string;
77
+ status?: 'open' | 'resolved' | 'all';
78
+ sort?: 'votes' | 'newest';
79
+ limit?: number;
80
+ offset?: number;
81
+ }): Promise<BoardData>;
82
+ /** Vote on a feedback item */
83
+ vote(feedbackId: string, direction?: 'up' | 'down'): Promise<{
84
+ votes: number;
85
+ }>;
86
+ /** Get responses for a feedback item */
87
+ getResponses(feedbackId: string): Promise<{
88
+ responses: FeedbackResponse[];
89
+ }>;
90
+ }
91
+ /**
92
+ * Create a status API client instance
93
+ */
94
+ export declare function createStatusClient(config: StatusClientConfig): StatusClient;
package/dist/api.js ADDED
@@ -0,0 +1,100 @@
1
+ /**
2
+ * API client for communicating with the status-feedback-admin backend.
3
+ *
4
+ * Usage:
5
+ * import { createStatusClient } from '@alliance-droid/status-feedback-system';
6
+ *
7
+ * const client = createStatusClient({
8
+ * apiUrl: 'https://status-admin.yourcompany.com',
9
+ * apiKey: 'sf_abc123...',
10
+ * });
11
+ *
12
+ * const { systems, incidents } = await client.getStatus();
13
+ */
14
+ /**
15
+ * Create a status API client instance
16
+ */
17
+ export function createStatusClient(config) {
18
+ const { apiUrl, apiKey } = config;
19
+ const fetchFn = config.fetch ?? globalThis.fetch;
20
+ const baseUrl = apiUrl.replace(/\/$/, '');
21
+ async function request(path, options) {
22
+ const url = `${baseUrl}${path}${path.includes('?') ? '&' : '?'}key=${encodeURIComponent(apiKey)}`;
23
+ const response = await fetchFn(url, {
24
+ ...options,
25
+ headers: {
26
+ 'Content-Type': 'application/json',
27
+ ...options?.headers,
28
+ },
29
+ });
30
+ if (!response.ok) {
31
+ const body = await response.text();
32
+ let message = `API error: ${response.status}`;
33
+ try {
34
+ const parsed = JSON.parse(body);
35
+ if (parsed.error)
36
+ message = parsed.error;
37
+ }
38
+ catch {
39
+ // ignore parse errors
40
+ }
41
+ throw new Error(message);
42
+ }
43
+ const json = (await response.json());
44
+ if (!json.success) {
45
+ throw new Error(json.error ?? 'Unknown API error');
46
+ }
47
+ return json.data;
48
+ }
49
+ return {
50
+ async getStatus() {
51
+ return request('/api/status');
52
+ },
53
+ async getIncidents(options) {
54
+ const params = new URLSearchParams();
55
+ if (options?.limit)
56
+ params.set('limit', String(options.limit));
57
+ if (options?.includeResolved !== undefined)
58
+ params.set('includeResolved', String(options.includeResolved));
59
+ const qs = params.toString();
60
+ return request(`/api/incidents${qs ? `?${qs}` : ''}`);
61
+ },
62
+ async getUptime(options) {
63
+ const params = new URLSearchParams();
64
+ if (options?.days)
65
+ params.set('days', String(options.days));
66
+ const qs = params.toString();
67
+ return request(`/api/uptime${qs ? `?${qs}` : ''}`);
68
+ },
69
+ async submitFeedback(data) {
70
+ return request('/api/feedback', {
71
+ method: 'POST',
72
+ body: JSON.stringify(data),
73
+ });
74
+ },
75
+ async getBoard(options) {
76
+ const params = new URLSearchParams();
77
+ if (options?.category)
78
+ params.set('category', options.category);
79
+ if (options?.status)
80
+ params.set('status', options.status);
81
+ if (options?.sort)
82
+ params.set('sort', options.sort);
83
+ if (options?.limit)
84
+ params.set('limit', String(options.limit));
85
+ if (options?.offset)
86
+ params.set('offset', String(options.offset));
87
+ const qs = params.toString();
88
+ return request(`/api/board${qs ? `?${qs}` : ''}`);
89
+ },
90
+ async vote(feedbackId, direction = 'up') {
91
+ return request('/api/board/vote', {
92
+ method: 'POST',
93
+ body: JSON.stringify({ feedbackId, direction }),
94
+ });
95
+ },
96
+ async getResponses(feedbackId) {
97
+ return request(`/api/board/${feedbackId}/responses`);
98
+ },
99
+ };
100
+ }