@takeshape/ssg 10.2.0 → 10.2.4

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/config.js CHANGED
@@ -98,14 +98,13 @@ function getGraphQLQueries(config) {
98
98
  routes
99
99
  } = config;
100
100
  const routeQueries = (0, _flatten.default)(Object.keys(routes).map(routeName => {
101
- var _route$paginate;
102
101
  const route = routes[routeName];
103
102
  const results = route.context ? getContextGraphQLQueries(route.context, {
104
103
  routeName,
105
104
  path: route.path,
106
105
  isPaginated: false
107
106
  }) : [];
108
- if ((_route$paginate = route.paginate) !== null && _route$paginate !== void 0 && _route$paginate.data) {
107
+ if (route.paginate?.data) {
109
108
  const filePath = isGraphQLQueryConfig(route.paginate.data) ? route.paginate.data.query : route.paginate.data;
110
109
  results.push({
111
110
  routeName,
@@ -121,10 +121,10 @@ function createNumberFilter({
121
121
  return (value, formatStr, config) => {
122
122
  const localeSettings = {
123
123
  ...(locales[locale.toLowerCase()] || _enUS.default),
124
- ...(numbers === null || numbers === void 0 ? void 0 : numbers.config),
124
+ ...numbers?.config,
125
125
  ...config
126
126
  };
127
- const format = formatStr ? formatStr : numbers !== null && numbers !== void 0 && numbers.format ? numbers.format : ',';
127
+ const format = formatStr ? formatStr : numbers?.format ? numbers.format : ',';
128
128
  return (0, _d3Format.formatLocale)(localeSettings).format(format)(value);
129
129
  };
130
130
  }
@@ -13,7 +13,7 @@ function createRouteFilter(config, stats) {
13
13
  return function (obj, routeName) {
14
14
  const route = (0, _get.default)(config.routes, routeName);
15
15
  let path;
16
- if (route !== null && route !== void 0 && route.path) {
16
+ if (route?.path) {
17
17
  const pathResult = (0, _routing.formatPath)(route.path, obj);
18
18
  path = (0, _paths.joinPath)(config.pathPrefix, pathResult.path);
19
19
  if (pathResult.warnings.length) {
@@ -53,12 +53,11 @@ const getItemContext = (route, context, {
53
53
  previous,
54
54
  next
55
55
  }) => {
56
- var _route$paginate;
57
56
  const itemContext = {
58
57
  item: current.item,
59
58
  currentPath: current.path
60
59
  };
61
- if ((_route$paginate = route.paginate) !== null && _route$paginate !== void 0 && _route$paginate.itemName) {
60
+ if (route.paginate?.itemName) {
62
61
  itemContext[route.paginate.itemName] = current.item;
63
62
  }
64
63
  if (previous) {
@@ -267,12 +267,11 @@ async function generateRoute(config, params) {
267
267
  }
268
268
  const identity = obj => obj;
269
269
  function getRenderTemplateDecorator(config) {
270
- var _config$htmlCompressi;
271
270
  const decorators = [];
272
271
  if (config.gzip) {
273
272
  decorators.push(_gzip.default);
274
273
  }
275
- if ((_config$htmlCompressi = config.htmlCompression) !== null && _config$htmlCompressi !== void 0 && _config$htmlCompressi.enabled) {
274
+ if (config.htmlCompression?.enabled) {
276
275
  decorators.push((0, _compressHtml.default)(config.htmlCompression));
277
276
  }
278
277
  return decorators.length ? (0, _compose.default)(decorators) : identity;
@@ -68,8 +68,7 @@ function getMapResponse(props) {
68
68
  ...res.data
69
69
  };
70
70
  for (const prop of props) {
71
- var _res$data;
72
- if ((_res$data = res.data) !== null && _res$data !== void 0 && _res$data[prop]) {
71
+ if (res.data?.[prop]) {
73
72
  newRes.data[prop] = res.data[prop].items;
74
73
  }
75
74
  }
@@ -44,7 +44,7 @@ function getPaginationStrategy(fieldDef) {
44
44
  const {
45
45
  args
46
46
  } = fieldDef;
47
- if (args !== null && args !== void 0 && args.length) {
47
+ if (args?.length) {
48
48
  const keyedArgs = (0, _keyBy.default)(args, 'name');
49
49
  return paginationStrategies.find(strategy => {
50
50
  const {
@@ -42,7 +42,7 @@ function ensureIds(queryAst, schema) {
42
42
  if (fieldDef) {
43
43
  const type = getItemType(fieldDef.type);
44
44
  const fields = getFields(type);
45
- if (fields !== null && fields !== void 0 && fields._id) {
45
+ if (fields?._id) {
46
46
  return addId(node);
47
47
  }
48
48
  }
@@ -137,7 +137,7 @@ function withQueryTransforms(connector, schema, {
137
137
  if (usage) {
138
138
  queryAst = ensureIds(queryAst, schema);
139
139
  }
140
- if (context !== null && context !== void 0 && context.isPaginated && contentId) {
140
+ if (context?.isPaginated && contentId) {
141
141
  const {
142
142
  ast,
143
143
  modified,
@@ -68,7 +68,6 @@ function schemaConnectorFactory(cwd, config) {
68
68
  if (config.type === 'graphql-js' && config.file) {
69
69
  const schema = require(_path.default.join(cwd, config.file)); // eslint-disable-line
70
70
  connector = async params => {
71
- var _res$errors;
72
71
  const res = await (0, _graphql.graphql)({
73
72
  schema: schema.default || schema,
74
73
  source: params.query,
@@ -78,7 +77,7 @@ function schemaConnectorFactory(cwd, config) {
78
77
  });
79
78
  return {
80
79
  data: res.data,
81
- errors: (_res$errors = res.errors) === null || _res$errors === void 0 ? void 0 : _res$errors.map(_graphql.formatError)
80
+ errors: res.errors?.map(_graphql.formatError)
82
81
  };
83
82
  };
84
83
  }
@@ -20,7 +20,7 @@ var _config = require("./config");
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
  function getType(path) {
22
22
  const matches = /\.(graphql|yml|yaml|json)$/.exec(path);
23
- if (matches !== null && matches !== void 0 && matches.length) {
23
+ if (matches?.length) {
24
24
  const type = matches[1];
25
25
  return type === 'yml' ? 'yaml' : type;
26
26
  }
@@ -76,7 +76,7 @@ async function handleGraphQL({
76
76
  throw new _graphqlError.default(`An error occurred while resolving ${queryPath}`, res.errors);
77
77
  }
78
78
  const data = res.data;
79
- if (route !== null && route !== void 0 && route.path && !route.paginate) {
79
+ if (route?.path && !route.paginate) {
80
80
  (0, _stats.recordContentUsage)(stats, data, route.path);
81
81
  }
82
82
  return data;
package/dist/stats.js CHANGED
@@ -34,7 +34,7 @@ function scrapeIds(obj, depth = 1, result = []) {
34
34
  return result;
35
35
  }
36
36
  function recordContentUsage(stats, data, path) {
37
- if (stats !== null && stats !== void 0 && stats.contentUsage) {
37
+ if (stats?.contentUsage) {
38
38
  const {
39
39
  contentUsage
40
40
  } = stats;
package/es/config.js CHANGED
@@ -87,14 +87,13 @@ export function getGraphQLQueries(config) {
87
87
  routes
88
88
  } = config;
89
89
  const routeQueries = flatten(Object.keys(routes).map(routeName => {
90
- var _route$paginate;
91
90
  const route = routes[routeName];
92
91
  const results = route.context ? getContextGraphQLQueries(route.context, {
93
92
  routeName,
94
93
  path: route.path,
95
94
  isPaginated: false
96
95
  }) : [];
97
- if ((_route$paginate = route.paginate) !== null && _route$paginate !== void 0 && _route$paginate.data) {
96
+ if (route.paginate?.data) {
98
97
  const filePath = isGraphQLQueryConfig(route.paginate.data) ? route.paginate.data.query : route.paginate.data;
99
98
  results.push({
100
99
  routeName,
@@ -114,10 +114,10 @@ export default function createNumberFilter({
114
114
  return (value, formatStr, config) => {
115
115
  const localeSettings = {
116
116
  ...(locales[locale.toLowerCase()] || enUS),
117
- ...(numbers === null || numbers === void 0 ? void 0 : numbers.config),
117
+ ...numbers?.config,
118
118
  ...config
119
119
  };
120
- const format = formatStr ? formatStr : numbers !== null && numbers !== void 0 && numbers.format ? numbers.format : ',';
120
+ const format = formatStr ? formatStr : numbers?.format ? numbers.format : ',';
121
121
  return formatLocale(localeSettings).format(format)(value);
122
122
  };
123
123
  }
@@ -6,7 +6,7 @@ export default function createRouteFilter(config, stats) {
6
6
  return function (obj, routeName) {
7
7
  const route = get(config.routes, routeName);
8
8
  let path;
9
- if (route !== null && route !== void 0 && route.path) {
9
+ if (route?.path) {
10
10
  const pathResult = formatPath(route.path, obj);
11
11
  path = joinPath(config.pathPrefix, pathResult.path);
12
12
  if (pathResult.warnings.length) {
@@ -45,12 +45,11 @@ export const getItemContext = (route, context, {
45
45
  previous,
46
46
  next
47
47
  }) => {
48
- var _route$paginate;
49
48
  const itemContext = {
50
49
  item: current.item,
51
50
  currentPath: current.path
52
51
  };
53
- if ((_route$paginate = route.paginate) !== null && _route$paginate !== void 0 && _route$paginate.itemName) {
52
+ if (route.paginate?.itemName) {
54
53
  itemContext[route.paginate.itemName] = current.item;
55
54
  }
56
55
  if (previous) {
@@ -253,12 +253,11 @@ export async function generateRoute(config, params) {
253
253
  }
254
254
  const identity = obj => obj;
255
255
  function getRenderTemplateDecorator(config) {
256
- var _config$htmlCompressi;
257
256
  const decorators = [];
258
257
  if (config.gzip) {
259
258
  decorators.push(gzipContents);
260
259
  }
261
- if ((_config$htmlCompressi = config.htmlCompression) !== null && _config$htmlCompressi !== void 0 && _config$htmlCompressi.enabled) {
260
+ if (config.htmlCompression?.enabled) {
262
261
  decorators.push(compressHtml(config.htmlCompression));
263
262
  }
264
263
  return decorators.length ? compose(decorators) : identity;
@@ -59,8 +59,7 @@ export function getMapResponse(props) {
59
59
  ...res.data
60
60
  };
61
61
  for (const prop of props) {
62
- var _res$data;
63
- if ((_res$data = res.data) !== null && _res$data !== void 0 && _res$data[prop]) {
62
+ if (res.data?.[prop]) {
64
63
  newRes.data[prop] = res.data[prop].items;
65
64
  }
66
65
  }
@@ -30,7 +30,7 @@ function getPaginationStrategy(fieldDef) {
30
30
  const {
31
31
  args
32
32
  } = fieldDef;
33
- if (args !== null && args !== void 0 && args.length) {
33
+ if (args?.length) {
34
34
  const keyedArgs = keyBy(args, 'name');
35
35
  return paginationStrategies.find(strategy => {
36
36
  const {
@@ -30,7 +30,7 @@ export function ensureIds(queryAst, schema) {
30
30
  if (fieldDef) {
31
31
  const type = getItemType(fieldDef.type);
32
32
  const fields = getFields(type);
33
- if (fields !== null && fields !== void 0 && fields._id) {
33
+ if (fields?._id) {
34
34
  return addId(node);
35
35
  }
36
36
  }
@@ -124,7 +124,7 @@ export function withQueryTransforms(connector, schema, {
124
124
  if (usage) {
125
125
  queryAst = ensureIds(queryAst, schema);
126
126
  }
127
- if (context !== null && context !== void 0 && context.isPaginated && contentId) {
127
+ if (context?.isPaginated && contentId) {
128
128
  const {
129
129
  ast,
130
130
  modified,
@@ -60,7 +60,6 @@ export function schemaConnectorFactory(cwd, config) {
60
60
  if (config.type === 'graphql-js' && config.file) {
61
61
  const schema = require(path.join(cwd, config.file)); // eslint-disable-line
62
62
  connector = async params => {
63
- var _res$errors;
64
63
  const res = await graphql({
65
64
  schema: schema.default || schema,
66
65
  source: params.query,
@@ -70,7 +69,7 @@ export function schemaConnectorFactory(cwd, config) {
70
69
  });
71
70
  return {
72
71
  data: res.data,
73
- errors: (_res$errors = res.errors) === null || _res$errors === void 0 ? void 0 : _res$errors.map(formatError)
72
+ errors: res.errors?.map(formatError)
74
73
  };
75
74
  };
76
75
  }
@@ -7,7 +7,7 @@ import { recordContentUsage } from './stats';
7
7
  import { isGraphQLQueryConfig } from './config';
8
8
  export function getType(path) {
9
9
  const matches = /\.(graphql|yml|yaml|json)$/.exec(path);
10
- if (matches !== null && matches !== void 0 && matches.length) {
10
+ if (matches?.length) {
11
11
  const type = matches[1];
12
12
  return type === 'yml' ? 'yaml' : type;
13
13
  }
@@ -63,7 +63,7 @@ export async function handleGraphQL({
63
63
  throw new GraphQLError(`An error occurred while resolving ${queryPath}`, res.errors);
64
64
  }
65
65
  const data = res.data;
66
- if (route !== null && route !== void 0 && route.path && !route.paginate) {
66
+ if (route?.path && !route.paginate) {
67
67
  recordContentUsage(stats, data, route.path);
68
68
  }
69
69
  return data;
package/es/stats.js CHANGED
@@ -26,7 +26,7 @@ export function scrapeIds(obj, depth = 1, result = []) {
26
26
  return result;
27
27
  }
28
28
  export function recordContentUsage(stats, data, path) {
29
- if (stats !== null && stats !== void 0 && stats.contentUsage) {
29
+ if (stats?.contentUsage) {
30
30
  const {
31
31
  contentUsage
32
32
  } = stats;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/ssg",
3
- "version": "10.2.0",
3
+ "version": "10.2.4",
4
4
  "description": "Static Site Generator",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "prismjs": "^1.22.0",
40
40
  "pumpify": "^2.0.1",
41
41
  "resolve": "^1.19.0",
42
- "@takeshape/routing": "10.2.0",
43
- "@takeshape/util": "10.2.0",
44
- "@takeshape/streams": "10.2.0"
42
+ "@takeshape/routing": "10.2.4",
43
+ "@takeshape/util": "10.2.4",
44
+ "@takeshape/streams": "10.2.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/bluebird": "^3.5.33",
@@ -57,10 +57,10 @@
57
57
  "@types/prismjs": "^1.16.2",
58
58
  "@types/pumpify": "^1.4.1",
59
59
  "graphql-type-json": "^0.3.2",
60
- "@takeshape/typescript-jest-junit-reporter": "10.2.0"
60
+ "@takeshape/typescript-jest-junit-reporter": "10.2.4"
61
61
  },
62
62
  "engines": {
63
- "node": ">=16"
63
+ "node": ">=18"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "pnpm build:js && pnpm build:es && pnpm build:types && pnpm build:copy",