@deepgram/sdk 4.7.0 → 4.8.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.
Files changed (78) hide show
  1. package/README.md +4 -2
  2. package/dist/main/lib/helpers.d.ts.map +1 -1
  3. package/dist/main/lib/helpers.js +7 -10
  4. package/dist/main/lib/helpers.js.map +1 -1
  5. package/dist/main/lib/types/AgentLiveSchema.d.ts +1 -1
  6. package/dist/main/lib/types/AgentLiveSchema.d.ts.map +1 -1
  7. package/dist/main/lib/types/CreateProjectKeySchema.d.ts +1 -1
  8. package/dist/main/lib/types/CreateProjectKeySchema.d.ts.map +1 -1
  9. package/dist/main/lib/types/DeepgramClientOptions.d.ts +6 -6
  10. package/dist/main/lib/types/DeepgramClientOptions.d.ts.map +1 -1
  11. package/dist/main/lib/types/DeepgramResponse.d.ts +1 -1
  12. package/dist/main/lib/types/DeepgramResponse.d.ts.map +1 -1
  13. package/dist/main/lib/types/DeepgramSource.d.ts +4 -3
  14. package/dist/main/lib/types/DeepgramSource.d.ts.map +1 -1
  15. package/dist/main/lib/types/Fetch.d.ts +3 -3
  16. package/dist/main/lib/types/Fetch.d.ts.map +1 -1
  17. package/dist/main/lib/types/GetModelsResponse.d.ts +3 -3
  18. package/dist/main/lib/types/GetModelsResponse.d.ts.map +1 -1
  19. package/dist/main/lib/types/LiveConfigOptions.d.ts +1 -1
  20. package/dist/main/lib/types/LiveConfigOptions.d.ts.map +1 -1
  21. package/dist/main/lib/types/VoidResponse.d.ts +1 -1
  22. package/dist/main/lib/types/VoidResponse.d.ts.map +1 -1
  23. package/dist/main/lib/version.d.ts +1 -1
  24. package/dist/main/lib/version.js +1 -1
  25. package/dist/main/packages/AbstractLiveClient.d.ts +2 -2
  26. package/dist/main/packages/AbstractLiveClient.d.ts.map +1 -1
  27. package/dist/main/packages/AbstractRestClient.d.ts +1 -0
  28. package/dist/main/packages/AbstractRestClient.d.ts.map +1 -1
  29. package/dist/main/packages/AgentLiveClient.d.ts +9 -0
  30. package/dist/main/packages/AgentLiveClient.d.ts.map +1 -1
  31. package/dist/main/packages/AgentLiveClient.js +10 -0
  32. package/dist/main/packages/AgentLiveClient.js.map +1 -1
  33. package/dist/main/packages/ManageRestClient.js +1 -1
  34. package/dist/main/packages/ManageRestClient.js.map +1 -1
  35. package/dist/main/packages/SpeakLiveClient.d.ts +1 -0
  36. package/dist/main/packages/SpeakLiveClient.d.ts.map +1 -1
  37. package/dist/module/lib/helpers.d.ts.map +1 -1
  38. package/dist/module/lib/helpers.js +7 -10
  39. package/dist/module/lib/helpers.js.map +1 -1
  40. package/dist/module/lib/types/AgentLiveSchema.d.ts +1 -1
  41. package/dist/module/lib/types/AgentLiveSchema.d.ts.map +1 -1
  42. package/dist/module/lib/types/CreateProjectKeySchema.d.ts +1 -1
  43. package/dist/module/lib/types/CreateProjectKeySchema.d.ts.map +1 -1
  44. package/dist/module/lib/types/DeepgramClientOptions.d.ts +6 -6
  45. package/dist/module/lib/types/DeepgramClientOptions.d.ts.map +1 -1
  46. package/dist/module/lib/types/DeepgramResponse.d.ts +1 -1
  47. package/dist/module/lib/types/DeepgramResponse.d.ts.map +1 -1
  48. package/dist/module/lib/types/DeepgramSource.d.ts +4 -3
  49. package/dist/module/lib/types/DeepgramSource.d.ts.map +1 -1
  50. package/dist/module/lib/types/Fetch.d.ts +3 -3
  51. package/dist/module/lib/types/Fetch.d.ts.map +1 -1
  52. package/dist/module/lib/types/GetModelsResponse.d.ts +3 -3
  53. package/dist/module/lib/types/GetModelsResponse.d.ts.map +1 -1
  54. package/dist/module/lib/types/LiveConfigOptions.d.ts +1 -1
  55. package/dist/module/lib/types/LiveConfigOptions.d.ts.map +1 -1
  56. package/dist/module/lib/types/VoidResponse.d.ts +1 -1
  57. package/dist/module/lib/types/VoidResponse.d.ts.map +1 -1
  58. package/dist/module/lib/version.d.ts +1 -1
  59. package/dist/module/lib/version.js +1 -1
  60. package/dist/module/packages/AbstractLiveClient.d.ts +2 -2
  61. package/dist/module/packages/AbstractLiveClient.d.ts.map +1 -1
  62. package/dist/module/packages/AbstractRestClient.d.ts +1 -0
  63. package/dist/module/packages/AbstractRestClient.d.ts.map +1 -1
  64. package/dist/module/packages/AgentLiveClient.d.ts +9 -0
  65. package/dist/module/packages/AgentLiveClient.d.ts.map +1 -1
  66. package/dist/module/packages/AgentLiveClient.js +10 -0
  67. package/dist/module/packages/AgentLiveClient.js.map +1 -1
  68. package/dist/module/packages/ManageRestClient.js +1 -1
  69. package/dist/module/packages/ManageRestClient.js.map +1 -1
  70. package/dist/module/packages/SpeakLiveClient.d.ts +1 -0
  71. package/dist/module/packages/SpeakLiveClient.d.ts.map +1 -1
  72. package/dist/umd/deepgram.js +2 -1
  73. package/dist/umd/deepgram.js.LICENSE.txt +10 -0
  74. package/package.json +21 -15
  75. package/src/lib/helpers.ts +6 -10
  76. package/src/lib/version.ts +1 -1
  77. package/src/packages/AgentLiveClient.ts +11 -0
  78. package/src/packages/ManageRestClient.ts +1 -1
