@checkstack/integration-webex-backend 0.0.23 → 0.0.25
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/CHANGELOG.md +27 -0
- package/package.json +4 -4
- package/src/provider.test.ts +24 -14
- package/src/provider.ts +12 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @checkstack/integration-webex-backend
|
|
2
2
|
|
|
3
|
+
## 0.0.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d1ef12: ## Downstream consumer bumps for the anomaly detection + cache system rollout
|
|
8
|
+
|
|
9
|
+
Packages on this branch were updated as part of the anomaly detection feature (schema annotations on result fields, plugin metadata for the modular cache system) but were not listed in the upstream changesets.
|
|
10
|
+
|
|
11
|
+
- **`@checkstack/healthcheck-common`** (minor) — new RPC contract additions and schema changes supporting per-field anomaly metadata.
|
|
12
|
+
- **`@checkstack/cache-memory-common`** (minor) — new package providing access rules + plugin metadata for the in-memory cache backend.
|
|
13
|
+
- **healthcheck plugins** (patch) — adopt the new `x-anomaly-*` schema annotations on their result fields so anomaly detection works automatically against their checks. No public API changes.
|
|
14
|
+
- **integration / notification / auth / queue / collector plugins** (patch) — minor internal updates as consumers of upstream API changes (cache plugin registry, schema additions). No public API changes.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [8d1ef12]
|
|
17
|
+
- Updated dependencies [8d1ef12]
|
|
18
|
+
- @checkstack/common@0.7.0
|
|
19
|
+
- @checkstack/backend-api@0.13.0
|
|
20
|
+
- @checkstack/integration-backend@0.1.20
|
|
21
|
+
|
|
22
|
+
## 0.0.24
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [26d8bae]
|
|
27
|
+
- @checkstack/backend-api@0.12.0
|
|
28
|
+
- @checkstack/integration-backend@0.1.19
|
|
29
|
+
|
|
3
30
|
## 0.0.23
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/integration-webex-backend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"checkstack": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"lint:code": "eslint . --max-warnings 0"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@checkstack/backend-api": "0.
|
|
16
|
-
"@checkstack/integration-backend": "0.1.
|
|
17
|
-
"@checkstack/common": "0.6.
|
|
15
|
+
"@checkstack/backend-api": "0.12.0",
|
|
16
|
+
"@checkstack/integration-backend": "0.1.19",
|
|
17
|
+
"@checkstack/common": "0.6.5",
|
|
18
18
|
"zod": "^4.2.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
package/src/provider.test.ts
CHANGED
|
@@ -116,9 +116,9 @@ describe("Webex Integration Provider", () => {
|
|
|
116
116
|
(async () => {
|
|
117
117
|
return new Response(
|
|
118
118
|
JSON.stringify({ id: "bot-123", displayName: "Test Bot" }),
|
|
119
|
-
{ status: 200 }
|
|
119
|
+
{ status: 200 },
|
|
120
120
|
);
|
|
121
|
-
}) as unknown as typeof fetch
|
|
121
|
+
}) as unknown as typeof fetch,
|
|
122
122
|
);
|
|
123
123
|
|
|
124
124
|
try {
|
|
@@ -137,7 +137,7 @@ describe("Webex Integration Provider", () => {
|
|
|
137
137
|
const mockFetch = spyOn(globalThis, "fetch").mockImplementation(
|
|
138
138
|
(async () => {
|
|
139
139
|
return new Response("Unauthorized", { status: 401 });
|
|
140
|
-
}) as unknown as typeof fetch
|
|
140
|
+
}) as unknown as typeof fetch,
|
|
141
141
|
);
|
|
142
142
|
|
|
143
143
|
try {
|
|
@@ -153,13 +153,23 @@ describe("Webex Integration Provider", () => {
|
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
it("returns failure for invalid config", async () => {
|
|
156
|
-
//
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
// Explicitly mock fetch to simulate network error for empty token
|
|
157
|
+
const mockFetch = spyOn(globalThis, "fetch").mockImplementation(
|
|
158
|
+
(async () => {
|
|
159
|
+
throw new TypeError("fetch failed");
|
|
160
|
+
}) as unknown as typeof fetch,
|
|
161
|
+
);
|
|
160
162
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
try {
|
|
164
|
+
const result = await webexProvider.testConnection!({
|
|
165
|
+
botToken: "",
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect(result.success).toBe(false);
|
|
169
|
+
expect(result.message).toContain("failed");
|
|
170
|
+
} finally {
|
|
171
|
+
mockFetch.mockRestore();
|
|
172
|
+
}
|
|
163
173
|
});
|
|
164
174
|
});
|
|
165
175
|
|
|
@@ -178,9 +188,9 @@ describe("Webex Integration Provider", () => {
|
|
|
178
188
|
{ id: "room-2", title: "DevOps", type: "group" },
|
|
179
189
|
],
|
|
180
190
|
}),
|
|
181
|
-
{ status: 200 }
|
|
191
|
+
{ status: 200 },
|
|
182
192
|
);
|
|
183
|
-
}) as unknown as typeof fetch
|
|
193
|
+
}) as unknown as typeof fetch,
|
|
184
194
|
);
|
|
185
195
|
|
|
186
196
|
try {
|
|
@@ -239,7 +249,7 @@ describe("Webex Integration Provider", () => {
|
|
|
239
249
|
|
|
240
250
|
const mockFetch = spyOn(globalThis, "fetch").mockImplementation((async (
|
|
241
251
|
_url: RequestInfo | URL,
|
|
242
|
-
options?: RequestInit
|
|
252
|
+
options?: RequestInit,
|
|
243
253
|
) => {
|
|
244
254
|
capturedBody = options?.body as string;
|
|
245
255
|
return new Response(JSON.stringify({ id: "msg-456" }), {
|
|
@@ -286,7 +296,7 @@ describe("Webex Integration Provider", () => {
|
|
|
286
296
|
|
|
287
297
|
const mockFetch = spyOn(globalThis, "fetch").mockImplementation((async (
|
|
288
298
|
_url: RequestInfo | URL,
|
|
289
|
-
options?: RequestInit
|
|
299
|
+
options?: RequestInit,
|
|
290
300
|
) => {
|
|
291
301
|
capturedBody = options?.body as string;
|
|
292
302
|
return new Response(JSON.stringify({ id: "msg-456" }), {
|
|
@@ -321,7 +331,7 @@ describe("Webex Integration Provider", () => {
|
|
|
321
331
|
|
|
322
332
|
const parsedBody = JSON.parse(capturedBody!);
|
|
323
333
|
expect(parsedBody.markdown).toBe(
|
|
324
|
-
"🚨 **Server Down** - Incident inc-123"
|
|
334
|
+
"🚨 **Server Down** - Incident inc-123",
|
|
325
335
|
);
|
|
326
336
|
} finally {
|
|
327
337
|
mockFetch.mockRestore();
|
package/src/provider.ts
CHANGED
|
@@ -27,7 +27,7 @@ const WEBEX_RESOLVERS = {
|
|
|
27
27
|
*/
|
|
28
28
|
export const WebexConnectionSchema = z.object({
|
|
29
29
|
botToken: configString({ "x-secret": true }).describe(
|
|
30
|
-
"Webex Bot Access Token from developer.webex.com"
|
|
30
|
+
"Webex Bot Access Token from developer.webex.com",
|
|
31
31
|
),
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -46,7 +46,7 @@ export const WebexSubscriptionSchema = z.object({
|
|
|
46
46
|
.string()
|
|
47
47
|
.optional()
|
|
48
48
|
.describe(
|
|
49
|
-
"Message template (supports {{event.payload.*}} placeholders). Leave empty for default format."
|
|
49
|
+
"Message template (supports {{event.payload.*}} placeholders). Leave empty for default format.",
|
|
50
50
|
),
|
|
51
51
|
});
|
|
52
52
|
|
|
@@ -78,7 +78,7 @@ interface WebexMessageResponse {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async function fetchWebexRooms(
|
|
81
|
-
botToken: string
|
|
81
|
+
botToken: string,
|
|
82
82
|
): Promise<
|
|
83
83
|
{ success: true; rooms: WebexRoom[] } | { success: false; error: string }
|
|
84
84
|
> {
|
|
@@ -129,7 +129,7 @@ async function sendWebexMessage(params: {
|
|
|
129
129
|
success: false,
|
|
130
130
|
error: `Webex API error (${response.status}): ${errorText.slice(
|
|
131
131
|
0,
|
|
132
|
-
200
|
|
132
|
+
200,
|
|
133
133
|
)}`,
|
|
134
134
|
};
|
|
135
135
|
}
|
|
@@ -143,7 +143,7 @@ async function sendWebexMessage(params: {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
async function testWebexConnection(
|
|
146
|
-
botToken: string
|
|
146
|
+
botToken: string,
|
|
147
147
|
): Promise<
|
|
148
148
|
{ success: true; botName: string } | { success: false; error: string }
|
|
149
149
|
> {
|
|
@@ -173,7 +173,7 @@ async function testWebexConnection(
|
|
|
173
173
|
|
|
174
174
|
function expandTemplate(
|
|
175
175
|
template: string,
|
|
176
|
-
context: Record<string, unknown
|
|
176
|
+
context: Record<string, unknown>,
|
|
177
177
|
): string {
|
|
178
178
|
return template.replaceAll(/\{\{([^}]+)\}\}/g, (_match, path: string) => {
|
|
179
179
|
const trimmedPath = path.trim();
|
|
@@ -198,7 +198,7 @@ function expandTemplate(
|
|
|
198
198
|
function buildDefaultMessage(
|
|
199
199
|
eventId: string,
|
|
200
200
|
payload: Record<string, unknown>,
|
|
201
|
-
subscriptionName: string
|
|
201
|
+
subscriptionName: string,
|
|
202
202
|
): string {
|
|
203
203
|
const lines: string[] = [
|
|
204
204
|
`📢 **Integration Event**`,
|
|
@@ -256,7 +256,7 @@ export const webexProvider: IntegrationProvider<
|
|
|
256
256
|
},
|
|
257
257
|
|
|
258
258
|
async getConnectionOptions(
|
|
259
|
-
params: GetConnectionOptionsParams
|
|
259
|
+
params: GetConnectionOptionsParams,
|
|
260
260
|
): Promise<ConnectionOption[]> {
|
|
261
261
|
const { resolverName, connectionId, getConnectionWithCredentials } = params;
|
|
262
262
|
|
|
@@ -298,8 +298,7 @@ export const webexProvider: IntegrationProvider<
|
|
|
298
298
|
message: `Connection failed: ${result.error}`,
|
|
299
299
|
};
|
|
300
300
|
} catch (error) {
|
|
301
|
-
const message =
|
|
302
|
-
extractErrorMessage(error, "Invalid configuration");
|
|
301
|
+
const message = extractErrorMessage(error, "Invalid configuration");
|
|
303
302
|
return {
|
|
304
303
|
success: false,
|
|
305
304
|
message: `Validation failed: ${message}`,
|
|
@@ -308,7 +307,7 @@ export const webexProvider: IntegrationProvider<
|
|
|
308
307
|
},
|
|
309
308
|
|
|
310
309
|
async deliver(
|
|
311
|
-
context: IntegrationDeliveryContext<WebexSubscriptionConfig
|
|
310
|
+
context: IntegrationDeliveryContext<WebexSubscriptionConfig>,
|
|
312
311
|
): Promise<IntegrationDeliveryResult> {
|
|
313
312
|
const { event, subscription, providerConfig, logger } = context;
|
|
314
313
|
|
|
@@ -324,7 +323,7 @@ export const webexProvider: IntegrationProvider<
|
|
|
324
323
|
}
|
|
325
324
|
|
|
326
325
|
const connection = await context.getConnectionWithCredentials(
|
|
327
|
-
config.connectionId
|
|
326
|
+
config.connectionId,
|
|
328
327
|
);
|
|
329
328
|
|
|
330
329
|
if (!connection) {
|
|
@@ -356,7 +355,7 @@ export const webexProvider: IntegrationProvider<
|
|
|
356
355
|
markdown = buildDefaultMessage(
|
|
357
356
|
event.eventId,
|
|
358
357
|
event.payload as Record<string, unknown>,
|
|
359
|
-
subscription.name
|
|
358
|
+
subscription.name,
|
|
360
359
|
);
|
|
361
360
|
}
|
|
362
361
|
|