@voxgig/apidef 8.22.0 → 8.23.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
@@ -1129,6 +1129,25 @@ function normalizeFieldName(s: string): string {
1129
1129
  }
1130
1130
 
1131
1131
 
1132
+ function canonizeParam(name: string): string {
1133
+ return depluralize(snakify(normalizeFieldName(name)))
1134
+ }
1135
+
1136
+
1137
+ // A guide may key a rename by the definition's spelling, its normalized form
1138
+ // or its canonical form.
1139
+ function paramName(wire: string, renames?: Record<string, any> | null): string {
1140
+ for (const key of [wire, normalizeFieldName(wire), canonizeParam(wire)]) {
1141
+ const target = null != renames && Object.prototype.hasOwnProperty.call(renames, key) ?
1142
+ renames[key] : undefined
1143
+ if ('string' === typeof target && '' !== target) {
1144
+ return target
1145
+ }
1146
+ }
1147
+ return canonizeParam(wire)
1148
+ }
1149
+
1150
+
1132
1151
  const MIN_ENTITY_NAME_LEN = 3
1133
1152
  const MAX_ENTITY_NAME_LEN = 67
1134
1153
 
@@ -1996,6 +2015,8 @@ export {
1996
2015
  ensureMinEntityName,
1997
2016
  inferFieldType,
1998
2017
  normalizeFieldName,
2018
+ canonizeParam,
2019
+ paramName,
1999
2020
  humanTitle,
2000
2021
  prefixLeadingDigit,
2001
2022
  debugpath,