@minipim/sdk 0.7.0 → 0.9.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/README.md +29 -1
- package/dist/openapi.d.cts +1393 -656
- package/dist/openapi.d.ts +1393 -656
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -192,6 +192,20 @@ await pim.GET('/v1/content', { params: { query: { tag: 'Buying Guide' } } }); //
|
|
|
192
192
|
|
|
193
193
|
Documented in the field descriptions from API **0.14.1+**, and in these types from v0.7.0.
|
|
194
194
|
|
|
195
|
+
## Ordering a content archive (API 0.19.0+)
|
|
196
|
+
|
|
197
|
+
`GET /v1/content` defaults to `updatedAt` descending — the order things were last *edited*, which is rarely the order an archive should read in. Sort by `publishedAt`, which imports preserve from the source system:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const { data } = await pim.GET('/v1/content', {
|
|
201
|
+
params: { query: { sortBy: 'publishedAt', sortDir: 'desc', limit: 20 } },
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Pages with no `publishedAt` sort **last in both directions** — an undated page is unscheduled, not newest. `sortBy` also accepts `updatedAt`, `createdAt` and `title`.
|
|
206
|
+
|
|
207
|
+
`categoryId` behaves exactly like it does on products: **self-only** unless you add `includeDescendants: true`. Content gets filed against leaf categories too, so filtering by a parent section returns an empty page without it.
|
|
208
|
+
|
|
195
209
|
## Uploading files
|
|
196
210
|
|
|
197
211
|
`POST /v1/media` is `multipart/form-data`, not JSON. The file field is named `file`; everything else is optional and lets you attach the upload in the same request:
|
|
@@ -205,7 +219,21 @@ form.append('role', 'technical'); // hero | gallery | thumbnail | tech
|
|
|
205
219
|
form.append('altText', JSON.stringify({ en_US: 'Sell sheet' })); // a JSON *string*, not an object
|
|
206
220
|
```
|
|
207
221
|
|
|
208
|
-
`altText` is parsed as JSON
|
|
222
|
+
`altText` is parsed as JSON, so passing a real object rather than a string stores no alt text. Send `JSON.stringify(...)`.
|
|
223
|
+
|
|
224
|
+
That case no longer fails silently. From API **0.21.0** a malformed `altText` still lets the upload succeed — it never fails the request — but the response says what it ignored:
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
const { data } = await pim.POST('/v1/media', { body: form as never });
|
|
228
|
+
if (data?.warnings?.length) console.warn(data.warnings);
|
|
229
|
+
// ["altText was not valid JSON and no alt text was stored; expected an object keyed by locale, …"]
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`warnings` is absent when there is nothing to report, so a clean upload's response is unchanged.
|
|
233
|
+
|
|
234
|
+
**You do not have to get the content type right.** From API **0.21.0** the leading bytes are sniffed whenever you send `application/octet-stream` or no type at all — so a PNG whose filename lost its extension uploads as a PNG. If a specific declared type contradicts the bytes, the bytes win. SVG, CSV, plain text and the Office formats have no distinguishing magic bytes and still need an explicit type.
|
|
235
|
+
|
|
236
|
+
`role` and `position` are validated: an unrecognised value is a 422 listing the accepted ones in `details.accepted`, not a 500.
|
|
209
237
|
|
|
210
238
|
Requires API **0.14.0+** to appear in the spec at all — before that this endpoint published no request body, so generated clients had nothing for it.
|
|
211
239
|
|