@fastly/compute-js-context 0.5.0 → 0.5.2

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 (3) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/README.md +17 -7
  3. package/package.json +1 -1
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.5.2] - 2025-10-16
11
+
12
+ ### Fixed
13
+
14
+ - Updated README
15
+
16
+ ## [0.5.1] - 2025-10-14
17
+
18
+ ### Fixed
19
+
20
+ - Updated README
21
+
10
22
  ## [0.5.0] - 2025-10-14
11
23
 
12
24
  ### Changed
@@ -35,7 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
47
 
36
48
  - Initial public release
37
49
 
38
- [unreleased]: https://github.com/fastly/compute-js-context/compare/v0.5.0...HEAD
50
+ [unreleased]: https://github.com/fastly/compute-js-context/compare/v0.5.2...HEAD
51
+ [0.5.2]: https://github.com/fastly/compute-js-context/compare/v0.5.1...v0.5.2
52
+ [0.5.1]: https://github.com/fastly/compute-js-context/compare/v0.5.0...v0.5.1
39
53
  [0.5.0]: https://github.com/fastly/compute-js-context/compare/v0.4.2...v0.5.0
40
54
  [0.4.2]: https://github.com/fastly/compute-js-context/compare/v0.4.1...v0.4.2
41
55
  [0.4.1]: https://github.com/fastly/compute-js-context/compare/v0.2.0...v0.4.1
package/README.md CHANGED
@@ -80,7 +80,7 @@ Then, pass these definitions to `buildContextProxy()`.
80
80
 
81
81
  ```typescript
82
82
  /// <reference types="@fastly/js-compute" />
83
- import { createContext, buildContextProxy, type BindingsDefs } from '@fastly/compute-js-context';
83
+ import { buildContextProxy, type BindingsDefs } from '@fastly/compute-js-context';
84
84
 
85
85
  // Define your application's bindings
86
86
  const bindingsDefs = {
@@ -99,10 +99,8 @@ type Bindings = ContextProxy<typeof bindingsDefs>;
99
99
 
100
100
  addEventListener('fetch', (event) => event.respondWith(handler(event)));
101
101
  async function handler(event: FetchEvent): Promise<Response> {
102
- const ctx = createContext();
103
-
104
102
  // Create the typed environment
105
- const bindings: Bindings = buildContextProxy(ctx, bindingsDefs);
103
+ const bindings: Bindings = buildContextProxy(bindingsDefs);
106
104
 
107
105
  // Now use your custom bindings!
108
106
  const asset = await bindings.assets?.get('/index.html');
@@ -126,16 +124,29 @@ Creates the main immutable `Context`. Each sub-object is a `Proxy` that:
126
124
  - **Returns `undefined`** for names that don’t exist (except for `ENV`, which returns `''`)
127
125
  - **Is not enumerable** by design (don’t rely on `Object.keys`)
128
126
 
129
- ### `buildContextProxy<T>(context: Context, bindingsDefs: T): ContextProxy<T>`
127
+ ### `buildContextProxy<T>(bindingsDefs: T): ContextProxy<T>`
130
128
 
131
129
  Creates a custom, strongly-typed proxy object based on your definitions.
132
130
 
133
- - `context`: An instance of the main `Context` object
134
131
  - `bindingsDefs`: A `const` object defining your desired bindings
135
132
  - **Key**: The property name you want on your final `contextProxy` object
136
133
  - **Value**: A string in the format `'ResourceType'` or `'ResourceType:actual-name'`
137
134
  - **Returns**: A proxy object `contextProxy` with your custom bindings. Accessing a property on this object looks up the resource from the main `Context`
138
135
 
136
+ ### Type `ContentProxy<T>`
137
+
138
+ Defines a type that represents the content proxy, inferred from your bindings definitions.
139
+
140
+ ### (Advanced) `buildContextProxyOn<C, T>(target: C, bindingsDefs: T): C & ContextProxy<T>`
141
+
142
+ Extends the passed-in object with a custom, strongly-typed proxy object based on your definitions.
143
+
144
+ - `target`: An object to extend
145
+ - `bindingsDefs`: A `const` object defining your desired bindings
146
+ - **Key**: The property name you want on your final `contextProxy` object
147
+ - **Value**: A string in the format `'ResourceType'` or `'ResourceType:actual-name'`
148
+ - **Returns**: A proxy object `contextProxy` that extends `target` with your custom bindings. Accessing a property on this object looks up the resource from the main `Context` before falling back to `target`.
149
+
139
150
  ### Context Categories & Shapes
140
151
 
141
152
  > These are the raw shapes available on the main `Context` object.
@@ -154,7 +165,6 @@ Creates a custom, strongly-typed proxy object based on your definitions.
154
165
  - **Don’t mutate** the context or its sub-objects; it’s intentionally `Readonly`
155
166
  - **Expect `undefined`** for missing resources and code accordingly (`?.`/guard)
156
167
 
157
-
158
168
  ## Issues
159
169
 
160
170
  If you encounter any non-security-related bug or unexpected behavior, please [file an issue][bug] using the bug report template.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastly/compute-js-context",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Surfaces Fastly Compute environment as a context object",
5
5
  "license": "MIT",
6
6
  "repository": {