@fastly/compute-js-static-publish 4.2.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -50
- package/build/cli/commands/build-static.js +49 -49
- package/build/cli/commands/clean-kv-store.d.ts +3 -0
- package/build/cli/commands/clean-kv-store.d.ts.map +1 -0
- package/build/cli/commands/clean-kv-store.js +54 -0
- package/build/cli/commands/init-app.js +11 -11
- package/build/cli/index.js +9 -9
- package/build/cli/load-config.js +9 -9
- package/build/cli/presets/preset-base.d.ts +1 -1
- package/build/cli/presets/preset-base.d.ts.map +1 -1
- package/build/cli/util/fastly-api.js +1 -1
- package/build/cli/util/kv-store.d.ts +16 -0
- package/build/cli/util/kv-store.d.ts.map +1 -0
- package/build/cli/util/kv-store.js +108 -0
- package/build/compute-js.d.ts +1 -1
- package/build/compute-js.d.ts.map +1 -1
- package/build/compute-js.js +1 -1
- package/build/server/assets/content-asset-kv-store.d.ts +18 -0
- package/build/server/assets/content-asset-kv-store.d.ts.map +1 -0
- package/build/server/assets/content-asset-kv-store.js +67 -0
- package/build/server/assets/content-asset-wasm-inline.js +1 -1
- package/build/server/assets/content-assets.js +1 -1
- package/build/server/kv-store/inline-store-entry.d.ts +25 -0
- package/build/server/kv-store/inline-store-entry.d.ts.map +1 -0
- package/build/server/kv-store/inline-store-entry.js +100 -0
- package/build/types/config-normalized.d.ts +1 -1
- package/build/types/config.d.ts +1 -1
- package/build/types/content-assets.d.ts +6 -6
- package/build/types/content-assets.d.ts.map +1 -1
- package/build/util/metadata.d.ts +1 -1
- package/build/util/metadata.d.ts.map +1 -1
- package/build/util/metadata.js +4 -4
- package/package.json +2 -2
- package/resources/statics-metadata.d.ts +1 -1
package/build/cli/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import commandLineArgs from "command-line-args";
|
|
3
3
|
import { initApp } from "./commands/init-app.js";
|
|
4
4
|
import { buildStaticLoader } from "./commands/build-static.js";
|
|
5
|
-
import {
|
|
5
|
+
import { cleanKVStore } from "./commands/clean-kv-store.js";
|
|
6
6
|
const optionDefinitions = [
|
|
7
7
|
// (optional) Should be one of:
|
|
8
8
|
// - cra (or create-react-app)
|
|
@@ -63,11 +63,11 @@ const optionDefinitions = [
|
|
|
63
63
|
{ name: 'description', type: String, },
|
|
64
64
|
// Fastly Service ID to be added to the fastly.toml that is generated.
|
|
65
65
|
{ name: 'service-id', type: String },
|
|
66
|
-
// The name of a Fastly
|
|
66
|
+
// The name of a Fastly KV Store to hold the content assets.
|
|
67
67
|
// It must be linked to the service specified by `--service-id`.
|
|
68
|
-
{ name: '
|
|
69
|
-
// Clean
|
|
70
|
-
{ name: 'clean-
|
|
68
|
+
{ name: 'kv-store-name', type: String },
|
|
69
|
+
// Clean KV Store mode
|
|
70
|
+
{ name: 'clean-kv-store', type: Boolean, },
|
|
71
71
|
];
|
|
72
72
|
const commandLineValues = commandLineArgs(optionDefinitions);
|
|
73
73
|
console.log("Fastly Compute@Edge JavaScript Static Publisher");
|
|
@@ -75,8 +75,8 @@ let mode = 'init-app';
|
|
|
75
75
|
if (commandLineValues['build-static']) {
|
|
76
76
|
mode = 'build-static';
|
|
77
77
|
}
|
|
78
|
-
else if (commandLineValues['clean-
|
|
79
|
-
mode = 'clean-
|
|
78
|
+
else if (commandLineValues['clean-kv-store']) {
|
|
79
|
+
mode = 'clean-kv-store';
|
|
80
80
|
}
|
|
81
81
|
switch (mode) {
|
|
82
82
|
case 'build-static':
|
|
@@ -85,7 +85,7 @@ switch (mode) {
|
|
|
85
85
|
case 'init-app':
|
|
86
86
|
initApp(commandLineValues);
|
|
87
87
|
break;
|
|
88
|
-
case 'clean-
|
|
89
|
-
await
|
|
88
|
+
case 'clean-kv-store':
|
|
89
|
+
await cleanKVStore(commandLineValues);
|
|
90
90
|
break;
|
|
91
91
|
}
|
package/build/cli/load-config.js
CHANGED
|
@@ -172,7 +172,7 @@ const normalizePublisherServerConfig = buildNormalizeFunctionForObject((config,
|
|
|
172
172
|
};
|
|
173
173
|
});
|
|
174
174
|
const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
|
|
175
|
-
let { rootDir,
|
|
175
|
+
let { rootDir, kvStoreName, excludeDirs, excludeDotFiles, includeWellKnown, contentAssetInclusionTest, contentCompression, moduleAssetInclusionTest, contentTypes, server, } = config;
|
|
176
176
|
if (!isSpecified(config, 'rootDir')) {
|
|
177
177
|
errors.push('rootDir must be specified.');
|
|
178
178
|
}
|
|
@@ -184,18 +184,18 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
|
|
|
184
184
|
errors.push('rootDir must be a non-empty string.');
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
if (!isSpecified(config, '
|
|
188
|
-
|
|
187
|
+
if (!isSpecified(config, 'kvStoreName')) {
|
|
188
|
+
kvStoreName = null;
|
|
189
189
|
}
|
|
190
190
|
else {
|
|
191
|
-
if (isStringAndNotEmpty(
|
|
191
|
+
if (isStringAndNotEmpty(kvStoreName) || kvStoreName === null) {
|
|
192
192
|
// ok
|
|
193
193
|
}
|
|
194
|
-
else if (
|
|
195
|
-
|
|
194
|
+
else if (kvStoreName === false) {
|
|
195
|
+
kvStoreName = null;
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
errors.push('
|
|
198
|
+
errors.push('kvStoreName, if specified, must be a non-empty string, false, or null.');
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
if (!isSpecified(config, 'excludeDotFiles')) {
|
|
@@ -267,7 +267,7 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
|
|
|
267
267
|
errors.push('contentAssetInclusionTest, if specified, must be null or a function.');
|
|
268
268
|
}
|
|
269
269
|
if (!isSpecified(config, 'contentCompression')) {
|
|
270
|
-
if (
|
|
270
|
+
if (kvStoreName != null) {
|
|
271
271
|
contentCompression = ['br', 'gzip'];
|
|
272
272
|
}
|
|
273
273
|
else {
|
|
@@ -335,7 +335,7 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
|
|
|
335
335
|
}
|
|
336
336
|
return {
|
|
337
337
|
rootDir,
|
|
338
|
-
|
|
338
|
+
kvStoreName,
|
|
339
339
|
excludeDotFiles,
|
|
340
340
|
includeWellKnown,
|
|
341
341
|
excludeDirs,
|
|
@@ -10,7 +10,7 @@ export type AppOptions = {
|
|
|
10
10
|
author: string | undefined;
|
|
11
11
|
description: string | undefined;
|
|
12
12
|
serviceId: string | undefined;
|
|
13
|
-
|
|
13
|
+
kvStoreName: string | undefined;
|
|
14
14
|
};
|
|
15
15
|
export interface IPresetBase {
|
|
16
16
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,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,
|
|
1
|
+
{"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,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,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
|
|
@@ -11,7 +11,7 @@ export function loadApiKey() {
|
|
|
11
11
|
if (apiToken == null) {
|
|
12
12
|
// Try to get API key from fastly cli
|
|
13
13
|
try {
|
|
14
|
-
apiToken = execSync('fastly profile token', {
|
|
14
|
+
apiToken = execSync('fastly profile token --quiet', {
|
|
15
15
|
encoding: 'utf-8',
|
|
16
16
|
})?.trim() || null;
|
|
17
17
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FastlyApiContext } from "./fastly-api.js";
|
|
2
|
+
type KVStoreInfo = {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
type KVStoreEntryInfo = string;
|
|
7
|
+
export declare function getKVStoreIdForNameMap(fastlyApiContext: FastlyApiContext): Promise<Record<string, string>>;
|
|
8
|
+
export declare function getKVStoreIdForName(fastlyApiContext: FastlyApiContext, kvStoreName: string): Promise<string | null>;
|
|
9
|
+
export declare function getKVStoreInfos(fastlyApiContext: FastlyApiContext): Promise<KVStoreInfo[]>;
|
|
10
|
+
export declare const _getKVStoreKeys: (fastlyApiContext: FastlyApiContext, kvStoreId: string) => Promise<string[]>;
|
|
11
|
+
export declare function getKVStoreKeys(fastlyApiContext: FastlyApiContext, kvStoreName: string): Promise<KVStoreEntryInfo[] | null>;
|
|
12
|
+
export declare function kvStoreEntryExists(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<boolean>;
|
|
13
|
+
export declare function kvStoreSubmitFile(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string, data: Uint8Array | string): Promise<void>;
|
|
14
|
+
export declare function kvStoreDeleteFile(fastlyApiContext: FastlyApiContext, kvStoreName: string, key: string): Promise<void>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=kv-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/cli/util/kv-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElE,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAUF,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAS/B,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBhH;AAED,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIzH;AAwCD,wBAAsB,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAchG;AAED,eAAO,MAAM,eAAe,qBApDgB,gBAAgB,yCAoD6F,CAAC;AAE1J,wBAAsB,cAAc,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,CAQhI;AAED,wBAAsB,kBAAkB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAa/H;AAGD,wBAAsB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBtJ;AAED,wBAAsB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB3H"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { callFastlyApi } from "./fastly-api.js";
|
|
2
|
+
const cache = new WeakMap();
|
|
3
|
+
export async function getKVStoreIdForNameMap(fastlyApiContext) {
|
|
4
|
+
const cacheEntry = cache.get(fastlyApiContext);
|
|
5
|
+
let kvStoreNameMap = cacheEntry?.kvStoreNameMap;
|
|
6
|
+
if (kvStoreNameMap != null) {
|
|
7
|
+
return kvStoreNameMap;
|
|
8
|
+
}
|
|
9
|
+
const kvStoreInfos = await getKVStoreInfos(fastlyApiContext);
|
|
10
|
+
kvStoreNameMap = {};
|
|
11
|
+
for (const { id, name } of kvStoreInfos) {
|
|
12
|
+
kvStoreNameMap[name] = id;
|
|
13
|
+
}
|
|
14
|
+
cache.set(fastlyApiContext, { ...cacheEntry, kvStoreNameMap });
|
|
15
|
+
return kvStoreNameMap;
|
|
16
|
+
}
|
|
17
|
+
export async function getKVStoreIdForName(fastlyApiContext, kvStoreName) {
|
|
18
|
+
const kvStoreNameMap = await getKVStoreIdForNameMap(fastlyApiContext);
|
|
19
|
+
return kvStoreNameMap[kvStoreName] ?? null;
|
|
20
|
+
}
|
|
21
|
+
function createArrayGetter() {
|
|
22
|
+
return function (fn) {
|
|
23
|
+
return async function (fastlyApiContext, ...args) {
|
|
24
|
+
const results = [];
|
|
25
|
+
let cursor = null;
|
|
26
|
+
while (true) {
|
|
27
|
+
const queryParams = new URLSearchParams();
|
|
28
|
+
if (cursor != null) {
|
|
29
|
+
queryParams.set('cursor', cursor);
|
|
30
|
+
}
|
|
31
|
+
const endpoint = fn(...args);
|
|
32
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, queryParams);
|
|
33
|
+
if (response.status !== 200) {
|
|
34
|
+
throw new Error('Unexpected data format');
|
|
35
|
+
}
|
|
36
|
+
const infos = await response.json();
|
|
37
|
+
for (const item of infos.data) {
|
|
38
|
+
results.push(item);
|
|
39
|
+
}
|
|
40
|
+
if (infos.meta.next_cursor === undefined) {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
cursor = infos.meta.next_cursor;
|
|
44
|
+
}
|
|
45
|
+
return results;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const _getKVStoreInfos = createArrayGetter()(() => `/resources/stores/kv`);
|
|
50
|
+
export async function getKVStoreInfos(fastlyApiContext) {
|
|
51
|
+
const cacheEntry = cache.get(fastlyApiContext);
|
|
52
|
+
let kvStoreInfos = cacheEntry?.kvStoreInfos;
|
|
53
|
+
if (kvStoreInfos != null) {
|
|
54
|
+
return kvStoreInfos;
|
|
55
|
+
}
|
|
56
|
+
kvStoreInfos = await _getKVStoreInfos(fastlyApiContext);
|
|
57
|
+
cache.set(fastlyApiContext, { ...cacheEntry, kvStoreInfos });
|
|
58
|
+
return kvStoreInfos;
|
|
59
|
+
}
|
|
60
|
+
export const _getKVStoreKeys = createArrayGetter()((kvStoreId) => `/resources/stores/kv/${encodeURIComponent(kvStoreId)}/keys`);
|
|
61
|
+
export async function getKVStoreKeys(fastlyApiContext, kvStoreName) {
|
|
62
|
+
const kvStoreId = await getKVStoreIdForName(fastlyApiContext, kvStoreName);
|
|
63
|
+
if (kvStoreId == null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return await _getKVStoreKeys(fastlyApiContext, kvStoreId);
|
|
67
|
+
}
|
|
68
|
+
export async function kvStoreEntryExists(fastlyApiContext, kvStoreName, key) {
|
|
69
|
+
const kvStoreId = await getKVStoreIdForName(fastlyApiContext, kvStoreName);
|
|
70
|
+
if (kvStoreId == null) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const endpoint = `/resources/stores/kv/${encodeURIComponent(kvStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
74
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, null, { method: 'HEAD' });
|
|
75
|
+
return response.status === 200;
|
|
76
|
+
}
|
|
77
|
+
const encoder = new TextEncoder();
|
|
78
|
+
export async function kvStoreSubmitFile(fastlyApiContext, kvStoreName, key, data) {
|
|
79
|
+
const kvStoreId = await getKVStoreIdForName(fastlyApiContext, kvStoreName);
|
|
80
|
+
if (kvStoreId == null) {
|
|
81
|
+
throw new Error('KV Store not found');
|
|
82
|
+
}
|
|
83
|
+
const endpoint = `/resources/stores/kv/${encodeURIComponent(kvStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
84
|
+
const body = typeof data === 'string' ? encoder.encode(data) : data;
|
|
85
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, null, {
|
|
86
|
+
method: 'PUT',
|
|
87
|
+
headers: {
|
|
88
|
+
'content-type': 'application/octet-stream',
|
|
89
|
+
},
|
|
90
|
+
body,
|
|
91
|
+
});
|
|
92
|
+
if (response.status !== 200) {
|
|
93
|
+
throw new Error(`Submitting item ${key} gave error: ${response.status}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export async function kvStoreDeleteFile(fastlyApiContext, kvStoreName, key) {
|
|
97
|
+
const kvStoreId = await getKVStoreIdForName(fastlyApiContext, kvStoreName);
|
|
98
|
+
if (kvStoreId == null) {
|
|
99
|
+
throw new Error('KV Store not found');
|
|
100
|
+
}
|
|
101
|
+
const endpoint = `/resources/stores/kv/${encodeURIComponent(kvStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
102
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, null, {
|
|
103
|
+
method: 'DELETE',
|
|
104
|
+
});
|
|
105
|
+
if (response.status < 200 || response.status >= 300) {
|
|
106
|
+
throw new Error(`Deleting item '${key}' gave error: ${response.status}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
package/build/compute-js.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute-js.d.ts","sourceRoot":"","sources":["../src/compute-js.ts"],"names":[],"mappings":"AAAA,OAAO,8CAA8C,CAAC;AACtD,OAAO
|
|
1
|
+
{"version":3,"file":"compute-js.d.ts","sourceRoot":"","sources":["../src/compute-js.ts"],"names":[],"mappings":"AAAA,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC"}
|
package/build/compute-js.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './server/assets/content-asset-wasm-inline.js';
|
|
2
|
-
import './server/assets/content-asset-
|
|
2
|
+
import './server/assets/content-asset-kv-store.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ContentAsset, ContentAssetMetadataMapEntry, StoreEntry } from "../../types/index.js";
|
|
2
|
+
import { ContentAssetMetadataMapEntryKVStore } from "../../types/content-assets.js";
|
|
3
|
+
import { ContentCompressionTypes } from "../../constants/compression.js";
|
|
4
|
+
export declare class ContentKVStoreAsset implements ContentAsset {
|
|
5
|
+
readonly type = "kv-store";
|
|
6
|
+
private readonly metadata;
|
|
7
|
+
private readonly kvStoreName;
|
|
8
|
+
private readonly sourceAndInfo;
|
|
9
|
+
private readonly compressedSourcesAndInfo;
|
|
10
|
+
constructor(metadata: ContentAssetMetadataMapEntryKVStore, kvStoreName: string);
|
|
11
|
+
get isLocal(): boolean;
|
|
12
|
+
get assetKey(): string;
|
|
13
|
+
getStoreEntry(acceptEncodingsGroups?: ContentCompressionTypes[][]): Promise<StoreEntry>;
|
|
14
|
+
getBytes(): Uint8Array;
|
|
15
|
+
getText(): string;
|
|
16
|
+
getMetadata(): ContentAssetMetadataMapEntry;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=content-asset-kv-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-asset-kv-store.d.ts","sourceRoot":"","sources":["../../../src/server/assets/content-asset-kv-store.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,mCAAmC,EACpC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,qBAAa,mBAAoB,YAAW,YAAY;IACtD,QAAQ,CAAC,IAAI,cAAc;IAE3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;IAE/D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;IACtD,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA6C;gBAE1E,QAAQ,EAAE,mCAAmC,EAAE,WAAW,EAAE,MAAM;IAqB9E,IAAI,OAAO,YAEV;IAED,IAAI,QAAQ,WAEX;IAEK,aAAa,CAAC,qBAAqB,GAAE,uBAAuB,EAAE,EAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IA4BjG,QAAQ,IAAI,UAAU;IAItB,OAAO,IAAI,MAAM;IAIjB,WAAW,IAAI,4BAA4B;CAI5C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { KVStore } from "fastly:kv-store";
|
|
2
|
+
import { ContentAssets, findMatchingSourceAndInfo } from "./content-assets.js";
|
|
3
|
+
export class ContentKVStoreAsset {
|
|
4
|
+
constructor(metadata, kvStoreName) {
|
|
5
|
+
this.type = 'kv-store';
|
|
6
|
+
this.metadata = metadata;
|
|
7
|
+
this.kvStoreName = kvStoreName;
|
|
8
|
+
this.sourceAndInfo = {
|
|
9
|
+
source: metadata.fileInfo.kvStoreKey,
|
|
10
|
+
hash: metadata.fileInfo.hash,
|
|
11
|
+
size: metadata.fileInfo.size,
|
|
12
|
+
};
|
|
13
|
+
this.compressedSourcesAndInfo = Object.entries(metadata.compressedFileInfos)
|
|
14
|
+
.reduce((obj, [key, value]) => {
|
|
15
|
+
obj[key] = {
|
|
16
|
+
source: value.kvStoreKey,
|
|
17
|
+
hash: value.hash,
|
|
18
|
+
size: value.size,
|
|
19
|
+
};
|
|
20
|
+
return obj;
|
|
21
|
+
}, {});
|
|
22
|
+
}
|
|
23
|
+
get isLocal() {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
get assetKey() {
|
|
27
|
+
return this.metadata.assetKey;
|
|
28
|
+
}
|
|
29
|
+
async getStoreEntry(acceptEncodingsGroups = []) {
|
|
30
|
+
const { sourceAndInfo, contentEncoding } = findMatchingSourceAndInfo(acceptEncodingsGroups, this.sourceAndInfo, encoding => this.compressedSourcesAndInfo[encoding]);
|
|
31
|
+
const kvStore = new KVStore(this.kvStoreName);
|
|
32
|
+
let retries = 3;
|
|
33
|
+
while (retries > 0) {
|
|
34
|
+
const storeEntry = await kvStore.get(sourceAndInfo.source);
|
|
35
|
+
if (storeEntry != null) {
|
|
36
|
+
const { hash, size } = sourceAndInfo;
|
|
37
|
+
return Object.assign(storeEntry, { contentEncoding, hash, size });
|
|
38
|
+
}
|
|
39
|
+
// Note the null does NOT mean 404. The fact that we are here means
|
|
40
|
+
// metadata exists for this path, and we're just trying to get the data from
|
|
41
|
+
// the KV Store.
|
|
42
|
+
// So if we're here then the data is either not available yet (in which case
|
|
43
|
+
// we can wait just a bit and try again), or the data was deleted.
|
|
44
|
+
retries--;
|
|
45
|
+
// We're going to wait 250ms/500ms/750ms and try again.
|
|
46
|
+
const delay = (3 - retries) * 250;
|
|
47
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
48
|
+
}
|
|
49
|
+
throw new Error("Asset could not be retrieved from the KV Store.");
|
|
50
|
+
}
|
|
51
|
+
getBytes() {
|
|
52
|
+
throw new Error("Can't getBytes() for KV Store asset");
|
|
53
|
+
}
|
|
54
|
+
getText() {
|
|
55
|
+
throw new Error("Can't getText() for KV Store asset");
|
|
56
|
+
}
|
|
57
|
+
getMetadata() {
|
|
58
|
+
return this.metadata;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ContentAssets.registerAssetBuilder('kv-store', (metadata, context) => {
|
|
62
|
+
const { kvStoreName } = context;
|
|
63
|
+
if (kvStoreName == null) {
|
|
64
|
+
throw new Error("Unexpected! KV Store name should be specified!!");
|
|
65
|
+
}
|
|
66
|
+
return new ContentKVStoreAsset(metadata, kvStoreName);
|
|
67
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { includeBytes } from "fastly:experimental";
|
|
2
|
-
import { InlineStoreEntry } from "../
|
|
2
|
+
import { InlineStoreEntry } from "../kv-store/inline-store-entry.js";
|
|
3
3
|
import { ContentAssets, findMatchingSourceAndInfo } from "./content-assets.js";
|
|
4
4
|
const decoder = new TextDecoder();
|
|
5
5
|
export class ContentWasmInlineAsset {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetManager } from "./asset-manager.js";
|
|
2
|
-
import { InlineStoreEntry } from "../
|
|
2
|
+
import { InlineStoreEntry } from "../kv-store/inline-store-entry.js";
|
|
3
3
|
const decoder = new TextDecoder();
|
|
4
4
|
export function findMatchingSourceAndInfo(acceptEncodingsGroups, defaultSourceAndInfo, sourceAndInfoForEncodingFn) {
|
|
5
5
|
let sourceAndInfo;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StoreEntry } from "../../types/compute.js";
|
|
2
|
+
export declare class InlineStoreEntry implements StoreEntry {
|
|
3
|
+
_consumed: boolean;
|
|
4
|
+
_body: ReadableStreamForBytes;
|
|
5
|
+
_contentEncoding: string | null;
|
|
6
|
+
_hash: string;
|
|
7
|
+
_size: number;
|
|
8
|
+
constructor(array: Uint8Array, contentEncoding: string | null, hash: string, size: number);
|
|
9
|
+
get body(): ReadableStream<Uint8Array>;
|
|
10
|
+
get bodyUsed(): boolean;
|
|
11
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
12
|
+
static decoder: TextDecoder;
|
|
13
|
+
text(): Promise<string>;
|
|
14
|
+
json(): Promise<any>;
|
|
15
|
+
get contentEncoding(): string | null;
|
|
16
|
+
get hash(): string;
|
|
17
|
+
get size(): number;
|
|
18
|
+
}
|
|
19
|
+
declare class ReadableStreamForBytes extends ReadableStream<Uint8Array> {
|
|
20
|
+
_disturbed: boolean;
|
|
21
|
+
constructor(array: Uint8Array);
|
|
22
|
+
getReader(): ReadableStreamDefaultReader<Uint8Array>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=inline-store-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-store-entry.d.ts","sourceRoot":"","sources":["../../../src/server/kv-store/inline-store-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKpD,qBAAa,gBAAiB,YAAW,UAAU;IACjD,SAAS,EAAE,OAAO,CAAC;IAEnB,KAAK,EAAE,sBAAsB,CAAC;IAE9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQzF,IAAI,IAAI,IAAI,cAAc,CAAC,UAAU,CAAC,CAErC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAEK,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAiCzC,MAAM,CAAC,OAAO,cAAqB;IAC7B,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAKvB,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAK1B,IAAI,eAAe,kBAElB;IAED,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAEP;CACF;AAED,cAAM,sBAAuB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAG7D,UAAU,UAAS;gBAEP,KAAK,EAAE,UAAU;IASpB,SAAS,IAAI,2BAA2B,CAAC,UAAU,CAAC;CA6B9D"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// A class designed to give a Body-style interface to Uint8Array.
|
|
2
|
+
// The intended use case is arrays brought in from includeBytes().
|
|
3
|
+
class InlineStoreEntry {
|
|
4
|
+
constructor(array, contentEncoding, hash, size) {
|
|
5
|
+
this._body = new ReadableStreamForBytes(array);
|
|
6
|
+
this._consumed = false;
|
|
7
|
+
this._contentEncoding = contentEncoding;
|
|
8
|
+
this._hash = hash;
|
|
9
|
+
this._size = size;
|
|
10
|
+
}
|
|
11
|
+
get body() {
|
|
12
|
+
return this._body;
|
|
13
|
+
}
|
|
14
|
+
get bodyUsed() {
|
|
15
|
+
return this._consumed;
|
|
16
|
+
}
|
|
17
|
+
async arrayBuffer() {
|
|
18
|
+
if (this._consumed) {
|
|
19
|
+
throw new Error('Body has already been consumed');
|
|
20
|
+
}
|
|
21
|
+
if (this._body.locked) {
|
|
22
|
+
throw new Error('The ReadableStream body is already locked and can\'t be consumed');
|
|
23
|
+
}
|
|
24
|
+
if (this._body._disturbed) {
|
|
25
|
+
throw new Error('Body object should not be disturbed or locked');
|
|
26
|
+
}
|
|
27
|
+
this._consumed = true;
|
|
28
|
+
let result = new Uint8Array(0);
|
|
29
|
+
const reader = this._body.getReader();
|
|
30
|
+
try {
|
|
31
|
+
while (true) {
|
|
32
|
+
const { done, value } = await reader.read();
|
|
33
|
+
if (done) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
const newResult = new Uint8Array(result.length + value.length);
|
|
37
|
+
newResult.set(result);
|
|
38
|
+
newResult.set(value, result.length);
|
|
39
|
+
result = newResult;
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
reader.releaseLock();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async text() {
|
|
48
|
+
const data = await this.arrayBuffer();
|
|
49
|
+
return InlineStoreEntry.decoder.decode(data);
|
|
50
|
+
}
|
|
51
|
+
async json() {
|
|
52
|
+
const text = await this.text();
|
|
53
|
+
return JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
get contentEncoding() {
|
|
56
|
+
return this._contentEncoding;
|
|
57
|
+
}
|
|
58
|
+
get hash() {
|
|
59
|
+
return this._hash;
|
|
60
|
+
}
|
|
61
|
+
get size() {
|
|
62
|
+
return this._size;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
InlineStoreEntry.decoder = new TextDecoder();
|
|
66
|
+
export { InlineStoreEntry };
|
|
67
|
+
class ReadableStreamForBytes extends ReadableStream {
|
|
68
|
+
constructor(array) {
|
|
69
|
+
super({
|
|
70
|
+
async start(controller) {
|
|
71
|
+
controller.enqueue(array);
|
|
72
|
+
controller.close();
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
// Closest we can get to the "disturbed" flag
|
|
76
|
+
this._disturbed = false;
|
|
77
|
+
}
|
|
78
|
+
getReader() {
|
|
79
|
+
const reader = super.getReader();
|
|
80
|
+
const stream = this;
|
|
81
|
+
// Monkey-patch read
|
|
82
|
+
const _read = reader.read;
|
|
83
|
+
reader.read = async () => {
|
|
84
|
+
const result = await _read.call(reader);
|
|
85
|
+
if (result.done) {
|
|
86
|
+
// NOTE: C@E Request body does not seem to get marked as "disturbed" until
|
|
87
|
+
// end of stream is reached either...
|
|
88
|
+
stream._disturbed = true;
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
// Monkey-patch cancel
|
|
93
|
+
const _cancel = reader.cancel;
|
|
94
|
+
reader.cancel = async (reason) => {
|
|
95
|
+
await _cancel.call(reader, reason);
|
|
96
|
+
stream._disturbed = true;
|
|
97
|
+
};
|
|
98
|
+
return reader;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -11,7 +11,7 @@ export type ModuleAssetInclusionResultNormalized = {
|
|
|
11
11
|
};
|
|
12
12
|
export type StaticPublisherConfigNormalized = {
|
|
13
13
|
rootDir: string;
|
|
14
|
-
|
|
14
|
+
kvStoreName: string | null;
|
|
15
15
|
excludeDirs: ExcludeDirTest[];
|
|
16
16
|
excludeDotFiles: boolean;
|
|
17
17
|
includeWellKnown: boolean;
|
package/build/types/config.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type ModuleAssetInclusionResult = {
|
|
|
14
14
|
export type ModuleAssetInclusionTest = (assetKey: string, contentType?: string) => ModuleAssetInclusionResult | true | false | 'static-import' | null;
|
|
15
15
|
export type StaticPublisherConfig = {
|
|
16
16
|
rootDir: string;
|
|
17
|
-
|
|
17
|
+
kvStoreName?: string | false | null;
|
|
18
18
|
excludeDirs?: (string | ExcludeDirTest)[] | string | ExcludeDirTest | null;
|
|
19
19
|
excludeDotFiles?: boolean;
|
|
20
20
|
includeWellKnown?: boolean;
|
|
@@ -15,8 +15,8 @@ export type ContentFileInfoForStaticPublishing = ContentFileInfo & {
|
|
|
15
15
|
staticFilePath: string;
|
|
16
16
|
};
|
|
17
17
|
export type ContentFileInfoForWasmInline = ContentFileInfoForStaticPublishing;
|
|
18
|
-
export type
|
|
19
|
-
|
|
18
|
+
export type ContentFileInfoForKVStore = ContentFileInfoForStaticPublishing & {
|
|
19
|
+
kvStoreKey: string;
|
|
20
20
|
};
|
|
21
21
|
export type ContentAssetMetadataMapEntryBase<TFileInfo> = {
|
|
22
22
|
assetKey: string;
|
|
@@ -35,10 +35,10 @@ export type ContentAssetMetadataMapEntryString = {
|
|
|
35
35
|
export type ContentAssetMetadataMapEntryWasmInline = {
|
|
36
36
|
type: 'wasm-inline';
|
|
37
37
|
} & ContentAssetMetadataMapEntryBase<ContentFileInfoForWasmInline>;
|
|
38
|
-
export type
|
|
39
|
-
type: '
|
|
40
|
-
} & ContentAssetMetadataMapEntryBase<
|
|
41
|
-
export type ContentAssetMetadataMapEntry = ContentAssetMetadataMapEntryBytes | ContentAssetMetadataMapEntryString | ContentAssetMetadataMapEntryWasmInline |
|
|
38
|
+
export type ContentAssetMetadataMapEntryKVStore = {
|
|
39
|
+
type: 'kv-store';
|
|
40
|
+
} & ContentAssetMetadataMapEntryBase<ContentFileInfoForKVStore>;
|
|
41
|
+
export type ContentAssetMetadataMapEntry = ContentAssetMetadataMapEntryBytes | ContentAssetMetadataMapEntryString | ContentAssetMetadataMapEntryWasmInline | ContentAssetMetadataMapEntryKVStore;
|
|
42
42
|
export type ContentAssetMetadataMap = {
|
|
43
43
|
[assetKey: string]: ContentAssetMetadataMapEntry;
|
|
44
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-assets.d.ts","sourceRoot":"","sources":["../../src/types/content-assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG;IACtD,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IACvD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAAG;IACjE,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,kCAAkC,CAAC;AAE9E,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"content-assets.d.ts","sourceRoot":"","sources":["../../src/types/content-assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG;IACtD,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IACvD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAGF,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAAG;IACjE,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,kCAAkC,CAAC;AAE9E,MAAM,MAAM,yBAAyB,GAAG,kCAAkC,GAAG;IAC3E,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gCAAgC,CAAC,SAAS,IAAI;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,mBAAmB,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;CACpD,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,gCAAgC,CAAC,uBAAuB,CAAC,CAAC;AAC9D,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,QAAQ,CAAC;CAChB,GAAG,gCAAgC,CAAC,wBAAwB,CAAC,CAAC;AAE/D,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,aAAa,CAAC;CACrB,GAAG,gCAAgC,CAAC,4BAA4B,CAAC,CAAC;AAEnE,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,UAAU,CAAC;CAClB,GAAG,gCAAgC,CAAC,yBAAyB,CAAC,CAAC;AAEhE,MAAM,MAAM,4BAA4B,GACpC,iCAAiC,GACjC,kCAAkC,GAClC,sCAAsC,GACtC,mCAAmC,CAAC;AAExC,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,QAAQ,EAAE,MAAM,GAAG,4BAA4B,CAAC;CAClD,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,WAAW,IAAI,4BAA4B,CAAC;IAC5C,aAAa,CAAC,qBAAqB,CAAC,EAAE,uBAAuB,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxF,QAAQ,IAAI,UAAU,CAAC;IACvB,OAAO,IAAI,MAAM,CAAC;CACnB"}
|
package/build/util/metadata.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ContentAssetMetadataMap } from "../types/content-assets.js";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getKVStoreKeysFromMetadata(contentAssetMetadataMap: ContentAssetMetadataMap): Set<string>;
|
|
3
3
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/util/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,wBAAgB,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/util/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,wBAAgB,0BAA0B,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC,CAexG"}
|
package/build/util/metadata.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function getKVStoreKeysFromMetadata(contentAssetMetadataMap) {
|
|
2
2
|
const results = new Set();
|
|
3
3
|
for (const metadata of Object.values(contentAssetMetadataMap)) {
|
|
4
|
-
if (metadata.type === '
|
|
5
|
-
results.add(metadata.fileInfo.
|
|
4
|
+
if (metadata.type === 'kv-store') {
|
|
5
|
+
results.add(metadata.fileInfo.kvStoreKey);
|
|
6
6
|
for (const fileInfo of Object.values(metadata.compressedFileInfos)) {
|
|
7
|
-
results.add(fileInfo.
|
|
7
|
+
results.add(fileInfo.kvStoreKey);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/compute-js-static-publish",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.1",
|
|
5
5
|
"description": "Static Publisher for Compute@Edge JavaScript",
|
|
6
6
|
"main": "./build/index.js",
|
|
7
7
|
"types": "./build/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/fastly/compute-js-static-publish#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@fastly/js-compute": "^
|
|
34
|
+
"@fastly/js-compute": "^2.0.0",
|
|
35
35
|
"command-line-args": "^5.2.1",
|
|
36
36
|
"glob-to-regexp": "^0.4.1"
|
|
37
37
|
},
|