@credal/sdk 0.1.10 → 0.1.12
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/cjs/BaseClient.d.ts +6 -1
- package/dist/cjs/BaseClient.js +47 -0
- package/dist/cjs/Client.d.ts +16 -16
- package/dist/cjs/Client.js +8 -49
- package/dist/cjs/api/resources/copilots/client/Client.d.ts +21 -21
- package/dist/cjs/api/resources/copilots/client/Client.js +41 -22
- package/dist/cjs/api/resources/documentCatalog/client/Client.d.ts +12 -12
- package/dist/cjs/api/resources/documentCatalog/client/Client.js +22 -13
- package/dist/cjs/api/resources/documentCollections/client/Client.d.ts +18 -18
- package/dist/cjs/api/resources/documentCollections/client/Client.js +34 -19
- package/dist/cjs/api/resources/search/client/Client.d.ts +6 -6
- package/dist/cjs/api/resources/search/client/Client.js +10 -7
- package/dist/cjs/api/resources/users/client/Client.d.ts +6 -6
- package/dist/cjs/api/resources/users/client/Client.js +10 -7
- package/dist/cjs/core/exports.d.ts +1 -0
- package/dist/cjs/core/exports.js +1 -0
- package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -1
- package/dist/cjs/core/fetcher/Fetcher.js +202 -9
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
- package/dist/cjs/core/fetcher/getRequestBody.js +4 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
- package/dist/cjs/core/fetcher/makeRequest.js +0 -2
- package/dist/cjs/core/fetcher/requestWithRetries.js +0 -9
- package/dist/cjs/core/fetcher/signals.d.ts +0 -6
- package/dist/cjs/core/fetcher/signals.js +0 -12
- package/dist/cjs/core/headers.js +6 -4
- package/dist/cjs/core/index.d.ts +1 -0
- package/dist/cjs/core/index.js +2 -1
- package/dist/cjs/core/logging/exports.d.ts +18 -0
- package/dist/cjs/core/logging/exports.js +45 -0
- package/dist/cjs/core/logging/index.d.ts +1 -0
- package/dist/cjs/core/logging/index.js +17 -0
- package/dist/cjs/core/logging/logger.d.ts +126 -0
- package/dist/cjs/core/logging/logger.js +144 -0
- package/dist/cjs/core/url/join.js +0 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +6 -1
- package/dist/esm/BaseClient.mjs +13 -1
- package/dist/esm/Client.d.mts +16 -16
- package/dist/esm/Client.mjs +13 -21
- package/dist/esm/api/resources/copilots/client/Client.d.mts +21 -21
- package/dist/esm/api/resources/copilots/client/Client.mjs +39 -20
- package/dist/esm/api/resources/documentCatalog/client/Client.d.mts +12 -12
- package/dist/esm/api/resources/documentCatalog/client/Client.mjs +20 -11
- package/dist/esm/api/resources/documentCollections/client/Client.d.mts +18 -18
- package/dist/esm/api/resources/documentCollections/client/Client.mjs +32 -17
- package/dist/esm/api/resources/search/client/Client.d.mts +6 -6
- package/dist/esm/api/resources/search/client/Client.mjs +8 -5
- package/dist/esm/api/resources/users/client/Client.d.mts +6 -6
- package/dist/esm/api/resources/users/client/Client.mjs +8 -5
- package/dist/esm/core/exports.d.mts +1 -0
- package/dist/esm/core/exports.mjs +1 -0
- package/dist/esm/core/fetcher/Fetcher.d.mts +4 -1
- package/dist/esm/core/fetcher/Fetcher.mjs +202 -9
- package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
- package/dist/esm/core/fetcher/getRequestBody.mjs +4 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +0 -2
- package/dist/esm/core/fetcher/requestWithRetries.mjs +0 -9
- package/dist/esm/core/fetcher/signals.d.mts +0 -6
- package/dist/esm/core/fetcher/signals.mjs +0 -12
- package/dist/esm/core/headers.mjs +6 -4
- package/dist/esm/core/index.d.mts +1 -0
- package/dist/esm/core/index.mjs +1 -0
- package/dist/esm/core/logging/exports.d.mts +18 -0
- package/dist/esm/core/logging/exports.mjs +9 -0
- package/dist/esm/core/logging/index.d.mts +1 -0
- package/dist/esm/core/logging/index.mjs +1 -0
- package/dist/esm/core/logging/logger.d.mts +126 -0
- package/dist/esm/core/logging/logger.mjs +138 -0
- package/dist/esm/core/url/join.mjs +0 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +3 -2
- package/reference.md +21 -21
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
export const LogLevel = {
|
|
2
|
+
Debug: "debug",
|
|
3
|
+
Info: "info",
|
|
4
|
+
Warn: "warn",
|
|
5
|
+
Error: "error",
|
|
6
|
+
};
|
|
7
|
+
const logLevelMap = {
|
|
8
|
+
[LogLevel.Debug]: 1,
|
|
9
|
+
[LogLevel.Info]: 2,
|
|
10
|
+
[LogLevel.Warn]: 3,
|
|
11
|
+
[LogLevel.Error]: 4,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Default console-based logger implementation.
|
|
15
|
+
*/
|
|
16
|
+
export class ConsoleLogger {
|
|
17
|
+
debug(message, ...args) {
|
|
18
|
+
console.debug(message, ...args);
|
|
19
|
+
}
|
|
20
|
+
info(message, ...args) {
|
|
21
|
+
console.info(message, ...args);
|
|
22
|
+
}
|
|
23
|
+
warn(message, ...args) {
|
|
24
|
+
console.warn(message, ...args);
|
|
25
|
+
}
|
|
26
|
+
error(message, ...args) {
|
|
27
|
+
console.error(message, ...args);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Logger class that provides level-based logging functionality.
|
|
32
|
+
*/
|
|
33
|
+
export class Logger {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new logger instance.
|
|
36
|
+
* @param config - Logger configuration
|
|
37
|
+
*/
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this.level = logLevelMap[config.level];
|
|
40
|
+
this.logger = config.logger;
|
|
41
|
+
this.silent = config.silent;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a log level should be output based on configuration.
|
|
45
|
+
* @param level - The log level to check
|
|
46
|
+
* @returns True if the level should be logged
|
|
47
|
+
*/
|
|
48
|
+
shouldLog(level) {
|
|
49
|
+
return !this.silent && this.level <= logLevelMap[level];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if debug logging is enabled.
|
|
53
|
+
* @returns True if debug logs should be output
|
|
54
|
+
*/
|
|
55
|
+
isDebug() {
|
|
56
|
+
return this.shouldLog(LogLevel.Debug);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Logs a debug message if debug logging is enabled.
|
|
60
|
+
* @param message - The message to log
|
|
61
|
+
* @param args - Additional arguments to log
|
|
62
|
+
*/
|
|
63
|
+
debug(message, ...args) {
|
|
64
|
+
if (this.isDebug()) {
|
|
65
|
+
this.logger.debug(message, ...args);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if info logging is enabled.
|
|
70
|
+
* @returns True if info logs should be output
|
|
71
|
+
*/
|
|
72
|
+
isInfo() {
|
|
73
|
+
return this.shouldLog(LogLevel.Info);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Logs an info message if info logging is enabled.
|
|
77
|
+
* @param message - The message to log
|
|
78
|
+
* @param args - Additional arguments to log
|
|
79
|
+
*/
|
|
80
|
+
info(message, ...args) {
|
|
81
|
+
if (this.isInfo()) {
|
|
82
|
+
this.logger.info(message, ...args);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Checks if warning logging is enabled.
|
|
87
|
+
* @returns True if warning logs should be output
|
|
88
|
+
*/
|
|
89
|
+
isWarn() {
|
|
90
|
+
return this.shouldLog(LogLevel.Warn);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Logs a warning message if warning logging is enabled.
|
|
94
|
+
* @param message - The message to log
|
|
95
|
+
* @param args - Additional arguments to log
|
|
96
|
+
*/
|
|
97
|
+
warn(message, ...args) {
|
|
98
|
+
if (this.isWarn()) {
|
|
99
|
+
this.logger.warn(message, ...args);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Checks if error logging is enabled.
|
|
104
|
+
* @returns True if error logs should be output
|
|
105
|
+
*/
|
|
106
|
+
isError() {
|
|
107
|
+
return this.shouldLog(LogLevel.Error);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Logs an error message if error logging is enabled.
|
|
111
|
+
* @param message - The message to log
|
|
112
|
+
* @param args - Additional arguments to log
|
|
113
|
+
*/
|
|
114
|
+
error(message, ...args) {
|
|
115
|
+
if (this.isError()) {
|
|
116
|
+
this.logger.error(message, ...args);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export function createLogger(config) {
|
|
121
|
+
var _a, _b, _c;
|
|
122
|
+
if (config == null) {
|
|
123
|
+
return defaultLogger;
|
|
124
|
+
}
|
|
125
|
+
if (config instanceof Logger) {
|
|
126
|
+
return config;
|
|
127
|
+
}
|
|
128
|
+
config = config !== null && config !== void 0 ? config : {};
|
|
129
|
+
(_a = config.level) !== null && _a !== void 0 ? _a : (config.level = LogLevel.Info);
|
|
130
|
+
(_b = config.logger) !== null && _b !== void 0 ? _b : (config.logger = new ConsoleLogger());
|
|
131
|
+
(_c = config.silent) !== null && _c !== void 0 ? _c : (config.silent = true);
|
|
132
|
+
return new Logger(config);
|
|
133
|
+
}
|
|
134
|
+
const defaultLogger = new Logger({
|
|
135
|
+
level: LogLevel.Info,
|
|
136
|
+
logger: new ConsoleLogger(),
|
|
137
|
+
silent: true,
|
|
138
|
+
});
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.12";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.
|
|
1
|
+
export const SDK_VERSION = "0.1.12";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@credal/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": "github:credal-ai/credal-typescript-sdk",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"test:unit": "vitest --project unit",
|
|
43
43
|
"test:wire": "vitest --project wire"
|
|
44
44
|
},
|
|
45
|
+
"dependencies": {},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"webpack": "^5.97.1",
|
|
47
48
|
"ts-loader": "^9.5.1",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"path": false,
|
|
58
59
|
"stream": false
|
|
59
60
|
},
|
|
60
|
-
"packageManager": "pnpm@10.
|
|
61
|
+
"packageManager": "pnpm@10.20.0",
|
|
61
62
|
"engines": {
|
|
62
63
|
"node": ">=18.0.0"
|
|
63
64
|
},
|
package/reference.md
CHANGED
|
@@ -58,7 +58,7 @@ await client.copilots.createCopilot({
|
|
|
58
58
|
<dl>
|
|
59
59
|
<dd>
|
|
60
60
|
|
|
61
|
-
**requestOptions:** `
|
|
61
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
62
62
|
|
|
63
63
|
</dd>
|
|
64
64
|
</dl>
|
|
@@ -124,7 +124,7 @@ await client.copilots.createConversation({
|
|
|
124
124
|
<dl>
|
|
125
125
|
<dd>
|
|
126
126
|
|
|
127
|
-
**requestOptions:** `
|
|
127
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
128
128
|
|
|
129
129
|
</dd>
|
|
130
130
|
</dl>
|
|
@@ -182,7 +182,7 @@ await client.copilots.provideMessageFeedback({
|
|
|
182
182
|
<dl>
|
|
183
183
|
<dd>
|
|
184
184
|
|
|
185
|
-
**requestOptions:** `
|
|
185
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
186
186
|
|
|
187
187
|
</dd>
|
|
188
188
|
</dl>
|
|
@@ -242,7 +242,7 @@ await client.copilots.sendMessage({
|
|
|
242
242
|
<dl>
|
|
243
243
|
<dd>
|
|
244
244
|
|
|
245
|
-
**requestOptions:** `
|
|
245
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
246
246
|
|
|
247
247
|
</dd>
|
|
248
248
|
</dl>
|
|
@@ -319,7 +319,7 @@ for await (const item of response) {
|
|
|
319
319
|
<dl>
|
|
320
320
|
<dd>
|
|
321
321
|
|
|
322
|
-
**requestOptions:** `
|
|
322
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
323
323
|
|
|
324
324
|
</dd>
|
|
325
325
|
</dl>
|
|
@@ -385,7 +385,7 @@ await client.copilots.addCollectionToCopilot({
|
|
|
385
385
|
<dl>
|
|
386
386
|
<dd>
|
|
387
387
|
|
|
388
|
-
**requestOptions:** `
|
|
388
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
389
389
|
|
|
390
390
|
</dd>
|
|
391
391
|
</dl>
|
|
@@ -451,7 +451,7 @@ await client.copilots.removeCollectionFromCopilot({
|
|
|
451
451
|
<dl>
|
|
452
452
|
<dd>
|
|
453
453
|
|
|
454
|
-
**requestOptions:** `
|
|
454
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
455
455
|
|
|
456
456
|
</dd>
|
|
457
457
|
</dl>
|
|
@@ -525,7 +525,7 @@ await client.copilots.updateConfiguration({
|
|
|
525
525
|
<dl>
|
|
526
526
|
<dd>
|
|
527
527
|
|
|
528
|
-
**requestOptions:** `
|
|
528
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
529
529
|
|
|
530
530
|
</dd>
|
|
531
531
|
</dl>
|
|
@@ -576,7 +576,7 @@ await client.copilots.deleteCopilot({
|
|
|
576
576
|
<dl>
|
|
577
577
|
<dd>
|
|
578
578
|
|
|
579
|
-
**requestOptions:** `
|
|
579
|
+
**requestOptions:** `CopilotsClient.RequestOptions`
|
|
580
580
|
|
|
581
581
|
</dd>
|
|
582
582
|
</dl>
|
|
@@ -632,7 +632,7 @@ await client.documentCatalog.uploadDocumentContents({
|
|
|
632
632
|
<dl>
|
|
633
633
|
<dd>
|
|
634
634
|
|
|
635
|
-
**requestOptions:** `
|
|
635
|
+
**requestOptions:** `DocumentCatalogClient.RequestOptions`
|
|
636
636
|
|
|
637
637
|
</dd>
|
|
638
638
|
</dl>
|
|
@@ -698,7 +698,7 @@ await client.documentCatalog.syncSourceByUrl({
|
|
|
698
698
|
<dl>
|
|
699
699
|
<dd>
|
|
700
700
|
|
|
701
|
-
**requestOptions:** `
|
|
701
|
+
**requestOptions:** `DocumentCatalogClient.RequestOptions`
|
|
702
702
|
|
|
703
703
|
</dd>
|
|
704
704
|
</dl>
|
|
@@ -784,7 +784,7 @@ await client.documentCatalog.metadata({
|
|
|
784
784
|
<dl>
|
|
785
785
|
<dd>
|
|
786
786
|
|
|
787
|
-
**requestOptions:** `
|
|
787
|
+
**requestOptions:** `DocumentCatalogClient.RequestOptions`
|
|
788
788
|
|
|
789
789
|
</dd>
|
|
790
790
|
</dl>
|
|
@@ -859,7 +859,7 @@ await client.documentCollections.addDocumentsToCollection({
|
|
|
859
859
|
<dl>
|
|
860
860
|
<dd>
|
|
861
861
|
|
|
862
|
-
**requestOptions:** `
|
|
862
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
863
863
|
|
|
864
864
|
</dd>
|
|
865
865
|
</dl>
|
|
@@ -933,7 +933,7 @@ await client.documentCollections.removeDocumentsFromCollection({
|
|
|
933
933
|
<dl>
|
|
934
934
|
<dd>
|
|
935
935
|
|
|
936
|
-
**requestOptions:** `
|
|
936
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
937
937
|
|
|
938
938
|
</dd>
|
|
939
939
|
</dl>
|
|
@@ -998,7 +998,7 @@ await client.documentCollections.listDocumentsInCollection({
|
|
|
998
998
|
<dl>
|
|
999
999
|
<dd>
|
|
1000
1000
|
|
|
1001
|
-
**requestOptions:** `
|
|
1001
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
1002
1002
|
|
|
1003
1003
|
</dd>
|
|
1004
1004
|
</dl>
|
|
@@ -1068,7 +1068,7 @@ await client.documentCollections.createCollection({
|
|
|
1068
1068
|
<dl>
|
|
1069
1069
|
<dd>
|
|
1070
1070
|
|
|
1071
|
-
**requestOptions:** `
|
|
1071
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
1072
1072
|
|
|
1073
1073
|
</dd>
|
|
1074
1074
|
</dl>
|
|
@@ -1133,7 +1133,7 @@ await client.documentCollections.deleteCollection({
|
|
|
1133
1133
|
<dl>
|
|
1134
1134
|
<dd>
|
|
1135
1135
|
|
|
1136
|
-
**requestOptions:** `
|
|
1136
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
1137
1137
|
|
|
1138
1138
|
</dd>
|
|
1139
1139
|
</dl>
|
|
@@ -1214,7 +1214,7 @@ await client.documentCollections.createMongoCollectionSync({
|
|
|
1214
1214
|
<dl>
|
|
1215
1215
|
<dd>
|
|
1216
1216
|
|
|
1217
|
-
**requestOptions:** `
|
|
1217
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
1218
1218
|
|
|
1219
1219
|
</dd>
|
|
1220
1220
|
</dl>
|
|
@@ -1295,7 +1295,7 @@ await client.documentCollections.updateMongoCollectionSync({
|
|
|
1295
1295
|
<dl>
|
|
1296
1296
|
<dd>
|
|
1297
1297
|
|
|
1298
|
-
**requestOptions:** `
|
|
1298
|
+
**requestOptions:** `DocumentCollectionsClient.RequestOptions`
|
|
1299
1299
|
|
|
1300
1300
|
</dd>
|
|
1301
1301
|
</dl>
|
|
@@ -1376,7 +1376,7 @@ await client.search.searchDocumentCollection({
|
|
|
1376
1376
|
<dl>
|
|
1377
1377
|
<dd>
|
|
1378
1378
|
|
|
1379
|
-
**requestOptions:** `
|
|
1379
|
+
**requestOptions:** `SearchClient.RequestOptions`
|
|
1380
1380
|
|
|
1381
1381
|
</dd>
|
|
1382
1382
|
</dl>
|
|
@@ -1452,7 +1452,7 @@ await client.users.metadata([{
|
|
|
1452
1452
|
<dl>
|
|
1453
1453
|
<dd>
|
|
1454
1454
|
|
|
1455
|
-
**requestOptions:** `
|
|
1455
|
+
**requestOptions:** `UsersClient.RequestOptions`
|
|
1456
1456
|
|
|
1457
1457
|
</dd>
|
|
1458
1458
|
</dl>
|