@siren-js/client
Version:
Siren API client library
69 lines (68 loc) • 2.37 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { IsArray, IsMimeType, IsOptional, IsString } from 'class-validator';
import { IsUri } from '../utils/is-uri';
/**
* Represents a URI-addressable resource
*/
export class Link {
/**
* List of strings describing the nature of the `Link` based on the current representation. Possible values are
* implementation-dependent and should be documented.
*/
class = [];
/**
* URI of the linked resource.
*/
href;
/**
* List of strings describing the relationship of the `Link` to its `Entity`, per [RFC 8288](https://tools.ietf.org/html/rfc8288).
*/
rel;
/**
* Text describing the nature of the link.
*/
title;
/**
* Hint indicating what the media type of the result of dereferencing the `Link` should be, per [RFC 8288](https://tools.ietf.org/html/rfc8288#section-3.4.1).
*/
type;
/**
* Visits this link.
*/
async accept(visitor) {
await visitor.visitLink(this);
}
}
__decorate([
IsArray(),
IsString({ each: true }),
IsOptional(),
__metadata("design:type", Array)
], Link.prototype, "class", void 0);
__decorate([
IsUri(),
__metadata("design:type", String)
], Link.prototype, "href", void 0);
__decorate([
IsArray(),
IsString({ each: true }),
__metadata("design:type", Array)
], Link.prototype, "rel", void 0);
__decorate([
IsString(),
IsOptional(),
__metadata("design:type", String)
], Link.prototype, "title", void 0);
__decorate([
IsMimeType(),
IsOptional(),
__metadata("design:type", String)
], Link.prototype, "type", void 0);