@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 +1 -2
- package/dist/filters/create-number-filter.js +2 -2
- package/dist/filters/create-route-filter.js +1 -1
- package/dist/generate/context.js +1 -2
- package/dist/generate/generate.js +1 -2
- package/dist/graphql/migrate.js +1 -2
- package/dist/graphql/pagination.js +1 -1
- package/dist/graphql/query.js +2 -2
- package/dist/graphql/schema-connector-factory.js +1 -2
- package/dist/resolve-context.js +2 -2
- package/dist/stats.js +1 -1
- package/es/config.js +1 -2
- package/es/filters/create-number-filter.js +2 -2
- package/es/filters/create-route-filter.js +1 -1
- package/es/generate/context.js +1 -2
- package/es/generate/generate.js +1 -2
- package/es/graphql/migrate.js +1 -2
- package/es/graphql/pagination.js +1 -1
- package/es/graphql/query.js +2 -2
- package/es/graphql/schema-connector-factory.js +1 -2
- package/es/resolve-context.js +2 -2
- package/es/stats.js +1 -1
- package/package.json +6 -6
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 (
|
|
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
|
-
...
|
|
124
|
+
...numbers?.config,
|
|
125
125
|
...config
|
|
126
126
|
};
|
|
127
|
-
const format = formatStr ? formatStr : numbers
|
|
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
|
|
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) {
|
package/dist/generate/context.js
CHANGED
|
@@ -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 (
|
|
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 (
|
|
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;
|
package/dist/graphql/migrate.js
CHANGED
|
@@ -68,8 +68,7 @@ function getMapResponse(props) {
|
|
|
68
68
|
...res.data
|
|
69
69
|
};
|
|
70
70
|
for (const prop of props) {
|
|
71
|
-
|
|
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
|
|
47
|
+
if (args?.length) {
|
|
48
48
|
const keyedArgs = (0, _keyBy.default)(args, 'name');
|
|
49
49
|
return paginationStrategies.find(strategy => {
|
|
50
50
|
const {
|
package/dist/graphql/query.js
CHANGED
|
@@ -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
|
|
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
|
|
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:
|
|
80
|
+
errors: res.errors?.map(_graphql.formatError)
|
|
82
81
|
};
|
|
83
82
|
};
|
|
84
83
|
}
|
package/dist/resolve-context.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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 (
|
|
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
|
-
...
|
|
117
|
+
...numbers?.config,
|
|
118
118
|
...config
|
|
119
119
|
};
|
|
120
|
-
const format = formatStr ? formatStr : numbers
|
|
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
|
|
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) {
|
package/es/generate/context.js
CHANGED
|
@@ -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 (
|
|
52
|
+
if (route.paginate?.itemName) {
|
|
54
53
|
itemContext[route.paginate.itemName] = current.item;
|
|
55
54
|
}
|
|
56
55
|
if (previous) {
|
package/es/generate/generate.js
CHANGED
|
@@ -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 (
|
|
260
|
+
if (config.htmlCompression?.enabled) {
|
|
262
261
|
decorators.push(compressHtml(config.htmlCompression));
|
|
263
262
|
}
|
|
264
263
|
return decorators.length ? compose(decorators) : identity;
|
package/es/graphql/migrate.js
CHANGED
|
@@ -59,8 +59,7 @@ export function getMapResponse(props) {
|
|
|
59
59
|
...res.data
|
|
60
60
|
};
|
|
61
61
|
for (const prop of props) {
|
|
62
|
-
|
|
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
|
}
|
package/es/graphql/pagination.js
CHANGED
|
@@ -30,7 +30,7 @@ function getPaginationStrategy(fieldDef) {
|
|
|
30
30
|
const {
|
|
31
31
|
args
|
|
32
32
|
} = fieldDef;
|
|
33
|
-
if (args
|
|
33
|
+
if (args?.length) {
|
|
34
34
|
const keyedArgs = keyBy(args, 'name');
|
|
35
35
|
return paginationStrategies.find(strategy => {
|
|
36
36
|
const {
|
package/es/graphql/query.js
CHANGED
|
@@ -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
|
|
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
|
|
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:
|
|
72
|
+
errors: res.errors?.map(formatError)
|
|
74
73
|
};
|
|
75
74
|
};
|
|
76
75
|
}
|
package/es/resolve-context.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
43
|
-
"@takeshape/util": "10.2.
|
|
44
|
-
"@takeshape/streams": "10.2.
|
|
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.
|
|
60
|
+
"@takeshape/typescript-jest-junit-reporter": "10.2.4"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
|
-
"node": ">=
|
|
63
|
+
"node": ">=18"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "pnpm build:js && pnpm build:es && pnpm build:types && pnpm build:copy",
|