@usecortex_ai/node 0.3.0 → 0.3.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/README.md +6 -18
- package/dist/api/resources/sources/client/Client.d.ts +29 -3
- package/dist/api/resources/sources/client/Client.js +92 -4
- package/dist/api/resources/sources/client/requests/SourcesGetAllRequest.d.ts +3 -2
- package/dist/api/resources/sources/client/requests/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/api/resources/sources/client/requests/SourcesGetSubTenantIdsRequest.d.ts +0 -12
- package/dist/api/resources/sources/client/requests/SourcesGetSubTenantIdsRequest.js +0 -5
- package/dist/api/resources/upload/client/requests/BodyUpdateMarkdownUploadUpdateMarkdownPatch.d.ts +0 -21
- package/dist/api/resources/upload/client/requests/BodyUpdateMarkdownUploadUpdateMarkdownPatch.js +0 -5
- package/dist/api/resources/upload/client/requests/BodyUpdateMarkdownUploadUpdateTextPatch.d.ts +0 -21
- package/dist/api/resources/upload/client/requests/BodyUpdateMarkdownUploadUpdateTextPatch.js +0 -5
- package/dist/api/resources/upload/client/requests/BodyUploadMarkdownUploadUploadMarkdownPost.d.ts +0 -19
- package/dist/api/resources/upload/client/requests/BodyUploadMarkdownUploadUploadMarkdownPost.js +0 -5
- package/dist/api/resources/upload/client/requests/BodyUploadMarkdownUploadUploadTextPost.d.ts +0 -19
- package/dist/api/resources/upload/client/requests/BodyUploadMarkdownUploadUploadTextPost.js +0 -5
- package/dist/api/resources/userMemory/client/requests/UserMemoryAddUserMemoryRequest.d.ts +0 -16
- package/dist/api/resources/userMemory/client/requests/UserMemoryAddUserMemoryRequest.js +0 -5
- package/dist/api/resources/userMemory/client/requests/UserMemoryGenerateUserMemoryRequest.d.ts +0 -18
- package/dist/api/resources/userMemory/client/requests/UserMemoryGenerateUserMemoryRequest.js +0 -5
- package/dist/api/resources/userMemory/client/requests/UserMemoryRetrieveUserMemoryRequest.d.ts +0 -17
- package/dist/api/resources/userMemory/client/requests/UserMemoryRetrieveUserMemoryRequest.js +0 -5
- package/dist/api/types/SourceContent.d.ts +0 -11
- package/dist/api/types/SourceContent.js +0 -5
package/README.md
CHANGED
|
@@ -2,27 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
The official TypeScript SDK for the Cortex AI platform. Build powerful, context-aware AI applications in your Node.js or TypeScript projects.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/ "null")
|
|
5
|
+
## Links
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
To use the SDK, you'll need an API key from your Cortex AI dashboard.
|
|
11
|
-
|
|
12
|
-
### Initialize the Client
|
|
7
|
+
- **Homepage:** [usecortex.ai](https://www.usecortex.ai/)
|
|
8
|
+
- **Documentation:** [docs.usecortex.ai](https://docs.usecortex.ai/)
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
import { CortexAI } from "@usecortex/ai";
|
|
18
|
-
|
|
19
|
-
const client = new CortexAI({
|
|
20
|
-
// Defaults to process.env.CORTEX_API_KEY
|
|
21
|
-
apiKey: "YOUR_API_KEY",
|
|
22
|
-
});
|
|
10
|
+
## Getting Started
|
|
23
11
|
|
|
24
|
-
|
|
12
|
+
Please refer to our [SDK documentation](https://docs.usecortex.ai/api-reference/sdks) and [API reference](https://docs.usecortex.ai/api-reference/introduction) to get started.
|
|
25
13
|
|
|
26
14
|
## Support
|
|
27
15
|
|
|
28
|
-
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai
|
|
16
|
+
If you have any questions or need help, please reach out to our support team at [founders@usecortex.ai](mailto:founders@usecortex.ai).
|
|
@@ -29,6 +29,32 @@ export declare namespace Sources {
|
|
|
29
29
|
export declare class Sources {
|
|
30
30
|
protected readonly _options: Sources.Options;
|
|
31
31
|
constructor(_options?: Sources.Options);
|
|
32
|
+
/**
|
|
33
|
+
* Retrieve all sources for a specific tenant.
|
|
34
|
+
*
|
|
35
|
+
* Use this endpoint to fetch a complete list of all sources associated with your tenant. This includes documents, files, and other content you've uploaded for processing.
|
|
36
|
+
*
|
|
37
|
+
* You can optionally specify a sub-tenant to narrow down the results to sources within that specific sub-tenant scope.
|
|
38
|
+
*
|
|
39
|
+
* @param {CortexAI.SourcesGetAllRequest} request
|
|
40
|
+
* @param {Sources.RequestOptions} requestOptions - Request-specific configuration.
|
|
41
|
+
*
|
|
42
|
+
* @throws {@link CortexAI.BadRequestError}
|
|
43
|
+
* @throws {@link CortexAI.UnauthorizedError}
|
|
44
|
+
* @throws {@link CortexAI.ForbiddenError}
|
|
45
|
+
* @throws {@link CortexAI.NotFoundError}
|
|
46
|
+
* @throws {@link CortexAI.UnprocessableEntityError}
|
|
47
|
+
* @throws {@link CortexAI.InternalServerError}
|
|
48
|
+
* @throws {@link CortexAI.ServiceUnavailableError}
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* await client.sources.getAll({
|
|
52
|
+
* tenant_id: "tenant_1234",
|
|
53
|
+
* sub_tenant_id: "sub_tenant_4567"
|
|
54
|
+
* })
|
|
55
|
+
*/
|
|
56
|
+
getAll(request: CortexAI.SourcesGetAllRequest, requestOptions?: Sources.RequestOptions): core.HttpResponsePromise<CortexAI.ListSourcesResponse>;
|
|
57
|
+
private __getAll;
|
|
32
58
|
/**
|
|
33
59
|
* Retrieve specific sources by their IDs.
|
|
34
60
|
*
|
|
@@ -48,12 +74,12 @@ export declare class Sources {
|
|
|
48
74
|
* @throws {@link CortexAI.ServiceUnavailableError}
|
|
49
75
|
*
|
|
50
76
|
* @example
|
|
51
|
-
* await client.sources.
|
|
77
|
+
* await client.sources.getByIds({
|
|
52
78
|
* tenant_id: "tenant_1234",
|
|
53
79
|
* source_ids: ["CortexDoc1234", "CortexDoc4567"]
|
|
54
80
|
* })
|
|
55
81
|
*/
|
|
56
|
-
|
|
57
|
-
private
|
|
82
|
+
getByIds(request: CortexAI.SourceBodyParams, requestOptions?: Sources.RequestOptions): core.HttpResponsePromise<CortexAI.ListSourcesResponse>;
|
|
83
|
+
private __getByIds;
|
|
58
84
|
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
59
85
|
}
|
|
@@ -36,6 +36,94 @@ class Sources {
|
|
|
36
36
|
constructor(_options = {}) {
|
|
37
37
|
this._options = _options;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve all sources for a specific tenant.
|
|
41
|
+
*
|
|
42
|
+
* Use this endpoint to fetch a complete list of all sources associated with your tenant. This includes documents, files, and other content you've uploaded for processing.
|
|
43
|
+
*
|
|
44
|
+
* You can optionally specify a sub-tenant to narrow down the results to sources within that specific sub-tenant scope.
|
|
45
|
+
*
|
|
46
|
+
* @param {CortexAI.SourcesGetAllRequest} request
|
|
47
|
+
* @param {Sources.RequestOptions} requestOptions - Request-specific configuration.
|
|
48
|
+
*
|
|
49
|
+
* @throws {@link CortexAI.BadRequestError}
|
|
50
|
+
* @throws {@link CortexAI.UnauthorizedError}
|
|
51
|
+
* @throws {@link CortexAI.ForbiddenError}
|
|
52
|
+
* @throws {@link CortexAI.NotFoundError}
|
|
53
|
+
* @throws {@link CortexAI.UnprocessableEntityError}
|
|
54
|
+
* @throws {@link CortexAI.InternalServerError}
|
|
55
|
+
* @throws {@link CortexAI.ServiceUnavailableError}
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* await client.sources.getAll({
|
|
59
|
+
* tenant_id: "tenant_1234",
|
|
60
|
+
* sub_tenant_id: "sub_tenant_4567"
|
|
61
|
+
* })
|
|
62
|
+
*/
|
|
63
|
+
getAll(request, requestOptions) {
|
|
64
|
+
return core.HttpResponsePromise.fromPromise(this.__getAll(request, requestOptions));
|
|
65
|
+
}
|
|
66
|
+
async __getAll(request, requestOptions) {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const { tenant_id: tenantId, sub_tenant_id: subTenantId } = request;
|
|
69
|
+
const _queryParams = {};
|
|
70
|
+
_queryParams["tenant_id"] = tenantId;
|
|
71
|
+
if (subTenantId != null) {
|
|
72
|
+
_queryParams["sub_tenant_id"] = subTenantId;
|
|
73
|
+
}
|
|
74
|
+
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: await this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
75
|
+
const _response = await core.fetcher({
|
|
76
|
+
url: core.url.join((_c = (_b = (await core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (await core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.CortexAIEnvironment.CortexProd, "list/sources"),
|
|
77
|
+
method: "GET",
|
|
78
|
+
headers: _headers,
|
|
79
|
+
queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
|
|
80
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
81
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
82
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
83
|
+
});
|
|
84
|
+
if (_response.ok) {
|
|
85
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
86
|
+
}
|
|
87
|
+
if (_response.error.reason === "status-code") {
|
|
88
|
+
switch (_response.error.statusCode) {
|
|
89
|
+
case 400:
|
|
90
|
+
throw new CortexAI.BadRequestError(_response.error.body, _response.rawResponse);
|
|
91
|
+
case 401:
|
|
92
|
+
throw new CortexAI.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
93
|
+
case 403:
|
|
94
|
+
throw new CortexAI.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
95
|
+
case 404:
|
|
96
|
+
throw new CortexAI.NotFoundError(_response.error.body, _response.rawResponse);
|
|
97
|
+
case 422:
|
|
98
|
+
throw new CortexAI.UnprocessableEntityError(_response.error.body, _response.rawResponse);
|
|
99
|
+
case 500:
|
|
100
|
+
throw new CortexAI.InternalServerError(_response.error.body, _response.rawResponse);
|
|
101
|
+
case 503:
|
|
102
|
+
throw new CortexAI.ServiceUnavailableError(_response.error.body, _response.rawResponse);
|
|
103
|
+
default:
|
|
104
|
+
throw new errors.CortexAIError({
|
|
105
|
+
statusCode: _response.error.statusCode,
|
|
106
|
+
body: _response.error.body,
|
|
107
|
+
rawResponse: _response.rawResponse,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
switch (_response.error.reason) {
|
|
112
|
+
case "non-json":
|
|
113
|
+
throw new errors.CortexAIError({
|
|
114
|
+
statusCode: _response.error.statusCode,
|
|
115
|
+
body: _response.error.rawBody,
|
|
116
|
+
rawResponse: _response.rawResponse,
|
|
117
|
+
});
|
|
118
|
+
case "timeout":
|
|
119
|
+
throw new errors.CortexAITimeoutError("Timeout exceeded when calling GET /list/sources.");
|
|
120
|
+
case "unknown":
|
|
121
|
+
throw new errors.CortexAIError({
|
|
122
|
+
message: _response.error.errorMessage,
|
|
123
|
+
rawResponse: _response.rawResponse,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
39
127
|
/**
|
|
40
128
|
* Retrieve specific sources by their IDs.
|
|
41
129
|
*
|
|
@@ -55,15 +143,15 @@ class Sources {
|
|
|
55
143
|
* @throws {@link CortexAI.ServiceUnavailableError}
|
|
56
144
|
*
|
|
57
145
|
* @example
|
|
58
|
-
* await client.sources.
|
|
146
|
+
* await client.sources.getByIds({
|
|
59
147
|
* tenant_id: "tenant_1234",
|
|
60
148
|
* source_ids: ["CortexDoc1234", "CortexDoc4567"]
|
|
61
149
|
* })
|
|
62
150
|
*/
|
|
63
|
-
|
|
64
|
-
return core.HttpResponsePromise.fromPromise(this.
|
|
151
|
+
getByIds(request, requestOptions) {
|
|
152
|
+
return core.HttpResponsePromise.fromPromise(this.__getByIds(request, requestOptions));
|
|
65
153
|
}
|
|
66
|
-
async
|
|
154
|
+
async __getByIds(request, requestOptions) {
|
|
67
155
|
var _a, _b, _c;
|
|
68
156
|
let _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: await this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
69
157
|
const _response = await core.fetcher({
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
* {
|
|
7
|
-
* tenant_id: "
|
|
7
|
+
* tenant_id: "tenant_1234",
|
|
8
|
+
* sub_tenant_id: "sub_tenant_4567"
|
|
8
9
|
* }
|
|
9
10
|
*/
|
|
10
11
|
export interface SourcesGetAllRequest {
|
|
11
12
|
/** Unique identifier for the tenant/organization */
|
|
12
13
|
tenant_id: string;
|
|
13
|
-
/** Optional sub-tenant identifier
|
|
14
|
+
/** Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used. */
|
|
14
15
|
sub_tenant_id?: string;
|
|
15
16
|
}
|
package/package.json
CHANGED
package/dist/api/resources/upload/client/requests/BodyUpdateMarkdownUploadUpdateMarkdownPatch.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as CortexAI from "../../../../index.js";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* {
|
|
8
|
-
* source_id: "source_id",
|
|
9
|
-
* tenant_id: "tenant_id",
|
|
10
|
-
* request: {
|
|
11
|
-
* content: "content"
|
|
12
|
-
* }
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
export interface BodyUpdateMarkdownUploadUpdateMarkdownPatch {
|
|
16
|
-
source_id: string;
|
|
17
|
-
tenant_id: string;
|
|
18
|
-
sub_tenant_id?: string;
|
|
19
|
-
request: CortexAI.MarkdownUploadRequest;
|
|
20
|
-
relations?: CortexAI.Relations;
|
|
21
|
-
}
|
package/dist/api/resources/upload/client/requests/BodyUpdateMarkdownUploadUpdateTextPatch.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as CortexAI from "../../../../index.js";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* {
|
|
8
|
-
* source_id: "source_id",
|
|
9
|
-
* tenant_id: "tenant_id",
|
|
10
|
-
* request: {
|
|
11
|
-
* content: "content"
|
|
12
|
-
* }
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
export interface BodyUpdateMarkdownUploadUpdateTextPatch {
|
|
16
|
-
source_id: string;
|
|
17
|
-
tenant_id: string;
|
|
18
|
-
sub_tenant_id?: string;
|
|
19
|
-
request: CortexAI.MarkdownUploadRequest;
|
|
20
|
-
relations?: CortexAI.Relations;
|
|
21
|
-
}
|
package/dist/api/resources/upload/client/requests/BodyUploadMarkdownUploadUploadMarkdownPost.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as CortexAI from "../../../../index.js";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* {
|
|
8
|
-
* tenant_id: "tenant_id",
|
|
9
|
-
* request: {
|
|
10
|
-
* content: "content"
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
*/
|
|
14
|
-
export interface BodyUploadMarkdownUploadUploadMarkdownPost {
|
|
15
|
-
tenant_id: string;
|
|
16
|
-
sub_tenant_id?: string;
|
|
17
|
-
request: CortexAI.MarkdownUploadRequest;
|
|
18
|
-
relations?: CortexAI.Relations;
|
|
19
|
-
}
|
package/dist/api/resources/upload/client/requests/BodyUploadMarkdownUploadUploadTextPost.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
import * as CortexAI from "../../../../index.js";
|
|
5
|
-
/**
|
|
6
|
-
* @example
|
|
7
|
-
* {
|
|
8
|
-
* tenant_id: "tenant_id",
|
|
9
|
-
* request: {
|
|
10
|
-
* content: "content"
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
*/
|
|
14
|
-
export interface BodyUploadMarkdownUploadUploadTextPost {
|
|
15
|
-
tenant_id: string;
|
|
16
|
-
sub_tenant_id?: string;
|
|
17
|
-
request: CortexAI.MarkdownUploadRequest;
|
|
18
|
-
relations?: CortexAI.Relations;
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* {
|
|
7
|
-
* tenant_id: "tenant_id",
|
|
8
|
-
* user_memory: "user_memory",
|
|
9
|
-
* sub_tenant_id: "sub_tenant_id"
|
|
10
|
-
* }
|
|
11
|
-
*/
|
|
12
|
-
export interface UserMemoryAddUserMemoryRequest {
|
|
13
|
-
tenant_id: string;
|
|
14
|
-
user_memory: string;
|
|
15
|
-
sub_tenant_id: string;
|
|
16
|
-
}
|
package/dist/api/resources/userMemory/client/requests/UserMemoryGenerateUserMemoryRequest.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* {
|
|
7
|
-
* tenant_id: "tenant_id",
|
|
8
|
-
* user_query: "user_query",
|
|
9
|
-
* user_name: "user_name",
|
|
10
|
-
* sub_tenant_id: "sub_tenant_id"
|
|
11
|
-
* }
|
|
12
|
-
*/
|
|
13
|
-
export interface UserMemoryGenerateUserMemoryRequest {
|
|
14
|
-
tenant_id: string;
|
|
15
|
-
user_query: string;
|
|
16
|
-
user_name: string;
|
|
17
|
-
sub_tenant_id: string;
|
|
18
|
-
}
|
package/dist/api/resources/userMemory/client/requests/UserMemoryRetrieveUserMemoryRequest.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @example
|
|
6
|
-
* {
|
|
7
|
-
* tenant_id: "tenant_id",
|
|
8
|
-
* query: "query",
|
|
9
|
-
* sub_tenant_id: "sub_tenant_id"
|
|
10
|
-
* }
|
|
11
|
-
*/
|
|
12
|
-
export interface UserMemoryRetrieveUserMemoryRequest {
|
|
13
|
-
tenant_id: string;
|
|
14
|
-
query: string;
|
|
15
|
-
sub_tenant_id: string;
|
|
16
|
-
max_count?: number;
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
export interface SourceContent {
|
|
5
|
-
text?: string;
|
|
6
|
-
html_base64?: string;
|
|
7
|
-
csv_base64?: string;
|
|
8
|
-
markdown?: string;
|
|
9
|
-
files?: Record<string, unknown>[];
|
|
10
|
-
layout?: Record<string, unknown>[];
|
|
11
|
-
}
|