@stone-js/aws-lambda-http-adapter 0.1.0 → 0.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.
@@ -0,0 +1,68 @@
1
+ import { IntegrationError, classDecoratorLegacyWrapper } from '@stone-js/core';
2
+
3
+ /**
4
+ * A constant representing the AWS Lambda HTTP platform identifier.
5
+ *
6
+ * This constant is used as an alias for the AWS Lambda HTTP Adapter within the Stone.js framework.
7
+ * It helps in identifying and configuring platform-specific adapters or components for handling
8
+ * HTTP requests and responses.
9
+ */
10
+ const AWS_LAMBDA_HTTP_PLATFORM = 'aws_lambda_http';
11
+
12
+ /**
13
+ * Custom error for AWS Lambda adapter operations.
14
+ */
15
+ class AwsLambdaHttpAdapterError extends IntegrationError {
16
+ constructor(message, options) {
17
+ super(message, options);
18
+ this.name = 'AwsLambdaHttpAdapterError';
19
+ }
20
+ }
21
+
22
+ /**
23
+ * A Stone.js decorator that integrates the AWS Lambda HTTP Adapter with a class.
24
+ *
25
+ * This decorator modifies the class to seamlessly enable AWS Lambda HTTP as the
26
+ * execution environment for a Stone.js application. By applying this decorator,
27
+ * the class is automatically configured with the necessary blueprint for AWS Lambda HTTP.
28
+ *
29
+ * NB: This decorator is stubbed for browser environments compatibility and does not
30
+ * perform any actual functionality in the browser. It is intended for use in Node.js environments
31
+ * where the Node.js HTTP adapter is applicable.
32
+ *
33
+ * @template T - The type of the class being decorated. Defaults to `ClassType`.
34
+ * @param options - Optional configuration to customize the AWS Lambda HTTP Adapter.
35
+ *
36
+ * @returns A class decorator that applies the AWS Lambda HTTP adapter configuration.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { AwsLambdaHttp } from '@stone-js/aws-lambda-http-adapter';
41
+ *
42
+ * @AwsLambdaHttp({
43
+ * alias: 'MyAwsLambdaHttpAdapter',
44
+ * current: true,
45
+ * })
46
+ * class App {
47
+ * // Your application logic here
48
+ * }
49
+ * ```
50
+ */
51
+ const AwsLambdaHttp = (_options = {}) => {
52
+ return classDecoratorLegacyWrapper((_target, _context) => { });
53
+ };
54
+
55
+ /**
56
+ * Default blueprint configuration for the AWS Lambda Http Adapter.
57
+ *
58
+ * This blueprint defines the initial configuration for the AWS Lambda Http adapter
59
+ * within the Stone.js framework. It includes:
60
+ * - An alias for the AWS Lambda platform (`AWS_LAMBDA_HTTP_PLATFORM`).
61
+ * - A default resolver function (currently a placeholder).
62
+ * - Middleware, hooks, and state flags (`current`, `default`, `preferred`).
63
+ *
64
+ * NB: This is a stub for browser environments and does not perform any actual functionality in the browser.
65
+ */
66
+ const awsLambdaHttpAdapterBlueprint = { stone: { http: {}, adapters: [] } };
67
+
68
+ export { AWS_LAMBDA_HTTP_PLATFORM, AwsLambdaHttp, AwsLambdaHttpAdapterError, awsLambdaHttpAdapterBlueprint };
package/dist/index.d.ts CHANGED
@@ -460,50 +460,6 @@ declare const MetaBodyEventMiddleware: {
460
460
  isClass: boolean;
461
461
  };
462
462
 
