@sinequa/atomic 2.1.0 → 2.3.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.
Files changed (186) hide show
  1. package/README.md +28 -1
  2. package/dist/atomic.cjs +1 -1
  3. package/dist/atomic.js +2 -2
  4. package/dist/authentication/constants.d.ts +20 -0
  5. package/dist/authentication/constants.d.ts.map +1 -1
  6. package/dist/authentication/events/auth-events.d.ts +71 -0
  7. package/dist/authentication/events/auth-events.d.ts.map +1 -0
  8. package/dist/authentication/events/emit-authenticated-event.d.ts +9 -0
  9. package/dist/authentication/events/emit-authenticated-event.d.ts.map +1 -1
  10. package/dist/authentication/events/index.d.ts +1 -0
  11. package/dist/authentication/events/index.d.ts.map +1 -1
  12. package/dist/authentication/index.d.ts +3 -3
  13. package/dist/authentication/index.d.ts.map +1 -1
  14. package/dist/authentication/providers/oauth-authentication.d.ts +10 -1
  15. package/dist/authentication/providers/oauth-authentication.d.ts.map +1 -1
  16. package/dist/authentication/providers/redirect-to-identity-provider.d.ts +34 -0
  17. package/dist/authentication/providers/redirect-to-identity-provider.d.ts.map +1 -0
  18. package/dist/authentication/providers/saml-authentication.d.ts +10 -1
  19. package/dist/authentication/providers/saml-authentication.d.ts.map +1 -1
  20. package/dist/authentication/session/auth-mode-marker.d.ts +7 -0
  21. package/dist/authentication/session/auth-mode-marker.d.ts.map +1 -1
  22. package/dist/authentication/session/auth-state.d.ts +6 -1
  23. package/dist/authentication/session/auth-state.d.ts.map +1 -1
  24. package/dist/authentication/session/detect-auth-mode.d.ts +2 -1
  25. package/dist/authentication/session/detect-auth-mode.d.ts.map +1 -1
  26. package/dist/authentication/session/has-session.d.ts +26 -0
  27. package/dist/authentication/session/has-session.d.ts.map +1 -0
  28. package/dist/authentication/session/index.d.ts +2 -0
  29. package/dist/authentication/session/index.d.ts.map +1 -1
  30. package/dist/authentication/session/login.d.ts +12 -7
  31. package/dist/authentication/session/login.d.ts.map +1 -1
  32. package/dist/authentication/session/logout.d.ts +13 -2
  33. package/dist/authentication/session/logout.d.ts.map +1 -1
  34. package/dist/authentication/session/redirect-guard.d.ts +18 -0
  35. package/dist/authentication/session/redirect-guard.d.ts.map +1 -0
  36. package/dist/authentication/session/try-auto-authentication.d.ts +5 -2
  37. package/dist/authentication/session/try-auto-authentication.d.ts.map +1 -1
  38. package/dist/authentication/session/user-authentication.d.ts +7 -2
  39. package/dist/authentication/session/user-authentication.d.ts.map +1 -1
  40. package/dist/authentication/tokens/delete-web-token-cookie.d.ts +10 -5
  41. package/dist/authentication/tokens/delete-web-token-cookie.d.ts.map +1 -1
  42. package/dist/authentication/tokens/get-csrf-token.d.ts +4 -1
  43. package/dist/authentication/tokens/get-csrf-token.d.ts.map +1 -1
  44. package/dist/authentication/tokens/get-jwt-token.d.ts +29 -5
  45. package/dist/authentication/tokens/get-jwt-token.d.ts.map +1 -1
  46. package/dist/authentication/tokens/get-token.d.ts +7 -1
  47. package/dist/authentication/tokens/get-token.d.ts.map +1 -1
  48. package/dist/authentication/tokens/index.d.ts +1 -1
  49. package/dist/authentication/tokens/index.d.ts.map +1 -1
  50. package/dist/authentication/tokens/set-token.d.ts +7 -1
  51. package/dist/authentication/tokens/set-token.d.ts.map +1 -1
  52. package/dist/client/atomic-context.d.ts +61 -0
  53. package/dist/client/atomic-context.d.ts.map +1 -0
  54. package/dist/client/create-api.d.ts +109 -0
  55. package/dist/client/create-api.d.ts.map +1 -0
  56. package/dist/client/create-atomic-client.d.ts +138 -0
  57. package/dist/client/create-atomic-client.d.ts.map +1 -0
  58. package/dist/client/http-adapter.d.ts +30 -0
  59. package/dist/client/http-adapter.d.ts.map +1 -0
  60. package/dist/client/index.d.ts +5 -0
  61. package/dist/client/index.d.ts.map +1 -0
  62. package/dist/configurations/auth-mode.d.ts +51 -1
  63. package/dist/configurations/auth-mode.d.ts.map +1 -1
  64. package/dist/configurations/auth-options.d.ts +78 -0
  65. package/dist/configurations/auth-options.d.ts.map +1 -0
  66. package/dist/configurations/global.config.d.ts +23 -3
  67. package/dist/configurations/global.config.d.ts.map +1 -1
  68. package/dist/configurations/index.d.ts +1 -0
  69. package/dist/configurations/index.d.ts.map +1 -1
  70. package/dist/helpers/filters.d.ts +24 -0
  71. package/dist/helpers/filters.d.ts.map +1 -1
  72. package/dist/helpers/index.d.ts +1 -0
  73. package/dist/helpers/index.d.ts.map +1 -1
  74. package/dist/helpers/pagination.d.ts +23 -0
  75. package/dist/helpers/pagination.d.ts.map +1 -0
  76. package/dist/helpers/ts-helper.d.ts +6 -0
  77. package/dist/helpers/ts-helper.d.ts.map +1 -1
  78. package/dist/index.d.ts +1 -0
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/polyfills/storage.d.ts +12 -3
  81. package/dist/polyfills/storage.d.ts.map +1 -1
  82. package/dist/spfx/index.cjs +1 -1
  83. package/dist/spfx/index.d.ts +1 -0
  84. package/dist/spfx/index.d.ts.map +1 -1
  85. package/dist/spfx/index.js +2 -2
  86. package/dist/src-1RUu1uXc.cjs +1 -0
  87. package/dist/src-DFuZeDvd.js +2198 -0
  88. package/dist/types/api-endpoints.d.ts +1 -1
  89. package/dist/types/api-endpoints.d.ts.map +1 -1
  90. package/dist/types/document-upload/container-document.d.ts +22 -0
  91. package/dist/types/document-upload/container-document.d.ts.map +1 -0
  92. package/dist/types/document-upload/container.d.ts +31 -0
  93. package/dist/types/document-upload/container.d.ts.map +1 -0
  94. package/dist/types/document-upload/index.d.ts +3 -0
  95. package/dist/types/document-upload/index.d.ts.map +1 -0
  96. package/dist/types/index.d.ts +2 -0
  97. package/dist/types/index.d.ts.map +1 -1
  98. package/dist/types/search/Result.d.ts +36 -2
  99. package/dist/types/search/Result.d.ts.map +1 -1
  100. package/dist/types/search/index.d.ts +1 -1
  101. package/dist/types/search/index.d.ts.map +1 -1
  102. package/dist/types/security-principal/index.d.ts +2 -0
  103. package/dist/types/security-principal/index.d.ts.map +1 -0
  104. package/dist/types/security-principal/security-principal.d.ts +25 -0
  105. package/dist/types/security-principal/security-principal.d.ts.map +1 -0
  106. package/dist/utils/logger.d.ts +27 -16
  107. package/dist/utils/logger.d.ts.map +1 -1
  108. package/dist/web-api/helpers/aad-http-client-manager.d.ts +8 -0
  109. package/dist/web-api/helpers/aad-http-client-manager.d.ts.map +1 -1
  110. package/dist/web-api/helpers/create-headers.d.ts +9 -0
  111. package/dist/web-api/helpers/create-headers.d.ts.map +1 -1
  112. package/dist/web-api/helpers/errors/api-error.d.ts.map +1 -1
  113. package/dist/web-api/helpers/handle-response.d.ts +17 -1
  114. package/dist/web-api/helpers/handle-response.d.ts.map +1 -1
  115. package/dist/web-api/helpers/index.d.ts +1 -1
  116. package/dist/web-api/helpers/index.d.ts.map +1 -1
  117. package/dist/web-api/helpers/methods/del.d.ts +13 -11
  118. package/dist/web-api/helpers/methods/del.d.ts.map +1 -1
  119. package/dist/web-api/helpers/methods/get.d.ts +6 -12
  120. package/dist/web-api/helpers/methods/get.d.ts.map +1 -1
  121. package/dist/web-api/helpers/methods/patch.d.ts +6 -7
  122. package/dist/web-api/helpers/methods/patch.d.ts.map +1 -1
  123. package/dist/web-api/helpers/methods/post.d.ts +6 -8
  124. package/dist/web-api/helpers/methods/post.d.ts.map +1 -1
  125. package/dist/web-api/helpers/methods/put.d.ts +6 -7
  126. package/dist/web-api/helpers/methods/put.d.ts.map +1 -1
  127. package/dist/web-api/helpers/methods/send-request.d.ts +24 -0
  128. package/dist/web-api/helpers/methods/send-request.d.ts.map +1 -0
  129. package/dist/web-api/helpers/request-options.d.ts +35 -12
  130. package/dist/web-api/helpers/request-options.d.ts.map +1 -1
  131. package/dist/web-api/helpers/utils/build-request-url.d.ts +12 -0
  132. package/dist/web-api/helpers/utils/build-request-url.d.ts.map +1 -0
  133. package/dist/web-api/helpers/utils/{date-utils..d.ts → date-utils.d.ts} +1 -1
  134. package/dist/web-api/helpers/utils/date-utils.d.ts.map +1 -0
  135. package/dist/web-api/helpers/utils/resolve-no-auto-authentication.d.ts +9 -0
  136. package/dist/web-api/helpers/utils/resolve-no-auto-authentication.d.ts.map +1 -1
  137. package/dist/web-api/helpers/utils/with-retry.d.ts +10 -5
  138. package/dist/web-api/helpers/utils/with-retry.d.ts.map +1 -1
  139. package/dist/web-api/index.d.ts +2 -0
  140. package/dist/web-api/index.d.ts.map +1 -1
  141. package/dist/web-api/v1/fetch-aggregation.d.ts +2 -1
  142. package/dist/web-api/v1/fetch-aggregation.d.ts.map +1 -1
  143. package/dist/web-api/v1/fetch-app.d.ts +12 -5
  144. package/dist/web-api/v1/fetch-app.d.ts.map +1 -1
  145. package/dist/web-api/v1/fetch-audit.d.ts +2 -1
  146. package/dist/web-api/v1/fetch-audit.d.ts.map +1 -1
  147. package/dist/web-api/v1/fetch-dataset.d.ts +4 -3
  148. package/dist/web-api/v1/fetch-dataset.d.ts.map +1 -1
  149. package/dist/web-api/v1/fetch-labels.d.ts +9 -8
  150. package/dist/web-api/v1/fetch-labels.d.ts.map +1 -1
  151. package/dist/web-api/v1/fetch-preview.d.ts +2 -1
  152. package/dist/web-api/v1/fetch-preview.d.ts.map +1 -1
  153. package/dist/web-api/v1/fetch-principal.d.ts +8 -4
  154. package/dist/web-api/v1/fetch-principal.d.ts.map +1 -1
  155. package/dist/web-api/v1/fetch-query-export.d.ts +2 -1
  156. package/dist/web-api/v1/fetch-query-export.d.ts.map +1 -1
  157. package/dist/web-api/v1/fetch-query-intent.d.ts +2 -1
  158. package/dist/web-api/v1/fetch-query-intent.d.ts.map +1 -1
  159. package/dist/web-api/v1/fetch-query.d.ts +3 -2
  160. package/dist/web-api/v1/fetch-query.d.ts.map +1 -1
  161. package/dist/web-api/v1/fetch-security-principal.d.ts +23 -0
  162. package/dist/web-api/v1/fetch-security-principal.d.ts.map +1 -0
  163. package/dist/web-api/v1/fetch-similar-documents.d.ts +2 -1
  164. package/dist/web-api/v1/fetch-similar-documents.d.ts.map +1 -1
  165. package/dist/web-api/v1/fetch-sponsored-links.d.ts +2 -1
  166. package/dist/web-api/v1/fetch-sponsored-links.d.ts.map +1 -1
  167. package/dist/web-api/v1/fetch-suggest.d.ts +4 -3
  168. package/dist/web-api/v1/fetch-suggest.d.ts.map +1 -1
  169. package/dist/web-api/v1/fetch-text-chunk.d.ts +2 -1
  170. package/dist/web-api/v1/fetch-text-chunk.d.ts.map +1 -1
  171. package/dist/web-api/v1/fetch-user-settings.d.ts +5 -4
  172. package/dist/web-api/v1/fetch-user-settings.d.ts.map +1 -1
  173. package/dist/web-api/v2/fetch-change-password.d.ts +2 -1
  174. package/dist/web-api/v2/fetch-change-password.d.ts.map +1 -1
  175. package/dist/web-api/v2/fetch-document-upload-container.d.ts +83 -0
  176. package/dist/web-api/v2/fetch-document-upload-container.d.ts.map +1 -0
  177. package/dist/web-api/v2/fetch-forgot-password.d.ts +2 -1
  178. package/dist/web-api/v2/fetch-forgot-password.d.ts.map +1 -1
  179. package/dist/web-api/v2/fetch-user-profile.d.ts +5 -4
  180. package/dist/web-api/v2/fetch-user-profile.d.ts.map +1 -1
  181. package/dist/web-api/v2/fetch-version.d.ts +2 -1
  182. package/dist/web-api/v2/fetch-version.d.ts.map +1 -1
  183. package/package.json +10 -7
  184. package/dist/src-C3yJArxW.js +0 -1886
  185. package/dist/src-CGNARSYI.cjs +0 -1
  186. package/dist/web-api/helpers/utils/date-utils..d.ts.map +0 -1
