@m-ld/gateway
Version:
m-ld gateway for services
56 lines (55 loc) • 1.77 kB
TypeScript
import { Reference } from '@m-ld/m-ld';
import { as } from '../lib/validate.js';
/**
* Combination of gateway, account and timesheet/project. Representations:
* 1. Presentation string `[<account>/]<name>[@<gateway>]`,
* see {@link toString} and {@link #fromString}.
* 2. Configuration/persistence path array
* see {@link #toPath} and {@link #fromPath}.
* 3. m-ld domain name `<name>.<account>.<gateway>`
* see {@link #fromDomain}.
*/
export declare class AccountOwnedId {
static fromString(str: string): AccountOwnedId;
static fromPath(dir: string[]): AccountOwnedId;
static fromDomain(domain: string): AccountOwnedId;
static fromIri(iri: string | URL, gateway?: string): AccountOwnedId;
static fromReference(ref: Reference, gateway?: string): AccountOwnedId;
readonly gateway: string;
readonly account: string;
readonly name: string;
/**
* @param name
* @param account
* @param gateway dot-separated gateway "domain name"
*/
constructor({ gateway, account, name }: {
gateway?: string;
account?: string;
name: string;
});
get isRelative(): boolean;
get isValid(): boolean;
/** Validates this ID */
validate(): this;
static checkComponentId(id: any): void;
static isComponentId(id: any): id is string;
static asComponentId: as.StringSchema<string>;
/**
* @returns path relative directory path suitable for persistence
*/
toPath(): string[];
toDomain(): string;
toIri(): string;
toRelativeIri(): string;
toReference(): {
'@id': string;
};
toStateId(tick: number): string;
toString(): string;
toJSON(): {
gateway: string;
account: string;
name: string;
};
}