@corti/sdk 0.1.3-alpha → 0.1.5-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/api/resources/recordings/client/Client.d.ts +2 -4
- package/dist/cjs/api/resources/recordings/client/Client.js +7 -6
- package/dist/cjs/api/types/TemplatesSection.d.ts +1 -1
- package/dist/cjs/api/types/TemplatesSectionTranslation.d.ts +11 -0
- package/dist/cjs/api/types/TemplatesSectionTranslation.js +5 -0
- package/dist/cjs/api/types/TemplatesTranslation.d.ts +2 -2
- package/dist/cjs/api/types/index.d.ts +1 -0
- package/dist/cjs/api/types/index.js +1 -0
- package/dist/cjs/core/exports.d.ts +1 -0
- package/dist/cjs/core/exports.js +17 -0
- package/dist/cjs/core/file/exports.d.ts +1 -0
- package/dist/cjs/core/file/exports.js +2 -0
- package/dist/cjs/core/file/file.d.ts +5 -0
- package/dist/cjs/core/file/file.js +203 -0
- package/dist/cjs/core/file/index.d.ts +2 -0
- package/dist/cjs/core/file/index.js +18 -0
- package/dist/cjs/core/file/types.d.ts +66 -0
- package/dist/cjs/core/file/types.js +2 -0
- package/dist/cjs/core/index.d.ts +1 -0
- package/dist/cjs/core/index.js +2 -1
- package/dist/cjs/core/schemas/utils/maybeSkipValidation.js +1 -1
- package/dist/cjs/core/websocket/ws.js +1 -1
- package/dist/cjs/custom/CortiAuth.d.ts +8 -0
- package/dist/cjs/custom/CortiAuth.js +7 -0
- package/dist/cjs/custom/CortiClient.js +2 -7
- package/dist/cjs/custom/utils/getEnvironmentFromString.d.ts +6 -0
- package/dist/cjs/custom/utils/getEnvironmentFromString.js +12 -0
- package/dist/cjs/environments.d.ts +1 -6
- package/dist/cjs/environments.js +0 -5
- package/dist/cjs/exports.d.ts +1 -0
- package/dist/cjs/exports.js +17 -0
- package/dist/cjs/serialization/types/TemplatesSection.d.ts +2 -2
- package/dist/cjs/serialization/types/TemplatesSection.js +2 -2
- package/dist/cjs/serialization/types/TemplatesSectionTranslation.d.ts +14 -0
- package/dist/cjs/serialization/types/TemplatesSectionTranslation.js +45 -0
- package/dist/cjs/serialization/types/TemplatesTranslation.d.ts +2 -2
- package/dist/cjs/serialization/types/TemplatesTranslation.js +2 -2
- package/dist/cjs/serialization/types/index.d.ts +1 -0
- package/dist/cjs/serialization/types/index.js +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/api/resources/recordings/client/Client.d.mts +2 -4
- package/dist/esm/api/resources/recordings/client/Client.mjs +7 -6
- package/dist/esm/api/types/TemplatesSection.d.mts +1 -1
- package/dist/esm/api/types/TemplatesSectionTranslation.d.mts +11 -0
- package/dist/esm/api/types/TemplatesSectionTranslation.mjs +4 -0
- package/dist/esm/api/types/TemplatesTranslation.d.mts +2 -2
- package/dist/esm/api/types/index.d.mts +1 -0
- package/dist/esm/api/types/index.mjs +1 -0
- package/dist/esm/core/exports.d.mts +1 -0
- package/dist/esm/core/exports.mjs +1 -0
- package/dist/esm/core/file/exports.d.mts +1 -0
- package/dist/esm/core/file/exports.mjs +1 -0
- package/dist/esm/core/file/file.d.mts +5 -0
- package/dist/esm/core/file/file.mjs +167 -0
- package/dist/esm/core/file/index.d.mts +2 -0
- package/dist/esm/core/file/index.mjs +2 -0
- package/dist/esm/core/file/types.d.mts +66 -0
- package/dist/esm/core/file/types.mjs +1 -0
- package/dist/esm/core/index.d.mts +1 -0
- package/dist/esm/core/index.mjs +1 -0
- package/dist/esm/core/schemas/utils/maybeSkipValidation.mjs +1 -1
- package/dist/esm/core/websocket/ws.mjs +1 -1
- package/dist/esm/custom/CortiAuth.d.mts +8 -0
- package/dist/esm/custom/CortiAuth.mjs +7 -0
- package/dist/esm/custom/CortiClient.mjs +2 -7
- package/dist/esm/custom/utils/getEnvironmentFromString.d.mts +6 -0
- package/dist/esm/custom/utils/getEnvironmentFromString.mjs +9 -0
- package/dist/esm/environments.d.mts +1 -6
- package/dist/esm/environments.mjs +0 -5
- package/dist/esm/exports.d.mts +1 -0
- package/dist/esm/exports.mjs +1 -0
- package/dist/esm/serialization/types/TemplatesSection.d.mts +2 -2
- package/dist/esm/serialization/types/TemplatesSection.mjs +2 -2
- package/dist/esm/serialization/types/TemplatesSectionTranslation.d.mts +14 -0
- package/dist/esm/serialization/types/TemplatesSectionTranslation.mjs +9 -0
- package/dist/esm/serialization/types/TemplatesTranslation.d.mts +2 -2
- package/dist/esm/serialization/types/TemplatesTranslation.mjs +2 -2
- package/dist/esm/serialization/types/index.d.mts +1 -0
- package/dist/esm/serialization/types/index.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ import { CortiEnvironment, CortiClient } from "@corti/sdk";
|
|
|
32
32
|
|
|
33
33
|
// Using client credentials (OAuth2)
|
|
34
34
|
const client = new CortiClient({
|
|
35
|
-
environment: CortiEnvironment.
|
|
35
|
+
environment: CortiEnvironment.Eu,
|
|
36
36
|
tenantName: "YOUR_TENANT_NAME",
|
|
37
37
|
auth: {
|
|
38
38
|
clientId: "YOUR_CLIENT_ID",
|
|
@@ -42,7 +42,7 @@ const client = new CortiClient({
|
|
|
42
42
|
|
|
43
43
|
// Or using a bearer token
|
|
44
44
|
const client = new CortiClient({
|
|
45
|
-
environment: CortiEnvironment.
|
|
45
|
+
environment: CortiEnvironment.Eu,
|
|
46
46
|
tenantName: "YOUR_TENANT_NAME",
|
|
47
47
|
auth: {
|
|
48
48
|
accessToken: "YOUR_ACCESS_TOKEN",
|
|
@@ -120,7 +120,7 @@ List endpoints are paginated. The SDK provides an iterator so that you can simpl
|
|
|
120
120
|
import { CortiEnvironment, CortiClient } from "@corti/sdk";
|
|
121
121
|
|
|
122
122
|
const client = new CortiClient({
|
|
123
|
-
environment: CortiEnvironment.
|
|
123
|
+
environment: CortiEnvironment.Eu,
|
|
124
124
|
tenantName: "YOUR_TENANT_NAME",
|
|
125
125
|
auth: {
|
|
126
126
|
clientId: "YOUR_CLIENT_ID",
|
package/dist/cjs/Client.js
CHANGED
|
@@ -63,8 +63,8 @@ class CortiClient {
|
|
|
63
63
|
"Tenant-Name": _options === null || _options === void 0 ? void 0 : _options.tenantName,
|
|
64
64
|
"X-Fern-Language": "JavaScript",
|
|
65
65
|
"X-Fern-SDK-Name": "@corti/sdk",
|
|
66
|
-
"X-Fern-SDK-Version": "0.1.
|
|
67
|
-
"User-Agent": "@corti/sdk/0.1.
|
|
66
|
+
"X-Fern-SDK-Version": "0.1.5-alpha",
|
|
67
|
+
"User-Agent": "@corti/sdk/0.1.5-alpha",
|
|
68
68
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
69
69
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
70
70
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import * as environments from "../../../../environments.js";
|
|
5
5
|
import * as core from "../../../../core/index.js";
|
|
6
6
|
import * as Corti from "../../../index.js";
|
|
7
|
-
import * as fs from "fs";
|
|
8
|
-
import { Blob } from "buffer";
|
|
9
7
|
export declare namespace Recordings {
|
|
10
8
|
interface Options {
|
|
11
9
|
environment: core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls>;
|
|
@@ -52,7 +50,7 @@ export declare class Recordings {
|
|
|
52
50
|
/**
|
|
53
51
|
* Upload a recording for a given interaction. There is a maximum limit of 60 minutes in length and 150MB in size for recordings.
|
|
54
52
|
*
|
|
55
|
-
* @param {
|
|
53
|
+
* @param {core.file.Uploadable} uploadable
|
|
56
54
|
* @param {Corti.Uuid} id
|
|
57
55
|
* @param {Recordings.RequestOptions} requestOptions - Request-specific configuration.
|
|
58
56
|
*
|
|
@@ -61,7 +59,7 @@ export declare class Recordings {
|
|
|
61
59
|
* @throws {@link Corti.InternalServerError}
|
|
62
60
|
* @throws {@link Corti.GatewayTimeoutError}
|
|
63
61
|
*/
|
|
64
|
-
upload(
|
|
62
|
+
upload(uploadable: core.file.Uploadable, id: Corti.Uuid, requestOptions?: Recordings.RequestOptions): core.HttpResponsePromise<Corti.RecordingsCreateResponse>;
|
|
65
63
|
private __upload;
|
|
66
64
|
/**
|
|
67
65
|
* Retrieve a specific recording for a given interaction.
|
|
@@ -148,7 +148,7 @@ class Recordings {
|
|
|
148
148
|
/**
|
|
149
149
|
* Upload a recording for a given interaction. There is a maximum limit of 60 minutes in length and 150MB in size for recordings.
|
|
150
150
|
*
|
|
151
|
-
* @param {
|
|
151
|
+
* @param {core.file.Uploadable} uploadable
|
|
152
152
|
* @param {Corti.Uuid} id
|
|
153
153
|
* @param {Recordings.RequestOptions} requestOptions - Request-specific configuration.
|
|
154
154
|
*
|
|
@@ -157,23 +157,24 @@ class Recordings {
|
|
|
157
157
|
* @throws {@link Corti.InternalServerError}
|
|
158
158
|
* @throws {@link Corti.GatewayTimeoutError}
|
|
159
159
|
*/
|
|
160
|
-
upload(
|
|
161
|
-
return core.HttpResponsePromise.fromPromise(this.__upload(
|
|
160
|
+
upload(uploadable, id, requestOptions) {
|
|
161
|
+
return core.HttpResponsePromise.fromPromise(this.__upload(uploadable, id, requestOptions));
|
|
162
162
|
}
|
|
163
|
-
__upload(
|
|
163
|
+
__upload(uploadable, id, requestOptions) {
|
|
164
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
165
165
|
var _a, _b;
|
|
166
|
+
const _binaryUploadRequest = yield core.file.toBinaryUploadRequest(uploadable);
|
|
166
167
|
const _response = yield core.fetcher({
|
|
167
168
|
url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment)).base, `interactions/${encodeURIComponent(serializers.Uuid.jsonOrThrow(id, { omitUndefined: true }))}/recordings/`),
|
|
168
169
|
method: "POST",
|
|
169
170
|
headers: (0, headers_js_1.mergeHeaders)((_b = this._options) === null || _b === void 0 ? void 0 : _b.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
170
171
|
Authorization: yield this._getAuthorizationHeader(),
|
|
171
172
|
"Tenant-Name": requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.tenantName,
|
|
172
|
-
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
173
|
+
}), _binaryUploadRequest.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
173
174
|
contentType: "application/octet-stream",
|
|
174
175
|
requestType: "bytes",
|
|
175
176
|
duplex: "half",
|
|
176
|
-
body:
|
|
177
|
+
body: _binaryUploadRequest.body,
|
|
177
178
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
178
179
|
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
179
180
|
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export interface TemplatesSectionTranslation {
|
|
5
|
+
/** Language identifier */
|
|
6
|
+
languagesId: string;
|
|
7
|
+
/** Localized name */
|
|
8
|
+
name?: string | null;
|
|
9
|
+
/** Localized description */
|
|
10
|
+
description?: string | null;
|
|
11
|
+
}
|
|
@@ -56,6 +56,7 @@ export * from "./InteractionsGenderEnum.js";
|
|
|
56
56
|
export * from "./CommonSourceEnum.js";
|
|
57
57
|
export * from "./TranscriptsParticipantRoleEnum.js";
|
|
58
58
|
export * from "./TemplatesWritingStyle.js";
|
|
59
|
+
export * from "./TemplatesSectionTranslation.js";
|
|
59
60
|
export * from "./TemplatesTranslation.js";
|
|
60
61
|
export * from "./StreamConfigMessage.js";
|
|
61
62
|
export * from "./StreamConfig.js";
|
|
@@ -72,6 +72,7 @@ __exportStar(require("./InteractionsGenderEnum.js"), exports);
|
|
|
72
72
|
__exportStar(require("./CommonSourceEnum.js"), exports);
|
|
73
73
|
__exportStar(require("./TranscriptsParticipantRoleEnum.js"), exports);
|
|
74
74
|
__exportStar(require("./TemplatesWritingStyle.js"), exports);
|
|
75
|
+
__exportStar(require("./TemplatesSectionTranslation.js"), exports);
|
|
75
76
|
__exportStar(require("./TemplatesTranslation.js"), exports);
|
|
76
77
|
__exportStar(require("./StreamConfigMessage.js"), exports);
|
|
77
78
|
__exportStar(require("./StreamConfig.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./file/exports.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file/exports.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Uploadable } from "./types.js";
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.toBinaryUploadRequest = toBinaryUploadRequest;
|
|
46
|
+
function toBinaryUploadRequest(file) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const { data, filename, contentLength, contentType } = yield getFileWithMetadata(file);
|
|
49
|
+
const request = {
|
|
50
|
+
body: data,
|
|
51
|
+
headers: {},
|
|
52
|
+
};
|
|
53
|
+
if (filename) {
|
|
54
|
+
request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
|
|
55
|
+
}
|
|
56
|
+
if (contentType) {
|
|
57
|
+
request.headers["Content-Type"] = contentType;
|
|
58
|
+
}
|
|
59
|
+
if (contentLength != null) {
|
|
60
|
+
request.headers["Content-Length"] = contentLength.toString();
|
|
61
|
+
}
|
|
62
|
+
return request;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function getFileWithMetadata(file) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var _a, _b, _c, _d, _e;
|
|
68
|
+
if (isFileLike(file)) {
|
|
69
|
+
return getFileWithMetadata({
|
|
70
|
+
data: file,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if ("path" in file) {
|
|
74
|
+
const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
|
|
75
|
+
if (!fs || !fs.createReadStream) {
|
|
76
|
+
throw new Error("File path uploads are not supported in this environment.");
|
|
77
|
+
}
|
|
78
|
+
const data = fs.createReadStream(file.path);
|
|
79
|
+
const contentLength = (_a = file.contentLength) !== null && _a !== void 0 ? _a : (yield tryGetFileSizeFromPath(file.path));
|
|
80
|
+
const filename = (_b = file.filename) !== null && _b !== void 0 ? _b : getNameFromPath(file.path);
|
|
81
|
+
return {
|
|
82
|
+
data,
|
|
83
|
+
filename,
|
|
84
|
+
contentType: file.contentType,
|
|
85
|
+
contentLength,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if ("data" in file) {
|
|
89
|
+
const data = file.data;
|
|
90
|
+
const contentLength = (_c = file.contentLength) !== null && _c !== void 0 ? _c : (yield tryGetContentLengthFromFileLike(data));
|
|
91
|
+
const filename = (_d = file.filename) !== null && _d !== void 0 ? _d : tryGetNameFromFileLike(data);
|
|
92
|
+
return {
|
|
93
|
+
data,
|
|
94
|
+
filename,
|
|
95
|
+
contentType: (_e = file.contentType) !== null && _e !== void 0 ? _e : tryGetContentTypeFromFileLike(data),
|
|
96
|
+
contentLength,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function isFileLike(value) {
|
|
103
|
+
return (isBuffer(value) ||
|
|
104
|
+
isArrayBufferView(value) ||
|
|
105
|
+
isArrayBuffer(value) ||
|
|
106
|
+
isUint8Array(value) ||
|
|
107
|
+
isBlob(value) ||
|
|
108
|
+
isFile(value) ||
|
|
109
|
+
isStreamLike(value) ||
|
|
110
|
+
isReadableStream(value));
|
|
111
|
+
}
|
|
112
|
+
function tryGetFileSizeFromPath(path) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
try {
|
|
115
|
+
const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
|
|
116
|
+
if (!fs || !fs.promises || !fs.promises.stat) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const fileStat = yield fs.promises.stat(path);
|
|
120
|
+
return fileStat.size;
|
|
121
|
+
}
|
|
122
|
+
catch (fallbackError) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function tryGetNameFromFileLike(data) {
|
|
128
|
+
if (isNamedValue(data)) {
|
|
129
|
+
return data.name;
|
|
130
|
+
}
|
|
131
|
+
if (isPathedValue(data)) {
|
|
132
|
+
return getNameFromPath(data.path.toString());
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
function tryGetContentLengthFromFileLike(data) {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
if (isBuffer(data)) {
|
|
139
|
+
return data.length;
|
|
140
|
+
}
|
|
141
|
+
if (isArrayBufferView(data)) {
|
|
142
|
+
return data.byteLength;
|
|
143
|
+
}
|
|
144
|
+
if (isArrayBuffer(data)) {
|
|
145
|
+
return data.byteLength;
|
|
146
|
+
}
|
|
147
|
+
if (isBlob(data)) {
|
|
148
|
+
return data.size;
|
|
149
|
+
}
|
|
150
|
+
if (isFile(data)) {
|
|
151
|
+
return data.size;
|
|
152
|
+
}
|
|
153
|
+
if (isPathedValue(data)) {
|
|
154
|
+
return yield tryGetFileSizeFromPath(data.path.toString());
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function tryGetContentTypeFromFileLike(data) {
|
|
160
|
+
if (isBlob(data)) {
|
|
161
|
+
return data.type;
|
|
162
|
+
}
|
|
163
|
+
if (isFile(data)) {
|
|
164
|
+
return data.type;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
function getNameFromPath(path) {
|
|
169
|
+
const lastForwardSlash = path.lastIndexOf("/");
|
|
170
|
+
const lastBackSlash = path.lastIndexOf("\\");
|
|
171
|
+
const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
|
|
172
|
+
return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
|
|
173
|
+
}
|
|
174
|
+
function isNamedValue(value) {
|
|
175
|
+
return typeof value === "object" && value != null && "name" in value;
|
|
176
|
+
}
|
|
177
|
+
function isPathedValue(value) {
|
|
178
|
+
return typeof value === "object" && value != null && "path" in value;
|
|
179
|
+
}
|
|
180
|
+
function isStreamLike(value) {
|
|
181
|
+
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
182
|
+
}
|
|
183
|
+
function isReadableStream(value) {
|
|
184
|
+
return typeof value === "object" && value != null && "getReader" in value;
|
|
185
|
+
}
|
|
186
|
+
function isBuffer(value) {
|
|
187
|
+
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
188
|
+
}
|
|
189
|
+
function isArrayBufferView(value) {
|
|
190
|
+
return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
|
|
191
|
+
}
|
|
192
|
+
function isArrayBuffer(value) {
|
|
193
|
+
return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
|
|
194
|
+
}
|
|
195
|
+
function isUint8Array(value) {
|
|
196
|
+
return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
|
|
197
|
+
}
|
|
198
|
+
function isBlob(value) {
|
|
199
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
200
|
+
}
|
|
201
|
+
function isFile(value) {
|
|
202
|
+
return typeof File !== "undefined" && value instanceof File;
|
|
203
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file.js"), exports);
|
|
18
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
|
|
3
|
+
* a path to a file, or an object with a file-like object and metadata.
|
|
4
|
+
*/
|
|
5
|
+
export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
|
|
6
|
+
export declare namespace Uploadable {
|
|
7
|
+
/**
|
|
8
|
+
* Various file-like objects that can be used to upload a file.
|
|
9
|
+
*/
|
|
10
|
+
type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
|
|
11
|
+
/**
|
|
12
|
+
* A file path with optional metadata, used for uploading a file from the file system.
|
|
13
|
+
*/
|
|
14
|
+
type FromPath = {
|
|
15
|
+
/** The path to the file to upload */
|
|
16
|
+
path: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional override for the file name (defaults to basename of path).
|
|
19
|
+
* This is used to set the `Content-Disposition` header in upload requests.
|
|
20
|
+
*/
|
|
21
|
+
filename?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
24
|
+
* This is used to set the `Content-Type` header in upload requests.
|
|
25
|
+
*/
|
|
26
|
+
contentType?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Optional file size in bytes.
|
|
29
|
+
* If not provided, the file size will be determined from the file system.
|
|
30
|
+
* The content length is used to set the `Content-Length` header in upload requests.
|
|
31
|
+
*/
|
|
32
|
+
contentLength?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A file-like object with metadata, used for uploading files.
|
|
36
|
+
*/
|
|
37
|
+
type WithMetadata = {
|
|
38
|
+
/** The file data */
|
|
39
|
+
data: FileLike;
|
|
40
|
+
/**
|
|
41
|
+
* Optional override for the file name (defaults to basename of path).
|
|
42
|
+
* This is used to set the `Content-Disposition` header in upload requests.
|
|
43
|
+
*/
|
|
44
|
+
filename?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
47
|
+
* This is used to set the `Content-Type` header in upload requests.
|
|
48
|
+
*
|
|
49
|
+
* If not provided, the content type may be determined from the data itself.
|
|
50
|
+
* * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
|
|
51
|
+
* * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
|
|
52
|
+
*/
|
|
53
|
+
contentType?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional file size in bytes.
|
|
56
|
+
* The content length is used to set the `Content-Length` header in upload requests.
|
|
57
|
+
* If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
|
|
58
|
+
*
|
|
59
|
+
* If not provided, the file size will be determined depending on the data type.
|
|
60
|
+
* * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
|
|
61
|
+
* * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
|
|
62
|
+
* * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
|
|
63
|
+
*/
|
|
64
|
+
contentLength?: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
package/dist/cjs/core/index.d.ts
CHANGED
package/dist/cjs/core/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.serialization = exports.url = void 0;
|
|
39
|
+
exports.file = exports.serialization = exports.url = void 0;
|
|
40
40
|
__exportStar(require("./auth/index.js"), exports);
|
|
41
41
|
__exportStar(require("./fetcher/index.js"), exports);
|
|
42
42
|
__exportStar(require("./runtime/index.js"), exports);
|
|
@@ -46,3 +46,4 @@ __exportStar(require("./websocket/index.js"), exports);
|
|
|
46
46
|
__exportStar(require("./base64.js"), exports);
|
|
47
47
|
__exportStar(require("./utils/index.js"), exports);
|
|
48
48
|
__exportStar(require("./pagination/index.js"), exports);
|
|
49
|
+
exports.file = __importStar(require("./file/index.js"));
|
|
@@ -9,7 +9,7 @@ function transformAndMaybeSkipValidation(transform) {
|
|
|
9
9
|
const transformed = transform(value, opts);
|
|
10
10
|
const { skipValidation = false } = opts !== null && opts !== void 0 ? opts : {};
|
|
11
11
|
if (!transformed.ok && skipValidation) {
|
|
12
|
-
//
|
|
12
|
+
// biome-ignore lint/suspicious/noConsole: allow console
|
|
13
13
|
console.warn([
|
|
14
14
|
"Failed to validate.",
|
|
15
15
|
...transformed.errors.map((error) => " - " +
|
|
@@ -322,7 +322,7 @@ class ReconnectingWebSocket {
|
|
|
322
322
|
if (this._options.debug) {
|
|
323
323
|
// not using spread because compiled version uses Symbols
|
|
324
324
|
// tslint:disable-next-line
|
|
325
|
-
//
|
|
325
|
+
// biome-ignore lint/suspicious/noConsole: allow console
|
|
326
326
|
console.log.apply(console, ["RWS>", ...args]);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { Auth as FernAuth } from "../api/resources/auth/client/Client.js";
|
|
15
15
|
import * as core from "../core/index.js";
|
|
16
16
|
import * as Corti from "../api/index.js";
|
|
17
|
+
import * as environments from "../environments.js";
|
|
17
18
|
interface AuthorizationCodeClient {
|
|
18
19
|
clientId: string;
|
|
19
20
|
redirectUri: string;
|
|
@@ -32,7 +33,14 @@ interface AuthorizationRefreshServer {
|
|
|
32
33
|
interface Options {
|
|
33
34
|
skipRedirect?: boolean;
|
|
34
35
|
}
|
|
36
|
+
type AuthOptions = Omit<FernAuth.Options, 'environment'> & {
|
|
37
|
+
environment: core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls> | string;
|
|
38
|
+
};
|
|
35
39
|
export declare class Auth extends FernAuth {
|
|
40
|
+
/**
|
|
41
|
+
* Patch: use custom AuthOptions type to support string-based environment
|
|
42
|
+
*/
|
|
43
|
+
constructor(_options: AuthOptions);
|
|
36
44
|
/**
|
|
37
45
|
* Patch: called custom implementation this.__getToken_custom instead of this.__getToken
|
|
38
46
|
*/
|
|
@@ -61,7 +61,14 @@ const core = __importStar(require("../core/index.js"));
|
|
|
61
61
|
const headers_js_1 = require("../core/headers.js");
|
|
62
62
|
const serializers = __importStar(require("../serialization/index.js"));
|
|
63
63
|
const errors = __importStar(require("../errors/index.js"));
|
|
64
|
+
const getEnvironmentFromString_js_1 = require("./utils/getEnvironmentFromString.js");
|
|
64
65
|
class Auth extends Client_js_1.Auth {
|
|
66
|
+
/**
|
|
67
|
+
* Patch: use custom AuthOptions type to support string-based environment
|
|
68
|
+
*/
|
|
69
|
+
constructor(_options) {
|
|
70
|
+
super(Object.assign(Object.assign({}, _options), { environment: (0, getEnvironmentFromString_js_1.getEnvironment)(_options.environment) }));
|
|
71
|
+
}
|
|
65
72
|
/**
|
|
66
73
|
* Patch: called custom implementation this.__getToken_custom instead of this.__getToken
|
|
67
74
|
*/
|
|
@@ -84,6 +84,7 @@ const RefreshBearerProvider_js_1 = require("./RefreshBearerProvider.js");
|
|
|
84
84
|
* Patch: added SDK_VERSION import
|
|
85
85
|
*/
|
|
86
86
|
const version_js_1 = require("../version.js");
|
|
87
|
+
const getEnvironmentFromString_js_1 = require("./utils/getEnvironmentFromString.js");
|
|
87
88
|
class CortiClient {
|
|
88
89
|
constructor(_options) {
|
|
89
90
|
this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
|
|
@@ -97,13 +98,7 @@ class CortiClient {
|
|
|
97
98
|
"User-Agent": `@corti/sdk/${version_js_1.SDK_VERSION}`,
|
|
98
99
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
99
100
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
100
|
-
}, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: "clientId" in _options.auth ? _options.auth.clientId : undefined, clientSecret: "clientSecret" in _options.auth ? _options.auth.clientSecret : undefined, token: "accessToken" in _options.auth ? _options.auth.accessToken : undefined, environment:
|
|
101
|
-
? {
|
|
102
|
-
base: `https://api.${_options.environment}.corti.app/v2`,
|
|
103
|
-
wss: `wss://api.${_options.environment}.corti.app`,
|
|
104
|
-
login: `https://auth.${_options.environment}.corti.app/realms`,
|
|
105
|
-
}
|
|
106
|
-
: _options.environment });
|
|
101
|
+
}, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: "clientId" in _options.auth ? _options.auth.clientId : undefined, clientSecret: "clientSecret" in _options.auth ? _options.auth.clientSecret : undefined, token: "accessToken" in _options.auth ? _options.auth.accessToken : undefined, environment: (0, getEnvironmentFromString_js_1.getEnvironment)(_options.environment) });
|
|
107
102
|
/**
|
|
108
103
|
* Patch: if `accessToken` is provided, use BearerProvider, otherwise use OAuthTokenProvider
|
|
109
104
|
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as core from "../../core/index.js";
|
|
2
|
+
import * as environments from "../../environments.js";
|
|
3
|
+
type Environment = core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls> | string;
|
|
4
|
+
type CortiEnvironment = core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls>;
|
|
5
|
+
export declare function getEnvironment(environment: Environment): CortiEnvironment;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvironment = getEnvironment;
|
|
4
|
+
function getEnvironment(environment) {
|
|
5
|
+
return typeof environment === "string"
|
|
6
|
+
? {
|
|
7
|
+
base: `https://api.${environment}.corti.app/v2`,
|
|
8
|
+
wss: `wss://api.${environment}.corti.app`,
|
|
9
|
+
login: `https://auth.${environment}.corti.app/realms`,
|
|
10
|
+
}
|
|
11
|
+
: environment;
|
|
12
|
+
}
|
|
@@ -7,11 +7,6 @@ export interface CortiEnvironmentUrls {
|
|
|
7
7
|
login: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const CortiEnvironment: {
|
|
10
|
-
readonly BetaEu: {
|
|
11
|
-
readonly base: "https://api.beta-eu.corti.app/v2";
|
|
12
|
-
readonly wss: "wss://api.beta-eu.corti.app";
|
|
13
|
-
readonly login: "https://auth.beta-eu.corti.app/realms";
|
|
14
|
-
};
|
|
15
10
|
readonly Eu: {
|
|
16
11
|
readonly base: "https://api.eu.corti.app/v2";
|
|
17
12
|
readonly wss: "wss://api.eu.corti.app";
|
|
@@ -23,4 +18,4 @@ export declare const CortiEnvironment: {
|
|
|
23
18
|
readonly login: "https://auth.us.corti.app/realms";
|
|
24
19
|
};
|
|
25
20
|
};
|
|
26
|
-
export type CortiEnvironment = typeof CortiEnvironment.
|
|
21
|
+
export type CortiEnvironment = typeof CortiEnvironment.Eu | typeof CortiEnvironment.Us;
|