Skip to content

Instantly share code, notes, and snippets.

@erights
Created February 18, 2022 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erights/fb27c01cea57674439a027a6c701b200 to your computer and use it in GitHub Desktop.
Save erights/fb27c01cea57674439a027a6c701b200 to your computer and use it in GitHub Desktop.
const ModuleLanguagesSet = makeConstSet([
'cjs',
'mjs',
'json',
'pre-mjs-json',
'pre-cjs-json',
]);
// TODO M.elementOf doesn't yet exist. We should add it.
const ModuleLanguageShape = M.elementOf(ModuleLanguagesSet),
const CompartmentModuleShape = harden({
compartment: M.string(),
module: M.string(),
});
const FileModuleShape = harden({
location: M.string(),
parser: ModuleLanguageShape,
sha512: M.string(),
});
const ExitModuleShape = harden({
exit: M.string(),
});
const ModuleShape = M.or(
CompartmentModuleShape,
FileModuleShape,
ExitModuleShape,
);
const ScopeShape = harden({
compartment: M.string(),
});
const CompartmentShape = harden({
location: M.string(),
name: M.string(),
label: M.string(),
parsers: M.recordOf(M.string(), ModuleLanguageShape),
types: M.recordOf(M.string(), ModuleLanguageShape),
scopes: M.recordOf(M.string(), ScopeShape),
modules: M.recordOf(M.string(), ModuleShape),
});
const EntryShape = harden({
compartment: M.string(),
module: M.string(),
});
const CompartmentMapShape = harden({
tags: M.arrayOf(M.string()),
entry: EntryShape,
compartments: M.recordOf(M.string(), CompartmentShape),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment