const Project_element_defaultsDBApi = require('../db/api/project_element_defaults');
const { createEntityService } = require('../factories/service.factory');

const BaseService = createEntityService(Project_element_defaultsDBApi, {
  entityName: 'project_element_defaults',
});

class Project_element_defaultsService extends BaseService {
  /**
   * Reset a project element default to the current global default
   */
  static async resetToGlobal(id, options = {}) {
    return Project_element_defaultsDBApi.resetToGlobal(id, options);
  }

  /**
   * Get diff between project default and current global default
   */
  static async getDiffFromGlobal(id) {
    return Project_element_defaultsDBApi.getDiffFromGlobal(id);
  }

  /**
   * Snapshot all global element defaults to a project
   */
  static async snapshotGlobalDefaults(projectId, options = {}) {
    return Project_element_defaultsDBApi.snapshotGlobalDefaults(
      projectId,
      options,
    );
  }
}

module.exports = Project_element_defaultsService;
