@apowerb/apowerb-sdk 0.0.1 → 0.0.2

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.
Files changed (2) hide show
  1. package/README.md +20 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # @apowerb/apowerb-sdk
2
2
 
3
- Client JavaScript du backend th2agent : agents, outils, RAG, BI, webhooks, facturation, skills. **139 fonctions**, aucune dépendance, aucun code React ni Next — utilisable dans un navigateur comme dans Node.
3
+ JavaScript client for the apowerb backend: agents, tools, RAG, BI, webhooks, billing, skills. **143 functions**, no dependencies, no React and no Next code usable in a browser as well as in Node.
4
4
 
5
- ## Pourquoi ce paquet
5
+ ## Why this package
6
6
 
7
- Cette couche vivait dans `src/lib/api.js` de l'application Next, avec `const BASE = ""` codé en dur : toutes les requêtes partaient en relatif vers `/api/...`, ce qui suppose d'être servi par l'app qui proxie ces routes. La partie la plus réutilisable du dépôt était donc prisonnière du front.
7
+ This layer used to live in `src/lib/api.js` inside the Next application, with `const BASE = ""` hard-coded: every request went out relative to `/api/...`, which assumes being served by the app that proxies those routes. The most reusable part of the repository was therefore trapped inside the front end.
8
8
 
9
9
  ## Usage
10
10
 
11
- Sans configuration, le comportement est celui d'originerequêtes relatives, jeton lu dans `localStorage` — donc l'application Next ne change pas d'un octet :
11
+ With no configuration the behaviour is the original one relative requests, token read from `localStorage` — so the Next application does not change by a single byte:
12
12
 
13
13
  ```js
14
14
  import { listAgents } from "@apowerb/apowerb-sdk";
@@ -16,38 +16,38 @@ import { listAgents } from "@apowerb/apowerb-sdk";
16
16
  const agents = await listAgents(); // GET /api/agents
17
17
  ```
18
18
 
19
- Ailleurs, on pointe le backend de son choix :
19
+ Anywhere else, point it at the backend of your choice:
20
20
 
21
21
  ```js
22
22
  import { configureClient, listAgents } from "@apowerb/apowerb-sdk";
23
23
 
24
24
  configureClient({
25
- baseUrl: "https://agent.thaink2.com",
26
- storage: { getToken: () => process.env.TH2AGENT_TOKEN },
25
+ baseUrl: "https://your-apowerb-host",
26
+ storage: { getToken: () => process.env.APOWERB_TOKEN },
27
27
  });
28
28
 
29
- const agents = await listAgents(); // GET https://agent.thaink2.com/api/agents
29
+ const agents = await listAgents(); // GET https://your-apowerb-host/api/agents
30
30
  ```
31
31
 
32
32
  ## Configuration
33
33
 
34
- `configureClient(options)` — les clés omises gardent leur valeur courante.
34
+ `configureClient(options)` — omitted keys keep their current value.
35
35
 
36
- | Option | Défaut | Rôle |
36
+ | Option | Default | Role |
37
37
  |---|---|---|
38
- | `baseUrl` | `""` | Racine du backend. Vide = requêtes relatives. Un slash final est toléré. |
39
- | `storage` | `authStorage` (localStorage) | Doit exposer `getToken()`, idéalement `setToken()` et `clear()`. |
40
- | `onUnauthorized` | évènement `auth:unauthorized` sur `window` | Appelé sur un 401 définitif. Sans DOM, ne fait rien. |
38
+ | `baseUrl` | `""` | Backend root. Empty means relative requests. A trailing slash is tolerated. |
39
+ | `storage` | `authStorage` (localStorage) | Must expose `getToken()`, ideally `setToken()` and `clear()`. |
40
+ | `onUnauthorized` | `auth:unauthorized` event on `window` | Called on a final 401. With no DOM, it does nothing. |
41
41
 
42
- `getClientConfig()` retourne la configuration courante, `resetClientConfig()` rétablit les défauts (utile entre deux tests).
42
+ `getClientConfig()` returns the current configuration; `resetClientConfig()` restores the defaults, which is useful between tests.
43
43
 
44
- ## Ce que le client gère pour vous
44
+ ## What the client handles for you
45
45
 
46
- - injection de l'en-tête `Authorization` ;
47
- - rafraîchissement du jeton sur 401, avec verrou pour éviter les rafraîchissements concurrents, puis rejeu de la requête ;
48
- - réponses non-JSON des reverse proxies (502/503/504) converties en `Error` propres portant `status` ;
49
- - upload de fichiers, y compris en morceaux.
46
+ - injecting the `Authorization` header;
47
+ - refreshing the token on a 401, with a lock so concurrent refreshes cannot pile up, then replaying the request;
48
+ - non-JSON responses from reverse proxies (502/503/504), turned into clean `Error` objects carrying `status`;
49
+ - file uploads, including chunked ones.
50
50
 
51
51
  ## Format
52
52
 
53
- ESM pur, publié tel quel pas d'étape de build. Les fichiers ne contiennent ni JSX ni syntaxe propriétaire, donc Node comme n'importe quel bundler les consomment directement.
53
+ Pure ESM, published as-isno build step. The files contain neither JSX nor any proprietary syntax, so Node and any bundler consume them directly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apowerb/apowerb-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "JavaScript SDK for the apowerb backend: agents, tools, RAG, BI, webhooks and billing. Dependency-free, runs in the browser and in Node.",
5
5
  "license": "MIT",
6
6
  "repository": {