@voxgig/apidef 8.18.1 → 8.20.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/apidef.js +1 -0
- package/dist/apidef.js.map +1 -1
- package/dist/guide/heuristic01.js +17 -5
- package/dist/guide/heuristic01.js.map +1 -1
- package/dist/transform/args.js +27 -0
- package/dist/transform/args.js.map +1 -1
- package/dist/transform/entity.js +15 -14
- package/dist/transform/entity.js.map +1 -1
- package/dist/transform/top.js +30 -16
- package/dist/transform/top.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js.map +1 -1
- package/dist/utility.js +40 -5
- package/dist/utility.js.map +1 -1
- package/package.json +1 -1
- package/src/apidef.ts +1 -0
- package/src/guide/heuristic01.ts +19 -5
- package/src/transform/args.ts +27 -0
- package/src/transform/entity.ts +17 -13
- package/src/transform/top.ts +29 -15
- package/src/types.ts +1 -0
- package/src/utility.ts +52 -5
package/src/utility.ts
CHANGED
|
@@ -1624,7 +1624,19 @@ function envelopeProp(resprops: any, opname: string): string | null {
|
|
|
1624
1624
|
return null
|
|
1625
1625
|
}
|
|
1626
1626
|
|
|
1627
|
-
|
|
1627
|
+
let structured = keys.filter((k: string) => isEntityWrapperProp(resprops[k]))
|
|
1628
|
+
|
|
1629
|
+
// A page's own metadata object, such as Vapi's `metadata` or Neon's
|
|
1630
|
+
// `pagination`, sits beside its records and is not a second candidate. A
|
|
1631
|
+
// list under such a name is records, such as Maxio's custom field metadata.
|
|
1632
|
+
if ('list' === opname) {
|
|
1633
|
+
const records = structured.filter((k: string) =>
|
|
1634
|
+
!isPageMetaProp(k) || true === propIsList(resprops[k]))
|
|
1635
|
+
if (1 === records.length && isRecordList(resprops[records[0]])) {
|
|
1636
|
+
structured = records
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1628
1640
|
if (1 !== structured.length) {
|
|
1629
1641
|
return null
|
|
1630
1642
|
}
|
|
@@ -1666,10 +1678,11 @@ function isEnvelopeStatusProp(name: string): boolean {
|
|
|
1666
1678
|
const ENVELOPE_PAGING_PROPS = new Set([
|
|
1667
1679
|
'count', 'total', 'totalcount', 'totalhits', 'totalitems', 'totalpages',
|
|
1668
1680
|
'totalresults', 'page', 'pages', 'pagecount', 'pagenumber', 'pagesize',
|
|
1669
|
-
'perpage', 'limit', 'offset', 'cursor', 'next', 'nextcursor', 'nextpage',
|
|
1681
|
+
'size', 'perpage', 'limit', 'offset', 'cursor', 'next', 'nextcursor', 'nextpage',
|
|
1670
1682
|
'nextpagetoken', 'nexttoken', 'nexturl', 'previous', 'prev',
|
|
1671
1683
|
'previouscursor', 'prevcursor', 'previouspage', 'prevpage', 'previousurl',
|
|
1672
1684
|
'prevurl', 'hasmore', 'hasnext', 'hasprevious', 'object', 'url',
|
|
1685
|
+
'currentpage',
|
|
1673
1686
|
])
|
|
1674
1687
|
|
|
1675
1688
|
|
|
@@ -1678,10 +1691,44 @@ function isEnvelopePagingProp(name: string): boolean {
|
|
|
1678
1691
|
}
|
|
1679
1692
|
|
|
1680
1693
|
|
|
1681
|
-
//
|
|
1682
|
-
//
|
|
1694
|
+
// A list whose items are objects. GitHub's feed holds a list of URL strings
|
|
1695
|
+
// beside its links, and a page of strings is not a page of records.
|
|
1696
|
+
function isRecordList(prop: any): boolean {
|
|
1697
|
+
return isObjectSchema(true === propIsList(prop) ? prop?.items : null)
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
|
|
1701
|
+
// An object, or a composition with a branch that is one. A nullable string
|
|
1702
|
+
// written as a oneOf is not.
|
|
1703
|
+
function isObjectSchema(schema: any): boolean {
|
|
1704
|
+
if (null == schema || 'object' !== typeof schema) {
|
|
1705
|
+
return false
|
|
1706
|
+
}
|
|
1707
|
+
if (null != schema.$ref || null != schema.properties || 'object' === schema.type) {
|
|
1708
|
+
return true
|
|
1709
|
+
}
|
|
1710
|
+
return ['allOf', 'oneOf', 'anyOf'].some((k: string) =>
|
|
1711
|
+
Array.isArray(schema[k]) && schema[k].some(isObjectSchema))
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
// The object a page may carry about itself beside its records, compared as
|
|
1716
|
+
// the paging names are.
|
|
1717
|
+
const PAGE_META_PROPS = new Set([
|
|
1718
|
+
'meta', 'metadata', 'pagination', 'paging', 'pageinfo', 'links',
|
|
1719
|
+
])
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
function isPageMetaProp(name: string): boolean {
|
|
1723
|
+
return PAGE_META_PROPS.has(name.toLowerCase().replace(/[_-]/g, ''))
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
// Paging, the page's own metadata, or a count that describes the page, such
|
|
1728
|
+
// as the number of Lob's QR codes on the page that were scanned at least once.
|
|
1683
1729
|
function isEnvelopePageProp(name: string): boolean {
|
|
1684
|
-
return isEnvelopePagingProp(name) || name
|
|
1730
|
+
return isEnvelopePagingProp(name) || isPageMetaProp(name) ||
|
|
1731
|
+
name.toLowerCase().replace(/[_-]/g, '').endsWith('count')
|
|
1685
1732
|
}
|
|
1686
1733
|
|
|
1687
1734
|
|