Skip to content

Commit

Permalink
Bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiandupont committed Oct 8, 2023
1 parent 5f39afb commit afa91cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extract-pg-schema",
"version": "4.2.2",
"version": "4.2.4",
"keywords": [
"postgresql",
"schema"
Expand Down
24 changes: 11 additions & 13 deletions src/extractSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,20 @@ const emptySchema: Omit<Schema, "name"> = {
compositeTypes: [],
};

type Populator = <K extends Kind>(
type Populator<K extends Kind> = (
db: Knex,
pgType: PgType<K>,
) => Promise<DetailsMap[K]>;

// @ts-ignore Why is this broken? I don't understand. :-/
const populatorMap: Record<Kind, Populator> = {
domain: extractDomain,
enum: extractEnum,
range: extractRange,

table: extractTable,
view: extractView,
materializedView: extractMaterializedView,
compositeType: extractCompositeType,
} as const;
const populatorMap = {
domain: extractDomain as Populator<"domain">,
enum: extractEnum as Populator<"enum">,
range: extractRange as Populator<"range">,
table: extractTable as Populator<"table">,
view: extractView as Populator<"view">,
materializedView: extractMaterializedView as Populator<"materializedView">,
compositeType: extractCompositeType as Populator<"compositeType">,
};

/**
* This is the options object that can be passed to `extractSchemas`.
Expand Down Expand Up @@ -153,7 +151,7 @@ async function extractSchemas(

const populated = await Promise.all(
typesToExtract.map(async (pgType) => {
const result = await populatorMap[pgType.kind](db, pgType);
const result = await populatorMap[pgType.kind](db, pgType as any); // Now this is broken. I am not sure why!
options?.onProgress?.();
return result;
}),
Expand Down

0 comments on commit afa91cf

Please sign in to comment.