@sinequa/atomic 2.3.2 → 2.5.0
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/README.md +117 -54
- package/dist/atomic.cjs +1 -1
- package/dist/atomic.js +2 -2
- package/dist/client/create-api.d.ts +4 -4
- package/dist/configurations/auth-mode.d.ts +2 -2
- package/dist/configurations/global.config.d.ts +33 -2
- package/dist/configurations/global.config.d.ts.map +1 -1
- package/dist/helpers/aggregation-count.d.ts +68 -0
- package/dist/helpers/aggregation-count.d.ts.map +1 -0
- package/dist/helpers/column-resolver.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/utils.d.ts +42 -7
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/spfx/index.cjs +1 -1
- package/dist/spfx/index.js +2 -2
- package/dist/src-BcyahlCg.cjs +1 -0
- package/dist/{src-QHeKpRHd.js → src-vDryIxd0.js} +632 -583
- package/dist/types/search/Article.d.ts +8 -0
- package/dist/types/search/Article.d.ts.map +1 -1
- package/dist/types/search/DidYouMeanItem.d.ts +29 -1
- package/dist/types/search/DidYouMeanItem.d.ts.map +1 -1
- package/dist/types/search/QueryIntent.d.ts +8 -1
- package/dist/types/search/QueryIntent.d.ts.map +1 -1
- package/dist/types/search/QueryIntentDatasets.d.ts +0 -3
- package/dist/types/search/QueryIntentDatasets.d.ts.map +1 -1
- package/dist/types/search/index.d.ts +3 -1
- package/dist/types/search/index.d.ts.map +1 -1
- package/dist/utils/date.d.ts +10 -2
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/query-params.d.ts +20 -3
- package/dist/utils/query-params.d.ts.map +1 -1
- package/dist/web-api/helpers/handle-response.d.ts.map +1 -1
- package/dist/web-api/helpers/methods/send-request.d.ts +0 -4
- package/dist/web-api/helpers/methods/send-request.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-aggregation.d.ts +26 -5
- package/dist/web-api/v1/fetch-aggregation.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-labels.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-preview.d.ts +11 -4
- package/dist/web-api/v1/fetch-preview.d.ts.map +1 -1
- package/dist/web-api/v1/fetch-query.d.ts +10 -3
- package/dist/web-api/v1/fetch-query.d.ts.map +1 -1
- package/dist/web-api/v2/fetch-forgot-password.d.ts +5 -1
- package/dist/web-api/v2/fetch-forgot-password.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/src-DQYL0h7T.cjs +0 -1
- package/dist/types/interfaces/json.d.ts +0 -7
- package/dist/types/interfaces/json.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
3
|
<img src="https://img.shields.io/npm/v/@sinequa/atomic?style=for-the-badge&color=0ea5e9&label=@sinequa%2Fatomic" alt="npm version" />
|
|
4
|
-
<img src="https://img.shields.io/badge/TypeScript-
|
|
4
|
+
<img src="https://img.shields.io/badge/TypeScript-7.x-3178c6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" />
|
|
5
5
|
<img src="https://img.shields.io/badge/ESM-ready-f59e0b?style=for-the-badge" alt="ESM" />
|
|
6
6
|
<img src="https://img.shields.io/badge/SPFx-ready-0078d4?style=for-the-badge&logo=microsoftsharepoint&logoColor=white" alt="SPFx" />
|
|
7
|
-
<img src="https://img.shields.io/npm/l/@sinequa/atomic?style=for-the-badge&color=22c55e" alt="MIT License" />
|
|
8
7
|
|
|
9
8
|
<br /><br />
|
|
10
9
|
|
|
@@ -14,7 +13,7 @@
|
|
|
14
13
|
Authentication, search, aggregations, datasets, preview — everything typed, tree-shakable, zero runtime dependencies.
|
|
15
14
|
SPFx-ready via the `@sinequa/atomic/spfx` subpath export.
|
|
16
15
|
|
|
17
|
-
[Docs](
|
|
16
|
+
[Docs](./docs/index.mdx) · [Get started](./docs/start/index.mdx) · [Reference](./docs/reference/index.mdx)
|
|
18
17
|
|
|
19
18
|
</div>
|
|
20
19
|
|
|
@@ -39,16 +38,26 @@ npm install @microsoft/sp-http --save-peer
|
|
|
39
38
|
## At a glance
|
|
40
39
|
|
|
41
40
|
```typescript
|
|
42
|
-
import {
|
|
41
|
+
import { setGlobalConfig, isAuthenticated, login, fetchQuery } from '@sinequa/atomic';
|
|
42
|
+
|
|
43
|
+
setGlobalConfig({ app: 'my-app', backendUrl: 'https://my-sinequa-server.example.com' });
|
|
43
44
|
|
|
44
45
|
if (!isAuthenticated()) {
|
|
45
46
|
await login({ username: 'alice', password: 's3cr3t' });
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
const
|
|
49
|
+
// A query is a plain object; only `name` — the query web service — is required.
|
|
50
|
+
const result = await fetchQuery({ name: '<your-query>', text: 'knowledge management', pageSize: 10 });
|
|
51
|
+
|
|
52
|
+
// One round-trip: the documents are in `records`, the facet counts in `aggregations`.
|
|
53
|
+
// Check `$error` before concluding anything from an empty `records`.
|
|
54
|
+
const { records, aggregations, $error } = result;
|
|
50
55
|
```
|
|
51
56
|
|
|
57
|
+
`fetchAggregation(aggregation, query)` is for **paging** an aggregation you already received — it
|
|
58
|
+
takes the `Aggregation` object off `result.aggregations` and the same query, as two positional
|
|
59
|
+
arguments. See [Aggregations](./docs/search/aggregations.mdx).
|
|
60
|
+
|
|
52
61
|
---
|
|
53
62
|
|
|
54
63
|
## SharePoint Framework (SPFx)
|
|
@@ -67,14 +76,17 @@ const client = await this.context.aadHttpClientFactory
|
|
|
67
76
|
initializeAadHttpClient(client);
|
|
68
77
|
|
|
69
78
|
// All subsequent API calls route through AadHttpClient automatically:
|
|
70
|
-
const results = await fetchQuery({ name: '
|
|
79
|
+
const results = await fetchQuery({ name: '<your-query>', text: 'knowledge management' });
|
|
71
80
|
```
|
|
72
81
|
|
|
73
82
|
Call `initializeAadHttpClient(null)` to detach the client (e.g. in `onDispose`).
|
|
74
83
|
|
|
75
84
|
> The `./spfx` subpath re-exports everything from `@sinequa/atomic` and adds
|
|
76
|
-
> `initializeAadHttpClient`, `
|
|
77
|
-
>
|
|
85
|
+
> `initializeAadHttpClient`, `aadHttpClientManager`, `createSpfxHttpAdapter`, `AadHttpClientLike`
|
|
86
|
+
> and `AadHttpResponseLike`. `initializeAadHttpClient` registers the client globally for the free
|
|
87
|
+
> functions; `createSpfxHttpAdapter(aadHttpClient)` is the same transport as an `httpAdapter` for
|
|
88
|
+
> `createAtomicClient`. Standard (non-SPFx) consumers use `@sinequa/atomic` directly — no changes
|
|
89
|
+
> needed. See [SPFx](./docs/integration/spfx.mdx).
|
|
78
90
|
|
|
79
91
|
---
|
|
80
92
|
|
|
@@ -83,9 +95,11 @@ Call `initializeAadHttpClient(null)` to detach the client (e.g. in `onDispose`).
|
|
|
83
95
|
### Client (experimental)
|
|
84
96
|
|
|
85
97
|
`createAtomicClient(config)` returns an isolated client — its own configuration, session and event
|
|
86
|
-
subscribers — exposing `client.config`, `client.
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
subscribers — exposing `client.config`, `client.configure()`, `client.initializeConfig()`,
|
|
99
|
+
`client.auth`, `client.http` and `client.api` (the typed endpoints, e.g.
|
|
100
|
+
`client.api.query.search(query)`). Several clients can target different backends from the same page,
|
|
101
|
+
and each takes its transport and auth knobs as configuration (`httpAdapter`, and
|
|
102
|
+
`auth: { fetch, storage, logger }`), which removes the need for module mocks in tests.
|
|
89
103
|
|
|
90
104
|
```typescript
|
|
91
105
|
import { createAtomicClient } from '@sinequa/atomic';
|
|
@@ -98,6 +112,7 @@ const results = await client.http.post('api/v1/search.query', { text: 'hello' })
|
|
|
98
112
|
The free functions below keep working unchanged: they run on a default client whose configuration
|
|
99
113
|
**is** `globalConfig`, and `getDefaultClient()` hands back that very instance — useful from code
|
|
100
114
|
that cannot receive one (a distributed web component, a plugin).
|
|
115
|
+
See [The client](./docs/core/client.mdx) and [Multiple backends](./docs/integration/multiple-backends.mdx).
|
|
101
116
|
|
|
102
117
|
### Authentication
|
|
103
118
|
|
|
@@ -105,34 +120,41 @@ Full auth lifecycle — from first handshake to logout.
|
|
|
105
120
|
|
|
106
121
|
| Export | Description |
|
|
107
122
|
|---|---|
|
|
108
|
-
| `isAuthenticated()` |
|
|
109
|
-
| `
|
|
123
|
+
| `isAuthenticated()` | Synchronous. `true` when a CSRF token is stored **or** a token-less session was recorded (ambient SSO issues no client token) |
|
|
124
|
+
| `hasSession()` | Asks the server when nothing is stored, and never redirects — unlike `login()` |
|
|
125
|
+
| `login(credentials?)` | Login — switches on the resolved `authMode` (credentials / SSO / OAuth / SAML / bearer / unknown) |
|
|
110
126
|
| `logout()` | Clears session, returns the server's `redirectUrl` |
|
|
111
|
-
| `clearSessionTokens()` | Drops the
|
|
127
|
+
| `clearSessionTokens()` | Drops the local session (tokens, token-less flag) and emits `authenticated: false`, without a server round-trip |
|
|
112
128
|
| `detectAuthMode(config, preLogin?)` | Pure resolution of the `AuthMode` from config + server pre-login (no I/O) |
|
|
113
129
|
| `getToken()` / `setToken(token)` | Read/write the stored CSRF token |
|
|
114
|
-
| `
|
|
130
|
+
| `requestWebTokenSession(credentials?)` | POSTs `security.webtoken`. The JWT lands in a cookie; the returned (and stored) value is the **CSRF token**. Omit the credentials to use the configured bearer token |
|
|
115
131
|
| `getCsrfToken()` | CSRF token for mutating requests |
|
|
116
132
|
| `deleteWebTokenCookie()` | Explicitly removes the web token cookie |
|
|
117
|
-
| `onAuthEvent(event, handler)` | Typed subscription to the auth lifecycle (`authenticated`, `unauthorized`, `tokenRefreshed`, `loggedOut`) — returns the unsubscribe function |
|
|
118
|
-
| `tryAutoAuthentication()` | Probes
|
|
133
|
+
| `onAuthEvent(event, handler)` | Typed subscription to the auth lifecycle (`authenticated`, `unauthorized`, `requestFailed`, `tokenRefreshed`, `loggedOut`) — returns the unsubscribe function |
|
|
134
|
+
| `tryAutoAuthentication()` | Probes a protected endpoint for server-side auto-authentication (OIDC, IIS Negotiate) — used by `login()` in `sso`, `unknown` and `bearer` modes. Never throws |
|
|
135
|
+
| `isRedirectPending()` | Whether an OAuth/SAML redirect is in flight and has not established a session yet |
|
|
119
136
|
| `tryOAuthAuthentication()` / `trySAMLAuthentication()` | Redirect to the configured identity provider (with a one-shot redirect-loop guard) |
|
|
120
137
|
| `emitAuthenticatedEvent(bool)` | Dispatches the DOM `'authenticated'` CustomEvent (on `document`, bubbles to `window`) |
|
|
121
138
|
|
|
139
|
+
> `getJWToken` is **`@deprecated`**: it is an alias of `requestWebTokenSession`, renamed because the
|
|
140
|
+
> old name suggested it returned the JWT. It will be removed in the next major.
|
|
141
|
+
|
|
122
142
|
The authentication layer is configurable via `setGlobalConfig({ auth: { … } })` (`AuthOptions`):
|
|
123
|
-
|
|
124
|
-
`
|
|
143
|
+
`timeoutMs`, `probeEndpoint`, injectable `storage`/`logger`/`fetch`, the requests' `credentials`
|
|
144
|
+
mode, and `recoverFromUnauthorized` — the hook that re-establishes a session after a 401 and gets
|
|
145
|
+
the request replayed once. See [Authentication](./docs/auth/index.mdx) and
|
|
146
|
+
[Handling 401](./docs/auth/handling-401.mdx).
|
|
125
147
|
|
|
126
148
|
```typescript
|
|
127
149
|
import { isAuthenticated, login, logout } from '@sinequa/atomic';
|
|
128
150
|
|
|
129
151
|
if (!isAuthenticated()) {
|
|
130
|
-
// Auto-resolve: reuse an existing session if any, otherwise
|
|
131
|
-
// fall back to the credentials form.
|
|
152
|
+
// Auto-resolve: reuse an existing session if any, otherwise follow the resolved
|
|
153
|
+
// `authMode` — in `unknown` mode, probe for SSO then fall back to the credentials form.
|
|
132
154
|
const ok = await login();
|
|
133
155
|
|
|
134
|
-
// — or —
|
|
135
|
-
const
|
|
156
|
+
// — or — explicit credentials, which bypass mode detection entirely.
|
|
157
|
+
const okWithCredentials = await login({ username: 'alice', password: 's3cr3t' });
|
|
136
158
|
}
|
|
137
159
|
|
|
138
160
|
const redirectUrl = await logout();
|
|
@@ -144,7 +166,7 @@ const redirectUrl = await logout();
|
|
|
144
166
|
typed discriminated union — no more juggling overlapping booleans:
|
|
145
167
|
|
|
146
168
|
```typescript
|
|
147
|
-
import { AuthMode, setGlobalConfig } from '@sinequa/atomic';
|
|
169
|
+
import { AuthMode, globalConfig, setGlobalConfig } from '@sinequa/atomic';
|
|
148
170
|
|
|
149
171
|
setGlobalConfig({ authMode: AuthMode.credentials() }); // username/password form
|
|
150
172
|
setGlobalConfig({ authMode: AuthMode.sso() }); // browser/proxy-injected auth
|
|
@@ -153,14 +175,16 @@ setGlobalConfig({ authMode: AuthMode.saml('my-provider') }); // redirect to a S
|
|
|
153
175
|
setGlobalConfig({ authMode: AuthMode.bearer(token) }); // server-to-server bearer token
|
|
154
176
|
setGlobalConfig({ authMode: AuthMode.unknown() }); // try SSO, then fall back to credentials
|
|
155
177
|
|
|
156
|
-
// `login()` and `detectAuthMode()` branch on `authMode.kind
|
|
157
|
-
|
|
178
|
+
// `login()` and `detectAuthMode()` branch on `authMode.kind`. Every key of `globalConfig` is
|
|
179
|
+
// optional, so read it through `?.` — the default is `AuthMode.unknown()`.
|
|
180
|
+
const kind = globalConfig.authMode?.kind; // 'credentials' | 'sso' | 'oauth' | 'saml' | 'bearer' | 'unknown'
|
|
158
181
|
```
|
|
159
182
|
|
|
160
183
|
> **Migrating from 1.x:** the booleans `useCredentials` / `useSSO` / `useSAML` are now
|
|
161
184
|
> **`@deprecated` read-only getters** derived from `authMode`. Reading them still works, and writing
|
|
162
185
|
> them through `setGlobalConfig({ useSSO: true })` is translated into the matching `authMode` — so
|
|
163
186
|
> existing code keeps working. Prefer `authMode.kind` (and the `AuthMode.*` constructors) in new code.
|
|
187
|
+
> Full upgrade notes: [Migrating from 1.x](./docs/reference/migrating-from-1x.mdx).
|
|
164
188
|
|
|
165
189
|
---
|
|
166
190
|
|
|
@@ -171,7 +195,9 @@ Every Sinequa v1 endpoint has a typed wrapper.
|
|
|
171
195
|
```typescript
|
|
172
196
|
import {
|
|
173
197
|
fetchApp,
|
|
198
|
+
fetchAppPreLogin,
|
|
174
199
|
fetchQuery,
|
|
200
|
+
fetchBulkQuery,
|
|
175
201
|
fetchAggregation,
|
|
176
202
|
fetchDataset,
|
|
177
203
|
fetchPreview,
|
|
@@ -179,15 +205,18 @@ import {
|
|
|
179
205
|
fetchSimilarDocuments,
|
|
180
206
|
fetchSponsoredLinks,
|
|
181
207
|
fetchSuggest,
|
|
182
|
-
|
|
208
|
+
fetchTextChunks,
|
|
183
209
|
fetchUserSettings,
|
|
184
|
-
fetchAudit,
|
|
185
210
|
fetchLabels,
|
|
186
211
|
fetchQueryExport,
|
|
187
212
|
fetchQueryIntent,
|
|
213
|
+
searchPrincipals,
|
|
188
214
|
} from '@sinequa/atomic';
|
|
189
215
|
```
|
|
190
216
|
|
|
217
|
+
Auditing is not a `fetch*` function: use `Audit.notify(...)`, plus the record decorators
|
|
218
|
+
`addAuditAdditionalInfo`, `addSessionId` and `addUrl`. See [Audit](./docs/integration/audit.mdx).
|
|
219
|
+
|
|
191
220
|
### Web API — v2
|
|
192
221
|
|
|
193
222
|
```typescript
|
|
@@ -195,10 +224,13 @@ import {
|
|
|
195
224
|
fetchUserProfile,
|
|
196
225
|
fetchVersion,
|
|
197
226
|
fetchChangePassword,
|
|
198
|
-
|
|
227
|
+
fetchSendPasswordResetEmail,
|
|
199
228
|
} from '@sinequa/atomic';
|
|
200
229
|
```
|
|
201
230
|
|
|
231
|
+
The full endpoint list — with the `client.api` method and the free function for each — is in
|
|
232
|
+
[Endpoints](./docs/reference/endpoints.mdx).
|
|
233
|
+
|
|
202
234
|
---
|
|
203
235
|
|
|
204
236
|
### Helpers
|
|
@@ -207,16 +239,20 @@ Utilities for transforming Sinequa data structures.
|
|
|
207
239
|
|
|
208
240
|
```typescript
|
|
209
241
|
import {
|
|
210
|
-
getMetadata,
|
|
211
|
-
getMetadataWithValues, //
|
|
242
|
+
getMetadata, // metadata of an article as `string[]` (splits comma-separated values)
|
|
243
|
+
getMetadataWithValues, // same, as `{ display, value }[]`
|
|
212
244
|
makeColumn,
|
|
245
|
+
extraColumns,
|
|
213
246
|
resolveToColumnName,
|
|
247
|
+
resultPages,
|
|
214
248
|
escapeExpr,
|
|
215
249
|
guid,
|
|
216
250
|
isObject,
|
|
217
251
|
} from '@sinequa/atomic';
|
|
218
252
|
```
|
|
219
253
|
|
|
254
|
+
More in [Helpers](./docs/reference/helpers.mdx).
|
|
255
|
+
|
|
220
256
|
#### Filter builder
|
|
221
257
|
|
|
222
258
|
Build structured `query.filters` without hand-writing filter objects. Combinators ignore falsy
|
|
@@ -235,11 +271,16 @@ const filters = filter.and(
|
|
|
235
271
|
onlyRecent && filter.between('modified', '2024-01-01', '2024-12-31'),
|
|
236
272
|
);
|
|
237
273
|
|
|
238
|
-
await fetchQuery({ name: '
|
|
274
|
+
await fetchQuery({ name: '<your-query>', text: 'report', filters });
|
|
239
275
|
```
|
|
240
276
|
|
|
241
277
|
Leaf operators: `eq` · `neq` · `gt` · `gte` · `lt` · `lte` · `like` · `contains` · `regex` · `isNull` · `isNotNull` · `in` · `between`. Combinators: `and` · `or` · `not`.
|
|
242
278
|
|
|
279
|
+
`filter.distribution(field, item.value)` handles the one case the leaf operators cannot: a
|
|
280
|
+
**distribution** aggregation item (a date or size bucket), whose `value` is an expression the server
|
|
281
|
+
built rather than a value. Passing it to `filter.eq` makes the backend answer
|
|
282
|
+
`500 — "Field type error"`. See [Filters](./docs/search/filters.mdx).
|
|
283
|
+
|
|
243
284
|
---
|
|
244
285
|
|
|
245
286
|
### Utilities
|
|
@@ -247,15 +288,19 @@ Leaf operators: `eq` · `neq` · `gt` · `gte` · `lt` · `lte` · `like` · `co
|
|
|
247
288
|
```typescript
|
|
248
289
|
import {
|
|
249
290
|
bisect,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
291
|
+
sysLang, // resolves `all[fr]tous[de]alle` against a locale
|
|
292
|
+
getRelativeDate, // and `getOffsetFromDates`
|
|
293
|
+
getQueryParamsFromUrl, // and `getUrlParamsFromQueryParams`, `getFiltersFromUrl`, …
|
|
294
|
+
addConcepts, // and `getConcepts`, `parseText`, `rewriteText`, `removeConcept(s)`
|
|
295
|
+
notify,
|
|
296
|
+
configureLogger, // and the `debug` / `info` / `warn` / `error` bindings, `LogLevel`
|
|
256
297
|
} from '@sinequa/atomic';
|
|
257
298
|
```
|
|
258
299
|
|
|
300
|
+
> The library's verbosity is set with `configureLogger({ level: LogLevel.DEBUG })`, **not** through
|
|
301
|
+
> a configuration key. See [Logging](./docs/integration/logging.mdx) and
|
|
302
|
+
> [URL state](./docs/search/url-state.mdx).
|
|
303
|
+
|
|
259
304
|
---
|
|
260
305
|
|
|
261
306
|
## Types
|
|
@@ -275,6 +320,8 @@ import type {
|
|
|
275
320
|
} from '@sinequa/atomic';
|
|
276
321
|
```
|
|
277
322
|
|
|
323
|
+
Which type comes back from which call: [Type map](./docs/reference/types-map.mdx).
|
|
324
|
+
|
|
278
325
|
---
|
|
279
326
|
|
|
280
327
|
## Configuration
|
|
@@ -291,23 +338,40 @@ setGlobalConfig({
|
|
|
291
338
|
authMode: AuthMode.unknown(), // optional — defaults to `unknown`
|
|
292
339
|
});
|
|
293
340
|
|
|
294
|
-
// read it back
|
|
295
|
-
console.log(globalConfig.backendUrl, globalConfig.authMode
|
|
341
|
+
// read it back — every key is optional on `globalConfig`, so `?.` is required
|
|
342
|
+
console.log(globalConfig.backendUrl, globalConfig.authMode?.kind);
|
|
296
343
|
```
|
|
297
344
|
|
|
298
|
-
|
|
299
|
-
|
|
345
|
+
Call `initializeAppConfig()` once at bootstrap: it fills in `backendUrl`/`app` from the browser URL
|
|
346
|
+
when they were not provided, then resolves the `authMode` from the server's pre-login response.
|
|
347
|
+
|
|
348
|
+
> `appInitializerFn` is a **`@deprecated`** alias of `initializeAppConfig` — use the latter.
|
|
349
|
+
|
|
350
|
+
Three declared keys are read by nothing, and setting them has no effect: `logLevel` (set the level
|
|
351
|
+
with `configureLogger({ level })`), `loginPath` (routing is yours — use `recoverFromUnauthorized` or
|
|
352
|
+
the `unauthorized` event) and `createRoutes`. Every key, with its default:
|
|
353
|
+
[Configuration keys](./docs/reference/config-keys.mdx).
|
|
300
354
|
|
|
301
355
|
---
|
|
302
356
|
|
|
303
357
|
## Testing
|
|
304
358
|
|
|
305
359
|
```bash
|
|
306
|
-
npm test
|
|
307
|
-
npm test -- --
|
|
360
|
+
npm test # vitest, watch mode
|
|
361
|
+
npm test -- --watch=false # single run (what CI does)
|
|
308
362
|
```
|
|
309
363
|
|
|
310
|
-
|
|
364
|
+
`--ui` is not available out of the box: `@vitest/ui` is an optional peer of vitest and is not
|
|
365
|
+
installed here — `npm i -D @vitest/ui` first.
|
|
366
|
+
|
|
367
|
+
Coverage is deepest on authentication (`AuthMode` detection, OAuth, SAML, credentials, tokens,
|
|
368
|
+
401 recovery) and on the HTTP helpers. On the endpoints it is targeted rather than exhaustive —
|
|
369
|
+
`fetchQuery`, `fetchAggregation`, `fetchPrincipal`, `searchPrincipals`, `fetchApp` and the
|
|
370
|
+
document-upload containers. Also covered: the filter builder, metadata parsing, column resolution,
|
|
371
|
+
pagination, date utilities and the SQL value helper.
|
|
372
|
+
|
|
373
|
+
Injecting `fetch`, `storage` and `logger` through the configuration is what lets a test avoid module
|
|
374
|
+
mocks — see [Testing](./docs/integration/testing.mdx).
|
|
311
375
|
|
|
312
376
|
---
|
|
313
377
|
|
|
@@ -326,18 +390,17 @@ npm run dev:pack # build + pack locally
|
|
|
326
390
|
1. All tests must pass.
|
|
327
391
|
2. Lint with [Biome](https://biomejs.dev/) — `npx @biomejs/biome check --write .`
|
|
328
392
|
3. Follow [Conventional Commits](https://www.conventionalcommits.org/).
|
|
329
|
-
4.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
MIT — see [LICENSE](./LICENSE).
|
|
393
|
+
4. Any change touching `src/` needs a **changeset** in the same commit (`npm run changeset`, then
|
|
394
|
+
`npm run changeset:status` to check) — the `changeset-check` CI job blocks the merge without one.
|
|
395
|
+
Add `#skip-changeset` to the MR title for a change that does not touch the published library.
|
|
396
|
+
Full guide, with examples: [`CONTRIBUTING-changesets.md`](./CONTRIBUTING-changesets.md).
|
|
397
|
+
5. New public API → add tests + JSDoc, and export it from `src/index.ts` (a helper that is written
|
|
398
|
+
and tested but not re-exported from the barrel is not part of the public API).
|
|
336
399
|
|
|
337
400
|
---
|
|
338
401
|
|
|
339
402
|
<div align="center">
|
|
340
403
|
|
|
341
|
-
Built for the [Sinequa](https://www.sinequa.com/) ecosystem · [Report an issue](https://
|
|
404
|
+
Built for the [Sinequa](https://www.sinequa.com/) ecosystem · [Report an issue](https://gitlab.chapsvision.in/sinequa/rnd/sba-atomic-js/-/issues)
|
|
342
405
|
|
|
343
406
|
</div>
|
package/dist/atomic.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-BcyahlCg.cjs");exports.API=e.ft,exports.ApiError=e.Vn,exports.Audit=e.Tt,exports.AuditEventType=e.Qt,exports.AuthMode=e.Qn,exports.DEFAULT_AGGREGATION_COUNT=e.en,exports.DidYouMeanKind=e.Jt,exports.EngineType=e.Zt,exports.EngineTypeModifier=e.Xt,exports.LogLevel=e.ir,exports.MINIMUM_COMPATIBLE_SERVER_API_VERSION=e.Yt,exports.RFMDisplay=e.qt,exports.ServerError=e.Rn,exports.TimeoutError=e.jn,exports.UnauthorizedError=e.Bn,exports.addAuditAdditionalInfo=e.Et,exports.addConcepts=e.b,exports.addSessionId=e.Dt,exports.addUrl=e.Ot,exports.aggItemRegex=e.D,exports.aggregationHasMore=e.tn,exports.aggregationItemStrictCompare=e.O,exports.appInitializerFn=e.rn,exports.applyConfig=e.Yn,exports.assertNever=e.Sn,exports.bisect=e.E,exports.buildPathsAndLevels=e.lt,exports.clearSessionTokens=e.hn,exports.configureLogger=e.ar,exports.createAtomicClient=e.N,exports.createContainer=e.V,exports.createHeaders=e.Hn,exports.createHeadersWithContext=e.Un,exports.createTimeoutController=e.An,exports.createUserProfile=e.I,Object.defineProperty(exports,"debug",{enumerable:!0,get:function(){return e.or}}),exports.del=e.dn,exports.delWithContext=e.fn,exports.deleteContainerDocuments=e.H,exports.deleteContainers=e.U,exports.deleteUserProfileProperty=e.L,exports.deleteUserSettings=e.Y,exports.deleteWebTokenCookie=e._n,exports.detectAuthMode=e.Dn,exports.emitAuthenticatedEvent=e.Gn,Object.defineProperty(exports,"error",{enumerable:!0,get:function(){return e.sr}}),exports.escapeExpr=e.kt,exports.expiresSoon=e.n,exports.extraColumns=e.Gt,exports.fetchAggregation=e.wt,exports.fetchApp=e.in,exports.fetchAppPreLogin=e.an,exports.fetchBulkQuery=e.ut,exports.fetchChangePassword=e.J,exports.fetchDataset=e.xt,exports.fetchDatasetList=e.St,exports.fetchDatasets=e.Ct,exports.fetchLabels=e.yt,exports.fetchPreview=e._t,exports.fetchPreviewUrl=e.vt,exports.fetchPrincipal=e.pt,exports.fetchPrincipalList=e.mt,exports.fetchPrincipalUserid=e.ht,exports.fetchPrincipalUserids=e.gt,exports.fetchQuery=e.dt,exports.fetchQueryExport=e.ct,exports.fetchQueryIntent=e.st,exports.fetchSendPasswordResetEmail=e.B,exports.fetchSimilarDocuments=e.at,exports.fetchSponsoredLinks=e.it,exports.fetchSuggest=e.et,exports.fetchSuggestField=e.tt,exports.fetchSuggestQuery=e.nt,exports.fetchTextChunks=e.$,exports.fetchUserProfile=e.R,exports.fetchUserSettings=e.X,exports.fetchVersion=e.F,exports.filter=e.Ut,exports.get=e.Tn,exports.getConcepts=e.x,exports.getContainer=e.W,exports.getCsrfToken=e.wn,exports.getDefaultClient=e.P,exports.getFiltersFromURI=e.s,exports.getFiltersFromUrl=e.c,exports.getHelpIndexUrl=e.a,exports.getIdFromUrl=e.l,exports.getJWToken=e.bn,exports.getMetadata=e.Vt,exports.getMetadataWithValues=e.Ht,exports.getOffsetFromDates=e.v,exports.getQueryPageFromUrl=e.u,exports.getQueryParamsFromUrl=e.d,exports.getQueryTabFromUrl=e.f,exports.getQueryTextFromUrl=e.p,exports.getRelativeDate=e.y,exports.getTime=e.At,exports.getToken=e.Wn,exports.getUrlParamsFromQueryParams=e.m,exports.getWithContext=e.En,exports.globalConfig=e.Xn,exports.guid=e.jt,exports.handleResponse=e.In,exports.handleResponseWithContext=e.Ln,exports.hasSession=e.Cn,exports.hashString=e.Mt,Object.defineProperty(exports,"info",{enumerable:!0,get:function(){return e.cr}}),exports.initializeAppConfig=e.on,exports.isArrayBuffer=e.Nt,exports.isAuthenticated=e.pn,exports.isBlob=e.Pt,exports.isDate=e.Ft,exports.isExpired=e.r,exports.isExternalAuthMode=e.$n,exports.isJsonable=e.It,exports.isNotInputEvent=e._,exports.isObject=e.Lt,exports.isRedirectPending=e.mn,exports.isString=e.Rt,exports.labels=e.bt,exports.legacyBooleansToAuthMode=e.er,exports.legacyFilterToFilter=e.Wt,exports.listContainerDocuments=e.G,exports.listContainers=e.K,exports.login=e.vn,exports.logout=e.gn,exports.makeColumn=e.Kt,exports.notify=e.g,exports.onAuthEvent=e.ur,exports.openParentNodes=e.k,exports.parseText=e.S,exports.parseValueAndOperatorFromItem=e.A,exports.patch=e.ln,exports.patchUserProfile=e.z,exports.patchUserSettings=e.Z,exports.patchWithContext=e.un,exports.post=e.Mn,exports.postWithContext=e.Nn,exports.put=e.sn,exports.putWithContext=e.cn,exports.queryParamsFromUrl=e.h,exports.removeConcept=e.C,exports.removeConcepts=e.w,exports.requestWebTokenSession=e.xn,exports.resolveAggregationCount=e.nn,exports.resolveBearerToken=e.tr,exports.resolveNoAutoAuthentication=e.Pn,exports.resolveNoAutoAuthenticationWithContext=e.Fn,exports.resolveOAuthProvider=e.nr,exports.resolveSAMLProvider=e.rr,exports.resolveToColumnName=e.$t,exports.resultPages=e.Bt,exports.rewriteText=e.T,exports.saveUserSettings=e.Q,exports.searchPrincipals=e.ot,exports.setGlobalConfig=e.Zn,exports.setToken=e.zn,exports.sha512=e.zt,exports.suggestionsToTreeAggregationNodes=e.j,exports.sysLang=e.o,exports.toDate=e.i,exports.toSqlValue=e.rt,exports.translateAggregationToDateOptions=e.M,exports.tryAutoAuthentication=e.yn,exports.tryOAuthAuthentication=e.kn,exports.trySAMLAuthentication=e.On,exports.updateContainer=e.q,Object.defineProperty(exports,"warn",{enumerable:!0,get:function(){return e.lr}}),exports.withRetry=e.t;
|
package/dist/atomic.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as e, $n as t, $t as n, A as r, An as i, At as a, B as o, Bn as s, Bt as c, C as l, Cn as u, Ct as d, D as f, Dn as p, Dt as m, E as h, En as g, Et as _, F as v, Fn as y, Ft as b, G as x, Gn as S, Gt as C, H as w,
|
|
2
|
-
export {
|
|
1
|
+
import { $ as e, $n as t, $t as n, A as r, An as i, At as a, B as o, Bn as s, Bt as c, C as l, Cn as u, Ct as d, D as f, Dn as p, Dt as m, E as h, En as g, Et as _, F as v, Fn as y, Ft as b, G as x, Gn as S, Gt as C, H as w, Hn as T, Ht as E, I as D, In as O, It as k, J as A, Jt as j, K as M, Kt as N, L as P, Ln as F, Lt as I, M as L, Mn as R, Mt as z, N as B, Nn as V, Nt as H, O as U, On as W, Ot as G, P as K, Pn as q, Pt as J, Q as Y, Qn as X, Qt as Z, R as Q, Rn as $, Rt as ee, S as te, Sn as ne, St as re, T as ie, Tn as ae, Tt as oe, U as se, Un as ce, Ut as le, V as ue, Vn as de, Vt as fe, W as pe, Wn as me, Wt as he, X as ge, Xn as _e, Xt as ve, Y as ye, Yn as be, Yt as xe, Z as Se, Zn as Ce, Zt as we, _ as Te, _n as Ee, _t as De, a as Oe, an as ke, ar as Ae, at as je, b as Me, bn as Ne, bt as Pe, c as Fe, cn as Ie, cr as Le, ct as Re, d as ze, dn as Be, dt as Ve, en as He, er as Ue, et as We, f as Ge, fn as Ke, ft as qe, g as Je, gn as Ye, gt as Xe, h as Ze, hn as Qe, ht as $e, i as et, in as tt, ir as nt, it as rt, j as it, jn as at, jt as ot, k as st, kn as ct, kt as lt, l as ut, ln as dt, lr as ft, lt as pt, m as mt, mn as ht, mt as gt, n as _t, nn as vt, nr as yt, nt as bt, o as xt, on as St, or as Ct, ot as wt, p as Tt, pn as Et, pt as Dt, q as Ot, qt as kt, r as At, rn as jt, rr as Mt, rt as Nt, s as Pt, sn as Ft, sr as It, st as Lt, t as Rt, tn as zt, tr as Bt, tt as Vt, u as Ht, un as Ut, ur as Wt, ut as Gt, v as Kt, vn as qt, vt as Jt, w as Yt, wn as Xt, wt as Zt, x as Qt, xn as $t, xt as en, y as tn, yn as nn, yt as rn, z as an, zn as on, zt as sn } from "./src-vDryIxd0.js";
|
|
2
|
+
export { qe as API, de as ApiError, oe as Audit, Z as AuditEventType, X as AuthMode, He as DEFAULT_AGGREGATION_COUNT, j as DidYouMeanKind, we as EngineType, ve as EngineTypeModifier, nt as LogLevel, xe as MINIMUM_COMPATIBLE_SERVER_API_VERSION, kt as RFMDisplay, $ as ServerError, at as TimeoutError, s as UnauthorizedError, _ as addAuditAdditionalInfo, Me as addConcepts, m as addSessionId, G as addUrl, f as aggItemRegex, zt as aggregationHasMore, U as aggregationItemStrictCompare, jt as appInitializerFn, be as applyConfig, ne as assertNever, h as bisect, pt as buildPathsAndLevels, Qe as clearSessionTokens, Ae as configureLogger, B as createAtomicClient, ue as createContainer, T as createHeaders, ce as createHeadersWithContext, i as createTimeoutController, D as createUserProfile, Ct as debug, Be as del, Ke as delWithContext, w as deleteContainerDocuments, se as deleteContainers, P as deleteUserProfileProperty, ye as deleteUserSettings, Ee as deleteWebTokenCookie, p as detectAuthMode, S as emitAuthenticatedEvent, It as error, lt as escapeExpr, _t as expiresSoon, C as extraColumns, Zt as fetchAggregation, tt as fetchApp, ke as fetchAppPreLogin, Gt as fetchBulkQuery, A as fetchChangePassword, en as fetchDataset, re as fetchDatasetList, d as fetchDatasets, rn as fetchLabels, De as fetchPreview, Jt as fetchPreviewUrl, Dt as fetchPrincipal, gt as fetchPrincipalList, $e as fetchPrincipalUserid, Xe as fetchPrincipalUserids, Ve as fetchQuery, Re as fetchQueryExport, Lt as fetchQueryIntent, o as fetchSendPasswordResetEmail, je as fetchSimilarDocuments, rt as fetchSponsoredLinks, We as fetchSuggest, Vt as fetchSuggestField, bt as fetchSuggestQuery, e as fetchTextChunks, Q as fetchUserProfile, ge as fetchUserSettings, v as fetchVersion, le as filter, ae as get, Qt as getConcepts, pe as getContainer, Xt as getCsrfToken, K as getDefaultClient, Pt as getFiltersFromURI, Fe as getFiltersFromUrl, Oe as getHelpIndexUrl, ut as getIdFromUrl, Ne as getJWToken, fe as getMetadata, E as getMetadataWithValues, Kt as getOffsetFromDates, Ht as getQueryPageFromUrl, ze as getQueryParamsFromUrl, Ge as getQueryTabFromUrl, Tt as getQueryTextFromUrl, tn as getRelativeDate, a as getTime, me as getToken, mt as getUrlParamsFromQueryParams, g as getWithContext, _e as globalConfig, ot as guid, O as handleResponse, F as handleResponseWithContext, u as hasSession, z as hashString, Le as info, St as initializeAppConfig, H as isArrayBuffer, Et as isAuthenticated, J as isBlob, b as isDate, At as isExpired, t as isExternalAuthMode, k as isJsonable, Te as isNotInputEvent, I as isObject, ht as isRedirectPending, ee as isString, Pe as labels, Ue as legacyBooleansToAuthMode, he as legacyFilterToFilter, x as listContainerDocuments, M as listContainers, qt as login, Ye as logout, N as makeColumn, Je as notify, Wt as onAuthEvent, st as openParentNodes, te as parseText, r as parseValueAndOperatorFromItem, dt as patch, an as patchUserProfile, Se as patchUserSettings, Ut as patchWithContext, R as post, V as postWithContext, Ft as put, Ie as putWithContext, Ze as queryParamsFromUrl, l as removeConcept, Yt as removeConcepts, $t as requestWebTokenSession, vt as resolveAggregationCount, Bt as resolveBearerToken, q as resolveNoAutoAuthentication, y as resolveNoAutoAuthenticationWithContext, yt as resolveOAuthProvider, Mt as resolveSAMLProvider, n as resolveToColumnName, c as resultPages, ie as rewriteText, Y as saveUserSettings, wt as searchPrincipals, Ce as setGlobalConfig, on as setToken, sn as sha512, it as suggestionsToTreeAggregationNodes, xt as sysLang, et as toDate, Nt as toSqlValue, L as translateAggregationToDateOptions, nn as tryAutoAuthentication, ct as tryOAuthAuthentication, W as trySAMLAuthentication, Ot as updateContainer, ft as warn, Rt as withRetry };
|
|
@@ -29,8 +29,8 @@ export declare function createApi(ctx: AtomicContext): {
|
|
|
29
29
|
}, signal?: AbortSignal | undefined) => Promise<import("..").SecurityPrincipalSearchResponse>;
|
|
30
30
|
};
|
|
31
31
|
query: {
|
|
32
|
-
search: (query: import("..").Query, audit?: import("..").AuditEvents | undefined, queryIntentData?: import("..").QueryIntentData | undefined) => Promise<import("..").Result>;
|
|
33
|
-
bulk: (queries: import("..").Query[], mode?: "parallel" | undefined, auditEvents?: import("..").AuditEvents | undefined) => Promise<import("..").Result[]>;
|
|
32
|
+
search: (query: import("..").Query, audit?: import("..").AuditEvents | undefined, queryIntentData?: import("..").QueryIntentData | undefined) => Promise<import("..").Result & import("..").ResultPages>;
|
|
33
|
+
bulk: (queries: import("..").Query[], mode?: "parallel" | undefined, auditEvents?: import("..").AuditEvents | undefined) => Promise<(import("..").Result & import("..").ResultPages)[]>;
|
|
34
34
|
intent: (query: import("..").Query) => Promise<import("..").QueryIntentMatch[]>;
|
|
35
35
|
export: (args_0: {
|
|
36
36
|
model: import("..").ExportQueryModel;
|
|
@@ -38,7 +38,7 @@ export declare function createApi(ctx: AtomicContext): {
|
|
|
38
38
|
query: import("..").Query;
|
|
39
39
|
article?: import("..").Article;
|
|
40
40
|
}) => Promise<Response>;
|
|
41
|
-
aggregate: (aggregation: import("..").Aggregation, query: import("..").Query, audit?: import("..").AuditEvents | undefined) => Promise<import("..").Aggregation>;
|
|
41
|
+
aggregate: (aggregation: import("..").Aggregation, query: import("..").Query, audit?: import("..").AuditEvents | undefined, count?: number | undefined) => Promise<import("..").Aggregation>;
|
|
42
42
|
sponsoredLinks: (webservice: string, query: import("..").Query) => Promise<import("..").LinkResult[]>;
|
|
43
43
|
similarDocuments: (documentId: string, queryName: string, signal?: AbortSignal | undefined) => Promise<import("..").Article[]>;
|
|
44
44
|
};
|
|
@@ -100,7 +100,7 @@ export declare function createApi(ctx: AtomicContext): {
|
|
|
100
100
|
};
|
|
101
101
|
password: {
|
|
102
102
|
change: (newPassword: string, currentPassword?: string | undefined) => Promise<import("..").ChangePasswordResponse>;
|
|
103
|
-
sendResetEmail: (userName: string) => Promise<import("..").PasswordResetEmailResponse>;
|
|
103
|
+
sendResetEmail: (userName: string, changePasswordRedirectUrl?: string | undefined) => Promise<import("..").PasswordResetEmailResponse>;
|
|
104
104
|
};
|
|
105
105
|
version: () => Promise<import("..").VersionResponse>;
|
|
106
106
|
};
|
|
@@ -43,8 +43,8 @@ export declare const AuthMode: {
|
|
|
43
43
|
* @param token - The Sinequa access token, sent as `Authorization: Bearer <token>`.
|
|
44
44
|
* @param options.sessionCookie - Whether to also open a **server session** by exchanging the token
|
|
45
45
|
* through `security.webtoken` (`tokenInCookie`). Defaults to `true`, and a server that refuses
|
|
46
|
-
* the exchange falls back to the header alone — see {@link AuthMode} and
|
|
47
|
-
*
|
|
46
|
+
* the exchange falls back to the header alone — see {@link AuthMode} and `docs/auth/bearer.mdx`.
|
|
47
|
+
* Pass `false` for a headless, server-to-server consumer:
|
|
48
48
|
* there is no browser to load anything on its own, so the roundtrip buys nothing.
|
|
49
49
|
*/
|
|
50
50
|
readonly bearer: (token: string, options?: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AggregationCounts } from "../helpers/aggregation-count";
|
|
2
|
+
import { type LogLevel } from "../utils/logger";
|
|
2
3
|
import { type AuthMode as AuthModeType } from "./auth-mode";
|
|
3
4
|
import type { AuthOptions } from "./auth-options";
|
|
4
5
|
/**
|
|
@@ -16,7 +17,6 @@ export type AppGlobalConfig<T extends Record<string, unknown> = {}> = {
|
|
|
16
17
|
autoOAuthProvider: string;
|
|
17
18
|
autoSAMLProvider: string;
|
|
18
19
|
bearerToken: string;
|
|
19
|
-
loginPath: string;
|
|
20
20
|
userOverride: {
|
|
21
21
|
username: string;
|
|
22
22
|
domain: string;
|
|
@@ -31,13 +31,44 @@ export type AppGlobalConfig<T extends Record<string, unknown> = {}> = {
|
|
|
31
31
|
* when not configured, so the server keeps applying its own default.
|
|
32
32
|
*/
|
|
33
33
|
uiLanguage: string;
|
|
34
|
+
/**
|
|
35
|
+
* The number of values the server returns per aggregation, keyed by aggregation name — the
|
|
36
|
+
* administrator's `CCAggregation.count`, which no query response repeats.
|
|
37
|
+
*
|
|
38
|
+
* Declare it (typically once at start-up, from `api.app.get()`) so `$hasMore` is computed against
|
|
39
|
+
* the real page size. Aggregations left out fall back to
|
|
40
|
+
* {@link DEFAULT_AGGREGATION_COUNT}. @see AggregationCounts
|
|
41
|
+
*/
|
|
42
|
+
aggregationCounts: AggregationCounts;
|
|
34
43
|
/** @deprecated Derived read-only getter computed from {@link authMode}. */
|
|
35
44
|
useCredentials: boolean;
|
|
36
45
|
/** @deprecated Derived read-only getter computed from {@link authMode}. */
|
|
37
46
|
useSSO: boolean;
|
|
38
47
|
/** @deprecated Derived read-only getter computed from {@link authMode}. */
|
|
39
48
|
useSAML: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Verbosity of the library logger, applied by {@link setGlobalConfig}.
|
|
51
|
+
*
|
|
52
|
+
* It used to be declared, defaulted, and read by nothing — so an application that set it got
|
|
53
|
+
* silence, and the comment here described a boolean ("when true, the application logs more
|
|
54
|
+
* information") for a value that was never one. `setGlobalConfig({ logLevel })` now forwards to
|
|
55
|
+
* `configureLogger({ level })`.
|
|
56
|
+
*
|
|
57
|
+
* A client created with `createAtomicClient` does **not** apply it: the library logger is
|
|
58
|
+
* process-wide, so a second client repointing it would silence the first. Inject `auth.logger`
|
|
59
|
+
* per client instead.
|
|
60
|
+
*/
|
|
40
61
|
logLevel: LogLevel;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Read by nothing in this library. Routing belongs to the application: react to the
|
|
64
|
+
* `unauthorized` event, or configure `auth.recoverFromUnauthorized`. It will stop being declared
|
|
65
|
+
* in the next major.
|
|
66
|
+
*/
|
|
67
|
+
loginPath: string;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Read by nothing in this library, and always has been. It will stop being declared in
|
|
70
|
+
* the next major.
|
|
71
|
+
*/
|
|
41
72
|
createRoutes: boolean;
|
|
42
73
|
} & T;
|
|
43
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.config.d.ts","sourceRoot":"","sources":["../../src/configurations/global.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"global.config.d.ts","sourceRoot":"","sources":["../../src/configurations/global.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAEL,KAAK,QAAQ,IAAI,YAAY,EAE9B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,IAAI;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,EAAE,YAAY,CAAC;IACvB,sGAAsG;IACtG,IAAI,EAAE,WAAW,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;OAOG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,MAAM,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB,GAAG,CAAC,CAAC;AAEN;;;;;;;;GAQG;AACH,QAAA,MAAM,YAAY,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAIpE,CAAC;AAsCF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACzD,IAAI,CASN;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1D,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACzD,IAAI,CAwBN;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Aggregation, Query } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Page size assumed for an aggregation when nothing declares one.
|
|
4
|
+
*
|
|
5
|
+
* It mirrors the value the Sinequa administration proposes for
|
|
6
|
+
* [CCAggregation.count]{@link CCAggregation#count}, and it is a **fallback, not a fact**: a query
|
|
7
|
+
* web service configured with another count answers exactly the same way, so there is nothing in the
|
|
8
|
+
* response that would let the client notice. Declare the real sizes with
|
|
9
|
+
* {@link AggregationCounts} to get `$hasMore` right on those aggregations.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_AGGREGATION_COUNT = 10;
|
|
12
|
+
/**
|
|
13
|
+
* The number of values the server returns per aggregation, keyed by aggregation name.
|
|
14
|
+
*
|
|
15
|
+
* This is the administrator's decision — [CCAggregation.count]{@link CCAggregation#count}, *the
|
|
16
|
+
* maximum number of values to retrieve* — and the query response does not repeat it. An application
|
|
17
|
+
* that reads the configuration once at start-up can hand it over, and the whole library then sizes
|
|
18
|
+
* `$hasMore` and aggregation paging against the real values:
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const app = await client.api.app.get();
|
|
23
|
+
* client.configure({
|
|
24
|
+
* aggregationCounts: Object.fromEntries(
|
|
25
|
+
* app.queries["_query"].aggregations.map((a) => [a.name, a.count]),
|
|
26
|
+
* ),
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export type AggregationCounts = Record<string, number>;
|
|
31
|
+
/**
|
|
32
|
+
* The number of values the server was asked for, for one aggregation.
|
|
33
|
+
*
|
|
34
|
+
* No field of the response carries it, so it is reconstructed from the most specific source
|
|
35
|
+
* available:
|
|
36
|
+
*
|
|
37
|
+
* 1. `query.aggregations[name].count` — what *this* call explicitly requested, as an
|
|
38
|
+
* `action: "aggregate"` page does;
|
|
39
|
+
* 2. `counts[name]` — what the application declared once from the app configuration
|
|
40
|
+
* (see {@link AggregationCounts});
|
|
41
|
+
* 3. {@link DEFAULT_AGGREGATION_COUNT}, when nothing is known.
|
|
42
|
+
*
|
|
43
|
+
* @param name - The name of the aggregation.
|
|
44
|
+
* @param query - The query the aggregation came back from, if any.
|
|
45
|
+
* @param counts - The declared page sizes, if any.
|
|
46
|
+
* @returns The count to compare the received items against.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveAggregationCount(name: string, query?: Pick<Query, "aggregations">, counts?: AggregationCounts): number;
|
|
49
|
+
/**
|
|
50
|
+
* Whether more values remain to be fetched for an aggregation.
|
|
51
|
+
*
|
|
52
|
+
* The response has no "total values" field. Instead, **when values remain the server returns one
|
|
53
|
+
* item beyond the `count` it was asked for**: ask for 10 and you receive 11, the eleventh being a
|
|
54
|
+
* sentinel that means "there is more". That extra item is the only signal available, so the test is
|
|
55
|
+
* `items.length > count` — and never an equality, which would only ever hold for one particular
|
|
56
|
+
* configured count and leave every other facet silently claiming it is complete.
|
|
57
|
+
*
|
|
58
|
+
* Distributions and trees always report `false`, deliberately: paging a bucket list, or a level of a
|
|
59
|
+
* hierarchy (`action: "open"`), is not the same operation as paging a flat list of values.
|
|
60
|
+
*
|
|
61
|
+
* @param aggregation - The aggregation returned by the server.
|
|
62
|
+
* @param count - The number of values that were requested. @see resolveAggregationCount
|
|
63
|
+
* @returns Whether the aggregation has more values on the server.
|
|
64
|
+
*/
|
|
65
|
+
export declare function aggregationHasMore(aggregation: Pick<Aggregation, "isDistribution" | "isTree"> & {
|
|
66
|
+
items?: Aggregation["items"];
|
|
67
|
+
}, count: number): boolean;
|
|
68
|
+
//# sourceMappingURL=aggregation-count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregation-count.d.ts","sourceRoot":"","sources":["../../src/helpers/aggregation-count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAoBvD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,cAAc,CAAC,EACnC,MAAM,CAAC,EAAE,iBAAiB,GACzB,MAAM,CAQR;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,gBAAgB,GAAG,QAAQ,CAAC,GAAG;IAC5D,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC9B,EACD,KAAK,EAAE,MAAM,GACZ,OAAO,CAKT"}
|