@@ -1,1886 +0,0 @@
1
- //#region src/authentication/events/emit-authenticated-event.ts
2
- function e(e) {
3
- if (typeof CustomEvent > "u" || typeof dispatchEvent > "u") return;
4
- let t = new CustomEvent("authenticated", {
5
- bubbles: !0,
6
- cancelable: !1,
7
- detail: { authenticated: e }
8
- });
9
- dispatchEvent(t);
10
- }
11
- //#endregion
12
- //#region src/configurations/auth-mode.ts
13
- var t = {
14
- credentials: () => ({ kind: "credentials" }),
15
- sso: () => ({ kind: "sso" }),
16
- oauth: (e) => ({
17
- kind: "oauth",
18
- provider: e
19
- }),
20
- saml: (e) => ({
21
- kind: "saml",
22
- provider: e
23
- }),
24
- bearer: (e) => ({
25
- kind: "bearer",
26
- token: e
27
- }),
28
- unknown: () => ({ kind: "unknown" })
29
- };
30
- function n(e, n) {
31
- let { useCredentials: r, useSSO: i, useSAML: a } = e;
32
- return a && n.autoSAMLProvider ? t.saml(n.autoSAMLProvider) : r && i ? t.unknown() : r ? t.credentials() : i ? t.sso() : n.authMode ?? t.unknown();
33
- }
34
- //#endregion
35
- //#region src/configurations/global.config.ts
36
- var r = {
37
- loginPath: "/login",
38
- createRoutes: !1,
39
- authMode: t.unknown()
40
- };
41
- Object.defineProperties(r, {
42
- useCredentials: {
43
- enumerable: !1,
44
- configurable: !0,
45
- get() {
46
- let e = r.authMode?.kind;
47
- return e === "credentials" || e === "unknown";
48
- }
49
- },
50
- useSSO: {
51
- enumerable: !1,
52
- configurable: !0,
53
- get() {
54
- let e = r.authMode?.kind;
55
- return e === "sso" || e === "unknown";
56
- }
57
- },
58
- useSAML: {
59
- enumerable: !1,
60
- configurable: !0,
61
- get() {
62
- return r.authMode?.kind === "saml";
63
- }
64
- }
65
- });
66
- function i(e) {
67
- let { useCredentials: t, useSSO: i, useSAML: a, authMode: o, ...s } = e;
68
- if (Object.assign(r, s), o !== void 0) {
69
- r.authMode = o;
70
- return;
71
- }
72
- (t !== void 0 || i !== void 0 || a !== void 0) && (r.authMode = n({
73
- useCredentials: t,
74
- useSSO: i,
75
- useSAML: a
76
- }, r));
77
- }
78
- //#endregion
79
- //#region src/polyfills/storage.ts
80
- var a = {
81
- store: {},
82
- getItem(e) {
83
- return this.store[e] ?? null;
84
- },
85
- setItem(e, t) {
86
- this.store[e] = t.toString();
87
- },
88
- removeItem(e) {
89
- delete this.store[e];
90
- },
91
- clear() {
92
- this.store = {};
93
- }
94
- }, o = a;
95
- function s(e) {
96
- return typeof window > "u" || !window.localStorage ? a.getItem(e) : window.localStorage.getItem(e);
97
- }
98
- function c(e, t) {
99
- typeof window > "u" || !window.localStorage ? a.setItem(e, t) : window.localStorage.setItem(e, t);
100
- }
101
- function l(e) {
102
- typeof window > "u" || !window.localStorage ? a.removeItem(e) : window.localStorage.removeItem(e);
103
- }
104
- function u(e) {
105
- return typeof window > "u" || !window.sessionStorage ? o.getItem(e) : window.sessionStorage.getItem(e);
106
- }
107
- function d(e, t) {
108
- typeof window > "u" || !window.sessionStorage ? o.setItem(e, t) : window.sessionStorage.setItem(e, t);
109
- }
110
- function f(e) {
111
- typeof window > "u" || !window.sessionStorage ? o.removeItem(e) : window.sessionStorage.removeItem(e);
112
- }
113
- //#endregion
114
- //#region src/utils/aggregations.ts
115
- var ee = /.*:\(?([><=\d\-.AND ]+)\)?/;
116
- function te(e, t) {
117
- return !e?.items || e?.items?.length === 0 ? [] : e.items.reduce((n, r) => {
118
- if (!r.value || r.value === "") return n;
119
- let i = ne(r, e.column);
120
- return n.push({
121
- operator: i.operator,
122
- value: i.value,
123
- display: r.display || i.display,
124
- filters: i.filters,
125
- disabled: r.count === 0,
126
- hidden: r.count === 0 && e.isDistribution ? !t : !1
127
- }), n;
128
- }, []);
129
- }
130
- function ne(e, t) {
131
- let n = t, r = e.value.match(ee);
132
- if (r?.[1]) {
133
- let t = (r?.[1].split(" AND ")).map((t) => ({
134
- field: n,
135
- operator: t.indexOf(">=") === -1 ? "lt" : "gte",
136
- value: t.substring(t.indexOf(" ") + 1),
137
- display: e.display || e.value
138
- }));
139
- if (t.length === 2) return {
140
- field: n,
141
- operator: "and",
142
- filters: t,
143
- value: e.value,
144
- display: t[0].display || t[0].value
145
- };
146
- if (t.length === 1) return {
147
- ...t[0],
148
- field: n
149
- };
150
- throw Error("Failed to parse distribution expression");
151
- }
152
- return {
153
- field: n,
154
- operator: "eq",
155
- value: e.value,
156
- display: e.display
157
- };
158
- }
159
- function re(e, t, n) {
160
- return e.valuesAreExpressions ? t.display === n.display : t.value === n.value;
161
- }
162
- function ie(e) {
163
- return e.items &&= e.items.map((e) => ie(e)), e.items?.some((e) => e.$selected || e.$opened) && (e.$opened = !0), e;
164
- }
165
- function ae(e, t) {
166
- let n = [];
167
- if (e.length > 0) {
168
- let r = /* @__PURE__ */ new Map(), i = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").normalize("NFD").replace(/[\u0300-\u036f]/g, ""), a = RegExp(`\\b${i}`, "i");
169
- e.forEach((e) => {
170
- if (e.display.length > 1) {
171
- let i = e.display.normalize("NFD").replace(/[\u0300-\u036f]/g, ""), o = a.exec(i);
172
- oe(n, r, "/", e.display, +(e.frequency || 0), 1, (o?.index || 0) + t.length);
173
- }
174
- });
175
- }
176
- return n;
177
- }
178
- function oe(e, t, n, r, i, a, o) {
179
- let s = r.indexOf("/", n.length), c = r.substring(0, s + 1), l = t.get(c);
180
- if (!l) {
181
- let u = c.replace(/^\/|\/$/g, "");
182
- l = {
183
- value: r.substring(n.length, s),
184
- count: i,
185
- items: [],
186
- hasChildren: !1,
187
- $level: a,
188
- $opened: o >= c.length,
189
- $path: u
190
- }, t.set(c, l), e.push(l);
191
- }
192
- c.length < r.length && (l.hasChildren = !0, oe(l.items, t, c, r, i, a + 1, o));
193
- }
194
- //#endregion
195
- //#region src/utils/bisect.ts
196
- function se(e, t) {
197
- return e.reduce((e, n) => (t(n) ? e.true.push(n) : e.false.push(n), e), {
198
- true: [],
199
- false: []
200
- });
201
- }
202
- //#endregion
203
- //#region src/utils/concepts.ts
204
- var ce = /(([+-])?\(([^)]+)\))|(([+-])?\[([^\]]+)\])|(([+-])?"([^"]+)")|(([+-])?\/([^/]+)\/)|(([+-])?(\S+))/g, le = 2, ue = 3, de = 5, fe = 6, pe = 8, me = 9, he = 11, ge = 12, _e = 14, ve = 15;
205
- function p(e) {
206
- if (!e) return [];
207
- let t = [], n = e.matchAll(ce);
208
- for (let e of n) e[ue] ? t.push({
209
- type: "group",
210
- value: e[ue],
211
- op: e[le]
212
- }) : e[fe] ? t.push({
213
- type: "adjacent",
214
- value: e[fe],
215
- op: e[de]
216
- }) : e[me] ? t.push({
217
- type: "exact",
218
- value: e[me],
219
- op: e[pe]
220
- }) : e[ge] ? t.push({
221
- type: "regex",
222
- value: e[ge],
223
- op: e[he]
224
- }) : e[ve] && t.push({
225
- type: "token",
226
- value: e[ve],
227
- op: e[_e]
228
- });
229
- return t;
230
- }
231
- function m(e) {
232
- return e.map((e) => {
233
- let t = e.op || "";
234
- switch (e.type) {
235
- case "group": return `${t}(${e.value})`;
236
- case "adjacent": return `${t}[${e.value}]`;
237
- case "exact": return `${t}"${e.value}"`;
238
- case "regex": return `${t}/${e.value}/`;
239
- case "token": return `${t}${e.value}`;
240
- default: return "";
241
- }
242
- }).join(" ");
243
- }
244
- function ye(e, t, n) {
245
- let r = p(e);
246
- for (let e of t) r.push({
247
- type: "adjacent",
248
- value: e,
249
- op: n
250
- });
251
- return m(r);
252
- }
253
- function be(e, t) {
254
- let n = p(t), r = n.findIndex((t) => t.value === e);
255
- return r === -1 ? t : (n.splice(r, 1), m(n));
256
- }
257
- function xe(e) {
258
- return m(p(e).filter((e) => e.type !== "adjacent"));
259
- }
260
- function Se(e) {
261
- return p(e).filter((e) => e.type === "adjacent").map((e) => e.value);
262
- }
263
- //#endregion
264
- //#region src/utils/date.ts
265
- function Ce(e, t, n) {
266
- let r = new Intl.RelativeTimeFormat(e, { numeric: "auto" }), { offset: i, unit: a, isFuture: o } = we(t, n);
267
- return r.format(i * (o ? 1 : -1), a);
268
- }
269
- function we(e, t) {
270
- let n = new Date(e), r = t ? new Date(t) : /* @__PURE__ */ new Date(), i = Math.abs(r.getTime() - n.getTime());
271
- return {
272
- offset: Math.floor(i / (1e3 * 60 * 60 * 24)),
273
- unit: "day",
274
- isFuture: n > r
275
- };
276
- }
277
- //#endregion
278
- //#region src/utils/is-not-input-event.ts
279
- function Te(e) {
280
- let t = e.target;
281
- return t && t.nodeName !== "INPUT" && t.nodeName !== "TEXTAREA";
282
- }
283
- //#endregion
284
- //#region src/utils/logger.ts
285
- var Ee = /* @__PURE__ */ function(e) {
286
- return e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e;
287
- }({}), h = {
288
- level: 1,
289
- enableConsoleOutput: !0
290
- };
291
- function De(e) {
292
- h = {
293
- ...h,
294
- ...e
295
- };
296
- }
297
- function g(e, t, n) {
298
- if (e < h.level) return;
299
- let r = `${`[${Ee[e]}]`} ${t}`;
300
- if (h.enableConsoleOutput) switch (e) {
301
- case 0:
302
- console.debug(r, n || "");
303
- break;
304
- case 1:
305
- console.info(r, n || "");
306
- break;
307
- case 2:
308
- console.warn(r, n || "");
309
- break;
310
- case 3:
311
- console.error(r, n || "");
312
- break;
313
- }
314
- }
315
- function _(e, t) {
316
- g(0, e, t);
317
- }
318
- function v(e, t) {
319
- g(1, e, t);
320
- }
321
- function y(e, t) {
322
- g(2, e, t);
323
- }
324
- function b(e, t) {
325
- g(3, e, t);
326
- }
327
- //#endregion
328
- //#region src/utils/notification.ts
329
- function x(e) {
330
- let t = new CustomEvent("notification", {
331
- bubbles: !0,
332
- cancelable: !1,
333
- detail: e
334
- });
335
- dispatchEvent(t);
336
- }
337
- var Oe = {
338
- success: (e, t) => {
339
- x({
340
- type: "success",
341
- message: e,
342
- options: t
343
- });
344
- },
345
- info: (e, t) => {
346
- x({
347
- type: "info",
348
- message: e,
349
- options: t
350
- });
351
- },
352
- warning: (e, t) => {
353
- x({
354
- type: "warning",
355
- message: e,
356
- options: t
357
- });
358
- },
359
- error: (e, t) => {
360
- x({
361
- type: "error",
362
- message: e,
363
- options: t
364
- });
365
- }
366
- };
367
- //#endregion
368
- //#region src/utils/query-params.ts
369
- function ke(e) {
370
- if (e === void 0) return;
371
- let { q: t, f: n, p: r, s: i, t: a, n: o, b: s } = C(e), [c] = e.split("?");
372
- return {
373
- path: c,
374
- text: t,
375
- filters: n ? S(n) : void 0,
376
- page: r ? parseInt(r, 10) : void 0,
377
- sort: i,
378
- tab: a,
379
- name: o,
380
- basket: s
381
- };
382
- }
383
- function Ae(e) {
384
- if (!e) return "";
385
- let { text: t, filters: n, page: r, sort: i, tab: a, name: o, basket: s } = e, c = {};
386
- return t && (c.q = t), n && (c.f = JSON.stringify(n)), r && (c.p = r.toString()), i && (c.s = i), a && (c.t = a), o && (c.n = o), s && (c.b = s), new URLSearchParams(c).toString() || "";
387
- }
388
- function je(e) {
389
- if (e === void 0) return [];
390
- let { f: t } = C(e);
391
- return S(t);
392
- }
393
- function S(e) {
394
- let t = decodeURIComponent(e);
395
- try {
396
- return JSON.parse(t ?? "[]");
397
- } catch {
398
- return console.error(`Error parsing filters from URI: ${e}`), [];
399
- }
400
- }
401
- function C(e) {
402
- let t = e.split("?")[1];
403
- if (t === void 0) return {};
404
- let n = new URLSearchParams(t);
405
- return Object.fromEntries(n);
406
- }
407
- function Me(e) {
408
- let { q: t = "" } = C(e);
409
- return t;
410
- }
411
- function Ne(e) {
412
- let { id: t } = C(e);
413
- return decodeURIComponent(t);
414
- }
415
- function Pe(e) {
416
- let { p: t = "0" } = C(e);
417
- return parseInt(t, 10);
418
- }
419
- function Fe(e) {
420
- let { t } = C(e);
421
- return t;
422
- }
423
- //#endregion
424
- //#region src/utils/syslang.ts
425
- function Ie(e, t) {
426
- if (!e) return e;
427
- let n = 0, r = e.length, i = 0;
428
- if (e[i] === "[") {
429
- for (; i < r && /[0-9]/.test(e[i]);) i++;
430
- e[i] === "]" && (n = i + 1);
431
- }
432
- let a = w(e, n, !1);
433
- if (!a) return e;
434
- let o = t.charCodeAt(0), s = t.charCodeAt(1), c = a;
435
- for (; c;) if (o === c.lang1 && s === c.lang2) {
436
- let t = w(e, c.end + 4, !0);
437
- return e.substring(t.start, t.end);
438
- } else c = w(e, c.end + 4, !1);
439
- return e.substring(a.start, a.end) || e;
440
- }
441
- function w(e, t, n) {
442
- for (let n = t, r = e.length - 3; n < r; n++) if (e[n] === "[" && e[n + 3] === "]") return {
443
- start: t,
444
- end: n,
445
- lang1: e.charCodeAt(n + 1),
446
- lang2: e.charCodeAt(n + 2)
447
- };
448
- if (n) return {
449
- start: t,
450
- end: e.length,
451
- lang1: -1,
452
- lang2: -1
453
- };
454
- }
455
- //#endregion
456
- //#region src/utils/utilities.ts
457
- function Le(e, t) {
458
- let { useLocale: n, useLocaleAsPrefix: r, indexFile: i, path: a, folder: o } = t, s = n ? `${e}/` : null, c = r ? `${e}.${i}` : i ?? "";
459
- return [
460
- a,
461
- o,
462
- `${s || ""}${c}`
463
- ].filter((e) => e !== void 0).join("/");
464
- }
465
- //#endregion
466
- //#region src/web-api/helpers/create-headers.ts
467
- function T(e) {
468
- let t = $(), n = new Headers(e);
469
- n.append("Sinequa-Force-Camel-Case", "true"), n.append("accept", "application/json"), t && n.append("Sinequa-csrf-token", t);
470
- let { userOverride: i, userOverrideActive: a, bearerToken: o } = r;
471
- return o && n.append("Authorization", `Bearer ${o}`), i && a && (n.append("sinequa-override-user", i.username), n.append("sinequa-override-domain", i.domain)), n;
472
- }
473
- //#endregion
474
- //#region src/web-api/helpers/errors/api-error.ts
475
- var E = class extends Error {
476
- status;
477
- constructor(e, t) {
478
- super(e), this.name = "ApiError", this.status = t;
479
- }
480
- }, D = class extends E {
481
- constructor(e = "Server error") {
482
- super(e, 500), this.name = "ServerError";
483
- }
484
- }, Re = class extends E {
485
- constructor(e = "Request timed out") {
486
- super(e, 408), this.name = "TimeoutError";
487
- }
488
- }, O = class extends E {
489
- constructor(e = "Unauthorized access") {
490
- super(e, 401), this.name = "UnauthorizedError";
491
- }
492
- };
493
- //#endregion
494
- //#region src/web-api/helpers/handle-response.ts
495
- async function k(e, t = "json") {
496
- let n = e.headers.get("sinequa-jwt-refresh");
497
- if (n !== null && X(n), e.status >= 200 && e.status < 300) {
498
- let n = e.headers.get("content-length");
499
- if (e.status === 204 || n === "0") return;
500
- switch (t) {
501
- case "arraybuffer": return await e.arrayBuffer();
502
- case "blob": return await e.blob();
503
- case "text": return await e.text();
504
- default: return await e.json();
505
- }
506
- }
507
- if (e.status === 401) {
508
- if (r.userOverrideActive) {
509
- let t = {};
510
- try {
511
- t = await (e.clone?.() ?? e).json();
512
- } catch {}
513
- throw y("Unauthorized access attempt with user override", {
514
- endpoint: e.url ?? "",
515
- error: t
516
- }), new O(t.errorMessage ?? t.message ?? "Unauthorized... User override failed.");
517
- }
518
- return await A(e, 401);
519
- }
520
- return e.status === 500 ? (b("Server error occurred", { endpoint: e.url ?? "" }), await A(e, 500)) : (y(`Unexpected response status: ${e.status}`, { endpoint: e.url ?? "" }), await A(e, e.status));
521
- }
522
- async function A(e, t) {
523
- try {
524
- let { done: n, value: r } = await e.body?.getReader().read() || {
525
- done: !0,
526
- value: void 0
527
- };
528
- if (n || !r) throw t === 401 ? new O() : t === 500 ? new D() : new E(`Request failed with status ${t}`, t);
529
- let i = JSON.parse(new TextDecoder().decode(r));
530
- throw Error(i.errorMessage || i.message || `Request failed with status ${t}`, { cause: {
531
- errorCode: i.errorCode,
532
- errorCodeTest: i.errorCodeTest
533
- } });
534
- } catch (e) {
535
- throw e instanceof E ? e : t === 401 ? new O(e.message) : t === 500 ? new D(e.message) : new E(e.message ?? `Request failed with status ${t}`, t);
536
- }
537
- }
538
- var j = new class {
539
- client = null;
540
- initialize(e) {
541
- this.client = e;
542
- }
543
- getClient() {
544
- if (!this.client) throw Error("AadHttpClient not initialized. Call initializeAadHttpClient first.");
545
- return this.client;
546
- }
547
- isInitialized() {
548
- return this.client !== null;
549
- }
550
- }();
551
- function ze(e) {
552
- j.initialize(e);
553
- }
554
- //#endregion
555
- //#region src/web-api/helpers/utils/resolve-no-auto-authentication.ts
556
- function M() {
557
- return r.authMode?.kind !== "sso";
558
- }
559
- //#endregion
560
- //#region src/web-api/helpers/methods/del.ts
561
- async function Be(e, t, n) {
562
- let i = T(n?.headers), { app: a, backendUrl: o } = r, s = t ? `?${new URLSearchParams(t)}` : "", c = o ? `${o}/${e}${s}` : `${e}${s}`, l;
563
- if (n?.body) {
564
- i.has("Content-Type") || i.set("Content-Type", "application/json");
565
- let e = {
566
- app: a,
567
- ...n.body,
568
- locale: n.body.locale || navigator.language,
569
- noUserOverride: !0,
570
- noAutoAuthentication: M()
571
- };
572
- l = JSON.stringify(e);
573
- }
574
- _(`Making DELETE request to: ${c}`);
575
- try {
576
- if (j.isInitialized()) {
577
- let e = j.getClient();
578
- return k(await e.fetch(c, e.constructor.configurations.v1, {
579
- method: "DELETE",
580
- headers: i,
581
- body: l
582
- }), n?.responseType);
583
- }
584
- return k(await fetch(c, {
585
- method: "DELETE",
586
- credentials: "include",
587
- headers: i,
588
- body: l
589
- }), n?.responseType);
590
- } catch (e) {
591
- throw b("Error making DELETE request:", e), e;
592
- }
593
- }
594
- //#endregion
595
- //#region src/web-api/helpers/methods/get.ts
596
- async function N(e, t, n) {
597
- let i = T(n?.headers), { backendUrl: a } = r, o = t ? `?${new URLSearchParams(t)}` : "";
598
- e.startsWith("plugin") && (e = `api/v1/${e}`);
599
- let s = a ? `${a}/${e}${o}` : `${e}${o}`;
600
- _(`Making GET request to: ${s}`);
601
- try {
602
- if (j.isInitialized()) {
603
- let e = j.getClient();
604
- return k(await e.get(s, e.constructor.configurations.v1, {
605
- headers: i,
606
- signal: n?.signal
607
- }), n?.responseType);
608
- }
609
- return k(await fetch(s, {
610
- method: "GET",
611
- credentials: "include",
612
- headers: i,
613
- signal: n?.signal,
614
- redirect: n?.redirect
615
- }), n?.responseType);
616
- } catch (e) {
617
- throw b("Error making GET request:", e), e;
618
- }
619
- }
620
- //#endregion
621
- //#region src/web-api/helpers/methods/patch.ts
622
- async function Ve(e, t, n) {
623
- let i = T(n?.headers);
624
- i.append("content-type", "application/json");
625
- let { app: a, backendUrl: o } = r, s = {
626
- app: a,
627
- ...t,
628
- locale: t.locale || navigator.language,
629
- noUserOverride: !0,
630
- noAutoAuthentication: M()
631
- }, c = o ? `${o}/${e}` : `${e}`;
632
- _(`Making PATCH request to: ${c}`);
633
- try {
634
- if (j.isInitialized()) {
635
- let e = j.getClient();
636
- return k(await e.fetch(c, e.constructor.configurations.v1, {
637
- method: "PATCH",
638
- headers: i,
639
- body: JSON.stringify(s)
640
- }), n?.responseType);
641
- }
642
- return k(await fetch(c, {
643
- method: "PATCH",
644
- headers: i,
645
- credentials: "include",
646
- body: JSON.stringify(s)
647
- }), n?.responseType);
648
- } catch (e) {
649
- throw b("Error making PATCH request:", e), e;
650
- }
651
- }
652
- //#endregion
653
- //#region src/web-api/helpers/methods/post.ts
654
- async function P(e, t, n) {
655
- let i = T(n?.headers), { app: a, backendUrl: o } = r;
656
- i.has("Content-Type") || i.set("Content-Type", "application/json");
657
- let s = {
658
- app: a,
659
- ...t,
660
- locale: t.locale || navigator.language,
661
- noUserOverride: !0,
662
- noAutoAuthentication: M()
663
- };
664
- e.startsWith("plugin") && (e = `api/v1/${e}`);
665
- let c = o ? `${o}/${e}` : `${e}`;
666
- _(`Making POST request to: ${c}`);
667
- try {
668
- if (j.isInitialized()) {
669
- let e = j.getClient();
670
- return k(await e.post(c, e.constructor.configurations.v1, {
671
- headers: i,
672
- body: JSON.stringify(s),
673
- signal: n?.signal
674
- }), n?.responseType);
675
- }
676
- return k(await fetch(c, {
677
- method: "POST",
678
- headers: i,
679
- credentials: "include",
680
- body: JSON.stringify(s),
681
- signal: n?.signal
682
- }), n?.responseType);
683
- } catch (e) {
684
- throw b("Error making POST request:", e), e;
685
- }
686
- }
687
- //#endregion
688
- //#region src/web-api/helpers/methods/put.ts
689
- async function He(e, t, n) {
690
- let i = T(n?.headers), { app: a, backendUrl: o } = r;
691
- i.has("Content-Type") || i.set("Content-Type", "application/json");
692
- let s = {
693
- app: a,
694
- ...t,
695
- locale: t.locale || navigator.language,
696
- noUserOverride: !0,
697
- noAutoAuthentication: M()
698
- }, c = `${o}/${e}`;
699
- _(`Making PUT request to: ${c}`);
700
- try {
701
- if (j.isInitialized()) {
702
- let e = j.getClient();
703
- return k(await e.fetch(c, e.constructor.configurations.v1, {
704
- method: "PUT",
705
- headers: i,
706
- body: JSON.stringify(s)
707
- }), n?.responseType);
708
- }
709
- return k(await fetch(c, {
710
- method: "PUT",
711
- headers: i,
712
- credentials: "include",
713
- body: JSON.stringify(s)
714
- }), n?.responseType);
715
- } catch (e) {
716
- throw b("Error making PUT request:", e), e;
717
- }
718
- }
719
- //#endregion
720
- //#region src/web-api/helpers/utils/create-timeout-controller.ts
721
- function F(e) {
722
- let t = new AbortController(), { signal: n } = t;
723
- return e && setTimeout(() => {
724
- n.aborted || t.abort(new Re(`Request timed out after ${e}ms`));
725
- }, e), {
726
- controller: t,
727
- signal: n
728
- };
729
- }
730
- //#endregion
731
- //#region src/web-api/helpers/utils/date-utils..ts
732
- function I(e) {
733
- if (!e) return;
734
- let t = new Date(e);
735
- return Number.isNaN(t.getTime()) ? void 0 : t;
736
- }
737
- function Ue(e) {
738
- let t = I(e);
739
- return !!t && t.getTime() <= Date.now();
740
- }
741
- function We(e, t = 7) {
742
- let n = I(e);
743
- if (!n) return !1;
744
- let r = Date.now(), i = r + t * 24 * 60 * 60 * 1e3, a = n.getTime();
745
- return a > r && a <= i;
746
- }
747
- //#endregion
748
- //#region src/web-api/helpers/utils/with-retry.ts
749
- async function Ge(e, t = 0, n = 1e3) {
750
- let r;
751
- for (let i = 0; i <= t; i++) try {
752
- return await e();
753
- } catch (e) {
754
- if (r = e, e instanceof E && e.status >= 400 && e.status < 500 && e.status !== 429 || e instanceof DOMException && e.name === "AbortError") throw e;
755
- i < t && (y(`Retrying request (${i + 1}/${t})`, { error: e }), await new Promise((e) => setTimeout(e, n)));
756
- }
757
- throw r;
758
- }
759
- //#endregion
760
- //#region src/helpers/column-resolver.ts
761
- function Ke(e, t, n) {
762
- if (!e || !t) return;
763
- if (n) {
764
- let r = Object.keys(t.queries).find((e) => e === n?.toLowerCase()), i;
765
- r && (i = t.queries[r]);
766
- let a = (i?.columnsInfo?.columns || [])?.find((t) => t.aliases?.split(",")?.includes(e));
767
- if (a) return a.name;
768
- }
769
- let r = t.indexes?._?.columns, i = Object.entries(r).find((t) => t[1].aliases?.includes(e));
770
- if (i) return i[0];
771
- }
772
- //#endregion
773
- //#region src/types/audit/AuditEventType.ts
774
- var L = /* @__PURE__ */ function(e) {
775
- return e.None = "None", e.Search_FirstPage = "Search_FirstPage", e.Search_Text = "Search_Text", e.Search_Refine = "Search_Refine", e.Search_Select_Item = "Search_Select_Item", e.Search_Select_Custom = "Search_Select_Custom", e.Search_Select_Concept = "Search_Select_Concept", e.Search_Select_Correction = "Search_Select_Correction", e.Search_GotoPage = "Search_GotoPage", e.Search_GotoTab = "Search_GotoTab", e.Search_DisplayResult = "Search_DisplayResult", e.Search_RemoveResult = "Search_RemoveResult", e.Search_RemoveAdvanced = "Search_RemoveAdvanced", e.Search_SavedQuery = "Search_SavedQuery", e.Search_WebService = "Search_WebService", e.Search_DidYouMean_Original = "Search_DidYouMean_Original", e.Search_DidYouMean_Correction = "Search_DidYouMean_Correction", e.Search_ExportCSV = "Search_ExportCSV", e.Search_SavedQuery_ExportCSV = "Search_SavedQuery_ExportCSV", e.Search_Selection_ExportCSV = "Search_Selection_ExportCSV", e.Search_AlertQuery = "Search_AlertQuery", e.Search_Select_AnalyticsItem = "Search_Select_AnalyticsItem", e.Search_Sort = "Search_Sort", e.Search_Exit_Logout = "Search_Exit_Logout", e.Search_Timeline_Usage = "Search_Timeline_Usage", e.Search_AutoComplete = "Search_Autocomplete", e.Search_Login_Success = "Login_Success_Form", e.Search_QueryIntent_Detected = "Search_QueryIntent_Detected", e.SavedQuery_Add = "SavedQuery_Add", e.SavedQuery_Delete = "SavedQuery_Delete", e.SavedQuery_DeleteAll = "SavedQuery_DeleteAll", e.SavedQuery_Rename = "SavedQuery_Rename", e.Alert_Edit = "Alert_Edit", e.Alert_Delete = "Alert_Delete", e.Alert_DeleteAll = "Alert_DeleteAll", e.Link_Display = "Link_Display", e.Link_Click = "Link_Click", e.Basket_Add = "Basket_Add", e.Basket_Delete = "Basket_Delete", e.Basket_DeleteAll = "Basket_DeleteAll", e.Basket_Rename = "Basket_Rename", e.Basket_AddDoc = "Basket_AddDoc", e.Basket_RemoveDoc = "Basket_RemoveDoc", e.Basket_Open = "Basket_Open", e.Basket_ExportCSV = "Basket_ExportCSV", e.Label_Add = "Label_Add", e.Label_Delete = "Label_Delete", e.Label_Rename = "Label_Rename", e.Label_Open = "Label_Open", e.Label_AddDoc = "Label_AddDoc", e.Label_RemoveDoc = "Label_RemoveDoc", e.Label_ExportCSV = "Label_ExportCSV", e.Label_Menu_ExportCSV = "Label_Menu_ExportCSV", e.Rating_Set = "Rating_Set", e.Rating_Delete = "Rating_Delete", e.Doc_Preview = "Doc_Preview", e.Doc_CacheHtml = "Doc_CacheHtml", e.Doc_CachePdf = "Doc_CachePdf", e.Doc_CacheOriginal = "Doc_CacheOriginal", e.Doc_Url1 = "Doc_Url1", e.Doc_Url2 = "Doc_Url2", e.Preview_Close = "Preview_Close", e.Click_ResultLink = "Click_ResultLink", e.Click_ResultLink1 = "Click_ResultLink1", e.Click_ResultLink2 = "Click_ResultLink2", e.Click_ResultLink3 = "Click_ResultLink3", e.Click_ResultLink4 = "Click_ResultLink4", e.Click_ResultLink5 = "Click_ResultLink5", e.Click_ResultLink6 = "Click_ResultLink6", e.Click_ResultLink7 = "Click_ResultLink7", e.Click_ResultLink8 = "Click_ResultLink8", e.Click_ResultLink9 = "Click_ResultLink9", e.Click_ResultLink10 = "Click_ResultLink10", e.Click_PreviewLink1 = "Click_PreviewLink1", e.Click_PreviewLink2 = "Click_PreviewLink2", e.Click_PreviewLink3 = "Click_PreviewLink3", e.Click_PreviewLink4 = "Click_PreviewLink4", e.Click_PreviewLink5 = "Click_PreviewLink5", e.Click_PreviewLink6 = "Click_PreviewLink6", e.Click_PreviewLink7 = "Click_PreviewLink7", e.Click_PreviewLink8 = "Click_PreviewLink8", e.Click_PreviewLink9 = "Click_PreviewLink9", e.Click_PreviewLink10 = "Click_PreviewLink10", e.RFM_ClickSet = "RFM_ClickSet", e.RFM_ClickReset = "RFM_ClickReset", e.RFM_Like = "RFM_Like", e.RFM_LikeReset = "RFM_LikeReset", e.RFM_Dislike = "RFM_Dislike", e.RFM_Important = "RFM_Important", e.RFM_ImportantReset = "RFM_ImportantReset", e.RFM_Ban = "RFM_Ban", e.Navigation_Exit = "Navigation_Exit", e.Navigation_Return = "Navigation_Return", e.Navigation_Route = "Navigation_Route", e.Answer_Display = "Answer_Display", e.Answer_Click = "Answer_Click", e.Answer_Result = "Answer_Result", e.Answer_Liked = "Answer_Liked", e.Answer_Disliked = "Answer_Disliked", e.Answer_Liked_Cancelled = "Answer_Liked_Cancelled", e.Answer_Disliked_Cancelled = "Answer_Disliked_Cancelled", e.TopPassages_Display = "TopPassages_Display", e.TopPassages_Click = "TopPassages_Click", e.UserSettings_Reset = "UserSettings_Reset", e.Change_Password_Failed = "change.password.failed", e.Change_Password_Success_Form = "change.password.success.form", e.Forgot_Password_Request = "forgot.password.request", e.Login_Denied = "login.denied", e.Login_Success_Form = "login.success.form", e.Send_Reset_Password_Link = "send.reset.password.link", e.Xrest_ChangePassword = "xrest.changepassword", e;
776
- }({}), R = /* @__PURE__ */ function(e) {
777
- return e[e.none = 0] = "none", e[e.bool = 1] = "bool", e[e.date = 2] = "date", e[e.dateTime = 3] = "dateTime", e[e.time = 4] = "time", e[e.unsigned = 5] = "unsigned", e[e.integer = 6] = "integer", e[e.float = 7] = "float", e[e.double = 8] = "double", e[e.dates = 9] = "dates", e[e.dateTimes = 10] = "dateTimes", e[e.times = 11] = "times", e[e.varchar = 12] = "varchar", e[e.binary = 13] = "binary", e[e.string = 14] = "string", e[e.csv = 15] = "csv", e;
778
- }({}), z = /* @__PURE__ */ function(e) {
779
- return e[e.none = 0] = "none", e[e.a = 2053] = "a", e[e.c = 4] = "c", e[e.d = 8] = "d", e[e.e = 2068] = "e", e[e.i = 256] = "i", e[e.l = 2052] = "l", e[e.n = 8192] = "n", e[e.t = 524292] = "t", e[e.x = 8388608] = "x", e[e.z = 33554432] = "z", e[e.f_ordinal = 8192] = "f_ordinal", e[e.f_multidates = 8192] = "f_multidates", e[e.f_varchar = 33554432] = "f_varchar", e[e.f_binary = 33562624] = "f_binary", e[e.f_string = 33562888] = "f_string", e[e.f_csv = 42477853] = "f_csv", e[e.f_overridable = 33554696] = "f_overridable", e;
780
- }({}), qe = "1.0", Je = /* @__PURE__ */ function(e) {
781
- return e[e.Original = 0] = "Original", e[e.Corrected = 1] = "Corrected", e;
782
- }({}), Ye = /* @__PURE__ */ function(e) {
783
- return e[e.none = 0] = "none", e[e.positiveRate = 1] = "positiveRate", e[e.mainlyPosRate = 2] = "mainlyPosRate", e[e.unrate = 4] = "unrate", e[e.mainlyNegRate = 8] = "mainlyNegRate", e[e.negativeRate = 16] = "negativeRate", e[e.all = 31] = "all", e[e.positiveOnly = 7] = "positiveOnly", e[e.negativeOnly = 28] = "negativeOnly", e[e.personalAll = 21] = "personalAll", e[e.personalPosOnly = 5] = "personalPosOnly", e[e.personalNegOnly = 20] = "personalNegOnly", e;
784
- }({});
785
- //#endregion
786
- //#region src/helpers/columns.ts
787
- function Xe(e) {
788
- if (!e) return R.none;
789
- switch (e.toLocaleLowerCase()) {
790
- case "bool":
791
- case "boolean": return R.bool;
792
- case "date": return R.date;
793
- case "datetime": return R.dateTime;
794
- case "time": return R.time;
795
- case "unsigned": return R.unsigned;
796
- case "integer": return R.integer;
797
- case "float": return R.float;
798
- case "double": return R.double;
799
- case "dates": return R.dates;
800
- case "datetimes": return R.dateTimes;
801
- case "times": return R.times;
802
- case "varchar": return R.varchar;
803
- case "binary": return R.binary;
804
- case "string": return R.string;
805
- case "csv": return R.csv;
806
- default: return R.none;
807
- }
808
- }
809
- function Ze(e) {
810
- switch (e) {
811
- case "a": return z.a;
812
- case "c": return z.c;
813
- case "d": return z.d;
814
- case "e": return z.e;
815
- case "i": return z.i;
816
- case "l": return z.l;
817
- case "n": return z.n;
818
- case "t": return z.t;
819
- case "x": return z.x;
820
- case "z": return z.z;
821
- default: return z.none;
822
- }
823
- }
824
- function Qe(e) {
825
- let t = z.none;
826
- if (e) for (let n of e) t |= Ze(n);
827
- return t;
828
- }
829
- function B(e, t, n, r) {
830
- return {
831
- name: e,
832
- type: t,
833
- typeModifier: n,
834
- eType: Xe(t),
835
- eTypeModifier: Qe(n || ""),
836
- aliases: r
837
- };
838
- }
839
- var $e = {
840
- id: B("id", "string"),
841
- text: B("text", "varchar"),
842
- documentlanguages: B("documentlanguages", "csv", "ci", ["language"]),
843
- databasealias: B("databasealias", "varchar"),
844
- globalrelevance: B("globalrelevance", "double"),
845
- matchingpartnames: B("matchingpartnames", "csv"),
846
- matchlocations: B("matchlocations", "csv"),
847
- matchlocationsperpartname: B("matchlocationsperpartname", "varchar"),
848
- extracts: B("extracts", "csv"),
849
- extractsperpartname: B("extractsperpartname", "varchar"),
850
- extractslocations: B("extractslocations", "csv"),
851
- documentweight: B("documentweight", "varchar"),
852
- groupcount: B("groupcount", "integer"),
853
- accesslists: B("accesslists", "varchar", void 0, ["accessLists"])
854
- };
855
- //#endregion
856
- //#region src/helpers/filters.ts
857
- function et(e) {
858
- return e.filter((e) => !!e);
859
- }
860
- var V = {
861
- eq: (e, t) => ({
862
- field: e,
863
- operator: "eq",
864
- value: t
865
- }),
866
- neq: (e, t) => ({
867
- field: e,
868
- operator: "neq",
869
- value: t
870
- }),
871
- gt: (e, t) => ({
872
- field: e,
873
- operator: "gt",
874
- value: t
875
- }),
876
- gte: (e, t) => ({
877
- field: e,
878
- operator: "gte",
879
- value: t
880
- }),
881
- lt: (e, t) => ({
882
- field: e,
883
- operator: "lt",
884
- value: t
885
- }),
886
- lte: (e, t) => ({
887
- field: e,
888
- operator: "lte",
889
- value: t
890
- }),
891
- like: (e, t) => ({
892
- field: e,
893
- operator: "like",
894
- value: t
895
- }),
896
- contains: (e, t) => ({
897
- field: e,
898
- operator: "contains",
899
- value: t
900
- }),
901
- regex: (e, t) => ({
902
- field: e,
903
- operator: "regex",
904
- value: t
905
- }),
906
- isNull: (e) => ({
907
- field: e,
908
- operator: "null"
909
- }),
910
- isNotNull: (e) => ({
911
- field: e,
912
- operator: "notnull"
913
- }),
914
- in: (e, t) => ({
915
- field: e,
916
- operator: "in",
917
- values: t
918
- }),
919
- between: (e, t, n) => ({
920
- field: e,
921
- operator: "between",
922
- start: t,
923
- end: n
924
- }),
925
- and: (...e) => tt("and", e),
926
- or: (...e) => tt("or", e),
927
- not: (...e) => {
928
- let t = et(e);
929
- return t.length ? {
930
- operator: "not",
931
- filters: t
932
- } : void 0;
933
- }
934
- };
935
- function tt(e, t) {
936
- let n = et(t);
937
- if (n.length !== 0) return n.length === 1 ? n[0] : {
938
- operator: e,
939
- filters: n
940
- };
941
- }
942
- function H(e) {
943
- if (!e) return;
944
- let { operator: t, field: n } = e;
945
- switch (t) {
946
- case "and":
947
- case "or": {
948
- let n = (e.filters ?? []).map((e) => H(e));
949
- return t === "and" ? V.and(...n) : V.or(...n);
950
- }
951
- case "not": {
952
- let t = (e.filters ?? []).map((e) => H(e));
953
- return V.not(...t);
954
- }
955
- case "in": return n && e.values?.length ? V.in(n, e.values) : void 0;
956
- case "between": return n && e.start !== void 0 && e.end !== void 0 ? V.between(n, e.start, e.end) : void 0;
957
- case "null": return n ? V.isNull(n) : void 0;
958
- case "notnull": return n ? V.isNotNull(n) : void 0;
959
- case "eq":
960
- case "neq":
961
- case "gt":
962
- case "gte":
963
- case "lt":
964
- case "lte":
965
- case "like":
966
- case "contains":
967
- case "regex": return n && e.value !== void 0 ? V[t](n, e.value) : void 0;
968
- case void 0: return n && e.value !== void 0 ? V.eq(n, e.value) : void 0;
969
- default: return;
970
- }
971
- }
972
- //#endregion
973
- //#region src/helpers/metadata.ts
974
- function nt(e, t) {
975
- let n = e[t];
976
- return n === void 0 ? [] : (typeof n == "string" && (n = String(n).split(",")), Array.isArray(n) ? n.map((e) => {
977
- if (typeof e == "string") return e.trim();
978
- if (typeof e == "object" && e && "display" in e) return e.display.trim();
979
- }).filter((e) => e !== void 0) : [String(n).trim()]);
980
- }
981
- function rt(e, t) {
982
- let n = e[t];
983
- if (n === void 0) return [];
984
- if (typeof n == "string" && (n = String(n).split(",")), Array.isArray(n)) return n.map((e) => {
985
- if (typeof e == "string") return {
986
- display: e.trim(),
987
- value: e.trim()
988
- };
989
- if (typeof e == "object" && e && "display" in e) {
990
- let t = e.display.trim();
991
- return {
992
- display: t,
993
- value: "value" in e ? String(e.value).trim() : t
994
- };
995
- }
996
- }).filter((e) => e !== void 0);
997
- let r = String(n).trim();
998
- return [{
999
- display: r,
1000
- value: r
1001
- }];
1002
- }
1003
- //#endregion
1004
- //#region src/helpers/utils.ts
1005
- function U(e) {
1006
- return typeof e == "object" && !!e;
1007
- }
1008
- function it(e) {
1009
- return U(e) && Object.prototype.toString.call(e) === "[object ArrayBuffer]";
1010
- }
1011
- function at(e) {
1012
- return U(e) && Object.prototype.toString.call(e) === "[object Blob]";
1013
- }
1014
- function ot(e) {
1015
- return Object.prototype.toString.call(e) === "[object Date]";
1016
- }
1017
- function st(e) {
1018
- return typeof e == "string";
1019
- }
1020
- function ct(e) {
1021
- return (U(e) || Array.isArray(e)) && !it(e) && !at(e) && !st(e);
1022
- }
1023
- function lt(e) {
1024
- return e ? (e.getHours() * 60 * 60 + e.getMinutes() * 60 + e.getSeconds()) * 1e3 + e.getMilliseconds() : 0;
1025
- }
1026
- function ut(e = !0) {
1027
- let t = Date.now();
1028
- return (e ? "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" : "xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx").replace(/[xy]/g, (e) => {
1029
- let n = (t + Math.random() * 16) % 16 | 0;
1030
- return t = Math.floor(t / 16), (e === "x" ? n : n & 3 | 8).toString(16);
1031
- });
1032
- }
1033
- function dt(e) {
1034
- if (!e) return "``";
1035
- if (e = String(e), e.search(/[\\`]/) === -1) return `\`${e}\``;
1036
- let t = ["`"];
1037
- for (let n = 0, r = e.length; n < r; n++) {
1038
- let r = e[n];
1039
- (r === "\\" || r === "`") && t.push("\\"), t.push(r);
1040
- }
1041
- return t.push("`"), t.join("");
1042
- }
1043
- function ft(e) {
1044
- if (typeof crypto < "u" && crypto.subtle && typeof crypto.subtle.digest == "function") try {
1045
- return crypto.subtle.digest("SHA-512", new TextEncoder().encode(e)).then((e) => Array.prototype.map.call(new Uint8Array(e), (e) => `00${e.toString(16)}`.slice(-2)).join("")).catch(() => Promise.resolve(W(e)));
1046
- } catch {
1047
- return Promise.resolve(W(e));
1048
- }
1049
- return Promise.resolve(W(e));
1050
- }
1051
- function W(e) {
1052
- let t = 2166136261;
1053
- for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = t * 16777619 >>> 0;
1054
- let n = t.toString(16).padStart(8, "0"), r = ((t ^ 2863311530) >>> 0).toString(16).padStart(8, "0"), i = ((t ^ 1431655765) >>> 0).toString(16).padStart(8, "0"), a = ((t ^ 3435973836) >>> 0).toString(16).padStart(8, "0"), o = n + r + i + a;
1055
- return (o + o + o + o).substring(0, 128);
1056
- }
1057
- //#endregion
1058
- //#region src/web-api/v1/fetch-audit.ts
1059
- var G, pt;
1060
- function K(e, t = !0) {
1061
- let n = mt(e.$auditRecord);
1062
- n && (ht(n), t && gt(n)), e.$auditRecord = n;
1063
- }
1064
- function mt(e) {
1065
- if (!e) return;
1066
- let t;
1067
- if (Array.isArray(e)) t = e;
1068
- else if (U(e)) {
1069
- let n = e;
1070
- if (n.auditEvents || n.mlAuditEvents) return n;
1071
- t = [e];
1072
- }
1073
- return { auditEvents: t };
1074
- }
1075
- function ht(e) {
1076
- let t = _t();
1077
- return e.auditEvents?.forEach((e) => {
1078
- e.detail ||= {}, e.detail.sessionid = t;
1079
- }), e;
1080
- }
1081
- function gt(e) {
1082
- let t = typeof window < "u" ? decodeURIComponent(window.location.href) : "http://localhost";
1083
- return e?.auditEvents?.forEach((e) => {
1084
- e.detail ||= {}, e.detail.url = t;
1085
- }), e;
1086
- }
1087
- function _t() {
1088
- return (!G || vt()) && (G = ut()), pt = /* @__PURE__ */ new Date(), G;
1089
- }
1090
- function vt() {
1091
- return Date.now() - pt.getTime() > 600 * 1e3;
1092
- }
1093
- async function yt(e, t = !0) {
1094
- let n = {
1095
- event: L.None,
1096
- $auditRecord: e
1097
- };
1098
- return K(n, t), P("api/v1/audit.notify", n);
1099
- }
1100
- var bt = { notify: yt };
1101
- //#endregion
1102
- //#region src/web-api/v1/fetch-aggregation.ts
1103
- async function xt(e, t, n) {
1104
- let r = e.items?.length || 0, i = {
1105
- query: {
1106
- ...t,
1107
- action: "aggregate",
1108
- aggregations: { [e.name]: {
1109
- skip: r,
1110
- count: 10
1111
- } }
1112
- },
1113
- $auditRecord: { auditEvents: [n] }
1114
- };
1115
- K(i);
1116
- let { aggregations: a } = await k(await P("api/v1/query", i)), o = a[0];
1117
- return o.$hasMore = o.items.length > 10, o.items = [...e.items, ...o.items], Promise.resolve(o);
1118
- }
1119
- //#endregion
1120
- //#region src/authentication/session/detect-auth-mode.ts
1121
- function St(e, n) {
1122
- if (e.authMode?.kind === "credentials") return t.credentials();
1123
- if (e.bearerToken) return t.bearer(e.bearerToken);
1124
- let r = e.autoOAuthProvider || n?.autoOAuthProvider;
1125
- if (r) return t.oauth(r);
1126
- let i = e.autoSAMLProvider || n?.autoSAMLProvider;
1127
- return i ? t.saml(i) : t.unknown();
1128
- }
1129
- //#endregion
1130
- //#region src/web-api/v1/fetch-app.ts
1131
- async function Ct(e) {
1132
- let t = e || r.app;
1133
- return N("api/v1/app", new URLSearchParams({ app: t || "" }));
1134
- }
1135
- async function wt() {
1136
- let { app: e } = r;
1137
- return N("api/v1/app", new URLSearchParams({
1138
- app: e || "",
1139
- preLogin: "true"
1140
- }));
1141
- }
1142
- function Tt() {
1143
- let { backendUrl: e, app: n } = r;
1144
- if (typeof window < "u") {
1145
- if (e ||= window.location.origin, !n) {
1146
- let e = window.location.pathname.match(/\/app(?:-debug)?\/([^/#]+)/);
1147
- e && (n = e[1]);
1148
- }
1149
- i({
1150
- backendUrl: e,
1151
- app: n
1152
- });
1153
- }
1154
- return r.authMode?.kind === "credentials" ? (i({
1155
- authMode: t.credentials(),
1156
- autoOAuthProvider: void 0,
1157
- autoSAMLProvider: void 0,
1158
- bearerToken: void 0
1159
- }), Promise.resolve({})) : wt().then((e) => (i({
1160
- authMode: St(r, e),
1161
- autoOAuthProvider: r.autoOAuthProvider || e.autoOAuthProvider,
1162
- autoSAMLProvider: r.autoSAMLProvider || e.autoSAMLProvider
1163
- }), e)).catch((e) => {
1164
- throw b("atomic:fetchAppPreLogin error", e), e;
1165
- });
1166
- }
1167
- var Et = Tt;
1168
- //#endregion
1169
- //#region src/web-api/v1/fetch-dataset.ts
1170
- async function Dt(e, t, n = {}) {
1171
- let r = await P(`api/v1/search.dataset/${e}/${t}`, { parameters: n }), i = t[0].toLowerCase() + t.slice(1), a = r.datasets[i];
1172
- if ("errorCode" in a && "errorMessage" in a) throw Error(a.errorMessage);
1173
- return a;
1174
- }
1175
- async function Ot(e, t) {
1176
- let n = `api/v1/search.dataset/${e}`, { parameters: r = {}, datasets: i = [] } = t;
1177
- return (await P(n, {
1178
- parameters: r,
1179
- datasets: i
1180
- })).datasets;
1181
- }
1182
- async function kt(e) {
1183
- return await N(`api/v1/search.dataset/${e}`);
1184
- }
1185
- //#endregion
1186
- //#region src/web-api/v1/fetch-labels.ts
1187
- async function At(e, t = !0, n) {
1188
- try {
1189
- return (await P("api/v1/labels", {
1190
- action: "list",
1191
- q: e,
1192
- public: t,
1193
- locale: n,
1194
- localize: !1
1195
- })).labels;
1196
- } catch (e) {
1197
- throw b("Error in fetchLabels", e), e;
1198
- }
1199
- }
1200
- async function jt() {
1201
- try {
1202
- let { app: e = "" } = r;
1203
- return N("api/v1/labels", new URLSearchParams({
1204
- app: e,
1205
- action: "getUserRights"
1206
- }));
1207
- } catch (e) {
1208
- throw b("Error in getUserRights", e), e;
1209
- }
1210
- }
1211
- async function Mt(e, t, n = !0) {
1212
- try {
1213
- return P("api/v1/labels", {
1214
- action: "add",
1215
- labels: e,
1216
- ids: t,
1217
- public: n,
1218
- $auditRecord: {
1219
- auditEvents: [{
1220
- type: L.Label_AddDoc,
1221
- detail: {
1222
- public: n,
1223
- label: e ? e.toString() : null,
1224
- doccount: t ? t.length : 0
1225
- }
1226
- }],
1227
- mlAuditEvents: [{
1228
- actionType: "addToLabel",
1229
- documentIds: t
1230
- }]
1231
- }
1232
- });
1233
- } catch (e) {
1234
- throw b("Error in add", e), e;
1235
- }
1236
- }
1237
- async function Nt(e, t, n = !0) {
1238
- try {
1239
- return P("api/v1/labels", {
1240
- action: "remove",
1241
- labels: e,
1242
- ids: t,
1243
- public: n,
1244
- $auditRecord: {
1245
- auditEvents: [{
1246
- type: L.Label_RemoveDoc,
1247
- detail: {
1248
- public: n,
1249
- label: e ? e.toString() : null,
1250
- doccount: t ? t.length : 0
1251
- }
1252
- }],
1253
- mlAuditEvents: [{
1254
- actionType: "removeFromLabel",
1255
- documentIds: t
1256
- }]
1257
- }
1258
- });
1259
- } catch (e) {
1260
- throw b("Error in remove", e), e;
1261
- }
1262
- }
1263
- async function Pt(e, t, n = !0) {
1264
- try {
1265
- return P("api/v1/labels", {
1266
- action: "rename",
1267
- labels: e,
1268
- newLabel: t,
1269
- public: n,
1270
- auditEvents: {
1271
- type: L.Label_Rename,
1272
- detail: {
1273
- public: n,
1274
- oldlabel: e ? e.toString() : null,
1275
- label: t
1276
- }
1277
- }
1278
- });
1279
- } catch (e) {
1280
- throw b("Error in rename", e), e;
1281
- }
1282
- }
1283
- async function Ft(e, t = !0) {
1284
- try {
1285
- return P("api/v1/labels", {
1286
- action: "delete",
1287
- labels: e,
1288
- public: t,
1289
- auditEvents: {
1290
- type: L.Label_Delete,
1291
- detail: {
1292
- public: t,
1293
- label: e ? e.toString() : null
1294
- }
1295
- }
1296
- });
1297
- } catch (e) {
1298
- throw b("Error in deleteLabels", e), e;
1299
- }
1300
- }
1301
- async function It(e, t, n = !0) {
1302
- try {
1303
- return P("api/v1/labels", {
1304
- action: "bulkAdd",
1305
- labels: e,
1306
- query: t,
1307
- public: n,
1308
- auditEvents: {
1309
- type: L.Label_Add,
1310
- detail: {
1311
- public: n,
1312
- label: e ? e.toString() : null,
1313
- query: t === null ? null : t.name
1314
- }
1315
- }
1316
- });
1317
- } catch (e) {
1318
- throw b("Error in bulkAdd", e), e;
1319
- }
1320
- }
1321
- async function Lt(e, t, n = !0) {
1322
- try {
1323
- return P("api/v1/labels", {
1324
- action: "bulkRemove",
1325
- labels: e,
1326
- query: t,
1327
- public: n,
1328
- auditEvents: {
1329
- type: L.Label_Delete,
1330
- detail: {
1331
- public: n,
1332
- label: e ? e.toString() : null,
1333
- query: t === null ? null : t.name
1334
- }
1335
- }
1336
- });
1337
- } catch (e) {
1338
- throw b("Error in bulkRemove", e), e;
1339
- }
1340
- }
1341
- var Rt = {
1342
- getUserRights: jt,
1343
- add: Mt,
1344
- remove: Nt,
1345
- rename: Pt,
1346
- delete: Ft,
1347
- bulkAdd: It,
1348
- bulkRemove: Lt
1349
- };
1350
- //#endregion
1351
- //#region src/web-api/v1/fetch-preview.ts
1352
- async function zt(e, t) {
1353
- if (typeof window > "u") return P("api/v1/preview", {
1354
- action: "get",
1355
- id: e,
1356
- query: t
1357
- });
1358
- let n = `${window.location.origin}${window.location.pathname}`;
1359
- return P("api/v1/preview", {
1360
- action: "get",
1361
- id: e,
1362
- query: {
1363
- name: t?.name,
1364
- text: t?.text
1365
- },
1366
- browserUrl: n
1367
- });
1368
- }
1369
- async function Bt(e) {
1370
- let t = new Headers();
1371
- t.append("content-type", "text"), k(await fetch(e, {
1372
- method: "GET",
1373
- headers: t
1374
- }));
1375
- }
1376
- //#endregion
1377
- //#region src/web-api/v1/fetch-principal.ts
1378
- async function Vt() {
1379
- return N("api/v1/principal", new URLSearchParams({
1380
- action: "get",
1381
- noAutoAuthentication: String(M())
1382
- }));
1383
- }
1384
- async function Ht(e) {
1385
- let t = {
1386
- noAutoAuthentication: String(M()),
1387
- ...e
1388
- }, n = new URLSearchParams();
1389
- return Object.entries(t).forEach(([e, t]) => {
1390
- t !== void 0 && n.append(e, String(t));
1391
- }), N("api/v1/principal/list", n);
1392
- }
1393
- async function Ut(e) {
1394
- return e ? N("api/v1/principal", new URLSearchParams({
1395
- action: "userid",
1396
- noAutoAuthentication: String(M()),
1397
- userid: e
1398
- })) : Promise.reject(/* @__PURE__ */ Error("userid is required"));
1399
- }
1400
- async function Wt(e) {
1401
- return e.length === 0 ? Promise.reject(/* @__PURE__ */ Error("userids is required")) : N("api/v1/principal/userids", new URLSearchParams({
1402
- noAutoAuthentication: String(M()),
1403
- userids: [...e].join(",")
1404
- }));
1405
- }
1406
- var Gt = { principal: {
1407
- get: Vt,
1408
- list: Ht,
1409
- userid: Ut,
1410
- userids: Wt
1411
- } }, Kt = 11;
1412
- async function qt(e, t, n) {
1413
- let r = await P("api/v1/query", {
1414
- query: e,
1415
- $auditRecord: t,
1416
- queryIntentData: n
1417
- });
1418
- r.aggregations.forEach((e) => {
1419
- e.$hasMore = !1, !e.isDistribution && !e.isTree && e.items && (e.$hasMore = e.items.length === Kt), e.isTree && e.items && q(e);
1420
- }), r.records?.map((e) => Object.assign(e, {
1421
- value: e.title,
1422
- type: "default"
1423
- }));
1424
- let i = {
1425
- ...r,
1426
- nextPage: r.page < Math.ceil(r.rowCount / r.pageSize) ? r.page + 1 : void 0,
1427
- previousPage: r.page > 1 ? r.page - 1 : void 0
1428
- };
1429
- return Promise.resolve(i);
1430
- }
1431
- async function Jt(e, t, n) {
1432
- let { app: i = "" } = r, a = {
1433
- methods: [],
1434
- mode: t,
1435
- propagateErrors: !0,
1436
- $auditRecord: { auditEvents: [n] }
1437
- };
1438
- for (let t of e) a.methods.push({
1439
- method: "query",
1440
- app: i,
1441
- query: t
1442
- });
1443
- let o = await P("api/v1/multi", a);
1444
- o.results.forEach((e) => {
1445
- e.aggregations.forEach((e) => {
1446
- e.$hasMore = !1, !e.isDistribution && !e.isTree && e.items && (e.$hasMore = e.items.length === Kt), e.isTree && q(e);
1447
- });
1448
- }), o.results.forEach((e) => {
1449
- e.records?.map((e) => Object.assign(e, {
1450
- value: e.title,
1451
- type: "default"
1452
- }));
1453
- });
1454
- let s = o.results.map((e) => ({
1455
- ...e,
1456
- nextPage: e.page < Math.ceil(e.rowCount / e.pageSize) ? e.page + 1 : void 0,
1457
- previousPage: e.page > 1 ? e.page - 1 : void 0
1458
- }));
1459
- return Promise.resolve(s);
1460
- }
1461
- function q(e, t = "", n = 0) {
1462
- let r = [];
1463
- return e.items && e.items.forEach((e) => {
1464
- let i = t ? `${t}/${e.value}` : e.value, a = n + 1;
1465
- r.push({
1466
- path: i,
1467
- level: a
1468
- }), e.$path = i, e.$level = a, e.hasChildren ? r = r.concat(q(e, i, a)) : e.hasChildren = !1;
1469
- }), r;
1470
- }
1471
- //#endregion
1472
- //#region src/web-api/v1/fetch-query-export.ts
1473
- async function Yt({ model: e, appName: t, query: n, article: r }) {
1474
- let { webservice: i, format: a, maxcount: o, exportedColumns: s, export: c } = e, l = {
1475
- app: t,
1476
- webservice: i,
1477
- query: n,
1478
- type: c,
1479
- format: a,
1480
- maxcount: o,
1481
- exportedColumns: s,
1482
- $auditRecord: { auditEvents: [{
1483
- type: "Search_ExportCSV",
1484
- detail: { resultid: r ? r.id : void 0 }
1485
- }] }
1486
- };
1487
- return K(l), await P("api/v1/search.queryexport", l, { responseType: "blob" });
1488
- }
1489
- //#endregion
1490
- //#region src/web-api/v1/fetch-query-intent.ts
1491
- async function Xt(e) {
1492
- return (await P("api/v1/queryintent", { query: e }))?.intents;
1493
- }
1494
- //#endregion
1495
- //#region src/web-api/v1/fetch-similar-documents.ts
1496
- async function Zt(e, t, n) {
1497
- return (await P("api/v1/similardocuments", {
1498
- sourceDocumentId: e,
1499
- query: { name: t }
1500
- }, { signal: n })).data;
1501
- }
1502
- //#endregion
1503
- //#region src/web-api/v1/fetch-sponsored-links.ts
1504
- async function Qt(e, t) {
1505
- return (await P("api/v1/query.links", {
1506
- webservice: e,
1507
- query: t
1508
- }))?.links?.map((e) => ({
1509
- ...e,
1510
- query: t
1511
- }));
1512
- }
1513
- //#endregion
1514
- //#region src/utils/to-sql.ts
1515
- function $t(e, t) {
1516
- if (typeof e == "number") return `${e}`;
1517
- if (ot(e)) return t ? `'${en(e)}'` : en(e);
1518
- if (typeof e == "boolean") return e ? "true" : "false";
1519
- if (e === null) return "null";
1520
- if (Array.isArray(e)) {
1521
- let t = [];
1522
- return e.forEach((e) => {
1523
- t.length > 0 && t.push(","), e ? typeof e == "string" ? t.push(e) : t.push(e.display || e.value || "") : t.push("null");
1524
- }), t.splice(0, 0, "["), t.push("]"), t.join("");
1525
- }
1526
- return t ? `'${e}'` : e;
1527
- }
1528
- function en(e) {
1529
- if (!e) return "";
1530
- try {
1531
- return lt(e) === 0 ? new Intl.DateTimeFormat("en-CA", {
1532
- year: "numeric",
1533
- month: "2-digit",
1534
- day: "2-digit"
1535
- }).format(e) : `${new Intl.DateTimeFormat("en-CA").format(e)} ${new Intl.DateTimeFormat("en-CA", {
1536
- hour: "2-digit",
1537
- minute: "2-digit",
1538
- second: "2-digit",
1539
- hour12: !1
1540
- }).format(e)}`;
1541
- } catch {
1542
- return "Invalid date";
1543
- }
1544
- }
1545
- //#endregion
1546
- //#region src/web-api/v1/fetch-suggest.ts
1547
- async function tn(e, t, n, i, a) {
1548
- let { app: o } = r, s = {
1549
- app: o || "",
1550
- suggestQuery: e,
1551
- text: t,
1552
- filter: n,
1553
- kinds: i,
1554
- showSource: a
1555
- };
1556
- try {
1557
- return (await P("api/v1/search.suggest", s)).suggests;
1558
- } catch (e) {
1559
- throw console.error("Error fetching suggestions:", e), e;
1560
- }
1561
- }
1562
- async function nn(e, t, n, i) {
1563
- let { app: a } = r;
1564
- return (await P("api/v1/suggestquery", {
1565
- app: a || "",
1566
- suggestQuery: e,
1567
- text: t,
1568
- query: n,
1569
- kinds: i
1570
- })).suggests;
1571
- }
1572
- async function rn(e, t, n) {
1573
- if (!t) return Promise.resolve([]);
1574
- let { app: i } = r, a = await P("api/v1/suggestfield", {
1575
- app: i || "",
1576
- text: e,
1577
- fields: t,
1578
- query: n
1579
- });
1580
- return a.suggests.forEach((e) => {
1581
- e.display = $t(e.display);
1582
- }), a.suggests;
1583
- }
1584
- //#endregion
1585
- //#region src/web-api/v1/fetch-text-chunk.ts
1586
- async function an(e, t, n, r, i, a) {
1587
- return P("api/v1/doc.textchunks", {
1588
- id: e,
1589
- textChunks: t,
1590
- highlights: n,
1591
- query: r,
1592
- leftSentencesCount: i,
1593
- rightSentencesCount: a
1594
- });
1595
- }
1596
- //#endregion
1597
- //#region src/web-api/v1/fetch-user-settings.ts
1598
- async function on() {
1599
- let { app: e } = r;
1600
- return N("api/v1/usersettings", new URLSearchParams({
1601
- app: e || "",
1602
- action: "load"
1603
- }));
1604
- }
1605
- async function sn(e, t) {
1606
- let n = {
1607
- action: "save",
1608
- userSettings: e,
1609
- $auditRecord: { auditEvents: [t] }
1610
- };
1611
- return K(n), P("api/v1/usersettings", n);
1612
- }
1613
- async function cn(e, t) {
1614
- let n = {
1615
- action: "patch",
1616
- userSettings: e,
1617
- $auditRecord: t ? { auditEvents: [t] } : void 0
1618
- };
1619
- return K(n), P("api/v1/usersettings", n);
1620
- }
1621
- async function ln() {
1622
- return sn({}, { type: "UserSettings_Reset" });
1623
- }
1624
- //#endregion
1625
- //#region src/web-api/v2/fetch-change-password.ts
1626
- async function un(e, t) {
1627
- return P("api/v2/security/password/change", {
1628
- newPassword: e,
1629
- currentPassword: t
1630
- });
1631
- }
1632
- //#endregion
1633
- //#region src/web-api/v2/fetch-forgot-password.ts
1634
- async function dn(e) {
1635
- return P("api/v2/security/password/ask-reset-email", {
1636
- changePasswordRedirectUrl: `${window.location.origin}/login?mode=changepassword`,
1637
- userName: e
1638
- });
1639
- }
1640
- //#endregion
1641
- //#region src/web-api/v2/fetch-user-profile.ts
1642
- async function fn(e) {
1643
- return await N(`api/v2/user-profile/${e}`);
1644
- }
1645
- async function pn(e) {
1646
- return await P("api/v2/user-profile", e);
1647
- }
1648
- async function mn(e, t, n) {
1649
- return await Ve(`api/v2/user-profile/${e.data?.id}/${t}/${n}`, e);
1650
- }
1651
- async function hn(e, t, n) {
1652
- return (await Be(`api/v2/user-profile/${e.data?.id}/${t}/${n}`)).success === !0;
1653
- }
1654
- //#endregion
1655
- //#region src/web-api/v2/fetch-version.ts
1656
- async function gn() {
1657
- return await N("api/v2/version");
1658
- }
1659
- //#endregion
1660
- //#region src/authentication/constants.ts
1661
- var J = 1e4, Y = "sinequa-auth-redirect-attempt", _n = async () => {
1662
- let { autoOAuthProvider: e } = r;
1663
- if (!e) throw Error("autoOAuthProvider is not configured in globalConfig");
1664
- if (typeof window > "u") try {
1665
- let { signal: t } = F(J);
1666
- return await P("security.oauth", {
1667
- action: "getcode",
1668
- provider: e,
1669
- tokenInCookie: !0,
1670
- originalUrl: "http://localhost"
1671
- }, { signal: t });
1672
- } catch (e) {
1673
- throw b("Failed to authenticate with OAuth", e), e;
1674
- }
1675
- let t = {
1676
- action: "getcode",
1677
- provider: e,
1678
- tokenInCookie: !0,
1679
- originalUrl: window.location.href
1680
- };
1681
- try {
1682
- let { signal: n } = F(J), r = await P("api/v1/security.oauth", t, { signal: n });
1683
- if (r.redirectUrl) {
1684
- let t = new URL(r.redirectUrl, window.location.origin);
1685
- if (t.protocol === "https:" || t.protocol === "http:") {
1686
- if (u("sinequa-auth-redirect-attempt")) throw f(Y), Error(`OAuth sign-in with provider "${e}" did not establish a session — its callback is likely not authorized for this application.`);
1687
- d(Y, "1"), window.location.href = t.href;
1688
- }
1689
- }
1690
- return r;
1691
- } catch (e) {
1692
- throw b("Failed to authenticate with OAuth", e), e;
1693
- }
1694
- }, vn = async () => {
1695
- let { autoSAMLProvider: e } = r;
1696
- if (!e) throw Error("autoSAMLProvider is not configured in globalConfig");
1697
- if (typeof window > "u") try {
1698
- let { signal: t } = F(J);
1699
- return await P("security.saml", {
1700
- action: "getresponse",
1701
- provider: e,
1702
- tokenInCookie: !0,
1703
- originalUrl: "http://localhost"
1704
- }, { signal: t });
1705
- } catch (e) {
1706
- throw b("Failed to authenticate with SAML", e), e;
1707
- }
1708
- let t = {
1709
- action: "getresponse",
1710
- provider: e,
1711
- tokenInCookie: !0,
1712
- originalUrl: window.location.href
1713
- };
1714
- try {
1715
- let { signal: n } = F(J), r = await P("api/v1/security.saml", t, { signal: n });
1716
- if (r.redirectUrl) {
1717
- let t = new URL(r.redirectUrl, window.location.origin);
1718
- if (t.protocol === "https:" || t.protocol === "http:") {
1719
- if (u("sinequa-auth-redirect-attempt")) throw f(Y), Error(`SAML sign-in with provider "${e}" did not establish a session — its callback is likely not authorized for this application.`);
1720
- d(Y, "1"), window.location.href = t.href;
1721
- }
1722
- }
1723
- return r;
1724
- } catch (e) {
1725
- throw b("Failed to authenticate with SAML", e), e;
1726
- }
1727
- }, X = (e) => d("sinequa-credentials", JSON.stringify({ data: { csrfToken: e } })), Z = async () => {
1728
- let e;
1729
- try {
1730
- let { signal: t } = F(J);
1731
- e = await N("api/v1/challenge?action=getCsrfToken&suppressErrors=true", void 0, { signal: t });
1732
- } catch (e) {
1733
- throw y("CSRF token fetch failed", e), e;
1734
- }
1735
- return e?.csrfToken ? (X(e.csrfToken), e.csrfToken) : null;
1736
- };
1737
- //#endregion
1738
- //#region src/authentication/tokens/get-jwt-token.ts
1739
- async function Q(e) {
1740
- if (e) {
1741
- let { username: t, password: n } = e, r = {
1742
- action: "get",
1743
- tokenInCookie: !0,
1744
- user: t,
1745
- password: n,
1746
- noUserOverride: !0,
1747
- noAutoAuthentication: !0
1748
- };
1749
- try {
1750
- let { signal: e } = F(J), t = await P("api/v1/security.webtoken", r, { signal: e });
1751
- return t?.csrfToken ? (X(t.csrfToken), t.csrfToken) : null;
1752
- } catch (e) {
1753
- throw b("Failed to get JWT", e), e;
1754
- }
1755
- } else {
1756
- let e = {
1757
- action: "get",
1758
- tokenInCookie: !0,
1759
- noUserOverride: !0,
1760
- noAutoAuthentication: !1
1761
- }, { bearerToken: t } = r;
1762
- if (!t) throw Error("Bearer token is required in globalConfig for credentialless JWT retrieval.");
1763
- try {
1764
- let { signal: t } = F(J), n = await P("api/v1/security.webtoken", e, { signal: t });
1765
- return n?.csrfToken ? (X(n.csrfToken), n.csrfToken) : null;
1766
- } catch (e) {
1767
- throw b("Failed to get JWT without credentials", e), e;
1768
- }
1769
- }
1770
- }
1771
- //#endregion
1772
- //#region src/authentication/tokens/get-token.ts
1773
- var $ = () => {
1774
- let e = u("sinequa-credentials");
1775
- if (e) try {
1776
- let t = JSON.parse(e).data?.csrfToken;
1777
- if (t) return t;
1778
- } catch (e) {
1779
- y("Failed to parse session storage credentials, falling back to local storage", e);
1780
- }
1781
- return s("csrfToken") || null;
1782
- }, yn = "sinequa-last-auth-mode", bn = () => {
1783
- c(yn, "credentials");
1784
- }, xn = () => s(yn) === "credentials", Sn = () => {
1785
- l(yn);
1786
- }, Cn = "sinequa-authenticated", wn = (e) => {
1787
- e ? d(Cn, "true") : f(Cn);
1788
- }, Tn = () => u(Cn) === "true", En = async () => {
1789
- try {
1790
- let { signal: e } = F(J);
1791
- return await N("api/v1/principal", new URLSearchParams({ action: "get" }), {
1792
- signal: e,
1793
- redirect: "manual"
1794
- }), v("Server auto-authenticated the user (OIDC)"), !0;
1795
- } catch {
1796
- return !1;
1797
- }
1798
- }, Dn = () => xn() ? t.credentials() : t.sso(), On = async (n) => {
1799
- if (n) {
1800
- let { username: t, password: r } = n;
1801
- return !t || !r ? (b("Credentials are required for authentication"), e(!1), !1) : kn({
1802
- username: t,
1803
- password: r
1804
- });
1805
- }
1806
- let a = r.authMode ?? t.unknown();
1807
- if (a.kind === "credentials") return e(!1), !1;
1808
- if (a.kind === "bearer") return An();
1809
- if ($()) {
1810
- if (v("User already authenticated (existing token)"), i({ isRedirectUrl: !1 }), f(Y), a.kind === "unknown") {
1811
- let e = Dn();
1812
- v(`Ambiguous auth mode resolved to "${e.kind}"`), i({ authMode: e });
1813
- }
1814
- return e(!0), !0;
1815
- }
1816
- try {
1817
- if (v("Checking for an existing session via CSRF token retrieval"), await Z()) {
1818
- if (v("User already authenticated (existing session)"), f(Y), a.kind === "unknown") {
1819
- let e = Dn();
1820
- v(`Ambiguous auth mode resolved to "${e.kind}"`), i({ authMode: e });
1821
- }
1822
- return e(!0), !0;
1823
- }
1824
- } catch {}
1825
- switch (a.kind) {
1826
- case "oauth": return v("Initiating OAuth authentication flow"), await _n(), e(!1), !1;
1827
- case "saml": return v("Initiating SAML authentication flow"), await vn(), e(!1), !1;
1828
- case "sso": return e(!1), !1;
1829
- default: return v("No provider declared — probing for server-side auto-authentication (OIDC)"), await En() ? (v("User auto-authenticated by the server (OIDC)"), f(Y), i({ authMode: t.sso() }), await Z().catch(() => {}), wn(!0), e(!0), !0) : (i({ authMode: t.credentials() }), e(!1), !1);
1830
- }
1831
- };
1832
- async function kn(n) {
1833
- v("Attempting authentication using credentials"), i({ authMode: t.credentials() }), bn();
1834
- let { userOverrideActive: a, userOverride: o } = r;
1835
- i({
1836
- userOverrideActive: !1,
1837
- userOverride: void 0
1838
- });
1839
- try {
1840
- await Q(n);
1841
- } catch (t) {
1842
- throw e(!1), t;
1843
- }
1844
- return i({
1845
- userOverrideActive: a,
1846
- userOverride: o
1847
- }), e(!0), !0;
1848
- }
1849
- async function An() {
1850
- try {
1851
- if (v("Attempting authentication using bearer token"), await Q()) return e(!0), !0;
1852
- } catch (t) {
1853
- throw b("Bearer authentication failed", t), e(!1), t;
1854
- }
1855
- return e(!1), !1;
1856
- }
1857
- //#endregion
1858
- //#region src/authentication/tokens/delete-web-token-cookie.ts
1859
- var jn = async () => {
1860
- let e = new URLSearchParams({
1861
- action: "deleteWebTokenCookie",
1862
- noUserOverride: "true",
1863
- noAutoAuthentication: "true"
1864
- }), { signal: t } = F(J);
1865
- return N("api/v1/challenge", e, { signal: t });
1866
- };
1867
- //#endregion
1868
- //#region src/authentication/session/logout.ts
1869
- async function Mn() {
1870
- let { userOverrideActive: e } = r;
1871
- if (Nn(), Sn(), !e) try {
1872
- let { methodresult: e, logoutUrl: t } = await jn();
1873
- if (e === "ok") return t;
1874
- b("logout failed");
1875
- } catch (e) {
1876
- b("logout failed", e);
1877
- }
1878
- }
1879
- function Nn() {
1880
- l("csrfToken"), f("sinequa-credentials"), wn(!1), e(!1);
1881
- }
1882
- //#endregion
1883
- //#region src/authentication/session/user-authentication.ts
1884
- var Pn = () => !!$() || Tn();
1885
- //#endregion
1886
- export { bt as $, Me as $t, Xt as A, F as At, zt as B, O as Bt, sn as C, ae as Cn, R as Ct, nn as D, t as Dn, We as Dt, rn as E, i as En, Ge as Et, Gt as F, Be as Ft, kt as G, Le as Gt, At as H, D as Ht, Vt as I, M as It, Ct as J, je as Jt, Ot as K, Ie as Kt, Ht as L, j as Lt, q as M, P as Mt, Jt as N, Ve as Nt, Qt as O, n as On, Ue as Ot, qt as P, N as Pt, xt as Q, Fe as Qt, Ut as R, ze as Rt, cn as S, ne as Sn, z as St, tn as T, r as Tn, Ke as Tt, Rt as U, E as Ut, Bt as V, Re as Vt, Dt as W, T as Wt, Tt as X, Pe as Xt, wt as Y, Ne as Yt, St as Z, ke as Zt, mn as _, m as _n, $e as _t, On as a, _ as an, ut as at, ln as b, re as bn, Je as bt, Q as c, y as cn, ot as ct, vn as d, Ce as dn, st as dt, Ae as en, K as et, _n as f, ye as fn, ft, fn as g, xe as gn, H as gt, hn as h, be as hn, V as ht, jn as i, De as in, lt as it, Yt as j, He as jt, Zt as k, e as kn, I as kt, Z as l, Te as ln, ct as lt, pn as m, p as mn, rt as mt, Nn as n, Oe as nn, gt as nt, En as o, b as on, it as ot, gn as p, Se as pn, nt as pt, Et as q, S as qt, Mn as r, Ee as rn, dt as rt, $ as s, v as sn, at as st, Pn as t, C as tn, ht as tt, X as u, we as un, U as ut, dn as v, se as vn, B as vt, an as w, te as wn, L as wt, on as x, ie as xn, qe as xt, un as y, ee as yn, Ye as yt, Wt as z, k as zt };