@serialized/serialized-client
Advanced tools
Comparing version 6.2.0 to 7.0.0
@@ -17,17 +17,21 @@ import { BaseClient, DomainEvent } from './'; | ||
} | ||
export interface AggregateBulkRequest { | ||
export interface BulkSaveRequest { | ||
tenantId?: string; | ||
batches: EventBatch[]; | ||
} | ||
export interface CreateAggregateOptions { | ||
export interface BulkUpdateRequest { | ||
tenantId?: string; | ||
aggregateIds: string[]; | ||
} | ||
export interface UpdateAggregateOptions { | ||
export interface UpdateAggregateRequest { | ||
aggregateId: AggregateId; | ||
tenantId?: string; | ||
useOptimisticConcurrency?: boolean; | ||
} | ||
export interface CheckAggregateExistsOptions { | ||
export interface CreateAggregateRequest { | ||
aggregateId: AggregateId; | ||
tenantId?: string; | ||
} | ||
export interface LoadAggregateOptions { | ||
export interface LoadAggregateRequest { | ||
aggregateId: AggregateId; | ||
tenantId?: string; | ||
@@ -45,2 +49,3 @@ since?: number; | ||
aggregateId: AggregateId; | ||
tenantId?: string; | ||
} | ||
@@ -71,11 +76,11 @@ export interface DeleteAggregateOptions { | ||
constructor(aggregateTypeConstructor: any, serializedConfig: any, aggregateClientConfig?: AggregatesClientConfig); | ||
exists(request: CheckAggregateExistsRequest, options?: CheckAggregateExistsOptions): Promise<boolean>; | ||
save(request: AggregateRequest): Promise<number>; | ||
saveBulk(request: AggregateBulkRequest): Promise<number>; | ||
update(aggregateId: string, commandHandler: (s: any) => DomainEvent<any>[], options?: UpdateAggregateOptions): Promise<number>; | ||
bulkUpdate(aggregateIds: string[], commandHandler: (s: any) => DomainEvent<any>[], tenantId?: string): Promise<number>; | ||
update(request: UpdateAggregateRequest, commandHandler: (s: any) => DomainEvent<any>[]): Promise<number>; | ||
saveBulk(request: BulkSaveRequest): Promise<number>; | ||
bulkUpdate(request: BulkUpdateRequest, commandHandler: (s: any) => DomainEvent<any>[]): Promise<number>; | ||
bulkSave(batches: EventBatch[], tenantId?: string): Promise<number>; | ||
create(aggregateId: string, commandHandler: (s: any) => DomainEvent<any>[], options?: CreateAggregateOptions): Promise<number>; | ||
create(request: CreateAggregateRequest, commandHandler: (s: any) => DomainEvent<any>[]): Promise<number>; | ||
exists(request: CheckAggregateExistsRequest): Promise<boolean>; | ||
delete(options?: DeleteAggregateOptions): Promise<DeleteToken>; | ||
private loadInternal; | ||
delete(options?: DeleteAggregateOptions): Promise<DeleteToken>; | ||
confirmDelete(options: ConfirmDeleteAggregateOptions): Promise<void>; | ||
@@ -82,0 +87,0 @@ private saveBulkInternal; |
@@ -73,27 +73,2 @@ "use strict"; | ||
} | ||
AggregatesClient.prototype.exists = function (request, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, error_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = AggregatesClient.aggregateUrlPath(this.aggregateType, request.aggregateId); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.axiosClient.head(url, this.axiosConfig(options === null || options === void 0 ? void 0 : options.tenantId))]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, true]; | ||
case 3: | ||
error_2 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_2) && error_2.statusCode === 404) { | ||
return [2 /*return*/, false]; | ||
} | ||
throw error_2; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AggregatesClient.prototype.save = function (request) { | ||
@@ -112,18 +87,5 @@ return __awaiter(this, void 0, void 0, function () { | ||
}; | ||
AggregatesClient.prototype.saveBulk = function (request) { | ||
AggregatesClient.prototype.update = function (request, commandHandler) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var batches, tenantId; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
batches = request.batches, tenantId = request.tenantId; | ||
return [4 /*yield*/, this.saveBulkInternal(batches, tenantId)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AggregatesClient.prototype.update = function (aggregateId, commandHandler, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tenantId, error_3; | ||
var tenantId, error_2; | ||
var _this = this; | ||
@@ -133,3 +95,3 @@ return __generator(this, function (_a) { | ||
case 0: | ||
tenantId = options === null || options === void 0 ? void 0 : options.tenantId; | ||
tenantId = request === null || request === void 0 ? void 0 : request.tenantId; | ||
_a.label = 1; | ||
@@ -142,3 +104,3 @@ case 1: | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.loadInternal(aggregateId, options)]; | ||
case 0: return [4 /*yield*/, this.loadInternal(request)]; | ||
case 1: | ||
@@ -149,5 +111,5 @@ response = _a.sent(); | ||
return [4 /*yield*/, this.saveInternal({ | ||
aggregateId: aggregateId, | ||
aggregateId: request.aggregateId, | ||
events: eventsToSave, | ||
expectedVersion: (options === null || options === void 0 ? void 0 : options.useOptimisticConcurrency) === false ? undefined : currentVersion | ||
expectedVersion: (request === null || request === void 0 ? void 0 : request.useOptimisticConcurrency) === false ? undefined : currentVersion | ||
}, tenantId)]; | ||
@@ -160,9 +122,9 @@ case 2: return [2 /*return*/, _a.sent()]; | ||
case 3: | ||
error_3 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_3)) { | ||
if (error_3.statusCode === 409) { | ||
throw new error_1.Conflict(this.aggregateType, aggregateId); | ||
error_2 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_2)) { | ||
if (error_2.statusCode === 409) { | ||
throw new error_1.Conflict(this.aggregateType, request.aggregateId); | ||
} | ||
} | ||
throw error_3; | ||
throw error_2; | ||
case 4: return [2 /*return*/]; | ||
@@ -173,5 +135,18 @@ } | ||
}; | ||
AggregatesClient.prototype.bulkUpdate = function (aggregateIds, commandHandler, tenantId) { | ||
AggregatesClient.prototype.saveBulk = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_4; | ||
var batches, tenantId; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
batches = request.batches, tenantId = request.tenantId; | ||
return [4 /*yield*/, this.saveBulkInternal(batches, tenantId)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AggregatesClient.prototype.bulkUpdate = function (request, commandHandler) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_3; | ||
var _this = this; | ||
@@ -183,24 +158,24 @@ return __generator(this, function (_a) { | ||
return [4 /*yield*/, this.aggregateClientConfig.retryStrategy.executeWithRetries(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var batches, _i, aggregateIds_1, aggregateId, response, currentVersion, eventsToSave; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var batches, _i, _a, aggregateId, response, currentVersion, eventsToSave; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
batches = []; | ||
_i = 0, aggregateIds_1 = aggregateIds; | ||
_a.label = 1; | ||
_i = 0, _a = request.aggregateIds; | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < aggregateIds_1.length)) return [3 /*break*/, 4]; | ||
aggregateId = aggregateIds_1[_i]; | ||
return [4 /*yield*/, this.loadInternal(aggregateId)]; | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
aggregateId = _a[_i]; | ||
return [4 /*yield*/, this.loadInternal({ aggregateId: aggregateId })]; | ||
case 2: | ||
response = _a.sent(); | ||
response = _b.sent(); | ||
currentVersion = response.metadata.version; | ||
eventsToSave = commandHandler(response.aggregate); | ||
batches.push({ events: eventsToSave, expectedVersion: currentVersion }); | ||
_a.label = 3; | ||
_b.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [4 /*yield*/, this.saveBulkInternal(batches, tenantId)]; | ||
case 5: return [2 /*return*/, _a.sent()]; | ||
case 4: return [4 /*yield*/, this.saveBulkInternal(batches, request.tenantId)]; | ||
case 5: return [2 /*return*/, _b.sent()]; | ||
} | ||
@@ -211,9 +186,9 @@ }); | ||
case 2: | ||
error_4 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_4)) { | ||
if (error_4.statusCode === 409) { | ||
error_3 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_3)) { | ||
if (error_3.statusCode === 409) { | ||
throw new error_1.Conflict(this.aggregateType); | ||
} | ||
} | ||
throw error_4; | ||
throw error_3; | ||
case 3: return [2 /*return*/]; | ||
@@ -226,3 +201,3 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_5; | ||
var error_4; | ||
var _this = this; | ||
@@ -251,9 +226,9 @@ return __generator(this, function (_a) { | ||
case 2: | ||
error_5 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_5)) { | ||
if (error_5.statusCode === 409) { | ||
error_4 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_4)) { | ||
if (error_4.statusCode === 409) { | ||
throw new error_1.Conflict(this.aggregateType); | ||
} | ||
} | ||
throw error_5; | ||
throw error_4; | ||
case 3: return [2 /*return*/]; | ||
@@ -264,5 +239,5 @@ } | ||
}; | ||
AggregatesClient.prototype.create = function (aggregateId, commandHandler, options) { | ||
AggregatesClient.prototype.create = function (request, commandHandler) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var aggregate, eventsToSave, tenantId, error_6; | ||
var aggregate, eventsToSave, tenantId, aggregateId, error_5; | ||
var _this = this; | ||
@@ -274,3 +249,4 @@ return __generator(this, function (_a) { | ||
eventsToSave = commandHandler(aggregate); | ||
tenantId = options === null || options === void 0 ? void 0 : options.tenantId; | ||
tenantId = request === null || request === void 0 ? void 0 : request.tenantId; | ||
aggregateId = request.aggregateId; | ||
_a.label = 1; | ||
@@ -289,8 +265,33 @@ case 1: | ||
case 3: | ||
error_6 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_6)) { | ||
if (error_6.statusCode === 409) { | ||
error_5 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_5)) { | ||
if (error_5.statusCode === 409) { | ||
throw new error_1.Conflict(this.aggregateType, aggregateId); | ||
} | ||
} | ||
throw error_5; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AggregatesClient.prototype.exists = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, error_6; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = AggregatesClient.aggregateUrlPath(this.aggregateType, request.aggregateId); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.axiosClient.head(url, this.axiosConfig(request.tenantId))]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, true]; | ||
case 3: | ||
error_6 = _a.sent(); | ||
if ((0, error_1.isSerializedApiError)(error_6) && error_6.statusCode === 404) { | ||
return [2 /*return*/, false]; | ||
} | ||
throw error_6; | ||
@@ -302,4 +303,22 @@ case 4: return [2 /*return*/]; | ||
}; | ||
AggregatesClient.prototype.loadInternal = function (aggregateId, options) { | ||
AggregatesClient.prototype.delete = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var config, url, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
url = (options === null || options === void 0 ? void 0 : options.aggregateId) ? | ||
"".concat(AggregatesClient.aggregateUrlPath(this.aggregateType, options.aggregateId)) : | ||
"".concat(AggregatesClient.aggregateTypeUrlPath(this.aggregateType)); | ||
return [4 /*yield*/, this.axiosClient.delete(url, config)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AggregatesClient.prototype.loadInternal = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, config, limit, since, queryParams, events, response, axiosResponse, currentState, aggregate, metadata; | ||
@@ -309,6 +328,6 @@ return __generator(this, function (_a) { | ||
case 0: | ||
url = "".concat(AggregatesClient.aggregateUrlPath(this.aggregateType, aggregateId)); | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
limit = options && options.limit ? options.limit : 1000; | ||
since = options && options.since ? options.since : 0; | ||
url = "".concat(AggregatesClient.aggregateUrlPath(this.aggregateType, request.aggregateId)); | ||
config = request.tenantId ? this.axiosConfig(request.tenantId) : this.axiosConfig(); | ||
limit = request.limit ? request.limit : 1000; | ||
since = request.since ? request.since : 0; | ||
queryParams = new URLSearchParams(); | ||
@@ -338,3 +357,3 @@ queryParams.set('since', String(since)); | ||
aggregate._metadata = metadata; | ||
console.log("Loaded aggregate ".concat(this.aggregateType, "@").concat(aggregateId, ":").concat(metadata.version)); | ||
console.log("Loaded aggregate ".concat(this.aggregateType, "@").concat(request.aggregateId, ":").concat(metadata.version)); | ||
return [2 /*return*/, { aggregate: aggregate, metadata: metadata }]; | ||
@@ -345,20 +364,2 @@ } | ||
}; | ||
AggregatesClient.prototype.delete = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var config, url, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
url = (options === null || options === void 0 ? void 0 : options.aggregateId) ? | ||
"".concat(AggregatesClient.aggregateUrlPath(this.aggregateType, options.aggregateId)) : | ||
"".concat(AggregatesClient.aggregateTypeUrlPath(this.aggregateType)); | ||
return [4 /*yield*/, this.axiosClient.delete(url, config)]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.data]; | ||
} | ||
}); | ||
}); | ||
}; | ||
AggregatesClient.prototype.confirmDelete = function (options) { | ||
@@ -365,0 +366,0 @@ return __awaiter(this, void 0, void 0, function () { |
@@ -8,13 +8,2 @@ import { BaseClient } from "./"; | ||
} | ||
export interface LoadFeedOptions { | ||
tenantId?: string; | ||
since?: number; | ||
limit?: number; | ||
from?: string; | ||
to?: string; | ||
waitTime?: number; | ||
types?: string[]; | ||
partitionNumber?: number; | ||
partitionCount?: number; | ||
} | ||
export interface FeedEntry { | ||
@@ -41,17 +30,38 @@ sequenceNumber: number; | ||
} | ||
export interface FeedRequest { | ||
export interface LoadFeedRequest { | ||
feedName: string; | ||
tenantId?: string; | ||
since?: number; | ||
limit?: number; | ||
from?: string; | ||
to?: string; | ||
waitTime?: number; | ||
types?: string[]; | ||
partitionNumber?: number; | ||
partitionCount?: number; | ||
} | ||
export interface LoadFeedRequest extends FeedRequest { | ||
export interface LoadAllFeedRequest { | ||
tenantId?: string; | ||
since?: number; | ||
limit?: number; | ||
from?: string; | ||
to?: string; | ||
waitTime?: number; | ||
types?: string[]; | ||
partitionNumber?: number; | ||
partitionCount?: number; | ||
} | ||
export interface LoadAllFeedRequest { | ||
export interface GetCurrentSequenceNumberRequest { | ||
feedName: string; | ||
options?: LoadFeedOptions; | ||
tenantId?: string; | ||
} | ||
export interface GetGlobalSequenceNumberRequest { | ||
tenantId?: string; | ||
} | ||
export declare class FeedsClient extends BaseClient { | ||
loadOverview(): Promise<LoadFeedsOverviewResponse>; | ||
loadFeed(request: LoadFeedRequest, options?: LoadFeedOptions): Promise<LoadFeedResponse>; | ||
loadFeed(request: LoadFeedRequest): Promise<LoadFeedResponse>; | ||
loadAllFeed(request: LoadAllFeedRequest): Promise<LoadFeedResponse>; | ||
getCurrentSequenceNumber(request: FeedRequest): Promise<number>; | ||
getGlobalSequenceNumber(): Promise<number>; | ||
getCurrentSequenceNumber(request: GetCurrentSequenceNumberRequest): Promise<number>; | ||
getGlobalSequenceNumber(request: GetGlobalSequenceNumberRequest): Promise<number>; | ||
static feedsUrl(): string; | ||
@@ -58,0 +68,0 @@ static allFeedUrl(): string; |
@@ -17,2 +17,13 @@ "use strict"; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -72,3 +83,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
FeedsClient.prototype.loadFeed = function (request, options) { | ||
FeedsClient.prototype.loadFeed = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -81,33 +92,31 @@ var config, params; | ||
params = new URLSearchParams(); | ||
if (options) { | ||
if (options.tenantId !== undefined) { | ||
config = this.axiosConfig(options.tenantId); | ||
} | ||
if (options.limit !== undefined) { | ||
params.set('limit', String(options.limit)); | ||
} | ||
if (options.since !== undefined) { | ||
params.set('since', String(options.since)); | ||
} | ||
if (options.from !== undefined) { | ||
params.set('from', String(options.from)); | ||
} | ||
if (options.to !== undefined) { | ||
params.set('to', String(options.to)); | ||
} | ||
if (options.waitTime !== undefined) { | ||
params.set('waitTime', String(options.waitTime)); | ||
} | ||
if (options.partitionNumber !== undefined) { | ||
params.set('partitionNumber', String(options.partitionNumber)); | ||
} | ||
if (options.partitionCount !== undefined) { | ||
params.set('partitionCount', String(options.partitionCount)); | ||
} | ||
if (options.types) { | ||
options.types.forEach(function (type) { | ||
params.append('filterType', type); | ||
}); | ||
} | ||
if (request.tenantId !== undefined) { | ||
config = this.axiosConfig(request.tenantId); | ||
} | ||
if (request.limit !== undefined) { | ||
params.set('limit', String(request.limit)); | ||
} | ||
if (request.since !== undefined) { | ||
params.set('since', String(request.since)); | ||
} | ||
if (request.from !== undefined) { | ||
params.set('from', String(request.from)); | ||
} | ||
if (request.to !== undefined) { | ||
params.set('to', String(request.to)); | ||
} | ||
if (request.waitTime !== undefined) { | ||
params.set('waitTime', String(request.waitTime)); | ||
} | ||
if (request.partitionNumber !== undefined) { | ||
params.set('partitionNumber', String(request.partitionNumber)); | ||
} | ||
if (request.partitionCount !== undefined) { | ||
params.set('partitionCount', String(request.partitionCount)); | ||
} | ||
if (request.types) { | ||
request.types.forEach(function (type) { | ||
params.append('filterType', type); | ||
}); | ||
} | ||
config.params = params; | ||
@@ -122,10 +131,6 @@ return [4 /*yield*/, this.axiosClient.get(FeedsClient.feedUrl(request.feedName), config)]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var config; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
config = this.axiosConfig(); | ||
config.params = request.options; | ||
return [4 /*yield*/, this.axiosClient.get(FeedsClient.allFeedUrl(), config)]; | ||
case 1: return [2 /*return*/, (_a.sent()).data]; | ||
case 0: return [4 /*yield*/, this.loadFeed(__assign({ feedName: '_all' }, { request: request }))]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
@@ -148,3 +153,3 @@ }); | ||
}; | ||
FeedsClient.prototype.getGlobalSequenceNumber = function () { | ||
FeedsClient.prototype.getGlobalSequenceNumber = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -151,0 +156,0 @@ var headers; |
import { BaseClient } from "./"; | ||
import { UnauthorizedError } from "./error"; | ||
export declare type ProjectionSort = 'projectionId' | 'reference' | 'createdAt' | 'updatedAt' | '-projectionId' | '-reference' | '-createdAt' | '-updatedAt' | '+projectionId' | '+reference' | '+createdAt' | '+updatedAt'; | ||
export interface ListSingleProjectionOptions { | ||
reference?: string; | ||
from?: string; | ||
to?: string; | ||
tenantId?: string; | ||
sort?: ProjectionSort; | ||
skip?: number; | ||
limit?: number; | ||
id?: string[]; | ||
} | ||
export interface DeleteProjectionOptions { | ||
tenantId?: string; | ||
} | ||
export interface GetSingleProjectionOptions { | ||
tenantId?: string; | ||
awaitCreation?: number; | ||
} | ||
export interface GetSingleProjectionResponse { | ||
@@ -34,2 +17,3 @@ projectionId: string; | ||
projectionName: string; | ||
tenantId?: string; | ||
} | ||
@@ -45,5 +29,2 @@ export interface GetAggregatedProjectionResponse { | ||
} | ||
export interface RecreateAggregatedProjectionRequest { | ||
projectionName: string; | ||
} | ||
export interface CustomProjectionHandler { | ||
@@ -87,5 +68,2 @@ eventType: string; | ||
} | ||
export interface RecreateSingleProjectionsRequest { | ||
projectionName: string; | ||
} | ||
export interface ListSingleProjectionsResponse { | ||
@@ -99,10 +77,18 @@ projections: GetSingleProjectionResponse[]; | ||
projectionId: string; | ||
tenantId?: string; | ||
awaitCreation?: number; | ||
} | ||
export interface ListSingleProjectionRequest { | ||
projectionName: string; | ||
reference?: string; | ||
from?: string; | ||
to?: string; | ||
tenantId?: string; | ||
sort?: ProjectionSort; | ||
skip?: number; | ||
limit?: number; | ||
ids?: string[]; | ||
} | ||
export interface CountSingleProjectionRequest { | ||
projectionName: string; | ||
} | ||
export interface CountSingleProjectionOptions { | ||
tenantId?: string; | ||
@@ -119,9 +105,7 @@ } | ||
getProjectionDefinition(request: GetProjectionDefinitionRequest): Promise<LoadProjectionDefinitionResponse>; | ||
getSingleProjection(request: GetSingleProjectionRequest, options?: GetSingleProjectionOptions): Promise<GetSingleProjectionResponse>; | ||
getSingleProjection(request: GetSingleProjectionRequest): Promise<GetSingleProjectionResponse>; | ||
getAggregatedProjection(request: GetAggregatedProjectionRequest): Promise<GetAggregatedProjectionResponse>; | ||
deleteProjections(request: DeleteProjectionsRequest, options?: DeleteProjectionOptions): Promise<void>; | ||
listSingleProjections(request: ListSingleProjectionRequest, options?: ListSingleProjectionOptions): Promise<ListSingleProjectionsResponse>; | ||
countSingleProjections(request: CountSingleProjectionRequest, options?: CountSingleProjectionOptions): Promise<number>; | ||
recreateSingleProjections(request: RecreateSingleProjectionsRequest, options?: DeleteProjectionOptions): Promise<void>; | ||
recreateAggregatedProjection(request: RecreateAggregatedProjectionRequest, options?: DeleteProjectionOptions): Promise<void>; | ||
delete(request: DeleteProjectionsRequest): Promise<void>; | ||
listSingleProjections(request: ListSingleProjectionRequest): Promise<ListSingleProjectionsResponse>; | ||
countSingleProjections(request: CountSingleProjectionRequest): Promise<number>; | ||
private handleApiError; | ||
@@ -128,0 +112,0 @@ private handleAxiosError; |
@@ -157,3 +157,3 @@ "use strict"; | ||
}; | ||
ProjectionsClient.prototype.getSingleProjection = function (request, options) { | ||
ProjectionsClient.prototype.getSingleProjection = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -170,10 +170,8 @@ var url, config, params, error_2; | ||
params = new URLSearchParams(); | ||
if (options) { | ||
if (options.tenantId !== undefined) { | ||
config = this.axiosConfig(options.tenantId); | ||
} | ||
if (options.awaitCreation !== undefined) { | ||
params.set('awaitCreation', String(options.awaitCreation)); | ||
} | ||
if (request.tenantId !== undefined) { | ||
config = this.axiosConfig(request.tenantId); | ||
} | ||
if (request.awaitCreation !== undefined) { | ||
params.set('awaitCreation', String(request.awaitCreation)); | ||
} | ||
config.params = params; | ||
@@ -210,3 +208,3 @@ return [4 /*yield*/, this.axiosClient.get(url, config)]; | ||
}; | ||
ProjectionsClient.prototype.deleteProjections = function (request, options) { | ||
ProjectionsClient.prototype.delete = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -226,3 +224,3 @@ var url, config, error_4; | ||
_a.trys.push([1, 3, , 4]); | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
config = request && request.tenantId ? this.axiosConfig(request.tenantId) : this.axiosConfig(); | ||
config.params = new URLSearchParams(); | ||
@@ -241,3 +239,3 @@ return [4 /*yield*/, this.axiosClient.delete(url, config)]; | ||
}; | ||
ProjectionsClient.prototype.listSingleProjections = function (request, options) { | ||
ProjectionsClient.prototype.listSingleProjections = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -254,30 +252,28 @@ var url, config, params_1, error_5; | ||
params_1 = new URLSearchParams(); | ||
if (options) { | ||
if (options.tenantId !== undefined) { | ||
config = this.axiosConfig(options.tenantId); | ||
} | ||
if (options.limit !== undefined) { | ||
params_1.set('limit', options.limit.toString()); | ||
} | ||
if (options.reference !== undefined) { | ||
params_1.set('reference', options.reference); | ||
} | ||
if (options.from !== undefined) { | ||
params_1.set('from', options.from); | ||
} | ||
if (options.to !== undefined) { | ||
params_1.set('to', options.to); | ||
} | ||
if (options.skip !== undefined) { | ||
params_1.set('skip', options.skip.toString()); | ||
} | ||
if (options.sort !== undefined) { | ||
params_1.set('sort', options.sort); | ||
} | ||
if (options.id !== undefined) { | ||
options.id.forEach(function (id) { | ||
params_1.append('id', id); | ||
}); | ||
} | ||
if (request.tenantId !== undefined) { | ||
config = this.axiosConfig(request.tenantId); | ||
} | ||
if (request.limit !== undefined) { | ||
params_1.set('limit', request.limit.toString()); | ||
} | ||
if (request.reference !== undefined) { | ||
params_1.set('reference', request.reference); | ||
} | ||
if (request.from !== undefined) { | ||
params_1.set('from', request.from); | ||
} | ||
if (request.to !== undefined) { | ||
params_1.set('to', request.to); | ||
} | ||
if (request.skip !== undefined) { | ||
params_1.set('skip', request.skip.toString()); | ||
} | ||
if (request.sort !== undefined) { | ||
params_1.set('sort', request.sort); | ||
} | ||
if (request.ids !== undefined) { | ||
request.ids.forEach(function (id) { | ||
params_1.append('id', id); | ||
}); | ||
} | ||
config.params = params_1; | ||
@@ -294,3 +290,3 @@ return [4 /*yield*/, this.axiosClient.get(url, config)]; | ||
}; | ||
ProjectionsClient.prototype.countSingleProjections = function (request, options) { | ||
ProjectionsClient.prototype.countSingleProjections = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -305,3 +301,3 @@ var url, config, data, error_6; | ||
_a.trys.push([1, 3, , 4]); | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
config = request.tenantId ? this.axiosConfig(request.tenantId) : this.axiosConfig(); | ||
return [4 /*yield*/, this.axiosClient.get(url, config)]; | ||
@@ -319,32 +315,2 @@ case 2: | ||
}; | ||
ProjectionsClient.prototype.recreateSingleProjections = function (request, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.deleteProjections({ | ||
projectionType: ProjectionType.SINGLE, | ||
projectionName: request.projectionName | ||
}, options)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ProjectionsClient.prototype.recreateAggregatedProjection = function (request, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.deleteProjections({ | ||
projectionType: ProjectionType.AGGREGATED, | ||
projectionName: request.projectionName | ||
}, options)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ProjectionsClient.prototype.handleApiError = function (err, request) { | ||
@@ -351,0 +317,0 @@ if ((0, error_1.isSerializedApiError)(err)) { |
@@ -48,7 +48,9 @@ import { BaseClient } from "./"; | ||
reactionId: string; | ||
tenantId?: string; | ||
} | ||
export interface ExecuteReactionRequest { | ||
reactionId: string; | ||
tenantId?: string; | ||
} | ||
export interface ListReactionsOptions { | ||
export interface ListReactionsRequest { | ||
tenantId?: string; | ||
@@ -59,8 +61,2 @@ status?: string; | ||
} | ||
export interface ExecuteReactionOptions { | ||
tenantId?: string; | ||
} | ||
export interface DeleteReactionOptions { | ||
tenantId?: string; | ||
} | ||
export interface CreateReactionDefinitionRequest { | ||
@@ -100,5 +96,5 @@ reactionName: string; | ||
deleteDefinition(request: DeleteReactionDefinitionRequest): Promise<void>; | ||
listReactions(options?: ListReactionsOptions): Promise<ListReactionsResponse>; | ||
deleteReaction(request: DeleteReactionRequest, options?: DeleteReactionOptions): Promise<void>; | ||
executeReaction(request: ExecuteReactionRequest, options?: ExecuteReactionOptions): Promise<void>; | ||
listReactions(request?: ListReactionsRequest): Promise<ListReactionsResponse>; | ||
deleteReaction(request: DeleteReactionRequest): Promise<void>; | ||
executeReaction(request: ExecuteReactionRequest): Promise<void>; | ||
static reactionDefinitionsUrl(): string; | ||
@@ -105,0 +101,0 @@ static reactionDefinitionUrl(reactionName: string): string; |
@@ -139,3 +139,3 @@ "use strict"; | ||
; | ||
ReactionsClient.prototype.listReactions = function (options) { | ||
ReactionsClient.prototype.listReactions = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -146,12 +146,12 @@ var config; | ||
case 0: | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
config = request && request.tenantId ? this.axiosConfig(request.tenantId) : this.axiosConfig(); | ||
config.params = new URLSearchParams(); | ||
if (options.status !== undefined) { | ||
config.params.set('status', options.status); | ||
if (request.status !== undefined) { | ||
config.params.set('status', request.status); | ||
} | ||
if (options.skip !== undefined) { | ||
config.params.set('skip', options.skip.toString()); | ||
if (request.skip !== undefined) { | ||
config.params.set('skip', request.skip.toString()); | ||
} | ||
if (options.limit !== undefined) { | ||
config.params.set('limit', options.limit.toString()); | ||
if (request.limit !== undefined) { | ||
config.params.set('limit', request.limit.toString()); | ||
} | ||
@@ -165,3 +165,3 @@ return [4 /*yield*/, this.axiosClient.get(ReactionsClient.reactionsUrl(), config)]; | ||
; | ||
ReactionsClient.prototype.deleteReaction = function (request, options) { | ||
ReactionsClient.prototype.deleteReaction = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -172,3 +172,3 @@ var config; | ||
case 0: | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
config = request.tenantId ? this.axiosConfig(request.tenantId) : this.axiosConfig(); | ||
config.params = new URLSearchParams(); | ||
@@ -184,3 +184,3 @@ return [4 /*yield*/, this.axiosClient.delete(ReactionsClient.reactionUrl(request.reactionId), config)]; | ||
; | ||
ReactionsClient.prototype.executeReaction = function (request, options) { | ||
ReactionsClient.prototype.executeReaction = function (request) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -191,3 +191,3 @@ var config; | ||
case 0: | ||
config = options && options.tenantId ? this.axiosConfig(options.tenantId) : this.axiosConfig(); | ||
config = request.tenantId ? this.axiosConfig(request.tenantId) : this.axiosConfig(); | ||
config.params = new URLSearchParams(); | ||
@@ -194,0 +194,0 @@ return [4 /*yield*/, this.axiosClient.post(ReactionsClient.reactionExecutionUrl(request.reactionId), '', config)]; |
@@ -7,7 +7,7 @@ import { BaseClient } from "./"; | ||
tenantId: string; | ||
reference: string; | ||
reference?: string; | ||
} | ||
export interface AddTenantRequest { | ||
tenantId: string; | ||
reference: string; | ||
reference?: string; | ||
} | ||
@@ -14,0 +14,0 @@ export declare class TenantClient extends BaseClient { |
@@ -6,3 +6,3 @@ { | ||
"author": "Serialized", | ||
"version": "6.2.0", | ||
"version": "7.0.0", | ||
"main": "dist/index.js", | ||
@@ -9,0 +9,0 @@ "types": "dist/index.d.ts", |
121020
2570