From 6ad956a5e759140a3505828259bea7411a476a36 Mon Sep 17 00:00:00 2001 From: Dishant Hirpara Date: Tue, 4 Aug 2026 13:34:26 -0700 Subject: [PATCH 1/2] [Node] Document created/modified time search params on search() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #9538 What changed: - Added a JSDoc block above the search() function in lib/management/user.ts documenting fromCreatedTime, toCreatedTime, fromModifiedTime, and toModifiedTime, matching the JSDoc style already used on the deprecated searchAll() function above it. - Updated the README "Search all users" example to show fromCreatedTime/toModifiedTime usage. - No functional/type code was changed: these 4 fields already existed on the SearchRequest type (with only inline `//` comments) and were already wired through to the request body via the `...searchReq` spread in search() — they just lacked a proper JSDoc block on the function itself. - Per explicit instruction, the deprecated searchAll() function (which does not support these params) was left untouched. Verified: - Manual diff review only: the change is a JSDoc comment block plus a README edit, added directly above an existing, unmodified arrow function — no syntax risk to the surrounding code. Not verified: - No TypeScript compile/typecheck was run (`tsc --noEmit` or similar) because node_modules were not installed in this session and doing so was out of scope for this check. No integration/functional testing against a live API was performed. --- README.md | 4 ++++ lib/management/user.ts | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 808fe3f39..7e2ea499a 100644 --- a/README.md +++ b/README.md @@ -904,10 +904,14 @@ usersRes.data.forEach((user) => { // Search all users, optionally according to tenant and/or role filter // Results can be paginated using the limit and page parameters // Additional filters: verifiedEmail, verifiedPhone, statuses, roles, tenantIds, etc. +// Results can also be filtered by time using fromCreatedTime, toCreatedTime, +// fromModifiedTime, and toModifiedTime (epoch in milliseconds) const usersRes = await descopeClient.management.user.search({ tenantIds: ['tenant-ID'], verifiedEmail: true, // optional: filter by verified email status verifiedPhone: false, // optional: filter by verified phone status + fromCreatedTime: 1700000000000, // optional: only users created on or after this time + toModifiedTime: 1800000000000, // optional: only users modified on or before this time }); console.log('Total users:', usersRes.data.total); usersRes.data.users.forEach((user) => { diff --git a/lib/management/user.ts b/lib/management/user.ts index 87a0fe4b2..44454dc5f 100644 --- a/lib/management/user.ts +++ b/lib/management/user.ts @@ -674,6 +674,16 @@ const withUser = (httpClient: HttpClient) => { }), (data) => ({ users: data.users, total: data.total }), ), + /** + * Search all users. Results can be filtered according to tenants, roles, + * and other attributes on the given SearchRequest, and paginated using + * the limit and page fields. + * @param searchReq.fromCreatedTime only include users created on or after this time (epoch in milliseconds) + * @param searchReq.toCreatedTime only include users created on or before this time (epoch in milliseconds) + * @param searchReq.fromModifiedTime only include users modified on or after this time (epoch in milliseconds) + * @param searchReq.toModifiedTime only include users modified on or before this time (epoch in milliseconds) + * @returns The users found by the query, along with the total number of matches + */ search: (searchReq: SearchRequest): Promise> => transformResponse( httpClient.post(apiPaths.user.search, { From ebc4cc403a634ed06cfd8ac22739099b4f0adb7a Mon Sep 17 00:00:00 2001 From: Dishant Hirpara Date: Tue, 11 Aug 2026 10:36:07 -0700 Subject: [PATCH 2/2] docs: fix boundary wording for time-filter params #9538 What changed: - Corrected the inclusive/exclusive boundary wording on all 4 time-filter params (fromCreatedTime, toCreatedTime, fromModifiedTime, toModifiedTime) in lib/management/user.ts and README.md, based on the actual backend comparison operators (traced through managementservice -> common -> userservice): - fromCreatedTime / fromModifiedTime: backend uses SQL `>` (exclusive) -> wording is "after", not "on or after" - toCreatedTime / toModifiedTime: backend uses SQL `<=` (inclusive) -> wording is "on or before", not "before" - Fixed the JSDoc @param lines on search() (added earlier in this PR) for fromCreatedTime/fromModifiedTime: "on or after" -> "after". - Fixed the pre-existing SearchRequest type inline comments for toCreatedTime/toModifiedTime, which predate this PR and were already wrong before it: "before" -> "on or before". - Fixed the README example comment for fromCreatedTime to match. Verified: - Backend behavior confirmed directly in source across 3 repos, not assumed: managementservice/internal/services/user.go (builds the SearchField, only Negative is set on the to* variants), common's search domain (negative flag selects Operator vs NegativeOperator), and userservice/internal/entities/search.go (the actual operator strings: Operator: " > ", NegativeOperator: " <= " for both createdtime and modifiedtime). Not verified: - No integration/functional testing against a live Descope API was performed; this is a documentation/comment wording fix only, no functional code was touched. --- README.md | 2 +- lib/management/user.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7e2ea499a..635ac4888 100644 --- a/README.md +++ b/README.md @@ -910,7 +910,7 @@ const usersRes = await descopeClient.management.user.search({ tenantIds: ['tenant-ID'], verifiedEmail: true, // optional: filter by verified email status verifiedPhone: false, // optional: filter by verified phone status - fromCreatedTime: 1700000000000, // optional: only users created on or after this time + fromCreatedTime: 1700000000000, // optional: only users created after this time toModifiedTime: 1800000000000, // optional: only users modified on or before this time }); console.log('Total users:', usersRes.data.total); diff --git a/lib/management/user.ts b/lib/management/user.ts index 44454dc5f..8fd5fa061 100644 --- a/lib/management/user.ts +++ b/lib/management/user.ts @@ -58,9 +58,9 @@ type SearchRequest = { loginIds?: string[]; userIds?: string[]; fromCreatedTime?: number; // Search users created after this time (epoch in milliseconds) - toCreatedTime?: number; // Search users created before this time (epoch in milliseconds) + toCreatedTime?: number; // Search users created on or before this time (epoch in milliseconds) fromModifiedTime?: number; // Search users modified after this time (epoch in milliseconds) - toModifiedTime?: number; // Search users modified before this time (epoch in milliseconds) + toModifiedTime?: number; // Search users modified on or before this time (epoch in milliseconds) tenantRoleIds?: Record; // Search users based on tenants and role IDs tenantRoleNames?: Record; // Search users based on tenants and role names verifiedEmail?: boolean; // Filter by verified email status @@ -678,9 +678,9 @@ const withUser = (httpClient: HttpClient) => { * Search all users. Results can be filtered according to tenants, roles, * and other attributes on the given SearchRequest, and paginated using * the limit and page fields. - * @param searchReq.fromCreatedTime only include users created on or after this time (epoch in milliseconds) + * @param searchReq.fromCreatedTime only include users created after this time (epoch in milliseconds) * @param searchReq.toCreatedTime only include users created on or before this time (epoch in milliseconds) - * @param searchReq.fromModifiedTime only include users modified on or after this time (epoch in milliseconds) + * @param searchReq.fromModifiedTime only include users modified after this time (epoch in milliseconds) * @param searchReq.toModifiedTime only include users modified on or before this time (epoch in milliseconds) * @returns The users found by the query, along with the total number of matches */