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