Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(service-spec-importers): expose importers via DatabaseBuilder #631

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Oct 23, 2023

Preparing the service-spec-importers package for a public release, pt2.
This change replaces existing exports of everything with explicit exports for:

  • DatabaseBuilder a new class that helps importing data into a database
  • DbDiff a class that helps diff'ing to databases
  • ProblemReport a class to collect & report problems encountered during import

While this change is already enough to import additional specs on top of an existing database, we will need one further change to decouple the package from the source files in this repo.

@mrgrain mrgrain force-pushed the mrgrain/feat/loaders-importers branch from 96e17ac to 1dd2845 Compare October 23, 2023 09:38
@mrgrain mrgrain force-pushed the mrgrain/feat/loaders-importers branch from 1dd2845 to df5fe20 Compare October 23, 2023 10:35
@rix0rrr rix0rrr disabled auto-merge October 23, 2023 11:54
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditionally approved

Comment on lines +29 to +30
.importScrutinies()
.importAugmentations()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these built into the importers package?

Copy link
Contributor Author

@mrgrain mrgrain Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately yes. Should we change that? WDYT?

export type SourceImporter = (db: SpecDatabase, report: ProblemReport) => Promise<void>;

export class DatabaseBuilder {
private readonly sourceImporters = new Array<SourceImporter>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this lazy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to improve UX, this enables a fluent interface. Otherwise it's a bunch of statements that need to be awaited.
I don't have strong feelings about this. It made sense to me to expose the importers as methods on a class.

import { SpecDatabase, emptyDatabase } from '@aws-cdk/service-spec-types';
import { DatabaseBuilder, DatabaseBuilderOptions } from './db-builder';

const SOURCES = path.join(__dirname, '../../../../sources');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me think this file needs to live somewhere else. Can it be an unpackaged build tool for aws-service-spec ?

Otherwise, make this directory a parameter I think and call it with the right relative directory from the aws-service-spec build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes planning to do exactly this in the next PR!

@mrgrain mrgrain added this pull request to the merge queue Oct 23, 2023
Merged via the queue into main with commit e97d522 Oct 23, 2023
6 checks passed
@mrgrain mrgrain deleted the mrgrain/feat/loaders-importers branch October 23, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants