Skip to content

Commit 86ab782

Browse files
authored
fix: add new generators for the TypeScript SDK (#1563)
Synchronized the latest sdk-codegen code from internal development. The MSW and SDK data hooks generators aren't yet ready for public consumption but they do work for internal testing
1 parent dfc0637 commit 86ab782

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1248
-1002
lines changed

examplesIndex.json

Lines changed: 871 additions & 751 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"@types/blueimp-md5": "^2.7.0",
101101
"@types/ini": "^1.3.30",
102102
"@types/jest": "29.2.4",
103-
"@types/js-yaml": "^3.12.1",
103+
"@types/js-yaml": "4.0.9",
104104
"@types/lodash": "4.14.172",
105105
"@types/node": "22.5.4",
106106
"@types/prettier": "2.7.3",
@@ -136,7 +136,7 @@
136136
"jest-environment-node": "29.7.0",
137137
"jest-junit": "12.3.0",
138138
"jest-styled-components": "7.1.1",
139-
"js-yaml": "3.14.1",
139+
"js-yaml": "4.1.0",
140140
"jsdom": "21.1.2",
141141
"lerna": "3.22.1",
142142
"lint-staged": "10.2.2",

packages/api-explorer/src/utils/sdkLanguage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
*/
2626

27-
import type { ArgValues } from '@looker/sdk-codegen';
27+
import type { ArgValues } from '@looker/sdk-rtl';
2828
import { codeGenerators } from '@looker/sdk-codegen';
2929

3030
export const allAlias = 'all';
@@ -36,7 +36,7 @@ export const allAlias = 'all';
3636
export const allSdkLanguages = (): Record<string, string> => {
3737
const languages: ArgValues = {};
3838
codeGenerators.forEach(gen => {
39-
const alias = gen.extension.toString().match(/\.(\w+)\b/)![1];
39+
const alias = (gen.extension.toString().match(/\.(\w+)\b/) ?? [])[1];
4040
languages[alias] = gen.language;
4141
});
4242

packages/sdk-codegen-scripts/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
"cross-env": "^7.0.2"
3737
},
3838
"devDependencies": {
39-
"@openapitools/openapi-generator-cli": "^2.1.23",
40-
"@types/config": "^0.0.36",
41-
"dotenv": "^8.2.0",
39+
"@openapitools/openapi-generator-cli": "2.7.0",
40+
"@types/config": "0.0.36",
41+
"dotenv": "8.2.0",
4242
"expect": "29.7.0",
4343
"file-type": "^16.5.4",
4444
"ini": "^1.3.8",
45-
"js-yaml": "3.14.1",
45+
"js-yaml": "4.1.0",
4646
"openapi3-ts": "2.0.2",
4747
"@types/prettier": "2.7.3",
4848
"prettier": "2.8.8",

packages/sdk-codegen-scripts/scripts/mineDeclarations.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import {
6666
}
6767
}
6868
const indexFile = path.join(root, indexName);
69+
/* eslint-disable no-console */
6970
console.log(`Mining declarations from ${sourcePath} ...`);
7071

7172
const miner = new DeclarationMiner(
@@ -78,6 +79,7 @@ import {
7879
fs.writeFileSync(indexFile, JSON.stringify(result, null, 2), {
7980
encoding: 'utf-8',
8081
});
82+
/* eslint-disable no-console */
8183
console.log(
8284
`${
8385
Object.entries(result.methods).length +
@@ -89,12 +91,14 @@ import {
8991
fs.writeFileSync(indexCopy, JSON.stringify(result, null, 2), {
9092
encoding: 'utf-8',
9193
});
94+
/* eslint-disable no-console */
9295
console.log(`Copied declaration nuggets to ${indexCopy}`);
9396
const examplesIndex = 'examplesIndex.json';
9497
const examples = path.join(root, examplesIndex);
9598
if (fs.existsSync(examples)) {
9699
const examplesCopy = path.join(copyPath, examplesIndex);
97100
fs.copyFileSync(examples, examplesCopy);
101+
/* eslint-disable no-console */
98102
console.log(`Copied example nuggets to ${examplesCopy}`);
99103
}
100104
}

packages/sdk-codegen-scripts/scripts/mineExamples.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ import { ExampleMiner } from '../src/exampleMiner';
3333
const root = path.join(__dirname, '/../../../');
3434
const sourcePath = total < 1 ? root : path.join(root, args[0]);
3535
const indexFile = path.join(sourcePath, '/examplesIndex.json');
36+
/* eslint-disable no-console */
3637
console.log(`Mining examples from ${sourcePath} ...`);
3738
const miner = new ExampleMiner(sourcePath);
3839
const result = miner.execute();
3940
fs.writeFileSync(indexFile, JSON.stringify(result, null, 2), {
4041
encoding: 'utf-8',
4142
});
43+
/* eslint-disable no-console */
4244
console.log(
4345
`${Object.entries(result.nuggets).length} nuggets written to ${indexFile}`
4446
);

packages/sdk-codegen-scripts/scripts/register.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
import { registerApp } from './utils';
2828
(async () => {
2929
const result = await registerApp();
30+
/* eslint-disable no-console */
3031
console.log(result);
3132
})();

packages/sdk-codegen-scripts/scripts/specLinter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const getOptions = () => {
6060
status: 'beta',
6161
};
6262
const args = process.argv.slice(1);
63+
/* eslint-disable no-console */
6364
console.log(`${args[0]} [fileA] [fileB] [format] [status]\n
6465
format=csv|md
6566
status=beta|all
@@ -84,6 +85,7 @@ status=beta|all
8485
}
8586
result.status = args[4].toLowerCase();
8687
}
88+
/* eslint-disable no-console */
8789
console.log(`using:\n${JSON.stringify(result, null, 2)}`);
8890

8991
return result;
@@ -127,6 +129,7 @@ function checkSpecs() {
127129
writeFileSync(outFile, result, {
128130
encoding: 'utf-8',
129131
});
132+
/* eslint-disable no-console */
130133
console.log(`Wrote ${diff.length} method differences to ${outFile}`);
131134
}
132135

packages/sdk-codegen-scripts/scripts/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {
3535
logConvertSpec,
3636
} from '../../sdk-codegen-scripts/src/fetchSpec';
3737

38+
/* eslint no-console: 0 */
39+
3840
const supportedApiVersions = ['3.1', '4.0'];
3941

4042
const homeToRoost = '../../../';
@@ -105,10 +107,10 @@ const brokenPromise = (message: string) => Promise.reject(new Error(message));
105107
export const registerApp = async () => {
106108
const args = process.argv.slice(2);
107109
const total = args.length;
108-
// eslint-disable-next-line node/no-path-concat
109-
const iniFile = total < 1 ? `${__dirname}/../../../looker.ini` : args[0];
110-
// eslint-disable-next-line node/no-path-concat
111-
const configFile = total < 2 ? `${__dirname}/appconfig.json` : args[1];
110+
const iniFile =
111+
total < 1 ? path.join(__dirname, '/../../../looker.ini') : args[0];
112+
const configFile =
113+
total < 2 ? path.join(__dirname, 'appconfig.json') : args[1];
112114
let result = '';
113115
console.log(
114116
`Using ${iniFile} to register the OAuth application configured in ${configFile}`

packages/sdk-codegen-scripts/scripts/vox.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ import {
3838
update_artifacts,
3939
} from '@looker/sdk';
4040

41+
/* eslint no-console: 0 */
42+
4143
const root = path.join(__dirname, '/../../../');
4244
const indexFile = path.join(root, 'hackathons.json');
4345
const compareFile = path.join(root, 'hackCompare.json');
44-
const utf8 = { encoding: 'utf-8' };
46+
const utf8 = 'utf8';
4547
const content = fs.readFileSync(indexFile, utf8);
4648
const artifacts = JSON.parse(content) as IArtifact[];
4749
const sdk = LookerNodeSDK.init40();
@@ -120,10 +122,12 @@ const findOrMakeUser = async (art: IArtifact) => {
120122
create_user(sdk, { first_name: f.first_name, last_name: f.last_name })
121123
);
122124
}
123-
if (!user?.group_ids?.includes(group.id!)) {
124-
await sdk.ok(add_group_user(sdk, group.id!, { user_id: user.id! }));
125+
if (!user?.group_ids?.includes(group.id ?? '')) {
126+
await sdk.ok(
127+
add_group_user(sdk, group.id ?? '', { user_id: user.id ?? '' })
128+
);
125129
}
126-
return swapUserId(art, user.id!);
130+
return swapUserId(art, user.id ?? '');
127131
};
128132

129133
// const removeHackUsers = async () => {

0 commit comments

Comments
 (0)