@fastly/compute-js-static-publish 8.1.0-beta.3 → 8.1.0-beta.5
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 +602 -0
- package/DOCUMENTATION.md +53 -14
- package/MIGRATING.md +289 -0
- package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/deploy.js +27 -7
- package/build/cli/cli/commands/manage/index.d.ts +1 -0
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/index.js +13 -11
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +5 -3
- package/build/cli/cli/commands/manage/status.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/status.js +7 -5
- package/build/cli/cli/commands/manage/template/init.js +6 -6
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +2 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.js +6 -0
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +12 -6
- package/build/cli/cli/index.js +15 -1
- package/build/cli/cli/managed/fastly-service.d.ts +7 -0
- package/build/cli/cli/managed/fastly-service.d.ts.map +1 -1
- package/build/cli/cli/managed/fastly-service.js +31 -1
- package/build/cli/cli/managed/fingerprint.d.ts +12 -0
- package/build/cli/cli/managed/fingerprint.d.ts.map +1 -1
- package/build/cli/cli/managed/fingerprint.js +25 -0
- package/build/cli/cli/managed/project-file.d.ts.map +1 -1
- package/build/cli/cli/managed/project-file.js +9 -1
- package/build/cli/cli/managed/template-init.d.ts.map +1 -1
- package/build/cli/cli/managed/template-init.js +3 -1
- package/build/cli/cli/util/collection-selection-flags.d.ts +1 -1
- package/build/cli/cli/util/collection-selection-flags.d.ts.map +1 -1
- package/build/cli/cli/util/collection-selection-flags.js +31 -5
- package/build/cli/cli/util/config.d.ts +4 -0
- package/build/cli/cli/util/config.d.ts.map +1 -1
- package/build/cli/cli/util/config.js +33 -0
- package/build/cli/cli/util/fastly-options.d.ts +2 -0
- package/build/cli/cli/util/fastly-options.d.ts.map +1 -0
- package/build/cli/cli/util/fastly-options.js +52 -0
- package/build/cli/cli/util/output.js +1 -1
- package/build/cli/cli/util/package.d.ts.map +1 -1
- package/build/cli/cli/util/package.js +10 -4
- package/build/cli/models/config/collection-selection.d.ts +2 -0
- package/build/cli/models/config/collection-selection.d.ts.map +1 -1
- package/build/cli/models/config/collection-selection.js +48 -8
- package/build/cli/models/config/s3-storage-config.d.ts +1 -0
- package/build/cli/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/cli/models/config/s3-storage-config.js +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.js +3 -1
- package/build/server/hono/extensions.d.ts +3 -1
- package/build/server/hono/extensions.d.ts.map +1 -1
- package/build/server/hono/extensions.js +12 -7
- package/build/server/hono/index.d.ts +6 -1
- package/build/server/hono/index.d.ts.map +1 -1
- package/build/server/hono/index.js +21 -13
- package/build/server/models/config/collection-selection.d.ts +2 -0
- package/build/server/models/config/collection-selection.d.ts.map +1 -1
- package/build/server/models/config/collection-selection.js +48 -8
- package/build/server/models/config/s3-storage-config.d.ts +1 -0
- package/build/server/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/server/models/config/s3-storage-config.js +1 -0
- package/build/server/models/config/static-publish-rc.d.ts +1 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/models/config/static-publish-rc.js +3 -1
- package/build/server/server/collection-selection/index.d.ts.map +1 -1
- package/build/server/server/collection-selection/index.js +16 -6
- package/build/server/server/publisher-server/index.d.ts +2 -0
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +4 -4
- package/build/server/server/storage/s3-storage-provider.d.ts +2 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +15 -7
- package/package.json +4 -2
- package/resources/app/fastly.toml.njk +8 -8
- package/resources/app/static-publish.project.js.njk +6 -0
- package/resources/app/static-publish.rc.js.njk +6 -0
- package/resources/template-init/hono/gitignore +1 -0
- package/resources/templates/hono/src/index.ts +6 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
// The options after -- of deploy, which go to 'fastly compute deploy' (or
|
|
6
|
+
// 'fastly compute publish' in an ejected app). deploy refuses the options that
|
|
7
|
+
// it sets itself, and the options that make the Fastly CLI deploy another
|
|
8
|
+
// package, from another directory, or with another manifest or token.
|
|
9
|
+
const REFUSED = new Map([
|
|
10
|
+
['comment', `deploy sets the comment of the service version. Use the --comment option of deploy (before --).`],
|
|
11
|
+
['service-id', `Use --fastly-service-id or FASTLY_SERVICE_ID.`],
|
|
12
|
+
['token', `Use --fastly-api-token or FASTLY_API_TOKEN.`],
|
|
13
|
+
['package', `deploy deploys the package that it builds.`],
|
|
14
|
+
['dir', `deploy deploys the app of the project.`],
|
|
15
|
+
['env', `deploy uses the fastly.toml of the app.`],
|
|
16
|
+
]);
|
|
17
|
+
// The short forms of the refused options. In 'fastly compute deploy' and
|
|
18
|
+
// 'fastly compute publish', these are the only short options that take a
|
|
19
|
+
// value. The other short options (-i, -y, -d, -v, -q, -h) take no value, so a
|
|
20
|
+
// group such as -is is -i and then -s.
|
|
21
|
+
const REFUSED_SHORT = new Map([
|
|
22
|
+
['s', 'service-id'],
|
|
23
|
+
['t', 'token'],
|
|
24
|
+
['p', 'package'],
|
|
25
|
+
['C', 'dir'],
|
|
26
|
+
]);
|
|
27
|
+
// Returns the error message for the first refused option in args, or null if
|
|
28
|
+
// args has none. A value that starts with '-' (for example --service-name -s)
|
|
29
|
+
// looks like an option, so it can also be refused.
|
|
30
|
+
export function findRefusedFastlyOption(args) {
|
|
31
|
+
for (const arg of args) {
|
|
32
|
+
if (arg.startsWith('--')) {
|
|
33
|
+
const name = arg.slice(2).split('=')[0];
|
|
34
|
+
const reason = REFUSED.get(name);
|
|
35
|
+
if (reason != null) {
|
|
36
|
+
return `--${name} cannot be given to the Fastly CLI. ${reason}`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (arg.startsWith('-') && arg.length > 1) {
|
|
40
|
+
for (const letter of arg.slice(1)) {
|
|
41
|
+
if (letter === '=') {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
const name = REFUSED_SHORT.get(letter);
|
|
45
|
+
if (name != null) {
|
|
46
|
+
return `-${letter} (--${name}) cannot be given to the Fastly CLI. ${REFUSED.get(name)}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
@@ -27,7 +27,7 @@ const USAGE_CODES = [
|
|
|
27
27
|
'config-invalid', // a config file cannot be loaded or is not valid
|
|
28
28
|
'collection-name-invalid', // a collection name breaks the rule
|
|
29
29
|
'collection-not-found', // the command needs a collection that does not exist
|
|
30
|
-
'project-dir-not-found', // --project-dir is not a directory, or has no config file
|
|
30
|
+
'project-dir-not-found', // --project-dir is not a directory, or has no config file, or a command for a project runs in a directory with no config file
|
|
31
31
|
'json-not-supported', // --json with a command that does not support it
|
|
32
32
|
'credentials-missing', // a token or credentials are necessary, but not given
|
|
33
33
|
'version-mismatch', // managed.staticPublishVersion is not the version that runs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/package.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAA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wB,EACjC,SAAS,GAAE,OAAuB,GACjC,MAAM,CAaR;AAED,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,UA8ClF"}
|
|
@@ -45,19 +45,25 @@ export function isLocalCopy(dir = process.cwd()) {
|
|
|
45
45
|
// The npx command of this package, for the messages of the CLI.
|
|
46
46
|
// - If a plain npx runs this copy (it is installed in the project or the app),
|
|
47
47
|
// the command has no dist-tag. A dist-tag makes npx get the version of that
|
|
48
|
-
// tag from npm, which can be
|
|
48
|
+
// tag from npm, which can be a different version from the installed one.
|
|
49
49
|
// - Else, the version of a prerelease (for example 8.1.0-beta.1) gives the
|
|
50
50
|
// dist-tag of the prerelease (@beta), because npx without a dist-tag runs
|
|
51
51
|
// the latest stable version, which does not have the features of the
|
|
52
52
|
// prerelease. A stable version gives no dist-tag, or @latest with
|
|
53
53
|
// { latest: true } (the command that makes a new app).
|
|
54
54
|
export function cliCommand(options = {}, version = getOwnVersion(), localCopy = isLocalCopy()) {
|
|
55
|
+
const command = 'npx @fastly/compute-js-static-publish';
|
|
55
56
|
if (localCopy) {
|
|
56
|
-
return
|
|
57
|
+
return command;
|
|
57
58
|
}
|
|
58
59
|
const prerelease = /^\d+\.\d+\.\d+-([a-z][a-z0-9-]*)/.exec(version)?.[1];
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
if (prerelease != null) {
|
|
61
|
+
return `${command}@${prerelease}`;
|
|
62
|
+
}
|
|
63
|
+
if (options.latest) {
|
|
64
|
+
return `${command}@latest`;
|
|
65
|
+
}
|
|
66
|
+
return command;
|
|
61
67
|
}
|
|
62
68
|
export function findComputeJsStaticPublisherVersion(packageJson) {
|
|
63
69
|
// Get the current compute js static publisher version.
|
|
@@ -2,10 +2,12 @@ export declare const COLLECTION_PLACEHOLDER = "{collection}";
|
|
|
2
2
|
export type CollectionSelectionHostSource = {
|
|
3
3
|
type: 'host';
|
|
4
4
|
pattern: string;
|
|
5
|
+
value?: string;
|
|
5
6
|
};
|
|
6
7
|
export type CollectionSelectionPathSource = {
|
|
7
8
|
type: 'path';
|
|
8
9
|
prefix: string;
|
|
10
|
+
value?: string;
|
|
9
11
|
sticky?: 'cookie';
|
|
10
12
|
};
|
|
11
13
|
export type CollectionSelectionQuerySource = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IAIb,OAAO,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IAIb,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,OAAO,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,QAAQ,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,+BAA+B,G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E,mBAAmB,GAAG,MAAM,GAAG,IAAI,CA6C9G;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAqBxI"}
|
|
@@ -67,6 +67,20 @@ export function validateCollectionSelection(config) {
|
|
|
67
67
|
return ['collectionSelection must be an object.'];
|
|
68
68
|
}
|
|
69
69
|
const { sources, allow, onMissing, noindex } = config;
|
|
70
|
+
const allowIsValid = allow === undefined ||
|
|
71
|
+
(Array.isArray(allow) && allow.every(x => typeof x === 'string' && ALLOW_PATTERN.test(x)));
|
|
72
|
+
// The value of a host or path source: a collection name that allow (if set) matches.
|
|
73
|
+
const checkValue = (name, value, patternField, pattern) => {
|
|
74
|
+
if (typeof value !== 'string' || !isValidCollectionName(value)) {
|
|
75
|
+
errors.push(`${name}.value must be a valid collection name. ${COLLECTION_NAME_RULE}`);
|
|
76
|
+
}
|
|
77
|
+
else if (allowIsValid && !isCollectionNameAllowed(value, allow)) {
|
|
78
|
+
errors.push(`${name}.value '${value}' is not in collectionSelection.allow.`);
|
|
79
|
+
}
|
|
80
|
+
if (typeof pattern === 'string' && pattern.includes(COLLECTION_PLACEHOLDER)) {
|
|
81
|
+
errors.push(`${name}: use ${COLLECTION_PLACEHOLDER} in ${patternField}, or value, not both.`);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
70
84
|
if (!Array.isArray(sources)) {
|
|
71
85
|
errors.push('collectionSelection.sources must be an array.');
|
|
72
86
|
}
|
|
@@ -86,9 +100,17 @@ export function validateCollectionSelection(config) {
|
|
|
86
100
|
}
|
|
87
101
|
switch (s.type) {
|
|
88
102
|
case 'host': {
|
|
103
|
+
if (s.value !== undefined) {
|
|
104
|
+
checkValue(name, s.value, 'pattern', s.pattern);
|
|
105
|
+
if (typeof s.pattern !== 'string' ||
|
|
106
|
+
(!s.pattern.includes(COLLECTION_PLACEHOLDER) && !/^[a-z0-9-]+(\.[a-z0-9-]+)*$/i.test(s.pattern))) {
|
|
107
|
+
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.'.`);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
89
111
|
const parts = typeof s.pattern === 'string' ? splitPattern(s.pattern) : null;
|
|
90
112
|
if (parts == null) {
|
|
91
|
-
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
113
|
+
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a hostname with value.`);
|
|
92
114
|
}
|
|
93
115
|
else if (!/^[a-z0-9.-]*$/i.test(parts.before + parts.after)) {
|
|
94
116
|
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.' around ${COLLECTION_PLACEHOLDER}.`);
|
|
@@ -99,14 +121,19 @@ export function validateCollectionSelection(config) {
|
|
|
99
121
|
break;
|
|
100
122
|
}
|
|
101
123
|
case 'path': {
|
|
102
|
-
|
|
124
|
+
if (s.value !== undefined) {
|
|
125
|
+
checkValue(name, s.value, 'prefix', s.prefix);
|
|
126
|
+
}
|
|
127
|
+
const parts = typeof s.prefix !== 'string' ? null :
|
|
128
|
+
s.value !== undefined ? { before: s.prefix, after: '' } :
|
|
129
|
+
splitPattern(s.prefix);
|
|
103
130
|
if (parts == null) {
|
|
104
|
-
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
131
|
+
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a prefix with value.`);
|
|
105
132
|
}
|
|
106
133
|
else if (!parts.before.startsWith('/')) {
|
|
107
134
|
errors.push(`${name}.prefix must start with '/'.`);
|
|
108
135
|
}
|
|
109
|
-
else if (parts.after.endsWith('/')) {
|
|
136
|
+
else if ((s.value !== undefined ? parts.before : parts.after).endsWith('/')) {
|
|
110
137
|
errors.push(`${name}.prefix must not end with '/'.`);
|
|
111
138
|
}
|
|
112
139
|
else if (/[?#]/.test(parts.before + parts.after)) {
|
|
@@ -139,6 +166,9 @@ export function validateCollectionSelection(config) {
|
|
|
139
166
|
}
|
|
140
167
|
break;
|
|
141
168
|
}
|
|
169
|
+
if (s.value !== undefined && s.type !== 'host' && s.type !== 'path') {
|
|
170
|
+
errors.push(`${name}.value is only for the 'host' and 'path' sources.`);
|
|
171
|
+
}
|
|
142
172
|
if (s.sticky !== undefined) {
|
|
143
173
|
if (s.type !== 'path' && s.type !== 'query') {
|
|
144
174
|
errors.push(`${name}.sticky is only for the 'path' and 'query' sources.`);
|
|
@@ -158,10 +188,8 @@ export function validateCollectionSelection(config) {
|
|
|
158
188
|
errors.push(`sticky: 'cookie' needs a 'cookie' source in collectionSelection.sources, for the settings of the cookie.`);
|
|
159
189
|
}
|
|
160
190
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
164
|
-
}
|
|
191
|
+
if (!allowIsValid) {
|
|
192
|
+
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
165
193
|
}
|
|
166
194
|
if (onMissing !== undefined && onMissing !== 'not-found' && onMissing !== 'default') {
|
|
167
195
|
errors.push(`collectionSelection.onMissing must be 'not-found' or 'default'.`);
|
|
@@ -187,6 +215,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
187
215
|
for (const source of config.sources) {
|
|
188
216
|
switch (source.type) {
|
|
189
217
|
case 'host': {
|
|
218
|
+
if (source.value != null) {
|
|
219
|
+
if (source.value === collectionName) {
|
|
220
|
+
return `${base.protocol}//${source.pattern.toLowerCase()}/`;
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
190
224
|
const maxLength = maxCollectionNameLengthForHost(source.pattern);
|
|
191
225
|
if (collectionName.length > maxLength) {
|
|
192
226
|
throw new Error(`'${collectionName}' is too long for the host pattern '${source.pattern}': a host label has at most ${MAX_LABEL_LENGTH} characters, so the name can have at most ${maxLength}.`);
|
|
@@ -194,6 +228,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
194
228
|
return `${base.protocol}//${source.pattern.replace(COLLECTION_PLACEHOLDER, collectionName).toLowerCase()}/`;
|
|
195
229
|
}
|
|
196
230
|
case 'path':
|
|
231
|
+
if (source.value != null) {
|
|
232
|
+
if (source.value === collectionName) {
|
|
233
|
+
return `${base.origin}${source.prefix}/`;
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
197
237
|
return `${base.origin}${source.prefix.replace(COLLECTION_PLACEHOLDER, collectionName)}/`;
|
|
198
238
|
case 'query': {
|
|
199
239
|
const url = new URL('/', base);
|
|
@@ -4,6 +4,7 @@ export type S3StorageConfig = {
|
|
|
4
4
|
bucket: string;
|
|
5
5
|
endpoint?: string;
|
|
6
6
|
fastlyBackendName?: string;
|
|
7
|
+
secretStoreLinkName?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare function getS3StorageConfigFromRc(rc: StaticPublishS3Storage): S3StorageConfig;
|
|
9
10
|
//# sourceMappingURL=s3-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB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,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAG3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAChC,6BAA6B,GAAG,mBAAmB,CAAC;AAEtD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,sBAAsB,CA6B7E;AAED,MAAM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,6BAA6B,CAChC;AAED,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,sBAAsB,CACzB;AAQD,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuB5E"}
|
|
@@ -32,7 +32,9 @@ export function isS3StorageConfigRc(rc) {
|
|
|
32
32
|
rc.s3.endpoint === undefined ||
|
|
33
33
|
typeof rc.s3.endpoint === 'string') && (!('fastlyBackendName' in rc.s3) ||
|
|
34
34
|
rc.s3.fastlyBackendName === undefined ||
|
|
35
|
-
typeof rc.s3.fastlyBackendName === 'string'))
|
|
35
|
+
typeof rc.s3.fastlyBackendName === 'string') && (!('secretStoreLinkName' in rc.s3) ||
|
|
36
|
+
rc.s3.secretStoreLinkName === undefined ||
|
|
37
|
+
(typeof rc.s3.secretStoreLinkName === 'string' && rc.s3.secretStoreLinkName !== ''))) {
|
|
36
38
|
return true;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -5,6 +5,7 @@ import type { KVStore } from 'fastly:kv-store';
|
|
|
5
5
|
import type { Logger } from 'fastly:logger';
|
|
6
6
|
import type { SecretStore } from 'fastly:secret-store';
|
|
7
7
|
import type { Hono } from 'hono';
|
|
8
|
+
import type { PublisherServerMiddleware } from './index.js';
|
|
8
9
|
export type ExtensionBindings = Record<string, string>;
|
|
9
10
|
type ResourceTypes = {
|
|
10
11
|
Acl: Acl;
|
|
@@ -24,7 +25,8 @@ export type ExtensionEnv<B extends ExtensionBindings> = {
|
|
|
24
25
|
};
|
|
25
26
|
export declare const EXTENSION_PHASES: readonly ['middleware', 'beforeFiles', 'afterFiles'];
|
|
26
27
|
export type ExtensionPhase = typeof EXTENSION_PHASES[number];
|
|
27
|
-
export type
|
|
28
|
+
export type ExtensionHelpers = Pick<PublisherServerMiddleware, 'publisherServer' | 'serveStatic' | 'staticResponse' | 'serveFallback'>;
|
|
29
|
+
export type ExtensionPhaseFunction<B extends ExtensionBindings = ExtensionBindings, O = any> = (app: Hono<ExtensionEnv<B>, any, any>, options: O | undefined, helpers: ExtensionHelpers) => void;
|
|
28
30
|
export type ExtensionPhases<B extends ExtensionBindings = ExtensionBindings, O = any> = {
|
|
29
31
|
[P in ExtensionPhase]?: ExtensionPhaseFunction<B, O>;
|
|
30
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/hono/extensions.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../../src/hono/extensions.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CA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,CAAC;AACpH,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;AAwBzL,wBAAgB,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,iBAAiB,CAgDtH"}
|
|
@@ -26,16 +26,21 @@ const isPlainObject = (value) => typeof value === 'object' && value != null && !
|
|
|
26
26
|
// one name with two different resources; the message names the file. Call it at
|
|
27
27
|
// the top level of the app, so that an error stops the build.
|
|
28
28
|
export function mergeBindings(appBindings, entries) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Maps, so that a binding name such as 'toString' is not found on
|
|
30
|
+
// Object.prototype.
|
|
31
|
+
const merged = new Map();
|
|
32
|
+
const sourceOf = new Map();
|
|
31
33
|
const add = (bindings, source) => {
|
|
32
34
|
for (const [name, resource] of Object.entries(bindings)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const existing = merged.get(name);
|
|
36
|
+
if (existing != null && existing !== resource) {
|
|
37
|
+
throw new Error(`The binding '${name}' is '${existing}' in ${sourceOf.get(name)}, ` +
|
|
35
38
|
`but '${resource}' in ${source}. Use the same resource, or another name.`);
|
|
36
39
|
}
|
|
37
|
-
merged
|
|
38
|
-
sourceOf
|
|
40
|
+
merged.set(name, resource);
|
|
41
|
+
if (!sourceOf.has(name)) {
|
|
42
|
+
sourceOf.set(name, source);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
add(appBindings ?? {}, 'templateOptions.hono.bindings');
|
|
@@ -61,5 +66,5 @@ export function mergeBindings(appBindings, entries) {
|
|
|
61
66
|
}
|
|
62
67
|
add(module.bindings ?? {}, source);
|
|
63
68
|
}
|
|
64
|
-
return merged;
|
|
69
|
+
return Object.fromEntries(merged);
|
|
65
70
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context, MiddlewareHandler, NotFoundHandler } from 'hono';
|
|
2
2
|
import { PublisherServer, type StaticPublishRc } from '../server/index.js';
|
|
3
3
|
import { type ServeStaticPathOptions } from './path.js';
|
|
4
|
-
export { type BindingResource, type DefineExtensionOptions, EXTENSION_PHASES, type Extension, type ExtensionBindings, type ExtensionEntry, type ExtensionEnv, type ExtensionPhase, type ExtensionPhaseFunction, type ExtensionPhases, defineExtension, mergeBindings, } from './extensions.js';
|
|
4
|
+
export { type BindingResource, type DefineExtensionOptions, EXTENSION_PHASES, type Extension, type ExtensionBindings, type ExtensionEntry, type ExtensionEnv, type ExtensionHelpers, type ExtensionPhase, type ExtensionPhaseFunction, type ExtensionPhases, defineExtension, mergeBindings, } from './extensions.js';
|
|
5
5
|
export type StaticPublisherVariables = {
|
|
6
6
|
staticPublisher: {
|
|
7
7
|
publisherServer: PublisherServer;
|
|
@@ -10,18 +10,23 @@ export type StaticPublisherVariables = {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
export type CollectionNameOption = string | null | ((c: Context) => string | null | undefined);
|
|
13
|
+
export type OnMissingOption = 'not-found' | 'default';
|
|
13
14
|
export type ServeStaticOptions = ServeStaticPathOptions<Context> & {
|
|
14
15
|
collectionName?: CollectionNameOption;
|
|
16
|
+
onMissing?: OnMissingOption;
|
|
15
17
|
};
|
|
16
18
|
export type ServeFallbackOptions = {
|
|
17
19
|
collectionName?: CollectionNameOption;
|
|
20
|
+
onMissing?: OnMissingOption;
|
|
18
21
|
};
|
|
19
22
|
export type PublisherServerMiddlewareDefaults = {
|
|
20
23
|
collectionName?: CollectionNameOption;
|
|
24
|
+
onMissing?: OnMissingOption;
|
|
21
25
|
};
|
|
22
26
|
export type PublisherServerMiddleware = {
|
|
23
27
|
publisherServer: PublisherServer;
|
|
24
28
|
serveStatic: (options?: ServeStaticOptions) => MiddlewareHandler;
|
|
29
|
+
staticResponse: (c: Context, options?: ServeStaticOptions) => Promise<Response | null>;
|
|
25
30
|
serveFallback: (options?: ServeFallbackOptions) => NotFoundHandler;
|
|
26
31
|
selectCollection: () => MiddlewareHandler;
|
|
27
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hono/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,KAAK,sBAAsB,EAA8B,MAAM,WAAW,CAAC;AAEpF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,eAAe,EACf,aAAa,GACd,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,wBAAwB,GAAG;IACrC,eAAe,EAAE;QACf,eAAe,EAAE,eAAe,CAAC;QAGjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAMF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hono/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,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e,CAAC;IAIjC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,iBAAiB,CAAC;IAKjE,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAIvF,aAAa,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,eAAe,CAAC;IAKnE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;CAC3C,CAAC;AAsBF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,GAAE,iCAAsC,GAAG,yBAAyB,CA2DxI;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,GAAE,iCAAsC,GAAG,yBAAyB,CAEpI"}
|
|
@@ -21,20 +21,27 @@ function resolveCollectionName(c, option, selection) {
|
|
|
21
21
|
return selection != null ? selection.collectionName : undefined;
|
|
22
22
|
}
|
|
23
23
|
export function fromPublisherServer(server, defaults = {}) {
|
|
24
|
-
const
|
|
24
|
+
const staticResponse = async (c, callOptions = {}) => {
|
|
25
25
|
const options = { ...defaults, ...callOptions };
|
|
26
|
+
const selection = getSelection(c, server);
|
|
27
|
+
// For a path source, the path without its prefix. A path option
|
|
28
|
+
// replaces the request path (see resolveServeStaticPathname()).
|
|
29
|
+
const requestPath = selection?.pathname ?? c.req.path;
|
|
30
|
+
const pathname = resolveServeStaticPathname(requestPath, c, options);
|
|
31
|
+
if (pathname == null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return server.serveRequest(c.req.raw, {
|
|
35
|
+
collectionName: resolveCollectionName(c, options.collectionName, selection),
|
|
36
|
+
pathname,
|
|
37
|
+
fallback: false,
|
|
38
|
+
healthCheck: false,
|
|
39
|
+
onMissing: options.onMissing,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const serveStatic = (callOptions = {}) => {
|
|
26
43
|
return async (c, next) => {
|
|
27
|
-
const
|
|
28
|
-
// For a path source, the path without its prefix. A path option
|
|
29
|
-
// replaces the request path (see resolveServeStaticPathname()).
|
|
30
|
-
const requestPath = selection?.pathname ?? c.req.path;
|
|
31
|
-
const pathname = resolveServeStaticPathname(requestPath, c, options);
|
|
32
|
-
const response = pathname != null ? await server.serveRequest(c.req.raw, {
|
|
33
|
-
collectionName: resolveCollectionName(c, options.collectionName, selection),
|
|
34
|
-
pathname,
|
|
35
|
-
fallback: false,
|
|
36
|
-
healthCheck: false,
|
|
37
|
-
}) : null;
|
|
44
|
+
const response = await staticResponse(c, callOptions);
|
|
38
45
|
if (response == null) {
|
|
39
46
|
await next();
|
|
40
47
|
return;
|
|
@@ -47,6 +54,7 @@ export function fromPublisherServer(server, defaults = {}) {
|
|
|
47
54
|
return async (c) => {
|
|
48
55
|
const response = await server.serveFallback(c.req.raw, {
|
|
49
56
|
collectionName: resolveCollectionName(c, options.collectionName, getSelection(c, server)),
|
|
57
|
+
onMissing: options.onMissing,
|
|
50
58
|
});
|
|
51
59
|
return response ?? c.text('404 Not Found', 404);
|
|
52
60
|
};
|
|
@@ -65,7 +73,7 @@ export function fromPublisherServer(server, defaults = {}) {
|
|
|
65
73
|
await next();
|
|
66
74
|
};
|
|
67
75
|
};
|
|
68
|
-
return { publisherServer: server, serveStatic, serveFallback, selectCollection };
|
|
76
|
+
return { publisherServer: server, serveStatic, staticResponse, serveFallback, selectCollection };
|
|
69
77
|
}
|
|
70
78
|
export function fromStaticPublishRc(rc, defaults = {}) {
|
|
71
79
|
return fromPublisherServer(PublisherServer.fromStaticPublishRc(rc), defaults);
|
|
@@ -2,10 +2,12 @@ export declare const COLLECTION_PLACEHOLDER = "{collection}";
|
|
|
2
2
|
export type CollectionSelectionHostSource = {
|
|
3
3
|
type: 'host';
|
|
4
4
|
pattern: string;
|
|
5
|
+
value?: string;
|
|
5
6
|
};
|
|
6
7
|
export type CollectionSelectionPathSource = {
|
|
7
8
|
type: 'path';
|
|
8
9
|
prefix: string;
|
|
10
|
+
value?: string;
|
|
9
11
|
sticky?: 'cookie';
|
|
10
12
|
};
|
|
11
13
|
export type CollectionSelectionQuerySource = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"collection-selection.d.ts","sourceRoot":"","sources":["../../../../src/models/config/collection-selection.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IAIb,OAAO,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IAIb,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,OAAO,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,QAAQ,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,QAAQ,CAAC;IAEf,IA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MD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG;IAAE,IAAI,EAAE,6BAA6B,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,CAqBxI"}
|
|
@@ -67,6 +67,20 @@ export function validateCollectionSelection(config) {
|
|
|
67
67
|
return ['collectionSelection must be an object.'];
|
|
68
68
|
}
|
|
69
69
|
const { sources, allow, onMissing, noindex } = config;
|
|
70
|
+
const allowIsValid = allow === undefined ||
|
|
71
|
+
(Array.isArray(allow) && allow.every(x => typeof x === 'string' && ALLOW_PATTERN.test(x)));
|
|
72
|
+
// The value of a host or path source: a collection name that allow (if set) matches.
|
|
73
|
+
const checkValue = (name, value, patternField, pattern) => {
|
|
74
|
+
if (typeof value !== 'string' || !isValidCollectionName(value)) {
|
|
75
|
+
errors.push(`${name}.value must be a valid collection name. ${COLLECTION_NAME_RULE}`);
|
|
76
|
+
}
|
|
77
|
+
else if (allowIsValid && !isCollectionNameAllowed(value, allow)) {
|
|
78
|
+
errors.push(`${name}.value '${value}' is not in collectionSelection.allow.`);
|
|
79
|
+
}
|
|
80
|
+
if (typeof pattern === 'string' && pattern.includes(COLLECTION_PLACEHOLDER)) {
|
|
81
|
+
errors.push(`${name}: use ${COLLECTION_PLACEHOLDER} in ${patternField}, or value, not both.`);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
70
84
|
if (!Array.isArray(sources)) {
|
|
71
85
|
errors.push('collectionSelection.sources must be an array.');
|
|
72
86
|
}
|
|
@@ -86,9 +100,17 @@ export function validateCollectionSelection(config) {
|
|
|
86
100
|
}
|
|
87
101
|
switch (s.type) {
|
|
88
102
|
case 'host': {
|
|
103
|
+
if (s.value !== undefined) {
|
|
104
|
+
checkValue(name, s.value, 'pattern', s.pattern);
|
|
105
|
+
if (typeof s.pattern !== 'string' ||
|
|
106
|
+
(!s.pattern.includes(COLLECTION_PLACEHOLDER) && !/^[a-z0-9-]+(\.[a-z0-9-]+)*$/i.test(s.pattern))) {
|
|
107
|
+
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.'.`);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
89
111
|
const parts = typeof s.pattern === 'string' ? splitPattern(s.pattern) : null;
|
|
90
112
|
if (parts == null) {
|
|
91
|
-
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
113
|
+
errors.push(`${name}.pattern must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a hostname with value.`);
|
|
92
114
|
}
|
|
93
115
|
else if (!/^[a-z0-9.-]*$/i.test(parts.before + parts.after)) {
|
|
94
116
|
errors.push(`${name}.pattern must be a hostname: use only a-z, 0-9, '-', and '.' around ${COLLECTION_PLACEHOLDER}.`);
|
|
@@ -99,14 +121,19 @@ export function validateCollectionSelection(config) {
|
|
|
99
121
|
break;
|
|
100
122
|
}
|
|
101
123
|
case 'path': {
|
|
102
|
-
|
|
124
|
+
if (s.value !== undefined) {
|
|
125
|
+
checkValue(name, s.value, 'prefix', s.prefix);
|
|
126
|
+
}
|
|
127
|
+
const parts = typeof s.prefix !== 'string' ? null :
|
|
128
|
+
s.value !== undefined ? { before: s.prefix, after: '' } :
|
|
129
|
+
splitPattern(s.prefix);
|
|
103
130
|
if (parts == null) {
|
|
104
|
-
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}.`);
|
|
131
|
+
errors.push(`${name}.prefix must be a string with exactly one ${COLLECTION_PLACEHOLDER}, or a prefix with value.`);
|
|
105
132
|
}
|
|
106
133
|
else if (!parts.before.startsWith('/')) {
|
|
107
134
|
errors.push(`${name}.prefix must start with '/'.`);
|
|
108
135
|
}
|
|
109
|
-
else if (parts.after.endsWith('/')) {
|
|
136
|
+
else if ((s.value !== undefined ? parts.before : parts.after).endsWith('/')) {
|
|
110
137
|
errors.push(`${name}.prefix must not end with '/'.`);
|
|
111
138
|
}
|
|
112
139
|
else if (/[?#]/.test(parts.before + parts.after)) {
|
|
@@ -139,6 +166,9 @@ export function validateCollectionSelection(config) {
|
|
|
139
166
|
}
|
|
140
167
|
break;
|
|
141
168
|
}
|
|
169
|
+
if (s.value !== undefined && s.type !== 'host' && s.type !== 'path') {
|
|
170
|
+
errors.push(`${name}.value is only for the 'host' and 'path' sources.`);
|
|
171
|
+
}
|
|
142
172
|
if (s.sticky !== undefined) {
|
|
143
173
|
if (s.type !== 'path' && s.type !== 'query') {
|
|
144
174
|
errors.push(`${name}.sticky is only for the 'path' and 'query' sources.`);
|
|
@@ -158,10 +188,8 @@ export function validateCollectionSelection(config) {
|
|
|
158
188
|
errors.push(`sticky: 'cookie' needs a 'cookie' source in collectionSelection.sources, for the settings of the cookie.`);
|
|
159
189
|
}
|
|
160
190
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
164
|
-
}
|
|
191
|
+
if (!allowIsValid) {
|
|
192
|
+
errors.push(`collectionSelection.allow must be an array of patterns. Use a-z, 0-9, '-', and '*'.`);
|
|
165
193
|
}
|
|
166
194
|
if (onMissing !== undefined && onMissing !== 'not-found' && onMissing !== 'default') {
|
|
167
195
|
errors.push(`collectionSelection.onMissing must be 'not-found' or 'default'.`);
|
|
@@ -187,6 +215,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
187
215
|
for (const source of config.sources) {
|
|
188
216
|
switch (source.type) {
|
|
189
217
|
case 'host': {
|
|
218
|
+
if (source.value != null) {
|
|
219
|
+
if (source.value === collectionName) {
|
|
220
|
+
return `${base.protocol}//${source.pattern.toLowerCase()}/`;
|
|
221
|
+
}
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
190
224
|
const maxLength = maxCollectionNameLengthForHost(source.pattern);
|
|
191
225
|
if (collectionName.length > maxLength) {
|
|
192
226
|
throw new Error(`'${collectionName}' is too long for the host pattern '${source.pattern}': a host label has at most ${MAX_LABEL_LENGTH} characters, so the name can have at most ${maxLength}.`);
|
|
@@ -194,6 +228,12 @@ export function previewUrl(collectionName, baseUrl, config) {
|
|
|
194
228
|
return `${base.protocol}//${source.pattern.replace(COLLECTION_PLACEHOLDER, collectionName).toLowerCase()}/`;
|
|
195
229
|
}
|
|
196
230
|
case 'path':
|
|
231
|
+
if (source.value != null) {
|
|
232
|
+
if (source.value === collectionName) {
|
|
233
|
+
return `${base.origin}${source.prefix}/`;
|
|
234
|
+
}
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
197
237
|
return `${base.origin}${source.prefix.replace(COLLECTION_PLACEHOLDER, collectionName)}/`;
|
|
198
238
|
case 'query': {
|
|
199
239
|
const url = new URL('/', base);
|
|
@@ -4,6 +4,7 @@ export type S3StorageConfig = {
|
|
|
4
4
|
bucket: string;
|
|
5
5
|
endpoint?: string;
|
|
6
6
|
fastlyBackendName?: string;
|
|
7
|
+
secretStoreLinkName?: string;
|
|
7
8
|
};
|
|
8
9
|
export declare function getS3StorageConfigFromRc(rc: StaticPublishS3Storage): S3StorageConfig;
|
|
9
10
|
//# sourceMappingURL=s3-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,sBAAsB,GAAG,eAAe,CAQpF"}
|