@serialized/serialized-client
Advanced tools
Comparing version 0.2.1 to 0.2.2
import { AxiosInstance } from "axios"; | ||
import { SerializedConfig } from "./serialized-config"; | ||
import { LoadAggregateResponse } from "./types"; | ||
import BaseClient from "./base-client"; | ||
@@ -8,5 +7,5 @@ import AggregateRoot from "./model/aggregate-root"; | ||
constructor(axiosClient: AxiosInstance, config: SerializedConfig); | ||
load(aggregateType: string, aggregateId: string, since?: number, limit?: number): Promise<LoadAggregateResponse>; | ||
load<T>(aggregateRoot: AggregateRoot<T>): Promise<void>; | ||
save(aggregateRoot: AggregateRoot<any>, consistencyCheck?: boolean): Promise<any>; | ||
checkExists(aggregateType: string, aggregateId: string): Promise<any>; | ||
} |
@@ -61,8 +61,12 @@ "use strict"; | ||
} | ||
AggregateClient.prototype.load = function (aggregateType, aggregateId, since, limit) { | ||
AggregateClient.prototype.load = function (aggregateRoot) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.axiosClient.get("/aggregates/" + aggregateType + "/" + aggregateId, this.axiosConfig())]; | ||
case 1: return [2 /*return*/, (_a.sent()).data]; | ||
case 0: return [4 /*yield*/, this.axiosClient.get("/aggregates/" + aggregateRoot.aggregateType + "/" + aggregateRoot.aggregateId, this.axiosConfig())]; | ||
case 1: | ||
data = (_a.sent()).data; | ||
aggregateRoot.fromEvents(data); | ||
return [2 /*return*/]; | ||
} | ||
@@ -69,0 +73,0 @@ }); |
{ | ||
"name": "@serialized/serialized-client", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
32340
686