effortless-aws 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ISJC6CHC.js → chunk-HGSMOO4A.js} +60 -1
- package/dist/index.d.ts +319 -188
- package/dist/index.js +199 -54
- package/dist/index.js.map +1 -1
- package/dist/runtime/wrap-api.js +2 -2
- package/dist/runtime/wrap-bucket.js +2 -2
- package/dist/runtime/wrap-cron.js +40 -0
- package/dist/runtime/wrap-fifo-queue.js +4 -4
- package/dist/runtime/wrap-table-stream.js +5 -5
- package/dist/runtime/wrap-worker.js +109 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -34,30 +34,22 @@ var param = (key, transform) => {
|
|
|
34
34
|
var generateHex = (bytes) => `hex:${bytes}`;
|
|
35
35
|
var generateBase64 = (bytes) => `base64:${bytes}`;
|
|
36
36
|
var generateUuid = () => "uuid";
|
|
37
|
-
function unsafeAs() {
|
|
38
|
-
return (input) => input;
|
|
39
|
-
}
|
|
40
37
|
|
|
41
38
|
// src/handlers/define-table.ts
|
|
42
39
|
function defineTable(options) {
|
|
43
40
|
const {
|
|
44
|
-
memory,
|
|
45
|
-
timeout,
|
|
46
|
-
permissions,
|
|
47
|
-
logLevel,
|
|
48
41
|
schema,
|
|
49
|
-
static: staticFiles,
|
|
50
42
|
...tableConfig
|
|
51
43
|
} = options ?? {};
|
|
52
|
-
const
|
|
53
|
-
const spec = {
|
|
54
|
-
...tableConfig,
|
|
55
|
-
...hasLambda ? { lambda: { ...memory != null ? { memory } : {}, ...timeout != null ? { timeout } : {}, ...permissions ? { permissions } : {}, ...logLevel ? { logLevel } : {} } } : {}
|
|
56
|
-
};
|
|
44
|
+
const spec = { ...tableConfig };
|
|
57
45
|
const state = {
|
|
58
46
|
spec,
|
|
59
|
-
...schema ? { schema } : {}
|
|
60
|
-
|
|
47
|
+
...schema ? { schema } : {}
|
|
48
|
+
};
|
|
49
|
+
const applyLambdaOptions = (lambda) => {
|
|
50
|
+
if (Object.keys(lambda).length > 0) {
|
|
51
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
52
|
+
}
|
|
61
53
|
};
|
|
62
54
|
const finalize = () => ({
|
|
63
55
|
__brand: "effortless-table",
|
|
@@ -81,8 +73,17 @@ function defineTable(options) {
|
|
|
81
73
|
state.config = resolveConfigFactory(fn);
|
|
82
74
|
return builder;
|
|
83
75
|
},
|
|
84
|
-
|
|
85
|
-
state.
|
|
76
|
+
include(glob) {
|
|
77
|
+
state.static = [...state.static ?? [], glob];
|
|
78
|
+
return builder;
|
|
79
|
+
},
|
|
80
|
+
setup(fnOrLambda, maybeLambda) {
|
|
81
|
+
if (typeof fnOrLambda === "function") {
|
|
82
|
+
state.setup = fnOrLambda;
|
|
83
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
84
|
+
} else {
|
|
85
|
+
applyLambdaOptions(fnOrLambda);
|
|
86
|
+
}
|
|
86
87
|
return builder;
|
|
87
88
|
},
|
|
88
89
|
onRecord(fn) {
|
|
@@ -123,23 +124,18 @@ var defineStaticSite = () => (options) => ({
|
|
|
123
124
|
// src/handlers/define-fifo-queue.ts
|
|
124
125
|
function defineFifoQueue(options) {
|
|
125
126
|
const {
|
|
126
|
-
memory,
|
|
127
|
-
timeout,
|
|
128
|
-
permissions,
|
|
129
|
-
logLevel,
|
|
130
127
|
schema,
|
|
131
|
-
static: staticFiles,
|
|
132
128
|
...queueConfig
|
|
133
129
|
} = options ?? {};
|
|
134
|
-
const
|
|
135
|
-
const spec = {
|
|
136
|
-
...queueConfig,
|
|
137
|
-
...hasLambda ? { lambda: { ...memory != null ? { memory } : {}, ...timeout != null ? { timeout } : {}, ...permissions ? { permissions } : {}, ...logLevel ? { logLevel } : {} } } : {}
|
|
138
|
-
};
|
|
130
|
+
const spec = { ...queueConfig };
|
|
139
131
|
const state = {
|
|
140
132
|
spec,
|
|
141
|
-
...schema ? { schema } : {}
|
|
142
|
-
|
|
133
|
+
...schema ? { schema } : {}
|
|
134
|
+
};
|
|
135
|
+
const applyLambdaOptions = (lambda) => {
|
|
136
|
+
if (Object.keys(lambda).length > 0) {
|
|
137
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
138
|
+
}
|
|
143
139
|
};
|
|
144
140
|
const finalize = () => ({
|
|
145
141
|
__brand: "effortless-fifo-queue",
|
|
@@ -163,8 +159,17 @@ function defineFifoQueue(options) {
|
|
|
163
159
|
state.config = resolveConfigFactory(fn);
|
|
164
160
|
return builder;
|
|
165
161
|
},
|
|
166
|
-
|
|
167
|
-
state.
|
|
162
|
+
include(glob) {
|
|
163
|
+
state.static = [...state.static ?? [], glob];
|
|
164
|
+
return builder;
|
|
165
|
+
},
|
|
166
|
+
setup(fnOrLambda, maybeLambda) {
|
|
167
|
+
if (typeof fnOrLambda === "function") {
|
|
168
|
+
state.setup = fnOrLambda;
|
|
169
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
170
|
+
} else {
|
|
171
|
+
applyLambdaOptions(fnOrLambda);
|
|
172
|
+
}
|
|
168
173
|
return builder;
|
|
169
174
|
},
|
|
170
175
|
onMessage(fn) {
|
|
@@ -189,22 +194,17 @@ function defineFifoQueue(options) {
|
|
|
189
194
|
|
|
190
195
|
// src/handlers/define-bucket.ts
|
|
191
196
|
function defineBucket(options) {
|
|
192
|
-
const {
|
|
193
|
-
memory,
|
|
194
|
-
timeout,
|
|
195
|
-
permissions,
|
|
196
|
-
logLevel,
|
|
197
|
-
static: staticFiles,
|
|
198
|
-
...bucketConfig
|
|
199
|
-
} = options ?? {};
|
|
200
|
-
const hasLambda = memory != null || timeout != null || permissions != null || logLevel != null;
|
|
197
|
+
const bucketConfig = options ?? {};
|
|
201
198
|
const spec = {
|
|
202
|
-
...bucketConfig
|
|
203
|
-
...hasLambda ? { lambda: { ...memory != null ? { memory } : {}, ...timeout != null ? { timeout } : {}, ...permissions ? { permissions } : {}, ...logLevel ? { logLevel } : {} } } : {}
|
|
199
|
+
...bucketConfig
|
|
204
200
|
};
|
|
205
201
|
const state = {
|
|
206
|
-
spec
|
|
207
|
-
|
|
202
|
+
spec
|
|
203
|
+
};
|
|
204
|
+
const applyLambdaOptions = (lambda) => {
|
|
205
|
+
if (Object.keys(lambda).length > 0) {
|
|
206
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
207
|
+
}
|
|
208
208
|
};
|
|
209
209
|
const finalize = () => ({
|
|
210
210
|
__brand: "effortless-bucket",
|
|
@@ -227,8 +227,17 @@ function defineBucket(options) {
|
|
|
227
227
|
state.config = resolveConfigFactory(fn);
|
|
228
228
|
return builder;
|
|
229
229
|
},
|
|
230
|
-
|
|
231
|
-
state.
|
|
230
|
+
include(glob) {
|
|
231
|
+
state.static = [...state.static ?? [], glob];
|
|
232
|
+
return builder;
|
|
233
|
+
},
|
|
234
|
+
setup(fnOrLambda, maybeLambda) {
|
|
235
|
+
if (typeof fnOrLambda === "function") {
|
|
236
|
+
state.setup = fnOrLambda;
|
|
237
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
238
|
+
} else {
|
|
239
|
+
applyLambdaOptions(fnOrLambda);
|
|
240
|
+
}
|
|
232
241
|
return builder;
|
|
233
242
|
},
|
|
234
243
|
onObjectCreated(fn) {
|
|
@@ -262,15 +271,12 @@ var defineMailer = () => (options) => ({
|
|
|
262
271
|
|
|
263
272
|
// src/handlers/define-api.ts
|
|
264
273
|
function defineApi(options) {
|
|
265
|
-
const { basePath, stream
|
|
266
|
-
const hasLambda = Object.keys(lambdaConfig).length > 0;
|
|
274
|
+
const { basePath, stream } = options;
|
|
267
275
|
const state = {
|
|
268
276
|
spec: {
|
|
269
277
|
basePath,
|
|
270
|
-
...hasLambda ? { lambda: lambdaConfig } : {},
|
|
271
278
|
...stream ? { stream } : {}
|
|
272
279
|
},
|
|
273
|
-
...staticFiles ? { static: staticFiles } : {},
|
|
274
280
|
routes: []
|
|
275
281
|
};
|
|
276
282
|
const addRoute = (method, path, handler, opts) => {
|
|
@@ -281,6 +287,11 @@ function defineApi(options) {
|
|
|
281
287
|
...opts?.public ? { public: true } : {}
|
|
282
288
|
});
|
|
283
289
|
};
|
|
290
|
+
const applyLambdaOptions = (lambda) => {
|
|
291
|
+
if (Object.keys(lambda).length > 0) {
|
|
292
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
293
|
+
}
|
|
294
|
+
};
|
|
284
295
|
const finalize = () => {
|
|
285
296
|
const handler = {
|
|
286
297
|
__brand: "effortless-api",
|
|
@@ -311,8 +322,17 @@ function defineApi(options) {
|
|
|
311
322
|
state.config = resolveConfigFactory(fn);
|
|
312
323
|
return builder;
|
|
313
324
|
},
|
|
314
|
-
|
|
315
|
-
state.
|
|
325
|
+
include(glob) {
|
|
326
|
+
state.static = [...state.static ?? [], glob];
|
|
327
|
+
return builder;
|
|
328
|
+
},
|
|
329
|
+
setup(fnOrLambda, maybeLambda) {
|
|
330
|
+
if (typeof fnOrLambda === "function") {
|
|
331
|
+
state.setup = fnOrLambda;
|
|
332
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
333
|
+
} else {
|
|
334
|
+
applyLambdaOptions(fnOrLambda);
|
|
335
|
+
}
|
|
316
336
|
return builder;
|
|
317
337
|
},
|
|
318
338
|
onError(fn) {
|
|
@@ -346,22 +366,147 @@ function defineApi(options) {
|
|
|
346
366
|
};
|
|
347
367
|
return builder;
|
|
348
368
|
}
|
|
369
|
+
|
|
370
|
+
// src/handlers/define-cron.ts
|
|
371
|
+
function defineCron(options) {
|
|
372
|
+
const { schedule, timezone } = options;
|
|
373
|
+
const spec = {
|
|
374
|
+
schedule,
|
|
375
|
+
...timezone ? { timezone } : {}
|
|
376
|
+
};
|
|
377
|
+
const state = { spec };
|
|
378
|
+
const applyLambdaOptions = (lambda) => {
|
|
379
|
+
if (Object.keys(lambda).length > 0) {
|
|
380
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
const finalize = () => ({
|
|
384
|
+
__brand: "effortless-cron",
|
|
385
|
+
__spec: state.spec,
|
|
386
|
+
...state.onError ? { onError: state.onError } : {},
|
|
387
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
388
|
+
...state.setup ? { setup: state.setup } : {},
|
|
389
|
+
...state.deps ? { deps: state.deps } : {},
|
|
390
|
+
...state.config ? { config: state.config } : {},
|
|
391
|
+
...state.static ? { static: state.static } : {},
|
|
392
|
+
...state.onTick ? { onTick: state.onTick } : {}
|
|
393
|
+
});
|
|
394
|
+
const builder = {
|
|
395
|
+
deps(fn) {
|
|
396
|
+
state.deps = fn;
|
|
397
|
+
return builder;
|
|
398
|
+
},
|
|
399
|
+
config(fn) {
|
|
400
|
+
state.config = resolveConfigFactory(fn);
|
|
401
|
+
return builder;
|
|
402
|
+
},
|
|
403
|
+
include(glob) {
|
|
404
|
+
state.static = [...state.static ?? [], glob];
|
|
405
|
+
return builder;
|
|
406
|
+
},
|
|
407
|
+
setup(fnOrLambda, maybeLambda) {
|
|
408
|
+
if (typeof fnOrLambda === "function") {
|
|
409
|
+
state.setup = fnOrLambda;
|
|
410
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
411
|
+
} else {
|
|
412
|
+
applyLambdaOptions(fnOrLambda);
|
|
413
|
+
}
|
|
414
|
+
return builder;
|
|
415
|
+
},
|
|
416
|
+
onError(fn) {
|
|
417
|
+
state.onError = fn;
|
|
418
|
+
return builder;
|
|
419
|
+
},
|
|
420
|
+
onCleanup(fn) {
|
|
421
|
+
state.onCleanup = fn;
|
|
422
|
+
return builder;
|
|
423
|
+
},
|
|
424
|
+
onTick(fn) {
|
|
425
|
+
state.onTick = fn;
|
|
426
|
+
return finalize();
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
return builder;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/handlers/define-worker.ts
|
|
433
|
+
function defineWorker(options) {
|
|
434
|
+
const spec = {
|
|
435
|
+
...options?.size ? { size: options.size } : {},
|
|
436
|
+
...options?.idleTimeout ? { idleTimeout: options.idleTimeout } : {},
|
|
437
|
+
...options?.concurrency ? { concurrency: options.concurrency } : {}
|
|
438
|
+
};
|
|
439
|
+
const state = { spec };
|
|
440
|
+
const applyLambdaOptions = (lambda) => {
|
|
441
|
+
if (Object.keys(lambda).length > 0) {
|
|
442
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
const finalize = () => ({
|
|
446
|
+
__brand: "effortless-worker",
|
|
447
|
+
__spec: state.spec,
|
|
448
|
+
...state.onError ? { onError: state.onError } : {},
|
|
449
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
450
|
+
...state.setup ? { setup: state.setup } : {},
|
|
451
|
+
...state.deps ? { deps: state.deps } : {},
|
|
452
|
+
...state.config ? { config: state.config } : {},
|
|
453
|
+
...state.static ? { static: state.static } : {},
|
|
454
|
+
...state.onMessage ? { onMessage: state.onMessage } : {}
|
|
455
|
+
});
|
|
456
|
+
const builder = {
|
|
457
|
+
deps(fn) {
|
|
458
|
+
state.deps = fn;
|
|
459
|
+
return builder;
|
|
460
|
+
},
|
|
461
|
+
config(fn) {
|
|
462
|
+
state.config = resolveConfigFactory(fn);
|
|
463
|
+
return builder;
|
|
464
|
+
},
|
|
465
|
+
include(glob) {
|
|
466
|
+
state.static = [...state.static ?? [], glob];
|
|
467
|
+
return builder;
|
|
468
|
+
},
|
|
469
|
+
setup(fnOrLambda, maybeLambda) {
|
|
470
|
+
if (typeof fnOrLambda === "function") {
|
|
471
|
+
state.setup = fnOrLambda;
|
|
472
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
473
|
+
} else {
|
|
474
|
+
applyLambdaOptions(fnOrLambda);
|
|
475
|
+
}
|
|
476
|
+
return builder;
|
|
477
|
+
},
|
|
478
|
+
onError(fn) {
|
|
479
|
+
state.onError = fn;
|
|
480
|
+
return builder;
|
|
481
|
+
},
|
|
482
|
+
onCleanup(fn) {
|
|
483
|
+
state.onCleanup = fn;
|
|
484
|
+
return builder;
|
|
485
|
+
},
|
|
486
|
+
onMessage(fn) {
|
|
487
|
+
state.onMessage = fn;
|
|
488
|
+
return finalize();
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
return builder;
|
|
492
|
+
}
|
|
349
493
|
export {
|
|
350
494
|
defineApi,
|
|
351
495
|
defineApp,
|
|
352
496
|
defineBucket,
|
|
353
497
|
defineConfig,
|
|
498
|
+
defineCron,
|
|
354
499
|
defineFifoQueue,
|
|
355
500
|
defineMailer,
|
|
356
501
|
defineSecret,
|
|
357
502
|
defineStaticSite,
|
|
358
503
|
defineTable,
|
|
504
|
+
defineWorker,
|
|
359
505
|
generateBase64,
|
|
360
506
|
generateHex,
|
|
361
507
|
generateUuid,
|
|
362
508
|
param,
|
|
363
509
|
secret,
|
|
364
|
-
toSeconds
|
|
365
|
-
unsafeAs
|
|
510
|
+
toSeconds
|
|
366
511
|
};
|
|
367
512
|
//# sourceMappingURL=index.js.map
|