@voxgig/apidef 8.25.4 → 8.26.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
@@ -1120,6 +1120,13 @@ function cmpRefName(xref: string): string {
1120
1120
  }
1121
1121
 
1122
1122
 
1123
+ // Entity names with one key meet as one class in PHP and one file on a
1124
+ // case-insensitive file system: `use_case` and `usecase` are `usecase`.
1125
+ function foldName(name: string): string {
1126
+ return String(camelify(name)).toLowerCase()
1127
+ }
1128
+
1129
+
1123
1130
  const FIRST_LETTER_RE = /[a-zA-Z]/
1124
1131
 
1125
1132
 
@@ -1828,8 +1835,10 @@ function envelopeProp(resprops: any, opname: string): string | null {
1828
1835
 
1829
1836
  // A page that holds no data of its own reads its one list of records
1830
1837
  // past a list of scalars, such as Mux's timeframe, and past an object,
1831
- // such as the filter Novu's notifications were read with.
1832
- else if (!holdsOwnData(resprops)) {
1838
+ // such as the filter Novu's notifications were read with. A page that
1839
+ // says where it is in the paging reads it past scalars of its own too,
1840
+ // such as whether Edgepedia's timeline was sampled.
1841
+ else if (!holdsOwnData(resprops) || holdsPagePosition(resprops)) {
1833
1842
  const lists = records.filter((k: string) => isRecordList(resprops[k]))
1834
1843
  if (1 === lists.length) {
1835
1844
  structured = lists
@@ -1837,6 +1846,15 @@ function envelopeProp(resprops: any, opname: string): string | null {
1837
1846
  }
1838
1847
  }
1839
1848
 
1849
+ // A single item may carry the same metadata object a page does, such as
1850
+ // the `meta` beside each of Open Mindfulness's records.
1851
+ else {
1852
+ const items = structured.filter((k: string) => !isItemMetaProp(resprops, k))
1853
+ if (1 === items.length) {
1854
+ structured = items
1855
+ }
1856
+ }
1857
+
1840
1858
  if (1 !== structured.length) {
1841
1859
  return null
1842
1860
  }
@@ -1850,8 +1868,9 @@ function envelopeProp(resprops: any, opname: string): string | null {
1850
1868
  }
1851
1869
 
1852
1870
  // Beside an `id` or other data, one object is the record's own, such as
1853
- // Lob's link and its metadata. A single item sits beside status or paging.
1854
- if (!islist && keys.some((k: string) => k !== key &&
1871
+ // Lob's link and its metadata. A single item sits beside status, paging or
1872
+ // its metadata.
1873
+ if (!islist && keys.some((k: string) => k !== key && !isItemMetaProp(resprops, k) &&
1855
1874
  !isEnvelopeStatusProp(k) && !isEnvelopePagingProp(k))) {
1856
1875
  return null
1857
1876
  }
@@ -1924,6 +1943,36 @@ function isPageMetaProp(name: string): boolean {
1924
1943
  }
1925
1944
 
1926
1945
 
1946
+ // The page metadata a single item may carry too. Paging beside an object makes
1947
+ // it a page, such as GitHub's attestations by digest beside their page info.
1948
+ const ITEM_META_PROPS = new Set(['meta', 'metadata', 'links'])
1949
+
1950
+
1951
+ // A list under a metadata name is records, as it is on a page.
1952
+ function isItemMetaProp(resprops: any, name: string): boolean {
1953
+ return ITEM_META_PROPS.has(name.toLowerCase().replace(/[_-]/g, '')) &&
1954
+ true !== propIsList(resprops[name])
1955
+ }
1956
+
1957
+
1958
+ // The paging names that say where a page is, rather than how many records
1959
+ // there are, so a record that counts what it lists does not pass for a page.
1960
+ const PAGE_POSITION_PROPS = new Set([
1961
+ 'page', 'pages', 'pagenumber', 'currentpage', 'totalpages', 'offset',
1962
+ 'cursor', 'next', 'nextcursor', 'nextpage', 'nextpagetoken', 'nexttoken',
1963
+ 'nexturl', 'previous', 'prev', 'previouscursor', 'prevcursor',
1964
+ 'previouspage', 'prevpage', 'previousurl', 'prevurl', 'hasmore', 'hasnext',
1965
+ 'hasprevious',
1966
+ ])
1967
+
1968
+
1969
+ function holdsPagePosition(resprops: any): boolean {
1970
+ return keysof(resprops).some((k: string) =>
1971
+ PAGE_POSITION_PROPS.has(k.toLowerCase().replace(/[_-]/g, '')) &&
1972
+ !isObjectSchema(resprops[k]) && true !== propIsList(resprops[k]))
1973
+ }
1974
+
1975
+
1927
1976
  // Paging, the page's own metadata, or a count that describes the page, such
1928
1977
  // as the number of Lob's QR codes on the page that were scanned at least once.
1929
1978
  function isEnvelopePageProp(name: string): boolean {
@@ -2223,6 +2272,7 @@ export {
2223
2272
  canonizeParam,
2224
2273
  paramName,
2225
2274
  humanTitle,
2275
+ foldName,
2226
2276
  prefixLeadingDigit,
2227
2277
  debugpath,
2228
2278
  debugpathOn,