repository-provider
Version:
abstract interface to git repository providers like github, bitbucket and gitlab
74 lines (65 loc) • 1.55 kB
JavaScript
import { getAttributesJSON, name_attribute_writable } from "pacc";
import { BaseObject } from "./base-object.mjs";
/**
* Object with a name.
* @param {string} name
* @param {Object} [options]
* @param {string} [options.id]
* @param {string} [options.name]
* @param {string} [options.description]
* @param {Object} [additionalProperties]
*
* @property {string} name
*/
export class NamedObject extends BaseObject {
static attributes = {
...BaseObject.attributes,
name: name_attribute_writable
};
name;
constructor(name, options) {
delete options?.name; // TODO
super(options);
this.name = name;
}
/**
* Beautified name use for human displaying only.
* @return {string} human readable name
*/
get displayName() {
return this.name;
}
/**
* Name with default parts removed
* @return {string}
*/
get condensedName() {
return this.name;
}
/**
* Complete name in the hierachy.
* @return {string}
*/
get fullCondensedName() {
return this.fullName;
}
/**
* Check for equality.
* @param {NamedObject} other
* @return {boolean} true if names are equal and have the same provider
*/
equals(other) {
return (
super.equals(other) &&
this.fullName === other.fullName &&
// @ts-ignore
this.provider.equals(other.provider)
);
}
/**
* Provided name and all defined attributes.
*/
toJSON(filter) {
return { ...getAttributesJSON(this, this.constructor.attributes, filter), name: this.name };
}
}