@sinequa/atomic

User profile

The business profile — job title, organisation, skills — which is a different store from user settings, with a per-property API.

Not to be confused with user settings. Settings are the user's preferences; the profile is their identity in the organisation — the information an expert-finder or a people directory displays.

SettingsProfile
APIv1 usersettingsv2 user-profile
ShapeFree-form, extended by youDeclared: data + customData
WrittenWhole object, or mergedOne property at a time
HoldsPage size, saved searchesJob title, organisation, location, skills

The per-property API

The write calls are unusual: they address a single property, by category and name, rather than sending an object.

Prop

Type

A UserProfile is { data: UserProfileData, customData?, created?, modified? }. data declares id, mail, fullName, and the optional jobTitle, group, organisation, location, profilePhoto and skills. customData is the free-form part.

Reading and editing a profile

Show a profile, edit one field
src/profile.ts
import { createAtomicClient } from "@sinequa/atomic";
import type { UserProfile } from "@sinequa/atomic";

const client = createAtomicClient({
  app: "<your-app>",
  backendUrl: "https://<your-sinequa-server>",
});

await client.initializeConfig();
await client.auth.login();

// A profile belongs to a user id — usually the signed-in one to start with.
const principal = await client.api.principal.get();
const profile: UserProfile = await client.api.userProfile.get(principal.id);

console.log(profile.data.fullName, profile.data.jobTitle ?? "(no job title)");

/**
 * Updates one property. The request URL is built from `profile.data.id`, so the
 * object you pass must carry it — passing only the changed field fails.
 */
export async function setJobTitle(profile: UserProfile, jobTitle: string) {
  return client.api.userProfile.patch(
    { data: { ...profile.data, jobTitle } },
    "data",
    "jobTitle",
  );
}

export async function clearJobTitle(profile: UserProfile) {
  return client.api.userProfile.deleteProperty(
    { data: profile.data },
    "data",
    "jobTitle",
  );
}

Pitfalls

What's next

On this page