@adobe/helix-shared-config 11.1.12 → 11.1.14

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +355 -0
  3. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [@adobe/helix-shared-config-v11.1.14](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config-v11.1.13...@adobe/helix-shared-config-v11.1.14) (2026-01-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update external fixes ([#1183](https://github.com/adobe/helix-shared/issues/1183)) ([d0e9105](https://github.com/adobe/helix-shared/commit/d0e91053b2d3fd3d229b0b984473017ebbecee90))
7
+
8
+ # [@adobe/helix-shared-config-v11.1.13](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config-v11.1.12...@adobe/helix-shared-config-v11.1.13) (2025-12-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#1179](https://github.com/adobe/helix-shared/issues/1179)) ([a140ab9](https://github.com/adobe/helix-shared/commit/a140ab9d3533dc335660270b3a1a1824464f6c31))
14
+
1
15
  # [@adobe/helix-shared-config-v11.1.12](https://github.com/adobe/helix-shared/compare/@adobe/helix-shared-config-v11.1.11...@adobe/helix-shared-config-v11.1.12) (2025-10-13)
2
16
 
3
17
 
package/README.md CHANGED
@@ -1 +1,356 @@
1
1
  # Helix Shared - config
2
+
3
+ The config package provides a set of configuration classes for managing various Helix project configurations. These classes handle loading, validating, and managing YAML-based configuration files from local directories or remote GitHub repositories.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @adobe/helix-shared-config
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### IndexConfig - Managing Search Indices
14
+
15
+ The `IndexConfig` class manages search index configurations for content discovery and querying.
16
+
17
+ ```js
18
+ import { IndexConfig } from '@adobe/helix-shared-config';
19
+
20
+ // Load from local file
21
+ const config = await new IndexConfig()
22
+ .withConfigPath('/path/to/helix-query.yaml')
23
+ .init();
24
+
25
+ // Load from GitHub repository
26
+ const config = await new IndexConfig()
27
+ .withRepo('owner', 'repo', 'ref')
28
+ .init();
29
+
30
+ // Access index configuration
31
+ const indices = config.toJSON().indices;
32
+
33
+ // Get a specific query
34
+ const query = config.getQuery('my-index', 'my-query');
35
+
36
+ // Get query cache timeout
37
+ const cacheTimeout = config.getQueryCache('my-index', 'my-query');
38
+
39
+ // Generate query URL with parameters
40
+ const queryUrl = config.getQueryURL('my-index', 'my-query', 'owner', 'repo', {
41
+ page: '1',
42
+ filter: 'value'
43
+ });
44
+ ```
45
+
46
+ ### MountConfig - Managing Mount Points
47
+
48
+ The `MountConfig` class manages mount point configurations that map paths to external content sources like OneDrive, Google Drive, or GitHub.
49
+
50
+ ```js
51
+ import { MountConfig } from '@adobe/helix-shared-config';
52
+
53
+ // Load mount configuration
54
+ const config = await new MountConfig()
55
+ .withRepo('owner', 'repo', 'ref')
56
+ .init();
57
+
58
+ // Match a resource path to a mount point
59
+ const mountPoint = config.match('/docs/guide');
60
+
61
+ if (mountPoint) {
62
+ console.log(mountPoint.type); // 'onedrive', 'google', or 'github'
63
+ console.log(mountPoint.url); // Source URL
64
+ console.log(mountPoint.relPath); // Relative path from mount point
65
+ }
66
+ ```
67
+
68
+ Supported mount point types:
69
+ - **OneDrive/SharePoint**: `https://*.sharepoint.com/...` or `onedrive:` URLs
70
+ - **Google Drive**: `https://drive.google.com/...` or `gdrive:` URLs
71
+ - **GitHub**: `https://github.com/owner/repo/tree/ref/path` URLs
72
+
73
+ ### SitemapConfig - Managing Sitemaps
74
+
75
+ The `SitemapConfig` class manages sitemap configurations for SEO and content discovery.
76
+
77
+ ```js
78
+ import { SitemapConfig } from '@adobe/helix-shared-config';
79
+
80
+ // Load sitemap configuration
81
+ const config = await new SitemapConfig()
82
+ .withRepo('owner', 'repo', 'ref')
83
+ .init();
84
+
85
+ // Add a new sitemap
86
+ const sitemap = config.addSitemap({
87
+ name: 'main',
88
+ origin: 'https://example.com',
89
+ source: '/content',
90
+ destination: '/sitemap.xml',
91
+ lastmod: 'YYYY-MM-DD'
92
+ });
93
+
94
+ // Add language variants
95
+ config.addLanguage('main', {
96
+ name: 'en',
97
+ source: '/en',
98
+ destination: '/en/sitemap.xml',
99
+ hreflang: 'en-US',
100
+ alternate: 'https://example.com/en'
101
+ });
102
+
103
+ // Update sitemap origin
104
+ config.setOrigin('main', 'https://www.example.com');
105
+ ```
106
+
107
+ ### IgnoreConfig - Managing Ignore Patterns
108
+
109
+ The `IgnoreConfig` class manages ignore patterns similar to `.gitignore`.
110
+
111
+ ```js
112
+ import { IgnoreConfig } from '@adobe/helix-shared-config';
113
+
114
+ // Load ignore configuration
115
+ const config = await new IgnoreConfig()
116
+ .withDirectory('/path/to/project')
117
+ .init();
118
+
119
+ // Check if a path is ignored
120
+ const isIgnored = config.ignores('/node_modules/package');
121
+ ```
122
+
123
+ ### ModifiersConfig - Managing Metadata Modifiers
124
+
125
+ The `ModifiersConfig` class manages metadata and header modifiers based on URL patterns.
126
+
127
+ ```js
128
+ import { ModifiersConfig } from '@adobe/helix-shared-config/modifiers';
129
+
130
+ // Parse from a sheet-like structure
131
+ const sheet = [
132
+ { url: '/*', key: 'Cache-Control', value: 'max-age=3600' },
133
+ { url: '/blog/*', Title: 'Blog', Description: 'Our blog' },
134
+ { url: '/docs/**', key: 'X-Robots-Tag', value: 'noindex' }
135
+ ];
136
+
137
+ const config = ModifiersConfig.fromModifierSheet(sheet);
138
+
139
+ // Get modifiers for a specific path
140
+ const modifiers = config.getModifiers('/blog/post-1');
141
+ // Returns: { 'cache-control': 'max-age=3600', 'title': 'Blog', 'description': 'Our blog' }
142
+ ```
143
+
144
+ ### Config Wrappers for Serverless Functions
145
+
146
+ Use `requiredConfig` or `optionalConfig` to automatically load configurations in serverless functions.
147
+
148
+ ```js
149
+ import { requiredConfig, optionalConfig } from '@adobe/helix-shared-config';
150
+
151
+ // Function that requires configuration
152
+ async function handler(request, context) {
153
+ // Configuration available in context.config
154
+ const { fstab, index } = context.config;
155
+
156
+ const mountPoint = fstab.match(request.url);
157
+ // ... process request
158
+ }
159
+
160
+ // Wrap with required config - returns 400 if config is missing
161
+ export const main = requiredConfig(handler, 'fstab', 'index');
162
+
163
+ // Or use optional config - continues without config if missing
164
+ export const main = optionalConfig(handler, 'fstab', 'index');
165
+ ```
166
+
167
+ The wrappers automatically extract `owner`, `repo`, and `ref` from the request parameters and load the specified configurations.
168
+
169
+ ## Configuration Options
170
+
171
+ All configuration classes extend `BaseConfig` and support the following options:
172
+
173
+ ### Loading Configuration
174
+
175
+ ```js
176
+ const config = await new IndexConfig()
177
+ .withDirectory('/path/to/dir') // Set working directory
178
+ .withConfigPath('/path/to/config.yaml') // Set explicit config file path
179
+ .withSource('yaml: content') // Provide YAML source directly
180
+ .withJSON({ key: 'value' }) // Provide parsed JSON directly
181
+ .withLogger(logger) // Set custom logger
182
+ .init();
183
+ ```
184
+
185
+ ### Loading from GitHub
186
+
187
+ ```js
188
+ const config = await new IndexConfig()
189
+ .withRepo('owner', 'repo', 'ref', {
190
+ headers: {
191
+ authorization: 'token ghp_...'
192
+ }
193
+ })
194
+ .withTransactionID('request-id-123')
195
+ .init();
196
+ ```
197
+
198
+ ### Caching
199
+
200
+ ```js
201
+ const config = await new IndexConfig()
202
+ .withCache({ max: 100 }) // Set cache size (max entries)
203
+ .withRepo('owner', 'repo', 'ref')
204
+ .init();
205
+ ```
206
+
207
+ ### Validation
208
+
209
+ ```js
210
+ // Check for parsing errors
211
+ const errors = config.getErrors();
212
+ if (errors.length > 0) {
213
+ console.error('Configuration errors:', errors);
214
+ }
215
+ ```
216
+
217
+ ## Configuration File Formats
218
+
219
+ ### helix-query.yaml (IndexConfig)
220
+
221
+ ```yaml
222
+ version: 1
223
+ indices:
224
+ my-index:
225
+ include:
226
+ - /content/**
227
+ exclude:
228
+ - /content/drafts/**
229
+ target: https://example.algolia.net
230
+ properties:
231
+ title:
232
+ select: head > meta[property="og:title"]
233
+ value: attribute(el, 'content')
234
+ description:
235
+ select: head > meta[name="description"]
236
+ value: attribute(el, 'content')
237
+ queries:
238
+ search:
239
+ query: '{search}'
240
+ parameters:
241
+ - search
242
+ hitsPerPage: 10
243
+ cache: 600
244
+ ```
245
+
246
+ ### fstab.yaml (MountConfig)
247
+
248
+ ```yaml
249
+ mountpoints:
250
+ /: https://adobe.sharepoint.com/sites/example/Shared%20Documents/root
251
+ /docs: https://github.com/owner/repo/tree/main/documentation
252
+ /assets: https://drive.google.com/drive/folders/abc123def456
253
+ ```
254
+
255
+ ### helix-sitemap.yaml (SitemapConfig)
256
+
257
+ ```yaml
258
+ version: 1
259
+ sitemaps:
260
+ website:
261
+ origin: https://www.example.com
262
+ source: /content
263
+ destination: /sitemap.xml
264
+ lastmod: YYYY-MM-DD
265
+ languages:
266
+ en:
267
+ source: /en
268
+ destination: /en/sitemap.xml
269
+ hreflang: en-US
270
+ alternate: https://www.example.com/en
271
+ ```
272
+
273
+ ### .hlxignore (IgnoreConfig)
274
+
275
+ ```
276
+ # Ignore patterns (glob format)
277
+ node_modules/
278
+ *.tmp
279
+ .git/
280
+ .DS_Store
281
+ ```
282
+
283
+ ## Advanced Usage
284
+
285
+ ### Adding/Modifying Index Definitions
286
+
287
+ ```js
288
+ const config = await new IndexConfig().init();
289
+
290
+ // Add a new index
291
+ config.addIndex({
292
+ name: 'blog',
293
+ include: ['/blog/**'],
294
+ exclude: ['/blog/drafts/**'],
295
+ target: 'https://example.algolia.net',
296
+ properties: {
297
+ title: { select: 'h1', value: 'textContent(el)' }
298
+ }
299
+ });
300
+
301
+ // Replace an existing index
302
+ config.replaceIndex({
303
+ name: 'blog',
304
+ include: ['/blog/**', '/news/**'],
305
+ exclude: [],
306
+ target: 'https://example.algolia.net',
307
+ properties: {}
308
+ });
309
+
310
+ // Remove an index
311
+ config.removeIndex({ name: 'blog' });
312
+
313
+ // Save changes
314
+ await config.saveConfig();
315
+ ```
316
+
317
+ ### Working with Configuration Sources
318
+
319
+ ```js
320
+ // Export to YAML
321
+ const yamlString = config.toYAML();
322
+
323
+ // Export to JSON
324
+ const jsonObject = config.toJSON();
325
+
326
+ // Get raw source
327
+ const source = config.source;
328
+
329
+ // Get version
330
+ const version = config.version;
331
+ ```
332
+
333
+ ## Error Handling
334
+
335
+ Configuration classes include robust error handling:
336
+
337
+ ```js
338
+ try {
339
+ const config = await new IndexConfig()
340
+ .withRepo('owner', 'repo', 'ref')
341
+ .init();
342
+
343
+ const errors = config.getErrors();
344
+ if (errors.length > 0) {
345
+ // Handle YAML parsing errors
346
+ errors.forEach(error => console.error(error.message));
347
+ }
348
+ } catch (e) {
349
+ // Handle loading errors
350
+ console.error('Failed to load configuration:', e);
351
+ }
352
+ ```
353
+
354
+ ## License
355
+
356
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-shared-config",
3
- "version": "11.1.12",
3
+ "version": "11.1.14",
4
4
  "description": "Shared modules of the Helix Project - config",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -42,11 +42,11 @@
42
42
  "@adobe/helix-shared-utils": "^2.1.0",
43
43
  "ajv": "8.17.1",
44
44
  "ajv-formats": "3.0.1",
45
- "cookie": "1.0.2",
46
- "fs-extra": "11.3.2",
45
+ "cookie": "1.1.1",
46
+ "fs-extra": "11.3.3",
47
47
  "ignore": "7.0.5",
48
- "lru-cache": "11.2.2",
49
- "yaml": "2.8.1"
48
+ "lru-cache": "11.2.4",
49
+ "yaml": "2.8.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@adobe/helix-shared-wrap": "^1.0.5",