Merge remote-tracking branch 'origin/refactor/common' into feat/user-routes
# Conflicts: # backend/src/controllers/learning-objects.ts
This commit is contained in:
		
						commit
						01b40992e2
					
				
					 15 changed files with 35 additions and 32 deletions
				
			
		
							
								
								
									
										4
									
								
								.github/workflows/lint-action.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/lint-action.yml
									
										
									
									
										vendored
									
									
								
							|  | @ -43,6 +43,6 @@ jobs: | ||||||
|               with: |               with: | ||||||
|                   auto_fix: true |                   auto_fix: true | ||||||
|                   eslint: true |                   eslint: true | ||||||
|                   eslint_args: '--config eslint.config.ts' |                   eslint_args: "--config eslint.config.ts --ignore-pattern '**/prettier.config.js'" | ||||||
|                   prettier: true |                   prettier: true | ||||||
|                   commit_message: 'style: fix linting issues met ${linter}' |                   commit_message: 'style: fix linting issues met ${linter}' | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -737,4 +737,4 @@ flycheck_*.el | ||||||
| # network security | # network security | ||||||
| /network-security.data | /network-security.data | ||||||
| 
 | 
 | ||||||
| 
 | docs/.venv | ||||||
|  |  | ||||||
|  | @ -6,11 +6,7 @@ import attachmentService from '../services/learning-objects/attachment-service.j | ||||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||||
| import { envVars, getEnvVar } from '../util/envVars.js'; | import { envVars, getEnvVar } from '../util/envVars.js'; | ||||||
| import { | import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||||
|     FilteredLearningObject, |  | ||||||
|     LearningObjectIdentifier, |  | ||||||
|     LearningPathIdentifier |  | ||||||
| } from "@dwengo-1/common/interfaces/learning-content"; |  | ||||||
| 
 | 
 | ||||||
