@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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.BearerAuthProvider = void 0;
|
|
47
|
+
const core = __importStar(require("../core/index.js"));
|
|
48
|
+
const errors = __importStar(require("../errors/index.js"));
|
|
49
|
+
class BearerAuthProvider {
|
|
50
|
+
constructor(options) {
|
|
51
|
+
this.token = options.apiKey;
|
|
52
|
+
}
|
|
53
|
+
static canCreate(options) {
|
|
54
|
+
var _a;
|
|
55
|
+
return options.apiKey != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a.CREDAL_API_KEY) != null;
|
|
56
|
+
}
|
|
57
|
+
getAuthRequest(_arg) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const apiKey = (_a = (yield core.Supplier.get(this.token))) !== null && _a !== void 0 ? _a : (_b = process.env) === null || _b === void 0 ? void 0 : _b.CREDAL_API_KEY;
|
|
61
|
+
if (apiKey == null) {
|
|
62
|
+
throw new errors.CredalError({
|
|
63
|
+
message: "Please specify a apiKey by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.BearerAuthProvider = BearerAuthProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BearerAuthProvider = void 0;
|
|
4
|
+
var BearerAuthProvider_js_1 = require("./BearerAuthProvider.js");
|
|
5
|
+
Object.defineProperty(exports, "BearerAuthProvider", { enumerable: true, get: function () { return BearerAuthProvider_js_1.BearerAuthProvider; } });
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "../fetcher/EndpointMetadata.js";
|
|
1
2
|
import type { AuthRequest } from "./AuthRequest.js";
|
|
2
3
|
export interface AuthProvider {
|
|
3
|
-
getAuthRequest(
|
|
4
|
+
getAuthRequest(arg?: {
|
|
5
|
+
endpointMetadata?: EndpointMetadata;
|
|
6
|
+
}): Promise<AuthRequest>;
|
|
4
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
2
3
|
export declare const BearerToken: {
|
|
3
|
-
toAuthorizationHeader:
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
4
5
|
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
5
6
|
};
|
|
7
|
+
export {};
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BearerToken = void 0;
|
|
4
4
|
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
5
|
+
function toAuthorizationHeader(token) {
|
|
6
|
+
if (token == null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return `Bearer ${token}`;
|
|
10
|
+
}
|
|
5
11
|
exports.BearerToken = {
|
|
6
|
-
toAuthorizationHeader:
|
|
7
|
-
if (token == null) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
return `Bearer ${token}`;
|
|
11
|
-
},
|
|
12
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
12
13
|
fromAuthorizationHeader: (header) => {
|
|
13
14
|
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
14
15
|
},
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.13";
|
package/dist/cjs/version.js
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/esm/BaseClient.mjs
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import { BearerAuthProvider } from "./auth/BearerAuthProvider.mjs";
|
|
2
3
|
import { mergeHeaders } from "./core/headers.mjs";
|
|
3
4
|
import * as core from "./core/index.mjs";
|
|
4
5
|
export function normalizeClientOptions(options) {
|
|
5
6
|
const headers = mergeHeaders({
|
|
6
7
|
"X-Fern-Language": "JavaScript",
|
|
7
8
|
"X-Fern-SDK-Name": "@credal/sdk",
|
|
8
|
-
"X-Fern-SDK-Version": "0.1.
|
|
9
|
-
"User-Agent": "@credal/sdk/0.1.
|
|
9
|
+
"X-Fern-SDK-Version": "0.1.13",
|
|
10
|
+
"User-Agent": "@credal/sdk/0.1.13",
|
|
10
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
11
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
12
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
13
14
|
return Object.assign(Object.assign({}, options), { logging: core.logging.createLogger(options === null || options === void 0 ? void 0 : options.logging), headers });
|
|
14
15
|
}
|
|
16
|
+
export function normalizeClientOptionsWithAuth(options) {
|
|
17
|
+
var _a;
|
|
18
|
+
const normalized = normalizeClientOptions(options);
|
|
19
|
+
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new BearerAuthProvider(options));
|
|
20
|
+
return normalized;
|
|
21
|
+
}
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ import { DocumentCollectionsClient } from "./api/resources/documentCollections/c
|
|
|
4
4
|
import { SearchClient } from "./api/resources/search/client/Client.mjs";
|
|
5
5
|
import { UsersClient } from "./api/resources/users/client/Client.mjs";
|
|
6
6
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
|
|
7
|
+
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.mjs";
|
|
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/esm/Client.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import { DocumentCatalogClient } from "./api/resources/documentCatalog/client/Cl
|
|
|
4
4
|
import { DocumentCollectionsClient } from "./api/resources/documentCollections/client/Client.mjs";
|
|
5
5
|
import { SearchClient } from "./api/resources/search/client/Client.mjs";
|
|
6
6
|
import { UsersClient } from "./api/resources/users/client/Client.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs";
|
|
8
8
|
export class CredalClient {
|
|
9
9
|
constructor(options = {}) {
|
|
10
|
-
this._options =
|
|
10
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
11
11
|
}
|
|
12
12
|
get copilots() {
|
|
13
13
|
var _a;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import type * as Credal from "../../../index.mjs";
|
|
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
|
}
|
|
@@ -8,14 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
12
|
-
import { mergeHeaders
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
15
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
16
|
export class CopilotsClient {
|
|
17
17
|
constructor(options = {}) {
|
|
18
|
-
this._options =
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Create a new agent. The API key used will be added to the agent for future Requests
|
|
@@ -39,7 +39,8 @@ export class CopilotsClient {
|
|
|
39
39
|
__createCopilot(request, requestOptions) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
42
|
-
const
|
|
42
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
43
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
43
44
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
44
45
|
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"),
|
|
45
46
|
method: "POST",
|
|
@@ -99,7 +100,8 @@ export class CopilotsClient {
|
|
|
99
100
|
__createConversation(request, requestOptions) {
|
|
100
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
102
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
102
|
-
const
|
|
103
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
104
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
103
105
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
104
106
|
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"),
|
|
105
107
|
method: "POST",
|
|
@@ -163,7 +165,8 @@ export class CopilotsClient {
|
|
|
163
165
|
__provideMessageFeedback(request, requestOptions) {
|
|
164
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
167
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
166
|
-
const
|
|
168
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
169
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
167
170
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
168
171
|
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"),
|
|
169
172
|
method: "POST",
|
|
@@ -229,7 +232,8 @@ export class CopilotsClient {
|
|
|
229
232
|
__sendMessage(request, requestOptions) {
|
|
230
233
|
return __awaiter(this, void 0, void 0, function* () {
|
|
231
234
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
232
|
-
const
|
|
235
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
236
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
233
237
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
234
238
|
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"),
|
|
235
239
|
method: "POST",
|
|
@@ -280,7 +284,8 @@ export class CopilotsClient {
|
|
|
280
284
|
__streamMessage(request, requestOptions) {
|
|
281
285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
282
286
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
283
|
-
const
|
|
287
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
288
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
284
289
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
285
290
|
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"),
|
|
286
291
|
method: "POST",
|
|
@@ -352,7 +357,8 @@ export class CopilotsClient {
|
|
|
352
357
|
__addCollectionToCopilot(request, requestOptions) {
|
|
353
358
|
return __awaiter(this, void 0, void 0, function* () {
|
|
354
359
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
355
|
-
const
|
|
360
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
361
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
356
362
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
357
363
|
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"),
|
|
358
364
|
method: "POST",
|
|
@@ -412,7 +418,8 @@ export class CopilotsClient {
|
|
|
412
418
|
__removeCollectionFromCopilot(request, requestOptions) {
|
|
413
419
|
return __awaiter(this, void 0, void 0, function* () {
|
|
414
420
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
415
|
-
const
|
|
421
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
422
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
416
423
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
417
424
|
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"),
|
|
418
425
|
method: "POST",
|
|
@@ -480,7 +487,8 @@ export class CopilotsClient {
|
|
|
480
487
|
__updateConfiguration(request, requestOptions) {
|
|
481
488
|
return __awaiter(this, void 0, void 0, function* () {
|
|
482
489
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
483
|
-
const
|
|
490
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
491
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
484
492
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
485
493
|
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"),
|
|
486
494
|
method: "POST",
|
|
@@ -537,7 +545,8 @@ export class CopilotsClient {
|
|
|
537
545
|
__deleteCopilot(request, requestOptions) {
|
|
538
546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
539
547
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
540
|
-
const
|
|
548
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
549
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
541
550
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
542
551
|
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"),
|
|
543
552
|
method: "DELETE",
|
|
@@ -579,16 +588,4 @@ export class CopilotsClient {
|
|
|
579
588
|
}
|
|
580
589
|
});
|
|
581
590
|
}
|
|
582
|
-
_getAuthorizationHeader() {
|
|
583
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
584
|
-
var _a;
|
|
585
|
-
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;
|
|
586
|
-
if (bearer == null) {
|
|
587
|
-
throw new errors.CredalError({
|
|
588
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
return `Bearer ${bearer}`;
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
591
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import type * as Credal from "../../../index.mjs";
|
|
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
|
}
|
|
@@ -8,14 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
12
|
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
15
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
16
|
export class DocumentCatalogClient {
|
|
17
17
|
constructor(options = {}) {
|
|
18
|
-
this._options =
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* @param {Credal.UploadDocumentContentsRequest} request
|
|
@@ -36,7 +36,8 @@ export class DocumentCatalogClient {
|
|
|
36
36
|
__uploadDocumentContents(request, requestOptions) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
39
|
-
const
|
|
39
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
40
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
40
41
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
41
42
|
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"),
|
|
42
43
|
method: "POST",
|
|
@@ -122,7 +123,8 @@ export class DocumentCatalogClient {
|
|
|
122
123
|
_request.append("awaitVectorStoreSync", request.awaitVectorStoreSync);
|
|
123
124
|
}
|
|
124
125
|
const _maybeEncodedRequest = yield _request.getRequest();
|
|
125
|
-
const
|
|
126
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
127
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, _maybeEncodedRequest.headers)), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
126
128
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
127
129
|
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"),
|
|
128
130
|
method: "POST",
|
|
@@ -182,7 +184,8 @@ export class DocumentCatalogClient {
|
|
|
182
184
|
__syncSourceByUrl(request, requestOptions) {
|
|
183
185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
186
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
185
|
-
const
|
|
187
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
188
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
186
189
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
187
190
|
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"),
|
|
188
191
|
method: "POST",
|
|
@@ -262,7 +265,8 @@ export class DocumentCatalogClient {
|
|
|
262
265
|
__metadata(request, requestOptions) {
|
|
263
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
264
267
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
265
|
-
const
|
|
268
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
269
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
266
270
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
267
271
|
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"),
|
|
268
272
|
method: "PATCH",
|
|
@@ -304,16 +308,4 @@ export class DocumentCatalogClient {
|
|
|
304
308
|
}
|
|
305
309
|
});
|
|
306
310
|
}
|
|
307
|
-
_getAuthorizationHeader() {
|
|
308
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
var _a;
|
|
310
|
-
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;
|
|
311
|
-
if (bearer == null) {
|
|
312
|
-
throw new errors.CredalError({
|
|
313
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
return `Bearer ${bearer}`;
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
311
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import type * as Credal from "../../../index.mjs";
|
|
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
|
}
|
|
@@ -8,14 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
import {
|
|
12
|
-
import { mergeHeaders
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
13
|
import * as core from "../../../../core/index.mjs";
|
|
14
14
|
import * as environments from "../../../../environments.mjs";
|
|
15
15
|
import * as errors from "../../../../errors/index.mjs";
|
|
16
16
|
export class DocumentCollectionsClient {
|
|
17
17
|
constructor(options = {}) {
|
|
18
|
-
this._options =
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* 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.
|
|
@@ -43,7 +43,8 @@ export class DocumentCollectionsClient {
|
|
|
43
43
|
__addDocumentsToCollection(request, requestOptions) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
46
|
-
const
|
|
46
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
47
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
47
48
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
48
49
|
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"),
|
|
49
50
|
method: "POST",
|
|
@@ -111,7 +112,8 @@ export class DocumentCollectionsClient {
|
|
|
111
112
|
__removeDocumentsFromCollection(request, requestOptions) {
|
|
112
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
114
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
114
|
-
const
|
|
115
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
116
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
115
117
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
116
118
|
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"),
|
|
117
119
|
method: "DELETE",
|
|
@@ -173,7 +175,8 @@ export class DocumentCollectionsClient {
|
|
|
173
175
|
const { collectionId } = request;
|
|
174
176
|
const _queryParams = {};
|
|
175
177
|
_queryParams.collectionId = collectionId;
|
|
176
|
-
const
|
|
178
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
179
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
177
180
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
178
181
|
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"),
|
|
179
182
|
method: "GET",
|
|
@@ -237,7 +240,8 @@ export class DocumentCollectionsClient {
|
|
|
237
240
|
__createCollection(request, requestOptions) {
|
|
238
241
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
242
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
240
|
-
const
|
|
243
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
244
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
241
245
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
242
246
|
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"),
|
|
243
247
|
method: "POST",
|
|
@@ -296,7 +300,8 @@ export class DocumentCollectionsClient {
|
|
|
296
300
|
__deleteCollection(request, requestOptions) {
|
|
297
301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
298
302
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
299
|
-
const
|
|
303
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
304
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
300
305
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
301
306
|
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"),
|
|
302
307
|
method: "DELETE",
|
|
@@ -371,7 +376,8 @@ export class DocumentCollectionsClient {
|
|
|
371
376
|
__createMongoCollectionSync(request, requestOptions) {
|
|
372
377
|
return __awaiter(this, void 0, void 0, function* () {
|
|
373
378
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
374
|
-
const
|
|
379
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
380
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
375
381
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
376
382
|
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"),
|
|
377
383
|
method: "POST",
|
|
@@ -446,7 +452,8 @@ export class DocumentCollectionsClient {
|
|
|
446
452
|
__updateMongoCollectionSync(request, requestOptions) {
|
|
447
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
448
454
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
449
|
-
const
|
|
455
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
456
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
450
457
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
451
458
|
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"),
|
|
452
459
|
method: "POST",
|
|
@@ -488,16 +495,4 @@ export class DocumentCollectionsClient {
|
|
|
488
495
|
}
|
|
489
496
|
});
|
|
490
497
|
}
|
|
491
|
-
_getAuthorizationHeader() {
|
|
492
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
493
|
-
var _a;
|
|
494
|
-
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;
|
|
495
|
-
if (bearer == null) {
|
|
496
|
-
throw new errors.CredalError({
|
|
497
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
return `Bearer ${bearer}`;
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
498
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
2
3
|
import * as core from "../../../../core/index.mjs";
|
|
3
4
|
import type * as Credal from "../../../index.mjs";
|
|
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
|
}
|