@mcp-consultant-tools/service-bus 1.0.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.
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Azure Service Bus Integration
3
+ *
4
+ * Provides read-only access to Azure Service Bus queues and dead letter queues.
5
+ * Supports Entra ID authentication and per-resource connection strings.
6
+ *
7
+ * CRITICAL DESIGN: Uses TWO separate client types:
8
+ * - ServiceBusClient: For message operations (peek)
9
+ * - ServiceBusAdministrationClient: For management operations (list queues, get properties)
10
+ *
11
+ * Read-only by design: Uses peekMessages() only, NEVER receiveMessages()
12
+ */
13
+ import { ServiceBusReceivedMessage, QueueProperties } from '@azure/service-bus';
14
+ /**
15
+ * Service Bus namespace resource configuration
16
+ */
17
+ export interface ServiceBusResource {
18
+ id: string;
19
+ name: string;
20
+ namespace: string;
21
+ active: boolean;
22
+ connectionString?: string;
23
+ description?: string;
24
+ }
25
+ /**
26
+ * Service Bus service configuration
27
+ */
28
+ export interface ServiceBusConfig {
29
+ resources: ServiceBusResource[];
30
+ authMethod: 'entra-id' | 'connection-string';
31
+ tenantId?: string;
32
+ clientId?: string;
33
+ clientSecret?: string;
34
+ sanitizeMessages?: boolean;
35
+ peekTimeout?: number;
36
+ retryMaxAttempts?: number;
37
+ retryDelay?: number;
38
+ maxSearchMessages?: number;
39
+ maxPeekMessages?: number;
40
+ cacheQueueListTTL?: number;
41
+ }
42
+ /**
43
+ * Queue information
44
+ */
45
+ export interface QueueInfo {
46
+ name: string;
47
+ activeMessageCount: number;
48
+ deadLetterMessageCount: number;
49
+ scheduledMessageCount: number;
50
+ sizeInBytes: number | undefined;
51
+ totalMessageCount: number | undefined;
52
+ requiresSession: boolean;
53
+ }
54
+ /**
55
+ * Search result
56
+ */
57
+ export interface SearchResult {
58
+ messages: ServiceBusReceivedMessage[];
59
+ totalPeeked: number;
60
+ matchCount: number;
61
+ limitReached: boolean;
62
+ }
63
+ /**
64
+ * Search criteria
65
+ */
66
+ export interface SearchCriteria {
67
+ bodyContains?: string;
68
+ propertyKey?: string;
69
+ propertyValue?: any;
70
+ correlationId?: string;
71
+ messageId?: string;
72
+ sessionId?: string;
73
+ }
74
+ export declare class ServiceBusService {
75
+ private config;
76
+ private clients;
77
+ private adminClients;
78
+ private msalClient;
79
+ private accessToken;
80
+ private tokenExpirationTime;
81
+ private queueListCache;
82
+ constructor(config: ServiceBusConfig);
83
+ /**
84
+ * Get ServiceBusClient for message operations (peek)
85
+ * CRITICAL: This is for message operations ONLY
86
+ */
87
+ private getClient;
88
+ /**
89
+ * Get ServiceBusAdministrationClient for management operations (list queues, properties)
90
+ * CRITICAL: This is for management operations ONLY
91
+ */
92
+ private getAdminClient;
93
+ /**
94
+ * Test connection to Service Bus namespace
95
+ * Verifies both message operations and management operations permissions
96
+ */
97
+ testConnection(resourceId: string): Promise<{
98
+ connected: boolean;
99
+ namespace: string;
100
+ canPeekMessages: boolean;
101
+ canListQueues: boolean;
102
+ authMethod: string;
103
+ error?: string;
104
+ }>;
105
+ /**
106
+ * List all queues in a namespace (with caching)
107
+ */
108
+ listQueues(resourceId: string): Promise<QueueInfo[]>;
109
+ /**
110
+ * Peek messages from queue (non-destructive, read-only)
111
+ * CRITICAL: Uses peekMessages() which NEVER removes messages from queue
112
+ */
113
+ peekMessages(resourceId: string, queueName: string, maxMessages?: number, sessionId?: string): Promise<ServiceBusReceivedMessage[]>;
114
+ /**
115
+ * Peek dead letter messages
116
+ */
117
+ peekDeadLetterMessages(resourceId: string, queueName: string, maxMessages?: number, sessionId?: string): Promise<ServiceBusReceivedMessage[]>;
118
+ /**
119
+ * Get queue configuration properties (lock duration, max delivery count, etc.)
120
+ */
121
+ getQueueConfigProperties(resourceId: string, queueName: string): Promise<QueueProperties>;
122
+ /**
123
+ * Get queue information including both runtime metrics and configuration
124
+ */
125
+ getQueueProperties(resourceId: string, queueName: string): Promise<QueueInfo>;
126
+ /**
127
+ * Search messages by content/properties
128
+ * WARNING: Peeks messages into memory, then filters client-side
129
+ */
130
+ searchMessages(resourceId: string, queueName: string, searchCriteria: SearchCriteria, maxMessages?: number): Promise<SearchResult>;
131
+ /**
132
+ * Get namespace properties (tier, quotas)
133
+ * Note: v10.0 assumes Standard tier (256 KB)
134
+ */
135
+ getNamespaceProperties(resourceId: string): Promise<{
136
+ namespace: string;
137
+ tier: string;
138
+ maxMessageSizeKB: number;
139
+ }>;
140
+ /**
141
+ * Get all configured resources
142
+ */
143
+ getAllResources(): ServiceBusResource[];
144
+ /**
145
+ * Get active resources only
146
+ */
147
+ getActiveResources(): ServiceBusResource[];
148
+ /**
149
+ * Get resource by ID (with validation)
150
+ */
151
+ getResourceById(resourceId: string): ServiceBusResource;
152
+ /**
153
+ * Sanitize sensitive data from message (if enabled)
154
+ */
155
+ private sanitizeMessage;
156
+ /**
157
+ * Sanitize object recursively
158
+ */
159
+ private sanitizeObject;
160
+ /**
161
+ * Cleanup
162
+ */
163
+ close(): Promise<void>;
164
+ }
165
+ //# sourceMappingURL=ServiceBusService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceBusService.d.ts","sourceRoot":"","sources":["../src/ServiceBusService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAIL,yBAAyB,EACzB,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAS5B;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,UAAU,EAAE,UAAU,GAAG,mBAAmB,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,CA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