Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 1x 1x 1x 1x | // Package: com.lightningkite.lightningdb.live
// Generated by Khrysalis - this file will be overwritten.
import { Condition } from '../Condition'
import { HasId } from '../HasId'
import { MassModification } from '../MassModification'
import { Modification } from '../Modification'
import { UUIDFor } from '../UUIDFor'
import { WriteModelApi } from '../WriteModelApi'
import { ReifiedType } from '@lightningkite/khrysalis-runtime'
import { HttpBody, HttpClient, fromJSON, unsuccessfulAsError } from '@lightningkite/rxjs-plus'
import { Observable, switchMap } from 'rxjs'
//! Declares com.lightningkite.lightningdb.live.LiveWriteModelApi
export class LiveWriteModelApi<Model extends HasId> extends WriteModelApi<Model> {
public constructor(public readonly url: string, public readonly token: string, public readonly serializer: ReifiedType) {
super();
}
public post(value: Model): Observable<Model> {
return HttpClient.INSTANCE.call(this.url, HttpClient.INSTANCE.POST, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(value), undefined).pipe(unsuccessfulAsError, fromJSON<Model>(this.serializer));
}
public postBulk(values: Array<Model>): Observable<Array<Model>> {
return HttpClient.INSTANCE.call(`${this.url}/bulk`, HttpClient.INSTANCE.POST, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(values), undefined).pipe(unsuccessfulAsError, fromJSON<Array<Model>>([Array, this.serializer]));
}
public put(value: Model): Observable<Model> {
return HttpClient.INSTANCE.call(`${this.url}/${value._id}`, HttpClient.INSTANCE.PUT, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(value), undefined).pipe(unsuccessfulAsError, fromJSON<Model>(this.serializer));
}
public putBulk(values: Array<Model>): Observable<Array<Model>> {
return HttpClient.INSTANCE.call(`${this.url}/bulk`, HttpClient.INSTANCE.PUT, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(values), undefined).pipe(unsuccessfulAsError, fromJSON<Array<Model>>([Array, this.serializer]));
}
public patch(id: UUIDFor<Model>, modification: Modification<Model>): Observable<Model> {
return HttpClient.INSTANCE.call(`${this.url}/${id}`, HttpClient.INSTANCE.PATCH, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(modification), undefined).pipe(unsuccessfulAsError, fromJSON<Model>(this.serializer));
}
public patchBulk(modification: MassModification<Model>): Observable<Array<Model>> {
return HttpClient.INSTANCE.call(`${this.url}/bulk`, HttpClient.INSTANCE.PATCH, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(modification), undefined).pipe(unsuccessfulAsError, fromJSON<Array<Model>>([Array, this.serializer]));
}
public _delete(id: UUIDFor<Model>): Observable<void> {
return HttpClient.INSTANCE.call(`${this.url}/${id}`, HttpClient.INSTANCE.DELETE, new Map([["Authorization", `Bearer ${this.token}`]]), undefined, undefined).pipe(unsuccessfulAsError, switchMap(x => x.text().then(x => undefined)));
}
public deleteBulk(condition: Condition<Model>): Observable<void> {
return HttpClient.INSTANCE.call(`${this.url}/bulk`, HttpClient.INSTANCE.DELETE, new Map([["Authorization", `Bearer ${this.token}`]]), HttpBody.json(condition), undefined).pipe(unsuccessfulAsError, switchMap(x => x.text().then(x => undefined)));
}
} |