@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/DOCUMENTATION.md +112 -70
  3. package/MIGRATING.md +45 -15
  4. package/README.md +6 -5
  5. package/README.short.md +6 -5
  6. package/build/cli/cli/commands/manage/clean.js +1 -1
  7. package/build/cli/cli/commands/manage/collections/delete.js +1 -1
  8. package/build/cli/cli/commands/manage/collections/index.js +1 -1
  9. package/build/cli/cli/commands/manage/collections/list.js +1 -1
  10. package/build/cli/cli/commands/manage/collections/promote.js +1 -1
  11. package/build/cli/cli/commands/manage/collections/update-expiration.js +1 -1
  12. package/build/cli/cli/commands/manage/index.js +2 -2
  13. package/build/cli/cli/commands/manage/publish-content.js +1 -1
  14. package/build/cli/cli/commands/manage/status.js +1 -1
  15. package/build/cli/cli/commands/manage/template/index.js +1 -1
  16. package/build/cli/cli/commands/manage/template/init.d.ts.map +1 -1
  17. package/build/cli/cli/commands/manage/template/init.js +11 -4
  18. package/build/cli/cli/commands/scaffold/app-template.js +1 -1
  19. package/build/cli/cli/commands/scaffold/generate-app.d.ts +1 -1
  20. package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
  21. package/build/cli/cli/commands/scaffold/generate-app.js +1 -1
  22. package/build/cli/cli/commands/scaffold/index.js +5 -5
  23. package/build/cli/cli/hono/build.d.ts +21 -14
  24. package/build/cli/cli/hono/build.d.ts.map +1 -1
  25. package/build/cli/cli/hono/build.js +119 -76
  26. package/build/cli/cli/managed/app.js +4 -4
  27. package/build/cli/cli/managed/command-helpers.js +6 -6
  28. package/build/cli/cli/managed/project-file.js +6 -6
  29. package/build/cli/cli/managed/template-init.js +3 -3
  30. package/build/cli/cli/storage/kv-store-local-provider.d.ts +2 -2
  31. package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
  32. package/build/cli/cli/storage/kv-store-local-provider.js +2 -14
  33. package/build/cli/cli/storage/kv-store-provider.d.ts +2 -2
  34. package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
  35. package/build/cli/cli/storage/kv-store-provider.js +2 -1
  36. package/build/cli/cli/storage/s3-storage-provider.d.ts +2 -2
  37. package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
  38. package/build/cli/cli/storage/s3-storage-provider.js +4 -3
  39. package/build/cli/cli/storage/storage-provider.d.ts +3 -1
  40. package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
  41. package/build/cli/cli/storage/storage-provider.js +16 -0
  42. package/build/cli/cli/util/kv-store.d.ts +1 -1
  43. package/build/cli/cli/util/kv-store.d.ts.map +1 -1
  44. package/build/cli/models/config/static-publish-rc.d.ts +4 -3
  45. package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
  46. package/build/cli/models/config/template-settings.d.ts.map +1 -1
  47. package/build/cli/models/config/template-settings.js +34 -9
  48. package/build/server/hono/compose.d.ts +51 -0
  49. package/build/server/hono/compose.d.ts.map +1 -0
  50. package/build/server/hono/compose.js +93 -0
  51. package/build/server/hono/index.d.ts +1 -1
  52. package/build/server/hono/index.d.ts.map +1 -1
  53. package/build/server/hono/index.js +1 -1
  54. package/build/server/models/config/static-publish-rc.d.ts +4 -3
  55. package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
  56. package/build/server/server/index.d.ts +1 -1
  57. package/build/server/server/index.d.ts.map +1 -1
  58. package/build/server/server/publisher-server/index.d.ts.map +1 -1
  59. package/build/server/server/publisher-server/index.js +6 -1
  60. package/build/server/server/storage/kv-store-provider.d.ts.map +1 -1
  61. package/build/server/server/storage/kv-store-provider.js +1 -0
  62. package/build/server/server/storage/s3-storage-provider.d.ts +2 -2
  63. package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
  64. package/build/server/server/storage/s3-storage-provider.js +5 -2
  65. package/build/server/server/storage/storage-provider.d.ts +12 -1
  66. package/build/server/server/storage/storage-provider.d.ts.map +1 -1
  67. package/package.json +2 -2
  68. package/resources/template-init/hono/_example.ts +14 -13
  69. package/resources/templates/hono/package-lock.json +40 -40
  70. package/resources/templates/hono/package.json +2 -2
  71. package/resources/templates/hono/scripts/template_postinstall.js +5 -5
  72. package/resources/templates/hono/scripts/template_prebuild.js +6 -6
  73. package/resources/templates/hono/scripts/template_watch.js +5 -4
  74. package/resources/templates/hono/src/hono-compose.generated.d.ts +5 -0
  75. package/resources/templates/hono/src/index.ts +14 -14
  76. package/resources/templates/plain/package-lock.json +40 -40
  77. package/resources/templates/plain/package.json +2 -2
  78. package/build/server/hono/extensions.d.ts +0 -50
  79. package/build/server/hono/extensions.d.ts.map +0 -1
  80. package/build/server/hono/extensions.js +0 -70
  81. package/resources/templates/hono/src/hono-extensions.generated.d.ts +0 -5
@@ -4,8 +4,8 @@
4
4
  */
5
5
  // @fastly/compute-js-static-publish/hono/build: helpers for the scripts of the
6
6
  // hono template (scripts/template_prebuild.js, template_postinstall.js, and
7
- // template_watch.js), which run in Node at build time and during development. The scripts stay in an ejected app, so this
8
- // is a public API. Never import this module in the code of the app: the Wasm
7
+ // template_watch.js), which run in Node at build time and during development.
8
+ // The scripts stay in an ejected app, so this is a public API. Never import this module in the code of the app: the Wasm
9
9
  // bundle must not contain it.
