UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.12 kB
import{n as e}from"./openclaw-state-read-rolldown-runtime-C7TU3oOp.mjs";import{Cn as t,gn as n,xt as r}from"./openclaw-state-read-subsystem-Dwoo5bcz.mjs";import{d as i}from"./openclaw-state-read-openclaw-state-db-cache-DyomEqgV.mjs";import"./openclaw-state-read-sqlite-post-commit-CsXPYVOo.mjs";import{a,i as o,o as s,r as c}from"./openclaw-state-read-kysely-sync-Bcu0Qb7F.mjs";import{o as l}from"./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs";import{t as u}from"./openclaw-state-read-openclaw-state-feature-schema-ensure-BXxkFsiE.mjs";import"./openclaw-state-read-user-profile-events-D1aryhLR.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))}t(Symbol.for(`openclaw.userPreferences.publications`),()=>{let e=/* @__PURE__ */ new Map;return i(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 t=/* @__PURE__ */ new Set,i=a(e);for(let a of s(e,i.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 i of e)if(r(i)&&Array.isArray(i.sessionKeys))for(let e of i.sessionKeys){let r=n(e);r&&t.add(r)}}else for(let n of e){let e=parseSidebarSessionReference(n);e&&t.add(e)}}}return[...t].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};