Skip to content

Commit

Permalink
Fixed shared types generation
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Jan 14, 2025
1 parent c20ab72 commit 2850365
Show file tree
Hide file tree
Showing 29 changed files with 96 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ Thumbs.db


backend/public/

frontend/projects/shared-call-components/src/lib/typings/

backend/src/typings/
16 changes: 3 additions & 13 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"dev:start": "cross-env USE_HTTPS=false SERVER_CORS_ORIGIN=* nodemon -I --exec node --experimental-specifier-resolution=node --loader ts-node/esm ./src/server.ts",
"lint": "eslint src --fix",
"format": "prettier --ignore-path .gitignore --write '**/*.{ts,js,json,md}'",
"pack": "npm pack",
"dev:sync-call-pro": "npm run build && npm run pack && cp openvidu-call-server-**.tgz ../../openvidu-call-pro/backend && cd ../../openvidu-call-pro/backend && npm install openvidu-call-server-**.tgz "
"package": "npm run build && npm pack",
"lib:sync-call-pro": "npm run package && cp openvidu-call-server-*.tgz ../../openvidu-call-pro/backend"
},
"dependencies": {
"@aws-sdk/client-s3": "3.673.0",
Expand All @@ -51,7 +51,6 @@
"@types/cors": "2.8.17",
"@types/express": "4.17.21",
"@types/node": "^20.12.14",
"@types/openvidu-call": "file:types-openvidu-call-1.0.0.tgz",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.6",
"@types/validator": "^13.12.2",
Expand All @@ -65,8 +64,5 @@
"prettier": "3.3.3",
"ts-node": "10.9.2",
"typescript": "5.4.5"
},
"peerDependencies": {
"@types/openvidu-call": "file:types-openvidu-call-1.0.0.tgz"
}
}
2 changes: 1 addition & 1 deletion backend/src/controllers/embedded.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import { LoggerService } from '../services/logger.service.js';
import { LiveKitService } from '../services/livekit.service.js';
import { TokenOptions } from 'openvidu-call';
import { TokenOptions } from '@typings-ce';

const logger = LoggerService.getInstance();
const livekitService = LiveKitService.getInstance();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import { CALL_PRIVATE_ACCESS } from '../../config.js';
import { LoggerService } from '../../services/logger.service.js';
import { GlobalPreferences } from 'openvidu-call';
import { GlobalPreferences } from '@typings-ce';

const logger = LoggerService.getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { GlobalPreferencesService } from '../../services/preferences/index.js';
import { OpenViduCallError } from '../../models/error.model.js';

const logger = LoggerService.getInstance();
const preferenceService = GlobalPreferencesService.getInstance();

