Skip to content

Commit 26353ae

Browse files
committed
feat: upgrade Twilio SDK to v5 and require as peer dependency
WHAT: - Upgraded the core `twilio` Node.js helper library to v5.5.2 across relevant packages (`runtime-handler`, `create-twilio-function` defaults, test dependencies). - Changed `@twilio-labs/serverless-runtime-types` and `@twilio-labs/twilio-run` to declare `twilio` as a `peerDependency` (^5.5.2) instead of a direct dependency. - Updated internal type definitions (`ClientOpts`) for compatibility with `twilio@5.x`. - Updated Twilio Console URL generation logic in `twilio-run`. - Updated default dependencies (`typescript`, `serverlessRuntimeTypes`) used by `create-twilio-function`. WHY: - Aligns the toolkit with the latest Twilio SDK features, improvements, and security updates available in v5. - Resolves potential version conflicts and type mismatches (e.g., TS2322/TS2352) by ensuring a single `twilio` instance is used, managed explicitly by the consuming project. This promotes a more stable and predictable dependency graph. BREAKING CHANGE: Consumers of `@twilio-labs/twilio-run` or projects directly importing types from `@twilio-labs/serverless-runtime-types` MUST now explicitly install `twilio` as a direct dependency in their own project. Add the `twilio` dependency: ```bash npm install twilio@^5.5.2 --save-dev yarn add twilio@^5.5.2 --dev ```
1 parent 14e4d32 commit 26353ae

File tree

15 files changed

+89
-33
lines changed

15 files changed

+89
-33
lines changed

