@sinequa/atomic 1.0.1 → 1.1.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 +219 -219
- package/dist/atomic.js +372 -361
- package/dist/atomic.umd.cjs +1 -1
- package/dist/authentication/index.d.ts +1 -1
- package/dist/authentication/index.d.ts.map +1 -1
- package/dist/authentication/session/index.d.ts +1 -1
- package/dist/authentication/session/index.d.ts.map +1 -1
- package/dist/authentication/session/logout.d.ts +7 -3
- package/dist/authentication/session/logout.d.ts.map +1 -1
- package/dist/authentication/tokens/delete-web-token-cookie.d.ts +1 -0
- package/dist/authentication/tokens/delete-web-token-cookie.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,219 +1,219 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
import {
|
|
121
|
-
getMetadata,
|
|
122
|
-
getMetadataWithValues,
|
|
123
|
-
makeColumn,
|
|
124
|
-
resolveToColumnName,
|
|
125
|
-
escapeExpr,
|
|
126
|
-
guid,
|
|
127
|
-
isObject,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
[
|
|
218
|
-
|
|
219
|
-
</div>
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
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-5.x-3178c6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" />
|
|
5
|
+
<img src="https://img.shields.io/badge/ESM-ready-f59e0b?style=for-the-badge" alt="ESM" />
|
|
6
|
+
<img src="https://img.shields.io/npm/l/@sinequa/atomic?style=for-the-badge&color=22c55e" alt="MIT License" />
|
|
7
|
+
|
|
8
|
+
<br /><br />
|
|
9
|
+
|
|
10
|
+
# `@sinequa/atomic`
|
|
11
|
+
|
|
12
|
+
**The TypeScript-first SDK for the Sinequa REST API.**
|
|
13
|
+
Authentication, search, aggregations, datasets, preview — everything typed, tree-shakable, zero runtime dependencies.
|
|
14
|
+
|
|
15
|
+
[Docs](https://sinequa.github.io/sba-mint/atomic/intro) · [API Reference](https://sinequa.github.io/sba-mint/atomic/api/app)
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @sinequa/atomic
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> Requires **Node ≥ 18** or any modern browser. Ships as ESM (`atomic.js`) and CJS (`atomic.umd.cjs`) with full `.d.ts` declarations.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## At a glance
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { login, isAuthenticated, fetchQuery, fetchAggregation } from '@sinequa/atomic';
|
|
35
|
+
|
|
36
|
+
if (!isAuthenticated()) {
|
|
37
|
+
await login({ username: 'alice', password: 's3cr3t' });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const results = await fetchQuery({ query: 'knowledge management', pageSize: 10 });
|
|
41
|
+
const facets = await fetchAggregation({ aggregation: 'company', query: 'knowledge management' });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Modules
|
|
47
|
+
|
|
48
|
+
### Authentication
|
|
49
|
+
|
|
50
|
+
Full auth lifecycle — from first handshake to logout.
|
|
51
|
+
|
|
52
|
+
| Export | Description |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `isAuthenticated()` | Returns `true` when a valid token is present |
|
|
55
|
+
| `login(credentials?)` | Login — handles OAuth, SAML and credential flows automatically |
|
|
56
|
+
| `logout()` | Clears session, returns the server's `redirectUrl` |
|
|
57
|
+
| `getToken()` / `setToken(token)` | Read/write the stored CSRF token |
|
|
58
|
+
| `getJWToken(credentials?)` | Fetches a JWT from the server, returns the CSRF token |
|
|
59
|
+
| `getCsrfToken()` | CSRF token for mutating requests |
|
|
60
|
+
| `deleteWebTokenCookie()` | Explicitly removes the web token cookie |
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { isAuthenticated, login, logout } from '@sinequa/atomic';
|
|
64
|
+
|
|
65
|
+
if (!isAuthenticated()) {
|
|
66
|
+
// SSO (OAuth/SAML) — provider resolved from server config
|
|
67
|
+
const ok = await login();
|
|
68
|
+
|
|
69
|
+
// — or — credential-based login, bypasses SSO
|
|
70
|
+
const ok = await login({ username: 'alice', password: 's3cr3t' });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const redirectUrl = await logout();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### Web API — v1
|
|
79
|
+
|
|
80
|
+
Every Sinequa v1 endpoint has a typed wrapper.
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import {
|
|
84
|
+
fetchApp,
|
|
85
|
+
fetchQuery,
|
|
86
|
+
fetchAggregation,
|
|
87
|
+
fetchDataset,
|
|
88
|
+
fetchPreview,
|
|
89
|
+
fetchPrincipal,
|
|
90
|
+
fetchSimilarDocuments,
|
|
91
|
+
fetchSponsoredLinks,
|
|
92
|
+
fetchSuggest,
|
|
93
|
+
fetchTextChunk,
|
|
94
|
+
fetchUserSettings,
|
|
95
|
+
fetchAudit,
|
|
96
|
+
fetchLabels,
|
|
97
|
+
fetchQueryExport,
|
|
98
|
+
fetchQueryIntent,
|
|
99
|
+
} from '@sinequa/atomic';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Web API — v2
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import {
|
|
106
|
+
fetchUserProfile,
|
|
107
|
+
fetchVersion,
|
|
108
|
+
fetchChangePassword,
|
|
109
|
+
fetchForgotPassword,
|
|
110
|
+
} from '@sinequa/atomic';
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### Helpers
|
|
116
|
+
|
|
117
|
+
Utilities for transforming Sinequa data structures.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import {
|
|
121
|
+
getMetadata,
|
|
122
|
+
getMetadataWithValues, // parses comma-separated metadata strings
|
|
123
|
+
makeColumn,
|
|
124
|
+
resolveToColumnName,
|
|
125
|
+
escapeExpr,
|
|
126
|
+
guid,
|
|
127
|
+
isObject,
|
|
128
|
+
} from '@sinequa/atomic';
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### Utilities
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import {
|
|
137
|
+
bisect,
|
|
138
|
+
formatDate,
|
|
139
|
+
parseDate,
|
|
140
|
+
logger,
|
|
141
|
+
queryParamsToString,
|
|
142
|
+
toSQL,
|
|
143
|
+
syslang,
|
|
144
|
+
} from '@sinequa/atomic';
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Types
|
|
150
|
+
|
|
151
|
+
The package re-exports every Sinequa domain type so you never need to cast:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import type {
|
|
155
|
+
CCApp, CCQuery, CCColumn, CCIndex,
|
|
156
|
+
Aggregation, AggregationItem, ListAggregation, TreeAggregation,
|
|
157
|
+
Filter, SimpleFilter, InFilter, BetweenFilter,
|
|
158
|
+
PreviewData,
|
|
159
|
+
Principal,
|
|
160
|
+
AuditEvent, AuditRecord,
|
|
161
|
+
TextChunk,
|
|
162
|
+
} from '@sinequa/atomic';
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Configuration
|
|
168
|
+
|
|
169
|
+
Set a base URL before making any API call (required when the Sinequa server is not same-origin):
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { setConfig } from '@sinequa/atomic';
|
|
173
|
+
|
|
174
|
+
setConfig({ url: 'https://my-sinequa-server.example.com' });
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Testing
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npm test # run vitest (560+ test cases)
|
|
183
|
+
npm test -- --ui # interactive UI
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Coverage spans authentication flows (OAuth, SAML, credentials), all API endpoints, error handling, metadata parsing, date utilities, and SQL helpers.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Development
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm run build # production build (vite + tsc)
|
|
194
|
+
npm run watch # rebuild on change
|
|
195
|
+
npm run dev:pack # build + pack locally
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
1. All tests must pass.
|
|
203
|
+
2. Lint with [Biome](https://biomejs.dev/) — `npx @biomejs/biome check --write .`
|
|
204
|
+
3. Follow [Conventional Commits](https://www.conventionalcommits.org/).
|
|
205
|
+
4. New public API → add tests + JSDoc.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
MIT — see [LICENSE](./LICENSE).
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
<div align="center">
|
|
216
|
+
|
|
217
|
+
Built for the [Sinequa](https://www.sinequa.com/) ecosystem · [Report an issue](https://github.com/Product/sba-atomic-js/issues)
|
|
218
|
+
|
|
219
|
+
</div>
|