Skip to content

Commit 12c2c09

Browse files
committed
feat(api): update via SDK Studio
1 parent 153050a commit 12c2c09

File tree

22 files changed

+367
-1022
lines changed

22 files changed

+367
-1022
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: CI
22
on:
33
push:
44
branches:
5-
- main
5+
- v3
66
pull_request:
77
branches:
8-
- main
8+
- v3
99

1010
jobs:
1111
lint:

.github/workflows/create-releases.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ on:
44
- cron: '0 5 * * *' # every day at 5am UTC
55
push:
66
branches:
7-
- main
7+
- v3
88

99
jobs:
1010
release:
1111
name: release
12-
if: github.ref == 'refs/heads/main' && github.repository == 'intercom/intercom-node'
12+
if: github.ref == 'refs/heads/v3' && github.repository == 'intercom/intercom-node'
1313
runs-on: ubuntu-latest
1414

1515
steps:

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 106
1+
configured_endpoints: 107
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a202b2b4aa0e356eb61376a3bf484132be2e9e3bff3796e1fe4606ab2a3734fd.yml

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
1111
## Installation
1212

1313
```sh
14-
npm install intercom-client
14+
npm install git+ssh://[email protected]:intercom/intercom-node.git
1515
```
1616

17+
> [!NOTE]
18+
> Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install intercom-client`
19+
1720
## Usage
1821

1922
The full API of this library can be found in [api.md](api.md).
@@ -217,7 +220,7 @@ import Intercom from 'intercom-client';
217220
```
218221

219222
To do the inverse, add `import "intercom-client/shims/node"` (which does import polyfills).
220-
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/intercom/intercom-node/tree/main/src/_shims#readme)).
223+
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/intercom/intercom-node/tree/v3/src/_shims#readme)).
221224

222225
### Logging and middleware
223226

api.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ Types:
77
- <code><a href="./src/resources/shared.ts">ArticleTranslatedContent</a></code>
88
- <code><a href="./src/resources/shared.ts">Company</a></code>
99
- <code><a href="./src/resources/shared.ts">Contact</a></code>
10+
- <code><a href="./src/resources/shared.ts">ContactReference</a></code>
1011
- <code><a href="./src/resources/shared.ts">Conversation</a></code>
12+
- <code><a href="./src/resources/shared.ts">CursorPages</a></code>
1113
- <code><a href="./src/resources/shared.ts">GroupContent</a></code>
1214
- <code><a href="./src/resources/shared.ts">GroupTranslatedContent</a></code>
1315
- <code><a href="./src/resources/shared.ts">Message</a></code>
1416
- <code><a href="./src/resources/shared.ts">MultipleFilterSearchRequest</a></code>
1517
- <code><a href="./src/resources/shared.ts">Note</a></code>
1618
- <code><a href="./src/resources/shared.ts">PaginatedResponse</a></code>
19+
- <code><a href="./src/resources/shared.ts">PartAttachment</a></code>
20+
- <code><a href="./src/resources/shared.ts">Reference</a></code>
1721
- <code><a href="./src/resources/shared.ts">SearchRequest</a></code>
22+
- <code><a href="./src/resources/shared.ts">SingleFilterSearchRequest</a></code>
23+
- <code><a href="./src/resources/shared.ts">StartingAfterPaging</a></code>
1824
- <code><a href="./src/resources/shared.ts">SubscriptionTypeList</a></code>
1925
- <code><a href="./src/resources/shared.ts">Tag</a></code>
2026
- <code><a href="./src/resources/shared.ts">TagList</a></code>
@@ -168,6 +174,7 @@ Types:
168174

169175
Methods:
170176

177+
- <code title="post /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">create</a>(contactId, { ...params }) -> Company</code>
171178
- <code title="delete /contacts/{contact_id}/companies/{id}">client.contacts.companies.<a href="./src/resources/contacts/companies.ts">delete</a>(contactId, id, { ...params }) -> Company</code>
172179

173180
## Notes
@@ -216,13 +223,14 @@ Methods:
216223
Types:
217224

218225
- <code><a href="./src/resources/conversations/conversations.ts">ConversationList</a></code>
226+
- <code><a href="./src/resources/conversations/conversations.ts">ConversationListResponse</a></code>
219227

