@looker/sdk-codegen-scripts 21.4.8 → 21.5.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.
- package/CHANGELOG.md +25 -1
- package/lib/convert.js +0 -10
- package/lib/convert.js.map +1 -1
- package/lib/declarationMiner.js +11 -37
- package/lib/declarationMiner.js.map +1 -1
- package/lib/esm/convert.js +20 -18
- package/lib/esm/convert.js.map +1 -1
- package/lib/esm/declarationMiner.js +32 -41
- package/lib/esm/declarationMiner.js.map +1 -1
- package/lib/esm/exampleMiner.js +52 -77
- package/lib/esm/exampleMiner.js.map +1 -1
- package/lib/esm/fetchSpec.js +65 -83
- package/lib/esm/fetchSpec.js.map +1 -1
- package/lib/esm/index.js +93 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/languages.js +16 -11
- package/lib/esm/languages.js.map +1 -1
- package/lib/esm/legacy.js +8 -9
- package/lib/esm/legacy.js.map +1 -1
- package/lib/esm/legacyGenerator.js +19 -22
- package/lib/esm/legacyGenerator.js.map +1 -1
- package/lib/esm/nodeUtils.js +39 -22
- package/lib/esm/nodeUtils.js.map +1 -1
- package/lib/esm/prettify.js +15 -9
- package/lib/esm/prettify.js.map +1 -1
- package/lib/esm/reformatter.js +53 -102
- package/lib/esm/reformatter.js.map +1 -1
- package/lib/esm/sdkConfig.js +19 -13
- package/lib/esm/sdkConfig.js.map +1 -1
- package/lib/esm/sdkGen.js +43 -59
- package/lib/esm/sdkGen.js.map +1 -1
- package/lib/esm/sdkGenerator.js +34 -47
- package/lib/esm/sdkGenerator.js.map +1 -1
- package/lib/esm/specConvert.js +20 -27
- package/lib/esm/specConvert.js.map +1 -1
- package/lib/esm/testUtils/index.js +28 -0
- package/lib/esm/testUtils/index.js.map +1 -0
- package/lib/esm/testUtils/mocks.js +16 -0
- package/lib/esm/testUtils/mocks.js.map +1 -0
- package/lib/esm/testUtils/testUtils.js +66 -0
- package/lib/esm/testUtils/testUtils.js.map +1 -0
- package/lib/esm/utils.js +43 -60
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/yamlToJson.js +8 -6
- package/lib/esm/yamlToJson.js.map +1 -1
- package/lib/exampleMiner.js +4 -89
- package/lib/exampleMiner.js.map +1 -1
- package/lib/fetchSpec.js +6 -76
- package/lib/fetchSpec.js.map +1 -1
- package/lib/index.js +0 -16
- package/lib/index.js.map +1 -1
- package/lib/languages.js +0 -11
- package/lib/languages.js.map +1 -1
- package/lib/legacy.js +0 -5
- package/lib/legacy.js.map +1 -1
- package/lib/legacyGenerator.js +0 -15
- package/lib/legacyGenerator.js.map +1 -1
- package/lib/nodeUtils.js +1 -34
- package/lib/nodeUtils.js.map +1 -1
- package/lib/prettify.js +5 -14
- package/lib/prettify.js.map +1 -1
- package/lib/reformatter.js +3 -70
- package/lib/reformatter.js.map +1 -1
- package/lib/sdkConfig.js +0 -16
- package/lib/sdkConfig.js.map +1 -1
- package/lib/sdkGen.js +0 -41
- package/lib/sdkGen.js.map +1 -1
- package/lib/sdkGenerator.js +4 -52
- package/lib/sdkGenerator.js.map +1 -1
- package/lib/specConvert.js +0 -19
- package/lib/specConvert.js.map +1 -1
- package/lib/testUtils/index.js +0 -4
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/mocks.js +0 -4
- package/lib/testUtils/mocks.js.map +1 -1
- package/lib/testUtils/testUtils.js +1 -17
- package/lib/testUtils/testUtils.js.map +1 -1
- package/lib/utils.js +6 -48
- package/lib/utils.js.map +1 -1
- package/lib/yamlToJson.js +0 -7
- package/lib/yamlToJson.js.map +1 -1
- package/package.json +6 -6
package/lib/reformatter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reformatter.ts"],"names":["writeFile","fileName","content","fs","writeFileSync","utf8Encoding","noFormatter","language","files","list","join","fullPath","weirdPath","path","resolve","BaseFormatter","constructor","fileSep","reformat","skipping","reformatted","PythonFormatter","pipEnvExists","instructions","includes","versionStamp","gen","versions","lookerVersion","stampFile","sdkVersionPattern","envPattern","replace","environmentPrefix","TypescriptFormatter","forEach","f","reformatFile","source","KotlinFormatter","lookerPattern","apiPattern","spec","version","SwiftFormatter","CsharpFormatter","GoFormatter","gofmtExists","fileFormatters","FilesFormatter","addFile","key","extname","push","clear","Object","entries","formatter","fileExtension"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;AAgBA,IAAMA,SAAS,GAAG,CAACC,QAAD,EAAmBC,OAAnB,KAAuC;AACvDC,EAAAA,EAAE,CAACC,aAAH,CAAiBH,QAAjB,EAA2BC,OAA3B,EAAoCG,uBAApC;AACD,CAFD;;AAIA,IAAMC,WAAW,GAAG,CAACC,QAAD,EAAmBC,KAAnB,KAAuC;AACzD,MAAMC,IAAI,GAAGD,KAAK,CAACE,IAAN,CAAW,MAAX,CAAb;AACA,SAAO,iDACUH,QADV,qDAC6DE,IAD7D,EAAP;AAGD,CALD;;AAOA,IAAME,QAAQ,GAAIC,SAAD,IAAuBC,IAAI,CAACC,OAAL,CAAaF,SAAb,CAAxC;;AAEA,MAAeG,aAAf,CAAkD;AAChDC,EAAAA,WAAW,CAAQT,QAAR,EAAmD;AAAA,QAAlBU,OAAkB;AAAA,SAA3CV,QAA2C,GAA3CA,QAA2C;AAAA,SAAlBU,OAAkB,GAAlBA,OAAkB;AAAE;;AAChEC,EAAAA,QAAQ,CAACV,KAAD,EAA0B;AAChC,WAAOF,WAAW,CAAC,KAAKC,QAAN,EAAgBC,KAAhB,CAAlB;AACD;;AAIDW,EAAAA,QAAQ,GAAG;AACT,WAAO,qFAC8C,KAAKZ,QADnD,4BAAP;AAGD;;AAEDa,EAAAA,WAAW,CAACZ,KAAD,EAAkB;AAC3B,WAAO,oDACU,KAAKD,QADf,wBACqCC,KAAK,CAACE,IAAN,CAAW,KAAKO,OAAhB,CADrC,EAAP;AAGD;;AAlB+C;;AAqBlD,MAAMI,eAAN,SAA8BN,aAA9B,CAA4C;AAC1CC,EAAAA,WAAW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A,MAAM,CAACC,OAAP,CAAe,KAAKhD,KAApB,EAA2B2B,OAA3B,CAAmC,QAAiB;AAAA,UAAhB,CAACgB,GAAD,EAAM1C,IAAN,CAAgB;;AAClD,UAAI0C,GAAG,IAAIH,cAAX,EAA2B;AACzBA,QAAAA,cAAc,CAACG,GAAD,CAAd,CAAoBjC,QAApB,CAA6BT,IAA7B;AACD;AACF,KAJD;AAKD;;AAEDgB,EAAAA,YAAY,CAACC,GAAD,EAAgB;AAC1B,QAAM+B,SAAS,GAAGT,cAAc,CAACtB,GAAG,CAACgC,aAAL,CAAhC;AACA,WAAOD,SAAS,CAAChC,YAAV,CAAuBC,GAAvB,CAAP;AACD;;AA5ByB","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 * as path from 'path'\nimport * as fs from 'fs'\nimport { danger, success, warn } from '@looker/sdk-codegen-utils'\nimport type { ICodeGen } from '@looker/sdk-codegen'\nimport { isFileSync, readFileSync, run, utf8Encoding } from './nodeUtils'\nimport { prettify } from './prettify'\n\nexport interface IReformat {\n fileSep: string\n language: string\n reformat(files: string[]): string\n versionStamp(gen: ICodeGen): string\n skipping(): string\n reformatted(files: string[]): string\n}\n\n/**\n * wrapper function for writing reformatted files with utf-8 encoding synchronously\n * @param {string} fileName name of file to write\n * @param {string} content content to write\n */\nconst writeFile = (fileName: string, content: string) => {\n fs.writeFileSync(fileName, content, utf8Encoding)\n}\n\nconst noFormatter = (language: string, files: string[]) => {\n const list = files.join('\\n ')\n return warn(\n `There is no ${language} formatter. Skipped reformatting of:\\n ${list}`\n )\n}\n\nconst fullPath = (weirdPath: string) => path.resolve(weirdPath)\n\nabstract class BaseFormatter implements IReformat {\n constructor(public language: string, public fileSep = ` \\n`) {}\n reformat(files: string[]): string {\n return noFormatter(this.language, files)\n }\n\n abstract versionStamp(gen: ICodeGen): string\n\n skipping() {\n return warn(\n `Version information was not retrieved. Skipping ${this.language} SDK version updating.`\n )\n }\n\n reformatted(files: string[]) {\n return success(\n `Reformatted ${this.language} files:\\n ${files.join(this.fileSep)}`\n )\n }\n}\n\nclass PythonFormatter extends BaseFormatter {\n constructor() {\n super('Python')\n }\n\n instructions =\n 'To reformat Python files, please install pipenv: https://docs.pipenv.org/en/latest/install/#installing-pipenv'\n\n reformat(files: string[]): string {\n const pipEnvExists = run(\n 'command',\n ['-v', 'pipenv'],\n this.instructions,\n true\n )\n if (pipEnvExists.includes('pipenv')) {\n const list = files.join(' ')\n // pipenv check completed without error\n run('pipenv', ['run', 'black', list], 'Python reformat', true)\n return success(files)\n } else {\n return danger(this.instructions)\n }\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('sdk/constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const sdkVersionPattern = /sdk_version = ['\"].*['\"]/i\n const envPattern = /environment_prefix = ['\"].*['\"]/i\n content = content.replace(\n sdkVersionPattern,\n `sdk_version = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n envPattern,\n `environment_prefix = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(`updated ${stampFile} to ${gen.versions.lookerVersion}`)\n }\n\n return this.skipping()\n }\n}\n\nclass TypescriptFormatter extends BaseFormatter {\n constructor() {\n super('TypeScript')\n }\n\n reformat(files: string[]): string {\n files.forEach((f) => {\n this.reformatFile(f)\n })\n return success(files)\n }\n\n reformatFile(fileName: string) {\n const source = prettify(readFileSync(fileName))\n if (source) {\n writeFile(fileName, source)\n }\n return fileName\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('../../sdk/src/constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const sdkVersionPattern = /sdkVersion = ['\"].*['\"]/i\n const envPattern = /environmentPrefix = ['\"].*['\"]/i\n content = content.replace(\n sdkVersionPattern,\n `sdkVersion = '${gen.versions.lookerVersion}'`\n )\n content = content.replace(\n envPattern,\n `environmentPrefix = '${gen.environmentPrefix}'`\n )\n writeFile(stampFile, content)\n return success(`updated ${stampFile} to ${gen.versions.lookerVersion}`)\n }\n\n return this.skipping()\n }\n}\n\nclass KotlinFormatter extends BaseFormatter {\n // TODO Kotlin formatter\n constructor() {\n super('Kotlin')\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('sdk/Constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const lookerPattern = /\\bLOOKER_VERSION = ['\"].*['\"]/i\n const apiPattern = /\\bAPI_VERSION = ['\"].*['\"]/i\n const envPattern = /\\bENVIRONMENT_PREFIX = ['\"].*['\"]/i\n content = content.replace(\n lookerPattern,\n `LOOKER_VERSION = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n apiPattern,\n `API_VERSION = \"${gen.versions.spec.version}\"`\n )\n content = content.replace(\n envPattern,\n `ENVIRONMENT_PREFIX = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(\n `updated ${stampFile} to ${gen.versions.spec.version}.${gen.versions.lookerVersion}`\n )\n }\n return this.skipping()\n }\n}\n\nclass SwiftFormatter extends BaseFormatter {\n // TODO Swift formatter\n constructor() {\n super('Swift')\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('rtl/constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const lookerPattern = /lookerVersion = ['\"].*['\"]/i\n const apiPattern = /apiVersion = ['\"].*['\"]/i\n const envPattern = /environmentPrefix = ['\"].*['\"]/i\n content = content.replace(\n lookerPattern,\n `lookerVersion = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n apiPattern,\n `apiVersion = \"${gen.versions.spec.version}\"`\n )\n content = content.replace(\n envPattern,\n `environmentPrefix = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(\n `updated ${stampFile} to ${gen.versions.spec.version}.${gen.versions.lookerVersion}`\n )\n }\n return this.skipping()\n }\n}\n\nclass CsharpFormatter extends BaseFormatter {\n // TODO C# formatter https://github.com/dotnet/format\n constructor() {\n super('C#')\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('rtl/Constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const lookerPattern = /LookerVersion = ['\"].*['\"]/i\n const apiPattern = /ApiVersion = ['\"].*['\"]/i\n const envPattern = /EnvironmentPrefix = ['\"].*['\"]/i\n content = content.replace(\n lookerPattern,\n `LookerVersion = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n apiPattern,\n `ApiVersion = \"${gen.versions.spec.version}\"`\n )\n content = content.replace(\n envPattern,\n `EnvironmentPrefix = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(\n `updated ${stampFile} to ${gen.versions.spec.version}.${gen.versions.lookerVersion}`\n )\n }\n return this.skipping()\n }\n}\n\nclass GoFormatter extends BaseFormatter {\n // TODO Go formatter\n constructor() {\n super('Go')\n }\n\n instructions =\n 'To reformat Go files, please install gofmt: https://go.dev/blog/gofmt'\n\n reformat(files: string[]): string {\n const gofmtExists = run('command', ['-v', 'gofmt'], this.instructions, true)\n if (gofmtExists.includes('gofmt')) {\n const list = files.join(' ')\n // gofmt check completed without error\n run('gofmt', ['-w', list], 'Go reformat', true)\n return success(files)\n } else {\n return danger(this.instructions)\n }\n }\n\n versionStamp() {\n return warn('Skipping SDK version updating - not implemented for Go.')\n }\n}\n\ntype IFormatFiles = { [key: string]: string[] }\n\ntype IFormatters = { [key: string]: IReformat }\n\nconst fileFormatters: IFormatters = {\n '.cs': new CsharpFormatter(),\n '.kt': new KotlinFormatter(),\n '.py': new PythonFormatter(),\n '.swift': new SwiftFormatter(),\n '.ts': new TypescriptFormatter(),\n '.go': new GoFormatter(),\n}\n\nexport class FilesFormatter {\n files: IFormatFiles = {}\n\n addFile(fileName: string) {\n const key = path.extname(fileName)\n if (key in this.files) {\n this.files[key].push(fileName)\n } else {\n this.files[key] = [fileName]\n }\n }\n\n clear() {\n this.files = {}\n }\n\n reformat(files?: string[]) {\n if (files) files.forEach((f) => this.addFile(f))\n Object.entries(this.files).forEach(([key, list]) => {\n if (key in fileFormatters) {\n fileFormatters[key].reformat(list)\n }\n })\n }\n\n versionStamp(gen: ICodeGen) {\n const formatter = fileFormatters[gen.fileExtension]\n return formatter.versionStamp(gen)\n }\n}\n"],"file":"reformatter.js"}
|
|
1
|
+
{"version":3,"file":"reformatter.js","names":["writeFile","fileName","content","fs","writeFileSync","utf8Encoding","noFormatter","language","files","list","join","warn","fullPath","weirdPath","path","resolve","BaseFormatter","constructor","fileSep","reformat","skipping","reformatted","success","PythonFormatter","pipEnvExists","run","instructions","includes","danger","versionStamp","gen","versions","lookerVersion","stampFile","isFileSync","readFileSync","sdkVersionPattern","envPattern","replace","environmentPrefix","TypescriptFormatter","forEach","f","reformatFile","source","prettify","KotlinFormatter","lookerPattern","apiPattern","spec","version","SwiftFormatter","CsharpFormatter","GoFormatter","gofmtExists","fileFormatters","FilesFormatter","addFile","key","extname","push","clear","Object","entries","formatter","fileExtension"],"sources":["../src/reformatter.ts"],"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 * as path from 'path'\nimport * as fs from 'fs'\nimport { danger, success, warn } from '@looker/sdk-codegen-utils'\nimport type { ICodeGen } from '@looker/sdk-codegen'\nimport { isFileSync, readFileSync, run, utf8Encoding } from './nodeUtils'\nimport { prettify } from './prettify'\n\nexport interface IReformat {\n fileSep: string\n language: string\n reformat(files: string[]): string\n versionStamp(gen: ICodeGen): string\n skipping(): string\n reformatted(files: string[]): string\n}\n\n/**\n * wrapper function for writing reformatted files with utf-8 encoding synchronously\n * @param {string} fileName name of file to write\n * @param {string} content content to write\n */\nconst writeFile = (fileName: string, content: string) => {\n fs.writeFileSync(fileName, content, utf8Encoding)\n}\n\nconst noFormatter = (language: string, files: string[]) => {\n const list = files.join('\\n ')\n return warn(\n `There is no ${language} formatter. Skipped reformatting of:\\n ${list}`\n )\n}\n\nconst fullPath = (weirdPath: string) => path.resolve(weirdPath)\n\nabstract class BaseFormatter implements IReformat {\n constructor(public language: string, public fileSep = ` \\n`) {}\n reformat(files: string[]): string {\n return noFormatter(this.language, files)\n }\n\n abstract versionStamp(gen: ICodeGen): string\n\n skipping() {\n return warn(\n `Version information was not retrieved. Skipping ${this.language} SDK version updating.`\n )\n }\n\n reformatted(files: string[]) {\n return success(\n `Reformatted ${this.language} files:\\n ${files.join(this.fileSep)}`\n )\n }\n}\n\nclass PythonFormatter extends BaseFormatter {\n constructor() {\n super('Python')\n }\n\n instructions =\n 'To reformat Python files, please install pipenv: https://docs.pipenv.org/en/latest/install/#installing-pipenv'\n\n reformat(files: string[]): string {\n const pipEnvExists = run(\n 'command',\n ['-v', 'pipenv'],\n this.instructions,\n true\n )\n if (pipEnvExists.includes('pipenv')) {\n const list = files.join(' ')\n // pipenv check completed without error\n run('pipenv', ['run', 'black', list], 'Python reformat', true)\n return success(files)\n } else {\n return danger(this.instructions)\n }\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('sdk/constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const sdkVersionPattern = /sdk_version = ['\"].*['\"]/i\n const envPattern = /environment_prefix = ['\"].*['\"]/i\n content = content.replace(\n sdkVersionPattern,\n `sdk_version = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n envPattern,\n `environment_prefix = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(`updated ${stampFile} to ${gen.versions.lookerVersion}`)\n }\n\n return this.skipping()\n }\n}\n\nclass TypescriptFormatter extends BaseFormatter {\n constructor() {\n super('TypeScript')\n }\n\n reformat(files: string[]): string {\n files.forEach((f) => {\n this.reformatFile(f)\n })\n return success(files)\n }\n\n reformatFile(fileName: string) {\n const source = prettify(readFileSync(fileName))\n if (source) {\n writeFile(fileName, source)\n }\n return fileName\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('../../sdk/src/constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const sdkVersionPattern = /sdkVersion = ['\"].*['\"]/i\n const envPattern = /environmentPrefix = ['\"].*['\"]/i\n content = content.replace(\n sdkVersionPattern,\n `sdkVersion = '${gen.versions.lookerVersion}'`\n )\n content = content.replace(\n envPattern,\n `environmentPrefix = '${gen.environmentPrefix}'`\n )\n writeFile(stampFile, content)\n return success(`updated ${stampFile} to ${gen.versions.lookerVersion}`)\n }\n\n return this.skipping()\n }\n}\n\nclass KotlinFormatter extends BaseFormatter {\n // TODO Kotlin formatter\n constructor() {\n super('Kotlin')\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('sdk/Constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const lookerPattern = /\\bLOOKER_VERSION = ['\"].*['\"]/i\n const apiPattern = /\\bAPI_VERSION = ['\"].*['\"]/i\n const envPattern = /\\bENVIRONMENT_PREFIX = ['\"].*['\"]/i\n content = content.replace(\n lookerPattern,\n `LOOKER_VERSION = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n apiPattern,\n `API_VERSION = \"${gen.versions.spec.version}\"`\n )\n content = content.replace(\n envPattern,\n `ENVIRONMENT_PREFIX = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(\n `updated ${stampFile} to ${gen.versions.spec.version}.${gen.versions.lookerVersion}`\n )\n }\n return this.skipping()\n }\n}\n\nclass SwiftFormatter extends BaseFormatter {\n // TODO Swift formatter\n constructor() {\n super('Swift')\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('rtl/constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const lookerPattern = /lookerVersion = ['\"].*['\"]/i\n const apiPattern = /apiVersion = ['\"].*['\"]/i\n const envPattern = /environmentPrefix = ['\"].*['\"]/i\n content = content.replace(\n lookerPattern,\n `lookerVersion = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n apiPattern,\n `apiVersion = \"${gen.versions.spec.version}\"`\n )\n content = content.replace(\n envPattern,\n `environmentPrefix = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(\n `updated ${stampFile} to ${gen.versions.spec.version}.${gen.versions.lookerVersion}`\n )\n }\n return this.skipping()\n }\n}\n\nclass CsharpFormatter extends BaseFormatter {\n // TODO C# formatter https://github.com/dotnet/format\n constructor() {\n super('C#')\n }\n\n versionStamp(gen: ICodeGen) {\n if (gen.versions && gen.versions.lookerVersion) {\n const stampFile = fullPath(gen.fileName('rtl/Constants'))\n if (!isFileSync(stampFile)) {\n warn(`${stampFile} was not found. Skipping version update.`)\n }\n let content = readFileSync(stampFile)\n const lookerPattern = /LookerVersion = ['\"].*['\"]/i\n const apiPattern = /ApiVersion = ['\"].*['\"]/i\n const envPattern = /EnvironmentPrefix = ['\"].*['\"]/i\n content = content.replace(\n lookerPattern,\n `LookerVersion = \"${gen.versions.lookerVersion}\"`\n )\n content = content.replace(\n apiPattern,\n `ApiVersion = \"${gen.versions.spec.version}\"`\n )\n content = content.replace(\n envPattern,\n `EnvironmentPrefix = \"${gen.environmentPrefix}\"`\n )\n writeFile(stampFile, content)\n return success(\n `updated ${stampFile} to ${gen.versions.spec.version}.${gen.versions.lookerVersion}`\n )\n }\n return this.skipping()\n }\n}\n\nclass GoFormatter extends BaseFormatter {\n // TODO Go formatter\n constructor() {\n super('Go')\n }\n\n instructions =\n 'To reformat Go files, please install gofmt: https://go.dev/blog/gofmt'\n\n reformat(files: string[]): string {\n const gofmtExists = run('command', ['-v', 'gofmt'], this.instructions, true)\n if (gofmtExists.includes('gofmt')) {\n const list = files.join(' ')\n // gofmt check completed without error\n run('gofmt', ['-w', list], 'Go reformat', true)\n return success(files)\n } else {\n return danger(this.instructions)\n }\n }\n\n versionStamp() {\n return warn('Skipping SDK version updating - not implemented for Go.')\n }\n}\n\ntype IFormatFiles = { [key: string]: string[] }\n\ntype IFormatters = { [key: string]: IReformat }\n\nconst fileFormatters: IFormatters = {\n '.cs': new CsharpFormatter(),\n '.kt': new KotlinFormatter(),\n '.py': new PythonFormatter(),\n '.swift': new SwiftFormatter(),\n '.ts': new TypescriptFormatter(),\n '.go': new GoFormatter(),\n}\n\nexport class FilesFormatter {\n files: IFormatFiles = {}\n\n addFile(fileName: string) {\n const key = path.extname(fileName)\n if (key in this.files) {\n this.files[key].push(fileName)\n } else {\n this.files[key] = [fileName]\n }\n }\n\n clear() {\n this.files = {}\n }\n\n reformat(files?: string[]) {\n if (files) files.forEach((f) => this.addFile(f))\n Object.entries(this.files).forEach(([key, list]) => {\n if (key in fileFormatters) {\n fileFormatters[key].reformat(list)\n }\n })\n }\n\n versionStamp(gen: ICodeGen) {\n const formatter = fileFormatters[gen.fileExtension]\n return formatter.versionStamp(gen)\n }\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AAEA;AACA;AAAqC;AAAA;AAAA;AAAA;AAAA;AAgBrC,IAAMA,SAA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IAChDoB,MAAM,CAACC,OAAO,CAAC,IAAI,CAACvD,KAAK,CAAC,CAACiC,OAAO,CAAC,QAAiB;MAAA,IAAhB,CAACiB,GAAG,EAAEjD,IAAI,CAAC;MAC7C,IAAIiD,GAAG,IAAIH,cAAc,EAAE;QACzBA,cAAc,CAACG,GAAG,CAAC,CAACvC,QAAQ,CAACV,IAAI,CAAC;MACpC;IACF,CAAC,CAAC;EACJ;EAEAoB,YAAY,CAACC,GAAa,EAAE;IAC1B,IAAMkC,SAAS,GAAGT,cAAc,CAACzB,GAAG,CAACmC,aAAa,CAAC;IACnD,OAAOD,SAAS,CAACnC,YAAY,CAACC,GAAG,CAAC;EACpC;AACF;AAAC"}
|
package/lib/sdkConfig.js
CHANGED
|
@@ -4,39 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SDKConfig = void 0;
|
|
7
|
-
|
|
8
7
|
var fs = _interopRequireWildcard(require("fs"));
|
|
9
|
-
|
|
10
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
11
|
-
|
|
12
9
|
var _sdkRtl = require("@looker/sdk-rtl");
|
|
13
|
-
|
|
14
10
|
var _sdkNode = require("@looker/sdk-node");
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
14
|
var SDKConfig = function SDKConfig() {
|
|
23
15
|
var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : './looker.ini';
|
|
24
16
|
var envPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'LOOKERSDK';
|
|
25
17
|
var sectionName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Looker';
|
|
26
|
-
|
|
27
18
|
_dotenv.default.config();
|
|
28
|
-
|
|
29
19
|
if (process.env.DOT_ENV_FILE) {
|
|
30
20
|
var name = process.env.DOT_ENV_FILE;
|
|
31
|
-
|
|
32
21
|
var vals = _dotenv.default.parse(fs.readFileSync(name, 'utf-8'));
|
|
33
|
-
|
|
34
22
|
Object.entries(vals).forEach(_ref => {
|
|
35
23
|
var [key, val] = _ref;
|
|
36
24
|
if (val) process.env[key] = val;
|
|
37
25
|
});
|
|
38
26
|
}
|
|
39
|
-
|
|
40
27
|
var section = (0, _sdkNode.readIniConfig)(fileName, envPrefix, sectionName);
|
|
41
28
|
var config = {
|
|
42
29
|
api_version: section.api_version,
|
|
@@ -46,15 +33,12 @@ var SDKConfig = function SDKConfig() {
|
|
|
46
33
|
client_secret: section.client_secret,
|
|
47
34
|
verify_ssl: (0, _sdkRtl.boolDefault)(section.verify_ssl, true)
|
|
48
35
|
};
|
|
49
|
-
|
|
50
36
|
if (!config.base_url) {
|
|
51
37
|
throw Error('Fatal error: base_url is not configured. Exiting.');
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
return {
|
|
55
40
|
[sectionName]: config
|
|
56
41
|
};
|
|
57
42
|
};
|
|
58
|
-
|
|
59
43
|
exports.SDKConfig = SDKConfig;
|
|
60
44
|
//# sourceMappingURL=sdkConfig.js.map
|
package/lib/sdkConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sdkConfig.js","names":["SDKConfig","fileName","envPrefix","sectionName","dotenv","config","process","env","DOT_ENV_FILE","name","vals","parse","fs","readFileSync","Object","entries","forEach","key","val","section","readIniConfig","api_version","api_versions","base_url","client_id","client_secret","verify_ssl","boolDefault","Error"],"sources":["../src/sdkConfig.ts"],"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 * as fs from 'fs'\nimport dotenv from 'dotenv'\nimport { boolDefault } from '@looker/sdk-rtl'\nimport { readIniConfig } from '@looker/sdk-node'\n\nexport interface ISDKConfigProps {\n api_version: string\n api_versions: string\n base_url: string\n client_id: string\n client_secret: string\n verify_ssl: boolean\n}\n\nexport interface ISDKConfigSection {\n [key: string]: ISDKConfigProps\n}\n\nexport const SDKConfig = (\n fileName = './looker.ini',\n envPrefix = 'LOOKERSDK',\n sectionName = 'Looker'\n): ISDKConfigSection => {\n dotenv.config()\n if (process.env.DOT_ENV_FILE) {\n // Load custom env file\n const name = process.env.DOT_ENV_FILE\n const vals = dotenv.parse(fs.readFileSync(name, 'utf-8'))\n Object.entries(vals).forEach(([key, val]) => {\n if (val) process.env[key] = val\n })\n }\n\n const section = readIniConfig(fileName, envPrefix, sectionName)\n const config: ISDKConfigProps = {\n api_version: section.api_version,\n api_versions: section.api_versions,\n base_url: section.base_url,\n client_id: section.client_id,\n client_secret: section.client_secret,\n verify_ssl: boolDefault(section.verify_ssl, true),\n }\n\n if (!config.base_url) {\n throw Error('Fatal error: base_url is not configured. Exiting.')\n }\n return { [sectionName]: config }\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AACA;AAAgD;AAAA;AAAA;AAezC,IAAMA,SAAS,GAAG,SAAZA,SAAS,GAIE;EAAA,IAHtBC,QAAQ,uEAAG,cAAc;EAAA,IACzBC,SAAS,uEAAG,WAAW;EAAA,IACvBC,WAAW,uEAAG,QAAQ;EAEtBC,eAAM,CAACC,MAAM,EAAE;EACf,IAAIC,OAAO,CAACC,GAAG,CAACC,YAAY,EAAE;IAE5B,IAAMC,IAAI,GAAGH,OAAO,CAACC,GAAG,CAACC,YAAY;IACrC,IAAME,IAAI,GAAGN,eAAM,CAACO,KAAK,CAACC,EAAE,CAACC,YAAY,CAACJ,IAAI,EAAE,OAAO,CAAC,CAAC;IACzDK,MAAM,CAACC,OAAO,CAACL,IAAI,CAAC,CAACM,OAAO,CAAC,QAAgB;MAAA,IAAf,CAACC,GAAG,EAAEC,GAAG,CAAC;MACtC,IAAIA,GAAG,EAAEZ,OAAO,CAACC,GAAG,CAACU,GAAG,CAAC,GAAGC,GAAG;IACjC,CAAC,CAAC;EACJ;EAEA,IAAMC,OAAO,GAAG,IAAAC,sBAAa,EAACnB,QAAQ,EAAEC,SAAS,EAAEC,WAAW,CAAC;EAC/D,IAAME,MAAuB,GAAG;IAC9BgB,WAAW,EAAEF,OAAO,CAACE,WAAW;IAChCC,YAAY,EAAEH,OAAO,CAACG,YAAY;IAClCC,QAAQ,EAAEJ,OAAO,CAACI,QAAQ;IAC1BC,SAAS,EAAEL,OAAO,CAACK,SAAS;IAC5BC,aAAa,EAAEN,OAAO,CAACM,aAAa;IACpCC,UAAU,EAAE,IAAAC,mBAAW,EAACR,OAAO,CAACO,UAAU,EAAE,IAAI;EAClD,CAAC;EAED,IAAI,CAACrB,MAAM,CAACkB,QAAQ,EAAE;IACpB,MAAMK,KAAK,CAAC,mDAAmD,CAAC;EAClE;EACA,OAAO;IAAE,CAACzB,WAAW,GAAGE;EAAO,CAAC;AAClC,CAAC;AAAA"}
|
package/lib/sdkGen.js
CHANGED
|
@@ -4,38 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.writeCodeFile = void 0;
|
|
7
|
-
|
|
8
7
|
var fs = _interopRequireWildcard(require("fs"));
|
|
9
|
-
|
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
9
|
var _sdkCodegenUtils = require("@looker/sdk-codegen-utils");
|
|
13
|
-
|
|
14
10
|
var _sdkGenerator = require("./sdkGenerator");
|
|
15
|
-
|
|
16
11
|
var _reformatter = require("./reformatter");
|
|
17
|
-
|
|
18
12
|
var _nodeUtils = require("./nodeUtils");
|
|
19
|
-
|
|
20
13
|
var _languages = require("./languages");
|
|
21
|
-
|
|
22
14
|
var _utils = require("./utils");
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
31
|
-
|
|
32
19
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
33
|
-
|
|
34
20
|
var formatter = new _reformatter.FilesFormatter();
|
|
35
|
-
|
|
36
21
|
var writeCodeFile = (fileName, content) => {
|
|
37
22
|
var filePath = _path.default.dirname(fileName);
|
|
38
|
-
|
|
39
23
|
if (!(0, _nodeUtils.isDirSync)(filePath)) fs.mkdirSync(filePath, {
|
|
40
24
|
recursive: true
|
|
41
25
|
});
|
|
@@ -43,18 +27,14 @@ var writeCodeFile = (fileName, content) => {
|
|
|
43
27
|
formatter.addFile(fileName);
|
|
44
28
|
return fileName;
|
|
45
29
|
};
|
|
46
|
-
|
|
47
30
|
exports.writeCodeFile = writeCodeFile;
|
|
48
|
-
|
|
49
31
|
_asyncToGenerator(function* () {
|
|
50
32
|
var config;
|
|
51
|
-
|
|
52
33
|
try {
|
|
53
34
|
config = yield (0, _utils.prepGen)(process.argv.slice(2));
|
|
54
35
|
} catch (e) {
|
|
55
36
|
(0, _nodeUtils.quit)(e);
|
|
56
37
|
}
|
|
57
|
-
|
|
58
38
|
if (!config) return;
|
|
59
39
|
var {
|
|
60
40
|
props,
|
|
@@ -66,7 +46,6 @@ _asyncToGenerator(function* () {
|
|
|
66
46
|
var specs = yield (0, _utils.loadSpecs)(config);
|
|
67
47
|
var apis = config.apis;
|
|
68
48
|
(0, _sdkCodegenUtils.log)("generating ".concat(languages.join(','), " SDKs for APIs ").concat(apis));
|
|
69
|
-
|
|
70
49
|
try {
|
|
71
50
|
for (var language of languages) {
|
|
72
51
|
for (var api of apis) {
|
|
@@ -76,75 +55,55 @@ _asyncToGenerator(function* () {
|
|
|
76
55
|
lookerVersion
|
|
77
56
|
};
|
|
78
57
|
var apiModel = spec.api;
|
|
79
|
-
|
|
80
58
|
if (!apiModel) {
|
|
81
59
|
(0, _sdkCodegenUtils.danger)("Could not fetch or compile apiModel for ".concat(api, " ").concat(spec.specURL));
|
|
82
60
|
continue;
|
|
83
61
|
}
|
|
84
|
-
|
|
85
62
|
var gen = (0, _languages.getGenerator)(language, apiModel, versions);
|
|
86
|
-
|
|
87
63
|
if (!gen) {
|
|
88
64
|
(0, _sdkCodegenUtils.danger)("".concat(language, " does not have a code generator defined"));
|
|
89
65
|
continue;
|
|
90
66
|
}
|
|
91
|
-
|
|
92
67
|
if (api !== lastApi && !gen.supportsMultiApi()) {
|
|
93
68
|
(0, _sdkCodegenUtils.danger)("skipping API ".concat(api, " for ").concat(language, " because it doesn't support multiple API versions"));
|
|
94
69
|
continue;
|
|
95
70
|
}
|
|
96
|
-
|
|
97
71
|
(0, _sdkCodegenUtils.log)("generating ".concat(language, " from ").concat(props.base_url, " ").concat(api, " ..."));
|
|
98
72
|
(0, _sdkCodegenUtils.log)("generating ".concat(api, " methods ..."));
|
|
99
|
-
|
|
100
73
|
if (gen.useFunctions) {
|
|
101
74
|
(0, _sdkCodegenUtils.log)("generating ".concat(api, " functions ..."));
|
|
102
75
|
var s = new _sdkGenerator.FunctionGenerator(apiModel, gen);
|
|
103
|
-
|
|
104
76
|
var _output = s.render(gen.indentStr, noStreams);
|
|
105
|
-
|
|
106
77
|
writeCodeFile(gen.sdkFileName("funcs"), _output);
|
|
107
78
|
}
|
|
108
|
-
|
|
109
79
|
if (gen.useInterfaces) {
|
|
110
80
|
(0, _sdkCodegenUtils.log)("generating ".concat(api, " interfaces ..."));
|
|
111
|
-
|
|
112
81
|
var _s = new _sdkGenerator.InterfaceGenerator(apiModel, gen);
|
|
113
|
-
|
|
114
82
|
var _output2 = _s.render(gen.indentStr, noStreams);
|
|
115
|
-
|
|
116
83
|
writeCodeFile(gen.sdkFileName("methodsInterface"), _output2);
|
|
117
84
|
}
|
|
118
|
-
|
|
119
85
|
var sdk = new _sdkGenerator.MethodGenerator(apiModel, gen);
|
|
120
86
|
var output = sdk.render(gen.indentStr, noStreams);
|
|
121
87
|
writeCodeFile(gen.sdkFileName("methods"), output);
|
|
122
|
-
|
|
123
88
|
if (gen.willItStream) {
|
|
124
89
|
if (noStreams) {
|
|
125
90
|
(0, _sdkCodegenUtils.warn)("SKIPPING ".concat(api, " streaming methods ..."));
|
|
126
91
|
} else {
|
|
127
92
|
(0, _sdkCodegenUtils.log)("generating ".concat(api, " streaming methods ..."));
|
|
128
|
-
|
|
129
93
|
var _s2 = new _sdkGenerator.StreamGenerator(apiModel, gen);
|
|
130
|
-
|
|
131
94
|
var _output3 = _s2.render(gen.indentStr, noStreams);
|
|
132
|
-
|
|
133
95
|
writeCodeFile(gen.sdkFileName("streams"), _output3);
|
|
134
96
|
}
|
|
135
97
|
}
|
|
136
|
-
|
|
137
98
|
(0, _sdkCodegenUtils.log)("generating ".concat(api, " models ..."));
|
|
138
99
|
var types = new _sdkGenerator.TypeGenerator(apiModel, gen);
|
|
139
100
|
output = types.render('', noStreams);
|
|
140
101
|
writeCodeFile(gen.sdkFileName("models"), output);
|
|
141
|
-
|
|
142
102
|
if (api === lastApi) {
|
|
143
103
|
formatter.versionStamp(gen);
|
|
144
104
|
}
|
|
145
105
|
}
|
|
146
106
|
}
|
|
147
|
-
|
|
148
107
|
formatter.reformat();
|
|
149
108
|
} catch (e) {
|
|
150
109
|
(0, _nodeUtils.quit)(e);
|
package/lib/sdkGen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"sdkGen.js","names":["formatter","FilesFormatter","writeCodeFile","fileName","content","filePath","path","dirname","isDirSync","fs","mkdirSync","recursive","writeFileSync","addFile","config","prepGen","process","argv","slice","e","quit","props","languages","lookerVersion","lastApi","noStreams","specs","loadSpecs","apis","log","join","language","api","spec","versions","apiModel","danger","specURL","gen","getGenerator","supportsMultiApi","base_url","useFunctions","s","FunctionGenerator","output","render","indentStr","sdkFileName","useInterfaces","InterfaceGenerator","sdk","MethodGenerator","willItStream","warn","StreamGenerator","types","TypeGenerator","versionStamp","reformat"],"sources":["../src/sdkGen.ts"],"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 * as fs from 'fs'\nimport path from 'path'\nimport { danger, log, warn } from '@looker/sdk-codegen-utils'\nimport type { IVersionInfo } from '@looker/sdk-codegen'\nimport {\n FunctionGenerator,\n InterfaceGenerator,\n MethodGenerator,\n StreamGenerator,\n TypeGenerator,\n} from './sdkGenerator'\nimport { FilesFormatter } from './reformatter'\nimport { isDirSync, quit } from './nodeUtils'\nimport { getGenerator } from './languages'\nimport { loadSpecs, prepGen } from './utils'\n\nconst formatter = new FilesFormatter()\n\n/**\n * Writes the source code file and registers it with the file reformatter for processing\n * @param fileName name of source file\n * @param content contents to (over) write into source file\n * @returns the name of the file written\n */\nexport const writeCodeFile = (fileName: string, content: string): string => {\n const filePath = path.dirname(fileName)\n if (!isDirSync(filePath)) fs.mkdirSync(filePath, { recursive: true })\n\n fs.writeFileSync(fileName, content)\n formatter.addFile(fileName)\n return fileName\n}\n;(async () => {\n let config\n try {\n config = await prepGen(process.argv.slice(2))\n } catch (e: any) {\n quit(e)\n }\n if (!config) return\n const { props, languages, lookerVersion, lastApi, noStreams } = config\n\n // load the specifications and create the unique keys in case of spec API version overlap\n const specs = await loadSpecs(config)\n const apis = config.apis\n log(`generating ${languages.join(',')} SDKs for APIs ${apis}`)\n\n try {\n for (const language of languages) {\n for (const api of apis) {\n const spec = specs[api]\n const versions: IVersionInfo = {\n spec,\n lookerVersion,\n }\n const apiModel = spec.api\n if (!apiModel) {\n danger(\n `Could not fetch or compile apiModel for ${api} ${spec.specURL}`\n )\n continue\n }\n const gen = getGenerator(language, apiModel, versions)\n if (!gen) {\n danger(`${language} does not have a code generator defined`)\n continue\n }\n if (api !== lastApi && !gen.supportsMultiApi()) {\n danger(\n `skipping API ${api} for ${language} because it doesn't support multiple API versions`\n )\n continue\n }\n log(`generating ${language} from ${props.base_url} ${api} ...`)\n log(`generating ${api} methods ...`)\n\n if (gen.useFunctions) {\n log(`generating ${api} functions ...`)\n const s = new FunctionGenerator(apiModel, gen)\n const output = s.render(gen.indentStr, noStreams)\n writeCodeFile(gen.sdkFileName(`funcs`), output)\n }\n\n if (gen.useInterfaces) {\n log(`generating ${api} interfaces ...`)\n const s = new InterfaceGenerator(apiModel, gen)\n const output = s.render(gen.indentStr, noStreams)\n writeCodeFile(gen.sdkFileName(`methodsInterface`), output)\n }\n\n // Generate standard method declarations\n const sdk = new MethodGenerator(apiModel, gen)\n let output = sdk.render(gen.indentStr, noStreams)\n writeCodeFile(gen.sdkFileName(`methods`), output)\n\n if (gen.willItStream) {\n if (noStreams) {\n warn(`SKIPPING ${api} streaming methods ...`)\n } else {\n // Generate streaming method declarations\n log(`generating ${api} streaming methods ...`)\n const s = new StreamGenerator(apiModel, gen)\n const output = s.render(gen.indentStr, noStreams)\n writeCodeFile(gen.sdkFileName(`streams`), output)\n }\n }\n\n log(`generating ${api} models ...`)\n const types = new TypeGenerator(apiModel, gen)\n output = types.render('', noStreams)\n writeCodeFile(gen.sdkFileName(`models`), output)\n if (api === lastApi) {\n formatter.versionStamp(gen)\n }\n }\n }\n // finally, reformat all the files that have been generated\n formatter.reformat()\n } catch (e: any) {\n quit(e)\n }\n})()\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AAEA;AAOA;AACA;AACA;AACA;AAA4C;AAAA;AAAA;AAAA;AAAA;AAE5C,IAAMA,SAAS,GAAG,IAAIC,2BAAc,EAAE;AAQ/B,IAAMC,aAAa,GAAG,CAACC,QAAgB,EAAEC,OAAe,KAAa;EAC1E,IAAMC,QAAQ,GAAGC,aAAI,CAACC,OAAO,CAACJ,QAAQ,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W,EAAEH,MAAM,CAAC;QAEjD,IAAIP,GAAG,CAACe,YAAY,EAAE;UACpB,IAAI5B,SAAS,EAAE;YACb,IAAA6B,qBAAI,qBAAatB,GAAG,4BAAyB;UAC/C,CAAC,MAAM;YAEL,IAAAH,oBAAG,uBAAeG,GAAG,4BAAyB;YAC9C,IAAMW,GAAC,GAAG,IAAIY,6BAAe,CAACpB,QAAQ,EAAEG,GAAG,CAAC;YAC5C,IAAMO,QAAM,GAAGF,GAAC,CAACG,MAAM,CAACR,GAAG,CAACS,SAAS,EAAEtB,SAAS,CAAC;YACjDvB,aAAa,CAACoC,GAAG,CAACU,WAAW,WAAW,EAAEH,QAAM,CAAC;UACnD;QACF;QAEA,IAAAhB,oBAAG,uBAAeG,GAAG,iBAAc;QACnC,IAAMwB,KAAK,GAAG,IAAIC,2BAAa,CAACtB,QAAQ,EAAEG,GAAG,CAAC;QAC9CO,MAAM,GAAGW,KAAK,CAACV,MAAM,CAAC,EAAE,EAAErB,SAAS,CAAC;QACpCvB,aAAa,CAACoC,GAAG,CAACU,WAAW,UAAU,EAAEH,MAAM,CAAC;QAChD,IAAIb,GAAG,KAAKR,OAAO,EAAE;UACnBxB,SAAS,CAAC0D,YAAY,CAACpB,GAAG,CAAC;QAC7B;MACF;IACF;IAEAtC,SAAS,CAAC2D,QAAQ,EAAE;EACtB,CAAC,CAAC,OAAOxC,CAAM,EAAE;IACf,IAAAC,eAAI,EAACD,CAAC,CAAC;EACT;AACF,CAAC,GAAG"}
|
package/lib/sdkGenerator.js
CHANGED
|
@@ -3,73 +3,53 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.specFromFile = exports.TypeGenerator = exports.StreamGenerator = exports.MethodGenerator = exports.InterfaceGenerator = exports.Generator = exports.FunctionGenerator = void 0;
|
|
8
7
|
var _fs = require("fs");
|
|
9
|
-
|
|
10
8
|
var Models = _interopRequireWildcard(require("@looker/sdk-codegen"));
|
|
11
|
-
|
|
12
9
|
var _sdkCodegenUtils = require("@looker/sdk-codegen-utils");
|
|
13
|
-
|
|
14
10
|
var _nodeUtils = require("./nodeUtils");
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
16
|
var specFromFile = specFile => {
|
|
23
17
|
var specContent = (0, _nodeUtils.readFileSync)(specFile);
|
|
24
18
|
return Models.ApiModel.fromString(specContent);
|
|
25
19
|
};
|
|
26
|
-
|
|
27
20
|
exports.specFromFile = specFromFile;
|
|
28
21
|
var licenseFile = "./LICENSE";
|
|
29
22
|
var licenseText = (0, _fs.existsSync)(licenseFile) ? (0, _nodeUtils.readFileSync)('./LICENSE') : "".concat(licenseFile, " file not found");
|
|
30
|
-
|
|
31
23
|
class Generator {
|
|
32
24
|
constructor(model, formatter) {
|
|
33
25
|
_defineProperty(this, "codeFormatter", void 0);
|
|
34
|
-
|
|
35
26
|
_defineProperty(this, "model", void 0);
|
|
36
|
-
|
|
37
27
|
_defineProperty(this, "buf", []);
|
|
38
|
-
|
|
39
28
|
this.model = model;
|
|
40
29
|
this.codeFormatter = formatter;
|
|
41
30
|
}
|
|
42
|
-
|
|
43
31
|
p(str) {
|
|
44
32
|
if (typeof str !== 'undefined' && str.length > 0) {
|
|
45
33
|
this.buf = this.buf.concat(str);
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
return this;
|
|
49
36
|
}
|
|
50
|
-
|
|
51
37
|
toString(indent) {
|
|
52
38
|
return indent + this.buf.join('\n' + indent);
|
|
53
39
|
}
|
|
54
|
-
|
|
55
40
|
}
|
|
56
|
-
|
|
57
41
|
exports.Generator = Generator;
|
|
58
42
|
var noComment = ' ';
|
|
59
|
-
|
|
60
43
|
class MethodGenerator extends Generator {
|
|
61
44
|
itemGenerator(indent, method) {
|
|
62
45
|
return this.codeFormatter.declareMethod(indent, method);
|
|
63
46
|
}
|
|
64
|
-
|
|
65
47
|
prologue(indent) {
|
|
66
48
|
return this.codeFormatter.methodsPrologue(indent);
|
|
67
49
|
}
|
|
68
|
-
|
|
69
50
|
epilogue(indent) {
|
|
70
51
|
return this.codeFormatter.methodsEpilogue(indent);
|
|
71
52
|
}
|
|
72
|
-
|
|
73
53
|
render(indent) {
|
|
74
54
|
var noStreams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
75
55
|
this.codeFormatter.reset();
|
|
@@ -78,16 +58,13 @@ class MethodGenerator extends Generator {
|
|
|
78
58
|
var tagCount = 0;
|
|
79
59
|
Object.entries(this.model.tags).forEach(_ref => {
|
|
80
60
|
var _this$model$spec$tags;
|
|
81
|
-
|
|
82
61
|
var [tagName, methods] = _ref;
|
|
83
62
|
var tag = (_this$model$spec$tags = this.model.spec.tags) === null || _this$model$spec$tags === void 0 ? void 0 : _this$model$spec$tags.find(t => t.name.localeCompare(tagName, undefined, {
|
|
84
63
|
sensitivity: 'base'
|
|
85
64
|
}) === 0);
|
|
86
|
-
|
|
87
65
|
if (!tag) {
|
|
88
66
|
(0, _sdkCodegenUtils.warn)("Could not find tag ".concat(tagName, " in API specification"));
|
|
89
67
|
}
|
|
90
|
-
|
|
91
68
|
if (tag) {
|
|
92
69
|
tagCount++;
|
|
93
70
|
items.push(this.codeFormatter.beginRegion(indent, "".concat(tag.name, ": ").concat(tag.description)));
|
|
@@ -99,69 +76,49 @@ class MethodGenerator extends Generator {
|
|
|
99
76
|
});
|
|
100
77
|
var tally = "".concat(items.length - tagCount, " API methods");
|
|
101
78
|
(0, _sdkCodegenUtils.success)(tally);
|
|
102
|
-
|
|
103
79
|
if (noStreams) {
|
|
104
80
|
tally = '';
|
|
105
81
|
}
|
|
106
|
-
|
|
107
82
|
return this.p(this.codeFormatter.commentHeader('', licenseText, noComment)).p(this.codeFormatter.commentHeader('', tally)).p(this.prologue(indent)).p(items.join('\n\n')).p(this.epilogue(indent)).toString('');
|
|
108
83
|
}
|
|
109
|
-
|
|
110
84
|
}
|
|
111
|
-
|
|
112
85
|
exports.MethodGenerator = MethodGenerator;
|
|
113
|
-
|
|
114
86
|
class StreamGenerator extends MethodGenerator {
|
|
115
87
|
itemGenerator(indent, method) {
|
|
116
88
|
return this.codeFormatter.declareStreamer(indent, method);
|
|
117
89
|
}
|
|
118
|
-
|
|
119
90
|
prologue(indent) {
|
|
120
91
|
return this.codeFormatter.streamsPrologue(indent);
|
|
121
92
|
}
|
|
122
|
-
|
|
123
93
|
epilogue(indent) {
|
|
124
94
|
return this.codeFormatter.methodsEpilogue(indent);
|
|
125
95
|
}
|
|
126
|
-
|
|
127
96
|
}
|
|
128
|
-
|
|
129
97
|
exports.StreamGenerator = StreamGenerator;
|
|
130
|
-
|
|
131
98
|
class InterfaceGenerator extends MethodGenerator {
|
|
132
99
|
itemGenerator(indent, method) {
|
|
133
100
|
return this.codeFormatter.declareInterface(indent, method);
|
|
134
101
|
}
|
|
135
|
-
|
|
136
102
|
prologue(indent) {
|
|
137
103
|
return this.codeFormatter.interfacesPrologue(indent);
|
|
138
104
|
}
|
|
139
|
-
|
|
140
105
|
epilogue(indent) {
|
|
141
106
|
return this.codeFormatter.methodsEpilogue(indent);
|
|
142
107
|
}
|
|
143
|
-
|
|
144
108
|
}
|
|
145
|
-
|
|
146
109
|
exports.InterfaceGenerator = InterfaceGenerator;
|
|
147
|
-
|
|
148
110
|
class FunctionGenerator extends MethodGenerator {
|
|
149
111
|
itemGenerator(indent, method) {
|
|
150
112
|
return this.codeFormatter.declareFunction(indent, method);
|
|
151
113
|
}
|
|
152
|
-
|
|
153
114
|
prologue(indent) {
|
|
154
115
|
return this.codeFormatter.functionsPrologue(indent);
|
|
155
116
|
}
|
|
156
|
-
|
|
157
117
|
epilogue(indent) {
|
|
158
118
|
return this.codeFormatter.functionsEpilogue(indent);
|
|
159
119
|
}
|
|
160
|
-
|
|
161
120
|
}
|
|
162
|
-
|
|
163
121
|
exports.FunctionGenerator = FunctionGenerator;
|
|
164
|
-
|
|
165
122
|
class TypeGenerator extends Generator {
|
|
166
123
|
render(indent) {
|
|
167
124
|
var noStreams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -177,14 +134,11 @@ class TypeGenerator extends Generator {
|
|
|
177
134
|
var counts = this.typeTally(this.model.types);
|
|
178
135
|
var tally = "".concat(counts.total, " API models: ").concat(counts.standard, " Spec, ").concat(counts.request, " Request, ").concat(counts.write, " Write, ").concat(counts.enums, " Enum");
|
|
179
136
|
(0, _sdkCodegenUtils.success)(tally);
|
|
180
|
-
|
|
181
137
|
if (noStreams) {
|
|
182
138
|
tally = '';
|
|
183
139
|
}
|
|
184
|
-
|
|
185
140
|
return this.p(this.codeFormatter.commentHeader('', licenseText, noComment)).p(this.codeFormatter.commentHeader('', tally)).p(this.codeFormatter.modelsPrologue(indent)).p(items.join('\n\n')).p(this.codeFormatter.modelsEpilogue(indent)).toString(indent);
|
|
186
141
|
}
|
|
187
|
-
|
|
188
142
|
typeTally(types) {
|
|
189
143
|
var request = 0;
|
|
190
144
|
var write = 0;
|
|
@@ -209,8 +163,6 @@ class TypeGenerator extends Generator {
|
|
|
209
163
|
enums
|
|
210
164
|
};
|
|
211
165
|
}
|
|
212
|
-
|
|
213
166
|
}
|
|
214
|
-
|
|
215
167
|
exports.TypeGenerator = TypeGenerator;
|
|
216
168
|
//# sourceMappingURL=sdkGenerator.js.map
|
package/lib/sdkGenerator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdkGenerator.ts"],"names":["specFromFile","specFile","specContent","Models","ApiModel","fromString","licenseFile","licenseText","Generator","constructor","model","formatter","codeFormatter","p","str","length","buf","concat","toString","indent","join","noComment","MethodGenerator","itemGenerator","method","declareMethod","prologue","methodsPrologue","epilogue","methodsEpilogue","render","noStreams","reset","items","Object","values","types","forEach","type","refCount","tagCount","entries","tags","tagName","methods","tag","spec","find","t","name","localeCompare","undefined","sensitivity","push","beginRegion","description","endRegion","tally","commentHeader","StreamGenerator","declareStreamer","streamsPrologue","InterfaceGenerator","declareInterface","interfacesPrologue","FunctionGenerator","declareFunction","functionsPrologue","functionsEpilogue","TypeGenerator","IntrinsicType","useNamedParameters","RequestType","declareType","counts","typeTally","total","standard","request","write","enums","modelsPrologue","modelsEpilogue","filter","WriteType","EnumType"],"mappings":";;;;;;;AA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nC,MAAM,CAACqE,WAA3B,EAAwC;AACtC,YAAIlC,IAAI,CAACC,QAAL,GAAgB,CAApB,EAAuBuC,OAAO;AAC/B,OAFD,MAEO,IAAIxC,IAAI,YAAYnC,MAAM,CAACiF,SAA3B,EAAsC;AAC3C,YAAI9C,IAAI,CAACC,QAAL,GAAgB,CAApB,EAAuBwC,KAAK;AAC7B,OAFM,MAEA,IAAIzC,IAAI,YAAYnC,MAAM,CAACkF,QAA3B,EAAqC;AAC1C,YAAI/C,IAAI,CAACC,QAAL,GAAgB,CAApB,EAAuByC,KAAK;AAC7B,OAFM,MAEA;AACLH,QAAAA,QAAQ;AACT;AACF,KAZH;AAaA,WAAO;AACLC,MAAAA,OADK;AAELD,MAAAA,QAFK;AAGLD,MAAAA,KAAK,EAAEC,QAAQ,GAAGE,KAAX,GAAmBD,OAAnB,GAA6BE,KAH/B;AAILD,MAAAA,KAJK;AAKLC,MAAAA;AALK,KAAP;AAOD;;AAvD4D","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 { existsSync } from 'fs'\nimport * as Models from '@looker/sdk-codegen'\nimport { success, warn } from '@looker/sdk-codegen-utils'\nimport { readFileSync } from './nodeUtils'\n\nexport const specFromFile = (specFile: string): Models.ApiModel => {\n const specContent = readFileSync(specFile)\n return Models.ApiModel.fromString(specContent)\n}\n\nexport interface IGeneratorCtor<T extends Models.IModel> {\n new (model: T, formatter: Models.ICodeGen): Generator<T>\n}\n\nconst licenseFile = `./LICENSE`\nconst licenseText = existsSync(licenseFile)\n ? readFileSync('./LICENSE')\n : `${licenseFile} file not found`\n\nexport abstract class Generator<T extends Models.IModel> {\n codeFormatter: Models.ICodeGen\n model: T\n buf: string[] = []\n\n constructor(model: T, formatter: Models.ICodeGen) {\n this.model = model\n this.codeFormatter = formatter\n }\n\n abstract render(indent: string, noStreams: boolean): string\n\n // Add one or more strings to the internal buffer\n // if the string is not empty or undefined\n p(str?: string | string[]): this {\n if (typeof str !== 'undefined' && str.length > 0) {\n this.buf = this.buf.concat(str)\n }\n return this\n }\n\n toString(indent: string): string {\n return indent + this.buf.join('\\n' + indent)\n }\n}\n\nconst noComment = ' '\n\nexport class MethodGenerator extends Generator<Models.IApiModel> {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareMethod(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.methodsPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.methodsEpilogue(indent)\n }\n\n render(indent: string, noStreams = false) {\n this.codeFormatter.reset()\n const items: string[] = []\n // reset refcounts for ALL types so dynamic import statement will work\n Object.values(this.model.types).forEach((type) => (type.refCount = 0))\n let tagCount = 0\n Object.entries(this.model.tags).forEach(([tagName, methods]) => {\n const tag = this.model.spec.tags?.find(\n (t) =>\n t.name.localeCompare(tagName, undefined, { sensitivity: 'base' }) ===\n 0\n )\n if (!tag) {\n warn(`Could not find tag ${tagName} in API specification`)\n }\n if (tag) {\n tagCount++\n items.push(\n this.codeFormatter.beginRegion(\n indent,\n `${tag.name}: ${tag.description}`\n )\n )\n Object.values(methods).forEach((method) => {\n items.push(this.itemGenerator(indent, method))\n })\n items.push(\n this.codeFormatter.endRegion(\n indent,\n `${tag.name}: ${tag.description}`\n )\n )\n }\n })\n let tally = `${items.length - tagCount} API methods`\n success(tally)\n if (noStreams) {\n // Minimize code changes, don't include the tally when not streaming\n tally = ''\n }\n return this.p(this.codeFormatter.commentHeader('', licenseText, noComment))\n .p(this.codeFormatter.commentHeader('', tally))\n .p(this.prologue(indent))\n .p(items.join('\\n\\n'))\n .p(this.epilogue(indent))\n .toString('')\n }\n}\n\nexport class StreamGenerator extends MethodGenerator {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareStreamer(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.streamsPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.methodsEpilogue(indent)\n }\n}\n\nexport class InterfaceGenerator extends MethodGenerator {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareInterface(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.interfacesPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.methodsEpilogue(indent)\n }\n}\n\nexport class FunctionGenerator extends MethodGenerator {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareFunction(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.functionsPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.functionsEpilogue(indent)\n }\n}\n\nexport class TypeGenerator extends Generator<Models.IApiModel> {\n render(indent: string, noStreams = false) {\n this.codeFormatter.reset()\n const items: string[] = []\n Object.values(this.model.types).forEach((type) => {\n if (!(type instanceof Models.IntrinsicType)) {\n if (\n !this.codeFormatter.useNamedParameters ||\n !(type instanceof Models.RequestType)\n ) {\n items.push(this.codeFormatter.declareType(indent, type))\n }\n }\n })\n\n const counts = this.typeTally(this.model.types)\n let tally = `${counts.total} API models: ${counts.standard} Spec, ${counts.request} Request, ${counts.write} Write, ${counts.enums} Enum`\n success(tally)\n if (noStreams) {\n // Minimize code changes, don't include the tally when not streaming\n tally = ''\n }\n return this.p(this.codeFormatter.commentHeader('', licenseText, noComment))\n .p(this.codeFormatter.commentHeader('', tally))\n .p(this.codeFormatter.modelsPrologue(indent))\n .p(items.join('\\n\\n'))\n .p(this.codeFormatter.modelsEpilogue(indent))\n .toString(indent)\n }\n\n typeTally(types: Record<string, Models.IType>) {\n let request = 0\n let write = 0\n let standard = 0\n let enums = 0\n Object.values(types)\n .filter((type) => !(type instanceof Models.IntrinsicType))\n .forEach((type) => {\n if (type instanceof Models.RequestType) {\n if (type.refCount > 0) request++\n } else if (type instanceof Models.WriteType) {\n if (type.refCount > 0) write++\n } else if (type instanceof Models.EnumType) {\n if (type.refCount > 0) enums++\n } else {\n standard++\n }\n })\n return {\n request,\n standard,\n total: standard + write + request + enums,\n write,\n enums,\n }\n }\n}\n"],"file":"sdkGenerator.js"}
|
|
1
|
+
{"version":3,"file":"sdkGenerator.js","names":["specFromFile","specFile","specContent","readFileSync","Models","ApiModel","fromString","licenseFile","licenseText","existsSync","Generator","constructor","model","formatter","codeFormatter","p","str","length","buf","concat","toString","indent","join","noComment","MethodGenerator","itemGenerator","method","declareMethod","prologue","methodsPrologue","epilogue","methodsEpilogue","render","noStreams","reset","items","Object","values","types","forEach","type","refCount","tagCount","entries","tags","tagName","methods","tag","spec","find","t","name","localeCompare","undefined","sensitivity","warn","push","beginRegion","description","endRegion","tally","success","commentHeader","StreamGenerator","declareStreamer","streamsPrologue","InterfaceGenerator","declareInterface","interfacesPrologue","FunctionGenerator","declareFunction","functionsPrologue","functionsEpilogue","TypeGenerator","IntrinsicType","useNamedParameters","RequestType","declareType","counts","typeTally","total","standard","request","write","enums","modelsPrologue","modelsEpilogue","filter","WriteType","EnumType"],"sources":["../src/sdkGenerator.ts"],"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 { existsSync } from 'fs'\nimport * as Models from '@looker/sdk-codegen'\nimport { success, warn } from '@looker/sdk-codegen-utils'\nimport { readFileSync } from './nodeUtils'\n\nexport const specFromFile = (specFile: string): Models.ApiModel => {\n const specContent = readFileSync(specFile)\n return Models.ApiModel.fromString(specContent)\n}\n\nexport interface IGeneratorCtor<T extends Models.IModel> {\n new (model: T, formatter: Models.ICodeGen): Generator<T>\n}\n\nconst licenseFile = `./LICENSE`\nconst licenseText = existsSync(licenseFile)\n ? readFileSync('./LICENSE')\n : `${licenseFile} file not found`\n\nexport abstract class Generator<T extends Models.IModel> {\n codeFormatter: Models.ICodeGen\n model: T\n buf: string[] = []\n\n constructor(model: T, formatter: Models.ICodeGen) {\n this.model = model\n this.codeFormatter = formatter\n }\n\n abstract render(indent: string, noStreams: boolean): string\n\n // Add one or more strings to the internal buffer\n // if the string is not empty or undefined\n p(str?: string | string[]): this {\n if (typeof str !== 'undefined' && str.length > 0) {\n this.buf = this.buf.concat(str)\n }\n return this\n }\n\n toString(indent: string): string {\n return indent + this.buf.join('\\n' + indent)\n }\n}\n\nconst noComment = ' '\n\nexport class MethodGenerator extends Generator<Models.IApiModel> {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareMethod(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.methodsPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.methodsEpilogue(indent)\n }\n\n render(indent: string, noStreams = false) {\n this.codeFormatter.reset()\n const items: string[] = []\n // reset refcounts for ALL types so dynamic import statement will work\n Object.values(this.model.types).forEach((type) => (type.refCount = 0))\n let tagCount = 0\n Object.entries(this.model.tags).forEach(([tagName, methods]) => {\n const tag = this.model.spec.tags?.find(\n (t) =>\n t.name.localeCompare(tagName, undefined, { sensitivity: 'base' }) ===\n 0\n )\n if (!tag) {\n warn(`Could not find tag ${tagName} in API specification`)\n }\n if (tag) {\n tagCount++\n items.push(\n this.codeFormatter.beginRegion(\n indent,\n `${tag.name}: ${tag.description}`\n )\n )\n Object.values(methods).forEach((method) => {\n items.push(this.itemGenerator(indent, method))\n })\n items.push(\n this.codeFormatter.endRegion(\n indent,\n `${tag.name}: ${tag.description}`\n )\n )\n }\n })\n let tally = `${items.length - tagCount} API methods`\n success(tally)\n if (noStreams) {\n // Minimize code changes, don't include the tally when not streaming\n tally = ''\n }\n return this.p(this.codeFormatter.commentHeader('', licenseText, noComment))\n .p(this.codeFormatter.commentHeader('', tally))\n .p(this.prologue(indent))\n .p(items.join('\\n\\n'))\n .p(this.epilogue(indent))\n .toString('')\n }\n}\n\nexport class StreamGenerator extends MethodGenerator {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareStreamer(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.streamsPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.methodsEpilogue(indent)\n }\n}\n\nexport class InterfaceGenerator extends MethodGenerator {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareInterface(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.interfacesPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.methodsEpilogue(indent)\n }\n}\n\nexport class FunctionGenerator extends MethodGenerator {\n itemGenerator(indent: string, method: Models.IMethod) {\n return this.codeFormatter.declareFunction(indent, method)\n }\n\n prologue(indent: string) {\n return this.codeFormatter.functionsPrologue(indent)\n }\n\n epilogue(indent: string) {\n return this.codeFormatter.functionsEpilogue(indent)\n }\n}\n\nexport class TypeGenerator extends Generator<Models.IApiModel> {\n render(indent: string, noStreams = false) {\n this.codeFormatter.reset()\n const items: string[] = []\n Object.values(this.model.types).forEach((type) => {\n if (!(type instanceof Models.IntrinsicType)) {\n if (\n !this.codeFormatter.useNamedParameters ||\n !(type instanceof Models.RequestType)\n ) {\n items.push(this.codeFormatter.declareType(indent, type))\n }\n }\n })\n\n const counts = this.typeTally(this.model.types)\n let tally = `${counts.total} API models: ${counts.standard} Spec, ${counts.request} Request, ${counts.write} Write, ${counts.enums} Enum`\n success(tally)\n if (noStreams) {\n // Minimize code changes, don't include the tally when not streaming\n tally = ''\n }\n return this.p(this.codeFormatter.commentHeader('', licenseText, noComment))\n .p(this.codeFormatter.commentHeader('', tally))\n .p(this.codeFormatter.modelsPrologue(indent))\n .p(items.join('\\n\\n'))\n .p(this.codeFormatter.modelsEpilogue(indent))\n .toString(indent)\n }\n\n typeTally(types: Record<string, Models.IType>) {\n let request = 0\n let write = 0\n let standard = 0\n let enums = 0\n Object.values(types)\n .filter((type) => !(type instanceof Models.IntrinsicType))\n .forEach((type) => {\n if (type instanceof Models.RequestType) {\n if (type.refCount > 0) request++\n } else if (type instanceof Models.WriteType) {\n if (type.refCount > 0) write++\n } else if (type instanceof Models.EnumType) {\n if (type.refCount > 0) enums++\n } else {\n standard++\n }\n })\n return {\n request,\n standard,\n total: standard + write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