@sinequa/atomic-angular 1.14.1 → 1.15.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.
@@ -1,9 +1,14 @@
1
- import { UpdateContainerInput } from '@sinequa/atomic';
1
+ import { UpdateContainerInput, UploadJobStatus } from '@sinequa/atomic';
2
2
  import { EnvironmentProviders } from '@angular/core';
3
3
 
4
- type TooltipPlacement = 'top' | 'right' | 'left' | 'bottom';
4
+ type TooltipPlacement = "top" | "right" | "left" | "bottom";
5
5
  interface TooltipController {
6
- attach(el: HTMLElement, text: string, placement?: TooltipPlacement, condition?: () => boolean): void;
6
+ /**
7
+ * Shows a tooltip on hover. `key` is a catalog key, not literal text, and is
8
+ * resolved on every hover — so a tooltip attached once still follows a later
9
+ * language change without re-attaching anything.
10
+ */
11
+ attach(el: HTMLElement, key: string, placement?: TooltipPlacement, condition?: () => boolean): void;
7
12
  position(trigger: HTMLElement, placement?: TooltipPlacement): void;
8
13
  el: HTMLSpanElement;
9
14
  }
@@ -12,7 +17,7 @@ interface MobileSheetController {
12
17
  close(): void;
13
18
  }
14
19
 
