Skip to content

Commit

Permalink
Merge pull request #53 from AssemblyAI/E07417BDFEA3614F5967B1520F8B2F61
Browse files Browse the repository at this point in the history
Sync from internal repo (2024/05/30)
  • Loading branch information
Swimburger committed May 30, 2024
2 parents 78d1382 + f3aa029 commit 8ff43dc
Show file tree
Hide file tree
Showing 18 changed files with 7,232 additions and 34 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [4.4.4]

- Add an export that only includes the Streaming STT code. You can use the export
- by importing `assemblyai/streaming`,
- or by loading the `assemblyai.streaming.umd.js` file, or `assemblyai.streaming.umd.min.js` file in a script-tag.
- Add new `EntityType` enum values

## [4.4.3] - 2024-05-09

- Add react-native exports that resolve to the browser version of the library.
Expand Down
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,19 @@ TEST_TRANSCRIPT_IDS=...
## Generate types from OpenAPI and AsyncAPI spec

1. Configure the location of the OpenAPI and AsyncAPI spec as environment variables:
- `OPENAPI_SPEC`: Path or URL to the AssemblyAI OpenAPI spec
- `ASYNCAPI_SPEC`: Path or URL to the AssemblyAI AsyncAPI spec

2. Generate the types using `pnpm generate:types`.
- `OPENAPI_SPEC`: Path or URL to the AssemblyAI OpenAPI spec
- `ASYNCAPI_SPEC`: Path or URL to the AssemblyAI AsyncAPI spec

2. Generate the types using `pnpm generate:types`.

## Notes about the JavaScript SDK

### Rollup

We use Rollup to build the JavaScript SDK.
Our Rollup configuration generates the following versions:

- node.{cjs,mjs}: The Node runtime version using CommonJS and ESModule syntax.
- bun.mjs: The Bun runtime version.
- deno.mjs: The Deno runtime version.
Expand All @@ -83,7 +84,7 @@ Our Rollup configuration generates the following versions:
When a user uses the SDK, the users' runtime will automatically choose the runtime-specific version
if defined in the package.json `exports` object, or fall back to the default version.

For example, Bun will use *bun.mjs* and Cloudflare Workers (workerd) will use *index.mjs*.
For example, Bun will use _bun.mjs_ and Cloudflare Workers (workerd) will use _index.mjs_.

### Package.json imports

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ You can use automatic CDNs like [UNPKG](https://unpkg.com/) to load the library

- Replace `:version` with the desired version or `latest`.
- Remove `.min` to load the non-minified version.
- Remove `.streaming` to load the entire SDK. Keep `.streaming` to load the Streaming STT specific version.

```html
<!-- Unminified full SDK -->
<script src="https://www.unpkg.com/assemblyai@:version/dist/assemblyai.umd.js"></script>
<!-- Minified full SDK -->
<script src="https://www.unpkg.com/assemblyai@:version/dist/assemblyai.umd.min.js"></script>
<!-- Unminified Streaming STT only -->
<script src="https://www.unpkg.com/assemblyai@:version/dist/assemblyai.streaming.umd.js"></script>
<!-- Minified Streaming STT only -->
<script src="https://www.unpkg.com/assemblyai@:version/dist/assemblyai.streaming.umd.min.js"></script>
```

The script creates a global `assemblyai` variable containing all the services.
Expand Down Expand Up @@ -264,7 +272,7 @@ const rt = client.realtime.transcriber({
> _Client code_:
>
> ```typescript
> import { RealtimeTranscriber } from "assemblyai";
> import { RealtimeTranscriber } from "assemblyai"; // or "assemblyai/streaming"
> // TODO: implement getToken to retrieve token from server
> const token = await getToken();
> const rt = new RealtimeTranscriber({
Expand Down
27 changes: 20 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,34 @@
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"types": "./dist/exports/index.d.ts",
"bun": {
"types": "./dist/index.d.ts",
"types": "./dist/exports/index.d.ts",
"default": "./dist/bun.mjs"
},
"deno": {
"types": "./dist/index.d.ts",
"types": "./dist/exports/index.d.ts",
"default": "./dist/deno.mjs"
},
"workerd": "./dist/index.mjs",
"browser": "./dist/browser.mjs",
"react-native": "./dist/browser.mjs",
"node": {
"types": "./dist/index.d.ts",
"types": "./dist/exports/index.d.ts",
"import": "./dist/node.mjs",
"require": "./dist/node.cjs"
},
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.cjs"
},
"./streaming": {
"types": "./dist/exports/streaming.d.ts",
"browser": "./dist/streaming.browser.mjs",
"import": "./dist/streaming.mjs",
"require": "./dist/streaming.cjs",
"default": "./dist/streaming.cjs"
},
"./package.json": "./package.json"
},
"imports": {
Expand Down Expand Up @@ -67,11 +74,15 @@
"scripts": {
"build": "pnpm clean && pnpm rollup -c",
"clean": "rimraf dist/* && rimraf temp/* && rimraf temp-docs/*",
"lint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}' && publint && tsc --noEmit -p tsconfig.json",
"test": "pnpm run test:unit && pnpm run test:integration",
"lint": "pnpm lint:eslint && pnpm lint:tsc && pnpm lint:format && pnpm lint:publint",
"lint:eslint": "eslint -c .eslintrc.json '{src,tests}/**/*.{js,ts}'",
"lint:tsc": "tsc --noEmit -p tsconfig.json",
"lint:format": "prettier --check --no-error-on-unmatched-pattern {*,**/*}",
"lint:publint": "publint",
"test": "pnpm test:unit && pnpm test:integration",
"test:unit": "jest --config jest.unit.config.js --testTimeout 1000",
"test:integration": "jest --config jest.integration.config.js --testTimeout 360000",
"format": "prettier {*,**/*} --write --no-error-on-unmatched-pattern",
"format": "prettier --write --no-error-on-unmatched-pattern {*,**/*}",
"generate:types": "tsx ./scripts/generate-types.ts && prettier 'src/types/*.generated.ts' --write",
"generate:reference": "typedoc",
"copybara:dry-run": "./copybara.sh dry_run --init-history",
Expand Down Expand Up @@ -103,6 +114,7 @@
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jest": "^29.5.12",
Expand All @@ -118,6 +130,7 @@
"jest-fetch-mock": "^3.0.3",
"jest-junit": "^16.0.0",
"jest-websocket-mock": "^2.5.0",
"jsr": "^0.12.4",
"mock-socket": "^9.3.1",
"openapi-typescript": "^6.7.5",
"prettier": "^3.2.5",
Expand Down
Loading

0 comments on commit 8ff43dc

Please sign in to comment.