@lmzhen/dsh-memory 0.3.21 → 0.3.23

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
@@ -18,12 +18,17 @@ var MemoryRegistry = class extends Service {
18
18
  };
19
19
  }
20
20
  /** 0.3.17 (E-73): named lookup like the io/state-storage registries; no
21
- * name = first registered (backward compatible). */
21
+ * name = first registered (backward compatible). A named miss throws (F-333,
22
+ * 0.3.23) instead of silently falling back to the first provider, so a wrong
23
+ * name surfaces rather than writing to the wrong memory store. */
22
24
  provider(name) {
23
- const byName = name ? this.providers.get(name) : void 0;
24
- if (byName) return byName;
25
+ if (name) {
26
+ const byName = this.providers.get(name);
27
+ if (!byName) throw new Error(`memory provider "${name}" is not registered`);
28
+ return byName;
29
+ }
25
30
  const first = this.providers.values().next().value;
26
- if (!first) throw new Error(`memory: no provider registered${name ? ` named "${name}"` : ""}`);
31
+ if (!first) throw new Error("memory: no provider registered");
27
32
  return first;
28
33
  }
29
34
  read(target) {
@@ -55,7 +55,9 @@ export declare class MemoryRegistry extends Service {
55
55
  constructor(ctx: Context);
56
56
  registerProvider(provider: MemoryProvider): () => void;
57
57
  /** 0.3.17 (E-73): named lookup like the io/state-storage registries; no
58
- * name = first registered (backward compatible). */
58
+ * name = first registered (backward compatible). A named miss throws (F-333,
59
+ * 0.3.23) instead of silently falling back to the first provider, so a wrong
60
+ * name surfaces rather than writing to the wrong memory store. */
59
61
  provider(name?: string): MemoryProvider;
60
62
  read(target: MemoryTarget): Promise<string[]>;
61
63
  applyBatch(target: MemoryTarget, operations: MemoryOperation[]): Promise<MemoryApplyResult>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-memory",
3
3
  "description": "Memory provider registry for self-evolution (community build)",
4
- "version": "0.3.21",
4
+ "version": "0.3.23",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },