wardens 0.5.0-rc.0 → 0.5.1-rc.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Fixed
10
+
11
+ - Added support for parametrized resources in `ResourceHandle<T>`.
12
+
13
+ ## [0.5.0]
14
+
9
15
  ### Changed
10
16
 
11
17
  - Wardens is now published with ESM (`type=module`). It should be backwards compatible.
@@ -75,7 +81,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
75
81
  - `mount`/`unmount` hooks to provision resources
76
82
  - `allocate`/`deallocate` for creating hierarchies of resources
77
83
 
78
- [Unreleased]: https://github.com/PsychoLlama/wardens/compare/v0.4.1...HEAD
84
+ [Unreleased]: https://github.com/PsychoLlama/wardens/compare/v0.5.0...HEAD
85
+ [0.5.0]: https://github.com/PsychoLlama/wardens/compare/v0.4.1...v0.5.0
79
86
  [0.4.1]: https://github.com/PsychoLlama/wardens/compare/v0.4.0...v0.4.1
80
87
  [0.4.0]: https://github.com/PsychoLlama/wardens/compare/v0.3.0...v0.4.0
81
88
  [0.3.0]: https://github.com/PsychoLlama/wardens/compare/v0.2.0...v0.3.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wardens",
3
- "version": "0.5.0-rc.0",
3
+ "version": "0.5.1-rc.0",
4
4
  "description": "A framework for resource management",
5
5
  "type": "module",
6
6
  "main": "./dist/wardens.cjs",
@@ -1,4 +1,4 @@
1
- import { create, ResourceHandle } from '../';
1
+ import { create, ResourceContext, ResourceHandle } from '../';
2
2
 
3
3
  describe('Utility types', () => {
4
4
  describe('ResourceHandle', () => {
@@ -15,5 +15,18 @@ describe('Utility types', () => {
15
15
  hello: 'world',
16
16
  });
17
17
  });
18
+
19
+ it('infers the type when the value comes from a parameter', async () => {
20
+ async function Test(_ctx: ResourceContext, value: { count: number }) {
21
+ return {
22
+ value,
23
+ };
24
+ }
25
+
26
+ const test = await create(Test, { count: 2 });
27
+ expectTypeOf(test).toEqualTypeOf<ResourceHandle<typeof Test>>({
28
+ count: 2,
29
+ });
30
+ });
18
31
  });
19
32
  });
package/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import type ResourceContext from './resource-context';
2
3
 
3
4
  /**
@@ -25,6 +26,6 @@ export interface Resource<Value extends object> {
25
26
  }
26
27
 
27
28
  /** The `value` type returned when creating a resource. */
28
- export type ResourceHandle<Factory extends ResourceFactory<object>> = Awaited<
29
- ReturnType<Factory>
30
- >['value'];
29
+ export type ResourceHandle<
30
+ Factory extends ParametrizedResourceFactory<object, Array<any>>,
31
+ > = Awaited<ReturnType<Factory>>['value'];