@datawheel/bespoke 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +4 -4
- package/dist/index.js +4196 -3767
- package/dist/server.js +135 -163
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -500,7 +500,8 @@ var BLOCK_CONTENT_TYPES = {
|
|
|
500
500
|
// todo1.0 - move to logic types
|
|
501
501
|
STAT: "stat",
|
|
502
502
|
SUBTITLE: "subtitle",
|
|
503
|
-
TITLE: "title"
|
|
503
|
+
TITLE: "title",
|
|
504
|
+
NAV: "nav"
|
|
504
505
|
// todo1.0, how to put custom blocks in here?
|
|
505
506
|
};
|
|
506
507
|
var BLOCK_LOGIC_TYPES = {
|
|
@@ -1737,11 +1738,11 @@ function capitalize(str) {
|
|
|
1737
1738
|
|
|
1738
1739
|
// libs/configs/getLocales.ts
|
|
1739
1740
|
var getLocales_default = () => {
|
|
1740
|
-
const
|
|
1741
|
-
const
|
|
1742
|
-
if (!
|
|
1743
|
-
|
|
1744
|
-
return { localeDefault:
|
|
1741
|
+
const localeDefault11 = process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT || "en";
|
|
1742
|
+
const locales9 = process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",") || [localeDefault11];
|
|
1743
|
+
if (!locales9.includes(localeDefault11))
|
|
1744
|
+
locales9.push(localeDefault11);
|
|
1745
|
+
return { localeDefault: localeDefault11, locales: locales9 };
|
|
1745
1746
|
};
|
|
1746
1747
|
|
|
1747
1748
|
// libs/js/stripHTML.ts
|
|
@@ -2382,12 +2383,12 @@ function dbBlockFactory(db) {
|
|
|
2382
2383
|
deleteBlock
|
|
2383
2384
|
};
|
|
2384
2385
|
async function createBlock(data) {
|
|
2385
|
-
const {
|
|
2386
|
+
const { locales: locales9, ...blockData } = data;
|
|
2386
2387
|
const entity = await Block.create({
|
|
2387
2388
|
...blockData,
|
|
2388
2389
|
consumers: [],
|
|
2389
2390
|
inputs: [],
|
|
2390
|
-
contentByLocale:
|
|
2391
|
+
contentByLocale: locales9.map((locale) => ({ locale }))
|
|
2391
2392
|
}, {
|
|
2392
2393
|
include: blockQuery.include
|
|
2393
2394
|
});
|
|
@@ -2533,6 +2534,7 @@ function dbFormatterFactory(db) {
|
|
|
2533
2534
|
}
|
|
2534
2535
|
|
|
2535
2536
|
// api/db/entityCRUD/report.ts
|
|
2537
|
+
var { locales: reportLocales } = getLocales_default();
|
|
2536
2538
|
function dbReportFactory(db) {
|
|
2537
2539
|
const { report: Report } = db;
|
|
2538
2540
|
return {
|
|
@@ -2551,14 +2553,33 @@ function dbReportFactory(db) {
|
|
|
2551
2553
|
});
|
|
2552
2554
|
return entity.toJSON();
|
|
2553
2555
|
}
|
|
2554
|
-
async function readReport({
|
|
2556
|
+
async function readReport({
|
|
2557
|
+
id,
|
|
2558
|
+
include,
|
|
2559
|
+
locales: locales9 = reportLocales
|
|
2560
|
+
} = {}) {
|
|
2555
2561
|
const idList = id == null ? [] : [].concat(id);
|
|
2556
2562
|
const entities = await Report.findAll({
|
|
2557
2563
|
where: idList.length > 0 ? { id: idList } : void 0,
|
|
2558
2564
|
include: include ? reportQuery.include : void 0
|
|
2559
2565
|
});
|
|
2560
2566
|
if (idList.length === 0 || entities.length === idList.length) {
|
|
2561
|
-
return entities.map((entity) =>
|
|
2567
|
+
return entities.map((entity) => {
|
|
2568
|
+
const report = entity.toJSON();
|
|
2569
|
+
return {
|
|
2570
|
+
...report,
|
|
2571
|
+
sections: report.sections.map((section) => ({
|
|
2572
|
+
...section,
|
|
2573
|
+
blocks: section.blocks.map((block) => ({
|
|
2574
|
+
...block,
|
|
2575
|
+
contentByLocale: Object.keys(block.contentByLocale).reduce((filteredContent, locale) => ({
|
|
2576
|
+
...filteredContent,
|
|
2577
|
+
...[...locales9, "logic"].includes(locale) ? { [locale]: block.contentByLocale[locale] } : {}
|
|
2578
|
+
}), {})
|
|
2579
|
+
}))
|
|
2580
|
+
}))
|
|
2581
|
+
};
|
|
2582
|
+
});
|
|
2562
2583
|
}
|
|
2563
2584
|
const found = entities.map((entity) => entity.id);
|
|
2564
2585
|
const missing = idList.filter((item) => !found.includes(item));
|
|
@@ -3523,7 +3544,31 @@ function dbReadPrivateBlocksFactory(db) {
|
|
|
3523
3544
|
const allBlocks = await Report.findByPk(
|
|
3524
3545
|
params.report_id,
|
|
3525
3546
|
{
|
|
3526
|
-
include:
|
|
3547
|
+
include: {
|
|
3548
|
+
association: "sections",
|
|
3549
|
+
separate: true,
|
|
3550
|
+
include: [
|
|
3551
|
+
{
|
|
3552
|
+
association: "blocks",
|
|
3553
|
+
separate: true,
|
|
3554
|
+
include: [
|
|
3555
|
+
{
|
|
3556
|
+
association: "contentByLocale",
|
|
3557
|
+
separate: true,
|
|
3558
|
+
where: {
|
|
3559
|
+
locale: params.locale
|
|
3560
|
+
}
|
|
3561
|
+
},
|
|
3562
|
+
{
|
|
3563
|
+
association: "inputs"
|
|
3564
|
+
},
|
|
3565
|
+
{
|
|
3566
|
+
association: "consumers"
|
|
3567
|
+
}
|
|
3568
|
+
]
|
|
3569
|
+
}
|
|
3570
|
+
]
|
|
3571
|
+
}
|
|
3527
3572
|
}
|
|
3528
3573
|
).then((report) => {
|
|
3529
3574
|
if (report && report.sections && Array.isArray(report.sections)) {
|
|
@@ -3868,12 +3913,13 @@ function endpointRevalidateFactory(operations) {
|
|
|
3868
3913
|
}
|
|
3869
3914
|
|
|
3870
3915
|
// api/endpoints/readPrivateBlocks.ts
|
|
3916
|
+
var { localeDefault: localeDefault5 } = getLocales_default();
|
|
3871
3917
|
function endpointReadPrivateBlocksFactory(operations) {
|
|
3872
3918
|
const { readPrivateBlocks: readPrivateBlocks2 } = operations;
|
|
3873
3919
|
return endpoint("POST", "read/blocks/private", (req, res, session) => {
|
|
3874
3920
|
const params = {
|
|
3875
3921
|
report_id: parseInt(req.body.report_id, 10),
|
|
3876
|
-
locale: req.body.locale ||
|
|
3922
|
+
locale: req.body.locale || localeDefault5,
|
|
3877
3923
|
roles: session && session.user ? session.user.bespoke_roles : []
|
|
3878
3924
|
};
|
|
3879
3925
|
return readPrivateBlocks2(params);
|
|
@@ -4224,12 +4270,12 @@ var transformReadMembers = (params) => {
|
|
|
4224
4270
|
};
|
|
4225
4271
|
|
|
4226
4272
|
// models/block.ts
|
|
4227
|
-
var { localeDefault:
|
|
4273
|
+
var { localeDefault: localeDefault6 } = getLocales_default();
|
|
4228
4274
|
function parseBlockContext(context) {
|
|
4229
4275
|
return {
|
|
4230
4276
|
variables: context.variables || {},
|
|
4231
4277
|
query: context.query || {},
|
|
4232
|
-
locale: context.locale ||
|
|
4278
|
+
locale: context.locale || localeDefault6
|
|
4233
4279
|
};
|
|
4234
4280
|
}
|
|
4235
4281
|
var verbose6 = yn3(process.env.REPORTS_LOGGING);
|
|
@@ -4417,13 +4463,13 @@ var selectorQueryToVariable = (id, query, config) => {
|
|
|
4417
4463
|
var selectorQueryToVariable_default = selectorQueryToVariable;
|
|
4418
4464
|
|
|
4419
4465
|
// libs/blocks/getBlockContent.ts
|
|
4420
|
-
var { localeDefault:
|
|
4466
|
+
var { localeDefault: localeDefault7, locales: locales6 } = getLocales_default();
|
|
4421
4467
|
var logicTypes = Object.values(BLOCK_LOGIC_TYPES);
|
|
4422
|
-
var getLocaleDerived = (block, locale =
|
|
4423
|
-
var getBlockContent = (block, _locale =
|
|
4468
|
+
var getLocaleDerived = (block, locale = localeDefault7) => block && logicTypes.includes(block.type) ? { locale: BLOCK_LOGIC_LOCALE, locales: [BLOCK_LOGIC_LOCALE] } : { locale, locales: locales6 };
|
|
4469
|
+
var getBlockContent = (block, _locale = localeDefault7) => {
|
|
4424
4470
|
if (!block)
|
|
4425
4471
|
return {};
|
|
4426
|
-
const locale = getLocaleDerived(block, _locale);
|
|
4472
|
+
const { locale } = getLocaleDerived(block, _locale);
|
|
4427
4473
|
return block.contentByLocale?.[locale]?.content;
|
|
4428
4474
|
};
|
|
4429
4475
|
|
|
@@ -4556,147 +4602,64 @@ async function runSingleBlock(block, formatterFunctions, blockContext) {
|
|
|
4556
4602
|
}
|
|
4557
4603
|
};
|
|
4558
4604
|
}
|
|
4559
|
-
var
|
|
4605
|
+
var getDependencies = (bid, blocks, acc = [], crawlUp = true, crawlDown2 = true) => {
|
|
4560
4606
|
const rootBlock = blocks[bid];
|
|
4561
|
-
if (rootBlock.
|
|
4562
|
-
rootBlock.
|
|
4563
|
-
|
|
4607
|
+
if (rootBlock.inputs.length && crawlUp) {
|
|
4608
|
+
rootBlock.inputs.forEach((iid) => {
|
|
4609
|
+
const rel = `${iid}-${bid}`;
|
|
4610
|
+
if (!acc.includes(rel))
|
|
4611
|
+
acc.push(rel);
|
|
4612
|
+
rootBlock.inputs.forEach((iid2) => getDependencies(iid2, blocks, acc, crawlUp, false));
|
|
4564
4613
|
});
|
|
4565
4614
|
}
|
|
4566
|
-
|
|
4567
|
-
return acc;
|
|
4568
|
-
};
|
|
4569
|
-
var getDependencies = (bid, blocks, acc = []) => {
|
|
4570
|
-
const rootBlock = blocks[bid];
|
|
4571
|
-
if (rootBlock.consumers.length) {
|
|
4615
|
+
if (rootBlock.consumers.length && crawlDown2) {
|
|
4572
4616
|
rootBlock.consumers.forEach((cid) => {
|
|
4573
|
-
|
|
4574
|
-
|
|
4617
|
+
const rel = `${bid}-${cid}`;
|
|
4618
|
+
if (!acc.includes(rel))
|
|
4619
|
+
acc.push(rel);
|
|
4620
|
+
rootBlock.consumers.forEach((cid2) => getDependencies(cid2, blocks, acc, crawlUp, crawlDown2));
|
|
4575
4621
|
});
|
|
4576
4622
|
}
|
|
4577
4623
|
return acc;
|
|
4578
4624
|
};
|
|
4579
4625
|
var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockContext, initialVariables = {}) => {
|
|
4580
4626
|
if (!bid && !sections)
|
|
4581
|
-
return { variables: {} };
|
|
4627
|
+
return { variables: { ...initialVariables } };
|
|
4582
4628
|
const variablesById = { ...initialVariables };
|
|
4583
4629
|
const parsedBlockContext = parseBlockContext(blockContext);
|
|
4584
4630
|
const attributes = parsedBlockContext.variables;
|
|
4585
4631
|
const rootBlocks = bid ? { [bid]: blocks[bid] } : sections.reduce((rootBlocks2, { id }) => ({ ...rootBlocks2, ...getRootBlocksForSection_default(id, blocks) }), {});
|
|
4586
|
-
const blockDeps = Object.keys(rootBlocks).reduce((deps,
|
|
4632
|
+
const blockDeps = Object.keys(rootBlocks).reduce((deps, id) => {
|
|
4633
|
+
const dependencies = getDependencies(Number(id), blocks, [], !bid).map((rel) => rel.split("-"));
|
|
4634
|
+
return [...deps, ...dependencies];
|
|
4635
|
+
}, []);
|
|
4587
4636
|
const orderedDAG = toposort(blockDeps);
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
const
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
formatterFunctions,
|
|
4595
|
-
{
|
|
4596
|
-
...parsedBlockContext,
|
|
4597
|
-
variables
|
|
4598
|
-
}
|
|
4599
|
-
);
|
|
4600
|
-
variablesById[blockId] = outputVariables;
|
|
4601
|
-
}
|
|
4602
|
-
return { variables: { ...initialVariables, ...variablesById } };
|
|
4603
|
-
};
|
|
4604
|
-
var runConsumers = async (blocks, sid, bid, formatterFunctions, blockContext, initialVariables) => {
|
|
4605
|
-
const revalidate = bid ? getConsumers(bid, blocks) : [];
|
|
4606
|
-
const rootBlocks = bid ? { [bid]: blocks[bid] } : getRootBlocksForSection_default(sid, blocks);
|
|
4607
|
-
const parsedBlockContext = parseBlockContext(blockContext);
|
|
4608
|
-
const attributes = parsedBlockContext.variables;
|
|
4609
|
-
const variablesById = initialVariables ? { ...initialVariables } : {};
|
|
4610
|
-
const statusById = {};
|
|
4611
|
-
const crawlUp = async (bid2) => {
|
|
4612
|
-
const block = blocks[bid2];
|
|
4613
|
-
if (block.inputs.length === 0 && !variablesById[bid2]) {
|
|
4614
|
-
const { outputVariables, status } = await runSingleBlock(block, formatterFunctions, parsedBlockContext);
|
|
4615
|
-
variablesById[bid2] = outputVariables;
|
|
4616
|
-
statusById[bid2] = status;
|
|
4617
|
-
return;
|
|
4618
|
-
}
|
|
4619
|
-
for (let i = 0; i < block.inputs.length; i += 1) {
|
|
4620
|
-
const input = block.inputs[i];
|
|
4621
|
-
if (!variablesById[input])
|
|
4622
|
-
await crawlUp(input);
|
|
4623
|
-
}
|
|
4624
|
-
const variables = block.inputs.reduce((acc, d) => ({ ...acc, ...variablesById[d] }), attributes);
|
|
4625
|
-
if (!variablesById[bid2]) {
|
|
4626
|
-
const { outputVariables, status } = await runSingleBlock(
|
|
4627
|
-
block,
|
|
4628
|
-
formatterFunctions,
|
|
4629
|
-
{ ...parsedBlockContext, variables }
|
|
4637
|
+
async function runTasksInParallel(executionOrder, blocks2) {
|
|
4638
|
+
const runningBlocks = /* @__PURE__ */ new Map();
|
|
4639
|
+
for (const bid2 of executionOrder) {
|
|
4640
|
+
const block = blocks2[bid2];
|
|
4641
|
+
const dependenciesDone = Promise.all(
|
|
4642
|
+
block.inputs.filter((iid) => executionOrder.includes(String(iid))).map((iid) => runningBlocks.get(Number(iid)))
|
|
4630
4643
|
);
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
const crawlDown2 = async (bid2, cascader = false) => {
|
|
4636
|
-
if (cascader) {
|
|
4637
|
-
variablesById[bid2] = {};
|
|
4638
|
-
statusById[bid2] = { hiddenByCascade: cascader };
|
|
4639
|
-
for (let i = 0; i < blocks[bid2].consumers.length; i += 1) {
|
|
4640
|
-
const cid = blocks[bid2].consumers[i];
|
|
4641
|
-
await crawlDown2(cid, cascader);
|
|
4642
|
-
}
|
|
4643
|
-
return;
|
|
4644
|
-
}
|
|
4645
|
-
let block;
|
|
4646
|
-
let variables = {};
|
|
4647
|
-
if (rootBlocks[bid2]) {
|
|
4648
|
-
block = rootBlocks[bid2];
|
|
4649
|
-
if (blocks[bid2].inputs.length > 0) {
|
|
4650
|
-
await crawlUp(bid2);
|
|
4651
|
-
variables = block.inputs.reduce((acc, d) => ({ ...acc, ...variablesById[d] }), {});
|
|
4652
|
-
}
|
|
4653
|
-
} else {
|
|
4654
|
-
block = blocks[bid2];
|
|
4655
|
-
if (block.inputs.some((d) => !variablesById[d]))
|
|
4656
|
-
await crawlUp(bid2);
|
|
4657
|
-
variables = block.inputs.reduce((acc, d) => ({ ...acc, ...variablesById[d] }), {});
|
|
4658
|
-
}
|
|
4659
|
-
let allowed = true;
|
|
4660
|
-
if ("allowed" in block.settings && block.settings.allowed !== "always") {
|
|
4661
|
-
if (block.settings.allowed === "never")
|
|
4662
|
-
allowed = false;
|
|
4663
|
-
else {
|
|
4664
|
-
const { vars, error, output } = mortarEval_default(
|
|
4665
|
-
"variables",
|
|
4666
|
-
{ ...variables, ...attributes },
|
|
4667
|
-
block.settings.allowedLogic,
|
|
4644
|
+
const runningTask = dependenciesDone.then(() => {
|
|
4645
|
+
const variables = block.inputs.reduce((acc, d) => ({ ...acc, ...variablesById[d] }), attributes);
|
|
4646
|
+
return runSingleBlock(
|
|
4647
|
+
block,
|
|
4668
4648
|
formatterFunctions,
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
const { outputVariables, status } = await runSingleBlock(block, formatterFunctions, { ...parsedBlockContext, variables: { ...variables, ...attributes } });
|
|
4679
|
-
variablesById[bid2] = outputVariables;
|
|
4680
|
-
statusById[bid2] = status;
|
|
4681
|
-
}
|
|
4682
|
-
for (const cid of blocks[bid2].consumers) {
|
|
4683
|
-
await crawlDown2(cid);
|
|
4684
|
-
}
|
|
4685
|
-
} else {
|
|
4686
|
-
variablesById[bid2] = {};
|
|
4687
|
-
statusById[bid2] = { hiddenByCascade: bid2 };
|
|
4688
|
-
for (const cid of blocks[bid2].consumers) {
|
|
4689
|
-
await crawlDown2(cid, bid2);
|
|
4690
|
-
}
|
|
4649
|
+
{
|
|
4650
|
+
...parsedBlockContext,
|
|
4651
|
+
variables
|
|
4652
|
+
}
|
|
4653
|
+
).then(({ outputVariables }) => {
|
|
4654
|
+
variablesById[bid2] = outputVariables;
|
|
4655
|
+
});
|
|
4656
|
+
});
|
|
4657
|
+
runningBlocks.set(Number(bid2), runningTask);
|
|
4691
4658
|
}
|
|
4692
|
-
|
|
4693
|
-
for (const id of Object.keys(rootBlocks)) {
|
|
4694
|
-
await crawlDown2(id);
|
|
4659
|
+
await Promise.all(Array.from(runningBlocks.values()));
|
|
4695
4660
|
}
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
status: statusById
|
|
4699
|
-
};
|
|
4661
|
+
await runTasksInParallel(orderedDAG, blocks);
|
|
4662
|
+
return { variables: { ...initialVariables, ...variablesById } };
|
|
4700
4663
|
};
|
|
4701
4664
|
|
|
4702
4665
|
// libs/variables/previewsToAttributes.ts
|
|
@@ -4716,12 +4679,6 @@ function previewsToAttributes(previews = []) {
|
|
|
4716
4679
|
}, {});
|
|
4717
4680
|
}
|
|
4718
4681
|
var previewsToAttributes_default = previewsToAttributes;
|
|
4719
|
-
|
|
4720
|
-
// store/envvars.ts
|
|
4721
|
-
var localeDefault7 = process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT || "en";
|
|
4722
|
-
var locales6 = process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",") || [localeDefault7];
|
|
4723
|
-
if (!locales6.includes(localeDefault7))
|
|
4724
|
-
locales6.push(localeDefault7);
|
|
4725
4682
|
function comparePositions(firstPos, secondPos) {
|
|
4726
4683
|
return +(firstPos < secondPos) - +(firstPos > secondPos);
|
|
4727
4684
|
}
|
|
@@ -4863,9 +4820,18 @@ var funcifyFormattersByLocale = (formatters = [], locale = localeDefault8) => fo
|
|
|
4863
4820
|
acc[f.name] = formatterFn;
|
|
4864
4821
|
return acc;
|
|
4865
4822
|
}, {});
|
|
4823
|
+
|
|
4824
|
+
// store/envvars.ts
|
|
4825
|
+
var localeDefault9 = process.env.NEXT_PUBLIC_REPORTS_LOCALE_DEFAULT || "en";
|
|
4826
|
+
var locales7 = process.env.NEXT_PUBLIC_REPORTS_LOCALES?.split(",") || [localeDefault9];
|
|
4827
|
+
if (!locales7.includes(localeDefault9))
|
|
4828
|
+
locales7.push(localeDefault9);
|
|
4829
|
+
|
|
4830
|
+
// store/statusSlice.ts
|
|
4866
4831
|
var initialState = {
|
|
4867
|
-
localeDefault:
|
|
4868
|
-
locales:
|
|
4832
|
+
localeDefault: localeDefault9,
|
|
4833
|
+
locales: locales7,
|
|
4834
|
+
currentLocale: localeDefault9,
|
|
4869
4835
|
showToolbar: false,
|
|
4870
4836
|
activeSection: null,
|
|
4871
4837
|
previews: [],
|
|
@@ -5000,6 +4966,10 @@ var recordsSlice = createSlice({
|
|
|
5000
4966
|
} else if (req.type === "section") {
|
|
5001
4967
|
const item = req.data;
|
|
5002
4968
|
state.entities.report[item.report_id].sections.push(item.id);
|
|
4969
|
+
state.entities.report[item.report_id].sections = recalculateOrder(
|
|
4970
|
+
nextEntities.report[item.report_id].sections,
|
|
4971
|
+
nextEntities.section
|
|
4972
|
+
);
|
|
5003
4973
|
} else if (req.type === "block") {
|
|
5004
4974
|
const item = req.data;
|
|
5005
4975
|
state.entities.section[item.section_id].blocks.push(item.id);
|
|
@@ -5412,8 +5382,9 @@ function setQueryParam(resource, key, value) {
|
|
|
5412
5382
|
function recalculateVariables(resource, params) {
|
|
5413
5383
|
return async (dispatch, getState) => {
|
|
5414
5384
|
const state = getState();
|
|
5385
|
+
const { currentLocale } = state.status;
|
|
5415
5386
|
const blocks = state.records.entities.block;
|
|
5416
|
-
const formatterFunctions = resource.formatterFunctions[
|
|
5387
|
+
const formatterFunctions = resource.formatterFunctions[currentLocale];
|
|
5417
5388
|
const { parsedParams, statusPayload } = parseVariableUpdateParams(state.status, params);
|
|
5418
5389
|
const {
|
|
5419
5390
|
sid,
|
|
@@ -5427,12 +5398,12 @@ function recalculateVariables(resource, params) {
|
|
|
5427
5398
|
const blockContext = {
|
|
5428
5399
|
variables: attributes,
|
|
5429
5400
|
query,
|
|
5430
|
-
locale:
|
|
5431
|
-
//TODO: locale is variable
|
|
5401
|
+
locale: currentLocale
|
|
5432
5402
|
};
|
|
5433
|
-
const
|
|
5403
|
+
const section = state.records.entities.section[sid];
|
|
5404
|
+
const data = await runConsumersV2(
|
|
5434
5405
|
blocks,
|
|
5435
|
-
|
|
5406
|
+
section && [section],
|
|
5436
5407
|
bid,
|
|
5437
5408
|
formatterFunctions,
|
|
5438
5409
|
blockContext
|
|
@@ -5581,10 +5552,10 @@ function parseReportId(value) {
|
|
|
5581
5552
|
const [, reportId] = Array.isArray(value) ? value : [value];
|
|
5582
5553
|
return Number.parseInt(reportId) || void 0;
|
|
5583
5554
|
}
|
|
5584
|
-
var { locales:
|
|
5555
|
+
var { locales: locales8 } = getLocales_default();
|
|
5585
5556
|
var initialContext = {
|
|
5586
5557
|
pathSegment: "path",
|
|
5587
|
-
formatterFunctions:
|
|
5558
|
+
formatterFunctions: locales8.reduce((acc, d) => ({ ...acc, [d]: {} }), {})
|
|
5588
5559
|
};
|
|
5589
5560
|
createContext(initialContext);
|
|
5590
5561
|
|
|
@@ -5607,19 +5578,19 @@ function BespokeRendererStaticPaths(options) {
|
|
|
5607
5578
|
} = options || {};
|
|
5608
5579
|
return async (context) => {
|
|
5609
5580
|
const {
|
|
5610
|
-
defaultLocale =
|
|
5611
|
-
locales:
|
|
5581
|
+
defaultLocale = localeDefault9,
|
|
5582
|
+
locales: locales9 = []
|
|
5612
5583
|
} = context;
|
|
5613
5584
|
let paths = [];
|
|
5614
5585
|
if (limit > 0) {
|
|
5615
|
-
const locale =
|
|
5586
|
+
const locale = locales9.find((token) => token === defaultLocale);
|
|
5616
5587
|
const { searchMember: searchMember2 } = await getDB().then(apiFactory);
|
|
5617
5588
|
const req = await searchMember2({
|
|
5618
5589
|
query: "",
|
|
5619
5590
|
// gets top {limit} ranked per profile type.
|
|
5620
5591
|
limit,
|
|
5621
5592
|
format: "plain",
|
|
5622
|
-
locale: locale ||
|
|
5593
|
+
locale: locale || localeDefault9,
|
|
5623
5594
|
noImage: true,
|
|
5624
5595
|
visible: true,
|
|
5625
5596
|
report: [],
|
|
@@ -5629,7 +5600,7 @@ function BespokeRendererStaticPaths(options) {
|
|
|
5629
5600
|
});
|
|
5630
5601
|
if (req.ok === true) {
|
|
5631
5602
|
paths = req.data.results.slice(0, limit).map((item) => ({
|
|
5632
|
-
locale:
|
|
5603
|
+
locale: locales9.find((token) => token === item.locale),
|
|
5633
5604
|
params: {
|
|
5634
5605
|
bespoke: [item.variant.slug, item.slug]
|
|
5635
5606
|
// TODO: fix SearchResult definition
|
|
@@ -5653,7 +5624,7 @@ function BespokeRendererStaticProps(options) {
|
|
|
5653
5624
|
await dispatch(useDatabaseApi);
|
|
5654
5625
|
const buildTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
5655
5626
|
const {
|
|
5656
|
-
locale =
|
|
5627
|
+
locale = localeDefault9,
|
|
5657
5628
|
// TODO: detect or use app default
|
|
5658
5629
|
params = {}
|
|
5659
5630
|
} = context;
|
|
@@ -5677,12 +5648,13 @@ function BespokeRendererStaticProps(options) {
|
|
|
5677
5648
|
dispatch(readEntity("formatter", {})),
|
|
5678
5649
|
dispatch(readEntity("report", {
|
|
5679
5650
|
id: members.results.map((member) => member.report_id),
|
|
5680
|
-
include: true
|
|
5651
|
+
include: true,
|
|
5652
|
+
locales: [locale]
|
|
5681
5653
|
}))
|
|
5682
5654
|
]);
|
|
5683
5655
|
const state = store.getState();
|
|
5684
5656
|
const formatterList = selectFormatterList(state);
|
|
5685
|
-
const formatters = funcifyFormattersByLocale(formatterList,
|
|
5657
|
+
const formatters = funcifyFormattersByLocale(formatterList, localeDefault9);
|
|
5686
5658
|
const sectionList = selectSectionList(state);
|
|
5687
5659
|
const blockRecords = selectBlockRecords(state);
|
|
5688
5660
|
const publicBlockRecords = { ...blockRecords };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datawheel/bespoke",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Content management system for creating automated data reports",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@auth0/nextjs-auth0": "^2.0.1",
|
|
43
43
|
"@emotion/react": "^11.10.4",
|
|
44
|
+
"@hello-pangea/dnd": "^16.2.0",
|
|
44
45
|
"@mantine/core": "^5.6.3",
|
|
45
46
|
"@mantine/dates": "^5.6.3",
|
|
46
47
|
"@mantine/dropzone": "^5.6.3",
|
|
@@ -88,7 +89,6 @@
|
|
|
88
89
|
"pg": "^8.7.3",
|
|
89
90
|
"pretty-format": "^28.1.1",
|
|
90
91
|
"react": "^18.0.2",
|
|
91
|
-
"react-beautiful-dnd": "^13.1.0",
|
|
92
92
|
"react-clipboard.js": "^2.0.16",
|
|
93
93
|
"react-icons": "^4.3.1",
|
|
94
94
|
"react-redux": "^7.2.6",
|