@looker/sdk-codegen 21.6.0 → 21.7.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.
@@ -208,7 +208,10 @@ export var compareResponses = (lMethod, rMethod, count) => {
208
208
  };
209
209
  };
210
210
  export var csvHeaderRow = 'method name,"Op + URI",left status,right status,typeDiff,paramDiff,bodyDiff,responseDiff,diffCount';
211
- export var csvDiffRow = diff => "\n".concat(diff.name, ",").concat(diff.id, ",").concat(diff.lStatus, ",").concat(diff.rStatus, ",").concat(diff.typeDiff, ",").concat(diff.paramsDiff, ",").concat(diff.bodyDiff, ",").concat(diff.responseDiff, ",").concat(JSON.stringify(diff.diffCount));
211
+ export var csvDiffRow = diff => {
212
+ var diffCount = JSON.stringify(diff.diffCount).replace(/"/g, "'");
213
+ return "\n".concat(diff.name, ",").concat(diff.id, ",").concat(diff.lStatus, ",").concat(diff.rStatus, ",").concat(diff.typeDiff, ",").concat(diff.paramsDiff, ",").concat(diff.bodyDiff, ",").concat(diff.responseDiff, ",\"").concat(diffCount, "\"");
214
+ };
212
215
  export var mdHeaderRow = "\n| method name | Op + URI | 3.1 | 4.0 | typeDiff | paramDiff | bodyDiff | responseDiff | diffCount |\n| ------------ | -------- | --- | --- | ------------ | --------- | -------- | ------------ | --------- |";
213
216
  export var mdDiffRow = diff => "\n| ".concat(diff.name, " | ").concat(diff.id, " | ").concat(diff.lStatus, " | ").concat(diff.rStatus, " | ").concat(diff.typeDiff, " | ").concat(diff.paramsDiff, " | ").concat(diff.bodyDiff, " | ").concat(diff.responseDiff, " | ").concat(JSON.stringify(diff.diffCount), " |");
214
217
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/specDiff.ts"],"names":["EnumType","ArrayType","DiffCompare","startCount","changed","added","removed","diffCompare","lKey","rKey","localeCompare","RightMissing","LeftMissing","countDiffs","count","lKeys","rKeys","comparer","sort","a","b","l","r","length","lk","rk","comp","compareEnumTypes","lType","rType","lNum","rNum","values","map","v","toString","lVal","JSON","stringify","rVal","lhs","rhs","compareTypes","elementType","asHashString","diff","Object","keys","properties","summary","lhsVal","rhsVal","compareParams","lMethod","rMethod","lParams","rParams","allParams","forEach","p","name","lsh","signature","rsh","lSignature","rSignature","compareBodies","bodyParams","lSide","type","fullName","required","rSide","compareResponses","responses","statusCode","mediaType","csvHeaderRow","csvDiffRow","id","lStatus","rStatus","typeDiff","paramsDiff","bodyDiff","responseDiff","diffCount","mdHeaderRow","mdDiffRow","diffToString","result","replace","computeDiff","Error","countStatus","status","includeDiffs","delta","compareSpecs","lSpec","rSpec","include","specSort","lMethods","methods","rMethods","lLength","rLength","lIndex","rIndex","undefined","push"],"mappings":"AA2BA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,aAApC;IAOKC,W;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W;;AAgBL,OAAO,IAAMC,UAAU,GAAG,MAAiB;AACzC,SAAO;AAAEC,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,KAAK,EAAE,CAArB;AAAwBC,IAAAA,OAAO,EAAE;AAAjC,GAAP;AACD,CAFM;;AAIP,IAAMC,WAAW,GAAG,CAACC,IAAD,EAAeC,IAAf,KAAgC;AAClD,MAAID,IAAI,IAAIC,IAAZ,EAAkB,OAAOD,IAAI,CAACE,aAAL,CAAmBD,IAAnB,CAAP;AAClB,MAAID,IAAJ,EAAU,OAAON,WAAW,CAACS,YAAnB;AACV,SAAOT,WAAW,CAACU,WAAnB;AACD,CAJD;;AAMA,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACxBC,KADwB,EAExBC,KAFwB,EAGxBC,KAHwB,EAKrB;AAAA,MADHC,QACG,uEADqBV,WACrB;AACHQ,EAAAA,KAAK,GAAGA,KAAK,CAACG,IAAN,CAAW,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACT,a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,KAHM,MAGA,IAAItD,QAAO,CAACyB,EAAR,GAAa1B,QAAO,CAAC0B,EAAzB,EAA6B;AAClC1B,MAAAA,QAAO,GAAGyD,SAAV;AACAD,MAAAA,MAAM;AACP,KAHM,MAGA;AACLD,MAAAA,MAAM;AACNC,MAAAA,MAAM;AACP;;AAED,QAAMZ,MAAK,GAAGL,WAAW,CAACvC,QAAD,EAAUC,QAAV,CAAzB;;AACA,QAAI+C,OAAO,CAACJ,MAAD,EAAQ5C,QAAR,EAAiBC,QAAjB,CAAX,EAAsC;AACpCT,MAAAA,IAAI,CAACkE,IAAL,CAAUd,MAAV;AACD;AACF;;AACD,SAAOpD,IAAP;AACD,CAzCM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IMethod, IType, KeyedCollection, IApiModel } from './sdkModels'\nimport { EnumType, ArrayType } from './sdkModels'\n\ninterface ITypeDelta {\n lhs: string\n rhs: string\n}\n\nenum DiffCompare {\n RightMissing = -1,\n Equal = 0,\n LeftMissing = 1,\n}\n\nexport interface DiffCount {\n changed: number\n added: number\n removed: number\n}\n\nexport type TypeDelta = KeyedCollection<ITypeDelta>\n\nexport type DiffTracker = (lKey: string, rKey: string) => number\n\nexport const startCount = (): DiffCount => {\n return { changed: 0, added: 0, removed: 0 }\n}\n\nconst diffCompare = (lKey: string, rKey: string) => {\n if (lKey && rKey) return lKey.localeCompare(rKey)\n if (lKey) return DiffCompare.RightMissing\n return DiffCompare.LeftMissing\n}\n\nexport const countDiffs = (\n count: DiffCount,\n lKeys: string[],\n rKeys: string[],\n comparer: DiffTracker = diffCompare\n) => {\n lKeys = lKeys.sort((a, b) => a.localeCompare(b))\n rKeys = rKeys.sort((a, b) => a.localeCompare(b))\n let l = 0\n let r = 0\n while (l < lKeys.length || r < rKeys.length) {\n const lk = lKeys[l]\n const rk = rKeys[r]\n const comp = comparer(lk, rk)\n switch (comp) {\n case DiffCompare.LeftMissing: {\n count.added++\n r++\n break\n }\n case DiffCompare.RightMissing: {\n count.removed++\n l++\n break\n }\n default: {\n l++\n r++\n }\n }\n }\n return count\n}\n\nexport const compareEnumTypes = (\n lType: IType,\n rType: IType,\n count: DiffCount\n) => {\n const lNum = lType as EnumType\n const rNum = rType as EnumType\n const lKeys = lNum.values.map((v) => v.toString())\n const rKeys = rNum.values.map((v) => v.toString())\n countDiffs(count, lKeys, rKeys)\n const lVal = JSON.stringify(lKeys)\n const rVal = JSON.stringify(rKeys)\n if (lVal === rVal) return\n return {\n lhs: lVal,\n rhs: rVal,\n }\n}\n\n/**\n * Compares two types and returns an object of non-matching entries\n * @param lType\n * @param rType\n * @param count change tracking\n */\nexport const compareTypes = (lType: IType, rType: IType, count: DiffCount) => {\n if (lType instanceof EnumType) {\n return compareEnumTypes(lType, rType, count)\n }\n\n if (lType instanceof ArrayType) {\n lType = lType.elementType\n }\n\n if (rType instanceof ArrayType) {\n rType = rType.elementType\n }\n\n if (lType.asHashString() === rType.asHashString()) return\n\n const diff: TypeDelta = {}\n countDiffs(\n count,\n Object.keys(lType.properties),\n Object.keys(rType.properties),\n (lKey, rKey) => {\n const comp = diffCompare(lKey, rKey)\n switch (comp) {\n case DiffCompare.LeftMissing: {\n diff[rKey] = {\n lhs: '',\n rhs: rType.properties[rKey].summary(),\n }\n break\n }\n case DiffCompare.RightMissing: {\n diff[lKey] = {\n lhs: lType.properties[lKey].summary(),\n rhs: '',\n }\n break\n }\n default: {\n const lhsVal = lType.properties[lKey]\n const rhsVal = rType.properties[rKey]\n const lhs = lhsVal.summary()\n const rhs = rhsVal.summary()\n if (lhs !== rhs) {\n count.changed++\n diff[lKey] = {\n lhs,\n rhs,\n }\n }\n }\n }\n return comp\n }\n )\n if (Object.keys(diff).length === 0) return\n return diff\n}\n\n/**\n * Compares the params of two methods and returns the signature of both methods\n * if non matching.\n * @param lMethod\n * @param rMethod\n * @param count change tracking\n */\nexport const compareParams = (\n lMethod: IMethod,\n rMethod: IMethod,\n count: DiffCount\n) => {\n const lParams = {}\n const rParams = {}\n lMethod.allParams.forEach((p) => (lParams[p.name] = p))\n rMethod.allParams.forEach((p) => (rParams[p.name] = p))\n // TODO typediff the matching body types?\n countDiffs(\n count,\n Object.keys(lParams),\n Object.keys(rParams),\n (lKey, rKey) => {\n const comp = diffCompare(lKey, rKey)\n if (comp === 0) {\n const lsh = lParams[lKey].signature()\n const rsh = rParams[rKey].signature()\n if (lsh !== rsh) {\n count.changed++\n }\n }\n return comp\n }\n )\n\n const lSignature = lMethod.signature()\n const rSignature = rMethod.signature()\n if (lSignature === rSignature) return\n\n return {\n lhs: lSignature,\n rhs: rSignature,\n }\n}\n\n/**\n * Compares the bodies of two methods and returns diffs if there are any\n * @param lMethod\n * @param rMethod\n * @param count change tracking\n */\nexport const compareBodies = (\n lMethod: IMethod,\n rMethod: IMethod,\n count: DiffCount\n) => {\n const lParams = {}\n const rParams = {}\n lMethod.bodyParams.forEach((p) => (lParams[p.name] = p))\n rMethod.bodyParams.forEach((p) => (rParams[p.name] = p))\n // TODO typediff the matching body types?\n countDiffs(count, Object.keys(lParams), Object.keys(rParams))\n\n const lSide = lMethod.bodyParams.map((p) => {\n return {\n name: p.name,\n type: p.type.fullName,\n required: p.required,\n }\n })\n const rSide = rMethod.bodyParams.map((p) => {\n return {\n name: p.name,\n type: p.type.fullName,\n required: p.required,\n }\n })\n\n if (JSON.stringify(lSide) === JSON.stringify(rSide)) return\n\n count.changed++\n return {\n lhs: lSide,\n rhs: rSide,\n }\n}\n\n/**\n * Compare two response lists, returning diff\n * @param lMethod\n * @param rMethod\n * @param count change tracking\n */\nexport const compareResponses = (\n lMethod: IMethod,\n rMethod: IMethod,\n count: DiffCount\n) => {\n // TODO deep type comparison? Probably diff all types instead\n const lSide = lMethod.responses.map((r) => {\n return {\n statusCode: r.statusCode,\n mediaType: r.mediaType,\n type: r.type.fullName,\n }\n })\n const rSide = rMethod.responses.map((r) => {\n return {\n statusCode: r.statusCode,\n mediaType: r.mediaType,\n type: r.type.fullName,\n }\n })\n if (JSON.stringify(lSide) === JSON.stringify(rSide)) return\n\n count.changed++\n return {\n lhs: lSide,\n rhs: rSide,\n }\n}\n\nexport const csvHeaderRow =\n 'method name,\"Op + URI\",left status,right status,typeDiff,paramDiff,bodyDiff,responseDiff,diffCount'\n\nexport const csvDiffRow = (diff: DiffRow) => `\n${diff.name},${diff.id},${diff.lStatus},${diff.rStatus},${diff.typeDiff},${\n diff.paramsDiff\n},${diff.bodyDiff},${diff.responseDiff},${JSON.stringify(diff.diffCount)}`\n\nexport const mdHeaderRow = `\n| method name | Op + URI | 3.1 | 4.0 | typeDiff | paramDiff | bodyDiff | responseDiff | diffCount |\n| ------------ | -------- | --- | --- | ------------ | --------- | -------- | ------------ | --------- |`\n\nexport const mdDiffRow = (diff: DiffRow) => `\n| ${diff.name} | ${diff.id} | ${diff.lStatus} | ${diff.rStatus} | ${\n diff.typeDiff\n} | ${diff.paramsDiff} | ${diff.bodyDiff} | ${\n diff.responseDiff\n} | ${JSON.stringify(diff.diffCount)} |`\n\nconst diffToString = (diff: any) => {\n if (!diff) return ''\n const result = JSON.stringify(diff, null, 2)\n if (result === '{}') return ''\n return `\"${result.replace(/\"/g, \"'\")}\"`\n}\n\nexport interface ComputeDiffInputs {\n lMethod?: IMethod\n rMethod?: IMethod\n}\n\nexport interface DiffRow {\n /** Method name */\n name: string\n /** Method operation and path */\n id: string\n /** Method status in both specs */\n lStatus: string\n rStatus: string\n /** Method type diff if any */\n typeDiff: string\n /** Method params diff if any */\n paramsDiff: string\n /** Body diff if any */\n bodyDiff: string\n /** Response diff if any */\n responseDiff: string\n /** Count of differences */\n diffCount: DiffCount\n}\n\n/**\n * Computes the diff of two methods\n * @param lMethod\n * @param rMethod\n */\nconst computeDiff = (lMethod?: IMethod, rMethod?: IMethod) => {\n if (!lMethod && !rMethod) throw new Error('At least one method is required.')\n\n const count = startCount()\n const countStatus = () => {\n if (!rMethod) {\n count.removed++\n } else if (!lMethod) {\n count.added++\n } else {\n if (lMethod.status !== rMethod.status) count.changed++\n }\n }\n\n let result: DiffRow\n countStatus()\n if (lMethod) {\n const typeDiff = rMethod\n ? diffToString(compareTypes(lMethod.type, rMethod.type, count))\n : ''\n const paramsDiff = rMethod\n ? diffToString(compareParams(lMethod, rMethod, count))\n : ''\n const bodyDiff = rMethod\n ? diffToString(compareBodies(lMethod, rMethod, count))\n : ''\n const responseDiff = rMethod\n ? diffToString(compareResponses(lMethod, rMethod, count))\n : ''\n result = {\n name: lMethod.name,\n id: lMethod.id,\n lStatus: lMethod.status,\n rStatus: rMethod ? rMethod.status : '',\n typeDiff,\n paramsDiff,\n bodyDiff,\n responseDiff,\n diffCount: count,\n }\n } else if (!lMethod && rMethod) {\n result = {\n name: rMethod.name,\n id: rMethod.id,\n lStatus: '',\n rStatus: rMethod.status,\n typeDiff: '',\n paramsDiff: '',\n bodyDiff: '',\n responseDiff: '',\n diffCount: count,\n }\n }\n\n return result!\n}\n\nexport type DiffFilter = (\n delta: DiffRow,\n lMethod?: IMethod,\n rMethod?: IMethod\n) => boolean\n\n/**\n * Include when:\n * - lMethod is missing\n * - rMethod is missing\n * - params differ\n * - types differ\n * @param delta\n * @param lMethod\n * @param rMethod\n */\nexport const includeDiffs: DiffFilter = (delta, lMethod, rMethod) =>\n !lMethod ||\n !rMethod! ||\n delta.lStatus !== delta.rStatus ||\n !!delta.paramsDiff ||\n !!delta.typeDiff ||\n !!delta.bodyDiff ||\n !!delta.responseDiff\n\n/**\n * Compares two specs and returns a diff object\n * @param lSpec left-side spec\n * @param rSpec right-side spec\n * @param include evaluates to true if the comparison should be included\n */\nexport const compareSpecs = (\n lSpec: IApiModel,\n rSpec: IApiModel,\n include: DiffFilter = includeDiffs\n) => {\n const specSort = (a: IMethod, b: IMethod) => a.id.localeCompare(b.id)\n\n const lMethods = Object.values(lSpec.methods).sort(specSort)\n const rMethods = Object.values(rSpec.methods).sort(specSort)\n\n const lLength = lMethods.length\n const rLength = rMethods.length\n let lIndex = 0\n let rIndex = 0\n const diff: DiffRow[] = []\n\n while (lIndex < lLength || rIndex < rLength) {\n let lMethod: IMethod | undefined = lMethods[lIndex]\n let rMethod: IMethod | undefined = rMethods[rIndex]\n\n if (!lMethod) {\n rIndex++\n } else if (!rMethod) {\n lIndex++\n } else if (lMethod.id < rMethod.id) {\n rMethod = undefined\n lIndex++\n } else if (rMethod.id < lMethod.id) {\n lMethod = undefined\n rIndex++\n } else {\n lIndex++\n rIndex++\n }\n\n const delta = computeDiff(lMethod, rMethod)\n if (include(delta, lMethod, rMethod)) {\n diff.push(delta)\n }\n }\n return diff\n}\n"],"file":"specDiff.js"}
1
+ {"version":3,"sources":["../../src/specDiff.ts"],"names":["EnumType","ArrayType","DiffCompare","startCount","changed","added","removed","diffCompare","lKey","rKey","localeCompare","RightMissing","LeftMissing","countDiffs","count","lKeys","rKeys","comparer","sort","a","b","l","r","length","lk","rk","comp","compareEnumTypes","lType","rType","lNum","rNum","values","map","v","toString","lVal","JSON","stringify","rVal","lhs","rhs","compareTypes","elementType","asHashString","diff","Object","keys","properties","summary","lhsVal","rhsVal","compareParams","lMethod","rMethod","lParams","rParams","allParams","forEach","p","name","lsh","signature","rsh","lSignature","rSignature","compareBodies","bodyParams","lSide","type","fullName","required","rSide","compareResponses","responses","statusCode","mediaType","csvHeaderRow","csvDiffRow","diffCount","replace","id","lStatus","rStatus","typeDiff","paramsDiff","bodyDiff","responseDiff","mdHeaderRow","mdDiffRow","diffToString","result","computeDiff","Error","countStatus","status","includeDiffs","delta","compareSpecs","lSpec","rSpec","include","specSort","lMethods","methods","rMethods","lLength","rLength","lIndex","rIndex","undefined","push"],"mappings":"AA2BA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,aAApC;IAOKC,W;;WAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W;;AAgBL,OAAO,IAAMC,UAAU,GAAG,MAAiB;AACzC,SAAO;AAAEC,IAAAA,OAAO,EAAE,CAAX;AAAcC,IAAAA,KAAK,EAAE,CAArB;AAAwBC,IAAAA,OAAO,EAAE;AAAjC,GAAP;AACD,CAFM;;AAIP,IAAMC,WAAW,GAAG,CAACC,IAAD,EAAeC,IAAf,KAAgC;AAClD,MAAID,IAAI,IAAIC,IAAZ,EAAkB,OAAOD,IAAI,CAACE,aAAL,CAAmBD,IAAnB,CAAP;AAClB,MAAID,IAAJ,EAAU,OAAON,WAAW,CAACS,YAAnB;AACV,SAAOT,WAAW,CAACU,WAAnB;AACD,CAJD;;AAMA,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAa,CACxBC,KADwB,EAExBC,KAFwB,EAGxBC,KAHwB,EAKrB;AAAA,MADHC,QACG,uEADqBV,WACrB;AACHQ,EAAAA,KAAK,GAAGA,KAAK,CAACG,IAAN,CAAW,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACT,aAAF,CAAgBU,CAAhB,CAArB,CAAR;AACAJ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MAAAA,QAAO,GAAGwD,SAAV;AACAF,MAAAA,MAAM;AACP,KAHM,MAGA,IAAItD,QAAO,CAAC2B,EAAR,GAAa5B,QAAO,CAAC4B,EAAzB,EAA6B;AAClC5B,MAAAA,QAAO,GAAGyD,SAAV;AACAD,MAAAA,MAAM;AACP,KAHM,MAGA;AACLD,MAAAA,MAAM;AACNC,MAAAA,MAAM;AACP;;AAED,QAAMZ,MAAK,GAAGL,WAAW,CAACvC,QAAD,EAAUC,QAAV,CAAzB;;AACA,QAAI+C,OAAO,CAACJ,MAAD,EAAQ5C,QAAR,EAAiBC,QAAjB,CAAX,EAAsC;AACpCT,MAAAA,IAAI,CAACkE,IAAL,CAAUd,MAAV;AACD;AACF;;AACD,SAAOpD,IAAP;AACD,CAzCM","sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport type { IMethod, IType, KeyedCollection, IApiModel } from './sdkModels'\nimport { EnumType, ArrayType } from './sdkModels'\n\ninterface ITypeDelta {\n lhs: string\n rhs: string\n}\n\nenum DiffCompare {\n RightMissing = -1,\n Equal = 0,\n LeftMissing = 1,\n}\n\nexport interface DiffCount {\n changed: number\n added: number\n removed: number\n}\n\nexport type TypeDelta = KeyedCollection<ITypeDelta>\n\nexport type DiffTracker = (lKey: string, rKey: string) => number\n\nexport const startCount = (): DiffCount => {\n return { changed: 0, added: 0, removed: 0 }\n}\n\nconst diffCompare = (lKey: string, rKey: string) => {\n if (lKey && rKey) return lKey.localeCompare(rKey)\n if (lKey) return DiffCompare.RightMissing\n return DiffCompare.LeftMissing\n}\n\nexport const countDiffs = (\n count: DiffCount,\n lKeys: string[],\n rKeys: string[],\n comparer: DiffTracker = diffCompare\n) => {\n lKeys = lKeys.sort((a, b) => a.localeCompare(b))\n rKeys = rKeys.sort((a, b) => a.localeCompare(b))\n let l = 0\n let r = 0\n while (l < lKeys.length || r < rKeys.length) {\n const lk = lKeys[l]\n const rk = rKeys[r]\n const comp = comparer(lk, rk)\n switch (comp) {\n case DiffCompare.LeftMissing: {\n count.added++\n r++\n break\n }\n case DiffCompare.RightMissing: {\n count.removed++\n l++\n break\n }\n default: {\n l++\n r++\n }\n }\n }\n return count\n}\n\nexport const compareEnumTypes = (\n lType: IType,\n rType: IType,\n count: DiffCount\n) => {\n const lNum = lType as EnumType\n const rNum = rType as EnumType\n const lKeys = lNum.values.map((v) => v.toString())\n const rKeys = rNum.values.map((v) => v.toString())\n countDiffs(count, lKeys, rKeys)\n const lVal = JSON.stringify(lKeys)\n const rVal = JSON.stringify(rKeys)\n if (lVal === rVal) return\n return {\n lhs: lVal,\n rhs: rVal,\n }\n}\n\n/**\n * Compares two types and returns an object of non-matching entries\n * @param lType\n * @param rType\n * @param count change tracking\n */\nexport const compareTypes = (lType: IType, rType: IType, count: DiffCount) => {\n if (lType instanceof EnumType) {\n return compareEnumTypes(lType, rType, count)\n }\n\n if (lType instanceof ArrayType) {\n lType = lType.elementType\n }\n\n if (rType instanceof ArrayType) {\n rType = rType.elementType\n }\n\n if (lType.asHashString() === rType.asHashString()) return\n\n const diff: TypeDelta = {}\n countDiffs(\n count,\n Object.keys(lType.properties),\n Object.keys(rType.properties),\n (lKey, rKey) => {\n const comp = diffCompare(lKey, rKey)\n switch (comp) {\n case DiffCompare.LeftMissing: {\n diff[rKey] = {\n lhs: '',\n rhs: rType.properties[rKey].summary(),\n }\n break\n }\n case DiffCompare.RightMissing: {\n diff[lKey] = {\n lhs: lType.properties[lKey].summary(),\n rhs: '',\n }\n break\n }\n default: {\n const lhsVal = lType.properties[lKey]\n const rhsVal = rType.properties[rKey]\n const lhs = lhsVal.summary()\n const rhs = rhsVal.summary()\n if (lhs !== rhs) {\n count.changed++\n diff[lKey] = {\n lhs,\n rhs,\n }\n }\n }\n }\n return comp\n }\n )\n if (Object.keys(diff).length === 0) return\n return diff\n}\n\n/**\n * Compares the params of two methods and returns the signature of both methods\n * if non matching.\n * @param lMethod\n * @param rMethod\n * @param count change tracking\n */\nexport const compareParams = (\n lMethod: IMethod,\n rMethod: IMethod,\n count: DiffCount\n) => {\n const lParams = {}\n const rParams = {}\n lMethod.allParams.forEach((p) => (lParams[p.name] = p))\n rMethod.allParams.forEach((p) => (rParams[p.name] = p))\n // TODO typediff the matching body types?\n countDiffs(\n count,\n Object.keys(lParams),\n Object.keys(rParams),\n (lKey, rKey) => {\n const comp = diffCompare(lKey, rKey)\n if (comp === 0) {\n const lsh = lParams[lKey].signature()\n const rsh = rParams[rKey].signature()\n if (lsh !== rsh) {\n count.changed++\n }\n }\n return comp\n }\n )\n\n const lSignature = lMethod.signature()\n const rSignature = rMethod.signature()\n if (lSignature === rSignature) return\n\n return {\n lhs: lSignature,\n rhs: rSignature,\n }\n}\n\n/**\n * Compares the bodies of two methods and returns diffs if there are any\n * @param lMethod\n * @param rMethod\n * @param count change tracking\n */\nexport const compareBodies = (\n lMethod: IMethod,\n rMethod: IMethod,\n count: DiffCount\n) => {\n const lParams = {}\n const rParams = {}\n lMethod.bodyParams.forEach((p) => (lParams[p.name] = p))\n rMethod.bodyParams.forEach((p) => (rParams[p.name] = p))\n // TODO typediff the matching body types?\n countDiffs(count, Object.keys(lParams), Object.keys(rParams))\n\n const lSide = lMethod.bodyParams.map((p) => {\n return {\n name: p.name,\n type: p.type.fullName,\n required: p.required,\n }\n })\n const rSide = rMethod.bodyParams.map((p) => {\n return {\n name: p.name,\n type: p.type.fullName,\n required: p.required,\n }\n })\n\n if (JSON.stringify(lSide) === JSON.stringify(rSide)) return\n\n count.changed++\n return {\n lhs: lSide,\n rhs: rSide,\n }\n}\n\n/**\n * Compare two response lists, returning diff\n * @param lMethod\n * @param rMethod\n * @param count change tracking\n */\nexport const compareResponses = (\n lMethod: IMethod,\n rMethod: IMethod,\n count: DiffCount\n) => {\n // TODO deep type comparison? Probably diff all types instead\n const lSide = lMethod.responses.map((r) => {\n return {\n statusCode: r.statusCode,\n mediaType: r.mediaType,\n type: r.type.fullName,\n }\n })\n const rSide = rMethod.responses.map((r) => {\n return {\n statusCode: r.statusCode,\n mediaType: r.mediaType,\n type: r.type.fullName,\n }\n })\n if (JSON.stringify(lSide) === JSON.stringify(rSide)) return\n\n count.changed++\n return {\n lhs: lSide,\n rhs: rSide,\n }\n}\n\nexport const csvHeaderRow =\n 'method name,\"Op + URI\",left status,right status,typeDiff,paramDiff,bodyDiff,responseDiff,diffCount'\n\nexport const csvDiffRow = (diff: DiffRow) => {\n const diffCount = JSON.stringify(diff.diffCount).replace(/\"/g, `'`)\n return `\n${diff.name},${diff.id},${diff.lStatus},${diff.rStatus},${diff.typeDiff},${diff.paramsDiff},${diff.bodyDiff},${diff.responseDiff},\"${diffCount}\"`\n}\n\nexport const mdHeaderRow = `\n| method name | Op + URI | 3.1 | 4.0 | typeDiff | paramDiff | bodyDiff | responseDiff | diffCount |\n| ------------ | -------- | --- | --- | ------------ | --------- | -------- | ------------ | --------- |`\n\nexport const mdDiffRow = (diff: DiffRow) => `\n| ${diff.name} | ${diff.id} | ${diff.lStatus} | ${diff.rStatus} | ${\n diff.typeDiff\n} | ${diff.paramsDiff} | ${diff.bodyDiff} | ${\n diff.responseDiff\n} | ${JSON.stringify(diff.diffCount)} |`\n\nconst diffToString = (diff: any) => {\n if (!diff) return ''\n const result = JSON.stringify(diff, null, 2)\n if (result === '{}') return ''\n return `\"${result.replace(/\"/g, \"'\")}\"`\n}\n\nexport interface ComputeDiffInputs {\n lMethod?: IMethod\n rMethod?: IMethod\n}\n\nexport interface DiffRow {\n /** Method name */\n name: string\n /** Method operation and path */\n id: string\n /** Method status in both specs */\n lStatus: string\n rStatus: string\n /** Method type diff if any */\n typeDiff: string\n /** Method params diff if any */\n paramsDiff: string\n /** Body diff if any */\n bodyDiff: string\n /** Response diff if any */\n responseDiff: string\n /** Count of differences */\n diffCount: DiffCount\n}\n\n/**\n * Computes the diff of two methods\n * @param lMethod\n * @param rMethod\n */\nconst computeDiff = (lMethod?: IMethod, rMethod?: IMethod) => {\n if (!lMethod && !rMethod) throw new Error('At least one method is required.')\n\n const count = startCount()\n const countStatus = () => {\n if (!rMethod) {\n count.removed++\n } else if (!lMethod) {\n count.added++\n } else {\n if (lMethod.status !== rMethod.status) count.changed++\n }\n }\n\n let result: DiffRow\n countStatus()\n if (lMethod) {\n const typeDiff = rMethod\n ? diffToString(compareTypes(lMethod.type, rMethod.type, count))\n : ''\n const paramsDiff = rMethod\n ? diffToString(compareParams(lMethod, rMethod, count))\n : ''\n const bodyDiff = rMethod\n ? diffToString(compareBodies(lMethod, rMethod, count))\n : ''\n const responseDiff = rMethod\n ? diffToString(compareResponses(lMethod, rMethod, count))\n : ''\n result = {\n name: lMethod.name,\n id: lMethod.id,\n lStatus: lMethod.status,\n rStatus: rMethod ? rMethod.status : '',\n typeDiff,\n paramsDiff,\n bodyDiff,\n responseDiff,\n diffCount: count,\n }\n } else if (!lMethod && rMethod) {\n result = {\n name: rMethod.name,\n id: rMethod.id,\n lStatus: '',\n rStatus: rMethod.status,\n typeDiff: '',\n paramsDiff: '',\n bodyDiff: '',\n responseDiff: '',\n diffCount: count,\n }\n }\n\n return result!\n}\n\nexport type DiffFilter = (\n delta: DiffRow,\n lMethod?: IMethod,\n rMethod?: IMethod\n) => boolean\n\n/**\n * Include when:\n * - lMethod is missing\n * - rMethod is missing\n * - params differ\n * - types differ\n * @param delta\n * @param lMethod\n * @param rMethod\n */\nexport const includeDiffs: DiffFilter = (delta, lMethod, rMethod) =>\n !lMethod ||\n !rMethod! ||\n delta.lStatus !== delta.rStatus ||\n !!delta.paramsDiff ||\n !!delta.typeDiff ||\n !!delta.bodyDiff ||\n !!delta.responseDiff\n\n/**\n * Compares two specs and returns a diff object\n * @param lSpec left-side spec\n * @param rSpec right-side spec\n * @param include evaluates to true if the comparison should be included\n */\nexport const compareSpecs = (\n lSpec: IApiModel,\n rSpec: IApiModel,\n include: DiffFilter = includeDiffs\n) => {\n const specSort = (a: IMethod, b: IMethod) => a.id.localeCompare(b.id)\n\n const lMethods = Object.values(lSpec.methods).sort(specSort)\n const rMethods = Object.values(rSpec.methods).sort(specSort)\n\n const lLength = lMethods.length\n const rLength = rMethods.length\n let lIndex = 0\n let rIndex = 0\n const diff: DiffRow[] = []\n\n while (lIndex < lLength || rIndex < rLength) {\n let lMethod: IMethod | undefined = lMethods[lIndex]\n let rMethod: IMethod | undefined = rMethods[rIndex]\n\n if (!lMethod) {\n rIndex++\n } else if (!rMethod) {\n lIndex++\n } else if (lMethod.id < rMethod.id) {\n rMethod = undefined\n lIndex++\n } else if (rMethod.id < lMethod.id) {\n lMethod = undefined\n rIndex++\n } else {\n lIndex++\n rIndex++\n }\n\n const delta = computeDiff(lMethod, rMethod)\n if (include(delta, lMethod, rMethod)) {\n diff.push(delta)\n }\n }\n return diff\n}\n"],"file":"specDiff.js"}
@@ -397,7 +397,6 @@ export interface IApiModel extends IModel {
397
397
  }
