@looker/sdk-codegen 21.5.0 → 21.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/lib/codeGenerators.js.map +1 -1
- package/lib/declarationInfo.d.ts +2 -2
- package/lib/declarationInfo.js +3 -2
- package/lib/declarationInfo.js.map +1 -1
- package/lib/esm/codeGenerators.js.map +1 -1
- package/lib/esm/declarationInfo.js +3 -2
- package/lib/esm/declarationInfo.js.map +1 -1
- package/lib/esm/exampleInfo.js +1 -0
- package/lib/esm/exampleInfo.js.map +1 -1
- package/lib/esm/sdkModels.js +10 -16
- package/lib/esm/sdkModels.js.map +1 -1
- package/lib/esm/specConverter.js +1 -1
- package/lib/esm/specConverter.js.map +1 -1
- package/lib/exampleInfo.d.ts +3 -1
- package/lib/exampleInfo.js +5 -1
- package/lib/exampleInfo.js.map +1 -1
- package/lib/sdkModels.d.ts +4 -4
- package/lib/sdkModels.js +10 -16
- package/lib/sdkModels.js.map +1 -1
- package/lib/specConverter.js +1 -1
- package/lib/specConverter.js.map +1 -1
- package/lib/testUtils/testUtils.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [21.7.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.6.0...sdk-codegen-v21.7.0) (2022-07-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* keep SDK request interfaces distinct ([#1125](https://www.github.com/looker-open-source/sdk-codegen/issues/1125)) ([50e925c](https://www.github.com/looker-open-source/sdk-codegen/commit/50e925c90eb3c5ffefc8e8535131471e2f2d0334))
|
|
14
|
+
|
|
15
|
+
## [21.6.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.5.2...sdk-codegen-v21.6.0) (2022-07-07)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* generate SDK 22.6 ([#1102](https://www.github.com/looker-open-source/sdk-codegen/issues/1102)) ([2162860](https://www.github.com/looker-open-source/sdk-codegen/commit/2162860f0bf292bce0a79f8115f7c9fc5628057f))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* remove generated files from examples index ([#1076](https://www.github.com/looker-open-source/sdk-codegen/issues/1076)) ([d75bce8](https://www.github.com/looker-open-source/sdk-codegen/commit/d75bce8dc25d41fd6bc5e2e513782eaa6009fd10))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Dependencies
|
|
29
|
+
|
|
30
|
+
* The following workspace dependencies were updated
|
|
31
|
+
* dependencies
|
|
32
|
+
* @looker/sdk-rtl bumped from ^21.3.3 to ^21.3.4
|
|
33
|
+
|
|
34
|
+
### [21.5.2](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.5.1...sdk-codegen-v21.5.2) (2022-04-07)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Dependencies
|
|
38
|
+
|
|
39
|
+
* The following workspace dependencies were updated
|
|
40
|
+
* dependencies
|
|
41
|
+
* @looker/sdk-rtl bumped from ^21.3.2 to ^21.3.3
|
|
42
|
+
|
|
8
43
|
## [21.5.0](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-v21.4.0...sdk-codegen-v21.5.0) (2022-03-04)
|
|
9
44
|
|
|
10
45
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/codeGenerators.ts"],"names":["Generators","factory","api","versions","PythonGen","language","extension","TypescriptGen","KotlinGen","CSharpGen","legacy","options","SwiftGen","GoGen","codeGenerators","filter","x","undefined","findG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lB,EAAuBC,QAAvB,CAAP;AACD;;AACD,SAAOc,SAAP;AACD,CAVM;;;;AAYA,IAAMS,eAAe,GAAG,MAA6B;AAC1D,SAAO1B,UAAU,CAACe,MAAX,CAAmBC,CAAD,IAAO,CAAC,CAACA,CAAC,CAACN,MAA7B,CAAP;AACD,CAFM","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 { ApiModel } from './sdkModels'\nimport type { ICodeGen, IVersionInfo } from './codeGen'\nimport { CSharpGen } from './csharp.gen'\nimport { KotlinGen } from './kotlin.gen'\nimport { SwiftGen } from './swift.gen'\nimport { PythonGen } from './python.gen'\nimport { TypescriptGen } from './typescript.gen'\nimport { GoGen } from './go.gen'\n\nexport interface IGeneratorSpec {\n /** source code file extension regex */\n extension: RegExp\n /** name of language SDK to generate */\n language: string\n /** path name for legacy generator output. Defaults to language */\n path?: string\n /** code generator constructor */\n factory?: (api: ApiModel, versions?: IVersionInfo) => ICodeGen\n /** options for the legacy code generator */\n options?: string\n /** name of the legacy language generator */\n legacy?: string // legacy language tag\n}\n\n// To disable generation of any language specification,
|
|
1
|
+
{"version":3,"sources":["../src/codeGenerators.ts"],"names":["Generators","factory","api","versions","PythonGen","language","extension","TypescriptGen","KotlinGen","CSharpGen","legacy","options","SwiftGen","GoGen","codeGenerators","filter","x","undefined","findGenerator","target","toLocaleLowerCase","find","item","match","getCodeGenerator","generator","legacyLanguages"],"mappings":";;;;;;;AA4BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAkBO,IAAMA,UAAiC,GAAG,CAC/C;AACEC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAgBC,QAAhB,KACP,IAAIC,iBAAJ,CAAcF,GAAd,EAAmBC,QAAnB,CAFJ;AAGEE,EAAAA,QAAQ,EAAE,QAHZ;AAIEC,EAAAA,SAAS,EAAE;AAJb,CAD+C,EAO/C;AACEL,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAgBC,QAAhB,KACP,IAAII,yBAAJ,CAAkBL,GAAlB,EAAuBC,QAAvB,CAFJ;AAGEE,EAAAA,QAAQ,EAAE,YAHZ;AAIEC,EAAAA,SAAS,EAAE;AAJb,CAP+C,EAa/C;AACEL,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAgBC,QAAhB,KACP,IAAIK,iBAAJ,CAAcN,GAAd,EAAmBC,QAAnB,CAFJ;AAGEE,EAAAA,QAAQ,EAAE,QAHZ;AAIEC,EAAAA,SAAS,EAAE;AAJb,CAb+C,EAmB/C;AACEL,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAgBC,QAAhB,KACP,IAAIM,iBAAJ,CAAcP,GAAd,EAAmBC,QAAnB,CAFJ;AAGEE,EAAAA,QAAQ,EAAE,IAHZ;AAIEK,EAAAA,MAAM,EAAE,QAJV;AAKEC,EAAAA,OAAO,EAAE,0CALX;AAMEL,EAAAA,SAAS,EAAE;AANb,CAnB+C,EA2B/C;AACEL,EAAAA,OAAO,EAAE,CA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IAAMK,gBAAgB,GAAG,CAC9BnB,QAD8B,EAE9BH,GAF8B,EAG9BC,QAH8B,KAIL;AACzB,MAAMsB,SAAS,GAAGP,aAAa,CAACb,QAAD,CAA/B;;AACA,MAAIoB,SAAS,IAAIA,SAAS,CAACxB,OAA3B,EAAoC;AAClC,WAAOwB,SAAS,CAACxB,OAAV,CAAkBC,GAAlB,EAAuBC,QAAvB,CAAP;AACD;;AACD,SAAOc,SAAP;AACD,CAVM;;;;AAYA,IAAMS,eAAe,GAAG,MAA6B;AAC1D,SAAO1B,UAAU,CAACe,MAAX,CAAmBC,CAAD,IAAO,CAAC,CAACA,CAAC,CAACN,MAA7B,CAAP;AACD,CAFM","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 { ApiModel } from './sdkModels'\nimport type { ICodeGen, IVersionInfo } from './codeGen'\nimport { CSharpGen } from './csharp.gen'\nimport { KotlinGen } from './kotlin.gen'\nimport { SwiftGen } from './swift.gen'\nimport { PythonGen } from './python.gen'\nimport { TypescriptGen } from './typescript.gen'\nimport { GoGen } from './go.gen'\n\nexport interface IGeneratorSpec {\n /** source code file extension regex */\n extension: RegExp\n /** name of language SDK to generate */\n language: string\n /** path name for legacy generator output. Defaults to language */\n path?: string\n /** code generator constructor */\n factory?: (api: ApiModel, versions?: IVersionInfo) => ICodeGen\n /** options for the legacy code generator */\n options?: string\n /** name of the legacy language generator */\n legacy?: string // legacy language tag\n}\n\n// To disable generation of any language specification, just comment it out\nexport const Generators: Array<IGeneratorSpec> = [\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new PythonGen(api, versions),\n language: 'Python',\n extension: /\\.py/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new TypescriptGen(api, versions),\n language: 'TypeScript',\n extension: /\\.ts(x?)/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new KotlinGen(api, versions),\n language: 'Kotlin',\n extension: /\\.kt/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new CSharpGen(api, versions),\n language: 'C#',\n legacy: 'csharp',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.cs/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new SwiftGen(api, versions),\n language: 'Swift',\n extension: /\\.swift/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new GoGen(api, versions),\n language: 'Go',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.go/gi,\n },\n {\n language: 'java',\n legacy: 'java',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.java/gi,\n },\n {\n language: 'php',\n legacy: 'php',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.php/gi,\n },\n // {\n // language: 'R',\n // legacy: 'r'\n // options: '-papiPackage=Looker -ppackageName=looker'\n // extension: /\\.r/gi,\n // },\n // {\n // language: 'Ruby',\n // options: '-papiPackage=Looker -ppackageName=looker'\n // extension: /\\.rb/gi,\n // },\n // {\n // language: 'Rust',\n // options: '-papiPackage=Looker -ppackageName=looker'\n // extension: /\\.rs/gi,\n // },\n]\n\nexport const codeGenerators = Generators.filter((x) => x.factory !== undefined)\n\n/**\n * Matches the code generator based on the language name, alias, file extension, or legacy name\n * @param target label/language/file extension to find in the generator list\n * @returns undefined if the label/language/extension isn't found, otherwise the generator entry\n */\nexport const findGenerator = (target: string) => {\n target = target.toLocaleLowerCase()\n // Convenience alias\n return codeGenerators.find(\n (item) =>\n item.language.toLocaleLowerCase() === target ||\n target.match(item.extension) ||\n ('.' + target).match(item.extension) ||\n item.legacy?.toLocaleLowerCase() === target\n )\n}\n\n/**\n * constructs a language generator by name lookup\n *\n * CodeGenerator settings can be overridden by creating a config file and adding an entry for the desired language\n *\n * See the `config` folder in this package for more sample config files\n *\n * @param language name, file extension, or alias of code language to generate\n * @param api API specification\n * @param versions version info to use for stamping the agentTag\n * @returns either an ICodeGen implementation or undefined\n */\nexport const getCodeGenerator = (\n language: string,\n api: ApiModel,\n versions?: IVersionInfo\n): ICodeGen | undefined => {\n const generator = findGenerator(language)\n if (generator && generator.factory) {\n return generator.factory(api, versions)\n }\n return undefined\n}\n\nexport const legacyLanguages = (): Array<IGeneratorSpec> => {\n return Generators.filter((x) => !!x.legacy)\n}\n"],"file":"codeGenerators.js"}
|
package/lib/declarationInfo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IMine, IFileCall } from './exampleInfo';
|
|
1
|
+
import type { IMine, IFileCall, SourceLink } from './exampleInfo';
|
|
2
2
|
import type { KeyedCollection } from './sdkModels';
|
|
3
3
|
export interface IDeclarationMine extends IMine {
|
|
4
4
|
types: DeclarationNuggets;
|
|
@@ -7,7 +7,7 @@ export interface IDeclarationMine extends IMine {
|
|
|
7
7
|
export interface IDeclarationNugget extends IFileCall {
|
|
8
8
|
}
|
|
9
9
|
export declare type DeclarationNuggets = KeyedCollection<IDeclarationNugget>;
|
|
10
|
-
export declare const findDeclaration: (lode: IDeclarationMine, methodId?: string | undefined, typeId?: string | undefined) => {
|
|
10
|
+
export declare const findDeclaration: (lode: IDeclarationMine, methodId?: string | undefined, typeId?: string | undefined, sourcerer?: SourceLink) => {
|
|
11
11
|
declaration: IDeclarationNugget | undefined;
|
|
12
12
|
link: string | undefined;
|
|
13
13
|
};
|
package/lib/declarationInfo.js
CHANGED
|
@@ -7,7 +7,8 @@ exports.findDeclaration = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _exampleInfo = require("./exampleInfo");
|
|
9
9
|
|
|
10
|
-
var findDeclaration = (lode, methodId, typeId)
|
|
10
|
+
var findDeclaration = function findDeclaration(lode, methodId, typeId) {
|
|
11
|
+
var sourcerer = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _exampleInfo.permaLink;
|
|
11
12
|
var declaration;
|
|
12
13
|
|
|
13
14
|
if (methodId) {
|
|
@@ -19,7 +20,7 @@ var findDeclaration = (lode, methodId, typeId) => {
|
|
|
19
20
|
var link;
|
|
20
21
|
|
|
21
22
|
if (declaration) {
|
|
22
|
-
link = (
|
|
23
|
+
link = sourcerer(lode.remoteOrigin, lode.commitHash, declaration.sourceFile, declaration.line);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/declarationInfo.ts"],"names":["findDeclaration","lode","methodId","typeId","declaration","methods","types","link","remoteOrigin","commitHash","sourceFile","line"],"mappings":";;;;;;;AA0BA;;
|
|
1
|
+
{"version":3,"sources":["../src/declarationInfo.ts"],"names":["findDeclaration","lode","methodId","typeId","sourcerer","permaLink","declaration","methods","types","link","remoteOrigin","commitHash","sourceFile","line"],"mappings":";;;;;;;AA0BA;;AAqBO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAC7BC,IAD6B,EAE7BC,QAF6B,EAG7BC,MAH6B,EAK1B;AAAA,MADHC,SACG,uEADqBC,sBACrB;AACH,MAAIC,WAAJ;;AACA,MAAIJ,QAAJ,EAAc;AACZI,IAAAA,WAAW,GAAGL,IAAI,CAACM,OAAL,CAAaL,QAAb,CAAd;AACD,GAFD,MAEO,IAAIC,MAAJ,EAAY;AACjBG,IAAAA,WAAW,GAAGL,IAAI,CAACO,KAAL,CAAWL,MAAX,CAAd;AACD;;AAED,MAAIM,IAAJ;;AACA,MAAIH,WAAJ,EAAiB;AACfG,IAAAA,IAAI,GAAGL,SAAS,CACdH,IAAI,CAACS,YADS,EAEdT,IAAI,CAACU,UAFS,EAGdL,WAAW,CAACM,UAHE,EAIdN,WAAW,CAACO,IAJE,CAAhB;AAOD;;AACD,SAAO;AAAEP,IAAAA,WAAF;AAAeG,IAAAA;AAAf,GAAP;AACD,CAxBM","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 */\nimport type { IMine, IFileCall, SourceLink } from './exampleInfo'\nimport { permaLink } from './exampleInfo'\nimport type { KeyedCollection } from './sdkModels'\n\n/** All mined declaration data */\nexport interface IDeclarationMine extends IMine {\n types: DeclarationNuggets\n methods: DeclarationNuggets\n}\n\nexport interface IDeclarationNugget extends IFileCall {}\n\nexport type DeclarationNuggets = KeyedCollection<IDeclarationNugget>\n\n/**\n * Searches for declaration of a given method or type and returns a GitHub\n * permalink if found\n * @param lode All declaration data\n * @param methodId Method id to search for\n * @param typeId Type id to search for\n * @param sourcerer Function to format source code link\n */\nexport const findDeclaration = (\n lode: IDeclarationMine,\n methodId?: string,\n typeId?: string,\n sourcerer: SourceLink = permaLink\n) => {\n let declaration\n if (methodId) {\n declaration = lode.methods[methodId]\n } else if (typeId) {\n declaration = lode.types[typeId]\n }\n\n let link\n if (declaration) {\n link = sourcerer(\n lode.remoteOrigin,\n lode.commitHash,\n declaration.sourceFile,\n declaration.line\n )\n // link = ideLink(parentPath, declaration.sourceFile, declaration.line)\n }\n return { declaration, link }\n}\n"],"file":"declarationInfo.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/codeGenerators.ts"],"names":["CSharpGen","KotlinGen","SwiftGen","PythonGen","TypescriptGen","GoGen","Generators","factory","api","versions","language","extension","legacy","options","codeGenerators","filter","x","undefined","findGenerator","target","toLocaleLowerCase","find","item","match","getCodeGenerator","generator","legacyLanguages"],"mappings":"AA4BA,SAASA,SAAT,QAA0B,cAA1B;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,QAAT,QAAyB,aAAzB;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,aAAT,QAA8B,kBAA9B;AACA,SAASC,KAAT,QAAsB,UAAtB;AAkBA,OAAO,IAAMC,UAAiC,GAAG,CAC/C;AACEC,EAAAA,OAAO,EAAE,CAACC,GAAD,EAAgBC,QAAhB,KACP,IAAIN,SAAJ,CAAcK,GAAd,EAAmBC,QAAnB,CAFJ;AAGEC,EAAAA,QAAQ,EAAE,QAHZ;AAIEC,EAAAA,SAAS,EAAE;AAJb,C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AA,QAAQ,EAAE,KADZ;AAEEE,EAAAA,MAAM,EAAE,KAFV;AAGEC,EAAAA,OAAO,EAAE,0CAHX;AAIEF,EAAAA,SAAS,EAAE;AAJb,CA9C+C,CAA1C;AAsEP,OAAO,IAAMG,cAAc,GAAGR,UAAU,CAACS,MAAX,CAAmBC,CAAD,IAAOA,CAAC,CAACT,OAAF,KAAcU,SAAvC,CAAvB;AAOP,OAAO,IAAMC,aAAa,GAAIC,MAAD,IAAoB;AAC/CA,EAAAA,MAAM,GAAGA,MAAM,CAACC,iBAAP,EAAT;AAEA,SAAON,cAAc,CAACO,IAAf,CACJC,IAAD;AAAA;;AAAA,WACEA,IAAI,CAACZ,QAAL,CAAcU,iBAAd,OAAsCD,MAAtC,IACAA,MAAM,CAACI,KAAP,CAAaD,IAAI,CAACX,SAAlB,CADA,IAEA,CAAC,MAAMQ,MAAP,EAAeI,KAAf,CAAqBD,IAAI,CAACX,SAA1B,CAFA,IAGA,iBAAAW,IAAI,CAACV,MAAL,8DAAaQ,iBAAb,QAAqCD,MAJvC;AAAA,GADK,CAAP;AAOD,CAVM;AAwBP,OAAO,IAAMK,gBAAgB,GAAG,CAC9Bd,QAD8B,EAE9BF,GAF8B,EAG9BC,QAH8B,KAIL;AACzB,MAAMgB,SAAS,GAAGP,aAAa,CAACR,QAAD,CAA/B;;AACA,MAAIe,SAAS,IAAIA,SAAS,CAAClB,OAA3B,EAAoC;AAClC,WAAOkB,SAAS,CAAClB,OAAV,CAAkBC,GAAlB,EAAuBC,QAAvB,CAAP;AACD;;AACD,SAAOQ,SAAP;AACD,CAVM;AAYP,OAAO,IAAMS,eAAe,GAAG,MAA6B;AAC1D,SAAOpB,UAAU,CAACS,MAAX,CAAmBC,CAAD,IAAO,CAAC,CAACA,CAAC,CAACJ,MAA7B,CAAP;AACD,CAFM","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 { ApiModel } from './sdkModels'\nimport type { ICodeGen, IVersionInfo } from './codeGen'\nimport { CSharpGen } from './csharp.gen'\nimport { KotlinGen } from './kotlin.gen'\nimport { SwiftGen } from './swift.gen'\nimport { PythonGen } from './python.gen'\nimport { TypescriptGen } from './typescript.gen'\nimport { GoGen } from './go.gen'\n\nexport interface IGeneratorSpec {\n /** source code file extension regex */\n extension: RegExp\n /** name of language SDK to generate */\n language: string\n /** path name for legacy generator output. Defaults to language */\n path?: string\n /** code generator constructor */\n factory?: (api: ApiModel, versions?: IVersionInfo) => ICodeGen\n /** options for the legacy code generator */\n options?: string\n /** name of the legacy language generator */\n legacy?: string // legacy language tag\n}\n\n// To disable generation of any language specification,
|
|
1
|
+
{"version":3,"sources":["../../src/codeGenerators.ts"],"names":["CSharpGen","KotlinGen","SwiftGen","PythonGen","TypescriptGen","GoGen","Generators","factory","api","versions","language","extension","legacy","options","codeGenerators","filter","x","undefined","findGenerator","target","toLocaleLowerCase","find","item","match","getCodeGenerator","generator","legacyLanguages"],"mappings":"AA4BA,SAAS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AIe,SAAS,IAAIA,SAAS,CAAClB,OAA3B,EAAoC;AAClC,WAAOkB,SAAS,CAAClB,OAAV,CAAkBC,GAAlB,EAAuBC,QAAvB,CAAP;AACD;;AACD,SAAOQ,SAAP;AACD,CAVM;AAYP,OAAO,IAAMS,eAAe,GAAG,MAA6B;AAC1D,SAAOpB,UAAU,CAACS,MAAX,CAAmBC,CAAD,IAAO,CAAC,CAACA,CAAC,CAACJ,MAA7B,CAAP;AACD,CAFM","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 { ApiModel } from './sdkModels'\nimport type { ICodeGen, IVersionInfo } from './codeGen'\nimport { CSharpGen } from './csharp.gen'\nimport { KotlinGen } from './kotlin.gen'\nimport { SwiftGen } from './swift.gen'\nimport { PythonGen } from './python.gen'\nimport { TypescriptGen } from './typescript.gen'\nimport { GoGen } from './go.gen'\n\nexport interface IGeneratorSpec {\n /** source code file extension regex */\n extension: RegExp\n /** name of language SDK to generate */\n language: string\n /** path name for legacy generator output. Defaults to language */\n path?: string\n /** code generator constructor */\n factory?: (api: ApiModel, versions?: IVersionInfo) => ICodeGen\n /** options for the legacy code generator */\n options?: string\n /** name of the legacy language generator */\n legacy?: string // legacy language tag\n}\n\n// To disable generation of any language specification, just comment it out\nexport const Generators: Array<IGeneratorSpec> = [\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new PythonGen(api, versions),\n language: 'Python',\n extension: /\\.py/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new TypescriptGen(api, versions),\n language: 'TypeScript',\n extension: /\\.ts(x?)/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new KotlinGen(api, versions),\n language: 'Kotlin',\n extension: /\\.kt/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new CSharpGen(api, versions),\n language: 'C#',\n legacy: 'csharp',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.cs/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new SwiftGen(api, versions),\n language: 'Swift',\n extension: /\\.swift/gi,\n },\n {\n factory: (api: ApiModel, versions?: IVersionInfo) =>\n new GoGen(api, versions),\n language: 'Go',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.go/gi,\n },\n {\n language: 'java',\n legacy: 'java',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.java/gi,\n },\n {\n language: 'php',\n legacy: 'php',\n options: '-papiPackage=Looker -ppackageName=looker',\n extension: /\\.php/gi,\n },\n // {\n // language: 'R',\n // legacy: 'r'\n // options: '-papiPackage=Looker -ppackageName=looker'\n // extension: /\\.r/gi,\n // },\n // {\n // language: 'Ruby',\n // options: '-papiPackage=Looker -ppackageName=looker'\n // extension: /\\.rb/gi,\n // },\n // {\n // language: 'Rust',\n // options: '-papiPackage=Looker -ppackageName=looker'\n // extension: /\\.rs/gi,\n // },\n]\n\nexport const codeGenerators = Generators.filter((x) => x.factory !== undefined)\n\n/**\n * Matches the code generator based on the language name, alias, file extension, or legacy name\n * @param target label/language/file extension to find in the generator list\n * @returns undefined if the label/language/extension isn't found, otherwise the generator entry\n */\nexport const findGenerator = (target: string) => {\n target = target.toLocaleLowerCase()\n // Convenience alias\n return codeGenerators.find(\n (item) =>\n item.language.toLocaleLowerCase() === target ||\n target.match(item.extension) ||\n ('.' + target).match(item.extension) ||\n item.legacy?.toLocaleLowerCase() === target\n )\n}\n\n/**\n * constructs a language generator by name lookup\n *\n * CodeGenerator settings can be overridden by creating a config file and adding an entry for the desired language\n *\n * See the `config` folder in this package for more sample config files\n *\n * @param language name, file extension, or alias of code language to generate\n * @param api API specification\n * @param versions version info to use for stamping the agentTag\n * @returns either an ICodeGen implementation or undefined\n */\nexport const getCodeGenerator = (\n language: string,\n api: ApiModel,\n versions?: IVersionInfo\n): ICodeGen | undefined => {\n const generator = findGenerator(language)\n if (generator && generator.factory) {\n return generator.factory(api, versions)\n }\n return undefined\n}\n\nexport const legacyLanguages = (): Array<IGeneratorSpec> => {\n return Generators.filter((x) => !!x.legacy)\n}\n"],"file":"codeGenerators.js"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { permaLink } from './exampleInfo';
|
|
2
|
-
export var findDeclaration = (lode, methodId, typeId)
|
|
2
|
+
export var findDeclaration = function findDeclaration(lode, methodId, typeId) {
|
|
3
|
+
var sourcerer = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : permaLink;
|
|
3
4
|
var declaration;
|
|
4
5
|
|
|
5
6
|
if (methodId) {
|
|
@@ -11,7 +12,7 @@ export var findDeclaration = (lode, methodId, typeId) => {
|
|
|
11
12
|
var link;
|
|
12
13
|
|
|
13
14
|
if (declaration) {
|
|
14
|
-
link =
|
|
15
|
+
link = sourcerer(lode.remoteOrigin, lode.commitHash, declaration.sourceFile, declaration.line);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/declarationInfo.ts"],"names":["permaLink","findDeclaration","lode","methodId","typeId","declaration","methods","types","link","remoteOrigin","commitHash","sourceFile","line"],"mappings":"AA0BA,SAASA,SAAT,QAA0B,eAA1B;
|
|
1
|
+
{"version":3,"sources":["../../src/declarationInfo.ts"],"names":["permaLink","findDeclaration","lode","methodId","typeId","sourcerer","declaration","methods","types","link","remoteOrigin","commitHash","sourceFile","line"],"mappings":"AA0BA,SAASA,SAAT,QAA0B,eAA1B;AAqBA,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAC7BC,IAD6B,EAE7BC,QAF6B,EAG7BC,MAH6B,EAK1B;AAAA,MADHC,SACG,uEADqBL,SACrB;AACH,MAAIM,WAAJ;;AACA,MAAIH,QAAJ,EAAc;AACZG,IAAAA,WAAW,GAAGJ,IAAI,CAACK,OAAL,CAAaJ,QAAb,CAAd;AACD,GAFD,MAEO,IAAIC,MAAJ,EAAY;AACjBE,IAAAA,WAAW,GAAGJ,IAAI,CAACM,KAAL,CAAWJ,MAAX,CAAd;AACD;;AAED,MAAIK,IAAJ;;AACA,MAAIH,WAAJ,EAAiB;AACfG,IAAAA,IAAI,GAAGJ,SAAS,CACdH,IAAI,CAACQ,YADS,EAEdR,IAAI,CAACS,UAFS,EAGdL,WAAW,CAACM,UAHE,EAIdN,WAAW,CAACO,IAJE,CAAhB;AAOD;;AACD,SAAO;AAAEP,IAAAA,WAAF;AAAeG,IAAAA;AAAf,GAAP;AACD,CAxBM","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 */\nimport type { IMine, IFileCall, SourceLink } from './exampleInfo'\nimport { permaLink } from './exampleInfo'\nimport type { KeyedCollection } from './sdkModels'\n\n/** All mined declaration data */\nexport interface IDeclarationMine extends IMine {\n types: DeclarationNuggets\n methods: DeclarationNuggets\n}\n\nexport interface IDeclarationNugget extends IFileCall {}\n\nexport type DeclarationNuggets = KeyedCollection<IDeclarationNugget>\n\n/**\n * Searches for declaration of a given method or type and returns a GitHub\n * permalink if found\n * @param lode All declaration data\n * @param methodId Method id to search for\n * @param typeId Type id to search for\n * @param sourcerer Function to format source code link\n */\nexport const findDeclaration = (\n lode: IDeclarationMine,\n methodId?: string,\n typeId?: string,\n sourcerer: SourceLink = permaLink\n) => {\n let declaration\n if (methodId) {\n declaration = lode.methods[methodId]\n } else if (typeId) {\n declaration = lode.types[typeId]\n }\n\n let link\n if (declaration) {\n link = sourcerer(\n lode.remoteOrigin,\n lode.commitHash,\n declaration.sourceFile,\n declaration.line\n )\n // link = ideLink(parentPath, declaration.sourceFile, declaration.line)\n }\n return { declaration, link }\n}\n"],"file":"declarationInfo.js"}
|
package/lib/esm/exampleInfo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export var permaLink = (remote, hash, fileName, line) => "".concat(remote, "/blob/").concat(hash, "/").concat(fileName, "#L").concat(line);
|
|
2
|
+
export var codeSearchLink = (remote, hash, fileName, line) => "".concat(remote, "/").concat(fileName, "?l=").concat(line, "&rcl=").concat(hash);
|
|
2
3
|
export var ideLink = (parentPath, fileName, line) => {
|
|
3
4
|
var vscode = 'vscode://';
|
|
4
5
|
return "".concat(vscode).concat(parentPath, "/").concat(fileName, ":L:").concat(line);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exampleInfo.ts"],"names":["permaLink","remote","hash","fileName","line","ideLink","parentPath","vscode","summarize","lode","call","sourceFile","summaries","summary","exampleLink","link","remoteOrigin","commitHash","permalink","description","tooltip","lineNumber","toString","extensionToLanguage","getLanguageExtensions","language","toLowerCase","findExampleLanguages","methodName","all","nuggets","result","Set","keys","Object","forEach","key","calls","add","Array","from","findExamples","operationId","exts","links","length","ext","push","sort","a","b","localeCompare"],"mappings":"AAsHA,OAAO,IAAMA,SAAS,GAAG,CAEvBC,MAFuB,EAGvBC,IAHuB,EAIvBC,QAJuB,EAKvBC,IALuB,eAMjBH,MANiB,mBAMFC,IANE,cAMMC,QANN,eAMmBC,IANnB,CAAlB;AAcP,OAAO,IAAMC,OAAO,GAAG,CAIrBC,UAJqB,EAKrBH,QALqB,EAMrBC,IANqB,KAOlB;AAEH,MAAMG,MAAM,GAAG,WAAf;AAEA,mBAAUA,MAAV,SAAmBD,UAAnB,cAAiCH,QAAjC,gBAA+CC,IAA/C;AACD,CAZM;AAmBP,OAAO,IAAMI,SAAS,GAAG,CAACC,IAAD,EAAqBC,IAArB,KAAiD;AACxE,MAAIA,IAAI,CAACC,UAAL,IAAmBF,IAAI,CAACG,SAA5B,EAAuC;AACrC,WAAOH,IAAI,CAACG,SAAL,CAAeF,IAAI,CAACC,UAApB,EAAgCE,OAAvC;AACD;;AAED,SAAOH,IAAI,CAACC,UAAZ;AACD,CANM;AAaP,OAAO,IAAMG,WAAW,GAAG,CACzBL,IADyB,EAEzBC,IAFyB,KAGR;AACjB,MAAMK,IAAI,GAAGf,SAAS,CACpBS,IAAI,CAACO,YADe,EAEpBP,IA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,SAAOkC,KAAK,CAACI,IAAN,CAAW,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC/B,SAAF,CAAYiC,aAAZ,CAA0BD,CAAC,CAAChC,SAA5B,CAArB,CAAP;AACD,CAvBM","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 { KeyedCollection } from './sdkModels'\n\nexport interface ISDKCall {\n /** SDK variable name for the call found */\n sdk: string\n\n /** Name of the method/operationId */\n operationId: string\n\n /** Source code line number */\n line: number\n\n /** Source code column number where method name was found */\n column: number\n}\n\nexport interface IExampleLink {\n /** Either summary from .md documentation or the name of the source file */\n description: string\n /** permalink to file and line number */\n permalink: string\n /** text to show on hover */\n tooltip: string\n /** line number text */\n lineNumber: string\n}\n\nexport type SDKCalls = ISDKCall[]\n\nexport interface ISummary {\n /** relative file name */\n sourceFile: string\n /** summary extracted from md, rst, or other doc file */\n summary: string\n}\n\nexport type Summaries = KeyedCollection<ISummary>\n\nexport interface IFileCall {\n /** relative file name */\n sourceFile: string\n /** line number for source code call */\n line: number\n /** Optional column number for source code call. Maybe we don't need this datum */\n column?: number\n}\n\n/**\n { \"me\": {\n \".ts\": {\n [\n {\n \"hash\": \"TODO\",\n \"sourceFile\": \"foo.ts\",\n \"line\": 1,\n \"column\": 5,\n }\n ]\n }\n }\n}\n */\n\nexport type FileCalls = IFileCall[]\n\nexport type LanguageCalls = KeyedCollection<FileCalls>\n\nexport interface INugget {\n operationId: string\n calls: LanguageCalls\n}\n\nexport type Nuggets = KeyedCollection<INugget>\n\nexport interface IMine {\n commitHash: string\n remoteOrigin: string\n}\n\n/** All mined example data */\nexport interface IExampleMine extends IMine {\n summaries: Summaries\n nuggets: Nuggets\n}\n\n/**\n * Create a permalink for a github file with line number\n * @param remote https url for repository\n * @param hash commit hash\n * @param fileName name of file\n * @param line line number in file\n */\nexport const permaLink = (\n // https://github.com/looker-open-source/sdk-codegen/blob/bfca52d2c8ba85018f76548158fd1dd90aa1f64a/examples/typescript/customConfigReader.ts#L53\n remote: string,\n hash: string,\n fileName: string,\n line: number\n) => `${remote}/blob/${hash}/${fileName}#L${line}`\n\n/**\n * Create an IDE file link with line number\n * @param parentPath to fully qualify the source file\n * @param fileName full name of file\n * @param line line number in file\n */\nexport const ideLink = (\n // https://plugins.jetbrains.com/plugin/6027-remote-call\n // https://github.com/microsoft/vscode/issues/4883#issuecomment-270141535\n // pattern:\n parentPath: string,\n fileName: string,\n line: number\n) => {\n // const idea = 'http//localhost:8091'\n const vscode = 'vscode://'\n\n return `${vscode}${parentPath}/${fileName}:L:${line}`\n}\n\n/**\n * Gets the summary for an example file, or defaults to the file and line number\n * @param lode all mined example data\n * @param call specific call to summarize\n */\nexport const summarize = (lode: IExampleMine, call: IFileCall): string => {\n if (call.sourceFile in lode.summaries) {\n return lode.summaries[call.sourceFile].summary\n }\n // Default to file name if no summary is found\n return call.sourceFile\n}\n\n/**\n * Provides permalink and description for an example file call\n * @param lode all mined example data\n * @param call specific all to link\n */\nexport const exampleLink = (\n lode: IExampleMine,\n call: IFileCall\n): IExampleLink => {\n const link = permaLink(\n lode.remoteOrigin,\n lode.commitHash,\n call.sourceFile,\n call.line\n )\n\n return {\n permalink: link,\n description: summarize(lode, call),\n tooltip: `${call.sourceFile} line ${call.line}`,\n lineNumber: call.line.toString(),\n }\n}\n\n// TODO create one data set for extensionToLanguage and getLanguageExtensions\n/** map file extension to language name */\nexport const extensionToLanguage = {\n '.py': 'Python',\n '.ts': 'TypeScript',\n '.tsx': 'TypeScript',\n '.cs': 'C#',\n '.kt': 'Kotlin',\n '.swift': 'Swift',\n '.rb': 'Ruby',\n '.dart': 'Dart',\n '.go': 'Go',\n '.md': 'Markdown',\n '.java': 'Java',\n}\n\n/**\n * Return the recognized file extensions for the requested language\n * @param language\n */\nexport const getLanguageExtensions = (language: string): string[] => {\n switch (language.toLowerCase()) {\n case 'ts':\n case 'typescript':\n return ['.ts', 'tsx']\n case 'csharp':\n case 'c#':\n return ['.cs']\n case 'ruby':\n return ['.rb']\n case 'python':\n return ['.py']\n case 'swift':\n return ['.swift']\n case 'kotlin':\n return ['.kt']\n case 'dart':\n return ['.dart']\n case 'go':\n return ['.go']\n case 'java':\n return ['.java']\n default:\n return []\n }\n}\n\nexport const findExampleLanguages = (\n lode: IExampleMine,\n methodName: string\n) => {\n const all = lode.nuggets[methodName]\n if (!all) return []\n const result = new Set<string>()\n const keys = Object.keys(extensionToLanguage)\n keys.forEach((key) => {\n if (all.calls[key]) result.add(extensionToLanguage[key])\n })\n return Array.from(result)\n}\n\n/**\n * Searches for examples containing operationId usages in the given language\n * @param lode All example data\n * @param language Language example should be in\n * @param operationId Method's operationId to search for\n */\nexport const findExamples = (\n lode: IExampleMine,\n language: string,\n operationId: string\n): IExampleLink[] => {\n const all = lode.nuggets[operationId]\n const exts = getLanguageExtensions(language)\n const links: IExampleLink[] = []\n\n if (all && exts.length > 0) {\n exts.forEach((ext) => {\n const calls = all.calls[ext]\n if (calls) {\n calls.forEach((call: IFileCall) => {\n const link = exampleLink(lode, call)\n if (link) {\n links.push(exampleLink(lode, call))\n }\n })\n }\n })\n }\n return links.sort((a, b) => a.permalink.localeCompare(b.permalink))\n}\n"],"file":"exampleInfo.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/exampleInfo.ts"],"names":["permaLink","remote","hash","fileName","line","codeSearchLink","ideLink","parentPath","vscode","summarize","lode","call","sourceFile","summaries","summary","exampleLink","link","remoteOrigin","commitHash","permalink","description","tooltip","lineNumber","toString","extensionToLanguage","getLanguageExtensions","language","toLowerCase","findExampleLanguages","methodName","all","nuggets","result","Set","keys","Object","forEach","key","calls","add","Array","from","findExamples","operationId","exts","links","length","ext","push","sort","a","b","localeCompare"],"mappings":"AA8HA,OAAO,IAAMA,SAAqB,GAAG,CAEnCC,MAFmC,EAGnCC,IAHmC,EAInCC,QAJmC,EAKnCC,IALmC,eAM7BH,MAN6B,mBAMdC,IANc,cAMNC,QANM,eAMOC,IANP,CAA9B;AAeP,OAAO,IAAMC,cAA0B,GAAG,CACxCJ,MADwC,EAExCC,IAFwC,EAGxCC,QAHwC,EAIxCC,IAJwC,eAKlCH,MALkC,cAKxBE,QALwB,gBAKVC,IALU,kBAKEF,IALF,CAAnC;AAaP,OAAO,IAAMI,OAAO,GAAG,CAIrBC,UAJqB,EAKrBJ,QALqB,EAMrBC,IANqB,KAOlB;AAEH,MAAMI,MAAM,GAAG,WAAf;AAEA,mBAAUA,MAAV,SAAmBD,UAAnB,cAAiCJ,QAAjC,gBAA+CC,IAA/C;AACD,CAZM;AAmBP,OAAO,IAAMK,SAAS,GAAG,CAACC,IAAD,EAAqBC,IAArB,KAAiD;AACxE,MAAIA,IAAI,CAACC,UAAL,IAAmBF,IAAI,CAACG,SAA5B,EAAuC;AACrC,WAAOH,IAAI,CAACG,SAAL,CAAeF,IAAI,CAACC,UAApB,EAAgCE,OAAvC;AACD;;AAED,SAAOH,IAAI,CAACC,UAAZ;AACD,CANM;AAaP,OA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AAU;AACR6B,YAAAA,KAAK,CAACG,IAAN,CAAWjC,WAAW,CAACL,IAAD,EAAOC,IAAP,CAAtB;AACD;AACF,SALD;AAMD;AACF,KAVD;AAWD;;AACD,SAAOkC,KAAK,CAACI,IAAN,CAAW,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAAC/B,SAAF,CAAYiC,aAAZ,CAA0BD,CAAC,CAAChC,SAA5B,CAArB,CAAP;AACD,CAvBM","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 { KeyedCollection } from './sdkModels'\n\nexport interface ISDKCall {\n /** SDK variable name for the call found */\n sdk: string\n\n /** Name of the method/operationId */\n operationId: string\n\n /** Source code line number */\n line: number\n\n /** Source code column number where method name was found */\n column: number\n}\n\nexport interface IExampleLink {\n /** Either summary from .md documentation or the name of the source file */\n description: string\n /** permalink to file and line number */\n permalink: string\n /** text to show on hover */\n tooltip: string\n /** line number text */\n lineNumber: string\n}\n\nexport type SDKCalls = ISDKCall[]\n\nexport interface ISummary {\n /** relative file name */\n sourceFile: string\n /** summary extracted from md, rst, or other doc file */\n summary: string\n}\n\nexport type Summaries = KeyedCollection<ISummary>\n\nexport interface IFileCall {\n /** relative file name */\n sourceFile: string\n /** line number for source code call */\n line: number\n /** Optional column number for source code call. Maybe we don't need this datum */\n column?: number\n}\n\n/**\n { \"me\": {\n \".ts\": {\n [\n {\n \"hash\": \"TODO\",\n \"sourceFile\": \"foo.ts\",\n \"line\": 1,\n \"column\": 5,\n }\n ]\n }\n }\n}\n */\n\nexport type FileCalls = IFileCall[]\n\nexport type LanguageCalls = KeyedCollection<FileCalls>\n\nexport interface INugget {\n operationId: string\n calls: LanguageCalls\n}\n\nexport type Nuggets = KeyedCollection<INugget>\n\nexport interface IMine {\n commitHash: string\n remoteOrigin: string\n}\n\n/** All mined example data */\nexport interface IExampleMine extends IMine {\n summaries: Summaries\n nuggets: Nuggets\n}\n\n/** function type for formatting source code links */\nexport type SourceLink = (\n remote: string,\n hash: string,\n fileName: string,\n line: number\n) => string\n\n/**\n * Create a permalink for a github file with line number\n * @param remote https url for repository\n * @param hash commit hash\n * @param fileName name of file\n * @param line line number in file\n */\nexport const permaLink: SourceLink = (\n // https://github.com/looker-open-source/sdk-codegen/blob/bfca52d2c8ba85018f76548158fd1dd90aa1f64a/examples/typescript/customConfigReader.ts#L53\n remote: string,\n hash: string,\n fileName: string,\n line: number\n) => `${remote}/blob/${hash}/${fileName}#L${line}`\n\n/**\n * Create a permalink for a code search with commit hash and line number\n * @param remote https url for repository\n * @param hash commit hash\n * @param fileName name of file\n * @param line line number in file\n */\nexport const codeSearchLink: SourceLink = (\n remote: string,\n hash: string,\n fileName: string,\n line: number\n) => `${remote}/${fileName}?l=${line}&rcl=${hash}`\n\n/**\n * Create an IDE file link with line number\n * @param parentPath to fully qualify the source file\n * @param fileName full name of file\n * @param line line number in file\n */\nexport const ideLink = (\n // https://plugins.jetbrains.com/plugin/6027-remote-call\n // https://github.com/microsoft/vscode/issues/4883#issuecomment-270141535\n // pattern:\n parentPath: string,\n fileName: string,\n line: number\n) => {\n // const idea = 'http//localhost:8091'\n const vscode = 'vscode://'\n\n return `${vscode}${parentPath}/${fileName}:L:${line}`\n}\n\n/**\n * Gets the summary for an example file, or defaults to the file and line number\n * @param lode all mined example data\n * @param call specific call to summarize\n */\nexport const summarize = (lode: IExampleMine, call: IFileCall): string => {\n if (call.sourceFile in lode.summaries) {\n return lode.summaries[call.sourceFile].summary\n }\n // Default to file name if no summary is found\n return call.sourceFile\n}\n\n/**\n * Provides permalink and description for an example file call\n * @param lode all mined example data\n * @param call specific all to link\n */\nexport const exampleLink = (\n lode: IExampleMine,\n call: IFileCall\n): IExampleLink => {\n const link = permaLink(\n lode.remoteOrigin,\n lode.commitHash,\n call.sourceFile,\n call.line\n )\n\n return {\n permalink: link,\n description: summarize(lode, call),\n tooltip: `${call.sourceFile} line ${call.line}`,\n lineNumber: call.line.toString(),\n }\n}\n\n// TODO create one data set for extensionToLanguage and getLanguageExtensions\n/** map file extension to language name */\nexport const extensionToLanguage = {\n '.py': 'Python',\n '.ts': 'TypeScript',\n '.tsx': 'TypeScript',\n '.cs': 'C#',\n '.kt': 'Kotlin',\n '.swift': 'Swift',\n '.rb': 'Ruby',\n '.dart': 'Dart',\n '.go': 'Go',\n '.md': 'Markdown',\n '.java': 'Java',\n}\n\n/**\n * Return the recognized file extensions for the requested language\n * @param language\n */\nexport const getLanguageExtensions = (language: string): string[] => {\n switch (language.toLowerCase()) {\n case 'ts':\n case 'typescript':\n return ['.ts', 'tsx']\n case 'csharp':\n case 'c#':\n return ['.cs']\n case 'ruby':\n return ['.rb']\n case 'python':\n return ['.py']\n case 'swift':\n return ['.swift']\n case 'kotlin':\n return ['.kt']\n case 'dart':\n return ['.dart']\n case 'go':\n return ['.go']\n case 'java':\n return ['.java']\n default:\n return []\n }\n}\n\nexport const findExampleLanguages = (\n lode: IExampleMine,\n methodName: string\n) => {\n const all = lode.nuggets[methodName]\n if (!all) return []\n const result = new Set<string>()\n const keys = Object.keys(extensionToLanguage)\n keys.forEach((key) => {\n if (all.calls[key]) result.add(extensionToLanguage[key])\n })\n return Array.from(result)\n}\n\n/**\n * Searches for examples containing operationId usages in the given language\n * @param lode All example data\n * @param language Language example should be in\n * @param operationId Method's operationId to search for\n */\nexport const findExamples = (\n lode: IExampleMine,\n language: string,\n operationId: string\n): IExampleLink[] => {\n const all = lode.nuggets[operationId]\n const exts = getLanguageExtensions(language)\n const links: IExampleLink[] = []\n\n if (all && exts.length > 0) {\n exts.forEach((ext) => {\n const calls = all.calls[ext]\n if (calls) {\n calls.forEach((call: IFileCall) => {\n const link = exampleLink(lode, call)\n if (link) {\n links.push(exampleLink(lode, call))\n }\n })\n }\n })\n }\n return links.sort((a, b) => a.permalink.localeCompare(b.permalink))\n}\n"],"file":"exampleInfo.js"}
|
package/lib/esm/sdkModels.js
CHANGED
|
@@ -1275,8 +1275,6 @@ export class ApiModel {
|
|
|
1275
1275
|
constructor(spec) {
|
|
1276
1276
|
this.spec = spec;
|
|
1277
1277
|
|
|
1278
|
-
_defineProperty(this, "requestTypes", {});
|
|
1279
|
-
|
|
1280
1278
|
_defineProperty(this, "enumTypes", {});
|
|
1281
1279
|
|
|
1282
1280
|
_defineProperty(this, "refs", {});
|
|
@@ -1507,11 +1505,14 @@ export class ApiModel {
|
|
|
1507
1505
|
throw new Error("Schema ".concat(typeof schema === 'string' ? schema : JSON.stringify(schema), " must have a ref or a type"));
|
|
1508
1506
|
}
|
|
1509
1507
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1508
|
+
requestTypeName(method) {
|
|
1509
|
+
return "".concat(strRequest).concat(camelCase('_' + method.name));
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
makeRequestType(method) {
|
|
1513
|
+
var name = this.requestTypeName(method);
|
|
1512
1514
|
var request = new RequestType(this, name, method.allParams, "Dynamically generated request type for ".concat(method.name));
|
|
1513
1515
|
this.types[name] = request;
|
|
1514
|
-
this.requestTypes[hash] = request;
|
|
1515
1516
|
method.addType(this, request);
|
|
1516
1517
|
return request;
|
|
1517
1518
|
}
|
|
@@ -1544,11 +1545,8 @@ export class ApiModel {
|
|
|
1544
1545
|
|
|
1545
1546
|
_getRequestType(method) {
|
|
1546
1547
|
if (method.optionalParams.length <= 1) return undefined;
|
|
1547
|
-
var
|
|
1548
|
-
|
|
1549
|
-
var hash = md5(paramHash);
|
|
1550
|
-
var result = this.requestTypes[hash];
|
|
1551
|
-
if (!result) result = this.makeRequestType(hash, method);
|
|
1548
|
+
var result = this.types[this.requestTypeName(method)];
|
|
1549
|
+
if (!result) result = this.makeRequestType(method);
|
|
1552
1550
|
return result;
|
|
1553
1551
|
}
|
|
1554
1552
|
|
|
@@ -1563,10 +1561,9 @@ export class ApiModel {
|
|
|
1563
1561
|
return this.enumTypes;
|
|
1564
1562
|
}
|
|
1565
1563
|
|
|
1566
|
-
makeWriteableType(
|
|
1564
|
+
makeWriteableType(type) {
|
|
1567
1565
|
var writer = new WriteType(this, type);
|
|
1568
1566
|
this.types[writer.name] = writer;
|
|
1569
|
-
this.requestTypes[hash] = writer;
|
|
1570
1567
|
return writer;
|
|
1571
1568
|
}
|
|
1572
1569
|
|
|
@@ -1596,10 +1593,7 @@ export class ApiModel {
|
|
|
1596
1593
|
}
|
|
1597
1594
|
|
|
1598
1595
|
if (writes.length === props.length && JSON.stringify(writes) === JSON.stringify(props)) return undefined;
|
|
1599
|
-
var
|
|
1600
|
-
var result = this.requestTypes[hash];
|
|
1601
|
-
if (result) return result;
|
|
1602
|
-
result = this.makeWriteableType(hash, type);
|
|
1596
|
+
var result = this.makeWriteableType(type);
|
|
1603
1597
|
type.types.add(result.name);
|
|
1604
1598
|
type.customTypes.add(result.name);
|
|
1605
1599
|
result.parentTypes.add(type.name);
|