| function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier { | function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier { | ||||||
|     if (!req.params.hruid) { |     if (!req.params.hruid) { | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| import { Language } from "@dwengo-1/common/util/language"; | import { Language } from '@dwengo-1/common/util/language'; | ||||||
| 
 | 
 | ||||||
| export class LearningObjectIdentifier { | export class LearningObjectIdentifier { | ||||||
|     constructor( |     constructor( | ||||||
|  |  | ||||||
|  | @ -69,7 +69,7 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full | ||||||
|             nodes.map(async (node) => { |             nodes.map(async (node) => { | ||||||
|                 const learningObjectId: LearningObjectIdentifier = { |                 const learningObjectId: LearningObjectIdentifier = { | ||||||
|                     hruid: node.learningobject_hruid, |                     hruid: node.learningobject_hruid, | ||||||
|                     language: learningPathId.language |                     language: learningPathId.language, | ||||||
|                 }; |                 }; | ||||||
|                 return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId); |                 return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId); | ||||||
|             }) |             }) | ||||||
|  |  | ||||||
|  | @ -2,11 +2,7 @@ import dwengoApiLearningObjectProvider from './dwengo-api-learning-object-provid | ||||||
| import { LearningObjectProvider } from './learning-object-provider.js'; | import { LearningObjectProvider } from './learning-object-provider.js'; | ||||||
| import { envVars, getEnvVar } from '../../util/envVars.js'; | import { envVars, getEnvVar } from '../../util/envVars.js'; | ||||||
| import databaseLearningObjectProvider from './database-learning-object-provider.js'; | import databaseLearningObjectProvider from './database-learning-object-provider.js'; | ||||||
| import { | import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||||
|     FilteredLearningObject, |  | ||||||
|     LearningObjectIdentifier, |  | ||||||
|     LearningPathIdentifier, |  | ||||||
| } from '@dwengo-1/common/interfaces/learning-content'; |  | ||||||
| 
 | 
 | ||||||
| function getProvider(id: LearningObjectIdentifier): LearningObjectProvider { | function getProvider(id: LearningObjectIdentifier): LearningObjectProvider { | ||||||
|     if (id.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) { |     if (id.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) { | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ export async function createQuestion(questionDTO: QuestionDTO): Promise<Question | ||||||
|     const loId: LearningObjectIdentifier = { |     const loId: LearningObjectIdentifier = { | ||||||
|         ...questionDTO.learningObjectIdentifier, |         ...questionDTO.learningObjectIdentifier, | ||||||
|         version: questionDTO.learningObjectIdentifier.version ?? 1, |         version: questionDTO.learningObjectIdentifier.version ?? 1, | ||||||
|     } |     }; | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|         await questionRepository.createQuestion({ |         await questionRepository.createQuestion({ | ||||||
|  | @ -98,10 +98,10 @@ export async function deleteQuestion(questionId: QuestionId): Promise<QuestionDT | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const loId : LearningObjectIdentifier = { |     const loId: LearningObjectIdentifier = { | ||||||
|         ...questionId.learningObjectIdentifier, |         ...questionId.learningObjectIdentifier, | ||||||
|         version: questionId.learningObjectIdentifier.version ?? 1 |         version: questionId.learningObjectIdentifier.version ?? 1, | ||||||
|     } |     }; | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(loId, questionId.sequenceNumber); |         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(loId, questionId.sequenceNumber); | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| import { LearningObjectIdentifier } from "@dwengo-1/common/interfaces/learning-content"; | import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||||
| 
 | 
 | ||||||
| export function isValidHttpUrl(url: string): boolean { | export function isValidHttpUrl(url: string): boolean { | ||||||
|     try { |     try { | ||||||
|  |  | ||||||
|  | @ -48,8 +48,8 @@ describe('LearningPathService', () => { | ||||||
|             expect(result.data?.length).toBe(1); |             expect(result.data?.length).toBe(1); | ||||||
| 
 | 
 | ||||||
|             // Should include all the nodes, even those pointing to foreign learning objects.
 |             // Should include all the nodes, even those pointing to foreign learning objects.
 | ||||||
|             expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort()).toEqual( |             expect([...result.data![0].nodes.map((it) => it.learningobject_hruid)].sort((a, b) => a.localeCompare(b))).toEqual( | ||||||
|                 example.learningPath.nodes.map((it) => it.learningObjectHruid).sort() |                 example.learningPath.nodes.map((it) => it.learningObjectHruid).sort((a, b) => a.localeCompare(b)) | ||||||
|             ); |             ); | ||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
|     "include": ["src/**/*.ts"], |     "include": ["src/**/*.ts"], | ||||||
|     "compilerOptions": { |     "compilerOptions": { | ||||||
|         "rootDir": "./src", |         "rootDir": "./src", | ||||||
|         "outDir": "./dist", |         "outDir": "./dist" | ||||||
|     }, |     }, | ||||||
|     "references": [ |     "references": [ | ||||||
|         { |         { | ||||||
|  |  | ||||||
|  | @ -4,7 +4,9 @@ | ||||||
|     "description": "Common types and utilities for Dwengo-1", |     "description": "Common types and utilities for Dwengo-1", | ||||||
|     "private": true, |     "private": true, | ||||||
|     "type": "module", |     "type": "module", | ||||||
|     "files": [ "./dist" ], |     "files": [ | ||||||
|  |         "./dist" | ||||||
|  |     ], | ||||||
|     "scripts": { |     "scripts": { | ||||||
|         "build": "tsc --build", |         "build": "tsc --build", | ||||||
|         "clean": "tsc --build --clean", |         "clean": "tsc --build --clean", | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| import { Language } from "../util/language"; | import { Language } from '../util/language'; | ||||||
| 
 | 
 | ||||||
| export interface Transition { | export interface Transition { | ||||||
|     default: boolean; |     default: boolean; | ||||||
|  |  | ||||||
|  | @ -16,7 +16,16 @@ export default [ | ||||||
|     prettierConfig, |     prettierConfig, | ||||||
|     includeIgnoreFile(gitignorePath), |     includeIgnoreFile(gitignorePath), | ||||||
|     { |     { | ||||||
|         ignores: ['**/dist/**', '**/.node_modules/**', '**/coverage/**', '**/.github/**'], |         ignores: [ | ||||||
|  |             '**/dist/**', | ||||||
|  |             '**/.node_modules/**', | ||||||
|  |             '**/coverage/**', | ||||||
|  |             '**/.github/**', | ||||||
|  |             '**/prettier.config.js', | ||||||
|  |             'docs/.venv/**', | ||||||
|  |             'prettier.config.js', | ||||||
|  |             'frontend/prettier.config.js', | ||||||
|  |         ], | ||||||
|         files: ['**/*.ts', '**/*.cts', '**.*.mts'], |         files: ['**/*.ts', '**/*.cts', '**.*.mts'], | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -1,11 +1,11 @@ | ||||||
| { | { | ||||||
|     "name": "dwengo-1-monorepo", |     "name": "dwengo-1", | ||||||
|     "version": "0.1.1", |     "version": "0.1.1", | ||||||
|     "lockfileVersion": 3, |     "lockfileVersion": 3, | ||||||
|     "requires": true, |     "requires": true, | ||||||
|     "packages": { |     "packages": { | ||||||
|         "": { |         "": { | ||||||
|             "name": "dwengo-1-monorepo", |             "name": "dwengo-1", | ||||||
|             "version": "0.1.1", |             "version": "0.1.1", | ||||||
|             "license": "MIT", |             "license": "MIT", | ||||||
|             "workspaces": [ |             "workspaces": [ | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ | ||||||
| 
 | 
 | ||||||
|         /* Projects */ |         /* Projects */ | ||||||
|         // "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ |         // "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ | ||||||
|         "composite": true,                                   /* Enable constraints that allow a TypeScript project to be used with project references. */ |         "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */, | ||||||
|         // "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */ |         // "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */ | ||||||
|         // "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */ |         // "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */ | ||||||
|         // "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */ |         // "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */ | ||||||
|  | @ -59,10 +59,10 @@ | ||||||
|         // "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ |         // "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ | ||||||
| 
 | 
 | ||||||
|         /* Emit */ |         /* Emit */ | ||||||
|         "declaration": true,                                 /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ |         "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, | ||||||
|         "declarationMap": true,                              /* Create sourcemaps for d.ts files. */ |         "declarationMap": true /* Create sourcemaps for d.ts files. */, | ||||||
|         // "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */ |         // "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */ | ||||||
|         "sourceMap": true,                                   /* Create source map files for emitted JavaScript files. */ |         "sourceMap": true /* Create source map files for emitted JavaScript files. */, | ||||||
|         // "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */ |         // "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */ | ||||||
|         // "noEmit": true,                                   /* Disable emitting files from a compilation. */ |         // "noEmit": true,                                   /* Disable emitting files from a compilation. */ | ||||||
|         // "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ |         // "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl