Skip to content

Commit

Permalink
update nested resources typing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Oct 2, 2024
1 parent 3f6138c commit 8588eba
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## v2

### v2.0.0-alpha.3

- Update typing on Nested Resources

### v2.0.0-alpha.2

- Fix `AI` resource methods and created nested structure
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Build Status](https://github.com/team-telnyx/telnyx-node/workflows/CI/badge.svg)](https://github.com/team-telnyx/telnyx-node/actions)
[![Downloads](https://img.shields.io/npm/dm/telnyx.svg)](https://www.npmjs.com/package/telnyx)
[![Try on RunKit](https://badge.runkitcdn.com/telnyx.svg)](https://runkit.com/npm/telnyx)
[![Code Style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier")
[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://joinslack.telnyx.com/)

The Telnyx Node library provides convenient access to the Telnyx API from
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0-alpha.2
2.0.0-alpha.3
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telnyx",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Telnyx API Node SDK",
"keywords": [
"telnyx",
Expand Down
2 changes: 0 additions & 2 deletions src/resources/Addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export const Addresses = TelnyxResource.extend({
list: telnyxMethod({
method: 'GET',
methodType: 'list',

transformResponseData: transformResponseData,
}),

create: telnyxMethod({
Expand Down
14 changes: 12 additions & 2 deletions types/AddressesResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,25 @@ declare module 'telnyx' {
options?: RequestOptions,
): Promise<
Telnyx.Response<
Telnyx.AddressesRetrieveResponse & AddressesNestedMethods
Telnyx.AddressesRetrieveResponse &
NestedResponseData<
AddressesRetrieveResponse['data'],
AddressesNestedMethods
>
>
>;

create(
params: AddressesCreateParams,
options?: RequestOptions,
): Promise<
Telnyx.Response<Telnyx.AddressesCreateResponse & AddressesNestedMethods>
Telnyx.Response<
Telnyx.AddressesCreateResponse &
NestedResponseData<
AddressesCreateResponse['data'],
AddressesNestedMethods
>
>
>;

validate(
Expand Down
10 changes: 8 additions & 2 deletions types/CallsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,20 @@ declare module 'telnyx' {
params: CallsCreateParams,
options?: RequestOptions,
): Promise<
Telnyx.Response<Telnyx.CallsCreateResponse & CallsNestedMethods>
Telnyx.Response<
Telnyx.CallsCreateResponse &
NestedResponseData<CallsCreateResponse['data'], CallsNestedMethods>
>
>;

dial(
params: CallsCreateParams,
options?: RequestOptions,
): Promise<
Telnyx.Response<Telnyx.CallsCreateResponse & CallsNestedMethods>
Telnyx.Response<
Telnyx.CallsCreateResponse &
NestedResponseData<CallsCreateResponse['data'], CallsNestedMethods>
>
>;

answer(
Expand Down
10 changes: 8 additions & 2 deletions types/MessagingProfilesResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ declare module 'telnyx' {
): Promise<
Telnyx.Response<
Telnyx.MessagingProfilesCreateResponse &
MessagingProfilesNestedMethods
NestedResponseData<
MessagingProfilesCreateResponse['data'],
MessagingProfilesNestedMethods
>
>
>;

Expand All @@ -97,7 +100,10 @@ declare module 'telnyx' {
): Promise<
Telnyx.Response<
Telnyx.MessagingProfilesRetrieveResponse &
MessagingProfilesNestedMethods
NestedResponseData<
MessagingProfilesRetrieveResponse['data'],
MessagingProfilesNestedMethods
>
>
>;

Expand Down
2 changes: 2 additions & 0 deletions types/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ declare module 'telnyx' {
headers?: Record<string, string | number | string[]>;
}

export type NestedResponseData<T, N> = {data?: T & N};

export type Response<T> = T & {
lastResponse: {
headers: Record<string, string | number | string[]>;
Expand Down

0 comments on commit 8588eba

Please sign in to comment.