codemie-sdk 0.1.440 → 0.1.444
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/dist/index.cjs +135 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +174 -171
- package/dist/index.d.ts +174 -171
- package/dist/index.js +134 -123
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -29,14 +29,20 @@ var _KeycloakCredentials = class _KeycloakCredentials {
|
|
|
29
29
|
} else {
|
|
30
30
|
payload = this.createClientCredentialsPayload();
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
try {
|
|
33
|
+
const { data } = await axios.post(url, this.createSearchParams(payload), {
|
|
34
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
35
|
+
httpsAgent: this.httpAgent
|
|
36
|
+
});
|
|
37
|
+
this.cachedToken = data.access_token;
|
|
38
|
+
const expiresIn = data.expires_in ?? 300;
|
|
39
|
+
this.tokenExpiresAt = now + expiresIn * 1e3 - _KeycloakCredentials.TOKEN_EXPIRY_BUFFER_MS;
|
|
40
|
+
return this.cachedToken;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
const axiosErr = err;
|
|
43
|
+
const reason = axiosErr.message ?? String(err);
|
|
44
|
+
throw new Error(`Cannot connect to Keycloak at ${url}: ${reason}`);
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
clearCache() {
|
|
42
48
|
this.cachedToken = null;
|
|
@@ -236,7 +242,7 @@ var ApiRequestHandler = class {
|
|
|
236
242
|
throw new ApiError(errorMessage2 || "Validation error", status, data);
|
|
237
243
|
}
|
|
238
244
|
const errorMessage = [data.error?.message, data.error?.detail, data.error?.help].filter(Boolean).join(". ");
|
|
239
|
-
throw new ApiError(errorMessage
|
|
245
|
+
throw new ApiError(errorMessage || `HTTP ${status} error`, status, data);
|
|
240
246
|
}
|
|
241
247
|
};
|
|
242
248
|
|
|
@@ -445,6 +451,7 @@ var AssistantCreateParamsSchema = z2.object({
|
|
|
445
451
|
})
|
|
446
452
|
),
|
|
447
453
|
assistant_ids: z2.array(z2.string()),
|
|
454
|
+
skill_ids: z2.array(z2.string()).optional(),
|
|
448
455
|
prompt_variables: z2.array(PromptVariableSchema).optional().default([]),
|
|
449
456
|
categories: z2.array(z2.string()).max(3).optional(),
|
|
450
457
|
skip_integration_validation: z2.boolean().optional().default(false)
|
|
@@ -1215,7 +1222,8 @@ var DatasourceService = class {
|
|
|
1215
1222
|
"/v1/index",
|
|
1216
1223
|
queryParams
|
|
1217
1224
|
);
|
|
1218
|
-
|
|
1225
|
+
const items = Array.isArray(response?.data) ? response.data : [];
|
|
1226
|
+
return items.map(DatasourceMapper.mapDatasourceResponse);
|
|
1219
1227
|
}
|
|
1220
1228
|
/**
|
|
1221
1229
|
* Get datasource by ID.
|
|
@@ -1425,7 +1433,7 @@ var IntegrationService = class {
|
|
|
1425
1433
|
this.getBasePath(settingType),
|
|
1426
1434
|
queryParams
|
|
1427
1435
|
);
|
|
1428
|
-
return response.data;
|
|
1436
|
+
return Array.isArray(response?.data) ? response.data : [];
|
|
1429
1437
|
}
|
|
1430
1438
|
/**
|
|
1431
1439
|
* Get integration by ID.
|
|
@@ -1512,114 +1520,6 @@ var LLMService = class {
|
|
|
1512
1520
|
}
|
|
1513
1521
|
};
|
|
1514
1522
|
|
|
1515
|
-
// src/services/task.ts
|
|
1516
|
-
var TaskService = class {
|
|
1517
|
-
constructor(config) {
|
|
1518
|
-
this.api = new ApiRequestHandler(config);
|
|
1519
|
-
}
|
|
1520
|
-
/**
|
|
1521
|
-
* Get a background task by ID.
|
|
1522
|
-
*/
|
|
1523
|
-
async get(taskId) {
|
|
1524
|
-
return this.api.get(`/v1/tasks/${taskId}`);
|
|
1525
|
-
}
|
|
1526
|
-
};
|
|
1527
|
-
|
|
1528
|
-
// src/mappers/user.mapper.ts
|
|
1529
|
-
var UserMapper = class {
|
|
1530
|
-
static mapAboutUserResponse(response) {
|
|
1531
|
-
return omitUndefined({
|
|
1532
|
-
user_id: response.user_id,
|
|
1533
|
-
name: response.name,
|
|
1534
|
-
username: response.username,
|
|
1535
|
-
email: response.email,
|
|
1536
|
-
is_admin: response.is_admin,
|
|
1537
|
-
applications: response.applications,
|
|
1538
|
-
applications_admin: response.applications_admin,
|
|
1539
|
-
picture: response.picture,
|
|
1540
|
-
knowledge_bases: response.knowledge_bases
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
};
|
|
1544
|
-
|
|
1545
|
-
// src/services/user.ts
|
|
1546
|
-
var UserService = class {
|
|
1547
|
-
constructor(config) {
|
|
1548
|
-
this.api = new ApiRequestHandler(config);
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Get current user profile.
|
|
1552
|
-
*/
|
|
1553
|
-
async aboutMe() {
|
|
1554
|
-
const response = await this.api.get("/v1/user");
|
|
1555
|
-
return UserMapper.mapAboutUserResponse(response);
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* Get user data and preferences.
|
|
1559
|
-
*/
|
|
1560
|
-
async getData() {
|
|
1561
|
-
return this.api.get("/v1/user/data");
|
|
1562
|
-
}
|
|
1563
|
-
};
|
|
1564
|
-
|
|
1565
|
-
// src/services/category.ts
|
|
1566
|
-
var CategoryService = class {
|
|
1567
|
-
constructor(config) {
|
|
1568
|
-
this.api = new ApiRequestHandler(config);
|
|
1569
|
-
}
|
|
1570
|
-
/**
|
|
1571
|
-
* Get all available assistant categories (legacy, non-paginated).
|
|
1572
|
-
* Public endpoint — no admin access required.
|
|
1573
|
-
* GET /v1/assistants/categories
|
|
1574
|
-
*/
|
|
1575
|
-
async getCategories() {
|
|
1576
|
-
return this.api.get("/v1/assistants/categories");
|
|
1577
|
-
}
|
|
1578
|
-
/**
|
|
1579
|
-
* Get paginated list of categories with marketplace/project assistant counts.
|
|
1580
|
-
* Admin access required.
|
|
1581
|
-
* GET /v1/assistants/categories/list
|
|
1582
|
-
*/
|
|
1583
|
-
async listCategories(page = 0, perPage = 10) {
|
|
1584
|
-
return this.api.get("/v1/assistants/categories/list", {
|
|
1585
|
-
page,
|
|
1586
|
-
per_page: perPage
|
|
1587
|
-
});
|
|
1588
|
-
}
|
|
1589
|
-
/**
|
|
1590
|
-
* Get a specific category by ID with assistant counts.
|
|
1591
|
-
* Admin access required.
|
|
1592
|
-
* GET /v1/assistants/categories/{id}
|
|
1593
|
-
*/
|
|
1594
|
-
async getCategory(categoryId) {
|
|
1595
|
-
return this.api.get(`/v1/assistants/categories/${categoryId}`);
|
|
1596
|
-
}
|
|
1597
|
-
/**
|
|
1598
|
-
* Create a new category. The ID is auto-generated from the name.
|
|
1599
|
-
* Admin access required.
|
|
1600
|
-
* POST /v1/assistants/categories
|
|
1601
|
-
*/
|
|
1602
|
-
async createCategory(params) {
|
|
1603
|
-
return this.api.post("/v1/assistants/categories", params);
|
|
1604
|
-
}
|
|
1605
|
-
/**
|
|
1606
|
-
* Update an existing category.
|
|
1607
|
-
* Admin access required.
|
|
1608
|
-
* PUT /v1/assistants/categories/{id}
|
|
1609
|
-
*/
|
|
1610
|
-
async updateCategory(categoryId, params) {
|
|
1611
|
-
return this.api.put(`/v1/assistants/categories/${categoryId}`, params);
|
|
1612
|
-
}
|
|
1613
|
-
/**
|
|
1614
|
-
* Delete a category. Fails with 409 if any assistants are assigned to it.
|
|
1615
|
-
* Admin access required.
|
|
1616
|
-
* DELETE /v1/assistants/categories/{id}
|
|
1617
|
-
*/
|
|
1618
|
-
async deleteCategory(categoryId) {
|
|
1619
|
-
return this.api.delete(`/v1/assistants/categories/${categoryId}`);
|
|
1620
|
-
}
|
|
1621
|
-
};
|
|
1622
|
-
|
|
1623
1523
|
// src/schemas/skill.ts
|
|
1624
1524
|
import { z as z6 } from "zod";
|
|
1625
1525
|
|
|
@@ -1813,6 +1713,114 @@ var SkillService = class {
|
|
|
1813
1713
|
}
|
|
1814
1714
|
};
|
|
1815
1715
|
|
|
1716
|
+
// src/services/task.ts
|
|
1717
|
+
var TaskService = class {
|
|
1718
|
+
constructor(config) {
|
|
1719
|
+
this.api = new ApiRequestHandler(config);
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Get a background task by ID.
|
|
1723
|
+
*/
|
|
1724
|
+
async get(taskId) {
|
|
1725
|
+
return this.api.get(`/v1/tasks/${taskId}`);
|
|
1726
|
+
}
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
// src/mappers/user.mapper.ts
|
|
1730
|
+
var UserMapper = class {
|
|
1731
|
+
static mapAboutUserResponse(response) {
|
|
1732
|
+
return omitUndefined({
|
|
1733
|
+
user_id: response.user_id,
|
|
1734
|
+
name: response.name,
|
|
1735
|
+
username: response.username,
|
|
1736
|
+
email: response.email,
|
|
1737
|
+
is_admin: response.is_admin,
|
|
1738
|
+
applications: response.applications,
|
|
1739
|
+
applications_admin: response.applications_admin,
|
|
1740
|
+
picture: response.picture,
|
|
1741
|
+
knowledge_bases: response.knowledge_bases
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
|
|
1746
|
+
// src/services/user.ts
|
|
1747
|
+
var UserService = class {
|
|
1748
|
+
constructor(config) {
|
|
1749
|
+
this.api = new ApiRequestHandler(config);
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Get current user profile.
|
|
1753
|
+
*/
|
|
1754
|
+
async aboutMe() {
|
|
1755
|
+
const response = await this.api.get("/v1/user");
|
|
1756
|
+
return UserMapper.mapAboutUserResponse(response);
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Get user data and preferences.
|
|
1760
|
+
*/
|
|
1761
|
+
async getData() {
|
|
1762
|
+
return this.api.get("/v1/user/data");
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
|
|
1766
|
+
// src/services/category.ts
|
|
1767
|
+
var CategoryService = class {
|
|
1768
|
+
constructor(config) {
|
|
1769
|
+
this.api = new ApiRequestHandler(config);
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Get all available assistant categories (legacy, non-paginated).
|
|
1773
|
+
* Public endpoint — no admin access required.
|
|
1774
|
+
* GET /v1/assistants/categories
|
|
1775
|
+
*/
|
|
1776
|
+
async getCategories() {
|
|
1777
|
+
return this.api.get("/v1/assistants/categories");
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Get paginated list of categories with marketplace/project assistant counts.
|
|
1781
|
+
* Admin access required.
|
|
1782
|
+
* GET /v1/assistants/categories/list
|
|
1783
|
+
*/
|
|
1784
|
+
async listCategories(page = 0, perPage = 10) {
|
|
1785
|
+
return this.api.get("/v1/assistants/categories/list", {
|
|
1786
|
+
page,
|
|
1787
|
+
per_page: perPage
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Get a specific category by ID with assistant counts.
|
|
1792
|
+
* Admin access required.
|
|
1793
|
+
* GET /v1/assistants/categories/{id}
|
|
1794
|
+
*/
|
|
1795
|
+
async getCategory(categoryId) {
|
|
1796
|
+
return this.api.get(`/v1/assistants/categories/${categoryId}`);
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Create a new category. The ID is auto-generated from the name.
|
|
1800
|
+
* Admin access required.
|
|
1801
|
+
* POST /v1/assistants/categories
|
|
1802
|
+
*/
|
|
1803
|
+
async createCategory(params) {
|
|
1804
|
+
return this.api.post("/v1/assistants/categories", params);
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Update an existing category.
|
|
1808
|
+
* Admin access required.
|
|
1809
|
+
* PUT /v1/assistants/categories/{id}
|
|
1810
|
+
*/
|
|
1811
|
+
async updateCategory(categoryId, params) {
|
|
1812
|
+
return this.api.put(`/v1/assistants/categories/${categoryId}`, params);
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Delete a category. Fails with 409 if any assistants are assigned to it.
|
|
1816
|
+
* Admin access required.
|
|
1817
|
+
* DELETE /v1/assistants/categories/{id}
|
|
1818
|
+
*/
|
|
1819
|
+
async deleteCategory(categoryId) {
|
|
1820
|
+
return this.api.delete(`/v1/assistants/categories/${categoryId}`);
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
|
|
1816
1824
|
// src/mappers/workflow.mapper.ts
|
|
1817
1825
|
var WorkflowMapper = class {
|
|
1818
1826
|
static mapWorkflowResponse(response) {
|
|
@@ -2026,7 +2034,8 @@ var WorkflowService = class {
|
|
|
2026
2034
|
*/
|
|
2027
2035
|
async getPrebuilt() {
|
|
2028
2036
|
const response = await this.api.get("/v1/workflows/prebuilt");
|
|
2029
|
-
|
|
2037
|
+
const prebuiltItems = Array.isArray(response) ? response : [];
|
|
2038
|
+
return prebuiltItems.map(WorkflowMapper.mapWorkflowResponse);
|
|
2030
2039
|
}
|
|
2031
2040
|
/**
|
|
2032
2041
|
* Create a new workflow.
|
|
@@ -2060,7 +2069,8 @@ var WorkflowService = class {
|
|
|
2060
2069
|
"/v1/workflows",
|
|
2061
2070
|
queryParams
|
|
2062
2071
|
);
|
|
2063
|
-
|
|
2072
|
+
const items = Array.isArray(workflows?.data) ? workflows.data : [];
|
|
2073
|
+
return items.map(WorkflowMapper.mapWorkflowResponse);
|
|
2064
2074
|
}
|
|
2065
2075
|
/**
|
|
2066
2076
|
* Get workflow by ID.
|
|
@@ -2153,9 +2163,9 @@ var CodeMieClient = class {
|
|
|
2153
2163
|
this._integrations = new IntegrationService(authConfig);
|
|
2154
2164
|
this._llms = new LLMService(authConfig);
|
|
2155
2165
|
this._tasks = new TaskService(authConfig);
|
|
2166
|
+
this._skills = new SkillService(authConfig);
|
|
2156
2167
|
this._users = new UserService(authConfig);
|
|
2157
2168
|
this._categories = new CategoryService(authConfig);
|
|
2158
|
-
this._skills = new SkillService(authConfig);
|
|
2159
2169
|
this._workflows = new WorkflowService(authConfig);
|
|
2160
2170
|
}
|
|
2161
2171
|
/**
|
|
@@ -2303,10 +2313,10 @@ var CodeMieClient = class {
|
|
|
2303
2313
|
this._files = new FileService(authConfig);
|
|
2304
2314
|
this._integrations = new IntegrationService(authConfig);
|
|
2305
2315
|
this._llms = new LLMService(authConfig);
|
|
2316
|
+
this._skills = new SkillService(authConfig);
|
|
2306
2317
|
this._tasks = new TaskService(authConfig);
|
|
2307
2318
|
this._users = new UserService(authConfig);
|
|
2308
2319
|
this._categories = new CategoryService(authConfig);
|
|
2309
|
-
this._skills = new SkillService(authConfig);
|
|
2310
2320
|
this._workflows = new WorkflowService(authConfig);
|
|
2311
2321
|
}
|
|
2312
2322
|
};
|
|
@@ -2516,6 +2526,7 @@ export {
|
|
|
2516
2526
|
NotFoundError,
|
|
2517
2527
|
PaginatedAnalyticsQueryParamsSchema,
|
|
2518
2528
|
SkillCategory,
|
|
2529
|
+
SkillListParamsSchema,
|
|
2519
2530
|
SkillScopeFilter,
|
|
2520
2531
|
SkillService,
|
|
2521
2532
|
SkillSortBy,
|