dsh-reconcile 0.1.1 → 0.1.2
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/README.md +2 -2
- package/index.js +37 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,11 +66,11 @@ DeepSeek Harness 插件:**先核事实、再决定问不问、收工对账**
|
|
|
66
66
|
|
|
67
67
|
## 安装
|
|
68
68
|
|
|
69
|
-
**从 npm 装(已发布 0.1.
|
|
69
|
+
**从 npm 装(已发布 0.1.1):**
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
72
|
dsh plugin --profile web add dsh-reconcile
|
|
73
|
-
dsh plugin --profile web add dsh-reconcile@0.1.
|
|
73
|
+
dsh plugin --profile web add dsh-reconcile@0.1.1 # 钉版本
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
npm 包页:<https://www.npmjs.com/package/dsh-reconcile>
|
package/index.js
CHANGED
|
@@ -712,26 +712,45 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
712
712
|
}],
|
|
713
713
|
]
|
|
714
714
|
|
|
715
|
-
|
|
716
|
-
|
|
715
|
+
/**
|
|
716
|
+
* 路由挂载。必须用 ctx.inject(['connection']) 等它就绪:
|
|
717
|
+
* 插件之间是并行激活的,apply() 执行时 connection 可能还没起来;
|
|
718
|
+
* 直接 ctx.get('connection') 拿不到就静默跳过,表现为面板按钮全部 404。
|
|
719
|
+
*/
|
|
720
|
+
const mountRoutes = (hostCtx) => {
|
|
721
|
+
const connection = hostCtx?.connection ?? hostCtx?.get?.('connection')
|
|
722
|
+
if (!connection?.fetch?.register) {
|
|
723
|
+
hostCtx?.logger?.warn?.('dsh-reconcile: connection.fetch 不可用,面板按钮会退化成只读(工具与收尾对账不受影响)')
|
|
724
|
+
return false
|
|
725
|
+
}
|
|
717
726
|
for (const [routePath, methods, handler] of routes) {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
727
|
+
hostCtx.effect?.(() => {
|
|
728
|
+
const dispose = connection.fetch.register({
|
|
729
|
+
path: routePath,
|
|
730
|
+
methods,
|
|
731
|
+
requestBody: 'buffered',
|
|
732
|
+
fetch: async (request) => {
|
|
733
|
+
const blocked = admit(request)
|
|
734
|
+
if (blocked) return blocked
|
|
735
|
+
try {
|
|
736
|
+
return await handler(request)
|
|
737
|
+
} catch (error) {
|
|
738
|
+
return json({ ok: false, error: String(error?.message ?? error) }, 500)
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
})
|
|
742
|
+
return () => { void dispose?.() }
|
|
743
|
+
}, 'dsh-reconcile: route ' + routePath)
|
|
744
|
+
}
|
|
745
|
+
return true
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (config.routesEnabled !== false) {
|
|
749
|
+
if (typeof ctx.inject === 'function') {
|
|
750
|
+
ctx.inject(['connection'], (child) => { mountRoutes(child) })
|
|
751
|
+
} else {
|
|
752
|
+
mountRoutes(ctx)
|
|
732
753
|
}
|
|
733
|
-
} else {
|
|
734
|
-
ctx.logger?.warn?.('dsh-reconcile: 没有 connection.fetch 服务,面板按钮会退化成只读(工具与收尾对账不受影响)')
|
|
735
754
|
}
|
|
736
755
|
|
|
737
756
|
return () => {
|
package/package.json
CHANGED