@faapi/faapi 2.0.1-canary.0 → 3.0.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/cli/index.js +4195 -3320
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +449 -4
- package/dist/index.js +1715 -772
- package/dist/index.js.map +1 -1
- package/dist/testing.js +24 -1
- package/dist/testing.js.map +1 -1
- package/package.json +2 -1
package/dist/testing.js
CHANGED
|
@@ -379,7 +379,11 @@ var PARAM_TYPE_MAP = {
|
|
|
379
379
|
ip: "ip",
|
|
380
380
|
ua: "ua",
|
|
381
381
|
files: "files",
|
|
382
|
-
fields: "fields"
|
|
382
|
+
fields: "fields",
|
|
383
|
+
agent: "agent",
|
|
384
|
+
// Phase 2.3
|
|
385
|
+
agents: "agents"
|
|
386
|
+
// Phase 2.3
|
|
383
387
|
};
|
|
384
388
|
function resolveInjection(fn) {
|
|
385
389
|
const fnStr = fn.toString();
|
|
@@ -459,6 +463,19 @@ function queryToObject(params) {
|
|
|
459
463
|
return result;
|
|
460
464
|
}
|
|
461
465
|
|
|
466
|
+
// src/injection/agentRegistry.ts
|
|
467
|
+
var registry = /* @__PURE__ */ new Map();
|
|
468
|
+
function listAgents() {
|
|
469
|
+
return Array.from(registry.values());
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// src/injection/agentHandle.ts
|
|
473
|
+
var currentFactory = null;
|
|
474
|
+
function getAgentHandle(ctx) {
|
|
475
|
+
if (currentFactory === null) return void 0;
|
|
476
|
+
return currentFactory(ctx);
|
|
477
|
+
}
|
|
478
|
+
|
|
462
479
|
// src/injection/injectParams.ts
|
|
463
480
|
function getBuiltinInjectionValue(type, ctx, body) {
|
|
464
481
|
switch (type) {
|
|
@@ -492,6 +509,12 @@ function getBuiltinInjectionValue(type, ctx, body) {
|
|
|
492
509
|
return body.fields;
|
|
493
510
|
}
|
|
494
511
|
return {};
|
|
512
|
+
// Phase 2.3:注入所有已注册 agent 元数据列表
|
|
513
|
+
case "agents":
|
|
514
|
+
return listAgents();
|
|
515
|
+
// Phase 3.5:调 @faapi/agent 插件注册的工厂获取 AgentHandle
|
|
516
|
+
case "agent":
|
|
517
|
+
return getAgentHandle(ctx);
|
|
495
518
|
default:
|
|
496
519
|
return void 0;
|
|
497
520
|
}
|