@objectstack/rest 9.4.0 → 9.5.1

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.js CHANGED
@@ -1482,6 +1482,16 @@ var RestServer = class {
1482
1482
  visible = Array.isArray(raw) ? filtered : { ...raw, items: filtered };
1483
1483
  }
1484
1484
  }
1485
+ if (req.params.type === "doc") {
1486
+ const locale = this.extractLocale(req);
1487
+ const { resolveDocLocale } = await import("@objectstack/spec/system");
1488
+ const raw = visible;
1489
+ const list = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : null;
1490
+ if (list) {
1491
+ const localized = list.map((it) => it && typeof it === "object" ? resolveDocLocale(it, locale) : it);
1492
+ visible = Array.isArray(raw) ? localized : { ...raw, items: localized };
1493
+ }
1494
+ }
1485
1495
  if (req.params.type === "doc" && req.query?.include !== "content") {
1486
1496
  const raw = visible;
1487
1497
  const list = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : null;
@@ -1559,7 +1569,7 @@ var RestServer = class {
1559
1569
  const isDraftRead = typeof req.query?.state === "string" && req.query.state.toLowerCase() === "draft";
1560
1570
  const previewDrafts = typeof req.query?.preview === "string" && req.query.preview.toLowerCase() === "draft";
1561
1571
  const packageScoped = typeof req.query?.package === "string" && req.query.package.length > 0;
1562
- if (metadata.enableCache && p.getMetaItemCached && !isAppType && !isDraftRead && !previewDrafts && !packageScoped) {
1572
+ if (metadata.enableCache && p.getMetaItemCached && !isAppType && !isDraftRead && !previewDrafts && !packageScoped && req.params.type !== "doc") {
1563
1573
  const cacheRequest = {
1564
1574
  ifNoneMatch: req.headers["if-none-match"],
1565
1575
  ifModifiedSince: req.headers["if-modified-since"]
@@ -1618,6 +1628,11 @@ var RestServer = class {
1618
1628
  }
1619
1629
  }
1620
1630
  }
1631
+ if (req.params.type === "doc" && visible) {
1632
+ const locale = this.extractLocale(req);
1633
+ const { resolveDocLocale } = await import("@objectstack/spec/system");
1634
+ visible = isMetaEnvelope(visible) ? { ...visible, item: resolveDocLocale(visible.item, locale) } : resolveDocLocale(visible, locale);
1635
+ }
1621
1636
  res.header("Vary", "Accept-Language");
1622
1637
  res.json(await this.translateMetaItem(req, req.params.type, environmentId, visible));
1623
1638
  }