@@ -10,16 +10,20 @@ The IcePanel TypeScript library provides convenient access to the IcePanel APIs
1010- [ Installation] ( #installation )
1111- [ Reference] ( #reference )
1212- [ Getting Started] ( #getting-started )
13+ - [ Environments] ( #environments )
1314- [ Request and Response Types] ( #request-and-response-types )
1415- [ Exception Handling] ( #exception-handling )
16+ - [ Pagination] ( #pagination )
1517- [ Advanced] ( #advanced )
18+ - [ Subpackage Exports] ( #subpackage-exports )
1619 - [ Additional Headers] ( #additional-headers )
1720 - [ Additional Query String Parameters] ( #additional-query-string-parameters )
1821 - [ Retries] ( #retries )
1922 - [ Timeouts] ( #timeouts )
2023 - [ Aborting Requests] ( #aborting-requests )
2124 - [ Access Raw Response Data] ( #access-raw-response-data )
2225 - [ Logging] ( #logging )
26+ - [ Custom Fetch] ( #custom-fetch )
2327 - [ Runtime Compatibility] ( #runtime-compatibility )
2428- [ Contributing] ( #contributing )
2529
@@ -52,6 +56,18 @@ await client.model.objects.list({
5256```
5357
5458
59+ ## Environments
60+
61+ This SDK allows you to configure different environments for API requests.
62+
63+ ``` typescript
64+ import { IcePanelClient , IcePanelEnvironment } from " @icepanel/sdk" ;
65+
66+ const client = new IcePanelClient ({
67+ environment: IcePanelEnvironment .ApiV1 ,
68+ });
69+ ```
70+
5571## Request and Response Types
5672
5773The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
@@ -85,8 +101,45 @@ try {
85101}
86102```
87103
104+ ## Pagination
105+
106+ List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items:
107+
108+ ``` typescript
109+ import { IcePanelClient } from " @icepanel/sdk" ;
110+
111+ const client = new IcePanelClient ({ apiKey: " YOUR_API_KEY" , token: " YOUR_TOKEN" });
112+ const pageableResponse = await client .versions .list ({
113+ landscapeId: " landscapeId"
114+ });
115+ for await (const item of pageableResponse ) {
116+ console .log (item );
117+ }
118+
119+ // Or you can manually iterate page-by-page
120+ let page = await client .versions .list ({
121+ landscapeId: " landscapeId"
122+ });
123+ while (page .hasNextPage ()) {
124+ page = page .getNextPage ();
125+ }
126+
127+ // You can also access the underlying response
128+ const response = page .response ;
129+ ```
130+
88131## Advanced
89132
133+ ### Subpackage Exports
134+
135+ This SDK supports direct imports of subpackage clients, which allows JavaScript bundlers to tree-shake and include only the imported subpackage code. This results in much smaller bundle sizes.
136+
137+ ``` typescript
138+ import { CommentsClient } from ' @icepanel/sdk/comments' ;
139+
140+ const client = new CommentsClient ({... });
141+ ```
142+
90143### Additional Headers
91144
92145If you would like to send additional headers as part of the request, use the ` headers ` request option.
@@ -237,6 +290,26 @@ const logger: logging.ILogger = {
237290</details >
238291
239292
293+ ### Custom Fetch
294+
295+ The SDK provides a low-level ` fetch ` method for making custom HTTP requests while still
296+ benefiting from SDK-level configuration like authentication, retries, timeouts, and logging.
297+ This is useful for calling API endpoints not yet supported in the SDK.
298+
299+ ``` typescript
300+ const response = await client .fetch (" /v1/custom/endpoint" , {
301+ method: " GET" ,
302+ }, {
303+ timeoutInSeconds: 30 ,
304+ maxRetries: 3 ,
305+ headers: {
306+ " X-Custom-Header" : " custom-value" ,
307+ },
308+ });
309+
310+ const data = await response .json ();
311+ ```
312+
240313### Runtime Compatibility
241314
242315
@@ -251,19 +324,6 @@ The SDK works in the following runtimes:
251324- Bun 1.0+
252325- React Native
253326
254- ### Customizing Fetch Client
255-
256- The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
257- unsupported environment, this provides a way for you to break glass and ensure the SDK works.
258-
259- ``` typescript
260- import { IcePanelClient } from " @icepanel/sdk" ;
261-
262- const client = new IcePanelClient ({
263- ...
264- fetcher : // provide your implementation here
265- });
266- ```
267327
268328## Contributing
269329
@@ -273,4 +333,4 @@ otherwise they would be overwritten upon the next generated release. Feel free t
273333a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
274334an issue first to discuss with us!
275335
276- On the other hand, contributions to the README are always very welcome!
336+ On the other hand, contributions to the README are always very welcome!
0 commit comments