From 50b988aaa58586ed70d5505ccd347d9ab8200e87 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Thu, 7 Mar 2024 15:31:27 +0100 Subject: [PATCH] refactor: rename utils --- packages/core/src/api/actor.api.ts | 6 +++--- packages/core/src/utils/env.utils.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/src/api/actor.api.ts b/packages/core/src/api/actor.api.ts index 57c70fc5..a7dc332d 100644 --- a/packages/core/src/api/actor.api.ts +++ b/packages/core/src/api/actor.api.ts @@ -3,18 +3,18 @@ import type {_SERVICE as SatelliteActor} from '../../declarations/satellite/sate import {idlFactory} from '../../declarations/satellite/satellite.factory.did.js'; import type {Satellite} from '../types/satellite.types'; import {createActor} from '../utils/actor.utils'; -import {mapContainer, mapSatelliteId} from '../utils/env.utils'; +import {customOrEnvContainer, customOrEnvSatelliteId} from '../utils/env.utils'; export const getSatelliteActor = async ({ satelliteId: customSatelliteId, container: customContainer, ...rest }: Satellite): Promise => { - const {satelliteId} = mapSatelliteId({satelliteId: customSatelliteId}); + const {satelliteId} = customOrEnvSatelliteId({satelliteId: customSatelliteId}); assertNonNullish(satelliteId, 'No satellite principal defined.'); - const {container} = mapContainer({container: customContainer}); + const {container} = customOrEnvContainer({container: customContainer}); return createActor({ satelliteId, diff --git a/packages/core/src/utils/env.utils.ts b/packages/core/src/utils/env.utils.ts index 6ec72c5f..c5008f2d 100644 --- a/packages/core/src/utils/env.utils.ts +++ b/packages/core/src/utils/env.utils.ts @@ -7,8 +7,8 @@ export const satelliteUrl = ({ satelliteId: customSatelliteId, container: customContainer }: Satellite): string => { - const {satelliteId} = mapSatelliteId({satelliteId: customSatelliteId}); - const {container} = mapContainer({container: customContainer}); + const {satelliteId} = customOrEnvSatelliteId({satelliteId: customSatelliteId}); + const {container} = customOrEnvContainer({container: customContainer}); if (nonNullish(container) && container !== false) { const {host: containerHost, protocol} = new URL( @@ -20,14 +20,14 @@ export const satelliteUrl = ({ return `https://${satelliteId ?? 'unknown'}.icp0.io`; }; -export const mapSatelliteId = ({ +export const customOrEnvSatelliteId = ({ satelliteId }: Pick): Pick => nonNullish(satelliteId) ? {satelliteId} : EnvStore.getInstance().get() ?? {satelliteId: undefined}; -export const mapContainer = ({ +export const customOrEnvContainer = ({ container: customContainer }: Pick): Pick => nonNullish(customContainer)