@fastly/compute-js-static-publish 8.0.0 → 8.1.0-beta.1
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/DOCUMENTATION.md +1984 -0
- package/README.md +11 -4
- package/README.short.md +11 -4
- package/build/cli/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/clean.js +12 -7
- package/build/cli/cli/commands/manage/collections/delete.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/delete.js +29 -13
- package/build/cli/cli/commands/manage/collections/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/index.js +6 -1
- package/build/cli/cli/commands/manage/collections/list.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/list.js +47 -7
- package/build/cli/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/promote.js +67 -20
- package/build/cli/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.js +10 -11
- package/build/cli/cli/commands/manage/deploy.d.ts +2 -0
- package/build/cli/cli/commands/manage/deploy.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/deploy.js +194 -0
- package/build/cli/cli/commands/manage/dev.d.ts +2 -0
- package/build/cli/cli/commands/manage/dev.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/dev.js +77 -0
- package/build/cli/cli/commands/manage/eject.d.ts +2 -0
- package/build/cli/cli/commands/manage/eject.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/eject.js +155 -0
- package/build/cli/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/index.js +37 -1
- package/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +85 -35
- package/build/cli/cli/commands/manage/status.d.ts +2 -0
- package/build/cli/cli/commands/manage/status.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/status.js +162 -0
- package/build/cli/cli/commands/manage/template/index.d.ts +2 -0
- package/build/cli/cli/commands/manage/template/index.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/template/index.js +42 -0
- package/build/cli/cli/commands/manage/template/init.d.ts +13 -0
- package/build/cli/cli/commands/manage/template/init.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/template/init.js +172 -0
- package/build/cli/cli/commands/manage/upgrade.d.ts +2 -0
- package/build/cli/cli/commands/manage/upgrade.d.ts.map +1 -0
- package/build/cli/cli/commands/manage/upgrade.js +59 -0
- package/build/cli/cli/commands/run-dev-watch.d.ts +8 -0
- package/build/cli/cli/commands/run-dev-watch.d.ts.map +1 -0
- package/build/cli/cli/commands/run-dev-watch.js +41 -0
- package/build/cli/cli/commands/run-template-hook.d.ts +2 -0
- package/build/cli/cli/commands/run-template-hook.d.ts.map +1 -0
- package/build/cli/cli/commands/run-template-hook.js +28 -0
- package/build/cli/cli/commands/scaffold/app-template.d.ts +17 -0
- package/build/cli/cli/commands/scaffold/app-template.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/app-template.js +54 -0
- package/build/cli/cli/commands/scaffold/fastly-toml-sections.d.ts +5 -0
- package/build/cli/cli/commands/scaffold/fastly-toml-sections.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/fastly-toml-sections.js +154 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +47 -0
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/generate-app.js +164 -0
- package/build/cli/cli/commands/scaffold/index.d.ts +6 -0
- package/build/cli/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/index.js +239 -300
- package/build/cli/cli/commands/scaffold/render.d.ts +7 -0
- package/build/cli/cli/commands/scaffold/render.d.ts.map +1 -0
- package/build/cli/cli/commands/scaffold/render.js +72 -0
- package/build/cli/cli/hono/build.d.ts +43 -0
- package/build/cli/cli/hono/build.d.ts.map +1 -0
- package/build/cli/cli/hono/build.js +297 -0
- package/build/cli/cli/index.js +98 -5
- package/build/cli/cli/managed/app.d.ts +21 -0
- package/build/cli/cli/managed/app.d.ts.map +1 -0
- package/build/cli/cli/managed/app.js +162 -0
- package/build/cli/cli/managed/command-helpers.d.ts +6 -0
- package/build/cli/cli/managed/command-helpers.d.ts.map +1 -0
- package/build/cli/cli/managed/command-helpers.js +81 -0
- package/build/cli/cli/managed/eject.d.ts +6 -0
- package/build/cli/cli/managed/eject.d.ts.map +1 -0
- package/build/cli/cli/managed/eject.js +68 -0
- package/build/cli/cli/managed/fastly-service.d.ts +8 -0
- package/build/cli/cli/managed/fastly-service.d.ts.map +1 -0
- package/build/cli/cli/managed/fastly-service.js +21 -0
- package/build/cli/cli/managed/fingerprint.d.ts +13 -0
- package/build/cli/cli/managed/fingerprint.d.ts.map +1 -0
- package/build/cli/cli/managed/fingerprint.js +60 -0
- package/build/cli/cli/managed/lockfile.d.ts +31 -0
- package/build/cli/cli/managed/lockfile.d.ts.map +1 -0
- package/build/cli/cli/managed/lockfile.js +62 -0
- package/build/cli/cli/managed/project-edit.d.ts +3 -0
- package/build/cli/cli/managed/project-edit.d.ts.map +1 -0
- package/build/cli/cli/managed/project-edit.js +35 -0
- package/build/cli/cli/managed/project-file.d.ts +16 -0
- package/build/cli/cli/managed/project-file.d.ts.map +1 -0
- package/build/cli/cli/managed/project-file.js +119 -0
- package/build/cli/cli/managed/template-init.d.ts +12 -0
- package/build/cli/cli/managed/template-init.d.ts.map +1 -0
- package/build/cli/cli/managed/template-init.js +120 -0
- package/build/cli/cli/managed/version-check.d.ts +25 -0
- package/build/cli/cli/managed/version-check.d.ts.map +1 -0
- package/build/cli/cli/managed/version-check.js +84 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts +1 -0
- package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-local-provider.js +6 -3
- package/build/cli/cli/storage/kv-store-provider.d.ts +2 -1
- package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-provider.js +17 -6
- package/build/cli/cli/storage/s3-storage-provider.d.ts +1 -0
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/s3-storage-provider.js +8 -2
- package/build/cli/cli/storage/storage-provider.d.ts +4 -0
- package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/storage-provider.js +32 -0
- package/build/cli/cli/util/api-token.d.ts +2 -1
- package/build/cli/cli/util/api-token.d.ts.map +1 -1
- package/build/cli/cli/util/api-token.js +38 -3
- package/build/cli/cli/util/collection-name.d.ts +3 -0
- package/build/cli/cli/util/collection-name.d.ts.map +1 -0
- package/build/cli/cli/util/collection-name.js +24 -0
- package/build/cli/cli/util/collection-selection-flags.d.ts +13 -0
- package/build/cli/cli/util/collection-selection-flags.d.ts.map +1 -0
- package/build/cli/cli/util/collection-selection-flags.js +131 -0
- package/build/cli/cli/util/config.d.ts +13 -0
- package/build/cli/cli/util/config.d.ts.map +1 -1
- package/build/cli/cli/util/config.js +172 -38
- package/build/cli/cli/util/data.d.ts.map +1 -1
- package/build/cli/cli/util/global-options.d.ts +13 -0
- package/build/cli/cli/util/global-options.d.ts.map +1 -0
- package/build/cli/cli/util/global-options.js +53 -0
- package/build/cli/cli/util/kv-store-items.d.ts +1 -0
- package/build/cli/cli/util/kv-store-items.d.ts.map +1 -1
- package/build/cli/cli/util/kv-store-items.js +16 -40
- package/build/cli/cli/util/kv-store-local-server.d.ts +1 -1
- package/build/cli/cli/util/kv-store-local-server.d.ts.map +1 -1
- package/build/cli/cli/util/kv-store-local-server.js +4 -2
- package/build/cli/cli/util/output.d.ts +31 -0
- package/build/cli/cli/util/output.d.ts.map +1 -0
- package/build/cli/cli/util/output.js +139 -0
- package/build/cli/cli/util/package.d.ts +3 -0
- package/build/cli/cli/util/package.d.ts.map +1 -1
- package/build/cli/cli/util/package.js +12 -0
- package/build/cli/cli/util/progress.d.ts +11 -0
- package/build/cli/cli/util/progress.d.ts.map +1 -0
- package/build/cli/cli/util/progress.js +32 -0
- package/build/cli/cli/util/purge.d.ts +15 -3
- package/build/cli/cli/util/purge.d.ts.map +1 -1
- package/build/cli/cli/util/purge.js +23 -10
- package/build/cli/cli/util/resources.d.ts +2 -0
- package/build/cli/cli/util/resources.d.ts.map +1 -0
- package/build/cli/cli/util/resources.js +8 -0
- package/build/cli/cli/util/service-id.d.ts +1 -0
- package/build/cli/cli/util/service-id.d.ts.map +1 -1
- package/build/cli/cli/util/service-id.js +5 -1
- package/build/cli/cli/util/variants.d.ts.map +1 -1
- package/build/cli/models/assets/index.d.ts +6 -0
- package/build/cli/models/assets/index.d.ts.map +1 -1
- package/build/cli/models/assets/index.js +24 -0
- package/build/cli/models/collections/index.d.ts +3 -0
- package/build/cli/models/collections/index.d.ts.map +1 -0
- package/build/cli/models/collections/index.js +15 -0
- package/build/cli/models/compression/index.d.ts +1 -1
- package/build/cli/models/compression/index.d.ts.map +1 -1
- package/build/cli/models/config/collection-selection.d.ts +55 -0
- package/build/cli/models/config/collection-selection.d.ts.map +1 -0
- package/build/cli/models/config/collection-selection.js +238 -0
- package/build/cli/models/config/item-patterns.d.ts +4 -0
- package/build/cli/models/config/item-patterns.d.ts.map +1 -0
- package/build/cli/models/config/item-patterns.js +43 -0
- package/build/cli/models/config/publish-content-config.d.ts +6 -1
- package/build/cli/models/config/publish-content-config.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-project.d.ts +23 -0
- package/build/cli/models/config/static-publish-project.d.ts.map +1 -0
- package/build/cli/models/config/static-publish-project.js +11 -0
- package/build/cli/models/config/static-publish-rc.d.ts +25 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.js +31 -0
- package/build/cli/models/config/template-settings.d.ts +10 -0
- package/build/cli/models/config/template-settings.d.ts.map +1 -0
- package/build/cli/models/config/template-settings.js +72 -0
- package/build/cli/models/server/index.d.ts.map +1 -1
- package/build/cli/models/server/index.js +6 -2
- package/build/server/hono/extensions.d.ts +48 -0
- package/build/server/hono/extensions.d.ts.map +1 -0
- package/build/server/hono/extensions.js +65 -0
- package/build/server/hono/index.d.ts +30 -0
- package/build/server/hono/index.d.ts.map +1 -0
- package/build/server/hono/index.js +72 -0
- package/build/server/hono/path.d.ts +7 -0
- package/build/server/hono/path.d.ts.map +1 -0
- package/build/server/hono/path.js +32 -0
- package/build/server/models/assets/index.d.ts +6 -0
- package/build/server/models/assets/index.d.ts.map +1 -1
- package/build/server/models/assets/index.js +24 -0
- package/build/server/models/collections/index.d.ts +3 -0
- package/build/server/models/collections/index.d.ts.map +1 -0
- package/build/server/models/collections/index.js +15 -0
- package/build/server/models/compression/index.d.ts +1 -1
- package/build/server/models/compression/index.d.ts.map +1 -1
- package/build/server/models/config/collection-selection.d.ts +55 -0
- package/build/server/models/config/collection-selection.d.ts.map +1 -0
- package/build/server/models/config/collection-selection.js +238 -0
- package/build/server/models/config/item-patterns.d.ts +4 -0
- package/build/server/models/config/item-patterns.d.ts.map +1 -0
- package/build/server/models/config/item-patterns.js +43 -0
- package/build/server/models/config/publish-content-config.d.ts +6 -1
- package/build/server/models/config/publish-content-config.d.ts.map +1 -1
- package/build/server/models/config/static-publish-project.d.ts +23 -0
- package/build/server/models/config/static-publish-project.d.ts.map +1 -0
- package/build/server/models/config/static-publish-project.js +11 -0
- package/build/server/models/config/static-publish-rc.d.ts +25 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/models/config/static-publish-rc.js +31 -0
- package/build/server/models/server/index.d.ts.map +1 -1
- package/build/server/models/server/index.js +6 -2
- package/build/server/server/collection-selection/index.d.ts +11 -0
- package/build/server/server/collection-selection/index.d.ts.map +1 -0
- package/build/server/server/collection-selection/index.js +192 -0
- package/build/server/server/collection-selector/from-cookie.d.ts.map +1 -1
- package/build/server/server/collection-selector/from-cookie.js +6 -8
- package/build/server/server/collection-selector/from-request.d.ts.map +1 -1
- package/build/server/server/index.d.ts +4 -1
- package/build/server/server/index.d.ts.map +1 -1
- package/build/server/server/index.js +3 -1
- package/build/server/server/publisher-server/accept-html.d.ts +2 -0
- package/build/server/server/publisher-server/accept-html.d.ts.map +1 -0
- package/build/server/server/publisher-server/accept-html.js +50 -0
- package/build/server/server/publisher-server/index.d.ts +59 -6
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +370 -131
- package/build/server/server/publisher-server/response-cache.d.ts +3 -0
- package/build/server/server/publisher-server/response-cache.d.ts.map +1 -1
- package/build/server/server/publisher-server/response-cache.js +24 -1
- package/build/server/server/storage/kv-store-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/storage-provider.d.ts.map +1 -1
- package/build/server/server/util/body-length.d.ts.map +1 -1
- package/build/server/server/util/server-timing.d.ts.map +1 -1
- package/package.json +23 -4
- package/resources/app/fastly.toml.njk +58 -0
- package/resources/app/gitignore.njk +9 -0
- package/resources/app/publish-content.config.from-project.js.njk +9 -0
- package/resources/app/publish-content.config.js.njk +35 -0
- package/resources/app/static-publish.project.js.njk +83 -0
- package/resources/app/static-publish.rc.js.njk +43 -0
- package/resources/template-init/hono/_example.ts +22 -0
- package/resources/template-init/hono/tsconfig.json +17 -0
- package/resources/templates/hono/package-lock.json +4123 -0
- package/resources/templates/hono/package.json +15 -0
- package/resources/templates/hono/scripts/template_postinstall.js +10 -0
- package/resources/templates/hono/scripts/template_prebuild.js +8 -0
- package/resources/templates/hono/scripts/template_watch.js +15 -0
- package/resources/templates/hono/src/hono-extensions.generated.d.ts +5 -0
- package/resources/templates/hono/src/index.ts +53 -0
- package/resources/templates/hono/tsconfig.json +17 -0
- package/resources/templates/plain/package-lock.json +4088 -0
- package/resources/templates/plain/package.json +10 -0
- package/resources/templates/plain/src/index.js +34 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
// Chooses the collection for a request from a collectionSelection config.
|
|
6
|
+
// This module does not import fastly:*, so that the unit tests can load it.
|
|
7
|
+
import { COLLECTION_NAME_RULE, isValidCollectionName } from '../../models/collections/index.js';
|
|
8
|
+
import { COOKIE_SOURCE_DEFAULTS, isCollectionNameAllowed, splitPattern, validateCollectionSelection, } from '../../models/config/collection-selection.js';
|
|
9
|
+
import { getCookieValue } from '../util/cookies.js';
|
|
10
|
+
const NAME_GROUP = '([a-z0-9-]{1,63})';
|
|
11
|
+
function escapeRegExp(value) {
|
|
12
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
13
|
+
}
|
|
14
|
+
const compiledConfigs = new WeakMap();
|
|
15
|
+
function compile(config) {
|
|
16
|
+
let compiled = compiledConfigs.get(config);
|
|
17
|
+
if (compiled != null) {
|
|
18
|
+
return compiled;
|
|
19
|
+
}
|
|
20
|
+
const errors = validateCollectionSelection(config);
|
|
21
|
+
if (errors.length > 0) {
|
|
22
|
+
throw new TypeError(`Invalid collectionSelection:\n${errors.join('\n')}`);
|
|
23
|
+
}
|
|
24
|
+
const cookieSource = config.sources.find(x => x.type === 'cookie');
|
|
25
|
+
const cookie = cookieSource != null ? {
|
|
26
|
+
type: 'cookie',
|
|
27
|
+
cookieName: cookieSource.cookieName ?? COOKIE_SOURCE_DEFAULTS.cookieName,
|
|
28
|
+
activatePath: cookieSource.activatePath ?? COOKIE_SOURCE_DEFAULTS.activatePath,
|
|
29
|
+
resetPath: cookieSource.resetPath ?? COOKIE_SOURCE_DEFAULTS.resetPath,
|
|
30
|
+
maxAge: cookieSource.maxAge,
|
|
31
|
+
} : null;
|
|
32
|
+
const allowed = (value) => value != null && isCollectionNameAllowed(value, config.allow);
|
|
33
|
+
const matchers = config.sources.map((source) => {
|
|
34
|
+
switch (source.type) {
|
|
35
|
+
case 'host': {
|
|
36
|
+
const parts = splitPattern(source.pattern);
|
|
37
|
+
const re = new RegExp(`^${escapeRegExp(parts.before.toLowerCase())}${NAME_GROUP}${escapeRegExp(parts.after.toLowerCase())}$`);
|
|
38
|
+
return (url) => {
|
|
39
|
+
const name = re.exec(url.hostname.toLowerCase())?.[1];
|
|
40
|
+
return allowed(name) ? { collectionName: name } : null;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
case 'path': {
|
|
44
|
+
const parts = splitPattern(source.prefix);
|
|
45
|
+
const re = new RegExp(`^${escapeRegExp(parts.before)}${NAME_GROUP}${escapeRegExp(parts.after)}(/.*)?$`);
|
|
46
|
+
return (url) => {
|
|
47
|
+
const match = re.exec(url.pathname);
|
|
48
|
+
if (match == null || !allowed(match[1])) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
let pathname;
|
|
52
|
+
try {
|
|
53
|
+
pathname = decodeURI(match[2] ?? '/');
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return { collectionName: match[1], pathname };
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
case 'query':
|
|
62
|
+
return (url) => {
|
|
63
|
+
const name = url.searchParams.get(source.param);
|
|
64
|
+
return allowed(name) ? { collectionName: name } : null;
|
|
65
|
+
};
|
|
66
|
+
case 'cookie':
|
|
67
|
+
return (_url, request) => {
|
|
68
|
+
const name = getCookieValue(request, cookie.cookieName);
|
|
69
|
+
return allowed(name) ? { collectionName: name } : null;
|
|
70
|
+
};
|
|
71
|
+
case 'header':
|
|
72
|
+
return (_url, request) => {
|
|
73
|
+
const name = request.headers.get(source.name)?.trim();
|
|
74
|
+
return allowed(name) ? { collectionName: name } : null;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
compiled = { config, cookie, matchers };
|
|
79
|
+
compiledConfigs.set(config, compiled);
|
|
80
|
+
return compiled;
|
|
81
|
+
}
|
|
82
|
+
// A Location value that stays on this site: a path that starts with exactly one
|
|
83
|
+
// '/'. A value such as '//example.com' or '/\example.com' is a URL of another
|
|
84
|
+
// site for a browser, so it becomes '/'. So does a value with control characters.
|
|
85
|
+
export function sameSiteLocation(value) {
|
|
86
|
+
if (!value.startsWith('/') || value[1] === '/' || value[1] === '\\' || /[\u0000-\u001f\u007f]/.test(value)) {
|
|
87
|
+
return '/';
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
function cookieAttributes(url, maxAge) {
|
|
92
|
+
const segments = ['Path=/'];
|
|
93
|
+
if (maxAge != null) {
|
|
94
|
+
segments.push(`Max-Age=${maxAge}`);
|
|
95
|
+
}
|
|
96
|
+
segments.push('HttpOnly');
|
|
97
|
+
if (url.protocol === 'https:') {
|
|
98
|
+
segments.push('Secure');
|
|
99
|
+
}
|
|
100
|
+
segments.push('SameSite=Lax');
|
|
101
|
+
return segments;
|
|
102
|
+
}
|
|
103
|
+
function redirect(location, setCookie) {
|
|
104
|
+
const headers = new Headers();
|
|
105
|
+
headers.append('Set-Cookie', setCookie);
|
|
106
|
+
headers.set('Location', sameSiteLocation(location));
|
|
107
|
+
// A redirect that sets a cookie must not be stored by a shared cache.
|
|
108
|
+
headers.set('Cache-Control', 'no-store');
|
|
109
|
+
return new Response(null, { status: 308, headers });
|
|
110
|
+
}
|
|
111
|
+
function setCookieValue(cookie, url, collectionName) {
|
|
112
|
+
return [`${cookie.cookieName}=${collectionName}`, ...cookieAttributes(url, cookie.maxAge)].join('; ');
|
|
113
|
+
}
|
|
114
|
+
function clearCookieValue(cookie, url) {
|
|
115
|
+
return [`${cookie.cookieName}=`, ...cookieAttributes(url, 0)].join('; ');
|
|
116
|
+
}
|
|
117
|
+
// True if the result selects the collection through the URL (a host, path, or
|
|
118
|
+
// query source). Then the URL names the collection. A sticky source gives a
|
|
119
|
+
// redirect in place of a file, so its result is never selected by URL.
|
|
120
|
+
export function isSelectedByUrl(result, collectionName) {
|
|
121
|
+
return result.response == null && result.collectionName === collectionName &&
|
|
122
|
+
(result.matchedBy === 'host' || result.matchedBy === 'path' || result.matchedBy === 'query');
|
|
123
|
+
}
|
|
124
|
+
// Choose the collection for a request. With no sources, every request gets the
|
|
125
|
+
// default collection (collectionName: null). Throws a TypeError if the config is
|
|
126
|
+
// not valid.
|
|
127
|
+
export function resolveCollection(request, config) {
|
|
128
|
+
if (config == null) {
|
|
129
|
+
return { collectionName: null };
|
|
130
|
+
}
|
|
131
|
+
const compiled = compile(config);
|
|
132
|
+
const url = new URL(request.url);
|
|
133
|
+
// The activate and reset paths of the cookie source.
|
|
134
|
+
const cookie = compiled.cookie;
|
|
135
|
+
if (cookie != null && (request.method === 'GET' || request.method === 'HEAD')) {
|
|
136
|
+
if (url.pathname === cookie.activatePath) {
|
|
137
|
+
const collectionName = url.searchParams.get('collection');
|
|
138
|
+
if (collectionName == null) {
|
|
139
|
+
return { collectionName: null, matchedBy: 'cookie', response: new Response(`Missing required 'collection' query parameter.`, { status: 400 }) };
|
|
140
|
+
}
|
|
141
|
+
if (!isValidCollectionName(collectionName)) {
|
|
142
|
+
return { collectionName: null, matchedBy: 'cookie', response: new Response(`The 'collection' query parameter is not a valid collection name. ${COLLECTION_NAME_RULE}`, { status: 400 }) };
|
|
143
|
+
}
|
|
144
|
+
if (!isCollectionNameAllowed(collectionName, config.allow)) {
|
|
145
|
+
return { collectionName: null, matchedBy: 'cookie', response: new Response(`The collection '${collectionName}' cannot be selected.`, { status: 403 }) };
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
collectionName,
|
|
149
|
+
matchedBy: 'cookie',
|
|
150
|
+
response: redirect(url.searchParams.get('redirectTo') ?? '/', setCookieValue(cookie, url, collectionName)),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (url.pathname === cookie.resetPath) {
|
|
154
|
+
return {
|
|
155
|
+
collectionName: null,
|
|
156
|
+
matchedBy: 'cookie',
|
|
157
|
+
response: redirect(url.searchParams.get('redirectTo') ?? '/', clearCookieValue(cookie, url)),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const [index, matcher] of compiled.matchers.entries()) {
|
|
162
|
+
const match = matcher(url, request);
|
|
163
|
+
if (match == null) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const source = config.sources[index];
|
|
167
|
+
const result = { collectionName: match.collectionName, matchedBy: source.type };
|
|
168
|
+
if (match.pathname != null) {
|
|
169
|
+
result.pathname = match.pathname;
|
|
170
|
+
}
|
|
171
|
+
// Sticky: set the cookie, and redirect to the URL without the selector.
|
|
172
|
+
if ((source.type === 'path' || source.type === 'query') && source.sticky === 'cookie' && cookie != null &&
|
|
173
|
+
(request.method === 'GET' || request.method === 'HEAD')) {
|
|
174
|
+
let location;
|
|
175
|
+
if (source.type === 'path') {
|
|
176
|
+
// The path without the prefix, not decoded.
|
|
177
|
+
const parts = splitPattern(source.prefix);
|
|
178
|
+
const prefix = parts.before + match.collectionName + parts.after;
|
|
179
|
+
location = (url.pathname.slice(prefix.length) || '/') + url.search;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const params = new URLSearchParams(url.search);
|
|
183
|
+
params.delete(source.param);
|
|
184
|
+
const search = params.toString();
|
|
185
|
+
location = url.pathname + (search !== '' ? `?${search}` : '');
|
|
186
|
+
}
|
|
187
|
+
result.response = redirect(location, setCookieValue(cookie, url, match.collectionName));
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
return { collectionName: null };
|
|
192
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-cookie.d.ts","sourceRoot":"","sources":["../../../../src/server/collection-selector/from-cookie.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"from-cookie.d.ts","sourceRoot":"","sources":["../../../../src/server/collection-selector/from-cookie.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,kCAAkC,CAAC;AAqB1C,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,wBAAyB,YAAW,6BAA6B;IAC5E,cAAqB;IACrB,YAAmB,UAAU,EAAE,MAAM,EAAE;IACvC,YAAmB,IAAI,EAAE,OAAO,CAAC,4BAA4B,CAAC,EAAE;IAqBzD,IAAI,EAAE,4BAA4B,CAAC;IAEnC,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,4BAA4B,CAEvE;IAEM,aAAa,CAAC,OAAO,EAAE,OAAO,mBAkEpC;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,4BAA4B,CAAC;IAC7C,gBAAgB,EAAE,QAAQ,GAAG,IAAI,CAAC;CACnC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,4BAA4B,GAAG,gBAAgB,CAevH"}
|
|
@@ -2,10 +2,8 @@
|
|
|
2
2
|
* Copyright Fastly, Inc.
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
|
+
import { COLLECTION_NAME_RULE, isValidCollectionName } from '../../models/collections/index.js';
|
|
5
6
|
import { getCookieValue } from '../util/cookies.js';
|
|
6
|
-
// The characters that a cookie value can have (cookie-octet in RFC 6265):
|
|
7
|
-
// no controls, spaces, '"', ',', ';', or '\'.
|
|
8
|
-
const COOKIE_VALUE_PATTERN = /^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/;
|
|
9
7
|
// The redirect target after activate or reset. Only a path on the same site
|
|
10
8
|
// is allowed; anything else gives '/'.
|
|
11
9
|
function getRedirectTo(url) {
|
|
@@ -55,9 +53,9 @@ export class CookieCollectionSelector {
|
|
|
55
53
|
if (collectionName == null) {
|
|
56
54
|
return new Response(`Missing required 'collection' query parameter.`, { status: 400 });
|
|
57
55
|
}
|
|
58
|
-
// The value goes into Set-Cookie
|
|
59
|
-
if (!
|
|
60
|
-
return new Response(`The 'collection' query parameter
|
|
56
|
+
// The value goes into Set-Cookie. A valid collection name is also a valid cookie value.
|
|
57
|
+
if (!isValidCollectionName(collectionName)) {
|
|
58
|
+
return new Response(`The 'collection' query parameter is not a valid collection name. ${COLLECTION_NAME_RULE}`, { status: 400 });
|
|
61
59
|
}
|
|
62
60
|
const redirectTo = getRedirectTo(url);
|
|
63
61
|
const cookieSegments = [
|
|
@@ -78,7 +76,7 @@ export class CookieCollectionSelector {
|
|
|
78
76
|
headers.append("Set-Cookie", cookieSegments.join(';'));
|
|
79
77
|
headers.set("Location", redirectTo);
|
|
80
78
|
return new Response(null, {
|
|
81
|
-
status:
|
|
79
|
+
status: 308,
|
|
82
80
|
headers,
|
|
83
81
|
});
|
|
84
82
|
}
|
|
@@ -99,7 +97,7 @@ export class CookieCollectionSelector {
|
|
|
99
97
|
headers.append("Set-Cookie", cookieSegments.join(';'));
|
|
100
98
|
headers.set("Location", redirectTo);
|
|
101
99
|
return new Response(null, {
|
|
102
|
-
status:
|
|
100
|
+
status: 308,
|
|
103
101
|
headers,
|
|
104
102
|
});
|
|
105
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-request.d.ts","sourceRoot":"","sources":["../../../../src/server/collection-selector/from-request.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,kCAAkC,CAAC;AAE1C,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,4BAA4B,CAAC;AAC7F,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;AAG3D,qBAAa,iCAAkC,YAAW,6BAA6B;
|
|
1
|
+
{"version":3,"file":"from-request.d.ts","sourceRoot":"","sources":["../../../../src/server/collection-selector/from-request.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EACnC,MAAM,kCAAkC,CAAC;AAE1C,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,4BAA4B,CAAC;AAC7F,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;AAG3D,qBAAa,iCAAkC,YAAW,6BAA6B;IACrF,YACE,IAAI,EAAE,2BAA2B,EAGlC;IAEM,IAAI,EAAE,2BAA2B,CAAC;IAElC,iBAAiB,CAAC,OAAO,EAAE,OAAO,gCAExC;CACF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,GAAG,4BAA4B,CAK7G;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,GAAG,4BAA4B,CAI5G;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,4BAA4B,CAKhG"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export { type StaticPublishRc } from '../models/config/static-publish-rc.js';
|
|
2
|
+
export { type StaticPublishProject } from '../models/config/static-publish-project.js';
|
|
2
3
|
export { type PublishContentConfig } from '../models/config/publish-content-config.js';
|
|
3
4
|
export * as collectionSelector from './collection-selector/index.js';
|
|
5
|
+
export { type ResolveCollectionResult, resolveCollection, } from './collection-selection/index.js';
|
|
6
|
+
export { type CollectionSelection, type CollectionSelectionSource, previewUrl, validateCollectionSelection, } from '../models/config/collection-selection.js';
|
|
4
7
|
export { CookieCollectionSelector, type CookieCollectionSelectorOpts, } from './collection-selector/from-cookie.js';
|
|
5
8
|
export { type StorageProvider, type StorageProviderBuilder, type StorageEntry, registerStorageProviderBuilder, } from './storage/storage-provider.js';
|
|
6
9
|
export { setSecretStoreForS3Credentials, setSecretStoreKeyForS3AccessKeyId, setSecretStoreKeyForS3SecretAccessKey, setS3CredentialsBuilder, } from './storage/s3-storage-provider.js';
|
|
7
|
-
export { PublisherServer } from './publisher-server/index.js';
|
|
10
|
+
export { type GetMatchingAssetOptions, type ServeFallbackOptions, type ServeRequestOptions, PublisherServer, } from './publisher-server/index.js';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,GAClC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EACjC,qCAAqC,EACrC,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AACrE,OAAO,EACL,KAAK,uBAAuB,EAC5B,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,UAAU,EACV,2BAA2B,GAC5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,GAClC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,iCAAiC,EACjC,qCAAqC,EACrC,uBAAuB,GACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,eAAe,GAChB,MAAM,6BAA6B,CAAC"}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
4
|
*/
|
|
5
5
|
export * as collectionSelector from './collection-selector/index.js';
|
|
6
|
+
export { resolveCollection, } from './collection-selection/index.js';
|
|
7
|
+
export { previewUrl, validateCollectionSelection, } from '../models/config/collection-selection.js';
|
|
6
8
|
export { CookieCollectionSelector, } from './collection-selector/from-cookie.js';
|
|
7
9
|
export { registerStorageProviderBuilder, } from './storage/storage-provider.js';
|
|
8
10
|
export { setSecretStoreForS3Credentials, setSecretStoreKeyForS3AccessKeyId, setSecretStoreKeyForS3SecretAccessKey, setS3CredentialsBuilder, } from './storage/s3-storage-provider.js';
|
|
9
|
-
export { PublisherServer } from './publisher-server/index.js';
|
|
11
|
+
export { PublisherServer, } from './publisher-server/index.js';
|
|
10
12
|
// Register storage builder providers
|
|
11
13
|
import { registerStorageProviderBuilder } from './storage/storage-provider.js';
|
|
12
14
|
import * as kvStoreProvider from './storage/kv-store-provider.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accept-html.d.ts","sourceRoot":"","sources":["../../../../src/server/publisher-server/accept-html.ts"],"names":[],"mappings":"AAYA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAyChE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
// Returns true if the request accepts a text/html response.
|
|
6
|
+
// https://httpwg.org/specs/rfc9110.html#field.accept
|
|
7
|
+
// * A missing or empty Accept header accepts all media types.
|
|
8
|
+
// * The most specific media range that matches text/html gives the q-value:
|
|
9
|
+
// text/html, then text/*, then */*. A q-value of 0 means "not acceptable".
|
|
10
|
+
// * The media type parameters other than q are ignored.
|
|
11
|
+
// * A bare '*' is the same as '*/*'.
|
|
12
|
+
export function requestAcceptsTextHtml(request) {
|
|
13
|
+
const header = (request.headers.get('Accept') ?? '').trim();
|
|
14
|
+
if (header === '') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
// The highest q-value for each media range that matches text/html
|
|
18
|
+
let htmlQValue = null;
|
|
19
|
+
let textQValue = null;
|
|
20
|
+
let anyQValue = null;
|
|
21
|
+
for (const item of header.split(',')) {
|
|
22
|
+
const [rangeStr, ...paramStrs] = item.split(';');
|
|
23
|
+
const range = rangeStr.trim().toLowerCase();
|
|
24
|
+
if (range === '') {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
let qValue = 1;
|
|
28
|
+
for (const paramStr of paramStrs) {
|
|
29
|
+
const [name, value] = paramStr.split('=');
|
|
30
|
+
if (name.trim().toLowerCase() !== 'q' || value == null) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const parsed = parseFloat(value.trim());
|
|
34
|
+
if (!Number.isNaN(parsed)) {
|
|
35
|
+
qValue = Math.min(Math.max(parsed, 0), 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (range === 'text/html') {
|
|
39
|
+
htmlQValue = Math.max(htmlQValue ?? 0, qValue);
|
|
40
|
+
}
|
|
41
|
+
else if (range === 'text/*') {
|
|
42
|
+
textQValue = Math.max(textQValue ?? 0, qValue);
|
|
43
|
+
}
|
|
44
|
+
else if (range === '*/*' || range === '*') {
|
|
45
|
+
anyQValue = Math.max(anyQValue ?? 0, qValue);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const qValue = htmlQValue ?? textQValue ?? anyQValue;
|
|
49
|
+
return qValue != null && qValue > 0;
|
|
50
|
+
}
|
|
@@ -2,9 +2,15 @@ import { type StaticPublishRc } from '../../models/config/static-publish-rc.js';
|
|
|
2
2
|
import { type PublisherServerConfigNormalized } from '../../models/config/publisher-server-config.js';
|
|
3
3
|
import { type ContentCompressionTypes } from '../../models/compression/index.js';
|
|
4
4
|
import { type AssetEntry, type AssetEntryMap, type AssetVariantMetadata } from '../../models/assets/index.js';
|
|
5
|
+
import { type CollectionSelection } from '../../models/config/collection-selection.js';
|
|
6
|
+
import { type ResolveCollectionResult } from '../collection-selection/index.js';
|
|
5
7
|
import { type StorageEntry, type StorageProvider } from '../storage/storage-provider.js';
|
|
6
8
|
import { ServerTiming } from '../util/server-timing.js';
|
|
7
9
|
import { type ResponseCacheOptions } from './response-cache.js';
|
|
10
|
+
export type GetMatchingAssetOptions = {
|
|
11
|
+
applyAuto?: boolean;
|
|
12
|
+
includeHidden?: boolean;
|
|
13
|
+
};
|
|
8
14
|
type AssetVariant = {
|
|
9
15
|
storageEntry: StorageEntry;
|
|
10
16
|
} & AssetVariantMetadata;
|
|
@@ -14,6 +20,15 @@ type AssetInit = {
|
|
|
14
20
|
headers?: Record<string, string>;
|
|
15
21
|
cache?: 'extended' | 'never' | null;
|
|
16
22
|
};
|
|
23
|
+
export type ServeRequestOptions = {
|
|
24
|
+
collectionName?: string | null;
|
|
25
|
+
pathname?: string;
|
|
26
|
+
fallback?: boolean;
|
|
27
|
+
healthCheck?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type ServeFallbackOptions = {
|
|
30
|
+
collectionName?: string | null;
|
|
31
|
+
};
|
|
17
32
|
export declare class PublisherServer {
|
|
18
33
|
constructor(publishId: string, storageProvider: StorageProvider, defaultCollectionName: string);
|
|
19
34
|
static fromStaticPublishRc(config: StaticPublishRc): PublisherServer;
|
|
@@ -23,31 +38,69 @@ export declare class PublisherServer {
|
|
|
23
38
|
activeCollectionName: string;
|
|
24
39
|
collectionNameHeader: string | null;
|
|
25
40
|
serverTimingRequestHeader: string | null;
|
|
26
|
-
serverTiming: ServerTiming | null;
|
|
27
41
|
responseCache: ResponseCacheOptions | null;
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
collectionSelection: CollectionSelection | null;
|
|
43
|
+
private currentScope;
|
|
44
|
+
private requestScopes;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Read-only. This returns the Server-Timing of the current request.
|
|
47
|
+
* It will be removed in v9.
|
|
48
|
+
*/
|
|
49
|
+
get serverTiming(): ServerTiming | null;
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Read-only. This returns the settings that the current request
|
|
52
|
+
* read. Use getServerConfig().
|
|
53
|
+
* It will be removed in v9.
|
|
54
|
+
*/
|
|
55
|
+
get settingsCached(): PublisherServerConfigNormalized | null | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Read-only. This returns the index that the current request read.
|
|
58
|
+
* Use getAssetEntryMap().
|
|
59
|
+
* It will be removed in v9.
|
|
60
|
+
*/
|
|
61
|
+
get assetEntryMapCache(): AssetEntryMap | null | undefined;
|
|
30
62
|
setActiveCollectionName(collectionName: string | null): void;
|
|
31
63
|
setCollectionNameHeader(collectionHeader: string | null): void;
|
|
32
64
|
setServerTimingRequestHeader(requestHeader: string | null): void;
|
|
33
65
|
setResponseCache(options: ResponseCacheOptions | null): void;
|
|
66
|
+
setCollectionSelection(config: CollectionSelection | null): void;
|
|
67
|
+
resolveCollection(request: Request): ResolveCollectionResult;
|
|
34
68
|
beginRequest(request: Request): void;
|
|
69
|
+
private newServerTiming;
|
|
70
|
+
private newScope;
|
|
71
|
+
private scopeForRequest;
|
|
35
72
|
private timed;
|
|
36
73
|
getServerConfig(): Promise<PublisherServerConfigNormalized | null>;
|
|
37
|
-
|
|
74
|
+
private getServerConfigFor;
|
|
75
|
+
getStaticItems(): Promise<import("../../models/config/item-patterns.js").ItemPattern[]>;
|
|
76
|
+
private getStaticItemsFor;
|
|
38
77
|
getAssetEntryMap(): Promise<AssetEntryMap | null>;
|
|
39
|
-
|
|
78
|
+
private getAssetEntryMapFor;
|
|
79
|
+
getMatchingAsset(assetKey: string, options?: boolean | GetMatchingAssetOptions): Promise<AssetEntry | null>;
|
|
80
|
+
private getMatchingAssetFor;
|
|
40
81
|
findAcceptEncodingsGroups(request: Request): Promise<ContentCompressionTypes[][]>;
|
|
82
|
+
private findAcceptEncodingsGroupsFor;
|
|
41
83
|
testExtendedCache(pathname: string): Promise<boolean>;
|
|
84
|
+
private testExtendedCacheFor;
|
|
42
85
|
handlePreconditions(request: Request, asset: AssetEntry, responseHeaders: Headers): Response | null;
|
|
43
86
|
private handlePreconditionsForLastModified;
|
|
44
87
|
loadAssetVariant(entry: AssetEntry, variant: ContentCompressionTypes | null): Promise<AssetVariant | null>;
|
|
88
|
+
private loadAssetVariantFor;
|
|
45
89
|
private findAssetVariantForAcceptEncodingsGroups;
|
|
46
90
|
serveAsset(request: Request, asset: AssetEntry, init?: AssetInit): Promise<Response>;
|
|
91
|
+
private serveAssetFor;
|
|
47
92
|
serveCached(request: Request, keyPath: string, produce: (request: Request) => Promise<Response | null>): Promise<Response | null>;
|
|
93
|
+
private serveCachedFor;
|
|
48
94
|
private responseFromCache;
|
|
49
|
-
serveRequest(request: Request): Promise<Response | null>;
|
|
95
|
+
serveRequest(request: Request, options?: ServeRequestOptions): Promise<Response | null>;
|
|
96
|
+
serveFallback(request: Request, options?: ServeFallbackOptions): Promise<Response | null>;
|
|
97
|
+
isCollectionAvailable(request: Request, collectionName: string | null): Promise<boolean>;
|
|
98
|
+
private isCollectionAvailableFor;
|
|
99
|
+
private checkSelectedCollection;
|
|
100
|
+
private markPreviewResponse;
|
|
101
|
+
private beginRequestFor;
|
|
50
102
|
private serveRequestFromStorage;
|
|
103
|
+
private serveFallbackFromStorage;
|
|
51
104
|
}
|
|
52
105
|
export {};
|
|
53
106
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/publisher-server/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,+BAA+B,EACrC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/publisher-server/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,KAAK,+BAA+B,EACrC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAI1B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,KAAK,uBAAuB,EAAsC,MAAM,kCAAkC,CAAC;AAGpH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EAErB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAEL,KAA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