@fastly/compute-js-static-publish 8.1.0-beta.7 → 8.1.0-beta.9
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 +10 -2
- package/DOCUMENTATION.md +112 -70
- package/MIGRATING.md +45 -15
- package/README.md +6 -5
- package/README.short.md +6 -5
- package/build/cli/cli/commands/manage/clean.js +1 -1
- package/build/cli/cli/commands/manage/collections/delete.js +1 -1
- package/build/cli/cli/commands/manage/collections/index.js +1 -1
- package/build/cli/cli/commands/manage/collections/list.js +1 -1
- package/build/cli/cli/commands/manage/collections/promote.js +1 -1
- package/build/cli/cli/commands/manage/collections/update-expiration.js +1 -1
- package/build/cli/cli/commands/manage/index.js +2 -2
- package/build/cli/cli/commands/manage/publish-content.js +1 -1
- package/build/cli/cli/commands/manage/status.js +1 -1
- package/build/cli/cli/commands/manage/template/index.js +1 -1
- package/build/cli/cli/commands/manage/template/init.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/template/init.js +11 -4
- package/build/cli/cli/commands/scaffold/app-template.js +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.d.ts +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
- package/build/cli/cli/commands/scaffold/generate-app.js +1 -1
- package/build/cli/cli/commands/scaffold/index.js +5 -5
- package/build/cli/cli/hono/build.d.ts +21 -14
- package/build/cli/cli/hono/build.d.ts.map +1 -1
- package/build/cli/cli/hono/build.js +119 -76
- package/build/cli/cli/managed/app.js +4 -4
- package/build/cli/cli/managed/command-helpers.js +6 -6
- package/build/cli/cli/managed/project-file.js +6 -6
- package/build/cli/cli/managed/template-init.js +3 -3
- package/build/cli/cli/storage/kv-store-local-provider.d.ts +2 -2
- package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-local-provider.js +2 -14
- package/build/cli/cli/storage/kv-store-provider.d.ts +2 -2
- package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/kv-store-provider.js +2 -1
- package/build/cli/cli/storage/s3-storage-provider.d.ts +2 -2
- package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/s3-storage-provider.js +4 -3
- package/build/cli/cli/storage/storage-provider.d.ts +3 -1
- package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
- package/build/cli/cli/storage/storage-provider.js +16 -0
- package/build/cli/cli/util/kv-store.d.ts +1 -1
- package/build/cli/cli/util/kv-store.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.d.ts +4 -3
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/template-settings.d.ts.map +1 -1
- package/build/cli/models/config/template-settings.js +34 -9
- package/build/server/hono/compose.d.ts +51 -0
- package/build/server/hono/compose.d.ts.map +1 -0
- package/build/server/hono/compose.js +93 -0
- package/build/server/hono/index.d.ts +1 -1
- package/build/server/hono/index.d.ts.map +1 -1
- package/build/server/hono/index.js +1 -1
- package/build/server/models/config/static-publish-rc.d.ts +4 -3
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/server/index.d.ts +1 -1
- package/build/server/server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.d.ts.map +1 -1
- package/build/server/server/publisher-server/index.js +6 -1
- package/build/server/server/storage/kv-store-provider.d.ts.map +1 -1
- package/build/server/server/storage/kv-store-provider.js +1 -0
- package/build/server/server/storage/s3-storage-provider.d.ts +2 -2
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +5 -2
- package/build/server/server/storage/storage-provider.d.ts +12 -1
- package/build/server/server/storage/storage-provider.d.ts.map +1 -1
- package/package.json +2 -2
- package/resources/template-init/hono/_example.ts +14 -13
- package/resources/templates/hono/package-lock.json +40 -40
- package/resources/templates/hono/package.json +2 -2
- package/resources/templates/hono/scripts/template_postinstall.js +5 -5
- package/resources/templates/hono/scripts/template_prebuild.js +6 -6
- package/resources/templates/hono/scripts/template_watch.js +5 -4
- package/resources/templates/hono/src/hono-compose.generated.d.ts +5 -0
- package/resources/templates/hono/src/index.ts +14 -14
- package/resources/templates/plain/package-lock.json +40 -40
- package/resources/templates/plain/package.json +2 -2
- package/build/server/hono/extensions.d.ts +0 -50
- package/build/server/hono/extensions.d.ts.map +0 -1
- package/build/server/hono/extensions.js +0 -70
- package/resources/templates/hono/src/hono-extensions.generated.d.ts +0 -5
|
@@ -5,11 +5,13 @@ export interface StorageEntry {
|
|
|
5
5
|
providerMetadata?: Record<string, string>;
|
|
6
6
|
size?: number;
|
|
7
7
|
}
|
|
8
|
+
export type StorageEntryData = ReadableStream<Uint8Array> | Uint8Array | string | null | undefined;
|
|
9
|
+
export declare function storageEntryDataToBytes(data: StorageEntryData): Promise<Uint8Array>;
|
|
8
10
|
export interface StorageProvider {
|
|
9
11
|
getStorageKeys(prefix?: string): Promise<string[] | null>;
|
|
10
12
|
getStorageEntryInfo(key: string): Promise<StorageEntry | null>;
|
|
11
13
|
getStorageEntry(key: string): Promise<StorageEntry | null>;
|
|
12
|
-
submitStorageEntry(key: string, filePath: string, data:
|
|
14
|
+
submitStorageEntry(key: string, filePath: string, data: StorageEntryData, metadata?: Record<string, string>): Promise<void>;
|
|
13
15
|
deleteStorageEntry(key: string): Promise<void>;
|
|
14
16
|
applyBatch(batch: StorageProviderBatch, options?: ApplyBatchOptions): Promise<void>;
|
|
15
17
|
doConcurrentParallel<TObject extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/storage-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EA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
|
+
// Reads the data of an entry into memory. An upload of a stream has no
|
|
6
|
+
// Content-Length, and the Fastly KV Store API can refuse such an upload
|
|
7
|
+
// with 400 "must include valid content-length header". Thus the providers
|
|
8
|
+
// upload the bytes.
|
|
9
|
+
export async function storageEntryDataToBytes(data) {
|
|
10
|
+
if (data == null) {
|
|
11
|
+
return new Uint8Array(0);
|
|
12
|
+
}
|
|
13
|
+
if (typeof data === 'string') {
|
|
14
|
+
return new TextEncoder().encode(data);
|
|
15
|
+
}
|
|
16
|
+
if (data instanceof Uint8Array) {
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
return new Uint8Array(await new Response(data).arrayBuffer());
|
|
20
|
+
}
|
|
5
21
|
export class StorageProviderBatch {
|
|
6
22
|
constructor() {
|
|
7
23
|
this.storageProviderBatchEntries = [];
|
|
@@ -15,7 +15,7 @@ export declare const _getKVStoreKeys: (fastlyApiContext: FastlyApiContext, opera
|
|
|
15
15
|
export declare function getKVStoreKeys(fastlyApiContext: FastlyApiContext, kvStoreName: string, prefix?: string): Promise<string[] | null>;
|
|
16
16
|
export declare function getKvStoreEntryInfo(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<KvStoreEntryInfo | null>;
|
|
17
17
|
export declare function getKvStoreEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, metadataOnly?: boolean): Promise<KvStoreEntryInfo | null>;
|
|
18
|
-
export declare function kvStoreSubmitEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, data:
|
|
18
|
+
export declare function kvStoreSubmitEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, data: Uint8Array | string, metadata: string | undefined): Promise<void>;
|
|
19
19
|
export declare function kvStoreDeleteEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<void>;
|
|
20
20
|
export type KvStoreBatchError = {
|
|
21
21
|
key: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv-store.d.ts","sourceRoot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Q,EAAE,MAAM,GAAG,SAAS,iBAoB7B;AAED,wBAAsB,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAa5G;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAKF,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAwC9B"}
|
|
@@ -10,14 +10,15 @@ export type StaticPublishRcBase = {
|
|
|
10
10
|
};
|
|
11
11
|
export type StaticPublishBuild = {
|
|
12
12
|
hono?: {
|
|
13
|
-
|
|
13
|
+
composeDir?: string;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export type HonoBindings = Record<string, string>;
|
|
17
17
|
export type HonoTemplateOptions = {
|
|
18
18
|
bindings?: HonoBindings;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
compose?: {
|
|
20
|
+
plugins?: Record<string, unknown>;
|
|
21
|
+
};
|
|
21
22
|
};
|
|
22
23
|
export type StaticPublishTemplateOptions = {
|
|
23
24
|
hono?: HonoTemplateOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-publish-rc.d.ts","sourceRoot":"","sources":["../../../../src/models/config/static-publish-rc.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG;IAGhC,SAAS,EAAE,MAAM,CAAC;IAGlB,qBAAqB,EAAE,MAAM,CAAC;IAK9B,yBAAyB,EAAE,MAAM,CAAC;IAGlC,aAAa,CAAC,EAAE,aAAa,CAAC;IAK9B,mBAA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CAAC;AAGF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAGF,MAAM,MAAM,2BAA2B,GACnC,8BAA8B,GAC9B,iCAAiC,CACpC;AAGD,MAAM,MAAM,oBAAoB,GAC9B,2BAA2B,GAAG,mBAAmB,CAAC;AAEpD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,oBAAoB,CAqBzE;AAGD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,WAAW,EAAE,IAAI,CAAC;IAClB,EAAE,EAAE;QACF,MAAM,EAAE,MAAM,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-settings.d.ts","sourceRoot":"","sources":["../../../../src/models/config/template-settings.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE,MAAM,EAAE,CAAA;CAAE,CAK5F,CAAC;
|
|
1
|
+
{"version":3,"file":"template-settings.d.ts","sourceRoot":"","sources":["../../../../src/models/config/template-settings.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE,MAAM,EAAE,CAAA;CAAE,CAK5F,CAAC;AAYF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAOF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,qBAAqB,CAsErG"}
|
|
@@ -8,8 +8,17 @@
|
|
|
8
8
|
// so that an older version of this package can read a newer file.
|
|
9
9
|
export const TEMPLATE_SETTINGS = {
|
|
10
10
|
hono: {
|
|
11
|
-
build: ['
|
|
12
|
-
templateOptions: ['bindings', '
|
|
11
|
+
build: ['composeDir'],
|
|
12
|
+
templateOptions: ['bindings', 'compose'],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
// The names of settings in earlier betas of 8.1, and the name that each one
|
|
16
|
+
// has now. They are errors, not warnings, so that a build never skips the
|
|
17
|
+
// plugins without a message. Removed in v9.
|
|
18
|
+
const RENAMED_SETTINGS = {
|
|
19
|
+
hono: {
|
|
20
|
+
build: { extensionsDir: 'build.hono.composeDir' },
|
|
21
|
+
templateOptions: { extensions: 'templateOptions.hono.compose.plugins' },
|
|
13
22
|
},
|
|
14
23
|
};
|
|
15
24
|
const isPlainObject = (value) => typeof value === 'object' && value != null && !Array.isArray(value);
|
|
@@ -37,17 +46,21 @@ export function checkTemplateSettings(build, templateOptions) {
|
|
|
37
46
|
continue;
|
|
38
47
|
}
|
|
39
48
|
for (const key of Object.keys(settings)) {
|
|
40
|
-
|
|
49
|
+
const renamed = RENAMED_SETTINGS[templateName]?.[field]?.[key];
|
|
50
|
+
if (renamed != null) {
|
|
51
|
+
errors.push(`${field}.${templateName}.${key} is now ${renamed}.`);
|
|
52
|
+
}
|
|
53
|
+
else if (!declared.includes(key)) {
|
|
41
54
|
warnings.push(`${field}.${templateName}.${key} is not a setting of the template '${templateName}'. It is ignored.`);
|
|
42
55
|
}
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
// The settings of the hono template.
|
|
47
|
-
if (isPlainObject(build) && isPlainObject(build.hono) && build.hono.
|
|
48
|
-
const
|
|
49
|
-
if (typeof
|
|
50
|
-
errors.push(`build.hono.
|
|
60
|
+
if (isPlainObject(build) && isPlainObject(build.hono) && build.hono.composeDir !== undefined) {
|
|
61
|
+
const composeDir = build.hono.composeDir;
|
|
62
|
+
if (typeof composeDir !== 'string' || !/^\.\.?\//.test(composeDir)) {
|
|
63
|
+
errors.push(`build.hono.composeDir must be a relative path that starts with './' or '../'.`);
|
|
51
64
|
}
|
|
52
65
|
}
|
|
53
66
|
if (isPlainObject(templateOptions) && isPlainObject(templateOptions.hono)) {
|
|
@@ -64,8 +77,20 @@ export function checkTemplateSettings(build, templateOptions) {
|
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
|
-
if (hono.
|
|
68
|
-
|
|
80
|
+
if (hono.compose !== undefined) {
|
|
81
|
+
if (!isPlainObject(hono.compose)) {
|
|
82
|
+
errors.push('templateOptions.hono.compose must be an object.');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
for (const key of Object.keys(hono.compose)) {
|
|
86
|
+
if (key !== 'plugins') {
|
|
87
|
+
warnings.push(`templateOptions.hono.compose.${key} is not a setting of the template 'hono'. It is ignored.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (hono.compose.plugins !== undefined && !isPlainObject(hono.compose.plugins)) {
|
|
91
|
+
errors.push('templateOptions.hono.compose.plugins must be an object, with the options of each plugin by plugin name.');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
69
94
|
}
|
|
70
95
|
}
|
|
71
96
|
return { errors, warnings };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Acl } from 'fastly:acl';
|
|
2
|
+
import type { Backend } from 'fastly:backend';
|
|
3
|
+
import type { ConfigStore } from 'fastly:config-store';
|
|
4
|
+
import type { KVStore } from 'fastly:kv-store';
|
|
5
|
+
import type { Logger } from 'fastly:logger';
|
|
6
|
+
import type { SecretStore } from 'fastly:secret-store';
|
|
7
|
+
import type { Hono } from 'hono';
|
|
8
|
+
import type { PublisherServerMiddleware } from './index.js';
|
|
9
|
+
export type PluginBindings = Record<string, string>;
|
|
10
|
+
type ResourceTypes = {
|
|
11
|
+
Acl: Acl;
|
|
12
|
+
Backend: Backend;
|
|
13
|
+
ConfigStore: ConfigStore;
|
|
14
|
+
env: string;
|
|
15
|
+
KVStore: KVStore;
|
|
16
|
+
Logger: Logger;
|
|
17
|
+
SecretStore: SecretStore;
|
|
18
|
+
};
|
|
19
|
+
export type BindingResource<R> = R extends `${infer T}:${string}` ? (T extends keyof ResourceTypes ? ResourceTypes[T] | undefined : unknown) : R extends keyof ResourceTypes ? ResourceTypes[R] | undefined : unknown;
|
|
20
|
+
export type PluginEnv<B extends PluginBindings> = {
|
|
21
|
+
Bindings: {
|
|
22
|
+
[K in keyof B]: BindingResource<B[K]>;
|
|
23
|
+
};
|
|
24
|
+
Variables: Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
export declare const PLUGIN_PHASES: readonly ['middleware', 'routes', 'afterFilesRoutes'];
|
|
27
|
+
export type PluginPhase = typeof PLUGIN_PHASES[number];
|
|
28
|
+
export type PluginHelpers = Pick<PublisherServerMiddleware, 'publisherServer' | 'serveStatic' | 'staticResponse' | 'serveFallback' | 'fallbackResponse' | 'isCollectionAvailable'>;
|
|
29
|
+
export type PluginPhaseFunction<B extends PluginBindings = PluginBindings, O = any> = (app: Hono<PluginEnv<B>, any, any>, options: O | undefined, helpers: PluginHelpers) => void;
|
|
30
|
+
export type PluginPhases<B extends PluginBindings = PluginBindings, O = any> = {
|
|
31
|
+
[P in PluginPhase]?: PluginPhaseFunction<B, O>;
|
|
32
|
+
};
|
|
33
|
+
export type DefinePluginOptions<B extends PluginBindings = PluginBindings> = {
|
|
34
|
+
bindings?: B;
|
|
35
|
+
};
|
|
36
|
+
export type Plugin = {
|
|
37
|
+
kind: 'plugin';
|
|
38
|
+
bindings: PluginBindings;
|
|
39
|
+
phases: PluginPhases<any>;
|
|
40
|
+
};
|
|
41
|
+
export type PluginEntry = {
|
|
42
|
+
name: string;
|
|
43
|
+
file: string;
|
|
44
|
+
plugin: Plugin;
|
|
45
|
+
};
|
|
46
|
+
export declare function definePlugin<O = any>(phases: PluginPhaseFunction<{}, O> | PluginPhases<{}, O>): Plugin;
|
|
47
|
+
export declare function definePlugin<const B extends PluginBindings, O = any>(options: DefinePluginOptions<B>, phases: PluginPhaseFunction<B, O> | PluginPhases<B, O>): Plugin;
|
|
48
|
+
export declare function defineExtension(..._args: unknown[]): never;
|
|
49
|
+
export declare function mergeBindings(appBindings: PluginBindings | undefined, entries: PluginEntry[]): PluginBindings;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../../src/hono/compose.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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AC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;AAkBvK,wBAAgB,eAAe,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAK1D;AAWD,wBAAgB,aAAa,CAAC,WAAW,EAAE,cAAc,GAAG,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,cAAc,CAoD7G"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Fastly, Inc.
|
|
3
|
+
* Licensed under the MIT license. See LICENSE file for details.
|
|
4
|
+
*/
|
|
5
|
+
// The phases of the app, in the order that the app adds them. They are on two
|
|
6
|
+
// axes:
|
|
7
|
+
// - Processing: middleware wraps each request, for example a login check, or
|
|
8
|
+
// the time of a request. The code before await next() runs before the routes,
|
|
9
|
+
// and the code after it runs after the response is made, in the reverse order.
|
|
10
|
+
// - Routing: the routes that can answer a request, in this order:
|
|
11
|
+
// - routes: before the published files. These routes win over a file.
|
|
12
|
+
// - (the published files, with serveStatic())
|
|
13
|
+
// - afterFilesRoutes: only for the requests that no published file matches,
|
|
14
|
+
// before the fallback (the SPA file or the 404 page).
|
|
15
|
+
export const PLUGIN_PHASES = ['middleware', 'routes', 'afterFilesRoutes'];
|
|
16
|
+
// The names of the phases in earlier betas of 8.1, and the phase that has
|
|
17
|
+
// each one now. mergeBindings() names the new phase in its error.
|
|
18
|
+
const RENAMED_PHASES = {
|
|
19
|
+
beforeFiles: 'routes',
|
|
20
|
+
beforeFilesRoutes: 'routes',
|
|
21
|
+
afterFiles: 'afterFilesRoutes',
|
|
22
|
+
};
|
|
23
|
+
export function definePlugin(optionsOrPhases, phases) {
|
|
24
|
+
const [options, value] = phases === undefined ?
|
|
25
|
+
[{}, optionsOrPhases] :
|
|
26
|
+
[optionsOrPhases, phases];
|
|
27
|
+
return {
|
|
28
|
+
kind: 'plugin',
|
|
29
|
+
bindings: { ...options.bindings },
|
|
30
|
+
phases: typeof value === 'function' ? { middleware: value } : value,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// The name of definePlugin() in earlier betas of 8.1. It throws, so that a
|
|
34
|
+
// plugin with the old name stops the build with a message that gives the new
|
|
35
|
+
// name. Removed in v9.
|
|
36
|
+
export function defineExtension(..._args) {
|
|
37
|
+
throw new Error("defineExtension() is now definePlugin(), from the same import: " +
|
|
38
|
+
"import { definePlugin } from '@fastly/compute-js-static-publish/hono'.");
|
|
39
|
+
}
|
|
40
|
+
const isPlainObject = (value) => typeof value === 'object' && value != null && !Array.isArray(value);
|
|
41
|
+
// Checks the plugins of the manifest, and merges their bindings with the
|
|
42
|
+
// bindings of the app (templateOptions.hono.bindings), for buildFire(). The
|
|
43
|
+
// same name with the same resource is allowed. Throws for a file that does not
|
|
44
|
+
// default-export definePlugin(…), for phases that are not correct, or for
|
|
45
|
+
// one name with two different resources; the message names the file. Call it at
|
|
46
|
+
// the top level of the app, so that an error stops the build.
|
|
47
|
+
export function mergeBindings(appBindings, entries) {
|
|
48
|
+
// Maps, so that a binding name such as 'toString' is not found on
|
|
49
|
+
// Object.prototype.
|
|
50
|
+
const merged = new Map();
|
|
51
|
+
const sourceOf = new Map();
|
|
52
|
+
const add = (bindings, source) => {
|
|
53
|
+
for (const [name, resource] of Object.entries(bindings)) {
|
|
54
|
+
const existing = merged.get(name);
|
|
55
|
+
if (existing != null && existing !== resource) {
|
|
56
|
+
throw new Error(`The binding '${name}' is '${existing}' in ${sourceOf.get(name)}, ` +
|
|
57
|
+
`but '${resource}' in ${source}. Use the same resource, or another name.`);
|
|
58
|
+
}
|
|
59
|
+
merged.set(name, resource);
|
|
60
|
+
if (!sourceOf.has(name)) {
|
|
61
|
+
sourceOf.set(name, source);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
add(appBindings ?? {}, 'templateOptions.hono.bindings');
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
const source = `hono-compose/${entry.file}`;
|
|
68
|
+
const plugin = entry.plugin;
|
|
69
|
+
if (plugin == null || plugin.kind !== 'plugin') {
|
|
70
|
+
throw new Error(`${source}: the default export must be definePlugin(…).`);
|
|
71
|
+
}
|
|
72
|
+
const phases = plugin.phases;
|
|
73
|
+
const keys = isPlainObject(phases) ? Object.keys(phases) : [];
|
|
74
|
+
const unknown = keys.filter(key => !PLUGIN_PHASES.includes(key));
|
|
75
|
+
if (!isPlainObject(phases) || keys.length === 0 || unknown.length > 0) {
|
|
76
|
+
throw new Error(`${source}: definePlugin() needs a function, or an object with a function ` +
|
|
77
|
+
`for one or more of the phases ${PLUGIN_PHASES.join(', ')}.` +
|
|
78
|
+
(unknown.length === 1 ? ` '${unknown[0]}' is not a phase.` : '') +
|
|
79
|
+
(unknown.length > 1 ? ` ${unknown.map(x => `'${x}'`).join(', ')} are not phases.` : '') +
|
|
80
|
+
unknown
|
|
81
|
+
.filter(x => Object.prototype.hasOwnProperty.call(RENAMED_PHASES, x))
|
|
82
|
+
.map(x => ` Rename '${x}' to '${RENAMED_PHASES[x]}'.`)
|
|
83
|
+
.join(''));
|
|
84
|
+
}
|
|
85
|
+
for (const key of keys) {
|
|
86
|
+
if (typeof phases[key] !== 'function') {
|
|
87
|
+
throw new Error(`${source}: the phase ${key} must be a function.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
add(plugin.bindings ?? {}, source);
|
|
91
|
+
}
|
|
92
|
+
return Object.fromEntries(merged);
|
|
93
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context, MiddlewareHandler, NotFoundHandler } from 'hono';
|
|
2
2
|
import { PublisherServer, type ResponseOverrides, type StaticPublishRc } from '../server/index.js';
|
|
3
3
|
import { type ServeStaticPathOptions } from './path.js';
|
|
4
|
-
export { type BindingResource, type
|
|
4
|
+
export { type BindingResource, type DefinePluginOptions, PLUGIN_PHASES, type Plugin, type PluginBindings, type PluginEntry, type PluginEnv, type PluginHelpers, type PluginPhase, type PluginPhaseFunction, type PluginPhases, defineExtension, definePlugin, mergeBindings, } from './compose.js';
|
|
5
5
|
export type StaticPublisherVariables = {
|
|
6
6
|
staticPublisher: {
|
|
7
7
|
publisherServer: PublisherServer;
|
|
@@ -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,iBAAiB,EAAE,KAAK,eAAe,EAA6B,MAAM,oBAAoB,CAAC;AAC9H,OAAO,EAAE,KAAK,sBAAsB,EAA8B,MAAM,WAAW,CAAC;AAEpF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,
|
|
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,iBAAiB,EAAE,KAAK,eAAe,EAA6B,MAAM,oBAAoB,CAAC;AAC9H,OAAO,EAAE,KAAK,sBAAsB,EAA8B,MAAM,WAAW,CAAC;AAEpF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,aAAa,EACb,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,wBAAwB,GAAG;IACrC,eAAe,EAAE;QACf,eAAe,EAAE,eAAe,CAAC;QAGjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAE9B,QAAQ,CAAC,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F,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;CAC3C,CAAC;AAmDF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,GAAE,iCAAsC,GAAG,yBAAyB,CA0FxI;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,GAAE,iCAAsC,GAAG,yBAAyB,CAEpI"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// Import from the package entry point, which registers the storage providers.
|
|
6
6
|
import { PublisherServer } from '../server/index.js';
|
|
7
7
|
import { resolveServeStaticPathname } from './path.js';
|
|
8
|
-
export {
|
|
8
|
+
export { PLUGIN_PHASES, defineExtension, definePlugin, mergeBindings, } from './compose.js';
|
|
9
9
|
// The selection that selectCollection() of this server made for the request.
|
|
10
10
|
function getSelection(c, server) {
|
|
11
11
|
const selection = c.var.staticPublisher;
|
|
@@ -10,14 +10,15 @@ export type StaticPublishRcBase = {
|
|
|
10
10
|
};
|
|
11
11
|
export type StaticPublishBuild = {
|
|
12
12
|
hono?: {
|
|
13
|
-
|
|
13
|
+
composeDir?: string;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export type HonoBindings = Record<string, string>;
|
|
17
17
|
export type HonoTemplateOptions = {
|
|
18
18
|
bindings?: HonoBindings;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
compose?: {
|
|
20
|
+
plugins?: Record<string, unknown>;
|
|
21
|
+
};
|
|
21
22
|
};
|
|
22
23
|
export type StaticPublishTemplateOptions = {
|
|
23
24
|
hono?: HonoTemplateOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-publish-rc.d.ts","sourceRoot":"","sources":["../../../../src/models/config/static-publish-rc.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG;IAGhC,SAAS,EAAE,MAAM,CAAC;IAGlB,q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selector/index.js';
|
|
|
5
5
|
export { type ResolveCollectionResult, resolveCollection, } from './collection-selection/index.js';
|
|
6
6
|
export { type CollectionSelection, type CollectionSelectionSource, previewUrl, validateCollectionSelection, } from '../models/config/collection-selection.js';
|
|
7
7
|
export { CookieCollectionSelector, type CookieCollectionSelectorOpts, } from './collection-selector/from-cookie.js';
|
|
8
|
-
export { type StorageProvider, type StorageProviderBuilder, type StorageEntry, registerStorageProviderBuilder, } from './storage/storage-provider.js';
|
|
8
|
+
export { type GetEntryOptions, type StorageProvider, type StorageProviderBuilder, type StorageEntry, registerStorageProviderBuilder, } from './storage/storage-provider.js';
|
|
9
9
|
export { setSecretStoreForS3Credentials, setSecretStoreKeyForS3AccessKeyId, setSecretStoreKeyForS3SecretAccessKey, setS3CredentialsBuilder, } from './storage/s3-storage-provider.js';
|
|
10
10
|
export { type GetMatchingAssetOptions, type ProduceResult, type ResponseOverrides, type ServeFallbackOptions, type ServeRequestOptions, type StreamingServeResult, PublisherServer, } from './publisher-server/index.js';
|
|
11
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,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,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AAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,eAAe,GAChB,MAAM,6BAA6B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/publisher-server/index.ts"],"names":[],"mappings":"AAWA,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,KAAK,oBAAoB,EAc1B,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,uBAAuB,GAAG;IAEpC,SAAS,CAAC,EAAE,OAAO,CAAC;IAGpB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,oBAAoB,CAAC;AAEzB,wBAAgB,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,WAWpF;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/publisher-server/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,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AAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7F;YAEa,wBAAwB;YASxB,uBAAuB;IAyBrC,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,eAAe;YAQT,uBAAuB;YAwCvB,wBAAwB;CAiCvC"}
|
|
@@ -36,6 +36,8 @@ export function buildHeadersSubset(responseHeaders, keys) {
|
|
|
36
36
|
// * Content-Location, Date, ETag, and Vary
|
|
37
37
|
// * Cache-Control and Expires
|
|
38
38
|
const headersToPreserveForUnmodified = ['Content-Location', 'ETag', 'Vary', 'Cache-Control', 'Expires'];
|
|
39
|
+
// The time, in seconds, that a storage provider with a cache keeps a file (one year).
|
|
40
|
+
const FILE_CACHE_TTL = 31536000;
|
|
39
41
|
// RFC 9110 evaluates the preconditions only for a response that would be 2xx.
|
|
40
42
|
function isSuccessStatus(status) {
|
|
41
43
|
return status >= 200 && status < 300;
|
|
@@ -477,7 +479,10 @@ export class PublisherServer {
|
|
|
477
479
|
const baseHash = entry.key.slice(7);
|
|
478
480
|
const baseKey = `${this.publishId}_files_sha256_${baseHash}`;
|
|
479
481
|
const variantKey = variant != null ? `${baseKey}_${variant}` : baseKey;
|
|
480
|
-
|
|
482
|
+
// The key of a file has the hash of its content, so a cached copy is never
|
|
483
|
+
// out of date. A publish does not purge the tag; purge it to remove the
|
|
484
|
+
// cached copies of all files, for example after a bad upload.
|
|
485
|
+
const storageEntry = await this.timed(scope, 'asset', () => this.storageProvider.getEntry(variantKey, [`${this.publishId}-files`], { ttl: FILE_CACHE_TTL }));
|
|
481
486
|
if (storageEntry == null) {
|
|
482
487
|
return null;
|
|
483
488
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv-store-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/kv-store-provider.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAK/B,eAAO,MAAM,kBAAkB,EAAE,sBAMhC,CAAC;AAEF,qBAAa,eAAgB,YAAW,eAAe;IACrD,YAAY,WAAW,EAAE,MAAM,EAE9B;IAED,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"kv-store-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/kv-store-provider.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAK/B,eAAO,MAAM,kBAAkB,EAAE,sBAMhC,CAAC;AAEF,qBAAa,eAAgB,YAAW,eAAe;IACrD,YAAY,WAAW,EAAE,MAAM,EAE9B;IAED,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAGvB,QAAQ,CAAC,GAAG,EAAE,MAAM,0DAGzB;CACF"}
|
|
@@ -17,6 +17,7 @@ export class KvStoreProvider {
|
|
|
17
17
|
constructor(kvStoreName) {
|
|
18
18
|
this.kvStoreName = kvStoreName;
|
|
19
19
|
}
|
|
20
|
+
// The KV Store has its own cache, so the tags and the TTL are not used.
|
|
20
21
|
async getEntry(key) {
|
|
21
22
|
const kvStore = new KVStore(this.kvStoreName);
|
|
22
23
|
return await getKVStoreEntry(kvStore, key);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type StorageEntry, type StorageProvider, StorageProviderBuilder } from './storage-provider.js';
|
|
1
|
+
import { type GetEntryOptions, type StorageEntry, type StorageProvider, StorageProviderBuilder } from './storage-provider.js';
|
|
2
2
|
export type S3Credentials = {
|
|
3
3
|
accessKeyId: string;
|
|
4
4
|
secretAccessKey: string;
|
|
@@ -28,6 +28,6 @@ export declare class S3StorageProvider implements StorageProvider {
|
|
|
28
28
|
private readonly s3FastlyBackendName?;
|
|
29
29
|
objectUrl(key: string): URL;
|
|
30
30
|
fetchObject(key: string, requestInit: RequestInit): Promise<Response>;
|
|
31
|
-
getEntry(key: string, tags?: string[]): Promise<StorageEntry | null>;
|
|
31
|
+
getEntry(key: string, tags?: string[], options?: GetEntryOptions): Promise<StorageEntry | null>;
|
|
32
32
|
}
|
|
33
33
|
//# sourceMappingURL=s3-storage-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AAElF,eAAO,MAAM,kBAAkB,EAAE,sBAchC,CAAC;AAYF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,gBAAgB,EAAE,MAAM,QAEtE;AAED,wBAAgB,iCAAiC,CAAC,cAAc,EAAE,MAAM,QAEvE;AAED,wBAAgB,qCAAqC,CAAC,cAAc,EAAE,MAAM,QAE3E;AAGD,wBAAsB,iCAAiC,2BA4BtD;AAGD,wBAAgB,uBAAuB,CAAC,oBAAoB,EAAE,oBAAoB,QAEjF;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAA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6 +76,9 @@ let _s3CredentialsBuilder = buildS3CredentialsFromSecretStore;
|
|
|
76
76
|
export function setS3CredentialsBuilder(s3CredentialsBuilder) {
|
|
77
77
|
_s3CredentialsBuilder = s3CredentialsBuilder;
|
|
78
78
|
}
|
|
79
|
+
// The time, in seconds, that the readthrough cache keeps an object when
|
|
80
|
+
// getEntry() does not give a TTL (one hour).
|
|
81
|
+
const DEFAULT_CACHE_TTL = 3600;
|
|
79
82
|
// Attempts for a request that fails with a retryable status or a network error.
|
|
80
83
|
const MAX_ATTEMPTS = 5;
|
|
81
84
|
const RETRY_BASE_DELAY_MS = 100;
|
|
@@ -161,11 +164,11 @@ export class S3StorageProvider {
|
|
|
161
164
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
|
-
async getEntry(key, tags) {
|
|
167
|
+
async getEntry(key, tags, options) {
|
|
165
168
|
const response = await this.fetchObject(key, {
|
|
166
169
|
backend: this.s3FastlyBackendName ?? "s3_storage",
|
|
167
170
|
cacheOverride: new CacheOverride({
|
|
168
|
-
ttl:
|
|
171
|
+
ttl: options?.ttl ?? DEFAULT_CACHE_TTL,
|
|
169
172
|
surrogateKey: (tags ?? []).join(' ') || undefined,
|
|
170
173
|
}),
|
|
171
174
|
});
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { type StaticPublishRc } from '../../models/config/static-publish-rc.js';
|
|
2
|
+
export type GetEntryOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* How long, in seconds, a provider that caches what it reads (such as the
|
|
5
|
+
* S3 provider) keeps the entry. A provider that does not cache ignores it.
|
|
6
|
+
*/
|
|
7
|
+
ttl?: number;
|
|
8
|
+
};
|
|
2
9
|
export interface StorageProvider {
|
|
3
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Reads an entry. `tags` are the surrogate keys of the cached copy, if the
|
|
12
|
+
* provider caches what it reads.
|
|
13
|
+
*/
|
|
14
|
+
getEntry(key: string, tags?: string[], options?: GetEntryOptions): Promise<StorageEntry | null>;
|
|
4
15
|
}
|
|
5
16
|
export type StorageProviderBuilder = (config: StaticPublishRc) => (StorageProvider | null);
|
|
6
17
|
export interface StorageEntry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/storage-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/storage-provider.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EACrB,MAAM,0CAA0C,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CACjG;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;AAE3F,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,IAAI,IAAI,cAAc,CAAC;IAE3B;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAAC;IAExB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB;;OAEG;IACH,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpC;;OAEG;IACH,QAAQ,IAAI,WAAW,GAAG,IAAI,CAAC;IAE/B;;;OAGG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;CAC/B;AAKD,qBAAa,gBAAiB,SAAQ,QAAS,YAAW,YAAY;IACpE,YAAY,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAG/C;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAE3C,IAAI,IAAI,4CAEP;IAED,QAAQ,IAAI,WAAW,GAAG,IAAI,CAE7B;IACD,YAAY,IAAI,MAAM,GAAG,IAAI,CAE5B;CACF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,GAAG,cAAc,CAAC,UAAU,CAAC,CAuCvG;AAGD,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,sBAAsB,QAE7E;AAED,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,eAAe,mBAS7E"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/compute-js-static-publish",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.1.0-beta.
|
|
4
|
+
"version": "8.1.0-beta.9",
|
|
5
5
|
"description": "Static Publisher for Fastly Compute JavaScript",
|
|
6
6
|
"main": "build/server/server/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@fastly/js-compute": "^4.0
|
|
70
|
+
"@fastly/js-compute": "^4.4.0",
|
|
71
71
|
"@types/command-line-args": "^5.2.0",
|
|
72
72
|
"@types/glob-to-regexp": "^0.4.1",
|
|
73
73
|
"@types/node": "^20.11.0",
|