@fastly/compute-js-static-publish 7.0.0-beta.2 → 7.0.0-beta.4
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/README.md +11 -3
- package/README.short.md +11 -3
- package/build/cli/commands/manage/clean.d.ts.map +1 -1
- package/build/cli/commands/manage/clean.js +96 -20
- package/build/cli/commands/manage/collections/delete.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/delete.js +84 -23
- package/build/cli/commands/manage/collections/index.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/index.js +14 -8
- package/build/cli/commands/manage/collections/list.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/list.js +77 -19
- package/build/cli/commands/manage/collections/promote.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/promote.js +139 -45
- package/build/cli/commands/manage/collections/update-expiration.d.ts.map +1 -1
- package/build/cli/commands/manage/collections/update-expiration.js +120 -34
- package/build/cli/commands/manage/index.d.ts.map +1 -1
- package/build/cli/commands/manage/index.js +10 -5
- package/build/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/commands/manage/publish-content.js +96 -81
- package/build/cli/commands/scaffold/index.d.ts.map +1 -1
- package/build/cli/commands/scaffold/index.js +11 -10
- package/build/cli/util/api-token.d.ts.map +1 -0
- package/build/cli/{fastly-api → util}/api-token.js +1 -1
- package/build/cli/util/config.d.ts.map +1 -1
- package/build/cli/util/config.js +19 -19
- package/build/cli/util/kv-store-items.js +1 -1
- package/build/cli/util/kv-store-local-server.d.ts +8 -0
- package/build/cli/util/kv-store-local-server.d.ts.map +1 -1
- package/build/cli/util/kv-store-local-server.js +76 -0
- package/build/cli/{fastly-api → util}/kv-store.d.ts +4 -4
- package/build/cli/util/kv-store.d.ts.map +1 -0
- package/build/cli/{fastly-api → util}/kv-store.js +2 -2
- package/build/models/config/publish-content-config.d.ts +0 -2
- package/build/models/config/publish-content-config.d.ts.map +1 -1
- package/build/models/config/static-publish-rc.d.ts +1 -0
- package/build/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/models/time/index.d.ts +2 -1
- package/build/models/time/index.d.ts.map +1 -1
- package/build/models/time/index.js +6 -3
- package/package.json +1 -1
- package/build/cli/fastly-api/api-token.d.ts.map +0 -1
- package/build/cli/fastly-api/kv-store.d.ts.map +0 -1
- /package/build/cli/{fastly-api → util}/api-token.d.ts +0 -0
|
@@ -6,8 +6,8 @@ import * as fs from 'node:fs';
|
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { isKVAssetVariantMetadata } from '../../../models/assets/kvstore-assets.js';
|
|
8
8
|
import { calcExpirationTime } from '../../../models/time/index.js';
|
|
9
|
-
import { loadApiToken } from '../../
|
|
10
|
-
import { getKvStoreEntryInfo, kvStoreSubmitEntry } from '../../
|
|
9
|
+
import { loadApiToken } from '../../util/api-token.js';
|
|
10
|
+
import { getKvStoreEntryInfo, kvStoreSubmitEntry } from '../../util/kv-store.js';
|
|
11
11
|
import { parseCommandLine } from '../../util/args.js';
|
|
12
12
|
import { mergeContentTypes, testFileContentType } from '../../util/content-types.js';
|
|
13
13
|
import { LoadConfigError, loadPublishContentConfigFile, loadStaticPublisherRcFile } from '../../util/config.js';
|
|
@@ -28,48 +28,73 @@ function help() {
|
|
|
28
28
|
console.log(`\
|
|
29
29
|
|
|
30
30
|
Usage:
|
|
31
|
-
npx @fastly/compute-js-static-publish publish-content [options]
|
|
31
|
+
npx @fastly/compute-js-static-publish publish-content [--collection-name=<name>] [options]
|
|
32
32
|
|
|
33
33
|
Description:
|
|
34
|
-
Publishes static files from your root directory into
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
Publishes static files from your local root directory into a named collection,
|
|
35
|
+
either in the Fastly KV Store (default) or to a local dev directory (--local).
|
|
36
|
+
Files that already exist with the same hash are skipped automatically.
|
|
37
|
+
|
|
38
|
+
After this process is complete, the PublisherServer object in the Compute application
|
|
39
|
+
will see the updated index of files and updated server settings from the
|
|
40
|
+
publish-content.config.js file.
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
--
|
|
40
|
-
|
|
41
|
-
--root-dir <dir> Override the root directory to publish from
|
|
42
|
-
--collection-name <name> Publish under a specific collection name (defaults to value in static-publish.rc.js).
|
|
43
|
-
--expires-in <duration> Set expiration for the collection relative to now (e.g., 3d, 6h, 1w).
|
|
44
|
-
--expires-at <timestamp> Set expiration using an absolute ISO 8601 timestamp.
|
|
45
|
-
--local-only Write content to local KV Store for testing only. No remote uploads.
|
|
46
|
-
--no-local Skip local KV Store writes and upload only to the Fastly KV Store.
|
|
47
|
-
--kv-overwrite When Fastly KV Store is used, always overwrite existing items in the store.
|
|
42
|
+
Optional:
|
|
43
|
+
--collection-name=<name> Name of the collection to publish into.
|
|
44
|
+
Default: value from static-publisher.rc.js (defaultCollectionName)
|
|
48
45
|
|
|
49
|
-
--
|
|
50
|
-
|
|
46
|
+
--config=<file> Path to a publish-content.config.js file.
|
|
47
|
+
Default: ./publish-content.config.js
|
|
48
|
+
|
|
49
|
+
--root-dir=<dir> Directory to publish from. Overrides the config file setting.
|
|
50
|
+
Default: rootDir from publish-content.config.js
|
|
51
|
+
|
|
52
|
+
--kv-overwrite Cannot be used with --local.
|
|
53
|
+
When using Fastly KV Store, always overwrite
|
|
54
|
+
existing entries, even if unchanged.
|
|
55
|
+
|
|
56
|
+
Expiration:
|
|
57
|
+
--expires-in=<duration> Expiration duration from now.
|
|
58
|
+
Examples: 3d, 12h, 15m, 1w
|
|
59
|
+
|
|
60
|
+
--expires-at=<timestamp> Absolute expiration in ISO 8601 format.
|
|
61
|
+
Example: 2025-05-01T00:00:00Z
|
|
62
|
+
|
|
63
|
+
--expires-never Prevent this collection from expiring.
|
|
64
|
+
|
|
65
|
+
⚠ These three options are mutually exclusive.
|
|
66
|
+
Specify only one.
|
|
67
|
+
|
|
68
|
+
Global Options:
|
|
69
|
+
--local Instead of working with the Fastly KV Store, operate on
|
|
70
|
+
local files that will be used to simulate the KV Store
|
|
71
|
+
with the local development environment.
|
|
72
|
+
|
|
73
|
+
--fastly-api-token=<token> Fastly API token for KV Store access.
|
|
74
|
+
If not set, the tool will check:
|
|
51
75
|
1. FASTLY_API_TOKEN environment variable
|
|
52
|
-
2.
|
|
53
|
-
|
|
76
|
+
2. Logged-in Fastly CLI profile
|
|
77
|
+
|
|
78
|
+
-h, --help Show this help message and exit.
|
|
79
|
+
|
|
80
|
+
Examples:
|
|
81
|
+
npx @fastly/compute-js-static-publish publish-content --collection-name=preview-456
|
|
82
|
+
npx @fastly/compute-js-static-publish publish-content --expires-in=7d --kv-overwrite
|
|
83
|
+
npx @fastly/compute-js-static-publish publish-content --expires-never --local
|
|
84
|
+
|
|
54
85
|
`);
|
|
55
86
|
}
|
|
56
87
|
export async function action(actionArgs) {
|
|
57
88
|
const optionDefinitions = [
|
|
58
|
-
{ name: 'verbose', type: Boolean
|
|
89
|
+
{ name: 'verbose', type: Boolean },
|
|
59
90
|
{ name: 'config', type: String },
|
|
60
|
-
// The 'root' directory for the publishing.
|
|
61
|
-
// All assets are expected to exist under this root. Required.
|
|
62
|
-
// For backwards compatibility, if this value is not provided,
|
|
63
|
-
// then the value of 'public-dir' is used.
|
|
64
|
-
{ name: 'root-dir', type: String, },
|
|
65
|
-
// Collection name to be used for this publishing.
|
|
66
91
|
{ name: 'collection-name', type: String, },
|
|
92
|
+
{ name: 'root-dir', type: String, },
|
|
93
|
+
{ name: 'kv-overwrite', type: Boolean },
|
|
67
94
|
{ name: 'expires-in', type: String },
|
|
68
95
|
{ name: 'expires-at', type: String },
|
|
69
|
-
{ name: '
|
|
70
|
-
{ name: '
|
|
71
|
-
{ name: 'kv-overwrite', type: Boolean },
|
|
72
|
-
// Fastly API Token to use for this publishing.
|
|
96
|
+
{ name: 'expires-never', type: Boolean },
|
|
97
|
+
{ name: 'local', type: Boolean },
|
|
73
98
|
{ name: 'fastly-api-token', type: String, },
|
|
74
99
|
];
|
|
75
100
|
const parsed = parseCommandLine(actionArgs, optionDefinitions);
|
|
@@ -82,13 +107,7 @@ export async function action(actionArgs) {
|
|
|
82
107
|
help();
|
|
83
108
|
return;
|
|
84
109
|
}
|
|
85
|
-
const { verbose, ['
|
|
86
|
-
// no-local and local-only are mutually exclusive
|
|
87
|
-
if (noLocalMode && localOnlyMode) {
|
|
88
|
-
console.error("❌ '--no-local' and '--local-only' are mutually exclusive.");
|
|
89
|
-
process.exitCode = 1;
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
110
|
+
const { verbose, config: configFilePathValue, ['collection-name']: collectionNameValue, ['root-dir']: rootDir, ['kv-overwrite']: overwriteKvStoreItems, ['expires-in']: expiresIn, ['expires-at']: expiresAt, ['expires-never']: expiresNever, local: localMode, ['fastly-api-token']: fastlyApiToken, } = parsed.commandLineOptions;
|
|
92
111
|
// compute-js-static-publisher cli is always run from the Compute application directory
|
|
93
112
|
// in other words, the directory that contains `fastly.toml`.
|
|
94
113
|
const computeAppDir = path.resolve();
|
|
@@ -108,35 +127,18 @@ export async function action(actionArgs) {
|
|
|
108
127
|
process.exitCode = 1;
|
|
109
128
|
return;
|
|
110
129
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
else {
|
|
117
|
-
createLocalFiles = true;
|
|
118
|
-
}
|
|
119
|
-
// Use the KV Store unless 'local-only' is set
|
|
120
|
-
let useKvStore = false;
|
|
121
|
-
if (serviceId == null) {
|
|
122
|
-
console.log(`ℹ️ 'service_id' not set in 'fastly.toml' - skipping creation of files for Fastly KV Store`);
|
|
123
|
-
}
|
|
124
|
-
else if (localOnlyMode) {
|
|
125
|
-
console.log(`ℹ️ 'Local only mode' - skipping creation of files for Fastly KV Store`);
|
|
130
|
+
console.log(`🚀 Publishing content...`);
|
|
131
|
+
// Verify targets
|
|
132
|
+
let fastlyApiContext = undefined;
|
|
133
|
+
if (localMode) {
|
|
134
|
+
console.log(` Working on local simulated KV Store...`);
|
|
126
135
|
}
|
|
127
136
|
else {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
if (useKvStore) {
|
|
135
|
-
segments.push('to the Fastly KV Store');
|
|
136
|
-
}
|
|
137
|
-
console.log(`🚀 Publishing content ${segments.join(' and ')}...`);
|
|
138
|
-
let fastlyApiContext = undefined;
|
|
139
|
-
if (useKvStore) {
|
|
137
|
+
if (serviceId === null) {
|
|
138
|
+
console.log(`❌️ 'service_id' not set in 'fastly.toml' - Deploy your Compute app to Fastly before publishing.`);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
140
142
|
const apiTokenResult = loadApiToken({ commandLine: fastlyApiToken });
|
|
141
143
|
if (apiTokenResult == null) {
|
|
142
144
|
console.error("❌ Fastly API Token not provided.");
|
|
@@ -146,6 +148,7 @@ export async function action(actionArgs) {
|
|
|
146
148
|
}
|
|
147
149
|
fastlyApiContext = { apiToken: apiTokenResult.apiToken };
|
|
148
150
|
console.log(`✔️ Fastly API Token: ${fastlyApiContext.apiToken.slice(0, 4)}${'*'.repeat(fastlyApiContext.apiToken.length - 4)} from '${apiTokenResult.source}'`);
|
|
151
|
+
console.log(` Working on the Fastly KV Store...`);
|
|
149
152
|
}
|
|
150
153
|
// #### load config
|
|
151
154
|
let staticPublisherRc;
|
|
@@ -188,7 +191,7 @@ export async function action(actionArgs) {
|
|
|
188
191
|
}
|
|
189
192
|
let expirationTime;
|
|
190
193
|
try {
|
|
191
|
-
expirationTime = calcExpirationTime({ expiresIn, expiresAt });
|
|
194
|
+
expirationTime = calcExpirationTime({ expiresIn, expiresAt, expiresNever });
|
|
192
195
|
}
|
|
193
196
|
catch (err) {
|
|
194
197
|
console.error(`❌ Cannot process expiration time`);
|
|
@@ -203,8 +206,9 @@ export async function action(actionArgs) {
|
|
|
203
206
|
console.log(` | Using KV Store: ${kvStoreName}`);
|
|
204
207
|
const defaultCollectionName = staticPublisherRc.defaultCollectionName;
|
|
205
208
|
console.log(` | Default Collection Name: ${defaultCollectionName}`);
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
const staticPublisherWorkingDir = staticPublisherRc.staticPublisherWorkingDir;
|
|
210
|
+
console.log(` | Static publisher working directory: ${staticPublisherWorkingDir}`);
|
|
211
|
+
const storeFile = path.resolve(staticPublisherWorkingDir, `./kvstore.json`);
|
|
208
212
|
// Load content types
|
|
209
213
|
const contentTypes = mergeContentTypes(publishContentConfig.contentTypes);
|
|
210
214
|
// #### Collect all file paths
|
|
@@ -236,7 +240,14 @@ export async function action(actionArgs) {
|
|
|
236
240
|
else {
|
|
237
241
|
console.log(`✔️ Publishing with no expiration timestamp.`);
|
|
238
242
|
}
|
|
239
|
-
if (
|
|
243
|
+
if (expirationTime == null) {
|
|
244
|
+
// includes null and undefined
|
|
245
|
+
console.log(`✔️ Publishing with no expiration timestamp.`);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
console.log(`✔️ Updating expiration timestamp: ${new Date(expirationTime * 1000).toISOString()}`);
|
|
249
|
+
}
|
|
250
|
+
if (collectionName === defaultCollectionName && expirationTime !== undefined) {
|
|
240
251
|
console.log(` ⚠️ NOTE: Expiration time not enforced for default collection.`);
|
|
241
252
|
}
|
|
242
253
|
// files to be included in the build/publish
|
|
@@ -323,7 +334,7 @@ export async function action(actionArgs) {
|
|
|
323
334
|
}
|
|
324
335
|
else {
|
|
325
336
|
let kvStoreItemMetadata = null;
|
|
326
|
-
if (
|
|
337
|
+
if (!localMode && !overwriteKvStoreItems) {
|
|
327
338
|
const items = [{
|
|
328
339
|
key: variantKey,
|
|
329
340
|
}];
|
|
@@ -386,7 +397,7 @@ export async function action(actionArgs) {
|
|
|
386
397
|
}
|
|
387
398
|
else {
|
|
388
399
|
await ensureVariantFileExists(variantFilePath, variant, file);
|
|
389
|
-
if (
|
|
400
|
+
if (!localMode) {
|
|
390
401
|
console.log(` ・ Flagging asset for upload to KV Store with key "${variantKey}".`);
|
|
391
402
|
}
|
|
392
403
|
let contentEncoding, hash, size;
|
|
@@ -421,8 +432,8 @@ export async function action(actionArgs) {
|
|
|
421
432
|
numChunks: variantMetadata.numChunks,
|
|
422
433
|
},
|
|
423
434
|
});
|
|
424
|
-
if (
|
|
425
|
-
// Although we already know the size and hash of the
|
|
435
|
+
if (localMode) {
|
|
436
|
+
// Although we already know the size and hash of the variant, the local server
|
|
426
437
|
// needs a copy of the file so we create it if it doesn't exist.
|
|
427
438
|
// This may happen for example if files were uploaded to the KV Store in a previous
|
|
428
439
|
// publishing, but local static content files have been removed since.
|
|
@@ -445,6 +456,11 @@ export async function action(actionArgs) {
|
|
|
445
456
|
};
|
|
446
457
|
}
|
|
447
458
|
console.log(`✅ Scan complete.`);
|
|
459
|
+
// TODO: fix this bug:
|
|
460
|
+
// Technically it's a bug to WRITE the index and settings json files to the
|
|
461
|
+
// staticPublisherKvStoreContent dir when target === 'fastly'.
|
|
462
|
+
// For these files we should not be creating the files using
|
|
463
|
+
// kvStoreItemDescriptions, but rather creating them directly.
|
|
448
464
|
// #### INDEX FILE
|
|
449
465
|
console.log(`🗂️ Creating Index...`);
|
|
450
466
|
const indexFileName = `index_${collectionName}.json`;
|
|
@@ -454,7 +470,7 @@ export async function action(actionArgs) {
|
|
|
454
470
|
const indexFileSize = getFileSize(indexFilePath);
|
|
455
471
|
const indexMetadata = {
|
|
456
472
|
publishedTime: Math.floor(Date.now() / 1000),
|
|
457
|
-
expirationTime,
|
|
473
|
+
expirationTime: expirationTime ?? undefined,
|
|
458
474
|
};
|
|
459
475
|
kvStoreItemDescriptions.push({
|
|
460
476
|
write: true,
|
|
@@ -538,7 +554,12 @@ export async function action(actionArgs) {
|
|
|
538
554
|
console.log(`🍪 Chunking large files...`);
|
|
539
555
|
await applyKVStoreEntriesChunks(kvStoreItemDescriptions, KV_STORE_CHUNK_SIZE);
|
|
540
556
|
console.log(`✅ Large files have been chunked.`);
|
|
541
|
-
if (
|
|
557
|
+
if (localMode) {
|
|
558
|
+
console.log(`📝 Writing local server KV Store entries.`);
|
|
559
|
+
writeKVStoreEntriesForLocal(storeFile, computeAppDir, kvStoreItemDescriptions);
|
|
560
|
+
console.log(`✅ Wrote KV Store entries for local server.`);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
542
563
|
console.log(`📤 Uploading entries to KV Store.`);
|
|
543
564
|
// fastlyApiContext is non-null if useKvStore is true
|
|
544
565
|
await doKvStoreItemsOperation(kvStoreItemDescriptions.filter(x => x.write), async ({ filePath, metadataJson }, key) => {
|
|
@@ -548,11 +569,5 @@ export async function action(actionArgs) {
|
|
|
548
569
|
});
|
|
549
570
|
console.log(`✅ Uploaded entries to KV Store.`);
|
|
550
571
|
}
|
|
551
|
-
if (createLocalFiles) {
|
|
552
|
-
console.log(`📝 Writing local server KV Store entries.`);
|
|
553
|
-
const storeFile = path.resolve(staticPublisherWorkingDir, `./kvstore.json`);
|
|
554
|
-
writeKVStoreEntriesForLocal(storeFile, computeAppDir, kvStoreItemDescriptions);
|
|
555
|
-
console.log(`✅ Wrote KV Store entries for local server.`);
|
|
556
|
-
}
|
|
557
572
|
console.log(`🎉 Completed.`);
|
|
558
573
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AA2DA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/scaffold/index.ts"],"names":[],"mappings":"AA2DA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBAwehD"}
|
|
@@ -28,8 +28,8 @@ Options:
|
|
|
28
28
|
--kv-store-name <name> (required) KV Store name for content storage
|
|
29
29
|
--root-dir <path> (required) Path to static content (e.g., ./public)
|
|
30
30
|
-o, --output <dir> Output directory for Compute app (default: ./compute-js)
|
|
31
|
+
--static-publisher-working-dir <dir> Working directory for build artifacts (default: <output>/static-publisher)
|
|
31
32
|
--publish-id <id> Advanced. Prefix for KV keys (default: "default")
|
|
32
|
-
--static-publisher-working-dir <dir> Working directory for build artifacts
|
|
33
33
|
(default: ./compute-js/static-publisher)
|
|
34
34
|
|
|
35
35
|
Compute Service Metadata:
|
|
@@ -542,11 +542,11 @@ export async function action(actionArgs) {
|
|
|
542
542
|
},
|
|
543
543
|
private: true,
|
|
544
544
|
scripts: {
|
|
545
|
-
|
|
546
|
-
start:
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
build: 'js-compute-runtime ./src/index.js ./bin/main.wasm'
|
|
545
|
+
'dev:publish': 'npx @fastly/compute-js-static-publish publish-content --local',
|
|
546
|
+
'dev:start': 'fastly compute serve',
|
|
547
|
+
'fastly:deploy': 'fastly compute publish',
|
|
548
|
+
'fastly:publish': 'npx @fastly/compute-js-static-publish publish-content',
|
|
549
|
+
'build': 'js-compute-runtime ./src/index.js ./bin/main.wasm'
|
|
550
550
|
},
|
|
551
551
|
}, undefined, 2);
|
|
552
552
|
// fastly.toml
|
|
@@ -582,6 +582,7 @@ const rc = {
|
|
|
582
582
|
kvStoreName: ${JSON.stringify(kvStoreName)},
|
|
583
583
|
publishId: ${JSON.stringify(publishId)},
|
|
584
584
|
defaultCollectionName: ${JSON.stringify(defaultCollectionName)},
|
|
585
|
+
staticPublisherWorkingDir: ${JSON.stringify(dotRelative(computeJsDir, staticPublisherWorkingDir))},
|
|
585
586
|
};
|
|
586
587
|
|
|
587
588
|
export default rc;
|
|
@@ -633,7 +634,6 @@ export default rc;
|
|
|
633
634
|
/** @type {import('@fastly/compute-js-static-publish').PublishContentConfig} */
|
|
634
635
|
const config = {
|
|
635
636
|
rootDir: ${JSON.stringify(dotRelative(computeJsDir, rootDir))},
|
|
636
|
-
staticPublisherWorkingDir: ${JSON.stringify(dotRelative(computeJsDir, staticPublisherWorkingDir))},
|
|
637
637
|
// excludeDirs: [ './node_modules' ],
|
|
638
638
|
// excludeDotFiles: true,
|
|
639
639
|
// includeWellKnown: true,
|
|
@@ -699,12 +699,13 @@ async function handleRequest(event) {
|
|
|
699
699
|
console.log('To run your Compute application locally:');
|
|
700
700
|
console.log('');
|
|
701
701
|
console.log(' cd ' + COMPUTE_JS_DIR);
|
|
702
|
-
console.log(' npm run
|
|
702
|
+
console.log(' npm run dev:publish');
|
|
703
|
+
console.log(' npm run dev:start');
|
|
703
704
|
console.log('');
|
|
704
705
|
console.log('To build and deploy to your Compute service:');
|
|
705
706
|
console.log('');
|
|
706
707
|
console.log(' cd ' + COMPUTE_JS_DIR);
|
|
707
|
-
console.log(' npm run
|
|
708
|
-
console.log(' npm run publish
|
|
708
|
+
console.log(' npm run fastly:deploy');
|
|
709
|
+
console.log(' npm run fastly:publish');
|
|
709
710
|
console.log('');
|
|
710
711
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-token.d.ts","sourceRoot":"","sources":["../../../src/cli/util/api-token.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,IAAI,CAwC7E;AAaD,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK3C,MAAM,EAAE,MAAM,CAAC;CAChB;AAWD,wBAAsB,aAAa,CACjC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,EACpC,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,QAAQ,CAAC,CAqCnB"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import cli from '@fastly/cli';
|
|
7
|
-
import { makeRetryable } from '
|
|
7
|
+
import { makeRetryable } from './retryable.js';
|
|
8
8
|
export function loadApiToken(params) {
|
|
9
9
|
let apiToken = null;
|
|
10
10
|
let source = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/cli/util/config.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,8BAA8B,EAEpC,MAAM,+CAA+C,CAAC;AAOvD,OAAO,EAAE,KAAK,+BAA+B,EAAE,MAAM,gDAAgD,CAAC;AACtG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEhF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEL,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAIrD;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,eAAe,CAAC,CA2B1E;AAGD,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/cli/util/config.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,8BAA8B,EAEpC,MAAM,+CAA+C,CAAC;AAOvD,OAAO,EAAE,KAAK,+BAA+B,EAAE,MAAM,gDAAgD,CAAC;AACtG,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEhF,qBAAa,eAAgB,SAAQ,KAAK;IACxC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEL,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAIrD;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,eAAe,CAAC,CA2B1E;AAGD,eAAO,MAAM,0BAA0B,6DA+DrC,CAAC;AAEH,wBAAsB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAyB9G;AA4CD,eAAO,MAAM,6BAA6B,4EAmJxC,CAAC;AAEH,eAAO,MAAM,8BAA8B,6EAkIzC,CAAC"}
|
package/build/cli/util/config.js
CHANGED
|
@@ -34,7 +34,7 @@ export async function loadStaticPublisherRcFile() {
|
|
|
34
34
|
return config;
|
|
35
35
|
}
|
|
36
36
|
export const normalizeStaticPublisherRc = buildNormalizeFunctionForObject((config, errors) => {
|
|
37
|
-
let { kvStoreName, publishId, defaultCollectionName, } = config;
|
|
37
|
+
let { kvStoreName, publishId, defaultCollectionName, staticPublisherWorkingDir, } = config;
|
|
38
38
|
if (!isSpecified(config, 'kvStoreName')) {
|
|
39
39
|
errors.push('kvStoreName must be specified.');
|
|
40
40
|
}
|
|
@@ -68,10 +68,27 @@ export const normalizeStaticPublisherRc = buildNormalizeFunctionForObject((confi
|
|
|
68
68
|
errors.push('defaultCollectionName must be a non-empty string.');
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
if (!isSpecified(config, 'staticPublisherWorkingDir')) {
|
|
72
|
+
errors.push('staticPublisherWorkingDir must be specified.');
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (staticPublisherWorkingDir.startsWith('./') &&
|
|
76
|
+
staticPublisherWorkingDir !== './' &&
|
|
77
|
+
!staticPublisherWorkingDir.includes('//')) {
|
|
78
|
+
// ok
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
errors.push('staticPublisherWorkingDir must be a relative subdirectory.');
|
|
82
|
+
}
|
|
83
|
+
while (staticPublisherWorkingDir.endsWith('/')) {
|
|
84
|
+
staticPublisherWorkingDir = staticPublisherWorkingDir.slice(0, -1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
71
87
|
return {
|
|
72
88
|
kvStoreName,
|
|
73
89
|
publishId,
|
|
74
90
|
defaultCollectionName,
|
|
91
|
+
staticPublisherWorkingDir,
|
|
75
92
|
};
|
|
76
93
|
});
|
|
77
94
|
export async function loadPublishContentConfigFile(configFile) {
|
|
@@ -133,7 +150,7 @@ const normalizeContentTypeDefs = buildNormalizeFunctionForArray((config, errors)
|
|
|
133
150
|
return normalizeContentTypeDef(config, errors);
|
|
134
151
|
});
|
|
135
152
|
export const normalizePublishContentConfig = buildNormalizeFunctionForObject((config, errors) => {
|
|
136
|
-
let { rootDir,
|
|
153
|
+
let { rootDir, excludeDirs, excludeDotFiles, includeWellKnown, kvStoreAssetInclusionTest, contentCompression, contentTypes, server, } = config;
|
|
137
154
|
if (!isSpecified(config, 'rootDir')) {
|
|
138
155
|
errors.push('rootDir must be specified.');
|
|
139
156
|
}
|
|
@@ -145,22 +162,6 @@ export const normalizePublishContentConfig = buildNormalizeFunctionForObject((co
|
|
|
145
162
|
errors.push('rootDir must be a non-empty string.');
|
|
146
163
|
}
|
|
147
164
|
}
|
|
148
|
-
if (!isSpecified(config, 'staticPublisherWorkingDir')) {
|
|
149
|
-
errors.push('staticPublisherWorkingDir must be specified.');
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
if (staticPublisherWorkingDir.startsWith('./') &&
|
|
153
|
-
staticPublisherWorkingDir !== './' &&
|
|
154
|
-
!staticPublisherWorkingDir.includes('//')) {
|
|
155
|
-
// ok
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
errors.push('staticPublisherWorkingDir must be a relative subdirectory.');
|
|
159
|
-
}
|
|
160
|
-
while (staticPublisherWorkingDir.endsWith('/')) {
|
|
161
|
-
staticPublisherWorkingDir = staticPublisherWorkingDir.slice(0, -1);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
165
|
if (!isSpecified(config, 'excludeDotFiles')) {
|
|
165
166
|
excludeDotFiles = true;
|
|
166
167
|
}
|
|
@@ -284,7 +285,6 @@ export const normalizePublishContentConfig = buildNormalizeFunctionForObject((co
|
|
|
284
285
|
}
|
|
285
286
|
return {
|
|
286
287
|
rootDir,
|
|
287
|
-
staticPublisherWorkingDir,
|
|
288
288
|
excludeDirs,
|
|
289
289
|
excludeDotFiles,
|
|
290
290
|
includeWellKnown,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import { directoryExists, getFileSize } from './files.js';
|
|
7
7
|
import { attemptWithRetries } from './retryable.js';
|
|
8
|
-
import { FetchError } from '
|
|
8
|
+
import { FetchError } from './api-token.js';
|
|
9
9
|
export async function doKvStoreItemsOperation(objects, fn, maxConcurrent = 12) {
|
|
10
10
|
let index = 0; // Shared among workers
|
|
11
11
|
async function worker() {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { type KVStoreItemDesc } from './kv-store-items.js';
|
|
2
|
+
export declare function getLocalKVStoreKeys(storeFile: string, prefix?: string): Promise<string[]>;
|
|
3
|
+
export declare function getLocalKvStoreEntry(storeFile: string, key: string, metadataOnly?: boolean): Promise<{
|
|
4
|
+
metadata: string | null;
|
|
5
|
+
generation: null;
|
|
6
|
+
response: Response;
|
|
7
|
+
} | null>;
|
|
8
|
+
export declare function localKvStoreSubmitEntry(storeFile: string, key: string, file: string, metadata: string | undefined): Promise<void>;
|
|
9
|
+
export declare function localKvStoreDeleteEntry(storeFile: string, key: string): Promise<void>;
|
|
2
10
|
export declare function writeKVStoreEntriesForLocal(storeFile: string, computeAppDir: string, kvStoreItemDescriptions: KVStoreItemDesc[]): void;
|
|
3
11
|
//# sourceMappingURL=kv-store-local-server.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAK3D,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,qBAoBhB;AAED,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,OAAO;;;;UAgCvB;AAED,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,iBAmB7B;AAED,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,iBAgBZ;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,uBAAuB,EAAE,eAAe,EAAE,QAiC3C"}
|
|
@@ -4,6 +4,82 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
+
export async function getLocalKVStoreKeys(storeFile, prefix) {
|
|
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
|
+
let keys = Object.keys(store);
|
|
18
|
+
if (prefix != null) {
|
|
19
|
+
keys = keys.filter(key => key.startsWith(prefix));
|
|
20
|
+
}
|
|
21
|
+
return keys;
|
|
22
|
+
}
|
|
23
|
+
export async function getLocalKvStoreEntry(storeFile, key, metadataOnly) {
|
|
24
|
+
let store;
|
|
25
|
+
try {
|
|
26
|
+
// If the local KV store file exists, we have to add to it.
|
|
27
|
+
const storeFileJson = fs.readFileSync(storeFile, 'utf-8');
|
|
28
|
+
store = JSON.parse(storeFileJson);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
store = {};
|
|
32
|
+
}
|
|
33
|
+
const obj = store[key];
|
|
34
|
+
if (obj == null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
let response;
|
|
38
|
+
if (metadataOnly) {
|
|
39
|
+
response = new Response(null);
|
|
40
|
+
}
|
|
41
|
+
else if ('data' in obj) {
|
|
42
|
+
response = new Response(obj.data);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const fileData = fs.readFileSync(obj.file);
|
|
46
|
+
response = new Response(fileData);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
metadata: obj.metadata ?? null,
|
|
50
|
+
generation: null,
|
|
51
|
+
response,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export async function localKvStoreSubmitEntry(storeFile, key, file, metadata) {
|
|
55
|
+
let store;
|
|
56
|
+
try {
|
|
57
|
+
// If the local KV store file exists, we have to add to it.
|
|
58
|
+
const storeFileJson = fs.readFileSync(storeFile, 'utf-8');
|
|
59
|
+
store = JSON.parse(storeFileJson);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
store = {};
|
|
63
|
+
}
|
|
64
|
+
store[key] = {
|
|
65
|
+
file,
|
|
66
|
+
metadata,
|
|
67
|
+
};
|
|
68
|
+
fs.writeFileSync(storeFile, JSON.stringify(store));
|
|
69
|
+
}
|
|
70
|
+
export async function localKvStoreDeleteEntry(storeFile, key) {
|
|
71
|
+
let store;
|
|
72
|
+
try {
|
|
73
|
+
// If the local KV store file exists, we have to add to it.
|
|
74
|
+
const storeFileJson = fs.readFileSync(storeFile, 'utf-8');
|
|
75
|
+
store = JSON.parse(storeFileJson);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
store = {};
|
|
79
|
+
}
|
|
80
|
+
delete store[key];
|
|
81
|
+
fs.writeFileSync(storeFile, JSON.stringify(store));
|
|
82
|
+
}
|
|
7
83
|
export function writeKVStoreEntriesForLocal(storeFile, computeAppDir, kvStoreItemDescriptions) {
|
|
8
84
|
let store;
|
|
9
85
|
try {
|
|
@@ -8,16 +8,16 @@ export declare function getKVStoreIdForName(fastlyApiContext: FastlyApiContext,
|
|
|
8
8
|
export declare function getKVStoreInfos(fastlyApiContext: FastlyApiContext): Promise<KVStoreInfo[]>;
|
|
9
9
|
export declare const _getKVStoreKeys: (fastlyApiContext: FastlyApiContext, operationName: string, kvStoreId: string, prefix?: string | undefined) => Promise<string[]>;
|
|
10
10
|
export declare function getKVStoreKeys(fastlyApiContext: FastlyApiContext, kvStoreName: string, prefix?: string): Promise<string[] | null>;
|
|
11
|
-
export declare function getKvStoreEntryInfo(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<
|
|
11
|
+
export declare function getKvStoreEntryInfo(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<{
|
|
12
12
|
metadata: string | null;
|
|
13
13
|
generation: string | null;
|
|
14
14
|
response: Response;
|
|
15
|
-
}>;
|
|
16
|
-
export declare function getKvStoreEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, metadataOnly?: boolean): Promise<
|
|
15
|
+
} | null>;
|
|
16
|
+
export declare function getKvStoreEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, metadataOnly?: boolean): Promise<{
|
|
17
17
|
metadata: string | null;
|
|
18
18
|
generation: string | null;
|
|
19
19
|
response: Response;
|
|
20
|
-
}>;
|
|
20
|
+
} | null>;
|
|
21
21
|
export declare function kvStoreSubmitEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, data: ReadableStream<Uint8Array> | Uint8Array | string, metadata: string | undefined): Promise<void>;
|
|
22
22
|
export declare function kvStoreDeleteEntry(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<void>;
|
|
23
23
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,gBAAgB,EAAc,MAAM,gBAAgB,CAAC;AAElF,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmBF,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,mCAkB9E;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAKhG;AAqCD,wBAAsB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,0BAcvE;AAED,eAAO,MAAM,eAAe,qBAjDgB,gBAAgB,iBAAiB,MAAM,sEAyDlF,CAAC;AAEF,wBAAsB,cAAc,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,4BAchB;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;;;;UAI7G;AAED,wBAAsB,eAAe,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,YAAY,CAAC,EAAE,OAAO;;;;UA8BvB;AAGD,wBAAsB,kBAAkB,CACtC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,MAAM,EACtD,QAAQ,EAAE,MAAM,GAAG,SAAS,iBAoB7B;AAED,wBAAsB,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAa5G"}
|
|
@@ -78,7 +78,7 @@ export async function getKvStoreEntryInfo(fastlyApiContext, kvStoreName, key) {
|
|
|
78
78
|
export async function getKvStoreEntry(fastlyApiContext, kvStoreName, key, metadataOnly) {
|
|
79
79
|
const kvStoreId = await getKVStoreIdForName(fastlyApiContext, kvStoreName);
|
|
80
80
|
if (kvStoreId == null) {
|
|
81
|
-
return
|
|
81
|
+
return null;
|
|
82
82
|
}
|
|
83
83
|
const endpoint = `/resources/stores/kv/${encodeURIComponent(kvStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
84
84
|
let response;
|
|
@@ -87,7 +87,7 @@ export async function getKvStoreEntry(fastlyApiContext, kvStoreName, key, metada
|
|
|
87
87
|
}
|
|
88
88
|
catch (err) {
|
|
89
89
|
if (err instanceof FetchError && err.status === 404) {
|
|
90
|
-
return
|
|
90
|
+
return null;
|
|
91
91
|
}
|
|
92
92
|
throw err;
|
|
93
93
|
}
|
|
@@ -18,7 +18,6 @@ export interface ExcludeDirTest {
|
|
|
18
18
|
export type KVStoreAssetInclusionTest = (assetKey: string, contentType?: string) => boolean;
|
|
19
19
|
export type PublishContentConfig = {
|
|
20
20
|
rootDir: string;
|
|
21
|
-
staticPublisherWorkingDir: string;
|
|
22
21
|
excludeDirs?: (string | ExcludeDirTest)[] | string | ExcludeDirTest | null;
|
|
23
22
|
excludeDotFiles?: boolean;
|
|
24
23
|
includeWellKnown?: boolean;
|
|
@@ -29,7 +28,6 @@ export type PublishContentConfig = {
|
|
|
29
28
|
};
|
|
30
29
|
export type PublishContentConfigNormalized = {
|
|
31
30
|
rootDir: string;
|
|
32
|
-
staticPublisherWorkingDir: string;
|
|
33
31
|
excludeDirs: ExcludeDirTest[];
|
|
34
32
|
excludeDotFiles: boolean;
|
|
35
33
|
includeWellKnown: boolean;
|
|
@@ -1 +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;
|
|
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;IAMhB,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,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"}
|