@datawheel/bespoke 0.1.27 → 0.1.28

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.js CHANGED
@@ -1091,6 +1091,20 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
1091
1091
  let apiResponse;
1092
1092
  let duration = null;
1093
1093
  let api = null;
1094
+ if (!allowed) {
1095
+ return {
1096
+ outputVariables: {},
1097
+ renderVariables: {},
1098
+ status: {
1099
+ api: null,
1100
+ duration: null,
1101
+ resp: null,
1102
+ log: [],
1103
+ error: null,
1104
+ allowed: false
1105
+ }
1106
+ };
1107
+ }
1094
1108
  if (unswappedAPI) {
1095
1109
  api = swapAPI(unswappedAPI, formatterFunctions, blockContext);
1096
1110
  const isAbsolute = new RegExp("^(?:[a-z+]+:)?//", "i");
@@ -1103,7 +1117,7 @@ async function runSingleBlock(block, formatterFunctions, blockContext, readMembe
1103
1117
  return result;
1104
1118
  }, (e) => {
1105
1119
  if (verbose2)
1106
- console.error(`Error fetching ${api}: ${e.message}`);
1120
+ console.error(`Error fetching ${api} block ${block.id}: ${e.message}`);
1107
1121
  return { data: {}, requestDuration: 0 };
1108
1122
  });
1109
1123
  resp = apiResponse.data;
@@ -1237,7 +1251,7 @@ var init_runConsumers = __esm({
1237
1251
  allowed = false;
1238
1252
  } else {
1239
1253
  const parsedBlockContext = parseBlockContext(blockContext);
1240
- const { vars, error, output } = mortarEval_default(
1254
+ const { error, output } = mortarEval_default(
1241
1255
  "variables",
1242
1256
  variables,
1243
1257
  block.settings.allowedLogic || "return false;",
@@ -1277,6 +1291,19 @@ var init_runConsumers = __esm({
1277
1291
  );
1278
1292
  const runningTask = dependenciesDone.then(() => {
1279
1293
  const variables = block.inputs.reduce((acc, d) => ({ ...acc, ...variablesById[d] }), attributes);
1294
+ const inputNotAllowed = block.inputs.find((iid) => !statusById[iid].allowed || statusById[iid].hiddenByCascade);
1295
+ if (inputNotAllowed) {
1296
+ statusById[bid2] = {
1297
+ api: null,
1298
+ duration: null,
1299
+ resp: null,
1300
+ log: [],
1301
+ error: null,
1302
+ allowed: false,
1303
+ hiddenByCascade: statusById[inputNotAllowed].hiddenByCascade || inputNotAllowed
1304
+ };
1305
+ return;
1306
+ }
1280
1307
  return runSingleBlock(
1281
1308
  block,
1282
1309
  formatterFunctions,
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 { vars, error, output } = mortarEval_default(
4848
+ const { error, output } = mortarEval_default(
4835
4849
  "variables",
4836
4850
  variables,
4837
4851
  block.settings.allowedLogic || "return false;",
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {