@looker/sdk-codegen-scripts 21.5.42 → 21.5.44

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/convert.apispec.js +3 -3
  3. package/lib/convert.apispec.js.map +1 -1
  4. package/lib/convert.js.map +1 -1
  5. package/lib/declarationMiner.js +6 -6
  6. package/lib/declarationMiner.js.map +1 -1
  7. package/lib/esm/convert.apispec.js +2 -2
  8. package/lib/esm/convert.apispec.js.map +1 -1
  9. package/lib/esm/convert.js.map +1 -1
  10. package/lib/esm/declarationMiner.js +5 -5
  11. package/lib/esm/declarationMiner.js.map +1 -1
  12. package/lib/esm/exampleMiner.js +6 -5
  13. package/lib/esm/exampleMiner.js.map +1 -1
  14. package/lib/esm/fetchSpec.apispec.js +2 -2
  15. package/lib/esm/fetchSpec.apispec.js.map +1 -1
  16. package/lib/esm/fetchSpec.js +12 -12
  17. package/lib/esm/fetchSpec.js.map +1 -1
  18. package/lib/esm/index.js.map +1 -1
  19. package/lib/esm/languages.js.map +1 -1
  20. package/lib/esm/legacy.js +2 -2
  21. package/lib/esm/legacy.js.map +1 -1
  22. package/lib/esm/legacyGenerator.js +2 -2
  23. package/lib/esm/legacyGenerator.js.map +1 -1
  24. package/lib/esm/nodeUtils.js.map +1 -1
  25. package/lib/esm/prettify.js +2 -2
  26. package/lib/esm/prettify.js.map +1 -1
  27. package/lib/esm/reformatter.js +2 -2
  28. package/lib/esm/reformatter.js.map +1 -1
  29. package/lib/esm/sdkConfig.js.map +1 -1
  30. package/lib/esm/sdkGen.js +2 -2
  31. package/lib/esm/sdkGen.js.map +1 -1
  32. package/lib/esm/sdkGenerator.js +2 -2
  33. package/lib/esm/sdkGenerator.js.map +1 -1
  34. package/lib/esm/specConvert.js +2 -2
  35. package/lib/esm/specConvert.js.map +1 -1
  36. package/lib/esm/utils.js +4 -4
  37. package/lib/esm/utils.js.map +1 -1
  38. package/lib/esm/yamlToJson.js.map +1 -1
  39. package/lib/exampleMiner.js +7 -8
  40. package/lib/exampleMiner.js.map +1 -1
  41. package/lib/fetchSpec.apispec.js +3 -3
  42. package/lib/fetchSpec.apispec.js.map +1 -1
  43. package/lib/fetchSpec.js +12 -12
  44. package/lib/fetchSpec.js.map +1 -1
  45. package/lib/index.js.map +1 -1
  46. package/lib/languages.js +1 -1
  47. package/lib/languages.js.map +1 -1
  48. package/lib/legacy.js +2 -2
  49. package/lib/legacy.js.map +1 -1
  50. package/lib/legacyGenerator.js +2 -2
  51. package/lib/legacyGenerator.js.map +1 -1
  52. package/lib/nodeUtils.js +2 -3
  53. package/lib/nodeUtils.js.map +1 -1
  54. package/lib/prettify.js +3 -4
  55. package/lib/prettify.js.map +1 -1
  56. package/lib/reformatter.js +3 -4
  57. package/lib/reformatter.js.map +1 -1
  58. package/lib/sdkConfig.js +2 -3
  59. package/lib/sdkConfig.js.map +1 -1
  60. package/lib/sdkGen.js +4 -5
  61. package/lib/sdkGen.js.map +1 -1
  62. package/lib/sdkGenerator.js +3 -4
  63. package/lib/sdkGenerator.js.map +1 -1
  64. package/lib/specConvert.js +3 -4
  65. package/lib/specConvert.js.map +1 -1
  66. package/lib/utils.js +4 -4
  67. package/lib/utils.js.map +1 -1
  68. package/lib/yamlToJson.js +1 -2
  69. package/lib/yamlToJson.js.map +1 -1
  70. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"convert.apispec.js","names":["readFileSync","describe","it","expect","cloneDeep","isEmpty","LookerNodeSDK","NodeSettingsIniFile","ApiModel","compareSpecs","convertDefs","convertParam","fixConversion","getLookerSpecs","getSpecLinks","getSpecsFromVersions","loadSpecs","openApiStyle","specToModel","swapXLookerTags","upgradeSpec","TestConfig","testFile","swaggerFrag","openApiFrag","specFrag","swagger","JSON","parse","api","config","swaggerFile","apiFile","swaggerSource","fullSwagger","apiSource","settings","localIni","sdk","init40","baseUrl","authSession","base_url","actual","toContain","not","toEqual","toBeUndefined","spec","fixes","toHaveLength","onlyPublic","specs","filter","v","status","_asyncToGenerator","toBeDefined","looker_release_version","current_version","version","supported","supported_versions","versions","forEach","name","url","current","find","s","links","link","replace","substring","indexOf","description","op","paths","get","param","parameters","expected","defs","definitions","keys","Object","length","skip","left","fromString","right","diff","full_version","swagger_url","api_server_url","entries","_ref6","_","a","isDefault","moar","push"],"sources":["../../src/convert.apispec.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 { readFileSync } from 'fs';\nimport { describe, it } from 'node:test';\nimport { expect } from 'expect';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport { LookerNodeSDK, NodeSettingsIniFile } from '@looker/sdk-node';\nimport type { ISpecItem } from '@looker/sdk-codegen';\nimport {\n ApiModel,\n compareSpecs,\n convertDefs,\n convertParam,\n fixConversion,\n getLookerSpecs,\n getSpecLinks,\n getSpecsFromVersions,\n loadSpecs,\n openApiStyle,\n specToModel,\n swapXLookerTags,\n upgradeSpec,\n} from '@looker/sdk-codegen';\nimport { TestConfig, testFile } from '@looker/sdk-codegen-utils';\n\nconst swaggerFrag = `\n{\n \"paths\": {\n \"/query_tasks/multi_results\": {\n \"get\": {\n \"tags\": [\"Query\"],\n \"operationId\": \"query_task_multi_results\",\n \"summary\": \"Get Multiple Async Query Results\",\n \"description\": \"### Fetch results of multiple async queries\\\\n\\\\nReturns the results of multiple async queries in one request.\\\\n\\\\nFor Query Tasks that are not completed, the response will include the execution status of the Query Task but will not include query results.\\\\nQuery Tasks whose results have expired will have a status of 'expired'.\\\\nIf the user making the API request does not have sufficient privileges to view a Query Task result, the result will have a status of 'missing'\\\\n\",\n \"parameters\": [\n {\n \"name\": \"query_task_ids\",\n \"in\": \"query\",\n \"description\": \"List of Query Task IDs\",\n \"required\": true,\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"collectionFormat\": \"csv\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Multiple query results\",\n \"schema\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"db_query\"\n }\n },\n \"/dashboards/{lookml_dashboard_id}/import/{space_id}\": {\n \"post\": {\n \"tags\": [\"Dashboard\"],\n \"operationId\": \"import_lookml_dashboard\",\n \"summary\": \"Import LookML Dashboard\",\n \"description\": \"### Import a LookML dashboard to a space as a UDD\\\\nCreates a UDD (a dashboard which exists in the Looker database rather than as a LookML file) from the LookML dashboard\\\\nand puts it in the space specified. The created UDD will have a lookml_link_id which links to the original LookML dashboard.\\\\n\\\\nTo give the imported dashboard specify a (e.g. title: \\\\\"my title\\\\\") in the body of your request, otherwise the imported\\\\ndashboard will have the same title as the original LookML dashboard.\\\\n\\\\nFor this operation to succeed the user must have permission to see the LookML dashboard in question, and have permission to\\\\ncreate content in the space the dashboard is being imported to.\\\\n\\\\n**Sync** a linked UDD with [sync_lookml_dashboard()](#!/Dashboard/sync_lookml_dashboard)\\\\n**Unlink** a linked UDD by setting lookml_link_id to null with [update_dashboard()](#!/Dashboard/update_dashboard)\\\\n\",\n \"parameters\": [\n {\n \"name\": \"lookml_dashboard_id\",\n \"in\": \"path\",\n \"description\": \"Id of LookML dashboard\",\n \"required\": true,\n \"type\": \"string\"\n },\n {\n \"name\": \"space_id\",\n \"in\": \"path\",\n \"description\": \"Id of space to import the dashboard to\",\n \"required\": true,\n \"type\": \"string\"\n },\n {\n \"name\": \"body\",\n \"in\": \"body\",\n \"description\": \"Dashboard\",\n \"required\": false,\n \"schema\": {\n \"$ref\": \"#/definitions/Dashboard\"\n }\n },\n {\n \"name\": \"raw_locale\",\n \"in\": \"query\",\n \"description\": \"If true, and this dashboard is localized, export it with the raw keys, not localized.\",\n \"required\": false,\n \"type\": \"boolean\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Dashboard\",\n \"schema\": {\n \"$ref\": \"#/definitions/Dashboard\"\n }\n },\n \"201\": {\n \"description\": \"dashboard\",\n \"schema\": {\n \"$ref\": \"#/definitions/Dashboard\"\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"schema\": {\n \"$ref\": \"#/definitions/ValidationError\"\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"non_query\"\n }\n }\n }\n}\n`;\nconst openApiFrag = `\n{\n \"paths\": {\n \"/query_tasks/multi_results\": {\n \"get\": {\n \"tags\": [\"Query\"],\n \"operationId\": \"query_task_multi_results\",\n \"summary\": \"Get Multiple Async Query Results\",\n \"description\": \"### Fetch results of multiple async queries\\\\n\\\\nReturns the results of multiple async queries in one request.\\\\n\\\\nFor Query Tasks that are not completed, the response will include the execution status of the Query Task but will not include query results.\\\\nQuery Tasks whose results have expired will have a status of 'expired'.\\\\nIf the user making the API request does not have sufficient privileges to view a Query Task result, the result will have a status of 'missing'\\\\n\",\n \"parameters\": [\n {\n \"name\": \"query_task_ids\",\n \"in\": \"query\",\n \"description\": \"List of Query Task IDs\",\n \"required\": true,\n \"style\": \"simple\",\n \"explode\": false,\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Multiple query results\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n }\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"db_query\"\n }\n },\n\n \"/dashboards/{lookml_dashboard_id}/import/{space_id}\": {\n \"post\": {\n \"tags\": [\"Dashboard\"],\n \"operationId\": \"import_lookml_dashboard\",\n \"summary\": \"Import LookML Dashboard\",\n \"description\": \"### Import a LookML dashboard to a space as a UDD\\\\nCreates a UDD (a dashboard which exists in the Looker database rather than as a LookML file) from the LookML dashboard\\\\nand puts it in the space specified. The created UDD will have a lookml_link_id which links to the original LookML dashboard.\\\\n\\\\nTo give the imported dashboard specify a (e.g. title: \\\\\"my title\\\\\") in the body of your request, otherwise the imported\\\\ndashboard will have the same title as the original LookML dashboard.\\\\n\\\\nFor this operation to succeed the user must have permission to see the LookML dashboard in question, and have permission to\\\\ncreate content in the space the dashboard is being imported to.\\\\n\\\\n**Sync** a linked UDD with [sync_lookml_dashboard()](#!/Dashboard/sync_lookml_dashboard)\\\\n**Unlink** a linked UDD by setting lookml_link_id to null with [update_dashboard()](#!/Dashboard/update_dashboard)\\\\n\",\n \"parameters\": [\n {\n \"name\": \"lookml_dashboard_id\",\n \"in\": \"path\",\n \"description\": \"Id of LookML dashboard\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"name\": \"space_id\",\n \"in\": \"path\",\n \"description\": \"Id of space to import the dashboard to\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"name\": \"raw_locale\",\n \"in\": \"query\",\n \"description\": \"If true, and this dashboard is localized, export it with the raw keys, not localized.\",\n \"required\": false,\n \"schema\": {\n \"type\": \"boolean\"\n }\n }\n ],\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Dashboard\"\n }\n }\n },\n \"description\": \"Dashboard\"\n },\n \"responses\": {\n \"200\": {\n \"description\": \"Dashboard\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Dashboard\"\n }\n }\n }\n },\n \"201\": {\n \"description\": \"dashboard\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Dashboard\"\n }\n }\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/ValidationError\"\n }\n }\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"non_query\"\n }\n }\n }\n}\n`;\nconst specFrag = `\n\"can\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"boolean\"\n },\n \"readOnly\": true,\n \"description\": \"Operations the current user is able to perform on this object\",\n \"x-looker-nullable\": false\n},\n\"content_favorite_id\": {\n \"type\": \"integer\",\n \"format\": \"int64\",\n \"readOnly\": true,\n \"description\": \"Content Favorite Id\",\n \"x-looker-nullable\": true\n},\n\"content_metadata_id\": {\n \"type\": \"integer\",\n \"format\": \"int64\",\n \"readOnly\": true,\n \"description\": \"Id of content metadata\",\n \"x-looker-nullable\": true\n},\n\"description\": {\n \"type\": \"string\",\n \"readOnly\": true,\n \"description\": \"Description\",\n \"x-looker-nullable\": true\n},\n\"hidden\": {\n \"type\": \"boolean\",\n \"readOnly\": true,\n \"description\": \"Is Hidden\",\n \"x-looker-nullable\": false,\n \"x-looker-deprecated\": true,\n},\n\"supported_formats\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\" },\n \"readOnly\": true,\n \"x-looker-values\": [\n \"txt\",\n \"csv\",\n \"inline_json\",\n \"json\",\n \"json_label\",\n \"json_detail\",\n \"json_detail_lite_stream\",\n \"xlsx\",\n \"html\",\n \"wysiwyg_pdf\",\n \"assembled_pdf\",\n \"wysiwyg_png\",\n \"csv_zip\"\n ],\n \"description\": \"A list of data formats the integration supports. If unspecified, the default is all data formats. Valid values are: \\\\\"txt\\\\\", \\\\\"csv\\\\\", \\\\\"inline_json\\\\\", \\\\\"json\\\\\", \\\\\"json_label\\\\\", \\\\\"json_detail\\\\\", \\\\\"json_detail_lite_stream\\\\\", \\\\\"xlsx\\\\\", \\\\\"html\\\\\", \\\\\"wysiwyg_pdf\\\\\", \\\\\"assembled_pdf\\\\\", \\\\\"wysiwyg_png\\\\\", \\\\\"csv_zip\\\\\".\",\n \"nullable\": false\n},\n`;\n\nconst swagger = JSON.parse(swaggerFrag);\nconst api = JSON.parse(openApiFrag);\n\nconst config = TestConfig(specToModel);\nconst swaggerFile = testFile('Looker.4.0.json');\nconst apiFile = testFile('Looker.4.0.oas.json');\nconst swaggerSource = readFileSync(swaggerFile, 'utf-8');\nconst fullSwagger = JSON.parse(swaggerSource);\nconst apiSource = readFileSync(apiFile, 'utf-8');\nconst settings = new NodeSettingsIniFile(\n 'LOOKERSDK',\n config.localIni,\n 'Looker'\n);\nconst sdk = LookerNodeSDK.init40(settings);\nconst baseUrl = sdk.authSession.settings.base_url;\n\ndescribe('spec conversion', () => {\n it('swaps out x-looker-tags', () => {\n const actual = swapXLookerTags(specFrag);\n expect(actual).toContain('\"nullable\": true');\n expect(actual).not.toContain('\"x-looker-nullable\": true');\n expect(actual).toContain('\"enum\": [');\n expect(actual).not.toContain('\"x-looker-values\": [');\n expect(actual).toContain('\"deprecated\": true');\n expect(actual).not.toContain('\"x-looker-deprecated\"');\n });\n\n it('collectionFormat to style', () => {\n expect(openApiStyle('csv')).toEqual('simple');\n expect(openApiStyle('ssv')).toEqual('spaceDelimited');\n expect(openApiStyle('pipes')).toEqual('pipeDelimited');\n expect(openApiStyle('tabs')).toBeUndefined();\n });\n\n it('fixes missing conversion items', () => {\n const actual = fixConversion(openApiFrag, swaggerFrag);\n expect(actual.spec).toContain(`\"style\":\"simple\"`);\n expect(actual.fixes).not.toHaveLength(0);\n });\n\n describe('spec retrieval', () => {\n const onlyPublic = (specs: ISpecItem[]) => {\n return specs.filter(v => v.status !== 'undocumented');\n };\n\n it('gets looker specs', async () => {\n expect(baseUrl).toBeDefined();\n const actual = await getLookerSpecs(sdk, baseUrl);\n expect(actual).toBeDefined();\n expect(actual.looker_release_version).not.toEqual('');\n expect(actual.current_version.version).not.toEqual('');\n const supported = onlyPublic(actual.supported_versions);\n expect(supported).toHaveLength(1);\n });\n\n it('gets spec links', async () => {\n const versions = await getLookerSpecs(sdk, baseUrl);\n expect(versions).toBeDefined();\n versions.supported_versions = onlyPublic(versions.supported_versions);\n const actual = getSpecLinks(versions);\n expect(actual).toBeDefined();\n /*\n * 23.18 and later only has one API defined\n * expect(actual).toHaveLength(3)\n */\n actual.forEach(spec => {\n expect(spec.name).not.toEqual('');\n expect(spec.version).not.toEqual('');\n expect(spec.status).not.toEqual('');\n expect(spec.url).not.toEqual('');\n expect(isEmpty(spec.api)).toEqual(true);\n });\n const current = actual.find(s => s.status === 'current');\n expect(current).toBeDefined();\n actual.forEach(spec => expect(isEmpty(spec.api)).toEqual(true));\n });\n\n it('fetches and parses all specs', async () => {\n const versions = await getLookerSpecs(sdk, baseUrl);\n expect(versions).toBeDefined();\n versions.supported_versions = onlyPublic(versions.supported_versions);\n const links = getSpecLinks(versions);\n links.forEach(\n link =>\n (link.url = link.url.replace(\n link.url.substring(0, link.url.indexOf('/api/')),\n baseUrl\n ))\n );\n const actual = await loadSpecs(sdk, links);\n expect(actual).toBeDefined();\n /*\n * 23.18 and later only has one API defined\n * expect(actual).toHaveLength(3)\n */\n actual.forEach(spec => {\n expect(isEmpty(spec.api)).toEqual(false);\n expect(spec.api.version).not.toEqual('');\n expect(spec.api.description).not.toEqual('');\n });\n });\n });\n\n describe('spec upgrade', () => {\n it('converts a swagger array param', () => {\n const op = swagger.paths['/query_tasks/multi_results'].get;\n const param = op.parameters[0];\n const actual = convertParam(param);\n expect(actual).toBeDefined();\n const expected =\n api.paths['/query_tasks/multi_results'].get.parameters[0];\n expect(actual).toEqual(expected);\n });\n\n it('converts all definitions', () => {\n const defs = fullSwagger.definitions;\n const actual = convertDefs(defs);\n expect(actual).toBeDefined();\n const keys = Object.keys(actual);\n expect(keys).toHaveLength(Object.keys(defs).length);\n });\n\n /** eslint-disable jest/no-disabled-tests */\n it('matches a reference OpenAPI conversion', { skip: true }, () => {\n // TODO There is a different branch to address this\n const spec = upgradeSpec(swaggerSource);\n expect(spec).toBeDefined();\n const left = ApiModel.fromString(apiSource);\n const right = ApiModel.fromString(spec);\n const diff = compareSpecs(left, right);\n expect(diff).toHaveLength(0);\n });\n\n it('passes through an existing OpenAPI spec', () => {\n const spec = upgradeSpec(apiSource);\n expect(spec).toBeDefined();\n const left = ApiModel.fromString(apiSource);\n const right = ApiModel.fromString(spec);\n const diff = compareSpecs(left, right);\n expect(diff).toHaveLength(0);\n });\n });\n\n describe('getSpecsFromVersions', () => {\n const versions = {\n looker_release_version: '21.3.0',\n current_version: {\n version: '3.1',\n full_version: '3.1.0',\n status: 'current',\n swagger_url: 'http://localhost:19999/api/3.1/swagger.json',\n },\n supported_versions: [\n {\n version: '2.99',\n full_version: '2.99.0',\n status: 'internal_test',\n swagger_url: 'http://localhost:19999/api/2.99/swagger.json',\n },\n {\n version: '3.0',\n full_version: '3.0.0',\n status: 'legacy',\n swagger_url: 'http://localhost:19999/api/3.0/swagger.json',\n },\n {\n version: '3.1',\n full_version: '3.1.0',\n status: 'current',\n swagger_url: 'http://localhost:19999/api/3.1/swagger.json',\n },\n {\n version: '4.0',\n full_version: '4.0.21.3',\n status: 'experimental',\n swagger_url: 'http://localhost:19999/api/4.0/swagger.json',\n },\n ],\n api_server_url: 'http://localhost:19999',\n };\n\n it('only gets supported specifications', async () => {\n const actual = await getSpecsFromVersions(versions);\n expect(Object.keys(actual)).toEqual(['3.1', '4.0']);\n });\n\n it('current is the default spec', async () => {\n const specs = await getSpecsFromVersions(versions);\n const actual = Object.entries(specs).find(\n ([_, a]) => a.status === 'current'\n );\n expect(actual).toBeDefined();\n if (actual) {\n const [, current] = actual;\n expect(current).toBeDefined();\n expect(current.status).toEqual('current');\n expect(current.isDefault).toEqual(true);\n }\n });\n\n it('specs have unique keys', async () => {\n const moar = cloneDeep(versions);\n moar.supported_versions.push(\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/u.json',\n },\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/un.json',\n },\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/un3.json',\n },\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/un4.json',\n }\n );\n const actual = await getSpecsFromVersions(moar);\n expect(Object.keys(actual)).toEqual([\n '3.1',\n '4.0',\n '4.0u',\n '4.0un',\n '4.0un3',\n '4.0un4',\n ]);\n });\n });\n});\n"],"mappings":";;AA0BA,SAASA,YAAY,QAAQ,IAAI;AACjC,SAASC,QAAQ,EAAEC,EAAE,QAAQ,WAAW;AACxC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,SAAS,MAAM,kBAAkB;AACxC,OAAOC,OAAO,MAAM,gBAAgB;AACpC,SAASC,aAAa,EAAEC,mBAAmB,QAAQ,kBAAkB;AAErE,SACEC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZC,oBAAoB,EACpBC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,WAAW,QACN,qBAAqB;AAC5B,SAASC,UAAU,EAAEC,QAAQ,QAAQ,2BAA2B;AAEhE,IAAMC,WAAW,4hKA6HhB;AACD,IAAMC,WAAW,mrMAwKhB;AACD,IAAMC,QAAQ,otDA2Db;AAED,IAAMC,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACL,WAAW,CAAC;AACvC,IAAMM,GAAG,GAAGF,IAAI,CAACC,KAAK,CAACJ,WAAW,CAAC;AAEnC,IAAMM,MAAM,GAAGT,UAAU,CAACH,WAAW,CAAC;AACtC,IAAMa,WAAW,GAAGT,QAAQ,CAAC,iBAAiB,CAAC;AAC/C,IAAMU,OAAO,GAAGV,QAAQ,CAAC,qBAAqB,CAAC;AAC/C,IAAMW,aAAa,GAAGjC,YAAY,CAAC+B,WAAW,EAAE,OAAO,CAAC;AACxD,IAAMG,WAAW,GAAGP,IAAI,CAACC,KAAK,CAACK,aAAa,CAAC;AAC7C,IAAME,SAAS,GAAGnC,YAAY,CAACgC,OAAO,EAAE,OAAO,CAAC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AAC,EACD;QACEjC,OAAO,EAAE,KAAK;QACdgC,YAAY,EAAE,MAAM;QACpBrC,MAAM,EAAE,IAAI;QACZsC,WAAW,EAAE;MACf,CACF,CAAC;MACD,IAAMlD,MAAM,SAAS5B,oBAAoB,CAACqF,IAAI,CAAC;MAC/CjG,MAAM,CAACkF,MAAM,CAACD,IAAI,CAACzC,MAAM,CAAC,CAAC,CAACG,OAAO,CAAC,CAClC,KAAK,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC,EAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"convert.apispec.js","names":["readFileSync","describe","it","expect","cloneDeep","isEmpty","LookerNodeSDK","NodeSettingsIniFile","ApiModel","compareSpecs","convertDefs","convertParam","fixConversion","getLookerSpecs","getSpecLinks","getSpecsFromVersions","loadSpecs","openApiStyle","specToModel","swapXLookerTags","upgradeSpec","TestConfig","testFile","swaggerFrag","openApiFrag","specFrag","swagger","JSON","parse","api","config","swaggerFile","apiFile","swaggerSource","fullSwagger","apiSource","settings","localIni","sdk","init40","baseUrl","authSession","base_url","actual","toContain","not","toEqual","toBeUndefined","spec","fixes","toHaveLength","onlyPublic","specs","filter","v","status","_asyncToGenerator","toBeDefined","looker_release_version","current_version","version","supported","supported_versions","versions","forEach","name","url","current","find","s","links","link","replace","substring","indexOf","description","op","paths","get","param","parameters","expected","defs","definitions","keys","Object","length","skip","left","fromString","right","diff","full_version","swagger_url","api_server_url","entries","_ref6","_","a","isDefault","moar","push"],"sources":["../../src/convert.apispec.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 { readFileSync } from 'fs';\nimport { describe, it } from 'node:test';\nimport { expect } from 'expect';\nimport cloneDeep from 'lodash/cloneDeep';\nimport isEmpty from 'lodash/isEmpty';\nimport { LookerNodeSDK, NodeSettingsIniFile } from '@looker/sdk-node';\nimport type { ISpecItem } from '@looker/sdk-codegen';\nimport {\n ApiModel,\n compareSpecs,\n convertDefs,\n convertParam,\n fixConversion,\n getLookerSpecs,\n getSpecLinks,\n getSpecsFromVersions,\n loadSpecs,\n openApiStyle,\n specToModel,\n swapXLookerTags,\n upgradeSpec,\n} from '@looker/sdk-codegen';\nimport { TestConfig, testFile } from '@looker/sdk-codegen-utils';\n\nconst swaggerFrag = `\n{\n \"paths\": {\n \"/query_tasks/multi_results\": {\n \"get\": {\n \"tags\": [\"Query\"],\n \"operationId\": \"query_task_multi_results\",\n \"summary\": \"Get Multiple Async Query Results\",\n \"description\": \"### Fetch results of multiple async queries\\\\n\\\\nReturns the results of multiple async queries in one request.\\\\n\\\\nFor Query Tasks that are not completed, the response will include the execution status of the Query Task but will not include query results.\\\\nQuery Tasks whose results have expired will have a status of 'expired'.\\\\nIf the user making the API request does not have sufficient privileges to view a Query Task result, the result will have a status of 'missing'\\\\n\",\n \"parameters\": [\n {\n \"name\": \"query_task_ids\",\n \"in\": \"query\",\n \"description\": \"List of Query Task IDs\",\n \"required\": true,\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"collectionFormat\": \"csv\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Multiple query results\",\n \"schema\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"db_query\"\n }\n },\n \"/dashboards/{lookml_dashboard_id}/import/{space_id}\": {\n \"post\": {\n \"tags\": [\"Dashboard\"],\n \"operationId\": \"import_lookml_dashboard\",\n \"summary\": \"Import LookML Dashboard\",\n \"description\": \"### Import a LookML dashboard to a space as a UDD\\\\nCreates a UDD (a dashboard which exists in the Looker database rather than as a LookML file) from the LookML dashboard\\\\nand puts it in the space specified. The created UDD will have a lookml_link_id which links to the original LookML dashboard.\\\\n\\\\nTo give the imported dashboard specify a (e.g. title: \\\\\"my title\\\\\") in the body of your request, otherwise the imported\\\\ndashboard will have the same title as the original LookML dashboard.\\\\n\\\\nFor this operation to succeed the user must have permission to see the LookML dashboard in question, and have permission to\\\\ncreate content in the space the dashboard is being imported to.\\\\n\\\\n**Sync** a linked UDD with [sync_lookml_dashboard()](#!/Dashboard/sync_lookml_dashboard)\\\\n**Unlink** a linked UDD by setting lookml_link_id to null with [update_dashboard()](#!/Dashboard/update_dashboard)\\\\n\",\n \"parameters\": [\n {\n \"name\": \"lookml_dashboard_id\",\n \"in\": \"path\",\n \"description\": \"Id of LookML dashboard\",\n \"required\": true,\n \"type\": \"string\"\n },\n {\n \"name\": \"space_id\",\n \"in\": \"path\",\n \"description\": \"Id of space to import the dashboard to\",\n \"required\": true,\n \"type\": \"string\"\n },\n {\n \"name\": \"body\",\n \"in\": \"body\",\n \"description\": \"Dashboard\",\n \"required\": false,\n \"schema\": {\n \"$ref\": \"#/definitions/Dashboard\"\n }\n },\n {\n \"name\": \"raw_locale\",\n \"in\": \"query\",\n \"description\": \"If true, and this dashboard is localized, export it with the raw keys, not localized.\",\n \"required\": false,\n \"type\": \"boolean\"\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Dashboard\",\n \"schema\": {\n \"$ref\": \"#/definitions/Dashboard\"\n }\n },\n \"201\": {\n \"description\": \"dashboard\",\n \"schema\": {\n \"$ref\": \"#/definitions/Dashboard\"\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"schema\": {\n \"$ref\": \"#/definitions/Error\"\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"schema\": {\n \"$ref\": \"#/definitions/ValidationError\"\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"non_query\"\n }\n }\n }\n}\n`;\nconst openApiFrag = `\n{\n \"paths\": {\n \"/query_tasks/multi_results\": {\n \"get\": {\n \"tags\": [\"Query\"],\n \"operationId\": \"query_task_multi_results\",\n \"summary\": \"Get Multiple Async Query Results\",\n \"description\": \"### Fetch results of multiple async queries\\\\n\\\\nReturns the results of multiple async queries in one request.\\\\n\\\\nFor Query Tasks that are not completed, the response will include the execution status of the Query Task but will not include query results.\\\\nQuery Tasks whose results have expired will have a status of 'expired'.\\\\nIf the user making the API request does not have sufficient privileges to view a Query Task result, the result will have a status of 'missing'\\\\n\",\n \"parameters\": [\n {\n \"name\": \"query_task_ids\",\n \"in\": \"query\",\n \"description\": \"List of Query Task IDs\",\n \"required\": true,\n \"style\": \"simple\",\n \"explode\": false,\n \"schema\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n }\n ],\n \"responses\": {\n \"200\": {\n \"description\": \"Multiple query results\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n }\n }\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"db_query\"\n }\n },\n\n \"/dashboards/{lookml_dashboard_id}/import/{space_id}\": {\n \"post\": {\n \"tags\": [\"Dashboard\"],\n \"operationId\": \"import_lookml_dashboard\",\n \"summary\": \"Import LookML Dashboard\",\n \"description\": \"### Import a LookML dashboard to a space as a UDD\\\\nCreates a UDD (a dashboard which exists in the Looker database rather than as a LookML file) from the LookML dashboard\\\\nand puts it in the space specified. The created UDD will have a lookml_link_id which links to the original LookML dashboard.\\\\n\\\\nTo give the imported dashboard specify a (e.g. title: \\\\\"my title\\\\\") in the body of your request, otherwise the imported\\\\ndashboard will have the same title as the original LookML dashboard.\\\\n\\\\nFor this operation to succeed the user must have permission to see the LookML dashboard in question, and have permission to\\\\ncreate content in the space the dashboard is being imported to.\\\\n\\\\n**Sync** a linked UDD with [sync_lookml_dashboard()](#!/Dashboard/sync_lookml_dashboard)\\\\n**Unlink** a linked UDD by setting lookml_link_id to null with [update_dashboard()](#!/Dashboard/update_dashboard)\\\\n\",\n \"parameters\": [\n {\n \"name\": \"lookml_dashboard_id\",\n \"in\": \"path\",\n \"description\": \"Id of LookML dashboard\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"name\": \"space_id\",\n \"in\": \"path\",\n \"description\": \"Id of space to import the dashboard to\",\n \"required\": true,\n \"schema\": {\n \"type\": \"string\"\n }\n },\n {\n \"name\": \"raw_locale\",\n \"in\": \"query\",\n \"description\": \"If true, and this dashboard is localized, export it with the raw keys, not localized.\",\n \"required\": false,\n \"schema\": {\n \"type\": \"boolean\"\n }\n }\n ],\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Dashboard\"\n }\n }\n },\n \"description\": \"Dashboard\"\n },\n \"responses\": {\n \"200\": {\n \"description\": \"Dashboard\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Dashboard\"\n }\n }\n }\n },\n \"201\": {\n \"description\": \"dashboard\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Dashboard\"\n }\n }\n }\n },\n \"400\": {\n \"description\": \"Bad Request\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n },\n \"404\": {\n \"description\": \"Not Found\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/Error\"\n }\n }\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/ValidationError\"\n }\n }\n }\n }\n },\n \"x-looker-status\": \"beta\",\n \"x-looker-activity-type\": \"non_query\"\n }\n }\n }\n}\n`;\nconst specFrag = `\n\"can\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"boolean\"\n },\n \"readOnly\": true,\n \"description\": \"Operations the current user is able to perform on this object\",\n \"x-looker-nullable\": false\n},\n\"content_favorite_id\": {\n \"type\": \"integer\",\n \"format\": \"int64\",\n \"readOnly\": true,\n \"description\": \"Content Favorite Id\",\n \"x-looker-nullable\": true\n},\n\"content_metadata_id\": {\n \"type\": \"integer\",\n \"format\": \"int64\",\n \"readOnly\": true,\n \"description\": \"Id of content metadata\",\n \"x-looker-nullable\": true\n},\n\"description\": {\n \"type\": \"string\",\n \"readOnly\": true,\n \"description\": \"Description\",\n \"x-looker-nullable\": true\n},\n\"hidden\": {\n \"type\": \"boolean\",\n \"readOnly\": true,\n \"description\": \"Is Hidden\",\n \"x-looker-nullable\": false,\n \"x-looker-deprecated\": true,\n},\n\"supported_formats\": {\n \"type\": \"array\",\n \"items\": { \"type\": \"string\" },\n \"readOnly\": true,\n \"x-looker-values\": [\n \"txt\",\n \"csv\",\n \"inline_json\",\n \"json\",\n \"json_label\",\n \"json_detail\",\n \"json_detail_lite_stream\",\n \"xlsx\",\n \"html\",\n \"wysiwyg_pdf\",\n \"assembled_pdf\",\n \"wysiwyg_png\",\n \"csv_zip\"\n ],\n \"description\": \"A list of data formats the integration supports. If unspecified, the default is all data formats. Valid values are: \\\\\"txt\\\\\", \\\\\"csv\\\\\", \\\\\"inline_json\\\\\", \\\\\"json\\\\\", \\\\\"json_label\\\\\", \\\\\"json_detail\\\\\", \\\\\"json_detail_lite_stream\\\\\", \\\\\"xlsx\\\\\", \\\\\"html\\\\\", \\\\\"wysiwyg_pdf\\\\\", \\\\\"assembled_pdf\\\\\", \\\\\"wysiwyg_png\\\\\", \\\\\"csv_zip\\\\\".\",\n \"nullable\": false\n},\n`;\n\nconst swagger = JSON.parse(swaggerFrag);\nconst api = JSON.parse(openApiFrag);\n\nconst config = TestConfig(specToModel);\nconst swaggerFile = testFile('Looker.4.0.json');\nconst apiFile = testFile('Looker.4.0.oas.json');\nconst swaggerSource = readFileSync(swaggerFile, 'utf-8');\nconst fullSwagger = JSON.parse(swaggerSource);\nconst apiSource = readFileSync(apiFile, 'utf-8');\nconst settings = new NodeSettingsIniFile(\n 'LOOKERSDK',\n config.localIni,\n 'Looker'\n);\nconst sdk = LookerNodeSDK.init40(settings);\nconst baseUrl = sdk.authSession.settings.base_url;\n\ndescribe('spec conversion', () => {\n it('swaps out x-looker-tags', () => {\n const actual = swapXLookerTags(specFrag);\n expect(actual).toContain('\"nullable\": true');\n expect(actual).not.toContain('\"x-looker-nullable\": true');\n expect(actual).toContain('\"enum\": [');\n expect(actual).not.toContain('\"x-looker-values\": [');\n expect(actual).toContain('\"deprecated\": true');\n expect(actual).not.toContain('\"x-looker-deprecated\"');\n });\n\n it('collectionFormat to style', () => {\n expect(openApiStyle('csv')).toEqual('simple');\n expect(openApiStyle('ssv')).toEqual('spaceDelimited');\n expect(openApiStyle('pipes')).toEqual('pipeDelimited');\n expect(openApiStyle('tabs')).toBeUndefined();\n });\n\n it('fixes missing conversion items', () => {\n const actual = fixConversion(openApiFrag, swaggerFrag);\n expect(actual.spec).toContain(`\"style\":\"simple\"`);\n expect(actual.fixes).not.toHaveLength(0);\n });\n\n describe('spec retrieval', () => {\n const onlyPublic = (specs: ISpecItem[]) => {\n return specs.filter(v => v.status !== 'undocumented');\n };\n\n it('gets looker specs', async () => {\n expect(baseUrl).toBeDefined();\n const actual = await getLookerSpecs(sdk, baseUrl);\n expect(actual).toBeDefined();\n expect(actual.looker_release_version).not.toEqual('');\n expect(actual.current_version.version).not.toEqual('');\n const supported = onlyPublic(actual.supported_versions);\n expect(supported).toHaveLength(1);\n });\n\n it('gets spec links', async () => {\n const versions = await getLookerSpecs(sdk, baseUrl);\n expect(versions).toBeDefined();\n versions.supported_versions = onlyPublic(versions.supported_versions);\n const actual = getSpecLinks(versions);\n expect(actual).toBeDefined();\n /*\n * 23.18 and later only has one API defined\n * expect(actual).toHaveLength(3)\n */\n actual.forEach(spec => {\n expect(spec.name).not.toEqual('');\n expect(spec.version).not.toEqual('');\n expect(spec.status).not.toEqual('');\n expect(spec.url).not.toEqual('');\n expect(isEmpty(spec.api)).toEqual(true);\n });\n const current = actual.find(s => s.status === 'current');\n expect(current).toBeDefined();\n actual.forEach(spec => expect(isEmpty(spec.api)).toEqual(true));\n });\n\n it('fetches and parses all specs', async () => {\n const versions = await getLookerSpecs(sdk, baseUrl);\n expect(versions).toBeDefined();\n versions.supported_versions = onlyPublic(versions.supported_versions);\n const links = getSpecLinks(versions);\n links.forEach(\n link =>\n (link.url = link.url.replace(\n link.url.substring(0, link.url.indexOf('/api/')),\n baseUrl\n ))\n );\n const actual = await loadSpecs(sdk, links);\n expect(actual).toBeDefined();\n /*\n * 23.18 and later only has one API defined\n * expect(actual).toHaveLength(3)\n */\n actual.forEach(spec => {\n expect(isEmpty(spec.api)).toEqual(false);\n expect(spec.api.version).not.toEqual('');\n expect(spec.api.description).not.toEqual('');\n });\n });\n });\n\n describe('spec upgrade', () => {\n it('converts a swagger array param', () => {\n const op = swagger.paths['/query_tasks/multi_results'].get;\n const param = op.parameters[0];\n const actual = convertParam(param);\n expect(actual).toBeDefined();\n const expected =\n api.paths['/query_tasks/multi_results'].get.parameters[0];\n expect(actual).toEqual(expected);\n });\n\n it('converts all definitions', () => {\n const defs = fullSwagger.definitions;\n const actual = convertDefs(defs);\n expect(actual).toBeDefined();\n const keys = Object.keys(actual);\n expect(keys).toHaveLength(Object.keys(defs).length);\n });\n\n /** eslint-disable jest/no-disabled-tests */\n it('matches a reference OpenAPI conversion', { skip: true }, () => {\n // TODO There is a different branch to address this\n const spec = upgradeSpec(swaggerSource);\n expect(spec).toBeDefined();\n const left = ApiModel.fromString(apiSource);\n const right = ApiModel.fromString(spec);\n const diff = compareSpecs(left, right);\n expect(diff).toHaveLength(0);\n });\n\n it('passes through an existing OpenAPI spec', () => {\n const spec = upgradeSpec(apiSource);\n expect(spec).toBeDefined();\n const left = ApiModel.fromString(apiSource);\n const right = ApiModel.fromString(spec);\n const diff = compareSpecs(left, right);\n expect(diff).toHaveLength(0);\n });\n });\n\n describe('getSpecsFromVersions', () => {\n const versions = {\n looker_release_version: '21.3.0',\n current_version: {\n version: '3.1',\n full_version: '3.1.0',\n status: 'current',\n swagger_url: 'http://localhost:19999/api/3.1/swagger.json',\n },\n supported_versions: [\n {\n version: '2.99',\n full_version: '2.99.0',\n status: 'internal_test',\n swagger_url: 'http://localhost:19999/api/2.99/swagger.json',\n },\n {\n version: '3.0',\n full_version: '3.0.0',\n status: 'legacy',\n swagger_url: 'http://localhost:19999/api/3.0/swagger.json',\n },\n {\n version: '3.1',\n full_version: '3.1.0',\n status: 'current',\n swagger_url: 'http://localhost:19999/api/3.1/swagger.json',\n },\n {\n version: '4.0',\n full_version: '4.0.21.3',\n status: 'experimental',\n swagger_url: 'http://localhost:19999/api/4.0/swagger.json',\n },\n ],\n api_server_url: 'http://localhost:19999',\n };\n\n it('only gets supported specifications', async () => {\n const actual = await getSpecsFromVersions(versions);\n expect(Object.keys(actual)).toEqual(['3.1', '4.0']);\n });\n\n it('current is the default spec', async () => {\n const specs = await getSpecsFromVersions(versions);\n const actual = Object.entries(specs).find(\n ([_, a]) => a.status === 'current'\n );\n expect(actual).toBeDefined();\n if (actual) {\n const [, current] = actual;\n expect(current).toBeDefined();\n expect(current.status).toEqual('current');\n expect(current.isDefault).toEqual(true);\n }\n });\n\n it('specs have unique keys', async () => {\n const moar = cloneDeep(versions);\n moar.supported_versions.push(\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/u.json',\n },\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/un.json',\n },\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/un3.json',\n },\n {\n version: '4.0',\n full_version: 'full',\n status: 'un',\n swagger_url: 'http://localhost:19999/api/4.0/un4.json',\n }\n );\n const actual = await getSpecsFromVersions(moar);\n expect(Object.keys(actual)).toEqual([\n '3.1',\n '4.0',\n '4.0u',\n '4.0un',\n '4.0un3',\n '4.0un4',\n ]);\n });\n });\n});\n"],"mappings":";;AA0BA,SAASA,YAAY,QAAQ,IAAI;AACjC,SAASC,QAAQ,EAAEC,EAAE,QAAQ,WAAW;AACxC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,OAAOC,SAAS,MAAM,kBAAkB;AACxC,OAAOC,OAAO,MAAM,gBAAgB;AACpC,SAASC,aAAa,EAAEC,mBAAmB,QAAQ,kBAAkB;AAErE,SACEC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,Y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AAC,GAAGxB,MAAM;QAC1BxC,MAAM,CAACgE,OAAO,CAAC,CAACV,WAAW,CAAC,CAAC;QAC7BtD,MAAM,CAACgE,OAAO,CAACZ,MAAM,CAAC,CAACT,OAAO,CAAC,SAAS,CAAC;QACzC3C,MAAM,CAACgE,OAAO,CAACgC,SAAS,CAAC,CAACrD,OAAO,CAAC,IAAI,CAAC;MACzC;IACF,CAAC,EAAC;IAEF5C,EAAE,CAAC,wBAAwB,EAAAsD,iBAAA,CAAE,aAAY;MACvC,IAAM4C,IAAI,GAAGhG,SAAS,CAAC2D,QAAQ,CAAC;MAChCqC,IAAI,CAACtC,kBAAkB,CAACuC,IAAI,CAC1B;QACEzC,OAAO,EAAE,KAAK;QACdgC,YAAY,EAAE,MAAM;QACpBrC,MAAM,EAAE,IAAI;QACZsC,WAAW,EAAE;MACf,CAAC,EACD;QACEjC,OAAO,EAAE,KAAK;QACdgC,YAAY,EAAE,MAAM;QACpBrC,MAAM,EAAE,IAAI;QACZsC,WAAW,EAAE;MACf,CAAC,EACD;QACEjC,OAAO,EAAE,KAAK;QACdgC,YAAY,EAAE,MAAM;QACpBrC,MAAM,EAAE,IAAI;QACZsC,WAAW,EAAE;MACf,CAAC,EACD;QACEjC,OAAO,EAAE,KAAK;QACdgC,YAAY,EAAE,MAAM;QACpBrC,MAAM,EAAE,IAAI;QACZsC,WAAW,EAAE;MACf,CACF,CAAC;MACD,IAAMlD,MAAM,SAAS5B,oBAAoB,CAACqF,IAAI,CAAC;MAC/CjG,MAAM,CAACkF,MAAM,CAACD,IAAI,CAACzC,MAAM,CAAC,CAAC,CAACG,OAAO,CAAC,CAClC,KAAK,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC,EAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"convert.js","names":["log","upgradeSpec","createJsonFile","fail","isFileSync","readFileSync","run","writeFileSync","convertSpec","specFileName","openApiFilename","force","arguments","length","undefined","concat","spec","swagger","JSON","parse","openapi","stringify","Error","source"],"sources":["../../src/convert.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 { log } from '@looker/sdk-codegen-utils';\nimport { upgradeSpec } from '@looker/sdk-codegen';\nimport {\n createJsonFile,\n fail,\n isFileSync,\n readFileSync,\n run,\n writeFileSync,\n} from './nodeUtils';\n\n/**\n * Convert a Swagger specification to OpenAPI\n *\n * If the source spec is already an OpenAPI spec, fixes are still processed\n *\n * @param specFileName source Swagger spec file\n * @param openApiFilename destination OpenAPI spec file\n * @param force use `true` to force a conversion even if the file exists\n * @returns {Promise<string>} name of OpenAPI file\n */\nexport const convertSpec = (\n specFileName: string,\n openApiFilename: string,\n force = false\n) => {\n if (isFileSync(openApiFilename) && !force) {\n log(`${openApiFilename} already exists. Skipping conversion.`);\n return openApiFilename;\n }\n const spec = readFileSync(specFileName);\n const swagger = JSON.parse(spec);\n if (swagger.swagger) {\n // Still a swagger spec. Convert it.\n // https://github.com/Mermade/oas-kit/tree/master/packages/swagger2openapi config options:\n // patch to fix up small errors in source definition (not required, just to ensure smooth process)\n // indent no spaces\n // output to openApiFilename\n run('yarn swagger2openapi', [\n specFileName,\n '-p',\n '-i',\n '\"\"',\n '-o',\n openApiFilename,\n ]);\n } else if (swagger.openapi) {\n // We've already got an OpenAPI file\n writeFileSync(openApiFilename, JSON.stringify(swagger));\n } else {\n throw new Error(`Bad specification file ${specFileName}`);\n }\n if (!isFileSync(openApiFilename)) {\n return fail('convertSpec', `creating ${openApiFilename} failed`);\n }\n const source = upgradeSpec(readFileSync(openApiFilename));\n createJsonFile(openApiFilename, source);\n return openApiFilename;\n};\n"],"mappings":"AA0BA,SAASA,GAAG,QAAQ,2BAA2B;AAC/C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SACEC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,aAAa,QACR,aAAa;AAYpB,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CACtBC,YAAoB,EACpBC,eAAuB,EAEpB;EAAA,IADHC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEb,IAAIR,UAAU,CAACM,eAAe,CAAC,IAAI,CAACC,KAAK,EAAE;IACzCX,GAAG,IAAAe,MAAA,CAAIL,eAAe,0CAAuC,CAAC;IAC9D,OAAOA,eAAe;EACxB;EACA,IAAMM,IAAI,GAAGX,YAAY,CAACI,YAAY,CAAC;EACvC,IAAMQ,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;EAChC,IAAIC,OAAO,CAACA,OAAO,EAAE;IAMnBX,GAAG,CAAC,sBAAsB,EAAE,CAC1BG,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJC,eAAe,CAChB,CAAC;EACJ,CAAC,MAAM,IAAIO,OAAO,CAACG,OAAO,EAAE;IAE1Bb,aAAa,CAACG,eAAe,EAAEQ,IAAI,CAACG,SAAS,CAACJ,OAAO,CAAC,CAAC;EACzD,CAAC,MAAM;IACL,MAAM,IAAIK,KAAK,2BAAAP,MAAA,CAA2BN,YAAY,CAAE,CAAC;EAC3D;EACA,IAAI,CAACL,UAAU,CAACM,eAAe,CAAC,EAAE;IAChC,OAAOP,IAAI,CAAC,aAAa,cAAAY,MAAA,CAAcL,eAAe,YAAS,CAAC;EAClE;EACA,IAAMa,MAAM,GAAGtB,WAAW,CAACI,YAAY,CAACK,eAAe,CAAC,CAAC;EACzDR,cAAc,CAACQ,eAAe,EAAEa,MAAM,CAAC;EACvC,OAAOb,eAAe;AACxB,CAAC"}
1
+ {"version":3,"file":"convert.js","names":["log","upgradeSpec","createJsonFile","fail","isFileSync","readFileSync","run","writeFileSync","convertSpec","specFileName","openApiFilename","force","arguments","length","undefined","concat","spec","swagger","JSON","parse","openapi","stringify","Error","source"],"sources":["../../src/convert.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 { log } from '@looker/sdk-codegen-utils';\nimport { upgradeSpec } from '@looker/sdk-codegen';\nimport {\n createJsonFile,\n fail,\n isFileSync,\n readFileSync,\n run,\n writeFileSync,\n} from './nodeUtils';\n\n/**\n * Convert a Swagger specification to OpenAPI\n *\n * If the source spec is already an OpenAPI spec, fixes are still processed\n *\n * @param specFileName source Swagger spec file\n * @param openApiFilename destination OpenAPI spec file\n * @param force use `true` to force a conversion even if the file exists\n * @returns {Promise<string>} name of OpenAPI file\n */\nexport const convertSpec = (\n specFileName: string,\n openApiFilename: string,\n force = false\n) => {\n if (isFileSync(openApiFilename) && !force) {\n log(`${openApiFilename} already exists. Skipping conversion.`);\n return openApiFilename;\n }\n const spec = readFileSync(specFileName);\n const swagger = JSON.parse(spec);\n if (swagger.swagger) {\n // Still a swagger spec. Convert it.\n // https://github.com/Mermade/oas-kit/tree/master/packages/swagger2openapi config options:\n // patch to fix up small errors in source definition (not required, just to ensure smooth process)\n // indent no spaces\n // output to openApiFilename\n run('yarn swagger2openapi', [\n specFileName,\n '-p',\n '-i',\n '\"\"',\n '-o',\n openApiFilename,\n ]);\n } else if (swagger.openapi) {\n // We've already got an OpenAPI file\n writeFileSync(openApiFilename, JSON.stringify(swagger));\n } else {\n throw new Error(`Bad specification file ${specFileName}`);\n }\n if (!isFileSync(openApiFilename)) {\n return fail('convertSpec', `creating ${openApiFilename} failed`);\n }\n const source = upgradeSpec(readFileSync(openApiFilename));\n createJsonFile(openApiFilename, source);\n return openApiFilename;\n};\n"],"mappings":"AA0BA,SAASA,GAAG,QAAQ,2BAA2B;AAC/C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SACEC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,GAAG,EACHC,aAAa,QACR,aAAa;AAYpB,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CACtBC,YAAoB,EACpBC,eAAuB,EAEpB;EAAA,IADHC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAEb,IAAIR,UAAU,CAACM,eAAe,CAAC,IAAI,CAACC,KAAK,EAAE;IACzCX,GAAG,IAAAe,MAAA,CAAIL,eAAe,0CAAuC,CAAC;IAC9D,OAAOA,eAAe;EACxB;EACA,IAAMM,IAAI,GAAGX,YAAY,CAACI,YAAY,CAAC;EACvC,IAAMQ,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAAC;EAChC,IAAIC,OAAO,CAACA,OAAO,EAAE;IAMnBX,GAAG,CAAC,sBAAsB,EAAE,CAC1BG,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJC,eAAe,CAChB,CAAC;EACJ,CAAC,MAAM,IAAIO,OAAO,CAACG,OAAO,EAAE;IAE1Bb,aAAa,CAACG,eAAe,EAAEQ,IAAI,CAACG,SAAS,CAACJ,OAAO,CAAC,CAAC;EACzD,CAAC,MAAM;IACL,MAAM,IAAIK,KAAK,2BAAAP,MAAA,CAA2BN,YAAY,CAAE,CAAC;EAC3D;EACA,IAAI,CAACL,UAAU,CAACM,eAAe,CAAC,EAAE;IAChC,OAAOP,IAAI,CAAC,aAAa,cAAAY,MAAA,CAAcL,eAAe,YAAS,CAAC;EAClE;EACA,IAAMa,MAAM,GAAGtB,WAAW,CAACI,YAAY,CAACK,eAAe,CAAC,CAAC;EACzDR,cAAc,CAACQ,eAAe,EAAEa,MAAM,CAAC;EACvC,OAAOb,eAAe;AACxB,CAAC","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
2
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
- 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; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
5
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
- function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = new RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
7
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
8
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
6
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) { if ("" === t) return e; var p = o[r]; return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : ""; })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
7
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
8
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
9
9
  import path from 'path';
10
10
  import { ExampleMiner, filterCodeFiles, getCodeFiles, getCommitHash, getRemoteOrigin, readFile } from './exampleMiner';
11
11
  var fileFilter = (endpointFilePattern, typeFilePattern, fileName) => {
@@ -1 +1 @@
1
- {"version":3,"file":"declarationMiner.js","names":["path","ExampleMiner","filterCodeFiles","getCodeFiles","getCommitHash","getRemoteOrigin","readFile","fileFilter","endpointFilePattern","typeFilePattern","fileName","fileMatch","test","rubyMethodProbe","fileNamePattern","declarationPattern","_wrapRegExp","verb","matchToSpecKeyTransform","match","_match$groups","_match$groups2","groups","toLocaleUpperCase","replace","key","concat","rubyTypeProbe","typeName","DeclarationMiner","constructor","sourcePath","methodProbe","typeProbe","originOverride","_defineProperty","execute","filePath","mProbe","tProbe","files","undefined","bind","forEach","f","relFile","processFile","basename","methods","_objectSpread","mineFile","types","lode","commitHash","process","chdir","remoteOrigin","relate","probe","mineCode","content","lines","split","declarations","line","index","exec","sourceFile"],"sources":["../../src/declarationMiner.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 path from 'path';\nimport type { DeclarationNuggets, IDeclarationMine } from '@looker/sdk-codegen';\n\nimport {\n ExampleMiner,\n filterCodeFiles,\n getCodeFiles,\n getCommitHash,\n getRemoteOrigin,\n readFile,\n} from './exampleMiner';\n\n/**\n * Filter that checks if given file name matches any of the specified patterns\n * @param endpointFilePattern A pattern that matches endpoint files\n * @param typeFilePattern A pattern that matches type files\n * @param fileName File name to check against patterns\n */\nconst fileFilter = (\n endpointFilePattern: RegExp,\n typeFilePattern: RegExp,\n fileName: string\n) => {\n const fileMatch =\n endpointFilePattern.test(fileName) || typeFilePattern.test(fileName);\n return filterCodeFiles(fileName) && fileMatch;\n};\n\n/**\n * Reference method probe for a Ruby controller\n */\nexport const rubyMethodProbe = {\n fileNamePattern: /^(?!test).*_controller.rb$/,\n declarationPattern:\n /(?<verb>GET|POST|DELETE|PUT|PATCH)\\s(?:\"|')\\/api\\/3\\.x(?<path>\\S+)(?:\"|')/i,\n matchToSpecKeyTransform: (match: RegExpExecArray) => {\n const verb = match.groups?.verb.toLocaleUpperCase();\n const path = match.groups?.path\n .replace(':#', '')\n .replace('#', '')\n .replace(/:(\\w+)/g, '{$1}');\n const key = `${verb} ${path}`;\n return key;\n },\n};\n\n/**\n * Reference type probe for a Ruby mapper\n */\nexport const rubyTypeProbe: IProbe = {\n fileNamePattern: /^(?!test).*_mapper.rb$/,\n declarationPattern: /class\\s(?<typeName>\\w+)Mapper/i,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n matchToSpecKeyTransform: (match: RegExpExecArray) => match.groups!.typeName,\n};\n\nexport interface IProbe {\n /** Pattern of file names to mine */\n fileNamePattern: RegExp;\n /** Pattern matching the declaration of a method/type */\n declarationPattern: RegExp;\n /** A transform lambda for transforming a declaration match into a spec key */\n matchToSpecKeyTransform: (match: RegExpExecArray) => string;\n}\n\nexport class DeclarationMiner {\n types: DeclarationNuggets = {};\n methods: DeclarationNuggets = {};\n\n constructor(\n public readonly sourcePath: string,\n public readonly methodProbe: IProbe,\n public readonly typeProbe: IProbe,\n private readonly originOverride: string\n ) {}\n\n execute(sourcePath?: string, methodProbe?: IProbe, typeProbe?: IProbe) {\n const filePath = sourcePath ?? this.sourcePath;\n const mProbe = methodProbe ?? this.methodProbe;\n const tProbe = typeProbe ?? this.typeProbe;\n\n const files = getCodeFiles(\n filePath,\n undefined,\n fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern),\n ['node_modules', 'dist']\n );\n\n files.forEach(f => {\n const relFile = this.processFile(f);\n const fileName = path.basename(relFile);\n if (mProbe.fileNamePattern.test(fileName)) {\n this.methods = {\n ...this.methods,\n ...this.mineFile(relFile, f, mProbe),\n };\n } else {\n this.types = { ...this.types, ...this.mineFile(relFile, f, tProbe) };\n }\n });\n return this.lode;\n }\n\n get commitHash(): string {\n process.chdir(this.sourcePath);\n return getCommitHash();\n }\n\n get remoteOrigin(): string {\n if (this.originOverride) {\n return this.originOverride;\n }\n process.chdir(this.sourcePath);\n return getRemoteOrigin();\n }\n\n get lode(): IDeclarationMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n types: this.types,\n methods: this.methods,\n };\n }\n\n protected processFile(fileName: string) {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName);\n return relFile;\n }\n\n protected mineFile(relFile: string, fileName: string, probe: IProbe) {\n return this.mineCode(relFile, readFile(fileName), probe);\n }\n\n protected mineCode(relFile: string, content: string, probe: IProbe) {\n const lines = content.split('\\n');\n const declarations: DeclarationNuggets = {};\n lines.forEach((line, index) => {\n const match = probe.declarationPattern.exec(line);\n if (match) {\n const key = probe.matchToSpecKeyTransform(match);\n declarations[key] = {\n line: index + 1,\n sourceFile: relFile,\n };\n }\n });\n return declarations;\n }\n}\n"],"mappings":";;;;;;;;AA0BA,OAAOA,IAAI,MAAM,MAAM;AAGvB,SACEC,YAAY,EACZC,eAAe,EACfC,YAAY,EACZC,aAAa,EACbC,eAAe,EACfC,QAAQ,QACH,gBAAgB;AAQvB,IAAMC,UAAU,GAAGA,CACjBC,mBAA2B,EAC3BC,eAAuB,EACvBC,QAAgB,KACb;EACH,IAAMC,SAAS,GACbH,mBAAmB,CAACI,IAAI,CAACF,QAAQ,CAAC,IAAID,eAAe,CAACG,IAAI,CAACF,QAAQ,CAAC;EACtE,OAAOR,eAAe,CAACQ,QAAQ,CAAC,IAAIC,SAAS;AAC/C,CAAC;AAKD,OAAO,IAAME,eAAe,GAAG;EAC7BC,eAAe,EAAE,4BAA4B;EAC7CC,kBAAkB,EAAAC,WAAA,CAChB,8DAA4E;IAAAC,IAAA;IAAAjB,IAAA;EAAA;EAC9EkB,uBAAuB,EAAGC,KAAsB,IAAK;IAAA,IAAAC,aAAA,EAAAC,cAAA;IACnD,IAAMJ,IAAI,IAAAG,aAAA,GAAGD,KAAK,CAACG,MAAM,cAAAF,aAAA,uBAAZA,aAAA,CAAcH,IAAI,CAACM,iBAAiB,CAAC,CAAC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,YAAY;MAC/BL,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBH,OAAO,EAAE,IAAI,CAACA;IAChB,CAAC;EACH;EAEUF,WAAWA,CAACpC,QAAgB,EAAE;IACtC,IAAMmC,OAAO,GAAG5C,YAAY,CAACwD,MAAM,CAAC,IAAI,CAAC1B,UAAU,EAAErB,QAAQ,CAAC;IAC9D,OAAOmC,OAAO;EAChB;EAEUK,QAAQA,CAACL,OAAe,EAAEnC,QAAgB,EAAEgD,KAAa,EAAE;IACnE,OAAO,IAAI,CAACC,QAAQ,CAACd,OAAO,EAAEvC,QAAQ,CAACI,QAAQ,CAAC,EAAEgD,KAAK,CAAC;EAC1D;EAEUC,QAAQA,CAACd,OAAe,EAAEe,OAAe,EAAEF,KAAa,EAAE;IAClE,IAAMG,KAAK,GAAGD,OAAO,CAACE,KAAK,CAAC,IAAI,CAAC;IACjC,IAAMC,YAAgC,GAAG,CAAC,CAAC;IAC3CF,KAAK,CAAClB,OAAO,CAAC,CAACqB,IAAI,EAAEC,KAAK,KAAK;MAC7B,IAAM9C,KAAK,GAAGuC,KAAK,CAAC3C,kBAAkB,CAACmD,IAAI,CAACF,IAAI,CAAC;MACjD,IAAI7C,KAAK,EAAE;QACT,IAAMM,GAAG,GAAGiC,KAAK,CAACxC,uBAAuB,CAACC,KAAK,CAAC;QAChD4C,YAAY,CAACtC,GAAG,CAAC,GAAG;UAClBuC,IAAI,EAAEC,KAAK,GAAG,CAAC;UACfE,UAAU,EAAEtB;QACd,CAAC;MACH;IACF,CAAC,CAAC;IACF,OAAOkB,YAAY;EACrB;AACF"}
1
+ {"version":3,"file":"declarationMiner.js","names":["path","ExampleMiner","filterCodeFiles","getCodeFiles","getCommitHash","getRemoteOrigin","readFile","fileFilter","endpointFilePattern","typeFilePattern","fileName","fileMatch","test","rubyMethodProbe","fileNamePattern","declarationPattern","_wrapRegExp","verb","matchToSpecKeyTransform","match","_match$groups","_match$groups2","groups","toLocaleUpperCase","replace","key","concat","rubyTypeProbe","typeName","DeclarationMiner","constructor","sourcePath","methodProbe","typeProbe","originOverride","_defineProperty","execute","filePath","mProbe","tProbe","files","undefined","bind","forEach","f","relFile","processFile","basename","methods","_objectSpread","mineFile","types","lode","commitHash","process","chdir","remoteOrigin","relate","probe","mineCode","content","lines","split","declarations","line","index","exec","sourceFile"],"sources":["../../src/declarationMiner.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 path from 'path';\nimport type { DeclarationNuggets, IDeclarationMine } from '@looker/sdk-codegen';\n\nimport {\n ExampleMiner,\n filterCodeFiles,\n getCodeFiles,\n getCommitHash,\n getRemoteOrigin,\n readFile,\n} from './exampleMiner';\n\n/**\n * Filter that checks if given file name matches any of the specified patterns\n * @param endpointFilePattern A pattern that matches endpoint files\n * @param typeFilePattern A pattern that matches type files\n * @param fileName File name to check against patterns\n */\nconst fileFilter = (\n endpointFilePattern: RegExp,\n typeFilePattern: RegExp,\n fileName: string\n) => {\n const fileMatch =\n endpointFilePattern.test(fileName) || typeFilePattern.test(fileName);\n return filterCodeFiles(fileName) && fileMatch;\n};\n\n/**\n * Reference method probe for a Ruby controller\n */\nexport const rubyMethodProbe = {\n fileNamePattern: /^(?!test).*_controller.rb$/,\n declarationPattern:\n /(?<verb>GET|POST|DELETE|PUT|PATCH)\\s(?:\"|')\\/api\\/3\\.x(?<path>\\S+)(?:\"|')/i,\n matchToSpecKeyTransform: (match: RegExpExecArray) => {\n const verb = match.groups?.verb.toLocaleUpperCase();\n const path = match.groups?.path\n .replace(':#', '')\n .replace('#', '')\n .replace(/:(\\w+)/g, '{$1}');\n const key = `${verb} ${path}`;\n return key;\n },\n};\n\n/**\n * Reference type probe for a Ruby mapper\n */\nexport const rubyTypeProbe: IProbe = {\n fileNamePattern: /^(?!test).*_mapper.rb$/,\n declarationPattern: /class\\s(?<typeName>\\w+)Mapper/i,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n matchToSpecKeyTransform: (match: RegExpExecArray) => match.groups!.typeName,\n};\n\nexport interface IProbe {\n /** Pattern of file names to mine */\n fileNamePattern: RegExp;\n /** Pattern matching the declaration of a method/type */\n declarationPattern: RegExp;\n /** A transform lambda for transforming a declaration match into a spec key */\n matchToSpecKeyTransform: (match: RegExpExecArray) => string;\n}\n\nexport class DeclarationMiner {\n types: DeclarationNuggets = {};\n methods: DeclarationNuggets = {};\n\n constructor(\n public readonly sourcePath: string,\n public readonly methodProbe: IProbe,\n public readonly typeProbe: IProbe,\n private readonly originOverride: string\n ) {}\n\n execute(sourcePath?: string, methodProbe?: IProbe, typeProbe?: IProbe) {\n const filePath = sourcePath ?? this.sourcePath;\n const mProbe = methodProbe ?? this.methodProbe;\n const tProbe = typeProbe ?? this.typeProbe;\n\n const files = getCodeFiles(\n filePath,\n undefined,\n fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern),\n ['node_modules', 'dist']\n );\n\n files.forEach(f => {\n const relFile = this.processFile(f);\n const fileName = path.basename(relFile);\n if (mProbe.fileNamePattern.test(fileName)) {\n this.methods = {\n ...this.methods,\n ...this.mineFile(relFile, f, mProbe),\n };\n } else {\n this.types = { ...this.types, ...this.mineFile(relFile, f, tProbe) };\n }\n });\n return this.lode;\n }\n\n get commitHash(): string {\n process.chdir(this.sourcePath);\n return getCommitHash();\n }\n\n get remoteOrigin(): string {\n if (this.originOverride) {\n return this.originOverride;\n }\n process.chdir(this.sourcePath);\n return getRemoteOrigin();\n }\n\n get lode(): IDeclarationMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n types: this.types,\n methods: this.methods,\n };\n }\n\n protected processFile(fileName: string) {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName);\n return relFile;\n }\n\n protected mineFile(relFile: string, fileName: string, probe: IProbe) {\n return this.mineCode(relFile, readFile(fileName), probe);\n }\n\n protected mineCode(relFile: string, content: string, probe: IProbe) {\n const lines = content.split('\\n');\n const declarations: DeclarationNuggets = {};\n lines.forEach((line, index) => {\n const match = probe.declarationPattern.exec(line);\n if (match) {\n const key = probe.matchToSpecKeyTransform(match);\n declarations[key] = {\n line: index + 1,\n sourceFile: relFile,\n };\n }\n });\n return declarations;\n }\n}\n"],"mappings":";;;;;;;;AA0BA,OAAOA,IAAI,MAAM,MAAM;AAGvB,SACEC,YAAY,EACZC,eAAe,EACfC,YAAY,EACZC,aAAa,EACbC,eAAe,EACfC,QAAQ,QACH,gBAAgB;AAQvB,IAAMC,UAAU,GAAGA,CACjBC,mBAA2B,EAC3BC,eAAuB,EACvBC,QAAgB,KACb;EACH,IAAMC,SAAS,GACbH,mBAAmB,CAACI,IAAI,CAACF,QAAQ,CAAC,IAAID,eAAe,CAACG,IAAI,CAACF,QAAQ,CAAC;EACtE,OAAOR,eAAe,CAACQ,QAAQ,CAAC,IAAIC,SAAS;AAC/C,CAAC;AAKD,OAAO,IAAME,eAAe,GAAG;EAC7BC,eAAe,EAAE,4BAA4B;EAC7CC,kBAAkB,EAAA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;AACF","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- 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; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
3
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  import * as fs from 'fs';
5
5
  import path from 'path';
@@ -22,7 +22,7 @@ var skipFolder = function skipFolder(name) {
22
22
  var excludeList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IGNORE_PATHS;
23
23
  return new RegExp(excludeList.join('|'), 'gi').test(name);
24
24
  };
25
- export var getAllFiles = function getAllFiles(searchPath) {
25
+ var _getAllFiles = function getAllFiles(searchPath) {
26
26
  var listOfFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
27
27
  var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : filterAllFiles;
28
28
  var ignorePaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
@@ -30,7 +30,7 @@ export var getAllFiles = function getAllFiles(searchPath) {
30
30
  files.forEach(file => {
31
31
  try {
32
32
  if (fs.statSync(searchPath + '/' + file).isDirectory()) {
33
- if (!skipFolder(file, ignorePaths)) listOfFiles = getAllFiles(searchPath + '/' + file, listOfFiles, filter, ignorePaths);
33
+ if (!skipFolder(file, ignorePaths)) listOfFiles = _getAllFiles(searchPath + '/' + file, listOfFiles, filter, ignorePaths);
34
34
  } else {
35
35
  if (filter(file)) {
36
36
  var _fileName = path.join(searchPath, '/', file);
@@ -41,11 +41,12 @@ export var getAllFiles = function getAllFiles(searchPath) {
41
41
  });
42
42
  return listOfFiles;
43
43
  };
44
+ export { _getAllFiles as getAllFiles };
44
45
  export var getCodeFiles = function getCodeFiles(searchPath) {
45
46
  var listOfFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
46
47
  var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : filterCodeFiles;
47
48
  var ignorePaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : IGNORE_PATHS;
48
- return getAllFiles(searchPath, listOfFiles, filter, ignorePaths);
49
+ return _getAllFiles(searchPath, listOfFiles, filter, ignorePaths);
49
50
  };
50
51
  export var execRead = command => {
51
52
  return execSync(command, {
@@ -1 +1 @@
1
- {"version":3,"file":"exampleMiner.js","names":["fs","path","execSync","warn","readFile","fileName","readFileSync","encoding","sdkPattern","mdPattern","linkPattern","filterAllFiles","trim","length","filterCodeFiles","test","ext","extname","toLocaleLowerCase","fileMiners","IGNORE_PATHS","skipFolder","name","excludeList","arguments","undefined","RegExp","join","getAllFiles","searchPath","listOfFiles","filter","ignorePaths","files","readdirSync","forEach","file","statSync","isDirectory","push","_e","getCodeFiles","execRead","command","getCommitHash","getRemoteOrigin","getRemoteHttpOrigin","origin","gitExtractor","match","exec","httpExtractor","concat","getPermalinkRoot","root","endsWith","substring","CodeMiner","ignoreCall","call","sdk","ignoreOps","has","operationId","mineCode","sourceCode","lines","split","result","line","index","sdkRef","column","mineFile","_defineProperty","Set","MarkdownMiner","ignoreLink","linkFile","stripSearch","notCode","isHttp","noDash","value","dasher","replace","sourcerer","sourceFileName","startsWith","base","dirname","mineContent","content","summary","localeCompare","sensitivity","sourceFile","ExampleMiner","constructor","sourcePath","execute","lode","commitHash","remoteOrigin","summaries","nuggets","addCall","relativeFile","addFileCall","nugget","fileCalls","calls","sdkCall","fileCall","find","f","s","relate","relative","processFile","coder","relFile","dirPath"],"sources":["../../src/exampleMiner.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 { execSync } from 'child_process';\nimport { warn } from '@looker/sdk-codegen-utils';\nimport type {\n IExampleMine,\n IFileCall,\n INugget,\n ISDKCall,\n ISummary,\n Nuggets,\n SDKCalls,\n Summaries,\n} from '@looker/sdk-codegen';\n\nexport interface IFileMine {\n mineFile(fileName: string): SDKCalls;\n mineCode(code: string): SDKCalls;\n ignoreCall(call: ISDKCall): boolean;\n}\n\nexport interface IDocMine {\n mineFile(fileName: string): ISummary[];\n mineContent(sourceFile: string, content: string): ISummary[];\n ignoreLink(fileName: string): boolean;\n}\n\nexport const readFile = (fileName: string) =>\n fs.readFileSync(fileName, { encoding: 'utf-8' });\n\nconst sdkPattern = /(\\b[a-z0-9_]*sdk)\\.\\s*([a-z0-9_]*)\\s*[(<]/gi;\nconst mdPattern = /(\\[(.+?)\\]\\((.+?)\\))/gim;\nconst linkPattern = /(.*)\\[\\[link\\]\\]\\((.+?)\\)/gim;\n\nexport type IMiners = { [key: string]: IFileMine | IDocMine };\n\n/** file-filtering lambda for `getAllFiles()` and `getCodeFiles()` */\nexport type FileFilter = (fileName: string, pattern?: RegExp) => boolean;\n\n/**\n * Filter to include every file that has a non-empty file name\n * @param fileName name of file to check\n */\nexport const filterAllFiles = (fileName: string) => fileName.trim().length > 0;\n\n/**\n * Filter for code files\n * @param fileName name of file from which to extract its extension\n */\nexport const filterCodeFiles = (fileName: string) => {\n if (/(^|\\/)node_modules\\//gi.test(fileName)) return false;\n const ext = path.extname(fileName).toLocaleLowerCase();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return ext in fileMiners;\n};\n\nexport const IGNORE_PATHS = [\n 'node_modules',\n 'lib',\n 'dist',\n 'bazel-bin',\n 'build',\n 'bin',\n '.build',\n '.direnv',\n '.github',\n '.vscode',\n '.idea',\n '.gradle',\n 'results',\n];\n\nconst skipFolder = (name: string, excludeList: string[] = IGNORE_PATHS) =>\n new RegExp(excludeList.join('|'), 'gi').test(name);\n\n/**\n * Finds all file recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of current files already found\n * @param filter lambda for file inclusion in results. truthy analyzes the file\n * @param ignorePaths paths to ignore\n */\nexport const getAllFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterAllFiles,\n ignorePaths: string[] = []\n) => {\n const files = fs.readdirSync(searchPath);\n\n files.forEach(file => {\n try {\n if (fs.statSync(searchPath + '/' + file).isDirectory()) {\n if (!skipFolder(file, ignorePaths))\n listOfFiles = getAllFiles(\n searchPath + '/' + file,\n listOfFiles,\n filter,\n ignorePaths\n );\n } else {\n if (filter(file)) {\n const fileName = path.join(searchPath, '/', file);\n listOfFiles.push(fileName);\n }\n }\n } catch (_e: any) {\n // warn(`skipping ${file}: ${e}`)\n }\n });\n\n return listOfFiles;\n};\n\n/**\n * Find all source code files recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of source code files that can be mined\n * @param filter function to determine whether a file should be analyzed\n * @param ignorePaths paths to ignore\n */\nexport const getCodeFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterCodeFiles,\n ignorePaths: string[] = IGNORE_PATHS\n) => {\n return getAllFiles(searchPath, listOfFiles, filter, ignorePaths);\n};\n\n/** get the trimmed output of the command as a UTF-8 string */\nexport const execRead = (command: string) => {\n return execSync(command, { encoding: 'utf-8' }).trim();\n};\n\n/** get this git repository's current commit hash */\nexport const getCommitHash = () => execRead('git rev-parse HEAD');\n\n/** get the remote origin url for this repository */\nexport const getRemoteOrigin = () => {\n return execRead('git remote get-url origin');\n};\n\n/**\n * Convert this github repository's git address to an HTTP url\n */\nexport const getRemoteHttpOrigin = () => {\n const origin = getRemoteOrigin();\n const gitExtractor = /git@github\\.com:(.*)\\.git/gi;\n let match = gitExtractor.exec(origin);\n if (!match) {\n // git origin on CI: https://github.com/looker-open-source/sdk-codegen\n const httpExtractor = /(https:\\/\\/github.com.*)(|.git)/;\n match = httpExtractor.exec(origin);\n if (!match) {\n return '';\n }\n return match[1];\n }\n return `https://github.com/${match[1]}`;\n};\n\n/** Permalink paths should not have the `.git` ending for a repo */\nexport const getPermalinkRoot = () => {\n let root = getRemoteHttpOrigin();\n if (root.endsWith('.git')) root = root.substring(0, root.length - 4);\n return root;\n};\n\nexport class CodeMiner implements IFileMine {\n static ignoreOps = new Set<string>(['ok', 'init40']);\n ignoreCall(call: ISDKCall): boolean {\n if (!/sdk/i.test(call.sdk)) return true;\n return CodeMiner.ignoreOps.has(call.operationId);\n }\n\n mineCode(sourceCode: string): SDKCalls {\n const lines = sourceCode.split('\\n');\n const result: SDKCalls = [];\n lines.forEach((line, index) => {\n let match = sdkPattern.exec(line);\n while (match !== null) {\n // TODO need to ignore source code comments?\n if (match && match.length > 2) {\n const sdkRef = match[1].trim();\n const call: ISDKCall = {\n sdk: sdkRef,\n operationId: match[2].trim(),\n line: index + 1,\n column: match.index,\n };\n if (!this.ignoreCall(call)) {\n result.push(call);\n }\n }\n match = sdkPattern.exec(line);\n }\n });\n return result;\n }\n\n mineFile(fileName: string): SDKCalls {\n return this.mineCode(readFile(fileName));\n }\n}\n\n/**\n * Processes markdown files and extracts links to source code to use as summaries\n */\nexport class MarkdownMiner implements IDocMine {\n // TODO ensure summaries don't include markdown files\n ignoreLink(linkFile: string): boolean {\n linkFile = this.stripSearch(linkFile);\n const ext = path.extname(linkFile).toLocaleLowerCase();\n const notCode = ext === '.md' || !filterCodeFiles(linkFile);\n const isHttp = /^(http|https):/gi.test(linkFile);\n return notCode || isHttp;\n }\n\n /**\n * Remove leading - from a string\n * @param value string to process\n */\n noDash(value: string) {\n value = value.trim();\n const dasher = /^\\s*-\\s*(.*)/g;\n if (dasher.test(value)) {\n value = value.replace(dasher, '$1');\n }\n return value.trim();\n }\n\n stripSearch(fileName: string) {\n fileName = fileName.trim();\n const match = /(.*)#.*/gi.exec(fileName);\n if (match) fileName = match[1];\n return fileName;\n }\n\n /**\n * Fully qualify the path for `linkFile`\n * @param sourceFileName\n * @param linkFile\n */\n sourcerer(sourceFileName: string, linkFile: string) {\n linkFile = this.stripSearch(linkFile);\n if (linkFile.startsWith('/')) return linkFile.substring(1);\n const base = path.dirname(sourceFileName);\n return path.join(base, '/', linkFile);\n }\n\n /**\n * Get all links from content\n * @param fileName fully qualified source file name\n * @param content markdown to parse\n */\n mineContent(fileName: string, content: string): ISummary[] {\n const result: ISummary[] = [];\n let match = mdPattern.exec(content);\n let linkFile: string;\n while (match !== null) {\n const summary = this.noDash(match[2]);\n linkFile = this.stripSearch(match[3]);\n if (!this.ignoreLink(linkFile)) {\n if (\n summary.localeCompare('[link]', undefined, {\n sensitivity: 'base',\n }) !== 0\n ) {\n linkFile = this.sourcerer(fileName, linkFile);\n result.push({ summary, sourceFile: linkFile });\n }\n }\n match = mdPattern.exec(content);\n }\n\n match = linkPattern.exec(content);\n while (match != null) {\n const summary = this.noDash(match[1]);\n linkFile = this.stripSearch(match[2]);\n if (!this.ignoreLink(linkFile)) {\n linkFile = this.sourcerer(fileName, linkFile);\n result.push({ summary, sourceFile: linkFile });\n }\n match = linkPattern.exec(content);\n }\n return result;\n }\n\n mineFile(fileName: string): ISummary[] {\n return this.mineContent(fileName, readFile(fileName));\n }\n}\n\nconst fileMiners: IMiners = {\n '.cs': new CodeMiner(),\n '.kt': new CodeMiner(),\n '.py': new CodeMiner(),\n '.swift': new CodeMiner(),\n '.ts': new CodeMiner(),\n '.tsx': new CodeMiner(),\n '.rb': new CodeMiner(),\n '.md': new MarkdownMiner(),\n '.dart': new CodeMiner(),\n '.go': new CodeMiner(),\n '.java': new CodeMiner(),\n // '.rst': new MarkdownMiner(), // TODO .rst miner? Probably not needed\n};\n\nexport class ExampleMiner {\n summaries: Summaries = {};\n nuggets: Nuggets = {};\n commitHash: string = getCommitHash();\n remoteOrigin: string = getPermalinkRoot();\n\n constructor(public readonly sourcePath: string) {\n this.execute(sourcePath);\n }\n\n get lode(): IExampleMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n summaries: this.summaries,\n nuggets: this.nuggets,\n };\n }\n\n addCall(ext: string, relativeFile: string, call: ISDKCall | ISummary) {\n function addFileCall(nugget: INugget) {\n // Extension is key for language\n let fileCalls = nugget.calls[ext];\n if (!fileCalls) {\n fileCalls = [];\n }\n const sdkCall = call as ISDKCall;\n const fileCall: IFileCall = {\n sourceFile: relativeFile,\n column: sdkCall.column,\n line: sdkCall.line,\n };\n if (\n !fileCalls.find(\n f =>\n f.line === fileCall.line &&\n f.column === fileCall.column &&\n f.sourceFile === fileCall.sourceFile\n )\n )\n fileCalls.push(fileCall);\n nugget.calls[ext] = fileCalls;\n }\n\n if ('summary' in call) {\n const s = call as ISummary;\n s.sourceFile = ExampleMiner.relate(this.sourcePath, s.sourceFile);\n this.summaries[s.sourceFile] = s;\n } else {\n let nugget: INugget = this.nuggets[call.operationId];\n if (!nugget) {\n nugget = { operationId: call.operationId, calls: {} };\n }\n addFileCall(nugget);\n this.nuggets[nugget.operationId] = nugget;\n }\n }\n\n /**\n * Derive relative path, retaining last directory\n * @param sourcePath original file search path\n * @param fileName fully qualified name of found file\n *\n * @example `Miner.relate('/a/b/c/', '/a/b/c/d.txt')` returns 'd.txt'\n */\n public static relate(sourcePath: string, fileName: string) {\n return path.relative(sourcePath, fileName);\n }\n\n processFile(fileName: string) {\n const ext = path.extname(fileName);\n if (ext in fileMiners) {\n const coder = fileMiners[ext];\n const calls = coder.mineFile(fileName);\n calls.forEach((call: ISDKCall | ISummary) => {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName);\n this.addCall(ext, relFile, call);\n });\n } else {\n warn(`${fileName} cannot be mined`);\n }\n }\n\n execute(sourcePath: string | null = null) {\n const dirPath = sourcePath ?? this.sourcePath;\n const files = getCodeFiles(dirPath);\n files.forEach(f => this.processFile(f));\n return this.lode;\n }\n}\n"],"mappings":";;;AA0BA,OAAO,KAAKA,EAAE,MAAM,IAAI;AACxB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,QAAQ,eAAe;AACxC,SAASC,IAAI,QAAQ,2BAA2B;AAwBhD,OAAO,IAAMC,QAAQ,GAAIC,QAAgB,IACvCL,EAAE,CAACM,YAAY,CAACD,QAAQ,EAAE;EAAEE,QAAQ,EAAE;AAAQ,CAAC,CAAC;AAElD,IAAMC,UAAU,GAAG,6CAA6C;AAChE,IAAMC,SAAS,GAAG,yBAAyB;AAC3C,IAAMC,WAAW,GAAG,8BAA8B;AAWlD,OAAO,IAAMC,cAAc,GAAIN,QAAgB,IAAKA,QAAQ,CAACO,IAAI,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC;AAM9E,OAAO,IAAMC,eAAe,GAAIT,QAAgB,IAAK;EACnD,IAAI,wBAAwB,CAACU,IAAI,CAACV,QAAQ,CAAC,EAAE,OAAO,K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AAQ,CAACnB,UAAU,EAAE9F,QAAQ,CAAC;EAC5C;EAEAkH,WAAWA,CAAClH,QAAgB,EAAE;IAC5B,IAAMW,GAAG,GAAGf,IAAI,CAACgB,OAAO,CAACZ,QAAQ,CAAC;IAClC,IAAIW,GAAG,IAAIG,UAAU,EAAE;MACrB,IAAMqG,KAAK,GAAGrG,UAAU,CAACH,GAAG,CAAC;MAC7B,IAAM+F,KAAK,GAAGS,KAAK,CAAC/C,QAAQ,CAACpE,QAAQ,CAAC;MACtC0G,KAAK,CAAC5E,OAAO,CAAEwB,IAAyB,IAAK;QAC3C,IAAM8D,OAAO,GAAGxB,YAAY,CAACoB,MAAM,CAAC,IAAI,CAAClB,UAAU,EAAE9F,QAAQ,CAAC;QAC9D,IAAI,CAACqG,OAAO,CAAC1F,GAAG,EAAEyG,OAAO,EAAE9D,IAAI,CAAC;MAClC,CAAC,CAAC;IACJ,CAAC,MAAM;MACLxD,IAAI,IAAAiD,MAAA,CAAI/C,QAAQ,qBAAkB,CAAC;IACrC;EACF;EAEA+F,OAAOA,CAAA,EAAmC;IAAA,IAAlCD,UAAyB,GAAA3E,SAAA,CAAAX,MAAA,QAAAW,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,IAAI;IACtC,IAAMkG,OAAO,GAAGvB,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,IAAI,CAACA,UAAU;IAC7C,IAAMlE,KAAK,GAAGQ,YAAY,CAACiF,OAAO,CAAC;IACnCzF,KAAK,CAACE,OAAO,CAACgF,CAAC,IAAI,IAAI,CAACI,WAAW,CAACJ,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAACd,IAAI;EAClB;AACF"}
1
+ {"version":3,"file":"exampleMiner.js","names":["fs","path","execSync","warn","readFile","fileName","readFileSync","encoding","sdkPattern","mdPattern","linkPattern","filterAllFiles","trim","length","filterCodeFiles","test","ext","extname","toLocaleLowerCase","fileMiners","IGNORE_PATHS","skipFolder","name","excludeList","arguments","undefined","RegExp","join","getAllFiles","searchPath","listOfFiles","filter","ignorePaths","files","readdirSync","forEach","file","statSync","isDirectory","push","_e","_getAllFiles","getCodeFiles","execRead","command","getCommitHash","getRemoteOrigin","getRemoteHttpOrigin","origin","gitExtractor","match","exec","httpExtractor","concat","getPermalinkRoot","root","endsWith","substring","CodeMiner","ignoreCall","call","sdk","ignoreOps","has","operationId","mineCode","sourceCode","lines","split","result","line","index","sdkRef","column","mineFile","_defineProperty","Set","MarkdownMiner","ignoreLink","linkFile","stripSearch","notCode","isHttp","noDash","value","dasher","replace","sourcerer","sourceFileName","startsWith","base","dirname","mineContent","content","summary","localeCompare","sensitivity","sourceFile","ExampleMiner","constructor","sourcePath","execute","lode","commitHash","remoteOrigin","summaries","nuggets","addCall","relativeFile","addFileCall","nugget","fileCalls","calls","sdkCall","fileCall","find","f","s","relate","relative","processFile","coder","relFile","dirPath"],"sources":["../../src/exampleMiner.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 { execSync } from 'child_process';\nimport { warn } from '@looker/sdk-codegen-utils';\nimport type {\n IExampleMine,\n IFileCall,\n INugget,\n ISDKCall,\n ISummary,\n Nuggets,\n SDKCalls,\n Summaries,\n} from '@looker/sdk-codegen';\n\nexport interface IFileMine {\n mineFile(fileName: string): SDKCalls;\n mineCode(code: string): SDKCalls;\n ignoreCall(call: ISDKCall): boolean;\n}\n\nexport interface IDocMine {\n mineFile(fileName: string): ISummary[];\n mineContent(sourceFile: string, content: string): ISummary[];\n ignoreLink(fileName: string): boolean;\n}\n\nexport const readFile = (fileName: string) =>\n fs.readFileSync(fileName, { encoding: 'utf-8' });\n\nconst sdkPattern = /(\\b[a-z0-9_]*sdk)\\.\\s*([a-z0-9_]*)\\s*[(<]/gi;\nconst mdPattern = /(\\[(.+?)\\]\\((.+?)\\))/gim;\nconst linkPattern = /(.*)\\[\\[link\\]\\]\\((.+?)\\)/gim;\n\nexport type IMiners = { [key: string]: IFileMine | IDocMine };\n\n/** file-filtering lambda for `getAllFiles()` and `getCodeFiles()` */\nexport type FileFilter = (fileName: string, pattern?: RegExp) => boolean;\n\n/**\n * Filter to include every file that has a non-empty file name\n * @param fileName name of file to check\n */\nexport const filterAllFiles = (fileName: string) => fileName.trim().length > 0;\n\n/**\n * Filter for code files\n * @param fileName name of file from which to extract its extension\n */\nexport const filterCodeFiles = (fileName: string) => {\n if (/(^|\\/)node_modules\\//gi.test(fileName)) return false;\n const ext = path.extname(fileName).toLocaleLowerCase();\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return ext in fileMiners;\n};\n\nexport const IGNORE_PATHS = [\n 'node_modules',\n 'lib',\n 'dist',\n 'bazel-bin',\n 'build',\n 'bin',\n '.build',\n '.direnv',\n '.github',\n '.vscode',\n '.idea',\n '.gradle',\n 'results',\n];\n\nconst skipFolder = (name: string, excludeList: string[] = IGNORE_PATHS) =>\n new RegExp(excludeList.join('|'), 'gi').test(name);\n\n/**\n * Finds all file recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of current files already found\n * @param filter lambda for file inclusion in results. truthy analyzes the file\n * @param ignorePaths paths to ignore\n */\nexport const getAllFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterAllFiles,\n ignorePaths: string[] = []\n) => {\n const files = fs.readdirSync(searchPath);\n\n files.forEach(file => {\n try {\n if (fs.statSync(searchPath + '/' + file).isDirectory()) {\n if (!skipFolder(file, ignorePaths))\n listOfFiles = getAllFiles(\n searchPath + '/' + file,\n listOfFiles,\n filter,\n ignorePaths\n );\n } else {\n if (filter(file)) {\n const fileName = path.join(searchPath, '/', file);\n listOfFiles.push(fileName);\n }\n }\n } catch (_e: any) {\n // warn(`skipping ${file}: ${e}`)\n }\n });\n\n return listOfFiles;\n};\n\n/**\n * Find all source code files recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of source code files that can be mined\n * @param filter function to determine whether a file should be analyzed\n * @param ignorePaths paths to ignore\n */\nexport const getCodeFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterCodeFiles,\n ignorePaths: string[] = IGNORE_PATHS\n) => {\n return getAllFiles(searchPath, listOfFiles, filter, ignorePaths);\n};\n\n/** get the trimmed output of the command as a UTF-8 string */\nexport const execRead = (command: string) => {\n return execSync(command, { encoding: 'utf-8' }).trim();\n};\n\n/** get this git repository's current commit hash */\nexport const getCommitHash = () => execRead('git rev-parse HEAD');\n\n/** get the remote origin url for this repository */\nexport const getRemoteOrigin = () => {\n return execRead('git remote get-url origin');\n};\n\n/**\n * Convert this github repository's git address to an HTTP url\n */\nexport const getRemoteHttpOrigin = () => {\n const origin = getRemoteOrigin();\n const gitExtractor = /git@github\\.com:(.*)\\.git/gi;\n let match = gitExtractor.exec(origin);\n if (!match) {\n // git origin on CI: https://github.com/looker-open-source/sdk-codegen\n const httpExtractor = /(https:\\/\\/github.com.*)(|.git)/;\n match = httpExtractor.exec(origin);\n if (!match) {\n return '';\n }\n return match[1];\n }\n return `https://github.com/${match[1]}`;\n};\n\n/** Permalink paths should not have the `.git` ending for a repo */\nexport const getPermalinkRoot = () => {\n let root = getRemoteHttpOrigin();\n if (root.endsWith('.git')) root = root.substring(0, root.length - 4);\n return root;\n};\n\nexport class CodeMiner implements IFileMine {\n static ignoreOps = new Set<string>(['ok', 'init40']);\n ignoreCall(call: ISDKCall): boolean {\n if (!/sdk/i.test(call.sdk)) return true;\n return CodeMiner.ignoreOps.has(call.operationId);\n }\n\n mineCode(sourceCode: string): SDKCalls {\n const lines = sourceCode.split('\\n');\n const result: SDKCalls = [];\n lines.forEach((line, index) => {\n let match = sdkPattern.exec(line);\n while (match !== null) {\n // TODO need to ignore source code comments?\n if (match && match.length > 2) {\n const sdkRef = match[1].trim();\n const call: ISDKCall = {\n sdk: sdkRef,\n operationId: match[2].trim(),\n line: index + 1,\n column: match.index,\n };\n if (!this.ignoreCall(call)) {\n result.push(call);\n }\n }\n match = sdkPattern.exec(line);\n }\n });\n return result;\n }\n\n mineFile(fileName: string): SDKCalls {\n return this.mineCode(readFile(fileName));\n }\n}\n\n/**\n * Processes markdown files and extracts links to source code to use as summaries\n */\nexport class MarkdownMiner implements IDocMine {\n // TODO ensure summaries don't include markdown files\n ignoreLink(linkFile: string): boolean {\n linkFile = this.stripSearch(linkFile);\n const ext = path.extname(linkFile).toLocaleLowerCase();\n const notCode = ext === '.md' || !filterCodeFiles(linkFile);\n const isHttp = /^(http|https):/gi.test(linkFile);\n return notCode || isHttp;\n }\n\n /**\n * Remove leading - from a string\n * @param value string to process\n */\n noDash(value: string) {\n value = value.trim();\n const dasher = /^\\s*-\\s*(.*)/g;\n if (dasher.test(value)) {\n value = value.replace(dasher, '$1');\n }\n return value.trim();\n }\n\n stripSearch(fileName: string) {\n fileName = fileName.trim();\n const match = /(.*)#.*/gi.exec(fileName);\n if (match) fileName = match[1];\n return fileName;\n }\n\n /**\n * Fully qualify the path for `linkFile`\n * @param sourceFileName\n * @param linkFile\n */\n sourcerer(sourceFileName: string, linkFile: string) {\n linkFile = this.stripSearch(linkFile);\n if (linkFile.startsWith('/')) return linkFile.substring(1);\n const base = path.dirname(sourceFileName);\n return path.join(base, '/', linkFile);\n }\n\n /**\n * Get all links from content\n * @param fileName fully qualified source file name\n * @param content markdown to parse\n */\n mineContent(fileName: string, content: string): ISummary[] {\n const result: ISummary[] = [];\n let match = mdPattern.exec(content);\n let linkFile: string;\n while (match !== null) {\n const summary = this.noDash(match[2]);\n linkFile = this.stripSearch(match[3]);\n if (!this.ignoreLink(linkFile)) {\n if (\n summary.localeCompare('[link]', undefined, {\n sensitivity: 'base',\n }) !== 0\n ) {\n linkFile = this.sourcerer(fileName, linkFile);\n result.push({ summary, sourceFile: linkFile });\n }\n }\n match = mdPattern.exec(content);\n }\n\n match = linkPattern.exec(content);\n while (match != null) {\n const summary = this.noDash(match[1]);\n linkFile = this.stripSearch(match[2]);\n if (!this.ignoreLink(linkFile)) {\n linkFile = this.sourcerer(fileName, linkFile);\n result.push({ summary, sourceFile: linkFile });\n }\n match = linkPattern.exec(content);\n }\n return result;\n }\n\n mineFile(fileName: string): ISummary[] {\n return this.mineContent(fileName, readFile(fileName));\n }\n}\n\nconst fileMiners: IMiners = {\n '.cs': new CodeMiner(),\n '.kt': new CodeMiner(),\n '.py': new CodeMiner(),\n '.swift': new CodeMiner(),\n '.ts': new CodeMiner(),\n '.tsx': new CodeMiner(),\n '.rb': new CodeMiner(),\n '.md': new MarkdownMiner(),\n '.dart': new CodeMiner(),\n '.go': new CodeMiner(),\n '.java': new CodeMiner(),\n // '.rst': new MarkdownMiner(), // TODO .rst miner? Probably not needed\n};\n\nexport class ExampleMiner {\n summaries: Summaries = {};\n nuggets: Nuggets = {};\n commitHash: string = getCommitHash();\n remoteOrigin: string = getPermalinkRoot();\n\n constructor(public readonly sourcePath: string) {\n this.execute(sourcePath);\n }\n\n get lode(): IExampleMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n summaries: this.summaries,\n nuggets: this.nuggets,\n };\n }\n\n addCall(ext: string, relativeFile: string, call: ISDKCall | ISummary) {\n function addFileCall(nugget: INugget) {\n // Extension is key for language\n let fileCalls = nugget.calls[ext];\n if (!fileCalls) {\n fileCalls = [];\n }\n const sdkCall = call as ISDKCall;\n const fileCall: IFileCall = {\n sourceFile: relativeFile,\n column: sdkCall.column,\n line: sdkCall.line,\n };\n if (\n !fileCalls.find(\n f =>\n f.line === fileCall.line &&\n f.column === fileCall.column &&\n f.sourceFile === fileCall.sourceFile\n )\n )\n fileCalls.push(fileCall);\n nugget.calls[ext] = fileCalls;\n }\n\n if ('summary' in call) {\n const s = call as ISummary;\n s.sourceFile = ExampleMiner.relate(this.sourcePath, s.sourceFile);\n this.summaries[s.sourceFile] = s;\n } else {\n let nugget: INugget = this.nuggets[call.operationId];\n if (!nugget) {\n nugget = { operationId: call.operationId, calls: {} };\n }\n addFileCall(nugget);\n this.nuggets[nugget.operationId] = nugget;\n }\n }\n\n /**\n * Derive relative path, retaining last directory\n * @param sourcePath original file search path\n * @param fileName fully qualified name of found file\n *\n * @example `Miner.relate('/a/b/c/', '/a/b/c/d.txt')` returns 'd.txt'\n */\n public static relate(sourcePath: string, fileName: string) {\n return path.relative(sourcePath, fileName);\n }\n\n processFile(fileName: string) {\n const ext = path.extname(fileName);\n if (ext in fileMiners) {\n const coder = fileMiners[ext];\n const calls = coder.mineFile(fileName);\n calls.forEach((call: ISDKCall | ISummary) => {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName);\n this.addCall(ext, relFile, call);\n });\n } else {\n warn(`${fileName} cannot be mined`);\n }\n }\n\n execute(sourcePath: string | null = null) {\n const dirPath = sourcePath ?? this.sourcePath;\n const files = getCodeFiles(dirPath);\n files.forEach(f => this.processFile(f));\n return this.lode;\n }\n}\n"],"mappings":";;;AA0BA,OAAO,KAAKA,EAAE,MAAM,IAAI;AACxB,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,Q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CAAAX,MAAA,QAAAW,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,IAAI;IACtC,IAAMmG,OAAO,GAAGvB,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,IAAI,CAACA,UAAU;IAC7C,IAAMnE,KAAK,GAAGS,YAAY,CAACiF,OAAO,CAAC;IACnC1F,KAAK,CAACE,OAAO,CAACiF,CAAC,IAAI,IAAI,CAACI,WAAW,CAACJ,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAACd,IAAI;EAClB;AACF","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- 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); } }
2
- 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); }); }; }
1
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
3
  import fs from 'fs';
4
4
  import { describe, it } from 'node:test';
5
5
  import { expect } from 'expect';
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSpec.apispec.js","names":["fs","describe","it","expect","getSpecsFromVersions","specToModel","TestConfig","fetchLookerVersion","fetchLookerVersions","getVersionInfo","logConvertSpec","login","supportedVersion","ApiConfigSection","config","props","readFileSync","localIni","api_version","_asyncToGenerator","testProps","JSON","parse","stringify","base_url","actual","undefined","timeout","toEqual","not","looker_release_version","toBeDefined","version","lookerVersion","spec","token","swagger_url","name","lookerVersions","specs","length","toBeGreaterThan"],"sources":["../../src/fetchSpec.apispec.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 fs from 'fs';\nimport { describe, it } from 'node:test';\nimport { expect } from 'expect';\nimport { getSpecsFromVersions, specToModel } from '@looker/sdk-codegen';\nimport { TestConfig } from '@looker/sdk-codegen-utils';\nimport {\n fetchLookerVersion,\n fetchLookerVersions,\n getVersionInfo,\n logConvertSpec,\n login,\n supportedVersion,\n} from './fetchSpec';\nimport type { ISDKConfigProps } from './sdkConfig';\nimport { ApiConfigSection } from '@looker/sdk-node';\n\nconst config = TestConfig(specToModel);\nconst props = ApiConfigSection(\n fs.readFileSync(config.localIni, 'utf8')\n) as unknown as ISDKConfigProps;\n// api_version is no longer part of the INI, now set by sdkGen iterator\nprops.api_version = '4.0';\n\ndescribe('fetch operations', () => {\n it('defaults lookerVersion when server is not responding', async () => {\n const testProps = JSON.parse(JSON.stringify(props));\n testProps.base_url = 'https://bogus-server.looker.com:99';\n const actual = await fetchLookerVersion(testProps, undefined, {\n timeout: 3,\n });\n expect(actual).toEqual('');\n });\n\n it('gets lookerVersion with good server', async () => {\n const actual = await fetchLookerVersion(props);\n expect(actual).not.toEqual('');\n });\n\n it('gets lookerVersion with supplied versions', async () => {\n const actual = await fetchLookerVersion(props, {\n looker_release_version: '7.10.0',\n });\n expect(actual).toEqual('7.10');\n });\n\n it('gets version info', async () => {\n expect(props).toBeDefined();\n const version = await getVersionInfo(props);\n expect(version).toBeDefined();\n if (version) {\n expect(version.lookerVersion).toBeDefined();\n expect(version.spec).toBeDefined();\n }\n });\n\n it('can login', async () => {\n expect(props).toBeDefined();\n const token = await login(props);\n expect(token).toBeDefined();\n });\n\n it('get versions', async () => {\n expect(props).toBeDefined();\n const actual = await fetchLookerVersions(props);\n expect(actual).toBeDefined();\n const version: any = supportedVersion('4.0', actual);\n expect(version).toBeDefined();\n if (version) {\n expect(version.version).toEqual('4.0');\n expect(version.swagger_url).toBeDefined();\n // TODO enable when these values are surfaced in Looker\n // expect(version.swagger_min_url).toBeDefined()\n // expect(version.openapi_url).toBeDefined()\n // expect(version.openapi_min_url).toBeDefined()\n }\n });\n\n it('logConvertSpec', async () => {\n expect(props).toBeDefined();\n const name = 'Looker';\n const lookerVersions = await fetchLookerVersions(props);\n const specs = await getSpecsFromVersions(lookerVersions);\n const actual = await logConvertSpec(\n name,\n specs[props.api_version],\n lookerVersions,\n true\n );\n expect(actual).toBeDefined();\n expect(actual.length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;AA0BA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,QAAQ,EAAEC,EAAE,QAAQ,WAAW;AACxC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,qBAAqB;AACvE,S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B,EAAAiB,iBAAA,CAAE,aAAY;IAC/BhB,MAAM,CAACY,KAAK,CAAC,CAACgB,WAAW,CAAC,CAAC;IAC3B,IAAMM,IAAI,GAAG,QAAQ;IACrB,IAAMC,cAAc,SAAS9B,mBAAmB,CAACO,KAAK,CAAC;IACvD,IAAMwB,KAAK,SAASnC,oBAAoB,CAACkC,cAAc,CAAC;IACxD,IAAMb,MAAM,SAASf,cAAc,CACjC2B,IAAI,EACJE,KAAK,CAACxB,KAAK,CAACG,WAAW,CAAC,EACxBoB,cAAc,EACd,IACF,CAAC;IACDnC,MAAM,CAACsB,MAAM,CAAC,CAACM,WAAW,CAAC,CAAC;IAC5B5B,MAAM,CAACsB,MAAM,CAACe,MAAM,CAAC,CAACC,eAAe,CAAC,CAAC,CAAC;EAC1C,CAAC,EAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"fetchSpec.apispec.js","names":["fs","describe","it","expect","getSpecsFromVersions","specToModel","TestConfig","fetchLookerVersion","fetchLookerVersions","getVersionInfo","logConvertSpec","login","supportedVersion","ApiConfigSection","config","props","readFileSync","localIni","api_version","_asyncToGenerator","testProps","JSON","parse","stringify","base_url","actual","undefined","timeout","toEqual","not","looker_release_version","toBeDefined","version","lookerVersion","spec","token","swagger_url","name","lookerVersions","specs","length","toBeGreaterThan"],"sources":["../../src/fetchSpec.apispec.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 fs from 'fs';\nimport { describe, it } from 'node:test';\nimport { expect } from 'expect';\nimport { getSpecsFromVersions, specToModel } from '@looker/sdk-codegen';\nimport { TestConfig } from '@looker/sdk-codegen-utils';\nimport {\n fetchLookerVersion,\n fetchLookerVersions,\n getVersionInfo,\n logConvertSpec,\n login,\n supportedVersion,\n} from './fetchSpec';\nimport type { ISDKConfigProps } from './sdkConfig';\nimport { ApiConfigSection } from '@looker/sdk-node';\n\nconst config = TestConfig(specToModel);\nconst props = ApiConfigSection(\n fs.readFileSync(config.localIni, 'utf8')\n) as unknown as ISDKConfigProps;\n// api_version is no longer part of the INI, now set by sdkGen iterator\nprops.api_version = '4.0';\n\ndescribe('fetch operations', () => {\n it('defaults lookerVersion when server is not responding', async () => {\n const testProps = JSON.parse(JSON.stringify(props));\n testProps.base_url = 'https://bogus-server.looker.com:99';\n const actual = await fetchLookerVersion(testProps, undefined, {\n timeout: 3,\n });\n expect(actual).toEqual('');\n });\n\n it('gets lookerVersion with good server', async () => {\n const actual = await fetchLookerVersion(props);\n expect(actual).not.toEqual('');\n });\n\n it('gets lookerVersion with supplied versions', async () => {\n const actual = await fetchLookerVersion(props, {\n looker_release_version: '7.10.0',\n });\n expect(actual).toEqual('7.10');\n });\n\n it('gets version info', async () => {\n expect(props).toBeDefined();\n const version = await getVersionInfo(props);\n expect(version).toBeDefined();\n if (version) {\n expect(version.lookerVersion).toBeDefined();\n expect(version.spec).toBeDefined();\n }\n });\n\n it('can login', async () => {\n expect(props).toBeDefined();\n const token = await login(props);\n expect(token).toBeDefined();\n });\n\n it('get versions', async () => {\n expect(props).toBeDefined();\n const actual = await fetchLookerVersions(props);\n expect(actual).toBeDefined();\n const version: any = supportedVersion('4.0', actual);\n expect(version).toBeDefined();\n if (version) {\n expect(version.version).toEqual('4.0');\n expect(version.swagger_url).toBeDefined();\n // TODO enable when these values are surfaced in Looker\n // expect(version.swagger_min_url).toBeDefined()\n // expect(version.openapi_url).toBeDefined()\n // expect(version.openapi_min_url).toBeDefined()\n }\n });\n\n it('logConvertSpec', async () => {\n expect(props).toBeDefined();\n const name = 'Looker';\n const lookerVersions = await fetchLookerVersions(props);\n const specs = await getSpecsFromVersions(lookerVersions);\n const actual = await logConvertSpec(\n name,\n specs[props.api_version],\n lookerVersions,\n true\n );\n expect(actual).toBeDefined();\n expect(actual.length).toBeGreaterThan(0);\n });\n});\n"],"mappings":";;AA0BA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,QAAQ,EAAEC,EAAE,QAAQ,WAAW;AACxC,SAASC,MAAM,QAAQ,QAAQ;AAC/B,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,qBAAqB;AACvE,SAASC,UAAU,QAAQ,2BAA2B;AACtD,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,cAAc,EACdC,cAAc,EACdC,KAAK,EACLC,gBAAgB,QACX,aAAa;AAEpB,SAASC,gBAAgB,QAAQ,kBAAkB;AAEnD,IAAMC,MAAM,GAAGR,UAAU,CAACD,WAAW,CAAC;AACtC,IAAMU,KAAK,GAAGF,gBAAgB,CAC5Bb,EAAE,CAACgB,YAAY,CAACF,MAAM,CAACG,QAAQ,EAAE,MAAM,CACzC,CAA+B;AAE/BF,KAAK,CAACG,WAAW,GAAG,KAAK;AAEzBjB,QAAQ,CAAC,kBAAkB,EAAE,MAAM;EACjCC,EAAE,CAAC,sDAAsD,EAAAiB,iBAAA,CAAE,aAAY;IACrE,IAAMC,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,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