@fastly/compute-js-static-publish 6.3.0 → 7.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +31 -586
  3. package/README.short.md +53 -0
  4. package/build/cli/commands/clean.d.ts +2 -0
  5. package/build/cli/commands/clean.d.ts.map +1 -0
  6. package/build/cli/commands/clean.js +121 -0
  7. package/build/cli/commands/collections/delete.d.ts +2 -0
  8. package/build/cli/commands/collections/delete.d.ts.map +1 -0
  9. package/build/cli/commands/collections/delete.js +88 -0
  10. package/build/cli/commands/collections/index.d.ts +2 -0
  11. package/build/cli/commands/collections/index.d.ts.map +1 -0
  12. package/build/cli/commands/collections/index.js +52 -0
  13. package/build/cli/commands/collections/list.d.ts +2 -0
  14. package/build/cli/commands/collections/list.d.ts.map +1 -0
  15. package/build/cli/commands/collections/list.js +62 -0
  16. package/build/cli/commands/index.d.ts +2 -0
  17. package/build/cli/commands/index.d.ts.map +1 -0
  18. package/build/cli/commands/index.js +67 -0
  19. package/build/cli/commands/init-app.d.ts +18 -2
  20. package/build/cli/commands/init-app.d.ts.map +1 -1
  21. package/build/cli/commands/init-app.js +291 -264
  22. package/build/cli/commands/publish-content.d.ts +2 -0
  23. package/build/cli/commands/publish-content.d.ts.map +1 -0
  24. package/build/cli/commands/publish-content.js +472 -0
  25. package/build/cli/compression/brotli.d.ts +1 -1
  26. package/build/cli/compression/brotli.d.ts.map +1 -1
  27. package/build/cli/compression/brotli.js +8 -11
  28. package/build/cli/compression/gzip.d.ts +1 -1
  29. package/build/cli/compression/gzip.d.ts.map +1 -1
  30. package/build/cli/compression/gzip.js +8 -11
  31. package/build/cli/compression/index.d.ts +3 -6
  32. package/build/cli/compression/index.d.ts.map +1 -1
  33. package/build/cli/compression/index.js +8 -9
  34. package/build/cli/fastly-api/api-token.d.ts +17 -0
  35. package/build/cli/fastly-api/api-token.d.ts.map +1 -0
  36. package/build/cli/fastly-api/api-token.js +94 -0
  37. package/build/cli/fastly-api/kv-store.d.ts +24 -0
  38. package/build/cli/fastly-api/kv-store.d.ts.map +1 -0
  39. package/build/cli/{util → fastly-api}/kv-store.js +42 -22
  40. package/build/cli/index.js +7 -91
  41. package/build/cli/util/args.d.ts +16 -0
  42. package/build/cli/util/args.d.ts.map +1 -0
  43. package/build/cli/util/args.js +55 -0
  44. package/build/cli/util/config.d.ts +13 -0
  45. package/build/cli/util/config.d.ts.map +1 -0
  46. package/build/cli/{load-config.js → util/config.js} +234 -187
  47. package/build/{util → cli/util}/content-types.d.ts +1 -2
  48. package/build/cli/util/content-types.d.ts.map +1 -0
  49. package/build/{util → cli/util}/content-types.js +11 -6
  50. package/build/cli/util/data.d.ts +3 -3
  51. package/build/cli/util/data.d.ts.map +1 -1
  52. package/build/cli/util/data.js +6 -2
  53. package/build/cli/util/files.d.ts +10 -2
  54. package/build/cli/util/files.d.ts.map +1 -1
  55. package/build/cli/util/files.js +53 -6
  56. package/build/cli/util/kv-store-items.d.ts +12 -0
  57. package/build/cli/util/kv-store-items.d.ts.map +1 -0
  58. package/build/cli/util/kv-store-items.js +161 -0
  59. package/build/cli/util/kv-store-local-server.d.ts +3 -0
  60. package/build/cli/util/kv-store-local-server.d.ts.map +1 -0
  61. package/build/cli/util/kv-store-local-server.js +35 -0
  62. package/build/cli/util/package.d.ts +9 -0
  63. package/build/cli/util/package.d.ts.map +1 -0
  64. package/build/cli/util/package.js +44 -0
  65. package/build/cli/util/retryable.d.ts +12 -0
  66. package/build/cli/util/retryable.d.ts.map +1 -0
  67. package/build/cli/util/retryable.js +43 -0
  68. package/build/cli/util/variants.d.ts +4 -0
  69. package/build/cli/util/variants.d.ts.map +1 -0
  70. package/build/cli/util/variants.js +27 -0
  71. package/build/index.d.ts +5 -5
  72. package/build/index.d.ts.map +1 -1
  73. package/build/index.js +7 -6
  74. package/build/models/assets/kvstore-assets.d.ts +17 -0
  75. package/build/models/assets/kvstore-assets.d.ts.map +1 -0
  76. package/build/models/assets/kvstore-assets.js +28 -0
  77. package/build/{constants/compression.d.ts → models/compression/index.d.ts} +2 -1
  78. package/build/models/compression/index.d.ts.map +1 -0
  79. package/build/models/compression/index.js +11 -0
  80. package/build/models/config/publish-content-config.d.ts +41 -0
  81. package/build/models/config/publish-content-config.d.ts.map +1 -0
  82. package/build/models/config/publish-content-config.js +5 -0
  83. package/build/models/config/publisher-server-config.d.ts +20 -0
  84. package/build/models/config/publisher-server-config.d.ts.map +1 -0
  85. package/build/models/config/publisher-server-config.js +5 -0
  86. package/build/models/config/static-publish-rc.d.ts +6 -0
  87. package/build/models/config/static-publish-rc.d.ts.map +1 -0
  88. package/build/models/config/static-publish-rc.js +5 -0
  89. package/build/server/collection-selector/from-config-store.d.ts +2 -0
  90. package/build/server/collection-selector/from-config-store.d.ts.map +1 -0
  91. package/build/server/collection-selector/from-config-store.js +15 -0
  92. package/build/server/collection-selector/from-cookie.d.ts +23 -0
  93. package/build/server/collection-selector/from-cookie.d.ts.map +1 -0
  94. package/build/server/collection-selector/from-cookie.js +98 -0
  95. package/build/server/collection-selector/from-request.d.ts +13 -0
  96. package/build/server/collection-selector/from-request.d.ts.map +1 -0
  97. package/build/server/collection-selector/from-request.js +22 -0
  98. package/build/server/collection-selector/index.d.ts +5 -0
  99. package/build/server/collection-selector/index.d.ts.map +1 -0
  100. package/build/server/collection-selector/index.js +7 -0
  101. package/build/server/collection-selector/request-collection-selector.d.ts +5 -0
  102. package/build/server/collection-selector/request-collection-selector.d.ts.map +1 -0
  103. package/build/server/collection-selector/request-collection-selector.js +5 -0
  104. package/build/server/publisher-server/index.d.ts +38 -0
  105. package/build/server/publisher-server/index.d.ts.map +1 -0
  106. package/build/server/publisher-server/index.js +415 -0
  107. package/build/server/publisher-server/serve-preconditions/if-modified-since.d.ts +3 -0
  108. package/build/server/publisher-server/serve-preconditions/if-modified-since.d.ts.map +1 -0
  109. package/build/server/{serve-preconditions → publisher-server/serve-preconditions}/if-modified-since.js +6 -2
  110. package/build/server/publisher-server/serve-preconditions/if-none-match.d.ts.map +1 -0
  111. package/build/server/{serve-preconditions → publisher-server/serve-preconditions}/if-none-match.js +4 -0
  112. package/build/server/util/cookies.d.ts +2 -0
  113. package/build/server/util/cookies.d.ts.map +1 -0
  114. package/build/server/util/cookies.js +14 -0
  115. package/build/server/util/kv-store.d.ts +3 -0
  116. package/build/server/util/kv-store.d.ts.map +1 -0
  117. package/build/server/util/kv-store.js +95 -0
  118. package/package.json +18 -10
  119. package/build/cli/commands/build-static.d.ts +0 -3
  120. package/build/cli/commands/build-static.d.ts.map +0 -1
  121. package/build/cli/commands/build-static.js +0 -541
  122. package/build/cli/commands/clean-kv-store.d.ts +0 -3
  123. package/build/cli/commands/clean-kv-store.d.ts.map +0 -1
  124. package/build/cli/commands/clean-kv-store.js +0 -55
  125. package/build/cli/load-config.d.ts +0 -6
  126. package/build/cli/load-config.d.ts.map +0 -1
  127. package/build/cli/presets/implementations/astro.d.ts +0 -7
  128. package/build/cli/presets/implementations/astro.d.ts.map +0 -1
  129. package/build/cli/presets/implementations/astro.js +0 -23
  130. package/build/cli/presets/implementations/create-react-app.d.ts +0 -11
  131. package/build/cli/presets/implementations/create-react-app.d.ts.map +0 -1
  132. package/build/cli/presets/implementations/create-react-app.js +0 -34
  133. package/build/cli/presets/implementations/docusaurus.d.ts +0 -7
  134. package/build/cli/presets/implementations/docusaurus.d.ts.map +0 -1
  135. package/build/cli/presets/implementations/docusaurus.js +0 -13
  136. package/build/cli/presets/implementations/gatsby.d.ts +0 -7
  137. package/build/cli/presets/implementations/gatsby.d.ts.map +0 -1
  138. package/build/cli/presets/implementations/gatsby.js +0 -13
  139. package/build/cli/presets/implementations/next.d.ts +0 -7
  140. package/build/cli/presets/implementations/next.d.ts.map +0 -1
  141. package/build/cli/presets/implementations/next.js +0 -13
  142. package/build/cli/presets/implementations/sveltekit.d.ts +0 -7
  143. package/build/cli/presets/implementations/sveltekit.d.ts.map +0 -1
  144. package/build/cli/presets/implementations/sveltekit.js +0 -13
  145. package/build/cli/presets/implementations/vite.d.ts +0 -7
  146. package/build/cli/presets/implementations/vite.d.ts.map +0 -1
  147. package/build/cli/presets/implementations/vite.js +0 -13
  148. package/build/cli/presets/implementations/vue.d.ts +0 -7
  149. package/build/cli/presets/implementations/vue.d.ts.map +0 -1
  150. package/build/cli/presets/implementations/vue.js +0 -24
  151. package/build/cli/presets/index.d.ts +0 -3
  152. package/build/cli/presets/index.d.ts.map +0 -1
  153. package/build/cli/presets/index.js +0 -20
  154. package/build/cli/presets/preset-base.d.ts +0 -21
  155. package/build/cli/presets/preset-base.d.ts.map +0 -1
  156. package/build/cli/presets/preset-base.js +0 -1
  157. package/build/cli/util/fastly-api.d.ts +0 -10
  158. package/build/cli/util/fastly-api.d.ts.map +0 -1
  159. package/build/cli/util/fastly-api.js +0 -47
  160. package/build/cli/util/hash.d.ts +0 -5
  161. package/build/cli/util/hash.d.ts.map +0 -1
  162. package/build/cli/util/hash.js +0 -9
  163. package/build/cli/util/id.d.ts +0 -3
  164. package/build/cli/util/id.d.ts.map +0 -1
  165. package/build/cli/util/id.js +0 -17
  166. package/build/cli/util/kv-store.d.ts +0 -16
  167. package/build/cli/util/kv-store.d.ts.map +0 -1
  168. package/build/cli/util/publish-id.d.ts +0 -5
  169. package/build/cli/util/publish-id.d.ts.map +0 -1
  170. package/build/cli/util/publish-id.js +0 -26
  171. package/build/compute-js.d.ts +0 -3
  172. package/build/compute-js.d.ts.map +0 -1
  173. package/build/compute-js.js +0 -2
  174. package/build/constants/compression.d.ts.map +0 -1
  175. package/build/constants/compression.js +0 -4
  176. package/build/server/assets/asset-manager.d.ts +0 -8
  177. package/build/server/assets/asset-manager.d.ts.map +0 -1
  178. package/build/server/assets/asset-manager.js +0 -14
  179. package/build/server/assets/content-asset-kv-store.d.ts +0 -19
  180. package/build/server/assets/content-asset-kv-store.d.ts.map +0 -1
  181. package/build/server/assets/content-asset-kv-store.js +0 -70
  182. package/build/server/assets/content-asset-wasm-inline.d.ts +0 -18
  183. package/build/server/assets/content-asset-wasm-inline.d.ts.map +0 -1
  184. package/build/server/assets/content-asset-wasm-inline.js +0 -52
  185. package/build/server/assets/content-assets.d.ts +0 -46
  186. package/build/server/assets/content-assets.d.ts.map +0 -1
  187. package/build/server/assets/content-assets.js +0 -100
  188. package/build/server/assets/module-assets.d.ts +0 -23
  189. package/build/server/assets/module-assets.d.ts.map +0 -1
  190. package/build/server/assets/module-assets.js +0 -45
  191. package/build/server/kv-store/inline-store-entry.d.ts +0 -25
  192. package/build/server/kv-store/inline-store-entry.d.ts.map +0 -1
  193. package/build/server/kv-store/inline-store-entry.js +0 -100
  194. package/build/server/publisher-server.d.ts +0 -23
  195. package/build/server/publisher-server.d.ts.map +0 -1
  196. package/build/server/publisher-server.js +0 -257
  197. package/build/server/serve-preconditions/if-modified-since.d.ts +0 -4
  198. package/build/server/serve-preconditions/if-modified-since.d.ts.map +0 -1
  199. package/build/server/serve-preconditions/if-none-match.d.ts.map +0 -1
  200. package/build/server/util/http.d.ts +0 -2
  201. package/build/server/util/http.d.ts.map +0 -1
  202. package/build/server/util/http.js +0 -9
  203. package/build/types/compute.d.ts +0 -11
  204. package/build/types/compute.d.ts.map +0 -1
  205. package/build/types/compute.js +0 -1
  206. package/build/types/config-normalized.d.ts +0 -34
  207. package/build/types/config-normalized.d.ts.map +0 -1
  208. package/build/types/config-normalized.js +0 -1
  209. package/build/types/config.d.ts +0 -37
  210. package/build/types/config.d.ts.map +0 -1
  211. package/build/types/config.js +0 -1
  212. package/build/types/content-assets.d.ts +0 -55
  213. package/build/types/content-assets.d.ts.map +0 -1
  214. package/build/types/content-assets.js +0 -1
  215. package/build/types/content-types.d.ts +0 -11
  216. package/build/types/content-types.d.ts.map +0 -1
  217. package/build/types/content-types.js +0 -1
  218. package/build/types/index.d.ts +0 -7
  219. package/build/types/index.d.ts.map +0 -1
  220. package/build/types/index.js +0 -1
  221. package/build/types/module-assets.d.ts +0 -15
  222. package/build/types/module-assets.d.ts.map +0 -1
  223. package/build/types/module-assets.js +0 -1
  224. package/build/types/util.d.ts +0 -7
  225. package/build/types/util.d.ts.map +0 -1
  226. package/build/types/util.js +0 -1
  227. package/build/util/content-types.d.ts.map +0 -1
  228. package/build/util/index.d.ts +0 -3
  229. package/build/util/index.d.ts.map +0 -1
  230. package/build/util/index.js +0 -2
  231. package/build/util/metadata.d.ts +0 -3
  232. package/build/util/metadata.d.ts.map +0 -1
  233. package/build/util/metadata.js +0 -12
  234. package/resources/README.md +0 -3
  235. package/resources/statics-metadata.d.ts +0 -10
  236. package/resources/statics.d.ts +0 -19
  237. package/resources/webpack.config.js +0 -41
  238. /package/build/server/{serve-preconditions → publisher-server/serve-preconditions}/if-none-match.d.ts +0 -0
