@boostercloud/framework-provider-azure 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -73,6 +73,7 @@ const Provider = (rockets) => ({
|
|
|
73
73
|
latestEntitySnapshot: events_adapter_1.readEntityLatestSnapshot.bind(null, cosmosClient),
|
|
74
74
|
search: events_searcher_adapter_1.searchEvents.bind(null, cosmosClient),
|
|
75
75
|
searchEntitiesIDs: events_searcher_adapter_1.searchEntitiesIds.bind(null, cosmosClient),
|
|
76
|
+
storeDispatched: events_adapter_1.storeDispatchedEvent.bind(null, cosmosClient),
|
|
76
77
|
},
|
|
77
78
|
// ProviderReadModelsLibrary
|
|
78
79
|
readModels: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CosmosClient } from '@azure/cosmos';
|
|
2
|
-
import {
|
|
2
|
+
import { BoosterConfig, EntitySnapshotEnvelope, EventEnvelope, NonPersistedEntitySnapshotEnvelope, NonPersistedEventEnvelope, UUID } from '@boostercloud/framework-types';
|
|
3
3
|
import { Context } from '@azure/functions';
|
|
4
4
|
export declare function rawEventsToEnvelopes(context: Context): Array<EventEnvelope>;
|
|
5
5
|
export declare function readEntityEventsSince(cosmosDb: CosmosClient, config: BoosterConfig, entityTypeName: string, entityID: UUID, since?: string): Promise<Array<EventEnvelope>>;
|
|
6
6
|
export declare function readEntityLatestSnapshot(cosmosDb: CosmosClient, config: BoosterConfig, entityTypeName: string, entityID: UUID): Promise<EntitySnapshotEnvelope | undefined>;
|
|
7
7
|
export declare function storeEvents(cosmosDb: CosmosClient, eventEnvelopes: Array<NonPersistedEventEnvelope>, config: BoosterConfig): Promise<Array<EventEnvelope>>;
|
|
8
8
|
export declare function storeSnapshot(cosmosDb: CosmosClient, snapshotEnvelope: NonPersistedEntitySnapshotEnvelope, config: BoosterConfig): Promise<EntitySnapshotEnvelope>;
|
|
9
|
+
export declare function storeDispatchedEvent(cosmosDb: CosmosClient, eventEnvelope: EventEnvelope, config: BoosterConfig): Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storeSnapshot = exports.storeEvents = exports.readEntityLatestSnapshot = exports.readEntityEventsSince = exports.rawEventsToEnvelopes = void 0;
|
|
3
|
+
exports.storeDispatchedEvent = exports.storeSnapshot = exports.storeEvents = exports.readEntityLatestSnapshot = exports.readEntityEventsSince = exports.rawEventsToEnvelopes = void 0;
|
|
4
4
|
const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const partition_keys_1 = require("./partition-keys");
|
|
@@ -138,3 +138,29 @@ async function storeSnapshot(cosmosDb, snapshotEnvelope, config) {
|
|
|
138
138
|
return persistableEntitySnapshot;
|
|
139
139
|
}
|
|
140
140
|
exports.storeSnapshot = storeSnapshot;
|
|
141
|
+
async function storeDispatchedEvent(cosmosDb, eventEnvelope, config) {
|
|
142
|
+
const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-adapter#storeDispatchedEvent');
|
|
143
|
+
logger.debug('[EventsAdapter#storeDispatchedEvent] Storing EventEnvelope for event with ID: ', eventEnvelope.id);
|
|
144
|
+
try {
|
|
145
|
+
await cosmosDb
|
|
146
|
+
.database(config.resourceNames.applicationStack)
|
|
147
|
+
.container(config.resourceNames.dispatchedEventsStore)
|
|
148
|
+
.items.create({
|
|
149
|
+
eventId: eventEnvelope.id,
|
|
150
|
+
});
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
if (e.code === 409) {
|
|
155
|
+
// If an item with the same ID already exists in the container, it will return a 409 status code.
|
|
156
|
+
// See https://learn.microsoft.com/en-us/rest/api/cosmos-db/http-status-codes-for-cosmosdb
|
|
157
|
+
logger.debug('[EventsAdapter#storeDispatchedEvent] Event has already been dispatched', eventEnvelope.id);
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
logger.error('[EventsAdapter#storeDispatchedEvent] Error storing dispatched event', e);
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.storeDispatchedEvent = storeDispatchedEvent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boostercloud/framework-provider-azure",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Handle Booster's integration with Azure",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework-provider-azure"
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"@azure/functions": "^1.2.2",
|
|
28
28
|
"@azure/identity": "~2.1.0",
|
|
29
29
|
"@azure/event-hubs": "5.11.1",
|
|
30
|
-
"@boostercloud/framework-common-helpers": "^2.
|
|
31
|
-
"@boostercloud/framework-types": "^2.
|
|
30
|
+
"@boostercloud/framework-common-helpers": "^2.8.0",
|
|
31
|
+
"@boostercloud/framework-types": "^2.8.0",
|
|
32
32
|
"tslib": "^2.4.0",
|
|
33
33
|
"@effect-ts/core": "^0.60.4",
|
|
34
34
|
"@azure/web-pubsub": "~1.1.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@boostercloud/eslint-config": "^2.
|
|
37
|
+
"@boostercloud/eslint-config": "^2.8.0",
|
|
38
38
|
"@types/chai": "4.2.18",
|
|
39
39
|
"@types/chai-as-promised": "7.1.4",
|
|
40
40
|
"@types/faker": "5.1.5",
|