10
10
  import fs from 'node:fs';
11
11
  import path from 'node:path';
@@ -13,47 +13,57 @@ import { pathToFileURL } from 'node:url';
13
13
  import { compareVersions } from '../managed/version-check.js';
14
14
  import { cliCommand } from '../util/package.js';
15
15
  // The file that the build writes into the app, and that src/index.ts imports.
16
- export const HONO_EXTENSIONS_MANIFEST = 'src/hono-extensions.generated.js';
17
- // The extensions folder when build.hono.extensionsDir is not set, relative to
16
+ export const PLUGINS_MANIFEST = 'src/hono-compose.generated.js';
17
+ // The folder of the plugins when build.hono.composeDir is not set, relative to
18
18
  // static-publish.rc.js.
19
- export const DEFAULT_HONO_EXTENSIONS_DIR = './hono-extensions';
19
+ export const DEFAULT_PLUGINS_DIR = './hono-compose';
20
20
  const THIS_PACKAGE = '@fastly/compute-js-static-publish';
21
21
  const MODULE_FILE = /\.(?:js|mjs|ts|mts)$/;
22
- // The modules of the extensions folder: the files directly in the folder with
23
- // the extension .js, .mjs, .ts, or .mts, in file-name order. Files that start
24
- // with '_' or '.', .d.ts files, and the files in subfolders (for example lib/)
25
- // are not modules. Throws if two modules have the same name.
26
- export function listHonoExtensionModules(extensionsDir) {
27
- if (!fs.existsSync(extensionsDir)) {
22
+ // A file with this name (with any extension of MODULE_FILE) is not a plugin.
23
+ // The name is kept for a later configuration file of the folder.
24
+ const RESERVED_NAME = 'index';
25
+ // The name of the folder of the plugins in earlier betas of 8.1.
26
+ const OLD_DIR_NAME = 'hono-extensions';
27
+ // The plugins of the folder: the files directly in the folder with the
28
+ // extension .js, .mjs, .ts, or .mts, in file-name order. Files that start with
29
+ // '_' or '.', .d.ts files, and the files in subfolders (for example lib/) are
30
+ // not plugins. Throws for a file with the reserved name index, and if two
31
+ // plugins have the same name.
32
+ export function listPlugins(composeDir) {
33
+ if (!fs.existsSync(composeDir)) {
28
34
  return [];
29
35
  }
30
- const modules = fs.readdirSync(extensionsDir, { withFileTypes: true })
36
+ const files = fs.readdirSync(composeDir, { withFileTypes: true })
31
37
  .filter(entry => entry.isFile() && !entry.name.startsWith('_') && !entry.name.startsWith('.'))
32
38
  .map(entry => entry.name)
33
39
  .filter(file => MODULE_FILE.test(file) && !/\.d\.[cm]?ts$/.test(file))
34
- .sort()
35
- .map(file => ({
36
- name: file.replace(/\.[cm]?[jt]s$/, '').replace(/^\d+-/, ''),
37
- file,
38
- }));
40
+ .sort();
41
+ const plugins = [];
39
42
  const seen = new Map();
40
- for (const module of modules) {
41
- const other = seen.get(module.name);
43
+ for (const file of files) {
44
+ const base = file.replace(/\.[cm]?[jt]s$/, '');
45
+ if (base === RESERVED_NAME) {
46
+ throw new Error(`hono-compose/${file}: '${RESERVED_NAME}' is a reserved name in this folder. ` +
47
+ `Rename the file, for example to 10-${file}.`);
48
+ }
49
+ const name = base.replace(/^\d+-/, '');
50
+ const other = seen.get(name);
42
51
  if (other != null) {
43
- throw new Error(`hono-extensions: ${other} and ${module.file} have the same module name '${module.name}'.`);
52
+ throw new Error(`hono-compose: ${other} and ${file} have the same plugin name '${name}'.`);
44
53
  }
45
- seen.set(module.name, module.file);
54
+ seen.set(name, file);
55
+ plugins.push({ name, file });
46
56
  }
47
- return modules;
57
+ return plugins;
48
58
  }
49
59
  function readJson(file) {
50
60
  return JSON.parse(fs.readFileSync(file, 'utf-8'));
51
61
  }
52
- // The packages that the app provides to the extensions: each package in the
62
+ // The packages that the app provides to the plugins: each package in the
53
63
  // dependencies of the app's package.json, and this package, each also with its
54
- // subpaths, and the fastly:* modules of the runtime. The bundle of the
55
- // extensions leaves their imports, so that the app's copy is the only copy.
56
- export function honoExtensionsExternals(appDir) {
64
+ // subpaths, and the fastly:* modules of the runtime. The bundle of the plugins
65
+ // leaves their imports, so that the app's copy is the only copy.
66
+ export function pluginsExternals(appDir) {
57
67
  const packageJson = readJson(path.resolve(appDir, 'package.json'));
58
68
  const names = new Set([...Object.keys(packageJson.dependencies ?? {}), THIS_PACKAGE]);
59
69
  return [...[...names].sort().flatMap(name => [name, `${name}/*`]), 'fastly:*'];
@@ -62,25 +72,44 @@ async function loadRc(appDir) {
62
72
  const rcPath = path.resolve(appDir, 'static-publish.rc.js');
63
73
  return (await import(pathToFileURL(rcPath).href)).default ?? {};
64
74
  }
65
- // The extensions folder of the app: build.hono.extensionsDir, relative to
75
+ // The folder of the plugins of the app: build.hono.composeDir, relative to
66
76
  // static-publish.rc.js.
67
- export function honoExtensionsDir(appDir, rc) {
68
- return path.resolve(appDir, rc.build?.hono?.extensionsDir ?? DEFAULT_HONO_EXTENSIONS_DIR);
77
+ export function pluginsDir(appDir, rc) {
78
+ return path.resolve(appDir, rc.build?.hono?.composeDir ?? DEFAULT_PLUGINS_DIR);
69
79
  }
70
80
  const GENERATED_HEADER = '// Generated by @fastly/compute-js-static-publish at each build. Do not edit.\n';
71
- function entrySource(modules) {
72
- const lines = modules.map((module, i) => `import m${i} from ${JSON.stringify(`./${module.file}`)};`);
73
- const entries = modules
74
- .map((module, i) => ` { name: ${JSON.stringify(module.name)}, file: ${JSON.stringify(module.file)}, module: m${i} },`)
81
+ function entrySource(plugins) {
82
+ const lines = plugins.map((plugin, i) => `import p${i} from ${JSON.stringify(`./${plugin.file}`)};`);
83
+ const entries = plugins
84
+ .map((plugin, i) => ` { name: ${JSON.stringify(plugin.name)}, file: ${JSON.stringify(plugin.file)}, plugin: p${i} },`)
75
85
  .join('\n');
76
- lines.push(`export const extensions = [\n${entries}\n];`);
86
+ lines.push(`export const plugins = [\n${entries}\n];`);
77
87
  return lines.join('\n') + '\n';
78
88
  }
89
+ // The names of earlier betas of 8.1 stop the build, with a message that gives
90
+ // the new name, so that a build never skips the plugins without a message.
91
+ // Removed in v9.
92
+ function checkOldNames(rc, composeDir) {
93
+ const errors = [];
94
+ if (rc.build?.hono?.extensionsDir !== undefined) {
95
+ errors.push('build.hono.extensionsDir is now build.hono.composeDir.');
96
+ }
97
+ if (rc.templateOptions?.hono?.extensions !== undefined) {
98
+ errors.push('templateOptions.hono.extensions is now templateOptions.hono.compose.plugins.');
99
+ }
100
+ const oldDir = path.resolve(path.dirname(composeDir), OLD_DIR_NAME);
101
+ if (!fs.existsSync(composeDir) && fs.existsSync(oldDir) && fs.readdirSync(oldDir).length > 0) {
102
+ errors.push(`The folder ${OLD_DIR_NAME}/ is now hono-compose/. Rename it (${oldDir}).`);
103
+ }
104
+ if (errors.length > 0) {
105
+ throw new Error(`The plugins of the hono template have new names: ${errors.join(' ')}`);
106
+ }
107
+ }
79
108
  // Writes the manifest, but only if its content changes, so that a watcher of
80
109
  // the app (fastly compute serve --watch) does not see a change that is not
81
110
  // one. Returns true if it wrote the file.
82
111
  function writeManifest(appDir, content) {
83
- const file = path.resolve(appDir, HONO_EXTENSIONS_MANIFEST);
112
+ const file = path.resolve(appDir, PLUGINS_MANIFEST);
84
113
  if (fs.existsSync(file) && fs.readFileSync(file, 'utf-8') === content) {
85
114
  return false;
86
115
  }
@@ -88,10 +117,10 @@ function writeManifest(appDir, content) {
88
117
  fs.writeFileSync(file, content, 'utf-8');
89
118
  return true;
90
119
  }
91
- // Writes the manifest with no modules. Then src/index.ts can import it before
120
+ // Writes the manifest with no plugins. Then src/index.ts can import it before
92
121
  // the first build, so that an editor does not show an error.
93
- export function writeHonoExtensionsStub(options) {
94
- return writeManifest(options.appDir, GENERATED_HEADER + 'export const extensions = [];\n');
122
+ export function writePluginsStub(options) {
123
+ return writeManifest(options.appDir, GENERATED_HEADER + 'export const plugins = [];\n');
95
124
  }
96
125
  // A small part of semver ranges: ^, ~, >=, an exact version, and *. Returns
97
126
  // null for a range that this cannot read, so that no warning is given.
@@ -130,10 +159,10 @@ function satisfiesRange(version, range) {
130
159
  }
131
160
  }
132
161
  // The warnings about the packages that the app provides: a range in the
133
- // extensions folder's package.json that does not include the version that the
134
- // app has. The build uses the app's copy, so this is only a warning.
135
- export function checkProvidedVersions(appDir, extensionsDir) {
136
- const folderPackageJsonPath = path.resolve(extensionsDir, 'package.json');
162
+ // package.json of the folder of the plugins that does not include the version
163
+ // that the app has. The build uses the app's copy, so this is only a warning.
164
+ export function checkProvidedVersions(appDir, composeDir) {
165
+ const folderPackageJsonPath = path.resolve(composeDir, 'package.json');
137
166
  if (!fs.existsSync(folderPackageJsonPath)) {
138
167
  return [];
139
168
  }
@@ -143,7 +172,7 @@ export function checkProvidedVersions(appDir, extensionsDir) {
143
172
  ...folderPackageJson.dependencies,
144
173
  ...folderPackageJson.peerDependencies,
145
174
  };
146
- const provided = new Set(honoExtensionsExternals(appDir).filter(x => !x.endsWith('/*') && x !== 'fastly:*'));
175
+ const provided = new Set(pluginsExternals(appDir).filter(x => !x.endsWith('/*') && x !== 'fastly:*'));
147
176
  const warnings = [];
148
177
  for (const [name, range] of Object.entries(ranges)) {
149
178
  if (!provided.has(name)) {
@@ -155,68 +184,69 @@ export function checkProvidedVersions(appDir, extensionsDir) {
155
184
  }
156
185
  const version = readJson(installed).version;
157
186
  if (satisfiesRange(version, range) === false) {
158
- warnings.push(`hono-extensions/package.json expects ${name} ${range}, but the app provides ${version}. ` +
187
+ warnings.push(`hono-compose/package.json expects ${name} ${range}, but the app provides ${version}. ` +
159
188
  `The build uses the app's ${name}. Run: ${cliCommand()} template init`);
160
189
  }
161
190
  }
162
191
  return warnings;
163
192
  }
164
- // Bundles the modules of the extensions folder into one file of the app
165
- // (HONO_EXTENSIONS_MANIFEST), which src/index.ts imports. The packages that
166
- // the app provides stay imports (see honoExtensionsExternals()), so that the
167
- // Wasm bundle has one copy of each. Without the folder, or without modules, it
168
- // writes the manifest with no modules. It writes the file only if its content
169
- // changes. Returns true if it wrote the file.
170
- export async function bundleHonoExtensions(options) {
193
+ // Bundles the plugins of the folder into one file of the app
194
+ // (PLUGINS_MANIFEST), which src/index.ts imports. The packages that the app
195
+ // provides stay imports (see pluginsExternals()), so that the Wasm bundle has
196
+ // one copy of each. Without the folder, or without plugins, it writes the
197
+ // manifest with no plugins. It writes the file only if its content changes.
198
+ // Returns true if it wrote the file.
199
+ export async function bundlePlugins(options) {
171
200
  const { appDir, esbuild } = options;
172
201
  const rc = await loadRc(appDir);
173
- const extensionsDir = honoExtensionsDir(appDir, rc);
174
- if (!fs.existsSync(extensionsDir)) {
175
- return writeHonoExtensionsStub({ appDir });
202
+ const composeDir = pluginsDir(appDir, rc);
203
+ checkOldNames(rc, composeDir);
204
+ if (!fs.existsSync(composeDir)) {
205
+ return writePluginsStub({ appDir });
176
206
  }
177
- const modules = listHonoExtensionModules(extensionsDir);
178
- const names = new Set(modules.map(module => module.name));
179
- for (const name of Object.keys(rc.templateOptions?.hono?.extensions ?? {})) {
207
+ const plugins = listPlugins(composeDir);
208
+ const names = new Set(plugins.map(plugin => plugin.name));
209
+ for (const name of Object.keys(rc.templateOptions?.hono?.compose?.plugins ?? {})) {
180
210
  if (!names.has(name)) {
181
- console.warn(`⚠️ templateOptions.hono.extensions.${name}: there is no module '${name}' in hono-extensions/.`);
211
+ console.warn(`⚠️ templateOptions.hono.compose.plugins.${name}: there is no plugin '${name}' in hono-compose/.`);
182
212
  }
183
213
  }
184
- for (const warning of checkProvidedVersions(appDir, extensionsDir)) {
214
+ for (const warning of checkProvidedVersions(appDir, composeDir)) {
185
215
  console.warn(`⚠️ ${warning}`);
186
216
  }
187
- if (modules.length === 0) {
188
- return writeHonoExtensionsStub({ appDir });
217
+ if (plugins.length === 0) {
218
+ return writePluginsStub({ appDir });
189
219
  }
190
220
  const result = await esbuild.build({
191
- stdin: { contents: entrySource(modules), resolveDir: extensionsDir, sourcefile: 'hono-extensions.js', loader: 'js' },
221
+ stdin: { contents: entrySource(plugins), resolveDir: composeDir, sourcefile: 'hono-compose.js', loader: 'js' },
192
222
  bundle: true,
193
223
  format: 'esm',
194
224
  // As js-compute's own bundler, so that packages resolve the same way.
195
225
  conditions: ['fastly'],
196
- external: honoExtensionsExternals(appDir),
197
- outfile: path.resolve(appDir, HONO_EXTENSIONS_MANIFEST),
226
+ external: pluginsExternals(appDir),
227
+ outfile: path.resolve(appDir, PLUGINS_MANIFEST),
198
228
  banner: { js: GENERATED_HEADER.trimEnd() },
199
229
  logLevel: 'warning',
200
230
  write: false,
201
231
  });
202
232
  const text = result.outputFiles?.[0]?.text;
203
233
  if (text == null) {
204
- throw new Error('hono-extensions: esbuild gave no output.');
234
+ throw new Error('hono-compose: esbuild gave no output.');
205
235
  }
206
236
  return writeManifest(appDir, text);
207
237
  }
208
238
  const WATCH_DELAY_MS = 100;
209
- // Watches the extensions folder, and bundles the modules again after each
210
- // change (see bundleHonoExtensions()). fastly compute serve --watch watches only
239
+ // Watches the folder of the plugins, and bundles the plugins again after each
240
+ // change (see bundlePlugins()). fastly compute serve --watch watches only
211
241
  // the app directory: a new manifest is the change that makes it build the app
212
242
  // again. All files in the folder count, except node_modules/, so that a new
213
- // module and a changed helper are found. Imports from outside the folder are
243
+ // plugin and a changed helper are found. Imports from outside the folder are
214
244
  // not watched. While the folder does not exist, it checks each second if the
215
245
  // folder was made. A failed bundle shows the error and keeps the manifest that
216
246
  // the app has.
217
- export async function watchHonoExtensions(options) {
247
+ export async function watchPlugins(options) {
218
248
  const { appDir } = options;
219
- const extensionsDir = honoExtensionsDir(appDir, await loadRc(appDir));
249
+ const composeDir = pluginsDir(appDir, await loadRc(appDir));
220
250
  let closed = false;
221
251
  let folderWatcher;
222
252
  let timer;
@@ -224,12 +254,12 @@ export async function watchHonoExtensions(options) {
224
254
  let again = false;
225
255
  const bundle = async () => {
226
256
  try {
227
- if (await bundleHonoExtensions(options)) {
228
- console.log(`🔄 ${HONO_EXTENSIONS_MANIFEST} changed.`);
257
+ if (await bundlePlugins(options)) {
258
+ console.log(`🔄 ${PLUGINS_MANIFEST} changed.`);
229
259
  }
230
260
  }
231
261
  catch (err) {
232
- console.error(`❌ Could not bundle the Hono extensions: ${String(err instanceof Error ? err.message : err)}`);
262
+ console.error(`❌ Could not bundle the plugins: ${String(err instanceof Error ? err.message : err)}`);
233
263
  }
234
264
  };
235
265
  // One bundle at a time. A change during a bundle starts one more bundle.
@@ -259,9 +289,9 @@ export async function watchHonoExtensions(options) {
259
289
  if (closed) {
260
290
  return;
261
291
  }
262
- const exists = fs.existsSync(extensionsDir);
292
+ const exists = fs.existsSync(composeDir);
263
293
  if (exists && folderWatcher == null) {
264
- folderWatcher = fs.watch(extensionsDir, { recursive: true }, (_event, file) => {
294
+ folderWatcher = fs.watch(composeDir, { recursive: true }, (_event, file) => {
265
295
  if (file == null || !file.toString().split(/[\\/]/).includes('node_modules')) {
266
296
  schedule();
267
297
  }
@@ -281,7 +311,7 @@ export async function watchHonoExtensions(options) {
281
311
  // While the folder does not exist, a check each second. The timer also keeps
282
312
  // the process of the watch script alive until close().
283
313
  const poll = setInterval(() => {
284
- if (folderWatcher == null && running == null && fs.existsSync(extensionsDir)) {
314
+ if (folderWatcher == null && running == null && fs.existsSync(composeDir)) {
285
315
  schedule();
286
316
  }
287
317
  }, 1000);
@@ -296,3 +326,16 @@ export async function watchHonoExtensions(options) {
296
326
  },
297
327
  };
298
328
  }
329
+ // The names of earlier betas of 8.1. Each one throws, so that the scripts of
330
+ // an ejected app that use an old name stop with a message that gives the new
331
+ // name. Removed in v9.
332
+ const OLD_SCRIPTS_MESSAGE = 'The plugins of the hono template have new names: update scripts/ and src/index.ts of the app as MIGRATING.md shows.';
333
+ export function bundleHonoExtensions(..._args) {
334
+ throw new Error(`${OLD_SCRIPTS_MESSAGE} bundleHonoExtensions() is now bundlePlugins().`);
335
+ }
336
+ export function watchHonoExtensions(..._args) {
337
+ throw new Error(`${OLD_SCRIPTS_MESSAGE} watchHonoExtensions() is now watchPlugins().`);
338
+ }
339
+ export function writeHonoExtensionsStub(..._args) {
340
+ throw new Error(`${OLD_SCRIPTS_MESSAGE} writeHonoExtensionsStub() is now writePluginsStub().`);
341
+ }
@@ -135,11 +135,11 @@ export async function managedAppState(projectDir, project) {
135
135
  managedAppFiles(generateApp({ ...appConfig, fastlyToml: { ...appConfig.fastlyToml, local_server: undefined } })) :
136
136
  files;
137
137
  const cliPackageDir = getOwnPackageDir();
138
- // The extensions folder of the hono template is part of the app that deploy
138
+ // The folder of the plugins of the hono template is part of the app that deploy
139
139
  // deploys, so a change to it changes the fingerprint.
140
- const extensionsDir = appConfig.build?.hono?.extensionsDir;
141
- const fingerprintFiles = extensionsDir != null ?
142
- { ...deployedFiles, ...folderFilesForFingerprint(extensionsDir, '<hono-extensions>') } :
140
+ const composeDir = appConfig.build?.hono?.composeDir;
141
+ const fingerprintFiles = composeDir != null ?
142
+ { ...deployedFiles, ...folderFilesForFingerprint(composeDir, '<hono-compose>') } :
143
143
  deployedFiles;
144
144
  const fingerprint = computeFingerprint(fingerprintFiles, {
145
145
  staticPublishVersion: getOwnVersion(),
@@ -8,7 +8,7 @@ import { PROJECT_FILE_NAME } from '../../models/config/static-publish-project.js
8
8
  import { LoadConfigError, detectProjectMode, loadProjectFile } from '../util/config.js';
9
9
  import { cliCommand, getOwnVersion } from '../util/package.js';
10
10
  import { DEFAULT_APP_TEMPLATE_NAME } from '../commands/scaffold/app-template.js';
11
- import { DEFAULT_HONO_EXTENSIONS_DIR } from '../hono/build.js';
11
+ import { DEFAULT_PLUGINS_DIR } from '../hono/build.js';
12
12
  import { writeBackStaticPublishVersion } from './project-edit.js';
13
13
  import { checkProjectVersion, versionCheckError } from './version-check.js';
14
14
  import { fail, recordFailure } from '../util/output.js';
@@ -35,15 +35,15 @@ export async function loadManagedProject(command, ejectedHint) {
35
35
  return null;
36
36
  }
37
37
  }
38
- // For the hono template: a hint when the extensions folder does not exist. The
39
- // app works without it.
38
+ // For the hono template: a hint when the folder of the plugins does not exist.
39
+ // The app works without it.
40
40
  export function showTemplateFolderHint(project) {
41
41
  if ((project.managed.template ?? DEFAULT_APP_TEMPLATE_NAME) !== 'hono') {
42
42
  return;
43
43
  }
44
- const extensionsDir = project.rc.build?.hono?.extensionsDir ?? DEFAULT_HONO_EXTENSIONS_DIR;
45
- if (!fs.existsSync(path.resolve(extensionsDir))) {
46
- console.log(`💡 No ${extensionsDir} folder. To add your own Hono middleware and routes, run: ${cliCommand()} template init`);
44
+ const composeDir = project.rc.build?.hono?.composeDir ?? DEFAULT_PLUGINS_DIR;
45
+ if (!fs.existsSync(path.resolve(composeDir))) {
46
+ console.log(`💡 No ${composeDir} folder. To add your own Hono middleware and routes with plugins, run: ${cliCommand()} template init`);
47
47
  }
48
48
  }
49
49
  // Check managed.staticPublishVersion against the running CLI. With
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import * as path from 'node:path';
6
6
  import { isS3StorageConfigRc } from '../../models/config/static-publish-rc.js';
7
- import { DEFAULT_HONO_EXTENSIONS_DIR } from '../hono/build.js';
7
+ import { DEFAULT_PLUGINS_DIR } from '../hono/build.js';
8
8
  import { getKvStoreConfigFromRc } from '../../models/config/kv-store-config.js';
9
9
  import { DEFAULT_APP_INFO } from '../commands/scaffold/generate-app.js';
10
10
  import { renderAppResource } from '../commands/scaffold/render.js';
@@ -33,9 +33,9 @@ export function renderProjectFile(config, projectDir, staticPublishVersion) {
33
33
  defaultCollectionName: config.defaultCollectionName,
34
34
  staticPublisherWorkingDir: relative(config.staticPublisherWorkingDir),
35
35
  collectionSelection: config.collectionSelection,
36
- // The extensions folder only if it is not the default, next to this file.
37
- build: config.build?.hono != null && config.build.hono.extensionsDir !== path.resolve(projectDir, DEFAULT_HONO_EXTENSIONS_DIR) ?
38
- { hono: { extensionsDir: relative(config.build.hono.extensionsDir) } } :
36
+ // The folder of the plugins only if it is not the default, next to this file.
37
+ build: config.build?.hono != null && config.build.hono.composeDir !== path.resolve(projectDir, DEFAULT_PLUGINS_DIR) ?
38
+ { hono: { composeDir: relative(config.build.hono.composeDir) } } :
39
39
  undefined,
40
40
  templateOptions: config.templateOptions,
41
41
  rootDir: relative(config.rootDir),
@@ -114,10 +114,10 @@ export function appConfigFromProject(rc, publishContent, managed, options) {
114
114
  generatedFrom: undefined,
115
115
  ...(rc.collectionSelection != null ? { collectionSelection: rc.collectionSelection } : {}),
116
116
  ...(managed.fastlyToml != null ? { fastlyToml: managed.fastlyToml } : {}),
117
- // The hono template: the extensions folder, relative to the project file
117
+ // The hono template: the folder of the plugins, relative to the project file
118
118
  // (default: next to it). The generated rc gets it relative to the app dir.
119
119
  ...(options.template.name === 'hono' ?
120
- { build: { hono: { extensionsDir: path.resolve(projectDir, rc.build?.hono?.extensionsDir ?? DEFAULT_HONO_EXTENSIONS_DIR) } } } :
120
+ { build: { hono: { composeDir: path.resolve(projectDir, rc.build?.hono?.composeDir ?? DEFAULT_PLUGINS_DIR) } } } :
121
121
  {}),
122
122
  // Only the options of the app's template, so that a change to the options
123
123
  // of another template does not change the app.
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT license. See LICENSE file for details.
4
4
  */
5
5
  // template init: makes or updates the folder of a template, for example
6
- // hono-extensions/ of the hono template. The starter files are in
6
+ // hono-compose/ of the hono template. The starter files are in
7
7
  // resources/template-init/<template>/. The template owns the peer dependencies
8
8
  // on the packages that it provides; the customer owns everything else.
9
9
  import fs from 'node:fs';
@@ -56,7 +56,7 @@ export function providedVersions(templateName, appNodeModulesDir, ownVersion) {
56
56
  result[THIS_PACKAGE] = ownVersion;
57
57
  return result;
58
58
  }
59
- // What template init does for a folder. It never changes a module of the
59
+ // What template init does for a folder. It never changes a plugin of the
60
60
  // customer: only package.json (the peer dependencies on the provided packages,
61
61
  // merged), and the starter files that are missing (or all of them, with reset).
62
62
  export function planTemplateInit(templateName, folderDir, provided, options) {
@@ -78,7 +78,7 @@ export function planTemplateInit(templateName, folderDir, provided, options) {
78
78
  }
79
79
  const typescriptRange = loadAppTemplate(templateName).devDependencies.typescript;
80
80
  const packageJson = {
81
- name: `${templateName}-extensions`,
81
+ name: `${templateName}-compose`,
82
82
  private: true,
83
83
  type: 'module',
84
84
  ...existing,
@@ -1,4 +1,4 @@
1
- import { type StorageEntry, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type ApplyBatchOptions } from './storage-provider.js';
1
+ import { type StorageEntry, type StorageEntryData, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type ApplyBatchOptions } from './storage-provider.js';
2
2
  export declare const buildStoreProvider: StorageProviderBuilder;
3
3
  export declare class KvStoreLocalProvider implements StorageProvider {
4
4
  constructor(storeFile: string, computeAppDir: string);
@@ -7,7 +7,7 @@ export declare class KvStoreLocalProvider implements StorageProvider {
7
7
  getStorageKeys(prefix?: string): Promise<string[] | null>;
8
8
  getStorageEntry(key: string): Promise<StorageEntry | null>;
9
9
  getStorageEntryInfo(key: string): Promise<StorageEntry | null>;
10
- submitStorageEntry(key: string, filePath: string, data: ReadableStream<Uint8Array> | Uint8Array | string | null | undefined, metadata?: Record<string, string>): Promise<void>;
10
+ submitStorageEntry(key: string, filePath: string, data: StorageEntryData, metadata?: Record<string, string>): Promise<void>;
11
11
  deleteStorageEntry(key: string): Promise<void>;
12
12
  applyBatch(batch: StorageProviderBatch, _options?: ApplyBatchOptions): Promise<void>;
13
13
  doConcurrentParallel<TObject extends {
@@ -1 +1 @@
1
- {"version":3,"file":"kv-store-local-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/kv-store-local-provider.ts"],"names":[],"mappings":"AA2BA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAE3B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAK/B,eAAO,MAAM,kBAAkB,EAAE,sBAkBhC,CAAC;AAEF,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,YACE,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EAItB;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAEzB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAM9D;IAEK,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAc/D;IAEK,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAcnE;IAEK,kBAAkB,CACtB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACzE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAoBf;IAEK,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOnD;IAEK,UAAU,CAAC,KAAK,EAAE,oBAAoB,EAAE,QAAQ,GAAE,iBAA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nE;IAEK,kBAAkB,CACtB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,gBAAgB,EACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAUf;IAEK,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOnD;IAEK,UAAU,CAAC,KAAK,EAAE,oBAAoB,EAAE,QAAQ,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB7F;IAEK,oBAAoB,CAAC,OAAO,SAAS;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EACxD,OAAO,EAAE,OAAO,EAAE,EAClB,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC/D,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,GAAE,OAAe,GAC5B,OAAO,CAAC,IAAI,CAAC,CAUf;IAED,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1C;CACF"}
@@ -9,6 +9,7 @@ import { getKvStoreConfigFromRc, } from '../../models/config/kv-store-config.js'
9
9
  import { applyKVStoreEntriesChunks, chunkSizes, KV_STORE_CHUNK_SIZE, } from '../util/kv-store-items.js';
10
10
  import { getLocalKvStoreEntry, getLocalKVStoreKeys, localKvStoreDeleteEntry, localKvStoreSubmitEntry, writeKVStoreEntriesForLocal, } from '../util/kv-store-local-server.js';
11
11
  import { concurrentParallel } from '../util/retryable.js';
12
+ import { storageEntryDataToBytes, } from './storage-provider.js';
12
13
  import { kvStoreEntryToStorageEntry, } from './kv-store-provider.js';
13
14
  export const buildStoreProvider = (config, context) => {
14
15
  if (isKvStoreConfigRc(config) && context.localMode) {
@@ -45,20 +46,7 @@ export class KvStoreLocalProvider {
45
46
  return kvStoreEntryToStorageEntry(kvStoreEntry);
46
47
  }
47
48
  async submitStorageEntry(key, filePath, data, metadata) {
48
- let fileData;
49
- if (data == null) {
50
- fileData = new Uint8Array(0);
51
- }
52
- else if (data instanceof ReadableStream) {
53
- fileData = Buffer.from(await new Response(data).arrayBuffer());
54
- }
55
- else if (typeof data === 'string') {
56
- fileData = new TextEncoder().encode(data);
57
- }
58
- else {
59
- fileData = data;
60
- }
61
- fs.writeFileSync(filePath, fileData);
49
+ fs.writeFileSync(filePath, await storageEntryDataToBytes(data));
62
50
  await localKvStoreSubmitEntry(this.storeFile, key, path.relative(this.computeAppDir, filePath), metadata != null ? JSON.stringify(metadata) : undefined);
63
51
  }
64
52
  async deleteStorageEntry(key) {
@@ -1,6 +1,6 @@
1
1
  import { type FastlyApiContext } from '../util/api-token.js';
2
2
  import { type KvStoreEntryInfo } from '../util/kv-store.js';
3
- import { type StorageEntry, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type StorageProviderBatchEntry, type ApplyBatchOptions } from './storage-provider.js';
3
+ import { type StorageEntry, type StorageEntryData, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type StorageProviderBatchEntry, type ApplyBatchOptions } from './storage-provider.js';
4
4
  export declare const buildStoreProvider: StorageProviderBuilder;
5
5
  export declare class KvStoreProvider implements StorageProvider {
6
6
  constructor(storeName: string, fastlyApiToken: string);
@@ -9,7 +9,7 @@ export declare class KvStoreProvider implements StorageProvider {
9
9
  getStorageKeys(prefix?: string): Promise<string[] | null>;
10
10
  getStorageEntry(key: string): Promise<StorageEntry | null>;
11
11
  getStorageEntryInfo(key: string): Promise<StorageEntry | null>;
12
- submitStorageEntry(key: string, _filePath: string, data: ReadableStream<Uint8Array> | Uint8Array | string | null | undefined, metadata?: Record<string, string>): Promise<void>;
12
+ submitStorageEntry(key: string, _filePath: string, data: StorageEntryData, metadata?: Record<string, string>): Promise<void>;
13
13
  deleteStorageEntry(key: string): Promise<void>;
14
14
  applyBatch(batch: StorageProviderBatch, options?: ApplyBatchOptions): Promise<void>;
15
15
  uploadEntries(entries: StorageProviderBatchEntry[], verbose?: boolean): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"kv-store-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/kv-store-provider.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,KAAK,gBAAgB,EAMtB,MAAM,qBAAqB,CAAC;AAa7B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAE3B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,kBAAkB,EAAE,sBAsBhC,CAAC;AAEF,qBAAa,eAAgB,YAAW,eAAe;IACrD,YACE,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EAIvB;IAED,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IAEd,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAQ9D;IAEK,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAa/D;IAEK,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAenE;IAEK,kBAAkB,CACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACzE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,I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5B,OAAO,CAAC,IAAI,CAAC,CAmBf;IAED,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1C;CAEF;AAED,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,gBAAgB,gBA6B/B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,iCAiCpD"}
@@ -11,6 +11,7 @@ import { ProgressLog } from '../util/progress.js';
11
11
  import { getKvStoreEntry, getKVStoreKeys, kvStoreDeleteEntry, kvStoreSubmitEntry, kvStoreSubmitBatch, } from '../util/kv-store.js';
12
12
  import { applyKVStoreEntriesChunks, chunkSizes, packNdjsonBatches, ndjsonLineForBatchEntry, entriesToUpload, KV_STORE_CHUNK_SIZE, } from '../util/kv-store-items.js';
13
13
  import { concurrentParallel, makeRetryable, } from '../util/retryable.js';
14
+ import { storageEntryDataToBytes, } from './storage-provider.js';
14
15
  export const buildStoreProvider = (config, context) => {
15
16
  if (isKvStoreConfigRc(config) && !context.localMode) {
16
17
  console.log(` Working on the Fastly KV Store...`);
@@ -50,7 +51,7 @@ export class KvStoreProvider {
50
51
  return kvStoreEntryToStorageEntry(kvStoreEntry);
51
52
  }
52
53
  async submitStorageEntry(key, _filePath, data, metadata) {
53
- await kvStoreSubmitEntry(this.fastlyApiContext, this.kvStoreName, key, data ?? new Uint8Array(0), metadata != null ? JSON.stringify(metadata) : undefined);
54
+ await kvStoreSubmitEntry(this.fastlyApiContext, this.kvStoreName, key, await storageEntryDataToBytes(data), metadata != null ? JSON.stringify(metadata) : undefined);
54
55
  }
55
56
  async deleteStorageEntry(key) {
56
57
  await kvStoreDeleteEntry(this.fastlyApiContext, this.kvStoreName, key);
@@ -1,6 +1,6 @@
1
1
  import { S3Client } from '@aws-sdk/client-s3';
2
2
  import { type Command, type HttpHandlerOptions } from '@aws-sdk/types';
3
- import { type StorageEntry, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type ApplyBatchOptions } from './storage-provider.js';
3
+ import { type StorageEntry, type StorageEntryData, type StorageProvider, type StorageProviderBuilder, type StorageProviderBatch, type ApplyBatchOptions } from './storage-provider.js';
4
4
  type CommandOutput<C> = C extends Command<any, any, any, infer O, any> ? O : never;
5
5
  export declare const DEFAULT_S3_UPLOAD_CONCURRENCY = 64;
6
6
  export declare const S3_LOCAL_MODE_ERROR = "--local is available only in KV Store mode. In S3 mode, the commands always use the bucket in static-publish.rc.js.";
@@ -19,7 +19,7 @@ export declare class S3StorageProvider implements StorageProvider {
19
19
  getStorageKeys(prefix?: string): Promise<string[] | null>;
20
20
  getStorageEntry(key: string): Promise<StorageEntry | null>;
21
21
  getStorageEntryInfo(key: string): Promise<StorageEntry | null>;
22
- submitStorageEntry(key: string, _filePath: string, data: ReadableStream<Uint8Array> | Uint8Array | string | null | undefined, metadata?: Record<string, string>): Promise<void>;
22
+ submitStorageEntry(key: string, _filePath: string, data: StorageEntryData, metadata?: Record<string, string>): Promise<void>;
23
23
  deleteStorageEntry(key: string): Promise<void>;
24
24
  applyBatch(batch: StorageProviderBatch, options?: ApplyBatchOptions): Promise<void>;
25
25
  doConcurrentParallel<TObject extends {
@@ -1 +1 @@
1
- {"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/cli/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAQA,OAAO,EAUL,QAAQ,EAIT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AASxB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAE3B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAc/B,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,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,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAuBnE;IAEK,kBAAkB,CACtB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,gBAAgB,EACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAWf;IAEK,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnD;IAEK,UAAU,CAAC,KAAK,EAAE,oBAAoB,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6B5F;IAEK,oBAAoB,CAAC,OAAO,SAAS;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EACxD,OAAO,EAAE,OAAO,EAAE,EAClB,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC/D,aAAa,GAAE,MAAW,EAC1B,YAAY,GAAE,OAAe,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiBf;IAED,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExC;IAED,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1C;CAEF"}
@@ -8,6 +8,7 @@ import https from 'node:https';
8
8
  import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client, S3ServiceException, paginateListObjectsV2, } from '@aws-sdk/client-s3';
9
9
  import { isS3StorageConfigRc, } from '../../models/config/static-publish-rc.js';
10
10
  import { getS3StorageConfigFromRc, } from '../../models/config/s3-storage-config.js';
11
+ import { storageEntryDataToBytes, } from './storage-provider.js';
11
12
  import { entriesToUpload } from '../util/kv-store-items.js';
12
13
  import { loadS3Credentials, } from '../util/s3-credentials.js';
13
14
  import { concurrentParallel, makeRetryable, } from '../util/retryable.js';
@@ -27,9 +28,9 @@ export const buildStoreProvider = async (config, context) => {
27
28
  if (context.localMode) {
28
29
  throw new Error(S3_LOCAL_MODE_ERROR);
29
30
  }
30
- console.log(` Working on S3 (or compatible) storage (BETA)...`);
31
+ console.log(` Working on S3 (or compatible) storage...`);
31
32
  const { region, bucket, endpoint, } = getS3StorageConfigFromRc(config);
32
- console.log(` | Using S3 storage (BETA)`);
33
+ console.log(` | Using S3 storage`);
33
34
  console.log(` Region : ${region}`);
34
35
  console.log(` Bucket : ${bucket}`);
35
36
  console.log(` Endpoint: ${endpoint ?? 'default'}`);
@@ -164,7 +165,7 @@ export class S3StorageProvider {
164
165
  const input = {
165
166
  Bucket: this.s3Bucket, // required
166
167
  Key: key, // required
167
- Body: data ?? undefined,
168
+ Body: await storageEntryDataToBytes(data),
168
169
  Metadata: metadata,
169
170
  };
170
171
  const command = new PutObjectCommand(input);