UNPKG

1.48 kBTypeScriptView Raw
1import { HandlerContext } from "@atomist/automation-client/lib/HandlerContext";
2/**
3 * Creates a PreferenceStore instance provided the HandlerContext of the current execution
4 */
5export declare type PreferenceStoreFactory = (ctx: HandlerContext) => PreferenceStore;
6/**
7 * Scope of a preference
8 */
9export declare enum PreferenceScope {
10 Sdm = "sdm",
11 Workspace = "workspace"
12}
13/**
14 * Strategy to store and retrieve SDM preferences.
15 */
16export interface PreferenceStore {
17 /**
18 * Retrieve a preference object via its key in the given scope.
19 */
20 get<V>(key: string, options?: {
21 scope?: PreferenceScope | string;
22 defaultValue?: V;
23 }): Promise<V | undefined>;
24 /**
25 * Store a preference object with the specified ttl and scope.
26 */
27 put<V>(key: string, value: V, options?: {
28 scope?: PreferenceScope | string;
29 ttl?: number;
30 }): Promise<V>;
31 /**
32 * List all preferences in a given scope
33 */
34 list<V>(scope: PreferenceScope | string): Promise<Array<{
35 key: string;
36 value: V;
37 }>>;
38 /**
39 * Delete a preference in a given scope
40 */
41 delete(key: string, options?: {
42 scope?: PreferenceScope | string;
43 }): Promise<void>;
44}
45/**
46 * NoOp PreferenceStore implementation useful for situations in which
47 * the SDM does not support preferences or tests.
48 */
49export declare const NoPreferenceStore: PreferenceStore;
50//# sourceMappingURL=preferenceStore.d.ts.map
\No newline at end of file