@dipswitch/openfeature-node 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Engineers Space LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,25 @@
1
- # Temporary Holding Version
1
+ # @dipswitch/openfeature-node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Use Dipswitch with the OpenFeature Node SDK. The adapter reads rules through the Dipswitch Node SDK and evaluates flags in memory.
4
+
5
+ ```sh
6
+ npm install @dipswitch/openfeature-node @openfeature/server-sdk
7
+ ```
8
+
9
+ ```ts
10
+ import { DipswitchProvider } from '@dipswitch/openfeature-node'
11
+ import { OpenFeature, ProviderNotReadyError } from '@openfeature/server-sdk'
12
+
13
+ await OpenFeature.setProviderAndWait(
14
+ new DipswitchProvider({ serverKey: process.env.DIPSWITCH_SERVER_KEY ?? '' }),
15
+ ).catch((error: unknown) => {
16
+ if (!(error instanceof ProviderNotReadyError)) throw error
17
+ })
18
+ const client = OpenFeature.getClient()
19
+ const billing = await client.getBooleanDetails('new-billing', false, { targetingKey: 'user-123' })
20
+ console.log(billing.value, billing.reason)
21
+ ```
22
+
23
+ Use `targetingKey` for the user id and omit it for anonymous evaluation. The provider forwards OpenFeature configuration-change events. Pass `edgeUrl` to use a local edge. Call `OpenFeature.clearProviders()` when the app shuts down.
24
+
25
+ Dipswitch flags are boolean. A missing flag returns the supplied default with `FLAG_NOT_FOUND`. When the ruleset is unavailable at startup, evaluations return the default with `PROVIDER_NOT_READY`. The SDK retries temporary failures and stops if the key is the wrong kind, is revoked, or keeps getting a 401. OpenFeature signals readiness when a ruleset arrives.
package/dist/index.cjs ADDED
@@ -0,0 +1,51 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _dipswitch_sdk_node = require("@dipswitch/sdk-node");
3
+ let _openfeature_server_sdk = require("@openfeature/server-sdk");
4
+ // src/index.ts
5
+ const unsupported = async () => {
6
+ throw new _openfeature_server_sdk.TypeMismatchError("Dipswitch flags are boolean.");
7
+ };
8
+ const notReady = () => new _openfeature_server_sdk.ProviderNotReadyError("The first ruleset has not loaded.");
9
+ var DipswitchProvider = class {
10
+ options;
11
+ metadata = { name: "Dipswitch" };
12
+ runsOn = "server";
13
+ events = new _openfeature_server_sdk.OpenFeatureEventEmitter();
14
+ sdk;
15
+ unsubscribe;
16
+ recovering = false;
17
+ constructor(options) {
18
+ this.options = options;
19
+ }
20
+ async initialize() {
21
+ this.recovering = false;
22
+ const sdk = (0, _dipswitch_sdk_node.createClient)(this.options);
23
+ this.sdk = sdk;
24
+ this.unsubscribe = sdk.onChange(() => {
25
+ const event = this.recovering ? _openfeature_server_sdk.ProviderEvents.Ready : _openfeature_server_sdk.ProviderEvents.ConfigurationChanged;
26
+ this.recovering = false;
27
+ this.events.emit(event);
28
+ });
29
+ await sdk.ready;
30
+ if (this.sdk === sdk && sdk.snapshotVersion === void 0) {
31
+ this.recovering = true;
32
+ throw notReady();
33
+ }
34
+ }
35
+ async onClose() {
36
+ this.unsubscribe?.();
37
+ this.sdk?.close();
38
+ this.unsubscribe = void 0;
39
+ this.sdk = void 0;
40
+ }
41
+ async resolveBooleanEvaluation(key, _defaultValue, context) {
42
+ const result = this.sdk?.getFlagDetails(key, context.targetingKey);
43
+ if (!result || result.reason === "NOT_READY") throw notReady();
44
+ if (result.value === void 0) throw new _openfeature_server_sdk.FlagNotFoundError(`No flag named ${key}.`);
45
+ return result;
46
+ }
47
+ resolveStringEvaluation = unsupported;
48
+ resolveNumberEvaluation = unsupported;
49
+ resolveObjectEvaluation = unsupported;
50
+ };
51
+ exports.DipswitchProvider = DipswitchProvider;
@@ -0,0 +1,20 @@
1
+ import { ClientOptions } from "@dipswitch/sdk-node";
2
+ import { EvaluationContext, OpenFeatureEventEmitter, Provider, ResolutionDetails } from "@openfeature/server-sdk";
3
+ export declare class DipswitchProvider implements Provider {
4
+ private readonly options;
5
+ readonly metadata: {
6
+ name: string;
7
+ };
8
+ readonly runsOn: "server";
9
+ readonly events: OpenFeatureEventEmitter;
10
+ private sdk?;
11
+ private unsubscribe?;
12
+ private recovering;
13
+ constructor(options: ClientOptions);
14
+ initialize(): Promise<void>;
15
+ onClose(): Promise<void>;
16
+ resolveBooleanEvaluation(key: string, _defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
17
+ readonly resolveStringEvaluation: () => Promise<never>;
18
+ readonly resolveNumberEvaluation: () => Promise<never>;
19
+ readonly resolveObjectEvaluation: () => Promise<never>;
20
+ }
@@ -0,0 +1,20 @@
1
+ import { ClientOptions } from "@dipswitch/sdk-node";
2
+ import { EvaluationContext, OpenFeatureEventEmitter, Provider, ResolutionDetails } from "@openfeature/server-sdk";
3
+ export declare class DipswitchProvider implements Provider {
4
+ private readonly options;
5
+ readonly metadata: {
6
+ name: string;
7
+ };
8
+ readonly runsOn: "server";
9
+ readonly events: OpenFeatureEventEmitter;
10
+ private sdk?;
11
+ private unsubscribe?;
12
+ private recovering;
13
+ constructor(options: ClientOptions);
14
+ initialize(): Promise<void>;
15
+ onClose(): Promise<void>;
16
+ resolveBooleanEvaluation(key: string, _defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
17
+ readonly resolveStringEvaluation: () => Promise<never>;
18
+ readonly resolveNumberEvaluation: () => Promise<never>;
19
+ readonly resolveObjectEvaluation: () => Promise<never>;
20
+ }
package/dist/index.mjs ADDED
@@ -0,0 +1,50 @@
1
+ import { createClient } from "@dipswitch/sdk-node";
2
+ import { FlagNotFoundError, OpenFeatureEventEmitter, ProviderEvents, ProviderNotReadyError, TypeMismatchError } from "@openfeature/server-sdk";
3
+ // src/index.ts
4
+ const unsupported = async () => {
5
+ throw new TypeMismatchError("Dipswitch flags are boolean.");
6
+ };
7
+ const notReady = () => new ProviderNotReadyError("The first ruleset has not loaded.");
8
+ var DipswitchProvider = class {
9
+ options;
10
+ metadata = { name: "Dipswitch" };
11
+ runsOn = "server";
12
+ events = new OpenFeatureEventEmitter();
13
+ sdk;
14
+ unsubscribe;
15
+ recovering = false;
16
+ constructor(options) {
17
+ this.options = options;
18
+ }
19
+ async initialize() {
20
+ this.recovering = false;
21
+ const sdk = createClient(this.options);
22
+ this.sdk = sdk;
23
+ this.unsubscribe = sdk.onChange(() => {
24
+ const event = this.recovering ? ProviderEvents.Ready : ProviderEvents.ConfigurationChanged;
25
+ this.recovering = false;
26
+ this.events.emit(event);
27
+ });
28
+ await sdk.ready;
29
+ if (this.sdk === sdk && sdk.snapshotVersion === void 0) {
30
+ this.recovering = true;
31
+ throw notReady();
32
+ }
33
+ }
34
+ async onClose() {
35
+ this.unsubscribe?.();
36
+ this.sdk?.close();
37
+ this.unsubscribe = void 0;
38
+ this.sdk = void 0;
39
+ }
40
+ async resolveBooleanEvaluation(key, _defaultValue, context) {
41
+ const result = this.sdk?.getFlagDetails(key, context.targetingKey);
42
+ if (!result || result.reason === "NOT_READY") throw notReady();
43
+ if (result.value === void 0) throw new FlagNotFoundError(`No flag named ${key}.`);
44
+ return result;
45
+ }
46
+ resolveStringEvaluation = unsupported;
47
+ resolveNumberEvaluation = unsupported;
48
+ resolveObjectEvaluation = unsupported;
49
+ };
50
+ export { DipswitchProvider };
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@dipswitch/openfeature-node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Dipswitch provider for the OpenFeature Node SDK.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./dist/index.d.mts",
14
+ "default": "./dist/index.mjs"
15
+ },
16
+ "require": {
17
+ "types": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ }
20
+ }
21
+ },
22
+ "main": "./dist/index.cjs",
23
+ "module": "./dist/index.mjs",
24
+ "types": "./dist/index.d.cts",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "sideEffects": false,
29
+ "dependencies": {
30
+ "@dipswitch/sdk-node": "0.1.0"
31
+ },
32
+ "peerDependencies": {
33
+ "@openfeature/server-sdk": "^1.23.0"
34
+ }
6
35
  }