effortless-aws 0.34.0 → 0.36.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-6HFS224S.js → chunk-Q3ZDMZF3.js} +13 -4
- package/dist/index.d.ts +160 -124
- package/dist/index.js +109 -44
- package/dist/index.js.map +1 -1
- package/dist/runtime/wrap-api.js +19 -3
- package/dist/runtime/wrap-bucket.js +1 -1
- package/dist/runtime/wrap-cron.js +1 -1
- package/dist/runtime/wrap-fifo-queue.js +1 -1
- package/dist/runtime/wrap-mcp.js +76 -19
- package/dist/runtime/wrap-middleware.js +1 -1
- package/dist/runtime/wrap-table-stream.js +1 -1
- package/dist/runtime/wrap-worker.js +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -116,11 +116,32 @@ var defineApp = () => (options) => ({
|
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
// src/handlers/define-static-site.ts
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
function defineStaticSite(options) {
|
|
120
|
+
const state = {
|
|
121
|
+
spec: { ...options },
|
|
122
|
+
routes: [],
|
|
123
|
+
middleware: void 0
|
|
124
|
+
};
|
|
125
|
+
const builder = {
|
|
126
|
+
route(pattern, origin, opts) {
|
|
127
|
+
state.routes.push({ pattern, origin, ...opts?.access ? { access: opts.access } : {} });
|
|
128
|
+
return builder;
|
|
129
|
+
},
|
|
130
|
+
middleware(fn) {
|
|
131
|
+
state.middleware = fn;
|
|
132
|
+
return builder;
|
|
133
|
+
},
|
|
134
|
+
build() {
|
|
135
|
+
return {
|
|
136
|
+
__brand: "effortless-static-site",
|
|
137
|
+
__spec: state.spec,
|
|
138
|
+
routes: state.routes,
|
|
139
|
+
...state.middleware ? { middleware: state.middleware } : {}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return builder;
|
|
144
|
+
}
|
|
124
145
|
|
|
125
146
|
// src/handlers/define-fifo-queue.ts
|
|
126
147
|
function defineFifoQueue(options) {
|
|
@@ -301,13 +322,14 @@ function defineApi(options) {
|
|
|
301
322
|
},
|
|
302
323
|
routes: []
|
|
303
324
|
};
|
|
304
|
-
const addRoute = (method,
|
|
305
|
-
const routeCache =
|
|
325
|
+
const addRoute = (method, def, handler) => {
|
|
326
|
+
const routeCache = def.cache != null ? resolveCache(def.cache) : void 0;
|
|
306
327
|
state.routes.push({
|
|
307
328
|
method,
|
|
308
|
-
path,
|
|
329
|
+
path: def.path,
|
|
309
330
|
onRequest: handler,
|
|
310
|
-
...
|
|
331
|
+
...def.input ? { schema: def.input } : {},
|
|
332
|
+
...def.public ? { public: true } : {},
|
|
311
333
|
...routeCache ? { cache: routeCache } : {}
|
|
312
334
|
});
|
|
313
335
|
};
|
|
@@ -324,13 +346,14 @@ function defineApi(options) {
|
|
|
324
346
|
...state.onError ? { onError: state.onError } : {},
|
|
325
347
|
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
326
348
|
...state.setup ? { setup: state.setup } : {},
|
|
349
|
+
...state.authFn ? { authFn: state.authFn } : {},
|
|
327
350
|
...state.deps ? { deps: state.deps } : {},
|
|
328
351
|
...state.config ? { config: state.config } : {},
|
|
329
352
|
...state.static ? { static: state.static } : {}
|
|
330
353
|
};
|
|
331
354
|
for (const m of ["get", "post", "put", "patch", "delete"]) {
|
|
332
|
-
handler[m] = (
|
|
333
|
-
addRoute(m.toUpperCase(),
|
|
355
|
+
handler[m] = (def, fn) => {
|
|
356
|
+
addRoute(m.toUpperCase(), def, fn);
|
|
334
357
|
handler.routes = state.routes;
|
|
335
358
|
return handler;
|
|
336
359
|
};
|
|
@@ -350,6 +373,10 @@ function defineApi(options) {
|
|
|
350
373
|
state.static = [...state.static ?? [], glob];
|
|
351
374
|
return builder;
|
|
352
375
|
},
|
|
376
|
+
auth(fn) {
|
|
377
|
+
state.authFn = fn;
|
|
378
|
+
return builder;
|
|
379
|
+
},
|
|
353
380
|
setup(fnOrLambda, maybeLambda) {
|
|
354
381
|
if (typeof fnOrLambda === "function") {
|
|
355
382
|
state.setup = fnOrLambda;
|
|
@@ -367,24 +394,24 @@ function defineApi(options) {
|
|
|
367
394
|
state.onCleanup = fn;
|
|
368
395
|
return builder;
|
|
369
396
|
},
|
|
370
|
-
get(
|
|
371
|
-
addRoute("GET",
|
|
397
|
+
get(def, fn) {
|
|
398
|
+
addRoute("GET", def, fn);
|
|
372
399
|
return finalize();
|
|
373
400
|
},
|
|
374
|
-
post(
|
|
375
|
-
addRoute("POST",
|
|
401
|
+
post(def, fn) {
|
|
402
|
+
addRoute("POST", def, fn);
|
|
376
403
|
return finalize();
|
|
377
404
|
},
|
|
378
|
-
put(
|
|
379
|
-
addRoute("PUT",
|
|
405
|
+
put(def, fn) {
|
|
406
|
+
addRoute("PUT", def, fn);
|
|
380
407
|
return finalize();
|
|
381
408
|
},
|
|
382
|
-
patch(
|
|
383
|
-
addRoute("PATCH",
|
|
409
|
+
patch(def, fn) {
|
|
410
|
+
addRoute("PATCH", def, fn);
|
|
384
411
|
return finalize();
|
|
385
412
|
},
|
|
386
|
-
delete(
|
|
387
|
-
addRoute("DELETE",
|
|
413
|
+
delete(def, fn) {
|
|
414
|
+
addRoute("DELETE", def, fn);
|
|
388
415
|
return finalize();
|
|
389
416
|
}
|
|
390
417
|
};
|
|
@@ -522,25 +549,55 @@ function defineMcp(options) {
|
|
|
522
549
|
...options.version ? { version: options.version } : {},
|
|
523
550
|
...options.instructions ? { instructions: options.instructions } : {}
|
|
524
551
|
};
|
|
525
|
-
const state = { spec };
|
|
552
|
+
const state = { spec, toolEntries: [], resourceEntries: [], promptEntries: [] };
|
|
526
553
|
const applyLambdaOptions = (lambda) => {
|
|
527
554
|
if (Object.keys(lambda).length > 0) {
|
|
528
555
|
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
529
556
|
}
|
|
530
557
|
};
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
558
|
+
const buildToolsFactory = () => state.toolEntries.length > 0 ? () => Object.fromEntries(state.toolEntries) : void 0;
|
|
559
|
+
const buildResourcesFactory = () => state.resourceEntries.length > 0 ? () => Object.fromEntries(state.resourceEntries) : void 0;
|
|
560
|
+
const buildPromptsFactory = () => state.promptEntries.length > 0 ? () => Object.fromEntries(state.promptEntries) : void 0;
|
|
561
|
+
const finalize = () => {
|
|
562
|
+
const tools = buildToolsFactory();
|
|
563
|
+
const resources = buildResourcesFactory();
|
|
564
|
+
const prompts = buildPromptsFactory();
|
|
565
|
+
return {
|
|
566
|
+
__brand: "effortless-mcp",
|
|
567
|
+
__spec: state.spec,
|
|
568
|
+
...state.onError ? { onError: state.onError } : {},
|
|
569
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
570
|
+
...state.setup ? { setup: state.setup } : {},
|
|
571
|
+
...state.authFn ? { authFn: state.authFn } : {},
|
|
572
|
+
...state.deps ? { deps: state.deps } : {},
|
|
573
|
+
...state.config ? { config: state.config } : {},
|
|
574
|
+
...state.static ? { static: state.static } : {},
|
|
575
|
+
...resources ? { resources } : {},
|
|
576
|
+
...prompts ? { prompts } : {},
|
|
577
|
+
...tools ? { tools } : {}
|
|
578
|
+
};
|
|
579
|
+
};
|
|
580
|
+
const finalizeWithEntries = () => {
|
|
581
|
+
const handler = finalize();
|
|
582
|
+
handler.tool = (def, fn) => {
|
|
583
|
+
state.toolEntries.push([def.name, { description: def.description, input: def.input, handler: fn }]);
|
|
584
|
+
handler.tools = buildToolsFactory();
|
|
585
|
+
return handler;
|
|
586
|
+
};
|
|
587
|
+
handler.resource = (def, fn) => {
|
|
588
|
+
const entry = { name: def.name, ...def.description ? { description: def.description } : {}, ...def.mimeType ? { mimeType: def.mimeType } : {}, handler: fn, ...def.params ? { params: def.params } : {} };
|
|
589
|
+
state.resourceEntries.push([def.uri, entry]);
|
|
590
|
+
handler.resources = buildResourcesFactory();
|
|
591
|
+
return handler;
|
|
592
|
+
};
|
|
593
|
+
handler.prompt = (def, fn) => {
|
|
594
|
+
const entry = { ...def.description ? { description: def.description } : {}, args: def.args, handler: fn };
|
|
595
|
+
state.promptEntries.push([def.name, entry]);
|
|
596
|
+
handler.prompts = buildPromptsFactory();
|
|
597
|
+
return handler;
|
|
598
|
+
};
|
|
599
|
+
return handler;
|
|
600
|
+
};
|
|
544
601
|
const builder = {
|
|
545
602
|
deps(fn) {
|
|
546
603
|
state.deps = fn;
|
|
@@ -554,6 +611,10 @@ function defineMcp(options) {
|
|
|
554
611
|
state.static = [...state.static ?? [], glob];
|
|
555
612
|
return builder;
|
|
556
613
|
},
|
|
614
|
+
auth(fn) {
|
|
615
|
+
state.authFn = fn;
|
|
616
|
+
return builder;
|
|
617
|
+
},
|
|
557
618
|
setup(fnOrLambda, maybeLambda) {
|
|
558
619
|
if (typeof fnOrLambda === "function") {
|
|
559
620
|
state.setup = fnOrLambda;
|
|
@@ -571,16 +632,21 @@ function defineMcp(options) {
|
|
|
571
632
|
state.onCleanup = fn;
|
|
572
633
|
return builder;
|
|
573
634
|
},
|
|
574
|
-
|
|
575
|
-
state.
|
|
576
|
-
return
|
|
635
|
+
tool(def, fn) {
|
|
636
|
+
state.toolEntries.push([def.name, { description: def.description, input: def.input, handler: fn }]);
|
|
637
|
+
return finalizeWithEntries();
|
|
577
638
|
},
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
639
|
+
resource(def, fn) {
|
|
640
|
+
const entry = { name: def.name, ...def.description ? { description: def.description } : {}, ...def.mimeType ? { mimeType: def.mimeType } : {}, handler: fn, ...def.params ? { params: def.params } : {} };
|
|
641
|
+
state.resourceEntries.push([def.uri, entry]);
|
|
642
|
+
return finalizeWithEntries();
|
|
581
643
|
},
|
|
582
|
-
|
|
583
|
-
|
|
644
|
+
prompt(def, fn) {
|
|
645
|
+
const entry = { ...def.description ? { description: def.description } : {}, args: def.args, handler: fn };
|
|
646
|
+
state.promptEntries.push([def.name, entry]);
|
|
647
|
+
return finalizeWithEntries();
|
|
648
|
+
},
|
|
649
|
+
build() {
|
|
584
650
|
return finalize();
|
|
585
651
|
}
|
|
586
652
|
};
|
|
@@ -602,7 +668,6 @@ export {
|
|
|
602
668
|
generateBase64,
|
|
603
669
|
generateHex,
|
|
604
670
|
generateUuid,
|
|
605
|
-
isBucketRoute,
|
|
606
671
|
param,
|
|
607
672
|
secret,
|
|
608
673
|
toSeconds
|