@flaghoist/core 0.1.0 → 0.1.1

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 ADDED
@@ -0,0 +1,45 @@
1
+ # @flaghoist/core
2
+
3
+ The evaluation engine behind Flaghoist. Flag schema, targeting rules, percentage rollouts, and the
4
+ storage and auth interfaces the rest of the packages build on.
5
+
6
+ Zero dependencies, and no knowledge of HTTP or of where flags are stored.
7
+
8
+ You usually get this as a dependency of `@flaghoist/server` rather than installing it yourself.
9
+ Install it directly if you are writing a storage adapter, or if you want to evaluate flags in
10
+ process without running a server.
11
+
12
+ ```bash
13
+ npm install @flaghoist/core
14
+ ```
15
+
16
+ ```ts
17
+ import { evaluate, createFlag } from '@flaghoist/core'
18
+
19
+ const flag = createFlag('new-checkout', {
20
+ enabled: true,
21
+ rollout: { percentage: 25 },
22
+ })
23
+
24
+ const result = evaluate(flag.flag, { targetingKey: 'user-123', plan: 'pro' })
25
+ // { value: true, reason: 'SPLIT', ... }
26
+ ```
27
+
28
+ ## How evaluation works
29
+
30
+ Rules are ordered and the first match wins, with conditions inside a rule combined with AND. If no
31
+ rule matches, the percentage rollout decides.
32
+
33
+ Rollouts bucket users with SHA-256 over the targeting key, so the same user always lands in the same
34
+ place. Going from 10 percent to 20 percent adds people without reshuffling the ones already in.
35
+
36
+ Flags are boolean. There are no multivariate values, and evaluation returns a reason so you can tell
37
+ why you got what you got.
38
+
39
+ ## Status
40
+
41
+ Pre-alpha, built and maintained by one person. The API can still change without notice, and
42
+ production use is not recommended yet. If you try it and something breaks, an issue is genuinely
43
+ useful.
44
+
45
+ Apache-2.0. Part of [Flaghoist](https://github.com/flaghoist/flaghoist).
package/dist/index.cjs CHANGED
@@ -33,8 +33,7 @@ __export(index_exports, {
33
33
  matchCondition: () => matchCondition,
34
34
  matchesAllConditions: () => matchesAllConditions,
35
35
  parseFlag: () => parseFlag,
36
- stickyBucket: () => stickyBucket,
37
- version: () => version
36
+ stickyBucket: () => stickyBucket
38
37
  });
39
38
  module.exports = __toCommonJS(index_exports);
40
39
 
@@ -277,9 +276,6 @@ function createFlag(input) {
277
276
  metadata: { createdBy: identity, createdAt: now, updatedBy: identity, updatedAt: now }
278
277
  };
279
278
  }
280
-
281
- // src/index.ts
282
- var version = "0.0.0";
283
279
  // Annotate the CommonJS export names for ESM import in node:
284
280
  0 && (module.exports = {
285
281
  FLAG_KEY_RULE,
@@ -295,6 +291,5 @@ var version = "0.0.0";
295
291
  matchCondition,
296
292
  matchesAllConditions,
297
293
  parseFlag,
298
- stickyBucket,
299
- version
294
+ stickyBucket
300
295
  });
package/dist/index.d.cts CHANGED
@@ -185,6 +185,4 @@ interface CreateFlagInput {
185
185
  */
186
186
  declare function createFlag(input: CreateFlagInput): FeatureFlag;
187
187
 
188
- declare const version = "0.0.0";
189
-
190
- export { type AttributeValue, type AuthContext, type AuthVerifier, type Condition, type ConditionValue, type CreateFlagInput, type EvaluationContext, type EvaluationReason, type EvaluationResult, FLAG_KEY_RULE, FORBIDDEN_ATTRIBUTES, type FeatureFlag, type FlagMetadata, LIMITS, type Operator, type RuleResult, type StorageAdapter, type TargetingRule, clampPercentage, compareSemver, createFlag, evaluate, evaluateAll, isInRollout, isValidFlagKey, matchCondition, matchesAllConditions, parseFlag, stickyBucket, version };
188
+ export { type AttributeValue, type AuthContext, type AuthVerifier, type Condition, type ConditionValue, type CreateFlagInput, type EvaluationContext, type EvaluationReason, type EvaluationResult, FLAG_KEY_RULE, FORBIDDEN_ATTRIBUTES, type FeatureFlag, type FlagMetadata, LIMITS, type Operator, type RuleResult, type StorageAdapter, type TargetingRule, clampPercentage, compareSemver, createFlag, evaluate, evaluateAll, isInRollout, isValidFlagKey, matchCondition, matchesAllConditions, parseFlag, stickyBucket };
package/dist/index.d.ts CHANGED
@@ -185,6 +185,4 @@ interface CreateFlagInput {
185
185
  */
186
186
  declare function createFlag(input: CreateFlagInput): FeatureFlag;
187
187
 
188
- declare const version = "0.0.0";
189
-
190
- export { type AttributeValue, type AuthContext, type AuthVerifier, type Condition, type ConditionValue, type CreateFlagInput, type EvaluationContext, type EvaluationReason, type EvaluationResult, FLAG_KEY_RULE, FORBIDDEN_ATTRIBUTES, type FeatureFlag, type FlagMetadata, LIMITS, type Operator, type RuleResult, type StorageAdapter, type TargetingRule, clampPercentage, compareSemver, createFlag, evaluate, evaluateAll, isInRollout, isValidFlagKey, matchCondition, matchesAllConditions, parseFlag, stickyBucket, version };
188
+ export { type AttributeValue, type AuthContext, type AuthVerifier, type Condition, type ConditionValue, type CreateFlagInput, type EvaluationContext, type EvaluationReason, type EvaluationResult, FLAG_KEY_RULE, FORBIDDEN_ATTRIBUTES, type FeatureFlag, type FlagMetadata, LIMITS, type Operator, type RuleResult, type StorageAdapter, type TargetingRule, clampPercentage, compareSemver, createFlag, evaluate, evaluateAll, isInRollout, isValidFlagKey, matchCondition, matchesAllConditions, parseFlag, stickyBucket };
package/dist/index.js CHANGED
@@ -237,9 +237,6 @@ function createFlag(input) {
237
237
  metadata: { createdBy: identity, createdAt: now, updatedBy: identity, updatedAt: now }
238
238
  };
239
239
  }
240
-
241
- // src/index.ts
242
- var version = "0.0.0";
243
240
  export {
244
241
  FLAG_KEY_RULE,
245
242
  FORBIDDEN_ATTRIBUTES,
@@ -254,6 +251,5 @@ export {
254
251
  matchCondition,
255
252
  matchesAllConditions,
256
253
  parseFlag,
257
- stickyBucket,
258
- version
254
+ stickyBucket
259
255
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flaghoist/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Flag schema, evaluation engine, and storage/auth interfaces for Flaghoist. Zero dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -29,6 +29,22 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
+ "keywords": [
33
+ "feature-flags",
34
+ "feature-toggles",
35
+ "evaluation",
36
+ "targeting",
37
+ "percentage-rollout"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/flaghoist/flaghoist.git",
42
+ "directory": "packages/core"
43
+ },
44
+ "homepage": "https://github.com/flaghoist/flaghoist#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/flaghoist/flaghoist/issues"
47
+ },
32
48
  "scripts": {
33
49
  "build": "tsup src/index.ts --format esm,cjs --dts --clean",
34
50
  "test": "vitest run --passWithNoTests",