15
- type ContainerRole = 'creator' | 'owner' | 'reader';
20
+ type ContainerRole = "creator" | "owner" | "reader";
16
21
  interface Collection {
17
22
  id: string;
18
23
  name: string;
@@ -24,7 +29,6 @@ interface Collection {
24
29
  ownerIds: string[];
25
30
  readerIds: string[];
26
31
  currentUserRole: ContainerRole;
27
- favorited: boolean;
28
32
  }
29
33
  interface CollectionDocument {
30
34
  _id: string;
@@ -34,8 +38,10 @@ interface CollectionDocument {
34
38
  date: string;
35
39
  size?: string;
36
40
  source?: string;
37
- status?: 'uploading' | 'indexing' | 'error' | null;
41
+ status?: "uploading" | "indexing" | "error" | null;
38
42
  uploadedBy?: string;
43
+ percent?: number;
44
+ jobId?: string;
39
45
  }
40
46
  declare class CollectionsStore extends EventTarget {
41
47
  collections: Collection[];
@@ -52,12 +58,15 @@ declare class CollectionsStore extends EventTarget {
52
58
  fetchContainer(id: string): Promise<Collection>;
53
59
  get hasMoreCollections(): boolean;
54
60
  ensureLoaded(): Promise<Collection[]>;
61
+ reload(): Promise<Collection[]>;
55
62
  load(): Promise<Collection[]>;
56
63
  loadMore(): Promise<Collection[]>;
57
- create({ name, desc, tags }: {
64
+ create({ name, desc, tags, owners, readers }: {
58
65
  name: string;
59
66
  desc?: string;
60
67
  tags?: string[];
68
+ owners?: string[];
69
+ readers?: string[];
61
70
  }): Promise<Collection>;
62
71
  update(id: string, patch: UpdateContainerInput): Promise<Collection | null>;
63
72
  remove(ids: string[]): Promise<{
@@ -67,7 +76,6 @@ declare class CollectionsStore extends EventTarget {
67
76
  error: string;
68
77
  }[];
69
78
  }>;
70
- toggleFavorite(id: string): boolean | undefined;
71
79
  getDocuments(collectionId: string): CollectionDocument[];
72
80
  hasMoreDocuments(collectionId: string): boolean;
73
81
  loadDocuments(collectionId: string): Promise<CollectionDocument[]>;
@@ -86,23 +94,73 @@ interface TrackerFileInput {
86
94
  name: string;
87
95
  type: string;
88
96
  }
97
+ /**
98
+ * What the tracker's connection banner is currently saying. Emitted whenever the
99
+ * situation changes, and `null` once everything is healthy again.
100
+ */
101
+ interface ConnectionNotice {
102
+ /**
103
+ * - `retrying` - a transfer is waiting out `retryAtMs` before its next attempt;
104
+ * - `reconnecting` - a session recovery is in flight;
105
+ * - `signed-out` - recovery came back negative; nothing moves until the user
106
+ * signs in again.
107
+ */
108
+ phase: "retrying" | "reconnecting" | "signed-out";
109
+ /** Transfers held up by this. 0 when only the status poll is affected. */
110
+ uploads: number;
111
+ /** 1-based number of the attempt about to be made, and the budget it comes from. */
112
+ attempt: number;
113
+ maxAttempts: number;
114
+ /** Epoch ms of the next attempt - the countdown's target (`retrying` only). */
115
+ retryAtMs?: number;
116
+ /** Epoch ms at which the retry budget runs out (`retrying` only). */
117
+ budgetEndsAtMs?: number;
118
+ /** Epoch ms the connection was first reported lost - drives "lost N ago". */
119
+ sinceMs: number;
120
+ /**
121
+ * Re-runs the recovery, for the banner's Retry button. Carried on the payload
122
+ * rather than published as another controller method because it is the one
123
+ * thing the banner can DO, and it is meaningless without the notice it belongs
124
+ * to. Absent when there is nothing useful to retry.
125
+ */
126
+ retry?(): void;
127
+ }
89
128
  interface UploadTrackerController {
90
129
  addFiles(trackerDocs: TrackerFileInput[], colId: string, colName: string): void;
91
130
  onProgress(docId: string, pct: number): void;
92
131
  onIndexing(docId: string): void;
93
132
  onComplete(docId: string): void;
94
133
  onError(docId: string): void;
134
+ /**
135
+ * Feeds in the job-level half of the status API: per-file error messages and
136
+ * rejections, which only `GET .../document-upload/status` reports.
137
+ *
138
+ * Optional on purpose - this interface is published from index.ts and driven
139
+ * by hand by the demo app's /document-upload tester, so a required method
140
+ * would be a breaking change for it. Returns whether anything actually
141
+ * changed, which paces the poller; `void` is accepted so an implementation
142
+ * that does not care still satisfies the type.
143
+ */
144
+ onJobUpdate?(jobs: UploadJobStatus[]): boolean | void;
145
+ /**
146
+ * Drives the connection banner. `null` clears it.
147
+ *
148
+ * Optional for the same reason as `onJobUpdate` - this interface is published
149
+ * from index.ts and driven by hand by the demo app's /document-upload tester.
150
+ */
151
+ onConnectionChange?(notice: ConnectionNotice | null): void;
95
152
  }
96
153
 
97
154
  interface CollectionsHost extends HTMLElement {
98
155
  readonly shadowRoot: ShadowRoot;
99
156
  _pickerContainer: HTMLDivElement;
100
157
  _tooltip: TooltipController;
101
- _colCurrentView: 'grid' | 'list';
158
+ _colCurrentView: "grid" | "list";
102
159
  _colGridBuilt: boolean;
103
160
  _colListBuilt: boolean;
104
161
  _showList(): Promise<void>;
105
162
  _hideList(): void;
163
+ _refreshList?(): Promise<void>;
106
164
  _buildCollectionCard(col: Collection): HTMLElement;
107
165
  _updateColTabCounts(): void;
108
166
  _applyColFilters?(): void;
@@ -111,7 +169,7 @@ interface CollectionsHost extends HTMLElement {
111
169
  _closeColDeleteModal(): void;
112
170
  _currentCol: Collection | null;
113
171
  _currentDocs: CollectionDocument[];
114
- _cdvCurrentView: 'grid' | 'list';
172
+ _cdvCurrentView: "grid" | "list";
115
173
  _cdvListBuilt: boolean;
116
174
  _openColDetail(col: Collection): void;
117
175
  _closeColDetail(): void;
@@ -125,6 +183,8 @@ interface CollectionsHost extends HTMLElement {
125
183
  _closeColDocPreview(): void;
126
184
  _syncColDocPreviewView(): void;
127
185
  _uploadTracker: UploadTrackerController;
186
+ _startUploadPolling?(): void;
187
+ _stopUploadPolling?(): void;
128
188
  }
129
189
 
130
190
  interface Passage {
@@ -143,7 +203,7 @@ declare class LexiqCollectionsElement extends HTMLElement implements Collections
143
203
  _initialized: boolean;
144
204
  _pickerContainer: HTMLDivElement;
145
205
  _tooltip: TooltipController;
146
- _colCurrentView: 'grid' | 'list';
206
+ _colCurrentView: "grid" | "list";
147
207
  _colGridBuilt: boolean;
148
208
  _colListBuilt: boolean;
149
209
  _showList: () => Promise<void>;
@@ -155,7 +215,7 @@ declare class LexiqCollectionsElement extends HTMLElement implements Collections
155
215
  _closeColDeleteModal: () => void;
156
216
  _currentCol: Collection | null;
157
217
  _currentDocs: CollectionDocument[];
158
- _cdvCurrentView: 'grid' | 'list';
218
+ _cdvCurrentView: "grid" | "list";
159
219
  _cdvListBuilt: boolean;
160
220
  _openColDetail: (col: Collection) => void;
161
221
  _closeColDetail: () => void;
@@ -167,8 +227,11 @@ declare class LexiqCollectionsElement extends HTMLElement implements Collections
167
227
  _closeColDocPreview: () => void;
168
228
  _syncColDocPreviewView: () => void;
169
229
  _uploadTracker: UploadTrackerController;
230
+ _startUploadPolling?: () => void;
231
+ _stopUploadPolling?: () => void;
170
232
  constructor();
171
233
  connectedCallback(): void;
234
+ disconnectedCallback(): void;
172
235
  showList(): Promise<void>;
173
236
  hideList(): void;
174
237
  showDetail(collectionId: string): Promise<void>;
@@ -178,7 +241,7 @@ declare class LexiqCollectionsElement extends HTMLElement implements Collections
178
241
  get collections(): Collection[];
179
242
  }
180
243
 
181
- type IncomingDocument = Partial<Pick<CollectionDocument, '_id'>> & Omit<CollectionDocument, '_id'>;
244
+ type IncomingDocument = Partial<Pick<CollectionDocument, "_id">> & Omit<CollectionDocument, "_id">;
182
245
  interface PickerOptions {
183
246
  mobileSheet?: MobileSheetController | null;
184
247
  root?: ShadowRoot | null;
@@ -196,6 +259,7 @@ declare class LexiqCollectionPickerElement extends HTMLElement {
196
259
  private _container;
197
260
  constructor();
198
261
  connectedCallback(): void;
262
+ disconnectedCallback(): void;
199
263
  private _withEvents;
200
264
  openSaveCard(anchorEl: HTMLElement, opts?: Partial<PickerOptions>): void;
201
265
  closeSaveCard(anchorEl?: HTMLElement | null): void;
@@ -232,9 +296,38 @@ declare function defineLexiqCollectionPicker(tagName?: string): void;
232
296
  declare function defineLexiqCollectionMentionList(tagName?: string): void;
233
297
  declare function registerLexiqCollectionsElements(): void;
234
298
 
299
+ /** Values substituted into `{placeholder}` slots of a catalog entry. */
300
+ type TranslateParams = Record<string, string | number>;
301
+ /**
302
+ * Resolves a catalog key (unscoped, e.g. `list.title`) against the host's
303
+ * translation engine. Returns `undefined` when the host cannot resolve the
304
+ * key, which makes the bundled English catalog take over.
305
+ */
306
+ type Translator = (key: string, params?: TranslateParams) => string | undefined;
307
+ /** The active BCP 47 language tag, for `Intl` formatters used across the views. */
308
+ declare function getLang(): string;
309
+ /**
310
+ * Installs the host's translation engine and language, then re-translates every
311
+ * connected element in place. Call it again on every language change.
312
+ *
313
+ * @param next - Resolver for catalog keys, or null to return to bundled English.
314
+ * @param lang - BCP 47 tag of the language `next` resolves into.
315
+ */
316
+ declare function setTranslator(next: Translator | null, lang: string): void;
317
+ /**
318
+ * Switches the language used for plural selection and `Intl` formatting, and
319
+ * re-translates connected elements. Prefer {@link setTranslator}; this is for
320
+ * hosts that translate through a resolver whose language changes behind it.
321
+ *
322
+ * @param lang - BCP 47 tag, e.g. `fr` or `fr-FR`.
323
+ */
324
+ declare function setLang(lang: string): void;
325
+
235
326
  /**
236
327
  * Registers the LexiQ Collections native Custom Elements when the Angular
237
- * application environment initializes. Add to an app/route `providers` array:
328
+ * application environment initializes, and — when the host app uses Transloco —
329
+ * bridges its translations into the elements. Add to an app/route `providers`
330
+ * array:
238
331
  *
239
332
  * ```ts
240
333
  * export const appConfig: ApplicationConfig = {
@@ -243,8 +336,11 @@ declare function registerLexiqCollectionsElements(): void;
243
336
  * ```
244
337
  *
245
338
  * Components using the tags still need `schemas: [CUSTOM_ELEMENTS_SCHEMA]`.
339
+ *
340
+ * Transloco is optional: without it the elements fall back to their bundled
341
+ * English catalog, which is why nothing under `internal/` imports it.
246
342
  */
247
343
  declare function provideLexiqCollectionsElements(): EnvironmentProviders;
248
344
 
249
- export { LexiqCollectionMentionListElement, LexiqCollectionPickerElement, LexiqCollectionsElement, store as collectionsStore, defineLexiqCollectionMentionList, defineLexiqCollectionPicker, defineLexiqCollections, provideLexiqCollectionsElements, registerLexiqCollectionsElements };
250
- export type { Collection, CollectionDocument, ContainerRole, PickerOptions, RefDocument };
345
+ export { LexiqCollectionMentionListElement, LexiqCollectionPickerElement, LexiqCollectionsElement, store as collectionsStore, defineLexiqCollectionMentionList, defineLexiqCollectionPicker, defineLexiqCollections, getLang, provideLexiqCollectionsElements, registerLexiqCollectionsElements, setLang, setTranslator };
346
+ export type { Collection, CollectionDocument, ConnectionNotice, ContainerRole, PickerOptions, RefDocument, TranslateParams, Translator, UploadTrackerController };