@objectstack/rest 9.4.0 → 9.5.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/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1522,6 +1522,16 @@ var RestServer = class {
|
|
|
1522
1522
|
visible = Array.isArray(raw) ? filtered : { ...raw, items: filtered };
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
|
+
if (req.params.type === "doc") {
|
|
1526
|
+
const locale = this.extractLocale(req);
|
|
1527
|
+
const { resolveDocLocale } = await import("@objectstack/spec/system");
|
|
1528
|
+
const raw = visible;
|
|
1529
|
+
const list = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : null;
|
|
1530
|
+
if (list) {
|
|
1531
|
+
const localized = list.map((it) => it && typeof it === "object" ? resolveDocLocale(it, locale) : it);
|
|
1532
|
+
visible = Array.isArray(raw) ? localized : { ...raw, items: localized };
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1525
1535
|
if (req.params.type === "doc" && req.query?.include !== "content") {
|
|
1526
1536
|
const raw = visible;
|
|
1527
1537
|
const list = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : null;
|
|
@@ -1599,7 +1609,7 @@ var RestServer = class {
|
|
|
1599
1609
|
const isDraftRead = typeof req.query?.state === "string" && req.query.state.toLowerCase() === "draft";
|
|
1600
1610
|
const previewDrafts = typeof req.query?.preview === "string" && req.query.preview.toLowerCase() === "draft";
|
|
1601
1611
|
const packageScoped = typeof req.query?.package === "string" && req.query.package.length > 0;
|
|
1602
|
-
if (metadata.enableCache && p.getMetaItemCached && !isAppType && !isDraftRead && !previewDrafts && !packageScoped) {
|
|
1612
|
+
if (metadata.enableCache && p.getMetaItemCached && !isAppType && !isDraftRead && !previewDrafts && !packageScoped && req.params.type !== "doc") {
|
|
1603
1613
|
const cacheRequest = {
|
|
1604
1614
|
ifNoneMatch: req.headers["if-none-match"],
|
|
1605
1615
|
ifModifiedSince: req.headers["if-modified-since"]
|
|
@@ -1658,6 +1668,11 @@ var RestServer = class {
|
|
|
1658
1668
|
}
|
|
1659
1669
|
}
|
|
1660
1670
|
}
|
|
1671
|
+
if (req.params.type === "doc" && visible) {
|
|
1672
|
+
const locale = this.extractLocale(req);
|
|
1673
|
+
const { resolveDocLocale } = await import("@objectstack/spec/system");
|
|
1674
|
+
visible = isMetaEnvelope(visible) ? { ...visible, item: resolveDocLocale(visible.item, locale) } : resolveDocLocale(visible, locale);
|
|
1675
|
+
}
|
|
1661
1676
|
res.header("Vary", "Accept-Language");
|
|
1662
1677
|
res.json(await this.translateMetaItem(req, req.params.type, environmentId, visible));
|
|
1663
1678
|
}
|