@picked/admin-api-client 0.0.85-next.4 → 0.0.85-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +79 -2
- package/dist/esm/index.js +27 -12
- package/dist/types/client.d.ts +35 -2
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/graphql-env.d.ts +18 -7
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/workspace-transfer.d.ts +170 -0
- package/dist/types/workspace-transfer.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,14 @@ Typed [gql.tada](https://gql.tada.dev) client for the Picked admin (management)
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { createAdminApiClient, graphql } from '@picked/admin-api-client'
|
|
9
9
|
|
|
10
|
-
const MeQuery = graphql(`
|
|
10
|
+
const MeQuery = graphql(`
|
|
11
|
+
query Me {
|
|
12
|
+
user {
|
|
13
|
+
id
|
|
14
|
+
email
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`)
|
|
11
18
|
|
|
12
19
|
const client = createAdminApiClient({ apiUrl: 'https://api.picked.app', token: accessToken })
|
|
13
20
|
const data = await client.request(MeQuery, {}) // fully typed from the schema
|
|
@@ -16,6 +23,18 @@ const data = await client.request(MeQuery, {}) // fully typed from the schema
|
|
|
16
23
|
Documents are authored with `graphql`; results and variables are inferred from the API schema. The
|
|
17
24
|
client trusts the API response (no runtime shape validation), matching the dashboard's transport.
|
|
18
25
|
|
|
26
|
+
Pass `apiKey` to authenticate with an API key; the client sends it as the `X-API-Key` header.
|
|
27
|
+
|
|
28
|
+
A request is aborted after 30 seconds; `client.request(document, variables, { timeoutMs })`
|
|
29
|
+
sets a different limit for one request. When the API answers with GraphQL errors, `request`
|
|
30
|
+
throws an `AdminApiResponseError` whose `codes` holds each error's `extensions.code`; a
|
|
31
|
+
network failure, timeout, or HTTP error without a GraphQL error list throws a plain `Error`.
|
|
32
|
+
|
|
33
|
+
The package also exports the documents that move a workspace between projects:
|
|
34
|
+
`WorkspaceExportDocument`, `ProjectLiveVersionDocument`, `WorkspaceImportDocument`,
|
|
35
|
+
`AssetUploadInitDocument`, `AssetCommitDocument`, `AssetDeleteDocument` and
|
|
36
|
+
`WorkspacePublishDocument`.
|
|
37
|
+
|
|
19
38
|
## Development
|
|
20
39
|
|
|
21
40
|
Regenerate the schema types after the API schema changes:
|