@fastly/hono-fastly-compute 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/build/fire.js +3 -0
- package/package.json +1 -1
- package/build/bindings.d.ts +0 -37
- package/build/bindings.js +0 -53
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.7] - 2026-01-07
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Publish using CI
|
|
15
|
+
|
|
16
|
+
## [0.3.6] - 2025-10-19
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Within `fire()`, run a dummy `match()` against the router, forcing it to build any caches during the pre-wizer step.
|
|
21
|
+
|
|
10
22
|
## [0.3.5] - 2025-10-19
|
|
11
23
|
|
|
12
24
|
### Fixed
|
|
@@ -54,7 +66,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
54
66
|
|
|
55
67
|
- Initial public release
|
|
56
68
|
|
|
57
|
-
[unreleased]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.
|
|
69
|
+
[unreleased]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.7...HEAD
|
|
70
|
+
[0.3.7]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.6...v0.3.7
|
|
71
|
+
[0.3.6]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.5...v0.3.6
|
|
58
72
|
[0.3.5]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.4...v0.3.5
|
|
59
73
|
[0.3.4]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.3...v0.3.4
|
|
60
74
|
[0.3.3]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.2...v0.3.3
|
package/build/fire.js
CHANGED
|
@@ -40,6 +40,9 @@ import { handle } from './handler.js';
|
|
|
40
40
|
*/
|
|
41
41
|
export function buildFire(bindingsDefs) {
|
|
42
42
|
const fireFn = ((app, options = { fetch: undefined, }) => {
|
|
43
|
+
// Run a dummy match() against the router.
|
|
44
|
+
// This forces the router (for example, RegExpRouter) to build any caches in the pre-wizer step.
|
|
45
|
+
app.router.match('', '');
|
|
43
46
|
addEventListener('fetch', handle(app, bindingsDefs, options));
|
|
44
47
|
});
|
|
45
48
|
fireFn._defs = bindingsDefs;
|
package/package.json
CHANGED
package/build/bindings.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Acl } from 'fastly:acl';
|
|
2
|
-
import { Backend } from 'fastly:backend';
|
|
3
|
-
import { ConfigStore } from 'fastly:config-store';
|
|
4
|
-
import { KVStore } from 'fastly:kv-store';
|
|
5
|
-
import { Logger } from 'fastly:logger';
|
|
6
|
-
import { SecretStore } from 'fastly:secret-store';
|
|
7
|
-
import { Context } from "@h7/fastly-compute-js-context";
|
|
8
|
-
type Def<T extends string> = T | `${T}:${string}`;
|
|
9
|
-
type Defs<T extends string> = T extends string ? Def<T> : never;
|
|
10
|
-
declare const BindingStringToContextKeyMapping: {
|
|
11
|
-
readonly Acl: "ACLS";
|
|
12
|
-
readonly Backend: "BACKENDS";
|
|
13
|
-
readonly ConfigStore: "CONFIG_STORES";
|
|
14
|
-
readonly env: "ENV";
|
|
15
|
-
readonly KVStore: "KV_STORES";
|
|
16
|
-
readonly Logger: "LOGGERS";
|
|
17
|
-
readonly SecretStore: "SECRET_STORES";
|
|
18
|
-
};
|
|
19
|
-
export type ResourceType = keyof typeof BindingStringToContextKeyMapping;
|
|
20
|
-
export type BindingsString = Defs<ResourceType>;
|
|
21
|
-
export type EnvBindingsDefs = Record<string, BindingsString>;
|
|
22
|
-
type BindingStringToResourceInstanceTypeMapping = {
|
|
23
|
-
Acl: Acl;
|
|
24
|
-
Backend: Backend;
|
|
25
|
-
ConfigStore: ConfigStore;
|
|
26
|
-
env: string;
|
|
27
|
-
KVStore: KVStore;
|
|
28
|
-
Logger: Logger;
|
|
29
|
-
SecretStore: SecretStore;
|
|
30
|
-
};
|
|
31
|
-
export type ResourceInstance<T> = T extends Def<infer K extends keyof BindingStringToResourceInstanceTypeMapping> ? BindingStringToResourceInstanceTypeMapping[K] : never;
|
|
32
|
-
export type BuildBindings<T extends EnvBindingsDefs> = {
|
|
33
|
-
[K in keyof T]: ResourceInstance<T[K]>;
|
|
34
|
-
};
|
|
35
|
-
export declare function buildEnvironment<T extends EnvBindingsDefs>(context: Context, envBindingsDefs: T): BuildBindings<T>;
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=bindings.d.ts.map
|
package/build/bindings.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
const BindingStringToContextKeyMapping = {
|
|
2
|
-
Acl: 'ACLS',
|
|
3
|
-
Backend: 'BACKENDS',
|
|
4
|
-
ConfigStore: 'CONFIG_STORES',
|
|
5
|
-
env: 'ENV',
|
|
6
|
-
KVStore: 'KV_STORES',
|
|
7
|
-
Logger: 'LOGGERS',
|
|
8
|
-
SecretStore: 'SECRET_STORES',
|
|
9
|
-
};
|
|
10
|
-
function isResourceType(resourceType) {
|
|
11
|
-
return resourceType in BindingStringToContextKeyMapping;
|
|
12
|
-
}
|
|
13
|
-
function getResourceType(typeName) {
|
|
14
|
-
const [resourceType,] = typeName.split(':');
|
|
15
|
-
if (isResourceType(resourceType)) {
|
|
16
|
-
return resourceType;
|
|
17
|
-
}
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
function getResourceName(key, typeName) {
|
|
21
|
-
const [, seg,] = typeName.split(':');
|
|
22
|
-
return seg ?? key;
|
|
23
|
-
}
|
|
24
|
-
export function buildEnvironment(context, envBindingsDefs) {
|
|
25
|
-
const target = {};
|
|
26
|
-
const getEntry = (key) => {
|
|
27
|
-
if (typeof key !== "string") {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
console.log('key', key);
|
|
31
|
-
const typeName = envBindingsDefs[key];
|
|
32
|
-
const resourceType = getResourceType(typeName);
|
|
33
|
-
if (resourceType == null) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
const resourceName = getResourceName(key, typeName);
|
|
37
|
-
const contextKey = BindingStringToContextKeyMapping[resourceType];
|
|
38
|
-
const contextEntry = context[contextKey];
|
|
39
|
-
if (contextEntry == null) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
return contextEntry[resourceName];
|
|
43
|
-
};
|
|
44
|
-
const handler = {
|
|
45
|
-
get(_, key) {
|
|
46
|
-
return getEntry(key);
|
|
47
|
-
},
|
|
48
|
-
has(_, key) {
|
|
49
|
-
return getEntry(key) !== undefined;
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
return new Proxy(target, handler);
|
|
53
|
-
}
|