@boostercloud/framework-provider-azure 0.21.1 → 0.21.5

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.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- import { ProviderLibrary } from '@boostercloud/framework-types';
1
+ import { HasInfrastructure, ProviderLibrary } from '@boostercloud/framework-types';
2
+ export declare function loadInfrastructurePackage(packageName: string): HasInfrastructure;
2
3
  export declare const Provider: () => ProviderLibrary;
3
4
  export * from './constants';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Provider = void 0;
3
+ exports.Provider = exports.loadInfrastructurePackage = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const api_adapter_1 = require("./library/api-adapter");
6
6
  const graphql_adapter_1 = require("./library/graphql-adapter");
@@ -16,6 +16,14 @@ if (typeof process.env[constants_1.environmentVarNames.cosmosDbConnectionString]
16
16
  else {
17
17
  cosmosClient = new cosmos_1.CosmosClient(process.env[constants_1.environmentVarNames.cosmosDbConnectionString]);
18
18
  }
19
+ /* We load the infrastructure package dynamically here to avoid including it in the
20
+ * dependencies that are deployed in the lambda functions. The infrastructure
21
+ * package is only used during the deploy.
22
+ */
23
+ function loadInfrastructurePackage(packageName) {
24
+ return require(packageName);
25
+ }
26
+ exports.loadInfrastructurePackage = loadInfrastructurePackage;
19
27
  const Provider = () => ({
20
28
  // ProviderEventsLibrary
21
29
  events: {
@@ -58,7 +66,19 @@ const Provider = () => ({
58
66
  rawToEnvelope: undefined,
59
67
  },
60
68
  // ProviderInfrastructureGetter
61
- infrastructure: () => require(require('../package.json').name + '-infrastructure').Infrastructure,
69
+ infrastructure: () => {
70
+ const infrastructurePackageName = require('../package.json').name + '-infrastructure';
71
+ let infrastructure;
72
+ try {
73
+ infrastructure = loadInfrastructurePackage(infrastructurePackageName);
74
+ }
75
+ catch (e) {
76
+ throw new Error(`The Azure infrastructure package could not be loaded. The following error was thrown: ${e.message}. Please ensure that one of the following actions has been done:\n` +
77
+ ` - It has been specified in your "devDependencies" section of your "package.json" file. You can do so by running 'npm install --save-dev ${infrastructurePackageName}'\n` +
78
+ ` - Or it has been installed globally. You can do so by running 'npm install -g ${infrastructurePackageName}'`);
79
+ }
80
+ return infrastructure.Infrastructure();
81
+ },
62
82
  });
63
83
  exports.Provider = Provider;
64
84
  function notImplemented() { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostercloud/framework-provider-azure",
3
- "version": "0.21.1",
3
+ "version": "0.21.5",
4
4
  "description": "Handle Booster's integration with Azure",
5
5
  "keywords": [
6
6
  "framework-provider-azure"
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@azure/cosmos": "3.7.3",
24
24
  "@azure/functions": "^1.2.2",
25
- "@boostercloud/framework-types": "^0.21.1",
25
+ "@boostercloud/framework-types": "^0.21.5",
26
26
  "chai": "4.2.0",
27
27
  "chai-as-promised": "7.1.1",
28
28
  "mocha": "8.4.0",
@@ -41,5 +41,5 @@
41
41
  "bugs": {
42
42
  "url": "https://github.com/boostercloud/booster/issues"
43
43
  },
44
- "gitHead": "8598aecaef64284de86af97f64b0786c82ecda58"
44
+ "gitHead": "fd6680faaa9fe56a0d8cc34cf50e283981283ce3"
45
45
  }