From b537c902aca495302672967b637db0181c08b3e4 Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 30 Nov 2023 16:36:29 -0500 Subject: [PATCH] chore: migrate from js-sdk to server-sdk (#258) Signed-off-by: Michael Beemer --- package-lock.json | 47 ++++++++++++++----- package.json | 12 ++--- packages/app/src/app/app.module.ts | 2 +- .../src/app/fibonacci/fibonacci.service.ts | 2 +- .../src/app/transaction-context.middleware.ts | 2 +- .../fibonacci-service/src/app/app.module.ts | 2 +- .../src/app/transaction-context.middleware.ts | 2 +- packages/fibonacci/src/lib/fibonacci.ts | 2 +- .../src/lib/flagsmith.ts | 12 ++++- .../src/lib/js-harness-provider.ts | 2 +- .../src/lib/js-launchdarkly-provider.ts | 4 +- .../src/lib/js-split-provider.ts | 6 +-- .../src/lib/hooks/class-validator-hook.ts | 2 +- .../src/lib/hooks/logging-hook.ts | 2 +- packages/openfeature-extra/src/lib/logger.ts | 2 +- .../async-local-storage.ts | 2 +- .../src/lib/openfeature-propagator.ts | 2 +- packages/provider/src/lib/provider.service.ts | 2 +- packages/utils/src/lib/parse-valid-boolean.ts | 2 +- .../utils/src/lib/parse-valid-json-object.ts | 2 +- packages/utils/src/lib/parse-valid-number.ts | 2 +- 21 files changed, 72 insertions(+), 41 deletions(-) diff --git a/package-lock.json b/package-lock.json index cddcf342..9e57428b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,13 +16,13 @@ "@nestjs/core": "9.4.3", "@nestjs/platform-express": "9.4.3", "@nestjs/serve-static": "^3.0.0", - "@openfeature/env-var-provider": "^0.1.1", - "@openfeature/flagd-provider": "^0.8.2", + "@openfeature/env-var-provider": "^0.2.0", + "@openfeature/flagd-provider": "^0.8.3", "@openfeature/flagd-web-provider": "^0.4.0", - "@openfeature/go-feature-flag-provider": "^0.5.14", - "@openfeature/js-sdk": "^1.4.1", - "@openfeature/open-telemetry-hooks": "^0.2.3", - "@openfeature/web-sdk": "0.4.0", + "@openfeature/go-feature-flag-provider": "^0.5.16", + "@openfeature/open-telemetry-hooks": "^0.2.4", + "@openfeature/server-sdk": "^1.7.4", + "@openfeature/web-sdk": "0.4.7", "@opentelemetry/api": "~1.6.0", "@opentelemetry/auto-instrumentations-node": "^0.39.2", "@opentelemetry/exporter-metrics-otlp-grpc": "^0.43.0", @@ -5472,12 +5472,18 @@ "node": ">=8" } }, + "node_modules/@openfeature/core": { + "version": "0.0.20", + "resolved": "https://registry.npmjs.org/@openfeature/core/-/core-0.0.20.tgz", + "integrity": "sha512-YVokonIlYYqIV/ozp1/Td4n5j62biNC7+TvDpAFavNCUm6ULp7oT1sxCPbQhMGv+iS7nb3CSRXGDPykSjTDDoA==", + "peer": true + }, "node_modules/@openfeature/env-var-provider": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@openfeature/env-var-provider/-/env-var-provider-0.1.1.tgz", - "integrity": "sha512-BbQLyfus3ACxnt4iEONEUgysgQKz6gI7tz2m6q07eCbO6RGrk9VMmmEwxx8Rg8MPdOQIdzwsCLfn4g9WtdWTEA==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@openfeature/env-var-provider/-/env-var-provider-0.2.0.tgz", + "integrity": "sha512-ZlO4PkJ/k2xcRHTbrt6oGg8QY+fKqVpf1XHXZQDunyvvXKLLWNzUFcA33s5vHJFs71D+hG2M23LmDhRqnKalOg==", "peerDependencies": { - "@openfeature/js-sdk": "^1.0.0" + "@openfeature/server-sdk": "^1.6.0" } }, "node_modules/@openfeature/flagd-provider": { @@ -5551,6 +5557,7 @@ "resolved": "https://registry.npmjs.org/@openfeature/js-sdk/-/js-sdk-1.6.1.tgz", "integrity": "sha512-IMxkVxpAiiMfmqQXLsMlePb0/NtmmuisOcA27LGjJy7dXRqafNpJlzJXxSsGou1+/DtrFOVkJ/Udc1adNfXaFg==", "deprecated": "This package has been moved to @openfeature/server-sdk", + "peer": true, "engines": { "node": ">=16" } @@ -5564,10 +5571,24 @@ "@opentelemetry/api": ">=1.3.0" } }, + "node_modules/@openfeature/server-sdk": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@openfeature/server-sdk/-/server-sdk-1.7.4.tgz", + "integrity": "sha512-xOMNdFk+K8cn0Sh6TlooXm8V1/qW2KrNRB2q2ysmoLcwoMRwsqEhSTuBNxmnVC82SVpVUa3MOvusmF4V4JLgNg==", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@openfeature/core": "0.0.20" + } + }, "node_modules/@openfeature/web-sdk": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@openfeature/web-sdk/-/web-sdk-0.4.0.tgz", - "integrity": "sha512-k14SBiGCwPSQ9zhFfK2/oslUNrvfd/hleD2WfiKi69YDcWnsUqGeeXvvE4KI6FS54GJgXlNVpfqDQ4gUHbywHQ==" + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/@openfeature/web-sdk/-/web-sdk-0.4.7.tgz", + "integrity": "sha512-KdIx2XITfpfQ92FyioNaf0M5kTvRk9JHlvRUoaLjrUvuA5JQBOaZUjA2jwI6HNKuGuTVLrA1FmzVy0Day2QKOw==", + "peerDependencies": { + "@openfeature/core": "0.0.20" + } }, "node_modules/@opentelemetry/api": { "version": "1.6.0", diff --git a/package.json b/package.json index f00209af..80be2e16 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,13 @@ "@nestjs/core": "9.4.3", "@nestjs/platform-express": "9.4.3", "@nestjs/serve-static": "^3.0.0", - "@openfeature/env-var-provider": "^0.1.1", - "@openfeature/flagd-provider": "^0.8.2", + "@openfeature/env-var-provider": "^0.2.0", + "@openfeature/flagd-provider": "^0.8.3", "@openfeature/flagd-web-provider": "^0.4.0", - "@openfeature/go-feature-flag-provider": "^0.5.14", - "@openfeature/js-sdk": "^1.4.1", - "@openfeature/open-telemetry-hooks": "^0.2.3", - "@openfeature/web-sdk": "0.4.0", + "@openfeature/go-feature-flag-provider": "^0.5.16", + "@openfeature/open-telemetry-hooks": "^0.2.4", + "@openfeature/server-sdk": "^1.7.4", + "@openfeature/web-sdk": "0.4.7", "@opentelemetry/api": "~1.6.0", "@opentelemetry/auto-instrumentations-node": "^0.39.2", "@opentelemetry/exporter-metrics-otlp-grpc": "^0.43.0", diff --git a/packages/app/src/app/app.module.ts b/packages/app/src/app/app.module.ts index 8b94eeb5..b52a60fa 100644 --- a/packages/app/src/app/app.module.ts +++ b/packages/app/src/app/app.module.ts @@ -3,7 +3,7 @@ import {MiddlewareConsumer, Module, NestModule, Scope} from '@nestjs/common'; import {REQUEST} from '@nestjs/core'; import {ServeStaticModule} from '@nestjs/serve-static'; import {AsyncLocalStorageTransactionContext, LoggingHook, OpenFeatureLogger} from '@openfeature/extra'; -import {FlagMetadata, OpenFeature} from '@openfeature/js-sdk'; +import { FlagMetadata, OpenFeature } from '@openfeature/server-sdk'; import {MetricsHook, TracingHook as SpanEventBasedTracingHook} from '@openfeature/open-telemetry-hooks'; import {ProviderService} from '@openfeature/provider'; import {Request} from 'express'; diff --git a/packages/app/src/app/fibonacci/fibonacci.service.ts b/packages/app/src/app/fibonacci/fibonacci.service.ts index b8d706da..c69d51d6 100644 --- a/packages/app/src/app/fibonacci/fibonacci.service.ts +++ b/packages/app/src/app/fibonacci/fibonacci.service.ts @@ -1,7 +1,7 @@ import { HttpService } from '@nestjs/axios'; import { Inject, Injectable } from '@nestjs/common'; import { fibonacci } from '@openfeature/fibonacci'; -import { Client } from '@openfeature/js-sdk'; +import { Client } from '@openfeature/server-sdk'; import { OPENFEATURE_CLIENT } from '../constants'; import { lastValueFrom, map } from 'rxjs'; diff --git a/packages/app/src/app/transaction-context.middleware.ts b/packages/app/src/app/transaction-context.middleware.ts index c01d5d09..4627a482 100644 --- a/packages/app/src/app/transaction-context.middleware.ts +++ b/packages/app/src/app/transaction-context.middleware.ts @@ -1,5 +1,5 @@ import { Injectable, NestMiddleware, Inject } from '@nestjs/common'; -import { OpenFeature } from '@openfeature/js-sdk'; +import { OpenFeature } from '@openfeature/server-sdk'; import { NextFunction, Request, Response } from 'express'; import { REQUEST_DATA } from './constants'; import { RequestData } from './types'; diff --git a/packages/fibonacci-service/src/app/app.module.ts b/packages/fibonacci-service/src/app/app.module.ts index 481295b9..40b2434c 100644 --- a/packages/fibonacci-service/src/app/app.module.ts +++ b/packages/fibonacci-service/src/app/app.module.ts @@ -1,7 +1,7 @@ import {MiddlewareConsumer, Module, NestModule} from '@nestjs/common'; import {AppController} from './app.controller'; import {LoggerModule} from 'nestjs-pino'; -import {FlagMetadata, OpenFeature} from '@openfeature/js-sdk'; +import { FlagMetadata, OpenFeature } from '@openfeature/server-sdk'; import {AsyncLocalStorageTransactionContext, LoggingHook, OpenFeatureLogger} from '@openfeature/extra'; import {MetricsHook, TracingHook as SpanEventBasedTracingHook} from '@openfeature/open-telemetry-hooks'; import {TransactionContextMiddleware} from './transaction-context.middleware'; diff --git a/packages/fibonacci-service/src/app/transaction-context.middleware.ts b/packages/fibonacci-service/src/app/transaction-context.middleware.ts index 71e5079a..7aac467f 100644 --- a/packages/fibonacci-service/src/app/transaction-context.middleware.ts +++ b/packages/fibonacci-service/src/app/transaction-context.middleware.ts @@ -1,5 +1,5 @@ import { Injectable, NestMiddleware } from '@nestjs/common'; -import { EvaluationContext, OpenFeature } from '@openfeature/js-sdk'; +import { EvaluationContext, OpenFeature } from '@openfeature/server-sdk'; import { NextFunction, Request, Response } from 'express'; import { propagation, context } from '@opentelemetry/api'; diff --git a/packages/fibonacci/src/lib/fibonacci.ts b/packages/fibonacci/src/lib/fibonacci.ts index 0a5d6503..f1e8684b 100644 --- a/packages/fibonacci/src/lib/fibonacci.ts +++ b/packages/fibonacci/src/lib/fibonacci.ts @@ -1,4 +1,4 @@ -import { OpenFeature } from '@openfeature/js-sdk'; +import { OpenFeature } from '@openfeature/server-sdk'; const oFeatClient = OpenFeature.getClient('fibonacci'); diff --git a/packages/js-flagsmith-provider/src/lib/flagsmith.ts b/packages/js-flagsmith-provider/src/lib/flagsmith.ts index f4763774..52afaabc 100644 --- a/packages/js-flagsmith-provider/src/lib/flagsmith.ts +++ b/packages/js-flagsmith-provider/src/lib/flagsmith.ts @@ -1,4 +1,14 @@ -import { EvaluationContext, EvaluationContextValue, FlagNotFoundError, JsonValue, Logger, ParseError, Provider, ResolutionDetails, TypeMismatchError } from '@openfeature/js-sdk'; +import { + EvaluationContext, + EvaluationContextValue, + FlagNotFoundError, + JsonValue, + Logger, + ParseError, + Provider, + ResolutionDetails, + TypeMismatchError, +} from '@openfeature/server-sdk'; import { parseValidJsonObject } from '@openfeature/utils'; import Flagsmith from 'flagsmith-nodejs'; diff --git a/packages/js-harness-provider/src/lib/js-harness-provider.ts b/packages/js-harness-provider/src/lib/js-harness-provider.ts index 63dac4c6..8a31c71c 100644 --- a/packages/js-harness-provider/src/lib/js-harness-provider.ts +++ b/packages/js-harness-provider/src/lib/js-harness-provider.ts @@ -1,5 +1,5 @@ import { Client, Target } from '@harnessio/ff-nodejs-server-sdk'; -import { EvaluationContext, Provider, ResolutionDetails, JsonValue } from '@openfeature/js-sdk'; +import { EvaluationContext, Provider, ResolutionDetails, JsonValue } from '@openfeature/server-sdk'; /** * NOTE: This is an unofficial provider that was created for demonstration diff --git a/packages/js-launchdarkly-provider/src/lib/js-launchdarkly-provider.ts b/packages/js-launchdarkly-provider/src/lib/js-launchdarkly-provider.ts index de74f7c7..b286125e 100644 --- a/packages/js-launchdarkly-provider/src/lib/js-launchdarkly-provider.ts +++ b/packages/js-launchdarkly-provider/src/lib/js-launchdarkly-provider.ts @@ -1,5 +1,5 @@ -import { FlagValue, JsonValue, ParseError, TypeMismatchError } from '@openfeature/js-sdk'; -import { EvaluationContext, Provider, ResolutionDetails, Logger } from '@openfeature/js-sdk'; +import { FlagValue, JsonValue, ParseError, TypeMismatchError } from '@openfeature/server-sdk'; +import { EvaluationContext, Provider, ResolutionDetails, Logger } from '@openfeature/server-sdk'; import { init, LDClient, LDUser } from 'launchdarkly-node-server-sdk'; export interface LaunchDarklyProviderOptions { diff --git a/packages/js-split-provider/src/lib/js-split-provider.ts b/packages/js-split-provider/src/lib/js-split-provider.ts index 2a3b500e..9efbe9c9 100644 --- a/packages/js-split-provider/src/lib/js-split-provider.ts +++ b/packages/js-split-provider/src/lib/js-split-provider.ts @@ -1,10 +1,10 @@ -import { JsonValue, TypeMismatchError } from '@openfeature/js-sdk'; -import { EvaluationContext, Provider, ResolutionDetails, Logger } from '@openfeature/js-sdk'; +import { JsonValue, TypeMismatchError } from '@openfeature/server-sdk'; +import { EvaluationContext, Provider, ResolutionDetails, Logger } from '@openfeature/server-sdk'; import type { Attributes, IClient } from '@splitsoftware/splitio/types/splitio'; import { parseValidNumber, parseValidJsonObject } from '@openfeature/utils'; /** - * + * * NOTE: This is an unofficial provider that was created for demonstration * purposes only. The playground environment will be updated to use official * providers once they're available. diff --git a/packages/openfeature-extra/src/lib/hooks/class-validator-hook.ts b/packages/openfeature-extra/src/lib/hooks/class-validator-hook.ts index 223fe407..c5779034 100644 --- a/packages/openfeature-extra/src/lib/hooks/class-validator-hook.ts +++ b/packages/openfeature-extra/src/lib/hooks/class-validator-hook.ts @@ -1,4 +1,4 @@ -import { EvaluationDetails, Hook, HookContext, JsonObject } from '@openfeature/js-sdk'; +import { EvaluationDetails, Hook, HookContext, JsonObject } from '@openfeature/server-sdk'; import { validateSync } from 'class-validator'; /* eslint-disable @typescript-eslint/no-explicit-any */ diff --git a/packages/openfeature-extra/src/lib/hooks/logging-hook.ts b/packages/openfeature-extra/src/lib/hooks/logging-hook.ts index c34bab95..3d956530 100644 --- a/packages/openfeature-extra/src/lib/hooks/logging-hook.ts +++ b/packages/openfeature-extra/src/lib/hooks/logging-hook.ts @@ -1,4 +1,4 @@ -import { EvaluationDetails, FlagValue, Hook, HookContext, HookHints } from '@openfeature/js-sdk'; +import { EvaluationDetails, FlagValue, Hook, HookContext, HookHints } from '@openfeature/server-sdk'; /** * A hook that simply logs at every life-cycle stage. diff --git a/packages/openfeature-extra/src/lib/logger.ts b/packages/openfeature-extra/src/lib/logger.ts index 5d2579b5..3a8bed28 100644 --- a/packages/openfeature-extra/src/lib/logger.ts +++ b/packages/openfeature-extra/src/lib/logger.ts @@ -1,4 +1,4 @@ -import { Logger as OFLogger } from '@openfeature/js-sdk'; +import { Logger as OFLogger } from '@openfeature/server-sdk'; import { Logger } from '@nestjs/common'; /** diff --git a/packages/openfeature-extra/src/lib/transaction-context/async-local-storage.ts b/packages/openfeature-extra/src/lib/transaction-context/async-local-storage.ts index 741a4947..2cc465d4 100644 --- a/packages/openfeature-extra/src/lib/transaction-context/async-local-storage.ts +++ b/packages/openfeature-extra/src/lib/transaction-context/async-local-storage.ts @@ -1,4 +1,4 @@ -import { EvaluationContext, TransactionContextPropagator } from '@openfeature/js-sdk'; +import { EvaluationContext, TransactionContextPropagator } from '@openfeature/server-sdk'; import { AsyncLocalStorage } from 'async_hooks'; export class AsyncLocalStorageTransactionContext implements TransactionContextPropagator { diff --git a/packages/openfeature-propagator/src/lib/openfeature-propagator.ts b/packages/openfeature-propagator/src/lib/openfeature-propagator.ts index c776c9dd..00143080 100644 --- a/packages/openfeature-propagator/src/lib/openfeature-propagator.ts +++ b/packages/openfeature-propagator/src/lib/openfeature-propagator.ts @@ -7,7 +7,7 @@ import { BaggageEntry, } from '@opentelemetry/api'; import { isTracingSuppressed } from '@opentelemetry/core'; -import { OpenFeature, EvaluationContext } from '@openfeature/js-sdk'; +import { OpenFeature, EvaluationContext } from '@openfeature/server-sdk'; const KEY_PAIR_SEPARATOR = '='; const PROPERTIES_SEPARATOR = ';'; diff --git a/packages/provider/src/lib/provider.service.ts b/packages/provider/src/lib/provider.service.ts index ae7e3555..6c464d7b 100644 --- a/packages/provider/src/lib/provider.service.ts +++ b/packages/provider/src/lib/provider.service.ts @@ -4,7 +4,7 @@ import { GoFeatureFlagProvider } from '@openfeature/go-feature-flag-provider'; import { EnvVarProvider } from '@openfeature/env-var-provider'; import { FlagsmithProvider } from '@openfeature/js-flagsmith-provider'; import { OpenFeatureLaunchDarklyProvider } from '@openfeature/js-launchdarkly-provider'; -import { OpenFeature, Provider } from '@openfeature/js-sdk'; +import { OpenFeature, Provider } from '@openfeature/server-sdk'; import { OpenFeatureSplitProvider } from '@openfeature/js-split-provider'; import { SplitFactory } from '@splitsoftware/splitio'; import { CloudbeesProvider } from 'cloudbees-openfeature-provider-node'; diff --git a/packages/utils/src/lib/parse-valid-boolean.ts b/packages/utils/src/lib/parse-valid-boolean.ts index 6ba96cfc..1b08c150 100644 --- a/packages/utils/src/lib/parse-valid-boolean.ts +++ b/packages/utils/src/lib/parse-valid-boolean.ts @@ -1,4 +1,4 @@ -import { TypeMismatchError } from '@openfeature/js-sdk'; +import { TypeMismatchError } from '@openfeature/server-sdk'; export const parseValidBoolean = (stringValue: string | undefined) => { const asUnknown = stringValue as unknown; diff --git a/packages/utils/src/lib/parse-valid-json-object.ts b/packages/utils/src/lib/parse-valid-json-object.ts index db3d9198..6c512284 100644 --- a/packages/utils/src/lib/parse-valid-json-object.ts +++ b/packages/utils/src/lib/parse-valid-json-object.ts @@ -1,4 +1,4 @@ -import { JsonValue, ParseError, TypeMismatchError } from '@openfeature/js-sdk'; +import { JsonValue, ParseError, TypeMismatchError } from '@openfeature/server-sdk'; export const parseValidJsonObject = (stringValue: string): T => { if (stringValue === undefined) { diff --git a/packages/utils/src/lib/parse-valid-number.ts b/packages/utils/src/lib/parse-valid-number.ts index cb00f636..f242a5ba 100644 --- a/packages/utils/src/lib/parse-valid-number.ts +++ b/packages/utils/src/lib/parse-valid-number.ts @@ -1,4 +1,4 @@ -import { ParseError, TypeMismatchError } from '@openfeature/js-sdk'; +import { ParseError, TypeMismatchError } from '@openfeature/server-sdk'; export const parseValidNumber = (stringValue: string | undefined) => { if (stringValue === undefined) {