@deepgram/sdk 4.9.0 → 4.10.0
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 +155 -331
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +11 -2
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types/DeepgramSource.d.ts +1 -1
- package/dist/main/lib/types/DeepgramSource.d.ts.map +1 -1
- package/dist/main/lib/types/GrantTokenSchema.d.ts +10 -0
- package/dist/main/lib/types/GrantTokenSchema.d.ts.map +1 -0
- package/dist/main/lib/types/GrantTokenSchema.js +3 -0
- package/dist/main/lib/types/GrantTokenSchema.js.map +1 -0
- package/dist/main/lib/types/index.d.ts +1 -0
- package/dist/main/lib/types/index.d.ts.map +1 -1
- package/dist/main/lib/types/index.js +1 -0
- package/dist/main/lib/types/index.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/packages/AbstractRestClient.d.ts +1 -1
- package/dist/main/packages/AbstractRestClient.d.ts.map +1 -1
- package/dist/main/packages/AuthRestClient.d.ts +3 -1
- package/dist/main/packages/AuthRestClient.d.ts.map +1 -1
- package/dist/main/packages/AuthRestClient.js +6 -2
- package/dist/main/packages/AuthRestClient.js.map +1 -1
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +11 -2
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types/DeepgramSource.d.ts +1 -1
- package/dist/module/lib/types/DeepgramSource.d.ts.map +1 -1
- package/dist/module/lib/types/GrantTokenSchema.d.ts +10 -0
- package/dist/module/lib/types/GrantTokenSchema.d.ts.map +1 -0
- package/dist/module/lib/types/GrantTokenSchema.js +2 -0
- package/dist/module/lib/types/GrantTokenSchema.js.map +1 -0
- package/dist/module/lib/types/index.d.ts +1 -0
- package/dist/module/lib/types/index.d.ts.map +1 -1
- package/dist/module/lib/types/index.js +1 -0
- package/dist/module/lib/types/index.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/packages/AbstractRestClient.d.ts +1 -1
- package/dist/module/packages/AbstractRestClient.d.ts.map +1 -1
- package/dist/module/packages/AuthRestClient.d.ts +3 -1
- package/dist/module/packages/AuthRestClient.d.ts.map +1 -1
- package/dist/module/packages/AuthRestClient.js +6 -2
- package/dist/module/packages/AuthRestClient.js.map +1 -1
- package/dist/umd/deepgram.js +1 -2
- package/package.json +1 -1
- package/src/lib/helpers.ts +14 -2
- package/src/lib/types/DeepgramSource.ts +1 -1
- package/src/lib/types/GrantTokenSchema.ts +9 -0
- package/src/lib/types/index.ts +1 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/AbstractRestClient.ts +1 -1
- package/src/packages/AuthRestClient.ts +7 -3
- package/dist/umd/deepgram.js.LICENSE.txt +0 -10
package/package.json
CHANGED
package/src/lib/helpers.ts
CHANGED
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
TranscriptionSchema,
|
|
10
10
|
} from "./types";
|
|
11
11
|
import { Headers as CrossFetchHeaders } from "cross-fetch";
|
|
12
|
-
import { Readable } from "stream";
|
|
12
|
+
import type { Readable } from "node:stream";
|
|
13
13
|
import merge from "deepmerge";
|
|
14
|
+
import { isBrowser } from "./runtime";
|
|
14
15
|
|
|
15
16
|
export function stripTrailingSlash(url: string): string {
|
|
16
17
|
return url.replace(/\/$/, "");
|
|
@@ -71,7 +72,18 @@ const isBufferSource = (providedSource: PrerecordedSource): providedSource is Bu
|
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
const isReadStreamSource = (providedSource: PrerecordedSource): providedSource is Readable => {
|
|
74
|
-
|
|
75
|
+
if (providedSource == null) return false;
|
|
76
|
+
|
|
77
|
+
// In browser environments, there's no Readable stream from Node.js
|
|
78
|
+
if (isBrowser()) return false;
|
|
79
|
+
|
|
80
|
+
// Check for stream-like properties without importing Readable
|
|
81
|
+
return (
|
|
82
|
+
typeof providedSource === "object" &&
|
|
83
|
+
typeof (providedSource as any).pipe === "function" &&
|
|
84
|
+
typeof (providedSource as any).read === "function" &&
|
|
85
|
+
typeof (providedSource as any)._readableState === "object"
|
|
86
|
+
);
|
|
75
87
|
};
|
|
76
88
|
|
|
77
89
|
export class CallbackUrl extends URL {
|
package/src/lib/types/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./GetProjectUsageSummaryResponse";
|
|
|
27
27
|
export * from "./GetProjectUsageSummarySchema";
|
|
28
28
|
export * from "./GetTokenDetailsResponse";
|
|
29
29
|
export * from "./GrantTokenResponse";
|
|
30
|
+
export * from "./GrantTokenSchema";
|
|
30
31
|
export * from "./ListOnPremCredentialsResponse";
|
|
31
32
|
export * from "./LiveConfigOptions";
|
|
32
33
|
export * from "./LiveMetadataEvent";
|
package/src/lib/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "4.
|
|
1
|
+
export const version = "4.10.0";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepgramApiError, DeepgramError, DeepgramUnknownError } from "../lib/errors";
|
|
2
|
-
import { Readable } from "stream";
|
|
2
|
+
import type { Readable } from "node:stream";
|
|
3
3
|
import { fetchWithAuth, resolveResponse } from "../lib/fetch";
|
|
4
4
|
import type { Fetch, FetchOptions, RequestMethodType } from "../lib/types/Fetch";
|
|
5
5
|
import { AbstractClient } from "./AbstractClient";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isDeepgramError } from "../lib/errors";
|
|
2
2
|
import type { DeepgramResponse } from "../lib/types/DeepgramResponse";
|
|
3
3
|
import type { GrantTokenResponse } from "../lib/types/GrantTokenResponse";
|
|
4
|
+
import type { GrantTokenSchema } from "../lib/types/GrantTokenSchema";
|
|
4
5
|
import { AbstractRestClient } from "./AbstractRestClient";
|
|
5
6
|
|
|
6
7
|
export class AuthRestClient extends AbstractRestClient {
|
|
@@ -8,17 +9,20 @@ export class AuthRestClient extends AbstractRestClient {
|
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Generates a new temporary token for the Deepgram API.
|
|
12
|
+
* @param options Optional configuration options for the token generation. Includes ttl_seconds to set token expiration.
|
|
11
13
|
* @param endpoint Optional custom endpoint to use for the request. Defaults to ":version/auth/grant".
|
|
12
14
|
* @returns Object containing the result of the request or an error if one occurred. Result will contain access_token and expires_in properties.
|
|
13
15
|
*/
|
|
14
16
|
public async grantToken(
|
|
17
|
+
options: GrantTokenSchema = {},
|
|
15
18
|
endpoint = ":version/auth/grant"
|
|
16
19
|
): Promise<DeepgramResponse<GrantTokenResponse>> {
|
|
17
20
|
try {
|
|
18
21
|
const requestUrl = this.getRequestUrl(endpoint);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const body = JSON.stringify(options);
|
|
23
|
+
const result: GrantTokenResponse = await this.post(requestUrl, body, {
|
|
24
|
+
headers: { "Content-Type": "application/json" },
|
|
25
|
+
}).then((result) => result.json());
|
|
22
26
|
|
|
23
27
|
return { result, error: null };
|
|
24
28
|
} catch (error) {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* The buffer module from node.js, for the browser.
|
|
3
|
-
*
|
|
4
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
-
* @license MIT
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
9
|
-
|
|
10
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|