@lunora/flags 1.0.0-alpha.1 → 1.0.0-alpha.10

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.md CHANGED
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
103
103
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
104
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
105
  specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
110
+ <!-- TYPE_DEPENDENCIES -->
111
+ <!-- /TYPE_DEPENDENCIES -->
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  export { defineFlags, isFlagsDefinition } from './packem_shared/defineFlags-DAIO8cWQ.mjs';
2
- export { createFlags } from './packem_shared/createFlags-BQ8eiIlo.mjs';
2
+ export { createFlags } from './packem_shared/createFlags-CEbcdnqZ.mjs';
@@ -1,3 +1,4 @@
1
+ import { LunoraError } from '@lunora/errors';
1
2
  import { OpenFeature, ErrorCode } from '@openfeature/server-sdk';
2
3
 
3
4
  const DOMAIN = "lunora";
@@ -26,8 +27,13 @@ const resetFlags = async () => {
26
27
  await OpenFeature.clearProviders();
27
28
  };
28
29
  const memoKey = (type, flagKey, defaultValue, context) => {
29
- const entries = Object.keys(context).toSorted((a, b) => a.localeCompare(b)).map((name) => [name, context[name]]);
30
- return JSON.stringify([type, flagKey, defaultValue, entries]);
30
+ const contextKeys = Object.keys(context);
31
+ const prefix = JSON.stringify([type, flagKey, defaultValue]);
32
+ if (contextKeys.length === 0) {
33
+ return `${prefix}:[]`;
34
+ }
35
+ const entries = contextKeys.toSorted((a, b) => a.localeCompare(b)).map((name) => [name, context[name]]);
36
+ return `${prefix}:${JSON.stringify(entries)}`;
31
37
  };
32
38
  const resolveDetails = (client, type, flagKey, defaultValue, context) => {
33
39
  switch (type) {
@@ -44,7 +50,7 @@ const resolveDetails = (client, type, flagKey, defaultValue, context) => {
44
50
  return client.getStringDetails(flagKey, defaultValue, context);
45
51
  }
46
52
  default: {
47
- throw new Error(`createFlags: unknown flag type "${type}"`);
53
+ throw new LunoraError("INTERNAL", `createFlags: unknown flag type "${type}"`);
48
54
  }
49
55
  }
50
56
  };
@@ -1,4 +1,5 @@
1
1
  import { FlagshipServerProvider } from '@cloudflare/flagship/server';
2
+ import { LunoraError } from '@lunora/errors';
2
3
 
3
4
  const isBindingOptions = (options) => "binding" in options && typeof options.binding === "string";
4
5
  const flagshipProvider = (options) => {
@@ -7,7 +8,8 @@ const flagshipProvider = (options) => {
7
8
  return (env) => {
8
9
  const binding = env[bindingName];
9
10
  if (binding === void 0 || binding === null) {
10
- throw new Error(
11
+ throw new LunoraError(
12
+ "INTERNAL",
11
13
  `flagshipProvider: no binding "${bindingName}" found on env. Add a \`flagship\` binding to wrangler.jsonc, e.g. { "flagship": [{ "binding": "${bindingName}", "app_id": "your-app-id" }] }.`
12
14
  );
13
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/flags",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.10",
4
4
  "description": "OpenFeature-based feature flags for Lunora — ctx.flags, useFlag, and a first-class Cloudflare Flagship provider with any OpenFeature provider pluggable",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -60,11 +60,12 @@
60
60
  "access": "public"
61
61
  },
62
62
  "dependencies": {
63
- "@openfeature/server-sdk": "^1.20.2"
63
+ "@lunora/errors": "1.0.0-alpha.2",
64
+ "@openfeature/server-sdk": "^1.22.0"
64
65
  },
65
66
  "peerDependencies": {
66
67
  "@cloudflare/flagship": "^0.4.2",
67
- "@openfeature/web-sdk": "^1.7.3"
68
+ "@openfeature/web-sdk": "^1.9.0"
68
69
  },
69
70
  "peerDependenciesMeta": {
70
71
  "@cloudflare/flagship": {