@paragraphcms/client 1.5.0 → 2.0.0
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/LICENSE +21 -0
- package/README.md +39 -429
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +208 -83
- package/dist/types.d.ts +96 -95
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Paragraph CMS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,473 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @paragraphcms/client
|
|
2
2
|
|
|
3
|
-
Official TypeScript client for the Paragraph CMS
|
|
3
|
+
Official TypeScript client for the Paragraph CMS API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!--
|
|
6
|
+
Replace this block with the README image.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
<p align="center">
|
|
9
|
+
<img src="./assets/paragraph-client.png" alt="@paragraphcms/client" />
|
|
10
|
+
</p>
|
|
11
|
+
-->
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
- `new Client({ apiKey })` entrypoint with a small, typed SDK.
|
|
11
|
-
- Built-in request queue that rate-limits each client instance to `5 req/s` by default.
|
|
12
|
-
- Runtime-agnostic implementation with no runtime dependencies.
|
|
13
|
-
- First-class TypeScript types for request payloads, responses, list metadata, and API errors.
|
|
14
|
-
- Request cancellation with `AbortSignal`.
|
|
13
|
+
`@paragraphcms/client` is a small, typed SDK built on top of the standard Fetch API. It runs in Node.js 18+ and other server-side runtimes that expose `fetch`.
|
|
15
14
|
|
|
16
|
-
##
|
|
15
|
+
## Install
|
|
17
16
|
|
|
18
17
|
```bash
|
|
19
18
|
npm install @paragraphcms/client
|
|
19
|
+
# or
|
|
20
|
+
pnpm add @paragraphcms/client
|
|
21
|
+
# or
|
|
22
|
+
yarn add @paragraphcms/client
|
|
20
23
|
```
|
|
21
24
|
|
|
22
25
|
## Quick Start
|
|
23
26
|
|
|
27
|
+
Create a client instance with your API key:
|
|
28
|
+
|
|
24
29
|
```ts
|
|
25
30
|
import { Client } from "@paragraphcms/client";
|
|
26
31
|
|
|
27
32
|
const client = new Client({
|
|
28
33
|
apiKey: process.env.PARAGRAPH_API_KEY!,
|
|
29
34
|
});
|
|
30
|
-
|
|
31
|
-
const pages = await client.pages.list();
|
|
32
|
-
const page = await client.pages.getBySlug("pricing");
|
|
33
|
-
|
|
34
|
-
console.log(pages.meta.total_items);
|
|
35
|
-
console.log(page.id);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Runtime Notes
|
|
39
|
-
|
|
40
|
-
- The default API base URL is `https://api.paragraphcms.com/v1`.
|
|
41
|
-
- If you pass `baseUrl: "https://api.paragraphcms.com"`, the client automatically normalizes it to `https://api.paragraphcms.com/v1`.
|
|
42
|
-
- The client uses `x-api-key` authentication by default.
|
|
43
|
-
- Field names in request and response payloads intentionally mirror the HTTP API. That means body/query keys stay in `snake_case`.
|
|
44
|
-
|
|
45
|
-
## Rate Limiting
|
|
46
|
-
|
|
47
|
-
Paragraph CMS v1 is rate-limited to `5 req/s`. Each `Client` instance contains an internal queue that spaces request starts so the instance does not exceed that budget by default.
|
|
48
|
-
|
|
49
|
-
Important details:
|
|
50
|
-
|
|
51
|
-
- The limiter is per client instance, not global across all containers, lambdas, or workers.
|
|
52
|
-
- If your app creates many `Client` instances, each instance will maintain its own queue.
|
|
53
|
-
- The safest pattern is to reuse one shared `Client` instance per process or isolate when possible.
|
|
54
|
-
|
|
55
|
-
You can override the per-instance limit if you need a lower ceiling:
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
const client = new Client({
|
|
59
|
-
apiKey: process.env.PARAGRAPH_API_KEY!,
|
|
60
|
-
maxRequestsPerSecond: 3,
|
|
61
|
-
});
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Configuration
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
type ClientOptions = {
|
|
68
|
-
apiKey: string;
|
|
69
|
-
baseUrl?: string;
|
|
70
|
-
fetch?: typeof globalThis.fetch;
|
|
71
|
-
headers?: HeadersInit;
|
|
72
|
-
timeoutMs?: number;
|
|
73
|
-
maxRequestsPerSecond?: number;
|
|
74
|
-
};
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### `apiKey`
|
|
78
|
-
|
|
79
|
-
Required. Paragraph CMS organization API key.
|
|
80
|
-
|
|
81
|
-
### `baseUrl`
|
|
82
|
-
|
|
83
|
-
Optional. Defaults to `https://api.paragraphcms.com/v1`.
|
|
84
|
-
|
|
85
|
-
Examples:
|
|
86
|
-
|
|
87
|
-
- `https://api.paragraphcms.com/v1`
|
|
88
|
-
- `https://api.paragraphcms.com`
|
|
89
|
-
- `http://localhost:3001/v1`
|
|
90
|
-
|
|
91
|
-
### `fetch`
|
|
92
|
-
|
|
93
|
-
Optional custom fetch implementation. Useful in tests or custom runtimes.
|
|
94
|
-
|
|
95
|
-
### `headers`
|
|
96
|
-
|
|
97
|
-
Optional default headers added to every request.
|
|
98
|
-
|
|
99
|
-
### `timeoutMs`
|
|
100
|
-
|
|
101
|
-
Optional default request timeout in milliseconds. Per-call options can override it.
|
|
102
|
-
|
|
103
|
-
### `maxRequestsPerSecond`
|
|
104
|
-
|
|
105
|
-
Optional per-client limiter ceiling. Defaults to `5`.
|
|
106
|
-
|
|
107
|
-
## Per-Request Options
|
|
108
|
-
|
|
109
|
-
Every SDK method accepts an optional last argument:
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
type RequestOptions = {
|
|
113
|
-
signal?: AbortSignal;
|
|
114
|
-
headers?: HeadersInit;
|
|
115
|
-
timeoutMs?: number;
|
|
116
|
-
};
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Example:
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
const controller = new AbortController();
|
|
123
|
-
|
|
124
|
-
const page = await client.pages.get("page-id", undefined, {
|
|
125
|
-
signal: controller.signal,
|
|
126
|
-
timeoutMs: 10_000,
|
|
127
|
-
});
|
|
128
35
|
```
|
|
129
36
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
The client throws `ParagraphApiError` for non-2xx API responses and `ParagraphClientError` for local runtime/configuration problems.
|
|
37
|
+
### Get All Pages or Pages From a Collection
|
|
133
38
|
|
|
134
39
|
```ts
|
|
135
|
-
|
|
40
|
+
const { data: allPages, meta } = await client.pages.list();
|
|
136
41
|
|
|
137
|
-
const
|
|
138
|
-
|
|
42
|
+
const { data: collectionPages } = await client.pages.list({
|
|
43
|
+
collectionId: "collection-id",
|
|
139
44
|
});
|
|
140
45
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error instanceof ParagraphApiError) {
|
|
145
|
-
console.error(error.status);
|
|
146
|
-
console.error(error.code);
|
|
147
|
-
console.error(error.message);
|
|
148
|
-
console.error(error.details);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Return Shapes
|
|
154
|
-
|
|
155
|
-
- Single-resource endpoints return the unwrapped `data` payload.
|
|
156
|
-
- Paginated endpoints return `{ data, meta }`.
|
|
157
|
-
- `locales.list()` returns a plain `Locale[]` because the API endpoint itself is not paginated.
|
|
158
|
-
|
|
159
|
-
## API Surface
|
|
160
|
-
|
|
161
|
-
### Root
|
|
162
|
-
|
|
163
|
-
```ts
|
|
164
|
-
client.getInfo()
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Returns the public `/v1` info payload:
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
{
|
|
171
|
-
version: "v1",
|
|
172
|
-
openapi_url: "/v1/openapi.json",
|
|
173
|
-
authentication: {
|
|
174
|
-
type: "api_key",
|
|
175
|
-
supported_headers: ["x-api-key", "authorization"],
|
|
176
|
-
authorization_format: "Bearer <api-key>",
|
|
177
|
-
},
|
|
178
|
-
resources: [...]
|
|
179
|
-
}
|
|
46
|
+
console.log(meta.totalItems);
|
|
47
|
+
console.log(collectionPages.map((page) => page.title));
|
|
180
48
|
```
|
|
181
49
|
|
|
182
|
-
###
|
|
50
|
+
### Get a Page by Slug
|
|
183
51
|
|
|
184
52
|
```ts
|
|
185
|
-
client.pages.
|
|
186
|
-
client.pages.create(body?, options?)
|
|
187
|
-
client.pages.get(pageId, query?, options?)
|
|
188
|
-
client.pages.getBySlug(slug, options?)
|
|
189
|
-
client.pages.update(pageId, body, options?)
|
|
190
|
-
client.pages.delete(pageId, options?)
|
|
191
|
-
client.pages.restore(pageId, options?)
|
|
192
|
-
client.pages.permanentlyDelete(pageId, options?)
|
|
193
|
-
client.pages.duplicate(pageId, options?)
|
|
194
|
-
client.pages.createTranslation(pageId, body, options?)
|
|
195
|
-
client.page.getBySlug(slug, options?)
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
Supported `sort` fields for `pages.list()`:
|
|
199
|
-
|
|
200
|
-
- `title`
|
|
201
|
-
- `language`
|
|
202
|
-
- `created_at`
|
|
203
|
-
- `updated_at`
|
|
204
|
-
- `published_at`
|
|
205
|
-
|
|
206
|
-
Notes:
|
|
207
|
-
|
|
208
|
-
- If you omit both `limit` and `page`, `pages.list()` returns the full matching result set.
|
|
209
|
-
- `label_id` is passed as `string[]` in the SDK and serialized to the API CSV format automatically.
|
|
210
|
-
- `pages.list()` sends `include_content: false` by default. Set `include_content: true` to include `content` in list results.
|
|
211
|
-
- Page responses should be treated as Tiptap JSON arrays. `content_format` is no longer required in the response shape.
|
|
212
|
-
- `pages.getBySlug()` is an SDK convenience lookup built on top of `pages.list({ slug })`, and then fetches the full page details by ID.
|
|
213
|
-
- `page.getBySlug()` is a short alias for the same lookup.
|
|
214
|
-
|
|
215
|
-
### Collections
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
client.collections.list(query?, options?)
|
|
219
|
-
client.collections.create(body, options?)
|
|
220
|
-
client.collections.get(collectionId, options?)
|
|
221
|
-
client.collections.update(collectionId, body, options?)
|
|
222
|
-
client.collections.delete(collectionId, options?)
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
Supported `sort` fields for `collections.list()`:
|
|
226
|
-
|
|
227
|
-
- `name`
|
|
228
|
-
- `page_count`
|
|
229
|
-
- `last_modified_at`
|
|
230
|
-
|
|
231
|
-
### Media
|
|
232
|
-
|
|
233
|
-
```ts
|
|
234
|
-
client.media.list(query?, options?)
|
|
235
|
-
client.media.upload(body, options?)
|
|
236
|
-
client.media.get(mediaId, options?)
|
|
237
|
-
client.media.update(mediaId, body, options?)
|
|
238
|
-
client.media.delete(mediaId, options?)
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
Supported `sort` fields for `media.list()`:
|
|
242
|
-
|
|
243
|
-
- `file_name`
|
|
244
|
-
- `size`
|
|
245
|
-
- `created_at`
|
|
246
|
-
- `updated_at`
|
|
247
|
-
|
|
248
|
-
`media.upload()` accepts:
|
|
249
|
-
|
|
250
|
-
- `File`
|
|
251
|
-
- `Blob`
|
|
252
|
-
- `ArrayBuffer`
|
|
253
|
-
- Typed arrays like `Uint8Array`
|
|
254
|
-
- Node.js `Buffer`
|
|
255
|
-
|
|
256
|
-
Example:
|
|
257
|
-
|
|
258
|
-
```ts
|
|
259
|
-
const file = new File([imageBytes], "hero.png", {
|
|
260
|
-
type: "image/png",
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
const upload = await client.media.upload({
|
|
264
|
-
file,
|
|
265
|
-
page_id: "page-id",
|
|
266
|
-
alt: "Homepage hero",
|
|
267
|
-
});
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
If you upload from a raw `Buffer`, `Uint8Array`, or `ArrayBuffer`, you can also pass `file_name` and `content_type`:
|
|
271
|
-
|
|
272
|
-
```ts
|
|
273
|
-
await client.media.upload({
|
|
274
|
-
file: imageBuffer,
|
|
275
|
-
file_name: "hero.png",
|
|
276
|
-
content_type: "image/png",
|
|
277
|
-
page_id: "page-id",
|
|
278
|
-
});
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Members, Authors, Reviewers
|
|
282
|
-
|
|
283
|
-
```ts
|
|
284
|
-
client.members.list(query?, options?)
|
|
285
|
-
client.members.get(memberId, options?)
|
|
286
|
-
client.authors.list(query?, options?)
|
|
287
|
-
client.authors.get(authorId, options?)
|
|
288
|
-
client.reviewers.list(query?, options?)
|
|
289
|
-
client.reviewers.get(reviewerId, options?)
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Supported `sort` fields:
|
|
293
|
-
|
|
294
|
-
- `name`
|
|
295
|
-
- `email`
|
|
296
|
-
- `created_at`
|
|
297
|
-
|
|
298
|
-
Notes:
|
|
299
|
-
|
|
300
|
-
- `members.get()`, `authors.get()`, and `reviewers.get()` are SDK convenience lookups built on top of the paginated list endpoints because the HTTP API does not expose `/members/{id}`, `/authors/{id}`, or `/reviewers/{id}` endpoints.
|
|
301
|
-
- `authors` and `reviewers` are aliases of the member listing endpoints exposed by the API.
|
|
302
|
-
|
|
303
|
-
### Statuses
|
|
304
|
-
|
|
305
|
-
```ts
|
|
306
|
-
client.statuses.list(query?, options?)
|
|
307
|
-
client.statuses.create(body, options?)
|
|
308
|
-
client.statuses.get(statusId, options?)
|
|
309
|
-
client.statuses.update(statusId, body, options?)
|
|
310
|
-
client.statuses.reorder(body, options?)
|
|
311
|
-
client.statuses.delete(statusId, options?)
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
Supported `sort` fields for `statuses.list()`:
|
|
315
|
-
|
|
316
|
-
- `type`
|
|
317
|
-
- `order`
|
|
318
|
-
- `name`
|
|
319
|
-
- `created_at`
|
|
320
|
-
|
|
321
|
-
### Labels
|
|
322
|
-
|
|
323
|
-
```ts
|
|
324
|
-
client.labels.list(query?, options?)
|
|
325
|
-
client.labels.create(body, options?)
|
|
326
|
-
client.labels.get(labelId, options?)
|
|
327
|
-
client.labels.update(labelId, body, options?)
|
|
328
|
-
client.labels.reorder(body, options?)
|
|
329
|
-
client.labels.delete(labelId, options?)
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
Supported `sort` fields for `labels.list()`:
|
|
333
|
-
|
|
334
|
-
- `order`
|
|
335
|
-
- `name`
|
|
336
|
-
- `created_at`
|
|
337
|
-
|
|
338
|
-
### Data Models
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
client.dataModels.list(query?, options?)
|
|
342
|
-
client.dataModels.create(body, options?)
|
|
343
|
-
client.dataModels.get(dataModelId, options?)
|
|
344
|
-
client.dataModels.update(dataModelId, body, options?)
|
|
345
|
-
client.dataModels.delete(dataModelId, options?)
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
Supported `sort` fields for `dataModels.list()`:
|
|
349
|
-
|
|
350
|
-
- `name`
|
|
351
|
-
- `created_at`
|
|
352
|
-
- `updated_at`
|
|
353
|
-
|
|
354
|
-
### Locales
|
|
355
|
-
|
|
356
|
-
```ts
|
|
357
|
-
client.locales.list(options?)
|
|
358
|
-
client.locales.get(code, options?)
|
|
359
|
-
client.locales.create(body, options?)
|
|
360
|
-
client.locales.delete(code, options?)
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
`locales.get()` is an SDK convenience lookup over `locales.list()` because the HTTP API exposes locale listing and deletion by code, but not a dedicated locale detail endpoint.
|
|
364
|
-
|
|
365
|
-
### AI
|
|
366
|
-
|
|
367
|
-
```ts
|
|
368
|
-
client.ai.generateMetaName(body, options?)
|
|
369
|
-
client.ai.generateMetaDescription(body, options?)
|
|
370
|
-
client.ai.generateContent(body, options?)
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
## End-to-End Examples
|
|
374
|
-
|
|
375
|
-
### Create a page and upload its hero image
|
|
376
|
-
|
|
377
|
-
```ts
|
|
378
|
-
const pageResult = await client.pages.create({
|
|
379
|
-
title: "About",
|
|
380
|
-
language: "en",
|
|
381
|
-
content: [
|
|
382
|
-
{
|
|
383
|
-
type: "paragraph",
|
|
384
|
-
content: [{ type: "text", text: "About" }],
|
|
385
|
-
},
|
|
386
|
-
],
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
await client.media.upload({
|
|
390
|
-
file: heroBytes,
|
|
391
|
-
file_name: "about-hero.png",
|
|
392
|
-
content_type: "image/png",
|
|
393
|
-
page_id: pageResult.page.id,
|
|
394
|
-
alt: "About page hero image",
|
|
395
|
-
});
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
### Create a translated page variant
|
|
53
|
+
const page = await client.pages.getBySlug("pricing");
|
|
399
54
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
language: "de",
|
|
403
|
-
mode: "translate",
|
|
404
|
-
model: "openai/gpt-5.4",
|
|
405
|
-
});
|
|
55
|
+
console.log(page.id);
|
|
56
|
+
console.log(page.title);
|
|
406
57
|
```
|
|
407
58
|
|
|
408
|
-
###
|
|
59
|
+
### Get All Supported Languages
|
|
409
60
|
|
|
410
61
|
```ts
|
|
411
|
-
const
|
|
412
|
-
model: "openai/gpt-5.4",
|
|
413
|
-
title: "Platform overview",
|
|
414
|
-
content: [],
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
console.log(generatedMeta.meta_description);
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
## Exported Types
|
|
421
|
-
|
|
422
|
-
The package exports the `Client` class, both error classes, and the main request/response/domain types used by the SDK, including:
|
|
423
|
-
|
|
424
|
-
- `ClientOptions`
|
|
425
|
-
- `RequestOptions`
|
|
426
|
-
- `ListResponse`
|
|
427
|
-
- `PaginationMeta`
|
|
428
|
-
- `Page`
|
|
429
|
-
- `PageSummary`
|
|
430
|
-
- `Collection`
|
|
431
|
-
- `Media`
|
|
432
|
-
- `MediaDetail`
|
|
433
|
-
- `Status`
|
|
434
|
-
- `Label`
|
|
435
|
-
- `DataModel`
|
|
436
|
-
- `Locale`
|
|
437
|
-
- `Member`
|
|
438
|
-
- `CreatePageRequest`
|
|
439
|
-
- `UpdatePageRequest`
|
|
440
|
-
- `UploadMediaRequest`
|
|
441
|
-
- `GenerateContentRequest`
|
|
442
|
-
|
|
443
|
-
## Testing
|
|
62
|
+
const locales = await client.locales.list();
|
|
444
63
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
- Unit tests for request serialization, multipart uploads, error handling, and rate limiting.
|
|
448
|
-
- Live integration tests that create, update, fetch, reorder, delete, and clean up real resources against the Paragraph API.
|
|
449
|
-
|
|
450
|
-
Commands:
|
|
451
|
-
|
|
452
|
-
```bash
|
|
453
|
-
npm test
|
|
454
|
-
npm run test:unit
|
|
455
|
-
npm run test:integration
|
|
64
|
+
console.log(locales.map((locale) => locale.code));
|
|
456
65
|
```
|
|
457
66
|
|
|
458
|
-
|
|
67
|
+
## Framework Guides
|
|
459
68
|
|
|
460
|
-
|
|
461
|
-
- `PARAGRAPH_API_BASE_URL` optional override for local/staging API targets.
|
|
462
|
-
- `PARAGRAPH_AI_MODEL` optional model id for AI endpoint tests. When omitted, AI integration tests are skipped.
|
|
69
|
+
Build with:
|
|
463
70
|
|
|
464
|
-
|
|
71
|
+
- [Next.js](https://paragraphcms.com)
|
|
72
|
+
- [Nuxt](https://paragraphcms.com)
|
|
73
|
+
- [Astro](https://paragraphcms.com)
|
|
74
|
+
- [SvelteKit](https://paragraphcms.com)
|
|
75
|
+
- [Remix](https://paragraphcms.com)
|
|
465
76
|
|
|
466
|
-
##
|
|
77
|
+
## Documentation
|
|
467
78
|
|
|
468
|
-
|
|
469
|
-
- A runtime with standard Fetch API primitives for edge/serverless usage.
|
|
79
|
+
For full guides and API reference, see [paragraphcms.com](https://paragraphcms.com).
|
|
470
80
|
|
|
471
81
|
## License
|
|
472
82
|
|
|
473
|
-
|
|
83
|
+
MIT
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AiContentResult, AiMetaDescriptionResult, AiMetaNameResult, ApiInfo, ClientOptions, Collection, CollectionListQuery, CollectionMutationResult, CreateCollectionRequest, CreateDataModelRequest, CreateLabelRequest, CreateLocaleRequest, CreatePageRequest, CreatePageTranslationRequest, CreateStatusRequest, DataModel, DataModelListQuery, DataModelMutationResult, DeleteByCodeResult, DeleteResult, GenerateContentRequest, GenerateMetaRequest, GetPageQuery, Label, LabelMutationResult, LabelListQuery, ListResponse, Locale, LocaleMutationResult, Media, MediaDeleteResult, MediaDetail, MediaListQuery, MediaMutationResult, MediaUploadResult, Member, MemberListQuery, Page, PageListQuery, PageSummary, PageMutationResult, PageRestoreResult, PermanentDeleteResult, ReorderLabelsRequest, ReorderResult, ReorderStatusesRequest, RequestOptions, Status, StatusListQuery, StatusMutationResult, UpdateCollectionRequest, UpdateDataModelRequest, UpdateLabelRequest, UpdateMediaRequest, UpdatePageRequest, UpdateStatusRequest, UploadMediaRequest } from "./types.js";
|
|
2
2
|
export declare class Client {
|
|
3
3
|
private readonly apiKey;
|
|
4
|
-
private readonly baseUrl;
|
|
5
4
|
private readonly fetchImpl;
|
|
6
5
|
private readonly defaultHeaders;
|
|
7
6
|
private readonly timeoutMs?;
|
|
7
|
+
private readonly maxRateLimitRetries;
|
|
8
8
|
private readonly limiter;
|
|
9
9
|
readonly pages: {
|
|
10
10
|
list: (query?: PageListQuery, options?: RequestOptions) => Promise<ListResponse<PageSummary>>;
|
|
@@ -19,6 +19,7 @@ export declare class Client {
|
|
|
19
19
|
createTranslation: (pageId: string, body: CreatePageTranslationRequest, options?: RequestOptions) => Promise<PageMutationResult>;
|
|
20
20
|
};
|
|
21
21
|
readonly page: {
|
|
22
|
+
get: (pageId: string, query?: GetPageQuery, options?: RequestOptions) => Promise<Page>;
|
|
22
23
|
getBySlug: (slug: string, options?: RequestOptions) => Promise<Page>;
|
|
23
24
|
};
|
|
24
25
|
readonly collections: {
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAEhB,OAAO,EACP,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,4BAA4B,EAC5B,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,KAAK,EACL,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,MAAM,EACN,oBAAoB,EACpB,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,IAAI,EACJ,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EAEtB,cAAc,EACd,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAEhB,OAAO,EACP,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,4BAA4B,EAC5B,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,EACZ,KAAK,EACL,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,MAAM,EACN,oBAAoB,EACpB,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,IAAI,EACJ,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EAEtB,cAAc,EACd,MAAM,EACN,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AA8cpB,qBAAa,MA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