forked from launchql/libpg-query-node
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move nodeFields.json into ./scripts/data/
…and map the field data from tuples into objects.
- Loading branch information
1 parent
dafbc22
commit b3e72bf
Showing
4 changed files
with
45 additions
and
17 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import { mapValues } from 'radashi' | ||
import type { NodeFieldMetadataByTag } from '../inferFieldMetadata' | ||
|
||
const dataDir = new URL('.', import.meta.url).pathname | ||
const data = mapValues( | ||
JSON.parse( | ||
fs.readFileSync(path.join(dataDir, 'fieldMetadata.json'), 'utf8'), | ||
) as NodeFieldMetadataByTag, | ||
fieldMap => | ||
mapValues(fieldMap!, ([nullable, tags, listTags]) => ({ | ||
nullable, | ||
tags, | ||
listTags, | ||
})), | ||
) | ||
|
||
/** | ||
* Field metadata is inferred from test cases sourced from the libpg_query | ||
* repository. Check out the {@link ../inferFieldMetadata.ts inferFieldMetadata} | ||
* module for more details. | ||
*/ | ||
export const fieldMetadataMap = data as { | ||
[typeName: string]: { | ||
[fieldName: string]: typeof data[string][string] | undefined | ||
} | undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters