@adastradev/serverless-discovery-sdk
Advanced tools
Comparing version 1.1.2 to 2.0.0-beta.2
@@ -1,5 +0,1 @@ | ||
export interface ICloudDependency { | ||
name: string; | ||
version: string; | ||
} | ||
export declare class DiscoverySdk { | ||
@@ -10,8 +6,6 @@ private api; | ||
private cloudDependencies; | ||
constructor(serviceEndpointUri: string, region?: string, defaultStageName?: string, lookupVersionPostfix?: string, configPath?: string, cloudDeps?: Map<string, string>); | ||
constructor(serviceEndpointUri: string, region?: string, defaultStageName?: string, lookupVersionPostfix?: string, cloudDeps?: Map<string, string>); | ||
readonly cloudDependencyNames: string[]; | ||
getDependency(name: string): ICloudDependency | undefined; | ||
getDependency(name: string): string | undefined; | ||
lookupService(serviceName: string, stageName?: string, version?: string, externalID?: string): Promise<any>; | ||
private populateDependencies; | ||
private readConfig; | ||
} |
@@ -39,7 +39,4 @@ "use strict"; | ||
var DiscoveryServiceApi_1 = require("./DiscoveryServiceApi"); | ||
var appRoot = require("app-root-path"); | ||
var fs = require("fs"); | ||
var Path = require("path"); | ||
var DiscoverySdk = /** @class */ (function () { | ||
function DiscoverySdk(serviceEndpointUri, region, defaultStageName, lookupVersionPostfix, configPath, cloudDeps) { | ||
function DiscoverySdk(serviceEndpointUri, region, defaultStageName, lookupVersionPostfix, cloudDeps) { | ||
this.cloudDependencies = new Map(); | ||
@@ -52,11 +49,7 @@ this.api = new DiscoveryServiceApi_1.DiscoveryServiceApi(serviceEndpointUri, region || 'us-east-1', { type: 'None' }); | ||
lookupVersionPostfix = process.env.VERSION_POSTFIX; | ||
if (lookupVersionPostfix) { | ||
console.log("DEBUG: Using VERSION_POSTFIX=" + lookupVersionPostfix); | ||
} | ||
else { | ||
console.log('DEBUG: VERSION_POSTFIX not found'); | ||
} | ||
} | ||
this.lookupVersionPostfix = lookupVersionPostfix; | ||
this.populateDependencies(configPath, cloudDeps); | ||
if (cloudDeps) { | ||
this.cloudDependencies = cloudDeps; | ||
} | ||
} | ||
@@ -75,7 +68,6 @@ Object.defineProperty(DiscoverySdk.prototype, "cloudDependencyNames", { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var cloudDep, result; | ||
var result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
console.log("DEBUG: lookupService called (serviceName: " + serviceName + ", stageName: " + stageName + ", version: " + version + ", externalID: " + externalID); | ||
if (!stageName) { | ||
@@ -86,11 +78,6 @@ stageName = this.defaultStageName; | ||
if (!version) { | ||
cloudDep = this.getDependency(serviceName); | ||
if (cloudDep) { | ||
version = cloudDep.version; | ||
console.log("DEBUG: Using version from config: " + version); | ||
} | ||
version = this.cloudDependencies.get(serviceName); | ||
} | ||
if (version && this.lookupVersionPostfix) { | ||
version += this.lookupVersionPostfix; | ||
console.log("DEBUG: Version updated with postfix: " + version); | ||
} | ||
@@ -108,47 +95,4 @@ if (!externalID) { | ||
}; | ||
DiscoverySdk.prototype.populateDependencies = function (configPath, cloudDeps) { | ||
// Can provide all of dependencies or be overridden by a config file. | ||
if (cloudDeps) { | ||
console.log("DEBUG: Passed cloudDeps"); | ||
console.log(cloudDeps); | ||
for (var _i = 0, _a = Array.from(cloudDeps.keys()); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
this.cloudDependencies.set(key, { name: key, version: cloudDeps.get(key) }); | ||
} | ||
} | ||
console.log("DEBUG: populateDependencies: (configPath: " + configPath + ")"); | ||
if (configPath !== undefined) { | ||
this.readConfig(configPath); | ||
} | ||
else { | ||
// Look for the package.json file in the root project folder | ||
var basePackagePath = Path.join(appRoot.path, 'package.json'); | ||
if (fs.existsSync(basePackagePath)) { | ||
console.log("DEBUG: Searched for config. Found at: " + basePackagePath); | ||
this.readConfig(basePackagePath); | ||
} | ||
else { | ||
console.log("DEBUG: Never found a config file at: " + basePackagePath); | ||
} | ||
} | ||
}; | ||
DiscoverySdk.prototype.readConfig = function (configPath) { | ||
console.log("DEBUG: readConfig (" + configPath + ")"); | ||
var rawdata = fs.readFileSync(configPath); | ||
var config = JSON.parse(rawdata.toString('utf8')); | ||
if (config.hasOwnProperty('cloudDependencies')) { | ||
console.log("DEBUG: cloudDependencies found"); | ||
console.log(config.cloudDependencies); | ||
for (var key in config.cloudDependencies) { | ||
if (config.cloudDependencies.hasOwnProperty(key)) { | ||
this.cloudDependencies.set(key, { name: key, version: config.cloudDependencies[key] }); | ||
} | ||
} | ||
} | ||
else { | ||
console.log("DEBUG: cloudDependencies section not found in config file."); | ||
} | ||
}; | ||
return DiscoverySdk; | ||
}()); | ||
exports.DiscoverySdk = DiscoverySdk; |
@@ -58,2 +58,6 @@ "use strict"; | ||
var body = {}; | ||
// We need more than stageName only | ||
if (stageName === '' && version === '' && externalID === '') { | ||
throw new Error('Must provide more than service name only'); | ||
} | ||
return this.apigClient.invokeApi(params, pathTemplate, method, additionalParams, body); | ||
@@ -60,0 +64,0 @@ }; |
{ | ||
"name": "@adastradev/serverless-discovery-sdk", | ||
"version": "1.1.2", | ||
"version": "2.0.0-beta.2", | ||
"description": "Serverless Service Discovery API", | ||
@@ -39,3 +39,2 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"app-root-path": "^2.2.1", | ||
"aws-api-gateway-client": "^0.2.17" | ||
@@ -42,0 +41,0 @@ }, |
@@ -41,3 +41,3 @@ # serverless-discovery-sdk-js | ||
var endpoints = await sdk.lookupService('my-service-name'); | ||
var endpoints = await sdk.lookupService('my-service-name', undefined, '1.x.x'); | ||
``` | ||
@@ -50,3 +50,3 @@ | ||
const endpoints = await sdk.lookupService('my-service-name'); | ||
const endpoints = await sdk.lookupService('my-service-name', undefined, '1.x.x'); | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
2
17055
259
2
- Removedapp-root-path@^2.2.1
- Removedapp-root-path@2.2.1(transitive)