effortless-aws 0.32.1 → 0.33.1

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/index.js CHANGED
@@ -116,6 +116,7 @@ var defineApp = () => (options) => ({
116
116
  });
117
117
 
118
118
  // src/handlers/define-static-site.ts
119
+ var isBucketRoute = (v) => v != null && typeof v === "object" && "bucket" in v && v.bucket != null && typeof v.bucket === "object" && v.bucket.__brand === "effortless-bucket";
119
120
  var defineStaticSite = () => (options) => ({
120
121
  __brand: "effortless-static-site",
121
122
  __spec: options
@@ -231,6 +232,13 @@ function defineBucket(options) {
231
232
  state.static = [...state.static ?? [], glob];
232
233
  return builder;
233
234
  },
235
+ entity(name, options2) {
236
+ state.spec = {
237
+ ...state.spec,
238
+ entities: { ...state.spec.entities, [name]: options2 ?? {} }
239
+ };
240
+ return builder;
241
+ },
234
242
  setup(fnOrLambda, maybeLambda) {
235
243
  if (typeof fnOrLambda === "function") {
236
244
  state.setup = fnOrLambda;
@@ -270,6 +278,20 @@ var defineMailer = () => (options) => ({
270
278
  });
271
279
 
272
280
  // src/handlers/define-api.ts
281
+ var resolveCache = (cache) => {
282
+ if (typeof cache === "number" || typeof cache === "string") {
283
+ const ttl2 = toSeconds(cache);
284
+ return { ttl: ttl2, swr: ttl2 * 2 };
285
+ }
286
+ const ttl = toSeconds(cache.ttl);
287
+ if (cache.scope === "private") {
288
+ return { private: true, ttl };
289
+ }
290
+ return {
291
+ ttl,
292
+ swr: cache.swr != null ? toSeconds(cache.swr) : ttl * 2
293
+ };
294
+ };
273
295
  function defineApi(options) {
274
296
  const { basePath, stream } = options;
275
297
  const state = {
@@ -280,11 +302,13 @@ function defineApi(options) {
280
302
  routes: []
281
303
  };
282
304
  const addRoute = (method, path, handler, opts) => {
305
+ const routeCache = opts?.cache != null ? resolveCache(opts.cache) : void 0;
283
306
  state.routes.push({
284
307
  method,
285
308
  path,
286
309
  onRequest: handler,
287
- ...opts?.public ? { public: true } : {}
310
+ ...opts?.public ? { public: true } : {},
311
+ ...routeCache ? { cache: routeCache } : {}
288
312
  });
289
313
  };
290
314
  const applyLambdaOptions = (lambda) => {
@@ -490,6 +514,67 @@ function defineWorker(options) {
490
514
  };
491
515
  return builder;
492
516
  }
517
+
518
+ // src/handlers/define-mcp.ts
519
+ function defineMcp(options) {
520
+ const spec = {
521
+ name: options.name,
522
+ ...options.version ? { version: options.version } : {}
523
+ };
524
+ const state = { spec };
525
+ const applyLambdaOptions = (lambda) => {
526
+ if (Object.keys(lambda).length > 0) {
527
+ state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
528
+ }
529
+ };
530
+ const finalize = () => ({
531
+ __brand: "effortless-mcp",
532
+ __spec: state.spec,
533
+ ...state.onError ? { onError: state.onError } : {},
534
+ ...state.onCleanup ? { onCleanup: state.onCleanup } : {},
535
+ ...state.setup ? { setup: state.setup } : {},
536
+ ...state.deps ? { deps: state.deps } : {},
537
+ ...state.config ? { config: state.config } : {},
538
+ ...state.static ? { static: state.static } : {},
539
+ ...state.tools ? { tools: state.tools } : {}
540
+ });
541
+ const builder = {
542
+ deps(fn) {
543
+ state.deps = fn;
544
+ return builder;
545
+ },
546
+ config(fn) {
547
+ state.config = resolveConfigFactory(fn);
548
+ return builder;
549
+ },
550
+ include(glob) {
551
+ state.static = [...state.static ?? [], glob];
552
+ return builder;
553
+ },
554
+ setup(fnOrLambda, maybeLambda) {
555
+ if (typeof fnOrLambda === "function") {
556
+ state.setup = fnOrLambda;
557
+ if (maybeLambda) applyLambdaOptions(maybeLambda);
558
+ } else {
559
+ applyLambdaOptions(fnOrLambda);
560
+ }
561
+ return builder;
562
+ },
563
+ onError(fn) {
564
+ state.onError = fn;
565
+ return builder;
566
+ },
567
+ onCleanup(fn) {
568
+ state.onCleanup = fn;
569
+ return builder;
570
+ },
571
+ tools(fn) {
572
+ state.tools = fn;
573
+ return finalize();
574
+ }
575
+ };
576
+ return builder;
577
+ }
493
578
  export {
494
579
  defineApi,
495
580
  defineApp,
@@ -498,6 +583,7 @@ export {
498
583
  defineCron,
499
584
  defineFifoQueue,
500
585
  defineMailer,
586
+ defineMcp,
501
587
  defineSecret,
502
588
  defineStaticSite,
503
589
  defineTable,
@@ -505,6 +591,7 @@ export {
505
591
  generateBase64,
506
592
  generateHex,
507
593
  generateUuid,
594
+ isBucketRoute,
508
595
  param,
509
596
  secret,
510
597
  toSeconds