@datawheel/bespoke 0.3.3 → 0.3.5

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/server.js CHANGED
@@ -26,7 +26,9 @@ import * as allIcons from '@tabler/icons-react';
26
26
  import NextCors from 'nextjs-cors';
27
27
  import formidable from 'formidable';
28
28
  import DomParser from 'dom-parser';
29
+ import axiosRetry from 'axios-retry';
29
30
  import toposort from 'toposort';
31
+ import { csvParse } from 'd3-dsv';
30
32
  import getConfig from 'next/config';
31
33
  import { schema, normalize } from 'normalizr';
32
34
  import { createSlice, configureStore } from '@reduxjs/toolkit';
@@ -4275,6 +4277,15 @@ var getRootBlocksForSection_default = getRootBlocksForSection;
4275
4277
  var apiSeparator = "|||";
4276
4278
  var debug = yn2(process.env.NEXT_PUBLIC_REPORTS_DEBUG);
4277
4279
  var ORIGIN = process.env.REPORTS_ORIGIN || "";
4280
+ axiosRetry(axios5, {
4281
+ retries: 3,
4282
+ retryDelay: axiosRetry.exponentialDelay,
4283
+ onRetry: (retryCount, error, requestConfig) => {
4284
+ console.log("Generator request failed. Retrying... Count: ", retryCount);
4285
+ console.log("URL: ", requestConfig.url);
4286
+ console.log(error.message);
4287
+ }
4288
+ });
4278
4289
  axios5.interceptors.request.use((config) => ({
4279
4290
  ...config,
4280
4291
  requestStart: Date.now()
@@ -4323,7 +4334,11 @@ async function apiFetch(url, settings, readMemberFn, locale = "en") {
4323
4334
  timeout: apiFetchTimeout
4324
4335
  });
4325
4336
  if (response.status === 200) {
4326
- finalData = response.data;
4337
+ if (response.headers["content-type"] === "text/csv") {
4338
+ finalData = csvParse(response.data);
4339
+ } else {
4340
+ finalData = response.data;
4341
+ }
4327
4342
  } else {
4328
4343
  throw new ApiFetchException("No response");
4329
4344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {
@@ -56,6 +56,7 @@
56
56
  "@tinymce/tinymce-react": "^4.2.0",
57
57
  "auth0": "^3.3",
58
58
  "axios": "^0.26.1",
59
+ "axios-retry": "^3.8.0",
59
60
  "base58": "^2.0.1",
60
61
  "buble": "^0.20.0",
61
62
  "comment-parser": "^1.3.1",