Skip to content

Commit

Permalink
feat: uniform query return types
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik committed Apr 8, 2024
1 parent 17ee8a6 commit 99179b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "ignoreRestSiblings": true }
Expand Down
13 changes: 4 additions & 9 deletions lib/schemaToTs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ import { StdFee } from "@cosmjs/amino";
};
for (const [fnName, value] of Object.entries(file.responses)) {
const title = value.title;
const newTitle = lodash_1.default.upperFirst(title
.replace(/Array_of_/, 'ArrayOf')
.replace(/Tuple_of/, 'TupleOf')
.replace(/_and_/, 'And_'));
log(value.title);
log('old title', title);
const newTitle = lodash_1.default.upperFirst(lodash_1.default.camelCase(title));
log('new title', newTitle);
fixEnum(value);
if (value.title === 'Coin') {
hasCoin = true;
Expand Down Expand Up @@ -124,10 +122,7 @@ export class Client {
let wasRequired = false;
for (const query of file.query.oneOf) {
const queryName = query.required ? query.required[0] : query.enum[0];
const outType = queryMap[queryName]
.replace('_for_', 'For_')
.replace('_of_', 'Of_')
.replace('_and_', 'And_');
const outType = queryMap[queryName];
const inType = query.properties && query.properties[queryName];
log('generating query', queryName);
if (inType && inType.properties) {
Expand Down
15 changes: 4 additions & 11 deletions src/schemaToTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ import { StdFee } from "@cosmjs/amino";
};
for (const [fnName, value] of Object.entries(file.responses)) {
const title = (value as any).title;
const newTitle = _.upperFirst(
title
.replace(/Array_of_/, 'ArrayOf')
.replace(/Tuple_of/, 'TupleOf')
.replace(/_and_/, 'And_'),
);
log((value as any).title);
log('old title', title);
const newTitle = _.upperFirst(_.camelCase(title));
log('new title', newTitle);
fixEnum(value);
if ((value as any).title === 'Coin') {
hasCoin = true;
Expand Down Expand Up @@ -133,10 +129,7 @@ export class Client {
let wasRequired = false;
for (const query of file.query.oneOf) {
const queryName = query.required ? query.required[0] : query.enum[0];
const outType = queryMap[queryName]
.replace('_for_', 'For_')
.replace('_of_', 'Of_')
.replace('_and_', 'And_');
const outType = queryMap[queryName];
const inType = query.properties && query.properties[queryName];
log('generating query', queryName);
if (inType && inType.properties) {
Expand Down

0 comments on commit 99179b2

Please sign in to comment.