@oxog/types 1.0.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/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +945 -0
- package/dist/index.d.ts +945 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ersin Koç
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# @oxog/types
|
|
2
|
+
|
|
3
|
+
**Shared TypeScript types, interfaces, and utilities for the @oxog ecosystem.**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@oxog/types)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://github.com/ersinkoc/types)
|
|
8
|
+
[](https://github.com/ersinkoc/types)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
`@oxog/types` is the foundational package for the entire @oxog ecosystem. It provides:
|
|
14
|
+
|
|
15
|
+
- **Micro-kernel plugin architecture** - Standardized Plugin and Kernel interfaces
|
|
16
|
+
- **Functional error handling** - Rust-inspired Result type (Ok/Err)
|
|
17
|
+
- **Error classes** - OxogError, ValidationError, PluginError
|
|
18
|
+
- **Type guards** - Runtime type checking for all public types
|
|
19
|
+
- **Utility types** - Branded types, deep utilities, JSON types, and more
|
|
20
|
+
- **Event system** - Type-safe event handling primitives
|
|
21
|
+
- **Zero dependencies** - Pure TypeScript, no runtime dependencies
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @oxog/types
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { Plugin, Kernel, Result, Ok, Err, OxogError } from '@oxog/types';
|
|
31
|
+
|
|
32
|
+
// Example: Using Result type
|
|
33
|
+
function divide(a: number, b: number): Result<number, string> {
|
|
34
|
+
if (b === 0) return Err('Division by zero');
|
|
35
|
+
return Ok(a / b);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const result = divide(10, 2);
|
|
39
|
+
if (isOk(result)) {
|
|
40
|
+
console.log(result.value); // 5
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Example: Creating a plugin
|
|
44
|
+
const myPlugin: Plugin = {
|
|
45
|
+
name: 'my-plugin',
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
install(kernel) {
|
|
48
|
+
kernel.on('event', (payload) => {
|
|
49
|
+
console.log('Event received:', payload);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Example: Error handling
|
|
55
|
+
throw new OxogError('Database error', ErrorCodes.DEPENDENCY_ERROR, {
|
|
56
|
+
host: 'localhost',
|
|
57
|
+
port: 5432,
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
### 1. Plugin System
|
|
64
|
+
|
|
65
|
+
Standard plugin interface for extensible applications:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
interface Plugin<TContext = unknown> {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly version: string;
|
|
71
|
+
readonly dependencies?: readonly string[];
|
|
72
|
+
install: (kernel: Kernel<TContext>) => void;
|
|
73
|
+
onInit?: (context: TContext) => MaybePromise<void>;
|
|
74
|
+
onDestroy?: () => MaybePromise<void>;
|
|
75
|
+
onError?: (error: Error) => void;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. Result Type
|
|
80
|
+
|
|
81
|
+
Rust-inspired functional error handling:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
type Result<T, E> = Ok<T> | Err<E>;
|
|
85
|
+
|
|
86
|
+
function parseInt(value: string): Result<number, string> {
|
|
87
|
+
const num = Number(value);
|
|
88
|
+
if (isNaN(num)) return Err('Not a number');
|
|
89
|
+
return Ok(num);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const result = parseInt('42').map(n => n * 2);
|
|
93
|
+
if (isOk(result)) {
|
|
94
|
+
console.log(result.value); // 84
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 3. Error Classes
|
|
99
|
+
|
|
100
|
+
Standardized error hierarchy:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
// Base error with code and context
|
|
104
|
+
throw new OxogError('Something went wrong', 'ERR_CODE', { userId: '123' });
|
|
105
|
+
|
|
106
|
+
// Validation errors
|
|
107
|
+
throw new ValidationError('Invalid email', { field: 'email', value: 'bad-email' });
|
|
108
|
+
|
|
109
|
+
// Plugin errors
|
|
110
|
+
throw new PluginError('Failed to initialize', 'cache-plugin', { reason: 'Redis down' });
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 4. Type Guards
|
|
114
|
+
|
|
115
|
+
Runtime type checking:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
if (isPlugin(obj)) {
|
|
119
|
+
console.log(obj.name, obj.version); // TypeScript knows it's a Plugin
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (isValidationError(error)) {
|
|
123
|
+
console.log(error.context?.field); // TypeScript knows it's a ValidationError
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 5. Branded Types
|
|
128
|
+
|
|
129
|
+
Type-safe identifiers:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
type UserId = Branded<string, 'UserId'>;
|
|
133
|
+
type OrderId = Branded<string, 'OrderId'>;
|
|
134
|
+
|
|
135
|
+
const userId: UserId = 'user_123' as UserId;
|
|
136
|
+
const orderId: OrderId = 'order_456' as OrderId;
|
|
137
|
+
|
|
138
|
+
// Type error: Type 'UserId' is not assignable to type 'OrderId'
|
|
139
|
+
const wrong: OrderId = userId;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 6. Utility Types
|
|
143
|
+
|
|
144
|
+
Common TypeScript utilities:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
// Deep utilities
|
|
148
|
+
type PartialUser = DeepPartial<User>;
|
|
149
|
+
|
|
150
|
+
// JSON types
|
|
151
|
+
type ApiResponse = JsonValue;
|
|
152
|
+
|
|
153
|
+
// MaybePromise for sync/async flexibility
|
|
154
|
+
function getData(): MaybePromise<string> {
|
|
155
|
+
return 'sync'; // or Promise.resolve('async')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// NonEmptyArray
|
|
159
|
+
const list: NonEmptyArray<number> = [1]; // At least one element
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 7. Event System
|
|
163
|
+
|
|
164
|
+
Type-safe event handling:
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
interface AppEvents extends EventMap {
|
|
168
|
+
'user:login': { userId: string; timestamp: number };
|
|
169
|
+
'error': Error;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const handler: EventHandler<AppEvents, 'user:login'> = (payload) => {
|
|
173
|
+
console.log(payload.userId, payload.timestamp);
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## API Reference
|
|
178
|
+
|
|
179
|
+
### Core Interfaces
|
|
180
|
+
|
|
181
|
+
- `Plugin<TContext>` - Standard plugin interface
|
|
182
|
+
- `Kernel<TContext>` - Micro-kernel for plugin management
|
|
183
|
+
- `TypedEventEmitter<TEvents>` - Type-safe event emitter
|
|
184
|
+
|
|
185
|
+
### Result Type
|
|
186
|
+
|
|
187
|
+
- `Result<T, E>` - Union of Ok<T> or Err<E>
|
|
188
|
+
- `Ok<T>` - Successful result interface
|
|
189
|
+
- `Err<E>` - Failed result interface
|
|
190
|
+
- `Ok(value: T)` - Create successful result
|
|
191
|
+
- `Err(error: E)` - Create failed result
|
|
192
|
+
- `isOk(result)` - Type guard for Ok
|
|
193
|
+
- `isErr(result)` - Type guard for Err
|
|
194
|
+
|
|
195
|
+
### Error Classes
|
|
196
|
+
|
|
197
|
+
- `OxogError` - Base error class
|
|
198
|
+
- `ValidationError` - Validation errors
|
|
199
|
+
- `PluginError` - Plugin-specific errors
|
|
200
|
+
- `ErrorCodes` - Standard error codes enum
|
|
201
|
+
|
|
202
|
+
### Type Guards
|
|
203
|
+
|
|
204
|
+
- `isPlugin<T>(value)` - Check if value is Plugin
|
|
205
|
+
- `isKernel<T>(value)` - Check if value is Kernel
|
|
206
|
+
- `isOxogError(value)` - Check if value is OxogError
|
|
207
|
+
- `isValidationError(value)` - Check if value is ValidationError
|
|
208
|
+
- `isPluginError(value)` - Check if value is PluginError
|
|
209
|
+
|
|
210
|
+
### Utility Types
|
|
211
|
+
|
|
212
|
+
**Branded:**
|
|
213
|
+
- `Branded<T, B>` - Create branded type
|
|
214
|
+
- `Brand<T, B>` - Shorthand for Branded
|
|
215
|
+
|
|
216
|
+
**Deep:**
|
|
217
|
+
- `DeepPartial<T>` - All properties optional
|
|
218
|
+
- `DeepReadonly<T>` - All properties readonly
|
|
219
|
+
- `DeepRequired<T>` - All properties required
|
|
220
|
+
|
|
221
|
+
**Function:**
|
|
222
|
+
- `MaybePromise<T>` - Sync or async value
|
|
223
|
+
- `AsyncFunction<T>` - Async function type
|
|
224
|
+
- `SyncFunction<T>` - Sync function type
|
|
225
|
+
- `AnyFunction` - Any function type
|
|
226
|
+
|
|
227
|
+
**JSON:**
|
|
228
|
+
- `JsonPrimitive` - string | number | boolean | null
|
|
229
|
+
- `JsonArray` - JsonValue[]
|
|
230
|
+
- `JsonObject` - { [key: string]: JsonValue }
|
|
231
|
+
- `JsonValue` - Any valid JSON value
|
|
232
|
+
|
|
233
|
+
**Object:**
|
|
234
|
+
- `Prettify<T>` - Flatten type for IDE
|
|
235
|
+
- `StrictOmit<T, K>` - Omit with key validation
|
|
236
|
+
- `StrictPick<T, K>` - Pick with key validation
|
|
237
|
+
- `NonEmptyArray<T>` - Array with ≥1 element
|
|
238
|
+
- `Nullable<T>` - T | null
|
|
239
|
+
- `Optional<T>` - T | undefined
|
|
240
|
+
|
|
241
|
+
### Events
|
|
242
|
+
|
|
243
|
+
- `EventMap` - Base event map interface
|
|
244
|
+
- `EventHandler<TEvents, K>` - Event handler type
|
|
245
|
+
- `TypedEventEmitter<TEvents>` - Event emitter interface
|
|
246
|
+
- `Unsubscribe` - Cleanup function () => void
|
|
247
|
+
|
|
248
|
+
### Constants
|
|
249
|
+
|
|
250
|
+
- `OXOG_PLUGIN` - Well-known symbol for plugins
|
|
251
|
+
- `OXOG_KERNEL` - Well-known symbol for kernels
|
|
252
|
+
- `OXOG_VERSION` - Package version string
|
|
253
|
+
- `ErrorCodes` - Standard error codes
|
|
254
|
+
|
|
255
|
+
## Examples
|
|
256
|
+
|
|
257
|
+
The package includes 15 comprehensive examples:
|
|
258
|
+
|
|
259
|
+
1. **Basic Plugin** - Creating and using plugins
|
|
260
|
+
2. **Result Type** - Functional error handling
|
|
261
|
+
3. **Error Handling** - Error classes and patterns
|
|
262
|
+
4. **Type Guards** - Runtime type checking
|
|
263
|
+
5. **Branded Types** - Type-safe identifiers
|
|
264
|
+
6. **Deep Utilities** - Nested type transformations
|
|
265
|
+
7. **Event Types** - Type-safe events
|
|
266
|
+
8. **JSON Types** - JSON-compatible types
|
|
267
|
+
9. **MaybePromise** - Sync/async flexibility
|
|
268
|
+
10. **Kernel Interface** - Micro-kernel usage
|
|
269
|
+
11. **Plugin Options** - Configuration and logging
|
|
270
|
+
12. **Strict Pick/Omit** - Type-safe property selection
|
|
271
|
+
13. **Non Empty Array** - Guaranteed non-empty arrays
|
|
272
|
+
14. **Typed Emitter** - Event emitter implementation
|
|
273
|
+
15. **Real World** - Full integration example
|
|
274
|
+
|
|
275
|
+
Run examples:
|
|
276
|
+
```bash
|
|
277
|
+
npm run example:01-basic-plugin
|
|
278
|
+
npm run example:02-result-type
|
|
279
|
+
# ... and more
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Technical Details
|
|
283
|
+
|
|
284
|
+
### Requirements
|
|
285
|
+
|
|
286
|
+
- Node.js >= 18
|
|
287
|
+
- TypeScript >= 5.0
|
|
288
|
+
- Strict mode enabled
|
|
289
|
+
|
|
290
|
+
### Build
|
|
291
|
+
|
|
292
|
+
- ES2022 target
|
|
293
|
+
- ESM + CJS module formats
|
|
294
|
+
- TypeScript declaration files
|
|
295
|
+
- Tree-shaking enabled
|
|
296
|
+
- < 3KB gzipped
|
|
297
|
+
|
|
298
|
+
### Testing
|
|
299
|
+
|
|
300
|
+
- 100% code coverage
|
|
301
|
+
- Unit tests for all modules
|
|
302
|
+
- Integration tests
|
|
303
|
+
- Vitest test runner
|
|
304
|
+
|
|
305
|
+
### Bundle Size
|
|
306
|
+
|
|
307
|
+
- Core: < 2KB gzipped
|
|
308
|
+
- All (ESM + CJS + DTS): < 3KB gzipped
|
|
309
|
+
|
|
310
|
+
## Architecture
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
┌─────────────────────────────────────┐
|
|
314
|
+
│ User Application │
|
|
315
|
+
├─────────────────────────────────────┤
|
|
316
|
+
│ Plugin Registry Interface │
|
|
317
|
+
│ use() · register() · unregister() │
|
|
318
|
+
├──────┬──────┬──────┬────────────────┤
|
|
319
|
+
│ Core │ Opt. │Import│ Community │
|
|
320
|
+
│ │ │ │ │
|
|
321
|
+
├──────┴──────┴──────┴────────────────┤
|
|
322
|
+
│ Micro Kernel │
|
|
323
|
+
│ Event Bus · Lifecycle · Errors │
|
|
324
|
+
└─────────────────────────────────────┘
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Error Codes
|
|
328
|
+
|
|
329
|
+
Standard error codes for consistent handling:
|
|
330
|
+
|
|
331
|
+
- `UNKNOWN` - Unknown error
|
|
332
|
+
- `VALIDATION_ERROR` - Validation failed
|
|
333
|
+
- `PLUGIN_ERROR` - Plugin-related error
|
|
334
|
+
- `NOT_FOUND` - Resource not found
|
|
335
|
+
- `TIMEOUT` - Operation timed out
|
|
336
|
+
- `DEPENDENCY_ERROR` - Dependency issue
|
|
337
|
+
|
|
338
|
+
## Use Cases
|
|
339
|
+
|
|
340
|
+
### Functional Error Handling
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
function fetchUser(id: string): Result<User, string> {
|
|
344
|
+
if (!id) return Err('ID required');
|
|
345
|
+
return Ok({ id, name: 'John' });
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Plugin Architecture
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
const logger: Plugin = {
|
|
353
|
+
name: 'logger',
|
|
354
|
+
version: '1.0.0',
|
|
355
|
+
install(kernel) {
|
|
356
|
+
kernel.on('log', (message) => console.log(message));
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Type-Safe APIs
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
type UserId = Branded<string, 'UserId'>;
|
|
365
|
+
|
|
366
|
+
interface UserAPI {
|
|
367
|
+
getUser(id: UserId): Promise<User>;
|
|
368
|
+
createUser(data: StrictOmit<User, 'id'>): Promise<UserId>;
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Event-Driven Architecture
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
interface AppEvents extends EventMap {
|
|
376
|
+
'user:login': { userId: string };
|
|
377
|
+
'order:placed': { orderId: string; amount: number };
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Ecosystem
|
|
382
|
+
|
|
383
|
+
All @oxog packages depend on `@oxog/types` for consistency:
|
|
384
|
+
|
|
385
|
+
- `@oxog/core` - Core micro-kernel implementation
|
|
386
|
+
- `@oxog/cli` - Command-line tools
|
|
387
|
+
- `@oxog/utils` - Utility functions
|
|
388
|
+
|
|
389
|
+
## Contributing
|
|
390
|
+
|
|
391
|
+
Contributions welcome! Please read our contributing guidelines.
|
|
392
|
+
|
|
393
|
+
## License
|
|
394
|
+
|
|
395
|
+
MIT License - see LICENSE file for details.
|
|
396
|
+
|
|
397
|
+
## Author
|
|
398
|
+
|
|
399
|
+
**Ersin Koç**
|
|
400
|
+
|
|
401
|
+
- GitHub: [@ersinkoc](https://github.com/ersinkoc)
|
|
402
|
+
- Website: [https://types.oxog.dev](https://types.oxog.dev)
|
|
403
|
+
|
|
404
|
+
## Links
|
|
405
|
+
|
|
406
|
+
- [Documentation](https://types.oxog.dev)
|
|
407
|
+
- [GitHub](https://github.com/ersinkoc/types)
|
|
408
|
+
- [npm](https://www.npmjs.com/package/@oxog/types)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var l=class{constructor(e){this.value=e;}ok=true;error=void 0;map(e){return E(e(this.value))}mapErr(e){return this}match(e){return e.ok(this.value)}unwrap(){return this.value}unwrapOr(e){return this.value}unwrapOrElse(e){return this.value}},p=class{constructor(e){this.error=e;}ok=false;value=void 0;map(e){return this}mapErr(e){return T(e(this.error))}match(e){return e.err(this.error)}unwrap(){throw new Error(`Cannot unwrap Err: ${String(this.error)}`)}unwrapOr(e){return e}unwrapOrElse(e){return e(this.error)}};function E(r){return new l(r)}function T(r){return new p(r)}var c=(n=>(n.UNKNOWN="UNKNOWN",n.VALIDATION_ERROR="VALIDATION_ERROR",n.PLUGIN_ERROR="PLUGIN_ERROR",n.NOT_FOUND="NOT_FOUND",n.TIMEOUT="TIMEOUT",n.DEPENDENCY_ERROR="DEPENDENCY_ERROR",n))(c||{}),t=class extends Error{constructor(o,u,a){super(o);this.code=u;this.context=a;this.name="OxogError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,new.target);}name},s=class extends t{constructor(o,u){super(o,"VALIDATION_ERROR",u);this.context=u;this.name="ValidationError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,new.target);}name},i=class extends t{constructor(o,u,a){super(o,"PLUGIN_ERROR",a?{pluginName:u,...a}:void 0);this.pluginName=u;this.name="PluginError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace(this,new.target);}name};function d(r){return r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.version=="string"&&typeof r.install=="function"}function m(r){return r!==null&&typeof r=="object"&&typeof r.use=="function"&&typeof r.unregister=="function"&&typeof r.getPlugin=="function"&&typeof r.listPlugins=="function"&&typeof r.hasPlugin=="function"&&typeof r.emit=="function"&&typeof r.on=="function"&&typeof r.getContext=="function"}function R(r){return r instanceof t}function x(r){return r instanceof s}function k(r){return r instanceof i}function f(r){return r!==null&&typeof r=="object"&&typeof r.ok=="boolean"&&("value"in r||"error"in r)}function U(r){return f(r)&&r.ok===true}function w(r){return f(r)&&r.ok===false}var N=Symbol.for("@oxog/plugin"),P=Symbol.for("@oxog/kernel"),b="1.0.0";exports.Err=T;exports.ErrorCodes=c;exports.OXOG_KERNEL=P;exports.OXOG_PLUGIN=N;exports.OXOG_VERSION=b;exports.Ok=E;exports.OxogError=t;exports.PluginError=i;exports.ValidationError=s;exports.isErr=w;exports.isKernel=m;exports.isOk=U;exports.isOxogError=R;exports.isPlugin=d;exports.isPluginError=k;exports.isResult=f;exports.isValidationError=x;//# sourceMappingURL=index.cjs.map
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/result.ts","../src/errors.ts","../src/guards.ts","../src/constants.ts"],"names":["OkImpl","value","fn","Ok","_fn","handlers","_defaultValue","ErrImpl","error","Err","defaultValue","ErrorCodes","OxogError","message","code","context","ValidationError","PluginError","pluginName","isPlugin","isKernel","isOxogError","isValidationError","isPluginError","isResult","isOk","isErr","OXOG_PLUGIN","OXOG_KERNEL","OXOG_VERSION"],"mappings":"aAqHA,IAAMA,CAAAA,CAAN,KAAiC,CAI/B,WAAA,CAA4BC,EAAU,CAAV,IAAA,CAAA,KAAA,CAAAA,EAAW,CAH9B,EAAA,CAAK,IAAA,CACL,MAAQ,MAAA,CAIjB,GAAA,CAAOC,EAAuC,CAC5C,OAAOC,EAAGD,CAAAA,CAAG,IAAA,CAAK,KAAK,CAAC,CAC1B,CAEA,OAAUE,CAAAA,CAAiC,CACzC,OAAO,IACT,CAEA,MAASC,CAAAA,CAAgE,CACvE,OAAOA,CAAAA,CAAS,EAAA,CAAG,IAAA,CAAK,KAAK,CAC/B,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Ac,MAAA,CAAO,GAAA,CAAI,cAAc,CAAA,CAiBvCC,EAAc,MAAA,CAAO,GAAA,CAAI,cAAc,CAAA,CAYvCC,CAAAA,CAAe","file":"index.cjs","sourcesContent":["/**\n * @oxog/types - Result type for functional error handling\n * @version 1.0.0\n * @author Ersin Koç\n */\n\n/**\n * Represents a successful result.\n *\n * Contains a value and provides methods for transforming the value\n * or handling errors. Only available on successful results.\n *\n * @example\n * ```typescript\n * const ok = Ok(42);\n * if (isOk(ok)) {\n * console.log(ok.value); // 42\n * }\n * ```\n */\nexport interface Ok<T> {\n readonly ok: true;\n readonly value: T;\n readonly error?: never;\n\n /** Transform the value if successful */\n map<U>(fn: (value: T) => U): Result<U, never>;\n\n /** Transform the error (no-op for Ok) */\n mapErr<F>(fn: (error: never) => F): Ok<T>;\n\n /** Pattern matching for both cases */\n match<U>(handlers: { ok: (value: T) => U; err: (error: never) => U }): U;\n\n /** Unwrap the value (asserts success) */\n unwrap(): T;\n\n /** Unwrap with default value */\n unwrapOr(defaultValue: T): T;\n\n /** Unwrap using a fallback function */\n unwrapOrElse(fn: () => T): T;\n}\n\n/**\n * Represents a failed result.\n *\n * Contains an error and provides methods for transforming the error\n * or handling success cases. Only available on failed results.\n *\n * @example\n * ```typescript\n * const err = Err('Something went wrong');\n * if (isErr(err)) {\n * console.log(err.error); // 'Something went wrong'\n * }\n * ```\n */\nexport interface Err<E> {\n readonly ok: false;\n readonly value?: never;\n readonly error: E;\n\n /** Transform the value (no-op for Err) */\n map<U>(fn: (value: never) => U): Err<E>;\n\n /** Transform the error if failed */\n mapErr<F>(fn: (error: E) => F): Result<never, F>;\n\n /** Pattern matching for both cases */\n match<U>(handlers: { ok: (value: never) => U; err: (error: E) => U }): U;\n\n /** Unwrap the value (asserts success, throws for Err) */\n unwrap(): never;\n\n /** Unwrap with default value */\n unwrapOr<T>(defaultValue: T): T;\n\n /** Unwrap using a fallback function */\n unwrapOrElse<T>(fn: () => T): T;\n}\n\n/**\n * Result type - either Ok<T> or Err<E>.\n *\n * A type that represents either success (Ok) or failure (Err).\n * This is inspired by Rust's Result type and provides functional\n * error handling without exceptions.\n *\n * @example\n * ```typescript\n * function divide(a: number, b: number): Result<number, string> {\n * if (b === 0) {\n * return Err('Division by zero');\n * }\n * return Ok(a / b);\n * }\n *\n * const result = divide(10, 2);\n *\n * // Pattern matching\n * const message = result.match({\n * ok: (value) => `Result: ${value}`,\n * err: (error) => `Error: ${error}`\n * });\n *\n * // Chaining\n * const doubled = result\n * .map(x => x * 2)\n * .mapErr(e => `Calculation failed: ${e}`);\n * ```\n */\nexport type Result<T, E> = Ok<T> | Err<E>;\n\n/**\n * Internal implementation of Ok result.\n */\nclass OkImpl<T> implements Ok<T> {\n readonly ok = true as const;\n readonly error = undefined as never;\n\n constructor(public readonly value: T) {}\n\n map<U>(fn: (value: T) => U): Result<U, never> {\n return Ok(fn(this.value));\n }\n\n mapErr<F>(_fn: (error: never) => F): Ok<T> {\n return this;\n }\n\n match<U>(handlers: { ok: (value: T) => U; err: (error: never) => U }): U {\n return handlers.ok(this.value);\n }\n\n unwrap(): T {\n return this.value;\n }\n\n unwrapOr(_defaultValue: T): T {\n return this.value;\n }\n\n unwrapOrElse(_fn: () => T): T {\n return this.value;\n }\n}\n\n/**\n * Internal implementation of Err result.\n */\nclass ErrImpl<E> implements Err<E> {\n readonly ok = false as const;\n readonly value = undefined as never;\n\n constructor(public readonly error: E) {}\n\n map<U>(_fn: (value: never) => U): Err<E> {\n return this;\n }\n\n mapErr<F>(fn: (error: E) => F): Result<never, F> {\n return Err(fn(this.error));\n }\n\n match<U>(handlers: { ok: (value: never) => U; err: (error: E) => U }): U {\n return handlers.err(this.error);\n }\n\n unwrap(): never {\n throw new Error(`Cannot unwrap Err: ${String(this.error)}`);\n }\n\n unwrapOr<T>(defaultValue: T): T {\n return defaultValue;\n }\n\n unwrapOrElse<T>(fn: (error: E) => T): T {\n return fn(this.error);\n }\n}\n\n/**\n * Creates a successful Result containing a value.\n *\n * @example\n * ```typescript\n * const ok = Ok(42);\n * const okStr = Ok('hello');\n * const okObj = Ok({ id: 1 });\n * ```\n *\n * @param value - The value to wrap\n * @returns An Ok result containing the value\n */\nexport function Ok<T>(value: T): Ok<T> {\n return new OkImpl(value);\n}\n\n/**\n * Creates a failed Result containing an error.\n *\n * @example\n * ```typescript\n * const err = Err('Something went wrong');\n * const errNum = Err(404);\n * const errObj = Err({ code: 'NOT_FOUND' });\n * ```\n *\n * @param error - The error to wrap\n * @returns An Err result containing the error\n */\nexport function Err<E>(error: E): Err<E> {\n return new ErrImpl(error);\n}\n","/**\n * @oxog/types - Standardized error classes\n * @version 1.0.0\n * @author Ersin Koç\n */\n\n/**\n * Standard error codes for @oxog ecosystem.\n *\n * These codes provide programmatic ways to identify and handle errors.\n */\nexport enum ErrorCodes {\n /** Unknown error */\n UNKNOWN = 'UNKNOWN',\n\n /** Validation error */\n VALIDATION_ERROR = 'VALIDATION_ERROR',\n\n /** Plugin-related error */\n PLUGIN_ERROR = 'PLUGIN_ERROR',\n\n /** Resource not found */\n NOT_FOUND = 'NOT_FOUND',\n\n /** Operation timed out */\n TIMEOUT = 'TIMEOUT',\n\n /** Dependency error */\n DEPENDENCY_ERROR = 'DEPENDENCY_ERROR',\n}\n\n/**\n * Base error class for all @oxog errors.\n *\n * Provides structured error information with code, message, and context.\n * All other @oxog errors inherit from this class.\n *\n * @example\n * ```typescript\n * throw new OxogError(\n * 'Database connection failed',\n * ErrorCodes.DEPENDENCY_ERROR,\n * { host: 'localhost', port: 5432 }\n * );\n * ```\n */\nexport class OxogError extends Error {\n /** Error name */\n public override readonly name: string;\n\n /**\n * Creates a new OxogError.\n *\n * @param message - Human-readable error message\n * @param code - Error code for programmatic handling\n * @param context - Additional context about the error\n */\n constructor(\n message: string,\n public readonly code: string,\n public readonly context?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'OxogError';\n Object.setPrototypeOf(this, new.target.prototype);\n Error.captureStackTrace(this, new.target);\n }\n}\n\n/**\n * Error thrown when validation fails.\n *\n * Used for input validation, schema validation, and type checking errors.\n *\n * @example\n * ```typescript\n * throw new ValidationError(\n * 'Invalid email format',\n * { field: 'email', value: 'not-an-email' }\n * );\n * ```\n */\nexport class ValidationError extends OxogError {\n /** Error name */\n public override readonly name: string;\n\n /**\n * Creates a new ValidationError.\n *\n * @param message - Human-readable error message\n * @param context - Additional context about the validation failure\n */\n constructor(\n message: string,\n public override readonly context?: Record<string, unknown>\n ) {\n super(message, ErrorCodes.VALIDATION_ERROR, context);\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, new.target.prototype);\n Error.captureStackTrace(this, new.target);\n }\n}\n\n/**\n * Error thrown when a plugin operation fails.\n *\n * Used for plugin initialization, dependency resolution, and runtime errors\n * specific to plugins.\n *\n * @example\n * ```typescript\n * throw new PluginError(\n * 'Failed to initialize cache plugin',\n * 'cache-plugin',\n * { reason: 'Redis connection failed' }\n * );\n * ```\n */\nexport class PluginError extends OxogError {\n /** Error name */\n public override readonly name: string;\n\n /**\n * Creates a new PluginError.\n *\n * @param message - Human-readable error message\n * @param pluginName - Name of the plugin that caused the error\n * @param context - Additional context about the plugin error\n */\n constructor(\n message: string,\n public readonly pluginName: string,\n context?: Record<string, unknown>\n ) {\n super(message, ErrorCodes.PLUGIN_ERROR, context ? { pluginName, ...context } : undefined);\n this.name = 'PluginError';\n Object.setPrototypeOf(this, new.target.prototype);\n Error.captureStackTrace(this, new.target);\n }\n}\n","/**\n * @oxog/types - Type guard functions\n * @version 1.0.0\n * @author Ersin Koç\n */\n\nimport type { Plugin, Kernel } from './plugin.js';\nimport type { Result, Ok, Err } from './result.js';\nimport { OxogError, ValidationError, PluginError } from './errors.js';\n\n/**\n * Type guard for Plugin.\n *\n * Checks if a value is a valid Plugin instance.\n *\n * @example\n * ```typescript\n * const plugin = { name: 'test', version: '1.0.0', install: () => {} };\n * if (isPlugin(plugin)) {\n * console.log(plugin.name); // TypeScript knows it's a Plugin\n * }\n * ```\n */\nexport function isPlugin<T>(value: unknown): value is Plugin<T> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as Plugin<T>).name === 'string' &&\n typeof (value as Plugin<T>).version === 'string' &&\n typeof (value as Plugin<T>).install === 'function'\n );\n}\n\n/**\n * Type guard for Kernel.\n *\n * Checks if a value is a valid Kernel instance.\n *\n * @example\n * ```typescript\n * const kernel = {\n * use: (plugin) => kernel,\n * unregister: () => true,\n * getPlugin: () => undefined,\n * listPlugins: () => [],\n * hasPlugin: () => false,\n * emit: () => {},\n * on: () => () => {},\n * getContext: () => null\n * };\n * if (isKernel(kernel)) {\n * console.log(kernel.listPlugins()); // TypeScript knows it's a Kernel\n * }\n * ```\n */\nexport function isKernel<T>(value: unknown): value is Kernel<T> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as Kernel<T>).use === 'function' &&\n typeof (value as Kernel<T>).unregister === 'function' &&\n typeof (value as Kernel<T>).getPlugin === 'function' &&\n typeof (value as Kernel<T>).listPlugins === 'function' &&\n typeof (value as Kernel<T>).hasPlugin === 'function' &&\n typeof (value as Kernel<T>).emit === 'function' &&\n typeof (value as Kernel<T>).on === 'function' &&\n typeof (value as Kernel<T>).getContext === 'function'\n );\n}\n\n/**\n * Type guard for OxogError.\n *\n * Checks if a value is an OxogError instance.\n *\n * @example\n * ```typescript\n * const error = new OxogError('Test', 'TEST');\n * if (isOxogError(error)) {\n * console.log(error.code); // TypeScript knows it's an OxogError\n * }\n * ```\n */\nexport function isOxogError(value: unknown): value is OxogError {\n return value instanceof OxogError;\n}\n\n/**\n * Type guard for ValidationError.\n *\n * Checks if a value is a ValidationError instance.\n *\n * @example\n * ```typescript\n * const error = new ValidationError('Invalid', { field: 'test' });\n * if (isValidationError(error)) {\n * console.log(error.context); // TypeScript knows it's a ValidationError\n * }\n * ```\n */\nexport function isValidationError(value: unknown): value is ValidationError {\n return value instanceof ValidationError;\n}\n\n/**\n * Type guard for PluginError.\n *\n * Checks if a value is a PluginError instance.\n *\n * @example\n * ```typescript\n * const error = new PluginError('Plugin failed', 'my-plugin');\n * if (isPluginError(error)) {\n * console.log(error.pluginName); // TypeScript knows it's a PluginError\n * }\n * ```\n */\nexport function isPluginError(value: unknown): value is PluginError {\n return value instanceof PluginError;\n}\n\n/**\n * Type guard for Result.\n *\n * Checks if a value is a Result instance (either Ok or Err).\n *\n * @example\n * ```typescript\n * const result = Ok(42);\n * if (isResult(result)) {\n * // result is Ok<number, unknown>\n * }\n *\n * const err = Err('error');\n * if (isResult(err)) {\n * // err is Err<unknown, string>\n * }\n * ```\n */\nexport function isResult<T, E>(value: unknown): value is Result<T, E> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as Result<T, E>).ok === 'boolean' &&\n (('value' in (value as object)) || ('error' in (value as object)))\n );\n}\n\n/**\n * Type guard for Ok result.\n *\n * Checks if a Result is an Ok (success) instance.\n *\n * @example\n * ```typescript\n * const ok = Ok(42);\n * if (isOk(ok)) {\n * console.log(ok.value); // TypeScript knows it's Ok\n * }\n * ```\n */\nexport function isOk<T>(value: Result<T, unknown>): value is Ok<T> {\n return isResult(value) && value.ok === true;\n}\n\n/**\n * Type guard for Err result.\n *\n * Checks if a Result is an Err (failure) instance.\n *\n * @example\n * ```typescript\n * const err = Err('error');\n * if (isErr(err)) {\n * console.log(err.error); // TypeScript knows it's Err\n * }\n * ```\n */\nexport function isErr<E>(value: Result<unknown, E>): value is Err<E> {\n return isResult(value) && value.ok === false;\n}\n","/**\n * @oxog/types - Well-known symbols and constants\n * @version 1.0.0\n * @author Ersin Koç\n */\n\nimport { ErrorCodes } from './errors.js';\n\n/**\n * Well-known symbol for @oxog plugins.\n *\n * Use this symbol to mark objects as @oxog plugins.\n * This enables runtime detection and validation.\n *\n * @example\n * ```typescript\n * const myPlugin = {\n * [OXOG_PLUGIN]: true,\n * name: 'my-plugin',\n * version: '1.0.0',\n * install: () => {}\n * };\n * ```\n */\nexport const OXOG_PLUGIN = Symbol.for('@oxog/plugin');\n\n/**\n * Well-known symbol for @oxog kernels.\n *\n * Use this symbol to mark objects as @oxog kernels.\n * This enables runtime detection and validation.\n *\n * @example\n * ```typescript\n * const myKernel = {\n * [OXOG_KERNEL]: true,\n * use: (plugin) => kernel,\n * // ... other methods\n * };\n * ```\n */\nexport const OXOG_KERNEL = Symbol.for('@oxog/kernel');\n\n/**\n * @oxog/types package version.\n *\n * Current version of the @oxog/types package.\n *\n * @example\n * ```typescript\n * console.log(`Using @oxog/types v${OXOG_VERSION}`);\n * ```\n */\nexport const OXOG_VERSION = '1.0.0';\n\n/**\n * Standard error codes for @oxog ecosystem.\n *\n * Re-exported from errors module for convenience.\n *\n * @example\n * ```typescript\n * throw new OxogError('Not found', ErrorCodes.NOT_FOUND);\n * ```\n */\nexport { ErrorCodes };\n"]}
|