krawlet-js 1.2.0 → 1.3.1
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/dist/index.cjs +29 -0
- package/dist/index.d.cts +43 -5
- package/dist/index.d.ts +43 -5
- package/dist/index.js +29 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -243,6 +243,35 @@ var HealthResource = class {
|
|
|
243
243
|
const response = await this.client.request("/v1/health/detailed");
|
|
244
244
|
return response.data;
|
|
245
245
|
}
|
|
246
|
+
async getServiceStatus(service, useDetailed = false) {
|
|
247
|
+
if (useDetailed) {
|
|
248
|
+
const health2 = await this.detailed();
|
|
249
|
+
return health2.services[service];
|
|
250
|
+
}
|
|
251
|
+
const health = await this.check();
|
|
252
|
+
return health.services[service];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Check if all services are connected
|
|
256
|
+
* @returns true if all services have 'connected' status
|
|
257
|
+
*/
|
|
258
|
+
async areAllServicesConnected() {
|
|
259
|
+
const health = await this.check();
|
|
260
|
+
const services = health.services;
|
|
261
|
+
return services.kromerWs.status === "connected" && services.chatbox.status === "connected" && services.discord.status === "connected";
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Get the connection status of all services as a simple object
|
|
265
|
+
* @returns Object mapping service names to their connection status
|
|
266
|
+
*/
|
|
267
|
+
async getServicesStatus() {
|
|
268
|
+
const health = await this.check();
|
|
269
|
+
return {
|
|
270
|
+
kromerWs: health.services.kromerWs.status,
|
|
271
|
+
chatbox: health.services.chatbox.status,
|
|
272
|
+
discord: health.services.discord.status
|
|
273
|
+
};
|
|
274
|
+
}
|
|
246
275
|
};
|
|
247
276
|
|
|
248
277
|
// src/resources/players.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -227,19 +227,51 @@ interface ErrorResponse {
|
|
|
227
227
|
};
|
|
228
228
|
meta: ApiResponseMeta;
|
|
229
229
|
}
|
|
230
|
+
type ServiceStatus = 'connected' | 'disconnected' | 'connecting' | 'error';
|
|
231
|
+
interface ServiceInfo {
|
|
232
|
+
status: ServiceStatus;
|
|
233
|
+
lastError?: string;
|
|
234
|
+
}
|
|
235
|
+
interface KromerServiceInfo extends ServiceInfo {
|
|
236
|
+
lastConnectedAt?: string;
|
|
237
|
+
lastTransactionId?: number;
|
|
238
|
+
}
|
|
239
|
+
interface ChatboxServiceInfo extends ServiceInfo {
|
|
240
|
+
owner?: string;
|
|
241
|
+
playerCount?: number;
|
|
242
|
+
}
|
|
243
|
+
interface DiscordServiceInfo extends ServiceInfo {
|
|
244
|
+
username?: string;
|
|
245
|
+
commandCount?: number;
|
|
246
|
+
}
|
|
247
|
+
interface HealthServices {
|
|
248
|
+
kromerWs: ServiceInfo;
|
|
249
|
+
chatbox: ServiceInfo;
|
|
250
|
+
discord: ServiceInfo;
|
|
251
|
+
}
|
|
252
|
+
interface HealthServicesDetailed {
|
|
253
|
+
kromerWs: KromerServiceInfo;
|
|
254
|
+
chatbox: ChatboxServiceInfo;
|
|
255
|
+
discord: DiscordServiceInfo;
|
|
256
|
+
}
|
|
257
|
+
interface HealthChecks {
|
|
258
|
+
database: boolean;
|
|
259
|
+
memory: boolean;
|
|
260
|
+
kromerWs: boolean;
|
|
261
|
+
chatbox: boolean;
|
|
262
|
+
discord: boolean;
|
|
263
|
+
}
|
|
230
264
|
interface HealthResponse {
|
|
231
265
|
status: string;
|
|
232
266
|
timestamp: string;
|
|
233
267
|
uptime: number;
|
|
234
268
|
version: string;
|
|
235
269
|
name: string;
|
|
270
|
+
services: HealthServices;
|
|
236
271
|
}
|
|
237
272
|
interface DetailedHealthResponse {
|
|
238
273
|
status: 'healthy' | 'degraded';
|
|
239
|
-
checks:
|
|
240
|
-
database: boolean;
|
|
241
|
-
memory: boolean;
|
|
242
|
-
};
|
|
274
|
+
checks: HealthChecks;
|
|
243
275
|
details: {
|
|
244
276
|
timestamp: string;
|
|
245
277
|
uptime: number;
|
|
@@ -253,6 +285,7 @@ interface DetailedHealthResponse {
|
|
|
253
285
|
node: string;
|
|
254
286
|
platform: string;
|
|
255
287
|
};
|
|
288
|
+
services: HealthServicesDetailed;
|
|
256
289
|
}
|
|
257
290
|
interface StorageData {
|
|
258
291
|
data: unknown;
|
|
@@ -305,11 +338,16 @@ declare class HttpClient {
|
|
|
305
338
|
private sleep;
|
|
306
339
|
}
|
|
307
340
|
|
|
341
|
+
type ServiceName = 'kromerWs' | 'chatbox' | 'discord';
|
|
308
342
|
declare class HealthResource {
|
|
309
343
|
private client;
|
|
310
344
|
constructor(client: HttpClient);
|
|
311
345
|
check(): Promise<HealthResponse>;
|
|
312
346
|
detailed(): Promise<DetailedHealthResponse>;
|
|
347
|
+
getServiceStatus<T extends ServiceName>(service: T, useDetailed?: false): Promise<ServiceInfo>;
|
|
348
|
+
getServiceStatus<T extends ServiceName>(service: T, useDetailed: true): Promise<T extends 'kromerWs' ? KromerServiceInfo : T extends 'chatbox' ? ChatboxServiceInfo : DiscordServiceInfo>;
|
|
349
|
+
areAllServicesConnected(): Promise<boolean>;
|
|
350
|
+
getServicesStatus(): Promise<Record<ServiceName, ServiceStatus>>;
|
|
313
351
|
}
|
|
314
352
|
|
|
315
353
|
declare class PlayersResource {
|
|
@@ -429,4 +467,4 @@ declare class KrawletError extends Error {
|
|
|
429
467
|
isRateLimitError(): boolean;
|
|
430
468
|
}
|
|
431
469
|
|
|
432
|
-
export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type ChangeLogOptions, type ChangeLogResult, type DetailedHealthResponse, ErrorCode, type ErrorResponse, HealthResource, type HealthResponse, type Item, type ItemChangeLog, type ItemChangeType, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, ReportsResource, type RequestLog, type RequestLogsResponse, type Shop, type ShopChangeLog, type ShopSyncData, ShopsResource, type StorageData, StorageResource };
|
|
470
|
+
export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type ChangeLogOptions, type ChangeLogResult, type ChatboxServiceInfo, type DetailedHealthResponse, type DiscordServiceInfo, ErrorCode, type ErrorResponse, type HealthChecks, HealthResource, type HealthResponse, type HealthServices, type HealthServicesDetailed, type Item, type ItemChangeLog, type ItemChangeType, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type KromerServiceInfo, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, ReportsResource, type RequestLog, type RequestLogsResponse, type ServiceInfo, type ServiceName, type ServiceStatus, type Shop, type ShopChangeLog, type ShopSyncData, ShopsResource, type StorageData, StorageResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -227,19 +227,51 @@ interface ErrorResponse {
|
|
|
227
227
|
};
|
|
228
228
|
meta: ApiResponseMeta;
|
|
229
229
|
}
|
|
230
|
+
type ServiceStatus = 'connected' | 'disconnected' | 'connecting' | 'error';
|
|
231
|
+
interface ServiceInfo {
|
|
232
|
+
status: ServiceStatus;
|
|
233
|
+
lastError?: string;
|
|
234
|
+
}
|
|
235
|
+
interface KromerServiceInfo extends ServiceInfo {
|
|
236
|
+
lastConnectedAt?: string;
|
|
237
|
+
lastTransactionId?: number;
|
|
238
|
+
}
|
|
239
|
+
interface ChatboxServiceInfo extends ServiceInfo {
|
|
240
|
+
owner?: string;
|
|
241
|
+
playerCount?: number;
|
|
242
|
+
}
|
|
243
|
+
interface DiscordServiceInfo extends ServiceInfo {
|
|
244
|
+
username?: string;
|
|
245
|
+
commandCount?: number;
|
|
246
|
+
}
|
|
247
|
+
interface HealthServices {
|
|
248
|
+
kromerWs: ServiceInfo;
|
|
249
|
+
chatbox: ServiceInfo;
|
|
250
|
+
discord: ServiceInfo;
|
|
251
|
+
}
|
|
252
|
+
interface HealthServicesDetailed {
|
|
253
|
+
kromerWs: KromerServiceInfo;
|
|
254
|
+
chatbox: ChatboxServiceInfo;
|
|
255
|
+
discord: DiscordServiceInfo;
|
|
256
|
+
}
|
|
257
|
+
interface HealthChecks {
|
|
258
|
+
database: boolean;
|
|
259
|
+
memory: boolean;
|
|
260
|
+
kromerWs: boolean;
|
|
261
|
+
chatbox: boolean;
|
|
262
|
+
discord: boolean;
|
|
263
|
+
}
|
|
230
264
|
interface HealthResponse {
|
|
231
265
|
status: string;
|
|
232
266
|
timestamp: string;
|
|
233
267
|
uptime: number;
|
|
234
268
|
version: string;
|
|
235
269
|
name: string;
|
|
270
|
+
services: HealthServices;
|
|
236
271
|
}
|
|
237
272
|
interface DetailedHealthResponse {
|
|
238
273
|
status: 'healthy' | 'degraded';
|
|
239
|
-
checks:
|
|
240
|
-
database: boolean;
|
|
241
|
-
memory: boolean;
|
|
242
|
-
};
|
|
274
|
+
checks: HealthChecks;
|
|
243
275
|
details: {
|
|
244
276
|
timestamp: string;
|
|
245
277
|
uptime: number;
|
|
@@ -253,6 +285,7 @@ interface DetailedHealthResponse {
|
|
|
253
285
|
node: string;
|
|
254
286
|
platform: string;
|
|
255
287
|
};
|
|
288
|
+
services: HealthServicesDetailed;
|
|
256
289
|
}
|
|
257
290
|
interface StorageData {
|
|
258
291
|
data: unknown;
|
|
@@ -305,11 +338,16 @@ declare class HttpClient {
|
|
|
305
338
|
private sleep;
|
|
306
339
|
}
|
|
307
340
|
|
|
341
|
+
type ServiceName = 'kromerWs' | 'chatbox' | 'discord';
|
|
308
342
|
declare class HealthResource {
|
|
309
343
|
private client;
|
|
310
344
|
constructor(client: HttpClient);
|
|
311
345
|
check(): Promise<HealthResponse>;
|
|
312
346
|
detailed(): Promise<DetailedHealthResponse>;
|
|
347
|
+
getServiceStatus<T extends ServiceName>(service: T, useDetailed?: false): Promise<ServiceInfo>;
|
|
348
|
+
getServiceStatus<T extends ServiceName>(service: T, useDetailed: true): Promise<T extends 'kromerWs' ? KromerServiceInfo : T extends 'chatbox' ? ChatboxServiceInfo : DiscordServiceInfo>;
|
|
349
|
+
areAllServicesConnected(): Promise<boolean>;
|
|
350
|
+
getServicesStatus(): Promise<Record<ServiceName, ServiceStatus>>;
|
|
313
351
|
}
|
|
314
352
|
|
|
315
353
|
declare class PlayersResource {
|
|
@@ -429,4 +467,4 @@ declare class KrawletError extends Error {
|
|
|
429
467
|
isRateLimitError(): boolean;
|
|
430
468
|
}
|
|
431
469
|
|
|
432
|
-
export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type ChangeLogOptions, type ChangeLogResult, type DetailedHealthResponse, ErrorCode, type ErrorResponse, HealthResource, type HealthResponse, type Item, type ItemChangeLog, type ItemChangeType, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, ReportsResource, type RequestLog, type RequestLogsResponse, type Shop, type ShopChangeLog, type ShopSyncData, ShopsResource, type StorageData, StorageResource };
|
|
470
|
+
export { AddressesResource, type ApiKeyInfo, ApiKeyResource, type ApiKeyTier, type ApiKeyUsage, type ApiResponse, type ApiResponseMeta, type ChangeLogOptions, type ChangeLogResult, type ChatboxServiceInfo, type DetailedHealthResponse, type DiscordServiceInfo, ErrorCode, type ErrorResponse, type HealthChecks, HealthResource, type HealthResponse, type HealthServices, type HealthServicesDetailed, type Item, type ItemChangeLog, type ItemChangeType, ItemsResource, type KnownAddress, type KnownAddressType, KrawletClient, type KrawletClientConfig, KrawletError, type KromerServiceInfo, type Player, type PlayerNotifications, PlayersResource, type Price, type PriceChangeLog, type QuickCodeGenerateResponse, type QuickCodeRedeemResponse, type RateLimit, type ReportRecords, ReportsResource, type RequestLog, type RequestLogsResponse, type ServiceInfo, type ServiceName, type ServiceStatus, type Shop, type ShopChangeLog, type ShopSyncData, ShopsResource, type StorageData, StorageResource };
|
package/dist/index.js
CHANGED
|
@@ -207,6 +207,35 @@ var HealthResource = class {
|
|
|
207
207
|
const response = await this.client.request("/v1/health/detailed");
|
|
208
208
|
return response.data;
|
|
209
209
|
}
|
|
210
|
+
async getServiceStatus(service, useDetailed = false) {
|
|
211
|
+
if (useDetailed) {
|
|
212
|
+
const health2 = await this.detailed();
|
|
213
|
+
return health2.services[service];
|
|
214
|
+
}
|
|
215
|
+
const health = await this.check();
|
|
216
|
+
return health.services[service];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Check if all services are connected
|
|
220
|
+
* @returns true if all services have 'connected' status
|
|
221
|
+
*/
|
|
222
|
+
async areAllServicesConnected() {
|
|
223
|
+
const health = await this.check();
|
|
224
|
+
const services = health.services;
|
|
225
|
+
return services.kromerWs.status === "connected" && services.chatbox.status === "connected" && services.discord.status === "connected";
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get the connection status of all services as a simple object
|
|
229
|
+
* @returns Object mapping service names to their connection status
|
|
230
|
+
*/
|
|
231
|
+
async getServicesStatus() {
|
|
232
|
+
const health = await this.check();
|
|
233
|
+
return {
|
|
234
|
+
kromerWs: health.services.kromerWs.status,
|
|
235
|
+
chatbox: health.services.chatbox.status,
|
|
236
|
+
discord: health.services.discord.status
|
|
237
|
+
};
|
|
238
|
+
}
|
|
210
239
|
};
|
|
211
240
|
|
|
212
241
|
// src/resources/players.ts
|