@observa/sdk 2.4.0 → 2.4.5
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/README.md +140 -176
- package/dist/apis/ingestApi.d.ts +1 -15
- package/dist/apis/ingestApi.d.ts.map +1 -1
- package/dist/apis/ingestApi.js +2 -151
- package/dist/apis/ingestApi.js.map +1 -1
- package/dist/apis/uptimeApi.js +1 -1
- package/dist/apis/uptimeApi.js.map +1 -1
- package/dist/domain/ingest.d.ts +4 -33
- package/dist/domain/ingest.d.ts.map +1 -1
- package/dist/http/httpClient.d.ts +5 -2
- package/dist/http/httpClient.d.ts.map +1 -1
- package/dist/http/httpClient.js +44 -8
- package/dist/http/httpClient.js.map +1 -1
- package/dist/index.d.ts +18 -507
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -582
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +4 -9
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +7 -19
- package/dist/sdk.js.map +1 -1
- package/package.json +9 -16
- package/dist/src/apis/ingestApi.d.ts +0 -22
- package/dist/src/apis/ingestApi.js +0 -167
- package/dist/src/apis/ingestApi.js.map +0 -1
- package/dist/src/apis/uptimeApi.d.ts +0 -11
- package/dist/src/apis/uptimeApi.js +0 -39
- package/dist/src/apis/uptimeApi.js.map +0 -1
- package/dist/src/domain/ingest.d.ts +0 -47
- package/dist/src/domain/ingest.js +0 -2
- package/dist/src/domain/ingest.js.map +0 -1
- package/dist/src/domain/uptime.d.ts +0 -23
- package/dist/src/domain/uptime.js +0 -2
- package/dist/src/domain/uptime.js.map +0 -1
- package/dist/src/http/errors.d.ts +0 -33
- package/dist/src/http/errors.js +0 -54
- package/dist/src/http/errors.js.map +0 -1
- package/dist/src/http/httpClient.d.ts +0 -45
- package/dist/src/http/httpClient.js +0 -165
- package/dist/src/http/httpClient.js.map +0 -1
- package/dist/src/index.d.ts +0 -12
- package/dist/src/index.js +0 -7
- package/dist/src/index.js.map +0 -1
- package/dist/src/sdk.d.ts +0 -23
- package/dist/src/sdk.js +0 -40
- package/dist/src/sdk.js.map +0 -1
- package/dist/src/utils/processContext.d.ts +0 -34
- package/dist/src/utils/processContext.js +0 -47
- package/dist/src/utils/processContext.js.map +0 -1
- package/dist/src/utils/validate.d.ts +0 -2
- package/dist/src/utils/validate.js +0 -12
- package/dist/src/utils/validate.js.map +0 -1
- package/dist/tests/httpClient.test.d.ts +0 -1
- package/dist/tests/httpClient.test.js +0 -47
- package/dist/tests/httpClient.test.js.map +0 -1
- package/dist/tests/ingestApi.test.d.ts +0 -1
- package/dist/tests/ingestApi.test.js +0 -65
- package/dist/tests/ingestApi.test.js.map +0 -1
- package/dist/tests/observaSdk.integration.test.d.ts +0 -1
- package/dist/tests/observaSdk.integration.test.js +0 -51
- package/dist/tests/observaSdk.integration.test.js.map +0 -1
- package/dist/tests/sdk.test.d.ts +0 -1
- package/dist/tests/sdk.test.js +0 -104
- package/dist/tests/sdk.test.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/utils/processContext.d.ts +0 -35
- package/dist/utils/processContext.d.ts.map +0 -1
- package/dist/utils/processContext.js +0 -47
- package/dist/utils/processContext.js.map +0 -1
- package/src/apis/ingestApi.ts +0 -199
- package/src/apis/uptimeApi.ts +0 -58
- package/src/domain/ingest.ts +0 -93
- package/src/domain/uptime.ts +0 -86
- package/src/http/errors.ts +0 -88
- package/src/http/httpClient.ts +0 -284
- package/src/index.ts +0 -68
- package/src/sdk.ts +0 -107
- package/src/utils/processContext.ts +0 -84
- package/src/utils/validate.ts +0 -19
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export type ErrorDetails = {
|
|
2
|
-
status?: number;
|
|
3
|
-
code?: string;
|
|
4
|
-
details?: unknown;
|
|
5
|
-
retryAfter?: number;
|
|
6
|
-
};
|
|
7
|
-
export declare class SdkError extends Error {
|
|
8
|
-
readonly status?: number;
|
|
9
|
-
readonly code?: string;
|
|
10
|
-
readonly details?: unknown;
|
|
11
|
-
constructor(message: string, details?: ErrorDetails);
|
|
12
|
-
}
|
|
13
|
-
export declare class ValidationError extends SdkError {
|
|
14
|
-
}
|
|
15
|
-
export declare class AuthError extends SdkError {
|
|
16
|
-
}
|
|
17
|
-
export declare class ForbiddenError extends SdkError {
|
|
18
|
-
}
|
|
19
|
-
export declare class NotFoundError extends SdkError {
|
|
20
|
-
}
|
|
21
|
-
export declare class ConflictError extends SdkError {
|
|
22
|
-
}
|
|
23
|
-
export declare class RateLimitError extends SdkError {
|
|
24
|
-
readonly retryAfter?: number;
|
|
25
|
-
constructor(message: string, details?: ErrorDetails);
|
|
26
|
-
}
|
|
27
|
-
export declare class ServerError extends SdkError {
|
|
28
|
-
}
|
|
29
|
-
export declare class NetworkError extends SdkError {
|
|
30
|
-
}
|
|
31
|
-
export declare class TimeoutError extends SdkError {
|
|
32
|
-
}
|
|
33
|
-
export declare function mapHttpError(status: number, details?: unknown, retryAfter?: number): SdkError;
|
package/dist/src/http/errors.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export class SdkError extends Error {
|
|
2
|
-
status;
|
|
3
|
-
code;
|
|
4
|
-
details;
|
|
5
|
-
constructor(message, details) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = new.target.name;
|
|
8
|
-
this.status = details?.status;
|
|
9
|
-
this.code = details?.code;
|
|
10
|
-
this.details = details?.details;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export class ValidationError extends SdkError {
|
|
14
|
-
}
|
|
15
|
-
export class AuthError extends SdkError {
|
|
16
|
-
}
|
|
17
|
-
export class ForbiddenError extends SdkError {
|
|
18
|
-
}
|
|
19
|
-
export class NotFoundError extends SdkError {
|
|
20
|
-
}
|
|
21
|
-
export class ConflictError extends SdkError {
|
|
22
|
-
}
|
|
23
|
-
export class RateLimitError extends SdkError {
|
|
24
|
-
retryAfter;
|
|
25
|
-
constructor(message, details) {
|
|
26
|
-
super(message, details);
|
|
27
|
-
this.retryAfter = details?.retryAfter;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export class ServerError extends SdkError {
|
|
31
|
-
}
|
|
32
|
-
export class NetworkError extends SdkError {
|
|
33
|
-
}
|
|
34
|
-
export class TimeoutError extends SdkError {
|
|
35
|
-
}
|
|
36
|
-
export function mapHttpError(status, details, retryAfter) {
|
|
37
|
-
const info = { status, details, retryAfter };
|
|
38
|
-
if (status === 400)
|
|
39
|
-
return new ValidationError('Invalid request', info);
|
|
40
|
-
if (status === 401)
|
|
41
|
-
return new AuthError('Unauthorized', info);
|
|
42
|
-
if (status === 403)
|
|
43
|
-
return new ForbiddenError('Forbidden', info);
|
|
44
|
-
if (status === 404)
|
|
45
|
-
return new NotFoundError('Resource not found', info);
|
|
46
|
-
if (status === 409)
|
|
47
|
-
return new ConflictError('Conflict', info);
|
|
48
|
-
if (status === 429)
|
|
49
|
-
return new RateLimitError('Rate limit exceeded', info);
|
|
50
|
-
if (status >= 500)
|
|
51
|
-
return new ServerError('Server error', info);
|
|
52
|
-
return new SdkError('HTTP error', info);
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/http/errors.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACtB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,OAAO,CAAU;IAK1B,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAA;IACnC,CAAC;CACJ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C,qBAAqB,EAAE,IAAI,CAAC,CAAA;IAC1E,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IAC/D,OAAO,IAAI,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export type AuthMode = 'apiKey' | 'none';
|
|
2
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
3
|
-
export type QueryParams = Record<string, string | number | boolean | undefined>;
|
|
4
|
-
export type RetryPolicy = {
|
|
5
|
-
retries: number;
|
|
6
|
-
retryDelayMs?: (attempt: number, response?: Response, error?: unknown) => number;
|
|
7
|
-
retryOn?: (response?: Response, error?: unknown) => boolean;
|
|
8
|
-
};
|
|
9
|
-
export type HttpClientOptions = {
|
|
10
|
-
baseUrl: string;
|
|
11
|
-
apiKey?: string;
|
|
12
|
-
timeoutMs?: number;
|
|
13
|
-
headers?: Record<string, string>;
|
|
14
|
-
retry?: RetryPolicy;
|
|
15
|
-
};
|
|
16
|
-
export type RequestOptions = {
|
|
17
|
-
method: HttpMethod;
|
|
18
|
-
path: string;
|
|
19
|
-
query?: QueryParams;
|
|
20
|
-
body?: unknown;
|
|
21
|
-
headers?: Record<string, string>;
|
|
22
|
-
auth?: AuthMode;
|
|
23
|
-
};
|
|
24
|
-
export declare class HttpClient {
|
|
25
|
-
private apiKey?;
|
|
26
|
-
private readonly baseUrl;
|
|
27
|
-
private readonly timeoutMs;
|
|
28
|
-
private readonly headers;
|
|
29
|
-
private readonly retry?;
|
|
30
|
-
private healthCheckPromise?;
|
|
31
|
-
constructor(options: HttpClientOptions);
|
|
32
|
-
setApiKey(apiKey?: string): void;
|
|
33
|
-
startHealthCheck(healthCheck: () => Promise<unknown>): void;
|
|
34
|
-
get<T>(path: string, options?: Omit<RequestOptions, 'method' | 'path'>): Promise<T>;
|
|
35
|
-
post<T>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'path' | 'body'>): Promise<T>;
|
|
36
|
-
put<T>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'path' | 'body'>): Promise<T>;
|
|
37
|
-
patch<T>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'path' | 'body'>): Promise<T>;
|
|
38
|
-
delete<T>(path: string, options?: Omit<RequestOptions, 'method' | 'path'>): Promise<T>;
|
|
39
|
-
request<T>(options: RequestOptions): Promise<T>;
|
|
40
|
-
private execute;
|
|
41
|
-
private buildUrl;
|
|
42
|
-
private readBody;
|
|
43
|
-
private parseRetryAfter;
|
|
44
|
-
private delay;
|
|
45
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { AuthError, NetworkError, TimeoutError, mapHttpError } from './errors.js';
|
|
2
|
-
export class HttpClient {
|
|
3
|
-
apiKey;
|
|
4
|
-
baseUrl;
|
|
5
|
-
timeoutMs;
|
|
6
|
-
headers;
|
|
7
|
-
retry;
|
|
8
|
-
healthCheckPromise;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.baseUrl = options.baseUrl.replace(/\/+$/, '');
|
|
11
|
-
this.apiKey = options.apiKey;
|
|
12
|
-
this.timeoutMs = options.timeoutMs ?? 5000;
|
|
13
|
-
this.headers = options.headers ?? {};
|
|
14
|
-
this.retry = options.retry;
|
|
15
|
-
}
|
|
16
|
-
setApiKey(apiKey) {
|
|
17
|
-
this.apiKey = apiKey;
|
|
18
|
-
}
|
|
19
|
-
startHealthCheck(healthCheck) {
|
|
20
|
-
if (!this.healthCheckPromise) {
|
|
21
|
-
const promise = healthCheck();
|
|
22
|
-
this.healthCheckPromise = promise;
|
|
23
|
-
promise.catch(() => undefined);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async get(path, options) {
|
|
27
|
-
return this.request({ method: 'GET', path, ...options });
|
|
28
|
-
}
|
|
29
|
-
async post(path, body, options) {
|
|
30
|
-
return this.request({ method: 'POST', path, body, ...options });
|
|
31
|
-
}
|
|
32
|
-
async put(path, body, options) {
|
|
33
|
-
return this.request({ method: 'PUT', path, body, ...options });
|
|
34
|
-
}
|
|
35
|
-
async patch(path, body, options) {
|
|
36
|
-
return this.request({ method: 'PATCH', path, body, ...options });
|
|
37
|
-
}
|
|
38
|
-
async delete(path, options) {
|
|
39
|
-
return this.request({ method: 'DELETE', path, ...options });
|
|
40
|
-
}
|
|
41
|
-
async request(options) {
|
|
42
|
-
if (this.healthCheckPromise) {
|
|
43
|
-
await this.healthCheckPromise;
|
|
44
|
-
}
|
|
45
|
-
const retry = this.retry ?? { retries: 0 };
|
|
46
|
-
const retryOn = retry.retryOn ?? ((response, error) => {
|
|
47
|
-
if (response)
|
|
48
|
-
return response.status === 429 || response.status >= 500;
|
|
49
|
-
return error instanceof NetworkError || error instanceof TimeoutError || error instanceof TypeError;
|
|
50
|
-
});
|
|
51
|
-
const retryDelayMs = retry.retryDelayMs ?? ((attempt) => Math.min(1000 * 2 ** (attempt - 1), 8000));
|
|
52
|
-
let lastError;
|
|
53
|
-
for (let attempt = 0; attempt <= retry.retries; attempt += 1) {
|
|
54
|
-
try {
|
|
55
|
-
const { response, data } = await this.execute(options);
|
|
56
|
-
if (!response.ok) {
|
|
57
|
-
const retryAfter = this.parseRetryAfter(response.headers.get('retry-after'));
|
|
58
|
-
const error = mapHttpError(response.status, data, retryAfter);
|
|
59
|
-
if (retryOn(response, error) && attempt < retry.retries) {
|
|
60
|
-
await this.delay(retryDelayMs(attempt + 1, response, error));
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
return data;
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
lastError = error;
|
|
69
|
-
if (retryOn(undefined, error) && attempt < retry.retries) {
|
|
70
|
-
await this.delay(retryDelayMs(attempt + 1, undefined, error));
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
throw lastError;
|
|
77
|
-
}
|
|
78
|
-
async execute(options) {
|
|
79
|
-
const url = this.buildUrl(options.path, options.query);
|
|
80
|
-
const headers = { ...this.headers, ...options.headers };
|
|
81
|
-
if (options.body !== undefined)
|
|
82
|
-
headers['content-type'] = 'application/json';
|
|
83
|
-
const authMode = options.auth ?? 'none';
|
|
84
|
-
if (authMode === 'apiKey') {
|
|
85
|
-
if (!this.apiKey)
|
|
86
|
-
throw new AuthError('API key is required');
|
|
87
|
-
headers['x-api-key'] = this.apiKey;
|
|
88
|
-
}
|
|
89
|
-
const controller = new AbortController();
|
|
90
|
-
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
91
|
-
try {
|
|
92
|
-
const response = await fetch(url, {
|
|
93
|
-
method: options.method,
|
|
94
|
-
headers,
|
|
95
|
-
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
96
|
-
signal: controller.signal,
|
|
97
|
-
});
|
|
98
|
-
const data = await this.readBody(response);
|
|
99
|
-
return { response, data };
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
if (error?.name === 'AbortError') {
|
|
103
|
-
throw new TimeoutError('Request timeout');
|
|
104
|
-
}
|
|
105
|
-
if (error instanceof NetworkError || error instanceof TimeoutError)
|
|
106
|
-
throw error;
|
|
107
|
-
if (error instanceof Error) {
|
|
108
|
-
if (error instanceof AuthError)
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
if (error instanceof Error && 'status' in error)
|
|
112
|
-
throw error;
|
|
113
|
-
throw new NetworkError('Network error', { details: error });
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
clearTimeout(timer);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
buildUrl(path, query) {
|
|
120
|
-
const base = this.baseUrl;
|
|
121
|
-
const fullPath = path.startsWith('http') ? path : `${base}${path.startsWith('/') ? '' : '/'}${path}`;
|
|
122
|
-
if (!query)
|
|
123
|
-
return fullPath;
|
|
124
|
-
const params = new URLSearchParams();
|
|
125
|
-
for (const [key, value] of Object.entries(query)) {
|
|
126
|
-
if (value === undefined)
|
|
127
|
-
continue;
|
|
128
|
-
params.set(key, String(value));
|
|
129
|
-
}
|
|
130
|
-
const suffix = params.toString();
|
|
131
|
-
return suffix ? `${fullPath}?${suffix}` : fullPath;
|
|
132
|
-
}
|
|
133
|
-
async readBody(response) {
|
|
134
|
-
if (response.status === 204)
|
|
135
|
-
return undefined;
|
|
136
|
-
const text = await response.text();
|
|
137
|
-
if (!text)
|
|
138
|
-
return undefined;
|
|
139
|
-
try {
|
|
140
|
-
return JSON.parse(text);
|
|
141
|
-
}
|
|
142
|
-
catch {
|
|
143
|
-
return text;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
parseRetryAfter(value) {
|
|
147
|
-
if (!value)
|
|
148
|
-
return undefined;
|
|
149
|
-
const seconds = Number(value);
|
|
150
|
-
if (!Number.isNaN(seconds) && Number.isFinite(seconds)) {
|
|
151
|
-
return Math.max(0, seconds);
|
|
152
|
-
}
|
|
153
|
-
const parsedDate = Date.parse(value);
|
|
154
|
-
if (Number.isNaN(parsedDate))
|
|
155
|
-
return undefined;
|
|
156
|
-
const diffMs = parsedDate - Date.now();
|
|
157
|
-
if (diffMs <= 0)
|
|
158
|
-
return 0;
|
|
159
|
-
return Math.ceil(diffMs / 1000);
|
|
160
|
-
}
|
|
161
|
-
async delay(ms) {
|
|
162
|
-
await new Promise(resolve => setTimeout(resolve, ms));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
//# sourceMappingURL=httpClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../../src/http/httpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AA6E9E,MAAM,OA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,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;IACzD,CAAC;CACJ"}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { ObservaSDK } from './sdk';
|
|
2
|
-
export type { ObservaSDKOptions } from './sdk';
|
|
3
|
-
export { HttpClient } from './http/httpClient';
|
|
4
|
-
export type { HttpClientOptions, RequestOptions, RetryPolicy, AuthMode } from './http/httpClient';
|
|
5
|
-
export { SdkError, ValidationError, AuthError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, NetworkError, TimeoutError, } from './http/errors';
|
|
6
|
-
export { UptimeApi } from './apis/uptimeApi';
|
|
7
|
-
export { IngestApi } from './apis/ingestApi';
|
|
8
|
-
export type { IngestNormalizationOptions } from './apis/ingestApi';
|
|
9
|
-
export type { UptimeEvent, UptimeStatus, UptimeHeartbeatInput, UptimeSummary } from './domain/uptime';
|
|
10
|
-
export type { IngestEvent, IngestEventContext, IngestException, IngestLevel, IngestRequest, IngestResponse, RequestContext, Stacktrace, StacktraceFrame, } from './domain/ingest';
|
|
11
|
-
export type { ProcessContext, ProcessContextDynamic, ProcessContextDynamicOptions, ProcessContextOptions, ProcessContextStatic, ProcessContextStaticOptions, } from './utils/processContext';
|
|
12
|
-
export { getProcessContext, getProcessContextDynamic, getProcessContextStatic } from './utils/processContext';
|
package/dist/src/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { ObservaSDK } from './sdk.js';
|
|
2
|
-
export { HttpClient } from './http/httpClient.js';
|
|
3
|
-
export { SdkError, ValidationError, AuthError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, NetworkError, TimeoutError, } from './http/errors.js';
|
|
4
|
-
export { UptimeApi } from './apis/uptimeApi.js';
|
|
5
|
-
export { IngestApi } from './apis/ingestApi.js';
|
|
6
|
-
export { getProcessContext, getProcessContextDynamic, getProcessContextStatic } from './utils/processContext.js';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AASlC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAS9C,OAAO,EACL,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAA;AAKtB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AA6B5C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/src/sdk.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { IngestApi, type IngestNormalizationOptions } from './apis/ingestApi';
|
|
2
|
-
import { UptimeApi } from './apis/uptimeApi';
|
|
3
|
-
import { type RetryPolicy } from './http/httpClient';
|
|
4
|
-
import { type ProcessContext, type ProcessContextDynamic, type ProcessContextDynamicOptions, type ProcessContextOptions, type ProcessContextStatic, type ProcessContextStaticOptions } from './utils/processContext';
|
|
5
|
-
export type ObservaSDKOptions = {
|
|
6
|
-
apiKey: string;
|
|
7
|
-
dsnKey: string;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
timeoutMs?: number;
|
|
10
|
-
retry?: RetryPolicy;
|
|
11
|
-
headers?: Record<string, string>;
|
|
12
|
-
ingest?: IngestNormalizationOptions;
|
|
13
|
-
};
|
|
14
|
-
export declare class ObservaSDK {
|
|
15
|
-
readonly uptime: UptimeApi;
|
|
16
|
-
readonly ingest: IngestApi;
|
|
17
|
-
private readonly http;
|
|
18
|
-
constructor(options: ObservaSDKOptions);
|
|
19
|
-
setApiKey(apiKey: string): void;
|
|
20
|
-
getProcessContext(options?: ProcessContextOptions): ProcessContext;
|
|
21
|
-
getProcessContextStatic(options?: ProcessContextStaticOptions): ProcessContextStatic;
|
|
22
|
-
getProcessContextDynamic(options?: ProcessContextDynamicOptions): ProcessContextDynamic;
|
|
23
|
-
}
|
package/dist/src/sdk.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { IngestApi } from './apis/ingestApi.js';
|
|
2
|
-
import { UptimeApi } from './apis/uptimeApi.js';
|
|
3
|
-
import { HttpClient } from './http/httpClient.js';
|
|
4
|
-
import { getProcessContext, getProcessContextDynamic, getProcessContextStatic, } from './utils/processContext.js';
|
|
5
|
-
const DEFAULT_BASE_URL = 'https://backend-observa-production.up.railway.app/v1';
|
|
6
|
-
export class ObservaSDK {
|
|
7
|
-
uptime;
|
|
8
|
-
ingest;
|
|
9
|
-
http;
|
|
10
|
-
constructor(options) {
|
|
11
|
-
if (!options || !options.apiKey || !options.dsnKey) {
|
|
12
|
-
throw new Error('ObservaSDK requires both apiKey and dsnKey');
|
|
13
|
-
}
|
|
14
|
-
const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
15
|
-
const normalizedBaseUrl = baseUrl.endsWith('/v1') ? baseUrl : `${baseUrl}/v1`;
|
|
16
|
-
this.http = new HttpClient({
|
|
17
|
-
baseUrl: normalizedBaseUrl,
|
|
18
|
-
apiKey: options.apiKey,
|
|
19
|
-
timeoutMs: options.timeoutMs,
|
|
20
|
-
retry: options.retry,
|
|
21
|
-
headers: options.headers,
|
|
22
|
-
});
|
|
23
|
-
this.ingest = new IngestApi(this.http, options.dsnKey, options.ingest);
|
|
24
|
-
this.uptime = new UptimeApi(this.http, options.dsnKey);
|
|
25
|
-
this.http.startHealthCheck(() => this.ingest.health(options.dsnKey));
|
|
26
|
-
}
|
|
27
|
-
setApiKey(apiKey) {
|
|
28
|
-
this.http.setApiKey(apiKey);
|
|
29
|
-
}
|
|
30
|
-
getProcessContext(options) {
|
|
31
|
-
return getProcessContext(options);
|
|
32
|
-
}
|
|
33
|
-
getProcessContextStatic(options) {
|
|
34
|
-
return getProcessContextStatic(options);
|
|
35
|
-
}
|
|
36
|
-
getProcessContextDynamic(options) {
|
|
37
|
-
return getProcessContextDynamic(options);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=sdk.js.map
|
package/dist/src/sdk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmC,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAA;AAChE,OAAO,EACH,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,GAO1B,MAAM,wBAAwB,CAAA;AAiC/B,MAAM,gBAAgB,GAAG,sDAAsD,CAAA;AAK/E,MAAM,OAAO,UAAU;IAIV,MAAM,CAAW;IAIjB,MAAM,CAAW;IAET,IAAI,CAAY;IAKjC,YAAY,OAA0B;QAClC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;QACjE,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACzE,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,CAAA;QAC7E,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC;YACvB,OAAO,EAAE,iBAAiB;YAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;SAC3B,CAAC,CAAA;QACF,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACtE,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACtD,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACxE,CAAC;IAKD,SAAS,CAAC,MAAc;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,iBAAiB,CAAC,OAA+B;QAC7C,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IAED,uBAAuB,CAAC,OAAqC;QACzD,OAAO,uBAAuB,CAAC,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED,wBAAwB,CAAC,OAAsC;QAC3D,OAAO,wBAAwB,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;CACJ"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type ProcessContextStatic = {
|
|
2
|
-
versions?: NodeJS.ProcessVersions;
|
|
3
|
-
node?: string;
|
|
4
|
-
platform?: NodeJS.Platform;
|
|
5
|
-
arch?: string;
|
|
6
|
-
releaseName?: string;
|
|
7
|
-
};
|
|
8
|
-
export type ProcessContextDynamic = {
|
|
9
|
-
pid?: number;
|
|
10
|
-
uptimeSeconds?: number;
|
|
11
|
-
memory?: NodeJS.MemoryUsage;
|
|
12
|
-
};
|
|
13
|
-
export type ProcessContext = ProcessContextStatic & ProcessContextDynamic;
|
|
14
|
-
export type ProcessContextOptions = {
|
|
15
|
-
includeStatic?: boolean;
|
|
16
|
-
includeDynamic?: boolean;
|
|
17
|
-
includeVersions?: boolean;
|
|
18
|
-
includeRuntime?: boolean;
|
|
19
|
-
includePid?: boolean;
|
|
20
|
-
includeUptime?: boolean;
|
|
21
|
-
includeMemory?: boolean;
|
|
22
|
-
};
|
|
23
|
-
export type ProcessContextStaticOptions = {
|
|
24
|
-
includeVersions?: boolean;
|
|
25
|
-
includeRuntime?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export type ProcessContextDynamicOptions = {
|
|
28
|
-
includePid?: boolean;
|
|
29
|
-
includeUptime?: boolean;
|
|
30
|
-
includeMemory?: boolean;
|
|
31
|
-
};
|
|
32
|
-
export declare function getProcessContext(options?: ProcessContextOptions): ProcessContext;
|
|
33
|
-
export declare function getProcessContextStatic(options?: ProcessContextStaticOptions): ProcessContextStatic;
|
|
34
|
-
export declare function getProcessContextDynamic(options?: ProcessContextDynamicOptions): ProcessContextDynamic;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export function getProcessContext(options) {
|
|
2
|
-
const includeStatic = options?.includeStatic ?? true;
|
|
3
|
-
const includeDynamic = options?.includeDynamic ?? true;
|
|
4
|
-
const includeVersions = options?.includeVersions ?? true;
|
|
5
|
-
const includeRuntime = options?.includeRuntime ?? true;
|
|
6
|
-
const includePid = options?.includePid ?? true;
|
|
7
|
-
const includeUptime = options?.includeUptime ?? true;
|
|
8
|
-
const includeMemory = options?.includeMemory ?? true;
|
|
9
|
-
const context = {};
|
|
10
|
-
if (includeDynamic) {
|
|
11
|
-
if (includePid)
|
|
12
|
-
context.pid = process.pid;
|
|
13
|
-
if (includeUptime)
|
|
14
|
-
context.uptimeSeconds = Math.round(process.uptime());
|
|
15
|
-
if (includeMemory)
|
|
16
|
-
context.memory = process.memoryUsage();
|
|
17
|
-
}
|
|
18
|
-
if (includeStatic) {
|
|
19
|
-
if (includeVersions)
|
|
20
|
-
context.versions = process.versions;
|
|
21
|
-
if (includeRuntime) {
|
|
22
|
-
context.node = process.versions.node;
|
|
23
|
-
context.platform = process.platform;
|
|
24
|
-
context.arch = process.arch;
|
|
25
|
-
context.releaseName = process.release?.name;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return context;
|
|
29
|
-
}
|
|
30
|
-
export function getProcessContextStatic(options) {
|
|
31
|
-
return getProcessContext({
|
|
32
|
-
includeDynamic: false,
|
|
33
|
-
includeStatic: true,
|
|
34
|
-
includeVersions: options?.includeVersions,
|
|
35
|
-
includeRuntime: options?.includeRuntime,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export function getProcessContextDynamic(options) {
|
|
39
|
-
return getProcessContext({
|
|
40
|
-
includeStatic: false,
|
|
41
|
-
includeDynamic: true,
|
|
42
|
-
includePid: options?.includePid,
|
|
43
|
-
includeUptime: options?.includeUptime,
|
|
44
|
-
includeMemory: options?.includeMemory,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=processContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processContext.js","sourceRoot":"","sources":["../../../src/utils/processContext.ts"],"names":[],"mappings":"AAqCA,MAAM,UAAU,iBAAiB,CAAC,OAA+B;IAC7D,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,IAAI,CAAA;IACpD,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,IAAI,CAAA;IACtD,MAAM,eAAe,GAAG,OAAO,EAAE,eAAe,IAAI,IAAI,CAAA;IACxD,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,IAAI,CAAA;IACtD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,IAAI,CAAA;IAC9C,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,IAAI,CAAA;IACpD,M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;QACrC,aAAa,EAAE,OAAO,EAAE,aAAa;KACxC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ValidationError } from '../http/errors.js';
|
|
2
|
-
export function ensureNonEmpty(value, name) {
|
|
3
|
-
if (!value || value.trim().length === 0) {
|
|
4
|
-
throw new ValidationError(`${name} is required`);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export function ensureDefined(value, name) {
|
|
8
|
-
if (value === null || value === undefined) {
|
|
9
|
-
throw new ValidationError(`${name} is required`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/utils/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAKhD,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,IAAY;IACtD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,eAAe,CAAC,GAAG,IAAI,cAAc,CAAC,CAAA;IACpD,CAAC;AACL,CAAC;AAKD,MAAM,UAAU,aAAa,CAAI,KAA2B,EAAE,IAAY;IACtE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,IAAI,eAAe,CAAC,GAAG,IAAI,cAAc,CAAC,CAAA;IACpD,CAAC;AACL,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
import { HttpClient } from '../src/http/httpClient.js';
|
|
3
|
-
import { AuthError } from '../src/http/errors.js';
|
|
4
|
-
describe('HttpClient', () => {
|
|
5
|
-
const originalFetch = global.fetch;
|
|
6
|
-
afterEach(() => {
|
|
7
|
-
global.fetch = originalFetch;
|
|
8
|
-
jest.resetAllMocks();
|
|
9
|
-
});
|
|
10
|
-
test('adjunta x-api-key cuando auth es apiKey', async () => {
|
|
11
|
-
const fetchMock = jest.fn().mockImplementation(async () => ({
|
|
12
|
-
ok: true,
|
|
13
|
-
status: 200,
|
|
14
|
-
text: async () => JSON.stringify({ ok: true }),
|
|
15
|
-
}));
|
|
16
|
-
global.fetch = fetchMock;
|
|
17
|
-
const client = new HttpClient({ baseUrl: 'http://localhost', apiKey: 'key123' });
|
|
18
|
-
await client.get('/ping', { auth: 'apiKey' });
|
|
19
|
-
const [, options] = global.fetch.mock.calls[0];
|
|
20
|
-
expect(options.headers['x-api-key']).toBe('key123');
|
|
21
|
-
});
|
|
22
|
-
test('mapea 401 a AuthError', async () => {
|
|
23
|
-
const fetchMock = jest.fn().mockImplementation(async () => ({
|
|
24
|
-
ok: false,
|
|
25
|
-
status: 401,
|
|
26
|
-
headers: { get: () => null },
|
|
27
|
-
text: async () => JSON.stringify({ message: 'unauthorized' }),
|
|
28
|
-
}));
|
|
29
|
-
global.fetch = fetchMock;
|
|
30
|
-
const client = new HttpClient({ baseUrl: 'http://localhost', apiKey: 'key123' });
|
|
31
|
-
await expect(client.get('/private', { auth: 'apiKey' })).rejects.toBeInstanceOf(AuthError);
|
|
32
|
-
});
|
|
33
|
-
test('agrega content-type y construye url con baseUrl', async () => {
|
|
34
|
-
const fetchMock = jest.fn().mockImplementation(async () => ({
|
|
35
|
-
ok: true,
|
|
36
|
-
status: 200,
|
|
37
|
-
text: async () => JSON.stringify({ ok: true }),
|
|
38
|
-
}));
|
|
39
|
-
global.fetch = fetchMock;
|
|
40
|
-
const client = new HttpClient({ baseUrl: 'http://localhost/api', apiKey: 'key123' });
|
|
41
|
-
await client.post('ingest/events', { dsnKey: 'dsn_1', event: { level: 'error' } }, { auth: 'apiKey' });
|
|
42
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
43
|
-
expect(url).toBe('http://localhost/api/ingest/events');
|
|
44
|
-
expect(options.headers['content-type']).toBe('application/json');
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=httpClient.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpClient.test.js","sourceRoot":"","sources":["../../tests/httpClient.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IACxB,MAAM,aAAa,GAAG,MAAM,CAAC,KAAY,CAAA;IAEzC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,CAAC,KAAK,GAAG,aAAa,CAAA;QAC5B,IAAI,CAAC,aAAa,EAAE,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,SAAS,GAAI,IAAI,CAAC,EAAE,EAAU,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACjE,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;SACjD,CAAC,CAAC,CAAA;QACH,MAAM,CAAC,KAAK,GAAG,SAAgB,CAAA;QAC/B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QAChF,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;QAC7C,MAAM,CAAC,EAAE,OAAO,CAAC,GAAI,MAAM,CAAC,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AC,KAAK,GAAG,SAAgB,CAAA;QAC/B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QACpF,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;QACtG,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAI,MAAM,CAAC,KAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;QACtD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
import { IngestApi } from '../src/apis/ingestApi.js';
|
|
3
|
-
import { HttpClient } from '../src/http/httpClient.js';
|
|
4
|
-
import { ValidationError } from '../src/http/errors.js';
|
|
5
|
-
describe('IngestApi', () => {
|
|
6
|
-
const originalFetch = global.fetch;
|
|
7
|
-
afterEach(() => {
|
|
8
|
-
global.fetch = originalFetch;
|
|
9
|
-
jest.resetAllMocks();
|
|
10
|
-
});
|
|
11
|
-
test('envía headers opcionales y dsnKey por defecto', async () => {
|
|
12
|
-
const fetchMock = jest.fn().mockImplementation(async () => ({
|
|
13
|
-
ok: true,
|
|
14
|
-
status: 200,
|
|
15
|
-
text: async () => JSON.stringify({ event_id: 'evt_10' }),
|
|
16
|
-
}));
|
|
17
|
-
global.fetch = fetchMock;
|
|
18
|
-
const client = new HttpClient({ baseUrl: 'http://localhost', apiKey: 'key_1' });
|
|
19
|
-
const api = new IngestApi(client, 'dsn_1');
|
|
20
|
-
await api.event({
|
|
21
|
-
event: {
|
|
22
|
-
level: 'error',
|
|
23
|
-
message: 'boom',
|
|
24
|
-
},
|
|
25
|
-
idempotencyKey: 'req_10',
|
|
26
|
-
sdkVersion: '2.0.0',
|
|
27
|
-
});
|
|
28
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
29
|
-
expect(url).toBe('http://localhost/ingest/events');
|
|
30
|
-
expect(options.headers['x-idempotency-key']).toBe('req_10');
|
|
31
|
-
expect(options.headers['x-sdk-version']).toBe('2.0.0');
|
|
32
|
-
const body = JSON.parse(options.body);
|
|
33
|
-
expect(body.dsnKey).toBe('dsn_1');
|
|
34
|
-
expect(body.event.schema_version).toBe(1);
|
|
35
|
-
expect(body.event.event_id).toBeDefined();
|
|
36
|
-
expect(new Date(body.event.timestamp).toString()).not.toBe('Invalid Date');
|
|
37
|
-
expect(body.event.context.system.pid).toBe(process.pid);
|
|
38
|
-
expect(body.event.context.runtime.arch).toBe(process.arch);
|
|
39
|
-
});
|
|
40
|
-
test('valida tamaño de idempotencyKey', async () => {
|
|
41
|
-
const client = new HttpClient({ baseUrl: 'http://localhost', apiKey: 'key_1' });
|
|
42
|
-
const api = new IngestApi(client, 'dsn_1');
|
|
43
|
-
await expect(api.event({
|
|
44
|
-
event: { level: 'error', message: 'boom' },
|
|
45
|
-
idempotencyKey: 'a'.repeat(129),
|
|
46
|
-
})).rejects.toBeInstanceOf(ValidationError);
|
|
47
|
-
});
|
|
48
|
-
test('health usa POST /ingest/health con dsnKey', async () => {
|
|
49
|
-
const fetchMock = jest.fn().mockImplementation(async () => ({
|
|
50
|
-
ok: true,
|
|
51
|
-
status: 200,
|
|
52
|
-
text: async () => JSON.stringify({ ok: true }),
|
|
53
|
-
}));
|
|
54
|
-
global.fetch = fetchMock;
|
|
55
|
-
const client = new HttpClient({ baseUrl: 'http://localhost', apiKey: 'key_1' });
|
|
56
|
-
const api = new IngestApi(client, 'dsn_1');
|
|
57
|
-
const result = await api.health();
|
|
58
|
-
expect(result.ok).toBe(true);
|
|
59
|
-
const [url, options] = global.fetch.mock.calls[0];
|
|
60
|
-
expect(url).toBe('http://localhost/ingest/health');
|
|
61
|
-
expect(options.method).toBe('POST');
|
|
62
|
-
expect(JSON.parse(options.body).dsnKey).toBe('dsn_1');
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=ingestApi.test.js.map
|