@marktiderman/genesis-features 0.3.0 → 0.4.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 +40 -0
- package/dist/blocks.js +3 -2
- package/dist/{chunk-EF72JS5S.js → chunk-4Q356635.js} +4 -3
- package/dist/chunk-4Q356635.js.map +1 -0
- package/dist/chunk-B6WRD3WF.js +6 -0
- package/dist/chunk-B6WRD3WF.js.map +1 -0
- package/dist/{chunk-KCUQY5UZ.js → chunk-JMXJZT6O.js} +8 -10
- package/dist/chunk-JMXJZT6O.js.map +1 -0
- package/dist/chunk-LNVWVPWB.js +111 -0
- package/dist/chunk-LNVWVPWB.js.map +1 -0
- package/dist/chunk-OW46SL2G.js +10 -0
- package/dist/chunk-OW46SL2G.js.map +1 -0
- package/dist/{chunk-2ARZER3G.js → chunk-VYUX7VAX.js} +3 -6
- package/dist/chunk-VYUX7VAX.js.map +1 -0
- package/dist/gate-BY352cd0.d.ts +186 -0
- package/dist/gate-react.d.ts +48 -0
- package/dist/gate-react.js +37 -0
- package/dist/gate-react.js.map +1 -0
- package/dist/gate.d.ts +18 -0
- package/dist/gate.js +5 -0
- package/dist/gate.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -3
- package/dist/{model-CW3d2gsf.d.ts → model-8dMGbgtM.d.ts} +3 -36
- package/dist/node.d.ts +2 -1
- package/dist/node.js +4 -2
- package/dist/node.js.map +1 -1
- package/dist/react.d.ts +2 -1
- package/dist/react.js +4 -2
- package/dist/react.js.map +1 -1
- package/dist/types-Bd766VxF.d.ts +39 -0
- package/package.json +12 -4
- package/dist/chunk-2ARZER3G.js.map +0 -1
- package/dist/chunk-EF72JS5S.js.map +0 -1
- package/dist/chunk-KCUQY5UZ.js.map +0 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { F as FlagValue, a as FeatureStatus, b as FeatureAccess, c as FlagKind } from './types-Bd766VxF.js';
|
|
2
|
+
import { F as FeaturePlatform } from './platforms-NR0liM8L.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The feature gate: one answer to "is this feature on here?" for UI, server
|
|
6
|
+
* code, agents and (for status and entitlement) the database.
|
|
7
|
+
*
|
|
8
|
+
* Checks run in a fixed order and the first "no" wins:
|
|
9
|
+
*
|
|
10
|
+
* 1. status the feature has shipped (beta, live or deprecated)
|
|
11
|
+
* 2. platform it has shipped on this platform
|
|
12
|
+
* 3. tenant the tenant has not switched it off
|
|
13
|
+
* 4. flag each of its boolean release or permission flags is true
|
|
14
|
+
* 5. entitlement a paid feature (`access: { plan }`) has an active entitlement
|
|
15
|
+
*
|
|
16
|
+
* Entitlement is last on purpose: an "upgrade to unlock" answer is only given
|
|
17
|
+
* when paying is the one thing missing, so an upsell never promises a feature
|
|
18
|
+
* that a switch or a flag would still keep off.
|
|
19
|
+
*
|
|
20
|
+
* The registry comes from code (features.ts and flags.json). Everything that
|
|
21
|
+
* changes at runtime (entitlements, switches, flag values) comes in through
|
|
22
|
+
* {@link GateContext}, read once per request or session on the server. Role
|
|
23
|
+
* and row rights are not the gate's business: "may this person" stays with
|
|
24
|
+
* roles and row security.
|
|
25
|
+
*
|
|
26
|
+
* No zod, React, Node built-ins or DOM globals here: this file ships to
|
|
27
|
+
* browsers, extension service workers, phones and edge functions.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/** The statuses in which a feature is on. A deprecated feature still works until it is retired. @stability Beta */
|
|
31
|
+
declare const SHIPPED_STATUSES: readonly FeatureStatus[];
|
|
32
|
+
/**
|
|
33
|
+
* Why a feature is off: the first check that said no. `unknown` is an id that
|
|
34
|
+
* isn't in the registry (or not in a snapshot).
|
|
35
|
+
*
|
|
36
|
+
* @stability Beta
|
|
37
|
+
*/
|
|
38
|
+
type GateReason = "unknown" | "status" | "platform" | "tenant" | "flag" | "entitlement";
|
|
39
|
+
/**
|
|
40
|
+
* The gate's answer for one feature. `unlock` is set when the reason is
|
|
41
|
+
* `entitlement`: the plan that turns it on, so the UI can show an upgrade
|
|
42
|
+
* instead of hiding the feature.
|
|
43
|
+
*
|
|
44
|
+
* @stability Beta
|
|
45
|
+
*/
|
|
46
|
+
interface GateAnswer {
|
|
47
|
+
on: boolean;
|
|
48
|
+
reason?: GateReason;
|
|
49
|
+
unlock?: {
|
|
50
|
+
plan: string;
|
|
51
|
+
};
|
|
52
|
+
/** The flag that turned it off, when the reason is `flag`. Server side only: snapshots leave it out. */
|
|
53
|
+
flag?: string;
|
|
54
|
+
}
|
|
55
|
+
/** The fields of a feature the gate reads. A `FeatureDef` fits. @stability Beta */
|
|
56
|
+
interface GateFeature {
|
|
57
|
+
status: FeatureStatus;
|
|
58
|
+
apps: readonly string[];
|
|
59
|
+
platforms?: Partial<Record<FeaturePlatform, FeatureStatus>>;
|
|
60
|
+
access?: FeatureAccess;
|
|
61
|
+
}
|
|
62
|
+
/** The fields of a flag the gate reads. A `FlagDef` fits. @stability Beta */
|
|
63
|
+
interface GateFlag {
|
|
64
|
+
feature: string;
|
|
65
|
+
kind: FlagKind;
|
|
66
|
+
default: FlagValue;
|
|
67
|
+
}
|
|
68
|
+
/** What the gate decides from: the registry, as code defines it. @stability Beta */
|
|
69
|
+
interface GateRegistry {
|
|
70
|
+
features: {
|
|
71
|
+
readonly [id: string]: GateFeature;
|
|
72
|
+
};
|
|
73
|
+
flags?: {
|
|
74
|
+
readonly [name: string]: GateFlag;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A set of ids: a list, a Set or a test. Not any iterable: an iterator would
|
|
79
|
+
* be used up by the first feature asked, and a bare string would count as its
|
|
80
|
+
* characters.
|
|
81
|
+
*
|
|
82
|
+
* @stability Beta
|
|
83
|
+
*/
|
|
84
|
+
type IdSet = readonly string[] | ReadonlySet<string> | ((id: string) => boolean);
|
|
85
|
+
/**
|
|
86
|
+
* Where and for whom the gate is asked: the platform, plus the tenant's
|
|
87
|
+
* runtime state. Leave out what the app doesn't have: no `entitlements` means
|
|
88
|
+
* no paid feature is on, no `off` means no switch is off, no `flags` means
|
|
89
|
+
* every flag has its default.
|
|
90
|
+
*
|
|
91
|
+
* @stability Beta
|
|
92
|
+
*/
|
|
93
|
+
interface GateContext {
|
|
94
|
+
platform: FeaturePlatform;
|
|
95
|
+
/** Feature ids the tenant holds an active entitlement for. */
|
|
96
|
+
entitlements?: IdSet;
|
|
97
|
+
/** Feature ids the tenant switched off. */
|
|
98
|
+
off?: IdSet;
|
|
99
|
+
/** Flag values for this tenant, by flag name. A missing flag has its default. */
|
|
100
|
+
flags?: {
|
|
101
|
+
readonly [name: string]: FlagValue | undefined;
|
|
102
|
+
} | ((name: string) => FlagValue | undefined);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Is feature `id` on for this context? Returns the first check that said no
|
|
106
|
+
* as `reason`, and for a paid feature the plan that unlocks it. An unknown id
|
|
107
|
+
* is off with reason `unknown`; it never throws for one.
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* const answer = featureOn({ features, flags }, { platform: "web", entitlements, off }, "form-webhook-delivery");
|
|
111
|
+
* // { on: false, reason: "entitlement", unlock: { plan: "pro" } }
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @stability Beta
|
|
115
|
+
*/
|
|
116
|
+
declare function featureOn(registry: GateRegistry, context: GateContext, id: string): GateAnswer;
|
|
117
|
+
/**
|
|
118
|
+
* Every shipped feature's answer for one context: what a server hands a
|
|
119
|
+
* client, so the client never decides on its own. Plain JSON, safe to store
|
|
120
|
+
* (an extension's session storage, a cache) and to compare by `version`.
|
|
121
|
+
*
|
|
122
|
+
* It lists only features that have shipped somewhere (beta, live or
|
|
123
|
+
* deprecated) and leaves out flag names; anything missing reads as off.
|
|
124
|
+
*
|
|
125
|
+
* @stability Beta
|
|
126
|
+
*/
|
|
127
|
+
interface GateSnapshot {
|
|
128
|
+
/** The answers, by feature id. */
|
|
129
|
+
readonly answers: {
|
|
130
|
+
readonly [id: string]: GateAnswer;
|
|
131
|
+
};
|
|
132
|
+
/** When the server made it (ISO 8601). Refresh after your own time limit. */
|
|
133
|
+
readonly at: string;
|
|
134
|
+
/** The registry version it was made from, when known (the build's version). */
|
|
135
|
+
readonly version?: string | number;
|
|
136
|
+
}
|
|
137
|
+
/** @stability Beta */
|
|
138
|
+
interface GateSnapshotOptions {
|
|
139
|
+
/** Answer for these features only. */
|
|
140
|
+
ids?: Iterable<string>;
|
|
141
|
+
/** The registry version, carried into the snapshot. */
|
|
142
|
+
version?: string | number;
|
|
143
|
+
/** The time to stamp (default now). */
|
|
144
|
+
at?: Date;
|
|
145
|
+
}
|
|
146
|
+
/** @stability Beta */
|
|
147
|
+
declare function gateSnapshot(registry: GateRegistry, context: GateContext, options?: GateSnapshotOptions): GateSnapshot;
|
|
148
|
+
/**
|
|
149
|
+
* Whether a snapshot is older than `maxAgeMs`: refresh it then. A client
|
|
150
|
+
* (an extension worker, a tab left open) keeps a snapshot, replaces it when it
|
|
151
|
+
* is stale, after sign-in or a tenant switch, and right after a refusal.
|
|
152
|
+
*
|
|
153
|
+
* @stability Beta
|
|
154
|
+
*/
|
|
155
|
+
declare function isSnapshotStale(snapshot: GateSnapshot, maxAgeMs: number, now?: Date): boolean;
|
|
156
|
+
/** One feature's answer from a snapshot. An id missing from it is off, as an unknown feature. @stability Beta */
|
|
157
|
+
declare function fromSnapshot(snapshot: GateSnapshot, id: string): GateAnswer;
|
|
158
|
+
/**
|
|
159
|
+
* Thrown by {@link requireFeature} when a feature is off. Servers map it to a
|
|
160
|
+
* refusal that carries the reason (HTTP 403, or 402 for `entitlement`).
|
|
161
|
+
*
|
|
162
|
+
* @stability Beta
|
|
163
|
+
*/
|
|
164
|
+
declare class FeatureOff extends Error {
|
|
165
|
+
readonly feature: string;
|
|
166
|
+
readonly reason: GateReason;
|
|
167
|
+
readonly unlock?: {
|
|
168
|
+
plan: string;
|
|
169
|
+
};
|
|
170
|
+
constructor(feature: string, answer: GateAnswer);
|
|
171
|
+
/** The HTTP status for this refusal: 402 when a plan unlocks it, else 403. */
|
|
172
|
+
get status(): 402 | 403;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Refuse unless the feature is on: call it at the top of every server
|
|
176
|
+
* function and route that belongs to a feature.
|
|
177
|
+
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* requireFeature({ features, flags }, await gateContext(tenant), "form-webhook-delivery");
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @stability Beta
|
|
183
|
+
*/
|
|
184
|
+
declare function requireFeature(registry: GateRegistry, context: GateContext, id: string): void;
|
|
185
|
+
|
|
186
|
+
export { FeatureOff as F, type GateAnswer as G, type IdSet as I, SHIPPED_STATUSES as S, type GateSnapshot as a, type GateContext as b, type GateFeature as c, type GateFlag as d, type GateReason as e, type GateRegistry as f, type GateSnapshotOptions as g, featureOn as h, fromSnapshot as i, gateSnapshot as j, isSnapshotStale as k, requireFeature as r };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { G as GateAnswer, a as GateSnapshot } from './gate-BY352cd0.js';
|
|
4
|
+
import './types-Bd766VxF.js';
|
|
5
|
+
import './platforms-NR0liM8L.js';
|
|
6
|
+
|
|
7
|
+
/** Hands the session's gate answers to every {@link useFeature} below it. @stability Beta */
|
|
8
|
+
declare function FeatureGateProvider({ snapshot, children, }: {
|
|
9
|
+
snapshot: GateSnapshot;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): react.JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* The gate's answer for one feature. Outside a {@link FeatureGateProvider}
|
|
14
|
+
* this throws: a missing provider would otherwise turn every feature off
|
|
15
|
+
* without a word.
|
|
16
|
+
*
|
|
17
|
+
* @stability Beta
|
|
18
|
+
*/
|
|
19
|
+
declare function useFeature(id: string): GateAnswer;
|
|
20
|
+
/** @stability Beta */
|
|
21
|
+
interface FeatureGateProps {
|
|
22
|
+
/** The feature this content belongs to. */
|
|
23
|
+
feature: string;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
/** Shown when a plan would unlock the feature: an upgrade prompt, a locked row. Defaults to `fallback`. */
|
|
26
|
+
upsell?: (answer: GateAnswer & {
|
|
27
|
+
unlock: {
|
|
28
|
+
plan: string;
|
|
29
|
+
};
|
|
30
|
+
}) => ReactNode;
|
|
31
|
+
/** Shown for any other "off". Defaults to nothing. */
|
|
32
|
+
fallback?: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Renders `children` when the feature is on; `upsell` when a plan would turn
|
|
36
|
+
* it on; otherwise `fallback`.
|
|
37
|
+
*
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <FeatureGate feature="form-webhook-delivery" upsell={({ unlock }) => <UpgradeRow plan={unlock.plan} />}>
|
|
40
|
+
* <WebhookSettings />
|
|
41
|
+
* </FeatureGate>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @stability Beta
|
|
45
|
+
*/
|
|
46
|
+
declare function FeatureGate({ feature, children, upsell, fallback, }: FeatureGateProps): react.JSX.Element;
|
|
47
|
+
|
|
48
|
+
export { FeatureGate, type FeatureGateProps, FeatureGateProvider, useFeature };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { fromSnapshot } from './chunk-LNVWVPWB.js';
|
|
3
|
+
import './chunk-OW46SL2G.js';
|
|
4
|
+
import { createContext, useContext } from 'react';
|
|
5
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var GateContext = createContext(null);
|
|
8
|
+
function FeatureGateProvider({
|
|
9
|
+
snapshot,
|
|
10
|
+
children
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ jsx(GateContext.Provider, { value: snapshot, children });
|
|
13
|
+
}
|
|
14
|
+
function useFeature(id) {
|
|
15
|
+
const snapshot = useContext(GateContext);
|
|
16
|
+
if (!snapshot)
|
|
17
|
+
throw new Error(
|
|
18
|
+
`useFeature("${id}") needs a <FeatureGateProvider> above it`
|
|
19
|
+
);
|
|
20
|
+
return fromSnapshot(snapshot, id);
|
|
21
|
+
}
|
|
22
|
+
function FeatureGate({
|
|
23
|
+
feature,
|
|
24
|
+
children,
|
|
25
|
+
upsell,
|
|
26
|
+
fallback = null
|
|
27
|
+
}) {
|
|
28
|
+
const answer = useFeature(feature);
|
|
29
|
+
if (answer.on) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
30
|
+
if (answer.reason === "entitlement" && answer.unlock && upsell)
|
|
31
|
+
return /* @__PURE__ */ jsx(Fragment, { children: upsell({ ...answer, unlock: answer.unlock }) });
|
|
32
|
+
return /* @__PURE__ */ jsx(Fragment, { children: fallback });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { FeatureGate, FeatureGateProvider, useFeature };
|
|
36
|
+
//# sourceMappingURL=gate-react.js.map
|
|
37
|
+
//# sourceMappingURL=gate-react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/gate-react.tsx"],"names":[],"mappings":";;;;;;AAYA,IAAM,WAAA,GAAc,cAAmC,IAAI,CAAA;AAGpD,SAAS,mBAAA,CAAoB;AAAA,EAClC,QAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,2BACG,WAAA,CAAY,QAAA,EAAZ,EAAqB,KAAA,EAAO,UAAW,QAAA,EAAS,CAAA;AAErD;AASO,SAAS,WAAW,EAAA,EAAwB;AACjD,EAAA,MAAM,QAAA,GAAW,WAAW,WAAW,CAAA;AACvC,EAAA,IAAI,CAAC,QAAA;AACH,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,eAAe,EAAE,CAAA,yCAAA;AAAA,KACnB;AACF,EAAA,OAAO,YAAA,CAAa,UAAU,EAAE,CAAA;AAClC;AAyBO,SAAS,WAAA,CAAY;AAAA,EAC1B,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA,GAAW;AACb,CAAA,EAAqB;AACnB,EAAA,MAAM,MAAA,GAAS,WAAW,OAAO,CAAA;AACjC,EAAA,IAAI,MAAA,CAAO,EAAA,EAAI,uBAAO,GAAA,CAAA,QAAA,EAAA,EAAG,QAAA,EAAS,CAAA;AAClC,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,aAAA,IAAiB,MAAA,CAAO,MAAA,IAAU,MAAA;AACtD,IAAA,uBAAO,GAAA,CAAA,QAAA,EAAA,EAAG,iBAAO,EAAE,GAAG,QAAQ,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAQ,CAAA,EAAE,CAAA;AACzD,EAAA,uCAAU,QAAA,EAAA,QAAA,EAAS,CAAA;AACrB","file":"gate-react.js","sourcesContent":["/**\n * `@marktiderman/genesis-features/gate/react`: the gate's answers in React,\n * on the web and in React Native. The server computes a {@link GateSnapshot}\n * and the provider hands it down; components never decide on their own. To\n * refresh, give the provider a new snapshot: every `useFeature` below it\n * re-renders with the new answers.\n *\n * @stability Beta\n */\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport { fromSnapshot, type GateAnswer, type GateSnapshot } from \"./gate\";\n\nconst GateContext = createContext<GateSnapshot | null>(null);\n\n/** Hands the session's gate answers to every {@link useFeature} below it. @stability Beta */\nexport function FeatureGateProvider({\n snapshot,\n children,\n}: {\n snapshot: GateSnapshot;\n children: ReactNode;\n}) {\n return (\n <GateContext.Provider value={snapshot}>{children}</GateContext.Provider>\n );\n}\n\n/**\n * The gate's answer for one feature. Outside a {@link FeatureGateProvider}\n * this throws: a missing provider would otherwise turn every feature off\n * without a word.\n *\n * @stability Beta\n */\nexport function useFeature(id: string): GateAnswer {\n const snapshot = useContext(GateContext);\n if (!snapshot)\n throw new Error(\n `useFeature(\"${id}\") needs a <FeatureGateProvider> above it`,\n );\n return fromSnapshot(snapshot, id);\n}\n\n/** @stability Beta */\nexport interface FeatureGateProps {\n /** The feature this content belongs to. */\n feature: string;\n children: ReactNode;\n /** Shown when a plan would unlock the feature: an upgrade prompt, a locked row. Defaults to `fallback`. */\n upsell?: (answer: GateAnswer & { unlock: { plan: string } }) => ReactNode;\n /** Shown for any other \"off\". Defaults to nothing. */\n fallback?: ReactNode;\n}\n\n/**\n * Renders `children` when the feature is on; `upsell` when a plan would turn\n * it on; otherwise `fallback`.\n *\n * ```tsx\n * <FeatureGate feature=\"form-webhook-delivery\" upsell={({ unlock }) => <UpgradeRow plan={unlock.plan} />}>\n * <WebhookSettings />\n * </FeatureGate>\n * ```\n *\n * @stability Beta\n */\nexport function FeatureGate({\n feature,\n children,\n upsell,\n fallback = null,\n}: FeatureGateProps) {\n const answer = useFeature(feature);\n if (answer.on) return <>{children}</>;\n if (answer.reason === \"entitlement\" && answer.unlock && upsell)\n return <>{upsell({ ...answer, unlock: answer.unlock })}</>;\n return <>{fallback}</>;\n}\n"]}
|
package/dist/gate.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { F as FeatureOff, G as GateAnswer, b as GateContext, c as GateFeature, d as GateFlag, e as GateReason, f as GateRegistry, a as GateSnapshot, g as GateSnapshotOptions, I as IdSet, S as SHIPPED_STATUSES, h as featureOn, i as fromSnapshot, j as gateSnapshot, k as isSnapshotStale, r as requireFeature } from './gate-BY352cd0.js';
|
|
2
|
+
import { a as FeatureStatus } from './types-Bd766VxF.js';
|
|
3
|
+
import { F as FeaturePlatform } from './platforms-NR0liM8L.js';
|
|
4
|
+
export { a as FEATURE_PLATFORMS } from './platforms-NR0liM8L.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A feature's status on one platform, or undefined when it isn't there.
|
|
8
|
+
* Zod-free so the gate can use it on phones and in browsers.
|
|
9
|
+
*
|
|
10
|
+
* @stability Beta
|
|
11
|
+
*/
|
|
12
|
+
declare function statusOn(def: {
|
|
13
|
+
status: FeatureStatus;
|
|
14
|
+
apps: readonly string[];
|
|
15
|
+
platforms?: Partial<Record<FeaturePlatform, FeatureStatus>>;
|
|
16
|
+
}, platform: FeaturePlatform): FeatureStatus | undefined;
|
|
17
|
+
|
|
18
|
+
export { FeaturePlatform, statusOn };
|
package/dist/gate.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FeatureOff, SHIPPED_STATUSES, featureOn, fromSnapshot, gateSnapshot, isSnapshotStale, requireFeature } from './chunk-LNVWVPWB.js';
|
|
2
|
+
export { FEATURE_PLATFORMS } from './chunk-B6WRD3WF.js';
|
|
3
|
+
export { statusOn } from './chunk-OW46SL2G.js';
|
|
4
|
+
//# sourceMappingURL=gate.js.map
|
|
5
|
+
//# sourceMappingURL=gate.js.map
|
package/dist/gate.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"gate.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { F as Features, b as FeatureRecord, a as Flags } from './model-
|
|
2
|
-
export {
|
|
1
|
+
import { F as Features, b as FeatureRecord, a as Flags } from './model-8dMGbgtM.js';
|
|
2
|
+
export { c as FEATURE_HORIZONS, d as FEATURE_LAYERS, e as FeatureDef, f as FeatureHorizon, g as FeatureIdOf, h as FeatureLayer, i as FeatureLinks, j as FeatureMedia, k as FeatureRegistryError, l as FeatureVisibility, m as FindOptions, n as FlagDef, o as defineFeatures, p as defineFlags, q as expiredFlags, r as featureSchema, s as findFeatures, t as flagSchema, u as flagsForFeature, v as toRecords } from './model-8dMGbgtM.js';
|
|
3
3
|
export { BlockContributions, BlockDataUse, BlockDef, BlockError, BlockMigration, BlockNavItem, BlockPrivacy, BlockRoute, BlockSettingsRow, Contributed, EnabledBlocks, ResolveBlocksOptions, ResolvedBlocks, defineBlock, resolveBlocks } from './blocks.js';
|
|
4
|
+
export { F as FeatureOff, G as GateAnswer, b as GateContext, c as GateFeature, d as GateFlag, e as GateReason, f as GateRegistry, a as GateSnapshot, g as GateSnapshotOptions, I as IdSet, S as SHIPPED_STATUSES, h as featureOn, i as fromSnapshot, j as gateSnapshot, k as isSnapshotStale, r as requireFeature } from './gate-BY352cd0.js';
|
|
4
5
|
export { a as FEATURE_PLATFORMS, F as FeaturePlatform } from './platforms-NR0liM8L.js';
|
|
6
|
+
export { d as FEATURE_STATUSES, e as FLAG_KINDS, b as FeatureAccess, a as FeatureStatus, c as FlagKind, F as FlagValue } from './types-Bd766VxF.js';
|
|
7
|
+
export { statusOn } from './gate.js';
|
|
5
8
|
import 'zod';
|
|
6
9
|
|
|
7
10
|
/** Marks the start of the generated block in AGENTS.md. */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export { BlockError, defineBlock, resolveBlocks } from './chunk-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { BlockError, defineBlock, resolveBlocks } from './chunk-4Q356635.js';
|
|
2
|
+
export { FeatureOff, SHIPPED_STATUSES, featureOn, fromSnapshot, gateSnapshot, isSnapshotStale, requireFeature } from './chunk-LNVWVPWB.js';
|
|
3
|
+
export { AGENTS_BLOCK_END, AGENTS_BLOCK_START, BrokenBlockError, FEATURE_HORIZONS, FEATURE_LAYERS, FEATURE_STATUSES, FLAG_KINDS, FeatureRegistryError, MARKETING_BLOCK_END, MARKETING_BLOCK_START, OPENFEATURE_MANIFEST_SCHEMA, defineFeatures, defineFlags, expiredFlags, featureSchema, findFeatures, flagSchema, flagsForFeature, marketingRecords, readAgentsBlock, replaceAgentsBlock, toAgentsMarkdown, toJson, toMarketingMarkdown, toOpenFeatureManifest, toRecords, toSkillMarkdown } from './chunk-JMXJZT6O.js';
|
|
4
|
+
export { cycleProblems, dependencyOrder, requirementProblem, requiresProblems } from './chunk-VYUX7VAX.js';
|
|
5
|
+
export { FEATURE_PLATFORMS } from './chunk-B6WRD3WF.js';
|
|
6
|
+
export { statusOn } from './chunk-OW46SL2G.js';
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { F as FeaturePlatform } from './platforms-NR0liM8L.js';
|
|
3
|
+
import { a as FeatureStatus, b as FeatureAccess, c as FlagKind, F as FlagValue } from './types-Bd766VxF.js';
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* Where a feature is in its life. The order is the board's column order.
|
|
6
|
-
* `idea` is captured but not agreed: it is in the list so `find` turns it up
|
|
7
|
-
* before someone builds the same thing twice.
|
|
8
|
-
*
|
|
9
|
-
* @stability Beta
|
|
10
|
-
*/
|
|
11
|
-
declare const FEATURE_STATUSES: readonly ["idea", "planned", "building", "beta", "live", "deprecated", "retired"];
|
|
12
|
-
/** @stability Beta */
|
|
13
|
-
type FeatureStatus = (typeof FEATURE_STATUSES)[number];
|
|
14
5
|
/**
|
|
15
6
|
* When a planned or building feature is due, without dates: the roadmap's
|
|
16
7
|
* three columns.
|
|
@@ -27,15 +18,6 @@ type FeatureHorizon = (typeof FEATURE_HORIZONS)[number];
|
|
|
27
18
|
* @stability Beta
|
|
28
19
|
*/
|
|
29
20
|
type FeatureVisibility = "internal" | "customer" | "public" | `client:${string}`;
|
|
30
|
-
/**
|
|
31
|
-
* Who gets a feature: everyone, or one paid plan. The feature id doubles as
|
|
32
|
-
* the billing entitlement's lookup key (a Stripe `lookup_key`).
|
|
33
|
-
*
|
|
34
|
-
* @stability Beta
|
|
35
|
-
*/
|
|
36
|
-
type FeatureAccess = "all" | {
|
|
37
|
-
plan: string;
|
|
38
|
-
};
|
|
39
21
|
/**
|
|
40
22
|
* Pointers from a feature to where it lives. `code` paths are relative to the
|
|
41
23
|
* repository root and `genesis features check` fails when one doesn't exist.
|
|
@@ -131,20 +113,6 @@ interface FeatureDef {
|
|
|
131
113
|
/** The parts an app can replace or drop through `slots`. */
|
|
132
114
|
slots?: readonly string[];
|
|
133
115
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Why a flag exists. `release` and `experiment` flags need `expires`, `ops`
|
|
136
|
-
* flags need a `runbook`, and `permission` flags fail `check`: paid access
|
|
137
|
-
* belongs in entitlements (`access`), not flags.
|
|
138
|
-
*
|
|
139
|
-
* @stability Beta
|
|
140
|
-
*/
|
|
141
|
-
declare const FLAG_KINDS: readonly ["release", "experiment", "ops", "permission"];
|
|
142
|
-
/** @stability Beta */
|
|
143
|
-
type FlagKind = (typeof FLAG_KINDS)[number];
|
|
144
|
-
/** A flag's default: anything an OpenFeature flag can hold. */
|
|
145
|
-
type FlagValue = boolean | string | number | {
|
|
146
|
-
readonly [key: string]: unknown;
|
|
147
|
-
};
|
|
148
116
|
/**
|
|
149
117
|
* One flag. `feature` names the {@link FeatureDef} it belongs to; a feature's
|
|
150
118
|
* flags are found by reverse lookup ({@link flagsForFeature}) and never
|
|
@@ -385,8 +353,7 @@ interface FindOptions {
|
|
|
385
353
|
layer?: FeatureLayer;
|
|
386
354
|
status?: FeatureStatus;
|
|
387
355
|
}
|
|
388
|
-
|
|
389
|
-
declare function statusOn(def: FeatureDef, platform: FeaturePlatform): FeatureStatus | undefined;
|
|
356
|
+
|
|
390
357
|
/**
|
|
391
358
|
* Features matching `term` in their id, aliases, name, keywords, summary,
|
|
392
359
|
* tagline, category, import paths, slots, contributions or code paths, best
|
|
@@ -397,4 +364,4 @@ declare function statusOn(def: FeatureDef, platform: FeaturePlatform): FeatureSt
|
|
|
397
364
|
*/
|
|
398
365
|
declare function findFeatures(features: Features, term: string, flags?: Flags, options?: FindOptions): FeatureRecord[];
|
|
399
366
|
|
|
400
|
-
export {
|
|
367
|
+
export { type Features as F, type Flags as a, type FeatureRecord as b, FEATURE_HORIZONS as c, FEATURE_LAYERS as d, type FeatureDef as e, type FeatureHorizon as f, type FeatureIdOf as g, type FeatureLayer as h, type FeatureLinks as i, type FeatureMedia as j, FeatureRegistryError as k, type FeatureVisibility as l, type FindOptions as m, type FlagDef as n, defineFeatures as o, defineFlags as p, expiredFlags as q, featureSchema as r, findFeatures as s, flagSchema as t, flagsForFeature as u, toRecords as v };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { F as Features, a as Flags } from './model-
|
|
1
|
+
import { F as Features, a as Flags } from './model-8dMGbgtM.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import './platforms-NR0liM8L.js';
|
|
4
|
+
import './types-Bd766VxF.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Where a repo keeps its registry's outputs and what `check` scans. Every
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { BrokenBlockError, expiredFlags, toAgentsMarkdown, readAgentsBlock, replaceAgentsBlock, toJson, toOpenFeatureManifest, toSkillMarkdown, toMarketingMarkdown, readBlock, MARKETING_BLOCK_START, MARKETING_BLOCK_END, replaceBlock } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { BrokenBlockError, expiredFlags, toAgentsMarkdown, readAgentsBlock, replaceAgentsBlock, toJson, toOpenFeatureManifest, toSkillMarkdown, toMarketingMarkdown, readBlock, MARKETING_BLOCK_START, MARKETING_BLOCK_END, replaceBlock } from './chunk-JMXJZT6O.js';
|
|
2
|
+
import './chunk-VYUX7VAX.js';
|
|
3
|
+
import './chunk-B6WRD3WF.js';
|
|
4
|
+
import './chunk-OW46SL2G.js';
|
|
3
5
|
import { existsSync, readFileSync, readdirSync, mkdirSync, writeFileSync } from 'fs';
|
|
4
6
|
import { join, dirname } from 'path';
|
|
5
7
|
|