Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnolte committed Sep 26, 2024
1 parent b541dc0 commit 5ae8d2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
6 changes: 0 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
AutoblocksEnvVar,
AUTOBLOCKS_HEADERS,
API_ENDPOINT,
RevisionSpecialVersionsEnum,
} from './util';

export interface View {
Expand Down Expand Up @@ -281,7 +280,6 @@ export class AutoblocksAPIClient {
}> {
const encodedName = encodeURIComponent(args.name);
const encodedSchemaVersion = encodeURIComponent(args.schemaVersion);

if (args.revisionId) {
return this.get(
`/datasets/${encodedName}/schema-versions/${encodedSchemaVersion}/revisions/${encodeURIComponent(
Expand All @@ -290,10 +288,6 @@ export class AutoblocksAPIClient {
);
}

if (args.schemaVersion === RevisionSpecialVersionsEnum.LATEST) {
return this.get(`/datasets/${encodedName}/revisions/latest`);
}

return this.get(
`/datasets/${encodedName}/schema-versions/${encodedSchemaVersion}`,
);
Expand Down
15 changes: 6 additions & 9 deletions src/datasets-cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
AutoblocksEnvVar,
AUTOBLOCKS_HEADERS,
API_ENDPOINT,
RevisionSpecialVersionsEnum,
} from '../util';
import { ParsedDataset, PropertySchema, PropertyTypesEnum } from './types';

Expand All @@ -27,13 +26,11 @@ export const autogenerationConfigs: AutogenerationConfig[] = [
symbolType: 'interface',
filesToModify: ['../datasets/index.d.ts', '../datasets/index.d.mts'],
generate: (args) => {
let generated = `interface ${args.symbolName} {`;
let generated = `interface ${args.symbolName} {`; // start of definition

args.datasets.forEach((dataset) => {
generated += `\n '${dataset.name}': {`; // start of dataset definition

generated += `\n '${RevisionSpecialVersionsEnum.LATEST}': Record<string, unknown>;`;

dataset.schemaVersions.forEach((schemaVersion) => {
generated += `\n '${schemaVersion.version}': {`; // start of schema version definition
schemaVersion.schema.forEach((property) => {
Expand All @@ -45,7 +42,7 @@ export const autogenerationConfigs: AutogenerationConfig[] = [
generated += '\n };'; // end of dataset definition
});

generated += '\n}';
generated += '\n}'; // end of definition
return generated;
},
},
Expand Down Expand Up @@ -130,9 +127,9 @@ function determineStartAndEndIdx(args: {
);
}

async function getAllDatasetSchemasFromAPI(args: {
apiKey: string;
}): Promise<ParsedDataset[]> {
async function getAllDatasetSchemasFromAPI(args: { apiKey: string }): Promise<{
datasets: ParsedDataset[];
}> {
const resp = await fetch(`${API_ENDPOINT}/datasets/schemas`, {
method: 'GET',
headers: {
Expand Down Expand Up @@ -183,7 +180,7 @@ export async function run(): Promise<void> {
);
}

const datasets = await getAllDatasetSchemasFromAPI({ apiKey });
const { datasets } = await getAllDatasetSchemasFromAPI({ apiKey });

if (datasets.length === 0) {
console.log('No dataset schemas found.');
Expand Down

0 comments on commit 5ae8d2e

Please sign in to comment.