@railflag/sdk-node 0.0.0-stage → 0.2.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/dist/index.js ADDED
@@ -0,0 +1,526 @@
1
+ // src/index.ts
2
+ import {
3
+ ErrorCode,
4
+ OpenFeatureEventEmitter,
5
+ ProviderEvents,
6
+ StandardResolutionReasons
7
+ } from "@openfeature/server-sdk";
8
+
9
+ // ../eval/src/murmur3.ts
10
+ var C1 = 3432918353;
11
+ var C2 = 461845907;
12
+ function hashBytes(bytes, seed) {
13
+ let h = seed >>> 0;
14
+ const len = bytes.length;
15
+ const n = len & ~3;
16
+ let k;
17
+ for (let i = 0; i < n; i += 4) {
18
+ k = bytes[i] | bytes[i + 1] << 8 | bytes[i + 2] << 16 | bytes[i + 3] << 24;
19
+ k = Math.imul(k, C1);
20
+ k = k << 15 | k >>> 17;
21
+ k = Math.imul(k, C2);
22
+ h ^= k;
23
+ h = h << 13 | h >>> 19;
24
+ h = Math.imul(h, 5) + 3864292196 | 0;
25
+ }
26
+ k = 0;
27
+ const rem = len & 3;
28
+ if (rem === 3) k ^= bytes[n + 2] << 16;
29
+ if (rem >= 2) k ^= bytes[n + 1] << 8;
30
+ if (rem >= 1) {
31
+ k ^= bytes[n];
32
+ k = Math.imul(k, C1);
33
+ k = k << 15 | k >>> 17;
34
+ k = Math.imul(k, C2);
35
+ h ^= k;
36
+ }
37
+ h ^= len;
38
+ h ^= h >>> 16;
39
+ h = Math.imul(h, 2246822507);
40
+ h ^= h >>> 13;
41
+ h = Math.imul(h, 3266489909);
42
+ h ^= h >>> 16;
43
+ return h >>> 0;
44
+ }
45
+ var encoder = new TextEncoder();
46
+ function murmur3(input, seed = 0) {
47
+ return hashBytes(encoder.encode(input), seed);
48
+ }
49
+ function murmur3Latin1(input, seed = 0) {
50
+ const bytes = new Uint8Array(input.length);
51
+ for (let i = 0; i < input.length; i++) bytes[i] = input.charCodeAt(i) & 255;
52
+ return hashBytes(bytes, seed);
53
+ }
54
+
55
+ // ../schema/src/index.ts
56
+ import { z } from "zod";
57
+ var WEIGHT_SCALE = 1e5;
58
+ var flagKey = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "Use letters, digits, dot, dash or underscore, starting with a letter or digit");
59
+ var flagType = z.enum(["boolean", "string", "number", "json"]);
60
+ var flagKind = z.enum(["release", "ops", "experiment", "permission"]);
61
+ var clauseOp = z.enum([
62
+ "in",
63
+ "exists",
64
+ "startsWith",
65
+ "endsWith",
66
+ "contains",
67
+ "matches",
68
+ "lt",
69
+ "lte",
70
+ "gt",
71
+ "gte",
72
+ "semverEq",
73
+ "semverLt",
74
+ "semverGt",
75
+ "before",
76
+ "after",
77
+ "segmentMatch"
78
+ ]);
79
+ var scalar = z.union([z.string(), z.number(), z.boolean()]);
80
+ var clause = z.object({
81
+ attr: z.string().min(1),
82
+ op: clauseOp,
83
+ values: z.array(scalar).min(1),
84
+ negate: z.boolean().optional()
85
+ });
86
+ var bucketing = z.object({
87
+ algorithm: z.enum(["murmur3", "abtasty", "unleash", "unleash-variant"]),
88
+ /** abtasty: the variation group id that seeds the hash. unleash, unleash-variant: the strategy's groupId. */
89
+ seed: z.string().optional(),
90
+ /**
91
+ * unleash-variant: the total variant weight Unleash takes the hash modulo (usually 1000). Unleash bucket x maps
92
+ * to floor(x * WEIGHT_SCALE / modulus), so cumulative boundaries at floor(C * WEIGHT_SCALE / modulus) are exact.
93
+ */
94
+ modulus: z.number().int().positive().max(WEIGHT_SCALE).optional()
95
+ });
96
+ var rollout = z.object({
97
+ bucketBy: z.string().optional(),
98
+ weights: z.array(z.number().int().min(0).max(WEIGHT_SCALE)).min(1),
99
+ bucketing: bucketing.optional(),
100
+ /** Variation indexes in the order their ranges are laid out (default: index order). Vendors such as Unleash walk their own order. */
101
+ order: z.array(z.number().int().min(0)).optional(),
102
+ /**
103
+ * Traffic allocation before the split, hashed separately: only users whose gate bucket is below
104
+ * `weight` get a variation; the rest continue to the next rule. Reproduces vendors that hash twice
105
+ * (Unleash rollout + variants, Split traffic allocation, DevCycle rollout).
106
+ */
107
+ gate: z.object({
108
+ weight: z.number().int().min(0).max(WEIGHT_SCALE),
109
+ bucketBy: z.string().optional(),
110
+ bucketing: bucketing.optional()
111
+ }).optional()
112
+ }).refine((r) => r.weights.reduce((a, b) => a + b, 0) <= WEIGHT_SCALE, {
113
+ message: `Weights must add up to at most ${WEIGHT_SCALE}`
114
+ });
115
+ var serve = z.union([
116
+ z.object({ variation: z.number().int().min(0) }),
117
+ z.object({ rollout })
118
+ ]);
119
+ var rule = z.object({
120
+ id: z.string().min(1),
121
+ name: z.string().optional(),
122
+ clauses: z.array(clause),
123
+ serve
124
+ });
125
+ var target = z.object({
126
+ variation: z.number().int().min(0),
127
+ values: z.array(z.string())
128
+ });
129
+ var prerequisite = z.object({ key: flagKey, variation: z.number().int().min(0) });
130
+ var targeting = z.object({
131
+ enabled: z.boolean(),
132
+ offVariation: z.number().int().min(0),
133
+ fallthrough: serve,
134
+ targets: z.array(target).default([]),
135
+ rules: z.array(rule).default([]),
136
+ prerequisites: z.array(prerequisite).default([])
137
+ });
138
+ var variation = z.object({
139
+ value: z.unknown(),
140
+ name: z.string().optional(),
141
+ description: z.string().optional()
142
+ });
143
+ var segmentRules = z.object({
144
+ included: z.array(z.string()).default([]),
145
+ excluded: z.array(z.string()).default([]),
146
+ rules: z.array(z.object({ clauses: z.array(clause) })).default([])
147
+ });
148
+ var snapshotFlag = targeting.extend({
149
+ key: flagKey,
150
+ type: flagType,
151
+ variations: z.array(z.unknown()).min(1),
152
+ salt: z.string(),
153
+ version: z.number().int()
154
+ });
155
+ var snapshot = z.object({
156
+ env: z.string(),
157
+ version: z.number().int(),
158
+ generatedAt: z.string(),
159
+ flags: z.record(z.string(), snapshotFlag),
160
+ segments: z.record(z.string(), segmentRules)
161
+ });
162
+ var evalReason = z.enum(["STATIC", "DEFAULT", "TARGETING_MATCH", "SPLIT", "DISABLED", "ERROR"]);
163
+
164
+ // ../eval/src/bucket.ts
165
+ var UNLEASH_VARIANT_SEED = 86028157;
166
+ function bucketFor(flagKey2, salt, value, bucketing2) {
167
+ if (bucketing2?.algorithm === "abtasty") {
168
+ const seed = bucketing2.seed ?? "";
169
+ return murmur3Latin1(seed + value) % 100 * (WEIGHT_SCALE / 100);
170
+ }
171
+ if (bucketing2?.algorithm === "unleash") {
172
+ return murmur3Latin1(`${bucketing2.seed ?? flagKey2}:${value}`, 0) % 100 * (WEIGHT_SCALE / 100);
173
+ }
174
+ if (bucketing2?.algorithm === "unleash-variant") {
175
+ const m = bucketing2.modulus ?? 1e3;
176
+ return Math.floor(murmur3Latin1(`${bucketing2.seed ?? flagKey2}:${value}`, UNLEASH_VARIANT_SEED) % m * WEIGHT_SCALE / m);
177
+ }
178
+ const h = murmur3(`${flagKey2}.${salt}.${value}`);
179
+ return Math.floor(h / 4294967296 * WEIGHT_SCALE);
180
+ }
181
+ function pickWeighted(weights, bucket, order) {
182
+ let total = 0;
183
+ for (const i of order ?? weights.keys()) {
184
+ total += weights[i] ?? 0;
185
+ if (bucket < total) return i;
186
+ }
187
+ return null;
188
+ }
189
+
190
+ // ../eval/src/clauses.ts
191
+ function parseSemver(v) {
192
+ if (typeof v !== "string") return null;
193
+ const m = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(v.trim());
194
+ if (!m) return null;
195
+ return [Number(m[1]), Number(m[2] ?? 0), Number(m[3] ?? 0)];
196
+ }
197
+ function cmpSemver(a, b) {
198
+ for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;
199
+ return 0;
200
+ }
201
+ function toTime(v) {
202
+ if (typeof v === "number" && Number.isFinite(v)) return v;
203
+ if (typeof v === "string") {
204
+ const t = Date.parse(v);
205
+ return Number.isNaN(t) ? null : t;
206
+ }
207
+ return null;
208
+ }
209
+ function compare(a, b) {
210
+ if (typeof a === "number" && typeof b === "number") return a - b;
211
+ if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
212
+ return null;
213
+ }
214
+ var regexCache = /* @__PURE__ */ new Map();
215
+ function regex(src) {
216
+ if (!regexCache.has(src)) {
217
+ let re = null;
218
+ try {
219
+ re = new RegExp(src);
220
+ } catch {
221
+ re = null;
222
+ }
223
+ regexCache.set(src, re);
224
+ }
225
+ return regexCache.get(src);
226
+ }
227
+ function matchOne(op, actual, expected) {
228
+ switch (op) {
229
+ case "in":
230
+ return actual === expected;
231
+ case "startsWith":
232
+ return typeof actual === "string" && actual.startsWith(String(expected));
233
+ case "endsWith":
234
+ return typeof actual === "string" && actual.endsWith(String(expected));
235
+ case "contains":
236
+ return typeof actual === "string" && actual.includes(String(expected));
237
+ case "matches": {
238
+ const re = typeof actual === "string" ? regex(String(expected)) : null;
239
+ return re !== null && re.test(actual);
240
+ }
241
+ case "lt": {
242
+ const c = compare(actual, expected);
243
+ return c !== null && c < 0;
244
+ }
245
+ case "lte": {
246
+ const c = compare(actual, expected);
247
+ return c !== null && c <= 0;
248
+ }
249
+ case "gt": {
250
+ const c = compare(actual, expected);
251
+ return c !== null && c > 0;
252
+ }
253
+ case "gte": {
254
+ const c = compare(actual, expected);
255
+ return c !== null && c >= 0;
256
+ }
257
+ case "semverEq":
258
+ case "semverLt":
259
+ case "semverGt": {
260
+ const a = parseSemver(actual);
261
+ const b = parseSemver(expected);
262
+ if (!a || !b) return false;
263
+ const c = cmpSemver(a, b);
264
+ return op === "semverEq" ? c === 0 : op === "semverLt" ? c < 0 : c > 0;
265
+ }
266
+ case "before":
267
+ case "after": {
268
+ const a = toTime(actual);
269
+ const b = toTime(expected);
270
+ if (a === null || b === null) return false;
271
+ return op === "before" ? a < b : a > b;
272
+ }
273
+ default:
274
+ return false;
275
+ }
276
+ }
277
+ function clauseMatches(c, ctx, env) {
278
+ if (c.op === "segmentMatch") {
279
+ const hit2 = c.values.some((s) => segmentMatches(String(s), ctx, env));
280
+ return c.negate ? !hit2 : hit2;
281
+ }
282
+ const actual = c.attr === "key" ? env.contextKey : ctx[c.attr];
283
+ if (c.op === "exists") {
284
+ const present = actual !== void 0 && actual !== null;
285
+ return c.negate ? !present : present;
286
+ }
287
+ if (actual === void 0 || actual === null) return false;
288
+ const values = Array.isArray(actual) ? actual : [actual];
289
+ const hit = values.some((a) => c.values.some((e) => matchOne(c.op, a, e)));
290
+ return c.negate ? !hit : hit;
291
+ }
292
+ function segmentMatches(key, ctx, env) {
293
+ const seg = env.segments[key];
294
+ if (!seg || env.depth > 5) return false;
295
+ const k = env.contextKey;
296
+ if (k !== void 0) {
297
+ if (seg.excluded.includes(k)) return false;
298
+ if (seg.included.includes(k)) return true;
299
+ }
300
+ const inner = { ...env, depth: env.depth + 1 };
301
+ return seg.rules.some((r) => r.clauses.every((c) => clauseMatches(c, ctx, inner)));
302
+ }
303
+
304
+ // ../eval/src/evaluate.ts
305
+ function contextKeyOf(ctx) {
306
+ const k = ctx.targetingKey ?? ctx.key;
307
+ return k === void 0 || k === null ? void 0 : String(k);
308
+ }
309
+ function typeOf(v) {
310
+ if (typeof v === "boolean") return "boolean";
311
+ if (typeof v === "string") return "string";
312
+ if (typeof v === "number") return "number";
313
+ return "json";
314
+ }
315
+ function resolveServe(flag, s, ctx, ruleId) {
316
+ if ("variation" in s) return { index: s.variation, reason: ruleId ? "TARGETING_MATCH" : "DEFAULT", ruleId };
317
+ const attr = s.rollout.bucketBy ?? "key";
318
+ const gate = s.rollout.gate;
319
+ if (gate) {
320
+ const gateAttr = gate.bucketBy ?? attr;
321
+ const g = gateAttr === "key" ? contextKeyOf(ctx) : ctx[gateAttr];
322
+ const gateBucket = g === void 0 || g === null ? 0 : bucketFor(flag.key, flag.salt, String(g), gate.bucketing);
323
+ if (gateBucket >= gate.weight) return null;
324
+ }
325
+ const raw = attr === "key" ? contextKeyOf(ctx) : ctx[attr];
326
+ const bucket = raw === void 0 || raw === null ? 0 : bucketFor(flag.key, flag.salt, String(raw), s.rollout.bucketing);
327
+ const index = pickWeighted(s.rollout.weights, bucket, s.rollout.order);
328
+ if (index === null) return null;
329
+ return { index, reason: "SPLIT", ruleId };
330
+ }
331
+ function evaluateFlag(snapshot2, flag, ctx, seen) {
332
+ if (!flag.enabled) return { index: flag.offVariation, reason: "DISABLED" };
333
+ for (const p of flag.prerequisites) {
334
+ const pre = snapshot2.flags[p.key];
335
+ if (!pre || seen.has(p.key)) return { index: flag.offVariation, reason: "DEFAULT", ruleId: `prerequisite:${p.key}` };
336
+ seen.add(p.key);
337
+ const r = evaluateFlag(snapshot2, pre, ctx, seen);
338
+ seen.delete(p.key);
339
+ if (!r || !pre.enabled || r.index !== p.variation)
340
+ return { index: flag.offVariation, reason: "DEFAULT", ruleId: `prerequisite:${p.key}` };
341
+ }
342
+ const key = contextKeyOf(ctx);
343
+ if (key !== void 0) {
344
+ for (const t of flag.targets) {
345
+ if (t.values.includes(key)) return { index: t.variation, reason: "TARGETING_MATCH", ruleId: "target" };
346
+ }
347
+ }
348
+ const env = { segments: snapshot2.segments, contextKey: key, depth: 0 };
349
+ for (const rule2 of flag.rules) {
350
+ if (!rule2.clauses.every((c) => clauseMatches(c, ctx, env))) continue;
351
+ const r = resolveServe(flag, rule2.serve, ctx, rule2.id);
352
+ if (r) return r;
353
+ }
354
+ return resolveServe(flag, flag.fallthrough, ctx, void 0) ?? { index: flag.offVariation, reason: "DEFAULT" };
355
+ }
356
+ function evaluate(snapshot2, flagKey2, ctx = {}, opts = {}) {
357
+ try {
358
+ const flag = snapshot2.flags[flagKey2];
359
+ if (!flag) return { value: void 0, variationIndex: null, reason: "ERROR", errorCode: "FLAG_NOT_FOUND", errorMessage: `Flag ${flagKey2} not found` };
360
+ const r = evaluateFlag(snapshot2, flag, ctx, /* @__PURE__ */ new Set([flagKey2]));
361
+ const index = r?.index ?? flag.offVariation;
362
+ if (index < 0 || index >= flag.variations.length)
363
+ return { value: void 0, variationIndex: null, reason: "ERROR", errorCode: "GENERAL", errorMessage: "Variation index out of range", flagVersion: flag.version };
364
+ const value = flag.variations[index];
365
+ if (opts.expectedType && typeOf(value) !== opts.expectedType && !(opts.expectedType === "json"))
366
+ return { value: void 0, variationIndex: null, reason: "ERROR", errorCode: "TYPE_MISMATCH", errorMessage: `Flag ${flagKey2} is ${flag.type}, not ${opts.expectedType}`, flagVersion: flag.version };
367
+ return { value, variationIndex: index, reason: r?.reason ?? "DEFAULT", ruleId: r?.ruleId, flagVersion: flag.version };
368
+ } catch (e) {
369
+ return { value: void 0, variationIndex: null, reason: "ERROR", errorCode: "GENERAL", errorMessage: e instanceof Error ? e.message : String(e) };
370
+ }
371
+ }
372
+
373
+ // src/sse.ts
374
+ async function readSse(res, onEvent, signal) {
375
+ if (!res.body) throw new Error("No response body");
376
+ const reader = res.body.getReader();
377
+ const dec = new TextDecoder();
378
+ let buf = "";
379
+ let cur = {};
380
+ while (!signal.aborted) {
381
+ const { value, done } = await reader.read();
382
+ if (done) return;
383
+ buf += dec.decode(value, { stream: true });
384
+ let nl;
385
+ while ((nl = buf.indexOf("\n")) >= 0) {
386
+ const line = buf.slice(0, nl).replace(/\r$/, "");
387
+ buf = buf.slice(nl + 1);
388
+ if (line === "") {
389
+ if (cur.data !== void 0 || cur.event) onEvent({ event: cur.event ?? "message", data: cur.data ?? "", id: cur.id });
390
+ cur = {};
391
+ } else if (!line.startsWith(":")) {
392
+ const i = line.indexOf(":");
393
+ const field = i < 0 ? line : line.slice(0, i);
394
+ const val = i < 0 ? "" : line.slice(i + 1).replace(/^ /, "");
395
+ if (field === "event") cur.event = val;
396
+ else if (field === "data") cur.data = cur.data === void 0 ? val : `${cur.data}
397
+ ${val}`;
398
+ else if (field === "id") cur.id = val;
399
+ }
400
+ }
401
+ }
402
+ }
403
+
404
+ // src/source.ts
405
+ var ConfigSource = class {
406
+ snapshot = null;
407
+ etag = null;
408
+ opts;
409
+ f;
410
+ abort = new AbortController();
411
+ pollTimer;
412
+ listeners = /* @__PURE__ */ new Set();
413
+ streaming = false;
414
+ constructor(o) {
415
+ if (typeof o.baseUrl !== "string" || !/^https?:\/\//.test(o.baseUrl)) {
416
+ throw new TypeError(`baseUrl must be your Railflag relay URL, like https://relay.example.com (got ${JSON.stringify(o.baseUrl)})`);
417
+ }
418
+ this.opts = { stream: true, pollIntervalMs: 3e4, ...o, baseUrl: o.baseUrl.replace(/\/+$/, "") };
419
+ this.f = o.fetch ?? fetch;
420
+ }
421
+ onChange(l) {
422
+ this.listeners.add(l);
423
+ return () => this.listeners.delete(l);
424
+ }
425
+ async start() {
426
+ await this.fetchConfig();
427
+ this.pollTimer = setInterval(() => void this.fetchConfig().catch((e) => this.opts.logger?.warn("railflag poll failed", e)), this.opts.pollIntervalMs);
428
+ this.pollTimer.unref?.();
429
+ if (this.opts.stream) void this.streamLoop();
430
+ }
431
+ stop() {
432
+ this.abort.abort();
433
+ clearInterval(this.pollTimer);
434
+ }
435
+ async fetchConfig() {
436
+ const headers = { authorization: this.opts.sdkKey };
437
+ if (this.etag) headers["if-none-match"] = this.etag;
438
+ const res = await this.f(`${this.opts.baseUrl}/sdk/v1/config`, { headers, signal: this.abort.signal });
439
+ if (res.status === 304) return;
440
+ if (!res.ok) throw new Error(`Railflag config request failed: ${res.status}`);
441
+ const snap = await res.json();
442
+ if (this.snapshot && snap.version < this.snapshot.version) return;
443
+ this.snapshot = snap;
444
+ this.etag = res.headers.get("etag");
445
+ for (const l of this.listeners) l(snap);
446
+ }
447
+ async streamLoop() {
448
+ let backoff = 500;
449
+ while (!this.abort.signal.aborted) {
450
+ try {
451
+ const res = await this.f(`${this.opts.baseUrl}/sdk/v1/stream`, { headers: { authorization: this.opts.sdkKey }, signal: this.abort.signal });
452
+ if (!res.ok) throw new Error(`stream ${res.status}`);
453
+ this.streaming = true;
454
+ backoff = 500;
455
+ await readSse(res, (e) => {
456
+ if (e.event === "config") {
457
+ const v = Number(JSON.parse(e.data || "{}").version);
458
+ if (!this.snapshot || v > this.snapshot.version) void this.fetchConfig().catch(() => {
459
+ });
460
+ }
461
+ }, this.abort.signal);
462
+ } catch (e) {
463
+ if (this.abort.signal.aborted) return;
464
+ this.opts.logger?.warn("railflag stream dropped, reconnecting", e);
465
+ }
466
+ this.streaming = false;
467
+ if (this.abort.signal.aborted) return;
468
+ await new Promise((r) => setTimeout(r, backoff));
469
+ backoff = Math.min(backoff * 2, 3e4);
470
+ }
471
+ }
472
+ };
473
+
474
+ // src/index.ts
475
+ var codes = {
476
+ FLAG_NOT_FOUND: ErrorCode.FLAG_NOT_FOUND,
477
+ TYPE_MISMATCH: ErrorCode.TYPE_MISMATCH,
478
+ PARSE_ERROR: ErrorCode.PARSE_ERROR,
479
+ GENERAL: ErrorCode.GENERAL
480
+ };
481
+ var RailflagProvider = class {
482
+ metadata = { name: "railflag" };
483
+ runsOn = "server";
484
+ events = new OpenFeatureEventEmitter();
485
+ source;
486
+ constructor(opts) {
487
+ this.source = new ConfigSource(opts);
488
+ this.source.onChange((s) => this.events.emit(ProviderEvents.ConfigurationChanged, { message: `config version ${s.version}` }));
489
+ }
490
+ async initialize() {
491
+ await this.source.start();
492
+ }
493
+ async onClose() {
494
+ this.source.stop();
495
+ }
496
+ resolve(flagKey2, def, ctx, type) {
497
+ const snap = this.source.snapshot;
498
+ if (!snap) return { value: def, reason: StandardResolutionReasons.ERROR, errorCode: ErrorCode.PROVIDER_NOT_READY };
499
+ const r = evaluate(snap, flagKey2, ctx, { expectedType: type });
500
+ if (r.reason === "ERROR") {
501
+ return { value: def, reason: StandardResolutionReasons.ERROR, errorCode: codes[r.errorCode ?? "GENERAL"] ?? ErrorCode.GENERAL, errorMessage: r.errorMessage };
502
+ }
503
+ return {
504
+ value: r.value,
505
+ variant: r.variationIndex === null ? void 0 : String(r.variationIndex),
506
+ reason: r.reason,
507
+ flagMetadata: { flagVersion: r.flagVersion ?? 0, ...r.ruleId ? { ruleId: r.ruleId } : {}, configVersion: snap.version }
508
+ };
509
+ }
510
+ resolveBooleanEvaluation(k, d, c) {
511
+ return Promise.resolve(this.resolve(k, d, c, "boolean"));
512
+ }
513
+ resolveStringEvaluation(k, d, c) {
514
+ return Promise.resolve(this.resolve(k, d, c, "string"));
515
+ }
516
+ resolveNumberEvaluation(k, d, c) {
517
+ return Promise.resolve(this.resolve(k, d, c, "number"));
518
+ }
519
+ resolveObjectEvaluation(k, d, c) {
520
+ return Promise.resolve(this.resolve(k, d, c, "json"));
521
+ }
522
+ };
523
+ export {
524
+ ConfigSource,
525
+ RailflagProvider
526
+ };
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@railflag/sdk-node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.1",
4
+ "description": "Railflag OpenFeature provider for Node.js: local evaluation, streaming updates",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/panosangelopoulos/railflag.git",
9
+ "directory": "packages/sdk-node"
10
+ },
11
+ "sideEffects": false,
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "import": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "require": {
23
+ "types": "./dist/index.d.cts",
24
+ "default": "./dist/index.cjs"
25
+ }
26
+ }
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "peerDependencies": {
32
+ "@openfeature/core": "^1.9.0",
33
+ "@openfeature/server-sdk": "^1.19.0"
34
+ },
35
+ "devDependencies": {
36
+ "@openfeature/core": "1.9.2",
37
+ "@openfeature/server-sdk": "1.19.0",
38
+ "ioredis": "5.11.1",
39
+ "tsup": "8.5.0",
40
+ "@railflag/api": "0.1.0",
41
+ "@railflag/eval": "0.1.0",
42
+ "@railflag/relay": "0.1.0",
43
+ "@railflag/schema": "0.1.0"
44
+ },
45
+ "engines": {
46
+ "node": ">=20"
47
+ },
48
+ "dependencies": {
49
+ "zod": "^4.1.13"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "typecheck": "tsc -p .",
54
+ "test": "vitest run"
55
+ },
56
+ "main": "./dist/index.cjs",
57
+ "module": "./dist/index.js",
58
+ "types": "./dist/index.d.ts"
6
59
  }