@fireweaveai/server-sdk 2.2.1-staging.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.
Files changed (58) hide show
  1. package/README.md +263 -0
  2. package/dist/application/client.d.ts +92 -0
  3. package/dist/application/client.d.ts.map +1 -0
  4. package/dist/application/client.js +156 -0
  5. package/dist/application/client.js.map +1 -0
  6. package/dist/application/mode.d.ts +71 -0
  7. package/dist/application/mode.d.ts.map +1 -0
  8. package/dist/application/mode.js +72 -0
  9. package/dist/application/mode.js.map +1 -0
  10. package/dist/application/ports.d.ts +95 -0
  11. package/dist/application/ports.d.ts.map +1 -0
  12. package/dist/application/ports.js +2 -0
  13. package/dist/application/ports.js.map +1 -0
  14. package/dist/application/runtime.d.ts +102 -0
  15. package/dist/application/runtime.d.ts.map +1 -0
  16. package/dist/application/runtime.js +342 -0
  17. package/dist/application/runtime.js.map +1 -0
  18. package/dist/domain/context.d.ts +68 -0
  19. package/dist/domain/context.d.ts.map +1 -0
  20. package/dist/domain/context.js +85 -0
  21. package/dist/domain/context.js.map +1 -0
  22. package/dist/domain/errors.d.ts +43 -0
  23. package/dist/domain/errors.d.ts.map +1 -0
  24. package/dist/domain/errors.js +64 -0
  25. package/dist/domain/errors.js.map +1 -0
  26. package/dist/domain/target.d.ts +3 -0
  27. package/dist/domain/target.d.ts.map +1 -0
  28. package/dist/domain/target.js +2 -0
  29. package/dist/domain/target.js.map +1 -0
  30. package/dist/domain/types.d.ts +108 -0
  31. package/dist/domain/types.d.ts.map +1 -0
  32. package/dist/domain/types.js +2 -0
  33. package/dist/domain/types.js.map +1 -0
  34. package/dist/domain/validation.d.ts +125 -0
  35. package/dist/domain/validation.d.ts.map +1 -0
  36. package/dist/domain/validation.js +347 -0
  37. package/dist/domain/validation.js.map +1 -0
  38. package/dist/index.d.ts +35 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +23 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/infrastructure/adapters/inmemory.d.ts +78 -0
  43. package/dist/infrastructure/adapters/inmemory.d.ts.map +1 -0
  44. package/dist/infrastructure/adapters/inmemory.js +148 -0
  45. package/dist/infrastructure/adapters/inmemory.js.map +1 -0
  46. package/dist/infrastructure/adapters/local.d.ts +109 -0
  47. package/dist/infrastructure/adapters/local.d.ts.map +1 -0
  48. package/dist/infrastructure/adapters/local.js +102 -0
  49. package/dist/infrastructure/adapters/local.js.map +1 -0
  50. package/dist/infrastructure/adapters/remote.d.ts +75 -0
  51. package/dist/infrastructure/adapters/remote.d.ts.map +1 -0
  52. package/dist/infrastructure/adapters/remote.js +361 -0
  53. package/dist/infrastructure/adapters/remote.js.map +1 -0
  54. package/dist/infrastructure/hosts.d.ts +19 -0
  55. package/dist/infrastructure/hosts.d.ts.map +1 -0
  56. package/dist/infrastructure/hosts.js +68 -0
  57. package/dist/infrastructure/hosts.js.map +1 -0
  58. package/package.json +56 -0
