@grafana/assistant 0.1.10 → 0.1.11

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.
@@ -0,0 +1,41 @@
1
+ import { BusEventWithPayload } from '@grafana/data';
2
+ /**
3
+ * Payload for the InvestigationCreatedEvent
4
+ */
5
+ export interface InvestigationCreatedPayload {
6
+ /** The ID of the newly created investigation */
7
+ investigationId: string;
8
+ }
9
+ /**
10
+ * Event emitted when an investigation is created.
11
+ * External integrations can subscribe to this event to react to new investigations.
12
+ */
13
+ export declare class InvestigationCreatedEvent extends BusEventWithPayload<InvestigationCreatedPayload> {
14
+ static type: string;
15
+ }
16
+ /**
17
+ * Emit an InvestigationCreatedEvent to notify subscribers that a new investigation was created.
18
+ *
19
+ * @param investigationId - The ID of the newly created investigation
20
+ */
21
+ export declare function emitInvestigationCreated(investigationId: string): void;
22
+ /**
23
+ * Subscribe to investigation created events.
24
+ *
25
+ * @param callback - Function to call when an investigation is created
26
+ * @returns Unsubscribe function to stop listening for events
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { onInvestigationCreated } from '@grafana/assistant';
31
+ *
32
+ * const unsubscribe = onInvestigationCreated((payload) => {
33
+ * console.log('Investigation created:', payload.investigationId);
34
+ * });
35
+ *
36
+ * // Later, when you want to stop listening
37
+ * unsubscribe();
38
+ * ```
39
+ */
40
+ export declare function onInvestigationCreated(callback: (payload: InvestigationCreatedPayload) => void): () => void;
41
+ //# sourceMappingURL=investigations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"investigations.d.ts","sourceRoot":"","sources":["../src/investigations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gDAAgD;IAChD,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,2BAA2B,CAAC;IAC7F,MAAM,CAAC,IAAI,SAA6C;CACzD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAGtE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,IAAI,GAAG,MAAM,IAAI,CAM3G"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Event name dispatched when limits are updated via SSE.
3
+ * Other components can listen to this event to get real-time updates.
4
+ */
5
+ export declare const LIMITS_UPDATED_EVENT = "grafana-assistant-limits-updated";
6
+ /**
7
+ * Detail payload for the LIMITS_UPDATED_EVENT custom event.
8
+ */
9
+ export interface LimitsUpdatedEventDetail {
10
+ count: number;
11
+ limit: number;
12
+ }
13
+ /**
14
+ * Result type for limits data.
15
+ */
16
+ export interface LimitsData {
17
+ /** Current prompt count for the month */
18
+ count: number;
19
+ /** Monthly prompt limit (0 = unlimited) */
20
+ limit: number;
21
+ /** Current month in YYYY-MM format */
22
+ month: string;
23
+ /** Whether the limit has been reached */
24
+ isLimitReached: boolean;
25
+ }
26
+ /**
27
+ * Checks whether the user has reached their monthly prompt limit.
28
+ *
29
+ * @returns A promise that resolves to `true` if limits are reached, `false` otherwise
30
+ * @throws Error if the API call fails
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * import { checkLimits } from '@grafana/assistant';
35
+ *
36
+ * const data = await checkLimits();
37
+ * if (data.isLimitReached) {
38
+ * console.log('Monthly limit reached');
39
+ * }
40
+ * ```
41
+ */
42
+ export declare function checkLimits(): Promise<LimitsData>;
43
+ /**
44
+ * React hook to check user prompt limits.
45
+ * Automatically fetches limits data on mount and listens to real-time updates
46
+ * via the LIMITS_UPDATED_EVENT custom event.
47
+ *
48
+ * @returns An object containing limit data, loading state, error state, and refetch function
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * import { useLimits } from '@grafana/assistant';
53
+ *
54
+ * function MyComponent() {
55
+ * const { count, limit, isLimitReached, loading, error, refetch } = useLimits();
56
+ *
57
+ * if (loading) return <div>Loading...</div>;
58
+ * if (error) return <div>Error: {error}</div>;
59
+ * if (isLimitReached) return <div>Monthly limit reached ({count}/{limit})</div>;
60
+ * return <div>Prompts used: {count}/{limit || 'unlimited'}</div>;
61
+ * }
62
+ * ```
63
+ */
64
+ export declare function useLimits(): {
65
+ count: number;
66
+ limit: number;
67
+ month: string;
68
+ isLimitReached: boolean;
69
+ loading: boolean;
70
+ error: string | null;
71
+ refetch: () => Promise<void>;
72
+ };
73
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/limits/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;CACzB;AAiCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAMvD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS;;;;;;;;EA8DxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/assistant",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Type definitions and helper functions for Grafana Assistant",
5
5
  "repository": {
6
6
  "type": "git",