Personal Telegram developer console for GitHub

feat(cp7): add automation store client

davoodmehraban89 committed Oct 5, 2026 at 06:21 UTC f7569d33a9565c50bce70efa2ed8c109d0793940
1 file changed +1
src/core/automation-store.js new
+1
@@ -0,0 +1 @@
1 +export class DurableAutomationStoreClient{constructor({namespace,ownerId}){this.namespace=namespace;this.ownerId=String(ownerId||'');}stub(id){if(!this.namespace||!this.ownerId)throw new Error('Automation store is not configured');return this.namespace.get(this.namespace.idFromName(`owner:${this.ownerId}:automation:${id}`));}async get(id){const r=await this.stub(id).fetch(`https://automation.local/?owner=${encodeURIComponent(this.ownerId)}&id=${encodeURIComponent(id)}`);if(r.status===404)return null;if(!r.ok)throw new Error('Automation read failed');return r.json();}async put(state){const r=await this.stub(state.id).fetch(`https://automation.local/?owner=${encodeURIComponent(this.ownerId)}&id=${encodeURIComponent(state.id)}`,{method:'PUT',headers:{'content-type':'application/json'},body:JSON.stringify(state)});if(!r.ok)throw new Error('Automation write failed');return r.json();}}