UNPKG

@mondaydotcomorg/atp-runtime

Version:

Runtime SDK injected into sandbox for Agent Tool Protocol

103 lines 3.8 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; /** * Cache API - Clean refactored version with decorators and extracted modules * * Benefits: * - No duplication between implementation and metadata * - Types auto-detected from TypeScript signatures * - Clean separation of concerns (backends, API) */ import { RuntimeAPI, RuntimeMethod } from '../metadata/decorators.js'; import { getCacheBackend } from './backends.js'; export { MemoryCacheBackend, RedisCacheBackend, initializeCache } from './backends.js'; /** * Cache Runtime API * * Store and retrieve data with optional TTL (Time To Live). * Supports in-memory (node-cache) and Redis backends. */ let CacheAPI = class CacheAPI { /** * Gets a value from cache */ async get(key) { return getCacheBackend().get(key); } /** * Sets a value in cache with optional TTL in seconds */ async set(key, value, ttl) { return getCacheBackend().set(key, value, ttl); } /** * Deletes a value from cache */ async delete(key) { return getCacheBackend().delete(key); } /** * Checks if a key exists in cache */ async has(key) { return getCacheBackend().has(key); } /** * Clears all cache entries */ async clear() { return getCacheBackend().clear(); } }; __decorate([ RuntimeMethod('Get a value from cache by key', { key: { description: 'Cache key' }, }), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], CacheAPI.prototype, "get", null); __decorate([ RuntimeMethod('Set a value in cache with optional TTL', { key: { description: 'Cache key' }, value: { description: 'Value to cache', type: 'unknown' }, ttl: { description: 'Time to live in seconds', optional: true }, }), __metadata("design:type", Function), __metadata("design:paramtypes", [String, Object, Number]), __metadata("design:returntype", Promise) ], CacheAPI.prototype, "set", null); __decorate([ RuntimeMethod('Delete a value from cache', { key: { description: 'Cache key to delete' }, }), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], CacheAPI.prototype, "delete", null); __decorate([ RuntimeMethod('Check if a key exists in cache', { key: { description: 'Cache key to check' }, }), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", Promise) ], CacheAPI.prototype, "has", null); __decorate([ RuntimeMethod('Clear all cache entries'), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise) ], CacheAPI.prototype, "clear", null); CacheAPI = __decorate([ RuntimeAPI('cache', 'Cache API - Store and retrieve data with optional TTL') ], CacheAPI); export const cache = new CacheAPI(); //# sourceMappingURL=index.js.map