Normalization helpers

The normalization helpers are exported from the package root so consumers and tests can reuse the exact same logic the library uses internally. All are pure functions: any input shape in, one normalized shape out, no side effects.

1. Main-type constants

MAIN_TYPE_FOLDER   // 0
MAIN_TYPE_REGISTER // 99

The two well-known mainType values (everything else is a document). See SelectedEntry for how mainType is computed.

2. Selection caps

MAX_SELECTION_RAW_LENGTH  // 65 536 characters
MAX_SELECTION_ENTRIES     // 10 000 entries

The rich-client selection string is parsed under these bounds (bounded parsing): a raw string over the length cap or a parsed result over the entry cap is treated as unreadable — the normalized selection is empty and nothing is thrown. The length cap is checked first so the split never runs on hostile input.

3. Functions

Function Behavior

parseRichClientSelectionString(raw)

Parses the raw rich-client selection string ("osid,objectTypeId;…") into SelectedEntry[]; empty input → []. Phantom entries (osid 0 with type 0 or null) are dropped; malformed id parts produce entries with osid null, which the rich-client paths that consume them (init and getSelectedObjects) filter out; typeless documents carry the -1 type marker. Over-cap input → [], no throw.

normalizeEntry(osid, objectTypeId, declaredMainType?)

Normalizes one raw id/type pair into a SelectedEntry (webclient entries); the declared main type is used only when no type ID is present.

normalizeLocation(fields)

Derives the enclosing LocationInfo from raw rich-client location fields (folderid/foldertype, registerid/registertype); the register wins over the folder; absent/zero ids → null (root).

normalizeSession(raw, env?)

Extracts the session block (SessionInfo) from a raw payload (either host shape), falling back to the environment info where the payload is silent.

normalizeUser(raw, env?)

Extracts the user block (UserInfo) from a raw payload, with the same environment fallback.

normalizeWebclientPayload(raw, environment?)

Normalizes a webclient event payload (onInit/onUpdate data) into an InitContext; the environment is confirmed from sessionInfo.clientType.

normalizeRichClientPayload(raw, selectedEntries, envInfo?)

Normalizes a rich-client raw payload (all-string field set) into an InitContext. In the self-init path (no host callback yet) pass null or {} as raw and fill the user/session data from envInfo.

4. RichEnvironmentInfo

The fields derivable from osjxGetEnvironment(n) reads (self-init path):

Field Slot Meaning

version

10

Client version (may carry a trailing space)

language

—

GUI language short code (de, en, fr, …)

userName

3

User login name

fullName

14

Full user name

email

16

User e-mail

userGuid

18

User GUID

sessionId

27

Current session GUID