@serialized/serialized-client
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -9,3 +9,3 @@ import { AxiosInstance } from "axios"; | ||
save(aggregateRoot: AggregateRoot<any>, consistencyCheck?: boolean): Promise<any>; | ||
checkExists(aggregateType: string, aggregateId: string): Promise<any>; | ||
checkExists(aggregateRoot: AggregateRoot<any>): Promise<any>; | ||
} |
@@ -69,3 +69,4 @@ "use strict"; | ||
data = (_a.sent()).data; | ||
aggregateRoot.fromEvents(data); | ||
// @ts-ignore | ||
response.events.map(function (e) { return aggregateRoot['handle' + e.eventType](); }); | ||
return [2 /*return*/]; | ||
@@ -101,7 +102,7 @@ } | ||
}; | ||
AggregateClient.prototype.checkExists = function (aggregateType, aggregateId) { | ||
AggregateClient.prototype.checkExists = function (aggregateRoot) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.axiosClient.head("/aggregates/" + aggregateType + "/" + aggregateId + "/events", this.axiosConfig())]; | ||
case 0: return [4 /*yield*/, this.axiosClient.head("/aggregates/" + aggregateRoot.aggregateType + "/" + aggregateRoot.aggregateId + "/events", this.axiosConfig())]; | ||
case 1: return [2 /*return*/, (_a.sent()).data]; | ||
@@ -108,0 +109,0 @@ } |
@@ -15,6 +15,18 @@ import { AggregateClient } from "./aggregate-client"; | ||
constructor(config: SerializedConfig); | ||
static initializeFromEnvironment(): Serialized; | ||
static initialize(accessKey: string, secretAccessKey: string): Serialized; | ||
} | ||
declare var serialized: typeof Serialized; | ||
export = serialized; | ||
declare function createFromEnv(): Serialized; | ||
declare function create(accessKey: string, secretAccessKey: string): Serialized; | ||
declare const _default: { | ||
serialized: typeof Serialized; | ||
create: typeof create; | ||
createFromEnv: typeof createFromEnv; | ||
Event: { | ||
new (type: string, eventInitDict?: EventInit | undefined): Event; | ||
prototype: Event; | ||
readonly AT_TARGET: number; | ||
readonly BUBBLING_PHASE: number; | ||
readonly CAPTURING_PHASE: number; | ||
readonly NONE: number; | ||
}; | ||
}; | ||
export = _default; |
@@ -26,17 +26,17 @@ "use strict"; | ||
} | ||
Serialized.initializeFromEnvironment = function () { | ||
var accessKey = process.env.SERIALIZED_ACCESS_KEY; | ||
var secretAccessKey = process.env.SERIALIZED_SECRET_ACCESS_KEY; | ||
if (!accessKey || !secretAccessKey) { | ||
console.error('Environment variable SERIALIZED_ACCESS_KEY or SERIALIZED_SECRET_ACCESS_KEY is undefined.'); | ||
process.exit(1); | ||
} | ||
return new Serialized({ accessKey: accessKey, secretAccessKey: secretAccessKey }); | ||
}; | ||
Serialized.initialize = function (accessKey, secretAccessKey) { | ||
return new Serialized({ accessKey: accessKey, secretAccessKey: secretAccessKey }); | ||
}; | ||
return Serialized; | ||
}()); | ||
function createFromEnv() { | ||
var accessKey = process.env.SERIALIZED_ACCESS_KEY; | ||
var secretAccessKey = process.env.SERIALIZED_SECRET_ACCESS_KEY; | ||
if (!accessKey || !secretAccessKey) { | ||
console.error('Environment variable SERIALIZED_ACCESS_KEY or SERIALIZED_SECRET_ACCESS_KEY is undefined.'); | ||
process.exit(1); | ||
} | ||
return new Serialized({ accessKey: accessKey, secretAccessKey: secretAccessKey }); | ||
} | ||
function create(accessKey, secretAccessKey) { | ||
return new Serialized({ accessKey: accessKey, secretAccessKey: secretAccessKey }); | ||
} | ||
var serialized = Serialized; | ||
module.exports = serialized; | ||
module.exports = { serialized: serialized, create: create, createFromEnv: createFromEnv, Event: Event }; |
@@ -1,2 +0,2 @@ | ||
import { Event, LoadAggregateResponse } from "../types"; | ||
import { Event } from "../types"; | ||
export default abstract class AggregateRoot<T> { | ||
@@ -8,3 +8,2 @@ readonly aggregateId: string; | ||
constructor(aggregateId: string, aggregateType: string); | ||
fromEvents(response: LoadAggregateResponse): void; | ||
protected saveEvents(events: Event[]): void; | ||
@@ -11,0 +10,0 @@ getUncommittedEvents(): Event[]; |
@@ -10,8 +10,2 @@ "use strict"; | ||
} | ||
AggregateRoot.prototype.fromEvents = function (response) { | ||
var _this = this; | ||
this.currentVersion = response.aggregateVersion; | ||
// @ts-ignore | ||
response.events.map(function (e) { return _this['handle' + e.eventType](); }); | ||
}; | ||
AggregateRoot.prototype.saveEvents = function (events) { | ||
@@ -18,0 +12,0 @@ var _this = this; |
{ | ||
"name": "@serialized/serialized-client", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
32434
692