.changeset/heavy-moose-appear.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'@twilio-labs/serverless-runtime-types': major
3+
'twilio-run': major
4+
'create-twilio-function': minor
5+
'@twilio/runtime-handler': minor
6+
---
7+
8+
feat: Upgrade Twilio SDK to v5 and use peer dependency
9+
10+
**WHAT:**
11+
- Upgraded the core `twilio` Node.js helper library to v5.5.2 across the toolkit.
12+
- Changed `@twilio-labs/serverless-runtime-types` and `@twilio-labs/twilio-run` to require `twilio` as a `peerDependency` instead of a direct dependency.
13+
- Updated type definitions (`ClientOpts`) for compatibility with `twilio@5.x`.
14+
- Updated default dependencies (`twilio`, `typescript`, `serverlessRuntimeTypes`) used by `@twilio-labs/create-twilio-function`.
15+
16+
**WHY:**
17+
- Aligns the toolkit with the latest Twilio SDK features, improvements, and security updates.
18+
- Resolves potential type conflicts (e.g., `TS2322`/`TS2352`) by ensuring a single `twilio` instance, managed by the user's project.
19+
20+
**HOW:**
21+
**BREAKING CHANGE:** Users of `@twilio-labs/twilio-run` or projects importing types from `@twilio-labs/serverless-runtime-types` **must** now add `twilio` as a direct dependency to their project:
22+
```bash
23+
npm install twilio@^5.5.2
24+
# or
25+
yarn add twilio@^5.5.2
26+
```
27+
After updating toolkit packages and adding `twilio`, perform a clean install (delete `node_modules` and lock file, then run `npm install` or `yarn install`).

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@changesets/cli": "^2.26.0",
2727
"@commitlint/cli": "^19.1.0",
2828
"@commitlint/config-conventional": "^19.1.0",
29-
"@twilio/test-dep": "npm:twilio@4.22.0",
29+
"@twilio/test-dep": "npm:twilio@5.2.2",
3030
"@types/jest": "^29.2.4",
3131
"all-contributors-cli": "^6.1.2",
3232
"commitizen": "^4.2.4",
@@ -45,6 +45,9 @@
4545
"typedoc": "^0.27.4",
4646
"typescript": "^5.3.3"
4747
},
48+
"peerDependencies": {
49+
"twilio": "^5.5.2"
50+
},
4851
"lint-staged": {
4952
"*.{js,jsx,ts,tsx}": [
5053
"prettier --write",

packages/create-twilio-function/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"license": "MIT",
2626
"devDependencies": {
27-
"@twilio/runtime-handler": "^2.0.3",
27+
"@twilio/runtime-handler": "^2.1.0",
2828
"nock": "^11.3.4"
2929
},
3030
"dependencies": {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const pkgJson = require('../../package.json');
22

33
module.exports = {
4-
twilio: '5.0.3',
4+
twilio: '5.5.2',
55
twilioRuntimeHandler: pkgJson.devDependencies[
66
'@twilio/runtime-handler'
77
].replace(/[\^~]/, ''),
88
twilioRun: pkgJson.dependencies['twilio-run'],
99
node: '18',
10-
typescript: '^5.3.3',
11-
serverlessRuntimeTypes: '^4.0.0',
10+
typescript: '^5.8.0',
11+
serverlessRuntimeTypes: '^4.0.1',
1212
copyfiles: '^2.4.1',
1313
};

packages/runtime-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"nocache": "^2.1.0",
7171
"normalize.css": "^8.0.1",
7272
"serialize-error": "^7.0.1",
73-
"twilio": "4.23.0"
73+
"twilio": "5.5.2"
7474
},
7575
"gitHead": "6db273648ed19474f4125042556b10c051529912"
7676
}

packages/serverless-runtime-types/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
npm install @twilio-labs/serverless-runtime-types
2323
```
2424

25+
**Peer Dependency Requirement:**
26+
27+
This package requires the core `twilio` Node.js library as a **peer dependency** (version `^5.5.2` or compatible). This is necessary to ensure type consistency and prevent version conflicts within your project.
28+
29+
**You MUST explicitly install both `@twilio-labs/serverless-runtime-types` and a compatible version of `twilio` in your project.**
30+
31+
```bash
32+
# Using npm
33+
npm install @twilio-labs/serverless-runtime-types twilio@^5.5.2 --save-dev
34+
```
35+
2536
## Example
2637

2738
### In JavaScript

packages/serverless-runtime-types/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
},
3030
"dependencies": {
3131
"@types/express": "^4.17.21",
32-
"@types/qs": "^6.9.4",
33-
"twilio": "^4.23.0"
32+
"@types/qs": "^6.9.4"
3433
},
34+
"peerDependencies": {
35+
"twilio": "^5.5.2"
36+
},
3537
"devDependencies": {
3638
"all-contributors-cli": "^6.7.0",
37-
"typescript": "^5.3.3"
39+
"typescript": "^5.8.0"
3840
},
3941
"publishConfig": {
4042
"access": "public"

packages/serverless-runtime-types/types.d.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as twilio from 'twilio';
22
import { ServiceContext } from 'twilio/lib/rest/sync/v1/service';
33
import { SyncListListInstance } from 'twilio/lib/rest/sync/v1/service/syncList';
44
import { SyncMapListInstance } from 'twilio/lib/rest/sync/v1/service/syncMap';
5-
import { TwilioClientOptions } from 'twilio/lib/rest/Twilio';
5+
import { ClientOpts } from 'twilio';
66

77
export type EnvironmentVariables = {
88
[key: string]: string | undefined;
@@ -187,7 +187,7 @@ export interface TwilioResponse {
187187
removeCookie(key: string): TwilioResponse;
188188
}
189189

190-
export type RuntimeSyncClientOptions = TwilioClientOptions & {
190+
export type RuntimeSyncClientOptions = ClientOpts & {
191191
serviceName?: string;
192192
};
193193

@@ -360,7 +360,7 @@ export type Context<T = {}> = {
360360
* };
361361
* ```
362362
*/
363-
getTwilioClient(options?: TwilioClientOptions): twilio.Twilio;
363+
getTwilioClient(options?: ClientOpts): twilio.Twilio;
364364
/**
365365
* The domain name for the Service that contains this Function.
366366
*/
@@ -412,6 +412,7 @@ export type GlobalTwilio = Omit<typeof twilio, 'default'> & {
412412
export { ServiceContext } from 'twilio/lib/rest/sync/v1/service';
413413
export { SyncListListInstance } from 'twilio/lib/rest/sync/v1/service/syncList';
414414
export { SyncMapListInstance } from 'twilio/lib/rest/sync/v1/service/syncMap';
415-
export { TwilioClientOptions } from 'twilio/lib/rest/Twilio';
415+
export { ClientOpts as TwilioClientOptions } from 'twilio/lib/rest/Twilio';
416+
416417
export type TwilioClient = twilio.Twilio;
417418
export type TwilioPackage = typeof twilio;

packages/twilio-run/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@
7676
"serialize-error": "^7.0.1",
7777
"terminal-link": "^1.3.0",
7878
"title": "^3.4.1",
79-
"twilio": "^4.23.0",
8079
"type-fest": "^0.15.1",
8180
"window-size": "^1.1.1",
8281
"wrap-ansi": "^7.0.0",
8382
"yargs": "^17.2.1"
8483
},
84+
"peerDependencies": {
85+
"twilio": "^5.5.2"
86+
},
8587
"optionalDependencies": {
8688
"ngrok": "^3.3.0"
8789
},
@@ -113,7 +115,7 @@
113115
"nock": "^12.0.2",
114116
"supertest": "^3.1.0",
115117
"typescript": "^4.9.4",
116-
"@twilio/test-dep": "npm:twilio@4.22.0"
118+
"@twilio/test-dep": "npm:twilio@5.5.2"
117119
},
118120
"files": [
119121
"bin/",

packages/twilio-run/src/commands/promote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export async function handler(
9494
config.targetEnvironment || 'production'
9595
}`
9696
);
97-
printActivateResult(result, config.outputFormat);
97+
printActivateResult(result, config.outputFormat, config.region);
9898
} catch (err) {
9999
handleError(err, spinner);
100100
}

0 commit comments

Comments
 (0)