idea-toolbox
Version:
IDEA's utility functions
121 lines (120 loc) • 3.33 kB
TypeScript
import { Resource } from './resource.model';
import { epochDateTime } from './epoch';
/**
* A record for the Delta mechanism.
* It shows the latest state of a particular resource element.
*
* Table: `xxx_teamsResources_delta`.
*
* Indexes:
* - `teamResource-timestamp-index`; LSI, includes: deleted, element.
* - `teamResource-timestamp-count`; LSI, includes: deleted.
*/
export declare class DeltaRecord extends Resource {
/**
* The concatenation of teamId and resource.
*/
teamResource: string;
/**
* The id of the record; it could be a concatenation of the element ids.
*/
id: string;
/**
* The timestamp when the record was lastly updated.
*/
timestamp: epochDateTime;
/**
* If set, the record shows the element was deleted.
*/
deleted?: boolean;
/**
* The current state of the element, if not deleted.
*/
element?: any;
load(x?: any): void;
}
/**
* A structure to manage the delta (changes since a timestamp) of a set of resources.
*/
export declare class Delta extends Resource {
/**
* Starting time to confront what's changed since then.
*/
since: epochDateTime;
/**
* If set, there are more resesources to acquire, so it contains the link to request another page.
*/
next?: string;
/**
* The list of resources involved in this delta.
*/
resources: (DeltaResources | string)[];
/**
* The list of delta records for each resource.
*/
records: {
[resource: string]: DeltaRecord[];
};
load(x: any): void;
/**
* Set the records of a resource to the delta.
*/
setRecordsOfResource(records: DeltaRecord[], resource: DeltaResources | string): void;
}
/**
* The structure to have the next page of a previous delta request.
*/
export declare class DeltaNext extends Resource {
/**
* The resources of which there is still data to acquire.
*/
resources: (DeltaResources | string)[];
/**
* The lastEvaluatedKeys for getting the next page of the pagination, for each resources.
*/
keys: {
[resource: string]: any;
};
load(x: any): void;
/**
* Add the keys of a resource to the DeltaNext.
*/
addKeyOfResource(key: {
[resource: string]: any;
}, resource: DeltaResources | string): void;
/**
* Remove a resource from the structure.
*/
removeResource(resource: DeltaResources | string): void;
/**
* Whether the DeltaNext is needed; it depends if there are still resources to be managed.
*/
isNeeded(): number;
}
/**
* The resources supporting the delta mechanism.
* Create a similar structure when implementing the delta in a project.
*/
export declare enum DeltaResources {
RESOURCE = "RESOURCE"
}
/**
* A structure to have an overview of the number of elements for each resource.
*/
export declare class DeltaCount extends Resource {
/**
* Starting time to confront what's changed since then.
*/
since: epochDateTime;
/**
* The list of resources involved in this delta.
*/
resources: (DeltaResources | string)[];
/**
* The count of elements for each resource.
*/
count: {
[resource: string]: number;
};
load(x: any): void;
}