@rathnasgala/theme 0.0.5 → 0.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rathnasgala/theme",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Managed Gala static-site theme payload",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "themePackage": {
4
4
  "name": "@rathnasgala/theme",
5
- "version": "0.0.5",
5
+ "version": "0.0.6",
6
6
  "availableDesignThemes": [
7
7
  "editorial"
8
8
  ],
@@ -15,7 +15,7 @@
15
15
  "package.json": "cccea6fc4edf4b4b653bd5cfc0901ab20dd92ac8975408fb01ae3670005da641",
16
16
  "package-lock.json": "c97a6a2f794aef083a39a8d2628eccc4a3c484e1c6225899b77ec1fb7c466d9e",
17
17
  "lib/build-manifest.js": "88949f0112d683ca809bb67ca969e15634792423559a67bc79a534cd807e5535",
18
- "lib/site-config.js": "83aa8ea678e06ae0e85096c841a2d6084ee23c7f236191ea426bbeda99567d16",
18
+ "lib/site-config.js": "59579cc3253529c7201002ab40435eeaeb4359ca82ddbb473a026bc317f62fcb",
19
19
  "lib/performance-budget.js": "124c43494c092a956accec46d1463ea063ed73363d0db01f24aaea987459d683",
20
20
  "lib/engagement-snapshot.js": "298c11b1ab135a3a98a4e31b6320ab60dfd7fda6a9d9053df37d86282a5a6687",
21
21
  "lib/publication-state.js": "1b59c29a18bbb1193bddea898dac3a4fb832c7bc4751263be086f3d64392dea0",
@@ -25,6 +25,21 @@ export function validatePerformanceBudgets(value) {
25
25
  return Object.freeze(Object.fromEntries(BUDGET_KEYS.map((key) => [key, value[key]])));
26
26
  }
27
27
 
28
+ export function validateStatistics(value) {
29
+ if (value == null) return Object.freeze({ publicViewCounts: false });
30
+ if (Array.isArray(value) || typeof value !== 'object') {
31
+ throw new TypeError('statistics must be a mapping');
32
+ }
33
+ const unknown = Object.keys(value).filter((key) => key !== 'publicViewCounts');
34
+ if (unknown.length > 0) {
35
+ throw new TypeError(`Unsupported statistics option: ${unknown.join(', ')}`);
36
+ }
37
+ if (value.publicViewCounts != null && typeof value.publicViewCounts !== 'boolean') {
38
+ throw new TypeError('statistics.publicViewCounts must be a boolean');
39
+ }
40
+ return Object.freeze({ publicViewCounts: value.publicViewCounts === true });
41
+ }
42
+
28
43
  export async function loadSiteConfiguration({
29
44
  root = process.cwd(),
30
45
  configPath = process.env.GALA_CONFIG_PATH ?? 'site.config.yml'
@@ -44,5 +59,6 @@ export async function loadSiteConfiguration({
44
59
  }
45
60
  const config = parse(await readFile(file, 'utf8'));
46
61
  validatePerformanceBudgets(config?.performance?.budgets);
62
+ config.statistics = validateStatistics(config.statistics);
47
63
  return config;
48
64
  }