From 5be167b2b58cf8faedeb3f7014e841291491065e Mon Sep 17 00:00:00 2001 From: Karlie Li Date: Wed, 17 Jul 2024 18:14:42 -0700 Subject: [PATCH] fix circular dependency --- .../offline-channel-js/src/Helpers/Utils.ts | 17 ++++++++++++++--- .../offline-channel-js/src/OfflineChannel.ts | 3 +-- .../src/Providers/IndexDbProvider.ts | 15 ++------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/channels/offline-channel-js/src/Helpers/Utils.ts b/channels/offline-channel-js/src/Helpers/Utils.ts index 4b4a72b13..856241b16 100644 --- a/channels/offline-channel-js/src/Helpers/Utils.ts +++ b/channels/offline-channel-js/src/Helpers/Utils.ts @@ -2,10 +2,21 @@ // Licensed under the MIT License. import { EventPersistence } from "@microsoft/applicationinsights-common"; -import { INotificationManager, ITelemetryItem, NotificationManager, generateW3CId } from "@microsoft/applicationinsights-core-js"; -import { isString, objKeys, strSubstr } from "@nevware21/ts-utils"; +import { + INotificationManager, ITelemetryItem, NotificationManager, eLoggingSeverity, generateW3CId +} from "@microsoft/applicationinsights-core-js"; +import { isNumber, isString, objKeys, strSubstr } from "@nevware21/ts-utils"; import { IPostTransmissionTelemetryItem } from "../Interfaces/IInMemoryBatch"; -import { isValidPersistenceLevel } from "../Providers/IndexDbProvider"; + +/** +* Checks if the value is a valid EventPersistence. +* @param {enum} value - The value that needs to be checked. +* @return {boolean} True if the value is in EventPersistence, false otherwise. +*/ +export function isValidPersistenceLevel(value: EventPersistence | number): boolean { + return (isNumber(value) && value >= eLoggingSeverity.DISABLED && value <= EventPersistence.Critical); +} + // Endpoint schema // . diff --git a/channels/offline-channel-js/src/OfflineChannel.ts b/channels/offline-channel-js/src/OfflineChannel.ts index 23562d893..e4d133750 100644 --- a/channels/offline-channel-js/src/OfflineChannel.ts +++ b/channels/offline-channel-js/src/OfflineChannel.ts @@ -15,7 +15,7 @@ import { import { IPromise, ITaskScheduler, createAsyncPromise, createTaskScheduler } from "@nevware21/ts-async"; import { ITimerHandler, isFunction, isString, objDeepFreeze, scheduleTimeout } from "@nevware21/ts-utils"; import { - EVT_DISCARD_STR, EVT_SENT_STR, EVT_STORE_STR, batchDropNotification, callNotification, isGreaterThanZero + EVT_DISCARD_STR, EVT_SENT_STR, EVT_STORE_STR, batchDropNotification, callNotification, isGreaterThanZero, isValidPersistenceLevel } from "./Helpers/Utils"; import { InMemoryBatch } from "./InMemoryBatch"; import { IPostTransmissionTelemetryItem } from "./Interfaces/IInMemoryBatch"; @@ -26,7 +26,6 @@ import { ILocalStorageProviderContext, IOfflineChannelConfiguration, IOfflineSenderConfig, IStorageTelemetryItem, eStorageProviders } from "./Interfaces/IOfflineProvider"; import { OfflineBatchHandler } from "./OfflineBatchHandler"; -import { isValidPersistenceLevel } from "./Providers/IndexDbProvider"; import { Sender } from "./Sender"; const version = "#version#"; diff --git a/channels/offline-channel-js/src/Providers/IndexDbProvider.ts b/channels/offline-channel-js/src/Providers/IndexDbProvider.ts index 790058fa2..96885ac0b 100644 --- a/channels/offline-channel-js/src/Providers/IndexDbProvider.ts +++ b/channels/offline-channel-js/src/Providers/IndexDbProvider.ts @@ -2,10 +2,9 @@ // Licensed under the MIT License. import dynamicProto from "@microsoft/dynamicproto-js"; -import { EventPersistence } from "@microsoft/applicationinsights-common"; import { - INotificationManager, IProcessTelemetryContext, IUnloadHookContainer, eBatchDiscardedReason, eLoggingSeverity, isNotNullOrUndefined, - isNumber, isString, newGuid, onConfigChange + INotificationManager, IProcessTelemetryContext, IUnloadHookContainer, eBatchDiscardedReason, isNotNullOrUndefined, isString, newGuid, + onConfigChange } from "@microsoft/applicationinsights-core-js"; import { IPromise, createAsyncAllPromise, createAsyncPromise, doAwait, doAwaitResponse } from "@nevware21/ts-async"; import { batchDropNotification, getEndpointDomain, getTimeFromId, getTimeId } from "../Helpers/Utils"; @@ -30,16 +29,6 @@ export const DbVersion = 1; // The Current version of th export const EventObjectStoreName = "Evts"; -/** -* Checks if the value is a valid EventPersistence. -* @param {enum} value - The value that needs to be checked. -* @return {boolean} True if the value is in EventPersistence, false otherwise. -*/ -export function isValidPersistenceLevel(value: EventPersistence | number): boolean { - return (isNumber(value) && value >= eLoggingSeverity.DISABLED && value <= EventPersistence.Critical); -} - - /** * The format of the data stored in the iKey objectStore */