220228
Methods:
221229

222230
- <code title="post /conversations">client.conversations.<a href="./src/resources/conversations/conversations.ts">create</a>({ ...params }) -> Message</code>
223231
- <code title="get /conversations/{id}">client.conversations.<a href="./src/resources/conversations/conversations.ts">retrieve</a>(id, { ...params }) -> Conversation</code>
224232
- <code title="put /conversations/{id}">client.conversations.<a href="./src/resources/conversations/conversations.ts">update</a>(id, { ...params }) -> Conversation</code>
225-
- <code title="get /conversations">client.conversations.<a href="./src/resources/conversations/conversations.ts">list</a>({ ...params }) -> PaginatedResponse</code>
233+
- <code title="get /conversations">client.conversations.<a href="./src/resources/conversations/conversations.ts">list</a>({ ...params }) -> ConversationListResponsesCursorPagination</code>
226234
- <code title="post /conversations/{id}/convert">client.conversations.<a href="./src/resources/conversations/conversations.ts">convert</a>(id, { ...params }) -> Ticket | null</code>
227235
- <code title="post /conversations/redact">client.conversations.<a href="./src/resources/conversations/conversations.ts">redact</a>({ ...params }) -> Conversation</code>
228236
- <code title="post /conversations/search">client.conversations.<a href="./src/resources/conversations/conversations.ts">search</a>({ ...params }) -> ConversationList</code>

src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as Errors from './error';
55
import { type Agent } from './_shims/index';
66
import * as Uploads from './uploads';
77
import * as qs from 'qs';
8+
import * as Pagination from './pagination';
89
import * as API from './resources/index';
910

