@credal/sdk 0.1.12 → 0.1.13
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 +9 -1
- package/dist/cjs/BaseClient.js +10 -2
- package/dist/cjs/Client.d.ts +2 -1
- package/dist/cjs/Client.js +1 -1
- package/dist/cjs/api/resources/copilots/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/copilots/client/Client.js +19 -22
- package/dist/cjs/api/resources/documentCatalog/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/documentCatalog/client/Client.js +9 -17
- package/dist/cjs/api/resources/documentCollections/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/documentCollections/client/Client.js +15 -20
- package/dist/cjs/api/resources/search/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/search/client/Client.js +3 -14
- package/dist/cjs/api/resources/users/client/Client.d.ts +2 -2
- package/dist/cjs/api/resources/users/client/Client.js +3 -14
- package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -0
- package/dist/cjs/auth/BearerAuthProvider.js +72 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +4 -1
- package/dist/cjs/core/auth/BearerToken.d.ts +3 -1
- package/dist/cjs/core/auth/BearerToken.js +7 -6
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +9 -1
- package/dist/esm/BaseClient.mjs +9 -2
- package/dist/esm/Client.d.mts +2 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/copilots/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/copilots/client/Client.mjs +21 -24
- package/dist/esm/api/resources/documentCatalog/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/documentCatalog/client/Client.mjs +10 -18
- package/dist/esm/api/resources/documentCollections/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/documentCollections/client/Client.mjs +17 -22
- package/dist/esm/api/resources/search/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/search/client/Client.mjs +5 -16
- package/dist/esm/api/resources/users/client/Client.d.mts +2 -2
- package/dist/esm/api/resources/users/client/Client.mjs +5 -16
- package/dist/esm/auth/BearerAuthProvider.d.mts +14 -0
- package/dist/esm/auth/BearerAuthProvider.mjs +35 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +4 -1
- package/dist/esm/core/auth/BearerToken.d.mts +3 -1
- package/dist/esm/core/auth/BearerToken.mjs +7 -6
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/dist/cjs/BaseClient.d.ts
CHANGED
|
@@ -29,4 +29,12 @@ export interface BaseRequestOptions {
|
|
|
29
29
|
/** Additional headers to include in the request. */
|
|
30
30
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
|
|
33
|
+
logging: core.logging.Logger;
|
|
34
|
+
authProvider?: core.AuthProvider;
|
|
35
|
+
};
|
|
36
|
+
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
37
|
+
authProvider: core.AuthProvider;
|
|
38
|
+
};
|
|
39
|
+
export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
40
|
+
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -35,16 +35,24 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.normalizeClientOptions = normalizeClientOptions;
|
|
38
|
+
exports.normalizeClientOptionsWithAuth = normalizeClientOptionsWithAuth;
|
|
39
|
+
const BearerAuthProvider_js_1 = require("./auth/BearerAuthProvider.js");
|
|
38
40
|
const headers_js_1 = require("./core/headers.js");
|
|
39
41
|
const core = __importStar(require("./core/index.js"));
|
|
40
42
|
function normalizeClientOptions(options) {
|
|
41
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
42
44
|
"X-Fern-Language": "JavaScript",
|
|
43
45
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
44
|
-
"X-Fern-SDK-Version": "0.1.
|
|
45
|
-
"User-Agent": "@credal/sdk/0.1.
|
|
46
|
+
"X-Fern-SDK-Version": "0.1.13",
|
|
47
|
+
"User-Agent": "@credal/sdk/0.1.13",
|
|
46
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
47
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
48
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
49
51
|
return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
|
|
50
52
|
}
|
|
53
|
+
function normalizeClientOptionsWithAuth(options) {
|
|
54
|
+
var _a;
|
|
55
|
+
const normalized = normalizeClientOptions(options);
|
|
56
|
+
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider_js_1.BearerAuthProvider(options));
|
|
57
|
+
return normalized;
|
|
58
|
+
}
|
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { DocumentCollectionsClient } from "./api/resources/documentCollections/c
|
|
|
4
4
|
import { SearchClient } from "./api/resources/search/client/Client.js";
|
|
5
5
|
import { UsersClient } from "./api/resources/users/client/Client.js";
|
|
6
6
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
7
|
+
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
|
|
7
8
|
export declare namespace CredalClient {
|
|
8
9
|
interface Options extends BaseClientOptions {
|
|
9
10
|
}
|
|
@@ -11,7 +12,7 @@ export declare namespace CredalClient {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
export declare class CredalClient {
|
|
14
|
-
protected readonly _options: CredalClient.Options
|
|
15
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<CredalClient.Options>;
|
|
15
16
|
protected _copilots: CopilotsClient | undefined;
|
|
16
17
|
protected _documentCatalog: DocumentCatalogClient | undefined;
|
|
17
18
|
protected _documentCollections: DocumentCollectionsClient | undefined;
|
package/dist/cjs/Client.js
CHANGED
|
@@ -10,7 +10,7 @@ const Client_js_5 = require("./api/resources/users/client/Client.js");
|
|
|
10
10
|
const BaseClient_js_1 = require("./BaseClient.js");
|
|
11
11
|
class CredalClient {
|
|
12
12
|
constructor(options = {}) {
|
|
13
|
-
this._options = (0, BaseClient_js_1.
|
|
13
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
14
14
|
}
|
|
15
15
|
get copilots() {
|
|
16
16
|
var _a;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
2
3
|
import * as core from "../../../../core/index.js";
|
|
3
4
|
import type * as Credal from "../../../index.js";
|
|
4
5
|
export declare namespace CopilotsClient {
|
|
@@ -8,7 +9,7 @@ export declare namespace CopilotsClient {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
export declare class CopilotsClient {
|
|
11
|
-
protected readonly _options: CopilotsClient.Options
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<CopilotsClient.Options>;
|
|
12
13
|
constructor(options?: CopilotsClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* Create a new agent. The API key used will be added to the agent for future Requests
|
|
@@ -146,5 +147,4 @@ export declare class CopilotsClient {
|
|
|
146
147
|
*/
|
|
147
148
|
deleteCopilot(request: Credal.DeleteCopilotRequest, requestOptions?: CopilotsClient.RequestOptions): core.HttpResponsePromise<Credal.DeleteCopilotResponse>;
|
|
148
149
|
private __deleteCopilot;
|
|
149
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
150
150
|
}
|
|
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
51
51
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
52
|
class CopilotsClient {
|
|
53
53
|
constructor(options = {}) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Create a new agent. The API key used will be added to the agent for future Requests
|
|
@@ -75,7 +75,8 @@ class CopilotsClient {
|
|
|
75
75
|
__createCopilot(request, requestOptions) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
77
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
78
|
-
const
|
|
78
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
79
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
79
80
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
80
81
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/createCopilot"),
|
|
81
82
|
method: "POST",
|
|
@@ -135,7 +136,8 @@ class CopilotsClient {
|
|
|
135
136
|
__createConversation(request, requestOptions) {
|
|
136
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
138
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
138
|
-
const
|
|
139
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
140
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
139
141
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
140
142
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/createConversation"),
|
|
141
143
|
method: "POST",
|
|
@@ -199,7 +201,8 @@ class CopilotsClient {
|
|
|
199
201
|
__provideMessageFeedback(request, requestOptions) {
|
|
200
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
203
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
202
|
-
const
|
|
204
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
205
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
203
206
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
204
207
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/provideMessageFeedback"),
|
|
205
208
|
method: "POST",
|
|
@@ -265,7 +268,8 @@ class CopilotsClient {
|
|
|
265
268
|
__sendMessage(request, requestOptions) {
|
|
266
269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
267
270
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
268
|
-
const
|
|
271
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
272
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
269
273
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
270
274
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/sendMessage"),
|
|
271
275
|
method: "POST",
|
|
@@ -316,7 +320,8 @@ class CopilotsClient {
|
|
|
316
320
|
__streamMessage(request, requestOptions) {
|
|
317
321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
318
322
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
319
|
-
const
|
|
323
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
324
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
320
325
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
321
326
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/streamMessage"),
|
|
322
327
|
method: "POST",
|
|
@@ -388,7 +393,8 @@ class CopilotsClient {
|
|
|
388
393
|
__addCollectionToCopilot(request, requestOptions) {
|
|
389
394
|
return __awaiter(this, void 0, void 0, function* () {
|
|
390
395
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
391
|
-
const
|
|
396
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
397
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
392
398
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
393
399
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/addCollectionToCopilot"),
|
|
394
400
|
method: "POST",
|
|
@@ -448,7 +454,8 @@ class CopilotsClient {
|
|
|
448
454
|
__removeCollectionFromCopilot(request, requestOptions) {
|
|
449
455
|
return __awaiter(this, void 0, void 0, function* () {
|
|
450
456
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
451
|
-
const
|
|
457
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
458
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
452
459
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
453
460
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/removeCollectionFromCopilot"),
|
|
454
461
|
method: "POST",
|
|
@@ -516,7 +523,8 @@ class CopilotsClient {
|
|
|
516
523
|
__updateConfiguration(request, requestOptions) {
|
|
517
524
|
return __awaiter(this, void 0, void 0, function* () {
|
|
518
525
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
519
|
-
const
|
|
526
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
527
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
520
528
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
521
529
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/updateConfiguration"),
|
|
522
530
|
method: "POST",
|
|
@@ -573,7 +581,8 @@ class CopilotsClient {
|
|
|
573
581
|
__deleteCopilot(request, requestOptions) {
|
|
574
582
|
return __awaiter(this, void 0, void 0, function* () {
|
|
575
583
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
576
|
-
const
|
|
584
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
585
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
577
586
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
578
587
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/copilots/deleteCopilot"),
|
|
579
588
|
method: "DELETE",
|
|
@@ -615,17 +624,5 @@ class CopilotsClient {
|
|
|
615
624
|
}
|
|
616
625
|
});
|
|
617
626
|
}
|
|
618
|
-
_getAuthorizationHeader() {
|
|
619
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
620
|
-
var _a;
|
|
621
|
-
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
|
|
622
|
-
if (bearer == null) {
|
|
623
|
-
throw new errors.CredalError({
|
|
624
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
return `Bearer ${bearer}`;
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
627
|
}
|
|
631
628
|
exports.CopilotsClient = CopilotsClient;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
2
3
|
import * as core from "../../../../core/index.js";
|
|
3
4
|
import type * as Credal from "../../../index.js";
|
|
4
5
|
export declare namespace DocumentCatalogClient {
|
|
@@ -8,7 +9,7 @@ export declare namespace DocumentCatalogClient {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
export declare class DocumentCatalogClient {
|
|
11
|
-
protected readonly _options: DocumentCatalogClient.Options
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<DocumentCatalogClient.Options>;
|
|
12
13
|
constructor(options?: DocumentCatalogClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* @param {Credal.UploadDocumentContentsRequest} request
|
|
@@ -81,5 +82,4 @@ export declare class DocumentCatalogClient {
|
|
|
81
82
|
*/
|
|
82
83
|
metadata(request: Credal.DocumentMetadataPatchRequest, requestOptions?: DocumentCatalogClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
83
84
|
private __metadata;
|
|
84
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
85
85
|
}
|
|
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
51
51
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
52
|
class DocumentCatalogClient {
|
|
53
53
|
constructor(options = {}) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* @param {Credal.UploadDocumentContentsRequest} request
|
|
@@ -72,7 +72,8 @@ class DocumentCatalogClient {
|
|
|
72
72
|
__uploadDocumentContents(request, requestOptions) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
75
|
-
const
|
|
75
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
76
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
76
77
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
77
78
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/uploadDocumentContents"),
|
|
78
79
|
method: "POST",
|
|
@@ -158,7 +159,8 @@ class DocumentCatalogClient {
|
|
|
158
159
|
_request.append("awaitVectorStoreSync", request.awaitVectorStoreSync);
|
|
159
160
|
}
|
|
160
161
|
const _maybeEncodedRequest = yield _request.getRequest();
|
|
161
|
-
const
|
|
162
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
163
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
162
164
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
163
165
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/uploadFile"),
|
|
164
166
|
method: "POST",
|
|
@@ -218,7 +220,8 @@ class DocumentCatalogClient {
|
|
|
218
220
|
__syncSourceByUrl(request, requestOptions) {
|
|
219
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
222
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
221
|
-
const
|
|
223
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
224
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
222
225
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
223
226
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/syncSourceByUrl"),
|
|
224
227
|
method: "POST",
|
|
@@ -298,7 +301,8 @@ class DocumentCatalogClient {
|
|
|
298
301
|
__metadata(request, requestOptions) {
|
|
299
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
303
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
301
|
-
const
|
|
304
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
305
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
302
306
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
303
307
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/catalog/metadata"),
|
|
304
308
|
method: "PATCH",
|
|
@@ -340,17 +344,5 @@ class DocumentCatalogClient {
|
|
|
340
344
|
}
|
|
341
345
|
});
|
|
342
346
|
}
|
|
343
|
-
_getAuthorizationHeader() {
|
|
344
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
345
|
-
var _a;
|
|
346
|
-
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
|
|
347
|
-
if (bearer == null) {
|
|
348
|
-
throw new errors.CredalError({
|
|
349
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
return `Bearer ${bearer}`;
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
347
|
}
|
|
356
348
|
exports.DocumentCatalogClient = DocumentCatalogClient;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
2
3
|
import * as core from "../../../../core/index.js";
|
|
3
4
|
import type * as Credal from "../../../index.js";
|
|
4
5
|
export declare namespace DocumentCollectionsClient {
|
|
@@ -8,7 +9,7 @@ export declare namespace DocumentCollectionsClient {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
export declare class DocumentCollectionsClient {
|
|
11
|
-
protected readonly _options: DocumentCollectionsClient.Options
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<DocumentCollectionsClient.Options>;
|
|
12
13
|
constructor(options?: DocumentCollectionsClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* Add documents to a document collection. Note that the documents must already exist in the document catalog to use this endpoint. If you want to upload a new document to a collection, use the `uploadDocumentContents` endpoint.
|
|
@@ -156,5 +157,4 @@ export declare class DocumentCollectionsClient {
|
|
|
156
157
|
*/
|
|
157
158
|
updateMongoCollectionSync(request: Credal.UpdateMongoCollectionSyncRequest, requestOptions?: DocumentCollectionsClient.RequestOptions): core.HttpResponsePromise<Credal.MongoCollectionSyncResponse>;
|
|
158
159
|
private __updateMongoCollectionSync;
|
|
159
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
160
160
|
}
|
|
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
51
51
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
52
|
class DocumentCollectionsClient {
|
|
53
53
|
constructor(options = {}) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Add documents to a document collection. Note that the documents must already exist in the document catalog to use this endpoint. If you want to upload a new document to a collection, use the `uploadDocumentContents` endpoint.
|
|
@@ -79,7 +79,8 @@ class DocumentCollectionsClient {
|
|
|
79
79
|
__addDocumentsToCollection(request, requestOptions) {
|
|
80
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
81
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
82
|
-
const
|
|
82
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
83
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
83
84
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
84
85
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/addDocumentsToCollection"),
|
|
85
86
|
method: "POST",
|
|
@@ -147,7 +148,8 @@ class DocumentCollectionsClient {
|
|
|
147
148
|
__removeDocumentsFromCollection(request, requestOptions) {
|
|
148
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
150
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
150
|
-
const
|
|
151
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
152
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
151
153
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
152
154
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/removeDocumentsFromCollection"),
|
|
153
155
|
method: "DELETE",
|
|
@@ -209,7 +211,8 @@ class DocumentCollectionsClient {
|
|
|
209
211
|
const { collectionId } = request;
|
|
210
212
|
const _queryParams = {};
|
|
211
213
|
_queryParams.collectionId = collectionId;
|
|
212
|
-
const
|
|
214
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
215
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
213
216
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
214
217
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/listDocumentsInCollection"),
|
|
215
218
|
method: "GET",
|
|
@@ -273,7 +276,8 @@ class DocumentCollectionsClient {
|
|
|
273
276
|
__createCollection(request, requestOptions) {
|
|
274
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
275
278
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
276
|
-
const
|
|
279
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
280
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
277
281
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
278
282
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/createCollection"),
|
|
279
283
|
method: "POST",
|
|
@@ -332,7 +336,8 @@ class DocumentCollectionsClient {
|
|
|
332
336
|
__deleteCollection(request, requestOptions) {
|
|
333
337
|
return __awaiter(this, void 0, void 0, function* () {
|
|
334
338
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
335
|
-
const
|
|
339
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
340
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
336
341
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
337
342
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/deleteCollection"),
|
|
338
343
|
method: "DELETE",
|
|
@@ -407,7 +412,8 @@ class DocumentCollectionsClient {
|
|
|
407
412
|
__createMongoCollectionSync(request, requestOptions) {
|
|
408
413
|
return __awaiter(this, void 0, void 0, function* () {
|
|
409
414
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
410
|
-
const
|
|
415
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
416
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
411
417
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
412
418
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/mongodb/createMongoSync"),
|
|
413
419
|
method: "POST",
|
|
@@ -482,7 +488,8 @@ class DocumentCollectionsClient {
|
|
|
482
488
|
__updateMongoCollectionSync(request, requestOptions) {
|
|
483
489
|
return __awaiter(this, void 0, void 0, function* () {
|
|
484
490
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
485
|
-
const
|
|
491
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
492
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
486
493
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
487
494
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/documentCollections/mongodb/updateMongoSync"),
|
|
488
495
|
method: "POST",
|
|
@@ -524,17 +531,5 @@ class DocumentCollectionsClient {
|
|
|
524
531
|
}
|
|
525
532
|
});
|
|
526
533
|
}
|
|
527
|
-
_getAuthorizationHeader() {
|
|
528
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
529
|
-
var _a;
|
|
530
|
-
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
|
|
531
|
-
if (bearer == null) {
|
|
532
|
-
throw new errors.CredalError({
|
|
533
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
return `Bearer ${bearer}`;
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
534
|
}
|
|
540
535
|
exports.DocumentCollectionsClient = DocumentCollectionsClient;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
2
3
|
import * as core from "../../../../core/index.js";
|
|
3
4
|
import type * as Credal from "../../../index.js";
|
|
4
5
|
export declare namespace SearchClient {
|
|
@@ -8,7 +9,7 @@ export declare namespace SearchClient {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
export declare class SearchClient {
|
|
11
|
-
protected readonly _options: SearchClient.Options
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<SearchClient.Options>;
|
|
12
13
|
constructor(options?: SearchClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* Search across all documents in a document collection using the document metadata and contents.
|
|
@@ -38,5 +39,4 @@ export declare class SearchClient {
|
|
|
38
39
|
*/
|
|
39
40
|
searchDocumentCollection(request: Credal.SearchDocumentCollectionRequest, requestOptions?: SearchClient.RequestOptions): core.HttpResponsePromise<Credal.SearchDocumentCollectionResponse>;
|
|
40
41
|
private __searchDocumentCollection;
|
|
41
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
42
42
|
}
|
|
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
51
51
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
52
|
class SearchClient {
|
|
53
53
|
constructor(options = {}) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Search across all documents in a document collection using the document metadata and contents.
|
|
@@ -85,7 +85,8 @@ class SearchClient {
|
|
|
85
85
|
__searchDocumentCollection(request, requestOptions) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
87
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
88
|
-
const
|
|
88
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
89
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
89
90
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
90
91
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/search/searchDocumentCollection"),
|
|
91
92
|
method: "POST",
|
|
@@ -130,17 +131,5 @@ class SearchClient {
|
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
|
-
_getAuthorizationHeader() {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
var _a;
|
|
136
|
-
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
|
|
137
|
-
if (bearer == null) {
|
|
138
|
-
throw new errors.CredalError({
|
|
139
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
return `Bearer ${bearer}`;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
134
|
}
|
|
146
135
|
exports.SearchClient = SearchClient;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
2
3
|
import * as core from "../../../../core/index.js";
|
|
3
4
|
import type * as Credal from "../../../index.js";
|
|
4
5
|
export declare namespace UsersClient {
|
|
@@ -8,7 +9,7 @@ export declare namespace UsersClient {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
export declare class UsersClient {
|
|
11
|
-
protected readonly _options: UsersClient.Options
|
|
12
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<UsersClient.Options>;
|
|
12
13
|
constructor(options?: UsersClient.Options);
|
|
13
14
|
/**
|
|
14
15
|
* Bulk patch metadata for users
|
|
@@ -33,5 +34,4 @@ export declare class UsersClient {
|
|
|
33
34
|
*/
|
|
34
35
|
metadata(request: Credal.UserMetadataPatch[], requestOptions?: UsersClient.RequestOptions): core.HttpResponsePromise<void>;
|
|
35
36
|
private __metadata;
|
|
36
|
-
protected _getAuthorizationHeader(): Promise<string>;
|
|
37
37
|
}
|
|
@@ -51,7 +51,7 @@ const environments = __importStar(require("../../../../environments.js"));
|
|
|
51
51
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
52
|
class UsersClient {
|
|
53
53
|
constructor(options = {}) {
|
|
54
|
-
this._options = (0, BaseClient_js_1.
|
|
54
|
+
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Bulk patch metadata for users
|
|
@@ -80,7 +80,8 @@ class UsersClient {
|
|
|
80
80
|
__metadata(request, requestOptions) {
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
82
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
83
|
-
const
|
|
83
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
84
|
+
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
84
85
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
85
86
|
url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.CredalEnvironment.Production, "/v0/users/metadata"),
|
|
86
87
|
method: "PATCH",
|
|
@@ -122,17 +123,5 @@ class UsersClient {
|
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
|
-
_getAuthorizationHeader() {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
var _a;
|
|
128
|
-
const bearer = (_a = (yield core.Supplier.get(this._options.apiKey))) !== null && _a !== void 0 ? _a : process === null || process === void 0 ? void 0 : process.env.CREDAL_API_KEY;
|
|
129
|
-
if (bearer == null) {
|
|
130
|
-
throw new errors.CredalError({
|
|
131
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return `Bearer ${bearer}`;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
126
|
}
|
|
138
127
|
exports.UsersClient = UsersClient;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as core from "../core/index.js";
|
|
2
|
+
export declare namespace BearerAuthProvider {
|
|
3
|
+
interface Options {
|
|
4
|
+
apiKey?: core.Supplier<core.BearerToken | undefined>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class BearerAuthProvider implements core.AuthProvider {
|
|
8
|
+
private readonly token;
|
|
9
|
+
constructor(options: BearerAuthProvider.Options);
|
|
10
|
+
static canCreate(options: BearerAuthProvider.Options): boolean;
|
|
11
|
+
getAuthRequest(_arg?: {
|
|
12
|
+
endpointMetadata?: core.EndpointMetadata;
|
|
13
|
+
}): Promise<core.AuthRequest>;
|
|
14
|
+
}
|