New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@holaluz/pomada

Package Overview
Dependencies
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@holaluz/pomada - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0-beta.1

dist/product-fees/domain/cups-error.d.ts

5

dist/index.d.ts

@@ -1,4 +0,1 @@

export { EnergyFee } from './product-fees/domain/energy-fee';
export { ProductFee } from './product-fees/domain/product-fee';
export { ProductName } from './product-fees/domain/product-name';
export { getProductFees, GetProductFeesParams } from './product-fees/application/get-product-fees';
export { getProductFees } from './product-fees/application/get-product-fees';

14

dist/index.js

@@ -1,2 +0,14 @@

export { ProductName } from './product-fees/domain/product-name';
// TODO: we should export each module individually, not in an index.ts file
// We want things like: import { supplyPoint } from 'this-repository/supply-point
// instead of importing everything from 'this-repository'
export { getProductFees } from './product-fees/application/get-product-fees';
// getProductFees(
// {
// cups:
// 'def502007780c632e2f5002c8faf93b5c74e1e65b6a08a9bee7b5abd21f60555a9c170f2946b3719cc098d90d6023c2e1e7ac6db293cc74b7fffb69415c7040a9376e2a1005eb696b8f1e76cdfb31fe8227fe65bff3b3492879b4396f7d7e8e88122f8db50453c19',
// },
// {
// onSuccess: () => {},
// onCupsInvalid: () => {},
// }
// )

@@ -1,5 +0,10 @@

import { ProductFee } from '../domain/product-fee';
export declare type GetProductFeesParams = {
cups: String;
import { CupsError } from '../domain/cups-error';
import { SupplyPoint } from '../domain/supply-point';
declare type GetProductFeesParams = {
cups: string;
};
declare type GetProductFeesCallbacks = {
onSuccess: (supplyPoint: SupplyPoint) => void;
onCupsInvalid: (cupsError: CupsError) => void;
};
/**

@@ -9,2 +14,3 @@ * For a given supply point, calculates all the available products

*/
export declare function getProductFees({ cups }: GetProductFeesParams): Promise<ProductFee[]>;
export declare function getProductFees({ cups }: GetProductFeesParams, { onSuccess, onCupsInvalid }: GetProductFeesCallbacks): Promise<void>;
export {};

@@ -0,1 +1,5 @@

import { isCupsValid } from '../infrastructure/is-cups-valid';
import { getSupplyPoint } from '../infrastructure/get-supply-point';
import { getPricesOfProduct } from '../infrastructure/get-prices-of-product';
import { getFeeOfProduct } from '../infrastructure/get-fee-of-product';
import { ProductName } from '../domain/product-name';

@@ -6,15 +10,34 @@ /**

*/
export function getProductFees({ cups }) {
return Promise.resolve([
{
name: ProductName.classic,
fee: 30,
energyFees: [
{
name: 'P1',
fee: 0.034,
},
],
},
export async function getProductFees({ cups }, { onSuccess, onCupsInvalid }) {
const isCupsValidRequest = await isCupsValid(cups);
if (isCupsValidRequest.isFail()) {
return onCupsInvalid(isCupsValidRequest.getFail());
}
const supplyPointRequest = await getSupplyPoint(cups);
if (supplyPointRequest.isFail()) {
return onCupsInvalid(supplyPointRequest.getFail());
}
const supplyPoint = supplyPointRequest.getSuccess();
await Promise.all([
...supplyPoint.products.map(async (product) => {
if (product.name === ProductName.fairFee)
return;
const pricesResult = await getPricesOfProduct(product.id);
// Fixme: what if we have error?
if (pricesResult.isSuccess()) {
const prices = pricesResult.getSuccess();
product.powerFees = prices.power;
product.energyFees = prices.energy;
}
}),
...supplyPoint.products.map(async (product) => {
const feeResult = await getFeeOfProduct(product.id, supplyPoint.consumption, supplyPoint.currentPower, supplyPoint.optimizedPower);
// Fixme: what if we have error?
if (feeResult.isSuccess()) {
const fee = feeResult.getSuccess();
product.fee = fee;
}
}),
]);
return onSuccess(supplyPoint);
}
import { EnergyFee } from './energy-fee';
import { ProductName } from './product-name';
export declare type ProductFee = {
id: string;
name: ProductName;
fee: Number;
energyFees: [EnergyFee];
powerFees: number;
};
export declare enum ProductName {
classic = "classic",
fairFee = "fairFee",
sinsor = "sinsor"
classic = "clasico",
fairFee = "tarifaJusta",
sinsor = "sinSorpresas"
}
export var ProductName;
(function (ProductName) {
ProductName["classic"] = "classic";
ProductName["fairFee"] = "fairFee";
ProductName["sinsor"] = "sinsor";
ProductName["classic"] = "clasico";
ProductName["fairFee"] = "tarifaJusta";
ProductName["sinsor"] = "sinSorpresas";
})(ProductName || (ProductName = {}));
{
"name": "@holaluz/pomada",
"version": "1.0.3",
"version": "1.1.0-beta.1",
"description": "Holaluz shared FE business logic repository",

@@ -5,0 +5,0 @@ "author": "Holaluz",

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