uni-types 1.3.0 → 1.5.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/README.md +337 -1
- package/dist/index.d.cts +7208 -1934
- package/dist/index.d.mts +7208 -1934
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ A comprehensive collection of type helpers for TypeScript development
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
|
-
- 🎯 **
|
|
21
|
+
- 🎯 **500+ Type Utilities** - Comprehensive type helpers for every use case
|
|
22
22
|
- 🔒 **Type Safe** - Full TypeScript support with strict type checking
|
|
23
23
|
- 📦 **Zero Dependencies** - Lightweight and tree-shakeable
|
|
24
24
|
- 🚀 **TypeScript 5.x** - Built with the latest TypeScript features
|
|
@@ -368,6 +368,342 @@ type Result = If<true, 'success', 'error'> // 'success'
|
|
|
368
368
|
| `SvelteStore<T>` | Svelte store type |
|
|
369
369
|
| `SvelteAction<Element, Params>` | Svelte action type |
|
|
370
370
|
|
|
371
|
+
### Type-Level Algorithms *(v1.4.0)*
|
|
372
|
+
|
|
373
|
+
| Type | Description |
|
|
374
|
+
|------|-------------|
|
|
375
|
+
| `Sort<T, Order>` | Sort tuple of numbers |
|
|
376
|
+
| `QuickSort<T>` | QuickSort implementation |
|
|
377
|
+
| `MergeSort<T>` | MergeSort implementation |
|
|
378
|
+
| `Find<T, P>` | Find first matching element |
|
|
379
|
+
| `FindIndex<T, P>` | Find index of matching element |
|
|
380
|
+
| `Includes<T, U>` | Check if tuple includes element |
|
|
381
|
+
| `IndexOf<T, U>` | Get index of element |
|
|
382
|
+
| `GCD<A, B>` | Greatest Common Divisor |
|
|
383
|
+
| `LCM<A, B>` | Least Common Multiple |
|
|
384
|
+
| `Factorial<N>` | Factorial of number |
|
|
385
|
+
| `Fibonacci<N>` | Fibonacci number |
|
|
386
|
+
| `IsPrime<N>` | Check if number is prime |
|
|
387
|
+
| `LongestCommonPrefix<T>` | Longest common prefix of strings |
|
|
388
|
+
| `LevenshteinDistance<A, B>` | Edit distance between strings |
|
|
389
|
+
| `Reverse<T>` | Reverse a tuple |
|
|
390
|
+
| `Unique<T>` | Remove duplicates from tuple |
|
|
391
|
+
| `Flatten<T>` | Flatten nested tuples |
|
|
392
|
+
|
|
393
|
+
### Type-Level Parsers *(v1.4.0)*
|
|
394
|
+
|
|
395
|
+
| Type | Description |
|
|
396
|
+
|------|-------------|
|
|
397
|
+
| `ParseJSON<S>` | Parse JSON string to type |
|
|
398
|
+
| `StringifyJSON<T>` | Stringify type to JSON |
|
|
399
|
+
| `IsValidJSON<S>` | Check if string is valid JSON |
|
|
400
|
+
| `ParseURL<S>` | Parse URL string |
|
|
401
|
+
| `QueryParams<S>` | Parse query string |
|
|
402
|
+
| `PathParams<Pattern, Path>` | Extract path params |
|
|
403
|
+
| `ParseCSV<S>` | Parse CSV string |
|
|
404
|
+
| `StringifyCSV<T>` | Stringify records to CSV |
|
|
405
|
+
| `ParseExpression<S>` | Parse arithmetic expression |
|
|
406
|
+
| `EvaluateExpression<T>` | Evaluate parsed expression |
|
|
407
|
+
|
|
408
|
+
### Type-Level State Machines *(v1.4.0)*
|
|
409
|
+
|
|
410
|
+
| Type | Description |
|
|
411
|
+
|------|-------------|
|
|
412
|
+
| `StateMachine<T>` | State machine definition |
|
|
413
|
+
| `State<S, Data>` | State definition |
|
|
414
|
+
| `Transition<E, From, To>` | Transition definition |
|
|
415
|
+
| `CurrentState<T>` | Get current state |
|
|
416
|
+
| `NextState<T, E>` | Get next state after event |
|
|
417
|
+
| `ValidTransitions<T>` | Get valid transitions |
|
|
418
|
+
| `StateHistory<T>` | State history type |
|
|
419
|
+
| `CanTransition<T, E>` | Check if transition is valid |
|
|
420
|
+
| `IsTerminal<T>` | Check if state is terminal |
|
|
421
|
+
|
|
422
|
+
### Type-Level Data Structures *(v1.4.0)*
|
|
423
|
+
|
|
424
|
+
| Type | Description |
|
|
425
|
+
|------|-------------|
|
|
426
|
+
| `Tree<T>` | Tree type |
|
|
427
|
+
| `TreeNode<T>` | Tree node type |
|
|
428
|
+
| `TreePath<T, V>` | Path to value in tree |
|
|
429
|
+
| `TreeDepth<T>` | Maximum depth of tree |
|
|
430
|
+
| `TreeLeaves<T>` | All leaf values |
|
|
431
|
+
| `TreeFlatten<T>` | Flatten tree to array |
|
|
432
|
+
| `Graph<Adjacency>` | Graph type (adjacency list) |
|
|
433
|
+
| `GraphNode<T, Edges>` | Graph node type |
|
|
434
|
+
| `GraphEdge<From, To>` | Graph edge type |
|
|
435
|
+
| `GraphPath<A, From, To>` | Path between nodes |
|
|
436
|
+
| `GraphHasCycle<A>` | Check for cycles |
|
|
437
|
+
| `LinkedList<T>` | Linked list type |
|
|
438
|
+
| `ListNode<T>` | List node type |
|
|
439
|
+
| `ListHead<T>` | Head of list |
|
|
440
|
+
| `ListTail<T>` | Tail of list |
|
|
441
|
+
| `Stack<T>` | Stack type (LIFO) |
|
|
442
|
+
| `Queue<T>` | Queue type (FIFO) |
|
|
443
|
+
| `Push<S, V>` | Push onto stack |
|
|
444
|
+
| `Pop<S>` | Pop from stack |
|
|
445
|
+
|
|
446
|
+
### Type-Level HTTP & API *(v1.4.0)*
|
|
447
|
+
|
|
448
|
+
| Type | Description |
|
|
449
|
+
|------|-------------|
|
|
450
|
+
| `HTTPMethod` | HTTP methods |
|
|
451
|
+
| `HTTPStatus` | HTTP status codes |
|
|
452
|
+
| `HTTPHeaders<T>` | HTTP headers type |
|
|
453
|
+
| `Route<P, M, H>` | Route definition |
|
|
454
|
+
| `RouteParams<P>` | Extract route params |
|
|
455
|
+
| `RouteQuery<Q>` | Route query type |
|
|
456
|
+
| `Router<T>` | Router type |
|
|
457
|
+
| `APIEndpoint<T>` | API endpoint type |
|
|
458
|
+
| `APIRequest<T>` | API request type |
|
|
459
|
+
| `APIResponse<T>` | API response type |
|
|
460
|
+
| `APIError<T>` | API error type |
|
|
461
|
+
| `Middleware<C>` | Middleware type |
|
|
462
|
+
| `Context<C>` | Request context |
|
|
463
|
+
| `ComposeMiddleware<M>` | Compose middleware chain |
|
|
464
|
+
|
|
465
|
+
### Type-Level Database *(v1.4.0)*
|
|
466
|
+
|
|
467
|
+
| Type | Description |
|
|
468
|
+
|------|-------------|
|
|
469
|
+
| `SQLType<T>` | TypeScript to SQL type mapping |
|
|
470
|
+
| `CreateTable<T>` | CREATE TABLE type |
|
|
471
|
+
| `SelectQuery<T, F>` | SELECT query type |
|
|
472
|
+
| `WhereClause<T>` | WHERE clause type |
|
|
473
|
+
| `JoinQuery<T, U>` | JOIN query type |
|
|
474
|
+
| `Migration<T>` | Migration type |
|
|
475
|
+
| `MigrationUp<T>` | Up migration |
|
|
476
|
+
| `MigrationDown<T>` | Down migration |
|
|
477
|
+
| `QueryBuilder<T>` | Query builder type |
|
|
478
|
+
| `WhereBuilder<T>` | WHERE builder type |
|
|
479
|
+
| `Index<T>` | Index type |
|
|
480
|
+
| `UniqueIndex<T>` | Unique index type |
|
|
481
|
+
| `CompositeIndex<T, K>` | Composite index type |
|
|
482
|
+
|
|
483
|
+
### Type-Level Concurrency *(v1.4.0)*
|
|
484
|
+
|
|
485
|
+
| Type | Description |
|
|
486
|
+
|------|-------------|
|
|
487
|
+
| `Task<T>` | Task type |
|
|
488
|
+
| `TaskResult<T>` | Task result type |
|
|
489
|
+
| `TaskError<T>` | Task error type |
|
|
490
|
+
| `TaskStatus` | Task status type |
|
|
491
|
+
| `Pipeline<I, O, S>` | Pipeline type |
|
|
492
|
+
| `PipelineStage<N, I, O>` | Pipeline stage type |
|
|
493
|
+
| `Scheduler<T>` | Scheduler type |
|
|
494
|
+
| `Worker<I, O>` | Worker type |
|
|
495
|
+
| `WorkerPool<I, O>` | Worker pool type |
|
|
496
|
+
| `RateLimiter<T>` | Rate limiter type |
|
|
497
|
+
| `Throttle<T>` | Throttle type |
|
|
498
|
+
| `Debounce<T>` | Debounce type |
|
|
499
|
+
|
|
500
|
+
### Type-Level Interop *(v1.4.0)*
|
|
501
|
+
|
|
502
|
+
| Type | Description |
|
|
503
|
+
|------|-------------|
|
|
504
|
+
| `ToTypeFest<T>` | Convert to type-fest format |
|
|
505
|
+
| `FromTypeFest<T>` | Convert from type-fest format |
|
|
506
|
+
| `ToTsToolbelt<T>` | Convert to ts-toolbelt format |
|
|
507
|
+
| `FromTsToolbelt<T>` | Convert from ts-toolbelt format |
|
|
508
|
+
| `ToUtilityTypes<T>` | Convert to utility-types format |
|
|
509
|
+
| `FromUtilityTypes<T>` | Convert from utility-types format |
|
|
510
|
+
| `ConvertTo<T, Format>` | Convert to format |
|
|
511
|
+
| `ConvertFrom<T, Format>` | Convert from format |
|
|
512
|
+
| `IsCompatible<T, U>` | Check type compatibility |
|
|
513
|
+
| `CompatibleWith<T, Libs>` | Check library compatibility |
|
|
514
|
+
|
|
515
|
+
### Type-Level Testing *(v1.4.0)*
|
|
516
|
+
|
|
517
|
+
| Type | Description |
|
|
518
|
+
|------|-------------|
|
|
519
|
+
| `ExpectTrue<T>` | Expect type to be true |
|
|
520
|
+
| `ExpectFalse<T>` | Expect type to be false |
|
|
521
|
+
| `ExpectEqual<T, U>` | Expect types to be equal |
|
|
522
|
+
| `ExpectExtends<T, U>` | Expect T extends U |
|
|
523
|
+
| `TypeTest<Name, Test>` | Type test definition |
|
|
524
|
+
| `TypeTestSuite<T>` | Test suite type |
|
|
525
|
+
| `TypeTestResult` | Test result type |
|
|
526
|
+
| `TypeCoverage<T>` | Type coverage analysis |
|
|
527
|
+
| `TypeComplexity<T>` | Type complexity analysis |
|
|
528
|
+
| `TypeInfo<T>` | Type information |
|
|
529
|
+
| `InspectType<T>` | Inspect type details |
|
|
530
|
+
|
|
531
|
+
### Authorization & Permissions *(v1.5.0)*
|
|
532
|
+
|
|
533
|
+
| Type | Description |
|
|
534
|
+
|------|-------------|
|
|
535
|
+
| `Permission<T>` | Permission definition |
|
|
536
|
+
| `PermissionSet<T>` | Set of permissions |
|
|
537
|
+
| `Role<T>` | Role definition |
|
|
538
|
+
| `RoleSet<T>` | Set of roles |
|
|
539
|
+
| `Policy` | Policy for ABAC |
|
|
540
|
+
| `PolicyRule<T>` | Policy rule |
|
|
541
|
+
| `PolicyEffect` | Allow or deny |
|
|
542
|
+
| `RBAC<R, P>` | Role-Based Access Control |
|
|
543
|
+
| `ABAC<T>` | Attribute-Based Access Control |
|
|
544
|
+
| `ACL` | Access Control List |
|
|
545
|
+
| `AccessControl<T>` | Access control interface |
|
|
546
|
+
| `Resource<T>` | Resource for authorization |
|
|
547
|
+
| `Action` | Action type (create, read, update, delete, etc.) |
|
|
548
|
+
| `AuthorizationProvider<T>` | Authorization provider |
|
|
549
|
+
|
|
550
|
+
### Caching Strategies *(v1.5.0)*
|
|
551
|
+
|
|
552
|
+
| Type | Description |
|
|
553
|
+
|------|-------------|
|
|
554
|
+
| `Cache<T>` | Cache interface |
|
|
555
|
+
| `CacheEntry<T>` | Cache entry |
|
|
556
|
+
| `CacheOptions` | Cache options (TTL, tags) |
|
|
557
|
+
| `CacheStats` | Cache statistics |
|
|
558
|
+
| `LRUCache<T>` | LRU Cache |
|
|
559
|
+
| `LFUCache<T>` | LFU Cache |
|
|
560
|
+
| `TTLCache<T>` | TTL Cache |
|
|
561
|
+
| `FIFOCache<T>` | FIFO Cache |
|
|
562
|
+
| `ARCCache<T>` | Adaptive Replacement Cache |
|
|
563
|
+
| `DistributedCache<T>` | Distributed cache |
|
|
564
|
+
| `CacheAside<T>` | Cache-aside pattern |
|
|
565
|
+
| `ReadThroughCache<T>` | Read-through pattern |
|
|
566
|
+
| `WriteThroughCache<T>` | Write-through pattern |
|
|
567
|
+
| `WriteBehindCache<T>` | Write-behind pattern |
|
|
568
|
+
|
|
569
|
+
### Configuration Management *(v1.5.0)*
|
|
570
|
+
|
|
571
|
+
| Type | Description |
|
|
572
|
+
|------|-------------|
|
|
573
|
+
| `Config<T>` | Configuration type |
|
|
574
|
+
| `ConfigField<T>` | Config field definition |
|
|
575
|
+
| `ConfigLoader<T>` | Config loader interface |
|
|
576
|
+
| `ConfigSchema<T>` | Config schema |
|
|
577
|
+
| `EnvConfig` | Environment config |
|
|
578
|
+
| `EnvMapping` | Env var mapping |
|
|
579
|
+
| `FeatureFlag` | Feature flag |
|
|
580
|
+
| `FeatureFlagConfig` | Feature flag config |
|
|
581
|
+
| `FeatureFlags<T>` | Feature flags collection |
|
|
582
|
+
| `RemoteConfigProvider<T>` | Remote config provider |
|
|
583
|
+
| `Secret` | Secret value |
|
|
584
|
+
| `SecretProvider` | Secret provider |
|
|
585
|
+
|
|
586
|
+
### Event-Driven Architecture *(v1.5.0)*
|
|
587
|
+
|
|
588
|
+
| Type | Description |
|
|
589
|
+
|------|-------------|
|
|
590
|
+
| `EventBus<T>` | Event bus interface |
|
|
591
|
+
| `EventStream<T>` | Event stream |
|
|
592
|
+
| `Command<T>` | Command for CQRS |
|
|
593
|
+
| `CommandBus<T>` | Command bus |
|
|
594
|
+
| `CommandHandler<T, R>` | Command handler |
|
|
595
|
+
| `Query<T>` | Query for CQRS |
|
|
596
|
+
| `QueryBus<T>` | Query bus |
|
|
597
|
+
| `QueryHandler<T, R>` | Query handler |
|
|
598
|
+
| `Saga<T>` | Saga orchestrator |
|
|
599
|
+
| `SagaStep<T>` | Saga step |
|
|
600
|
+
| `MessageQueue<T>` | Message queue |
|
|
601
|
+
| `EventStore<T>` | Event store |
|
|
602
|
+
| `DeadLetterQueue<T>` | Dead letter queue |
|
|
603
|
+
|
|
604
|
+
### GraphQL Integration *(v1.5.0)*
|
|
605
|
+
|
|
606
|
+
| Type | Description |
|
|
607
|
+
|------|-------------|
|
|
608
|
+
| `GraphQLSchema` | GraphQL schema |
|
|
609
|
+
| `GraphQLType` | GraphQL type wrapper |
|
|
610
|
+
| `GraphQLScalar<T>` | Scalar type |
|
|
611
|
+
| `GraphQLEnum<T>` | Enum type |
|
|
612
|
+
| `GraphQLInput<T>` | Input type |
|
|
613
|
+
| `GraphQLObject<T>` | Object type |
|
|
614
|
+
| `GraphQLField<T, A, R>` | Field type |
|
|
615
|
+
| `GraphQLResolver<T, A, R>` | Resolver type |
|
|
616
|
+
| `GraphQLContext<T>` | Context type |
|
|
617
|
+
| `GraphQLResult<T>` | Result wrapper |
|
|
618
|
+
| `GraphQLError` | Error type |
|
|
619
|
+
|
|
620
|
+
### Logging & Observability *(v1.5.0)*
|
|
621
|
+
|
|
622
|
+
| Type | Description |
|
|
623
|
+
|------|-------------|
|
|
624
|
+
| `Logger<T>` | Logger interface |
|
|
625
|
+
| `LogLevel` | Log levels |
|
|
626
|
+
| `LogEntry<T>` | Log entry |
|
|
627
|
+
| `Metric<T>` | Metric type |
|
|
628
|
+
| `Counter<T>` | Counter metric |
|
|
629
|
+
| `Gauge<T>` | Gauge metric |
|
|
630
|
+
| `Histogram` | Histogram metric |
|
|
631
|
+
| `Tracer` | Tracer interface |
|
|
632
|
+
| `Span` | Tracing span |
|
|
633
|
+
| `Trace<T>` | Trace type |
|
|
634
|
+
| `Monitor` | Monitor type |
|
|
635
|
+
| `Alert<T>` | Alert type |
|
|
636
|
+
| `HealthIndicator<T>` | Health indicator |
|
|
637
|
+
| `HealthCheckResult<T>` | Health check result |
|
|
638
|
+
|
|
639
|
+
### Microservices Architecture *(v1.5.0)*
|
|
640
|
+
|
|
641
|
+
| Type | Description |
|
|
642
|
+
|------|-------------|
|
|
643
|
+
| `Microservice<T>` | Microservice type |
|
|
644
|
+
| `ServiceConfig<T>` | Service config |
|
|
645
|
+
| `ServiceRegistry<T>` | Service registry |
|
|
646
|
+
| `ServiceInstance` | Service instance |
|
|
647
|
+
| `ServiceDiscovery<T>` | Service discovery |
|
|
648
|
+
| `CircuitBreaker<T>` | Circuit breaker |
|
|
649
|
+
| `RateLimit` | Rate limiting |
|
|
650
|
+
| `LoadBalancer<T>` | Load balancer |
|
|
651
|
+
| `APIGateway<T>` | API Gateway |
|
|
652
|
+
| `GatewayRoute` | Gateway route |
|
|
653
|
+
| `HealthReport` | Health report |
|
|
654
|
+
|
|
655
|
+
### Validation Rules *(v1.5.0)*
|
|
656
|
+
|
|
657
|
+
| Type | Description |
|
|
658
|
+
|------|-------------|
|
|
659
|
+
| `ValidationRule<T>` | Validation rule |
|
|
660
|
+
| `Validator<T>` | Validator function |
|
|
661
|
+
| `ValidatorResult<T>` | Validator result |
|
|
662
|
+
| `ValidationError` | Validation error |
|
|
663
|
+
| `StringFieldValidator<T>` | String validator |
|
|
664
|
+
| `NumberFieldValidator<T>` | Number validator |
|
|
665
|
+
| `ArrayFieldValidator<T>` | Array validator |
|
|
666
|
+
| `ObjectFieldValidator<T>` | Object validator |
|
|
667
|
+
| `MinLength` | Min length constraint |
|
|
668
|
+
| `MaxLength` | Max length constraint |
|
|
669
|
+
| `MinValue` | Min value constraint |
|
|
670
|
+
| `MaxValue` | Max value constraint |
|
|
671
|
+
| `Pattern` | Regex pattern |
|
|
672
|
+
| `Sanitizer<T>` | Sanitizer function |
|
|
673
|
+
|
|
674
|
+
### WebSocket & Real-Time *(v1.5.0)*
|
|
675
|
+
|
|
676
|
+
| Type | Description |
|
|
677
|
+
|------|-------------|
|
|
678
|
+
| `WebSocketConfig` | WebSocket config |
|
|
679
|
+
| `WebSocketMessage<T>` | WebSocket message |
|
|
680
|
+
| `EventEmitter<T>` | Event emitter |
|
|
681
|
+
| `PubSub<T>` | Pub/Sub interface |
|
|
682
|
+
| `Publisher<T>` | Publisher |
|
|
683
|
+
| `Subscriber<T>` | Subscriber |
|
|
684
|
+
| `RealTimeChannel<T>` | Real-time channel |
|
|
685
|
+
| `RealTimeClient<T>` | Real-time client |
|
|
686
|
+
| `Stream<T>` | Stream interface |
|
|
687
|
+
| `StreamReader<T>` | Stream reader |
|
|
688
|
+
| `StreamWriter<T>` | Stream writer |
|
|
689
|
+
|
|
690
|
+
### Workflow Engine *(v1.5.0)*
|
|
691
|
+
|
|
692
|
+
| Type | Description |
|
|
693
|
+
|------|-------------|
|
|
694
|
+
| `Workflow<T>` | Workflow definition |
|
|
695
|
+
| `WorkflowInstance<T>` | Workflow instance |
|
|
696
|
+
| `WorkflowStep<T>` | Workflow step |
|
|
697
|
+
| `WorkflowTransition<T>` | Workflow transition |
|
|
698
|
+
| `WorkflowExecution<T>` | Workflow execution |
|
|
699
|
+
| `WorkflowHistory<T>` | Workflow history |
|
|
700
|
+
| `WorkflowEngine<T>` | Workflow engine |
|
|
701
|
+
| `RetryPolicy` | Retry policy |
|
|
702
|
+
| `BPMNProcess<T>` | BPMN process |
|
|
703
|
+
| `BPMNTask<T>` | BPMN task |
|
|
704
|
+
| `BPMNGateway<T>` | BPMN gateway |
|
|
705
|
+
| `BPMNEvent<T>` | BPMN event |
|
|
706
|
+
|
|
371
707
|
## Examples
|
|
372
708
|
|
|
373
709
|
```typescript
|