@numbunch/node 0.0.0-stage → 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.
@@ -0,0 +1,8 @@
1
+ export { type Bootstrap, type CaptureMessage, type FlagOptions, Numbunch, type NumbunchOptions } from './client.js';
2
+ export { activeTrace, type HeadersLike, loadOtel, type OtelApi, parseBaggage, type RequestContext, requestContext, withRequestContext, } from './context.js';
3
+ export { type ConditionSet, type Definitions, evaluateFlag, evaluateLocally, type FlagDefinition, type FlagFilters, type FlagValue, type LocalInput, type Variant, } from './evaluate.js';
4
+ export { type ExceptionEntry, exceptionList, parseStack, type StackFrame } from './exceptions.js';
5
+ export { type Bucketing, bucket, holdoutValue, murmur3_x86_32, murmur3V1, pickVariant, sha1V1, within } from './hash.js';
6
+ export { InconclusiveMatchError, matchProperty, type Operator, type Properties, type PropertyFilter } from './matching.js';
7
+ export { uuidv7 } from './uuid.js';
8
+ export { VERSION } from './version.js';
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // @numbunch/node: the Numbunch SDK for Node.js (MIT).
2
+ export { Numbunch } from './client.js';
3
+ export { activeTrace, loadOtel, parseBaggage, requestContext, withRequestContext, } from './context.js';
4
+ export { evaluateFlag, evaluateLocally, } from './evaluate.js';
5
+ export { exceptionList, parseStack } from './exceptions.js';
6
+ export { bucket, holdoutValue, murmur3_x86_32, murmur3V1, pickVariant, sha1V1, within } from './hash.js';
7
+ export { InconclusiveMatchError, matchProperty } from './matching.js';
8
+ export { uuidv7 } from './uuid.js';
9
+ export { VERSION } from './version.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,EAAyD,QAAQ,EAAwB,MAAM,aAAa,CAAA;AACnH,OAAO,EACL,WAAW,EAEX,QAAQ,EAER,YAAY,EAEZ,cAAc,EACd,kBAAkB,GACnB,MAAM,cAAc,CAAA;AACrB,OAAO,EAGL,YAAY,EACZ,eAAe,GAMhB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAuB,aAAa,EAAE,UAAU,EAAmB,MAAM,iBAAiB,CAAA;AACjG,OAAO,EAAkB,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACxH,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAuD,MAAM,eAAe,CAAA;AAC1H,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,21 @@
1
+ export type Operator = 'exact' | 'is_not' | 'icontains' | 'not_icontains' | 'regex' | 'not_regex' | 'gt' | 'gte' | 'lt' | 'lte' | 'is_set' | 'is_not_set' | 'is_date_before' | 'is_date_after';
2
+ export interface PropertyFilter {
3
+ key: string;
4
+ value?: unknown;
5
+ operator?: Operator;
6
+ type?: 'person' | 'group' | 'cohort' | 'flag';
7
+ group_type_index?: number | null;
8
+ }
9
+ export type Properties = Record<string, unknown>;
10
+ /** The supplied properties cannot decide the filter; the server must evaluate the flag. */
11
+ export declare class InconclusiveMatchError extends Error {
12
+ constructor(message?: string);
13
+ }
14
+ /** Matches one filter against the supplied (partial) properties. Throws [`InconclusiveMatchError`]. */
15
+ export declare function matchProperty(filter: PropertyFilter, properties: Properties, now?: Date): boolean;
16
+ /** JavaScript's `String(value)`, which the SDKs and the server use before comparing. */
17
+ export declare function jsString(value: unknown): string;
18
+ /** A filter date as epoch milliseconds: a relative date (`-7d`, `24h`, `2w`, `3m`, `1y`) or an absolute one. */
19
+ export declare function parseFilterDate(value: string, now: Date): number | undefined;
20
+ /** RFC 3339, `YYYY-MM-DD` (midnight UTC) or a naive date-time read as UTC, as epoch milliseconds. */
21
+ export declare function parseAbsoluteDate(text: string): number | undefined;
@@ -0,0 +1,196 @@
1
+ // Property matching for flag conditions, identical to crates/nb-flags/src/matching.rs (server semantics).
2
+ //
3
+ // Ported from posthog-node 4.11.2 `src/feature-flags.ts` (`matchProperty`, `relativeDateParseForFeatureFlagMatching`),
4
+ // MIT, Copyright (c) PostHog Inc. `gt`/`gte`/`lt`/`lte` compare as posthog-node does: a string property against the
5
+ // filter value's text as strings, any other against `parseFloat(value)` as numbers. Differences from posthog-node, as
6
+ // on the Numbunch server: dates without an offset are UTC, and epoch numbers are seconds.
7
+ /** The supplied properties cannot decide the filter; the server must evaluate the flag. */
8
+ export class InconclusiveMatchError extends Error {
9
+ constructor(message = 'inconclusive') {
10
+ super(message);
11
+ this.name = 'InconclusiveMatchError';
12
+ }
13
+ }
14
+ /** Matches one filter against the supplied (partial) properties. Throws [`InconclusiveMatchError`]. */
15
+ export function matchProperty(filter, properties, now = new Date()) {
16
+ const operator = filter.operator ?? 'exact';
17
+ if (!Object.prototype.hasOwnProperty.call(properties, filter.key) || properties[filter.key] === undefined) {
18
+ throw new InconclusiveMatchError(`property ${filter.key} not supplied`);
19
+ }
20
+ const actual = properties[filter.key];
21
+ // A supplied null fails every operator except `is_not`, including `is_set`.
22
+ if (actual === null && operator !== 'is_not')
23
+ return false;
24
+ const expected = filter.value ?? null;
25
+ switch (operator) {
26
+ case 'is_set':
27
+ return true;
28
+ case 'is_not_set':
29
+ return false;
30
+ case 'exact':
31
+ return exact(expected, actual);
32
+ case 'is_not':
33
+ return !exact(expected, actual);
34
+ case 'icontains':
35
+ return contains(actual, expected);
36
+ case 'not_icontains':
37
+ return !contains(actual, expected);
38
+ case 'regex':
39
+ case 'not_regex': {
40
+ let regex;
41
+ try {
42
+ regex = new RegExp(jsString(expected));
43
+ }
44
+ catch {
45
+ return false;
46
+ }
47
+ const found = regex.test(jsString(actual));
48
+ return operator === 'regex' ? found : !found;
49
+ }
50
+ case 'gt':
51
+ case 'gte':
52
+ case 'lt':
53
+ case 'lte': {
54
+ const bound = typeof expected === 'number' ? expected : typeof expected === 'string' ? parseFloat(expected) : null;
55
+ if (bound === null)
56
+ return ordered(operator, jsString(actual), jsString(expected));
57
+ if (typeof actual === 'string')
58
+ return ordered(operator, actual, jsString(expected));
59
+ const n = typeof actual === 'number' ? actual : typeof actual === 'boolean' ? Number(actual) : Number.NaN;
60
+ return ordered(operator, n, bound);
61
+ }
62
+ case 'is_date_before':
63
+ case 'is_date_after': {
64
+ const bound = typeof expected === 'string' ? parseFilterDate(expected, now) : undefined;
65
+ if (bound === undefined)
66
+ return false;
67
+ const date = asDate(actual);
68
+ if (date === undefined)
69
+ throw new InconclusiveMatchError(`property ${filter.key} is not a date`);
70
+ return operator === 'is_date_before' ? date < bound : date > bound;
71
+ }
72
+ default:
73
+ // An operator this SDK does not know: let the server decide.
74
+ throw new InconclusiveMatchError(`unknown operator ${String(operator)}`);
75
+ }
76
+ }
77
+ /** JavaScript's `String(value)`, which the SDKs and the server use before comparing. */
78
+ export function jsString(value) {
79
+ return String(value);
80
+ }
81
+ function exact(expected, actual) {
82
+ const a = jsString(actual).toLowerCase();
83
+ if (Array.isArray(expected))
84
+ return expected.some((item) => jsString(item).toLowerCase() === a);
85
+ return jsString(expected).toLowerCase() === a;
86
+ }
87
+ function contains(actual, expected) {
88
+ return jsString(actual).toLowerCase().includes(jsString(expected).toLowerCase());
89
+ }
90
+ const FLOAT = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
91
+ const SPECIAL = /^[+-]?(?:inf|infinity)$/i;
92
+ /** Rust's `str::parse::<f64>` on the trimmed string (no hex, no empty string); NaN is not a number. */
93
+ function parseFloatStrict(text) {
94
+ const s = text.trim();
95
+ if (FLOAT.test(s))
96
+ return Number(s);
97
+ if (SPECIAL.test(s))
98
+ return s.startsWith('-') ? -Infinity : Infinity;
99
+ return undefined;
100
+ }
101
+ /** `lhs <op> rhs` with JavaScript's comparison: numbers numerically (NaN never matches), strings by UTF-16 code unit. */
102
+ function ordered(operator, lhs, rhs) {
103
+ if (operator === 'gt')
104
+ return lhs > rhs;
105
+ if (operator === 'gte')
106
+ return lhs >= rhs;
107
+ if (operator === 'lt')
108
+ return lhs < rhs;
109
+ return lhs <= rhs;
110
+ }
111
+ /** A property as epoch milliseconds: epoch seconds (number or numeric string) or an ISO 8601 string. */
112
+ function asDate(value) {
113
+ if (typeof value === 'number')
114
+ return Number.isFinite(value) ? value * 1000 : undefined;
115
+ if (typeof value === 'string') {
116
+ const seconds = parseFloatStrict(value);
117
+ if (seconds !== undefined)
118
+ return Number.isFinite(seconds) ? seconds * 1000 : undefined;
119
+ return parseAbsoluteDate(value);
120
+ }
121
+ return undefined;
122
+ }
123
+ /** A filter date as epoch milliseconds: a relative date (`-7d`, `24h`, `2w`, `3m`, `1y`) or an absolute one. */
124
+ export function parseFilterDate(value, now) {
125
+ return parseRelativeDate(value, now) ?? parseAbsoluteDate(value);
126
+ }
127
+ function parseRelativeDate(value, now) {
128
+ const m = /^-?(\d+)([hdwmy])$/.exec(value);
129
+ if (!m)
130
+ return undefined;
131
+ const number = Number(m[1]);
132
+ if (number >= 10_000)
133
+ return undefined;
134
+ const t = now.getTime();
135
+ switch (m[2]) {
136
+ case 'h':
137
+ return t - number * 3_600_000;
138
+ case 'd':
139
+ return t - number * 86_400_000;
140
+ case 'w':
141
+ return t - number * 7 * 86_400_000;
142
+ case 'm':
143
+ return subMonths(now, number);
144
+ default:
145
+ return subMonths(now, number * 12);
146
+ }
147
+ }
148
+ /** chrono's `checked_sub_months`: same day and time, clamped to the last day of the target month. */
149
+ function subMonths(now, months) {
150
+ const total = now.getUTCFullYear() * 12 + now.getUTCMonth() - months;
151
+ const year = Math.floor(total / 12);
152
+ const month = total - year * 12;
153
+ const lastDay = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
154
+ const day = Math.min(now.getUTCDate(), lastDay);
155
+ const date = new Date(now.getTime());
156
+ date.setUTCFullYear(year, month, day);
157
+ return date.getTime();
158
+ }
159
+ const RFC3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt ](\d{2}):(\d{2}):(\d{2})(\.\d+)?([Zz]|[+-]\d{2}:\d{2})$/;
160
+ const DATE = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
161
+ const NAIVE = /^(\d{4})-(\d{1,2})-(\d{1,2})[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(\.\d+)?)?$/;
162
+ /** RFC 3339, `YYYY-MM-DD` (midnight UTC) or a naive date-time read as UTC, as epoch milliseconds. */
163
+ export function parseAbsoluteDate(text) {
164
+ const value = text.trim();
165
+ let m = RFC3339.exec(value);
166
+ if (m) {
167
+ const base = utc(m[1], m[2], m[3], m[4], m[5], m[6], m[7]);
168
+ if (base === undefined)
169
+ return undefined;
170
+ const zone = m[8];
171
+ if (zone === 'Z' || zone === 'z')
172
+ return base;
173
+ const sign = zone.startsWith('-') ? -1 : 1;
174
+ const [hours, minutes] = zone.slice(1).split(':').map(Number);
175
+ if (hours > 23 || minutes > 59)
176
+ return undefined;
177
+ return base - sign * (hours * 60 + minutes) * 60_000;
178
+ }
179
+ m = DATE.exec(value);
180
+ if (m)
181
+ return utc(m[1], m[2], m[3], '0', '0', '0', undefined);
182
+ m = NAIVE.exec(value);
183
+ if (m)
184
+ return utc(m[1], m[2], m[3], m[4], m[5], m[6] ?? '0', m[7]);
185
+ return undefined;
186
+ }
187
+ function utc(y, mo, d, h, mi, s, fraction) {
188
+ const [year, month, day, hour, minute, second] = [y, mo, d, h, mi, s].map(Number);
189
+ if (month < 1 || month > 12 || day < 1 || hour > 23 || minute > 59 || second > 60)
190
+ return undefined;
191
+ const t = Date.UTC(year, month - 1, day, hour, minute, Math.min(second, 59));
192
+ if (new Date(t).getUTCDate() !== day)
193
+ return undefined;
194
+ return t + (second === 60 ? 1000 : 0) + (fraction ? Number(`0${fraction}`) * 1000 : 0);
195
+ }
196
+ //# sourceMappingURL=matching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching.js","sourceRoot":"","sources":["../src/matching.ts"],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RFC 9562): 48-bit Unix milliseconds, version 7, random rest. */
2
+ export declare function uuidv7(now?: number): string;
package/dist/uuid.js ADDED
@@ -0,0 +1,15 @@
1
+ import { randomFillSync } from 'node:crypto';
2
+ /** A UUIDv7 (RFC 9562): 48-bit Unix milliseconds, version 7, random rest. */
3
+ export function uuidv7(now = Date.now()) {
4
+ const bytes = randomFillSync(new Uint8Array(16));
5
+ let ms = now;
6
+ for (let i = 5; i >= 0; i--) {
7
+ bytes[i] = ms % 256;
8
+ ms = Math.floor(ms / 256);
9
+ }
10
+ bytes[6] = (bytes[6] & 0x0f) | 0x70;
11
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
12
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
13
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
14
+ }
15
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.js","sourceRoot":"","sources":["../src/uuid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,6EAA6E;AAC7E,MAAM,UAAU,MAAM,CAAC,MAAc,IAAI,CAAC,GAAG,EAAE;IAC7C,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAA;IAChD,IAAI,EAAE,GAAG,GAAG,CAAA;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAA;QACnB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IAC3B,CAAC;IACD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9E,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;AAC5G,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** The package version, sent as `$lib_version`. Kept equal to package.json by the release check. */
2
+ export declare const VERSION = "0.1.1";
@@ -0,0 +1,3 @@
1
+ /** The package version, sent as `$lib_version`. Kept equal to package.json by the release check. */
2
+ export const VERSION = '0.1.1';
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@numbunch/node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Numbunch Node.js SDK: batched capture, local flag evaluation (sha1_v1 and murmur3_v1), exceptions, OpenTelemetry",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/MidgardAI/numbunch.git",
9
+ "directory": "sdk/node"
10
+ },
11
+ "type": "module",
12
+ "files": [
13
+ "dist",
14
+ "LICENSE"
15
+ ],
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./express": {
24
+ "types": "./dist/express.d.ts",
25
+ "default": "./dist/express.js"
26
+ },
27
+ "./fastify": {
28
+ "types": "./dist/fastify.d.ts",
29
+ "default": "./dist/fastify.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "engines": {
34
+ "node": ">=20.19"
35
+ },
36
+ "peerDependencies": {
37
+ "@opentelemetry/api": "^1.9.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "@opentelemetry/api": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "devDependencies": {
45
+ "@eslint/js": "10.0.1",
46
+ "eslint": "10.15.0",
47
+ "globals": "17.14.0",
48
+ "typescript": "6.0.3",
49
+ "typescript-eslint": "8.72.2",
50
+ "vitest": "5.1.0",
51
+ "@opentelemetry/api": "1.10.0",
52
+ "@types/node": "22.20.5"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "scripts": {
58
+ "build": "tsc -p tsconfig.build.json",
59
+ "typecheck": "tsc --noEmit -p tsconfig.json",
60
+ "lint": "eslint .",
61
+ "test": "vitest run"
62
+ }
6
63
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.