UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.17 kB
import{r as e}from"./openclaw-state-read-semver-CqfGj9gv.mjs";import{f as t,v as n}from"./openclaw-state-read-home-dir-BQZX1pD2.mjs";import{d as r}from"./openclaw-state-read-openclaw-state-db-cache-BVY8IYkn.mjs";import{a as i}from"./openclaw-state-read-record-coerce-D1s3ReAs.mjs";import"./openclaw-state-read-sqlite-post-commit-CEHMNIsB.mjs";import{a,i as o,o as s,r as c}from"./openclaw-state-read-kysely-sync-DQyYiAw5.mjs";import{o as l}from"./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs";import{t as u}from"./openclaw-state-read-openclaw-state-feature-schema-ensure-xUv2B99F.mjs";import"./openclaw-state-read-user-profile-events-DvdEKDEH.mjs";import"node:util";function parseSidebarSessionReference(e){if(typeof e!=`string`)return null;let t=e.startsWith(`session:`)?`session:`:e.startsWith(`session-rail:`)?`session-rail:`:null;return t&&e.slice(t.length).trim()||null}u({table:`user_background_images`,operationLabel:`users.background.schema.ensure`});function readUserBackgroundImage(e,t,n){if(l(e,`user_background_images`))return o(e,a(e).selectFrom(`user_background_images`).selectAll().where(`profile_id`,`=`,t).where(`asset_id`,`=`,n))}function readUserBackgroundAsset(e,t){if(l(e,`user_background_images`))return o(e,a(e).selectFrom(`user_background_images`).select([`asset_id`,`width`,`height`]).select(e=>e.fn(`length`,[`image`]).as(`byte_length`)).where(`profile_id`,`=`,t))}n(Symbol.for(`openclaw.userPreferences.publications`),()=>{let e=/* @__PURE__ */ new Map;return r(t=>{t.kind!==`opened`&&t.identity&&e.delete(t.identity.key)}),e});var d=/* @__PURE__ */ e({readUserPreferences:()=>readUserPreferences,selectPersonalPinnedSessionKeys:()=>selectPersonalPinnedSessionKeys,selectUserPreferenceValues:()=>selectUserPreferenceValues});const f=[`ui.railShortcuts`,`ui.personalSessionGroups`];u({table:`user_preferences`,operationLabel:`users.preferences.schema.ensure`});function selectUserPreferenceValues(e,t,n){if(t.length===0||!l(e,`user_preferences`))return/* @__PURE__ */ new Map;let r=c(e,a(e).selectFrom(`user_preferences`).select([`profile_id`,`value_json`]).where(`profile_id`,`in`,[...t]).where(`pref_key`,`=`,n)).rows;return new Map(r.map(e=>[e.profile_id,JSON.parse(e.value_json)]))}function selectPersonalPinnedSessionKeys(e){if(!l(e,`user_preferences`))return[];let n=/* @__PURE__ */ new Set,r=a(e);for(let a of s(e,r.selectFrom(`user_preferences`).select([`pref_key`,`value_json`]).where(`pref_key`,`in`,f))){let e=JSON.parse(a.value_json);if(Array.isArray(e)){if(a.pref_key===`ui.personalSessionGroups`){for(let r of e)if(i(r)&&Array.isArray(r.sessionKeys))for(let e of r.sessionKeys){let r=t(e);r&&n.add(r)}}else for(let t of e){let e=parseSidebarSessionReference(t);e&&n.add(e)}}}return[...n].toSorted()}function readUserPreferences(e,t,n){if(n?.length===0)return{};let r=a(e).selectFrom(`user_preferences`).select([`pref_key`,`value_json`]).where(`profile_id`,`=`,t).orderBy(`pref_key`,`asc`);return n&&(r=r.where(`pref_key`,`in`,[...n])),Object.fromEntries(c(e,r).rows.map(e=>[e.pref_key,JSON.parse(e.value_json)]))}export{readUserBackgroundImage as i,d as n,readUserBackgroundAsset as r,readUserPreferences as t};