@corti/sdk 0.1.0-alpha → 0.1.0-rc
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 +10 -11
- 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/resources/transcripts/client/requests/TranscriptsCreateRequest.d.ts +1 -1
- package/dist/cjs/api/resources/transcripts/types/index.d.ts +0 -1
- package/dist/cjs/api/resources/transcripts/types/index.js +0 -1
- package/dist/cjs/api/types/DocumentsContext.d.ts +11 -5
- package/dist/cjs/api/types/DocumentsContextWithFacts.d.ts +8 -0
- package/dist/cjs/api/types/DocumentsContextWithString.d.ts +7 -0
- package/dist/cjs/api/types/DocumentsContextWithString.js +5 -0
- package/dist/cjs/api/types/DocumentsContextWithTranscript.d.ts +8 -0
- package/dist/cjs/api/types/DocumentsContextWithTranscript.js +5 -0
- package/dist/cjs/api/types/DocumentsCreateRequestWithTemplate.d.ts +1 -1
- package/dist/cjs/api/types/DocumentsCreateRequestWithTemplateId.d.ts +1 -1
- package/dist/cjs/api/types/DocumentsCreateRequestWithTemplateKey.d.ts +1 -1
- package/dist/cjs/api/types/DocumentsTemplate.d.ts +1 -10
- package/dist/cjs/api/types/DocumentsTemplateWithSectionIds.d.ts +12 -0
- package/dist/cjs/api/types/DocumentsTemplateWithSectionIds.js +5 -0
- package/dist/cjs/api/types/DocumentsTemplateWithSectionKeys.d.ts +11 -0
- package/dist/cjs/api/types/DocumentsTemplateWithSectionKeys.js +5 -0
- package/dist/cjs/api/types/StreamSupportedLanguage.d.ts +1 -17
- package/dist/cjs/api/types/StreamSupportedLanguage.js +0 -17
- 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/TranscribeSupportedLanguage.d.ts +1 -17
- package/dist/cjs/api/types/TranscribeSupportedLanguage.js +0 -17
- package/dist/cjs/api/types/index.d.ts +6 -2
- package/dist/cjs/api/types/index.js +6 -2
- package/dist/cjs/core/exports.d.ts +1 -0
- package/dist/cjs/core/exports.js +17 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +7 -4
- package/dist/cjs/core/fetcher/BinaryResponse.js +5 -2
- package/dist/cjs/core/fetcher/Fetcher.js +3 -3
- package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.js +44 -0
- package/dist/cjs/core/fetcher/getResponseBody.js +2 -1
- 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/url/join.js +23 -3
- 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.d.ts +4 -1
- package/dist/cjs/custom/CortiClient.js +2 -1
- package/dist/cjs/custom/CustomStream.d.ts +3 -1
- package/dist/cjs/custom/CustomStream.js +22 -2
- package/dist/cjs/custom/CustomStreamSocket.d.ts +5 -1
- package/dist/cjs/custom/CustomStreamSocket.js +8 -0
- package/dist/cjs/custom/CustomTranscribe.d.ts +3 -1
- package/dist/cjs/custom/CustomTranscribe.js +22 -2
- package/dist/cjs/custom/CustomTranscribeSocket.d.ts +5 -1
- package/dist/cjs/custom/CustomTranscribeSocket.js +8 -0
- 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/resources/transcripts/client/requests/TranscriptsCreateRequest.d.ts +1 -2
- package/dist/cjs/serialization/resources/transcripts/client/requests/TranscriptsCreateRequest.js +1 -2
- package/dist/cjs/serialization/resources/transcripts/types/index.d.ts +0 -1
- package/dist/cjs/serialization/resources/transcripts/types/index.js +0 -1
- package/dist/cjs/serialization/types/DocumentsContext.d.ts +13 -6
- package/dist/cjs/serialization/types/DocumentsContext.js +12 -5
- package/dist/cjs/serialization/types/DocumentsContextWithFacts.d.ts +13 -0
- package/dist/cjs/serialization/{resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.js → types/DocumentsContextWithFacts.js} +6 -3
- package/dist/cjs/serialization/types/DocumentsContextWithString.d.ts +12 -0
- package/dist/cjs/serialization/types/{DocumentsContextTypeEnum.js → DocumentsContextWithString.js} +4 -2
- package/dist/cjs/serialization/types/DocumentsContextWithTranscript.d.ts +13 -0
- package/dist/cjs/serialization/types/{DocumentsContextData.js → DocumentsContextWithTranscript.js} +4 -7
- package/dist/cjs/serialization/types/DocumentsTemplate.d.ts +4 -8
- package/dist/cjs/serialization/types/DocumentsTemplate.js +3 -7
- package/dist/cjs/serialization/types/DocumentsTemplateWithSectionIds.d.ts +15 -0
- package/dist/cjs/serialization/types/DocumentsTemplateWithSectionIds.js +46 -0
- package/dist/cjs/serialization/types/DocumentsTemplateWithSectionKeys.d.ts +14 -0
- package/dist/cjs/serialization/types/DocumentsTemplateWithSectionKeys.js +45 -0
- package/dist/cjs/serialization/types/StreamSupportedLanguage.d.ts +1 -1
- package/dist/cjs/serialization/types/StreamSupportedLanguage.js +1 -16
- 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/TranscribeSupportedLanguage.d.ts +1 -1
- package/dist/cjs/serialization/types/TranscribeSupportedLanguage.js +1 -16
- package/dist/cjs/serialization/types/index.d.ts +6 -2
- package/dist/cjs/serialization/types/index.js +6 -2
- 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/resources/transcripts/client/requests/TranscriptsCreateRequest.d.mts +1 -1
- package/dist/esm/api/resources/transcripts/types/index.d.mts +0 -1
- package/dist/esm/api/resources/transcripts/types/index.mjs +0 -1
- package/dist/esm/api/types/DocumentsContext.d.mts +11 -5
- package/dist/esm/api/types/DocumentsContextWithFacts.d.mts +8 -0
- package/dist/esm/api/types/DocumentsContextWithString.d.mts +7 -0
- package/dist/esm/api/types/DocumentsContextWithString.mjs +4 -0
- package/dist/esm/api/types/DocumentsContextWithTranscript.d.mts +8 -0
- package/dist/esm/api/types/DocumentsContextWithTranscript.mjs +4 -0
- package/dist/esm/api/types/DocumentsCreateRequestWithTemplate.d.mts +1 -1
- package/dist/esm/api/types/DocumentsCreateRequestWithTemplateId.d.mts +1 -1
- package/dist/esm/api/types/DocumentsCreateRequestWithTemplateKey.d.mts +1 -1
- package/dist/esm/api/types/DocumentsTemplate.d.mts +1 -10
- package/dist/esm/api/types/DocumentsTemplateWithSectionIds.d.mts +12 -0
- package/dist/esm/api/types/DocumentsTemplateWithSectionIds.mjs +4 -0
- package/dist/esm/api/types/DocumentsTemplateWithSectionKeys.d.mts +11 -0
- package/dist/esm/api/types/DocumentsTemplateWithSectionKeys.mjs +4 -0
- package/dist/esm/api/types/StreamSupportedLanguage.d.mts +1 -17
- package/dist/esm/api/types/StreamSupportedLanguage.mjs +1 -16
- 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/TranscribeSupportedLanguage.d.mts +1 -17
- package/dist/esm/api/types/TranscribeSupportedLanguage.mjs +1 -16
- package/dist/esm/api/types/index.d.mts +6 -2
- package/dist/esm/api/types/index.mjs +6 -2
- package/dist/esm/core/exports.d.mts +1 -0
- package/dist/esm/core/exports.mjs +1 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +7 -4
- package/dist/esm/core/fetcher/BinaryResponse.mjs +5 -2
- package/dist/esm/core/fetcher/Fetcher.mjs +3 -3
- package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.mjs +41 -0
- package/dist/esm/core/fetcher/getResponseBody.mjs +2 -1
- 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/url/join.mjs +23 -3
- 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.d.mts +4 -1
- package/dist/esm/custom/CortiClient.mjs +2 -1
- package/dist/esm/custom/CustomStream.d.mts +3 -1
- package/dist/esm/custom/CustomStream.mjs +22 -2
- package/dist/esm/custom/CustomStreamSocket.d.mts +5 -1
- package/dist/esm/custom/CustomStreamSocket.mjs +8 -0
- package/dist/esm/custom/CustomTranscribe.d.mts +3 -1
- package/dist/esm/custom/CustomTranscribe.mjs +22 -2
- package/dist/esm/custom/CustomTranscribeSocket.d.mts +5 -1
- package/dist/esm/custom/CustomTranscribeSocket.mjs +8 -0
- 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/resources/transcripts/client/requests/TranscriptsCreateRequest.d.mts +1 -2
- package/dist/esm/serialization/resources/transcripts/client/requests/TranscriptsCreateRequest.mjs +1 -2
- package/dist/esm/serialization/resources/transcripts/types/index.d.mts +0 -1
- package/dist/esm/serialization/resources/transcripts/types/index.mjs +0 -1
- package/dist/esm/serialization/types/DocumentsContext.d.mts +13 -6
- package/dist/esm/serialization/types/DocumentsContext.mjs +12 -5
- package/dist/esm/serialization/types/DocumentsContextWithFacts.d.mts +13 -0
- package/dist/esm/serialization/types/DocumentsContextWithFacts.mjs +8 -0
- package/dist/esm/serialization/types/DocumentsContextWithString.d.mts +12 -0
- package/dist/esm/serialization/types/{DocumentsContextTypeEnum.mjs → DocumentsContextWithString.mjs} +3 -1
- package/dist/esm/serialization/types/DocumentsContextWithTranscript.d.mts +13 -0
- package/dist/esm/serialization/types/DocumentsContextWithTranscript.mjs +8 -0
- package/dist/esm/serialization/types/DocumentsTemplate.d.mts +4 -8
- package/dist/esm/serialization/types/DocumentsTemplate.mjs +3 -7
- package/dist/esm/serialization/types/DocumentsTemplateWithSectionIds.d.mts +15 -0
- package/dist/esm/serialization/types/DocumentsTemplateWithSectionIds.mjs +10 -0
- package/dist/esm/serialization/types/DocumentsTemplateWithSectionKeys.d.mts +14 -0
- package/dist/esm/serialization/types/DocumentsTemplateWithSectionKeys.mjs +9 -0
- package/dist/esm/serialization/types/StreamSupportedLanguage.d.mts +1 -1
- package/dist/esm/serialization/types/StreamSupportedLanguage.mjs +1 -16
- 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/TranscribeSupportedLanguage.d.mts +1 -1
- package/dist/esm/serialization/types/TranscribeSupportedLanguage.mjs +1 -16
- package/dist/esm/serialization/types/index.d.mts +6 -2
- package/dist/esm/serialization/types/index.mjs +6 -2
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +4 -3
- package/reference.md +1 -1
- package/dist/cjs/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.ts +0 -21
- package/dist/cjs/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.js +0 -20
- package/dist/cjs/api/types/DocumentsContextData.d.ts +0 -14
- package/dist/cjs/api/types/DocumentsContextTypeEnum.d.ts +0 -9
- package/dist/cjs/api/types/DocumentsContextTypeEnum.js +0 -11
- package/dist/cjs/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.ts +0 -10
- package/dist/cjs/serialization/types/DocumentsContextData.d.ts +0 -12
- package/dist/cjs/serialization/types/DocumentsContextTypeEnum.d.ts +0 -10
- package/dist/esm/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.mts +0 -21
- package/dist/esm/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.mjs +0 -17
- package/dist/esm/api/types/DocumentsContextData.d.mts +0 -14
- package/dist/esm/api/types/DocumentsContextTypeEnum.d.mts +0 -9
- package/dist/esm/api/types/DocumentsContextTypeEnum.mjs +0 -8
- package/dist/esm/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.mts +0 -10
- package/dist/esm/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.mjs +0 -5
- package/dist/esm/serialization/types/DocumentsContextData.d.mts +0 -12
- package/dist/esm/serialization/types/DocumentsContextData.mjs +0 -11
- package/dist/esm/serialization/types/DocumentsContextTypeEnum.d.mts +0 -10
- /package/dist/cjs/api/types/{DocumentsContextData.js → DocumentsContextWithFacts.js} +0 -0
- /package/dist/esm/api/types/{DocumentsContextData.mjs → DocumentsContextWithFacts.mjs} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getErrorResponseBody = getErrorResponseBody;
|
|
13
|
+
const json_js_1 = require("../json.js");
|
|
14
|
+
const getResponseBody_js_1 = require("./getResponseBody.js");
|
|
15
|
+
function getErrorResponseBody(response) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
let contentType = (_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
19
|
+
if (contentType == null || contentType.length === 0) {
|
|
20
|
+
return (0, getResponseBody_js_1.getResponseBody)(response);
|
|
21
|
+
}
|
|
22
|
+
if (contentType.indexOf(";") !== -1) {
|
|
23
|
+
contentType = (_c = (_b = contentType.split(";")[0]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : "";
|
|
24
|
+
}
|
|
25
|
+
switch (contentType) {
|
|
26
|
+
case "application/hal+json":
|
|
27
|
+
case "application/json":
|
|
28
|
+
case "application/ld+json":
|
|
29
|
+
case "application/problem+json":
|
|
30
|
+
case "application/vnd.api+json":
|
|
31
|
+
case "text/json":
|
|
32
|
+
const text = yield response.text();
|
|
33
|
+
return text.length > 0 ? (0, json_js_1.fromJson)(text) : undefined;
|
|
34
|
+
default:
|
|
35
|
+
if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) {
|
|
36
|
+
const text = yield response.text();
|
|
37
|
+
return text.length > 0 ? (0, json_js_1.fromJson)(text) : undefined;
|
|
38
|
+
}
|
|
39
|
+
// Fallback to plain text if content type is not recognized
|
|
40
|
+
// Even if no body is present, the response will be an empty string
|
|
41
|
+
return yield response.text();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getResponseBody = getResponseBody;
|
|
13
13
|
const BinaryResponse_js_1 = require("./BinaryResponse.js");
|
|
14
14
|
const ResponseWithBody_js_1 = require("./ResponseWithBody.js");
|
|
15
|
+
const json_js_1 = require("../json.js");
|
|
15
16
|
function getResponseBody(response, responseType) {
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
if (!(0, ResponseWithBody_js_1.isResponseWithBody)(response)) {
|
|
@@ -35,7 +36,7 @@ function getResponseBody(response, responseType) {
|
|
|
35
36
|
const text = yield response.text();
|
|
36
37
|
if (text.length > 0) {
|
|
37
38
|
try {
|
|
38
|
-
let responseBody =
|
|
39
|
+
let responseBody = (0, json_js_1.fromJson)(text);
|
|
39
40
|
return responseBody;
|
|
40
41
|
}
|
|
41
42
|
catch (err) {
|
|
@@ -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) => " - " +
|
|
@@ -5,6 +5,9 @@ function join(base, ...segments) {
|
|
|
5
5
|
if (!base) {
|
|
6
6
|
return "";
|
|
7
7
|
}
|
|
8
|
+
if (segments.length === 0) {
|
|
9
|
+
return base;
|
|
10
|
+
}
|
|
8
11
|
if (base.includes("://")) {
|
|
9
12
|
let url;
|
|
10
13
|
try {
|
|
@@ -14,24 +17,37 @@ function join(base, ...segments) {
|
|
|
14
17
|
// Fallback to path joining if URL is malformed
|
|
15
18
|
return joinPath(base, ...segments);
|
|
16
19
|
}
|
|
20
|
+
const lastSegment = segments[segments.length - 1];
|
|
21
|
+
const shouldPreserveTrailingSlash = lastSegment && lastSegment.endsWith("/");
|
|
17
22
|
for (const segment of segments) {
|
|
18
23
|
const cleanSegment = trimSlashes(segment);
|
|
19
24
|
if (cleanSegment) {
|
|
20
25
|
url.pathname = joinPathSegments(url.pathname, cleanSegment);
|
|
21
26
|
}
|
|
22
27
|
}
|
|
28
|
+
if (shouldPreserveTrailingSlash && !url.pathname.endsWith("/")) {
|
|
29
|
+
url.pathname += "/";
|
|
30
|
+
}
|
|
23
31
|
return url.toString();
|
|
24
32
|
}
|
|
25
33
|
return joinPath(base, ...segments);
|
|
26
34
|
}
|
|
27
35
|
function joinPath(base, ...segments) {
|
|
36
|
+
if (segments.length === 0) {
|
|
37
|
+
return base;
|
|
38
|
+
}
|
|
28
39
|
let result = base;
|
|
40
|
+
const lastSegment = segments[segments.length - 1];
|
|
41
|
+
const shouldPreserveTrailingSlash = lastSegment && lastSegment.endsWith("/");
|
|
29
42
|
for (const segment of segments) {
|
|
30
43
|
const cleanSegment = trimSlashes(segment);
|
|
31
44
|
if (cleanSegment) {
|
|
32
45
|
result = joinPathSegments(result, cleanSegment);
|
|
33
46
|
}
|
|
34
47
|
}
|
|
48
|
+
if (shouldPreserveTrailingSlash && !result.endsWith("/")) {
|
|
49
|
+
result += "/";
|
|
50
|
+
}
|
|
35
51
|
return result;
|
|
36
52
|
}
|
|
37
53
|
function joinPathSegments(left, right) {
|
|
@@ -43,7 +59,11 @@ function joinPathSegments(left, right) {
|
|
|
43
59
|
function trimSlashes(str) {
|
|
44
60
|
if (!str)
|
|
45
61
|
return str;
|
|
46
|
-
let start =
|
|
47
|
-
let end = str.
|
|
48
|
-
|
|
62
|
+
let start = 0;
|
|
63
|
+
let end = str.length;
|
|
64
|
+
if (str.startsWith("/"))
|
|
65
|
+
start = 1;
|
|
66
|
+
if (str.endsWith("/"))
|
|
67
|
+
end = str.length - 1;
|
|
68
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
49
69
|
}
|
|
@@ -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
|
*/
|
|
@@ -40,7 +40,10 @@ export declare namespace CortiClient {
|
|
|
40
40
|
clientSecret: core.Supplier<string>;
|
|
41
41
|
}
|
|
42
42
|
interface Options {
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Patch: allow to pass a custom string-based environment
|
|
45
|
+
* */
|
|
46
|
+
environment: core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls> | string;
|
|
44
47
|
/** Override the Tenant-Name header */
|
|
45
48
|
tenantName: core.Supplier<string>;
|
|
46
49
|
/** Additional headers to include in requests. */
|
|
@@ -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,7 +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 });
|
|
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) });
|
|
101
102
|
/**
|
|
102
103
|
* Patch: if `accessToken` is provided, use BearerProvider, otherwise use OAuthTokenProvider
|
|
103
104
|
*/
|
|
@@ -14,5 +14,7 @@ export declare class Stream extends FernStream {
|
|
|
14
14
|
/**
|
|
15
15
|
* Patch: use custom connect method to support passing _options parameters
|
|
16
16
|
*/
|
|
17
|
-
connect(args: Omit<FernStream.ConnectArgs, 'token' | 'tenantName'
|
|
17
|
+
connect({ configuration, ...args }: Omit<FernStream.ConnectArgs, 'token' | 'tenantName'> & {
|
|
18
|
+
configuration?: api.StreamConfig;
|
|
19
|
+
}): Promise<StreamSocket>;
|
|
18
20
|
}
|
|
@@ -41,6 +41,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
};
|
|
44
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
56
|
exports.Stream = void 0;
|
|
46
57
|
/**
|
|
@@ -59,11 +70,12 @@ class Stream extends Client_js_1.Stream {
|
|
|
59
70
|
/**
|
|
60
71
|
* Patch: use custom connect method to support passing _options parameters
|
|
61
72
|
*/
|
|
62
|
-
connect(
|
|
73
|
+
connect(_a) {
|
|
63
74
|
const _super = Object.create(null, {
|
|
64
75
|
connect: { get: () => super.connect }
|
|
65
76
|
});
|
|
66
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var { configuration } = _a, args = __rest(_a, ["configuration"]);
|
|
67
79
|
const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || '', tenantName: yield core.Supplier.get(this._options.tenantName) }));
|
|
68
80
|
const ws = new CustomStreamSocket_js_1.StreamSocket({ socket: fernWs.socket });
|
|
69
81
|
if (!configuration) {
|
|
@@ -93,7 +105,15 @@ class Stream extends Client_js_1.Stream {
|
|
|
93
105
|
|| parsedResponse.value.type === 'CONFIG_NOT_PROVIDED')) {
|
|
94
106
|
ws.socket.dispatchEvent(new events_js_1.ErrorEvent({
|
|
95
107
|
name: parsedResponse.value.type,
|
|
96
|
-
message:
|
|
108
|
+
message: JSON.stringify(parsedResponse.value),
|
|
109
|
+
}, ''));
|
|
110
|
+
ws.close();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (parsedResponse.ok && parsedResponse.value.type === 'error') {
|
|
114
|
+
ws.socket.dispatchEvent(new events_js_1.ErrorEvent({
|
|
115
|
+
name: 'error',
|
|
116
|
+
message: JSON.stringify(parsedResponse.value),
|
|
97
117
|
}, ''));
|
|
98
118
|
ws.close();
|
|
99
119
|
return;
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { StreamSocket as FernStreamSocket } from '../api/resources/stream/client/Socket.js';
|
|
5
5
|
export declare class StreamSocket extends FernStreamSocket {
|
|
6
|
-
sendAudio(message:
|
|
6
|
+
sendAudio(message: ArrayBufferLike | Blob | ArrayBufferView | string): void;
|
|
7
7
|
/**
|
|
8
8
|
* Patch: have to repeat this method, because it is private in the base class
|
|
9
9
|
*/
|
|
10
10
|
private __assertSocketIsOpen;
|
|
11
|
+
/**
|
|
12
|
+
* Patch: added ability to remove event handlers
|
|
13
|
+
*/
|
|
14
|
+
off<T extends keyof FernStreamSocket.EventHandlers>(event: T, callback?: FernStreamSocket.EventHandlers[T]): void;
|
|
11
15
|
}
|
|
@@ -58,5 +58,13 @@ class StreamSocket extends Socket_js_1.StreamSocket {
|
|
|
58
58
|
throw new Error("Socket is not open.");
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Patch: added ability to remove event handlers
|
|
63
|
+
*/
|
|
64
|
+
off(event, callback) {
|
|
65
|
+
if (!callback || callback === this.eventHandlers[event]) {
|
|
66
|
+
delete this.eventHandlers[event];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
61
69
|
}
|
|
62
70
|
exports.StreamSocket = StreamSocket;
|
|
@@ -14,5 +14,7 @@ export declare class Transcribe extends FernTranscribe {
|
|
|
14
14
|
/**
|
|
15
15
|
* Patch: use custom connect method to support passing _options parameters
|
|
16
16
|
*/
|
|
17
|
-
connect(args?: Omit<FernTranscribe.ConnectArgs, 'token' | 'tenantName'
|
|
17
|
+
connect({ configuration, ...args }?: Omit<FernTranscribe.ConnectArgs, 'token' | 'tenantName'> & {
|
|
18
|
+
configuration?: api.TranscribeConfig;
|
|
19
|
+
}): Promise<TranscribeSocket>;
|
|
18
20
|
}
|