import { Service, Inject, Container } from 'typedi'; import initLogger, { JsmLogger } from 'jsm-logger'; import { fixFiltersObject, createBooleanFilter, createDateRangeFilter, createStringFilter, } from "jsm-utilities"; import exceptions from "jsm-exceptions"; import { uniq } from "lodash"; import { } from ''; /** * @service ArticlesService * @description Articles management service * @method create Create a new article * @method update Update an article * @method delete Delete an article * @method getById Get an article * @method getBySlug Get an article * @method list List articles * @method aggregateByTypes Aggregate articles by types * @method aggregateByRoles Aggregate articles by roles * */ @Service() export class ArticlesService extends BaseService { constructor() { super(); } /** * * @description Create a new article * @method POST * @link /content/articles * @param {Levelup.Core.Content.Api.Articles.Create.Request} body * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async create( AUTH_DATA ): Promise { try { this.logger.info('Calling method create'); return result; } catch (error) { this.logger.error('Error in create method:', error); throw new Error('create operation failed'); } } /** * * @description Update an article * @method PUT * @link /content/articles/:id * @param {string} @description Update an article * @param {string} @method PUT * @param {string} @link /content/articles/:id * @param {Levelup.Core.Content.Api.Articles.Update.Request} body * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async update( AUTH_DATA ): Promise { try { this.logger.info('Calling method update'); return result; } catch (error) { this.logger.error('Error in update method:', error); throw new Error('update operation failed'); } } /** * * @description Delete an article * @method DELETE * @link /content/articles/:id * @param {string} @description Delete an article * @param {string} @method DELETE * @param {string} @link /content/articles/:id * @param {Levelup.Core.Content.Api.Articles.Delete.Request} query * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async delete( AUTH_DATA ): Promise { try { this.logger.info('Calling method delete'); return result; } catch (error) { this.logger.error('Error in delete method:', error); throw new Error('delete operation failed'); } } /** * * @description Get an article * @method GET * @link /content/articles/:id * @param {string} @description Get an article * @param {string} @method GET * @param {string} @link /content/articles/:id * @param {Levelup.Core.Content.Api.Articles.GetOne.Request} query * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async getById( AUTH_DATA ): Promise { try { this.logger.info('Calling method getById'); return result; } catch (error) { this.logger.error('Error in getById method:', error); throw new Error('getById operation failed'); } } /** * * @description Get an article * @method GET * @link /content/articles/by-slug/:slug * @param {string} @description Get an article * @param {string} @method GET * @param {string} @link /content/articles/by-slug/:slug * @param {Levelup.Core.Content.Api.Articles.GetOne.Request} query * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async getBySlug( AUTH_DATA ): Promise { try { this.logger.info('Calling method getBySlug'); return result; } catch (error) { this.logger.error('Error in getBySlug method:', error); throw new Error('getBySlug operation failed'); } } /** * * @description List articles * @method GET * @link /content/articles * @param {Levelup.Core.Content.Api.Articles.List.Request} query * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async list( AUTH_DATA ): Promise { try { this.logger.info('Calling method list'); return result; } catch (error) { this.logger.error('Error in list method:', error); throw new Error('list operation failed'); } } /** * * @description Aggregate articles by types * @method GET * @link /content/articles/aggregate-by-types * @param {Levelup.Core.Content.Api.Articles.AggregateByTypes.Request} query * @param {Levelup.Core.Security.AuthData | null } authData * @returns {Promise} */ async aggregateByTypes( AUTH_DATA ): Promise { try { this.logger.info('Calling method aggregateByTypes'); return result; } catch (error) { this.logger.error('Error in aggregateByTypes method:', error); throw new Error('aggregateByTypes operation failed'); } } }