1011
const environments = {
@@ -227,6 +228,10 @@ export import fileFromPath = Uploads.fileFromPath;
227228
export namespace Intercom {
228229
export import RequestOptions = Core.RequestOptions;
229230

231+
export import CursorPagination = Pagination.CursorPagination;
232+
export import CursorPaginationParams = Pagination.CursorPaginationParams;
233+
export import CursorPaginationResponse = Pagination.CursorPaginationResponse;
234+
230235
export import Me = API.Me;
231236
export import AdminWithApp = API.AdminWithApp;
232237
export import MeRetrieveParams = API.MeRetrieveParams;
@@ -280,6 +285,8 @@ export namespace Intercom {
280285

281286
export import Conversations = API.Conversations;
282287
export import ConversationList = API.ConversationList;
288+
export import ConversationListResponse = API.ConversationListResponse;
289+
export import ConversationListResponsesCursorPagination = API.ConversationListResponsesCursorPagination;
283290
export import ConversationCreateParams = API.ConversationCreateParams;
284291
export import ConversationRetrieveParams = API.ConversationRetrieveParams;
285292
export import ConversationUpdateParams = API.ConversationUpdateParams;
@@ -372,14 +379,20 @@ export namespace Intercom {
372379
export import ArticleTranslatedContent = API.ArticleTranslatedContent;
373380
export import Company = API.Company;
374381
export import Contact = API.Contact;
382+
export import ContactReference = API.ContactReference;
375383
export import Conversation = API.Conversation;
384+
export import CursorPages = API.CursorPages;
376385
export import GroupContent = API.GroupContent;
377386
export import GroupTranslatedContent = API.GroupTranslatedContent;
378387
export import Message = API.Message;
379388
export import MultipleFilterSearchRequest = API.MultipleFilterSearchRequest;
380389
export import Note = API.Note;
381390
export import PaginatedResponse = API.PaginatedResponse;
391+
export import PartAttachment = API.PartAttachment;
392+
export import Reference = API.Reference;
382393
export import SearchRequest = API.SearchRequest;
394+
export import SingleFilterSearchRequest = API.SingleFilterSearchRequest;
395+
export import StartingAfterPaging = API.StartingAfterPaging;
383396
export import SubscriptionTypeList = API.SubscriptionTypeList;
384397
export import Tag = API.Tag;
385398
export import TagList = API.TagList;

src/pagination.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';
4+
5+
export interface CursorPaginationResponse<Item> {
6+
pages: CursorPaginationResponse.Pages;
7+
8+
total_count: number;
9+
10+
data: Array<Item>;
11+
}
12+
13+
export namespace CursorPaginationResponse {
14+
export interface Pages {
15+
next?: Pages.Next;
16+
17+
page?: number;
18+
19+
total_pages?: number;
20+
21+
type?: string;
22+
}
23+
24+
export namespace Pages {
25+
export interface Next {
26+
page?: number;
27+
28+
starting_after?: string;
29+
}
30+
}
31+
}
32+
33+
export interface CursorPaginationParams {
34+
/**
35+
* The pagination cursor value.
36+
*/
37+
starting_after?: string;
38+
39+
/**
40+
* Number of results to return per page.
41+
*/
42+
per_page?: number;
43+
}
44+
45+
export class CursorPagination<Item> extends AbstractPage<Item> implements CursorPaginationResponse<Item> {
46+
pages: CursorPaginationResponse.Pages;
47+
48+
total_count: number;
49+
50+
data: Array<Item>;
51+
52+
constructor(
53+
client: APIClient,
54+
response: Response,
55+
body: CursorPaginationResponse<Item>,
56+
options: FinalRequestOptions,
57+
) {
58+
super(client, response, body, options);
59+
60+
this.pages = body.pages || {};
61+
this.total_count = body.total_count || 0;
62+
this.data = body.data || [];
63+
}
64+
65+
getPaginatedItems(): Item[] {
66+
return this.data ?? [];
67+
}
68+
69+
// @deprecated Please use `nextPageInfo()` instead
70+
nextPageParams(): Partial<CursorPaginationParams> | null {
71+
const info = this.nextPageInfo();
72+
if (!info) return null;
73+
if ('params' in info) return info.params;
74+
const params = Object.fromEntries(info.url.searchParams);
75+
if (!Object.keys(params).length) return null;
76+
return params;
77+
}
78+
79+
nextPageInfo(): PageInfo | null {
80+
const cursor = this.pages?.next?.starting_after;
81+
if (!cursor) {
82+
return null;
83+
}
84+
85+
return {
86+
params: {
87+
starting_after: cursor,
88+
},
89+
};
90+
}
91+
}

src/resources/admins/activity-logs.ts

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import * as Core from '../../core';
44
import { APIResource } from '../../resource';
55
import * as ActivityLogsAPI from './activity-logs';
6+
import * as Shared from '../shared';
67

78
export class ActivityLogs extends APIResource {
89
/**
@@ -38,7 +39,7 @@ export interface ActivityLogList {
3839
* the current position in the result set, allowing the API to return the data in
3940
* small chunks or "pages" as needed.
4041
*/
41-
pages?: ActivityLogList.Pages | null;
42+
pages?: Shared.CursorPages | null;
4243

4344
/**
4445
* String representing the object's type. Always has the value `activity_log.list`.
@@ -222,50 +223,6 @@ export namespace ActivityLogList {
222223
type?: string;
223224
}
224225
}
225-
226-
/**
227-
* Cursor-based pagination is a technique used in the Intercom API to navigate
228-
* through large amounts of data. A "cursor" or pointer is used to keep track of
229-
* the current position in the result set, allowing the API to return the data in
230-
* small chunks or "pages" as needed.
231-
*/
232-
export interface Pages {
233-
next?: Pages.Next | null;
234-
235-
/**
236-
* The current page
237-
*/
238-
page?: number;
239-
240-
/**
241-
* Number of results per page
242-
*/
243-
per_page?: number;
244-
245-
/**
246-
* Total number of pages
247-
*/
248-
total_pages?: number;
249-
250-
/**
251-
* the type of object `pages`.
252-
*/
253-
type?: 'pages';
254-
}
255-
256-
export namespace Pages {
257-
export interface Next {
258-
/**
259-
* The number of results to fetch per page.
260-
*/
261-
per_page?: number;
262-
263-
/**
264-
* The cursor to use in the next request to get the next page of results.
265-
*/
266-
starting_after?: string | null;
267-
}
268-
}
269226
}
270227

271228
export interface ActivityLogListParams {

0 commit comments

Comments
 (0)