@levante-framework/firekit
Version:
A library to facilitate Firebase authentication and Firestore interaction for LEVANTE apps
100 lines (99 loc) • 3.21 kB
TypeScript
import { CollectionReference, DocumentReference, Firestore, serverTimestamp } from 'firebase/firestore';
export interface TaskVariantBase {
taskId: string;
taskName?: string;
taskDescription?: string;
taskImage?: string;
taskURL?: string;
taskVersion?: string;
gameConfig?: object;
external?: boolean;
variantName: string;
variantParams: {
[key: string]: unknown;
};
registered?: boolean;
db: Firestore;
}
export interface TaskVariantForAssessment extends TaskVariantBase {
variantId: string;
}
export interface FirestoreTaskData {
name?: string;
description?: string | null;
image?: string;
taskURL?: string;
gameConfig?: object;
external?: boolean;
lastUpdated: ReturnType<typeof serverTimestamp>;
registered?: boolean;
testData?: boolean;
demoData?: boolean;
createdAt?: ReturnType<typeof serverTimestamp>;
updatedAt: ReturnType<typeof serverTimestamp>;
}
export interface TaskData extends FirestoreTaskData {
id: string;
}
export interface FirestoreVariantData {
name?: string;
description?: string | null;
taskURL?: string;
external?: boolean;
params: {
[key: string]: unknown;
};
lastUpdated: ReturnType<typeof serverTimestamp>;
registered?: boolean;
createdAt?: ReturnType<typeof serverTimestamp>;
updatedAt: ReturnType<typeof serverTimestamp>;
}
/**
* Class representing a ROAR task.
*/
export declare class RoarTaskVariant {
db: Firestore;
taskId: string;
taskName?: string;
taskDescription?: string;
taskImage?: string;
taskURL?: string;
taskVersion?: string;
gameConfig?: object;
registered?: boolean;
external?: boolean;
taskRef: DocumentReference;
variantId?: string;
variantName?: string;
variantParams: {
[key: string]: unknown;
};
variantRef: DocumentReference | undefined;
variantsCollectionRef: CollectionReference;
/** Create a ROAR task
* @param {TaskVariantInput} input
* @param {Firestore} input.db - The assessment Firestore instance to which this task'data will be written
* @param {string} input.taskId - The ID of the parent task. Should be a short initialism, e.g. "swr" or "sre"
* @param {string} input.taskName - The name of the parent task
* @param {string} input.taskDescription - The description of the task
* @param {string} input.variantName - The name of the task variant
* @param {string} input.variantDescription - The description of the variant
* @param {object} input.variantParams - The parameters of the task variant
*/
constructor({ db, taskId, taskName, taskDescription, taskImage, taskURL, gameConfig, taskVersion, registered, external, variantName, variantParams, }: TaskVariantBase);
/**
* Push the trial and trial variant to Firestore
* @method
* @async
*/
toFirestore(): Promise<void>;
/**
* Update variant params in Firestore
* @method
* @param {object} newParams - The parameters of the task variant
* @async
*/
updateTaskParams(newParams: {
[key: string]: unknown;
}): Promise<void>;
}