@amityco/ts-sdk-react-native
Version:
Amity Social Cloud Typescript SDK
88 lines • 3.12 kB
TypeScript
declare type SortingFunc<T = Record<string, unknown>> = (a: T, b: T) => number;
/**
* Alphabetic sorting of objects having a displayName
*/
export declare const sortByDisplayName: SortingFunc<{
displayName?: string;
}>;
/**
* Alphabetic sorting of objects having a name
*/
export declare const sortByName: SortingFunc<{
name?: string;
}>;
/**
* Sorting a collection by their apparition order (oldest first)
*/
export declare const sortByChannelSegment: SortingFunc<{
channelSegment: number;
}>;
/**
* Sorting a collection by their apparition order (oldest first)
*/
export declare const sortBySegmentNumber: SortingFunc<{
segmentNumber: number;
}>;
/**
* Sorting a collection by its oldest items
*/
export declare const sortByFirstCreated: SortingFunc<{
createdAt: Date | number | string;
}>;
/**
* Sorting a story-collection by its localSortingDate
*/
export declare const sortByLocalSortingDate: SortingFunc<{
localSortingDate: Date | number | string;
}>;
/**
* Sorting a collection by its newest items
*/
export declare const sortByLastCreated: SortingFunc<{
createdAt: Date | number | string;
}>;
/**
* Sorting a collection by its oldest items
* -- Due to Amity.UpdatedAt is an optional type, we need to define a default value to 0 to prevent error
*/
export declare const sortByFirstUpdated: SortingFunc<{
updatedAt?: Date | number | string;
}>;
/**
* Sorting a collection by its newest items
* -- Due to Amity.UpdatedAt is an optional type, we need to define a default value to 0 to prevent error
*/
export declare const sortByLastUpdated: SortingFunc<{
updatedAt?: Date | number | string;
}>;
/**
* Sorting a collection by the items with most recent activity
*/
export declare const sortByLastActivity: SortingFunc<{
lastActivity: Date | number | string;
}>;
/**
* Filter items by untilAt timestamp based on sort direction
* - For 'lastCreated' (newest first): untilAt acts as lower bound, excludes items older than boundary
* - For 'firstCreated' (oldest first): untilAt acts as upper bound, excludes items newer than boundary
* - Comparison is exclusive: posts with createdAt === untilAt are excluded
*/
export declare const filterByUntilAt: <T extends {
createdAt: Date | number | string;
}>(items: T[], untilAt: Date | number | string, sortBy: 'lastCreated' | 'firstCreated') => T[];
/**
* Validates untilAt parameter and returns undefined if invalid
* @param untilAt - The untilAt value to validate
* @returns The validated untilAt value or undefined if invalid
*/
export declare const validateUntilAt: (untilAt: string) => string | undefined;
/**
* Checks if a post should be excluded based on untilAt boundary
* @param createdAt - The post's createdAt timestamp
* @param untilAt - The untilAt boundary
* @param sortBy - The sort direction
* @returns true if the post exceeds the boundary (should be excluded)
*/
export declare const exceedsUntilAtBoundary: (createdAt: Date | number | string, untilAt: Date | number | string, sortBy: 'lastCreated' | 'firstCreated') => boolean;
export {};
//# sourceMappingURL=sorting.d.ts.map