@@ -0,0 +1,10 @@
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> */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepgram/sdk",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Isomorphic Javascript client for Deepgram",
5
5
  "keywords": [
6
6
  "javascript",
@@ -10,6 +10,7 @@
10
10
  "speech",
11
11
  "sdk"
12
12
  ],
13
+ "packageManager": "pnpm@10.12.1",
13
14
  "homepage": "https://github.com/deepgram/deepgram-js-sdk",
14
15
  "bugs": "https://github.com/deepgram/deepgram-js-sdk/issues",
15
16
  "license": "MIT",
@@ -39,21 +40,26 @@
39
40
  "repository": "deepgram/deepgram-js-sdk",
40
41
  "scripts": {
41
42
  "clean": "rimraf dist docs/v2",
42
- "format": "prettier --write \"{src,test}/**/*.ts\"",
43
+ "format": "prettier --write \"src/**/*.ts\"",
43
44
  "build": "run-s clean format build:*",
44
45
  "build:main": "tsc -p tsconfig.json",
45
46
  "build:module": "tsc -p tsconfig.module.json",
46
47
  "build:umd": "webpack --mode=production",
47
48
  "lint": "run-s lint:*",
48
- "lint:js": "eslint --no-eslintrc -c .eslintrc-examples.js examples --max-warnings 0",
49
+ "lint:js": "eslint -c .eslintrc-examples.js examples --max-warnings 0",
49
50
  "lint:md": "markdownlint **/*.md *.md",
50
51
  "lint:yml": "yamllint .github/workflows",
51
52
  "lint:ts": "eslint src --max-warnings 0",
52
53
  "watch": "nodemon -e ts --watch src --exec \"npm run build\"",
53
- "test": "mocha -r ts-node/register test/*test.ts test/**/*test.ts --inspect --exit",
54
- "test:coverage": "nyc --reporter=lcovonly --reporter=text --reporter=text-summary npm run test",
55
54
  "docs": "typedoc --entryPoints src/index.ts --out docs/ --includes src/packages/**/*.ts --emit none",
56
- "docs:json": "typedoc --entryPoints src/index.ts --includes src/packages/**/*.ts --json docs/spec.json --emit none"
55
+ "docs:json": "typedoc --entryPoints src/index.ts --includes src/packages/**/*.ts --json docs/spec.json --emit none",
56
+ "test": "jest",
57
+ "test:unit": "jest --testPathPattern=tests/unit",
58
+ "test:e2e": "jest --testPathPattern=tests/e2e",
59
+ "test:e2e:offline": "node scripts/test-offline.js",
60
+ "test:watch": "jest --watch",
61
+ "test:coverage": "jest --coverage",
62
+ "test:ci": "jest --ci --coverage --watchAll=false"
57
63
  },
