Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@equinor/fusion-framework-module-service-discovery

Package Overview
Dependencies
Maintainers
3
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@equinor/fusion-framework-module-service-discovery - npm Package Compare versions

Comparing version 4.0.8 to 5.0.0

10

CHANGELOG.md

@@ -6,2 +6,12 @@ # Change Log

## 5.0.0 (2023-01-12)
### ⚠ BREAKING CHANGES
- **module-service-discovery:** changed `environment` from promise to sync
### Features
- **module-service-discovery:** allow sync resolve of service ([aa0361c](https://github.com/equinor/fusion-framework/commit/aa0361c765604ca5f642c9f2916cea860968d4a3))
## 4.0.8 (2022-12-14)

@@ -8,0 +18,0 @@

17

dist/esm/client.js

@@ -24,5 +24,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { firstValueFrom } from 'rxjs';
const queryKey = 'services';
export class ServiceDiscoveryClient {
get environment() {
return firstValueFrom(Query.extractQueryValue(__classPrivateFieldGet(this, _ServiceDiscoveryClient_query, "f").query(undefined, { cache: { suppressInvalid: true } })));
var _a;
const env = (_a = __classPrivateFieldGet(this, _ServiceDiscoveryClient_query, "f").cache.getItem(queryKey)) === null || _a === void 0 ? void 0 : _a.value;
if (!env) {
throw Error('no cached environment found');
}
return env;
}

@@ -37,6 +43,11 @@ constructor({ http, endpoint }) {

},
key: () => 'services',
key: () => queryKey,
expire: 5 * 60 * 1000,
}), "f");
}
fetchEnvironment() {
return __awaiter(this, void 0, void 0, function* () {
return firstValueFrom(Query.extractQueryValue(__classPrivateFieldGet(this, _ServiceDiscoveryClient_query, "f").query(undefined, { cache: { suppressInvalid: true } })));
});
}
selector(response) {

@@ -60,3 +71,3 @@ return __awaiter(this, void 0, void 0, function* () {

try {
const { services } = yield this.environment;
const { services } = yield this.fetchEnvironment();
const service = services[key];

@@ -63,0 +74,0 @@ return service;

@@ -19,2 +19,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
resolveServices() {
return this._client.fetchEnvironment();
}
resolveService(key) {

@@ -21,0 +24,0 @@ return __awaiter(this, void 0, void 0, function* () {

6

dist/types/client.d.ts
import { IHttpClient } from '@equinor/fusion-framework-module-http';
import { Environment, Service } from './types';
export interface IServiceDiscoveryClient {
readonly environment: Promise<Environment>;
readonly environment: Environment;
resolveService(key: string): Promise<Service>;
fetchEnvironment(): Promise<Environment>;
}

@@ -18,4 +19,5 @@ export interface IServiceDiscoveryClientCtor<TEnv extends Environment = Environment> {

http: IHttpClient;
get environment(): Promise<Environment>;
get environment(): T;
constructor({ http, endpoint }: ServiceDiscoveryClientCtorArgs);
fetchEnvironment(): Promise<T>;
selector(response: Response): Promise<T>;

@@ -22,0 +24,0 @@ resolveService(key: string): Promise<Service>;

@@ -7,3 +7,4 @@ import { IServiceDiscoveryClient } from './client';

resolveService(key: string): Promise<Service>;
readonly environment: Promise<Environment>;
readonly environment: Environment;
resolveServices(): Promise<Environment>;
createClient(name: string, opt?: Omit<HttpClientOptions, 'baseUri' | 'defaultScopes' | 'ctor'>): Promise<IHttpClient>;

@@ -19,3 +20,4 @@ configureClient(serviceName: string | {

constructor(_client: IServiceDiscoveryClient, _http: ModuleType<HttpModule>);
get environment(): Promise<Environment>;
get environment(): Environment;
resolveServices(): Promise<Environment>;
resolveService(key: string): Promise<Service>;

@@ -22,0 +24,0 @@ createClient(name: string, opt?: Omit<HttpClientOptions, 'baseUri' | 'defaultScopes' | 'ctor'>): Promise<IHttpClient>;

{
"name": "@equinor/fusion-framework-module-service-discovery",
"version": "4.0.8",
"version": "5.0.0",
"description": "",

@@ -34,3 +34,3 @@ "main": "dist/esm/index.js",

},
"gitHead": "e5668331df89b0ef6ef6175ea1908d4aeb772544"
"gitHead": "d42b4f2ee8759d3d9906c705abb259d6664f5283"
}

@@ -9,4 +9,5 @@ import { IHttpClient } from '@equinor/fusion-framework-module-http';

export interface IServiceDiscoveryClient {
readonly environment: Promise<Environment>;
readonly environment: Environment;
resolveService(key: string): Promise<Service>;
fetchEnvironment(): Promise<Environment>;
}

@@ -23,2 +24,4 @@

const queryKey = 'services';
export class ServiceDiscoveryClient<T extends Environment = Environment>

@@ -33,8 +36,8 @@ implements IServiceDiscoveryClient

get environment(): Promise<Environment> {
return firstValueFrom(
Query.extractQueryValue(
this.#query.query(undefined, { cache: { suppressInvalid: true } })
)
);
get environment(): T {
const env = this.#query.cache.getItem(queryKey)?.value;
if (!env) {
throw Error('no cached environment found');
}
return env;
}

@@ -49,3 +52,3 @@

},
key: () => 'services',
key: () => queryKey,
expire: 5 * 60 * 1000,

@@ -56,2 +59,10 @@ // queueOperator: (_) => ($) => $.pipe(throttleTime(100)),

public async fetchEnvironment(): Promise<T> {
return firstValueFrom(
Query.extractQueryValue(
this.#query.query(undefined, { cache: { suppressInvalid: true } })
)
);
}
public async selector(response: Response): Promise<T> {

@@ -73,3 +84,3 @@ const env = (await response.json()) as EnvironmentResponse;

try {
const { services } = await this.environment;
const { services } = await this.fetchEnvironment();
const service = services[key];

@@ -76,0 +87,0 @@ return service;

@@ -21,5 +21,8 @@ import { configureHttpClient } from '@equinor/fusion-framework-module-http';

* service environment
* this might throw error if no environment is loaded
*/
readonly environment: Promise<Environment>;
readonly environment: Environment;
resolveServices(): Promise<Environment>;
createClient(

@@ -42,6 +45,10 @@ name: string,

public get environment(): Promise<Environment> {
public get environment(): Environment {
return this._client.environment;
}
public resolveServices(): Promise<Environment> {
return this._client.fetchEnvironment();
}
public async resolveService(key: string): Promise<Service> {

@@ -48,0 +55,0 @@ return this._client.resolveService(key);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc