@zodic/shared 0.0.179 → 0.0.181

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.
@@ -99,19 +99,34 @@ export class ConceptNameDO {
99
99
  }
100
100
 
101
101
  async addName(language: 'en-us' | 'pt-br', name: string): Promise<void> {
102
- await this.getNames(); // Ensure latest state
102
+ await this.getNames(); // Ensure latest name list is loaded
103
+ await this.loadCount(); // ✅ Load latest count before modifying
103
104
 
104
105
  if (!this.names[language].includes(name)) {
105
106
  this.names[language].push(name);
106
- this.count++;
107
+ this.count += 1; // ✅ Increment count correctly
108
+
107
109
  this.recordTimestamp();
108
110
 
109
- // ✅ **Batch storage writes** instead of multiple separate `put()` calls
111
+ // ✅ **Store all updated values in a single put() call**
110
112
  await this.state.storage.put({
111
113
  names: this.names,
112
- count: this.count,
114
+ count: this.count, // ✅ Store updated count properly
113
115
  timestamps: this.timestamps,
114
116
  });
117
+
118
+ console.log(
119
+ `✅ Added name "${name}" to ${language}, count is now ${this.count}`
120
+ );
121
+ }
122
+ }
123
+
124
+ async loadCount(): Promise<void> {
125
+ const storedCount = await this.state.storage.get<number>('count');
126
+ if (typeof storedCount === 'number') {
127
+ this.count = storedCount; // ✅ Ensure we always load the latest count
128
+ } else {
129
+ this.count = 0; // ✅ Ensure count is initialized properly
115
130
  }
116
131
  }
117
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.179",
3
+ "version": "0.0.181",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {