From 94334bd11d1cf0ae6cc12cb858658acbffef0fe4 Mon Sep 17 00:00:00 2001 From: Jonathan Norris Date: Tue, 24 Oct 2023 15:55:01 -0400 Subject: [PATCH] feat: DVC-9059 pull out EnvironmentConfigManager to its own library, change nodejs build to define external pacakges (#564) --- lib/shared/config-manager/.eslintrc.json | 18 +++++++ lib/shared/config-manager/README.md | 12 +++++ .../config-manager}/__mocks__/cross-fetch.ts | 0 .../config-manager}/__mocks__/fetch-retry.ts | 0 .../environmentConfigManager.spec.ts | 52 ++++++++++++------- .../config-manager}/__tests__/request.spec.ts | 5 +- lib/shared/config-manager/jest.config.ts | 13 +++++ lib/shared/config-manager/package.json | 10 ++++ lib/shared/config-manager/project.json | 41 +++++++++++++++ .../shared/config-manager/src/index.ts | 38 +++++++++++--- lib/shared/config-manager/src/request.ts | 38 ++++++++++++++ lib/shared/config-manager/tsconfig.json | 13 +++++ lib/shared/config-manager/tsconfig.lib.json | 10 ++++ lib/shared/config-manager/tsconfig.spec.json | 14 +++++ sdk/nodejs/__tests__/client.spec.ts | 2 +- sdk/nodejs/__tests__/initialize.spec.ts | 2 +- sdk/nodejs/package.json | 5 +- sdk/nodejs/project.json | 9 +++- sdk/nodejs/src/bucketing.ts | 8 +++ sdk/nodejs/src/client.ts | 11 +++- sdk/nodejs/src/request.ts | 19 ------- sdk/nodejs/tsconfig.lib.json | 1 + tsconfig.base.json | 3 ++ yarn.lock | 16 +++++- 24 files changed, 282 insertions(+), 58 deletions(-) create mode 100644 lib/shared/config-manager/.eslintrc.json create mode 100644 lib/shared/config-manager/README.md rename {sdk/nodejs => lib/shared/config-manager}/__mocks__/cross-fetch.ts (100%) rename {sdk/nodejs => lib/shared/config-manager}/__mocks__/fetch-retry.ts (100%) rename {sdk/nodejs => lib/shared/config-manager}/__tests__/environmentConfigManager.spec.ts (83%) rename {sdk/nodejs => lib/shared/config-manager}/__tests__/request.spec.ts (87%) create mode 100644 lib/shared/config-manager/jest.config.ts create mode 100644 lib/shared/config-manager/package.json create mode 100644 lib/shared/config-manager/project.json rename sdk/nodejs/src/environmentConfigManager.ts => lib/shared/config-manager/src/index.ts (77%) create mode 100644 lib/shared/config-manager/src/request.ts create mode 100644 lib/shared/config-manager/tsconfig.json create mode 100644 lib/shared/config-manager/tsconfig.lib.json create mode 100644 lib/shared/config-manager/tsconfig.spec.json diff --git a/lib/shared/config-manager/.eslintrc.json b/lib/shared/config-manager/.eslintrc.json new file mode 100644 index 000000000..9761c5638 --- /dev/null +++ b/lib/shared/config-manager/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/lib/shared/config-manager/README.md b/lib/shared/config-manager/README.md new file mode 100644 index 000000000..d7e67356b --- /dev/null +++ b/lib/shared/config-manager/README.md @@ -0,0 +1,12 @@ +# config-manager + +This library extracts the `EnvironmentConfigManager` Server SDK logic to be used across the NodeJS SDK +and Edge Worker SDKs. + +## Building + +Run `nx build config-manager` to build the library. + +## Running unit tests + +Run `nx test config-manager` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/sdk/nodejs/__mocks__/cross-fetch.ts b/lib/shared/config-manager/__mocks__/cross-fetch.ts similarity index 100% rename from sdk/nodejs/__mocks__/cross-fetch.ts rename to lib/shared/config-manager/__mocks__/cross-fetch.ts diff --git a/sdk/nodejs/__mocks__/fetch-retry.ts b/lib/shared/config-manager/__mocks__/fetch-retry.ts similarity index 100% rename from sdk/nodejs/__mocks__/fetch-retry.ts rename to lib/shared/config-manager/__mocks__/fetch-retry.ts diff --git a/sdk/nodejs/__tests__/environmentConfigManager.spec.ts b/lib/shared/config-manager/__tests__/environmentConfigManager.spec.ts similarity index 83% rename from sdk/nodejs/__tests__/environmentConfigManager.spec.ts rename to lib/shared/config-manager/__tests__/environmentConfigManager.spec.ts index 031b55803..5dbc0b812 100644 --- a/sdk/nodejs/__tests__/environmentConfigManager.spec.ts +++ b/lib/shared/config-manager/__tests__/environmentConfigManager.spec.ts @@ -1,23 +1,40 @@ jest.mock('../src/request') jest.useFakeTimers() jest.spyOn(global, 'setInterval') -jest.mock('../src/bucketing') -import { EnvironmentConfigManager } from '../src/environmentConfigManager' -import { importBucketingLib, getBucketingLib } from '../src/bucketing' +import { EnvironmentConfigManager } from '../src' import { mocked } from 'jest-mock' import { Response } from 'cross-fetch' -import { dvcDefaultLogger, ResponseError } from '@devcycle/js-cloud-server-sdk' +import { + DevCycleOptions, + dvcDefaultLogger, + ResponseError, +} from '@devcycle/js-cloud-server-sdk' +import { DVCLogger } from '@devcycle/types' import { getEnvironmentConfig } from '../src/request' const setInterval_mock = mocked(setInterval) const getEnvironmentConfig_mock = mocked(getEnvironmentConfig) const logger = dvcDefaultLogger() +const mockSDKConfig = jest.fn() + +function getConfigManager( + logger: DVCLogger, + sdkKey: string, + options: DevCycleOptions, +) { + return new EnvironmentConfigManager( + logger, + sdkKey, + mockSDKConfig, + setInterval, + clearInterval, + options, + ) +} + describe('EnvironmentConfigManager Unit Tests', () => { - beforeAll(async () => { - await importBucketingLib() - }) beforeEach(() => { getEnvironmentConfig_mock.mockReset() setInterval_mock.mockReset() @@ -43,7 +60,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 200 }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', { + const envConfig = getConfigManager(logger, 'sdkKey', { configPollingIntervalMS: 1000, configPollingTimeoutMS: 1000, }) @@ -51,10 +68,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { expect(setInterval_mock).toHaveBeenCalledTimes(1) await envConfig._fetchConfig() - expect(getBucketingLib().setConfigDataUTF8).toHaveBeenCalledWith( - 'sdkKey', - Buffer.from('{}', 'utf8'), - ) + expect(mockSDKConfig).toHaveBeenCalledWith('sdkKey', '{}') expect(envConfig).toEqual( expect.objectContaining({ @@ -72,7 +86,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 200 }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', { + const envConfig = getConfigManager(logger, 'sdkKey', { configPollingIntervalMS: 10, configPollingTimeoutMS: 10000, }) @@ -97,7 +111,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 200 }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', { + const envConfig = getConfigManager(logger, 'sdkKey', { configPollingIntervalMS: 1000, configPollingTimeoutMS: 1000, }) @@ -129,7 +143,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 500 }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', {}) + const envConfig = getConfigManager(logger, 'sdkKey', {}) expect(envConfig.fetchConfigPromise).rejects.toThrow( 'Failed to download DevCycle config.', ) @@ -140,7 +154,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 403 }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', {}) + const envConfig = getConfigManager(logger, 'sdkKey', {}) expect(envConfig.fetchConfigPromise).rejects.toThrow( 'Invalid SDK key provided:', ) @@ -150,7 +164,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { it('should throw error fetching config throws', () => { getEnvironmentConfig_mock.mockRejectedValue(new Error('Error')) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', {}) + const envConfig = getConfigManager(logger, 'sdkKey', {}) expect(envConfig.fetchConfigPromise).rejects.toThrow( 'Failed to download DevCycle config.', ) @@ -162,7 +176,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 200, data: config }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', { + const envConfig = getConfigManager(logger, 'sdkKey', { configPollingIntervalMS: 1000, configPollingTimeoutMS: 1000, }) @@ -184,7 +198,7 @@ describe('EnvironmentConfigManager Unit Tests', () => { mockFetchResponse({ status: 500 }), ) - const envConfig = new EnvironmentConfigManager(logger, 'sdkKey', {}) + const envConfig = getConfigManager(logger, 'sdkKey', {}) await expect(envConfig.fetchConfigPromise).rejects.toThrow() expect(setInterval_mock).toHaveBeenCalledTimes(1) }) diff --git a/sdk/nodejs/__tests__/request.spec.ts b/lib/shared/config-manager/__tests__/request.spec.ts similarity index 87% rename from sdk/nodejs/__tests__/request.spec.ts rename to lib/shared/config-manager/__tests__/request.spec.ts index c9ed0b37d..4c06f69b6 100644 --- a/sdk/nodejs/__tests__/request.spec.ts +++ b/lib/shared/config-manager/__tests__/request.spec.ts @@ -3,12 +3,9 @@ import fetch, { Response } from 'cross-fetch' global.fetch = fetch +import { getEnvironmentConfig } from '../src/request' const fetchRequestMock = fetch as jest.MockedFn -import { publishEvents, getEnvironmentConfig } from '../src/request' -import { dvcDefaultLogger } from '@devcycle/js-cloud-server-sdk' -const logger = dvcDefaultLogger() - describe('request.ts Unit Tests', () => { beforeEach(() => { fetchRequestMock.mockReset() diff --git a/lib/shared/config-manager/jest.config.ts b/lib/shared/config-manager/jest.config.ts new file mode 100644 index 000000000..23c054a9b --- /dev/null +++ b/lib/shared/config-manager/jest.config.ts @@ -0,0 +1,13 @@ +/* eslint-disable */ +export default { + displayName: 'config-manager', + preset: '../../../jest.preset.js', + transform: { + '^.+\\.[tj]s$': [ + 'ts-jest', + { tsconfig: '/tsconfig.spec.json' }, + ], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../../coverage/lib/shared/config-manager', +} diff --git a/lib/shared/config-manager/package.json b/lib/shared/config-manager/package.json new file mode 100644 index 000000000..fe3796d9c --- /dev/null +++ b/lib/shared/config-manager/package.json @@ -0,0 +1,10 @@ +{ + "name": "@devcycle/config-manager", + "private": true, + "version": "1.0.0", + "type": "commonjs", + "dependencies": { + "@devcycle/js-cloud-server-sdk": "^1.0.0", + "@devcycle/types": "^1.1.15" + } +} diff --git a/lib/shared/config-manager/project.json b/lib/shared/config-manager/project.json new file mode 100644 index 000000000..3c2662afd --- /dev/null +++ b/lib/shared/config-manager/project.json @@ -0,0 +1,41 @@ +{ + "name": "config-manager", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "lib/shared/config-manager/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/lib/shared/config-manager", + "main": "lib/shared/config-manager/src/index.ts", + "tsConfig": "lib/shared/config-manager/tsconfig.lib.json", + "assets": ["lib/shared/config-manager/*.md"], + "external": ["shared-types", "js-cloud-server-sdk"] + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["lib/shared/config-manager/**/*.ts"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "lib/shared/config-manager/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + } + }, + "tags": [] +} diff --git a/sdk/nodejs/src/environmentConfigManager.ts b/lib/shared/config-manager/src/index.ts similarity index 77% rename from sdk/nodejs/src/environmentConfigManager.ts rename to lib/shared/config-manager/src/index.ts index e525eaecd..617be268a 100644 --- a/sdk/nodejs/src/environmentConfigManager.ts +++ b/lib/shared/config-manager/src/index.ts @@ -1,6 +1,5 @@ import { DVCLogger } from '@devcycle/types' -import { getBucketingLib } from './bucketing' -import { UserError } from './utils/userError' +// import { UserError } from './utils/userError' import { getEnvironmentConfig } from './request' import { ResponseError, DevCycleOptions } from '@devcycle/js-cloud-server-sdk' @@ -8,6 +7,19 @@ type ConfigPollingOptions = DevCycleOptions & { cdnURI?: string } +type SetIntervalInterface = (handler: () => void, timeout?: number) => any +type ClearIntervalInterface = (intervalTimeout: any) => void + +type SetConfigBuffer = (sdkKey: string, projectConfig: string) => void + +export class UserError extends Error { + constructor(error: Error | string) { + super(error instanceof Error ? error.message : error) + this.name = 'UserError' + this.stack = error instanceof Error ? error.stack : undefined + } +} + export class EnvironmentConfigManager { private readonly logger: DVCLogger private readonly sdkKey: string @@ -17,12 +29,18 @@ export class EnvironmentConfigManager { private readonly requestTimeoutMS: number private readonly cdnURI: string fetchConfigPromise: Promise - private intervalTimeout?: NodeJS.Timeout + private intervalTimeout?: any private disablePolling = false + private readonly setConfigBuffer: SetConfigBuffer + private readonly setInterval: SetIntervalInterface + private readonly clearInterval: ClearIntervalInterface constructor( logger: DVCLogger, sdkKey: string, + setConfigBuffer: SetConfigBuffer, + setInterval: SetIntervalInterface, + clearInterval: ClearIntervalInterface, { configPollingIntervalMS = 10000, configPollingTimeoutMS = 5000, @@ -32,6 +50,11 @@ export class EnvironmentConfigManager { ) { this.logger = logger this.sdkKey = sdkKey + + this.setConfigBuffer = setConfigBuffer + this.setInterval = setInterval + this.clearInterval = clearInterval + this.pollingIntervalMS = configPollingIntervalMS >= 1000 ? configPollingIntervalMS : 1000 this.requestTimeoutMS = @@ -48,11 +71,11 @@ export class EnvironmentConfigManager { if (this.disablePolling) { return } - this.intervalTimeout = setInterval(async () => { + this.intervalTimeout = this.setInterval(async () => { try { await this._fetchConfig() } catch (ex) { - this.logger.error(ex.message) + this.logger.error((ex as Error).message) } }, this.pollingIntervalMS) }) @@ -60,7 +83,7 @@ export class EnvironmentConfigManager { stopPolling(): void { this.disablePolling = true - clearInterval(this.intervalTimeout) + this.clearInterval(this.intervalTimeout) } cleanup(): void { @@ -119,8 +142,7 @@ export class EnvironmentConfigManager { } else if (res?.status === 200 && projectConfig) { try { const etag = res?.headers.get('etag') || '' - const configBuffer = Buffer.from(projectConfig, 'utf8') - getBucketingLib().setConfigDataUTF8(this.sdkKey, configBuffer) + this.setConfigBuffer(this.sdkKey, projectConfig) this.hasConfig = true this.configEtag = etag return diff --git a/lib/shared/config-manager/src/request.ts b/lib/shared/config-manager/src/request.ts new file mode 100644 index 000000000..84e621f7e --- /dev/null +++ b/lib/shared/config-manager/src/request.ts @@ -0,0 +1,38 @@ +import { RequestInitWithRetry } from 'fetch-retry' +import { get } from '@devcycle/js-cloud-server-sdk' + +export async function getEnvironmentConfig( + url: string, + requestTimeout: number, + etag?: string, +): Promise { + const headers: Record = etag + ? { 'If-None-Match': etag } + : {} + + return await getWithTimeout( + url, + { + headers: headers, + retries: 1, + }, + requestTimeout, + ) +} + +async function getWithTimeout( + url: string, + requestConfig: RequestInit | RequestInitWithRetry, + timeout: number, +): Promise { + const controller = new AbortController() + const id = setTimeout(() => { + controller.abort() + }, timeout) + const response = await get(url, { + ...requestConfig, + signal: controller.signal, + }) + clearTimeout(id) + return response +} diff --git a/lib/shared/config-manager/tsconfig.json b/lib/shared/config-manager/tsconfig.json new file mode 100644 index 000000000..b8b7b3ce4 --- /dev/null +++ b/lib/shared/config-manager/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/lib/shared/config-manager/tsconfig.lib.json b/lib/shared/config-manager/tsconfig.lib.json new file mode 100644 index 000000000..fcf1bcdb3 --- /dev/null +++ b/lib/shared/config-manager/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "declaration": true, + "types": [] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/lib/shared/config-manager/tsconfig.spec.json b/lib/shared/config-manager/tsconfig.spec.json new file mode 100644 index 000000000..adff492c1 --- /dev/null +++ b/lib/shared/config-manager/tsconfig.spec.json @@ -0,0 +1,14 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "src/**/*.test.ts", + "src/**/*.spec.ts", + "src/**/*.d.ts" + ] +} diff --git a/sdk/nodejs/__tests__/client.spec.ts b/sdk/nodejs/__tests__/client.spec.ts index 84b052e96..dd51dc3ef 100644 --- a/sdk/nodejs/__tests__/client.spec.ts +++ b/sdk/nodejs/__tests__/client.spec.ts @@ -4,7 +4,7 @@ import { DevCycleClient } from '../src/client' import { DevCycleUser } from '@devcycle/js-cloud-server-sdk' jest.mock('../src/bucketing') -jest.mock('../src/environmentConfigManager') +jest.mock('@devcycle/config-manager') jest.mock('../src/eventQueue') describe('DevCycleClient', () => { diff --git a/sdk/nodejs/__tests__/initialize.spec.ts b/sdk/nodejs/__tests__/initialize.spec.ts index 63ea6e33f..492d42685 100644 --- a/sdk/nodejs/__tests__/initialize.spec.ts +++ b/sdk/nodejs/__tests__/initialize.spec.ts @@ -5,7 +5,7 @@ import { } from '../src/index' jest.mock('../src/bucketing') -jest.mock('../src/environmentConfigManager') +jest.mock('@devcycle/config-manager') describe('NodeJS SDK Initialize', () => { afterAll(() => { diff --git a/sdk/nodejs/package.json b/sdk/nodejs/package.json index 8f16a9556..493b84157 100644 --- a/sdk/nodejs/package.json +++ b/sdk/nodejs/package.json @@ -7,7 +7,10 @@ "@devcycle/bucketing-test-data": "^1.2.22" }, "dependencies": { - "@devcycle/bucketing-assembly-script": "^1.8.4" + "@devcycle/bucketing-assembly-script": "^1.8.4", + "@devcycle/js-cloud-server-sdk": "^1.0.0", + "@devcycle/types": "^1.1.15", + "fetch-retry": "^5.0.3" }, "engines": { "node": ">=14.0.0" diff --git a/sdk/nodejs/project.json b/sdk/nodejs/project.json index 6ab19a2bc..3f9aa3ed5 100644 --- a/sdk/nodejs/project.json +++ b/sdk/nodejs/project.json @@ -48,7 +48,14 @@ "packageJson": "sdk/nodejs/package.json", "buildableProjectDepsInPackageJsonType": "dependencies", "main": "sdk/nodejs/src/index.ts", - "assets": ["sdk/nodejs/*.md"] + "assets": ["sdk/nodejs/*.md"], + // External pacakges now need to be defined here, all other pacakges will be compiled into the sdk. + "external": [ + "shared-types", + "shared-bucketing-as", + "shared-bucketing-test-data", + "js-cloud-server-sdk" + ] }, "dependsOn": [ { diff --git a/sdk/nodejs/src/bucketing.ts b/sdk/nodejs/src/bucketing.ts index 0aad75849..aa4c08f74 100644 --- a/sdk/nodejs/src/bucketing.ts +++ b/sdk/nodejs/src/bucketing.ts @@ -55,3 +55,11 @@ export const getBucketingLib = (): Exports => { export const cleanupBucketingLib = (): void => { Bucketing = null } + +export const setConfigDataUTF8 = ( + sdkKey: string, + projectConfigStr: string, +): void => { + const configBuffer = Buffer.from(projectConfigStr, 'utf8') + getBucketingLib().setConfigDataUTF8(sdkKey, configBuffer) +} diff --git a/sdk/nodejs/src/client.ts b/sdk/nodejs/src/client.ts index 61afebc4e..27842e0e3 100644 --- a/sdk/nodejs/src/client.ts +++ b/sdk/nodejs/src/client.ts @@ -1,4 +1,4 @@ -import { EnvironmentConfigManager } from './environmentConfigManager' +import { EnvironmentConfigManager } from '@devcycle/config-manager' import { bucketUserForConfig, getVariableTypeCode, @@ -6,7 +6,11 @@ import { } from './utils/userBucketingHelper' import { EventQueue, EventTypes } from './eventQueue' import * as packageJson from '../package.json' -import { importBucketingLib, getBucketingLib } from './bucketing' +import { + importBucketingLib, + getBucketingLib, + setConfigDataUTF8, +} from './bucketing' import { DVCLogger, getVariableTypeFromValue, @@ -73,6 +77,9 @@ export class DevCycleClient { this.configHelper = new EnvironmentConfigManager( this.logger, sdkKey, + setConfigDataUTF8, + setInterval, + clearInterval, options || {}, ) this.eventQueue = new EventQueue(sdkKey, { diff --git a/sdk/nodejs/src/request.ts b/sdk/nodejs/src/request.ts index 01d31d3f9..a7c0829b2 100644 --- a/sdk/nodejs/src/request.ts +++ b/sdk/nodejs/src/request.ts @@ -6,25 +6,6 @@ export const HOST = '.devcycle.com' export const EVENT_URL = 'https://events' export const EVENTS_PATH = '/v1/events/batch' -export async function getEnvironmentConfig( - url: string, - requestTimeout: number, - etag?: string, -): Promise { - const headers: Record = etag - ? { 'If-None-Match': etag } - : {} - - return await getWithTimeout( - url, - { - headers: headers, - retries: 1, - }, - requestTimeout, - ) -} - export async function publishEvents( logger: DVCLogger, sdkKey: string, diff --git a/sdk/nodejs/tsconfig.lib.json b/sdk/nodejs/tsconfig.lib.json index 68eae97f1..cc88f3e56 100644 --- a/sdk/nodejs/tsconfig.lib.json +++ b/sdk/nodejs/tsconfig.lib.json @@ -10,6 +10,7 @@ "**/*.spec.ts", "**/*.test.ts", "**/__mocks__/**/*.ts", + "**/__tests__/**/*.ts", "jest.config.ts" ], "include": ["**/*.ts"] diff --git a/tsconfig.base.json b/tsconfig.base.json index 68217c78c..917528ac8 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -25,6 +25,9 @@ "@devcycle/bucketing-test-data": [ "lib/shared/bucketing-test-data/src/index.ts" ], + "@devcycle/config-manager": [ + "lib/shared/config-manager/src/index.ts" + ], "@devcycle/js-client-sdk": ["sdk/js/src/index.ts"], "@devcycle/js-cloud-server-sdk": [ "sdk/js-cloud-server/src/index.ts" diff --git a/yarn.lock b/yarn.lock index b44938dcf..586aab80d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4879,6 +4879,15 @@ __metadata: languageName: unknown linkType: soft +"@devcycle/config-manager@workspace:lib/shared/config-manager": + version: 0.0.0-use.local + resolution: "@devcycle/config-manager@workspace:lib/shared/config-manager" + dependencies: + "@devcycle/js-cloud-server-sdk": ^1.0.0 + "@devcycle/types": ^1.1.15 + languageName: unknown + linkType: soft + "@devcycle/js-client-sdk-web-example@workspace:examples/js/web-elements-app": version: 0.0.0-use.local resolution: "@devcycle/js-client-sdk-web-example@workspace:examples/js/web-elements-app" @@ -4891,7 +4900,7 @@ __metadata: languageName: unknown linkType: soft -"@devcycle/js-cloud-server-sdk@1.0.0, @devcycle/js-cloud-server-sdk@workspace:sdk/js-cloud-server": +"@devcycle/js-cloud-server-sdk@1.0.0, @devcycle/js-cloud-server-sdk@^1.0.0, @devcycle/js-cloud-server-sdk@workspace:sdk/js-cloud-server": version: 0.0.0-use.local resolution: "@devcycle/js-cloud-server-sdk@workspace:sdk/js-cloud-server" dependencies: @@ -4933,6 +4942,9 @@ __metadata: dependencies: "@devcycle/bucketing-assembly-script": ^1.8.4 "@devcycle/bucketing-test-data": ^1.2.22 + "@devcycle/js-cloud-server-sdk": ^1.0.0 + "@devcycle/types": ^1.1.15 + fetch-retry: ^5.0.3 languageName: unknown linkType: soft @@ -4985,7 +4997,7 @@ __metadata: languageName: unknown linkType: soft -"@devcycle/types@workspace:lib/shared/types": +"@devcycle/types@^1.1.15, @devcycle/types@workspace:lib/shared/types": version: 0.0.0-use.local resolution: "@devcycle/types@workspace:lib/shared/types" languageName: unknown