@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
|
@@ -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 SearchClient {
|
|
17
17
|
constructor(options = {}) {
|
|
18
|
-
this._options =
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Search across all documents in a document collection using the document metadata and contents.
|
|
@@ -49,7 +49,8 @@ export class SearchClient {
|
|
|
49
49
|
__searchDocumentCollection(request, requestOptions) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
52
|
-
const
|
|
52
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
53
|
+
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);
|
|
53
54
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
54
55
|
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"),
|
|
55
56
|
method: "POST",
|
|
@@ -94,16 +95,4 @@ export class SearchClient {
|
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
_getAuthorizationHeader() {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
var _a;
|
|
100
|
-
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;
|
|
101
|
-
if (bearer == null) {
|
|
102
|
-
throw new errors.CredalError({
|
|
103
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return `Bearer ${bearer}`;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
98
|
}
|
|
@@ -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 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
|
}
|
|
@@ -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 UsersClient {
|
|
17
17
|
constructor(options = {}) {
|
|
18
|
-
this._options =
|
|
18
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Bulk patch metadata for users
|
|
@@ -44,7 +44,8 @@ export class UsersClient {
|
|
|
44
44
|
__metadata(request, requestOptions) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
47
|
-
const
|
|
47
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
48
|
+
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);
|
|
48
49
|
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
49
50
|
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"),
|
|
50
51
|
method: "PATCH",
|
|
@@ -86,16 +87,4 @@ export class UsersClient {
|
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
|
-
_getAuthorizationHeader() {
|
|
90
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
var _a;
|
|
92
|
-
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;
|
|
93
|
-
if (bearer == null) {
|
|
94
|
-
throw new errors.CredalError({
|
|
95
|
-
message: "Please specify a bearer by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return `Bearer ${bearer}`;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
90
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as core from "../core/index.mjs";
|
|
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
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import * as core from "../core/index.mjs";
|
|
12
|
+
import * as errors from "../errors/index.mjs";
|
|
13
|
+
export class BearerAuthProvider {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
this.token = options.apiKey;
|
|
16
|
+
}
|
|
17
|
+
static canCreate(options) {
|
|
18
|
+
var _a;
|
|
19
|
+
return options.apiKey != null || ((_a = process.env) === null || _a === void 0 ? void 0 : _a.CREDAL_API_KEY) != null;
|
|
20
|
+
}
|
|
21
|
+
getAuthRequest(_arg) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
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;
|
|
25
|
+
if (apiKey == null) {
|
|
26
|
+
throw new errors.CredalError({
|
|
27
|
+
message: "Please specify a apiKey by either passing it in to the constructor or initializing a CREDAL_API_KEY environment variable",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BearerAuthProvider } from "./BearerAuthProvider.mjs";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "../fetcher/EndpointMetadata.mjs";
|
|
1
2
|
import type { AuthRequest } from "./AuthRequest.mjs";
|
|
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 {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
2
|
+
function toAuthorizationHeader(token) {
|
|
3
|
+
if (token == null) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return `Bearer ${token}`;
|
|
7
|
+
}
|
|
2
8
|
export const BearerToken = {
|
|
3
|
-
toAuthorizationHeader:
|
|
4
|
-
if (token == null) {
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|
|
7
|
-
return `Bearer ${token}`;
|
|
8
|
-
},
|
|
9
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
9
10
|
fromAuthorizationHeader: (header) => {
|
|
10
11
|
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
11
12
|
},
|
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.13";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.
|
|
1
|
+
export const SDK_VERSION = "0.1.13";
|