463
- /**
464
- * Class representing a FilesEventMiddleware.
465
- *
466
- * @author Mr. Stone <evensstone@gmail.com>
467
- */
468
- declare class FilesEventMiddleware {
469
- /**
470
- * The blueprint for resolving configuration and dependencies.
471
- */
472
- private readonly blueprint;
473
- /**
474
- * Create a FilesEventMiddleware.
475
- *
476
- * @param {blueprint} options - Options for creating the FilesEventMiddleware.
477
- */
478
- constructor({ blueprint }: {
479
- blueprint: IBlueprint;
480
- });
481
- /**
482
- * Handles the incoming event, processes it, and invokes the next middleware in the pipeline.
483
- *
484
- * @param context - The adapter context containing the raw event, execution context, and other data.
485
- * @param next - The next middleware to be invoked in the pipeline.
486
- * @returns A promise that resolves to the destination type after processing.
487
- *
488
- * @throws {AwsLambdaHttpAdapterError} If required components such as the rawEvent or IncomingEventBuilder are not provided.
489
- */
490
- handle(context: AwsLambdaHttpAdapterContext, next: NextMiddleware<AwsLambdaHttpAdapterContext, AwsLambdaHttpAdapterResponseBuilder>): Promise<AwsLambdaHttpAdapterResponseBuilder>;
491
- /**
492
- * Normalize the incoming event to an IncomingMessage.
493
- *
494
- * @param rawEvent - The raw event to be normalized.
495
- * @returns The normalized event.
496
- */
497
- private normalizeEvent;
498
- }
499
- /**
500
- * Meta Middleware for processing files uploads.
501
- */
502
- declare const MetaFilesEventMiddleware: {
503
- module: typeof FilesEventMiddleware;
504
- isClass: boolean;
505
- };
506
-
507
463
  /**
508
464
  * Middleware for handling incoming events and transforming them into Stone.js events.
509
465
  *
@@ -611,6 +567,50 @@ declare const MetaIncomingEventMiddleware: {
611
567
  isClass: boolean;
612
568
  };
613
569
 
570
+ /**
571
+ * Class representing a FilesEventMiddleware.
572
+ *
573
+ * @author Mr. Stone <evensstone@gmail.com>
574
+ */
575
+ declare class FilesEventMiddleware {
576
+ /**
577
+ * The blueprint for resolving configuration and dependencies.
578
+ */
579
+ private readonly blueprint;
580
+ /**
581
+ * Create a FilesEventMiddleware.
582
+ *
583
+ * @param {blueprint} options - Options for creating the FilesEventMiddleware.
584
+ */
585
+ constructor({ blueprint }: {
586
+ blueprint: IBlueprint;
587
+ });
588
+ /**
589
+ * Handles the incoming event, processes it, and invokes the next middleware in the pipeline.
590
+ *
591
+ * @param context - The adapter context containing the raw event, execution context, and other data.
592
+ * @param next - The next middleware to be invoked in the pipeline.
593
+ * @returns A promise that resolves to the destination type after processing.
594
+ *
595
+ * @throws {AwsLambdaHttpAdapterError} If required components such as the rawEvent or IncomingEventBuilder are not provided.
596
+ */
597
+ handle(context: AwsLambdaHttpAdapterContext, next: NextMiddleware<AwsLambdaHttpAdapterContext, AwsLambdaHttpAdapterResponseBuilder>): Promise<AwsLambdaHttpAdapterResponseBuilder>;
598
+ /**
599
+ * Normalize the incoming event to an IncomingMessage.
600
+ *
601
+ * @param rawEvent - The raw event to be normalized.
602
+ * @returns The normalized event.
603
+ */
604
+ private normalizeEvent;
605
+ }
606
+ /**
607
+ * Meta Middleware for processing files uploads.
608
+ */
609
+ declare const MetaFilesEventMiddleware: {
610
+ module: typeof FilesEventMiddleware;
611
+ isClass: boolean;
612
+ };
613
+
614
614
  /**
615
615
  * Middleware for handling server responses and transforming them into the appropriate HTTP responses.
616
616
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stone-js/aws-lambda-http-adapter",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Official AWS Lambda HTTP adapter for Stone.js. Run your Stone.js apps on AWS Lambda behind API Gateway with full Continuum lifecycle support.",
5
5
  "author": "Mr. Stone <evensstone@gmail.com>",
6
6
  "license": "MIT",
@@ -34,12 +34,18 @@
34
34
  "types": "./dist/index.d.ts",
35
35
  "exports": {
36
36
  ".": {
37
- "types": "./dist/index.d.ts",
38
- "default": "./dist/index.js"
37
+ "browser": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/browser.js"
40
+ },
41
+ "default": {
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.js"
44
+ }
39
45
  }
40
46
  },
41
47
  "engines": {
42
- "node": ">=18.0.0"
48
+ "node": ">=18.17.0"
43
49
  },
44
50
  "scripts": {
45
51
  "lint": "ts-standard src",