@lmzhen/dsh-evolution-io 0.22.0 → 0.24.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/lib/index.js CHANGED
@@ -58,5 +58,28 @@ var EvolutionIoRegistry = class extends Service {
58
58
  return first;
59
59
  }
60
60
  };
61
+ /**
62
+ * Resolve the seam implementation for a consumer, preferring a backend the deployment mounted.
63
+ *
64
+ * Contract C2 (declared gaps) has no other shape: a consumer that can work on either medium asks for
65
+ * its preference and the DEPLOYMENT decides which backends exist. The lookup is contained here because
66
+ * the registry deliberately has no presence probe (v20 A-3 removed `hasProvider`; a presence probe goes
67
+ * through `provider(name)`, which fails loud) — so this function is the ONE sanctioned place that turns
68
+ * that failure into a fallback. A caller that needs a SPECIFIC backend must call `provider(name)` and
69
+ * take the error.
70
+ * @param registry - the seam registry (`ctx.evolutionIo`).
71
+ * @param names - preferred provider names, most preferred first.
72
+ * @returns the first registered preference, else the registry default.
73
+ */
74
+ /**
75
+ * @typeParam T - the seam implementation type the caller works with (`EvolutionIo` or the wider
76
+ * `EvolutionIoLike`), so the same helper serves every consumer shape.
77
+ */
78
+ function preferProvider(registry, names) {
79
+ for (const name of names) try {
80
+ return registry.provider(name);
81
+ } catch {}
82
+ return registry.provider();
83
+ }
61
84
  //#endregion
62
- export { EvolutionIoRegistry, EvolutionIoRegistry as default };
85
+ export { EvolutionIoRegistry, EvolutionIoRegistry as default, preferProvider };
@@ -51,5 +51,25 @@ export declare class EvolutionIoRegistry extends Service {
51
51
  }): () => void;
52
52
  provider(name?: string): EvolutionIo;
53
53
  }
54
+ /**
55
+ * Resolve the seam implementation for a consumer, preferring a backend the deployment mounted.
56
+ *
57
+ * Contract C2 (declared gaps) has no other shape: a consumer that can work on either medium asks for
58
+ * its preference and the DEPLOYMENT decides which backends exist. The lookup is contained here because
59
+ * the registry deliberately has no presence probe (v20 A-3 removed `hasProvider`; a presence probe goes
60
+ * through `provider(name)`, which fails loud) — so this function is the ONE sanctioned place that turns
61
+ * that failure into a fallback. A caller that needs a SPECIFIC backend must call `provider(name)` and
62
+ * take the error.
63
+ * @param registry - the seam registry (`ctx.evolutionIo`).
64
+ * @param names - preferred provider names, most preferred first.
65
+ * @returns the first registered preference, else the registry default.
66
+ */
67
+ /**
68
+ * @typeParam T - the seam implementation type the caller works with (`EvolutionIo` or the wider
69
+ * `EvolutionIoLike`), so the same helper serves every consumer shape.
70
+ */
71
+ export declare function preferProvider<T>(registry: {
72
+ provider(name?: string): T;
73
+ }, names: readonly string[]): T;
54
74
  export default EvolutionIoRegistry;
55
75
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-io",
3
3
  "description": "IO seam for evolution providers (community build)",
4
- "version": "0.22.0",
4
+ "version": "0.24.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@lmzhen/dsh-evolution-core": "^0.22.0"
29
+ "@lmzhen/dsh-evolution-core": "^0.24.0"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@deepseek-ai/cordis": "^4.0.1"