{"id":15816,"library":"scim-query-filter-parser","title":"SCIM Query Filter & Sorter Parser","description":"This library, `scim-query-filter-parser`, provides a robust parser and compiler for the System for Cross-Domain Identity Management (SCIM) Protocol 2.0. Specifically, it enables the processing of SCIM filtering (RFC 7644, section 3.4.2.2) and sorting (RFC 7644, section 3.4.2.3) expressions. It takes a SCIM filter or sort string as input and compiles it into a standard JavaScript function that can be used directly with array `filter` or `sort` methods, respectively. The current stable version is 2.0.4. While a specific release cadence isn't explicitly stated, the project appears actively maintained given its versioning and clear use case. A key differentiator is its direct implementation of RFC 7644 standards, originally built for `AuthX`, offering a specialized solution for SCIM-compliant identity management systems.","status":"active","version":"2.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/the-control-group/scim-query-filter-parser-js","tags":["javascript","scim","scimplecloud","parser","filter","typescript"],"install":[{"cmd":"npm install scim-query-filter-parser","lang":"bash","label":"npm"},{"cmd":"yarn add scim-query-filter-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add scim-query-filter-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import is recommended, especially when using TypeScript. While CommonJS `require` might work due to dual package builds, it is not the idiomatic way to consume this library in modern environments.","wrong":"const compileFilter = require('scim-query-filter-parser').compileFilter;","symbol":"compileFilter","correct":"import { compileFilter } from 'scim-query-filter-parser';"},{"note":"ESM import is recommended. CommonJS `require` is technically supported but less preferred for new projects or TypeScript contexts.","wrong":"const compileSorter = require('scim-query-filter-parser').compileSorter;","symbol":"compileSorter","correct":"import { compileSorter } from 'scim-query-filter-parser';"},{"note":"Importing types explicitly helps with static analysis and IntelliSense in TypeScript projects without adding runtime overhead.","symbol":"Type definitions","correct":"import type { ScimFilterFunction, ScimSorterFunction } from 'scim-query-filter-parser';"}],"quickstart":{"code":"import { compileFilter, compileSorter } from \"scim-query-filter-parser\";\n\nconst users = [\n  { id: 'u1', userName: 'alice', active: true, 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:employeeNumber': 'EMP001' },\n  { id: 'u2', userName: 'bob', active: false, 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:employeeNumber': 'EMP002' },\n  { id: 'u3', userName: 'charlie', active: true, 'urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:employeeNumber': 'EMP003' }\n];\n\n// Example 1: Filtering users where userName equals 'alice'\nconst aliceFilter = compileFilter('userName eq \"alice\"');\nconst filteredUsers = users.filter(aliceFilter);\nconsole.log('Filtered for Alice:', filteredUsers);\n\n// Example 2: Filtering active users with an employee number greater than 'EMP001'\nconst complexFilter = compileFilter('active eq true and urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:employeeNumber gt \"EMP001\"');\nconst complexFilteredUsers = users.filter(complexFilter);\nconsole.log('Complex filter results:', complexFilteredUsers);\n\n// Example 3: Sorting users by userName in ascending order\nconst userNameSorter = compileSorter('userName asc');\nconst sortedUsers = [...users].sort(userNameSorter);\nconsole.log('Sorted by Username:', sortedUsers);","lang":"typescript","description":"Demonstrates how to import `compileFilter` and `compileSorter` and use them to filter and sort an array of objects based on SCIM query strings, including complex filters and extended attributes."},"warnings":[{"fix":"Prefer `import` statements for consuming the library. If using CommonJS, ensure your bundler or Node.js environment correctly resolves the `main` entry point. Test existing `require` statements thoroughly after upgrading.","message":"Version 2.0.0 introduced ES Module (ESM) support. While the package maintains CommonJS compatibility via its `main` entry point, projects relying solely on CommonJS or specific bundler configurations might need adjustments, especially if `package.json`'s `exports` field is used by tooling.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Validate SCIM query strings before passing them to the compiler functions. Refer to RFC 7644, sections 3.4.2.2 (filtering) and 3.4.2.3 (sorting) for correct syntax. Implement robust error handling around calls to `compileFilter` and `compileSorter`.","message":"The parser strictly adheres to the SCIM Protocol RFC 7644 for filter and sort expressions. Malformed or non-compliant query strings will lead to runtime errors when `compileFilter` or `compileSorter` are called.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Cache the results of `compileFilter` and `compileSorter` if the filter or sort string is static or frequently reused. Avoid recompiling the same string multiple times within a tight loop. For extremely high-performance scenarios with huge datasets, consider pre-filtering or indexing strategies.","message":"Performance considerations: While efficient for typical use cases, compiling very complex filters or executing them against extremely large datasets in a hot path might introduce overhead. The compiled functions are pure, so reuse the compiled function if the filter string doesn't change.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use `import { symbol } from 'package';` instead of `const { symbol } = require('package');` in modern JavaScript or TypeScript environments. Ensure your `package.json` has `\"type\": \"module\"` if your files are ESM, or configure your bundler (e.g., Webpack, Rollup) to correctly handle dual packages.","cause":"Attempting to `require()` an ES Module (ESM) package in a strict CommonJS environment without proper transpilation or configuration, or when a tool incorrectly picks the ESM bundle for `require`.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Verify the exact import statement: `import { compileFilter } from 'scim-query-filter-parser';`. If using `require`, ensure it's `const { compileFilter } = require('scim-query-filter-parser');` and not `const compileFilter = require('scim-query-filter-parser');`.","cause":"This typically occurs if the import path is incorrect, or if `require` is used and the package's CommonJS export structure is not directly compatible with destructuring the top-level `module.exports` object.","error":"TypeError: compileFilter is not a function"},{"fix":"Carefully review the provided filter or sort string against RFC 7644 section 3.4.2.2 and 3.4.2.3. Common mistakes include mismatched quotes, incorrect logical operators (e.g., `and` vs `&&`), invalid attribute names, or improper use of comparison operators.","cause":"The input string provided to `compileFilter` or `compileSorter` does not conform to the SCIM Protocol RFC 7644 specification for filter or sort expressions.","error":"Error: Invalid SCIM filter string: '...' (details about parsing error)"}],"ecosystem":"npm"}