@granito/ngx-hal-client
Version:
A HAL client to be used in Angular projects
1 lines • 31.4 kB
Source Map (JSON)
{"version":3,"file":"granito-ngx-hal-client.mjs","sources":["../../../src/lib/hal-error.ts","../../../src/lib/hal-base.ts","../../../src/lib/resource.ts","../../../src/lib/collection.ts","../../../src/lib/utils.ts","../../../src/lib/rxjs.ts","../../../src/lib/hal-client.service.ts","../../../src/lib/accessor.ts","../../../src/public-api.ts","../../../src/granito-ngx-hal-client.ts"],"sourcesContent":["/**\n * This class represents errors thrown by _Angular HAL Client_. It\n * unifies errors produced by _Angulat HTTP Client_ and errors originating\n * in the API.\n */\nexport class HalError extends Error {\n /**\n * The URI path where the error originated.\n */\n path?: string;\n\n /**\n * The HTTP status code of the error.\n */\n status?: number;\n\n /**\n * The description of the HTTP status.\n */\n error?: string;\n\n /**\n * XXX.\n */\n [key: string]: any;\n\n /**\n * @param err the object used to set properties\n */\n constructor(err: any) {\n super();\n Object.assign(this, err);\n this.name = 'HalError';\n }\n}\n","import { HttpClient, HttpErrorResponse } from '@angular/common/http';\nimport { Type } from '@angular/core';\nimport { Observable, catchError, map, throwError } from 'rxjs';\nimport { Accessor, HalError, objectFrom } from './internal';\n\nconst self = 'self';\n\ninterface Link {\n href: string;\n\n templated?: boolean;\n\n methods?: string[];\n}\n\n/**\n * The common base for resource and accessor.\n */\nexport abstract class HalBase {\n protected readonly _client!: HttpClient;\n\n protected readonly _links: Readonly<Record<string, Link>> = {};\n\n protected readonly _embedded: Readonly<Record<string, Object>> = {};\n\n /**\n * The URI of `self` link.\n */\n get self(): string {\n return this._links[self]?.href;\n }\n\n /**\n * This property is `true` when either `methods` array does not exist\n * in the `self` link or the array exists and contains `POST` string.\n * It is `false` otherwise.\n */\n get canCreate(): boolean {\n return this.can('POST');\n }\n\n /**\n * This property is `true` when either `methods` array does not exist\n * in the `self` link or the array exists and contains `GET` string.\n * It is `false` otherwise.\n */\n get canRead(): boolean {\n return this.can('GET');\n }\n\n /**\n * This property is `true` when either `methods` array does not exist\n * in the `self` link or the array exists and contains `DELETE`\n * string. It is `false` otherwise.\n */\n get canDelete(): boolean {\n return this.can('DELETE');\n }\n\n /**\n * @param obj the object used to assign the properties\n */\n constructor(obj: Object) {\n Object.assign(this, obj);\n }\n\n /**\n * Create a new resource in the collection identified by `self` link.\n * It makes a `POST` call to the URI in `self` link and returns an\n * observable for the call. The observable normally emits an accessor\n * for the newly created resource or `undefined` if `Location` header\n * was not returned by the call.\n *\n * @param obj the payload for the `POST` method call\n * @returns an observable of the resource's accessor\n */\n create(obj: any): Observable<Accessor | undefined> {\n return this.withSelf(\n self => this._client.post(self, objectFrom(obj), {\n observe: 'response'\n }).pipe(\n map(response => response.headers.get('Location') || undefined),\n map(location => !location ? undefined : this.accessor(location)),\n catchError(this.handleError)\n )\n );\n }\n\n /**\n * Delete the resource identified by `self` link.\n *\n * @returns an observable that emits next signal on successful delete\n */\n delete(): Observable<void> {\n return this.withSelf(\n self => this._client.delete(self).pipe(\n map(() => undefined),\n catchError(this.handleError)\n )\n );\n }\n\n protected withSelf<T>(func: (uri: string) => Observable<T>): Observable<T> {\n const self = this.self;\n\n if (!self)\n return throwError(() => new HalError({\n message: 'no valid \"self\" relation'\n }));\n\n return func(self);\n }\n\n protected accessor(href: string, methods?: string[]): Accessor {\n return this.instanceOf(Accessor, {\n _links: {\n self: {\n href,\n methods\n }\n }\n });\n }\n\n protected instanceOf<T>(type: Type<T>, obj: Object): T {\n return new type({ ...obj, _client: this._client });\n }\n\n protected handleError(err: HttpErrorResponse): Observable<never> {\n if (err.error instanceof Event)\n return throwError(() => new HalError({\n message: err.message,\n path: err.url\n }));\n\n return throwError(() => new HalError({\n message: err.message,\n status: err.status,\n error: err.statusText,\n path: err.url,\n ...err.error\n }));\n }\n\n protected can(method: string): boolean {\n const methods = this._links[self]?.methods;\n\n if (!Array.isArray(methods))\n return true;\n\n return !!methods.find(m => typeof m === 'string' &&\n m.toUpperCase() === method);\n }\n}\n","import { Type } from '@angular/core';\nimport { Observable, catchError, map } from 'rxjs';\nimport * as URI from 'uri-template';\nimport { Accessor, HalBase, objectFrom } from './internal';\n\n/**\n * This type represent parameters for templated links.\n */\nexport type Params = Record<string, string | number | boolean>;\n\n/**\n * This class repesents an in-memory instance of a HAL resource.\n */\nexport class Resource extends HalBase {\n /**\n * This property is `true` when either `methods` array does not exist\n * in the `self` link or the array exists and contains `PUT` string.\n * It is `false` otherwise.\n */\n get canUpdate(): boolean {\n return this.can('PUT');\n }\n\n /**\n * Follow the relation link. Returns an accessor for the resource\n * or `undefined` if no such relation exists.\n *\n * @param rel the name of the relation link\n * @param params parameters for a templated link\n * @returns an accessor for the linked resource or `undefined`\n */\n follow(rel: string, params: Params = {}): Accessor | undefined {\n const link = this._links[rel];\n\n if (!link)\n return undefined;\n\n const uri = link.href;\n\n return !uri ? undefined :\n this.accessor(!link.templated ? uri :\n URI.parse(uri).expand(params), link.methods);\n }\n\n /**\n * Refresh the the resource. In other words, read the resource\n * identified by `self` link.\n *\n * @returns an observable of the refreshed resource instance\n */\n read(): Observable<this> {\n const type = this.constructor as Type<this>;\n\n return this.withSelf(self => this._client.get(self).pipe(\n map(obj => this.instanceOf(type, obj)),\n catchError(this.handleError)\n ));\n }\n\n /**\n * Persit the resource. Uses `PUT` request to send the new resource\n * state.\n *\n * @returns an observable of resource accessor\n */\n update(): Observable<Accessor> {\n return this.withSelf(self => this._client.put(self, objectFrom(this)).pipe(\n map(() => this.accessor(self)),\n catchError(this.handleError)\n ));\n }\n\n /**\n * Returns a single embedded resource or `undefined` if no such\n * embedded exists. If the named resource is an array it returns\n * the first element.\n *\n * @param type the resource type\n * @param rel the name of the embedded resource\n * @returns the resource or `undefined`\n */\n get<T extends Resource>(type: Type<T>, rel: string): T | undefined {\n const obj = this._embedded[rel];\n\n if (Array.isArray(obj)) {\n const objs = obj as Object[];\n const first = objs[0];\n\n return first && this.instanceOf(type, first);\n }\n\n return obj && this.instanceOf(type, obj);\n }\n\n /**\n * Returns an embedded array of resources or `undefined` if the named\n * embedded does not exist. If the named resource is not an array it\n * wraps the resource in an array.\n *\n * @param type the element resource type\n * @param rel the name of the embedded resource array\n * @returns the resource array or `undefined`\n */\n getArray<T extends Resource>(type: Type<T>, rel: string):\n T[] | undefined {\n const obj = this._embedded[rel];\n\n if (Array.isArray(obj))\n return this.arrayOf(type, obj);\n\n return obj && [this.instanceOf(type, obj)];\n }\n\n protected clone(override: any = {}): this {\n return new (this.constructor as Type<this>)({\n ...this,\n ...override\n });\n }\n\n protected arrayOf<T extends Resource>(type: Type<T>,\n values: Object[]): T[] {\n return values.map(obj => this.instanceOf(type, obj));\n }\n}\n","import { Type } from '@angular/core';\nimport { Observable, catchError, map } from 'rxjs';\nimport { Accessor, Resource } from './internal';\n\nconst next = 'next';\n\nconst prev = 'prev';\n\n/**\n * This class represents an in-memory collection of resources.\n */\nexport class Collection<T extends Resource> extends Resource {\n /**\n * Zero-based offset of the first element of the `values` array in\n * the collection.\n */\n readonly start: number;\n\n /**\n * A page of values of the collection starting with `start` offset.\n */\n readonly values: T[];\n\n /**\n * @param type the element resource type\n * @param obj the object used to assign the properties\n */\n constructor(private readonly type: Type<T>, obj: any) {\n super(obj);\n\n this.start = obj.start > 0 ? Math.trunc(obj.start) : 0;\n\n for (const rel in this._embedded) {\n const values = this._embedded[rel];\n\n if (Array.isArray(values)) {\n this.values = this.arrayOf(type, values);\n\n return;\n }\n }\n\n this.values = [];\n }\n\n /**\n * Follow `next` link if it exists and can be read.\n *\n * @returns the accessor for the link or `undefined`\n */\n next(): Accessor | undefined {\n const accessor = this.follow(next);\n\n return !!accessor && accessor.canRead ? accessor : undefined;\n }\n\n /**\n * Follow `prev` link if it exists and can be read.\n *\n * @returns the accessor for the link or `undefined`\n */\n previous(): Accessor | undefined {\n const accessor = this.follow(prev);\n\n return !!accessor && accessor.canRead ? accessor : undefined;\n }\n\n /**\n * Refresh the resource collection. In other words, read\n * the resource collection identified by `self` link.\n *\n * @returns an observable of the refreshed resource collection instance\n */\n override read(): Observable<this> {\n return this.withSelf(self => this._client.get(self).pipe(\n map(obj => new Collection(this.type, {\n ...obj,\n _client: this._client\n }) as this),\n catchError(this.handleError)\n ));\n }\n}\n","import { Collection, Resource } from './internal';\n\n/**\n * Convert any item, be that a {@link Resource} or {@link Collection}\n * to a plain {@link Object} or {@link Array}. On conversion\n * HAL-related properties (`_client`, `_links`, `_embedded`)\n * are not included in the resulting object. Primitive types\n * as well as `null` or `undefined` are returned unchanged.\n * If the argument is an array, every item of the returned array\n * is converted recursively. For {@link Collection} it returns\n * the array of values where each item is converted recursively.\n *\n * @param item the item to convert\n * @returns an object, array, primitive value, `undefined` or `null`\n */\nexport function objectFrom(item: any): any {\n if (typeof item !== 'object' || item === null)\n return item;\n\n if (item instanceof Collection)\n return objectFrom(item.values);\n\n if (Array.isArray(item))\n return item.map(x => objectFrom(x));\n\n const { _client, _links, _embedded, ...object } = item;\n\n return object;\n}\n\n/**\n * @param arg argument to test\n * @returns `false` if the argument is `null` or `undefined` and `true`\n * otherwise\n */\nexport function isDefined<T>(arg: T | null | undefined):\n arg is T extends null | undefined ? never : T {\n return arg !== undefined && arg !== null;\n}\n","import { Type } from '@angular/core';\nimport { Observable, OperatorFunction, filter, map, of, pipe, switchMap,\n takeUntil } from 'rxjs';\nimport { Accessor, Collection, Params, Resource, isDefined } from './internal';\n\n/**\n * Returns an RxJS operator that makes the source {@link Observable}\n * complete at the same time as the lifetime {@link Observable}.\n *\n * @param lifetime the lifetime observable\n * @returns a function that transforms the source {@link Observable}\n */\nexport function completeWith<T>(lifetime: Observable<any>):\n OperatorFunction<T, T> {\n const terminator$ = new Observable<void>(subscriber =>\n lifetime.subscribe().add(() => subscriber.next()));\n\n return pipe(takeUntil(terminator$));\n}\n\n/**\n * Returns an RxJS operator to follow a link on a {@link Resource}. It is\n * equivalent to\n * ```ts\n * map(resource => resource?.follow(rel, params))\n * ```\n *\n * @param rel the relation to follow\n * @param params the parameters to expand the link\n * @returns a function that transforms the source {@link Observable}\n */\nexport function follow(rel: string, params?: Params | undefined):\n OperatorFunction<Resource | null | undefined, Accessor | undefined> {\n return pipe(\n map(resource => resource?.follow(rel, params))\n );\n}\n\n/**\n * Returns an RxJS operator to create a new resource identified by\n * an {@link Accessor} or a {@link Resource}. It is equivalent to\n * ```ts\n * switchMap(x => of(undefined))\n * ```\n * if the stream value is `null` or `undefined` and to\n * ```ts\n * switchMap(x => x.create(obj))\n * ```\n * otherwise.\n *\n * @param obj the value for the resource\n * @returns a function that transforms the source {@link Observable}\n */\nexport function create(obj: any):\n OperatorFunction<Accessor | Resource | undefined, Accessor | undefined> {\n return pipe(\n switchMap(base => !base ? of(undefined) : base.create(obj))\n );\n}\n\n/**\n * Returns an RxJS operator to read a {@link Resource} using an\n * {@link Accessor}. It is equivalent to\n * ```ts\n * switchMap(accessor => of(undefined))\n * ```\n * if `accessor` is `null` or `undefined` and to\n * ```ts\n * switchMap(accessor => accessor.read(type))\n * ```\n * otherwise.\n *\n * @param type the resource type\n * @returns a function that transforms the source {@link Observable}\n */\nexport function read<T extends Resource>(type: Type<T>):\n OperatorFunction<Accessor | null | undefined, T | undefined> {\n return pipe(\n switchMap(accessor => !accessor ? of(undefined) :\n accessor.read(type))\n );\n}\n\n/**\n * Returns an RxJS operator to read a {@link Collection} of resources\n * using an {@link Accessor}. It is equivalent to\n * ```ts\n * switchMap(accessor => of(undefined))\n * ```\n * if `accessor` is `null` or `undefined` and to\n * ```ts\n * switchMap(accessor => accessor.readCollection(type))\n * ```\n * otherwise.\n *\n * @param type the collection element type\n * @returns a function that transforms the source {@link Observable}\n */\nexport function readCollection<T extends Resource>(type: Type<T>):\n OperatorFunction<Accessor | null | undefined, Collection<T> | undefined> {\n return pipe(\n switchMap(accessor => !accessor ? of(undefined) :\n accessor.readCollection(type))\n );\n}\n\n/**\n * Returns an RxJS operator to refresh a {@link Resource} or\n * {@link Collection} of resources. It is equivalent to\n * ```ts\n * switchMap(resource => of(undefined))\n * ```\n * if `resource` is `null` or `undefined` and to\n * ```ts\n * switchMap(resource => resource.read())\n * ```\n * otherwise.\n *\n * @returns a function that transforms the source {@link Observable}\n */\nexport function refresh<T extends Resource>():\n OperatorFunction<T | null | undefined, T | undefined> {\n return pipe(\n switchMap(resource => !resource ? of(undefined) : resource.read())\n );\n}\n\n/**\n * Returns an RxJS operator to edit and update a {@link Resource}.\n * It is equivalent to\n * ```ts\n * switchMap(resource => of(undefined))\n * ```\n * if `resource` is `null` or `undefined` and applying edit operation to\n * the resource and doing\n * ```ts\n * switchMap(resource => resource.update())\n * ```\n * otherwise.\n *\n * @param edit the operation to edit the resource\n * @returns a function that transforms the source {@link Observable}\n */\nexport function update<T extends Resource>(edit: (resource: Readonly<T>) => T):\n OperatorFunction<T | undefined, Accessor | undefined> {\n return pipe(\n switchMap(resource => {\n if (!resource)\n return of(undefined);\n\n return (edit(resource)).update();\n })\n );\n}\n\n/**\n * Returns an RxJS operator to delete a resource identified by\n * an {@link Accessor} or a {@link Resource}. It is equivalent to\n * ```ts\n * switchMap(x => of(undefined))\n * ```\n * if the stream value is `null` or `undefined` and to\n * ```ts\n * switchMap(x => x.delete())\n * ```\n * otherwise.\n *\n * @returns a function that transforms the source {@link Observable}\n */\nexport function del():\n OperatorFunction<Accessor | Resource | undefined, void> {\n return pipe(\n switchMap(base => !base ? of(undefined) : base.delete())\n );\n}\n\n/**\n * Returns an RxJS operator to filter out `null` and `undefined` items\n * from the source {@link Observable}.\n *\n * @returns a function that transforms the source {@link Observable}\n */\nexport function defined<T>():\n OperatorFunction<T | null | undefined, T extends null | undefined ? never : T> {\n return pipe(\n filter(isDefined)\n );\n}\n","import { HttpClient } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { Accessor } from './internal';\n\n/**\n * This service is used to obtain API root accessors. It incapsulates\n * {@link HttpClient}, which will be passed to all {@link Accessor}\n * objects originating from this service, directly or indirectly.\n */\n@Injectable({ providedIn: 'root' })\nexport class HalClientService {\n /**\n * @param httpClient Angular HTTP client\n */\n constructor(private readonly httpClient: HttpClient) {\n }\n\n /**\n * Obtain an accessor for the API root entry point specified by the\n * URI.\n *\n * @param uri the URI for the API root\n * @returns an accessor for the API root\n */\n root(uri: string): Accessor {\n return new Accessor({\n _client: this.httpClient,\n _links: {\n self: { href: uri }\n }\n });\n }\n}\n","import { Type } from '@angular/core';\nimport { Observable, catchError, map } from 'rxjs';\nimport { Collection, HalBase, Resource } from './internal';\n\n/**\n * This class provides a way to execute operations on HAL resources\n * without reading them first. Accessors are obtained either by following\n * resource links or by getting the root entry point for the API.\n */\nexport class Accessor extends HalBase {\n /**\n * Read the resource identified by `self` link.\n *\n * @param type the resource type\n * @returns an observable of the resource instance\n */\n read<T extends Resource>(type: Type<T>): Observable<T> {\n return this._client.get(this.self).pipe(\n map(obj => this.instanceOf(type, obj)),\n catchError(this.handleError)\n );\n }\n\n /**\n * Read the resource collection identified by `self` link.\n *\n * @param type the collection element type\n * @returns an observable of the collection instance\n */\n readCollection<T extends Resource>(type: Type<T>):\n Observable<Collection<T>> {\n return this._client.get(this.self).pipe(\n map(obj => new Collection(type, {\n ...obj,\n _client: this._client\n })),\n catchError(this.handleError)\n );\n }\n}\n","/*\n * Public API Surface of ngx-hal-client\n */\n\nexport * from './lib/hal-error';\nexport * from './lib/accessor';\nexport * from './lib/resource';\nexport * from './lib/collection';\nexport * from './lib/utils';\nexport * from './lib/rxjs';\nexport * from './lib/hal-client.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;AAIG;AACG,MAAO,QAAS,SAAQ,KAAK,CAAA;AAqB/B;;AAEG;AACH,IAAA,WAAA,CAAY,GAAQ,EAAA;AAChB,QAAA,KAAK,EAAE,CAAC;AACR,QAAA,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACzB,QAAA,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;KAC1B;AACJ;;AC7BD,MAAM,IAAI,GAAG,MAAM,CAAC;AAUpB;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