@datawheel/bespoke 0.1.27 → 0.1.29
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 +0 -4
- package/dist/index.js +1213 -770
- package/dist/server.js +37 -7
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -4717,6 +4717,20 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
|
|
|
4717
4717
|
let apiResponse;
|
|
4718
4718
|
let duration = null;
|
|
4719
4719
|
let api = null;
|
|
4720
|
+
if (!allowed) {
|
|
4721
|
+
return {
|
|
4722
|
+
outputVariables: {},
|
|
4723
|
+
renderVariables: {},
|
|
4724
|
+
status: {
|
|
4725
|
+
api: null,
|
|
4726
|
+
duration: null,
|
|
4727
|
+
resp: null,
|
|
4728
|
+
log: [],
|
|
4729
|
+
error: null,
|
|
4730
|
+
allowed: false
|
|
4731
|
+
}
|
|
4732
|
+
};
|
|
4733
|
+
}
|
|
4720
4734
|
if (unswappedAPI) {
|
|
4721
4735
|
api = swapAPI(unswappedAPI, formatterFunctions, blockContext);
|
|
4722
4736
|
const isAbsolute = new RegExp("^(?:[a-z+]+:)?//", "i");
|
|
@@ -4729,7 +4743,7 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
|
|
|
4729
4743
|
return result;
|
|
4730
4744
|
}, (e) => {
|
|
4731
4745
|
if (verbose7)
|
|
4732
|
-
console.error(`Error fetching ${api}: ${e.message}`);
|
|
4746
|
+
console.error(`Error fetching ${api} block ${block.id}: ${e.message}`);
|
|
4733
4747
|
return { data: {}, requestDuration: 0 };
|
|
4734
4748
|
});
|
|
4735
4749
|
resp = apiResponse.data;
|
|
@@ -4831,7 +4845,7 @@ var isBlockAllowed = (block, blockContext, variables, formatterFunctions) => {
|
|
|
4831
4845
|
allowed = false;
|
|
4832
4846
|
} else {
|
|
4833
4847
|
const parsedBlockContext = parseBlockContext(blockContext);
|
|
4834
|
-
const {
|
|
4848
|
+
const { error, output } = mortarEval_default(
|
|
4835
4849
|
"variables",
|
|
4836
4850
|
variables,
|
|
4837
4851
|
block.settings.allowedLogic || "return false;",
|
|
@@ -4845,11 +4859,11 @@ var isBlockAllowed = (block, blockContext, variables, formatterFunctions) => {
|
|
|
4845
4859
|
}
|
|
4846
4860
|
return allowed;
|
|
4847
4861
|
};
|
|
4848
|
-
var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockContext,
|
|
4862
|
+
var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockContext, initialState4 = {}, readMemberFn, mode = "section") => {
|
|
4849
4863
|
if (!bid && !sections)
|
|
4850
|
-
return {
|
|
4851
|
-
const variablesById = { ...
|
|
4852
|
-
const statusById = {};
|
|
4864
|
+
return { ...initialState4 };
|
|
4865
|
+
const variablesById = { ...initialState4.variables ?? {} };
|
|
4866
|
+
const statusById = { ...initialState4.status ?? {} };
|
|
4853
4867
|
const parsedBlockContext = parseBlockContext(blockContext);
|
|
4854
4868
|
const attributes = parsedBlockContext.variables;
|
|
4855
4869
|
const rootBlocks = bid ? { [bid]: blocks[bid] } : sections.reduce((rootBlocks2, { id }) => ({ ...rootBlocks2, ...getRootBlocksForSection_default(id, blocks) }), {});
|
|
@@ -4871,6 +4885,19 @@ var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockCont
|
|
|
4871
4885
|
);
|
|
4872
4886
|
const runningTask = dependenciesDone.then(() => {
|
|
4873
4887
|
const variables = block.inputs.reduce((acc, d) => ({ ...acc, ...variablesById[d] }), attributes);
|
|
4888
|
+
const inputNotAllowed = block.inputs.find((iid) => !statusById[iid].allowed || statusById[iid].hiddenByCascade);
|
|
4889
|
+
if (inputNotAllowed) {
|
|
4890
|
+
statusById[bid2] = {
|
|
4891
|
+
api: null,
|
|
4892
|
+
duration: null,
|
|
4893
|
+
resp: null,
|
|
4894
|
+
log: [],
|
|
4895
|
+
error: null,
|
|
4896
|
+
allowed: false,
|
|
4897
|
+
hiddenByCascade: statusById[inputNotAllowed].hiddenByCascade || inputNotAllowed
|
|
4898
|
+
};
|
|
4899
|
+
return;
|
|
4900
|
+
}
|
|
4874
4901
|
return runSingleBlock(
|
|
4875
4902
|
block,
|
|
4876
4903
|
formatterFunctions,
|
|
@@ -4889,7 +4916,10 @@ var runConsumersV2 = async (blocks, sections, bid, formatterFunctions, blockCont
|
|
|
4889
4916
|
await Promise.all(Array.from(runningBlocks.values()));
|
|
4890
4917
|
}
|
|
4891
4918
|
await runTasksInParallel(orderedDAG, blocks);
|
|
4892
|
-
return {
|
|
4919
|
+
return {
|
|
4920
|
+
variables: { ...initialState4.variables ?? {}, ...variablesById },
|
|
4921
|
+
status: { ...initialState4.status ?? {}, ...statusById }
|
|
4922
|
+
};
|
|
4893
4923
|
};
|
|
4894
4924
|
|
|
4895
4925
|
// libs/variables/previewsToAttributes.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datawheel/bespoke",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "Content management system for creating automated data reports",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"fast-glob": "^3.2.12",
|
|
78
78
|
"file-loader": "^6.2.0",
|
|
79
79
|
"file-saver": "^1.3.3",
|
|
80
|
-
"flickr-sdk": "
|
|
80
|
+
"flickr-sdk": "6.1.2",
|
|
81
81
|
"formidable": "^2.1.1",
|
|
82
82
|
"html-react-parser": "^3.0.15",
|
|
83
83
|
"html-to-image": "^1.10.8",
|