-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: finalise OA v4.0 context url (#311)
* refactor: improve naming of context keys * chore: finalise oa v4 context url * fix(optional): loosely match against oa v4 context url * fix: document builder to reference context constants * docs: update context url in readme * test: update v4.0 test fixtures * fix: revert earlier commit to strictly match oa v4 context url * feat: prefetch frequently used contexts in OA v4 * feat: hardcode frequently used contexts instead * feat: use code generation script for frequently used contexts * chore: update comment and remove redundant function
- Loading branch information
Showing
30 changed files
with
269 additions
and
325 deletions.
There are no files selected for viewing
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
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,24 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { ContextUrl } from "../src/4.0/context"; | ||
|
||
const OUTPUT_DIR = path.resolve("./src/4.0/contexts/__generated__"); | ||
|
||
// make sure the output directory exists | ||
if (fs.existsSync(OUTPUT_DIR)) { | ||
fs.rmSync(OUTPUT_DIR, { recursive: true }); | ||
} | ||
fs.mkdirSync(OUTPUT_DIR, { recursive: true }); | ||
|
||
const CONTEXTS_TO_FETCH = Object.values(ContextUrl); | ||
|
||
const sb: string[] = [`const contextsMap = new Map<string, string>();`]; | ||
Promise.all( | ||
CONTEXTS_TO_FETCH.map(async (url) => { | ||
const context = await (await fetch(url)).json(); | ||
sb.push(`contextsMap.set("${url}", \`${JSON.stringify(context)}\`);`); | ||
}) | ||
).then(() => { | ||
sb.push(`export { contextsMap };`); | ||
fs.writeFileSync(path.join(OUTPUT_DIR, "index.ts"), sb.join("\n")); | ||
}); |
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
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
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
Oops, something went wrong.