@voxgig/apidef 8.20.0 → 8.21.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/src/utility.ts CHANGED
@@ -1635,6 +1635,16 @@ function envelopeProp(resprops: any, opname: string): string | null {
1635
1635
  if (1 === records.length && isRecordList(resprops[records[0]])) {
1636
1636
  structured = records
1637
1637
  }
1638
+
1639
+ // A page that holds no data of its own reads its one list of records
1640
+ // past a list of scalars, such as Mux's timeframe, and past an object,
1641
+ // such as the filter Novu's notifications were read with.
1642
+ else if (!holdsOwnData(resprops)) {
1643
+ const lists = records.filter((k: string) => isRecordList(resprops[k]))
1644
+ if (1 === lists.length) {
1645
+ structured = lists
1646
+ }
1647
+ }
1638
1648
  }
1639
1649
 
1640
1650
  if (1 !== structured.length) {
@@ -1732,6 +1742,16 @@ function isEnvelopePageProp(name: string): boolean {
1732
1742
  }
1733
1743
 
1734
1744
 
1745
+ // A property that is neither an object nor a list is scalar, however it is
1746
+ // composed, such as a nullable state written as a oneOf. Unless it is status
1747
+ // or paging it is the response's own data, such as the state of GitHub's
1748
+ // combined status beside the statuses it counts.
1749
+ function holdsOwnData(resprops: any): boolean {
1750
+ return keysof(resprops).some((k: string) => !isObjectSchema(resprops[k]) &&
1751
+ true !== propIsList(resprops[k]) && !isEnvelopeStatusProp(k) && !isEnvelopePageProp(k))
1752
+ }
1753
+
1754
+
1735
1755
  // The component a response envelope carries: the resolved reference of the
1736
1756
  // record strictEnvelopeProp unwraps to.
1737
1757
  function envelopeItemRef(schema: any, opname: string): string | null {
@@ -1774,12 +1794,18 @@ function strictEnvelopeProp(props: any, opname: string): string | null {
1774
1794
 
1775
1795
  // The envelope of a schema composed with allOf, such as Lob's list,
1776
1796
  // allOf[list, {data: [...]}]. Only the strict rules apply: most composed
1777
- // schemas are records, and a record's one object is its data.
1797
+ // schemas are records, and a record's one object is its data. A page with no
1798
+ // data of its own is the exception, such as Neon's branches beside their
1799
+ // annotations, and reads its one list of records as a plain page does.
1778
1800
  function composedEnvelopeProp(schema: any, opname: string): string | null {
1779
1801
  if (null == schema || 'object' !== typeof schema || !Array.isArray(schema.allOf)) {
1780
1802
  return null
1781
1803
  }
1782
- return strictEnvelopeProp(mergedProperties(schema), opname)
1804
+ const props = mergedProperties(schema)
1805
+ if ('list' === opname && null != props && !holdsOwnData(props)) {
1806
+ return envelopeProp(props, opname)
1807
+ }
1808
+ return strictEnvelopeProp(props, opname)
1783
1809
  }
1784
1810
 
1785
1811