@b10cks/mgmt-client 0.1.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/LICENSE +21 -0
- package/README.md +482 -0
- package/dist/index.d.ts +518 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +424 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present – Coder's Cantina e.U.
|
|
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
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
# @b10cks/mgmt-client
|
|
2
|
+
|
|
3
|
+
Management API client for b10cks - A TypeScript client for managing your b10cks resources.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @b10cks/mgmt-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @b10cks/mgmt-client
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @b10cks/mgmt-client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { ManagementClient } from '@b10cks/mgmt-client'
|
|
23
|
+
|
|
24
|
+
const client = new ManagementClient({
|
|
25
|
+
baseUrl: 'https://api.b10cks.com',
|
|
26
|
+
token: 'your-bearer-token',
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const user = await client.users.getMe()
|
|
30
|
+
console.log(user)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
The client accepts the following configuration options:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
interface ClientConfig {
|
|
39
|
+
baseUrl: string // Base URL of the b10cks API
|
|
40
|
+
token: string // Bearer token for authentication
|
|
41
|
+
timeout?: number // Request timeout in milliseconds (default: 30000)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API Resources
|
|
46
|
+
|
|
47
|
+
### Users
|
|
48
|
+
|
|
49
|
+
Manage user account information.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Get current user
|
|
53
|
+
const user = await client.users.getMe()
|
|
54
|
+
|
|
55
|
+
// Update current user
|
|
56
|
+
await client.users.updateMe({
|
|
57
|
+
firstname: 'John',
|
|
58
|
+
lastname: 'Doe',
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// Update user avatar
|
|
62
|
+
await client.users.updateAvatar({
|
|
63
|
+
avatar: 'base64-encoded-image',
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// Update password
|
|
67
|
+
await client.users.updatePassword({
|
|
68
|
+
old_password: 'current-password',
|
|
69
|
+
password: 'new-password',
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
// Update user settings
|
|
73
|
+
await client.users.updateSettings()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Teams
|
|
77
|
+
|
|
78
|
+
Manage teams and team hierarchies.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// List all teams
|
|
82
|
+
const teams = await client.teams.list()
|
|
83
|
+
|
|
84
|
+
// Create a team
|
|
85
|
+
const team = await client.teams.create({
|
|
86
|
+
name: 'Marketing Team',
|
|
87
|
+
color: '#FF5733',
|
|
88
|
+
description: 'Our marketing team',
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Get a specific team
|
|
92
|
+
const team = await client.teams.get('team-id')
|
|
93
|
+
|
|
94
|
+
// Update a team
|
|
95
|
+
await client.teams.update('team-id', {
|
|
96
|
+
name: 'Updated Team Name',
|
|
97
|
+
color: '#00FF00',
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
// Delete a team
|
|
101
|
+
await client.teams.delete('team-id')
|
|
102
|
+
|
|
103
|
+
// Get team hierarchy
|
|
104
|
+
const hierarchy = await client.teams.getHierarchy()
|
|
105
|
+
|
|
106
|
+
// Manage team users
|
|
107
|
+
await client.teams.addUser('team-id')
|
|
108
|
+
await client.teams.updateUser('team-id', 'user-id')
|
|
109
|
+
await client.teams.removeUser('team-id', 'user-id')
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Spaces
|
|
113
|
+
|
|
114
|
+
Manage spaces within your organization.
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Create a space
|
|
118
|
+
const space = await client.spaces.create({
|
|
119
|
+
name: 'My Space',
|
|
120
|
+
slug: 'my-space',
|
|
121
|
+
color: '#4A90E2',
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// Get a space
|
|
125
|
+
const space = await client.spaces.get('space-id')
|
|
126
|
+
|
|
127
|
+
// Update a space
|
|
128
|
+
await client.spaces.update('space-id', {
|
|
129
|
+
name: 'Updated Space',
|
|
130
|
+
slug: 'updated-space',
|
|
131
|
+
state: 'active',
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
// Delete a space
|
|
135
|
+
await client.spaces.delete('space-id')
|
|
136
|
+
|
|
137
|
+
// Update space icon
|
|
138
|
+
await client.spaces.updateIcon('space-id', {
|
|
139
|
+
icon: 'base64-encoded-icon',
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
// Archive a space
|
|
143
|
+
await client.spaces.archive('space-id')
|
|
144
|
+
|
|
145
|
+
// Get space statistics
|
|
146
|
+
const stats = await client.spaces.getStats('space-id')
|
|
147
|
+
|
|
148
|
+
// Get AI usage for a space
|
|
149
|
+
const aiUsage = await client.spaces.getAiUsage('space-id')
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Blocks
|
|
153
|
+
|
|
154
|
+
Manage content blocks within spaces.
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// List blocks in a space
|
|
158
|
+
const blocks = await client.blocks.list('space-id', {
|
|
159
|
+
page: 1,
|
|
160
|
+
per_page: 20,
|
|
161
|
+
search: 'blog',
|
|
162
|
+
type: 'article',
|
|
163
|
+
sort: '-created_at',
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
// Create a block
|
|
167
|
+
const block = await client.blocks.create('space-id')
|
|
168
|
+
|
|
169
|
+
// Get a block
|
|
170
|
+
const block = await client.blocks.get('space-id', 'block-id')
|
|
171
|
+
|
|
172
|
+
// Update a block
|
|
173
|
+
await client.blocks.update('space-id', 'block-id')
|
|
174
|
+
|
|
175
|
+
// Delete a block
|
|
176
|
+
await client.blocks.delete('space-id', 'block-id')
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Block Tags
|
|
180
|
+
|
|
181
|
+
Organize blocks with tags.
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// List block tags
|
|
185
|
+
const tags = await client.blockTags.list('space-id')
|
|
186
|
+
|
|
187
|
+
// Create a tag
|
|
188
|
+
const tag = await client.blockTags.create('space-id')
|
|
189
|
+
|
|
190
|
+
// Get a tag
|
|
191
|
+
const tag = await client.blockTags.get('space-id', 'tag-id')
|
|
192
|
+
|
|
193
|
+
// Update a tag
|
|
194
|
+
await client.blockTags.update('space-id', 'tag-id')
|
|
195
|
+
|
|
196
|
+
// Delete a tag
|
|
197
|
+
await client.blockTags.delete('space-id', 'tag-id')
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Block Folders
|
|
201
|
+
|
|
202
|
+
Organize blocks in folder structures.
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
// List folders
|
|
206
|
+
const folders = await client.blockFolders.list('space-id')
|
|
207
|
+
|
|
208
|
+
// Create a folder
|
|
209
|
+
const folder = await client.blockFolders.create('space-id')
|
|
210
|
+
|
|
211
|
+
// Get a folder
|
|
212
|
+
const folder = await client.blockFolders.get('space-id', 'folder-id')
|
|
213
|
+
|
|
214
|
+
// Update a folder
|
|
215
|
+
await client.blockFolders.update('space-id', 'folder-id')
|
|
216
|
+
|
|
217
|
+
// Delete a folder
|
|
218
|
+
await client.blockFolders.delete('space-id', 'folder-id')
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Contents
|
|
222
|
+
|
|
223
|
+
Manage content entries and their versions.
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
// List contents
|
|
227
|
+
const contents = await client.contents.list('space-id', {
|
|
228
|
+
page: 1,
|
|
229
|
+
per_page: 20,
|
|
230
|
+
block_id: 'block-id',
|
|
231
|
+
published: true,
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
// Create content
|
|
235
|
+
const content = await client.contents.create('space-id')
|
|
236
|
+
|
|
237
|
+
// Get content
|
|
238
|
+
const content = await client.contents.get('space-id', 'content-id')
|
|
239
|
+
|
|
240
|
+
// Update content
|
|
241
|
+
await client.contents.update('space-id', 'content-id')
|
|
242
|
+
|
|
243
|
+
// Delete content
|
|
244
|
+
await client.contents.delete('space-id', 'content-id')
|
|
245
|
+
|
|
246
|
+
// Publish content
|
|
247
|
+
await client.contents.publish('space-id', 'content-id')
|
|
248
|
+
|
|
249
|
+
// Unpublish content
|
|
250
|
+
await client.contents.unpublish('space-id', 'content-id')
|
|
251
|
+
|
|
252
|
+
// Get a specific version
|
|
253
|
+
const version = await client.contents.getVersion('space-id', 'content-id', 1)
|
|
254
|
+
|
|
255
|
+
// Update a version
|
|
256
|
+
await client.contents.updateVersion('space-id', 'content-id', 1)
|
|
257
|
+
|
|
258
|
+
// Publish a specific version
|
|
259
|
+
await client.contents.publishVersion('space-id', 'content-id', 1)
|
|
260
|
+
|
|
261
|
+
// Set a version as current
|
|
262
|
+
await client.contents.setVersionAsCurrent('space-id', 'content-id', 1)
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Assets
|
|
266
|
+
|
|
267
|
+
Manage media assets.
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
// List assets
|
|
271
|
+
const assets = await client.assets.list('space-id')
|
|
272
|
+
|
|
273
|
+
// Create an asset
|
|
274
|
+
const asset = await client.assets.create('space-id')
|
|
275
|
+
|
|
276
|
+
// Get an asset
|
|
277
|
+
const asset = await client.assets.get('space-id', 'asset-id')
|
|
278
|
+
|
|
279
|
+
// Update an asset
|
|
280
|
+
await client.assets.update('space-id', 'asset-id')
|
|
281
|
+
|
|
282
|
+
// Delete an asset
|
|
283
|
+
await client.assets.delete('space-id', 'asset-id')
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Asset Folders
|
|
287
|
+
|
|
288
|
+
Organize assets in folders.
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
// List asset folders
|
|
292
|
+
const folders = await client.assetFolders.list('space-id')
|
|
293
|
+
|
|
294
|
+
// Create a folder
|
|
295
|
+
const folder = await client.assetFolders.create('space-id')
|
|
296
|
+
|
|
297
|
+
// Get a folder
|
|
298
|
+
const folder = await client.assetFolders.get('space-id', 'folder-id')
|
|
299
|
+
|
|
300
|
+
// Update a folder
|
|
301
|
+
await client.assetFolders.update('space-id', 'folder-id')
|
|
302
|
+
|
|
303
|
+
// Delete a folder
|
|
304
|
+
await client.assetFolders.delete('space-id', 'folder-id')
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Asset Tags
|
|
308
|
+
|
|
309
|
+
Tag and organize assets.
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// List asset tags
|
|
313
|
+
const tags = await client.assetTags.list('space-id')
|
|
314
|
+
|
|
315
|
+
// Create a tag
|
|
316
|
+
const tag = await client.assetTags.create('space-id')
|
|
317
|
+
|
|
318
|
+
// Get a tag
|
|
319
|
+
const tag = await client.assetTags.get('space-id', 'tag-id')
|
|
320
|
+
|
|
321
|
+
// Update a tag
|
|
322
|
+
await client.assetTags.update('space-id', 'tag-id')
|
|
323
|
+
|
|
324
|
+
// Delete a tag
|
|
325
|
+
await client.assetTags.delete('space-id', 'tag-id')
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Redirects
|
|
329
|
+
|
|
330
|
+
Manage URL redirects.
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
// List redirects
|
|
334
|
+
const redirects = await client.redirects.list('space-id', {
|
|
335
|
+
type: 'permanent',
|
|
336
|
+
sort: '-hits',
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
// Create a redirect
|
|
340
|
+
const redirect = await client.redirects.create('space-id')
|
|
341
|
+
|
|
342
|
+
// Get a redirect
|
|
343
|
+
const redirect = await client.redirects.get('space-id', 'redirect-id')
|
|
344
|
+
|
|
345
|
+
// Update a redirect
|
|
346
|
+
await client.redirects.update('space-id', 'redirect-id')
|
|
347
|
+
|
|
348
|
+
// Delete a redirect
|
|
349
|
+
await client.redirects.delete('space-id', 'redirect-id')
|
|
350
|
+
|
|
351
|
+
// Reset redirect hit counter
|
|
352
|
+
await client.redirects.reset('space-id', 'redirect-id')
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Tokens
|
|
356
|
+
|
|
357
|
+
Manage space access tokens.
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
// Create a token
|
|
361
|
+
const token = await client.tokens.create('space-id', {
|
|
362
|
+
name: 'Production API Token',
|
|
363
|
+
expires_at: '2024-12-31T23:59:59Z',
|
|
364
|
+
execution_limit: 10000,
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
// Delete a token
|
|
368
|
+
await client.tokens.delete('space-id', 'token-id')
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Data Sources
|
|
372
|
+
|
|
373
|
+
Manage external data sources.
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// List data sources
|
|
377
|
+
const sources = await client.dataSources.list('space-id')
|
|
378
|
+
|
|
379
|
+
// Create a data source
|
|
380
|
+
const source = await client.dataSources.create('space-id')
|
|
381
|
+
|
|
382
|
+
// Get a data source
|
|
383
|
+
const source = await client.dataSources.get('space-id', 'source-id')
|
|
384
|
+
|
|
385
|
+
// Update a data source
|
|
386
|
+
await client.dataSources.update('space-id', 'source-id')
|
|
387
|
+
|
|
388
|
+
// Delete a data source
|
|
389
|
+
await client.dataSources.delete('space-id', 'source-id')
|
|
390
|
+
|
|
391
|
+
// Manage data entries
|
|
392
|
+
const entries = await client.dataSources.listEntries('space-id', 'source-id')
|
|
393
|
+
const entry = await client.dataSources.createEntry('space-id', 'source-id')
|
|
394
|
+
const entry = await client.dataSources.getEntry('space-id', 'source-id', 'entry-id')
|
|
395
|
+
await client.dataSources.updateEntry('space-id', 'source-id', 'entry-id')
|
|
396
|
+
await client.dataSources.deleteEntry('space-id', 'source-id', 'entry-id')
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### AI
|
|
400
|
+
|
|
401
|
+
Access AI-powered features.
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
// Get available AI models
|
|
405
|
+
const models = await client.ai.getAvailableModels({
|
|
406
|
+
provider: 'openai',
|
|
407
|
+
capability: 'text-generation',
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
// Generate meta tags
|
|
411
|
+
const metaTags = await client.ai.generateMetaTags()
|
|
412
|
+
|
|
413
|
+
// Translate content
|
|
414
|
+
const translation = await client.ai.translate()
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### System
|
|
418
|
+
|
|
419
|
+
System health and configuration.
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// Check API health
|
|
423
|
+
const health = await client.system.health()
|
|
424
|
+
|
|
425
|
+
// Get system configuration
|
|
426
|
+
const config = await client.system.getConfig()
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Error Handling
|
|
430
|
+
|
|
431
|
+
The client throws `ManagementApiError` for API errors:
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
import { ManagementApiError } from '@b10cks/mgmt-client'
|
|
435
|
+
|
|
436
|
+
try {
|
|
437
|
+
const user = await client.users.getMe()
|
|
438
|
+
} catch (error) {
|
|
439
|
+
if (error instanceof ManagementApiError) {
|
|
440
|
+
console.error('API Error:', error.message)
|
|
441
|
+
console.error('Status Code:', error.statusCode)
|
|
442
|
+
console.error('Response:', error.response)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
## Pagination
|
|
448
|
+
|
|
449
|
+
List endpoints return paginated responses:
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
const result = await client.blocks.list('space-id', {
|
|
453
|
+
page: 1,
|
|
454
|
+
per_page: 20,
|
|
455
|
+
})
|
|
456
|
+
|
|
457
|
+
console.log(result.data) // Array of items
|
|
458
|
+
console.log(result.meta.total) // Total number of items
|
|
459
|
+
console.log(result.links.next) // URL for next page
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
## TypeScript Support
|
|
463
|
+
|
|
464
|
+
This package is written in TypeScript and includes full type definitions:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
import type {
|
|
468
|
+
User,
|
|
469
|
+
Space,
|
|
470
|
+
Block,
|
|
471
|
+
Content,
|
|
472
|
+
PaginatedResponse
|
|
473
|
+
} from '@b10cks/mgmt-client'
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## License
|
|
477
|
+
|
|
478
|
+
MIT
|
|
479
|
+
|
|
480
|
+
## Support
|
|
481
|
+
|
|
482
|
+
For issues and questions, please visit the [GitHub repository](https://github.com/b10cks/sdk).
|