@unieojs/unieo 1.0.0 β 1.2.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 +271 -47
- package/dist/cjs/common/Enum.d.ts +0 -4
- package/dist/cjs/common/Enum.d.ts.map +1 -1
- package/dist/cjs/common/Enum.js +1 -8
- package/dist/cjs/common/Enum.js.map +1 -1
- package/dist/cjs/common/Error/index.d.ts +9 -50
- package/dist/cjs/common/Error/index.d.ts.map +1 -1
- package/dist/cjs/common/Error/index.js +15 -223
- package/dist/cjs/common/Error/index.js.map +1 -1
- package/dist/cjs/core/index.d.ts +1 -0
- package/dist/cjs/core/index.d.ts.map +1 -1
- package/dist/cjs/core/index.js +1 -0
- package/dist/cjs/core/index.js.map +1 -1
- package/dist/cjs/middleware/DefaultFetch.js +1 -1
- package/dist/cjs/middleware/DefaultFetch.js.map +1 -1
- package/dist/cjs/middleware/ErrorFallback.js +1 -1
- package/dist/cjs/middleware/ErrorFallback.js.map +1 -1
- package/dist/cjs/middleware/index.js +2 -2
- package/dist/cjs/middleware/index.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/common/Enum.d.ts +0 -4
- package/dist/esm/common/Enum.d.ts.map +1 -1
- package/dist/esm/common/Enum.js +0 -7
- package/dist/esm/common/Enum.js.map +1 -1
- package/dist/esm/common/Error/index.d.ts +9 -50
- package/dist/esm/common/Error/index.d.ts.map +1 -1
- package/dist/esm/common/Error/index.js +15 -223
- package/dist/esm/common/Error/index.js.map +1 -1
- package/dist/esm/core/index.d.ts +1 -0
- package/dist/esm/core/index.d.ts.map +1 -1
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/middleware/DefaultFetch.js +1 -1
- package/dist/esm/middleware/DefaultFetch.js.map +1 -1
- package/dist/esm/middleware/ErrorFallback.js +1 -1
- package/dist/esm/middleware/ErrorFallback.js.map +1 -1
- package/dist/esm/middleware/index.js +2 -2
- package/dist/esm/middleware/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ Unieo separates routing logic from application code through declarative configur
|
|
|
44
44
|
meta: {
|
|
45
45
|
match: {
|
|
46
46
|
list: [{
|
|
47
|
-
origin: { source: '
|
|
47
|
+
origin: { source: 'cf-ipcountry', sourceType: 'request_header' },
|
|
48
48
|
criteria: { source: 'CN', sourceType: 'literal' },
|
|
49
49
|
operator: 'equal'
|
|
50
50
|
}]
|
|
@@ -137,6 +137,7 @@ addEventListener('fetch', (event: FetchEvent) => {
|
|
|
137
137
|
|
|
138
138
|
## π¨ Real-World Examples
|
|
139
139
|
|
|
140
|
+
|
|
140
141
|
### π API Gateway
|
|
141
142
|
|
|
142
143
|
Perfect for building API gateways that need request routing, authentication, and response transformation:
|
|
@@ -282,9 +283,12 @@ const abTestingRoutes = [
|
|
|
282
283
|
|
|
283
284
|
Route requests based on device characteristics for optimal user experience:
|
|
284
285
|
|
|
285
|
-
- **Match logic**: Uses `sourceType: '
|
|
286
|
+
- **Match logic**: Uses `sourceType: 'request_header'` with `source: 'user-agent'` to detect device type through User-Agent header analysis
|
|
286
287
|
- **Request rewrite**: Adds `x-mobile-optimized: true` header for mobile-specific processing
|
|
287
288
|
|
|
289
|
+
> [!TIP]
|
|
290
|
+
> **Device Detection**: This example demonstrates User-Agent based device detection using regex patterns. For more sophisticated device detection, consider integrating specialized device detection libraries in your custom middleware.
|
|
291
|
+
|
|
288
292
|
```typescript
|
|
289
293
|
const deviceRoutes = [
|
|
290
294
|
{
|
|
@@ -300,9 +304,9 @@ const deviceRoutes = [
|
|
|
300
304
|
match: {
|
|
301
305
|
list: [
|
|
302
306
|
{
|
|
303
|
-
origin: { source: '
|
|
304
|
-
criteria: { source: '
|
|
305
|
-
operator: '
|
|
307
|
+
origin: { source: 'user-agent', sourceType: 'request_header' },
|
|
308
|
+
criteria: { source: 'Mobile|Android|iPhone', sourceType: 'literal' },
|
|
309
|
+
operator: 'regexp'
|
|
306
310
|
}
|
|
307
311
|
]
|
|
308
312
|
},
|
|
@@ -325,9 +329,10 @@ const deviceRoutes = [
|
|
|
325
329
|
|
|
326
330
|
Serve localized content based on user location:
|
|
327
331
|
|
|
328
|
-
- **Match logic**: Uses `sourceType: '
|
|
332
|
+
- **Match logic**: Uses `sourceType: 'request_header'` with `source: 'cf-ipcountry'` to get user's country from Cloudflare's geolocation header
|
|
329
333
|
- **Response rewrite**: Sets `x-privacy-policy: gdpr-compliant` header for EU users
|
|
330
334
|
|
|
335
|
+
|
|
331
336
|
```typescript
|
|
332
337
|
const geoRoutes = [
|
|
333
338
|
{
|
|
@@ -342,11 +347,11 @@ const geoRoutes = [
|
|
|
342
347
|
meta: {
|
|
343
348
|
match: {
|
|
344
349
|
list: [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
+
{
|
|
351
|
+
origin: { source: 'cf-ipcountry', sourceType: 'request_header' },
|
|
352
|
+
criteria: { source: '^(FR|DE|IT|ES|NL|BE|AT|PT|IE|LU|FI|SE|DK|EE|LV|LT|PL|CZ|SK|HU|SI|HR|BG|RO|MT|CY)$', sourceType: 'literal' },
|
|
353
|
+
operator: 'regexp'
|
|
354
|
+
}
|
|
350
355
|
]
|
|
351
356
|
},
|
|
352
357
|
responseRewrites: [
|
|
@@ -518,7 +523,7 @@ const routesWithMiddleware = [
|
|
|
518
523
|
|
|
519
524
|
### π§ Complex Matching Logic
|
|
520
525
|
|
|
521
|
-
|
|
526
|
+
Unieo's Match system supports sophisticated conditional logic through its Value system:
|
|
522
527
|
|
|
523
528
|
```typescript
|
|
524
529
|
const complexRoutes = [
|
|
@@ -535,26 +540,50 @@ const complexRoutes = [
|
|
|
535
540
|
match: {
|
|
536
541
|
list: [
|
|
537
542
|
{
|
|
538
|
-
// Match specific user agent
|
|
543
|
+
// Match specific user agent using regex
|
|
539
544
|
origin: { source: 'user-agent', sourceType: 'request_header' },
|
|
540
545
|
criteria: { source: 'bot|crawler', sourceType: 'literal' },
|
|
541
546
|
operator: 'regexp'
|
|
542
547
|
},
|
|
543
548
|
{
|
|
544
|
-
// Match
|
|
545
|
-
origin: { source: 'hour', sourceType: '
|
|
549
|
+
// Match time range (requires middleware to set header)
|
|
550
|
+
origin: { source: 'x-current-hour', sourceType: 'request_header' },
|
|
546
551
|
criteria: { source: '9', sourceType: 'literal' },
|
|
547
552
|
operator: 'gte'
|
|
548
553
|
},
|
|
549
554
|
{
|
|
550
|
-
// Match
|
|
555
|
+
// Match API paths using prefix matching
|
|
551
556
|
origin: { source: 'path', sourceType: 'url' },
|
|
552
557
|
criteria: { source: '/api/', sourceType: 'literal' },
|
|
553
558
|
operator: 'prefix'
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
// Advanced: Nested value processing
|
|
562
|
+
origin: {
|
|
563
|
+
source: {
|
|
564
|
+
userType: { source: 'x-user-type', sourceType: 'request_header' },
|
|
565
|
+
region: { source: 'cf-ipcountry', sourceType: 'request_header' }
|
|
566
|
+
},
|
|
567
|
+
sourceType: 'value_object'
|
|
568
|
+
},
|
|
569
|
+
criteria: {
|
|
570
|
+
source: { userType: 'premium', region: 'US' },
|
|
571
|
+
sourceType: 'literal'
|
|
572
|
+
},
|
|
573
|
+
operator: 'equal'
|
|
554
574
|
}
|
|
555
575
|
],
|
|
556
576
|
operator: 'and' // All conditions must match
|
|
557
|
-
}
|
|
577
|
+
},
|
|
578
|
+
// Apply custom processing when matched
|
|
579
|
+
requestRewrites: [
|
|
580
|
+
{
|
|
581
|
+
type: 'header',
|
|
582
|
+
field: 'x-route-matched',
|
|
583
|
+
value: { source: 'complex-route', sourceType: 'literal' },
|
|
584
|
+
operation: 'set'
|
|
585
|
+
}
|
|
586
|
+
]
|
|
558
587
|
}
|
|
559
588
|
}
|
|
560
589
|
]
|
|
@@ -562,6 +591,13 @@ const complexRoutes = [
|
|
|
562
591
|
];
|
|
563
592
|
```
|
|
564
593
|
|
|
594
|
+
#### π― Match System Features
|
|
595
|
+
|
|
596
|
+
- **Nested Logic**: Support for complex AND/OR operations
|
|
597
|
+
- **Value Integration**: Dynamic value extraction and comparison
|
|
598
|
+
- **Operator Variety**: Equal, regex, prefix, range, and custom operators
|
|
599
|
+
- **Type Coercion**: Automatic type conversion for comparisons
|
|
600
|
+
|
|
565
601
|
## π Route Configuration Reference
|
|
566
602
|
|
|
567
603
|
### π GroupRouteConfig
|
|
@@ -591,59 +627,247 @@ interface SubRouteConfig {
|
|
|
591
627
|
redirects?: RedirectConfig[]; // Redirect rules
|
|
592
628
|
requestRewrites?: RequestRewriteConfig[]; // Request modifications
|
|
593
629
|
responseRewrites?: ResponseRewriteConfig[]; // Response modifications
|
|
630
|
+
[key: string]: unknown; // Custom meta types via MetaFactory
|
|
594
631
|
};
|
|
595
632
|
args?: Record<string, unknown>; // Processor arguments
|
|
596
633
|
}
|
|
597
634
|
```
|
|
598
635
|
|
|
599
|
-
|
|
636
|
+
### π Meta Layer Architecture
|
|
600
637
|
|
|
601
|
-
|
|
638
|
+
The Meta layer is the heart of Unieo's processing system, utilizing the Factory pattern for dynamic behavior:
|
|
602
639
|
|
|
603
|
-
|
|
640
|
+
#### π MetaFactory System
|
|
604
641
|
|
|
605
642
|
```typescript
|
|
606
|
-
//
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
// Custom matching logic
|
|
612
|
-
return true;
|
|
613
|
-
}
|
|
643
|
+
// Meta types are registered with MetaFactory
|
|
644
|
+
enum MetaType {
|
|
645
|
+
REDIRECT = 'redirects',
|
|
646
|
+
REQUEST_REWRITE = 'requestRewrites',
|
|
647
|
+
RESPONSE_REWRITE = 'responseRewrites'
|
|
614
648
|
}
|
|
615
649
|
|
|
616
|
-
//
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
650
|
+
// Each meta type has corresponding data structure
|
|
651
|
+
interface SubRouteMetaTypes {
|
|
652
|
+
redirects?: RawRedirect[]; // Handled by RedirectMeta
|
|
653
|
+
requestRewrites?: RawRequestRewrite[]; // Handled by RequestRewriteMeta
|
|
654
|
+
responseRewrites?: RawResponseRewrite[]; // Handled by ResponseRewriteMeta
|
|
655
|
+
}
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
#### π Meta Processing Flow
|
|
659
|
+
|
|
660
|
+
1. **Configuration Parsing**: SubProcessor reads meta configuration
|
|
661
|
+
2. **Factory Creation**: MetaFactory creates appropriate Meta instances based on type
|
|
662
|
+
3. **Processing**: Each Meta instance handles its specific logic (redirects, rewrites, etc.)
|
|
663
|
+
4. **Execution**: Executors coordinate Meta processing through the pipeline
|
|
664
|
+
|
|
665
|
+
#### π― Built-in Meta Types
|
|
666
|
+
|
|
667
|
+
- **RedirectMeta**: Handles URL redirections with pattern matching
|
|
668
|
+
- **RequestRewriteMeta**: Modifies incoming requests (headers, URL, middleware)
|
|
669
|
+
- **ResponseRewriteMeta**: Transforms outgoing responses (headers, content)
|
|
670
|
+
|
|
671
|
+
#### π Value System Integration
|
|
672
|
+
|
|
673
|
+
Meta processing leverages Unieo's powerful Value system for dynamic data extraction and transformation:
|
|
674
|
+
|
|
675
|
+
```typescript
|
|
676
|
+
// Value configuration structure
|
|
677
|
+
interface ValueRawData {
|
|
678
|
+
source: unknown; // The data source (header name, URL part, etc.)
|
|
679
|
+
sourceType: string; // How to extract the data
|
|
680
|
+
valueType?: ValueType; // How to process the extracted data
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// Available source types
|
|
684
|
+
enum ValueSourceType {
|
|
685
|
+
LITERAL = 'literal', // Static value
|
|
686
|
+
REQUEST_HEADER = 'request_header', // HTTP request header
|
|
687
|
+
RESPONSE_HEADER = 'response_header', // HTTP response header
|
|
688
|
+
URL = 'url', // URL components (path, host, etc.)
|
|
689
|
+
COOKIE = 'cookie', // Cookie values
|
|
690
|
+
QUERY = 'query', // Query parameters
|
|
691
|
+
FETCH = 'fetch', // External API call
|
|
692
|
+
STRING_TEMPLATE = 'string_template', // Template with variable substitution
|
|
693
|
+
VALUE_OBJECT = 'value_object' // Nested value processing
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
// Example: Dynamic header based on user location
|
|
697
|
+
const dynamicRewrite = {
|
|
698
|
+
type: 'header',
|
|
699
|
+
field: 'x-user-region',
|
|
700
|
+
value: {
|
|
701
|
+
source: 'cf-ipcountry', // Extract from Cloudflare header
|
|
702
|
+
sourceType: 'request_header', // Source is a request header
|
|
703
|
+
valueType: 'string' // Process as string
|
|
704
|
+
},
|
|
705
|
+
operation: 'set'
|
|
706
|
+
};
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
#### π§© Custom Meta Extension
|
|
710
|
+
|
|
711
|
+
The Meta system supports custom extensions:
|
|
712
|
+
|
|
713
|
+
```typescript
|
|
714
|
+
// Define custom meta data structure
|
|
715
|
+
interface CustomValidationMeta {
|
|
716
|
+
rules: ValidationRule[];
|
|
717
|
+
onFailure: 'block' | 'warn' | 'log';
|
|
718
|
+
customHeaders?: Record<string, string>;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// Register custom meta type
|
|
722
|
+
MetaFactory.register('validation', CustomValidationMeta);
|
|
723
|
+
|
|
724
|
+
// Use in route configuration
|
|
725
|
+
const routeWithCustomMeta = {
|
|
726
|
+
meta: {
|
|
727
|
+
validation: [
|
|
728
|
+
{
|
|
729
|
+
rules: [{ field: 'authorization', required: true }],
|
|
730
|
+
onFailure: 'block',
|
|
731
|
+
customHeaders: { 'x-validation-error': 'missing-auth' }
|
|
732
|
+
}
|
|
733
|
+
]
|
|
626
734
|
}
|
|
735
|
+
};
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
## ποΈ System Architecture
|
|
739
|
+
|
|
740
|
+
Unieo adopts a sophisticated multi-layered architecture designed for maximum flexibility and extensibility. The system is built around several key concepts:
|
|
741
|
+
|
|
742
|
+
### π― Core Concepts
|
|
743
|
+
|
|
744
|
+
- **Meta-Driven Configuration**: Route behavior is defined by Meta configurations rather than hard-coded logic
|
|
745
|
+
- **Factory Pattern**: Dynamic creation and registration of components (Processors, Executors, Meta types)
|
|
746
|
+
- **Value System**: Unified data extraction and transformation across all components
|
|
747
|
+
- **Middleware Integration**: Comprehensive middleware system for request/response processing
|
|
748
|
+
|
|
749
|
+
### π Execution Flow
|
|
750
|
+
|
|
751
|
+
Unieo processes routes through a well-defined pipeline:
|
|
752
|
+
|
|
753
|
+
1. **Route Initialization**: Creates RouteContext and ProcessorFactory
|
|
754
|
+
2. **Configuration Processing**: Parses route configuration and creates appropriate processors
|
|
755
|
+
3. **Meta Processing**: Dynamically creates Meta instances based on configuration
|
|
756
|
+
4. **Execution Pipeline**: Coordinates redirects β request rewrites β middleware β response rewrites
|
|
757
|
+
5. **Response Delivery**: Returns the final processed response
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
## π§© Extending Unieo
|
|
762
|
+
|
|
763
|
+
Unieo supports extensibility through custom middleware and value processors:
|
|
764
|
+
|
|
765
|
+
### π Custom Middleware
|
|
766
|
+
|
|
767
|
+
The most common way to extend Unieo is through custom middleware:
|
|
768
|
+
|
|
769
|
+
```typescript
|
|
770
|
+
import type { MiddlewareGen, BaseMiddlewareOption, RouteContext, MiddlewareNext } from 'unieo';
|
|
771
|
+
|
|
772
|
+
// Define middleware options
|
|
773
|
+
interface AuthMiddlewareOption extends BaseMiddlewareOption {
|
|
774
|
+
secret: string;
|
|
775
|
+
headerName?: string;
|
|
627
776
|
}
|
|
777
|
+
|
|
778
|
+
// Create middleware
|
|
779
|
+
const AuthMiddleware: MiddlewareGen<AuthMiddlewareOption> = (opt) => {
|
|
780
|
+
return async (ctx: RouteContext, next: MiddlewareNext) => {
|
|
781
|
+
const { secret, headerName = 'authorization' } = opt;
|
|
782
|
+
const authHeader = ctx.request.headers.get(headerName);
|
|
783
|
+
|
|
784
|
+
if (!authHeader || !authHeader.includes(secret)) {
|
|
785
|
+
ctx.setResponse(new Response('Unauthorized', { status: 401 }));
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
await next();
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// Register and use
|
|
794
|
+
const route = new Route({
|
|
795
|
+
event,
|
|
796
|
+
middlewares: [['Auth', AuthMiddleware]]
|
|
797
|
+
});
|
|
628
798
|
```
|
|
629
799
|
|
|
630
|
-
###
|
|
800
|
+
### π Custom Value Processors
|
|
801
|
+
|
|
802
|
+
Extend the Value system for custom data sources:
|
|
631
803
|
|
|
632
804
|
```typescript
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
//
|
|
638
|
-
|
|
805
|
+
import { SourceProcessorManager } from 'unieo';
|
|
806
|
+
|
|
807
|
+
class DatabaseSourceProcessor implements ISourceProcessor {
|
|
808
|
+
async getSource({ source }: IValue, ctx: RouteContext): Promise<unknown> {
|
|
809
|
+
// Custom database lookup
|
|
810
|
+
const query = source as string;
|
|
811
|
+
return await this.queryDatabase(query);
|
|
639
812
|
}
|
|
640
813
|
|
|
641
|
-
private
|
|
642
|
-
//
|
|
814
|
+
private async queryDatabase(query: string): Promise<unknown> {
|
|
815
|
+
// Implement database logic
|
|
816
|
+
return fetch(`/api/db?q=${encodeURIComponent(query)}`)
|
|
817
|
+
.then(res => res.json());
|
|
643
818
|
}
|
|
644
819
|
}
|
|
820
|
+
|
|
821
|
+
// Register custom source processor
|
|
822
|
+
const sourceManager = new SourceProcessorManager();
|
|
823
|
+
sourceManager.register('database', new DatabaseSourceProcessor());
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
### ποΈ Advanced Configuration
|
|
827
|
+
|
|
828
|
+
Use custom processors in route configurations:
|
|
829
|
+
|
|
830
|
+
```typescript
|
|
831
|
+
const advancedRoutes = [
|
|
832
|
+
{
|
|
833
|
+
name: 'database-routing',
|
|
834
|
+
type: 'dynamic',
|
|
835
|
+
processor: 'COMMON_GROUP_PROCESSOR',
|
|
836
|
+
routes: [
|
|
837
|
+
{
|
|
838
|
+
name: 'user-route',
|
|
839
|
+
type: 'user',
|
|
840
|
+
processor: 'COMMON_SUB_PROCESSOR',
|
|
841
|
+
meta: {
|
|
842
|
+
match: {
|
|
843
|
+
list: [{
|
|
844
|
+
origin: { source: 'SELECT role FROM users WHERE id = ?', sourceType: 'database' },
|
|
845
|
+
criteria: { source: 'admin', sourceType: 'literal' },
|
|
846
|
+
operator: 'equal'
|
|
847
|
+
}]
|
|
848
|
+
},
|
|
849
|
+
requestRewrites: [{
|
|
850
|
+
type: 'middleware',
|
|
851
|
+
value: {
|
|
852
|
+
source: [
|
|
853
|
+
['Auth', { secret: 'admin-secret' }],
|
|
854
|
+
['DefaultFetch', {}]
|
|
855
|
+
],
|
|
856
|
+
sourceType: 'literal'
|
|
857
|
+
},
|
|
858
|
+
operation: 'set'
|
|
859
|
+
}]
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
]
|
|
863
|
+
}
|
|
864
|
+
];
|
|
645
865
|
```
|
|
646
866
|
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
647
871
|
## π€ Contributing
|
|
648
872
|
[](https://deepwiki.com/unieojs/unieo)
|
|
649
873
|
|
|
@@ -8,10 +8,6 @@ export declare enum GroupProcessorType {
|
|
|
8
8
|
export declare enum SubProcessorType {
|
|
9
9
|
COMMON_SUB_PROCESSOR = "COMMON_SUB_PROCESSOR"
|
|
10
10
|
}
|
|
11
|
-
export declare enum RouteType {
|
|
12
|
-
AUTH_GROUP_ROUTE = "AUTH_GROUP_ROUTE",
|
|
13
|
-
GREY_GROUP_ROUTE = "GREY_GROUP_ROUTE"
|
|
14
|
-
}
|
|
15
11
|
export declare enum MatchOperator {
|
|
16
12
|
AND = "and",
|
|
17
13
|
OR = "or"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enum.d.ts","sourceRoot":"","sources":["../../../src/common/Enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,oBAAY,kBAAkB;IAE5B,sBAAsB,2BAA2B;CAClD;AAED,oBAAY,gBAAgB;IAE1B,oBAAoB,yBAAyB;CAC9C;AAED,oBAAY,
|
|
1
|
+
{"version":3,"file":"Enum.d.ts","sourceRoot":"","sources":["../../../src/common/Enum.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,oBAAY,kBAAkB;IAE5B,sBAAsB,2BAA2B;CAClD;AAED,oBAAY,gBAAgB;IAE1B,oBAAoB,yBAAyB;CAC9C;AAED,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,EAAE,OAAO;CACV;AAED,oBAAY,eAAe;IAEzB,OAAO,YAAY;IAEnB,cAAc,mBAAmB;IAEjC,eAAe,oBAAoB;IAEnC,eAAe,oBAAoB;IAEnC,MAAM,WAAW;IAEjB,GAAG,QAAQ;IAEX,UAAU,eAAe;IAEzB,KAAK,UAAU;IAEf,MAAM,WAAW;IAEjB,KAAK,UAAU;IAEf,UAAU,eAAe;IAEzB,eAAe,oBAAoB;IAEnC,YAAY,iBAAiB;CAC9B;AAED,oBAAY,QAAQ;IAClB,EAAE,OAAO;IACT,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,MAAM,WAAW;IAEjB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAE3B,eAAe,oBAAoB;IACnC,GAAG,QAAQ;IACX,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,EAAE,OAAO;IACT,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,GA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exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpStatus = exports.HttpMethod = exports.ValueType = exports.DecompressType = exports.RedirectType = exports.RequestInitValueType = exports.UrlValueType = exports.RewriteOperation = exports.ResponseRewriteOperation = exports.ResponseRewriteType = exports.RequestRewriteType = exports.Operator = exports.ValueSourceType = exports.MatchOperator = exports.
|
|
3
|
+
exports.HttpStatus = exports.HttpMethod = exports.ValueType = exports.DecompressType = exports.RedirectType = exports.RequestInitValueType = exports.UrlValueType = exports.RewriteOperation = exports.ResponseRewriteOperation = exports.ResponseRewriteType = exports.RequestRewriteType = exports.Operator = exports.ValueSourceType = exports.MatchOperator = exports.SubProcessorType = exports.GroupProcessorType = exports.RouteStatus = void 0;
|
|
4
4
|
var RouteStatus;
|
|
5
5
|
(function (RouteStatus) {
|
|
6
6
|
RouteStatus["ONLINE"] = "ONLINE";
|
|
@@ -16,13 +16,6 @@ var SubProcessorType;
|
|
|
16
16
|
// ιη¨ε€ηε¨
|
|
17
17
|
SubProcessorType["COMMON_SUB_PROCESSOR"] = "COMMON_SUB_PROCESSOR";
|
|
18
18
|
})(SubProcessorType || (exports.SubProcessorType = SubProcessorType = {}));
|
|
19
|
-
var RouteType;
|
|
20
|
-
(function (RouteType) {
|
|
21
|
-
// AUTH εη»
|
|
22
|
-
RouteType["AUTH_GROUP_ROUTE"] = "AUTH_GROUP_ROUTE";
|
|
23
|
-
// η°εΊ¦εη»
|
|
24
|
-
RouteType["GREY_GROUP_ROUTE"] = "GREY_GROUP_ROUTE";
|
|
25
|
-
})(RouteType || (exports.RouteType = RouteType = {}));
|
|
26
19
|
var MatchOperator;
|
|
27
20
|
(function (MatchOperator) {
|
|
28
21
|
MatchOperator["AND"] = "and";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Enum.js","sourceRoot":"","sources":["../../../src/common/Enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,kCAA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@ -4,56 +4,15 @@ export * from './Base';
|
|
|
4
4
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
5
5
|
type ErrorOption = PartialBy<Omit<BaseErrorOptions, 'code'>, 'name'>;
|
|
6
6
|
export declare enum ErrorCode {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
HostResourceConfigInvalidError = 1010,
|
|
17
|
-
PackRouteConfigInvalidError = 1011,
|
|
18
|
-
HostResourceRequestError = 1012,
|
|
19
|
-
RevisionNotFoundError = 1013,
|
|
20
|
-
SubRouteRedirectError = 1014,
|
|
21
|
-
RequestMiddlewareRedefined = 1015,
|
|
22
|
-
SubRouteCheckHostForbidError = 1016,
|
|
23
|
-
HostInfoNotInitError = 1017,
|
|
24
|
-
CreateSubRouteContextError = 1018,
|
|
25
|
-
AliyunHttpClientForbidRouteExecuteError = 1019,
|
|
26
|
-
MethodNotAllowed = 1020,
|
|
27
|
-
PathmapError = 1021,
|
|
28
|
-
AMDCConfigError = 1022,
|
|
29
|
-
AMDCRequestError = 1023,
|
|
30
|
-
CORSHeaderAppendError = 1024,
|
|
31
|
-
PathForbidden = 1025,
|
|
32
|
-
SubRouteCheckHostInterceptError = 1026,
|
|
33
|
-
RequestNotAllowed = 1027,
|
|
34
|
-
EdgeKVNotFoundError = 2001,
|
|
35
|
-
EdgeKVRequestError = 2002,
|
|
36
|
-
EdgeKVTimeoutError = 2003,
|
|
37
|
-
SystemError = 3001,
|
|
38
|
-
NotFoundRenderOriginHostError = 3002,
|
|
39
|
-
NotFoundTernError = 3003,
|
|
40
|
-
NotFoundWebGWHostError = 3004,
|
|
41
|
-
TimeoutError = 3005,
|
|
42
|
-
RenderConfigRequestError = 4001,
|
|
43
|
-
RenderConfigTimeoutError = 4002,
|
|
44
|
-
RenderAssetsRequestError = 4003,
|
|
45
|
-
UnioVersionNotFoundError = 4004,
|
|
46
|
-
SSRPreludeResponseInvalidError = 5001,
|
|
47
|
-
SSRPreludeResponseInvalidErrorAsEmptyVersion = 5002,
|
|
48
|
-
SSRPreludeResponseInvalidErrorAsEmptyBody = 5003,
|
|
49
|
-
SSRPostponedResponseInvalidError = 5010,
|
|
50
|
-
SSRPostponedUncheckedError = 5100,
|
|
51
|
-
SSRResponseStreamTimeout = 5200,
|
|
52
|
-
UserRouteConfigInvalidError = 6001,
|
|
53
|
-
UnauthenticatedError = 6002,
|
|
54
|
-
TernMiddlewareError = 7001,
|
|
55
|
-
TernSiteExecutorStageError = 7002,
|
|
56
|
-
TernResourceStatusError = 7003
|
|
7
|
+
SystemError = 1001,
|
|
8
|
+
TimeoutError = 1002,
|
|
9
|
+
GroupProcessorNotFoundError = 1101,
|
|
10
|
+
SubProcessorNotFoundError = 1102,
|
|
11
|
+
LoadMiddlewareNotFoundError = 1103,
|
|
12
|
+
SubRouteRedirectError = 1201,
|
|
13
|
+
SubRouteBeforeRequestError = 1202,
|
|
14
|
+
SubRouteBeforeResponseError = 1203,
|
|
15
|
+
MiddlewareResponseInvalidError = 1301
|
|
57
16
|
}
|
|
58
17
|
export declare function genError(code: ErrorCode, errorOption?: string | ErrorOption | Error): BaseError;
|
|
59
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/Error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAE/C,cAAc,QAAQ,CAAC;AAOvB,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEx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