UNPKG

timeld-common

Version:
30 lines (27 loc) 714 B
import { AccountOwnedId } from '../index.mjs'; /** * Utility base class for things that represent a Gateway */ export default class BaseGateway { /** * @param {string} domainName */ constructor(domainName) { if (!domainName) throw new RangeError('No domain specified for Gateway'); this.domainName = domainName; } /** * @param {import('@m-ld/m-ld').Reference} tsRef * @returns {AccountOwnedId} */ ownedRefAsId(tsRef) { // A timesheet reference may be relative to the domain base return AccountOwnedId.fromReference(tsRef, this.domainName); } ownedId(account, name) { return new AccountOwnedId({ gateway: this.domainName, account, name }); } }