Skip to content

Commit 20ec335

Browse files
committed
SDK regeneration
1 parent c484b93 commit 20ec335

File tree

56 files changed

+1384
-926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1384
-926
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ const response = await client.articles.create(..., {
105105
### Retries
106106

107107
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
108-
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
108+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
109109
retry limit (default: 2).
110110

111-
A request is deemed retriable when any of the following HTTP status codes is returned:
111+
A request is deemed retryable when any of the following HTTP status codes is returned:
112112

113-
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
114-
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
115-
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
113+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
114+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
115+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
116116

117117
Use the `maxRetries` request option to configure this behavior.
118118

@@ -149,12 +149,12 @@ controller.abort(); // aborts the request
149149
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
150150
runtimes:
151151

152-
- Node.js 18+
153-
- Vercel
154-
- Cloudflare Workers
155-
- Deno v1.25+
156-
- Bun 1.0+
157-
- React Native
152+
- Node.js 18+
153+
- Vercel
154+
- Cloudflare Workers
155+
- Deno v1.25+
156+
- Bun 1.0+
157+
- React Native
158158

159159
### Customizing Fetch Client
160160

@@ -170,6 +170,16 @@ const client = new IntercomClient({
170170
});
171171
```
172172

173+
## Contributing
174+
175+
While we value open-source contributions to this SDK, this library is generated programmatically.
176+
Additions made directly to this library would have to be moved over to our generation code,
177+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
178+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
179+
an issue first to discuss with us!
180+
181+
On the other hand, contributions to the README are always very welcome!
182+
173183
## Request Options
174184

175185
This client library also supports passing in [`request` options](https://github.com/axios/axios#request-config):
@@ -191,13 +201,3 @@ client.useRequestOpts({
191201
baseURL: "https://api.eu.intercom.io",
192202
});
193203
```
194-
195-
## Contributing
196-
197-
While we value open-source contributions to this SDK, this library is generated programmatically.
198-
Additions made directly to this library would have to be moved over to our generation code,
199-
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
200-
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
201-
an issue first to discuss with us!
202-
203-
On the other hand, contributions to the README are always very welcome!
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/** @type {import('jest').Config} */
2-
module.exports = {
2+
export default {
33
preset: "ts-jest",
44
testEnvironment: "node",
5+
moduleNameMapper: {
6+
"(.+)\.js$": "$1",
7+
},
58
};

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "intercom-client",
3-
"version": "v6.1.1",
3+
"version": "6.2.0",
44
"private": false,
55
"repository": "https://github.com/intercom/intercom-node",
66
"main": "./index.js",
@@ -15,25 +15,25 @@
1515
"url-join": "4.0.1",
1616
"form-data": "^4.0.0",
1717
"formdata-node": "^6.0.3",
18-
"node-fetch": "2.7.0",
19-
"qs": "6.11.2",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
2020
"readable-stream": "^4.5.2",
21-
"js-base64": "3.7.2"
21+
"js-base64": "3.7.7"
2222
},
2323
"devDependencies": {
2424
"@types/url-join": "4.0.1",
25-
"@types/qs": "6.9.8",
26-
"@types/node-fetch": "2.6.9",
27-
"@types/readable-stream": "^4.0.15",
28-
"webpack": "^5.94.0",
29-
"ts-loader": "^9.3.1",
30-
"jest": "29.7.0",
31-
"@types/jest": "29.5.5",
32-
"ts-jest": "29.1.1",
33-
"jest-environment-jsdom": "29.7.0",
34-
"@types/node": "17.0.33",
35-
"prettier": "2.7.1",
36-
"typescript": "4.6.4"
25+
"@types/qs": "^6.9.17",
26+
"@types/node-fetch": "^2.6.12",
27+
"@types/readable-stream": "^4.0.18",
28+
"webpack": "^5.97.1",
29+
"ts-loader": "^9.5.1",
30+
"jest": "^29.7.0",
31+
"@types/jest": "^29.5.14",
32+
"ts-jest": "^29.1.1",
33+
"jest-environment-jsdom": "^29.7.0",
34+
"@types/node": "^18.19.70",
35+
"prettier": "^3.4.2",
36+
"typescript": "~5.7.2"
3737
},
3838
"browser": {
3939
"fs": false,

reference.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,9 @@ while (page.hasNextPage()) {
14571457

14581458
The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset.
14591459

1460-
- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
1461-
- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
1462-
- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
1460+
- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app.
1461+
- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail
1462+
- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire
14631463

14641464
{% admonition type="info" name="Scroll Parameter" %}
14651465
You can get the first page of companies by simply sending a GET request to the scroll endpoint.
@@ -2376,8 +2376,8 @@ If a contact has recently been created, there is a possibility that it will not
23762376
You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
23772377
There are some limitations to the amount of multiple's there can be:
23782378

2379-
- There's a limit of max 2 nested filters
2380-
- There's a limit of max 15 filters for each AND or OR group
2379+
- There's a limit of max 2 nested filters
2380+
- There's a limit of max 15 filters for each AND or OR group
23812381

23822382
### Searching for Timestamp Fields
23832383

@@ -4023,8 +4023,8 @@ See the [pagination section](https://developers.intercom.com/docs/build-an-integ
40234023
You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
40244024
There are some limitations to the amount of multiple's there can be:
40254025

4026-
- There's a limit of max 2 nested filters
4027-
- There's a limit of max 15 filters for each AND or OR group
4026+
- There's a limit of max 2 nested filters
4027+
- There's a limit of max 15 filters for each AND or OR group
40284028

40294029
### Accepted Fields
40304030

@@ -4278,14 +4278,14 @@ await client.conversations.reply({
42784278

42794279
For managing conversations you can:
42804280

4281-
- Close a conversation
4282-
- Snooze a conversation to reopen on a future date
4283-
- Open a conversation which is `snoozed` or `closed`
4284-
- Assign a conversation to an admin and/or team.
4285-
</dd>
4286-
</dl>
4287-
</dd>
4288-
</dl>
4281+
- Close a conversation
4282+
- Snooze a conversation to reopen on a future date
4283+
- Open a conversation which is `snoozed` or `closed`
4284+
- Assign a conversation to an admin and/or team.
4285+
</dd>
4286+
</dl>
4287+
</dd>
4288+
</dl>
42894289

42904290
#### 🔌 Usage
42914291

@@ -4921,9 +4921,9 @@ await client.dataAttributes.update({
49214921
49224922
The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`.
49234923

4924-
- `https://api.intercom.io/events?type=user&user_id={user_id}`
4925-
- `https://api.intercom.io/events?type=user&email={email}`
4926-
- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads)
4924+
- `https://api.intercom.io/events?type=user&user_id={user_id}`
4925+
- `https://api.intercom.io/events?type=user&email={email}`
4926+
- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads)
49274927

49284928
The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending.
49294929

@@ -5015,9 +5015,9 @@ When submitting events for Leads, you will need to specify the Lead's `id`.
50155015

50165016
**Metadata behaviour**
50175017

5018-
- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
5019-
- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
5020-
- There might be up to 24 hrs delay when you send a new metadata for an existing event.
5018+
- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event.
5019+
- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one.
5020+
- There might be up to 24 hrs delay when you send a new metadata for an existing event.
50215021

50225022
**Event de-duplication**
50235023

@@ -5027,15 +5027,15 @@ Duplicated events are responded to using the normal `202 Accepted` code - an err
50275027

50285028
### HTTP API Responses
50295029

5030-
- Successful responses to submitted events return `202 Accepted` with an empty body.
5031-
- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code.
5032-
- Events sent about users that cannot be found will return a `404 Not Found`.
5033-
- Event lists containing duplicate events will have those duplicates ignored.
5034-
- Server errors will return a `500` response code and may contain an error message in the body.
5035-
</dd>
5036-
</dl>
5037-
</dd>
5038-
</dl>
5030+
- Successful responses to submitted events return `202 Accepted` with an empty body.
5031+
- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code.
5032+
- Events sent about users that cannot be found will return a `404 Not Found`.
5033+
- Event lists containing duplicate events will have those duplicates ignored.
5034+
- Server errors will return a `500` response code and may contain an error message in the body.
5035+
</dd>
5036+
</dl>
5037+
</dd>
5038+
</dl>
50395039

50405040
#### 🔌 Usage
50415041

@@ -6488,8 +6488,8 @@ See the [pagination section](https://developers.intercom.com/docs/build-an-integ
64886488
You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4).
64896489
There are some limitations to the amount of multiples there can be:
64906490

6491-
- There's a limit of max 2 nested filters
6492-
- There's a limit of max 15 filters for each AND or OR group
6491+
- There's a limit of max 2 nested filters
6492+
- There's a limit of max 15 filters for each AND or OR group
64936493

64946494
### Accepted Fields
64956495

scripts/rename-to-esm-files.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require("fs").promises;
4+
const path = require("path");
5+
6+
const extensionMap = {
7+
".js": ".mjs",
8+
".d.ts": ".d.mts",
9+
};
10+
const oldExtensions = Object.keys(extensionMap);
11+
12+
async function findFiles(rootPath) {
13+
const files = [];
14+
15+
async function scan(directory) {
16+
const entries = await fs.readdir(directory, { withFileTypes: true });
17+
18+
for (const entry of entries) {
19+
const fullPath = path.join(directory, entry.name);
20+
21+
if (entry.isDirectory()) {
22+
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
23+
await scan(fullPath);
24+
}
25+
} else if (entry.isFile()) {
26+
if (oldExtensions.some((ext) => entry.name.endsWith(ext))) {
27+
files.push(fullPath);
28+
}
29+
}
30+
}
31+
}
32+
33+
await scan(rootPath);
34+
return files;
35+
}
36+
37+
async function updateFiles(files) {
38+
const updatedFiles = [];
39+
for (const file of files) {
40+
const updated = await updateFileContents(file);
41+
updatedFiles.push(updated);
42+
}
43+
44+
console.log(`Updated imports in ${updatedFiles.length} files.`);
45+
}
46+
47+
async function updateFileContents(file) {
48+
const content = await fs.readFile(file, "utf8");
49+
50+
let newContent = content;
51+
// Update each extension type defined in the map
52+
for (const [oldExt, newExt] of Object.entries(extensionMap)) {
53+
const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
54+
newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
55+
}
56+
57+
if (content !== newContent) {
58+
await fs.writeFile(file, newContent, "utf8");
59+
return true;
60+
}
61+
return false;
62+
}
63+
64+
async function renameFiles(files) {
65+
let counter = 0;
66+
for (const file of files) {
67+
const ext = oldExtensions.find((ext) => file.endsWith(ext));
68+
const newExt = extensionMap[ext];
69+
70+
if (newExt) {
71+
const newPath = file.slice(0, -ext.length) + newExt;
72+
await fs.rename(file, newPath);
73+
counter++;
74+
}
75+
}
76+
77+
console.log(`Renamed ${counter} files.`);
78+
}
79+
80+
async function main() {
81+
try {
82+
const targetDir = process.argv[2];
83+
if (!targetDir) {
84+
console.error("Please provide a target directory");
85+
process.exit(1);
86+
}
87+
88+
const targetPath = path.resolve(targetDir);
89+
const targetStats = await fs.stat(targetPath);
90+
91+
if (!targetStats.isDirectory()) {
92+
console.error("The provided path is not a directory");
93+
process.exit(1);
94+
}
95+
96+
console.log(`Scanning directory: ${targetDir}`);
97+
98+
const files = await findFiles(targetDir);
99+
100+
if (files.length === 0) {
101+
console.log("No matching files found.");
102+
process.exit(0);
103+
}
104+
105+
console.log(`Found ${files.length} files.`);
106+
await updateFiles(files);
107+
await renameFiles(files);
108+
console.log("\nDone!");
109+
} catch (error) {
110+
console.error("An error occurred:", error.message);
111+
process.exit(1);
112+
}
113+
}
114+
115+
main();

src/Client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import { Visitors } from "./api/resources/visitors/client/Client";
2626
import { News } from "./api/resources/news/client/Client";
2727

2828
export declare namespace IntercomClient {
29-
interface Options {
29+
export interface Options {
3030
environment?: core.Supplier<environments.IntercomEnvironment | string>;
31+
/** Specify a custom URL to connect the client to. */
32+
baseUrl?: core.Supplier<string>;
3133
token?: core.Supplier<core.BearerToken | undefined>;
3234
/** Override the Intercom-Version header */
3335
version?:
@@ -52,7 +54,7 @@ export declare namespace IntercomClient {
5254
fetcher?: core.FetchFunction;
5355
}
5456

55-
interface RequestOptions {
57+
export interface RequestOptions {
5658
/** The maximum time to wait for a response in seconds. */
5759
timeoutInSeconds?: number;
5860
/** The number of times to retry the request. Defaults to 2. */

0 commit comments

Comments
 (0)