@@ -1,11 +1,16 @@
1
- import fs from "fs";
2
- import path from "path";
3
- export function getFiles(dir, opts) {
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ import crypto from 'node:crypto';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ export function enumerateFiles(opts) {
4
9
  const results = [];
5
- getFilesWorker(results, dir, opts);
10
+ enumerateFilesWorker(results, opts.publicDirRoot, opts);
6
11
  return results;
7
12
  }
8
- function getFilesWorker(results, dir, opts) {
13
+ function enumerateFilesWorker(results, dir, opts) {
9
14
  const entries = fs.readdirSync(dir, { withFileTypes: true });
10
15
  for (const entry of entries) {
11
16
  const { name } = entry;
@@ -24,10 +29,52 @@ function getFilesWorker(results, dir, opts) {
24
29
  }
25
30
  }
26
31
  if (entry.isDirectory()) {
27
- getFilesWorker(results, fullpath, opts);
32
+ enumerateFilesWorker(results, fullpath, opts);
28
33
  }
29
34
  else {
30
35
  results.push(fullpath);
31
36
  }
32
37
  }
33
38
  }
39
+ export function getFileSize(filePath) {
40
+ const stats = fs.statSync(filePath);
41
+ return stats.size;
42
+ }
43
+ export function directoryExists(dirPath) {
44
+ try {
45
+ const stats = fs.statSync(dirPath);
46
+ return stats.isDirectory();
47
+ }
48
+ catch (err) {
49
+ if (err.code === 'ENOENT') {
50
+ return false; // Path doesn't exist
51
+ }
52
+ throw err; // Other errors, rethrow
53
+ }
54
+ }
55
+ export async function calculateFileSizeAndHash(filePath) {
56
+ const stream = fs.createReadStream(filePath);
57
+ // Use createHash, rather than subtle, since it supports streaming.
58
+ const hash = crypto.createHash('sha256');
59
+ let size = 0;
60
+ return new Promise((resolve, reject) => {
61
+ stream.on('data', chunk => {
62
+ hash.update(chunk);
63
+ size += chunk.length;
64
+ });
65
+ stream.on('end', () => {
66
+ resolve({
67
+ size,
68
+ hash: hash.digest('hex'),
69
+ });
70
+ });
71
+ stream.on('error', reject);
72
+ });
73
+ }
74
+ export function rootRelative(itemPath) {
75
+ return dotRelative(null, itemPath);
76
+ }
77
+ export function dotRelative(from, to) {
78
+ const relPath = path.relative(from ?? path.resolve(), to);
79
+ return relPath.startsWith('..') ? relPath : './' + relPath;
80
+ }
@@ -0,0 +1,12 @@
1
+ import { type FastlyApiContext } from '../fastly-api/api-token.js';
2
+ export type KVStoreItemDesc = {
3
+ write: boolean;
4
+ size: number;
5
+ key: string;
6
+ filePath: string;
7
+ metadataJson?: Record<string, any>;
8
+ };
9
+ export declare function uploadFilesToKVStore(fastlyApiContext: FastlyApiContext, kvStoreName: string, kvStoreItemDescriptions: KVStoreItemDesc[]): Promise<void>;
10
+ export declare function shouldRecreateChunks(chunksDir: string, numChunks: number, item: KVStoreItemDesc, chunkSize: number): boolean;
11
+ export declare function applyKVStoreEntriesChunks(kvStoreItemDescriptions: KVStoreItemDesc[], chunkSize: number): Promise<void>;
12
+ //# sourceMappingURL=kv-store-items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv-store-items.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store-items.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,gBAAgB,EAAc,MAAM,4BAA4B,CAAC;AAG/E,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,iBAgD7I;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAkClH;AAED,wBAAsB,yBAAyB,CAAC,uBAAuB,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,MAAM,iBAoG5G"}
@@ -0,0 +1,161 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ import fs from 'node:fs';
6
+ import { directoryExists, getFileSize, rootRelative } from './files.js';
7
+ import { attemptWithRetries } from './retryable.js';
8
+ import { FetchError } from '../fastly-api/api-token.js';
9
+ import { kvStoreSubmitFile } from '../fastly-api/kv-store.js';
10
+ export async function uploadFilesToKVStore(fastlyApiContext, kvStoreName, kvStoreItemDescriptions) {
11
+ const maxConcurrent = 12;
12
+ let index = 0; // Shared among workers
13
+ async function worker() {
14
+ while (index < kvStoreItemDescriptions.length) {
15
+ const currentIndex = index;
16
+ index = index + 1;
17
+ const { write, key, filePath, metadataJson } = kvStoreItemDescriptions[currentIndex];
18
+ if (!write) {
19
+ continue;
20
+ }
21
+ try {
22
+ await attemptWithRetries(async () => {
23
+ const fileBytes = fs.readFileSync(filePath);
24
+ await kvStoreSubmitFile(fastlyApiContext, kvStoreName, key, fileBytes, metadataJson != null ? JSON.stringify(metadataJson) : undefined);
25
+ console.log(` 🌐 Submitted asset "${rootRelative(filePath)}" to KV Store with key "${key}".`);
26
+ }, {
27
+ onAttempt(attempt) {
28
+ if (attempt > 0) {
29
+ console.log(` Attempt ${attempt + 1} for: ${key}`);
30
+ }
31
+ },
32
+ onRetry(attempt, err, delay) {
33
+ let statusMessage = 'unknown';
34
+ if (err instanceof FetchError) {
35
+ statusMessage = `HTTP ${err.status}`;
36
+ }
37
+ else if (err instanceof TypeError) {
38
+ statusMessage = 'transport';
39
+ }
40
+ console.log(` ‼️ Attempt ${attempt + 1} for ${key} gave retryable error (${statusMessage}), delaying ${delay} ms`);
41
+ },
42
+ });
43
+ }
44
+ catch (err) {
45
+ const e = err instanceof Error ? err : new Error(String(err));
46
+ console.error(` ❌ Failed: ${key} → ${e.message}`);
47
+ console.error(e.stack);
48
+ }
49
+ }
50
+ }
51
+ const workers = Array.from({ length: maxConcurrent }, () => worker());
52
+ await Promise.all(workers);
53
+ }
54
+ export function shouldRecreateChunks(chunksDir, numChunks, item, chunkSize) {
55
+ console.log(` 📄 '${item.key}' - ${item.size} bytes → ${numChunks} chunks`);
56
+ if (!directoryExists(chunksDir)) {
57
+ console.log(` ・ Creating chunks for '${item.key}' - found no existing chunks`);
58
+ return true;
59
+ }
60
+ const existingChunks = fs.readdirSync(chunksDir).length;
61
+ if (existingChunks !== numChunks) {
62
+ console.log(` ・ Recreating chunks for '${item.key}' - found ${existingChunks} existing chunk(s), expected ${numChunks}`);
63
+ return true;
64
+ }
65
+ const finalChunkSize = item.size % chunkSize;
66
+ for (let chunk = 0; chunk < numChunks; chunk++) {
67
+ const chunkFileName = `${chunksDir}/${chunk}`;
68
+ // If the chunk does not exist
69
+ if (!fs.existsSync(chunkFileName)) {
70
+ console.log(` ・ Recreating chunks for '${item.key}' - chunk ${chunk} does not exist`);
71
+ return true;
72
+ }
73
+ // or if the chunk isn't the expected size
74
+ const expectedFileSize = chunk === numChunks - 1 ? finalChunkSize : chunkSize;
75
+ const existingFileSize = getFileSize(chunkFileName);
76
+ if (existingFileSize !== expectedFileSize) {
77
+ console.log(` ・ Recreating chunks for '${item.key}' - chunk ${chunk} existing file size ${existingFileSize} does not match expected size ${expectedFileSize}`);
78
+ return true;
79
+ }
80
+ }
81
+ console.log(` ・ Existing chunks for '${item.key}' look good.`);
82
+ return false;
83
+ }
84
+ export async function applyKVStoreEntriesChunks(kvStoreItemDescriptions, chunkSize) {
85
+ const items = kvStoreItemDescriptions.splice(0);
86
+ // kvStoreItemDescriptions is now empty.
87
+ for (const item of items) {
88
+ if (item.size <= chunkSize) {
89
+ // If file is not over the chunk size, use it as it is.
90
+ kvStoreItemDescriptions.push(item);
91
+ continue;
92
+ }
93
+ // Check if the chunks exist on disk, and if they don't, recreate them.
94
+ const chunksDir = `${item.filePath}_chunks`;
95
+ const numChunks = Math.ceil(item.size / chunkSize);
96
+ if (shouldRecreateChunks(chunksDir, numChunks, item, chunkSize)) {
97
+ // Recreate chunks
98
+ fs.rmSync(chunksDir, { recursive: true, force: true });
99
+ fs.mkdirSync(chunksDir, { recursive: true });
100
+ const numWrittenChunks = await new Promise((resolve, reject) => {
101
+ const chunkPaths = [];
102
+ let chunkIndex = 0;
103
+ let bytesWritten = 0;
104
+ let currentStream = null;
105
+ const inputStream = fs.createReadStream(item.filePath);
106
+ inputStream.on('error', reject);
107
+ inputStream.on('data', (chunk) => {
108
+ let offset = 0;
109
+ while (offset < chunk.length) {
110
+ if (!currentStream || bytesWritten >= chunkSize) {
111
+ if (currentStream != null) {
112
+ currentStream.end();
113
+ }
114
+ const chunkFileName = `${chunksDir}/${chunkIndex}`;
115
+ currentStream = fs.createWriteStream(chunkFileName);
116
+ chunkPaths.push(chunkFileName);
117
+ chunkIndex++;
118
+ bytesWritten = 0;
119
+ }
120
+ const bytesLeftInChunk = chunkSize - bytesWritten;
121
+ const bytesLeftInBuffer = chunk.length - offset;
122
+ const bytesToWrite = Math.min(bytesLeftInChunk, bytesLeftInBuffer);
123
+ const slice = chunk.slice(offset, offset + bytesToWrite);
124
+ currentStream.write(slice);
125
+ bytesWritten += bytesToWrite;
126
+ offset += bytesToWrite;
127
+ }
128
+ });
129
+ inputStream.on('end', () => {
130
+ if (currentStream != null) {
131
+ currentStream.end();
132
+ }
133
+ resolve(chunkPaths.length);
134
+ });
135
+ });
136
+ if (numWrittenChunks !== numChunks) {
137
+ throw new Error(`numWrittenChunks (${numWrittenChunks}) does not equal numChunks (${numChunks})`);
138
+ }
139
+ }
140
+ for (let chunkIndex = 0; chunkIndex < numChunks; chunkIndex++) {
141
+ const kvItem = structuredClone(item);
142
+ // Source the chunk from the chunk directory
143
+ kvItem.filePath = `${chunksDir}/${chunkIndex}`;
144
+ // Add chunk ID to metadata
145
+ if (kvItem.metadataJson == null) {
146
+ kvItem.metadataJson = {};
147
+ }
148
+ kvItem.metadataJson.chunkIndex = chunkIndex;
149
+ if (chunkIndex !== 0) {
150
+ // For additional chunks (all but the first):
151
+ // add suffix to key
152
+ kvItem.key = item.key + '_' + chunkIndex;
153
+ // remove other metadata
154
+ delete kvItem.metadataJson.hash;
155
+ delete kvItem.metadataJson.size;
156
+ delete kvItem.metadataJson.numChunks;
157
+ }
158
+ kvStoreItemDescriptions.push(kvItem);
159
+ }
160
+ }
161
+ }
@@ -0,0 +1,3 @@
1
+ import { type KVStoreItemDesc } from './kv-store-items.js';
2
+ export declare function writeKVStoreEntriesForLocal(storeFile: string, computeAppDir: string, kvStoreItemDescriptions: KVStoreItemDesc[]): void;
3
+ //# sourceMappingURL=kv-store-local-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kv-store-local-server.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store-local-server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,QAmC/H"}
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ export function writeKVStoreEntriesForLocal(storeFile, computeAppDir, kvStoreItemDescriptions) {
8
+ let store;
9
+ try {
10
+ // If the local KV store file exists, we have to add to it.
11
+ const storeFileJson = fs.readFileSync(storeFile, 'utf-8');
12
+ store = JSON.parse(storeFileJson);
13
+ }
14
+ catch {
15
+ store = {};
16
+ }
17
+ for (const kvStoreItemDescription of kvStoreItemDescriptions) {
18
+ store[kvStoreItemDescription.key] = {
19
+ file: path.relative(computeAppDir, kvStoreItemDescription.filePath),
20
+ metadata: kvStoreItemDescription.metadataJson != null ? JSON.stringify(kvStoreItemDescription.metadataJson) : undefined,
21
+ };
22
+ }
23
+ // Delete any keys that point to items that do not exist in the file system
24
+ const keysToDelete = new Set();
25
+ for (const [key, value] of Object.entries(store)) {
26
+ if (!("file" in value) || fs.existsSync(path.resolve(computeAppDir, value.file))) {
27
+ continue;
28
+ }
29
+ keysToDelete.add(key);
30
+ }
31
+ for (const key of keysToDelete) {
32
+ delete store[key];
33
+ }
34
+ fs.writeFileSync(storeFile, JSON.stringify(store));
35
+ }
@@ -0,0 +1,9 @@
1
+ export type PackageJson = {
2
+ author?: string;
3
+ name?: string;
4
+ description?: string;
5
+ dependencies?: Record<string, string>;
6
+ devDependencies?: Record<string, string>;
7
+ };
8
+ export declare function findComputeJsStaticPublisherVersion(packageJson: PackageJson | null): string;
9
+ //# sourceMappingURL=package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../../src/cli/util/package.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,UA8ClF"}
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ export function findComputeJsStaticPublisherVersion(packageJson) {
8
+ // Get the current compute js static publisher version.
9
+ let computeJsStaticPublisherVersion = null;
10
+ if (packageJson != null) {
11
+ // First try current project's package.json
12
+ computeJsStaticPublisherVersion =
13
+ packageJson.dependencies?.["@fastly/compute-js-static-publish"] ??
14
+ packageJson.devDependencies?.["@fastly/compute-js-static-publish"] ??
15
+ null;
16
+ // This may be a file url if during development
17
+ if (computeJsStaticPublisherVersion != null) {
18
+ if (computeJsStaticPublisherVersion.startsWith('file:')) {
19
+ // this is a relative path from the current directory.
20
+ // we replace it with an absolute path
21
+ const relPath = computeJsStaticPublisherVersion.slice('file:'.length);
22
+ const absPath = path.resolve(relPath);
23
+ computeJsStaticPublisherVersion = 'file:' + absPath;
24
+ }
25
+ }
26
+ }
27
+ if (computeJsStaticPublisherVersion == null) {
28
+ // Also try package.json of the package that contains the currently running program
29
+ // This is used when the program doesn't actually install the package (running via npx).
30
+ const computeJsStaticPublishPackageJsonPath = path.resolve(import.meta.dirname, '../../../package.json');
31
+ const computeJsStaticPublishPackageJsonText = fs.readFileSync(computeJsStaticPublishPackageJsonPath, 'utf-8');
32
+ const computeJsStaticPublishPackageJson = JSON.parse(computeJsStaticPublishPackageJsonText);
33
+ computeJsStaticPublisherVersion = computeJsStaticPublishPackageJson?.version;
34
+ }
35
+ if (computeJsStaticPublisherVersion == null) {
36
+ // Unexpected, but if it's still null then we go to a literal
37
+ computeJsStaticPublisherVersion = '7.0.0';
38
+ }
39
+ if (!computeJsStaticPublisherVersion.startsWith('^') &&
40
+ !computeJsStaticPublisherVersion.startsWith('file:')) {
41
+ computeJsStaticPublisherVersion = '^' + computeJsStaticPublisherVersion;
42
+ }
43
+ return computeJsStaticPublisherVersion;
44
+ }
@@ -0,0 +1,12 @@
1
+ export declare function makeRetryable(error: Error): Error;
2
+ export declare function isRetryableError(error: unknown): any;
3
+ type RetryWithBackoffOptions = {
4
+ maxRetries?: number;
5
+ initialDelay?: number;
6
+ onAttempt?: (attempt: number) => void;
7
+ onSuccess?: (attempt: number) => void;
8
+ onRetry?: (attempt: number, err: unknown, delay: number) => void;
9
+ };
10
+ export declare function attemptWithRetries<TResult>(fn: () => Promise<TResult>, options?: RetryWithBackoffOptions): Promise<TResult>;
11
+ export {};
12
+ //# sourceMappingURL=retryable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retryable.d.ts","sourceRoot":"","sources":["../../../src/cli/util/retryable.ts"],"names":[],"mappings":"AAQA,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,SAGzC;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,OAK9C;AAED,KAAK,uBAAuB,GAAG;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAClE,CAAC;AACF,wBAAsB,kBAAkB,CAAC,OAAO,EAC9C,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC1B,OAAO,GAAE,uBAA4B,oBAsCtC"}
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ let _globalBackoffUntil = 0;
6
+ const retryableSymbol = Symbol();
7
+ export function makeRetryable(error) {
8
+ error[retryableSymbol] = true;
9
+ return error;
10
+ }
11
+ export function isRetryableError(error) {
12
+ if (!(error instanceof Error)) {
13
+ return false;
14
+ }
15
+ return error[retryableSymbol] ?? false;
16
+ }
17
+ export async function attemptWithRetries(fn, options = {}) {
18
+ const { maxRetries = 5, initialDelay = 60000, onAttempt, onSuccess, onRetry, } = options;
19
+ let attempt = 0;
20
+ let result;
21
+ while (true) {
22
+ const waitTime = _globalBackoffUntil - Date.now();
23
+ if (waitTime > 0) {
24
+ await new Promise(res => setTimeout(res, waitTime));
25
+ }
26
+ try {
27
+ onAttempt?.(attempt);
28
+ result = await fn();
29
+ onSuccess?.(attempt);
30
+ break;
31
+ }
32
+ catch (err) {
33
+ if (!isRetryableError(err) || attempt >= maxRetries) {
34
+ throw err;
35
+ }
36
+ const delay = initialDelay * (attempt + 1);
37
+ _globalBackoffUntil = Date.now() + delay;
38
+ onRetry?.(attempt, err, delay);
39
+ }
40
+ attempt++;
41
+ }
42
+ return result;
43
+ }
@@ -0,0 +1,4 @@
1
+ import { type ContentCompressionTypes } from '../../models/compression/index.js';
2
+ export type Variants = 'original' | ContentCompressionTypes;
3
+ export declare function ensureVariantFileExists(variantFilePath: string, variant: Variants, file: string): Promise<void>;
4
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../src/cli/util/variants.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAIjF,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,uBAAuB,CAAC;AAE5D,wBAAsB,uBAAuB,CAC3C,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,MAAM,iBAyBb"}
@@ -0,0 +1,27 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ import fs from 'node:fs';
6
+ import { algs } from '../compression/index.js';
7
+ import { rootRelative } from './files.js';
8
+ export async function ensureVariantFileExists(variantFilePath, variant, file) {
9
+ // Compress/prepare the asset if it doesn't already exist
10
+ // We disregard chunked copies of the file and only check for the existence
11
+ // of the main copy of the file at this point.
12
+ if (!fs.existsSync(variantFilePath)) {
13
+ if (variant === 'original') {
14
+ fs.cpSync(file, variantFilePath);
15
+ console.log(` 📄→📄 Copied file '${rootRelative(file)}' to '${rootRelative(variantFilePath)}'.`);
16
+ }
17
+ else {
18
+ const compressTo = algs[variant];
19
+ await compressTo(file, variantFilePath);
20
+ console.log(` 📄→🗄️ Compressed file '${rootRelative(file)}' to '${rootRelative(variantFilePath)}' [${variant}].`);
21
+ }
22
+ // However, if we did just create the file,
23
+ // we delete any chunked copies that may exist as they can be out of date.
24
+ // (They will be recreated in a later step)
25
+ fs.rmSync(`${variantFilePath}_chunks`, { recursive: true, force: true });
26
+ }
27
+ }
package/build/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './types/index.js';
2
- export * from './util/index.js';
3
- export { ContentAssets } from './server/assets/content-assets.js';
4
- export { ModuleAssets } from './server/assets/module-assets.js';
5
- export { PublisherServer } from './server/publisher-server.js';
1
+ export { type StaticPublishRc } from './models/config/static-publish-rc.js';
2
+ export { type PublishContentConfig } from './models/config/publish-content-config.js';
3
+ export * as collectionSelector from './server/collection-selector/index.js';
4
+ export { CookieCollectionSelector, type CookieCollectionSelectorOpts, } from './server/collection-selector/from-cookie.js';
5
+ export { PublisherServer } from './server/publisher-server/index.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,kBAAkB,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EACL,wBAAwB,EACxB,KAAK,4BAA4B,GAClC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC"}
package/build/index.js CHANGED
@@ -1,6 +1,7 @@
1
- /// <reference types="@fastly/js-compute" />
2
- export * from './types/index.js';
3
- export * from './util/index.js';
4
- export { ContentAssets } from './server/assets/content-assets.js';
5
- export { ModuleAssets } from './server/assets/module-assets.js';
6
- export { PublisherServer } from './server/publisher-server.js';
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ export * as collectionSelector from './server/collection-selector/index.js';
6
+ export { CookieCollectionSelector, } from './server/collection-selector/from-cookie.js';
7
+ export { PublisherServer } from './server/publisher-server/index.js';
@@ -0,0 +1,17 @@
1
+ import { type ContentCompressionTypes } from '../compression/index.js';
2
+ export type KVAssetEntry = {
3
+ key: string;
4
+ size: number;
5
+ contentType: string;
6
+ lastModifiedTime: number;
7
+ variants: ContentCompressionTypes[];
8
+ };
9
+ export type KVAssetEntryMap = Record<string, KVAssetEntry>;
10
+ export type KVAssetVariantMetadata = {
11
+ contentEncoding?: ContentCompressionTypes;
12
+ size: number;
13
+ hash: string;
14
+ numChunks?: number;
15
+ };
16
+ export declare function isKVAssetVariantMetadata(obj: unknown): obj is KVAssetVariantMetadata;
17
+ //# sourceMappingURL=kvstore-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvstore-assets.d.ts","sourceRoot":"","sources":["../../../src/models/assets/kvstore-assets.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,uBAAuB,EAAqB,MAAM,yBAAyB,CAAC;AAE1F,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,uBAAuB,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAE3D,MAAM,MAAM,sBAAsB,GAAG;IACnC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,sBAAsB,CAyBpF"}
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ import { isCompressionType } from '../compression/index.js';
6
+ export function isKVAssetVariantMetadata(obj) {
7
+ if (obj == null || typeof obj !== 'object') {
8
+ return false;
9
+ }
10
+ if ('contentEncoding' in obj) {
11
+ if (typeof obj.contentEncoding !== 'string' ||
12
+ !isCompressionType(obj.contentEncoding)) {
13
+ return false;
14
+ }
15
+ }
16
+ if (!('size' in obj) || typeof obj.size !== 'number') {
17
+ return false;
18
+ }
19
+ if (!('hash' in obj) || typeof obj.hash !== 'string') {
20
+ return false;
21
+ }
22
+ if ('numChunks' in obj) {
23
+ if (typeof obj.numChunks !== 'number') {
24
+ return false;
25
+ }
26
+ }
27
+ return true;
28
+ }
@@ -1,3 +1,4 @@
1
1
  export declare const compressionTypes: readonly ["br", "gzip"];
2
2
  export type ContentCompressionTypes = typeof compressionTypes[number];
3
- //# sourceMappingURL=compression.d.ts.map
3
+ export declare function isCompressionType(value: string): value is ContentCompressionTypes;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/compression/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,yBAGnB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAEtE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,uBAAuB,CAEjF"}
@@ -0,0 +1,11 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ export const compressionTypes = [
6
+ 'br',
7
+ 'gzip',
8
+ ];
9
+ export function isCompressionType(value) {
10
+ return compressionTypes.includes(value);
11
+ }
@@ -0,0 +1,41 @@
1
+ import { type PublisherServerConfig, type PublisherServerConfigNormalized } from './publisher-server-config.js';
2
+ import { type ContentCompressionTypes } from '../compression/index.js';
3
+ export type ContentTypeTest = (name: string) => boolean;
4
+ export type ContentTypeDef = {
5
+ test: RegExp | ContentTypeTest;
6
+ contentType: string;
7
+ text?: boolean;
8
+ precompressAsset?: boolean;
9
+ };
10
+ export type ContentTypeTestResult = {
11
+ contentType: string;
12
+ text: boolean;
13
+ precompressAsset: boolean;
14
+ };
15
+ export interface ExcludeDirTest {
16
+ test(name: string): boolean;
17
+ }
18
+ export type KVStoreAssetInclusionTest = (assetKey: string, contentType?: string) => boolean;
19
+ export type PublishContentConfig = {
20
+ rootDir: string;
21
+ staticPublisherWorkingDir: string;
22
+ excludeDirs?: (string | ExcludeDirTest)[] | string | ExcludeDirTest | null;
23
+ excludeDotFiles?: boolean;
24
+ includeWellKnown?: boolean;
25
+ kvStoreAssetInclusionTest?: KVStoreAssetInclusionTest | null;
26
+ contentCompression?: ('br' | 'gzip')[];
27
+ contentTypes?: ContentTypeDef[];
28
+ server?: PublisherServerConfig | null;
29
+ };
30
+ export type PublishContentConfigNormalized = {
31
+ rootDir: string;
32
+ staticPublisherWorkingDir: string;
33
+ excludeDirs: ExcludeDirTest[];
34
+ excludeDotFiles: boolean;
35
+ includeWellKnown: boolean;
36
+ kvStoreAssetInclusionTest: KVStoreAssetInclusionTest | null;
37
+ contentCompression: ContentCompressionTypes[];
38
+ contentTypes: ContentTypeDef[];
39
+ server: PublisherServerConfigNormalized | null;
40
+ };
41
+ //# sourceMappingURL=publish-content-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish-content-config.d.ts","sourceRoot":"","sources":["../../../src/models/config/publish-content-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACrC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,KAAK,uBAAuB,EAC7B,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAGxD,MAAM,MAAM,cAAc,GAAG;IAE3B,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IAG/B,WAAW,EAAE,MAAM,CAAC;IAIpB,IAAI,CAAC,EAAE,OAAO,CAAC;IAIf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;AAE5F,MAAM,MAAM,oBAAoB,GAAG;IAEjC,OAAO,EAAE,MAAM,CAAC;IAIhB,yBAAyB,EAAE,MAAM,CAAC;IAMlC,WAAW,CAAC,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IAI3E,eAAe,CAAC,EAAE,OAAO,CAAC;IAI1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAG3B,yBAAyB,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAI7D,kBAAkB,CAAC,EAAE,CAAC,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC;IAGvC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAGhC,MAAM,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB,EAAE,MAAM,CAAC;IAClC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC5D,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAChD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Copyright Fastly, Inc.
3
+ * Licensed under the MIT license. See LICENSE file for details.
4
+ */
5
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type ContentCompressionTypes } from '../compression/index.js';
2
+ export type PublisherServerConfig = {
3
+ publicDirPrefix?: string;
4
+ staticItems?: string[] | string | false | null;
5
+ allowedEncodings?: ContentCompressionTypes[];
6
+ spaFile?: string | false | null;
7
+ notFoundPageFile?: string | false | null;
8
+ autoExt?: string[] | string | false | null;
9
+ autoIndex?: string[] | string | false | null;
10
+ };
11
+ export type PublisherServerConfigNormalized = {
12
+ publicDirPrefix: string;
13
+ staticItems: string[];
14
+ allowedEncodings: ContentCompressionTypes[];
15
+ spaFile: string | null;
16
+ notFoundPageFile: string | null;
17
+ autoExt: string[];
18
+ autoIndex: string[];
19
+ };
20
+ //# sourceMappingURL=publisher-server-config.d.ts.map