58
64
  "dependencies": {
59
65
  "@deepgram/captions": "^1.1.1",
@@ -66,33 +72,33 @@
66
72
  "devDependencies": {
67
73
  "@commitlint/cli": "^17.6.7",
68
74
  "@commitlint/config-conventional": "^17.6.7",
69
- "@faker-js/faker": "^8.0.2",
70
- "@flydotio/dockerfile": "^0.4.10",
71
- "@types/chai": "^4.3.5",
72
- "@types/mocha": "^9.1.1",
73
- "@types/sinon": "^17.0.3",
75
+ "@types/jest": "^29.5.12",
74
76
  "@types/ws": "^8.5.10",
75
77
  "@typescript-eslint/eslint-plugin": "^8.7.0",
76
78
  "@typescript-eslint/parser": "^8.7.0",
77
- "chai": "^4.3.7",
79
+ "buffer": "^6.0.3",
78
80
  "cross-env": "^7.0.3",
81
+ "dotenv": "^16.5.0",
79
82
  "eslint": "^8.57.1",
80
83
  "husky": "^4.3.0",
84
+ "jest": "^29.7.0",
85
+ "jest-environment-jsdom": "^29.7.0",
81
86
  "markdownlint": "^0.35.0",
82
87
  "markdownlint-cli": "^0.42.0",
83
- "mocha": "^9.2.2",
84
88
  "nodemon": "^3.0.1",
85
89
  "npm-run-all": "^4.1.5",
86
- "nyc": "^15.1.0",
87
90
  "prettier": "^2.5.1",
88
91
  "pretty-quick": "^3.1.3",
89
92
  "rimraf": "^3.0.2",
90
93
  "semantic-release-plugin-update-version-in-files": "^1.1.0",
91
- "sinon": "^17.0.1",
94
+ "stream-browserify": "^3.0.0",
95
+ "ts-jest": "^29.1.2",
92
96
  "ts-loader": "^8.0.11",
93
97
  "ts-node": "^10.9.1",
94
98
  "typedoc": "^0.22.16",
95
99
  "typescript": "^4.5.5",
100
+ "url": "^0.11.4",
101
+ "util": "^0.12.5",
96
102
  "webpack": "^5.69.1",
97
103
  "webpack-cli": "^4.9.2",
98
104
  "yaml-lint": "^1.7.0"
@@ -47,7 +47,7 @@ export const resolveHeadersConstructor = () => {
47
47
  export const isUrlSource = (
48
48
  providedSource: PrerecordedSource | AnalyzeSource
49
49
  ): providedSource is UrlSource => {
50
- if ((providedSource as UrlSource).url) return true;
50
+ if (providedSource && (providedSource as UrlSource).url) return true;
51
51
 
52
52
  return false;
53
53
  };
@@ -55,7 +55,7 @@ export const isUrlSource = (
55
55
  export const isTextSource = (
56
56
  providedSource: PrerecordedSource | AnalyzeSource
57
57
  ): providedSource is TextSource => {
58
- if ((providedSource as TextSource).text) return true;
58
+ if (providedSource && (providedSource as TextSource).text) return true;
59
59
 
60
60
  return false;
61
61
  };
@@ -67,15 +67,11 @@ export const isFileSource = (providedSource: PrerecordedSource): providedSource
67
67
  };
68
68
 
69
69
  const isBufferSource = (providedSource: PrerecordedSource): providedSource is Buffer => {
70
- if (providedSource as Buffer) return true;
71
-
72
- return false;
70
+ return providedSource != null && Buffer.isBuffer(providedSource);
73
71
  };
74
72
 
75
73
  const isReadStreamSource = (providedSource: PrerecordedSource): providedSource is Readable => {
76
- if (providedSource as Readable) return true;
77
-
78
- return false;
74
+ return providedSource != null && providedSource instanceof Readable;
79
75
  };
80
76
 
81
77
  export class CallbackUrl extends URL {
@@ -100,11 +96,11 @@ export const buildRequestUrl = (
100
96
  };
101
97
 
102
98
  export function isLiveSchema(arg: any): arg is LiveSchema {
103
- return arg && typeof arg.interim_results !== "undefined";
99
+ return arg != null && typeof arg.interim_results !== "undefined";
104
100
  }
105
101
 
106
102
  export function isDeepgramClientOptions(arg: any): arg is DeepgramClientOptions {
107
- return arg && typeof arg.global !== "undefined";
103
+ return arg != null && typeof arg.global !== "undefined";
108
104
  }
109
105
 
110
106
  export const convertLegacyOptions = (optionsArg: DeepgramClientOptions): DeepgramClientOptions => {
@@ -1 +1 @@
1
- export const version = "4.7.0";
1
+ export const version = "4.8.0";
@@ -140,6 +140,17 @@ export class AgentLiveClient extends AbstractLiveClient {
140
140
  this.send(JSON.stringify({ type: "InjectAgentMessage", content }));
141
141
  }
142
142
 
143
+ /**
144
+ * Send a text-based message to the agent as if it came from the user.
145
+ * This allows you to inject user messages into the conversation for the agent to respond to.
146
+ * @example "Hello! Can you hear me?"
147
+ * @example "What's the weather like today?"
148
+ * @param content - The specific phrase or statement the agent should respond to.
149
+ */
150
+ public injectUserMessage(content: string): void {
151
+ this.send(JSON.stringify({ type: "InjectUserMessage", content }));
152
+ }
153
+
143
154
  /**
144
155
  * Respond to a function call request.
145
156
  * @param response - The response to the function call request.
@@ -515,7 +515,7 @@ export class ManageRestClient extends AbstractRestClient {
515
515
  ): Promise<VoidResponse> {
516
516
  try {
517
517
  const requestUrl = this.getRequestUrl(endpoint, { projectId, email });
518
- await this.delete(requestUrl).then((result) => result.json());
518
+ await this.delete(requestUrl);
519
519
 
520
520
  return { error: null };
521
521
  } catch (error) {