fortepiano 1.0.2 → 1.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,249 @@
1
+ # Changelog
2
+
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#96](https://github.com/facile-it/fortepiano/pull/96) [`854860e`](https://github.com/facile-it/fortepiano/commit/854860ea7e6f27b137a13f4dfb4e077f198106d6) Thanks [@pierroberto](https://github.com/pierroberto)! - Upgrade the development toolchain.
8
+
9
+ - typescript 4.7.4 → 6.0.3
10
+ - eslint 8.18.0 → 9.39.5
11
+ - eslint-config-facile 0.5.0 → 1.2.0
12
+ - jest 26.6.3 → 30.5.2
13
+ - ts-jest 26.5.6 → 29.4.14
14
+ - @types/jest 26.0.24 → 30.0.0
15
+ - prettier 2.7.1 → 3.9.10
16
+ - @types/node 22.8.7 → 26.6.5
17
+ - fp-ts 2.12.1 → 2.16.11 (devDependency; peer stays ^2.5.0)
18
+ - io-ts 2.2.16 → 2.2.22 (devDependency; peer stays ^2.2.0)
19
+
20
+ Remove @rushstack/eslint-patch and move ESLint to the flat config.
21
+
22
+ ## 1.0.3
23
+
24
+ ### Patch Changes
25
+
26
+ - [#107](https://github.com/facile-it/fortepiano/pull/107) [`8268baf`](https://github.com/facile-it/fortepiano/commit/8268bafa66db140d4ee91917ef86ba712ce338e5) Thanks [@pierroberto](https://github.com/pierroberto)! - Add Changesets to automate versioning, changelog generation, and npm releases.
27
+
28
+ ## [1.0.2](https://github.com/facile-it/fortepiano/compare/v1.0.1...v1.0.2) - 2026-08-10
29
+
30
+ ### Changed
31
+
32
+ - Upgrade CI workflows to supported Node.js versions.
33
+ - Upgrade Yarn from 3.2.3 to 4.18.1.
34
+
35
+ ## [1.0.1](https://github.com/facile-it/fortepiano/compare/v1.0.0...v1.0.1) - 2026-08-10
36
+
37
+ ### Fixed
38
+
39
+ - Fix `prerelease` and `release` script.
40
+
41
+ ## [1.0.0](https://github.com/facile-it/fortepiano/compare/v0.1.9...v1.0.0) - 2025-27-02
42
+
43
+ ### Removed
44
+
45
+ - Remove `Http` module.
46
+ - Remove `Cache` module.
47
+ - Remove `Memcached` module.
48
+ - Remove `Buffer` module.
49
+ - Remove `Stream` module.
50
+ - Remove `Memory` module.
51
+ - Remove `Redis` module.
52
+ - Remove `Storage` module.
53
+ - Remove `Axios` module.
54
+ - Remove `Fetch` module.
55
+ - Remove `Got` module.
56
+ - Remove `Flydrive` module.
57
+ - Remove `Fs` module.
58
+ - Remove `Random` module.
59
+ - Remove `Log` module.
60
+ - Remove `Void` module.
61
+ - Remove `GeneratorL` module.
62
+ - Remove `number` module.
63
+ - Remove `Console` module.
64
+ - Remove `Crypto` module.
65
+ - Remove `Binary` module.
66
+ - Remove `Date` module.
67
+ - Remove `AsyncYield` module.
68
+ - Remove `Magma` module.
69
+ - Remove `Matrix` module.
70
+ - Remove `Option` module.
71
+ - Remove `Reader` module.
72
+ - Remove `ReaderEither` module.
73
+ - Remove `ReaderTask` module.
74
+ - Remove `ReaderTaskEither` module.
75
+ - Remove `ReadonlyTuple` module.
76
+ - Remove `TaskEither` module.
77
+ - Remove `Validation` module.
78
+ - Remove `Has` module.
79
+ - Remove `Aggregate` module.
80
+ - Remove `Eq` module.
81
+ - Remove `string` module.
82
+ - Remove `Error` module.
83
+ - Remove `ReadonlyRecord` module.
84
+ - Remove `ReadonlyArray` module.
85
+ - Remove `Yield` module.
86
+ - Remove unused functions `ReadonlyArray`, `Type`, `function` and `struct` modules.
87
+
88
+ ## [0.1.9](https://github.com/facile-it/fortepiano/compare/v0.1.8...v0.1.9) - 2024-05-14
89
+
90
+ ### Security
91
+
92
+ - Fix CVE-2022-25883.
93
+
94
+ ## [0.1.8](https://github.com/facile-it/fortepiano/compare/v0.1.7...v0.1.8) - 2023-07-10
95
+
96
+ ### Added
97
+
98
+ - Complete the list of `Http` errors.
99
+
100
+ ### Security
101
+
102
+ - Fix CVE-2022-46175.
103
+ - Fix CVE-2022-25881.
104
+ - Fix CVE-2023-26136.
105
+
106
+ ## [0.1.7](https://github.com/facile-it/fortepiano/compare/v0.1.6...v0.1.7) - 2023-01-02
107
+
108
+ ### Added
109
+
110
+ - Add `infix` to `string` module.
111
+
112
+ ## [0.1.6](https://github.com/facile-it/fortepiano/compare/v0.1.5...v0.1.6) - 2022-09-30
113
+
114
+ ### Added
115
+
116
+ - Add `collectWithIndex` function to `ReadonlyRecord` module.
117
+
118
+ ## [0.1.5](https://github.com/facile-it/fortepiano/compare/v0.1.4...v0.1.5) - 2022-09-22
119
+
120
+ ### Added
121
+
122
+ - Add `prefix` to `string` module.
123
+ - Add `suffix` to `string` module.
124
+
125
+ ### Changed
126
+
127
+ - Changed overloads of `$mock.union` function.
128
+
129
+ ### Fixed
130
+
131
+ - Update `yarn.lock` in order to fix "typescript (18.x)" and "jest (18.x)" jobs in CI.
132
+
133
+ ## [0.1.4](https://github.com/facile-it/fortepiano/compare/v0.1.3...v0.1.4) - 2022-06-24
134
+
135
+ ### Security
136
+
137
+ - Fix CVE-2022-33987.
138
+
139
+ ## [0.1.3](https://github.com/facile-it/fortepiano/compare/v0.1.2...v0.1.3) - 2022-05-31
140
+
141
+ ### Added
142
+
143
+ - Add `AggregateError` inspired from TC39.
144
+ - Add `decode` method to `Type` module to help wrapping `io-ts` `Errors` into an `Error` subclass.
145
+ - Add unit tests for the `set` function of the `Redis` module.
146
+ - Add `Has` module and enhance `ReaderTaskEither` for smart dependencies management (inspired by [Effect-TS](https://www.matechs.com/open-source)):
147
+
148
+ ```typescript
149
+ // Foo.ts
150
+ import { TaskEither } from 'fp-ts/TaskEither'
151
+ import { $has, $readerTaskEither } from 'fortepiano'
152
+
153
+ export interface Foo {
154
+ bar(a: number): TaskEither<Error, string>
155
+ }
156
+
157
+ export const TagFoo = $has.tag<Foo>()
158
+
159
+ export const $foo = {
160
+ bar: $readerTaskEither.derivesTaskEither(TagFoo, 'bar'),
161
+ }
162
+ ```
163
+
164
+ ```typescript
165
+ // Bar.ts
166
+ import { IOEither } from 'fp-ts/IOEither'
167
+ import { $has, $readerTaskEither } from 'fortepiano'
168
+
169
+ export interface Bar {
170
+ (a: string): IOEither<Error, boolean>
171
+ }
172
+
173
+ export const TagBar = $has.tag<Bar>()
174
+
175
+ export const bar = $readerTaskEither.deriveIOEither(TagBar)
176
+ ```
177
+
178
+ ```typescript
179
+ // index.ts
180
+ import { $has } from 'fortepiano'
181
+ import { ioEither, readerTaskEither, taskEither } from 'fp-ts'
182
+ import { pipe } from 'fp-ts/function'
183
+ import { TagBar, bar } from './Bar'
184
+ import { $foo, TagFoo } from './Foo'
185
+
186
+ // const a: ReaderTaskEither<Has<Foo> & Has<Bar>, Error, boolean>
187
+ const a = pipe($foo.bar(42), readerTaskEither.chainW(bar))
188
+
189
+ // const b: TaskEither<Error, boolean>
190
+ const b = a(
191
+ // Let's mock our dependencies.
192
+ pipe(
193
+ $has.singleton(TagFoo, { bar: () => taskEither.of('foobar') }),
194
+ $has.upsertAt(TagBar, () => ioEither.of(true)),
195
+ ),
196
+ )
197
+ ```
198
+
199
+ ### Changed
200
+
201
+ - Replace `struct` type with `Struct`.
202
+ - Rename `GeneratorL` module to `Yield`.
203
+ - Use `cause` property to record wrapped errors (inspired by TC39).
204
+
205
+ ### Deprecated
206
+
207
+ - Deprecate `struct` (use `Struct` instead).
208
+ - Deprecate `GeneratorL` module (use `Yield` instead).
209
+
210
+ ### Fixed
211
+
212
+ - Decode from Json and then from the given codec in the `get` function of the `Redis` module.
213
+
214
+ ## [0.1.2](https://github.com/facile-it/fortepiano/compare/v0.1.1...v0.1.2) - 2022-04-29
215
+
216
+ ### Added
217
+
218
+ - Add `LICENSE.md`.
219
+ - Add `CONTRIBUTING.md`.
220
+ - Add `CHANGELOG.md`.
221
+
222
+ ### Changed
223
+
224
+ - Relicense as MIT.
225
+ - Update `README.md`.
226
+
227
+ ### Deprecated
228
+
229
+ - Deprecate `$got` (use `$axios` instead).
230
+
231
+ ## [0.1.1](https://github.com/facile-it/fortepiano/compare/v0.1.0...v0.1.1) - 2022-04-26
232
+
233
+ ### Added
234
+
235
+ - Support [tree shaking](https://webpack.js.org/guides/tree-shaking/) via top-level imports:
236
+ ```typescript
237
+ import { curry } from 'fortepiano/function'
238
+ // ...instead of `import { curry } from 'fortepiano/lib/function'`
239
+ ```
240
+
241
+ ### Deprecated
242
+
243
+ - Discourage imports from `fortepiano/lib/*` as they break tree shaking.
244
+
245
+ ## [0.1.0](https://github.com/facile-it/fortepiano/releases/tag/v0.1.0) - 2022-04-20
246
+
247
+ ### Added
248
+
249
+ - First public release of `fortepiano`.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <p align="center">
2
- <img src="./logo.png" width=150px" height="auto"/>
2
+ <img src="./logo.png" width="150px" height="auto"/>
3
3
  </p>
4
4
 
5
5
  # fortepiano [ˌfɔrteˈpjaːno]
6
6
 
7
- _Playing actual music over `fp-ts` notes_ 🎶
7
+ _Playing actual music over functional notes_ 🎶
8
8
 
9
9
  [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/facile-it/fortepiano/main)](https://github.com/facile-it/fortepiano/actions)
10
10
  [![Codecov](https://img.shields.io/codecov/c/gh/facile-it/fortepiano)](https://app.codecov.io/gh/facile-it/fortepiano)
@@ -25,7 +25,7 @@ To install the stable version:
25
25
  npm install fortepiano
26
26
  ```
27
27
 
28
- or using yarn:
28
+ or using Yarn:
29
29
 
30
30
  ```bash
31
31
  yarn add fortepiano
@@ -35,10 +35,26 @@ yarn add fortepiano
35
35
 
36
36
  Fortepiano uses a functional API to create and configure mocks, encouraging pure function usage and immutable mock objects.
37
37
 
38
- Here's an example:
38
+ Import Fortepiano as a namespace:
39
39
 
40
40
  ```typescript
41
- import { $mock } from 'fortepiano'
41
+ import * as $mock from 'fortepiano'
42
+ ```
43
+
44
+ A mock is a function that produces an `IO`, so call it twice to generate a value:
45
+
46
+ ```typescript
47
+ const value = $mock.string()()
48
+
49
+ console.log(value) // A randomly generated string
50
+ ```
51
+
52
+ #### Creating structured mocks
53
+
54
+ Use `$mock.struct` to combine mocks:
55
+
56
+ ```typescript
57
+ import * as $mock from 'fortepiano'
42
58
 
43
59
  interface User {
44
60
  firstName: string
@@ -51,7 +67,87 @@ export const UserMock = (): $mock.Mock<User> =>
51
67
  lastName: $mock.string,
52
68
  })
53
69
 
54
- console.log(UserMock()()()) // Output: { firstName: 'randomString', lastName: 'randomString' }
70
+ const user = UserMock()()()
71
+
72
+ console.log(user)
73
+ // { firstName: "<random string>", lastName: "<random string>" }
74
+ ```
75
+
76
+ `UserMock()` creates the mock, the second call creates its `IO`, and the third call executes that `IO`.
77
+
78
+ You can also define the mock directly:
79
+
80
+ ```typescript
81
+ const userMock: $mock.Mock<User> = $mock.struct({
82
+ firstName: $mock.string,
83
+ lastName: $mock.string,
84
+ })
85
+
86
+ const user = userMock()()
87
+ ```
88
+
89
+ #### Using fixed values
90
+
91
+ Use `$mock.of` when a mock should always produce a specific value:
92
+
93
+ ```typescript
94
+ const testString = $mock.of('test')
95
+
96
+ console.log(testString()()) // "test"
97
+ ```
98
+
99
+ Fixed and generated values can be combined in a structured mock:
100
+
101
+ ```typescript
102
+ const userMock: $mock.Mock<User> = $mock.struct({
103
+ firstName: $mock.of('test'),
104
+ lastName: $mock.string,
105
+ })
106
+
107
+ console.log(userMock()())
108
+ // { firstName: "test", lastName: "<random string>" }
109
+ ```
110
+
111
+ #### Overriding generated values
112
+
113
+ A value can be supplied when invoking a mock:
114
+
115
+ ```typescript
116
+ console.log($mock.string('test')()) // "test"
117
+ ```
118
+
119
+ Structured mocks accept partial overrides:
120
+
121
+ ```typescript
122
+ const userMock: $mock.Mock<User> = $mock.struct({
123
+ firstName: $mock.string,
124
+ lastName: $mock.string,
125
+ })
126
+
127
+ console.log(userMock({ firstName: 'John' })())
128
+ // { firstName: "John", lastName: "<random string>" }
129
+ ```
130
+
131
+ This lets you reuse a mock while customizing only the properties relevant to a test.
132
+
133
+ #### Importing individual exports
134
+
135
+ You can import individual functions and types instead of using a namespace:
136
+
137
+ ```typescript
138
+ import { of, string, struct, type Mock } from 'fortepiano'
139
+
140
+ interface User {
141
+ firstName: string
142
+ lastName: string
143
+ }
144
+
145
+ const userMock: Mock<User> = struct({
146
+ firstName: of('test'),
147
+ lastName: string,
148
+ })
149
+
150
+ console.log(userMock()())
55
151
  ```
56
152
 
57
153
  ## Contributing
@@ -1,23 +1,23 @@
1
- import * as Appli from 'fp-ts/Applicative';
1
+ import type * as Appli from 'fp-ts/Applicative';
2
2
  import * as _Apply from 'fp-ts/Apply';
3
3
  import * as C from 'fp-ts/Chain';
4
4
  import * as FIO from 'fp-ts/FromIO';
5
5
  import * as F from 'fp-ts/Functor';
6
6
  import * as IO from 'fp-ts/IO';
7
- import * as M from 'fp-ts/Monad';
8
- import * as MIO from 'fp-ts/MonadIO';
9
- import * as P from 'fp-ts/Pointed';
7
+ import type * as M from 'fp-ts/Monad';
8
+ import type * as MIO from 'fp-ts/MonadIO';
9
+ import type * as P from 'fp-ts/Pointed';
10
10
  import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray';
11
11
  import * as RR from 'fp-ts/ReadonlyRecord';
12
- import { PartialDeep } from './utils/struct';
12
+ import type { PartialDeep } from './utils/struct';
13
13
  export declare const URI = "Mock";
14
- export declare type URI = typeof URI;
14
+ export type URI = typeof URI;
15
15
  declare module 'fp-ts/HKT' {
16
16
  interface URItoKind<A> {
17
17
  readonly [URI]: Mock<A>;
18
18
  }
19
19
  }
20
- declare type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R;
20
+ type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R;
21
21
  export interface Mock<A> {
22
22
  (...as: ReadonlyArray<PartialDeep<A>>): IO.IO<A>;
23
23
  }
@@ -36,12 +36,12 @@ export declare const apS: <N extends string, A, B>(name: Exclude<N, keyof A>, fb
36
36
  export declare const Applicative: Appli.Applicative1<URI>;
37
37
  export declare const Chain: C.Chain1<URI>;
38
38
  export declare const chain: <A, B>(a: (a: A) => Mock<B>) => (b: Mock<A>) => Mock<B>;
39
- export declare const chainFirst: <A, B>(f: (a: A) => Mock<B>) => (first: Mock<A>) => Mock<A>;
39
+ export declare const chainFirst: <A, _>(f: (a: A) => Mock<_>) => (first: Mock<A>) => Mock<A>;
40
40
  export declare const bind: <N extends string, A, B>(name: Exclude<N, keyof A>, f: (a: A) => Mock<B>) => (ma: Mock<A>) => Mock<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>;
41
41
  export declare const Monad: M.Monad1<URI>;
42
42
  export declare const FromIO: FIO.FromIO1<URI>;
43
- export declare const fromIO: import("fp-ts/lib/NaturalTransformation").NaturalTransformation11<"IO", "Mock">;
44
- export declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => IO.IO<B>) => (...a: A) => Mock<B>;
43
+ export declare const fromIO: <A>(fa: IO.IO<A>) => Mock<A>;
44
+ export declare const fromIOK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO.IO<B>) => (...a: A) => Mock<B>;
45
45
  export declare const chainIOK: <A, B>(f: (a: A) => IO.IO<B>) => (first: Mock<A>) => Mock<B>;
46
46
  export declare const chainFirstIOK: <A, B>(f: (a: A) => IO.IO<B>) => (first: Mock<A>) => Mock<A>;
47
47
  export declare const MonadIO: MIO.MonadIO1<URI>;
@@ -53,7 +53,7 @@ export declare const float: (min?: number, max?: number) => Mock<number>;
53
53
  export declare const integer: (min?: number, max?: number) => Mock<number>;
54
54
  export declare const number: (min?: number, max?: number) => Mock<number>;
55
55
  export declare const string: Mock<string>;
56
- export declare const literal: <A extends string | number | boolean>(a: A) => Mock<A>;
56
+ export declare const literal: <A extends boolean | number | string>(a: A) => Mock<A>;
57
57
  export declare const unknown: (depth?: number) => Mock<unknown>;
58
58
  export declare const nullable: <A>(M: Mock<A>) => Mock<A | undefined>;
59
59
  export declare const tuple: <T extends Mock<any>[]>(...t: T & {
@@ -75,7 +75,7 @@ export declare function union<A, B, C, D, E>(a: Mock<A>, b: Mock<B>, c: Mock<C>,
75
75
  export declare function union<A, B, C, D>(a: Mock<A>, b: Mock<B>, c: Mock<C>, d: Mock<D>): Mock<A | B | C | D>;
76
76
  export declare function union<A, B, C>(a: Mock<A>, b: Mock<B>, c: Mock<C>): Mock<A | B | C>;
77
77
  export declare function union<A, B>(a: Mock<A>, b: Mock<B>): Mock<A | B>;
78
- export declare const readonlyArray: <A>(M: Mock<A>, min?: number, max?: number) => Mock<readonly A[]>;
78
+ export declare const readonlyArray: <A>(M: Mock<A>, min?: number, max?: number) => Mock<ReadonlyArray<A>>;
79
79
  export declare const readonlyNonEmptyArray: <A>(M: Mock<A>, min?: number, max?: number) => Mock<RNEA.ReadonlyNonEmptyArray<A>>;
80
- export declare const readonlyRecord: <K extends string, T>(KM: Mock<K>, TM: Mock<T>, min?: number, max?: number) => Mock<Readonly<Record<K, T>>>;
80
+ export declare const readonlyRecord: <K extends string, T>(KM: Mock<K>, TM: Mock<T>, min?: number, max?: number) => Mock<RR.ReadonlyRecord<K, T>>;
81
81
  export { _void as void, _undefined as undefined, _null as null };
package/dist/cjs/index.js CHANGED
@@ -15,15 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.null = exports.undefined = exports.void = exports.readonlyRecord = exports.readonlyNonEmptyArray = exports.readonlyArray = exports.union = exports.partial = exports.struct = exports.tuple = exports.nullable = exports.unknown = exports.literal = exports.string = exports.number = exports.integer = exports.float = exports.boolean = exports.MonadIO = exports.chainFirstIOK = exports.chainIOK = exports.fromIOK = exports.fromIO = exports.FromIO = exports.Monad = exports.bind = exports.chainFirst = exports.chain = exports.Chain = exports.Applicative = exports.apS = exports.apSecond = exports.apFirst = exports.ap = exports.Apply = exports.Do = exports.of = exports.Pointed = exports.bindTo = exports.flap = exports.map = exports.Functor = exports.URI = void 0;
36
+ exports.null = exports.undefined = exports.void = exports.readonlyRecord = exports.readonlyNonEmptyArray = exports.readonlyArray = exports.partial = exports.struct = exports.tuple = exports.nullable = exports.unknown = exports.literal = exports.string = exports.number = exports.integer = exports.float = exports.boolean = exports.MonadIO = exports.chainFirstIOK = exports.chainIOK = exports.fromIOK = exports.fromIO = exports.FromIO = exports.Monad = exports.bind = exports.chainFirst = exports.chain = exports.Chain = exports.Applicative = exports.apS = exports.apSecond = exports.apFirst = exports.ap = exports.Apply = exports.Do = exports.of = exports.Pointed = exports.bindTo = exports.flap = exports.map = exports.Functor = exports.URI = void 0;
37
+ exports.union = union;
27
38
  const _Apply = __importStar(require("fp-ts/Apply"));
28
39
  const C = __importStar(require("fp-ts/Chain"));
29
40
  const FIO = __importStar(require("fp-ts/FromIO"));
@@ -48,7 +59,7 @@ exports.Functor = {
48
59
  URI: exports.URI,
49
60
  map: (fa, f) => (0, function_1.pipe)(fa(), IO.map(f), exports.FromIO.fromIO),
50
61
  };
51
- exports.map = (0, function_2.curry)((0, function_1.flip)(exports.Functor.map));
62
+ exports.map = (0, function_2.curry)((0, function_2.flip)(exports.Functor.map));
52
63
  exports.flap = F.flap(exports.Functor);
53
64
  exports.bindTo = F.bindTo(exports.Functor);
54
65
  exports.Pointed = {
@@ -60,13 +71,13 @@ exports.Pointed = {
60
71
  exports.of = exports.Pointed.of;
61
72
  exports.Do = exports.Pointed.of({});
62
73
  exports.Apply = Object.assign(Object.assign({}, exports.Functor), { ap: (fab, fa) => exports.Chain.chain(fab, (0, function_2.curry)(exports.Functor.map)(fa)) });
63
- exports.ap = (0, function_2.curry)((0, function_1.flip)(exports.Apply.ap));
74
+ exports.ap = (0, function_2.curry)((0, function_2.flip)(exports.Apply.ap));
64
75
  exports.apFirst = _Apply.apFirst(exports.Apply);
65
76
  exports.apSecond = _Apply.apSecond(exports.Apply);
66
77
  exports.apS = _Apply.apS(exports.Apply);
67
78
  exports.Applicative = Object.assign(Object.assign({}, exports.Pointed), exports.Apply);
68
79
  exports.Chain = Object.assign(Object.assign({}, exports.Apply), { chain: (fa, f) => exports.Functor.map(exports.Functor.map(fa, f), (fb) => fb()()) });
69
- exports.chain = (0, function_2.curry)((0, function_1.flip)(exports.Chain.chain));
80
+ exports.chain = (0, function_2.curry)((0, function_2.flip)(exports.Chain.chain));
70
81
  exports.chainFirst = C.chainFirst(exports.Chain);
71
82
  exports.bind = C.bind(exports.Chain);
72
83
  exports.Monad = Object.assign(Object.assign({}, exports.Applicative), exports.Chain);
@@ -108,7 +119,6 @@ exports.partial = partial;
108
119
  function union(...Ms) {
109
120
  return (0, function_1.pipe)(Ms, R.randomElem, IO.chain(function_2.run), exports.fromIO);
110
121
  }
111
- exports.union = union;
112
122
  const readonlyArray = (M, min = 0, max = 10) => {
113
123
  return (as) => () => {
114
124
  if (as !== undefined) {
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.struct = void 0;
27
37
  const function_1 = require("fp-ts/function");
@@ -1,4 +1,5 @@
1
- import { Lazy } from 'fp-ts/function';
1
+ import type { Lazy } from 'fp-ts/function';
2
+ export declare function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C;
2
3
  export declare const run: <A>(f: Lazy<A>) => A;
3
4
  export declare function curry<A, B, C>(f: (a: A, b: B) => C): (a: A) => (b: B) => C;
4
5
  export declare function curry<A, B, C, D>(f: (a: A, b: B, c: C) => D): (a: A) => (b: B) => (c: C) => D;
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recurse = exports.curry = exports.run = void 0;
3
+ exports.recurse = exports.run = void 0;
4
+ exports.flip = flip;
5
+ exports.curry = curry;
6
+ function flip(f) {
7
+ return (b, a) => {
8
+ return f(a, b);
9
+ };
10
+ }
4
11
  const run = (f) => f();
5
12
  exports.run = run;
6
13
  function curry(f) {
@@ -10,7 +17,6 @@ function curry(f) {
10
17
  : (...rest) => curried(...head.concat(rest));
11
18
  };
12
19
  }
13
- exports.curry = curry;
14
20
  /**
15
21
  * @example
16
22
  * const pi = (max: number) => (): ((n?: number) => number) =>
@@ -1,16 +1,16 @@
1
- import { Predicate } from 'fp-ts/Predicate';
2
- export declare type Struct = object;
3
- export declare type PartialDeep<A> = A extends {
1
+ import type { Predicate } from 'fp-ts/Predicate';
2
+ export type Struct = object;
3
+ export type PartialDeep<A> = A extends {
4
4
  readonly [x: string]: unknown;
5
5
  } ? Partial<{
6
6
  readonly [K in keyof A]: PartialDeep<A[K]>;
7
7
  }> : A;
8
- declare type IntersectionDeep<A, B> = A extends {
8
+ type IntersectionDeep<A, B> = A extends {
9
9
  readonly [x: string]: unknown;
10
10
  } ? A & {
11
11
  readonly [K in keyof B]: IntersectionDeep<K extends keyof A ? A[K] : unknown, B[K]>;
12
12
  } : B;
13
- export declare const toReadonlyArray: <A extends object>(a: A) => readonly (readonly [keyof A, A[keyof A]])[];
14
- export declare const filterDeep: <A extends object>(f: Predicate<unknown>) => (a: A) => PartialDeep<A>;
15
- export declare const patch: <A extends object, B extends PartialDeep<A> & object>(b: B) => (a: A) => IntersectionDeep<A, B>;
13
+ export declare const toReadonlyArray: <A extends Struct>(a: A) => ReadonlyArray<Readonly<[keyof A, A[keyof A]]>>;
14
+ export declare const filterDeep: <A extends Struct>(f: Predicate<unknown>) => (a: A) => PartialDeep<A>;
15
+ export declare const patch: <A extends Struct, B extends PartialDeep<A> & Struct>(b: B) => (a: A) => IntersectionDeep<A, B>;
16
16
  export {};
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.patch = exports.filterDeep = exports.toReadonlyArray = void 0;
27
37
  const function_1 = require("fp-ts/function");
@@ -1,23 +1,23 @@
1
- import * as Appli from 'fp-ts/Applicative';
1
+ import type * as Appli from 'fp-ts/Applicative';
2
2
  import * as _Apply from 'fp-ts/Apply';
3
3
  import * as C from 'fp-ts/Chain';
4
4
  import * as FIO from 'fp-ts/FromIO';
5
5
  import * as F from 'fp-ts/Functor';
6
6
  import * as IO from 'fp-ts/IO';
7
- import * as M from 'fp-ts/Monad';
8
- import * as MIO from 'fp-ts/MonadIO';
9
- import * as P from 'fp-ts/Pointed';
7
+ import type * as M from 'fp-ts/Monad';
8
+ import type * as MIO from 'fp-ts/MonadIO';
9
+ import type * as P from 'fp-ts/Pointed';
10
10
  import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray';
11
11
  import * as RR from 'fp-ts/ReadonlyRecord';
12
- import { PartialDeep } from './utils/struct';
12
+ import type { PartialDeep } from './utils/struct';
13
13
  export declare const URI = "Mock";
14
- export declare type URI = typeof URI;
14
+ export type URI = typeof URI;
15
15
  declare module 'fp-ts/HKT' {
16
16
  interface URItoKind<A> {
17
17
  readonly [URI]: Mock<A>;
18
18
  }
19
19
  }
20
- declare type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R;
20
+ type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R;
21
21
  export interface Mock<A> {
22
22
  (...as: ReadonlyArray<PartialDeep<A>>): IO.IO<A>;
23
23
  }
@@ -36,12 +36,12 @@ export declare const apS: <N extends string, A, B>(name: Exclude<N, keyof A>, fb
36
36
  export declare const Applicative: Appli.Applicative1<URI>;
37
37
  export declare const Chain: C.Chain1<URI>;
38
38
  export declare const chain: <A, B>(a: (a: A) => Mock<B>) => (b: Mock<A>) => Mock<B>;
39
- export declare const chainFirst: <A, B>(f: (a: A) => Mock<B>) => (first: Mock<A>) => Mock<A>;
39
+ export declare const chainFirst: <A, _>(f: (a: A) => Mock<_>) => (first: Mock<A>) => Mock<A>;
40
40
  export declare const bind: <N extends string, A, B>(name: Exclude<N, keyof A>, f: (a: A) => Mock<B>) => (ma: Mock<A>) => Mock<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>;
41
41
  export declare const Monad: M.Monad1<URI>;
42
42
  export declare const FromIO: FIO.FromIO1<URI>;
43
- export declare const fromIO: import("fp-ts/lib/NaturalTransformation").NaturalTransformation11<"IO", "Mock">;
44
- export declare const fromIOK: <A extends readonly unknown[], B>(f: (...a: A) => IO.IO<B>) => (...a: A) => Mock<B>;
43
+ export declare const fromIO: <A>(fa: IO.IO<A>) => Mock<A>;
44
+ export declare const fromIOK: <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => IO.IO<B>) => (...a: A) => Mock<B>;
45
45
  export declare const chainIOK: <A, B>(f: (a: A) => IO.IO<B>) => (first: Mock<A>) => Mock<B>;
46
46
  export declare const chainFirstIOK: <A, B>(f: (a: A) => IO.IO<B>) => (first: Mock<A>) => Mock<A>;
47
47
  export declare const MonadIO: MIO.MonadIO1<URI>;
@@ -53,7 +53,7 @@ export declare const float: (min?: number, max?: number) => Mock<number>;
53
53
  export declare const integer: (min?: number, max?: number) => Mock<number>;
54
54
  export declare const number: (min?: number, max?: number) => Mock<number>;
55
55
  export declare const string: Mock<string>;
56
- export declare const literal: <A extends string | number | boolean>(a: A) => Mock<A>;
56
+ export declare const literal: <A extends boolean | number | string>(a: A) => Mock<A>;
57
57
  export declare const unknown: (depth?: number) => Mock<unknown>;
58
58
  export declare const nullable: <A>(M: Mock<A>) => Mock<A | undefined>;
59
59
  export declare const tuple: <T extends Mock<any>[]>(...t: T & {
@@ -75,7 +75,7 @@ export declare function union<A, B, C, D, E>(a: Mock<A>, b: Mock<B>, c: Mock<C>,
75
75
  export declare function union<A, B, C, D>(a: Mock<A>, b: Mock<B>, c: Mock<C>, d: Mock<D>): Mock<A | B | C | D>;
76
76
  export declare function union<A, B, C>(a: Mock<A>, b: Mock<B>, c: Mock<C>): Mock<A | B | C>;
77
77
  export declare function union<A, B>(a: Mock<A>, b: Mock<B>): Mock<A | B>;
78
- export declare const readonlyArray: <A>(M: Mock<A>, min?: number, max?: number) => Mock<readonly A[]>;
78
+ export declare const readonlyArray: <A>(M: Mock<A>, min?: number, max?: number) => Mock<ReadonlyArray<A>>;
79
79
  export declare const readonlyNonEmptyArray: <A>(M: Mock<A>, min?: number, max?: number) => Mock<RNEA.ReadonlyNonEmptyArray<A>>;
80
- export declare const readonlyRecord: <K extends string, T>(KM: Mock<K>, TM: Mock<T>, min?: number, max?: number) => Mock<Readonly<Record<K, T>>>;
80
+ export declare const readonlyRecord: <K extends string, T>(KM: Mock<K>, TM: Mock<T>, min?: number, max?: number) => Mock<RR.ReadonlyRecord<K, T>>;
81
81
  export { _void as void, _undefined as undefined, _null as null };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _Apply from 'fp-ts/Apply';
2
2
  import * as C from 'fp-ts/Chain';
3
3
  import * as FIO from 'fp-ts/FromIO';
4
- import { constNull, constUndefined, constVoid, flip, pipe, } from 'fp-ts/function';
4
+ import { constNull, constUndefined, constVoid, pipe } from 'fp-ts/function';
5
5
  import * as F from 'fp-ts/Functor';
6
6
  import * as IO from 'fp-ts/IO';
7
7
  import * as N from 'fp-ts/number';
@@ -14,7 +14,7 @@ import * as RNEA from 'fp-ts/ReadonlyNonEmptyArray';
14
14
  import * as RR from 'fp-ts/ReadonlyRecord';
15
15
  import * as Se from 'fp-ts/Semigroup';
16
16
  import * as t from 'io-ts';
17
- import { curry, recurse, run } from './utils/function';
17
+ import { curry, flip, recurse, run } from './utils/function';
18
18
  import * as $St from './utils/struct';
19
19
  import * as $t from './utils/Type';
20
20
  export const URI = 'Mock';
@@ -1,4 +1,5 @@
1
- import { Lazy } from 'fp-ts/function';
1
+ import type { Lazy } from 'fp-ts/function';
2
+ export declare function flip<A, B, C>(f: (a: A, b: B) => C): (b: B, a: A) => C;
2
3
  export declare const run: <A>(f: Lazy<A>) => A;
3
4
  export declare function curry<A, B, C>(f: (a: A, b: B) => C): (a: A) => (b: B) => C;
4
5
  export declare function curry<A, B, C, D>(f: (a: A, b: B, c: C) => D): (a: A) => (b: B) => (c: C) => D;
@@ -1,3 +1,8 @@
1
+ export function flip(f) {
2
+ return (b, a) => {
3
+ return f(a, b);
4
+ };
5
+ }
1
6
  export const run = (f) => f();
2
7
  export function curry(f) {
3
8
  return function curried(...head) {
@@ -1,16 +1,16 @@
1
- import { Predicate } from 'fp-ts/Predicate';
2
- export declare type Struct = object;
3
- export declare type PartialDeep<A> = A extends {
1
+ import type { Predicate } from 'fp-ts/Predicate';
2
+ export type Struct = object;
3
+ export type PartialDeep<A> = A extends {
4
4
  readonly [x: string]: unknown;
5
5
  } ? Partial<{
6
6
  readonly [K in keyof A]: PartialDeep<A[K]>;
7
7
  }> : A;
8
- declare type IntersectionDeep<A, B> = A extends {
8
+ type IntersectionDeep<A, B> = A extends {
9
9
  readonly [x: string]: unknown;
10
10
  } ? A & {
11
11
  readonly [K in keyof B]: IntersectionDeep<K extends keyof A ? A[K] : unknown, B[K]>;
12
12
  } : B;
13
- export declare const toReadonlyArray: <A extends object>(a: A) => readonly (readonly [keyof A, A[keyof A]])[];
14
- export declare const filterDeep: <A extends object>(f: Predicate<unknown>) => (a: A) => PartialDeep<A>;
15
- export declare const patch: <A extends object, B extends PartialDeep<A> & object>(b: B) => (a: A) => IntersectionDeep<A, B>;
13
+ export declare const toReadonlyArray: <A extends Struct>(a: A) => ReadonlyArray<Readonly<[keyof A, A[keyof A]]>>;
14
+ export declare const filterDeep: <A extends Struct>(f: Predicate<unknown>) => (a: A) => PartialDeep<A>;
15
+ export declare const patch: <A extends Struct, B extends PartialDeep<A> & Struct>(b: B) => (a: A) => IntersectionDeep<A, B>;
16
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fortepiano",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Playing actual music over fp-ts notes",
5
5
  "keywords": [
6
6
  "typescript",
@@ -43,29 +43,32 @@
43
43
  "eslint:fix": "eslint --fix ./",
44
44
  "prettier": "prettier --check ./",
45
45
  "prettier:fix": "prettier --write ./",
46
+ "changeset": "changeset",
47
+ "changeset:version": "changeset version",
46
48
  "prerelease": "yarn build",
47
- "release": "yarn prerelease && npm publish",
49
+ "release": "yarn prerelease && changeset publish",
48
50
  "test": "jest",
49
51
  "test:watch": "jest --watchAll",
50
52
  "test:coverage": "jest --coverage"
51
53
  },
52
54
  "devDependencies": {
53
- "@rushstack/eslint-patch": "^1.1.3",
54
- "@types/jest": "^26.0.24",
55
- "@types/node": "^22.8.7",
56
- "eslint": "^8.16.0",
57
- "eslint-config-facile": "^0.5.0",
58
- "fp-ts": "^2.0.0",
59
- "io-ts": "^2.0.0",
60
- "jest": "^26.6.3",
61
- "prettier": "^2.6.2",
62
- "ts-jest": "^26.5.6",
55
+ "@changesets/changelog-github": "^1.0.1",
56
+ "@changesets/cli": "^3.0.3",
57
+ "@types/jest": "^30.0.0",
58
+ "@types/node": "^26.6.5",
59
+ "eslint": "^9.39.5",
60
+ "eslint-config-facile": "^1.2.0",
61
+ "fp-ts": "^2.16.0",
62
+ "io-ts": "^2.2.20",
63
+ "jest": "^30.5.2",
64
+ "prettier": "^3.3.3",
65
+ "ts-jest": "^29.2.5",
63
66
  "ts-node": "^10.9.2",
64
- "typescript": "^4.6.4"
67
+ "typescript": "^6.0.3"
65
68
  },
66
69
  "peerDependencies": {
67
70
  "fp-ts": "^2.5.0",
68
71
  "io-ts": "^2.2.0"
69
72
  },
70
73
  "packageManager": "yarn@4.18.1"
71
- }
74
+ }