@@ -74,20 +74,35 @@ export async function checkDatabaseSchema(): Promise<boolean> {
7474 return matches . tables ;
7575}
7676
77+ /**
78+ * Generates DB create stamps
79+ * @param currentContext The current context of the Express request
80+ * @returns An object with filled create stamps
81+ */
7782export function generateCreateStamps ( currentContext : CurrentContext | undefined ) {
7883 return {
7984 createdBy : currentContext ?. userId ?? NIL ,
8085 createdAt : new Date ( )
8186 } ;
8287}
8388
89+ /**
90+ * Generates DB update stamps
91+ * @param currentContext The current context of the Express request
92+ * @returns An object with filled update stamps
93+ */
8494export function generateUpdateStamps ( currentContext : CurrentContext | undefined ) {
8595 return {
8696 updatedBy : ( currentContext ?. userId as string ) ?? NIL ,
8797 updatedAt : new Date ( )
8898 } ;
8999}
90100
101+ /**
102+ * Generates null DB update stamps
103+ * @param currentContext The current context of the Express request
104+ * @returns An object with null update stamps
105+ */
91106export function generateNullUpdateStamps ( ) {
92107 return {
93108 updatedBy : null ,
@@ -98,9 +113,10 @@ export function generateNullUpdateStamps() {
98113/**
99114 * Generate a new activityId, which are truncated UUIDs
100115 * If a collision is detected, generate new UUID and test again
116+ * @param tx Prisma transaction client
101117 * @returns A string in title case
102118 */
103- export async function generateUniqueActivityId ( tx : PrismaTransactionClient ) {
119+ export async function generateUniqueActivityId ( tx : PrismaTransactionClient ) : Promise < string > {
104120 let id , queryResult ;
105121
106122 do {
@@ -112,7 +128,7 @@ export async function generateUniqueActivityId(tx: PrismaTransactionClient) {
112128 return id ;
113129}
114130
115- export function jsonToPrismaInputJson ( json : Prisma . JsonValue ) {
131+ export function jsonToPrismaInputJson ( json : Prisma . JsonValue ) : Prisma . NullTypes . JsonNull | Prisma . InputJsonValue {
116132 if ( json === null ) return null as unknown as Prisma . JsonNullValueInput ;
117133 return json as Prisma . InputJsonValue ;
118134}
0 commit comments