@boostercloud/framework-provider-azure 3.0.0 → 3.1.1

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.search = exports.replaceOrDeleteItem = void 0;
3
+ exports.replaceOrDeleteItem = replaceOrDeleteItem;
4
+ exports.search = search;
4
5
  const framework_types_1 = require("@boostercloud/framework-types");
5
6
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
6
7
  async function replaceOrDeleteItem(cosmosDb, container, config, id, partitionKey, newValue) {
@@ -15,7 +16,6 @@ async function replaceOrDeleteItem(cosmosDb, container, config, id, partitionKey
15
16
  await cosmosDb.database(config.resourceNames.applicationStack).container(container).item(id, partitionKey).delete();
16
17
  }
17
18
  }
18
- exports.replaceOrDeleteItem = replaceOrDeleteItem;
19
19
  async function search(cosmosDb, config, containerName, filters, limit, afterCursor, paginatedVersion = false, order, projections = '*') {
20
20
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'query-helper#search');
21
21
  const filterExpression = buildFilterExpression(filters);
@@ -60,7 +60,6 @@ async function search(cosmosDb, config, containerName, filters, limit, afterCurs
60
60
  return resources !== null && resources !== void 0 ? resources : [];
61
61
  }
62
62
  }
63
- exports.search = search;
64
63
  function buildFilterExpression(filters, usedPlaceholders = []) {
65
64
  return Object.entries(filters)
66
65
  .map(([propName, filter]) => {
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Provider = exports.loadInfrastructurePackage = void 0;
4
+ exports.Provider = void 0;
5
+ exports.loadInfrastructurePackage = loadInfrastructurePackage;
5
6
  const tslib_1 = require("tslib");
6
7
  const api_adapter_1 = require("./library/api-adapter");
7
8
  const graphql_adapter_1 = require("./library/graphql-adapter");
@@ -61,7 +62,6 @@ else {
61
62
  function loadInfrastructurePackage(packageName) {
62
63
  return require(packageName);
63
64
  }
64
- exports.loadInfrastructurePackage = loadInfrastructurePackage;
65
65
  const Provider = (rockets) => ({
66
66
  // ProviderEventsLibrary
67
67
  events: {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requestFailed = exports.requestSucceeded = void 0;
3
+ exports.requestSucceeded = requestSucceeded;
4
+ exports.requestFailed = requestFailed;
4
5
  const framework_types_1 = require("@boostercloud/framework-types");
5
6
  const WEB_SOCKET_PROTOCOL_HEADER = 'Sec-WebSocket-Protocol';
6
7
  async function requestSucceeded(body, headers) {
@@ -23,7 +24,6 @@ async function requestSucceeded(body, headers) {
23
24
  ...extraParams,
24
25
  };
25
26
  }
26
- exports.requestSucceeded = requestSucceeded;
27
27
  async function requestFailed(error) {
28
28
  const status = (0, framework_types_1.httpStatusCodeFor)(error);
29
29
  return {
@@ -39,4 +39,3 @@ async function requestFailed(error) {
39
39
  }),
40
40
  };
41
41
  }
42
- exports.requestFailed = requestFailed;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendMessageToConnection = exports.deleteConnectionData = exports.fetchConnectionData = exports.storeConnectionData = void 0;
3
+ exports.storeConnectionData = storeConnectionData;
4
+ exports.fetchConnectionData = fetchConnectionData;
5
+ exports.deleteConnectionData = deleteConnectionData;
6
+ exports.sendMessageToConnection = sendMessageToConnection;
4
7
  const constants_1 = require("../constants");
5
8
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
6
9
  const web_pubsub_1 = require("@azure/web-pubsub");
@@ -15,7 +18,6 @@ async function storeConnectionData(cosmosDb, config, connectionID, data) {
15
18
  ttl: ttl,
16
19
  });
17
20
  }
18
- exports.storeConnectionData = storeConnectionData;
19
21
  async function fetchConnectionData(cosmosDb, config, connectionID) {
20
22
  const { resources } = await cosmosDb
21
23
  .database(config.resourceNames.applicationStack)
@@ -34,7 +36,6 @@ async function fetchConnectionData(cosmosDb, config, connectionID) {
34
36
  .fetchAll();
35
37
  return resources[0];
36
38
  }
37
- exports.fetchConnectionData = fetchConnectionData;
38
39
  async function deleteConnectionData(cosmosDb, config, connectionID) {
39
40
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'connections-adapter#deleteConnectionData');
40
41
  const { resources } = await cosmosDb
@@ -65,11 +66,9 @@ async function deleteConnectionData(cosmosDb, config, connectionID) {
65
66
  .item(connectionsToDelete.id, connectionsToDelete[constants_1.connectionsStoreAttributes.partitionKey])
66
67
  .delete();
67
68
  }
68
- exports.deleteConnectionData = deleteConnectionData;
69
69
  async function sendMessageToConnection(config, connectionID, data) {
70
70
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'connection-adapter#sendMessageToConnection');
71
71
  logger.debug(`Sending message ${JSON.stringify(data)} to connection ${connectionID}`);
72
72
  const serviceClient = new web_pubsub_1.WebPubSubServiceClient(process.env.WebPubSubConnectionString, 'booster');
73
73
  await serviceClient.sendToConnection(connectionID, JSON.stringify(data), { contentType: 'text/plain' });
74
74
  }
75
- exports.sendMessageToConnection = sendMessageToConnection;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteSnapshot = exports.deleteEvent = exports.findDeletableSnapshot = exports.findDeletableEvent = void 0;
3
+ exports.findDeletableEvent = findDeletableEvent;
4
+ exports.findDeletableSnapshot = findDeletableSnapshot;
5
+ exports.deleteEvent = deleteEvent;
6
+ exports.deleteSnapshot = deleteSnapshot;
4
7
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
8
  const query_helper_1 = require("../helpers/query-helper");
6
9
  async function findDeletableEvent(cosmosDb, config, parameters) {
@@ -13,7 +16,6 @@ async function findDeletableEvent(cosmosDb, config, parameters) {
13
16
  logger.debug(`Finished deletable event search for ${stringifyParameters}`);
14
17
  return result;
15
18
  }
16
- exports.findDeletableEvent = findDeletableEvent;
17
19
  async function findDeletableSnapshot(cosmosDb, config, parameters) {
18
20
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-delete-adapter#findDeletableSnapshot');
19
21
  const stringifyParameters = JSON.stringify(parameters);
@@ -24,7 +26,6 @@ async function findDeletableSnapshot(cosmosDb, config, parameters) {
24
26
  logger.debug(`Finished deletable snapshot search for ${stringifyParameters}`);
25
27
  return result;
26
28
  }
27
- exports.findDeletableSnapshot = findDeletableSnapshot;
28
29
  async function deleteEvent(cosmosDb, config, events) {
29
30
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-delete-adapter#deleteEvent');
30
31
  const stringifyParameters = JSON.stringify(events);
@@ -41,7 +42,6 @@ async function deleteEvent(cosmosDb, config, events) {
41
42
  }
42
43
  logger.debug(`Finished event delete for ${stringifyParameters}`);
43
44
  }
44
- exports.deleteEvent = deleteEvent;
45
45
  async function deleteSnapshot(cosmosDb, config, snapshots) {
46
46
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-delete-adapter#deleteSnapshot');
47
47
  const stringifyParameters = JSON.stringify(snapshots);
@@ -57,7 +57,6 @@ async function deleteSnapshot(cosmosDb, config, snapshots) {
57
57
  }
58
58
  logger.debug(`Finished snapshot delete for ${stringifyParameters}`);
59
59
  }
60
- exports.deleteSnapshot = deleteSnapshot;
61
60
  function buildNewEvent(existingEvent) {
62
61
  return {
63
62
  ...existingEvent,
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storeDispatchedEvent = exports.storeSnapshot = exports.readEntityLatestSnapshot = exports.readEntityEventsSince = exports.rawEventsToEnvelopes = void 0;
3
+ exports.rawEventsToEnvelopes = rawEventsToEnvelopes;
4
+ exports.readEntityEventsSince = readEntityEventsSince;
5
+ exports.readEntityLatestSnapshot = readEntityLatestSnapshot;
6
+ exports.storeSnapshot = storeSnapshot;
7
+ exports.storeDispatchedEvent = storeDispatchedEvent;
4
8
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
9
  const constants_1 = require("../constants");
6
10
  const partition_keys_1 = require("./partition-keys");
@@ -8,7 +12,6 @@ const originOfTime = new Date(0).toISOString();
8
12
  function rawEventsToEnvelopes(context) {
9
13
  return context.bindings.rawEvent;
10
14
  }
11
- exports.rawEventsToEnvelopes = rawEventsToEnvelopes;
12
15
  async function readEntityEventsSince(cosmosDb, config, entityTypeName, entityID, since) {
13
16
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-adapter#readEntityEventsSince');
14
17
  const fromTime = since ? since : originOfTime;
@@ -36,7 +39,6 @@ async function readEntityEventsSince(cosmosDb, config, entityTypeName, entityID,
36
39
  logger.debug(`Loaded events for entity ${entityTypeName} with ID ${entityID} with result:`, resources);
37
40
  return resources;
38
41
  }
39
- exports.readEntityEventsSince = readEntityEventsSince;
40
42
  async function readEntityLatestSnapshot(cosmosDb, config, entityTypeName, entityID) {
41
43
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-adapter#readEntityLatestSnapshot');
42
44
  const { resources } = await cosmosDb
@@ -63,7 +65,6 @@ async function readEntityLatestSnapshot(cosmosDb, config, entityTypeName, entity
63
65
  return undefined;
64
66
  }
65
67
  }
66
- exports.readEntityLatestSnapshot = readEntityLatestSnapshot;
67
68
  async function storeSnapshot(cosmosDb, snapshotEnvelope, config) {
68
69
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-adapter#storeSnapshot');
69
70
  logger.debug('Storing snapshot with snapshotEnvelope:', snapshotEnvelope);
@@ -117,7 +118,6 @@ async function storeSnapshot(cosmosDb, snapshotEnvelope, config) {
117
118
  logger.debug('Snapshot stored', snapshotEnvelope);
118
119
  return persistableEntitySnapshot;
119
120
  }
120
- exports.storeSnapshot = storeSnapshot;
121
121
  async function storeDispatchedEvent(cosmosDb, eventEnvelope, config) {
122
122
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-adapter#storeDispatchedEvent');
123
123
  logger.debug('[EventsAdapter#storeDispatchedEvent] Storing EventEnvelope for event with ID: ', eventEnvelope.id);
@@ -143,4 +143,3 @@ async function storeDispatchedEvent(cosmosDb, eventEnvelope, config) {
143
143
  }
144
144
  }
145
145
  }
146
- exports.storeDispatchedEvent = storeDispatchedEvent;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchEntitiesIds = exports.searchEvents = void 0;
3
+ exports.searchEvents = searchEvents;
4
+ exports.searchEntitiesIds = searchEntitiesIds;
4
5
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
6
  const query_helper_1 = require("../helpers/query-helper");
6
7
  const events_searcher_builder_1 = require("./events-searcher-builder");
@@ -18,7 +19,6 @@ async function searchEvents(cosmosDb, config, parameters) {
18
19
  logger.debug('Events search result: ', eventEnvelopes);
19
20
  return eventEnvelopes;
20
21
  }
21
- exports.searchEvents = searchEvents;
22
22
  async function searchEntitiesIds(cosmosDb, config, limit, afterCursor, entityTypeName) {
23
23
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-searcher-adapter#searchEntitiesIds');
24
24
  logger.debug(`Initiating a paginated events search. limit: ${limit}, afterCursor: ${JSON.stringify(afterCursor)}, entityTypeName: ${entityTypeName}`);
@@ -32,4 +32,3 @@ async function searchEntitiesIds(cosmosDb, config, limit, afterCursor, entityTyp
32
32
  logger.debug('Unique events search result', result);
33
33
  return result;
34
34
  }
35
- exports.searchEntitiesIds = searchEntitiesIds;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resultToEventSearchResponse = exports.buildFiltersForByFilters = exports.buildFiltersForByTime = void 0;
3
+ exports.buildFiltersForByTime = buildFiltersForByTime;
4
+ exports.buildFiltersForByFilters = buildFiltersForByFilters;
5
+ exports.resultToEventSearchResponse = resultToEventSearchResponse;
4
6
  function buildFiltersForByTime(fromValue, toValue) {
5
7
  if (fromValue && toValue) {
6
8
  return {
@@ -19,7 +21,6 @@ function buildFiltersForByTime(fromValue, toValue) {
19
21
  }
20
22
  return {};
21
23
  }
22
- exports.buildFiltersForByTime = buildFiltersForByTime;
23
24
  function buildFiltersForByFilters(parameters) {
24
25
  if ('entity' in parameters) {
25
26
  if (parameters.entityID) {
@@ -34,7 +35,6 @@ function buildFiltersForByFilters(parameters) {
34
35
  throw new Error('Invalid search event query. It is neither an search by "entity" nor a search by "type"');
35
36
  }
36
37
  }
37
- exports.buildFiltersForByFilters = buildFiltersForByFilters;
38
38
  function resultToEventSearchResponse(result) {
39
39
  if (!result || result.length === 0)
40
40
  return [];
@@ -52,7 +52,6 @@ function resultToEventSearchResponse(result) {
52
52
  });
53
53
  return eventSearchResult !== null && eventSearchResult !== void 0 ? eventSearchResult : [];
54
54
  }
55
- exports.resultToEventSearchResponse = resultToEventSearchResponse;
56
55
  function buildByEntityAndID(entityValue, entityIdValue) {
57
56
  const value = partitionKeyForEvent(entityValue, entityIdValue);
58
57
  return {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storeEvents = void 0;
3
+ exports.storeEvents = storeEvents;
4
4
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
5
  const partition_keys_1 = require("./partition-keys");
6
6
  const constants_1 = require("../constants");
@@ -30,7 +30,6 @@ async function storeEvents(cosmosDb, eventEnvelopes, config) {
30
30
  logger.debug('EventEnvelopes stored:');
31
31
  return persistableEvents;
32
32
  }
33
- exports.storeEvents = storeEvents;
34
33
  /**
35
34
  * Limits: The Azure Cosmos DB request size limit constrains the size of the TransactionalBatch payload to not exceed 2 MB,
36
35
  * and the maximum execution time is 5 seconds. There's a current limit of 100 operations per TransactionalBatch to ensure
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawEventsStreamToEnvelopes = exports.dedupEventStream = void 0;
3
+ exports.dedupEventStream = dedupEventStream;
4
+ exports.rawEventsStreamToEnvelopes = rawEventsStreamToEnvelopes;
4
5
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
6
  const constants_1 = require("../constants");
6
7
  const DEFAULT_DEDUP_TTL = 86400;
@@ -35,7 +36,6 @@ async function dedupEventStream(cosmosDb, config, context) {
35
36
  }
36
37
  return resources;
37
38
  }
38
- exports.dedupEventStream = dedupEventStream;
39
39
  function rawEventsStreamToEnvelopes(config, context, dedupEventStream) {
40
40
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'events-adapter#rawEventsStreamToEnvelopes');
41
41
  logger.debug(`Mapping ${dedupEventStream.length} events`);
@@ -51,4 +51,3 @@ function rawEventsStreamToEnvelopes(config, context, dedupEventStream) {
51
51
  return rawParsed;
52
52
  });
53
53
  }
54
- exports.rawEventsStreamToEnvelopes = rawEventsStreamToEnvelopes;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.produceEventsStream = void 0;
3
+ exports.produceEventsStream = produceEventsStream;
4
4
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
5
  const partition_keys_1 = require("./partition-keys");
6
6
  async function produceEventsStream(producer, entityName, entityID, eventEnvelopes, config) {
@@ -40,4 +40,3 @@ async function produceEventsStream(producer, entityName, entityID, eventEnvelope
40
40
  throw new Error(`Not all messages were sent (${numEventsSent}/${eventEnvelopes.length})`);
41
41
  }
42
42
  }
43
- exports.produceEventsStream = produceEventsStream;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawGraphQLRequestToEnvelope = void 0;
3
+ exports.rawGraphQLRequestToEnvelope = rawGraphQLRequestToEnvelope;
4
4
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
5
5
  async function rawGraphQLRequestToEnvelope(config, context) {
6
6
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -47,4 +47,3 @@ async function rawGraphQLRequestToEnvelope(config, context) {
47
47
  };
48
48
  }
49
49
  }
50
- exports.rawGraphQLRequestToEnvelope = rawGraphQLRequestToEnvelope;
@@ -1,28 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.databaseReadModelsHealthDetails = exports.rawRequestToSensorHealth = exports.rawRequestToSensorHealthComponentPath = exports.areRocketFunctionsUp = exports.isRocketFunctionUp = exports.isGraphQLFunctionUp = exports.areDatabaseReadModelsUp = exports.isDatabaseEventUp = exports.rocketFunctionAppUrl = exports.graphqlFunctionUrl = exports.databaseEventsHealthDetails = exports.countAll = exports.isContainerUp = exports.getContainer = exports.databaseUrl = void 0;
3
+ exports.databaseUrl = databaseUrl;
4
+ exports.getContainer = getContainer;
5
+ exports.isContainerUp = isContainerUp;
6
+ exports.countAll = countAll;
7
+ exports.databaseEventsHealthDetails = databaseEventsHealthDetails;
8
+ exports.graphqlFunctionUrl = graphqlFunctionUrl;
9
+ exports.rocketFunctionAppUrl = rocketFunctionAppUrl;
10
+ exports.isDatabaseEventUp = isDatabaseEventUp;
11
+ exports.areDatabaseReadModelsUp = areDatabaseReadModelsUp;
12
+ exports.isGraphQLFunctionUp = isGraphQLFunctionUp;
13
+ exports.isRocketFunctionUp = isRocketFunctionUp;
14
+ exports.areRocketFunctionsUp = areRocketFunctionsUp;
15
+ exports.rawRequestToSensorHealthComponentPath = rawRequestToSensorHealthComponentPath;
16
+ exports.rawRequestToSensorHealth = rawRequestToSensorHealth;
17
+ exports.databaseReadModelsHealthDetails = databaseReadModelsHealthDetails;
4
18
  const constants_1 = require("../constants");
5
19
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
6
20
  async function databaseUrl(cosmosDb, config) {
7
21
  const database = cosmosDb.database(config.resourceNames.applicationStack);
8
22
  return [database.url];
9
23
  }
10
- exports.databaseUrl = databaseUrl;
11
24
  function getContainer(cosmosDb, config, containerName) {
12
25
  return cosmosDb.database(config.resourceNames.applicationStack).container(containerName);
13
26
  }
14
- exports.getContainer = getContainer;
15
27
  async function isContainerUp(cosmosDb, config, containerName) {
16
28
  const container = getContainer(cosmosDb, config, containerName);
17
- const { resources } = await container.items.query('SELECT TOP 1 1 FROM c', { maxItemCount: -1 }).fetchAll();
29
+ const { resources } = await container.items
30
+ .query({
31
+ query: 'SELECT TOP 1 1 FROM c',
32
+ parameters: [],
33
+ })
34
+ .fetchAll();
18
35
  return resources !== undefined;
19
36
  }
20
- exports.isContainerUp = isContainerUp;
21
37
  async function countAll(container) {
22
- const { resources } = await container.items.query('SELECT VALUE COUNT(1) FROM c', { maxItemCount: -1 }).fetchAll();
38
+ const { resources } = await container.items
39
+ .query({
40
+ query: 'SELECT VALUE COUNT(1) FROM c',
41
+ parameters: [],
42
+ })
43
+ .fetchAll();
23
44
  return resources ? resources[0] : 0;
24
45
  }
25
- exports.countAll = countAll;
26
46
  async function databaseEventsHealthDetails(cosmosDb, config) {
27
47
  const container = getContainer(cosmosDb, config, config.resourceNames.eventsStore);
28
48
  const url = container.url;
@@ -32,7 +52,6 @@ async function databaseEventsHealthDetails(cosmosDb, config) {
32
52
  count: count,
33
53
  };
34
54
  }
35
- exports.databaseEventsHealthDetails = databaseEventsHealthDetails;
36
55
  async function graphqlFunctionUrl() {
37
56
  try {
38
57
  const basePath = process.env[constants_1.environmentVarNames.restAPIURL];
@@ -42,15 +61,12 @@ async function graphqlFunctionUrl() {
42
61
  return '';
43
62
  }
44
63
  }
45
- exports.graphqlFunctionUrl = graphqlFunctionUrl;
46
64
  async function rocketFunctionAppUrl(functionAppName) {
47
65
  return `https://${functionAppName}.azurewebsites.net`;
48
66
  }
49
- exports.rocketFunctionAppUrl = rocketFunctionAppUrl;
50
67
  async function isDatabaseEventUp(cosmosDb, config) {
51
68
  return await isContainerUp(cosmosDb, config, config.resourceNames.eventsStore);
52
69
  }
53
- exports.isDatabaseEventUp = isDatabaseEventUp;
54
70
  async function areDatabaseReadModelsUp(cosmosDb, config) {
55
71
  const promises = Object.values(config.readModels).map((readModel) => {
56
72
  const name = readModel.class.name;
@@ -60,18 +76,18 @@ async function areDatabaseReadModelsUp(cosmosDb, config) {
60
76
  const containersUp = await Promise.all(promises);
61
77
  return containersUp.every((isContainerUp) => isContainerUp);
62
78
  }
63
- exports.areDatabaseReadModelsUp = areDatabaseReadModelsUp;
64
79
  async function isGraphQLFunctionUp() {
65
80
  try {
66
81
  const restAPIUrl = await graphqlFunctionUrl();
67
- const response = await (0, framework_common_helpers_1.request)(restAPIUrl, 'POST');
82
+ const response = await (0, framework_common_helpers_1.request)(restAPIUrl, 'POST', JSON.stringify({
83
+ query: 'query { __typename }',
84
+ }));
68
85
  return response.status === 200;
69
86
  }
70
87
  catch (e) {
71
88
  return false;
72
89
  }
73
90
  }
74
- exports.isGraphQLFunctionUp = isGraphQLFunctionUp;
75
91
  async function isRocketFunctionUp(rocketFunctionAppName) {
76
92
  try {
77
93
  const functionAppUrl = await rocketFunctionAppUrl(rocketFunctionAppName);
@@ -82,7 +98,6 @@ async function isRocketFunctionUp(rocketFunctionAppName) {
82
98
  return false;
83
99
  }
84
100
  }
85
- exports.isRocketFunctionUp = isRocketFunctionUp;
86
101
  async function areRocketFunctionsUp() {
87
102
  var _a;
88
103
  const functionAppNames = ((_a = process.env[constants_1.environmentVarNames.rocketFunctionAppNames]) === null || _a === void 0 ? void 0 : _a.split(',').filter((str) => str.trim() !== '')) || [];
@@ -92,13 +107,11 @@ async function areRocketFunctionsUp() {
92
107
  }));
93
108
  return results.reduce((acc, result) => ({ ...acc, ...result }), {});
94
109
  }
95
- exports.areRocketFunctionsUp = areRocketFunctionsUp;
96
110
  function rawRequestToSensorHealthComponentPath(rawRequest) {
97
111
  var _a;
98
112
  const parameters = (_a = rawRequest.req) === null || _a === void 0 ? void 0 : _a.url.replace(/^.*sensor\/health\/?/, '');
99
113
  return parameters !== null && parameters !== void 0 ? parameters : '';
100
114
  }
101
- exports.rawRequestToSensorHealthComponentPath = rawRequestToSensorHealthComponentPath;
102
115
  function rawRequestToSensorHealth(context) {
103
116
  var _a, _b, _c, _d;
104
117
  const componentPath = rawRequestToSensorHealthComponentPath(context);
@@ -116,7 +129,6 @@ function rawRequestToSensorHealth(context) {
116
129
  token: (_d = (_c = context.req) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d.authorization,
117
130
  };
118
131
  }
119
- exports.rawRequestToSensorHealth = rawRequestToSensorHealth;
120
132
  async function databaseReadModelsHealthDetails(cosmosDb, config) {
121
133
  const readModels = Object.values(config.readModels);
122
134
  const result = [];
@@ -133,4 +145,3 @@ async function databaseReadModelsHealthDetails(cosmosDb, config) {
133
145
  }
134
146
  return result;
135
147
  }
136
- exports.databaseReadModelsHealthDetails = databaseReadModelsHealthDetails;
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.partitionKeyForSnapshot = exports.partitionKeyForEvent = void 0;
3
+ exports.partitionKeyForEvent = partitionKeyForEvent;
4
+ exports.partitionKeyForSnapshot = partitionKeyForSnapshot;
4
5
  function partitionKeyForEvent(entityTypeName, entityID) {
5
6
  return `${entityTypeName}-${entityID}-event`;
6
7
  }
7
- exports.partitionKeyForEvent = partitionKeyForEvent;
8
8
  function partitionKeyForSnapshot(entityTypeName, entityID) {
9
9
  return `${entityTypeName}-${entityID}-snapshot`;
10
10
  }
11
- exports.partitionKeyForSnapshot = partitionKeyForSnapshot;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawReadModelEventsToEnvelopes = exports.deleteReadModel = exports.storeReadModel = exports.fetchReadModel = void 0;
3
+ exports.fetchReadModel = fetchReadModel;
4
+ exports.storeReadModel = storeReadModel;
5
+ exports.deleteReadModel = deleteReadModel;
6
+ exports.rawReadModelEventsToEnvelopes = rawReadModelEventsToEnvelopes;
4
7
  const framework_types_1 = require("@boostercloud/framework-types");
5
8
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
6
9
  const constants_1 = require("../constants");
@@ -24,7 +27,6 @@ async function fetchReadModel(db, config, readModelName, readModelID) {
24
27
  },
25
28
  ];
26
29
  }
27
- exports.fetchReadModel = fetchReadModel;
28
30
  async function insertReadModel(readModel, db, config, readModelName) {
29
31
  var _a;
30
32
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'read-model-adapter#insertReadModel');
@@ -83,7 +85,6 @@ async function storeReadModel(db, config, readModelName, readModel) {
83
85
  }
84
86
  return await updateReadModel(readModel, db, config, readModelName);
85
87
  }
86
- exports.storeReadModel = storeReadModel;
87
88
  async function deleteReadModel(db, config, readModelName, readModel) {
88
89
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'read-model-adapter#deleteReadModel');
89
90
  logger.debug(`Entering to Read model deleted. ${readModelName} ID = ${readModel.id}`);
@@ -99,7 +100,6 @@ async function deleteReadModel(db, config, readModelName, readModel) {
99
100
  logger.warn(`Read model to delete ${readModelName} ID = ${readModel.id} not found`);
100
101
  }
101
102
  }
102
- exports.deleteReadModel = deleteReadModel;
103
103
  async function rawReadModelEventsToEnvelopes(config, rawEvents) {
104
104
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'read-model-adapter#rawReadModelEventsToEnvelopes');
105
105
  logger.debug(`Parsing raw read models ${JSON.stringify(rawEvents)}`);
@@ -116,7 +116,6 @@ async function rawReadModelEventsToEnvelopes(config, rawEvents) {
116
116
  logger.warn(`Unexpected events to be parsed ${JSON.stringify(rawEvents)}`);
117
117
  return [];
118
118
  }
119
- exports.rawReadModelEventsToEnvelopes = rawReadModelEventsToEnvelopes;
120
119
  function isSubscriptionContext(rawRequest) {
121
120
  return (rawRequest.bindings !== undefined &&
122
121
  rawRequest.bindings.rawEvent !== undefined);
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawRocketInputToEnvelope = void 0;
3
+ exports.rawRocketInputToEnvelope = rawRocketInputToEnvelope;
4
4
  const framework_types_1 = require("@boostercloud/framework-types");
5
5
  function rawRocketInputToEnvelope(config, request) {
6
6
  return {
7
7
  rocketId: process.env[framework_types_1.rocketFunctionIDEnvVar],
8
8
  };
9
9
  }
10
- exports.rawRocketInputToEnvelope = rawRocketInputToEnvelope;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rawScheduledInputToEnvelope = void 0;
3
+ exports.rawScheduledInputToEnvelope = rawScheduledInputToEnvelope;
4
4
  const framework_types_1 = require("@boostercloud/framework-types");
5
5
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
6
6
  async function rawScheduledInputToEnvelope(config, input) {
@@ -13,4 +13,3 @@ async function rawScheduledInputToEnvelope(config, input) {
13
13
  typeName: Object.keys(input.bindings)[0],
14
14
  };
15
15
  }
16
- exports.rawScheduledInputToEnvelope = rawScheduledInputToEnvelope;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchReadModel = void 0;
3
+ exports.searchReadModel = searchReadModel;
4
4
  const queryHelper = require("../helpers/query-helper");
5
5
  async function searchReadModel(cosmosDb, config, readModelName, filters, sortBy, limit, afterCursor, paginatedVersion = false, select) {
6
6
  return await queryHelper.search(cosmosDb, config, config.resourceNames.forReadModel(readModelName), filters, limit, afterCursor, paginatedVersion, sortBy, select);
7
7
  }
8
- exports.searchReadModel = searchReadModel;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteAllSubscriptions = exports.deleteSubscription = exports.fetchSubscriptions = exports.subscribeToReadModel = void 0;
3
+ exports.subscribeToReadModel = subscribeToReadModel;
4
+ exports.fetchSubscriptions = fetchSubscriptions;
5
+ exports.deleteSubscription = deleteSubscription;
6
+ exports.deleteAllSubscriptions = deleteAllSubscriptions;
4
7
  const constants_1 = require("../constants");
5
8
  const framework_common_helpers_1 = require("@boostercloud/framework-common-helpers");
6
9
  async function subscribeToReadModel(cosmosDb, config, subscriptionEnvelope) {
@@ -22,7 +25,6 @@ async function subscribeToReadModel(cosmosDb, config, subscriptionEnvelope) {
22
25
  ttl: ttl,
23
26
  });
24
27
  }
25
- exports.subscribeToReadModel = subscribeToReadModel;
26
28
  async function fetchSubscriptions(cosmosDb, config, subscriptionName) {
27
29
  // TODO: filter expired ones. Or... is it needed?
28
30
  const { resources } = await cosmosDb
@@ -37,7 +39,6 @@ async function fetchSubscriptions(cosmosDb, config, subscriptionName) {
37
39
  .fetchAll();
38
40
  return resources;
39
41
  }
40
- exports.fetchSubscriptions = fetchSubscriptions;
41
42
  async function deleteSubscription(cosmosDb, config, connectionID, subscriptionID) {
42
43
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'subscription-adapter#deleteSubscription');
43
44
  // TODO: Manage query pagination
@@ -74,7 +75,6 @@ async function deleteSubscription(cosmosDb, config, connectionID, subscriptionID
74
75
  .item(subscriptionToDelete.id, subscriptionToDelete[constants_1.subscriptionsStoreAttributes.partitionKey])
75
76
  .delete();
76
77
  }
77
- exports.deleteSubscription = deleteSubscription;
78
78
  async function deleteAllSubscriptions(cosmosDb, config, connectionID) {
79
79
  const logger = (0, framework_common_helpers_1.getLogger)(config, 'subscription-adapter#deleteAllSubscriptions');
80
80
  // TODO: Manage query pagination and db.batchWrite limit of 25 operations at a time
@@ -106,7 +106,6 @@ async function deleteAllSubscriptions(cosmosDb, config, connectionID) {
106
106
  .delete());
107
107
  await Promise.allSettled(deletePromises);
108
108
  }
109
- exports.deleteAllSubscriptions = deleteAllSubscriptions;
110
109
  function sortKeyForSubscription(connectionID, subscriptionID) {
111
110
  return `${connectionID}-${subscriptionID}`;
112
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostercloud/framework-provider-azure",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "Handle Booster's integration with Azure",
5
5
  "keywords": [
6
6
  "framework-provider-azure"
@@ -25,20 +25,20 @@
25
25
  "dependencies": {
26
26
  "@azure/cosmos": "^4.0.0",
27
27
  "@azure/functions": "^1.2.2",
28
- "@azure/identity": "~2.1.0",
28
+ "@azure/identity": "~4.7.0",
29
29
  "@azure/event-hubs": "5.11.1",
30
- "@boostercloud/framework-common-helpers": "^3.0.0",
31
- "@boostercloud/framework-types": "^3.0.0",
30
+ "@boostercloud/framework-common-helpers": "^3.1.1",
31
+ "@boostercloud/framework-types": "^3.1.1",
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": "^3.0.0",
37
+ "@boostercloud/eslint-config": "^3.1.1",
38
38
  "@types/chai": "4.2.18",
39
39
  "@types/chai-as-promised": "7.1.4",
40
40
  "@types/faker": "5.1.5",
41
- "@types/mocha": "10.0.1",
41
+ "@types/mocha": "10.0.10",
42
42
  "@types/node": "^20.17.17",
43
43
  "@types/sinon": "10.0.0",
44
44
  "@types/sinon-chai": "3.2.5",
@@ -58,7 +58,7 @@
58
58
  "sinon": "9.2.3",
59
59
  "sinon-chai": "3.5.0",
60
60
  "ts-node": "^10.9.1",
61
- "typescript": "5.1.6",
61
+ "typescript": "5.7.3",
62
62
  "eslint-plugin-unicorn": "~44.0.2"
63
63
  },
64
64
  "bugs": {