@gandalan/weblibs 2.0.9 → 2.0.11

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.
@@ -70,6 +70,7 @@
70
70
  * @property {string | null} [parent] - Parent menu item (optional). If not set, the item will be added to the top level menu.
71
71
  * @property {boolean} [hidden] - If true, the menu item will not be displayed
72
72
  * @property {boolean} [separator] - If true, renders as a non-interactive divider between items (text/icon/url are ignored). Use `parent` to place the separator inside a sub-menu.
73
+ * @property {boolean} [heading] - If true, renders `text` as a non-interactive group heading inside a sub-menu (ALL CAPS, bold, extra space above; icon/url are ignored). Requires `parent`; ignored on the top level. `text` is translated like any other entry.
73
74
  * @property {string} [i18nNamespace] - Catalog in which `text` is translated. Set automatically to the registering module's name; only pass it explicitly for items added outside `setup`. See `NeherApp3I18n`.
74
75
  */
75
76
 
@@ -268,6 +269,92 @@
268
269
  * @property {NeherApp3LocaleInfo[]} locales - Languages offered by the shell.
269
270
  */
270
271
 
272
+ /**
273
+ * Settings handle of a single namespace — what
274
+ * `neherapp3.settings.register("my-module")` returns.
275
+ * @typedef {Object} NeherApp3SettingsHandle
276
+ * @property {string} namespace - The bound namespace (lower case).
277
+ * @property {(key: string, fallback?: any) => any} get - Value of a setting, or `fallback`. Reactive.
278
+ * @property {(key: string, value: unknown) => void} set - Store a value: applied locally at once, sent to the server coalesced.
279
+ * @property {(key: string) => void} remove - Drop a setting; the user is back to its default.
280
+ * @property {() => Record<string, unknown>} all - All settings of this namespace.
281
+ * @property {() => Promise<void>} flush - Write pending changes now. Call before a reload.
282
+ */
283
+
284
+ /**
285
+ * User settings, exposed at `neherapp3.settings`.
286
+ *
287
+ * The store is the **database**, not `localStorage`: inside the i3 WebView
288
+ * `localStorage` is ephemeral and would lose every setting on each start. A
289
+ * setting is addressed by namespace and key, both lower case; `shell` belongs
290
+ * to the framework, every module uses its own namespace — the same one it uses
291
+ * for `i18n.register`. Values are arbitrary JSON.
292
+ *
293
+ * Reads are reactive. Writes are applied locally at once and sent to the
294
+ * server after a short coalescing delay, so call `flush()` before a reload.
295
+ * @typedef {Object} NeherApp3Settings
296
+ * @property {string} scope - Namespace of the framework (`"shell"`).
297
+ * @property {boolean} loaded - `true` once the values from the database have arrived.
298
+ * @property {(namespace: string) => NeherApp3SettingsHandle} register - Settings handle bound to a module's namespace.
299
+ * @property {(scope: string, key: string, fallback?: any) => any} get - Value of a setting, or `fallback`. Reactive.
300
+ * @property {(scope: string, key: string, value: unknown) => void} set - Store a value.
301
+ * @property {(scope: string, key: string) => void} remove - Drop a setting.
302
+ * @property {(scope: string) => Record<string, unknown>} all - All settings of one namespace.
303
+ * @property {() => Promise<void>} flush - Write pending changes now. Call before a reload.
304
+ */
305
+
306
+ /**
307
+ * The profile of *another* user, as returned by `profile.byEmail` and friends.
308
+ *
309
+ * Identity comes from the platform's user table — whoever has signed in here at
310
+ * least once; the remaining fields are filled in only where that user curated
311
+ * them.
312
+ * @typedef {Object} NeherApp3PublicProfile
313
+ * @property {string} userId - The user's `benutzerGuid`.
314
+ * @property {string} userName - Login name.
315
+ * @property {string} email - E-mail address.
316
+ * @property {string | null} displayName - Self-chosen name shown in the interface.
317
+ * @property {string | null} initials - Self-chosen initials, up to 3 characters.
318
+ * @property {string | null} jobTitle - Job title / function.
319
+ * @property {string | null} department - Department.
320
+ * @property {string | null} location - Site / plant.
321
+ * @property {string | null} mobile - Mobile number.
322
+ * @property {string | null} avatar - The avatar as a data URL, or `null` when none is stored.
323
+ * @property {string | null} avatarUpdatedAt - When the avatar was last uploaded.
324
+ */
325
+
326
+ /**
327
+ * The signed-in user, exposed at `neherapp3.profile`.
328
+ *
329
+ * Two sources in one place: identity comes from the IDAS token (user id, login
330
+ * name, e-mail, roles, rights), the remaining fields from the platform's own
331
+ * profile table — above all the avatar, which IDAS does not carry.
332
+ *
333
+ * Read-only and reactive: the local fields arrive shortly after start and are
334
+ * edited in the framework's settings, not by a module. The same object carries
335
+ * the lookup of *other* users' profiles (`byEmail`, `byEmails`, `byUserId`) —
336
+ * the way to put a name and a face next to a user id in a list.
337
+ * @typedef {Object} NeherApp3Profile
338
+ * @property {string} userId - `benutzerGuid` from the token.
339
+ * @property {string} userName - Login name (`id` claim).
340
+ * @property {string} email - E-mail address from the token.
341
+ * @property {string[]} roles - Roles from the token.
342
+ * @property {string[]} rights - Rights from the token.
343
+ * @property {string} displayName - Best available name: the self-chosen one, otherwise the token's.
344
+ * @property {string} initials - Up to 3 characters: self-chosen, otherwise derived from the name.
345
+ * @property {string | null} avatar - The avatar as a data URL, or `null` when none is stored.
346
+ * @property {string | null} jobTitle - Job title / function.
347
+ * @property {string | null} department - Department.
348
+ * @property {string | null} location - Site / plant.
349
+ * @property {string | null} mobile - Mobile number (IDAS carries only one phone number).
350
+ * @property {boolean} loaded - `true` once the local profile has been fetched.
351
+ * @property {() => Promise<void>} reload - Fetch the local profile again.
352
+ * @property {(email: string) => Promise<NeherApp3PublicProfile | null>} byEmail - The profile of another user by e-mail address; `null` when this platform does not know them. Calls made close together are coalesced into one request and cached for the session.
353
+ * @property {(emails: string[]) => Promise<NeherApp3PublicProfile[]>} byEmails - The profiles of several users; unknown addresses are absent from the result.
354
+ * @property {(userId: string) => Promise<NeherApp3PublicProfile | null>} byUserId - The profile of another user by their `benutzerGuid`.
355
+ * @property {() => void} clearCache - Discard the cached profiles, so the next lookup asks again.
356
+ */
357
+
271
358
  /**
272
359
  * @typedef {Object} NeherApp3
273
360
  * @property {(menuItem: NeherApp3MenuItem) => void} addMenuItem - Adds a menu item. If an item with the same `id` already exists it is replaced.
@@ -280,6 +367,8 @@
280
367
  * @property {NeherApp3Messages} messages - In-realm message bus for module-to-module communication.
281
368
  * @property {NeherApp3I18n} i18n - Localization: register a module's translation catalog, translate, switch language, sort language-aware.
282
369
  * @property {Localize} localize - Shorthand for `i18n.localize` (namespace `shell`): a function for strings, a `use:` action for elements.
370
+ * @property {NeherApp3Settings} settings - Per-user settings, stored in the database (not `localStorage`).
371
+ * @property {NeherApp3Profile} profile - The signed-in user: identity from the IDAS token plus the platform's own profile fields (avatar, job title, …).
283
372
  * @property {boolean} isEmbedded - Indicates if the app is embedded inside i3
284
373
  */
