alepha 0.10.1 → 0.10.3
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 +131 -34
- package/batch.d.ts +1 -1
- package/bucket.d.ts +1 -1
- package/cache/redis.d.ts +1 -1
- package/cache.d.ts +1 -1
- package/command.d.ts +1 -1
- package/core.d.ts +20 -11
- package/datetime.d.ts +1 -1
- package/email.d.ts +6 -6
- package/lock/redis.d.ts +1 -1
- package/lock.d.ts +1 -1
- package/logger.d.ts +1 -1
- package/package.json +44 -44
- package/postgres.d.ts +64 -376
- package/queue/redis.d.ts +1 -1
- package/queue.d.ts +1 -1
- package/react/auth.d.ts +1 -1
- package/react/form.d.ts +2 -2
- package/react/head.d.ts +1 -1
- package/react/i18n.d.ts +1 -1
- package/react.d.ts +33 -28
- package/redis.d.ts +1 -1
- package/scheduler.d.ts +1 -1
- package/security.d.ts +8 -7
- package/server/cache.d.ts +1 -1
- package/server/compress.d.ts +1 -1
- package/server/cookies.d.ts +3 -13
- package/server/cors.d.ts +1 -1
- package/server/health.d.ts +1 -1
- package/server/helmet.d.ts +1 -1
- package/server/links.d.ts +34 -34
- package/server/metrics.d.ts +1 -1
- package/server/multipart.d.ts +1 -1
- package/server/proxy.d.ts +1 -1
- package/server/security.d.ts +1 -1
- package/server/static.d.ts +1 -1
- package/server/swagger.d.ts +14 -1
- package/server.d.ts +35 -390
- package/topic/redis.d.ts +1 -1
- package/topic.d.ts +1 -1
package/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alepha_core11 from "alepha";
|
|
2
2
|
import { Alepha, AlephaError, Async, Descriptor, FileLike, KIND, Static, StreamLike, TArray, TFile, TObject, TRecord, TSchema, TStream, TString, TVoid } from "alepha";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _alepha_logger3 from "alepha/logger";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
import { ReadableStream } from "node:stream/web";
|
|
6
6
|
import { Route, RouterProvider } from "alepha/router";
|
|
@@ -176,13 +176,13 @@ declare class ServerRequestParser {
|
|
|
176
176
|
//#region src/providers/ServerTimingProvider.d.ts
|
|
177
177
|
type TimingMap = Record<string, [number, number]>;
|
|
178
178
|
declare class ServerTimingProvider {
|
|
179
|
-
protected readonly log:
|
|
179
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
180
180
|
protected readonly alepha: Alepha;
|
|
181
181
|
options: {
|
|
182
182
|
disabled: boolean;
|
|
183
183
|
};
|
|
184
|
-
readonly onRequest:
|
|
185
|
-
readonly onResponse:
|
|
184
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
185
|
+
readonly onResponse: _alepha_core11.HookDescriptor<"server:onResponse">;
|
|
186
186
|
protected get handlerName(): string;
|
|
187
187
|
beginTiming(name: string): void;
|
|
188
188
|
endTiming(name: string): void;
|
|
@@ -222,7 +222,7 @@ declare class ServerRouterProvider extends RouterProvider<ServerRouteMatcher> {
|
|
|
222
222
|
//#endregion
|
|
223
223
|
//#region src/services/HttpClient.d.ts
|
|
224
224
|
declare class HttpClient {
|
|
225
|
-
protected readonly log:
|
|
225
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
226
226
|
protected readonly alepha: Alepha;
|
|
227
227
|
readonly cache: _alepha_cache0.CacheDescriptorFn<HttpClientCache, any[]>;
|
|
228
228
|
protected readonly pendingRequests: HttpClientPendingRequests;
|
|
@@ -334,8 +334,9 @@ interface HttpAction {
|
|
|
334
334
|
* import { t } from "alepha";
|
|
335
335
|
*
|
|
336
336
|
* class UserController {
|
|
337
|
-
*
|
|
337
|
+
*
|
|
338
338
|
* getUsers = $action({
|
|
339
|
+
* path: "/users",
|
|
339
340
|
* description: "Retrieve all users with pagination",
|
|
340
341
|
* schema: {
|
|
341
342
|
* query: t.object({
|
|
@@ -366,8 +367,9 @@ interface HttpAction {
|
|
|
366
367
|
* }
|
|
367
368
|
* });
|
|
368
369
|
*
|
|
369
|
-
* // POST /api/users
|
|
370
370
|
* createUser = $action({
|
|
371
|
+
* method: "POST",
|
|
372
|
+
* path: "/users",
|
|
371
373
|
* description: "Create a new user account",
|
|
372
374
|
* schema: {
|
|
373
375
|
* body: t.object({
|
|
@@ -402,8 +404,8 @@ interface HttpAction {
|
|
|
402
404
|
* }
|
|
403
405
|
* });
|
|
404
406
|
*
|
|
405
|
-
* // GET /api/users/:id
|
|
406
407
|
* getUser = $action({
|
|
408
|
+
* path: "/users/:id",
|
|
407
409
|
* description: "Retrieve user by ID",
|
|
408
410
|
* schema: {
|
|
409
411
|
* params: t.object({
|
|
@@ -430,9 +432,9 @@ interface HttpAction {
|
|
|
430
432
|
* }
|
|
431
433
|
* });
|
|
432
434
|
*
|
|
433
|
-
* // PUT /api/users/:id
|
|
434
435
|
* updateUser = $action({
|
|
435
436
|
* method: "PUT",
|
|
437
|
+
* path: "/users/:id",
|
|
436
438
|
* description: "Update user information",
|
|
437
439
|
* schema: {
|
|
438
440
|
* params: t.object({ id: t.string() }),
|
|
@@ -460,363 +462,6 @@ interface HttpAction {
|
|
|
460
462
|
* }
|
|
461
463
|
* ```
|
|
462
464
|
*
|
|
463
|
-
* @example
|
|
464
|
-
* **File upload with multipart form data:**
|
|
465
|
-
* ```ts
|
|
466
|
-
* class FileController {
|
|
467
|
-
* uploadAvatar = $action({
|
|
468
|
-
* method: "POST",
|
|
469
|
-
* description: "Upload user avatar image",
|
|
470
|
-
* schema: {
|
|
471
|
-
* body: t.object({
|
|
472
|
-
* file: t.file({
|
|
473
|
-
* maxSize: 5 * 1024 * 1024, // 5MB
|
|
474
|
-
* allowedMimeTypes: ["image/jpeg", "image/png", "image/webp"]
|
|
475
|
-
* }),
|
|
476
|
-
* userId: t.string()
|
|
477
|
-
* }),
|
|
478
|
-
* response: t.object({
|
|
479
|
-
* url: t.string({ format: "uri" }),
|
|
480
|
-
* size: t.number(),
|
|
481
|
-
* mimeType: t.string(),
|
|
482
|
-
* uploadedAt: t.datetime()
|
|
483
|
-
* })
|
|
484
|
-
* },
|
|
485
|
-
* handler: async ({ body }) => {
|
|
486
|
-
* const { file, userId } = body;
|
|
487
|
-
*
|
|
488
|
-
* // Validate file
|
|
489
|
-
* await this.fileService.validateImage(file);
|
|
490
|
-
*
|
|
491
|
-
* // Generate unique filename
|
|
492
|
-
* const filename = `avatars/${userId}/${Date.now()}-${file.name}`;
|
|
493
|
-
*
|
|
494
|
-
* // Upload to storage
|
|
495
|
-
* const uploadResult = await this.storageService.upload(filename, file);
|
|
496
|
-
*
|
|
497
|
-
* // Update user profile
|
|
498
|
-
* await this.userService.updateAvatar(userId, uploadResult.url);
|
|
499
|
-
*
|
|
500
|
-
* return {
|
|
501
|
-
* url: uploadResult.url,
|
|
502
|
-
* size: file.size,
|
|
503
|
-
* mimeType: file.type,
|
|
504
|
-
* uploadedAt: new Date().toISOString()
|
|
505
|
-
* };
|
|
506
|
-
* }
|
|
507
|
-
* });
|
|
508
|
-
*
|
|
509
|
-
* downloadFile = $action({
|
|
510
|
-
* method: "GET",
|
|
511
|
-
* description: "Download file by ID",
|
|
512
|
-
* schema: {
|
|
513
|
-
* params: t.object({ id: t.string() }),
|
|
514
|
-
* query: t.object({
|
|
515
|
-
* download: t.optional(t.boolean()),
|
|
516
|
-
* thumbnail: t.optional(t.boolean())
|
|
517
|
-
* }),
|
|
518
|
-
* response: t.file()
|
|
519
|
-
* },
|
|
520
|
-
* handler: async ({ params, query, reply, user }) => {
|
|
521
|
-
* const file = await this.fileService.findById(params.id);
|
|
522
|
-
* if (!file) {
|
|
523
|
-
* throw new Error("File not found");
|
|
524
|
-
* }
|
|
525
|
-
*
|
|
526
|
-
* // Check permissions
|
|
527
|
-
* await this.fileService.checkAccess(params.id, user.id);
|
|
528
|
-
*
|
|
529
|
-
* const fileBuffer = query.thumbnail
|
|
530
|
-
* ? await this.fileService.getThumbnail(file.id)
|
|
531
|
-
* : await this.fileService.getBuffer(file.path);
|
|
532
|
-
*
|
|
533
|
-
* // Set appropriate headers
|
|
534
|
-
* reply.header("Content-Type", file.mimeType);
|
|
535
|
-
* reply.header("Content-Length", fileBuffer.length);
|
|
536
|
-
*
|
|
537
|
-
* if (query.download) {
|
|
538
|
-
* reply.header("Content-Disposition", `attachment; filename="${file.name}"`);
|
|
539
|
-
* }
|
|
540
|
-
*
|
|
541
|
-
* return fileBuffer;
|
|
542
|
-
* }
|
|
543
|
-
* });
|
|
544
|
-
* }
|
|
545
|
-
* ```
|
|
546
|
-
*
|
|
547
|
-
* @example
|
|
548
|
-
* **Advanced API with custom paths and grouped operations:**
|
|
549
|
-
* ```ts
|
|
550
|
-
* class OrderController {
|
|
551
|
-
* group = "orders"; // Groups all actions under "orders" tag
|
|
552
|
-
*
|
|
553
|
-
* // GET /api/orders/search
|
|
554
|
-
* searchOrders = $action({
|
|
555
|
-
* name: "search",
|
|
556
|
-
* path: "/orders/search", // Custom path
|
|
557
|
-
* description: "Advanced order search with filtering",
|
|
558
|
-
* schema: {
|
|
559
|
-
* query: t.object({
|
|
560
|
-
* status: t.optional(t.union([
|
|
561
|
-
* t.literal("pending"),
|
|
562
|
-
* t.literal("processing"),
|
|
563
|
-
* t.literal("shipped"),
|
|
564
|
-
* t.literal("delivered"),
|
|
565
|
-
* t.literal("cancelled")
|
|
566
|
-
* ])),
|
|
567
|
-
* customerId: t.optional(t.string()),
|
|
568
|
-
* dateFrom: t.optional(t.date()),
|
|
569
|
-
* dateTo: t.optional(t.date()),
|
|
570
|
-
* minAmount: t.optional(t.number({ minimum: 0 })),
|
|
571
|
-
* maxAmount: t.optional(t.number({ minimum: 0 })),
|
|
572
|
-
* sortBy: t.optional(t.union([
|
|
573
|
-
* t.literal("createdAt"),
|
|
574
|
-
* t.literal("amount"),
|
|
575
|
-
* t.literal("status")
|
|
576
|
-
* ])),
|
|
577
|
-
* sortOrder: t.optional(t.enum(["asc", "desc"]))
|
|
578
|
-
* }),
|
|
579
|
-
* response: t.object({
|
|
580
|
-
* orders: t.array(t.object({
|
|
581
|
-
* id: t.string(),
|
|
582
|
-
* orderNumber: t.string(),
|
|
583
|
-
* customerId: t.string(),
|
|
584
|
-
* customerName: t.string(),
|
|
585
|
-
* status: t.string(),
|
|
586
|
-
* totalAmount: t.number(),
|
|
587
|
-
* createdAt: t.datetime(),
|
|
588
|
-
* itemCount: t.number()
|
|
589
|
-
* })),
|
|
590
|
-
* pagination: t.object({
|
|
591
|
-
* page: t.number(),
|
|
592
|
-
* limit: t.number(),
|
|
593
|
-
* total: t.number(),
|
|
594
|
-
* hasMore: t.boolean()
|
|
595
|
-
* }),
|
|
596
|
-
* filters: t.object({
|
|
597
|
-
* appliedFilters: t.array(t.string()),
|
|
598
|
-
* availableStatuses: t.array(t.string())
|
|
599
|
-
* })
|
|
600
|
-
* })
|
|
601
|
-
* },
|
|
602
|
-
* handler: async ({ query }) => {
|
|
603
|
-
* // Build dynamic query based on filters
|
|
604
|
-
* const searchCriteria = this.orderService.buildSearchCriteria(query);
|
|
605
|
-
* const results = await this.orderService.searchOrders(searchCriteria);
|
|
606
|
-
*
|
|
607
|
-
* return {
|
|
608
|
-
* orders: results.orders,
|
|
609
|
-
* pagination: results.pagination,
|
|
610
|
-
* filters: {
|
|
611
|
-
* appliedFilters: Object.keys(query).filter(key => query[key] !== undefined),
|
|
612
|
-
* availableStatuses: await this.orderService.getAvailableStatuses()
|
|
613
|
-
* }
|
|
614
|
-
* };
|
|
615
|
-
* }
|
|
616
|
-
* });
|
|
617
|
-
*
|
|
618
|
-
* // POST /api/orders/:id/process
|
|
619
|
-
* processOrder = $action({
|
|
620
|
-
* method: "POST",
|
|
621
|
-
* path: "/orders/:id/process",
|
|
622
|
-
* description: "Process an order through the fulfillment workflow",
|
|
623
|
-
* schema: {
|
|
624
|
-
* params: t.object({ id: t.string() }),
|
|
625
|
-
* body: t.object({
|
|
626
|
-
* notes: t.optional(t.string()),
|
|
627
|
-
* priority: t.optional(t.union([
|
|
628
|
-
* t.literal("low"),
|
|
629
|
-
* t.literal("normal"),
|
|
630
|
-
* t.literal("high"),
|
|
631
|
-
* t.literal("urgent")
|
|
632
|
-
* ])),
|
|
633
|
-
* assignToWarehouse: t.optional(t.string())
|
|
634
|
-
* }),
|
|
635
|
-
* response: t.object({
|
|
636
|
-
* orderId: t.string(),
|
|
637
|
-
* status: t.string(),
|
|
638
|
-
* processedAt: t.datetime(),
|
|
639
|
-
* estimatedFulfillment: t.datetime(),
|
|
640
|
-
* trackingInfo: t.optional(t.object({
|
|
641
|
-
* trackingNumber: t.string(),
|
|
642
|
-
* carrier: t.string(),
|
|
643
|
-
* estimatedDelivery: t.date()
|
|
644
|
-
* }))
|
|
645
|
-
* })
|
|
646
|
-
* },
|
|
647
|
-
* handler: async ({ params, body, user }) => {
|
|
648
|
-
* // Validate order can be processed
|
|
649
|
-
* const order = await this.orderService.findById(params.id);
|
|
650
|
-
* if (!order || order.status !== "pending") {
|
|
651
|
-
* throw new Error("Order cannot be processed in current status");
|
|
652
|
-
* }
|
|
653
|
-
*
|
|
654
|
-
* // Check inventory availability
|
|
655
|
-
* const inventoryCheck = await this.inventoryService.checkAvailability(order.items);
|
|
656
|
-
* if (!inventoryCheck.available) {
|
|
657
|
-
* throw new Error(`Insufficient inventory: ${inventoryCheck.missingItems.join(", ")}`);
|
|
658
|
-
* }
|
|
659
|
-
*
|
|
660
|
-
* // Process the order
|
|
661
|
-
* const processResult = await this.fulfillmentService.processOrder({
|
|
662
|
-
* orderId: params.id,
|
|
663
|
-
* options: {
|
|
664
|
-
* notes: body.notes,
|
|
665
|
-
* priority: body.priority || "normal",
|
|
666
|
-
* warehouse: body.assignToWarehouse
|
|
667
|
-
* }
|
|
668
|
-
* });
|
|
669
|
-
*
|
|
670
|
-
* // Update order status
|
|
671
|
-
* await this.orderService.updateStatus(params.id, "processing", {
|
|
672
|
-
* processedBy: user.id,
|
|
673
|
-
* processedAt: new Date(),
|
|
674
|
-
* notes: body.notes
|
|
675
|
-
* });
|
|
676
|
-
*
|
|
677
|
-
* // Send notification
|
|
678
|
-
* await this.notificationService.sendOrderUpdate(order.customerId, {
|
|
679
|
-
* orderId: params.id,
|
|
680
|
-
* status: "processing",
|
|
681
|
-
* message: "Your order is now being processed"
|
|
682
|
-
* });
|
|
683
|
-
*
|
|
684
|
-
* return {
|
|
685
|
-
* orderId: params.id,
|
|
686
|
-
* status: "processing",
|
|
687
|
-
* processedAt: new Date().toISOString(),
|
|
688
|
-
* estimatedFulfillment: processResult.estimatedCompletion,
|
|
689
|
-
* trackingInfo: processResult.trackingInfo
|
|
690
|
-
* };
|
|
691
|
-
* }
|
|
692
|
-
* });
|
|
693
|
-
* }
|
|
694
|
-
* ```
|
|
695
|
-
*
|
|
696
|
-
* @example
|
|
697
|
-
* **Actions with security integration and role-based access:**
|
|
698
|
-
* ```ts
|
|
699
|
-
* class AdminController {
|
|
700
|
-
* group = "admin";
|
|
701
|
-
*
|
|
702
|
-
* // Only accessible to users with "admin:users:read" permission
|
|
703
|
-
* getUserStats = $action({
|
|
704
|
-
* description: "Get comprehensive user statistics",
|
|
705
|
-
* security: { permissions: ["admin:users:read"] },
|
|
706
|
-
* schema: {
|
|
707
|
-
* query: t.object({
|
|
708
|
-
* includeInactive: t.optional(t.boolean())
|
|
709
|
-
* }),
|
|
710
|
-
* response: t.object({
|
|
711
|
-
* totalUsers: t.number(),
|
|
712
|
-
* activeUsers: t.number(),
|
|
713
|
-
* newUsers: t.number(),
|
|
714
|
-
* userGrowth: t.number(),
|
|
715
|
-
* breakdown: t.object({
|
|
716
|
-
* byRole: t.record(t.string(), t.number()),
|
|
717
|
-
* byStatus: t.record(t.string(), t.number()),
|
|
718
|
-
* byRegistrationSource: t.record(t.string(), t.number())
|
|
719
|
-
* }),
|
|
720
|
-
* trends: t.array(t.object({
|
|
721
|
-
* date: t.date(),
|
|
722
|
-
* registrations: t.number(),
|
|
723
|
-
* activations: t.number()
|
|
724
|
-
* }))
|
|
725
|
-
* })
|
|
726
|
-
* },
|
|
727
|
-
* handler: async ({ query, user }) => {
|
|
728
|
-
* // user is available through security integration
|
|
729
|
-
* this.auditLogger.log({
|
|
730
|
-
* action: "admin.getUserStats",
|
|
731
|
-
* userId: user.id,
|
|
732
|
-
* userRole: user.role,
|
|
733
|
-
* timestamp: new Date()
|
|
734
|
-
* });
|
|
735
|
-
*
|
|
736
|
-
* const period = query.period || "month";
|
|
737
|
-
* const stats = await this.analyticsService.getUserStatistics({
|
|
738
|
-
* period,
|
|
739
|
-
* includeInactive: query.includeInactive || false
|
|
740
|
-
* });
|
|
741
|
-
*
|
|
742
|
-
* return stats;
|
|
743
|
-
* }
|
|
744
|
-
* });
|
|
745
|
-
*
|
|
746
|
-
* // Bulk operations with transaction support
|
|
747
|
-
* bulkUpdateUsers = $action({
|
|
748
|
-
* method: "POST",
|
|
749
|
-
* path: "/admin/users/bulk-update",
|
|
750
|
-
* description: "Bulk update user properties",
|
|
751
|
-
* security: { permissions: ["admin:users:write"] },
|
|
752
|
-
* schema: {
|
|
753
|
-
* body: t.object({
|
|
754
|
-
* userIds: t.array(t.string(), { minItems: 1, maxItems: 1000 }),
|
|
755
|
-
* updates: t.object({
|
|
756
|
-
* status: t.optional(t.union([t.literal("active"), t.literal("inactive")])),
|
|
757
|
-
* role: t.optional(t.string()),
|
|
758
|
-
* tags: t.optional(t.array(t.string())),
|
|
759
|
-
* customFields: t.optional(t.record(t.string(), t.any()))
|
|
760
|
-
* }),
|
|
761
|
-
* reason: t.string({ minLength: 10, maxLength: 500 })
|
|
762
|
-
* }),
|
|
763
|
-
* response: t.object({
|
|
764
|
-
* updated: t.number(),
|
|
765
|
-
* failed: t.number(),
|
|
766
|
-
* errors: t.array(t.object({
|
|
767
|
-
* userId: t.string(),
|
|
768
|
-
* error: t.string()
|
|
769
|
-
* })),
|
|
770
|
-
* auditLogId: t.string()
|
|
771
|
-
* })
|
|
772
|
-
* },
|
|
773
|
-
* handler: async ({ body, user }) => {
|
|
774
|
-
* const results = { updated: 0, failed: 0, errors: [] };
|
|
775
|
-
*
|
|
776
|
-
* // Create audit log entry
|
|
777
|
-
* const auditLogId = await this.auditService.logBulkOperation({
|
|
778
|
-
* operation: "bulk_user_update",
|
|
779
|
-
* initiatedBy: user.id,
|
|
780
|
-
* targetCount: body.userIds.length,
|
|
781
|
-
* reason: body.reason,
|
|
782
|
-
* changes: body.updates
|
|
783
|
-
* });
|
|
784
|
-
*
|
|
785
|
-
* // Process in batches to avoid overwhelming the database
|
|
786
|
-
* const batchSize = 50;
|
|
787
|
-
* for (let i = 0; i < body.userIds.length; i += batchSize) {
|
|
788
|
-
* const batch = body.userIds.slice(i, i + batchSize);
|
|
789
|
-
*
|
|
790
|
-
* try {
|
|
791
|
-
* const updateResult = await this.userService.bulkUpdate(batch, body.updates);
|
|
792
|
-
* results.updated += updateResult.success;
|
|
793
|
-
* results.failed += updateResult.failed;
|
|
794
|
-
* results.errors.push(...updateResult.errors);
|
|
795
|
-
* } catch (error) {
|
|
796
|
-
* // Log batch failure but continue processing
|
|
797
|
-
* this.logger.error(`Bulk update batch failed`, {
|
|
798
|
-
* batch: i / batchSize + 1,
|
|
799
|
-
* userIds: batch,
|
|
800
|
-
* error: error.message
|
|
801
|
-
* });
|
|
802
|
-
*
|
|
803
|
-
* results.failed += batch.length;
|
|
804
|
-
* results.errors.push(...batch.map(userId => ({
|
|
805
|
-
* userId,
|
|
806
|
-
* error: error.message
|
|
807
|
-
* })));
|
|
808
|
-
* }
|
|
809
|
-
* }
|
|
810
|
-
*
|
|
811
|
-
* // Update audit log with results
|
|
812
|
-
* await this.auditService.updateBulkOperationResults(auditLogId, results);
|
|
813
|
-
*
|
|
814
|
-
* return { ...results, auditLogId };
|
|
815
|
-
* }
|
|
816
|
-
* });
|
|
817
|
-
* }
|
|
818
|
-
* ```
|
|
819
|
-
*
|
|
820
465
|
* **Important Notes**:
|
|
821
466
|
* - Actions are automatically registered with the HTTP server when the service is initialized
|
|
822
467
|
* - Use `run()` for direct invocation (testing, internal calls, or remote services)
|
|
@@ -824,12 +469,9 @@ interface HttpAction {
|
|
|
824
469
|
* - Schema validation occurs automatically for all requests and responses
|
|
825
470
|
* - Path parameters are automatically extracted from schema definitions
|
|
826
471
|
* - Content-Type headers are automatically set based on schema types
|
|
827
|
-
* - Actions can be disabled via the `disabled` option for maintenance or feature flags
|
|
828
|
-
*
|
|
829
|
-
* @stability 2
|
|
830
472
|
*/
|
|
831
473
|
declare const $action: {
|
|
832
|
-
<TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>):
|
|
474
|
+
<TConfig extends RequestConfigSchema>(options: ActionDescriptorOptions<TConfig>): ActionDescriptorFn<TConfig>;
|
|
833
475
|
[KIND]: typeof ActionDescriptor;
|
|
834
476
|
};
|
|
835
477
|
interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends Omit<ServerRoute, "handler" | "path" | "schema" | "mapParams"> {
|
|
@@ -899,7 +541,7 @@ interface ActionDescriptorOptions<TConfig extends RequestConfigSchema> extends O
|
|
|
899
541
|
handler: ServerActionHandler<TConfig>;
|
|
900
542
|
}
|
|
901
543
|
declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Descriptor<ActionDescriptorOptions<TConfig>> {
|
|
902
|
-
protected readonly log:
|
|
544
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
903
545
|
protected readonly env: {
|
|
904
546
|
SERVER_API_PREFIX: string;
|
|
905
547
|
};
|
|
@@ -939,12 +581,15 @@ declare class ActionDescriptor<TConfig extends RequestConfigSchema> extends Desc
|
|
|
939
581
|
*/
|
|
940
582
|
fetch(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<FetchResponse<ClientRequestResponse<TConfig>>>;
|
|
941
583
|
}
|
|
584
|
+
interface ActionDescriptorFn<TConfig extends RequestConfigSchema> extends ActionDescriptor<TConfig> {
|
|
585
|
+
(config?: ClientRequestEntry<TConfig>, options?: ClientRequestOptions): Promise<ClientRequestResponse<TConfig>>;
|
|
586
|
+
}
|
|
942
587
|
type ClientRequestEntry<TConfig extends RequestConfigSchema, T = ClientRequestEntryContainer<TConfig>> = { [K in keyof T as T[K] extends undefined ? never : K]: T[K] };
|
|
943
588
|
type ClientRequestEntryContainer<TConfig extends RequestConfigSchema> = {
|
|
944
|
-
body: TConfig["body"] extends
|
|
945
|
-
params: TConfig["params"] extends
|
|
946
|
-
headers?: TConfig["headers"] extends
|
|
947
|
-
query?: TConfig["query"] extends
|
|
589
|
+
body: TConfig["body"] extends TObject ? Static<TConfig["body"]> : undefined;
|
|
590
|
+
params: TConfig["params"] extends TObject ? Static<TConfig["params"]> : undefined;
|
|
591
|
+
headers?: TConfig["headers"] extends TObject ? Static<TConfig["headers"]> : undefined;
|
|
592
|
+
query?: TConfig["query"] extends TObject ? Partial<Static<TConfig["query"]>> : undefined;
|
|
948
593
|
};
|
|
949
594
|
interface ClientRequestOptions extends FetchOptions {
|
|
950
595
|
/**
|
|
@@ -1068,9 +713,9 @@ declare const okSchema: typebox0.TObject<{
|
|
|
1068
713
|
type Ok = Static<typeof okSchema>;
|
|
1069
714
|
//#endregion
|
|
1070
715
|
//#region src/providers/NodeHttpServerProvider.d.ts
|
|
1071
|
-
declare const envSchema:
|
|
1072
|
-
SERVER_PORT:
|
|
1073
|
-
SERVER_HOST:
|
|
716
|
+
declare const envSchema: _alepha_core11.TObject<{
|
|
717
|
+
SERVER_PORT: _alepha_core11.TInteger;
|
|
718
|
+
SERVER_HOST: _alepha_core11.TString;
|
|
1074
719
|
}>;
|
|
1075
720
|
declare module "alepha" {
|
|
1076
721
|
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
@@ -1078,31 +723,31 @@ declare module "alepha" {
|
|
|
1078
723
|
declare class NodeHttpServerProvider extends ServerProvider {
|
|
1079
724
|
protected readonly alepha: Alepha;
|
|
1080
725
|
protected readonly dateTimeProvider: DateTimeProvider;
|
|
1081
|
-
protected readonly log:
|
|
726
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
1082
727
|
protected readonly env: {
|
|
1083
728
|
SERVER_PORT: number;
|
|
1084
729
|
SERVER_HOST: string;
|
|
1085
730
|
};
|
|
1086
731
|
protected readonly router: ServerRouterProvider;
|
|
1087
732
|
protected readonly server: http0.Server<typeof IncomingMessage, typeof ServerResponse$1>;
|
|
1088
|
-
protected readonly onNodeRequest:
|
|
733
|
+
protected readonly onNodeRequest: _alepha_core11.HookDescriptor<"node:request">;
|
|
1089
734
|
handle(req: IncomingMessage, res: ServerResponse$1): Promise<void>;
|
|
1090
735
|
createRouterRequest(req: IncomingMessage, res: ServerResponse$1, params?: Record<string, string>): ServerRawRequest;
|
|
1091
736
|
getProtocol(req: IncomingMessage): "http" | "https";
|
|
1092
737
|
get hostname(): string;
|
|
1093
|
-
readonly start:
|
|
1094
|
-
protected readonly stop:
|
|
738
|
+
readonly start: _alepha_core11.HookDescriptor<"start">;
|
|
739
|
+
protected readonly stop: _alepha_core11.HookDescriptor<"stop">;
|
|
1095
740
|
protected listen(): Promise<void>;
|
|
1096
741
|
protected close(): Promise<void>;
|
|
1097
742
|
}
|
|
1098
743
|
//#endregion
|
|
1099
744
|
//#region src/providers/ServerLoggerProvider.d.ts
|
|
1100
745
|
declare class ServerLoggerProvider {
|
|
1101
|
-
protected readonly log:
|
|
746
|
+
protected readonly log: _alepha_logger3.Logger;
|
|
1102
747
|
protected readonly alepha: Alepha;
|
|
1103
|
-
readonly onRequest:
|
|
1104
|
-
readonly onError:
|
|
1105
|
-
readonly onResponse:
|
|
748
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
749
|
+
readonly onError: _alepha_core11.HookDescriptor<"server:onError">;
|
|
750
|
+
readonly onResponse: _alepha_core11.HookDescriptor<"server:onResponse">;
|
|
1106
751
|
}
|
|
1107
752
|
//#endregion
|
|
1108
753
|
//#region src/providers/ServerNotReadyProvider.d.ts
|
|
@@ -1115,7 +760,7 @@ declare class ServerLoggerProvider {
|
|
|
1115
760
|
*/
|
|
1116
761
|
declare class ServerNotReadyProvider {
|
|
1117
762
|
protected readonly alepha: Alepha;
|
|
1118
|
-
readonly onRequest:
|
|
763
|
+
readonly onRequest: _alepha_core11.HookDescriptor<"server:onRequest">;
|
|
1119
764
|
}
|
|
1120
765
|
//#endregion
|
|
1121
766
|
//#region src/index.d.ts
|
|
@@ -1183,7 +828,7 @@ declare module "alepha" {
|
|
|
1183
828
|
* @see {@link $action}
|
|
1184
829
|
* @module alepha.server
|
|
1185
830
|
*/
|
|
1186
|
-
declare const AlephaServer:
|
|
831
|
+
declare const AlephaServer: _alepha_core11.Service<_alepha_core11.Module<{}>>;
|
|
1187
832
|
//#endregion
|
|
1188
|
-
export { $action, $route, ActionDescriptor, ActionDescriptorOptions, AlephaServer, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, ErrorSchema, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionHandler, ServerActionRequest, ServerHandler, ServerLoggerProvider, ServerNotReadyProvider, ServerProvider, ServerRawRequest, ServerReply, ServerRequest, ServerRequestConfig, ServerRequestConfigEntry, ServerResponse, ServerResponseBody, ServerRoute, ServerRouteMatcher, ServerRouteRequestHandler, ServerRouterProvider, ServerTimingProvider, TRequestBody, TResponseBody, UnauthorizedError, ValidationError, errorNameByStatus, errorSchema, isHttpError, isMultipart, okSchema, routeMethods };
|
|
833
|
+
export { $action, $route, ActionDescriptor, ActionDescriptorFn, ActionDescriptorOptions, AlephaServer, BadRequestError, ClientRequestEntry, ClientRequestEntryContainer, ClientRequestOptions, ClientRequestResponse, ConflictError, ErrorSchema, FetchActionArgs, FetchOptions, FetchResponse, ForbiddenError, HttpAction, HttpClient, HttpClientPendingRequests, HttpError, HttpErrorLike, NodeHttpServerProvider, NotFoundError, Ok, RequestConfigSchema, ResponseBodyType, ResponseKind, RouteDescriptor, RouteDescriptorOptions, RouteMethod, ServerActionHandler, ServerActionRequest, ServerHandler, ServerLoggerProvider, ServerNotReadyProvider, ServerProvider, ServerRawRequest, ServerReply, ServerRequest, ServerRequestConfig, ServerRequestConfigEntry, ServerResponse, ServerResponseBody, ServerRoute, ServerRouteMatcher, ServerRouteRequestHandler, ServerRouterProvider, ServerTimingProvider, TRequestBody, TResponseBody, UnauthorizedError, ValidationError, errorNameByStatus, errorSchema, isHttpError, isMultipart, okSchema, routeMethods };
|
|
1189
834
|
//# sourceMappingURL=index.d.ts.map
|
package/topic/redis.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ declare class RedisTopicProvider extends TopicProvider {
|
|
|
36
36
|
* @see {@link RedisTopicProvider}
|
|
37
37
|
* @module alepha.topic.redis
|
|
38
38
|
*/
|
|
39
|
-
declare const AlephaTopicRedis: _alepha_core1.Service<_alepha_core1.Module
|
|
39
|
+
declare const AlephaTopicRedis: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
40
40
|
//#endregion
|
|
41
41
|
export { AlephaTopicRedis, RedisTopicProvider };
|
|
42
42
|
//# sourceMappingURL=index.d.ts.map
|
package/topic.d.ts
CHANGED
|
@@ -948,7 +948,7 @@ declare class MemoryTopicProvider extends TopicProvider {
|
|
|
948
948
|
* @see {@link $subscriber}
|
|
949
949
|
* @module alepha.topic
|
|
950
950
|
*/
|
|
951
|
-
declare const AlephaTopic: _alepha_core1.Service<_alepha_core1.Module
|
|
951
|
+
declare const AlephaTopic: _alepha_core1.Service<_alepha_core1.Module<{}>>;
|
|
952
952
|
//#endregion
|
|
953
953
|
export { $subscriber, $topic, AlephaTopic, MemoryTopicProvider, SubscribeCallback, SubscriberDescriptor, SubscriberDescriptorOptions, TopicDescriptor, TopicDescriptorOptions, TopicHandler, TopicMessage, TopicMessageSchema, TopicProvider, TopicTimeoutError, TopicWaitOptions, UnSubscribeFn };
|
|
954
954
|
//# sourceMappingURL=index.d.ts.map
|