Registry / serialization / scim2-filter

scim2-filter

JSON →
library0.2.0jsnpmunverified

A parser and evaluator for RFC 7643 SCIM 2.0 filter syntax. Version 0.2.0 allows parsing filter expressions into an AST and applying them as JavaScript functions to filter JSON objects. Supports operators (eq, co, sw, pr, gt, ge, lt, le, and, or, not) and complex filters with attribute paths and value filters. Lightweight, dependency-free, and ESM-only. No TypeScript types provided. Differentiates from generic query parsers by adhering strictly to SCIM 2.0 filtering grammar.

npm install scim2-filter
INSTALL
IMPORT
SIG · SCIM2-FILTER
S
scim2-filter
serializationjavascriptv0.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'scim2-filter'
const parse = require('scim2-filter')
Package is ESM-only; CommonJS require will fail.
filter
import { filter } from 'scim2-filter'
const filter = require('scim2-filter').filter
Named export; must use ESM syntax.
types (AST types)
import type { ScimFilter, FilterOperator } from 'scim2-filter'
No wrong pattern known
Package does not export any types; these are hypothetical. Actually, no TypeScript declarations are provided. Use with '// @ts-ignore' or create your own types.

Parses a SCIM 2.0 filter string into an AST, then uses the filter function to evaluate the expression against an array of objects.

import { parse, filter } from 'scim2-filter'; const ast = parse(`userType eq "Employee" and emails[type eq "work" and value co "@example.com"]`); console.log(JSON.stringify(ast, null, 2)); const userFilter = filter(parse(`userName eq "test1@example.com"`)); const users = [ { userName: "test1@example.com" }, { userName: "test2@example.com" } ]; const result = users.filter(userFilter); console.log(result); // [{ userName: "test1@example.com" }]
Debug
Known issues
gotchaPackage has no TypeScript type declarations. Use with TypeScript may require 'any' casts or custom type definitions.
fix
Install @types/scim2-filter if available or add a declaration file manually. Alternatively, use JSDoc comments for type hints.
affects: >=0.0.0
gotchaThe `filter` function returns a predicate that expects array elements to be objects. Non-object elements may cause runtime errors or unexpected behavior.
fix
Ensure input data consists of plain JavaScript objects.
affects: >=0.0.0
gotchaThis package only parses and evaluates filters; it does not handle SCIM attribute validation, complex attribute names with sub-attributes, or proper escaping beyond the spec. Use with caution in production.
fix
Validate filter syntax and implement additional attribute handling as needed.
affects: >=0.0.0
deprecatedNo deprecated features identified; however, version 0.2.0 may have limited support for all SCIM 2.0 filter operators (e.g., 'pr' for presence).
fix
Check the package source for supported operators; consider contributing missing features.
affects: 0.2.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Using ESM import in a CommonJS context (e.g., Node.js without 'type':'module' in package.json).
fix
Add "type": "module" to package.json or use .mjs extension for importing file.
TypeError: parse is not a function
Incorrect import: using default import instead of named import.
fix
Use `import { parse } from 'scim2-filter'` instead of `import parse from 'scim2-filter'` or `const parse = require('scim2-filter')`.
Uncaught TypeError: filter(...) is not a function
The filter function returns a predicate, but it's being called on non-array or used incorrectly.
fix
Ensure the result of `filter(parse(...))` is a function; use it as a callback to `Array.filter()`.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
scim2-filter — npm install scim2-filter · libregistry