Skip to content

Commit 43f9692

Browse files
committed
sdk v2 with no async init
1 parent b1fd403 commit 43f9692

50 files changed

Lines changed: 72 additions & 128 deletions

Some content is hidden

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

docs/auth/authentication.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ epilot.authorize('my-static-api-token') // static string
5353
import { authorize } from '@epilot/sdk'
5454
import { getClient } from '@epilot/sdk/entity'
5555

56-
const entityClient = await getClient()
56+
const entityClient = getClient()
5757
authorize(entityClient, () => '<my-token>')
5858
```
5959

@@ -74,8 +74,8 @@ Pass the caller's headers to downstream APIs for permission checks:
7474
import { getClient } from '@epilot/sdk/entity'
7575
import { getLambdaRunner } from 'openapi-lambda-adapter'
7676

77-
const getEntityClient = async (passedHeaders: Headers) => {
78-
const client = await getClient()
77+
const getEntityClient = (passedHeaders: Headers) => {
78+
const client = getClient()
7979
client.api.registerRunner(getLambdaRunner(process.env.ENTITY_LAMBDA_NAME))
8080
client.defaults.headers.common = {
8181
authorization: passedHeaders['authorization'],

docs/auth/token-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Create tokens in the epilot portal under **Settings > Access Tokens**, or progra
5757
```typescript title="create-access-token.ts"
5858
import { authorize, getClient } from '@epilot/sdk/access-token';
5959

60-
const accessTokenClient = await getClient();
60+
const accessTokenClient = getClient();
6161
authorize(accessTokenClient, cognitoIdToken);
6262

6363
const { data } = await accessTokenClient.createAccessToken(null, {

docs/sdk/client-usage.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ const { data } = await entityClient.get('/v2/entity/schemas/contact/123')
3939
Use `getClient()` when you need direct access to the underlying axios instance, for example to set custom headers or add interceptors.
4040

4141
```ts
42-
const entityClient = await epilot.entity.getClient()
42+
const entityClient = epilot.entity.getClient()
4343
const { data } = await entityClient.getEntity({ slug: 'contact', id: '123' })
4444
```
4545

46-
`getClient()` returns a cached singleton. Calling it multiple times returns the same instance (until config changes).
46+
`getClient()` is synchronous and returns a cached singleton. Calling it multiple times returns the same instance (until config changes).
4747

4848
:::warning Stale references
4949
If you hold a client reference and then change config, your reference still points to the old client:
5050

5151
```ts
52-
const entityClient = await epilot.entity.getClient()
52+
const entityClient = epilot.entity.getClient()
5353

5454
epilot.authorize(() => 'new-token') // invalidates cached clients
5555

@@ -67,7 +67,7 @@ Use `createClient()` when you need a completely independent client that is not s
6767
```ts
6868
import { createClient, authorize } from '@epilot/sdk/entity'
6969

70-
const entityClient = await createClient()
70+
const entityClient = createClient()
7171
authorize(entityClient, () => '<my-token>')
7272
entityClient.defaults.headers.common['x-epilot-org-id'] = 'org-123'
7373
```
@@ -79,7 +79,7 @@ Import only the APIs you use. Other APIs never touch your bundle.
7979
```ts
8080
import { getClient, authorize } from '@epilot/sdk/entity'
8181

82-
const entityClient = await getClient()
82+
const entityClient = getClient()
8383
authorize(entityClient, () => '<my-token>')
8484

8585
const { data } = await entityClient.getEntity({ slug: 'contact', id: '123' })
@@ -141,5 +141,19 @@ When you call `authorize()`, `headers()`, `retry()`, `largeResponse()`, or `inte
141141
| Pattern | Always up to date? | Notes |
142142
| --- | --- | --- |
143143
| `epilot.entity.getEntity(...)` | Yes | Re-resolves the client on every call |
144-
| `await epilot.entity.getClient()` | At time of call | Can go stale after config changes |
145-
| `await createClient()` | Independent | Not affected by SDK config changes |
144+
| `epilot.entity.getClient()` | At time of call | Can go stale after config changes |
145+
| `createClient()` | Independent | Not affected by SDK config changes |
146+
147+
## Migration from `@epilot/*-client`
148+
149+
Drop-in replacement — just change the import path:
150+
151+
```ts
152+
// Before
153+
import { getClient, createClient, authorize } from '@epilot/entity-client'
154+
import type { Client, Entity } from '@epilot/entity-client'
155+
156+
// After
157+
import { getClient, createClient, authorize } from '@epilot/sdk/entity'
158+
import type { Client, Entity } from '@epilot/sdk/entity'
159+
```

docs/sdk/clients/access-token.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.accessToken.createAccessToken(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/access-token'
2323

24-
const accessTokenClient = await getClient()
24+
const accessTokenClient = getClient()
2525
authorize(accessTokenClient, () => '<token>')
2626
const { data } = await accessTokenClient.createAccessToken(...)
2727
```

docs/sdk/clients/address-suggestions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.addressSuggestions.getAddresses(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/address-suggestions'
2323

24-
const addressSuggestionsClient = await getClient()
24+
const addressSuggestionsClient = getClient()
2525
authorize(addressSuggestionsClient, () => '<token>')
2626
const { data } = await addressSuggestionsClient.getAddresses(...)
2727
```

docs/sdk/clients/address.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.address.getAddressSuggestions(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/address'
2323

24-
const addressClient = await getClient()
24+
const addressClient = getClient()
2525
authorize(addressClient, () => '<token>')
2626
const { data } = await addressClient.getAddressSuggestions(...)
2727
```

docs/sdk/clients/ai-agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.aiAgents.createAgent(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/ai-agents'
2323

24-
const aiAgentsClient = await getClient()
24+
const aiAgentsClient = getClient()
2525
authorize(aiAgentsClient, () => '<token>')
2626
const { data } = await aiAgentsClient.createAgent(...)
2727
```

docs/sdk/clients/app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.app.getPublicFacingComponent(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/app'
2323

24-
const appClient = await getClient()
24+
const appClient = getClient()
2525
authorize(appClient, () => '<token>')
2626
const { data } = await appClient.getPublicFacingComponent(...)
2727
```

docs/sdk/clients/audit-logs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.auditLogs.getLogs(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/audit-logs'
2323

24-
const auditLogsClient = await getClient()
24+
const auditLogsClient = getClient()
2525
authorize(auditLogsClient, () => '<token>')
2626
const { data } = await auditLogsClient.getLogs(...)
2727
```

docs/sdk/clients/automation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { data } = await epilot.automation.searchFlows(...)
2121
```ts
2222
import { getClient, authorize } from '@epilot/sdk/automation'
2323

24-
const automationClient = await getClient()
24+
const automationClient = getClient()
2525
authorize(automationClient, () => '<token>')
2626
const { data } = await automationClient.searchFlows(...)
2727
```

0 commit comments

Comments
 (0)