@dipswitch/sdk-node-launchdarkly 0.1.0 → 0.2.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/README.md CHANGED
@@ -7,10 +7,10 @@ Compare boolean flag values during a Node service's move from LaunchDarkly to Di
7
7
  For local use, build and pack `sdk-node` and `sdk-node-launchdarkly`. In a service that already uses the LaunchDarkly Node server SDK, install both tarballs together.
8
8
 
9
9
  ```sh
10
- npm install ./dipswitch-sdk-node-0.1.0.tgz ./dipswitch-sdk-node-launchdarkly-0.1.0.tgz
10
+ npm install ./dipswitch-sdk-node-0.2.0.tgz ./dipswitch-sdk-node-launchdarkly-0.2.0.tgz
11
11
  ```
12
12
 
13
- After publication, install both Dipswitch packages from npm for the shadow example. The service supplies `@launchdarkly/node-server-sdk` in the supported `^9.16.4` range.
13
+ For released versions, install both Dipswitch packages from npm. The service supplies `@launchdarkly/node-server-sdk` in the supported `^9.16.4` range.
14
14
 
15
15
  ```sh
16
16
  npm install @dipswitch/sdk-node @dipswitch/sdk-node-launchdarkly
package/dist/index.cjs CHANGED
@@ -6,20 +6,24 @@ function userKey(context) {
6
6
  const user = kind === "multi" && "user" in context ? context.user : kind === "user" || kind === void 0 ? context : void 0;
7
7
  if (typeof user === "object" && user !== null && "key" in user && typeof user.key === "string" && user.key !== "") return user.key;
8
8
  }
9
- function logMismatch(mismatch) {
10
- console.warn("[Dipswitch shadow] Flag mismatch", mismatch);
9
+ function logMismatch({ flagKey, launchDarkly, dipswitch }) {
10
+ console.warn("[Dipswitch shadow] Flag mismatch", {
11
+ flagKey,
12
+ launchDarkly,
13
+ dipswitch
14
+ });
11
15
  }
12
16
  /** Wraps the existing LaunchDarkly client. Adding a Dipswitch client enables comparison. */
13
17
  function createFlagClient(options) {
14
18
  const readLaunchDarkly = (key, context, fallback) => options.launchDarkly.boolVariation(key, context, fallback);
15
19
  if (!options.dipswitch) return { isEnabled: readLaunchDarkly };
16
20
  const { dipswitch, onMismatch = logMismatch, returnFrom = "launchdarkly" } = options;
17
- return { isEnabled(flagKey, context, defaultValue) {
21
+ return { isEnabled(flagKey, context, defaultValue, workspaceId) {
18
22
  const next = (async () => {
19
23
  const userId = userKey(context);
20
24
  return {
21
25
  userId,
22
- value: dipswitch.isEnabled(flagKey, userId, defaultValue)
26
+ value: workspaceId === void 0 ? dipswitch.isEnabled(flagKey, userId, defaultValue) : dipswitch.isEnabled(flagKey, userId, defaultValue, workspaceId)
23
27
  };
24
28
  })();
25
29
  const legacy = (async () => readLaunchDarkly(flagKey, context, defaultValue))();
package/dist/index.d.cts CHANGED
@@ -7,7 +7,7 @@ export interface FlagMismatch {
7
7
  dipswitch: boolean;
8
8
  }
9
9
  export interface FlagClient {
10
- isEnabled(flagKey: string, context: LDContext, defaultValue: boolean): Promise<boolean>;
10
+ isEnabled(flagKey: string, context: LDContext, defaultValue: boolean, workspaceId?: string): Promise<boolean>;
11
11
  }
12
12
  export type FlagClientOptions = {
13
13
  launchDarkly: Pick<LDClient, 'boolVariation'>;
package/dist/index.d.mts CHANGED
@@ -7,7 +7,7 @@ export interface FlagMismatch {
7
7
  dipswitch: boolean;
8
8
  }
9
9
  export interface FlagClient {
10
- isEnabled(flagKey: string, context: LDContext, defaultValue: boolean): Promise<boolean>;
10
+ isEnabled(flagKey: string, context: LDContext, defaultValue: boolean, workspaceId?: string): Promise<boolean>;
11
11
  }
12
12
  export type FlagClientOptions = {
13
13
  launchDarkly: Pick<LDClient, 'boolVariation'>;
package/dist/index.mjs CHANGED
@@ -5,20 +5,24 @@ function userKey(context) {
5
5
  const user = kind === "multi" && "user" in context ? context.user : kind === "user" || kind === void 0 ? context : void 0;
6
6
  if (typeof user === "object" && user !== null && "key" in user && typeof user.key === "string" && user.key !== "") return user.key;
7
7
  }
8
- function logMismatch(mismatch) {
9
- console.warn("[Dipswitch shadow] Flag mismatch", mismatch);
8
+ function logMismatch({ flagKey, launchDarkly, dipswitch }) {
9
+ console.warn("[Dipswitch shadow] Flag mismatch", {
10
+ flagKey,
11
+ launchDarkly,
12
+ dipswitch
13
+ });
10
14
  }
11
15
  /** Wraps the existing LaunchDarkly client. Adding a Dipswitch client enables comparison. */
12
16
  function createFlagClient(options) {
13
17
  const readLaunchDarkly = (key, context, fallback) => options.launchDarkly.boolVariation(key, context, fallback);
14
18
  if (!options.dipswitch) return { isEnabled: readLaunchDarkly };
15
19
  const { dipswitch, onMismatch = logMismatch, returnFrom = "launchdarkly" } = options;
16
- return { isEnabled(flagKey, context, defaultValue) {
20
+ return { isEnabled(flagKey, context, defaultValue, workspaceId) {
17
21
  const next = (async () => {
18
22
  const userId = userKey(context);
19
23
  return {
20
24
  userId,
21
- value: dipswitch.isEnabled(flagKey, userId, defaultValue)
25
+ value: workspaceId === void 0 ? dipswitch.isEnabled(flagKey, userId, defaultValue) : dipswitch.isEnabled(flagKey, userId, defaultValue, workspaceId)
22
26
  };
23
27
  })();
24
28
  const legacy = (async () => readLaunchDarkly(flagKey, context, defaultValue))();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dipswitch/sdk-node-launchdarkly",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Compare LaunchDarkly and Dipswitch feature flags during a Node migration.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "sideEffects": false,
29
29
  "dependencies": {
30
- "@dipswitch/sdk-node": "0.1.0"
30
+ "@dipswitch/sdk-node": "0.2.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@launchdarkly/node-server-sdk": "^9.16.4"