@adobe/helix-shared-config 1.7.21 → 2.0.0
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/CHANGELOG.md +39 -0
- package/package.json +12 -9
- package/src/config-wrapper.js +0 -6
- package/src/index.js +0 -12
- package/src/Condition.js +0 -573
- package/src/ConfigValidator.js +0 -95
- package/src/DataEmbedValidator.js +0 -51
- package/src/DynamicRedirect.js +0 -125
- package/src/HelixConfig.js +0 -133
- package/src/MarkupConfig.js +0 -35
- package/src/Origin.js +0 -159
- package/src/Performance.js +0 -80
- package/src/Redirect.js +0 -64
- package/src/RedirectConfig.js +0 -64
- package/src/RedirectRuleHandler.js +0 -46
- package/src/Static.js +0 -119
- package/src/Strain.js +0 -332
- package/src/Strains.js +0 -68
- package/src/schemas/conditions.schema.json +0 -140
- package/src/schemas/config.description.md +0 -7
- package/src/schemas/config.example.1.json +0 -26
- package/src/schemas/config.schema.json +0 -44
- package/src/schemas/data-embed-response.schema.json +0 -40
- package/src/schemas/giturl.schema.json +0 -62
- package/src/schemas/markup.schema.json +0 -22
- package/src/schemas/markupconfig.schema.json +0 -38
- package/src/schemas/markupmapping.description.md +0 -242
- package/src/schemas/markupmapping.schema.json +0 -122
- package/src/schemas/origin.description.md +0 -5
- package/src/schemas/origin.schema.json +0 -86
- package/src/schemas/performance.schema.json +0 -210
- package/src/schemas/proxystrain.description.md +0 -20
- package/src/schemas/proxystrain.schema.json +0 -87
- package/src/schemas/redirect.schema.json +0 -34
- package/src/schemas/redirectrule.schema.json +0 -46
- package/src/schemas/redirects.description.md +0 -1
- package/src/schemas/redirects.schema.json +0 -41
- package/src/schemas/row.schema.json +0 -23
- package/src/schemas/runtimestrain.schema.json +0 -144
- package/src/schemas/sheet.schema.json +0 -57
- package/src/schemas/staticgiturl.schema.json +0 -80
- package/src/schemas/strains.schema.json +0 -39
- package/src/schemas/vanity.schema.json +0 -38
- package/src/schemas/version-lock.description.md +0 -3
- package/src/schemas/version-lock.schema.json +0 -35
- package/src/schemas/workbook.schema.json +0 -49
package/src/Static.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const { Pair } = require('yaml/types');
|
|
14
|
-
|
|
15
|
-
const EventEmitter = require('events');
|
|
16
|
-
const { GitUrl } = require('@adobe/helix-shared-git');
|
|
17
|
-
const pruneEmptyValues = require('@adobe/helix-shared-prune');
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Static content handling
|
|
21
|
-
*/
|
|
22
|
-
class Static extends EventEmitter {
|
|
23
|
-
constructor(cfg) {
|
|
24
|
-
super();
|
|
25
|
-
this.url = cfg;
|
|
26
|
-
this._magic = cfg.magic || false;
|
|
27
|
-
this._allow = cfg.allow || [];
|
|
28
|
-
this._deny = cfg.deny || [];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get url() {
|
|
32
|
-
return this._url;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
set url(value) {
|
|
36
|
-
if (value.toJSON) {
|
|
37
|
-
this._url = new GitUrl(value.toJSON({ minimal: true, keepFormat: true }), { ref: 'master', path: '/htdocs' });
|
|
38
|
-
} else {
|
|
39
|
-
this._url = new GitUrl(value, { ref: 'master', path: '/htdocs' });
|
|
40
|
-
}
|
|
41
|
-
this.emit('url-change', value);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get magic() {
|
|
45
|
-
return this._magic;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get allow() {
|
|
49
|
-
return this._allow;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get deny() {
|
|
53
|
-
return this._deny;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get path() {
|
|
57
|
-
return this._url.path;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get owner() {
|
|
61
|
-
return this._url.owner;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
get repo() {
|
|
65
|
-
return this._url.repo;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get ref() {
|
|
69
|
-
return this._url.ref;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* JSON Serialization of Static
|
|
74
|
-
* @typedef Static~JSON
|
|
75
|
-
* @augments GitUrl~JSON
|
|
76
|
-
* @property {boolean} magic
|
|
77
|
-
* @property {String[]} allow
|
|
78
|
-
* @property {String[]} deny
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Returns a json representation
|
|
83
|
-
* @returns {Static~JSON}
|
|
84
|
-
*/
|
|
85
|
-
toJSON(opts) {
|
|
86
|
-
let json = {
|
|
87
|
-
magic: this.magic,
|
|
88
|
-
allow: this.allow,
|
|
89
|
-
deny: this.deny,
|
|
90
|
-
};
|
|
91
|
-
if (opts && (opts.minimal || opts.keepFormat)) {
|
|
92
|
-
json = pruneEmptyValues(json);
|
|
93
|
-
}
|
|
94
|
-
if (!json) {
|
|
95
|
-
return this.url.toJSON(opts);
|
|
96
|
-
}
|
|
97
|
-
const myOpts = { ...opts };
|
|
98
|
-
delete myOpts.keepFormat;
|
|
99
|
-
return Object.assign(json, this.url.toJSON(myOpts));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
toYAMLNode() {
|
|
103
|
-
const props = pruneEmptyValues({
|
|
104
|
-
magic: this.magic,
|
|
105
|
-
allow: this.allow,
|
|
106
|
-
deny: this.deny,
|
|
107
|
-
});
|
|
108
|
-
if (!props) {
|
|
109
|
-
return this.url.toYAMLNode();
|
|
110
|
-
}
|
|
111
|
-
const node = this.url.toYAMLNode(true);
|
|
112
|
-
Object.keys(props).forEach((key) => {
|
|
113
|
-
node.items.push(new Pair(key, props[key]));
|
|
114
|
-
});
|
|
115
|
-
return node;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
module.exports = Static;
|
package/src/Strain.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const URI = require('uri-js');
|
|
14
|
-
const YAML = require('yaml');
|
|
15
|
-
const { YAMLMap, Pair } = require('yaml/types');
|
|
16
|
-
const { GitUrl } = require('@adobe/helix-shared-git');
|
|
17
|
-
const pruneEmptyValues = require('@adobe/helix-shared-prune');
|
|
18
|
-
const Origin = require('./Origin.js');
|
|
19
|
-
const Static = require('./Static.js');
|
|
20
|
-
const Performance = require('./Performance.js');
|
|
21
|
-
const Redirect = require('./Redirect.js');
|
|
22
|
-
const Condition = require('./Condition.js');
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Strain
|
|
26
|
-
*/
|
|
27
|
-
class Strain {
|
|
28
|
-
constructor(cfg) {
|
|
29
|
-
this._name = cfg.name;
|
|
30
|
-
if (cfg.origin) {
|
|
31
|
-
// proxy
|
|
32
|
-
this._origin = new Origin(cfg.origin);
|
|
33
|
-
} else {
|
|
34
|
-
this._origin = null;
|
|
35
|
-
this._content = new GitUrl(cfg.content, { ref: 'master' });
|
|
36
|
-
this._code = new GitUrl(cfg.code, { ref: 'master' });
|
|
37
|
-
// todo: 1. do we still need whilelists?
|
|
38
|
-
this._static = new Static(cfg.static);
|
|
39
|
-
// detect changes in static URL
|
|
40
|
-
this._static.on('url-change', () => {
|
|
41
|
-
this._modified('static', this._static);
|
|
42
|
-
});
|
|
43
|
-
this._directoryIndex = cfg.directoryIndex;
|
|
44
|
-
this._package = cfg.package || '';
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// todo: schema for perf
|
|
48
|
-
this._perf = new Performance(cfg.perf);
|
|
49
|
-
this._condition = cfg.condition ? new Condition(cfg.condition) : null;
|
|
50
|
-
|
|
51
|
-
if (cfg.url) {
|
|
52
|
-
throw new Error('url property is no longer supported.');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this._sticky = cfg.sticky;
|
|
56
|
-
|
|
57
|
-
this._redirects = (Array.isArray(cfg.redirects) ? cfg.redirects : [])
|
|
58
|
-
.map((r) => new Redirect(r));
|
|
59
|
-
|
|
60
|
-
this._urls = new Set(Array.isArray(cfg.urls) ? cfg.urls.map(URI.normalize) : []);
|
|
61
|
-
this._params = Array.isArray(cfg.params) ? cfg.params : [];
|
|
62
|
-
this._versionLock = cfg['version-lock'];
|
|
63
|
-
this._yamlNode = null;
|
|
64
|
-
// define them initially, and clear for alias node
|
|
65
|
-
// todo: improve
|
|
66
|
-
this._ownProperties = new Set([
|
|
67
|
-
'name',
|
|
68
|
-
'origin',
|
|
69
|
-
'code',
|
|
70
|
-
'content',
|
|
71
|
-
'static',
|
|
72
|
-
'package',
|
|
73
|
-
'perf',
|
|
74
|
-
'condition',
|
|
75
|
-
'sticky',
|
|
76
|
-
'urls',
|
|
77
|
-
'params',
|
|
78
|
-
'redirects',
|
|
79
|
-
'version-lock',
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
clone() {
|
|
84
|
-
const strain = new Strain(this.toJSON({ keepFormat: true }));
|
|
85
|
-
if (this._directoryIndex) {
|
|
86
|
-
// this is a bit a hack...consider a better binding
|
|
87
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
88
|
-
strain._ownProperties.add('directoryIndex');
|
|
89
|
-
}
|
|
90
|
-
// another neccessary hack
|
|
91
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
92
|
-
strain._sticky = this._sticky;
|
|
93
|
-
return strain;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
get urls() {
|
|
97
|
-
return Array.from(this._urls);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
set urls(value) {
|
|
101
|
-
if (Array.isArray(value)) {
|
|
102
|
-
this._urls = new Set(value.map(URI.normalize));
|
|
103
|
-
} else {
|
|
104
|
-
this._urls = new Set([value].map(URI.normalize));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
get sticky() {
|
|
109
|
-
// when `sticky` is not set
|
|
110
|
-
// assume the strain to be sticky when the condition is
|
|
111
|
-
return this._sticky === undefined && this._condition !== null
|
|
112
|
-
? this._condition.sticky()
|
|
113
|
-
: !!this._sticky;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Name of this strain.
|
|
118
|
-
* @returns {String}
|
|
119
|
-
*/
|
|
120
|
-
get name() {
|
|
121
|
-
return this._name;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
set name(value) {
|
|
125
|
-
this._name = value;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* GitUrl of the content repository
|
|
130
|
-
* @returns {GitUrl}
|
|
131
|
-
*/
|
|
132
|
-
get content() {
|
|
133
|
-
return this._content;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
set content(url) {
|
|
137
|
-
this._content = url;
|
|
138
|
-
this._modified('content', url);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* GitUrl of the code repository
|
|
143
|
-
* @returns {GitUrl}
|
|
144
|
-
*/
|
|
145
|
-
get code() {
|
|
146
|
-
return this._code;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
set code(code) {
|
|
150
|
-
this._code = code;
|
|
151
|
-
this._modified('code', code);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Static information of this strain
|
|
156
|
-
* @returns {Static}
|
|
157
|
-
*/
|
|
158
|
-
get static() {
|
|
159
|
-
return this._static;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
get package() {
|
|
163
|
-
return this._package;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
set package(value) {
|
|
167
|
-
this._package = value;
|
|
168
|
-
this._modified('package', value);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
get params() {
|
|
172
|
-
return this._params;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get condition() {
|
|
176
|
-
return this._condition;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
set condition(value) {
|
|
180
|
-
this._condition = value;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
get directoryIndex() {
|
|
184
|
-
return this._directoryIndex || 'index.html';
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
set directoryIndex(value) {
|
|
188
|
-
this._directoryIndex = value;
|
|
189
|
-
this._modified('directoryIndex', value);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
get perf() {
|
|
193
|
-
return this._perf;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
get origin() {
|
|
197
|
-
return this._origin;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
isProxy() {
|
|
201
|
-
return this._origin !== null;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
get redirects() {
|
|
205
|
-
return this._redirects;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
get versionLock() {
|
|
209
|
-
return this._versionLock;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* JSON Serialization of a Strain
|
|
214
|
-
* @typedef Strain~JSON
|
|
215
|
-
* @property {String} name
|
|
216
|
-
* @property {String} code
|
|
217
|
-
* @property {GitUrl~JSON} content
|
|
218
|
-
* @property {Static~JSON} static
|
|
219
|
-
* @property {String} condition
|
|
220
|
-
* @property {String} directoryIndex
|
|
221
|
-
* @property {Performance~JSON} perf
|
|
222
|
-
* @property {Origin~JSON} origin
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Returns a json representation
|
|
227
|
-
* @returns {Strain~JSON}
|
|
228
|
-
*/
|
|
229
|
-
toJSON(opts) {
|
|
230
|
-
const json = {
|
|
231
|
-
name: this.name,
|
|
232
|
-
sticky: this.sticky,
|
|
233
|
-
condition: this.condition ? this.condition.toJSON(opts) : '',
|
|
234
|
-
perf: this.perf.toJSON(opts),
|
|
235
|
-
urls: this.urls,
|
|
236
|
-
};
|
|
237
|
-
if (this.params.length > 0) {
|
|
238
|
-
json.params = this.params;
|
|
239
|
-
}
|
|
240
|
-
if (this.redirects.length > 0) {
|
|
241
|
-
json.redirects = this.redirects.map((r) => r.toJSON());
|
|
242
|
-
}
|
|
243
|
-
if (this.isProxy()) {
|
|
244
|
-
return { origin: this.origin.toJSON(opts), ...json };
|
|
245
|
-
}
|
|
246
|
-
if (this.versionLock) {
|
|
247
|
-
json['version-lock'] = this.versionLock;
|
|
248
|
-
}
|
|
249
|
-
const ret = {
|
|
250
|
-
code: this.code.toJSON(opts),
|
|
251
|
-
content: this.content.toJSON(opts),
|
|
252
|
-
static: this.static.toJSON(opts),
|
|
253
|
-
directoryIndex: this.directoryIndex,
|
|
254
|
-
package: this.package,
|
|
255
|
-
...json,
|
|
256
|
-
};
|
|
257
|
-
if (opts && opts.minimal) {
|
|
258
|
-
return pruneEmptyValues(ret);
|
|
259
|
-
}
|
|
260
|
-
return ret;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
_modified(propertyName, propertyValue) {
|
|
264
|
-
if (propertyName && propertyValue) {
|
|
265
|
-
this._ownProperties.add(propertyName);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (this._yamlNode) {
|
|
269
|
-
const node = this._yamlNode;
|
|
270
|
-
this._ownProperties.forEach((key) => {
|
|
271
|
-
const idx = node.items.findIndex((i) => i.key === key
|
|
272
|
-
|| (i.key.value && i.key.value === key));
|
|
273
|
-
let value = key === 'version-lock' ? this.versionLock : this[key];
|
|
274
|
-
value = key === 'sticky' ? this._sticky : value;
|
|
275
|
-
if (value && value.toYAMLNode) {
|
|
276
|
-
value = value.toYAMLNode();
|
|
277
|
-
}
|
|
278
|
-
if (Array.isArray(value) && value.length === 0) {
|
|
279
|
-
value = null;
|
|
280
|
-
}
|
|
281
|
-
if (value || (value === false && key === 'sticky')) {
|
|
282
|
-
if (idx >= 0) {
|
|
283
|
-
const item = node.items[idx];
|
|
284
|
-
const oldValue = item.value.type === 'ALIAS' ? item.value.source : item.value;
|
|
285
|
-
if (oldValue.toString() !== value.toString()) {
|
|
286
|
-
item.value = value;
|
|
287
|
-
}
|
|
288
|
-
} else {
|
|
289
|
-
node.items.push(new Pair(key, value));
|
|
290
|
-
}
|
|
291
|
-
} else if (idx >= 0) {
|
|
292
|
-
node.items.splice(idx, 1);
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (propertyName && !propertyValue) {
|
|
298
|
-
this._ownProperties.clear(propertyName);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
toYAML() {
|
|
303
|
-
return YAML.stringify(this.toYAMLNode());
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
static fromYAMLNode(node) {
|
|
307
|
-
/* eslint-disable no-underscore-dangle */
|
|
308
|
-
const json = node.toJSON();
|
|
309
|
-
const strain = new Strain(json);
|
|
310
|
-
strain._yamlNode = node;
|
|
311
|
-
strain._ownProperties.clear();
|
|
312
|
-
if (node.type === 'MAP') {
|
|
313
|
-
// remember our 'own' properties
|
|
314
|
-
node.items.forEach((pair) => {
|
|
315
|
-
strain._ownProperties.add(pair.key.value);
|
|
316
|
-
});
|
|
317
|
-
strain._ownProperties.delete('<<');
|
|
318
|
-
}
|
|
319
|
-
/* eslint-enable no-underscore-dangle */
|
|
320
|
-
return strain;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
toYAMLNode() {
|
|
324
|
-
if (!this._yamlNode) {
|
|
325
|
-
this._yamlNode = new YAMLMap();
|
|
326
|
-
this._modified();
|
|
327
|
-
}
|
|
328
|
-
return this._yamlNode;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
module.exports = Strain;
|
package/src/Strains.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2018 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
const Strain = require('./Strain.js');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Strains
|
|
16
|
-
*/
|
|
17
|
-
class Strains extends Map {
|
|
18
|
-
add(strain) {
|
|
19
|
-
this.set(strain.name, strain);
|
|
20
|
-
if (this._yamlNode) {
|
|
21
|
-
const node = strain.toYAMLNode();
|
|
22
|
-
node.spaceBefore = true;
|
|
23
|
-
this._yamlNode.items.push(node);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Returns a json representation
|
|
29
|
-
* @returns {Strains~JSON}
|
|
30
|
-
*/
|
|
31
|
-
toJSON() {
|
|
32
|
-
const strains = [];
|
|
33
|
-
this.forEach((strain) => {
|
|
34
|
-
strains.push(strain.toJSON());
|
|
35
|
-
});
|
|
36
|
-
return strains;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
filterByCode(code) {
|
|
40
|
-
return this.getByFilter((strain) => code.equalsIgnoreTransport(strain.code));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
getByFilter(filterfn) {
|
|
44
|
-
return [...this.values()].filter(filterfn);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getRuntimeStrains() {
|
|
48
|
-
return this.getByFilter((strain) => !strain.isProxy());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getProxyStrains() {
|
|
52
|
-
return this.getByFilter((strain) => strain.isProxy());
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Creates the strains from a yaml node
|
|
57
|
-
* @param {YAMLSeq} node
|
|
58
|
-
*/
|
|
59
|
-
fromYAML(node) {
|
|
60
|
-
this._yamlNode = node;
|
|
61
|
-
node.items.forEach((value) => {
|
|
62
|
-
const strain = Strain.fromYAMLNode(value);
|
|
63
|
-
this.set(strain.name, strain);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports = Strains;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"meta:license": [
|
|
3
|
-
"Copyright 2018 Adobe. All rights reserved.",
|
|
4
|
-
"This file is licensed to you under the Apache License, Version 2.0 (the \"License\");",
|
|
5
|
-
"you may not use this file except in compliance with the License. You may obtain a copy",
|
|
6
|
-
"of the License at http://www.apache.org/licenses/LICENSE-2.0",
|
|
7
|
-
"",
|
|
8
|
-
"Unless required by applicable law or agreed to in writing, software distributed under",
|
|
9
|
-
"the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS",
|
|
10
|
-
"OF ANY KIND, either express or implied. See the License for the specific language",
|
|
11
|
-
"governing permissions and limitations under the License."
|
|
12
|
-
],
|
|
13
|
-
"$id": "https://ns.adobe.com/helix/shared/conditions",
|
|
14
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
15
|
-
"title": "Conditions",
|
|
16
|
-
"type": "object",
|
|
17
|
-
"meta:status": "stabilizing",
|
|
18
|
-
"description": "A condition expression",
|
|
19
|
-
"additionalProperties": false,
|
|
20
|
-
"minProperties": 1,
|
|
21
|
-
"maxProperties": 1,
|
|
22
|
-
"properties": {
|
|
23
|
-
"and": {
|
|
24
|
-
"type": "array",
|
|
25
|
-
"items": { "$ref": "https://ns.adobe.com/helix/shared/conditions" },
|
|
26
|
-
"description": "All conditions in this list must be met"
|
|
27
|
-
},
|
|
28
|
-
"or": {
|
|
29
|
-
"type": "array",
|
|
30
|
-
"items": { "$ref": "https://ns.adobe.com/helix/shared/conditions" },
|
|
31
|
-
"description": "Any conditions in this list must be met"
|
|
32
|
-
},
|
|
33
|
-
"not": {
|
|
34
|
-
"$ref": "https://ns.adobe.com/helix/shared/conditions"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"patternProperties": {
|
|
38
|
-
"^url[=~]?$": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"description": "Matches the full URL, including request parameters"
|
|
41
|
-
},
|
|
42
|
-
"^url\\.hostname[=~]?$": {
|
|
43
|
-
"type": "string",
|
|
44
|
-
"description": "Matches the hostname only"
|
|
45
|
-
},
|
|
46
|
-
"^url\\.path[=~]?$": {
|
|
47
|
-
"type": "string",
|
|
48
|
-
"description": "Matches the path only. Path does not include the query string."
|
|
49
|
-
},
|
|
50
|
-
"^referer[=~]?$": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"description": "Matches the Referrer (note the spelling)"
|
|
53
|
-
},
|
|
54
|
-
"^client_name[=~]?$": {
|
|
55
|
-
"type": "string",
|
|
56
|
-
"description": "Matches the client's company or ISP name"
|
|
57
|
-
},
|
|
58
|
-
"^client_city[=~]?$": {
|
|
59
|
-
"type": "string",
|
|
60
|
-
"description": "Matches the client's city"
|
|
61
|
-
},
|
|
62
|
-
"^client_country_code[=~]?$": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"description": "Matches the ISO 3166-1 country code (two letters)"
|
|
65
|
-
},
|
|
66
|
-
"^user_agent[=~]?$": {
|
|
67
|
-
"type": "string",
|
|
68
|
-
"description": "Matches the User Agent"
|
|
69
|
-
},
|
|
70
|
-
"^accept_language[=~]?$": {
|
|
71
|
-
"type": "string",
|
|
72
|
-
"description": "Matches the Accept-Language header"
|
|
73
|
-
},
|
|
74
|
-
"^client_lat[<=>]?$": {
|
|
75
|
-
"type": "number",
|
|
76
|
-
"description": "Compares the latitude"
|
|
77
|
-
},
|
|
78
|
-
"^client_lon[<=>]?$": {
|
|
79
|
-
"type": "number",
|
|
80
|
-
"description": "Compares the longitude"
|
|
81
|
-
},
|
|
82
|
-
"^client_gmt_offset[<=>]?$": {
|
|
83
|
-
"type": "number",
|
|
84
|
-
"description": "UTC offset for the client's time zone. Values look like -100 or 300."
|
|
85
|
-
},
|
|
86
|
-
"^time[<=>]?$": {
|
|
87
|
-
"type": "string",
|
|
88
|
-
"format": "date-time",
|
|
89
|
-
"description": "Absolute time of the request, evaluated against UTC"
|
|
90
|
-
},
|
|
91
|
-
"^time_day[<=>]?$": {
|
|
92
|
-
"type": "number",
|
|
93
|
-
"description": "Day of the week, same as Date.getDay() – adjusted for GMT offset"
|
|
94
|
-
},
|
|
95
|
-
"^time_date[<=>]?$": {
|
|
96
|
-
"type": "number",
|
|
97
|
-
"description": "Day of the month, same as Date.getDate() – adjusted for GMT offset"
|
|
98
|
-
},
|
|
99
|
-
"^time_hours[<=>]?$": {
|
|
100
|
-
"type": "number",
|
|
101
|
-
"description": "Hour of the day, same as Date.getHours() – adjusted for GMT offset"
|
|
102
|
-
},
|
|
103
|
-
"^time_minutes[<=>]?$": {
|
|
104
|
-
"type": "number",
|
|
105
|
-
"description": "Minute of the hour, same as Date.getMinutes() – adjusted for GMT offset"
|
|
106
|
-
},
|
|
107
|
-
"^time_month[<=>]?$": {
|
|
108
|
-
"type": "number",
|
|
109
|
-
"description": "Month of the year, same as Date.getMonth() – adjusted for GMT offset"
|
|
110
|
-
},
|
|
111
|
-
"^time_year[<=>]?$": {
|
|
112
|
-
"type": "number",
|
|
113
|
-
"description": "Year, same as Date.getFullYear() – adjusted for GMT offset"
|
|
114
|
-
},
|
|
115
|
-
"^url_param\\..+[~]?$": {
|
|
116
|
-
"type": "string",
|
|
117
|
-
"description": "Matches a URL parameter's value as a string"
|
|
118
|
-
},
|
|
119
|
-
"^url_param\\..+[<>]$": {
|
|
120
|
-
"type": "number",
|
|
121
|
-
"description": "Matches a URL parameter's value as a number"
|
|
122
|
-
},
|
|
123
|
-
"^url_param\\..+[=]$": {
|
|
124
|
-
"type": ["number", "string"],
|
|
125
|
-
"description": "Matches a URL parameter's value as a number or string"
|
|
126
|
-
},
|
|
127
|
-
"^preflight\\..+[~]?$": {
|
|
128
|
-
"type": "string",
|
|
129
|
-
"description": "Matches a preflight response header value as a string"
|
|
130
|
-
},
|
|
131
|
-
"^preflight\\..+[<>]$": {
|
|
132
|
-
"type": "number",
|
|
133
|
-
"description": "Matches a preflight response header value as a number"
|
|
134
|
-
},
|
|
135
|
-
"^preflight\\..+[=]$": {
|
|
136
|
-
"type": ["number", "string"],
|
|
137
|
-
"description": "Matches a preflight response header value as a number or string"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
The Strains configuration for a Project Helix website.
|
|
2
|
-
|
|
3
|
-
The `helix-config.yaml` file contains the list of Strains that have been configured for a Helix site.
|
|
4
|
-
|
|
5
|
-
Each strain represents a variant of the site. It is required to have a default strain for each website. A strain is either a [Runtime strain](runtimestrain.md), if it's powered by the Helix pipeline on Adobe I/O Runtime, or a [Proxy strain](proxystrain.md), if it's serving content from another host.
|
|
6
|
-
|
|
7
|
-
All strains can have [Conditions](conditions.md) that determine if a visitor is eligible to see a certain strain. If a request fulfills the conditions of multiple strains, the first eligible strain will be served. This is why order of the strains in `helix-config.yaml` is important.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"strains": [
|
|
3
|
-
{
|
|
4
|
-
"name": "preview",
|
|
5
|
-
"owner": "adobe",
|
|
6
|
-
"repo": "project-helix.io",
|
|
7
|
-
"ref": "preview",
|
|
8
|
-
"condition": {
|
|
9
|
-
"url": "https://preview.project.helix.io/"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"name": "legacy",
|
|
14
|
-
"origin": "https://www.adobe.io/helix",
|
|
15
|
-
"condition": {
|
|
16
|
-
"url": "https://www.project.helix.io/"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"name": "default",
|
|
21
|
-
"owner": "adobe",
|
|
22
|
-
"repo": "project-helix.io",
|
|
23
|
-
"ref": "master"
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|