Skip to content

Commit dc2a35c

Browse files
authored
prepare for production (#30)
1 parent a7cd12a commit dc2a35c

28 files changed

Lines changed: 2242 additions & 32 deletions

.changeset/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changesets
2+
3+
This folder stores changeset entries used for versioning and changelogs.
4+
See https://github.com/changesets/changesets for details.

.changeset/cold-olives-cry.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.planning/PROJECT.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# @power-rent/try-catch
2+
3+
## What This Is
4+
5+
A TypeScript utility library for full-stack teams to handle async errors with a fluent Try API and optional Sentry reporting via `report()`. It supports Node, browser, and Next.js entry points with consistent behavior across environments.
6+
7+
## Core Value
8+
9+
A fluent Try API that never hides errors.
10+
11+
## Requirements
12+
13+
### Validated
14+
15+
- ✓ Developers can run functions via `Try` and choose `.value()`, `.default()`, `.error()`, or `.unwrap()` for clear outcomes — existing
16+
- ✓ Developers can send errors to Sentry using `.report(message)` with tags and breadcrumbs — existing
17+
- ✓ Developers can use environment-specific entry points (`/node`, `/browser`, `/nextjs`) — existing
18+
19+
### Active
20+
21+
- [ ] Documentation aligns with real usage patterns, especially `report()` behavior and error outcomes
22+
- [ ] Type safety is preserved across sync/async functions and all execution paths
23+
- [ ] Core error-handling flows are well tested (value/default/error/unwrap + reporting)
24+
25+
### Out of Scope
26+
27+
- New runtimes (Deno/Bun/Cloudflare) — keep focus on current environments
28+
29+
## Context
30+
31+
- Existing codebase with a modular core Try class, reporter abstraction, and platform adapters
32+
- Sentry integration is opt-in via `.report()`; reporting uses adapters per environment
33+
34+
## Constraints
35+
36+
- **Quality**: Type-safe API and strong test coverage — required
37+
- **Runtime**: Node.js >= 20 — current support target
38+
39+
## Key Decisions
40+
41+
| Decision | Rationale | Outcome |
42+
|----------|-----------|---------|
43+
| Target both server and browser usage | Library is meant to be shared across environments | — Pending |
44+
| Reporting via explicit `.report()` | Keeps error handling intentional and opt-in | — Pending |
45+
| No new runtimes in v1 | Reduce scope and keep focus on current adapters | — Pending |
46+
47+
---
48+
*Last updated: 2026-01-30 after initialization*

.planning/REQUIREMENTS.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Requirements: @power-rent/try-catch
2+
3+
**Defined:** 2026-01-31
4+
**Core Value:** A fluent Try API that never hides errors.
5+
6+
## v1 Requirements
7+
8+
Requirements for initial release. Each maps to roadmap phases.
9+
10+
### Core Try API
11+
12+
- [ ] **TRY-01**: User can wrap sync functions with `new Try(fn, ...args)` and execute via `.value()`, `.error()`, or `.unwrap()`
13+
- [ ] **TRY-02**: User can wrap async functions with the same fluent API and preserve type inference
14+
- [ ] **TRY-03**: User can provide a fallback via `.default(value)` and receive it on error
15+
- [ ] **TRY-04**: Error channel is type-safe across all execution paths
16+
17+
### Sentry Reporting
18+
19+
- [ ] **SENT-01**: User can call `.report(message)` to capture the error via Sentry
20+
- [ ] **SENT-02**: User can attach tags and breadcrumbs to reported events via fluent chain
21+
- [ ] **SENT-03**: Errors are reported only when `.report()` is explicitly called, but breadcrumbs are always recorded when `.breadcrumbs()` is used
22+
- [ ] **SENT-04**: Breadcrumbs configuration is type-safe and matches README examples
23+
24+
### Entry Points
25+
26+
- [ ] **ENTRY-01**: Node entry point available at `@power-rent/try-catch/node`
27+
- [ ] **ENTRY-02**: Browser entry point available at `@power-rent/try-catch/browser`
28+
- [ ] **ENTRY-03**: Next.js entry point available at `@power-rent/try-catch/nextjs`
29+
30+
### Diagnostics
31+
32+
- [ ] **DIAG-01**: Non-Error throws are normalized into an Error before reporting
33+
- [ ] **DIAG-02**: Debug mode allows local error logging without Sentry
34+
35+
### Developer Experience
36+
37+
- [ ] **DX-01**: Documentation and examples read like native English error handling
38+
39+
## v2 Requirements
40+
41+
Deferred to future release. Tracked but not in current roadmap.
42+
43+
### Sentry Reporting
44+
45+
- **SENT-05**: Scoped metadata isolation per call to prevent cross-request bleed
46+
- **SENT-06**: Zero runtime dependency when Sentry is unused
47+
48+
## Out of Scope
49+
50+
Explicitly excluded. Documented to prevent scope creep.
51+
52+
| Feature | Reason |
53+
|---------|--------|
54+
| New runtimes (Deno/Bun/Cloudflare) | Focus on current environments for v1 |
55+
| Result-style combinators (combine/all/partition) | Scope creep beyond focused Try API |
56+
| Lint plugin for “must handle” semantics | Likely separate package later |
57+
| Auto-report all errors by default | Creates Sentry noise; report is explicit |
58+
59+
## Traceability
60+
61+
Which phases cover which requirements. Updated during roadmap creation.
62+
63+
| Requirement | Phase | Status |
64+
|-------------|-------|--------|
65+
| TRY-01 | Phase 1 | Pending |
66+
| TRY-02 | Phase 1 | Pending |
67+
| TRY-03 | Phase 1 | Pending |
68+
| TRY-04 | Phase 1 | Pending |
69+
| SENT-01 | Phase 2 | Pending |
70+
| SENT-02 | Phase 2 | Pending |
71+
| SENT-03 | Phase 2 | Pending |
72+
| SENT-04 | Phase 2 | Pending |
73+
| ENTRY-01 | Phase 2 | Pending |
74+
| ENTRY-02 | Phase 2 | Pending |
75+
| ENTRY-03 | Phase 2 | Pending |
76+
| DIAG-01 | Phase 2 | Pending |
77+
| DIAG-02 | Phase 2 | Pending |
78+
| DX-01 | Phase 3 | Pending |
79+
80+
**Coverage:**
81+
- v1 requirements: 14 total
82+
- Mapped to phases: 14
83+
- Unmapped: 0
84+
85+
---
86+
*Requirements defined: 2026-01-31*
87+
*Last updated: 2026-01-31 after initial definition*

.planning/ROADMAP.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Roadmap: @power-rent/try-catch
2+
3+
## Overview
4+
5+
This roadmap delivers a fluent, type-safe Try API first, then layers in Sentry reporting with runtime entry points and diagnostics. Documentation comes last to ensure examples reflect the real behavior users will see.
6+
7+
## Phases
8+
9+
**Phase Numbering:**
10+
- Integer phases (1, 2, 3): Planned milestone work
11+
- Decimal phases (2.1, 2.2): Urgent insertions (marked with INSERTED)
12+
13+
Decimal phases appear between their surrounding integers in numeric order.
14+
15+
- [ ] **Phase 1: Core Try Semantics** - Users can handle sync/async errors with typed outcomes.
16+
- [ ] **Phase 2: Reporting + Runtime Entry Points** - Users can report errors with Sentry across environments, with diagnostics.
17+
- [ ] **Phase 3: Documentation & Examples** - Users can follow clear docs that match real behavior.
18+
19+
## Phase Details
20+
21+
### Phase 1: Core Try Semantics
22+
**Goal**: Users can handle sync/async errors with a type-safe Try API.
23+
**Depends on**: Nothing (first phase)
24+
**Requirements**: TRY-01, TRY-02, TRY-03, TRY-04
25+
**Success Criteria** (what must be TRUE):
26+
1. User can wrap sync functions with `new Try(fn, ...args)` and retrieve outcomes via `.value()`, `.error()`, or `.unwrap()`.
27+
2. User can wrap async functions with the same API and retain correct TypeScript inference for success and error channels.
28+
3. User can supply a fallback via `.default(value)` and receive it on error.
29+
**Plans**: TBD
30+
31+
Plans:
32+
- [ ] 01-01: TBD
33+
34+
### Phase 2: Reporting + Runtime Entry Points
35+
**Goal**: Users can report errors with Sentry across runtimes, with clear diagnostics.
36+
**Depends on**: Phase 1
37+
**Requirements**: SENT-01, SENT-02, SENT-03, SENT-04, ENTRY-01, ENTRY-02, ENTRY-03, DIAG-01, DIAG-02
38+
**Success Criteria** (what must be TRUE):
39+
1. User can call `.report(message)` to send the current error to Sentry.
40+
2. User can attach tags and breadcrumbs in the fluent chain before reporting.
41+
3. Reporting defaults avoid noisy handled errors unless explicitly requested.
42+
4. User can import runtime-specific entry points (`/node`, `/browser`, `/nextjs`) with consistent reporting behavior.
43+
5. Breadcrumbs configuration is type-safe and matches README examples.
44+
6. Non-Error throws are normalized to Error before reporting, and debug mode logs locally without Sentry.
45+
**Plans**: TBD
46+
47+
Plans:
48+
- [ ] 02-01: TBD
49+
50+
### Phase 3: Documentation & Examples
51+
**Goal**: Users can rely on docs/examples that reflect real Try and reporting behavior.
52+
**Depends on**: Phase 2
53+
**Requirements**: DX-01
54+
**Success Criteria** (what must be TRUE):
55+
1. User can follow docs/examples for core Try usage that read like native English error handling and match actual outcomes.
56+
2. User can follow docs/examples for reporting and entry points that reflect real `report()` behavior and configuration.
57+
**Plans**: TBD
58+
59+
Plans:
60+
- [ ] 03-01: TBD
61+
62+
## Progress
63+
64+
**Execution Order:**
65+
Phases execute in numeric order: 2 → 2.1 → 2.2 → 3 → 3.1 → 4
66+
67+
| Phase | Plans Complete | Status | Completed |
68+
|-------|----------------|--------|-----------|
69+
| 1. Core Try Semantics | 0/TBD | Not started | - |
70+
| 2. Reporting + Runtime Entry Points | 0/TBD | Not started | - |
71+
| 3. Documentation & Examples | 0/TBD | Not started | - |

.planning/STATE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Project State
2+
3+
## Project Reference
4+
5+
See: .planning/PROJECT.md (updated 2026-01-31)
6+
7+
**Core value:** A fluent Try API that never hides errors.
8+
**Current focus:** Phase 1 — Core Try Semantics
9+
10+
## Current Position
11+
12+
Phase: 1 of 3 (Core Try Semantics)
13+
Plan: 0 of TBD in current phase
14+
Status: Ready to plan
15+
Last activity: 2026-01-31 - Completed quick task 001: write tests that verify type safety accoriding to the use cases covered in Readme.md
16+
17+
Progress: [░░░░░░░░░░] 0%
18+
19+
## Performance Metrics
20+
21+
**Velocity:**
22+
- Total plans completed: 1
23+
- Average duration: 2m 41s
24+
- Total execution time: 2m 41s
25+
26+
**By Phase:**
27+
28+
| Phase | Plans | Total | Avg/Plan |
29+
|-------|-------|-------|----------|
30+
| Quick | 1 | 2m 41s | 2m 41s |
31+
32+
**Recent Trend:**
33+
- Last 5 plans: -
34+
- Trend: -
35+
36+
*Updated after each plan completion*
37+
38+
## Accumulated Context
39+
40+
### Decisions
41+
42+
Decisions are logged in PROJECT.md Key Decisions table.
43+
Recent decisions affecting current work:
44+
45+
- None yet.
46+
47+
### Pending Todos
48+
49+
[From .planning/todos/pending/ — ideas captured during sessions]
50+
51+
None yet.
52+
53+
### Blockers/Concerns
54+
55+
[Issues that affect future work]
56+
57+
None yet.
58+
59+
### Quick Tasks Completed
60+
61+
| # | Description | Date | Commit | Directory |
62+
|---|-------------|------|--------|-----------|
63+
| 001 | write tests that verify type safety accoriding to the use cases covered in Readme.md | 2026-01-31 | 9595583 | [001-write-tests-that-verify-type-safety-acco](./quick/001-write-tests-that-verify-type-safety-acco/) |
64+
65+
## Session Continuity
66+
67+
Last session: 2026-01-31 14:21 UTC
68+
Stopped at: Completed quick-001 type-safety-tests plan 001
69+
Resume file: None

0 commit comments

Comments
 (0)