datasetSummary = async function (datasetIdOrObj, options, context) {
if (!context || !context[contextSymbol]) {
context = globalContext;
}
options = {
headingLevel: 2,
...options
};
const paramRegex = /{{([a-zA-Z_\-\d]+)}}/gm;
const dataset = await getDataset(datasetIdOrObj, context);
if (dataset) {
const heading = md`${"#".repeat(options.headingLevel)} Dataset \`${
dataset.id
}\``;
const description = md`${dataset.description || "No description"}`;
const propertyTable = table(
[
{ property: "Name", value: dataset.name },
{ property: "Type", value: dataset.type },
{
property: "Created",
value: humanDate.prettyPrint(dataset.createdAt)
},
{
property: "Updated",
value: humanDate.relativeTime(dataset.updatedAt)
}
],
{ header: false }
);
const params = Array.from(
new Set(
dataset.type === "sql"
? ((dataset.source || "").match(paramRegex) || []).map((p) =>
p.replace(/[{}]/g, "")
)
: []
)
);
const parameterTable = params.length
? table(params.map((p) => ({ Parameters: p })))
: "";
const source = await datasetSource(dataset, context);
const attributeTable = await datasetAttributes(dataset, context);
return htl.html`
${heading}
${description}
${propertyTable}
${parameterTable}
<h5 style="font-family: sans-serif;">SOURCE</h5>
${source}
${attributeTable}
`;
} else {
return md`Dataset not found`;
}
}