assemblyai 2.0.1-beta → 2.0.2-beta

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 CHANGED
@@ -1,7 +1,16 @@
1
- <img src="https://github.com/AssemblyAI/assemblyai-typescript-sdk/blob/master/assemblyai.png?raw=true" width="500"/>
1
+ <img src="https://github.com/AssemblyAI/assemblyai-node-sdk/blob/main/assemblyai.png?raw=true" width="500"/>
2
2
 
3
3
  ---
4
4
 
5
+ [![npm](https://img.shields.io/npm/v/assemblyai)](https://www.npmjs.com/package/assemblyai)
6
+ [![Test](https://github.com/AssemblyAI/assemblyai-node-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/AssemblyAI/assemblyai-node-sdk/actions/workflows/test.yml)
7
+ [![GitHub License](https://img.shields.io/github/license/AssemblyAI/assemblyai-node-sdk)](https://github.com/AssemblyAI/assemblyai-node-sdk/blob/master/LICENSE)
8
+ [![AssemblyAI Twitter](https://img.shields.io/twitter/follow/AssemblyAI?label=%40AssemblyAI&style=social)](https://twitter.com/AssemblyAI)
9
+ [![AssemblyAI YouTube](https://img.shields.io/youtube/channel/subscribers/UCtatfZMf-8EkIwASXM4ts0A)](https://www.youtube.com/@AssemblyAI)
10
+ [![Discord](https://img.shields.io/discord/875120158014853141?logo=discord&label=Discord&link=https%3A%2F%2Fdiscord.com%2Fchannels%2F875120158014853141&style=social)
11
+ ](https://discord.gg/5aQNZyq3)
12
+
13
+
5
14
  # AssemblyAI Node.js SDK
6
15
 
7
16
  The AssemblyAI Node.js SDK provides an easy-to-use interface for interacting with the AssemblyAI API,
@@ -173,7 +182,7 @@ const service = client.realtime.createService({
173
182
  You can also generate a temporary auth token for real-time.
174
183
 
175
184
  ```typescript
176
- const token = await client.realtime.createTemporaryToken({expires_in = 60});
185
+ const token = await client.realtime.createTemporaryToken({ expires_in = 60 });
177
186
  const rt = client.realtime.createService({
178
187
  token: token
179
188
  });
@@ -212,7 +221,7 @@ getAudio((chunk) => {
212
221
  Close the connection when you're finished.
213
222
 
214
223
  ```typescript
215
- rt.close();
224
+ await rt.close();
216
225
  ```
217
226
 
218
227
  # Tests
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import AssemblyAI from "./services";
1
+ import { AssemblyAI } from "./services";
2
2
  export * from "./services";
3
3
  export type * from "./types";
4
4
  export default AssemblyAI;
package/dist/index.esm.js CHANGED
@@ -164,11 +164,12 @@ class RealtimeService {
164
164
  url.search = searchParams.toString();
165
165
  return url;
166
166
  }
167
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
167
168
  on(event, listener) {
168
169
  this.listeners[event] = listener;
169
170
  }
170
171
  connect() {
171
- return new Promise((resolve, _) => {
172
+ return new Promise((resolve) => {
172
173
  if (this.socket) {
173
174
  throw new Error("Already connected");
174
175
  }
@@ -251,7 +252,7 @@ class RealtimeService {
251
252
  if (this.socket.readyState === WebSocket.OPEN) {
252
253
  const terminateSessionMessage = `{"terminate_session": true}`;
253
254
  if (waitForSessionTermination) {
254
- const sessionTerminatedPromise = new Promise((resolve, _) => {
255
+ const sessionTerminatedPromise = new Promise((resolve) => {
255
256
  this.sessionTerminatedResolve = resolve;
256
257
  });
257
258
  this.socket.send(terminateSessionMessage);
@@ -321,6 +322,7 @@ class TranscriptService extends BaseService {
321
322
  var _a;
322
323
  return __awaiter(this, void 0, void 0, function* () {
323
324
  const startTime = Date.now();
325
+ // eslint-disable-next-line no-constant-condition
324
326
  while (true) {
325
327
  const transcript = yield this.get(transcriptId);
326
328
  if (transcript.status === "completed" || transcript.status === "error") {
@@ -470,4 +472,18 @@ class AssemblyAI {
470
472
  }
471
473
  }
472
474
 
473
- export { FileService, LemurService, RealtimeService, RealtimeServiceFactory, TranscriptService, AssemblyAI as default };
475
+ var services = /*#__PURE__*/Object.freeze({
476
+ __proto__: null,
477
+ AssemblyAI: AssemblyAI,
478
+ FileService: FileService,
479
+ LemurService: LemurService,
480
+ RealtimeService: RealtimeService,
481
+ RealtimeServiceFactory: RealtimeServiceFactory,
482
+ TranscriptService: TranscriptService
483
+ });
484
+
485
+ class AssemblyAIExports extends AssemblyAI {
486
+ }
487
+ module.exports = Object.assign(AssemblyAIExports, services);
488
+
489
+ export { AssemblyAI, FileService, LemurService, RealtimeService, RealtimeServiceFactory, TranscriptService, AssemblyAI as default };
package/dist/index.js CHANGED
@@ -168,11 +168,12 @@ class RealtimeService {
168
168
  url.search = searchParams.toString();
169
169
  return url;
170
170
  }
171
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
172
  on(event, listener) {
172
173
  this.listeners[event] = listener;
173
174
  }
174
175
  connect() {
175
- return new Promise((resolve, _) => {
176
+ return new Promise((resolve) => {
176
177
  if (this.socket) {
177
178
  throw new Error("Already connected");
178
179
  }
@@ -255,7 +256,7 @@ class RealtimeService {
255
256
  if (this.socket.readyState === WebSocket.OPEN) {
256
257
  const terminateSessionMessage = `{"terminate_session": true}`;
257
258
  if (waitForSessionTermination) {
258
- const sessionTerminatedPromise = new Promise((resolve, _) => {
259
+ const sessionTerminatedPromise = new Promise((resolve) => {
259
260
  this.sessionTerminatedResolve = resolve;
260
261
  });
261
262
  this.socket.send(terminateSessionMessage);
@@ -325,6 +326,7 @@ class TranscriptService extends BaseService {
325
326
  var _a;
326
327
  return __awaiter(this, void 0, void 0, function* () {
327
328
  const startTime = Date.now();
329
+ // eslint-disable-next-line no-constant-condition
328
330
  while (true) {
329
331
  const transcript = yield this.get(transcriptId);
330
332
  if (transcript.status === "completed" || transcript.status === "error") {
@@ -474,6 +476,21 @@ class AssemblyAI {
474
476
  }
475
477
  }
476
478
 
479
+ var services = /*#__PURE__*/Object.freeze({
480
+ __proto__: null,
481
+ AssemblyAI: AssemblyAI,
482
+ FileService: FileService,
483
+ LemurService: LemurService,
484
+ RealtimeService: RealtimeService,
485
+ RealtimeServiceFactory: RealtimeServiceFactory,
486
+ TranscriptService: TranscriptService
487
+ });
488
+
489
+ class AssemblyAIExports extends AssemblyAI {
490
+ }
491
+ module.exports = Object.assign(AssemblyAIExports, services);
492
+
493
+ exports.AssemblyAI = AssemblyAI;
477
494
  exports.FileService = FileService;
478
495
  exports.LemurService = LemurService;
479
496
  exports.RealtimeService = RealtimeService;
@@ -2,7 +2,7 @@ import { AxiosInstance } from "axios";
2
2
  /**
3
3
  * Base class for services that communicate with the API.
4
4
  */
5
- declare abstract class BaseService {
5
+ export declare abstract class BaseService {
6
6
  protected client: AxiosInstance;
7
7
  /**
8
8
  * Create a new service.
@@ -10,4 +10,3 @@ declare abstract class BaseService {
10
10
  */
11
11
  constructor(client: AxiosInstance);
12
12
  }
13
- export default BaseService;
@@ -1,5 +1,5 @@
1
- import BaseService from "@/services/base";
2
- export default class FileService extends BaseService {
1
+ import { BaseService } from "@/services/base";
2
+ export declare class FileService extends BaseService {
3
3
  /**
4
4
  * Upload a local file to AssemblyAI.
5
5
  * @param path The local file to upload.
@@ -1,9 +1,9 @@
1
1
  import { BaseServiceParams } from "@/types";
2
- import LemurService from "./lemur";
2
+ import { LemurService } from "./lemur";
3
3
  import { RealtimeService, RealtimeServiceFactory } from "./realtime";
4
- import TranscriptService from "./transcripts";
5
- import FileService from "./files";
6
- export default class AssemblyAI {
4
+ import { TranscriptService } from "./transcripts";
5
+ import { FileService } from "./files";
6
+ declare class AssemblyAI {
7
7
  /**
8
8
  * The files service.
9
9
  */
@@ -26,4 +26,4 @@ export default class AssemblyAI {
26
26
  */
27
27
  constructor(params: BaseServiceParams);
28
28
  }
29
- export { LemurService, RealtimeServiceFactory, RealtimeService, TranscriptService, FileService, };
29
+ export { AssemblyAI, LemurService, RealtimeServiceFactory, RealtimeService, TranscriptService, FileService, };
@@ -1,6 +1,6 @@
1
1
  import { LemurSummaryParameters, LemurActionItemsParameters, LemurQuestionAnswerParameters, LemurTaskParameters, LemurSummaryResponse, LemurQuestionAnswerResponse, LemurActionItemsResponse, LemurTaskResponse } from "@/types";
2
- import BaseService from "@/services/base";
3
- export default class LemurService extends BaseService {
2
+ import { BaseService } from "@/services/base";
3
+ export declare class LemurService extends BaseService {
4
4
  summary(params: LemurSummaryParameters): Promise<LemurSummaryResponse>;
5
5
  questionAnswer(params: LemurQuestionAnswerParameters): Promise<LemurQuestionAnswerResponse>;
6
6
  actionItems(params: LemurActionItemsParameters): Promise<LemurActionItemsResponse>;
@@ -1,8 +1,8 @@
1
- import BaseService from "@/services/base";
1
+ import { BaseService } from "@/services/base";
2
2
  import { ParagraphsResponse, SentencesResponse, Transcript, TranscriptList, CreateTranscriptParameters, CreateTranscriptOptions, Createable, Deletable, Listable, Retrieveable, SubtitleFormat, RedactedAudioResponse } from "@/types";
3
3
  import { AxiosInstance } from "axios";
4
- import FileService from "../files";
5
- export default class TranscriptService extends BaseService implements Createable<Transcript, CreateTranscriptParameters, CreateTranscriptOptions>, Retrieveable<Transcript>, Deletable<Transcript>, Listable<TranscriptList> {
4
+ import { FileService } from "../files";
5
+ export declare class TranscriptService extends BaseService implements Createable<Transcript, CreateTranscriptParameters, CreateTranscriptOptions>, Retrieveable<Transcript>, Deletable<Transcript>, Listable<TranscriptList> {
6
6
  private files;
7
7
  constructor(client: AxiosInstance, files: FileService);
8
8
  /**
@@ -3,7 +3,7 @@
3
3
  * @template T The type of the resource.
4
4
  * @template Parameters The type of the parameters required to create the resource.
5
5
  */
6
- interface Createable<T, Parameters, Options = Record<string, any>> {
6
+ interface Createable<T, Parameters, Options = Record<string, unknown>> {
7
7
  /**
8
8
  * Create a new resource.
9
9
  * @param params The parameters of the new resource.
@@ -1 +1 @@
1
- export { default as RealtimeError, RealtimeErrorType, RealtimeErrorMessages, } from "./realtime";
1
+ export { RealtimeError, RealtimeErrorType, RealtimeErrorMessages, } from "./realtime";
@@ -19,5 +19,4 @@ declare enum RealtimeErrorType {
19
19
  declare const RealtimeErrorMessages: Record<RealtimeErrorType, string>;
20
20
  declare class RealtimeError extends Error {
21
21
  }
22
- export { RealtimeErrorType, RealtimeErrorMessages };
23
- export default RealtimeError;
22
+ export { RealtimeError, RealtimeErrorType, RealtimeErrorMessages };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assemblyai",
3
- "version": "2.0.1-beta",
3
+ "version": "2.0.2-beta",
4
4
  "description": "The AssemblyAI Node.js SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,7 +8,7 @@
8
8
  "typings": "dist/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/AssemblyAI/assemblyai-typescript-sdk.git"
11
+ "url": "git+https://github.com/AssemblyAI/assemblyai-node-sdk.git"
12
12
  },
13
13
  "publishConfig": {
14
14
  "tag": "beta",
@@ -18,15 +18,20 @@
18
18
  "scripts": {
19
19
  "build": "pnpm clean && pnpm rollup -c",
20
20
  "clean": "rimraf dist",
21
- "lint": "tslint -p tsconfig.json",
21
+ "lint": "eslint -c .eslintrc.json 'src/**/*'",
22
22
  "test": "pnpm lint && pnpm test:unit",
23
23
  "test:unit": "jest --config jest.config.rollup.ts",
24
- "prettier": "prettier --write 'src/**/*.ts'",
25
- "generate-types": "tsx ./scripts/generate-types.ts && pnpm prettier"
24
+ "format": "prettier --write 'src/**/*.ts'",
25
+ "generate-types": "tsx ./scripts/generate-types.ts && pnpm format",
26
+ "copybara:dry-run": "./copybara.sh dry_run --init-history",
27
+ "copybara:pr": "./copybara.sh sync_out --init-history"
26
28
  },
27
29
  "keywords": [
28
30
  "AssemblyAI",
29
- "Speech-to-text"
31
+ "Speech-to-text",
32
+ "Transcription",
33
+ "Audio",
34
+ "LLM"
30
35
  ],
31
36
  "author": "AssemblyAI (https://www.assemblyai.com)",
32
37
  "license": "MIT",
@@ -40,8 +45,9 @@
40
45
  "@types/jest": "^29.5.5",
41
46
  "@types/node": "^20.5.7",
42
47
  "@types/ws": "^8.5.5",
48
+ "@typescript-eslint/eslint-plugin": "^6.7.5",
43
49
  "dotenv": "^16.3.1",
44
- "eslint": "^8.43.0",
50
+ "eslint": "^8.48.0",
45
51
  "i": "^0.3.7",
46
52
  "jest": "^29.5.0",
47
53
  "jest-cli": "^29.5.0",
@@ -58,7 +64,6 @@
58
64
  "ts-jest": "^29.1.0",
59
65
  "ts-node": "^10.9.1",
60
66
  "tslib": "^2.5.3",
61
- "tslint": "^6.1.3",
62
67
  "typescript": "^5.2.2"
63
68
  },
64
69
  "dependencies": {
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
- import AssemblyAI from "./services";
2
-
1
+ import * as services from "./services";
2
+ import { AssemblyAI } from "./services";
3
3
  export * from "./services";
4
4
  export type * from "./types";
5
5
  export default AssemblyAI;
6
+ class AssemblyAIExports extends AssemblyAI {}
7
+ module.exports = Object.assign(AssemblyAIExports, services);
@@ -3,12 +3,10 @@ import { AxiosInstance } from "axios";
3
3
  /**
4
4
  * Base class for services that communicate with the API.
5
5
  */
6
- abstract class BaseService {
6
+ export abstract class BaseService {
7
7
  /**
8
8
  * Create a new service.
9
9
  * @param params The AxiosInstance to send HTTP requests to the API.
10
10
  */
11
11
  constructor(protected client: AxiosInstance) {}
12
12
  }
13
-
14
- export default BaseService;
@@ -1,8 +1,8 @@
1
1
  import { readFile } from "fs/promises";
2
- import BaseService from "@/services/base";
2
+ import { BaseService } from "@/services/base";
3
3
  import { UploadedFile } from "@/types";
4
4
 
5
- export default class FileService extends BaseService {
5
+ export class FileService extends BaseService {
6
6
  /**
7
7
  * Upload a local file to AssemblyAI.
8
8
  * @param path The local file to upload.
@@ -1,11 +1,11 @@
1
1
  import { createAxiosClient } from "@/utils/axios";
2
2
  import { BaseServiceParams } from "@/types";
3
- import LemurService from "./lemur";
3
+ import { LemurService } from "./lemur";
4
4
  import { RealtimeService, RealtimeServiceFactory } from "./realtime";
5
- import TranscriptService from "./transcripts";
6
- import FileService from "./files";
5
+ import { TranscriptService } from "./transcripts";
6
+ import { FileService } from "./files";
7
7
 
8
- export default class AssemblyAI {
8
+ class AssemblyAI {
9
9
  /**
10
10
  * The files service.
11
11
  */
@@ -41,6 +41,7 @@ export default class AssemblyAI {
41
41
  }
42
42
 
43
43
  export {
44
+ AssemblyAI,
44
45
  LemurService,
45
46
  RealtimeServiceFactory,
46
47
  RealtimeService,
@@ -8,9 +8,9 @@ import {
8
8
  LemurActionItemsResponse,
9
9
  LemurTaskResponse,
10
10
  } from "@/types";
11
- import BaseService from "@/services/base";
11
+ import { BaseService } from "@/services/base";
12
12
 
13
- export default class LemurService extends BaseService {
13
+ export class LemurService extends BaseService {
14
14
  async summary(params: LemurSummaryParameters): Promise<LemurSummaryResponse> {
15
15
  const { data } = await this.client.post<LemurSummaryResponse>(
16
16
  "/lemur/v3/generate/summary",
@@ -75,12 +75,13 @@ export class RealtimeService {
75
75
  ): void;
76
76
  on(event: "error", listener: (error: Error) => void): void;
77
77
  on(event: "close", listener: (code: number, reason: string) => void): void;
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
79
  on(event: RealtimeEvents, listener: (...args: any[]) => void) {
79
80
  this.listeners[event] = listener;
80
81
  }
81
82
 
82
83
  connect() {
83
- return new Promise<SessionBeginsEventData>((resolve, _) => {
84
+ return new Promise<SessionBeginsEventData>((resolve) => {
84
85
  if (this.socket) {
85
86
  throw new Error("Already connected");
86
87
  }
@@ -165,7 +166,7 @@ export class RealtimeService {
165
166
  if (this.socket.readyState === WebSocket.OPEN) {
166
167
  const terminateSessionMessage = `{"terminate_session": true}`;
167
168
  if (waitForSessionTermination) {
168
- const sessionTerminatedPromise = new Promise<void>((resolve, _) => {
169
+ const sessionTerminatedPromise = new Promise<void>((resolve) => {
169
170
  this.sessionTerminatedResolve = resolve;
170
171
  });
171
172
  this.socket.send(terminateSessionMessage);
@@ -1,4 +1,4 @@
1
- import BaseService from "@/services/base";
1
+ import { BaseService } from "@/services/base";
2
2
  import {
3
3
  ParagraphsResponse,
4
4
  SentencesResponse,
@@ -14,9 +14,9 @@ import {
14
14
  RedactedAudioResponse,
15
15
  } from "@/types";
16
16
  import { AxiosInstance } from "axios";
17
- import FileService from "../files";
17
+ import { FileService } from "../files";
18
18
 
19
- export default class TranscriptService
19
+ export class TranscriptService
20
20
  extends BaseService
21
21
  implements
22
22
  Createable<Transcript, CreateTranscriptParameters, CreateTranscriptOptions>,
@@ -58,6 +58,7 @@ export default class TranscriptService
58
58
  options?: CreateTranscriptOptions
59
59
  ): Promise<Transcript> {
60
60
  const startTime = Date.now();
61
+ // eslint-disable-next-line no-constant-condition
61
62
  while (true) {
62
63
  const transcript = await this.get(transcriptId);
63
64
  if (transcript.status === "completed" || transcript.status === "error") {
@@ -3,7 +3,7 @@
3
3
  * @template T The type of the resource.
4
4
  * @template Parameters The type of the parameters required to create the resource.
5
5
  */
6
- interface Createable<T, Parameters, Options = Record<string, any>> {
6
+ interface Createable<T, Parameters, Options = Record<string, unknown>> {
7
7
  /**
8
8
  * Create a new resource.
9
9
  * @param params The parameters of the new resource.
@@ -1,5 +1,5 @@
1
1
  export {
2
- default as RealtimeError,
2
+ RealtimeError,
3
3
  RealtimeErrorType,
4
4
  RealtimeErrorMessages,
5
5
  } from "./realtime";
@@ -41,5 +41,4 @@ const RealtimeErrorMessages: Record<RealtimeErrorType, string> = {
41
41
 
42
42
  class RealtimeError extends Error {}
43
43
 
44
- export { RealtimeErrorType, RealtimeErrorMessages };
45
- export default RealtimeError;
44
+ export { RealtimeError, RealtimeErrorType, RealtimeErrorMessages };