/** * The globally unique key identifying a resource. */ export declare type IntegrationCacheKey = string; /** * Cache entries depend on the needs of the implementation. */ export interface IntegrationCacheEntry { key: IntegrationCacheKey; /** * The value for the specified key, will be `undefined` when there is no entry * found in the cache. */ data?: any; } /** * Provides an integration a temporary storage facility, typically used to * communicate data between steps. * * The cache is bound to the current job identifier to ensure that stale data is * not used across invocations. Entries will expire in 24 hours; there is no * need for manual cleanup. */ export interface IntegrationCache { /** * Provides an `IterableCache`, wrapping this cache, that tracks the keys of * added entries of a specified type `T`, and allows for iterating the entries * later. This is useful across steps of the integration. */ iterableCache: (cacheName: string) => IterableCache; /** * Get an entry from the cache, one at a time. See `getEntries` for concurrent * fetching of many entries. * * Entries will always be returned, though the entry `data` will be * `undefined` if there is nothing in the cache for the specified key. */ getEntry: (key: IntegrationCacheKey) => Promise; /** * Get a number of entries from the cache concurrently. * * Entries will be returned for every provided key, though any entry's `data` * will be `undefined` if there is nothing in the cache for the specified key. */ getEntries: (keys: IntegrationCacheKey[]) => Promise; /** * Put an entry into the cache, one at a time. See `putEntries` for concurrent * putting of many entries. */ putEntry: (entry: IntegrationCacheEntry) => Promise; /** * Put a number of entries into the cache concurrently. */ putEntries: (entries: IntegrationCacheEntry[]) => Promise; } /** * A function to process each entry in an `IterableCache`. The function may or * may not be `async`; the cache will `Promise.resolve(callback)` to allow * either case. A function that returns `true` will stop iteration. */ export declare type IterableCacheCallback = (each: { entry: EntryType; entryIndex: number; totalEntries: number; }) => boolean | void | Promise; export declare type IterableCacheKeyCallback = (each: { key: string; keyIndex: number; totalKeys: number; getEntry: GetCacheEntry; }) => boolean | void | Promise; declare type GetCacheEntry = () => Promise; export interface IterableCache { /** * Iterates each entry in the cache, beginning at `skip` index up to the * provided `limit`. The `IterableCacheCallback` will be provided the index of * the entry, the total entry count, and it may return `true` to stop * iteration. */ forEach: (callback: IterableCacheCallback, options?: { skip?: number; limit?: number; }) => Promise; /** * Iterates each key in the cache, beginning at `skip` index up to the * provided `limit`. The `IterableCacheKeyCallback` will be provided the index * of the key, the total key count, a function to retrieve the current entry, * and it may return `true` to stop iteration. */ forEachKey: (callback: IterableCacheKeyCallback, options?: { skip?: number; limit?: number; }) => Promise; /** * Put entries into the cache for iterating later without loading all the data * into memory. * * @returns the total number of entries accumulated. */ putEntries: (entries: EntryType[]) => Promise; getEntry: (key: string) => Promise; /** * Add state data related to the cache, useful to communicate across execution * steps. * * This will add to existing state; use `replaceState` for a complete state * replacement. * * @returns the complete state */ putState: (state: StateType) => Promise; /** * Replace the state data related to the cache, useful to communicate across * execution steps. * * @returns the previous state */ replaceState: (state: StateType) => Promise; /** * Get state data related to the cache, useful to communicate across execution * steps. */ getState: () => Promise; } export {};