knowmax-quest-utils
Version:
Utilities for creating a Knowmax Quest client.
56 lines • 3.7 kB
TypeScript
import type { IReferenceInfo, IDocumentNode } from 'knowmax-quest-types';
/** Generates quest id from given IReferenceInfo.
* @param referenceInfo Describes document and version to generate quest id for.
* @param nodeQuestId Optional quest id of node to add to identification of document specified by referenceInfo.
* @param forceVersion Set to true to force version specification even if referenceInfo refers to current version.
* @returns QuestId or undefined in case referenceInfo contains no reference to an existing document and/or document version.
*/
/**export const generateQuestIdFromReference = (referenceInfo: IReferenceInfo, nodeQuestId?: string, forceVersion = false): string | undefined => {
return referenceInfo.document && referenceInfo.documentVersion ?
generateQuestId(referenceInfo.document.questId, referenceInfo.documentVersion.version, referenceInfo.documentVersion.current, nodeQuestId, forceVersion) : undefined;
}*/
export declare const generateQuestIdFromReference: <T extends IDocumentNode<T> = IDocumentNode<any>>(referenceInfo: IReferenceInfo<T>, nodeQuestId?: string, forceVersion?: boolean) => string | undefined;
export declare const generateQuestId: (documentQuestId: string, version: number | string, current?: boolean, nodeQuestId?: string, forceVersion?: boolean) => string;
/** Generates version postfix, like [versionumber] or empty in case it's current version.
* @param version Quest version specification. Might be number, date or Quest specific version specification.
* @param current Boolean indicating if given version is to be known as current version.
* @param force Boolean indicating to force version specification output even if this was current document.
*/
export declare const generateQuestIdVersionPostfix: (version: number | string, current: boolean, force?: boolean) => string;
/** Get levels from given quest identification. For example: '1/1.1/1.1.1' => ['1', '1/1.1', '1/1.1/1.1.1']
* @param questId Quest identification to extract levels from.
*/
export declare const getLevels: (questId: string) => string[];
/** Return level above given quest identification. For example: '1/1.1/1.1.1' => '1/1.1'
* @param questId Quest identification.
*/
export declare const levelUp: (questId: string) => string;
/** Returns first level of questId.
* @param questId Quest identification.
*/
export declare const firstLevel: (questId: string) => string | undefined;
/** Returns last level of questId.
* @param questId Quest identification.
*/
export declare const lastLevel: (questId: string) => string;
/** Checks given QuestId for version specification.
* @param questId Quest identification.
*/
export declare const hasVersionSpecification: (questId: string) => boolean;
/** Return array with QuestId and optional version specification.
* @param questId Quest identification with optional version specification
*/
export declare const extractIdAndVersion: (questId: string) => [string, string?];
/** Return QuestId without version specification.
* @param questId Quest identification with optional version specification to be stripped.
*/
export declare const extractId: (questId: string) => string;
/** Return version specification from QuestId.
* @param questId Quest identification with optional version specification to be extracted.
*/
export declare const extractVersion: (questId: string) => string | undefined;
/** Get numeric representation of given version.
* @param version Either numeric or string representation of version. Version specifications like last/first are ignored.
*/
export declare const numericVersion: (version?: string | number | undefined) => number | undefined;
//# sourceMappingURL=questid.d.ts.map