@walkeros/server-source-aws 0.0.0-next-20251219153324
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/CHANGELOG.md +44 -0
- package/README.md +321 -0
- package/dist/index.d.mts +223 -0
- package/dist/index.d.ts +223 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @walkeros/server-source-aws
|
|
2
|
+
|
|
3
|
+
## 0.0.0-next-20251219153324
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [5163b01]
|
|
8
|
+
- @walkeros/core@0.0.0-next-20251219153324
|
|
9
|
+
|
|
10
|
+
## 0.5.1-next.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [5163b01]
|
|
15
|
+
- @walkeros/core@0.5.1-next.0
|
|
16
|
+
|
|
17
|
+
## 0.5.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- just flow
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @walkeros/core@0.5.0
|
|
27
|
+
|
|
28
|
+
## 0.4.2
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Initial release of AWS Lambda source
|
|
33
|
+
- Support for API Gateway v1, v2, and Function URLs
|
|
34
|
+
- CORS configuration (default and custom)
|
|
35
|
+
- GET pixel tracking with 1x1 GIF
|
|
36
|
+
- POST event ingestion
|
|
37
|
+
- Health check endpoint
|
|
38
|
+
- Request ID tracking
|
|
39
|
+
- Logging integration
|
|
40
|
+
- Zod schema validation
|
|
41
|
+
- Base64 body decoding
|
|
42
|
+
- TypeScript type safety
|
|
43
|
+
- Updated dependencies
|
|
44
|
+
- @walkeros/core@0.4.2
|
package/README.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# @walkeros/server-source-aws
|
|
2
|
+
|
|
3
|
+
AWS server sources for walkerOS - lightweight, single-purpose runtime adapters
|
|
4
|
+
for AWS services.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @walkeros/server-source-aws @types/aws-lambda
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { sourceLambda, type SourceLambda } from '@walkeros/server-source-aws';
|
|
16
|
+
import { startFlow } from '@walkeros/collector';
|
|
17
|
+
|
|
18
|
+
const { elb } = await startFlow<SourceLambda.Push>({
|
|
19
|
+
sources: { lambda: { code: sourceLambda } },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const handler = elb;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Lambda Source
|
|
28
|
+
|
|
29
|
+
The Lambda source provides an HTTP handler that receives walker events and
|
|
30
|
+
forwards them to the walkerOS collector. Works with API Gateway v1 (REST API),
|
|
31
|
+
v2 (HTTP API), and Lambda Function URLs.
|
|
32
|
+
|
|
33
|
+
### Basic Usage
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { sourceLambda, type SourceLambda } from '@walkeros/server-source-aws';
|
|
37
|
+
import { startFlow } from '@walkeros/collector';
|
|
38
|
+
|
|
39
|
+
// Handler singleton - reused across warm invocations
|
|
40
|
+
let handler: SourceLambda.Push;
|
|
41
|
+
|
|
42
|
+
async function setup() {
|
|
43
|
+
if (handler) return handler;
|
|
44
|
+
|
|
45
|
+
const { elb } = await startFlow<SourceLambda.Push>({
|
|
46
|
+
sources: {
|
|
47
|
+
lambda: {
|
|
48
|
+
code: sourceLambda,
|
|
49
|
+
config: {
|
|
50
|
+
settings: {
|
|
51
|
+
cors: true,
|
|
52
|
+
healthPath: '/health',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
destinations: {
|
|
58
|
+
// Your destinations
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
handler = elb;
|
|
63
|
+
return handler;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const main: SourceLambda.Push = async (event, context) => {
|
|
67
|
+
const h = await setup();
|
|
68
|
+
return h(event, context);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Export for Lambda runtime
|
|
72
|
+
export { main as handler };
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Deployment
|
|
76
|
+
|
|
77
|
+
#### Lambda Function URL (Simplest)
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// No API Gateway needed
|
|
81
|
+
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
82
|
+
|
|
83
|
+
const fn = new lambda.Function(this, 'Walker', {
|
|
84
|
+
runtime: lambda.Runtime.NODEJS_20_X,
|
|
85
|
+
handler: 'index.handler',
|
|
86
|
+
code: lambda.Code.fromAsset('./dist'),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
fn.addFunctionUrl({
|
|
90
|
+
authType: lambda.FunctionUrlAuthType.NONE,
|
|
91
|
+
cors: {
|
|
92
|
+
allowedOrigins: ['*'],
|
|
93
|
+
allowedMethods: [lambda.HttpMethod.GET, lambda.HttpMethod.POST],
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### API Gateway HTTP API (v2) - Recommended
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
# serverless.yml
|
|
102
|
+
service: walkeros-collector
|
|
103
|
+
|
|
104
|
+
provider:
|
|
105
|
+
name: aws
|
|
106
|
+
runtime: nodejs20.x
|
|
107
|
+
memorySize: 256
|
|
108
|
+
timeout: 30
|
|
109
|
+
|
|
110
|
+
functions:
|
|
111
|
+
collector:
|
|
112
|
+
handler: dist/index.handler
|
|
113
|
+
events:
|
|
114
|
+
- httpApi:
|
|
115
|
+
path: /collect
|
|
116
|
+
method: post
|
|
117
|
+
- httpApi:
|
|
118
|
+
path: /collect
|
|
119
|
+
method: get
|
|
120
|
+
- httpApi:
|
|
121
|
+
path: /health
|
|
122
|
+
method: get
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### API Gateway REST API (v1)
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
# template.yaml (AWS SAM)
|
|
129
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
|
130
|
+
Transform: AWS::Serverless-2016-10-31
|
|
131
|
+
|
|
132
|
+
Resources:
|
|
133
|
+
WalkerFunction:
|
|
134
|
+
Type: AWS::Serverless::Function
|
|
135
|
+
Properties:
|
|
136
|
+
CodeUri: ./dist
|
|
137
|
+
Handler: index.handler
|
|
138
|
+
Runtime: nodejs20.x
|
|
139
|
+
Architectures: [arm64]
|
|
140
|
+
Events:
|
|
141
|
+
CollectPost:
|
|
142
|
+
Type: Api
|
|
143
|
+
Properties:
|
|
144
|
+
Path: /collect
|
|
145
|
+
Method: POST
|
|
146
|
+
CollectGet:
|
|
147
|
+
Type: Api
|
|
148
|
+
Properties:
|
|
149
|
+
Path: /collect
|
|
150
|
+
Method: GET
|
|
151
|
+
Health:
|
|
152
|
+
Type: Api
|
|
153
|
+
Properties:
|
|
154
|
+
Path: /health
|
|
155
|
+
Method: GET
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Configuration Options
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
interface Settings {
|
|
162
|
+
cors?: boolean | CorsOptions; // Enable CORS (default: true)
|
|
163
|
+
timeout?: number; // Request timeout (default: 30000ms, max: 900000ms)
|
|
164
|
+
enablePixelTracking?: boolean; // Enable GET tracking (default: true)
|
|
165
|
+
healthPath?: string; // Health check path (default: '/health')
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface CorsOptions {
|
|
169
|
+
origin?: string | string[]; // Allowed origins
|
|
170
|
+
methods?: string[]; // Allowed methods
|
|
171
|
+
headers?: string[]; // Allowed headers
|
|
172
|
+
credentials?: boolean; // Allow credentials
|
|
173
|
+
maxAge?: number; // Preflight cache time
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Request Format
|
|
178
|
+
|
|
179
|
+
**POST - Single Event:**
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"event": "page view",
|
|
184
|
+
"data": {
|
|
185
|
+
"title": "Home Page",
|
|
186
|
+
"path": "/"
|
|
187
|
+
},
|
|
188
|
+
"context": {
|
|
189
|
+
"stage": ["prod", 1]
|
|
190
|
+
},
|
|
191
|
+
"user": {
|
|
192
|
+
"id": "user-123"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**GET - Pixel Tracking:**
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
GET /collect?event=page%20view&data[title]=Home&data[path]=/
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Response Format
|
|
204
|
+
|
|
205
|
+
**Success:**
|
|
206
|
+
|
|
207
|
+
```json
|
|
208
|
+
{
|
|
209
|
+
"success": true,
|
|
210
|
+
"id": "event-id-123",
|
|
211
|
+
"requestId": "aws-request-id"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Error:**
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"success": false,
|
|
220
|
+
"error": "Invalid request format",
|
|
221
|
+
"requestId": "aws-request-id"
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Health Check:**
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"status": "ok",
|
|
230
|
+
"timestamp": 1733328000000,
|
|
231
|
+
"source": "lambda",
|
|
232
|
+
"requestId": "aws-request-id"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Supported Platforms
|
|
237
|
+
|
|
238
|
+
- ✅ AWS API Gateway REST API (v1)
|
|
239
|
+
- ✅ AWS API Gateway HTTP API (v2)
|
|
240
|
+
- ✅ Lambda Function URLs
|
|
241
|
+
- ✅ Direct Lambda invocation
|
|
242
|
+
|
|
243
|
+
### Features
|
|
244
|
+
|
|
245
|
+
- **Auto-detection**: Automatically detects API Gateway version
|
|
246
|
+
- **CORS**: Configurable CORS with defaults
|
|
247
|
+
- **Pixel Tracking**: Optional GET requests with 1x1 GIF response
|
|
248
|
+
- **Base64 Decoding**: Handles base64-encoded request bodies
|
|
249
|
+
- **Health Checks**: Built-in health check endpoint
|
|
250
|
+
- **Request IDs**: AWS request ID in all responses and logs
|
|
251
|
+
- **Logging**: Integrated with walkerOS logger
|
|
252
|
+
- **Type-Safe**: Full TypeScript support
|
|
253
|
+
|
|
254
|
+
### Production Considerations
|
|
255
|
+
|
|
256
|
+
#### Cold Starts
|
|
257
|
+
|
|
258
|
+
Use handler singleton pattern (shown in Basic Usage) to reuse source instance
|
|
259
|
+
across warm invocations.
|
|
260
|
+
|
|
261
|
+
#### Logging
|
|
262
|
+
|
|
263
|
+
The source integrates with the walkerOS logger from `env.logger`. Configure
|
|
264
|
+
CloudWatch Logs:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { createLogger } from '@walkeros/core';
|
|
268
|
+
|
|
269
|
+
const logger = createLogger({
|
|
270
|
+
level: 'info',
|
|
271
|
+
// CloudWatch-friendly JSON output
|
|
272
|
+
format: (level, message, meta) =>
|
|
273
|
+
JSON.stringify({ level, message, ...meta, timestamp: Date.now() }),
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### Error Handling
|
|
278
|
+
|
|
279
|
+
All errors include request IDs for tracing. Configure CloudWatch Insights
|
|
280
|
+
queries:
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
fields @timestamp, level, message, requestId, error
|
|
284
|
+
| filter level = "error"
|
|
285
|
+
| sort @timestamp desc
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
#### Monitoring
|
|
289
|
+
|
|
290
|
+
Key metrics to track:
|
|
291
|
+
|
|
292
|
+
- Lambda Duration (p50, p99)
|
|
293
|
+
- Lambda Errors
|
|
294
|
+
- Lambda Throttles
|
|
295
|
+
- API Gateway 4xx/5xx responses
|
|
296
|
+
|
|
297
|
+
#### Security
|
|
298
|
+
|
|
299
|
+
- Use API Gateway with API keys or AWS IAM for authentication
|
|
300
|
+
- Enable AWS WAF for DDoS protection
|
|
301
|
+
- Set Lambda reserved concurrency to prevent runaway costs
|
|
302
|
+
- Validate CORS origins in production (don't use `cors: true`)
|
|
303
|
+
|
|
304
|
+
### Examples
|
|
305
|
+
|
|
306
|
+
See [examples directory](./examples/) for:
|
|
307
|
+
|
|
308
|
+
- SAM deployment
|
|
309
|
+
- Serverless Framework deployment
|
|
310
|
+
- CDK deployment
|
|
311
|
+
- Local testing with SAM CLI
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
MIT
|
|
316
|
+
|
|
317
|
+
## Support
|
|
318
|
+
|
|
319
|
+
- [Documentation](https://www.walkeros.io/docs)
|
|
320
|
+
- [GitHub Issues](https://github.com/elbwalker/walkerOS/issues)
|
|
321
|
+
- [Discord Community](https://discord.gg/elbwalker)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { Source, WalkerOS } from '@walkeros/core';
|
|
2
|
+
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context, APIGatewayProxyResult } from 'aws-lambda';
|
|
3
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
4
|
+
import { z } from '@walkeros/core/dev';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* HTTP methods enum
|
|
8
|
+
*/
|
|
9
|
+
declare const HttpMethod: z.ZodEnum<{
|
|
10
|
+
GET: "GET";
|
|
11
|
+
POST: "POST";
|
|
12
|
+
PUT: "PUT";
|
|
13
|
+
PATCH: "PATCH";
|
|
14
|
+
DELETE: "DELETE";
|
|
15
|
+
OPTIONS: "OPTIONS";
|
|
16
|
+
HEAD: "HEAD";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* CORS origin configuration
|
|
20
|
+
* Accepts:
|
|
21
|
+
* - '*' for all origins
|
|
22
|
+
* - Single URL string
|
|
23
|
+
* - Array of URL strings
|
|
24
|
+
*/
|
|
25
|
+
declare const CorsOrigin: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>;
|
|
26
|
+
/**
|
|
27
|
+
* CORS options schema
|
|
28
|
+
* Configuration for Cross-Origin Resource Sharing
|
|
29
|
+
*/
|
|
30
|
+
declare const CorsOptionsSchema: z.ZodObject<{
|
|
31
|
+
origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
|
|
32
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
33
|
+
GET: "GET";
|
|
34
|
+
POST: "POST";
|
|
35
|
+
PUT: "PUT";
|
|
36
|
+
PATCH: "PATCH";
|
|
37
|
+
DELETE: "DELETE";
|
|
38
|
+
OPTIONS: "OPTIONS";
|
|
39
|
+
HEAD: "HEAD";
|
|
40
|
+
}>>>;
|
|
41
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
credentials: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
type CorsOptions$1 = z.infer<typeof CorsOptionsSchema>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* AWS Lambda source settings schema
|
|
49
|
+
*/
|
|
50
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
51
|
+
cors: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
52
|
+
origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
|
|
53
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
54
|
+
GET: "GET";
|
|
55
|
+
POST: "POST";
|
|
56
|
+
PUT: "PUT";
|
|
57
|
+
PATCH: "PATCH";
|
|
58
|
+
DELETE: "DELETE";
|
|
59
|
+
OPTIONS: "OPTIONS";
|
|
60
|
+
HEAD: "HEAD";
|
|
61
|
+
}>>>;
|
|
62
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
credentials: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>]>>;
|
|
66
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
67
|
+
enablePixelTracking: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
healthPath: z.ZodDefault<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
71
|
+
|
|
72
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
73
|
+
|
|
74
|
+
declare const index$1_CorsOptionsSchema: typeof CorsOptionsSchema;
|
|
75
|
+
declare const index$1_CorsOrigin: typeof CorsOrigin;
|
|
76
|
+
declare const index$1_HttpMethod: typeof HttpMethod;
|
|
77
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
78
|
+
declare const index$1_settings: typeof settings;
|
|
79
|
+
declare namespace index$1 {
|
|
80
|
+
export { type CorsOptions$1 as CorsOptions, index$1_CorsOptionsSchema as CorsOptionsSchema, index$1_CorsOrigin as CorsOrigin, index$1_HttpMethod as HttpMethod, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
84
|
+
type LambdaResult = APIGatewayProxyResult;
|
|
85
|
+
type LambdaContext = Context;
|
|
86
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
87
|
+
type CorsOptions = z.infer<typeof CorsOptionsSchema>;
|
|
88
|
+
type InitSettings = Partial<Settings>;
|
|
89
|
+
interface Mapping {
|
|
90
|
+
}
|
|
91
|
+
type Push = (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResult>;
|
|
92
|
+
interface Env extends Source.Env {
|
|
93
|
+
lambdaEvent?: LambdaEvent;
|
|
94
|
+
lambdaContext?: LambdaContext;
|
|
95
|
+
}
|
|
96
|
+
type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;
|
|
97
|
+
interface LambdaSource extends Omit<Source.Instance<Types>, 'push'> {
|
|
98
|
+
push: Push;
|
|
99
|
+
}
|
|
100
|
+
type Config = Source.Config<Types>;
|
|
101
|
+
type PartialConfig = Source.PartialConfig<Types>;
|
|
102
|
+
interface EventRequest {
|
|
103
|
+
event: string;
|
|
104
|
+
data?: WalkerOS.AnyObject;
|
|
105
|
+
context?: WalkerOS.AnyObject;
|
|
106
|
+
user?: WalkerOS.AnyObject;
|
|
107
|
+
globals?: WalkerOS.AnyObject;
|
|
108
|
+
consent?: WalkerOS.AnyObject;
|
|
109
|
+
}
|
|
110
|
+
interface EventResponse {
|
|
111
|
+
success: boolean;
|
|
112
|
+
id?: string;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
type RequestBody = EventRequest;
|
|
116
|
+
type ResponseBody = EventResponse;
|
|
117
|
+
interface ParsedRequest {
|
|
118
|
+
method: string;
|
|
119
|
+
body: unknown;
|
|
120
|
+
queryString: string | null;
|
|
121
|
+
headers: Record<string, string>;
|
|
122
|
+
isBase64Encoded: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type types_Config = Config;
|
|
126
|
+
type types_CorsOptions = CorsOptions;
|
|
127
|
+
type types_Env = Env;
|
|
128
|
+
type types_EventRequest = EventRequest;
|
|
129
|
+
type types_EventResponse = EventResponse;
|
|
130
|
+
type types_InitSettings = InitSettings;
|
|
131
|
+
type types_LambdaContext = LambdaContext;
|
|
132
|
+
type types_LambdaEvent = LambdaEvent;
|
|
133
|
+
type types_LambdaResult = LambdaResult;
|
|
134
|
+
type types_LambdaSource = LambdaSource;
|
|
135
|
+
type types_Mapping = Mapping;
|
|
136
|
+
type types_ParsedRequest = ParsedRequest;
|
|
137
|
+
type types_PartialConfig = PartialConfig;
|
|
138
|
+
type types_Push = Push;
|
|
139
|
+
type types_RequestBody = RequestBody;
|
|
140
|
+
type types_ResponseBody = ResponseBody;
|
|
141
|
+
type types_Settings = Settings;
|
|
142
|
+
type types_Types = Types;
|
|
143
|
+
declare namespace types {
|
|
144
|
+
export type { types_Config as Config, types_CorsOptions as CorsOptions, types_Env as Env, types_EventRequest as EventRequest, types_EventResponse as EventResponse, types_InitSettings as InitSettings, types_LambdaContext as LambdaContext, types_LambdaEvent as LambdaEvent, types_LambdaResult as LambdaResult, types_LambdaSource as LambdaSource, types_Mapping as Mapping, types_ParsedRequest as ParsedRequest, types_PartialConfig as PartialConfig, types_Push as Push, types_RequestBody as RequestBody, types_ResponseBody as ResponseBody, types_Settings as Settings, types_Types as Types };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Standard mock environment for testing Lambda source
|
|
149
|
+
*
|
|
150
|
+
* Use this for testing Lambda event ingestion and request/response handling
|
|
151
|
+
* without requiring a real AWS Lambda environment.
|
|
152
|
+
*/
|
|
153
|
+
declare const push: Env;
|
|
154
|
+
|
|
155
|
+
declare const env_push: typeof push;
|
|
156
|
+
declare namespace env {
|
|
157
|
+
export { env_push as push };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Real examples of Lambda events this source will receive.
|
|
162
|
+
* These define the CONTRACT - implementation must handle these inputs.
|
|
163
|
+
*/
|
|
164
|
+
declare const apiGatewayV2PostEvent: APIGatewayProxyEventV2;
|
|
165
|
+
declare const apiGatewayV2GetEvent: APIGatewayProxyEventV2;
|
|
166
|
+
declare const apiGatewayV1PostEvent: APIGatewayProxyEvent;
|
|
167
|
+
declare const healthCheckEvent: APIGatewayProxyEventV2;
|
|
168
|
+
declare const invalidJsonEvent: APIGatewayProxyEventV2;
|
|
169
|
+
declare const missingEventField: APIGatewayProxyEventV2;
|
|
170
|
+
|
|
171
|
+
declare const inputs_apiGatewayV1PostEvent: typeof apiGatewayV1PostEvent;
|
|
172
|
+
declare const inputs_apiGatewayV2GetEvent: typeof apiGatewayV2GetEvent;
|
|
173
|
+
declare const inputs_apiGatewayV2PostEvent: typeof apiGatewayV2PostEvent;
|
|
174
|
+
declare const inputs_healthCheckEvent: typeof healthCheckEvent;
|
|
175
|
+
declare const inputs_invalidJsonEvent: typeof invalidJsonEvent;
|
|
176
|
+
declare const inputs_missingEventField: typeof missingEventField;
|
|
177
|
+
declare namespace inputs {
|
|
178
|
+
export { inputs_apiGatewayV1PostEvent as apiGatewayV1PostEvent, inputs_apiGatewayV2GetEvent as apiGatewayV2GetEvent, inputs_apiGatewayV2PostEvent as apiGatewayV2PostEvent, inputs_healthCheckEvent as healthCheckEvent, inputs_invalidJsonEvent as invalidJsonEvent, inputs_missingEventField as missingEventField };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Expected walkerOS events from Lambda inputs.
|
|
183
|
+
* These are what processEvent should produce.
|
|
184
|
+
*/
|
|
185
|
+
declare const pageViewEvent: Partial<WalkerOS.Event>;
|
|
186
|
+
declare const buttonClickEvent: Partial<WalkerOS.Event>;
|
|
187
|
+
declare const productAddEvent: Partial<WalkerOS.Event>;
|
|
188
|
+
|
|
189
|
+
declare const events_buttonClickEvent: typeof buttonClickEvent;
|
|
190
|
+
declare const events_pageViewEvent: typeof pageViewEvent;
|
|
191
|
+
declare const events_productAddEvent: typeof productAddEvent;
|
|
192
|
+
declare namespace events {
|
|
193
|
+
export { events_buttonClickEvent as buttonClickEvent, events_pageViewEvent as pageViewEvent, events_productAddEvent as productAddEvent };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Expected Lambda response outputs.
|
|
198
|
+
* Tests verify implementation produces these.
|
|
199
|
+
*/
|
|
200
|
+
declare const successResponse: Partial<APIGatewayProxyResult>;
|
|
201
|
+
declare const healthResponse: Partial<APIGatewayProxyResult>;
|
|
202
|
+
declare const pixelResponse: Partial<APIGatewayProxyResult>;
|
|
203
|
+
declare const invalidBodyResponse: Partial<APIGatewayProxyResult>;
|
|
204
|
+
|
|
205
|
+
declare const outputs_healthResponse: typeof healthResponse;
|
|
206
|
+
declare const outputs_invalidBodyResponse: typeof invalidBodyResponse;
|
|
207
|
+
declare const outputs_pixelResponse: typeof pixelResponse;
|
|
208
|
+
declare const outputs_successResponse: typeof successResponse;
|
|
209
|
+
declare namespace outputs {
|
|
210
|
+
export { outputs_healthResponse as healthResponse, outputs_invalidBodyResponse as invalidBodyResponse, outputs_pixelResponse as pixelResponse, outputs_successResponse as successResponse };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare const index_env: typeof env;
|
|
214
|
+
declare const index_events: typeof events;
|
|
215
|
+
declare const index_inputs: typeof inputs;
|
|
216
|
+
declare const index_outputs: typeof outputs;
|
|
217
|
+
declare namespace index {
|
|
218
|
+
export { index_env as env, index_events as events, index_inputs as inputs, index_outputs as outputs };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare const sourceLambda: (config: Partial<Source.Config<Types>> | undefined, env: Env) => Promise<LambdaSource>;
|
|
222
|
+
|
|
223
|
+
export { types as SourceLambda, index as examples, index$1 as schemas, sourceLambda };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { Source, WalkerOS } from '@walkeros/core';
|
|
2
|
+
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context, APIGatewayProxyResult } from 'aws-lambda';
|
|
3
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
4
|
+
import { z } from '@walkeros/core/dev';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* HTTP methods enum
|
|
8
|
+
*/
|
|
9
|
+
declare const HttpMethod: z.ZodEnum<{
|
|
10
|
+
GET: "GET";
|
|
11
|
+
POST: "POST";
|
|
12
|
+
PUT: "PUT";
|
|
13
|
+
PATCH: "PATCH";
|
|
14
|
+
DELETE: "DELETE";
|
|
15
|
+
OPTIONS: "OPTIONS";
|
|
16
|
+
HEAD: "HEAD";
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* CORS origin configuration
|
|
20
|
+
* Accepts:
|
|
21
|
+
* - '*' for all origins
|
|
22
|
+
* - Single URL string
|
|
23
|
+
* - Array of URL strings
|
|
24
|
+
*/
|
|
25
|
+
declare const CorsOrigin: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>;
|
|
26
|
+
/**
|
|
27
|
+
* CORS options schema
|
|
28
|
+
* Configuration for Cross-Origin Resource Sharing
|
|
29
|
+
*/
|
|
30
|
+
declare const CorsOptionsSchema: z.ZodObject<{
|
|
31
|
+
origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
|
|
32
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
33
|
+
GET: "GET";
|
|
34
|
+
POST: "POST";
|
|
35
|
+
PUT: "PUT";
|
|
36
|
+
PATCH: "PATCH";
|
|
37
|
+
DELETE: "DELETE";
|
|
38
|
+
OPTIONS: "OPTIONS";
|
|
39
|
+
HEAD: "HEAD";
|
|
40
|
+
}>>>;
|
|
41
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
credentials: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
type CorsOptions$1 = z.infer<typeof CorsOptionsSchema>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* AWS Lambda source settings schema
|
|
49
|
+
*/
|
|
50
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
51
|
+
cors: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
52
|
+
origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
|
|
53
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
54
|
+
GET: "GET";
|
|
55
|
+
POST: "POST";
|
|
56
|
+
PUT: "PUT";
|
|
57
|
+
PATCH: "PATCH";
|
|
58
|
+
DELETE: "DELETE";
|
|
59
|
+
OPTIONS: "OPTIONS";
|
|
60
|
+
HEAD: "HEAD";
|
|
61
|
+
}>>>;
|
|
62
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
credentials: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
maxAge: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>]>>;
|
|
66
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
67
|
+
enablePixelTracking: z.ZodDefault<z.ZodBoolean>;
|
|
68
|
+
healthPath: z.ZodDefault<z.ZodString>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
type Settings$1 = z.infer<typeof SettingsSchema>;
|
|
71
|
+
|
|
72
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
73
|
+
|
|
74
|
+
declare const index$1_CorsOptionsSchema: typeof CorsOptionsSchema;
|
|
75
|
+
declare const index$1_CorsOrigin: typeof CorsOrigin;
|
|
76
|
+
declare const index$1_HttpMethod: typeof HttpMethod;
|
|
77
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
78
|
+
declare const index$1_settings: typeof settings;
|
|
79
|
+
declare namespace index$1 {
|
|
80
|
+
export { type CorsOptions$1 as CorsOptions, index$1_CorsOptionsSchema as CorsOptionsSchema, index$1_CorsOrigin as CorsOrigin, index$1_HttpMethod as HttpMethod, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;
|
|
84
|
+
type LambdaResult = APIGatewayProxyResult;
|
|
85
|
+
type LambdaContext = Context;
|
|
86
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
87
|
+
type CorsOptions = z.infer<typeof CorsOptionsSchema>;
|
|
88
|
+
type InitSettings = Partial<Settings>;
|
|
89
|
+
interface Mapping {
|
|
90
|
+
}
|
|
91
|
+
type Push = (event: LambdaEvent, context: LambdaContext) => Promise<LambdaResult>;
|
|
92
|
+
interface Env extends Source.Env {
|
|
93
|
+
lambdaEvent?: LambdaEvent;
|
|
94
|
+
lambdaContext?: LambdaContext;
|
|
95
|
+
}
|
|
96
|
+
type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;
|
|
97
|
+
interface LambdaSource extends Omit<Source.Instance<Types>, 'push'> {
|
|
98
|
+
push: Push;
|
|
99
|
+
}
|
|
100
|
+
type Config = Source.Config<Types>;
|
|
101
|
+
type PartialConfig = Source.PartialConfig<Types>;
|
|
102
|
+
interface EventRequest {
|
|
103
|
+
event: string;
|
|
104
|
+
data?: WalkerOS.AnyObject;
|
|
105
|
+
context?: WalkerOS.AnyObject;
|
|
106
|
+
user?: WalkerOS.AnyObject;
|
|
107
|
+
globals?: WalkerOS.AnyObject;
|
|
108
|
+
consent?: WalkerOS.AnyObject;
|
|
109
|
+
}
|
|
110
|
+
interface EventResponse {
|
|
111
|
+
success: boolean;
|
|
112
|
+
id?: string;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
type RequestBody = EventRequest;
|
|
116
|
+
type ResponseBody = EventResponse;
|
|
117
|
+
interface ParsedRequest {
|
|
118
|
+
method: string;
|
|
119
|
+
body: unknown;
|
|
120
|
+
queryString: string | null;
|
|
121
|
+
headers: Record<string, string>;
|
|
122
|
+
isBase64Encoded: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type types_Config = Config;
|
|
126
|
+
type types_CorsOptions = CorsOptions;
|
|
127
|
+
type types_Env = Env;
|
|
128
|
+
type types_EventRequest = EventRequest;
|
|
129
|
+
type types_EventResponse = EventResponse;
|
|
130
|
+
type types_InitSettings = InitSettings;
|
|
131
|
+
type types_LambdaContext = LambdaContext;
|
|
132
|
+
type types_LambdaEvent = LambdaEvent;
|
|
133
|
+
type types_LambdaResult = LambdaResult;
|
|
134
|
+
type types_LambdaSource = LambdaSource;
|
|
135
|
+
type types_Mapping = Mapping;
|
|
136
|
+
type types_ParsedRequest = ParsedRequest;
|
|
137
|
+
type types_PartialConfig = PartialConfig;
|
|
138
|
+
type types_Push = Push;
|
|
139
|
+
type types_RequestBody = RequestBody;
|
|
140
|
+
type types_ResponseBody = ResponseBody;
|
|
141
|
+
type types_Settings = Settings;
|
|
142
|
+
type types_Types = Types;
|
|
143
|
+
declare namespace types {
|
|
144
|
+
export type { types_Config as Config, types_CorsOptions as CorsOptions, types_Env as Env, types_EventRequest as EventRequest, types_EventResponse as EventResponse, types_InitSettings as InitSettings, types_LambdaContext as LambdaContext, types_LambdaEvent as LambdaEvent, types_LambdaResult as LambdaResult, types_LambdaSource as LambdaSource, types_Mapping as Mapping, types_ParsedRequest as ParsedRequest, types_PartialConfig as PartialConfig, types_Push as Push, types_RequestBody as RequestBody, types_ResponseBody as ResponseBody, types_Settings as Settings, types_Types as Types };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Standard mock environment for testing Lambda source
|
|
149
|
+
*
|
|
150
|
+
* Use this for testing Lambda event ingestion and request/response handling
|
|
151
|
+
* without requiring a real AWS Lambda environment.
|
|
152
|
+
*/
|
|
153
|
+
declare const push: Env;
|
|
154
|
+
|
|
155
|
+
declare const env_push: typeof push;
|
|
156
|
+
declare namespace env {
|
|
157
|
+
export { env_push as push };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Real examples of Lambda events this source will receive.
|
|
162
|
+
* These define the CONTRACT - implementation must handle these inputs.
|
|
163
|
+
*/
|
|
164
|
+
declare const apiGatewayV2PostEvent: APIGatewayProxyEventV2;
|
|
165
|
+
declare const apiGatewayV2GetEvent: APIGatewayProxyEventV2;
|
|
166
|
+
declare const apiGatewayV1PostEvent: APIGatewayProxyEvent;
|
|
167
|
+
declare const healthCheckEvent: APIGatewayProxyEventV2;
|
|
168
|
+
declare const invalidJsonEvent: APIGatewayProxyEventV2;
|
|
169
|
+
declare const missingEventField: APIGatewayProxyEventV2;
|
|
170
|
+
|
|
171
|
+
declare const inputs_apiGatewayV1PostEvent: typeof apiGatewayV1PostEvent;
|
|
172
|
+
declare const inputs_apiGatewayV2GetEvent: typeof apiGatewayV2GetEvent;
|
|
173
|
+
declare const inputs_apiGatewayV2PostEvent: typeof apiGatewayV2PostEvent;
|
|
174
|
+
declare const inputs_healthCheckEvent: typeof healthCheckEvent;
|
|
175
|
+
declare const inputs_invalidJsonEvent: typeof invalidJsonEvent;
|
|
176
|
+
declare const inputs_missingEventField: typeof missingEventField;
|
|
177
|
+
declare namespace inputs {
|
|
178
|
+
export { inputs_apiGatewayV1PostEvent as apiGatewayV1PostEvent, inputs_apiGatewayV2GetEvent as apiGatewayV2GetEvent, inputs_apiGatewayV2PostEvent as apiGatewayV2PostEvent, inputs_healthCheckEvent as healthCheckEvent, inputs_invalidJsonEvent as invalidJsonEvent, inputs_missingEventField as missingEventField };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Expected walkerOS events from Lambda inputs.
|
|
183
|
+
* These are what processEvent should produce.
|
|
184
|
+
*/
|
|
185
|
+
declare const pageViewEvent: Partial<WalkerOS.Event>;
|
|
186
|
+
declare const buttonClickEvent: Partial<WalkerOS.Event>;
|
|
187
|
+
declare const productAddEvent: Partial<WalkerOS.Event>;
|
|
188
|
+
|
|
189
|
+
declare const events_buttonClickEvent: typeof buttonClickEvent;
|
|
190
|
+
declare const events_pageViewEvent: typeof pageViewEvent;
|
|
191
|
+
declare const events_productAddEvent: typeof productAddEvent;
|
|
192
|
+
declare namespace events {
|
|
193
|
+
export { events_buttonClickEvent as buttonClickEvent, events_pageViewEvent as pageViewEvent, events_productAddEvent as productAddEvent };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Expected Lambda response outputs.
|
|
198
|
+
* Tests verify implementation produces these.
|
|
199
|
+
*/
|
|
200
|
+
declare const successResponse: Partial<APIGatewayProxyResult>;
|
|
201
|
+
declare const healthResponse: Partial<APIGatewayProxyResult>;
|
|
202
|
+
declare const pixelResponse: Partial<APIGatewayProxyResult>;
|
|
203
|
+
declare const invalidBodyResponse: Partial<APIGatewayProxyResult>;
|
|
204
|
+
|
|
205
|
+
declare const outputs_healthResponse: typeof healthResponse;
|
|
206
|
+
declare const outputs_invalidBodyResponse: typeof invalidBodyResponse;
|
|
207
|
+
declare const outputs_pixelResponse: typeof pixelResponse;
|
|
208
|
+
declare const outputs_successResponse: typeof successResponse;
|
|
209
|
+
declare namespace outputs {
|
|
210
|
+
export { outputs_healthResponse as healthResponse, outputs_invalidBodyResponse as invalidBodyResponse, outputs_pixelResponse as pixelResponse, outputs_successResponse as successResponse };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare const index_env: typeof env;
|
|
214
|
+
declare const index_events: typeof events;
|
|
215
|
+
declare const index_inputs: typeof inputs;
|
|
216
|
+
declare const index_outputs: typeof outputs;
|
|
217
|
+
declare namespace index {
|
|
218
|
+
export { index_env as env, index_events as events, index_inputs as inputs, index_outputs as outputs };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare const sourceLambda: (config: Partial<Source.Config<Types>> | undefined, env: Env) => Promise<LambdaSource>;
|
|
222
|
+
|
|
223
|
+
export { types as SourceLambda, index as examples, index$1 as schemas, sourceLambda };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},index_exports={};__export(index_exports,{SourceLambda:()=>types_exports,examples:()=>examples_exports,schemas:()=>schemas_exports,sourceLambda:()=>lambda_default}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core=require("@walkeros/core");function isAPIGatewayV2(event){return"version"in event&&"2.0"===event.version}function createResponse(statusCode,body,headers={},requestId){const responseHeaders={"Content-Type":"object"==typeof body?"application/json":"text/plain",...headers};return requestId&&(responseHeaders["X-Request-ID"]=requestId),{statusCode:statusCode,headers:responseHeaders,body:"object"==typeof body?JSON.stringify(body):String(body),isBase64Encoded:!1}}var import_dev2=require("@walkeros/core/dev"),import_dev=require("@walkeros/core/dev"),HttpMethod=import_dev.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),CorsOrigin=import_dev.z.union([import_dev.z.string(),import_dev.z.array(import_dev.z.string()),import_dev.z.literal("*")]),CorsOptionsSchema=import_dev.z.object({origin:CorsOrigin.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:import_dev.z.array(HttpMethod).describe("Allowed HTTP methods").optional(),headers:import_dev.z.array(import_dev.z.string()).describe("Allowed request headers").optional(),credentials:import_dev.z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:import_dev.z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),SettingsSchema=import_dev2.z.object({cors:import_dev2.z.union([import_dev2.z.boolean(),CorsOptionsSchema]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").default(!0),timeout:import_dev2.z.number().int().positive().max(9e5).describe("Request timeout in milliseconds (max: 900000 for Lambda)").default(3e4),enablePixelTracking:import_dev2.z.boolean().describe("Enable GET requests with 1x1 transparent GIF response for pixel tracking").default(!0),healthPath:import_dev2.z.string().describe("Health check endpoint path (e.g., /health)").default("/health")}),types_exports={},schemas_exports={};__export(schemas_exports,{CorsOptionsSchema:()=>CorsOptionsSchema,CorsOrigin:()=>CorsOrigin,HttpMethod:()=>HttpMethod,SettingsSchema:()=>SettingsSchema,settings:()=>settings});var settings=(0,require("@walkeros/core/dev").zodToSchema)(SettingsSchema),examples_exports={};__export(examples_exports,{env:()=>env_exports,events:()=>events_exports,inputs:()=>inputs_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{push:()=>push});var createMockElbFn=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),noopFn=()=>{},noopLogger={error:noopFn,info:noopFn,debug:noopFn,throw:message=>{throw"string"==typeof message?new Error(message):message},scope:()=>noopLogger},push={get push(){return createMockElbFn()},get command(){return createMockElbFn()},get elb(){return createMockElbFn()},logger:noopLogger},inputs_exports={};__export(inputs_exports,{apiGatewayV1PostEvent:()=>apiGatewayV1PostEvent,apiGatewayV2GetEvent:()=>apiGatewayV2GetEvent,apiGatewayV2PostEvent:()=>apiGatewayV2PostEvent,healthCheckEvent:()=>healthCheckEvent,invalidJsonEvent:()=>invalidJsonEvent,missingEventField:()=>missingEventField});var apiGatewayV2PostEvent={version:"2.0",routeKey:"$default",rawPath:"/collect",rawQueryString:"",headers:{"content-type":"application/json","user-agent":"Mozilla/5.0"},body:JSON.stringify({event:"page view",data:{title:"Home Page",path:"/"},user:{id:"user-123"}}),isBase64Encoded:!1,requestContext:{accountId:"123456789012",apiId:"api-id",domainName:"api.example.com",domainPrefix:"api",http:{method:"POST",path:"/collect",protocol:"HTTP/1.1",sourceIp:"1.2.3.4",userAgent:"Mozilla/5.0"},requestId:"request-123",routeKey:"$default",stage:"prod",time:"01/Jan/2024:00:00:00 +0000",timeEpoch:17040672e5}},apiGatewayV2GetEvent={version:"2.0",routeKey:"$default",rawPath:"/collect",rawQueryString:"event=button%20click&data[id]=cta&data[text]=Sign%20Up",headers:{},isBase64Encoded:!1,requestContext:{accountId:"123456789012",apiId:"api-id",domainName:"api.example.com",domainPrefix:"api",http:{method:"GET",path:"/collect",protocol:"HTTP/1.1",sourceIp:"1.2.3.4",userAgent:"Mozilla/5.0"},requestId:"request-456",routeKey:"$default",stage:"prod",time:"01/Jan/2024:00:00:01 +0000",timeEpoch:1704067201e3}},apiGatewayV1PostEvent={httpMethod:"POST",path:"/collect",body:JSON.stringify({event:"product add",data:{id:"P123",name:"Laptop",price:999}}),headers:{"content-type":"application/json"},multiValueHeaders:{},isBase64Encoded:!1,pathParameters:null,queryStringParameters:null,multiValueQueryStringParameters:null,stageVariables:null,resource:"/collect",requestContext:{accountId:"123456789012",apiId:"api-id",protocol:"HTTP/1.1",httpMethod:"POST",path:"/collect",stage:"prod",requestId:"request-789",requestTimeEpoch:1704067202e3,resourceId:"resource-id",resourcePath:"/collect",identity:{sourceIp:"1.2.3.4",userAgent:"Mozilla/5.0",accessKey:null,accountId:null,apiKey:null,apiKeyId:null,caller:null,clientCert:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,user:null,userArn:null},authorizer:null}},healthCheckEvent={...apiGatewayV2GetEvent,rawPath:"/health",rawQueryString:"",requestContext:{...apiGatewayV2GetEvent.requestContext,http:{...apiGatewayV2GetEvent.requestContext.http,path:"/health"}}},invalidJsonEvent={...apiGatewayV2PostEvent,body:"{invalid json"},missingEventField={...apiGatewayV2PostEvent,body:JSON.stringify({data:{foo:"bar"}})},events_exports={};__export(events_exports,{buttonClickEvent:()=>buttonClickEvent,pageViewEvent:()=>pageViewEvent,productAddEvent:()=>productAddEvent});var pageViewEvent={name:"page view",data:{title:"Home Page",path:"/"},user:{id:"user-123"}},buttonClickEvent={name:"button click",data:{id:"cta",text:"Sign Up"}},productAddEvent={name:"product add",data:{id:"P123",name:"Laptop",price:999}},outputs_exports={};__export(outputs_exports,{healthResponse:()=>healthResponse,invalidBodyResponse:()=>invalidBodyResponse,pixelResponse:()=>pixelResponse,successResponse:()=>successResponse});var successResponse={statusCode:200,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"},body:expect.stringContaining('"success":true')},healthResponse={statusCode:200,body:expect.stringContaining('"status":"ok"')},pixelResponse={statusCode:200,headers:expect.objectContaining({"Content-Type":"image/gif"}),isBase64Encoded:!0},invalidBodyResponse={statusCode:400,body:expect.stringContaining('"success":false')},sourceLambda=async(config={},env)=>{const{push:envPush}=env,settings2=SettingsSchema.parse(config.settings||{});return{type:"lambda",config:{...config,settings:settings2},push:async(event,context)=>{var _a;const requestId=context.awsRequestId;let parsed;try{const corsHeaders=function(corsOptions){if(!corsOptions)return{};if(!0===corsOptions)return{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization","Access-Control-Max-Age":"3600"};const headers={};if(corsOptions.origin){const origin=Array.isArray(corsOptions.origin)?corsOptions.origin.join(", "):corsOptions.origin;headers["Access-Control-Allow-Origin"]=origin}return corsOptions.methods&&(headers["Access-Control-Allow-Methods"]=corsOptions.methods.join(", ")),corsOptions.headers&&(headers["Access-Control-Allow-Headers"]=corsOptions.headers.join(", ")),corsOptions.credentials&&(headers["Access-Control-Allow-Credentials"]="true"),void 0!==corsOptions.maxAge&&(headers["Access-Control-Max-Age"]=corsOptions.maxAge.toString()),headers}(settings2.cors||!1);parsed=function(event){if(isAPIGatewayV2(event)){const headers={};return event.headers&&Object.entries(event.headers).forEach(([key,value])=>{value&&(headers[key.toLowerCase()]=value)}),{method:event.requestContext.http.method,body:event.body,queryString:event.rawQueryString||null,headers:headers,isBase64Encoded:event.isBase64Encoded||!1}}{const headers={};event.headers&&Object.entries(event.headers).forEach(([key,value])=>{value&&(headers[key.toLowerCase()]=value)});let queryString=null;if(event.queryStringParameters){const params=new URLSearchParams;Object.entries(event.queryStringParameters).forEach(([key,value])=>{value&¶ms.append(key,value)}),queryString=params.toString()||null}return{method:event.httpMethod,body:event.body,queryString:queryString,headers:headers,isBase64Encoded:event.isBase64Encoded||!1}}}(event);const path=function(event){return isAPIGatewayV2(event)?event.rawPath:event.path}(event);if(settings2.healthPath&&path===settings2.healthPath)return createResponse(200,{status:"ok",timestamp:Date.now(),source:"lambda",requestId:requestId},corsHeaders,requestId);if("OPTIONS"===parsed.method)return createResponse(204,"",corsHeaders,requestId);if("GET"===parsed.method){if(!settings2.enablePixelTracking)return createResponse(405,{success:!1,error:"GET not allowed",requestId:requestId},corsHeaders,requestId);if(parsed.queryString){const parsedData=(0,import_core.requestToData)(parsed.queryString);parsedData&&"object"==typeof parsedData&&await envPush(parsedData)}return function(headers={},requestId){const responseHeaders={"Content-Type":"image/gif","Cache-Control":"no-cache, no-store, must-revalidate",...headers};return requestId&&(responseHeaders["X-Request-ID"]=requestId),{statusCode:200,headers:responseHeaders,body:"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",isBase64Encoded:!0}}(corsHeaders,requestId)}if("POST"===parsed.method){if(!parsed.body)return createResponse(400,{success:!1,error:"Request body is required",requestId:requestId},corsHeaders,requestId);const body=function(body,isBase64Encoded){if(!body||"string"!=typeof body)return body;try{const decoded=isBase64Encoded?Buffer.from(body,"base64").toString("utf8"):body;return JSON.parse(decoded)}catch(e){return body}}(parsed.body,parsed.isBase64Encoded);if(!body||"object"!=typeof body)return createResponse(400,{success:!1,error:"Invalid event body",requestId:requestId},corsHeaders,requestId);if(function(body){return"object"==typeof body&&null!==body&&"event"in body&&"string"==typeof body.event}(body)){const result=await async function(eventReq,push2,logger,requestId){var _a;try{const result=await push2({name:eventReq.event,data:eventReq.data||{},context:eventReq.context,user:eventReq.user,globals:eventReq.globals,consent:eventReq.consent});return{id:null==(_a=null==result?void 0:result.event)?void 0:_a.id}}catch(error){return null==logger||logger.error("Event processing failed",{error:error,eventName:eventReq.event,requestId:requestId}),{error:error instanceof Error?error.message:"Unknown error"}}}(body,envPush,env.logger,requestId);return result.error?createResponse(400,{success:!1,error:result.error,requestId:requestId},corsHeaders,requestId):createResponse(200,{success:!0,id:result.id,requestId:requestId},corsHeaders,requestId)}return createResponse(400,{success:!1,error:"Invalid request format",requestId:requestId},corsHeaders,requestId)}return createResponse(405,{success:!1,error:"Method not allowed",requestId:requestId},corsHeaders,requestId)}catch(error){return null==(_a=env.logger)||_a.error("Lambda handler error",{error:error,requestId:requestId,method:null==parsed?void 0:parsed.method}),createResponse(500,{success:!1,error:error instanceof Error?error.message:"Internal server error",requestId:requestId},{},requestId)}}}},lambda_default=sourceLambda;//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lambda/index.ts","../src/lambda/utils.ts","../src/lambda/push.ts","../src/lambda/schemas/settings.ts","../src/lambda/schemas/primitives.ts","../src/lambda/types.ts","../src/lambda/schemas/index.ts","../src/lambda/examples/index.ts","../src/lambda/examples/env.ts","../src/lambda/examples/inputs.ts","../src/lambda/examples/events.ts","../src/lambda/examples/outputs.ts"],"sourcesContent":["export * from './lambda';\nexport { default as sourceLambda } from './lambda';\n","import type { LambdaSource, Env, Settings, EventRequest, Types } from './types';\nimport type { Source } from '@walkeros/core';\nimport { requestToData } from '@walkeros/core';\nimport {\n parseEvent,\n parseBody,\n isEventRequest,\n getCorsHeaders,\n createResponse,\n createPixelResponse,\n getPath,\n} from './utils';\nimport { processEvent } from './push';\nimport { SettingsSchema } from './schemas/settings';\n\nexport * as SourceLambda from './types';\nexport * as schemas from './schemas';\n\n// Export examples\nexport * as examples from './examples';\n\nexport const sourceLambda = async (\n config: Partial<Source.Config<Types>> = {},\n env: Env,\n): Promise<LambdaSource> => {\n const { push: envPush } = env;\n\n const settings = SettingsSchema.parse(config.settings || {});\n\n const fullConfig: Source.Config<Types> = {\n ...config,\n settings,\n };\n\n const push: Types['push'] = async (event, context) => {\n const requestId = context.awsRequestId;\n let parsed;\n\n try {\n const corsHeaders = getCorsHeaders(settings.cors || false);\n parsed = parseEvent(event);\n const path = getPath(event);\n\n // Health check\n if (settings.healthPath && path === settings.healthPath) {\n return createResponse(\n 200,\n {\n status: 'ok',\n timestamp: Date.now(),\n source: 'lambda',\n requestId,\n },\n corsHeaders,\n requestId,\n );\n }\n\n // Handle OPTIONS for CORS preflight\n if (parsed.method === 'OPTIONS') {\n return createResponse(204, '', corsHeaders, requestId);\n }\n\n // Handle GET for pixel tracking\n if (parsed.method === 'GET') {\n if (!settings.enablePixelTracking) {\n return createResponse(\n 405,\n { success: false, error: 'GET not allowed', requestId },\n corsHeaders,\n requestId,\n );\n }\n if (parsed.queryString) {\n const parsedData = requestToData(parsed.queryString);\n if (parsedData && typeof parsedData === 'object') {\n await envPush(parsedData);\n }\n }\n return createPixelResponse(corsHeaders, requestId);\n }\n\n // Handle POST for event data\n if (parsed.method === 'POST') {\n if (!parsed.body) {\n return createResponse(\n 400,\n { success: false, error: 'Request body is required', requestId },\n corsHeaders,\n requestId,\n );\n }\n\n const body = parseBody(parsed.body, parsed.isBase64Encoded);\n\n if (!body || typeof body !== 'object') {\n return createResponse(\n 400,\n { success: false, error: 'Invalid event body', requestId },\n corsHeaders,\n requestId,\n );\n }\n\n if (isEventRequest(body)) {\n const result = await processEvent(\n body as EventRequest,\n envPush,\n env.logger,\n requestId,\n );\n\n if (result.error) {\n return createResponse(\n 400,\n { success: false, error: result.error, requestId },\n corsHeaders,\n requestId,\n );\n }\n\n return createResponse(\n 200,\n { success: true, id: result.id, requestId },\n corsHeaders,\n requestId,\n );\n }\n\n return createResponse(\n 400,\n { success: false, error: 'Invalid request format', requestId },\n corsHeaders,\n requestId,\n );\n }\n\n return createResponse(\n 405,\n { success: false, error: 'Method not allowed', requestId },\n corsHeaders,\n requestId,\n );\n } catch (error) {\n // Log handler errors with context - per using-logger skill\n env.logger?.error('Lambda handler error', {\n error,\n requestId,\n method: parsed?.method,\n });\n return createResponse(\n 500,\n {\n success: false,\n error:\n error instanceof Error ? error.message : 'Internal server error',\n requestId,\n },\n {},\n requestId,\n );\n }\n };\n\n return {\n type: 'lambda',\n config: fullConfig,\n push,\n };\n};\n\nexport default sourceLambda;\n","import type { APIGatewayProxyEventV2, APIGatewayProxyResult } from 'aws-lambda';\nimport type {\n LambdaEvent,\n ParsedRequest,\n CorsOptions,\n RequestBody,\n EventRequest,\n} from './types';\n\nexport function isAPIGatewayV2(\n event: LambdaEvent,\n): event is APIGatewayProxyEventV2 {\n return 'version' in event && event.version === '2.0';\n}\n\nexport function parseEvent(event: LambdaEvent): ParsedRequest {\n if (isAPIGatewayV2(event)) {\n const headers: Record<string, string> = {};\n if (event.headers) {\n Object.entries(event.headers).forEach(([key, value]) => {\n if (value) headers[key.toLowerCase()] = value;\n });\n }\n return {\n method: event.requestContext.http.method,\n body: event.body,\n queryString: event.rawQueryString || null,\n headers,\n isBase64Encoded: event.isBase64Encoded || false,\n };\n } else {\n const headers: Record<string, string> = {};\n if (event.headers) {\n Object.entries(event.headers).forEach(([key, value]) => {\n if (value) headers[key.toLowerCase()] = value;\n });\n }\n let queryString: string | null = null;\n if (event.queryStringParameters) {\n const params = new URLSearchParams();\n Object.entries(event.queryStringParameters).forEach(([key, value]) => {\n if (value) params.append(key, value);\n });\n queryString = params.toString() || null;\n }\n return {\n method: event.httpMethod,\n body: event.body,\n queryString,\n headers,\n isBase64Encoded: event.isBase64Encoded || false,\n };\n }\n}\n\nexport function getPath(event: LambdaEvent): string {\n if (isAPIGatewayV2(event)) {\n return event.rawPath;\n } else {\n return event.path;\n }\n}\n\nexport function parseBody(body: unknown, isBase64Encoded: boolean): unknown {\n if (!body || typeof body !== 'string') return body;\n try {\n const decoded = isBase64Encoded\n ? Buffer.from(body, 'base64').toString('utf8')\n : body;\n return JSON.parse(decoded);\n } catch {\n return body;\n }\n}\n\nexport function isEventRequest(body: unknown): body is EventRequest {\n return (\n typeof body === 'object' &&\n body !== null &&\n 'event' in body &&\n typeof (body as EventRequest).event === 'string'\n );\n}\n\nexport function getCorsHeaders(\n corsOptions: boolean | CorsOptions,\n): Record<string, string> {\n if (!corsOptions) return {};\n if (corsOptions === true) {\n return {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n 'Access-Control-Max-Age': '3600',\n };\n }\n\n const headers: Record<string, string> = {};\n\n if (corsOptions.origin) {\n const origin = Array.isArray(corsOptions.origin)\n ? corsOptions.origin.join(', ')\n : corsOptions.origin;\n headers['Access-Control-Allow-Origin'] = origin;\n }\n if (corsOptions.methods) {\n headers['Access-Control-Allow-Methods'] = corsOptions.methods.join(', ');\n }\n if (corsOptions.headers) {\n headers['Access-Control-Allow-Headers'] = corsOptions.headers.join(', ');\n }\n if (corsOptions.credentials) {\n headers['Access-Control-Allow-Credentials'] = 'true';\n }\n if (corsOptions.maxAge !== undefined) {\n headers['Access-Control-Max-Age'] = corsOptions.maxAge.toString();\n }\n\n return headers;\n}\n\nexport function createResponse(\n statusCode: number,\n body: unknown,\n headers: Record<string, string> = {},\n requestId?: string,\n): APIGatewayProxyResult {\n const responseHeaders: Record<string, string> = {\n 'Content-Type':\n typeof body === 'object' ? 'application/json' : 'text/plain',\n ...headers,\n };\n\n if (requestId) {\n responseHeaders['X-Request-ID'] = requestId;\n }\n\n return {\n statusCode,\n headers: responseHeaders,\n body: typeof body === 'object' ? JSON.stringify(body) : String(body),\n isBase64Encoded: false,\n };\n}\n\nexport function createPixelResponse(\n headers: Record<string, string> = {},\n requestId?: string,\n): APIGatewayProxyResult {\n const responseHeaders: Record<string, string> = {\n 'Content-Type': 'image/gif',\n 'Cache-Control': 'no-cache, no-store, must-revalidate',\n ...headers,\n };\n\n if (requestId) {\n responseHeaders['X-Request-ID'] = requestId;\n }\n\n return {\n statusCode: 200,\n headers: responseHeaders,\n body: 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',\n isBase64Encoded: true,\n };\n}\n","import type { Collector, WalkerOS, Logger } from '@walkeros/core';\nimport type { EventRequest } from './types';\n\nexport async function processEvent(\n eventReq: EventRequest,\n push: Collector.PushFn,\n logger?: Logger.Instance,\n requestId?: string,\n): Promise<{ id?: string; error?: string }> {\n try {\n const result = await push({\n name: eventReq.event,\n data: (eventReq.data || {}) as WalkerOS.Properties,\n context: eventReq.context as WalkerOS.OrderedProperties | undefined,\n user: eventReq.user as WalkerOS.User | undefined,\n globals: eventReq.globals as WalkerOS.Properties | undefined,\n consent: eventReq.consent as WalkerOS.Consent | undefined,\n });\n\n return { id: result?.event?.id };\n } catch (error) {\n // Log with structured context - per using-logger skill\n logger?.error('Event processing failed', {\n error,\n eventName: eventReq.event,\n requestId,\n });\n return { error: error instanceof Error ? error.message : 'Unknown error' };\n }\n}\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\n/**\n * AWS Lambda source settings schema\n */\nexport const SettingsSchema = z.object({\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins, object = custom configuration',\n )\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(900000) // AWS Lambda max timeout: 15 minutes\n .describe('Request timeout in milliseconds (max: 900000 for Lambda)')\n .default(30000),\n\n enablePixelTracking: z\n .boolean()\n .describe(\n 'Enable GET requests with 1x1 transparent GIF response for pixel tracking',\n )\n .default(true),\n\n healthPath: z\n .string()\n .describe('Health check endpoint path (e.g., /health)')\n .default('/health'),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * HTTP methods enum\n */\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\n/**\n * CORS origin configuration\n * Accepts:\n * - '*' for all origins\n * - Single URL string\n * - Array of URL strings\n */\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\n/**\n * CORS options schema\n * Configuration for Cross-Origin Resource Sharing\n */\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.describe(\n 'Allowed origins (* for all, URL string, or array of URLs)',\n ).optional(),\n\n methods: z.array(HttpMethod).describe('Allowed HTTP methods').optional(),\n\n headers: z.array(z.string()).describe('Allowed request headers').optional(),\n\n credentials: z\n .boolean()\n .describe('Allow credentials (cookies, authorization headers)')\n .optional(),\n\n maxAge: z\n .number()\n .int()\n .positive()\n .describe('Preflight cache duration in seconds')\n .optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","import type { WalkerOS, Source as CoreSource } from '@walkeros/core';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n Context,\n} from 'aws-lambda';\nimport type { SettingsSchema, CorsOptionsSchema } from './schemas';\nimport { z } from '@walkeros/core/dev';\n\n// Lambda event types\nexport type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;\nexport type LambdaResult = APIGatewayProxyResult;\nexport type LambdaContext = Context;\n\n// Types inferred from Zod schemas\nexport type Settings = z.infer<typeof SettingsSchema>;\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n // Custom source event mapping properties\n}\n\n// Lambda-specific push type\nexport type Push = (\n event: LambdaEvent,\n context: LambdaContext,\n) => Promise<LambdaResult>;\n\nexport interface Env extends CoreSource.Env {\n lambdaEvent?: LambdaEvent;\n lambdaContext?: LambdaContext;\n}\n\n// Type bundle (must be after Settings, Mapping, Push, Env are defined)\nexport type Types = CoreSource.Types<\n Settings,\n Mapping,\n Push,\n Env,\n InitSettings\n>;\n\nexport interface LambdaSource extends Omit<CoreSource.Instance<Types>, 'push'> {\n push: Push;\n}\n\n// Convenience Config type\nexport type Config = CoreSource.Config<Types>;\nexport type PartialConfig = CoreSource.PartialConfig<Types>;\n\n// Lambda source doesn't follow standard Source.Init pattern due to Lambda handler interface\n\nexport interface EventRequest {\n event: string;\n data?: WalkerOS.AnyObject;\n context?: WalkerOS.AnyObject;\n user?: WalkerOS.AnyObject;\n globals?: WalkerOS.AnyObject;\n consent?: WalkerOS.AnyObject;\n}\n\nexport interface EventResponse {\n success: boolean;\n id?: string;\n error?: string;\n}\n\nexport type RequestBody = EventRequest;\nexport type ResponseBody = EventResponse;\n\n// Parsed request data structure\nexport interface ParsedRequest {\n method: string;\n body: unknown;\n queryString: string | null;\n headers: Record<string, string>;\n isBase64Encoded: boolean;\n}\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export primitives\nexport * from './primitives';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","export * as env from './env';\nexport * as inputs from './inputs';\nexport * as events from './events';\nexport * as outputs from './outputs';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for AWS Lambda source\n *\n * These environments provide standardized mock structures for testing\n * Lambda event handling without requiring actual Lambda deployment.\n */\n\n// Create a properly typed elb/push/command function that returns a promise with PushResult\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n successful: [],\n queued: [],\n failed: [],\n })) as Elb.Fn;\n return fn;\n};\n\n// Simple no-op logger for demo purposes\nconst noopFn = () => {};\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n scope: () => noopLogger,\n};\n\n/**\n * Standard mock environment for testing Lambda source\n *\n * Use this for testing Lambda event ingestion and request/response handling\n * without requiring a real AWS Lambda environment.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n","import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from 'aws-lambda';\n\n/**\n * Real examples of Lambda events this source will receive.\n * These define the CONTRACT - implementation must handle these inputs.\n */\n\n// API Gateway v2 (HTTP API) - POST with walker event\nexport const apiGatewayV2PostEvent: APIGatewayProxyEventV2 = {\n version: '2.0',\n routeKey: '$default',\n rawPath: '/collect',\n rawQueryString: '',\n headers: {\n 'content-type': 'application/json',\n 'user-agent': 'Mozilla/5.0',\n },\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home Page', path: '/' },\n user: { id: 'user-123' },\n }),\n isBase64Encoded: false,\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n domainName: 'api.example.com',\n domainPrefix: 'api',\n http: {\n method: 'POST',\n path: '/collect',\n protocol: 'HTTP/1.1',\n sourceIp: '1.2.3.4',\n userAgent: 'Mozilla/5.0',\n },\n requestId: 'request-123',\n routeKey: '$default',\n stage: 'prod',\n time: '01/Jan/2024:00:00:00 +0000',\n timeEpoch: 1704067200000,\n },\n};\n\n// API Gateway v2 - GET with query params (pixel tracking)\nexport const apiGatewayV2GetEvent: APIGatewayProxyEventV2 = {\n version: '2.0',\n routeKey: '$default',\n rawPath: '/collect',\n rawQueryString: 'event=button%20click&data[id]=cta&data[text]=Sign%20Up',\n headers: {},\n isBase64Encoded: false,\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n domainName: 'api.example.com',\n domainPrefix: 'api',\n http: {\n method: 'GET',\n path: '/collect',\n protocol: 'HTTP/1.1',\n sourceIp: '1.2.3.4',\n userAgent: 'Mozilla/5.0',\n },\n requestId: 'request-456',\n routeKey: '$default',\n stage: 'prod',\n time: '01/Jan/2024:00:00:01 +0000',\n timeEpoch: 1704067201000,\n },\n};\n\n// API Gateway v1 (REST API) - POST with walker event\nexport const apiGatewayV1PostEvent: APIGatewayProxyEvent = {\n httpMethod: 'POST',\n path: '/collect',\n body: JSON.stringify({\n event: 'product add',\n data: { id: 'P123', name: 'Laptop', price: 999 },\n }),\n headers: { 'content-type': 'application/json' },\n multiValueHeaders: {},\n isBase64Encoded: false,\n pathParameters: null,\n queryStringParameters: null,\n multiValueQueryStringParameters: null,\n stageVariables: null,\n resource: '/collect',\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n protocol: 'HTTP/1.1',\n httpMethod: 'POST',\n path: '/collect',\n stage: 'prod',\n requestId: 'request-789',\n requestTimeEpoch: 1704067202000,\n resourceId: 'resource-id',\n resourcePath: '/collect',\n identity: {\n sourceIp: '1.2.3.4',\n userAgent: 'Mozilla/5.0',\n accessKey: null,\n accountId: null,\n apiKey: null,\n apiKeyId: null,\n caller: null,\n clientCert: null,\n cognitoAuthenticationProvider: null,\n cognitoAuthenticationType: null,\n cognitoIdentityId: null,\n cognitoIdentityPoolId: null,\n principalOrgId: null,\n user: null,\n userArn: null,\n },\n authorizer: null,\n },\n};\n\n// Health check request\nexport const healthCheckEvent: APIGatewayProxyEventV2 = {\n ...apiGatewayV2GetEvent,\n rawPath: '/health',\n rawQueryString: '',\n requestContext: {\n ...apiGatewayV2GetEvent.requestContext,\n http: {\n ...apiGatewayV2GetEvent.requestContext.http,\n path: '/health',\n },\n },\n};\n\n// Invalid event - malformed JSON\nexport const invalidJsonEvent: APIGatewayProxyEventV2 = {\n ...apiGatewayV2PostEvent,\n body: '{invalid json',\n};\n\n// Missing event field\nexport const missingEventField: APIGatewayProxyEventV2 = {\n ...apiGatewayV2PostEvent,\n body: JSON.stringify({ data: { foo: 'bar' } }),\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS events from Lambda inputs.\n * These are what processEvent should produce.\n */\n\n// From apiGatewayV2PostEvent\nexport const pageViewEvent: Partial<WalkerOS.Event> = {\n name: 'page view',\n data: { title: 'Home Page', path: '/' },\n user: { id: 'user-123' },\n};\n\n// From apiGatewayV2GetEvent\nexport const buttonClickEvent: Partial<WalkerOS.Event> = {\n name: 'button click',\n data: { id: 'cta', text: 'Sign Up' },\n};\n\n// From apiGatewayV1PostEvent\nexport const productAddEvent: Partial<WalkerOS.Event> = {\n name: 'product add',\n data: { id: 'P123', name: 'Laptop', price: 999 },\n};\n","import type { APIGatewayProxyResult } from 'aws-lambda';\n\n/**\n * Expected Lambda response outputs.\n * Tests verify implementation produces these.\n */\n\n// Successful event processing\nexport const successResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 200,\n headers: {\n 'Content-Type': 'application/json',\n 'Access-Control-Allow-Origin': '*',\n },\n body: expect.stringContaining('\"success\":true'),\n};\n\n// Health check response\nexport const healthResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 200,\n body: expect.stringContaining('\"status\":\"ok\"'),\n};\n\n// Pixel tracking response\nexport const pixelResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 200,\n headers: expect.objectContaining({\n 'Content-Type': 'image/gif',\n }),\n isBase64Encoded: true,\n};\n\n// Error responses\nexport const invalidBodyResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 400,\n body: expect.stringContaining('\"success\":false'),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,kBAA8B;;;ACOvB,SAAS,eACd,OACiC;AACjC,SAAO,aAAa,SAAS,MAAM,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,IAAO,iBAAQ;","names":["push","import_dev","import_dev","settings","push"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __defProp=Object.defineProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})};import{requestToData}from"@walkeros/core";function isAPIGatewayV2(event){return"version"in event&&"2.0"===event.version}function createResponse(statusCode,body,headers={},requestId){const responseHeaders={"Content-Type":"object"==typeof body?"application/json":"text/plain",...headers};return requestId&&(responseHeaders["X-Request-ID"]=requestId),{statusCode:statusCode,headers:responseHeaders,body:"object"==typeof body?JSON.stringify(body):String(body),isBase64Encoded:!1}}import{z as z2}from"@walkeros/core/dev";import{z}from"@walkeros/core/dev";var HttpMethod=z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),CorsOrigin=z.union([z.string(),z.array(z.string()),z.literal("*")]),CorsOptionsSchema=z.object({origin:CorsOrigin.describe("Allowed origins (* for all, URL string, or array of URLs)").optional(),methods:z.array(HttpMethod).describe("Allowed HTTP methods").optional(),headers:z.array(z.string()).describe("Allowed request headers").optional(),credentials:z.boolean().describe("Allow credentials (cookies, authorization headers)").optional(),maxAge:z.number().int().positive().describe("Preflight cache duration in seconds").optional()}),SettingsSchema=z2.object({cors:z2.union([z2.boolean(),CorsOptionsSchema]).describe("CORS configuration: false = disabled, true = allow all origins, object = custom configuration").default(!0),timeout:z2.number().int().positive().max(9e5).describe("Request timeout in milliseconds (max: 900000 for Lambda)").default(3e4),enablePixelTracking:z2.boolean().describe("Enable GET requests with 1x1 transparent GIF response for pixel tracking").default(!0),healthPath:z2.string().describe("Health check endpoint path (e.g., /health)").default("/health")}),types_exports={},schemas_exports={};__export(schemas_exports,{CorsOptionsSchema:()=>CorsOptionsSchema,CorsOrigin:()=>CorsOrigin,HttpMethod:()=>HttpMethod,SettingsSchema:()=>SettingsSchema,settings:()=>settings});import{zodToSchema}from"@walkeros/core/dev";var settings=zodToSchema(SettingsSchema),examples_exports={};__export(examples_exports,{env:()=>env_exports,events:()=>events_exports,inputs:()=>inputs_exports,outputs:()=>outputs_exports});var env_exports={};__export(env_exports,{push:()=>push});var createMockElbFn=()=>()=>Promise.resolve({ok:!0,successful:[],queued:[],failed:[]}),noopFn=()=>{},noopLogger={error:noopFn,info:noopFn,debug:noopFn,throw:message=>{throw"string"==typeof message?new Error(message):message},scope:()=>noopLogger},push={get push(){return createMockElbFn()},get command(){return createMockElbFn()},get elb(){return createMockElbFn()},logger:noopLogger},inputs_exports={};__export(inputs_exports,{apiGatewayV1PostEvent:()=>apiGatewayV1PostEvent,apiGatewayV2GetEvent:()=>apiGatewayV2GetEvent,apiGatewayV2PostEvent:()=>apiGatewayV2PostEvent,healthCheckEvent:()=>healthCheckEvent,invalidJsonEvent:()=>invalidJsonEvent,missingEventField:()=>missingEventField});var apiGatewayV2PostEvent={version:"2.0",routeKey:"$default",rawPath:"/collect",rawQueryString:"",headers:{"content-type":"application/json","user-agent":"Mozilla/5.0"},body:JSON.stringify({event:"page view",data:{title:"Home Page",path:"/"},user:{id:"user-123"}}),isBase64Encoded:!1,requestContext:{accountId:"123456789012",apiId:"api-id",domainName:"api.example.com",domainPrefix:"api",http:{method:"POST",path:"/collect",protocol:"HTTP/1.1",sourceIp:"1.2.3.4",userAgent:"Mozilla/5.0"},requestId:"request-123",routeKey:"$default",stage:"prod",time:"01/Jan/2024:00:00:00 +0000",timeEpoch:17040672e5}},apiGatewayV2GetEvent={version:"2.0",routeKey:"$default",rawPath:"/collect",rawQueryString:"event=button%20click&data[id]=cta&data[text]=Sign%20Up",headers:{},isBase64Encoded:!1,requestContext:{accountId:"123456789012",apiId:"api-id",domainName:"api.example.com",domainPrefix:"api",http:{method:"GET",path:"/collect",protocol:"HTTP/1.1",sourceIp:"1.2.3.4",userAgent:"Mozilla/5.0"},requestId:"request-456",routeKey:"$default",stage:"prod",time:"01/Jan/2024:00:00:01 +0000",timeEpoch:1704067201e3}},apiGatewayV1PostEvent={httpMethod:"POST",path:"/collect",body:JSON.stringify({event:"product add",data:{id:"P123",name:"Laptop",price:999}}),headers:{"content-type":"application/json"},multiValueHeaders:{},isBase64Encoded:!1,pathParameters:null,queryStringParameters:null,multiValueQueryStringParameters:null,stageVariables:null,resource:"/collect",requestContext:{accountId:"123456789012",apiId:"api-id",protocol:"HTTP/1.1",httpMethod:"POST",path:"/collect",stage:"prod",requestId:"request-789",requestTimeEpoch:1704067202e3,resourceId:"resource-id",resourcePath:"/collect",identity:{sourceIp:"1.2.3.4",userAgent:"Mozilla/5.0",accessKey:null,accountId:null,apiKey:null,apiKeyId:null,caller:null,clientCert:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,user:null,userArn:null},authorizer:null}},healthCheckEvent={...apiGatewayV2GetEvent,rawPath:"/health",rawQueryString:"",requestContext:{...apiGatewayV2GetEvent.requestContext,http:{...apiGatewayV2GetEvent.requestContext.http,path:"/health"}}},invalidJsonEvent={...apiGatewayV2PostEvent,body:"{invalid json"},missingEventField={...apiGatewayV2PostEvent,body:JSON.stringify({data:{foo:"bar"}})},events_exports={};__export(events_exports,{buttonClickEvent:()=>buttonClickEvent,pageViewEvent:()=>pageViewEvent,productAddEvent:()=>productAddEvent});var pageViewEvent={name:"page view",data:{title:"Home Page",path:"/"},user:{id:"user-123"}},buttonClickEvent={name:"button click",data:{id:"cta",text:"Sign Up"}},productAddEvent={name:"product add",data:{id:"P123",name:"Laptop",price:999}},outputs_exports={};__export(outputs_exports,{healthResponse:()=>healthResponse,invalidBodyResponse:()=>invalidBodyResponse,pixelResponse:()=>pixelResponse,successResponse:()=>successResponse});var successResponse={statusCode:200,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"},body:expect.stringContaining('"success":true')},healthResponse={statusCode:200,body:expect.stringContaining('"status":"ok"')},pixelResponse={statusCode:200,headers:expect.objectContaining({"Content-Type":"image/gif"}),isBase64Encoded:!0},invalidBodyResponse={statusCode:400,body:expect.stringContaining('"success":false')},lambda_default=async(config={},env)=>{const{push:envPush}=env,settings2=SettingsSchema.parse(config.settings||{});return{type:"lambda",config:{...config,settings:settings2},push:async(event,context)=>{var _a;const requestId=context.awsRequestId;let parsed;try{const corsHeaders=function(corsOptions){if(!corsOptions)return{};if(!0===corsOptions)return{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization","Access-Control-Max-Age":"3600"};const headers={};if(corsOptions.origin){const origin=Array.isArray(corsOptions.origin)?corsOptions.origin.join(", "):corsOptions.origin;headers["Access-Control-Allow-Origin"]=origin}return corsOptions.methods&&(headers["Access-Control-Allow-Methods"]=corsOptions.methods.join(", ")),corsOptions.headers&&(headers["Access-Control-Allow-Headers"]=corsOptions.headers.join(", ")),corsOptions.credentials&&(headers["Access-Control-Allow-Credentials"]="true"),void 0!==corsOptions.maxAge&&(headers["Access-Control-Max-Age"]=corsOptions.maxAge.toString()),headers}(settings2.cors||!1);parsed=function(event){if(isAPIGatewayV2(event)){const headers={};return event.headers&&Object.entries(event.headers).forEach(([key,value])=>{value&&(headers[key.toLowerCase()]=value)}),{method:event.requestContext.http.method,body:event.body,queryString:event.rawQueryString||null,headers:headers,isBase64Encoded:event.isBase64Encoded||!1}}{const headers={};event.headers&&Object.entries(event.headers).forEach(([key,value])=>{value&&(headers[key.toLowerCase()]=value)});let queryString=null;if(event.queryStringParameters){const params=new URLSearchParams;Object.entries(event.queryStringParameters).forEach(([key,value])=>{value&¶ms.append(key,value)}),queryString=params.toString()||null}return{method:event.httpMethod,body:event.body,queryString:queryString,headers:headers,isBase64Encoded:event.isBase64Encoded||!1}}}(event);const path=function(event){return isAPIGatewayV2(event)?event.rawPath:event.path}(event);if(settings2.healthPath&&path===settings2.healthPath)return createResponse(200,{status:"ok",timestamp:Date.now(),source:"lambda",requestId:requestId},corsHeaders,requestId);if("OPTIONS"===parsed.method)return createResponse(204,"",corsHeaders,requestId);if("GET"===parsed.method){if(!settings2.enablePixelTracking)return createResponse(405,{success:!1,error:"GET not allowed",requestId:requestId},corsHeaders,requestId);if(parsed.queryString){const parsedData=requestToData(parsed.queryString);parsedData&&"object"==typeof parsedData&&await envPush(parsedData)}return function(headers={},requestId){const responseHeaders={"Content-Type":"image/gif","Cache-Control":"no-cache, no-store, must-revalidate",...headers};return requestId&&(responseHeaders["X-Request-ID"]=requestId),{statusCode:200,headers:responseHeaders,body:"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",isBase64Encoded:!0}}(corsHeaders,requestId)}if("POST"===parsed.method){if(!parsed.body)return createResponse(400,{success:!1,error:"Request body is required",requestId:requestId},corsHeaders,requestId);const body=function(body,isBase64Encoded){if(!body||"string"!=typeof body)return body;try{const decoded=isBase64Encoded?Buffer.from(body,"base64").toString("utf8"):body;return JSON.parse(decoded)}catch(e){return body}}(parsed.body,parsed.isBase64Encoded);if(!body||"object"!=typeof body)return createResponse(400,{success:!1,error:"Invalid event body",requestId:requestId},corsHeaders,requestId);if(function(body){return"object"==typeof body&&null!==body&&"event"in body&&"string"==typeof body.event}(body)){const result=await async function(eventReq,push2,logger,requestId){var _a;try{const result=await push2({name:eventReq.event,data:eventReq.data||{},context:eventReq.context,user:eventReq.user,globals:eventReq.globals,consent:eventReq.consent});return{id:null==(_a=null==result?void 0:result.event)?void 0:_a.id}}catch(error){return null==logger||logger.error("Event processing failed",{error:error,eventName:eventReq.event,requestId:requestId}),{error:error instanceof Error?error.message:"Unknown error"}}}(body,envPush,env.logger,requestId);return result.error?createResponse(400,{success:!1,error:result.error,requestId:requestId},corsHeaders,requestId):createResponse(200,{success:!0,id:result.id,requestId:requestId},corsHeaders,requestId)}return createResponse(400,{success:!1,error:"Invalid request format",requestId:requestId},corsHeaders,requestId)}return createResponse(405,{success:!1,error:"Method not allowed",requestId:requestId},corsHeaders,requestId)}catch(error){return null==(_a=env.logger)||_a.error("Lambda handler error",{error:error,requestId:requestId,method:null==parsed?void 0:parsed.method}),createResponse(500,{success:!1,error:error instanceof Error?error.message:"Internal server error",requestId:requestId},{},requestId)}}}};export{types_exports as SourceLambda,examples_exports as examples,schemas_exports as schemas,lambda_default as sourceLambda};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lambda/index.ts","../src/lambda/utils.ts","../src/lambda/push.ts","../src/lambda/schemas/settings.ts","../src/lambda/schemas/primitives.ts","../src/lambda/types.ts","../src/lambda/schemas/index.ts","../src/lambda/examples/index.ts","../src/lambda/examples/env.ts","../src/lambda/examples/inputs.ts","../src/lambda/examples/events.ts","../src/lambda/examples/outputs.ts"],"sourcesContent":["import type { LambdaSource, Env, Settings, EventRequest, Types } from './types';\nimport type { Source } from '@walkeros/core';\nimport { requestToData } from '@walkeros/core';\nimport {\n parseEvent,\n parseBody,\n isEventRequest,\n getCorsHeaders,\n createResponse,\n createPixelResponse,\n getPath,\n} from './utils';\nimport { processEvent } from './push';\nimport { SettingsSchema } from './schemas/settings';\n\nexport * as SourceLambda from './types';\nexport * as schemas from './schemas';\n\n// Export examples\nexport * as examples from './examples';\n\nexport const sourceLambda = async (\n config: Partial<Source.Config<Types>> = {},\n env: Env,\n): Promise<LambdaSource> => {\n const { push: envPush } = env;\n\n const settings = SettingsSchema.parse(config.settings || {});\n\n const fullConfig: Source.Config<Types> = {\n ...config,\n settings,\n };\n\n const push: Types['push'] = async (event, context) => {\n const requestId = context.awsRequestId;\n let parsed;\n\n try {\n const corsHeaders = getCorsHeaders(settings.cors || false);\n parsed = parseEvent(event);\n const path = getPath(event);\n\n // Health check\n if (settings.healthPath && path === settings.healthPath) {\n return createResponse(\n 200,\n {\n status: 'ok',\n timestamp: Date.now(),\n source: 'lambda',\n requestId,\n },\n corsHeaders,\n requestId,\n );\n }\n\n // Handle OPTIONS for CORS preflight\n if (parsed.method === 'OPTIONS') {\n return createResponse(204, '', corsHeaders, requestId);\n }\n\n // Handle GET for pixel tracking\n if (parsed.method === 'GET') {\n if (!settings.enablePixelTracking) {\n return createResponse(\n 405,\n { success: false, error: 'GET not allowed', requestId },\n corsHeaders,\n requestId,\n );\n }\n if (parsed.queryString) {\n const parsedData = requestToData(parsed.queryString);\n if (parsedData && typeof parsedData === 'object') {\n await envPush(parsedData);\n }\n }\n return createPixelResponse(corsHeaders, requestId);\n }\n\n // Handle POST for event data\n if (parsed.method === 'POST') {\n if (!parsed.body) {\n return createResponse(\n 400,\n { success: false, error: 'Request body is required', requestId },\n corsHeaders,\n requestId,\n );\n }\n\n const body = parseBody(parsed.body, parsed.isBase64Encoded);\n\n if (!body || typeof body !== 'object') {\n return createResponse(\n 400,\n { success: false, error: 'Invalid event body', requestId },\n corsHeaders,\n requestId,\n );\n }\n\n if (isEventRequest(body)) {\n const result = await processEvent(\n body as EventRequest,\n envPush,\n env.logger,\n requestId,\n );\n\n if (result.error) {\n return createResponse(\n 400,\n { success: false, error: result.error, requestId },\n corsHeaders,\n requestId,\n );\n }\n\n return createResponse(\n 200,\n { success: true, id: result.id, requestId },\n corsHeaders,\n requestId,\n );\n }\n\n return createResponse(\n 400,\n { success: false, error: 'Invalid request format', requestId },\n corsHeaders,\n requestId,\n );\n }\n\n return createResponse(\n 405,\n { success: false, error: 'Method not allowed', requestId },\n corsHeaders,\n requestId,\n );\n } catch (error) {\n // Log handler errors with context - per using-logger skill\n env.logger?.error('Lambda handler error', {\n error,\n requestId,\n method: parsed?.method,\n });\n return createResponse(\n 500,\n {\n success: false,\n error:\n error instanceof Error ? error.message : 'Internal server error',\n requestId,\n },\n {},\n requestId,\n );\n }\n };\n\n return {\n type: 'lambda',\n config: fullConfig,\n push,\n };\n};\n\nexport default sourceLambda;\n","import type { APIGatewayProxyEventV2, APIGatewayProxyResult } from 'aws-lambda';\nimport type {\n LambdaEvent,\n ParsedRequest,\n CorsOptions,\n RequestBody,\n EventRequest,\n} from './types';\n\nexport function isAPIGatewayV2(\n event: LambdaEvent,\n): event is APIGatewayProxyEventV2 {\n return 'version' in event && event.version === '2.0';\n}\n\nexport function parseEvent(event: LambdaEvent): ParsedRequest {\n if (isAPIGatewayV2(event)) {\n const headers: Record<string, string> = {};\n if (event.headers) {\n Object.entries(event.headers).forEach(([key, value]) => {\n if (value) headers[key.toLowerCase()] = value;\n });\n }\n return {\n method: event.requestContext.http.method,\n body: event.body,\n queryString: event.rawQueryString || null,\n headers,\n isBase64Encoded: event.isBase64Encoded || false,\n };\n } else {\n const headers: Record<string, string> = {};\n if (event.headers) {\n Object.entries(event.headers).forEach(([key, value]) => {\n if (value) headers[key.toLowerCase()] = value;\n });\n }\n let queryString: string | null = null;\n if (event.queryStringParameters) {\n const params = new URLSearchParams();\n Object.entries(event.queryStringParameters).forEach(([key, value]) => {\n if (value) params.append(key, value);\n });\n queryString = params.toString() || null;\n }\n return {\n method: event.httpMethod,\n body: event.body,\n queryString,\n headers,\n isBase64Encoded: event.isBase64Encoded || false,\n };\n }\n}\n\nexport function getPath(event: LambdaEvent): string {\n if (isAPIGatewayV2(event)) {\n return event.rawPath;\n } else {\n return event.path;\n }\n}\n\nexport function parseBody(body: unknown, isBase64Encoded: boolean): unknown {\n if (!body || typeof body !== 'string') return body;\n try {\n const decoded = isBase64Encoded\n ? Buffer.from(body, 'base64').toString('utf8')\n : body;\n return JSON.parse(decoded);\n } catch {\n return body;\n }\n}\n\nexport function isEventRequest(body: unknown): body is EventRequest {\n return (\n typeof body === 'object' &&\n body !== null &&\n 'event' in body &&\n typeof (body as EventRequest).event === 'string'\n );\n}\n\nexport function getCorsHeaders(\n corsOptions: boolean | CorsOptions,\n): Record<string, string> {\n if (!corsOptions) return {};\n if (corsOptions === true) {\n return {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n 'Access-Control-Max-Age': '3600',\n };\n }\n\n const headers: Record<string, string> = {};\n\n if (corsOptions.origin) {\n const origin = Array.isArray(corsOptions.origin)\n ? corsOptions.origin.join(', ')\n : corsOptions.origin;\n headers['Access-Control-Allow-Origin'] = origin;\n }\n if (corsOptions.methods) {\n headers['Access-Control-Allow-Methods'] = corsOptions.methods.join(', ');\n }\n if (corsOptions.headers) {\n headers['Access-Control-Allow-Headers'] = corsOptions.headers.join(', ');\n }\n if (corsOptions.credentials) {\n headers['Access-Control-Allow-Credentials'] = 'true';\n }\n if (corsOptions.maxAge !== undefined) {\n headers['Access-Control-Max-Age'] = corsOptions.maxAge.toString();\n }\n\n return headers;\n}\n\nexport function createResponse(\n statusCode: number,\n body: unknown,\n headers: Record<string, string> = {},\n requestId?: string,\n): APIGatewayProxyResult {\n const responseHeaders: Record<string, string> = {\n 'Content-Type':\n typeof body === 'object' ? 'application/json' : 'text/plain',\n ...headers,\n };\n\n if (requestId) {\n responseHeaders['X-Request-ID'] = requestId;\n }\n\n return {\n statusCode,\n headers: responseHeaders,\n body: typeof body === 'object' ? JSON.stringify(body) : String(body),\n isBase64Encoded: false,\n };\n}\n\nexport function createPixelResponse(\n headers: Record<string, string> = {},\n requestId?: string,\n): APIGatewayProxyResult {\n const responseHeaders: Record<string, string> = {\n 'Content-Type': 'image/gif',\n 'Cache-Control': 'no-cache, no-store, must-revalidate',\n ...headers,\n };\n\n if (requestId) {\n responseHeaders['X-Request-ID'] = requestId;\n }\n\n return {\n statusCode: 200,\n headers: responseHeaders,\n body: 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',\n isBase64Encoded: true,\n };\n}\n","import type { Collector, WalkerOS, Logger } from '@walkeros/core';\nimport type { EventRequest } from './types';\n\nexport async function processEvent(\n eventReq: EventRequest,\n push: Collector.PushFn,\n logger?: Logger.Instance,\n requestId?: string,\n): Promise<{ id?: string; error?: string }> {\n try {\n const result = await push({\n name: eventReq.event,\n data: (eventReq.data || {}) as WalkerOS.Properties,\n context: eventReq.context as WalkerOS.OrderedProperties | undefined,\n user: eventReq.user as WalkerOS.User | undefined,\n globals: eventReq.globals as WalkerOS.Properties | undefined,\n consent: eventReq.consent as WalkerOS.Consent | undefined,\n });\n\n return { id: result?.event?.id };\n } catch (error) {\n // Log with structured context - per using-logger skill\n logger?.error('Event processing failed', {\n error,\n eventName: eventReq.event,\n requestId,\n });\n return { error: error instanceof Error ? error.message : 'Unknown error' };\n }\n}\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\n/**\n * AWS Lambda source settings schema\n */\nexport const SettingsSchema = z.object({\n cors: z\n .union([z.boolean(), CorsOptionsSchema])\n .describe(\n 'CORS configuration: false = disabled, true = allow all origins, object = custom configuration',\n )\n .default(true),\n\n timeout: z\n .number()\n .int()\n .positive()\n .max(900000) // AWS Lambda max timeout: 15 minutes\n .describe('Request timeout in milliseconds (max: 900000 for Lambda)')\n .default(30000),\n\n enablePixelTracking: z\n .boolean()\n .describe(\n 'Enable GET requests with 1x1 transparent GIF response for pixel tracking',\n )\n .default(true),\n\n healthPath: z\n .string()\n .describe('Health check endpoint path (e.g., /health)')\n .default('/health'),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * HTTP methods enum\n */\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\n/**\n * CORS origin configuration\n * Accepts:\n * - '*' for all origins\n * - Single URL string\n * - Array of URL strings\n */\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\n/**\n * CORS options schema\n * Configuration for Cross-Origin Resource Sharing\n */\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.describe(\n 'Allowed origins (* for all, URL string, or array of URLs)',\n ).optional(),\n\n methods: z.array(HttpMethod).describe('Allowed HTTP methods').optional(),\n\n headers: z.array(z.string()).describe('Allowed request headers').optional(),\n\n credentials: z\n .boolean()\n .describe('Allow credentials (cookies, authorization headers)')\n .optional(),\n\n maxAge: z\n .number()\n .int()\n .positive()\n .describe('Preflight cache duration in seconds')\n .optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","import type { WalkerOS, Source as CoreSource } from '@walkeros/core';\nimport type {\n APIGatewayProxyEvent,\n APIGatewayProxyEventV2,\n APIGatewayProxyResult,\n Context,\n} from 'aws-lambda';\nimport type { SettingsSchema, CorsOptionsSchema } from './schemas';\nimport { z } from '@walkeros/core/dev';\n\n// Lambda event types\nexport type LambdaEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2;\nexport type LambdaResult = APIGatewayProxyResult;\nexport type LambdaContext = Context;\n\n// Types inferred from Zod schemas\nexport type Settings = z.infer<typeof SettingsSchema>;\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n // Custom source event mapping properties\n}\n\n// Lambda-specific push type\nexport type Push = (\n event: LambdaEvent,\n context: LambdaContext,\n) => Promise<LambdaResult>;\n\nexport interface Env extends CoreSource.Env {\n lambdaEvent?: LambdaEvent;\n lambdaContext?: LambdaContext;\n}\n\n// Type bundle (must be after Settings, Mapping, Push, Env are defined)\nexport type Types = CoreSource.Types<\n Settings,\n Mapping,\n Push,\n Env,\n InitSettings\n>;\n\nexport interface LambdaSource extends Omit<CoreSource.Instance<Types>, 'push'> {\n push: Push;\n}\n\n// Convenience Config type\nexport type Config = CoreSource.Config<Types>;\nexport type PartialConfig = CoreSource.PartialConfig<Types>;\n\n// Lambda source doesn't follow standard Source.Init pattern due to Lambda handler interface\n\nexport interface EventRequest {\n event: string;\n data?: WalkerOS.AnyObject;\n context?: WalkerOS.AnyObject;\n user?: WalkerOS.AnyObject;\n globals?: WalkerOS.AnyObject;\n consent?: WalkerOS.AnyObject;\n}\n\nexport interface EventResponse {\n success: boolean;\n id?: string;\n error?: string;\n}\n\nexport type RequestBody = EventRequest;\nexport type ResponseBody = EventResponse;\n\n// Parsed request data structure\nexport interface ParsedRequest {\n method: string;\n body: unknown;\n queryString: string | null;\n headers: Record<string, string>;\n isBase64Encoded: boolean;\n}\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\n// Export primitives\nexport * from './primitives';\n\n// Export Zod schemas and types\nexport { SettingsSchema, type Settings } from './settings';\n\n// JSON Schema exports (for website PropertyTable and documentation tools)\nexport const settings = zodToSchema(SettingsSchema);\n","export * as env from './env';\nexport * as inputs from './inputs';\nexport * as events from './events';\nexport * as outputs from './outputs';\n","import type { Env } from '../types';\nimport type { Elb, Logger } from '@walkeros/core';\n\n/**\n * Example environment configurations for AWS Lambda source\n *\n * These environments provide standardized mock structures for testing\n * Lambda event handling without requiring actual Lambda deployment.\n */\n\n// Create a properly typed elb/push/command function that returns a promise with PushResult\nconst createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n successful: [],\n queued: [],\n failed: [],\n })) as Elb.Fn;\n return fn;\n};\n\n// Simple no-op logger for demo purposes\nconst noopFn = () => {};\nconst noopLogger: Logger.Instance = {\n error: noopFn,\n info: noopFn,\n debug: noopFn,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n scope: () => noopLogger,\n};\n\n/**\n * Standard mock environment for testing Lambda source\n *\n * Use this for testing Lambda event ingestion and request/response handling\n * without requiring a real AWS Lambda environment.\n */\nexport const push: Env = {\n get push() {\n return createMockElbFn();\n },\n get command() {\n return createMockElbFn();\n },\n get elb() {\n return createMockElbFn();\n },\n logger: noopLogger,\n};\n","import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from 'aws-lambda';\n\n/**\n * Real examples of Lambda events this source will receive.\n * These define the CONTRACT - implementation must handle these inputs.\n */\n\n// API Gateway v2 (HTTP API) - POST with walker event\nexport const apiGatewayV2PostEvent: APIGatewayProxyEventV2 = {\n version: '2.0',\n routeKey: '$default',\n rawPath: '/collect',\n rawQueryString: '',\n headers: {\n 'content-type': 'application/json',\n 'user-agent': 'Mozilla/5.0',\n },\n body: JSON.stringify({\n event: 'page view',\n data: { title: 'Home Page', path: '/' },\n user: { id: 'user-123' },\n }),\n isBase64Encoded: false,\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n domainName: 'api.example.com',\n domainPrefix: 'api',\n http: {\n method: 'POST',\n path: '/collect',\n protocol: 'HTTP/1.1',\n sourceIp: '1.2.3.4',\n userAgent: 'Mozilla/5.0',\n },\n requestId: 'request-123',\n routeKey: '$default',\n stage: 'prod',\n time: '01/Jan/2024:00:00:00 +0000',\n timeEpoch: 1704067200000,\n },\n};\n\n// API Gateway v2 - GET with query params (pixel tracking)\nexport const apiGatewayV2GetEvent: APIGatewayProxyEventV2 = {\n version: '2.0',\n routeKey: '$default',\n rawPath: '/collect',\n rawQueryString: 'event=button%20click&data[id]=cta&data[text]=Sign%20Up',\n headers: {},\n isBase64Encoded: false,\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n domainName: 'api.example.com',\n domainPrefix: 'api',\n http: {\n method: 'GET',\n path: '/collect',\n protocol: 'HTTP/1.1',\n sourceIp: '1.2.3.4',\n userAgent: 'Mozilla/5.0',\n },\n requestId: 'request-456',\n routeKey: '$default',\n stage: 'prod',\n time: '01/Jan/2024:00:00:01 +0000',\n timeEpoch: 1704067201000,\n },\n};\n\n// API Gateway v1 (REST API) - POST with walker event\nexport const apiGatewayV1PostEvent: APIGatewayProxyEvent = {\n httpMethod: 'POST',\n path: '/collect',\n body: JSON.stringify({\n event: 'product add',\n data: { id: 'P123', name: 'Laptop', price: 999 },\n }),\n headers: { 'content-type': 'application/json' },\n multiValueHeaders: {},\n isBase64Encoded: false,\n pathParameters: null,\n queryStringParameters: null,\n multiValueQueryStringParameters: null,\n stageVariables: null,\n resource: '/collect',\n requestContext: {\n accountId: '123456789012',\n apiId: 'api-id',\n protocol: 'HTTP/1.1',\n httpMethod: 'POST',\n path: '/collect',\n stage: 'prod',\n requestId: 'request-789',\n requestTimeEpoch: 1704067202000,\n resourceId: 'resource-id',\n resourcePath: '/collect',\n identity: {\n sourceIp: '1.2.3.4',\n userAgent: 'Mozilla/5.0',\n accessKey: null,\n accountId: null,\n apiKey: null,\n apiKeyId: null,\n caller: null,\n clientCert: null,\n cognitoAuthenticationProvider: null,\n cognitoAuthenticationType: null,\n cognitoIdentityId: null,\n cognitoIdentityPoolId: null,\n principalOrgId: null,\n user: null,\n userArn: null,\n },\n authorizer: null,\n },\n};\n\n// Health check request\nexport const healthCheckEvent: APIGatewayProxyEventV2 = {\n ...apiGatewayV2GetEvent,\n rawPath: '/health',\n rawQueryString: '',\n requestContext: {\n ...apiGatewayV2GetEvent.requestContext,\n http: {\n ...apiGatewayV2GetEvent.requestContext.http,\n path: '/health',\n },\n },\n};\n\n// Invalid event - malformed JSON\nexport const invalidJsonEvent: APIGatewayProxyEventV2 = {\n ...apiGatewayV2PostEvent,\n body: '{invalid json',\n};\n\n// Missing event field\nexport const missingEventField: APIGatewayProxyEventV2 = {\n ...apiGatewayV2PostEvent,\n body: JSON.stringify({ data: { foo: 'bar' } }),\n};\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS events from Lambda inputs.\n * These are what processEvent should produce.\n */\n\n// From apiGatewayV2PostEvent\nexport const pageViewEvent: Partial<WalkerOS.Event> = {\n name: 'page view',\n data: { title: 'Home Page', path: '/' },\n user: { id: 'user-123' },\n};\n\n// From apiGatewayV2GetEvent\nexport const buttonClickEvent: Partial<WalkerOS.Event> = {\n name: 'button click',\n data: { id: 'cta', text: 'Sign Up' },\n};\n\n// From apiGatewayV1PostEvent\nexport const productAddEvent: Partial<WalkerOS.Event> = {\n name: 'product add',\n data: { id: 'P123', name: 'Laptop', price: 999 },\n};\n","import type { APIGatewayProxyResult } from 'aws-lambda';\n\n/**\n * Expected Lambda response outputs.\n * Tests verify implementation produces these.\n */\n\n// Successful event processing\nexport const successResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 200,\n headers: {\n 'Content-Type': 'application/json',\n 'Access-Control-Allow-Origin': '*',\n },\n body: expect.stringContaining('\"success\":true'),\n};\n\n// Health check response\nexport const healthResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 200,\n body: expect.stringContaining('\"status\":\"ok\"'),\n};\n\n// Pixel tracking response\nexport const pixelResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 200,\n headers: expect.objectContaining({\n 'Content-Type': 'image/gif',\n }),\n isBase64Encoded: true,\n};\n\n// Error responses\nexport const invalidBodyResponse: Partial<APIGatewayProxyResult> = {\n statusCode: 400,\n body: expect.stringContaining('\"success\":false'),\n};\n"],"mappings":";;;;;;;AAEA,SAAS,qBAAqB;;;ACOvB,SAAS,eACd,OACiC;AACjC,SAAO,aAAa,SAAS,MAAM,YAAY;AACjD;AAEO,SAAS,WAAW,OAAmC;AAC5D,MAAI,eAAe,KAAK,GAAG;AACzB,UAAM,UAAkC,CAAC;AACzC,QAAI,MAAM,SAAS;AACjB,aAAO,QAAQ,MAAM,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACtD,YAAI,MAAO,SAAQ,IAAI,YAAY,CAAC,IAAI;AAAA,MAC1C,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL,QAAQ,MAAM,eAAe,KAAK;AAAA,MAClC,MAAM,MAAM;AAAA,MACZ,aAAa,MAAM,kBAAkB;AAAA,MACrC;AAAA,MACA,iBAAiB,MAAM,mBAAmB;AAAA,IAC5C;AAAA,EACF,OAAO;AACL,UAAM,UAAkC,CAAC;AACzC,QAAI,MAAM,SAAS;AACjB,aAAO,QAAQ,MAAM,OAAO,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACtD,YAAI,MAAO,SAAQ,IAAI,YAAY,CAAC,IAAI;AAAA,MAC1C,CAAC;AAAA,IACH;AACA,QAAI,cAA6B;AACjC,QAAI,MAAM,uBAAuB;AAC/B,YAAM,SAAS,IAAI,gBAAgB;AACnC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AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA,EAAE,SAAS,OAAO,OAAO,sBAAsB,UAAU;AAAA,QACzD;AAAA,QACA;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AAEd,gBAAI,WAAJ,mBAAY,MAAM,wBAAwB;AAAA,QACxC;AAAA,QACA;AAAA,QACA,QAAQ,iCAAQ;AAAA,MAClB;AACA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE,SAAS;AAAA,UACT,OACE,iBAAiB,QAAQ,MAAM,UAAU;AAAA,UAC3C;AAAA,QACF;AAAA,QACA,CAAC;AAAA,QACD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAAC;AAAA,EACF;AACF;AAEA,IAAO,iBAAQ;","names":["push","z","z","settings","push"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/server-source-aws",
|
|
3
|
+
"description": "AWS server sources for walkerOS (Lambda, API Gateway, Function URLs)",
|
|
4
|
+
"version": "0.0.0-next-20251219153324",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/**",
|
|
11
|
+
"README.md",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup --silent",
|
|
16
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
17
|
+
"dev": "jest --watchAll --colors",
|
|
18
|
+
"lint": "tsc && eslint \"**/*.ts*\"",
|
|
19
|
+
"test": "jest",
|
|
20
|
+
"update": "npx npm-check-updates -u && npm update"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@walkeros/core": "0.0.0-next-20251219153324"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@types/aws-lambda": "^8.10.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/aws-lambda": "^8.10.159"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
33
|
+
"directory": "packages/server/sources/aws"
|
|
34
|
+
},
|
|
35
|
+
"author": "elbwalker <hello@elbwalker.com>",
|
|
36
|
+
"homepage": "https://github.com/elbwalker/walkerOS#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/elbwalker/walkerOS/issues"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"walker",
|
|
42
|
+
"walkerOS",
|
|
43
|
+
"source",
|
|
44
|
+
"server",
|
|
45
|
+
"aws",
|
|
46
|
+
"lambda",
|
|
47
|
+
"api gateway"
|
|
48
|
+
],
|
|
49
|
+
"funding": [
|
|
50
|
+
{
|
|
51
|
+
"type": "GitHub Sponsors",
|
|
52
|
+
"url": "https://github.com/sponsors/elbwalker"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"exports": {
|
|
56
|
+
".": {
|
|
57
|
+
"types": "./dist/index.d.ts",
|
|
58
|
+
"import": "./dist/index.mjs",
|
|
59
|
+
"require": "./dist/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./dev": {
|
|
62
|
+
"types": "./dist/dev.d.ts",
|
|
63
|
+
"import": "./dist/dev.mjs",
|
|
64
|
+
"require": "./dist/dev.js"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|