@railway-ts/pipelines 0.1.10 → 0.1.12
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/README.md +51 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ Railway-oriented programming for TypeScript. Result and Option types that don't
|
|
|
6
6
|
|
|
7
7
|
Small, focused API surface. Errors propagate automatically, you handle them once at the end.
|
|
8
8
|
|
|
9
|
+
Fully tree-shakable — import only what you need:
|
|
10
|
+
|
|
11
|
+
`option` 402 B · `result` 582 B · `composition` 233 B · `schema` ~3 kB — **~4.2 kB total** minified + brotli
|
|
12
|
+
|
|
9
13
|
## Install
|
|
10
14
|
|
|
11
15
|
```bash
|
|
@@ -73,6 +77,10 @@ For a complete real-world pipeline, see the [Launch Decision Pipeline](docs/RECI
|
|
|
73
77
|
- **Async** -- sync-preserving overloads, parallel field validation, seamless sync/async mixing
|
|
74
78
|
- **Standard Schema v1** -- `toStandardSchema()` for tRPC, TanStack Form, React Hook Form, and other consumers
|
|
75
79
|
|
|
80
|
+
## Ecosystem
|
|
81
|
+
|
|
82
|
+
- **[@railway-ts/use-form](https://github.com/sakobu/railway-ts-use-form)** -- Type-safe React form hook. Define a schema here, get validated forms with autocomplete, error handling, and native HTML bindings.
|
|
83
|
+
|
|
76
84
|
## API Reference
|
|
77
85
|
|
|
78
86
|
### Option
|
|
@@ -95,15 +103,15 @@ match(name, {
|
|
|
95
103
|
}); // Output: Alice
|
|
96
104
|
```
|
|
97
105
|
|
|
98
|
-
| Category
|
|
99
|
-
|
|
100
|
-
| **Core**
|
|
101
|
-
| **Transform** | `map`, `flatMap`, `bimap`, `filter`, `tap`
|
|
102
|
-
| **Curried**
|
|
103
|
-
| **Unwrap**
|
|
104
|
-
| **Combine**
|
|
105
|
-
| **Convert**
|
|
106
|
-
| **Branch**
|
|
106
|
+
| Category | Functions |
|
|
107
|
+
| ------------- | ------------------------------------------------- |
|
|
108
|
+
| **Core** | `some`, `none`, `isSome`, `isNone` |
|
|
109
|
+
| **Transform** | `map`, `flatMap`, `bimap`, `filter`, `tap` |
|
|
110
|
+
| **Curried** | `mapWith`, `flatMapWith`, `filterWith`, `tapWith` |
|
|
111
|
+
| **Unwrap** | `unwrap`, `unwrapOr`, `unwrapOrElse` |
|
|
112
|
+
| **Combine** | `combine` |
|
|
113
|
+
| **Convert** | `fromNullable`, `mapToResult` |
|
|
114
|
+
| **Branch** | `match` |
|
|
107
115
|
|
|
108
116
|
### Result
|
|
109
117
|
|
|
@@ -126,22 +134,22 @@ match(result, {
|
|
|
126
134
|
}); // Output: 15
|
|
127
135
|
```
|
|
128
136
|
|
|
129
|
-
| Category
|
|
130
|
-
|
|
131
|
-
| **Core**
|
|
132
|
-
| **Transform** | `map`, `mapErr`, `flatMap`, `bimap`, `filter`, `tap`, `tapErr`
|
|
133
|
-
| **Curried**
|
|
134
|
-
| **Recovery**
|
|
135
|
-
| **Unwrap**
|
|
136
|
-
| **Combine**
|
|
137
|
-
| **Convert**
|
|
138
|
-
| **Branch**
|
|
137
|
+
| Category | Functions |
|
|
138
|
+
| ------------- | ------------------------------------------------------------------------------------------------ |
|
|
139
|
+
| **Core** | `ok`, `err`, `isOk`, `isErr` |
|
|
140
|
+
| **Transform** | `map`, `mapErr`, `flatMap`, `bimap`, `filter`, `tap`, `tapErr` |
|
|
141
|
+
| **Curried** | `mapWith`, `flatMapWith`, `mapErrWith`, `filterWith`, `tapWith`, `tapErrWith` |
|
|
142
|
+
| **Recovery** | `orElse`, `orElseWith` |
|
|
143
|
+
| **Unwrap** | `unwrap`, `unwrapOr`, `unwrapOrElse` |
|
|
144
|
+
| **Combine** | `combine`, `combineAll` |
|
|
145
|
+
| **Convert** | `fromTry`, `fromTryWithError`, `fromPromise`, `fromPromiseWithError`, `toPromise`, `mapToOption` |
|
|
146
|
+
| **Branch** | `match` |
|
|
139
147
|
|
|
140
148
|
### Schema
|
|
141
149
|
|
|
142
150
|
Parse untrusted data into typed values. Accumulates all validation errors.
|
|
143
151
|
|
|
144
|
-
> **Standard Schema v1 compliant** — use `toStandardSchema()` for interop with tRPC, TanStack Form, React Hook Form, and other Standard Schema consumers. See [Recipes
|
|
152
|
+
> **Standard Schema v1 compliant** — use `toStandardSchema()` for interop with tRPC, TanStack Form, React Hook Form, and other Standard Schema consumers. See [Recipes -> Standard Schema Interop](docs/RECIPES.md#standard-schema-interop).
|
|
145
153
|
|
|
146
154
|
```typescript
|
|
147
155
|
import {
|
|
@@ -170,24 +178,24 @@ const result = validate(input, userSchema);
|
|
|
170
178
|
// Result<User, ValidationError[]>
|
|
171
179
|
```
|
|
172
180
|
|
|
173
|
-
| Category
|
|
174
|
-
|
|
175
|
-
| **Primitives**
|
|
176
|
-
| **Parsers**
|
|
177
|
-
| **Structures**
|
|
178
|
-
| **Unions**
|
|
179
|
-
| **Modifiers**
|
|
180
|
-
| **String Constraints**
|
|
181
|
-
| **Number Constraints**
|
|
182
|
-
| **Date Constraints**
|
|
183
|
-
| **Enums**
|
|
184
|
-
| **Boolean Constraints** | `matches`
|
|
185
|
-
| **Array Constraints**
|
|
186
|
-
| **Combinators**
|
|
187
|
-
| **Cross-field**
|
|
188
|
-
| **Async**
|
|
189
|
-
| **Utilities**
|
|
190
|
-
| **Types**
|
|
181
|
+
| Category | Functions |
|
|
182
|
+
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
183
|
+
| **Primitives** | `string`, `number`, `boolean`, `date`, `bigint` |
|
|
184
|
+
| **Parsers** | `parseNumber`, `parseString`, `parseBool`, `parseBigInt`, `parseDate`, `parseISODate`, `parseJSON`, `parseURL`, `parseEnum` |
|
|
185
|
+
| **Structures** | `object`, `array`, `tuple`, `tupleOf` |
|
|
186
|
+
| **Unions** | `union`, `discriminatedUnion`, `literal` |
|
|
187
|
+
| **Modifiers** | `required`, `optional`, `nullable`, `emptyAsOptional` |
|
|
188
|
+
| **String Constraints** | `minLength`, `maxLength`, `pattern`, `nonEmpty`, `email`, `phoneNumber` |
|
|
189
|
+
| **Number Constraints** | `min`, `max`, `integer`, `finite`, `between`, `positive`, `negative`, `nonZero`, `divisibleBy`, `precision` |
|
|
190
|
+
| **Date Constraints** | `dateRange`, `pastDate`, `futureDate`, `todayOrFuture` |
|
|
191
|
+
| **Enums** | `stringEnum`, `enumValue`, `oneOf` |
|
|
192
|
+
| **Boolean Constraints** | `matches` |
|
|
193
|
+
| **Array Constraints** | `minItems`, `maxItems`, `notEmpty`, `unique` |
|
|
194
|
+
| **Combinators** | `chain`, `transform`, `refine` |
|
|
195
|
+
| **Cross-field** | `refineAt`, `refineAtAsync` |
|
|
196
|
+
| **Async** | `chainAsync`, `refineAsync`, `refineAtAsync` |
|
|
197
|
+
| **Utilities** | `validate`, `validateAndFormatResult`, `formatErrors`, `toStandardSchema`, `ROOT_ERROR_KEY` |
|
|
198
|
+
| **Types** | `Validator`, `AsyncValidator`, `MaybeAsyncValidator`, `Schema`, `SyncSchema`, `InferSchemaType`, `ValidatorMapOutput`, `ValidationError`, `ValidationResult`, `StandardSchemaV1` |
|
|
191
199
|
|
|
192
200
|
### Composition
|
|
193
201
|
|
|
@@ -218,11 +226,11 @@ const processOrder = flowAsync(validateOrder, chargePayment, createShipment);
|
|
|
218
226
|
await processOrder(orderInput);
|
|
219
227
|
```
|
|
220
228
|
|
|
221
|
-
| Category
|
|
222
|
-
|
|
223
|
-
| **Sync**
|
|
224
|
-
| **Async** | `pipeAsync`, `flowAsync`
|
|
225
|
-
| **Types** | `MaybeAsync`
|
|
229
|
+
| Category | Functions |
|
|
230
|
+
| --------- | -------------------------------------------------------- |
|
|
231
|
+
| **Sync** | `pipe`, `flow`, `curry`, `uncurry`, `tupled`, `untupled` |
|
|
232
|
+
| **Async** | `pipeAsync`, `flowAsync` |
|
|
233
|
+
| **Types** | `MaybeAsync` |
|
|
226
234
|
|
|
227
235
|
## Examples
|
|
228
236
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@railway-ts/pipelines",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Railway-oriented pipelines for TypeScript: a lightweight fp-style Result/Option and schema layer for handling errors and validating boundaries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|