export const updateRoomPreferences = async (req: Request, res: Response) => {
logger.verbose(`Updating room preferences: ${JSON.stringify(req.body)}`);
const roomPreferences = req.body;

try {
const preferenceService = GlobalPreferencesService.getInstance();
preferenceService.validateRoomPreferences(roomPreferences);

const savedPreferences = await preferenceService.updateRoomPreferences(roomPreferences);
Expand All @@ -31,6 +31,7 @@ export const updateRoomPreferences = async (req: Request, res: Response) => {

export const getRoomPreferences = async (req: Request, res: Response) => {
try {
const preferenceService = GlobalPreferencesService.getInstance();
const preferences = await preferenceService.getRoomPreferences();

if (!preferences) {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/room.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LiveKitService } from '../services/livekit.service.js';
import { LoggerService } from '../services/logger.service.js';
import { OpenViduCallError } from '../models/error.model.js';
import { RoomService } from '../services/room.service.js';
import { TokenOptions } from 'openvidu-call';
import { TokenOptions } from '@typings-ce';

const livekitService = LiveKitService.getInstance();
const roomService = RoomService.getInstance();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/middlewares/broadcasting.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request, Response, NextFunction } from 'express';
import { GlobalPreferencesService } from '../services/preferences/index.js';
import { RoomPreferences } from 'openvidu-call';
import { RoomPreferences } from '@typings-ce';
import { LoggerService } from '../services/logger.service.js';

export const withBroadcastingEnabled = async (req: Request, res: Response, next: NextFunction) => {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/middlewares/recording.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request, Response, NextFunction } from 'express';
import { GlobalPreferencesService } from '../services/preferences/index.js';
import { RoomPreferences } from 'openvidu-call';
import { RoomPreferences } from '@typings-ce';
import { LoggerService } from '../services/logger.service.js';

export const withRecordingEnabled = async (req: Request, res: Response, next: NextFunction) => {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/services/livekit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { LIVEKIT_API_KEY, LIVEKIT_API_SECRET, LIVEKIT_URL, LIVEKIT_URL_PRIVATE } from '../config.js';
import { LoggerService } from './logger.service.js';
import { errorLivekitIsNotAvailable, errorParticipantAlreadyExists, internalError } from '../models/error.model.js';
import { TokenOptions } from 'openvidu-call';
import { TokenOptions } from '@typings-ce';

export class LiveKitService {
protected static instance: LiveKitService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GlobalPreferences } from 'openvidu-call';
import { GlobalPreferences } from '@typings-ce';

/**
* Interface for managing global preferences storage.
Expand Down
19 changes: 12 additions & 7 deletions backend/src/services/preferences/global-preferences.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* regardless of the underlying storage mechanism.
*/

import { GlobalPreferences, RoomPreferences } from 'openvidu-call';
import { GlobalPreferences, RoomPreferences } from '@typings-ce';
import { LoggerService } from '../logger.service.js';
import { GlobalPreferencesStorage } from './global-preferences-storage.interface.js';
import { GlobalPreferencesStorageFactory } from './global-preferences.factory.js';
Expand All @@ -16,6 +16,7 @@ export class GlobalPreferencesService<T extends GlobalPreferences = GlobalPrefer
protected storage: GlobalPreferencesStorage;
protected constructor() {
this.storage = GlobalPreferencesStorageFactory.create();
console.log('00000000000000000000 GlobalPreferencesService created');
}

static getInstance() {
Expand All @@ -26,6 +27,10 @@ export class GlobalPreferencesService<T extends GlobalPreferences = GlobalPrefer
return GlobalPreferencesService.instance;
}

static setInstance(instance: GlobalPreferencesService) {
GlobalPreferencesService.instance = instance;
}

/**
* Initializes default preferences if not already initialized.
* @returns {Promise<T>} Default global preferences.
Expand Down Expand Up @@ -79,13 +84,13 @@ export class GlobalPreferencesService<T extends GlobalPreferences = GlobalPrefer

/**
* Resets room preferences to default values.
* @returns {Promise<GlobalPreferences>}
* @returns {Promise<T>}
*/
async resetRoomPreferences(): Promise<GlobalPreferences> {
async resetRoomPreferences(): Promise<T> {
const preferences = this.getDefaultPreferences();
const existingPreferences = await this.getGlobalPreferences();
existingPreferences.roomPreferences = preferences.roomPreferences;
return this.storage.savePreferences(existingPreferences);
return this.storage.savePreferences(existingPreferences) as Promise<T>;
}

/**
Expand Down Expand Up @@ -119,9 +124,9 @@ export class GlobalPreferencesService<T extends GlobalPreferences = GlobalPrefer

/**
* Returns the default global preferences.
* @returns {T}
* @returns {GlobalPreferences}
*/
protected getDefaultPreferences(): T {
protected getDefaultPreferences(): GlobalPreferences {
return {
projectId: CALL_NAME_ID,
roomPreferences: {
Expand All @@ -130,7 +135,7 @@ export class GlobalPreferencesService<T extends GlobalPreferences = GlobalPrefer
chatPreferences: { enabled: true },
virtualBackgroundPreferences: { enabled: true }
}
} as T;
};
}

/**
Expand Down
2 changes: 2 additions & 0 deletions backend/src/services/preferences/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from './global-preferences.service.js';
export * from './global-preferences-storage.interface.js';
export * from './global-preferences.factory.js';
2 changes: 1 addition & 1 deletion backend/src/services/preferences/s3-preferences-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* This is used when the application is configured to operate in "s3" mode.
*/

import { GlobalPreferences } from 'openvidu-call';
import { GlobalPreferences } from '@typings-ce';
import { GlobalPreferencesStorage } from './global-preferences-storage.interface.js';
import { S3Service } from '../s3.service.js';
import { LoggerService } from '../logger.service.js';
Expand Down
4 changes: 3 additions & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

"paths": {
"@typings-ce": ["./src/typings/ce/index.ts"]
}
},
"include": ["src/**/*.ts", "index.ts"],
"exclude": ["node_modules", "tests/**/*.ts", "tests/**/*.tsx"],
Expand Down
7 changes: 0 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"@types/chai": "4.3.19",
"@types/mocha": "9.1.1",
"@types/node": "20.12.14",
"@types/openvidu-call": "file:types-openvidu-call-1.0.0.tgz",
"@types/pixelmatch": "^5.2.6",
"@types/pngjs": "^6.0.5",
"@types/selenium-webdriver": "4.1.26",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { GlobalPreferencesService, NotificationService } from '../../../services';
import { DynamicGridComponent, ToggleCardComponent } from '../../../components';
import { RoomPreferences } from 'openvidu-call';
import { RoomPreferences } from '@typings-ce';

@Component({
selector: 'ov-room-preferences',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ChatPreferences,
RecordingPreferences,
VirtualBackgroundPreferences
} from 'openvidu-call';
} from '@typings-ce';
import { HttpService, ContextService, GlobalPreferencesService } from '../../services';

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { RoomPreferences } from 'openvidu-call';
import { RoomPreferences } from '@typings-ce';
import { LoggerService } from 'openvidu-components-angular';
import { HttpService } from '../http/http.service';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { GlobalPreferences, RoomPreferences } from 'openvidu-call';
import { GlobalPreferences, RoomPreferences } from '@typings-ce';
import { RecordingInfo } from 'openvidu-components-angular';
import { lastValueFrom } from 'rxjs';

Expand Down
4 changes: 2 additions & 2 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"core-js/es7/reflect": ["./node_modules/core-js/proposals/reflect-metadata"],
"@app/*": ["src/app/*"],
"@lib/*": ["projects/shared-call-components/src/lib/*"],
"@typings-ce": ["projects/shared-call-components/src/lib/typings/ce/index.ts"],
// "@services/*": ["src/app/services/*"],
// "@models/*": ["src/app/models/*"],
// "@guards/*": ["src/app/guards/*"],
// "@pages/*": ["src/app/pages/*"],
"@environment/*": ["src/environments/*"],
"shared-call-components": ["dist/shared-call-components"],
"@types/openvidu-call": ["../types/dist"]
"shared-call-components": ["dist/shared-call-components"]
},
"importHelpers": true,
"target": "ES2022",
Expand Down
1 change: 1 addition & 0 deletions prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cd ..
# Build backend
cd backend
npm install
npm run build
cd ..

# Build frontend
Expand Down
7 changes: 3 additions & 4 deletions types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
"scripts": {
"build": "tsc",
"serve": "tsc -w",
"package": "npm run build && npm pack",
"sync-ce": "npm run package && PACKAGE=$(ls types-openvidu-call-*.tgz) && cp $PACKAGE ../frontend && cp $PACKAGE ../backend",
"sync-pro": "npm run package && PACKAGE=$(ls types-openvidu-call-*.tgz) && cp $PACKAGE ../../openvidu-call-pro/frontend && cp $PACKAGE ../../openvidu-call-pro/backend",
"sync": "npm run sync-ce && npm run sync-pro"
"sync-ce": "./sync-types.sh ce",
"sync-pro": "./sync-types.sh pro",
"sync": "./sync-types.sh"
},
"devDependencies": {
"typescript": "^5.6.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RoomPreferences } from './room-preferences';

import { RoomPreferences } from './room-preferences.js';
export interface GlobalPreferences {
projectId: string;
roomPreferences: RoomPreferences;
Expand Down
4 changes: 2 additions & 2 deletions types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './types/global-preferences.js';
export * from './types/room-preferences.js';
export * from './global-preferences.js';
export * from './room-preferences.js';
export * from './types/token.js';
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@ export interface RoomPreferences {
chatPreferences: ChatPreferences;
virtualBackgroundPreferences: VirtualBackgroundPreferences;
}

export interface RecordingPreferences {
enabled: boolean;
// outputMode: string;
// hasAudio: boolean;
// hasVideo: boolean;
}

export interface BroadcastingPreferences {
enabled: boolean;
}

export interface ChatPreferences {
enabled: boolean;
}

export interface VirtualBackgroundPreferences {
enabled: boolean;
}
Loading

0 comments on commit 2850365

Please sign in to comment.