@looker/sdk-codegen-scripts 21.5.29 → 21.5.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/lib/convert.apispec.js +3 -1
- package/lib/convert.apispec.js.map +1 -1
- package/lib/declarationMiner.js +3 -2
- package/lib/declarationMiner.js.map +1 -1
- package/lib/esm/convert.apispec.js +3 -1
- package/lib/esm/convert.apispec.js.map +1 -1
- package/lib/esm/declarationMiner.js +3 -2
- package/lib/esm/declarationMiner.js.map +1 -1
- package/lib/esm/prettify.js +1 -3
- package/lib/esm/prettify.js.map +1 -1
- package/lib/esm/sdkGen.js +18 -8
- package/lib/esm/sdkGen.js.map +1 -1
- package/lib/esm/sdkGenerator.js +22 -0
- package/lib/esm/sdkGenerator.js.map +1 -1
- package/lib/esm/utils.js +14 -11
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/yamlToJson.js +1 -1
- package/lib/esm/yamlToJson.js.map +1 -1
- package/lib/prettify.js +1 -3
- package/lib/prettify.js.map +1 -1
- package/lib/sdkGen.js +17 -7
- package/lib/sdkGen.js.map +1 -1
- package/lib/sdkGenerator.d.ts +10 -0
- package/lib/sdkGenerator.js +25 -1
- package/lib/sdkGenerator.js.map +1 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +14 -11
- package/lib/utils.js.map +1 -1
- package/lib/yamlToJson.js +1 -1
- package/lib/yamlToJson.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -205,6 +205,33 @@
|
|
|
205
205
|
* @looker/sdk-codegen-utils bumped from 21.0.18 to 21.0.19
|
|
206
206
|
* @looker/sdk-node bumped from 25.0.0 to 25.0.1
|
|
207
207
|
|
|
208
|
+
### Dependencies
|
|
209
|
+
|
|
210
|
+
* The following workspace dependencies were updated
|
|
211
|
+
* dependencies
|
|
212
|
+
* @looker/sdk bumped from 25.0.1 to 25.2.0
|
|
213
|
+
* @looker/sdk-codegen bumped from 21.9.8 to 21.9.9
|
|
214
|
+
* @looker/sdk-codegen-utils bumped from 21.0.19 to 21.0.20
|
|
215
|
+
* @looker/sdk-node bumped from 25.0.1 to 25.2.0
|
|
216
|
+
|
|
217
|
+
## [21.5.31](https://github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-scripts-v21.5.30...sdk-codegen-scripts-v21.5.31) (2025-03-11)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
### Bug Fixes
|
|
221
|
+
|
|
222
|
+
* add new generators for the TypeScript SDK ([#1563](https://github.com/looker-open-source/sdk-codegen/issues/1563)) ([86ab782](https://github.com/looker-open-source/sdk-codegen/commit/86ab7820c4ca095be20e219c5bd19ef3bfc3f030))
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
### Dependencies
|
|
226
|
+
|
|
227
|
+
* The following workspace dependencies were updated
|
|
228
|
+
* dependencies
|
|
229
|
+
* @looker/sdk bumped from 25.2.0 to 25.4.0
|
|
230
|
+
* @looker/sdk-codegen bumped from 21.9.9 to 21.9.10
|
|
231
|
+
* @looker/sdk-codegen-utils bumped from 21.0.20 to 21.0.21
|
|
232
|
+
* @looker/sdk-node bumped from 25.2.0 to 25.4.0
|
|
233
|
+
* @looker/sdk-rtl bumped from 21.6.3 to 21.6.4
|
|
234
|
+
|
|
208
235
|
## [21.5.23](https://github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-scripts-v21.5.22...sdk-codegen-scripts-v21.5.23) (2024-09-14)
|
|
209
236
|
|
|
210
237
|
|
package/lib/convert.apispec.js
CHANGED
|
@@ -107,7 +107,9 @@ var baseUrl = sdk.authSession.settings.base_url;
|
|
|
107
107
|
var keys = Object.keys(actual);
|
|
108
108
|
(0, _expect.expect)(keys).toHaveLength(Object.keys(defs).length);
|
|
109
109
|
});
|
|
110
|
-
_nodeTest.it
|
|
110
|
+
(0, _nodeTest.it)('matches a reference OpenAPI conversion', {
|
|
111
|
+
skip: true
|
|
112
|
+
}, () => {
|
|
111
113
|
var spec = (0, _sdkCodegen.upgradeSpec)(swaggerSource);
|
|
112
114
|
(0, _expect.expect)(spec).toBeDefined();
|
|
113
115
|
var left = _sdkCodegen.ApiModel.fromString(apiSource);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.apispec.js","names":["_fs","require","_nodeTest","_expect","_cloneDeep","_interopRequireDefault","_isEmpty","_sdkNode","_sdkCodegen","_sdkCodegenUtils","obj","__esModule","default","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","swaggerFrag","openApiFrag","specFrag","swagger","JSON","parse","api","config","TestConfig","specToModel","swaggerFile","testFile","apiFile","swaggerSource","readFileSync","fullSwagger","apiSource","settings","NodeSettingsIniFile","localIni","sdk","LookerNodeSDK","init40","baseUrl","authSession","base_url","describe","it","actual","swapXLookerTags","expect","toContain","not","openApiStyle","toEqual","toBeUndefined","fixConversion","spec","fixes","toHaveLength","onlyPublic","specs","filter","v","status","toBeDefined","getLookerSpecs","looker_release_version","current_version","version","supported","supported_versions","versions","getSpecLinks","forEach","name","url","isEmpty","current","find","s","links","link","replace","substring","indexOf","loadSpecs","description","op","paths","get","param","parameters","convertParam","expected","defs","definitions","convertDefs","keys","Object","length","skip","upgradeSpec","left","ApiModel","fromString","right","diff","compareSpecs","full_version","swagger_url","api_server_url","getSpecsFromVersions","entries","_ref6","_","a","isDefault","moar","cloneDeep","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 it.skip('matches a reference OpenAPI conversion', () => {\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,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAEA,IAAAO,WAAA,GAAAP,OAAA;AAeA,IAAAQ,gBAAA,GAAAR,OAAA;AAAiE,SAAAI,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KA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CAACd,MAAM,CAAC,CAACV,OAAO,CAAC,SAAS,CAAC;QACzC,IAAAJ,cAAM,EAAC4B,OAAO,CAACuC,SAAS,CAAC,CAAC/D,OAAO,CAAC,IAAI,CAAC;MACzC;IACF,CAAC,EAAC;IAEF,IAAAP,YAAE,EAAC,wBAAwB,EAAAnC,iBAAA,CAAE,aAAY;MACvC,IAAM0G,IAAI,GAAG,IAAAC,kBAAS,EAAC/C,QAAQ,CAAC;MAChC8C,IAAI,CAAC/C,kBAAkB,CAACiD,IAAI,CAC1B;QACEnD,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CAAC,EACD;QACEzC,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CAAC,EACD;QACEzC,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CAAC,EACD;QACEzC,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CACF,CAAC;MACD,IAAM9D,MAAM,SAAS,IAAAgE,gCAAoB,EAACM,IAAI,CAAC;MAC/C,IAAApE,cAAM,EAACiD,MAAM,CAACD,IAAI,CAAClD,MAAM,CAAC,CAAC,CAACM,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":["_fs","require","_nodeTest","_expect","_cloneDeep","_interopRequireDefault","_isEmpty","_sdkNode","_sdkCodegen","_sdkCodegenUtils","obj","__esModule","default","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","swaggerFrag","openApiFrag","specFrag","swagger","JSON","parse","api","config","TestConfig","specToModel","swaggerFile","testFile","apiFile","swaggerSource","readFileSync","fullSwagger","apiSource","settings","NodeSettingsIniFile","localIni","sdk","LookerNodeSDK","init40","baseUrl","authSession","base_url","describe","it","actual","swapXLookerTags","expect","toContain","not","openApiStyle","toEqual","toBeUndefined","fixConversion","spec","fixes","toHaveLength","onlyPublic","specs","filter","v","status","toBeDefined","getLookerSpecs","looker_release_version","current_version","version","supported","supported_versions","versions","getSpecLinks","forEach","name","url","isEmpty","current","find","s","links","link","replace","substring","indexOf","loadSpecs","description","op","paths","get","param","parameters","convertParam","expected","defs","definitions","convertDefs","keys","Object","length","skip","upgradeSpec","left","ApiModel","fromString","right","diff","compareSpecs","full_version","swagger_url","api_server_url","getSpecsFromVersions","entries","_ref6","_","a","isDefault","moar","cloneDeep","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,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAEA,IAAAO,WAAA,GAAAP,OAAA;AAeA,IAAAQ,gBAAA,GAAAR,OAAA;AAAiE,SAAAI,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,mBAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,GAAA,EAAAC,GAAA,cAAAC,IAAA,GAAAP,GAAA,CAAAK,GAAA,EAAAC,GAAA,OAAAE,KAAA,GAAAD,IAAA,CAAAC,KAAA,WAAAC,KAAA,IAAAP,MAAA,CAAAO,KAAA,iBAAAF,IAAA,CAA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,kBAAS,EAAC/C,QAAQ,CAAC;MAChC8C,IAAI,CAAC/C,kBAAkB,CAACiD,IAAI,CAC1B;QACEnD,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CAAC,EACD;QACEzC,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CAAC,EACD;QACEzC,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CAAC,EACD;QACEzC,OAAO,EAAE,KAAK;QACdwC,YAAY,EAAE,MAAM;QACpB7C,MAAM,EAAE,IAAI;QACZ8C,WAAW,EAAE;MACf,CACF,CAAC;MACD,IAAM9D,MAAM,SAAS,IAAAgE,gCAAoB,EAACM,IAAI,CAAC;MAC/C,IAAApE,cAAM,EAACiD,MAAM,CAACD,IAAI,CAAClD,MAAM,CAAC,CAAC,CAACM,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"}
|
package/lib/declarationMiner.js
CHANGED
|
@@ -26,8 +26,9 @@ var rubyMethodProbe = exports.rubyMethodProbe = {
|
|
|
26
26
|
path: 2
|
|
27
27
|
}),
|
|
28
28
|
matchToSpecKeyTransform: match => {
|
|
29
|
-
var
|
|
30
|
-
var
|
|
29
|
+
var _match$groups, _match$groups2;
|
|
30
|
+
var verb = (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.verb.toLocaleUpperCase();
|
|
31
|
+
var path = (_match$groups2 = match.groups) === null || _match$groups2 === void 0 ? void 0 : _match$groups2.path.replace(':#', '').replace('#', '').replace(/:(\w+)/g, '{$1}');
|
|
31
32
|
var key = "".concat(verb, " ").concat(path);
|
|
32
33
|
return key;
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarationMiner.js","names":["_path","_interopRequireDefault","require","_exampleMiner","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","_wrapRegExp","BabelRegExp","RegExp","prototype","WeakMap","p","set","get","_setPrototypeOf","buildGroups","reduce","create","_inherits","exec","groups","indices","replace","Array","isArray","join","slice","subClass","superClass","constructor","setPrototypeOf","bind","__proto__","fileFilter","endpointFilePattern","typeFilePattern","fileName","fileMatch","test","filterCodeFiles","rubyMethodProbe","exports","fileNamePattern","declarationPattern","verb","path","matchToSpecKeyTransform","match","toLocaleUpperCase","concat","rubyTypeProbe","typeName","DeclarationMiner","sourcePath","methodProbe","typeProbe","originOverride","execute","filePath","mProbe","tProbe","files","getCodeFiles","undefined","f","relFile","processFile","basename","methods","mineFile","types","lode","commitHash","process","chdir","getCommitHash","remoteOrigin","getRemoteOrigin","ExampleMiner","relate","probe","mineCode","readFile","content","lines","split","declarations","line","index","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\n .groups!.path.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 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,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,aAAA,GAAAD,OAAA;AAOwB,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WAAAd,CAAA,IAAAE,MAAA,CAAAgB,cAA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AAI,CAAC;MACjD,IAAIxC,KAAK,EAAE;QACT,IAAMtD,GAAG,GAAGuF,KAAK,CAAClC,uBAAuB,CAACC,KAAK,CAAC;QAChDuC,YAAY,CAAC7F,GAAG,CAAC,GAAG;UAClB8F,IAAI,EAAEC,KAAK,GAAG,CAAC;UACfC,UAAU,EAAExB;QACd,CAAC;MACH;IACF,CAAC,CAAC;IACF,OAAOqB,YAAY;EACrB;AACF;AAAC7C,OAAA,CAAAW,gBAAA,GAAAA,gBAAA"}
|
|
1
|
+
{"version":3,"file":"declarationMiner.js","names":["_path","_interopRequireDefault","require","_exampleMiner","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","_wrapRegExp","BabelRegExp","RegExp","prototype","WeakMap","p","set","get","_setPrototypeOf","buildGroups","reduce","create","_inherits","exec","groups","indices","replace","Array","isArray","join","slice","subClass","superClass","constructor","setPrototypeOf","bind","__proto__","fileFilter","endpointFilePattern","typeFilePattern","fileName","fileMatch","test","filterCodeFiles","rubyMethodProbe","exports","fileNamePattern","declarationPattern","verb","path","matchToSpecKeyTransform","match","_match$groups","_match$groups2","toLocaleUpperCase","concat","rubyTypeProbe","typeName","DeclarationMiner","sourcePath","methodProbe","typeProbe","originOverride","execute","filePath","mProbe","tProbe","files","getCodeFiles","undefined","f","relFile","processFile","basename","methods","mineFile","types","lode","commitHash","process","chdir","getCommitHash","remoteOrigin","getRemoteOrigin","ExampleMiner","relate","probe","mineCode","readFile","content","lines","split","declarations","line","index","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,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,aAAA,GAAAD,OAAA;AAOwB,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa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AAI,CAACC,QAAQ,CAAChB,OAAO,EAAE,IAAAiB,sBAAQ,EAAChD,QAAQ,CAAC,EAAE8C,KAAK,CAAC;EAC1D;EAEUC,QAAQA,CAAChB,OAAe,EAAEkB,OAAe,EAAEH,KAAa,EAAE;IAClE,IAAMI,KAAK,GAAGD,OAAO,CAACE,KAAK,CAAC,IAAI,CAAC;IACjC,IAAMC,YAAgC,GAAG,CAAC,CAAC;IAC3CF,KAAK,CAAClG,OAAO,CAAC,CAACqG,IAAI,EAAEC,KAAK,KAAK;MAC7B,IAAM3C,KAAK,GAAGmC,KAAK,CAACvC,kBAAkB,CAACxB,IAAI,CAACsE,IAAI,CAAC;MACjD,IAAI1C,KAAK,EAAE;QACT,IAAMtD,GAAG,GAAGyF,KAAK,CAACpC,uBAAuB,CAACC,KAAK,CAAC;QAChDyC,YAAY,CAAC/F,GAAG,CAAC,GAAG;UAClBgG,IAAI,EAAEC,KAAK,GAAG,CAAC;UACfC,UAAU,EAAExB;QACd,CAAC;MACH;IACF,CAAC,CAAC;IACF,OAAOqB,YAAY;EACrB;AACF;AAAC/C,OAAA,CAAAa,gBAAA,GAAAA,gBAAA"}
|
|
@@ -104,7 +104,9 @@ describe('spec conversion', () => {
|
|
|
104
104
|
var keys = Object.keys(actual);
|
|
105
105
|
expect(keys).toHaveLength(Object.keys(defs).length);
|
|
106
106
|
});
|
|
107
|
-
it
|
|
107
|
+
it('matches a reference OpenAPI conversion', {
|
|
108
|
+
skip: true
|
|
109
|
+
}, () => {
|
|
108
110
|
var spec = upgradeSpec(swaggerSource);
|
|
109
111
|
expect(spec).toBeDefined();
|
|
110
112
|
var left = ApiModel.fromString(apiSource);
|
|
@@ -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 it.skip('matches a reference OpenAPI conversion', () => {\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,WAA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AE;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"}
|
|
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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C;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -19,8 +19,9 @@ export var rubyMethodProbe = {
|
|
|
19
19
|
path: 2
|
|
20
20
|
}),
|
|
21
21
|
matchToSpecKeyTransform: match => {
|
|
22
|
-
var
|
|
23
|
-
var
|
|
22
|
+
var _match$groups, _match$groups2;
|
|
23
|
+
var verb = (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.verb.toLocaleUpperCase();
|
|
24
|
+
var path = (_match$groups2 = match.groups) === null || _match$groups2 === void 0 ? void 0 : _match$groups2.path.replace(':#', '').replace('#', '').replace(/:(\w+)/g, '{$1}');
|
|
24
25
|
var key = "".concat(verb, " ").concat(path);
|
|
25
26
|
return key;
|
|
26
27
|
}
|