@bereasoftware/nexa 1.6.0 → 1.8.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.
- package/README.en.md +32 -0
- package/README.md +35 -2
- package/dist/bereasoftware-nexa-1.8.0.tgz +0 -0
- package/dist/nexa.cjs.js +163 -163
- package/dist/nexa.cjs.js.map +1 -1
- package/dist/nexa.es.js +479 -365
- package/dist/nexa.es.js.map +1 -1
- package/dist/nexa.iife.js +163 -163
- package/dist/nexa.iife.js.map +1 -1
- package/dist/nexa.umd.js +163 -163
- package/dist/nexa.umd.js.map +1 -1
- package/dist/types/dev-overlay/env.d.ts +1 -0
- package/dist/types/dev-overlay/format.d.ts +3 -0
- package/dist/types/dev-overlay/overlay.d.ts +1 -2
- package/dist/types/dev-overlay/render.d.ts +6 -0
- package/dist/types/dev-overlay/theme.d.ts +40 -0
- package/dist/types/dev-overlay/tracker.d.ts +7 -1
- package/dist/types/http-client/http-client.d.ts +7 -0
- package/dist/types/http-client/index.d.ts +1 -1
- package/dist/types/realtime/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +31 -6
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +16 -16
- package/dist/bereasoftware-nexa-1.6.0.tgz +0 -0
package/README.en.md
CHANGED
|
@@ -266,6 +266,13 @@ const result = await client.head("/users/1");
|
|
|
266
266
|
|
|
267
267
|
// OPTIONS (CORS preflight, available methods)
|
|
268
268
|
const result = await client.options("/users");
|
|
269
|
+
|
|
270
|
+
// QUERY (IETF-draft method: safe, idempotent, JSON body)
|
|
271
|
+
// Ideal for complex search/filter payloads that don't fit in a URL.
|
|
272
|
+
const result = await client.query<User[]>("/users/search", {
|
|
273
|
+
filters: { role: "admin", active: true },
|
|
274
|
+
sort: ["-createdAt"],
|
|
275
|
+
});
|
|
269
276
|
```
|
|
270
277
|
|
|
271
278
|
All methods accept an optional config object as the last parameter:
|
|
@@ -303,6 +310,31 @@ const result = await client.get<User[]>("/users", {
|
|
|
303
310
|
// → GET /users?page=1&limit=20&active=true
|
|
304
311
|
```
|
|
305
312
|
|
|
313
|
+
Arrays are serialized as repeated keys, and one level of nested objects uses bracket notation. `null`/`undefined` values are omitted:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
await client.get("/users", {
|
|
317
|
+
query: {
|
|
318
|
+
tag: ["admin", "vip"], // → tag=admin&tag=vip
|
|
319
|
+
filter: { status: "active" }, // → filter[status]=active
|
|
320
|
+
sort: undefined, // omitted
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### QUERY method: complex searches with a body
|
|
326
|
+
|
|
327
|
+
The `QUERY` HTTP method (IETF draft) is safe and idempotent like `GET`, but allows sending a JSON body — useful for complex filters that would exceed a URL's practical length. Nexa caches it the same way as `GET` when `cache.enabled` is set (the body is part of the cache key):
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
const result = await client.query("/users/search", {
|
|
331
|
+
filters: { role: "admin" },
|
|
332
|
+
sort: ["-createdAt"],
|
|
333
|
+
}, {
|
|
334
|
+
cache: { enabled: true, ttlMs: 30000 },
|
|
335
|
+
});
|
|
336
|
+
```
|
|
337
|
+
|
|
306
338
|
### Auto Body Serialization
|
|
307
339
|
|
|
308
340
|
Nexa automatically detects and serializes the request body:
|
package/README.md
CHANGED
|
@@ -280,6 +280,13 @@ const result = await client.head("/users/1");
|
|
|
280
280
|
|
|
281
281
|
// OPTIONS (preflight CORS, métodos disponibles)
|
|
282
282
|
const result = await client.options("/users");
|
|
283
|
+
|
|
284
|
+
// QUERY (método IETF-draft: seguro, idempotente, con body JSON)
|
|
285
|
+
// Ideal para búsquedas/filtros complejos que no entran en una URL.
|
|
286
|
+
const result = await client.query<User[]>("/users/search", {
|
|
287
|
+
filters: { role: "admin", active: true },
|
|
288
|
+
sort: ["-createdAt"],
|
|
289
|
+
});
|
|
283
290
|
```
|
|
284
291
|
|
|
285
292
|
Todos los métodos aceptan un objeto de configuración opcional como último parámetro:
|
|
@@ -317,6 +324,31 @@ const result = await client.get<User[]>("/users", {
|
|
|
317
324
|
// → GET /users?page=1&limit=20&active=true
|
|
318
325
|
```
|
|
319
326
|
|
|
327
|
+
Los arrays se serializan como claves repetidas, y un nivel de objetos anidados usa notación de corchetes. Los valores `null`/`undefined` se omiten:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
await client.get("/users", {
|
|
331
|
+
query: {
|
|
332
|
+
tag: ["admin", "vip"], // → tag=admin&tag=vip
|
|
333
|
+
filter: { status: "active" }, // → filter[status]=active
|
|
334
|
+
sort: undefined, // se omite
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Método QUERY: búsquedas complejas con body
|
|
340
|
+
|
|
341
|
+
El método HTTP `QUERY` (propuesta IETF) es seguro e idempotente como `GET`, pero permite enviar un body JSON — útil para filtros complejos que excederían el largo práctico de una URL. Nexa lo cachea igual que `GET` cuando `cache.enabled` está activo (el body forma parte de la clave de caché):
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
const result = await client.query("/users/search", {
|
|
345
|
+
filters: { role: "admin" },
|
|
346
|
+
sort: ["-createdAt"],
|
|
347
|
+
}, {
|
|
348
|
+
cache: { enabled: true, ttlMs: 30000 },
|
|
349
|
+
});
|
|
350
|
+
```
|
|
351
|
+
|
|
320
352
|
### Serialización Automática del Body
|
|
321
353
|
|
|
322
354
|
Nexa detecta y serializa automáticamente el cuerpo de la petición:
|
|
@@ -1164,7 +1196,8 @@ const wsClient = createWebSocketClient("wss://echo.websocket.org", {
|
|
|
1164
1196
|
});
|
|
1165
1197
|
|
|
1166
1198
|
await wsClient.connect();
|
|
1167
|
-
wsClient.sendJson({ type: "message", data: "Hello" });
|
|
1199
|
+
const result = wsClient.sendJson({ type: "message", data: "Hello" });
|
|
1200
|
+
if (!result.ok) console.error("No se pudo enviar:", result.error.message);
|
|
1168
1201
|
wsClient.onMessage((event) => console.log("Mensaje:", event.data));
|
|
1169
1202
|
|
|
1170
1203
|
// SSE para streams de eventos
|
|
@@ -1810,7 +1843,7 @@ Ver la carpeta `examples/` para ejemplos de uso con diferentes frameworks:
|
|
|
1810
1843
|
|
|
1811
1844
|
**HTTP Client** (`test/http-client.test.ts`) — **88 tests**:
|
|
1812
1845
|
|
|
1813
|
-
- ✓ Métodos core: create, GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS (
|
|
1846
|
+
- ✓ Métodos core: create, GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS/QUERY (8 tests)
|
|
1814
1847
|
- ✓ Estrategias de reintentos & timeouts (3 tests)
|
|
1815
1848
|
- ✓ Interceptores & disposal (5 tests)
|
|
1816
1849
|
- ✓ Caché & validación (4 tests)
|
|
Binary file
|