@apowerb/apowerb-sdk 0.0.0 → 0.0.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/LICENSE +21 -21
- package/README.md +53 -53
- package/package.json +44 -44
- package/src/api.js +830 -830
- package/src/authStorage.js +770 -770
- package/src/config.js +86 -86
- package/src/index.js +26 -26
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 apowerb
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 apowerb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
# @apowerb/apowerb-sdk
|
|
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.
|
|
4
|
-
|
|
5
|
-
## Pourquoi ce paquet
|
|
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.
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
Sans configuration, le comportement est celui d'origine — requêtes relatives, jeton lu dans `localStorage` — donc l'application Next ne change pas d'un octet :
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
import { listAgents } from "@apowerb/apowerb-sdk";
|
|
15
|
-
|
|
16
|
-
const agents = await listAgents(); // GET /api/agents
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Ailleurs, on pointe le backend de son choix :
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
import { configureClient, listAgents } from "@apowerb/apowerb-sdk";
|
|
23
|
-
|
|
24
|
-
configureClient({
|
|
25
|
-
baseUrl: "https://agent.thaink2.com",
|
|
26
|
-
storage: { getToken: () => process.env.TH2AGENT_TOKEN },
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const agents = await listAgents(); // GET https://agent.thaink2.com/api/agents
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Configuration
|
|
33
|
-
|
|
34
|
-
`configureClient(options)` — les clés omises gardent leur valeur courante.
|
|
35
|
-
|
|
36
|
-
| Option | Défaut | Rôle |
|
|
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. |
|
|
41
|
-
|
|
42
|
-
`getClientConfig()` retourne la configuration courante, `resetClientConfig()` rétablit les défauts (utile entre deux tests).
|
|
43
|
-
|
|
44
|
-
## Ce que le client gère pour vous
|
|
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.
|
|
50
|
-
|
|
51
|
-
## Format
|
|
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.
|
|
1
|
+
# @apowerb/apowerb-sdk
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Pourquoi ce paquet
|
|
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.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Sans configuration, le comportement est celui d'origine — requêtes relatives, jeton lu dans `localStorage` — donc l'application Next ne change pas d'un octet :
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { listAgents } from "@apowerb/apowerb-sdk";
|
|
15
|
+
|
|
16
|
+
const agents = await listAgents(); // GET /api/agents
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Ailleurs, on pointe le backend de son choix :
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { configureClient, listAgents } from "@apowerb/apowerb-sdk";
|
|
23
|
+
|
|
24
|
+
configureClient({
|
|
25
|
+
baseUrl: "https://agent.thaink2.com",
|
|
26
|
+
storage: { getToken: () => process.env.TH2AGENT_TOKEN },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const agents = await listAgents(); // GET https://agent.thaink2.com/api/agents
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
`configureClient(options)` — les clés omises gardent leur valeur courante.
|
|
35
|
+
|
|
36
|
+
| Option | Défaut | Rôle |
|
|
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. |
|
|
41
|
+
|
|
42
|
+
`getClientConfig()` retourne la configuration courante, `resetClientConfig()` rétablit les défauts (utile entre deux tests).
|
|
43
|
+
|
|
44
|
+
## Ce que le client gère pour vous
|
|
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.
|
|
50
|
+
|
|
51
|
+
## Format
|
|
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.
|
package/package.json
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@apowerb/apowerb-sdk",
|
|
3
|
-
"version": "0.0.
|
|
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
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/apowerb/apowerb-ui.git",
|
|
9
|
-
"directory": "packages/apowerb-sdk"
|
|
10
|
-
},
|
|
11
|
-
"homepage": "https://github.com/apowerb/apowerb-ui/tree/main/packages/apowerb-sdk#readme",
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/apowerb/apowerb-ui/issues"
|
|
14
|
-
},
|
|
15
|
-
"type": "module",
|
|
16
|
-
"main": "./src/index.js",
|
|
17
|
-
"module": "./src/index.js",
|
|
18
|
-
"exports": {
|
|
19
|
-
".": "./src/index.js",
|
|
20
|
-
"./config": "./src/config.js",
|
|
21
|
-
"./authStorage": "./src/authStorage.js"
|
|
22
|
-
},
|
|
23
|
-
"files": [
|
|
24
|
-
"src",
|
|
25
|
-
"!src/__tests__",
|
|
26
|
-
"README.md",
|
|
27
|
-
"LICENSE"
|
|
28
|
-
],
|
|
29
|
-
"keywords": [
|
|
30
|
-
"apowerb",
|
|
31
|
-
"thaink2",
|
|
32
|
-
"sdk",
|
|
33
|
-
"api",
|
|
34
|
-
"agents",
|
|
35
|
-
"rag"
|
|
36
|
-
],
|
|
37
|
-
"sideEffects": false,
|
|
38
|
-
"engines": {
|
|
39
|
-
"node": ">=18"
|
|
40
|
-
},
|
|
41
|
-
"publishConfig": {
|
|
42
|
-
"access": "public"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@apowerb/apowerb-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
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
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/apowerb/apowerb-ui.git",
|
|
9
|
+
"directory": "packages/apowerb-sdk"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/apowerb/apowerb-ui/tree/main/packages/apowerb-sdk#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/apowerb/apowerb-ui/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./src/index.js",
|
|
17
|
+
"module": "./src/index.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./src/index.js",
|
|
20
|
+
"./config": "./src/config.js",
|
|
21
|
+
"./authStorage": "./src/authStorage.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"!src/__tests__",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"apowerb",
|
|
31
|
+
"thaink2",
|
|
32
|
+
"sdk",
|
|
33
|
+
"api",
|
|
34
|
+
"agents",
|
|
35
|
+
"rag"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|