398
398
  export declare class ApiModel implements ISymbolTable, IApiModel {
399
399
  readonly spec: OAS.OpenAPIObject;
400
- private requestTypes;
401
400
  private enumTypes;
402
401
  private refs;
403
402
  methods: MethodList;
@@ -417,13 +416,14 @@ export declare class ApiModel implements ISymbolTable, IApiModel {
417
416
  jsonPath(path: string | string[], item?: any, splitter?: string): any;
418
417
  private schemaHasEnums;
419
418
  resolveType(schema: string | OAS.SchemaObject | OAS.ReferenceObject, style?: string, typeName?: string, methodName?: string): IType;
420
- makeRequestType(hash: string, method: IMethod): RequestType;
419
+ private requestTypeName;
420
+ makeRequestType(method: IMethod): RequestType;
421
421
  registerEnum(type: IType, methodName?: string): IType;
422
422
  private _getRequestType;
423
423
  getRequestType(method: IMethod): IType | undefined;
424
424
  getEnumList(): TypeList;
425
- makeWriteableType(hash: string, type: IType): WriteType;
426
- mayGetWriteableType(type: IType): IType | WriteType | undefined;
425
+ makeWriteableType(type: IType): WriteType;
426
+ mayGetWriteableType(type: IType): WriteType | undefined;
427
427
  loadDynamicTypes(): void;
428
428
  sortList<T>(list: KeyedCollection<T>): KeyedCollection<T>;
429
429
  sortLists(): void;
package/lib/sdkModels.js CHANGED
@@ -1371,8 +1371,6 @@ class ApiModel {
1371
1371
  constructor(spec) {
1372
1372
  this.spec = spec;
1373
1373
 
1374
- _defineProperty(this, "requestTypes", {});
1375
-
1376
1374
  _defineProperty(this, "enumTypes", {});
1377
1375
 
1378
1376
  _defineProperty(this, "refs", {});
@@ -1603,11 +1601,14 @@ class ApiModel {
1603
1601
  throw new Error("Schema ".concat(typeof schema === 'string' ? schema : JSON.stringify(schema), " must have a ref or a type"));
1604
1602
  }
1605
1603
 
1606
- makeRequestType(hash, method) {
1607
- var name = "".concat(strRequest).concat(camelCase('_' + method.name));
1604
+ requestTypeName(method) {
1605
+ return "".concat(strRequest).concat(camelCase('_' + method.name));
1606
+ }
1607
+
1608
+ makeRequestType(method) {
1609
+ var name = this.requestTypeName(method);
1608
1610
  var request = new RequestType(this, name, method.allParams, "Dynamically generated request type for ".concat(method.name));
1609
1611
  this.types[name] = request;
1610
- this.requestTypes[hash] = request;
1611
1612
  method.addType(this, request);
1612
1613
  return request;
1613
1614
  }
@@ -1640,11 +1641,8 @@ class ApiModel {
1640
1641
 
1641
1642
  _getRequestType(method) {
1642
1643
  if (method.optionalParams.length <= 1) return undefined;
1643
- var paramHash = '';
1644
- method.allParams.forEach(p => paramHash += p.asHashString());
1645
- var hash = (0, _blueimpMd.default)(paramHash);
1646
- var result = this.requestTypes[hash];
1647
- if (!result) result = this.makeRequestType(hash, method);
1644
+ var result = this.types[this.requestTypeName(method)];
1645
+ if (!result) result = this.makeRequestType(method);
1648
1646
  return result;
1649
1647
  }
1650
1648
 
@@ -1659,10 +1657,9 @@ class ApiModel {
1659
1657
  return this.enumTypes;
1660
1658
  }
1661
1659
 
1662
- makeWriteableType(hash, type) {
1660
+ makeWriteableType(type) {
1663
1661
  var writer = new WriteType(this, type);
1664
1662
  this.types[writer.name] = writer;
1665
- this.requestTypes[hash] = writer;
1666
1663
  return writer;
1667
1664
  }
1668
1665
 
@@ -1692,10 +1689,7 @@ class ApiModel {
1692
1689
  }
1693
1690
 
1694
1691
  if (writes.length === props.length && JSON.stringify(writes) === JSON.stringify(props)) return undefined;
1695
- var hash = (0, _blueimpMd.default)(type.asHashString());
1696
- var result = this.requestTypes[hash];
1697
- if (result) return result;
1698
- result = this.makeWriteableType(hash, type);
1692
+ var result = this.makeWriteableType(type);
1699
1693
  type.types.add(result.name);
1700
1694
  type.customTypes.add(result.name);
1701
1695
  result.parentTypes.add(type.name);