mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	server-ts: cls.js -> cls.ts
This commit is contained in:
		
							parent
							
								
									981221d599
								
							
						
					
					
						commit
						78f631373b
					
				| @ -1,26 +1,29 @@ | |||||||
| const clsHooked = require('cls-hooked'); | import clsHooked = require('cls-hooked'); | ||||||
|  | import type entity_changes = require('./entity_changes'); | ||||||
| const namespace = clsHooked.createNamespace("trilium"); | const namespace = clsHooked.createNamespace("trilium"); | ||||||
| 
 | 
 | ||||||
| function init(callback) { | type Callback = (...args: any[]) => any; | ||||||
|  | 
 | ||||||
|  | function init(callback: Callback) { | ||||||
|     return namespace.runAndReturn(callback); |     return namespace.runAndReturn(callback); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function wrap(callback) { | function wrap(callback: Callback) { | ||||||
|     return () => { |     return () => { | ||||||
|         try { |         try { | ||||||
|             init(callback); |             init(callback); | ||||||
|         } |         } | ||||||
|         catch (e) { |         catch (e: any) { | ||||||
|             console.log(`Error occurred: ${e.message}: ${e.stack}`); |             console.log(`Error occurred: ${e.message}: ${e.stack}`); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function get(key) { | function get(key: string) { | ||||||
|     return namespace.get(key); |     return namespace.get(key); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function set(key, value) { | function set(key: string, value: any) { | ||||||
|     namespace.set(key, value); |     namespace.set(key, value); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -48,7 +51,7 @@ function isEntityEventsDisabled() { | |||||||
|     return !!namespace.get('disableEntityEvents'); |     return !!namespace.get('disableEntityEvents'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function setMigrationRunning(running) { | function setMigrationRunning(running: boolean) { | ||||||
|     namespace.set('migrationRunning', !!running); |     namespace.set('migrationRunning', !!running); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -56,7 +59,7 @@ function isMigrationRunning() { | |||||||
|     return !!namespace.get('migrationRunning'); |     return !!namespace.get('migrationRunning'); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function disableSlowQueryLogging(disable) { | function disableSlowQueryLogging(disable: boolean) { | ||||||
|     namespace.set('disableSlowQueryLogging', disable); |     namespace.set('disableSlowQueryLogging', disable); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -72,7 +75,7 @@ function getAndClearEntityChangeIds() { | |||||||
|     return entityChangeIds; |     return entityChangeIds; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function putEntityChange(entityChange) { | function putEntityChange(entityChange: entity_changes.EntityChange) { | ||||||
|     if (namespace.get('ignoreEntityChangeIds')) { |     if (namespace.get('ignoreEntityChangeIds')) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
							
								
								
									
										12
									
								
								src/services/entity_changes.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/services/entity_changes.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | export interface EntityChange { | ||||||
|  | 	id?: string; | ||||||
|  | 	entityName: string; | ||||||
|  | 	entityId: string; | ||||||
|  | 	hash: string; | ||||||
|  | 	utcDateChanged: string; | ||||||
|  | 	isSynced: boolean | 1 | 0; | ||||||
|  | 	isErased: boolean | 1 | 0; | ||||||
|  | 	componentId?: string | null; | ||||||
|  | 	changeId?: string | null; | ||||||
|  | 	instanceId?: string | null; | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran