@corti/sdk 0.1.0-alpha.rc → 0.1.2-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.
Files changed (80) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/transcripts/client/requests/TranscriptsCreateRequest.d.ts +1 -1
  3. package/dist/cjs/api/resources/transcripts/types/index.d.ts +0 -1
  4. package/dist/cjs/api/resources/transcripts/types/index.js +0 -1
  5. package/dist/cjs/api/types/StreamSupportedLanguage.d.ts +1 -17
  6. package/dist/cjs/api/types/StreamSupportedLanguage.js +0 -17
  7. package/dist/cjs/api/types/TranscribeSupportedLanguage.d.ts +1 -17
  8. package/dist/cjs/api/types/TranscribeSupportedLanguage.js +0 -17
  9. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +7 -4
  10. package/dist/cjs/core/fetcher/BinaryResponse.js +5 -2
  11. package/dist/cjs/core/fetcher/Fetcher.js +3 -3
  12. package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
  13. package/dist/cjs/core/fetcher/getErrorResponseBody.js +44 -0
  14. package/dist/cjs/core/fetcher/getResponseBody.js +2 -1
  15. package/dist/cjs/core/url/join.js +23 -3
  16. package/dist/cjs/custom/CortiClient.d.ts +4 -1
  17. package/dist/cjs/custom/CortiClient.js +7 -1
  18. package/dist/cjs/custom/CustomStream.d.ts +3 -1
  19. package/dist/cjs/custom/CustomStream.js +21 -1
  20. package/dist/cjs/custom/CustomStreamSocket.d.ts +5 -1
  21. package/dist/cjs/custom/CustomStreamSocket.js +8 -0
  22. package/dist/cjs/custom/CustomTranscribe.d.ts +3 -1
  23. package/dist/cjs/custom/CustomTranscribe.js +21 -1
  24. package/dist/cjs/custom/CustomTranscribeSocket.d.ts +5 -1
  25. package/dist/cjs/custom/CustomTranscribeSocket.js +8 -0
  26. package/dist/cjs/serialization/resources/transcripts/client/requests/TranscriptsCreateRequest.d.ts +1 -2
  27. package/dist/cjs/serialization/resources/transcripts/client/requests/TranscriptsCreateRequest.js +1 -2
  28. package/dist/cjs/serialization/resources/transcripts/types/index.d.ts +0 -1
  29. package/dist/cjs/serialization/resources/transcripts/types/index.js +0 -1
  30. package/dist/cjs/serialization/types/StreamSupportedLanguage.d.ts +1 -1
  31. package/dist/cjs/serialization/types/StreamSupportedLanguage.js +1 -16
  32. package/dist/cjs/serialization/types/TranscribeSupportedLanguage.d.ts +1 -1
  33. package/dist/cjs/serialization/types/TranscribeSupportedLanguage.js +1 -16
  34. package/dist/cjs/version.d.ts +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/esm/Client.mjs +2 -2
  37. package/dist/esm/api/resources/transcripts/client/requests/TranscriptsCreateRequest.d.mts +1 -1
  38. package/dist/esm/api/resources/transcripts/types/index.d.mts +0 -1
  39. package/dist/esm/api/resources/transcripts/types/index.mjs +0 -1
  40. package/dist/esm/api/types/StreamSupportedLanguage.d.mts +1 -17
  41. package/dist/esm/api/types/StreamSupportedLanguage.mjs +1 -16
  42. package/dist/esm/api/types/TranscribeSupportedLanguage.d.mts +1 -17
  43. package/dist/esm/api/types/TranscribeSupportedLanguage.mjs +1 -16
  44. package/dist/esm/core/fetcher/BinaryResponse.d.mts +7 -4
  45. package/dist/esm/core/fetcher/BinaryResponse.mjs +5 -2
  46. package/dist/esm/core/fetcher/Fetcher.mjs +3 -3
  47. package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
  48. package/dist/esm/core/fetcher/getErrorResponseBody.mjs +41 -0
  49. package/dist/esm/core/fetcher/getResponseBody.mjs +2 -1
  50. package/dist/esm/core/url/join.mjs +23 -3
  51. package/dist/esm/custom/CortiClient.d.mts +4 -1
  52. package/dist/esm/custom/CortiClient.mjs +7 -1
  53. package/dist/esm/custom/CustomStream.d.mts +3 -1
  54. package/dist/esm/custom/CustomStream.mjs +21 -1
  55. package/dist/esm/custom/CustomStreamSocket.d.mts +5 -1
  56. package/dist/esm/custom/CustomStreamSocket.mjs +8 -0
  57. package/dist/esm/custom/CustomTranscribe.d.mts +3 -1
  58. package/dist/esm/custom/CustomTranscribe.mjs +21 -1
  59. package/dist/esm/custom/CustomTranscribeSocket.d.mts +5 -1
  60. package/dist/esm/custom/CustomTranscribeSocket.mjs +8 -0
  61. package/dist/esm/serialization/resources/transcripts/client/requests/TranscriptsCreateRequest.d.mts +1 -2
  62. package/dist/esm/serialization/resources/transcripts/client/requests/TranscriptsCreateRequest.mjs +1 -2
  63. package/dist/esm/serialization/resources/transcripts/types/index.d.mts +0 -1
  64. package/dist/esm/serialization/resources/transcripts/types/index.mjs +0 -1
  65. package/dist/esm/serialization/types/StreamSupportedLanguage.d.mts +1 -1
  66. package/dist/esm/serialization/types/StreamSupportedLanguage.mjs +1 -16
  67. package/dist/esm/serialization/types/TranscribeSupportedLanguage.d.mts +1 -1
  68. package/dist/esm/serialization/types/TranscribeSupportedLanguage.mjs +1 -16
  69. package/dist/esm/version.d.mts +1 -1
  70. package/dist/esm/version.mjs +1 -1
  71. package/package.json +1 -1
  72. package/reference.md +1 -1
  73. package/dist/cjs/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.ts +0 -21
  74. package/dist/cjs/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.js +0 -20
  75. package/dist/cjs/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.ts +0 -10
  76. package/dist/cjs/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.js +0 -41
  77. package/dist/esm/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.mts +0 -21
  78. package/dist/esm/api/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.mjs +0 -17
  79. package/dist/esm/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.d.mts +0 -10
  80. package/dist/esm/serialization/resources/transcripts/types/TranscriptsCreateRequestPrimaryLanguage.mjs +0 -5
