Skip to content

Commit d28ed80

Browse files
committed
Enhance API reference and expand SmtpSessionState enum
Added namespaces, delegates, enums, and rate limiting sections to the API reference page, including support for displaying enum values and delegate signatures. Expanded the SmtpSessionState enum in C# to include Hello, Mail, Recipient, Data, and Quit states, each with descriptive XML comments.
1 parent db7216c commit d28ed80

2 files changed

Lines changed: 148 additions & 11 deletions

File tree

.pages/app/api/page.tsx

Lines changed: 125 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import {
1010
Hash,
1111
Box,
1212
Zap,
13-
Lock,
1413
Mail,
15-
Settings
14+
Settings,
15+
Gauge
1616
} from 'lucide-react';
1717

1818
export const metadata: Metadata = {
@@ -24,6 +24,7 @@ const apiCategories = [
2424
{
2525
title: 'Core Classes',
2626
icon: Box,
27+
namespace: 'Zetian.Server',
2728
items: [
2829
{
2930
name: 'SmtpServer',
@@ -75,7 +76,14 @@ const apiCategories = [
7576
'Build()'
7677
],
7778
events: []
78-
},
79+
}
80+
]
81+
},
82+
{
83+
title: 'Configuration',
84+
icon: Settings,
85+
namespace: 'Zetian.Configuration',
86+
items: [
7987
{
8088
name: 'SmtpServerConfiguration',
8189
description: 'Configuration settings for SMTP server',
@@ -116,6 +124,7 @@ const apiCategories = [
116124
{
117125
title: 'Core Interfaces',
118126
icon: FileCode,
127+
namespace: 'Zetian.Abstractions',
119128
items: [
120129
{
121130
name: 'ISmtpMessage',
@@ -186,12 +195,24 @@ const apiCategories = [
186195
'CanDeliverToAsync(ISmtpSession, string, string, CancellationToken)'
187196
],
188197
events: []
198+
},
199+
{
200+
name: 'IStatisticsCollector',
201+
description: 'Interface for statistics collection',
202+
properties: ['TotalSessions', 'TotalMessages', 'TotalErrors', 'TotalBytes'],
203+
methods: [
204+
'RecordSession()',
205+
'RecordMessage(ISmtpMessage)',
206+
'RecordError(Exception)'
207+
],
208+
events: []
189209
}
190210
]
191211
},
192212
{
193213
title: 'Authentication',
194214
icon: Shield,
215+
namespace: 'Zetian.Authentication & Zetian.Models',
195216
items: [
196217
{
197218
name: 'IAuthenticator',
@@ -226,6 +247,7 @@ const apiCategories = [
226247
{
227248
title: 'Storage',
228249
icon: Database,
250+
namespace: 'Zetian.Storage',
229251
items: [
230252
{
231253
name: 'FileMessageStore',
@@ -246,6 +268,7 @@ const apiCategories = [
246268
{
247269
title: 'Filtering',
248270
icon: Filter,
271+
namespace: 'Zetian.Storage',
249272
items: [
250273
{
251274
name: 'DomainMailboxFilter',
@@ -273,6 +296,7 @@ const apiCategories = [
273296
{
274297
title: 'Event Arguments',
275298
icon: Zap,
299+
namespace: 'Zetian.Models.EventArgs',
276300
items: [
277301
{
278302
name: 'MessageEventArgs',
@@ -307,6 +331,7 @@ const apiCategories = [
307331
{
308332
title: 'Protocol',
309333
icon: Mail,
334+
namespace: 'Zetian.Protocol',
310335
items: [
311336
{
312337
name: 'SmtpResponse',
@@ -340,6 +365,7 @@ const apiCategories = [
340365
{
341366
title: 'Extensions',
342367
icon: Zap,
368+
namespace: 'Zetian.Extensions & Zetian.Models',
343369
items: [
344370
{
345371
name: 'SmtpServerExtensions',
@@ -384,15 +410,60 @@ const apiCategories = [
384410
'GetRemainingAsync(key)'
385411
],
386412
events: []
387-
},
413+
}
414+
]
415+
},
416+
{
417+
title: 'Rate Limiting',
418+
icon: Gauge,
419+
namespace: 'Zetian.RateLimiting & Zetian.Abstractions',
420+
items: [
388421
{
389422
name: 'InMemoryRateLimiter',
390423
description: 'In-memory rate limiter implementation',
391424
properties: ['Configuration'],
392-
methods: [],
425+
methods: ['IsAllowedAsync(key)', 'IsAllowedAsync(IPAddress)', 'RecordRequestAsync(key)', 'RecordRequestAsync(IPAddress)', 'ResetAsync(key)', 'GetRemainingAsync(key)'],
393426
events: []
394427
}
395428
]
429+
},
430+
{
431+
title: 'Delegates',
432+
icon: Code2,
433+
namespace: 'Zetian.Delegates',
434+
items: [
435+
{
436+
name: 'AuthenticationHandler',
437+
description: 'Delegate for handling authentication',
438+
properties: [],
439+
methods: [],
440+
events: [],
441+
signature: 'Task<AuthenticationResult> AuthenticationHandler(string? username, string? password)'
442+
}
443+
]
444+
},
445+
{
446+
title: 'Enums',
447+
icon: Hash,
448+
namespace: 'Zetian.Enums',
449+
items: [
450+
{
451+
name: 'CompositeMode',
452+
description: 'Composite filter mode for combining multiple filters',
453+
properties: [],
454+
methods: [],
455+
events: [],
456+
values: ['All (AND logic)', 'Any (OR logic)']
457+
},
458+
{
459+
name: 'SmtpSessionState',
460+
description: 'SMTP session state enumeration',
461+
properties: [],
462+
methods: [],
463+
events: [],
464+
values: ['Connected', 'AwaitingCommand', 'ReceivingData', 'Closing']
465+
}
466+
]
396467
}
397468
];
398469

@@ -438,13 +509,20 @@ export default function ApiReferencePage() {
438509
className="scroll-mt-20"
439510
>
440511
{/* Category Header */}
441-
<div className="flex items-center gap-3 mb-6">
442-
<div className="p-2 bg-primary-100 dark:bg-primary-900/30 rounded-lg">
443-
<Icon className="h-5 w-5 text-primary-600 dark:text-primary-400" />
512+
<div className="mb-6">
513+
<div className="flex items-center gap-3 mb-2">
514+
<div className="p-2 bg-primary-100 dark:bg-primary-900/30 rounded-lg">
515+
<Icon className="h-5 w-5 text-primary-600 dark:text-primary-400" />
516+
</div>
517+
<h2 className="text-2xl font-bold text-gray-900 dark:text-white">
518+
{category.title}
519+
</h2>
444520
</div>
445-
<h2 className="text-2xl font-bold text-gray-900 dark:text-white">
446-
{category.title}
447-
</h2>
521+
{'namespace' in category && category.namespace && (
522+
<p className="text-sm text-gray-600 dark:text-gray-400 ml-12">
523+
Namespace: <code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-primary-600 dark:text-primary-400">{category.namespace}</code>
524+
</p>
525+
)}
448526
</div>
449527

450528
{/* Items */}
@@ -551,6 +629,42 @@ export default function ApiReferencePage() {
551629
</div>
552630
</div>
553631
)}
632+
633+
{/* Delegate Signature */}
634+
{'signature' in item && item.signature && (
635+
<div>
636+
<h4 className="text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 uppercase tracking-wider">
637+
Signature
638+
</h4>
639+
<div className="bg-gray-100 dark:bg-gray-800 p-3 rounded">
640+
<code className="text-sm text-blue-600 dark:text-blue-400">
641+
{item.signature}
642+
</code>
643+
</div>
644+
</div>
645+
)}
646+
647+
{/* Enum Values */}
648+
{'values' in item && item.values && item.values.length > 0 && (
649+
<div>
650+
<h4 className="text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 uppercase tracking-wider">
651+
Values
652+
</h4>
653+
<div className="space-y-2">
654+
{item.values.map((value: string) => (
655+
<div
656+
key={value}
657+
className="flex items-center gap-2 text-sm"
658+
>
659+
<Hash className="h-3 w-3 text-gray-400" />
660+
<code className="bg-gray-100 dark:bg-gray-800 px-2 py-1 rounded text-orange-600 dark:text-orange-400">
661+
{value}
662+
</code>
663+
</div>
664+
))}
665+
</div>
666+
</div>
667+
)}
554668
</div>
555669
))}
556670
</div>

src/Zetian/Enums/SmtpSessionState.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,34 @@
55
/// </summary>
66
internal enum SmtpSessionState
77
{
8+
/// <summary>
9+
/// Gets a value indicating whether the connection to the resource is currently established.
10+
/// </summary>
811
Connected,
12+
13+
/// <summary>
14+
/// Represents a greeting or salutation.
15+
/// </summary>
916
Hello,
17+
18+
/// <summary>
19+
/// Represents an email message, including its content, recipients, and related metadata.
20+
/// </summary>
1021
Mail,
22+
23+
/// <summary>
24+
/// Represents a recipient of a message, notification, or other communication.
25+
/// </summary>
1126
Recipient,
27+
28+
/// <summary>
29+
/// Gets or sets the data associated with this instance.
30+
/// </summary>
1231
Data,
32+
33+
/// <summary>
34+
/// Represents an action or command to exit or terminate the current process or application.
35+
/// </summary>
1336
Quit
1437
}
1538
}

0 commit comments

Comments
 (0)