@@ -0,0 +1,347 @@
1
+ /**
2
+ * Fireweave SDK validation — pure, total functions per spec/control-points.md
3
+ * "Validation, before any I/O" and spec/modes.md "Initialisation validation".
4
+ *
5
+ * Every read-path validator here (`validateControlPointKey`,
6
+ * `validateDefaultValue`, `validateContext`, `validateTargetingKey`) returns
7
+ * `Validated<T>` instead of throwing. `FireweaveRuntime.evaluate` runs them,
8
+ * in the fixed order the spec names — key, default-vs-type, context,
9
+ * lifecycle — and degrades to the caller's default on the first failure; it
10
+ * NEVER throws (spec/control-points.md "Return discipline — never throw into
11
+ * a read path").
12
+ *
13
+ * `validateInitOptions` is the one named exception (spec/modes.md
14
+ * "Initialisation validation"): its failures are converted to a THROW by
15
+ * `initFireweave` (src/init.ts). The validator itself still returns
16
+ * `Validated<T>` — the entry point does the throwing, not this module.
17
+ *
18
+ * Collected into one module so it can move wholesale into `domain/` (plan
19
+ * Phase 1.4) without touching its exports or call sites again. Everything
20
+ * below is pure (no I/O, no ambient state) and total (every branch returns a
21
+ * `Validated<T>`) — `conformance/` can exercise all four read-path rules
22
+ * offline, with no backend.
23
+ *
24
+ * `validateInitOptions` is deliberately generic rather than importing
25
+ * `InitFireweaveOptions` from `init.ts`: init.ts is the "mode" entry point
26
+ * (Phase 1.4 assigns it to `application/`), and this module is destined for
27
+ * `domain/`, which must not depend on outer layers. It also does not
28
+ * validate "apiUrl fails the host allowlist" (spec/modes.md row 3) — that
29
+ * check (`assertHostAllowed`) lives in `hosts.ts`, which Phase 1.4 assigns to
30
+ * `infrastructure/`; it stays reachable today via `FireweaveRuntime.initialize`
31
+ * (runtime.ts) / `FireweaveRemoteAdapter.initialize` (adapters/remote.ts),
32
+ * unchanged by this module.
33
+ */
34
+ import { FireweaveError } from './errors.js';
35
+ import { ALLOWED_FIREWEAVE_CONTEXT_KEYS } from './context.js';
36
+ const ok = (value) => ({ ok: true, value });
37
+ const fail = (error) => ({ ok: false, error });
38
+ // ---------------------------------------------------------------------------
39
+ // Rule 1 — validateControlPointKey (spec/control-points.md "Validation,
40
+ // before any I/O": "key — non-empty, ≤256 characters, no control characters")
41
+ // ---------------------------------------------------------------------------
42
+ /** C0 + C1 control characters (U+0000-U+001F, U+007F-U+009F). */
43
+ const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/;
44
+ const MAX_CONTROL_POINT_KEY_LENGTH = 256;
45
+ /**
46
+ * key — non-empty, ≤256 characters, no control characters
47
+ * (spec/control-points.md rule 1, the first check in the fixed order).
48
+ *
49
+ * No taxonomy kind names "malformed key" explicitly (the return-discipline
50
+ * table's closest row is "key unknown to the backend" → FlagNotFound): a key
51
+ * that can never identify a flag is treated the same as one the backend
52
+ * doesn't recognise, so this maps to FlagNotFound too.
53
+ *
54
+ * Controller-ruled interim mapping (Task 3 review): the 15-kind taxonomy in
55
+ * errors.schema.json is frozen at exactly 15 entries, `InvalidContext` is
56
+ * textually scoped to the evaluation *context* (not the key), and the
57
+ * schema already maps another non-literal case — quota-limited responses —
58
+ * onto `FlagNotFound` rather than adding a kind for it. `FlagNotFound` is
59
+ * therefore the least-wrong existing kind, not a literal fit. Other-language
60
+ * implementations copying node as the reference SHOULD use the same mapping
61
+ * rather than each independently guessing a different one.
62
+ */
63
+ export function validateControlPointKey(key) {
64
+ if (typeof key !== 'string' || key.length === 0) {
65
+ return fail(new FireweaveError('FlagNotFound', { message: 'control point key must be a non-empty string' }));
66
+ }
67
+ if (key.length > MAX_CONTROL_POINT_KEY_LENGTH) {
68
+ return fail(new FireweaveError('FlagNotFound', { message: 'control point key exceeds maximum length' }));
69
+ }
70
+ if (CONTROL_CHARACTERS.test(key)) {
71
+ return fail(new FireweaveError('FlagNotFound', { message: 'control point key contains control characters' }));
72
+ }
73
+ return ok(key);
74
+ }
75
+ /**
76
+ * Whether `value` matches the shape `expected` names. Shared by
77
+ * {@link validateDefaultValue} (the caller's default, before any I/O) and
78
+ * `FireweaveRuntime.evaluate`'s post-resolve check (the backend's resolved
79
+ * value, after I/O) — same predicate, two different inputs.
80
+ */
81
+ export function matchesExpectedType(value, expected) {
82
+ switch (expected) {
83
+ case 'boolean':
84
+ return typeof value === 'boolean';
85
+ case 'string':
86
+ return typeof value === 'string';
87
+ case 'number':
88
+ return typeof value === 'number';
89
+ case 'object':
90
+ return value !== null && typeof value === 'object';
91
+ }
92
+ }
93
+ /**
94
+ * default vs type — e.g. `getBooleanValue` with a non-boolean default is
95
+ * TypeMismatch (spec/control-points.md rule 2, checked before any I/O).
96
+ */
97
+ export function validateDefaultValue(expectedType, defaultValue) {
98
+ if (!matchesExpectedType(defaultValue, expectedType)) {
99
+ return fail(new FireweaveError('TypeMismatch'));
100
+ }
101
+ return ok(defaultValue);
102
+ }
103
+ // ---------------------------------------------------------------------------
104
+ // validateTargetingKey (spec/control-points.md "Context": targetingKey)
105
+ // ---------------------------------------------------------------------------
106
+ /**
107
+ * targetingKey: "An SDK MUST NOT invent one: a missing targeting key is
108
+ * InvalidContext where the evaluation needs it, never a generated anonymous
109
+ * id" (spec/control-points.md "Context"). `required` is call-site policy —
110
+ * the remote adapter always requires one for `resolve`/`registerTarget`
111
+ * (spec/remote-protocol.md "Two identity paths"); the generic context
112
+ * pipeline ({@link validateContext}) only does when
113
+ * `ContextPolicy.requireTargetingKey` opts in.
114
+ */
115
+ export function validateTargetingKey(targetingKey, required) {
116
+ if (required && (targetingKey === undefined || targetingKey === '')) {
117
+ return fail(new FireweaveError('InvalidContext', {
118
+ message: 'targeting key missing',
119
+ openFeatureErrorCode: 'TARGETING_KEY_MISSING',
120
+ }));
121
+ }
122
+ return ok(targetingKey);
123
+ }
124
+ // ---------------------------------------------------------------------------
125
+ // Rule 3 — validateContext (spec/control-points.md rule 3: "context — depth,
126
+ // key count, value size, reserved keys (evaluation-context.schema.json)")
127
+ // ---------------------------------------------------------------------------
128
+ /**
129
+ * UTF-8 byte length. `TextEncoder` rather than `Buffer.byteLength`: `Buffer`
130
+ * is a Node global that Deno only exposes under npm compatibility, and this
131
+ * bound is enforced on every evaluation (ADR-0008 runtime portability).
132
+ */
133
+ const utf8Encoder = new TextEncoder();
134
+ const byteLength = (s) => utf8Encoder.encode(s).length;
135
+ /**
136
+ * Sentinel returned (never thrown) when `deepCopyJson` walks back into an
137
+ * object already on the current recursion path — an actual reference cycle,
138
+ * not merely the same object shared by two sibling branches (which is legal
139
+ * and handled by backtracking `seen.delete(...)` below). Untyped caller
140
+ * input is `unknown`, so a circular attribute value is reachable from a
141
+ * caller today; without this, recursion never terminates and crashes the
142
+ * whole process with `RangeError: Maximum call stack size exceeded` —
143
+ * exactly the kind of throw a "before any I/O" validator must not allow
144
+ * (spec/control-points.md "Return discipline — never throw into a read
145
+ * path"). Module-local: never returned across this file's public surface,
146
+ * only used to fail `validateContext` closed as `InvalidContext`.
147
+ */
148
+ const CYCLIC = Symbol('fireweave.cyclicJson');
149
+ function deepCopyJson(value, seen = new WeakSet()) {
150
+ // Structured clone of JSON-compatible data; drops functions/undefined like JSON round-trip.
151
+ if (value === null || typeof value === 'string' || typeof value === 'boolean' || typeof value === 'number') {
152
+ return value;
153
+ }
154
+ if (Array.isArray(value)) {
155
+ if (seen.has(value))
156
+ return CYCLIC;
157
+ seen.add(value);
158
+ const out = [];
159
+ for (const v of value) {
160
+ const copied = deepCopyJson(v, seen);
161
+ if (copied === CYCLIC)
162
+ return CYCLIC;
163
+ out.push(copied);
164
+ }
165
+ seen.delete(value);
166
+ return out;
167
+ }
168
+ if (typeof value === 'object') {
169
+ if (seen.has(value))
170
+ return CYCLIC;
171
+ seen.add(value);
172
+ const out = {};
173
+ for (const [k, v] of Object.entries(value)) {
174
+ if (v !== undefined) {
175
+ const copied = deepCopyJson(v, seen);
176
+ if (copied === CYCLIC)
177
+ return CYCLIC;
178
+ out[k] = copied;
179
+ }
180
+ }
181
+ seen.delete(value);
182
+ return out;
183
+ }
184
+ return null;
185
+ }
186
+ /**
187
+ * Cycle-safe defensively: `nestingDepth` only ever runs on `deepCopyJson`'s
188
+ * own output today, which is guaranteed acyclic by construction (it builds
189
+ * fresh containers, never back-references). Guarded anyway per the same
190
+ * "must be genuinely total" reasoning as `deepCopyJson`, so a future caller
191
+ * (e.g. a Task 4 reuse) can't reintroduce the same crash by feeding this
192
+ * function un-copied input. A detected cycle returns `Infinity`, which
193
+ * always exceeds `limits.maxNestingDepth` and fails closed through the
194
+ * existing bound check in {@link validateContext} — no new failure path.
195
+ */
196
+ function nestingDepth(value, seen = new WeakSet()) {
197
+ if (value === null || typeof value !== 'object')
198
+ return 0;
199
+ if (seen.has(value))
200
+ return Infinity;
201
+ seen.add(value);
202
+ let max = 0;
203
+ const children = Array.isArray(value) ? value : Object.values(value);
204
+ for (const child of children) {
205
+ const d = nestingDepth(child, seen);
206
+ if (d > max)
207
+ max = d;
208
+ }
209
+ seen.delete(value);
210
+ return max + 1;
211
+ }
212
+ const invalidContext = (message) => new FireweaveError('InvalidContext', { message });
213
+ /**
214
+ * context — depth, key count, value size, reserved keys
215
+ * (evaluation-context.schema.json) (spec/control-points.md rule 3). Also
216
+ * enforces `policy.requireTargetingKey` via {@link validateTargetingKey}, and
217
+ * — on success — extracts `groups`/`groupProperties` the same way the former
218
+ * `canonicalizeContext` did.
219
+ *
220
+ * `merged` is the already-merged (global → client → invocation) raw input;
221
+ * merging itself (`mergeContexts`) lives in context.ts and carries no
222
+ * validation concerns of its own.
223
+ */
224
+ export function validateContext(merged, policy) {
225
+ const { limits } = policy;
226
+ const copied = deepCopyJson(merged.attributes);
227
+ if (copied === CYCLIC) {
228
+ return fail(invalidContext('context contains a circular reference'));
229
+ }
230
+ const attributes = copied;
231
+ const keys = Object.keys(attributes);
232
+ if (keys.length > limits.maxAttributeCount) {
233
+ return fail(invalidContext('context exceeds maximum attribute count'));
234
+ }
235
+ for (const key of keys) {
236
+ if (byteLength(key) > limits.maxKeyBytes) {
237
+ return fail(invalidContext('context key exceeds maximum size'));
238
+ }
239
+ }
240
+ for (const key of keys) {
241
+ const value = attributes[key];
242
+ if (byteLength(JSON.stringify(value ?? null)) > limits.maxValueBytes) {
243
+ return fail(invalidContext('context value exceeds maximum size'));
244
+ }
245
+ }
246
+ for (const key of keys) {
247
+ const value = attributes[key];
248
+ if (value !== undefined && nestingDepth(value) > limits.maxNestingDepth) {
249
+ return fail(invalidContext('context exceeds maximum nesting depth'));
250
+ }
251
+ }
252
+ const serialized = JSON.stringify({ targetingKey: merged.targetingKey, attributes });
253
+ if (byteLength(serialized) > limits.maxSerializedContextBytes) {
254
+ return fail(invalidContext('serialized context exceeds maximum size'));
255
+ }
256
+ for (const key of keys) {
257
+ if (policy.reservedAttributeKeys.includes(key)) {
258
+ return fail(invalidContext('invalid evaluation context'));
259
+ }
260
+ // Ruling 13: exactly fireweave.groups + fireweave.groupProperties are
261
+ // permitted in the reserved namespace; every other fireweave.* key is rejected.
262
+ if (key.startsWith('fireweave.') && !ALLOWED_FIREWEAVE_CONTEXT_KEYS.includes(key)) {
263
+ return fail(invalidContext('invalid evaluation context'));
264
+ }
265
+ }
266
+ const targetingKeyResult = validateTargetingKey(merged.targetingKey, policy.requireTargetingKey);
267
+ if (!targetingKeyResult.ok)
268
+ return targetingKeyResult;
269
+ const canonical = { attributes };
270
+ if (merged.targetingKey !== undefined)
271
+ canonical.targetingKey = merged.targetingKey;
272
+ // Group memberships: canonical carrier `fireweave.groups` (rulings 13–14),
273
+ // with plain `groups` retained as a documented alias.
274
+ const groups = attributes['fireweave.groups'] ?? attributes['groups'];
275
+ if (groups !== null && groups !== undefined && typeof groups === 'object' && !Array.isArray(groups)) {
276
+ const g = {};
277
+ let allStrings = true;
278
+ for (const [k, v] of Object.entries(groups)) {
279
+ if (typeof v === 'string')
280
+ g[k] = v;
281
+ else
282
+ allStrings = false;
283
+ }
284
+ if (allStrings)
285
+ canonical.groups = g;
286
+ }
287
+ // Group properties: canonical carrier `fireweave.groupProperties`,
288
+ // plain `groupProperties` retained as alias.
289
+ const groupProps = attributes['fireweave.groupProperties'] ?? attributes['groupProperties'];
290
+ if (groupProps !== null &&
291
+ groupProps !== undefined &&
292
+ typeof groupProps === 'object' &&
293
+ !Array.isArray(groupProps)) {
294
+ canonical.groupProperties = groupProps;
295
+ }
296
+ return ok(canonical);
297
+ }
298
+ /**
299
+ * Throwing wrapper around {@link validateContext} kept for the pre-existing
300
+ * public surface (`FireweaveRuntime.resolveContext`, direct callers of the
301
+ * package export). Read paths do not use this — they call
302
+ * {@link validateContext} directly so a failure degrades instead of throwing.
303
+ */
304
+ export function canonicalizeContext(merged, policy) {
305
+ const result = validateContext(merged, policy);
306
+ if (!result.ok)
307
+ throw result.error;
308
+ return result.value;
309
+ }
310
+ // ---------------------------------------------------------------------------
311
+ // validateInitOptions (spec/modes.md "Initialisation validation")
312
+ // ---------------------------------------------------------------------------
313
+ /** "missing" and "blank" collapse to one check: not a non-empty string. */
314
+ const isBlank = (value) => typeof value !== 'string' || value.trim().length === 0;
315
+ const configError = (message) => new FireweaveError('Configuration', { message });
316
+ /**
317
+ * Initialisation-validation table (spec/modes.md), rows 1, 2 and 4:
318
+ * - `mode` absent or unrecognised
319
+ * - `mode: 'remote'` with `apiKey` or `apiUrl` missing/blank
320
+ * - `mode: 'local'` with credentials supplied (a config half-migrated from
321
+ * remote to local reads as neither, silently — reject it instead)
322
+ *
323
+ * Row 3 ("apiUrl fails the host allowlist") is intentionally NOT checked
324
+ * here — see the module doc comment.
325
+ */
326
+ export function validateInitOptions(options) {
327
+ const mode = options?.mode;
328
+ if (mode !== 'local' && mode !== 'remote') {
329
+ return fail(configError('mode is required and must be "local" or "remote"'));
330
+ }
331
+ // Runtime-only guard: a config object half-migrated from remote to local
332
+ // can carry apiKey/apiUrl even though the local-mode type declares
333
+ // neither — TypeScript's excess-property check only fires on a fresh
334
+ // object literal, not on a variable assembled elsewhere and passed in.
335
+ const credentials = options;
336
+ if (mode === 'remote') {
337
+ if (isBlank(credentials.apiKey) || isBlank(credentials.apiUrl)) {
338
+ return fail(configError('mode "remote" requires apiKey and apiUrl'));
339
+ }
340
+ return ok(options);
341
+ }
342
+ if (!isBlank(credentials.apiKey) || !isBlank(credentials.apiUrl)) {
343
+ return fail(configError('mode "local" must not be combined with apiKey/apiUrl — the caller means one or the other'));
344
+ }
345
+ return ok(options);
346
+ }
347
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/domain/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,8BAA8B,EAAsB,MAAM,cAAc,CAAC;AAMlF,MAAM,EAAE,GAAG,CAAI,KAAQ,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAChE,MAAM,IAAI,GAAG,CAAI,KAAqB,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;AAEhF,8EAA8E;AAC9E,wEAAwE;AACxE,8EA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AAI,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAC,CAAC;IAC/E,CAAC;IACD,yEAAyE;IACzE,mEAAmE;IACnE,qEAAqE;IACrE,uEAAuE;IACvE,MAAM,WAAW,GAAG,OAA4D,CAAC;IACjF,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC,WAAW,CAAC,0CAA0C,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,OAAO,IAAI,CACT,WAAW,CAAC,0FAA0F,CAAC,CACxG,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fireweaveai/server-sdk — Fireweave release-engineering SDK for server runtimes
3
+ * (Node, Bun, Deno). Public API per docs/architecture.md §6.
4
+ *
5
+ * Exactly two v1 capabilities (spec/control-points.md): control points and
6
+ * target registration.
7
+ *
8
+ * Production default: {@link FireweaveRemoteAdapter} (Fireweave project key →
9
+ * fw-server). {@link InMemoryAdapter} for offline work and tests. The backend
10
+ * fw-server forwards to is fw-server's concern — no vendor SDK, key, or host
11
+ * appears in the application process (ADR-0005, ADR-0006).
12
+ */
13
+ export { FireweaveError, ERROR_TAXONOMY, redactSecrets, isFireweaveError } from './domain/errors.js';
14
+ export type { FireweaveErrorKind, OpenFeatureErrorCode, ErrorKindSpec } from './domain/errors.js';
15
+ export type { JsonValue, Decision, DecisionReason, CanonicalContext, LifecycleState, Signal, SignalKind, ReleaseContext, ReleaseState, ReleaseStatus, Exposure, Capabilities, FlagValueType, } from './domain/types.js';
16
+ export { DEFAULT_CONTEXT_LIMITS, DEFAULT_RESERVED_ATTRIBUTE_KEYS, ALLOWED_FIREWEAVE_CONTEXT_KEYS, mergeContexts, normalizeContextInput, resolvedContextView, } from './domain/context.js';
17
+ export type { ContextInput, ContextLimits, ContextPolicy } from './domain/context.js';
18
+ export { canonicalizeContext, validateControlPointKey, validateDefaultValue, validateContext, validateTargetingKey, validateInitOptions, } from './domain/validation.js';
19
+ export type { Validated } from './domain/validation.js';
20
+ export type { BackendAdapter, AdapterResolution, AdapterRuntimeFeatures, RegisterTargetOptions, RegisterTargetResult, ResolveOptions, } from './application/ports.js';
21
+ export type { TargetKind } from './domain/target.js';
22
+ export { InMemoryAdapter } from './infrastructure/adapters/inmemory.js';
23
+ export type { InMemoryAdapterOptions, InMemoryFlagDefinition, InMemoryFault } from './infrastructure/adapters/inmemory.js';
24
+ export { FireweaveRemoteAdapter } from './infrastructure/adapters/remote.js';
25
+ export type { FireweaveRemoteAdapterOptions } from './infrastructure/adapters/remote.js';
26
+ export { FireweaveLocalAdapter } from './infrastructure/adapters/local.js';
27
+ export type { FireweaveLocalAdapterOptions } from './infrastructure/adapters/local.js';
28
+ export { DEFAULT_ALLOWED_HOSTS, assertHostAllowed, isLoopbackHostname } from './infrastructure/hosts.js';
29
+ export { FireweaveRuntime, stableStringify, DEFAULT_SHUTDOWN_TIMEOUT_MS } from './application/runtime.js';
30
+ export type { FireweaveRuntimeConfig, EvaluateOptions, ExpectedFlagType } from './application/runtime.js';
31
+ export { FireweaveClient } from './application/client.js';
32
+ export type { ControlPointsApi, FireweaveClientOptions } from './application/client.js';
33
+ export { initFireweave } from './application/mode.js';
34
+ export type { InitFireweaveOptions, InitFireweaveLocalOptions, InitFireweaveRemoteOptions, } from './application/mode.js';
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mapp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4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAGvF,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEzG,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC1G,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG1G,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,YAAY,EACV,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @fireweaveai/server-sdk — Fireweave release-engineering SDK for server runtimes
3
+ * (Node, Bun, Deno). Public API per docs/architecture.md §6.
4
+ *
5
+ * Exactly two v1 capabilities (spec/control-points.md): control points and
6
+ * target registration.
7
+ *
8
+ * Production default: {@link FireweaveRemoteAdapter} (Fireweave project key →
9
+ * fw-server). {@link InMemoryAdapter} for offline work and tests. The backend
10
+ * fw-server forwards to is fw-server's concern — no vendor SDK, key, or host
11
+ * appears in the application process (ADR-0005, ADR-0006).
12
+ */
13
+ export { FireweaveError, ERROR_TAXONOMY, redactSecrets, isFireweaveError } from './domain/errors.js';
14
+ export { DEFAULT_CONTEXT_LIMITS, DEFAULT_RESERVED_ATTRIBUTE_KEYS, ALLOWED_FIREWEAVE_CONTEXT_KEYS, mergeContexts, normalizeContextInput, resolvedContextView, } from './domain/context.js';
15
+ export { canonicalizeContext, validateControlPointKey, validateDefaultValue, validateContext, validateTargetingKey, validateInitOptions, } from './domain/validation.js';
16
+ export { InMemoryAdapter } from './infrastructure/adapters/inmemory.js';
17
+ export { FireweaveRemoteAdapter } from './infrastructure/adapters/remote.js';
18
+ export { FireweaveLocalAdapter } from './infrastructure/adapters/local.js';
19
+ export { DEFAULT_ALLOWED_HOSTS, assertHostAllowed, isLoopbackHostname } from './infrastructure/hosts.js';
20
+ export { FireweaveRuntime, stableStringify, DEFAULT_SHUTDOWN_TIMEOUT_MS } from './application/runtime.js';
21
+ export { FireweaveClient } from './application/client.js';
22
+ export { initFireweave } from './application/mode.js';
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAmBrG,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,8BAA8B,EAC9B,aAAa,EACb,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAahC,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAG7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAI3E,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEzG,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAI1G,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Deterministic in-memory adapter for tests and conformance fixtures.
3
+ * Resolution model mirrors contracts/ fixture flag definitions: flags, variants,
4
+ * payloads, targeting by targeting key / person attributes / groups.
5
+ * Deliberately NO bucketing / percentage logic.
6
+ */
7
+ import { type FireweaveErrorKind } from '../../domain/errors.js';
8
+ import type { AdapterResolution, AdapterRuntimeFeatures, BackendAdapter, ResolveOptions } from '../../application/ports.js';
9
+ import type { CanonicalContext, DecisionReason, Exposure, JsonValue, Signal } from '../../domain/types.js';
10
+ export interface InMemoryFlagDefinition {
11
+ type: 'boolean' | 'string' | 'integer' | 'float' | 'object';
12
+ enabled: boolean;
13
+ value: JsonValue;
14
+ variant?: string;
15
+ variants?: string[];
16
+ payload?: JsonValue;
17
+ reason?: {
18
+ code?: string;
19
+ condition_index?: number;
20
+ description?: string;
21
+ };
22
+ metadata?: {
23
+ version?: number;
24
+ id?: number;
25
+ };
26
+ /** Canonical reason override (fixtures: "SPLIT"). */
27
+ fireweaveReason?: DecisionReason;
28
+ /** Served from last-good cache (stale scenarios). */
29
+ fromCache?: boolean;
30
+ /** Match only when all listed attributes deep-equal context attributes. */
31
+ matchAttribute?: Record<string, JsonValue>;
32
+ /** Match only when context groups contain these entries. */
33
+ matchGroups?: Record<string, string>;
34
+ /** Match only when person attributes contain these entries. */
35
+ matchPerson?: Record<string, JsonValue>;
36
+ /** Match only this exact targetingKey. */
37
+ matchTargetingKey?: string;
38
+ }
39
+ export interface InMemoryFault {
40
+ kind: FireweaveErrorKind;
41
+ metadata?: Record<string, string | number | boolean>;
42
+ }
43
+ export interface InMemoryAdapterOptions {
44
+ flags?: Record<string, InMemoryFlagDefinition>;
45
+ /** Fault to throw on every resolve (fault-mode conformance without HTTP). */
46
+ fault?: InMemoryFault;
47
+ /** Reject initialize() with this error kind. */
48
+ initError?: FireweaveErrorKind;
49
+ /** Delay initialize() until release() is called (cold-start tests). */
50
+ initGate?: {
51
+ promise: Promise<void>;
52
+ };
53
+ }
54
+ export declare class InMemoryAdapter implements BackendAdapter {
55
+ readonly name: "inmemory";
56
+ private flags;
57
+ private fault;
58
+ private readonly initError;
59
+ private readonly initGate;
60
+ private readonly exposures;
61
+ private readonly signals;
62
+ private closed;
63
+ constructor(options?: InMemoryAdapterOptions);
64
+ setFlags(flags: Record<string, InMemoryFlagDefinition>): void;
65
+ setFault(fault: InMemoryFault | undefined): void;
66
+ initialize(signal?: AbortSignal): Promise<void>;
67
+ resolve(flagKey: string, context: CanonicalContext, _options?: ResolveOptions): Promise<AdapterResolution>;
68
+ private matches;
69
+ recordExposure(exposure: Exposure): void;
70
+ getExposures(): readonly Exposure[];
71
+ recordSignal(signal: Signal): void;
72
+ getSignals(): readonly Signal[];
73
+ flush(): Promise<void>;
74
+ shutdown(): Promise<void>;
75
+ isClosed(): boolean;
76
+ features(): AdapterRuntimeFeatures;
77
+ }
78
+ //# sourceMappingURL=inmemory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inmemory.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/adapters/inmemory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5H,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3G,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC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