@@ -27,8 +27,8 @@ export class CortiClient {
27
27
  "Tenant-Name": _options === null || _options === void 0 ? void 0 : _options.tenantName,
28
28
  "X-Fern-Language": "JavaScript",
29
29
  "X-Fern-SDK-Name": "@corti/sdk",
30
- "X-Fern-SDK-Version": "0.1.0-alpha.rc",
31
- "User-Agent": "@corti/sdk/0.1.0-alpha.rc",
30
+ "X-Fern-SDK-Version": "0.1.2-alpha",
31
+ "User-Agent": "@corti/sdk/0.1.2-alpha",
32
32
  "X-Fern-Runtime": core.RUNTIME.type,
33
33
  "X-Fern-Runtime-Version": core.RUNTIME.version,
34
34
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -14,7 +14,7 @@ export interface TranscriptsCreateRequest {
14
14
  /** The unique identifier for the recording. */
15
15
  recordingId: Corti.Uuid;
16
16
  /** The primary spoken language of the recording. Check https://docs.corti.ai/about/languages for more. */
17
- primaryLanguage: Corti.TranscriptsCreateRequestPrimaryLanguage;
17
+ primaryLanguage: string;
18
18
  /** Indicates whether spoken dictation commands should be converted to punctuation (e.g., 'comma' → ','). */
19
19
  isDictation?: boolean;
20
20
  /** If true, each audio channel is transcribed separately. */
@@ -1,2 +1 @@
1
- export * from "./TranscriptsCreateRequestPrimaryLanguage.mjs";
2
1
  export * from "./TranscriptsCreateRequestModelName.mjs";
@@ -1,2 +1 @@
1
- export * from "./TranscriptsCreateRequestPrimaryLanguage.mjs";
2
1
  export * from "./TranscriptsCreateRequestModelName.mjs";
@@ -4,20 +4,4 @@
4
4
  /**
5
5
  * Supported language codes
6
6
  */
7
- export type StreamSupportedLanguage = "en" | "en-us" | "en-gb" | "da" | "se" | "no" | "de" | "nl" | "es" | "it" | "fr" | "pt" | "de-ch" | "sv";
8
- export declare const StreamSupportedLanguage: {
9
- readonly En: "en";
10
- readonly EnUs: "en-us";
11
- readonly EnGb: "en-gb";
12
- readonly Da: "da";
13
- readonly Se: "se";
14
- readonly No: "no";
15
- readonly De: "de";
16
- readonly Nl: "nl";
17
- readonly Es: "es";
18
- readonly It: "it";
19
- readonly Fr: "fr";
20
- readonly Pt: "pt";
21
- readonly DeCh: "de-ch";
22
- readonly Sv: "sv";
23
- };
7
+ export type StreamSupportedLanguage = string;
@@ -1,19 +1,4 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export const StreamSupportedLanguage = {
5
- En: "en",
6
- EnUs: "en-us",
7
- EnGb: "en-gb",
8
- Da: "da",
9
- Se: "se",
10
- No: "no",
11
- De: "de",
12
- Nl: "nl",
13
- Es: "es",
14
- It: "it",
15
- Fr: "fr",
16
- Pt: "pt",
17
- DeCh: "de-ch",
18
- Sv: "sv",
19
- };
4
+ export {};
@@ -4,20 +4,4 @@
4
4
  /**
5
5
  * Supported language codes for transcription
6
6
  */
7
- export type TranscribeSupportedLanguage = "en" | "en-us" | "en-gb" | "da" | "se" | "no" | "de" | "nl" | "es" | "it" | "fr" | "pt" | "de-ch" | "sv";
8
- export declare const TranscribeSupportedLanguage: {
9
- readonly En: "en";
10
- readonly EnUs: "en-us";
11
- readonly EnGb: "en-gb";
12
- readonly Da: "da";
13
- readonly Se: "se";
14
- readonly No: "no";
15
- readonly De: "de";
16
- readonly Nl: "nl";
17
- readonly Es: "es";
18
- readonly It: "it";
19
- readonly Fr: "fr";
20
- readonly Pt: "pt";
21
- readonly DeCh: "de-ch";
22
- readonly Sv: "sv";
23
- };
7
+ export type TranscribeSupportedLanguage = string;
@@ -1,19 +1,4 @@
1
1
  /**
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
- export const TranscribeSupportedLanguage = {
5
- En: "en",
6
- EnUs: "en-us",
7
- EnGb: "en-gb",
8
- Da: "da",
9
- Se: "se",
10
- No: "no",
11
- De: "de",
12
- Nl: "nl",
13
- Es: "es",
14
- It: "it",
15
- Fr: "fr",
16
- Pt: "pt",
17
- DeCh: "de-ch",
18
- Sv: "sv",
19
- };
4
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { ResponseWithBody } from "./ResponseWithBody.mjs";
2
- export interface BinaryResponse {
2
+ export type BinaryResponse = {
3
3
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
4
4
  bodyUsed: boolean;
5
5
  /**
@@ -11,7 +11,10 @@ export interface BinaryResponse {
11
11
  arrayBuffer: () => Promise<ArrayBuffer>;
12
12
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
13
13
  blob: () => Promise<Blob>;
14
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
15
- bytes(): Promise<Uint8Array>;
16
- }
14
+ /**
15
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
16
+ * Some versions of the Fetch API may not support this method.
17
+ */
18
+ bytes?(): Promise<Uint8Array>;
19
+ };
17
20
  export declare function getBinaryResponse(response: ResponseWithBody): BinaryResponse;
@@ -1,11 +1,14 @@
1
1
  export function getBinaryResponse(response) {
2
- return {
2
+ const binaryResponse = {
3
3
  get bodyUsed() {
4
4
  return response.bodyUsed;
5
5
  },
6
6
  stream: () => response.body,
7
7
  arrayBuffer: response.arrayBuffer.bind(response),
8
8
  blob: response.blob.bind(response),
9
- bytes: response.bytes.bind(response),
10
9
  };
10
+ if ("bytes" in response && typeof response.bytes === "function") {
11
+ binaryResponse.bytes = response.bytes.bind(response);
12
+ }
13
+ return binaryResponse;
11
14
  }
@@ -11,6 +11,7 @@ import { toJson } from "../json.mjs";
11
11
  import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
12
12
  import { Supplier } from "./Supplier.mjs";
13
13
  import { createRequestUrl } from "./createRequestUrl.mjs";
14
+ import { getErrorResponseBody } from "./getErrorResponseBody.mjs";
14
15
  import { getFetchFn } from "./getFetchFn.mjs";
15
16
  import { getRequestBody } from "./getRequestBody.mjs";
16
17
  import { getResponseBody } from "./getResponseBody.mjs";
@@ -51,11 +52,10 @@ export function fetcherImpl(args) {
51
52
  const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
52
53
  return makeRequest(fetchFn, url, args.method, yield getHeaders(args), requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
53
54
  }), args.maxRetries);
54
- const responseBody = yield getResponseBody(response, args.responseType);
55
55
  if (response.status >= 200 && response.status < 400) {
56
56
  return {
57
57
  ok: true,
58
- body: responseBody,
58
+ body: (yield getResponseBody(response, args.responseType)),
59
59
  headers: response.headers,
60
60
  rawResponse: toRawResponse(response),
61
61
  };
@@ -66,7 +66,7 @@ export function fetcherImpl(args) {
66
66
  error: {
67
67
  reason: "status-code",
68
68
  statusCode: response.status,
69
- body: responseBody,
69
+ body: yield getErrorResponseBody(response),
70
70
  },
71
71
  rawResponse: toRawResponse(response),
72
72
  };
@@ -0,0 +1 @@
1
+ export declare function getErrorResponseBody(response: Response): Promise<unknown>;
@@ -0,0 +1,41 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { fromJson } from "../json.mjs";
11
+ import { getResponseBody } from "./getResponseBody.mjs";
12
+ export function getErrorResponseBody(response) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ var _a, _b, _c;
15
+ let contentType = (_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
16
+ if (contentType == null || contentType.length === 0) {
17
+ return getResponseBody(response);
18
+ }
19
+ if (contentType.indexOf(";") !== -1) {
20
+ contentType = (_c = (_b = contentType.split(";")[0]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : "";
21
+ }
22
+ switch (contentType) {
23
+ case "application/hal+json":
24
+ case "application/json":
25
+ case "application/ld+json":
26
+ case "application/problem+json":
27
+ case "application/vnd.api+json":
28
+ case "text/json":
29
+ const text = yield response.text();
30
+ return text.length > 0 ? fromJson(text) : undefined;
31
+ default:
32
+ if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) {
33
+ const text = yield response.text();
34
+ return text.length > 0 ? fromJson(text) : undefined;
35
+ }
36
+ // Fallback to plain text if content type is not recognized
37
+ // Even if no body is present, the response will be an empty string
38
+ return yield response.text();
39
+ }
40
+ });
41
+ }
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { getBinaryResponse } from "./BinaryResponse.mjs";
11
11
  import { isResponseWithBody } from "./ResponseWithBody.mjs";
12
+ import { fromJson } from "../json.mjs";
12
13
  export function getResponseBody(response, responseType) {
13
14
  return __awaiter(this, void 0, void 0, function* () {
14
15
  if (!isResponseWithBody(response)) {
@@ -32,7 +33,7 @@ export function getResponseBody(response, responseType) {
32
33
  const text = yield response.text();
33
34
  if (text.length > 0) {
34
35
  try {
35
- let responseBody = JSON.parse(text);
36
+ let responseBody = fromJson(text);
36
37
  return responseBody;
37
38
  }
38
39
  catch (err) {
@@ -2,6 +2,9 @@ export function join(base, ...segments) {
2
2
  if (!base) {
3
3
  return "";
4
4
  }
5
+ if (segments.length === 0) {
6
+ return base;
7
+ }
5
8
  if (base.includes("://")) {
6
9
  let url;
7
10
  try {
@@ -11,24 +14,37 @@ export function join(base, ...segments) {
11
14
  // Fallback to path joining if URL is malformed
12
15
  return joinPath(base, ...segments);
13
16
  }
17
+ const lastSegment = segments[segments.length - 1];
18
+ const shouldPreserveTrailingSlash = lastSegment && lastSegment.endsWith("/");
14
19
  for (const segment of segments) {
15
20
  const cleanSegment = trimSlashes(segment);
16
21
  if (cleanSegment) {
17
22
  url.pathname = joinPathSegments(url.pathname, cleanSegment);
18
23
  }
19
24
  }
25
+ if (shouldPreserveTrailingSlash && !url.pathname.endsWith("/")) {
26
+ url.pathname += "/";
27
+ }
20
28
  return url.toString();
21
29
  }
22
30
  return joinPath(base, ...segments);
23
31
  }
24
32
  function joinPath(base, ...segments) {
33
+ if (segments.length === 0) {
34
+ return base;
35
+ }
25
36
  let result = base;
37
+ const lastSegment = segments[segments.length - 1];
38
+ const shouldPreserveTrailingSlash = lastSegment && lastSegment.endsWith("/");
26
39
  for (const segment of segments) {
27
40
  const cleanSegment = trimSlashes(segment);
28
41
  if (cleanSegment) {
29
42
  result = joinPathSegments(result, cleanSegment);
30
43
  }
31
44
  }
45
+ if (shouldPreserveTrailingSlash && !result.endsWith("/")) {
46
+ result += "/";
47
+ }
32
48
  return result;
33
49
  }
34
50
  function joinPathSegments(left, right) {
@@ -40,7 +56,11 @@ function joinPathSegments(left, right) {
40
56
  function trimSlashes(str) {
41
57
  if (!str)
42
58
  return str;
43
- let start = str.startsWith("/") ? 1 : 0;
44
- let end = str.endsWith("/") ? str.length - 1 : str.length;
45
- return str.slice(start, end);
59
+ let start = 0;
60
+ let end = str.length;
61
+ if (str.startsWith("/"))
62
+ start = 1;
63
+ if (str.endsWith("/"))
64
+ end = str.length - 1;
65
+ return start === 0 && end === str.length ? str : str.slice(start, end);
46
66
  }
@@ -40,7 +40,10 @@ export declare namespace CortiClient {
40
40
  clientSecret: core.Supplier<string>;
41
41
  }
42
42
  interface Options {
43
- environment: core.Supplier<environments.CortiEnvironment | environments.CortiEnvironmentUrls>;
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. */
@@ -61,7 +61,13 @@ export class CortiClient {
61
61
  "User-Agent": `@corti/sdk/${SDK_VERSION}`,
62
62
  "X-Fern-Runtime": core.RUNTIME.type,
63
63
  "X-Fern-Runtime-Version": core.RUNTIME.version,
64
- }, _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 });
64
+ }, _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: typeof _options.environment === "string"
65
+ ? {
66
+ base: `https://api.${_options.environment}.corti.app/v2`,
67
+ wss: `wss://api.${_options.environment}.corti.app`,
68
+ login: `https://auth.${_options.environment}.corti.app/realms`,
69
+ }
70
+ : _options.environment });
65
71
  /**
66
72
  * Patch: if `accessToken` is provided, use BearerProvider, otherwise use OAuthTokenProvider
67
73
  */
@@ -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'>, configuration?: api.StreamConfig): Promise<StreamSocket>;
17
+ connect({ configuration, ...args }: Omit<FernStream.ConnectArgs, 'token' | 'tenantName'> & {
18
+ configuration?: api.StreamConfig;
19
+ }): Promise<StreamSocket>;
18
20
  }
@@ -7,6 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
10
21
  /**
11
22
  * Patch: use custom Stream implementation to support passing _options parameters to connection function
12
23
  */
@@ -23,11 +34,12 @@ export class Stream extends FernStream {
23
34
  /**
24
35
  * Patch: use custom connect method to support passing _options parameters
25
36
  */
26
- connect(args, configuration) {
37
+ connect(_a) {
27
38
  const _super = Object.create(null, {
28
39
  connect: { get: () => super.connect }
29
40
  });
30
41
  return __awaiter(this, void 0, void 0, function* () {
42
+ var { configuration } = _a, args = __rest(_a, ["configuration"]);
31
43
  const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || '', tenantName: yield core.Supplier.get(this._options.tenantName) }));
32
44
  const ws = new StreamSocket({ socket: fernWs.socket });
33
45
  if (!configuration) {
@@ -62,6 +74,14 @@ export class Stream extends FernStream {
62
74
  ws.close();
63
75
  return;
64
76
  }
77
+ if (parsedResponse.ok && parsedResponse.value.type === 'error') {
78
+ ws.socket.dispatchEvent(new ErrorEvent({
79
+ name: 'error',
80
+ message: JSON.stringify(parsedResponse.value.error),
81
+ }, ''));
82
+ ws.close();
83
+ return;
84
+ }
65
85
  if (parsedResponse.ok && parsedResponse.value.type === 'ENDED') {
66
86
  ws.close();
67
87
  return;
@@ -3,9 +3,13 @@
3
3
  */
4
4
  import { StreamSocket as FernStreamSocket } from '../api/resources/stream/client/Socket.mjs';
5
5
  export declare class StreamSocket extends FernStreamSocket {
6
- sendAudio(message: ArrayBuffer | string): void;
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
  }
@@ -22,4 +22,12 @@ export class StreamSocket extends FernStreamSocket {
22
22
  throw new Error("Socket is not open.");
23
23
  }
24
24
  }
25
+ /**
26
+ * Patch: added ability to remove event handlers
27
+ */
28
+ off(event, callback) {
29
+ if (!callback || callback === this.eventHandlers[event]) {
30
+ delete this.eventHandlers[event];
31
+ }
32
+ }
25
33
  }
@@ -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'>, configuration?: api.TranscribeConfig): Promise<TranscribeSocket>;
17
+ connect({ configuration, ...args }?: Omit<FernTranscribe.ConnectArgs, 'token' | 'tenantName'> & {
18
+ configuration?: api.TranscribeConfig;
19
+ }): Promise<TranscribeSocket>;
18
20
  }
@@ -7,6 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
10
21
  /**
11
22
  * Patch: use custom Transcribe implementation to support passing _options parameters to connection function
12
23
  */
@@ -27,7 +38,8 @@ export class Transcribe extends FernTranscribe {
27
38
  const _super = Object.create(null, {
28
39
  connect: { get: () => super.connect }
29
40
  });
30
- return __awaiter(this, arguments, void 0, function* (args = {}, configuration) {
41
+ return __awaiter(this, arguments, void 0, function* (_a = {}) {
42
+ var { configuration } = _a, args = __rest(_a, ["configuration"]);
31
43
  const fernWs = yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || '', tenantName: yield core.Supplier.get(this._options.tenantName) }));
32
44
  const ws = new TranscribeSocket({ socket: fernWs.socket });
33
45
  if (!configuration) {
@@ -60,6 +72,14 @@ export class Transcribe extends FernTranscribe {
60
72
  ws.close();
61
73
  return;
62
74
  }
75
+ if (parsedResponse.ok && parsedResponse.value.type === 'error') {
76
+ ws.socket.dispatchEvent(new ErrorEvent({
77
+ name: 'error',
78
+ message: JSON.stringify(parsedResponse.value.error),
79
+ }, ''));
80
+ ws.close();
81
+ return;
82
+ }
63
83
  if (parsedResponse.ok && parsedResponse.value.type === 'ended') {
64
84
  ws.close();
65
85
  return;
@@ -3,9 +3,13 @@
3
3
  */
4
4
  import { TranscribeSocket as FernTranscribeSocket } from '../api/resources/transcribe/client/Socket.mjs';
5
5
  export declare class TranscribeSocket extends FernTranscribeSocket {
6
- sendAudio(message: ArrayBuffer | string): void;
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 FernTranscribeSocket.EventHandlers>(event: T, callback?: FernTranscribeSocket.EventHandlers[T]): void;
11
15
  }
@@ -22,4 +22,12 @@ export class TranscribeSocket extends FernTranscribeSocket {
22
22
  throw new Error("Socket is not open.");
23
23
  }
24
24
  }
25
+ /**
26
+ * Patch: added ability to remove event handlers
27
+ */
28
+ off(event, callback) {
29
+ if (!callback || callback === this.eventHandlers[event]) {
30
+ delete this.eventHandlers[event];
31
+ }
32
+ }
25
33
  }
@@ -5,14 +5,13 @@ import * as serializers from "../../../../index.mjs";
5
5
  import * as Corti from "../../../../../api/index.mjs";
6
6
  import * as core from "../../../../../core/index.mjs";
7
7
  import { Uuid } from "../../../../types/Uuid.mjs";
8
- import { TranscriptsCreateRequestPrimaryLanguage } from "../../types/TranscriptsCreateRequestPrimaryLanguage.mjs";
9
8
  import { TranscriptsParticipant } from "../../../../types/TranscriptsParticipant.mjs";
10
9
  import { TranscriptsCreateRequestModelName } from "../../types/TranscriptsCreateRequestModelName.mjs";
11
10
  export declare const TranscriptsCreateRequest: core.serialization.Schema<serializers.TranscriptsCreateRequest.Raw, Corti.TranscriptsCreateRequest>;
12
11
  export declare namespace TranscriptsCreateRequest {
13
12
  interface Raw {
14
13
  recordingId: Uuid.Raw;
15
- primaryLanguage: TranscriptsCreateRequestPrimaryLanguage.Raw;
14
+ primaryLanguage: string;
16
15
  isDictation?: boolean | null;
17
16
  isMultichannel?: boolean | null;
18
17
  diarize?: boolean | null;
@@ -3,12 +3,11 @@
3
3
  */
4
4
  import * as core from "../../../../../core/index.mjs";
5
5
  import { Uuid } from "../../../../types/Uuid.mjs";
6
- import { TranscriptsCreateRequestPrimaryLanguage } from "../../types/TranscriptsCreateRequestPrimaryLanguage.mjs";
7
6
  import { TranscriptsParticipant } from "../../../../types/TranscriptsParticipant.mjs";
8
7
  import { TranscriptsCreateRequestModelName } from "../../types/TranscriptsCreateRequestModelName.mjs";
9
8
  export const TranscriptsCreateRequest = core.serialization.object({
10
9
  recordingId: Uuid,
11
- primaryLanguage: TranscriptsCreateRequestPrimaryLanguage,
10
+ primaryLanguage: core.serialization.string(),
12
11
  isDictation: core.serialization.boolean().optional(),
13
12
  isMultichannel: core.serialization.boolean().optional(),
14
13
  diarize: core.serialization.boolean().optional(),
@@ -1,2 +1 @@
1
- export * from "./TranscriptsCreateRequestPrimaryLanguage.mjs";
2
1
  export * from "./TranscriptsCreateRequestModelName.mjs";
@@ -1,2 +1 @@
1
- export * from "./TranscriptsCreateRequestPrimaryLanguage.mjs";
2
1
  export * from "./TranscriptsCreateRequestModelName.mjs";
@@ -6,5 +6,5 @@ import * as Corti from "../../api/index.mjs";
6
6
  import * as core from "../../core/index.mjs";
7
7
  export declare const StreamSupportedLanguage: core.serialization.Schema<serializers.StreamSupportedLanguage.Raw, Corti.StreamSupportedLanguage>;
8
8
  export declare namespace StreamSupportedLanguage {
9
- type Raw = "en" | "en-us" | "en-gb" | "da" | "se" | "no" | "de" | "nl" | "es" | "it" | "fr" | "pt" | "de-ch" | "sv";
9
+ type Raw = string;
10
10
  }
@@ -2,19 +2,4 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as core from "../../core/index.mjs";
5
- export const StreamSupportedLanguage = core.serialization.enum_([
6
- "en",
7
- "en-us",
8
- "en-gb",
9
- "da",
10
- "se",
11
- "no",
12
- "de",
13
- "nl",
14
- "es",
15
- "it",
16
- "fr",
17
- "pt",
18
- "de-ch",
19
- "sv",
20
- ]);
5
+ export const StreamSupportedLanguage = core.serialization.string();
@@ -6,5 +6,5 @@ import * as Corti from "../../api/index.mjs";
6
6
  import * as core from "../../core/index.mjs";
7
7
  export declare const TranscribeSupportedLanguage: core.serialization.Schema<serializers.TranscribeSupportedLanguage.Raw, Corti.TranscribeSupportedLanguage>;
8
8
  export declare namespace TranscribeSupportedLanguage {
9
- type Raw = "en" | "en-us" | "en-gb" | "da" | "se" | "no" | "de" | "nl" | "es" | "it" | "fr" | "pt" | "de-ch" | "sv";
9
+ type Raw = string;
10
10
  }
@@ -2,19 +2,4 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as core from "../../core/index.mjs";
5
- export const TranscribeSupportedLanguage = core.serialization.enum_([
6
- "en",
7
- "en-us",
8
- "en-gb",
9
- "da",
10
- "se",
11
- "no",
12
- "de",
13
- "nl",
14
- "es",
15
- "it",
16
- "fr",
17
- "pt",
18
- "de-ch",
19
- "sv",
20
- ]);
5
+ export const TranscribeSupportedLanguage = core.serialization.string();
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.1.0-alpha.rc";
1
+ export declare const SDK_VERSION = "0.1.2-alpha";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.1.0-alpha.rc";
1
+ export const SDK_VERSION = "0.1.2-alpha";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corti/sdk",
3
- "version": "0.1.0-alpha.rc",
3
+ "version": "0.1.2-alpha",
4
4
  "private": false,
5
5
  "repository": "github:corticph/corti-sdk-typescript",
6
6
  "license": "MIT",