285
374
 
package/index.d.ts CHANGED
@@ -2077,6 +2077,8 @@ export type NeherApp3 = {
2077
2077
  messages: NeherApp3Messages;
2078
2078
  i18n: NeherApp3I18n;
2079
2079
  localize: Localize;
2080
+ settings: NeherApp3Settings;
2081
+ profile: NeherApp3Profile;
2080
2082
  isEmbedded: boolean;
2081
2083
  };
2082
2084
 
@@ -2142,6 +2144,7 @@ export type NeherApp3MenuItem = {
2142
2144
  parent?: string | null;
2143
2145
  hidden?: boolean;
2144
2146
  separator?: boolean;
2147
+ heading?: boolean;
2145
2148
  i18nNamespace?: string;
2146
2149
  };
2147
2150
 
@@ -2165,6 +2168,27 @@ export type NeherApp3Module = {
2165
2168
 
2166
2169
  export type NeherApp3NotifyType = 0 | 1 | 2;
2167
2170
 
2171
+ export type NeherApp3Profile = {
2172
+ userId: string;
2173
+ userName: string;
2174
+ email: string;
2175
+ roles: string[];
2176
+ rights: string[];
2177
+ displayName: string;
2178
+ initials: string;
2179
+ avatar: string | null;
2180
+ jobTitle: string | null;
2181
+ department: string | null;
2182
+ location: string | null;
2183
+ mobile: string | null;
2184
+ loaded: boolean;
2185
+ reload: () => Promise<void>;
2186
+ byEmail: (email: string) => Promise<NeherApp3PublicProfile | null>;
2187
+ byEmails: (emails: string[]) => Promise<NeherApp3PublicProfile[]>;
2188
+ byUserId: (userId: string) => Promise<NeherApp3PublicProfile | null>;
2189
+ clearCache: () => void;
2190
+ };
2191
+
2168
2192
  export type NeherApp3Props = {
2169
2193
  api: FluentApi;
2170
2194
  authManager?: FluentAuthManager;
@@ -2172,6 +2196,40 @@ export type NeherApp3Props = {
2172
2196
  mainCssPath?: string;
2173
2197
  };
2174
2198
 
2199
+ export type NeherApp3PublicProfile = {
2200
+ userId: string;
2201
+ userName: string;
2202
+ email: string;
2203
+ displayName: string | null;
2204
+ initials: string | null;
2205
+ jobTitle: string | null;
2206
+ department: string | null;
2207
+ location: string | null;
2208
+ mobile: string | null;
2209
+ avatar: string | null;
2210
+ avatarUpdatedAt: string | null;
2211
+ };
2212
+
2213
+ export type NeherApp3Settings = {
2214
+ scope: string;
2215
+ loaded: boolean;
2216
+ register: (namespace: string) => NeherApp3SettingsHandle;
2217
+ get: (scope: string, key: string, fallback?: any) => any;
2218
+ set: (scope: string, key: string, value: unknown) => void;
2219
+ remove: (scope: string, key: string) => void;
2220
+ all: (scope: string) => Record<string, unknown>;
2221
+ flush: () => Promise<void>;
2222
+ };
2223
+
2224
+ export type NeherApp3SettingsHandle = {
2225
+ namespace: string;
2226
+ get: (key: string, fallback?: any) => any;
2227
+ set: (key: string, value: unknown) => void;
2228
+ remove: (key: string) => void;
2229
+ all: () => Record<string, unknown>;
2230
+ flush: () => Promise<void>;
2231
+ };
2232
+
2175
2233
  export type NeherApp3SetupContext = NeherApp3Props & { neherapp3: NeherApp3 };
2176
2234
 
2177
2235
  export type NeherMessage = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "WebLibs for Gandalan JS/TS projects",
5
5
  "keywords": [
6
6
  "gandalan"