Skip to content

Commit 139b2df

Browse files
committed
feat: update to Effect 4 RC (#8)
1 parent 6273cd7 commit 139b2df

8 files changed

Lines changed: 45 additions & 82 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
`@toolsplus/json-evolutions` evolves stored JSON objects through explicitly versioned changesets while application code works with the latest Effect Schema representation.
44

5-
Version 2 is Effect 4-native and ESM-only. It deliberately replaces the v1 io-ts/fp-ts interface while preserving the stored `_version` protocol.
5+
Version 3 is Effect 4-native and ESM-only. It deliberately replaces the v1 io-ts/fp-ts interface while preserving the stored `_version` protocol.
66

77
## Install
88

99
```shell
10-
npm install @toolsplus/json-evolutions effect@4.0.0-beta.107
10+
npm install @toolsplus/json-evolutions effect@4.0.0-rc.109
1111
```
1212

13-
The Effect peer is pinned exactly while Effect 4 Schema remains beta-sensitive. Node.js 24 or newer is required.
13+
The Effect peer is pinned exactly while Effect 4 is a release candidate. Node.js 24 or newer is required.
1414

1515
## Complete example
1616

@@ -111,4 +111,4 @@ A stored value must be a genuine JSON root object with an own non-negative safe-
111111

112112
Functions, `undefined`, symbols, bigint, `Date`, `Map`, `Set`, non-finite numbers, cycles, and root arrays are rejected. Changesets never mutate the original input. The engine owns `_version`, stamps it after each successful changeset, and validates the newly stamped value before continuing. Business structs may not declare the reserved root marker.
113113

114-
See [the v1-to-v2 migration guide](docs/migration-v2.md) for source migration details.
114+
See [the v1-to-v3 migration guide](docs/migration-v3.md) for source migration details.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Release v2 without a prerelease line
1+
# Release v3 without a prerelease line
22

3-
The Effect 4 rewrite will be released directly as stable `2.0.0`, without a `2.0.0-beta.x` line, even though it initially peers on exact `effect@4.0.0-beta.107`. The package's own interface and behavior will be treated as release-ready; exact Effect pinning contains upstream beta drift, and later Effect upgrades can be released normally.
3+
The Effect 4 rewrite will be released directly as stable `3.0.0`, without a `3.0.0-beta.x` line, even though it initially peers on exact `effect@4.0.0-beta.107`. The package's own interface and behavior will be treated as release-ready; exact Effect pinning contains upstream beta drift, and later Effect upgrades can be released normally.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# Migrating from v1 to v2
1+
# Migrating from v1 to v3
22

3-
Version 2 preserves stored values but intentionally replaces the source API. Existing JSON objects carrying sequential `_version` markers remain the compatibility boundary.
3+
Version 3 preserves stored values but intentionally replaces the source API. Existing JSON objects carrying sequential `_version` markers remain the compatibility boundary.
44

55
## Package requirements
66

77
- Use Node.js 24 or newer.
88
- Consume the package as ESM.
9-
- Install the exact peer `effect@4.0.0-beta.107`.
9+
- Install the exact peer `effect@4.0.0-rc.109`.
1010
- Remove direct `io-ts` and `fp-ts` usage that existed only for JSON Evolutions.
1111

1212
## API replacements
1313

14-
| v1 | v2 |
14+
| v1 | v3 |
1515
| -------------------------------------------- | ---------------------------------------------- |
1616
| io-ts codec | `Schema.Struct` |
1717
| `versioned(codec, latestVersion(changelog))` | `schema.pipe(versioned(changelog))` |
@@ -45,7 +45,7 @@ const decoded = pipe(evolve(changelog)(input), E.chain(Configuration.decode));
4545

4646
## After
4747

48-
The v2 example below is compiled against the packed npm artifact during the package smoke test.
48+
The v3 example below is compiled against the packed npm artifact during the package smoke test.
4949

5050
```typescript package-smoke
5151
import {Effect, Result, Schema} from "effect";
@@ -64,14 +64,14 @@ const input = {_version: 1, enabled: true};
6464
const decoded = await Effect.runPromise(
6565
evolveAndDecode(StoredConfiguration)(input),
6666
);
67-
if (!decoded.enabled) throw new Error("v2 migration example failed");
67+
if (!decoded.enabled) throw new Error("v3 migration example failed");
6868
```
6969

7070
## Behavior changes
7171

7272
### Strict recursive JSON
7373

74-
Version 2 validates the entire stored value. JavaScript-only values such as functions, `undefined`, bigint, `Date`, `Map`, `Set`, non-finite numbers, and cycles now fail as `InvalidStoredValue`.
74+
Version 3 validates the entire stored value. JavaScript-only values such as functions, `undefined`, bigint, `Date`, `Map`, `Set`, non-finite numbers, and cycles now fail as `InvalidStoredValue`.
7575

7676
### Exact latest-version decoding
7777

@@ -99,4 +99,4 @@ Replace `errorCode` branching with `_tag` matching. Errors are yieldable `Schema
9999

100100
### ESM-only consumption
101101

102-
Version 2 exposes one ESM root entry. Replace `require()` with `import`; no CommonJS condition is advertised.
102+
Version 3 exposes one ESM root entry. Replace `require()` with `import`; no CommonJS condition is advertised.

‎docs/plans/effect-v4-rewrite.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Outcome
44

5-
Release `@toolsplus/json-evolutions` 2.0.0 as an Effect 4-native, ESM-only library. The release replaces the io-ts and fp-ts interface, preserves the persisted stored-value protocol, validates genuine JSON at runtime, and continues delegating changeset execution to `fast-json-patch` and `immutability-helper`.
5+
Release `@toolsplus/json-evolutions` 3.0.0 as an Effect 4-native, ESM-only library. The release replaces the io-ts and fp-ts interface, preserves the persisted stored-value protocol, validates genuine JSON at runtime, and continues delegating changeset execution to `fast-json-patch` and `immutability-helper`.
66

77
The rewrite is intentionally source-incompatible with v1. Existing stored values remain compatible.
88

@@ -153,7 +153,7 @@ evolveAndDecode<E = never, R = never>(
153153
154154
The final implementation must preserve the supplied struct's decoding and encoding service requirements. `VersionedSchema` is nominally marked and retains its validated changelog through private symbol metadata.
155155
156-
`versioned` initially supports `Schema.Struct` only. It rejects a business schema that declares the reserved root `_version` field. Do not add an opaque arbitrary-object-codec overload in v2.0.
156+
`versioned` initially supports `Schema.Struct` only. It rejects a business schema that declares the reserved root `_version` field. Do not add an opaque arbitrary-object-codec overload in v3.0.
157157
158158
All transformation functions are data-last and pipe-friendly. Do not add duplicate data-first overloads.
159159
@@ -318,8 +318,8 @@ Use exact Effect beta ranges. Do not use `^` or `~` while the public Schema type
318318
319319
- Update CI and release workflow test commands for Vitest.
320320
- Preserve build, coverage, lint, formatting, documentation, semantic-release, npm provenance, and Node 24 checks.
321-
- Ensure the release commit communicates a breaking change under the repository's Angular conventional-commit rules so semantic-release selects `2.0.0`.
322-
- Publish directly as stable `2.0.0`; do not create a package prerelease line.
321+
- Ensure the release commit communicates a breaking change under the repository's Angular conventional-commit rules so semantic-release selects `3.0.0`.
322+
- Publish directly as stable `3.0.0`; do not create a package prerelease line.
323323
324324
## Test strategy
325325
@@ -417,7 +417,7 @@ State explicitly that changelogs are trusted source declarations and that stored
417417
418418
### Migration guide
419419
420-
Add a concise v1-to-v2 guide covering:
420+
Add a concise v1-to-v3 guide covering:
421421
422422
- `io-ts` codec to Effect `Schema.Struct`
423423
- `versioned(codec, latestVersion(changelog))` to `schema.pipe(versioned(changelog))`
@@ -495,11 +495,11 @@ Do this after the interface works end to end so packaging failures remain separa
495495
### Phase 7: Consumer migration and release readiness
496496
497497
1. Rewrite the README.
498-
2. Add the v1-to-v2 migration guide.
498+
2. Add the v1-to-v3 migration guide.
499499
3. Verify generated API documentation.
500500
4. Audit exports and tarball contents.
501501
5. Run the full quality gate.
502-
6. Prepare a breaking conventional commit/release path for stable 2.0.0.
502+
6. Prepare a breaking conventional commit/release path for stable 3.0.0.
503503
504504
## Quality gate
505505

‎package-lock.json‎

Lines changed: 10 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"!**/__mocks__/**",
2222
"!**/*.json",
2323
"README.md",
24-
"docs/migration-v2.md"
24+
"docs/migration-v3.md"
2525
],
2626
"engines": {
2727
"node": ">=24"
@@ -31,10 +31,10 @@
3131
"build": "node scripts/build.mjs",
3232
"typecheck": "tsc -p tsconfig.test.json --noEmit",
3333
"fix": "run-s fix:*",
34-
"fix:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"README.md\" \"docs/migration-v2.md\" --write",
34+
"fix:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"README.md\" \"docs/migration-v3.md\" --write",
3535
"fix:lint": "eslint src test --fix",
3636
"lint": "eslint src test",
37-
"prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"README.md\" \"docs/migration-v2.md\" --check",
37+
"prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\" \"README.md\" \"docs/migration-v3.md\" --check",
3838
"test": "vitest run",
3939
"test:coverage": "vitest run --coverage",
4040
"smoke:package": "node scripts/package-smoke.mjs",
@@ -58,7 +58,7 @@
5858
"@typescript-eslint/eslint-plugin": "8.43.0",
5959
"@typescript-eslint/parser": "8.43.0",
6060
"@vitest/coverage-v8": "4.1.10",
61-
"effect": "4.0.0-beta.107",
61+
"effect": "4.0.0-rc.109",
6262
"eslint": "9.35.0",
6363
"eslint-config-prettier": "10.1.8",
6464
"fast-check": "4.9.0",
@@ -72,7 +72,7 @@
7272
"vitest": "4.1.10"
7373
},
7474
"peerDependencies": {
75-
"effect": "4.0.0-beta.107"
75+
"effect": "4.0.0-rc.109"
7676
},
7777
"dependencies": {
7878
"fast-json-patch": "^3.1.1",

‎scripts/package-smoke.mjs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ try {
4040
const packedPaths = new Set(files.map(({path}) => path));
4141
for (const requiredPath of [
4242
"README.md",
43-
"docs/migration-v2.md",
43+
"docs/migration-v3.md",
4444
"build/index.js",
4545
"build/index.d.ts",
4646
"package.json",
@@ -75,16 +75,16 @@ try {
7575
"--ignore-scripts",
7676
"--no-package-lock",
7777
tarball,
78-
"effect@4.0.0-beta.107",
78+
"effect@4.0.0-rc.109",
7979
],
8080
{cwd: fixture, stdio: "inherit", env: npmEnvironment},
8181
);
8282

8383
const readmeExample = extractPackageSmokeExample("README.md");
84-
const migrationExample = extractPackageSmokeExample("docs/migration-v2.md");
84+
const migrationExample = extractPackageSmokeExample("docs/migration-v3.md");
8585
writeFileSync(resolve(fixture, "README.example.ts"), readmeExample);
8686
writeFileSync(
87-
resolve(fixture, "migration-v2.example.ts"),
87+
resolve(fixture, "migration-v3.example.ts"),
8888
migrationExample,
8989
);
9090
writeFileSync(
@@ -98,7 +98,7 @@ try {
9898
noEmit: true,
9999
skipLibCheck: true,
100100
},
101-
include: ["README.example.ts", "migration-v2.example.ts"],
101+
include: ["README.example.ts", "migration-v3.example.ts"],
102102
}),
103103
);
104104

@@ -117,7 +117,7 @@ try {
117117
});
118118
execFileSync(
119119
process.execPath,
120-
[resolve(fixture, "migration-v2.example.ts")],
120+
[resolve(fixture, "migration-v3.example.ts")],
121121
{cwd: fixture, stdio: "inherit"},
122122
);
123123

‎test/type-contracts.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ export type CombinedServicesContract = Expect<
7474

7575
// @ts-expect-error Business schemas cannot own the reserved root marker.
7676
versioned(changelog)(Schema.Struct({_version: Schema.Number}));
77-
// @ts-expect-error Arbitrary object codecs are outside the v2 interface.
77+
// @ts-expect-error Arbitrary object codecs are outside the v3 interface.
7878
versioned(changelog)(Schema.Record(Schema.String, Schema.String));
7979

8080
class BusinessClass extends Schema.Class<BusinessClass>("BusinessClass")({
8181
value: Schema.String,
8282
}) {}
83-
// @ts-expect-error Schema classes are outside the v2 interface.
83+
// @ts-expect-error Schema classes are outside the v3 interface.
8484
versioned(changelog)(BusinessClass);
8585

8686
const StructWithRest = Schema.StructWithRest(Schema.Struct({}), [
8787
Schema.Record(Schema.String, Schema.String),
8888
]);
89-
// @ts-expect-error Structs with rest records are outside the v2 interface.
89+
// @ts-expect-error Structs with rest records are outside the v3 interface.
9090
versioned(changelog)(StructWithRest);
9191

9292
// @ts-expect-error evolveAndDecode accepts only nominal VersionedSchema values.

0 commit comments

Comments
 (0)